@bleedingdev/modern-js-server-core 3.9.0-ultramodern.11 → 3.9.0-ultramodern.13

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.
@@ -199,7 +199,7 @@ function createStaticMiddleware(options) {
199
199
  respondAsset: options.respondAsset,
200
200
  respondPublicFallback: options.respondPublicFallback
201
201
  })(c, next);
202
- {
202
+ else {
203
203
  const filepath = external_path_default().join(pwd, pathname.replace(pathPrefix, ()=>''));
204
204
  if (!isPathInside(filepath, pwd)) return next();
205
205
  if (!await utils_namespaceObject.fs.pathExists(filepath)) return next();
@@ -31,7 +31,7 @@ const LOADER_CONTEXT = 'loaderContext';
31
31
  function getLoaderCtx(c) {
32
32
  const loaderContext = c.get(LOADER_CONTEXT);
33
33
  if (loaderContext) return loaderContext;
34
- {
34
+ else {
35
35
  const loaderContext = new Map();
36
36
  c.set(LOADER_CONTEXT, loaderContext);
37
37
  return loaderContext;
@@ -87,8 +87,7 @@ var __webpack_exports__ = {};
87
87
  void 0,
88
88
  {}
89
89
  ];
90
- }
91
- {
90
+ } else {
92
91
  const result = matchedRoutes[0];
93
92
  if (!result) return [
94
93
  void 0,
@@ -243,7 +242,7 @@ var __webpack_exports__ = {};
243
242
  if (req.headers.get('x-rsc-action')) return 'rsc-action';
244
243
  if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
245
244
  if (!isSSR) return 'csr';
246
- {
245
+ else {
247
246
  if (query.__loader) return 'data';
248
247
  const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
249
248
  if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
@@ -272,7 +271,7 @@ var __webpack_exports__ = {};
272
271
  [external_constants_js_namespaceObject.X_MODERNJS_RENDER]: 'client'
273
272
  })
274
273
  });
275
- return (0, external_csrRscRender_js_namespaceObject.csrRscRender)(request, options);
274
+ else return (0, external_csrRscRender_js_namespaceObject.csrRscRender)(request, options);
276
275
  }
277
276
  })();
278
277
  exports.createRender = __webpack_exports__.createRender;
@@ -112,7 +112,7 @@ function computedKey(req, cacheControl) {
112
112
  const defaultKey = '/' === pathname ? pathname : removeTailSlash(pathname);
113
113
  if (customKey) if ('string' == typeof customKey) return customKey;
114
114
  else return customKey(defaultKey);
115
- {
115
+ else {
116
116
  const url = new URL(req.url);
117
117
  return `${url.origin}${defaultKey}${url.search}`;
118
118
  }
@@ -126,7 +126,7 @@ function shouldUseCache(request) {
126
126
  }
127
127
  function matchCacheControl(cacheOption, req) {
128
128
  if (!cacheOption || !req) return;
129
- {
129
+ else {
130
130
  if (isCacheControl(cacheOption)) return cacheOption;
131
131
  if (isCacheOptionProvider(cacheOption)) return cacheOption(req);
132
132
  const url = req.url;
@@ -167,7 +167,7 @@ async function getCacheResult(request, options) {
167
167
  container,
168
168
  cacheStatus: 'miss'
169
169
  });
170
- {
170
+ else {
171
171
  const cache = JSON.parse(value);
172
172
  const interval = Date.now() - cache.cursor;
173
173
  if (interval <= maxAge) {
@@ -178,17 +178,16 @@ async function getCacheResult(request, options) {
178
178
  [external_constants_js_namespaceObject.X_RENDER_CACHE]: cacheStatus
179
179
  }
180
180
  });
181
- }
182
- if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
183
- key,
184
- request,
185
- requestHandler,
186
- requestHandlerOptions,
187
- ttl,
188
- container,
189
- cacheStatus: 'expired'
190
- });
191
- {
181
+ } else {
182
+ if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
183
+ key,
184
+ request,
185
+ requestHandler,
186
+ requestHandlerOptions,
187
+ ttl,
188
+ container,
189
+ cacheStatus: 'expired'
190
+ });
192
191
  processCache({
193
192
  key,
194
193
  request,
@@ -179,7 +179,7 @@ function applyMiddlewares() {
179
179
  if (middleware.before) {
180
180
  const targetIndex = finalMiddlewares.findIndex((item)=>{
181
181
  if (middleware.before?.includes(item.name)) return true;
182
- return false;
182
+ else return false;
183
183
  });
184
184
  if (-1 !== targetIndex) finalMiddlewares.splice(targetIndex, 0, middleware);
185
185
  else finalMiddlewares.push(middleware);
@@ -200,7 +200,7 @@ function applyMiddlewares() {
200
200
  }
201
201
  function handler2Handlers(handler) {
202
202
  if (Array.isArray(handler)) return handler;
203
- return [
203
+ else return [
204
204
  handler
205
205
  ];
206
206
  }
@@ -43,7 +43,7 @@ function transformResponse(response, transformCb) {
43
43
  if (response.body) {
44
44
  const stream = createTransformStream(async (before)=>{
45
45
  if (Array.isArray(transformCb)) return transformCb.reduce(async (before, cb)=>cb(await before), Promise.resolve(before));
46
- return transformCb(before);
46
+ else return transformCb(before);
47
47
  });
48
48
  response.body.pipeThrough(stream);
49
49
  readable = stream.readable;
@@ -154,7 +154,7 @@ function createStaticMiddleware(options) {
154
154
  respondAsset: options.respondAsset,
155
155
  respondPublicFallback: options.respondPublicFallback
156
156
  })(c, next);
157
- {
157
+ else {
158
158
  const filepath = path.join(pwd, pathname.replace(pathPrefix, ()=>''));
159
159
  if (!isPathInside(filepath, pwd)) return next();
160
160
  if (!await fs.pathExists(filepath)) return next();
@@ -2,7 +2,7 @@ const LOADER_CONTEXT = 'loaderContext';
2
2
  function getLoaderCtx(c) {
3
3
  const loaderContext = c.get(LOADER_CONTEXT);
4
4
  if (loaderContext) return loaderContext;
5
- {
5
+ else {
6
6
  const loaderContext = new Map();
7
7
  c.set(LOADER_CONTEXT, loaderContext);
8
8
  return loaderContext;
@@ -7,12 +7,6 @@ import { dataHandler } from "./dataHandler.mjs";
7
7
  import { renderRscHandler } from "./renderRscHandler.mjs";
8
8
  import { serverActionHandler } from "./serverActionHandler.mjs";
9
9
  import { ssrRender } from "./ssrRender.mjs";
10
- import { __webpack_require__ } from "../../rslib-runtime~1.mjs";
11
- __webpack_require__.add({
12
- 718 (module) {
13
- module.exports = require("@modern-js/runtime-utils/router");
14
- }
15
- });
16
10
  const DYNAMIC_ROUTE_REG = /\/:./;
17
11
  function getRouter(routes) {
18
12
  const dynamicRoutes = [];
@@ -45,8 +39,7 @@ function matchRoute(router, pathname, entryName) {
45
39
  void 0,
46
40
  {}
47
41
  ];
48
- }
49
- {
42
+ } else {
50
43
  const result = matchedRoutes[0];
51
44
  if (!result) return [
52
45
  void 0,
@@ -163,7 +156,7 @@ async function renderHandler(request, options, mode, fallbackWrapper, framework)
163
156
  const { nestedRoutesJson } = serverManifest;
164
157
  const routes = nestedRoutesJson?.[options.routeInfo.entryName];
165
158
  if (routes) {
166
- const { matchRoutes } = __webpack_require__(718);
159
+ const { matchRoutes } = require("@modern-js/runtime-utils/router");
167
160
  const url = new URL(request.url);
168
161
  const matchedRoutes = matchRoutes(routes, url.pathname, options.routeInfo.urlPath);
169
162
  if (matchedRoutes) {
@@ -201,7 +194,7 @@ async function getRenderMode(req, fallbackHeader, isSSR, forceCSR, nodeReq, onFa
201
194
  if (req.headers.get('x-rsc-action')) return 'rsc-action';
202
195
  if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
203
196
  if (!isSSR) return 'csr';
204
- {
197
+ else {
205
198
  if (query.__loader) return 'data';
206
199
  const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
207
200
  if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
@@ -230,6 +223,6 @@ async function csrRender(request, options) {
230
223
  [X_MODERNJS_RENDER]: 'client'
231
224
  })
232
225
  });
233
- return csrRscRender(request, options);
226
+ else return csrRscRender(request, options);
234
227
  }
235
228
  export { createRender, matchRoute };
@@ -78,7 +78,7 @@ function computedKey(req, cacheControl) {
78
78
  const defaultKey = '/' === pathname ? pathname : removeTailSlash(pathname);
79
79
  if (customKey) if ('string' == typeof customKey) return customKey;
80
80
  else return customKey(defaultKey);
81
- {
81
+ else {
82
82
  const url = new URL(req.url);
83
83
  return `${url.origin}${defaultKey}${url.search}`;
84
84
  }
@@ -92,7 +92,7 @@ function shouldUseCache(request) {
92
92
  }
93
93
  function matchCacheControl(cacheOption, req) {
94
94
  if (!cacheOption || !req) return;
95
- {
95
+ else {
96
96
  if (isCacheControl(cacheOption)) return cacheOption;
97
97
  if (isCacheOptionProvider(cacheOption)) return cacheOption(req);
98
98
  const url = req.url;
@@ -133,7 +133,7 @@ async function getCacheResult(request, options) {
133
133
  container,
134
134
  cacheStatus: 'miss'
135
135
  });
136
- {
136
+ else {
137
137
  const cache = JSON.parse(value);
138
138
  const interval = Date.now() - cache.cursor;
139
139
  if (interval <= maxAge) {
@@ -144,17 +144,16 @@ async function getCacheResult(request, options) {
144
144
  [X_RENDER_CACHE]: cacheStatus
145
145
  }
146
146
  });
147
- }
148
- if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
149
- key,
150
- request,
151
- requestHandler,
152
- requestHandlerOptions,
153
- ttl,
154
- container,
155
- cacheStatus: 'expired'
156
- });
157
- {
147
+ } else {
148
+ if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
149
+ key,
150
+ request,
151
+ requestHandler,
152
+ requestHandlerOptions,
153
+ ttl,
154
+ container,
155
+ cacheStatus: 'expired'
156
+ });
158
157
  processCache({
159
158
  key,
160
159
  request,
@@ -146,7 +146,7 @@ function applyMiddlewares() {
146
146
  if (middleware.before) {
147
147
  const targetIndex = finalMiddlewares.findIndex((item)=>{
148
148
  if (middleware.before?.includes(item.name)) return true;
149
- return false;
149
+ else return false;
150
150
  });
151
151
  if (-1 !== targetIndex) finalMiddlewares.splice(targetIndex, 0, middleware);
152
152
  else finalMiddlewares.push(middleware);
@@ -167,7 +167,7 @@ function applyMiddlewares() {
167
167
  }
168
168
  function handler2Handlers(handler) {
169
169
  if (Array.isArray(handler)) return handler;
170
- return [
170
+ else return [
171
171
  handler
172
172
  ];
173
173
  }
@@ -14,7 +14,7 @@ function transformResponse(response, transformCb) {
14
14
  if (response.body) {
15
15
  const stream = createTransformStream(async (before)=>{
16
16
  if (Array.isArray(transformCb)) return transformCb.reduce(async (before, cb)=>cb(await before), Promise.resolve(before));
17
- return transformCb(before);
17
+ else return transformCb(before);
18
18
  });
19
19
  response.body.pipeThrough(stream);
20
20
  readable = stream.readable;
@@ -155,7 +155,7 @@ function createStaticMiddleware(options) {
155
155
  respondAsset: options.respondAsset,
156
156
  respondPublicFallback: options.respondPublicFallback
157
157
  })(c, next);
158
- {
158
+ else {
159
159
  const filepath = path.join(pwd, pathname.replace(pathPrefix, ()=>''));
160
160
  if (!isPathInside(filepath, pwd)) return next();
161
161
  if (!await fs.pathExists(filepath)) return next();
@@ -3,7 +3,7 @@ const LOADER_CONTEXT = 'loaderContext';
3
3
  function getLoaderCtx(c) {
4
4
  const loaderContext = c.get(LOADER_CONTEXT);
5
5
  if (loaderContext) return loaderContext;
6
- {
6
+ else {
7
7
  const loaderContext = new Map();
8
8
  c.set(LOADER_CONTEXT, loaderContext);
9
9
  return loaderContext;
@@ -8,14 +8,8 @@ import { dataHandler } from "./dataHandler.mjs";
8
8
  import { renderRscHandler } from "./renderRscHandler.mjs";
9
9
  import { serverActionHandler } from "./serverActionHandler.mjs";
10
10
  import { ssrRender } from "./ssrRender.mjs";
11
- import { __webpack_require__ } from "../../rslib-runtime~0.mjs";
12
11
  import { createRequire as __rspack_createRequire } from "node:module";
13
12
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
14
- __webpack_require__.add({
15
- "@modern-js/runtime-utils/router" (module) {
16
- module.exports = __rspack_createRequire_require("@modern-js/runtime-utils/router");
17
- }
18
- });
19
13
  const DYNAMIC_ROUTE_REG = /\/:./;
20
14
  function getRouter(routes) {
21
15
  const dynamicRoutes = [];
@@ -48,8 +42,7 @@ function matchRoute(router, pathname, entryName) {
48
42
  void 0,
49
43
  {}
50
44
  ];
51
- }
52
- {
45
+ } else {
53
46
  const result = matchedRoutes[0];
54
47
  if (!result) return [
55
48
  void 0,
@@ -166,7 +159,7 @@ async function renderHandler(request, options, mode, fallbackWrapper, framework)
166
159
  const { nestedRoutesJson } = serverManifest;
167
160
  const routes = nestedRoutesJson?.[options.routeInfo.entryName];
168
161
  if (routes) {
169
- const { matchRoutes } = __webpack_require__("@modern-js/runtime-utils/router");
162
+ const { matchRoutes } = __rspack_createRequire_require("@modern-js/runtime-utils/router");
170
163
  const url = new URL(request.url);
171
164
  const matchedRoutes = matchRoutes(routes, url.pathname, options.routeInfo.urlPath);
172
165
  if (matchedRoutes) {
@@ -204,7 +197,7 @@ async function getRenderMode(req, fallbackHeader, isSSR, forceCSR, nodeReq, onFa
204
197
  if (req.headers.get('x-rsc-action')) return 'rsc-action';
205
198
  if (req.headers.get('x-rsc-tree')) return 'rsc-tree';
206
199
  if (!isSSR) return 'csr';
207
- {
200
+ else {
208
201
  if (query.__loader) return 'data';
209
202
  const fallbackHeaderValue = req.headers.get(fallbackHeader) || nodeReq?.headers[fallbackHeader];
210
203
  if (forceCSR && (query.csr || fallbackHeaderValue || contextForceCSR)) {
@@ -233,6 +226,6 @@ async function csrRender(request, options) {
233
226
  [X_MODERNJS_RENDER]: 'client'
234
227
  })
235
228
  });
236
- return csrRscRender(request, options);
229
+ else return csrRscRender(request, options);
237
230
  }
238
231
  export { createRender, matchRoute };
@@ -79,7 +79,7 @@ function computedKey(req, cacheControl) {
79
79
  const defaultKey = '/' === pathname ? pathname : removeTailSlash(pathname);
80
80
  if (customKey) if ('string' == typeof customKey) return customKey;
81
81
  else return customKey(defaultKey);
82
- {
82
+ else {
83
83
  const url = new URL(req.url);
84
84
  return `${url.origin}${defaultKey}${url.search}`;
85
85
  }
@@ -93,7 +93,7 @@ function shouldUseCache(request) {
93
93
  }
94
94
  function matchCacheControl(cacheOption, req) {
95
95
  if (!cacheOption || !req) return;
96
- {
96
+ else {
97
97
  if (isCacheControl(cacheOption)) return cacheOption;
98
98
  if (isCacheOptionProvider(cacheOption)) return cacheOption(req);
99
99
  const url = req.url;
@@ -134,7 +134,7 @@ async function getCacheResult(request, options) {
134
134
  container,
135
135
  cacheStatus: 'miss'
136
136
  });
137
- {
137
+ else {
138
138
  const cache = JSON.parse(value);
139
139
  const interval = Date.now() - cache.cursor;
140
140
  if (interval <= maxAge) {
@@ -145,17 +145,16 @@ async function getCacheResult(request, options) {
145
145
  [X_RENDER_CACHE]: cacheStatus
146
146
  }
147
147
  });
148
- }
149
- if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
150
- key,
151
- request,
152
- requestHandler,
153
- requestHandlerOptions,
154
- ttl,
155
- container,
156
- cacheStatus: 'expired'
157
- });
158
- {
148
+ } else {
149
+ if (!(interval <= staleWhileRevalidate + maxAge)) return processCache({
150
+ key,
151
+ request,
152
+ requestHandler,
153
+ requestHandlerOptions,
154
+ ttl,
155
+ container,
156
+ cacheStatus: 'expired'
157
+ });
159
158
  processCache({
160
159
  key,
161
160
  request,
@@ -147,7 +147,7 @@ function applyMiddlewares() {
147
147
  if (middleware.before) {
148
148
  const targetIndex = finalMiddlewares.findIndex((item)=>{
149
149
  if (middleware.before?.includes(item.name)) return true;
150
- return false;
150
+ else return false;
151
151
  });
152
152
  if (-1 !== targetIndex) finalMiddlewares.splice(targetIndex, 0, middleware);
153
153
  else finalMiddlewares.push(middleware);
@@ -168,7 +168,7 @@ function applyMiddlewares() {
168
168
  }
169
169
  function handler2Handlers(handler) {
170
170
  if (Array.isArray(handler)) return handler;
171
- return [
171
+ else return [
172
172
  handler
173
173
  ];
174
174
  }
@@ -15,7 +15,7 @@ function transformResponse(response, transformCb) {
15
15
  if (response.body) {
16
16
  const stream = createTransformStream(async (before)=>{
17
17
  if (Array.isArray(transformCb)) return transformCb.reduce(async (before, cb)=>cb(await before), Promise.resolve(before));
18
- return transformCb(before);
18
+ else return transformCb(before);
19
19
  });
20
20
  response.body.pipeThrough(stream);
21
21
  readable = stream.readable;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.11",
20
+ "version": "3.9.0-ultramodern.13",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -66,25 +66,25 @@
66
66
  "node": ">=20"
67
67
  },
68
68
  "dependencies": {
69
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.11",
70
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.11",
71
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.11",
69
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.13",
70
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.13",
71
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.13",
72
72
  "@swc/helpers": "^0.5.23",
73
73
  "@web-std/fetch": "^4.2.1",
74
74
  "@web-std/file": "^3.0.3",
75
75
  "@web-std/stream": "^1.0.3",
76
76
  "cloneable-readable": "^3.0.0",
77
77
  "flatted": "^3.4.4",
78
- "hono": "^4.13.7",
78
+ "hono": "^4.13.8",
79
79
  "ts-deepmerge": "8.0.0"
80
80
  },
81
81
  "devDependencies": {
82
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.11",
83
- "@rslib/core": "1.0.0",
82
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.13",
83
+ "@rslib/core": "1.0.2",
84
84
  "@scripts/rstest-config": "2.66.0",
85
85
  "@types/cloneable-readable": "^2.0.3",
86
86
  "@types/merge-deep": "^3.0.3",
87
- "@types/node": "^26.4.1",
87
+ "@types/node": "^26.6.2",
88
88
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
89
89
  "http-proxy-middleware": "^4.2.0",
90
90
  "typescript": "^7.0.2"
@@ -1,18 +0,0 @@
1
- var __webpack_modules__ = {};
2
- var __webpack_module_cache__ = {};
3
- function __webpack_require__(moduleId) {
4
- var cachedModule = __webpack_module_cache__[moduleId];
5
- if (void 0 !== cachedModule) return cachedModule.exports;
6
- var module = __webpack_module_cache__[moduleId] = {
7
- exports: {}
8
- };
9
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
10
- return module.exports;
11
- }
12
- __webpack_require__.m = __webpack_modules__;
13
- (()=>{
14
- __webpack_require__.add = function(modules) {
15
- Object.assign(__webpack_require__.m, modules);
16
- };
17
- })();
18
- export { __webpack_require__ };
@@ -1,19 +0,0 @@
1
- import "node:module";
2
- var __webpack_modules__ = {};
3
- var __webpack_module_cache__ = {};
4
- function __webpack_require__(moduleId) {
5
- var cachedModule = __webpack_module_cache__[moduleId];
6
- if (void 0 !== cachedModule) return cachedModule.exports;
7
- var module = __webpack_module_cache__[moduleId] = {
8
- exports: {}
9
- };
10
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
11
- return module.exports;
12
- }
13
- __webpack_require__.m = __webpack_modules__;
14
- (()=>{
15
- __webpack_require__.add = function(modules) {
16
- Object.assign(__webpack_require__.m, modules);
17
- };
18
- })();
19
- export { __webpack_require__ };