@bleedingdev/modern-js-runtime 3.9.0-ultramodern.1 → 3.9.0-ultramodern.11

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 (166) 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/exports/head.js +7 -14
  24. package/dist/cjs/router/runtime/PrefetchLink.js +67 -123
  25. package/dist/cjs/router/runtime/hooks.js +13 -2
  26. package/dist/cjs/router/runtime/internal.js +7 -45
  27. package/dist/cjs/router/runtime/plugin.js +2 -8
  28. package/dist/cjs/router/runtime/plugin.node.js +2 -30
  29. package/dist/cjs/router/runtime/redirect.js +1 -1
  30. package/dist/esm/cli/code.mjs +3 -1
  31. package/dist/esm/cli/ssr/index.mjs +3 -72
  32. package/dist/esm/core/browser/hydrate.mjs +7 -2
  33. package/dist/esm/core/context/index.mjs +2 -5
  34. package/dist/esm/core/context/public.mjs +1 -5
  35. package/dist/esm/core/context/runtime.mjs +13 -4
  36. package/dist/esm/core/react/wrapper.mjs +21 -67
  37. package/dist/esm/core/server/helmet.mjs +5 -4
  38. package/dist/esm/core/server/requestResponse.mjs +3 -3
  39. package/dist/esm/core/server/routerCleanup.mjs +1 -1
  40. package/dist/esm/core/server/shared.mjs +153 -1
  41. package/dist/esm/core/server/stream/afterTemplate.mjs +23 -18
  42. package/dist/esm/core/server/stream/beforeTemplate.mjs +37 -28
  43. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +31 -24
  44. package/dist/esm/core/server/stream/createReadableStream.mjs +207 -122
  45. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +149 -90
  46. package/dist/esm/core/server/stream/deferredScript.mjs +3 -3
  47. package/dist/esm/core/server/stream/shared.mjs +2 -2
  48. package/dist/esm/core/server/string/index.mjs +104 -68
  49. package/dist/esm/core/server/string/loadable.mjs +34 -19
  50. package/dist/esm/core/server/string/ssrData.mjs +5 -12
  51. package/dist/esm/core/server/utils.mjs +1 -2
  52. package/dist/esm/exports/head.mjs +7 -14
  53. package/dist/esm/router/runtime/PrefetchLink.mjs +67 -123
  54. package/dist/esm/router/runtime/hooks.mjs +9 -1
  55. package/dist/esm/router/runtime/internal.mjs +2 -33
  56. package/dist/esm/router/runtime/plugin.mjs +1 -7
  57. package/dist/esm/router/runtime/plugin.node.mjs +1 -29
  58. package/dist/esm/router/runtime/redirect.mjs +1 -1
  59. package/dist/esm-node/cli/code.mjs +3 -1
  60. package/dist/esm-node/cli/ssr/index.mjs +3 -72
  61. package/dist/esm-node/core/browser/hydrate.mjs +7 -2
  62. package/dist/esm-node/core/context/index.mjs +2 -5
  63. package/dist/esm-node/core/context/public.mjs +1 -5
  64. package/dist/esm-node/core/context/runtime.mjs +13 -4
  65. package/dist/esm-node/core/react/wrapper.mjs +21 -67
  66. package/dist/esm-node/core/server/helmet.mjs +5 -4
  67. package/dist/esm-node/core/server/requestResponse.mjs +3 -3
  68. package/dist/esm-node/core/server/routerCleanup.mjs +1 -1
  69. package/dist/esm-node/core/server/shared.mjs +153 -1
  70. package/dist/esm-node/core/server/stream/afterTemplate.mjs +23 -18
  71. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +37 -28
  72. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +31 -24
  73. package/dist/esm-node/core/server/stream/createReadableStream.mjs +207 -122
  74. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +149 -90
  75. package/dist/esm-node/core/server/stream/deferredScript.mjs +3 -3
  76. package/dist/esm-node/core/server/stream/shared.mjs +2 -2
  77. package/dist/esm-node/core/server/string/index.mjs +104 -68
  78. package/dist/esm-node/core/server/string/loadable.mjs +34 -19
  79. package/dist/esm-node/core/server/string/ssrData.mjs +5 -12
  80. package/dist/esm-node/core/server/utils.mjs +1 -2
  81. package/dist/esm-node/exports/head.mjs +7 -14
  82. package/dist/esm-node/router/runtime/PrefetchLink.mjs +67 -123
  83. package/dist/esm-node/router/runtime/hooks.mjs +9 -1
  84. package/dist/esm-node/router/runtime/internal.mjs +2 -33
  85. package/dist/esm-node/router/runtime/plugin.mjs +1 -7
  86. package/dist/esm-node/router/runtime/plugin.node.mjs +1 -29
  87. package/dist/esm-node/router/runtime/redirect.mjs +1 -1
  88. package/dist/types/cli/ssr/index.d.ts +0 -3
  89. package/dist/types/core/context/index.d.ts +4 -6
  90. package/dist/types/core/context/public.d.ts +1 -23
  91. package/dist/types/core/context/runtime.d.ts +26 -2
  92. package/dist/types/core/react/wrapper.d.ts +6 -0
  93. package/dist/types/core/server/helmet.d.ts +4 -5
  94. package/dist/types/core/server/requestHandler.d.ts +2 -2
  95. package/dist/types/core/server/requestResponse.d.ts +1 -1
  96. package/dist/types/core/server/routerCleanup.d.ts +1 -1
  97. package/dist/types/core/server/shared.d.ts +24 -1
  98. package/dist/types/core/server/stream/afterTemplate.d.ts +2 -1
  99. package/dist/types/core/server/stream/beforeTemplate.d.ts +4 -1
  100. package/dist/types/core/server/stream/beforeTemplate.worker.d.ts +4 -1
  101. package/dist/types/core/server/stream/shared.d.ts +2 -2
  102. package/dist/types/core/server/string/loadable.d.ts +6 -3
  103. package/dist/types/core/server/string/ssrData.d.ts +2 -1
  104. package/dist/types/core/server/string/types.d.ts +1 -5
  105. package/dist/types/core/server/tracer.d.ts +1 -1
  106. package/dist/types/core/server/utils.d.ts +1 -1
  107. package/dist/types/core/types.d.ts +1 -2
  108. package/dist/types/exports/head.d.ts +2 -2
  109. package/dist/types/router/runtime/PrefetchLink.d.ts +27 -2
  110. package/dist/types/router/runtime/hooks.d.ts +19 -2
  111. package/dist/types/router/runtime/internal.d.ts +4 -21
  112. package/dist/types/router/runtime/types.d.ts +2 -43
  113. package/package.json +18 -46
  114. package/rstest.config.mts +32 -2
  115. package/dist/cjs/boundary-debugger/index.js +0 -317
  116. package/dist/cjs/core/context/extensions.js +0 -74
  117. package/dist/cjs/core/context/helmetContext.js +0 -54
  118. package/dist/cjs/core/server/federatedCss.js +0 -58
  119. package/dist/cjs/core/server/scriptOrder.js +0 -140
  120. package/dist/cjs/module-federation/consume-surface.js +0 -199
  121. package/dist/cjs/module-federation/distributed-ssr.js +0 -135
  122. package/dist/cjs/module-federation/index.js +0 -316
  123. package/dist/cjs/module-federation/last-known-good.js +0 -157
  124. package/dist/cjs/module-federation/manifest-recovery-runtime-plugin.js +0 -129
  125. package/dist/cjs/module-federation/surface-resolution-types.js +0 -61
  126. package/dist/cjs/router/runtime/lifecycle.js +0 -167
  127. package/dist/cjs/router/runtime/provider.js +0 -153
  128. package/dist/esm/boundary-debugger/index.mjs +0 -277
  129. package/dist/esm/core/context/extensions.mjs +0 -33
  130. package/dist/esm/core/context/helmetContext.mjs +0 -13
  131. package/dist/esm/core/server/federatedCss.mjs +0 -20
  132. package/dist/esm/core/server/scriptOrder.mjs +0 -90
  133. package/dist/esm/module-federation/consume-surface.mjs +0 -158
  134. package/dist/esm/module-federation/distributed-ssr.mjs +0 -82
  135. package/dist/esm/module-federation/index.mjs +0 -115
  136. package/dist/esm/module-federation/last-known-good.mjs +0 -113
  137. package/dist/esm/module-federation/manifest-recovery-runtime-plugin.mjs +0 -89
  138. package/dist/esm/module-federation/surface-resolution-types.mjs +0 -8
  139. package/dist/esm/router/runtime/lifecycle.mjs +0 -105
  140. package/dist/esm/router/runtime/provider.mjs +0 -100
  141. package/dist/esm-node/boundary-debugger/index.mjs +0 -278
  142. package/dist/esm-node/core/context/extensions.mjs +0 -34
  143. package/dist/esm-node/core/context/helmetContext.mjs +0 -14
  144. package/dist/esm-node/core/server/federatedCss.mjs +0 -21
  145. package/dist/esm-node/core/server/scriptOrder.mjs +0 -91
  146. package/dist/esm-node/module-federation/consume-surface.mjs +0 -159
  147. package/dist/esm-node/module-federation/distributed-ssr.mjs +0 -83
  148. package/dist/esm-node/module-federation/index.mjs +0 -116
  149. package/dist/esm-node/module-federation/last-known-good.mjs +0 -114
  150. package/dist/esm-node/module-federation/manifest-recovery-runtime-plugin.mjs +0 -90
  151. package/dist/esm-node/module-federation/surface-resolution-types.mjs +0 -9
  152. package/dist/esm-node/router/runtime/lifecycle.mjs +0 -106
  153. package/dist/esm-node/router/runtime/provider.mjs +0 -101
  154. package/dist/types/boundary-debugger/index.d.ts +0 -28
  155. package/dist/types/core/context/extensions.d.ts +0 -35
  156. package/dist/types/core/context/helmetContext.d.ts +0 -10
  157. package/dist/types/core/server/federatedCss.d.ts +0 -5
  158. package/dist/types/core/server/scriptOrder.d.ts +0 -25
  159. package/dist/types/module-federation/consume-surface.d.ts +0 -104
  160. package/dist/types/module-federation/distributed-ssr.d.ts +0 -61
  161. package/dist/types/module-federation/index.d.ts +0 -71
  162. package/dist/types/module-federation/last-known-good.d.ts +0 -52
  163. package/dist/types/module-federation/manifest-recovery-runtime-plugin.d.ts +0 -25
  164. package/dist/types/module-federation/surface-resolution-types.d.ts +0 -23
  165. package/dist/types/router/runtime/lifecycle.d.ts +0 -27
  166. package/dist/types/router/runtime/provider.d.ts +0 -78
@@ -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.js';
26
- import { type DiscoveryError, type EnvironmentId, type ParsedSurfaceRef, type ResolvedDeliveryUnit, type SurfaceResolutionProvider } from './surface-resolution-types.js';
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.js';
2
- export * from './distributed-ssr.js';
3
- export { DISTRIBUTED_SSR_FRAGMENT_REQUEST_LOCALS_KEY, useDistributedSsrFragmentProps, } from './distributed-ssr.js';
4
- export * from './last-known-good.js';
5
- export * from './manifest-recovery-runtime-plugin.js';
6
- export * from './surface-resolution-types.js';
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.js';
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.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;