@bleedingdev/modern-js-runtime 3.9.0-ultramodern.2 → 3.9.0-ultramodern.20

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 (209) hide show
  1. package/dist/cjs/cli/code.js +3 -1
  2. package/dist/cjs/cli/ssr/index.js +2 -74
  3. package/dist/cjs/cli/ssr/loadable-bundler-plugin.js +2 -0
  4. package/dist/cjs/cli/template.server.js +1 -2
  5. package/dist/cjs/core/browser/hydrate.js +9 -10
  6. package/dist/cjs/core/browser/index.js +4 -5
  7. package/dist/cjs/core/context/index.js +12 -45
  8. package/dist/cjs/core/context/public.js +4 -7
  9. package/dist/cjs/core/context/runtime.js +10 -4
  10. package/dist/cjs/core/index.js +3 -3
  11. package/dist/cjs/core/plugin/index.js +2 -2
  12. package/dist/cjs/core/react/index.js +3 -3
  13. package/dist/cjs/core/react/wrapper.js +23 -67
  14. package/dist/cjs/core/server/helmet.js +5 -4
  15. package/dist/cjs/core/server/requestHandler.js +6 -7
  16. package/dist/cjs/core/server/requestResponse.js +4 -4
  17. package/dist/cjs/core/server/routerCleanup.js +2 -2
  18. package/dist/cjs/core/server/shared.js +171 -4
  19. package/dist/cjs/core/server/stream/afterTemplate.js +21 -16
  20. package/dist/cjs/core/server/stream/beforeTemplate.js +37 -28
  21. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +30 -23
  22. package/dist/cjs/core/server/stream/createReadableStream.js +222 -125
  23. package/dist/cjs/core/server/stream/createReadableStream.worker.js +171 -90
  24. package/dist/cjs/core/server/stream/deferredScript.js +3 -3
  25. package/dist/cjs/core/server/stream/shared.js +6 -2
  26. package/dist/cjs/core/server/string/index.js +104 -66
  27. package/dist/cjs/core/server/string/loadable.js +38 -23
  28. package/dist/cjs/core/server/string/ssrData.js +5 -12
  29. package/dist/cjs/core/server/utils.js +1 -2
  30. package/dist/cjs/exports/head.js +7 -14
  31. package/dist/cjs/internal.js +2 -2
  32. package/dist/cjs/router/cli/code/nestedRoutes.js +1 -2
  33. package/dist/cjs/router/cli/code/templates.js +1 -1
  34. package/dist/cjs/router/cli/code/utils.js +2 -2
  35. package/dist/cjs/router/runtime/DeferredDataScripts.node.js +10 -9
  36. package/dist/cjs/router/runtime/PrefetchLink.js +69 -125
  37. package/dist/cjs/router/runtime/hooks.js +13 -2
  38. package/dist/cjs/router/runtime/internal.js +7 -45
  39. package/dist/cjs/router/runtime/plugin.js +19 -34
  40. package/dist/cjs/router/runtime/plugin.node.js +9 -37
  41. package/dist/cjs/router/runtime/redirect.js +1 -1
  42. package/dist/esm/cli/code.mjs +3 -1
  43. package/dist/esm/cli/ssr/index.mjs +3 -72
  44. package/dist/esm/cli/ssr/loadable-bundler-plugin.mjs +2 -0
  45. package/dist/esm/cli/template.server.mjs +1 -2
  46. package/dist/esm/core/browser/hydrate.mjs +10 -11
  47. package/dist/esm/core/browser/index.mjs +1 -2
  48. package/dist/esm/core/context/index.mjs +2 -5
  49. package/dist/esm/core/context/public.mjs +1 -5
  50. package/dist/esm/core/context/runtime.mjs +6 -3
  51. package/dist/esm/core/index.mjs +1 -1
  52. package/dist/esm/core/plugin/index.mjs +1 -1
  53. package/dist/esm/core/react/index.mjs +1 -1
  54. package/dist/esm/core/react/wrapper.mjs +20 -67
  55. package/dist/esm/core/server/helmet.mjs +5 -4
  56. package/dist/esm/core/server/requestHandler.mjs +1 -2
  57. package/dist/esm/core/server/requestResponse.mjs +3 -3
  58. package/dist/esm/core/server/routerCleanup.mjs +1 -1
  59. package/dist/esm/core/server/shared.mjs +153 -1
  60. package/dist/esm/core/server/stream/afterTemplate.mjs +23 -18
  61. package/dist/esm/core/server/stream/beforeTemplate.mjs +40 -31
  62. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +33 -26
  63. package/dist/esm/core/server/stream/createReadableStream.mjs +220 -123
  64. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +161 -90
  65. package/dist/esm/core/server/stream/deferredScript.mjs +3 -3
  66. package/dist/esm/core/server/stream/shared.mjs +4 -3
  67. package/dist/esm/core/server/string/index.mjs +106 -68
  68. package/dist/esm/core/server/string/loadable.mjs +38 -23
  69. package/dist/esm/core/server/string/ssrData.mjs +5 -12
  70. package/dist/esm/core/server/utils.mjs +1 -2
  71. package/dist/esm/exports/head.mjs +7 -14
  72. package/dist/esm/internal.mjs +1 -1
  73. package/dist/esm/router/cli/code/nestedRoutes.mjs +1 -2
  74. package/dist/esm/router/cli/code/templates.mjs +1 -1
  75. package/dist/esm/router/cli/code/utils.mjs +2 -2
  76. package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +10 -9
  77. package/dist/esm/router/runtime/PrefetchLink.mjs +68 -124
  78. package/dist/esm/router/runtime/hooks.mjs +9 -1
  79. package/dist/esm/router/runtime/internal.mjs +2 -33
  80. package/dist/esm/router/runtime/plugin.mjs +10 -25
  81. package/dist/esm/router/runtime/plugin.node.mjs +3 -31
  82. package/dist/esm/router/runtime/redirect.mjs +1 -1
  83. package/dist/esm-node/cli/code.mjs +3 -1
  84. package/dist/esm-node/cli/ssr/index.mjs +3 -72
  85. package/dist/esm-node/cli/ssr/loadable-bundler-plugin.mjs +2 -0
  86. package/dist/esm-node/cli/template.server.mjs +1 -2
  87. package/dist/esm-node/core/browser/hydrate.mjs +10 -11
  88. package/dist/esm-node/core/browser/index.mjs +1 -2
  89. package/dist/esm-node/core/context/index.mjs +2 -5
  90. package/dist/esm-node/core/context/public.mjs +1 -5
  91. package/dist/esm-node/core/context/runtime.mjs +6 -3
  92. package/dist/esm-node/core/index.mjs +1 -1
  93. package/dist/esm-node/core/plugin/index.mjs +1 -1
  94. package/dist/esm-node/core/react/index.mjs +1 -1
  95. package/dist/esm-node/core/react/wrapper.mjs +20 -67
  96. package/dist/esm-node/core/server/helmet.mjs +5 -4
  97. package/dist/esm-node/core/server/requestHandler.mjs +1 -2
  98. package/dist/esm-node/core/server/requestResponse.mjs +3 -3
  99. package/dist/esm-node/core/server/routerCleanup.mjs +1 -1
  100. package/dist/esm-node/core/server/shared.mjs +153 -1
  101. package/dist/esm-node/core/server/stream/afterTemplate.mjs +23 -18
  102. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +40 -31
  103. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +33 -26
  104. package/dist/esm-node/core/server/stream/createReadableStream.mjs +220 -123
  105. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +161 -90
  106. package/dist/esm-node/core/server/stream/deferredScript.mjs +3 -3
  107. package/dist/esm-node/core/server/stream/shared.mjs +4 -3
  108. package/dist/esm-node/core/server/string/index.mjs +106 -68
  109. package/dist/esm-node/core/server/string/loadable.mjs +38 -23
  110. package/dist/esm-node/core/server/string/ssrData.mjs +5 -12
  111. package/dist/esm-node/core/server/utils.mjs +1 -2
  112. package/dist/esm-node/exports/head.mjs +7 -14
  113. package/dist/esm-node/internal.mjs +1 -1
  114. package/dist/esm-node/router/cli/code/nestedRoutes.mjs +1 -2
  115. package/dist/esm-node/router/cli/code/templates.mjs +1 -1
  116. package/dist/esm-node/router/cli/code/utils.mjs +2 -2
  117. package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +10 -9
  118. package/dist/esm-node/router/runtime/PrefetchLink.mjs +68 -124
  119. package/dist/esm-node/router/runtime/hooks.mjs +9 -1
  120. package/dist/esm-node/router/runtime/internal.mjs +2 -33
  121. package/dist/esm-node/router/runtime/plugin.mjs +10 -25
  122. package/dist/esm-node/router/runtime/plugin.node.mjs +3 -31
  123. package/dist/esm-node/router/runtime/redirect.mjs +1 -1
  124. package/dist/types/cli/ssr/index.d.ts +0 -3
  125. package/dist/types/core/context/index.d.ts +4 -6
  126. package/dist/types/core/context/public.d.ts +1 -23
  127. package/dist/types/core/context/runtime.d.ts +26 -2
  128. package/dist/types/core/index.d.ts +1 -1
  129. package/dist/types/core/react/wrapper.d.ts +7 -1
  130. package/dist/types/core/server/helmet.d.ts +4 -5
  131. package/dist/types/core/server/requestHandler.d.ts +3 -3
  132. package/dist/types/core/server/requestResponse.d.ts +1 -1
  133. package/dist/types/core/server/routerCleanup.d.ts +1 -1
  134. package/dist/types/core/server/shared.d.ts +24 -1
  135. package/dist/types/core/server/stream/afterTemplate.d.ts +2 -1
  136. package/dist/types/core/server/stream/beforeTemplate.d.ts +4 -1
  137. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +4 -1
  138. package/dist/types/core/server/stream/shared.d.ts +16 -2
  139. package/dist/types/core/server/string/loadable.d.ts +6 -3
  140. package/dist/types/core/server/string/ssrData.d.ts +2 -1
  141. package/dist/types/core/server/string/types.d.ts +1 -5
  142. package/dist/types/core/server/tracer.d.ts +1 -1
  143. package/dist/types/core/server/utils.d.ts +1 -1
  144. package/dist/types/core/types.d.ts +1 -2
  145. package/dist/types/exports/head.d.ts +2 -2
  146. package/dist/types/internal.d.ts +1 -1
  147. package/dist/types/router/runtime/PrefetchLink.d.ts +27 -2
  148. package/dist/types/router/runtime/hooks.d.ts +19 -2
  149. package/dist/types/router/runtime/internal.d.ts +4 -21
  150. package/dist/types/router/runtime/types.d.ts +2 -43
  151. package/package.json +18 -46
  152. package/rslib.config.mts +3 -0
  153. package/rstest.config.mts +28 -2
  154. package/dist/cjs/boundary-debugger/index.js +0 -317
  155. package/dist/cjs/core/context/extensions.js +0 -74
  156. package/dist/cjs/core/context/helmetContext.js +0 -54
  157. package/dist/cjs/core/server/federatedCss.js +0 -58
  158. package/dist/cjs/core/server/scriptOrder.js +0 -140
  159. package/dist/cjs/module-federation/consume-surface.js +0 -199
  160. package/dist/cjs/module-federation/distributed-ssr.js +0 -135
  161. package/dist/cjs/module-federation/index.js +0 -316
  162. package/dist/cjs/module-federation/last-known-good.js +0 -157
  163. package/dist/cjs/module-federation/manifest-recovery-runtime-plugin.js +0 -129
  164. package/dist/cjs/module-federation/surface-resolution-types.js +0 -61
  165. package/dist/cjs/router/runtime/lifecycle.js +0 -167
  166. package/dist/cjs/router/runtime/provider.js +0 -153
  167. package/dist/cjs/rsc/server.worker.js +0 -62
  168. package/dist/esm/boundary-debugger/index.mjs +0 -277
  169. package/dist/esm/core/context/extensions.mjs +0 -33
  170. package/dist/esm/core/context/helmetContext.mjs +0 -13
  171. package/dist/esm/core/server/federatedCss.mjs +0 -20
  172. package/dist/esm/core/server/scriptOrder.mjs +0 -90
  173. package/dist/esm/module-federation/consume-surface.mjs +0 -158
  174. package/dist/esm/module-federation/distributed-ssr.mjs +0 -82
  175. package/dist/esm/module-federation/index.mjs +0 -115
  176. package/dist/esm/module-federation/last-known-good.mjs +0 -113
  177. package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +0 -89
  178. package/dist/esm/module-federation/surface-resolution-types.mjs +0 -8
  179. package/dist/esm/router/runtime/lifecycle.mjs +0 -105
  180. package/dist/esm/router/runtime/provider.mjs +0 -100
  181. package/dist/esm/rsc/server.worker.mjs +0 -1
  182. package/dist/esm-node/boundary-debugger/index.mjs +0 -278
  183. package/dist/esm-node/core/context/extensions.mjs +0 -34
  184. package/dist/esm-node/core/context/helmetContext.mjs +0 -14
  185. package/dist/esm-node/core/server/federatedCss.mjs +0 -21
  186. package/dist/esm-node/core/server/scriptOrder.mjs +0 -91
  187. package/dist/esm-node/module-federation/consume-surface.mjs +0 -159
  188. package/dist/esm-node/module-federation/distributed-ssr.mjs +0 -83
  189. package/dist/esm-node/module-federation/index.mjs +0 -116
  190. package/dist/esm-node/module-federation/last-known-good.mjs +0 -114
  191. package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +0 -90
  192. package/dist/esm-node/module-federation/surface-resolution-types.mjs +0 -9
  193. package/dist/esm-node/router/runtime/lifecycle.mjs +0 -106
  194. package/dist/esm-node/router/runtime/provider.mjs +0 -101
  195. package/dist/esm-node/rsc/server.worker.mjs +0 -2
  196. package/dist/types/boundary-debugger/index.d.ts +0 -28
  197. package/dist/types/core/context/extensions.d.ts +0 -35
  198. package/dist/types/core/context/helmetContext.d.ts +0 -10
  199. package/dist/types/core/server/federatedCss.d.ts +0 -5
  200. package/dist/types/core/server/scriptOrder.d.ts +0 -25
  201. package/dist/types/module-federation/consume-surface.d.ts +0 -104
  202. package/dist/types/module-federation/distributed-ssr.d.ts +0 -61
  203. package/dist/types/module-federation/index.d.ts +0 -71
  204. package/dist/types/module-federation/last-known-good.d.ts +0 -52
  205. package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +0 -25
  206. package/dist/types/module-federation/surface-resolution-types.d.ts +0 -23
  207. package/dist/types/router/runtime/lifecycle.d.ts +0 -27
  208. package/dist/types/router/runtime/provider.d.ts +0 -78
  209. package/dist/types/rsc/server.worker.d.ts +0 -1
@@ -1,23 +0,0 @@
1
- /**
2
- * Surface-resolution types for the module-federation runtime.
3
- *
4
- * Thin re-export of the canonical module in `@modern-js/utils/universal`
5
- * (`packages/toolkit/utils/src/universal/surface-resolution/`,
6
- * RESOLUTION-0001). Kept as a file so existing `./surface-resolution-types`
7
- * imports stay stable. Only helpers the canonical module deliberately does not
8
- * ship (the (ref, env) cache key) live here, implemented against canonical
9
- * types.
10
- */
11
- import { type EnvironmentId, type ParsedSurfaceRef } from '@modern-js/utils/universal';
12
- export { type CompatibilityStatus, type CompatibilityVerdict, createDiscoveryError, type DiscoveryError, type DiscoveryErrorCode, type DiscoveryResult, type EnvironmentId, formatSurfaceRef, type ParsedSurfaceRef, parseSurfaceRef, type ResolvedDeliveryUnit, type ResolvedSurface, type ResolvedSurfaceKind, type ResolvedSurfaceLocation, type ResolvedSurfaceLocationPlatform, type SurfaceRefParseError, type SurfaceRefParseResult, type SurfaceResolutionProvider, validateSurfaceRef, } from '@modern-js/utils/universal';
13
- /** Stable cache/identity key for a (ref, env) pair. */
14
- export declare function surfaceResolutionKey(ref: ParsedSurfaceRef, env: EnvironmentId): string;
15
- /**
16
- * Stable cache key for a (deliveryUnit, env) pair — ONE record per unit per
17
- * env (ADR-0019 atomicity). All surfaces of a unit share this key so a refresh
18
- * replaces the whole unit snapshot atomically for every surface, and two
19
- * surfaces of the same unit can never be served from different cached
20
- * snapshots. The ref's external-major participates in lookup validation (see
21
- * the LKG provider), not in this key.
22
- */
23
- export declare function deliveryUnitResolutionKey(unitId: string, env: EnvironmentId): string;
@@ -1,27 +0,0 @@
1
- import type { RouteObject } from '@modern-js/runtime-utils/router';
2
- import type { TInternalRuntimeContext } from '../../core/context/runtime.js';
3
- import type { InternalRouterRuntimeState, InternalRouterServerSnapshot, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult } from './types.js';
4
- export declare function getRouterRuntimeState(runtimeContext: object): InternalRouterRuntimeState | undefined;
5
- export declare function getRouterServerSnapshot(runtimeContext: object): InternalRouterServerSnapshot | undefined;
6
- export type RouterLifecyclePhase = 'ssr-prepare' | 'client-create' | 'hydrate';
7
- export type RouterLifecycleContext = {
8
- framework: RouterFramework;
9
- phase: RouterLifecyclePhase;
10
- routes: RouteObject[];
11
- runtimeContext: TInternalRuntimeContext;
12
- basename?: string;
13
- hydrationData?: unknown;
14
- router?: unknown;
15
- matches?: RouterRouteMatchSnapshot[];
16
- cleanup?: () => void | Promise<void>;
17
- serverSnapshot?: InternalRouterServerSnapshot;
18
- };
19
- type RouterSnapshotLike = Partial<InternalRouterServerSnapshot>;
20
- export declare function createRouterServerSnapshot(state: RouterSnapshotLike): InternalRouterServerSnapshot;
21
- export declare function createRouterRuntimeState(state: InternalRouterRuntimeState): InternalRouterRuntimeState;
22
- export declare function applyRouterRuntimeState(runtimeContext: TInternalRuntimeContext, state: InternalRouterRuntimeState): TInternalRuntimeContext;
23
- export declare function applyRouterServerPrepareResult(runtimeContext: TInternalRuntimeContext, result: RouterServerPrepareResult): TInternalRuntimeContext;
24
- export declare function getRouterHydrationScripts(runtimeContext: TInternalRuntimeContext): string[];
25
- export declare function getRouterMatchedRouteIds(runtimeContext: TInternalRuntimeContext): string[] | undefined;
26
- export declare function cleanupRouterRuntimeState(runtimeContext: TInternalRuntimeContext): Promise<void>;
27
- export {};
@@ -1,78 +0,0 @@
1
- /**
2
- * Fork-owned router-provider registry.
3
- *
4
- * `runtime.router.framework` selects the router implementation used by the
5
- * built-in router runtime plugin (`@modern-js/runtime/router/internal`).
6
- * Instead of hardcoding every implementation there, providers register
7
- * themselves here:
8
- *
9
- * - `react-router` registers itself as the default provider when the
10
- * built-in router plugin module is loaded.
11
- * - `@modern-js/plugin-tanstack` registers the `tanstack` provider when its
12
- * runtime entry is imported.
13
- */
14
- import type { RuntimePlugin } from '../../common.js';
15
- import type { RouterExtendsHooks } from './hooks.js';
16
- import type { RouterConfig } from './types.js';
17
- /**
18
- * The single declaration source for the router hook registry. Every router
19
- * provider (built-in react-router, @modern-js/plugin-tanstack, ...) and the
20
- * framework-resolving wrapper plugin register exactly these instances, so the
21
- * hook set is defined once and providers cannot drift apart.
22
- */
23
- export declare const routerProviderRegistryHooks: RouterExtendsHooks;
24
- export type RouterProviderPlugin = RuntimePlugin<{
25
- extendHooks: RouterExtendsHooks;
26
- }>;
27
- /**
28
- * Guard for the wrapper plugin (`router/internal`): a resolved provider is
29
- * only invoked through `setup`, so registry hooks outside the canonical
30
- * router hook contract cannot be registered for it. Returns the offending
31
- * hook names and warns once so they are surfaced instead of silently dropped.
32
- */
33
- export declare function reportUnsupportedProviderRegistryHooks(providerPlugin: {
34
- name?: string;
35
- registryHooks?: Record<string, unknown>;
36
- }): string[];
37
- export type RouterProviderFactory = (userConfig: Partial<RouterConfig>) => RouterProviderPlugin;
38
- export type RouterProviderRegistration = {
39
- name: string;
40
- factory: RouterProviderFactory;
41
- isDefault?: boolean;
42
- };
43
- /**
44
- * App-owned provider catalog. Provider factories close over their module graph,
45
- * so they must be resolved from the runtime wrapper that owns the app instead
46
- * of from a page-global first-registration winner.
47
- */
48
- export type RouterProviderRealm = Readonly<{
49
- defaultProvider?: string;
50
- get: (name: string) => RouterProviderFactory | undefined;
51
- names: () => readonly string[];
52
- }>;
53
- export declare function createRouterProviderRealm(registrations: readonly RouterProviderRegistration[]): RouterProviderRealm;
54
- export declare function registerRouterProvider(name: string, factory: RouterProviderFactory, options?: {
55
- isDefault?: boolean;
56
- }): void;
57
- export declare function resolveRouterProvider(framework?: RouterConfig['framework'], options?: {
58
- /**
59
- * Provider factories owned by the resolving app/runtime wrapper. A realm
60
- * is the exclusive provider source when supplied because its factories
61
- * close over the correct app module graph.
62
- */
63
- realm?: RouterProviderRealm;
64
- /**
65
- * Legacy single-provider override retained for published wrappers. New
66
- * integrations should pass an app-owned `realm`, which supports every
67
- * provider rather than only the default.
68
- */
69
- localDefault?: {
70
- name: string;
71
- factory: RouterProviderFactory;
72
- };
73
- }): RouterProviderFactory;
74
- /**
75
- * Test-only escape hatch: compatibility registries live on `globalThis`, so
76
- * unit tests need a way to restore a pristine state between cases.
77
- */
78
- export declare function unsafe_resetRouterProvidersForTesting(): void;
@@ -1 +0,0 @@
1
- export * from '@modern-js/render/rsc-worker';