@modern-js/server-core 2.0.0-beta.2 → 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 CHANGED
@@ -1,5 +1,85 @@
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
+
44
+ ## 2.0.0-beta.3
45
+
46
+ ### Major Changes
47
+
48
+ - dda38c9c3e: chore: v2
49
+
50
+ ### Minor Changes
51
+
52
+ - 543be9558e: feat: compile server loader and support handle loader request
53
+ feat: 编译 server loader 并支持处理 loader 的请求
54
+
55
+ ### Patch Changes
56
+
57
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
58
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
59
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
60
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
61
+ - Updated dependencies [6aca875]
62
+ - Updated dependencies [2e60319]
63
+ - Updated dependencies [92f0eade39]
64
+ - Updated dependencies [edd1cfb1af]
65
+ - Updated dependencies [cc971eabfc]
66
+ - Updated dependencies [5b9049f2e9]
67
+ - Updated dependencies [92004d1906]
68
+ - Updated dependencies [b8bbe036c7]
69
+ - Updated dependencies [d5a31df781]
70
+ - Updated dependencies [dda38c9c3e]
71
+ - Updated dependencies [3bbea92b2a]
72
+ - Updated dependencies [b710adb]
73
+ - Updated dependencies [f179749375]
74
+ - Updated dependencies [ea7cf06]
75
+ - Updated dependencies [bbe4c4a]
76
+ - Updated dependencies [e4558a0]
77
+ - Updated dependencies [abf3421a75]
78
+ - Updated dependencies [543be9558e]
79
+ - Updated dependencies [14b712da84]
80
+ - @modern-js/utils@2.0.0-beta.3
81
+ - @modern-js/plugin@2.0.0-beta.3
82
+
3
83
  ## 2.0.0-beta.2
4
84
 
5
85
  ### Major Changes
@@ -1,4 +1,4 @@
1
1
  export * from "./plugin";
2
- export * from '@modern-js/plugin';
2
+ export * from "@modern-js/plugin";
3
3
  export * from "./loadPlugins";
4
- export * from "./types/config";
4
+ export * from "./types/config";
@@ -1,7 +1,11 @@
1
- import { compatRequire, getInternalPlugins, tryResolve } from '@modern-js/utils';
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 !== 'string';
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
- export const loadPlugins = (appDirectory, configPlugins, options) => {
18
- const loadedPlugins = getInternalPlugins(appDirectory, options.internalPlugins);
19
- return [...loadedPlugins, ...configPlugins].map(plugin => {
20
- const {
21
- module
22
- } = resolvePlugin(plugin, appDirectory);
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
+ };
@@ -1,8 +1,12 @@
1
- import { createContext, createAsyncManager, createAsyncPipeline, createAsyncWaterfall, createParallelWorkflow, createWaterfall } from '@modern-js/plugin';
2
- // collect all middleware register in server plugins
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
- export const AppContext = createContext({});
44
- export const setAppContext = value => AppContext.set(value);
45
- export const ConfigContext = createContext({});
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
- /** All hooks of server plugin. */
96
-
97
- export const createServerManager = () => createAsyncManager(serverHooks, pluginAPI);
98
- export const serverManager = createServerManager();
99
-
100
- /** Plugin options of a server plugin. */
101
-
102
- export const {
103
- createPlugin
104
- } = serverManager;
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
+ };
@@ -4,4 +4,3 @@ export * from "./output";
4
4
  export * from "./server";
5
5
  export * from "./source";
6
6
  export * from "./tools";
7
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +1,20 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _plugin = require("./plugin");
7
- Object.keys(_plugin).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _plugin[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _plugin[key];
14
- }
15
- });
16
- });
17
- var _plugin2 = require("@modern-js/plugin");
18
- Object.keys(_plugin2).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _plugin2[key]) return;
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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.loadPlugins = void 0;
7
- var _utils = require("@modern-js/utils");
8
- var _plugin = require("./plugin");
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 !== 'string';
26
+ const isPluginInstance = typeof p !== "string";
11
27
  if (isPluginInstance) {
12
28
  return {
13
- module: (0, _plugin.createPlugin)(p.setup, p)
29
+ module: (0, import_plugin.createPlugin)(p.setup, p)
14
30
  };
15
31
  }
16
- const pluginPath = (0, _utils.tryResolve)(p, appDirectory);
17
- const module = (0, _utils.compatRequire)(pluginPath);
18
- const pluginInstance = module();
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, _plugin.createPlugin)(pluginInstance.setup, pluginInstance)
36
+ module: (0, import_plugin.createPlugin)(pluginInstance.setup, pluginInstance)
21
37
  };
22
38
  };
23
39
  const loadPlugins = (appDirectory, configPlugins, options) => {
24
- const loadedPlugins = (0, _utils.getInternalPlugins)(appDirectory, options.internalPlugins);
25
- return [...loadedPlugins, ...configPlugins].map(plugin => {
26
- const {
27
- module
28
- } = resolvePlugin(plugin, appDirectory);
29
- return module;
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;
@@ -1,76 +1,73 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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
- exports.useConfigContext = exports.useAppContext = exports.setAppContext = exports.serverManager = exports.createServerManager = exports.createPlugin = exports.ConfigContext = exports.AppContext = void 0;
7
- var _plugin = require("@modern-js/plugin");
8
- // collect all middleware register in server plugins
9
- const gather = (0, _plugin.createParallelWorkflow)();
10
-
11
- // config
12
- const config = (0, _plugin.createWaterfall)();
13
- const prepare = (0, _plugin.createWaterfall)();
14
- const preparebeforeRouteHandler = (0, _plugin.createAsyncPipeline)();
15
- const prepareWebServer = (0, _plugin.createAsyncPipeline)();
16
- const prepareApiServer = (0, _plugin.createAsyncPipeline)();
17
- const onApiChange = (0, _plugin.createWaterfall)();
18
- const beforeDevServer = (0, _plugin.createParallelWorkflow)();
19
- const setupCompiler = (0, _plugin.createParallelWorkflow)();
20
- const afterDevServer = (0, _plugin.createParallelWorkflow)();
21
-
22
- // TODO FIXME
23
-
24
- const beforeRouteSet = (0, _plugin.createAsyncPipeline)();
25
- const afterRouteSet = (0, _plugin.createAsyncPipeline)();
26
- const beforeProdServer = (0, _plugin.createParallelWorkflow)();
27
- const afterProdServer = (0, _plugin.createParallelWorkflow)();
28
- const listen = (0, _plugin.createParallelWorkflow)();
29
- const beforeServerReset = (0, _plugin.createParallelWorkflow)();
30
- const afterServerReset = (0, _plugin.createParallelWorkflow)();
31
- const extendSSRContext = (0, _plugin.createAsyncWaterfall)();
32
- const extendContext = (0, _plugin.createAsyncPipeline)();
33
- const handleError = (0, _plugin.createParallelWorkflow)();
34
- const beforeMatch = (0, _plugin.createAsyncPipeline)();
35
- const afterMatch = (0, _plugin.createAsyncPipeline)();
36
-
37
- // TODO FIXME
38
-
39
- const prefetch = (0, _plugin.createParallelWorkflow)();
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
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _bff = require("./bff");
7
- Object.keys(_bff).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _bff[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _bff[key];
14
- }
15
- });
16
- });
17
- var _html = require("./html");
18
- Object.keys(_html).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _html[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
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);
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,64 +1,5 @@
1
1
  import { InternalPlugins } from '@modern-js/types';
2
- import { ServerPlugin } from './plugin';
2
+ import { createPlugin, ServerPlugin } from './plugin';
3
3
  export declare const loadPlugins: (appDirectory: string, configPlugins: ServerPlugin[], options: {
4
4
  internalPlugins?: InternalPlugins;
5
- }) => import("@modern-js/plugin").AsyncPlugin<{
6
- gather: import("@modern-js/plugin").ParallelWorkflow<{
7
- addWebMiddleware: (_input: any) => void;
8
- addAPIMiddleware: (_input: any) => void;
9
- }, unknown>;
10
- config: import("@modern-js/plugin").Waterfall<import("./plugin").ServerConfig>;
11
- prepare: import("@modern-js/plugin").Waterfall<void>;
12
- preparebeforeRouteHandler: import("@modern-js/plugin").AsyncPipeline<{
13
- serverRoutes: import("@modern-js/types").ServerRoute[];
14
- distDir: string;
15
- }, import("./plugin").BeforeRouteHandler>;
16
- prepareWebServer: import("@modern-js/plugin").AsyncPipeline<import("./plugin").WebServerStartInput, import("./plugin").WebAdapter>;
17
- prepareApiServer: import("@modern-js/plugin").AsyncPipeline<import("./plugin").APIServerStartInput, import("./plugin").Adapter>;
18
- onApiChange: import("@modern-js/plugin").Waterfall<{
19
- filename: string;
20
- event: "add" | "unlink" | "change";
21
- }[]>;
22
- beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
23
- setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
24
- afterDevServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
25
- beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<import("./plugin").Route[], import("./plugin").Route[]>;
26
- afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
27
- beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
28
- afterProdServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
29
- listen: import("@modern-js/plugin").ParallelWorkflow<{
30
- ip: string;
31
- port: number;
32
- }, any[]>;
33
- beforeServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
34
- afterServerReset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
35
- extendSSRContext: import("@modern-js/plugin").AsyncWaterfall<import("@modern-js/types").BaseSSRServerContext>;
36
- extendContext: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/types").ModernServerContext, import("@modern-js/types").ModernServerContext>;
37
- handleError: import("@modern-js/plugin").ParallelWorkflow<{
38
- error: Error;
39
- }, unknown>;
40
- beforeMatch: import("@modern-js/plugin").AsyncPipeline<{
41
- context: import("@modern-js/types").ModernServerContext;
42
- }, any>;
43
- afterMatch: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/types").AfterMatchContext, any>;
44
- prefetch: import("@modern-js/plugin").ParallelWorkflow<{
45
- context: import("./plugin").SSRServerContext;
46
- }, unknown>;
47
- renderToString: import("@modern-js/plugin").AsyncPipeline<{
48
- App: import("react").Component<{}, {}, any>;
49
- context: import("./plugin").RenderContext;
50
- }, string>;
51
- beforeRender: import("@modern-js/plugin").AsyncPipeline<{
52
- context: import("@modern-js/types").ModernServerContext;
53
- }, any>;
54
- afterRender: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/types").AfterRenderContext, any>;
55
- beforeSend: import("@modern-js/plugin").AsyncPipeline<import("@modern-js/types").ModernServerContext, import("./plugin").RequestResult>;
56
- afterSend: import("@modern-js/plugin").ParallelWorkflow<{
57
- context: import("@modern-js/types").ModernServerContext;
58
- }, unknown>;
59
- reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
60
- }, {
61
- useAppContext: () => import("@modern-js/types").ISAppContext;
62
- useConfigContext: () => import(".").UserConfig;
63
- setAppContext: (value: import("@modern-js/types").ISAppContext) => void;
64
- }>[];
5
+ }) => ReturnType<typeof createPlugin>[];
@@ -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>, any, any> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
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.2",
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.2",
33
- "@modern-js/utils": "2.0.0-beta.2"
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.2",
43
- "@modern-js/babel-preset-app": "2.0.0-beta.2",
44
- "@scripts/build": "2.0.0-beta.2",
45
- "@scripts/jest-config": "2.0.0-beta.2"
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"