brass-runtime 1.17.0 → 1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +36 -3
  2. package/dist/agent/cli/main.cjs +31 -32
  3. package/dist/agent/cli/main.js +3 -4
  4. package/dist/agent/cli/main.mjs +3 -4
  5. package/dist/agent/index.cjs +4 -5
  6. package/dist/agent/index.d.ts +1 -1
  7. package/dist/agent/index.js +3 -4
  8. package/dist/agent/index.mjs +3 -4
  9. package/dist/{chunk-7X3K5RMS.js → chunk-22HZQG5F.js} +9 -11
  10. package/dist/{chunk-GLE2WY7Z.cjs → chunk-2JHJ4YHS.cjs} +417 -124
  11. package/dist/{chunk-Q2I37RP3.cjs → chunk-2OW6IFY2.cjs} +44 -323
  12. package/dist/{chunk-7ZPEZ57L.cjs → chunk-5LC7V2OZ.cjs} +18 -20
  13. package/dist/{chunk-AGR5B2BC.cjs → chunk-5RZ7YITF.cjs} +564 -12
  14. package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
  15. package/dist/{chunk-EJ6BPYVR.mjs → chunk-6V2AWT4R.mjs} +1 -1
  16. package/dist/{chunk-3AYM6WPJ.js → chunk-7DU7IQHK.js} +20 -299
  17. package/dist/{chunk-SK7UZRNI.mjs → chunk-7GBJYOX7.mjs} +528 -23
  18. package/dist/chunk-7TKI527D.cjs +123 -0
  19. package/dist/{chunk-52OB2ROS.js → chunk-7VQLEN37.js} +2 -4
  20. package/dist/{chunk-KH4SYAOS.mjs → chunk-B5FKOLTB.mjs} +20 -299
  21. package/dist/{chunk-FHQGHPMO.mjs → chunk-BC6Q6BCO.mjs} +2 -4
  22. package/dist/{chunk-4P2HHGAX.mjs → chunk-COOW7BJX.mjs} +32 -11
  23. package/dist/{chunk-2HQTDLHF.mjs → chunk-EEN5OTCR.mjs} +555 -3
  24. package/dist/{chunk-KZJQ723N.cjs → chunk-EICAJDNX.cjs} +13 -15
  25. package/dist/chunk-ELIECDYN.cjs +33 -0
  26. package/dist/{chunk-GYM3LLGS.mjs → chunk-H626ZTDZ.mjs} +399 -106
  27. package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
  28. package/dist/{chunk-7JIJOVCT.js → chunk-IPSMXUWA.js} +2 -4
  29. package/dist/{chunk-4ROBZFL6.cjs → chunk-J6DUHITE.cjs} +6 -8
  30. package/dist/{chunk-6RY2FFN4.mjs → chunk-JWIEMBE6.mjs} +9 -11
  31. package/dist/{chunk-PD4EJTQC.cjs → chunk-KNTJ7FQB.cjs} +5 -5
  32. package/dist/chunk-KTGDLBLD.mjs +123 -0
  33. package/dist/chunk-LSYQ3C2M.js +33 -0
  34. package/dist/{chunk-RKGKFN2A.js → chunk-OW5VHAOE.js} +1 -1
  35. package/dist/{chunk-EOC4UHBS.mjs → chunk-RBHNOKH4.mjs} +2 -2
  36. package/dist/{chunk-6IXXWIUM.js → chunk-S4HXADU4.js} +555 -3
  37. package/dist/{chunk-FH2X7BVP.js → chunk-TTSPIU3U.js} +399 -106
  38. package/dist/{chunk-5QC7LRZ3.js → chunk-UAKAF32U.js} +2 -2
  39. package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
  40. package/dist/{chunk-MBEJI5HF.mjs → chunk-WCBNXPN6.mjs} +2 -4
  41. package/dist/{chunk-52PPNNI4.cjs → chunk-WGE2FEZE.cjs} +2 -2
  42. package/dist/{chunk-WBGRHGBP.cjs → chunk-WI7GZF3B.cjs} +114 -93
  43. package/dist/chunk-WUDHOZIH.js +6234 -0
  44. package/dist/{chunk-F6XWZQY4.cjs → chunk-WVSZOPGQ.cjs} +583 -78
  45. package/dist/chunk-XPIMJQYS.cjs +6234 -0
  46. package/dist/{chunk-VWIPB6I5.js → chunk-YGR2IN4R.js} +528 -23
  47. package/dist/chunk-YM3EDNYD.js +123 -0
  48. package/dist/chunk-YWLLH27R.mjs +33 -0
  49. package/dist/{chunk-BKK77SBA.js → chunk-YZ5LQ32F.js} +32 -11
  50. package/dist/chunk-Z3ZZMQUZ.mjs +6234 -0
  51. package/dist/core/index.cjs +37 -9
  52. package/dist/core/index.d.ts +19 -152
  53. package/dist/core/index.js +86 -58
  54. package/dist/core/index.mjs +86 -58
  55. package/dist/defaultClient-Cid0JoUR.d.ts +1648 -0
  56. package/dist/{effect-DIUHZ9IN.d.ts → effect-DnGUuhw6.d.ts} +22 -1
  57. package/dist/http/index.cjs +206 -59
  58. package/dist/http/index.d.ts +55 -819
  59. package/dist/http/index.js +220 -73
  60. package/dist/http/index.mjs +220 -73
  61. package/dist/http/testing.cjs +31 -10
  62. package/dist/http/testing.d.ts +16 -5
  63. package/dist/http/testing.js +29 -8
  64. package/dist/http/testing.mjs +29 -8
  65. package/dist/index.cjs +116 -88
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.js +87 -59
  68. package/dist/index.mjs +87 -59
  69. package/dist/{schedule-CK3Ml_7p.d.ts → layer-D2LFcBVx.d.ts} +176 -2
  70. package/dist/observability/index.cjs +20 -7
  71. package/dist/observability/index.d.ts +32 -8
  72. package/dist/observability/index.js +19 -6
  73. package/dist/observability/index.mjs +19 -6
  74. package/dist/perf/cli.cjs +26 -28
  75. package/dist/perf/cli.js +11 -13
  76. package/dist/perf/cli.mjs +11 -13
  77. package/dist/perf/index.cjs +13 -15
  78. package/dist/perf/index.js +11 -13
  79. package/dist/perf/index.mjs +11 -13
  80. package/dist/schema/index.cjs +2 -2
  81. package/dist/schema/index.js +1 -1
  82. package/dist/schema/index.mjs +1 -1
  83. package/dist/{server-D6JZ15_e.d.ts → server-Bf1zNYZk.d.ts} +5 -5
  84. package/dist/{stream-B4oK9JFP.d.ts → stream-I7bkvF7a.d.ts} +1 -1
  85. package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DF83nLn6.d.ts} +2 -2
  86. package/dist/{tracing-DqbTKGcf.d.ts → tracing-CWV4gT0u.d.ts} +1 -1
  87. package/docs/README.md +2 -0
  88. package/docs/ai/PUBLIC_API.md +28 -7
  89. package/docs/articles/brass-runtime-http-observability.md +467 -0
  90. package/docs/frameworks/angular.md +51 -0
  91. package/docs/frameworks/express.md +58 -0
  92. package/docs/frameworks/fastify.md +49 -0
  93. package/docs/frameworks/nestjs.md +53 -0
  94. package/docs/frameworks/nextjs.md +55 -0
  95. package/docs/frameworks/react.md +44 -0
  96. package/docs/frameworks/vanilla.md +56 -0
  97. package/docs/guides/layers.md +130 -0
  98. package/docs/http-recipes.md +31 -1
  99. package/docs/http.md +50 -1
  100. package/docs/observability.md +132 -0
  101. package/docs/performance-profiler.md +6 -2
  102. package/docs/recipes/layers.md +46 -2
  103. package/docs/recipes/testing.md +25 -0
  104. package/package.json +6 -2
  105. package/dist/chunk-3LOYJFRR.cjs +0 -300
  106. package/dist/chunk-3Y2RIUMM.js +0 -300
  107. package/dist/chunk-5EC274J5.cjs +0 -2874
  108. package/dist/chunk-5VRJNBLZ.mjs +0 -2874
  109. package/dist/chunk-62AZW6UT.cjs +0 -313
  110. package/dist/chunk-74ZTY6CP.js +0 -2871
  111. package/dist/chunk-7CMJS3QE.mjs +0 -2871
  112. package/dist/chunk-A2OM6NEH.mjs +0 -194
  113. package/dist/chunk-B33ICAKP.js +0 -313
  114. package/dist/chunk-JF5WGYJJ.cjs +0 -194
  115. package/dist/chunk-KN32XNTH.mjs +0 -313
  116. package/dist/chunk-KQLYONSE.cjs +0 -2871
  117. package/dist/chunk-L2SYFEBS.js +0 -194
  118. package/dist/chunk-MIIYDLGM.js +0 -2874
  119. package/dist/chunk-PWC3RBQE.mjs +0 -300
  120. package/dist/client-CZHU674n.d.ts +0 -820
@@ -1,20 +1,19 @@
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;
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;
2
2
 
3
- var _chunk62AZW6UTcjs = require('./chunk-62AZW6UT.cjs');
3
+ var _chunkWGE2FEZEcjs = require('./chunk-WGE2FEZE.cjs');
4
4
 
5
5
 
6
- var _chunkAGR5B2BCcjs = require('./chunk-AGR5B2BC.cjs');
7
6
 
7
+ var _chunk5RZ7YITFcjs = require('./chunk-5RZ7YITF.cjs');
8
8
 
9
- var _chunk52PPNNI4cjs = require('./chunk-52PPNNI4.cjs');
10
9
 
11
10
 
12
11
 
13
12
 
14
13
 
15
14
 
15
+ var _chunk2JHJ4YHScjs = require('./chunk-2JHJ4YHS.cjs');
16
16
 
17
- var _chunkGLE2WY7Zcjs = require('./chunk-GLE2WY7Z.cjs');
18
17
 
19
18
 
20
19
 
@@ -24,9 +23,10 @@ var _chunkGLE2WY7Zcjs = require('./chunk-GLE2WY7Z.cjs');
24
23
 
25
24
 
26
25
 
26
+ var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
27
27
 
28
28
 
29
- var _chunkMVGUEJ5Zcjs = require('./chunk-MVGUEJ5Z.cjs');
29
+ var _chunkUUMKZJRJcjs = require('./chunk-UUMKZJRJ.cjs');
30
30
 
31
31
  // src/core/types/cancel.ts
32
32
  function makeCancelToken() {
@@ -63,19 +63,19 @@ function linkAbortController(token, ac) {
63
63
 
64
64
  // src/core/runtime/dx.ts
65
65
  function makeRuntime(env = {}, options = {}) {
66
- return new (0, _chunkGLE2WY7Zcjs.Runtime)({ ...options, env });
66
+ return new (0, _chunk2JHJ4YHScjs.Runtime)({ ...options, env });
67
67
  }
68
68
  function runPromise(effect, envOrRuntime) {
69
- if (envOrRuntime instanceof _chunkGLE2WY7Zcjs.Runtime) return envOrRuntime.toPromise(effect);
70
- return _chunkGLE2WY7Zcjs.toPromise.call(void 0, effect, envOrRuntime);
69
+ if (envOrRuntime instanceof _chunk2JHJ4YHScjs.Runtime) return envOrRuntime.toPromise(effect);
70
+ return _chunk2JHJ4YHScjs.toPromise.call(void 0, effect, envOrRuntime);
71
71
  }
72
72
  function runExit(effect, envOrRuntime) {
73
73
  return new Promise((resolve) => {
74
- if (envOrRuntime instanceof _chunkGLE2WY7Zcjs.Runtime) {
74
+ if (envOrRuntime instanceof _chunk2JHJ4YHScjs.Runtime) {
75
75
  envOrRuntime.unsafeRunAsync(effect, resolve);
76
76
  return;
77
77
  }
78
- _chunkGLE2WY7Zcjs.unsafeRunAsync.call(void 0, effect, envOrRuntime, resolve);
78
+ _chunk2JHJ4YHScjs.unsafeRunAsync.call(void 0, effect, envOrRuntime, resolve);
79
79
  });
80
80
  }
81
81
  var runEffect = runPromise;
@@ -162,7 +162,7 @@ function makeSemaphore(n) {
162
162
  released = true;
163
163
  release();
164
164
  };
165
- const fiber = _chunkGLE2WY7Zcjs.getCurrentFiber.call(void 0, );
165
+ const fiber = _chunk2JHJ4YHScjs.getCurrentFiber.call(void 0, );
166
166
  _optionalChain([fiber, 'optionalAccess', _2 => _2.addFinalizer, 'call', _3 => _3(() => {
167
167
  releaseOnce();
168
168
  })]);
@@ -496,7 +496,7 @@ function makeTestRuntime(env, options = {}) {
496
496
  const scheduler = new TestScheduler(options);
497
497
  const clock = new TestClock(options.initialTimeMs, () => scheduler.flushAll(options.maxSteps), options.maxSteps);
498
498
  const testEnv = withTestClock(_nullishCoalesce(env, () => ( {})), clock);
499
- const runtime = _chunkGLE2WY7Zcjs.Runtime.makeWithEngine(testEnv, "ts", { scheduler });
499
+ const runtime = _chunk2JHJ4YHScjs.Runtime.makeWithEngine(testEnv, "ts", { scheduler });
500
500
  const flush = (maxTasks) => scheduler.flush(maxTasks);
501
501
  const flushAll = (maxSteps) => scheduler.flushAll(maxSteps);
502
502
  const advance = (ms) => clock.advance(ms);
@@ -567,7 +567,7 @@ function firstFailureValue(exit) {
567
567
  return failure._tag === "Some" ? failure.value : void 0;
568
568
  }
569
569
  function makeAssertionRuntime(runtime) {
570
- return _nullishCoalesce(runtime, () => ( _chunkGLE2WY7Zcjs.Runtime.make({})));
570
+ return _nullishCoalesce(runtime, () => ( _chunk2JHJ4YHScjs.Runtime.make({})));
571
571
  }
572
572
  async function assertSucceeds(effect, expected, runtime) {
573
573
  const rt = makeAssertionRuntime(runtime);
@@ -603,9 +603,9 @@ async function assertFailsWith(effect, predicate, runtime) {
603
603
  }
604
604
  async function assertCompletesWithin(effect, maxMs, runtime) {
605
605
  const rt = makeAssertionRuntime(runtime);
606
- const start = _chunkGLE2WY7Zcjs.runtimeClockFromEnv.call(void 0, rt.env).now();
606
+ const start = _chunk2JHJ4YHScjs.runtimeClockFromEnv.call(void 0, rt.env).now();
607
607
  const result = await rt.toPromise(effect);
608
- const elapsed = _chunkGLE2WY7Zcjs.runtimeClockFromEnv.call(void 0, rt.env).now() - start;
608
+ const elapsed = _chunk2JHJ4YHScjs.runtimeClockFromEnv.call(void 0, rt.env).now() - start;
609
609
  if (elapsed > maxMs) {
610
610
  throw new Error(`Effect took ${elapsed.toFixed(1)}ms, expected < ${maxMs}ms`);
611
611
  }
@@ -624,7 +624,7 @@ function flakyEffect(failCount, successValue, errorValue) {
624
624
  }
625
625
  function delayedEffect(ms, value) {
626
626
  return _chunkMVGUEJ5Zcjs.asyncEffect.call(void 0, (env, cb) => {
627
- const clock = _chunkGLE2WY7Zcjs.runtimeClockFromEnv.call(void 0, env);
627
+ const clock = _chunk2JHJ4YHScjs.runtimeClockFromEnv.call(void 0, env);
628
628
  const id = clock.setTimeout(() => cb(_chunkMVGUEJ5Zcjs.Exit.succeed(value)), ms);
629
629
  return () => clock.clearTimeout(id);
630
630
  });
@@ -636,275 +636,19 @@ function neverEffect() {
636
636
  });
637
637
  }
638
638
 
639
- // src/core/runtime/layer.ts
640
- var MissingLayerServiceError = (_class4 = class extends Error {
641
- __init15() {this._tag = "MissingLayerService"}
642
-
643
- constructor(serviceName) {
644
- super(`Missing layer service '${serviceName}'. Add a layer that provides this ServiceTag or pass a LayerContext containing it.`);_class4.prototype.__init15.call(this);;
645
- this.name = "MissingLayerServiceError";
646
- this.serviceName = serviceName;
647
- }
648
- }, _class4);
649
- function formatLayerError(error) {
650
- if (error instanceof MissingLayerServiceError) return error.message;
651
- if (isObjectRecord(error) && error._tag === "MissingLayerService" && typeof error.serviceName === "string") {
652
- return `Missing layer service '${error.serviceName}'. Add the provider layer before using the service.`;
653
- }
654
- return error instanceof Error ? error.message : String(error);
655
- }
656
- function makeServiceTag(name) {
657
- return {
658
- _tag: "ServiceTag",
659
- key: Symbol(name),
660
- name
661
- };
662
- }
663
- var serviceTag = makeServiceTag;
664
- var defineService = makeServiceTag;
665
- var LayerContext = class _LayerContext {
666
-
667
- constructor(entries) {
668
- if (entries instanceof Map) {
669
- this.services = new Map(entries);
670
- return;
671
- }
672
- this.services = /* @__PURE__ */ new Map();
673
- if (!entries) return;
674
- for (const [tag, service] of entries) this.services.set(tag.key, service);
675
- }
676
- static empty() {
677
- return new _LayerContext();
678
- }
679
- get(tag) {
680
- return this.services.get(tag.key);
681
- }
682
- unsafeGet(tag) {
683
- if (!this.services.has(tag.key)) {
684
- throw new MissingLayerServiceError(tag.name);
685
- }
686
- return this.services.get(tag.key);
687
- }
688
- has(tag) {
689
- return this.services.has(tag.key);
690
- }
691
- add(tag, service) {
692
- const next = new Map(this.services);
693
- next.set(tag.key, service);
694
- return new _LayerContext(next);
695
- }
696
- merge(other) {
697
- const next = new Map(this.services);
698
- for (const [key, service] of other.services) next.set(key, service);
699
- return new _LayerContext(next);
700
- }
701
- size() {
702
- return this.services.size;
703
- }
704
- };
705
- function makeLayerScope() {
706
- const cache = /* @__PURE__ */ new WeakMap();
707
- const finalizers = [];
708
- let closed = false;
709
- const scope = {
710
- get: (l, deps) => {
711
- if (closed) return _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, new Error("LayerScope is closed"));
712
- if (cache.has(l)) return _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, cache.get(l));
713
- const built = l.buildScoped ? l.buildScoped(deps, scope) : _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
714
- l.build(deps),
715
- ({ service, release }) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, scope.addFinalizer(release), () => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, service))
716
- );
717
- return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
718
- built,
719
- (service) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
720
- cache.set(l, service);
721
- return service;
722
- })
723
- );
724
- },
725
- close: () => {
726
- if (closed) return _chunkMVGUEJ5Zcjs.unit.call(void 0, );
727
- closed = true;
728
- return releaseAll(finalizers);
729
- },
730
- size: () => finalizers.length,
731
- addFinalizer: (release) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, () => {
732
- if (!closed) finalizers.push(release);
733
- })
734
- };
735
- return scope;
736
- }
737
- function releaseAll(finalizers) {
738
- const next = finalizers.pop();
739
- if (!next) return _chunkMVGUEJ5Zcjs.unit.call(void 0, );
740
- return _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
741
- next(),
742
- () => releaseAll(finalizers),
743
- () => releaseAll(finalizers)
744
- );
745
- }
746
- function mergeServices(a, b) {
747
- if (a instanceof LayerContext && b instanceof LayerContext) {
748
- return a.merge(b);
749
- }
750
- if (isObjectRecord(a) && isObjectRecord(b)) {
751
- return { ...a, ...b };
752
- }
753
- return Object.assign({}, a, b);
754
- }
755
- function isObjectRecord(value) {
756
- return typeof value === "object" && value !== null;
757
- }
758
- function layer(acquire, release) {
759
- return {
760
- _tag: "Layer",
761
- build: (_deps) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, acquire(), (service) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, {
762
- service,
763
- release: release ? () => release(service) : () => _chunkMVGUEJ5Zcjs.unit.call(void 0, )
764
- }))
765
- };
766
- }
767
- function layerValue(tag, value) {
768
- return layerEffect(tag, () => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, value));
769
- }
770
- function layerEffect(tag, acquire, release) {
771
- return {
772
- _tag: "Layer",
773
- build: (deps = LayerContext.empty()) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, acquire(deps), (service) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, {
774
- service: deps.add(tag, service),
775
- release: release ? () => release(service) : () => _chunkMVGUEJ5Zcjs.unit.call(void 0, )
776
- }))
777
- };
778
- }
779
- var layerFromContext = layerEffect;
780
- var defineLayer = layerEffect;
781
- function getService(tag) {
782
- return _chunkMVGUEJ5Zcjs.asyncSync.call(void 0, (context) => context.unsafeGet(tag));
783
- }
784
- function layerFrom() {
785
- return (acquire, release) => ({
786
- _tag: "Layer",
787
- build: (deps) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, acquire(deps), (service) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, {
788
- service,
789
- release: release ? () => release(service) : () => _chunkMVGUEJ5Zcjs.unit.call(void 0, )
790
- }))
791
- });
792
- }
793
- function layerSucceed(value) {
794
- return {
795
- _tag: "Layer",
796
- build: () => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, { service: value, release: () => _chunkMVGUEJ5Zcjs.unit.call(void 0, ) })
797
- };
798
- }
799
- function layerFail(error) {
800
- return {
801
- _tag: "Layer",
802
- build: () => _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, error)
803
- };
804
- }
805
- function compose(from, to) {
806
- return {
807
- _tag: "Layer",
808
- buildScoped: (deps, scope) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
809
- scope.get(from, deps),
810
- (mid) => scope.get(to, mid)
811
- ),
812
- build: (deps) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
813
- from.build(deps),
814
- ({ service: mid, release: releaseMid }) => _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
815
- to.build(mid),
816
- (error) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, releaseMid(), () => _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, error)),
817
- ({ service: out, release: releaseOut }) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, {
818
- service: out,
819
- release: () => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, releaseOut(), () => releaseMid())
820
- })
821
- )
822
- )
823
- };
824
- }
825
- function merge(left, right) {
826
- return {
827
- _tag: "Layer",
828
- buildScoped: (deps, scope) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
829
- scope.get(left, deps),
830
- (a) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
831
- scope.get(right, deps),
832
- (b) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, mergeServices(a, b))
833
- )
834
- ),
835
- build: (deps) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
836
- left.build(deps),
837
- ({ service: a, release: releaseA }) => _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
838
- right.build(deps),
839
- (error) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, releaseA(), () => _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, error)),
840
- ({ service: b, release: releaseB }) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, {
841
- service: mergeServices(a, b),
842
- release: () => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, releaseB(), () => releaseA())
843
- })
844
- )
845
- )
846
- };
847
- }
848
- function mapLayer(l, f) {
849
- return {
850
- _tag: "Layer",
851
- buildScoped: (deps, scope) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
852
- scope.get(l, deps),
853
- (service) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, f(service))
854
- ),
855
- build: (deps) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
856
- l.build(deps),
857
- ({ service, release }) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, { service: f(service), release })
858
- )
859
- };
860
- }
861
- function buildLayer(l, deps) {
862
- const scope = makeLayerScope();
863
- return _chunkMVGUEJ5Zcjs.asyncFold.call(void 0,
864
- scope.get(l, deps),
865
- (error) => _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, scope.close(), () => _chunkMVGUEJ5Zcjs.asyncFail.call(void 0, error)),
866
- (service) => _chunkMVGUEJ5Zcjs.asyncSucceed.call(void 0, {
867
- service,
868
- scope,
869
- close: scope.close,
870
- use: (body) => body(service)
871
- })
872
- );
873
- }
874
- function provideLayer(l, use, deps) {
875
- return _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0,
876
- buildLayer(l, _nullishCoalesce(deps, () => ( {}))),
877
- ({ service, close }) => _chunk62AZW6UTcjs.ensuring.call(void 0,
878
- use(service),
879
- () => close()
639
+ // src/core/runtime/configLayer.ts
640
+ function makeConfigLayer(tag, schema, source, options = {}) {
641
+ return _chunk5RZ7YITFcjs.layerEffect.call(void 0,
642
+ tag,
643
+ (context) => _chunkMVGUEJ5Zcjs.asyncSync.call(void 0,
644
+ () => _chunkUUMKZJRJcjs.parseConfig.call(void 0, _nullishCoalesce(options.name, () => ( tag.name)), schema, readConfigSource(source, context))
880
645
  )
881
646
  );
882
647
  }
883
- function provideLayerContext(l, use, deps = LayerContext.empty()) {
884
- return provideLayer(l, use, deps);
648
+ var defineConfigLayer = makeConfigLayer;
649
+ function readConfigSource(source, context) {
650
+ return typeof source === "function" ? source(context) : source;
885
651
  }
886
- var provide = provideLayer;
887
- var provideContext = provideLayerContext;
888
- var Layer = Object.freeze({
889
- make: layer,
890
- from: layerFrom,
891
- succeed: layerSucceed,
892
- fail: layerFail,
893
- value: layerValue,
894
- effect: layerEffect,
895
- define: defineLayer,
896
- fromContext: layerFromContext,
897
- compose,
898
- merge,
899
- map: mapLayer,
900
- provide: provideLayer,
901
- provideContext: provideLayerContext,
902
- build: buildLayer,
903
- scope: makeLayerScope,
904
- context: LayerContext.empty,
905
- tag: makeServiceTag,
906
- service: getService
907
- });
908
652
 
909
653
  // src/core/runtime/workerPool.ts
910
654
  function makeWorkerPool(config = {}) {
@@ -1078,14 +822,14 @@ function consoleJsonLogger() {
1078
822
  }
1079
823
 
1080
824
  // src/core/runtime/registry.ts
1081
- var RuntimeRegistry = (_class5 = class {constructor() { _class5.prototype.__init16.call(this);_class5.prototype.__init17.call(this);_class5.prototype.__init18.call(this);_class5.prototype.__init19.call(this);_class5.prototype.__init20.call(this); }
1082
- __init16() {this.fibers = /* @__PURE__ */ new Map()}
1083
- __init17() {this.scopes = /* @__PURE__ */ new Map()}
1084
- __init18() {this.seq = 1}
1085
- __init19() {this.recent = []}
1086
- __init20() {this.recentCap = 2e3}
825
+ var RuntimeRegistry = (_class4 = class {constructor() { _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); }
826
+ __init15() {this.fibers = /* @__PURE__ */ new Map()}
827
+ __init16() {this.scopes = /* @__PURE__ */ new Map()}
828
+ __init17() {this.seq = 1}
829
+ __init18() {this.recent = []}
830
+ __init19() {this.recentCap = 2e3}
1087
831
  emit(ev, ctx) {
1088
- const rec = _chunk52PPNNI4cjs.makeRuntimeEventRecord.call(void 0, ev, ctx, this.seq++);
832
+ const rec = _chunkWGE2FEZEcjs.makeRuntimeEventRecord.call(void 0, ev, ctx, this.seq++);
1089
833
  this.recent.push(rec);
1090
834
  if (this.recent.length > this.recentCap) this.recent.shift();
1091
835
  switch (rec.type) {
@@ -1154,7 +898,7 @@ var RuntimeRegistry = (_class5 = class {constructor() { _class5.prototype.__init
1154
898
  getRecentEvents() {
1155
899
  return this.recent.slice();
1156
900
  }
1157
- }, _class5);
901
+ }, _class4);
1158
902
  function formatRegistryError(error) {
1159
903
  if (error === void 0) return void 0;
1160
904
  if (_chunkMVGUEJ5Zcjs.Cause.isCause(error)) return _chunkMVGUEJ5Zcjs.Cause.pretty(error, { singleLine: true });
@@ -1241,8 +985,8 @@ function orElse(effect, fallback) {
1241
985
  // src/core/runtime/supervisor.ts
1242
986
  var nextSupervisorId = 1;
1243
987
  var nextChildId = 1;
1244
- var Supervisor = (_class6 = class {
1245
- constructor(runtime, config = {}) {;_class6.prototype.__init21.call(this);_class6.prototype.__init22.call(this);_class6.prototype.__init23.call(this);
988
+ var Supervisor = (_class5 = class {
989
+ constructor(runtime, config = {}) {;_class5.prototype.__init20.call(this);_class5.prototype.__init21.call(this);_class5.prototype.__init22.call(this);
1246
990
  this.runtime = runtime;
1247
991
  this.strategy = _nullishCoalesce(config.strategy, () => ( "one-for-one"));
1248
992
  this.restart = resolveRestartPolicy(_nullishCoalesce(config.restart, () => ( "on-failure")));
@@ -1251,14 +995,14 @@ var Supervisor = (_class6 = class {
1251
995
  this.onEvent = config.onEvent;
1252
996
  }
1253
997
 
1254
- __init21() {this.id = nextSupervisorId++}
1255
- __init22() {this.records = /* @__PURE__ */ new Map()}
998
+ __init20() {this.id = nextSupervisorId++}
999
+ __init21() {this.records = /* @__PURE__ */ new Map()}
1256
1000
 
1257
1001
 
1258
1002
 
1259
1003
 
1260
1004
 
1261
- __init23() {this.closed = false}
1005
+ __init22() {this.closed = false}
1262
1006
  start(spec) {
1263
1007
  if (this.closed) throw new Error("Supervisor is shut down");
1264
1008
  const record = {
@@ -1430,7 +1174,7 @@ var Supervisor = (_class6 = class {
1430
1174
  }
1431
1175
  record.restartTimes.push(now);
1432
1176
  if (record.restart.schedule) {
1433
- record.scheduleDriver ??= _chunkAGR5B2BCcjs.makeScheduleDriver.call(void 0, record.restart.schedule, {
1177
+ record.scheduleDriver ??= _chunk5RZ7YITFcjs.makeScheduleDriver.call(void 0, record.restart.schedule, {
1434
1178
  name: _nullishCoalesce(record.restart.schedule.name, () => ( "supervisor.restart")),
1435
1179
  clock: this.scheduleClock()
1436
1180
  });
@@ -1480,11 +1224,11 @@ var Supervisor = (_class6 = class {
1480
1224
  scheduleClock() {
1481
1225
  return {
1482
1226
  now: this.clock,
1483
- setTimeout: _chunkGLE2WY7Zcjs.liveClock.setTimeout,
1484
- clearTimeout: _chunkGLE2WY7Zcjs.liveClock.clearTimeout
1227
+ setTimeout: _chunk2JHJ4YHScjs.liveClock.setTimeout,
1228
+ clearTimeout: _chunk2JHJ4YHScjs.liveClock.clearTimeout
1485
1229
  };
1486
1230
  }
1487
- }, _class6);
1231
+ }, _class5);
1488
1232
  function makeSupervisor(runtime, config = {}) {
1489
1233
  return new Supervisor(runtime, config);
1490
1234
  }
@@ -1603,27 +1347,4 @@ function interruptExit() {
1603
1347
 
1604
1348
 
1605
1349
 
1606
-
1607
-
1608
-
1609
-
1610
-
1611
-
1612
-
1613
-
1614
-
1615
-
1616
-
1617
-
1618
-
1619
-
1620
-
1621
-
1622
-
1623
-
1624
-
1625
-
1626
-
1627
-
1628
-
1629
- exports.makeCancelToken = makeCancelToken; exports.linkAbortController = linkAbortController; exports.makeRuntime = makeRuntime; exports.runPromise = runPromise; exports.runExit = runExit; exports.runEffect = runEffect; exports.LinkedQueue = LinkedQueue; exports.makeSemaphore = makeSemaphore; exports.makeRef = makeRef; exports.derivedRef = derivedRef; exports.gracefulShutdown = gracefulShutdown; exports.registerShutdownHooks = registerShutdownHooks; exports.TestScheduler = TestScheduler; exports.TestClock = TestClock; exports.makeTestRuntime = makeTestRuntime; exports.assertSucceeds = assertSucceeds; exports.assertFails = assertFails; exports.assertFailsWith = assertFailsWith; exports.assertCompletesWithin = assertCompletesWithin; exports.flakyEffect = flakyEffect; exports.delayedEffect = delayedEffect; exports.neverEffect = neverEffect; exports.MissingLayerServiceError = MissingLayerServiceError; exports.formatLayerError = formatLayerError; exports.makeServiceTag = makeServiceTag; exports.serviceTag = serviceTag; exports.defineService = defineService; exports.LayerContext = LayerContext; exports.makeLayerScope = makeLayerScope; exports.layer = layer; exports.layerValue = layerValue; exports.layerEffect = layerEffect; exports.layerFromContext = layerFromContext; exports.defineLayer = defineLayer; exports.getService = getService; exports.layerFrom = layerFrom; exports.layerSucceed = layerSucceed; exports.layerFail = layerFail; exports.compose = compose; exports.merge = merge; exports.mapLayer = mapLayer; exports.buildLayer = buildLayer; exports.provideLayer = provideLayer; exports.provideLayerContext = provideLayerContext; exports.provide = provide; exports.provideContext = provideContext; exports.Layer = Layer; exports.makeWorkerPool = makeWorkerPool; exports.makeTracer = makeTracer; exports.consoleJsonLogger = consoleJsonLogger; exports.RuntimeRegistry = RuntimeRegistry; exports.dumpAllFibers = dumpAllFibers; exports.defaultTracer = defaultTracer; exports.catchTag = catchTag; exports.catchTags = catchTags; exports.mapError = mapError; exports.tagError = tagError; exports.orElse = orElse; exports.Supervisor = Supervisor; exports.makeSupervisor = makeSupervisor; exports.supervise = supervise; exports.joinSupervised = joinSupervised;
1350
+ exports.makeCancelToken = makeCancelToken; exports.linkAbortController = linkAbortController; exports.makeRuntime = makeRuntime; exports.runPromise = runPromise; exports.runExit = runExit; exports.runEffect = runEffect; exports.LinkedQueue = LinkedQueue; exports.makeSemaphore = makeSemaphore; exports.makeRef = makeRef; exports.derivedRef = derivedRef; exports.gracefulShutdown = gracefulShutdown; exports.registerShutdownHooks = registerShutdownHooks; exports.TestScheduler = TestScheduler; exports.TestClock = TestClock; exports.makeTestRuntime = makeTestRuntime; exports.assertSucceeds = assertSucceeds; exports.assertFails = assertFails; exports.assertFailsWith = assertFailsWith; exports.assertCompletesWithin = assertCompletesWithin; exports.flakyEffect = flakyEffect; exports.delayedEffect = delayedEffect; exports.neverEffect = neverEffect; exports.makeConfigLayer = makeConfigLayer; exports.defineConfigLayer = defineConfigLayer; exports.makeWorkerPool = makeWorkerPool; exports.makeTracer = makeTracer; exports.consoleJsonLogger = consoleJsonLogger; exports.RuntimeRegistry = RuntimeRegistry; exports.dumpAllFibers = dumpAllFibers; exports.defaultTracer = defaultTracer; exports.catchTag = catchTag; exports.catchTags = catchTags; exports.mapError = mapError; exports.tagError = tagError; exports.orElse = orElse; exports.Supervisor = Supervisor; exports.makeSupervisor = makeSupervisor; exports.supervise = supervise; exports.joinSupervised = joinSupervised;
@@ -1,26 +1,24 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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; }
2
2
 
3
3
 
4
- var _chunkPD4EJTQCcjs = require('./chunk-PD4EJTQC.cjs');
4
+ var _chunkKNTJ7FQBcjs = require('./chunk-KNTJ7FQB.cjs');
5
5
 
6
6
 
7
- var _chunkKQLYONSEcjs = require('./chunk-KQLYONSE.cjs');
7
+ var _chunkWVSZOPGQcjs = require('./chunk-WVSZOPGQ.cjs');
8
8
 
9
9
 
10
- var _chunk5EC274J5cjs = require('./chunk-5EC274J5.cjs');
10
+ var _chunkWI7GZF3Bcjs = require('./chunk-WI7GZF3B.cjs');
11
11
 
12
12
 
13
- var _chunkF6XWZQY4cjs = require('./chunk-F6XWZQY4.cjs');
13
+ var _chunkWGE2FEZEcjs = require('./chunk-WGE2FEZE.cjs');
14
14
 
15
15
 
16
- var _chunkWBGRHGBPcjs = require('./chunk-WBGRHGBP.cjs');
17
16
 
17
+ var _chunkXPIMJQYScjs = require('./chunk-XPIMJQYS.cjs');
18
18
 
19
- var _chunk52PPNNI4cjs = require('./chunk-52PPNNI4.cjs');
20
19
 
21
20
 
22
-
23
- var _chunkGLE2WY7Zcjs = require('./chunk-GLE2WY7Z.cjs');
21
+ var _chunk2JHJ4YHScjs = require('./chunk-2JHJ4YHS.cjs');
24
22
 
25
23
 
26
24
 
@@ -301,10 +299,10 @@ function makeRuntimeCase(variant, chainDepth) {
301
299
  maxCapacity: 8192,
302
300
  flushBudget: 2048
303
301
  };
304
- const scheduler = variant === "wide-scheduler" ? new (0, _chunkGLE2WY7Zcjs.Scheduler)(schedulerConfig) : void 0;
305
- const recorder = variant === "recorder" ? _chunkPD4EJTQCcjs.makeRuntimeRecorder.call(void 0, { maxEvents: 1e4 }) : void 0;
306
- const hooks = _nullishCoalesce(_optionalChain([recorder, 'optionalAccess', _8 => _8.hooks]), () => ( (variant === "active-hooks" ? new (0, _chunk52PPNNI4cjs.EventBus)() : void 0)));
307
- const runtime = _chunkGLE2WY7Zcjs.Runtime.makeWithEngine(hooks ? {} : {}, "ts", {
302
+ const scheduler = variant === "wide-scheduler" ? new (0, _chunk2JHJ4YHScjs.Scheduler)(schedulerConfig) : void 0;
303
+ const recorder = variant === "recorder" ? _chunkKNTJ7FQBcjs.makeRuntimeRecorder.call(void 0, { maxEvents: 1e4 }) : void 0;
304
+ const hooks = _nullishCoalesce(_optionalChain([recorder, 'optionalAccess', _8 => _8.hooks]), () => ( (variant === "active-hooks" ? new (0, _chunkWGE2FEZEcjs.EventBus)() : void 0)));
305
+ const runtime = _chunk2JHJ4YHScjs.Runtime.makeWithEngine(hooks ? {} : {}, "ts", {
308
306
  hooks,
309
307
  ...scheduler ? { scheduler } : {},
310
308
  inferLane: false
@@ -351,7 +349,7 @@ function makeFlatMapChain(depth) {
351
349
  return effect;
352
350
  }
353
351
  function makeFiberRefProgram(depth) {
354
- const ref = _chunkPD4EJTQCcjs.makeFiberRef.call(void 0, 0);
352
+ const ref = _chunkKNTJ7FQBcjs.makeFiberRef.call(void 0, 0);
355
353
  let effect = ref.set(0);
356
354
  for (let i = 0; i < depth; i++) {
357
355
  effect = _chunkMVGUEJ5Zcjs.asyncFlatMap.call(void 0, effect, () => ref.update((n) => n + 1));
@@ -653,7 +651,7 @@ async function profileHttpLayers(options = {}) {
653
651
  }
654
652
  async function runScenario(scenario) {
655
653
  const server = await startDummyServer(scenario.delayMs);
656
- const observability = scenario.variant === "default-json-observed" ? _chunkWBGRHGBPcjs.makeObservability.call(void 0, {
654
+ const observability = scenario.variant === "default-json-observed" ? _chunkWI7GZF3Bcjs.makeObservability.call(void 0, {
657
655
  logs: false,
658
656
  traces: { maxFinishedSpans: 1e4 },
659
657
  autoStart: false
@@ -840,9 +838,9 @@ function makeDefaultJsonRunner(server, scenario, preset, disableAdaptiveLimiter
840
838
  }
841
839
  function makeProfileRuntime(concurrency, observability) {
842
840
  const capacity = Math.max(65536, concurrency * 8);
843
- return _chunkGLE2WY7Zcjs.Runtime.makeWithEngine(_nullishCoalesce(_optionalChain([observability, 'optionalAccess', _30 => _30.env]), () => ( {})), "ts", {
841
+ return _chunk2JHJ4YHScjs.Runtime.makeWithEngine(_nullishCoalesce(_optionalChain([observability, 'optionalAccess', _30 => _30.env]), () => ( {})), "ts", {
844
842
  hooks: _optionalChain([observability, 'optionalAccess', _31 => _31.hooks]),
845
- scheduler: new (0, _chunkGLE2WY7Zcjs.Scheduler)({
843
+ scheduler: new (0, _chunk2JHJ4YHScjs.Scheduler)({
846
844
  laneMode: "single",
847
845
  initialCapacity: capacity,
848
846
  maxCapacity: capacity,
@@ -864,24 +862,24 @@ function baseHttpConfig(baseUrl, scenario) {
864
862
  };
865
863
  }
866
864
  function makeWireClient(baseUrl, scenario) {
867
- return _chunk5EC274J5cjs.makeHttp.call(void 0, baseHttpConfig(baseUrl, scenario));
865
+ return _chunkXPIMJQYScjs.makeHttp.call(void 0, baseHttpConfig(baseUrl, scenario));
868
866
  }
869
867
  function makeMinimalClient(baseUrl, scenario) {
870
- return _chunkKQLYONSEcjs.makeDefaultHttpClient.call(void 0, {
868
+ return _chunkXPIMJQYScjs.makeDefaultHttpClient.call(void 0, {
871
869
  preset: "minimal",
872
870
  compression: false,
873
871
  ...baseHttpConfig(baseUrl, scenario)
874
872
  });
875
873
  }
876
874
  function makeDefaultClient(baseUrl, scenario, preset, disableAdaptiveLimiter, observability) {
877
- return _chunkKQLYONSEcjs.makeDefaultHttpClient.call(void 0, {
875
+ return _chunkXPIMJQYScjs.makeDefaultHttpClient.call(void 0, {
878
876
  preset,
879
877
  compression: false,
880
878
  ...baseHttpConfig(baseUrl, scenario),
881
879
  ...disableAdaptiveLimiter ? { adaptiveLimiter: false } : {},
882
880
  ...observability ? {
883
881
  middleware: [
884
- _chunkF6XWZQY4cjs.withHttpObservability.call(void 0, {
882
+ _chunkWVSZOPGQcjs.withHttpObservability.call(void 0, {
885
883
  metrics: observability.metrics,
886
884
  logs: false,
887
885
  spans: {},