better-effect 0.13.0 → 0.14.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 (109) hide show
  1. package/README.md +337 -88
  2. package/dist/adapters/iti.d.mts +2 -3
  3. package/dist/adapters/iti.d.mts.map +1 -1
  4. package/dist/adapters/iti.mjs +2 -2
  5. package/dist/bun.d.mts +75 -23
  6. package/dist/bun.d.mts.map +1 -1
  7. package/dist/bun.mjs +170 -33
  8. package/dist/bun.mjs.map +1 -1
  9. package/dist/{context-BphfFUMO.mjs → context-DSGSqcJj.mjs} +12 -3
  10. package/dist/context-DSGSqcJj.mjs.map +1 -0
  11. package/dist/{current-request-DDKNyymv.mjs → current-request-Bc1YHL0w.mjs} +3 -2
  12. package/dist/{current-request-DDKNyymv.mjs.map → current-request-Bc1YHL0w.mjs.map} +1 -1
  13. package/dist/{current-request-CIU7AHhF.d.mts → current-request-Dm-QQ3Xr.d.mts} +4 -4
  14. package/dist/current-request-Dm-QQ3Xr.d.mts.map +1 -0
  15. package/dist/{effect-CPdV7Yv8.mjs → effect-W0IQXY8P.mjs} +21 -2
  16. package/dist/effect-W0IQXY8P.mjs.map +1 -0
  17. package/dist/{errors-BKcsQ0ip.d.mts → errors-CpHMzPiP.d.mts} +6 -2
  18. package/dist/errors-CpHMzPiP.d.mts.map +1 -0
  19. package/dist/hono.d.mts +63 -27
  20. package/dist/hono.d.mts.map +1 -1
  21. package/dist/hono.mjs +111 -45
  22. package/dist/hono.mjs.map +1 -1
  23. package/dist/{index-CCi07kUw.d.mts → index-3Bkl-sxS.d.mts} +7 -2
  24. package/dist/{index-CCi07kUw.d.mts.map → index-3Bkl-sxS.d.mts.map} +1 -1
  25. package/dist/{index-cXgyMa0v.d.mts → index-C2ed9Ilq.d.mts} +32 -7
  26. package/dist/index-C2ed9Ilq.d.mts.map +1 -0
  27. package/dist/{index-BodMy6rO.d.mts → index-ClNndn2-.d.mts} +93 -63
  28. package/dist/index-ClNndn2-.d.mts.map +1 -0
  29. package/dist/{index-DAKn0qHk.d.mts → index-Cy1VsU-u.d.mts} +2 -4
  30. package/dist/index-Cy1VsU-u.d.mts.map +1 -0
  31. package/dist/index.d.mts +6 -8
  32. package/dist/index.mjs +8 -9
  33. package/dist/index.mjs.map +1 -1
  34. package/dist/{internal-identity-CbXoZIfw.mjs → internal-identity-BuHBtP0k.mjs} +2 -2
  35. package/dist/{internal-identity-CbXoZIfw.mjs.map → internal-identity-BuHBtP0k.mjs.map} +1 -1
  36. package/dist/layer-2kjHVv4N.mjs +343 -0
  37. package/dist/layer-2kjHVv4N.mjs.map +1 -0
  38. package/dist/layer-C2OaqTmB.d.mts +987 -0
  39. package/dist/layer-C2OaqTmB.d.mts.map +1 -0
  40. package/dist/next.d.mts +102 -26
  41. package/dist/next.d.mts.map +1 -1
  42. package/dist/next.mjs +157 -40
  43. package/dist/next.mjs.map +1 -1
  44. package/dist/{node-context-DczjAcrX.d.mts → node-context-1YEjrU9g.d.mts} +2 -2
  45. package/dist/{node-context-DczjAcrX.d.mts.map → node-context-1YEjrU9g.d.mts.map} +1 -1
  46. package/dist/{node-context-Ca18oNSg.mjs → node-context-g3bCcY9t.mjs} +2 -2
  47. package/dist/{node-context-Ca18oNSg.mjs.map → node-context-g3bCcY9t.mjs.map} +1 -1
  48. package/dist/node.d.mts +11 -6
  49. package/dist/node.d.mts.map +1 -1
  50. package/dist/node.mjs +156 -10
  51. package/dist/node.mjs.map +1 -1
  52. package/dist/opentelemetry.d.mts +20 -2
  53. package/dist/opentelemetry.d.mts.map +1 -1
  54. package/dist/opentelemetry.mjs +423 -5
  55. package/dist/opentelemetry.mjs.map +1 -1
  56. package/dist/{registration-drnZk0SY.mjs → registration-Bwe2GbVu.mjs} +8 -2
  57. package/dist/registration-Bwe2GbVu.mjs.map +1 -0
  58. package/dist/runtime/explicit.d.mts +2 -2
  59. package/dist/runtime/explicit.mjs +1 -1
  60. package/dist/runtime/node.d.mts +3 -3
  61. package/dist/runtime/node.mjs +2 -2
  62. package/dist/runtime-qpcVwaz_.mjs +1680 -0
  63. package/dist/runtime-qpcVwaz_.mjs.map +1 -0
  64. package/dist/service-CO9VJQYa.mjs +74 -0
  65. package/dist/service-CO9VJQYa.mjs.map +1 -0
  66. package/dist/{signal-nfgFyNCk.mjs → signal-5Rg9bUUe.mjs} +2 -2
  67. package/dist/{signal-nfgFyNCk.mjs.map → signal-5Rg9bUUe.mjs.map} +1 -1
  68. package/dist/{standard-services-vnGIafkS.mjs → standard-services-B-iMM_W7.mjs} +38 -4
  69. package/dist/standard-services-B-iMM_W7.mjs.map +1 -0
  70. package/dist/standard-services.d.mts +4 -4
  71. package/dist/standard-services.mjs +3 -3
  72. package/dist/testing.d.mts +25 -7
  73. package/dist/testing.d.mts.map +1 -1
  74. package/dist/testing.mjs +51 -7
  75. package/dist/testing.mjs.map +1 -1
  76. package/dist/{types-oihI-ESv.d.mts → types-BFTqCCcw.d.mts} +32 -5
  77. package/dist/types-BFTqCCcw.d.mts.map +1 -0
  78. package/dist/web-effect-B9hp9jIe.mjs +380 -0
  79. package/dist/web-effect-B9hp9jIe.mjs.map +1 -0
  80. package/dist/web.d.mts +22 -13
  81. package/dist/web.d.mts.map +1 -1
  82. package/dist/web.mjs +1 -1
  83. package/package.json +10 -16
  84. package/dist/context-BphfFUMO.mjs.map +0 -1
  85. package/dist/current-request-CIU7AHhF.d.mts.map +0 -1
  86. package/dist/disposable-CP-Q2H3l.mjs +0 -57
  87. package/dist/disposable-CP-Q2H3l.mjs.map +0 -1
  88. package/dist/effect-CPdV7Yv8.mjs.map +0 -1
  89. package/dist/errors-BKcsQ0ip.d.mts.map +0 -1
  90. package/dist/index-AiKM71-u.d.mts +0 -376
  91. package/dist/index-AiKM71-u.d.mts.map +0 -1
  92. package/dist/index-BodMy6rO.d.mts.map +0 -1
  93. package/dist/index-DAKn0qHk.d.mts.map +0 -1
  94. package/dist/index-cXgyMa0v.d.mts.map +0 -1
  95. package/dist/layer-D16GKxuX.mjs +0 -269
  96. package/dist/layer-D16GKxuX.mjs.map +0 -1
  97. package/dist/observer-9nhbL7Pr.d.mts +0 -68
  98. package/dist/observer-9nhbL7Pr.d.mts.map +0 -1
  99. package/dist/outcome-DI8LPIQ4.d.mts +0 -387
  100. package/dist/outcome-DI8LPIQ4.d.mts.map +0 -1
  101. package/dist/program-metadata-BxjGkT17.mjs +0 -260
  102. package/dist/program-metadata-BxjGkT17.mjs.map +0 -1
  103. package/dist/registration-drnZk0SY.mjs.map +0 -1
  104. package/dist/runtime-C_55ofnL.mjs +0 -791
  105. package/dist/runtime-C_55ofnL.mjs.map +0 -1
  106. package/dist/standard-services-vnGIafkS.mjs.map +0 -1
  107. package/dist/types-oihI-ESv.d.mts.map +0 -1
  108. package/dist/web-Bq3MfMrj.mjs +0 -147
  109. package/dist/web-Bq3MfMrj.mjs.map +0 -1
package/dist/hono.mjs CHANGED
@@ -1,5 +1,8 @@
1
- import { t as Effect } from "./effect-CPdV7Yv8.mjs";
2
- import { r as assertResponse, t as WebEffect } from "./web-Bq3MfMrj.mjs";
1
+ import { t as Layer } from "./layer-2kjHVv4N.mjs";
2
+ import { t as Service } from "./service-CO9VJQYa.mjs";
3
+ import { n as eraseRuntimeExecutor, t as Runtime } from "./runtime-qpcVwaz_.mjs";
4
+ import { t as Effect } from "./effect-W0IQXY8P.mjs";
5
+ import { a as assertResponse, n as makeManagedResponse, r as runManagedWith } from "./web-effect-B9hp9jIe.mjs";
3
6
  import { Result } from "better-result";
4
7
  import { createMiddleware } from "hono/factory";
5
8
  //#region src/hono/request-boundary.ts
@@ -16,17 +19,33 @@ const recordRequestSuccess = (state, value, options) => {
16
19
  options
17
20
  };
18
21
  };
22
+ const recordRequestStream = (state, descriptor, options) => {
23
+ state.outcome ??= {
24
+ kind: "stream",
25
+ descriptor,
26
+ options
27
+ };
28
+ };
29
+ const responsePlan = (response) => {
30
+ const readiness = Promise.resolve(response).then((value) => assertResponse(value));
31
+ return {
32
+ readiness,
33
+ completion: readiness.then(() => void 0),
34
+ cancel: async () => {}
35
+ };
36
+ };
19
37
  const makeBoundaryOptions = (options, state, context) => {
20
38
  const boundaryOptions = {
21
- onSuccess: ({ value }) => {
22
- if (context.finalized) return context.res;
39
+ onSuccess: ({ value }, managed) => {
40
+ if (context.finalized) return responsePlan(context.res);
23
41
  const outcome = state.outcome;
24
- if (outcome?.kind !== "success") return value;
25
- if (outcome.options.respond !== void 0) return outcome.options.respond(value, context);
42
+ if (outcome?.kind === "stream") return makeManagedResponse(outcome.descriptor, managed, outcome.options.unconsumedTimeoutMs);
43
+ if (outcome?.kind !== "success") return responsePlan(value);
44
+ if (outcome.options.respond !== void 0) return responsePlan(outcome.options.respond(value, context));
26
45
  const success = { value };
27
46
  if (outcome.options.status !== void 0) Object.assign(success, { status: outcome.options.status });
28
47
  if (outcome.options.serialize !== void 0) Object.assign(success, { serialize: outcome.options.serialize });
29
- return options.onSuccess(success, context);
48
+ return responsePlan(options.onSuccess(success, context));
30
49
  },
31
50
  onFailure: (error) => {
32
51
  if (context.error !== void 0 || context.finalized) return context.res;
@@ -66,18 +85,7 @@ const makeRequestBoundary = (options) => {
66
85
  });
67
86
  const boundaryOptions = makeBoundaryOptions(options, state, context);
68
87
  let response;
69
- if (options.requestLayer === void 0) response = await WebEffect.handle(options.runtime, context.req.raw, program, {
70
- onSuccess: boundaryOptions.onSuccess,
71
- onFailure: boundaryOptions.onFailure
72
- });
73
- else {
74
- const requestBoundaryOptions = {
75
- onSuccess: boundaryOptions.onSuccess,
76
- onFailure: boundaryOptions.onFailure,
77
- requestLayer: (_request) => options.requestLayer(context)
78
- };
79
- response = await WebEffect.handle(options.runtime, context.req.raw, program, requestBoundaryOptions);
80
- }
88
+ response = await runManagedWith(options.executor, context.req.raw, program, boundaryOptions);
81
89
  if (!context.finalized || context.res !== response) context.res = response;
82
90
  } finally {
83
91
  options.states.delete(key);
@@ -99,31 +107,37 @@ const defaultFailure = (error, context) => {
99
107
  return context.json({ error: DEFAULT_FAILURE_MESSAGE }, 500);
100
108
  };
101
109
  //#endregion
102
- //#region src/hono/hono-effect.ts
103
- /** Run Effect Programs inside one Runtime execution per Hono request. */
104
- var HonoEffect = class HonoEffect {
105
- runtime;
110
+ //#region src/hono/builder.ts
111
+ /** Capture the active Runtime executor while a Hono application Layer is acquired. */
112
+ const makeOperation = (factory) => ({
113
+ *[Symbol.iterator]() {
114
+ const executor = yield* Runtime.executor();
115
+ return factory(eraseRuntimeExecutor(executor));
116
+ },
117
+ async *[Symbol.asyncIterator]() {
118
+ const executor = yield* Runtime.executor();
119
+ return factory(eraseRuntimeExecutor(executor));
120
+ }
121
+ });
122
+ /** Build Hono-native handlers whose Runtime capability is captured by the app Layer. */
123
+ var HonoEffectBuilder = class {
106
124
  states = /* @__PURE__ */ new WeakMap();
107
125
  onSuccess;
108
126
  onFailure;
109
127
  requestLayer;
110
- constructor(runtime, options) {
111
- this.runtime = runtime;
128
+ constructor(options) {
112
129
  this.onSuccess = options.onSuccess ?? defaultSuccess;
113
130
  this.onFailure = options.onFailure ?? defaultFailure;
114
131
  this.requestLayer = options.requestLayer;
115
132
  }
116
- static make(runtime, options) {
117
- return new HonoEffect(runtime, options ?? {});
118
- }
119
133
  middleware() {
120
- return makeRequestBoundary({
121
- runtime: this.runtime,
134
+ return makeOperation((executor) => makeRequestBoundary({
135
+ executor,
122
136
  states: this.states,
123
137
  requestLayer: this.requestLayer,
124
138
  onSuccess: this.onSuccess,
125
139
  onFailure: this.onFailure
126
- });
140
+ }));
127
141
  }
128
142
  handler(...args) {
129
143
  const last = args.at(-1);
@@ -131,9 +145,11 @@ var HonoEffect = class HonoEffect {
131
145
  const options = (hasOptions ? last : {}) ?? {};
132
146
  const bodyIndex = hasOptions ? args.length - 2 : args.length - 1;
133
147
  const makeProgram = args[bodyIndex];
134
- let handler = this.makeHandler(makeProgram, options);
135
- for (let index = bodyIndex - 1; index >= 0; index -= 1) handler = this.composeInputMiddleware(args[index], handler);
136
- return handler;
148
+ return makeOperation(() => {
149
+ let handler = this.makeHandler(makeProgram, options);
150
+ for (let index = bodyIndex - 1; index >= 0; index -= 1) handler = this.composeInputMiddleware(args[index], handler);
151
+ return handler;
152
+ });
137
153
  }
138
154
  gen(...args) {
139
155
  const last = args.at(-1);
@@ -141,22 +157,33 @@ var HonoEffect = class HonoEffect {
141
157
  const options = (hasOptions ? last : {}) ?? {};
142
158
  const bodyIndex = hasOptions ? args.length - 2 : args.length - 1;
143
159
  const body = args[bodyIndex];
144
- let handler = this.makeHandler((context) => {
145
- return Effect.fn(() => body(context));
146
- }, options);
147
- for (let index = bodyIndex - 1; index >= 0; index -= 1) handler = this.composeInputMiddleware(args[index], handler);
148
- return handler;
160
+ return makeOperation(() => {
161
+ let handler = this.makeHandler((context) => {
162
+ return Effect.fn(() => body(context));
163
+ }, options);
164
+ for (let index = bodyIndex - 1; index >= 0; index -= 1) handler = this.composeInputMiddleware(args[index], handler);
165
+ return handler;
166
+ });
167
+ }
168
+ stream(...args) {
169
+ const last = args.at(-1);
170
+ const hasOptions = args.length > 1 && (last === void 0 || typeof last !== "function");
171
+ const options = (hasOptions ? last : {}) ?? {};
172
+ const programIndex = hasOptions ? args.length - 2 : args.length - 1;
173
+ const streamProgram = args[programIndex];
174
+ return makeOperation(() => {
175
+ let handler = this.makeStreamHandler(streamProgram, options);
176
+ for (let index = programIndex - 1; index >= 0; index -= 1) handler = this.composeInputMiddleware(args[index], handler);
177
+ return handler;
178
+ });
149
179
  }
150
180
  guard(body) {
151
- return async (context, next) => {
181
+ return makeOperation(() => async (context, next) => {
152
182
  const state = this.getState(context);
153
183
  const result = await Effect.fn(() => body(context))();
154
184
  if (Result.isError(result)) return await this.handleFailure(state, result.error, context);
155
185
  await next();
156
- };
157
- }
158
- recordFailure(state, error) {
159
- recordRequestFailure(state, error);
186
+ });
160
187
  }
161
188
  makeHandler(makeProgram, options) {
162
189
  return async (context) => {
@@ -167,6 +194,14 @@ var HonoEffect = class HonoEffect {
167
194
  return await this.handleSuccess(result.value, options, context);
168
195
  };
169
196
  }
197
+ makeStreamHandler(streamProgram, options) {
198
+ return async (context) => {
199
+ const state = this.getState(context);
200
+ const result = await streamProgram();
201
+ if (Result.isError(result)) return await this.handleFailure(state, result.error, context);
202
+ recordRequestStream(state, result.value, options);
203
+ };
204
+ }
170
205
  async handleSuccess(value, options, context) {
171
206
  if (options.respond !== void 0) return assertResponse(await options.respond(value, context));
172
207
  const success = { value };
@@ -175,7 +210,7 @@ var HonoEffect = class HonoEffect {
175
210
  return assertResponse(await this.onSuccess(success, context));
176
211
  }
177
212
  async handleFailure(state, error, context) {
178
- this.recordFailure(state, error);
213
+ recordRequestFailure(state, error);
179
214
  return assertResponse(await this.onFailure(error, context));
180
215
  }
181
216
  composeInputMiddleware(inputMiddleware, handler) {
@@ -207,6 +242,37 @@ var HonoEffectBoundaryMissingError = class extends Error {
207
242
  }
208
243
  };
209
244
  //#endregion
245
+ //#region src/hono/hono-effect.ts
246
+ const defineLayerProperty = (token, layer) => {
247
+ Object.defineProperty(token, "layer", {
248
+ configurable: false,
249
+ enumerable: true,
250
+ value: layer,
251
+ writable: false
252
+ });
253
+ return token;
254
+ };
255
+ const makeHonoLayer = (service, options, factory) => {
256
+ return Layer.gen(service, () => {
257
+ return factory(new HonoEffectBuilder(options));
258
+ });
259
+ };
260
+ /** Layer-first Hono integration. The application owns the Runtime composition. */
261
+ var HonoEffect = class {
262
+ constructor() {}
263
+ /** Create a yieldable Hono application token and its Layer. */
264
+ static app(tag, options, factory) {
265
+ const literalTag = tag;
266
+ const token = Service()(literalTag);
267
+ const layer = makeHonoLayer(token, options, factory);
268
+ return defineLayerProperty(token, layer);
269
+ }
270
+ /** Provide an application-chosen Service token with a Hono Layer. */
271
+ static layer(service, options, factory) {
272
+ return makeHonoLayer(service, options, factory);
273
+ }
274
+ };
275
+ //#endregion
210
276
  export { HonoEffect, HonoEffectBoundaryMissingError };
211
277
 
212
278
  //# sourceMappingURL=hono.mjs.map
package/dist/hono.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hono.mjs","names":[],"sources":["../src/hono/request-boundary.ts","../src/hono/responses.ts","../src/hono/hono-effect.ts"],"sourcesContent":["import { Result } from 'better-result'\nimport { createMiddleware } from 'hono/factory'\nimport type { Env, MiddlewareHandler } from 'hono'\n\nimport { Effect } from '../effect'\nimport type { LayerInput } from '../layer/inference'\nimport { Runtime } from '../runtime'\nimport type { AnyService } from '../service'\nimport { WebEffect } from '../web'\nimport type { AnyRouteOptions, HonoContext, HonoEffectSuccess, ResponseLike } from './types'\n\n/* oxlint-disable anti-slop/no-unknown-parameters -- Hono handlers carry opaque Result values until the typed adapter callbacks consume them. */\n\ntype RequestOutcome =\n | {\n readonly kind: 'success'\n readonly value: unknown\n readonly options: AnyRouteOptions\n }\n | {\n readonly kind: 'failure'\n readonly cause: unknown\n }\n | {\n readonly kind: 'defect'\n readonly cause: unknown\n }\n\nexport type RequestState = {\n outcome?: RequestOutcome\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result failures are intentionally opaque until the Hono policy narrows them.\nexport const recordRequestFailure = (state: RequestState, cause: unknown): void => {\n state.outcome ??= { kind: 'failure', cause }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Route success values retain their public generic type only at the Hono handler boundary.\nexport const recordRequestSuccess = (\n state: RequestState,\n value: unknown,\n options: AnyRouteOptions\n): void => {\n state.outcome ??= { kind: 'success', value, options }\n}\n\nexport type RequestBoundaryOptions<\n Provided extends AnyService,\n RequestLayer extends LayerInput,\n Failure\n> = {\n readonly runtime: Runtime<Provided>\n readonly states: WeakMap<object, RequestState>\n readonly requestLayer?: ((context: HonoContext) => RequestLayer) | undefined\n readonly onSuccess: (result: HonoEffectSuccess<any>, context: HonoContext) => ResponseLike\n readonly onFailure: (error: Failure, context: HonoContext) => ResponseLike\n}\n\ntype BoundaryOptions<RequestLayer extends LayerInput> = {\n readonly requestLayer?: (request: Request) => RequestLayer\n readonly onSuccess: (result: { readonly value: unknown }) => ResponseLike\n readonly onFailure: (error: unknown) => ResponseLike\n}\n\nconst makeBoundaryOptions = <Provided extends AnyService, RequestLayer extends LayerInput, Failure>(\n options: RequestBoundaryOptions<Provided, RequestLayer, Failure>,\n state: RequestState,\n context: HonoContext\n): BoundaryOptions<RequestLayer> => {\n const boundaryOptions: BoundaryOptions<RequestLayer> = {\n onSuccess: ({ value }) => {\n if (context.finalized) {\n return context.res\n }\n\n const outcome = state.outcome\n\n if (outcome?.kind !== 'success') {\n // SAFETY: Values without a Hono route outcome are existing Web Responses; WebEffect validates them.\n return value as Response\n }\n\n if (outcome.options.respond !== undefined) {\n return outcome.options.respond(value, context)\n }\n\n const success: HonoEffectSuccess = { value }\n\n if (outcome.options.status !== undefined) {\n Object.assign(success, { status: outcome.options.status })\n }\n\n if (outcome.options.serialize !== undefined) {\n Object.assign(success, { serialize: outcome.options.serialize })\n }\n\n return options.onSuccess(success, context)\n },\n onFailure: (error) => {\n if (context.error !== undefined || context.finalized) {\n return context.res\n }\n\n if (state.outcome?.kind === 'defect') {\n // SAFETY: Hono has already converted its Error into context.res through app.onError; WebEffect validates it.\n return context.res\n }\n\n // SAFETY: HonoEffect validates the Program failure channel against Failure before this erased Web boundary.\n return options.onFailure(error as Failure, context)\n }\n }\n\n if (options.requestLayer !== undefined) {\n Object.assign(boundaryOptions, {\n requestLayer: (_request: Request) => options.requestLayer!(context)\n })\n }\n\n return boundaryOptions\n}\n\nconst selectBoundaryResult = (state: RequestState, context: HonoContext) => {\n const outcome = state.outcome\n\n if (outcome?.kind === 'failure') {\n return Result.err(outcome.cause)\n }\n\n if (context.error !== undefined) {\n state.outcome = { kind: 'defect', cause: context.error }\n return Result.err(context.error)\n }\n\n if (outcome?.kind === 'success') {\n return Result.ok(outcome.value)\n }\n\n return Result.ok(context.res)\n}\n\nexport const makeRequestBoundary = <\n Provided extends AnyService,\n RequestLayer extends LayerInput,\n Failure,\n E extends Env = Env,\n Path extends string = string\n>(\n options: RequestBoundaryOptions<Provided, RequestLayer, Failure>\n): MiddlewareHandler<E, Path> => {\n // SAFETY: createMiddleware preserves the Hono handler contract; only the generic Context is restored here.\n return createMiddleware(async (context, next) => {\n const key = context\n const existing = options.states.get(key)\n\n if (existing !== undefined) {\n await next()\n return\n }\n\n const state: RequestState = {}\n options.states.set(key, state)\n\n try {\n // oxlint-disable-next-line require-yield -- The bridge turns the complete Hono chain into one lazy WebEffect Program.\n const program = Effect.fn(async function* () {\n await next()\n return selectBoundaryResult(state, context)\n })\n const boundaryOptions = makeBoundaryOptions(options, state, context)\n let response: Response\n\n if (options.requestLayer === undefined) {\n response = await WebEffect.handle(options.runtime, context.req.raw, program, {\n onSuccess: boundaryOptions.onSuccess,\n onFailure: boundaryOptions.onFailure\n })\n } else {\n const requestBoundaryOptions = {\n onSuccess: boundaryOptions.onSuccess,\n onFailure: boundaryOptions.onFailure,\n requestLayer: (_request: Request) => options.requestLayer!(context)\n }\n // SAFETY: HonoEffect.make validates the concrete request Layer before this erased WebEffect dispatch.\n response = await WebEffect.handle(\n options.runtime,\n context.req.raw,\n program,\n requestBoundaryOptions as never\n )\n }\n\n if (!context.finalized || context.res !== response) {\n context.res = response\n }\n } finally {\n options.states.delete(key)\n }\n }) as MiddlewareHandler<E, Path>\n}\n","import type { HonoContext, HonoEffectSuccess } from './types'\n\nconst DEFAULT_FAILURE_MESSAGE = 'Internal Server Error'\n\nexport const defaultSuccess = (\n { value, status, serialize }: HonoEffectSuccess,\n context: HonoContext\n): Response => {\n if (value instanceof Response) {\n return value\n }\n\n const body = serialize === undefined ? value : serialize(value)\n\n if (body === undefined) {\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.body(null, (status ?? 204) as never)\n }\n\n if (status === undefined) {\n return context.json({ data: body })\n }\n\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.json({ data: body }, status as never)\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque at this HTTP boundary.\nexport const defaultFailure = (error: unknown, context: HonoContext): Response => {\n if (error instanceof Response) {\n return error\n }\n\n return context.json({ error: DEFAULT_FAILURE_MESSAGE }, 500)\n}\n","import { Result } from 'better-result'\nimport type { Context, Env, Handler, Input, MiddlewareHandler } from 'hono'\n\nimport { Effect } from '../effect'\nimport type { EffectSuccess, EffectYield, ProgramFromGenerator } from '../effect/types'\nimport { Runtime } from '../runtime'\nimport type { LayerInput } from '../layer/inference'\nimport type { AnyService } from '../service'\nimport {\n makeRequestBoundary,\n recordRequestFailure,\n recordRequestSuccess,\n type RequestState\n} from './request-boundary'\nimport { assertResponse } from '../web/responses'\nimport { defaultFailure, defaultSuccess } from './responses'\nimport type {\n AnyGeneratorBody,\n AnyHonoMiddleware,\n AnyProgram,\n AnyProgramFactory,\n AnyResult,\n AnyRouteOptions,\n AvailableServices,\n CompleteProgram,\n DefaultRequestLayer,\n GeneratorBody,\n GeneratorChecks,\n HonoContext,\n HonoEffectContext,\n HonoEffectOptions,\n HonoEffectRouteOptions,\n HonoEffectSuccess,\n HonoRequestLayerChecks,\n MiddlewareEnvironment,\n MiddlewareInputs,\n MiddlewarePath\n} from './types'\n\ntype HonoRouteArguments<Middlewares extends readonly AnyHonoMiddleware[], Body, Options> =\n | [...middlewares: Middlewares, body: Body]\n | [...middlewares: Middlewares, body: Body, options: Options | undefined]\n\ntype HonoInternalHandler = (\n context: HonoContext,\n next: () => Promise<void>\n) => Promise<Response | void>\n\ntype HonoHandlerFactory<\n ContextType extends object,\n Provided extends AnyService,\n Failure,\n ProgramFactory extends (context: ContextType) => AnyProgram\n> = ProgramFactory &\n ([ReturnType<ProgramFactory>] extends [\n CompleteProgram<Provided, ReturnType<ProgramFactory>, Failure>\n ]\n ? unknown\n : (context: ContextType) => CompleteProgram<Provided, ReturnType<ProgramFactory>, Failure>)\n\n/** Run Effect Programs inside one Runtime execution per Hono request. */\nexport class HonoEffect<\n Provided extends AnyService = any,\n Failure = unknown,\n RequestLayer extends LayerInput = DefaultRequestLayer\n> {\n readonly runtime: Runtime<Provided>\n\n private readonly states = new WeakMap<object, RequestState>()\n\n private readonly onSuccess: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onSuccess']>\n\n private readonly onFailure: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onFailure']>\n\n private readonly requestLayer: HonoEffectOptions<Failure, RequestLayer>['requestLayer']\n\n private constructor(\n runtime: Runtime<Provided>,\n options: HonoEffectOptions<Failure, RequestLayer>\n ) {\n this.runtime = runtime\n this.onSuccess = options.onSuccess ?? defaultSuccess\n this.onFailure = options.onFailure ?? defaultFailure\n this.requestLayer = options.requestLayer\n }\n\n static make<\n Provided extends AnyService,\n Failure = unknown,\n RequestLayer extends LayerInput = DefaultRequestLayer\n >(\n runtime: Runtime<Provided>,\n options?: HonoEffectOptions<Failure, RequestLayer> &\n HonoRequestLayerChecks<Provided, RequestLayer>\n ): HonoEffect<Provided, Failure, RequestLayer> {\n return new HonoEffect(runtime, options ?? {})\n }\n\n middleware<E extends Env = Env, Path extends string = string>(): MiddlewareHandler<E, Path> {\n return makeRequestBoundary<Provided, RequestLayer, Failure, E, Path>({\n runtime: this.runtime,\n states: this.states,\n requestLayer: this.requestLayer,\n onSuccess: this.onSuccess,\n onFailure: this.onFailure\n })\n }\n\n handler<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n Program extends AnyProgram = AnyProgram\n >(\n makeProgram: (\n context: Context<E, Path, InputType>\n ) => CompleteProgram<AvailableServices<Provided, RequestLayer>, Program, Failure>,\n options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, InputType>>\n ): Handler<E, Path, InputType, Promise<Response>>\n handler<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const ProgramFactory extends (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram = (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n HonoHandlerFactory<\n HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>,\n AvailableServices<Provided, RequestLayer>,\n Failure,\n ProgramFactory\n >,\n HonoEffectRouteOptions<\n EffectSuccess<ReturnType<ProgramFactory>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>\n handler(...args: unknown[]): Handler<any, any, any, Promise<Response>> {\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from function callbacks.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the program factory immediately before route options.\n const makeProgram = args[bodyIndex] as AnyProgramFactory\n let handler = this.makeHandler(makeProgram, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the program factory is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n // SAFETY: The public overload retains HonoEffect's Promise<Response> source contract; Hono also accepts the internal Promise<void> completion.\n return handler as Handler<any, any, any, Promise<Response>>\n }\n\n gen<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, InputType>\n >\n ): Handler<E, Path, InputType, Promise<Response>>\n gen<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n GeneratorBody<HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>,\n HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>\n gen(...args: unknown[]): Handler<any, any, any, Promise<Response>> {\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch distinguishes middleware from the generator body.\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from function callbacks.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the generator body immediately before route options.\n const body = args[bodyIndex] as AnyGeneratorBody\n\n let handler = this.makeHandler((context) => {\n // SAFETY: Effect.fn's runtime generator accepts both sync and async generators; the cast only joins its overloads.\n const program = Effect.fn(\n () => body(context) as AsyncGenerator<EffectYield, AnyResult, unknown>\n )\n\n // SAFETY: the public GeneratorChecks overload validates requirements before this erased boundary.\n return program as AnyProgram\n }, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the generator body is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n // SAFETY: The public overload retains HonoEffect's Promise<Response> source contract; Hono also accepts the internal Promise<void> completion.\n return handler as Handler<any, any, any, Promise<Response>>\n }\n\n guard<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<AvailableServices<Provided, RequestLayer>, Yield, Returned, Failure>\n ): MiddlewareHandler<E, Path> {\n return async (context, next) => {\n const state = this.getState(context)\n // SAFETY: Effect.fn accepts the sync or async generator supplied by the caller; this joins its overloads.\n const program = Effect.fn(() => body(context) as AsyncGenerator<Yield, Returned, unknown>)\n const result = await program()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n await next()\n }\n }\n\n private recordFailure(\n state: RequestState,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque until the WebEffect policy narrows them.\n error: unknown\n ): void {\n recordRequestFailure(state, error)\n }\n\n private makeHandler(\n makeProgram: (context: HonoContext) => AnyProgram,\n options: HonoEffectRouteOptions<any, any>\n ): HonoInternalHandler {\n return async (context) => {\n const state = this.getState(context)\n const result = await makeProgram(context)()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n recordRequestSuccess(state, result.value, options)\n return await this.handleSuccess(result.value, options, context)\n }\n }\n\n private async handleSuccess(\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Route values are intentionally opaque until the Hono success policy consumes them.\n value: unknown,\n options: AnyRouteOptions,\n context: HonoContext\n ): Promise<Response> {\n if (options.respond !== undefined) {\n return assertResponse(await options.respond(value, context))\n }\n\n const success: HonoEffectSuccess = { value }\n\n if (options.status !== undefined) {\n Object.assign(success, { status: options.status })\n }\n\n if (options.serialize !== undefined) {\n Object.assign(success, { serialize: options.serialize })\n }\n\n return assertResponse(await this.onSuccess(success, context))\n }\n\n private async handleFailure(\n state: RequestState,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque until the Hono failure policy consumes them.\n error: unknown,\n context: HonoContext\n ): Promise<Response> {\n this.recordFailure(state, error)\n // SAFETY: The public handler, generator, and guard constraints validate this error against Failure.\n return assertResponse(await this.onFailure(error as Failure, context))\n }\n\n private composeInputMiddleware(\n inputMiddleware: AnyHonoMiddleware,\n handler: HonoInternalHandler\n ): HonoInternalHandler {\n return async (context, next) => {\n let downstreamResponse: Response | undefined\n let nextCalled = false\n\n // Match Hono's compose guard: a middleware may advance the chain only once.\n const nextOnce = async (): Promise<void> => {\n if (nextCalled) {\n throw new Error('next() called multiple times')\n }\n\n nextCalled = true\n const response = await handler(context, next)\n\n if (response !== undefined) {\n downstreamResponse = response\n }\n }\n const middlewareResponse = await inputMiddleware(context, nextOnce)\n\n if (middlewareResponse instanceof Response) {\n return middlewareResponse\n }\n\n if (downstreamResponse !== undefined) {\n return downstreamResponse\n }\n\n if (context.finalized) {\n return context.res\n }\n }\n }\n\n private getState(context: HonoContext): RequestState {\n const state = this.states.get(context)\n\n if (state === undefined) {\n throw new HonoEffectBoundaryMissingError()\n }\n\n return state\n }\n}\n\nexport class HonoEffectBoundaryMissingError extends Error {\n constructor() {\n super('Register HonoEffect.middleware() before better-effect handlers')\n this.name = 'HonoEffectBoundaryMissingError'\n }\n}\n"],"mappings":";;;;;AAiCA,MAAa,wBAAwB,OAAqB,UAAyB;CACjF,MAAM,YAAY;EAAE,MAAM;EAAW;CAAM;AAC7C;AAGA,MAAa,wBACX,OACA,OACA,YACS;CACT,MAAM,YAAY;EAAE,MAAM;EAAW;EAAO;CAAQ;AACtD;AAoBA,MAAM,uBACJ,SACA,OACA,YACkC;CAClC,MAAM,kBAAiD;EACrD,YAAY,EAAE,YAAY;GACxB,IAAI,QAAQ,WACV,OAAO,QAAQ;GAGjB,MAAM,UAAU,MAAM;GAEtB,IAAI,SAAS,SAAS,WAEpB,OAAO;GAGT,IAAI,QAAQ,QAAQ,YAAY,KAAA,GAC9B,OAAO,QAAQ,QAAQ,QAAQ,OAAO,OAAO;GAG/C,MAAM,UAA6B,EAAE,MAAM;GAE3C,IAAI,QAAQ,QAAQ,WAAW,KAAA,GAC7B,OAAO,OAAO,SAAS,EAAE,QAAQ,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IACb,MAAM,WAAW,MAAM,QAAQ,SAAS,IAAI;IAE5C,IAAI,aAAa,KAAA,GACf,qBAAqB;GAEzB;GACA,MAAM,qBAAqB,MAAM,gBAAgB,SAAS,QAAQ;GAElE,IAAI,8BAA8B,UAChC,OAAO;GAGT,IAAI,uBAAuB,KAAA,GACzB,OAAO;GAGT,IAAI,QAAQ,WACV,OAAO,QAAQ;EAEnB;CACF;CAEA,SAAiB,SAAoC;EACnD,MAAM,QAAQ,KAAK,OAAO,IAAI,OAAO;EAErC,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,+BAA+B;EAG3C,OAAO;CACT;AACF;AAEA,IAAa,iCAAb,cAAoD,MAAM;CACxD,cAAc;EACZ,MAAM,gEAAgE;EACtE,KAAK,OAAO;CACd;AACF"}
1
+ {"version":3,"file":"hono.mjs","names":[],"sources":["../src/hono/request-boundary.ts","../src/hono/responses.ts","../src/hono/builder.ts","../src/hono/hono-effect.ts"],"sourcesContent":["import { Result } from 'better-result'\nimport { createMiddleware } from 'hono/factory'\nimport type { Env, MiddlewareHandler } from 'hono'\n\nimport { Effect } from '../effect'\nimport type { LayerInput } from '../layer/inference'\nimport type { RuntimeExecutor, RuntimeManagedExecution, RuntimeManagedPlan } from '../runtime'\nimport type { AnyService } from '../service'\nimport { makeManagedResponse, runManagedWith } from '../web/web-effect'\nimport { assertResponse } from '../web/responses'\nimport type {\n AnyRouteOptions,\n HonoContext,\n HonoEffectStreamOptions,\n HonoEffectSuccess,\n ResponseLike\n} from './types'\nimport type { WebEffectStream } from '../web/types'\n\n/* oxlint-disable anti-slop/no-unknown-parameters -- Hono handlers carry opaque Result values until the typed adapter callbacks consume them. */\n\ntype RequestOutcome =\n | {\n readonly kind: 'success'\n readonly value: unknown\n readonly options: AnyRouteOptions\n }\n | {\n readonly kind: 'failure'\n readonly cause: unknown\n }\n | {\n readonly kind: 'defect'\n readonly cause: unknown\n }\n | {\n readonly kind: 'stream'\n readonly descriptor: WebEffectStream\n readonly options: HonoEffectStreamOptions\n }\n\nexport type RequestState = {\n outcome?: RequestOutcome\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result failures are intentionally opaque until the Hono policy narrows them.\nexport const recordRequestFailure = (state: RequestState, cause: unknown): void => {\n state.outcome ??= { kind: 'failure', cause }\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Route success values retain their public generic type only at the Hono handler boundary.\nexport const recordRequestSuccess = (\n state: RequestState,\n value: unknown,\n options: AnyRouteOptions\n): void => {\n state.outcome ??= { kind: 'success', value, options }\n}\n\nexport const recordRequestStream = (\n state: RequestState,\n descriptor: WebEffectStream,\n options: HonoEffectStreamOptions\n): void => {\n state.outcome ??= { kind: 'stream', descriptor, options }\n}\n\nexport type RequestBoundaryOptions<RequestLayer extends LayerInput, Failure> = {\n readonly executor: RuntimeExecutor<AnyService>\n readonly states: WeakMap<object, RequestState>\n readonly requestLayer?: ((context: HonoContext) => RequestLayer) | undefined\n readonly onSuccess: (result: HonoEffectSuccess<any>, context: HonoContext) => ResponseLike\n readonly onFailure: (error: Failure, context: HonoContext) => ResponseLike\n}\n\ntype BoundaryOptions<RequestLayer extends LayerInput> = {\n readonly requestLayer?: (request: Request) => RequestLayer\n readonly onSuccess: (\n result: { readonly value: unknown },\n managed: Promise<RuntimeManagedExecution<unknown>>\n ) => RuntimeManagedPlan<Response> | PromiseLike<RuntimeManagedPlan<Response>>\n readonly onFailure: (error: unknown) => ResponseLike\n}\n\nconst responsePlan = (response: ResponseLike): RuntimeManagedPlan<Response> => {\n const readiness = Promise.resolve(response).then((value) => assertResponse(value))\n\n return {\n readiness,\n completion: readiness.then(() => undefined),\n cancel: async () => {}\n }\n}\n\nconst makeBoundaryOptions = <RequestLayer extends LayerInput, Failure>(\n options: RequestBoundaryOptions<RequestLayer, Failure>,\n state: RequestState,\n context: HonoContext\n): BoundaryOptions<RequestLayer> => {\n const boundaryOptions: BoundaryOptions<RequestLayer> = {\n onSuccess: ({ value }, managed) => {\n if (context.finalized) {\n return responsePlan(context.res)\n }\n\n const outcome = state.outcome\n\n if (outcome?.kind === 'stream') {\n return makeManagedResponse(outcome.descriptor, managed, outcome.options.unconsumedTimeoutMs)\n }\n\n if (outcome?.kind !== 'success') {\n // SAFETY: Values without a Hono route outcome are existing Web Responses; WebEffect validates them.\n return responsePlan(value as Response)\n }\n\n if (outcome.options.respond !== undefined) {\n return responsePlan(outcome.options.respond(value, context))\n }\n\n const success: HonoEffectSuccess = { value }\n\n if (outcome.options.status !== undefined) {\n Object.assign(success, { status: outcome.options.status })\n }\n\n if (outcome.options.serialize !== undefined) {\n Object.assign(success, { serialize: outcome.options.serialize })\n }\n\n return responsePlan(options.onSuccess(success, context))\n },\n onFailure: (error) => {\n if (context.error !== undefined || context.finalized) {\n return context.res\n }\n\n if (state.outcome?.kind === 'defect') {\n // SAFETY: Hono has already converted its Error into context.res through app.onError; WebEffect validates it.\n return context.res\n }\n\n // SAFETY: HonoEffect validates the Program failure channel against Failure before this erased Web boundary.\n return options.onFailure(error as Failure, context)\n }\n }\n\n if (options.requestLayer !== undefined) {\n Object.assign(boundaryOptions, {\n requestLayer: (_request: Request) => options.requestLayer!(context)\n })\n }\n\n return boundaryOptions\n}\n\nconst selectBoundaryResult = (state: RequestState, context: HonoContext) => {\n const outcome = state.outcome\n\n if (outcome?.kind === 'failure') {\n return Result.err(outcome.cause)\n }\n\n if (context.error !== undefined) {\n state.outcome = { kind: 'defect', cause: context.error }\n return Result.err(context.error)\n }\n\n if (outcome?.kind === 'success') {\n return Result.ok(outcome.value)\n }\n\n return Result.ok(context.res)\n}\n\nexport const makeRequestBoundary = <\n Failure,\n RequestLayer extends LayerInput,\n E extends Env = Env,\n Path extends string = string\n>(\n options: RequestBoundaryOptions<RequestLayer, Failure>\n): MiddlewareHandler<E, Path> => {\n // SAFETY: createMiddleware preserves the Hono handler contract; only the generic Context is restored here.\n return createMiddleware(async (context, next) => {\n const key = context\n const existing = options.states.get(key)\n\n if (existing !== undefined) {\n await next()\n return\n }\n\n const state: RequestState = {}\n options.states.set(key, state)\n\n try {\n // oxlint-disable-next-line require-yield -- The bridge turns the complete Hono chain into one lazy WebEffect Program.\n const program = Effect.fn(async function* () {\n await next()\n return selectBoundaryResult(state, context)\n })\n const boundaryOptions = makeBoundaryOptions(options, state, context)\n let response: Response\n\n // SAFETY: HonoEffect's public Layer boundary validates the request Layer before this erased WebEffect dispatch.\n response = await runManagedWith(\n options.executor,\n context.req.raw,\n program,\n boundaryOptions as never\n )\n\n if (!context.finalized || context.res !== response) {\n context.res = response\n }\n } finally {\n options.states.delete(key)\n }\n }) as MiddlewareHandler<E, Path>\n}\n","import type { HonoContext, HonoEffectSuccess } from './types'\n\nconst DEFAULT_FAILURE_MESSAGE = 'Internal Server Error'\n\nexport const defaultSuccess = (\n { value, status, serialize }: HonoEffectSuccess,\n context: HonoContext\n): Response => {\n if (value instanceof Response) {\n return value\n }\n\n const body = serialize === undefined ? value : serialize(value)\n\n if (body === undefined) {\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.body(null, (status ?? 204) as never)\n }\n\n if (status === undefined) {\n return context.json({ data: body })\n }\n\n // SAFETY: route status is intentionally configurable and Hono validates it at response construction.\n return context.json({ data: body }, status as never)\n}\n\n// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque at this HTTP boundary.\nexport const defaultFailure = (error: unknown, context: HonoContext): Response => {\n if (error instanceof Response) {\n return error\n }\n\n return context.json({ error: DEFAULT_FAILURE_MESSAGE }, 500)\n}\n","import { Result } from 'better-result'\nimport type { Context, Env, Handler, Input, MiddlewareHandler } from 'hono'\n\nimport { Effect } from '../effect'\nimport type {\n EffectSuccess,\n EffectYield,\n ProgramFromGenerator,\n ServiceRequirement\n} from '../effect/types'\nimport type { LayerInput, RequiredEnvironment } from '../layer/inference'\nimport { Runtime } from '../runtime'\nimport { eraseRuntimeExecutor, type RuntimeExecutor } from '../runtime/executor'\nimport type { AnyService } from '../service'\n\nimport {\n makeRequestBoundary,\n recordRequestFailure,\n recordRequestSuccess,\n recordRequestStream,\n type RequestState\n} from './request-boundary'\nimport { assertResponse } from '../web/responses'\nimport { defaultFailure, defaultSuccess } from './responses'\nimport type {\n AnyGeneratorBody,\n AnyHonoMiddleware,\n AnyProgram,\n AnyProgramFactory,\n AnyResult,\n AnyRouteOptions,\n CompleteHonoStreamProgram,\n CompleteProgram,\n GeneratorBody,\n GeneratorChecks,\n HonoContext,\n HonoEffectContext,\n HonoEffectOperation,\n HonoEffectOptions,\n HonoEffectRouteOptions,\n HonoEffectStreamOptions,\n HonoEffectSuccess,\n HonoProgramRequirements,\n MiddlewareEnvironment,\n MiddlewareInputs,\n MiddlewarePath\n} from './types'\n\ntype HonoRouteArguments<Middlewares extends readonly AnyHonoMiddleware[], Body, Options> =\n | [...middlewares: Middlewares, body: Body]\n | [...middlewares: Middlewares, body: Body, options: Options | undefined]\n\ntype HonoInternalHandler = (\n context: HonoContext,\n next: () => Promise<void>\n) => Promise<Response | void>\n\ntype HonoHandlerFactory<\n ContextType extends object,\n Failure,\n ProgramFactory extends (context: ContextType) => AnyProgram\n> = ProgramFactory &\n ([ReturnType<ProgramFactory>] extends [CompleteProgram<ReturnType<ProgramFactory>, Failure>]\n ? unknown\n : (context: ContextType) => CompleteProgram<ReturnType<ProgramFactory>, Failure>)\n\ntype OperationFactory<A> = (executor: RuntimeExecutor<AnyService>) => A\n\n/** Capture the active Runtime executor while a Hono application Layer is acquired. */\nconst makeOperation = <A, Requirements extends AnyService>(\n factory: OperationFactory<A>\n): HonoEffectOperation<A, Requirements> => ({\n *[Symbol.iterator](): Generator<ServiceRequirement<Requirements>, A, unknown> {\n const executor = yield* Runtime.executor<Requirements>()\n return factory(eraseRuntimeExecutor(executor))\n },\n async *[Symbol.asyncIterator](): AsyncGenerator<ServiceRequirement<Requirements>, A, unknown> {\n const executor = yield* Runtime.executor<Requirements>()\n return factory(eraseRuntimeExecutor(executor))\n }\n})\n\n/** Build Hono-native handlers whose Runtime capability is captured by the app Layer. */\nexport class HonoEffectBuilder<Failure, RequestLayer extends LayerInput> {\n private readonly states = new WeakMap<object, RequestState>()\n\n private readonly onSuccess: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onSuccess']>\n\n private readonly onFailure: NonNullable<HonoEffectOptions<Failure, RequestLayer>['onFailure']>\n\n private readonly requestLayer: HonoEffectOptions<Failure, RequestLayer>['requestLayer']\n\n constructor(options: HonoEffectOptions<Failure, RequestLayer>) {\n this.onSuccess = options.onSuccess ?? defaultSuccess\n this.onFailure = options.onFailure ?? defaultFailure\n this.requestLayer = options.requestLayer\n }\n\n middleware<E extends Env = Env, Path extends string = string>(): HonoEffectOperation<\n MiddlewareHandler<E, Path>,\n Extract<RequiredEnvironment<RequestLayer>, AnyService>\n > {\n return makeOperation((executor) =>\n makeRequestBoundary<Failure, RequestLayer, E, Path>({\n executor,\n states: this.states,\n requestLayer: this.requestLayer,\n onSuccess: this.onSuccess,\n onFailure: this.onFailure\n })\n )\n }\n\n handler<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n Program extends AnyProgram = AnyProgram\n >(\n makeProgram: (context: Context<E, Path, InputType>) => CompleteProgram<Program, Failure>,\n options?: HonoEffectRouteOptions<EffectSuccess<Program>, Context<E, Path, InputType>>\n ): HonoEffectOperation<\n Handler<E, Path, InputType, Promise<Response>>,\n HonoProgramRequirements<RequestLayer, Program>\n >\n handler<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const ProgramFactory extends (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram = (\n context: HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>\n ) => AnyProgram\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n HonoHandlerFactory<\n HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>,\n Failure,\n ProgramFactory\n >,\n HonoEffectRouteOptions<\n EffectSuccess<ReturnType<ProgramFactory>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): HonoEffectOperation<\n Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>,\n HonoProgramRequirements<RequestLayer, ReturnType<ProgramFactory>>\n >\n handler(...args: unknown[]): HonoEffectOperation<any, AnyService> {\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from function callbacks.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the program factory immediately before route options.\n const makeProgram = args[bodyIndex] as AnyProgramFactory\n\n return makeOperation(() => {\n let handler = this.makeHandler(makeProgram, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the program factory is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n // SAFETY: the public overload restores Hono's concrete handler channels after this erased implementation.\n return handler as Handler<any, any, any, Promise<Response>>\n })\n }\n\n gen<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<Yield, Returned, Failure>,\n options?: HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, InputType>\n >\n ): HonoEffectOperation<\n Handler<E, Path, InputType, Promise<Response>>,\n HonoProgramRequirements<RequestLayer, ProgramFromGenerator<Yield, Returned>>\n >\n gen<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n GeneratorBody<HonoEffectContext<E, Path, MiddlewareInputs<Middlewares>>, Yield, Returned> &\n GeneratorChecks<Yield, Returned, Failure>,\n HonoEffectRouteOptions<\n EffectSuccess<ProgramFromGenerator<Yield, Returned>>,\n Context<E, Path, MiddlewareInputs<Middlewares>>\n >\n >\n ): HonoEffectOperation<\n Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>,\n HonoProgramRequirements<RequestLayer, ProgramFromGenerator<Yield, Returned>>\n >\n gen(...args: unknown[]): HonoEffectOperation<any, AnyService> {\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch distinguishes middleware from the generator body.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to route options.\n const options = ((hasOptions ? last : {}) ?? {}) as AnyRouteOptions\n const bodyIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the generator body immediately before route options.\n const body = args[bodyIndex] as AnyGeneratorBody\n\n return makeOperation(() => {\n let handler = this.makeHandler((context) => {\n // SAFETY: Effect.fn's runtime generator accepts both sync and async generators; the cast only joins its overloads.\n const program = Effect.fn(\n () => body(context) as AsyncGenerator<EffectYield, AnyResult, unknown>\n )\n\n // SAFETY: the public GeneratorChecks overload validates failures before this erased boundary.\n return program as AnyProgram\n }, options)\n\n for (let index = bodyIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the generator body is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n // SAFETY: the public overload restores Hono's concrete handler channels after this erased implementation.\n return handler as Handler<any, any, any, Promise<Response>>\n })\n }\n\n stream<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n Program extends AnyProgram = AnyProgram\n >(\n program: CompleteHonoStreamProgram<Program, Failure>,\n options?: HonoEffectStreamOptions\n ): HonoEffectOperation<\n Handler<E, Path, InputType, Promise<Response>>,\n HonoProgramRequirements<RequestLayer, Program>\n >\n stream<\n const Middlewares extends readonly AnyHonoMiddleware[],\n E extends Env = MiddlewareEnvironment<Middlewares>,\n Path extends string = MiddlewarePath<Middlewares>,\n Program extends AnyProgram = AnyProgram\n >(\n ...args: HonoRouteArguments<\n Middlewares,\n CompleteHonoStreamProgram<Program, Failure>,\n HonoEffectStreamOptions\n >\n ): HonoEffectOperation<\n Handler<E, Path, MiddlewareInputs<Middlewares>, Promise<Response>>,\n HonoProgramRequirements<RequestLayer, Program>\n >\n stream(...args: unknown[]): HonoEffectOperation<any, AnyService> {\n const last = args.at(-1)\n // oxlint-disable-next-line anti-slop/no-runtime-typeof -- overload dispatch separates route options from the stream Program.\n const hasOptions = args.length > 1 && (last === undefined || typeof last !== 'function')\n // SAFETY: the overloads restrict the optional trailing argument to stream options.\n const options = ((hasOptions ? last : {}) ?? {}) as HonoEffectStreamOptions\n const programIndex = hasOptions ? args.length - 2 : args.length - 1\n // SAFETY: the overloads place the stream Program immediately before route options.\n const streamProgram = args[programIndex] as AnyProgram\n\n return makeOperation(() => {\n let handler = this.makeStreamHandler(streamProgram, options)\n\n for (let index = programIndex - 1; index >= 0; index -= 1) {\n // SAFETY: every argument before the stream Program is an input middleware by the overloads.\n handler = this.composeInputMiddleware(args[index] as AnyHonoMiddleware, handler)\n }\n\n // SAFETY: the public overload restores Hono's concrete handler channels after this erased boundary.\n return handler as Handler<any, any, any, Promise<Response>>\n })\n }\n\n guard<\n E extends Env = Env,\n Path extends string = string,\n InputType extends Input = Input,\n const Yield extends EffectYield = EffectYield,\n const Returned extends AnyResult = AnyResult\n >(\n body: GeneratorBody<Context<E, Path, InputType>, Yield, Returned> &\n GeneratorChecks<Yield, Returned, Failure>\n ): HonoEffectOperation<\n MiddlewareHandler<E, Path>,\n HonoProgramRequirements<RequestLayer, ProgramFromGenerator<Yield, Returned>>\n > {\n return makeOperation(() => async (context, next) => {\n const state = this.getState(context)\n // SAFETY: Effect.fn accepts the sync or async generator supplied by the caller; this joins its overloads.\n const program = Effect.fn(() => body(context) as AsyncGenerator<Yield, Returned, unknown>)\n const result = await program()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n await next()\n })\n }\n\n private makeHandler(\n makeProgram: (context: HonoContext) => AnyProgram,\n options: HonoEffectRouteOptions<any, any>\n ): HonoInternalHandler {\n return async (context) => {\n const state = this.getState(context)\n const result = await makeProgram(context)()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n recordRequestSuccess(state, result.value, options)\n return await this.handleSuccess(result.value, options, context)\n }\n }\n\n private makeStreamHandler(\n streamProgram: AnyProgram,\n options: HonoEffectStreamOptions\n ): HonoInternalHandler {\n return async (context) => {\n const state = this.getState(context)\n const result = await streamProgram()\n\n if (Result.isError(result)) {\n return await this.handleFailure(state, result.error, context)\n }\n\n recordRequestStream(state, result.value, options)\n }\n }\n\n private async handleSuccess(\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Route values are intentionally opaque until the Hono success policy consumes them.\n value: unknown,\n options: AnyRouteOptions,\n context: HonoContext\n ): Promise<Response> {\n if (options.respond !== undefined) {\n return assertResponse(await options.respond(value, context))\n }\n\n const success: HonoEffectSuccess = { value }\n\n if (options.status !== undefined) {\n Object.assign(success, { status: options.status })\n }\n\n if (options.serialize !== undefined) {\n Object.assign(success, { serialize: options.serialize })\n }\n\n return assertResponse(await this.onSuccess(success, context))\n }\n\n private async handleFailure(\n state: RequestState,\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Result errors are intentionally opaque until the Hono failure policy consumes them.\n error: unknown,\n context: HonoContext\n ): Promise<Response> {\n recordRequestFailure(state, error)\n // SAFETY: the public handler, generator, and guard constraints validate this error against Failure.\n return assertResponse(await this.onFailure(error as Failure, context))\n }\n\n private composeInputMiddleware(\n inputMiddleware: AnyHonoMiddleware,\n handler: HonoInternalHandler\n ): HonoInternalHandler {\n return async (context, next) => {\n let downstreamResponse: Response | undefined\n let nextCalled = false\n\n // Match Hono's compose guard: a middleware may advance the chain only once.\n const nextOnce = async (): Promise<void> => {\n if (nextCalled) {\n throw new Error('next() called multiple times')\n }\n\n nextCalled = true\n const response = await handler(context, next)\n\n if (response !== undefined) {\n downstreamResponse = response\n }\n }\n const middlewareResponse = await inputMiddleware(context, nextOnce)\n\n if (middlewareResponse instanceof Response) {\n return middlewareResponse\n }\n\n if (downstreamResponse !== undefined) {\n return downstreamResponse\n }\n\n if (context.finalized) {\n return context.res\n }\n }\n }\n\n private getState(context: HonoContext): RequestState {\n const state = this.states.get(context)\n\n if (state === undefined) {\n throw new HonoEffectBoundaryMissingError()\n }\n\n return state\n }\n}\n\nexport class HonoEffectBoundaryMissingError extends Error {\n constructor() {\n super('Register HonoEffect.middleware() before better-effect handlers')\n this.name = 'HonoEffectBoundaryMissingError'\n }\n}\n","import type { InferYieldRequirements, ServiceRequirement } from '../effect/types'\nimport { Layer } from '../layer'\nimport type { LayerInput, LayerResult } from '../layer/inference'\nimport { Service } from '../service'\nimport type {\n AnyService,\n ServiceContract,\n ServiceIdentity,\n ServiceRequirements,\n ServiceToken\n} from '../service'\n\nimport { HonoEffectBuilder } from './builder'\nimport type { DefaultRequestLayer, HonoEffectOptions, HonoRequestLayerChecks } from './types'\n\ntype HonoFactoryFor<Builder, Returned extends object> = (\n http: Builder\n) =>\n | Generator<ServiceRequirement<unknown>, Returned, unknown>\n | AsyncGenerator<ServiceRequirement<unknown>, Returned, unknown>\n\ntype HonoFactory<Builder> = HonoFactoryFor<Builder, object>\n\ntype HonoFactoryReturn<Factory> = Factory extends (...arguments_: any[]) => infer Iterator\n ? Iterator extends Generator<any, infer Returned, any>\n ? Returned extends object\n ? Returned\n : never\n : Iterator extends AsyncGenerator<any, infer Returned, any>\n ? Returned extends object\n ? Returned\n : never\n : never\n : never\n\ntype HonoFactoryYield<Factory> = Factory extends (...arguments_: any[]) => infer Iterator\n ? Iterator extends Generator<infer Yield, object, any>\n ? Yield\n : Iterator extends AsyncGenerator<infer Yield, object, any>\n ? Yield\n : never\n : never\n\n/** A Hono application Layer with inferred Service requirements. */\nexport type HonoEffectLayer<\n Service extends ServiceToken<any, any>,\n Yield extends ServiceRequirement<unknown>\n> = LayerResult<\n import('../layer/metadata').ProviderEntry<\n InstanceType<Service>,\n Extract<ServiceRequirements<InstanceType<Service>> | InferYieldRequirements<Yield>, AnyService>\n >\n>\n\nexport type HonoApplicationToken<\n Tag extends string,\n App extends object,\n Service extends ServiceToken<any, any>,\n Yield extends ServiceRequirement<unknown>\n> = ServiceToken<Tag, App & ServiceIdentity<Tag>> & {\n readonly layer: HonoEffectLayer<Service, Yield>\n}\n\ntype HonoLiteralTag<Tag extends string> = string extends Tag ? never : Tag extends '' ? never : Tag\n\nconst defineLayerProperty = <Token extends object, AppLayer extends LayerInput>(\n token: Token,\n layer: AppLayer\n): Token & { readonly layer: AppLayer } => {\n Object.defineProperty(token, 'layer', {\n configurable: false,\n enumerable: true,\n value: layer,\n writable: false\n })\n\n // SAFETY: The property was defined above as a non-writable value with the exact Layer type.\n return token as Token & { readonly layer: AppLayer }\n}\n\nconst makeHonoLayer = <\n Service extends ServiceToken<any, any>,\n Failure,\n RequestLayer extends LayerInput,\n Factory extends HonoFactory<HonoEffectBuilder<Failure, RequestLayer>>\n>(\n service: Service,\n options: HonoEffectOptions<Failure, RequestLayer>,\n factory: Factory\n): HonoEffectLayer<Service, Extract<HonoFactoryYield<Factory>, ServiceRequirement<unknown>>> => {\n const layer = Layer.gen(service, () => {\n const builder = new HonoEffectBuilder(options)\n\n // SAFETY: the public factory is constrained to a Hono Service contract; this erasure only adapts it to Layer.gen's runtime-erased provider storage.\n return factory(builder) as Generator<\n ServiceRequirement<unknown>,\n ServiceContract<InstanceType<Service>>,\n unknown\n >\n })\n\n // SAFETY: Layer.gen derives the same provider requirements from the factory's yield metadata.\n return layer as HonoEffectLayer<\n Service,\n Extract<HonoFactoryYield<Factory>, ServiceRequirement<unknown>>\n >\n}\n\n/** Layer-first Hono integration. The application owns the Runtime composition. */\nexport class HonoEffect {\n private constructor() {}\n\n /** Create a yieldable Hono application token and its Layer. */\n static app<\n const Tag extends string,\n RequestLayer extends LayerInput = DefaultRequestLayer,\n Failure = unknown,\n const Factory extends HonoFactory<HonoEffectBuilder<Failure, RequestLayer>> = HonoFactory<\n HonoEffectBuilder<Failure, RequestLayer>\n >\n >(\n tag: Tag & HonoLiteralTag<Tag>,\n options: HonoEffectOptions<Failure, RequestLayer> & HonoRequestLayerChecks<RequestLayer>,\n factory: Factory\n ): HonoApplicationToken<\n Tag,\n HonoFactoryReturn<Factory>,\n ServiceToken<Tag, HonoFactoryReturn<Factory> & ServiceIdentity<Tag>>,\n Extract<HonoFactoryYield<Factory>, ServiceRequirement<unknown>>\n > {\n const literalTag: HonoLiteralTag<Tag> = tag\n const tokenFactory = Service<HonoFactoryReturn<Factory> & ServiceIdentity<Tag>>()<Tag>\n // SAFETY: Service's factory returns the class-backed token; this assertion restores the precise application instance contract.\n // oxlint-disable-next-line anti-slop/no-chained-type-assertions -- the Service factory erases only the application instance contract.\n const token = tokenFactory(literalTag) as unknown as ServiceToken<\n Tag,\n HonoFactoryReturn<Factory> & ServiceIdentity<Tag>\n >\n const layer = makeHonoLayer(token, options, factory)\n\n // SAFETY: The token and Layer were created together above and the return type mirrors both exact values.\n return defineLayerProperty(token, layer) as HonoApplicationToken<\n Tag,\n HonoFactoryReturn<Factory>,\n ServiceToken<Tag, HonoFactoryReturn<Factory> & ServiceIdentity<Tag>>,\n Extract<HonoFactoryYield<Factory>, ServiceRequirement<unknown>>\n >\n }\n\n /** Provide an application-chosen Service token with a Hono Layer. */\n static layer<\n Service extends ServiceToken<any, any>,\n RequestLayer extends LayerInput = DefaultRequestLayer,\n Failure = unknown,\n const Returned extends ServiceContract<InstanceType<Service>> = ServiceContract<\n InstanceType<Service>\n >,\n const Factory extends HonoFactoryFor<HonoEffectBuilder<Failure, RequestLayer>, Returned> =\n HonoFactoryFor<HonoEffectBuilder<Failure, RequestLayer>, Returned>\n >(\n service: Service,\n options: HonoEffectOptions<Failure, RequestLayer> & HonoRequestLayerChecks<RequestLayer>,\n factory: Factory\n ): HonoEffectLayer<Service, Extract<HonoFactoryYield<Factory>, ServiceRequirement<unknown>>> {\n return makeHonoLayer(service, options, factory)\n }\n}\n"],"mappings":";;;;;;;;AA8CA,MAAa,wBAAwB,OAAqB,UAAyB;CACjF,MAAM,YAAY;EAAE,MAAM;EAAW;CAAM;AAC7C;AAGA,MAAa,wBACX,OACA,OACA,YACS;CACT,MAAM,YAAY;EAAE,MAAM;EAAW;EAAO;CAAQ;AACtD;AAEA,MAAa,uBACX,OACA,YACA,YACS;CACT,MAAM,YAAY;EAAE,MAAM;EAAU;EAAY;CAAQ;AAC1D;AAmBA,MAAM,gBAAgB,aAAyD;CAC7E,MAAM,YAAY,QAAQ,QAAQ,QAAQ,CAAC,CAAC,MAAM,UAAU,eAAe,KAAK,CAAC;CAEjF,OAAO;EACL;EACA,YAAY,UAAU,WAAW,KAAA,CAAS;EAC1C,QAAQ,YAAY,CAAC;CACvB;AACF;AAEA,MAAM,uBACJ,SACA,OACA,YACkC;CAClC,MAAM,kBAAiD;EACrD,YAAY,EAAE,SAAS,YAAY;GACjC,IAAI,QAAQ,WACV,OAAO,aAAa,QAAQ,GAAG;GAGjC,MAAM,UAAU,MAAM;GAEtB,IAAI,SAAS,SAAS,UACpB,OAAO,oBAAoB,QAAQ,YAAY,SAAS,QAAQ,QAAQ,mBAAmB;GAG7F,IAAI,SAAS,SAAS,WAEpB,OAAO,aAAa,KAAiB;GAGvC,IAAI,QAAQ,QAAQ,YAAY,KAAA,GAC9B,OAAO,aAAa,QAAQ,QAAQ,QAAQ,OAAO,OAAO,CAAC;GAG7D,MAAM,UAA6B,EAAE,MAAM;GAE3C,IAAI,QAAQ,QAAQ,WAAW,KAAA,GAC7B,OAAO,OAAO,SAAS,EAAE,QAAQ,QAAQ,QAAQ,OAAO,CAAC;GAG3D,IAAI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F,OAZc,MAAM,IAAI,eAAe;EAIrC,OAAO,QAAQ,IAHK,kBAAkB,OAGjB,CAAC;CAKxB,CAGW;AAIb;;AAGA,IAAa,aAAb,MAAwB;CACtB,cAAsB,CAAC;;CAGvB,OAAO,IAQL,KACA,SACA,SAMA;EACA,MAAM,aAAkC;EAIxC,MAAM,QAHe,QAGI,CAAC,CAAC,UAAU;EAIrC,MAAM,QAAQ,cAAc,OAAO,SAAS,OAAO;EAGnD,OAAO,oBAAoB,OAAO,KAAK;CAMzC;;CAGA,OAAO,MAUL,SACA,SACA,SAC2F;EAC3F,OAAO,cAAc,SAAS,SAAS,OAAO;CAChD;AACF"}
@@ -1,4 +1,4 @@
1
- import { A as ProgramFromGenerator, C as EffectError, D as EffectYield, E as EffectSuccess, M as AnyService, S as Effect$1, T as EffectRequirements, f as DisposableResource, h as ScopeOutcome, k as Program$1, p as MaybePromise, w as EffectFromGenerator, x as AnyEffect } from "./index-AiKM71-u.mjs";
1
+ import { At as EffectRequirements, B as forkScoped, Dt as Effect$1, Et as AnyEffect, Ft as ProgramFromGenerator, L as ScopedTask, Lt as AnyService, Mt as EffectYield, Ot as EffectError, Pt as Program$1, R as ScopedTaskExit, _t as DisposableResource, bt as ScopeOutcome, jt as EffectSuccess, kt as EffectFromGenerator, vt as MaybePromise } from "./layer-C2OaqTmB.mjs";
2
2
  import { Err, Result, UnhandledException } from "better-result";
3
3
  //#region src/effect/combinators.d.ts
4
4
  type EffectInput<A, E> = Result<A, E> | PromiseLike<Result<A, E>>;
@@ -360,6 +360,7 @@ type EffectNamespace = {
360
360
  readonly acquireReleaseResult: typeof acquireReleaseResult;
361
361
  readonly acquireDisposable: typeof acquireDisposable;
362
362
  readonly add: typeof add;
363
+ readonly forkScoped: typeof forkScoped;
363
364
  readonly map: typeof map$1;
364
365
  readonly mapError: typeof mapError$1;
365
366
  readonly andThen: typeof andThen$1;
@@ -394,7 +395,11 @@ declare namespace Effect {
394
395
  type Requirements<T> = EffectRequirements<T>;
395
396
  /** An Effect with erased success, error, and requirements. */
396
397
  type Any = AnyEffect;
398
+ /** A small handle for a Scope-owned child task. */
399
+ type Task<A, E> = ScopedTask<A, E>;
400
+ /** The terminal observation returned by a Scope-owned child task. */
401
+ type TaskExit<A, E> = ScopedTaskExit<A, E>;
397
402
  }
398
403
  //#endregion
399
404
  export { Program as n, ProgramAllOptions as r, Effect as t };
400
- //# sourceMappingURL=index-CCi07kUw.d.mts.map
405
+ //# sourceMappingURL=index-3Bkl-sxS.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CCi07kUw.d.mts","names":[],"sources":["../src/effect/combinators.ts","../src/effect/program-combinators.ts","../src/effect/effect.ts"],"mappings":";;;KAYK,YAAY,GAAG,KAAK,OAAW,GAAG,KAAK,YAAY,OAAW,GAAG;KAEjE,iBAAiB;KACjB,iBAAiB;KACjB,sBAAsB,YAAY;KAIlC,cAAc,OAAO,UAAU,cAAc,uBAAuB,QAAQ,UAAU;KAEtF,aAAa,OAAO,KAAK,SAAO,GAAG,YAAY,QAAQ,mBAAmB;KAE1E,kBAAkB,OAAO,MAAM,SAAO,cAAc,QAAQ,IAAI,mBAAmB;KAEnF,cAAc,OAAO,QAAQ,SAChC,cAAc,OACd,YAAY,SAAS,YAAY,OACjC,mBAAmB,SAAS,mBAAmB;KAG5C,cAAc,OAAO,QAAQ,cAAc,OAAO;KAElD,mBAAmB,OAAO,QAAQ,QAAQ,cAAc,OAAO;KAE/D,eAAa,GAAG;GAClB,OAAO,QAAQ,QAAQ,YAAY,UAAU,cAAc,OAAO,aAAa,OAAO;;KAGpF,oBAAkB,IAAI;GACxB,OAAO,QAAQ,QAAQ,iBAAiB,MAAM,cAAc,OAAO,kBAAkB,OAAO;;KAG1F,mBAAiB;GACnB,OAAO,QAAQ,QAAQ,iBAAiB,cAAc,OAAO;;KAG3D,sBAAsB,GAAG;GAC3B,OAAO,QAAQ,QAAQ,YAAY,UAAU,mBAAmB,OAAO;;KAGrE,aAAa,SAAS,SACzB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C,IAAI,UAAU,oBAC5B,UAAU,IACT,eAAe,WAAW,qBAAqB;;;;;;;KAY7C;WACM,YAAY;WACZ,WAAW;WACX,uBAAuB;WACvB,6BAA6B;WAC7B,0BAA0B;WAC1B,YAAY;WACZ,YAAY;WACZ,iBAAiB;WACjB,gBAAgB;WAChB,qBAAqB;WACrB,YAAY;WACZ,iBAAiB;WACjB,iBAAiB;WACjB,sBAAsB;WACtB,gBAAgB;WAChB,qBAAqB;WACrB,mBAAmB;WACnB,0BAA0B;WAC1B,gBAAgB;WAChB,qBAAqB;WACrB,gBAAgB;WAChB,WAAW;WACX,eAAe;WACf,cAAc;WACd,YAAY;WACZ,YAAY;;cAGV,QAAQ;;kBAwDI;;OAEX,QAAQ,GAAG,GAAG,UAAU,sBAAsB,YAAY,GAAG,GAAG;;OAGhE,QAAQ,KAAK,cAAc;;OAG3B,MAAM,KAAK,YAAY;;OAGvB,aAAa,KAAK,mBAAmB;;OAGrC,MAAM"}
1
+ {"version":3,"file":"index-3Bkl-sxS.d.mts","names":[],"sources":["../src/effect/combinators.ts","../src/effect/program-combinators.ts","../src/effect/effect.ts"],"mappings":";;;KAYK,YAAY,GAAG,KAAK,OAAW,GAAG,KAAK,YAAY,OAAW,GAAG;KAEjE,iBAAiB;KACjB,iBAAiB;KACjB,sBAAsB,YAAY;KAIlC,cAAc,OAAO,UAAU,cAAc,uBAAuB,QAAQ,UAAU;KAEtF,aAAa,OAAO,KAAK,SAAO,GAAG,YAAY,QAAQ,mBAAmB;KAE1E,kBAAkB,OAAO,MAAM,SAAO,cAAc,QAAQ,IAAI,mBAAmB;KAEnF,cAAc,OAAO,QAAQ,SAChC,cAAc,OACd,YAAY,SAAS,YAAY,OACjC,mBAAmB,SAAS,mBAAmB;KAG5C,cAAc,OAAO,QAAQ,cAAc,OAAO;KAElD,mBAAmB,OAAO,QAAQ,QAAQ,cAAc,OAAO;KAE/D,eAAa,GAAG;GAClB,OAAO,QAAQ,QAAQ,YAAY,UAAU,cAAc,O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,iBAAQ;WACR,gBAAO;;;;;;;;;;;;;;;;;iBAkBO,eAAe,GAC7B,eAAe,aAAa,IAC5B,UAAU,UAAU,GAAG,SAAS,iBAAiB,qBAChD,eAAe,WAAW,qBAAqB;;;;;;;;iBAiBlC,qBAAqB,GAAG,GACtC,eAAe,aAAa,OAAW,GAAG,KAC1C,UAAU,UAAU,GAAG,SAAS,iBAAiB,qBAChD,eAAe,WAAW,IAAI,qBAAqB;;;;;;;iBAiCtC,kBAAkB,UAAU,oBAC1C,eAAe,aAAa,KAC3B,eAAe,WAAW,qBAAqB;;;;;;;;;;;;;iBAkBlC,IAAI,UAAU,oBAC5B,UAAU,IACT,eAAe,WAAW,qBAAqB;;;;;;;KAY7C;WACM,YAAY;WACZ,WAAW;WACX,uBAAuB;WACvB,6BAA6B;WAC7B,0BAA0B;WAC1B,YAAY;WACZ,mBAAmB;WACnB,YAAY;WACZ,iBAAiB;WACjB,gBAAgB;WAChB,qBAAqB;WACrB,YAAY;WACZ,iBAAiB;WACjB,iBAAiB;WACjB,sBAAsB;WACtB,gBAAgB;WAChB,qBAAqB;WACrB,mBAAmB;WACnB,0BAA0B;WAC1B,gBAAgB;WAChB,qBAAqB;WACrB,gBAAgB;WAChB,WAAW;WACX,eAAe;WACf,cAAc;WACd,YAAY;WACZ,YAAY;;cAGV,QAAQ;;kBA0DI;;OAEX,QAAQ,GAAG,GAAG,UAAU,sBAAsB,YAAY,GAAG,GAAG;;OAGhE,QAAQ,KAAK,cAAc;;OAG3B,MAAM,KAAK,YAAY;;OAGvB,aAAa,KAAK,mBAAmB;;OAGrC,MAAM;;OAGN,KAAK,GAAG,KAAK,WAAW,GAAG;;OAG3B,SAAS,GAAG,KAAK,eAAe,GAAG"}
@@ -1,7 +1,7 @@
1
- import { H as ServiceToken, I as ServiceIdentity, b as Service, j as ServiceRequirement } from "./index-AiKM71-u.mjs";
2
- import { A as ProviderEntry, x as LayerResult } from "./outcome-DI8LPIQ4.mjs";
3
- import "./index-BodMy6rO.mjs";
4
- import "./current-request-CIU7AHhF.mjs";
1
+ import { It as ServiceRequirement, Kt as ServiceToken, Tt as Service, Vt as ServiceIdentity, ft as ProviderEntry, rt as LayerResult, t as Layer } from "./layer-C2OaqTmB.mjs";
2
+ import "./index-Cy1VsU-u.mjs";
3
+ import "./index-ClNndn2-.mjs";
4
+ import "./current-request-Dm-QQ3Xr.mjs";
5
5
  import { Err, StandardSchemaV1, UnhandledException } from "better-result";
6
6
  //#region src/standard-services/config.d.ts
7
7
  /** Raw string values supplied to a configuration schema. */
@@ -19,6 +19,9 @@ type ConfigFromEnvOptions<Schema extends StandardSchemaV1> = ConfigSourceOptions
19
19
  type ConfigOutput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferOutput<Schema>;
20
20
  /** The raw input type described by a Standard Schema. */
21
21
  type ConfigInput<Schema extends StandardSchemaV1> = StandardSchemaV1.InferInput<Schema>;
22
+ /** The string keys exposed by a schema's decoded configuration output. */
23
+ type ConfigOutputObject<Schema extends StandardSchemaV1> = ConfigOutput<Schema> extends object ? ConfigOutput<Schema> : Record<never, never>;
24
+ type ConfigKey<Schema extends StandardSchemaV1> = Extract<keyof ConfigOutputObject<Schema>, string>;
22
25
  /** A safe validation issue exposed by a configuration failure. */
23
26
  type ConfigIssue = StandardSchemaV1.Issue;
24
27
  declare const ConfigValidationError_base: import("better-result").TaggedErrorClass<"ConfigValidationError">;
@@ -41,19 +44,37 @@ type ConfigYield<Requirements extends Service.Any, Error> = Err<never, Error> |
41
44
  type ConfigValue<Schema extends StandardSchemaV1, Requirements extends Service.Any = never, Error = ConfigError> = {
42
45
  [Symbol.asyncIterator](): AsyncGenerator<ConfigYield<Requirements, Error>, ConfigOutput<Schema>, unknown>;
43
46
  };
47
+ type ConfigWithOutput<Schema extends StandardSchemaV1> = Omit<Config, 'get'> & {
48
+ get<Key extends ConfigKey<Schema>>(key: Key): ConfigOutputObject<Schema>[Key];
49
+ };
50
+ type SchemaConfigToken<Schema extends StandardSchemaV1> = Service.Class<'Config', ConfigWithOutput<Schema>> & Service.Token<'Config', ConfigWithOutput<Schema>> & {
51
+ readonly [Symbol.asyncIterator]: () => AsyncGenerator<ServiceRequirement<ConfigWithOutput<Schema>>, ConfigWithOutput<Schema>, unknown>;
52
+ } & {
53
+ readonly layer: (source: ConfigSource) => Layer<ConfigWithOutput<Schema>, never>;
54
+ readonly layerFromEnv: (options?: ConfigSourceOptions) => Layer<ConfigWithOutput<Schema>, never>;
55
+ };
44
56
  declare const Config_base: (abstract new () => ServiceIdentity<"Config">) & {
45
57
  readonly name: string;
46
58
  readonly serviceTag: "Config";
47
59
  } & {
48
60
  readonly of: Service.FactoryOf<Config, "Config">;
61
+ readonly [Symbol.iterator]: (this: ServiceToken<"Config", Config & ServiceIdentity<"Config">>) => Generator<ServiceRequirement<Config>, Config, unknown>;
49
62
  readonly [Symbol.asyncIterator]: (this: ServiceToken<"Config", Config & ServiceIdentity<"Config">>) => AsyncGenerator<ServiceRequirement<Config>, Config, unknown>;
50
63
  };
51
64
  /** Host-backed raw configuration source and provider token. */
52
65
  declare class Config extends Config_base {
53
66
  readonly source: ConfigSource;
67
+ private values;
54
68
  constructor(source: ConfigSource);
55
- /** Read one raw value from the configured source. */
69
+ /** Read one value from the configured source or decoded schema output. */
56
70
  get(key: string): string | undefined;
71
+ /**
72
+ * Create a schema-bound Config token with a typed `get` accessor.
73
+ *
74
+ * The token validates its source while its Layer is acquired. The accessor then
75
+ * reads the decoded schema output, so its return type follows the selected key.
76
+ */
77
+ static withSchema<Schema extends StandardSchemaV1>(schema: Schema): SchemaConfigToken<Schema>;
57
78
  /** Create a provider from an already-loaded source. */
58
79
  static layer(source: ConfigSource): LayerResult<ProviderEntry<Config, never>>;
59
80
  /** Create a provider whose source is loaded from dotenv and the host environment. */
@@ -83,6 +104,7 @@ declare const IdGenerator_base: (abstract new () => ServiceIdentity<"IdGenerator
83
104
  readonly serviceTag: "IdGenerator";
84
105
  } & {
85
106
  readonly of: Service.FactoryOf<IdGenerator, "IdGenerator">;
107
+ readonly [Symbol.iterator]: (this: ServiceToken<"IdGenerator", IdGenerator & ServiceIdentity<"IdGenerator">>) => Generator<ServiceRequirement<IdGenerator>, IdGenerator, unknown>;
86
108
  readonly [Symbol.asyncIterator]: (this: ServiceToken<"IdGenerator", IdGenerator & ServiceIdentity<"IdGenerator">>) => AsyncGenerator<ServiceRequirement<IdGenerator>, IdGenerator, unknown>;
87
109
  };
88
110
  /** Host-backed UUID string ID service. */
@@ -126,6 +148,7 @@ declare const Clock_base: (abstract new () => ServiceIdentity<"Clock">) & {
126
148
  readonly serviceTag: "Clock";
127
149
  } & {
128
150
  readonly of: Service.FactoryOf<Clock, "Clock">;
151
+ readonly [Symbol.iterator]: (this: ServiceToken<"Clock", Clock & ServiceIdentity<"Clock">>) => Generator<ServiceRequirement<Clock>, Clock, unknown>;
129
152
  readonly [Symbol.asyncIterator]: (this: ServiceToken<"Clock", Clock & ServiceIdentity<"Clock">>) => AsyncGenerator<ServiceRequirement<Clock>, Clock, unknown>;
130
153
  };
131
154
  /** Host-backed time and waiting service. */
@@ -168,6 +191,7 @@ declare const Random_base: (abstract new () => ServiceIdentity<"Random">) & {
168
191
  readonly serviceTag: "Random";
169
192
  } & {
170
193
  readonly of: Service.FactoryOf<Random, "Random">;
194
+ readonly [Symbol.iterator]: (this: ServiceToken<"Random", Random & ServiceIdentity<"Random">>) => Generator<ServiceRequirement<Random>, Random, unknown>;
171
195
  readonly [Symbol.asyncIterator]: (this: ServiceToken<"Random", Random & ServiceIdentity<"Random">>) => AsyncGenerator<ServiceRequirement<Random>, Random, unknown>;
172
196
  };
173
197
  /** Host-backed pseudo-random number service. */
@@ -200,6 +224,7 @@ declare const Logger_base: (abstract new () => ServiceIdentity<"Logger">) & {
200
224
  readonly serviceTag: "Logger";
201
225
  } & {
202
226
  readonly of: Service.FactoryOf<Logger, "Logger">;
227
+ readonly [Symbol.iterator]: (this: ServiceToken<"Logger", Logger & ServiceIdentity<"Logger">>) => Generator<ServiceRequirement<Logger>, Logger, unknown>;
203
228
  readonly [Symbol.asyncIterator]: (this: ServiceToken<"Logger", Logger & ServiceIdentity<"Logger">>) => AsyncGenerator<ServiceRequirement<Logger>, Logger, unknown>;
204
229
  };
205
230
  /** Structured host logger bridge. */
@@ -231,5 +256,5 @@ declare class LoggerTest implements Service.Contract<Logger> {
231
256
  }
232
257
  declare const LoggerTestLayer: () => LayerResult<ProviderEntry<Logger, never>>;
233
258
  //#endregion
234
- export { ConfigOutput as A, IdGeneratorUnavailableError as C, ConfigInput as D, ConfigFromEnvOptions as E, ConfigValue as F, StandardSchemaV1 as I, ConfigSourceError as M, ConfigSourceOptions as N, ConfigIssue as O, ConfigValidationError as P, IdGeneratorTestLayer as S, ConfigError as T, RandomSeededLayer as _, ClockTestLayer as a, IdGeneratorLive as b, LoggerData as c, LoggerLive as d, LoggerTest as f, RandomSeeded as g, RandomLive as h, ClockTest as i, ConfigSource as j, ConfigLive as k, LoggerEvent as l, Random as m, ClockLive as n, ClockTestRunAllOptions as o, LoggerTestLayer as p, ClockSleepOptions as r, Logger as s, Clock as t, LoggerLevel as u, IdGenerator as v, Config as w, IdGeneratorTest as x, IdGeneratorExhaustedError as y };
235
- //# sourceMappingURL=index-cXgyMa0v.d.mts.map
259
+ export { ConfigLive as A, IdGeneratorUnavailableError as C, ConfigInput as D, ConfigFromEnvOptions as E, ConfigValidationError as F, ConfigValue as I, StandardSchemaV1 as L, ConfigSource as M, ConfigSourceError as N, ConfigIssue as O, ConfigSourceOptions as P, IdGeneratorTestLayer as S, ConfigError as T, RandomSeededLayer as _, ClockTestLayer as a, IdGeneratorLive as b, LoggerData as c, LoggerLive as d, LoggerTest as f, RandomSeeded as g, RandomLive as h, ClockTest as i, ConfigOutput as j, ConfigKey as k, LoggerEvent as l, Random as m, ClockLive as n, ClockTestRunAllOptions as o, LoggerTestLayer as p, ClockSleepOptions as r, Logger as s, Clock as t, LoggerLevel as u, IdGenerator as v, Config as w, IdGeneratorTest as x, IdGeneratorExhaustedError as y };
260
+ //# sourceMappingURL=index-C2ed9Ilq.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-C2ed9Ilq.d.mts","names":[],"sources":["../src/standard-services/config.ts","../src/standard-services/id-generator.ts","../src/standard-services/index.ts"],"mappings":";;;;;;;KAgBY,eAAe,SAAS;;KAGxB;WACD;WACA,YAAY;;;KAIX,qBAAqB,eAAe,oBAAoB;WACzD,QAAQ;;;KAIP,aAAa,eAAe,oBAAoB,iBAAiB,YAAY;;KAG7E,YAAY,eAAe,oBAAoB,iBAAiB,WAAW;;KAGlF,mBAAmB,eAAe,oBACrC,aAAa,yBAAyB,aAAa,UAAU;KAEnD,UAAU,eAAe,oBAAoB,cACjD,mBAAmB;;KAKf,cAAc,iBAAiB;;;cAG9B,8BAA8B;WAChC,QAAQ,cAAc;WACtB;;;;cAIE,0BAA0B;WAC5B;WACA;WACA;;;KAIC,cAAc,wBAAwB,oBAAoB;KAEjE,YAAY,qBAAqB,QAAQ,KAAK,SAC/C,WAAW,SACX,mBAAmB;;KAGX,YACV,eAAe,kBACf,qBAAqB,QAAQ,aAC7B,QAAQ;GAEP,OAAO,kBAAkB,eACxB,YAAY,cAAc,QAC1B,aAAa;;KAsNZ,iBAAiB,eAAe,oBAAoB,KAAK;EAC5D,IAAI,YAAY,UAAU,SAAS,KAAK,MAAM,mBAAmB,QAAQ;;KAGtE,kBAAkB,eAAe,oBAAoB,QAAQ,gBAEhE,iBAAiB,WAEjB,QAAQ,gBAAgB,iBAAiB;YAC7B,OAAO,sBAAsB,eACrC,mBAAmB,iBAAiB,UACpC,iBAAiB;;WAIV,QAAQ,QAAQ,iBAAiB,MAAM,iBAAiB;WACxD,eAAe,UAAU,wBAAwB,MAAM,iBAAiB;;;;;;;;;;;cAIxE,eAAe;WAGL,QAAQ;UAFrB;EAER,YAAqB,QAAQ;;EAM7B,IAAI;;;;;;;SAYG,WAAW,eAAe,kBAAkB,QAAQ,SAAS,kBAAkB;;SAiD/E,MAAM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