@modern-js/server-core 1.21.2-beta.0 → 1.21.2-beta.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.
@@ -0,0 +1,3 @@
1
+ export * from "./plugin";
2
+ export * from '@modern-js/plugin';
3
+ export * from "./loadPlugins";
@@ -0,0 +1,47 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import { compatRequire, tryResolve } from '@modern-js/utils';
8
+ import { createPlugin } from "./plugin";
9
+ export const loadPlugins = (plugins, appDirectory) => {
10
+ const resolvePlugin = p => {
11
+ const isPluginInstance = typeof p !== 'string' && !Array.isArray(p);
12
+
13
+ if (isPluginInstance) {
14
+ return {
15
+ module: createPlugin(p.setup, p)
16
+ };
17
+ }
18
+
19
+ const [pkg, options] = typeof p === 'string' ? [p, undefined] : p;
20
+ const pluginPath = tryResolve(pkg, appDirectory);
21
+ let module = compatRequire(pluginPath);
22
+ const useNewSyntax = typeof module === 'function';
23
+
24
+ if (useNewSyntax) {
25
+ const plugin = module(options);
26
+ module = createPlugin(plugin.setup, plugin);
27
+ }
28
+
29
+ return {
30
+ pkg,
31
+ path: pluginPath,
32
+ module
33
+ };
34
+ };
35
+
36
+ return plugins.map(plugin => {
37
+ const {
38
+ pkg,
39
+ path,
40
+ module
41
+ } = resolvePlugin(plugin);
42
+ return _objectSpread(_objectSpread({}, module), {}, {
43
+ pluginPath: path,
44
+ pkg
45
+ });
46
+ });
47
+ };
@@ -0,0 +1,95 @@
1
+ import { createContext, createAsyncManager, createAsyncPipeline, createAsyncWaterfall, createParallelWorkflow, createWaterfall } from '@modern-js/plugin';
2
+ // collect all middleware register in server plugins
3
+ const gather = createParallelWorkflow();
4
+ // config
5
+ const config = createWaterfall();
6
+ const prepare = createWaterfall();
7
+ const create = createAsyncPipeline();
8
+ const prepareWebServer = createAsyncPipeline();
9
+ const prepareApiServer = createAsyncPipeline();
10
+ const onApiChange = createWaterfall();
11
+ const beforeDevServer = createParallelWorkflow();
12
+ const setupCompiler = createParallelWorkflow();
13
+ const afterDevServer = createParallelWorkflow(); // TODO FIXME
14
+
15
+ const beforeRouteSet = createAsyncPipeline();
16
+ const afterRouteSet = createAsyncPipeline();
17
+ const beforeProdServer = createParallelWorkflow();
18
+ const afterProdServer = createParallelWorkflow();
19
+ const listen = createParallelWorkflow();
20
+ const beforeServerReset = createParallelWorkflow();
21
+ const afterServerReset = createParallelWorkflow();
22
+ const extendSSRContext = createAsyncWaterfall();
23
+ const extendContext = createAsyncPipeline();
24
+ const handleError = createParallelWorkflow();
25
+ const beforeMatch = createAsyncPipeline();
26
+ const afterMatch = createAsyncPipeline(); // TODO FIXME
27
+
28
+ const prefetch = createParallelWorkflow(); // TODO FIXME
29
+
30
+ const renderToString = createAsyncPipeline();
31
+ const beforeRender = createAsyncPipeline();
32
+ const afterRender = createAsyncPipeline();
33
+ const beforeSend = createAsyncPipeline();
34
+ const afterSend = createParallelWorkflow();
35
+ const reset = createParallelWorkflow();
36
+ export const AppContext = createContext({});
37
+ export const setAppContext = value => AppContext.set(value);
38
+ export const ConfigContext = createContext({});
39
+ /**
40
+ * Get original content of user config.
41
+ */
42
+
43
+ export const useConfigContext = () => ConfigContext.use().value;
44
+ /**
45
+ * Get app context, including directories, plugins and some static infos.
46
+ */
47
+
48
+ export const useAppContext = () => AppContext.use().value;
49
+ const pluginAPI = {
50
+ useAppContext,
51
+ useConfigContext,
52
+ setAppContext
53
+ };
54
+ const serverHooks = {
55
+ // server hook
56
+ gather,
57
+ config,
58
+ prepare,
59
+ create,
60
+ prepareWebServer,
61
+ prepareApiServer,
62
+ onApiChange,
63
+ beforeDevServer,
64
+ setupCompiler,
65
+ afterDevServer,
66
+ beforeRouteSet,
67
+ afterRouteSet,
68
+ beforeProdServer,
69
+ afterProdServer,
70
+ listen,
71
+ beforeServerReset,
72
+ afterServerReset,
73
+ // request hook
74
+ extendSSRContext,
75
+ extendContext,
76
+ handleError,
77
+ beforeMatch,
78
+ afterMatch,
79
+ prefetch,
80
+ renderToString,
81
+ beforeRender,
82
+ afterRender,
83
+ beforeSend,
84
+ afterSend,
85
+ reset
86
+ };
87
+ /** All hooks of server plugin. */
88
+
89
+ export const createServerManager = () => createAsyncManager(serverHooks, pluginAPI);
90
+ export const serverManager = createServerManager();
91
+ /** Plugin options of a server plugin. */
92
+
93
+ export const {
94
+ createPlugin
95
+ } = serverManager;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _plugin = require("./plugin");
8
+
9
+ Object.keys(_plugin).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _plugin[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _plugin[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _plugin2 = require("@modern-js/plugin");
21
+
22
+ Object.keys(_plugin2).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _plugin2[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _plugin2[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _loadPlugins = require("./loadPlugins");
34
+
35
+ Object.keys(_loadPlugins).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _loadPlugins[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _loadPlugins[key];
42
+ }
43
+ });
44
+ });
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.loadPlugins = void 0;
7
+
8
+ var _utils = require("@modern-js/utils");
9
+
10
+ var _plugin = require("./plugin");
11
+
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
+
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
+
16
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+
18
+ const loadPlugins = (plugins, appDirectory) => {
19
+ const resolvePlugin = p => {
20
+ const isPluginInstance = typeof p !== 'string' && !Array.isArray(p);
21
+
22
+ if (isPluginInstance) {
23
+ return {
24
+ module: (0, _plugin.createPlugin)(p.setup, p)
25
+ };
26
+ }
27
+
28
+ const [pkg, options] = typeof p === 'string' ? [p, undefined] : p;
29
+ const pluginPath = (0, _utils.tryResolve)(pkg, appDirectory);
30
+ let module = (0, _utils.compatRequire)(pluginPath);
31
+ const useNewSyntax = typeof module === 'function';
32
+
33
+ if (useNewSyntax) {
34
+ const plugin = module(options);
35
+ module = (0, _plugin.createPlugin)(plugin.setup, plugin);
36
+ }
37
+
38
+ return {
39
+ pkg,
40
+ path: pluginPath,
41
+ module
42
+ };
43
+ };
44
+
45
+ return plugins.map(plugin => {
46
+ const {
47
+ pkg,
48
+ path,
49
+ module
50
+ } = resolvePlugin(plugin);
51
+ return _objectSpread(_objectSpread({}, module), {}, {
52
+ pluginPath: path,
53
+ pkg
54
+ });
55
+ });
56
+ };
57
+
58
+ exports.loadPlugins = loadPlugins;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useConfigContext = exports.useAppContext = exports.setAppContext = exports.serverManager = exports.createServerManager = exports.createPlugin = exports.ConfigContext = exports.AppContext = void 0;
7
+
8
+ var _plugin = require("@modern-js/plugin");
9
+
10
+ // collect all middleware register in server plugins
11
+ const gather = (0, _plugin.createParallelWorkflow)();
12
+ // config
13
+ const config = (0, _plugin.createWaterfall)();
14
+ const prepare = (0, _plugin.createWaterfall)();
15
+ const create = (0, _plugin.createAsyncPipeline)();
16
+ const prepareWebServer = (0, _plugin.createAsyncPipeline)();
17
+ const prepareApiServer = (0, _plugin.createAsyncPipeline)();
18
+ const onApiChange = (0, _plugin.createWaterfall)();
19
+ const beforeDevServer = (0, _plugin.createParallelWorkflow)();
20
+ const setupCompiler = (0, _plugin.createParallelWorkflow)();
21
+ const afterDevServer = (0, _plugin.createParallelWorkflow)(); // TODO FIXME
22
+
23
+ const beforeRouteSet = (0, _plugin.createAsyncPipeline)();
24
+ const afterRouteSet = (0, _plugin.createAsyncPipeline)();
25
+ const beforeProdServer = (0, _plugin.createParallelWorkflow)();
26
+ const afterProdServer = (0, _plugin.createParallelWorkflow)();
27
+ const listen = (0, _plugin.createParallelWorkflow)();
28
+ const beforeServerReset = (0, _plugin.createParallelWorkflow)();
29
+ const afterServerReset = (0, _plugin.createParallelWorkflow)();
30
+ const extendSSRContext = (0, _plugin.createAsyncWaterfall)();
31
+ const extendContext = (0, _plugin.createAsyncPipeline)();
32
+ const handleError = (0, _plugin.createParallelWorkflow)();
33
+ const beforeMatch = (0, _plugin.createAsyncPipeline)();
34
+ const afterMatch = (0, _plugin.createAsyncPipeline)(); // TODO FIXME
35
+
36
+ const prefetch = (0, _plugin.createParallelWorkflow)(); // TODO FIXME
37
+
38
+ const renderToString = (0, _plugin.createAsyncPipeline)();
39
+ const beforeRender = (0, _plugin.createAsyncPipeline)();
40
+ const afterRender = (0, _plugin.createAsyncPipeline)();
41
+ const beforeSend = (0, _plugin.createAsyncPipeline)();
42
+ const afterSend = (0, _plugin.createParallelWorkflow)();
43
+ const reset = (0, _plugin.createParallelWorkflow)();
44
+ const AppContext = (0, _plugin.createContext)({});
45
+ exports.AppContext = AppContext;
46
+
47
+ const setAppContext = value => AppContext.set(value);
48
+
49
+ exports.setAppContext = setAppContext;
50
+ const ConfigContext = (0, _plugin.createContext)({});
51
+ /**
52
+ * Get original content of user config.
53
+ */
54
+
55
+ exports.ConfigContext = ConfigContext;
56
+
57
+ const useConfigContext = () => ConfigContext.use().value;
58
+ /**
59
+ * Get app context, including directories, plugins and some static infos.
60
+ */
61
+
62
+
63
+ exports.useConfigContext = useConfigContext;
64
+
65
+ const useAppContext = () => AppContext.use().value;
66
+
67
+ exports.useAppContext = useAppContext;
68
+ const pluginAPI = {
69
+ useAppContext,
70
+ useConfigContext,
71
+ setAppContext
72
+ };
73
+ const serverHooks = {
74
+ // server hook
75
+ gather,
76
+ config,
77
+ prepare,
78
+ create,
79
+ prepareWebServer,
80
+ prepareApiServer,
81
+ onApiChange,
82
+ beforeDevServer,
83
+ setupCompiler,
84
+ afterDevServer,
85
+ beforeRouteSet,
86
+ afterRouteSet,
87
+ beforeProdServer,
88
+ afterProdServer,
89
+ listen,
90
+ beforeServerReset,
91
+ afterServerReset,
92
+ // request hook
93
+ extendSSRContext,
94
+ extendContext,
95
+ handleError,
96
+ beforeMatch,
97
+ afterMatch,
98
+ prefetch,
99
+ renderToString,
100
+ beforeRender,
101
+ afterRender,
102
+ beforeSend,
103
+ afterSend,
104
+ reset
105
+ };
106
+ /** All hooks of server plugin. */
107
+
108
+ const createServerManager = () => (0, _plugin.createAsyncManager)(serverHooks, pluginAPI);
109
+
110
+ exports.createServerManager = createServerManager;
111
+ const serverManager = createServerManager();
112
+ /** Plugin options of a server plugin. */
113
+
114
+ exports.serverManager = serverManager;
115
+ const {
116
+ createPlugin
117
+ } = serverManager;
118
+ exports.createPlugin = createPlugin;
@@ -0,0 +1,3 @@
1
+ export * from './plugin';
2
+ export * from '@modern-js/plugin';
3
+ export * from './loadPlugins';
@@ -0,0 +1,4 @@
1
+ import { ServerPlugin } from './plugin';
2
+ declare type Plugin = string | [string, any] | ServerPlugin;
3
+ export declare const loadPlugins: (plugins: Plugin[], appDirectory: string) => any[];
4
+ export {};
@@ -0,0 +1,497 @@
1
+ /// <reference types="node" />
2
+ import { IncomingMessage, ServerResponse } from 'http';
3
+ import type { Component } from 'react';
4
+ import { CommonAPI, ToThreads, AsyncSetup, PluginOptions } from '@modern-js/plugin';
5
+ import type { ModernServerContext, BaseSSRServerContext, Metrics, Logger } from '@modern-js/types/server';
6
+ import type { NormalizedConfig, UserConfig } from '@modern-js/core';
7
+ import type { ISAppContext } from '@modern-js/types';
8
+ import type { Options } from 'http-proxy-middleware';
9
+ /** The subset of NormalizedConfig, which really need in server */
10
+
11
+ export declare type ServerOptions = {
12
+ output: Pick<NormalizedConfig['output'], 'path' | 'assetPrefix'>;
13
+ source: Pick<NormalizedConfig['source'], 'alias' | 'envVars' | 'globalVars'>;
14
+ tools: {
15
+ babel: NormalizedConfig['tools']['babel'];
16
+ };
17
+ server: NormalizedConfig['server'];
18
+ runtime: NormalizedConfig['runtime'];
19
+ bff: NormalizedConfig['bff'];
20
+ plugins: NormalizedConfig['plugins'];
21
+ };
22
+ declare type ServerInitInput = {
23
+ loggerOptions: any;
24
+ metricsOptions: any;
25
+ };
26
+ declare type InitExtension = {
27
+ logger: Logger;
28
+ metrics: Metrics;
29
+ };
30
+ export declare type Adapter = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
31
+ export declare type WebServerStartInput = {
32
+ pwd: string;
33
+ config: Record<string, any>;
34
+ };
35
+ export declare type APIServerStartInput = {
36
+ pwd: string;
37
+ prefix?: string;
38
+ config?: {
39
+ middleware?: Array<any>;
40
+ };
41
+ };
42
+ declare type Change = {
43
+ filename: string;
44
+ event: 'add' | 'change' | 'unlink';
45
+ };
46
+ export declare type Route = Record<string, unknown>;
47
+ export declare type RequestResult = {
48
+ isfinish: boolean;
49
+ };
50
+ export declare type SSRServerContext = Record<string, unknown>;
51
+ export declare type RenderContext = Record<string, unknown>;
52
+ export declare const AppContext: import("@modern-js/plugin").Context<ISAppContext>;
53
+ export declare const setAppContext: (value: ISAppContext) => void;
54
+ export declare const ConfigContext: import("@modern-js/plugin").Context<UserConfig>;
55
+ /**
56
+ * Get original content of user config.
57
+ */
58
+
59
+ export declare const useConfigContext: () => UserConfig;
60
+ /**
61
+ * Get app context, including directories, plugins and some static infos.
62
+ */
63
+
64
+ export declare const useAppContext: () => ISAppContext;
65
+ declare const pluginAPI: {
66
+ useAppContext: () => ISAppContext;
67
+ useConfigContext: () => UserConfig;
68
+ setAppContext: (value: ISAppContext) => void;
69
+ };
70
+ declare const serverHooks: {
71
+ gather: import("@modern-js/plugin").ParallelWorkflow<{
72
+ addWebMiddleware: (_input: any) => void;
73
+ addAPIMiddleware: (_input: any) => void;
74
+ }, unknown>;
75
+ config: import("@modern-js/plugin").Waterfall<ServerConfig>;
76
+ prepare: import("@modern-js/plugin").Waterfall<void>;
77
+ create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
78
+ prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
79
+ prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
80
+ onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
81
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
82
+ setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
83
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
84
+ beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
85
+ afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
86
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
87
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
88
+ listen: import("@modern-js/plugin").ParallelWorkflow<{
89
+ ip: string;
90
+ port: number;
91
+ }, any[]>;
92
+ beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
93
+ afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
94
+ extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
95
+ extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
96
+ handleError: import("@modern-js/plugin").ParallelWorkflow<{
97
+ error: Error;
98
+ }, unknown>;
99
+ beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
100
+ context: ModernServerContext;
101
+ }, any>;
102
+ afterMatch: import("@modern-js/plugin").AsyncPipeline<{
103
+ context: ModernServerContext;
104
+ routeAPI: any;
105
+ }, any>;
106
+ prefetch: import("@modern-js/plugin").ParallelWorkflow<{
107
+ context: SSRServerContext;
108
+ }, unknown>;
109
+ renderToString: import("@modern-js/plugin").AsyncPipeline<{
110
+ App: Component;
111
+ context: RenderContext;
112
+ }, string>;
113
+ beforeRender: import("@modern-js/plugin").AsyncPipeline<{
114
+ context: ModernServerContext;
115
+ }, any>;
116
+ afterRender: import("@modern-js/plugin").AsyncPipeline<{
117
+ context: ModernServerContext;
118
+ templateAPI: any;
119
+ }, any>;
120
+ beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
121
+ afterSend: import("@modern-js/plugin").ParallelWorkflow<{
122
+ context: ModernServerContext;
123
+ }, unknown>;
124
+ reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
125
+ };
126
+ /** All hooks of server plugin. */
127
+
128
+ export declare type ServerHooks = typeof serverHooks;
129
+ /** All hook callbacks of server plugin. */
130
+
131
+ export declare type ServerHookCallbacks = ToThreads<ServerHooks>;
132
+ /** All apis for server plugin. */
133
+
134
+ export declare type PluginAPI = typeof pluginAPI & CommonAPI<ServerHooks>;
135
+ export declare const createServerManager: () => import("@modern-js/plugin").AsyncManager<{
136
+ gather: import("@modern-js/plugin").ParallelWorkflow<{
137
+ addWebMiddleware: (_input: any) => void;
138
+ addAPIMiddleware: (_input: any) => void;
139
+ }, unknown>;
140
+ config: import("@modern-js/plugin").Waterfall<ServerConfig>;
141
+ prepare: import("@modern-js/plugin").Waterfall<void>;
142
+ create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
143
+ prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
144
+ prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
145
+ onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
146
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
147
+ setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
148
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
149
+ beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
150
+ afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
151
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
152
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
153
+ listen: import("@modern-js/plugin").ParallelWorkflow<{
154
+ ip: string;
155
+ port: number;
156
+ }, any[]>;
157
+ beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
158
+ afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
159
+ extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
160
+ extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
161
+ handleError: import("@modern-js/plugin").ParallelWorkflow<{
162
+ error: Error;
163
+ }, unknown>;
164
+ beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
165
+ context: ModernServerContext;
166
+ }, any>;
167
+ afterMatch: import("@modern-js/plugin").AsyncPipeline<{
168
+ context: ModernServerContext;
169
+ routeAPI: any;
170
+ }, any>;
171
+ prefetch: import("@modern-js/plugin").ParallelWorkflow<{
172
+ context: SSRServerContext;
173
+ }, unknown>;
174
+ renderToString: import("@modern-js/plugin").AsyncPipeline<{
175
+ App: Component;
176
+ context: RenderContext;
177
+ }, string>;
178
+ beforeRender: import("@modern-js/plugin").AsyncPipeline<{
179
+ context: ModernServerContext;
180
+ }, any>;
181
+ afterRender: import("@modern-js/plugin").AsyncPipeline<{
182
+ context: ModernServerContext;
183
+ templateAPI: any;
184
+ }, any>;
185
+ beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
186
+ afterSend: import("@modern-js/plugin").ParallelWorkflow<{
187
+ context: ModernServerContext;
188
+ }, unknown>;
189
+ reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
190
+ }, {
191
+ useAppContext: () => ISAppContext;
192
+ useConfigContext: () => UserConfig;
193
+ setAppContext: (value: ISAppContext) => void;
194
+ }>;
195
+ export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
196
+ gather: import("@modern-js/plugin").ParallelWorkflow<{
197
+ addWebMiddleware: (_input: any) => void;
198
+ addAPIMiddleware: (_input: any) => void;
199
+ }, unknown>;
200
+ config: import("@modern-js/plugin").Waterfall<ServerConfig>;
201
+ prepare: import("@modern-js/plugin").Waterfall<void>;
202
+ create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
203
+ prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
204
+ prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
205
+ onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
206
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
207
+ setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
208
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
209
+ beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
210
+ afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
211
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
212
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
213
+ listen: import("@modern-js/plugin").ParallelWorkflow<{
214
+ ip: string;
215
+ port: number;
216
+ }, any[]>;
217
+ beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
218
+ afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
219
+ extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
220
+ extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
221
+ handleError: import("@modern-js/plugin").ParallelWorkflow<{
222
+ error: Error;
223
+ }, unknown>;
224
+ beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
225
+ context: ModernServerContext;
226
+ }, any>;
227
+ afterMatch: import("@modern-js/plugin").AsyncPipeline<{
228
+ context: ModernServerContext;
229
+ routeAPI: any;
230
+ }, any>;
231
+ prefetch: import("@modern-js/plugin").ParallelWorkflow<{
232
+ context: SSRServerContext;
233
+ }, unknown>;
234
+ renderToString: import("@modern-js/plugin").AsyncPipeline<{
235
+ App: Component;
236
+ context: RenderContext;
237
+ }, string>;
238
+ beforeRender: import("@modern-js/plugin").AsyncPipeline<{
239
+ context: ModernServerContext;
240
+ }, any>;
241
+ afterRender: import("@modern-js/plugin").AsyncPipeline<{
242
+ context: ModernServerContext;
243
+ templateAPI: any;
244
+ }, any>;
245
+ beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
246
+ afterSend: import("@modern-js/plugin").ParallelWorkflow<{
247
+ context: ModernServerContext;
248
+ }, unknown>;
249
+ reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
250
+ }, {
251
+ useAppContext: () => ISAppContext;
252
+ useConfigContext: () => UserConfig;
253
+ setAppContext: (value: ISAppContext) => void;
254
+ }>;
255
+ /** Plugin options of a server plugin. */
256
+
257
+ export declare type ServerPlugin = PluginOptions<ServerHooks, AsyncSetup<ServerHooks, PluginAPI>>;
258
+ export declare type ServerConfig = {
259
+ bff?: Partial<{
260
+ proxy: Record<string, Options>;
261
+ }>;
262
+ plugins?: ServerPlugin[];
263
+ };
264
+ export declare const createPlugin: (setup?: AsyncSetup<{
265
+ gather: import("@modern-js/plugin").ParallelWorkflow<{
266
+ addWebMiddleware: (_input: any) => void;
267
+ addAPIMiddleware: (_input: any) => void;
268
+ }, unknown>;
269
+ config: import("@modern-js/plugin").Waterfall<ServerConfig>;
270
+ prepare: import("@modern-js/plugin").Waterfall<void>;
271
+ create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
272
+ prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
273
+ prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
274
+ onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
275
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
276
+ setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
277
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
278
+ beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
279
+ afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
280
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
281
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
282
+ listen: import("@modern-js/plugin").ParallelWorkflow<{
283
+ ip: string;
284
+ port: number;
285
+ }, any[]>;
286
+ beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
287
+ afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
288
+ extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
289
+ extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
290
+ handleError: import("@modern-js/plugin").ParallelWorkflow<{
291
+ error: Error;
292
+ }, unknown>;
293
+ beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
294
+ context: ModernServerContext;
295
+ }, any>;
296
+ afterMatch: import("@modern-js/plugin").AsyncPipeline<{
297
+ context: ModernServerContext;
298
+ routeAPI: any;
299
+ }, any>;
300
+ prefetch: import("@modern-js/plugin").ParallelWorkflow<{
301
+ context: SSRServerContext;
302
+ }, unknown>;
303
+ renderToString: import("@modern-js/plugin").AsyncPipeline<{
304
+ App: Component;
305
+ context: RenderContext;
306
+ }, string>;
307
+ beforeRender: import("@modern-js/plugin").AsyncPipeline<{
308
+ context: ModernServerContext;
309
+ }, any>;
310
+ afterRender: import("@modern-js/plugin").AsyncPipeline<{
311
+ context: ModernServerContext;
312
+ templateAPI: any;
313
+ }, any>;
314
+ beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
315
+ afterSend: import("@modern-js/plugin").ParallelWorkflow<{
316
+ context: ModernServerContext;
317
+ }, unknown>;
318
+ reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
319
+ }, {
320
+ useAppContext: () => ISAppContext;
321
+ useConfigContext: () => UserConfig;
322
+ setAppContext: (value: ISAppContext) => void;
323
+ }> | undefined, options?: PluginOptions<{
324
+ gather: import("@modern-js/plugin").ParallelWorkflow<{
325
+ addWebMiddleware: (_input: any) => void;
326
+ addAPIMiddleware: (_input: any) => void;
327
+ }, unknown>;
328
+ config: import("@modern-js/plugin").Waterfall<ServerConfig>;
329
+ prepare: import("@modern-js/plugin").Waterfall<void>;
330
+ create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
331
+ prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
332
+ prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
333
+ onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
334
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
335
+ setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
336
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
337
+ beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
338
+ afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
339
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
340
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
341
+ listen: import("@modern-js/plugin").ParallelWorkflow<{
342
+ ip: string;
343
+ port: number;
344
+ }, any[]>;
345
+ beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
346
+ afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
347
+ extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
348
+ extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
349
+ handleError: import("@modern-js/plugin").ParallelWorkflow<{
350
+ error: Error;
351
+ }, unknown>;
352
+ beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
353
+ context: ModernServerContext;
354
+ }, any>;
355
+ afterMatch: import("@modern-js/plugin").AsyncPipeline<{
356
+ context: ModernServerContext;
357
+ routeAPI: any;
358
+ }, any>;
359
+ prefetch: import("@modern-js/plugin").ParallelWorkflow<{
360
+ context: SSRServerContext;
361
+ }, unknown>;
362
+ renderToString: import("@modern-js/plugin").AsyncPipeline<{
363
+ App: Component;
364
+ context: RenderContext;
365
+ }, string>;
366
+ beforeRender: import("@modern-js/plugin").AsyncPipeline<{
367
+ context: ModernServerContext;
368
+ }, any>;
369
+ afterRender: import("@modern-js/plugin").AsyncPipeline<{
370
+ context: ModernServerContext;
371
+ templateAPI: any;
372
+ }, any>;
373
+ beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
374
+ afterSend: import("@modern-js/plugin").ParallelWorkflow<{
375
+ context: ModernServerContext;
376
+ }, unknown>;
377
+ reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
378
+ }, AsyncSetup<{
379
+ gather: import("@modern-js/plugin").ParallelWorkflow<{
380
+ addWebMiddleware: (_input: any) => void;
381
+ addAPIMiddleware: (_input: any) => void;
382
+ }, unknown>;
383
+ config: import("@modern-js/plugin").Waterfall<ServerConfig>;
384
+ prepare: import("@modern-js/plugin").Waterfall<void>;
385
+ create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
386
+ prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
387
+ prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
388
+ onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
389
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
390
+ setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
391
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
392
+ beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
393
+ afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
394
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
395
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
396
+ listen: import("@modern-js/plugin").ParallelWorkflow<{
397
+ ip: string;
398
+ port: number;
399
+ }, any[]>;
400
+ beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
401
+ afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
402
+ extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
403
+ extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
404
+ handleError: import("@modern-js/plugin").ParallelWorkflow<{
405
+ error: Error;
406
+ }, unknown>;
407
+ beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
408
+ context: ModernServerContext;
409
+ }, any>;
410
+ afterMatch: import("@modern-js/plugin").AsyncPipeline<{
411
+ context: ModernServerContext;
412
+ routeAPI: any;
413
+ }, any>;
414
+ prefetch: import("@modern-js/plugin").ParallelWorkflow<{
415
+ context: SSRServerContext;
416
+ }, unknown>;
417
+ renderToString: import("@modern-js/plugin").AsyncPipeline<{
418
+ App: Component;
419
+ context: RenderContext;
420
+ }, string>;
421
+ beforeRender: import("@modern-js/plugin").AsyncPipeline<{
422
+ context: ModernServerContext;
423
+ }, any>;
424
+ afterRender: import("@modern-js/plugin").AsyncPipeline<{
425
+ context: ModernServerContext;
426
+ templateAPI: any;
427
+ }, any>;
428
+ beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
429
+ afterSend: import("@modern-js/plugin").ParallelWorkflow<{
430
+ context: ModernServerContext;
431
+ }, unknown>;
432
+ reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
433
+ }, {
434
+ useAppContext: () => ISAppContext;
435
+ useConfigContext: () => UserConfig;
436
+ setAppContext: (value: ISAppContext) => void;
437
+ }>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
438
+ gather: import("@modern-js/plugin").ParallelWorkflow<{
439
+ addWebMiddleware: (_input: any) => void;
440
+ addAPIMiddleware: (_input: any) => void;
441
+ }, unknown>;
442
+ config: import("@modern-js/plugin").Waterfall<ServerConfig>;
443
+ prepare: import("@modern-js/plugin").Waterfall<void>;
444
+ create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
445
+ prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
446
+ prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
447
+ onApiChange: import("@modern-js/plugin").Waterfall<Change[]>;
448
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
449
+ setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
450
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
451
+ beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<Route[], Route[]>;
452
+ afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
453
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
454
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<ServerOptions, any>;
455
+ listen: import("@modern-js/plugin").ParallelWorkflow<{
456
+ ip: string;
457
+ port: number;
458
+ }, any[]>;
459
+ beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
460
+ afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
461
+ extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<BaseSSRServerContext>;
462
+ extendContext: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, ModernServerContext>;
463
+ handleError: import("@modern-js/plugin").ParallelWorkflow<{
464
+ error: Error;
465
+ }, unknown>;
466
+ beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
467
+ context: ModernServerContext;
468
+ }, any>;
469
+ afterMatch: import("@modern-js/plugin").AsyncPipeline<{
470
+ context: ModernServerContext;
471
+ routeAPI: any;
472
+ }, any>;
473
+ prefetch: import("@modern-js/plugin").ParallelWorkflow<{
474
+ context: SSRServerContext;
475
+ }, unknown>;
476
+ renderToString: import("@modern-js/plugin").AsyncPipeline<{
477
+ App: Component;
478
+ context: RenderContext;
479
+ }, string>;
480
+ beforeRender: import("@modern-js/plugin").AsyncPipeline<{
481
+ context: ModernServerContext;
482
+ }, any>;
483
+ afterRender: import("@modern-js/plugin").AsyncPipeline<{
484
+ context: ModernServerContext;
485
+ templateAPI: any;
486
+ }, any>;
487
+ beforeSend: import("@modern-js/plugin").AsyncPipeline<ModernServerContext, RequestResult>;
488
+ afterSend: import("@modern-js/plugin").ParallelWorkflow<{
489
+ context: ModernServerContext;
490
+ }, unknown>;
491
+ reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
492
+ }, {
493
+ useAppContext: () => ISAppContext;
494
+ useConfigContext: () => UserConfig;
495
+ setAppContext: (value: ISAppContext) => void;
496
+ }>;
497
+ export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.21.2-beta.0",
14
+ "version": "1.21.2-beta.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -29,7 +29,7 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@modern-js/plugin": "1.21.2-beta.0",
32
+ "@modern-js/plugin": "1.21.1",
33
33
  "@modern-js/utils": "1.21.1"
34
34
  },
35
35
  "devDependencies": {