@bleedingdev/modern-js-server-core 3.2.0-ultramodern.0 → 3.2.0-ultramodern.2

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 (72) hide show
  1. package/package.json +5 -5
  2. package/dist/types/adapters/node/helper/index.d.ts +0 -6
  3. package/dist/types/adapters/node/helper/loadCache.d.ts +0 -2
  4. package/dist/types/adapters/node/helper/loadConfig.d.ts +0 -3
  5. package/dist/types/adapters/node/helper/loadEnv.d.ts +0 -3
  6. package/dist/types/adapters/node/helper/loadPlugin.d.ts +0 -3
  7. package/dist/types/adapters/node/helper/utils.d.ts +0 -21
  8. package/dist/types/adapters/node/hono.d.ts +0 -19
  9. package/dist/types/adapters/node/index.d.ts +0 -5
  10. package/dist/types/adapters/node/node.d.ts +0 -17
  11. package/dist/types/adapters/node/plugins/index.d.ts +0 -3
  12. package/dist/types/adapters/node/plugins/nodeServer.d.ts +0 -6
  13. package/dist/types/adapters/node/plugins/resource.d.ts +0 -11
  14. package/dist/types/adapters/node/plugins/static.d.ts +0 -25
  15. package/dist/types/constants.d.ts +0 -26
  16. package/dist/types/context.d.ts +0 -3
  17. package/dist/types/helper.d.ts +0 -10
  18. package/dist/types/hono.d.ts +0 -3
  19. package/dist/types/index.d.ts +0 -14
  20. package/dist/types/plugins/compat/hooks.d.ts +0 -8
  21. package/dist/types/plugins/compat/index.d.ts +0 -3
  22. package/dist/types/plugins/contractGateAutopilot.d.ts +0 -35
  23. package/dist/types/plugins/contractGateSnapshotStore.d.ts +0 -57
  24. package/dist/types/plugins/default.d.ts +0 -7
  25. package/dist/types/plugins/favicon.d.ts +0 -2
  26. package/dist/types/plugins/index.d.ts +0 -11
  27. package/dist/types/plugins/log.d.ts +0 -2
  28. package/dist/types/plugins/mfCache.d.ts +0 -12
  29. package/dist/types/plugins/middlewares.d.ts +0 -2
  30. package/dist/types/plugins/monitors.d.ts +0 -6
  31. package/dist/types/plugins/processedBy.d.ts +0 -2
  32. package/dist/types/plugins/render/csrRscRender.d.ts +0 -2
  33. package/dist/types/plugins/render/dataHandler.d.ts +0 -5
  34. package/dist/types/plugins/render/index.d.ts +0 -3
  35. package/dist/types/plugins/render/inject.d.ts +0 -7
  36. package/dist/types/plugins/render/render.d.ts +0 -16
  37. package/dist/types/plugins/render/renderRscHandler.d.ts +0 -2
  38. package/dist/types/plugins/render/serverActionHandler.d.ts +0 -2
  39. package/dist/types/plugins/render/ssrCache.d.ts +0 -18
  40. package/dist/types/plugins/render/ssrRender.d.ts +0 -26
  41. package/dist/types/plugins/render/utils.d.ts +0 -3
  42. package/dist/types/plugins/route.d.ts +0 -2
  43. package/dist/types/plugins/telemetry.d.ts +0 -309
  44. package/dist/types/serverBase.d.ts +0 -38
  45. package/dist/types/types/config/bff.d.ts +0 -142
  46. package/dist/types/types/config/dev.d.ts +0 -4
  47. package/dist/types/types/config/html.d.ts +0 -15
  48. package/dist/types/types/config/index.d.ts +0 -35
  49. package/dist/types/types/config/output.d.ts +0 -20
  50. package/dist/types/types/config/security.d.ts +0 -4
  51. package/dist/types/types/config/server.d.ts +0 -402
  52. package/dist/types/types/config/share.d.ts +0 -3
  53. package/dist/types/types/config/source.d.ts +0 -7
  54. package/dist/types/types/config/tools.d.ts +0 -2
  55. package/dist/types/types/index.d.ts +0 -4
  56. package/dist/types/types/plugins/base.d.ts +0 -57
  57. package/dist/types/types/plugins/index.d.ts +0 -2
  58. package/dist/types/types/plugins/plugin.d.ts +0 -31
  59. package/dist/types/types/render.d.ts +0 -24
  60. package/dist/types/types/requestHandler.d.ts +0 -48
  61. package/dist/types/types/server.d.ts +0 -67
  62. package/dist/types/utils/entry.d.ts +0 -3
  63. package/dist/types/utils/env.d.ts +0 -2
  64. package/dist/types/utils/error.d.ts +0 -8
  65. package/dist/types/utils/index.d.ts +0 -9
  66. package/dist/types/utils/middlewareCollector.d.ts +0 -12
  67. package/dist/types/utils/publicDir.d.ts +0 -40
  68. package/dist/types/utils/request.d.ts +0 -17
  69. package/dist/types/utils/serverConfig.d.ts +0 -8
  70. package/dist/types/utils/storage.d.ts +0 -5
  71. package/dist/types/utils/transformStream.d.ts +0 -5
  72. package/dist/types/utils/warmup.d.ts +0 -1
@@ -1,402 +0,0 @@
1
- import type { SSRMode } from '@modern-js/types';
2
- import type { WatchOptions } from '@modern-js/utils';
3
- type Route = string | string[] | {
4
- route?: string | string[];
5
- disableSpa?: boolean;
6
- resHeaders?: Record<string, unknown>;
7
- };
8
- export type Routes = Record<string, Route>;
9
- export type SSR = boolean | {
10
- forceCSR?: boolean;
11
- mode?: SSRMode;
12
- preload?: boolean | SSRPreload;
13
- inlineScript?: boolean;
14
- disablePrerender?: boolean;
15
- /**
16
- * Additional request header names removed from SSR payload serialization.
17
- * Sensitive headers are denylisted by default.
18
- */
19
- unsafeHeaders?: string[];
20
- /**
21
- * Enable app-level Module Federation SSR bridge path.
22
- * This flag should be enabled in both host and remote applications.
23
- * @default false
24
- */
25
- moduleFederationAppSSR?: boolean;
26
- };
27
- export type SSRByEntries = Record<string, SSR>;
28
- type SSRPreload = Record<string, unknown>;
29
- export interface ServerTelemetryExporterOptions {
30
- enabled?: boolean;
31
- endpoint?: string;
32
- headers?: Record<string, string>;
33
- timeoutMs?: number;
34
- }
35
- export interface ServerTelemetryVictoriaMetricsOptions extends ServerTelemetryExporterOptions {
36
- metricPrefix?: string;
37
- }
38
- export interface ServerTelemetrySloUserConfig {
39
- /**
40
- * Queue utilization ratio threshold that emits SLO degradation alerts.
41
- *
42
- * @default 0.8
43
- */
44
- queueUtilizationWarnThreshold?: number;
45
- /**
46
- * Total dropped-envelope threshold that emits SLO degradation alerts.
47
- *
48
- * @default 1
49
- */
50
- queueDroppedWarnThreshold?: number;
51
- /**
52
- * Cooldown between SLO alert emissions for the same alert type.
53
- *
54
- * @default 60000
55
- */
56
- alertCooldownMs?: number;
57
- }
58
- export interface ServerTelemetryCanaryContractGateUserConfig {
59
- /**
60
- * Whether this contract gate currently passes.
61
- */
62
- passed: boolean;
63
- /**
64
- * Optional failure reason used for rollback diagnostics.
65
- */
66
- reason?: string;
67
- }
68
- export interface ServerTelemetryCanaryAutopilotUserConfig {
69
- /**
70
- * Enable automatic contract gate synchronization from a gate snapshot file.
71
- *
72
- * @default true
73
- */
74
- enabled?: boolean;
75
- /**
76
- * Path to contract gate snapshot JSON file.
77
- *
78
- * @default ".modern/contract-gates.json"
79
- */
80
- gateSnapshotPath?: string;
81
- /**
82
- * Poll interval for reading gate snapshot changes.
83
- *
84
- * @default 15000
85
- */
86
- pollIntervalMs?: number;
87
- /**
88
- * Marks gate entries as failed when they are older than this threshold.
89
- *
90
- * @default 600000
91
- */
92
- gateStaleAfterMs?: number;
93
- /**
94
- * Runtime MF fallback signal ingestion.
95
- */
96
- runtimeFallbackSignal?: ServerTelemetryCanaryRuntimeFallbackSignalUserConfig;
97
- /**
98
- * Optional pluggable state store backend for contract gate snapshots.
99
- * When omitted, snapshots are read/written from gateSnapshotPath on local disk.
100
- */
101
- stateStore?: ServerTelemetryCanaryAutopilotStateStoreUserConfig;
102
- }
103
- export interface ServerTelemetryCanaryAutopilotStateStoreUserConfig {
104
- /**
105
- * Path or package name of a module that exports
106
- * `createContractGateSnapshotStore(context)`.
107
- */
108
- module: string;
109
- /**
110
- * Optional adapter-specific configuration.
111
- */
112
- options?: Record<string, unknown>;
113
- }
114
- export interface ServerTelemetryCanaryRuntimeFallbackSignalUserConfig {
115
- /**
116
- * Enable runtime MF fallback signal ingestion endpoint.
117
- *
118
- * @default true
119
- */
120
- enabled?: boolean;
121
- /**
122
- * HTTP endpoint path for runtime fallback events.
123
- *
124
- * @default "/_modern/contract-gates/runtime-fallback"
125
- */
126
- endpoint?: string;
127
- /**
128
- * Contract gate name updated by runtime fallback events.
129
- *
130
- * @default "runtime-mf-fallback-health"
131
- */
132
- gateName?: string;
133
- /**
134
- * How long a runtime fallback signal should hold gate failure status.
135
- *
136
- * @default 300000
137
- */
138
- failureHoldMs?: number;
139
- /**
140
- * Maximum accepted request body size in bytes.
141
- *
142
- * @default 16384
143
- */
144
- maxBodyBytes?: number;
145
- /**
146
- * Optional runtime trust policy for fallback signal ingestion.
147
- * Use this to restrict who can mutate canary contract gates.
148
- */
149
- trustPolicy?: ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig;
150
- /**
151
- * Optional request authentication for runtime fallback signal endpoint.
152
- */
153
- auth?: ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig;
154
- /**
155
- * Optional worker-lane pilot for runtime fallback snapshot persistence.
156
- * Disabled by default to keep baseline behavior deterministic.
157
- */
158
- workerLane?: ServerTelemetryCanaryRuntimeFallbackSignalWorkerLaneUserConfig;
159
- }
160
- export interface ServerTelemetryCanaryRuntimeFallbackSignalWorkerLaneUserConfig {
161
- /**
162
- * Enable off-main-thread persistence for runtime fallback gate snapshots.
163
- *
164
- * @default false
165
- */
166
- enabled?: boolean;
167
- /**
168
- * Maximum time to wait for worker-lane completion before falling back to
169
- * main-thread persistence.
170
- *
171
- * @default 250
172
- */
173
- timeoutMs?: number;
174
- }
175
- export interface ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig {
176
- /**
177
- * Enable auth guard for runtime fallback signal endpoint.
178
- *
179
- * @default false
180
- */
181
- enabled?: boolean;
182
- /**
183
- * Header name carrying runtime fallback auth token.
184
- *
185
- * @default "x-modernjs-runtime-signal-token"
186
- */
187
- headerName?: string;
188
- /**
189
- * Expected token value. Prefer using expectedValueEnv in production.
190
- */
191
- expectedValue?: string;
192
- /**
193
- * Name of environment variable that stores expected token value.
194
- */
195
- expectedValueEnv?: string;
196
- }
197
- export interface ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig {
198
- /**
199
- * Allowlist of app names accepted by runtime fallback signal endpoint.
200
- * Empty means no app-name allowlist check.
201
- */
202
- allowedApps?: string[];
203
- /**
204
- * Allowlist of entry origins accepted by runtime fallback signal endpoint.
205
- * Values should be URL origins (for example https://erp.example.com).
206
- * Empty means no entry-origin allowlist check.
207
- */
208
- allowedEntryOrigins?: string[];
209
- /**
210
- * Expected runtime digest per appName.
211
- */
212
- expectedRuntimeDigests?: Record<string, string>;
213
- /**
214
- * Require runtimeDigest to be present in signal payload metadata.
215
- *
216
- * @default false
217
- */
218
- enforceRuntimeDigest?: boolean;
219
- /**
220
- * Maximum accepted signals per app+origin window.
221
- *
222
- * @default 30
223
- */
224
- maxSignalsPerWindow?: number;
225
- /**
226
- * Sliding window size in milliseconds for maxSignalsPerWindow.
227
- *
228
- * @default 60000
229
- */
230
- windowMs?: number;
231
- /**
232
- * Drop duplicate fallback events with the same fingerprint during this window.
233
- *
234
- * @default 10000
235
- */
236
- dedupeWindowMs?: number;
237
- }
238
- export interface ServerTelemetryCanaryUserConfig {
239
- /**
240
- * Enable canary rollout/rollback orchestration.
241
- *
242
- * @default false
243
- */
244
- enabled?: boolean;
245
- /**
246
- * Periodic canary evaluation interval in milliseconds.
247
- *
248
- * @default 15000
249
- */
250
- evaluationIntervalMs?: number;
251
- /**
252
- * Required consecutive healthy evaluations before promotion.
253
- *
254
- * @default 3
255
- */
256
- minConsecutiveHealthyEvaluations?: number;
257
- /**
258
- * Consecutive failing evaluations before automated rollback.
259
- *
260
- * @default 2
261
- */
262
- rollbackConsecutiveFailures?: number;
263
- /**
264
- * Maximum queue utilization ratio allowed during canary.
265
- *
266
- * @default 0.8
267
- */
268
- maxQueueUtilization?: number;
269
- /**
270
- * Maximum allowed total dropped envelopes during canary.
271
- *
272
- * @default 0
273
- */
274
- maxTotalDropped?: number;
275
- /**
276
- * Maximum allowed unhealthy exporters during canary.
277
- *
278
- * @default 0
279
- */
280
- maxUnhealthyExporters?: number;
281
- /**
282
- * Contract gate map used in rollout decisions.
283
- * `true` means passing, `false` means failing.
284
- */
285
- contractGates?: Record<string, boolean | ServerTelemetryCanaryContractGateUserConfig>;
286
- /**
287
- * Contract-gate autopilot settings.
288
- */
289
- autopilot?: ServerTelemetryCanaryAutopilotUserConfig;
290
- }
291
- export interface ServerTelemetryUserConfig {
292
- /**
293
- * Enable framework telemetry envelope emission.
294
- * @default false
295
- */
296
- enabled?: boolean;
297
- /**
298
- * Logical service name attached to every telemetry envelope.
299
- * @default server.metaName
300
- */
301
- service?: string;
302
- /**
303
- * Logical module name attached to every telemetry envelope.
304
- * @default "server"
305
- */
306
- module?: string;
307
- /**
308
- * Environment attached to every telemetry envelope.
309
- * @default process.env.NODE_ENV || "development"
310
- */
311
- environment?: string;
312
- /**
313
- * Sampling rate for monitor events.
314
- * @default 1
315
- */
316
- samplingRate?: number;
317
- /**
318
- * Flush window in milliseconds for exporter batches.
319
- * @default 1000
320
- */
321
- flushIntervalMs?: number;
322
- /**
323
- * Maximum envelopes in one emitted batch.
324
- * @default 50
325
- */
326
- maxBatchSize?: number;
327
- /**
328
- * Maximum envelopes buffered before backpressure drops oldest.
329
- * @default 1000
330
- */
331
- maxQueueSize?: number;
332
- /**
333
- * Envelope attribute keys that should be redacted.
334
- */
335
- redactionKeys?: string[];
336
- /**
337
- * Control startup exporter health probe behavior.
338
- * When enabled (default), server initialization emits a startup probe and
339
- * marks exporters healthy/unhealthy before serving traffic.
340
- * When fail-loud mode is enabled (default), initialization throws if at
341
- * least one configured exporter is unhealthy.
342
- *
343
- * @default true
344
- */
345
- failLoudStartup?: boolean;
346
- /**
347
- * Queue backpressure/degradation SLO alert thresholds.
348
- */
349
- slo?: ServerTelemetrySloUserConfig;
350
- /**
351
- * Canary rollout and automated rollback orchestration policy.
352
- */
353
- canary?: ServerTelemetryCanaryUserConfig;
354
- exporters?: {
355
- /**
356
- * OpenTelemetry HTTP exporter.
357
- */
358
- otlp?: ServerTelemetryExporterOptions;
359
- /**
360
- * VictoriaMetrics Prometheus import exporter.
361
- */
362
- victoriaMetrics?: ServerTelemetryVictoriaMetricsOptions;
363
- };
364
- }
365
- export interface ServerUserConfig {
366
- publicDir?: string | string[];
367
- routes?: Routes;
368
- /**
369
- * Experimenal, it is not recommended to use it now
370
- */
371
- ssrByRouteIds?: string[];
372
- publicRoutes?: Record<string, string>;
373
- ssr?: SSR;
374
- ssrByEntries?: SSRByEntries;
375
- rsc?: boolean;
376
- baseUrl?: string | string[];
377
- port?: number;
378
- watchOptions?: WatchOptions;
379
- compiler?: 'typescript';
380
- /**
381
- * @description use json script tag instead of inline script
382
- * @default false
383
- */
384
- useJsonScript?: boolean;
385
- logger?: boolean | Record<string, unknown>;
386
- telemetry?: ServerTelemetryUserConfig;
387
- /**
388
- * @description disable hook middleware for performance
389
- * @default false
390
- */
391
- disableHook?: boolean;
392
- /**
393
- * Path to the tsconfig used by all server-side TypeScript stages:
394
- * BFF/api compile, custom server compile, runtime ts-node register,
395
- * and downstream runtimes.
396
- *
397
- * @default <appDirectory>/tsconfig.json
398
- */
399
- tsconfigPath?: string;
400
- }
401
- export type ServerNormalizedConfig = ServerUserConfig;
402
- export {};
@@ -1,3 +0,0 @@
1
- type ArrayOrNot<T> = T | T[];
2
- export type ConfigChain<Config, Utils = unknown> = ArrayOrNot<Config | (keyof Utils extends never ? (config: Config) => Config | void : (config: Config, utils: Utils) => Config | void)>;
3
- export {};
@@ -1,7 +0,0 @@
1
- import type { Alias } from '@modern-js/utils';
2
- import type { ConfigChain } from './share';
3
- export interface SourceUserConfig {
4
- alias?: ConfigChain<Alias>;
5
- enableAsyncEntry?: boolean;
6
- }
7
- export type SourceNormalizedConfig = SourceUserConfig;
@@ -1,2 +0,0 @@
1
- export type ToolsUserConfig = Record<string, never>;
2
- export type ToolsNormalizedConfig = ToolsUserConfig;
@@ -1,4 +0,0 @@
1
- export * from './config';
2
- export * from './plugins';
3
- export * from './render';
4
- export * from './server';
@@ -1,57 +0,0 @@
1
- import type { CacheOption, Container, HttpMethodDecider, MiddlewareContext, ServerRoute } from '@modern-js/types';
2
- import type { Context, MiddlewareHandler } from 'hono';
3
- import type { UserConfig } from '../config';
4
- import type { Render } from '../render';
5
- import type { ServerPlugin } from './plugin';
6
- export type { FileChangeEvent, ResetEvent } from '@modern-js/plugin';
7
- export type FallbackReason = 'error' | 'header' | 'query' | `header,${string}`;
8
- export type FallbackInput = {
9
- reason: FallbackReason;
10
- error: unknown;
11
- };
12
- export type OnFallback = (reason: FallbackReason, error?: unknown) => Promise<void>;
13
- export type APIServerStartInput = {
14
- pwd: string;
15
- prefix?: string;
16
- httpMethodDecider?: HttpMethodDecider;
17
- config?: {
18
- middleware?: Array<any>;
19
- };
20
- render?: Render | null;
21
- };
22
- export type WebServerStartInput = {
23
- pwd: string;
24
- config: Record<string, any>;
25
- };
26
- export type WebAdapter = (ctx: MiddlewareContext) => void | Promise<void>;
27
- /** Plugin Api */
28
- type MiddlewareOrder = 'pre' | 'post' | 'default';
29
- export type MiddlewareObj = {
30
- name: string;
31
- path?: string;
32
- method?: 'options' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all';
33
- handler: MiddlewareHandler | MiddlewareHandler[];
34
- before?: Array<MiddlewareObj['name']>;
35
- order?: MiddlewareOrder;
36
- };
37
- export type ServerMiddleware = MiddlewareObj;
38
- export interface GetRenderHandlerOptions {
39
- pwd: string;
40
- routes: ServerRoute[];
41
- config: UserConfig;
42
- onFallback?: OnFallback;
43
- cacheConfig?: CacheConfig;
44
- staticGenerate?: boolean;
45
- metaName?: string;
46
- }
47
- export type CacheConfig = {
48
- strategy: CacheOption;
49
- container?: Container;
50
- };
51
- export type ServerErrorHandler = (err: Error, c: Context) => Promise<any> | any;
52
- export type ServerConfig = {
53
- renderMiddlewares?: MiddlewareObj[];
54
- middlewares?: MiddlewareObj[];
55
- plugins?: ServerPlugin[];
56
- onError?: ServerErrorHandler;
57
- } & UserConfig;
@@ -1,2 +0,0 @@
1
- export type { APIServerStartInput, CacheConfig, FallbackInput, FallbackReason, FileChangeEvent, GetRenderHandlerOptions, MiddlewareObj, OnFallback, ServerConfig, ServerMiddleware, WebServerStartInput, } from './base';
2
- export * from './plugin';
@@ -1,31 +0,0 @@
1
- import type { AsyncHook, AsyncPipelineHook, ServerContext as BaseServerContext, ServerPlugin as BaseServerPlugin, ServerPluginAPI as BaseServerPluginAPI, ServerPluginExtends as BaseServerPluginExtends } from '@modern-js/plugin';
2
- import type { Hooks } from '@modern-js/plugin/server';
3
- import type { AfterMatchContext, AfterRenderContext, AfterStreamingRenderContext } from '@modern-js/types';
4
- import type { MiddlewareHandler } from 'hono';
5
- import type { APIServerStartInput, FallbackInput, MiddlewareObj, ServerConfig, WebAdapter, WebServerStartInput } from './base';
6
- export type FallbackFn = (input: FallbackInput) => Promise<FallbackInput>;
7
- export type PrepareWebServerFn = (input: WebServerStartInput) => Promise<WebAdapter | null>;
8
- export type PrepareApiServerFn = (input: APIServerStartInput) => Promise<MiddlewareHandler>;
9
- export type AfterMatchFn = (ctx: AfterMatchContext) => Promise<any>;
10
- export type AfterRenderFn = (ctx: AfterRenderContext) => Promise<any>;
11
- export type AfterStreamingRenderContextFn = (ctx: AfterStreamingRenderContext) => Promise<AfterStreamingRenderContext>;
12
- export interface ServerPluginExtends extends BaseServerPluginExtends {
13
- config: ServerConfig;
14
- extendContext: {
15
- middlewares: MiddlewareObj[];
16
- renderMiddlewares: MiddlewareObj[];
17
- [key: string]: any;
18
- };
19
- extendHooks: {
20
- prepareWebServer: AsyncPipelineHook<PrepareWebServerFn>;
21
- fallback: AsyncHook<FallbackFn>;
22
- prepareApiServer: AsyncPipelineHook<PrepareApiServerFn>;
23
- afterMatch: AsyncPipelineHook<AfterMatchFn>;
24
- afterRender: AsyncPipelineHook<AfterRenderFn>;
25
- afterStreamingRender: AsyncPipelineHook<AfterStreamingRenderContextFn>;
26
- };
27
- }
28
- export type ServerPlugin = BaseServerPlugin<ServerPluginExtends>;
29
- export type ServerContext = BaseServerContext<ServerPluginExtends> & ServerPluginExtends['extendContext'];
30
- export type ServerPluginHooks = Hooks<ServerPluginExtends> & ServerPluginExtends['extendHooks'];
31
- export type ServerPluginAPI = BaseServerPluginAPI<ServerPluginExtends> & ServerPluginExtends['extendApi'];
@@ -1,24 +0,0 @@
1
- import type { Monitors, Reporter, ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types';
2
- import type { NodeRequest } from '@modern-js/types/server';
3
- import type { ServerManifest } from './server';
4
- export interface RenderOptions {
5
- monitors: Monitors;
6
- loaderContext?: Map<string, unknown>;
7
- /** ssr render html templates */
8
- templates: Record<string, string>;
9
- /** Communicating with custom server hook & modern ssr runtime. */
10
- locals?: Record<string, any>;
11
- /** @deprecated */
12
- reporter?: Reporter;
13
- /** For compat rewrite MPA, while not modify request */
14
- matchPathname?: string;
15
- /** For compat rewrite MPA, while not modify request */
16
- matchEntryName?: string;
17
- serverManifest: ServerManifest;
18
- rscServerManifest?: RscServerManifest;
19
- rscClientManifest?: RscClientManifest;
20
- rscSSRManifest?: RscSSRManifest;
21
- nodeReq?: NodeRequest;
22
- contextForceCSR?: string;
23
- }
24
- export type Render = (request: Request, options: RenderOptions) => Promise<Response>;
@@ -1,48 +0,0 @@
1
- import type { Reporter, ServerRoute } from '@modern-js/types';
2
- import type { Monitors, ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types/server';
3
- import type { ServerUserConfig, SourceUserConfig } from './config';
4
- export type Resource = {
5
- loadableStats: Record<string, any>;
6
- routeManifest: Record<string, any>;
7
- route: ServerRoute;
8
- htmlTemplate: string;
9
- entryName: string;
10
- };
11
- export type Params = Record<string, any>;
12
- export type RequestHandlerConfig = {
13
- nonce?: string;
14
- crossorigin?: boolean | 'anonymous' | 'use-credentials';
15
- scriptLoading?: 'defer' | 'blocking' | 'module' | 'async';
16
- inlineStyles?: boolean | RegExp;
17
- inlineScripts?: boolean | RegExp;
18
- ssr?: ServerUserConfig['ssr'];
19
- ssrByEntries?: ServerUserConfig['ssrByEntries'];
20
- useJsonScript?: ServerUserConfig['useJsonScript'];
21
- enableAsyncEntry?: SourceUserConfig['enableAsyncEntry'];
22
- };
23
- export type LoaderContext = Map<string, any>;
24
- export type OnError = (err: unknown, key?: string) => void;
25
- export type OnTiming = (name: string, dur: number) => void;
26
- export type RequestHandlerOptions = {
27
- resource: Resource;
28
- config: RequestHandlerConfig;
29
- params: Params;
30
- loaderContext: LoaderContext;
31
- html?: string;
32
- rscServerManifest?: RscServerManifest;
33
- rscClientManifest?: RscClientManifest;
34
- rscSSRManifest?: RscSSRManifest;
35
- RSCRoot?: any;
36
- rscRoot?: any;
37
- serverPayload?: any;
38
- /** @deprecated */
39
- locals?: Record<string, any>;
40
- /** @deprecated */
41
- staticGenerate?: boolean;
42
- /** @deprecated ssr runtime code need reporter instance */
43
- reporter?: Reporter;
44
- monitors: Monitors;
45
- onError: OnError;
46
- onTiming: OnTiming;
47
- };
48
- export type RequestHandler = (request: Request, options: RequestHandlerOptions) => Promise<Response>;
@@ -1,67 +0,0 @@
1
- import type { Logger, Metrics, Monitors, NestedRoute, Reporter, ServerRoute } from '@modern-js/types';
2
- import type { ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types/server';
3
- import type { RequestHandler as BundleRequestHandler, OnError, OnTiming, RequestHandlerOptions, Resource } from './requestHandler';
4
- export type RequestHandler = (request: Request, ...args: any[]) => Response | Promise<Response>;
5
- export type ServerLoaderBundle = {
6
- routes: NestedRoute[];
7
- handleRequest: (options: {
8
- request: Request;
9
- serverRoutes: ServerRoute[];
10
- routes: NestedRoute[];
11
- context: {
12
- monitors: Monitors;
13
- reporter?: Reporter;
14
- loaderContext?: Map<string, unknown>;
15
- };
16
- onError?: OnError;
17
- onTiming?: OnTiming;
18
- }) => Promise<any>;
19
- };
20
- export type RscPayloadHandlerOptions = Omit<RequestHandlerOptions, 'resource'> & {
21
- resource: Omit<Resource, 'htmlTemplate'>;
22
- };
23
- type ServerRenderBundle = {
24
- requestHandler?: Promise<BundleRequestHandler>;
25
- handleAction?: (req: Request) => Promise<Response>;
26
- rscPayloadHandler?: (req: Request, options: RscPayloadHandlerOptions) => Promise<Response>;
27
- renderRscStreamHandler?: (req: Request, options: RscPayloadHandlerOptions) => Promise<Response>;
28
- };
29
- export type ServerManifest = {
30
- loaderBundles?: Record<string, ServerLoaderBundle>;
31
- renderBundles?: Record<string, ServerRenderBundle>;
32
- loadableStats?: Record<string, any>;
33
- routeManifest?: Record<string, any>;
34
- nestedRoutesJson?: Record<string, any>;
35
- };
36
- type ServerVariables = {
37
- /** @deprecated */
38
- logger: Logger;
39
- /** @deprecated */
40
- reporter?: Reporter;
41
- /** @deprecated */
42
- metrics?: Metrics;
43
- monitors: Monitors;
44
- serverManifest?: ServerManifest;
45
- rscServerManifest?: RscServerManifest;
46
- rscClientManifest?: RscClientManifest;
47
- rscSSRManifest?: RscSSRManifest;
48
- templates?: Record<string, string>;
49
- matchPathname?: string;
50
- matchEntryName?: string;
51
- /**
52
- * Communicating with custom server hook & modern ssrContext.
53
- *
54
- * Produce by custom server.
55
- * Custom by ssrRuntime.
56
- */
57
- locals?: Record<string, any>;
58
- /**
59
- * The current matched route, now only expose entryName field.
60
- */
61
- route: Required<Pick<ServerRoute, 'entryName' | 'urlPath'>>;
62
- forceCSR?: string;
63
- };
64
- export type ServerEnv = {
65
- Variables: ServerVariables;
66
- };
67
- export type { Context, Env, HonoRequest, MiddlewareHandler, MiddlewareHandler as Middleware, Next, } from 'hono';
@@ -1,3 +0,0 @@
1
- import type { ServerRoute } from '@modern-js/types';
2
- export declare const sortRoutes: (route1: ServerRoute, route2: ServerRoute) => number;
3
- export declare const uniqueKeyByRoute: (route: ServerRoute) => string;
@@ -1,2 +0,0 @@
1
- export declare const getRuntimeEnv: () => "node" | "other";
2
- export declare const checkIsProd: () => boolean;
@@ -1,8 +0,0 @@
1
- import type { Monitors } from '@modern-js/types';
2
- export declare const createErrorHtml: (status: number) => string;
3
- export declare enum ErrorDigest {
4
- ENOTF = "Page could not be found",
5
- EINTER = "Internal server error",
6
- ERENDER = "SSR render fallback"
7
- }
8
- export declare function onError(digest: ErrorDigest, error: Error | string, monitors?: Monitors, req?: Request): void;
@@ -1,9 +0,0 @@
1
- export * from './entry';
2
- export * from './env';
3
- export * from './error';
4
- export * from './middlewareCollector';
5
- export * from './publicDir';
6
- export * from './request';
7
- export * from './serverConfig';
8
- export * from './transformStream';
9
- export * from './warmup';