@bleedingdev/modern-js-runtime 3.5.0-ultramodern.10 → 3.5.0-ultramodern.11
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/core/context/public.js +49 -0
- package/dist/cjs/core/context/runtime.js +7 -10
- package/dist/cjs/index.js +7 -6
- package/dist/cjs/router/runtime/hooks.js +7 -6
- package/dist/esm/core/context/public.mjs +5 -0
- package/dist/esm/core/context/runtime.mjs +3 -6
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/router/runtime/hooks.mjs +7 -6
- package/dist/esm-node/core/context/public.mjs +6 -0
- package/dist/esm-node/core/context/runtime.mjs +3 -6
- package/dist/esm-node/index.mjs +2 -1
- package/dist/esm-node/router/runtime/hooks.mjs +7 -6
- package/dist/types/boundary-debugger/index.d.ts +1 -1
- package/dist/types/common.d.ts +8 -1
- package/dist/types/core/context/index.d.ts +24 -8
- package/dist/types/core/context/monitors/default.d.ts +10 -2
- package/dist/types/core/context/monitors/index.d.ts +1 -1
- package/dist/types/core/context/monitors/index.server.d.ts +2 -2
- package/dist/types/core/context/public.d.ts +26 -0
- package/dist/types/core/context/runtime.d.ts +15 -28
- package/dist/types/core/react/index.d.ts +1 -1
- package/dist/types/index.d.ts +5 -5
- package/dist/types/internal.d.ts +0 -1
- package/dist/types/router/runtime/hooks.d.ts +10 -6
- package/dist/types/router/runtime/internal.d.ts +1 -1
- package/dist/types/router/runtime/plugin.d.ts +1 -1
- package/dist/types/router/runtime/plugin.node.d.ts +1 -1
- package/dist/types/router/runtime/provider.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +26 -4
- package/package.json +8 -8
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
ReactRuntimeContext: ()=>ReactRuntimeContext,
|
|
32
|
+
RuntimeContext: ()=>RuntimeContext,
|
|
33
|
+
useRuntimeContext: ()=>useRuntimeContext
|
|
34
|
+
});
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const RuntimeContext = (0, external_react_namespaceObject.createContext)({});
|
|
37
|
+
const ReactRuntimeContext = RuntimeContext;
|
|
38
|
+
const useRuntimeContext = ()=>(0, external_react_namespaceObject.useContext)(RuntimeContext);
|
|
39
|
+
exports.ReactRuntimeContext = __webpack_exports__.ReactRuntimeContext;
|
|
40
|
+
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
41
|
+
exports.useRuntimeContext = __webpack_exports__.useRuntimeContext;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"ReactRuntimeContext",
|
|
44
|
+
"RuntimeContext",
|
|
45
|
+
"useRuntimeContext"
|
|
46
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
47
|
+
Object.defineProperty(exports, '__esModule', {
|
|
48
|
+
value: true
|
|
49
|
+
});
|
|
@@ -29,16 +29,14 @@ var __webpack_exports__ = {};
|
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
31
|
InternalRuntimeContext: ()=>InternalRuntimeContext,
|
|
32
|
-
ReactRuntimeContext: ()=>ReactRuntimeContext,
|
|
33
|
-
RuntimeContext: ()=>RuntimeContext,
|
|
32
|
+
ReactRuntimeContext: ()=>external_public_js_namespaceObject.ReactRuntimeContext,
|
|
33
|
+
RuntimeContext: ()=>external_public_js_namespaceObject.RuntimeContext,
|
|
34
34
|
getInitialContext: ()=>getInitialContext,
|
|
35
|
-
useRuntimeContext: ()=>useRuntimeContext
|
|
35
|
+
useRuntimeContext: ()=>external_public_js_namespaceObject.useRuntimeContext
|
|
36
36
|
});
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const InternalRuntimeContext =
|
|
40
|
-
const RuntimeContext = (0, external_react_namespaceObject.createContext)({});
|
|
41
|
-
const ReactRuntimeContext = RuntimeContext;
|
|
37
|
+
const external_public_js_namespaceObject = require("./public.js");
|
|
38
|
+
const ROUTE_MANIFEST = '_MODERNJS_ROUTE_MANIFEST';
|
|
39
|
+
const InternalRuntimeContext = external_public_js_namespaceObject.RuntimeContext;
|
|
42
40
|
const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
43
41
|
const requestContext = {
|
|
44
42
|
request: {},
|
|
@@ -46,12 +44,11 @@ const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
|
46
44
|
};
|
|
47
45
|
return {
|
|
48
46
|
isBrowser,
|
|
49
|
-
routeManifest: routeManifest || "u" > typeof window && window[
|
|
47
|
+
routeManifest: routeManifest || "u" > typeof window && window[ROUTE_MANIFEST],
|
|
50
48
|
requestContext,
|
|
51
49
|
context: requestContext
|
|
52
50
|
};
|
|
53
51
|
};
|
|
54
|
-
const useRuntimeContext = ()=>(0, external_react_namespaceObject.useContext)(RuntimeContext);
|
|
55
52
|
exports.InternalRuntimeContext = __webpack_exports__.InternalRuntimeContext;
|
|
56
53
|
exports.ReactRuntimeContext = __webpack_exports__.ReactRuntimeContext;
|
|
57
54
|
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
package/dist/cjs/index.js
CHANGED
|
@@ -28,19 +28,20 @@ var __webpack_require__ = {};
|
|
|
28
28
|
var __webpack_exports__ = {};
|
|
29
29
|
__webpack_require__.r(__webpack_exports__);
|
|
30
30
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
RuntimeContext: ()=>
|
|
32
|
-
defineRuntimeConfig: ()=>
|
|
33
|
-
getMonitors: ()=>
|
|
31
|
+
RuntimeContext: ()=>public_js_namespaceObject.RuntimeContext,
|
|
32
|
+
defineRuntimeConfig: ()=>config_js_namespaceObject.defineRuntimeConfig,
|
|
33
|
+
getMonitors: ()=>index_js_namespaceObject.getMonitors,
|
|
34
34
|
getRequest: ()=>request_index_js_namespaceObject.getRequest,
|
|
35
35
|
isBrowser: ()=>external_common_js_namespaceObject.isBrowser,
|
|
36
36
|
redirect: ()=>response_index_js_namespaceObject.redirect,
|
|
37
37
|
setHeaders: ()=>response_index_js_namespaceObject.setHeaders,
|
|
38
38
|
setStatus: ()=>response_index_js_namespaceObject.setStatus,
|
|
39
|
-
useRuntimeContext: ()=>
|
|
39
|
+
useRuntimeContext: ()=>public_js_namespaceObject.useRuntimeContext
|
|
40
40
|
});
|
|
41
41
|
const external_common_js_namespaceObject = require("./common.js");
|
|
42
|
-
const
|
|
43
|
-
const
|
|
42
|
+
const config_js_namespaceObject = require("./core/config.js");
|
|
43
|
+
const index_js_namespaceObject = require("./core/context/monitors/index.js");
|
|
44
|
+
const public_js_namespaceObject = require("./core/context/public.js");
|
|
44
45
|
const request_index_js_namespaceObject = require("./core/context/request/index.js");
|
|
45
46
|
const response_index_js_namespaceObject = require("./core/context/response/index.js");
|
|
46
47
|
exports.RuntimeContext = __webpack_exports__.RuntimeContext;
|
|
@@ -36,12 +36,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
onBeforeHydrateRouter: ()=>onBeforeHydrateRouter
|
|
37
37
|
});
|
|
38
38
|
const plugin_namespaceObject = require("@modern-js/plugin");
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
39
|
+
const createRouterSyncHook = ()=>(0, plugin_namespaceObject.createSyncHook)();
|
|
40
|
+
const modifyRoutes = createRouterSyncHook();
|
|
41
|
+
const onBeforeCreateRoutes = createRouterSyncHook();
|
|
42
|
+
const onBeforeCreateRouter = createRouterSyncHook();
|
|
43
|
+
const onAfterCreateRouter = createRouterSyncHook();
|
|
44
|
+
const onBeforeHydrateRouter = createRouterSyncHook();
|
|
45
|
+
const onAfterHydrateRouter = createRouterSyncHook();
|
|
45
46
|
exports.modifyRoutes = __webpack_exports__.modifyRoutes;
|
|
46
47
|
exports.onAfterCreateRouter = __webpack_exports__.onAfterCreateRouter;
|
|
47
48
|
exports.onAfterHydrateRouter = __webpack_exports__.onAfterHydrateRouter;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const InternalRuntimeContext =
|
|
4
|
-
const RuntimeContext = createContext({});
|
|
5
|
-
const ReactRuntimeContext = RuntimeContext;
|
|
1
|
+
import { ReactRuntimeContext, RuntimeContext, useRuntimeContext } from "./public.mjs";
|
|
2
|
+
const ROUTE_MANIFEST = '_MODERNJS_ROUTE_MANIFEST';
|
|
3
|
+
const InternalRuntimeContext = RuntimeContext;
|
|
6
4
|
const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
7
5
|
const requestContext = {
|
|
8
6
|
request: {},
|
|
@@ -15,5 +13,4 @@ const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
|
15
13
|
context: requestContext
|
|
16
14
|
};
|
|
17
15
|
};
|
|
18
|
-
const useRuntimeContext = ()=>useContext(RuntimeContext);
|
|
19
16
|
export { InternalRuntimeContext, ReactRuntimeContext, RuntimeContext, getInitialContext, useRuntimeContext };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { isBrowser } from "./common.mjs";
|
|
2
|
-
export {
|
|
2
|
+
export { defineRuntimeConfig } from "./core/config.mjs";
|
|
3
3
|
export { getMonitors } from "./core/context/monitors/index.mjs";
|
|
4
|
+
export { RuntimeContext, useRuntimeContext } from "./core/context/public.mjs";
|
|
4
5
|
export { getRequest } from "./core/context/request/index.mjs";
|
|
5
6
|
export { redirect, setHeaders, setStatus } from "./core/context/response/index.mjs";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createSyncHook } from "@modern-js/plugin";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
2
|
+
const createRouterSyncHook = ()=>createSyncHook();
|
|
3
|
+
const modifyRoutes = createRouterSyncHook();
|
|
4
|
+
const onBeforeCreateRoutes = createRouterSyncHook();
|
|
5
|
+
const onBeforeCreateRouter = createRouterSyncHook();
|
|
6
|
+
const onAfterCreateRouter = createRouterSyncHook();
|
|
7
|
+
const onBeforeHydrateRouter = createRouterSyncHook();
|
|
8
|
+
const onAfterHydrateRouter = createRouterSyncHook();
|
|
8
9
|
export { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const RuntimeContext = createContext({});
|
|
4
|
+
const ReactRuntimeContext = RuntimeContext;
|
|
5
|
+
const useRuntimeContext = ()=>useContext(RuntimeContext);
|
|
6
|
+
export { ReactRuntimeContext, RuntimeContext, useRuntimeContext };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const InternalRuntimeContext =
|
|
5
|
-
const RuntimeContext = createContext({});
|
|
6
|
-
const ReactRuntimeContext = RuntimeContext;
|
|
2
|
+
import { ReactRuntimeContext, RuntimeContext, useRuntimeContext } from "./public.mjs";
|
|
3
|
+
const ROUTE_MANIFEST = '_MODERNJS_ROUTE_MANIFEST';
|
|
4
|
+
const InternalRuntimeContext = RuntimeContext;
|
|
7
5
|
const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
8
6
|
const requestContext = {
|
|
9
7
|
request: {},
|
|
@@ -16,5 +14,4 @@ const getInitialContext = (isBrowser = true, routeManifest)=>{
|
|
|
16
14
|
context: requestContext
|
|
17
15
|
};
|
|
18
16
|
};
|
|
19
|
-
const useRuntimeContext = ()=>useContext(RuntimeContext);
|
|
20
17
|
export { InternalRuntimeContext, ReactRuntimeContext, RuntimeContext, getInitialContext, useRuntimeContext };
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
export { isBrowser } from "./common.mjs";
|
|
3
|
-
export {
|
|
3
|
+
export { defineRuntimeConfig } from "./core/config.mjs";
|
|
4
4
|
export { getMonitors } from "./core/context/monitors/index.mjs";
|
|
5
|
+
export { RuntimeContext, useRuntimeContext } from "./core/context/public.mjs";
|
|
5
6
|
export { getRequest } from "./core/context/request/index.mjs";
|
|
6
7
|
export { redirect, setHeaders, setStatus } from "./core/context/response/index.mjs";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { createSyncHook } from "@modern-js/plugin";
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
3
|
+
const createRouterSyncHook = ()=>createSyncHook();
|
|
4
|
+
const modifyRoutes = createRouterSyncHook();
|
|
5
|
+
const onBeforeCreateRoutes = createRouterSyncHook();
|
|
6
|
+
const onBeforeCreateRouter = createRouterSyncHook();
|
|
7
|
+
const onAfterCreateRouter = createRouterSyncHook();
|
|
8
|
+
const onBeforeHydrateRouter = createRouterSyncHook();
|
|
9
|
+
const onAfterHydrateRouter = createRouterSyncHook();
|
|
9
10
|
export { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter };
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import type { RuntimePlugin } from './core/plugin';
|
|
2
1
|
export declare const isBrowser: () => boolean;
|
|
2
|
+
export type RuntimePlugin<Extends = unknown> = {
|
|
3
|
+
name?: string;
|
|
4
|
+
registryHooks?: Extends extends {
|
|
5
|
+
extendHooks: infer Hooks;
|
|
6
|
+
} ? Hooks : Record<string, unknown>;
|
|
7
|
+
setup?: (...args: any[]) => unknown;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
3
10
|
export interface RuntimeConfig {
|
|
4
11
|
plugins?: RuntimePlugin[];
|
|
5
12
|
[key: string]: any;
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import type { InternalRuntimeContext } from '@modern-js/plugin';
|
|
2
|
-
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
3
1
|
import type React from 'react';
|
|
4
|
-
import type { RuntimeExtends } from '../plugin/types';
|
|
5
2
|
import type { ServerPayload } from './serverPayload/index';
|
|
3
|
+
export type RuntimeRoute = {
|
|
4
|
+
children?: RuntimeRoute[];
|
|
5
|
+
routes?: RuntimeRoute[];
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
type RuntimeHookCaller = {
|
|
9
|
+
call: (...args: any[]) => any;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
type RuntimeHooks = Record<string, RuntimeHookCaller>;
|
|
13
|
+
type RuntimePluginAPI = {
|
|
14
|
+
updateRuntimeContext?: (context: unknown) => unknown;
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
};
|
|
17
|
+
type InternalRuntimeContextLike = {
|
|
18
|
+
hooks: RuntimeHooks;
|
|
19
|
+
pluginAPI?: RuntimePluginAPI;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
};
|
|
6
22
|
export { DefaultNotFound } from '../../router/runtime/DefaultNotFound';
|
|
7
23
|
export { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter, type RouterExtendsHooks, } from '../../router/runtime/hooks';
|
|
8
24
|
export { applyRouterRuntimeState, applyRouterServerPrepareResult, cleanupRouterRuntimeState, createRouterRuntimeState, createRouterServerSnapshot, getRouterHydrationScripts, getRouterMatchedRouteIds, getRouterRuntimeState, getRouterServerSnapshot, type RouterLifecycleContext, type RouterLifecyclePhase, } from '../../router/runtime/lifecycle';
|
|
@@ -20,7 +36,7 @@ interface GlobalContext {
|
|
|
20
36
|
/**
|
|
21
37
|
* nest router and page router config
|
|
22
38
|
*/
|
|
23
|
-
routes?:
|
|
39
|
+
routes?: RuntimeRoute[];
|
|
24
40
|
/**
|
|
25
41
|
* nest router init function
|
|
26
42
|
*/
|
|
@@ -33,7 +49,7 @@ interface GlobalContext {
|
|
|
33
49
|
* Entry basename for routing
|
|
34
50
|
*/
|
|
35
51
|
basename?: string;
|
|
36
|
-
internalRuntimeContext?:
|
|
52
|
+
internalRuntimeContext?: InternalRuntimeContextLike;
|
|
37
53
|
/**
|
|
38
54
|
* RSCRoot
|
|
39
55
|
*/
|
|
@@ -48,9 +64,9 @@ export declare function getGlobalEnableRsc(): boolean | undefined;
|
|
|
48
64
|
export declare function setGlobalContext(context: Omit<GlobalContext, 'internalRuntimeContext'>): void;
|
|
49
65
|
export declare function getCurrentEntryName(): string | undefined;
|
|
50
66
|
export declare function getGlobalRSCRoot(): React.ComponentType<{}> | undefined;
|
|
51
|
-
export declare function setGlobalInternalRuntimeContext(context:
|
|
52
|
-
export declare function getGlobalInternalRuntimeContext():
|
|
67
|
+
export declare function setGlobalInternalRuntimeContext(context: InternalRuntimeContextLike): void;
|
|
68
|
+
export declare function getGlobalInternalRuntimeContext(): InternalRuntimeContextLike;
|
|
53
69
|
export declare function getGlobalApp(): React.ComponentType<{}> | undefined;
|
|
54
|
-
export declare function getGlobalRoutes(): undefined |
|
|
70
|
+
export declare function getGlobalRoutes(): undefined | RuntimeRoute[];
|
|
55
71
|
export declare function getGlobalLayoutApp(): React.ComponentType<{}> | undefined;
|
|
56
72
|
export declare function getGlobalBasename(): string | undefined;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export type RuntimeMonitors = {
|
|
2
|
+
counter: (name: string, ...args: any[]) => void;
|
|
3
|
+
info: (...args: any[]) => void;
|
|
4
|
+
debug: (...args: any[]) => void;
|
|
5
|
+
trace: (...args: any[]) => void;
|
|
6
|
+
warn: (...args: any[]) => void;
|
|
7
|
+
error: (...args: any[]) => void;
|
|
8
|
+
timing: (name: string, dur: number, ...args: any[]) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const defaultMonitors: RuntimeMonitors;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getMonitors: () =>
|
|
1
|
+
export declare const getMonitors: () => import("./default").RuntimeMonitors;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const getMonitors: () =>
|
|
1
|
+
import { type RuntimeMonitors } from './default';
|
|
2
|
+
export declare const getMonitors: () => RuntimeMonitors;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type RuntimeRequest = Record<string, unknown>;
|
|
2
|
+
export type RuntimeResponse = Record<string, unknown>;
|
|
3
|
+
export type RequestContext = {
|
|
4
|
+
request: RuntimeRequest;
|
|
5
|
+
response: RuntimeResponse;
|
|
6
|
+
};
|
|
7
|
+
export interface TRuntimeContext {
|
|
8
|
+
initialData?: Record<string, unknown>;
|
|
9
|
+
isBrowser: boolean;
|
|
10
|
+
routes?: unknown[];
|
|
11
|
+
requestContext: RequestContext;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `requestContext` instead
|
|
14
|
+
*/
|
|
15
|
+
context: RequestContext;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare const RuntimeContext: import("react").Context<TRuntimeContext>;
|
|
19
|
+
/**
|
|
20
|
+
* deprecated, use RuntimeContext instead
|
|
21
|
+
*/
|
|
22
|
+
export declare const ReactRuntimeContext: import("react").Context<TRuntimeContext>;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated use use(RuntimeContext) instead
|
|
25
|
+
*/
|
|
26
|
+
export declare const useRuntimeContext: () => TRuntimeContext;
|
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
context: RequestContext;
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
}
|
|
1
|
+
import type { Context } from 'react';
|
|
2
|
+
import { type RequestContext, type TRuntimeContext } from './public';
|
|
3
|
+
export type InternalSSRContext = {
|
|
4
|
+
request: RequestContext['request'] & {
|
|
5
|
+
raw?: Request;
|
|
6
|
+
};
|
|
7
|
+
response: RequestContext['response'];
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
export { ReactRuntimeContext, RuntimeContext, type TRuntimeContext, useRuntimeContext, } from './public';
|
|
15
11
|
/**
|
|
16
12
|
* InternalRuntimeContext used internally and by plugins
|
|
17
13
|
*/
|
|
18
14
|
export interface TInternalRuntimeContext extends TRuntimeContext {
|
|
19
|
-
routeManifest?:
|
|
20
|
-
routerContext?:
|
|
15
|
+
routeManifest?: Record<string, unknown>;
|
|
16
|
+
routerContext?: unknown;
|
|
21
17
|
unstable_getBlockNavState?: () => boolean;
|
|
22
|
-
ssrContext?:
|
|
18
|
+
ssrContext?: InternalSSRContext;
|
|
23
19
|
_internalContext?: any;
|
|
24
20
|
_internalRouterBaseName?: any;
|
|
25
21
|
}
|
|
26
|
-
export declare const InternalRuntimeContext:
|
|
27
|
-
export declare const
|
|
28
|
-
/**
|
|
29
|
-
* deprecated, use RuntimeContext instead
|
|
30
|
-
*/
|
|
31
|
-
export declare const ReactRuntimeContext: import("react").Context<TRuntimeContext>;
|
|
32
|
-
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: RouteManifest) => TInternalRuntimeContext;
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated use use(RuntimeContext) instead
|
|
35
|
-
*/
|
|
36
|
-
export declare const useRuntimeContext: () => TRuntimeContext;
|
|
22
|
+
export declare const InternalRuntimeContext: Context<TInternalRuntimeContext>;
|
|
23
|
+
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: Record<string, unknown>) => TInternalRuntimeContext;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
export declare function createRoot(UserApp?: React.ComponentType | null):
|
|
2
|
+
export declare function createRoot(UserApp?: React.ComponentType | null): any;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { RouterConfig } from './router/
|
|
2
|
-
export type { RuntimeConfig } from './common';
|
|
1
|
+
import type { RouterConfig } from './router/runtime/types';
|
|
2
|
+
export type { RuntimeConfig, RuntimePlugin } from './common';
|
|
3
3
|
export { isBrowser } from './common';
|
|
4
|
-
export
|
|
5
|
-
export { defineRuntimeConfig, RuntimeContext, useRuntimeContext, } from './core';
|
|
4
|
+
export { defineRuntimeConfig } from './core/config';
|
|
6
5
|
export { getMonitors } from './core/context/monitors';
|
|
6
|
+
export type { TRuntimeContext } from './core/context/public';
|
|
7
|
+
export { RuntimeContext, useRuntimeContext, } from './core/context/public';
|
|
7
8
|
export { getRequest } from './core/context/request';
|
|
8
9
|
export { redirect, setHeaders, setStatus } from './core/context/response';
|
|
9
|
-
export type { TRuntimeContext } from './core/context/runtime';
|
|
10
10
|
export type { RouterConfig };
|
package/dist/types/internal.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
2
|
import type { TRuntimeContext } from '../../core/context/runtime';
|
|
3
3
|
import type { RouterLifecycleContext } from './lifecycle';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
4
|
+
export type RouterSyncHook<Handler extends (...args: any[]) => any> = {
|
|
5
|
+
call: (...args: Parameters<Handler>) => ReturnType<Handler>;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
declare const modifyRoutes: RouterSyncHook<(routes: RouteObject[]) => RouteObject[]>;
|
|
9
|
+
declare const onBeforeCreateRoutes: RouterSyncHook<(context: TRuntimeContext) => void>;
|
|
10
|
+
declare const onBeforeCreateRouter: RouterSyncHook<(context: RouterLifecycleContext) => void>;
|
|
11
|
+
declare const onAfterCreateRouter: RouterSyncHook<(context: RouterLifecycleContext) => void>;
|
|
12
|
+
declare const onBeforeHydrateRouter: RouterSyncHook<(context: RouterLifecycleContext) => void>;
|
|
13
|
+
declare const onAfterHydrateRouter: RouterSyncHook<(context: RouterLifecycleContext) => void>;
|
|
10
14
|
export { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter, };
|
|
11
15
|
export type RouterExtendsHooks = {
|
|
12
16
|
modifyRoutes: typeof modifyRoutes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimePlugin } from '../../
|
|
1
|
+
import type { RuntimePlugin } from '../../common';
|
|
2
2
|
import type { RouterExtendsHooks } from './hooks';
|
|
3
3
|
import type { RouterConfig, SingleRouteConfig } from './types';
|
|
4
4
|
export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => RuntimePlugin<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RuntimePlugin } from '../../common';
|
|
2
2
|
import type { RouterExtendsHooks } from './hooks';
|
|
3
3
|
import type { RouterConfig, Routes } from './types';
|
|
4
4
|
export declare let finalRouteConfig: RouterConfig['routesConfig'];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimePlugin } from '../../
|
|
1
|
+
import type { RuntimePlugin } from '../../common';
|
|
2
2
|
import type { RouterExtendsHooks } from './hooks';
|
|
3
3
|
import type { RouterConfig } from './types';
|
|
4
4
|
export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => RuntimePlugin<{
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - `@modern-js/plugin-tanstack` registers the `tanstack` provider when its
|
|
12
12
|
* runtime entry is imported.
|
|
13
13
|
*/
|
|
14
|
-
import type { RuntimePlugin } from '../../
|
|
14
|
+
import type { RuntimePlugin } from '../../common';
|
|
15
15
|
import type { RouterExtendsHooks } from './hooks';
|
|
16
16
|
import type { RouterConfig } from './types';
|
|
17
17
|
/**
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type { RequestContext } from '@modern-js/runtime-utils/node';
|
|
2
1
|
import type { Params, RouteObject, RouteProps } from '@modern-js/runtime-utils/router';
|
|
3
|
-
|
|
2
|
+
export type ModernRoute = {
|
|
3
|
+
type: 'nested' | 'page';
|
|
4
|
+
path?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
component?: React.ComponentType | string;
|
|
7
|
+
children?: ModernRoute[];
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
4
10
|
export type SingleRouteConfig = RouteProps & {
|
|
5
11
|
redirect?: string;
|
|
6
12
|
routes?: SingleRouteConfig[];
|
|
@@ -25,7 +31,7 @@ export type RouterConfig = {
|
|
|
25
31
|
framework?: RouterFramework;
|
|
26
32
|
routesConfig: {
|
|
27
33
|
globalApp?: React.ComponentType<any>;
|
|
28
|
-
routes?:
|
|
34
|
+
routes?: ModernRoute[];
|
|
29
35
|
};
|
|
30
36
|
/**
|
|
31
37
|
* You should not use it
|
|
@@ -108,12 +114,28 @@ export type ModernRouteObject = RouteObject & {
|
|
|
108
114
|
component?: React.ComponentType | LazyComponentDescriptor;
|
|
109
115
|
entryCssFiles?: string[];
|
|
110
116
|
};
|
|
117
|
+
type LoaderContextKey<T = unknown> = {
|
|
118
|
+
symbol: symbol;
|
|
119
|
+
getDefaultValue: () => T;
|
|
120
|
+
};
|
|
121
|
+
interface LoaderRequestGet<P extends Record<string, unknown>> {
|
|
122
|
+
<Key extends keyof P>(key: Key): P[Key];
|
|
123
|
+
<T>(key: LoaderContextKey<T>): T;
|
|
124
|
+
}
|
|
125
|
+
interface LoaderRequestSet<P extends Record<string, unknown>> {
|
|
126
|
+
<Key extends keyof P>(key: Key, value: P[Key]): void;
|
|
127
|
+
<T>(key: LoaderContextKey<T>, value: T): void;
|
|
128
|
+
}
|
|
129
|
+
type LoaderRequestContext<P extends Record<string, unknown> = {}> = {
|
|
130
|
+
get: LoaderRequestGet<P & Record<string, unknown>>;
|
|
131
|
+
set: LoaderRequestSet<P & Record<string, unknown>>;
|
|
132
|
+
};
|
|
111
133
|
interface DataFunctionArgs<D = any> {
|
|
112
134
|
request: Request;
|
|
113
135
|
params: Params;
|
|
114
136
|
context?: D;
|
|
115
137
|
}
|
|
116
|
-
export type LoaderFunctionArgs<P extends Record<string, unknown> = Record<string, unknown>> = DataFunctionArgs<
|
|
138
|
+
export type LoaderFunctionArgs<P extends Record<string, unknown> = Record<string, unknown>> = DataFunctionArgs<LoaderRequestContext<P>>;
|
|
117
139
|
declare type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
118
140
|
export type LoaderFunction = <P extends Record<string, unknown> = Record<string, unknown>>(args: LoaderFunctionArgs<P>) => Promise<DataFunctionValue> | DataFunctionValue;
|
|
119
141
|
export {};
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.5.0-ultramodern.
|
|
20
|
+
"version": "3.5.0-ultramodern.11",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
@@ -240,12 +240,12 @@
|
|
|
240
240
|
"react-helmet": "^6.1.0",
|
|
241
241
|
"react-helmet-async": "3.0.0",
|
|
242
242
|
"react-is": "^19.2.7",
|
|
243
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.
|
|
244
|
-
"@modern-js/
|
|
245
|
-
"@modern-js/
|
|
246
|
-
"@modern-js/
|
|
247
|
-
"@modern-js/
|
|
248
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.
|
|
243
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.11",
|
|
244
|
+
"@modern-js/render": "npm:@bleedingdev/modern-js-render@3.5.0-ultramodern.11",
|
|
245
|
+
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.5.0-ultramodern.11",
|
|
246
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.11",
|
|
247
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.11",
|
|
248
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.11"
|
|
249
249
|
},
|
|
250
250
|
"peerDependencies": {
|
|
251
251
|
"react": "^19.2.7",
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
"react-dom": "^19.2.7",
|
|
266
266
|
"ts-node": "^10.9.2",
|
|
267
267
|
"typescript": "^6.0.3",
|
|
268
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.
|
|
268
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.11",
|
|
269
269
|
"@scripts/rstest-config": "2.66.0"
|
|
270
270
|
},
|
|
271
271
|
"sideEffects": false,
|