brass-runtime 1.15.0 → 1.16.0
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 +409 -137
- package/dist/agent/cli/main.cjs +40 -35
- package/dist/agent/cli/main.js +9 -4
- package/dist/agent/cli/main.mjs +9 -4
- package/dist/agent/index.cjs +8 -4
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +7 -3
- package/dist/agent/index.mjs +7 -3
- package/dist/{chunk-PPUXIH5R.js → chunk-2WC63LJK.mjs} +11 -7
- package/dist/chunk-3RG5ZIWI.js +10 -0
- package/dist/chunk-45F7OKGT.cjs +104 -0
- package/dist/chunk-5YOQOXEQ.cjs +2491 -0
- package/dist/{chunk-STVLQ3XD.cjs → chunk-7HUOJA4W.cjs} +78 -74
- package/dist/{chunk-BMH5AV44.js → chunk-7LVI2GIN.js} +251 -370
- package/dist/chunk-7TL2LHQJ.js +2491 -0
- package/dist/chunk-7V4KY4RL.mjs +104 -0
- package/dist/chunk-7XOPAB5Q.js +2143 -0
- package/dist/chunk-CCKHV5BT.mjs +193 -0
- package/dist/{chunk-AR22SXML.js → chunk-CY33PGEX.mjs} +488 -421
- package/dist/chunk-DJQ7OMMB.cjs +144 -0
- package/dist/chunk-F5EUMJL7.mjs +2143 -0
- package/dist/chunk-FM4W4QPL.js +193 -0
- package/dist/{chunk-TO7IKXYT.js → chunk-G3XGCZDQ.js} +1 -1
- package/dist/{chunk-BDF4AMWX.mjs → chunk-G6IQOE4P.mjs} +251 -370
- package/dist/chunk-GOV47PPB.mjs +552 -0
- package/dist/chunk-H55LI6WY.js +93 -0
- package/dist/chunk-IJT6RRQ5.cjs +93 -0
- package/dist/{chunk-ELOOF35R.mjs → chunk-J3H54ZRV.mjs} +1 -1
- package/dist/chunk-JF4XXPZ5.cjs +552 -0
- package/dist/chunk-JNFRRJYH.cjs +2143 -0
- package/dist/chunk-JX3LZQJH.cjs +354 -0
- package/dist/chunk-K2T3DV26.mjs +93 -0
- package/dist/chunk-KCPT2D6G.js +552 -0
- package/dist/chunk-MWXMNYJS.cjs +1110 -0
- package/dist/{chunk-VEZNF5GZ.cjs → chunk-N6VHMOWB.cjs} +130 -126
- package/dist/{chunk-3QMOKAS5.js → chunk-NC5SDRYE.js} +9 -5
- package/dist/chunk-NOYZIMUJ.mjs +144 -0
- package/dist/{chunk-R3R2FVLG.cjs → chunk-NYL4D7SK.cjs} +5 -5
- package/dist/chunk-OBGZSXTJ.cjs +10 -0
- package/dist/{chunk-4NHES7VK.mjs → chunk-OOGJ73B6.js} +11 -7
- package/dist/chunk-PNVFW245.js +144 -0
- package/dist/chunk-PRWCB3QL.mjs +2491 -0
- package/dist/{chunk-JFPU5GQI.mjs → chunk-QY5FKYEQ.js} +488 -421
- package/dist/chunk-ROJC3NBJ.js +104 -0
- package/dist/chunk-SPUEME2B.cjs +343 -0
- package/dist/chunk-TDVMADDN.js +343 -0
- package/dist/chunk-TVN5I4U6.cjs +193 -0
- package/dist/chunk-U5KWK3PX.mjs +343 -0
- package/dist/chunk-VFIUZG7J.mjs +354 -0
- package/dist/{chunk-TGIFUAK4.cjs → chunk-WQ5QNU5R.cjs} +459 -578
- package/dist/chunk-XDZOO4L5.js +354 -0
- package/dist/chunk-Y6FXYEAI.mjs +10 -0
- package/dist/{chunk-K6M7MDZ4.mjs → chunk-ZGLD4TVZ.mjs} +9 -5
- package/dist/client-CtFmoDvM.d.ts +645 -0
- package/dist/core/index.cjs +72 -4
- package/dist/core/index.d.ts +92 -198
- package/dist/core/index.js +106 -38
- package/dist/core/index.mjs +106 -38
- package/dist/{effect-CMOQKX8y.d.ts → effect-CGNl5Rqp.d.ts} +107 -1
- package/dist/effectRunner-3ZHAD3LE.cjs +8 -0
- package/dist/effectRunner-A4CHJXJI.js +8 -0
- package/dist/effectRunner-OPUF6QRN.mjs +8 -0
- package/dist/http/index.cjs +2189 -1271
- package/dist/http/index.d.ts +830 -270
- package/dist/http/index.js +2008 -1090
- package/dist/http/index.mjs +2008 -1090
- package/dist/http/testing.cjs +159 -0
- package/dist/http/testing.d.ts +42 -0
- package/dist/http/testing.js +159 -0
- package/dist/http/testing.mjs +159 -0
- package/dist/index.cjs +246 -178
- package/dist/index.d.ts +9 -35
- package/dist/index.js +120 -52
- package/dist/index.mjs +120 -52
- package/dist/observability/index.cjs +677 -0
- package/dist/observability/index.d.ts +79 -0
- package/dist/observability/index.js +677 -0
- package/dist/observability/index.mjs +677 -0
- package/dist/schedule-Fque9Abz.d.ts +70 -0
- package/dist/schema/index.cjs +25 -0
- package/dist/schema/index.d.ts +177 -0
- package/dist/schema/index.js +25 -0
- package/dist/schema/index.mjs +25 -0
- package/dist/server-C8hDXA74.d.ts +674 -0
- package/dist/{stream-FQm9h4Mg.d.ts → stream-dvSs0QS5.d.ts} +1 -1
- package/dist/tracer-B5tRH9H7.d.ts +230 -0
- package/dist/tracing-Dt9S_6V8.d.ts +148 -0
- package/package.json +27 -1
- package/dist/chunk-BDYEENHT.js +0 -224
- package/dist/chunk-MS34J5LY.cjs +0 -224
- package/dist/chunk-UMAZLXAB.mjs +0 -224
- package/dist/chunk-XPZNXSVN.cjs +0 -1043
- package/dist/tracing-DNT9jEbr.d.ts +0 -106
|
@@ -1,121 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17;
|
|
2
|
+
|
|
3
|
+
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
function asyncFold(fa, onFailure, onSuccess) {
|
|
16
|
-
return {
|
|
17
|
-
_tag: "Fold",
|
|
18
|
-
first: fa,
|
|
19
|
-
onFailure,
|
|
20
|
-
onSuccess
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function asyncCatchAll(fa, handler) {
|
|
24
|
-
return asyncFold(fa, handler, asyncSucceed);
|
|
25
|
-
}
|
|
26
|
-
function asyncMapError(fa, f) {
|
|
27
|
-
return asyncFold(fa, (e) => asyncFail(f(e)), asyncSucceed);
|
|
28
|
-
}
|
|
29
|
-
var SUCCEED_UNDEFINED = { _tag: "Succeed", value: void 0 };
|
|
30
|
-
var SUCCEED_TRUE = { _tag: "Succeed", value: true };
|
|
31
|
-
var SUCCEED_FALSE = { _tag: "Succeed", value: false };
|
|
32
|
-
var SUCCEED_NULL = { _tag: "Succeed", value: null };
|
|
33
|
-
var unit = () => SUCCEED_UNDEFINED;
|
|
34
|
-
var asyncSucceed = (value) => {
|
|
35
|
-
if (value === void 0) return SUCCEED_UNDEFINED;
|
|
36
|
-
if (value === true) return SUCCEED_TRUE;
|
|
37
|
-
if (value === false) return SUCCEED_FALSE;
|
|
38
|
-
if (value === null) return SUCCEED_NULL;
|
|
39
|
-
return { _tag: "Succeed", value };
|
|
40
|
-
};
|
|
41
|
-
var asyncFail = (error) => ({
|
|
42
|
-
_tag: "Fail",
|
|
43
|
-
error
|
|
44
|
-
});
|
|
45
|
-
var asyncSync = (thunk) => ({
|
|
46
|
-
_tag: "Sync",
|
|
47
|
-
thunk
|
|
48
|
-
});
|
|
49
|
-
var asyncTotal = (thunk) => asyncSync(() => thunk());
|
|
50
|
-
var asyncEffect = (register) => ({
|
|
51
|
-
_tag: "Async",
|
|
52
|
-
register
|
|
53
|
-
});
|
|
54
|
-
function asyncMap(fa, f) {
|
|
55
|
-
return asyncFlatMap(fa, (a) => asyncSucceed(f(a)));
|
|
56
|
-
}
|
|
57
|
-
function asyncFlatMap(fa, f) {
|
|
58
|
-
return {
|
|
59
|
-
_tag: "FlatMap",
|
|
60
|
-
first: fa,
|
|
61
|
-
andThen: f
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function acquireRelease(acquire, release, scope) {
|
|
65
|
-
return asyncFlatMap(acquire, (resource) => {
|
|
66
|
-
scope.addFinalizer((exit) => release(resource, exit));
|
|
67
|
-
return asyncSucceed(resource);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function asyncInterruptible(register) {
|
|
71
|
-
return asyncEffect(register);
|
|
72
|
-
}
|
|
73
|
-
var withAsyncPromise = (run) => (eff) => {
|
|
74
|
-
const anyEff = eff;
|
|
75
|
-
if (!anyEff.toPromise) {
|
|
76
|
-
anyEff.toPromise = (env) => run(eff, env);
|
|
77
|
-
anyEff.unsafeRunPromise = () => run(eff, {});
|
|
78
|
-
}
|
|
79
|
-
return anyEff;
|
|
80
|
-
};
|
|
81
|
-
var mapAsync = (fa, f) => asyncFlatMap(fa, (a) => asyncSucceed(f(a)));
|
|
82
|
-
var mapTryAsync = (fa, f) => asyncFlatMap(fa, (a) => asyncSync(() => f(a)));
|
|
83
|
-
|
|
84
|
-
// src/core/types/option.ts
|
|
85
|
-
var none = { _tag: "None" };
|
|
86
|
-
var some = (value) => ({ _tag: "Some", value });
|
|
87
|
-
|
|
88
|
-
// src/core/types/effect.ts
|
|
89
|
-
var Cause = {
|
|
90
|
-
fail: (error) => ({ _tag: "Fail", error }),
|
|
91
|
-
interrupt: () => ({ _tag: "Interrupt" }),
|
|
92
|
-
die: (defect) => ({ _tag: "Die", defect })
|
|
93
|
-
};
|
|
94
|
-
var Exit = {
|
|
95
|
-
succeed: (value) => ({
|
|
96
|
-
_tag: "Success",
|
|
97
|
-
value
|
|
98
|
-
}),
|
|
99
|
-
failCause: (cause) => ({
|
|
100
|
-
_tag: "Failure",
|
|
101
|
-
cause
|
|
102
|
-
})
|
|
103
|
-
};
|
|
104
|
-
var succeed = (value) => asyncSucceed(value);
|
|
105
|
-
var fail = (error) => asyncFail(error);
|
|
106
|
-
var sync = (thunk) => asyncSync((env) => thunk(env));
|
|
107
|
-
var map = (fa, f) => asyncMap(fa, f);
|
|
108
|
-
var flatMap = (fa, f) => asyncFlatMap(fa, f);
|
|
109
|
-
var mapError = (fa, f) => asyncMapError(fa, f);
|
|
110
|
-
var catchAll = (fa, handler) => asyncFold(fa, handler, asyncSucceed);
|
|
111
|
-
function orElseOptional(fa, that) {
|
|
112
|
-
return asyncFold(
|
|
113
|
-
fa,
|
|
114
|
-
(opt) => opt._tag === "Some" ? asyncFail(opt) : that(),
|
|
115
|
-
asyncSucceed
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
var end = () => fail(none);
|
|
5
|
+
|
|
6
|
+
var _chunkDJQ7OMMBcjs = require('./chunk-DJQ7OMMB.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkSPUEME2Bcjs = require('./chunk-SPUEME2B.cjs');
|
|
119
11
|
|
|
120
12
|
// src/core/runtime/ringBuffer.ts
|
|
121
13
|
var PushStatus = /* @__PURE__ */ ((PushStatus3) => {
|
|
@@ -441,13 +333,47 @@ function resolveWasmScheduler() {
|
|
|
441
333
|
var LaneState = (_class4 = class {
|
|
442
334
|
constructor(key, initial, max) {;_class4.prototype.__init16.call(this);_class4.prototype.__init17.call(this);_class4.prototype.__init18.call(this);
|
|
443
335
|
this.key = key;
|
|
336
|
+
this.initial = initial;
|
|
337
|
+
this.max = max;
|
|
444
338
|
this.queue = makeBoundedRingBuffer(initial, max, { engine: "ts" });
|
|
445
339
|
}
|
|
446
340
|
|
|
447
341
|
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
448
346
|
__init16() {this.enqueuedTasks = 0}
|
|
449
347
|
__init17() {this.executedTasks = 0}
|
|
450
348
|
__init18() {this.droppedTasks = 0}
|
|
349
|
+
recordTag(tag, queuedBefore) {
|
|
350
|
+
if (this.tagQueue) {
|
|
351
|
+
this.tagQueue.push(tag);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (queuedBefore === 0 || this.sharedTag === void 0) {
|
|
355
|
+
this.sharedTag = tag;
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (this.sharedTag === tag) return;
|
|
359
|
+
const tags = makeBoundedRingBuffer(this.initial, this.max, { engine: "ts" });
|
|
360
|
+
for (let i = 0; i < queuedBefore; i++) tags.push(this.sharedTag);
|
|
361
|
+
tags.push(tag);
|
|
362
|
+
this.tagQueue = tags;
|
|
363
|
+
}
|
|
364
|
+
shiftTag() {
|
|
365
|
+
if (this.tagQueue) {
|
|
366
|
+
const tag2 = _nullishCoalesce(_nullishCoalesce(this.tagQueue.shift(), () => ( this.sharedTag)), () => ( this.key));
|
|
367
|
+
if (this.queue.length === 0) {
|
|
368
|
+
this.tagQueue = void 0;
|
|
369
|
+
this.sharedTag = void 0;
|
|
370
|
+
}
|
|
371
|
+
return tag2;
|
|
372
|
+
}
|
|
373
|
+
const tag = _nullishCoalesce(this.sharedTag, () => ( this.key));
|
|
374
|
+
if (this.queue.length === 0) this.sharedTag = void 0;
|
|
375
|
+
return tag;
|
|
376
|
+
}
|
|
451
377
|
}, _class4);
|
|
452
378
|
var JsSchedulerState = (_class5 = class {
|
|
453
379
|
constructor(options) {;_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);_class5.prototype.__init22.call(this);_class5.prototype.__init23.call(this);_class5.prototype.__init24.call(this);_class5.prototype.__init25.call(this);_class5.prototype.__init26.call(this);_class5.prototype.__init27.call(this);_class5.prototype.__init28.call(this);_class5.prototype.__init29.call(this);_class5.prototype.__init30.call(this);_class5.prototype.__init31.call(this);
|
|
@@ -473,12 +399,33 @@ var JsSchedulerState = (_class5 = class {
|
|
|
473
399
|
return n;
|
|
474
400
|
}
|
|
475
401
|
}, _class5);
|
|
476
|
-
var
|
|
402
|
+
var JsSingleSchedulerState = (_class6 = class {
|
|
403
|
+
constructor(options) {;_class6.prototype.__init32.call(this);_class6.prototype.__init33.call(this);_class6.prototype.__init34.call(this);_class6.prototype.__init35.call(this);_class6.prototype.__init36.call(this);_class6.prototype.__init37.call(this);_class6.prototype.__init38.call(this);_class6.prototype.__init39.call(this);_class6.prototype.__init40.call(this);
|
|
404
|
+
this.options = options;
|
|
405
|
+
this.queue = makeBoundedRingBuffer(
|
|
406
|
+
_nullishCoalesce(options.initialCapacity, () => ( 1024)),
|
|
407
|
+
_nullishCoalesce(options.maxCapacity, () => ( SCHEDULER_QUEUE_CAPACITY)),
|
|
408
|
+
{ engine: "ts" }
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
477
412
|
|
|
478
|
-
__init32() {this.
|
|
479
|
-
__init33() {this.
|
|
480
|
-
__init34() {this.
|
|
481
|
-
|
|
413
|
+
__init32() {this.flushing = false}
|
|
414
|
+
__init33() {this.scheduled = false}
|
|
415
|
+
__init34() {this.scheduledFlushes = 0}
|
|
416
|
+
__init35() {this.completedFlushes = 0}
|
|
417
|
+
__init36() {this.enqueuedTasks = 0}
|
|
418
|
+
__init37() {this.executedTasks = 0}
|
|
419
|
+
__init38() {this.droppedTasks = 0}
|
|
420
|
+
__init39() {this.yieldedByBudget = 0}
|
|
421
|
+
__init40() {this.totalLength = 0}
|
|
422
|
+
}, _class6);
|
|
423
|
+
var WasmSchedulerState = (_class7 = class {
|
|
424
|
+
|
|
425
|
+
__init41() {this.nextRef = 1}
|
|
426
|
+
__init42() {this.tasks = /* @__PURE__ */ new Map()}
|
|
427
|
+
__init43() {this.tags = /* @__PURE__ */ new Map()}
|
|
428
|
+
constructor(options) {;_class7.prototype.__init41.call(this);_class7.prototype.__init42.call(this);_class7.prototype.__init43.call(this);
|
|
482
429
|
const Ctor = resolveWasmScheduler();
|
|
483
430
|
if (!Ctor) throw new Error("brass-runtime wasm scheduler is not available. Run npm run build:wasm first.");
|
|
484
431
|
this.machine = new Ctor(
|
|
@@ -539,7 +486,7 @@ var WasmSchedulerState = (_class6 = class {
|
|
|
539
486
|
stats() {
|
|
540
487
|
return { engine: "wasm", fallbackUsed: false, data: JSON.parse(this.machine.stats_json()) };
|
|
541
488
|
}
|
|
542
|
-
},
|
|
489
|
+
}, _class7);
|
|
543
490
|
function sanitizeLaneKey(value) {
|
|
544
491
|
let key = "";
|
|
545
492
|
let previousWasColon = false;
|
|
@@ -710,9 +657,9 @@ function inferLane(tag) {
|
|
|
710
657
|
}
|
|
711
658
|
function extractTaggedLane(tag, prefix) {
|
|
712
659
|
if (!tag.startsWith(prefix)) return void 0;
|
|
713
|
-
const
|
|
714
|
-
if (
|
|
715
|
-
const value = tag.slice(prefix.length,
|
|
660
|
+
const end = tag.indexOf("|", prefix.length);
|
|
661
|
+
if (end < 0) return void 0;
|
|
662
|
+
const value = tag.slice(prefix.length, end);
|
|
716
663
|
return value.length > 0 ? value : void 0;
|
|
717
664
|
}
|
|
718
665
|
function firstSeparatorIndex(value) {
|
|
@@ -723,7 +670,7 @@ function firstSeparatorIndex(value) {
|
|
|
723
670
|
}
|
|
724
671
|
return best;
|
|
725
672
|
}
|
|
726
|
-
var Scheduler = (
|
|
673
|
+
var Scheduler = (_class8 = class {
|
|
727
674
|
|
|
728
675
|
|
|
729
676
|
|
|
@@ -733,8 +680,10 @@ var Scheduler = (_class7 = class {
|
|
|
733
680
|
|
|
734
681
|
|
|
735
682
|
|
|
736
|
-
|
|
737
|
-
|
|
683
|
+
|
|
684
|
+
__init44() {this.boundFlush = () => this.flush()}
|
|
685
|
+
__init45() {this.shiftedTag = "anonymous"}
|
|
686
|
+
constructor(options = {}) {;_class8.prototype.__init44.call(this);_class8.prototype.__init45.call(this);
|
|
738
687
|
this.flushBudget = _nullishCoalesce(options.flushBudget, () => ( FLUSH_BUDGET));
|
|
739
688
|
this.microThreshold = _nullishCoalesce(options.microThreshold, () => ( MICRO_THRESHOLD));
|
|
740
689
|
this.laneCapacity = _nullishCoalesce(options.laneCapacity, () => ( DEFAULT_LANE_CAPACITY));
|
|
@@ -748,7 +697,11 @@ var Scheduler = (_class7 = class {
|
|
|
748
697
|
return;
|
|
749
698
|
}
|
|
750
699
|
if (requested === "ts") {
|
|
751
|
-
|
|
700
|
+
if (options.laneMode === "single") {
|
|
701
|
+
this.jsSingle = new JsSingleSchedulerState({ ...options, engine: "ts" });
|
|
702
|
+
} else {
|
|
703
|
+
this.js = new JsSchedulerState({ ...options, engine: "ts" });
|
|
704
|
+
}
|
|
752
705
|
this.engine = "ts";
|
|
753
706
|
this.fallbackUsed = false;
|
|
754
707
|
return;
|
|
@@ -758,14 +711,42 @@ var Scheduler = (_class7 = class {
|
|
|
758
711
|
schedule(task, tag = "anonymous") {
|
|
759
712
|
if (typeof task !== "function") return "dropped";
|
|
760
713
|
if (this.wasm) return this.scheduleWasm(task, tag);
|
|
714
|
+
if (this.jsSingle) return this.scheduleJsSingle(task);
|
|
761
715
|
return this.scheduleJs(task, tag);
|
|
762
716
|
}
|
|
763
717
|
scheduleBatch(tasks) {
|
|
764
718
|
if (this.wasm) return this.scheduleBatchWasm(tasks);
|
|
719
|
+
if (this.jsSingle) return this.scheduleBatchJsSingle(tasks);
|
|
765
720
|
return tasks.map(({ fn, tag }) => this.schedule(fn, tag));
|
|
766
721
|
}
|
|
767
722
|
stats() {
|
|
768
723
|
if (this.wasm) return this.wasm.stats();
|
|
724
|
+
if (this.jsSingle) {
|
|
725
|
+
const js2 = this.jsSingle;
|
|
726
|
+
return {
|
|
727
|
+
engine: "ts",
|
|
728
|
+
fallbackUsed: false,
|
|
729
|
+
data: {
|
|
730
|
+
len: js2.totalLength,
|
|
731
|
+
capacity: js2.queue.capacity,
|
|
732
|
+
phase: js2.flushing ? "flushing" : js2.scheduled ? "scheduled" : "idle",
|
|
733
|
+
scheduledFlushes: js2.scheduledFlushes,
|
|
734
|
+
completedFlushes: js2.completedFlushes,
|
|
735
|
+
enqueuedTasks: js2.enqueuedTasks,
|
|
736
|
+
executedTasks: js2.executedTasks,
|
|
737
|
+
droppedTasks: js2.droppedTasks,
|
|
738
|
+
yieldedByBudget: js2.yieldedByBudget,
|
|
739
|
+
lanes: [{
|
|
740
|
+
key: "single",
|
|
741
|
+
len: js2.queue.length,
|
|
742
|
+
capacity: js2.queue.capacity,
|
|
743
|
+
enqueuedTasks: js2.enqueuedTasks,
|
|
744
|
+
executedTasks: js2.executedTasks,
|
|
745
|
+
droppedTasks: js2.droppedTasks
|
|
746
|
+
}]
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
}
|
|
769
750
|
const js = this.js;
|
|
770
751
|
const lanes = Array.from(js.lanes.values()).map((lane) => ({ key: lane.key, len: lane.queue.length, capacity: lane.queue.capacity, enqueuedTasks: lane.enqueuedTasks, executedTasks: lane.executedTasks, droppedTasks: lane.droppedTasks }));
|
|
771
752
|
return { engine: "ts", fallbackUsed: false, data: { len: js.totalLength, capacity: js.totalCapacity, phase: js.flushing ? "flushing" : js.scheduled ? "scheduled" : "idle", scheduledFlushes: js.scheduledFlushes, completedFlushes: js.completedFlushes, enqueuedTasks: js.enqueuedTasks, executedTasks: js.executedTasks, droppedTasks: js.droppedTasks, yieldedByBudget: js.yieldedByBudget, lanes } };
|
|
@@ -821,13 +802,44 @@ var Scheduler = (_class7 = class {
|
|
|
821
802
|
const js = this.js;
|
|
822
803
|
const lane = new LaneState(key, this.laneCapacity, this.laneCapacity);
|
|
823
804
|
js.lanes.set(key, lane);
|
|
824
|
-
js.laneOrder.push(
|
|
805
|
+
js.laneOrder.push(lane);
|
|
825
806
|
return lane;
|
|
826
807
|
}
|
|
808
|
+
scheduleJsSingle(task) {
|
|
809
|
+
const js = this.jsSingle;
|
|
810
|
+
const status = js.queue.push(task);
|
|
811
|
+
js.enqueuedTasks++;
|
|
812
|
+
if ((status & 2) !== 0) {
|
|
813
|
+
js.droppedTasks++;
|
|
814
|
+
if (!js.flushing && !js.scheduled && js.totalLength > 0) {
|
|
815
|
+
js.scheduled = true;
|
|
816
|
+
js.scheduledFlushes++;
|
|
817
|
+
this.requestFlush(js.totalLength > this.microThreshold ? "macro" : "micro");
|
|
818
|
+
}
|
|
819
|
+
return "dropped";
|
|
820
|
+
}
|
|
821
|
+
js.totalLength++;
|
|
822
|
+
if (js.flushing) return "accepted";
|
|
823
|
+
if (!js.scheduled) {
|
|
824
|
+
js.scheduled = true;
|
|
825
|
+
js.scheduledFlushes++;
|
|
826
|
+
this.requestFlush(js.totalLength > this.microThreshold ? "macro" : "micro");
|
|
827
|
+
}
|
|
828
|
+
return "accepted";
|
|
829
|
+
}
|
|
830
|
+
scheduleBatchJsSingle(tasks) {
|
|
831
|
+
const results = new Array(tasks.length);
|
|
832
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
833
|
+
const task = tasks[i].fn;
|
|
834
|
+
results[i] = typeof task === "function" ? this.scheduleJsSingle(task) : "dropped";
|
|
835
|
+
}
|
|
836
|
+
return results;
|
|
837
|
+
}
|
|
827
838
|
scheduleJs(task, tag) {
|
|
828
839
|
const js = this.js;
|
|
829
840
|
const lane = this.getOrCreateLane(inferLane(tag));
|
|
830
|
-
const
|
|
841
|
+
const queuedBefore = lane.queue.length;
|
|
842
|
+
const status = lane.queue.push(task);
|
|
831
843
|
lane.enqueuedTasks++;
|
|
832
844
|
js.enqueuedTasks++;
|
|
833
845
|
if ((status & 2) !== 0) {
|
|
@@ -840,6 +852,7 @@ var Scheduler = (_class7 = class {
|
|
|
840
852
|
}
|
|
841
853
|
return "dropped";
|
|
842
854
|
}
|
|
855
|
+
lane.recordTag(tag, queuedBefore);
|
|
843
856
|
js.totalLength++;
|
|
844
857
|
if (js.flushing) return "accepted";
|
|
845
858
|
if (!js.scheduled) {
|
|
@@ -855,6 +868,7 @@ var Scheduler = (_class7 = class {
|
|
|
855
868
|
}
|
|
856
869
|
flush() {
|
|
857
870
|
if (this.wasm) return this.flushWasm();
|
|
871
|
+
if (this.jsSingle) return this.flushJsSingle();
|
|
858
872
|
this.flushJs();
|
|
859
873
|
}
|
|
860
874
|
flushWasm() {
|
|
@@ -879,15 +893,47 @@ var Scheduler = (_class7 = class {
|
|
|
879
893
|
else if (policy === 1) this.requestFlush("macro");
|
|
880
894
|
}
|
|
881
895
|
}
|
|
896
|
+
flushJsSingle() {
|
|
897
|
+
const js = this.jsSingle;
|
|
898
|
+
if (js.flushing) return;
|
|
899
|
+
js.flushing = true;
|
|
900
|
+
js.scheduled = false;
|
|
901
|
+
let ran = 0;
|
|
902
|
+
try {
|
|
903
|
+
while (ran < this.flushBudget) {
|
|
904
|
+
const task = js.queue.shift();
|
|
905
|
+
if (!task) break;
|
|
906
|
+
js.totalLength--;
|
|
907
|
+
ran++;
|
|
908
|
+
js.executedTasks++;
|
|
909
|
+
try {
|
|
910
|
+
task();
|
|
911
|
+
} catch (e) {
|
|
912
|
+
console.error("[Scheduler] task threw (laneMode=single)", e);
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
} finally {
|
|
916
|
+
js.flushing = false;
|
|
917
|
+
js.completedFlushes++;
|
|
918
|
+
if (js.totalLength > 0 && !js.scheduled) {
|
|
919
|
+
js.scheduled = true;
|
|
920
|
+
js.scheduledFlushes++;
|
|
921
|
+
const kind = ran >= this.flushBudget || js.totalLength > this.microThreshold ? "macro" : "micro";
|
|
922
|
+
if (ran >= this.flushBudget) js.yieldedByBudget++;
|
|
923
|
+
this.requestFlush(kind);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
882
927
|
shiftFromNextLane() {
|
|
883
928
|
const js = this.js;
|
|
884
929
|
const n = js.laneOrder.length;
|
|
885
930
|
if (n === 0) return void 0;
|
|
886
931
|
if (js.rrRemaining > 0) {
|
|
887
932
|
const currentIdx = (js.rrIndex + n - 1) % n;
|
|
888
|
-
const currentLane = js.
|
|
889
|
-
const next =
|
|
933
|
+
const currentLane = js.laneOrder[currentIdx];
|
|
934
|
+
const next = currentLane.queue.shift();
|
|
890
935
|
if (next) {
|
|
936
|
+
this.shiftedTag = currentLane.shiftTag();
|
|
891
937
|
js.rrRemaining--;
|
|
892
938
|
currentLane.executedTasks++;
|
|
893
939
|
js.totalLength--;
|
|
@@ -897,14 +943,15 @@ var Scheduler = (_class7 = class {
|
|
|
897
943
|
}
|
|
898
944
|
for (let scanned = 0; scanned < n; scanned++) {
|
|
899
945
|
const idx = js.rrIndex % n;
|
|
900
|
-
const
|
|
946
|
+
const lane = js.laneOrder[idx];
|
|
901
947
|
js.rrIndex = (idx + 1) % n;
|
|
902
|
-
|
|
903
|
-
if (!lane || lane.queue.length === 0) continue;
|
|
948
|
+
if (lane.queue.length === 0) continue;
|
|
904
949
|
js.rrRemaining = Math.max(0, this.laneBudget - 1);
|
|
905
950
|
lane.executedTasks++;
|
|
906
951
|
js.totalLength--;
|
|
907
|
-
|
|
952
|
+
const next = lane.queue.shift();
|
|
953
|
+
if (next) this.shiftedTag = lane.shiftTag();
|
|
954
|
+
return next;
|
|
908
955
|
}
|
|
909
956
|
return void 0;
|
|
910
957
|
}
|
|
@@ -921,9 +968,9 @@ var Scheduler = (_class7 = class {
|
|
|
921
968
|
ran++;
|
|
922
969
|
js.executedTasks++;
|
|
923
970
|
try {
|
|
924
|
-
next
|
|
971
|
+
next();
|
|
925
972
|
} catch (e) {
|
|
926
|
-
console.error(`[Scheduler] task threw (tag=${
|
|
973
|
+
console.error(`[Scheduler] task threw (tag=${this.shiftedTag})`, e);
|
|
927
974
|
}
|
|
928
975
|
}
|
|
929
976
|
} finally {
|
|
@@ -938,9 +985,30 @@ var Scheduler = (_class7 = class {
|
|
|
938
985
|
}
|
|
939
986
|
}
|
|
940
987
|
}
|
|
941
|
-
},
|
|
988
|
+
}, _class8);
|
|
942
989
|
var globalScheduler = new Scheduler();
|
|
943
990
|
|
|
991
|
+
// src/core/runtime/contex.ts
|
|
992
|
+
var emptyContext = { parent: null, patch: /* @__PURE__ */ Object.create(null) };
|
|
993
|
+
function ctxExtend(parent, patch) {
|
|
994
|
+
return { parent, patch };
|
|
995
|
+
}
|
|
996
|
+
function ctxToObject(ctx) {
|
|
997
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
998
|
+
const seen = /* @__PURE__ */ new Set();
|
|
999
|
+
let cur = ctx;
|
|
1000
|
+
while (cur) {
|
|
1001
|
+
for (const k of Object.keys(cur.patch)) {
|
|
1002
|
+
if (!seen.has(k)) {
|
|
1003
|
+
out[k] = cur.patch[k];
|
|
1004
|
+
seen.add(k);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
cur = cur.parent;
|
|
1008
|
+
}
|
|
1009
|
+
return out;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
944
1012
|
// src/core/runtime/hostAction.ts
|
|
945
1013
|
var DefaultHostExecutor = {
|
|
946
1014
|
async execute(action) {
|
|
@@ -952,33 +1020,39 @@ var DefaultHostExecutor = {
|
|
|
952
1020
|
}
|
|
953
1021
|
};
|
|
954
1022
|
|
|
955
|
-
// src/core/runtime/contex.ts
|
|
956
|
-
var emptyContext = { parent: null, patch: /* @__PURE__ */ Object.create(null) };
|
|
957
|
-
|
|
958
1023
|
// src/core/runtime/forkPolicy.ts
|
|
959
1024
|
function makeForkPolicy(env, hooks) {
|
|
960
1025
|
const svc = resolveForkServices(env);
|
|
961
1026
|
return {
|
|
962
1027
|
initChild(fiber, parent, scopeId) {
|
|
963
|
-
const parentCtx = _optionalChain([parent, 'optionalAccess',
|
|
964
|
-
const trace = forkTrace(svc, _nullishCoalesce(_optionalChain([parentCtx, 'optionalAccess',
|
|
1028
|
+
const parentCtx = _optionalChain([parent, 'optionalAccess', _4 => _4.fiberContext]);
|
|
1029
|
+
const trace = forkTrace(svc, _nullishCoalesce(_optionalChain([parentCtx, 'optionalAccess', _5 => _5.trace]), () => ( null)));
|
|
965
1030
|
fiber.fiberContext = {
|
|
966
|
-
log: _nullishCoalesce(_optionalChain([parentCtx, 'optionalAccess',
|
|
1031
|
+
log: _nullishCoalesce(_optionalChain([parentCtx, 'optionalAccess', _6 => _6.log]), () => ( emptyContext)),
|
|
967
1032
|
trace
|
|
968
1033
|
};
|
|
969
|
-
fiber.parentFiberId = _optionalChain([parent, 'optionalAccess',
|
|
970
|
-
fiber.name = svc.childName(_optionalChain([parent, 'optionalAccess',
|
|
1034
|
+
fiber.parentFiberId = _optionalChain([parent, 'optionalAccess', _7 => _7.id]);
|
|
1035
|
+
fiber.name = svc.childName(_optionalChain([parent, 'optionalAccess', _8 => _8.name]));
|
|
971
1036
|
if (scopeId !== void 0) fiber.scopeId = scopeId;
|
|
972
1037
|
hooks.emit(
|
|
973
1038
|
{
|
|
974
1039
|
type: "fiber.start",
|
|
975
1040
|
fiberId: fiber.id,
|
|
976
|
-
parentFiberId: _optionalChain([parent, 'optionalAccess',
|
|
1041
|
+
parentFiberId: _optionalChain([parent, 'optionalAccess', _9 => _9.id]),
|
|
977
1042
|
scopeId: fiber.scopeId,
|
|
978
1043
|
// ✅ ahora viaja
|
|
979
1044
|
name: fiber.name
|
|
980
1045
|
},
|
|
981
|
-
{
|
|
1046
|
+
{
|
|
1047
|
+
fiberId: fiber.id,
|
|
1048
|
+
scopeId: fiber.scopeId,
|
|
1049
|
+
traceId: _optionalChain([trace, 'optionalAccess', _10 => _10.traceId]),
|
|
1050
|
+
spanId: _optionalChain([trace, 'optionalAccess', _11 => _11.spanId]),
|
|
1051
|
+
parentSpanId: _optionalChain([trace, 'optionalAccess', _12 => _12.parentSpanId]),
|
|
1052
|
+
traceState: _optionalChain([trace, 'optionalAccess', _13 => _13.traceState]),
|
|
1053
|
+
baggage: _optionalChain([trace, 'optionalAccess', _14 => _14.baggage]),
|
|
1054
|
+
sampled: _optionalChain([trace, 'optionalAccess', _15 => _15.sampled])
|
|
1055
|
+
}
|
|
982
1056
|
);
|
|
983
1057
|
}
|
|
984
1058
|
};
|
|
@@ -988,15 +1062,16 @@ function resolveForkServices(env) {
|
|
|
988
1062
|
newTraceId: () => randomRuntimeId("trace"),
|
|
989
1063
|
newSpanId: () => randomRuntimeId("span")
|
|
990
1064
|
};
|
|
991
|
-
const brass = _optionalChain([env, 'optionalAccess',
|
|
992
|
-
const tracer = _nullishCoalesce(_optionalChain([brass, 'optionalAccess',
|
|
993
|
-
const seed = _optionalChain([brass, 'optionalAccess',
|
|
994
|
-
const
|
|
995
|
-
|
|
1065
|
+
const brass = _optionalChain([env, 'optionalAccess', _16 => _16.brass]);
|
|
1066
|
+
const tracer = _nullishCoalesce(_optionalChain([brass, 'optionalAccess', _17 => _17.tracer]), () => ( defaultTracer));
|
|
1067
|
+
const seed = _optionalChain([brass, 'optionalAccess', _18 => _18.traceSeed]);
|
|
1068
|
+
const baggage = _optionalChain([brass, 'optionalAccess', _19 => _19.baggage]);
|
|
1069
|
+
const childName = _nullishCoalesce(_optionalChain([brass, 'optionalAccess', _20 => _20.childName]), () => ( ((p) => p ? `${p}/child` : void 0)));
|
|
1070
|
+
return { tracer, seed, baggage, childName };
|
|
996
1071
|
}
|
|
997
1072
|
function randomRuntimeId(prefix) {
|
|
998
1073
|
const cryptoLike = globalThis.crypto;
|
|
999
|
-
if (typeof _optionalChain([cryptoLike, 'optionalAccess',
|
|
1074
|
+
if (typeof _optionalChain([cryptoLike, 'optionalAccess', _21 => _21.randomUUID]) === "function") {
|
|
1000
1075
|
return cryptoLike.randomUUID();
|
|
1001
1076
|
}
|
|
1002
1077
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
@@ -1007,11 +1082,22 @@ function forkTrace(svc, parentTrace) {
|
|
|
1007
1082
|
traceId: parentTrace.traceId,
|
|
1008
1083
|
spanId: svc.tracer.newSpanId(),
|
|
1009
1084
|
parentSpanId: parentTrace.spanId,
|
|
1010
|
-
sampled: parentTrace.sampled
|
|
1085
|
+
sampled: parentTrace.sampled,
|
|
1086
|
+
traceState: parentTrace.traceState,
|
|
1087
|
+
baggage: parentTrace.baggage
|
|
1011
1088
|
};
|
|
1012
1089
|
}
|
|
1013
|
-
if (svc.seed)
|
|
1014
|
-
|
|
1090
|
+
if (svc.seed) {
|
|
1091
|
+
const baggage2 = _nullishCoalesce(svc.seed.baggage, () => ( svc.baggage));
|
|
1092
|
+
return baggage2 ? { ...svc.seed, baggage: baggage2 } : { ...svc.seed };
|
|
1093
|
+
}
|
|
1094
|
+
const baggage = svc.baggage;
|
|
1095
|
+
return {
|
|
1096
|
+
traceId: svc.tracer.newTraceId(),
|
|
1097
|
+
spanId: svc.tracer.newSpanId(),
|
|
1098
|
+
sampled: true,
|
|
1099
|
+
...baggage ? { baggage } : {}
|
|
1100
|
+
};
|
|
1015
1101
|
}
|
|
1016
1102
|
|
|
1017
1103
|
// src/core/runtime/engine/opcodes.ts
|
|
@@ -1028,14 +1114,14 @@ function decodeRef(ref) {
|
|
|
1028
1114
|
generation: ref >>> REF_GENERATION_SHIFT & REF_GENERATION_MASK
|
|
1029
1115
|
};
|
|
1030
1116
|
}
|
|
1031
|
-
var HostRegistry = (
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1117
|
+
var HostRegistry = (_class9 = class {constructor() { _class9.prototype.__init46.call(this);_class9.prototype.__init47.call(this);_class9.prototype.__init48.call(this);_class9.prototype.__init49.call(this);_class9.prototype.__init50.call(this);_class9.prototype.__init51.call(this);_class9.prototype.__init52.call(this); }
|
|
1118
|
+
__init46() {this.slots = [{ value: void 0, generation: 0, occupied: false }]}
|
|
1119
|
+
__init47() {this.free = []}
|
|
1120
|
+
__init48() {this.live = 0}
|
|
1121
|
+
__init49() {this.allocated = 0}
|
|
1122
|
+
__init50() {this.released = 0}
|
|
1123
|
+
__init51() {this.reused = 0}
|
|
1124
|
+
__init52() {this.staleReads = 0}
|
|
1039
1125
|
register(value) {
|
|
1040
1126
|
const index = _nullishCoalesce(this.free.pop(), () => ( this.slots.length));
|
|
1041
1127
|
let slot = this.slots[index];
|
|
@@ -1083,7 +1169,7 @@ var HostRegistry = (_class8 = class {constructor() { _class8.prototype.__init36.
|
|
|
1083
1169
|
clear() {
|
|
1084
1170
|
for (let index = 1; index < this.slots.length; index++) {
|
|
1085
1171
|
const slot = this.slots[index];
|
|
1086
|
-
if (!_optionalChain([slot, 'optionalAccess',
|
|
1172
|
+
if (!_optionalChain([slot, 'optionalAccess', _22 => _22.occupied])) continue;
|
|
1087
1173
|
slot.value = void 0;
|
|
1088
1174
|
slot.occupied = false;
|
|
1089
1175
|
this.free.push(index);
|
|
@@ -1104,10 +1190,10 @@ var HostRegistry = (_class8 = class {constructor() { _class8.prototype.__init36.
|
|
|
1104
1190
|
staleReads: this.staleReads
|
|
1105
1191
|
};
|
|
1106
1192
|
}
|
|
1107
|
-
},
|
|
1108
|
-
var ProgramBuilder = (
|
|
1109
|
-
|
|
1110
|
-
|
|
1193
|
+
}, _class9);
|
|
1194
|
+
var ProgramBuilder = (_class10 = class {constructor() { _class10.prototype.__init53.call(this);_class10.prototype.__init54.call(this); }
|
|
1195
|
+
__init53() {this.nodes = []}
|
|
1196
|
+
__init54() {this.registry = new HostRegistry()}
|
|
1111
1197
|
compile(effect) {
|
|
1112
1198
|
const root = this.visit(effect);
|
|
1113
1199
|
return {
|
|
@@ -1171,14 +1257,14 @@ var ProgramBuilder = (_class9 = class {constructor() { _class9.prototype.__init4
|
|
|
1171
1257
|
return this.add(current.decode === void 0 ? base : { ...base, decodeRef: this.registry.register(current.decode) });
|
|
1172
1258
|
}
|
|
1173
1259
|
default:
|
|
1174
|
-
return this.add({ tag: "Fail", errorRef: this.registry.register(new Error(`Unknown Async opcode: ${_optionalChain([current, 'optionalAccess',
|
|
1260
|
+
return this.add({ tag: "Fail", errorRef: this.registry.register(new Error(`Unknown Async opcode: ${_optionalChain([current, 'optionalAccess', _23 => _23._tag])}`)) });
|
|
1175
1261
|
}
|
|
1176
1262
|
}
|
|
1177
|
-
},
|
|
1263
|
+
}, _class10);
|
|
1178
1264
|
|
|
1179
1265
|
// src/core/runtime/engine/FiberHandleImpl.ts
|
|
1180
|
-
var EngineFiberHandle = (
|
|
1181
|
-
constructor(id, runtime, onScheduledStep, onInterrupt, onJoiner, onQueued, onScheduleDropped, onScheduleRequest) {;
|
|
1266
|
+
var EngineFiberHandle = (_class11 = class {
|
|
1267
|
+
constructor(id, runtime, onScheduledStep, onInterrupt, onJoiner, onQueued, onScheduleDropped, onScheduleRequest) {;_class11.prototype.__init55.call(this);_class11.prototype.__init56.call(this);_class11.prototype.__init57.call(this);_class11.prototype.__init58.call(this);_class11.prototype.__init59.call(this);_class11.prototype.__init60.call(this);
|
|
1182
1268
|
this.onScheduledStep = onScheduledStep;
|
|
1183
1269
|
this.onInterrupt = onInterrupt;
|
|
1184
1270
|
this.onJoiner = onJoiner;
|
|
@@ -1201,12 +1287,12 @@ var EngineFiberHandle = (_class10 = class {
|
|
|
1201
1287
|
|
|
1202
1288
|
|
|
1203
1289
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1290
|
+
__init55() {this.result = null}
|
|
1291
|
+
__init56() {this.joiners = []}
|
|
1292
|
+
__init57() {this.finalizers = []}
|
|
1293
|
+
__init58() {this.finalizersDrained = false}
|
|
1294
|
+
__init59() {this.internalStatus = "running"}
|
|
1295
|
+
__init60() {this.queued = false}
|
|
1210
1296
|
status() {
|
|
1211
1297
|
if (this.result == null) return "Running";
|
|
1212
1298
|
if (this.result._tag === "Failure" && this.result.cause._tag === "Interrupt") return "Interrupted";
|
|
@@ -1227,13 +1313,13 @@ var EngineFiberHandle = (_class10 = class {
|
|
|
1227
1313
|
join(cb) {
|
|
1228
1314
|
if (this.result != null) cb(this.result);
|
|
1229
1315
|
else {
|
|
1230
|
-
_optionalChain([this, 'access',
|
|
1316
|
+
_optionalChain([this, 'access', _24 => _24.onJoiner, 'optionalCall', _25 => _25(this.id)]);
|
|
1231
1317
|
this.joiners.push(cb);
|
|
1232
1318
|
}
|
|
1233
1319
|
}
|
|
1234
1320
|
interrupt() {
|
|
1235
1321
|
if (this.result != null) return;
|
|
1236
|
-
this.onInterrupt(this.id, Cause.interrupt());
|
|
1322
|
+
this.onInterrupt(this.id, _chunkDJQ7OMMBcjs.Cause.interrupt());
|
|
1237
1323
|
}
|
|
1238
1324
|
addFinalizer(f) {
|
|
1239
1325
|
this.finalizers.push(f);
|
|
@@ -1242,12 +1328,12 @@ var EngineFiberHandle = (_class10 = class {
|
|
|
1242
1328
|
if (this.result != null || this.queued) return;
|
|
1243
1329
|
this.queued = true;
|
|
1244
1330
|
this.internalStatus = "queued";
|
|
1245
|
-
_optionalChain([this, 'access',
|
|
1331
|
+
_optionalChain([this, 'access', _26 => _26.onQueued, 'optionalCall', _27 => _27(this.id)]);
|
|
1246
1332
|
const label = `wasm-fiber#${this.id}.${tag}`;
|
|
1247
1333
|
const result = this.onScheduleRequest ? this.onScheduleRequest(this.id, label) : this.scheduleWithRuntime(label);
|
|
1248
1334
|
if (result === "dropped") {
|
|
1249
1335
|
this.queued = false;
|
|
1250
|
-
_optionalChain([this, 'access',
|
|
1336
|
+
_optionalChain([this, 'access', _28 => _28.onScheduleDropped, 'optionalCall', _29 => _29(this.id, label)]);
|
|
1251
1337
|
}
|
|
1252
1338
|
}
|
|
1253
1339
|
scheduleWithRuntime(label) {
|
|
@@ -1262,21 +1348,21 @@ var EngineFiberHandle = (_class10 = class {
|
|
|
1262
1348
|
this.runtime.hooks.emit(ev, {
|
|
1263
1349
|
fiberId: this.id,
|
|
1264
1350
|
scopeId: this.scopeId,
|
|
1265
|
-
traceId: _optionalChain([this, 'access',
|
|
1266
|
-
spanId: _optionalChain([this, 'access',
|
|
1351
|
+
traceId: _optionalChain([this, 'access', _30 => _30.fiberContext, 'optionalAccess', _31 => _31.trace, 'optionalAccess', _32 => _32.traceId]),
|
|
1352
|
+
spanId: _optionalChain([this, 'access', _33 => _33.fiberContext, 'optionalAccess', _34 => _34.trace, 'optionalAccess', _35 => _35.spanId])
|
|
1267
1353
|
});
|
|
1268
1354
|
}
|
|
1269
1355
|
succeed(value) {
|
|
1270
|
-
this.complete(Exit.succeed(value));
|
|
1356
|
+
this.complete(_chunkDJQ7OMMBcjs.Exit.succeed(value));
|
|
1271
1357
|
}
|
|
1272
1358
|
fail(error) {
|
|
1273
|
-
this.complete(Exit.failCause(Cause.fail(error)));
|
|
1359
|
+
this.complete(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.fail(error)));
|
|
1274
1360
|
}
|
|
1275
1361
|
die(defect) {
|
|
1276
|
-
this.complete(Exit.failCause(Cause.die(defect)));
|
|
1362
|
+
this.complete(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(defect)));
|
|
1277
1363
|
}
|
|
1278
1364
|
interrupted() {
|
|
1279
|
-
this.complete(Exit.failCause(Cause.interrupt()));
|
|
1365
|
+
this.complete(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.interrupt()));
|
|
1280
1366
|
}
|
|
1281
1367
|
complete(exit) {
|
|
1282
1368
|
if (this.result != null) return;
|
|
@@ -1307,7 +1393,7 @@ var EngineFiberHandle = (_class10 = class {
|
|
|
1307
1393
|
}
|
|
1308
1394
|
}
|
|
1309
1395
|
}
|
|
1310
|
-
},
|
|
1396
|
+
}, _class11);
|
|
1311
1397
|
|
|
1312
1398
|
// src/core/runtime/engine/binaryAbi.ts
|
|
1313
1399
|
var ABI_VERSION = 1;
|
|
@@ -1478,24 +1564,24 @@ var VM_METRIC_NAMES = [
|
|
|
1478
1564
|
"fiberSlabReleased",
|
|
1479
1565
|
"fiberSlabStaleReads"
|
|
1480
1566
|
];
|
|
1481
|
-
var WasmPackFiberBridge = (
|
|
1482
|
-
|
|
1567
|
+
var WasmPackFiberBridge = (_class12 = class {
|
|
1568
|
+
__init61() {this.kind = "wasm"}
|
|
1483
1569
|
|
|
1484
1570
|
|
|
1485
1571
|
|
|
1486
1572
|
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
constructor(modulePath) {;
|
|
1573
|
+
__init62() {this.jsonEventCalls = 0}
|
|
1574
|
+
__init63() {this.binaryEventCalls = 0}
|
|
1575
|
+
__init64() {this.zeroCopyEventCalls = 0}
|
|
1576
|
+
__init65() {this.eventsReceived = 0}
|
|
1577
|
+
__init66() {this.maxEventsPerCall = 0}
|
|
1578
|
+
__init67() {this.jsonPrograms = 0}
|
|
1579
|
+
__init68() {this.binaryPrograms = 0}
|
|
1580
|
+
__init69() {this.zeroCopyPrograms = 0}
|
|
1581
|
+
__init70() {this.jsonPatches = 0}
|
|
1582
|
+
__init71() {this.binaryPatches = 0}
|
|
1583
|
+
__init72() {this.zeroCopyPatches = 0}
|
|
1584
|
+
constructor(modulePath) {;_class12.prototype.__init61.call(this);_class12.prototype.__init62.call(this);_class12.prototype.__init63.call(this);_class12.prototype.__init64.call(this);_class12.prototype.__init65.call(this);_class12.prototype.__init66.call(this);_class12.prototype.__init67.call(this);_class12.prototype.__init68.call(this);_class12.prototype.__init69.call(this);_class12.prototype.__init70.call(this);_class12.prototype.__init71.call(this);_class12.prototype.__init72.call(this);
|
|
1499
1585
|
const mod = loadWasmModule(modulePath);
|
|
1500
1586
|
this.vm = new mod.BrassWasmVm();
|
|
1501
1587
|
this.supportsBinary = typeof this.vm.create_fiber_bin === "function" && typeof this.vm.drive_batch_bin === "function" && typeof this.vm.provide_value_bin === "function" && typeof this.vm.provide_error_bin === "function" && typeof this.vm.provide_effect_bin === "function" && typeof this.vm.interrupt_bin === "function";
|
|
@@ -1598,29 +1684,16 @@ var WasmPackFiberBridge = (_class11 = class {
|
|
|
1598
1684
|
}
|
|
1599
1685
|
decodeZeroCopy(ptr) {
|
|
1600
1686
|
this.zeroCopyEventCalls += 1;
|
|
1601
|
-
const len = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1687
|
+
const len = _nullishCoalesce(_optionalChain([this, 'access', _36 => _36.vm, 'access', _37 => _37.event_batch_len, 'optionalCall', _38 => _38()]), () => ( 0));
|
|
1602
1688
|
const words = this.readU32(ptr, len);
|
|
1603
1689
|
const events = decodeEventBatch(words);
|
|
1604
1690
|
this.eventsReceived += events.length;
|
|
1605
1691
|
this.maxEventsPerCall = Math.max(this.maxEventsPerCall, events.length);
|
|
1606
1692
|
return events;
|
|
1607
1693
|
}
|
|
1608
|
-
decodeBinary(words) {
|
|
1609
|
-
this.binaryEventCalls += 1;
|
|
1610
|
-
const events = decodeEventBatch(words);
|
|
1611
|
-
this.eventsReceived += events.length;
|
|
1612
|
-
this.maxEventsPerCall = Math.max(this.maxEventsPerCall, events.length);
|
|
1613
|
-
return events;
|
|
1614
|
-
}
|
|
1615
|
-
decodeJson(json) {
|
|
1616
|
-
this.jsonEventCalls += 1;
|
|
1617
|
-
this.eventsReceived += 1;
|
|
1618
|
-
this.maxEventsPerCall = Math.max(this.maxEventsPerCall, 1);
|
|
1619
|
-
return JSON.parse(json);
|
|
1620
|
-
}
|
|
1621
1694
|
memory() {
|
|
1622
|
-
const memory = _optionalChain([this, 'access',
|
|
1623
|
-
if (!_optionalChain([memory, 'optionalAccess',
|
|
1695
|
+
const memory = _optionalChain([this, 'access', _39 => _39.vm, 'access', _40 => _40.memory, 'optionalCall', _41 => _41()]);
|
|
1696
|
+
if (!_optionalChain([memory, 'optionalAccess', _42 => _42.buffer])) throw new Error("brass-runtime WASM memory is not available");
|
|
1624
1697
|
return memory;
|
|
1625
1698
|
}
|
|
1626
1699
|
readU32(ptr, len) {
|
|
@@ -1636,8 +1709,8 @@ var WasmPackFiberBridge = (_class11 = class {
|
|
|
1636
1709
|
new Uint32Array(this.memory().buffer, ptr, words.length).set(words);
|
|
1637
1710
|
}
|
|
1638
1711
|
readMetricsSnapshot() {
|
|
1639
|
-
const ptr = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1640
|
-
const len = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1712
|
+
const ptr = _nullishCoalesce(_optionalChain([this, 'access', _43 => _43.vm, 'access', _44 => _44.metrics_snapshot_ptr, 'optionalCall', _45 => _45()]), () => ( 0));
|
|
1713
|
+
const len = _nullishCoalesce(_optionalChain([this, 'access', _46 => _46.vm, 'access', _47 => _47.metrics_snapshot_len, 'optionalCall', _48 => _48()]), () => ( 0));
|
|
1641
1714
|
const view = this.readF64(ptr, len);
|
|
1642
1715
|
const out = {};
|
|
1643
1716
|
for (let i = 0; i < Math.min(view.length, VM_METRIC_NAMES.length); i++) {
|
|
@@ -1645,7 +1718,7 @@ var WasmPackFiberBridge = (_class11 = class {
|
|
|
1645
1718
|
}
|
|
1646
1719
|
return out;
|
|
1647
1720
|
}
|
|
1648
|
-
},
|
|
1721
|
+
}, _class12);
|
|
1649
1722
|
function loadWasmModule(modulePath) {
|
|
1650
1723
|
const mod = resolveWasmModule({ modulePath });
|
|
1651
1724
|
if (mod) return mod;
|
|
@@ -1669,7 +1742,7 @@ var WasmFiberRegistryBridge = class {
|
|
|
1669
1742
|
|
|
1670
1743
|
constructor() {
|
|
1671
1744
|
const mod = resolveWasmModule();
|
|
1672
|
-
const Ctor = _optionalChain([mod, 'optionalAccess',
|
|
1745
|
+
const Ctor = _optionalChain([mod, 'optionalAccess', _49 => _49.BrassWasmFiberRegistry]);
|
|
1673
1746
|
if (!Ctor) {
|
|
1674
1747
|
throw new Error("brass-runtime wasm fiber registry is not available. Run npm run build:wasm first.");
|
|
1675
1748
|
}
|
|
@@ -1768,7 +1841,7 @@ var DEFAULT_LANE_BUDGET2 = 64;
|
|
|
1768
1841
|
var DEFAULT_MAX_LANES2 = 256;
|
|
1769
1842
|
function resolveWasmReadyQueue() {
|
|
1770
1843
|
const mod = resolveWasmModule();
|
|
1771
|
-
return _nullishCoalesce(_optionalChain([mod, 'optionalAccess',
|
|
1844
|
+
return _nullishCoalesce(_optionalChain([mod, 'optionalAccess', _50 => _50.BrassWasmFiberReadyQueue]), () => ( null));
|
|
1772
1845
|
}
|
|
1773
1846
|
function decodePolicy(policy) {
|
|
1774
1847
|
switch (policy) {
|
|
@@ -1792,11 +1865,11 @@ function makeFiberReadyQueue(options = {}) {
|
|
|
1792
1865
|
}
|
|
1793
1866
|
throw new Error(`brass-runtime fiber ready queue engine must be 'ts' or 'wasm'; received '${String(requested)}'`);
|
|
1794
1867
|
}
|
|
1795
|
-
var WasmFiberReadyQueue = (
|
|
1796
|
-
|
|
1868
|
+
var WasmFiberReadyQueue = (_class13 = class {
|
|
1869
|
+
__init73() {this.engine = "wasm"}
|
|
1797
1870
|
|
|
1798
|
-
|
|
1799
|
-
constructor(Ctor, options) {;
|
|
1871
|
+
__init74() {this.laneCache = /* @__PURE__ */ new Map()}
|
|
1872
|
+
constructor(Ctor, options) {;_class13.prototype.__init73.call(this);_class13.prototype.__init74.call(this);
|
|
1800
1873
|
this.queue = new Ctor(
|
|
1801
1874
|
_nullishCoalesce(options.flushBudget, () => ( DEFAULT_FLUSH_BUDGET)),
|
|
1802
1875
|
_nullishCoalesce(options.microThreshold, () => ( DEFAULT_FLUSH_BUDGET * 2)),
|
|
@@ -1840,25 +1913,25 @@ var WasmFiberReadyQueue = (_class12 = class {
|
|
|
1840
1913
|
data: JSON.parse(this.queue.stats_json())
|
|
1841
1914
|
};
|
|
1842
1915
|
}
|
|
1843
|
-
},
|
|
1844
|
-
var TsFiberReadyQueue = (
|
|
1845
|
-
constructor(options) {;
|
|
1916
|
+
}, _class13);
|
|
1917
|
+
var TsFiberReadyQueue = (_class14 = class {
|
|
1918
|
+
constructor(options) {;_class14.prototype.__init75.call(this);_class14.prototype.__init76.call(this);_class14.prototype.__init77.call(this);_class14.prototype.__init78.call(this);_class14.prototype.__init79.call(this);_class14.prototype.__init80.call(this);_class14.prototype.__init81.call(this);_class14.prototype.__init82.call(this);_class14.prototype.__init83.call(this);_class14.prototype.__init84.call(this);_class14.prototype.__init85.call(this);_class14.prototype.__init86.call(this);_class14.prototype.__init87.call(this);
|
|
1846
1919
|
this.options = options;
|
|
1847
1920
|
}
|
|
1848
1921
|
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1922
|
+
__init75() {this.engine = "ts"}
|
|
1923
|
+
__init76() {this.lanes = /* @__PURE__ */ new Map()}
|
|
1924
|
+
__init77() {this.laneOrder = []}
|
|
1925
|
+
__init78() {this.rrIndex = 0}
|
|
1926
|
+
__init79() {this.rrRemaining = 0}
|
|
1927
|
+
__init80() {this.phase = "idle"}
|
|
1928
|
+
__init81() {this.totalLen = 0}
|
|
1929
|
+
__init82() {this.scheduledFlushes = 0}
|
|
1930
|
+
__init83() {this.completedFlushes = 0}
|
|
1931
|
+
__init84() {this.enqueuedFibers = 0}
|
|
1932
|
+
__init85() {this.executedFibers = 0}
|
|
1933
|
+
__init86() {this.droppedFibers = 0}
|
|
1934
|
+
__init87() {this.yieldedByBudget = 0}
|
|
1862
1935
|
enqueue(fiberId, tag) {
|
|
1863
1936
|
const lane = this.getOrCreateLane(inferLane2(tag));
|
|
1864
1937
|
this.enqueuedFibers += 1;
|
|
@@ -1985,7 +2058,7 @@ var TsFiberReadyQueue = (_class13 = class {
|
|
|
1985
2058
|
lane.executedFibers += 1;
|
|
1986
2059
|
return fiberId;
|
|
1987
2060
|
}
|
|
1988
|
-
},
|
|
2061
|
+
}, _class14);
|
|
1989
2062
|
function inferLane2(tag) {
|
|
1990
2063
|
const explicit = extractTaggedLane2(tag, "lane:");
|
|
1991
2064
|
if (explicit) return sanitizeLaneKey(explicit);
|
|
@@ -1997,9 +2070,9 @@ function inferLane2(tag) {
|
|
|
1997
2070
|
}
|
|
1998
2071
|
function extractTaggedLane2(tag, prefix) {
|
|
1999
2072
|
if (!tag.startsWith(prefix)) return void 0;
|
|
2000
|
-
const
|
|
2001
|
-
if (
|
|
2002
|
-
const value = tag.slice(prefix.length,
|
|
2073
|
+
const end = tag.indexOf("|", prefix.length);
|
|
2074
|
+
if (end < 0) return void 0;
|
|
2075
|
+
const value = tag.slice(prefix.length, end);
|
|
2003
2076
|
return value.length > 0 ? value : void 0;
|
|
2004
2077
|
}
|
|
2005
2078
|
function firstSeparatorIndex2(value) {
|
|
@@ -2083,7 +2156,7 @@ var WasmTimerWheelBridge = class {
|
|
|
2083
2156
|
};
|
|
2084
2157
|
function makeWasmTimerWheel(options) {
|
|
2085
2158
|
const mod = resolveWasmModule();
|
|
2086
|
-
const Ctor = _optionalChain([mod, 'optionalAccess',
|
|
2159
|
+
const Ctor = _optionalChain([mod, 'optionalAccess', _51 => _51.BrassWasmTimerWheel]);
|
|
2087
2160
|
if (!Ctor) throw new Error("brass-runtime wasm timer wheel is not available. Run npm run build:wasm first.");
|
|
2088
2161
|
return new WasmTimerWheelBridge(Ctor, options);
|
|
2089
2162
|
}
|
|
@@ -2094,8 +2167,8 @@ function toU64(value) {
|
|
|
2094
2167
|
// src/core/runtime/engine/WasmFiberEngine.ts
|
|
2095
2168
|
var DEFAULT_BUDGET = 4096;
|
|
2096
2169
|
var TIMER_KIND_HOST_ACTION = 1;
|
|
2097
|
-
var WasmFiberEngine = (
|
|
2098
|
-
constructor(runtime, options = {}) {;
|
|
2170
|
+
var WasmFiberEngine = (_class15 = class {
|
|
2171
|
+
constructor(runtime, options = {}) {;_class15.prototype.__init88.call(this);_class15.prototype.__init89.call(this);_class15.prototype.__init90.call(this);_class15.prototype.__init91.call(this);_class15.prototype.__init92.call(this);_class15.prototype.__init93.call(this);_class15.prototype.__init94.call(this);_class15.prototype.__init95.call(this);_class15.prototype.__init96.call(this);_class15.prototype.__init97.call(this);_class15.prototype.__init98.call(this);
|
|
2099
2172
|
this.runtime = runtime;
|
|
2100
2173
|
this.bridge = _nullishCoalesce(options.bridge, () => ( new WasmPackFiberBridge(options.modulePath)));
|
|
2101
2174
|
if (this.bridge.kind !== "wasm") {
|
|
@@ -2103,24 +2176,24 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2103
2176
|
}
|
|
2104
2177
|
this.kind = this.bridge.kind;
|
|
2105
2178
|
this.fiberRegistry = new WasmFiberRegistryBridge();
|
|
2106
|
-
this.readyQueue = makeFiberReadyQueue({ engine: "wasm" });
|
|
2179
|
+
this.readyQueue = makeFiberReadyQueue({ engine: "wasm", ...options.readyQueue });
|
|
2107
2180
|
this.timerWheel = makeWasmTimerWheel({ onExpired: (events) => this.onTimerExpired(events) });
|
|
2108
2181
|
}
|
|
2109
2182
|
|
|
2110
2183
|
|
|
2111
2184
|
|
|
2112
2185
|
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2186
|
+
__init88() {this.startedFibers = 0}
|
|
2187
|
+
__init89() {this.runningFibers = 0}
|
|
2188
|
+
__init90() {this.suspendedFibers = 0}
|
|
2189
|
+
__init91() {this.completedFibers = 0}
|
|
2190
|
+
__init92() {this.failedFibers = 0}
|
|
2191
|
+
__init93() {this.interruptedFibers = 0}
|
|
2192
|
+
__init94() {this.pendingHostEffects = 0}
|
|
2193
|
+
__init95() {this.readyDrainScheduled = false}
|
|
2194
|
+
__init96() {this.readyDraining = false}
|
|
2195
|
+
__init97() {this.states = /* @__PURE__ */ new Map()}
|
|
2196
|
+
__init98() {this.pendingResumes = /* @__PURE__ */ new Map()}
|
|
2124
2197
|
|
|
2125
2198
|
|
|
2126
2199
|
fork(effect, scopeId) {
|
|
@@ -2133,8 +2206,8 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2133
2206
|
this.runtime,
|
|
2134
2207
|
(id) => this.driveById(id),
|
|
2135
2208
|
(id, reason) => this.interruptById(id, reason),
|
|
2136
|
-
(id) => _optionalChain([this, 'access',
|
|
2137
|
-
(id) => _optionalChain([this, 'access',
|
|
2209
|
+
(id) => _optionalChain([this, 'access', _52 => _52.fiberRegistry, 'optionalAccess', _53 => _53.addJoiner, 'call', _54 => _54(id)]),
|
|
2210
|
+
(id) => _optionalChain([this, 'access', _55 => _55.fiberRegistry, 'optionalAccess', _56 => _56.markQueued, 'call', _57 => _57(id)]),
|
|
2138
2211
|
(id, label) => this.schedulerDropped(id, label),
|
|
2139
2212
|
(id, label) => this.enqueueFiberById(id, label)
|
|
2140
2213
|
);
|
|
@@ -2152,7 +2225,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2152
2225
|
hostActionToken: 0
|
|
2153
2226
|
};
|
|
2154
2227
|
this.states.set(fiberId, state);
|
|
2155
|
-
_optionalChain([this, 'access',
|
|
2228
|
+
_optionalChain([this, 'access', _58 => _58.fiberRegistry, 'optionalAccess', _59 => _59.registerFiber, 'call', _60 => _60(fiberId, void 0, scopeId)]);
|
|
2156
2229
|
this.startedFibers += 1;
|
|
2157
2230
|
this.runningFibers += 1;
|
|
2158
2231
|
return handle;
|
|
@@ -2193,17 +2266,17 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2193
2266
|
staleReads: hostStaleReads
|
|
2194
2267
|
},
|
|
2195
2268
|
wasm: this.bridge.stats(),
|
|
2196
|
-
fiberRegistry: _optionalChain([this, 'access',
|
|
2269
|
+
fiberRegistry: _optionalChain([this, 'access', _61 => _61.fiberRegistry, 'optionalAccess', _62 => _62.stats, 'call', _63 => _63()]),
|
|
2197
2270
|
readyQueue: this.readyQueue.stats(),
|
|
2198
|
-
timerWheel: _optionalChain([this, 'access',
|
|
2271
|
+
timerWheel: _optionalChain([this, 'access', _64 => _64.timerWheel, 'optionalAccess', _65 => _65.stats, 'call', _66 => _66()])
|
|
2199
2272
|
};
|
|
2200
2273
|
}
|
|
2201
2274
|
async shutdown() {
|
|
2202
2275
|
for (const state of Array.from(this.states.values())) {
|
|
2203
|
-
this.interruptState(state, Cause.interrupt());
|
|
2276
|
+
this.interruptState(state, _chunkDJQ7OMMBcjs.Cause.interrupt());
|
|
2204
2277
|
}
|
|
2205
2278
|
this.readyQueue.clear();
|
|
2206
|
-
_optionalChain([this, 'access',
|
|
2279
|
+
_optionalChain([this, 'access', _67 => _67.timerWheel, 'optionalAccess', _68 => _68.dispose, 'call', _69 => _69()]);
|
|
2207
2280
|
}
|
|
2208
2281
|
scheduleWakeup(fiberId) {
|
|
2209
2282
|
const state = this.states.get(fiberId);
|
|
@@ -2277,7 +2350,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2277
2350
|
const state = this.states.get(fiberId);
|
|
2278
2351
|
if (!state || state.completed) return;
|
|
2279
2352
|
state.handle.markDequeued();
|
|
2280
|
-
_optionalChain([this, 'access',
|
|
2353
|
+
_optionalChain([this, 'access', _70 => _70.fiberRegistry, 'optionalAccess', _71 => _71.markRunning, 'call', _72 => _72(fiberId)]);
|
|
2281
2354
|
const initialEvents = this.consumePendingResume(state);
|
|
2282
2355
|
withCurrentFiber(state.handle, () => this.drive(state, initialEvents));
|
|
2283
2356
|
}
|
|
@@ -2286,9 +2359,9 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2286
2359
|
if (!pending) return void 0;
|
|
2287
2360
|
this.pendingResumes.delete(state.fiberId);
|
|
2288
2361
|
if (pending.kind === "value") {
|
|
2289
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2362
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _73 => _73.bridge, 'access', _74 => _74.provideValueBatch, 'optionalCall', _75 => _75(state.fiberId, pending.ref, DEFAULT_BUDGET)]), () => ( [this.bridge.provideValue(state.fiberId, pending.ref)]));
|
|
2290
2363
|
}
|
|
2291
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2364
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _76 => _76.bridge, 'access', _77 => _77.provideErrorBatch, 'optionalCall', _78 => _78(state.fiberId, pending.ref, DEFAULT_BUDGET)]), () => ( [this.bridge.provideError(state.fiberId, pending.ref)]));
|
|
2292
2365
|
}
|
|
2293
2366
|
drive(state, initialEvents) {
|
|
2294
2367
|
if (state.completed) return;
|
|
@@ -2299,7 +2372,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2299
2372
|
while (!state.completed && budget-- > 0) {
|
|
2300
2373
|
try {
|
|
2301
2374
|
if (events.length === 0) {
|
|
2302
|
-
const next = _nullishCoalesce(_optionalChain([this, 'access',
|
|
2375
|
+
const next = _nullishCoalesce(_optionalChain([this, 'access', _79 => _79.bridge, 'access', _80 => _80.driveBatch, 'optionalCall', _81 => _81(state.fiberId, budget + 1)]), () => ( [this.bridge.poll(state.fiberId)]));
|
|
2303
2376
|
events.push(...next);
|
|
2304
2377
|
if (events.length === 0) events.push({ kind: "Continue", fiberId: state.fiberId });
|
|
2305
2378
|
}
|
|
@@ -2325,9 +2398,9 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2325
2398
|
const fn = state.registry.get(event.fnRef);
|
|
2326
2399
|
try {
|
|
2327
2400
|
const valueRef = state.registry.register(fn(this.runtime.env));
|
|
2328
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2401
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _82 => _82.bridge, 'access', _83 => _83.provideValueBatch, 'optionalCall', _84 => _84(state.fiberId, valueRef, budget + 1)]), () => ( [this.bridge.provideValue(state.fiberId, valueRef)])));
|
|
2329
2402
|
} catch (error) {
|
|
2330
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2403
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _85 => _85.bridge, 'access', _86 => _86.provideErrorBatch, 'optionalCall', _87 => _87(state.fiberId, state.registry.register(error), budget + 1)]), () => ( [this.bridge.provideError(state.fiberId, state.registry.register(error))])));
|
|
2331
2404
|
}
|
|
2332
2405
|
continue;
|
|
2333
2406
|
}
|
|
@@ -2337,9 +2410,9 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2337
2410
|
try {
|
|
2338
2411
|
const next = fn(value);
|
|
2339
2412
|
const patch = state.builder.append(next);
|
|
2340
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2413
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _88 => _88.bridge, 'access', _89 => _89.provideEffectBatch, 'optionalCall', _90 => _90(state.fiberId, patch.root, patch.nodes, budget + 1)]), () => ( [this.bridge.provideEffect(state.fiberId, patch.root, patch.nodes)])));
|
|
2341
2414
|
} catch (error) {
|
|
2342
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2415
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _91 => _91.bridge, 'access', _92 => _92.provideErrorBatch, 'optionalCall', _93 => _93(state.fiberId, state.registry.register(error), budget + 1)]), () => ( [this.bridge.provideError(state.fiberId, state.registry.register(error))])));
|
|
2343
2416
|
}
|
|
2344
2417
|
continue;
|
|
2345
2418
|
}
|
|
@@ -2349,9 +2422,9 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2349
2422
|
try {
|
|
2350
2423
|
const next = fn(errorValue);
|
|
2351
2424
|
const patch = state.builder.append(next);
|
|
2352
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2425
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _94 => _94.bridge, 'access', _95 => _95.provideEffectBatch, 'optionalCall', _96 => _96(state.fiberId, patch.root, patch.nodes, budget + 1)]), () => ( [this.bridge.provideEffect(state.fiberId, patch.root, patch.nodes)])));
|
|
2353
2426
|
} catch (error) {
|
|
2354
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2427
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _97 => _97.bridge, 'access', _98 => _98.provideErrorBatch, 'optionalCall', _99 => _99(state.fiberId, state.registry.register(error), budget + 1)]), () => ( [this.bridge.provideError(state.fiberId, state.registry.register(error))])));
|
|
2355
2428
|
}
|
|
2356
2429
|
continue;
|
|
2357
2430
|
}
|
|
@@ -2361,9 +2434,9 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2361
2434
|
try {
|
|
2362
2435
|
const next = fn(value);
|
|
2363
2436
|
const patch = state.builder.append(next);
|
|
2364
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2437
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _100 => _100.bridge, 'access', _101 => _101.provideEffectBatch, 'optionalCall', _102 => _102(state.fiberId, patch.root, patch.nodes, budget + 1)]), () => ( [this.bridge.provideEffect(state.fiberId, patch.root, patch.nodes)])));
|
|
2365
2438
|
} catch (error) {
|
|
2366
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2439
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _103 => _103.bridge, 'access', _104 => _104.provideErrorBatch, 'optionalCall', _105 => _105(state.fiberId, state.registry.register(error), budget + 1)]), () => ( [this.bridge.provideError(state.fiberId, state.registry.register(error))])));
|
|
2367
2440
|
}
|
|
2368
2441
|
continue;
|
|
2369
2442
|
}
|
|
@@ -2371,9 +2444,9 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2371
2444
|
const effect = state.registry.get(event.effectRef);
|
|
2372
2445
|
try {
|
|
2373
2446
|
const child = this.runtime.fork(effect, event.scopeId);
|
|
2374
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2447
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _106 => _106.bridge, 'access', _107 => _107.provideValueBatch, 'optionalCall', _108 => _108(state.fiberId, state.registry.register(child), budget + 1)]), () => ( [this.bridge.provideValue(state.fiberId, state.registry.register(child))])));
|
|
2375
2448
|
} catch (error) {
|
|
2376
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2449
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _109 => _109.bridge, 'access', _110 => _110.provideErrorBatch, 'optionalCall', _111 => _111(state.fiberId, state.registry.register(error), budget + 1)]), () => ( [this.bridge.provideError(state.fiberId, state.registry.register(error))])));
|
|
2377
2450
|
}
|
|
2378
2451
|
continue;
|
|
2379
2452
|
}
|
|
@@ -2387,7 +2460,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2387
2460
|
}
|
|
2388
2461
|
}
|
|
2389
2462
|
} catch (error) {
|
|
2390
|
-
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access',
|
|
2463
|
+
events.unshift(..._nullishCoalesce(_optionalChain([this, 'access', _112 => _112.bridge, 'access', _113 => _113.provideErrorBatch, 'optionalCall', _114 => _114(state.fiberId, state.registry.register(error), budget + 1)]), () => ( [this.bridge.provideError(state.fiberId, state.registry.register(error))])));
|
|
2391
2464
|
}
|
|
2392
2465
|
}
|
|
2393
2466
|
if (!state.completed) this.enqueueFiber(state, "budget-yield");
|
|
@@ -2443,7 +2516,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2443
2516
|
}
|
|
2444
2517
|
};
|
|
2445
2518
|
state.pendingCleanups.add(cancelCleanup);
|
|
2446
|
-
state.handle.addFinalizer(() => _optionalChain([cancelCleanup, 'optionalCall',
|
|
2519
|
+
state.handle.addFinalizer(() => _optionalChain([cancelCleanup, 'optionalCall', _115 => _115()]));
|
|
2447
2520
|
}
|
|
2448
2521
|
} catch (error) {
|
|
2449
2522
|
cleanup();
|
|
@@ -2460,7 +2533,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2460
2533
|
const deadlineAt = action.timeoutMs === void 0 ? void 0 : Date.now() + action.timeoutMs;
|
|
2461
2534
|
const cleanup = () => {
|
|
2462
2535
|
state.pendingCleanups.delete(cleanup);
|
|
2463
|
-
_optionalChain([this, 'access',
|
|
2536
|
+
_optionalChain([this, 'access', _116 => _116.timerWheel, 'optionalAccess', _117 => _117.cancel, 'call', _118 => _118(state.deadlineTimerId)]);
|
|
2464
2537
|
if (state.hostActionToken === token) state.deadlineTimerId = void 0;
|
|
2465
2538
|
};
|
|
2466
2539
|
state.pendingCleanups.add(cleanup);
|
|
@@ -2557,14 +2630,14 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2557
2630
|
if (state.completed) return;
|
|
2558
2631
|
if (!state.controller.signal.aborted) state.controller.abort(reason);
|
|
2559
2632
|
for (const cleanup of Array.from(state.pendingCleanups)) cleanup();
|
|
2560
|
-
const events = _nullishCoalesce(_optionalChain([this, 'access',
|
|
2633
|
+
const events = _nullishCoalesce(_optionalChain([this, 'access', _119 => _119.bridge, 'access', _120 => _120.interruptBatch, 'optionalCall', _121 => _121(state.fiberId, state.registry.register(reason), DEFAULT_BUDGET)]), () => ( [this.bridge.interrupt(state.fiberId, state.registry.register(reason))]));
|
|
2561
2634
|
this.drive(state, events);
|
|
2562
2635
|
}
|
|
2563
2636
|
markSuspended(state, reason) {
|
|
2564
2637
|
if (state.status !== "suspended") {
|
|
2565
2638
|
this.suspendedFibers += 1;
|
|
2566
2639
|
state.status = "suspended";
|
|
2567
|
-
_optionalChain([this, 'access',
|
|
2640
|
+
_optionalChain([this, 'access', _122 => _122.fiberRegistry, 'optionalAccess', _123 => _123.markSuspended, 'call', _124 => _124(state.fiberId)]);
|
|
2568
2641
|
state.handle.setEngineStatus("suspended");
|
|
2569
2642
|
state.handle.emit({ type: "fiber.suspend", fiberId: state.fiberId, reason });
|
|
2570
2643
|
}
|
|
@@ -2573,7 +2646,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2573
2646
|
if (state.status === "suspended") {
|
|
2574
2647
|
this.suspendedFibers = Math.max(0, this.suspendedFibers - 1);
|
|
2575
2648
|
state.status = "running";
|
|
2576
|
-
_optionalChain([this, 'access',
|
|
2649
|
+
_optionalChain([this, 'access', _125 => _125.fiberRegistry, 'optionalAccess', _126 => _126.markRunning, 'call', _127 => _127(state.fiberId)]);
|
|
2577
2650
|
state.handle.setEngineStatus("running");
|
|
2578
2651
|
state.handle.emit({ type: "fiber.resume", fiberId: state.fiberId });
|
|
2579
2652
|
}
|
|
@@ -2582,7 +2655,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2582
2655
|
if (state.completed) return;
|
|
2583
2656
|
state.completed = true;
|
|
2584
2657
|
state.status = "done";
|
|
2585
|
-
_optionalChain([this, 'access',
|
|
2658
|
+
_optionalChain([this, 'access', _128 => _128.fiberRegistry, 'optionalAccess', _129 => _129.markDone, 'call', _130 => _130(state.fiberId, "done")]);
|
|
2586
2659
|
this.completedFibers += 1;
|
|
2587
2660
|
this.cleanupState(state);
|
|
2588
2661
|
state.handle.succeed(value);
|
|
@@ -2591,7 +2664,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2591
2664
|
if (state.completed) return;
|
|
2592
2665
|
state.completed = true;
|
|
2593
2666
|
state.status = "failed";
|
|
2594
|
-
_optionalChain([this, 'access',
|
|
2667
|
+
_optionalChain([this, 'access', _131 => _131.fiberRegistry, 'optionalAccess', _132 => _132.markDone, 'call', _133 => _133(state.fiberId, "failed")]);
|
|
2595
2668
|
this.failedFibers += 1;
|
|
2596
2669
|
this.cleanupState(state);
|
|
2597
2670
|
state.handle.fail(error);
|
|
@@ -2600,7 +2673,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2600
2673
|
if (state.completed) return;
|
|
2601
2674
|
state.completed = true;
|
|
2602
2675
|
state.status = "failed";
|
|
2603
|
-
_optionalChain([this, 'access',
|
|
2676
|
+
_optionalChain([this, 'access', _134 => _134.fiberRegistry, 'optionalAccess', _135 => _135.markDone, 'call', _136 => _136(state.fiberId, "failed")]);
|
|
2604
2677
|
this.failedFibers += 1;
|
|
2605
2678
|
this.cleanupState(state);
|
|
2606
2679
|
state.handle.die(defect);
|
|
@@ -2609,7 +2682,7 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2609
2682
|
if (state.completed) return;
|
|
2610
2683
|
state.completed = true;
|
|
2611
2684
|
state.status = "interrupted";
|
|
2612
|
-
_optionalChain([this, 'access',
|
|
2685
|
+
_optionalChain([this, 'access', _137 => _137.fiberRegistry, 'optionalAccess', _138 => _138.markDone, 'call', _139 => _139(state.fiberId, "interrupted")]);
|
|
2613
2686
|
this.interruptedFibers += 1;
|
|
2614
2687
|
this.cleanupState(state);
|
|
2615
2688
|
state.handle.interrupted();
|
|
@@ -2617,34 +2690,34 @@ var WasmFiberEngine = (_class14 = class {
|
|
|
2617
2690
|
cleanupState(state) {
|
|
2618
2691
|
this.runningFibers = Math.max(0, this.runningFibers - 1);
|
|
2619
2692
|
if (state.status === "suspended") this.suspendedFibers = Math.max(0, this.suspendedFibers - 1);
|
|
2620
|
-
_optionalChain([this, 'access',
|
|
2693
|
+
_optionalChain([this, 'access', _140 => _140.timerWheel, 'optionalAccess', _141 => _141.cancel, 'call', _142 => _142(state.deadlineTimerId)]);
|
|
2621
2694
|
state.deadlineTimerId = void 0;
|
|
2622
2695
|
for (const cleanup of Array.from(state.pendingCleanups)) cleanup();
|
|
2623
2696
|
state.pendingCleanups.clear();
|
|
2624
2697
|
this.pendingResumes.delete(state.fiberId);
|
|
2625
2698
|
this.bridge.dropFiber(state.fiberId);
|
|
2626
|
-
_optionalChain([this, 'access',
|
|
2699
|
+
_optionalChain([this, 'access', _143 => _143.fiberRegistry, 'optionalAccess', _144 => _144.dropFiber, 'call', _145 => _145(state.fiberId)]);
|
|
2627
2700
|
state.registry.clear();
|
|
2628
2701
|
this.states.delete(state.fiberId);
|
|
2629
2702
|
}
|
|
2630
|
-
},
|
|
2703
|
+
}, _class15);
|
|
2631
2704
|
|
|
2632
2705
|
// src/core/runtime/capabilities.ts
|
|
2633
2706
|
function runtimeCapabilities() {
|
|
2634
2707
|
const mod = resolveWasmModule();
|
|
2635
2708
|
return {
|
|
2636
2709
|
wasmAvailable: !!mod,
|
|
2637
|
-
wasmFiberEngine: typeof _optionalChain([mod, 'optionalAccess',
|
|
2638
|
-
wasmRingBuffer: typeof _optionalChain([mod, 'optionalAccess',
|
|
2639
|
-
wasmScheduler: typeof _optionalChain([mod, 'optionalAccess',
|
|
2640
|
-
wasmFiberRegistry: typeof _optionalChain([mod, 'optionalAccess',
|
|
2641
|
-
wasmFiberReadyQueue: typeof _optionalChain([mod, 'optionalAccess',
|
|
2710
|
+
wasmFiberEngine: typeof _optionalChain([mod, 'optionalAccess', _146 => _146.BrassWasmVm]) === "function",
|
|
2711
|
+
wasmRingBuffer: typeof _optionalChain([mod, 'optionalAccess', _147 => _147.BrassWasmRingBuffer]) === "function",
|
|
2712
|
+
wasmScheduler: typeof _optionalChain([mod, 'optionalAccess', _148 => _148.BrassWasmSchedulerStateMachine]) === "function",
|
|
2713
|
+
wasmFiberRegistry: typeof _optionalChain([mod, 'optionalAccess', _149 => _149.BrassWasmFiberRegistry]) === "function",
|
|
2714
|
+
wasmFiberReadyQueue: typeof _optionalChain([mod, 'optionalAccess', _150 => _150.BrassWasmFiberReadyQueue]) === "function",
|
|
2642
2715
|
wasmBinaryAbi: hasBinaryVmAbi(mod),
|
|
2643
|
-
wasmStreamChunks: typeof _optionalChain([mod, 'optionalAccess',
|
|
2716
|
+
wasmStreamChunks: typeof _optionalChain([mod, 'optionalAccess', _151 => _151.BrassWasmChunkBuffer]) === "function"
|
|
2644
2717
|
};
|
|
2645
2718
|
}
|
|
2646
2719
|
function hasBinaryVmAbi(mod) {
|
|
2647
|
-
const Ctor = _optionalChain([mod, 'optionalAccess',
|
|
2720
|
+
const Ctor = _optionalChain([mod, 'optionalAccess', _152 => _152.BrassWasmVm]);
|
|
2648
2721
|
if (typeof Ctor !== "function") return false;
|
|
2649
2722
|
try {
|
|
2650
2723
|
const vm = new Ctor();
|
|
@@ -2666,6 +2739,12 @@ function normalizeRuntimeEngineMode(value) {
|
|
|
2666
2739
|
function unreachableEngine(value) {
|
|
2667
2740
|
throw new Error(`brass-runtime unsupported engine '${String(value)}'`);
|
|
2668
2741
|
}
|
|
2742
|
+
var runtimeOptionsSchema = _chunkSPUEME2Bcjs.Schema.object({
|
|
2743
|
+
env: _chunkSPUEME2Bcjs.Schema.any(),
|
|
2744
|
+
lane: _chunkSPUEME2Bcjs.Schema.string({ minLength: 1 }).optional(),
|
|
2745
|
+
inferLane: _chunkSPUEME2Bcjs.Schema.boolean().optional(),
|
|
2746
|
+
engine: _chunkSPUEME2Bcjs.Schema.enum(["ts", "wasm"]).optional()
|
|
2747
|
+
}, { unknownKeys: "passthrough" });
|
|
2669
2748
|
var Runtime = class _Runtime {
|
|
2670
2749
|
|
|
2671
2750
|
|
|
@@ -2681,6 +2760,7 @@ var Runtime = class _Runtime {
|
|
|
2681
2760
|
// opcional: registry para observabilidad
|
|
2682
2761
|
|
|
2683
2762
|
constructor(args) {
|
|
2763
|
+
_chunkSPUEME2Bcjs.parseConfig.call(void 0, "RuntimeOptions", runtimeOptionsSchema, args);
|
|
2684
2764
|
this.env = args.env;
|
|
2685
2765
|
this.scheduler = _nullishCoalesce(args.scheduler, () => ( globalScheduler));
|
|
2686
2766
|
this.lane = args.lane;
|
|
@@ -2733,7 +2813,7 @@ var Runtime = class _Runtime {
|
|
|
2733
2813
|
}
|
|
2734
2814
|
resolveFiberLane(parent) {
|
|
2735
2815
|
if (this.lane !== void 0) return this.lane;
|
|
2736
|
-
const parentLane = _optionalChain([parent, 'optionalAccess',
|
|
2816
|
+
const parentLane = _optionalChain([parent, 'optionalAccess', _153 => _153.lane]);
|
|
2737
2817
|
if (typeof parentLane === "string" && parentLane.length > 0) return parentLane;
|
|
2738
2818
|
if (!this.inferLane) return void 0;
|
|
2739
2819
|
return inferCallerLaneFromStack(void 0, "runtime");
|
|
@@ -2742,11 +2822,15 @@ var Runtime = class _Runtime {
|
|
|
2742
2822
|
if (this.hooks === NoopHooks) return;
|
|
2743
2823
|
const f = getCurrentFiber();
|
|
2744
2824
|
const ctx = {
|
|
2745
|
-
fiberId: _optionalChain([f, 'optionalAccess',
|
|
2746
|
-
scopeId: _optionalChain([f, 'optionalAccess',
|
|
2825
|
+
fiberId: _optionalChain([f, 'optionalAccess', _154 => _154.id]),
|
|
2826
|
+
scopeId: _optionalChain([f, 'optionalAccess', _155 => _155.scopeId]),
|
|
2747
2827
|
// ✅ FIX: era f?.scope
|
|
2748
|
-
traceId: _optionalChain([f, 'optionalAccess',
|
|
2749
|
-
spanId: _optionalChain([f, 'optionalAccess',
|
|
2828
|
+
traceId: _optionalChain([f, 'optionalAccess', _156 => _156.fiberContext, 'optionalAccess', _157 => _157.trace, 'optionalAccess', _158 => _158.traceId]),
|
|
2829
|
+
spanId: _optionalChain([f, 'optionalAccess', _159 => _159.fiberContext, 'optionalAccess', _160 => _160.trace, 'optionalAccess', _161 => _161.spanId]),
|
|
2830
|
+
parentSpanId: _optionalChain([f, 'optionalAccess', _162 => _162.fiberContext, 'optionalAccess', _163 => _163.trace, 'optionalAccess', _164 => _164.parentSpanId]),
|
|
2831
|
+
traceState: _optionalChain([f, 'optionalAccess', _165 => _165.fiberContext, 'optionalAccess', _166 => _166.trace, 'optionalAccess', _167 => _167.traceState]),
|
|
2832
|
+
baggage: _optionalChain([f, 'optionalAccess', _168 => _168.fiberContext, 'optionalAccess', _169 => _169.trace, 'optionalAccess', _170 => _170.baggage]),
|
|
2833
|
+
sampled: _optionalChain([f, 'optionalAccess', _171 => _171.fiberContext, 'optionalAccess', _172 => _172.trace, 'optionalAccess', _173 => _173.sampled])
|
|
2750
2834
|
};
|
|
2751
2835
|
this.hooks.emit(ev, ctx);
|
|
2752
2836
|
}
|
|
@@ -2760,7 +2844,7 @@ var Runtime = class _Runtime {
|
|
|
2760
2844
|
if (lane !== void 0) fiber.lane = lane;
|
|
2761
2845
|
if (scopeId !== void 0) fiber.scopeId = scopeId;
|
|
2762
2846
|
this.forkPolicy.initChild(fiber, parent, scopeId);
|
|
2763
|
-
_optionalChain([fiber, 'access',
|
|
2847
|
+
_optionalChain([fiber, 'access', _174 => _174.schedule, 'optionalCall', _175 => _175("initial-step")]);
|
|
2764
2848
|
return fiber;
|
|
2765
2849
|
}
|
|
2766
2850
|
stats() {
|
|
@@ -2771,7 +2855,7 @@ var Runtime = class _Runtime {
|
|
|
2771
2855
|
return runtimeCapabilities();
|
|
2772
2856
|
}
|
|
2773
2857
|
shutdown() {
|
|
2774
|
-
return _optionalChain([this, 'access',
|
|
2858
|
+
return _optionalChain([this, 'access', _176 => _176.fiberEngine, 'access', _177 => _177.shutdown, 'optionalCall', _178 => _178()]);
|
|
2775
2859
|
}
|
|
2776
2860
|
unsafeRunAsync(effect, cb) {
|
|
2777
2861
|
const fiber = this.fork(effect);
|
|
@@ -2784,8 +2868,8 @@ var Runtime = class _Runtime {
|
|
|
2784
2868
|
if (exit._tag === "Success") resolve(exit.value);
|
|
2785
2869
|
else {
|
|
2786
2870
|
const c = exit.cause;
|
|
2787
|
-
if (_optionalChain([c, 'optionalAccess',
|
|
2788
|
-
else if (_optionalChain([c, 'optionalAccess',
|
|
2871
|
+
if (_optionalChain([c, 'optionalAccess', _179 => _179._tag]) === "Fail") reject(c.error);
|
|
2872
|
+
else if (_optionalChain([c, 'optionalAccess', _180 => _180._tag]) === "Die") reject(c.defect instanceof Error ? c.defect : new Error(String(c.defect)));
|
|
2789
2873
|
else reject(new Error("Interrupted"));
|
|
2790
2874
|
}
|
|
2791
2875
|
});
|
|
@@ -2797,7 +2881,7 @@ var Runtime = class _Runtime {
|
|
|
2797
2881
|
});
|
|
2798
2882
|
}
|
|
2799
2883
|
delay(ms, eff) {
|
|
2800
|
-
return asyncEffect((_env, cb) => {
|
|
2884
|
+
return _chunkDJQ7OMMBcjs.asyncEffect.call(void 0, (_env, cb) => {
|
|
2801
2885
|
const handle = setTimeout(() => {
|
|
2802
2886
|
this.unsafeRunAsync(eff, cb);
|
|
2803
2887
|
}, ms);
|
|
@@ -2909,7 +2993,7 @@ function resetAbortablePromiseStats() {
|
|
|
2909
2993
|
abortablePromiseLabels.clear();
|
|
2910
2994
|
}
|
|
2911
2995
|
var normalizeAbortablePromiseLabel = (label) => {
|
|
2912
|
-
const value = _optionalChain([label, 'optionalAccess',
|
|
2996
|
+
const value = _optionalChain([label, 'optionalAccess', _181 => _181.trim, 'call', _182 => _182()]);
|
|
2913
2997
|
return value && value.length > 0 ? value.slice(0, 160) : "anonymous";
|
|
2914
2998
|
};
|
|
2915
2999
|
var makeTimeoutReason = (timeoutMs, label) => ({
|
|
@@ -2938,7 +3022,7 @@ function fromPromiseAbortable(make, onReject, options = {}) {
|
|
|
2938
3022
|
done = true;
|
|
2939
3023
|
cleanup();
|
|
2940
3024
|
recordAbortablePromiseFinish(label, outcome);
|
|
2941
|
-
_optionalChain([options, 'access',
|
|
3025
|
+
_optionalChain([options, 'access', _183 => _183.onFinish, 'optionalCall', _184 => _184({
|
|
2942
3026
|
label,
|
|
2943
3027
|
outcome,
|
|
2944
3028
|
durationMs: Math.round(performance.now() - startedAt),
|
|
@@ -2947,23 +3031,23 @@ function fromPromiseAbortable(make, onReject, options = {}) {
|
|
|
2947
3031
|
cb(exit);
|
|
2948
3032
|
};
|
|
2949
3033
|
recordAbortablePromiseStart(label);
|
|
2950
|
-
_optionalChain([options, 'access',
|
|
3034
|
+
_optionalChain([options, 'access', _185 => _185.onStart, 'optionalCall', _186 => _186(label)]);
|
|
2951
3035
|
if (timeoutMs !== void 0 && timeoutMs > 0) {
|
|
2952
3036
|
timeoutHandle = setTimeout(() => {
|
|
2953
|
-
const reason = _nullishCoalesce(_optionalChain([options, 'access',
|
|
3037
|
+
const reason = _nullishCoalesce(_optionalChain([options, 'access', _187 => _187.timeoutReason, 'optionalCall', _188 => _188()]), () => ( makeTimeoutReason(timeoutMs, label)));
|
|
2954
3038
|
try {
|
|
2955
3039
|
controller.abort(reason);
|
|
2956
3040
|
} catch (e9) {
|
|
2957
3041
|
controller.abort();
|
|
2958
3042
|
}
|
|
2959
|
-
finish("timeout", Exit.failCause(Cause.fail(onReject(reason))), reason);
|
|
3043
|
+
finish("timeout", _chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.fail(onReject(reason))), reason);
|
|
2960
3044
|
}, timeoutMs);
|
|
2961
3045
|
}
|
|
2962
3046
|
let promise;
|
|
2963
3047
|
try {
|
|
2964
3048
|
promise = make(controller.signal, env);
|
|
2965
3049
|
} catch (err) {
|
|
2966
|
-
finish("failure", Exit.failCause(Cause.fail(onReject(err))), err);
|
|
3050
|
+
finish("failure", _chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.fail(onReject(err))), err);
|
|
2967
3051
|
return () => void 0;
|
|
2968
3052
|
}
|
|
2969
3053
|
promise.then((value) => {
|
|
@@ -2971,13 +3055,13 @@ function fromPromiseAbortable(make, onReject, options = {}) {
|
|
|
2971
3055
|
recordAbortablePromiseLateSettlement(label);
|
|
2972
3056
|
return;
|
|
2973
3057
|
}
|
|
2974
|
-
finish("success", Exit.succeed(value));
|
|
3058
|
+
finish("success", _chunkDJQ7OMMBcjs.Exit.succeed(value));
|
|
2975
3059
|
}).catch((err) => {
|
|
2976
3060
|
if (done) {
|
|
2977
3061
|
recordAbortablePromiseLateSettlement(label);
|
|
2978
3062
|
return;
|
|
2979
3063
|
}
|
|
2980
|
-
finish("failure", Exit.failCause(Cause.fail(onReject(err))), err);
|
|
3064
|
+
finish("failure", _chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.fail(onReject(err))), err);
|
|
2981
3065
|
});
|
|
2982
3066
|
return () => {
|
|
2983
3067
|
if (done) return;
|
|
@@ -2985,7 +3069,7 @@ function fromPromiseAbortable(make, onReject, options = {}) {
|
|
|
2985
3069
|
controller.abort();
|
|
2986
3070
|
} catch (e10) {
|
|
2987
3071
|
}
|
|
2988
|
-
finish("interrupt", Exit.failCause(Cause.interrupt()));
|
|
3072
|
+
finish("interrupt", _chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.interrupt()));
|
|
2989
3073
|
};
|
|
2990
3074
|
}
|
|
2991
3075
|
};
|
|
@@ -3027,21 +3111,21 @@ function setBenchmarkBudget(budget) {
|
|
|
3027
3111
|
function getBenchmarkBudget() {
|
|
3028
3112
|
return __benchmarkBudget;
|
|
3029
3113
|
}
|
|
3030
|
-
var RuntimeFiber = (
|
|
3114
|
+
var RuntimeFiber = (_class16 = class {
|
|
3031
3115
|
|
|
3032
3116
|
// 👇 CLAVE: guardar el runtime en el fiber (para getCurrentRuntime())
|
|
3033
3117
|
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3118
|
+
__init99() {this.closing = null}
|
|
3119
|
+
__init100() {this.finishing = false}
|
|
3120
|
+
__init101() {this.runState = RUN.RUNNING}
|
|
3121
|
+
__init102() {this.interrupted = false}
|
|
3122
|
+
__init103() {this.result = null}
|
|
3123
|
+
__init104() {this.joiners = []}
|
|
3040
3124
|
// estado de evaluación
|
|
3041
3125
|
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3126
|
+
__init105() {this.stack = []}
|
|
3127
|
+
__init106() {this.fiberFinalizers = []}
|
|
3128
|
+
__init107() {this.finalizersDrained = false}
|
|
3045
3129
|
|
|
3046
3130
|
|
|
3047
3131
|
|
|
@@ -3055,12 +3139,12 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3055
3139
|
|
|
3056
3140
|
// Reusable async callback state — avoids allocating a closure per Async step.
|
|
3057
3141
|
// These fields are reset at the start of each Async case and reused.
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3142
|
+
__init108() {this._syncResolved = false}
|
|
3143
|
+
__init109() {this._syncExit = null}
|
|
3144
|
+
__init110() {this._asyncRegistered = false}
|
|
3061
3145
|
|
|
3062
3146
|
|
|
3063
|
-
constructor(runtime, effect) {;
|
|
3147
|
+
constructor(runtime, effect) {;_class16.prototype.__init99.call(this);_class16.prototype.__init100.call(this);_class16.prototype.__init101.call(this);_class16.prototype.__init102.call(this);_class16.prototype.__init103.call(this);_class16.prototype.__init104.call(this);_class16.prototype.__init105.call(this);_class16.prototype.__init106.call(this);_class16.prototype.__init107.call(this);_class16.prototype.__init108.call(this);_class16.prototype.__init109.call(this);_class16.prototype.__init110.call(this);_class16.prototype.__init111.call(this);
|
|
3064
3148
|
this.id = nextId++;
|
|
3065
3149
|
this.runtime = runtime;
|
|
3066
3150
|
this.current = effect;
|
|
@@ -3073,21 +3157,21 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3073
3157
|
return;
|
|
3074
3158
|
}
|
|
3075
3159
|
this._syncResolved = true;
|
|
3076
|
-
_optionalChain([this, 'access',
|
|
3160
|
+
_optionalChain([this, 'access', _189 => _189._asyncDetach, 'optionalCall', _190 => _190()]);
|
|
3077
3161
|
this._asyncDetach = void 0;
|
|
3078
3162
|
if (exit._tag === "Success") {
|
|
3079
|
-
this.current = Async.succeed(exit.value);
|
|
3163
|
+
this.current = _chunkDJQ7OMMBcjs.Async.succeed(exit.value);
|
|
3080
3164
|
this.schedule("async-resume");
|
|
3081
3165
|
return;
|
|
3082
3166
|
}
|
|
3083
3167
|
const cause = exit.cause;
|
|
3084
3168
|
if (cause._tag === "Interrupt") {
|
|
3085
|
-
this.notify(Exit.failCause(Cause.interrupt()));
|
|
3169
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.interrupt()));
|
|
3086
3170
|
} else if (cause._tag === "Fail") {
|
|
3087
|
-
this.current = Async.fail(cause.error);
|
|
3171
|
+
this.current = _chunkDJQ7OMMBcjs.Async.fail(cause.error);
|
|
3088
3172
|
this.schedule("async-resume");
|
|
3089
3173
|
} else {
|
|
3090
|
-
this.notify(Exit.failCause(Cause.die(cause.defect)));
|
|
3174
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(cause.defect)));
|
|
3091
3175
|
}
|
|
3092
3176
|
};
|
|
3093
3177
|
this.boundStep = () => {
|
|
@@ -3121,8 +3205,12 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3121
3205
|
this.runtime.hooks.emit(ev, {
|
|
3122
3206
|
fiberId: this.id,
|
|
3123
3207
|
scopeId: this.scopeId,
|
|
3124
|
-
traceId: _optionalChain([this, 'access',
|
|
3125
|
-
spanId: _optionalChain([this, 'access',
|
|
3208
|
+
traceId: _optionalChain([this, 'access', _191 => _191.fiberContext, 'optionalAccess', _192 => _192.trace, 'optionalAccess', _193 => _193.traceId]),
|
|
3209
|
+
spanId: _optionalChain([this, 'access', _194 => _194.fiberContext, 'optionalAccess', _195 => _195.trace, 'optionalAccess', _196 => _196.spanId]),
|
|
3210
|
+
parentSpanId: _optionalChain([this, 'access', _197 => _197.fiberContext, 'optionalAccess', _198 => _198.trace, 'optionalAccess', _199 => _199.parentSpanId]),
|
|
3211
|
+
traceState: _optionalChain([this, 'access', _200 => _200.fiberContext, 'optionalAccess', _201 => _201.trace, 'optionalAccess', _202 => _202.traceState]),
|
|
3212
|
+
baggage: _optionalChain([this, 'access', _203 => _203.fiberContext, 'optionalAccess', _204 => _204.trace, 'optionalAccess', _205 => _205.baggage]),
|
|
3213
|
+
sampled: _optionalChain([this, 'access', _206 => _206.fiberContext, 'optionalAccess', _207 => _207.trace, 'optionalAccess', _208 => _208.sampled])
|
|
3126
3214
|
});
|
|
3127
3215
|
}
|
|
3128
3216
|
addFinalizer(f) {
|
|
@@ -3168,7 +3256,7 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3168
3256
|
);
|
|
3169
3257
|
if (result === "dropped") {
|
|
3170
3258
|
this.runState = RUN.DONE;
|
|
3171
|
-
this.notify(Exit.failCause(Cause.die(new Error(`Brass scheduler dropped ${label} because the lane queue is full`))));
|
|
3259
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(new Error(`Brass scheduler dropped ${label} because the lane queue is full`))));
|
|
3172
3260
|
}
|
|
3173
3261
|
}
|
|
3174
3262
|
runFinalizersOnce(exit) {
|
|
@@ -3209,21 +3297,21 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3209
3297
|
onSuccess(value) {
|
|
3210
3298
|
const frame = this.stack.pop();
|
|
3211
3299
|
if (!frame) {
|
|
3212
|
-
this.notify(Exit.succeed(value));
|
|
3300
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.succeed(value));
|
|
3213
3301
|
return;
|
|
3214
3302
|
}
|
|
3215
3303
|
if (frame._tag === "SuccessCont") {
|
|
3216
3304
|
try {
|
|
3217
3305
|
this.current = frame.k(value);
|
|
3218
3306
|
} catch (e) {
|
|
3219
|
-
this.notify(Exit.failCause(Cause.die(e)));
|
|
3307
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(e)));
|
|
3220
3308
|
}
|
|
3221
3309
|
return;
|
|
3222
3310
|
}
|
|
3223
3311
|
try {
|
|
3224
3312
|
this.current = frame.onSuccess(value);
|
|
3225
3313
|
} catch (e) {
|
|
3226
|
-
this.notify(Exit.failCause(Cause.die(e)));
|
|
3314
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(e)));
|
|
3227
3315
|
}
|
|
3228
3316
|
}
|
|
3229
3317
|
onFailure(error) {
|
|
@@ -3239,13 +3327,13 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3239
3327
|
}
|
|
3240
3328
|
}
|
|
3241
3329
|
}
|
|
3242
|
-
this.notify(Exit.failCause(Cause.fail(error)));
|
|
3330
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.fail(error)));
|
|
3243
3331
|
}
|
|
3244
|
-
|
|
3332
|
+
__init111() {this.budget = DEFAULT_BUDGET2}
|
|
3245
3333
|
step() {
|
|
3246
3334
|
if (this.result != null) return STEP.DONE;
|
|
3247
3335
|
if (this.interrupted) {
|
|
3248
|
-
this.notify(Exit.failCause(Cause.interrupt()));
|
|
3336
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.interrupt()));
|
|
3249
3337
|
return STEP.DONE;
|
|
3250
3338
|
}
|
|
3251
3339
|
this.budget = _nullishCoalesce(__benchmarkBudget, () => ( DEFAULT_BUDGET2));
|
|
@@ -3302,11 +3390,11 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3302
3390
|
} else {
|
|
3303
3391
|
const cause = resolvedExit.cause;
|
|
3304
3392
|
if (cause._tag === "Interrupt") {
|
|
3305
|
-
this.notify(Exit.failCause(Cause.interrupt()));
|
|
3393
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.interrupt()));
|
|
3306
3394
|
} else if (cause._tag === "Fail") {
|
|
3307
3395
|
this.onFailure(cause.error);
|
|
3308
3396
|
} else {
|
|
3309
|
-
this.notify(Exit.failCause(Cause.die(cause.defect)));
|
|
3397
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(cause.defect)));
|
|
3310
3398
|
}
|
|
3311
3399
|
}
|
|
3312
3400
|
break;
|
|
@@ -3362,7 +3450,7 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3362
3450
|
syncTrampoline() {
|
|
3363
3451
|
while (this.budget-- > 0) {
|
|
3364
3452
|
let cur = this.current;
|
|
3365
|
-
while (cur._tag === "FlatMap" && _optionalChain([cur, 'access',
|
|
3453
|
+
while (cur._tag === "FlatMap" && _optionalChain([cur, 'access', _209 => _209.first, 'optionalAccess', _210 => _210._tag]) === "FlatMap") {
|
|
3366
3454
|
this.stack.push({ _tag: "SuccessCont", k: cur.andThen });
|
|
3367
3455
|
cur = cur.first;
|
|
3368
3456
|
}
|
|
@@ -3377,7 +3465,7 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3377
3465
|
try {
|
|
3378
3466
|
this.current = andThen(first.value);
|
|
3379
3467
|
} catch (e) {
|
|
3380
|
-
this.notify(Exit.failCause(Cause.die(e)));
|
|
3468
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(e)));
|
|
3381
3469
|
return TRAMPOLINE.DONE;
|
|
3382
3470
|
}
|
|
3383
3471
|
continue;
|
|
@@ -3387,7 +3475,7 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3387
3475
|
const value = first.thunk(this.env);
|
|
3388
3476
|
this.current = andThen(value);
|
|
3389
3477
|
} catch (e) {
|
|
3390
|
-
this.notify(Exit.failCause(Cause.die(e)));
|
|
3478
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(e)));
|
|
3391
3479
|
return TRAMPOLINE.DONE;
|
|
3392
3480
|
}
|
|
3393
3481
|
continue;
|
|
@@ -3414,7 +3502,7 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3414
3502
|
try {
|
|
3415
3503
|
this.current = andThen(exit.value);
|
|
3416
3504
|
} catch (e) {
|
|
3417
|
-
this.notify(Exit.failCause(Cause.die(e)));
|
|
3505
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(e)));
|
|
3418
3506
|
return TRAMPOLINE.DONE;
|
|
3419
3507
|
}
|
|
3420
3508
|
continue;
|
|
@@ -3424,9 +3512,9 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3424
3512
|
if (cause._tag === "Fail") {
|
|
3425
3513
|
this.onFailure(cause.error);
|
|
3426
3514
|
} else if (cause._tag === "Interrupt") {
|
|
3427
|
-
this.notify(Exit.failCause(Cause.interrupt()));
|
|
3515
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.interrupt()));
|
|
3428
3516
|
} else {
|
|
3429
|
-
this.notify(Exit.failCause(Cause.die(cause.defect)));
|
|
3517
|
+
this.notify(_chunkDJQ7OMMBcjs.Exit.failCause(_chunkDJQ7OMMBcjs.Cause.die(cause.defect)));
|
|
3430
3518
|
}
|
|
3431
3519
|
return this.result != null ? TRAMPOLINE.DONE : TRAMPOLINE.CONTINUE;
|
|
3432
3520
|
}
|
|
@@ -3464,13 +3552,13 @@ var RuntimeFiber = (_class15 = class {
|
|
|
3464
3552
|
}
|
|
3465
3553
|
return TRAMPOLINE.CONTINUE;
|
|
3466
3554
|
}
|
|
3467
|
-
},
|
|
3555
|
+
}, _class16);
|
|
3468
3556
|
function getCurrentFiber() {
|
|
3469
3557
|
return _current;
|
|
3470
3558
|
}
|
|
3471
3559
|
function unsafeGetCurrentRuntime() {
|
|
3472
3560
|
const f = getCurrentFiber();
|
|
3473
|
-
if (!_optionalChain([f, 'optionalAccess',
|
|
3561
|
+
if (!_optionalChain([f, 'optionalAccess', _211 => _211.runtime])) {
|
|
3474
3562
|
throw new Error("unsafeGetCurrentRuntime: no current fiber/runtime");
|
|
3475
3563
|
}
|
|
3476
3564
|
return f.runtime;
|
|
@@ -3486,13 +3574,13 @@ function withCurrentFiber(fiber, f) {
|
|
|
3486
3574
|
}
|
|
3487
3575
|
|
|
3488
3576
|
// src/core/runtime/engine/JsFiberEngine.ts
|
|
3489
|
-
var JsFiberEngine = (
|
|
3490
|
-
constructor(runtime) {;
|
|
3577
|
+
var JsFiberEngine = (_class17 = class {
|
|
3578
|
+
constructor(runtime) {;_class17.prototype.__init112.call(this);_class17.prototype.__init113.call(this);
|
|
3491
3579
|
this.runtime = runtime;
|
|
3492
3580
|
}
|
|
3493
3581
|
|
|
3494
|
-
|
|
3495
|
-
|
|
3582
|
+
__init112() {this.kind = "ts"}
|
|
3583
|
+
__init113() {this.startedFibers = 0}
|
|
3496
3584
|
fork(effect, scopeId) {
|
|
3497
3585
|
this.startedFibers += 1;
|
|
3498
3586
|
const fiber = new RuntimeFiber(this.runtime, effect);
|
|
@@ -3512,214 +3600,7 @@ var JsFiberEngine = (_class16 = class {
|
|
|
3512
3600
|
pendingHostEffects: 0
|
|
3513
3601
|
};
|
|
3514
3602
|
}
|
|
3515
|
-
}, _class16);
|
|
3516
|
-
|
|
3517
|
-
// src/core/runtime/scope.ts
|
|
3518
|
-
var nextScopeId = 1;
|
|
3519
|
-
function awaitAll(fibers) {
|
|
3520
|
-
return asyncEffect((_env, cb) => {
|
|
3521
|
-
let remaining = fibers.length;
|
|
3522
|
-
if (remaining === 0) {
|
|
3523
|
-
cb({ _tag: "Success", value: void 0 });
|
|
3524
|
-
return;
|
|
3525
|
-
}
|
|
3526
|
-
for (const f of fibers) {
|
|
3527
|
-
f.join(() => {
|
|
3528
|
-
remaining -= 1;
|
|
3529
|
-
if (remaining === 0) cb({ _tag: "Success", value: void 0 });
|
|
3530
|
-
});
|
|
3531
|
-
}
|
|
3532
|
-
});
|
|
3533
|
-
}
|
|
3534
|
-
var Scope = (_class17 = class _Scope {
|
|
3535
|
-
constructor(runtime, parentScopeId) {;_class17.prototype.__init104.call(this);_class17.prototype.__init105.call(this);_class17.prototype.__init106.call(this);_class17.prototype.__init107.call(this);
|
|
3536
|
-
this.runtime = runtime;
|
|
3537
|
-
this.parentScopeId = parentScopeId;
|
|
3538
|
-
this.id = nextScopeId++;
|
|
3539
|
-
const inferredParent = _nullishCoalesce(this.parentScopeId, () => ( _optionalChain([getCurrentFiber, 'call', _189 => _189(), 'optionalAccess', _190 => _190.scopeId])));
|
|
3540
|
-
if (this.runtime.hasActiveHooks()) {
|
|
3541
|
-
this.runtime.emit({
|
|
3542
|
-
type: "scope.open",
|
|
3543
|
-
scopeId: this.id,
|
|
3544
|
-
parentScopeId: inferredParent
|
|
3545
|
-
});
|
|
3546
|
-
}
|
|
3547
|
-
}
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
__init104() {this.closed = false}
|
|
3552
|
-
__init105() {this.children = /* @__PURE__ */ new Set()}
|
|
3553
|
-
__init106() {this.subScopes = /* @__PURE__ */ new Set()}
|
|
3554
|
-
__init107() {this.finalizers = []}
|
|
3555
|
-
/** registra un finalizer (LIFO) */
|
|
3556
|
-
addFinalizer(f) {
|
|
3557
|
-
if (this.closed) {
|
|
3558
|
-
throw new Error("Trying to add finalizer to closed scope");
|
|
3559
|
-
}
|
|
3560
|
-
this.finalizers.push(f);
|
|
3561
|
-
}
|
|
3562
|
-
/** crea un sub scope (mismo runtime) */
|
|
3563
|
-
subScope() {
|
|
3564
|
-
if (this.closed) throw new Error("Scope closed");
|
|
3565
|
-
const s = new _Scope(this.runtime, this.id);
|
|
3566
|
-
this.subScopes.add(s);
|
|
3567
|
-
return s;
|
|
3568
|
-
}
|
|
3569
|
-
/** ✅ fork en este scope */
|
|
3570
|
-
fork(eff) {
|
|
3571
|
-
if (this.closed) throw new Error("Scope closed");
|
|
3572
|
-
const f = this.runtime.fork(eff, this.id);
|
|
3573
|
-
this.children.add(f);
|
|
3574
|
-
f.join(() => this.children.delete(f));
|
|
3575
|
-
return f;
|
|
3576
|
-
}
|
|
3577
|
-
/** close fire-and-forget (no bloquea) */
|
|
3578
|
-
close(exit = { _tag: "Success", value: void 0 }) {
|
|
3579
|
-
this.runtime.fork(this.closeAsync(exit));
|
|
3580
|
-
}
|
|
3581
|
-
/** Emit the scope.close event if hooks are active. */
|
|
3582
|
-
emitCloseEvent(exit) {
|
|
3583
|
-
if (this.runtime.hasActiveHooks()) {
|
|
3584
|
-
const status = exit._tag === "Success" ? "success" : exit.cause._tag === "Interrupt" ? "interrupted" : "failure";
|
|
3585
|
-
this.runtime.emit({
|
|
3586
|
-
type: "scope.close",
|
|
3587
|
-
scopeId: this.id,
|
|
3588
|
-
status,
|
|
3589
|
-
error: exit._tag === "Failure" && exit.cause._tag === "Fail" ? exit.cause.error : void 0
|
|
3590
|
-
});
|
|
3591
|
-
}
|
|
3592
|
-
}
|
|
3593
|
-
/**
|
|
3594
|
-
* Build an effect that executes finalizers in LIFO order.
|
|
3595
|
-
*
|
|
3596
|
-
* Optimization over the original: instead of wrapping every finalizer in
|
|
3597
|
-
* `asyncFold(fin(exit), () => unit(), () => unit())` which creates 3 effect
|
|
3598
|
-
* nodes per finalizer (Fold + 2 Succeed), we use a single Sync thunk per
|
|
3599
|
-
* finalizer that catches errors inline. When the finalizer returns a
|
|
3600
|
-
* Succeed effect (like `unit()`), the Sync thunk completes without creating
|
|
3601
|
-
* additional effect nodes.
|
|
3602
|
-
*/
|
|
3603
|
-
buildFinalizerEffect(exit) {
|
|
3604
|
-
const fins = this.finalizers;
|
|
3605
|
-
if (fins.length === 0) return unit();
|
|
3606
|
-
let chain = unit();
|
|
3607
|
-
for (let i = fins.length - 1; i >= 0; i--) {
|
|
3608
|
-
const fin = fins[i];
|
|
3609
|
-
chain = asyncFlatMap(chain, () => {
|
|
3610
|
-
let result;
|
|
3611
|
-
try {
|
|
3612
|
-
result = fin(exit);
|
|
3613
|
-
} catch (e14) {
|
|
3614
|
-
return unit();
|
|
3615
|
-
}
|
|
3616
|
-
if (result._tag === "Succeed") {
|
|
3617
|
-
return unit();
|
|
3618
|
-
}
|
|
3619
|
-
return asyncFold(
|
|
3620
|
-
result,
|
|
3621
|
-
() => unit(),
|
|
3622
|
-
() => unit()
|
|
3623
|
-
);
|
|
3624
|
-
});
|
|
3625
|
-
}
|
|
3626
|
-
return chain;
|
|
3627
|
-
}
|
|
3628
|
-
closeAsync(exit = { _tag: "Success", value: void 0 }, opts = { awaitChildren: true }) {
|
|
3629
|
-
return asyncFlatMap(
|
|
3630
|
-
unit(),
|
|
3631
|
-
() => asyncEffect((env, cb) => {
|
|
3632
|
-
if (this.closed) {
|
|
3633
|
-
cb({ _tag: "Success", value: void 0 });
|
|
3634
|
-
return;
|
|
3635
|
-
}
|
|
3636
|
-
this.closed = true;
|
|
3637
|
-
const children = Array.from(this.children);
|
|
3638
|
-
const subScopes = Array.from(this.subScopes);
|
|
3639
|
-
for (const child of children) {
|
|
3640
|
-
child.interrupt();
|
|
3641
|
-
}
|
|
3642
|
-
const closeSubs = subScopes.reduceRight(
|
|
3643
|
-
(acc, s) => asyncFlatMap(acc, () => s.closeAsync(exit, opts)),
|
|
3644
|
-
unit()
|
|
3645
|
-
);
|
|
3646
|
-
const runFinalizers = this.buildFinalizerEffect(exit);
|
|
3647
|
-
const needsAwait = opts.awaitChildren && children.length > 0;
|
|
3648
|
-
const awaitChildrenEff = needsAwait ? awaitAll(children) : unit();
|
|
3649
|
-
const hasSubScopes = subScopes.length > 0;
|
|
3650
|
-
const hasNoFinalizers = this.finalizers.length === 0;
|
|
3651
|
-
if (!hasSubScopes && !needsAwait && hasNoFinalizers) {
|
|
3652
|
-
this.emitCloseEvent(exit);
|
|
3653
|
-
cb({ _tag: "Success", value: void 0 });
|
|
3654
|
-
return;
|
|
3655
|
-
}
|
|
3656
|
-
const all = asyncFlatMap(closeSubs, () => asyncFlatMap(awaitChildrenEff, () => runFinalizers));
|
|
3657
|
-
this.runtime.fork(all).join(() => {
|
|
3658
|
-
this.emitCloseEvent(exit);
|
|
3659
|
-
cb({ _tag: "Success", value: void 0 });
|
|
3660
|
-
});
|
|
3661
|
-
})
|
|
3662
|
-
);
|
|
3663
|
-
}
|
|
3664
3603
|
}, _class17);
|
|
3665
|
-
function withScopeAsync(runtime, f) {
|
|
3666
|
-
return asyncEffect((_env, cb) => {
|
|
3667
|
-
const scope = new Scope(runtime);
|
|
3668
|
-
let done = false;
|
|
3669
|
-
const completeAfterClose = (exit) => {
|
|
3670
|
-
runtime.fork(scope.closeAsync(exit)).join(() => {
|
|
3671
|
-
if (done) return;
|
|
3672
|
-
done = true;
|
|
3673
|
-
cb(exit);
|
|
3674
|
-
});
|
|
3675
|
-
};
|
|
3676
|
-
const fiber = runtime.fork(f(scope));
|
|
3677
|
-
fiber.join(completeAfterClose);
|
|
3678
|
-
return () => {
|
|
3679
|
-
if (done) return;
|
|
3680
|
-
fiber.interrupt();
|
|
3681
|
-
runtime.fork(scope.closeAsync(Exit.failCause(Cause.interrupt())));
|
|
3682
|
-
};
|
|
3683
|
-
});
|
|
3684
|
-
}
|
|
3685
|
-
function withScope(runtime, f) {
|
|
3686
|
-
return withScopeAsync(runtime, (scope) => {
|
|
3687
|
-
const out = f(scope);
|
|
3688
|
-
if (out && typeof out === "object" && "_tag" in out) return out;
|
|
3689
|
-
return unit();
|
|
3690
|
-
});
|
|
3691
|
-
}
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
3604
|
|
|
3724
3605
|
|
|
3725
3606
|
|
|
@@ -3770,4 +3651,4 @@ function withScope(runtime, f) {
|
|
|
3770
3651
|
|
|
3771
3652
|
|
|
3772
3653
|
|
|
3773
|
-
exports.
|
|
3654
|
+
exports.PushStatus = PushStatus; exports.RingBuffer = RingBuffer; exports.resolveWasmModule = resolveWasmModule; exports.makeBoundedRingBuffer = makeBoundedRingBuffer; exports.sanitizeLaneKey = sanitizeLaneKey; exports.laneTag = laneTag; exports.inferCallerLaneFromStack = inferCallerLaneFromStack; exports.Scheduler = Scheduler; exports.globalScheduler = globalScheduler; exports.emptyContext = emptyContext; exports.ctxExtend = ctxExtend; exports.ctxToObject = ctxToObject; exports.DefaultHostExecutor = DefaultHostExecutor; exports.JsFiberEngine = JsFiberEngine; exports.HostRegistry = HostRegistry; exports.ProgramBuilder = ProgramBuilder; exports.EngineFiberHandle = EngineFiberHandle; exports.ABI_VERSION = ABI_VERSION; exports.EVENT_WORDS = EVENT_WORDS; exports.NONE_U32 = NONE_U32; exports.OpcodeTagCode = OpcodeTagCode; exports.EventKindCode = EventKindCode; exports.encodeOpcodeProgram = encodeOpcodeProgram; exports.encodeOpcodeNodes = encodeOpcodeNodes; exports.decodeEvent = decodeEvent; exports.decodeEventBatch = decodeEventBatch; exports.WasmPackFiberBridge = WasmPackFiberBridge; exports.WasmFiberRegistryBridge = WasmFiberRegistryBridge; exports.makeFiberReadyQueue = makeFiberReadyQueue; exports.WasmFiberEngine = WasmFiberEngine; exports.runtimeCapabilities = runtimeCapabilities; exports.NoopHooks = NoopHooks; exports.Runtime = Runtime; exports.fork = fork; exports.runtimeForCaller = runtimeForCaller; exports.toPromiseByCaller = toPromiseByCaller; exports.unsafeRunAsync = unsafeRunAsync; exports.toPromise = toPromise; exports.abortablePromiseStats = abortablePromiseStats; exports.resetAbortablePromiseStats = resetAbortablePromiseStats; exports.fromPromiseAbortable = fromPromiseAbortable; exports.unsafeRunFoldWithEnv = unsafeRunFoldWithEnv; exports.setBenchmarkBudget = setBenchmarkBudget; exports.getBenchmarkBudget = getBenchmarkBudget; exports.RuntimeFiber = RuntimeFiber; exports.getCurrentFiber = getCurrentFiber; exports.unsafeGetCurrentRuntime = unsafeGetCurrentRuntime; exports.withCurrentFiber = withCurrentFiber;
|