@modern-js/server-core 2.0.0-beta.3 → 2.0.0-beta.4
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/CHANGELOG.md +41 -0
- package/dist/js/modern/index.js +2 -2
- package/dist/js/modern/loadPlugins.js +17 -9
- package/dist/js/modern/plugin.js +26 -39
- package/dist/js/modern/types/config/index.js +0 -1
- package/dist/js/modern/types/config/tools.js +0 -1
- package/dist/js/node/index.js +20 -49
- package/dist/js/node/loadPlugins.js +36 -20
- package/dist/js/node/plugin.js +63 -77
- package/dist/js/node/types/config/index.js +22 -71
- package/dist/js/node/types/config/tools.js +0 -5
- package/dist/types/plugin.d.ts +7 -1
- package/package.json +7 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @modern-js/server-plugin
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- dda38c9c3e: chore: v2
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- 543be9558e: feat: compile server loader and support handle loader request
|
|
12
|
+
feat: 编译 server loader 并支持处理 loader 的请求
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 15bf09d9c8: feat: support completely custom server, export render() api for render single page
|
|
17
|
+
feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
|
|
18
|
+
- cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
|
|
19
|
+
refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
|
|
20
|
+
- Updated dependencies [7879e8f]
|
|
21
|
+
- Updated dependencies [6aca875]
|
|
22
|
+
- Updated dependencies [2e6031955e]
|
|
23
|
+
- Updated dependencies [7b7d12c]
|
|
24
|
+
- Updated dependencies [92f0eade39]
|
|
25
|
+
- Updated dependencies [edd1cfb1af]
|
|
26
|
+
- Updated dependencies [cc971eabfc]
|
|
27
|
+
- Updated dependencies [5b9049f2e9]
|
|
28
|
+
- Updated dependencies [92004d1906]
|
|
29
|
+
- Updated dependencies [b8bbe036c7]
|
|
30
|
+
- Updated dependencies [d5a31df781]
|
|
31
|
+
- Updated dependencies [dda38c9c3e]
|
|
32
|
+
- Updated dependencies [3bbea92b2a]
|
|
33
|
+
- Updated dependencies [b710adb843]
|
|
34
|
+
- Updated dependencies [f179749375]
|
|
35
|
+
- Updated dependencies [ea7cf06]
|
|
36
|
+
- Updated dependencies [bbe4c4a]
|
|
37
|
+
- Updated dependencies [e4558a0]
|
|
38
|
+
- Updated dependencies [abf3421a75]
|
|
39
|
+
- Updated dependencies [543be9558e]
|
|
40
|
+
- Updated dependencies [14b712da84]
|
|
41
|
+
- @modern-js/utils@2.0.0-beta.4
|
|
42
|
+
- @modern-js/plugin@2.0.0-beta.4
|
|
43
|
+
|
|
3
44
|
## 2.0.0-beta.3
|
|
4
45
|
|
|
5
46
|
### Major Changes
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
compatRequire,
|
|
3
|
+
getInternalPlugins,
|
|
4
|
+
tryResolve
|
|
5
|
+
} from "@modern-js/utils";
|
|
2
6
|
import { createPlugin } from "./plugin";
|
|
3
7
|
const resolvePlugin = (p, appDirectory) => {
|
|
4
|
-
const isPluginInstance = typeof p !==
|
|
8
|
+
const isPluginInstance = typeof p !== "string";
|
|
5
9
|
if (isPluginInstance) {
|
|
6
10
|
return {
|
|
7
11
|
module: createPlugin(p.setup, p)
|
|
@@ -14,12 +18,16 @@ const resolvePlugin = (p, appDirectory) => {
|
|
|
14
18
|
module: createPlugin(pluginInstance.setup, pluginInstance)
|
|
15
19
|
};
|
|
16
20
|
};
|
|
17
|
-
|
|
18
|
-
const loadedPlugins = getInternalPlugins(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const loadPlugins = (appDirectory, configPlugins, options) => {
|
|
22
|
+
const loadedPlugins = getInternalPlugins(
|
|
23
|
+
appDirectory,
|
|
24
|
+
options.internalPlugins
|
|
25
|
+
);
|
|
26
|
+
return [...loadedPlugins, ...configPlugins].map((plugin) => {
|
|
27
|
+
const { module } = resolvePlugin(plugin, appDirectory);
|
|
23
28
|
return module;
|
|
24
29
|
});
|
|
25
|
-
};
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
loadPlugins
|
|
33
|
+
};
|
package/dist/js/modern/plugin.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
createAsyncManager,
|
|
4
|
+
createAsyncPipeline,
|
|
5
|
+
createAsyncWaterfall,
|
|
6
|
+
createParallelWorkflow,
|
|
7
|
+
createWaterfall
|
|
8
|
+
} from "@modern-js/plugin";
|
|
3
9
|
const gather = createParallelWorkflow();
|
|
4
|
-
|
|
5
|
-
// config
|
|
6
10
|
const config = createWaterfall();
|
|
7
11
|
const prepare = createWaterfall();
|
|
8
12
|
const preparebeforeRouteHandler = createAsyncPipeline();
|
|
@@ -12,9 +16,6 @@ const onApiChange = createWaterfall();
|
|
|
12
16
|
const beforeDevServer = createParallelWorkflow();
|
|
13
17
|
const setupCompiler = createParallelWorkflow();
|
|
14
18
|
const afterDevServer = createParallelWorkflow();
|
|
15
|
-
|
|
16
|
-
// TODO FIXME
|
|
17
|
-
|
|
18
19
|
const beforeRouteSet = createAsyncPipeline();
|
|
19
20
|
const afterRouteSet = createAsyncPipeline();
|
|
20
21
|
const beforeProdServer = createParallelWorkflow();
|
|
@@ -27,39 +28,24 @@ const extendContext = createAsyncPipeline();
|
|
|
27
28
|
const handleError = createParallelWorkflow();
|
|
28
29
|
const beforeMatch = createAsyncPipeline();
|
|
29
30
|
const afterMatch = createAsyncPipeline();
|
|
30
|
-
|
|
31
|
-
// TODO FIXME
|
|
32
|
-
|
|
33
31
|
const prefetch = createParallelWorkflow();
|
|
34
|
-
|
|
35
|
-
// TODO FIXME
|
|
36
|
-
|
|
37
32
|
const renderToString = createAsyncPipeline();
|
|
38
33
|
const beforeRender = createAsyncPipeline();
|
|
39
34
|
const afterRender = createAsyncPipeline();
|
|
40
35
|
const beforeSend = createAsyncPipeline();
|
|
41
36
|
const afterSend = createParallelWorkflow();
|
|
42
37
|
const reset = createParallelWorkflow();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* Get original content of user config.
|
|
49
|
-
*/
|
|
50
|
-
export const useConfigContext = () => ConfigContext.use().value;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Get app context, including directories, plugins and some static infos.
|
|
54
|
-
*/
|
|
55
|
-
export const useAppContext = () => AppContext.use().value;
|
|
38
|
+
const AppContext = createContext({});
|
|
39
|
+
const setAppContext = (value) => AppContext.set(value);
|
|
40
|
+
const ConfigContext = createContext({});
|
|
41
|
+
const useConfigContext = () => ConfigContext.use().value;
|
|
42
|
+
const useAppContext = () => AppContext.use().value;
|
|
56
43
|
const pluginAPI = {
|
|
57
44
|
useAppContext,
|
|
58
45
|
useConfigContext,
|
|
59
46
|
setAppContext
|
|
60
47
|
};
|
|
61
48
|
const serverHooks = {
|
|
62
|
-
// server hook
|
|
63
49
|
gather,
|
|
64
50
|
config,
|
|
65
51
|
prepare,
|
|
@@ -77,7 +63,6 @@ const serverHooks = {
|
|
|
77
63
|
listen,
|
|
78
64
|
beforeServerReset,
|
|
79
65
|
afterServerReset,
|
|
80
|
-
// request hook
|
|
81
66
|
extendSSRContext,
|
|
82
67
|
extendContext,
|
|
83
68
|
handleError,
|
|
@@ -91,14 +76,16 @@ const serverHooks = {
|
|
|
91
76
|
afterSend,
|
|
92
77
|
reset
|
|
93
78
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
export
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
const createServerManager = () => createAsyncManager(serverHooks, pluginAPI);
|
|
80
|
+
const serverManager = createServerManager();
|
|
81
|
+
const { createPlugin } = serverManager;
|
|
82
|
+
export {
|
|
83
|
+
AppContext,
|
|
84
|
+
ConfigContext,
|
|
85
|
+
createPlugin,
|
|
86
|
+
createServerManager,
|
|
87
|
+
serverManager,
|
|
88
|
+
setAppContext,
|
|
89
|
+
useAppContext,
|
|
90
|
+
useConfigContext
|
|
91
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/js/node/index.js
CHANGED
|
@@ -1,49 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _plugin2[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _loadPlugins = require("./loadPlugins");
|
|
29
|
-
Object.keys(_loadPlugins).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _loadPlugins[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _loadPlugins[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _config = require("./types/config");
|
|
40
|
-
Object.keys(_config).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _config[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _config[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var stdin_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
17
|
+
__reExport(stdin_exports, require("./plugin"), module.exports);
|
|
18
|
+
__reExport(stdin_exports, require("@modern-js/plugin"), module.exports);
|
|
19
|
+
__reExport(stdin_exports, require("./loadPlugins"), module.exports);
|
|
20
|
+
__reExport(stdin_exports, require("./types/config"), module.exports);
|
|
@@ -1,32 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
loadPlugins: () => loadPlugins
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
+
var import_utils = require("@modern-js/utils");
|
|
24
|
+
var import_plugin = require("./plugin");
|
|
9
25
|
const resolvePlugin = (p, appDirectory) => {
|
|
10
|
-
const isPluginInstance = typeof p !==
|
|
26
|
+
const isPluginInstance = typeof p !== "string";
|
|
11
27
|
if (isPluginInstance) {
|
|
12
28
|
return {
|
|
13
|
-
module: (0,
|
|
29
|
+
module: (0, import_plugin.createPlugin)(p.setup, p)
|
|
14
30
|
};
|
|
15
31
|
}
|
|
16
|
-
const pluginPath = (0,
|
|
17
|
-
const
|
|
18
|
-
const pluginInstance =
|
|
32
|
+
const pluginPath = (0, import_utils.tryResolve)(p, appDirectory);
|
|
33
|
+
const module2 = (0, import_utils.compatRequire)(pluginPath);
|
|
34
|
+
const pluginInstance = module2();
|
|
19
35
|
return {
|
|
20
|
-
module: (0,
|
|
36
|
+
module: (0, import_plugin.createPlugin)(pluginInstance.setup, pluginInstance)
|
|
21
37
|
};
|
|
22
38
|
};
|
|
23
39
|
const loadPlugins = (appDirectory, configPlugins, options) => {
|
|
24
|
-
const loadedPlugins = (0,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
const loadedPlugins = (0, import_utils.getInternalPlugins)(
|
|
41
|
+
appDirectory,
|
|
42
|
+
options.internalPlugins
|
|
43
|
+
);
|
|
44
|
+
return [...loadedPlugins, ...configPlugins].map((plugin) => {
|
|
45
|
+
const { module: module2 } = resolvePlugin(plugin, appDirectory);
|
|
46
|
+
return module2;
|
|
30
47
|
});
|
|
31
48
|
};
|
|
32
|
-
exports.loadPlugins = loadPlugins;
|
package/dist/js/node/plugin.js
CHANGED
|
@@ -1,76 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
AppContext: () => AppContext,
|
|
21
|
+
ConfigContext: () => ConfigContext,
|
|
22
|
+
createPlugin: () => createPlugin,
|
|
23
|
+
createServerManager: () => createServerManager,
|
|
24
|
+
serverManager: () => serverManager,
|
|
25
|
+
setAppContext: () => setAppContext,
|
|
26
|
+
useAppContext: () => useAppContext,
|
|
27
|
+
useConfigContext: () => useConfigContext
|
|
5
28
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
// TODO FIXME
|
|
42
|
-
|
|
43
|
-
const renderToString = (0, _plugin.createAsyncPipeline)();
|
|
44
|
-
const beforeRender = (0, _plugin.createAsyncPipeline)();
|
|
45
|
-
const afterRender = (0, _plugin.createAsyncPipeline)();
|
|
46
|
-
const beforeSend = (0, _plugin.createAsyncPipeline)();
|
|
47
|
-
const afterSend = (0, _plugin.createParallelWorkflow)();
|
|
48
|
-
const reset = (0, _plugin.createParallelWorkflow)();
|
|
49
|
-
const AppContext = (0, _plugin.createContext)({});
|
|
50
|
-
exports.AppContext = AppContext;
|
|
51
|
-
const setAppContext = value => AppContext.set(value);
|
|
52
|
-
exports.setAppContext = setAppContext;
|
|
53
|
-
const ConfigContext = (0, _plugin.createContext)({});
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get original content of user config.
|
|
57
|
-
*/
|
|
58
|
-
exports.ConfigContext = ConfigContext;
|
|
29
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
30
|
+
var import_plugin = require("@modern-js/plugin");
|
|
31
|
+
const gather = (0, import_plugin.createParallelWorkflow)();
|
|
32
|
+
const config = (0, import_plugin.createWaterfall)();
|
|
33
|
+
const prepare = (0, import_plugin.createWaterfall)();
|
|
34
|
+
const preparebeforeRouteHandler = (0, import_plugin.createAsyncPipeline)();
|
|
35
|
+
const prepareWebServer = (0, import_plugin.createAsyncPipeline)();
|
|
36
|
+
const prepareApiServer = (0, import_plugin.createAsyncPipeline)();
|
|
37
|
+
const onApiChange = (0, import_plugin.createWaterfall)();
|
|
38
|
+
const beforeDevServer = (0, import_plugin.createParallelWorkflow)();
|
|
39
|
+
const setupCompiler = (0, import_plugin.createParallelWorkflow)();
|
|
40
|
+
const afterDevServer = (0, import_plugin.createParallelWorkflow)();
|
|
41
|
+
const beforeRouteSet = (0, import_plugin.createAsyncPipeline)();
|
|
42
|
+
const afterRouteSet = (0, import_plugin.createAsyncPipeline)();
|
|
43
|
+
const beforeProdServer = (0, import_plugin.createParallelWorkflow)();
|
|
44
|
+
const afterProdServer = (0, import_plugin.createParallelWorkflow)();
|
|
45
|
+
const listen = (0, import_plugin.createParallelWorkflow)();
|
|
46
|
+
const beforeServerReset = (0, import_plugin.createParallelWorkflow)();
|
|
47
|
+
const afterServerReset = (0, import_plugin.createParallelWorkflow)();
|
|
48
|
+
const extendSSRContext = (0, import_plugin.createAsyncWaterfall)();
|
|
49
|
+
const extendContext = (0, import_plugin.createAsyncPipeline)();
|
|
50
|
+
const handleError = (0, import_plugin.createParallelWorkflow)();
|
|
51
|
+
const beforeMatch = (0, import_plugin.createAsyncPipeline)();
|
|
52
|
+
const afterMatch = (0, import_plugin.createAsyncPipeline)();
|
|
53
|
+
const prefetch = (0, import_plugin.createParallelWorkflow)();
|
|
54
|
+
const renderToString = (0, import_plugin.createAsyncPipeline)();
|
|
55
|
+
const beforeRender = (0, import_plugin.createAsyncPipeline)();
|
|
56
|
+
const afterRender = (0, import_plugin.createAsyncPipeline)();
|
|
57
|
+
const beforeSend = (0, import_plugin.createAsyncPipeline)();
|
|
58
|
+
const afterSend = (0, import_plugin.createParallelWorkflow)();
|
|
59
|
+
const reset = (0, import_plugin.createParallelWorkflow)();
|
|
60
|
+
const AppContext = (0, import_plugin.createContext)({});
|
|
61
|
+
const setAppContext = (value) => AppContext.set(value);
|
|
62
|
+
const ConfigContext = (0, import_plugin.createContext)({});
|
|
59
63
|
const useConfigContext = () => ConfigContext.use().value;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get app context, including directories, plugins and some static infos.
|
|
63
|
-
*/
|
|
64
|
-
exports.useConfigContext = useConfigContext;
|
|
65
64
|
const useAppContext = () => AppContext.use().value;
|
|
66
|
-
exports.useAppContext = useAppContext;
|
|
67
65
|
const pluginAPI = {
|
|
68
66
|
useAppContext,
|
|
69
67
|
useConfigContext,
|
|
70
68
|
setAppContext
|
|
71
69
|
};
|
|
72
70
|
const serverHooks = {
|
|
73
|
-
// server hook
|
|
74
71
|
gather,
|
|
75
72
|
config,
|
|
76
73
|
prepare,
|
|
@@ -88,7 +85,6 @@ const serverHooks = {
|
|
|
88
85
|
listen,
|
|
89
86
|
beforeServerReset,
|
|
90
87
|
afterServerReset,
|
|
91
|
-
// request hook
|
|
92
88
|
extendSSRContext,
|
|
93
89
|
extendContext,
|
|
94
90
|
handleError,
|
|
@@ -102,16 +98,6 @@ const serverHooks = {
|
|
|
102
98
|
afterSend,
|
|
103
99
|
reset
|
|
104
100
|
};
|
|
105
|
-
|
|
106
|
-
/** All hooks of server plugin. */
|
|
107
|
-
|
|
108
|
-
const createServerManager = () => (0, _plugin.createAsyncManager)(serverHooks, pluginAPI);
|
|
109
|
-
exports.createServerManager = createServerManager;
|
|
101
|
+
const createServerManager = () => (0, import_plugin.createAsyncManager)(serverHooks, pluginAPI);
|
|
110
102
|
const serverManager = createServerManager();
|
|
111
|
-
|
|
112
|
-
/** Plugin options of a server plugin. */
|
|
113
|
-
exports.serverManager = serverManager;
|
|
114
|
-
const {
|
|
115
|
-
createPlugin
|
|
116
|
-
} = serverManager;
|
|
117
|
-
exports.createPlugin = createPlugin;
|
|
103
|
+
const { createPlugin } = serverManager;
|
|
@@ -1,71 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
get: function () {
|
|
24
|
-
return _html[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _output = require("./output");
|
|
29
|
-
Object.keys(_output).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _output[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _output[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _server = require("./server");
|
|
40
|
-
Object.keys(_server).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _server[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _server[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _source = require("./source");
|
|
51
|
-
Object.keys(_source).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _source[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _source[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
var _tools = require("./tools");
|
|
62
|
-
Object.keys(_tools).forEach(function (key) {
|
|
63
|
-
if (key === "default" || key === "__esModule") return;
|
|
64
|
-
if (key in exports && exports[key] === _tools[key]) return;
|
|
65
|
-
Object.defineProperty(exports, key, {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _tools[key];
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
});
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var stdin_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
17
|
+
__reExport(stdin_exports, require("./bff"), module.exports);
|
|
18
|
+
__reExport(stdin_exports, require("./html"), module.exports);
|
|
19
|
+
__reExport(stdin_exports, require("./output"), module.exports);
|
|
20
|
+
__reExport(stdin_exports, require("./server"), module.exports);
|
|
21
|
+
__reExport(stdin_exports, require("./source"), module.exports);
|
|
22
|
+
__reExport(stdin_exports, require("./tools"), module.exports);
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -35,10 +35,12 @@ export declare const ConfigContext: import("@modern-js/plugin").Context<UserConf
|
|
|
35
35
|
/**
|
|
36
36
|
* Get original content of user config.
|
|
37
37
|
*/
|
|
38
|
+
|
|
38
39
|
export declare const useConfigContext: () => UserConfig;
|
|
39
40
|
/**
|
|
40
41
|
* Get app context, including directories, plugins and some static infos.
|
|
41
42
|
*/
|
|
43
|
+
|
|
42
44
|
export declare const useAppContext: () => ISAppContext;
|
|
43
45
|
declare const pluginAPI: {
|
|
44
46
|
useAppContext: () => ISAppContext;
|
|
@@ -99,10 +101,13 @@ declare const serverHooks: {
|
|
|
99
101
|
reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
|
|
100
102
|
};
|
|
101
103
|
/** All hooks of server plugin. */
|
|
104
|
+
|
|
102
105
|
export declare type ServerHooks = typeof serverHooks;
|
|
103
106
|
/** All hook callbacks of server plugin. */
|
|
107
|
+
|
|
104
108
|
export declare type ServerHookCallbacks = ToThreads<ServerHooks>;
|
|
105
109
|
/** All apis for server plugin. */
|
|
110
|
+
|
|
106
111
|
export declare type PluginAPI = typeof pluginAPI & CommonAPI<ServerHooks>;
|
|
107
112
|
export declare const createServerManager: () => import("@modern-js/plugin").AsyncManager<{
|
|
108
113
|
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
@@ -219,6 +224,7 @@ export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
|
|
|
219
224
|
setAppContext: (value: ISAppContext) => void;
|
|
220
225
|
}>;
|
|
221
226
|
/** Plugin options of a server plugin. */
|
|
227
|
+
|
|
222
228
|
export declare type ServerPlugin = PluginOptions<ServerHooks, AsyncSetup<ServerHooks, PluginAPI>>;
|
|
223
229
|
export declare type ServerConfig = {
|
|
224
230
|
bff?: Partial<{
|
|
@@ -390,7 +396,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
390
396
|
useAppContext: () => ISAppContext;
|
|
391
397
|
useConfigContext: () => UserConfig;
|
|
392
398
|
setAppContext: (value: ISAppContext) => void;
|
|
393
|
-
}>, Record<string, unknown
|
|
399
|
+
}>, Record<string, unknown>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
|
|
394
400
|
gather: import("@modern-js/plugin").ParallelWorkflow<{
|
|
395
401
|
addWebMiddleware: (_input: any) => void;
|
|
396
402
|
addAPIMiddleware: (_input: any) => void;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.0.0-beta.
|
|
14
|
+
"version": "2.0.0-beta.4",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@modern-js/plugin": "2.0.0-beta.
|
|
33
|
-
"@modern-js/utils": "2.0.0-beta.
|
|
32
|
+
"@modern-js/plugin": "2.0.0-beta.4",
|
|
33
|
+
"@modern-js/utils": "2.0.0-beta.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/jest": "^27",
|
|
@@ -39,17 +39,12 @@
|
|
|
39
39
|
"jest": "^27",
|
|
40
40
|
"ts-jest": "^27.0.4",
|
|
41
41
|
"typescript": "^4",
|
|
42
|
-
"@modern-js/types": "2.0.0-beta.
|
|
43
|
-
"@modern-js/babel-preset-app": "2.0.0-beta.
|
|
44
|
-
"@scripts/build": "2.0.0-beta.
|
|
45
|
-
"@scripts/jest-config": "2.0.0-beta.
|
|
42
|
+
"@modern-js/types": "2.0.0-beta.4",
|
|
43
|
+
"@modern-js/babel-preset-app": "2.0.0-beta.4",
|
|
44
|
+
"@scripts/build": "2.0.0-beta.4",
|
|
45
|
+
"@scripts/jest-config": "2.0.0-beta.4"
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": false,
|
|
48
|
-
"modernConfig": {
|
|
49
|
-
"output": {
|
|
50
|
-
"packageMode": "node-js"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
48
|
"publishConfig": {
|
|
54
49
|
"registry": "https://registry.npmjs.org/",
|
|
55
50
|
"access": "public"
|