@bleedingdev/modern-js-server-core 3.2.0-ultramodern.99 → 3.4.0-ultramodern.1

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 (113) hide show
  1. package/dist/cjs/adapters/node/helper/index.js +9 -5
  2. package/dist/cjs/adapters/node/helper/loadCache.js +9 -5
  3. package/dist/cjs/adapters/node/helper/loadConfig.js +9 -5
  4. package/dist/cjs/adapters/node/helper/loadEnv.js +9 -5
  5. package/dist/cjs/adapters/node/helper/loadPlugin.js +9 -5
  6. package/dist/cjs/adapters/node/helper/utils.js +12 -8
  7. package/dist/cjs/adapters/node/hono.js +9 -5
  8. package/dist/cjs/adapters/node/index.js +9 -5
  9. package/dist/cjs/adapters/node/node.js +9 -5
  10. package/dist/cjs/adapters/node/plugins/index.js +9 -5
  11. package/dist/cjs/adapters/node/plugins/nodeServer.js +12 -8
  12. package/dist/cjs/adapters/node/plugins/resource.js +10 -11
  13. package/dist/cjs/adapters/node/plugins/static.js +20 -190
  14. package/dist/cjs/adapters/node/plugins/staticModuleFederation.js +165 -0
  15. package/dist/cjs/adapters/node/plugins/staticPrecompressed.js +135 -0
  16. package/dist/cjs/constants.js +18 -13
  17. package/dist/cjs/context.js +9 -5
  18. package/dist/cjs/helper.js +12 -8
  19. package/dist/cjs/hono.js +9 -5
  20. package/dist/cjs/index.js +60 -32
  21. package/dist/cjs/plugins/compat/hooks.js +14 -10
  22. package/dist/cjs/plugins/compat/index.js +9 -5
  23. package/dist/cjs/plugins/default.js +9 -7
  24. package/dist/cjs/plugins/favicon.js +12 -8
  25. package/dist/cjs/plugins/index.js +11 -88
  26. package/dist/cjs/plugins/log.js +9 -5
  27. package/dist/cjs/plugins/middlewares.js +12 -8
  28. package/dist/cjs/plugins/monitors.js +9 -5
  29. package/dist/cjs/plugins/processedBy.js +12 -8
  30. package/dist/cjs/plugins/render/csrRscRender.js +9 -5
  31. package/dist/cjs/plugins/render/dataHandler.js +9 -5
  32. package/dist/cjs/plugins/render/index.js +12 -8
  33. package/dist/cjs/plugins/render/inject.js +12 -7
  34. package/dist/cjs/plugins/render/render.js +14 -6
  35. package/dist/cjs/plugins/render/renderRscHandler.js +9 -5
  36. package/dist/cjs/plugins/render/serverActionHandler.js +9 -5
  37. package/dist/cjs/plugins/render/ssrCache.js +9 -5
  38. package/dist/cjs/plugins/render/ssrRender.js +9 -5
  39. package/dist/cjs/plugins/render/utils.js +12 -8
  40. package/dist/cjs/plugins/route.js +9 -5
  41. package/dist/cjs/serverBase.js +9 -5
  42. package/dist/cjs/types/config/bffRuntime.js +18 -0
  43. package/dist/cjs/types/config/index.js +9 -5
  44. package/dist/cjs/types/config/serverTelemetry.js +18 -0
  45. package/dist/cjs/types/index.js +9 -5
  46. package/dist/cjs/types/plugins/index.js +9 -5
  47. package/dist/cjs/utils/entry.js +13 -9
  48. package/dist/cjs/utils/env.js +13 -9
  49. package/dist/cjs/utils/error.js +71 -5
  50. package/dist/cjs/utils/index.js +9 -5
  51. package/dist/cjs/utils/middlewareCollector.js +13 -9
  52. package/dist/cjs/utils/publicDir.js +9 -5
  53. package/dist/cjs/utils/request.js +16 -12
  54. package/dist/cjs/utils/serverConfig.js +9 -5
  55. package/dist/cjs/utils/storage.js +9 -5
  56. package/dist/cjs/utils/transformStream.js +13 -9
  57. package/dist/cjs/utils/warmup.js +12 -8
  58. package/dist/esm/adapters/node/plugins/resource.mjs +1 -6
  59. package/dist/esm/adapters/node/plugins/static.mjs +7 -181
  60. package/dist/esm/adapters/node/plugins/staticModuleFederation.mjs +96 -0
  61. package/dist/esm/adapters/node/plugins/staticPrecompressed.mjs +91 -0
  62. package/dist/esm/index.mjs +1 -1
  63. package/dist/esm/plugins/default.mjs +0 -2
  64. package/dist/esm/plugins/index.mjs +0 -3
  65. package/dist/esm/plugins/render/inject.mjs +3 -2
  66. package/dist/esm/plugins/render/render.mjs +7 -3
  67. package/dist/esm/types/config/bffRuntime.mjs +0 -0
  68. package/dist/esm/types/config/serverTelemetry.mjs +0 -0
  69. package/dist/esm/utils/error.mjs +54 -1
  70. package/dist/esm-node/adapters/node/plugins/resource.mjs +1 -6
  71. package/dist/esm-node/adapters/node/plugins/static.mjs +7 -181
  72. package/dist/esm-node/adapters/node/plugins/staticModuleFederation.mjs +97 -0
  73. package/dist/esm-node/adapters/node/plugins/staticPrecompressed.mjs +92 -0
  74. package/dist/esm-node/index.mjs +1 -1
  75. package/dist/esm-node/plugins/default.mjs +0 -2
  76. package/dist/esm-node/plugins/index.mjs +0 -3
  77. package/dist/esm-node/plugins/render/inject.mjs +3 -2
  78. package/dist/esm-node/plugins/render/render.mjs +5 -1
  79. package/dist/esm-node/types/config/bffRuntime.mjs +1 -0
  80. package/dist/esm-node/types/config/serverTelemetry.mjs +1 -0
  81. package/dist/esm-node/utils/error.mjs +54 -1
  82. package/dist/types/adapters/node/plugins/staticModuleFederation.d.ts +13 -0
  83. package/dist/types/adapters/node/plugins/staticPrecompressed.d.ts +13 -0
  84. package/dist/types/index.d.ts +2 -1
  85. package/dist/types/plugins/index.d.ts +0 -3
  86. package/dist/types/types/config/bff.d.ts +2 -97
  87. package/dist/types/types/config/bffRuntime.d.ts +105 -0
  88. package/dist/types/types/config/server.d.ts +3 -337
  89. package/dist/types/types/config/serverTelemetry.d.ts +319 -0
  90. package/dist/types/types/plugins/base.d.ts +7 -2
  91. package/dist/types/types/plugins/index.d.ts +1 -1
  92. package/dist/types/utils/error.d.ts +16 -0
  93. package/package.json +12 -12
  94. package/dist/cjs/adapters/node/plugins/moduleFederationCss.js +0 -172
  95. package/dist/cjs/plugins/contractGateAutopilot.js +0 -158
  96. package/dist/cjs/plugins/contractGateSnapshotStore.js +0 -239
  97. package/dist/cjs/plugins/mfCache.js +0 -78
  98. package/dist/cjs/plugins/telemetry.js +0 -1283
  99. package/dist/esm/adapters/node/plugins/moduleFederationCss.mjs +0 -125
  100. package/dist/esm/plugins/contractGateAutopilot.mjs +0 -124
  101. package/dist/esm/plugins/contractGateSnapshotStore.mjs +0 -180
  102. package/dist/esm/plugins/mfCache.mjs +0 -35
  103. package/dist/esm/plugins/telemetry.mjs +0 -1195
  104. package/dist/esm-node/adapters/node/plugins/moduleFederationCss.mjs +0 -126
  105. package/dist/esm-node/plugins/contractGateAutopilot.mjs +0 -125
  106. package/dist/esm-node/plugins/contractGateSnapshotStore.mjs +0 -182
  107. package/dist/esm-node/plugins/mfCache.mjs +0 -36
  108. package/dist/esm-node/plugins/telemetry.mjs +0 -1196
  109. package/dist/types/adapters/node/plugins/moduleFederationCss.d.ts +0 -33
  110. package/dist/types/plugins/contractGateAutopilot.d.ts +0 -35
  111. package/dist/types/plugins/contractGateSnapshotStore.d.ts +0 -57
  112. package/dist/types/plugins/mfCache.d.ts +0 -12
  113. package/dist/types/plugins/telemetry.d.ts +0 -309
@@ -0,0 +1,319 @@
1
+ export interface ServerTelemetryExporterOptions {
2
+ enabled?: boolean;
3
+ endpoint?: string;
4
+ headers?: Record<string, string>;
5
+ timeoutMs?: number;
6
+ }
7
+ export interface ServerTelemetryVictoriaMetricsOptions extends ServerTelemetryExporterOptions {
8
+ metricPrefix?: string;
9
+ }
10
+ export interface ServerTelemetrySloUserConfig {
11
+ /**
12
+ * Queue utilization ratio threshold that emits SLO degradation alerts.
13
+ *
14
+ * @default 0.8
15
+ */
16
+ queueUtilizationWarnThreshold?: number;
17
+ /**
18
+ * Total dropped-envelope threshold that emits SLO degradation alerts.
19
+ *
20
+ * @default 1
21
+ */
22
+ queueDroppedWarnThreshold?: number;
23
+ /**
24
+ * Cooldown between SLO alert emissions for the same alert type.
25
+ *
26
+ * @default 60000
27
+ */
28
+ alertCooldownMs?: number;
29
+ }
30
+ export interface ServerTelemetryCanaryContractGateUserConfig {
31
+ /**
32
+ * Whether this contract gate currently passes.
33
+ */
34
+ passed: boolean;
35
+ /**
36
+ * Optional failure reason used for rollback diagnostics.
37
+ */
38
+ reason?: string;
39
+ }
40
+ export interface ServerTelemetryCanaryAutopilotUserConfig {
41
+ /**
42
+ * Enable automatic contract gate synchronization from a gate snapshot file.
43
+ *
44
+ * @default true
45
+ */
46
+ enabled?: boolean;
47
+ /**
48
+ * Path to contract gate snapshot JSON file.
49
+ *
50
+ * @default ".modern/contract-gates.json"
51
+ */
52
+ gateSnapshotPath?: string;
53
+ /**
54
+ * Poll interval for reading gate snapshot changes.
55
+ *
56
+ * @default 15000
57
+ */
58
+ pollIntervalMs?: number;
59
+ /**
60
+ * Marks gate entries as failed when they are older than this threshold.
61
+ *
62
+ * @default 600000
63
+ */
64
+ gateStaleAfterMs?: number;
65
+ /**
66
+ * Runtime MF fallback signal ingestion.
67
+ */
68
+ runtimeFallbackSignal?: ServerTelemetryCanaryRuntimeFallbackSignalUserConfig;
69
+ /**
70
+ * Optional pluggable state store backend for contract gate snapshots.
71
+ * When omitted, snapshots are read/written from gateSnapshotPath on local disk.
72
+ */
73
+ stateStore?: ServerTelemetryCanaryAutopilotStateStoreUserConfig;
74
+ }
75
+ export interface ServerTelemetryCanaryAutopilotStateStoreUserConfig {
76
+ /**
77
+ * Path or package name of a module that exports
78
+ * `createContractGateSnapshotStore(context)`.
79
+ */
80
+ module: string;
81
+ /**
82
+ * Optional adapter-specific configuration.
83
+ */
84
+ options?: Record<string, unknown>;
85
+ }
86
+ export interface ServerTelemetryCanaryRuntimeFallbackSignalUserConfig {
87
+ /**
88
+ * Enable runtime MF fallback signal ingestion endpoint.
89
+ *
90
+ * Opt-in: when enabled, `auth` must be configured with a token
91
+ * (`expectedValue` or `expectedValueEnv`) or server setup throws.
92
+ *
93
+ * @default false
94
+ */
95
+ enabled?: boolean;
96
+ /**
97
+ * HTTP endpoint path for runtime fallback events.
98
+ *
99
+ * @default "/_modern/contract-gates/runtime-fallback"
100
+ */
101
+ endpoint?: string;
102
+ /**
103
+ * Contract gate name updated by runtime fallback events.
104
+ *
105
+ * @default "runtime-mf-fallback-health"
106
+ */
107
+ gateName?: string;
108
+ /**
109
+ * How long a runtime fallback signal should hold gate failure status.
110
+ *
111
+ * @default 300000
112
+ */
113
+ failureHoldMs?: number;
114
+ /**
115
+ * Maximum accepted request body size in bytes.
116
+ *
117
+ * @default 16384
118
+ */
119
+ maxBodyBytes?: number;
120
+ /**
121
+ * Optional runtime trust policy for fallback signal ingestion.
122
+ * Use this to restrict who can mutate canary contract gates.
123
+ */
124
+ trustPolicy?: ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig;
125
+ /**
126
+ * Optional request authentication for runtime fallback signal endpoint.
127
+ */
128
+ auth?: ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig;
129
+ }
130
+ export interface ServerTelemetryCanaryRuntimeFallbackSignalAuthUserConfig {
131
+ /**
132
+ * Enable auth guard for runtime fallback signal endpoint.
133
+ *
134
+ * @default false
135
+ */
136
+ enabled?: boolean;
137
+ /**
138
+ * Header name carrying runtime fallback auth token.
139
+ *
140
+ * @default "x-modernjs-runtime-signal-token"
141
+ */
142
+ headerName?: string;
143
+ /**
144
+ * Expected token value. Prefer using expectedValueEnv in production.
145
+ */
146
+ expectedValue?: string;
147
+ /**
148
+ * Name of environment variable that stores expected token value.
149
+ */
150
+ expectedValueEnv?: string;
151
+ }
152
+ export interface ServerTelemetryCanaryRuntimeFallbackSignalTrustPolicyUserConfig {
153
+ /**
154
+ * Allowlist of app names accepted by runtime fallback signal endpoint.
155
+ * Empty means no app-name allowlist check.
156
+ */
157
+ allowedApps?: string[];
158
+ /**
159
+ * Allowlist of entry origins accepted by runtime fallback signal endpoint.
160
+ * Values should be URL origins (for example https://erp.example.com).
161
+ * Empty means no entry-origin allowlist check.
162
+ */
163
+ allowedEntryOrigins?: string[];
164
+ /**
165
+ * Expected runtime digest per appName.
166
+ */
167
+ expectedRuntimeDigests?: Record<string, string>;
168
+ /**
169
+ * Require runtimeDigest to be present in signal payload metadata.
170
+ *
171
+ * @default false
172
+ */
173
+ enforceRuntimeDigest?: boolean;
174
+ /**
175
+ * Maximum accepted signals per app+origin window.
176
+ *
177
+ * @default 30
178
+ */
179
+ maxSignalsPerWindow?: number;
180
+ /**
181
+ * Sliding window size in milliseconds for maxSignalsPerWindow.
182
+ *
183
+ * @default 60000
184
+ */
185
+ windowMs?: number;
186
+ /**
187
+ * Drop duplicate fallback events with the same fingerprint during this window.
188
+ *
189
+ * @default 10000
190
+ */
191
+ dedupeWindowMs?: number;
192
+ }
193
+ export interface ServerTelemetryCanaryUserConfig {
194
+ /**
195
+ * Enable canary rollout/rollback orchestration.
196
+ *
197
+ * @default false
198
+ */
199
+ enabled?: boolean;
200
+ /**
201
+ * Periodic canary evaluation interval in milliseconds.
202
+ *
203
+ * @default 15000
204
+ */
205
+ evaluationIntervalMs?: number;
206
+ /**
207
+ * Required consecutive healthy evaluations before promotion.
208
+ *
209
+ * @default 3
210
+ */
211
+ minConsecutiveHealthyEvaluations?: number;
212
+ /**
213
+ * Consecutive failing evaluations before automated rollback.
214
+ *
215
+ * @default 2
216
+ */
217
+ rollbackConsecutiveFailures?: number;
218
+ /**
219
+ * Maximum queue utilization ratio allowed during canary.
220
+ *
221
+ * @default 0.8
222
+ */
223
+ maxQueueUtilization?: number;
224
+ /**
225
+ * Maximum allowed total dropped envelopes during canary.
226
+ *
227
+ * @default 0
228
+ */
229
+ maxTotalDropped?: number;
230
+ /**
231
+ * Maximum allowed unhealthy exporters during canary.
232
+ *
233
+ * @default 0
234
+ */
235
+ maxUnhealthyExporters?: number;
236
+ /**
237
+ * Contract gate map used in rollout decisions.
238
+ * `true` means passing, `false` means failing.
239
+ */
240
+ contractGates?: Record<string, boolean | ServerTelemetryCanaryContractGateUserConfig>;
241
+ /**
242
+ * Contract-gate autopilot settings.
243
+ */
244
+ autopilot?: ServerTelemetryCanaryAutopilotUserConfig;
245
+ }
246
+ export interface ServerTelemetryUserConfig {
247
+ /**
248
+ * Enable framework telemetry envelope emission.
249
+ * @default false
250
+ */
251
+ enabled?: boolean;
252
+ /**
253
+ * Logical service name attached to every telemetry envelope.
254
+ * @default server.metaName
255
+ */
256
+ service?: string;
257
+ /**
258
+ * Logical module name attached to every telemetry envelope.
259
+ * @default "server"
260
+ */
261
+ module?: string;
262
+ /**
263
+ * Environment attached to every telemetry envelope.
264
+ * @default process.env.NODE_ENV || "development"
265
+ */
266
+ environment?: string;
267
+ /**
268
+ * Sampling rate for monitor events.
269
+ * @default 1
270
+ */
271
+ samplingRate?: number;
272
+ /**
273
+ * Flush window in milliseconds for exporter batches.
274
+ * @default 1000
275
+ */
276
+ flushIntervalMs?: number;
277
+ /**
278
+ * Maximum envelopes in one emitted batch.
279
+ * @default 50
280
+ */
281
+ maxBatchSize?: number;
282
+ /**
283
+ * Maximum envelopes buffered before backpressure drops oldest.
284
+ * @default 1000
285
+ */
286
+ maxQueueSize?: number;
287
+ /**
288
+ * Envelope attribute keys that should be redacted.
289
+ */
290
+ redactionKeys?: string[];
291
+ /**
292
+ * Control startup exporter health probe behavior.
293
+ * When enabled (default), server initialization emits a startup probe and
294
+ * marks exporters healthy/unhealthy before serving traffic.
295
+ * When fail-loud mode is enabled (default), initialization throws if at
296
+ * least one configured exporter is unhealthy.
297
+ *
298
+ * @default true
299
+ */
300
+ failLoudStartup?: boolean;
301
+ /**
302
+ * Queue backpressure/degradation SLO alert thresholds.
303
+ */
304
+ slo?: ServerTelemetrySloUserConfig;
305
+ /**
306
+ * Canary rollout and automated rollback orchestration policy.
307
+ */
308
+ canary?: ServerTelemetryCanaryUserConfig;
309
+ exporters?: {
310
+ /**
311
+ * OpenTelemetry HTTP exporter.
312
+ */
313
+ otlp?: ServerTelemetryExporterOptions;
314
+ /**
315
+ * VictoriaMetrics Prometheus import exporter.
316
+ */
317
+ victoriaMetrics?: ServerTelemetryVictoriaMetricsOptions;
318
+ };
319
+ }
@@ -1,15 +1,20 @@
1
- import type { CacheOption, Container, HttpMethodDecider, MiddlewareContext, ServerRoute } from '@modern-js/types';
1
+ import type { CacheOption, Container, HttpMethodDecider, MiddlewareContext, Monitors, ServerRoute } from '@modern-js/types';
2
2
  import type { Context, MiddlewareHandler } from 'hono';
3
3
  import type { UserConfig } from '../config';
4
4
  import type { Render } from '../render';
5
5
  import type { ServerPlugin } from './plugin';
6
6
  export type { FileChangeEvent, ResetEvent } from '@modern-js/plugin';
7
7
  export type FallbackReason = 'error' | 'header' | 'query' | `header,${string}`;
8
+ export type FallbackContext = {
9
+ request: Request;
10
+ monitors?: Monitors;
11
+ };
8
12
  export type FallbackInput = {
9
13
  reason: FallbackReason;
10
14
  error: unknown;
15
+ context?: FallbackContext;
11
16
  };
12
- export type OnFallback = (reason: FallbackReason, error?: unknown) => Promise<void>;
17
+ export type OnFallback = (reason: FallbackReason, error?: unknown, context?: FallbackContext) => Promise<void>;
13
18
  export type APIServerStartInput = {
14
19
  pwd: string;
15
20
  prefix?: string;
@@ -1,2 +1,2 @@
1
- export type { APIServerStartInput, CacheConfig, FallbackInput, FallbackReason, FileChangeEvent, GetRenderHandlerOptions, MiddlewareObj, OnFallback, ServerConfig, ServerMiddleware, WebServerStartInput, } from './base';
1
+ export type { APIServerStartInput, CacheConfig, FallbackContext, FallbackInput, FallbackReason, FileChangeEvent, GetRenderHandlerOptions, MiddlewareObj, OnFallback, ServerConfig, ServerMiddleware, WebServerStartInput, } from './base';
2
2
  export * from './plugin';
@@ -1,4 +1,20 @@
1
1
  import type { Monitors } from '@modern-js/types';
2
+ export type SafeFailureEnvelope = {
3
+ success: false;
4
+ error: {
5
+ code: string;
6
+ message: string;
7
+ status: number;
8
+ };
9
+ };
10
+ export type SafeFailureHttpResult = {
11
+ status: number;
12
+ body: SafeFailureEnvelope;
13
+ headers: Record<string, string>;
14
+ };
15
+ export declare const getSafeFailureStatus: (error: unknown) => number;
16
+ export declare const createSafeFailureHttpResult: (error: unknown) => SafeFailureHttpResult;
17
+ export declare const createSafeJsonFailureResponse: (error: unknown) => Response;
2
18
  export declare const createErrorHtml: (status: number) => string;
3
19
  export declare enum ErrorDigest {
4
20
  ENOTF = "Page could not be found",
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.2.0-ultramodern.99",
20
+ "version": "3.4.0-ultramodern.1",
21
21
  "types": "./dist/types/index.d.ts",
22
22
  "main": "./dist/cjs/index.js",
23
23
  "exports": {
@@ -74,21 +74,21 @@
74
74
  "@web-std/stream": "^1.0.3",
75
75
  "cloneable-readable": "^3.0.0",
76
76
  "flatted": "^3.4.2",
77
- "hono": "^4.12.22",
77
+ "hono": "^4.12.27",
78
78
  "ts-deepmerge": "8.0.0",
79
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.99",
80
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.99",
81
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.99"
79
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.4.0-ultramodern.1",
80
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.4.0-ultramodern.1",
81
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.4.0-ultramodern.1"
82
82
  },
83
83
  "devDependencies": {
84
- "@rslib/core": "0.21.5",
84
+ "@rslib/core": "0.23.0",
85
85
  "@types/cloneable-readable": "^2.0.3",
86
86
  "@types/merge-deep": "^3.0.3",
87
- "@types/node": "^25.9.1",
88
- "@typescript/native-preview": "7.0.0-dev.20260527.2",
89
- "http-proxy-middleware": "^4.0.0",
90
- "@scripts/rstest-config": "2.66.0",
91
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.99"
87
+ "@types/node": "^26.0.0",
88
+ "@typescript/native-preview": "7.0.0-dev.20260624.1",
89
+ "http-proxy-middleware": "^4.1.1",
90
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.4.0-ultramodern.1",
91
+ "@scripts/rstest-config": "2.66.0"
92
92
  },
93
93
  "sideEffects": false,
94
94
  "publishConfig": {
@@ -97,7 +97,7 @@
97
97
  },
98
98
  "scripts": {
99
99
  "dev": "rslib build --watch",
100
- "build": "rslib build",
100
+ "build": "rslib build && pnpm -w tsgo:dts \"$PWD\"",
101
101
  "test": "rstest --passWithNoTests"
102
102
  }
103
103
  }
@@ -1,172 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
18
- };
19
- })();
20
- (()=>{
21
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
- })();
23
- (()=>{
24
- __webpack_require__.r = (exports1)=>{
25
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
- value: 'Module'
27
- });
28
- Object.defineProperty(exports1, '__esModule', {
29
- value: true
30
- });
31
- };
32
- })();
33
- var __webpack_exports__ = {};
34
- __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- collectDirectRemoteModuleFederationCss: ()=>collectDirectRemoteModuleFederationCss,
37
- collectModuleFederationManifestCss: ()=>collectModuleFederationManifestCss
38
- });
39
- const fileReader_namespaceObject = require("@modern-js/runtime-utils/fileReader");
40
- const utils_namespaceObject = require("@modern-js/utils");
41
- const external_path_namespaceObject = require("path");
42
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
43
- const MODULE_FEDERATION_MANIFEST_FILE = 'mf-manifest.json';
44
- const DEFAULT_REMOTE_MANIFEST_TIMEOUT = 1500;
45
- const warn = (monitors, message, ...args)=>{
46
- if (monitors) return void monitors.warn(message, ...args);
47
- console.warn(message, ...args);
48
- };
49
- const ensureTrailingSlash = (value)=>value.endsWith('/') ? value : `${value}/`;
50
- const tryResolveUrl = (value, base)=>{
51
- try {
52
- return new URL(value, base).toString();
53
- } catch {
54
- return;
55
- }
56
- };
57
- const normalizeRemoteEntry = (entry)=>{
58
- const value = entry.trim();
59
- if (!value) return;
60
- const atIndex = value.lastIndexOf('@');
61
- return atIndex >= 0 ? value.slice(atIndex + 1) : value;
62
- };
63
- const getCssAssets = (assets)=>[
64
- ...assets?.css?.sync || [],
65
- ...assets?.css?.async || []
66
- ];
67
- const getManifestFallbackBase = (manifestUrl)=>{
68
- try {
69
- return new URL('.', manifestUrl).toString();
70
- } catch {
71
- return ensureTrailingSlash(manifestUrl);
72
- }
73
- };
74
- const getManifestPublicPathBase = (publicPath, manifestUrl)=>{
75
- if (!publicPath || 'auto' === publicPath) return getManifestFallbackBase(manifestUrl);
76
- const base = tryResolveUrl(ensureTrailingSlash(publicPath), manifestUrl);
77
- return base || getManifestFallbackBase(manifestUrl);
78
- };
79
- const appendResolvedCssAssets = (result, seen, assets, base)=>{
80
- for (const asset of assets){
81
- if (!asset) continue;
82
- const resolved = tryResolveUrl(asset, base);
83
- if (resolved && !seen.has(resolved)) {
84
- seen.add(resolved);
85
- result.push(resolved);
86
- }
87
- }
88
- };
89
- const collectModuleFederationManifestCss = (manifest, manifestUrl)=>{
90
- const base = getManifestPublicPathBase(manifest.metaData?.publicPath, manifestUrl);
91
- const result = [];
92
- const seen = new Set();
93
- for (const item of manifest.shared || [])appendResolvedCssAssets(result, seen, getCssAssets(item.assets), base);
94
- for (const item of manifest.exposes || [])appendResolvedCssAssets(result, seen, getCssAssets(item.assets), base);
95
- return result;
96
- };
97
- const fetchJsonWithTimeout = async (url, fetcher, timeout)=>{
98
- const controller = new AbortController();
99
- let timeoutId;
100
- try {
101
- const response = await Promise.race([
102
- fetcher(url, {
103
- signal: controller.signal
104
- }),
105
- new Promise((_, reject)=>{
106
- timeoutId = setTimeout(()=>{
107
- controller.abort();
108
- reject(new Error(`Request timed out after ${timeout}ms`));
109
- }, timeout);
110
- })
111
- ]);
112
- if (!response.ok) throw new Error(`Unexpected status ${response.status}`);
113
- return await response.json();
114
- } finally{
115
- if (timeoutId) clearTimeout(timeoutId);
116
- }
117
- };
118
- const getHostManifest = async (pwd, monitors)=>{
119
- const manifestPath = external_path_default().join(pwd, MODULE_FEDERATION_MANIFEST_FILE);
120
- if (!await utils_namespaceObject.fs.pathExists(manifestPath)) return;
121
- const manifestBuffer = await fileReader_namespaceObject.fileReader.readFileFromSystem(manifestPath, 'buffer');
122
- if (null === manifestBuffer) return;
123
- try {
124
- return JSON.parse(manifestBuffer.toString('utf-8'));
125
- } catch (error) {
126
- warn(monitors, 'Parse module federation manifest failed, error = %s', error instanceof Error ? error.message : error);
127
- return;
128
- }
129
- };
130
- const collectDirectRemoteModuleFederationCss = async (pwd, options = {})=>{
131
- const hostManifest = await getHostManifest(pwd, options.monitors);
132
- if (!hostManifest) return [];
133
- const fetcher = options.fetcher || globalThis.fetch?.bind(globalThis);
134
- if (!fetcher) {
135
- warn(options.monitors, 'Skip module federation remote CSS collection because fetch is unavailable.');
136
- return [];
137
- }
138
- const timeout = options.timeout ?? DEFAULT_REMOTE_MANIFEST_TIMEOUT;
139
- const cssAssets = [];
140
- const seen = new Set();
141
- for (const remote of hostManifest.remotes || []){
142
- if (!remote.entry) continue;
143
- const remoteEntry = normalizeRemoteEntry(remote.entry);
144
- if (!remoteEntry) continue;
145
- let remoteManifestUrl;
146
- try {
147
- remoteManifestUrl = new URL(remoteEntry).toString();
148
- } catch {
149
- warn(options.monitors, 'Skip module federation remote CSS collection for non-absolute manifest URL %s', remoteEntry);
150
- continue;
151
- }
152
- try {
153
- const remoteManifest = await fetchJsonWithTimeout(remoteManifestUrl, fetcher, timeout);
154
- for (const asset of collectModuleFederationManifestCss(remoteManifest, remoteManifestUrl))if (!seen.has(asset)) {
155
- seen.add(asset);
156
- cssAssets.push(asset);
157
- }
158
- } catch (error) {
159
- warn(options.monitors, 'Load module federation remote manifest %s failed, error = %s', remoteManifestUrl, error instanceof Error ? error.message : error);
160
- }
161
- }
162
- return cssAssets;
163
- };
164
- exports.collectDirectRemoteModuleFederationCss = __webpack_exports__.collectDirectRemoteModuleFederationCss;
165
- exports.collectModuleFederationManifestCss = __webpack_exports__.collectModuleFederationManifestCss;
166
- for(var __rspack_i in __webpack_exports__)if (-1 === [
167
- "collectDirectRemoteModuleFederationCss",
168
- "collectModuleFederationManifestCss"
169
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
170
- Object.defineProperty(exports, '__esModule', {
171
- value: true
172
- });