brass-runtime 1.13.4 → 1.13.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
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;// src/core/types/asyncEffect.ts
1
+ // src/core/types/asyncEffect.ts
2
2
  var Async = {
3
3
  succeed: (value) => ({ _tag: "Succeed", value }),
4
4
  fail: (error) => ({ _tag: "Fail", error }),
@@ -124,14 +124,14 @@ var PushStatus = /* @__PURE__ */ ((PushStatus3) => {
124
124
  PushStatus3[PushStatus3["Dropped"] = 2] = "Dropped";
125
125
  return PushStatus3;
126
126
  })(PushStatus || {});
127
- var RingBuffer = (_class = class {
128
-
129
- __init() {this.head = 0}
130
- __init2() {this.tail = 0}
131
- __init3() {this.size_ = 0}
127
+ var RingBuffer = class {
128
+ buf;
129
+ head = 0;
130
+ tail = 0;
131
+ size_ = 0;
132
132
  // nuevo
133
-
134
- constructor(initialCapacity = 1024, maxCapacity = initialCapacity) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);
133
+ maxCap;
134
+ constructor(initialCapacity = 1024, maxCapacity = initialCapacity) {
135
135
  let initPow = Math.max(2, initialCapacity);
136
136
  initPow--;
137
137
  initPow |= initPow >>> 1;
@@ -200,10 +200,10 @@ var RingBuffer = (_class = class {
200
200
  this.head = 0;
201
201
  this.tail = this.size_;
202
202
  }
203
- }, _class);
203
+ };
204
204
 
205
205
  // src/core/runtime/wasmModule.ts
206
- var _module = require('module');
206
+ import { createRequire } from "module";
207
207
  var cachedWasmModule;
208
208
  var cachedWasmModuleErrors = [];
209
209
  function resolveWasmModule(options = {}) {
@@ -252,33 +252,33 @@ function remember(options, value, errors) {
252
252
  return value;
253
253
  }
254
254
  function getBestRequire() {
255
- return _nullishCoalesce(_nullishCoalesce(getNonWebpackRequire(), () => ( getRuntimeRequire())), () => ( getCreateRequire()));
255
+ return getNonWebpackRequire() ?? getRuntimeRequire() ?? getCreateRequire();
256
256
  }
257
257
  function getNonWebpackRequire() {
258
258
  try {
259
259
  return (0, eval)("typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : undefined");
260
- } catch (e2) {
260
+ } catch {
261
261
  return void 0;
262
262
  }
263
263
  }
264
264
  function getRuntimeRequire() {
265
265
  try {
266
266
  return (0, eval)("typeof require === 'function' ? require : undefined");
267
- } catch (e3) {
267
+ } catch {
268
268
  return void 0;
269
269
  }
270
270
  }
271
271
  function getCreateRequire() {
272
272
  try {
273
- return _module.createRequire.call(void 0, import.meta.url);
274
- } catch (e4) {
273
+ return createRequire(import.meta.url);
274
+ } catch {
275
275
  return void 0;
276
276
  }
277
277
  }
278
278
  function getCwd() {
279
279
  try {
280
280
  return (0, eval)("typeof process !== 'undefined' ? process.cwd() : ''");
281
- } catch (e5) {
281
+ } catch {
282
282
  return "";
283
283
  }
284
284
  }
@@ -291,18 +291,18 @@ var cachedWasmCtor;
291
291
  function resolveWasmRingBuffer() {
292
292
  if (cachedWasmCtor !== void 0) return cachedWasmCtor;
293
293
  const mod = resolveWasmModule();
294
- cachedWasmCtor = _nullishCoalesce(_optionalChain([mod, 'optionalAccess', _ => _.BrassWasmRingBuffer]), () => ( null));
294
+ cachedWasmCtor = mod?.BrassWasmRingBuffer ?? null;
295
295
  return cachedWasmCtor;
296
296
  }
297
- var WasmRingBuffer = (_class2 = class {
298
- __init4() {this.engine = "wasm"}
299
- __init5() {this.fallbackUsed = false}
300
-
301
- __init6() {this.pushes = 0}
302
- __init7() {this.shifts = 0}
303
- __init8() {this.clears = 0}
304
- __init9() {this.dropped = 0}
305
- constructor(initialCapacity, maxCapacity) {;_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);
297
+ var WasmRingBuffer = class {
298
+ engine = "wasm";
299
+ fallbackUsed = false;
300
+ inner;
301
+ pushes = 0;
302
+ shifts = 0;
303
+ clears = 0;
304
+ dropped = 0;
305
+ constructor(initialCapacity, maxCapacity) {
306
306
  const Ctor = resolveWasmRingBuffer();
307
307
  if (!Ctor) {
308
308
  throw new Error("brass-runtime wasm ring buffer is not available. Run npm run build:wasm first.");
@@ -347,19 +347,19 @@ var WasmRingBuffer = (_class2 = class {
347
347
  }
348
348
  };
349
349
  }
350
- }, _class2);
351
- var JsBoundedRingBuffer = (_class3 = class {
352
- constructor(inner, fallbackUsed) {;_class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);_class3.prototype.__init14.call(this);
350
+ };
351
+ var JsBoundedRingBuffer = class {
352
+ constructor(inner, fallbackUsed) {
353
353
  this.inner = inner;
354
354
  this.fallbackUsed = fallbackUsed;
355
355
  }
356
-
357
-
358
- __init10() {this.engine = "js"}
359
- __init11() {this.pushes = 0}
360
- __init12() {this.shifts = 0}
361
- __init13() {this.clears = 0}
362
- __init14() {this.dropped = 0}
356
+ inner;
357
+ fallbackUsed;
358
+ engine = "js";
359
+ pushes = 0;
360
+ shifts = 0;
361
+ clears = 0;
362
+ dropped = 0;
363
363
  get length() {
364
364
  return this.inner.length;
365
365
  }
@@ -398,9 +398,9 @@ var JsBoundedRingBuffer = (_class3 = class {
398
398
  }
399
399
  };
400
400
  }
401
- }, _class3);
401
+ };
402
402
  function makeBoundedRingBuffer(initialCapacity, maxCapacity = initialCapacity, options = {}) {
403
- const engine = _nullishCoalesce(options.engine, () => ( "auto"));
403
+ const engine = options.engine ?? "auto";
404
404
  if (engine === "js") {
405
405
  return new JsBoundedRingBuffer(new RingBuffer(initialCapacity, maxCapacity), false);
406
406
  }
@@ -428,7 +428,7 @@ var scheduleMacro = (() => {
428
428
  ch.port1.onmessage = () => {
429
429
  const f = cb;
430
430
  cb = null;
431
- _optionalChain([f, 'optionalCall', _2 => _2()]);
431
+ f?.();
432
432
  };
433
433
  return (f) => {
434
434
  cb = f;
@@ -439,39 +439,39 @@ var scheduleMacro = (() => {
439
439
  })();
440
440
  function resolveWasmScheduler() {
441
441
  const mod = resolveWasmModule();
442
- return _nullishCoalesce(_optionalChain([mod, 'optionalAccess', _3 => _3.BrassWasmSchedulerStateMachine]), () => ( null));
442
+ return mod?.BrassWasmSchedulerStateMachine ?? null;
443
443
  }
444
- var JsSchedulerState = (_class4 = class {
445
-
446
-
447
- __init15() {this.flushing = false}
448
- __init16() {this.scheduled = false}
449
- __init17() {this.scheduledFlushes = 0}
450
- __init18() {this.completedFlushes = 0}
451
- __init19() {this.enqueuedTasks = 0}
452
- __init20() {this.executedTasks = 0}
453
- __init21() {this.droppedTasks = 0}
454
- __init22() {this.yieldedByBudget = 0}
455
- constructor(options) {;_class4.prototype.__init15.call(this);_class4.prototype.__init16.call(this);_class4.prototype.__init17.call(this);_class4.prototype.__init18.call(this);_class4.prototype.__init19.call(this);_class4.prototype.__init20.call(this);_class4.prototype.__init21.call(this);_class4.prototype.__init22.call(this);
456
- const initial = _nullishCoalesce(options.initialCapacity, () => ( 1024));
457
- const max = _nullishCoalesce(options.maxCapacity, () => ( initial));
444
+ var JsSchedulerState = class {
445
+ tasks;
446
+ tags;
447
+ flushing = false;
448
+ scheduled = false;
449
+ scheduledFlushes = 0;
450
+ completedFlushes = 0;
451
+ enqueuedTasks = 0;
452
+ executedTasks = 0;
453
+ droppedTasks = 0;
454
+ yieldedByBudget = 0;
455
+ constructor(options) {
456
+ const initial = options.initialCapacity ?? 1024;
457
+ const max = options.maxCapacity ?? initial;
458
458
  this.tasks = makeBoundedRingBuffer(initial, max, { engine: options.engine });
459
459
  this.tags = makeBoundedRingBuffer(initial, max, { engine: options.engine });
460
460
  }
461
- }, _class4);
462
- var WasmSchedulerState = (_class5 = class {
463
-
464
- __init23() {this.nextRef = 1}
465
- __init24() {this.tasks = /* @__PURE__ */ new Map()}
466
- __init25() {this.tags = /* @__PURE__ */ new Map()}
467
- constructor(options) {;_class5.prototype.__init23.call(this);_class5.prototype.__init24.call(this);_class5.prototype.__init25.call(this);
461
+ };
462
+ var WasmSchedulerState = class {
463
+ machine;
464
+ nextRef = 1;
465
+ tasks = /* @__PURE__ */ new Map();
466
+ tags = /* @__PURE__ */ new Map();
467
+ constructor(options) {
468
468
  const Ctor = resolveWasmScheduler();
469
469
  if (!Ctor) throw new Error("brass-runtime wasm scheduler is not available. Run npm run build:wasm first.");
470
470
  this.machine = new Ctor(
471
- _nullishCoalesce(options.initialCapacity, () => ( 1024)),
472
- _nullishCoalesce(options.maxCapacity, () => ( SCHEDULER_QUEUE_CAPACITY)),
473
- _nullishCoalesce(options.flushBudget, () => ( FLUSH_BUDGET)),
474
- _nullishCoalesce(options.microThreshold, () => ( MICRO_THRESHOLD))
471
+ options.initialCapacity ?? 1024,
472
+ options.maxCapacity ?? SCHEDULER_QUEUE_CAPACITY,
473
+ options.flushBudget ?? FLUSH_BUDGET,
474
+ options.microThreshold ?? MICRO_THRESHOLD
475
475
  );
476
476
  }
477
477
  enqueue(task, tag) {
@@ -492,7 +492,7 @@ var WasmSchedulerState = (_class5 = class {
492
492
  const ref = this.machine.shift();
493
493
  if (ref === 0) return void 0;
494
494
  const task = this.tasks.get(ref);
495
- const tag = _nullishCoalesce(this.tags.get(ref), () => ( "anonymous"));
495
+ const tag = this.tags.get(ref) ?? "anonymous";
496
496
  this.tasks.delete(ref);
497
497
  this.tags.delete(ref);
498
498
  return task ? { task, tag } : void 0;
@@ -506,20 +506,20 @@ var WasmSchedulerState = (_class5 = class {
506
506
  stats() {
507
507
  return { engine: "wasm", fallbackUsed: false, data: JSON.parse(this.machine.stats_json()) };
508
508
  }
509
- }, _class5);
510
- var Scheduler = (_class6 = class {
511
-
512
-
513
-
514
-
515
-
516
-
509
+ };
510
+ var Scheduler = class {
511
+ engine;
512
+ js;
513
+ wasm;
514
+ flushBudget;
515
+ microThreshold;
516
+ fallbackUsed;
517
517
  // Cached flush closure — avoids creating a new closure on every requestFlush
518
- __init26() {this.boundFlush = () => this.flush()}
519
- constructor(options = {}) {;_class6.prototype.__init26.call(this);
520
- this.flushBudget = _nullishCoalesce(options.flushBudget, () => ( FLUSH_BUDGET));
521
- this.microThreshold = _nullishCoalesce(options.microThreshold, () => ( MICRO_THRESHOLD));
522
- const requested = _nullishCoalesce(options.engine, () => ( "js"));
518
+ boundFlush = () => this.flush();
519
+ constructor(options = {}) {
520
+ this.flushBudget = options.flushBudget ?? FLUSH_BUDGET;
521
+ this.microThreshold = options.microThreshold ?? MICRO_THRESHOLD;
522
+ const requested = options.engine ?? "js";
523
523
  if (requested === "wasm") {
524
524
  this.wasm = new WasmSchedulerState(options);
525
525
  this.engine = "wasm";
@@ -640,7 +640,7 @@ var Scheduler = (_class6 = class {
640
640
  }
641
641
  }
642
642
  }
643
- }, _class6);
643
+ };
644
644
  var globalScheduler = new Scheduler();
645
645
 
646
646
  // src/core/runtime/contex.ts
@@ -651,25 +651,25 @@ function makeForkPolicy(env, hooks) {
651
651
  const svc = resolveForkServices(env);
652
652
  return {
653
653
  initChild(fiber, parent, scopeId) {
654
- const parentCtx = _optionalChain([parent, 'optionalAccess', _4 => _4.fiberContext]);
655
- const trace = forkTrace(svc, _nullishCoalesce(_optionalChain([parentCtx, 'optionalAccess', _5 => _5.trace]), () => ( null)));
654
+ const parentCtx = parent?.fiberContext;
655
+ const trace = forkTrace(svc, parentCtx?.trace ?? null);
656
656
  fiber.fiberContext = {
657
- log: _nullishCoalesce(_optionalChain([parentCtx, 'optionalAccess', _6 => _6.log]), () => ( emptyContext)),
657
+ log: parentCtx?.log ?? emptyContext,
658
658
  trace
659
659
  };
660
- fiber.parentFiberId = _optionalChain([parent, 'optionalAccess', _7 => _7.id]);
661
- fiber.name = svc.childName(_optionalChain([parent, 'optionalAccess', _8 => _8.name]));
660
+ fiber.parentFiberId = parent?.id;
661
+ fiber.name = svc.childName(parent?.name);
662
662
  if (scopeId !== void 0) fiber.scopeId = scopeId;
663
663
  hooks.emit(
664
664
  {
665
665
  type: "fiber.start",
666
666
  fiberId: fiber.id,
667
- parentFiberId: _optionalChain([parent, 'optionalAccess', _9 => _9.id]),
667
+ parentFiberId: parent?.id,
668
668
  scopeId: fiber.scopeId,
669
669
  // ✅ ahora viaja
670
670
  name: fiber.name
671
671
  },
672
- { fiberId: _optionalChain([parent, 'optionalAccess', _10 => _10.id]), traceId: _optionalChain([parentCtx, 'optionalAccess', _11 => _11.trace, 'optionalAccess', _12 => _12.traceId]), spanId: _optionalChain([parentCtx, 'optionalAccess', _13 => _13.trace, 'optionalAccess', _14 => _14.spanId]) }
672
+ { fiberId: parent?.id, traceId: parentCtx?.trace?.traceId, spanId: parentCtx?.trace?.spanId }
673
673
  );
674
674
  }
675
675
  };
@@ -679,15 +679,15 @@ function resolveForkServices(env) {
679
679
  newTraceId: () => randomRuntimeId("trace"),
680
680
  newSpanId: () => randomRuntimeId("span")
681
681
  };
682
- const brass = _optionalChain([env, 'optionalAccess', _15 => _15.brass]);
683
- const tracer = _nullishCoalesce(_optionalChain([brass, 'optionalAccess', _16 => _16.tracer]), () => ( defaultTracer));
684
- const seed = _optionalChain([brass, 'optionalAccess', _17 => _17.traceSeed]);
685
- const childName = _nullishCoalesce(_optionalChain([brass, 'optionalAccess', _18 => _18.childName]), () => ( ((p) => p ? `${p}/child` : void 0)));
682
+ const brass = env?.brass;
683
+ const tracer = brass?.tracer ?? defaultTracer;
684
+ const seed = brass?.traceSeed;
685
+ const childName = brass?.childName ?? ((p) => p ? `${p}/child` : void 0);
686
686
  return { tracer, seed, childName };
687
687
  }
688
688
  function randomRuntimeId(prefix) {
689
689
  const cryptoLike = globalThis.crypto;
690
- if (typeof _optionalChain([cryptoLike, 'optionalAccess', _19 => _19.randomUUID]) === "function") {
690
+ if (typeof cryptoLike?.randomUUID === "function") {
691
691
  return cryptoLike.randomUUID();
692
692
  }
693
693
  return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
@@ -717,13 +717,13 @@ var DefaultHostExecutor = {
717
717
  };
718
718
 
719
719
  // src/core/runtime/engine/JsFiberEngine.ts
720
- var JsFiberEngine = (_class7 = class {
721
- constructor(runtime) {;_class7.prototype.__init27.call(this);_class7.prototype.__init28.call(this);
720
+ var JsFiberEngine = class {
721
+ constructor(runtime) {
722
722
  this.runtime = runtime;
723
723
  }
724
-
725
- __init27() {this.kind = "js"}
726
- __init28() {this.startedFibers = 0}
724
+ runtime;
725
+ kind = "js";
726
+ startedFibers = 0;
727
727
  fork(effect, scopeId) {
728
728
  this.startedFibers += 1;
729
729
  const fiber = new RuntimeFiber(this.runtime, effect);
@@ -743,12 +743,12 @@ var JsFiberEngine = (_class7 = class {
743
743
  pendingHostEffects: 0
744
744
  };
745
745
  }
746
- }, _class7);
746
+ };
747
747
 
748
748
  // src/core/runtime/engine/opcodes.ts
749
- var HostRegistry = (_class8 = class {constructor() { _class8.prototype.__init29.call(this);_class8.prototype.__init30.call(this); }
750
- __init29() {this.nextRef = 1}
751
- __init30() {this.refs = /* @__PURE__ */ new Map()}
749
+ var HostRegistry = class {
750
+ nextRef = 1;
751
+ refs = /* @__PURE__ */ new Map();
752
752
  register(value) {
753
753
  const ref = this.nextRef++;
754
754
  this.refs.set(ref, value);
@@ -772,10 +772,10 @@ var HostRegistry = (_class8 = class {constructor() { _class8.prototype.__init29.
772
772
  size() {
773
773
  return this.refs.size;
774
774
  }
775
- }, _class8);
776
- var ProgramBuilder = (_class9 = class {constructor() { _class9.prototype.__init31.call(this);_class9.prototype.__init32.call(this); }
777
- __init31() {this.nodes = []}
778
- __init32() {this.registry = new HostRegistry()}
775
+ };
776
+ var ProgramBuilder = class {
777
+ nodes = [];
778
+ registry = new HostRegistry();
779
779
  compile(effect) {
780
780
  const root = this.visit(effect);
781
781
  return {
@@ -839,14 +839,14 @@ var ProgramBuilder = (_class9 = class {constructor() { _class9.prototype.__init3
839
839
  return this.add(current.decode === void 0 ? base : { ...base, decodeRef: this.registry.register(current.decode) });
840
840
  }
841
841
  default:
842
- return this.add({ tag: "Fail", errorRef: this.registry.register(new Error(`Unknown Async opcode: ${_optionalChain([current, 'optionalAccess', _20 => _20._tag])}`)) });
842
+ return this.add({ tag: "Fail", errorRef: this.registry.register(new Error(`Unknown Async opcode: ${current?._tag}`)) });
843
843
  }
844
844
  }
845
- }, _class9);
845
+ };
846
846
 
847
847
  // src/core/runtime/engine/FiberHandleImpl.ts
848
- var EngineFiberHandle = (_class10 = class {
849
- constructor(id, runtime, onScheduledStep, onInterrupt, onJoiner, onQueued) {;_class10.prototype.__init33.call(this);_class10.prototype.__init34.call(this);_class10.prototype.__init35.call(this);_class10.prototype.__init36.call(this);_class10.prototype.__init37.call(this);_class10.prototype.__init38.call(this);
848
+ var EngineFiberHandle = class {
849
+ constructor(id, runtime, onScheduledStep, onInterrupt, onJoiner, onQueued) {
850
850
  this.onScheduledStep = onScheduledStep;
851
851
  this.onInterrupt = onInterrupt;
852
852
  this.onJoiner = onJoiner;
@@ -854,22 +854,22 @@ var EngineFiberHandle = (_class10 = class {
854
854
  this.id = id;
855
855
  this.runtime = runtime;
856
856
  }
857
-
858
-
859
-
860
-
861
-
862
-
863
-
864
-
865
-
866
-
867
- __init33() {this.result = null}
868
- __init34() {this.joiners = []}
869
- __init35() {this.finalizers = []}
870
- __init36() {this.finalizersDrained = false}
871
- __init37() {this.internalStatus = "running"}
872
- __init38() {this.queued = false}
857
+ onScheduledStep;
858
+ onInterrupt;
859
+ onJoiner;
860
+ onQueued;
861
+ id;
862
+ runtime;
863
+ fiberContext;
864
+ name;
865
+ scopeId;
866
+ parentFiberId;
867
+ result = null;
868
+ joiners = [];
869
+ finalizers = [];
870
+ finalizersDrained = false;
871
+ internalStatus = "running";
872
+ queued = false;
873
873
  status() {
874
874
  if (this.result == null) return "Running";
875
875
  if (this.result._tag === "Failure" && this.result.cause._tag === "Interrupt") return "Interrupted";
@@ -884,7 +884,7 @@ var EngineFiberHandle = (_class10 = class {
884
884
  join(cb) {
885
885
  if (this.result != null) cb(this.result);
886
886
  else {
887
- _optionalChain([this, 'access', _21 => _21.onJoiner, 'optionalCall', _22 => _22(this.id)]);
887
+ this.onJoiner?.(this.id);
888
888
  this.joiners.push(cb);
889
889
  }
890
890
  }
@@ -899,7 +899,7 @@ var EngineFiberHandle = (_class10 = class {
899
899
  if (this.result != null || this.queued) return;
900
900
  this.queued = true;
901
901
  this.internalStatus = "queued";
902
- _optionalChain([this, 'access', _23 => _23.onQueued, 'optionalCall', _24 => _24(this.id)]);
902
+ this.onQueued?.(this.id);
903
903
  this.runtime.scheduler.schedule(() => {
904
904
  this.queued = false;
905
905
  if (this.result != null) return;
@@ -910,8 +910,8 @@ var EngineFiberHandle = (_class10 = class {
910
910
  this.runtime.hooks.emit(ev, {
911
911
  fiberId: this.id,
912
912
  scopeId: this.scopeId,
913
- traceId: _optionalChain([this, 'access', _25 => _25.fiberContext, 'optionalAccess', _26 => _26.trace, 'optionalAccess', _27 => _27.traceId]),
914
- spanId: _optionalChain([this, 'access', _28 => _28.fiberContext, 'optionalAccess', _29 => _29.trace, 'optionalAccess', _30 => _30.spanId])
913
+ traceId: this.fiberContext?.trace?.traceId,
914
+ spanId: this.fiberContext?.trace?.spanId
915
915
  });
916
916
  }
917
917
  succeed(value) {
@@ -951,21 +951,21 @@ var EngineFiberHandle = (_class10 = class {
951
951
  if (eff && typeof eff === "object" && "_tag" in eff) {
952
952
  this.runtime.fork(eff);
953
953
  }
954
- } catch (e6) {
954
+ } catch {
955
955
  }
956
956
  }
957
957
  }
958
- }, _class10);
958
+ };
959
959
 
960
960
  // src/core/runtime/engine/bridge/ReferenceWasmBridge.ts
961
- var ReferenceWasmBridge = (_class11 = class {constructor() { _class11.prototype.__init39.call(this);_class11.prototype.__init40.call(this);_class11.prototype.__init41.call(this);_class11.prototype.__init42.call(this);_class11.prototype.__init43.call(this);_class11.prototype.__init44.call(this);_class11.prototype.__init45.call(this); }
962
- __init39() {this.kind = "wasm-reference"}
963
- __init40() {this.nextFiberId = 1}
964
- __init41() {this.fibers = /* @__PURE__ */ new Map()}
965
- __init42() {this.started = 0}
966
- __init43() {this.completed = 0}
967
- __init44() {this.failed = 0}
968
- __init45() {this.interrupted = 0}
961
+ var ReferenceWasmBridge = class {
962
+ kind = "wasm-reference";
963
+ nextFiberId = 1;
964
+ fibers = /* @__PURE__ */ new Map();
965
+ started = 0;
966
+ completed = 0;
967
+ failed = 0;
968
+ interrupted = 0;
969
969
  createFiber(program) {
970
970
  const id = this.nextFiberId++;
971
971
  this.started += 1;
@@ -1042,7 +1042,7 @@ var ReferenceWasmBridge = (_class11 = class {constructor() { _class11.prototype.
1042
1042
  step(fiber) {
1043
1043
  while (true) {
1044
1044
  if (fiber.status === "interrupted") {
1045
- const event = _nullishCoalesce(fiber.lastEvent, () => ( { kind: "Interrupted", fiberId: fiber.id, reasonRef: 0 }));
1045
+ const event = fiber.lastEvent ?? { kind: "Interrupted", fiberId: fiber.id, reasonRef: 0 };
1046
1046
  fiber.lastEvent = event;
1047
1047
  return event;
1048
1048
  }
@@ -1117,7 +1117,7 @@ var ReferenceWasmBridge = (_class11 = class {constructor() { _class11.prototype.
1117
1117
  fiber.lastEvent = event;
1118
1118
  return event;
1119
1119
  }
1120
- }, _class11);
1120
+ };
1121
1121
  function cloneProgram(program) {
1122
1122
  return {
1123
1123
  version: program.version,
@@ -1127,10 +1127,10 @@ function cloneProgram(program) {
1127
1127
  }
1128
1128
 
1129
1129
  // src/core/runtime/engine/bridge/WasmPackFiberBridge.ts
1130
- var WasmPackFiberBridge = (_class12 = class {
1131
- __init46() {this.kind = "wasm"}
1132
-
1133
- constructor(modulePath) {;_class12.prototype.__init46.call(this);
1130
+ var WasmPackFiberBridge = class {
1131
+ kind = "wasm";
1132
+ vm;
1133
+ constructor(modulePath) {
1134
1134
  const mod = loadWasmModule(modulePath);
1135
1135
  this.vm = new mod.BrassWasmVm();
1136
1136
  }
@@ -1158,7 +1158,7 @@ var WasmPackFiberBridge = (_class12 = class {
1158
1158
  stats() {
1159
1159
  return JSON.parse(this.vm.stats_json());
1160
1160
  }
1161
- }, _class12);
1161
+ };
1162
1162
  function loadWasmModule(modulePath) {
1163
1163
  const mod = resolveWasmModule({ modulePath });
1164
1164
  if (mod) return mod;
@@ -1179,17 +1179,17 @@ var FIBER_STATE_DONE = 3;
1179
1179
  var FIBER_STATE_FAILED = 4;
1180
1180
  var FIBER_STATE_INTERRUPTED = 5;
1181
1181
  var WasmFiberRegistryBridge = class {
1182
-
1182
+ registry;
1183
1183
  constructor() {
1184
1184
  const mod = resolveWasmModule();
1185
- const Ctor = _optionalChain([mod, 'optionalAccess', _31 => _31.BrassWasmFiberRegistry]);
1185
+ const Ctor = mod?.BrassWasmFiberRegistry;
1186
1186
  if (!Ctor) {
1187
1187
  throw new Error("brass-runtime wasm fiber registry is not available. Run npm run build:wasm first.");
1188
1188
  }
1189
1189
  this.registry = new Ctor();
1190
1190
  }
1191
1191
  registerFiber(fiberId, parentId, scopeId) {
1192
- this.registry.register_fiber(fiberId, _nullishCoalesce(parentId, () => ( 0)), _nullishCoalesce(scopeId, () => ( 0)), Date.now());
1192
+ this.registry.register_fiber(fiberId, parentId ?? 0, scopeId ?? 0, Date.now());
1193
1193
  }
1194
1194
  markQueued(fiberId) {
1195
1195
  this.registry.mark_queued(fiberId, Date.now());
@@ -1273,25 +1273,25 @@ function codeToStatus(code) {
1273
1273
 
1274
1274
  // src/core/runtime/engine/WasmFiberEngine.ts
1275
1275
  var DEFAULT_BUDGET = 4096;
1276
- var WasmFiberEngine = (_class13 = class {
1277
- constructor(runtime, options = {}) {;_class13.prototype.__init47.call(this);_class13.prototype.__init48.call(this);_class13.prototype.__init49.call(this);_class13.prototype.__init50.call(this);_class13.prototype.__init51.call(this);_class13.prototype.__init52.call(this);_class13.prototype.__init53.call(this);_class13.prototype.__init54.call(this);
1276
+ var WasmFiberEngine = class {
1277
+ constructor(runtime, options = {}) {
1278
1278
  this.runtime = runtime;
1279
- this.bridge = _nullishCoalesce(options.bridge, () => ( (options.reference ? new ReferenceWasmBridge() : new WasmPackFiberBridge(options.modulePath))));
1279
+ this.bridge = options.bridge ?? (options.reference ? new ReferenceWasmBridge() : new WasmPackFiberBridge(options.modulePath));
1280
1280
  this.kind = this.bridge.kind;
1281
1281
  this.fiberRegistry = this.kind === "wasm" ? new WasmFiberRegistryBridge() : void 0;
1282
1282
  }
1283
-
1284
-
1285
-
1286
- __init47() {this.startedFibers = 0}
1287
- __init48() {this.runningFibers = 0}
1288
- __init49() {this.suspendedFibers = 0}
1289
- __init50() {this.completedFibers = 0}
1290
- __init51() {this.failedFibers = 0}
1291
- __init52() {this.interruptedFibers = 0}
1292
- __init53() {this.pendingHostEffects = 0}
1293
- __init54() {this.states = /* @__PURE__ */ new Map()}
1294
-
1283
+ runtime;
1284
+ kind;
1285
+ bridge;
1286
+ startedFibers = 0;
1287
+ runningFibers = 0;
1288
+ suspendedFibers = 0;
1289
+ completedFibers = 0;
1290
+ failedFibers = 0;
1291
+ interruptedFibers = 0;
1292
+ pendingHostEffects = 0;
1293
+ states = /* @__PURE__ */ new Map();
1294
+ fiberRegistry;
1295
1295
  fork(effect, scopeId) {
1296
1296
  const builder = new ProgramBuilder();
1297
1297
  const compiled = builder.compile(effect);
@@ -1302,8 +1302,8 @@ var WasmFiberEngine = (_class13 = class {
1302
1302
  this.runtime,
1303
1303
  (id) => this.scheduleWakeup(id),
1304
1304
  (id, reason) => this.interruptById(id, reason),
1305
- (id) => _optionalChain([this, 'access', _32 => _32.fiberRegistry, 'optionalAccess', _33 => _33.addJoiner, 'call', _34 => _34(id)]),
1306
- (id) => _optionalChain([this, 'access', _35 => _35.fiberRegistry, 'optionalAccess', _36 => _36.markQueued, 'call', _37 => _37(id)])
1305
+ (id) => this.fiberRegistry?.addJoiner(id),
1306
+ (id) => this.fiberRegistry?.markQueued(id)
1307
1307
  );
1308
1308
  if (scopeId !== void 0) handle.scopeId = scopeId;
1309
1309
  const state = {
@@ -1318,7 +1318,7 @@ var WasmFiberEngine = (_class13 = class {
1318
1318
  pendingCleanups: /* @__PURE__ */ new Set()
1319
1319
  };
1320
1320
  this.states.set(fiberId, state);
1321
- _optionalChain([this, 'access', _38 => _38.fiberRegistry, 'optionalAccess', _39 => _39.registerFiber, 'call', _40 => _40(fiberId, void 0, scopeId)]);
1321
+ this.fiberRegistry?.registerFiber(fiberId, void 0, scopeId);
1322
1322
  this.startedFibers += 1;
1323
1323
  this.runningFibers += 1;
1324
1324
  return handle;
@@ -1338,7 +1338,7 @@ var WasmFiberEngine = (_class13 = class {
1338
1338
  pendingHostEffects: this.pendingHostEffects,
1339
1339
  hostRegistryRefs: hostRefs,
1340
1340
  wasm: this.bridge.stats(),
1341
- fiberRegistry: _optionalChain([this, 'access', _41 => _41.fiberRegistry, 'optionalAccess', _42 => _42.stats, 'call', _43 => _43()])
1341
+ fiberRegistry: this.fiberRegistry?.stats()
1342
1342
  };
1343
1343
  }
1344
1344
  async shutdown() {
@@ -1365,13 +1365,13 @@ var WasmFiberEngine = (_class13 = class {
1365
1365
  driveById(fiberId) {
1366
1366
  const state = this.states.get(fiberId);
1367
1367
  if (!state || state.completed) return;
1368
- _optionalChain([this, 'access', _44 => _44.fiberRegistry, 'optionalAccess', _45 => _45.markRunning, 'call', _46 => _46(fiberId)]);
1368
+ this.fiberRegistry?.markRunning(fiberId);
1369
1369
  withCurrentFiber(state.handle, () => this.drive(state));
1370
1370
  }
1371
1371
  drive(state, initialEvent) {
1372
1372
  if (state.completed) return;
1373
1373
  let budget = DEFAULT_BUDGET;
1374
- let event = _nullishCoalesce(initialEvent, () => ( this.bridge.poll(state.fiberId)));
1374
+ let event = initialEvent ?? this.bridge.poll(state.fiberId);
1375
1375
  state.status = "running";
1376
1376
  state.handle.setEngineStatus("running");
1377
1377
  while (!state.completed && budget-- > 0) {
@@ -1505,7 +1505,7 @@ var WasmFiberEngine = (_class13 = class {
1505
1505
  done = true;
1506
1506
  try {
1507
1507
  canceler();
1508
- } catch (e7) {
1508
+ } catch {
1509
1509
  }
1510
1510
  state.pendingCleanups.delete(cancelCleanup);
1511
1511
  };
@@ -1601,7 +1601,7 @@ var WasmFiberEngine = (_class13 = class {
1601
1601
  if (state.status !== "suspended") {
1602
1602
  this.suspendedFibers += 1;
1603
1603
  state.status = "suspended";
1604
- _optionalChain([this, 'access', _47 => _47.fiberRegistry, 'optionalAccess', _48 => _48.markSuspended, 'call', _49 => _49(state.fiberId)]);
1604
+ this.fiberRegistry?.markSuspended(state.fiberId);
1605
1605
  state.handle.setEngineStatus("suspended");
1606
1606
  state.handle.emit({ type: "fiber.suspend", fiberId: state.fiberId, reason });
1607
1607
  }
@@ -1610,7 +1610,7 @@ var WasmFiberEngine = (_class13 = class {
1610
1610
  if (state.status === "suspended") {
1611
1611
  this.suspendedFibers = Math.max(0, this.suspendedFibers - 1);
1612
1612
  state.status = "running";
1613
- _optionalChain([this, 'access', _50 => _50.fiberRegistry, 'optionalAccess', _51 => _51.markRunning, 'call', _52 => _52(state.fiberId)]);
1613
+ this.fiberRegistry?.markRunning(state.fiberId);
1614
1614
  state.handle.setEngineStatus("running");
1615
1615
  state.handle.emit({ type: "fiber.resume", fiberId: state.fiberId });
1616
1616
  }
@@ -1619,7 +1619,7 @@ var WasmFiberEngine = (_class13 = class {
1619
1619
  if (state.completed) return;
1620
1620
  state.completed = true;
1621
1621
  state.status = "done";
1622
- _optionalChain([this, 'access', _53 => _53.fiberRegistry, 'optionalAccess', _54 => _54.markDone, 'call', _55 => _55(state.fiberId, "done")]);
1622
+ this.fiberRegistry?.markDone(state.fiberId, "done");
1623
1623
  this.completedFibers += 1;
1624
1624
  this.cleanupState(state);
1625
1625
  state.handle.succeed(value);
@@ -1628,7 +1628,7 @@ var WasmFiberEngine = (_class13 = class {
1628
1628
  if (state.completed) return;
1629
1629
  state.completed = true;
1630
1630
  state.status = "failed";
1631
- _optionalChain([this, 'access', _56 => _56.fiberRegistry, 'optionalAccess', _57 => _57.markDone, 'call', _58 => _58(state.fiberId, "failed")]);
1631
+ this.fiberRegistry?.markDone(state.fiberId, "failed");
1632
1632
  this.failedFibers += 1;
1633
1633
  this.cleanupState(state);
1634
1634
  state.handle.fail(error);
@@ -1637,7 +1637,7 @@ var WasmFiberEngine = (_class13 = class {
1637
1637
  if (state.completed) return;
1638
1638
  state.completed = true;
1639
1639
  state.status = "failed";
1640
- _optionalChain([this, 'access', _59 => _59.fiberRegistry, 'optionalAccess', _60 => _60.markDone, 'call', _61 => _61(state.fiberId, "failed")]);
1640
+ this.fiberRegistry?.markDone(state.fiberId, "failed");
1641
1641
  this.failedFibers += 1;
1642
1642
  this.cleanupState(state);
1643
1643
  state.handle.die(defect);
@@ -1646,7 +1646,7 @@ var WasmFiberEngine = (_class13 = class {
1646
1646
  if (state.completed) return;
1647
1647
  state.completed = true;
1648
1648
  state.status = "interrupted";
1649
- _optionalChain([this, 'access', _62 => _62.fiberRegistry, 'optionalAccess', _63 => _63.markDone, 'call', _64 => _64(state.fiberId, "interrupted")]);
1649
+ this.fiberRegistry?.markDone(state.fiberId, "interrupted");
1650
1650
  this.interruptedFibers += 1;
1651
1651
  this.cleanupState(state);
1652
1652
  state.handle.interrupted();
@@ -1657,22 +1657,22 @@ var WasmFiberEngine = (_class13 = class {
1657
1657
  for (const cleanup of Array.from(state.pendingCleanups)) cleanup();
1658
1658
  state.pendingCleanups.clear();
1659
1659
  this.bridge.dropFiber(state.fiberId);
1660
- _optionalChain([this, 'access', _65 => _65.fiberRegistry, 'optionalAccess', _66 => _66.dropFiber, 'call', _67 => _67(state.fiberId)]);
1660
+ this.fiberRegistry?.dropFiber(state.fiberId);
1661
1661
  state.registry.clear();
1662
1662
  this.states.delete(state.fiberId);
1663
1663
  }
1664
- }, _class13);
1664
+ };
1665
1665
 
1666
1666
  // src/core/runtime/capabilities.ts
1667
1667
  function runtimeCapabilities() {
1668
1668
  const mod = resolveWasmModule();
1669
1669
  return {
1670
1670
  wasmAvailable: !!mod,
1671
- wasmFiberEngine: typeof _optionalChain([mod, 'optionalAccess', _68 => _68.BrassWasmVm]) === "function",
1672
- wasmRingBuffer: typeof _optionalChain([mod, 'optionalAccess', _69 => _69.BrassWasmRingBuffer]) === "function",
1673
- wasmScheduler: typeof _optionalChain([mod, 'optionalAccess', _70 => _70.BrassWasmSchedulerStateMachine]) === "function",
1674
- wasmFiberRegistry: typeof _optionalChain([mod, 'optionalAccess', _71 => _71.BrassWasmFiberRegistry]) === "function",
1675
- wasmStreamChunks: typeof _optionalChain([mod, 'optionalAccess', _72 => _72.BrassWasmChunkBuffer]) === "function"
1671
+ wasmFiberEngine: typeof mod?.BrassWasmVm === "function",
1672
+ wasmRingBuffer: typeof mod?.BrassWasmRingBuffer === "function",
1673
+ wasmScheduler: typeof mod?.BrassWasmSchedulerStateMachine === "function",
1674
+ wasmFiberRegistry: typeof mod?.BrassWasmFiberRegistry === "function",
1675
+ wasmStreamChunks: typeof mod?.BrassWasmChunkBuffer === "function"
1676
1676
  };
1677
1677
  }
1678
1678
 
@@ -1682,23 +1682,23 @@ var NoopHooks = {
1682
1682
  }
1683
1683
  };
1684
1684
  var Runtime = class _Runtime {
1685
-
1686
-
1687
-
1688
-
1689
-
1690
-
1691
-
1692
-
1693
-
1685
+ env;
1686
+ scheduler;
1687
+ hooks;
1688
+ hostExecutor;
1689
+ engineMode;
1690
+ wasmOptions;
1691
+ fiberEngine;
1692
+ fallbackUsed;
1693
+ forkPolicy;
1694
1694
  // opcional: registry para observabilidad
1695
-
1695
+ registry;
1696
1696
  constructor(args) {
1697
1697
  this.env = args.env;
1698
- this.scheduler = _nullishCoalesce(args.scheduler, () => ( globalScheduler));
1699
- this.hooks = _nullishCoalesce(args.hooks, () => ( NoopHooks));
1700
- this.hostExecutor = _nullishCoalesce(args.hostExecutor, () => ( DefaultHostExecutor));
1701
- this.engineMode = _nullishCoalesce(args.engine, () => ( "auto"));
1698
+ this.scheduler = args.scheduler ?? globalScheduler;
1699
+ this.hooks = args.hooks ?? NoopHooks;
1700
+ this.hostExecutor = args.hostExecutor ?? DefaultHostExecutor;
1701
+ this.engineMode = args.engine ?? "auto";
1702
1702
  this.wasmOptions = args.wasm;
1703
1703
  this.forkPolicy = makeForkPolicy(this.env, this.hooks);
1704
1704
  const selected = this.makeFiberEngine(this.engineMode, args.wasm);
@@ -1714,7 +1714,7 @@ var Runtime = class _Runtime {
1714
1714
  if (capabilities.wasmFiberEngine) {
1715
1715
  return { engine: new WasmFiberEngine(this, wasm), fallbackUsed: false };
1716
1716
  }
1717
- } catch (e8) {
1717
+ } catch {
1718
1718
  }
1719
1719
  return { engine: new JsFiberEngine(this), fallbackUsed: true };
1720
1720
  }
@@ -1737,11 +1737,11 @@ var Runtime = class _Runtime {
1737
1737
  if (this.hooks === NoopHooks) return;
1738
1738
  const f = getCurrentFiber();
1739
1739
  const ctx = {
1740
- fiberId: _optionalChain([f, 'optionalAccess', _73 => _73.id]),
1741
- scopeId: _optionalChain([f, 'optionalAccess', _74 => _74.scopeId]),
1740
+ fiberId: f?.id,
1741
+ scopeId: f?.scopeId,
1742
1742
  // ✅ FIX: era f?.scope
1743
- traceId: _optionalChain([f, 'optionalAccess', _75 => _75.fiberContext, 'optionalAccess', _76 => _76.trace, 'optionalAccess', _77 => _77.traceId]),
1744
- spanId: _optionalChain([f, 'optionalAccess', _78 => _78.fiberContext, 'optionalAccess', _79 => _79.trace, 'optionalAccess', _80 => _80.spanId])
1743
+ traceId: f?.fiberContext?.trace?.traceId,
1744
+ spanId: f?.fiberContext?.trace?.spanId
1745
1745
  };
1746
1746
  this.hooks.emit(ev, ctx);
1747
1747
  }
@@ -1753,7 +1753,7 @@ var Runtime = class _Runtime {
1753
1753
  const fiber = this.fiberEngine.fork(effect, scopeId);
1754
1754
  if (scopeId !== void 0) fiber.scopeId = scopeId;
1755
1755
  this.forkPolicy.initChild(fiber, parent, scopeId);
1756
- _optionalChain([fiber, 'access', _81 => _81.schedule, 'optionalCall', _82 => _82("initial-step")]);
1756
+ fiber.schedule?.("initial-step");
1757
1757
  return fiber;
1758
1758
  }
1759
1759
  stats() {
@@ -1765,7 +1765,7 @@ var Runtime = class _Runtime {
1765
1765
  return runtimeCapabilities();
1766
1766
  }
1767
1767
  shutdown() {
1768
- return _optionalChain([this, 'access', _83 => _83.fiberEngine, 'access', _84 => _84.shutdown, 'optionalCall', _85 => _85()]);
1768
+ return this.fiberEngine.shutdown?.();
1769
1769
  }
1770
1770
  unsafeRunAsync(effect, cb) {
1771
1771
  const fiber = this.fork(effect);
@@ -1778,7 +1778,7 @@ var Runtime = class _Runtime {
1778
1778
  if (exit._tag === "Success") resolve(exit.value);
1779
1779
  else {
1780
1780
  const c = exit.cause;
1781
- if (_optionalChain([c, 'optionalAccess', _86 => _86._tag]) === "Fail") reject(c.error);
1781
+ if (c?._tag === "Fail") reject(c.error);
1782
1782
  else reject(new Error("Interrupted"));
1783
1783
  }
1784
1784
  });
@@ -1810,13 +1810,13 @@ var Runtime = class _Runtime {
1810
1810
  }
1811
1811
  };
1812
1812
  function fork(effect, env) {
1813
- return Runtime.make(_nullishCoalesce(env, () => ( {}))).fork(effect);
1813
+ return Runtime.make(env ?? {}).fork(effect);
1814
1814
  }
1815
1815
  function unsafeRunAsync(effect, env, cb) {
1816
- Runtime.make(_nullishCoalesce(env, () => ( {}))).unsafeRunAsync(effect, cb);
1816
+ Runtime.make(env ?? {}).unsafeRunAsync(effect, cb);
1817
1817
  }
1818
1818
  function toPromise(effect, env) {
1819
- return Runtime.make(_nullishCoalesce(env, () => ( {}))).toPromise(effect);
1819
+ return Runtime.make(env ?? {}).toPromise(effect);
1820
1820
  }
1821
1821
  function fromPromiseAbortable(make, onReject) {
1822
1822
  return {
@@ -1873,7 +1873,7 @@ function getBenchmarkBudget() {
1873
1873
  }
1874
1874
  function reassociateFlatMap(cur) {
1875
1875
  let current = cur;
1876
- while (current._tag === "FlatMap" && _optionalChain([current, 'access', _87 => _87.first, 'optionalAccess', _88 => _88._tag]) === "FlatMap") {
1876
+ while (current._tag === "FlatMap" && current.first?._tag === "FlatMap") {
1877
1877
  const inner = current.first;
1878
1878
  const g = current.andThen;
1879
1879
  current = {
@@ -1888,32 +1888,32 @@ function reassociateFlatMap(cur) {
1888
1888
  }
1889
1889
  return current;
1890
1890
  }
1891
- var RuntimeFiber = (_class14 = class {
1892
-
1891
+ var RuntimeFiber = class {
1892
+ id;
1893
1893
  // 👇 CLAVE: guardar el runtime en el fiber (para getCurrentRuntime())
1894
-
1895
- __init55() {this.closing = null}
1896
- __init56() {this.finishing = false}
1897
- __init57() {this.runState = RUN.RUNNING}
1898
- __init58() {this.interrupted = false}
1899
- __init59() {this.result = null}
1900
- __init60() {this.joiners = []}
1894
+ runtime;
1895
+ closing = null;
1896
+ finishing = false;
1897
+ runState = RUN.RUNNING;
1898
+ interrupted = false;
1899
+ result = null;
1900
+ joiners = [];
1901
1901
  // estado de evaluación
1902
-
1903
- __init61() {this.stack = []}
1904
- __init62() {this.fiberFinalizers = []}
1905
- __init63() {this.finalizersDrained = false}
1906
-
1907
-
1908
-
1902
+ current;
1903
+ stack = [];
1904
+ fiberFinalizers = [];
1905
+ finalizersDrained = false;
1906
+ fiberContext;
1907
+ name;
1908
+ scopeId;
1909
1909
  /**
1910
1910
  * Cached closure for the scheduler callback — avoids creating a new
1911
1911
  * closure on every `schedule()` call. The tag parameter used by the
1912
1912
  * scheduler is only part of the label string, not the callback logic,
1913
1913
  * so a single cached closure is sufficient.
1914
1914
  */
1915
-
1916
- constructor(runtime, effect) {;_class14.prototype.__init55.call(this);_class14.prototype.__init56.call(this);_class14.prototype.__init57.call(this);_class14.prototype.__init58.call(this);_class14.prototype.__init59.call(this);_class14.prototype.__init60.call(this);_class14.prototype.__init61.call(this);_class14.prototype.__init62.call(this);_class14.prototype.__init63.call(this);_class14.prototype.__init64.call(this);
1915
+ boundStep;
1916
+ constructor(runtime, effect) {
1917
1917
  this.id = nextId++;
1918
1918
  this.runtime = runtime;
1919
1919
  this.current = effect;
@@ -1942,14 +1942,14 @@ var RuntimeFiber = (_class14 = class {
1942
1942
  return this.runtime.env;
1943
1943
  }
1944
1944
  get scheduler() {
1945
- return _nullishCoalesce(this.runtime.scheduler, () => ( globalScheduler));
1945
+ return this.runtime.scheduler ?? globalScheduler;
1946
1946
  }
1947
1947
  emit(ev) {
1948
1948
  this.runtime.hooks.emit(ev, {
1949
1949
  fiberId: this.id,
1950
1950
  scopeId: this.scopeId,
1951
- traceId: _optionalChain([this, 'access', _89 => _89.fiberContext, 'optionalAccess', _90 => _90.trace, 'optionalAccess', _91 => _91.traceId]),
1952
- spanId: _optionalChain([this, 'access', _92 => _92.fiberContext, 'optionalAccess', _93 => _93.trace, 'optionalAccess', _94 => _94.spanId])
1951
+ traceId: this.fiberContext?.trace?.traceId,
1952
+ spanId: this.fiberContext?.trace?.spanId
1953
1953
  });
1954
1954
  }
1955
1955
  addFinalizer(f) {
@@ -1992,7 +1992,7 @@ var RuntimeFiber = (_class14 = class {
1992
1992
  unsafeRunAsync(eff, this.env, () => {
1993
1993
  });
1994
1994
  }
1995
- } catch (e9) {
1995
+ } catch {
1996
1996
  }
1997
1997
  }
1998
1998
  }
@@ -2048,14 +2048,14 @@ var RuntimeFiber = (_class14 = class {
2048
2048
  }
2049
2049
  this.notify(Exit.failCause(Cause.fail(error)));
2050
2050
  }
2051
- __init64() {this.budget = DEFAULT_BUDGET2}
2051
+ budget = DEFAULT_BUDGET2;
2052
2052
  step() {
2053
2053
  if (this.result != null) return STEP.DONE;
2054
2054
  if (this.interrupted) {
2055
2055
  this.notify(Exit.failCause(Cause.interrupt()));
2056
2056
  return STEP.DONE;
2057
2057
  }
2058
- this.budget = _nullishCoalesce(__benchmarkBudget, () => ( DEFAULT_BUDGET2));
2058
+ this.budget = __benchmarkBudget ?? DEFAULT_BUDGET2;
2059
2059
  while (this.budget-- > 0) {
2060
2060
  this.current = reassociateFlatMap(this.current);
2061
2061
  const current = this.current;
@@ -2139,7 +2139,7 @@ var RuntimeFiber = (_class14 = class {
2139
2139
  done = true;
2140
2140
  try {
2141
2141
  canceler();
2142
- } catch (e10) {
2142
+ } catch {
2143
2143
  }
2144
2144
  });
2145
2145
  }
@@ -2168,13 +2168,13 @@ var RuntimeFiber = (_class14 = class {
2168
2168
  }
2169
2169
  return STEP.CONTINUE;
2170
2170
  }
2171
- }, _class14);
2171
+ };
2172
2172
  function getCurrentFiber() {
2173
2173
  return _current;
2174
2174
  }
2175
2175
  function unsafeGetCurrentRuntime() {
2176
2176
  const f = getCurrentFiber();
2177
- if (!_optionalChain([f, 'optionalAccess', _95 => _95.runtime])) {
2177
+ if (!f?.runtime) {
2178
2178
  throw new Error("unsafeGetCurrentRuntime: no current fiber/runtime");
2179
2179
  }
2180
2180
  return f.runtime;
@@ -2206,12 +2206,12 @@ function awaitAll(fibers) {
2206
2206
  }
2207
2207
  });
2208
2208
  }
2209
- var Scope = (_class15 = class _Scope {
2210
- constructor(runtime, parentScopeId) {;_class15.prototype.__init65.call(this);_class15.prototype.__init66.call(this);_class15.prototype.__init67.call(this);_class15.prototype.__init68.call(this);
2209
+ var Scope = class _Scope {
2210
+ constructor(runtime, parentScopeId) {
2211
2211
  this.runtime = runtime;
2212
2212
  this.parentScopeId = parentScopeId;
2213
2213
  this.id = nextScopeId++;
2214
- const inferredParent = _nullishCoalesce(this.parentScopeId, () => ( _optionalChain([getCurrentFiber, 'call', _96 => _96(), 'optionalAccess', _97 => _97.scopeId])));
2214
+ const inferredParent = this.parentScopeId ?? getCurrentFiber()?.scopeId;
2215
2215
  if (this.runtime.hasActiveHooks()) {
2216
2216
  this.runtime.emit({
2217
2217
  type: "scope.open",
@@ -2220,13 +2220,13 @@ var Scope = (_class15 = class _Scope {
2220
2220
  });
2221
2221
  }
2222
2222
  }
2223
-
2224
-
2225
-
2226
- __init65() {this.closed = false}
2227
- __init66() {this.children = /* @__PURE__ */ new Set()}
2228
- __init67() {this.subScopes = /* @__PURE__ */ new Set()}
2229
- __init68() {this.finalizers = []}
2223
+ runtime;
2224
+ parentScopeId;
2225
+ id;
2226
+ closed = false;
2227
+ children = /* @__PURE__ */ new Set();
2228
+ subScopes = /* @__PURE__ */ new Set();
2229
+ finalizers = [];
2230
2230
  /** registra un finalizer (LIFO) */
2231
2231
  addFinalizer(f) {
2232
2232
  if (this.closed) {
@@ -2285,7 +2285,7 @@ var Scope = (_class15 = class _Scope {
2285
2285
  let result;
2286
2286
  try {
2287
2287
  result = fin(exit);
2288
- } catch (e11) {
2288
+ } catch {
2289
2289
  return unit();
2290
2290
  }
2291
2291
  if (result._tag === "Succeed") {
@@ -2336,7 +2336,7 @@ var Scope = (_class15 = class _Scope {
2336
2336
  })
2337
2337
  );
2338
2338
  }
2339
- }, _class15);
2339
+ };
2340
2340
  function withScopeAsync(runtime, f) {
2341
2341
  return async((_env, cb) => {
2342
2342
  const scope = new Scope(runtime);
@@ -2486,71 +2486,71 @@ function raceWith(left, right, parentScope, onLeft, onRight) {
2486
2486
  });
2487
2487
  }
2488
2488
 
2489
-
2490
-
2491
-
2492
-
2493
-
2494
-
2495
-
2496
-
2497
-
2498
-
2499
-
2500
-
2501
-
2502
-
2503
-
2504
-
2505
-
2506
-
2507
-
2508
-
2509
-
2510
-
2511
-
2512
-
2513
-
2514
-
2515
-
2516
-
2517
-
2518
-
2519
-
2520
-
2521
-
2522
-
2523
-
2524
-
2525
-
2526
-
2527
-
2528
-
2529
-
2530
-
2531
-
2532
-
2533
-
2534
-
2535
-
2536
-
2537
-
2538
-
2539
-
2540
-
2541
-
2542
-
2543
-
2544
-
2545
-
2546
-
2547
-
2548
-
2549
-
2550
-
2551
-
2552
-
2553
-
2554
-
2555
-
2556
- exports.Async = Async; exports.asyncFold = asyncFold; exports.asyncCatchAll = asyncCatchAll; exports.asyncMapError = asyncMapError; exports.unit = unit; exports.asyncSucceed = asyncSucceed; exports.asyncFail = asyncFail; exports.asyncSync = asyncSync; exports.asyncTotal = asyncTotal; exports.async = async; exports.asyncMap = asyncMap; exports.asyncFlatMap = asyncFlatMap; exports.acquireRelease = acquireRelease; exports.asyncInterruptible = asyncInterruptible; exports.withAsyncPromise = withAsyncPromise; exports.mapAsync = mapAsync; exports.mapTryAsync = mapTryAsync; exports.none = none; exports.some = some; exports.Cause = Cause; exports.Exit = Exit; exports.succeed = succeed; exports.fail = fail; exports.sync = sync; exports.map = map; exports.flatMap = flatMap; exports.mapError = mapError; exports.catchAll = catchAll; exports.orElseOptional = orElseOptional; exports.end = end; exports.PushStatus = PushStatus; exports.RingBuffer = RingBuffer; exports.resolveWasmModule = resolveWasmModule; exports.makeBoundedRingBuffer = makeBoundedRingBuffer; exports.Scheduler = Scheduler; exports.globalScheduler = globalScheduler; exports.setBenchmarkBudget = setBenchmarkBudget; exports.getBenchmarkBudget = getBenchmarkBudget; exports.RuntimeFiber = RuntimeFiber; exports.getCurrentFiber = getCurrentFiber; exports.unsafeGetCurrentRuntime = unsafeGetCurrentRuntime; exports.withCurrentFiber = withCurrentFiber; exports.DefaultHostExecutor = DefaultHostExecutor; exports.JsFiberEngine = JsFiberEngine; exports.HostRegistry = HostRegistry; exports.ProgramBuilder = ProgramBuilder; exports.EngineFiberHandle = EngineFiberHandle; exports.ReferenceWasmBridge = ReferenceWasmBridge; exports.WasmPackFiberBridge = WasmPackFiberBridge; exports.WasmFiberRegistryBridge = WasmFiberRegistryBridge; exports.WasmFiberEngine = WasmFiberEngine; exports.runtimeCapabilities = runtimeCapabilities; exports.NoopHooks = NoopHooks; exports.Runtime = Runtime; exports.fork = fork; exports.unsafeRunAsync = unsafeRunAsync; exports.toPromise = toPromise; exports.fromPromiseAbortable = fromPromiseAbortable; exports.unsafeRunFoldWithEnv = unsafeRunFoldWithEnv; exports.Scope = Scope; exports.withScopeAsync = withScopeAsync; exports.withScope = withScope; exports.race = race; exports.zipPar = zipPar; exports.collectAllPar = collectAllPar; exports.raceWith = raceWith;
2489
+ export {
2490
+ Async,
2491
+ asyncFold,
2492
+ asyncCatchAll,
2493
+ asyncMapError,
2494
+ unit,
2495
+ asyncSucceed,
2496
+ asyncFail,
2497
+ asyncSync,
2498
+ asyncTotal,
2499
+ async,
2500
+ asyncMap,
2501
+ asyncFlatMap,
2502
+ acquireRelease,
2503
+ asyncInterruptible,
2504
+ withAsyncPromise,
2505
+ mapAsync,
2506
+ mapTryAsync,
2507
+ none,
2508
+ some,
2509
+ Cause,
2510
+ Exit,
2511
+ succeed,
2512
+ fail,
2513
+ sync,
2514
+ map,
2515
+ flatMap,
2516
+ mapError,
2517
+ catchAll,
2518
+ orElseOptional,
2519
+ end,
2520
+ PushStatus,
2521
+ RingBuffer,
2522
+ resolveWasmModule,
2523
+ makeBoundedRingBuffer,
2524
+ Scheduler,
2525
+ globalScheduler,
2526
+ setBenchmarkBudget,
2527
+ getBenchmarkBudget,
2528
+ RuntimeFiber,
2529
+ getCurrentFiber,
2530
+ unsafeGetCurrentRuntime,
2531
+ withCurrentFiber,
2532
+ DefaultHostExecutor,
2533
+ JsFiberEngine,
2534
+ HostRegistry,
2535
+ ProgramBuilder,
2536
+ EngineFiberHandle,
2537
+ ReferenceWasmBridge,
2538
+ WasmPackFiberBridge,
2539
+ WasmFiberRegistryBridge,
2540
+ WasmFiberEngine,
2541
+ runtimeCapabilities,
2542
+ NoopHooks,
2543
+ Runtime,
2544
+ fork,
2545
+ unsafeRunAsync,
2546
+ toPromise,
2547
+ fromPromiseAbortable,
2548
+ unsafeRunFoldWithEnv,
2549
+ Scope,
2550
+ withScopeAsync,
2551
+ withScope,
2552
+ race,
2553
+ zipPar,
2554
+ collectAllPar,
2555
+ raceWith
2556
+ };