@bleedingdev/modern-js-runtime 3.9.0-ultramodern.10 → 3.9.0-ultramodern.12

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.
@@ -101,7 +101,6 @@ const routerPlugin = (userConfig = {})=>({
101
101
  const match = serverBase.find((baseUrl)=>isSegmentPrefix(pathname, baseUrl));
102
102
  return match || '/';
103
103
  };
104
- let cachedRouter = null;
105
104
  const RouterWrapper = (props)=>{
106
105
  const routerResult = useRouterCreation(("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === (0, index_js_namespaceObject.getGlobalEnableRsc)()) ? {
107
106
  ...props,
@@ -113,12 +112,7 @@ const routerPlugin = (userConfig = {})=>({
113
112
  selectBasePath,
114
113
  basename
115
114
  });
116
- const router = (0, external_react_namespaceObject.useMemo)(()=>{
117
- if (cachedRouter) return cachedRouter;
118
- cachedRouter = routerResult.router;
119
- return cachedRouter;
120
- }, []);
121
- const { routes } = routerResult;
115
+ const { router, routes } = routerResult;
122
116
  routesContainer.current = routes;
123
117
  beforeCreateRouter = false;
124
118
  const routerContent = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
@@ -162,7 +156,8 @@ function useRouterCreation(props, options) {
162
156
  const { unstable_getBlockNavState: getBlockNavState } = runtimeContext;
163
157
  const rscPayload = ("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === (0, index_js_namespaceObject.getGlobalEnableRsc)()) && props?.rscPayload ? safeUse(props.rscPayload) : null;
164
158
  let hydrationData = "u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA : true === (0, index_js_namespaceObject.getGlobalEnableRsc)() ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA;
165
- return (0, external_react_namespaceObject.useMemo)(()=>{
159
+ const result = (0, external_react_namespaceObject.useRef)(null);
160
+ if (null === result.current) {
166
161
  if (hydrationData?.errors) hydrationData = {
167
162
  ...hydrationData,
168
163
  errors: (0, external_utils_js_namespaceObject.deserializeErrors)(hydrationData.errors)
@@ -178,10 +173,11 @@ function useRouterCreation(props, options) {
178
173
  const hooks = api.getHooks();
179
174
  if (("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === (0, index_js_namespaceObject.getGlobalEnableRsc)()) && rscPayload) try {
180
175
  const router = (0, external_rsc_router_js_namespaceObject.createClientRouterFromPayload)(rscPayload, routes, _basename);
181
- return {
176
+ result.current = {
182
177
  router,
183
178
  routes: router.routes || []
184
179
  };
180
+ return result.current;
185
181
  } catch (e) {
186
182
  console.error('Failed to create router from RSC payload:', e);
187
183
  }
@@ -230,17 +226,12 @@ function useRouterCreation(props, options) {
230
226
  };
231
227
  return originSubscribe(wrappedListener);
232
228
  };
233
- return {
229
+ result.current = {
234
230
  router,
235
231
  routes: modifiedRoutes
236
232
  };
237
- }, [
238
- finalRouteConfig,
239
- props,
240
- _basename,
241
- hydrationData,
242
- getBlockNavState
243
- ]);
233
+ }
234
+ return result.current;
244
235
  }
245
236
  exports.beforeCreateRouter = __webpack_exports__.beforeCreateRouter;
246
237
  exports.finalRouteConfig = __webpack_exports__.finalRouteConfig;
@@ -66,7 +66,6 @@ const routerPlugin = (userConfig = {})=>({
66
66
  const match = serverBase.find((baseUrl)=>isSegmentPrefix(pathname, baseUrl));
67
67
  return match || '/';
68
68
  };
69
- let cachedRouter = null;
70
69
  const RouterWrapper = (props)=>{
71
70
  const routerResult = useRouterCreation(("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) ? {
72
71
  ...props,
@@ -78,12 +77,7 @@ const routerPlugin = (userConfig = {})=>({
78
77
  selectBasePath,
79
78
  basename
80
79
  });
81
- const router = (0, __rspack_external_react.useMemo)(()=>{
82
- if (cachedRouter) return cachedRouter;
83
- cachedRouter = routerResult.router;
84
- return cachedRouter;
85
- }, []);
86
- const { routes } = routerResult;
80
+ const { router, routes } = routerResult;
87
81
  routesContainer.current = routes;
88
82
  beforeCreateRouter = false;
89
83
  const routerContent = /*#__PURE__*/ jsxs(Fragment, {
@@ -127,7 +121,8 @@ function useRouterCreation(props, options) {
127
121
  const { unstable_getBlockNavState: getBlockNavState } = runtimeContext;
128
122
  const rscPayload = ("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) && props?.rscPayload ? safeUse(props.rscPayload) : null;
129
123
  let hydrationData = "u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA : true === getGlobalEnableRsc() ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA;
130
- return (0, __rspack_external_react.useMemo)(()=>{
124
+ const result = (0, __rspack_external_react.useRef)(null);
125
+ if (null === result.current) {
131
126
  if (hydrationData?.errors) hydrationData = {
132
127
  ...hydrationData,
133
128
  errors: deserializeErrors(hydrationData.errors)
@@ -143,10 +138,11 @@ function useRouterCreation(props, options) {
143
138
  const hooks = api.getHooks();
144
139
  if (("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) && rscPayload) try {
145
140
  const router = createClientRouterFromPayload(rscPayload, routes, _basename);
146
- return {
141
+ result.current = {
147
142
  router,
148
143
  routes: router.routes || []
149
144
  };
145
+ return result.current;
150
146
  } catch (e) {
151
147
  console.error('Failed to create router from RSC payload:', e);
152
148
  }
@@ -195,16 +191,11 @@ function useRouterCreation(props, options) {
195
191
  };
196
192
  return originSubscribe(wrappedListener);
197
193
  };
198
- return {
194
+ result.current = {
199
195
  router,
200
196
  routes: modifiedRoutes
201
197
  };
202
- }, [
203
- finalRouteConfig,
204
- props,
205
- _basename,
206
- hydrationData,
207
- getBlockNavState
208
- ]);
198
+ }
199
+ return result.current;
209
200
  }
210
201
  export { beforeCreateRouter, finalRouteConfig, modifyRoutes, routerPlugin };
@@ -67,7 +67,6 @@ const routerPlugin = (userConfig = {})=>({
67
67
  const match = serverBase.find((baseUrl)=>isSegmentPrefix(pathname, baseUrl));
68
68
  return match || '/';
69
69
  };
70
- let cachedRouter = null;
71
70
  const RouterWrapper = (props)=>{
72
71
  const routerResult = useRouterCreation(("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) ? {
73
72
  ...props,
@@ -79,12 +78,7 @@ const routerPlugin = (userConfig = {})=>({
79
78
  selectBasePath,
80
79
  basename
81
80
  });
82
- const router = (0, __rspack_external_react.useMemo)(()=>{
83
- if (cachedRouter) return cachedRouter;
84
- cachedRouter = routerResult.router;
85
- return cachedRouter;
86
- }, []);
87
- const { routes } = routerResult;
81
+ const { router, routes } = routerResult;
88
82
  routesContainer.current = routes;
89
83
  beforeCreateRouter = false;
90
84
  const routerContent = /*#__PURE__*/ jsxs(Fragment, {
@@ -128,7 +122,8 @@ function useRouterCreation(props, options) {
128
122
  const { unstable_getBlockNavState: getBlockNavState } = runtimeContext;
129
123
  const rscPayload = ("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) && props?.rscPayload ? safeUse(props.rscPayload) : null;
130
124
  let hydrationData = "u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA : true === getGlobalEnableRsc() ? window._ROUTER_DATA || rscPayload : window._ROUTER_DATA;
131
- return (0, __rspack_external_react.useMemo)(()=>{
125
+ const result = (0, __rspack_external_react.useRef)(null);
126
+ if (null === result.current) {
132
127
  if (hydrationData?.errors) hydrationData = {
133
128
  ...hydrationData,
134
129
  errors: deserializeErrors(hydrationData.errors)
@@ -144,10 +139,11 @@ function useRouterCreation(props, options) {
144
139
  const hooks = api.getHooks();
145
140
  if (("u" > typeof __MODERN_ENABLE_RSC__ ? __MODERN_ENABLE_RSC__ : true === getGlobalEnableRsc()) && rscPayload) try {
146
141
  const router = createClientRouterFromPayload(rscPayload, routes, _basename);
147
- return {
142
+ result.current = {
148
143
  router,
149
144
  routes: router.routes || []
150
145
  };
146
+ return result.current;
151
147
  } catch (e) {
152
148
  console.error('Failed to create router from RSC payload:', e);
153
149
  }
@@ -196,16 +192,11 @@ function useRouterCreation(props, options) {
196
192
  };
197
193
  return originSubscribe(wrappedListener);
198
194
  };
199
- return {
195
+ result.current = {
200
196
  router,
201
197
  routes: modifiedRoutes
202
198
  };
203
- }, [
204
- finalRouteConfig,
205
- props,
206
- _basename,
207
- hydrationData,
208
- getBlockNavState
209
- ]);
199
+ }
200
+ return result.current;
210
201
  }
211
202
  export { beforeCreateRouter, finalRouteConfig, modifyRoutes, routerPlugin };
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.10",
20
+ "version": "3.9.0-ultramodern.12",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -217,14 +217,14 @@
217
217
  "dependencies": {
218
218
  "@loadable/component": "5.16.7",
219
219
  "@loadable/server": "5.16.7",
220
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.10",
221
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.10",
222
- "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.0-ultramodern.10",
223
- "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.10",
224
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.10",
225
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.10",
226
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.10",
227
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.10",
220
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.12",
221
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.12",
222
+ "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.0-ultramodern.12",
223
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.12",
224
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.12",
225
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.12",
226
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.12",
227
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.12",
228
228
  "@swc/core": "1.16.2",
229
229
  "@swc/helpers": "^0.5.23",
230
230
  "@swc/plugin-loadable-components": "^13.0.0",
@@ -245,7 +245,7 @@
245
245
  "react-dom": "^19.2.8"
246
246
  },
247
247
  "devDependencies": {
248
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.10",
248
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.12",
249
249
  "@remix-run/web-fetch": "^4.4.2",
250
250
  "@rsbuild/core": "2.2.3",
251
251
  "@rslib/core": "1.0.0",