@modern-js/runtime 2.49.4 → 2.50.0
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/router/runtime/plugin.node.js +2 -1
- package/dist/esm/router/runtime/plugin.node.js +5 -5
- package/dist/esm-node/router/runtime/plugin.node.js +3 -2
- package/dist/types/document/Body.d.ts +2 -4
- package/dist/types/document/Root.d.ts +2 -3
- package/dist/types/document/Style.d.ts +2 -2
- package/dist/types/exports/server.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +2 -2
- package/package.json +10 -10
|
@@ -80,6 +80,7 @@ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, creat
|
|
|
80
80
|
setup: (api) => {
|
|
81
81
|
return {
|
|
82
82
|
async init({ context }, next) {
|
|
83
|
+
var _context_ssrContext;
|
|
83
84
|
if (!routesConfig && !createRoutes) {
|
|
84
85
|
return next({
|
|
85
86
|
context
|
|
@@ -89,7 +90,7 @@ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, creat
|
|
|
89
90
|
const baseUrl = originalBaseUrl || request.baseUrl;
|
|
90
91
|
const _basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, basename) : baseUrl;
|
|
91
92
|
const { reporter, serverTiming } = context.ssrContext;
|
|
92
|
-
const requestContext = (0, import_node.createRequestContext)();
|
|
93
|
+
const requestContext = (0, import_node.createRequestContext)((_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.loaderContext);
|
|
93
94
|
requestContext.set(import_node.reporterCtx, reporter);
|
|
94
95
|
let routes = createRoutes ? createRoutes() : (0, import_router2.createRoutesFromElements)((0, import_utils.renderRoutes)({
|
|
95
96
|
routesConfig,
|
|
@@ -10,7 +10,7 @@ import { createStaticHandler } from "@modern-js/runtime-utils/remix-router";
|
|
|
10
10
|
import { createStaticRouter, StaticRouterProvider } from "@modern-js/runtime-utils/node/router";
|
|
11
11
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
12
12
|
import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
|
|
13
|
-
import {
|
|
13
|
+
import { reporterCtx, createRequestContext } from "@modern-js/runtime-utils/node";
|
|
14
14
|
import { time } from "@modern-js/runtime-utils/time";
|
|
15
15
|
import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
|
|
16
16
|
import { RuntimeReactContext } from "../../core";
|
|
@@ -88,7 +88,7 @@ var routerPlugin = function(param) {
|
|
|
88
88
|
init: function init(param2, next) {
|
|
89
89
|
var context = param2.context;
|
|
90
90
|
return _async_to_generator(function() {
|
|
91
|
-
var _context_ssrContext, request, ssrMode, nonce, baseUrl, _basename,
|
|
91
|
+
var _context_ssrContext, _context_ssrContext1, request, ssrMode, nonce, baseUrl, _basename, _context_ssrContext2, reporter, serverTiming, requestContext, routes, runner, query, remixRequest, end, routerContext, cost, router;
|
|
92
92
|
return _ts_generator(this, function(_state) {
|
|
93
93
|
switch (_state.label) {
|
|
94
94
|
case 0:
|
|
@@ -100,11 +100,11 @@ var routerPlugin = function(param) {
|
|
|
100
100
|
})
|
|
101
101
|
];
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
_context_ssrContext1 = context.ssrContext, request = _context_ssrContext1.request, ssrMode = _context_ssrContext1.mode, nonce = _context_ssrContext1.nonce;
|
|
104
104
|
baseUrl = originalBaseUrl || request.baseUrl;
|
|
105
105
|
_basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
|
|
106
|
-
|
|
107
|
-
requestContext = createRequestContext();
|
|
106
|
+
_context_ssrContext2 = context.ssrContext, reporter = _context_ssrContext2.reporter, serverTiming = _context_ssrContext2.serverTiming;
|
|
107
|
+
requestContext = createRequestContext((_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.loaderContext);
|
|
108
108
|
requestContext.set(reporterCtx, reporter);
|
|
109
109
|
routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
|
|
110
110
|
routesConfig,
|
|
@@ -4,7 +4,7 @@ import { createStaticHandler } from "@modern-js/runtime-utils/remix-router";
|
|
|
4
4
|
import { createStaticRouter, StaticRouterProvider } from "@modern-js/runtime-utils/node/router";
|
|
5
5
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
6
6
|
import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
|
|
7
|
-
import {
|
|
7
|
+
import { reporterCtx, createRequestContext } from "@modern-js/runtime-utils/node";
|
|
8
8
|
import { time } from "@modern-js/runtime-utils/time";
|
|
9
9
|
import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
|
|
10
10
|
import { RuntimeReactContext } from "../../core";
|
|
@@ -45,6 +45,7 @@ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, creat
|
|
|
45
45
|
setup: (api) => {
|
|
46
46
|
return {
|
|
47
47
|
async init({ context }, next) {
|
|
48
|
+
var _context_ssrContext;
|
|
48
49
|
if (!routesConfig && !createRoutes) {
|
|
49
50
|
return next({
|
|
50
51
|
context
|
|
@@ -54,7 +55,7 @@ const routerPlugin = ({ basename = "", originalBaseUrl = "", routesConfig, creat
|
|
|
54
55
|
const baseUrl = originalBaseUrl || request.baseUrl;
|
|
55
56
|
const _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
|
|
56
57
|
const { reporter, serverTiming } = context.ssrContext;
|
|
57
|
-
const requestContext = createRequestContext();
|
|
58
|
+
const requestContext = createRequestContext((_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.loaderContext);
|
|
58
59
|
requestContext.set(reporterCtx, reporter);
|
|
59
60
|
let routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
|
|
60
61
|
routesConfig,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export declare function Root(props: {
|
|
3
|
-
children?: any;
|
|
4
3
|
rootId?: string;
|
|
5
|
-
}): JSX.Element;
|
|
4
|
+
} & React.DOMAttributes<HTMLDivElement>): JSX.Element;
|
|
6
5
|
export declare function DefaultRoot(props: {
|
|
7
6
|
children?: any;
|
|
8
7
|
}): JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AfterMatchContext, AfterRenderContext, MiddlewareContext, NextFunction } from '@modern-js/types';
|
|
2
|
-
export type { Container, CacheControl, CacheOptionProvider, CacheOption, } from '@modern-js/types';
|
|
2
|
+
export type { Container, CacheControl, CacheOptionProvider, CacheOption, UnstableMiddlewareContext, UnstableMiddleware, UnstableNext, } from '@modern-js/types';
|
|
3
3
|
export declare const hook: (attacher: ({ addMiddleware, afterMatch, afterRender, }: {
|
|
4
4
|
addMiddleware: (mid: Middleware) => void;
|
|
5
5
|
afterRender: (hook: AfterRenderHook) => void;
|
|
@@ -56,7 +56,7 @@ interface DataFunctionArgs<D = any> {
|
|
|
56
56
|
params: Params;
|
|
57
57
|
context?: D;
|
|
58
58
|
}
|
|
59
|
-
export type LoaderFunctionArgs = DataFunctionArgs<RequestContext
|
|
59
|
+
export type LoaderFunctionArgs<P extends Record<string, unknown> = any> = DataFunctionArgs<RequestContext<P>>;
|
|
60
60
|
declare type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
61
|
-
export type LoaderFunction = (args: LoaderFunctionArgs) => Promise<DataFunctionValue> | DataFunctionValue;
|
|
61
|
+
export type LoaderFunction = <P extends Record<string, unknown> = Record<string, unknown>>(args: LoaderFunctionArgs<P>) => Promise<DataFunctionValue> | DataFunctionValue;
|
|
62
62
|
export {};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.50.0",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -170,10 +170,10 @@
|
|
|
170
170
|
"react-side-effect": "^2.1.1",
|
|
171
171
|
"styled-components": "^5.3.1",
|
|
172
172
|
"@swc/helpers": "0.5.3",
|
|
173
|
-
"@modern-js/plugin": "2.
|
|
174
|
-
"@modern-js/types": "2.
|
|
175
|
-
"@modern-js/utils": "2.
|
|
176
|
-
"@modern-js/runtime-utils": "2.
|
|
173
|
+
"@modern-js/plugin": "2.50.0",
|
|
174
|
+
"@modern-js/types": "2.50.0",
|
|
175
|
+
"@modern-js/utils": "2.50.0",
|
|
176
|
+
"@modern-js/runtime-utils": "2.50.0"
|
|
177
177
|
},
|
|
178
178
|
"peerDependencies": {
|
|
179
179
|
"react": ">=17",
|
|
@@ -194,11 +194,11 @@
|
|
|
194
194
|
"ts-jest": "^29.1.0",
|
|
195
195
|
"typescript": "^5",
|
|
196
196
|
"webpack": "^5.91.0",
|
|
197
|
-
"@modern-js/app-tools": "2.
|
|
198
|
-
"@modern-js/core": "2.
|
|
199
|
-
"@modern-js/
|
|
200
|
-
"@scripts/build": "2.
|
|
201
|
-
"@scripts/jest-config": "2.
|
|
197
|
+
"@modern-js/app-tools": "2.50.0",
|
|
198
|
+
"@modern-js/server-core": "2.50.0",
|
|
199
|
+
"@modern-js/core": "2.50.0",
|
|
200
|
+
"@scripts/build": "2.50.0",
|
|
201
|
+
"@scripts/jest-config": "2.50.0"
|
|
202
202
|
},
|
|
203
203
|
"sideEffects": false,
|
|
204
204
|
"publishConfig": {
|