@bleedingdev/modern-js-server-core 3.8.3-ultramodern.6 → 3.9.0-ultramodern.10

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 (94) hide show
  1. package/dist/cjs/adapters/node/index.js +4 -0
  2. package/dist/cjs/adapters/node/plugins/static.js +107 -29
  3. package/dist/cjs/index.js +10 -34
  4. package/dist/cjs/plugins/compat/index.js +1 -0
  5. package/dist/cjs/serverBase.js +58 -17
  6. package/dist/cjs/utils/error.js +0 -10
  7. package/dist/esm/adapters/node/index.mjs +1 -0
  8. package/dist/esm/adapters/node/plugins/static.mjs +107 -32
  9. package/dist/esm/index.mjs +1 -1
  10. package/dist/esm/plugins/compat/index.mjs +1 -0
  11. package/dist/esm/plugins/render/render.mjs +4 -5
  12. package/dist/esm/serverBase.mjs +58 -17
  13. package/dist/esm/utils/error.mjs +0 -1
  14. package/dist/esm-node/adapters/node/index.mjs +1 -0
  15. package/dist/esm-node/adapters/node/plugins/static.mjs +107 -32
  16. package/dist/esm-node/index.mjs +1 -1
  17. package/dist/esm-node/plugins/compat/index.mjs +1 -0
  18. package/dist/esm-node/plugins/render/render.mjs +4 -3
  19. package/dist/esm-node/serverBase.mjs +58 -17
  20. package/dist/esm-node/utils/error.mjs +0 -1
  21. package/dist/types/adapters/node/helper/index.d.ts +6 -6
  22. package/dist/types/adapters/node/helper/loadCache.d.ts +1 -1
  23. package/dist/types/adapters/node/helper/loadConfig.d.ts +1 -1
  24. package/dist/types/adapters/node/helper/loadEnv.d.ts +1 -1
  25. package/dist/types/adapters/node/helper/loadPlugin.d.ts +1 -1
  26. package/dist/types/adapters/node/helper/utils.d.ts +1 -1
  27. package/dist/types/adapters/node/hono.d.ts +2 -2
  28. package/dist/types/adapters/node/index.d.ts +7 -5
  29. package/dist/types/adapters/node/node.d.ts +1 -1
  30. package/dist/types/adapters/node/plugins/index.d.ts +3 -3
  31. package/dist/types/adapters/node/plugins/nodeServer.d.ts +1 -1
  32. package/dist/types/adapters/node/plugins/resource.d.ts +1 -1
  33. package/dist/types/adapters/node/plugins/static.d.ts +43 -5
  34. package/dist/types/helper.d.ts +1 -1
  35. package/dist/types/index.d.ts +13 -14
  36. package/dist/types/plugins/compat/hooks.d.ts +1 -1
  37. package/dist/types/plugins/compat/index.d.ts +2 -2
  38. package/dist/types/plugins/default.d.ts +2 -2
  39. package/dist/types/plugins/favicon.d.ts +1 -1
  40. package/dist/types/plugins/index.d.ts +8 -8
  41. package/dist/types/plugins/log.d.ts +1 -1
  42. package/dist/types/plugins/middlewares.d.ts +1 -1
  43. package/dist/types/plugins/monitors.d.ts +1 -1
  44. package/dist/types/plugins/processedBy.d.ts +1 -1
  45. package/dist/types/plugins/render/csrRscRender.d.ts +1 -1
  46. package/dist/types/plugins/render/dataHandler.d.ts +1 -1
  47. package/dist/types/plugins/render/index.d.ts +2 -2
  48. package/dist/types/plugins/render/inject.d.ts +1 -1
  49. package/dist/types/plugins/render/render.d.ts +2 -2
  50. package/dist/types/plugins/render/renderRscHandler.d.ts +1 -1
  51. package/dist/types/plugins/render/serverActionHandler.d.ts +1 -1
  52. package/dist/types/plugins/render/ssrCache.d.ts +1 -1
  53. package/dist/types/plugins/render/ssrRender.d.ts +2 -2
  54. package/dist/types/plugins/render/utils.d.ts +2 -2
  55. package/dist/types/plugins/route.d.ts +1 -1
  56. package/dist/types/serverBase.d.ts +9 -3
  57. package/dist/types/types/config/bff.d.ts +4 -15
  58. package/dist/types/types/config/index.d.ts +14 -14
  59. package/dist/types/types/config/server.d.ts +1 -3
  60. package/dist/types/types/config/source.d.ts +1 -1
  61. package/dist/types/types/index.d.ts +4 -4
  62. package/dist/types/types/plugins/base.d.ts +3 -3
  63. package/dist/types/types/plugins/index.d.ts +2 -2
  64. package/dist/types/types/plugins/plugin.d.ts +16 -2
  65. package/dist/types/types/render.d.ts +1 -1
  66. package/dist/types/types/requestHandler.d.ts +3 -4
  67. package/dist/types/types/server.d.ts +1 -1
  68. package/dist/types/utils/error.d.ts +0 -2
  69. package/dist/types/utils/index.d.ts +9 -9
  70. package/dist/types/utils/publicDir.d.ts +1 -1
  71. package/dist/types/utils/serverConfig.d.ts +1 -1
  72. package/package.json +8 -9
  73. package/dist/cjs/adapters/node/plugins/staticModuleFederation.js +0 -173
  74. package/dist/cjs/adapters/node/plugins/staticPrecompressed.js +0 -152
  75. package/dist/cjs/adapters/node/plugins/staticServing.js +0 -206
  76. package/dist/cjs/types/config/bffRuntime.js +0 -18
  77. package/dist/cjs/types/config/serverTelemetry.js +0 -18
  78. package/dist/esm/adapters/node/plugins/staticModuleFederation.mjs +0 -104
  79. package/dist/esm/adapters/node/plugins/staticPrecompressed.mjs +0 -111
  80. package/dist/esm/adapters/node/plugins/staticServing.mjs +0 -152
  81. package/dist/esm/types/config/bffRuntime.mjs +0 -0
  82. package/dist/esm/types/config/serverTelemetry.mjs +0 -0
  83. package/dist/esm-node/adapters/node/plugins/staticModuleFederation.mjs +0 -105
  84. package/dist/esm-node/adapters/node/plugins/staticPrecompressed.mjs +0 -112
  85. package/dist/esm-node/adapters/node/plugins/staticServing.mjs +0 -153
  86. package/dist/esm-node/types/config/bffRuntime.mjs +0 -1
  87. package/dist/esm-node/types/config/serverTelemetry.mjs +0 -1
  88. package/dist/types/adapters/node/plugins/staticModuleFederation.d.ts +0 -13
  89. package/dist/types/adapters/node/plugins/staticPrecompressed.d.ts +0 -13
  90. package/dist/types/adapters/node/plugins/staticServing.d.ts +0 -25
  91. package/dist/types/types/config/bffRuntime.d.ts +0 -116
  92. package/dist/types/types/config/serverTelemetry.d.ts +0 -319
  93. /package/dist/esm/{rslib-runtime.mjs → rslib-runtime~1.mjs} +0 -0
  94. /package/dist/esm-node/{rslib-runtime.mjs → rslib-runtime~0.mjs} +0 -0
@@ -1,2 +1,2 @@
1
- import type { CacheConfig } from '../../../types';
1
+ import type { CacheConfig } from '../../../types/index.js';
2
2
  export declare function loadCacheConfig(pwd: string): Promise<CacheConfig | undefined>;
@@ -1,3 +1,3 @@
1
- import type { CliConfig, ServerConfig, UserConfig } from '../../../types';
1
+ import type { CliConfig, ServerConfig, UserConfig } from '../../../types/index.js';
2
2
  export declare function loadServerRuntimeConfig(serverConfigPath: string): Promise<ServerConfig | undefined>;
3
3
  export declare function loadServerCliConfig(pwd: string, defaultConfig?: UserConfig): CliConfig;
@@ -1,3 +1,3 @@
1
- import type { ServerBaseOptions } from '../../../serverBase';
1
+ import type { ServerBaseOptions } from '../../../serverBase.js';
2
2
  /** 读取 .env.{process.env.MODERN_ENV} 文件,加载环境变量 */
3
3
  export declare function loadServerEnv(options: ServerBaseOptions): Promise<void>;
@@ -1,3 +1,3 @@
1
1
  import type { ServerPlugin } from '@modern-js/types';
2
- import type { ServerPlugin as ServerPluginInstance } from '../../../types';
2
+ import type { ServerPlugin as ServerPluginInstance } from '../../../types/index.js';
3
3
  export declare function loadServerPlugins(serverPlugins: ServerPlugin[], appDirectory: string): Promise<ServerPluginInstance[]>;
@@ -1,5 +1,5 @@
1
1
  import type { ClientManifest, NodeRequest, NodeResponse, SSRManifest } from '@modern-js/types/server';
2
- import type { HonoRequest, ServerManifest } from '../../../types';
2
+ import type { HonoRequest, ServerManifest } from '../../../types/index.js';
3
3
  type ExtendedNodeRequest = NodeRequest & {
4
4
  __honoRequest?: HonoRequest;
5
5
  __templates?: Record<string, string>;
@@ -1,6 +1,6 @@
1
1
  import type { NodeRequest, NodeResponse } from '@modern-js/types/server';
2
- import type { Context, Middleware, Next, ServerEnv } from '../../types';
3
- import { type NodeBindings } from './helper';
2
+ import type { Context, Middleware, Next, ServerEnv } from '../../types/index.js';
3
+ import { type NodeBindings } from './helper/index.js';
4
4
  export type ServerNodeEnv = {
5
5
  Bindings: NodeBindings;
6
6
  };
@@ -1,5 +1,7 @@
1
- export { loadCacheConfig, loadServerCliConfig, loadServerEnv, loadServerPlugins, loadServerRuntimeConfig, } from './helper';
2
- export type { ServerNodeContext, ServerNodeMiddleware } from './hono';
3
- export { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid, } from './hono';
4
- export { createNodeServer, createWebRequest, sendResponse, } from './node';
5
- export { getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, serverStaticPlugin, } from './plugins';
1
+ export { loadCacheConfig, loadServerCliConfig, loadServerEnv, loadServerPlugins, loadServerRuntimeConfig, } from './helper/index.js';
2
+ export type { ServerNodeContext, ServerNodeMiddleware } from './hono.js';
3
+ export { connectMid2HonoMid, connectMockMid2HonoMid, httpCallBack2HonoMid, } from './hono.js';
4
+ export { createNodeServer, createWebRequest, sendResponse, } from './node.js';
5
+ export { getHtmlTemplates, getServerManifest, injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, serverStaticPlugin, } from './plugins/index.js';
6
+ export type { ServerStaticPluginOptions, ServeStaticAsset, StaticAsset, StaticAssetRequest, StaticAssetResponder, StaticPublicFallbackResponder, } from './plugins/static.js';
7
+ export { serveStaticAsset } from './plugins/static.js';
@@ -2,7 +2,7 @@ import { type Server as NodeServer } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
3
  import type { Server as NodeHttpsServer } from 'node:https';
4
4
  import type { NodeRequest, NodeResponse } from '@modern-js/types/server';
5
- import type { RequestHandler } from '../../types';
5
+ import type { RequestHandler } from '../../types/index.js';
6
6
  export declare const createWebRequest: (req: NodeRequest, res: NodeResponse, body?: BodyInit) => Request;
7
7
  export declare const sendResponse: (response: Response, res: NodeResponse) => Promise<void>;
8
8
  declare const getRequestListener: (handler: RequestHandler) => (req: NodeRequest, res: NodeResponse) => Promise<void>;
@@ -1,3 +1,3 @@
1
- export * from './nodeServer';
2
- export * from './resource';
3
- export * from './static';
1
+ export * from './nodeServer.js';
2
+ export * from './resource.js';
3
+ export * from './static.js';
@@ -1,6 +1,6 @@
1
1
  import type { Server as NodeServer } from 'node:http';
2
2
  import type { Http2SecureServer } from 'node:http2';
3
- import type { ServerPlugin } from '../../../types';
3
+ import type { ServerPlugin } from '../../../types/index.js';
4
4
  export declare const injectNodeSeverPlugin: ({ nodeServer, }: {
5
5
  nodeServer: NodeServer | Http2SecureServer;
6
6
  }) => ServerPlugin;
@@ -1,5 +1,5 @@
1
1
  import type { Monitors, ServerRoute } from '@modern-js/types';
2
- import type { Middleware, ServerEnv, ServerManifest, ServerPlugin } from '../../../types';
2
+ import type { Middleware, ServerEnv, ServerManifest, ServerPlugin } from '../../../types/index.js';
3
3
  export declare function getHtmlTemplates(pwd: string, routes: ServerRoute[]): Promise<Record<string, string>>;
4
4
  export declare function injectTemplates(pwd: string, routes?: ServerRoute[], htmlTemplatePromise?: ReturnType<typeof getHtmlTemplates>): Middleware<ServerEnv>;
5
5
  export declare function getServerManifest(pwd: string, routes: ServerRoute[], monitors?: Monitors): Promise<ServerManifest>;
@@ -1,12 +1,50 @@
1
1
  import type { ServerRoute } from '@modern-js/types';
2
- import type { HtmlNormalizedConfig, Middleware, OutputNormalizedConfig, ServerNormalizedConfig, ServerPlugin } from '../../../types';
3
- export declare const serverStaticPlugin: () => ServerPlugin;
2
+ import type { HtmlNormalizedConfig, Middleware, OutputNormalizedConfig, ServerNormalizedConfig, ServerPlugin } from '../../../types/index.js';
3
+ /** A selected file and the native response conventions to use for it. */
4
+ export type StaticAsset = {
5
+ filename: string;
6
+ kind: 'static' | 'public';
7
+ /** An alternate representation retains the original resource's MIME type. */
8
+ mimeFilename?: string;
9
+ responseHeaders?: ServerRoute['responseHeaders'];
10
+ /** True uses the served byte length; omitted preserves native length defaults. */
11
+ contentLength?: boolean;
12
+ /** Optional lexical containment boundary. Use real paths to contain symlinks. */
13
+ root?: string;
14
+ /** Resolve symlinks before checking root. Implies a regular file is required. */
15
+ realpath?: boolean;
16
+ };
17
+ export type StaticAssetRequest = {
18
+ root: string;
19
+ pathPrefix: string;
20
+ };
21
+ /** Native serving of the selected file, optionally choosing another representation. */
22
+ export type ServeStaticAsset = (representation?: Partial<Pick<StaticAsset, 'filename' | 'contentLength'>>) => Promise<Response | null>;
23
+ /**
24
+ * Trusted server extension. Undefined uses the native file; null skips it.
25
+ * A returned response is final. Exceptions use the normal server error handler.
26
+ */
27
+ export type StaticAssetResponder = (context: Parameters<Middleware>[0], asset: StaticAsset, serve: ServeStaticAsset, request: StaticAssetRequest) => Response | null | undefined | Promise<Response | null | undefined>;
28
+ /**
29
+ * Handles requests outside the native static pattern. The continuation only
30
+ * tries native public routes; it returns null on a miss and never calls the next
31
+ * middleware. Returning null from this hook continues the middleware chain.
32
+ */
33
+ export type StaticPublicFallbackResponder = (context: Parameters<Middleware>[0], respondPublic: () => Promise<Response | null>, request: StaticAssetRequest) => Response | null | Promise<Response | null>;
34
+ /** Read a selected file using native readers, MIME, headers and body conversion. */
35
+ export declare function serveStaticAsset(context: Parameters<Middleware>[0], asset: StaticAsset, respond?: (asset: StaticAsset, serve: ServeStaticAsset) => Promise<Response | null>): Promise<Response | null>;
36
+ export type ServerStaticPluginOptions = {
37
+ respondAsset?: StaticAssetResponder;
38
+ respondPublicFallback?: StaticPublicFallbackResponder;
39
+ };
40
+ export declare const serverStaticPlugin: (options?: ServerStaticPluginOptions) => ServerPlugin;
4
41
  export type PublicMiddlwareOptions = {
5
42
  pwd: string;
6
43
  routes: ServerRoute[];
7
- };
8
- export declare function createPublicMiddleware({ pwd, routes, }: PublicMiddlwareOptions): Middleware;
9
- export interface ServerStaticOptions {
44
+ pathPrefix?: string;
45
+ } & ServerStaticPluginOptions;
46
+ export declare function createPublicMiddleware({ pwd, routes, pathPrefix, respondAsset, respondPublicFallback, }: PublicMiddlwareOptions): Middleware;
47
+ export interface ServerStaticOptions extends ServerStaticPluginOptions {
10
48
  pwd: string;
11
49
  output: OutputNormalizedConfig;
12
50
  html: HtmlNormalizedConfig;
@@ -1,4 +1,4 @@
1
- import type { Context } from './types';
1
+ import type { Context } from './types/index.js';
2
2
  type LoaderContext = Map<string, unknown>;
3
3
  type Var = {
4
4
  loaderContext: LoaderContext;
@@ -1,15 +1,14 @@
1
1
  export { Hono } from 'hono';
2
- export { AGGRED_DIR } from './constants';
3
- export { run, useHonoContext } from './context';
4
- export { getLoaderCtx } from './helper';
5
- export * from './plugins';
6
- export type { ServerBase, ServerBaseOptions } from './serverBase';
7
- export { createServerBase } from './serverBase';
8
- export type { Context, HonoRequest as InternalRequest, Middleware, MiddlewareHandler, Next, ServerEnv, ServerLoaderBundle, ServerManifest, } from './types';
9
- export * from './types/config';
10
- export * from './types/plugins';
11
- export * from './types/render';
12
- export * from './types/requestHandler';
13
- export type { SafeFailureEnvelope, SafeFailureHttpResult } from './utils';
14
- export { createErrorHtml, createSafeFailureHttpResult, createSafeJsonFailureResponse, ErrorDigest, getSafeFailureStatus, onError, } from './utils';
15
- export { getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, resolvePublicDirPaths, } from './utils/publicDir';
2
+ export { AGGRED_DIR } from './constants.js';
3
+ export { run, useHonoContext } from './context.js';
4
+ export { getLoaderCtx } from './helper.js';
5
+ export * from './plugins/index.js';
6
+ export type { ServerBase, ServerBaseOptions } from './serverBase.js';
7
+ export { createServerBase } from './serverBase.js';
8
+ export type { Context, HonoRequest as InternalRequest, Middleware, MiddlewareHandler, Next, ServerEnv, ServerLoaderBundle, ServerManifest, } from './types/index.js';
9
+ export * from './types/config/index.js';
10
+ export * from './types/plugins/index.js';
11
+ export * from './types/render.js';
12
+ export * from './types/requestHandler.js';
13
+ export { createErrorHtml, ErrorDigest, onError, } from './utils/index.js';
14
+ export { getPublicDirConfig, getPublicDirPatterns, getPublicDirRoutePrefixes, normalizePublicDir, normalizePublicDirPath, resolvePublicDirPaths, } from './utils/publicDir.js';
@@ -1,5 +1,5 @@
1
1
  import type { InternalServerContext } from '@modern-js/plugin';
2
- import type { ServerPluginExtends } from '../../types';
2
+ import type { ServerPluginExtends } from '../../types/index.js';
3
3
  /**
4
4
  * old plugin useHookRunners function result
5
5
  */
@@ -1,3 +1,3 @@
1
- import type { ServerPlugin } from '../../types';
2
- export { handleSetupResult } from './hooks';
1
+ import type { ServerPlugin } from '../../types/index.js';
2
+ export { handleSetupResult } from './hooks.js';
3
3
  export declare const compatPlugin: () => ServerPlugin;
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from '@modern-js/types';
2
- import type { ServerPlugin } from '../types';
3
- import { type InjectRenderHandlerOptions } from './render';
2
+ import type { ServerPlugin } from '../types/index.js';
3
+ import { type InjectRenderHandlerOptions } from './render/index.js';
4
4
  export type CreateDefaultPluginsOptions = InjectRenderHandlerOptions & {
5
5
  logger?: Logger | false;
6
6
  };
@@ -1,2 +1,2 @@
1
- import type { ServerPlugin } from '../types';
1
+ import type { ServerPlugin } from '../types/index.js';
2
2
  export declare const faviconPlugin: () => ServerPlugin;
@@ -1,8 +1,8 @@
1
- export { compatPlugin, handleSetupResult } from './compat';
2
- export { type CreateDefaultPluginsOptions, createDefaultPlugins, } from './default';
3
- export { faviconPlugin } from './favicon';
4
- export { logPlugin } from './log';
5
- export { injectConfigMiddlewarePlugin } from './middlewares';
6
- export { injectloggerPlugin, injectServerTiming } from './monitors';
7
- export { processedByPlugin } from './processedBy';
8
- export { getRenderHandler, type InjectRenderHandlerOptions, injectRenderHandlerPlugin, renderPlugin, } from './render';
1
+ export { compatPlugin, handleSetupResult } from './compat/index.js';
2
+ export { type CreateDefaultPluginsOptions, createDefaultPlugins, } from './default.js';
3
+ export { faviconPlugin } from './favicon.js';
4
+ export { logPlugin } from './log.js';
5
+ export { injectConfigMiddlewarePlugin } from './middlewares.js';
6
+ export { injectloggerPlugin, injectServerTiming } from './monitors.js';
7
+ export { processedByPlugin } from './processedBy.js';
8
+ export { getRenderHandler, type InjectRenderHandlerOptions, injectRenderHandlerPlugin, renderPlugin, } from './render/index.js';
@@ -1,2 +1,2 @@
1
- import type { ServerPlugin } from '../types';
1
+ import type { ServerPlugin } from '../types/index.js';
2
2
  export declare const logPlugin: () => ServerPlugin;
@@ -1,2 +1,2 @@
1
- import type { MiddlewareObj, ServerPlugin } from '../types';
1
+ import type { MiddlewareObj, ServerPlugin } from '../types/index.js';
2
2
  export declare const injectConfigMiddlewarePlugin: (configMiddlewares?: MiddlewareObj[], configRenderMiddlewares?: MiddlewareObj[]) => ServerPlugin;
@@ -1,5 +1,5 @@
1
1
  import type { Logger } from '@modern-js/types';
2
- import type { Context, Next, ServerEnv, ServerPlugin } from '../types';
2
+ import type { Context, Next, ServerEnv, ServerPlugin } from '../types/index.js';
3
3
  export declare const initMonitorsPlugin: () => ServerPlugin;
4
4
  export declare const injectloggerPlugin: (inputLogger: Logger) => ServerPlugin;
5
5
  export declare const injectServerTiming: () => ServerPlugin;
@@ -1,2 +1,2 @@
1
- import type { ServerPlugin } from '../types';
1
+ import type { ServerPlugin } from '../types/index.js';
2
2
  export declare const processedByPlugin: () => ServerPlugin;
@@ -1,2 +1,2 @@
1
- import type { SSRRenderOptions } from './ssrRender';
1
+ import type { SSRRenderOptions } from './ssrRender.js';
2
2
  export declare const csrRscRender: (req: Request, options: SSRRenderOptions) => Promise<Response>;
@@ -1,5 +1,5 @@
1
1
  import type { ServerRoute } from '@modern-js/types';
2
- import type { SSRRenderOptions } from './ssrRender';
2
+ import type { SSRRenderOptions } from './ssrRender.js';
3
3
  export declare const dataHandler: (request: Request, { routeInfo, serverRoutes, monitors, onError, onTiming, serverManifest, loaderContext, serverContext, reporter, }: SSRRenderOptions & {
4
4
  serverRoutes: ServerRoute[];
5
5
  }) => Promise<Response | void>;
@@ -1,3 +1,3 @@
1
- import type { ServerPlugin } from '../../types';
2
- export * from './inject';
1
+ import type { ServerPlugin } from '../../types/index.js';
2
+ export * from './inject.js';
3
3
  export declare const renderPlugin: () => ServerPlugin;
@@ -1,4 +1,4 @@
1
- import type { CacheConfig, GetRenderHandlerOptions, Render, ServerPlugin } from '../../types';
1
+ import type { CacheConfig, GetRenderHandlerOptions, Render, ServerPlugin } from '../../types/index.js';
2
2
  export interface InjectRenderHandlerOptions {
3
3
  staticGenerate?: boolean;
4
4
  cacheConfig?: CacheConfig;
@@ -1,7 +1,7 @@
1
1
  import type { ServerRoute } from '@modern-js/types';
2
2
  import type { Router } from 'hono/router';
3
- import type { CacheConfig, Render, UserConfig } from '../../types';
4
- import type { Params } from '../../types/requestHandler';
3
+ import type { CacheConfig, Render, UserConfig } from '../../types/index.js';
4
+ import type { Params } from '../../types/requestHandler.js';
5
5
  interface CreateRenderOptions {
6
6
  pwd: string;
7
7
  routes: ServerRoute[];
@@ -1,2 +1,2 @@
1
- import type { SSRRenderOptions } from './ssrRender';
1
+ import type { SSRRenderOptions } from './ssrRender.js';
2
2
  export declare const renderRscHandler: (req: Request, options: SSRRenderOptions) => Promise<Response>;
@@ -1,2 +1,2 @@
1
- import type { SSRRenderOptions } from './ssrRender';
1
+ import type { SSRRenderOptions } from './ssrRender.js';
2
2
  export declare const serverActionHandler: (req: Request, { serverManifest, routeInfo, rscClientManifest }: SSRRenderOptions) => Promise<Response>;
@@ -1,6 +1,6 @@
1
1
  import type { CacheControl, CacheOption, Container } from '@modern-js/types';
2
2
  import type { NodeRequest } from '@modern-js/types/server';
3
- import type { RequestHandler, RequestHandlerOptions } from '../../types/requestHandler';
3
+ import type { RequestHandler, RequestHandlerOptions } from '../../types/requestHandler.js';
4
4
  export type CacheStatus = 'hit' | 'stale' | 'expired' | 'miss';
5
5
  type MaybeAsync<T> = Promise<T> | T;
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import type { Reporter, ServerRoute } from '@modern-js/types';
2
2
  import type { Monitors, NodeRequest, ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types/server';
3
- import type { CacheConfig, Context, ServerManifest, UserConfig } from '../../types';
4
- import type { OnError, OnTiming, Params } from '../../types/requestHandler';
3
+ import type { CacheConfig, Context, ServerManifest, UserConfig } from '../../types/index.js';
4
+ import type { OnError, OnTiming, Params } from '../../types/requestHandler.js';
5
5
  export interface SSRRenderOptions {
6
6
  pwd: string;
7
7
  html: string;
@@ -1,3 +1,3 @@
1
- import type { UserConfig } from '../../types';
2
- import type { RequestHandlerConfig } from '../../types/requestHandler';
1
+ import type { UserConfig } from '../../types/index.js';
2
+ import type { RequestHandlerConfig } from '../../types/requestHandler.js';
3
3
  export declare function createRequestHandlerConfig(userConfig: UserConfig): RequestHandlerConfig;
@@ -1,2 +1,2 @@
1
- import type { ServerPlugin } from '../types';
1
+ import type { ServerPlugin } from '../types/index.js';
2
2
  export declare const injectRoutePlugin: () => ServerPlugin;
@@ -1,6 +1,6 @@
1
1
  import { type ServerCreateOptions } from '@modern-js/plugin/server';
2
- import type { Env, ServerConfig, ServerPlugin, ServerPluginHooks } from './types';
3
- import type { CliConfig } from './types/config';
2
+ import type { Env, ServerConfig, ServerPlugin, ServerPluginHooks } from './types/index.js';
3
+ import type { CliConfig } from './types/config/index.js';
4
4
  export interface ServerBaseOptions extends ServerCreateOptions {
5
5
  /** server working directory, and then also dist directory */
6
6
  config: CliConfig;
@@ -12,6 +12,8 @@ export declare class ServerBase<E extends Env = any> {
12
12
  serverOptions: ServerBaseOptions;
13
13
  private app;
14
14
  private plugins;
15
+ private disposers;
16
+ private disposePromise?;
15
17
  private serverContext;
16
18
  constructor(options: ServerBaseOptions);
17
19
  /**
@@ -20,6 +22,10 @@ export declare class ServerBase<E extends Env = any> {
20
22
  * - apply middlewares
21
23
  */
22
24
  init(): Promise<this>;
25
+ /** Register instance resources before initialization can fail. */
26
+ onDispose(disposer: () => void | Promise<void>): () => void;
27
+ /** Retire this instance and release every resource in reverse order once. */
28
+ dispose(): Promise<void>;
23
29
  addPlugins(plugins: ServerPlugin[]): void;
24
30
  get hooks(): ServerPluginHooks;
25
31
  get all(): import("hono/types").HandlerInterface<E, "all", import("hono/types").BlankSchema, "/", "/">;
@@ -30,7 +36,7 @@ export declare class ServerBase<E extends Env = any> {
30
36
  get put(): import("hono/types").HandlerInterface<E, "put", import("hono/types").BlankSchema, "/", "/">;
31
37
  get delete(): import("hono/types").HandlerInterface<E, "delete", import("hono/types").BlankSchema, "/", "/">;
32
38
  get patch(): import("hono/types").HandlerInterface<E, "patch", import("hono/types").BlankSchema, "/", "/">;
33
- get handle(): (request: Request, Env?: {} | E["Bindings"] | undefined, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
39
+ get handle(): (request: Request, env?: {} | E["Bindings"] | undefined, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
34
40
  get request(): (input: Request | string | URL, requestInit?: RequestInit, Env?: {} | E["Bindings"] | undefined, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
35
41
  get notFound(): (handler: import("hono").NotFoundHandler<E>) => import("hono/hono-base").HonoBase<E, import("hono/types").BlankSchema, "/", "/">;
36
42
  get onError(): (handler: import("hono").ErrorHandler<E>) => import("hono/hono-base").HonoBase<E, import("hono/types").BlankSchema, "/", "/">;
@@ -1,6 +1,5 @@
1
+ import type { BffRuntimeFramework } from '@modern-js/plugin/server';
1
2
  import type { HttpMethodDecider } from '@modern-js/types';
2
- import type { BffCrossProjectPolicyUserConfig, BffEffectUserConfig, BffRuntimeFramework } from './bffRuntime';
3
- export type { BffCrossProjectPolicyUserConfig, BffEffectDataPlatformBatchUserConfig, BffEffectDataPlatformSelectionUserConfig, BffEffectDataPlatformUserConfig, BffEffectOpenApiUserConfig, BffEffectUserConfig, BffRuntimeFramework, } from './bffRuntime';
4
3
  export interface BffUserConfig {
5
4
  prefix?: string | string[];
6
5
  httpMethodDecider?: HttpMethodDecider;
@@ -25,23 +24,13 @@ export interface BffUserConfig {
25
24
  * Custom request creator import path for generated BFF clients.
26
25
  */
27
26
  requestCreator?: string;
27
+ /** Node module exporting a generated-client transform. */
28
+ clientCodegenPlugin?: string;
28
29
  /**
29
30
  * Legacy custom fetcher import path for generated BFF clients.
30
31
  */
31
32
  fetcher?: string;
32
- /**
33
- * Selects the BFF runtime implementation.
34
- *
35
- * - `effect`: only `api/index` (or the configured `bff.effect.entry`) is served.
36
- * - `hono`: only `api/lambda/**` handlers are served.
37
- *
38
- * @default 'effect'
39
- */
33
+ /** Selects a registered BFF runtime implementation. */
40
34
  runtimeFramework?: BffRuntimeFramework;
41
- /**
42
- * Effect runtime configuration. Only applies when `runtimeFramework: 'effect'`.
43
- */
44
- effect?: BffEffectUserConfig;
45
- crossProjectPolicy?: BffCrossProjectPolicyUserConfig;
46
35
  }
47
36
  export type BffNormalizedConfig = BffUserConfig;
@@ -1,17 +1,17 @@
1
- import type { BffNormalizedConfig, BffUserConfig } from './bff';
2
- import type { DevNormalizedConfig, DevUserConfig } from './dev';
3
- import type { HtmlNormalizedConfig, HtmlUserConfig } from './html';
4
- import type { OutputNormalizedConfig, OutputUserConfig } from './output';
5
- import type { SecurityNormalizedConfig, SecurityUserConfig } from './security';
6
- import type { ServerNormalizedConfig, ServerUserConfig } from './server';
7
- import type { SourceNormalizedConfig, SourceUserConfig } from './source';
8
- import type { ToolsNormalizedConfig, ToolsUserConfig } from './tools';
9
- export * from './bff';
10
- export * from './html';
11
- export * from './output';
12
- export * from './server';
13
- export * from './source';
14
- export * from './tools';
1
+ import type { BffNormalizedConfig, BffUserConfig } from './bff.js';
2
+ import type { DevNormalizedConfig, DevUserConfig } from './dev.js';
3
+ import type { HtmlNormalizedConfig, HtmlUserConfig } from './html.js';
4
+ import type { OutputNormalizedConfig, OutputUserConfig } from './output.js';
5
+ import type { SecurityNormalizedConfig, SecurityUserConfig } from './security.js';
6
+ import type { ServerNormalizedConfig, ServerUserConfig } from './server.js';
7
+ import type { SourceNormalizedConfig, SourceUserConfig } from './source.js';
8
+ import type { ToolsNormalizedConfig, ToolsUserConfig } from './tools.js';
9
+ export * from './bff.js';
10
+ export * from './html.js';
11
+ export * from './output.js';
12
+ export * from './server.js';
13
+ export * from './source.js';
14
+ export * from './tools.js';
15
15
  export interface UserConfig {
16
16
  output?: OutputUserConfig;
17
17
  source?: SourceUserConfig;
@@ -1,7 +1,5 @@
1
1
  import type { SSRMode } from '@modern-js/types';
2
2
  import type { WatchOptions } from '@modern-js/utils';
3
- import type { ServerTelemetryUserConfig } from './serverTelemetry';
4
- export type { ServerTelemetryCanaryAutopilotStateStoreUserConfig, ServerTelemetryCanaryAutopilotUserConfig, ServerTelemetryCanaryContractGateUserConfig, ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig, ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig, ServerTelemetryCanaryRuntimeFallbackSignalUserConfig, ServerTelemetryCanaryUserConfig, ServerTelemetryExporterOptions, ServerTelemetrySloUserConfig, ServerTelemetryUserConfig, ServerTelemetryVictoriaMetricsOptions, } from './serverTelemetry';
5
3
  type Route = string | string[] | {
6
4
  route?: string | string[];
7
5
  disableSpa?: boolean;
@@ -50,7 +48,6 @@ export interface ServerUserConfig {
50
48
  */
51
49
  useJsonScript?: boolean;
52
50
  logger?: boolean | Record<string, unknown>;
53
- telemetry?: ServerTelemetryUserConfig;
54
51
  /**
55
52
  * @description disable hook middleware for performance
56
53
  * @default false
@@ -66,3 +63,4 @@ export interface ServerUserConfig {
66
63
  tsconfigPath?: string;
67
64
  }
68
65
  export type ServerNormalizedConfig = ServerUserConfig;
66
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { Alias } from '@modern-js/utils';
2
- import type { ConfigChain } from './share';
2
+ import type { ConfigChain } from './share.js';
3
3
  export interface SourceUserConfig {
4
4
  alias?: ConfigChain<Alias>;
5
5
  enableAsyncEntry?: boolean;
@@ -1,4 +1,4 @@
1
- export * from './config';
2
- export * from './plugins';
3
- export * from './render';
4
- export * from './server';
1
+ export * from './config/index.js';
2
+ export * from './plugins/index.js';
3
+ export * from './render.js';
4
+ export * from './server.js';
@@ -1,8 +1,8 @@
1
1
  import type { CacheOption, Container, HttpMethodDecider, MiddlewareContext, ServerRoute } from '@modern-js/types';
2
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';
3
+ import type { UserConfig } from '../config/index.js';
4
+ import type { Render } from '../render.js';
5
+ import type { ServerPlugin } from './plugin.js';
6
6
  export type { FileChangeEvent, ResetEvent } from '@modern-js/plugin';
7
7
  export type APIServerStartInput = {
8
8
  pwd: string;
@@ -1,2 +1,2 @@
1
- export type { APIServerStartInput, CacheConfig, FileChangeEvent, GetRenderHandlerOptions, MiddlewareObj, ServerConfig, ServerMiddleware, WebServerStartInput, } from './base';
2
- export * from './plugin';
1
+ export type { APIServerStartInput, CacheConfig, FileChangeEvent, GetRenderHandlerOptions, MiddlewareObj, ServerConfig, ServerMiddleware, WebServerStartInput, } from './base.js';
2
+ export * from './plugin.js';
@@ -1,21 +1,35 @@
1
1
  import type { AsyncPipelineHook, ServerContext as BaseServerContext, ServerPlugin as BaseServerPlugin, ServerPluginAPI as BaseServerPluginAPI, ServerPluginExtends as BaseServerPluginExtends } from '@modern-js/plugin';
2
2
  import type { Hooks } from '@modern-js/plugin/server';
3
3
  import type { AfterMatchContext, AfterRenderContext, AfterStreamingRenderContext } from '@modern-js/types';
4
- import type { MiddlewareHandler } from 'hono';
5
- import type { APIServerStartInput, MiddlewareObj, ServerConfig, WebAdapter, WebServerStartInput } from './base';
4
+ import type { Context, MiddlewareHandler } from 'hono';
5
+ import type { ServerStaticPluginOptions } from '../../adapters/node/plugins/static.js';
6
+ import type { APIServerStartInput, MiddlewareObj, ServerConfig, WebAdapter, WebServerStartInput } from './base.js';
6
7
  export type PrepareWebServerFn = (input: WebServerStartInput) => Promise<WebAdapter | null>;
7
8
  export type PrepareApiServerFn = (input: APIServerStartInput) => Promise<MiddlewareHandler>;
8
9
  export type AfterMatchFn = (ctx: AfterMatchContext) => Promise<any>;
9
10
  export type AfterRenderFn = (ctx: AfterRenderContext) => Promise<any>;
10
11
  export type AfterStreamingRenderContextFn = (ctx: AfterStreamingRenderContext) => Promise<AfterStreamingRenderContext>;
12
+ export interface HandleErrorInput {
13
+ error: Error;
14
+ context: Context;
15
+ response?: Response;
16
+ }
17
+ export type HandleErrorFn = (input: HandleErrorInput, next?: (input: HandleErrorInput) => void) => Promise<HandleErrorInput>;
11
18
  export interface ServerPluginExtends extends BaseServerPluginExtends {
12
19
  config: ServerConfig;
20
+ extendApi: {
21
+ /** Release an instance resource on shutdown or failed initialization. */
22
+ onDispose: (disposer: () => void | Promise<void>) => () => void;
23
+ };
13
24
  extendContext: {
25
+ /** Node static response extensions registered during plugin setup. */
26
+ staticAssetResponders?: ServerStaticPluginOptions;
14
27
  middlewares: MiddlewareObj[];
15
28
  renderMiddlewares: MiddlewareObj[];
16
29
  [key: string]: any;
17
30
  };
18
31
  extendHooks: {
32
+ handleError: AsyncPipelineHook<HandleErrorFn>;
19
33
  prepareWebServer: AsyncPipelineHook<PrepareWebServerFn>;
20
34
  prepareApiServer: AsyncPipelineHook<PrepareApiServerFn>;
21
35
  afterMatch: AsyncPipelineHook<AfterMatchFn>;
@@ -1,6 +1,6 @@
1
1
  import type { Monitors, Reporter, ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types';
2
2
  import type { NodeRequest } from '@modern-js/types/server';
3
- import type { Context, ServerManifest } from './server';
3
+ import type { Context, ServerManifest } from './server.js';
4
4
  export interface RenderOptions {
5
5
  monitors: Monitors;
6
6
  loaderContext?: Map<string, unknown>;
@@ -1,6 +1,6 @@
1
- import type { Reporter, ServerRoute } from '@modern-js/types';
1
+ import type { OnError, OnTiming, Reporter, ServerRoute } from '@modern-js/types';
2
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';
3
+ import type { ServerUserConfig, SourceUserConfig } from './config/index.js';
4
4
  export type Resource = {
5
5
  loadableStats: Record<string, any>;
6
6
  routeManifest: Record<string, any>;
@@ -22,8 +22,7 @@ export type RequestHandlerConfig = {
22
22
  enableAsyncEntry?: SourceUserConfig['enableAsyncEntry'];
23
23
  };
24
24
  export type LoaderContext = Map<string, any>;
25
- export type OnError = (err: unknown, key?: string) => void;
26
- export type OnTiming = (name: string, dur: number) => void;
25
+ export type { OnError, OnTiming };
27
26
  export type RequestHandlerOptions = {
28
27
  resource: Resource;
29
28
  config: RequestHandlerConfig;
@@ -1,6 +1,6 @@
1
1
  import type { Logger, Metrics, Monitors, NestedRoute, Reporter, ServerRoute } from '@modern-js/types';
2
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';
3
+ import type { RequestHandler as BundleRequestHandler, OnError, OnTiming, RequestHandlerOptions, Resource } from './requestHandler.js';
4
4
  export type RequestHandler = (request: Request, ...args: any[]) => Response | Promise<Response>;
5
5
  export type ServerLoaderBundle = {
6
6
  routes: NestedRoute[];
@@ -1,6 +1,4 @@
1
1
  import type { Monitors } from '@modern-js/types';
2
- export type { SafeFailureEnvelope, SafeFailureHttpResult, } from '@modern-js/runtime-extensions/safe-failure';
3
- export { createSafeFailureHttpResult, createSafeJsonFailureResponse, getSafeFailureStatus, } from '@modern-js/runtime-extensions/safe-failure';
4
2
  export declare const createErrorHtml: (status: number) => string;
5
3
  export declare enum ErrorDigest {
6
4
  ENOTF = "Page could not be found",