isr-engine 2.6.21 → 3.1.0
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.
- package/README.md +97 -616
- package/dist/Logger-DqBS_3v8.cjs +184 -0
- package/dist/Logger-DqBS_3v8.cjs.map +1 -0
- package/dist/Logger-bg-doGwZ.js +174 -0
- package/dist/Logger-bg-doGwZ.js.map +1 -0
- package/dist/abVariantContext-BvAMuhjj.cjs +510 -0
- package/dist/abVariantContext-BvAMuhjj.cjs.map +1 -0
- package/dist/abVariantContext-Ud3aZ1yk.js +355 -0
- package/dist/abVariantContext-Ud3aZ1yk.js.map +1 -0
- package/dist/app/createISRApp.d.ts +2 -2
- package/dist/cli/cli.cjs +1 -1
- package/dist/cli/cli.js +1 -1
- package/dist/cli/start.d.ts +1 -1
- package/dist/config/loadConfig.d.ts +1 -1
- package/dist/config/normalizeEngineConfig.d.ts +1 -1
- package/dist/config/normalizeEngineConfig.d.ts.map +1 -1
- package/dist/config/resolveRuntimeRedis.d.ts +1 -1
- package/dist/{createCacheInspectorMiddleware-DYJ2WGYu.js → createCacheInspectorMiddleware-Bjku5v62.js} +10 -5
- package/dist/createCacheInspectorMiddleware-Bjku5v62.js.map +1 -0
- package/dist/{createCacheInspectorMiddleware-Byzz8ZlU.cjs → createCacheInspectorMiddleware-DG1_VLBS.cjs} +12 -5
- package/dist/createCacheInspectorMiddleware-DG1_VLBS.cjs.map +1 -0
- package/dist/{createISRApp-CylUYiIU.js → createISRApp-DYVU8ydT.js} +632 -100
- package/dist/createISRApp-DYVU8ydT.js.map +1 -0
- package/dist/{createISRApp-C9Bezuit.cjs → createISRApp-HX6X8UNb.cjs} +698 -129
- package/dist/createISRApp-HX6X8UNb.cjs.map +1 -0
- package/dist/{createImagePlugin-_ntL0DcT.js → createImagePlugin-BZJHOvN9.js} +67 -21
- package/dist/createImagePlugin-BZJHOvN9.js.map +1 -0
- package/dist/{createImagePlugin-birVNynL.cjs → createImagePlugin-Ca4t_WhM.cjs} +73 -21
- package/dist/createImagePlugin-Ca4t_WhM.cjs.map +1 -0
- package/dist/defaults/runtime/browserObservability.d.ts.map +1 -1
- package/dist/defaults/runtime/defineSiteHooks.cjs +2 -2
- package/dist/defaults/runtime/defineSiteHooks.js +2 -2
- package/dist/defaults/runtime/dev-style-resource-dispatcher.server.d.ts.map +1 -1
- package/dist/{defineSiteHooks-BeVy-qPH.js → defineSiteHooks-CV4tqHvB.js} +11 -5
- package/dist/{defineSiteHooks-BeVy-qPH.js.map → defineSiteHooks-CV4tqHvB.js.map} +1 -1
- package/dist/{defineSiteHooks-C3v3WLS8.cjs → defineSiteHooks-w2IrF5-D.cjs} +11 -5
- package/dist/{defineSiteHooks-C3v3WLS8.cjs.map → defineSiteHooks-w2IrF5-D.cjs.map} +1 -1
- package/dist/engine/ISREngine.d.ts +2 -2
- package/dist/engine/ISREngine.d.ts.map +1 -1
- package/dist/{i18n-CyJIoYJT.cjs → i18n-CS5QhOO0.cjs} +7 -30
- package/dist/i18n-CS5QhOO0.cjs.map +1 -0
- package/dist/{i18n-Dobe0Wxn.js → i18n-CnXYAgQE.js} +8 -25
- package/dist/i18n-CnXYAgQE.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/isr/ISRRoutes.d.ts +5 -3
- package/dist/isr/ISRRoutes.d.ts.map +1 -1
- package/dist/isr-engine.cjs +619 -117
- package/dist/isr-engine.cjs.map +1 -1
- package/dist/isr-engine.js +609 -107
- package/dist/isr-engine.js.map +1 -1
- package/dist/logger/Logger.d.ts +6 -2
- package/dist/logger/Logger.d.ts.map +1 -1
- package/dist/logger/logRecord.d.ts +11 -0
- package/dist/logger/logRecord.d.ts.map +1 -0
- package/dist/logger/runtimeLogger.d.ts +6 -0
- package/dist/logger/runtimeLogger.d.ts.map +1 -0
- package/dist/metrics/PromMetrics.d.ts.map +1 -1
- package/dist/middlewares/LocaleRedirect.d.ts.map +1 -1
- package/dist/plugin/createCacheInspectorMiddleware.d.ts.map +1 -1
- package/dist/plugin/createDevCssHandoffPlugin.d.ts.map +1 -1
- package/dist/plugin/createFontPlugin.d.ts +1 -1
- package/dist/plugin/createFontPlugin.d.ts.map +1 -1
- package/dist/plugin/createIsrPlugin.d.ts.map +1 -1
- package/dist/plugin/googleFontAssets.d.ts +23 -0
- package/dist/plugin/googleFontAssets.d.ts.map +1 -0
- package/dist/plugin/isrCacheMiddleware.d.ts +5 -0
- package/dist/plugin/isrCacheMiddleware.d.ts.map +1 -1
- package/dist/plugin/remoteImageSource.d.ts +3 -3
- package/dist/plugin/remoteImageSource.d.ts.map +1 -1
- package/dist/rsc/ServerActions.d.ts.map +1 -1
- package/dist/rsc/cacheTag.d.ts.map +1 -1
- package/dist/rsc/index.cjs +8 -9
- package/dist/rsc/index.js +2 -3
- package/dist/rsc/revalidate.d.ts.map +1 -1
- package/dist/rsc/revalidationMetrics.d.ts +6 -0
- package/dist/rsc/revalidationMetrics.d.ts.map +1 -0
- package/dist/{rsc-lvWPTuVD.js → rsc-BJzB9s8U.js} +4 -6
- package/dist/rsc-BJzB9s8U.js.map +1 -0
- package/dist/{rsc-H7D_meHu.cjs → rsc-CYT6B6bf.cjs} +5 -7
- package/dist/rsc-CYT6B6bf.cjs.map +1 -0
- package/dist/server/manager.d.ts +1 -1
- package/dist/server/manager.d.ts.map +1 -1
- package/dist/server/opsConfig.d.ts +7 -1
- package/dist/server/opsConfig.d.ts.map +1 -1
- package/dist/server/productionRuntime.d.ts +3 -4
- package/dist/server/productionRuntime.d.ts.map +1 -1
- package/dist/server/requestLimits.d.ts +36 -0
- package/dist/server/requestLimits.d.ts.map +1 -0
- package/dist/server/safeRedirect.d.ts +6 -0
- package/dist/server/safeRedirect.d.ts.map +1 -0
- package/dist/server/types.d.ts +1 -1
- package/dist/ssg/spider.d.ts.map +1 -1
- package/dist/types/ISRConfig.d.ts +17 -0
- package/dist/types/ISRConfig.d.ts.map +1 -1
- package/dist/utils/cookie.d.ts.map +1 -1
- package/dist/utils/resolveFetchHandler.d.ts.map +1 -1
- package/package.json +30 -32
- package/src/defaults/runtime/browserObservability.ts +29 -13
- package/src/defaults/runtime/defineServerEntry.tsx +2 -2
- package/src/defaults/runtime/defineSiteHooks.ts +12 -7
- package/src/defaults/runtime/dev-style-resource-dispatcher.server.ts +2 -3
- package/src/types/ISRConfig.ts +21 -7
- package/src/utils/cookie.ts +5 -3
- package/src/utils/resolveFetchHandler.ts +1 -3
- package/dist/RequestContext-BVQ-rOmV.js +0 -58
- package/dist/RequestContext-BVQ-rOmV.js.map +0 -1
- package/dist/RequestContext-DgGEAxcW.cjs +0 -105
- package/dist/RequestContext-DgGEAxcW.cjs.map +0 -1
- package/dist/abVariantContext-CWCdRSdG.js +0 -549
- package/dist/abVariantContext-CWCdRSdG.js.map +0 -1
- package/dist/abVariantContext-Cqp-uxtd.cjs +0 -678
- package/dist/abVariantContext-Cqp-uxtd.cjs.map +0 -1
- package/dist/createCacheInspectorMiddleware-Byzz8ZlU.cjs.map +0 -1
- package/dist/createCacheInspectorMiddleware-DYJ2WGYu.js.map +0 -1
- package/dist/createISRApp-C9Bezuit.cjs.map +0 -1
- package/dist/createISRApp-CylUYiIU.js.map +0 -1
- package/dist/createImagePlugin-_ntL0DcT.js.map +0 -1
- package/dist/createImagePlugin-birVNynL.cjs.map +0 -1
- package/dist/i18n-CyJIoYJT.cjs.map +0 -1
- package/dist/i18n-Dobe0Wxn.js.map +0 -1
- package/dist/rsc-H7D_meHu.cjs.map +0 -1
- package/dist/rsc-lvWPTuVD.js.map +0 -1
|
@@ -358,6 +358,21 @@ export declare const InternalStrategies: {
|
|
|
358
358
|
export declare const FallbackChain: Record<RenderModeType, InternalStrategyType[]>;
|
|
359
359
|
/** Express-compatible policy for determining whether a remote proxy is trusted. */
|
|
360
360
|
export type ProxyTrustPolicy = boolean | number | string | string[] | ((address: string, hop: number) => boolean);
|
|
361
|
+
/** Positive, per-process admission budgets for engine-owned expensive request work. */
|
|
362
|
+
export interface RequestLimitPolicy {
|
|
363
|
+
windowMs?: number;
|
|
364
|
+
/** Maximum requests from one IPv4 address or IPv6 /56 per window. */
|
|
365
|
+
maxRequests?: number;
|
|
366
|
+
/** Maximum aggregate requests per window, including rejected client attempts. */
|
|
367
|
+
globalMaxRequests?: number;
|
|
368
|
+
/** Maximum live client counters; new clients receive 429 when this capacity is full. */
|
|
369
|
+
maxClients?: number;
|
|
370
|
+
}
|
|
371
|
+
export interface RequestLimitsConfig {
|
|
372
|
+
ops?: RequestLimitPolicy;
|
|
373
|
+
staticHtml?: RequestLimitPolicy;
|
|
374
|
+
seo?: RequestLimitPolicy;
|
|
375
|
+
}
|
|
361
376
|
export interface ISRConfig {
|
|
362
377
|
/** 全局默认渲染模式 */
|
|
363
378
|
renderMode: RenderModeType;
|
|
@@ -397,6 +412,8 @@ export interface ISRConfig {
|
|
|
397
412
|
* Hop counts/true require an ingress that overwrites client forwarded headers.
|
|
398
413
|
*/
|
|
399
414
|
trustProxy?: ProxyTrustPolicy;
|
|
415
|
+
/** Engine ops, indexed static HTML reads and SEO admission. Page cache hits/APIs are separate. */
|
|
416
|
+
requestLimits?: RequestLimitsConfig;
|
|
400
417
|
/** Node origin 监听端口;缺省 3000。 */
|
|
401
418
|
port: number;
|
|
402
419
|
/** Node origin 监听地址;通常本地留空,容器/内网按部署平台注入。 */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISRConfig.d.ts","sourceRoot":"","sources":["../../src/types/ISRConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;AAC/F;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,mDAAmD;IACnD,GAAG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,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/utils/cookie.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,IAAI,GACJ,SAAS,GACT;IACE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;CACnF,CAAC;AAEN,wBAAgB,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAelE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIvF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveFetchHandler.d.ts","sourceRoot":"","sources":["../../src/utils/resolveFetchHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"resolveFetchHandler.d.ts","sourceRoot":"","sources":["../../src/utils/resolveFetchHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAajE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isr-engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "ISR/SSG/Fallback rendering orchestration on Vite + React 19 RSC.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -111,40 +111,41 @@
|
|
|
111
111
|
"test:release": "node scripts/check-release.mjs"
|
|
112
112
|
},
|
|
113
113
|
"engines": {
|
|
114
|
-
"node": "
|
|
114
|
+
"node": "24.15.0"
|
|
115
115
|
},
|
|
116
116
|
"packageManager": "pnpm@9.15.9",
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"@vitejs/plugin-rsc": "0.5.
|
|
119
|
-
"chalk": "^
|
|
118
|
+
"@vitejs/plugin-rsc": "0.5.39",
|
|
119
|
+
"chalk": "^6.0.1",
|
|
120
120
|
"commander": "^12.1.0",
|
|
121
121
|
"compression": "^1.8.2",
|
|
122
122
|
"css-tree": "^3.2.1",
|
|
123
123
|
"esbuild": "^0.28.2",
|
|
124
124
|
"express": "^5.3.0",
|
|
125
|
+
"express-rate-limit": "8.7.5",
|
|
125
126
|
"helmet": "^7.1.0",
|
|
126
127
|
"ipaddr.js": "^2.5.0",
|
|
127
128
|
"lru-cache": "^10.4.3",
|
|
128
|
-
"ora": "^
|
|
129
|
+
"ora": "^10.0.0",
|
|
129
130
|
"parse5": "^8.0.1",
|
|
131
|
+
"pino": "10.4.0",
|
|
130
132
|
"prom-client": "^15.1.3",
|
|
133
|
+
"rsc-html-stream": "0.0.7",
|
|
131
134
|
"sharp": "^0.35.5",
|
|
132
|
-
"sitemap": "^
|
|
133
|
-
"typescript": "^
|
|
135
|
+
"sitemap": "^10.0.0",
|
|
136
|
+
"typescript": "^6.0.3"
|
|
134
137
|
},
|
|
135
138
|
"peerDependencies": {
|
|
136
|
-
"react": "19.3.
|
|
137
|
-
"react-dom": "19.3.
|
|
138
|
-
"react-server-dom-webpack": "19.3.0-canary-bd6ea412-20260824",
|
|
139
|
-
"rsc-html-stream": "^0.0.7",
|
|
139
|
+
"react": "19.3.1",
|
|
140
|
+
"react-dom": "19.3.1",
|
|
140
141
|
"vite": "8.1.6"
|
|
141
142
|
},
|
|
142
143
|
"optionalDependencies": {
|
|
143
|
-
"ioredis": "^5.
|
|
144
|
+
"ioredis": "^5.11.1"
|
|
144
145
|
},
|
|
145
146
|
"devDependencies": {
|
|
146
|
-
"@eslint/js": "^9.
|
|
147
|
-
"@playwright/test": "
|
|
147
|
+
"@eslint/js": "^9.39.5",
|
|
148
|
+
"@playwright/test": "1.65.1",
|
|
148
149
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
149
150
|
"@semantic-release/exec": "7.1.0",
|
|
150
151
|
"@semantic-release/npm": "13.2.0",
|
|
@@ -152,34 +153,31 @@
|
|
|
152
153
|
"@types/compression": "^1.7.5",
|
|
153
154
|
"@types/css-tree": "^3.2.0",
|
|
154
155
|
"@types/express": "^5.0.0",
|
|
155
|
-
"@types/ioredis-mock": "^8.2.
|
|
156
|
-
"@types/node": "
|
|
156
|
+
"@types/ioredis-mock": "^8.2.8",
|
|
157
|
+
"@types/node": "24.19.2",
|
|
157
158
|
"@types/react": "^19.2.15",
|
|
158
159
|
"@types/react-dom": "^19.0.0",
|
|
159
|
-
"@typescript-eslint/eslint-plugin": "
|
|
160
|
-
"@typescript-eslint/parser": "
|
|
160
|
+
"@typescript-eslint/eslint-plugin": "8.72.2",
|
|
161
|
+
"@typescript-eslint/parser": "8.72.2",
|
|
161
162
|
"@vitest/coverage-v8": "^4.1.12",
|
|
162
|
-
"autocannon": "^8.0.0",
|
|
163
163
|
"eslint": "^9.15.0",
|
|
164
|
-
"eslint-config-prettier": "^
|
|
165
|
-
"eslint-plugin-prettier": "^5.5.
|
|
164
|
+
"eslint-config-prettier": "^10.1.8",
|
|
165
|
+
"eslint-plugin-prettier": "^5.5.7",
|
|
166
166
|
"eslint-plugin-react": "^7.37.2",
|
|
167
|
-
"eslint-plugin-react-hooks": "^
|
|
167
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
168
168
|
"globals": "^15.9.0",
|
|
169
169
|
"happy-dom": "^21.0.4",
|
|
170
170
|
"husky": "^9.1.7",
|
|
171
171
|
"ioredis-mock": "^8.9.0",
|
|
172
|
-
"jsdom": "^29.1.1",
|
|
173
172
|
"miniflare": "4.20260730.0",
|
|
174
|
-
"prettier": "^3.
|
|
175
|
-
"react": "19.3.
|
|
176
|
-
"react-dom": "19.3.
|
|
177
|
-
"react-server-dom-webpack": "19.3.0-canary-bd6ea412-20260824",
|
|
173
|
+
"prettier": "^3.10.1",
|
|
174
|
+
"react": "19.3.1",
|
|
175
|
+
"react-dom": "19.3.1",
|
|
178
176
|
"rimraf": "^6.1.4",
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
177
|
+
"sass-embedded": "^1.108.2",
|
|
178
|
+
"semantic-release": "25.0.9",
|
|
179
|
+
"tsc-alias": "^1.9.10",
|
|
180
|
+
"undici": "8.12.4",
|
|
183
181
|
"vite": "8.1.6",
|
|
184
182
|
"vitest": "^4.1.12"
|
|
185
183
|
},
|
|
@@ -196,7 +194,7 @@
|
|
|
196
194
|
"undici@7": "7.30.2",
|
|
197
195
|
"js-yaml@4": "4.3.2",
|
|
198
196
|
"form-data@4": "4.0.6",
|
|
199
|
-
"@typescript-eslint/typescript-estree
|
|
197
|
+
"@typescript-eslint/typescript-estree>minimatch": "11.0.5"
|
|
200
198
|
}
|
|
201
199
|
}
|
|
202
200
|
}
|
|
@@ -211,6 +211,7 @@ function createEndpointAnalyticsClient(
|
|
|
211
211
|
},
|
|
212
212
|
getUser
|
|
213
213
|
);
|
|
214
|
+
if (!base) return null;
|
|
214
215
|
|
|
215
216
|
return {
|
|
216
217
|
track(name, properties, trackOptions) {
|
|
@@ -278,6 +279,7 @@ function createEndpointErrorReporter(
|
|
|
278
279
|
},
|
|
279
280
|
getUser
|
|
280
281
|
);
|
|
282
|
+
if (!base) return null;
|
|
281
283
|
|
|
282
284
|
const captureException = (error: unknown, context: TelemetryCaptureOptions = {}) => {
|
|
283
285
|
const normalized = normalizeError(error);
|
|
@@ -375,6 +377,8 @@ function createEndpointQueue(
|
|
|
375
377
|
const queue: FallbackPayload[] = [];
|
|
376
378
|
const sessionId = readOrCreateBrowserId(`${baseOptions.key}_session`);
|
|
377
379
|
const anonymousId = readOrCreateBrowserId(`${baseOptions.key}_anonymous`);
|
|
380
|
+
// Telemetry is optional: fail closed for identifiers without blocking client hydration.
|
|
381
|
+
if (!sessionId || !anonymousId) return null;
|
|
378
382
|
let timer: number | null = null;
|
|
379
383
|
let retryTimer: number | null = null;
|
|
380
384
|
let inFlight = false;
|
|
@@ -414,9 +418,11 @@ function createEndpointQueue(
|
|
|
414
418
|
const enqueue = (payload: FallbackPayload) => {
|
|
415
419
|
if (baseOptions.sampleRate <= 0) return;
|
|
416
420
|
if (baseOptions.sampleRate < 1 && Math.random() > baseOptions.sampleRate) return;
|
|
421
|
+
const id = createId(baseOptions.key.includes('errors') ? 'err' : 'evt');
|
|
422
|
+
if (!id) return;
|
|
417
423
|
|
|
418
424
|
queue.push({
|
|
419
|
-
id
|
|
425
|
+
id,
|
|
420
426
|
app: options.app,
|
|
421
427
|
ts: Date.now(),
|
|
422
428
|
release: options.release,
|
|
@@ -486,7 +492,7 @@ function createEndpointQueue(
|
|
|
486
492
|
}
|
|
487
493
|
|
|
488
494
|
function installFallbackWebVitals(
|
|
489
|
-
base: ReturnType<typeof createEndpointQueue
|
|
495
|
+
base: NonNullable<ReturnType<typeof createEndpointQueue>>,
|
|
490
496
|
includeQueryString?: boolean
|
|
491
497
|
): () => void {
|
|
492
498
|
if (!isBrowser() || typeof PerformanceObserver === 'undefined') return () => {};
|
|
@@ -569,8 +575,7 @@ function installFallbackWebVitals(
|
|
|
569
575
|
};
|
|
570
576
|
|
|
571
577
|
const nav = performance.getEntriesByType('navigation')[0] as
|
|
572
|
-
|
|
|
573
|
-
| undefined;
|
|
578
|
+
PerformanceNavigationTiming | undefined;
|
|
574
579
|
if (nav) {
|
|
575
580
|
base.enqueue({
|
|
576
581
|
name: 'web_vital',
|
|
@@ -678,8 +683,7 @@ function currentRoute(): string | undefined {
|
|
|
678
683
|
function currentNavigationType(): string | undefined {
|
|
679
684
|
if (!isBrowser() || typeof performance.getEntriesByType !== 'function') return undefined;
|
|
680
685
|
const nav = performance.getEntriesByType('navigation')[0] as
|
|
681
|
-
|
|
|
682
|
-
| undefined;
|
|
686
|
+
PerformanceNavigationTiming | undefined;
|
|
683
687
|
return typeof nav?.type === 'string' ? nav.type : undefined;
|
|
684
688
|
}
|
|
685
689
|
|
|
@@ -762,21 +766,33 @@ function isBrowser(): boolean {
|
|
|
762
766
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
763
767
|
}
|
|
764
768
|
|
|
765
|
-
function createId(prefix:
|
|
766
|
-
|
|
769
|
+
function createId(prefix: 'runtime' | 'evt' | 'err'): string | null {
|
|
770
|
+
try {
|
|
771
|
+
if (typeof globalThis.crypto?.getRandomValues !== 'function') return null;
|
|
772
|
+
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
|
773
|
+
return `${prefix}_${Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('')}`;
|
|
774
|
+
} catch {
|
|
775
|
+
return null;
|
|
776
|
+
}
|
|
767
777
|
}
|
|
768
778
|
|
|
769
|
-
function readOrCreateBrowserId(key: string): string {
|
|
779
|
+
function readOrCreateBrowserId(key: string): string | null {
|
|
770
780
|
if (!isBrowser()) return createId('runtime');
|
|
771
781
|
try {
|
|
772
782
|
const existing = window.localStorage.getItem(key);
|
|
773
|
-
|
|
774
|
-
|
|
783
|
+
// Older timestamp/Math.random identifiers must not retain the weak generator's output.
|
|
784
|
+
if (existing && /^runtime_[0-9a-f]{32}$/.test(existing)) return existing;
|
|
785
|
+
} catch {
|
|
786
|
+
// Storage can be unavailable in privacy modes; use an ephemeral secure identifier.
|
|
787
|
+
}
|
|
788
|
+
const next = createId('runtime');
|
|
789
|
+
if (!next) return null;
|
|
790
|
+
try {
|
|
775
791
|
window.localStorage.setItem(key, next);
|
|
776
|
-
return next;
|
|
777
792
|
} catch {
|
|
778
|
-
|
|
793
|
+
// Persisting an identifier is optional and must not affect event delivery.
|
|
779
794
|
}
|
|
795
|
+
return next;
|
|
780
796
|
}
|
|
781
797
|
|
|
782
798
|
/** 解析 ignoreSourcePatterns 选项 —— false 关闭过滤;数组与默认合并;缺省走默认。 */
|
|
@@ -154,9 +154,9 @@ export interface ServerEntryModule {
|
|
|
154
154
|
fetch: (request: Request) => Promise<Response>;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
/**
|
|
157
|
+
/** Node 24 and supported edge runtimes expose the Web Crypto UUID generator. */
|
|
158
158
|
function genTraceId(): string {
|
|
159
|
-
return `t-${
|
|
159
|
+
return `t-${crypto.randomUUID()}`;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
export function defineServerEntry<C extends ServerCtx = ServerCtx>(
|
|
@@ -905,7 +905,10 @@ function createServerErrorEndpointReporter(
|
|
|
905
905
|
const includeQueryString = config.includeQueryString === true;
|
|
906
906
|
|
|
907
907
|
return (err, req, errorCtx) => {
|
|
908
|
+
const id = createServerReportId();
|
|
909
|
+
if (!id) return;
|
|
908
910
|
const report = normalizeServerErrorReport(err, req, errorCtx, {
|
|
911
|
+
id,
|
|
909
912
|
release,
|
|
910
913
|
environment,
|
|
911
914
|
includeQueryString,
|
|
@@ -934,6 +937,7 @@ function normalizeServerErrorReport(
|
|
|
934
937
|
req: Request,
|
|
935
938
|
ctx: { traceId: string; locale?: string },
|
|
936
939
|
options: {
|
|
940
|
+
id: string;
|
|
937
941
|
release?: string;
|
|
938
942
|
environment?: string;
|
|
939
943
|
includeQueryString?: boolean;
|
|
@@ -945,7 +949,7 @@ function normalizeServerErrorReport(
|
|
|
945
949
|
const url = safeRequestPath(req.url, options.includeQueryString);
|
|
946
950
|
|
|
947
951
|
return {
|
|
948
|
-
id:
|
|
952
|
+
id: options.id,
|
|
949
953
|
ts: Date.now(),
|
|
950
954
|
level: 'error',
|
|
951
955
|
message,
|
|
@@ -976,12 +980,13 @@ function safeRequestPath(rawUrl: string, includeQueryString?: boolean): string {
|
|
|
976
980
|
}
|
|
977
981
|
}
|
|
978
982
|
|
|
979
|
-
function createServerReportId(): string {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
983
|
+
function createServerReportId(): string | null {
|
|
984
|
+
try {
|
|
985
|
+
return `srv_${crypto.randomUUID()}`;
|
|
986
|
+
} catch {
|
|
987
|
+
// Optional reporting must not weaken IDs or interrupt rendering without Web Crypto.
|
|
988
|
+
return null;
|
|
989
|
+
}
|
|
985
990
|
}
|
|
986
991
|
|
|
987
992
|
async function fetchJsonWithTimeout<T>(url: string, timeoutMs = 1200): Promise<T | null> {
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as ReactDOM from 'react-dom';
|
|
2
2
|
|
|
3
|
-
const PINNED_REACT_DOM_VERSION = '19.3.
|
|
3
|
+
const PINNED_REACT_DOM_VERSION = '19.3.1';
|
|
4
4
|
|
|
5
5
|
interface ReactDomResourceDispatcher {
|
|
6
6
|
S(href: string, precedence: string | undefined, options?: { media?: string }): void;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export type DevStyleResourcePrecedence =
|
|
10
|
-
|
|
11
|
-
| 'vite-rsc/importer-resources';
|
|
10
|
+
'vite-rsc/client-reference' | 'vite-rsc/importer-resources';
|
|
12
11
|
|
|
13
12
|
interface PinnedReactDomModule {
|
|
14
13
|
version: string;
|
package/src/types/ISRConfig.ts
CHANGED
|
@@ -248,8 +248,7 @@ export interface RuntimeTelemetryOtelExporterConfig {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
export type RuntimeTelemetryExporterConfig =
|
|
251
|
-
|
|
|
252
|
-
| RuntimeTelemetryOtelExporterConfig;
|
|
251
|
+
RuntimeTelemetryDatadogExporterConfig | RuntimeTelemetryOtelExporterConfig;
|
|
253
252
|
|
|
254
253
|
export interface RuntimeTelemetryIntegrationsConfig {
|
|
255
254
|
/**
|
|
@@ -385,11 +384,24 @@ export const FallbackChain: Record<RenderModeType, InternalStrategyType[]> = {
|
|
|
385
384
|
// 主配置接口
|
|
386
385
|
/** Express-compatible policy for determining whether a remote proxy is trusted. */
|
|
387
386
|
export type ProxyTrustPolicy =
|
|
388
|
-
| boolean
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
boolean | number | string | string[] | ((address: string, hop: number) => boolean);
|
|
388
|
+
|
|
389
|
+
/** Positive, per-process admission budgets for engine-owned expensive request work. */
|
|
390
|
+
export interface RequestLimitPolicy {
|
|
391
|
+
windowMs?: number;
|
|
392
|
+
/** Maximum requests from one IPv4 address or IPv6 /56 per window. */
|
|
393
|
+
maxRequests?: number;
|
|
394
|
+
/** Maximum aggregate requests per window, including rejected client attempts. */
|
|
395
|
+
globalMaxRequests?: number;
|
|
396
|
+
/** Maximum live client counters; new clients receive 429 when this capacity is full. */
|
|
397
|
+
maxClients?: number;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface RequestLimitsConfig {
|
|
401
|
+
ops?: RequestLimitPolicy;
|
|
402
|
+
staticHtml?: RequestLimitPolicy;
|
|
403
|
+
seo?: RequestLimitPolicy;
|
|
404
|
+
}
|
|
393
405
|
|
|
394
406
|
export interface ISRConfig {
|
|
395
407
|
/** 全局默认渲染模式 */
|
|
@@ -446,6 +458,8 @@ export interface ISRConfig {
|
|
|
446
458
|
* Hop counts/true require an ingress that overwrites client forwarded headers.
|
|
447
459
|
*/
|
|
448
460
|
trustProxy?: ProxyTrustPolicy;
|
|
461
|
+
/** Engine ops, indexed static HTML reads and SEO admission. Page cache hits/APIs are separate. */
|
|
462
|
+
requestLimits?: RequestLimitsConfig;
|
|
449
463
|
/** Node origin 监听端口;缺省 3000。 */
|
|
450
464
|
port: number;
|
|
451
465
|
/** Node origin 监听地址;通常本地留空,容器/内网按部署平台注入。 */
|
package/src/utils/cookie.ts
CHANGED
|
@@ -30,8 +30,7 @@ export function readCookie(source: CookieHeaderSource, name: string): string | u
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function parseCookieHeader(header: string): Record<string, string> {
|
|
33
|
-
const
|
|
34
|
-
if (!header) return cookies;
|
|
33
|
+
const entries = new Map<string, string>();
|
|
35
34
|
|
|
36
35
|
for (const part of header.split(';')) {
|
|
37
36
|
const trimmed = part.trim();
|
|
@@ -44,9 +43,12 @@ export function parseCookieHeader(header: string): Record<string, string> {
|
|
|
44
43
|
if (!key) continue;
|
|
45
44
|
|
|
46
45
|
const rawValue = trimmed.slice(index + 1).trim();
|
|
47
|
-
|
|
46
|
+
entries.set(key, safeDecodeCookieValue(rawValue));
|
|
48
47
|
}
|
|
49
48
|
|
|
49
|
+
// fromEntries creates own data properties, including __proto__, without invoking setters.
|
|
50
|
+
const cookies = Object.fromEntries(entries);
|
|
51
|
+
Object.setPrototypeOf(cookies, null);
|
|
50
52
|
return cookies;
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -3,9 +3,7 @@ import type { FetchHandler } from '../ssg/spider';
|
|
|
3
3
|
/** Resolve the built RSC module once, retaining the selected export's receiver. */
|
|
4
4
|
export function resolveFetchHandler(module: unknown): FetchHandler {
|
|
5
5
|
const mod = module as
|
|
6
|
-
|
|
7
|
-
| null
|
|
8
|
-
| undefined;
|
|
6
|
+
{ default?: { fetch?: unknown } | null; fetch?: unknown } | null | undefined;
|
|
9
7
|
const defaultOwner = mod?.default;
|
|
10
8
|
const defaultFetch = defaultOwner?.fetch;
|
|
11
9
|
if (typeof defaultFetch === 'function') {
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
-
//#region src/context/RequestContext.ts
|
|
4
|
-
var RequestContext_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
-
getAnonId: () => getAnonId,
|
|
6
|
-
getExperiments: () => getExperiments,
|
|
7
|
-
getRequestContext: () => getRequestContext,
|
|
8
|
-
getRequestId: () => getRequestId,
|
|
9
|
-
getTraceId: () => getTraceId,
|
|
10
|
-
getUserId: () => getUserId,
|
|
11
|
-
requestContext: () => requestContext
|
|
12
|
-
});
|
|
13
|
-
var REQUEST_CONTEXT_KEY = "__ISR_ENGINE_REQUEST_CONTEXT__";
|
|
14
|
-
function getGlobalRequestContext() {
|
|
15
|
-
const globalState = globalThis;
|
|
16
|
-
globalState[REQUEST_CONTEXT_KEY] ??= new AsyncLocalStorage();
|
|
17
|
-
return globalState[REQUEST_CONTEXT_KEY];
|
|
18
|
-
}
|
|
19
|
-
var requestContext = getGlobalRequestContext();
|
|
20
|
-
var getRequestContext = () => {
|
|
21
|
-
return requestContext.getStore();
|
|
22
|
-
};
|
|
23
|
-
var getTraceId = () => {
|
|
24
|
-
return requestContext.getStore()?.traceId || "system";
|
|
25
|
-
};
|
|
26
|
-
var getRequestId = () => {
|
|
27
|
-
return requestContext.getStore()?.requestId || "unknown";
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 获取 anonId —— 浏览器 / 设备维度稳定 UUID。
|
|
31
|
-
*
|
|
32
|
-
* engine 入口 createServerRequestContext 已保证 RequestContext 存在时这个字段必有值
|
|
33
|
-
* (cookie 缺失会自动生成);context 不在时(极少数 dev / unit-test 场景)返回 'system'。
|
|
34
|
-
* 业务侧用法:feature gating、telemetry user 维度聚合、个性化推荐 anchor。
|
|
35
|
-
*/
|
|
36
|
-
var getAnonId = () => {
|
|
37
|
-
return requestContext.getStore()?.anonId || "system";
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* 获取已登录用户 ID。业务侧 beforeRequest hook 解 session 写入;未登录返回 null。
|
|
41
|
-
* 注意:不要把这里返回的字符串当 anonId 用 —— anonId 跨登录态稳定(一个浏览器永远
|
|
42
|
-
* 同一份),userId 跨设备稳定但匿名期为 null。两者职责不同。
|
|
43
|
-
*/
|
|
44
|
-
var getUserId = () => {
|
|
45
|
-
return requestContext.getStore()?.userId ?? null;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* 获取本次请求生效的全部实验变体 —— `{ 'hero-style': 'bold', ... }`。
|
|
49
|
-
* 由 ABVariantMiddleware 基于 hash(anonId + expKey) 确定性算出,不在 cookie 里持久化。
|
|
50
|
-
* 没接 ABVariantMiddleware 时返回空对象。
|
|
51
|
-
*/
|
|
52
|
-
var getExperiments = () => {
|
|
53
|
-
return requestContext.getStore()?.experiments ?? {};
|
|
54
|
-
};
|
|
55
|
-
//#endregion
|
|
56
|
-
export { getRequestId as a, requestContext as c, getRequestContext as i, getAnonId as n, getTraceId as o, getExperiments as r, getUserId as s, RequestContext_exports as t };
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=RequestContext-BVQ-rOmV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestContext-BVQ-rOmV.js","names":[],"sources":["../src/context/RequestContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'async_hooks';\nimport type { ISRContextData } from '../types/ISRContext';\n\n// 复用 ISRContextData 类型,确保 ALS 中的数据结构与 ISRContext.data 一致\nexport type RequestContextState = ISRContextData;\n\nconst REQUEST_CONTEXT_KEY = '__ISR_ENGINE_REQUEST_CONTEXT__';\n\nfunction getGlobalRequestContext(): AsyncLocalStorage<RequestContextState> {\n const globalState = globalThis as typeof globalThis & {\n [REQUEST_CONTEXT_KEY]?: AsyncLocalStorage<RequestContextState>;\n };\n\n globalState[REQUEST_CONTEXT_KEY] ??= new AsyncLocalStorage<RequestContextState>();\n return globalState[REQUEST_CONTEXT_KEY];\n}\n\n// 全局 ALS 实例。dev 下 source/dist 可能同时被 Vite 加载,必须共享同一份请求上下文。\nexport const requestContext = getGlobalRequestContext();\n\n// 获取当前请求上下文的辅助函数\nexport const getRequestContext = (): RequestContextState | undefined => {\n return requestContext.getStore();\n};\n\n// 获取 Trace ID 的辅助函数 (安全访问)\nexport const getTraceId = (): string => {\n const store = requestContext.getStore();\n return store?.traceId || 'system';\n};\n\n// 获取 Request ID 的辅助函数 (安全访问)\nexport const getRequestId = (): string => {\n const store = requestContext.getStore();\n return store?.requestId || 'unknown';\n};\n\n/**\n * 获取 anonId —— 浏览器 / 设备维度稳定 UUID。\n *\n * engine 入口 createServerRequestContext 已保证 RequestContext 存在时这个字段必有值\n * (cookie 缺失会自动生成);context 不在时(极少数 dev / unit-test 场景)返回 'system'。\n * 业务侧用法:feature gating、telemetry user 维度聚合、个性化推荐 anchor。\n */\nexport const getAnonId = (): string => {\n const store = requestContext.getStore();\n return store?.anonId || 'system';\n};\n\n/**\n * 获取已登录用户 ID。业务侧 beforeRequest hook 解 session 写入;未登录返回 null。\n * 注意:不要把这里返回的字符串当 anonId 用 —— anonId 跨登录态稳定(一个浏览器永远\n * 同一份),userId 跨设备稳定但匿名期为 null。两者职责不同。\n */\nexport const getUserId = (): string | null => {\n const store = requestContext.getStore();\n return store?.userId ?? null;\n};\n\n/**\n * 获取本次请求生效的全部实验变体 —— `{ 'hero-style': 'bold', ... }`。\n * 由 ABVariantMiddleware 基于 hash(anonId + expKey) 确定性算出,不在 cookie 里持久化。\n * 没接 ABVariantMiddleware 时返回空对象。\n */\nexport const getExperiments = (): Record<string, string> => {\n const store = requestContext.getStore();\n return store?.experiments ?? {};\n};\n"],"mappings":";;;;;;;;;;;;AAMA,IAAM,sBAAsB;AAE5B,SAAS,0BAAkE;CACzE,MAAM,cAAc;CAIpB,YAAY,yBAAyB,IAAI,kBAAuC;CAChF,OAAO,YAAY;AACrB;AAGA,IAAa,iBAAiB,wBAAwB;AAGtD,IAAa,0BAA2D;CACtE,OAAO,eAAe,SAAS;AACjC;AAGA,IAAa,mBAA2B;CAEtC,OADc,eAAe,SACtB,CAAA,EAAO,WAAW;AAC3B;AAGA,IAAa,qBAA6B;CAExC,OADc,eAAe,SACtB,CAAA,EAAO,aAAa;AAC7B;;;;;;;;AASA,IAAa,kBAA0B;CAErC,OADc,eAAe,SACtB,CAAA,EAAO,UAAU;AAC1B;;;;;;AAOA,IAAa,kBAAiC;CAE5C,OADc,eAAe,SACtB,CAAA,EAAO,UAAU;AAC1B;;;;;;AAOA,IAAa,uBAA+C;CAE1D,OADc,eAAe,SACtB,CAAA,EAAO,eAAe,CAAC;AAChC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
|
|
2
|
-
let async_hooks = require("async_hooks");
|
|
3
|
-
//#region src/context/RequestContext.ts
|
|
4
|
-
var RequestContext_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
5
|
-
getAnonId: () => getAnonId,
|
|
6
|
-
getExperiments: () => getExperiments,
|
|
7
|
-
getRequestContext: () => getRequestContext,
|
|
8
|
-
getRequestId: () => getRequestId,
|
|
9
|
-
getTraceId: () => getTraceId,
|
|
10
|
-
getUserId: () => getUserId,
|
|
11
|
-
requestContext: () => requestContext
|
|
12
|
-
});
|
|
13
|
-
var REQUEST_CONTEXT_KEY = "__ISR_ENGINE_REQUEST_CONTEXT__";
|
|
14
|
-
function getGlobalRequestContext() {
|
|
15
|
-
const globalState = globalThis;
|
|
16
|
-
globalState[REQUEST_CONTEXT_KEY] ??= new async_hooks.AsyncLocalStorage();
|
|
17
|
-
return globalState[REQUEST_CONTEXT_KEY];
|
|
18
|
-
}
|
|
19
|
-
var requestContext = getGlobalRequestContext();
|
|
20
|
-
var getRequestContext = () => {
|
|
21
|
-
return requestContext.getStore();
|
|
22
|
-
};
|
|
23
|
-
var getTraceId = () => {
|
|
24
|
-
return requestContext.getStore()?.traceId || "system";
|
|
25
|
-
};
|
|
26
|
-
var getRequestId = () => {
|
|
27
|
-
return requestContext.getStore()?.requestId || "unknown";
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* 获取 anonId —— 浏览器 / 设备维度稳定 UUID。
|
|
31
|
-
*
|
|
32
|
-
* engine 入口 createServerRequestContext 已保证 RequestContext 存在时这个字段必有值
|
|
33
|
-
* (cookie 缺失会自动生成);context 不在时(极少数 dev / unit-test 场景)返回 'system'。
|
|
34
|
-
* 业务侧用法:feature gating、telemetry user 维度聚合、个性化推荐 anchor。
|
|
35
|
-
*/
|
|
36
|
-
var getAnonId = () => {
|
|
37
|
-
return requestContext.getStore()?.anonId || "system";
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* 获取已登录用户 ID。业务侧 beforeRequest hook 解 session 写入;未登录返回 null。
|
|
41
|
-
* 注意:不要把这里返回的字符串当 anonId 用 —— anonId 跨登录态稳定(一个浏览器永远
|
|
42
|
-
* 同一份),userId 跨设备稳定但匿名期为 null。两者职责不同。
|
|
43
|
-
*/
|
|
44
|
-
var getUserId = () => {
|
|
45
|
-
return requestContext.getStore()?.userId ?? null;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* 获取本次请求生效的全部实验变体 —— `{ 'hero-style': 'bold', ... }`。
|
|
49
|
-
* 由 ABVariantMiddleware 基于 hash(anonId + expKey) 确定性算出,不在 cookie 里持久化。
|
|
50
|
-
* 没接 ABVariantMiddleware 时返回空对象。
|
|
51
|
-
*/
|
|
52
|
-
var getExperiments = () => {
|
|
53
|
-
return requestContext.getStore()?.experiments ?? {};
|
|
54
|
-
};
|
|
55
|
-
//#endregion
|
|
56
|
-
Object.defineProperty(exports, "RequestContext_exports", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function() {
|
|
59
|
-
return RequestContext_exports;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, "getAnonId", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function() {
|
|
65
|
-
return getAnonId;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, "getExperiments", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function() {
|
|
71
|
-
return getExperiments;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, "getRequestContext", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function() {
|
|
77
|
-
return getRequestContext;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(exports, "getRequestId", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function() {
|
|
83
|
-
return getRequestId;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(exports, "getTraceId", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: function() {
|
|
89
|
-
return getTraceId;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, "getUserId", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function() {
|
|
95
|
-
return getUserId;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, "requestContext", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function() {
|
|
101
|
-
return requestContext;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=RequestContext-DgGEAxcW.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestContext-DgGEAxcW.cjs","names":[],"sources":["../src/context/RequestContext.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'async_hooks';\nimport type { ISRContextData } from '../types/ISRContext';\n\n// 复用 ISRContextData 类型,确保 ALS 中的数据结构与 ISRContext.data 一致\nexport type RequestContextState = ISRContextData;\n\nconst REQUEST_CONTEXT_KEY = '__ISR_ENGINE_REQUEST_CONTEXT__';\n\nfunction getGlobalRequestContext(): AsyncLocalStorage<RequestContextState> {\n const globalState = globalThis as typeof globalThis & {\n [REQUEST_CONTEXT_KEY]?: AsyncLocalStorage<RequestContextState>;\n };\n\n globalState[REQUEST_CONTEXT_KEY] ??= new AsyncLocalStorage<RequestContextState>();\n return globalState[REQUEST_CONTEXT_KEY];\n}\n\n// 全局 ALS 实例。dev 下 source/dist 可能同时被 Vite 加载,必须共享同一份请求上下文。\nexport const requestContext = getGlobalRequestContext();\n\n// 获取当前请求上下文的辅助函数\nexport const getRequestContext = (): RequestContextState | undefined => {\n return requestContext.getStore();\n};\n\n// 获取 Trace ID 的辅助函数 (安全访问)\nexport const getTraceId = (): string => {\n const store = requestContext.getStore();\n return store?.traceId || 'system';\n};\n\n// 获取 Request ID 的辅助函数 (安全访问)\nexport const getRequestId = (): string => {\n const store = requestContext.getStore();\n return store?.requestId || 'unknown';\n};\n\n/**\n * 获取 anonId —— 浏览器 / 设备维度稳定 UUID。\n *\n * engine 入口 createServerRequestContext 已保证 RequestContext 存在时这个字段必有值\n * (cookie 缺失会自动生成);context 不在时(极少数 dev / unit-test 场景)返回 'system'。\n * 业务侧用法:feature gating、telemetry user 维度聚合、个性化推荐 anchor。\n */\nexport const getAnonId = (): string => {\n const store = requestContext.getStore();\n return store?.anonId || 'system';\n};\n\n/**\n * 获取已登录用户 ID。业务侧 beforeRequest hook 解 session 写入;未登录返回 null。\n * 注意:不要把这里返回的字符串当 anonId 用 —— anonId 跨登录态稳定(一个浏览器永远\n * 同一份),userId 跨设备稳定但匿名期为 null。两者职责不同。\n */\nexport const getUserId = (): string | null => {\n const store = requestContext.getStore();\n return store?.userId ?? null;\n};\n\n/**\n * 获取本次请求生效的全部实验变体 —— `{ 'hero-style': 'bold', ... }`。\n * 由 ABVariantMiddleware 基于 hash(anonId + expKey) 确定性算出,不在 cookie 里持久化。\n * 没接 ABVariantMiddleware 时返回空对象。\n */\nexport const getExperiments = (): Record<string, string> => {\n const store = requestContext.getStore();\n return store?.experiments ?? {};\n};\n"],"mappings":";;;;;;;;;;;;AAMA,IAAM,sBAAsB;AAE5B,SAAS,0BAAkE;CACzE,MAAM,cAAc;CAIpB,YAAY,yBAAyB,IAAI,YAAA,kBAAuC;CAChF,OAAO,YAAY;AACrB;AAGA,IAAa,iBAAiB,wBAAwB;AAGtD,IAAa,0BAA2D;CACtE,OAAO,eAAe,SAAS;AACjC;AAGA,IAAa,mBAA2B;CAEtC,OADc,eAAe,SACtB,CAAA,EAAO,WAAW;AAC3B;AAGA,IAAa,qBAA6B;CAExC,OADc,eAAe,SACtB,CAAA,EAAO,aAAa;AAC7B;;;;;;;;AASA,IAAa,kBAA0B;CAErC,OADc,eAAe,SACtB,CAAA,EAAO,UAAU;AAC1B;;;;;;AAOA,IAAa,kBAAiC;CAE5C,OADc,eAAe,SACtB,CAAA,EAAO,UAAU;AAC1B;;;;;;AAOA,IAAa,uBAA+C;CAE1D,OADc,eAAe,SACtB,CAAA,EAAO,eAAe,CAAC;AAChC"}
|