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

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 (213) 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/document/cli/index.js +14 -5
  31. package/dist/cjs/exports/head.js +7 -14
  32. package/dist/cjs/internal.js +2 -2
  33. package/dist/cjs/router/cli/code/nestedRoutes.js +1 -2
  34. package/dist/cjs/router/cli/code/templates.js +1 -1
  35. package/dist/cjs/router/cli/code/utils.js +2 -2
  36. package/dist/cjs/router/runtime/DeferredDataScripts.node.js +10 -9
  37. package/dist/cjs/router/runtime/PrefetchLink.js +69 -125
  38. package/dist/cjs/router/runtime/hooks.js +13 -2
  39. package/dist/cjs/router/runtime/internal.js +7 -45
  40. package/dist/cjs/router/runtime/plugin.js +19 -34
  41. package/dist/cjs/router/runtime/plugin.node.js +9 -37
  42. package/dist/cjs/router/runtime/redirect.js +1 -1
  43. package/dist/esm/cli/code.mjs +3 -1
  44. package/dist/esm/cli/ssr/index.mjs +3 -72
  45. package/dist/esm/cli/ssr/loadable-bundler-plugin.mjs +2 -0
  46. package/dist/esm/cli/template.server.mjs +1 -2
  47. package/dist/esm/core/browser/hydrate.mjs +10 -11
  48. package/dist/esm/core/browser/index.mjs +1 -2
  49. package/dist/esm/core/context/index.mjs +2 -5
  50. package/dist/esm/core/context/public.mjs +1 -5
  51. package/dist/esm/core/context/runtime.mjs +6 -3
  52. package/dist/esm/core/index.mjs +1 -1
  53. package/dist/esm/core/plugin/index.mjs +1 -1
  54. package/dist/esm/core/react/index.mjs +1 -1
  55. package/dist/esm/core/react/wrapper.mjs +20 -67
  56. package/dist/esm/core/server/helmet.mjs +5 -4
  57. package/dist/esm/core/server/requestHandler.mjs +1 -2
  58. package/dist/esm/core/server/requestResponse.mjs +3 -3
  59. package/dist/esm/core/server/routerCleanup.mjs +1 -1
  60. package/dist/esm/core/server/shared.mjs +153 -1
  61. package/dist/esm/core/server/stream/afterTemplate.mjs +23 -18
  62. package/dist/esm/core/server/stream/beforeTemplate.mjs +40 -31
  63. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +33 -26
  64. package/dist/esm/core/server/stream/createReadableStream.mjs +220 -123
  65. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +161 -90
  66. package/dist/esm/core/server/stream/deferredScript.mjs +3 -3
  67. package/dist/esm/core/server/stream/shared.mjs +4 -3
  68. package/dist/esm/core/server/string/index.mjs +106 -68
  69. package/dist/esm/core/server/string/loadable.mjs +38 -23
  70. package/dist/esm/core/server/string/ssrData.mjs +5 -12
  71. package/dist/esm/core/server/utils.mjs +1 -2
  72. package/dist/esm/document/cli/index.mjs +12 -6
  73. package/dist/esm/exports/head.mjs +7 -14
  74. package/dist/esm/internal.mjs +1 -1
  75. package/dist/esm/router/cli/code/nestedRoutes.mjs +1 -2
  76. package/dist/esm/router/cli/code/templates.mjs +1 -1
  77. package/dist/esm/router/cli/code/utils.mjs +2 -2
  78. package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +10 -9
  79. package/dist/esm/router/runtime/PrefetchLink.mjs +68 -124
  80. package/dist/esm/router/runtime/hooks.mjs +9 -1
  81. package/dist/esm/router/runtime/internal.mjs +2 -33
  82. package/dist/esm/router/runtime/plugin.mjs +10 -25
  83. package/dist/esm/router/runtime/plugin.node.mjs +3 -31
  84. package/dist/esm/router/runtime/redirect.mjs +1 -1
  85. package/dist/esm-node/cli/code.mjs +3 -1
  86. package/dist/esm-node/cli/ssr/index.mjs +3 -72
  87. package/dist/esm-node/cli/ssr/loadable-bundler-plugin.mjs +2 -0
  88. package/dist/esm-node/cli/template.server.mjs +1 -2
  89. package/dist/esm-node/core/browser/hydrate.mjs +10 -11
  90. package/dist/esm-node/core/browser/index.mjs +1 -2
  91. package/dist/esm-node/core/context/index.mjs +2 -5
  92. package/dist/esm-node/core/context/public.mjs +1 -5
  93. package/dist/esm-node/core/context/runtime.mjs +6 -3
  94. package/dist/esm-node/core/index.mjs +1 -1
  95. package/dist/esm-node/core/plugin/index.mjs +1 -1
  96. package/dist/esm-node/core/react/index.mjs +1 -1
  97. package/dist/esm-node/core/react/wrapper.mjs +20 -67
  98. package/dist/esm-node/core/server/helmet.mjs +5 -4
  99. package/dist/esm-node/core/server/requestHandler.mjs +1 -2
  100. package/dist/esm-node/core/server/requestResponse.mjs +3 -3
  101. package/dist/esm-node/core/server/routerCleanup.mjs +1 -1
  102. package/dist/esm-node/core/server/shared.mjs +153 -1
  103. package/dist/esm-node/core/server/stream/afterTemplate.mjs +23 -18
  104. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +40 -31
  105. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +33 -26
  106. package/dist/esm-node/core/server/stream/createReadableStream.mjs +220 -123
  107. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +161 -90
  108. package/dist/esm-node/core/server/stream/deferredScript.mjs +3 -3
  109. package/dist/esm-node/core/server/stream/shared.mjs +4 -3
  110. package/dist/esm-node/core/server/string/index.mjs +106 -68
  111. package/dist/esm-node/core/server/string/loadable.mjs +38 -23
  112. package/dist/esm-node/core/server/string/ssrData.mjs +5 -12
  113. package/dist/esm-node/core/server/utils.mjs +1 -2
  114. package/dist/esm-node/document/cli/index.mjs +12 -6
  115. package/dist/esm-node/exports/head.mjs +7 -14
  116. package/dist/esm-node/internal.mjs +1 -1
  117. package/dist/esm-node/router/cli/code/nestedRoutes.mjs +1 -2
  118. package/dist/esm-node/router/cli/code/templates.mjs +1 -1
  119. package/dist/esm-node/router/cli/code/utils.mjs +2 -2
  120. package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +10 -9
  121. package/dist/esm-node/router/runtime/PrefetchLink.mjs +68 -124
  122. package/dist/esm-node/router/runtime/hooks.mjs +9 -1
  123. package/dist/esm-node/router/runtime/internal.mjs +2 -33
  124. package/dist/esm-node/router/runtime/plugin.mjs +10 -25
  125. package/dist/esm-node/router/runtime/plugin.node.mjs +3 -31
  126. package/dist/esm-node/router/runtime/redirect.mjs +1 -1
  127. package/dist/types/cli/ssr/index.d.ts +0 -3
  128. package/dist/types/core/context/index.d.ts +4 -6
  129. package/dist/types/core/context/public.d.ts +1 -23
  130. package/dist/types/core/context/runtime.d.ts +26 -2
  131. package/dist/types/core/index.d.ts +1 -1
  132. package/dist/types/core/react/wrapper.d.ts +7 -1
  133. package/dist/types/core/server/helmet.d.ts +4 -5
  134. package/dist/types/core/server/requestHandler.d.ts +3 -3
  135. package/dist/types/core/server/requestResponse.d.ts +1 -1
  136. package/dist/types/core/server/routerCleanup.d.ts +1 -1
  137. package/dist/types/core/server/shared.d.ts +24 -1
  138. package/dist/types/core/server/stream/afterTemplate.d.ts +2 -1
  139. package/dist/types/core/server/stream/beforeTemplate.d.ts +4 -1
  140. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +4 -1
  141. package/dist/types/core/server/stream/shared.d.ts +16 -2
  142. package/dist/types/core/server/string/loadable.d.ts +6 -3
  143. package/dist/types/core/server/string/ssrData.d.ts +2 -1
  144. package/dist/types/core/server/string/types.d.ts +1 -5
  145. package/dist/types/core/server/tracer.d.ts +1 -1
  146. package/dist/types/core/server/utils.d.ts +1 -1
  147. package/dist/types/core/types.d.ts +1 -2
  148. package/dist/types/document/cli/index.d.ts +1 -0
  149. package/dist/types/exports/head.d.ts +2 -2
  150. package/dist/types/internal.d.ts +1 -1
  151. package/dist/types/router/runtime/PrefetchLink.d.ts +27 -2
  152. package/dist/types/router/runtime/hooks.d.ts +19 -2
  153. package/dist/types/router/runtime/internal.d.ts +4 -21
  154. package/dist/types/router/runtime/types.d.ts +2 -43
  155. package/package.json +18 -46
  156. package/rslib.config.mts +3 -0
  157. package/rstest.config.mts +28 -2
  158. package/dist/cjs/boundary-debugger/index.js +0 -317
  159. package/dist/cjs/core/context/extensions.js +0 -74
  160. package/dist/cjs/core/context/helmetContext.js +0 -54
  161. package/dist/cjs/core/server/federatedCss.js +0 -58
  162. package/dist/cjs/core/server/scriptOrder.js +0 -140
  163. package/dist/cjs/module-federation/consume-surface.js +0 -199
  164. package/dist/cjs/module-federation/distributed-ssr.js +0 -135
  165. package/dist/cjs/module-federation/index.js +0 -316
  166. package/dist/cjs/module-federation/last-known-good.js +0 -157
  167. package/dist/cjs/module-federation/manifest-recovery-runtime-plugin.js +0 -129
  168. package/dist/cjs/module-federation/surface-resolution-types.js +0 -61
  169. package/dist/cjs/router/runtime/lifecycle.js +0 -167
  170. package/dist/cjs/router/runtime/provider.js +0 -153
  171. package/dist/cjs/rsc/server.worker.js +0 -62
  172. package/dist/esm/boundary-debugger/index.mjs +0 -277
  173. package/dist/esm/core/context/extensions.mjs +0 -33
  174. package/dist/esm/core/context/helmetContext.mjs +0 -13
  175. package/dist/esm/core/server/federatedCss.mjs +0 -20
  176. package/dist/esm/core/server/scriptOrder.mjs +0 -90
  177. package/dist/esm/module-federation/consume-surface.mjs +0 -158
  178. package/dist/esm/module-federation/distributed-ssr.mjs +0 -82
  179. package/dist/esm/module-federation/index.mjs +0 -115
  180. package/dist/esm/module-federation/last-known-good.mjs +0 -113
  181. package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +0 -89
  182. package/dist/esm/module-federation/surface-resolution-types.mjs +0 -8
  183. package/dist/esm/router/runtime/lifecycle.mjs +0 -105
  184. package/dist/esm/router/runtime/provider.mjs +0 -100
  185. package/dist/esm/rsc/server.worker.mjs +0 -1
  186. package/dist/esm-node/boundary-debugger/index.mjs +0 -278
  187. package/dist/esm-node/core/context/extensions.mjs +0 -34
  188. package/dist/esm-node/core/context/helmetContext.mjs +0 -14
  189. package/dist/esm-node/core/server/federatedCss.mjs +0 -21
  190. package/dist/esm-node/core/server/scriptOrder.mjs +0 -91
  191. package/dist/esm-node/module-federation/consume-surface.mjs +0 -159
  192. package/dist/esm-node/module-federation/distributed-ssr.mjs +0 -83
  193. package/dist/esm-node/module-federation/index.mjs +0 -116
  194. package/dist/esm-node/module-federation/last-known-good.mjs +0 -114
  195. package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +0 -90
  196. package/dist/esm-node/module-federation/surface-resolution-types.mjs +0 -9
  197. package/dist/esm-node/router/runtime/lifecycle.mjs +0 -106
  198. package/dist/esm-node/router/runtime/provider.mjs +0 -101
  199. package/dist/esm-node/rsc/server.worker.mjs +0 -2
  200. package/dist/types/boundary-debugger/index.d.ts +0 -28
  201. package/dist/types/core/context/extensions.d.ts +0 -35
  202. package/dist/types/core/context/helmetContext.d.ts +0 -10
  203. package/dist/types/core/server/federatedCss.d.ts +0 -5
  204. package/dist/types/core/server/scriptOrder.d.ts +0 -25
  205. package/dist/types/module-federation/consume-surface.d.ts +0 -104
  206. package/dist/types/module-federation/distributed-ssr.d.ts +0 -61
  207. package/dist/types/module-federation/index.d.ts +0 -71
  208. package/dist/types/module-federation/last-known-good.d.ts +0 -52
  209. package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +0 -25
  210. package/dist/types/module-federation/surface-resolution-types.d.ts +0 -23
  211. package/dist/types/router/runtime/lifecycle.d.ts +0 -27
  212. package/dist/types/router/runtime/provider.d.ts +0 -78
  213. 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';