@modern-js/runtime 2.9.0 → 2.10.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/CHANGELOG.md +21 -0
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +1 -1
- package/dist/cjs/ssr/serverRender/renderToStream/buildTemplate.after.js +8 -1
- package/dist/cjs/ssr/serverRender/renderToStream/template.js +2 -3
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +1 -1
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +5 -1
- package/dist/esm/ssr/serverRender/renderToStream/template.js +2 -3
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +1 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/buildTemplate.after.js +8 -1
- package/dist/esm-node/ssr/serverRender/renderToStream/template.js +2 -3
- package/dist/types/ssr/serverRender/renderToStream/buildTemplate.after.d.ts +2 -4
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @modern-js/runtime
|
|
2
2
|
|
|
3
|
+
## 2.10.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0da32d0: chore: upgrade jest and puppeteer
|
|
8
|
+
chore: 升级 jest 和 puppeteer 到 latest
|
|
9
|
+
- 5766414: fix: fix typos
|
|
10
|
+
fix: 修复拼写错误
|
|
11
|
+
- 950e138: fix: inject i18n placeholder in streaming ssr
|
|
12
|
+
fix: 流式 SSR 中,注入 i18n 数据占位字段
|
|
13
|
+
- Updated dependencies [3e0bd50]
|
|
14
|
+
- Updated dependencies [92d247f]
|
|
15
|
+
- Updated dependencies [0da32d0]
|
|
16
|
+
- Updated dependencies [0d9962b]
|
|
17
|
+
- Updated dependencies [fbefa7e]
|
|
18
|
+
- Updated dependencies [4d54233]
|
|
19
|
+
- Updated dependencies [6db4864]
|
|
20
|
+
- @modern-js/types@2.10.0
|
|
21
|
+
- @modern-js/plugin@2.10.0
|
|
22
|
+
- @modern-js/utils@2.10.0
|
|
23
|
+
|
|
3
24
|
## 2.9.0
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -28,7 +28,7 @@ var import_common = require("../../common");
|
|
|
28
28
|
var import_utils = require("./utils");
|
|
29
29
|
const setupFnStr = `function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};`;
|
|
30
30
|
const resolveFnStr = `function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};`;
|
|
31
|
-
const preResolvedFnStr = `function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.
|
|
31
|
+
const preResolvedFnStr = `function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.resolve(e)};`;
|
|
32
32
|
const DeferredDataScripts = () => {
|
|
33
33
|
const context = (0, import_react.useContext)(import_react_router_dom.UNSAFE_DataRouterContext);
|
|
34
34
|
const { staticContext } = context || {};
|
|
@@ -29,12 +29,19 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
|
29
29
|
const ssrDataScript = buildSSRDataScript();
|
|
30
30
|
return template.replace("<!--<?- SSRDataScript ?>-->", ssrDataScript);
|
|
31
31
|
function buildSSRDataScript() {
|
|
32
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
context: { ssrContext, initialData, __i18nData__ },
|
|
34
|
+
renderLevel
|
|
35
|
+
} = options;
|
|
33
36
|
const { request, enableUnsafeCtx } = ssrContext;
|
|
34
37
|
const unsafeContext = {
|
|
35
38
|
headers: request.headers
|
|
36
39
|
};
|
|
37
40
|
const SSRData = {
|
|
41
|
+
data: {
|
|
42
|
+
initialData,
|
|
43
|
+
i18nData: __i18nData__
|
|
44
|
+
},
|
|
38
45
|
context: {
|
|
39
46
|
request: {
|
|
40
47
|
params: request.params,
|
|
@@ -24,15 +24,14 @@ var import_buildTemplate = require("./buildTemplate.after");
|
|
|
24
24
|
var import_bulidTemplate = require("./bulidTemplate.before");
|
|
25
25
|
const HTML_SEPARATOR = "<!--<?- html ?>-->";
|
|
26
26
|
const getTemplates = (context, renderLevel) => {
|
|
27
|
-
const { ssrContext
|
|
27
|
+
const { ssrContext } = context;
|
|
28
28
|
const [beforeAppTemplate = "", afterAppHtmlTemplate = ""] = ssrContext.template.split(HTML_SEPARATOR) || [];
|
|
29
29
|
const builtBeforeTemplate = (0, import_bulidTemplate.buildShellBeforeTemplate)(
|
|
30
30
|
beforeAppTemplate,
|
|
31
31
|
context
|
|
32
32
|
);
|
|
33
33
|
const builtAfterTemplate = (0, import_buildTemplate.buildShellAfterTemplate)(afterAppHtmlTemplate, {
|
|
34
|
-
|
|
35
|
-
routerContext,
|
|
34
|
+
context,
|
|
36
35
|
renderLevel
|
|
37
36
|
});
|
|
38
37
|
return {
|
|
@@ -52,7 +52,7 @@ import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
|
52
52
|
import { serializeErrors } from "./utils";
|
|
53
53
|
var setupFnStr = "function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};";
|
|
54
54
|
var resolveFnStr = "function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};";
|
|
55
|
-
var preResolvedFnStr = "function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.
|
|
55
|
+
var preResolvedFnStr = "function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.resolve(e)};";
|
|
56
56
|
var DeferredDataScripts = function() {
|
|
57
57
|
var context = useContext(DataRouterContext);
|
|
58
58
|
var staticContext = (context || {}).staticContext;
|
|
@@ -33,12 +33,16 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
|
33
33
|
var ssrDataScript = buildSSRDataScript();
|
|
34
34
|
return template.replace("<!--<?- SSRDataScript ?>-->", ssrDataScript);
|
|
35
35
|
function buildSSRDataScript() {
|
|
36
|
-
var
|
|
36
|
+
var _options_context = options.context, ssrContext = _options_context.ssrContext, initialData = _options_context.initialData, __i18nData__ = _options_context.__i18nData__, renderLevel = options.renderLevel;
|
|
37
37
|
var request = ssrContext.request, enableUnsafeCtx = ssrContext.enableUnsafeCtx;
|
|
38
38
|
var unsafeContext = {
|
|
39
39
|
headers: request.headers
|
|
40
40
|
};
|
|
41
41
|
var SSRData = {
|
|
42
|
+
data: {
|
|
43
|
+
initialData: initialData,
|
|
44
|
+
i18nData: __i18nData__
|
|
45
|
+
},
|
|
42
46
|
context: {
|
|
43
47
|
request: _objectSpread({
|
|
44
48
|
params: request.params,
|
|
@@ -48,12 +48,11 @@ import { buildShellAfterTemplate } from "./buildTemplate.after";
|
|
|
48
48
|
import { buildShellBeforeTemplate } from "./bulidTemplate.before";
|
|
49
49
|
var HTML_SEPARATOR = "<!--<?- html ?>-->";
|
|
50
50
|
var getTemplates = function(context, renderLevel) {
|
|
51
|
-
var ssrContext = context.ssrContext
|
|
51
|
+
var ssrContext = context.ssrContext;
|
|
52
52
|
var _ref = _slicedToArray(ssrContext.template.split(HTML_SEPARATOR) || [], 2), tmp = _ref[0], beforeAppTemplate = tmp === void 0 ? "" : tmp, tmp1 = _ref[1], afterAppHtmlTemplate = tmp1 === void 0 ? "" : tmp1;
|
|
53
53
|
var builtBeforeTemplate = buildShellBeforeTemplate(beforeAppTemplate, context);
|
|
54
54
|
var builtAfterTemplate = buildShellAfterTemplate(afterAppHtmlTemplate, {
|
|
55
|
-
|
|
56
|
-
routerContext: routerContext,
|
|
55
|
+
context: context,
|
|
57
56
|
renderLevel: renderLevel
|
|
58
57
|
});
|
|
59
58
|
return {
|
|
@@ -10,7 +10,7 @@ import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
|
10
10
|
import { serializeErrors } from "./utils";
|
|
11
11
|
const setupFnStr = `function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};`;
|
|
12
12
|
const resolveFnStr = `function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};`;
|
|
13
|
-
const preResolvedFnStr = `function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.
|
|
13
|
+
const preResolvedFnStr = `function p(e,r){return void 0!==r?Promise.reject(new Error(r.message)):Promise.resolve(e)};`;
|
|
14
14
|
const DeferredDataScripts = () => {
|
|
15
15
|
const context = useContext(DataRouterContext);
|
|
16
16
|
const { staticContext } = context || {};
|
|
@@ -7,12 +7,19 @@ function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
|
7
7
|
const ssrDataScript = buildSSRDataScript();
|
|
8
8
|
return template.replace("<!--<?- SSRDataScript ?>-->", ssrDataScript);
|
|
9
9
|
function buildSSRDataScript() {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
context: { ssrContext, initialData, __i18nData__ },
|
|
12
|
+
renderLevel
|
|
13
|
+
} = options;
|
|
11
14
|
const { request, enableUnsafeCtx } = ssrContext;
|
|
12
15
|
const unsafeContext = {
|
|
13
16
|
headers: request.headers
|
|
14
17
|
};
|
|
15
18
|
const SSRData = {
|
|
19
|
+
data: {
|
|
20
|
+
initialData,
|
|
21
|
+
i18nData: __i18nData__
|
|
22
|
+
},
|
|
16
23
|
context: {
|
|
17
24
|
request: {
|
|
18
25
|
params: request.params,
|
|
@@ -2,15 +2,14 @@ import { buildShellAfterTemplate } from "./buildTemplate.after";
|
|
|
2
2
|
import { buildShellBeforeTemplate } from "./bulidTemplate.before";
|
|
3
3
|
const HTML_SEPARATOR = "<!--<?- html ?>-->";
|
|
4
4
|
const getTemplates = (context, renderLevel) => {
|
|
5
|
-
const { ssrContext
|
|
5
|
+
const { ssrContext } = context;
|
|
6
6
|
const [beforeAppTemplate = "", afterAppHtmlTemplate = ""] = ssrContext.template.split(HTML_SEPARATOR) || [];
|
|
7
7
|
const builtBeforeTemplate = buildShellBeforeTemplate(
|
|
8
8
|
beforeAppTemplate,
|
|
9
9
|
context
|
|
10
10
|
);
|
|
11
11
|
const builtAfterTemplate = buildShellAfterTemplate(afterAppHtmlTemplate, {
|
|
12
|
-
|
|
13
|
-
routerContext,
|
|
12
|
+
context,
|
|
14
13
|
renderLevel
|
|
15
14
|
});
|
|
16
15
|
return {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RenderLevel, SSRServerContext } from '../types';
|
|
1
|
+
import { RenderLevel, RuntimeContext } from '../types';
|
|
3
2
|
type BuildShellAfterTemplateOptions = {
|
|
4
|
-
|
|
5
|
-
routerContext: StaticHandlerContext;
|
|
3
|
+
context: RuntimeContext;
|
|
6
4
|
renderLevel: RenderLevel;
|
|
7
5
|
};
|
|
8
6
|
export declare function buildShellAfterTemplate(afterAppTemplate: string, options: BuildShellAfterTemplateOptions): string;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.
|
|
14
|
+
"version": "2.10.0",
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">=14.17.6"
|
|
17
17
|
},
|
|
@@ -158,9 +158,9 @@
|
|
|
158
158
|
"react-side-effect": "^2.1.1",
|
|
159
159
|
"redux-logger": "^3.0.6",
|
|
160
160
|
"styled-components": "^5.3.1",
|
|
161
|
-
"@modern-js/plugin": "2.
|
|
162
|
-
"@modern-js/
|
|
163
|
-
"@modern-js/
|
|
161
|
+
"@modern-js/plugin": "2.10.0",
|
|
162
|
+
"@modern-js/types": "2.10.0",
|
|
163
|
+
"@modern-js/utils": "2.10.0"
|
|
164
164
|
},
|
|
165
165
|
"peerDependencies": {
|
|
166
166
|
"react": ">=17",
|
|
@@ -172,20 +172,20 @@
|
|
|
172
172
|
"@testing-library/react": "^13.4.0",
|
|
173
173
|
"@testing-library/react-hooks": "^8.0.1",
|
|
174
174
|
"@types/invariant": "^2.2.30",
|
|
175
|
-
"@types/jest": "^
|
|
175
|
+
"@types/jest": "^29",
|
|
176
176
|
"@types/loadable__webpack-plugin": "^5.7.3",
|
|
177
177
|
"@types/node": "^14",
|
|
178
178
|
"@types/react-side-effect": "^1.1.1",
|
|
179
|
-
"jest": "^
|
|
179
|
+
"jest": "^29",
|
|
180
180
|
"react": "^18",
|
|
181
181
|
"react-dom": "^18",
|
|
182
|
-
"ts-jest": "^
|
|
182
|
+
"ts-jest": "^29.0.5",
|
|
183
183
|
"typescript": "^4",
|
|
184
|
-
"@modern-js/app-tools": "2.
|
|
185
|
-
"@modern-js/core": "2.
|
|
186
|
-
"@modern-js/server-core": "2.
|
|
187
|
-
"@scripts/
|
|
188
|
-
"@scripts/
|
|
184
|
+
"@modern-js/app-tools": "2.10.0",
|
|
185
|
+
"@modern-js/core": "2.10.0",
|
|
186
|
+
"@modern-js/server-core": "2.10.0",
|
|
187
|
+
"@scripts/build": "2.10.0",
|
|
188
|
+
"@scripts/jest-config": "2.10.0"
|
|
189
189
|
},
|
|
190
190
|
"sideEffects": false,
|
|
191
191
|
"modernConfig": {},
|