@bleedingdev/modern-js-runtime 3.2.0-ultramodern.5 → 3.2.0-ultramodern.50

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 (189) 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/afterTemplate.js +9 -6
  7. package/dist/cjs/core/server/stream/beforeTemplate.js +6 -7
  8. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +104 -0
  9. package/dist/cjs/core/server/stream/createReadableStream.worker.js +2 -1
  10. package/dist/cjs/core/server/stream/shared.js +1 -0
  11. package/dist/cjs/core/server/string/index.js +1 -0
  12. package/dist/cjs/core/server/string/loadable.js +16 -1
  13. package/dist/cjs/router/cli/code/tanstackTypes.js +20 -6
  14. package/dist/cjs/router/runtime/tanstack/plugin.js +2 -0
  15. package/dist/cjs/router/runtime/tanstack/routeTree.js +38 -2
  16. package/dist/cjs/rsc/server.worker.js +58 -0
  17. package/dist/esm/cli/ssr/index.mjs +3 -2
  18. package/dist/esm/cli/template.server.mjs +1 -0
  19. package/dist/esm/core/context/serverPayload/index.mjs +1 -1
  20. package/dist/esm/core/plugin/index.mjs +3 -2
  21. package/dist/esm/core/server/helmet.mjs +1 -1
  22. package/dist/esm/core/server/stream/afterTemplate.mjs +10 -7
  23. package/dist/esm/core/server/stream/beforeTemplate.mjs +6 -7
  24. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +60 -0
  25. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +2 -1
  26. package/dist/esm/core/server/stream/shared.mjs +1 -0
  27. package/dist/esm/core/server/string/index.mjs +1 -0
  28. package/dist/esm/core/server/string/loadable.mjs +16 -1
  29. package/dist/esm/router/cli/code/tanstackTypes.mjs +20 -6
  30. package/dist/esm/router/runtime/tanstack/plugin.mjs +2 -0
  31. package/dist/esm/router/runtime/tanstack/routeTree.mjs +38 -2
  32. package/dist/esm/rsc/server.worker.mjs +1 -0
  33. package/dist/esm-node/cli/ssr/index.mjs +3 -2
  34. package/dist/esm-node/cli/template.server.mjs +1 -0
  35. package/dist/esm-node/core/context/serverPayload/index.mjs +1 -1
  36. package/dist/esm-node/core/plugin/index.mjs +3 -2
  37. package/dist/esm-node/core/server/helmet.mjs +1 -1
  38. package/dist/esm-node/core/server/stream/afterTemplate.mjs +10 -7
  39. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +6 -7
  40. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +61 -0
  41. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +2 -1
  42. package/dist/esm-node/core/server/stream/shared.mjs +1 -0
  43. package/dist/esm-node/core/server/string/index.mjs +1 -0
  44. package/dist/esm-node/core/server/string/loadable.mjs +16 -1
  45. package/dist/esm-node/router/cli/code/tanstackTypes.mjs +20 -6
  46. package/dist/esm-node/router/runtime/tanstack/plugin.mjs +2 -0
  47. package/dist/esm-node/router/runtime/tanstack/routeTree.mjs +38 -2
  48. package/dist/esm-node/rsc/server.worker.mjs +2 -0
  49. package/dist/types/cache/index.d.ts +1 -0
  50. package/dist/types/cli/alias.d.ts +7 -0
  51. package/dist/types/cli/code.d.ts +3 -0
  52. package/dist/types/cli/constants.d.ts +9 -0
  53. package/dist/types/cli/entry.d.ts +2 -0
  54. package/dist/types/cli/index.d.ts +11 -0
  55. package/dist/types/cli/ssr/index.d.ts +6 -0
  56. package/dist/types/cli/ssr/loadable-bundler-plugin.d.ts +31 -0
  57. package/dist/types/cli/ssr/mode.d.ts +15 -0
  58. package/dist/types/cli/template.d.ts +50 -0
  59. package/dist/types/cli/template.server.d.ts +20 -0
  60. package/dist/types/common.d.ts +8 -0
  61. package/dist/types/core/browser/hydrate.d.ts +5 -0
  62. package/dist/types/core/browser/index.d.ts +9 -0
  63. package/dist/types/core/browser/withCallback.d.ts +5 -0
  64. package/dist/types/core/compat/hooks.d.ts +4 -0
  65. package/dist/types/core/compat/index.d.ts +2 -0
  66. package/dist/types/core/compat/requestContext.d.ts +5 -0
  67. package/dist/types/core/config.d.ts +6 -0
  68. package/dist/types/core/constants.d.ts +6 -0
  69. package/dist/types/core/context/index.d.ts +50 -0
  70. package/dist/types/core/context/monitors/default.d.ts +2 -0
  71. package/dist/types/core/context/monitors/index.d.ts +1 -0
  72. package/dist/types/core/context/monitors/index.server.d.ts +2 -0
  73. package/dist/types/core/context/request/index.d.ts +1 -0
  74. package/dist/types/core/context/request/index.server.d.ts +1 -0
  75. package/dist/types/core/context/response/index.d.ts +4 -0
  76. package/dist/types/core/context/response/index.server.d.ts +4 -0
  77. package/dist/types/core/context/runtime.d.ts +42 -0
  78. package/dist/types/core/context/serverPayload/index.d.ts +4 -0
  79. package/dist/types/core/context/serverPayload/index.server.d.ts +31 -0
  80. package/dist/types/core/index.d.ts +5 -0
  81. package/dist/types/core/plugin/index.d.ts +5 -0
  82. package/dist/types/core/plugin/types.d.ts +10 -0
  83. package/dist/types/core/react/index.d.ts +2 -0
  84. package/dist/types/core/react/wrapper.d.ts +3 -0
  85. package/dist/types/core/server/constants.d.ts +4 -0
  86. package/dist/types/core/server/helmet.d.ts +3 -0
  87. package/dist/types/core/server/index.d.ts +4 -0
  88. package/dist/types/core/server/react/index.d.ts +2 -0
  89. package/dist/types/core/server/react/no-ssr-cache/index.d.ts +2 -0
  90. package/dist/types/core/server/react/nossr/index.d.ts +4 -0
  91. package/dist/types/core/server/requestHandler.d.ts +13 -0
  92. package/dist/types/core/server/server.d.ts +4 -0
  93. package/dist/types/core/server/shared.d.ts +8 -0
  94. package/dist/types/core/server/stream/afterTemplate.d.ts +13 -0
  95. package/dist/types/core/server/stream/beforeTemplate.d.ts +9 -0
  96. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +9 -0
  97. package/dist/types/core/server/stream/createReadableStream.d.ts +2 -0
  98. package/dist/types/core/server/stream/createReadableStream.worker.d.ts +2 -0
  99. package/dist/types/core/server/stream/deferredScript.d.ts +15 -0
  100. package/dist/types/core/server/stream/index.d.ts +1 -0
  101. package/dist/types/core/server/stream/shared.d.ts +40 -0
  102. package/dist/types/core/server/stream/template.d.ts +9 -0
  103. package/dist/types/core/server/string/index.d.ts +2 -0
  104. package/dist/types/core/server/string/loadable.d.ts +39 -0
  105. package/dist/types/core/server/string/ssrData.d.ts +20 -0
  106. package/dist/types/core/server/string/types.d.ts +12 -0
  107. package/dist/types/core/server/tracer.d.ts +17 -0
  108. package/dist/types/core/server/utils.d.ts +19 -0
  109. package/dist/types/core/types.d.ts +49 -0
  110. package/dist/types/document/Body.d.ts +2 -0
  111. package/dist/types/document/Comment.d.ts +5 -0
  112. package/dist/types/document/DocumentContext.d.ts +13 -0
  113. package/dist/types/document/DocumentStructureContext.d.ts +12 -0
  114. package/dist/types/document/Head.d.ts +5 -0
  115. package/dist/types/document/Html.d.ts +4 -0
  116. package/dist/types/document/Links.d.ts +2 -0
  117. package/dist/types/document/Root.d.ts +7 -0
  118. package/dist/types/document/Script.d.ts +4 -0
  119. package/dist/types/document/Scripts.d.ts +2 -0
  120. package/dist/types/document/Style.d.ts +5 -0
  121. package/dist/types/document/Title.d.ts +1 -0
  122. package/dist/types/document/cli/index.d.ts +5 -0
  123. package/dist/types/document/constants.d.ts +25 -0
  124. package/dist/types/document/index.d.ts +12 -0
  125. package/dist/types/exports/config-routes.d.ts +9 -0
  126. package/dist/types/exports/head.d.ts +4 -0
  127. package/dist/types/exports/loadable.d.ts +3 -0
  128. package/dist/types/exports/tanstack-router.d.ts +5 -0
  129. package/dist/types/index.d.ts +10 -0
  130. package/dist/types/internal.d.ts +2 -0
  131. package/dist/types/react-server.d.ts +3 -0
  132. package/dist/types/router/cli/code/getClientRoutes/getRoutes.d.ts +8 -0
  133. package/dist/types/router/cli/code/getClientRoutes/index.d.ts +1 -0
  134. package/dist/types/router/cli/code/getClientRoutes/utils.d.ts +4 -0
  135. package/dist/types/router/cli/code/index.d.ts +12 -0
  136. package/dist/types/router/cli/code/inspect.d.ts +22 -0
  137. package/dist/types/router/cli/code/makeLegalIdentifier.d.ts +1 -0
  138. package/dist/types/router/cli/code/nestedRoutes.d.ts +13 -0
  139. package/dist/types/router/cli/code/tanstackTypes.d.ts +10 -0
  140. package/dist/types/router/cli/code/templates.d.ts +28 -0
  141. package/dist/types/router/cli/code/utils.d.ts +12 -0
  142. package/dist/types/router/cli/config-routes/converter.d.ts +15 -0
  143. package/dist/types/router/cli/config-routes/parseRouteConfig.d.ts +32 -0
  144. package/dist/types/router/cli/constants.d.ts +31 -0
  145. package/dist/types/router/cli/entry.d.ts +18 -0
  146. package/dist/types/router/cli/handler.d.ts +28 -0
  147. package/dist/types/router/cli/index.d.ts +5 -0
  148. package/dist/types/router/index.d.ts +1 -0
  149. package/dist/types/router/internal.d.ts +2 -0
  150. package/dist/types/router/runtime/CSSLinks.d.ts +9 -0
  151. package/dist/types/router/runtime/DefaultNotFound.d.ts +2 -0
  152. package/dist/types/router/runtime/DeferredDataScripts.d.ts +2 -0
  153. package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +11 -0
  154. package/dist/types/router/runtime/PrefetchLink.d.ts +27 -0
  155. package/dist/types/router/runtime/constants.d.ts +146 -0
  156. package/dist/types/router/runtime/hooks.d.ts +18 -0
  157. package/dist/types/router/runtime/index.d.ts +7 -0
  158. package/dist/types/router/runtime/internal.d.ts +11 -0
  159. package/dist/types/router/runtime/lifecycle.d.ts +25 -0
  160. package/dist/types/router/runtime/plugin.d.ts +9 -0
  161. package/dist/types/router/runtime/plugin.node.d.ts +7 -0
  162. package/dist/types/router/runtime/routerHelper.d.ts +5 -0
  163. package/dist/types/router/runtime/rsc-router.d.ts +20 -0
  164. package/dist/types/router/runtime/rsc.d.ts +1 -0
  165. package/dist/types/router/runtime/server.d.ts +1 -0
  166. package/dist/types/router/runtime/tanstack/basepathRewrite.d.ts +8 -0
  167. package/dist/types/router/runtime/tanstack/dataMutation.d.ts +29 -0
  168. package/dist/types/router/runtime/tanstack/plugin.d.ts +6 -0
  169. package/dist/types/router/runtime/tanstack/plugin.node.d.ts +6 -0
  170. package/dist/types/router/runtime/tanstack/prefetchLink.d.ts +11 -0
  171. package/dist/types/router/runtime/tanstack/routeTree.d.ts +8 -0
  172. package/dist/types/router/runtime/tanstack/rsc/ClientSlot.d.ts +5 -0
  173. package/dist/types/router/runtime/tanstack/rsc/CompositeComponent.d.ts +3 -0
  174. package/dist/types/router/runtime/tanstack/rsc/ReplayableStream.d.ts +24 -0
  175. package/dist/types/router/runtime/tanstack/rsc/RscNodeRenderer.d.ts +5 -0
  176. package/dist/types/router/runtime/tanstack/rsc/SlotContext.d.ts +11 -0
  177. package/dist/types/router/runtime/tanstack/rsc/client.d.ts +11 -0
  178. package/dist/types/router/runtime/tanstack/rsc/createRscProxy.d.ts +7 -0
  179. package/dist/types/router/runtime/tanstack/rsc/index.d.ts +2 -0
  180. package/dist/types/router/runtime/tanstack/rsc/server.d.ts +14 -0
  181. package/dist/types/router/runtime/tanstack/rsc/slotUsageSanitizer.d.ts +2 -0
  182. package/dist/types/router/runtime/tanstack/rsc/symbols.d.ts +46 -0
  183. package/dist/types/router/runtime/types.d.ts +119 -0
  184. package/dist/types/router/runtime/utils.d.ts +48 -0
  185. package/dist/types/router/runtime/withRouter.d.ts +10 -0
  186. package/dist/types/rsc/client.d.ts +2 -0
  187. package/dist/types/rsc/server.d.ts +1 -0
  188. package/dist/types/rsc/server.worker.d.ts +1 -0
  189. package/package.json +15 -15
@@ -79,6 +79,7 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
79
79
  const imports = [];
80
80
  const statements = [];
81
81
  const loaderImportMap = new Map();
82
+ const usedRouteVarNames = new Set();
82
83
  let loaderIndex = 0;
83
84
  let routeIndex = 0;
84
85
  const getImportNamesForLoader = async (aliasedNoExtPath, inline, hasAction)=>{
@@ -112,10 +113,17 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
112
113
  actionName
113
114
  };
114
115
  };
116
+ const reserveRouteVarName = (preferred)=>{
117
+ let candidate = preferred;
118
+ let suffix = 1;
119
+ while(usedRouteVarNames.has(candidate))candidate = `${preferred}_${suffix++}`;
120
+ usedRouteVarNames.add(candidate);
121
+ return candidate;
122
+ };
115
123
  const createRouteVarName = (route)=>{
116
124
  const id = route.id;
117
125
  const base = id ? makeLegalIdentifier(id) : `r_${routeIndex++}`;
118
- return `route_${base}`;
126
+ return reserveRouteVarName(`route_${base}`);
119
127
  };
120
128
  const buildRoute = async (opts)=>{
121
129
  const { parentVar, route } = opts;
@@ -144,14 +152,16 @@ async function generateTanstackRouterTypesSourceForEntry(opts) {
144
152
  actionName
145
153
  });
146
154
  if (staticDataSnippet) routeOpts.push(staticDataSnippet);
147
- statements.push(`const ${varName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
148
155
  const children = route.children;
156
+ const hasChildren = Boolean(children && children.length > 0);
157
+ const routeCtorVarName = hasChildren ? reserveRouteVarName(`${varName}__base`) : varName;
158
+ statements.push(`const ${routeCtorVarName} = createRoute({\n ${routeOpts.join('\n ')}\n});`);
149
159
  if (children && children.length > 0) {
150
160
  const childVars = await Promise.all(children.map((child)=>buildRoute({
151
- parentVar: varName,
161
+ parentVar: routeCtorVarName,
152
162
  route: child
153
163
  })));
154
- statements.push(`${varName}.addChildren([${childVars.join(', ')}]);`);
164
+ statements.push(`const ${varName} = ${routeCtorVarName}.addChildren([${childVars.join(', ')}]);`);
155
165
  }
156
166
  return varName;
157
167
  };
@@ -224,7 +234,11 @@ function createRouteStaticData(opts: {
224
234
  modernRouteAction?: unknown;
225
235
  modernRouteLoader?: unknown;
226
236
  }) {
227
- const staticData: Record<string, unknown> = {};
237
+ const staticData: {
238
+ modernRouteId?: string;
239
+ modernRouteAction?: unknown;
240
+ modernRouteLoader?: unknown;
241
+ } = {};
228
242
 
229
243
  if (opts.modernRouteId) {
230
244
  staticData.modernRouteId = opts.modernRouteId;
@@ -238,7 +252,7 @@ function createRouteStaticData(opts: {
238
252
  staticData.modernRouteAction = opts.modernRouteAction;
239
253
  }
240
254
 
241
- return Object.keys(staticData).length > 0 ? staticData : undefined;
255
+ return staticData;
242
256
  }
243
257
 
244
258
  function modernLoaderToTanstack<TLoader extends (args: any) => any>(
@@ -9,6 +9,7 @@ import { onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBefo
9
9
  import { applyRouterRuntimeState } from "../lifecycle.mjs";
10
10
  import { createRouteObjectsFromConfig, urlJoin } from "../utils.mjs";
11
11
  import { createModernBasepathRewrite } from "./basepathRewrite.mjs";
12
+ import { Link } from "./prefetchLink.mjs";
12
13
  import { createRouteTreeFromRouteObjects } from "./routeTree.mjs";
13
14
  import { getTanstackRscSerializationAdapters } from "./rsc/client.mjs";
14
15
  import * as __rspack_external_react from "react";
@@ -71,6 +72,7 @@ const tanstackRouterPlugin = (userConfig = {})=>({
71
72
  }
72
73
  }
73
74
  context.router = {
75
+ Link: Link,
74
76
  useMatches: useMatches,
75
77
  useLocation: useLocation,
76
78
  useNavigate: useNavigate,
@@ -1,5 +1,6 @@
1
1
  import "node:module";
2
2
  import { createRootRoute, createRoute, notFound, redirect } from "@tanstack/react-router";
3
+ import { createElement } from "react";
3
4
  import { DefaultNotFound } from "../DefaultNotFound.mjs";
4
5
  function createTanstackRoute(options) {
5
6
  return createRoute(options);
@@ -44,6 +45,33 @@ function isModernDeferredData(value) {
44
45
  function normalizeModernLoaderResult(result) {
45
46
  return isModernDeferredData(result) ? result.data : result;
46
47
  }
48
+ function pickRouteModuleComponent(routeModule) {
49
+ if ('function' == typeof routeModule || routeModule && 'object' == typeof routeModule && '$$typeof' in routeModule) return routeModule;
50
+ if (!routeModule || 'object' != typeof routeModule) return;
51
+ const module = routeModule;
52
+ const component = module.default || module.Component;
53
+ if ('function' == typeof component || component && 'object' == typeof component && '$$typeof' in component) return component;
54
+ }
55
+ function createServerLazyImportComponent(lazyImport, fallbackComponent) {
56
+ if ("u" > typeof document) return fallbackComponent;
57
+ let resolvedComponent;
58
+ let pendingLoad;
59
+ const load = async ()=>{
60
+ if (resolvedComponent) return resolvedComponent;
61
+ const routeModule = await lazyImport();
62
+ const component = pickRouteModuleComponent(routeModule);
63
+ if (component) resolvedComponent = component;
64
+ return resolvedComponent;
65
+ };
66
+ const Component = (props)=>{
67
+ if (resolvedComponent) return createElement(resolvedComponent, props);
68
+ pendingLoad ||= load();
69
+ throw pendingLoad;
70
+ };
71
+ Component.load = load;
72
+ Component.preload = load;
73
+ return Component;
74
+ }
47
75
  function throwTanstackRedirect(location) {
48
76
  const target = location || '/';
49
77
  try {
@@ -210,10 +238,18 @@ function wrapRouteObjectLoader(route, revalidationState) {
210
238
  }
211
239
  function toRouteComponent(routeObject) {
212
240
  const route = routeObject;
241
+ const lazyImport = 'function' == typeof route.lazyImport ? route.lazyImport : void 0;
242
+ const fallbackComponent = route.Component ? route.Component : route.element ? ()=>route.element : void 0;
243
+ if (lazyImport && fallbackComponent) return createServerLazyImportComponent(lazyImport, fallbackComponent);
213
244
  if (route.Component) return route.Component;
214
245
  const element = route.element;
215
246
  if (element) return ()=>element;
216
247
  }
248
+ function toModernRouteComponent(route) {
249
+ const component = route.component || void 0;
250
+ if ('function' == typeof route.lazyImport && component) return createServerLazyImportComponent(route.lazyImport, component);
251
+ return component;
252
+ }
217
253
  function toErrorComponent(routeObject) {
218
254
  const route = routeObject;
219
255
  if (route.ErrorBoundary) return route.ErrorBoundary;
@@ -293,7 +329,7 @@ function createRouteFromModernRoute(opts) {
293
329
  const stableFallbackId = modernId || route._component || route.filename || route.data || ('function' == typeof route.loader ? route.id : void 0);
294
330
  const pendingComponent = route.loading || route.pendingComponent;
295
331
  const errorComponent = route.error || route.errorComponent;
296
- const component = route.component;
332
+ const component = toModernRouteComponent(route);
297
333
  const modernLoader = route.loader;
298
334
  const modernAction = route.action;
299
335
  const modernShouldRevalidate = route.shouldRevalidate;
@@ -339,7 +375,7 @@ function createRouteFromModernRoute(opts) {
339
375
  }
340
376
  function createRouteTreeFromModernRoutes(routes) {
341
377
  const rootModern = routes.find((r)=>r && 'nested' === r.type && r.isRoot);
342
- const rootComponent = rootModern?.component;
378
+ const rootComponent = rootModern ? toModernRouteComponent(rootModern) : void 0;
343
379
  const pendingComponent = rootModern?.loading;
344
380
  const errorComponent = rootModern?.error;
345
381
  const rootLoader = rootModern?.loader;
@@ -0,0 +1,2 @@
1
+ import "node:module";
2
+ export * from "@modern-js/render/rsc-worker";
@@ -0,0 +1 @@
1
+ export * from '@modern-js/runtime-utils/cache';
@@ -0,0 +1,7 @@
1
+ import type { Entrypoint } from '@modern-js/types';
2
+ import type { RsbuildPlugin } from '@rsbuild/core';
3
+ export declare const builderPluginAlias: ({ entrypoints, internalDirectory, metaName, }: {
4
+ entrypoints: Entrypoint[];
5
+ internalDirectory: string;
6
+ metaName: string;
7
+ }) => RsbuildPlugin;
@@ -0,0 +1,3 @@
1
+ import type { AppToolsContext, AppToolsFeatureHooks, AppToolsNormalizedConfig } from '@modern-js/app-tools';
2
+ import type { Entrypoint } from '@modern-js/types';
3
+ export declare const generateCode: (entrypoints: Entrypoint[], appContext: AppToolsContext, config: AppToolsNormalizedConfig, hooks: AppToolsFeatureHooks) => Promise<void>;
@@ -0,0 +1,9 @@
1
+ export declare const APP_FILE_NAME = "App";
2
+ export declare const ENTRY_POINT_FILE_NAME = "index.jsx";
3
+ export declare const SERVER_ENTRY_POINT_FILE_NAME = "index.server.jsx";
4
+ export declare const INDEX_FILE_NAME = "index";
5
+ export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.jsx";
6
+ export declare const ENTRY_SERVER_BOOTSTRAP_FILE_NAME = "bootstrap.server.jsx";
7
+ export declare const ENTRY_POINT_RUNTIME_REGISTER_FILE_NAME = "runtime-register.js";
8
+ export declare const ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME = "runtime-global-context";
9
+ export declare const ENTRY_POINT_REGISTER_FILE_NAME = "register.js";
@@ -0,0 +1,2 @@
1
+ export declare const hasApp: (dir: string) => any;
2
+ export declare const isRuntimeEntry: (dir: string) => any;
@@ -0,0 +1,11 @@
1
+ import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
+ import { documentPlugin } from '../document/cli';
3
+ import { routerPlugin } from '../router/cli';
4
+ import { ssrPlugin } from './ssr';
5
+ export { getEntrypointRoutesDir, handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints, isRouteEntry, } from '../router/cli';
6
+ export { isRuntimeEntry } from './entry';
7
+ export { documentPlugin, routerPlugin, ssrPlugin };
8
+ export declare const runtimePlugin: (params?: {
9
+ plugins?: CliPlugin<AppTools>[];
10
+ }) => CliPlugin<AppTools>;
11
+ export default runtimePlugin;
@@ -0,0 +1,6 @@
1
+ import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
+ import type { MergedEnvironmentConfig } from '@rsbuild/core';
3
+ type EnvironmentConfigLike = Partial<Pick<MergedEnvironmentConfig, 'output' | 'source' | 'tools'>>;
4
+ export declare const shouldUseModuleFederationNodeOutput: (config: EnvironmentConfigLike) => boolean;
5
+ export declare const ssrPlugin: () => CliPlugin<AppTools>;
6
+ export default ssrPlugin;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/gregberge/loadable-components
4
+ *
5
+ * MIT Licensed
6
+ * Author Greg Bergé
7
+ * Copyright 2019 Greg Bergé
8
+ * https://github.com/gregberge/loadable-components/blob/main/LICENSE
9
+ */
10
+ import type { Rspack } from '@modern-js/app-tools';
11
+ interface LoadablePluginOptions {
12
+ filename: string;
13
+ path?: string;
14
+ writeToDisk?: any;
15
+ outputAsset?: boolean;
16
+ chunkLoadingGlobal?: string;
17
+ }
18
+ type Compiler = Rspack.Compiler;
19
+ type Compilation = Rspack.Compilation;
20
+ declare class LoadablePlugin {
21
+ opts: LoadablePluginOptions;
22
+ compiler: Compiler | null;
23
+ constructor({ filename, path, writeToDisk, outputAsset, chunkLoadingGlobal, }?: LoadablePluginOptions);
24
+ apply(compiler: Compiler): void;
25
+ handleEmit(compilation: Compilation): {
26
+ source(): string;
27
+ size(): number;
28
+ } | null;
29
+ writeAssetsFile(manifest: string): void;
30
+ }
31
+ export default LoadablePlugin;
@@ -0,0 +1,15 @@
1
+ import type { AppToolsNormalizedConfig } from '@modern-js/app-tools';
2
+ export type SSRMode = 'string' | 'stream' | false;
3
+ /**
4
+ * Unified SSR mode resolution function.
5
+ * Priority:
6
+ * 1. If SSG is enabled, use SSG configuration (SSG takes precedence over SSR when both are configured)
7
+ * 2. User's explicit server.ssr/server.ssrByEntries config
8
+ * 3. Otherwise return false (no SSR)
9
+ */
10
+ export declare function resolveSSRMode(params: {
11
+ entry?: string;
12
+ config: AppToolsNormalizedConfig;
13
+ appDirectory?: string;
14
+ nestedRoutesEntry?: string;
15
+ }): SSRMode;
@@ -0,0 +1,50 @@
1
+ import type { RuntimePluginConfig } from '@modern-js/app-tools';
2
+ export declare const entryForCSRWithRSC: ({ metaName, entryName, urlPath, mountId, isNestedRouter, }: {
3
+ metaName: string;
4
+ entryName: string;
5
+ urlPath?: string;
6
+ mountId?: string;
7
+ isNestedRouter?: string;
8
+ }) => string;
9
+ export declare const index: ({ srcDirectory, internalSrcAlias, metaName, entry, entryName, customEntry, mountId, enableRsc, isNestedRouter, }: {
10
+ srcDirectory: string;
11
+ internalSrcAlias: string;
12
+ metaName: string;
13
+ entry: string;
14
+ entryName: string;
15
+ customEntry?: boolean;
16
+ mountId?: string;
17
+ enableRsc?: boolean;
18
+ isNestedRouter?: boolean;
19
+ }) => string;
20
+ export declare const register: () => string;
21
+ export declare const runtimeRegister: ({ entryName, srcDirectory, internalSrcAlias, metaName, runtimeConfigFile, runtimePlugins, }: {
22
+ entryName: string;
23
+ srcDirectory: string;
24
+ internalSrcAlias: string;
25
+ metaName: string;
26
+ runtimeConfigFile: string | false;
27
+ runtimePlugins: RuntimePluginConfig[];
28
+ }) => string;
29
+ export declare const runtimeGlobalContext: ({ entryName, srcDirectory, internalSrcAlias, metaName, entry, customEntry, basename, }: {
30
+ entryName: string;
31
+ srcDirectory: string;
32
+ internalSrcAlias: string;
33
+ metaName: string;
34
+ entry: string;
35
+ customEntry?: boolean;
36
+ basename?: string;
37
+ }) => string;
38
+ export declare const runtimeGlobalContextForRSCServer: ({ metaName, }: {
39
+ metaName: string;
40
+ }) => string;
41
+ export declare const runtimeGlobalContextForRSCClient: ({ metaName, customEntry, }: {
42
+ metaName: string;
43
+ customEntry?: boolean;
44
+ }) => string;
45
+ export declare const AppProxyForRSC: ({ srcDirectory, internalSrcAlias, entry, customEntry, }: {
46
+ srcDirectory: string;
47
+ internalSrcAlias: string;
48
+ entry: string;
49
+ customEntry?: boolean;
50
+ }) => string;
@@ -0,0 +1,20 @@
1
+ type ServerIndexOptinos = GenHandlerCodeOptions & {
2
+ entryName: string;
3
+ };
4
+ export declare const serverIndex: (options: ServerIndexOptinos) => string;
5
+ export declare const entryForCSRWithRSC: ({ metaName, entryName, }: {
6
+ metaName: string;
7
+ entryName: string;
8
+ }) => string;
9
+ type GenHandlerCodeOptions = {
10
+ customServerEntry?: string | false;
11
+ srcDirectory: string;
12
+ internalSrcAlias: string;
13
+ entry: string;
14
+ enableRsc?: boolean;
15
+ } & TransformServerEntryOptions;
16
+ type TransformServerEntryOptions = {
17
+ metaName?: string;
18
+ mode: 'string' | 'stream';
19
+ };
20
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { RuntimePlugin } from './core/plugin';
2
+ export declare const isBrowser: () => boolean;
3
+ export interface RuntimeConfig {
4
+ plugins?: RuntimePlugin[];
5
+ [key: string]: any;
6
+ }
7
+ export declare const JSX_SHELL_STREAM_END_MARK = "<!--<?- SHELL_STREAM_END ?>-->";
8
+ export declare const ESCAPED_SHELL_STREAM_END_MARK = "&lt;!--&lt;?- SHELL_STREAM_END ?&gt;--&gt;";
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ import type { Root } from 'react-dom/client';
3
+ import type { TRuntimeContext } from '../context/runtime';
4
+ export declare const isReact18: () => boolean;
5
+ export declare function hydrateRoot(App: React.ReactElement, context: TRuntimeContext, ModernRender: (App: React.ReactElement) => Promise<HTMLElement | Root>, ModernHydrate: (App: React.ReactElement, callback?: () => void) => Promise<HTMLElement | Root>): Promise<HTMLElement | Root>;
@@ -0,0 +1,9 @@
1
+ import type React from 'react';
2
+ export type RenderFunc = typeof render;
3
+ export declare function render(App: React.ReactElement<{
4
+ basename: string;
5
+ }>, id?: HTMLElement | string): Promise<HTMLElement | import("react-dom/client").Root>;
6
+ export declare function renderWithReact18(App: React.ReactElement, rootElement: HTMLElement): Promise<import("react-dom/client").Root>;
7
+ export declare function renderWithReact17(App: React.ReactElement, rootElement: HTMLElement): Promise<HTMLElement>;
8
+ export declare function hydrateWithReact18(App: React.ReactElement, rootElement: HTMLElement): Promise<import("react-dom/client").Root>;
9
+ export declare function hydrateWithReact17(App: React.ReactElement, rootElement: HTMLElement, callback?: () => void): Promise<any>;
@@ -0,0 +1,5 @@
1
+ import type React from 'react';
2
+ export declare const WithCallback: React.FC<{
3
+ callback: () => void;
4
+ children: React.ReactElement;
5
+ }>;
@@ -0,0 +1,4 @@
1
+ import type { TInternalRuntimeContext } from '../context';
2
+ export declare function transformHookRunner(hookRunnerName: string): string;
3
+ export declare function handleSetupResult(setupResult: Record<string, (...args: any) => any>, api: Record<string, any>): void;
4
+ export declare function getHookRunners(runtimeContext: TInternalRuntimeContext): Record<string, any>;
@@ -0,0 +1,2 @@
1
+ import type { RuntimePlugin } from '../plugin/types';
2
+ export declare const compatPlugin: () => RuntimePlugin;
@@ -0,0 +1,5 @@
1
+ import type { TInternalRuntimeContext } from '../context';
2
+ import type { RuntimePlugin } from '../plugin/types';
3
+ import type { RequestContext } from '../types';
4
+ export declare const makeRequestContext: (context: TInternalRuntimeContext) => RequestContext;
5
+ export declare const requestContextPlugin: () => RuntimePlugin;
@@ -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;