@bleedingdev/modern-js-runtime 3.2.0-ultramodern.2 → 3.2.0-ultramodern.22

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.
Files changed (177) hide show
  1. package/dist/cjs/cli/ssr/index.js +3 -2
  2. package/dist/cjs/cli/template.server.js +1 -0
  3. package/dist/cjs/core/context/serverPayload/index.js +1 -1
  4. package/dist/cjs/core/plugin/index.js +3 -2
  5. package/dist/cjs/core/server/helmet.js +2 -2
  6. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +105 -0
  7. package/dist/cjs/core/server/stream/createReadableStream.worker.js +2 -1
  8. package/dist/cjs/core/server/stream/shared.js +1 -0
  9. package/dist/cjs/router/cli/code/tanstackTypes.js +20 -6
  10. package/dist/cjs/router/runtime/tanstack/plugin.js +2 -0
  11. package/dist/cjs/router/runtime/tanstack/routeTree.js +38 -2
  12. package/dist/cjs/rsc/server.worker.js +58 -0
  13. package/dist/esm/cli/ssr/index.mjs +3 -2
  14. package/dist/esm/cli/template.server.mjs +1 -0
  15. package/dist/esm/core/context/serverPayload/index.mjs +1 -1
  16. package/dist/esm/core/plugin/index.mjs +3 -2
  17. package/dist/esm/core/server/helmet.mjs +1 -1
  18. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +61 -0
  19. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +2 -1
  20. package/dist/esm/core/server/stream/shared.mjs +1 -0
  21. package/dist/esm/router/cli/code/tanstackTypes.mjs +20 -6
  22. package/dist/esm/router/runtime/tanstack/plugin.mjs +2 -0
  23. package/dist/esm/router/runtime/tanstack/routeTree.mjs +38 -2
  24. package/dist/esm/rsc/server.worker.mjs +1 -0
  25. package/dist/esm-node/cli/ssr/index.mjs +3 -2
  26. package/dist/esm-node/cli/template.server.mjs +1 -0
  27. package/dist/esm-node/core/context/serverPayload/index.mjs +1 -1
  28. package/dist/esm-node/core/plugin/index.mjs +3 -2
  29. package/dist/esm-node/core/server/helmet.mjs +1 -1
  30. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +62 -0
  31. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +2 -1
  32. package/dist/esm-node/core/server/stream/shared.mjs +1 -0
  33. package/dist/esm-node/router/cli/code/tanstackTypes.mjs +20 -6
  34. package/dist/esm-node/router/runtime/tanstack/plugin.mjs +2 -0
  35. package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +38 -2
  36. package/dist/esm-node/rsc/server.worker.mjs +2 -0
  37. package/dist/types/cache/index.d.ts +1 -0
  38. package/dist/types/cli/alias.d.ts +7 -0
  39. package/dist/types/cli/code.d.ts +3 -0
  40. package/dist/types/cli/constants.d.ts +9 -0
  41. package/dist/types/cli/entry.d.ts +2 -0
  42. package/dist/types/cli/index.d.ts +11 -0
  43. package/dist/types/cli/ssr/index.d.ts +6 -0
  44. package/dist/types/cli/ssr/loadable-bundler-plugin.d.ts +31 -0
  45. package/dist/types/cli/ssr/mode.d.ts +15 -0
  46. package/dist/types/cli/template.d.ts +50 -0
  47. package/dist/types/cli/template.server.d.ts +20 -0
  48. package/dist/types/common.d.ts +8 -0
  49. package/dist/types/core/browser/hydrate.d.ts +5 -0
  50. package/dist/types/core/browser/index.d.ts +9 -0
  51. package/dist/types/core/browser/withCallback.d.ts +5 -0
  52. package/dist/types/core/compat/hooks.d.ts +4 -0
  53. package/dist/types/core/compat/index.d.ts +2 -0
  54. package/dist/types/core/compat/requestContext.d.ts +5 -0
  55. package/dist/types/core/config.d.ts +6 -0
  56. package/dist/types/core/constants.d.ts +6 -0
  57. package/dist/types/core/context/index.d.ts +50 -0
  58. package/dist/types/core/context/monitors/default.d.ts +2 -0
  59. package/dist/types/core/context/monitors/index.d.ts +1 -0
  60. package/dist/types/core/context/monitors/index.server.d.ts +2 -0
  61. package/dist/types/core/context/request/index.d.ts +1 -0
  62. package/dist/types/core/context/request/index.server.d.ts +1 -0
  63. package/dist/types/core/context/response/index.d.ts +4 -0
  64. package/dist/types/core/context/response/index.server.d.ts +4 -0
  65. package/dist/types/core/context/runtime.d.ts +42 -0
  66. package/dist/types/core/context/serverPayload/index.d.ts +4 -0
  67. package/dist/types/core/context/serverPayload/index.server.d.ts +31 -0
  68. package/dist/types/core/index.d.ts +5 -0
  69. package/dist/types/core/plugin/index.d.ts +5 -0
  70. package/dist/types/core/plugin/types.d.ts +10 -0
  71. package/dist/types/core/react/index.d.ts +2 -0
  72. package/dist/types/core/react/wrapper.d.ts +3 -0
  73. package/dist/types/core/server/constants.d.ts +4 -0
  74. package/dist/types/core/server/helmet.d.ts +3 -0
  75. package/dist/types/core/server/index.d.ts +4 -0
  76. package/dist/types/core/server/react/index.d.ts +2 -0
  77. package/dist/types/core/server/react/no-ssr-cache/index.d.ts +2 -0
  78. package/dist/types/core/server/react/nossr/index.d.ts +4 -0
  79. package/dist/types/core/server/requestHandler.d.ts +13 -0
  80. package/dist/types/core/server/server.d.ts +4 -0
  81. package/dist/types/core/server/shared.d.ts +8 -0
  82. package/dist/types/core/server/stream/afterTemplate.d.ts +13 -0
  83. package/dist/types/core/server/stream/beforeTemplate.d.ts +9 -0
  84. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +9 -0
  85. package/dist/types/core/server/stream/createReadableStream.d.ts +2 -0
  86. package/dist/types/core/server/stream/createReadableStream.worker.d.ts +2 -0
  87. package/dist/types/core/server/stream/deferredScript.d.ts +15 -0
  88. package/dist/types/core/server/stream/index.d.ts +1 -0
  89. package/dist/types/core/server/stream/shared.d.ts +40 -0
  90. package/dist/types/core/server/stream/template.d.ts +9 -0
  91. package/dist/types/core/server/string/index.d.ts +2 -0
  92. package/dist/types/core/server/string/loadable.d.ts +36 -0
  93. package/dist/types/core/server/string/ssrData.d.ts +20 -0
  94. package/dist/types/core/server/string/types.d.ts +12 -0
  95. package/dist/types/core/server/tracer.d.ts +17 -0
  96. package/dist/types/core/server/utils.d.ts +19 -0
  97. package/dist/types/core/types.d.ts +49 -0
  98. package/dist/types/document/Body.d.ts +2 -0
  99. package/dist/types/document/Comment.d.ts +5 -0
  100. package/dist/types/document/DocumentContext.d.ts +13 -0
  101. package/dist/types/document/DocumentStructureContext.d.ts +12 -0
  102. package/dist/types/document/Head.d.ts +5 -0
  103. package/dist/types/document/Html.d.ts +4 -0
  104. package/dist/types/document/Links.d.ts +2 -0
  105. package/dist/types/document/Root.d.ts +7 -0
  106. package/dist/types/document/Script.d.ts +4 -0
  107. package/dist/types/document/Scripts.d.ts +2 -0
  108. package/dist/types/document/Style.d.ts +5 -0
  109. package/dist/types/document/Title.d.ts +1 -0
  110. package/dist/types/document/cli/index.d.ts +5 -0
  111. package/dist/types/document/constants.d.ts +25 -0
  112. package/dist/types/document/index.d.ts +12 -0
  113. package/dist/types/exports/config-routes.d.ts +9 -0
  114. package/dist/types/exports/head.d.ts +4 -0
  115. package/dist/types/exports/loadable.d.ts +3 -0
  116. package/dist/types/exports/tanstack-router.d.ts +5 -0
  117. package/dist/types/index.d.ts +10 -0
  118. package/dist/types/internal.d.ts +2 -0
  119. package/dist/types/react-server.d.ts +3 -0
  120. package/dist/types/router/cli/code/getClientRoutes/getRoutes.d.ts +8 -0
  121. package/dist/types/router/cli/code/getClientRoutes/index.d.ts +1 -0
  122. package/dist/types/router/cli/code/getClientRoutes/utils.d.ts +4 -0
  123. package/dist/types/router/cli/code/index.d.ts +12 -0
  124. package/dist/types/router/cli/code/inspect.d.ts +22 -0
  125. package/dist/types/router/cli/code/makeLegalIdentifier.d.ts +1 -0
  126. package/dist/types/router/cli/code/nestedRoutes.d.ts +13 -0
  127. package/dist/types/router/cli/code/tanstackTypes.d.ts +10 -0
  128. package/dist/types/router/cli/code/templates.d.ts +28 -0
  129. package/dist/types/router/cli/code/utils.d.ts +12 -0
  130. package/dist/types/router/cli/config-routes/converter.d.ts +15 -0
  131. package/dist/types/router/cli/config-routes/parseRouteConfig.d.ts +32 -0
  132. package/dist/types/router/cli/constants.d.ts +31 -0
  133. package/dist/types/router/cli/entry.d.ts +18 -0
  134. package/dist/types/router/cli/handler.d.ts +28 -0
  135. package/dist/types/router/cli/index.d.ts +5 -0
  136. package/dist/types/router/index.d.ts +1 -0
  137. package/dist/types/router/internal.d.ts +2 -0
  138. package/dist/types/router/runtime/CSSLinks.d.ts +9 -0
  139. package/dist/types/router/runtime/DefaultNotFound.d.ts +2 -0
  140. package/dist/types/router/runtime/DeferredDataScripts.d.ts +2 -0
  141. package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +11 -0
  142. package/dist/types/router/runtime/PrefetchLink.d.ts +27 -0
  143. package/dist/types/router/runtime/constants.d.ts +146 -0
  144. package/dist/types/router/runtime/hooks.d.ts +18 -0
  145. package/dist/types/router/runtime/index.d.ts +7 -0
  146. package/dist/types/router/runtime/internal.d.ts +11 -0
  147. package/dist/types/router/runtime/lifecycle.d.ts +25 -0
  148. package/dist/types/router/runtime/plugin.d.ts +9 -0
  149. package/dist/types/router/runtime/plugin.node.d.ts +7 -0
  150. package/dist/types/router/runtime/routerHelper.d.ts +5 -0
  151. package/dist/types/router/runtime/rsc-router.d.ts +20 -0
  152. package/dist/types/router/runtime/rsc.d.ts +1 -0
  153. package/dist/types/router/runtime/server.d.ts +1 -0
  154. package/dist/types/router/runtime/tanstack/basepathRewrite.d.ts +8 -0
  155. package/dist/types/router/runtime/tanstack/dataMutation.d.ts +29 -0
  156. package/dist/types/router/runtime/tanstack/plugin.d.ts +6 -0
  157. package/dist/types/router/runtime/tanstack/plugin.node.d.ts +6 -0
  158. package/dist/types/router/runtime/tanstack/prefetchLink.d.ts +11 -0
  159. package/dist/types/router/runtime/tanstack/routeTree.d.ts +8 -0
  160. package/dist/types/router/runtime/tanstack/rsc/ClientSlot.d.ts +5 -0
  161. package/dist/types/router/runtime/tanstack/rsc/CompositeComponent.d.ts +3 -0
  162. package/dist/types/router/runtime/tanstack/rsc/ReplayableStream.d.ts +24 -0
  163. package/dist/types/router/runtime/tanstack/rsc/RscNodeRenderer.d.ts +5 -0
  164. package/dist/types/router/runtime/tanstack/rsc/SlotContext.d.ts +11 -0
  165. package/dist/types/router/runtime/tanstack/rsc/client.d.ts +11 -0
  166. package/dist/types/router/runtime/tanstack/rsc/createRscProxy.d.ts +7 -0
  167. package/dist/types/router/runtime/tanstack/rsc/index.d.ts +2 -0
  168. package/dist/types/router/runtime/tanstack/rsc/server.d.ts +14 -0
  169. package/dist/types/router/runtime/tanstack/rsc/slotUsageSanitizer.d.ts +2 -0
  170. package/dist/types/router/runtime/tanstack/rsc/symbols.d.ts +46 -0
  171. package/dist/types/router/runtime/types.d.ts +119 -0
  172. package/dist/types/router/runtime/utils.d.ts +48 -0
  173. package/dist/types/router/runtime/withRouter.d.ts +10 -0
  174. package/dist/types/rsc/client.d.ts +2 -0
  175. package/dist/types/rsc/server.d.ts +1 -0
  176. package/dist/types/rsc/server.worker.d.ts +1 -0
  177. 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,6 @@
1
+ export declare enum RenderLevel {
2
+ CLIENT_RENDER = 0,
3
+ SERVER_RENDER = 2
4
+ }
5
+ export declare const SSR_DATA_JSON_ID = "__MODERN_SSR_DATA__";
6
+ export declare const ROUTER_DATA_JSON_ID = "__MODERN_ROUTER_DATA__";
@@ -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,2 @@
1
+ import type { Monitors } from '@modern-js/types';
2
+ export declare const defaultMonitors: Omit<Monitors, 'push'>;
@@ -0,0 +1 @@
1
+ export declare const getMonitors: () => Omit<import("@modern-js/types").Monitors, "push">;
@@ -0,0 +1,2 @@
1
+ import type { Monitors } from '@modern-js/types';
2
+ export declare const getMonitors: () => Omit<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,4 @@
1
+ export declare const getResponseProxy: () => any;
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,4 @@
1
+ import type { PayloadRoute, ServerPayload } from './index.server';
2
+ export type { PayloadRoute, ServerPayload };
3
+ export declare const getServerPayload: () => ServerPayload | undefined;
4
+ export declare const setServerPayload: (payload: ServerPayload) => void;
@@ -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,2 @@
1
+ import type React from 'react';
2
+ export declare function createRoot(UserApp?: React.ComponentType | null): React.ComponentType<any>;
@@ -0,0 +1,3 @@
1
+ import type React from 'react';
2
+ import { type TRuntimeContext } from '../context';
3
+ export declare function wrapRuntimeContextProvider(App: React.ReactElement, contextValue: TRuntimeContext): React.JSX.Element;
@@ -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,3 @@
1
+ import type { HelmetData } from 'react-helmet';
2
+ export declare function createReplaceHelemt(helmetData?: HelmetData): (template: string) => string;
3
+ export declare function helmetReplace(content: string, helmetData: HelmetData): string;
@@ -0,0 +1,4 @@
1
+ import type { RuntimePlugin } from '../plugin';
2
+ export { NoSSR, NoSSRCache } from './react';
3
+ export declare const ssr: (_config: any) => RuntimePlugin;
4
+ export default ssr;
@@ -0,0 +1,2 @@
1
+ export { NoSSRCache } from './no-ssr-cache';
2
+ export { NoSSR } from './nossr';
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const NoSSRCache: () => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import React, { type ReactElement } from 'react';
2
+ export declare const NoSSR: (props?: React.PropsWithChildren<{
3
+ fallback?: ReactElement | string;
4
+ }>) => ReactElement | null;
@@ -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,2 @@
1
+ import { type CreateReadableStreamFromElement } from './shared';
2
+ export declare const createReadableStreamFromElement: CreateReadableStreamFromElement;
@@ -0,0 +1,2 @@
1
+ import { type CreateReadableStreamFromElement } from './shared';
2
+ export declare const createReadableStreamFromElement: CreateReadableStreamFromElement;
@@ -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,2 @@
1
+ import { type RenderString } from '../shared';
2
+ export declare const renderString: RenderString;
@@ -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,2 @@
1
+ import React from 'react';
2
+ export declare function Body(props: React.DOMAttributes<HTMLBodyElement>): React.JSX.Element;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare function Comment(props: {
3
+ comment?: string;
4
+ children?: string;
5
+ }): React.JSX.Element;
@@ -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 {};
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare function Head(props: {
3
+ children?: any;
4
+ }): React.JSX.Element;
5
+ export declare function DefaultHead(): React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare function Html(props: {
3
+ children: any[];
4
+ } & React.HtmlHTMLAttributes<HTMLHtmlElement>): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare function Links(): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare function Root(props: {
3
+ rootId?: string;
4
+ } & React.DOMAttributes<HTMLDivElement>): React.JSX.Element;
5
+ export declare function DefaultRoot(props: {
6
+ children?: any;
7
+ }): React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ export declare function Script(props: DocumentScriptProps): import("react").JSX.Element;
2
+ export interface DocumentScriptProps extends Omit<React.ScriptHTMLAttributes<HTMLScriptElement>, 'content'> {
3
+ content?: () => void;
4
+ }