@modern-js/runtime 2.63.5 → 2.63.7-alpha.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.
@@ -176,8 +176,15 @@ const useRuntimeContext = () => {
176
176
  isBrowser: context.isBrowser,
177
177
  request: baseSSRContext.request || {},
178
178
  response: baseSSRContext.response || {},
179
- logger: baseSSRContext.logger || {}
180
- } : {};
179
+ logger: baseSSRContext.logger || {},
180
+ getInitData: () => {
181
+ return Object.freeze(context.initialData);
182
+ }
183
+ } : {
184
+ getInitData: () => {
185
+ return Object.freeze(context.initialData);
186
+ }
187
+ };
181
188
  const pickedContext = {
182
189
  ...context,
183
190
  context: tSSRContext,
@@ -109,10 +109,12 @@ const routerPlugin = (userConfig = {}) => {
109
109
  if (routerContext instanceof Response) {
110
110
  return interrupt(routerContext);
111
111
  }
112
- if (routerContext.statusCode >= 500 && routerContext.statusCode < 600 && // TODO: if loaderFailureMode is not 'errroBoundary', error log will not be printed.
113
- loaderFailureMode === "clientRender") {
112
+ const errors = Object.values(routerContext.errors || {});
113
+ if (
114
+ // TODO: if loaderFailureMode is not 'errroBoundary', error log will not be printed.
115
+ errors.length > 0 && loaderFailureMode === "clientRender"
116
+ ) {
114
117
  routerContext.statusCode = 200;
115
- const errors = Object.values(routerContext.errors);
116
118
  throw errors[0];
117
119
  }
118
120
  const router = (0, import_router.createStaticRouter)(routes, routerContext);
@@ -198,8 +198,15 @@ var useRuntimeContext = function() {
198
198
  isBrowser: context.isBrowser,
199
199
  request: baseSSRContext.request || {},
200
200
  response: baseSSRContext.response || {},
201
- logger: baseSSRContext.logger || {}
202
- } : {};
201
+ logger: baseSSRContext.logger || {},
202
+ getInitData: function() {
203
+ return Object.freeze(context.initialData);
204
+ }
205
+ } : {
206
+ getInitData: function() {
207
+ return Object.freeze(context.initialData);
208
+ }
209
+ };
203
210
  var pickedContext = _object_spread_props(_object_spread({}, context), {
204
211
  context: tSSRContext,
205
212
  request: (_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.request,
@@ -98,10 +98,12 @@ var routerPlugin = function() {
98
98
  interrupt(routerContext)
99
99
  ];
100
100
  }
101
- if (routerContext.statusCode >= 500 && routerContext.statusCode < 600 && // TODO: if loaderFailureMode is not 'errroBoundary', error log will not be printed.
102
- loaderFailureMode === "clientRender") {
101
+ errors = Object.values(routerContext.errors || {});
102
+ if (
103
+ // TODO: if loaderFailureMode is not 'errroBoundary', error log will not be printed.
104
+ errors.length > 0 && loaderFailureMode === "clientRender"
105
+ ) {
103
106
  routerContext.statusCode = 200;
104
- errors = Object.values(routerContext.errors);
105
107
  throw errors[0];
106
108
  }
107
109
  router = createStaticRouter(routes, routerContext);
@@ -141,8 +141,15 @@ const useRuntimeContext = () => {
141
141
  isBrowser: context.isBrowser,
142
142
  request: baseSSRContext.request || {},
143
143
  response: baseSSRContext.response || {},
144
- logger: baseSSRContext.logger || {}
145
- } : {};
144
+ logger: baseSSRContext.logger || {},
145
+ getInitData: () => {
146
+ return Object.freeze(context.initialData);
147
+ }
148
+ } : {
149
+ getInitData: () => {
150
+ return Object.freeze(context.initialData);
151
+ }
152
+ };
146
153
  const pickedContext = {
147
154
  ...context,
148
155
  context: tSSRContext,
@@ -75,10 +75,12 @@ const routerPlugin = (userConfig = {}) => {
75
75
  if (routerContext instanceof Response) {
76
76
  return interrupt(routerContext);
77
77
  }
78
- if (routerContext.statusCode >= 500 && routerContext.statusCode < 600 && // TODO: if loaderFailureMode is not 'errroBoundary', error log will not be printed.
79
- loaderFailureMode === "clientRender") {
78
+ const errors = Object.values(routerContext.errors || {});
79
+ if (
80
+ // TODO: if loaderFailureMode is not 'errroBoundary', error log will not be printed.
81
+ errors.length > 0 && loaderFailureMode === "clientRender"
82
+ ) {
80
83
  routerContext.statusCode = 200;
81
- const errors = Object.values(routerContext.errors);
82
84
  throw errors[0];
83
85
  }
84
86
  const router = createStaticRouter(routes, routerContext);
@@ -59,6 +59,7 @@ interface TSSRBaseContext {
59
59
  userAgent: string;
60
60
  cookie: string;
61
61
  };
62
+ getInitData: () => Readonly<Record<string, unknown> | undefined>;
62
63
  [propName: string]: any;
63
64
  }
64
65
  interface ServerContext extends TSSRBaseContext {
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.63.5",
18
+ "version": "2.63.7-alpha.0",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -200,12 +200,12 @@
200
200
  "react-is": "^18",
201
201
  "react-side-effect": "^2.1.1",
202
202
  "styled-components": "^5.3.1",
203
- "@modern-js/plugin": "2.63.5",
204
- "@modern-js/plugin-v2": "2.63.5",
205
- "@modern-js/runtime-utils": "2.63.5",
206
- "@modern-js/plugin-data-loader": "2.63.5",
207
- "@modern-js/types": "2.63.5",
208
- "@modern-js/utils": "2.63.5"
203
+ "@modern-js/plugin": "2.63.6",
204
+ "@modern-js/plugin-v2": "2.63.6",
205
+ "@modern-js/plugin-data-loader": "2.63.6",
206
+ "@modern-js/runtime-utils": "2.63.6",
207
+ "@modern-js/types": "2.63.6",
208
+ "@modern-js/utils": "2.63.6"
209
209
  },
210
210
  "peerDependencies": {
211
211
  "react": ">=17",
@@ -229,15 +229,14 @@
229
229
  "ts-node": "^10.9.1",
230
230
  "typescript": "^5",
231
231
  "webpack": "^5.97.1",
232
- "@modern-js/app-tools": "2.63.5",
233
- "@scripts/build": "2.63.5",
234
- "@scripts/jest-config": "2.63.5"
232
+ "@scripts/build": "2.63.6",
233
+ "@modern-js/app-tools": "2.63.6",
234
+ "@scripts/jest-config": "2.63.6"
235
235
  },
236
236
  "sideEffects": false,
237
237
  "publishConfig": {
238
238
  "registry": "https://registry.npmjs.org/",
239
- "access": "public",
240
- "provenance": true
239
+ "access": "public"
241
240
  },
242
241
  "scripts": {
243
242
  "dev": "modern-lib build --watch",