@bleedingdev/modern-js-runtime 3.2.0-ultramodern.2 → 3.2.0-ultramodern.23
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/ssr/index.js +3 -2
- package/dist/cjs/cli/template.server.js +1 -0
- package/dist/cjs/core/context/serverPayload/index.js +1 -1
- package/dist/cjs/core/plugin/index.js +3 -2
- package/dist/cjs/core/server/helmet.js +2 -2
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +105 -0
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +2 -1
- package/dist/cjs/core/server/stream/shared.js +1 -0
- package/dist/cjs/router/cli/code/tanstackTypes.js +20 -6
- package/dist/cjs/router/runtime/tanstack/plugin.js +2 -0
- package/dist/cjs/router/runtime/tanstack/routeTree.js +38 -2
- package/dist/cjs/rsc/server.worker.js +58 -0
- package/dist/esm/cli/ssr/index.mjs +3 -2
- package/dist/esm/cli/template.server.mjs +1 -0
- package/dist/esm/core/context/serverPayload/index.mjs +1 -1
- package/dist/esm/core/plugin/index.mjs +3 -2
- package/dist/esm/core/server/helmet.mjs +1 -1
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +61 -0
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +2 -1
- package/dist/esm/core/server/stream/shared.mjs +1 -0
- package/dist/esm/router/cli/code/tanstackTypes.mjs +20 -6
- package/dist/esm/router/runtime/tanstack/plugin.mjs +2 -0
- package/dist/esm/router/runtime/tanstack/routeTree.mjs +38 -2
- package/dist/esm/rsc/server.worker.mjs +1 -0
- package/dist/esm-node/cli/ssr/index.mjs +3 -2
- package/dist/esm-node/cli/template.server.mjs +1 -0
- package/dist/esm-node/core/context/serverPayload/index.mjs +1 -1
- package/dist/esm-node/core/plugin/index.mjs +3 -2
- package/dist/esm-node/core/server/helmet.mjs +1 -1
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +62 -0
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +2 -1
- package/dist/esm-node/core/server/stream/shared.mjs +1 -0
- package/dist/esm-node/router/cli/code/tanstackTypes.mjs +20 -6
- package/dist/esm-node/router/runtime/tanstack/plugin.mjs +2 -0
- package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +38 -2
- package/dist/esm-node/rsc/server.worker.mjs +2 -0
- package/dist/types/cache/index.d.ts +1 -0
- package/dist/types/cli/alias.d.ts +7 -0
- package/dist/types/cli/code.d.ts +3 -0
- package/dist/types/cli/constants.d.ts +9 -0
- package/dist/types/cli/entry.d.ts +2 -0
- package/dist/types/cli/index.d.ts +11 -0
- package/dist/types/cli/ssr/index.d.ts +6 -0
- package/dist/types/cli/ssr/loadable-bundler-plugin.d.ts +31 -0
- package/dist/types/cli/ssr/mode.d.ts +15 -0
- package/dist/types/cli/template.d.ts +50 -0
- package/dist/types/cli/template.server.d.ts +20 -0
- package/dist/types/common.d.ts +8 -0
- package/dist/types/core/browser/hydrate.d.ts +5 -0
- package/dist/types/core/browser/index.d.ts +9 -0
- package/dist/types/core/browser/withCallback.d.ts +5 -0
- package/dist/types/core/compat/hooks.d.ts +4 -0
- package/dist/types/core/compat/index.d.ts +2 -0
- package/dist/types/core/compat/requestContext.d.ts +5 -0
- package/dist/types/core/config.d.ts +6 -0
- package/dist/types/core/constants.d.ts +6 -0
- package/dist/types/core/context/index.d.ts +50 -0
- package/dist/types/core/context/monitors/default.d.ts +2 -0
- package/dist/types/core/context/monitors/index.d.ts +1 -0
- package/dist/types/core/context/monitors/index.server.d.ts +2 -0
- package/dist/types/core/context/request/index.d.ts +1 -0
- package/dist/types/core/context/request/index.server.d.ts +1 -0
- package/dist/types/core/context/response/index.d.ts +4 -0
- package/dist/types/core/context/response/index.server.d.ts +4 -0
- package/dist/types/core/context/runtime.d.ts +42 -0
- package/dist/types/core/context/serverPayload/index.d.ts +4 -0
- package/dist/types/core/context/serverPayload/index.server.d.ts +31 -0
- package/dist/types/core/index.d.ts +5 -0
- package/dist/types/core/plugin/index.d.ts +5 -0
- package/dist/types/core/plugin/types.d.ts +10 -0
- package/dist/types/core/react/index.d.ts +2 -0
- package/dist/types/core/react/wrapper.d.ts +3 -0
- package/dist/types/core/server/constants.d.ts +4 -0
- package/dist/types/core/server/helmet.d.ts +3 -0
- package/dist/types/core/server/index.d.ts +4 -0
- package/dist/types/core/server/react/index.d.ts +2 -0
- package/dist/types/core/server/react/no-ssr-cache/index.d.ts +2 -0
- package/dist/types/core/server/react/nossr/index.d.ts +4 -0
- package/dist/types/core/server/requestHandler.d.ts +13 -0
- package/dist/types/core/server/server.d.ts +4 -0
- package/dist/types/core/server/shared.d.ts +8 -0
- package/dist/types/core/server/stream/afterTemplate.d.ts +13 -0
- package/dist/types/core/server/stream/beforeTemplate.d.ts +9 -0
- package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +9 -0
- package/dist/types/core/server/stream/createReadableStream.d.ts +2 -0
- package/dist/types/core/server/stream/createReadableStream.worker.d.ts +2 -0
- package/dist/types/core/server/stream/deferredScript.d.ts +15 -0
- package/dist/types/core/server/stream/index.d.ts +1 -0
- package/dist/types/core/server/stream/shared.d.ts +40 -0
- package/dist/types/core/server/stream/template.d.ts +9 -0
- package/dist/types/core/server/string/index.d.ts +2 -0
- package/dist/types/core/server/string/loadable.d.ts +36 -0
- package/dist/types/core/server/string/ssrData.d.ts +20 -0
- package/dist/types/core/server/string/types.d.ts +12 -0
- package/dist/types/core/server/tracer.d.ts +17 -0
- package/dist/types/core/server/utils.d.ts +19 -0
- package/dist/types/core/types.d.ts +49 -0
- package/dist/types/document/Body.d.ts +2 -0
- package/dist/types/document/Comment.d.ts +5 -0
- package/dist/types/document/DocumentContext.d.ts +13 -0
- package/dist/types/document/DocumentStructureContext.d.ts +12 -0
- package/dist/types/document/Head.d.ts +5 -0
- package/dist/types/document/Html.d.ts +4 -0
- package/dist/types/document/Links.d.ts +2 -0
- package/dist/types/document/Root.d.ts +7 -0
- package/dist/types/document/Script.d.ts +4 -0
- package/dist/types/document/Scripts.d.ts +2 -0
- package/dist/types/document/Style.d.ts +5 -0
- package/dist/types/document/Title.d.ts +1 -0
- package/dist/types/document/cli/index.d.ts +5 -0
- package/dist/types/document/constants.d.ts +25 -0
- package/dist/types/document/index.d.ts +12 -0
- package/dist/types/exports/config-routes.d.ts +9 -0
- package/dist/types/exports/head.d.ts +4 -0
- package/dist/types/exports/loadable.d.ts +3 -0
- package/dist/types/exports/tanstack-router.d.ts +5 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/internal.d.ts +2 -0
- package/dist/types/react-server.d.ts +3 -0
- package/dist/types/router/cli/code/getClientRoutes/getRoutes.d.ts +8 -0
- package/dist/types/router/cli/code/getClientRoutes/index.d.ts +1 -0
- package/dist/types/router/cli/code/getClientRoutes/utils.d.ts +4 -0
- package/dist/types/router/cli/code/index.d.ts +12 -0
- package/dist/types/router/cli/code/inspect.d.ts +22 -0
- package/dist/types/router/cli/code/makeLegalIdentifier.d.ts +1 -0
- package/dist/types/router/cli/code/nestedRoutes.d.ts +13 -0
- package/dist/types/router/cli/code/tanstackTypes.d.ts +10 -0
- package/dist/types/router/cli/code/templates.d.ts +28 -0
- package/dist/types/router/cli/code/utils.d.ts +12 -0
- package/dist/types/router/cli/config-routes/converter.d.ts +15 -0
- package/dist/types/router/cli/config-routes/parseRouteConfig.d.ts +32 -0
- package/dist/types/router/cli/constants.d.ts +31 -0
- package/dist/types/router/cli/entry.d.ts +18 -0
- package/dist/types/router/cli/handler.d.ts +28 -0
- package/dist/types/router/cli/index.d.ts +5 -0
- package/dist/types/router/index.d.ts +1 -0
- package/dist/types/router/internal.d.ts +2 -0
- package/dist/types/router/runtime/CSSLinks.d.ts +9 -0
- package/dist/types/router/runtime/DefaultNotFound.d.ts +2 -0
- package/dist/types/router/runtime/DeferredDataScripts.d.ts +2 -0
- package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +11 -0
- package/dist/types/router/runtime/PrefetchLink.d.ts +27 -0
- package/dist/types/router/runtime/constants.d.ts +146 -0
- package/dist/types/router/runtime/hooks.d.ts +18 -0
- package/dist/types/router/runtime/index.d.ts +7 -0
- package/dist/types/router/runtime/internal.d.ts +11 -0
- package/dist/types/router/runtime/lifecycle.d.ts +25 -0
- package/dist/types/router/runtime/plugin.d.ts +9 -0
- package/dist/types/router/runtime/plugin.node.d.ts +7 -0
- package/dist/types/router/runtime/routerHelper.d.ts +5 -0
- package/dist/types/router/runtime/rsc-router.d.ts +20 -0
- package/dist/types/router/runtime/rsc.d.ts +1 -0
- package/dist/types/router/runtime/server.d.ts +1 -0
- package/dist/types/router/runtime/tanstack/basepathRewrite.d.ts +8 -0
- package/dist/types/router/runtime/tanstack/dataMutation.d.ts +29 -0
- package/dist/types/router/runtime/tanstack/plugin.d.ts +6 -0
- package/dist/types/router/runtime/tanstack/plugin.node.d.ts +6 -0
- package/dist/types/router/runtime/tanstack/prefetchLink.d.ts +11 -0
- package/dist/types/router/runtime/tanstack/routeTree.d.ts +8 -0
- package/dist/types/router/runtime/tanstack/rsc/ClientSlot.d.ts +5 -0
- package/dist/types/router/runtime/tanstack/rsc/CompositeComponent.d.ts +3 -0
- package/dist/types/router/runtime/tanstack/rsc/ReplayableStream.d.ts +24 -0
- package/dist/types/router/runtime/tanstack/rsc/RscNodeRenderer.d.ts +5 -0
- package/dist/types/router/runtime/tanstack/rsc/SlotContext.d.ts +11 -0
- package/dist/types/router/runtime/tanstack/rsc/client.d.ts +11 -0
- package/dist/types/router/runtime/tanstack/rsc/createRscProxy.d.ts +7 -0
- package/dist/types/router/runtime/tanstack/rsc/index.d.ts +2 -0
- package/dist/types/router/runtime/tanstack/rsc/server.d.ts +14 -0
- package/dist/types/router/runtime/tanstack/rsc/slotUsageSanitizer.d.ts +2 -0
- package/dist/types/router/runtime/tanstack/rsc/symbols.d.ts +46 -0
- package/dist/types/router/runtime/types.d.ts +119 -0
- package/dist/types/router/runtime/utils.d.ts +48 -0
- package/dist/types/router/runtime/withRouter.d.ts +10 -0
- package/dist/types/rsc/client.d.ts +2 -0
- package/dist/types/rsc/server.d.ts +1 -0
- package/dist/types/rsc/server.worker.d.ts +1 -0
- package/package.json +16 -16
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RuntimeConfig } from '../common';
|
|
2
|
+
/**
|
|
3
|
+
* This function helps you to autocomplete configuration types.
|
|
4
|
+
* It accepts a direct config object, or a function that returns a config.
|
|
5
|
+
*/
|
|
6
|
+
export declare const defineRuntimeConfig: (config: RuntimeConfig | ((entryName: string) => RuntimeConfig)) => RuntimeConfig | ((entryName: string) => RuntimeConfig);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { InternalRuntimeContext } from '@modern-js/plugin';
|
|
2
|
+
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
import type { RuntimeExtends } from '../plugin/types';
|
|
5
|
+
import type { ServerPayload } from './serverPayload/index';
|
|
6
|
+
export { getInitialContext, InternalRuntimeContext, RuntimeContext, type TInternalRuntimeContext, type TRuntimeContext, } from './runtime';
|
|
7
|
+
export type { PayloadRoute, ServerPayload } from './serverPayload/index';
|
|
8
|
+
interface GlobalContext {
|
|
9
|
+
entryName?: string;
|
|
10
|
+
/**
|
|
11
|
+
* App.tsx export default component
|
|
12
|
+
*/
|
|
13
|
+
App?: React.ComponentType;
|
|
14
|
+
/**
|
|
15
|
+
* nest router and page router config
|
|
16
|
+
*/
|
|
17
|
+
routes?: (NestedRoute | PageRoute)[];
|
|
18
|
+
/**
|
|
19
|
+
* nest router init function
|
|
20
|
+
*/
|
|
21
|
+
appInit?: () => Promise<unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* page router _app.tsx export layout app
|
|
24
|
+
*/
|
|
25
|
+
layoutApp?: React.ComponentType;
|
|
26
|
+
/**
|
|
27
|
+
* Entry basename for routing
|
|
28
|
+
*/
|
|
29
|
+
basename?: string;
|
|
30
|
+
internalRuntimeContext?: InternalRuntimeContext<RuntimeExtends>;
|
|
31
|
+
/**
|
|
32
|
+
* RSCRoot
|
|
33
|
+
*/
|
|
34
|
+
RSCRoot?: React.ComponentType;
|
|
35
|
+
isRscClient?: boolean;
|
|
36
|
+
serverPayload?: ServerPayload;
|
|
37
|
+
enableRsc?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export { getServerPayload, setServerPayload, } from './serverPayload/index';
|
|
40
|
+
export declare function getGlobalIsRscClient(): boolean | undefined;
|
|
41
|
+
export declare function getGlobalEnableRsc(): boolean | undefined;
|
|
42
|
+
export declare function setGlobalContext(context: Omit<GlobalContext, 'internalRuntimeContext'>): void;
|
|
43
|
+
export declare function getCurrentEntryName(): string | undefined;
|
|
44
|
+
export declare function getGlobalRSCRoot(): React.ComponentType<{}> | undefined;
|
|
45
|
+
export declare function setGlobalInternalRuntimeContext(context: InternalRuntimeContext<RuntimeExtends>): void;
|
|
46
|
+
export declare function getGlobalInternalRuntimeContext(): InternalRuntimeContext<Required<import("@modern-js/plugin").RuntimePluginExtends<import("../plugin/types").RuntimeConfig, import("./runtime").TInternalRuntimeContext, {}, {}>>>;
|
|
47
|
+
export declare function getGlobalApp(): React.ComponentType<{}> | undefined;
|
|
48
|
+
export declare function getGlobalRoutes(): undefined | (NestedRoute | PageRoute)[];
|
|
49
|
+
export declare function getGlobalLayoutApp(): React.ComponentType<{}> | undefined;
|
|
50
|
+
export declare function getGlobalBasename(): string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getMonitors: () => Omit<import("@modern-js/types").Monitors, "push">;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getRequest: () => Request;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getRequest: () => Request;
|
|
@@ -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,42 @@
|
|
|
1
|
+
import type { RouteObject, StaticHandlerContext } from '@modern-js/runtime-utils/router';
|
|
2
|
+
import type { InternalRouterRuntimeState, InternalRouterServerSnapshot, RouteManifest, RouterFramework } from '../../router/runtime/types';
|
|
3
|
+
import type { RequestContext, SSRServerContext } from '../types';
|
|
4
|
+
export interface TRuntimeContext {
|
|
5
|
+
initialData?: Record<string, unknown>;
|
|
6
|
+
isBrowser: boolean;
|
|
7
|
+
routes?: RouteObject[];
|
|
8
|
+
routerFramework?: RouterFramework;
|
|
9
|
+
requestContext: RequestContext;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `requestContext` instead
|
|
12
|
+
*/
|
|
13
|
+
context: RequestContext;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* InternalRuntimeContext used internally and by plugins
|
|
18
|
+
*/
|
|
19
|
+
export interface TInternalRuntimeContext extends TRuntimeContext {
|
|
20
|
+
routeManifest?: RouteManifest;
|
|
21
|
+
routerRuntime?: InternalRouterRuntimeState;
|
|
22
|
+
routerInstance?: unknown;
|
|
23
|
+
routerHydrationScript?: string;
|
|
24
|
+
routerMatchedRouteIds?: string[];
|
|
25
|
+
routerServerSnapshot?: InternalRouterServerSnapshot;
|
|
26
|
+
routerContext?: StaticHandlerContext;
|
|
27
|
+
unstable_getBlockNavState?: () => boolean;
|
|
28
|
+
ssrContext?: SSRServerContext;
|
|
29
|
+
_internalContext?: any;
|
|
30
|
+
_internalRouterBaseName?: any;
|
|
31
|
+
}
|
|
32
|
+
export declare const InternalRuntimeContext: import("react").Context<TInternalRuntimeContext>;
|
|
33
|
+
export declare const RuntimeContext: import("react").Context<TRuntimeContext>;
|
|
34
|
+
/**
|
|
35
|
+
* deprecated, use RuntimeContext instead
|
|
36
|
+
*/
|
|
37
|
+
export declare const ReactRuntimeContext: import("react").Context<TRuntimeContext>;
|
|
38
|
+
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: RouteManifest) => TInternalRuntimeContext;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated use use(RuntimeContext) instead
|
|
41
|
+
*/
|
|
42
|
+
export declare const useRuntimeContext: () => TRuntimeContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RouterState, ShouldRevalidateFunction } from '@modern-js/runtime-utils/router';
|
|
2
|
+
export type PayloadRoute = {
|
|
3
|
+
clientAction?: (...args: unknown[]) => unknown;
|
|
4
|
+
clientLoader?: (...args: unknown[]) => unknown;
|
|
5
|
+
element?: React.ReactNode;
|
|
6
|
+
errorElement?: React.ReactNode;
|
|
7
|
+
handle?: unknown;
|
|
8
|
+
hasAction: boolean;
|
|
9
|
+
hasErrorBoundary: boolean;
|
|
10
|
+
hasLoader: boolean;
|
|
11
|
+
hasClientLoader?: boolean;
|
|
12
|
+
id: string;
|
|
13
|
+
index?: boolean;
|
|
14
|
+
params: Record<string, string>;
|
|
15
|
+
parentId?: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
pathname: string;
|
|
18
|
+
pathnameBase: string;
|
|
19
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
20
|
+
};
|
|
21
|
+
export type ServerPayload = {
|
|
22
|
+
type: 'render';
|
|
23
|
+
actionData: RouterState['actionData'];
|
|
24
|
+
errors: RouterState['errors'];
|
|
25
|
+
loaderData: RouterState['loaderData'];
|
|
26
|
+
location: RouterState['location'];
|
|
27
|
+
routes: PayloadRoute[];
|
|
28
|
+
originalRoutes?: PayloadRoute[];
|
|
29
|
+
};
|
|
30
|
+
export declare const getServerPayload: () => ServerPayload | undefined;
|
|
31
|
+
export declare const setServerPayload: (payload: ServerPayload) => void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { defineRuntimeConfig } from './config';
|
|
2
|
+
export type { TRuntimeContext } from './context/runtime';
|
|
3
|
+
export { RuntimeContext, useRuntimeContext, } from './context/runtime';
|
|
4
|
+
export type { RuntimePlugin } from './plugin';
|
|
5
|
+
export type { SSRContainer, SSRData } from './types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InternalRuntimeContext } from '@modern-js/plugin/runtime';
|
|
2
|
+
import type { RuntimeConfig, RuntimeExtends, RuntimePlugin } from './types';
|
|
3
|
+
export type { RuntimePlugin };
|
|
4
|
+
export declare function registerPlugin(internalPlugins: RuntimePlugin[], runtimeConfig?: RuntimeConfig): InternalRuntimeContext<RuntimeExtends>;
|
|
5
|
+
export declare function mergeConfig(config: Record<string, any>, ...otherConfig: Record<string, any>[]): any;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RuntimePlugin as BaseRuntimePlugin, RuntimePluginExtends } from '@modern-js/plugin';
|
|
2
|
+
import type { Hooks } from '@modern-js/plugin/runtime';
|
|
3
|
+
import type { RuntimeConfig as BaseRuntimeConfig } from '../../common';
|
|
4
|
+
import type { TInternalRuntimeContext } from '../context/runtime';
|
|
5
|
+
export type RuntimeHooks = Hooks<RuntimeConfig, TInternalRuntimeContext>;
|
|
6
|
+
export type RuntimeExtends = Required<RuntimePluginExtends<RuntimeConfig, TInternalRuntimeContext, {}, {}>>;
|
|
7
|
+
export type RuntimePlugin<Extends extends RuntimePluginExtends = {}> = BaseRuntimePlugin<RuntimeExtends & Extends>;
|
|
8
|
+
export interface RuntimeConfig extends BaseRuntimeConfig {
|
|
9
|
+
plugins?: RuntimePlugin[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const HTML_PLACEHOLDER = "<!--<?- html ?>-->";
|
|
2
|
+
export declare const SSR_DATA_PLACEHOLDER = "<!--<?- SSRDataScript ?>-->";
|
|
3
|
+
export declare const CHUNK_JS_PLACEHOLDER = "<!--<?- chunksMap.js ?>-->";
|
|
4
|
+
export declare const CHUNK_CSS_PLACEHOLDER = "<!--<?- chunksMap.css ?>-->";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RequestHandler, RequestHandlerOptions } from '@modern-js/app-tools';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type TInternalRuntimeContext } from '../context';
|
|
4
|
+
export type { RequestHandlerConfig as HandleRequestConfig } from '@modern-js/app-tools';
|
|
5
|
+
export type HandleRequestOptions = Exclude<RequestHandlerOptions, 'staticGenerate'> & {
|
|
6
|
+
runtimeContext: TInternalRuntimeContext;
|
|
7
|
+
};
|
|
8
|
+
export type HandleRequest = (request: Request, ServerRoot: React.ComponentType, // App, routes,
|
|
9
|
+
options: HandleRequestOptions) => Promise<Response>;
|
|
10
|
+
export type CreateRequestHandler = (handleRequest: HandleRequest, options?: {
|
|
11
|
+
enableRsc?: boolean;
|
|
12
|
+
}) => Promise<RequestHandler>;
|
|
13
|
+
export declare const createRequestHandler: CreateRequestHandler;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type CreateRequestHandler, createRequestHandler, type HandleRequest, type HandleRequestConfig, type HandleRequestOptions, } from './requestHandler';
|
|
2
|
+
export type { RenderOptions, RenderStreaming, RenderString } from './shared';
|
|
3
|
+
export { renderStreaming } from './stream';
|
|
4
|
+
export { renderString } from './string';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ServerUserConfig } from '@modern-js/app-tools';
|
|
2
|
+
import type { HandleRequestOptions } from './requestHandler';
|
|
3
|
+
export type RenderOptions = HandleRequestOptions;
|
|
4
|
+
export type SSRConfig = NonNullable<ServerUserConfig['ssr']>;
|
|
5
|
+
export type RenderStreaming = (request: Request, serverRoot: React.ReactElement, optinos: RenderOptions) => Promise<ReadableStream>;
|
|
6
|
+
export type RenderString = (request: Request, serverRoot: React.ReactElement, optinos: RenderOptions) => Promise<string>;
|
|
7
|
+
export type BuildHtmlCb = (template: string) => string | Promise<string>;
|
|
8
|
+
export declare function buildHtml(template: string, callbacks: BuildHtmlCb[]): Promise<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type RenderLevel } from '../../constants';
|
|
2
|
+
import type { TInternalRuntimeContext } from '../../context';
|
|
3
|
+
import type { HandleRequestConfig } from '../requestHandler';
|
|
4
|
+
import { type SSRConfig } from '../shared';
|
|
5
|
+
export type BuildShellAfterTemplateOptions = {
|
|
6
|
+
runtimeContext: TInternalRuntimeContext;
|
|
7
|
+
renderLevel: RenderLevel;
|
|
8
|
+
ssrConfig: SSRConfig;
|
|
9
|
+
request: Request;
|
|
10
|
+
entryName: string;
|
|
11
|
+
config: HandleRequestConfig;
|
|
12
|
+
};
|
|
13
|
+
export declare function buildShellAfterTemplate(afterAppTemplate: string, options: BuildShellAfterTemplateOptions): Promise<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TInternalRuntimeContext } from '../../context';
|
|
2
|
+
import type { HandleRequestConfig } from '../requestHandler';
|
|
3
|
+
export interface BuildShellBeforeTemplateOptions {
|
|
4
|
+
runtimeContext: TInternalRuntimeContext;
|
|
5
|
+
entryName: string;
|
|
6
|
+
config: HandleRequestConfig;
|
|
7
|
+
styledComponentsStyleTags?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildShellBeforeTemplate(beforeAppTemplate: string, options: BuildShellBeforeTemplateOptions): Promise<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TInternalRuntimeContext } from '../../context';
|
|
2
|
+
import type { HandleRequestConfig } from '../requestHandler';
|
|
3
|
+
export interface BuildShellBeforeTemplateOptions {
|
|
4
|
+
runtimeContext: TInternalRuntimeContext;
|
|
5
|
+
entryName: string;
|
|
6
|
+
config: HandleRequestConfig;
|
|
7
|
+
styledComponentsStyleTags?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildShellBeforeTemplate(beforeAppTemplate: string, options: BuildShellBeforeTemplateOptions): Promise<string>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DeferredData } from '@modern-js/runtime-utils/browser';
|
|
2
|
+
export type DeferredDataLike = Pick<DeferredData, 'data' | 'pendingKeys'> & {
|
|
3
|
+
data?: Record<string, unknown>;
|
|
4
|
+
pendingKeys?: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function escapeAttr(value: string): string;
|
|
7
|
+
export declare function isRecord(v: unknown): v is Record<string, unknown>;
|
|
8
|
+
export declare function isDeferredDataLike(v: unknown): v is DeferredDataLike;
|
|
9
|
+
export declare function isPromiseLike(value: unknown): value is Promise<unknown>;
|
|
10
|
+
export declare function toErrorInfo(error: unknown): {
|
|
11
|
+
message: string;
|
|
12
|
+
stack?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildDeferredDataScript(nonce: string | undefined, args: unknown[]): string;
|
|
15
|
+
export declare function enqueueFromEntries(entries: Array<[string, unknown]>, nonce: string | undefined, emit: (script: string) => void): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderStreaming: import("../shared").RenderStreaming;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { OnError } from '@modern-js/app-tools';
|
|
2
|
+
import type { ClientManifest as RscClientManifest, ServerManifest as RscServerManifest, SSRManifest as RscSSRManifest } from '@modern-js/types/server';
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
import type { TRuntimeContext } from '../../context';
|
|
5
|
+
import type { HandleRequestConfig } from '../requestHandler';
|
|
6
|
+
import type { RenderStreaming, SSRConfig } from '../shared';
|
|
7
|
+
export type RscManifest = {
|
|
8
|
+
clientManifest?: RscClientManifest;
|
|
9
|
+
serverConsumerModuleMap?: unknown;
|
|
10
|
+
serverManifest?: RscServerManifest;
|
|
11
|
+
entryCssFiles?: Record<string, string[]>;
|
|
12
|
+
};
|
|
13
|
+
export type CreateReadableStreamFromElementOptions = {
|
|
14
|
+
runtimeContext: TRuntimeContext;
|
|
15
|
+
config: HandleRequestConfig;
|
|
16
|
+
ssrConfig: SSRConfig;
|
|
17
|
+
htmlTemplate: string;
|
|
18
|
+
entryName: string;
|
|
19
|
+
rscClientManifest?: RscClientManifest;
|
|
20
|
+
rscSSRManifest?: RscSSRManifest;
|
|
21
|
+
rscServerManifest?: RscServerManifest;
|
|
22
|
+
rscManifest?: RscManifest;
|
|
23
|
+
rscRoot?: React.ReactElement;
|
|
24
|
+
onShellReady?: () => void;
|
|
25
|
+
onShellError?: (error: unknown) => void;
|
|
26
|
+
onAllReady?: () => void;
|
|
27
|
+
onError: OnError;
|
|
28
|
+
};
|
|
29
|
+
export type CreateReadableStreamFromElement = (request: Request, rootElement: React.ReactElement, options: CreateReadableStreamFromElementOptions) => Promise<ReadableStream<Uint8Array>>;
|
|
30
|
+
export declare enum ShellChunkStatus {
|
|
31
|
+
START = 0,
|
|
32
|
+
FINISH = 1
|
|
33
|
+
}
|
|
34
|
+
export declare function resolveStreamingMode(request: Request, forceStreamToString: boolean): {
|
|
35
|
+
onReady: 'onAllReady' | 'onShellReady';
|
|
36
|
+
waitForAllReady: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare function encodeForWebStream(thing: unknown): unknown;
|
|
39
|
+
export declare function getReadableStreamFromString(content: string): ReadableStream;
|
|
40
|
+
export declare function createRenderStreaming(createReadableStreamPromise: Promise<CreateReadableStreamFromElement>): RenderStreaming;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type BuildShellAfterTemplateOptions } from './afterTemplate';
|
|
2
|
+
import { type BuildShellBeforeTemplateOptions } from './beforeTemplate';
|
|
3
|
+
export type InjectTemplate = {
|
|
4
|
+
shellBefore: string;
|
|
5
|
+
shellAfter: string;
|
|
6
|
+
};
|
|
7
|
+
type GetTemplatesOptions = BuildShellAfterTemplateOptions & BuildShellBeforeTemplateOptions;
|
|
8
|
+
export declare const getTemplates: (htmlTemplate: string, options: GetTemplatesOptions) => Promise<InjectTemplate>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { ChunkSet, Collector } from './types';
|
|
3
|
+
declare module '@loadable/server' {
|
|
4
|
+
interface ChunkExtractor {
|
|
5
|
+
chunks: string[];
|
|
6
|
+
getChunkAssets: (chunks: string[]) => Chunk[];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export interface LoadableCollectorOptions {
|
|
10
|
+
nonce?: string;
|
|
11
|
+
stats?: Record<string, any>;
|
|
12
|
+
routeManifest?: Record<string, any>;
|
|
13
|
+
template: string;
|
|
14
|
+
entryName: string;
|
|
15
|
+
chunkSet: ChunkSet;
|
|
16
|
+
config: LoadableCollectorConfig;
|
|
17
|
+
}
|
|
18
|
+
export interface LoadableCollectorConfig {
|
|
19
|
+
scriptLoading?: 'defer' | 'blocking' | 'module' | 'async';
|
|
20
|
+
inlineStyles?: boolean | RegExp;
|
|
21
|
+
inlineScripts?: boolean | RegExp;
|
|
22
|
+
crossorigin?: boolean | 'anonymous' | 'use-credentials';
|
|
23
|
+
enableAsyncEntry?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare class LoadableCollector implements Collector {
|
|
26
|
+
private options;
|
|
27
|
+
private extractor?;
|
|
28
|
+
constructor(options: LoadableCollectorOptions);
|
|
29
|
+
private get existsAssets();
|
|
30
|
+
collect(comopnent: ReactElement): ReactElement;
|
|
31
|
+
effect(): Promise<void>;
|
|
32
|
+
private emitLoadableScripts;
|
|
33
|
+
private emitScriptAssets;
|
|
34
|
+
private emitStyleAssets;
|
|
35
|
+
private generateAttributes;
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { StaticHandlerContext } from '@modern-js/runtime-utils/router';
|
|
2
|
+
import type { TInternalRuntimeContext } from '../../context';
|
|
3
|
+
import type { SSRServerContext } from '../../types';
|
|
4
|
+
import type { SSRConfig } from '../shared';
|
|
5
|
+
import type { ChunkSet, Collector } from './types';
|
|
6
|
+
export interface SSRDataCreatorOptions {
|
|
7
|
+
runtimeContext: TInternalRuntimeContext;
|
|
8
|
+
request: Request;
|
|
9
|
+
chunkSet: ChunkSet;
|
|
10
|
+
ssrContext: SSRServerContext;
|
|
11
|
+
ssrConfig?: SSRConfig;
|
|
12
|
+
routerContext?: StaticHandlerContext;
|
|
13
|
+
nonce?: string;
|
|
14
|
+
useJsonScript?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class SSRDataCollector implements Collector {
|
|
17
|
+
#private;
|
|
18
|
+
constructor(options: SSRDataCreatorOptions);
|
|
19
|
+
effect(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { RenderLevel } from '../../constants';
|
|
3
|
+
export interface Collector {
|
|
4
|
+
collect?: (comopnent: ReactElement) => ReactElement;
|
|
5
|
+
effect: () => void | Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export type ChunkSet = {
|
|
8
|
+
renderLevel: RenderLevel;
|
|
9
|
+
ssrScripts: string;
|
|
10
|
+
jsChunk: string;
|
|
11
|
+
cssChunk: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { OnError, OnTiming } from '@modern-js/app-tools';
|
|
2
|
+
export declare enum SSRTimings {
|
|
3
|
+
PRERENDER = "ssr-prerender",
|
|
4
|
+
RENDER_HTML = "ssr-render-html",
|
|
5
|
+
RENDER_SHELL = "ssr-render-shell"
|
|
6
|
+
}
|
|
7
|
+
export declare enum SSRErrors {
|
|
8
|
+
PRERENDER = "App Prerender",
|
|
9
|
+
RENDER_HTML = "App Render To HTML",
|
|
10
|
+
RENDER_STREAM = "An error occurs during streaming SSR",
|
|
11
|
+
RENDER_SHELL = "An error occurs during streaming render shell",
|
|
12
|
+
LOADER_ERROR = "App error occurs during data loader"
|
|
13
|
+
}
|
|
14
|
+
export type Tracer = {
|
|
15
|
+
onError: OnError;
|
|
16
|
+
onTiming: OnTiming;
|
|
17
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ServerUserConfig } from '@modern-js/app-tools';
|
|
2
|
+
import { type StaticHandlerContext } from '@modern-js/runtime-utils/router';
|
|
3
|
+
import type { SSRConfig } from './shared';
|
|
4
|
+
export declare function attributesToString(attributes: Record<string, any>): string;
|
|
5
|
+
/**
|
|
6
|
+
* @param source
|
|
7
|
+
* @param searchValue
|
|
8
|
+
* @param replaceValue
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function safeReplace(source: string, searchValue: string | RegExp, replaceValue: string): string;
|
|
12
|
+
export declare function checkIsNode(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* forked from https://github.com/remix-run/remix/blob/main/packages/remix-server-runtime/errors.ts
|
|
15
|
+
* license at https://github.com/remix-run/remix/blob/main/LICENSE.md
|
|
16
|
+
*/
|
|
17
|
+
export declare function serializeErrors(errors: StaticHandlerContext['errors']): StaticHandlerContext['errors'];
|
|
18
|
+
export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserConfig['ssr'], ssrByEntries?: ServerUserConfig['ssrByEntries']): any;
|
|
19
|
+
export declare function getSSRMode(ssrConfig?: SSRConfig): 'string' | 'stream' | false;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { OnError, OnTiming } from '@modern-js/app-tools';
|
|
2
|
+
import type { BaseSSRServerContext } from '@modern-js/types';
|
|
3
|
+
import type { RenderLevel } from './constants';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
_SSR_DATA?: SSRContainer;
|
|
7
|
+
_ROUTER_DATA?: RouterSSRData;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export interface SSRData {
|
|
11
|
+
initialData?: Record<string, unknown>;
|
|
12
|
+
i18nData?: Record<string, unknown>;
|
|
13
|
+
[props: string]: any;
|
|
14
|
+
}
|
|
15
|
+
export interface RouteData {
|
|
16
|
+
[routeId: string]: any;
|
|
17
|
+
}
|
|
18
|
+
export interface RouterSSRData {
|
|
19
|
+
loaderData: RouteData;
|
|
20
|
+
errors: RouteData | null;
|
|
21
|
+
}
|
|
22
|
+
export type SSRMode = 'string' | 'stream';
|
|
23
|
+
export interface SSRContainer {
|
|
24
|
+
renderLevel: RenderLevel;
|
|
25
|
+
mode: SSRMode;
|
|
26
|
+
data?: SSRData;
|
|
27
|
+
context?: {
|
|
28
|
+
request: BaseSSRServerContext['request'];
|
|
29
|
+
reporter?: {
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
type BuildHtmlCb = (tempalte: string) => string;
|
|
35
|
+
export type SSRServerContext = Pick<BaseSSRServerContext, 'baseUrl' | 'response' | 'nonce' | 'mode' | 'loaderContext' | 'reporter' | 'routeManifest'> & {
|
|
36
|
+
request: BaseSSRServerContext['request'] & {
|
|
37
|
+
raw: Request;
|
|
38
|
+
};
|
|
39
|
+
htmlModifiers: BuildHtmlCb[];
|
|
40
|
+
loaderFailureMode?: 'clientRender' | 'errorBoundary';
|
|
41
|
+
onError: OnError;
|
|
42
|
+
onTiming: OnTiming;
|
|
43
|
+
useJsonScript?: boolean;
|
|
44
|
+
};
|
|
45
|
+
export type RequestContext = {
|
|
46
|
+
request: BaseSSRServerContext['request'];
|
|
47
|
+
response: BaseSSRServerContext['response'];
|
|
48
|
+
};
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { type JSX } from 'react';
|
|
2
|
+
type DocumentProps = {
|
|
3
|
+
[x: string]: any;
|
|
4
|
+
config?: any;
|
|
5
|
+
templateParams: {
|
|
6
|
+
[y: string]: any;
|
|
7
|
+
mountId?: string;
|
|
8
|
+
};
|
|
9
|
+
processEnv?: Record<string, string | undefined>;
|
|
10
|
+
children?: JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
export declare const DocumentContext: React.Context<DocumentProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
type DocumentStructureContextProps = {
|
|
3
|
+
hasSetHead?: boolean;
|
|
4
|
+
hasSetScripts?: boolean;
|
|
5
|
+
hasSetLinks?: boolean;
|
|
6
|
+
hasSetBody?: boolean;
|
|
7
|
+
hasSetRoot?: boolean;
|
|
8
|
+
hasSetTitle?: boolean;
|
|
9
|
+
docChild?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export declare const DocumentStructureContext: React.Context<DocumentStructureContextProps>;
|
|
12
|
+
export {};
|