@modern-js/runtime 2.65.2 → 2.65.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/code.js +1 -0
- package/dist/cjs/cli/template.js +7 -3
- package/dist/cjs/core/browser/index.js +1 -3
- package/dist/cjs/core/compat/hooks.js +2 -2
- package/dist/cjs/core/compat/requestContext.js +48 -0
- package/dist/cjs/core/compatible.js +2 -14
- package/dist/cjs/core/context/index.js +6 -0
- package/dist/cjs/core/context/monitors/default.js +5 -10
- package/dist/cjs/core/context/response/index.js +43 -0
- package/dist/cjs/core/context/response/index.server.js +62 -0
- package/dist/cjs/core/plugin/index.js +2 -0
- package/dist/cjs/core/server/requestHandler.js +10 -8
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/react-server.js +12 -2
- package/dist/cjs/router/cli/code/templates.js +3 -1
- package/dist/cjs/router/cli/handler.js +1 -0
- package/dist/esm/cli/code.js +1 -0
- package/dist/esm/cli/template.js +4 -4
- package/dist/esm/core/browser/index.js +3 -4
- package/dist/esm/core/compat/hooks.js +2 -2
- package/dist/esm/core/compat/requestContext.js +25 -0
- package/dist/esm/core/compatible.js +5 -16
- package/dist/esm/core/context/index.js +5 -0
- package/dist/esm/core/context/monitors/default.js +5 -25
- package/dist/esm/core/context/response/index.js +16 -0
- package/dist/esm/core/context/response/index.server.js +41 -0
- package/dist/esm/core/plugin/index.js +3 -1
- package/dist/esm/core/server/requestHandler.js +12 -10
- package/dist/esm/index.js +4 -0
- package/dist/esm/react-server.js +7 -1
- package/dist/esm/router/cli/code/templates.js +3 -3
- package/dist/esm/router/cli/handler.js +1 -0
- package/dist/esm-node/cli/code.js +1 -0
- package/dist/esm-node/cli/template.js +7 -3
- package/dist/esm-node/core/browser/index.js +1 -3
- package/dist/esm-node/core/compat/hooks.js +2 -2
- package/dist/esm-node/core/compat/requestContext.js +23 -0
- package/dist/esm-node/core/compatible.js +2 -14
- package/dist/esm-node/core/context/index.js +5 -0
- package/dist/esm-node/core/context/monitors/default.js +5 -10
- package/dist/esm-node/core/context/response/index.js +16 -0
- package/dist/esm-node/core/context/response/index.server.js +35 -0
- package/dist/esm-node/core/plugin/index.js +2 -0
- package/dist/esm-node/core/server/requestHandler.js +10 -8
- package/dist/esm-node/index.js +4 -0
- package/dist/esm-node/react-server.js +7 -1
- package/dist/esm-node/router/cli/code/templates.js +3 -1
- package/dist/esm-node/router/cli/handler.js +1 -0
- package/dist/types/cli/template.d.ts +2 -1
- package/dist/types/core/compat/requestContext.d.ts +27 -0
- package/dist/types/core/config.d.ts +1 -1
- package/dist/types/core/context/index.d.ts +2 -0
- package/dist/types/core/context/response/index.d.ts +4 -0
- package/dist/types/core/context/response/index.server.d.ts +7 -0
- package/dist/types/core/context/runtime.d.ts +1 -0
- package/dist/types/core/plugin/base.d.ts +1 -1
- package/dist/types/core/plugin/index.d.ts +1 -1
- package/dist/types/core/plugin/types.d.ts +2 -1
- package/dist/types/core/types.d.ts +4 -17
- package/dist/types/index.d.ts +1 -0
- package/dist/types/react-server.d.ts +2 -0
- package/dist/types/router/cli/code/templates.d.ts +2 -1
- package/package.json +12 -12
|
@@ -5,6 +5,7 @@ import type { AppConfig } from '../../common';
|
|
|
5
5
|
import type { RuntimeExtends } from '../plugin/types';
|
|
6
6
|
export { type RuntimeContext, RuntimeReactContext, getInitialContext, } from './runtime';
|
|
7
7
|
interface GlobalContext {
|
|
8
|
+
entryName?: string;
|
|
8
9
|
/**
|
|
9
10
|
* App.tsx export default component
|
|
10
11
|
*/
|
|
@@ -34,6 +35,7 @@ interface GlobalContext {
|
|
|
34
35
|
export declare function setGlobalContext(context: Omit<GlobalContext, 'appConfig' | 'internalRuntimeContext'> & {
|
|
35
36
|
appConfig?: () => AppConfig;
|
|
36
37
|
}): void;
|
|
38
|
+
export declare function getCurrentEntryName(): string | undefined;
|
|
37
39
|
export declare function getGlobalRSCRoot(): import("react").ComponentType<{}> | undefined;
|
|
38
40
|
export declare function setGlobalInternalRuntimeContext(context: InternalRuntimeContext<RuntimeExtends>): void;
|
|
39
41
|
export declare function getGlobalInternalRuntimeContext(): InternalRuntimeContext<Required<import("@modern-js/plugin-v2").RuntimePluginExtends<import("../plugin/types").RuntimeConfig, import("./runtime").RuntimeContext, {}, {}>>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const getResponseProxy: () => null;
|
|
2
|
+
export declare const setHeaders: (headers: Record<string, string>) => void;
|
|
3
|
+
export declare const setStatus: (status: number) => void;
|
|
4
|
+
export declare const redirect: (url: string, init?: number | ResponseInit) => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const getResponseProxy: () => {
|
|
2
|
+
headers: Record<string, string>;
|
|
3
|
+
status: number;
|
|
4
|
+
} | undefined;
|
|
5
|
+
export declare const setHeaders: (headers: Record<string, string>) => void;
|
|
6
|
+
export declare const setStatus: (status: number) => void;
|
|
7
|
+
export declare const redirect: (url: string, init?: number | ResponseInit) => void;
|
|
@@ -7,7 +7,7 @@ export type RuntimeHooks = {
|
|
|
7
7
|
beforeRender: AsyncInterruptWorkflow<RuntimeContext, void>;
|
|
8
8
|
wrapRoot: Waterfall<React.ComponentType<any>>;
|
|
9
9
|
pickContext: Waterfall<TRuntimeContext>;
|
|
10
|
-
|
|
10
|
+
config: SyncParallelWorkflow<void, Record<string, any>>;
|
|
11
11
|
};
|
|
12
12
|
export type RuntimePluginAPI = {
|
|
13
13
|
useRuntimeConfigContext: () => RuntimeConfig;
|
|
@@ -13,7 +13,7 @@ export declare function registerPlugin(internalPlugins: (RuntimePlugin | Runtime
|
|
|
13
13
|
onBeforeRender: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").OnBeforeRenderFn<{} | undefined>>;
|
|
14
14
|
wrapRoot: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").WrapRootFn>;
|
|
15
15
|
pickContext: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").PickContextFn<import("@modern-js/plugin-v2/runtime").RuntimeContext>>;
|
|
16
|
-
|
|
16
|
+
config: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").ConfigFn<{} | undefined>>;
|
|
17
17
|
} & {}> | undefined;
|
|
18
18
|
_internalContext?: any | undefined;
|
|
19
19
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { RuntimePlugin as BaseRuntimePlugin, RuntimePluginExtends } from '@modern-js/plugin-v2';
|
|
2
2
|
import type { Hooks } from '@modern-js/plugin-v2/runtime';
|
|
3
|
+
import type { AppConfig } from '../../common';
|
|
3
4
|
import type { RuntimeContext } from '../context/runtime';
|
|
4
5
|
import type { Plugin } from './base';
|
|
5
6
|
export type RuntimeHooks = Hooks<RuntimeConfig, RuntimeContext>;
|
|
6
7
|
export type RuntimeExtends = Required<RuntimePluginExtends<RuntimeConfig, RuntimeContext, {}, {}>>;
|
|
7
8
|
export type RuntimePluginFuture<Extends extends RuntimePluginExtends = {}> = BaseRuntimePlugin<RuntimeExtends & Extends>;
|
|
8
|
-
export interface RuntimeConfig {
|
|
9
|
+
export interface RuntimeConfig extends AppConfig {
|
|
9
10
|
plugins?: (Plugin | RuntimePluginFuture)[];
|
|
10
11
|
}
|
|
@@ -27,14 +27,7 @@ export interface SSRContainer {
|
|
|
27
27
|
mode: SSRMode;
|
|
28
28
|
data?: SSRData;
|
|
29
29
|
context?: {
|
|
30
|
-
request:
|
|
31
|
-
params: Record<string, any>;
|
|
32
|
-
query: Record<string, string>;
|
|
33
|
-
pathname: string;
|
|
34
|
-
host: string;
|
|
35
|
-
url: string;
|
|
36
|
-
headers?: Record<string, string | undefined>;
|
|
37
|
-
};
|
|
30
|
+
request: BaseSSRServerContext['request'];
|
|
38
31
|
reporter?: {
|
|
39
32
|
sessionId?: string;
|
|
40
33
|
};
|
|
@@ -44,9 +37,6 @@ type BuildHtmlCb = (tempalte: string) => string;
|
|
|
44
37
|
export type SSRServerContext = Pick<BaseSSRServerContext, 'redirection' | 'response' | 'nonce' | 'mode' | 'loaderContext' | 'reporter' | 'logger' | 'metrics' | 'routeManifest'> & {
|
|
45
38
|
request: BaseSSRServerContext['request'] & {
|
|
46
39
|
baseUrl: string;
|
|
47
|
-
userAgent: string;
|
|
48
|
-
cookie: string;
|
|
49
|
-
cookieMap: Record<string, string>;
|
|
50
40
|
raw: Request;
|
|
51
41
|
};
|
|
52
42
|
htmlModifiers: BuildHtmlCb[];
|
|
@@ -56,18 +46,15 @@ export type SSRServerContext = Pick<BaseSSRServerContext, 'redirection' | 'respo
|
|
|
56
46
|
useJsonScript?: boolean;
|
|
57
47
|
};
|
|
58
48
|
interface TSSRBaseContext {
|
|
59
|
-
request: BaseSSRServerContext['request']
|
|
60
|
-
userAgent: string;
|
|
61
|
-
cookie: string;
|
|
62
|
-
};
|
|
49
|
+
request: BaseSSRServerContext['request'];
|
|
63
50
|
[propName: string]: any;
|
|
64
51
|
}
|
|
65
|
-
interface ServerContext extends TSSRBaseContext {
|
|
52
|
+
export interface ServerContext extends TSSRBaseContext {
|
|
66
53
|
isBrowser: false;
|
|
67
54
|
response: BaseSSRServerContext['response'];
|
|
68
55
|
logger: BaseSSRServerContext['logger'];
|
|
69
56
|
}
|
|
70
|
-
interface ClientContext extends TSSRBaseContext {
|
|
57
|
+
export interface ClientContext extends TSSRBaseContext {
|
|
71
58
|
isBrowser: true;
|
|
72
59
|
}
|
|
73
60
|
export declare type TSSRContext = ServerContext | ClientContext;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export type { RuntimeContext } from './core/context/runtime';
|
|
|
7
7
|
export type { RuntimeUserConfig } from './config';
|
|
8
8
|
export { getMonitors } from './core/context/monitors';
|
|
9
9
|
export { getRequest } from './core/context/request';
|
|
10
|
+
export { setHeaders, setStatus, redirect } from './core/context/response';
|
|
10
11
|
export { createApp, useLoader, bootstrap, RuntimeReactContext, defineConfig, defineRuntimeConfig, useRuntimeContext, } from './core';
|
|
11
12
|
export type { StateConfig, RouterConfig };
|
|
@@ -13,7 +13,8 @@ export declare const fileSystemRoutes: ({ metaName, routes, ssrMode, nestedRoute
|
|
|
13
13
|
splitRouteChunks?: boolean | undefined;
|
|
14
14
|
}) => Promise<string>;
|
|
15
15
|
export declare function ssrLoaderCombinedModule(entrypoints: Entrypoint[], entrypoint: Entrypoint, config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>): string | null;
|
|
16
|
-
export declare const runtimeGlobalContext: ({ metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, }: {
|
|
16
|
+
export declare const runtimeGlobalContext: ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, }: {
|
|
17
|
+
entryName: string;
|
|
17
18
|
metaName: string;
|
|
18
19
|
srcDirectory: string;
|
|
19
20
|
nestedRoutesEntry?: string | undefined;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.65.
|
|
18
|
+
"version": "2.65.4",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -226,13 +226,13 @@
|
|
|
226
226
|
"react-is": "^18",
|
|
227
227
|
"react-side-effect": "^2.1.1",
|
|
228
228
|
"styled-components": "^5.3.1",
|
|
229
|
-
"@modern-js/plugin": "2.65.
|
|
230
|
-
"@modern-js/plugin-data-loader": "2.65.
|
|
231
|
-
"@modern-js/plugin-v2": "2.65.
|
|
232
|
-
"@modern-js/render": "2.65.
|
|
233
|
-
"@modern-js/runtime-utils": "2.65.
|
|
234
|
-
"@modern-js/types": "2.65.
|
|
235
|
-
"@modern-js/utils": "2.65.
|
|
229
|
+
"@modern-js/plugin": "2.65.4",
|
|
230
|
+
"@modern-js/plugin-data-loader": "2.65.4",
|
|
231
|
+
"@modern-js/plugin-v2": "2.65.4",
|
|
232
|
+
"@modern-js/render": "2.65.4",
|
|
233
|
+
"@modern-js/runtime-utils": "2.65.4",
|
|
234
|
+
"@modern-js/types": "2.65.4",
|
|
235
|
+
"@modern-js/utils": "2.65.4"
|
|
236
236
|
},
|
|
237
237
|
"peerDependencies": {
|
|
238
238
|
"react": ">=17",
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
},
|
|
241
241
|
"devDependencies": {
|
|
242
242
|
"@remix-run/web-fetch": "^4.1.3",
|
|
243
|
-
"@rsbuild/core": "1.2.
|
|
243
|
+
"@rsbuild/core": "1.2.18",
|
|
244
244
|
"@testing-library/react": "^13.4.0",
|
|
245
245
|
"@types/cookie": "0.6.0",
|
|
246
246
|
"@types/invariant": "^2.2.30",
|
|
@@ -256,9 +256,9 @@
|
|
|
256
256
|
"ts-node": "^10.9.1",
|
|
257
257
|
"typescript": "^5",
|
|
258
258
|
"webpack": "^5.98.0",
|
|
259
|
-
"@modern-js/app-tools": "2.65.
|
|
260
|
-
"@scripts/build": "2.65.
|
|
261
|
-
"@scripts/jest-config": "2.65.
|
|
259
|
+
"@modern-js/app-tools": "2.65.4",
|
|
260
|
+
"@scripts/build": "2.65.4",
|
|
261
|
+
"@scripts/jest-config": "2.65.4"
|
|
262
262
|
},
|
|
263
263
|
"sideEffects": false,
|
|
264
264
|
"publishConfig": {
|