@modern-js/prod-server 2.33.1 → 2.34.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/libs/preload/flushServerHeader.js +3 -38
- package/dist/cjs/libs/preload/shouldFlushServerHeader.js +42 -0
- package/dist/cjs/libs/preload/transformLinks2String.js +115 -104
- package/dist/cjs/libs/render/index.js +4 -3
- package/dist/esm/libs/preload/flushServerHeader.js +0 -23
- package/dist/esm/libs/preload/shouldFlushServerHeader.js +23 -0
- package/dist/esm/libs/preload/transformLinks2String.js +130 -121
- package/dist/esm/libs/render/index.js +31 -20
- package/dist/esm-node/libs/preload/flushServerHeader.js +0 -23
- package/dist/esm-node/libs/preload/shouldFlushServerHeader.js +23 -0
- package/dist/esm-node/libs/preload/transformLinks2String.js +115 -104
- package/dist/esm-node/libs/render/index.js +2 -1
- package/dist/types/libs/context/context.d.ts +1 -1
- package/dist/types/libs/preload/flushServerHeader.d.ts +0 -2
- package/dist/types/libs/preload/parseLinks.d.ts +3 -0
- package/dist/types/libs/preload/shouldFlushServerHeader.d.ts +3 -0
- package/dist/types/utils.d.ts +1 -1
- package/package.json +8 -8
|
@@ -2,49 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: all[name]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
transformToRegExp: function() {
|
|
14
|
-
return transformToRegExp;
|
|
15
|
-
},
|
|
16
|
-
shouldFlushServerHeader: function() {
|
|
17
|
-
return shouldFlushServerHeader;
|
|
18
|
-
},
|
|
19
|
-
flushServerHeader: function() {
|
|
5
|
+
Object.defineProperty(exports, "flushServerHeader", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
20
8
|
return flushServerHeader;
|
|
21
9
|
}
|
|
22
10
|
});
|
|
23
11
|
const _parseLinks = require("./parseLinks");
|
|
24
12
|
const _transformLinks2String = require("./transformLinks2String");
|
|
25
|
-
function transformToRegExp(input) {
|
|
26
|
-
if (typeof input === "string") {
|
|
27
|
-
return new RegExp(input);
|
|
28
|
-
}
|
|
29
|
-
return input;
|
|
30
|
-
}
|
|
31
|
-
function shouldFlushServerHeader(serverConf, userAgent, disablePreload) {
|
|
32
|
-
const { ssr: ssrConf } = serverConf || {};
|
|
33
|
-
if (disablePreload) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
if (typeof ssrConf === "object" && ssrConf.preload) {
|
|
37
|
-
if (typeof ssrConf.preload === "object") {
|
|
38
|
-
const { userAgentFilter } = ssrConf.preload;
|
|
39
|
-
if (userAgentFilter && userAgent) {
|
|
40
|
-
return !transformToRegExp(userAgentFilter).test(userAgent);
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
13
|
async function flushServerHeader({ serverConf, ctx, distDir, template, headers }) {
|
|
49
14
|
const { ssr: ssrConf } = serverConf || {};
|
|
50
15
|
if (typeof ssrConf !== "object") {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
transformToRegExp: function() {
|
|
14
|
+
return transformToRegExp;
|
|
15
|
+
},
|
|
16
|
+
shouldFlushServerHeader: function() {
|
|
17
|
+
return shouldFlushServerHeader;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
function transformToRegExp(input) {
|
|
21
|
+
if (typeof input === "string") {
|
|
22
|
+
return new RegExp(input);
|
|
23
|
+
}
|
|
24
|
+
return input;
|
|
25
|
+
}
|
|
26
|
+
function shouldFlushServerHeader(serverConf, userAgent, disablePreload) {
|
|
27
|
+
const { ssr: ssrConf } = serverConf || {};
|
|
28
|
+
if (disablePreload) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (typeof ssrConf === "object" && ssrConf.preload) {
|
|
32
|
+
if (typeof ssrConf.preload === "object") {
|
|
33
|
+
const { userAgentFilter } = ssrConf.preload;
|
|
34
|
+
if (userAgentFilter && userAgent) {
|
|
35
|
+
return !transformToRegExp(userAgentFilter).test(userAgent);
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
@@ -8,116 +8,127 @@ Object.defineProperty(exports, "transformLinks2String", {
|
|
|
8
8
|
return transformLinks2String;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const
|
|
11
|
+
const _shouldFlushServerHeader = require("./shouldFlushServerHeader");
|
|
12
12
|
function transformLinks2String(links, preload) {
|
|
13
13
|
if (typeof preload === "boolean") {
|
|
14
|
-
return dedup(links)
|
|
14
|
+
return transformLinkToString(dedup(links));
|
|
15
15
|
}
|
|
16
16
|
const { include, exclude, attributes } = preload;
|
|
17
|
-
const resolveLinks = addAttributes(dedup(removeExclude(addInclude(links, include), exclude)), attributes);
|
|
18
|
-
return resolveLinks
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
uri: item,
|
|
67
|
-
as: type
|
|
68
|
-
};
|
|
69
|
-
}
|
|
17
|
+
const resolveLinks = transformLinkToString(addAttributes(dedup(removeExclude(addInclude(links, include), exclude)), attributes));
|
|
18
|
+
return resolveLinks;
|
|
19
|
+
}
|
|
20
|
+
function addInclude(links, include) {
|
|
21
|
+
var _include;
|
|
22
|
+
const images = [
|
|
23
|
+
"gif",
|
|
24
|
+
"jpg",
|
|
25
|
+
"jpeg",
|
|
26
|
+
"png",
|
|
27
|
+
"webp",
|
|
28
|
+
"bmp",
|
|
29
|
+
"tiff",
|
|
30
|
+
"anpg",
|
|
31
|
+
"ico"
|
|
32
|
+
];
|
|
33
|
+
const videos = [
|
|
34
|
+
"mp4",
|
|
35
|
+
"webm",
|
|
36
|
+
"ogm",
|
|
37
|
+
"ogv",
|
|
38
|
+
"ogg"
|
|
39
|
+
];
|
|
40
|
+
const fonts = [
|
|
41
|
+
"woff",
|
|
42
|
+
"woff2",
|
|
43
|
+
"eot",
|
|
44
|
+
"ttf",
|
|
45
|
+
"otf"
|
|
46
|
+
];
|
|
47
|
+
const includes = ((_include = include) === null || _include === void 0 ? void 0 : _include.map((item) => {
|
|
48
|
+
if (typeof item === "string") {
|
|
49
|
+
const type = (() => {
|
|
50
|
+
if (item.endsWith(".js")) {
|
|
51
|
+
return "script";
|
|
52
|
+
}
|
|
53
|
+
if (item.endsWith(".css")) {
|
|
54
|
+
return "style";
|
|
55
|
+
}
|
|
56
|
+
if (images.some((image) => item.endsWith(`.${image}`))) {
|
|
57
|
+
return "image";
|
|
58
|
+
}
|
|
59
|
+
if (videos.some((video) => item.endsWith(`.${video}`))) {
|
|
60
|
+
return "video";
|
|
61
|
+
}
|
|
62
|
+
if (fonts.some((font) => item.endsWith(`.${font}`))) {
|
|
63
|
+
return "font";
|
|
64
|
+
}
|
|
65
|
+
})();
|
|
70
66
|
return {
|
|
71
|
-
uri: item
|
|
72
|
-
as:
|
|
67
|
+
uri: item,
|
|
68
|
+
as: type
|
|
73
69
|
};
|
|
74
|
-
}
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
function addAttributes(links2, attributes2) {
|
|
81
|
-
const parseAttributes = (_attributes) => {
|
|
82
|
-
return Object.entries(_attributes || {}).reduce((results, [key, value]) => {
|
|
83
|
-
if (typeof value === "boolean") {
|
|
84
|
-
value && results.push(`; ${key}`);
|
|
85
|
-
return results;
|
|
86
|
-
}
|
|
87
|
-
results.push(`; ${key}=${value}`);
|
|
88
|
-
return results;
|
|
89
|
-
}, []).join("");
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
uri: item.url,
|
|
73
|
+
as: item.as,
|
|
74
|
+
rel: item.rel
|
|
90
75
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return parseAttributes(font);
|
|
104
|
-
default:
|
|
105
|
-
return "";
|
|
106
|
-
}
|
|
107
|
-
})();
|
|
108
|
-
return `<${uri}>; rel=preload; as=${as}${attributesStr}`;
|
|
109
|
-
}
|
|
110
|
-
return `<${uri}>; rel=preload`;
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
function dedup(links2) {
|
|
114
|
-
const set = /* @__PURE__ */ new Set();
|
|
115
|
-
return links2.filter(({ uri }) => {
|
|
116
|
-
if (set.has(uri)) {
|
|
117
|
-
return false;
|
|
76
|
+
})) || [];
|
|
77
|
+
return links.concat(includes);
|
|
78
|
+
}
|
|
79
|
+
function removeExclude(links, exclude) {
|
|
80
|
+
return exclude ? links.filter(({ uri }) => !(0, _shouldFlushServerHeader.transformToRegExp)(exclude).test(uri)) : links;
|
|
81
|
+
}
|
|
82
|
+
function addAttributes(links, attributes) {
|
|
83
|
+
const parseAttributes = (_attributes) => {
|
|
84
|
+
return Object.entries(_attributes || {}).reduce((results, [key, value]) => {
|
|
85
|
+
if (typeof value === "boolean") {
|
|
86
|
+
value && results.push(`; ${key}`);
|
|
87
|
+
return results;
|
|
118
88
|
}
|
|
119
|
-
|
|
120
|
-
return
|
|
121
|
-
});
|
|
122
|
-
}
|
|
89
|
+
results.push(`; ${key}=${value}`);
|
|
90
|
+
return results;
|
|
91
|
+
}, []).join("");
|
|
92
|
+
};
|
|
93
|
+
return links.map((link) => {
|
|
94
|
+
const { as } = link;
|
|
95
|
+
if (as) {
|
|
96
|
+
const attributesStr = (() => {
|
|
97
|
+
const { style, script, image, font } = attributes || {};
|
|
98
|
+
switch (as) {
|
|
99
|
+
case "script":
|
|
100
|
+
return parseAttributes(script);
|
|
101
|
+
case "style":
|
|
102
|
+
return parseAttributes(style);
|
|
103
|
+
case "image":
|
|
104
|
+
return parseAttributes(image);
|
|
105
|
+
case "font":
|
|
106
|
+
return parseAttributes(font);
|
|
107
|
+
default:
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
})();
|
|
111
|
+
return {
|
|
112
|
+
...link,
|
|
113
|
+
rest: attributesStr
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return link;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function dedup(links) {
|
|
120
|
+
const set = /* @__PURE__ */ new Set();
|
|
121
|
+
return links.filter(({ uri }) => {
|
|
122
|
+
if (set.has(uri)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
set.add(uri);
|
|
126
|
+
return true;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function transformLinkToString(links) {
|
|
130
|
+
return links.map(({ uri, as, rel: originalRel, rest }) => {
|
|
131
|
+
const rel = originalRel || "preload";
|
|
132
|
+
return as ? `<${uri}>; rel=${rel}; as=${as}${rest || ""}` : `<${uri}>; rel=${rel}${rest || ""}`;
|
|
133
|
+
}).join(", ");
|
|
123
134
|
}
|
|
@@ -13,7 +13,7 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
|
13
13
|
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
14
14
|
const _utils = require("@modern-js/utils");
|
|
15
15
|
const _constants = require("../../constants");
|
|
16
|
-
const
|
|
16
|
+
const _shouldFlushServerHeader = require("../preload/shouldFlushServerHeader");
|
|
17
17
|
const _static = require("./static");
|
|
18
18
|
const _reader = require("./reader");
|
|
19
19
|
const _ssr = /* @__PURE__ */ _interop_require_wildcard._(require("./ssr"));
|
|
@@ -38,8 +38,9 @@ const createRenderHandler = ({ distDir, staticGenerate, conf, forceCSR, nonce, s
|
|
|
38
38
|
try {
|
|
39
39
|
const userAgent = ctx.getReqHeader("User-Agent");
|
|
40
40
|
const disablePreload = Boolean(ctx.headers[`x-${(0, _utils.cutNameByHyphen)(metaName)}-disable-preload`]);
|
|
41
|
-
if ((0,
|
|
42
|
-
(
|
|
41
|
+
if ((0, _shouldFlushServerHeader.shouldFlushServerHeader)(conf.server, userAgent, disablePreload)) {
|
|
42
|
+
const { flushServerHeader } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("../preload")));
|
|
43
|
+
flushServerHeader({
|
|
43
44
|
serverConf: conf.server,
|
|
44
45
|
ctx,
|
|
45
46
|
distDir,
|
|
@@ -2,29 +2,6 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import { parseLinks } from "./parseLinks";
|
|
4
4
|
import { transformLinks2String } from "./transformLinks2String";
|
|
5
|
-
export function transformToRegExp(input) {
|
|
6
|
-
if (typeof input === "string") {
|
|
7
|
-
return new RegExp(input);
|
|
8
|
-
}
|
|
9
|
-
return input;
|
|
10
|
-
}
|
|
11
|
-
export function shouldFlushServerHeader(serverConf, userAgent, disablePreload) {
|
|
12
|
-
var _ref = serverConf || {}, ssrConf = _ref.ssr;
|
|
13
|
-
if (disablePreload) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
if (typeof ssrConf === "object" && ssrConf.preload) {
|
|
17
|
-
if (typeof ssrConf.preload === "object") {
|
|
18
|
-
var userAgentFilter = ssrConf.preload.userAgentFilter;
|
|
19
|
-
if (userAgentFilter && userAgent) {
|
|
20
|
-
return !transformToRegExp(userAgentFilter).test(userAgent);
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
5
|
export function flushServerHeader(_) {
|
|
29
6
|
return _flushServerHeader.apply(this, arguments);
|
|
30
7
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function transformToRegExp(input) {
|
|
2
|
+
if (typeof input === "string") {
|
|
3
|
+
return new RegExp(input);
|
|
4
|
+
}
|
|
5
|
+
return input;
|
|
6
|
+
}
|
|
7
|
+
export function shouldFlushServerHeader(serverConf, userAgent, disablePreload) {
|
|
8
|
+
var _ref = serverConf || {}, ssrConf = _ref.ssr;
|
|
9
|
+
if (disablePreload) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (typeof ssrConf === "object" && ssrConf.preload) {
|
|
13
|
+
if (typeof ssrConf.preload === "object") {
|
|
14
|
+
var userAgentFilter = ssrConf.preload.userAgentFilter;
|
|
15
|
+
if (userAgentFilter && userAgent) {
|
|
16
|
+
return !transformToRegExp(userAgentFilter).test(userAgent);
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
@@ -1,129 +1,138 @@
|
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
1
3
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
|
-
import { transformToRegExp } from "./
|
|
4
|
+
import { transformToRegExp } from "./shouldFlushServerHeader";
|
|
3
5
|
export function transformLinks2String(links, preload) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
6
|
+
if (typeof preload === "boolean") {
|
|
7
|
+
return transformLinkToString(dedup(links));
|
|
8
|
+
}
|
|
9
|
+
var include = preload.include, exclude = preload.exclude, attributes = preload.attributes;
|
|
10
|
+
var resolveLinks = transformLinkToString(addAttributes(dedup(removeExclude(addInclude(links, include), exclude)), attributes));
|
|
11
|
+
return resolveLinks;
|
|
12
|
+
}
|
|
13
|
+
function addInclude(links, include) {
|
|
14
|
+
var _include;
|
|
15
|
+
var images = [
|
|
16
|
+
"gif",
|
|
17
|
+
"jpg",
|
|
18
|
+
"jpeg",
|
|
19
|
+
"png",
|
|
20
|
+
"webp",
|
|
21
|
+
"bmp",
|
|
22
|
+
"tiff",
|
|
23
|
+
"anpg",
|
|
24
|
+
"ico"
|
|
25
|
+
];
|
|
26
|
+
var videos = [
|
|
27
|
+
"mp4",
|
|
28
|
+
"webm",
|
|
29
|
+
"ogm",
|
|
30
|
+
"ogv",
|
|
31
|
+
"ogg"
|
|
32
|
+
];
|
|
33
|
+
var fonts = [
|
|
34
|
+
"woff",
|
|
35
|
+
"woff2",
|
|
36
|
+
"eot",
|
|
37
|
+
"ttf",
|
|
38
|
+
"otf"
|
|
39
|
+
];
|
|
40
|
+
var includes = ((_include = include) === null || _include === void 0 ? void 0 : _include.map(function(item) {
|
|
41
|
+
if (typeof item === "string") {
|
|
42
|
+
var type = function() {
|
|
43
|
+
if (item.endsWith(".js")) {
|
|
44
|
+
return "script";
|
|
45
|
+
}
|
|
46
|
+
if (item.endsWith(".css")) {
|
|
47
|
+
return "style";
|
|
48
|
+
}
|
|
49
|
+
if (images.some(function(image) {
|
|
50
|
+
return item.endsWith(".".concat(image));
|
|
51
|
+
})) {
|
|
52
|
+
return "image";
|
|
53
|
+
}
|
|
54
|
+
if (videos.some(function(video) {
|
|
55
|
+
return item.endsWith(".".concat(video));
|
|
56
|
+
})) {
|
|
57
|
+
return "video";
|
|
58
|
+
}
|
|
59
|
+
if (fonts.some(function(font) {
|
|
60
|
+
return item.endsWith(".".concat(font));
|
|
61
|
+
})) {
|
|
62
|
+
return "font";
|
|
63
|
+
}
|
|
64
|
+
}();
|
|
61
65
|
return {
|
|
62
|
-
uri: item
|
|
63
|
-
as:
|
|
66
|
+
uri: item,
|
|
67
|
+
as: type
|
|
64
68
|
};
|
|
65
|
-
}
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var uri = param.uri;
|
|
71
|
-
return !transformToRegExp(exclude2).test(uri);
|
|
72
|
-
}) : links2;
|
|
73
|
-
};
|
|
74
|
-
var addAttributes = function addAttributes2(links2, attributes2) {
|
|
75
|
-
var parseAttributes = function(_attributes) {
|
|
76
|
-
return Object.entries(_attributes || {}).reduce(function(results, param) {
|
|
77
|
-
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
78
|
-
if (typeof value === "boolean") {
|
|
79
|
-
value && results.push("; ".concat(key));
|
|
80
|
-
return results;
|
|
81
|
-
}
|
|
82
|
-
results.push("; ".concat(key, "=").concat(value));
|
|
83
|
-
return results;
|
|
84
|
-
}, []).join("");
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
uri: item.url,
|
|
72
|
+
as: item.as,
|
|
73
|
+
rel: item.rel
|
|
85
74
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
}();
|
|
104
|
-
return "<".concat(uri, ">; rel=preload; as=").concat(as).concat(attributesStr);
|
|
105
|
-
}
|
|
106
|
-
return "<".concat(uri, ">; rel=preload");
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
var dedup = function dedup2(links2) {
|
|
110
|
-
var set = /* @__PURE__ */ new Set();
|
|
111
|
-
return links2.filter(function(param) {
|
|
112
|
-
var uri = param.uri;
|
|
113
|
-
if (set.has(uri)) {
|
|
114
|
-
return false;
|
|
75
|
+
})) || [];
|
|
76
|
+
return links.concat(includes);
|
|
77
|
+
}
|
|
78
|
+
function removeExclude(links, exclude) {
|
|
79
|
+
return exclude ? links.filter(function(param) {
|
|
80
|
+
var uri = param.uri;
|
|
81
|
+
return !transformToRegExp(exclude).test(uri);
|
|
82
|
+
}) : links;
|
|
83
|
+
}
|
|
84
|
+
function addAttributes(links, attributes) {
|
|
85
|
+
var parseAttributes = function(_attributes) {
|
|
86
|
+
return Object.entries(_attributes || {}).reduce(function(results, param) {
|
|
87
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
88
|
+
if (typeof value === "boolean") {
|
|
89
|
+
value && results.push("; ".concat(key));
|
|
90
|
+
return results;
|
|
115
91
|
}
|
|
116
|
-
|
|
117
|
-
return
|
|
118
|
-
});
|
|
92
|
+
results.push("; ".concat(key, "=").concat(value));
|
|
93
|
+
return results;
|
|
94
|
+
}, []).join("");
|
|
119
95
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
96
|
+
return links.map(function(link) {
|
|
97
|
+
var as = link.as;
|
|
98
|
+
if (as) {
|
|
99
|
+
var attributesStr = function() {
|
|
100
|
+
var _ref = attributes || {}, style = _ref.style, script = _ref.script, image = _ref.image, font = _ref.font;
|
|
101
|
+
switch (as) {
|
|
102
|
+
case "script":
|
|
103
|
+
return parseAttributes(script);
|
|
104
|
+
case "style":
|
|
105
|
+
return parseAttributes(style);
|
|
106
|
+
case "image":
|
|
107
|
+
return parseAttributes(image);
|
|
108
|
+
case "font":
|
|
109
|
+
return parseAttributes(font);
|
|
110
|
+
default:
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
}();
|
|
114
|
+
return _object_spread_props(_object_spread({}, link), {
|
|
115
|
+
rest: attributesStr
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return link;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function dedup(links) {
|
|
122
|
+
var set = /* @__PURE__ */ new Set();
|
|
123
|
+
return links.filter(function(param) {
|
|
124
|
+
var uri = param.uri;
|
|
125
|
+
if (set.has(uri)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
set.add(uri);
|
|
129
|
+
return true;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function transformLinkToString(links) {
|
|
133
|
+
return links.map(function(param) {
|
|
134
|
+
var uri = param.uri, as = param.as, originalRel = param.rel, rest = param.rest;
|
|
135
|
+
var rel = originalRel || "preload";
|
|
136
|
+
return as ? "<".concat(uri, ">; rel=").concat(rel, "; as=").concat(as).concat(rest || "") : "<".concat(uri, ">; rel=").concat(rel).concat(rest || "");
|
|
137
|
+
}).join(", ");
|
|
129
138
|
}
|
|
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { cutNameByHyphen, mime } from "@modern-js/utils";
|
|
5
5
|
import { ERROR_DIGEST } from "../../constants";
|
|
6
|
-
import {
|
|
6
|
+
import { shouldFlushServerHeader } from "../preload/shouldFlushServerHeader";
|
|
7
7
|
import { handleDirectory } from "./static";
|
|
8
8
|
import { readFile } from "./reader";
|
|
9
9
|
import * as ssr from "./ssr";
|
|
@@ -12,7 +12,7 @@ export var createRenderHandler = function(param) {
|
|
|
12
12
|
var distDir = param.distDir, staticGenerate = param.staticGenerate, conf = param.conf, forceCSR = param.forceCSR, nonce = param.nonce, ssrRender = param.ssrRender, _param_metaName = param.metaName, metaName = _param_metaName === void 0 ? "modern-js" : _param_metaName;
|
|
13
13
|
return function() {
|
|
14
14
|
var _render = _async_to_generator(function(param2) {
|
|
15
|
-
var ctx, route, runner, entryPath, urlPath, entry, result, templatePath, content, useCSR, userAgent, disablePreload, ssrRenderOptions, result1, err;
|
|
15
|
+
var ctx, route, runner, entryPath, urlPath, entry, result, templatePath, content, useCSR, userAgent, disablePreload, flushServerHeader, ssrRenderOptions, result1, err;
|
|
16
16
|
return _ts_generator(this, function(_state) {
|
|
17
17
|
switch (_state.label) {
|
|
18
18
|
case 0:
|
|
@@ -58,29 +58,40 @@ export var createRenderHandler = function(param) {
|
|
|
58
58
|
if (!(route.isSSR && !useCSR))
|
|
59
59
|
return [
|
|
60
60
|
3,
|
|
61
|
-
|
|
61
|
+
9
|
|
62
62
|
];
|
|
63
63
|
_state.label = 4;
|
|
64
64
|
case 4:
|
|
65
65
|
_state.trys.push([
|
|
66
66
|
4,
|
|
67
|
-
|
|
67
|
+
8,
|
|
68
68
|
,
|
|
69
|
-
|
|
69
|
+
9
|
|
70
70
|
]);
|
|
71
71
|
userAgent = ctx.getReqHeader("User-Agent");
|
|
72
72
|
disablePreload = Boolean(ctx.headers["x-".concat(cutNameByHyphen(metaName), "-disable-preload")]);
|
|
73
|
-
if (shouldFlushServerHeader(conf.server, userAgent, disablePreload))
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
if (!shouldFlushServerHeader(conf.server, userAgent, disablePreload))
|
|
74
|
+
return [
|
|
75
|
+
3,
|
|
76
|
+
6
|
|
77
|
+
];
|
|
78
|
+
return [
|
|
79
|
+
4,
|
|
80
|
+
import("../preload")
|
|
81
|
+
];
|
|
82
|
+
case 5:
|
|
83
|
+
flushServerHeader = _state.sent().flushServerHeader;
|
|
84
|
+
flushServerHeader({
|
|
85
|
+
serverConf: conf.server,
|
|
86
|
+
ctx: ctx,
|
|
87
|
+
distDir: distDir,
|
|
88
|
+
template: content.toString(),
|
|
89
|
+
headers: {
|
|
90
|
+
"Content-Type": mime.contentType(path.extname(templatePath))
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
_state.label = 6;
|
|
94
|
+
case 6:
|
|
84
95
|
ssrRenderOptions = {
|
|
85
96
|
distDir: distDir,
|
|
86
97
|
entryName: route.entryName,
|
|
@@ -102,21 +113,21 @@ export var createRenderHandler = function(param) {
|
|
|
102
113
|
nonce: nonce
|
|
103
114
|
}, runner)
|
|
104
115
|
];
|
|
105
|
-
case
|
|
116
|
+
case 7:
|
|
106
117
|
result1 = _state.sent();
|
|
107
118
|
return [
|
|
108
119
|
2,
|
|
109
120
|
result1
|
|
110
121
|
];
|
|
111
|
-
case
|
|
122
|
+
case 8:
|
|
112
123
|
err = _state.sent();
|
|
113
124
|
ctx.error(ERROR_DIGEST.ERENDER, err.stack || err.message);
|
|
114
125
|
ctx.res.set("x-modern-ssr-fallback", "1");
|
|
115
126
|
return [
|
|
116
127
|
3,
|
|
117
|
-
|
|
128
|
+
9
|
|
118
129
|
];
|
|
119
|
-
case
|
|
130
|
+
case 9:
|
|
120
131
|
return [
|
|
121
132
|
2,
|
|
122
133
|
{
|
|
@@ -1,28 +1,5 @@
|
|
|
1
1
|
import { parseLinks } from "./parseLinks";
|
|
2
2
|
import { transformLinks2String } from "./transformLinks2String";
|
|
3
|
-
export function transformToRegExp(input) {
|
|
4
|
-
if (typeof input === "string") {
|
|
5
|
-
return new RegExp(input);
|
|
6
|
-
}
|
|
7
|
-
return input;
|
|
8
|
-
}
|
|
9
|
-
export function shouldFlushServerHeader(serverConf, userAgent, disablePreload) {
|
|
10
|
-
const { ssr: ssrConf } = serverConf || {};
|
|
11
|
-
if (disablePreload) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
if (typeof ssrConf === "object" && ssrConf.preload) {
|
|
15
|
-
if (typeof ssrConf.preload === "object") {
|
|
16
|
-
const { userAgentFilter } = ssrConf.preload;
|
|
17
|
-
if (userAgentFilter && userAgent) {
|
|
18
|
-
return !transformToRegExp(userAgentFilter).test(userAgent);
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
3
|
export async function flushServerHeader({ serverConf, ctx, distDir, template, headers }) {
|
|
27
4
|
const { ssr: ssrConf } = serverConf || {};
|
|
28
5
|
if (typeof ssrConf !== "object") {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function transformToRegExp(input) {
|
|
2
|
+
if (typeof input === "string") {
|
|
3
|
+
return new RegExp(input);
|
|
4
|
+
}
|
|
5
|
+
return input;
|
|
6
|
+
}
|
|
7
|
+
export function shouldFlushServerHeader(serverConf, userAgent, disablePreload) {
|
|
8
|
+
const { ssr: ssrConf } = serverConf || {};
|
|
9
|
+
if (disablePreload) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (typeof ssrConf === "object" && ssrConf.preload) {
|
|
13
|
+
if (typeof ssrConf.preload === "object") {
|
|
14
|
+
const { userAgentFilter } = ssrConf.preload;
|
|
15
|
+
if (userAgentFilter && userAgent) {
|
|
16
|
+
return !transformToRegExp(userAgentFilter).test(userAgent);
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
@@ -1,113 +1,124 @@
|
|
|
1
|
-
import { transformToRegExp } from "./
|
|
1
|
+
import { transformToRegExp } from "./shouldFlushServerHeader";
|
|
2
2
|
export function transformLinks2String(links, preload) {
|
|
3
3
|
if (typeof preload === "boolean") {
|
|
4
|
-
return dedup(links)
|
|
4
|
+
return transformLinkToString(dedup(links));
|
|
5
5
|
}
|
|
6
6
|
const { include, exclude, attributes } = preload;
|
|
7
|
-
const resolveLinks = addAttributes(dedup(removeExclude(addInclude(links, include), exclude)), attributes);
|
|
8
|
-
return resolveLinks
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
uri: item,
|
|
57
|
-
as: type
|
|
58
|
-
};
|
|
59
|
-
}
|
|
7
|
+
const resolveLinks = transformLinkToString(addAttributes(dedup(removeExclude(addInclude(links, include), exclude)), attributes));
|
|
8
|
+
return resolveLinks;
|
|
9
|
+
}
|
|
10
|
+
function addInclude(links, include) {
|
|
11
|
+
var _include;
|
|
12
|
+
const images = [
|
|
13
|
+
"gif",
|
|
14
|
+
"jpg",
|
|
15
|
+
"jpeg",
|
|
16
|
+
"png",
|
|
17
|
+
"webp",
|
|
18
|
+
"bmp",
|
|
19
|
+
"tiff",
|
|
20
|
+
"anpg",
|
|
21
|
+
"ico"
|
|
22
|
+
];
|
|
23
|
+
const videos = [
|
|
24
|
+
"mp4",
|
|
25
|
+
"webm",
|
|
26
|
+
"ogm",
|
|
27
|
+
"ogv",
|
|
28
|
+
"ogg"
|
|
29
|
+
];
|
|
30
|
+
const fonts = [
|
|
31
|
+
"woff",
|
|
32
|
+
"woff2",
|
|
33
|
+
"eot",
|
|
34
|
+
"ttf",
|
|
35
|
+
"otf"
|
|
36
|
+
];
|
|
37
|
+
const includes = ((_include = include) === null || _include === void 0 ? void 0 : _include.map((item) => {
|
|
38
|
+
if (typeof item === "string") {
|
|
39
|
+
const type = (() => {
|
|
40
|
+
if (item.endsWith(".js")) {
|
|
41
|
+
return "script";
|
|
42
|
+
}
|
|
43
|
+
if (item.endsWith(".css")) {
|
|
44
|
+
return "style";
|
|
45
|
+
}
|
|
46
|
+
if (images.some((image) => item.endsWith(`.${image}`))) {
|
|
47
|
+
return "image";
|
|
48
|
+
}
|
|
49
|
+
if (videos.some((video) => item.endsWith(`.${video}`))) {
|
|
50
|
+
return "video";
|
|
51
|
+
}
|
|
52
|
+
if (fonts.some((font) => item.endsWith(`.${font}`))) {
|
|
53
|
+
return "font";
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
60
56
|
return {
|
|
61
|
-
uri: item
|
|
62
|
-
as:
|
|
57
|
+
uri: item,
|
|
58
|
+
as: type
|
|
63
59
|
};
|
|
64
|
-
}
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
function addAttributes(links2, attributes2) {
|
|
71
|
-
const parseAttributes = (_attributes) => {
|
|
72
|
-
return Object.entries(_attributes || {}).reduce((results, [key, value]) => {
|
|
73
|
-
if (typeof value === "boolean") {
|
|
74
|
-
value && results.push(`; ${key}`);
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
results.push(`; ${key}=${value}`);
|
|
78
|
-
return results;
|
|
79
|
-
}, []).join("");
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
uri: item.url,
|
|
63
|
+
as: item.as,
|
|
64
|
+
rel: item.rel
|
|
80
65
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return parseAttributes(font);
|
|
94
|
-
default:
|
|
95
|
-
return "";
|
|
96
|
-
}
|
|
97
|
-
})();
|
|
98
|
-
return `<${uri}>; rel=preload; as=${as}${attributesStr}`;
|
|
99
|
-
}
|
|
100
|
-
return `<${uri}>; rel=preload`;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function dedup(links2) {
|
|
104
|
-
const set = /* @__PURE__ */ new Set();
|
|
105
|
-
return links2.filter(({ uri }) => {
|
|
106
|
-
if (set.has(uri)) {
|
|
107
|
-
return false;
|
|
66
|
+
})) || [];
|
|
67
|
+
return links.concat(includes);
|
|
68
|
+
}
|
|
69
|
+
function removeExclude(links, exclude) {
|
|
70
|
+
return exclude ? links.filter(({ uri }) => !transformToRegExp(exclude).test(uri)) : links;
|
|
71
|
+
}
|
|
72
|
+
function addAttributes(links, attributes) {
|
|
73
|
+
const parseAttributes = (_attributes) => {
|
|
74
|
+
return Object.entries(_attributes || {}).reduce((results, [key, value]) => {
|
|
75
|
+
if (typeof value === "boolean") {
|
|
76
|
+
value && results.push(`; ${key}`);
|
|
77
|
+
return results;
|
|
108
78
|
}
|
|
109
|
-
|
|
110
|
-
return
|
|
111
|
-
});
|
|
112
|
-
}
|
|
79
|
+
results.push(`; ${key}=${value}`);
|
|
80
|
+
return results;
|
|
81
|
+
}, []).join("");
|
|
82
|
+
};
|
|
83
|
+
return links.map((link) => {
|
|
84
|
+
const { as } = link;
|
|
85
|
+
if (as) {
|
|
86
|
+
const attributesStr = (() => {
|
|
87
|
+
const { style, script, image, font } = attributes || {};
|
|
88
|
+
switch (as) {
|
|
89
|
+
case "script":
|
|
90
|
+
return parseAttributes(script);
|
|
91
|
+
case "style":
|
|
92
|
+
return parseAttributes(style);
|
|
93
|
+
case "image":
|
|
94
|
+
return parseAttributes(image);
|
|
95
|
+
case "font":
|
|
96
|
+
return parseAttributes(font);
|
|
97
|
+
default:
|
|
98
|
+
return "";
|
|
99
|
+
}
|
|
100
|
+
})();
|
|
101
|
+
return {
|
|
102
|
+
...link,
|
|
103
|
+
rest: attributesStr
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return link;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function dedup(links) {
|
|
110
|
+
const set = /* @__PURE__ */ new Set();
|
|
111
|
+
return links.filter(({ uri }) => {
|
|
112
|
+
if (set.has(uri)) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
set.add(uri);
|
|
116
|
+
return true;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function transformLinkToString(links) {
|
|
120
|
+
return links.map(({ uri, as, rel: originalRel, rest }) => {
|
|
121
|
+
const rel = originalRel || "preload";
|
|
122
|
+
return as ? `<${uri}>; rel=${rel}; as=${as}${rest || ""}` : `<${uri}>; rel=${rel}${rest || ""}`;
|
|
123
|
+
}).join(", ");
|
|
113
124
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { cutNameByHyphen, mime } from "@modern-js/utils";
|
|
3
3
|
import { ERROR_DIGEST } from "../../constants";
|
|
4
|
-
import {
|
|
4
|
+
import { shouldFlushServerHeader } from "../preload/shouldFlushServerHeader";
|
|
5
5
|
import { handleDirectory } from "./static";
|
|
6
6
|
import { readFile } from "./reader";
|
|
7
7
|
import * as ssr from "./ssr";
|
|
@@ -27,6 +27,7 @@ export const createRenderHandler = ({ distDir, staticGenerate, conf, forceCSR, n
|
|
|
27
27
|
const userAgent = ctx.getReqHeader("User-Agent");
|
|
28
28
|
const disablePreload = Boolean(ctx.headers[`x-${cutNameByHyphen(metaName)}-disable-preload`]);
|
|
29
29
|
if (shouldFlushServerHeader(conf.server, userAgent, disablePreload)) {
|
|
30
|
+
const { flushServerHeader } = await import("../preload");
|
|
30
31
|
flushServerHeader({
|
|
31
32
|
serverConf: conf.server,
|
|
32
33
|
ctx,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node/http" />
|
|
5
|
-
/// <reference types=".dts-temp/
|
|
5
|
+
/// <reference types=".dts-temp/o0jn6hsenwfj7pkdv8st4/src/type" />
|
|
6
6
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
7
7
|
import qs from 'querystring';
|
|
8
8
|
import type { ModernServerContext as ModernServerContextInterface, Reporter as ModernServerReporter, ServerTiming as ModernServerTiming } from '@modern-js/types';
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { OutgoingHttpHeaders } from 'http';
|
|
3
3
|
import { ServerOptions } from '@modern-js/server-core';
|
|
4
4
|
import { ModernServerContext } from '@modern-js/types';
|
|
5
|
-
export declare function transformToRegExp(input: string | RegExp): RegExp;
|
|
6
|
-
export declare function shouldFlushServerHeader(serverConf: ServerOptions['server'], userAgent?: string, disablePreload?: boolean): boolean;
|
|
7
5
|
export interface FlushServerHeaderOptions {
|
|
8
6
|
ctx: ModernServerContext;
|
|
9
7
|
distDir: string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ServerOptions } from '@modern-js/server-core';
|
|
2
|
+
export declare function transformToRegExp(input: string | RegExp): RegExp;
|
|
3
|
+
export declare function shouldFlushServerHeader(serverConf: ServerOptions['server'], userAgent?: string, disablePreload?: boolean): boolean;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node/http" />
|
|
3
|
-
/// <reference types=".dts-temp/
|
|
3
|
+
/// <reference types=".dts-temp/o0jn6hsenwfj7pkdv8st4/src/type" />
|
|
4
4
|
import { IncomingMessage } from 'http';
|
|
5
5
|
import type { OutputNormalizedConfig, HtmlNormalizedConfig } from '@modern-js/server-core';
|
|
6
6
|
export declare const debug: any;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.34.1-alpha.1",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"node-html-parser": "^6.1.5",
|
|
75
75
|
"path-to-regexp": "^6.2.0",
|
|
76
76
|
"serve-static": "^1.14.1",
|
|
77
|
-
"@modern-js/
|
|
78
|
-
"@modern-js/
|
|
79
|
-
"@modern-js/
|
|
77
|
+
"@modern-js/server-core": "2.34.0",
|
|
78
|
+
"@modern-js/utils": "2.34.0",
|
|
79
|
+
"@modern-js/plugin": "2.34.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/cookie": "^0.4.1",
|
|
@@ -95,10 +95,10 @@
|
|
|
95
95
|
"portfinder": "^1.0.28",
|
|
96
96
|
"typescript": "^5",
|
|
97
97
|
"ws": "^8.13.0",
|
|
98
|
-
"@modern-js/server-core": "2.
|
|
99
|
-
"@
|
|
100
|
-
"@
|
|
101
|
-
"@scripts/jest-config": "2.
|
|
98
|
+
"@modern-js/server-core": "2.34.0",
|
|
99
|
+
"@scripts/build": "2.34.0",
|
|
100
|
+
"@modern-js/types": "2.34.0",
|
|
101
|
+
"@scripts/jest-config": "2.34.0"
|
|
102
102
|
},
|
|
103
103
|
"sideEffects": false,
|
|
104
104
|
"publishConfig": {
|