@fluojs/runtime 1.1.8 → 3.0.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 (130) hide show
  1. package/README.ko.md +292 -21
  2. package/README.md +292 -21
  3. package/dist/abort.d.ts +6 -1
  4. package/dist/abort.d.ts.map +1 -1
  5. package/dist/abort.js +18 -2
  6. package/dist/adapters/internal-request-response-factory.d.ts +1 -1
  7. package/dist/adapters/internal-request-response-factory.d.ts.map +1 -1
  8. package/dist/adapters/internal-request-response-factory.js +1 -1
  9. package/dist/adapters/request-response-factory.d.ts +20 -1
  10. package/dist/adapters/request-response-factory.d.ts.map +1 -1
  11. package/dist/adapters/request-response-factory.js +75 -22
  12. package/dist/bootstrap.d.ts +3 -9
  13. package/dist/bootstrap.d.ts.map +1 -1
  14. package/dist/bootstrap.js +181 -76
  15. package/dist/devtools/contracts.d.ts +3 -135
  16. package/dist/devtools/contracts.d.ts.map +1 -1
  17. package/dist/devtools/index.d.ts +2 -3
  18. package/dist/devtools/index.d.ts.map +1 -1
  19. package/dist/devtools/index.js +1 -2
  20. package/dist/devtools/snapshot.d.ts +1 -1
  21. package/dist/devtools/snapshot.d.ts.map +1 -1
  22. package/dist/devtools/snapshot.js +18 -17
  23. package/dist/devtools/studio-request-observer.d.ts +14 -0
  24. package/dist/devtools/studio-request-observer.d.ts.map +1 -0
  25. package/dist/devtools/studio-request-observer.js +112 -0
  26. package/dist/devtools/studio-runtime-config.d.ts +25 -0
  27. package/dist/devtools/studio-runtime-config.d.ts.map +1 -0
  28. package/dist/devtools/studio-runtime-config.js +59 -0
  29. package/dist/devtools/studio-runtime.d.ts +12 -18
  30. package/dist/devtools/studio-runtime.d.ts.map +1 -1
  31. package/dist/devtools/studio-runtime.js +25 -169
  32. package/dist/errors.d.ts +26 -0
  33. package/dist/errors.d.ts.map +1 -1
  34. package/dist/errors.js +38 -0
  35. package/dist/health/health.d.ts +18 -4
  36. package/dist/health/health.d.ts.map +1 -1
  37. package/dist/health/health.js +5 -2
  38. package/dist/http-adapter-shared.d.ts +1 -1
  39. package/dist/http-adapter-shared.d.ts.map +1 -1
  40. package/dist/http-adapter-shared.js +1 -1
  41. package/dist/index.d.ts +6 -3
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +4 -1
  44. package/dist/internal/route-inspection-metadata.d.ts +30 -0
  45. package/dist/internal/route-inspection-metadata.d.ts.map +1 -0
  46. package/dist/internal/route-inspection-metadata.js +68 -0
  47. package/dist/internal.d.ts +6 -1
  48. package/dist/internal.d.ts.map +1 -1
  49. package/dist/internal.js +4 -1
  50. package/dist/module-definition.d.ts +10 -0
  51. package/dist/module-definition.d.ts.map +1 -0
  52. package/dist/module-definition.js +12 -0
  53. package/dist/module-graph.d.ts +42 -1
  54. package/dist/module-graph.d.ts.map +1 -1
  55. package/dist/module-graph.js +112 -16
  56. package/dist/multipart.d.ts +68 -4
  57. package/dist/multipart.d.ts.map +1 -1
  58. package/dist/multipart.js +666 -103
  59. package/dist/platform-component-registry.d.ts +9 -0
  60. package/dist/platform-component-registry.d.ts.map +1 -0
  61. package/dist/platform-component-registry.js +70 -0
  62. package/dist/platform-diagnostic-retention.d.ts +13 -0
  63. package/dist/platform-diagnostic-retention.d.ts.map +1 -0
  64. package/dist/platform-diagnostic-retention.js +43 -0
  65. package/dist/platform-shell-probe-reports.d.ts +8 -0
  66. package/dist/platform-shell-probe-reports.d.ts.map +1 -0
  67. package/dist/platform-shell-probe-reports.js +95 -0
  68. package/dist/platform-shell-probes.d.ts +16 -0
  69. package/dist/platform-shell-probes.d.ts.map +1 -0
  70. package/dist/platform-shell-probes.js +141 -0
  71. package/dist/platform-shell.d.ts +7 -13
  72. package/dist/platform-shell.d.ts.map +1 -1
  73. package/dist/platform-shell.js +58 -310
  74. package/dist/retryable-shutdown.d.ts +7 -0
  75. package/dist/retryable-shutdown.d.ts.map +1 -0
  76. package/dist/retryable-shutdown.js +20 -0
  77. package/dist/route-inspection.d.ts +56 -0
  78. package/dist/route-inspection.d.ts.map +1 -0
  79. package/dist/route-inspection.js +80 -0
  80. package/dist/tokens.d.ts +6 -4
  81. package/dist/tokens.d.ts.map +1 -1
  82. package/dist/tokens.js +5 -0
  83. package/dist/types.d.ts +53 -8
  84. package/dist/types.d.ts.map +1 -1
  85. package/dist/web.d.ts +22 -9
  86. package/dist/web.d.ts.map +1 -1
  87. package/dist/web.js +80 -34
  88. package/package.json +13 -26
  89. package/dist/internal-node.d.ts +0 -2
  90. package/dist/internal-node.d.ts.map +0 -1
  91. package/dist/internal-node.js +0 -1
  92. package/dist/logging/json-logger.d.ts +0 -8
  93. package/dist/logging/json-logger.d.ts.map +0 -1
  94. package/dist/logging/json-logger.js +0 -45
  95. package/dist/logging/logger.d.ts +0 -37
  96. package/dist/logging/logger.d.ts.map +0 -1
  97. package/dist/logging/logger.js +0 -103
  98. package/dist/node/internal-node-compression.d.ts +0 -22
  99. package/dist/node/internal-node-compression.d.ts.map +0 -1
  100. package/dist/node/internal-node-compression.js +0 -84
  101. package/dist/node/internal-node-request.d.ts +0 -162
  102. package/dist/node/internal-node-request.d.ts.map +0 -1
  103. package/dist/node/internal-node-request.js +0 -475
  104. package/dist/node/internal-node-response.d.ts +0 -28
  105. package/dist/node/internal-node-response.d.ts.map +0 -1
  106. package/dist/node/internal-node-response.js +0 -205
  107. package/dist/node/internal-node-shutdown.d.ts +0 -34
  108. package/dist/node/internal-node-shutdown.d.ts.map +0 -1
  109. package/dist/node/internal-node-shutdown.js +0 -83
  110. package/dist/node/internal-node.d.ts +0 -117
  111. package/dist/node/internal-node.d.ts.map +0 -1
  112. package/dist/node/internal-node.js +0 -283
  113. package/dist/node/node-compression.d.ts +0 -2
  114. package/dist/node/node-compression.d.ts.map +0 -1
  115. package/dist/node/node-compression.js +0 -1
  116. package/dist/node/node-request.d.ts +0 -2
  117. package/dist/node/node-request.d.ts.map +0 -1
  118. package/dist/node/node-request.js +0 -1
  119. package/dist/node/node-response.d.ts +0 -2
  120. package/dist/node/node-response.d.ts.map +0 -1
  121. package/dist/node/node-response.js +0 -1
  122. package/dist/node/node-shutdown.d.ts +0 -2
  123. package/dist/node/node-shutdown.d.ts.map +0 -1
  124. package/dist/node/node-shutdown.js +0 -1
  125. package/dist/node/node.d.ts +0 -2
  126. package/dist/node/node.d.ts.map +0 -1
  127. package/dist/node/node.js +0 -1
  128. package/dist/node.d.ts +0 -5
  129. package/dist/node.d.ts.map +0 -1
  130. package/dist/node.js +0 -3
package/dist/types.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type { Constructor, MaybePromise, Token } from '@fluojs/core';
2
2
  import type { Container, Provider } from '@fluojs/di';
3
- import type { ConverterLike, Dispatcher, FrameworkRequest, FrameworkResponse, HttpApplicationAdapter, InterceptorLike, MiddlewareLike, RequestObserverLike, VersioningOptions } from '@fluojs/http';
3
+ import type { ConditionalRequestOptions, ContentNegotiationOptions, ConverterLike, Dispatcher, FrameworkRequest, FrameworkResponse, HttpApplicationAdapter, HttpErrorRepresentationOptions, InterceptorLike, MiddlewareLike, RequestObserverLike, VersioningOptions } from '@fluojs/http/portable';
4
+ import type { StudioDevtoolsRuntime } from './devtools/studio-runtime.js';
4
5
  import type { BootstrapTimingDiagnostics } from './health/diagnostics.js';
6
+ import type { ModuleGraphCompileCache } from './module-graph.js';
5
7
  import type { PlatformComponentInput } from './platform-contract.js';
6
8
  /** Module class accepted by bootstrap and module-graph compilation helpers. */
7
9
  export type ModuleType = Constructor & {
@@ -30,9 +32,10 @@ export interface BootstrapModuleOptions {
30
32
  * The cache is disabled by default. When enabled, successful graph compiles are
31
33
  * keyed by root module identity, runtime provider inputs, validation tokens,
32
34
  * module replacement pairs, core metadata write versions, and the runtime compile algorithm version.
33
- * Failed compilations are never cached.
35
+ * Failed compilations are never cached. Pass a {@link ModuleGraphCompileCache}
36
+ * to bound and dispose cache retention under the caller's ownership.
34
37
  */
35
- moduleGraphCache?: boolean;
38
+ moduleGraphCache?: boolean | ModuleGraphCompileCache;
36
39
  /**
37
40
  * Low-level testing seam for compiling a module with replacement metadata while
38
41
  * preserving the original logical module identity in the compiled graph.
@@ -88,8 +91,8 @@ export interface ApplicationLogger {
88
91
  log(message: string, context?: string): void;
89
92
  warn(message: string, context?: string): void;
90
93
  }
91
- /** Registers runtime-owned cleanup callbacks that must run during bootstrap failure or shutdown. */
92
- export type RuntimeCleanupRegistration = (cleanup: () => void) => () => void;
94
+ /** Registers runtime-owned cleanup callbacks that must settle during bootstrap failure or shutdown. */
95
+ export type RuntimeCleanupRegistration = (cleanup: () => MaybePromise<void>) => () => void;
93
96
  /** Runtime-visible application states for HTTP and microservice shells. */
94
97
  export type ApplicationState = 'bootstrapped' | 'ready' | 'closed';
95
98
  /**
@@ -109,12 +112,33 @@ export interface ExceptionFilterHandler {
109
112
  /** High-level bootstrap options for creating an HTTP application shell. */
110
113
  export interface BootstrapApplicationOptions {
111
114
  adapter?: HttpApplicationAdapter;
115
+ /**
116
+ * Host-owned Studio bridge used to publish live bootstrap and request events.
117
+ *
118
+ * When omitted, runtime preserves the CLI-injected Node.js bridge behavior.
119
+ * Platform integrations should create this bridge from `@fluojs/runtime/devtools`
120
+ * instead of mutating the undocumented Studio process-global.
121
+ */
122
+ studioDevtools?: StudioDevtoolsRuntime;
123
+ /** Dispatcher-owned policy for HTTP validators and conditional requests. */
124
+ conditionalRequest?: ConditionalRequestOptions;
125
+ /** Application-owned HTML provider for HTTP-classified error and not-found outcomes. */
126
+ errorRepresentation?: HttpErrorRepresentationOptions;
127
+ /**
128
+ * Response formatter selection owned by the HTTP dispatcher.
129
+ *
130
+ * The runtime forwards this contract unchanged; `@Produces(...)`, `Accept`,
131
+ * success response headers, and 406 handling remain HTTP-owned.
132
+ */
133
+ contentNegotiation?: ContentNegotiationOptions;
112
134
  /**
113
135
  * Enables the opt-in process-local module graph compile result cache for this
114
136
  * bootstrap. The default is `false`, so each bootstrap compiles a fresh graph
115
- * unless callers explicitly request cache reuse.
137
+ * unless callers explicitly request cache reuse. Pass a
138
+ * {@link ModuleGraphCompileCache} to retain a bounded, caller-owned cache that
139
+ * can be disposed with its application lifecycle.
116
140
  */
117
- moduleGraphCache?: boolean;
141
+ moduleGraphCache?: boolean | ModuleGraphCompileCache;
118
142
  /**
119
143
  * Policy for duplicate provider tokens across modules.
120
144
  *
@@ -151,12 +175,27 @@ export interface CreateApplicationContextOptions extends Omit<BootstrapApplicati
151
175
  }
152
176
  /** Runtime transport contract used by microservice application shells. */
153
177
  export interface MicroserviceRuntime {
154
- /** Release transport resources owned by the microservice runtime during shutdown. */
178
+ /**
179
+ * Releases transport resources owned by the microservice runtime during shutdown.
180
+ *
181
+ * The owning {@link MicroserviceApplication} invokes this collaborator at most
182
+ * once and preserves its terminal success or failure for every later shell close.
183
+ */
155
184
  close?(signal?: string): MaybePromise<void>;
156
185
  /** Emit a fire-and-forget message for the given transport pattern. */
157
186
  emit?(pattern: string, payload: unknown): MaybePromise<void>;
158
187
  /** Start listening for transport messages. */
159
188
  listen(): MaybePromise<void>;
189
+ /**
190
+ * Synchronously notified when the owning shell begins shutdown.
191
+ *
192
+ * Implementations that expose their own ingress admission gate must close it
193
+ * before the first await in this call so that new send()/emit()/listen()
194
+ * attempts are rejected while a racing listen() is still settling. The
195
+ * owning shell caches its terminal close result before invoking this callback,
196
+ * and the terminal gate must stay closed even if close() later rejects.
197
+ */
198
+ markShutdownStarted?(): void;
160
199
  /** Send a request/response message for the given transport pattern. */
161
200
  send?(pattern: string, payload: unknown, signal?: AbortSignal): MaybePromise<unknown>;
162
201
  }
@@ -170,6 +209,7 @@ export interface ApplicationContext {
170
209
  readonly container: Container;
171
210
  readonly modules: CompiledModule[];
172
211
  readonly rootModule: ModuleType;
212
+ /** Closes the shell and retries incomplete teardown after a failed close. */
173
213
  close(signal?: string): Promise<void>;
174
214
  get<T>(token: Token<T>): Promise<T>;
175
215
  }
@@ -192,6 +232,11 @@ export interface Application {
192
232
  /** Connected microservice shell managed by an HTTP application or context. */
193
233
  export interface MicroserviceApplication extends ApplicationContext {
194
234
  readonly state: ApplicationState;
235
+ /**
236
+ * Closes the microservice shell once; later calls share its terminal success
237
+ * or failure result without re-invoking shutdown collaborators.
238
+ */
239
+ close(signal?: string): Promise<void>;
195
240
  emit(pattern: string, payload: unknown): Promise<void>;
196
241
  listen(): Promise<void>;
197
242
  send(pattern: string, payload: unknown, signal?: AbortSignal): Promise<unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,+EAA+E;AAC/E,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IAAE,UAAU,CAAC,EAAE,gBAAgB,CAAA;CAAE,CAAC;AACzE,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AACzC,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAEvE,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,cAAc,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;IAClB,UAAU,CAAC,EA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K,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACpC,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,8EAA8E;AAC9E,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IAEjC;;;OAGG;IACH,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjF"}
package/dist/web.d.ts CHANGED
@@ -1,12 +1,6 @@
1
- import { type Dispatcher, type FrameworkRequest, type FrameworkResponse } from '@fluojs/http';
2
- import { type MultipartOptions, type UploadedFile } from './multipart.js';
1
+ import { type Dispatcher, type FrameworkRequest, type FrameworkResponse } from '@fluojs/http/portable';
3
2
  import { type RequestResponseFactory } from './adapters/request-response-factory.js';
4
- declare module '@fluojs/http' {
5
- interface FrameworkRequest {
6
- files?: UploadedFile[];
7
- rawBody?: Uint8Array;
8
- }
9
- }
3
+ import { type MultipartOptions } from './multipart.js';
10
4
  /**
11
5
  * Configures Web request parsing, multipart handling, and raw body preservation.
12
6
  */
@@ -14,6 +8,10 @@ export interface CreateWebRequestResponseFactoryOptions {
14
8
  consumeOriginalBody?: boolean;
15
9
  maxBodySize?: number;
16
10
  multipart?: MultipartOptions;
11
+ /**
12
+ * @deprecated Retained for adapter compatibility. Web JSON bodies always use the bounded streaming reader,
13
+ * so this option no longer changes request parsing.
14
+ */
17
15
  preferNativeJsonBodyReader?: boolean;
18
16
  rawBody?: boolean;
19
17
  }
@@ -35,9 +33,17 @@ export interface DispatchWebRequestOptions extends CreateWebRequestResponseFacto
35
33
  * Represents a framework response that can be materialized as a native Web `Response`.
36
34
  */
37
35
  export interface WebFrameworkResponse extends FrameworkResponse {
36
+ /** @internal Optional early response signal provided by the built-in Web response facade. */
37
+ readonly responseReady?: Promise<Response>;
38
38
  toResponse(): Response;
39
39
  }
40
- export { parseMultipart } from './multipart.js';
40
+ /** Native Web response materialization and long-lived request lifecycle signals. */
41
+ export interface WebRequestDispatch {
42
+ readonly completion: Promise<void>;
43
+ readonly response: Promise<Response>;
44
+ }
45
+ export { MultipartBodyConsumedError, parseMultipart, parseMultipartStream, } from './multipart.js';
46
+ export type { MultipartFieldPart, MultipartFilePart, MultipartPart, } from './multipart.js';
41
47
  /**
42
48
  * Creates the request/response factory used by Web-standard adapters.
43
49
  *
@@ -52,6 +58,13 @@ export declare function createWebRequestResponseFactory(options?: CreateWebReque
52
58
  * @returns The native Web response produced by the dispatcher.
53
59
  */
54
60
  export declare function dispatchWebRequest({ dispatcher, dispatcherNotReadyMessage, factory, request, ...options }: DispatchWebRequestOptions): Promise<Response>;
61
+ /**
62
+ * Starts a native Web request dispatch without coupling streaming response materialization to lifecycle completion.
63
+ *
64
+ * @param options - Dispatch configuration including the request and runtime parsing options.
65
+ * @returns The native response signal and independently settling request lifecycle signal.
66
+ */
67
+ export declare function startWebRequestDispatch({ dispatcher, dispatcherNotReadyMessage, factory, request, ...options }: DispatchWebRequestOptions): WebRequestDispatch;
55
68
  /**
56
69
  * Creates a framework request from a native Web request.
57
70
  *
package/dist/web.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,UAAU,EACf,KAAK,gBAAgB,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,CAAC;CACxB;AAED,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CACtC;AAED,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAwNxB;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE,sCAA2C,GACnD,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE,oBAAoB,CAAC,CAgChF;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,UAAU,EACV,yBAAiG,EACjG,OAAO,EACP,OAAO,EACP,GAAG,OAAO,EACX,EAAE,yBAAyB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAQ/C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,yBAAiG,EACjG,OAAO,EACP,OAAO,EACP,GAAG,OAAO,EACX,EAAE,yBAAyB,GAAG,kBAAkB,CAoBhD;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,WAAW,EACnB,gBAAgB,CAAC,EAAE,gBAAgB,EACnC,WAAW,SAAwB,EACnC,eAAe,UAAQ,GACtB,OAAO,CAAC,gBAAgB,CAAC,CAY3B"}
package/dist/web.js CHANGED
@@ -1,7 +1,7 @@
1
- import { BadRequestException, createErrorResponse, HttpException, InternalServerErrorException, PayloadTooLargeException } from '@fluojs/http';
1
+ import { BadRequestException, createErrorResponse, HttpException, InternalServerErrorException, PayloadTooLargeException } from '@fluojs/http/portable';
2
+ import { startDispatchWithRequestResponseFactory } from './adapters/request-response-factory.js';
2
3
  import { attachRuntimeFrameworkRequestNativeRouteHandoff, consumeRuntimeRawRequestNativeRouteHandoff } from './internal/http-runtime.js';
3
- import { parseMultipart } from './multipart.js';
4
- import { dispatchWithRequestResponseFactory } from './adapters/request-response-factory.js';
4
+ import { markMultipartBodyConsumed, parseMultipart, parseMultipartStream } from './multipart.js';
5
5
  const DEFAULT_MAX_BODY_SIZE = 1 * 1024 * 1024;
6
6
  const TEXT_ENCODER = new TextEncoder();
7
7
  const TEXT_DECODER = new TextDecoder();
@@ -19,7 +19,9 @@ const REQUEST_BODY_LIMIT_MESSAGE = 'Request body exceeds the size limit.';
19
19
  * Represents a framework response that can be materialized as a native Web `Response`.
20
20
  */
21
21
 
22
- export { parseMultipart } from './multipart.js';
22
+ /** Native Web response materialization and long-lived request lifecycle signals. */
23
+
24
+ export { MultipartBodyConsumedError, parseMultipart, parseMultipartStream } from './multipart.js';
23
25
  class WebResponseStream {
24
26
  closeListeners = new Set();
25
27
  controller;
@@ -27,7 +29,7 @@ class WebResponseStream {
27
29
  markedClosed = false;
28
30
  readable = new ReadableStream({
29
31
  cancel: () => {
30
- this.close();
32
+ this.close(true);
31
33
  },
32
34
  start: controller => {
33
35
  this.controller = controller;
@@ -39,13 +41,15 @@ class WebResponseStream {
39
41
  get closed() {
40
42
  return this.markedClosed;
41
43
  }
42
- close() {
44
+ close(closedByConsumer = false) {
43
45
  this.activate();
44
46
  if (this.markedClosed) {
45
47
  return;
46
48
  }
47
49
  this.markedClosed = true;
48
- this.controller?.close();
50
+ if (!closedByConsumer) {
51
+ this.controller?.close();
52
+ }
49
53
  this.emitClose();
50
54
  }
51
55
  flush() {
@@ -94,9 +98,13 @@ class MutableWebFrameworkResponse {
94
98
  statusCode;
95
99
  statusSet;
96
100
  finalizedResponse;
101
+ resolveResponseReady = () => undefined;
97
102
  responseStream;
98
103
  responseBody;
99
104
  streamActive = false;
105
+ responseReady = new Promise(resolve => {
106
+ this.resolveResponseReady = resolve;
107
+ });
100
108
  get stream() {
101
109
  return this.getOrCreateResponseStream();
102
110
  }
@@ -150,12 +158,14 @@ class MutableWebFrameworkResponse {
150
158
  this.finalizedResponse = this.streamActive ? new Response(this.getOrCreateResponseStream().readable, init) : new Response(nativeResponseBody, init);
151
159
  this.raw = this.finalizedResponse;
152
160
  this.committed = true;
161
+ this.resolveResponseReady(this.finalizedResponse);
153
162
  }
154
163
  return this.finalizedResponse;
155
164
  }
156
165
  getOrCreateResponseStream() {
157
166
  this.responseStream ??= new WebResponseStream(() => {
158
167
  this.streamActive = true;
168
+ this.toResponse();
159
169
  });
160
170
  return this.responseStream;
161
171
  }
@@ -168,9 +178,10 @@ class MutableWebFrameworkResponse {
168
178
  * @returns A request/response factory for Web requests and responses.
169
179
  */
170
180
  export function createWebRequestResponseFactory(options = {}) {
181
+ const maxBodySize = resolveWebMaxBodySize(options.maxBodySize);
171
182
  return {
172
183
  async createRequest(request, signal) {
173
- return createDeferredWebFrameworkRequest(request, signal, options.multipart, options.maxBodySize ?? DEFAULT_MAX_BODY_SIZE, options.rawBody ?? false, options.preferNativeJsonBodyReader ?? false, options.consumeOriginalBody ?? false);
184
+ return createDeferredWebFrameworkRequest(request, signal, options.multipart, maxBodySize, options.rawBody ?? false, options.consumeOriginalBody ?? false);
174
185
  },
175
186
  materializeRequest(request) {
176
187
  return materializeWebFrameworkRequestBody(request);
@@ -205,14 +216,40 @@ export async function dispatchWebRequest({
205
216
  request,
206
217
  ...options
207
218
  }) {
208
- const frameworkResponse = await dispatchWithRequestResponseFactory({
219
+ return await startWebRequestDispatch({
220
+ dispatcher,
221
+ dispatcherNotReadyMessage,
222
+ factory,
223
+ request,
224
+ ...options
225
+ }).response;
226
+ }
227
+
228
+ /**
229
+ * Starts a native Web request dispatch without coupling streaming response materialization to lifecycle completion.
230
+ *
231
+ * @param options - Dispatch configuration including the request and runtime parsing options.
232
+ * @returns The native response signal and independently settling request lifecycle signal.
233
+ */
234
+ export function startWebRequestDispatch({
235
+ dispatcher,
236
+ dispatcherNotReadyMessage = 'Web adapter received a request before dispatcher binding completed.',
237
+ factory,
238
+ request,
239
+ ...options
240
+ }) {
241
+ const dispatch = startDispatchWithRequestResponseFactory({
209
242
  dispatcher,
210
243
  dispatcherNotReadyMessage,
211
244
  factory: factory ?? createWebRequestResponseFactory(options),
212
245
  rawRequest: request,
213
246
  rawResponse: request.signal
214
247
  });
215
- return frameworkResponse.toResponse();
248
+ const responseReady = dispatch.response.responseReady;
249
+ return {
250
+ completion: dispatch.completion.then(() => undefined),
251
+ response: responseReady ? Promise.race([responseReady, dispatch.completion.then(frameworkResponse => frameworkResponse.toResponse())]) : dispatch.completion.then(frameworkResponse => frameworkResponse.toResponse())
252
+ };
216
253
  }
217
254
 
218
255
  /**
@@ -226,7 +263,8 @@ export async function dispatchWebRequest({
226
263
  * @returns The normalized framework request used by the dispatcher.
227
264
  */
228
265
  export async function createWebFrameworkRequest(request, signal, multipartOptions, maxBodySize = DEFAULT_MAX_BODY_SIZE, preserveRawBody = false) {
229
- const frameworkRequest = createDeferredWebFrameworkRequest(request, signal, multipartOptions, maxBodySize, preserveRawBody);
266
+ const resolvedMaxBodySize = resolveWebMaxBodySize(maxBodySize);
267
+ const frameworkRequest = createDeferredWebFrameworkRequest(request, signal, multipartOptions, resolvedMaxBodySize, preserveRawBody);
230
268
  await materializeWebFrameworkRequestBody(frameworkRequest);
231
269
  return frameworkRequest;
232
270
  }
@@ -241,7 +279,7 @@ export async function createWebFrameworkRequest(request, signal, multipartOption
241
279
  * @param preserveRawBody - Whether materialization should retain raw request body bytes.
242
280
  * @returns The framework request shell with metadata snapshotted and body materialization deferred.
243
281
  */
244
- function createDeferredWebFrameworkRequest(request, signal, multipartOptions, maxBodySize = DEFAULT_MAX_BODY_SIZE, preserveRawBody = false, preferNativeJsonBodyReader = false, consumeOriginalBody = false) {
282
+ function createDeferredWebFrameworkRequest(request, signal, multipartOptions, maxBodySize = DEFAULT_MAX_BODY_SIZE, preserveRawBody = false, consumeOriginalBody = false) {
245
283
  const url = new URL(request.url);
246
284
  const requestHeaders = new Headers(request.headers);
247
285
  const method = request.method;
@@ -253,11 +291,23 @@ function createDeferredWebFrameworkRequest(request, signal, multipartOptions, ma
253
291
  const hasRequestBody = request.body !== null;
254
292
  const materializeBody = hasRequestBody ? createMemoizedAsyncValue(async () => {
255
293
  if (isMultipart) {
256
- const materializedRequest = request.clone();
257
- const result = await parseMultipart(createRequestWithSnapshotMetadata(materializedRequest, request.url, method, requestHeaders), {
294
+ const resolvedMultipartOptions = {
258
295
  ...multipartOptions,
259
296
  maxTotalSize: multipartOptions?.maxTotalSize ?? maxBodySize
260
- });
297
+ };
298
+ if (multipartOptions?.strategy === 'stream') {
299
+ frameworkRequest.body = parseMultipartStream({
300
+ body: request.body,
301
+ headers: requestHeaders,
302
+ method,
303
+ signal,
304
+ url: request.url
305
+ }, resolvedMultipartOptions);
306
+ return;
307
+ }
308
+ const materializedRequest = request.clone();
309
+ markMultipartBodyConsumed(request);
310
+ const result = await parseMultipart(createRequestWithSnapshotMetadata(materializedRequest, request.url, method, requestHeaders), resolvedMultipartOptions);
261
311
  frameworkRequest.body = result.fields;
262
312
  frameworkRequest.files = result.files;
263
313
  return;
@@ -268,7 +318,7 @@ function createDeferredWebFrameworkRequest(request, signal, multipartOptions, ma
268
318
  return;
269
319
  }
270
320
  const requestToRead = consumeOriginalBody ? request : request.clone();
271
- const bodyResult = await readWebRequestBody(requestToRead, contentType, maxBodySize, preserveRawBody, preferNativeJsonBodyReader);
321
+ const bodyResult = await readWebRequestBody(requestToRead, contentType, maxBodySize, preserveRawBody);
272
322
  frameworkRequest.body = bodyResult.body;
273
323
  if (bodyResult.rawBody) {
274
324
  frameworkRequest.rawBody = bodyResult.rawBody;
@@ -302,7 +352,8 @@ function createDeferredWebFrameworkRequest(request, signal, multipartOptions, ma
302
352
  function createRequestWithSnapshotMetadata(request, url, method, headers) {
303
353
  const init = {
304
354
  headers: new Headers(headers),
305
- method
355
+ method,
356
+ signal: request.signal
306
357
  };
307
358
  if (request.body) {
308
359
  init.body = request.body;
@@ -320,6 +371,13 @@ function validateWebRequestContentLength(request, maxBodySize) {
320
371
  throw new PayloadTooLargeException(REQUEST_BODY_LIMIT_MESSAGE);
321
372
  }
322
373
  }
374
+ function resolveWebMaxBodySize(value) {
375
+ const maxBodySize = value ?? DEFAULT_MAX_BODY_SIZE;
376
+ if (!Number.isInteger(maxBodySize) || maxBodySize < 0) {
377
+ throw new Error(`Invalid maxBodySize value: ${String(maxBodySize)}. Expected a non-negative integer number of bytes.`);
378
+ }
379
+ return maxBodySize;
380
+ }
323
381
 
324
382
  /**
325
383
  * Materializes a deferred Web framework request body exactly once.
@@ -422,20 +480,13 @@ function parseCookieHeader(cookieHeader) {
422
480
  return [pair.slice(0, index).trim(), decodeCookieValue(pair.slice(index + 1).trim())];
423
481
  }));
424
482
  }
425
- async function readWebRequestBody(request, contentType, maxBodySize = DEFAULT_MAX_BODY_SIZE, preserveRawBody = false, preferNativeJsonBodyReader = false) {
483
+ async function readWebRequestBody(request, contentType, maxBodySize = DEFAULT_MAX_BODY_SIZE, preserveRawBody = false) {
426
484
  validateWebRequestContentLength(request, maxBodySize);
427
485
  if (!request.body) {
428
486
  return {
429
487
  body: undefined
430
488
  };
431
489
  }
432
- if (!preserveRawBody && isJsonContentType(contentType) && (preferNativeJsonBodyReader || isContentLengthWithinLimit(request, maxBodySize))) {
433
- const rawBody = new Uint8Array(await request.arrayBuffer());
434
- if (rawBody.byteLength > maxBodySize) {
435
- throw new PayloadTooLargeException(REQUEST_BODY_LIMIT_MESSAGE);
436
- }
437
- return parseWebRequestRawBody(rawBody, contentType, preserveRawBody);
438
- }
439
490
  return parseWebRequestRawBody(await readByteLimitedStream(request.body, maxBodySize), contentType, preserveRawBody);
440
491
  }
441
492
  function parseWebRequestRawBody(rawBody, contentType, preserveRawBody) {
@@ -466,14 +517,6 @@ function parseWebRequestRawBody(rawBody, contentType, preserveRawBody) {
466
517
  rawBody: preserveRawBody ? rawBody : undefined
467
518
  };
468
519
  }
469
- function isContentLengthWithinLimit(request, maxBodySize) {
470
- const contentLength = request.headers.get('content-length');
471
- if (contentLength === null) {
472
- return false;
473
- }
474
- const parsedContentLength = Number(contentLength);
475
- return Number.isFinite(parsedContentLength) && parsedContentLength > 0 && parsedContentLength <= maxBodySize;
476
- }
477
520
  async function readByteLimitedStream(stream, maxBodySize) {
478
521
  const reader = stream.getReader();
479
522
  const chunks = [];
@@ -489,7 +532,10 @@ async function readByteLimitedStream(stream, maxBodySize) {
489
532
  }
490
533
  totalSize += value.byteLength;
491
534
  if (totalSize > maxBodySize) {
492
- await reader.cancel(REQUEST_BODY_LIMIT_MESSAGE);
535
+ const cancellation = new Promise((resolve, reject) => {
536
+ void reader.cancel(REQUEST_BODY_LIMIT_MESSAGE).then(resolve, reject);
537
+ });
538
+ void Promise.allSettled([cancellation]);
493
539
  throw new PayloadTooLargeException(REQUEST_BODY_LIMIT_MESSAGE);
494
540
  }
495
541
  chunks.push(value);
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "module-graph",
10
10
  "orchestration"
11
11
  ],
12
- "version": "1.1.8",
12
+ "version": "3.0.0",
13
13
  "private": false,
14
14
  "license": "MIT",
15
15
  "repository": {
@@ -17,9 +17,6 @@
17
17
  "url": "https://github.com/fluojs/fluo.git",
18
18
  "directory": "packages/runtime"
19
19
  },
20
- "engines": {
21
- "node": ">=20.0.0"
22
- },
23
20
  "publishConfig": {
24
21
  "access": "public"
25
22
  },
@@ -27,16 +24,17 @@
27
24
  "exports": {
28
25
  ".": {
29
26
  "types": "./dist/index.d.ts",
30
- "import": "./dist/index.js"
31
- },
32
- "./node": {
33
- "types": "./dist/node.d.ts",
34
- "import": "./dist/node.js"
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
35
29
  },
36
30
  "./web": {
37
31
  "types": "./dist/web.d.ts",
38
32
  "import": "./dist/web.js"
39
33
  },
34
+ "./devtools": {
35
+ "types": "./dist/devtools/index.d.ts",
36
+ "import": "./dist/devtools/index.js"
37
+ },
40
38
  "./internal": {
41
39
  "types": "./dist/internal.d.ts",
42
40
  "import": "./dist/internal.js"
@@ -48,33 +46,22 @@
48
46
  "./internal/request-response-factory": {
49
47
  "types": "./dist/internal-request-response-factory.d.ts",
50
48
  "import": "./dist/internal-request-response-factory.js"
51
- },
52
- "./internal-node": {
53
- "types": "./dist/internal-node.d.ts",
54
- "import": "./dist/internal-node.js"
55
49
  }
56
50
  },
57
51
  "main": "./dist/index.js",
58
52
  "types": "./dist/index.d.ts",
59
- "typesVersions": {
60
- "*": {
61
- "internal-node": [
62
- "./dist/internal-node.d.ts"
63
- ]
64
- }
65
- },
66
53
  "files": [
67
54
  "dist"
68
55
  ],
69
56
  "dependencies": {
70
- "@fluojs/config": "^1.0.3",
71
- "@fluojs/core": "^1.0.3",
72
- "@fluojs/di": "^1.1.0",
73
- "@fluojs/http": "^1.1.2"
57
+ "@fluojs/core": "^2.0.0",
58
+ "@fluojs/di": "^3.0.0",
59
+ "@fluojs/http": "^3.0.0",
60
+ "@fluojs/studio": "^2.0.0"
74
61
  },
75
62
  "devDependencies": {
76
- "vitest": "^3.2.4",
77
- "@fluojs/serialization": "^1.0.4"
63
+ "vitest": "^4.1.11",
64
+ "@fluojs/serialization": "^2.0.0"
78
65
  },
79
66
  "scripts": {
80
67
  "prebuild": "node ../../tooling/scripts/clean-dist.mjs",
@@ -1,2 +0,0 @@
1
- export * from './node/internal-node.js';
2
- //# sourceMappingURL=internal-node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal-node.d.ts","sourceRoot":"","sources":["../src/internal-node.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -1 +0,0 @@
1
- export * from './node/internal-node.js';
@@ -1,8 +0,0 @@
1
- import type { ApplicationLogger } from '../types.js';
2
- /**
3
- * Create json application logger.
4
- *
5
- * @returns The create json application logger result.
6
- */
7
- export declare function createJsonApplicationLogger(): ApplicationLogger;
8
- //# sourceMappingURL=json-logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-logger.d.ts","sourceRoot":"","sources":["../../src/logging/json-logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAqCrD;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,iBAAiB,CAe/D"}
@@ -1,45 +0,0 @@
1
- import { getCurrentRequestContext } from '@fluojs/http';
2
- function buildEntry(level, message, context, error) {
3
- const entry = {
4
- level,
5
- message,
6
- timestamp: new Date().toISOString()
7
- };
8
- const requestId = getCurrentRequestContext()?.requestId;
9
- if (requestId) {
10
- entry.requestId = requestId;
11
- }
12
- if (context) {
13
- entry.context = context;
14
- }
15
- if (error instanceof Error) {
16
- entry.error = {
17
- message: error.message,
18
- name: error.name,
19
- stack: error.stack
20
- };
21
- }
22
- return entry;
23
- }
24
-
25
- /**
26
- * Create json application logger.
27
- *
28
- * @returns The create json application logger result.
29
- */
30
- export function createJsonApplicationLogger() {
31
- return {
32
- debug(message, context) {
33
- process.stdout.write(JSON.stringify(buildEntry('debug', message, context)) + '\n');
34
- },
35
- error(message, error, context) {
36
- process.stderr.write(JSON.stringify(buildEntry('error', message, context, error)) + '\n');
37
- },
38
- log(message, context) {
39
- process.stdout.write(JSON.stringify(buildEntry('log', message, context)) + '\n');
40
- },
41
- warn(message, context) {
42
- process.stderr.write(JSON.stringify(buildEntry('warn', message, context)) + '\n');
43
- }
44
- };
45
- }