@modern-js/runtime 2.67.2 → 2.67.4
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/dist/cjs/cli/alias.js +1 -1
- package/dist/cjs/core/server/requestHandler.js +3 -1
- package/dist/cjs/router/cli/index.js +4 -1
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +4 -2
- package/dist/esm/cli/alias.js +1 -1
- package/dist/esm/core/server/requestHandler.js +4 -2
- package/dist/esm/router/cli/index.js +4 -1
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +6 -3
- package/dist/esm-node/cli/alias.js +1 -1
- package/dist/esm-node/core/server/requestHandler.js +3 -1
- package/dist/esm-node/router/cli/index.js +4 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +5 -3
- package/package.json +10 -10
package/dist/cjs/cli/alias.js
CHANGED
|
@@ -40,7 +40,7 @@ const builderPluginAlias = ({ entrypoints, internalDirectory, metaName }) => ({
|
|
|
40
40
|
const entrypointsAlias = {};
|
|
41
41
|
const mainEntrypointsAlias = {};
|
|
42
42
|
entrypoints.forEach((entrypoint) => {
|
|
43
|
-
entrypointsAlias[`@${metaName}/runtime/registry/${entrypoint.entryName}
|
|
43
|
+
entrypointsAlias[`@${metaName}/runtime/registry/${entrypoint.entryName}$`] = import_path.default.join(internalDirectory, entrypoint.entryName, import_constants.ENTRY_POINT_REGISTER_FILE_NAME);
|
|
44
44
|
if (entrypoint.isMainEntry) {
|
|
45
45
|
mainEntrypointsAlias[`@${metaName}/runtime/registry`] = import_path.default.join(internalDirectory, entrypoint.entryName, import_constants.ENTRY_POINT_REGISTER_FILE_NAME);
|
|
46
46
|
}
|
|
@@ -94,11 +94,13 @@ const createRequestHandler = async (handleRequest, createRequestOptions) => {
|
|
|
94
94
|
headers: {},
|
|
95
95
|
status: -1
|
|
96
96
|
};
|
|
97
|
+
const activeDeferreds = /* @__PURE__ */ new Map();
|
|
97
98
|
return import_node.storage.run({
|
|
98
99
|
headers: headersData,
|
|
99
100
|
request,
|
|
100
101
|
monitors: options.monitors,
|
|
101
|
-
responseProxy
|
|
102
|
+
responseProxy,
|
|
103
|
+
activeDeferreds
|
|
102
104
|
}, async () => {
|
|
103
105
|
var _context_routerContext, _context_routerContext1, _context_routerContext2;
|
|
104
106
|
const Root = (0, import_react.createRoot)();
|
|
@@ -32,6 +32,7 @@ const DeferredDataScripts = (props) => {
|
|
|
32
32
|
const staticContext = props === null || props === void 0 ? void 0 : props.context;
|
|
33
33
|
const useJsonScript = props === null || props === void 0 ? void 0 : props.useJsonScript;
|
|
34
34
|
const hydratedRef = (0, import_react.useRef)(false);
|
|
35
|
+
const isRouterV7 = process.env._MODERN_ROUTER_VERSION === "v7";
|
|
35
36
|
(0, import_react.useEffect)(() => {
|
|
36
37
|
hydratedRef.current = true;
|
|
37
38
|
}, []);
|
|
@@ -39,7 +40,8 @@ const DeferredDataScripts = (props) => {
|
|
|
39
40
|
if (!staticContext) {
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
|
-
const
|
|
43
|
+
const originalActiveDeferreds = import_node.storage.useContext().activeDeferreds;
|
|
44
|
+
const activeDeferreds = !isRouterV7 ? staticContext.activeDeferreds || [] : originalActiveDeferreds;
|
|
43
45
|
const _ROUTER_DATA = {
|
|
44
46
|
loaderData: staticContext.loaderData,
|
|
45
47
|
errors: (0, import_utils.serializeErrors)(staticContext.errors)
|
|
@@ -50,7 +52,7 @@ const DeferredDataScripts = (props) => {
|
|
|
50
52
|
import_constants2.modernInline
|
|
51
53
|
].join("\n");
|
|
52
54
|
const deferredDataScripts = [];
|
|
53
|
-
const initialScripts = Object.entries(activeDeferreds).map(([routeId, deferredData]) => {
|
|
55
|
+
const initialScripts = (activeDeferreds instanceof Map ? Array.from(activeDeferreds.entries()) : Object.entries(activeDeferreds)).map(([routeId, deferredData]) => {
|
|
54
56
|
const pendingKeys = new Set(deferredData.pendingKeys);
|
|
55
57
|
const { deferredKeys } = deferredData;
|
|
56
58
|
const deferredKeyPromiseManifests = deferredKeys.map((key) => {
|
package/dist/esm/cli/alias.js
CHANGED
|
@@ -11,7 +11,7 @@ var builderPluginAlias = function(param) {
|
|
|
11
11
|
var entrypointsAlias = {};
|
|
12
12
|
var mainEntrypointsAlias = {};
|
|
13
13
|
entrypoints.forEach(function(entrypoint) {
|
|
14
|
-
entrypointsAlias["@".concat(metaName, "/runtime/registry/").concat(entrypoint.entryName)] = path.join(internalDirectory, entrypoint.entryName, ENTRY_POINT_REGISTER_FILE_NAME);
|
|
14
|
+
entrypointsAlias["@".concat(metaName, "/runtime/registry/").concat(entrypoint.entryName, "$")] = path.join(internalDirectory, entrypoint.entryName, ENTRY_POINT_REGISTER_FILE_NAME);
|
|
15
15
|
if (entrypoint.isMainEntry) {
|
|
16
16
|
mainEntrypointsAlias["@".concat(metaName, "/runtime/registry")] = path.join(internalDirectory, entrypoint.entryName, ENTRY_POINT_REGISTER_FILE_NAME);
|
|
17
17
|
}
|
|
@@ -77,20 +77,22 @@ var createRequestHandler = function() {
|
|
|
77
77
|
return _ts_generator(this, function(_state) {
|
|
78
78
|
requestHandler = function() {
|
|
79
79
|
var _ref2 = _async_to_generator(function(request, options) {
|
|
80
|
-
var headersData, responseProxy;
|
|
80
|
+
var headersData, responseProxy, activeDeferreds;
|
|
81
81
|
return _ts_generator(this, function(_state2) {
|
|
82
82
|
headersData = parseHeaders(request);
|
|
83
83
|
responseProxy = {
|
|
84
84
|
headers: {},
|
|
85
85
|
status: -1
|
|
86
86
|
};
|
|
87
|
+
activeDeferreds = /* @__PURE__ */ new Map();
|
|
87
88
|
return [
|
|
88
89
|
2,
|
|
89
90
|
storage.run({
|
|
90
91
|
headers: headersData,
|
|
91
92
|
request,
|
|
92
93
|
monitors: options.monitors,
|
|
93
|
-
responseProxy
|
|
94
|
+
responseProxy,
|
|
95
|
+
activeDeferreds
|
|
94
96
|
}, /* @__PURE__ */ _async_to_generator(function() {
|
|
95
97
|
var _context_routerContext, _context_routerContext1, _context_routerContext2, Root, internalRuntimeContext, hooks, routeManifest, context, runBeforeRender, ssrContext, getRedirectResponse, initialData, _context_routerContext3, _context_ssrContext, errors, redirectResponse, htmlTemplate, response;
|
|
96
98
|
return _ts_generator(this, function(_state3) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
|
1
2
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
2
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
4
|
+
import { serializeJson, storage } from "@modern-js/runtime-utils/node";
|
|
4
5
|
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
5
6
|
import { Suspense, useEffect, useMemo, useRef } from "react";
|
|
6
7
|
import { ROUTER_DATA_JSON_ID } from "../../core/constants";
|
|
@@ -10,6 +11,7 @@ var DeferredDataScripts = function(props) {
|
|
|
10
11
|
var staticContext = props === null || props === void 0 ? void 0 : props.context;
|
|
11
12
|
var useJsonScript = props === null || props === void 0 ? void 0 : props.useJsonScript;
|
|
12
13
|
var hydratedRef = useRef(false);
|
|
14
|
+
var isRouterV7 = process.env._MODERN_ROUTER_VERSION === "v7";
|
|
13
15
|
useEffect(function() {
|
|
14
16
|
hydratedRef.current = true;
|
|
15
17
|
}, []);
|
|
@@ -17,7 +19,8 @@ var DeferredDataScripts = function(props) {
|
|
|
17
19
|
if (!staticContext) {
|
|
18
20
|
return null;
|
|
19
21
|
}
|
|
20
|
-
var
|
|
22
|
+
var originalActiveDeferreds = storage.useContext().activeDeferreds;
|
|
23
|
+
var activeDeferreds = !isRouterV7 ? staticContext.activeDeferreds || [] : originalActiveDeferreds;
|
|
21
24
|
var _ROUTER_DATA = {
|
|
22
25
|
loaderData: staticContext.loaderData,
|
|
23
26
|
errors: serializeErrors(staticContext.errors)
|
|
@@ -28,7 +31,7 @@ var DeferredDataScripts = function(props) {
|
|
|
28
31
|
modernInline
|
|
29
32
|
].join("\n");
|
|
30
33
|
var deferredDataScripts = [];
|
|
31
|
-
var initialScripts = Object.entries(activeDeferreds).map(function(param) {
|
|
34
|
+
var initialScripts = (_instanceof(activeDeferreds, Map) ? Array.from(activeDeferreds.entries()) : Object.entries(activeDeferreds)).map(function(param) {
|
|
32
35
|
var _param = _sliced_to_array(param, 2), routeId = _param[0], deferredData = _param[1];
|
|
33
36
|
var pendingKeys = new Set(deferredData.pendingKeys);
|
|
34
37
|
var deferredKeys = deferredData.deferredKeys;
|
|
@@ -7,7 +7,7 @@ const builderPluginAlias = ({ entrypoints, internalDirectory, metaName }) => ({
|
|
|
7
7
|
const entrypointsAlias = {};
|
|
8
8
|
const mainEntrypointsAlias = {};
|
|
9
9
|
entrypoints.forEach((entrypoint) => {
|
|
10
|
-
entrypointsAlias[`@${metaName}/runtime/registry/${entrypoint.entryName}
|
|
10
|
+
entrypointsAlias[`@${metaName}/runtime/registry/${entrypoint.entryName}$`] = path.join(internalDirectory, entrypoint.entryName, ENTRY_POINT_REGISTER_FILE_NAME);
|
|
11
11
|
if (entrypoint.isMainEntry) {
|
|
12
12
|
mainEntrypointsAlias[`@${metaName}/runtime/registry`] = path.join(internalDirectory, entrypoint.entryName, ENTRY_POINT_REGISTER_FILE_NAME);
|
|
13
13
|
}
|
|
@@ -71,11 +71,13 @@ const createRequestHandler = async (handleRequest, createRequestOptions) => {
|
|
|
71
71
|
headers: {},
|
|
72
72
|
status: -1
|
|
73
73
|
};
|
|
74
|
+
const activeDeferreds = /* @__PURE__ */ new Map();
|
|
74
75
|
return storage.run({
|
|
75
76
|
headers: headersData,
|
|
76
77
|
request,
|
|
77
78
|
monitors: options.monitors,
|
|
78
|
-
responseProxy
|
|
79
|
+
responseProxy,
|
|
80
|
+
activeDeferreds
|
|
79
81
|
}, async () => {
|
|
80
82
|
var _context_routerContext, _context_routerContext1, _context_routerContext2;
|
|
81
83
|
const Root = createRoot();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
2
|
+
import { serializeJson, storage } from "@modern-js/runtime-utils/node";
|
|
3
3
|
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
4
4
|
import { Suspense, useEffect, useMemo, useRef } from "react";
|
|
5
5
|
import { ROUTER_DATA_JSON_ID } from "../../core/constants";
|
|
@@ -9,6 +9,7 @@ const DeferredDataScripts = (props) => {
|
|
|
9
9
|
const staticContext = props === null || props === void 0 ? void 0 : props.context;
|
|
10
10
|
const useJsonScript = props === null || props === void 0 ? void 0 : props.useJsonScript;
|
|
11
11
|
const hydratedRef = useRef(false);
|
|
12
|
+
const isRouterV7 = process.env._MODERN_ROUTER_VERSION === "v7";
|
|
12
13
|
useEffect(() => {
|
|
13
14
|
hydratedRef.current = true;
|
|
14
15
|
}, []);
|
|
@@ -16,7 +17,8 @@ const DeferredDataScripts = (props) => {
|
|
|
16
17
|
if (!staticContext) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
|
-
const
|
|
20
|
+
const originalActiveDeferreds = storage.useContext().activeDeferreds;
|
|
21
|
+
const activeDeferreds = !isRouterV7 ? staticContext.activeDeferreds || [] : originalActiveDeferreds;
|
|
20
22
|
const _ROUTER_DATA = {
|
|
21
23
|
loaderData: staticContext.loaderData,
|
|
22
24
|
errors: serializeErrors(staticContext.errors)
|
|
@@ -27,7 +29,7 @@ const DeferredDataScripts = (props) => {
|
|
|
27
29
|
modernInline
|
|
28
30
|
].join("\n");
|
|
29
31
|
const deferredDataScripts = [];
|
|
30
|
-
const initialScripts = Object.entries(activeDeferreds).map(([routeId, deferredData]) => {
|
|
32
|
+
const initialScripts = (activeDeferreds instanceof Map ? Array.from(activeDeferreds.entries()) : Object.entries(activeDeferreds)).map(([routeId, deferredData]) => {
|
|
31
33
|
const pendingKeys = new Set(deferredData.pendingKeys);
|
|
32
34
|
const { deferredKeys } = deferredData;
|
|
33
35
|
const deferredKeyPromiseManifests = deferredKeys.map((key) => {
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.67.
|
|
18
|
+
"version": "2.67.4",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -211,13 +211,13 @@
|
|
|
211
211
|
"react-is": "^18",
|
|
212
212
|
"react-side-effect": "^2.1.1",
|
|
213
213
|
"styled-components": "^5.3.1",
|
|
214
|
-
"@modern-js/plugin": "2.67.
|
|
215
|
-
"@modern-js/plugin-data-loader": "2.67.
|
|
216
|
-
"@modern-js/plugin-v2": "2.67.
|
|
217
|
-
"@modern-js/render": "2.67.
|
|
218
|
-
"@modern-js/runtime-utils": "2.67.
|
|
219
|
-
"@modern-js/types": "2.67.
|
|
220
|
-
"@modern-js/utils": "2.67.
|
|
214
|
+
"@modern-js/plugin": "2.67.4",
|
|
215
|
+
"@modern-js/plugin-data-loader": "2.67.4",
|
|
216
|
+
"@modern-js/plugin-v2": "2.67.4",
|
|
217
|
+
"@modern-js/render": "2.67.4",
|
|
218
|
+
"@modern-js/runtime-utils": "2.67.4",
|
|
219
|
+
"@modern-js/types": "2.67.4",
|
|
220
|
+
"@modern-js/utils": "2.67.4"
|
|
221
221
|
},
|
|
222
222
|
"peerDependencies": {
|
|
223
223
|
"react": ">=17",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
},
|
|
226
226
|
"devDependencies": {
|
|
227
227
|
"@remix-run/web-fetch": "^4.1.3",
|
|
228
|
-
"@rsbuild/core": "1.3.
|
|
228
|
+
"@rsbuild/core": "1.3.16",
|
|
229
229
|
"@testing-library/react": "^13.4.0",
|
|
230
230
|
"@types/cookie": "0.6.0",
|
|
231
231
|
"@types/invariant": "^2.2.30",
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
"ts-node": "^10.9.1",
|
|
242
242
|
"typescript": "^5",
|
|
243
243
|
"webpack": "^5.98.0",
|
|
244
|
-
"@modern-js/app-tools": "2.67.
|
|
244
|
+
"@modern-js/app-tools": "2.67.4",
|
|
245
245
|
"@scripts/build": "2.66.0",
|
|
246
246
|
"@scripts/jest-config": "2.66.0"
|
|
247
247
|
},
|