isr-engine 3.1.4 → 4.0.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 +3 -3
- package/dist/{abVariantContext-BtLsLN1J.js → abVariantContext-CGBlCt0q.js} +8 -15
- package/dist/abVariantContext-CGBlCt0q.js.map +1 -0
- package/dist/adapters/observability/index.js +4 -8
- package/dist/adapters/observability/index.js.map +1 -1
- package/dist/adapters/runtime/index.js +4 -8
- package/dist/adapters/runtime/index.js.map +1 -1
- package/dist/cli/cli.js +12 -14
- package/dist/cli/cli.js.map +1 -1
- package/dist/config/defineConfig.js +1 -2
- package/dist/{createCacheInspectorMiddleware-Cb_MZhLZ.js → createCacheInspectorMiddleware-BjwSKfyf.js} +2 -3
- package/dist/{createCacheInspectorMiddleware-Cb_MZhLZ.js.map → createCacheInspectorMiddleware-BjwSKfyf.js.map} +1 -1
- package/dist/{createISRApp-rD8EUB--.js → createISRApp-CbDPv6fY.js} +115 -171
- package/dist/createISRApp-CbDPv6fY.js.map +1 -0
- package/dist/defaults/auto-observability.js +1 -2
- package/dist/defaults/runtime/defineSiteHooks.js +2 -2
- package/dist/{defineSiteHooks-BWaDDJ4B.js → defineSiteHooks-DUEds_hB.js} +4 -6
- package/dist/{defineSiteHooks-BWaDDJ4B.js.map → defineSiteHooks-DUEds_hB.js.map} +1 -1
- package/dist/{error500-template-DhaZzLOB.js → error500-template-CFdKp8YG.js} +2 -3
- package/dist/{error500-template-DhaZzLOB.js.map → error500-template-CFdKp8YG.js.map} +1 -1
- package/dist/{i18n-BFCx28rB.js → i18n-CJ0leKhc.js} +4 -7
- package/dist/{i18n-BFCx28rB.js.map → i18n-CJ0leKhc.js.map} +1 -1
- package/dist/image/index.js +1 -2
- package/dist/image/index.js.map +1 -1
- package/dist/isr-engine.js +37 -50
- package/dist/isr-engine.js.map +1 -1
- package/dist/plugin/createDevCssHandoffPlugin.d.ts.map +1 -1
- package/dist/rsc/browser.js +1 -2
- package/dist/rsc/index.js +2 -2
- package/dist/{rsc-Da-Nc0OM.js → rsc-DWwcqD4W.js} +6 -10
- package/dist/rsc-DWwcqD4W.js.map +1 -0
- package/dist/runtime/LocaleContext.d.ts +1 -1
- package/dist/runtime/LocaleContext.d.ts.map +1 -1
- package/dist/runtime/boundary.d.ts +2 -2
- package/dist/runtime/boundary.d.ts.map +1 -1
- package/dist/server/middleware.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/abVariantContext-BtLsLN1J.js.map +0 -1
- package/dist/createISRApp-rD8EUB--.js.map +0 -1
- package/dist/rsc-Da-Nc0OM.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as getTraceId, S as getRequestId, T as requestContext, _ as escapeSupplementalLogControls, a as isUncacheable, f as setRevalidationMetricRecorder, g as encodeSpinnerMessage, h as encodeLogField, l as registerInvalidator, m as setOriginLogger, r as collectTags, s as runWithTagStore, v as snapshotLogArgument, x as getRequestContext } from "./abVariantContext-
|
|
2
|
-
import { o as parseCookieHeader, r as resolveI18nConfig, s as readCookie, t as negotiateLocale } from "./i18n-
|
|
1
|
+
import { C as getTraceId, S as getRequestId, T as requestContext, _ as escapeSupplementalLogControls, a as isUncacheable, f as setRevalidationMetricRecorder, g as encodeSpinnerMessage, h as encodeLogField, l as registerInvalidator, m as setOriginLogger, r as collectTags, s as runWithTagStore, v as snapshotLogArgument, x as getRequestContext } from "./abVariantContext-CGBlCt0q.js";
|
|
2
|
+
import { o as parseCookieHeader, r as resolveI18nConfig, s as readCookie, t as negotiateLocale } from "./i18n-CJ0leKhc.js";
|
|
3
3
|
import fs, { createReadStream, promises } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import express from "express";
|
|
@@ -7,11 +7,9 @@ import { ipKeyGenerator, rateLimit } from "express-rate-limit";
|
|
|
7
7
|
import ipaddr from "ipaddr.js";
|
|
8
8
|
import chalk from "chalk";
|
|
9
9
|
import ora from "ora";
|
|
10
|
-
import * as path$2 from "path";
|
|
11
|
-
import path$1 from "path";
|
|
10
|
+
import path$1, * as path$2 from "path";
|
|
12
11
|
import pino from "pino";
|
|
13
|
-
import * as fs$4 from "fs";
|
|
14
|
-
import fs$1 from "fs";
|
|
12
|
+
import fs$1, * as fs$4 from "fs";
|
|
15
13
|
import fs$2 from "fs/promises";
|
|
16
14
|
import ts from "typescript";
|
|
17
15
|
import net, { isIP } from "node:net";
|
|
@@ -34,7 +32,7 @@ import { request as request$1 } from "node:https";
|
|
|
34
32
|
import { SitemapStream, streamToPromise } from "sitemap";
|
|
35
33
|
import { parse } from "parse5";
|
|
36
34
|
import { createServer as createServer$1 } from "http";
|
|
37
|
-
|
|
35
|
+
// src/config/resolveImageOptions.ts
|
|
38
36
|
/** Shared image policy for the automatic development and production endpoints. */
|
|
39
37
|
function resolveImageOptions(images) {
|
|
40
38
|
const invalid = () => /* @__PURE__ */ new Error("runtime.images must contain only remoteAllowlist: an array of exact host[:port] entries");
|
|
@@ -59,8 +57,7 @@ function resolveImageOptions(images) {
|
|
|
59
57
|
});
|
|
60
58
|
return { remoteAllowlist: [...new Set(hosts)] };
|
|
61
59
|
}
|
|
62
|
-
|
|
63
|
-
//#region src/utils/htmlPathname.ts
|
|
60
|
+
// src/utils/htmlPathname.ts
|
|
64
61
|
/** Shared logical identity for HTML dispatch, aliases and build-time route validation. */
|
|
65
62
|
function decodeHtmlPathname(raw) {
|
|
66
63
|
const pathname = decodeURIComponent(raw);
|
|
@@ -102,8 +99,7 @@ function assertDistinctHtmlRouteIdentities(routes, options = {}) {
|
|
|
102
99
|
owners.set(identity, route);
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
|
-
|
|
106
|
-
//#region src/utils/cacheDuration.ts
|
|
102
|
+
// src/utils/cacheDuration.ts
|
|
107
103
|
/** Cache deadlines must remain finite, positive (or explicitly zero for SWR) timestamps. */
|
|
108
104
|
function assertCacheDuration(seconds, label, allowZero = false) {
|
|
109
105
|
if (typeof seconds !== "number" || !Number.isFinite(seconds) || (allowZero ? seconds < 0 : seconds <= 0) || seconds * 1e3 > Number.MAX_SAFE_INTEGER) throw new RangeError(`${label} must be finite ${allowZero ? "non-negative" : "positive"} seconds within the safe cache window`);
|
|
@@ -121,8 +117,7 @@ function resolveCacheDurations(defaultTtl, overrides = {}, label = "route") {
|
|
|
121
117
|
swrSeconds: swr
|
|
122
118
|
};
|
|
123
119
|
}
|
|
124
|
-
|
|
125
|
-
//#region src/server/requestLimits.ts
|
|
120
|
+
// src/server/requestLimits.ts
|
|
126
121
|
/** Per-process admission budgets for engine-owned work, not page-cache hits or application APIs. */
|
|
127
122
|
var DEFAULT_REQUEST_LIMITS = {
|
|
128
123
|
ops: {
|
|
@@ -303,8 +298,7 @@ function admitRequest(limiter, req, res) {
|
|
|
303
298
|
}
|
|
304
299
|
});
|
|
305
300
|
}
|
|
306
|
-
|
|
307
|
-
//#region src/config/normalizeEngineConfig.ts
|
|
301
|
+
// src/config/normalizeEngineConfig.ts
|
|
308
302
|
/**
|
|
309
303
|
* Engine-owned config normalization.
|
|
310
304
|
*
|
|
@@ -377,8 +371,7 @@ function validateRoutes(routes, defaultTtl) {
|
|
|
377
371
|
function requireOwnProperties(value, keys, label) {
|
|
378
372
|
for (const key of keys) if (!Object.prototype.hasOwnProperty.call(value, key)) throw new Error(`ssr.config.ts 必须显式声明 ${label}.${key}`);
|
|
379
373
|
}
|
|
380
|
-
|
|
381
|
-
//#region src/logger/Logger.ts
|
|
374
|
+
// src/logger/Logger.ts
|
|
382
375
|
var LogLevel = /* @__PURE__ */ function(LogLevel) {
|
|
383
376
|
LogLevel["VERBOSE"] = "verbose";
|
|
384
377
|
LogLevel["DEBUG"] = "debug";
|
|
@@ -543,8 +536,7 @@ var Logger = class Logger {
|
|
|
543
536
|
}
|
|
544
537
|
}
|
|
545
538
|
};
|
|
546
|
-
|
|
547
|
-
//#region src/utils/CacheCleanup.ts
|
|
539
|
+
// src/utils/CacheCleanup.ts
|
|
548
540
|
var logger$9 = Logger.getInstance();
|
|
549
541
|
/**
|
|
550
542
|
* 缓存清理工具类
|
|
@@ -605,8 +597,7 @@ var CacheCleanup = class {
|
|
|
605
597
|
return path$2.resolve(process.cwd(), this.SSG_CACHE_DIR);
|
|
606
598
|
}
|
|
607
599
|
};
|
|
608
|
-
|
|
609
|
-
//#region src/config/getEnv.ts
|
|
600
|
+
// src/config/getEnv.ts
|
|
610
601
|
function getEnv(key, defaultValue) {
|
|
611
602
|
const value = process.env[key];
|
|
612
603
|
if (value === void 0) return defaultValue;
|
|
@@ -616,12 +607,10 @@ function getEnv(key, defaultValue) {
|
|
|
616
607
|
}
|
|
617
608
|
return value;
|
|
618
609
|
}
|
|
619
|
-
|
|
620
|
-
//#region src/config/getStatus.ts
|
|
610
|
+
// src/config/getStatus.ts
|
|
621
611
|
var isDev = () => getEnv("NODE_ENV") !== "production";
|
|
622
612
|
var isProd = () => getEnv("NODE_ENV") === "production";
|
|
623
|
-
|
|
624
|
-
//#region src/discovery/types.ts
|
|
613
|
+
// src/discovery/types.ts
|
|
625
614
|
/**
|
|
626
615
|
* 支持的文件扩展名
|
|
627
616
|
*/
|
|
@@ -631,8 +620,7 @@ var SUPPORTED_EXTENSIONS = [
|
|
|
631
620
|
".ts",
|
|
632
621
|
".js"
|
|
633
622
|
];
|
|
634
|
-
|
|
635
|
-
//#region src/discovery/fileSystem.ts
|
|
623
|
+
// src/discovery/fileSystem.ts
|
|
636
624
|
/**
|
|
637
625
|
* 文件系统工具函数
|
|
638
626
|
* 提供文件遍历、读取等基础能力
|
|
@@ -694,8 +682,7 @@ function isCodeFile(filePath) {
|
|
|
694
682
|
function isTestFile(filePath) {
|
|
695
683
|
return TEST_FILE_PATTERN.test(filePath);
|
|
696
684
|
}
|
|
697
|
-
|
|
698
|
-
//#region src/discovery/routeDiscovery.ts
|
|
685
|
+
// src/discovery/routeDiscovery.ts
|
|
699
686
|
/**
|
|
700
687
|
* 路由发现器
|
|
701
688
|
*
|
|
@@ -865,8 +852,7 @@ function parseRoutes(files, config) {
|
|
|
865
852
|
});
|
|
866
853
|
return routes;
|
|
867
854
|
}
|
|
868
|
-
|
|
869
|
-
//#region src/discovery/directiveParser.ts
|
|
855
|
+
// src/discovery/directiveParser.ts
|
|
870
856
|
/**
|
|
871
857
|
* AST 指令解析器
|
|
872
858
|
* 使用 TypeScript Compiler API 解析 'use client' 和 'use server' 指令
|
|
@@ -1087,8 +1073,7 @@ function hasServerDirective(content) {
|
|
|
1087
1073
|
const result = parseDirective(content);
|
|
1088
1074
|
return result.directive === "use server" && result.isValidPosition;
|
|
1089
1075
|
}
|
|
1090
|
-
|
|
1091
|
-
//#region src/discovery/exportParser.ts
|
|
1076
|
+
// src/discovery/exportParser.ts
|
|
1092
1077
|
/**
|
|
1093
1078
|
* AST 导出解析器
|
|
1094
1079
|
* 使用 TypeScript Compiler API 解析模块导出
|
|
@@ -1207,8 +1192,7 @@ function getExportNames(content) {
|
|
|
1207
1192
|
for (const exp of result.exports) if (!exp.isType && exp.name !== "*") names.push(exp.name);
|
|
1208
1193
|
return [...new Set(names)];
|
|
1209
1194
|
}
|
|
1210
|
-
|
|
1211
|
-
//#region src/discovery/componentDiscovery.ts
|
|
1195
|
+
// src/discovery/componentDiscovery.ts
|
|
1212
1196
|
/**
|
|
1213
1197
|
* 组件发现器
|
|
1214
1198
|
*
|
|
@@ -1258,8 +1242,7 @@ function parseComponentFromFile(fileInfo) {
|
|
|
1258
1242
|
function parseComponents(files) {
|
|
1259
1243
|
return files.map(parseComponentFromFile);
|
|
1260
1244
|
}
|
|
1261
|
-
|
|
1262
|
-
//#region src/discovery/scan.ts
|
|
1245
|
+
// src/discovery/scan.ts
|
|
1263
1246
|
/**
|
|
1264
1247
|
* 目录扫描器 —— 轻量文件发现(用于 engine 启动日志 / sitemap 路由枚举)
|
|
1265
1248
|
*
|
|
@@ -1355,8 +1338,7 @@ async function scanRoutes(projectRoot, config = {}) {
|
|
|
1355
1338
|
async function scanComponents(projectRoot, componentDirs = ["src/components"]) {
|
|
1356
1339
|
return parseComponents(await collectComponentsWithContent(projectRoot, componentDirs, true, 50));
|
|
1357
1340
|
}
|
|
1358
|
-
|
|
1359
|
-
//#region src/server/viteDevServer.ts
|
|
1341
|
+
// src/server/viteDevServer.ts
|
|
1360
1342
|
/**
|
|
1361
1343
|
* Vite 开发服务器管理(plugin-rsc 模式)
|
|
1362
1344
|
*
|
|
@@ -1392,10 +1374,11 @@ async function resolveHmrPort(preferredPort, host) {
|
|
|
1392
1374
|
async function createViteDevServer() {
|
|
1393
1375
|
const logger = Logger.getInstance();
|
|
1394
1376
|
if (viteServer) return viteServer;
|
|
1377
|
+
const projectRoot = process.cwd();
|
|
1395
1378
|
const loadResult = await loadConfigFromFile({
|
|
1396
1379
|
command: "serve",
|
|
1397
1380
|
mode: "development"
|
|
1398
|
-
}, void 0,
|
|
1381
|
+
}, void 0, projectRoot);
|
|
1399
1382
|
const userHmr = loadResult?.config?.server?.hmr;
|
|
1400
1383
|
const hmrDisabled = userHmr === false;
|
|
1401
1384
|
const userHmrOptions = typeof userHmr === "object" ? userHmr : {};
|
|
@@ -1420,13 +1403,14 @@ async function createViteDevServer() {
|
|
|
1420
1403
|
const userSsrNoExternal = userConfig.ssr?.noExternal;
|
|
1421
1404
|
const ssrNoExternal = Array.isArray(userSsrNoExternal) ? [...userSsrNoExternal] : userSsrNoExternal ? [userSsrNoExternal] : [];
|
|
1422
1405
|
if (!ssrNoExternal.includes("isr-engine")) ssrNoExternal.push("isr-engine");
|
|
1423
|
-
|
|
1406
|
+
const finalConfig = mergeConfig(userConfig, {
|
|
1424
1407
|
...engineOverrides,
|
|
1425
1408
|
ssr: {
|
|
1426
1409
|
...userConfig.ssr,
|
|
1427
1410
|
noExternal: ssrNoExternal
|
|
1428
1411
|
}
|
|
1429
|
-
})
|
|
1412
|
+
});
|
|
1413
|
+
viteServer = await createServer(finalConfig);
|
|
1430
1414
|
} else {
|
|
1431
1415
|
logger.warn("未找到 vite.config.ts —— 消费者必须在项目根下提供配置,否则 RSC 不工作");
|
|
1432
1416
|
viteServer = await createServer({
|
|
@@ -1447,8 +1431,7 @@ async function closeViteDevServer() {
|
|
|
1447
1431
|
viteServer = null;
|
|
1448
1432
|
}
|
|
1449
1433
|
}
|
|
1450
|
-
|
|
1451
|
-
//#region src/server/middleware.ts
|
|
1434
|
+
// src/server/middleware.ts
|
|
1452
1435
|
/**
|
|
1453
1436
|
* 中间件配置
|
|
1454
1437
|
* 提供通用中间件和开发/生产环境特定中间件
|
|
@@ -1569,29 +1552,33 @@ var PROD_CSP_BASE = {
|
|
|
1569
1552
|
* 必须在前面挂 createCspNonceMiddleware 才能让 res.locals.cspNonce 存在。
|
|
1570
1553
|
*/
|
|
1571
1554
|
function createSecurityMiddleware(isDev, extraConnectSrc = []) {
|
|
1572
|
-
if (isDev)
|
|
1573
|
-
|
|
1555
|
+
if (isDev) {
|
|
1556
|
+
const directives = {
|
|
1574
1557
|
...DEV_CSP,
|
|
1575
1558
|
connectSrc: [...DEV_CSP.connectSrc, ...extraConnectSrc]
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
|
|
1559
|
+
};
|
|
1560
|
+
return helmet({
|
|
1561
|
+
contentSecurityPolicy: { directives },
|
|
1562
|
+
strictTransportSecurity: false
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1579
1565
|
const nonceFn = (_req, res) => {
|
|
1580
1566
|
const nonce = res.locals?.[CSP_NONCE_LOCAL];
|
|
1581
1567
|
return typeof nonce === "string" ? `'nonce-${nonce}'` : "'self'";
|
|
1582
1568
|
};
|
|
1569
|
+
const directives = {
|
|
1570
|
+
...PROD_CSP_BASE,
|
|
1571
|
+
connectSrc: [...PROD_CSP_BASE.connectSrc, ...extraConnectSrc],
|
|
1572
|
+
scriptSrc: [
|
|
1573
|
+
"'self'",
|
|
1574
|
+
nonceFn,
|
|
1575
|
+
"'strict-dynamic'",
|
|
1576
|
+
"'unsafe-inline'"
|
|
1577
|
+
]
|
|
1578
|
+
};
|
|
1583
1579
|
return helmet({
|
|
1584
|
-
contentSecurityPolicy: { directives
|
|
1585
|
-
|
|
1586
|
-
connectSrc: [...PROD_CSP_BASE.connectSrc, ...extraConnectSrc],
|
|
1587
|
-
scriptSrc: [
|
|
1588
|
-
"'self'",
|
|
1589
|
-
nonceFn,
|
|
1590
|
-
"'strict-dynamic'",
|
|
1591
|
-
"'unsafe-inline'"
|
|
1592
|
-
]
|
|
1593
|
-
} },
|
|
1594
|
-
strictTransportSecurity: void 0
|
|
1580
|
+
contentSecurityPolicy: { directives },
|
|
1581
|
+
strictTransportSecurity: { maxAge: 15552e3 }
|
|
1595
1582
|
});
|
|
1596
1583
|
}
|
|
1597
1584
|
/**
|
|
@@ -1654,8 +1641,7 @@ function mountViteOrStatic(ctx) {
|
|
|
1654
1641
|
if (isDev && viteDevMiddleware) requestHandler.use(viteDevMiddleware.middlewares);
|
|
1655
1642
|
else if (!isDev) requestHandler.use(createStaticMiddleware("./dist/client"));
|
|
1656
1643
|
}
|
|
1657
|
-
|
|
1658
|
-
//#region src/utils/resolveFetchHandler.ts
|
|
1644
|
+
// src/utils/resolveFetchHandler.ts
|
|
1659
1645
|
/** Resolve the built RSC module once, retaining the selected export's receiver. */
|
|
1660
1646
|
function resolveFetchHandler(module) {
|
|
1661
1647
|
const mod = module;
|
|
@@ -1668,7 +1654,7 @@ function resolveFetchHandler(module) {
|
|
|
1668
1654
|
}
|
|
1669
1655
|
var package_default = {
|
|
1670
1656
|
name: "isr-engine",
|
|
1671
|
-
version: "
|
|
1657
|
+
version: "4.0.0",
|
|
1672
1658
|
description: "ISR/SSG/Fallback rendering orchestration on Vite + React 19 RSC.",
|
|
1673
1659
|
license: "UNLICENSED",
|
|
1674
1660
|
repository: {
|
|
@@ -1775,14 +1761,14 @@ var package_default = {
|
|
|
1775
1761
|
"esbuild": "^0.28.2",
|
|
1776
1762
|
"express": "^5.3.0",
|
|
1777
1763
|
"express-rate-limit": "8.7.5",
|
|
1778
|
-
"helmet": "^
|
|
1764
|
+
"helmet": "^8.3.0",
|
|
1779
1765
|
"ipaddr.js": "^2.5.0",
|
|
1780
|
-
"lru-cache": "^
|
|
1766
|
+
"lru-cache": "^11.5.3",
|
|
1781
1767
|
"ora": "^10.0.0",
|
|
1782
1768
|
"parse5": "^8.0.1",
|
|
1783
1769
|
"pino": "10.4.0",
|
|
1784
1770
|
"prom-client": "^15.1.3",
|
|
1785
|
-
"rsc-html-stream": "0.0.
|
|
1771
|
+
"rsc-html-stream": "0.0.8",
|
|
1786
1772
|
"sharp": "^0.35.5",
|
|
1787
1773
|
"sitemap": "^10.0.0",
|
|
1788
1774
|
"typescript": "^6.0.3"
|
|
@@ -1790,7 +1776,7 @@ var package_default = {
|
|
|
1790
1776
|
peerDependencies: {
|
|
1791
1777
|
"react": "19.3.1",
|
|
1792
1778
|
"react-dom": "19.3.1",
|
|
1793
|
-
"vite": "8.
|
|
1779
|
+
"vite": "8.3.8"
|
|
1794
1780
|
},
|
|
1795
1781
|
optionalDependencies: { "ioredis": "^5.11.1" },
|
|
1796
1782
|
devDependencies: {
|
|
@@ -1807,15 +1793,15 @@ var package_default = {
|
|
|
1807
1793
|
"@types/node": "24.19.2",
|
|
1808
1794
|
"@types/react": "^19.2.15",
|
|
1809
1795
|
"@types/react-dom": "^19.0.0",
|
|
1810
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
1811
|
-
"@typescript-eslint/parser": "8.
|
|
1796
|
+
"@typescript-eslint/eslint-plugin": "8.73.0",
|
|
1797
|
+
"@typescript-eslint/parser": "8.73.0",
|
|
1812
1798
|
"@vitest/coverage-v8": "^4.1.12",
|
|
1813
1799
|
"eslint": "^9.15.0",
|
|
1814
1800
|
"eslint-config-prettier": "^10.1.8",
|
|
1815
1801
|
"eslint-plugin-prettier": "^5.5.7",
|
|
1816
1802
|
"eslint-plugin-react": "^7.37.2",
|
|
1817
1803
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
1818
|
-
"globals": "^
|
|
1804
|
+
"globals": "^17.14.0",
|
|
1819
1805
|
"happy-dom": "^21.0.4",
|
|
1820
1806
|
"husky": "^9.1.7",
|
|
1821
1807
|
"ioredis-mock": "^8.9.0",
|
|
@@ -1828,7 +1814,7 @@ var package_default = {
|
|
|
1828
1814
|
"semantic-release": "25.0.9",
|
|
1829
1815
|
"tsc-alias": "^1.9.10",
|
|
1830
1816
|
"undici": "8.12.4",
|
|
1831
|
-
"vite": "8.
|
|
1817
|
+
"vite": "8.3.8",
|
|
1832
1818
|
"vitest": "^4.1.12"
|
|
1833
1819
|
},
|
|
1834
1820
|
pnpm: { "overrides": {
|
|
@@ -1846,8 +1832,7 @@ var package_default = {
|
|
|
1846
1832
|
"@typescript-eslint/typescript-estree>minimatch": "11.0.5"
|
|
1847
1833
|
} }
|
|
1848
1834
|
};
|
|
1849
|
-
|
|
1850
|
-
//#region src/config/defaults.ts
|
|
1835
|
+
// src/config/defaults.ts
|
|
1851
1836
|
/**
|
|
1852
1837
|
* 框架级默认配置常量
|
|
1853
1838
|
*
|
|
@@ -1856,14 +1841,12 @@ var package_default = {
|
|
|
1856
1841
|
*/
|
|
1857
1842
|
/** 默认服务器端口 */
|
|
1858
1843
|
var DEFAULT_PORT = 3e3;
|
|
1859
|
-
|
|
1860
|
-
//#region src/logger/index.ts
|
|
1844
|
+
// src/logger/index.ts
|
|
1861
1845
|
var logger$8 = Logger.getInstance({
|
|
1862
1846
|
verbose: true,
|
|
1863
1847
|
logFile: "./logs/isr-engine.log"
|
|
1864
1848
|
});
|
|
1865
|
-
|
|
1866
|
-
//#region src/ssg/spider.ts
|
|
1849
|
+
// src/ssg/spider.ts
|
|
1867
1850
|
/**
|
|
1868
1851
|
* SSG 爬虫 —— 构建后爬取 RSC fetch handler,产出静态 HTML 到 dist/client
|
|
1869
1852
|
*
|
|
@@ -2235,8 +2218,7 @@ async function extractSsgRoutes(config) {
|
|
|
2235
2218
|
assertDistinctHtmlRouteIdentities(ssgRoutes);
|
|
2236
2219
|
return ssgRoutes;
|
|
2237
2220
|
}
|
|
2238
|
-
|
|
2239
|
-
//#region src/security/cspNonceTemplate.ts
|
|
2221
|
+
// src/security/cspNonceTemplate.ts
|
|
2240
2222
|
var NONCE_VALUE = /^[A-Za-z0-9+/_-]+={0,2}$/;
|
|
2241
2223
|
var NONCE_SOURCE = /^'nonce-([A-Za-z0-9+/_-]+={0,2})'$/i;
|
|
2242
2224
|
/** Compile all verbatim nonce occurrences, including HTML attributes and serialized JS. */
|
|
@@ -2274,8 +2256,7 @@ function instantiateCspNonceTemplate(body, template, nonce) {
|
|
|
2274
2256
|
fragments.push(body.subarray(cursor));
|
|
2275
2257
|
return Buffer.concat(fragments);
|
|
2276
2258
|
}
|
|
2277
|
-
|
|
2278
|
-
//#region src/types/ISRConfig.ts
|
|
2259
|
+
// src/types/ISRConfig.ts
|
|
2279
2260
|
var RenderModes = {
|
|
2280
2261
|
SSG: "ssg",
|
|
2281
2262
|
ISR: "isr",
|
|
@@ -2313,8 +2294,7 @@ var FallbackChain = {
|
|
|
2313
2294
|
],
|
|
2314
2295
|
ssr: ["server", "csr-shell"]
|
|
2315
2296
|
};
|
|
2316
|
-
|
|
2317
|
-
//#region src/engine/RenderMode.ts
|
|
2297
|
+
// src/engine/RenderMode.ts
|
|
2318
2298
|
/**
|
|
2319
2299
|
* 渲染模式工具函数 —— 根据全局模式和路由覆盖配置,返回渲染模式 / 降级链
|
|
2320
2300
|
*
|
|
@@ -2442,8 +2422,7 @@ function selectRouteRule(url, routes) {
|
|
|
2442
2422
|
function getRouteFallbackChain(url, globalMode, overrides) {
|
|
2443
2423
|
return getFallbackChain(resolveRenderMode(url, globalMode, overrides));
|
|
2444
2424
|
}
|
|
2445
|
-
|
|
2446
|
-
//#region src/plugin/isrCacheStore.ts
|
|
2425
|
+
// src/plugin/isrCacheStore.ts
|
|
2447
2426
|
/**
|
|
2448
2427
|
* IsrCacheStore —— ISR HTTP 响应缓存的存储抽象(同步读 + 异步写穿)
|
|
2449
2428
|
*
|
|
@@ -2458,7 +2437,7 @@ function getRouteFallbackChain(url, globalMode, overrides) {
|
|
|
2458
2437
|
function createMemoryCacheStore(opts = {}) {
|
|
2459
2438
|
const lru = new LRUCache({
|
|
2460
2439
|
max: opts.max ?? 1e3,
|
|
2461
|
-
maxSize: opts.maxBytes ??
|
|
2440
|
+
maxSize: opts.maxBytes ?? 67108864,
|
|
2462
2441
|
sizeCalculation: (e) => e.body.byteLength + 1024
|
|
2463
2442
|
});
|
|
2464
2443
|
return {
|
|
@@ -2513,7 +2492,7 @@ function deserialize(value) {
|
|
|
2513
2492
|
function createHybridCacheStore(opts) {
|
|
2514
2493
|
const lru = new LRUCache({
|
|
2515
2494
|
max: opts.max ?? 1e3,
|
|
2516
|
-
maxSize: opts.maxBytes ??
|
|
2495
|
+
maxSize: opts.maxBytes ?? 67108864,
|
|
2517
2496
|
sizeCalculation: (e) => e.body.byteLength + 1024
|
|
2518
2497
|
});
|
|
2519
2498
|
const pendingReads = /* @__PURE__ */ new Map();
|
|
@@ -2649,8 +2628,7 @@ function createHybridCacheStore(opts) {
|
|
|
2649
2628
|
}
|
|
2650
2629
|
};
|
|
2651
2630
|
}
|
|
2652
|
-
|
|
2653
|
-
//#region src/metrics/PromMetrics.ts
|
|
2631
|
+
// src/metrics/PromMetrics.ts
|
|
2654
2632
|
/**
|
|
2655
2633
|
* PromMetrics —— prom-client 包装,导出 Prometheus 文本格式
|
|
2656
2634
|
*
|
|
@@ -2836,8 +2814,7 @@ function createPrometheusMetricsMiddleware(pathOrOptions = {}) {
|
|
|
2836
2814
|
}
|
|
2837
2815
|
};
|
|
2838
2816
|
}
|
|
2839
|
-
|
|
2840
|
-
//#region src/config/loadConfig.ts
|
|
2817
|
+
// src/config/loadConfig.ts
|
|
2841
2818
|
/**
|
|
2842
2819
|
* 配置加载工具
|
|
2843
2820
|
*/
|
|
@@ -2919,8 +2896,7 @@ async function resolveImportPath(filePath, options) {
|
|
|
2919
2896
|
}
|
|
2920
2897
|
return pathToFileURL$1(filePath).href + (forceReload ? `?t=${Date.now()}` : "");
|
|
2921
2898
|
}
|
|
2922
|
-
|
|
2923
|
-
//#region src/server/opsConfig.ts
|
|
2899
|
+
// src/server/opsConfig.ts
|
|
2924
2900
|
var opsLimiters = /* @__PURE__ */ new WeakMap();
|
|
2925
2901
|
var runtimeOpsConfigs = /* @__PURE__ */ new WeakMap();
|
|
2926
2902
|
/** Carry one resolved policy from the Vite plugin into its owning Express runtime. */
|
|
@@ -3063,8 +3039,7 @@ function createOpsAuthMiddleware(endpoint, resolved) {
|
|
|
3063
3039
|
next();
|
|
3064
3040
|
};
|
|
3065
3041
|
}
|
|
3066
|
-
|
|
3067
|
-
//#region src/plugin/devAssetRequestMiddleware.ts
|
|
3042
|
+
// src/plugin/devAssetRequestMiddleware.ts
|
|
3068
3043
|
var CACHE_SUFFIX_MARKERS = ["$$cache=", "%24%24cache="];
|
|
3069
3044
|
var DEV_ASSET_EXT_RE = /\.(js|mjs|cjs|ts|tsx|jsx|json|map|css|scss|sass|less|stylus|png|jpe?g|gif|webp|avif|svg|ico|woff2?|ttf|eot|mp3|mp4|webm|ogg|wasm|zip|pdf)$/i;
|
|
3070
3045
|
var VITE_OPTIMIZED_DEPS_DIR_RE = /^deps(?:_(?:rsc|ssr))?(?:_temp_[0-9a-f]{8})?$/;
|
|
@@ -3135,8 +3110,7 @@ function assetExists(root, pathname) {
|
|
|
3135
3110
|
function resolveAssetPath(root, pathname) {
|
|
3136
3111
|
return pathname.startsWith("/@fs/") ? pathname.slice(4) : path.join(root, pathname);
|
|
3137
3112
|
}
|
|
3138
|
-
|
|
3139
|
-
//#region src/plugin/coherentCacheStore.ts
|
|
3113
|
+
// src/plugin/coherentCacheStore.ts
|
|
3140
3114
|
function decode(value) {
|
|
3141
3115
|
if (!value || typeof value !== "object") return void 0;
|
|
3142
3116
|
const entry = value;
|
|
@@ -3147,7 +3121,7 @@ function decode(value) {
|
|
|
3147
3121
|
};
|
|
3148
3122
|
}
|
|
3149
3123
|
/** Remote validation is mandatory; pub/sub is an eviction hint, never a read authority. */
|
|
3150
|
-
function createCoherentCacheStore({ backend, max = 1e3, maxBytes =
|
|
3124
|
+
function createCoherentCacheStore({ backend, max = 1e3, maxBytes = 67108864 }) {
|
|
3151
3125
|
const local = new LRUCache({
|
|
3152
3126
|
max,
|
|
3153
3127
|
maxSize: maxBytes,
|
|
@@ -3257,9 +3231,8 @@ function createCoherentCacheStore({ backend, max = 1e3, maxBytes = 64 * 1024 * 1
|
|
|
3257
3231
|
}
|
|
3258
3232
|
};
|
|
3259
3233
|
}
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
var MAX_RESPONSE_TTL_MS = 720 * 60 * 60 * 1e3;
|
|
3234
|
+
// src/cache/RedisResponseCacheBackend.ts
|
|
3235
|
+
var MAX_RESPONSE_TTL_MS = 2592e6;
|
|
3263
3236
|
var MAX_TAGS = 128;
|
|
3264
3237
|
var PRELUDE = `
|
|
3265
3238
|
local function kind(key)
|
|
@@ -3499,8 +3472,7 @@ var RedisResponseCacheBackend = class {
|
|
|
3499
3472
|
await this.close?.();
|
|
3500
3473
|
}
|
|
3501
3474
|
};
|
|
3502
|
-
|
|
3503
|
-
//#region src/cache/MemoryCacheAdapter.ts
|
|
3475
|
+
// src/cache/MemoryCacheAdapter.ts
|
|
3504
3476
|
var DEFAULT_CONFIG$1 = {
|
|
3505
3477
|
capacity: 1e4,
|
|
3506
3478
|
defaultTTL: 0,
|
|
@@ -3676,8 +3648,7 @@ var MemoryCacheAdapter = class {
|
|
|
3676
3648
|
}
|
|
3677
3649
|
}
|
|
3678
3650
|
};
|
|
3679
|
-
|
|
3680
|
-
//#region src/cache/RedisCacheAdapter.ts
|
|
3651
|
+
// src/cache/RedisCacheAdapter.ts
|
|
3681
3652
|
var DEFAULT_CONFIG = {
|
|
3682
3653
|
port: 6379,
|
|
3683
3654
|
db: 0,
|
|
@@ -4137,8 +4108,7 @@ var RedisCacheAdapter = class {
|
|
|
4137
4108
|
this.connected = false;
|
|
4138
4109
|
}
|
|
4139
4110
|
};
|
|
4140
|
-
|
|
4141
|
-
//#region src/config/resolveRuntimeRedis.ts
|
|
4111
|
+
// src/config/resolveRuntimeRedis.ts
|
|
4142
4112
|
function nonEmpty(value) {
|
|
4143
4113
|
const trimmed = value?.trim();
|
|
4144
4114
|
return trimmed ? trimmed : void 0;
|
|
@@ -4181,8 +4151,7 @@ function hasRuntimeRedisConnection(redis) {
|
|
|
4181
4151
|
const resolved = resolveRuntimeRedisConfig(redis);
|
|
4182
4152
|
return Boolean(resolved?.url || resolved?.host);
|
|
4183
4153
|
}
|
|
4184
|
-
|
|
4185
|
-
//#region src/cache/createAutoCacheStore.ts
|
|
4154
|
+
// src/cache/createAutoCacheStore.ts
|
|
4186
4155
|
/**
|
|
4187
4156
|
* createAutoCacheStore —— 按显式 Redis 配置选择 cache backend
|
|
4188
4157
|
*
|
|
@@ -4221,8 +4190,7 @@ function createAutoCacheStore(opts = {}) {
|
|
|
4221
4190
|
max
|
|
4222
4191
|
});
|
|
4223
4192
|
}
|
|
4224
|
-
|
|
4225
|
-
//#region src/cache/RedisInvalidationBus.ts
|
|
4193
|
+
// src/cache/RedisInvalidationBus.ts
|
|
4226
4194
|
function normalizeTarget(target) {
|
|
4227
4195
|
if (!target || typeof target !== "object") return null;
|
|
4228
4196
|
const candidate = target;
|
|
@@ -4263,12 +4231,12 @@ var RedisInvalidationBus = class {
|
|
|
4263
4231
|
channel: config.channel,
|
|
4264
4232
|
connectTimeout: config.connectTimeout ?? 5e3,
|
|
4265
4233
|
commandTimeout: config.commandTimeout ?? 3e3,
|
|
4266
|
-
replayWindowMs: config.replayWindowMs ??
|
|
4234
|
+
replayWindowMs: config.replayWindowMs ?? 3e5,
|
|
4267
4235
|
replayLogMaxEntries: config.replayLogMaxEntries ?? 5e3
|
|
4268
4236
|
};
|
|
4269
4237
|
this.channel = this.config.channel ?? `${this.config.keyPrefix}invalidate`;
|
|
4270
4238
|
this.logKey = `${this.channel}:log`;
|
|
4271
|
-
this.replayWindowMs = this.config.replayWindowMs ??
|
|
4239
|
+
this.replayWindowMs = this.config.replayWindowMs ?? 3e5;
|
|
4272
4240
|
this.replayLogMaxEntries = this.config.replayLogMaxEntries ?? 5e3;
|
|
4273
4241
|
this.lastSeenSentAt = Date.now();
|
|
4274
4242
|
this.initPromise = this.init();
|
|
@@ -4448,8 +4416,7 @@ var RedisInvalidationBus = class {
|
|
|
4448
4416
|
}
|
|
4449
4417
|
}
|
|
4450
4418
|
};
|
|
4451
|
-
|
|
4452
|
-
//#region src/context/createServerRequestContext.ts
|
|
4419
|
+
// src/context/createServerRequestContext.ts
|
|
4453
4420
|
/**
|
|
4454
4421
|
* createServerRequestContext —— engine 入口处构造 RequestContext 的统一工厂。
|
|
4455
4422
|
*
|
|
@@ -4466,7 +4433,7 @@ var RedisInvalidationBus = class {
|
|
|
4466
4433
|
/** anonId cookie 名称 —— engine 全局常量,避免散落字符串。 */
|
|
4467
4434
|
var ANON_COOKIE_NAME = "anon";
|
|
4468
4435
|
/** anonId cookie 有效期(秒)。1 年;浏览器侧最大也只能撑到这个量级。 */
|
|
4469
|
-
var ANON_COOKIE_MAX_AGE_SECONDS =
|
|
4436
|
+
var ANON_COOKIE_MAX_AGE_SECONDS = 31536e3;
|
|
4470
4437
|
/**
|
|
4471
4438
|
* 从 IncomingMessage 构造 ISRContextData。
|
|
4472
4439
|
*
|
|
@@ -4479,7 +4446,8 @@ var ANON_COOKIE_MAX_AGE_SECONDS = 365 * 24 * 60 * 60;
|
|
|
4479
4446
|
*/
|
|
4480
4447
|
function createServerRequestContext(req) {
|
|
4481
4448
|
const rawCookie = req.headers["cookie"];
|
|
4482
|
-
const
|
|
4449
|
+
const cookieHeader = Array.isArray(rawCookie) ? rawCookie.join("; ") : typeof rawCookie === "string" ? rawCookie : "";
|
|
4450
|
+
const cookies = parseCookieHeader(cookieHeader);
|
|
4483
4451
|
const headerReqId = req.headers["x-request-id"];
|
|
4484
4452
|
const headerTraceparent = req.headers["traceparent"];
|
|
4485
4453
|
const existingAnon = cookies[ANON_COOKIE_NAME];
|
|
@@ -4523,8 +4491,7 @@ function applyAnonCookie(res, anonId, cookieDomain) {
|
|
|
4523
4491
|
if (cookieDomain) parts.push(`Domain=${cookieDomain}`);
|
|
4524
4492
|
res.appendHeader("Set-Cookie", parts.join("; "));
|
|
4525
4493
|
}
|
|
4526
|
-
|
|
4527
|
-
//#region src/utils/hash.ts
|
|
4494
|
+
// src/utils/hash.ts
|
|
4528
4495
|
/**
|
|
4529
4496
|
* 通用 hash 工具 —— 非加密用途的快速字符串 hash。
|
|
4530
4497
|
*
|
|
@@ -4555,8 +4522,7 @@ function fnv1a32(input) {
|
|
|
4555
4522
|
function fnv1a32Base36(input) {
|
|
4556
4523
|
return fnv1a32(input).toString(36);
|
|
4557
4524
|
}
|
|
4558
|
-
|
|
4559
|
-
//#region src/plugin/isrCacheMiddleware.ts
|
|
4525
|
+
// src/plugin/isrCacheMiddleware.ts
|
|
4560
4526
|
/**
|
|
4561
4527
|
* ISR 缓存中间件插件 —— engine 的差异化核心能力
|
|
4562
4528
|
*
|
|
@@ -4700,7 +4666,7 @@ function createIsrCacheHandler(config, options = {}) {
|
|
|
4700
4666
|
const seeded = /* @__PURE__ */ new Map();
|
|
4701
4667
|
const internalToken = randomBytes(24).toString("hex");
|
|
4702
4668
|
const singleflightWaitMs = options.singleflightWaitMs ?? 5e3;
|
|
4703
|
-
const maxCachedBodyBytes = options.maxCachedBodyBytes ??
|
|
4669
|
+
const maxCachedBodyBytes = options.maxCachedBodyBytes ?? 5242880;
|
|
4704
4670
|
const prefetchOnHit = options.prefetchOnHit;
|
|
4705
4671
|
const prefetchCooldownMs = options.prefetchCooldownMs ?? 3e4;
|
|
4706
4672
|
/**
|
|
@@ -4934,7 +4900,7 @@ function createIsrCacheMiddleware(explicitConfig, options = {}) {
|
|
|
4934
4900
|
development: true
|
|
4935
4901
|
}));
|
|
4936
4902
|
try {
|
|
4937
|
-
const inspector = opsConfig.inventory.enabled ? (await import("./createCacheInspectorMiddleware-
|
|
4903
|
+
const inspector = opsConfig.inventory.enabled ? (await import("./createCacheInspectorMiddleware-BjwSKfyf.js")).createCacheInspectorMiddleware(nextHandler, opsConfig) : void 0;
|
|
4938
4904
|
handler = nextHandler;
|
|
4939
4905
|
server.middlewares.use((req, res, next) => {
|
|
4940
4906
|
if (handler !== nextHandler) return next();
|
|
@@ -5758,8 +5724,7 @@ function refreshHeaders(req, ctx) {
|
|
|
5758
5724
|
}
|
|
5759
5725
|
return headers;
|
|
5760
5726
|
}
|
|
5761
|
-
|
|
5762
|
-
//#region src/plugin/remoteImageSource.ts
|
|
5727
|
+
// src/plugin/remoteImageSource.ts
|
|
5763
5728
|
var ImageSourceError = class extends Error {
|
|
5764
5729
|
status;
|
|
5765
5730
|
constructor(status, message) {
|
|
@@ -5893,7 +5858,7 @@ async function requestPinnedImage(url, allow, signal, accept = "image/*", userAg
|
|
|
5893
5858
|
path: requestPath,
|
|
5894
5859
|
agent: false,
|
|
5895
5860
|
signal,
|
|
5896
|
-
maxHeaderSize:
|
|
5861
|
+
maxHeaderSize: 16384,
|
|
5897
5862
|
...origin.protocol === "https:" ? {
|
|
5898
5863
|
servername: isIP(origin.hostname) ? void 0 : origin.hostname,
|
|
5899
5864
|
rejectUnauthorized: true
|
|
@@ -5913,8 +5878,7 @@ async function requestPinnedImage(url, allow, signal, accept = "image/*", userAg
|
|
|
5913
5878
|
request$2.end();
|
|
5914
5879
|
});
|
|
5915
5880
|
}
|
|
5916
|
-
|
|
5917
|
-
//#region src/plugin/createImagePlugin.ts
|
|
5881
|
+
// src/plugin/createImagePlugin.ts
|
|
5918
5882
|
/**
|
|
5919
5883
|
* createImagePlugin —— 图片优化(dev + prod 通用 endpoint)
|
|
5920
5884
|
*
|
|
@@ -5945,7 +5909,7 @@ var SUPPORTED_FORMATS = /* @__PURE__ */ new Set([
|
|
|
5945
5909
|
"jpg",
|
|
5946
5910
|
"png"
|
|
5947
5911
|
]);
|
|
5948
|
-
var MAX_INPUT_BYTES =
|
|
5912
|
+
var MAX_INPUT_BYTES = 26214400;
|
|
5949
5913
|
function createImagePlugin(options = {}, dependencies = {}) {
|
|
5950
5914
|
return {
|
|
5951
5915
|
name: "isr-engine:image-optimization",
|
|
@@ -5969,7 +5933,7 @@ function createImageHandler(opts, getPublicDir, dependencies, getDevServer) {
|
|
|
5969
5933
|
const allow = new Set(resolveImageOptions({ remoteAllowlist: opts.remoteAllowlist }).remoteAllowlist);
|
|
5970
5934
|
const cache = new LRUCache({
|
|
5971
5935
|
max: Math.max(1, opts.cacheMax ?? 500),
|
|
5972
|
-
maxSize:
|
|
5936
|
+
maxSize: 67108864,
|
|
5973
5937
|
sizeCalculation: (entry) => entry.body.byteLength,
|
|
5974
5938
|
ttl: 6e4
|
|
5975
5939
|
});
|
|
@@ -6201,8 +6165,7 @@ async function loadSource(src, allow, publicDir, server) {
|
|
|
6201
6165
|
throw new ImageError(404, "source not found");
|
|
6202
6166
|
}
|
|
6203
6167
|
}
|
|
6204
|
-
|
|
6205
|
-
//#region src/engine/seo/config.ts
|
|
6168
|
+
// src/engine/seo/config.ts
|
|
6206
6169
|
/** 默认 SEO 配置 */
|
|
6207
6170
|
var DEFAULT_SEO_CONFIG = {
|
|
6208
6171
|
baseUrl: "",
|
|
@@ -6267,8 +6230,7 @@ function mergeSEOConfig(base, override) {
|
|
|
6267
6230
|
}
|
|
6268
6231
|
};
|
|
6269
6232
|
}
|
|
6270
|
-
|
|
6271
|
-
//#region src/engine/seo/SEOEngine.ts
|
|
6233
|
+
// src/engine/seo/SEOEngine.ts
|
|
6272
6234
|
/**
|
|
6273
6235
|
* SEO 引擎 - 单例模式
|
|
6274
6236
|
*
|
|
@@ -6504,8 +6466,7 @@ var SEOEngine = class SEOEngine {
|
|
|
6504
6466
|
function createSEOEngine(config) {
|
|
6505
6467
|
return SEOEngine.getInstance(config);
|
|
6506
6468
|
}
|
|
6507
|
-
|
|
6508
|
-
//#region src/engine/seo/resolveSeoConfig.ts
|
|
6469
|
+
// src/engine/seo/resolveSeoConfig.ts
|
|
6509
6470
|
/**
|
|
6510
6471
|
* SEO 配置解析器 —— 唯一的 baseUrl 解析入口
|
|
6511
6472
|
*
|
|
@@ -6540,8 +6501,7 @@ function resolveSeoConfig(config) {
|
|
|
6540
6501
|
baseUrlSource: source
|
|
6541
6502
|
};
|
|
6542
6503
|
}
|
|
6543
|
-
|
|
6544
|
-
//#region src/experiments/ExposureQueue.ts
|
|
6504
|
+
// src/experiments/ExposureQueue.ts
|
|
6545
6505
|
/**
|
|
6546
6506
|
* ExposureQueue —— 曝光事件批量上报队列
|
|
6547
6507
|
*
|
|
@@ -6689,8 +6649,7 @@ function resolveExposureQueue(config, baseOrigin) {
|
|
|
6689
6649
|
sampleRate: config.sampleRate
|
|
6690
6650
|
});
|
|
6691
6651
|
}
|
|
6692
|
-
|
|
6693
|
-
//#region src/experiments/ManifestLoader.ts
|
|
6652
|
+
// src/experiments/ManifestLoader.ts
|
|
6694
6653
|
/**
|
|
6695
6654
|
* ManifestLoader —— 实验定义动态拉取
|
|
6696
6655
|
*
|
|
@@ -6783,7 +6742,6 @@ function createManifestLoader(options) {
|
|
|
6783
6742
|
case "empty":
|
|
6784
6743
|
state.current = {};
|
|
6785
6744
|
logger$2.warn(`[ManifestLoader] 拉取失败(${reason}),关闭所有实验`);
|
|
6786
|
-
break;
|
|
6787
6745
|
}
|
|
6788
6746
|
}
|
|
6789
6747
|
function schedulePoll() {
|
|
@@ -6838,8 +6796,7 @@ function resolveManifestLoader(config, staticExperiments, baseOrigin) {
|
|
|
6838
6796
|
staticExperiments
|
|
6839
6797
|
});
|
|
6840
6798
|
}
|
|
6841
|
-
|
|
6842
|
-
//#region src/middlewares/ABVariantMiddleware.ts
|
|
6799
|
+
// src/middlewares/ABVariantMiddleware.ts
|
|
6843
6800
|
/** 总桶数;10000 给到 0.01% 权重精度,业界通行做法 */
|
|
6844
6801
|
var BUCKET_SPACE = 1e4;
|
|
6845
6802
|
/**
|
|
@@ -6898,8 +6855,7 @@ function createABVariantMiddleware(options) {
|
|
|
6898
6855
|
next();
|
|
6899
6856
|
};
|
|
6900
6857
|
}
|
|
6901
|
-
|
|
6902
|
-
//#region src/server/safeRedirect.ts
|
|
6858
|
+
// src/server/safeRedirect.ts
|
|
6903
6859
|
var REDIRECT_ORIGIN = "https://isr.invalid";
|
|
6904
6860
|
/** Validate the final Location value against a fixed origin, never an untrusted Host header. */
|
|
6905
6861
|
function isSafeLocalRedirect(target) {
|
|
@@ -6928,8 +6884,7 @@ function redirectLocal(res, status, pathname, query) {
|
|
|
6928
6884
|
}
|
|
6929
6885
|
res.redirect(status, target);
|
|
6930
6886
|
}
|
|
6931
|
-
|
|
6932
|
-
//#region src/middlewares/LocaleRedirect.ts
|
|
6887
|
+
// src/middlewares/LocaleRedirect.ts
|
|
6933
6888
|
var FRAMEWORK_SKIP_PREFIXES = [
|
|
6934
6889
|
"/api/",
|
|
6935
6890
|
"/_rsc",
|
|
@@ -7003,8 +6958,7 @@ function readCookieLocale(header) {
|
|
|
7003
6958
|
}
|
|
7004
6959
|
return null;
|
|
7005
6960
|
}
|
|
7006
|
-
|
|
7007
|
-
//#region src/security/staticCspManifest.ts
|
|
6961
|
+
// src/security/staticCspManifest.ts
|
|
7008
6962
|
var STATIC_CSP_MANIFEST = "static-csp-manifest.json";
|
|
7009
6963
|
var SCHEMA_VERSION = 3;
|
|
7010
6964
|
var sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
@@ -7192,8 +7146,7 @@ function indexManifest(manifest, legacy) {
|
|
|
7192
7146
|
scriptHashes: new Map(manifest.files.map((file) => [file.path, Object.freeze([...file.scriptHashes])]))
|
|
7193
7147
|
};
|
|
7194
7148
|
}
|
|
7195
|
-
|
|
7196
|
-
//#region src/server/productionRuntime.ts
|
|
7149
|
+
// src/server/productionRuntime.ts
|
|
7197
7150
|
/** Shared production application assembly. Listening and process signals belong to callers. */
|
|
7198
7151
|
function safeOrigin(url) {
|
|
7199
7152
|
if (!url) return void 0;
|
|
@@ -7478,7 +7431,7 @@ async function createProductionRuntime(config, options = {}) {
|
|
|
7478
7431
|
});
|
|
7479
7432
|
cleanups.push(() => cache.destroy());
|
|
7480
7433
|
if (opsConfig.inventory.enabled) {
|
|
7481
|
-
const { createCacheInspectorMiddleware } = await import("./createCacheInspectorMiddleware-
|
|
7434
|
+
const { createCacheInspectorMiddleware } = await import("./createCacheInspectorMiddleware-BjwSKfyf.js");
|
|
7482
7435
|
app.use(createCacheInspectorMiddleware(cache, opsConfig));
|
|
7483
7436
|
logger$8.info("🔍 ISR cache inventory 已启用:GET /__isr/cache/inventory");
|
|
7484
7437
|
}
|
|
@@ -7530,7 +7483,7 @@ async function createProductionRuntime(config, options = {}) {
|
|
|
7530
7483
|
res.set("cache-control", "public, max-age=3600");
|
|
7531
7484
|
res.end(seo.generateRobotsTxt());
|
|
7532
7485
|
});
|
|
7533
|
-
const { renderError500Html } = await import("./error500-template-
|
|
7486
|
+
const { renderError500Html } = await import("./error500-template-CFdKp8YG.js");
|
|
7534
7487
|
app.all(/.*/, createProductionRequestHandler(rscHandler, (err, _req, res) => {
|
|
7535
7488
|
logger$8.error("[Server]", "请求处理异常", err);
|
|
7536
7489
|
if (!res.headersSent) {
|
|
@@ -7727,8 +7680,7 @@ function createStaticAssetMiddleware(clientDir) {
|
|
|
7727
7680
|
assets(req, res, next);
|
|
7728
7681
|
};
|
|
7729
7682
|
}
|
|
7730
|
-
|
|
7731
|
-
//#region src/server/httpServer.ts
|
|
7683
|
+
// src/server/httpServer.ts
|
|
7732
7684
|
/**
|
|
7733
7685
|
* HTTP 服务器启动器
|
|
7734
7686
|
*
|
|
@@ -7852,8 +7804,7 @@ function closeServer(server) {
|
|
|
7852
7804
|
closingServers.set(server, closing);
|
|
7853
7805
|
return closing;
|
|
7854
7806
|
}
|
|
7855
|
-
|
|
7856
|
-
//#region src/server/manager.ts
|
|
7807
|
+
// src/server/manager.ts
|
|
7857
7808
|
/**
|
|
7858
7809
|
* 服务器管理器
|
|
7859
7810
|
* 整合 Vite 开发服务器、HTTP 服务器和中间件
|
|
@@ -8037,8 +7988,7 @@ async function stopAppServer() {
|
|
|
8037
7988
|
if (errors.length) throw new AggregateError(errors.map((result) => result.reason), "Server shutdown failed");
|
|
8038
7989
|
logger.success("✅ 服务器已完全关闭");
|
|
8039
7990
|
}
|
|
8040
|
-
|
|
8041
|
-
//#region src/isr/ISRRoutes.ts
|
|
7991
|
+
// src/isr/ISRRoutes.ts
|
|
8042
7992
|
var ISRRoutes = class {
|
|
8043
7993
|
engine;
|
|
8044
7994
|
logger;
|
|
@@ -8112,8 +8062,7 @@ var ISRRoutes = class {
|
|
|
8112
8062
|
this.logger.debug("ISRRoutes: 已注册 ops 端点 (/health, /sitemap.xml, /robots.txt)");
|
|
8113
8063
|
}
|
|
8114
8064
|
};
|
|
8115
|
-
|
|
8116
|
-
//#region src/middlewares/MiddlewareComposer.ts
|
|
8065
|
+
// src/middlewares/MiddlewareComposer.ts
|
|
8117
8066
|
var MiddlewareComposer = class MiddlewareComposer {
|
|
8118
8067
|
static instance;
|
|
8119
8068
|
middlewares = [];
|
|
@@ -8154,8 +8103,7 @@ var MiddlewareComposer = class MiddlewareComposer {
|
|
|
8154
8103
|
return dispatch(0);
|
|
8155
8104
|
}
|
|
8156
8105
|
};
|
|
8157
|
-
|
|
8158
|
-
//#region src/middlewares/TraceMiddleware.ts
|
|
8106
|
+
// src/middlewares/TraceMiddleware.ts
|
|
8159
8107
|
/**
|
|
8160
8108
|
* W3C trace-context (traceparent) 解析
|
|
8161
8109
|
*
|
|
@@ -8209,8 +8157,7 @@ var traceMiddleware = async (context, next) => {
|
|
|
8209
8157
|
await next();
|
|
8210
8158
|
});
|
|
8211
8159
|
};
|
|
8212
|
-
|
|
8213
|
-
//#region src/middlewares/PerformanceMiddleware.ts
|
|
8160
|
+
// src/middlewares/PerformanceMiddleware.ts
|
|
8214
8161
|
/**
|
|
8215
8162
|
* 性能观测中间件 —— 记录中间件链的总耗时。
|
|
8216
8163
|
*
|
|
@@ -8237,8 +8184,7 @@ var performanceMiddleware = async (context, next) => {
|
|
|
8237
8184
|
}
|
|
8238
8185
|
}
|
|
8239
8186
|
};
|
|
8240
|
-
|
|
8241
|
-
//#region src/engine/ISREngine.ts
|
|
8187
|
+
// src/engine/ISREngine.ts
|
|
8242
8188
|
/**
|
|
8243
8189
|
* ISR 引擎 —— ISR/SSG/Fallback 编排层(plugin-rsc 模式)
|
|
8244
8190
|
*
|
|
@@ -8337,8 +8283,7 @@ var ISREngine = class {
|
|
|
8337
8283
|
this.logger.success("ISR 引擎关闭完成");
|
|
8338
8284
|
}
|
|
8339
8285
|
};
|
|
8340
|
-
|
|
8341
|
-
//#region src/app/createISRApp.ts
|
|
8286
|
+
// src/app/createISRApp.ts
|
|
8342
8287
|
function normalizeAppConfig(raw) {
|
|
8343
8288
|
return normalizeEngineConfig(raw);
|
|
8344
8289
|
}
|
|
@@ -8374,7 +8319,6 @@ async function createISRApp(appOption) {
|
|
|
8374
8319
|
shutdown: async () => engine.shutdown()
|
|
8375
8320
|
};
|
|
8376
8321
|
}
|
|
8377
|
-
//#endregion
|
|
8378
8322
|
export { parseComponents as $, invalidatorRunsTotal as A, InternalStrategies as B, createCoherentCacheStore as C, loadConfig as D, getOpsRequestLimiter as E, getFallbackChain as F, DEFAULT_PORT as G, extractSsgRoutes as H, getRouteFallbackChain as I, DEFAULT_SCAN_CONFIG as J, package_default as K, matchRoutePattern as L, recordHttpRequest as M, createHybridCacheStore as N, createPrometheusMetricsMiddleware as O, createMemoryCacheStore as P, parseComponentFromFile as Q, resolveRenderMode as R, MemoryCacheAdapter as S, createOpsAuthMiddleware as T, spiderSsgRoutes as U, RenderModes as V, logger$8 as W, scanProject as X, scanComponents as Y, scanRoutes as Z, requestPinnedImage as _, closeServer as a, isDev as at, RedisInvalidationBus as b, prepareProductionBuild as c, CacheCleanup as ct, SEOEngine as d, resolveImageOptions as dt, parseRouteFromFile as et, createSEOEngine as f, createImagePlugin as g, createImageMiddleware as h, startAppServer as i, readDirRecursive as it, promRegistry as j, invalidatorFailuresTotal as k, generateStaticCspManifest as l, Logger as lt, mergeSEOConfig as m, ISREngine as n, isCodeFile as nt, startServer as o, isProd as ot, DEFAULT_SEO_CONFIG as p, resolveFetchHandler as q, shutdownServer as r, isTestFile as rt, createProductionRuntime as s, getEnv as st, createISRApp as t, parseRoutes as tt, createABVariantMiddleware as u, assertDistinctHtmlRouteIdentities as ut, createIsrCacheHandler as v, createDevAssetRequestMiddleware as w, RedisCacheAdapter as x, createIsrCacheMiddleware as y, FallbackChain as z };
|
|
8379
8323
|
|
|
8380
|
-
//# sourceMappingURL=createISRApp-
|
|
8324
|
+
//# sourceMappingURL=createISRApp-CbDPv6fY.js.map
|