@modern-js/server-core 2.58.2-alpha.0 → 2.58.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.
- package/dist/cjs/adapters/node/plugins/resource.js +1 -1
- package/dist/cjs/plugins/customServer/index.js +19 -3
- package/dist/cjs/plugins/render/render.js +2 -1
- package/dist/esm/adapters/node/plugins/resource.js +1 -1
- package/dist/esm/plugins/customServer/index.js +11 -5
- package/dist/esm/plugins/render/render.js +2 -1
- package/dist/esm-node/adapters/node/plugins/resource.js +1 -1
- package/dist/esm-node/plugins/customServer/index.js +9 -3
- package/dist/esm-node/plugins/render/render.js +2 -1
- package/dist/types/adapters/node/helper/loadCache.d.ts +1 -1
- package/dist/types/adapters/node/helper/loadConfig.d.ts +1 -1
- package/dist/types/adapters/node/helper/loadPlugin.d.ts +2 -2
- package/dist/types/adapters/node/hono.d.ts +1 -1
- package/dist/types/adapters/node/node.d.ts +2 -2
- package/dist/types/adapters/node/plugins/nodeServer.d.ts +1 -1
- package/dist/types/adapters/node/plugins/resource.d.ts +1 -1
- package/dist/types/adapters/node/plugins/static.d.ts +1 -1
- package/dist/types/plugins/customServer/base.d.ts +1 -1
- package/dist/types/plugins/customServer/context.d.ts +3 -3
- package/dist/types/plugins/customServer/index.d.ts +3 -3
- package/dist/types/plugins/default.d.ts +2 -2
- package/dist/types/plugins/favicon.d.ts +1 -1
- package/dist/types/plugins/processedBy.d.ts +1 -1
- package/dist/types/plugins/render/dataHandler.d.ts +1 -1
- package/dist/types/plugins/render/index.d.ts +1 -1
- package/dist/types/plugins/render/render.d.ts +2 -2
- package/dist/types/plugins/render/ssrCache.d.ts +1 -1
- package/dist/types/plugins/render/ssrRender.d.ts +2 -2
- package/dist/types/serverBase.d.ts +1 -1
- package/dist/types/types/config/index.d.ts +8 -8
- package/dist/types/types/config/tools.d.ts +2 -2
- package/dist/types/types/plugin.d.ts +6 -6
- package/dist/types/types/requestHandler.d.ts +2 -2
- package/dist/types/types/server.d.ts +1 -1
- package/dist/types/utils/entry.d.ts +1 -1
- package/dist/types/utils/serverConfig.d.ts +1 -1
- package/dist/types/utils/transformStream.d.ts +1 -1
- package/package.json +7 -7
|
@@ -93,7 +93,7 @@ async function getServerManifest(pwd, routes, logger) {
|
|
|
93
93
|
const routesManifestUri = import_path.default.join(pwd, import_utils.ROUTE_MANIFEST_FILE);
|
|
94
94
|
const routeManifest = await (0, import_utils.compatibleRequire)(routesManifestUri).catch((_) => ({}));
|
|
95
95
|
const nestedRoutesJsonPath = import_path.default.join(pwd, import_utils.NESTED_ROUTE_SPEC_FILE);
|
|
96
|
-
const nestedRoutesJson = await
|
|
96
|
+
const nestedRoutesJson = await (0, import_utils.compatibleRequire)(nestedRoutesJsonPath).catch((_) => ({}));
|
|
97
97
|
return {
|
|
98
98
|
loaderBundles,
|
|
99
99
|
renderBundles,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var customServer_exports = {};
|
|
20
30
|
__export(customServer_exports, {
|
|
@@ -55,7 +65,14 @@ class CustomServer {
|
|
|
55
65
|
if (current !== entryName) {
|
|
56
66
|
const rewriteRoute = routes.find((route) => route.entryName === current);
|
|
57
67
|
if (rewriteRoute) {
|
|
58
|
-
|
|
68
|
+
const { headers, method, signal } = c.req.raw;
|
|
69
|
+
const url2 = new URL(c.req.url);
|
|
70
|
+
const newUrl = new URL(rewriteRoute.urlPath, url2.origin);
|
|
71
|
+
return this.serverBase.request(newUrl, {
|
|
72
|
+
headers,
|
|
73
|
+
method,
|
|
74
|
+
signal
|
|
75
|
+
}, c.env);
|
|
59
76
|
}
|
|
60
77
|
}
|
|
61
78
|
if (c.finalized) {
|
|
@@ -165,8 +182,7 @@ async function createMiddlewareContextFromHono(c) {
|
|
|
165
182
|
"GET",
|
|
166
183
|
"HEAD"
|
|
167
184
|
].includes(method) && !rawRequest.body && c.env.node.req) {
|
|
168
|
-
const
|
|
169
|
-
const { createReadableStreamFromReadable } = await import(streamPath);
|
|
185
|
+
const { createReadableStreamFromReadable } = await import("../../adapters/node/polyfills/stream.js");
|
|
170
186
|
const init = {
|
|
171
187
|
body: createReadableStreamFromReadable(c.env.node.req),
|
|
172
188
|
headers: rawRequest.headers,
|
|
@@ -37,6 +37,7 @@ var import_utils = require("../../utils");
|
|
|
37
37
|
var import_constants = require("../../constants");
|
|
38
38
|
var import_dataHandler = require("./dataHandler");
|
|
39
39
|
var import_ssrRender = require("./ssrRender");
|
|
40
|
+
var import_utils2 = require("@modern-js/utils");
|
|
40
41
|
const DYNAMIC_ROUTE_REG = /\/:./;
|
|
41
42
|
function getRouter(routes) {
|
|
42
43
|
const dynamicRoutes = [];
|
|
@@ -164,7 +165,7 @@ async function renderHandler(request, options, mode, onError) {
|
|
|
164
165
|
const { nestedRoutesJson } = serverManifest;
|
|
165
166
|
const routes = nestedRoutesJson === null || nestedRoutesJson === void 0 ? void 0 : nestedRoutesJson[options.routeInfo.entryName];
|
|
166
167
|
if (routes) {
|
|
167
|
-
const { matchRoutes } = await
|
|
168
|
+
const { matchRoutes } = await (0, import_utils2.compatibleRequire)(require.resolve("@modern-js/runtime-utils/remix-router"), false);
|
|
168
169
|
const url = new URL(request.url);
|
|
169
170
|
const matchedRoutes = matchRoutes(routes, url.pathname, options.routeInfo.urlPath);
|
|
170
171
|
if (!matchedRoutes) {
|
|
@@ -235,7 +235,7 @@ function _getServerManifest() {
|
|
|
235
235
|
nestedRoutesJsonPath = path.join(pwd, NESTED_ROUTE_SPEC_FILE);
|
|
236
236
|
return [
|
|
237
237
|
4,
|
|
238
|
-
|
|
238
|
+
compatibleRequire(nestedRoutesJsonPath).catch(function(_) {
|
|
239
239
|
return {};
|
|
240
240
|
})
|
|
241
241
|
];
|
|
@@ -36,7 +36,7 @@ var CustomServer = /* @__PURE__ */ function() {
|
|
|
36
36
|
var _this = this;
|
|
37
37
|
return function() {
|
|
38
38
|
var _ref = _async_to_generator(function(c, next) {
|
|
39
|
-
var routeInfo, monitors, baseHookCtx, afterMatchCtx, getCost, cost, _afterMatchCtx_router, url, status, current, rewriteRoute, afterStreamingRenderContext, afterRenderCtx, getCost1, cost1, newBody;
|
|
39
|
+
var routeInfo, monitors, baseHookCtx, afterMatchCtx, getCost, cost, _afterMatchCtx_router, url, status, current, rewriteRoute, _c_req_raw, headers, method, signal, url1, newUrl, afterStreamingRenderContext, afterRenderCtx, getCost1, cost1, newBody;
|
|
40
40
|
return _ts_generator(this, function(_state) {
|
|
41
41
|
switch (_state.label) {
|
|
42
42
|
case 0:
|
|
@@ -70,9 +70,16 @@ var CustomServer = /* @__PURE__ */ function() {
|
|
|
70
70
|
return route.entryName === current;
|
|
71
71
|
});
|
|
72
72
|
if (rewriteRoute) {
|
|
73
|
+
_c_req_raw = c.req.raw, headers = _c_req_raw.headers, method = _c_req_raw.method, signal = _c_req_raw.signal;
|
|
74
|
+
url1 = new URL(c.req.url);
|
|
75
|
+
newUrl = new URL(rewriteRoute.urlPath, url1.origin);
|
|
73
76
|
return [
|
|
74
77
|
2,
|
|
75
|
-
_this.serverBase.request(
|
|
78
|
+
_this.serverBase.request(newUrl, {
|
|
79
|
+
headers,
|
|
80
|
+
method,
|
|
81
|
+
signal
|
|
82
|
+
}, c.env)
|
|
76
83
|
];
|
|
77
84
|
}
|
|
78
85
|
}
|
|
@@ -281,7 +288,7 @@ function createMiddlewareContextFromHono(c) {
|
|
|
281
288
|
}
|
|
282
289
|
function _createMiddlewareContextFromHono() {
|
|
283
290
|
_createMiddlewareContextFromHono = _async_to_generator(function(c) {
|
|
284
|
-
var loaderContext, rawRequest, method,
|
|
291
|
+
var loaderContext, rawRequest, method, createReadableStreamFromReadable, init;
|
|
285
292
|
return _ts_generator(this, function(_state) {
|
|
286
293
|
switch (_state.label) {
|
|
287
294
|
case 0:
|
|
@@ -296,10 +303,9 @@ function _createMiddlewareContextFromHono() {
|
|
|
296
303
|
3,
|
|
297
304
|
2
|
|
298
305
|
];
|
|
299
|
-
streamPath = "../../adapters/node/polyfills/stream";
|
|
300
306
|
return [
|
|
301
307
|
4,
|
|
302
|
-
import(
|
|
308
|
+
import("../../adapters/node/polyfills/stream.js")
|
|
303
309
|
];
|
|
304
310
|
case 1:
|
|
305
311
|
createReadableStreamFromReadable = _state.sent().createReadableStreamFromReadable;
|
|
@@ -12,6 +12,7 @@ import { parseQuery, getPathname, createErrorHtml, sortRoutes, transformResponse
|
|
|
12
12
|
import { REPLACE_REG, X_MODERNJS_RENDER } from "../../constants";
|
|
13
13
|
import { dataHandler } from "./dataHandler";
|
|
14
14
|
import { ssrRender } from "./ssrRender";
|
|
15
|
+
import { compatibleRequire } from "@modern-js/utils";
|
|
15
16
|
var DYNAMIC_ROUTE_REG = /\/:./;
|
|
16
17
|
function getRouter(routes) {
|
|
17
18
|
var dynamicRoutes = [];
|
|
@@ -290,7 +291,7 @@ function _renderHandler() {
|
|
|
290
291
|
];
|
|
291
292
|
return [
|
|
292
293
|
4,
|
|
293
|
-
|
|
294
|
+
compatibleRequire(require.resolve("@modern-js/runtime-utils/remix-router"), false)
|
|
294
295
|
];
|
|
295
296
|
case 1:
|
|
296
297
|
matchRoutes = _state.sent().matchRoutes;
|
|
@@ -56,7 +56,7 @@ async function getServerManifest(pwd, routes, logger) {
|
|
|
56
56
|
const routesManifestUri = path.join(pwd, ROUTE_MANIFEST_FILE);
|
|
57
57
|
const routeManifest = await compatibleRequire(routesManifestUri).catch((_) => ({}));
|
|
58
58
|
const nestedRoutesJsonPath = path.join(pwd, NESTED_ROUTE_SPEC_FILE);
|
|
59
|
-
const nestedRoutesJson = await
|
|
59
|
+
const nestedRoutesJson = await compatibleRequire(nestedRoutesJsonPath).catch((_) => ({}));
|
|
60
60
|
return {
|
|
61
61
|
loaderBundles,
|
|
62
62
|
renderBundles,
|
|
@@ -31,7 +31,14 @@ class CustomServer {
|
|
|
31
31
|
if (current !== entryName) {
|
|
32
32
|
const rewriteRoute = routes.find((route) => route.entryName === current);
|
|
33
33
|
if (rewriteRoute) {
|
|
34
|
-
|
|
34
|
+
const { headers, method, signal } = c.req.raw;
|
|
35
|
+
const url2 = new URL(c.req.url);
|
|
36
|
+
const newUrl = new URL(rewriteRoute.urlPath, url2.origin);
|
|
37
|
+
return this.serverBase.request(newUrl, {
|
|
38
|
+
headers,
|
|
39
|
+
method,
|
|
40
|
+
signal
|
|
41
|
+
}, c.env);
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
if (c.finalized) {
|
|
@@ -141,8 +148,7 @@ async function createMiddlewareContextFromHono(c) {
|
|
|
141
148
|
"GET",
|
|
142
149
|
"HEAD"
|
|
143
150
|
].includes(method) && !rawRequest.body && c.env.node.req) {
|
|
144
|
-
const
|
|
145
|
-
const { createReadableStreamFromReadable } = await import(streamPath);
|
|
151
|
+
const { createReadableStreamFromReadable } = await import("../../adapters/node/polyfills/stream.js");
|
|
146
152
|
const init = {
|
|
147
153
|
body: createReadableStreamFromReadable(c.env.node.req),
|
|
148
154
|
headers: rawRequest.headers,
|
|
@@ -4,6 +4,7 @@ import { parseQuery, getPathname, createErrorHtml, sortRoutes, transformResponse
|
|
|
4
4
|
import { REPLACE_REG, X_MODERNJS_RENDER } from "../../constants";
|
|
5
5
|
import { dataHandler } from "./dataHandler";
|
|
6
6
|
import { ssrRender } from "./ssrRender";
|
|
7
|
+
import { compatibleRequire } from "@modern-js/utils";
|
|
7
8
|
const DYNAMIC_ROUTE_REG = /\/:./;
|
|
8
9
|
function getRouter(routes) {
|
|
9
10
|
const dynamicRoutes = [];
|
|
@@ -131,7 +132,7 @@ async function renderHandler(request, options, mode, onError) {
|
|
|
131
132
|
const { nestedRoutesJson } = serverManifest;
|
|
132
133
|
const routes = nestedRoutesJson === null || nestedRoutesJson === void 0 ? void 0 : nestedRoutesJson[options.routeInfo.entryName];
|
|
133
134
|
if (routes) {
|
|
134
|
-
const { matchRoutes } = await
|
|
135
|
+
const { matchRoutes } = await compatibleRequire(require.resolve("@modern-js/runtime-utils/remix-router"), false);
|
|
135
136
|
const url = new URL(request.url);
|
|
136
137
|
const matchedRoutes = matchRoutes(routes, url.pathname, options.routeInfo.urlPath);
|
|
137
138
|
if (!matchedRoutes) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CacheConfig } from '../../../types';
|
|
1
|
+
import type { CacheConfig } from '../../../types';
|
|
2
2
|
export declare function loadCacheConfig(pwd: string): Promise<CacheConfig | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CliConfig, ServerConfig, UserConfig } from '../../../types';
|
|
1
|
+
import type { CliConfig, ServerConfig, UserConfig } from '../../../types';
|
|
2
2
|
export declare function loadServerRuntimeConfig(pwd: string, oldServerFile?: string, newServerConfigPath?: string): Promise<ServerConfig | undefined>;
|
|
3
3
|
export declare function loadServerCliConfig(pwd: string, defaultConfig?: UserConfig): CliConfig;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ServerPlugin } from '@modern-js/types';
|
|
2
|
-
import { ServerPlugin as ServerPluginInstance } from '../../../types';
|
|
1
|
+
import type { ServerPlugin } from '@modern-js/types';
|
|
2
|
+
import type { ServerPlugin as ServerPluginInstance } from '../../../types';
|
|
3
3
|
export declare function loadServerPlugins(serverPlugins: ServerPlugin[], appDirectory: string): Promise<ServerPluginInstance[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodeRequest, NodeResponse, Context, HonoRequest, ServerEnv, Middleware, Next, ServerManifest } from '../../types';
|
|
1
|
+
import type { NodeRequest, NodeResponse, Context, HonoRequest, ServerEnv, Middleware, Next, ServerManifest } from '../../types';
|
|
2
2
|
type NodeBindings = {
|
|
3
3
|
node: {
|
|
4
4
|
req: NodeRequest & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Server as NodeServer } from 'node:http';
|
|
3
|
+
import { type Server as NodeServer } from 'node:http';
|
|
4
4
|
import type { Server as NodeHttpsServer } from 'node:https';
|
|
5
|
-
import { NodeRequest, NodeResponse, RequestHandler } from '../../types';
|
|
5
|
+
import type { NodeRequest, NodeResponse, RequestHandler } from '../../types';
|
|
6
6
|
export { writeReadableStreamToWritable } from './polyfills';
|
|
7
7
|
export declare const createWebRequest: (req: NodeRequest, res: NodeResponse, body?: BodyInit) => Request;
|
|
8
8
|
export declare const sendResponse: (response: Response, res: NodeResponse) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger, ServerRoute } from '@modern-js/types';
|
|
2
|
-
import { Middleware, ServerEnv, ServerManifest, ServerPlugin } from '../../../types';
|
|
2
|
+
import type { Middleware, ServerEnv, ServerManifest, ServerPlugin } from '../../../types';
|
|
3
3
|
export declare function getHtmlTemplates(pwd: string, routes: ServerRoute[]): Promise<Record<string, string>>;
|
|
4
4
|
export declare function injectTemplates(pwd: string, routes?: ServerRoute[]): Middleware<ServerEnv>;
|
|
5
5
|
export declare function getServerManifest(pwd: string, routes: ServerRoute[], logger: Logger): Promise<ServerManifest>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServerRoute } from '@modern-js/types';
|
|
1
|
+
import type { ServerRoute } from '@modern-js/types';
|
|
2
2
|
import type { OutputNormalizedConfig, HtmlNormalizedConfig, Middleware, ServerPlugin } from '../../../types';
|
|
3
3
|
export declare const serverStaticPlugin: () => ServerPlugin;
|
|
4
4
|
export type PublicMiddlwareOptions = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AfterMatchContext, AfterRenderContext, MiddlewareContext, AfterStreamingRenderContext, ServerRoute, HookContext } from '@modern-js/types';
|
|
2
|
-
import { Context, ServerEnv } from '../../types';
|
|
1
|
+
import type { AfterMatchContext, AfterRenderContext, MiddlewareContext, AfterStreamingRenderContext, ServerRoute, HookContext } from '@modern-js/types';
|
|
2
|
+
import type { Context, ServerEnv } from '../../types';
|
|
3
3
|
import type { ServerNodeEnv } from '../../adapters/node/hono';
|
|
4
|
-
import { ResArgs } from './base';
|
|
4
|
+
import { type ResArgs } from './base';
|
|
5
5
|
export declare function getAfterMatchCtx(entryName: string, baseHookCtx: HookContext): AfterMatchContext;
|
|
6
6
|
export declare function getAfterRenderCtx(c: Context, baseHookCtx: HookContext, route: Partial<ServerRoute>): Promise<AfterRenderContext>;
|
|
7
7
|
export declare function createCustomMiddlewaresCtx(c: Context<ServerNodeEnv & ServerEnv>, locals: Record<string, any>, resArgs?: ResArgs): MiddlewareContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ServerRoute, UnstableMiddleware } from '@modern-js/types';
|
|
2
|
-
import { ServerBase } from '../../serverBase';
|
|
3
|
-
import { ServerHookRunner, Middleware, ServerEnv } from '../../types';
|
|
1
|
+
import type { ServerRoute, UnstableMiddleware } from '@modern-js/types';
|
|
2
|
+
import type { ServerBase } from '../../serverBase';
|
|
3
|
+
import type { ServerHookRunner, Middleware, ServerEnv } from '../../types';
|
|
4
4
|
import type { ServerNodeEnv } from '../../adapters/node/hono';
|
|
5
5
|
export declare class CustomServer {
|
|
6
6
|
private runner;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger } from '@modern-js/types';
|
|
1
|
+
import type { Logger } from '@modern-js/types';
|
|
2
2
|
import type { ServerPlugin } from '../types';
|
|
3
|
-
import { InjectRenderHandlerOptions } from './render';
|
|
3
|
+
import { type InjectRenderHandlerOptions } from './render';
|
|
4
4
|
export type CreateDefaultPluginsOptions = InjectRenderHandlerOptions & {
|
|
5
5
|
logger?: Logger;
|
|
6
6
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ServerPlugin } from '../types';
|
|
1
|
+
import type { ServerPlugin } from '../types';
|
|
2
2
|
export declare const faviconPlugin: () => ServerPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ServerPlugin } from '../types';
|
|
1
|
+
import type { ServerPlugin } from '../types';
|
|
2
2
|
export declare const processedByPlugin: () => ServerPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ServerRoute } from '@modern-js/types';
|
|
2
|
-
import { SSRRenderOptions } from './ssrRender';
|
|
2
|
+
import type { SSRRenderOptions } from './ssrRender';
|
|
3
3
|
export declare const dataHandler: (request: Request, { routeInfo, serverRoutes, reporter, onError, onTiming, serverManifest, }: SSRRenderOptions & {
|
|
4
4
|
serverRoutes: ServerRoute[];
|
|
5
5
|
}) => Promise<Response | void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Logger, Metrics, Reporter, ServerRoute } from '@modern-js/types';
|
|
1
|
+
import type { Logger, Metrics, Reporter, ServerRoute } from '@modern-js/types';
|
|
2
2
|
import type { CacheConfig, FallbackReason, UserConfig } from '../../types';
|
|
3
|
-
import { Render } from '../../types';
|
|
3
|
+
import type { Render } from '../../types';
|
|
4
4
|
export type OnFallback = (reason: FallbackReason, utils: {
|
|
5
5
|
logger: Logger;
|
|
6
6
|
metrics?: Metrics;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { IncomingMessage } from 'http';
|
|
3
3
|
import type { CacheControl, CacheOption, Container } from '@modern-js/types';
|
|
4
|
-
import { RequestHandler, RequestHandlerOptions } from '../../types/requestHandler';
|
|
4
|
+
import type { RequestHandler, RequestHandlerOptions } from '../../types/requestHandler';
|
|
5
5
|
export type CacheStatus = 'hit' | 'stale' | 'expired' | 'miss';
|
|
6
6
|
type MaybeAsync<T> = Promise<T> | T;
|
|
7
7
|
export declare function matchCacheControl(cacheOption?: CacheOption, req?: IncomingMessage): MaybeAsync<CacheControl | undefined | false>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { IncomingMessage } from 'http';
|
|
3
3
|
import type { Reporter, ServerRoute, Logger, Metrics } from '@modern-js/types';
|
|
4
|
-
import { OnError, OnTiming, Params } from '../../types/requestHandler';
|
|
5
|
-
import { CacheConfig, ServerManifest, UserConfig } from '../../types';
|
|
4
|
+
import type { OnError, OnTiming, Params } from '../../types/requestHandler';
|
|
5
|
+
import type { CacheConfig, ServerManifest, UserConfig } from '../../types';
|
|
6
6
|
export interface SSRRenderOptions {
|
|
7
7
|
pwd: string;
|
|
8
8
|
html: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BffNormalizedConfig, BffUserConfig } from './bff';
|
|
2
|
-
import { DevNormalizedConfig, DevUserConfig } from './dev';
|
|
3
|
-
import { HtmlNormalizedConfig, HtmlUserConfig } from './html';
|
|
4
|
-
import { OutputNormalizedConfig, OutputUserConfig } from './output';
|
|
5
|
-
import { SecurityNormalizedConfig, SecurityUserConfig } from './security';
|
|
6
|
-
import { ServerNormalizedConfig, ServerUserConfig } from './server';
|
|
7
|
-
import { SourceNormalizedConfig, SourceUserConfig } from './source';
|
|
8
|
-
import { ToolsNormalizedConfig, ToolsUserConfig } from './tools';
|
|
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
9
|
export * from './bff';
|
|
10
10
|
export * from './html';
|
|
11
11
|
export * from './output';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BabelTransformOptions } from '@modern-js/types/common';
|
|
2
|
-
import { ConfigChain } from './share';
|
|
1
|
+
import type { BabelTransformOptions } from '@modern-js/types/common';
|
|
2
|
+
import type { ConfigChain } from './share';
|
|
3
3
|
type ToolsBabelConfig = ConfigChain<BabelTransformOptions, any>;
|
|
4
4
|
export interface ToolsUserConfig {
|
|
5
5
|
babel?: ToolsBabelConfig;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/** Hooks */
|
|
3
3
|
import type { Server as NodeServer, IncomingMessage, ServerResponse } from 'http';
|
|
4
|
-
import { AsyncWaterfall, ParallelWorkflow, ToRunners, ToThreads, CommonAPI, PluginOptions, AsyncSetup, createContext, AsyncPipeline } from '@modern-js/plugin';
|
|
5
|
-
import { AfterMatchContext, AfterRenderContext, AfterStreamingRenderContext, CacheOption, Container, HttpMethodDecider, ISAppContext, Logger, Metrics, MiddlewareContext, Reporter, ServerRoute, UnstableMiddleware } from '@modern-js/types';
|
|
6
|
-
import { MiddlewareHandler } from 'hono';
|
|
7
|
-
import { UserConfig } from './config';
|
|
8
|
-
import { Render } from './render';
|
|
4
|
+
import type { AsyncWaterfall, ParallelWorkflow, ToRunners, ToThreads, CommonAPI, PluginOptions, AsyncSetup, createContext, AsyncPipeline } from '@modern-js/plugin';
|
|
5
|
+
import type { AfterMatchContext, AfterRenderContext, AfterStreamingRenderContext, CacheOption, Container, HttpMethodDecider, ISAppContext, Logger, Metrics, MiddlewareContext, Reporter, ServerRoute, UnstableMiddleware } from '@modern-js/types';
|
|
6
|
+
import type { MiddlewareHandler } from 'hono';
|
|
7
|
+
import type { UserConfig } from './config';
|
|
8
|
+
import type { Render } from './render';
|
|
9
9
|
export type ChangeEvent = 'add' | 'change' | 'unlink';
|
|
10
10
|
export interface Change {
|
|
11
11
|
filename: string;
|
|
@@ -116,7 +116,7 @@ declare module '@modern-js/types' {
|
|
|
116
116
|
}
|
|
117
117
|
export type NodeRequest = IncomingMessage;
|
|
118
118
|
export type NodeResponse = ServerResponse;
|
|
119
|
-
export { NodeServer };
|
|
119
|
+
export type { NodeServer };
|
|
120
120
|
export type AppContext = ReturnType<typeof createContext<ISAppContext>>;
|
|
121
121
|
export type ConfigContext = ReturnType<typeof createContext<ServerConfig>>;
|
|
122
122
|
export type ServerPluginAPI = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Metrics, Reporter, ServerRoute, Logger } from '@modern-js/types';
|
|
2
|
-
import { ServerUserConfig } from './config';
|
|
1
|
+
import type { Metrics, Reporter, ServerRoute, Logger } from '@modern-js/types';
|
|
2
|
+
import type { ServerUserConfig } from './config';
|
|
3
3
|
export type Resource = {
|
|
4
4
|
loadableStats: Record<string, any>;
|
|
5
5
|
routeManifest: Record<string, any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { Readable } from 'node:stream';
|
|
3
3
|
import type { Metrics, Logger, Reporter, BaseSSRServerContext, ServerRoute, NestedRoute, Monitors } from '@modern-js/types';
|
|
4
|
-
import { RequestHandler as BundleRequestHandler, OnError, OnTiming } from './requestHandler';
|
|
4
|
+
import type { RequestHandler as BundleRequestHandler, OnError, OnTiming } from './requestHandler';
|
|
5
5
|
export type SSRServerContext = BaseSSRServerContext & {
|
|
6
6
|
staticGenerate?: boolean;
|
|
7
7
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ServerRoute } from '@modern-js/types';
|
|
1
|
+
import type { ServerRoute } from '@modern-js/types';
|
|
2
2
|
export declare const sortRoutes: (route1: ServerRoute, route2: ServerRoute) => number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaybeAsync } from '@modern-js/plugin';
|
|
1
|
+
import type { MaybeAsync } from '@modern-js/plugin';
|
|
2
2
|
type TransformCb = (tempalte: string) => MaybeAsync<string>;
|
|
3
3
|
export declare function createTransformStream(fn?: TransformCb): TransformStream<any, any>;
|
|
4
4
|
export declare function transformResponse(response: Response, transformCb: Array<TransformCb> | TransformCb): Response;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.58.2
|
|
18
|
+
"version": "2.58.2",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"flatted": "^3.2.9",
|
|
54
54
|
"hono": "^3.12.2",
|
|
55
55
|
"ts-deepmerge": "7.0.0",
|
|
56
|
-
"@modern-js/plugin": "2.58.
|
|
57
|
-
"@modern-js/utils": "2.58.
|
|
58
|
-
"@modern-js/
|
|
56
|
+
"@modern-js/plugin": "2.58.2",
|
|
57
|
+
"@modern-js/runtime-utils": "2.58.2",
|
|
58
|
+
"@modern-js/utils": "2.58.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/jest": "^29",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"jest": "^29",
|
|
66
66
|
"ts-jest": "^29.1.0",
|
|
67
67
|
"typescript": "^5",
|
|
68
|
-
"@modern-js/types": "2.58.
|
|
69
|
-
"@scripts/build": "2.58.
|
|
70
|
-
"@scripts/jest-config": "2.58.
|
|
68
|
+
"@modern-js/types": "2.58.2",
|
|
69
|
+
"@scripts/build": "2.58.2",
|
|
70
|
+
"@scripts/jest-config": "2.58.2"
|
|
71
71
|
},
|
|
72
72
|
"sideEffects": false,
|
|
73
73
|
"publishConfig": {
|