brass-runtime 1.16.1 → 1.18.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.
Files changed (123) hide show
  1. package/README.md +40 -8
  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-GYM3LLGS.mjs → chunk-2QNREG6K.mjs} +188 -5
  10. package/dist/{chunk-4ROBZFL6.cjs → chunk-2SLT3X6G.cjs} +6 -8
  11. package/dist/{chunk-KZJQ723N.cjs → chunk-3PFZGP23.cjs} +13 -15
  12. package/dist/{chunk-AVNQLJ5V.js → chunk-3PHU7FWS.js} +528 -23
  13. package/dist/{chunk-CIZFIMK5.js → chunk-4YQHPIWJ.js} +60 -11
  14. package/dist/chunk-5XADBMSU.cjs +33 -0
  15. package/dist/{chunk-DNFJLJMW.mjs → chunk-6MLAZPBL.mjs} +48 -24
  16. package/dist/chunk-7TKI527D.cjs +123 -0
  17. package/dist/{chunk-AGR5B2BC.cjs → chunk-7TXQJFZX.cjs} +564 -12
  18. package/dist/{chunk-RKGKFN2A.js → chunk-AADFFVYS.js} +1 -1
  19. package/dist/{chunk-52PPNNI4.cjs → chunk-AJMKZXRB.cjs} +2 -2
  20. package/dist/{chunk-3AYM6WPJ.js → chunk-BG5RNEA2.js} +20 -299
  21. package/dist/{chunk-2HQTDLHF.mjs → chunk-ELLF55ER.mjs} +555 -3
  22. package/dist/{chunk-EOC4UHBS.mjs → chunk-G5JTCFMI.mjs} +2 -2
  23. package/dist/chunk-H5GYX7RZ.js +6126 -0
  24. package/dist/{chunk-C3MDXTRZ.js → chunk-HCJ4S3YB.js} +48 -24
  25. package/dist/{chunk-6IXXWIUM.js → chunk-IBRHSH5H.js} +555 -3
  26. package/dist/{chunk-Q2I37RP3.cjs → chunk-IFRBVMWJ.cjs} +44 -323
  27. package/dist/{chunk-52OB2ROS.js → chunk-ITG6I7ZS.js} +2 -4
  28. package/dist/chunk-ITZQ526U.mjs +33 -0
  29. package/dist/{chunk-7JIJOVCT.js → chunk-JH4GI3DW.js} +2 -4
  30. package/dist/{chunk-76YMRMH2.cjs → chunk-KHACHFBQ.cjs} +583 -78
  31. package/dist/{chunk-MT3OWDPC.mjs → chunk-KRYP6CAE.mjs} +60 -11
  32. package/dist/chunk-KTGDLBLD.mjs +123 -0
  33. package/dist/{chunk-ENKODRU3.cjs → chunk-LXBU5E77.cjs} +143 -94
  34. package/dist/{chunk-PD4EJTQC.cjs → chunk-N6QNSTWD.cjs} +5 -5
  35. package/dist/{chunk-HLWLMW2F.mjs → chunk-OI4ESUMC.mjs} +9 -11
  36. package/dist/{chunk-EJ6BPYVR.mjs → chunk-OT2TESZU.mjs} +1 -1
  37. package/dist/{chunk-BABBZK4Y.js → chunk-PSEU65ND.js} +9 -11
  38. package/dist/{chunk-DNFO2EIZ.mjs → chunk-QCOLAHU3.mjs} +528 -23
  39. package/dist/{chunk-KH4SYAOS.mjs → chunk-QZ6QFJNM.mjs} +20 -299
  40. package/dist/{chunk-MBEJI5HF.mjs → chunk-R6WDSZA6.mjs} +2 -4
  41. package/dist/{chunk-FHQGHPMO.mjs → chunk-RREBJX2S.mjs} +2 -4
  42. package/dist/{chunk-5QC7LRZ3.js → chunk-S4HHFUYP.js} +2 -2
  43. package/dist/{chunk-GLE2WY7Z.cjs → chunk-SSQJKDN3.cjs} +194 -11
  44. package/dist/{chunk-CZIVE6NT.cjs → chunk-UUMKZJRJ.cjs} +48 -24
  45. package/dist/chunk-VIFA4DPN.cjs +6126 -0
  46. package/dist/chunk-W6WR37HN.js +33 -0
  47. package/dist/{chunk-FH2X7BVP.js → chunk-XSAHV5HQ.js} +188 -5
  48. package/dist/chunk-YM3EDNYD.js +123 -0
  49. package/dist/{chunk-VN44DYYT.cjs → chunk-YTX2JYYP.cjs} +18 -20
  50. package/dist/chunk-Z3PSSXP3.mjs +6126 -0
  51. package/dist/core/index.cjs +31 -9
  52. package/dist/core/index.d.ts +19 -152
  53. package/dist/core/index.js +80 -58
  54. package/dist/core/index.mjs +80 -58
  55. package/dist/defaultClient-DhpCQW9m.d.ts +1623 -0
  56. package/dist/{effect-DIUHZ9IN.d.ts → effect-CtUDl5M5.d.ts} +1 -1
  57. package/dist/http/index.cjs +202 -59
  58. package/dist/http/index.d.ts +55 -819
  59. package/dist/http/index.js +216 -73
  60. package/dist/http/index.mjs +216 -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 +110 -88
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.js +81 -59
  68. package/dist/index.mjs +81 -59
  69. package/dist/{schedule-CK3Ml_7p.d.ts → layer-BalPI6cN.d.ts} +176 -2
  70. package/dist/observability/index.cjs +22 -7
  71. package/dist/observability/index.d.ts +32 -8
  72. package/dist/observability/index.js +21 -6
  73. package/dist/observability/index.mjs +21 -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-GJPg8ZSG.d.ts → server-C1zVmqE6.d.ts} +16 -5
  84. package/dist/{stream-B4oK9JFP.d.ts → stream-Bb4FTejt.d.ts} +1 -1
  85. package/dist/{tracer-Hwt1cl7h.d.ts → tracer-DzfuE6um.d.ts} +2 -2
  86. package/dist/{tracing-DqbTKGcf.d.ts → tracing-BABA5arE.d.ts} +1 -1
  87. package/docs/README.md +4 -0
  88. package/docs/ai/PUBLIC_API.md +31 -7
  89. package/docs/articles/brass-runtime-http-observability.md +467 -0
  90. package/docs/framework-integrations.md +38 -0
  91. package/docs/frameworks/angular.md +204 -0
  92. package/docs/frameworks/express.md +183 -0
  93. package/docs/frameworks/fastify.md +173 -0
  94. package/docs/frameworks/nestjs.md +335 -0
  95. package/docs/frameworks/nextjs.md +202 -0
  96. package/docs/frameworks/react.md +183 -0
  97. package/docs/frameworks/vanilla.md +280 -0
  98. package/docs/guides/layers.md +130 -0
  99. package/docs/http-recipes.md +31 -1
  100. package/docs/http.md +50 -1
  101. package/docs/nestjs.md +6 -0
  102. package/docs/observability-framework-examples.md +12 -0
  103. package/docs/observability.md +239 -0
  104. package/docs/performance-profiler.md +6 -2
  105. package/docs/recipes/layers.md +46 -2
  106. package/docs/recipes/testing.md +25 -0
  107. package/package.json +4 -1
  108. package/dist/chunk-3LOYJFRR.cjs +0 -300
  109. package/dist/chunk-3Y2RIUMM.js +0 -300
  110. package/dist/chunk-5EC274J5.cjs +0 -2874
  111. package/dist/chunk-5VRJNBLZ.mjs +0 -2874
  112. package/dist/chunk-62AZW6UT.cjs +0 -313
  113. package/dist/chunk-74ZTY6CP.js +0 -2871
  114. package/dist/chunk-7CMJS3QE.mjs +0 -2871
  115. package/dist/chunk-A2OM6NEH.mjs +0 -194
  116. package/dist/chunk-B33ICAKP.js +0 -313
  117. package/dist/chunk-JF5WGYJJ.cjs +0 -194
  118. package/dist/chunk-KN32XNTH.mjs +0 -313
  119. package/dist/chunk-KQLYONSE.cjs +0 -2871
  120. package/dist/chunk-L2SYFEBS.js +0 -194
  121. package/dist/chunk-MIIYDLGM.js +0 -2874
  122. package/dist/chunk-PWC3RBQE.mjs +0 -300
  123. 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 _chunkAJMKZXRBcjs = require('./chunk-AJMKZXRB.cjs');
4
4
 
5
5
 
6
- var _chunkAGR5B2BCcjs = require('./chunk-AGR5B2BC.cjs');
7
6
 
7
+ var _chunk7TXQJFZXcjs = require('./chunk-7TXQJFZX.cjs');
8
8
 
9
- var _chunk52PPNNI4cjs = require('./chunk-52PPNNI4.cjs');
10
9
 
11
10
 
12
11
 
13
12
 
14
13
 
15
14
 
15
+ var _chunkSSQJKDN3cjs = require('./chunk-SSQJKDN3.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, _chunkSSQJKDN3cjs.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 _chunkSSQJKDN3cjs.Runtime) return envOrRuntime.toPromise(effect);
70
+ return _chunkSSQJKDN3cjs.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 _chunkSSQJKDN3cjs.Runtime) {
75
75
  envOrRuntime.unsafeRunAsync(effect, resolve);
76
76
  return;
77
77
  }
78
- _chunkGLE2WY7Zcjs.unsafeRunAsync.call(void 0, effect, envOrRuntime, resolve);
78
+ _chunkSSQJKDN3cjs.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 = _chunkSSQJKDN3cjs.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 = _chunkSSQJKDN3cjs.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, () => ( _chunkSSQJKDN3cjs.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 = _chunkSSQJKDN3cjs.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 = _chunkSSQJKDN3cjs.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 = _chunkSSQJKDN3cjs.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 _chunk7TXQJFZXcjs.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 = _chunkAJMKZXRBcjs.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 ??= _chunk7TXQJFZXcjs.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: _chunkSSQJKDN3cjs.liveClock.setTimeout,
1228
+ clearTimeout: _chunkSSQJKDN3cjs.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;
@@ -2,11 +2,9 @@ import {
2
2
  race
3
3
  } from "./chunk-UCUBNWM2.js";
4
4
  import {
5
+ fromPromiseAbortable,
5
6
  withScopeAsync
6
- } from "./chunk-L2SYFEBS.js";
7
- import {
8
- fromPromiseAbortable
9
- } from "./chunk-FH2X7BVP.js";
7
+ } from "./chunk-XSAHV5HQ.js";
10
8
  import {
11
9
  Cause,
12
10
  Exit,
@@ -0,0 +1,33 @@
1
+ import {
2
+ layerEffect,
3
+ makeServiceTag
4
+ } from "./chunk-ELLF55ER.mjs";
5
+ import {
6
+ Runtime
7
+ } from "./chunk-2QNREG6K.mjs";
8
+ import {
9
+ asyncSync
10
+ } from "./chunk-36I3M4UC.mjs";
11
+
12
+ // src/core/runtime/runtimeLayer.ts
13
+ var RuntimeService = makeServiceTag("Runtime");
14
+ function makeRuntimeLayer(env = {}, options = {}) {
15
+ const { tag = RuntimeService, ...runtimeOptions } = options;
16
+ return layerEffect(
17
+ tag,
18
+ (context) => asyncSync(
19
+ () => new Runtime({
20
+ ...runtimeOptions,
21
+ env: resolveRuntimeLayerEnv(env, context)
22
+ })
23
+ )
24
+ );
25
+ }
26
+ function resolveRuntimeLayerEnv(env, context) {
27
+ return typeof env === "function" ? env(context) : env;
28
+ }
29
+
30
+ export {
31
+ RuntimeService,
32
+ makeRuntimeLayer
33
+ };
@@ -2,13 +2,11 @@ import {
2
2
  raceWith
3
3
  } from "./chunk-UCUBNWM2.js";
4
4
  import {
5
- Scope
6
- } from "./chunk-L2SYFEBS.js";
7
- import {
5
+ Scope,
8
6
  getCurrentFiber,
9
7
  unsafeGetCurrentRuntime,
10
8
  unsafeRunFoldWithEnv
11
- } from "./chunk-FH2X7BVP.js";
9
+ } from "./chunk-XSAHV5HQ.js";
12
10
  import {
13
11
  Cause,
14
12
  Exit,