@modern-js/runtime 2.67.3 → 2.67.5
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/cjs/router/runtime/plugin.js +2 -1
- package/dist/cjs/router/runtime/plugin.node.js +6 -1
- 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/router/runtime/plugin.js +2 -1
- package/dist/esm/router/runtime/plugin.node.js +6 -1
- 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/dist/esm-node/router/runtime/plugin.js +2 -1
- package/dist/esm-node/router/runtime/plugin.node.js +6 -1
- package/dist/types/core/context/runtime.d.ts +3 -1
- package/package.json +14 -14
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) => {
|
|
@@ -118,7 +118,12 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
118
118
|
const router = (0, import_router.createStaticRouter)(routes, routerContext);
|
|
119
119
|
context.routerContext = routerContext;
|
|
120
120
|
context.remixRouter = router;
|
|
121
|
-
context
|
|
121
|
+
Object.defineProperty(context, "routes", {
|
|
122
|
+
get() {
|
|
123
|
+
return routes;
|
|
124
|
+
},
|
|
125
|
+
enumerable: true
|
|
126
|
+
});
|
|
122
127
|
});
|
|
123
128
|
api.wrapRoot((App) => {
|
|
124
129
|
if (!finalRouteConfig) {
|
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;
|
|
@@ -107,7 +107,12 @@ var routerPlugin = function() {
|
|
|
107
107
|
router = createStaticRouter(routes, routerContext);
|
|
108
108
|
context.routerContext = routerContext;
|
|
109
109
|
context.remixRouter = router;
|
|
110
|
-
context
|
|
110
|
+
Object.defineProperty(context, "routes", {
|
|
111
|
+
get: function get() {
|
|
112
|
+
return routes;
|
|
113
|
+
},
|
|
114
|
+
enumerable: true
|
|
115
|
+
});
|
|
111
116
|
return [
|
|
112
117
|
2
|
|
113
118
|
];
|
|
@@ -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) => {
|
|
@@ -84,7 +84,12 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
84
84
|
const router = createStaticRouter(routes, routerContext);
|
|
85
85
|
context.routerContext = routerContext;
|
|
86
86
|
context.remixRouter = router;
|
|
87
|
-
context
|
|
87
|
+
Object.defineProperty(context, "routes", {
|
|
88
|
+
get() {
|
|
89
|
+
return routes;
|
|
90
|
+
},
|
|
91
|
+
enumerable: true
|
|
92
|
+
});
|
|
88
93
|
});
|
|
89
94
|
api.wrapRoot((App) => {
|
|
90
95
|
if (!finalRouteConfig) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StaticHandlerContext } from '@modern-js/runtime-utils/remix-router';
|
|
2
|
+
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
3
|
import type { RouteManifest } from '../../router/runtime/types';
|
|
3
4
|
import { createLoaderManager } from '../loader/loaderManager';
|
|
4
5
|
import type { SSRServerContext, TSSRContext } from '../types';
|
|
@@ -20,7 +21,7 @@ export interface RuntimeContext extends BaseRuntimeContext {
|
|
|
20
21
|
}
|
|
21
22
|
export declare const RuntimeReactContext: import("react").Context<RuntimeContext>;
|
|
22
23
|
export declare const ServerRouterContext: import("react").Context<any>;
|
|
23
|
-
export interface TRuntimeContext
|
|
24
|
+
export interface TRuntimeContext {
|
|
24
25
|
initialData?: Record<string, unknown>;
|
|
25
26
|
isBrowser: boolean;
|
|
26
27
|
context: TSSRContext;
|
|
@@ -28,6 +29,7 @@ export interface TRuntimeContext extends Partial<BaseRuntimeContext> {
|
|
|
28
29
|
request?: SSRServerContext['request'];
|
|
29
30
|
/** @deprecated use context.response field instead */
|
|
30
31
|
response?: SSRServerContext['response'];
|
|
32
|
+
routes?: RouteObject[];
|
|
31
33
|
[key: string]: any;
|
|
32
34
|
}
|
|
33
35
|
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: RouteManifest) => RuntimeContext;
|
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.5",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"@loadable/babel-plugin": "5.15.3",
|
|
199
199
|
"@loadable/component": "5.15.3",
|
|
200
200
|
"@loadable/server": "5.15.3",
|
|
201
|
-
"@swc/helpers": "0.5.
|
|
201
|
+
"@swc/helpers": "^0.5.17",
|
|
202
202
|
"@types/loadable__component": "^5.13.4",
|
|
203
203
|
"@types/react-helmet": "^6.1.2",
|
|
204
204
|
"@types/styled-components": "^5.1.14",
|
|
@@ -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.5",
|
|
215
|
+
"@modern-js/plugin-data-loader": "2.67.5",
|
|
216
|
+
"@modern-js/plugin-v2": "2.67.5",
|
|
217
|
+
"@modern-js/render": "2.67.5",
|
|
218
|
+
"@modern-js/runtime-utils": "2.67.5",
|
|
219
|
+
"@modern-js/types": "2.67.5",
|
|
220
|
+
"@modern-js/utils": "2.67.5"
|
|
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.20",
|
|
229
229
|
"@testing-library/react": "^13.4.0",
|
|
230
230
|
"@types/cookie": "0.6.0",
|
|
231
231
|
"@types/invariant": "^2.2.30",
|
|
@@ -240,10 +240,10 @@
|
|
|
240
240
|
"ts-jest": "^29.1.0",
|
|
241
241
|
"ts-node": "^10.9.1",
|
|
242
242
|
"typescript": "^5",
|
|
243
|
-
"webpack": "^5.
|
|
244
|
-
"@modern-js/app-tools": "2.67.
|
|
245
|
-
"@scripts/
|
|
246
|
-
"@scripts/
|
|
243
|
+
"webpack": "^5.99.8",
|
|
244
|
+
"@modern-js/app-tools": "2.67.5",
|
|
245
|
+
"@scripts/jest-config": "2.66.0",
|
|
246
|
+
"@scripts/build": "2.66.0"
|
|
247
247
|
},
|
|
248
248
|
"sideEffects": false,
|
|
249
249
|
"publishConfig": {
|