@bleedingdev/modern-js-runtime 3.5.0-ultramodern.9 → 3.5.0-ultramodern.91
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/boundary-debugger/index.js +13 -3
- package/dist/cjs/cli/registry.js +18 -0
- package/dist/cjs/cli/ssr/index.js +3 -2
- package/dist/cjs/cli/ssr/loadable-bundler-plugin.js +8 -4
- package/dist/cjs/core/browser/hydrate.js +16 -2
- package/dist/cjs/core/browser/index.js +15 -3
- package/dist/cjs/core/context/index.js +3 -0
- package/dist/cjs/core/context/public.js +49 -0
- package/dist/cjs/core/context/runtime.js +6 -8
- package/dist/cjs/core/react/wrapper.js +57 -0
- package/dist/cjs/core/server/federatedCss.js +7 -3
- package/dist/cjs/core/server/requestHandler.js +15 -45
- package/dist/cjs/core/server/requestResponse.js +83 -0
- package/dist/cjs/core/server/routerCleanup.js +16 -6
- package/dist/cjs/core/server/scriptOrder.js +13 -10
- package/dist/cjs/core/server/stream/afterTemplate.js +9 -5
- package/dist/cjs/core/server/stream/template.js +3 -3
- package/dist/cjs/core/server/string/loadable.js +3 -11
- package/dist/cjs/index.js +7 -6
- package/dist/cjs/module-federation/consume-surface.js +199 -0
- package/dist/cjs/module-federation/distributed-ssr.js +134 -0
- package/dist/cjs/module-federation/index.js +258 -120
- package/dist/cjs/module-federation/last-known-good.js +124 -0
- package/dist/cjs/module-federation/manifest-recovery-runtime-plugin.js +140 -0
- package/dist/cjs/module-federation/surface-resolution-types.js +61 -0
- package/dist/cjs/router/cli/code/nestedRoutes.js +3 -0
- package/dist/cjs/router/cli/code/templates.js +3 -2
- package/dist/cjs/router/cli/constants.js +1 -0
- package/dist/cjs/router/cli/nestedRoutesSpec.js +3 -1
- package/dist/cjs/router/runtime/hooks.js +7 -6
- package/dist/cjs/router/runtime/internal.js +30 -16
- package/dist/cjs/router/runtime/plugin.js +6 -7
- package/dist/cjs/router/runtime/provider.js +58 -12
- package/dist/esm/boundary-debugger/index.mjs +13 -3
- package/dist/esm/cli/code.mjs +12 -12
- package/dist/esm/cli/registry.mjs +0 -0
- package/dist/esm/cli/ssr/index.mjs +3 -2
- package/dist/esm/cli/ssr/loadable-bundler-plugin.mjs +8 -4
- package/dist/esm/core/browser/hydrate.mjs +15 -4
- package/dist/esm/core/browser/index.mjs +11 -5
- package/dist/esm/core/context/index.mjs +1 -1
- package/dist/esm/core/context/public.mjs +5 -0
- package/dist/esm/core/context/runtime.mjs +4 -6
- package/dist/esm/core/react/wrapper.mjs +58 -1
- package/dist/esm/core/server/federatedCss.mjs +7 -3
- package/dist/esm/core/server/requestHandler.mjs +15 -45
- package/dist/esm/core/server/requestResponse.mjs +39 -0
- package/dist/esm/core/server/routerCleanup.mjs +11 -4
- package/dist/esm/core/server/scriptOrder.mjs +11 -8
- package/dist/esm/core/server/stream/afterTemplate.mjs +10 -6
- package/dist/esm/core/server/stream/template.mjs +3 -3
- package/dist/esm/core/server/string/loadable.mjs +3 -8
- package/dist/esm/exports/loadable.mjs +3 -3
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/module-federation/consume-surface.mjs +158 -0
- package/dist/esm/module-federation/distributed-ssr.mjs +81 -0
- package/dist/esm/module-federation/index.mjs +6 -0
- package/dist/esm/module-federation/last-known-good.mjs +80 -0
- package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +100 -0
- package/dist/esm/module-federation/surface-resolution-types.mjs +8 -0
- package/dist/esm/router/cli/code/index.mjs +5 -5
- package/dist/esm/router/cli/code/nestedRoutes.mjs +3 -0
- package/dist/esm/router/cli/code/templates.mjs +3 -2
- package/dist/esm/router/cli/constants.mjs +1 -0
- package/dist/esm/router/cli/handler.mjs +3 -3
- package/dist/esm/router/cli/nestedRoutesSpec.mjs +3 -1
- package/dist/esm/router/runtime/hooks.mjs +7 -6
- package/dist/esm/router/runtime/internal.mjs +26 -18
- package/dist/esm/router/runtime/plugin.mjs +6 -7
- package/dist/esm/router/runtime/provider.mjs +56 -13
- package/dist/esm-node/boundary-debugger/index.mjs +13 -3
- package/dist/esm-node/cli/code.mjs +12 -12
- package/dist/esm-node/cli/registry.mjs +1 -0
- package/dist/esm-node/cli/ssr/index.mjs +3 -2
- package/dist/esm-node/cli/ssr/loadable-bundler-plugin.mjs +8 -4
- package/dist/esm-node/core/browser/hydrate.mjs +15 -4
- package/dist/esm-node/core/browser/index.mjs +11 -5
- package/dist/esm-node/core/context/index.mjs +1 -1
- package/dist/esm-node/core/context/public.mjs +6 -0
- package/dist/esm-node/core/context/runtime.mjs +4 -6
- package/dist/esm-node/core/react/wrapper.mjs +58 -1
- package/dist/esm-node/core/server/federatedCss.mjs +7 -3
- package/dist/esm-node/core/server/requestHandler.mjs +15 -45
- package/dist/esm-node/core/server/requestResponse.mjs +40 -0
- package/dist/esm-node/core/server/routerCleanup.mjs +11 -4
- package/dist/esm-node/core/server/scriptOrder.mjs +11 -8
- package/dist/esm-node/core/server/stream/afterTemplate.mjs +10 -6
- package/dist/esm-node/core/server/stream/template.mjs +3 -3
- package/dist/esm-node/core/server/string/loadable.mjs +3 -8
- package/dist/esm-node/exports/loadable.mjs +3 -3
- package/dist/esm-node/index.mjs +2 -1
- package/dist/esm-node/module-federation/consume-surface.mjs +159 -0
- package/dist/esm-node/module-federation/distributed-ssr.mjs +82 -0
- package/dist/esm-node/module-federation/index.mjs +6 -0
- package/dist/esm-node/module-federation/last-known-good.mjs +81 -0
- package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +101 -0
- package/dist/esm-node/module-federation/surface-resolution-types.mjs +9 -0
- package/dist/esm-node/router/cli/code/index.mjs +5 -5
- package/dist/esm-node/router/cli/code/nestedRoutes.mjs +3 -0
- package/dist/esm-node/router/cli/code/templates.mjs +3 -2
- package/dist/esm-node/router/cli/constants.mjs +1 -0
- package/dist/esm-node/router/cli/handler.mjs +3 -3
- package/dist/esm-node/router/cli/nestedRoutesSpec.mjs +3 -1
- package/dist/esm-node/router/runtime/hooks.mjs +7 -6
- package/dist/esm-node/router/runtime/internal.mjs +26 -18
- package/dist/esm-node/router/runtime/plugin.mjs +6 -7
- package/dist/esm-node/router/runtime/provider.mjs +56 -13
- package/dist/types/boundary-debugger/index.d.ts +1 -1
- package/dist/types/cli/registry.d.ts +2 -0
- package/dist/types/common.d.ts +8 -1
- package/dist/types/core/browser/hydrate.d.ts +2 -1
- package/dist/types/core/browser/index.d.ts +4 -0
- package/dist/types/core/context/index.d.ts +26 -10
- 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 +27 -0
- package/dist/types/core/context/runtime.d.ts +12 -22
- package/dist/types/core/react/index.d.ts +1 -1
- package/dist/types/core/server/requestResponse.d.ts +15 -0
- package/dist/types/core/server/routerCleanup.d.ts +2 -1
- package/dist/types/core/server/scriptOrder.d.ts +1 -1
- package/dist/types/core/server/stream/shared.d.ts +2 -2
- package/dist/types/core/server/string/loadable.d.ts +0 -2
- package/dist/types/exports/head.d.ts +1 -1
- package/dist/types/index.d.ts +5 -5
- package/dist/types/internal.d.ts +0 -1
- package/dist/types/module-federation/consume-surface.d.ts +104 -0
- package/dist/types/module-federation/distributed-ssr.d.ts +61 -0
- package/dist/types/module-federation/index.d.ts +6 -0
- package/dist/types/module-federation/last-known-good.d.ts +72 -0
- package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +25 -0
- package/dist/types/module-federation/surface-resolution-types.d.ts +23 -0
- package/dist/types/router/cli/constants.d.ts +1 -0
- package/dist/types/router/runtime/hooks.d.ts +10 -6
- package/dist/types/router/runtime/internal.d.ts +13 -3
- 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 +28 -11
- package/dist/types/router/runtime/types.d.ts +27 -5
- package/package.json +46 -27
- package/dist/cjs/exports/tanstack-router.js +0 -83
- package/dist/esm/exports/tanstack-router.mjs +0 -30
- package/dist/esm-node/exports/tanstack-router.mjs +0 -31
- package/dist/types/exports/tanstack-router.d.ts +0 -88
|
@@ -1,13 +1,29 @@
|
|
|
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';
|
|
9
|
-
export { type RouterProviderFactory, type RouterProviderPlugin, registerRouterProvider, resolveRouterProvider, routerProviderRegistryHooks, } from '../../router/runtime/provider';
|
|
10
|
-
export type { BuiltInRouterFramework, InternalRouterRuntimeState, InternalRouterServerSnapshot, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult, } from '../../router/runtime/types';
|
|
25
|
+
export { createRouterProviderRealm, type RouterProviderFactory, type RouterProviderPlugin, type RouterProviderRealm, type RouterProviderRegistration, registerRouterProvider, resolveRouterProvider, routerProviderRegistryHooks, } from '../../router/runtime/provider';
|
|
26
|
+
export type { BuiltInRouterFramework, InternalRouterRuntimeState, InternalRouterServerSnapshot, LoaderFunction, LoaderFunctionArgs, ModernRoute, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult, } from '../../router/runtime/types';
|
|
11
27
|
export { createRuntimeContextExtension, type RuntimeContextExtension, } from './extensions';
|
|
12
28
|
export { getInitialContext, InternalRuntimeContext, RuntimeContext, type TInternalRuntimeContext, type TRuntimeContext, } from './runtime';
|
|
13
29
|
export type { PayloadRoute, ServerPayload } from './serverPayload/index';
|
|
@@ -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,27 @@
|
|
|
1
|
+
type RuntimeRequest = Record<string, unknown>;
|
|
2
|
+
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;
|
|
27
|
+
export {};
|
|
@@ -1,36 +1,26 @@
|
|
|
1
1
|
import type { RouteObject, StaticHandlerContext } from '@modern-js/runtime-utils/router';
|
|
2
|
+
import type { BaseSSRServerContext } from '@modern-js/types';
|
|
2
3
|
import type { RouteManifest } from '../../router/runtime/types';
|
|
3
|
-
import
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
context: RequestContext;
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
}
|
|
4
|
+
import { type TRuntimeContext } from './public';
|
|
5
|
+
export type InternalSSRContext = {
|
|
6
|
+
request: BaseSSRServerContext['request'] & {
|
|
7
|
+
raw?: Request;
|
|
8
|
+
};
|
|
9
|
+
response: BaseSSRServerContext['response'];
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
export { ReactRuntimeContext, RuntimeContext, type TRuntimeContext, useRuntimeContext, } from './public';
|
|
15
13
|
/**
|
|
16
14
|
* InternalRuntimeContext used internally and by plugins
|
|
17
15
|
*/
|
|
18
16
|
export interface TInternalRuntimeContext extends TRuntimeContext {
|
|
19
17
|
routeManifest?: RouteManifest;
|
|
18
|
+
routes?: RouteObject[];
|
|
20
19
|
routerContext?: StaticHandlerContext;
|
|
21
20
|
unstable_getBlockNavState?: () => boolean;
|
|
22
|
-
ssrContext?:
|
|
21
|
+
ssrContext?: InternalSSRContext;
|
|
23
22
|
_internalContext?: any;
|
|
24
23
|
_internalRouterBaseName?: any;
|
|
25
24
|
}
|
|
26
25
|
export declare const InternalRuntimeContext: import("react").Context<TInternalRuntimeContext>;
|
|
27
|
-
export declare const RuntimeContext: import("react").Context<TRuntimeContext>;
|
|
28
|
-
/**
|
|
29
|
-
* deprecated, use RuntimeContext instead
|
|
30
|
-
*/
|
|
31
|
-
export declare const ReactRuntimeContext: import("react").Context<TRuntimeContext>;
|
|
32
26
|
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: RouteManifest) => TInternalRuntimeContext;
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated use use(RuntimeContext) instead
|
|
35
|
-
*/
|
|
36
|
-
export declare const useRuntimeContext: () => TRuntimeContext;
|
|
@@ -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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OnError } from '@modern-js/app-tools';
|
|
2
|
+
import type { TInternalRuntimeContext } from '../context';
|
|
3
|
+
import type { RouterCleanup } from './routerCleanup';
|
|
4
|
+
export type ResponseProxy = {
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
status: number;
|
|
7
|
+
};
|
|
8
|
+
export type RedirectContext = {
|
|
9
|
+
enableRsc: boolean;
|
|
10
|
+
isRSCNavigation: boolean;
|
|
11
|
+
basename: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const applyRouterSnapshotResult: (context: TInternalRuntimeContext, onError: OnError) => void;
|
|
14
|
+
export declare const createLoaderRedirectResponse: (beforeRenderResult: Response | undefined, redirectCtx: RedirectContext) => Response | undefined;
|
|
15
|
+
export declare const finalizeRenderResponse: (response: Response, responseProxy: ResponseProxy, redirectCtx: RedirectContext, routerCleanup: RouterCleanup) => Response;
|
|
@@ -24,5 +24,6 @@ export type RouterCleanup = {
|
|
|
24
24
|
*/
|
|
25
25
|
deferUntilBodyDone: (response: Response) => Response;
|
|
26
26
|
};
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function runWithRouterCleanupOnError<T>(routerCleanup: RouterCleanup, callback: () => Promise<T> | T): Promise<T>;
|
|
28
|
+
export declare function finishWithRouterCleanup<T>(routerCleanup: RouterCleanup, callback: () => Promise<T> | T): Promise<T>;
|
|
28
29
|
export declare function createRouterCleanup(runtimeContext: TInternalRuntimeContext, onError: OnError): RouterCleanup;
|
|
@@ -9,7 +9,7 @@ type ScriptChunkLike = {
|
|
|
9
9
|
filename?: string;
|
|
10
10
|
url?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function getMatchedRouteChunks<T>(runtimeContext: TInternalRuntimeContext, routeManifest: RouteManifestLike | undefined, routeAssetToChunk: (asset: string) => T): T[];
|
|
13
13
|
export declare const orderHydrationScriptChunks: <T extends ScriptChunkLike>({ asyncEntryChunks, collectedChunks, matchedRouteChunks, entryName, }: {
|
|
14
14
|
asyncEntryChunks: T[];
|
|
15
15
|
collectedChunks: T[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OnError } from '@modern-js/app-tools';
|
|
2
2
|
import type { ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types/server';
|
|
3
3
|
import type React from 'react';
|
|
4
|
-
import type {
|
|
4
|
+
import type { TInternalRuntimeContext } from '../../context';
|
|
5
5
|
import type { HandleRequestConfig } from '../requestHandler';
|
|
6
6
|
import type { RenderStreaming, SSRConfig } from '../shared';
|
|
7
7
|
export type RscManifest = {
|
|
@@ -11,7 +11,7 @@ export type RscManifest = {
|
|
|
11
11
|
entryCssFiles?: Record<string, string[]>;
|
|
12
12
|
};
|
|
13
13
|
export type CreateReadableStreamFromElementOptions = {
|
|
14
|
-
runtimeContext:
|
|
14
|
+
runtimeContext: TInternalRuntimeContext;
|
|
15
15
|
config: HandleRequestConfig;
|
|
16
16
|
ssrConfig: SSRConfig;
|
|
17
17
|
htmlTemplate: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { TInternalRuntimeContext } from '../../context';
|
|
3
3
|
import type { ChunkSet, Collector } from './types';
|
|
4
|
-
export { orderHydrationScriptChunks } from '../scriptOrder';
|
|
5
4
|
declare module '@loadable/server' {
|
|
6
5
|
interface ChunkExtractor {
|
|
7
6
|
chunks: string[];
|
|
@@ -30,7 +29,6 @@ export declare class LoadableCollector implements Collector {
|
|
|
30
29
|
private options;
|
|
31
30
|
private extractor?;
|
|
32
31
|
constructor(options: LoadableCollectorOptions);
|
|
33
|
-
private getMatchedRouteChunks;
|
|
34
32
|
collect(comopnent: ReactElement): ReactElement;
|
|
35
33
|
effect(): Promise<void>;
|
|
36
34
|
private emitLoadableScripts;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Helmet as AsyncHelmet, HelmetData as AsyncHelmetData, type HelmetDatum, type HelmetHTMLBodyDatum, type HelmetHTMLElementDatum, type HelmetProps, HelmetProvider, type HelmetServerState, type HelmetTags } from 'react-helmet-async';
|
|
3
3
|
export declare const Helmet: (props: React.PropsWithChildren<HelmetProps>) => React.CElement<React.PropsWithChildren<HelmetProps>, AsyncHelmet> | null;
|
|
4
4
|
declare const head: {
|
|
5
|
-
Helmet:
|
|
5
|
+
Helmet: typeof Helmet;
|
|
6
6
|
HelmetData: typeof AsyncHelmetData;
|
|
7
7
|
HelmetProvider: typeof HelmetProvider;
|
|
8
8
|
};
|
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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* G22 — mandatory degraded consumption API.
|
|
3
|
+
*
|
|
4
|
+
* CONTEXT.md (Degraded State): "consuming a surface obliges the consumer to
|
|
5
|
+
* define a degraded state". This module turns that obligation into a
|
|
6
|
+
* compile-level one: {@link SurfaceConsumerOptions.degraded} is a REQUIRED
|
|
7
|
+
* field, so a call site that forgets its fallback does not type-check.
|
|
8
|
+
*
|
|
9
|
+
* The consumer wraps the loadRemote-ish flow (resolve a SurfaceRef through a
|
|
10
|
+
* provider, then load the execution artifact from the resolved record) and
|
|
11
|
+
* guarantees isolation: any discovery/load failure is caught, classified,
|
|
12
|
+
* reported through the existing MF fallback telemetry, and handed to the
|
|
13
|
+
* required degraded handler.
|
|
14
|
+
*
|
|
15
|
+
* Criticality (owner-default 5: unclassified consumption is `critical`). For a
|
|
16
|
+
* `noncritical` consumption the degraded handler's result is returned and the
|
|
17
|
+
* failure is swallowed, so one failing consumption can never propagate to a
|
|
18
|
+
* sibling (CONTEXT.md: faults isolate at the vertical boundary). For a
|
|
19
|
+
* `critical` consumption the degraded handler still runs — telemetry and
|
|
20
|
+
* fallback-UI obligations hold — but the returned promise then REJECTS with the
|
|
21
|
+
* typed failure so callers and rollout machinery observe it. Critical
|
|
22
|
+
* consumption during a rollout window should be driven by expand/contract, not
|
|
23
|
+
* by silent degrade.
|
|
24
|
+
*/
|
|
25
|
+
import { type ModuleFederationFallbackClassification, type ModuleFederationFallbackTelemetryEmitOptions, type ModuleFederationFallbackTelemetryPayload } from './index';
|
|
26
|
+
import { type DiscoveryError, type EnvironmentId, type ParsedSurfaceRef, type ResolvedDeliveryUnit, type SurfaceResolutionProvider } from './surface-resolution-types';
|
|
27
|
+
/** Where in the consumption lifecycle a failure was raised. */
|
|
28
|
+
export type SurfaceConsumptionPhase = 'discovery' | 'load' | 'mount';
|
|
29
|
+
/**
|
|
30
|
+
* The typed failure surfaced to the degraded handler. Exactly one of
|
|
31
|
+
* `discoveryError` (resolver returned a typed {@link DiscoveryError}) or
|
|
32
|
+
* `error` (something threw) is populated for a given failure.
|
|
33
|
+
*/
|
|
34
|
+
export type SurfaceConsumptionFailure = {
|
|
35
|
+
ref: ParsedSurfaceRef;
|
|
36
|
+
env: EnvironmentId;
|
|
37
|
+
phase: SurfaceConsumptionPhase;
|
|
38
|
+
classification: ModuleFederationFallbackClassification;
|
|
39
|
+
/** Present when discovery returned a typed error state. */
|
|
40
|
+
discoveryError?: DiscoveryError;
|
|
41
|
+
/** Present when a thrown error caused the failure. */
|
|
42
|
+
error?: unknown;
|
|
43
|
+
/** The resolved record, when discovery succeeded but load/mount failed. */
|
|
44
|
+
resolved?: ResolvedDeliveryUnit;
|
|
45
|
+
/** The fallback telemetry payload emitted for this failure. */
|
|
46
|
+
telemetry: ModuleFederationFallbackTelemetryPayload;
|
|
47
|
+
};
|
|
48
|
+
export type SurfaceLoadInput = {
|
|
49
|
+
resolved: ResolvedDeliveryUnit;
|
|
50
|
+
ref: ParsedSurfaceRef;
|
|
51
|
+
env: EnvironmentId;
|
|
52
|
+
};
|
|
53
|
+
export type SurfaceConsumerOptions<T> = {
|
|
54
|
+
/** The logical surface to consume (object or canonical string form). */
|
|
55
|
+
ref: ParsedSurfaceRef | string;
|
|
56
|
+
env: EnvironmentId;
|
|
57
|
+
/** The pluggable resolution seam (RESOLUTION-0001 §2.2). */
|
|
58
|
+
provider: SurfaceResolutionProvider;
|
|
59
|
+
/** Consumer app name, used for telemetry attribution. */
|
|
60
|
+
appName: string;
|
|
61
|
+
/**
|
|
62
|
+
* Loads the execution artifact from a resolved record — the loadRemote-ish
|
|
63
|
+
* flow. Receives the whole {@link ResolvedDeliveryUnit} so the adapter reads
|
|
64
|
+
* locations under one buildMarker (RESOLUTION-0001 §2.3).
|
|
65
|
+
*/
|
|
66
|
+
load: (input: SurfaceLoadInput) => Promise<T> | T;
|
|
67
|
+
/**
|
|
68
|
+
* REQUIRED degraded handler (G22 compile-level obligation). There is no
|
|
69
|
+
* default and no way to opt out at the type level: omitting this field is a
|
|
70
|
+
* compile error. Return the value to serve while the surface is unavailable
|
|
71
|
+
* or incompatible.
|
|
72
|
+
*/
|
|
73
|
+
degraded: (failure: SurfaceConsumptionFailure) => T | Promise<T>;
|
|
74
|
+
/**
|
|
75
|
+
* Consumption criticality (owner-default 5). Defaults to `'critical'` when
|
|
76
|
+
* omitted.
|
|
77
|
+
*
|
|
78
|
+
* - `'noncritical'`: the degraded handler's result is returned and the
|
|
79
|
+
* failure is swallowed — the promise never rejects.
|
|
80
|
+
* - `'critical'`: the degraded handler still runs (telemetry + fallback-UI
|
|
81
|
+
* obligations hold), but the returned promise then REJECTS with the typed
|
|
82
|
+
* failure so callers / rollout machinery observe it. Prefer expand/contract
|
|
83
|
+
* over silent degrade for critical surfaces during rollout windows.
|
|
84
|
+
*/
|
|
85
|
+
classification?: 'critical' | 'noncritical';
|
|
86
|
+
/** Optional telemetry emission options (endpoint/auth/fetch overrides). */
|
|
87
|
+
telemetry?: ModuleFederationFallbackTelemetryEmitOptions;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Consume one surface with a mandatory degraded fallback. On any discovery or
|
|
91
|
+
* load failure the required degraded handler runs (telemetry + fallback UI).
|
|
92
|
+
*
|
|
93
|
+
* For a `noncritical` consumption (see {@link SurfaceConsumerOptions.classification})
|
|
94
|
+
* this resolves to the degraded value and never rejects, so a failing
|
|
95
|
+
* consumption is isolated from any sibling. For a `critical` consumption (the
|
|
96
|
+
* default) it rejects with the typed failure AFTER the degraded handler has
|
|
97
|
+
* run, so callers / rollout machinery observe the failure.
|
|
98
|
+
*/
|
|
99
|
+
export declare function consumeSurface<T>(options: SurfaceConsumerOptions<T>): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* Build a reusable consumer bound to a provider/env/app, still requiring a
|
|
102
|
+
* degraded handler per call. Per-call options override the bound base.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createSurfaceConsumer(base: Pick<SurfaceConsumerOptions<unknown>, 'provider' | 'env' | 'appName' | 'telemetry'>): <T>(options: Omit<SurfaceConsumerOptions<T>, keyof typeof base> & Partial<Pick<SurfaceConsumerOptions<T>, keyof typeof base>>) => Promise<T>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
export declare const DISTRIBUTED_SSR_FRAGMENTS_LOCALS_KEY = "__modernDistributedSsrFragments";
|
|
3
|
+
export declare const DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY = "__modernDistributedSsrFragmentRequest";
|
|
4
|
+
export type DistributedSsrFragment = {
|
|
5
|
+
boundaryId: string;
|
|
6
|
+
buildMarker?: string;
|
|
7
|
+
digest?: string;
|
|
8
|
+
expose: string;
|
|
9
|
+
html: string;
|
|
10
|
+
remote: string;
|
|
11
|
+
status: 'ready';
|
|
12
|
+
};
|
|
13
|
+
export type DistributedSsrFragmentFailure = {
|
|
14
|
+
boundaryId: string;
|
|
15
|
+
expose: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
remote: string;
|
|
18
|
+
status: 'degraded';
|
|
19
|
+
};
|
|
20
|
+
type DistributedSsrFragmentResult = DistributedSsrFragment | DistributedSsrFragmentFailure;
|
|
21
|
+
export type DistributedSsrFragmentContext = {
|
|
22
|
+
fragments?: Record<string, DistributedSsrFragment | DistributedSsrFragmentFailure>;
|
|
23
|
+
required: true;
|
|
24
|
+
resolve?: (remote: string, expose: string, props: Record<string, unknown>) => DistributedSsrFragmentResult | PromiseLike<DistributedSsrFragmentResult>;
|
|
25
|
+
};
|
|
26
|
+
export type DistributedSsrBoundaryProps = {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
expose: string;
|
|
29
|
+
fallback: ReactNode;
|
|
30
|
+
fragmentProps?: Record<string, unknown>;
|
|
31
|
+
remote: string;
|
|
32
|
+
};
|
|
33
|
+
export type CreateDistributedSsrComponentOptions<Props extends object> = {
|
|
34
|
+
createComponent: () => ComponentType<Props>;
|
|
35
|
+
expose: string;
|
|
36
|
+
fallback: ReactNode;
|
|
37
|
+
remote: string;
|
|
38
|
+
};
|
|
39
|
+
export declare function distributedSsrFragmentKey(remote: string, expose: string): string;
|
|
40
|
+
export declare function useDistributedSsrFragmentProps<Props extends object>({ boundaryId, expose, }: {
|
|
41
|
+
boundaryId: string;
|
|
42
|
+
expose: string;
|
|
43
|
+
}): Props;
|
|
44
|
+
/**
|
|
45
|
+
* Keeps the browser on the native Module Federation component while allowing
|
|
46
|
+
* servers that cannot execute remote code (notably workerd) to render a
|
|
47
|
+
* trusted fragment produced by the remote Worker itself.
|
|
48
|
+
*
|
|
49
|
+
* Node SSR has no distributed-fragment context and therefore renders the
|
|
50
|
+
* child normally, preserving Module Federation's in-process SSR path.
|
|
51
|
+
*/
|
|
52
|
+
export declare function DistributedSsrBoundary({ children, expose, fallback, fragmentProps, remote, }: DistributedSsrBoundaryProps): import("react").JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* Defers creation of the native Module Federation component until React
|
|
55
|
+
* actually renders that child. A workerd request with a verified distributed
|
|
56
|
+
* fragment never constructs the native remote, so its module cannot perform
|
|
57
|
+
* forbidden global-scope network I/O. Browser and Node rendering keep using
|
|
58
|
+
* the native Module Federation component unchanged.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createDistributedSsrComponent<Props extends object>({ createComponent, expose, fallback, remote, }: CreateDistributedSsrComponentOptions<Props>): (props: Props) => import("react").JSX.Element;
|
|
61
|
+
export {};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export * from './consume-surface';
|
|
2
|
+
export * from './distributed-ssr';
|
|
3
|
+
export { DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY, useDistributedSsrFragmentProps, } from './distributed-ssr';
|
|
4
|
+
export * from './last-known-good';
|
|
5
|
+
export * from './manifest-recovery-runtime-plugin';
|
|
6
|
+
export * from './surface-resolution-types';
|
|
1
7
|
export declare const MODULE_FEDERATION_FALLBACK_SIGNAL_EVENT = "modernjs:mf-runtime-fallback";
|
|
2
8
|
export declare const MODULE_FEDERATION_RECOVERY_SIGNAL_EVENT = "modernjs:mf-runtime-recovery";
|
|
3
9
|
export declare const DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = "/_modern/contract-gates/runtime-fallback";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* G24a/b — last-known-good (LKG) provider wrapper.
|
|
3
|
+
*
|
|
4
|
+
* RESOLUTION-0001 §2.2: the LKG cache "wraps any provider; serves the last
|
|
5
|
+
* complete record on provider failure, marked `compatibility: 'degraded'`". It
|
|
6
|
+
* is universal — no DOM/fetch/framework coupling — so the same wrapper works in
|
|
7
|
+
* the browser, Node, and Cloudflare.
|
|
8
|
+
*
|
|
9
|
+
* Rollback semantics (ADR-0019 / CONTEXT.md Rollback): the delivery UNIT is
|
|
10
|
+
* the unit of rollback. The cache stores exactly ONE whole
|
|
11
|
+
* {@link ResolvedDeliveryUnit} per (unitId, env) key — never per (ref, env) —
|
|
12
|
+
* so every surface of a unit shares one snapshot and a fresh success swaps that
|
|
13
|
+
* snapshot atomically for all of them (two surfaces can never be served from
|
|
14
|
+
* different cached build markers). It never stores or serves a partial record,
|
|
15
|
+
* and it never mixes locations across build markers — a served degraded record
|
|
16
|
+
* is a byte-for-byte prior success with only its compatibility verdict flipped
|
|
17
|
+
* to `degraded`. An `incompatible` record is never good: it is neither cached
|
|
18
|
+
* as the last-known-good snapshot nor ever served. The ref's external-major
|
|
19
|
+
* participates in lookup validation but not in the storage key.
|
|
20
|
+
*/
|
|
21
|
+
import { type ResolvedDeliveryUnit, type SurfaceResolutionProvider } from './surface-resolution-types';
|
|
22
|
+
export declare const LAST_KNOWN_GOOD_PROVIDER_NAME = "last-known-good";
|
|
23
|
+
/** One cached complete record plus the time it was stored. */
|
|
24
|
+
export type LkgRecord = {
|
|
25
|
+
resolved: ResolvedDeliveryUnit;
|
|
26
|
+
storedAt: number;
|
|
27
|
+
/**
|
|
28
|
+
* External-major selector the record was resolved against. Participates in
|
|
29
|
+
* lookup validation — a cached record is only served for a matching major —
|
|
30
|
+
* but never in the storage key, which is (unitId, env) so all surfaces of a
|
|
31
|
+
* unit share one atomically-swapped record.
|
|
32
|
+
*/
|
|
33
|
+
major?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Pluggable storage hook. The default is an in-memory Map; callers may supply a
|
|
37
|
+
* durable store (KV, disk, etc). Reads/writes may be async. A store only ever
|
|
38
|
+
* receives whole records.
|
|
39
|
+
*/
|
|
40
|
+
export type LkgStorage = {
|
|
41
|
+
read(key: string): (LkgRecord | undefined) | Promise<LkgRecord | undefined>;
|
|
42
|
+
write(key: string, record: LkgRecord): void | Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
export type LkgFreshnessPolicy = {
|
|
45
|
+
/**
|
|
46
|
+
* Maximum age, in ms, a stored record may be served after a provider
|
|
47
|
+
* failure. When omitted, a served record never expires by age. A record
|
|
48
|
+
* older than this yields a typed `stale-record` discovery error.
|
|
49
|
+
*/
|
|
50
|
+
maxStaleMs?: number;
|
|
51
|
+
};
|
|
52
|
+
export type LastKnownGoodOptions = {
|
|
53
|
+
/** The wrapped provider (env/static, Zephyr, or any other). */
|
|
54
|
+
provider: SurfaceResolutionProvider;
|
|
55
|
+
/** Pluggable storage; defaults to a process-local in-memory Map. */
|
|
56
|
+
storage?: LkgStorage;
|
|
57
|
+
freshness?: LkgFreshnessPolicy;
|
|
58
|
+
/** Clock injection for deterministic freshness tests. */
|
|
59
|
+
now?: () => number;
|
|
60
|
+
};
|
|
61
|
+
/** Default process-local in-memory storage. */
|
|
62
|
+
export declare function createInMemoryLkgStorage(): LkgStorage;
|
|
63
|
+
/**
|
|
64
|
+
* Wrap a provider with a last-known-good cache. On success the whole record is
|
|
65
|
+
* cached (atomic swap). On provider failure (typed discovery error or a thrown
|
|
66
|
+
* error) the last complete record is served, marked degraded — unless it has
|
|
67
|
+
* expired per {@link LkgFreshnessPolicy}, in which case a typed `stale-record`
|
|
68
|
+
* error is returned. If there is no cached record, the original failure is
|
|
69
|
+
* passed through (a thrown error becomes a `provider-unavailable` discovery
|
|
70
|
+
* error).
|
|
71
|
+
*/
|
|
72
|
+
export declare function createLastKnownGoodProvider(options: LastKnownGoodOptions): SurfaceResolutionProvider;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type ErrorLoadRemoteArgs = {
|
|
2
|
+
id?: string;
|
|
3
|
+
error?: unknown;
|
|
4
|
+
lifecycle?: string;
|
|
5
|
+
};
|
|
6
|
+
export type ModuleFederationManifestRecoveryPluginOptions = {
|
|
7
|
+
attempts?: number;
|
|
8
|
+
retryDelayMs?: number;
|
|
9
|
+
timeoutMs?: number;
|
|
10
|
+
fetchImpl?: typeof fetch;
|
|
11
|
+
waitImpl?: (milliseconds: number) => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Gives server-side manifest loading a small, bounded recovery window.
|
|
15
|
+
*
|
|
16
|
+
* Returning `undefined` deliberately hands control back to Module Federation:
|
|
17
|
+
* its runtime preserves the original typed RUNTIME-003 error and invalidates
|
|
18
|
+
* the rejected manifest promise. Parsed manifests are returned without schema
|
|
19
|
+
* interpretation so runtime-core remains the authority for RUNTIME-013.
|
|
20
|
+
*/
|
|
21
|
+
export declare const createModuleFederationManifestRecoveryPlugin: (options?: ModuleFederationManifestRecoveryPluginOptions) => {
|
|
22
|
+
name: string;
|
|
23
|
+
errorLoadRemote(args: ErrorLoadRemoteArgs): Promise<any>;
|
|
24
|
+
};
|
|
25
|
+
export default createModuleFederationManifestRecoveryPlugin;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface-resolution types for the module-federation runtime.
|
|
3
|
+
*
|
|
4
|
+
* Thin re-export of the canonical module in `@modern-js/utils/universal`
|
|
5
|
+
* (`packages/toolkit/utils/src/universal/surface-resolution/`,
|
|
6
|
+
* RESOLUTION-0001). Kept as a file so existing `./surface-resolution-types`
|
|
7
|
+
* imports stay stable. Only helpers the canonical module deliberately does not
|
|
8
|
+
* ship (the (ref, env) cache key) live here, implemented against canonical
|
|
9
|
+
* types.
|
|
10
|
+
*/
|
|
11
|
+
import { type EnvironmentId, type ParsedSurfaceRef } from '@modern-js/utils/universal';
|
|
12
|
+
export { type CompatibilityStatus, type CompatibilityVerdict, createDiscoveryError, type DiscoveryError, type DiscoveryErrorCode, type DiscoveryResult, type EnvironmentId, formatSurfaceRef, type ParsedSurfaceRef, parseSurfaceRef, type ResolvedDeliveryUnit, type ResolvedSurface, type ResolvedSurfaceKind, type ResolvedSurfaceLocation, type ResolvedSurfaceLocationPlatform, type SurfaceRefParseError, type SurfaceRefParseResult, type SurfaceResolutionProvider, validateSurfaceRef, } from '@modern-js/utils/universal';
|
|
13
|
+
/** Stable cache/identity key for a (ref, env) pair. */
|
|
14
|
+
export declare function surfaceResolutionKey(ref: ParsedSurfaceRef, env: EnvironmentId): string;
|
|
15
|
+
/**
|
|
16
|
+
* Stable cache key for a (deliveryUnit, env) pair — ONE record per unit per
|
|
17
|
+
* env (ADR-0019 atomicity). All surfaces of a unit share this key so a refresh
|
|
18
|
+
* replaces the whole unit snapshot atomically for every surface, and two
|
|
19
|
+
* surfaces of the same unit can never be served from different cached
|
|
20
|
+
* snapshots. The ref's external-major participates in lookup validation (see
|
|
21
|
+
* the LKG provider), not in this key.
|
|
22
|
+
*/
|
|
23
|
+
export declare function deliveryUnitResolutionKey(unitId: string, env: EnvironmentId): string;
|
|
@@ -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,12 +1,22 @@
|
|
|
1
|
-
import type { RuntimePlugin } from '../../
|
|
1
|
+
import type { RuntimePlugin } from '../../common';
|
|
2
2
|
import type { RouterExtendsHooks } from './hooks';
|
|
3
|
+
import type { RouterProviderRegistration } from './provider';
|
|
3
4
|
import type { RouterConfig, SingleRouteConfig } from './types';
|
|
4
|
-
|
|
5
|
+
type LocalRouterProvider = Omit<RouterProviderRegistration, 'isDefault'>;
|
|
6
|
+
export type RouterPluginFactory = (userConfig?: Partial<RouterConfig>) => RuntimePlugin<{
|
|
5
7
|
extendHooks: RouterExtendsHooks;
|
|
6
8
|
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Create one router wrapper and its provider realm for a runtime entry. Optional
|
|
11
|
+
* providers are supplied by the entry-owning integration (for example the
|
|
12
|
+
* TanStack runtime/router module), so independently bundled apps never resolve
|
|
13
|
+
* factories from another app's module graph.
|
|
14
|
+
*/
|
|
15
|
+
export declare const createRouterPlugin: (localProviders?: readonly LocalRouterProvider[]) => RouterPluginFactory;
|
|
16
|
+
export declare const routerPlugin: RouterPluginFactory;
|
|
7
17
|
export default routerPlugin;
|
|
8
18
|
export type { RouterExtendsHooks } from './hooks';
|
|
9
19
|
export { modifyRoutes } from './plugin';
|
|
10
|
-
export { type RouterProviderFactory, type RouterProviderPlugin, registerRouterProvider, resolveRouterProvider, } from './provider';
|
|
20
|
+
export { createRouterProviderRealm, type RouterProviderFactory, type RouterProviderPlugin, type RouterProviderRealm, type RouterProviderRegistration, registerRouterProvider, resolveRouterProvider, } from './provider';
|
|
11
21
|
export { renderRoutes } from './utils';
|
|
12
22
|
export type { RouterConfig, SingleRouteConfig };
|