@bleedingdev/modern-js-runtime 3.8.3-ultramodern.6 → 3.9.0-ultramodern.10

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 (207) 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/core/browser/hydrate.js +6 -1
  4. package/dist/cjs/core/context/index.js +4 -43
  5. package/dist/cjs/core/context/public.js +4 -7
  6. package/dist/cjs/core/context/runtime.js +17 -5
  7. package/dist/cjs/core/react/wrapper.js +22 -65
  8. package/dist/cjs/core/server/helmet.js +5 -4
  9. package/dist/cjs/core/server/requestResponse.js +4 -4
  10. package/dist/cjs/core/server/routerCleanup.js +2 -2
  11. package/dist/cjs/core/server/shared.js +171 -4
  12. package/dist/cjs/core/server/stream/afterTemplate.js +21 -16
  13. package/dist/cjs/core/server/stream/beforeTemplate.js +34 -25
  14. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +28 -21
  15. package/dist/cjs/core/server/stream/createReadableStream.js +208 -123
  16. package/dist/cjs/core/server/stream/createReadableStream.worker.js +159 -90
  17. package/dist/cjs/core/server/stream/deferredScript.js +3 -3
  18. package/dist/cjs/core/server/stream/shared.js +2 -2
  19. package/dist/cjs/core/server/string/index.js +100 -64
  20. package/dist/cjs/core/server/string/loadable.js +34 -19
  21. package/dist/cjs/core/server/string/ssrData.js +5 -12
  22. package/dist/cjs/core/server/utils.js +1 -2
  23. package/dist/cjs/document/cli/index.js +1 -2
  24. package/dist/cjs/exports/head.js +7 -14
  25. package/dist/cjs/router/runtime/PrefetchLink.js +67 -123
  26. package/dist/cjs/router/runtime/hooks.js +13 -2
  27. package/dist/cjs/router/runtime/internal.js +7 -45
  28. package/dist/cjs/router/runtime/plugin.js +2 -8
  29. package/dist/cjs/router/runtime/plugin.node.js +2 -30
  30. package/dist/cjs/router/runtime/redirect.js +1 -1
  31. package/dist/esm/cli/code.mjs +3 -1
  32. package/dist/esm/cli/ssr/index.mjs +3 -72
  33. package/dist/esm/core/browser/hydrate.mjs +7 -2
  34. package/dist/esm/core/context/index.mjs +2 -5
  35. package/dist/esm/core/context/public.mjs +1 -5
  36. package/dist/esm/core/context/runtime.mjs +13 -4
  37. package/dist/esm/core/react/wrapper.mjs +21 -67
  38. package/dist/esm/core/server/helmet.mjs +5 -4
  39. package/dist/esm/core/server/requestResponse.mjs +3 -3
  40. package/dist/esm/core/server/routerCleanup.mjs +1 -1
  41. package/dist/esm/core/server/shared.mjs +153 -1
  42. package/dist/esm/core/server/stream/afterTemplate.mjs +23 -18
  43. package/dist/esm/core/server/stream/beforeTemplate.mjs +37 -28
  44. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +31 -24
  45. package/dist/esm/core/server/stream/createReadableStream.mjs +207 -122
  46. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +149 -90
  47. package/dist/esm/core/server/stream/deferredScript.mjs +3 -3
  48. package/dist/esm/core/server/stream/shared.mjs +2 -2
  49. package/dist/esm/core/server/string/index.mjs +104 -68
  50. package/dist/esm/core/server/string/loadable.mjs +34 -19
  51. package/dist/esm/core/server/string/ssrData.mjs +5 -12
  52. package/dist/esm/core/server/utils.mjs +1 -2
  53. package/dist/esm/document/cli/index.mjs +2 -3
  54. package/dist/esm/exports/head.mjs +7 -14
  55. package/dist/esm/router/runtime/PrefetchLink.mjs +68 -124
  56. package/dist/esm/router/runtime/hooks.mjs +9 -1
  57. package/dist/esm/router/runtime/internal.mjs +2 -33
  58. package/dist/esm/router/runtime/plugin.mjs +1 -7
  59. package/dist/esm/router/runtime/plugin.node.mjs +1 -29
  60. package/dist/esm/router/runtime/redirect.mjs +1 -1
  61. package/dist/esm-node/cli/code.mjs +3 -1
  62. package/dist/esm-node/cli/ssr/index.mjs +3 -72
  63. package/dist/esm-node/core/browser/hydrate.mjs +7 -2
  64. package/dist/esm-node/core/context/index.mjs +2 -5
  65. package/dist/esm-node/core/context/public.mjs +1 -5
  66. package/dist/esm-node/core/context/runtime.mjs +13 -4
  67. package/dist/esm-node/core/react/wrapper.mjs +21 -67
  68. package/dist/esm-node/core/server/helmet.mjs +5 -4
  69. package/dist/esm-node/core/server/requestResponse.mjs +3 -3
  70. package/dist/esm-node/core/server/routerCleanup.mjs +1 -1
  71. package/dist/esm-node/core/server/shared.mjs +153 -1
  72. package/dist/esm-node/core/server/stream/afterTemplate.mjs +23 -18
  73. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +37 -28
  74. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +31 -24
  75. package/dist/esm-node/core/server/stream/createReadableStream.mjs +207 -122
  76. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +149 -90
  77. package/dist/esm-node/core/server/stream/deferredScript.mjs +3 -3
  78. package/dist/esm-node/core/server/stream/shared.mjs +2 -2
  79. package/dist/esm-node/core/server/string/index.mjs +104 -68
  80. package/dist/esm-node/core/server/string/loadable.mjs +34 -19
  81. package/dist/esm-node/core/server/string/ssrData.mjs +5 -12
  82. package/dist/esm-node/core/server/utils.mjs +1 -2
  83. package/dist/esm-node/document/cli/index.mjs +2 -3
  84. package/dist/esm-node/exports/head.mjs +7 -14
  85. package/dist/esm-node/router/runtime/PrefetchLink.mjs +68 -124
  86. package/dist/esm-node/router/runtime/hooks.mjs +9 -1
  87. package/dist/esm-node/router/runtime/internal.mjs +2 -33
  88. package/dist/esm-node/router/runtime/plugin.mjs +1 -7
  89. package/dist/esm-node/router/runtime/plugin.node.mjs +1 -29
  90. package/dist/esm-node/router/runtime/redirect.mjs +1 -1
  91. package/dist/types/cli/index.d.ts +7 -7
  92. package/dist/types/cli/ssr/index.d.ts +0 -3
  93. package/dist/types/core/browser/hydrate.d.ts +1 -1
  94. package/dist/types/core/browser/index.d.ts +1 -1
  95. package/dist/types/core/compat/hooks.d.ts +1 -1
  96. package/dist/types/core/compat/index.d.ts +1 -1
  97. package/dist/types/core/compat/requestContext.d.ts +3 -3
  98. package/dist/types/core/config.d.ts +1 -1
  99. package/dist/types/core/context/index.d.ts +8 -10
  100. package/dist/types/core/context/monitors/index.d.ts +1 -1
  101. package/dist/types/core/context/monitors/index.server.d.ts +1 -1
  102. package/dist/types/core/context/public.d.ts +1 -23
  103. package/dist/types/core/context/runtime.d.ts +27 -3
  104. package/dist/types/core/context/serverPayload/index.d.ts +1 -1
  105. package/dist/types/core/index.d.ts +5 -5
  106. package/dist/types/core/plugin/index.d.ts +1 -1
  107. package/dist/types/core/plugin/types.d.ts +2 -2
  108. package/dist/types/core/react/wrapper.d.ts +7 -1
  109. package/dist/types/core/server/helmet.d.ts +4 -5
  110. package/dist/types/core/server/index.d.ts +2 -2
  111. package/dist/types/core/server/react/index.d.ts +2 -2
  112. package/dist/types/core/server/requestHandler.d.ts +3 -3
  113. package/dist/types/core/server/requestResponse.d.ts +3 -3
  114. package/dist/types/core/server/routerCleanup.d.ts +2 -2
  115. package/dist/types/core/server/server.d.ts +4 -4
  116. package/dist/types/core/server/shared.d.ts +25 -2
  117. package/dist/types/core/server/stream/afterTemplate.d.ts +5 -4
  118. package/dist/types/core/server/stream/beforeTemplate.d.ts +6 -3
  119. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +6 -3
  120. package/dist/types/core/server/stream/createReadableStream.d.ts +1 -1
  121. package/dist/types/core/server/stream/createReadableStream.worker.d.ts +1 -1
  122. package/dist/types/core/server/stream/index.d.ts +1 -1
  123. package/dist/types/core/server/stream/shared.d.ts +5 -5
  124. package/dist/types/core/server/stream/template.d.ts +2 -2
  125. package/dist/types/core/server/string/index.d.ts +1 -1
  126. package/dist/types/core/server/string/loadable.d.ts +7 -4
  127. package/dist/types/core/server/string/ssrData.d.ts +5 -4
  128. package/dist/types/core/server/string/types.d.ts +2 -6
  129. package/dist/types/core/server/tracer.d.ts +1 -1
  130. package/dist/types/core/server/utils.d.ts +2 -2
  131. package/dist/types/core/types.d.ts +2 -3
  132. package/dist/types/document/index.d.ts +12 -12
  133. package/dist/types/exports/config-routes.d.ts +1 -1
  134. package/dist/types/exports/head.d.ts +2 -2
  135. package/dist/types/index.d.ts +9 -9
  136. package/dist/types/internal.d.ts +1 -1
  137. package/dist/types/react-server.d.ts +3 -3
  138. package/dist/types/router/cli/code/getClientRoutes/index.d.ts +1 -1
  139. package/dist/types/router/cli/handler.d.ts +1 -1
  140. package/dist/types/router/cli/index.d.ts +3 -3
  141. package/dist/types/router/index.d.ts +1 -1
  142. package/dist/types/router/internal.d.ts +2 -2
  143. package/dist/types/router/runtime/PrefetchLink.d.ts +27 -2
  144. package/dist/types/router/runtime/hooks.d.ts +19 -2
  145. package/dist/types/router/runtime/index.d.ts +4 -4
  146. package/dist/types/router/runtime/internal.d.ts +5 -22
  147. package/dist/types/router/runtime/plugin.d.ts +3 -3
  148. package/dist/types/router/runtime/plugin.node.d.ts +3 -3
  149. package/dist/types/router/runtime/rsc-router.d.ts +3 -3
  150. package/dist/types/router/runtime/types.d.ts +2 -43
  151. package/dist/types/router/runtime/utils.d.ts +1 -1
  152. package/package.json +19 -47
  153. package/rstest.config.mts +32 -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/esm/boundary-debugger/index.mjs +0 -277
  168. package/dist/esm/core/context/extensions.mjs +0 -33
  169. package/dist/esm/core/context/helmetContext.mjs +0 -13
  170. package/dist/esm/core/server/federatedCss.mjs +0 -20
  171. package/dist/esm/core/server/scriptOrder.mjs +0 -90
  172. package/dist/esm/module-federation/consume-surface.mjs +0 -158
  173. package/dist/esm/module-federation/distributed-ssr.mjs +0 -82
  174. package/dist/esm/module-federation/index.mjs +0 -115
  175. package/dist/esm/module-federation/last-known-good.mjs +0 -113
  176. package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +0 -89
  177. package/dist/esm/module-federation/surface-resolution-types.mjs +0 -8
  178. package/dist/esm/router/runtime/lifecycle.mjs +0 -105
  179. package/dist/esm/router/runtime/provider.mjs +0 -100
  180. package/dist/esm-node/boundary-debugger/index.mjs +0 -278
  181. package/dist/esm-node/core/context/extensions.mjs +0 -34
  182. package/dist/esm-node/core/context/helmetContext.mjs +0 -14
  183. package/dist/esm-node/core/server/federatedCss.mjs +0 -21
  184. package/dist/esm-node/core/server/scriptOrder.mjs +0 -91
  185. package/dist/esm-node/module-federation/consume-surface.mjs +0 -159
  186. package/dist/esm-node/module-federation/distributed-ssr.mjs +0 -83
  187. package/dist/esm-node/module-federation/index.mjs +0 -116
  188. package/dist/esm-node/module-federation/last-known-good.mjs +0 -114
  189. package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +0 -90
  190. package/dist/esm-node/module-federation/surface-resolution-types.mjs +0 -9
  191. package/dist/esm-node/router/runtime/lifecycle.mjs +0 -106
  192. package/dist/esm-node/router/runtime/provider.mjs +0 -101
  193. package/dist/types/boundary-debugger/index.d.ts +0 -28
  194. package/dist/types/core/context/extensions.d.ts +0 -35
  195. package/dist/types/core/context/helmetContext.d.ts +0 -10
  196. package/dist/types/core/server/federatedCss.d.ts +0 -5
  197. package/dist/types/core/server/scriptOrder.d.ts +0 -25
  198. package/dist/types/module-federation/consume-surface.d.ts +0 -104
  199. package/dist/types/module-federation/distributed-ssr.d.ts +0 -61
  200. package/dist/types/module-federation/index.d.ts +0 -71
  201. package/dist/types/module-federation/last-known-good.d.ts +0 -52
  202. package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +0 -25
  203. package/dist/types/module-federation/surface-resolution-types.d.ts +0 -23
  204. package/dist/types/router/runtime/lifecycle.d.ts +0 -27
  205. package/dist/types/router/runtime/provider.d.ts +0 -78
  206. /package/dist/esm/{rslib-runtime.mjs → rslib-runtime~1.mjs} +0 -0
  207. /package/dist/esm-node/{rslib-runtime.mjs → rslib-runtime~0.mjs} +0 -0
@@ -1,101 +0,0 @@
1
- import "node:module";
2
- import { modifyRoutes, onAfterCreateRouter, onAfterHydrateRouter, onBeforeCreateRouter, onBeforeCreateRoutes, onBeforeHydrateRouter } from "./hooks.mjs";
3
- const routerProviderRegistryHooks = {
4
- modifyRoutes: modifyRoutes,
5
- onBeforeCreateRoutes: onBeforeCreateRoutes,
6
- onBeforeCreateRouter: onBeforeCreateRouter,
7
- onAfterCreateRouter: onAfterCreateRouter,
8
- onBeforeHydrateRouter: onBeforeHydrateRouter,
9
- onAfterHydrateRouter: onAfterHydrateRouter
10
- };
11
- function reportUnsupportedProviderRegistryHooks(providerPlugin) {
12
- const unsupportedHookNames = Object.keys(providerPlugin.registryHooks ?? {}).filter((hookName)=>!(hookName in routerProviderRegistryHooks));
13
- if (unsupportedHookNames.length > 0) console.warn(`[@modern-js/runtime] The router provider "${providerPlugin.name}" declares registry hooks outside the router hook contract: ${unsupportedHookNames.join(', ')}. These hooks are not registered when the provider is resolved through \`runtime.router.framework\` — declare them on a separate runtime plugin instead.`);
14
- return unsupportedHookNames;
15
- }
16
- function createRouterProviderRealm(registrations) {
17
- const providers = new Map();
18
- let defaultProvider;
19
- for (const registration of registrations){
20
- if (0 === registration.name.length) throw new Error('[@modern-js/runtime] A router provider realm cannot contain an unnamed provider.');
21
- if (providers.has(registration.name)) throw new Error(`[@modern-js/runtime] Router provider "${registration.name}" is declared more than once in the same runtime realm.`);
22
- if (true === registration.isDefault && void 0 !== defaultProvider && defaultProvider !== registration.name) throw new Error(`[@modern-js/runtime] Router provider realm declares both "${defaultProvider}" and "${registration.name}" as defaults.`);
23
- providers.set(registration.name, registration.factory);
24
- if (true === registration.isDefault) defaultProvider = registration.name;
25
- }
26
- const providerNames = Object.freeze([
27
- ...providers.keys()
28
- ]);
29
- return Object.freeze({
30
- ...void 0 !== defaultProvider ? {
31
- defaultProvider
32
- } : {},
33
- get: (name)=>providers.get(name),
34
- names: ()=>providerNames
35
- });
36
- }
37
- const REGISTRY_SLOT = Symbol.for('@modern-js/runtime:router-providers:v3');
38
- const LEGACY_V2_REGISTRY_SLOT = Symbol.for('@modern-js/runtime:router-providers:v2');
39
- function getRegistry() {
40
- const host = globalThis;
41
- host[REGISTRY_SLOT] ??= {
42
- providers: new Map(),
43
- duplicateProviders: new Set(),
44
- warnedDuplicates: new Set()
45
- };
46
- host[REGISTRY_SLOT].duplicateProviders ??= new Set();
47
- host[REGISTRY_SLOT].warnedDuplicates ??= new Set();
48
- return host[REGISTRY_SLOT];
49
- }
50
- function getLegacyV2Registry() {
51
- const host = globalThis;
52
- return host[LEGACY_V2_REGISTRY_SLOT];
53
- }
54
- function registerRouterProvider(name, factory, options = {}) {
55
- const registry = getRegistry();
56
- const existing = registry.providers.get(name);
57
- if (void 0 !== existing) {
58
- if (existing !== factory) registry.duplicateProviders.add(name);
59
- return;
60
- }
61
- if (true === options.isDefault) registry.defaultProvider = name;
62
- registry.providers.set(name, factory);
63
- }
64
- function resolveRouterProvider(framework, options = {}) {
65
- if (void 0 !== options.realm) {
66
- const name = framework || options.realm.defaultProvider;
67
- const realmProviderNames = options.realm.names();
68
- if (void 0 === name) throw new Error(`[@modern-js/runtime] The app-owned router provider realm does not declare a default provider. Available realm providers: ${realmProviderNames.join(', ') || '(none)'}.`);
69
- const factory = options.realm.get(name);
70
- if (void 0 === factory) throw new Error(`[@modern-js/runtime] Router provider "${name}" is not registered in the app-owned router provider realm. Available realm providers: ${realmProviderNames.join(', ') || '(none)'}. Compatibility registry fallback is disabled for app-owned realms.`);
71
- return factory;
72
- }
73
- const registry = getRegistry();
74
- const legacyV2Registry = getLegacyV2Registry();
75
- const name = framework || options.localDefault?.name || registry.defaultProvider || legacyV2Registry?.defaultProvider;
76
- if (void 0 === name) throw new Error('[@modern-js/runtime] No default router provider is registered. This is a bug in the runtime setup.');
77
- if (void 0 !== options.localDefault && name === options.localDefault.name) return options.localDefault.factory;
78
- const factory = registry.providers.get(name);
79
- if (void 0 !== factory) {
80
- if (registry.duplicateProviders.has(name) && !registry.warnedDuplicates.has(name)) {
81
- registry.warnedDuplicates.add(name);
82
- console.warn(`[@modern-js/runtime] The router provider "${name}" was registered more than once with different module instances, and a router wrapper without an app-owned provider realm is resolving the mixed-version compatibility fallback. The fallback is keeping the first registration. Modern router wrappers isolate app-owned realms automatically. For an older wrapper, share the provider runtime between Module Federation host and remotes or upgrade every app to a realm-aware runtime.`);
83
- }
84
- return factory;
85
- }
86
- const legacyV2Factory = legacyV2Registry?.providers.get(name);
87
- if (void 0 !== legacyV2Factory) return legacyV2Factory;
88
- if ('tanstack' === name) throw new Error("[@modern-js/runtime] `runtime.router.framework` is set to \"tanstack\", but no TanStack router provider is registered. Install @modern-js/plugin-tanstack, add `tanstackRouterPlugin()` to the `plugins` array in modern.config.ts, and make sure '@modern-js/plugin-tanstack/runtime' is imported (e.g. in modern.runtime.ts).");
89
- throw new Error(`[@modern-js/runtime] Unknown router framework "${name}". Registered providers: ${[
90
- ...new Set([
91
- ...registry.providers.keys(),
92
- ...legacyV2Registry?.providers.keys() ?? []
93
- ])
94
- ].join(', ') || '(none)'}. Install and register the plugin that provides this router framework.`);
95
- }
96
- function unsafe_resetRouterProvidersForTesting() {
97
- const host = globalThis;
98
- delete host[REGISTRY_SLOT];
99
- delete host[LEGACY_V2_REGISTRY_SLOT];
100
- }
101
- export { createRouterProviderRealm, registerRouterProvider, reportUnsupportedProviderRegistryHooks, resolveRouterProvider, routerProviderRegistryHooks, unsafe_resetRouterProvidersForTesting };
@@ -1,28 +0,0 @@
1
- import type { RuntimePlugin } from '../common';
2
- export type BoundaryDebugEntry = {
3
- appId: string;
4
- color?: string;
5
- label?: string;
6
- mfName: string;
7
- ownerTeam?: string;
8
- packageName?: string;
9
- role?: 'host' | 'vertical';
10
- };
11
- export type BoundaryDebugMetadata = {
12
- appId: string;
13
- boundaries: BoundaryDebugEntry[];
14
- schemaVersion: 1;
15
- };
16
- export type BoundaryDebuggerControlMode = 'visible' | 'hidden-when-off' | 'hidden';
17
- export type BoundaryDebuggerPluginOptions = {
18
- controlMode?: BoundaryDebuggerControlMode;
19
- enabledByDefault?: boolean;
20
- labels?: Record<string, {
21
- toggle: string;
22
- }>;
23
- legacySelector?: string;
24
- metadata: BoundaryDebugMetadata;
25
- storageKey?: string;
26
- };
27
- export declare const ultramodernBoundaryDebuggerPlugin: (options: BoundaryDebuggerPluginOptions) => RuntimePlugin;
28
- export default ultramodernBoundaryDebuggerPlugin;
@@ -1,35 +0,0 @@
1
- /**
2
- * Fork-owned runtime-context extension mechanism.
3
- *
4
- * Plugins must not add ad-hoc fields to `TRuntimeContext` /
5
- * `TInternalRuntimeContext`. Instead they store state in a single internal
6
- * slot (a `Map` keyed by symbol) attached to the context object under a
7
- * symbol property, so nothing leaks into string-key enumeration
8
- * (`Object.keys`, `JSON.stringify`, `{ ...context }` rest patterns over
9
- * named keys).
10
- *
11
- * `Symbol.for` is used for both the slot and the extension keys so that the
12
- * mechanism stays coherent even if this module is instantiated twice
13
- * (e.g. esm/cjs interop in test runners).
14
- */
15
- export interface RuntimeContextExtension<T> {
16
- /** Stable identity of this extension. */
17
- readonly key: symbol;
18
- get(context: object): T | undefined;
19
- set(context: object, value: T): void;
20
- remove(context: object): void;
21
- }
22
- /**
23
- * Removes the extension slot from a context object.
24
- *
25
- * The symbol slot crosses object spreads while remaining absent from string-key
26
- * enumeration and JSON. Callers can still explicitly clear the original context.
27
- */
28
- export declare function stripRuntimeContextExtensions(context: object): void;
29
- /**
30
- * Creates a typed accessor pair over the shared extension slot.
31
- *
32
- * The `id` must be globally unique (it is interned via `Symbol.for`); use a
33
- * package-prefixed name such as `@modern-js/plugin-tanstack:router-state`.
34
- */
35
- export declare function createRuntimeContextExtension<T>(id: string): RuntimeContextExtension<T>;
@@ -1,10 +0,0 @@
1
- /**
2
- * Fork-owned helmet state, stored via the runtime-context extension slot
3
- * instead of an ad-hoc `_helmetContext` field on `TInternalRuntimeContext`.
4
- */
5
- import type { HelmetServerState } from 'react-helmet-async';
6
- export interface HelmetContextSlot {
7
- helmet?: HelmetServerState | null;
8
- }
9
- export declare function getHelmetContext(context: object): HelmetContextSlot | undefined;
10
- export declare function ensureHelmetContext(context: object): HelmetContextSlot;
@@ -1,5 +0,0 @@
1
- export declare const createFederatedCssLinks: (assets: string[] | undefined, options: {
2
- template: string;
3
- attributes?: Record<string, any>;
4
- existingAssets?: Iterable<string>;
5
- }) => string;
@@ -1,25 +0,0 @@
1
- import type { TInternalRuntimeContext } from '../context';
2
- type RouteAssetManifest = {
3
- assets?: string[];
4
- };
5
- type RouteManifestLike = {
6
- routeAssets?: Record<string, RouteAssetManifest | undefined>;
7
- };
8
- type ScriptChunkLike = {
9
- filename?: string;
10
- url?: string;
11
- };
12
- export declare function getMatchedRouteChunks<T>(runtimeContext: TInternalRuntimeContext, routeManifest: RouteManifestLike | undefined, routeAssetToChunk: (asset: string) => T): T[];
13
- export declare const orderHydrationScriptChunks: <T extends ScriptChunkLike>({ asyncEntryChunks, collectedChunks, matchedRouteChunks, entryName, }: {
14
- asyncEntryChunks: T[];
15
- collectedChunks: T[];
16
- matchedRouteChunks: T[];
17
- entryName: string;
18
- }) => T[];
19
- export declare function injectBeforeHydrationEntryScript(template: string, scripts: string, entryName?: string): string;
20
- export declare function replaceChunkJsPlaceholder(template: string, scripts: string, entryName?: string, placeholder?: string): string;
21
- export declare function createRouteHydrationScriptTags(runtimeContext: TInternalRuntimeContext, entryName: string, options?: {
22
- nonce?: string;
23
- template?: string;
24
- }): string;
25
- export {};
@@ -1,104 +0,0 @@
1
- /**
2
- * G22 — mandatory degraded consumption API.
3
- *
4
- * CONTEXT.md (Degraded State): "consuming a surface obliges the consumer to
5
- * define a degraded state". This module turns that obligation into a
6
- * compile-level one: {@link SurfaceConsumerOptions.degraded} is a REQUIRED
7
- * field, so a call site that forgets its fallback does not type-check.
8
- *
9
- * The consumer wraps the loadRemote-ish flow (resolve a SurfaceRef through a
10
- * provider, then load the execution artifact from the resolved record) and
11
- * guarantees isolation: any discovery/load failure is caught, classified,
12
- * reported through the existing MF fallback telemetry, and handed to the
13
- * required degraded handler.
14
- *
15
- * Criticality (owner-default 5: unclassified consumption is `critical`). For a
16
- * `noncritical` consumption the degraded handler's result is returned and the
17
- * failure is swallowed, so one failing consumption can never propagate to a
18
- * sibling (CONTEXT.md: faults isolate at the vertical boundary). For a
19
- * `critical` consumption the degraded handler still runs — telemetry and
20
- * fallback-UI obligations hold — but the returned promise then REJECTS with the
21
- * typed failure so callers and rollout machinery observe it. Critical
22
- * consumption during a rollout window should be driven by expand/contract, not
23
- * by silent degrade.
24
- */
25
- import { type ModuleFederationFallbackClassification, type ModuleFederationFallbackTelemetryEmitOptions, type ModuleFederationFallbackTelemetryPayload } from './index';
26
- import { type DiscoveryError, type EnvironmentId, type ParsedSurfaceRef, type ResolvedDeliveryUnit, type SurfaceResolutionProvider } from './surface-resolution-types';
27
- /** Where in the consumption lifecycle a failure was raised. */
28
- export type SurfaceConsumptionPhase = 'discovery' | 'load' | 'mount';
29
- /**
30
- * The typed failure surfaced to the degraded handler. Exactly one of
31
- * `discoveryError` (resolver returned a typed {@link DiscoveryError}) or
32
- * `error` (something threw) is populated for a given failure.
33
- */
34
- export type SurfaceConsumptionFailure = {
35
- ref: ParsedSurfaceRef;
36
- env: EnvironmentId;
37
- phase: SurfaceConsumptionPhase;
38
- classification: ModuleFederationFallbackClassification;
39
- /** Present when discovery returned a typed error state. */
40
- discoveryError?: DiscoveryError;
41
- /** Present when a thrown error caused the failure. */
42
- error?: unknown;
43
- /** The resolved record, when discovery succeeded but load/mount failed. */
44
- resolved?: ResolvedDeliveryUnit;
45
- /** The fallback telemetry payload emitted for this failure. */
46
- telemetry: ModuleFederationFallbackTelemetryPayload;
47
- };
48
- export type SurfaceLoadInput = {
49
- resolved: ResolvedDeliveryUnit;
50
- ref: ParsedSurfaceRef;
51
- env: EnvironmentId;
52
- };
53
- export type SurfaceConsumerOptions<T> = {
54
- /** The logical surface to consume (object or canonical string form). */
55
- ref: ParsedSurfaceRef | string;
56
- env: EnvironmentId;
57
- /** The pluggable resolution seam (RESOLUTION-0001 §2.2). */
58
- provider: SurfaceResolutionProvider;
59
- /** Consumer app name, used for telemetry attribution. */
60
- appName: string;
61
- /**
62
- * Loads the execution artifact from a resolved record — the loadRemote-ish
63
- * flow. Receives the whole {@link ResolvedDeliveryUnit} so the adapter reads
64
- * locations under one buildMarker (RESOLUTION-0001 §2.3).
65
- */
66
- load: (input: SurfaceLoadInput) => Promise<T> | T;
67
- /**
68
- * REQUIRED degraded handler (G22 compile-level obligation). There is no
69
- * default and no way to opt out at the type level: omitting this field is a
70
- * compile error. Return the value to serve while the surface is unavailable
71
- * or incompatible.
72
- */
73
- degraded: (failure: SurfaceConsumptionFailure) => T | Promise<T>;
74
- /**
75
- * Consumption criticality (owner-default 5). Defaults to `'critical'` when
76
- * omitted.
77
- *
78
- * - `'noncritical'`: the degraded handler's result is returned and the
79
- * failure is swallowed — the promise never rejects.
80
- * - `'critical'`: the degraded handler still runs (telemetry + fallback-UI
81
- * obligations hold), but the returned promise then REJECTS with the typed
82
- * failure so callers / rollout machinery observe it. Prefer expand/contract
83
- * over silent degrade for critical surfaces during rollout windows.
84
- */
85
- classification?: 'critical' | 'noncritical';
86
- /** Optional telemetry emission options (endpoint/auth/fetch overrides). */
87
- telemetry?: ModuleFederationFallbackTelemetryEmitOptions;
88
- };
89
- /**
90
- * Consume one surface with a mandatory degraded fallback. On any discovery or
91
- * load failure the required degraded handler runs (telemetry + fallback UI).
92
- *
93
- * For a `noncritical` consumption (see {@link SurfaceConsumerOptions.classification})
94
- * this resolves to the degraded value and never rejects, so a failing
95
- * consumption is isolated from any sibling. For a `critical` consumption (the
96
- * default) it rejects with the typed failure AFTER the degraded handler has
97
- * run, so callers / rollout machinery observe the failure.
98
- */
99
- export declare function consumeSurface<T>(options: SurfaceConsumerOptions<T>): Promise<T>;
100
- /**
101
- * Build a reusable consumer bound to a provider/env/app, still requiring a
102
- * degraded handler per call. Per-call options override the bound base.
103
- */
104
- export declare function createSurfaceConsumer(base: Pick<SurfaceConsumerOptions<unknown>, 'provider' | 'env' | 'appName' | 'telemetry'>): <T>(options: Omit<SurfaceConsumerOptions<T>, keyof typeof base> & Partial<Pick<SurfaceConsumerOptions<T>, keyof typeof base>>) => Promise<T>;
@@ -1,61 +0,0 @@
1
- import type { ComponentType, ReactNode } from 'react';
2
- export declare const DISTRIBUTED_SSR_FRAGMENTS_LOCALS_KEY = "__modernDistributedSsrFragments";
3
- export declare const DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY = "__modernDistributedSsrFragmentRequest";
4
- export type DistributedSsrFragment = {
5
- boundaryId: string;
6
- buildMarker?: string;
7
- digest?: string;
8
- expose: string;
9
- html: string;
10
- remote: string;
11
- status: 'ready';
12
- };
13
- export type DistributedSsrFragmentFailure = {
14
- boundaryId: string;
15
- expose: string;
16
- reason: string;
17
- remote: string;
18
- status: 'degraded';
19
- };
20
- type DistributedSsrFragmentResult = DistributedSsrFragment | DistributedSsrFragmentFailure;
21
- export type DistributedSsrFragmentContext = {
22
- fragments?: Record<string, DistributedSsrFragment | DistributedSsrFragmentFailure>;
23
- required: true;
24
- resolve?: (remote: string, expose: string, props: Record<string, unknown>) => DistributedSsrFragmentResult | PromiseLike<DistributedSsrFragmentResult>;
25
- };
26
- export type DistributedSsrBoundaryProps<Props extends object = Record<string, unknown>> = {
27
- children: ReactNode;
28
- expose: string;
29
- fallback: ReactNode;
30
- fragmentProps?: Props;
31
- remote: string;
32
- };
33
- export type CreateDistributedSsrComponentOptions<Props extends object> = {
34
- createComponent: () => ComponentType<Props>;
35
- expose: string;
36
- fallback: ReactNode;
37
- remote: string;
38
- };
39
- export declare function distributedSsrFragmentKey(remote: string, expose: string): string;
40
- export declare function useDistributedSsrFragmentProps<Props extends object>({ boundaryId, expose, }: {
41
- boundaryId: string;
42
- expose: string;
43
- }): Props;
44
- /**
45
- * Keeps the browser on the native Module Federation component while allowing
46
- * servers that cannot execute remote code (notably workerd) to render a
47
- * trusted fragment produced by the remote Worker itself.
48
- *
49
- * Node SSR has no distributed-fragment context and therefore renders the
50
- * child normally, preserving Module Federation's in-process SSR path.
51
- */
52
- export declare function DistributedSsrBoundary<Props extends object = Record<string, unknown>>({ children, expose, fallback, fragmentProps, remote, }: DistributedSsrBoundaryProps<Props>): import("react").JSX.Element;
53
- /**
54
- * Defers creation of the native Module Federation component until React
55
- * actually renders that child. A workerd request with a verified distributed
56
- * fragment never constructs the native remote, so its module cannot perform
57
- * forbidden global-scope network I/O. Browser and Node rendering keep using
58
- * the native Module Federation component unchanged.
59
- */
60
- export declare function createDistributedSsrComponent<Props extends object>({ createComponent, expose, fallback, remote, }: CreateDistributedSsrComponentOptions<Props>): (props: Props) => import("react").JSX.Element;
61
- export {};
@@ -1,71 +0,0 @@
1
- export * from './consume-surface';
2
- export * from './distributed-ssr';
3
- export { DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY, useDistributedSsrFragmentProps, } from './distributed-ssr';
4
- export * from './last-known-good';
5
- export * from './manifest-recovery-runtime-plugin';
6
- export * from './surface-resolution-types';
7
- export declare const MODULE_FEDERATION_FALLBACK_SIGNAL_EVENT = "modernjs:mf-runtime-fallback";
8
- export declare const MODULE_FEDERATION_RECOVERY_SIGNAL_EVENT = "modernjs:mf-runtime-recovery";
9
- export declare const DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = "/_modern/contract-gates/runtime-fallback";
10
- export declare const DEFAULT_RUNTIME_FALLBACK_SIGNAL_AUTH_HEADER = "x-modernjs-runtime-signal-token";
11
- export type ModuleFederationFallbackClassification = 'timeout' | 'network' | 'contract' | 'version-skew' | 'remote-unavailable';
12
- export type ModuleFederationFallbackStatus = 'degraded' | 'failed' | 'recovered';
13
- export type ModuleFederationFallbackTelemetryInput = {
14
- appName: string;
15
- classification: ModuleFederationFallbackClassification;
16
- entry?: string;
17
- error?: unknown;
18
- eventName?: string;
19
- exportName?: string;
20
- metadata?: Record<string, unknown>;
21
- phase: 'discovery' | 'load' | 'mount' | 'hydrate' | 'recover';
22
- remote: string;
23
- runtimeDigest?: string;
24
- status?: ModuleFederationFallbackStatus;
25
- };
26
- export type ModuleFederationFallbackTelemetryPayload = {
27
- appName: string;
28
- entry?: string;
29
- eventName: string;
30
- phase: ModuleFederationFallbackTelemetryInput['phase'];
31
- reason: ModuleFederationFallbackClassification;
32
- runtimeDigest?: string;
33
- schemaVersion: 1;
34
- metadata: {
35
- classification: ModuleFederationFallbackClassification;
36
- errorMessage?: string;
37
- errorName?: string;
38
- exportName?: string;
39
- remote: string;
40
- runtimeDigest?: string;
41
- status: ModuleFederationFallbackStatus;
42
- } & Record<string, unknown>;
43
- };
44
- export type ModuleFederationFallbackTelemetryEmitOptions = {
45
- authHeaderName?: string;
46
- authToken?: string;
47
- endpoint?: string;
48
- fetchImpl?: typeof fetch;
49
- postSignal?: boolean;
50
- };
51
- export type ModuleFederationFallbackTelemetryEmitResult = {
52
- dispatched: boolean;
53
- posted: boolean;
54
- postStatus?: number;
55
- };
56
- export declare class ModuleFederationRemoteLoadTimeoutError extends Error {
57
- constructor(remote: string, timeoutMs: number);
58
- }
59
- export declare class ModuleFederationRemoteLoadError extends Error {
60
- readonly remote: string;
61
- readonly attempts: number;
62
- readonly causeError: Error;
63
- constructor(remote: string, attempts: number, causeError: Error);
64
- }
65
- export declare class ModuleFederationRemoteComponentContractError extends Error {
66
- constructor(remote: string, exportName: string);
67
- }
68
- export declare function classifyModuleFederationFallback(error: unknown): ModuleFederationFallbackClassification;
69
- export declare function createModuleFederationFallbackTelemetry(input: ModuleFederationFallbackTelemetryInput): ModuleFederationFallbackTelemetryPayload;
70
- export declare function toModuleFederationFallbackAttributes(payload: ModuleFederationFallbackTelemetryPayload): Record<string, string>;
71
- export declare function emitModuleFederationFallbackTelemetry(input: ModuleFederationFallbackTelemetryInput, options?: ModuleFederationFallbackTelemetryEmitOptions): Promise<ModuleFederationFallbackTelemetryEmitResult>;
@@ -1,52 +0,0 @@
1
- import { type ResolvedDeliveryUnit, type SurfaceResolutionProvider } from './surface-resolution-types';
2
- export declare const LAST_KNOWN_GOOD_PROVIDER_NAME = "last-known-good";
3
- /** One cached complete record plus the time it was stored. */
4
- export type LkgRecord = {
5
- resolved: ResolvedDeliveryUnit;
6
- storedAt: number;
7
- /**
8
- * External-major selector the record was resolved against. Participates in
9
- * lookup validation — a cached record is only served for a matching major —
10
- * but never in the storage key, which is (unitId, env) so all surfaces of a
11
- * unit share one atomically-swapped record.
12
- */
13
- major?: number;
14
- };
15
- /**
16
- * Pluggable storage hook. The default is an in-memory Map; callers may supply a
17
- * durable store (KV, disk, etc). Reads/writes may be async. A store only ever
18
- * receives whole records.
19
- */
20
- export type LkgStorage = {
21
- read(key: string): (LkgRecord | undefined) | Promise<LkgRecord | undefined>;
22
- write(key: string, record: LkgRecord): void | Promise<void>;
23
- };
24
- export type LkgFreshnessPolicy = {
25
- /**
26
- * Maximum age, in ms, a stored record may be served after a provider
27
- * failure. When omitted, a served record never expires by age. A record
28
- * older than this yields a typed `stale-record` discovery error.
29
- */
30
- maxStaleMs?: number;
31
- };
32
- export type LastKnownGoodOptions = {
33
- /** The wrapped provider (env/static, Zephyr, or any other). */
34
- provider: SurfaceResolutionProvider;
35
- /** Pluggable storage; defaults to a process-local in-memory Map. */
36
- storage?: LkgStorage;
37
- freshness?: LkgFreshnessPolicy;
38
- /** Clock injection for deterministic freshness tests. */
39
- now?: () => number;
40
- };
41
- /** Default process-local in-memory storage. */
42
- export declare function createInMemoryLkgStorage(): LkgStorage;
43
- /**
44
- * Wrap a provider with a last-known-good cache. On success the whole record is
45
- * cached (atomic swap). On provider failure (typed discovery error or a thrown
46
- * error) the last complete record is served, marked degraded — unless it has
47
- * expired per {@link LkgFreshnessPolicy}, in which case a typed `stale-record`
48
- * error is returned. If there is no cached record, the original failure is
49
- * passed through (a thrown error becomes a `provider-unavailable` discovery
50
- * error).
51
- */
52
- export declare function createLastKnownGoodProvider(options: LastKnownGoodOptions): SurfaceResolutionProvider;
@@ -1,25 +0,0 @@
1
- type ErrorLoadRemoteArgs = {
2
- id?: string;
3
- error?: unknown;
4
- lifecycle?: string;
5
- };
6
- export type ModuleFederationManifestRecoveryPluginOptions = {
7
- attempts?: number;
8
- retryDelayMs?: number;
9
- timeoutMs?: number;
10
- fetchImpl?: typeof fetch;
11
- waitImpl?: (milliseconds: number) => Promise<void>;
12
- };
13
- /**
14
- * Gives server-side manifest loading a small, bounded recovery window.
15
- *
16
- * Returning `undefined` deliberately hands control back to Module Federation:
17
- * its runtime preserves the original typed RUNTIME-003 error and invalidates
18
- * the rejected manifest promise. Parsed manifests are returned without schema
19
- * interpretation so runtime-core remains the authority for RUNTIME-013.
20
- */
21
- export declare const createModuleFederationManifestRecoveryPlugin: (options?: ModuleFederationManifestRecoveryPluginOptions) => {
22
- name: string;
23
- errorLoadRemote(args: ErrorLoadRemoteArgs): Promise<unknown>;
24
- };
25
- export default createModuleFederationManifestRecoveryPlugin;
@@ -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';
3
- import type { InternalRouterRuntimeState, InternalRouterServerSnapshot, RouterFramework, RouterRouteMatchSnapshot, RouterServerPrepareResult } from './types';
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';
15
- import type { RouterExtendsHooks } from './hooks';
16
- import type { RouterConfig } from './types';
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;