@modern-js/server-core 2.65.5 → 2.65.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +2 -5
- package/dist/cjs/plugins/compat/hooks.js +92 -0
- package/dist/cjs/plugins/compat/index.js +65 -0
- package/dist/cjs/plugins/customServer/index.js +11 -17
- package/dist/cjs/plugins/default.js +2 -0
- package/dist/cjs/plugins/index.js +5 -0
- package/dist/cjs/plugins/render/index.js +2 -2
- package/dist/cjs/serverBase.js +31 -40
- package/dist/cjs/types/index.js +2 -2
- package/dist/cjs/types/{plugin.js → plugins/base.js} +2 -2
- package/dist/cjs/types/plugins/index.js +24 -0
- package/dist/cjs/types/plugins/new.js +16 -0
- package/dist/cjs/types/plugins/old.js +16 -0
- package/dist/esm/index.js +1 -3
- package/dist/esm/plugins/compat/hooks.js +70 -0
- package/dist/esm/plugins/compat/index.js +45 -0
- package/dist/esm/plugins/customServer/index.js +30 -22
- package/dist/esm/plugins/default.js +2 -0
- package/dist/esm/plugins/index.js +3 -0
- package/dist/esm/plugins/render/index.js +3 -3
- package/dist/esm/serverBase.js +34 -38
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/plugins/base.js +0 -0
- package/dist/esm/types/plugins/index.js +2 -0
- package/dist/esm/types/plugins/new.js +0 -0
- package/dist/esm/types/plugins/old.js +0 -0
- package/dist/esm-node/index.js +1 -3
- package/dist/esm-node/plugins/compat/hooks.js +66 -0
- package/dist/esm-node/plugins/compat/index.js +40 -0
- package/dist/esm-node/plugins/customServer/index.js +10 -16
- package/dist/esm-node/plugins/default.js +2 -0
- package/dist/esm-node/plugins/index.js +3 -0
- package/dist/esm-node/plugins/render/index.js +2 -2
- package/dist/esm-node/serverBase.js +31 -40
- package/dist/esm-node/types/index.js +1 -1
- package/dist/esm-node/types/plugins/index.js +2 -0
- package/dist/esm-node/types/plugins/old.js +0 -0
- package/dist/types/adapters/node/plugins/nodeServer.d.ts +4 -2
- package/dist/types/adapters/node/plugins/resource.d.ts +3 -3
- package/dist/types/adapters/node/plugins/static.d.ts +2 -2
- package/dist/types/index.d.ts +1 -2
- package/dist/types/plugins/compat/hooks.d.ts +8 -0
- package/dist/types/plugins/compat/index.d.ts +3 -0
- 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 +2 -2
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/plugins/log.d.ts +2 -2
- package/dist/types/plugins/monitors.d.ts +4 -4
- package/dist/types/plugins/processedBy.d.ts +2 -2
- package/dist/types/plugins/render/index.d.ts +2 -2
- package/dist/types/plugins/render/inject.d.ts +2 -2
- package/dist/types/plugins/route.d.ts +2 -2
- package/dist/types/serverBase.d.ts +11 -22
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/plugins/base.d.ts +80 -0
- package/dist/types/types/plugins/index.d.ts +3 -0
- package/dist/types/types/plugins/new.d.ts +34 -0
- package/dist/types/types/plugins/old.d.ts +56 -0
- package/package.json +4 -3
- package/dist/cjs/pluginManager.js +0 -106
- package/dist/esm/pluginManager.js +0 -140
- package/dist/esm-node/pluginManager.js +0 -82
- package/dist/types/pluginManager.d.ts +0 -31
- package/dist/types/types/plugin.d.ts +0 -150
- /package/dist/esm-node/types/{plugin.js → plugins/base.js} +0 -0
- /package/dist/{esm/types/plugin.js → esm-node/types/plugins/new.js} +0 -0
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
|
|
3
|
-
import { _ as _class_private_field_get } from "@swc/helpers/_/_class_private_field_get";
|
|
4
|
-
import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init";
|
|
5
|
-
import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set";
|
|
6
|
-
import { _ as _class_private_method_get } from "@swc/helpers/_/_class_private_method_get";
|
|
7
|
-
import { _ as _class_private_method_init } from "@swc/helpers/_/_class_private_method_init";
|
|
8
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
9
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
10
|
-
import { createAsyncManager, createAsyncPipeline, createAsyncWaterfall, createAsyncWorkflow, createContext, createParallelWorkflow } from "@modern-js/plugin";
|
|
11
|
-
import { loadConfig } from "./utils";
|
|
12
|
-
var _appContext = /* @__PURE__ */ new WeakMap(), _plugins = /* @__PURE__ */ new WeakMap(), _options = /* @__PURE__ */ new WeakMap(), _configContext = /* @__PURE__ */ new WeakMap(), _createCoreManager = /* @__PURE__ */ new WeakSet(), _initConfigContext = /* @__PURE__ */ new WeakSet();
|
|
13
|
-
var PluginManager = /* @__PURE__ */ function() {
|
|
14
|
-
"use strict";
|
|
15
|
-
function PluginManager2(options) {
|
|
16
|
-
_class_call_check(this, PluginManager2);
|
|
17
|
-
_class_private_method_init(this, _createCoreManager);
|
|
18
|
-
_class_private_method_init(this, _initConfigContext);
|
|
19
|
-
_class_private_field_init(this, _appContext, {
|
|
20
|
-
writable: true,
|
|
21
|
-
value: void 0
|
|
22
|
-
});
|
|
23
|
-
_class_private_field_init(this, _plugins, {
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
|
-
_class_private_field_init(this, _options, {
|
|
28
|
-
writable: true,
|
|
29
|
-
value: void 0
|
|
30
|
-
});
|
|
31
|
-
_class_private_field_init(this, _configContext, {
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
_class_private_field_set(this, _plugins, []);
|
|
36
|
-
_class_private_field_set(this, _configContext, createContext({}));
|
|
37
|
-
_class_private_field_set(this, _appContext, options.appContext);
|
|
38
|
-
_class_private_field_set(this, _configContext, createContext(options.serverConfig || {}));
|
|
39
|
-
_class_private_field_set(this, _options, options);
|
|
40
|
-
}
|
|
41
|
-
var _proto = PluginManager2.prototype;
|
|
42
|
-
_proto.init = function init() {
|
|
43
|
-
var _this = this;
|
|
44
|
-
return _async_to_generator(function() {
|
|
45
|
-
var coreManager, runner;
|
|
46
|
-
return _ts_generator(this, function(_state) {
|
|
47
|
-
switch (_state.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
coreManager = _class_private_method_get(_this, _createCoreManager, createCoreManager).call(_this);
|
|
50
|
-
return [
|
|
51
|
-
4,
|
|
52
|
-
coreManager.init()
|
|
53
|
-
];
|
|
54
|
-
case 1:
|
|
55
|
-
runner = _state.sent();
|
|
56
|
-
return [
|
|
57
|
-
4,
|
|
58
|
-
_class_private_method_get(_this, _initConfigContext, initConfigContext).call(_this, runner)
|
|
59
|
-
];
|
|
60
|
-
case 2:
|
|
61
|
-
_state.sent();
|
|
62
|
-
return [
|
|
63
|
-
2,
|
|
64
|
-
runner
|
|
65
|
-
];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
})();
|
|
69
|
-
};
|
|
70
|
-
_proto.addPlugins = function addPlugins(plugins) {
|
|
71
|
-
var _$_class_private_field_get;
|
|
72
|
-
(_$_class_private_field_get = _class_private_field_get(this, _plugins)).push.apply(_$_class_private_field_get, _to_consumable_array(plugins));
|
|
73
|
-
};
|
|
74
|
-
return PluginManager2;
|
|
75
|
-
}();
|
|
76
|
-
function createCoreManager() {
|
|
77
|
-
var _this = this;
|
|
78
|
-
var _class_private_field_get_serverConfig;
|
|
79
|
-
var hooks = {
|
|
80
|
-
config: createAsyncWaterfall(),
|
|
81
|
-
prepare: createAsyncWaterfall(),
|
|
82
|
-
reset: createAsyncWorkflow(),
|
|
83
|
-
prepareWebServer: createAsyncPipeline(),
|
|
84
|
-
fallback: createParallelWorkflow(),
|
|
85
|
-
prepareApiServer: createAsyncPipeline(),
|
|
86
|
-
afterMatch: createAsyncPipeline(),
|
|
87
|
-
afterRender: createAsyncPipeline(),
|
|
88
|
-
afterStreamingRender: createAsyncPipeline()
|
|
89
|
-
};
|
|
90
|
-
var pluginApi = {
|
|
91
|
-
useConfigContext: function() {
|
|
92
|
-
return _class_private_field_get(_this, _configContext).use().value;
|
|
93
|
-
},
|
|
94
|
-
useAppContext: function() {
|
|
95
|
-
return _class_private_field_get(_this, _appContext).use().value;
|
|
96
|
-
},
|
|
97
|
-
setAppContext: function(c) {
|
|
98
|
-
return _class_private_field_get(_this, _appContext).set(c);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var coreManager = createAsyncManager(hooks, pluginApi);
|
|
102
|
-
this.addPlugins(((_class_private_field_get_serverConfig = _class_private_field_get(this, _options).serverConfig) === null || _class_private_field_get_serverConfig === void 0 ? void 0 : _class_private_field_get_serverConfig.plugins) || []);
|
|
103
|
-
_class_private_field_get(this, _plugins).forEach(function(p) {
|
|
104
|
-
var plugin = coreManager.createPlugin(p.setup, p);
|
|
105
|
-
coreManager.usePlugin(plugin);
|
|
106
|
-
});
|
|
107
|
-
return coreManager;
|
|
108
|
-
}
|
|
109
|
-
function initConfigContext(runner) {
|
|
110
|
-
return _initConfigContext1.apply(this, arguments);
|
|
111
|
-
}
|
|
112
|
-
function _initConfigContext1() {
|
|
113
|
-
_initConfigContext1 = _async_to_generator(function(runner) {
|
|
114
|
-
var _$_class_private_field_get, serverConfig, cliConfig, mergedConfig, finalServerConfig;
|
|
115
|
-
return _ts_generator(this, function(_state) {
|
|
116
|
-
switch (_state.label) {
|
|
117
|
-
case 0:
|
|
118
|
-
_$_class_private_field_get = _class_private_field_get(this, _options), serverConfig = _$_class_private_field_get.serverConfig, cliConfig = _$_class_private_field_get.cliConfig;
|
|
119
|
-
mergedConfig = loadConfig({
|
|
120
|
-
cliConfig,
|
|
121
|
-
serverConfig: serverConfig || {}
|
|
122
|
-
});
|
|
123
|
-
return [
|
|
124
|
-
4,
|
|
125
|
-
runner.config(mergedConfig)
|
|
126
|
-
];
|
|
127
|
-
case 1:
|
|
128
|
-
finalServerConfig = _state.sent();
|
|
129
|
-
_class_private_field_get(this, _configContext).set(finalServerConfig);
|
|
130
|
-
return [
|
|
131
|
-
2
|
|
132
|
-
];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
return _initConfigContext1.apply(this, arguments);
|
|
137
|
-
}
|
|
138
|
-
export {
|
|
139
|
-
PluginManager
|
|
140
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { _ as _class_private_field_get } from "@swc/helpers/_/_class_private_field_get";
|
|
2
|
-
import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init";
|
|
3
|
-
import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set";
|
|
4
|
-
import { _ as _class_private_method_get } from "@swc/helpers/_/_class_private_method_get";
|
|
5
|
-
import { _ as _class_private_method_init } from "@swc/helpers/_/_class_private_method_init";
|
|
6
|
-
import { createAsyncManager, createAsyncPipeline, createAsyncWaterfall, createAsyncWorkflow, createContext, createParallelWorkflow } from "@modern-js/plugin";
|
|
7
|
-
import { loadConfig } from "./utils";
|
|
8
|
-
var _appContext = /* @__PURE__ */ new WeakMap(), _plugins = /* @__PURE__ */ new WeakMap(), _options = /* @__PURE__ */ new WeakMap(), _configContext = /* @__PURE__ */ new WeakMap(), _createCoreManager = /* @__PURE__ */ new WeakSet(), _initConfigContext = /* @__PURE__ */ new WeakSet();
|
|
9
|
-
class PluginManager {
|
|
10
|
-
async init() {
|
|
11
|
-
const coreManager = _class_private_method_get(this, _createCoreManager, createCoreManager).call(this);
|
|
12
|
-
const runner = await coreManager.init();
|
|
13
|
-
await _class_private_method_get(this, _initConfigContext, initConfigContext).call(this, runner);
|
|
14
|
-
return runner;
|
|
15
|
-
}
|
|
16
|
-
addPlugins(plugins) {
|
|
17
|
-
_class_private_field_get(this, _plugins).push(...plugins);
|
|
18
|
-
}
|
|
19
|
-
constructor(options) {
|
|
20
|
-
_class_private_method_init(this, _createCoreManager);
|
|
21
|
-
_class_private_method_init(this, _initConfigContext);
|
|
22
|
-
_class_private_field_init(this, _appContext, {
|
|
23
|
-
writable: true,
|
|
24
|
-
value: void 0
|
|
25
|
-
});
|
|
26
|
-
_class_private_field_init(this, _plugins, {
|
|
27
|
-
writable: true,
|
|
28
|
-
value: void 0
|
|
29
|
-
});
|
|
30
|
-
_class_private_field_init(this, _options, {
|
|
31
|
-
writable: true,
|
|
32
|
-
value: void 0
|
|
33
|
-
});
|
|
34
|
-
_class_private_field_init(this, _configContext, {
|
|
35
|
-
writable: true,
|
|
36
|
-
value: void 0
|
|
37
|
-
});
|
|
38
|
-
_class_private_field_set(this, _plugins, []);
|
|
39
|
-
_class_private_field_set(this, _configContext, createContext({}));
|
|
40
|
-
_class_private_field_set(this, _appContext, options.appContext);
|
|
41
|
-
_class_private_field_set(this, _configContext, createContext(options.serverConfig || {}));
|
|
42
|
-
_class_private_field_set(this, _options, options);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function createCoreManager() {
|
|
46
|
-
var _class_private_field_get_serverConfig;
|
|
47
|
-
const hooks = {
|
|
48
|
-
config: createAsyncWaterfall(),
|
|
49
|
-
prepare: createAsyncWaterfall(),
|
|
50
|
-
reset: createAsyncWorkflow(),
|
|
51
|
-
prepareWebServer: createAsyncPipeline(),
|
|
52
|
-
fallback: createParallelWorkflow(),
|
|
53
|
-
prepareApiServer: createAsyncPipeline(),
|
|
54
|
-
afterMatch: createAsyncPipeline(),
|
|
55
|
-
afterRender: createAsyncPipeline(),
|
|
56
|
-
afterStreamingRender: createAsyncPipeline()
|
|
57
|
-
};
|
|
58
|
-
const pluginApi = {
|
|
59
|
-
useConfigContext: () => _class_private_field_get(this, _configContext).use().value,
|
|
60
|
-
useAppContext: () => _class_private_field_get(this, _appContext).use().value,
|
|
61
|
-
setAppContext: (c) => _class_private_field_get(this, _appContext).set(c)
|
|
62
|
-
};
|
|
63
|
-
const coreManager = createAsyncManager(hooks, pluginApi);
|
|
64
|
-
this.addPlugins(((_class_private_field_get_serverConfig = _class_private_field_get(this, _options).serverConfig) === null || _class_private_field_get_serverConfig === void 0 ? void 0 : _class_private_field_get_serverConfig.plugins) || []);
|
|
65
|
-
_class_private_field_get(this, _plugins).forEach((p) => {
|
|
66
|
-
const plugin = coreManager.createPlugin(p.setup, p);
|
|
67
|
-
coreManager.usePlugin(plugin);
|
|
68
|
-
});
|
|
69
|
-
return coreManager;
|
|
70
|
-
}
|
|
71
|
-
async function initConfigContext(runner) {
|
|
72
|
-
const { serverConfig, cliConfig } = _class_private_field_get(this, _options);
|
|
73
|
-
const mergedConfig = loadConfig({
|
|
74
|
-
cliConfig,
|
|
75
|
-
serverConfig: serverConfig || {}
|
|
76
|
-
});
|
|
77
|
-
const finalServerConfig = await runner.config(mergedConfig);
|
|
78
|
-
_class_private_field_get(this, _configContext).set(finalServerConfig);
|
|
79
|
-
}
|
|
80
|
-
export {
|
|
81
|
-
PluginManager
|
|
82
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { AppContext, CliConfig, ServerConfig, ServerPlugin } from './types';
|
|
2
|
-
export interface PluginManagerOptions {
|
|
3
|
-
cliConfig: CliConfig;
|
|
4
|
-
appContext: AppContext;
|
|
5
|
-
plugins?: ServerPlugin[];
|
|
6
|
-
serverConfig?: ServerConfig;
|
|
7
|
-
}
|
|
8
|
-
export declare class PluginManager {
|
|
9
|
-
#private;
|
|
10
|
-
constructor(options: PluginManagerOptions);
|
|
11
|
-
init(): Promise<import("@modern-js/plugin").ToRunners<{
|
|
12
|
-
config: import("@modern-js/plugin").AsyncWaterfall<ServerConfig>;
|
|
13
|
-
prepare: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
14
|
-
reset: import("@modern-js/plugin").AsyncWorkflow<{
|
|
15
|
-
event: import("./types").ResetEvent;
|
|
16
|
-
}, void>;
|
|
17
|
-
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<import("./types").WebServerStartInput, import("./types").WebAdapter | import("@modern-js/types").UnstableMiddleware[] | null>;
|
|
18
|
-
fallback: import("@modern-js/plugin").ParallelWorkflow<{
|
|
19
|
-
reason: import("./types").FallbackReason;
|
|
20
|
-
error: unknown;
|
|
21
|
-
logger: import("@modern-js/types").Logger;
|
|
22
|
-
metrics?: import("@modern-js/types").Metrics | undefined;
|
|
23
|
-
reporter?: import("@modern-js/types").Reporter | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<import("./types").APIServerStartInput, import("hono/types").MiddlewareHandler>;
|
|
26
|
-
afterMatch: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/types").AfterMatchContext, any>;
|
|
27
|
-
afterRender: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/types").AfterRenderContext, any>;
|
|
28
|
-
afterStreamingRender: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/types").AfterStreamingRenderContext, string>;
|
|
29
|
-
}>>;
|
|
30
|
-
addPlugins(plugins: ServerPlugin[]): void;
|
|
31
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/** Hooks */
|
|
3
|
-
import type { IncomingMessage, Server as NodeServer, ServerResponse } from 'http';
|
|
4
|
-
import type { AsyncPipeline, AsyncSetup, AsyncWaterfall, AsyncWorkflow, CommonAPI, ParallelWorkflow, PluginOptions, ToRunners, ToThreads, createContext } 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
|
-
export type ChangeEvent = 'add' | 'change' | 'unlink';
|
|
10
|
-
export interface Change {
|
|
11
|
-
filename: string;
|
|
12
|
-
event: ChangeEvent;
|
|
13
|
-
}
|
|
14
|
-
export interface RepackEvent {
|
|
15
|
-
type: 'repack';
|
|
16
|
-
}
|
|
17
|
-
export interface FileChangeEvent {
|
|
18
|
-
type: 'file-change';
|
|
19
|
-
payload: Change[];
|
|
20
|
-
}
|
|
21
|
-
export type ResetEvent = RepackEvent | FileChangeEvent;
|
|
22
|
-
export type FallbackReason = 'error' | 'header' | 'query';
|
|
23
|
-
type FallbackInput = {
|
|
24
|
-
reason: FallbackReason;
|
|
25
|
-
error: unknown;
|
|
26
|
-
logger: Logger;
|
|
27
|
-
metrics?: Metrics;
|
|
28
|
-
reporter?: Reporter;
|
|
29
|
-
};
|
|
30
|
-
export type OnFallback = (reason: FallbackReason, utils: {
|
|
31
|
-
logger: Logger;
|
|
32
|
-
metrics?: Metrics;
|
|
33
|
-
reporter?: Reporter;
|
|
34
|
-
}, error?: unknown) => Promise<void>;
|
|
35
|
-
export type APIServerStartInput = {
|
|
36
|
-
pwd: string;
|
|
37
|
-
prefix?: string;
|
|
38
|
-
httpMethodDecider?: HttpMethodDecider;
|
|
39
|
-
config?: {
|
|
40
|
-
middleware?: Array<any>;
|
|
41
|
-
};
|
|
42
|
-
render?: Render | null;
|
|
43
|
-
};
|
|
44
|
-
export type WebServerStartInput = {
|
|
45
|
-
pwd: string;
|
|
46
|
-
config: Record<string, any>;
|
|
47
|
-
};
|
|
48
|
-
export type WebAdapter = (ctx: MiddlewareContext) => void | Promise<void>;
|
|
49
|
-
export interface ServerHooks {
|
|
50
|
-
config: AsyncWaterfall<ServerConfig>;
|
|
51
|
-
prepare: AsyncWaterfall<void>;
|
|
52
|
-
reset: AsyncWorkflow<{
|
|
53
|
-
event: ResetEvent;
|
|
54
|
-
}, void>;
|
|
55
|
-
/**
|
|
56
|
-
* @deprecated
|
|
57
|
-
*
|
|
58
|
-
* deprecate it next major version
|
|
59
|
-
* */
|
|
60
|
-
prepareWebServer: AsyncPipeline<WebServerStartInput, WebAdapter | Array<UnstableMiddleware> | null>;
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated
|
|
63
|
-
*
|
|
64
|
-
* deprecate it when server runtime entry refactor
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
fallback: ParallelWorkflow<FallbackInput>;
|
|
68
|
-
/**
|
|
69
|
-
* @deprecated
|
|
70
|
-
*
|
|
71
|
-
* deprecate it next major version
|
|
72
|
-
*/
|
|
73
|
-
prepareApiServer: AsyncPipeline<APIServerStartInput, MiddlewareHandler>;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated
|
|
76
|
-
*
|
|
77
|
-
* deprecate it next major version
|
|
78
|
-
*/
|
|
79
|
-
afterMatch: AsyncPipeline<AfterMatchContext, any>;
|
|
80
|
-
/**
|
|
81
|
-
* @deprecated
|
|
82
|
-
*
|
|
83
|
-
* deprecate it next major version
|
|
84
|
-
*/
|
|
85
|
-
afterRender: AsyncPipeline<AfterRenderContext, any>;
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated
|
|
88
|
-
*
|
|
89
|
-
* deprecate it next major version
|
|
90
|
-
* */
|
|
91
|
-
afterStreamingRender: AsyncPipeline<AfterStreamingRenderContext, string>;
|
|
92
|
-
}
|
|
93
|
-
export type ServerHookCallback = ToThreads<ServerHooks>;
|
|
94
|
-
/** Plugin Api */
|
|
95
|
-
type MiddlewareOrder = 'pre' | 'post' | 'default';
|
|
96
|
-
type Middleware = {
|
|
97
|
-
name: string;
|
|
98
|
-
path?: string;
|
|
99
|
-
method?: 'options' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'all';
|
|
100
|
-
handler: MiddlewareHandler | MiddlewareHandler[];
|
|
101
|
-
before?: Array<Middleware['name']>;
|
|
102
|
-
order?: MiddlewareOrder;
|
|
103
|
-
};
|
|
104
|
-
export interface GetRenderHandlerOptions {
|
|
105
|
-
pwd: string;
|
|
106
|
-
routes: ServerRoute[];
|
|
107
|
-
config: UserConfig;
|
|
108
|
-
onFallback?: OnFallback;
|
|
109
|
-
cacheConfig?: CacheConfig;
|
|
110
|
-
staticGenerate?: boolean;
|
|
111
|
-
metaName?: string;
|
|
112
|
-
}
|
|
113
|
-
declare module '@modern-js/types' {
|
|
114
|
-
interface ISAppContext {
|
|
115
|
-
middlewares: Middleware[];
|
|
116
|
-
metaName: string;
|
|
117
|
-
getRenderOptions?: GetRenderHandlerOptions;
|
|
118
|
-
render?: Render;
|
|
119
|
-
routes?: ServerRoute[];
|
|
120
|
-
nodeServer?: NodeServer;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
export type NodeRequest = IncomingMessage;
|
|
124
|
-
export type NodeResponse = ServerResponse;
|
|
125
|
-
export type { NodeServer };
|
|
126
|
-
export type AppContext = ReturnType<typeof createContext<ISAppContext>>;
|
|
127
|
-
export type ConfigContext = ReturnType<typeof createContext<ServerConfig>>;
|
|
128
|
-
export type ServerPluginAPI = {
|
|
129
|
-
setAppContext: (c: ISAppContext) => void;
|
|
130
|
-
useAppContext: () => ISAppContext;
|
|
131
|
-
useConfigContext: () => ServerConfig;
|
|
132
|
-
};
|
|
133
|
-
export type PluginAPI = ServerPluginAPI & CommonAPI<ServerHooks>;
|
|
134
|
-
/** Runner */
|
|
135
|
-
export type ServerHookRunner = ToRunners<ServerHooks>;
|
|
136
|
-
/** Plugin options of a server plugin. */
|
|
137
|
-
export type ServerPlugin = PluginOptions<ServerHooks, AsyncSetup<ServerHooks, PluginAPI>>;
|
|
138
|
-
export type CacheConfig = {
|
|
139
|
-
strategy: CacheOption;
|
|
140
|
-
container?: Container;
|
|
141
|
-
};
|
|
142
|
-
type RenderMiddleware = UnstableMiddleware;
|
|
143
|
-
export interface RenderConfig {
|
|
144
|
-
cache?: CacheConfig;
|
|
145
|
-
middleware?: RenderMiddleware[];
|
|
146
|
-
}
|
|
147
|
-
export type ServerConfig = {
|
|
148
|
-
render?: RenderConfig;
|
|
149
|
-
plugins?: ServerPlugin[];
|
|
150
|
-
} & UserConfig;
|
|
File without changes
|
|
File without changes
|