@modern-js/prod-server 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 +132 -0
- package/dist/js/modern/constants.js +32 -25
- package/dist/js/modern/index.js +11 -6
- package/dist/js/modern/libs/context/context.js +52 -84
- package/dist/js/modern/libs/context/index.js +5 -2
- package/dist/js/modern/libs/hook-api/index.js +42 -35
- package/dist/js/modern/libs/hook-api/route.js +6 -7
- package/dist/js/modern/libs/hook-api/template.js +20 -34
- package/dist/js/modern/libs/loadConfig.js +45 -24
- package/dist/js/modern/libs/metrics.js +3 -4
- package/dist/js/modern/libs/proxy.js +68 -37
- package/dist/js/modern/libs/render/cache/__tests__/cache.fun.test.js +112 -67
- package/dist/js/modern/libs/render/cache/__tests__/cache.test.js +246 -216
- package/dist/js/modern/libs/render/cache/__tests__/cacheable.js +43 -49
- package/dist/js/modern/libs/render/cache/__tests__/error-configuration.js +36 -34
- package/dist/js/modern/libs/render/cache/__tests__/matched-cache.js +83 -113
- package/dist/js/modern/libs/render/cache/index.js +88 -54
- package/dist/js/modern/libs/render/cache/page-caches/index.js +31 -8
- package/dist/js/modern/libs/render/cache/page-caches/lru.js +6 -6
- package/dist/js/modern/libs/render/cache/spr.js +133 -117
- package/dist/js/modern/libs/render/cache/type.js +0 -1
- package/dist/js/modern/libs/render/cache/util.js +71 -39
- package/dist/js/modern/libs/render/index.js +76 -56
- package/dist/js/modern/libs/render/measure.js +38 -27
- package/dist/js/modern/libs/render/reader.js +65 -62
- package/dist/js/modern/libs/render/ssr.js +50 -32
- package/dist/js/modern/libs/render/static.js +50 -33
- package/dist/js/modern/libs/render/type.js +9 -6
- package/dist/js/modern/libs/route/index.js +8 -15
- package/dist/js/modern/libs/route/matcher.js +20 -34
- package/dist/js/modern/libs/route/route.js +9 -18
- package/dist/js/modern/libs/serve-file.js +33 -20
- package/dist/js/modern/server/index.js +144 -145
- package/dist/js/modern/server/modern-server-split.js +46 -12
- package/dist/js/modern/server/modern-server.js +377 -419
- package/dist/js/modern/type.js +0 -1
- package/dist/js/modern/utils.js +62 -43
- package/dist/js/modern/worker-server.js +34 -14
- package/dist/js/node/constants.js +45 -30
- package/dist/js/node/index.js +31 -57
- package/dist/js/node/libs/context/context.js +79 -94
- package/dist/js/node/libs/context/index.js +23 -13
- package/dist/js/node/libs/hook-api/index.js +69 -48
- package/dist/js/node/libs/hook-api/route.js +22 -11
- package/dist/js/node/libs/hook-api/template.js +36 -39
- package/dist/js/node/libs/loadConfig.js +69 -35
- package/dist/js/node/libs/metrics.js +21 -9
- package/dist/js/node/libs/proxy.js +86 -44
- package/dist/js/node/libs/render/cache/__tests__/cache.fun.test.js +132 -70
- package/dist/js/node/libs/render/cache/__tests__/cache.test.js +268 -218
- package/dist/js/node/libs/render/cache/__tests__/cacheable.js +61 -55
- package/dist/js/node/libs/render/cache/__tests__/error-configuration.js +54 -40
- package/dist/js/node/libs/render/cache/__tests__/matched-cache.js +101 -119
- package/dist/js/node/libs/render/cache/index.js +110 -64
- package/dist/js/node/libs/render/cache/page-caches/index.js +50 -14
- package/dist/js/node/libs/render/cache/page-caches/lru.js +29 -12
- package/dist/js/node/libs/render/cache/spr.js +156 -129
- package/dist/js/node/libs/render/cache/type.js +0 -5
- package/dist/js/node/libs/render/cache/util.js +88 -45
- package/dist/js/node/libs/render/index.js +102 -67
- package/dist/js/node/libs/render/measure.js +55 -31
- package/dist/js/node/libs/render/reader.js +87 -70
- package/dist/js/node/libs/render/ssr.js +76 -47
- package/dist/js/node/libs/render/static.js +75 -40
- package/dist/js/node/libs/render/type.js +27 -12
- package/dist/js/node/libs/route/index.js +26 -26
- package/dist/js/node/libs/route/matcher.js +36 -41
- package/dist/js/node/libs/route/route.js +25 -22
- package/dist/js/node/libs/serve-file.js +61 -32
- package/dist/js/node/server/index.js +160 -160
- package/dist/js/node/server/modern-server-split.js +68 -22
- package/dist/js/node/server/modern-server.js +395 -443
- package/dist/js/node/type.js +0 -3
- package/dist/js/node/utils.js +74 -52
- package/dist/js/node/worker-server.js +53 -21
- package/dist/js/treeshaking/constants.js +26 -25
- package/dist/js/treeshaking/index.js +10 -10
- package/dist/js/treeshaking/libs/context/context.js +268 -237
- package/dist/js/treeshaking/libs/context/index.js +3 -3
- package/dist/js/treeshaking/libs/hook-api/index.js +265 -143
- package/dist/js/treeshaking/libs/hook-api/route.js +65 -30
- package/dist/js/treeshaking/libs/hook-api/template.js +121 -85
- package/dist/js/treeshaking/libs/loadConfig.js +80 -37
- package/dist/js/treeshaking/libs/metrics.js +4 -10
- package/dist/js/treeshaking/libs/proxy.js +240 -76
- package/dist/js/treeshaking/libs/render/cache/__tests__/cache.fun.test.js +288 -121
- package/dist/js/treeshaking/libs/render/cache/__tests__/cache.test.js +772 -455
- package/dist/js/treeshaking/libs/render/cache/__tests__/cacheable.js +65 -51
- package/dist/js/treeshaking/libs/render/cache/__tests__/error-configuration.js +45 -35
- package/dist/js/treeshaking/libs/render/cache/__tests__/matched-cache.js +144 -118
- package/dist/js/treeshaking/libs/render/cache/index.js +337 -175
- package/dist/js/treeshaking/libs/render/cache/page-caches/index.js +151 -27
- package/dist/js/treeshaking/libs/render/cache/page-caches/lru.js +80 -42
- package/dist/js/treeshaking/libs/render/cache/spr.js +470 -340
- package/dist/js/treeshaking/libs/render/cache/type.js +1 -1
- package/dist/js/treeshaking/libs/render/cache/util.js +271 -92
- package/dist/js/treeshaking/libs/render/index.js +228 -95
- package/dist/js/treeshaking/libs/render/measure.js +142 -57
- package/dist/js/treeshaking/libs/render/reader.js +325 -177
- package/dist/js/treeshaking/libs/render/ssr.js +220 -95
- package/dist/js/treeshaking/libs/render/static.js +210 -78
- package/dist/js/treeshaking/libs/render/type.js +7 -6
- package/dist/js/treeshaking/libs/route/index.js +125 -89
- package/dist/js/treeshaking/libs/route/matcher.js +132 -107
- package/dist/js/treeshaking/libs/route/route.js +40 -26
- package/dist/js/treeshaking/libs/serve-file.js +177 -68
- package/dist/js/treeshaking/server/index.js +468 -327
- package/dist/js/treeshaking/server/modern-server-split.js +352 -144
- package/dist/js/treeshaking/server/modern-server.js +1046 -911
- package/dist/js/treeshaking/type.js +1 -1
- package/dist/js/treeshaking/utils.js +138 -81
- package/dist/js/treeshaking/worker-server.js +176 -55
- package/dist/types/index.d.ts +2 -0
- package/dist/types/libs/context/context.d.ts +4 -1
- package/dist/types/libs/loadConfig.d.ts +1 -0
- package/dist/types/libs/render/cache/index.d.ts +2 -0
- package/dist/types/libs/render/cache/spr.d.ts +2 -0
- package/dist/types/libs/route/route.d.ts +0 -1
- package/dist/types/server/index.d.ts +3 -0
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/worker-server.d.ts +1 -2
- package/package.json +7 -14
- package/dist/js/modern/libs/render/modern/browser-list.js +0 -7
- package/dist/js/modern/libs/render/modern/index.js +0 -37
- package/dist/js/node/libs/render/modern/browser-list.js +0 -14
- package/dist/js/node/libs/render/modern/index.js +0 -46
- package/dist/js/treeshaking/libs/render/modern/browser-list.js +0 -7
- package/dist/js/treeshaking/libs/render/modern/index.js +0 -39
- package/dist/types/libs/render/modern/browser-list.d.ts +0 -1
- package/dist/types/libs/render/modern/index.d.ts +0 -3
package/dist/js/node/type.js
CHANGED
package/dist/js/node/utils.js
CHANGED
|
@@ -1,26 +1,58 @@
|
|
|
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
|
+
createErrorDocument: () => createErrorDocument,
|
|
21
|
+
createMiddlewareCollecter: () => createMiddlewareCollecter,
|
|
22
|
+
debug: () => debug,
|
|
23
|
+
getStaticReg: () => getStaticReg,
|
|
24
|
+
headersWithoutCookie: () => headersWithoutCookie,
|
|
25
|
+
isRedirect: () => isRedirect,
|
|
26
|
+
mergeExtension: () => mergeExtension,
|
|
27
|
+
noop: () => noop,
|
|
28
|
+
prepareFavicons: () => prepareFavicons,
|
|
29
|
+
useLocalPrefix: () => useLocalPrefix
|
|
5
30
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
31
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
32
|
+
var import_utils = require("@modern-js/utils");
|
|
33
|
+
var __defProp2 = Object.defineProperty;
|
|
34
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
35
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
36
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
37
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
38
|
+
var __spreadValues = (a, b) => {
|
|
39
|
+
for (var prop in b || (b = {}))
|
|
40
|
+
if (__hasOwnProp2.call(b, prop))
|
|
41
|
+
__defNormalProp(a, prop, b[prop]);
|
|
42
|
+
if (__getOwnPropSymbols)
|
|
43
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
44
|
+
if (__propIsEnum.call(b, prop))
|
|
45
|
+
__defNormalProp(a, prop, b[prop]);
|
|
46
|
+
}
|
|
47
|
+
return a;
|
|
48
|
+
};
|
|
49
|
+
const debug = (0, import_utils.createDebugger)("prod-server");
|
|
50
|
+
const mergeExtension = (users) => {
|
|
14
51
|
const output = [];
|
|
15
|
-
return {
|
|
16
|
-
middleware: output.concat(users)
|
|
17
|
-
};
|
|
52
|
+
return { middleware: output.concat(users) };
|
|
18
53
|
};
|
|
19
|
-
exports.mergeExtension = mergeExtension;
|
|
20
54
|
const noop = () => {
|
|
21
|
-
// noop
|
|
22
55
|
};
|
|
23
|
-
exports.noop = noop;
|
|
24
56
|
const createErrorDocument = (status, text) => {
|
|
25
57
|
const title = `${status}: ${text}`;
|
|
26
58
|
return `<!DOCTYPE html>
|
|
@@ -54,14 +86,13 @@ const createErrorDocument = (status, text) => {
|
|
|
54
86
|
</html>
|
|
55
87
|
`;
|
|
56
88
|
};
|
|
57
|
-
exports.createErrorDocument = createErrorDocument;
|
|
58
89
|
const createMiddlewareCollecter = () => {
|
|
59
90
|
const webMiddlewares = [];
|
|
60
91
|
const apiMiddlewares = [];
|
|
61
|
-
const addWebMiddleware = input => {
|
|
92
|
+
const addWebMiddleware = (input) => {
|
|
62
93
|
webMiddlewares.push(input);
|
|
63
94
|
};
|
|
64
|
-
const addAPIMiddleware = input => {
|
|
95
|
+
const addAPIMiddleware = (input) => {
|
|
65
96
|
apiMiddlewares.push(input);
|
|
66
97
|
};
|
|
67
98
|
const getMiddlewares = () => ({
|
|
@@ -74,60 +105,51 @@ const createMiddlewareCollecter = () => {
|
|
|
74
105
|
addAPIMiddleware
|
|
75
106
|
};
|
|
76
107
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return (0, _utils.isProd)() && !url.includes('.');
|
|
108
|
+
const useLocalPrefix = (url) => {
|
|
109
|
+
return (0, import_utils.isProd)() && !url.includes(".");
|
|
80
110
|
};
|
|
81
|
-
exports.useLocalPrefix = useLocalPrefix;
|
|
82
111
|
const getStaticReg = (output = {}, html = {}) => {
|
|
83
112
|
const {
|
|
84
|
-
distPath: {
|
|
85
|
-
|
|
86
|
-
js: jsPath,
|
|
87
|
-
media: mediaPath
|
|
88
|
-
} = {},
|
|
89
|
-
assetPrefix = '/'
|
|
113
|
+
distPath: { css: cssPath, js: jsPath, media: mediaPath } = {},
|
|
114
|
+
assetPrefix = "/"
|
|
90
115
|
} = output;
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
faviconByEntries
|
|
94
|
-
} = html;
|
|
95
|
-
const prefix = useLocalPrefix(assetPrefix) ? assetPrefix : '';
|
|
116
|
+
const { favicon, faviconByEntries } = html;
|
|
117
|
+
const prefix = useLocalPrefix(assetPrefix) ? assetPrefix : "";
|
|
96
118
|
const favicons = prepareFavicons(favicon, faviconByEntries);
|
|
97
|
-
const staticFiles = [cssPath, jsPath, mediaPath].filter(v => Boolean(v));
|
|
98
|
-
const staticReg = [
|
|
99
|
-
const iconReg = [
|
|
100
|
-
const regPrefix = prefix.endsWith(
|
|
101
|
-
const staticPathRegExp = new RegExp(
|
|
119
|
+
const staticFiles = [cssPath, jsPath, mediaPath].filter((v) => Boolean(v));
|
|
120
|
+
const staticReg = ["static/", "upload/", ...staticFiles];
|
|
121
|
+
const iconReg = ["favicon.ico", "icon.png", ...favicons];
|
|
122
|
+
const regPrefix = prefix.endsWith("/") ? prefix : `${prefix}/`;
|
|
123
|
+
const staticPathRegExp = new RegExp(
|
|
124
|
+
`^${regPrefix}(${[...staticReg, ...iconReg].join("|")})`
|
|
125
|
+
);
|
|
102
126
|
return staticPathRegExp;
|
|
103
127
|
};
|
|
104
|
-
exports.getStaticReg = getStaticReg;
|
|
105
128
|
const prepareFavicons = (favicon, faviconByEntries) => {
|
|
106
129
|
const faviconNames = [];
|
|
107
130
|
if (favicon) {
|
|
108
|
-
faviconNames.push(favicon.substring(favicon.lastIndexOf(
|
|
131
|
+
faviconNames.push(favicon.substring(favicon.lastIndexOf("/") + 1));
|
|
109
132
|
}
|
|
110
133
|
if (faviconByEntries) {
|
|
111
|
-
Object.keys(faviconByEntries).forEach(f => {
|
|
134
|
+
Object.keys(faviconByEntries).forEach((f) => {
|
|
112
135
|
const curFavicon = faviconByEntries[f];
|
|
113
136
|
if (curFavicon) {
|
|
114
|
-
faviconNames.push(
|
|
137
|
+
faviconNames.push(
|
|
138
|
+
curFavicon.substring(curFavicon.lastIndexOf("/") + 1)
|
|
139
|
+
);
|
|
115
140
|
}
|
|
116
141
|
});
|
|
117
142
|
}
|
|
118
143
|
return faviconNames;
|
|
119
144
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const safeHeaders = _objectSpread({}, headers);
|
|
145
|
+
const headersWithoutCookie = (headers) => {
|
|
146
|
+
if (typeof headers.cookie !== "undefined") {
|
|
147
|
+
const safeHeaders = __spreadValues({}, headers);
|
|
124
148
|
delete safeHeaders.cookie;
|
|
125
149
|
return safeHeaders;
|
|
126
150
|
}
|
|
127
151
|
return headers;
|
|
128
152
|
};
|
|
129
|
-
|
|
130
|
-
const isRedirect = code => {
|
|
153
|
+
const isRedirect = (code) => {
|
|
131
154
|
return [301, 302, 307, 308].includes(code);
|
|
132
155
|
};
|
|
133
|
-
exports.isRedirect = isRedirect;
|
|
@@ -1,31 +1,64 @@
|
|
|
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
|
+
createHandler: () => createHandler
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
23
|
+
var import_route = require("./libs/route");
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const createHandler = (manifest) => {
|
|
45
|
+
const routeMgr = new import_route.RouteMatchManager();
|
|
46
|
+
const { pages, routes } = manifest;
|
|
14
47
|
routeMgr.reset(routes);
|
|
15
|
-
return
|
|
16
|
-
var
|
|
48
|
+
return (ctx) => __async(void 0, null, function* () {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17
50
|
const pageMatch = routeMgr.match(ctx.url);
|
|
18
51
|
if (!pageMatch) {
|
|
19
|
-
ctx.body =
|
|
52
|
+
ctx.body = "404: Page not found";
|
|
20
53
|
ctx.status = 404;
|
|
21
54
|
return;
|
|
22
55
|
}
|
|
23
56
|
const page = pages[pageMatch.spec.urlPath];
|
|
24
|
-
(
|
|
25
|
-
(
|
|
26
|
-
(
|
|
57
|
+
(_b = (_a = ctx.request).query) != null ? _b : _a.query = ctx.query;
|
|
58
|
+
(_d = (_c = ctx.request).pathname) != null ? _d : _c.pathname = ctx.pathname;
|
|
59
|
+
(_f = (_e = ctx.request).params) != null ? _f : _e.params = ctx.params;
|
|
27
60
|
const params = pageMatch.parseURLParams(ctx.url);
|
|
28
|
-
ctx.body =
|
|
61
|
+
ctx.body = yield page.serverRender({
|
|
29
62
|
template: page.template,
|
|
30
63
|
query: ctx.query,
|
|
31
64
|
request: ctx.request,
|
|
@@ -36,6 +69,5 @@ const createHandler = manifest => {
|
|
|
36
69
|
params: ctx.params || params || {}
|
|
37
70
|
});
|
|
38
71
|
ctx.status = 200;
|
|
39
|
-
};
|
|
72
|
+
});
|
|
40
73
|
};
|
|
41
|
-
exports.createHandler = createHandler;
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var AGGRED_DIR = {
|
|
2
|
+
mock: "config/mock",
|
|
3
|
+
server: "server",
|
|
4
|
+
api: "api",
|
|
5
|
+
shared: "shared",
|
|
6
|
+
lambda: "lambda"
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
var ApiServerMode = /* @__PURE__ */ function(ApiServerMode2) {
|
|
9
|
+
ApiServerMode2["func"] = "function";
|
|
10
|
+
ApiServerMode2["frame"] = "framework";
|
|
11
|
+
return ApiServerMode2;
|
|
12
|
+
}(ApiServerMode || {});
|
|
13
|
+
var ERROR_DIGEST = {
|
|
14
|
+
INIT: "Server init error",
|
|
15
|
+
ENOTF: "Page could not be found",
|
|
16
|
+
WARMUP: "SSR warmup failed",
|
|
17
|
+
EINTER: "Internal server error",
|
|
18
|
+
ERENDER: "SSR render failed",
|
|
19
|
+
EMICROINJ: "Get micro-frontend info failed"
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
var ERROR_PAGE_TEXT = {
|
|
22
|
+
404: "This page could not be found.",
|
|
23
|
+
500: "Internal Server Error."
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
25
|
+
var RUN_MODE = {
|
|
26
|
+
FULL: "full",
|
|
27
|
+
TYPE: "type"
|
|
28
|
+
};
|
|
29
|
+
export { AGGRED_DIR, ApiServerMode, ERROR_DIGEST, ERROR_PAGE_TEXT, RUN_MODE };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Server } from "./server";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { createProxyHandler } from "./libs/proxy";
|
|
2
|
+
import { ModernServer } from "./server/modern-server";
|
|
3
|
+
import { createProxyHandler } from "./libs/proxy";
|
|
5
4
|
export * from "./type";
|
|
6
5
|
export * from "./constants";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
6
|
+
var src_default = function(options) {
|
|
7
|
+
if (options == null) {
|
|
8
|
+
throw new Error("can not start mserver without options");
|
|
9
|
+
}
|
|
10
|
+
var server = new Server(options);
|
|
11
|
+
return server.init();
|
|
12
|
+
};
|
|
13
|
+
export { ModernServer, Server, createProxyHandler, src_default as default };
|