@modern-js/server-core 2.59.0 → 2.60.1

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.
@@ -56,7 +56,7 @@ const createWebRequest = (req, res, body) => {
56
56
  headers: headerRecord,
57
57
  signal: controller.signal
58
58
  };
59
- res.on("close", () => controller.abort());
59
+ res.on("close", () => controller.abort("res closed"));
60
60
  if (body || !(method === "GET" || method === "HEAD") && ((_req_url = req.url) === null || _req_url === void 0 ? void 0 : _req_url.includes("__loader"))) {
61
61
  init.body = body !== null && body !== void 0 ? body : (0, import_stream.createReadableStreamFromReadable)(req);
62
62
  init.duplex = "half";
@@ -25,6 +25,7 @@ module.exports = __toCommonJS(ssrCache_exports);
25
25
  var import_storer = require("@modern-js/runtime-utils/storer");
26
26
  var import_constants = require("../../constants");
27
27
  var import_utils = require("../../utils");
28
+ const ZERO_RENDER_LEVEL = /"renderLevel":0/;
28
29
  async function processCache({ request, key, requestHandler, requestHandlerOptions, ttl, container, cacheStatus }) {
29
30
  const response = await requestHandler(request, requestHandlerOptions);
30
31
  const decoder = new TextDecoder();
@@ -35,6 +36,11 @@ async function processCache({ request, key, requestHandler, requestHandlerOption
35
36
  let html = "";
36
37
  const push = () => reader.read().then(({ done, value }) => {
37
38
  if (done) {
39
+ const match = ZERO_RENDER_LEVEL.test(html);
40
+ if (match) {
41
+ writer.close();
42
+ return;
43
+ }
38
44
  const current = Date.now();
39
45
  const cache = {
40
46
  val: html,
@@ -25,7 +25,7 @@ var createWebRequest = function(req, res, body) {
25
25
  signal: controller.signal
26
26
  };
27
27
  res.on("close", function() {
28
- return controller.abort();
28
+ return controller.abort("res closed");
29
29
  });
30
30
  if (body || !(method === "GET" || method === "HEAD") && ((_req_url = req.url) === null || _req_url === void 0 ? void 0 : _req_url.includes("__loader"))) {
31
31
  init.body = body !== null && body !== void 0 ? body : createReadableStreamFromReadable(req);
@@ -1,6 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
+ import { _ as _type_of } from "@swc/helpers/_/_type_of";
4
5
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
6
  import { createRender } from "./render";
6
7
  var injectRenderHandlerPlugin = function(param) {
@@ -87,7 +88,7 @@ function _getRenderHandler() {
87
88
  return _ts_generator(this, function(_state) {
88
89
  pwd = param.pwd, routes = param.routes, config = param.config, cacheConfig = param.cacheConfig, metaName = param.metaName, staticGenerate = param.staticGenerate, onFallback = param.onFallback;
89
90
  ssrConfig = (_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.ssr;
90
- forceCSR = typeof ssrConfig === "object" ? ssrConfig.forceCSR : false;
91
+ forceCSR = (typeof ssrConfig === "undefined" ? "undefined" : _type_of(ssrConfig)) === "object" ? ssrConfig.forceCSR : false;
91
92
  render = createRender({
92
93
  routes,
93
94
  pwd,
@@ -1,10 +1,12 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
3
3
  import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
4
+ import { _ as _type_of } from "@swc/helpers/_/_type_of";
4
5
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
6
  import { createMemoryStorage } from "@modern-js/runtime-utils/storer";
6
7
  import { X_RENDER_CACHE } from "../../constants";
7
8
  import { createTransformStream, getPathname } from "../../utils";
9
+ var ZERO_RENDER_LEVEL = /"renderLevel":0/;
8
10
  function processCache(_) {
9
11
  return _processCache.apply(this, arguments);
10
12
  }
@@ -31,6 +33,11 @@ function _processCache() {
31
33
  return reader.read().then(function(param2) {
32
34
  var done = param2.done, value = param2.value;
33
35
  if (done) {
36
+ var match = ZERO_RENDER_LEVEL.test(html);
37
+ if (match) {
38
+ writer.close();
39
+ return;
40
+ }
34
41
  var current = Date.now();
35
42
  var cache = {
36
43
  val: html,
@@ -125,7 +132,7 @@ function matchCacheControl(cacheOption, req) {
125
132
  return typeof option2 === "function";
126
133
  }
127
134
  function isCacheControl(option2) {
128
- return typeof option2 === "object" && option2 !== null && "maxAge" in option2;
135
+ return (typeof option2 === "undefined" ? "undefined" : _type_of(option2)) === "object" && option2 !== null && "maxAge" in option2;
129
136
  }
130
137
  }
131
138
  function getCacheResult(request, options) {
@@ -20,7 +20,7 @@ const createWebRequest = (req, res, body) => {
20
20
  headers: headerRecord,
21
21
  signal: controller.signal
22
22
  };
23
- res.on("close", () => controller.abort());
23
+ res.on("close", () => controller.abort("res closed"));
24
24
  if (body || !(method === "GET" || method === "HEAD") && ((_req_url = req.url) === null || _req_url === void 0 ? void 0 : _req_url.includes("__loader"))) {
25
25
  init.body = body !== null && body !== void 0 ? body : createReadableStreamFromReadable(req);
26
26
  init.duplex = "half";
@@ -1,6 +1,7 @@
1
1
  import { createMemoryStorage } from "@modern-js/runtime-utils/storer";
2
2
  import { X_RENDER_CACHE } from "../../constants";
3
3
  import { createTransformStream, getPathname } from "../../utils";
4
+ const ZERO_RENDER_LEVEL = /"renderLevel":0/;
4
5
  async function processCache({ request, key, requestHandler, requestHandlerOptions, ttl, container, cacheStatus }) {
5
6
  const response = await requestHandler(request, requestHandlerOptions);
6
7
  const decoder = new TextDecoder();
@@ -11,6 +12,11 @@ async function processCache({ request, key, requestHandler, requestHandlerOption
11
12
  let html = "";
12
13
  const push = () => reader.read().then(({ done, value }) => {
13
14
  if (done) {
15
+ const match = ZERO_RENDER_LEVEL.test(html);
16
+ if (match) {
17
+ writer.close();
18
+ return;
19
+ }
14
20
  const current = Date.now();
15
21
  const cache = {
16
22
  val: html,
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.59.0",
18
+ "version": "2.60.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -46,16 +46,16 @@
46
46
  "node": ">=16.2.0"
47
47
  },
48
48
  "dependencies": {
49
- "@swc/helpers": "0.5.3",
49
+ "@swc/helpers": "0.5.13",
50
50
  "@web-std/fetch": "^4.2.1",
51
51
  "@web-std/file": "^3.0.3",
52
52
  "@web-std/stream": "^1.0.3",
53
53
  "flatted": "^3.2.9",
54
54
  "hono": "^3.12.2",
55
55
  "ts-deepmerge": "7.0.0",
56
- "@modern-js/plugin": "2.59.0",
57
- "@modern-js/utils": "2.59.0",
58
- "@modern-js/runtime-utils": "2.59.0"
56
+ "@modern-js/plugin": "2.60.1",
57
+ "@modern-js/utils": "2.60.1",
58
+ "@modern-js/runtime-utils": "2.60.1"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/jest": "^29",
@@ -65,9 +65,9 @@
65
65
  "jest": "^29",
66
66
  "ts-jest": "^29.1.0",
67
67
  "typescript": "^5",
68
- "@modern-js/types": "2.59.0",
69
- "@scripts/build": "2.59.0",
70
- "@scripts/jest-config": "2.59.0"
68
+ "@modern-js/types": "2.60.1",
69
+ "@scripts/build": "2.60.1",
70
+ "@scripts/jest-config": "2.60.1"
71
71
  },
72
72
  "sideEffects": false,
73
73
  "publishConfig": {