@modern-js/runtime 2.40.0 → 2.41.0
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/core/loader/loaderManager.js +7 -7
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.js +3 -3
- package/dist/cjs/ssr/serverRender/renderToStream/renderToPipe.worker.js +3 -3
- package/dist/cjs/ssr/serverRender/renderToString/entry.js +3 -2
- package/dist/cjs/ssr/serverRender/renderToString/loadable.js +2 -2
- package/dist/cjs/ssr/serverRender/tracker.js +9 -9
- package/dist/esm/core/loader/loaderManager.js +7 -7
- package/dist/esm/ssr/cli/babel-plugin-ssr-loader-id.js +3 -3
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +6 -6
- package/dist/esm/ssr/serverRender/renderToStream/bulidTemplate.before.js +14 -14
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.js +3 -3
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.worker.js +3 -3
- package/dist/esm/ssr/serverRender/renderToString/entry.js +2 -1
- package/dist/esm/ssr/serverRender/renderToString/loadable.js +2 -2
- package/dist/esm/ssr/serverRender/tracker.js +9 -9
- package/dist/esm-node/core/loader/loaderManager.js +7 -7
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.js +3 -3
- package/dist/esm-node/ssr/serverRender/renderToStream/renderToPipe.worker.js +3 -3
- package/dist/esm-node/ssr/serverRender/renderToString/entry.js +3 -2
- package/dist/esm-node/ssr/serverRender/renderToString/loadable.js +2 -2
- package/dist/esm-node/ssr/serverRender/tracker.js +9 -9
- package/package.json +11 -11
|
@@ -60,7 +60,7 @@ const createLoader = (id, initialData = {
|
|
|
60
60
|
error: void 0
|
|
61
61
|
}, loaderFn, skip = false) => {
|
|
62
62
|
let promise;
|
|
63
|
-
let status =
|
|
63
|
+
let status = 0;
|
|
64
64
|
let { data, error } = initialData;
|
|
65
65
|
let hasLoaded = false;
|
|
66
66
|
const handlers = /* @__PURE__ */ new Set();
|
|
@@ -68,19 +68,19 @@ const createLoader = (id, initialData = {
|
|
|
68
68
|
if (skip) {
|
|
69
69
|
return promise;
|
|
70
70
|
}
|
|
71
|
-
if (status ===
|
|
71
|
+
if (status === 1) {
|
|
72
72
|
return promise;
|
|
73
73
|
}
|
|
74
|
-
status =
|
|
74
|
+
status = 1;
|
|
75
75
|
notify();
|
|
76
76
|
promise = loaderFn().then((value) => {
|
|
77
77
|
data = value;
|
|
78
78
|
error = null;
|
|
79
|
-
status =
|
|
79
|
+
status = 2;
|
|
80
80
|
}).catch((e) => {
|
|
81
81
|
error = e;
|
|
82
82
|
data = null;
|
|
83
|
-
status =
|
|
83
|
+
status = 3;
|
|
84
84
|
}).finally(() => {
|
|
85
85
|
promise = null;
|
|
86
86
|
hasLoaded = true;
|
|
@@ -89,8 +89,8 @@ const createLoader = (id, initialData = {
|
|
|
89
89
|
return promise;
|
|
90
90
|
};
|
|
91
91
|
const getResult = () => ({
|
|
92
|
-
loading: !hasLoaded && status ===
|
|
93
|
-
reloading: hasLoaded && status ===
|
|
92
|
+
loading: !hasLoaded && status === 1,
|
|
93
|
+
reloading: hasLoaded && status === 1,
|
|
94
94
|
data,
|
|
95
95
|
error: error instanceof Error ? `${error.message}` : error,
|
|
96
96
|
// redundant fields for ssr log
|
|
@@ -31,7 +31,7 @@ var ShellChunkStatus;
|
|
|
31
31
|
ShellChunkStatus2[ShellChunkStatus2["FINIESH"] = 1] = "FINIESH";
|
|
32
32
|
})(ShellChunkStatus || (ShellChunkStatus = {}));
|
|
33
33
|
function renderToPipe(rootElement, context, options) {
|
|
34
|
-
let shellChunkStatus =
|
|
34
|
+
let shellChunkStatus = 0;
|
|
35
35
|
const { ssrContext } = context;
|
|
36
36
|
const chunkVec = [];
|
|
37
37
|
const forUserPipe = (stream) => {
|
|
@@ -51,12 +51,12 @@ function renderToPipe(rootElement, context, options) {
|
|
|
51
51
|
const injectableTransform = new import_stream.Transform({
|
|
52
52
|
transform(chunk, _encoding, callback) {
|
|
53
53
|
try {
|
|
54
|
-
if (shellChunkStatus !==
|
|
54
|
+
if (shellChunkStatus !== 1) {
|
|
55
55
|
chunkVec.push(chunk.toString());
|
|
56
56
|
let concatedChunk = chunkVec.join("");
|
|
57
57
|
if (concatedChunk.endsWith(import_common.ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
58
58
|
concatedChunk = concatedChunk.replace(import_common.ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
59
|
-
shellChunkStatus =
|
|
59
|
+
shellChunkStatus = 1;
|
|
60
60
|
this.push(`${shellBefore}${concatedChunk}${shellAfter}`);
|
|
61
61
|
}
|
|
62
62
|
} else {
|
|
@@ -31,7 +31,7 @@ var ShellChunkStatus;
|
|
|
31
31
|
ShellChunkStatus2[ShellChunkStatus2["FINIESH"] = 1] = "FINIESH";
|
|
32
32
|
})(ShellChunkStatus || (ShellChunkStatus = {}));
|
|
33
33
|
function renderToPipe(rootElement, context, options) {
|
|
34
|
-
let shellChunkStatus =
|
|
34
|
+
let shellChunkStatus = 0;
|
|
35
35
|
const chunkVec = [];
|
|
36
36
|
const { ssrContext } = context;
|
|
37
37
|
const forUserPipe = async () => {
|
|
@@ -59,13 +59,13 @@ function renderToPipe(rootElement, context, options) {
|
|
|
59
59
|
controller.close();
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
if (shellChunkStatus !==
|
|
62
|
+
if (shellChunkStatus !== 1) {
|
|
63
63
|
const chunk = new TextDecoder().decode(value);
|
|
64
64
|
chunkVec.push(chunk);
|
|
65
65
|
let concatedChunk = chunkVec.join("");
|
|
66
66
|
if (concatedChunk.endsWith(import_common.ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
67
67
|
concatedChunk = concatedChunk.replace(import_common.ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
68
|
-
shellChunkStatus =
|
|
68
|
+
shellChunkStatus = 1;
|
|
69
69
|
controller.enqueue(encodeForWebStream(`${shellBefore}${concatedChunk}${shellAfter}`));
|
|
70
70
|
}
|
|
71
71
|
} else {
|
|
@@ -69,7 +69,8 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
|
|
|
69
69
|
renderLevel
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
-
|
|
72
|
+
var Entry;
|
|
73
|
+
Entry = class Entry2 {
|
|
73
74
|
async renderToHtml(context) {
|
|
74
75
|
var _ssrContext_redirection, _ssrContext_redirection1, _ssrContext_redirection2;
|
|
75
76
|
const ssrContext = context.ssrContext;
|
|
@@ -186,4 +187,4 @@ class Entry {
|
|
|
186
187
|
}
|
|
187
188
|
};
|
|
188
189
|
}
|
|
189
|
-
}
|
|
190
|
+
};
|
|
@@ -53,8 +53,8 @@ const checkIsInline = (chunk, enableInline) => {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
const readAsset = async (chunk) => {
|
|
56
|
-
const fs = await Promise.resolve().then(() => __toESM(require("
|
|
57
|
-
const path = await Promise.resolve().then(() => __toESM(require("
|
|
56
|
+
const fs = await Promise.resolve().then(() => __toESM(require("fs/promises")));
|
|
57
|
+
const path = await Promise.resolve().then(() => __toESM(require("path")));
|
|
58
58
|
const filepath = path.resolve(__dirname, chunk.filename);
|
|
59
59
|
return fs.readFile(filepath, "utf-8");
|
|
60
60
|
};
|
|
@@ -39,47 +39,47 @@ var SSRErrors;
|
|
|
39
39
|
SSRErrors2[SSRErrors2["RENDER_SHELL"] = 4] = "RENDER_SHELL";
|
|
40
40
|
})(SSRErrors || (SSRErrors = {}));
|
|
41
41
|
const errors = {
|
|
42
|
-
[
|
|
42
|
+
[0]: {
|
|
43
43
|
reporter: "SSR Error - App Prerender",
|
|
44
44
|
logger: "App Prerender",
|
|
45
45
|
metrics: "app.prerender.error"
|
|
46
46
|
},
|
|
47
|
-
[
|
|
47
|
+
[1]: {
|
|
48
48
|
reporter: "SSR Error - App run useLoader",
|
|
49
49
|
logger: "App run useLoader",
|
|
50
50
|
metrics: "app.useloader.error"
|
|
51
51
|
},
|
|
52
|
-
[
|
|
52
|
+
[2]: {
|
|
53
53
|
reporter: "SSR Error - App Render To HTML",
|
|
54
54
|
logger: "App Render To HTML",
|
|
55
55
|
metrics: "app.render.html.error"
|
|
56
56
|
},
|
|
57
|
-
[
|
|
57
|
+
[3]: {
|
|
58
58
|
reporter: "SSR Error - App Render To Streaming",
|
|
59
59
|
logger: "An error occurs during streaming SSR",
|
|
60
60
|
metrics: "app.render.streaming.error"
|
|
61
61
|
},
|
|
62
|
-
[
|
|
62
|
+
[4]: {
|
|
63
63
|
metrics: "app.render.streaming.shell.error"
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
const timings = {
|
|
67
|
-
[
|
|
67
|
+
[0]: {
|
|
68
68
|
reporter: "ssr-prerender",
|
|
69
69
|
serverTiming: "ssr-prerender",
|
|
70
70
|
metrics: "app.prerender.cost",
|
|
71
71
|
logger: "App Prerender cost = %d ms"
|
|
72
72
|
},
|
|
73
|
-
[
|
|
73
|
+
[1]: {
|
|
74
74
|
reporter: "ssr-render-html",
|
|
75
75
|
serverTiming: "ssr-render-html",
|
|
76
76
|
metrics: "app.render.html.cost",
|
|
77
77
|
logger: "App Render To HTML cost = %d ms"
|
|
78
78
|
},
|
|
79
|
-
[
|
|
79
|
+
[2]: {
|
|
80
80
|
reporter: "ssr-render-shell"
|
|
81
81
|
},
|
|
82
|
-
[
|
|
82
|
+
[3]: {
|
|
83
83
|
reporter: "use-loader",
|
|
84
84
|
serverTiming: "use-loader",
|
|
85
85
|
logger: "App run useLoader cost = %d ms"
|
|
@@ -32,7 +32,7 @@ var createLoader = function(id) {
|
|
|
32
32
|
error: void 0
|
|
33
33
|
}, loaderFn = arguments.length > 2 ? arguments[2] : void 0, skip = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
|
|
34
34
|
var promise;
|
|
35
|
-
var status =
|
|
35
|
+
var status = 0;
|
|
36
36
|
var data = initialData.data, error = initialData.error;
|
|
37
37
|
var hasLoaded = false;
|
|
38
38
|
var handlers = /* @__PURE__ */ new Set();
|
|
@@ -45,22 +45,22 @@ var createLoader = function(id) {
|
|
|
45
45
|
promise
|
|
46
46
|
];
|
|
47
47
|
}
|
|
48
|
-
if (status ===
|
|
48
|
+
if (status === 1) {
|
|
49
49
|
return [
|
|
50
50
|
2,
|
|
51
51
|
promise
|
|
52
52
|
];
|
|
53
53
|
}
|
|
54
|
-
status =
|
|
54
|
+
status = 1;
|
|
55
55
|
notify();
|
|
56
56
|
promise = loaderFn().then(function(value) {
|
|
57
57
|
data = value;
|
|
58
58
|
error = null;
|
|
59
|
-
status =
|
|
59
|
+
status = 2;
|
|
60
60
|
}).catch(function(e) {
|
|
61
61
|
error = e;
|
|
62
62
|
data = null;
|
|
63
|
-
status =
|
|
63
|
+
status = 3;
|
|
64
64
|
}).finally(function() {
|
|
65
65
|
promise = null;
|
|
66
66
|
hasLoaded = true;
|
|
@@ -78,8 +78,8 @@ var createLoader = function(id) {
|
|
|
78
78
|
}();
|
|
79
79
|
var getResult = function() {
|
|
80
80
|
return {
|
|
81
|
-
loading: !hasLoaded && status ===
|
|
82
|
-
reloading: hasLoaded && status ===
|
|
81
|
+
loading: !hasLoaded && status === 1,
|
|
82
|
+
reloading: hasLoaded && status === 1,
|
|
83
83
|
data,
|
|
84
84
|
error: _instanceof(error, Error) ? "".concat(error.message) : error,
|
|
85
85
|
// redundant fields for ssr log
|
|
@@ -62,12 +62,12 @@ var require_babel_plugin_ssr_loader_id = __commonJS({
|
|
|
62
62
|
])), []);
|
|
63
63
|
}
|
|
64
64
|
module.exports = function() {
|
|
65
|
-
var genId = function genId2() {
|
|
66
|
-
return "".concat(hash, "_").concat(index++);
|
|
67
|
-
};
|
|
68
65
|
var useLoader = null;
|
|
69
66
|
var hash = "";
|
|
70
67
|
var index = 0;
|
|
68
|
+
function genId() {
|
|
69
|
+
return "".concat(hash, "_").concat(index++);
|
|
70
|
+
}
|
|
71
71
|
return {
|
|
72
72
|
name: "babel-plugin-ssr-loader-id",
|
|
73
73
|
pre: function pre() {
|
|
@@ -3,7 +3,11 @@ import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
|
3
3
|
import { attributesToString } from "../utils";
|
|
4
4
|
import { buildTemplate } from "./buildTemplate.share";
|
|
5
5
|
function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
6
|
-
var
|
|
6
|
+
var callbacks = [
|
|
7
|
+
injectSSRDataScript
|
|
8
|
+
];
|
|
9
|
+
return buildTemplate(afterAppTemplate, callbacks);
|
|
10
|
+
function injectSSRDataScript(template) {
|
|
7
11
|
var ssrDataScript = buildSSRDataScript();
|
|
8
12
|
return template.replace("<!--<?- SSRDataScript ?>-->", ssrDataScript);
|
|
9
13
|
function buildSSRDataScript() {
|
|
@@ -36,11 +40,7 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
|
36
40
|
});
|
|
37
41
|
return "\n <script".concat(attrsStr, ">window._SSR_DATA = ").concat(serializeJson(SSRData), "</script>\n ");
|
|
38
42
|
}
|
|
39
|
-
}
|
|
40
|
-
var callbacks = [
|
|
41
|
-
injectSSRDataScript
|
|
42
|
-
];
|
|
43
|
-
return buildTemplate(afterAppTemplate, callbacks);
|
|
43
|
+
}
|
|
44
44
|
}
|
|
45
45
|
export {
|
|
46
46
|
buildShellAfterTemplate
|
|
@@ -6,7 +6,20 @@ import helmetReplace from "../helmet";
|
|
|
6
6
|
import { CSS_CHUNKS_PLACEHOLDER } from "../utils";
|
|
7
7
|
import { HEAD_REG_EXP, buildTemplate } from "./buildTemplate.share";
|
|
8
8
|
function getHeadTemplate(beforeEntryTemplate, context) {
|
|
9
|
-
var
|
|
9
|
+
var callbacks = [
|
|
10
|
+
function(headTemplate2) {
|
|
11
|
+
var helmetData = ReactHelmet.renderStatic();
|
|
12
|
+
return helmetData ? helmetReplace(headTemplate2, helmetData) : headTemplate2;
|
|
13
|
+
},
|
|
14
|
+
// @TODO: prefetch scripts of lazy component
|
|
15
|
+
injectCss
|
|
16
|
+
];
|
|
17
|
+
var _ref = _sliced_to_array(beforeEntryTemplate.match(HEAD_REG_EXP) || [], 1), tmp = _ref[0], headTemplate = tmp === void 0 ? "" : tmp;
|
|
18
|
+
if (!headTemplate.length) {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
return buildTemplate(headTemplate, callbacks);
|
|
22
|
+
function injectCss(headTemplate2) {
|
|
10
23
|
return headTemplate2.replace(CSS_CHUNKS_PLACEHOLDER, getCssChunks());
|
|
11
24
|
function getCssChunks() {
|
|
12
25
|
var routeManifest = context.routeManifest, routerContext = context.routerContext, routes = context.routes;
|
|
@@ -38,20 +51,7 @@ function getHeadTemplate(beforeEntryTemplate, context) {
|
|
|
38
51
|
});
|
|
39
52
|
return "".concat(styleLinks.join(""));
|
|
40
53
|
}
|
|
41
|
-
};
|
|
42
|
-
var callbacks = [
|
|
43
|
-
function(headTemplate2) {
|
|
44
|
-
var helmetData = ReactHelmet.renderStatic();
|
|
45
|
-
return helmetData ? helmetReplace(headTemplate2, helmetData) : headTemplate2;
|
|
46
|
-
},
|
|
47
|
-
// @TODO: prefetch scripts of lazy component
|
|
48
|
-
injectCss
|
|
49
|
-
];
|
|
50
|
-
var _ref = _sliced_to_array(beforeEntryTemplate.match(HEAD_REG_EXP) || [], 1), tmp = _ref[0], headTemplate = tmp === void 0 ? "" : tmp;
|
|
51
|
-
if (!headTemplate.length) {
|
|
52
|
-
return "";
|
|
53
54
|
}
|
|
54
|
-
return buildTemplate(headTemplate, callbacks);
|
|
55
55
|
}
|
|
56
56
|
function buildShellBeforeTemplate(beforeAppTemplate, context) {
|
|
57
57
|
var headTemplate = getHeadTemplate(beforeAppTemplate, context);
|
|
@@ -11,7 +11,7 @@ var ShellChunkStatus;
|
|
|
11
11
|
ShellChunkStatus2[ShellChunkStatus2["FINIESH"] = 1] = "FINIESH";
|
|
12
12
|
})(ShellChunkStatus || (ShellChunkStatus = {}));
|
|
13
13
|
function renderToPipe(rootElement, context, options) {
|
|
14
|
-
var shellChunkStatus =
|
|
14
|
+
var shellChunkStatus = 0;
|
|
15
15
|
var ssrContext = context.ssrContext;
|
|
16
16
|
var chunkVec = [];
|
|
17
17
|
var forUserPipe = function(stream) {
|
|
@@ -30,12 +30,12 @@ function renderToPipe(rootElement, context, options) {
|
|
|
30
30
|
var injectableTransform = new Transform({
|
|
31
31
|
transform: function transform(chunk, _encoding, callback) {
|
|
32
32
|
try {
|
|
33
|
-
if (shellChunkStatus !==
|
|
33
|
+
if (shellChunkStatus !== 1) {
|
|
34
34
|
chunkVec.push(chunk.toString());
|
|
35
35
|
var concatedChunk = chunkVec.join("");
|
|
36
36
|
if (concatedChunk.endsWith(ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
37
37
|
concatedChunk = concatedChunk.replace(ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
38
|
-
shellChunkStatus =
|
|
38
|
+
shellChunkStatus = 1;
|
|
39
39
|
this.push("".concat(shellBefore).concat(concatedChunk).concat(shellAfter));
|
|
40
40
|
}
|
|
41
41
|
} else {
|
|
@@ -12,7 +12,7 @@ var ShellChunkStatus;
|
|
|
12
12
|
ShellChunkStatus2[ShellChunkStatus2["FINIESH"] = 1] = "FINIESH";
|
|
13
13
|
})(ShellChunkStatus || (ShellChunkStatus = {}));
|
|
14
14
|
function renderToPipe(rootElement, context, options) {
|
|
15
|
-
var shellChunkStatus =
|
|
15
|
+
var shellChunkStatus = 0;
|
|
16
16
|
var chunkVec = [];
|
|
17
17
|
var ssrContext = context.ssrContext;
|
|
18
18
|
var forUserPipe = function() {
|
|
@@ -70,13 +70,13 @@ function renderToPipe(rootElement, context, options) {
|
|
|
70
70
|
2
|
|
71
71
|
];
|
|
72
72
|
}
|
|
73
|
-
if (shellChunkStatus !==
|
|
73
|
+
if (shellChunkStatus !== 1) {
|
|
74
74
|
chunk = new TextDecoder().decode(value);
|
|
75
75
|
chunkVec.push(chunk);
|
|
76
76
|
concatedChunk = chunkVec.join("");
|
|
77
77
|
if (concatedChunk.endsWith(ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
78
78
|
concatedChunk = concatedChunk.replace(ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
79
|
-
shellChunkStatus =
|
|
79
|
+
shellChunkStatus = 1;
|
|
80
80
|
controller.enqueue(encodeForWebStream("".concat(shellBefore).concat(concatedChunk).concat(shellAfter)));
|
|
81
81
|
}
|
|
82
82
|
} else {
|
|
@@ -41,7 +41,8 @@ var buildTemplateData = function(context, data, renderLevel, tracker) {
|
|
|
41
41
|
renderLevel
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
var Entry
|
|
44
|
+
var Entry;
|
|
45
|
+
Entry = /* @__PURE__ */ function() {
|
|
45
46
|
"use strict";
|
|
46
47
|
function Entry2(options) {
|
|
47
48
|
_class_call_check(this, Entry2);
|
|
@@ -39,13 +39,13 @@ var readAsset = function() {
|
|
|
39
39
|
case 0:
|
|
40
40
|
return [
|
|
41
41
|
4,
|
|
42
|
-
import("
|
|
42
|
+
import("fs/promises")
|
|
43
43
|
];
|
|
44
44
|
case 1:
|
|
45
45
|
fs = _state.sent();
|
|
46
46
|
return [
|
|
47
47
|
4,
|
|
48
|
-
import("
|
|
48
|
+
import("path")
|
|
49
49
|
];
|
|
50
50
|
case 2:
|
|
51
51
|
path = _state.sent();
|
|
@@ -15,39 +15,39 @@ var SSRErrors;
|
|
|
15
15
|
SSRErrors2[SSRErrors2["RENDER_SHELL"] = 4] = "RENDER_SHELL";
|
|
16
16
|
})(SSRErrors || (SSRErrors = {}));
|
|
17
17
|
var _obj;
|
|
18
|
-
var errors = (_obj = {}, _define_property(_obj,
|
|
18
|
+
var errors = (_obj = {}, _define_property(_obj, 0, {
|
|
19
19
|
reporter: "SSR Error - App Prerender",
|
|
20
20
|
logger: "App Prerender",
|
|
21
21
|
metrics: "app.prerender.error"
|
|
22
|
-
}), _define_property(_obj,
|
|
22
|
+
}), _define_property(_obj, 1, {
|
|
23
23
|
reporter: "SSR Error - App run useLoader",
|
|
24
24
|
logger: "App run useLoader",
|
|
25
25
|
metrics: "app.useloader.error"
|
|
26
|
-
}), _define_property(_obj,
|
|
26
|
+
}), _define_property(_obj, 2, {
|
|
27
27
|
reporter: "SSR Error - App Render To HTML",
|
|
28
28
|
logger: "App Render To HTML",
|
|
29
29
|
metrics: "app.render.html.error"
|
|
30
|
-
}), _define_property(_obj,
|
|
30
|
+
}), _define_property(_obj, 3, {
|
|
31
31
|
reporter: "SSR Error - App Render To Streaming",
|
|
32
32
|
logger: "An error occurs during streaming SSR",
|
|
33
33
|
metrics: "app.render.streaming.error"
|
|
34
|
-
}), _define_property(_obj,
|
|
34
|
+
}), _define_property(_obj, 4, {
|
|
35
35
|
metrics: "app.render.streaming.shell.error"
|
|
36
36
|
}), _obj);
|
|
37
37
|
var _obj1;
|
|
38
|
-
var timings = (_obj1 = {}, _define_property(_obj1,
|
|
38
|
+
var timings = (_obj1 = {}, _define_property(_obj1, 0, {
|
|
39
39
|
reporter: "ssr-prerender",
|
|
40
40
|
serverTiming: "ssr-prerender",
|
|
41
41
|
metrics: "app.prerender.cost",
|
|
42
42
|
logger: "App Prerender cost = %d ms"
|
|
43
|
-
}), _define_property(_obj1,
|
|
43
|
+
}), _define_property(_obj1, 1, {
|
|
44
44
|
reporter: "ssr-render-html",
|
|
45
45
|
serverTiming: "ssr-render-html",
|
|
46
46
|
metrics: "app.render.html.cost",
|
|
47
47
|
logger: "App Render To HTML cost = %d ms"
|
|
48
|
-
}), _define_property(_obj1,
|
|
48
|
+
}), _define_property(_obj1, 2, {
|
|
49
49
|
reporter: "ssr-render-shell"
|
|
50
|
-
}), _define_property(_obj1,
|
|
50
|
+
}), _define_property(_obj1, 3, {
|
|
51
51
|
reporter: "use-loader",
|
|
52
52
|
serverTiming: "use-loader",
|
|
53
53
|
logger: "App run useLoader cost = %d ms"
|
|
@@ -26,7 +26,7 @@ const createLoader = (id, initialData = {
|
|
|
26
26
|
error: void 0
|
|
27
27
|
}, loaderFn, skip = false) => {
|
|
28
28
|
let promise;
|
|
29
|
-
let status =
|
|
29
|
+
let status = 0;
|
|
30
30
|
let { data, error } = initialData;
|
|
31
31
|
let hasLoaded = false;
|
|
32
32
|
const handlers = /* @__PURE__ */ new Set();
|
|
@@ -34,19 +34,19 @@ const createLoader = (id, initialData = {
|
|
|
34
34
|
if (skip) {
|
|
35
35
|
return promise;
|
|
36
36
|
}
|
|
37
|
-
if (status ===
|
|
37
|
+
if (status === 1) {
|
|
38
38
|
return promise;
|
|
39
39
|
}
|
|
40
|
-
status =
|
|
40
|
+
status = 1;
|
|
41
41
|
notify();
|
|
42
42
|
promise = loaderFn().then((value) => {
|
|
43
43
|
data = value;
|
|
44
44
|
error = null;
|
|
45
|
-
status =
|
|
45
|
+
status = 2;
|
|
46
46
|
}).catch((e) => {
|
|
47
47
|
error = e;
|
|
48
48
|
data = null;
|
|
49
|
-
status =
|
|
49
|
+
status = 3;
|
|
50
50
|
}).finally(() => {
|
|
51
51
|
promise = null;
|
|
52
52
|
hasLoaded = true;
|
|
@@ -55,8 +55,8 @@ const createLoader = (id, initialData = {
|
|
|
55
55
|
return promise;
|
|
56
56
|
};
|
|
57
57
|
const getResult = () => ({
|
|
58
|
-
loading: !hasLoaded && status ===
|
|
59
|
-
reloading: hasLoaded && status ===
|
|
58
|
+
loading: !hasLoaded && status === 1,
|
|
59
|
+
reloading: hasLoaded && status === 1,
|
|
60
60
|
data,
|
|
61
61
|
error: error instanceof Error ? `${error.message}` : error,
|
|
62
62
|
// redundant fields for ssr log
|
|
@@ -8,7 +8,7 @@ var ShellChunkStatus;
|
|
|
8
8
|
ShellChunkStatus2[ShellChunkStatus2["FINIESH"] = 1] = "FINIESH";
|
|
9
9
|
})(ShellChunkStatus || (ShellChunkStatus = {}));
|
|
10
10
|
function renderToPipe(rootElement, context, options) {
|
|
11
|
-
let shellChunkStatus =
|
|
11
|
+
let shellChunkStatus = 0;
|
|
12
12
|
const { ssrContext } = context;
|
|
13
13
|
const chunkVec = [];
|
|
14
14
|
const forUserPipe = (stream) => {
|
|
@@ -28,12 +28,12 @@ function renderToPipe(rootElement, context, options) {
|
|
|
28
28
|
const injectableTransform = new Transform({
|
|
29
29
|
transform(chunk, _encoding, callback) {
|
|
30
30
|
try {
|
|
31
|
-
if (shellChunkStatus !==
|
|
31
|
+
if (shellChunkStatus !== 1) {
|
|
32
32
|
chunkVec.push(chunk.toString());
|
|
33
33
|
let concatedChunk = chunkVec.join("");
|
|
34
34
|
if (concatedChunk.endsWith(ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
35
35
|
concatedChunk = concatedChunk.replace(ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
36
|
-
shellChunkStatus =
|
|
36
|
+
shellChunkStatus = 1;
|
|
37
37
|
this.push(`${shellBefore}${concatedChunk}${shellAfter}`);
|
|
38
38
|
}
|
|
39
39
|
} else {
|
|
@@ -8,7 +8,7 @@ var ShellChunkStatus;
|
|
|
8
8
|
ShellChunkStatus2[ShellChunkStatus2["FINIESH"] = 1] = "FINIESH";
|
|
9
9
|
})(ShellChunkStatus || (ShellChunkStatus = {}));
|
|
10
10
|
function renderToPipe(rootElement, context, options) {
|
|
11
|
-
let shellChunkStatus =
|
|
11
|
+
let shellChunkStatus = 0;
|
|
12
12
|
const chunkVec = [];
|
|
13
13
|
const { ssrContext } = context;
|
|
14
14
|
const forUserPipe = async () => {
|
|
@@ -36,13 +36,13 @@ function renderToPipe(rootElement, context, options) {
|
|
|
36
36
|
controller.close();
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
if (shellChunkStatus !==
|
|
39
|
+
if (shellChunkStatus !== 1) {
|
|
40
40
|
const chunk = new TextDecoder().decode(value);
|
|
41
41
|
chunkVec.push(chunk);
|
|
42
42
|
let concatedChunk = chunkVec.join("");
|
|
43
43
|
if (concatedChunk.endsWith(ESCAPED_SHELL_STREAM_END_MARK)) {
|
|
44
44
|
concatedChunk = concatedChunk.replace(ESCAPED_SHELL_STREAM_END_MARK, "");
|
|
45
|
-
shellChunkStatus =
|
|
45
|
+
shellChunkStatus = 1;
|
|
46
46
|
controller.enqueue(encodeForWebStream(`${shellBefore}${concatedChunk}${shellAfter}`));
|
|
47
47
|
}
|
|
48
48
|
} else {
|
|
@@ -36,7 +36,8 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
|
|
|
36
36
|
renderLevel
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
var Entry;
|
|
40
|
+
Entry = class Entry2 {
|
|
40
41
|
async renderToHtml(context) {
|
|
41
42
|
var _ssrContext_redirection, _ssrContext_redirection1, _ssrContext_redirection2;
|
|
42
43
|
const ssrContext = context.ssrContext;
|
|
@@ -153,7 +154,7 @@ class Entry {
|
|
|
153
154
|
}
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
|
-
}
|
|
157
|
+
};
|
|
157
158
|
export {
|
|
158
159
|
Entry as default
|
|
159
160
|
};
|
|
@@ -20,8 +20,8 @@ const checkIsInline = (chunk, enableInline) => {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
const readAsset = async (chunk) => {
|
|
23
|
-
const fs = await import("
|
|
24
|
-
const path = await import("
|
|
23
|
+
const fs = await import("fs/promises");
|
|
24
|
+
const path = await import("path");
|
|
25
25
|
const filepath = path.resolve(__dirname, chunk.filename);
|
|
26
26
|
return fs.readFile(filepath, "utf-8");
|
|
27
27
|
};
|
|
@@ -14,47 +14,47 @@ var SSRErrors;
|
|
|
14
14
|
SSRErrors2[SSRErrors2["RENDER_SHELL"] = 4] = "RENDER_SHELL";
|
|
15
15
|
})(SSRErrors || (SSRErrors = {}));
|
|
16
16
|
const errors = {
|
|
17
|
-
[
|
|
17
|
+
[0]: {
|
|
18
18
|
reporter: "SSR Error - App Prerender",
|
|
19
19
|
logger: "App Prerender",
|
|
20
20
|
metrics: "app.prerender.error"
|
|
21
21
|
},
|
|
22
|
-
[
|
|
22
|
+
[1]: {
|
|
23
23
|
reporter: "SSR Error - App run useLoader",
|
|
24
24
|
logger: "App run useLoader",
|
|
25
25
|
metrics: "app.useloader.error"
|
|
26
26
|
},
|
|
27
|
-
[
|
|
27
|
+
[2]: {
|
|
28
28
|
reporter: "SSR Error - App Render To HTML",
|
|
29
29
|
logger: "App Render To HTML",
|
|
30
30
|
metrics: "app.render.html.error"
|
|
31
31
|
},
|
|
32
|
-
[
|
|
32
|
+
[3]: {
|
|
33
33
|
reporter: "SSR Error - App Render To Streaming",
|
|
34
34
|
logger: "An error occurs during streaming SSR",
|
|
35
35
|
metrics: "app.render.streaming.error"
|
|
36
36
|
},
|
|
37
|
-
[
|
|
37
|
+
[4]: {
|
|
38
38
|
metrics: "app.render.streaming.shell.error"
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
const timings = {
|
|
42
|
-
[
|
|
42
|
+
[0]: {
|
|
43
43
|
reporter: "ssr-prerender",
|
|
44
44
|
serverTiming: "ssr-prerender",
|
|
45
45
|
metrics: "app.prerender.cost",
|
|
46
46
|
logger: "App Prerender cost = %d ms"
|
|
47
47
|
},
|
|
48
|
-
[
|
|
48
|
+
[1]: {
|
|
49
49
|
reporter: "ssr-render-html",
|
|
50
50
|
serverTiming: "ssr-render-html",
|
|
51
51
|
metrics: "app.render.html.cost",
|
|
52
52
|
logger: "App Render To HTML cost = %d ms"
|
|
53
53
|
},
|
|
54
|
-
[
|
|
54
|
+
[2]: {
|
|
55
55
|
reporter: "ssr-render-shell"
|
|
56
56
|
},
|
|
57
|
-
[
|
|
57
|
+
[3]: {
|
|
58
58
|
reporter: "use-loader",
|
|
59
59
|
serverTiming: "use-loader",
|
|
60
60
|
logger: "App run useLoader cost = %d ms"
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.41.0",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -170,11 +170,11 @@
|
|
|
170
170
|
"react-is": "^18",
|
|
171
171
|
"react-side-effect": "^2.1.1",
|
|
172
172
|
"styled-components": "^5.3.1",
|
|
173
|
-
"@swc/helpers": "0.5.
|
|
174
|
-
"@modern-js/plugin": "2.
|
|
175
|
-
"@modern-js/types": "2.
|
|
176
|
-
"@modern-js/utils": "2.
|
|
177
|
-
"@modern-js/runtime-utils": "2.
|
|
173
|
+
"@swc/helpers": "0.5.3",
|
|
174
|
+
"@modern-js/plugin": "2.41.0",
|
|
175
|
+
"@modern-js/types": "2.41.0",
|
|
176
|
+
"@modern-js/utils": "2.41.0",
|
|
177
|
+
"@modern-js/runtime-utils": "2.41.0"
|
|
178
178
|
},
|
|
179
179
|
"peerDependencies": {
|
|
180
180
|
"react": ">=17",
|
|
@@ -195,11 +195,11 @@
|
|
|
195
195
|
"ts-jest": "^29.1.0",
|
|
196
196
|
"typescript": "^5",
|
|
197
197
|
"webpack": "^5.88.1",
|
|
198
|
-
"@modern-js/
|
|
199
|
-
"@
|
|
200
|
-
"@modern-js/server-core": "2.
|
|
201
|
-
"@
|
|
202
|
-
"@scripts/jest-config": "2.
|
|
198
|
+
"@modern-js/core": "2.41.0",
|
|
199
|
+
"@scripts/build": "2.41.0",
|
|
200
|
+
"@modern-js/server-core": "2.41.0",
|
|
201
|
+
"@modern-js/app-tools": "2.41.0",
|
|
202
|
+
"@scripts/jest-config": "2.41.0"
|
|
203
203
|
},
|
|
204
204
|
"sideEffects": false,
|
|
205
205
|
"publishConfig": {
|