isr-engine 4.2.0 → 4.3.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 +5 -1
- package/dist/{contentRevalidation-D3SZwwbX.js → CacheTagContext-Btmq8KCD.js} +20 -7
- package/dist/CacheTagContext-Btmq8KCD.js.map +1 -0
- package/dist/{abVariantContext-BNInoflb.js → abVariantContext-yWZOqscY.js} +94 -36
- package/dist/abVariantContext-yWZOqscY.js.map +1 -0
- package/dist/cli/cli.js +1 -1
- package/dist/context/CacheTagContext.d.ts +10 -0
- package/dist/context/CacheTagContext.d.ts.map +1 -0
- package/dist/{createCacheInspectorMiddleware-CDOoJXGO.js → createCacheInspectorMiddleware-glgtcBcQ.js} +2 -2
- package/dist/{createCacheInspectorMiddleware-CDOoJXGO.js.map → createCacheInspectorMiddleware-glgtcBcQ.js.map} +1 -1
- package/dist/{createCachedFetcher-Y7zbGgjb.js → createCachedFetcher-CgJscexq.js} +29 -10
- package/dist/createCachedFetcher-CgJscexq.js.map +1 -0
- package/dist/{createISRApp-DA3-5Ezk.js → createISRApp-BG-s3uuL.js} +74 -56
- package/dist/createISRApp-BG-s3uuL.js.map +1 -0
- package/dist/defaults/runtime/contentRevalidation.d.ts +5 -2
- package/dist/defaults/runtime/contentRevalidation.d.ts.map +1 -1
- package/dist/defaults/runtime/createCachedFetcher.d.ts +5 -1
- package/dist/defaults/runtime/createCachedFetcher.d.ts.map +1 -1
- package/dist/defaults/runtime/defineSiteHooks.d.ts +2 -0
- package/dist/defaults/runtime/defineSiteHooks.d.ts.map +1 -1
- package/dist/defaults/runtime/defineSiteHooks.js +29 -23
- package/dist/defaults/runtime/defineSiteHooks.js.map +1 -1
- package/dist/defaults/runtime/renderCancellation.d.ts +3 -0
- package/dist/defaults/runtime/renderCancellation.d.ts.map +1 -0
- package/dist/engine/seo/resolveSeoConfig.d.ts +1 -0
- package/dist/engine/seo/resolveSeoConfig.d.ts.map +1 -1
- package/dist/isr-engine.js +4 -4
- package/dist/plugin/isrCacheMiddleware.d.ts.map +1 -1
- package/dist/rsc/browser.js +1 -1
- package/dist/rsc/browser.js.map +1 -1
- package/dist/rsc/cacheTag.d.ts +1 -8
- package/dist/rsc/cacheTag.d.ts.map +1 -1
- package/dist/rsc/index.js +3 -2
- package/dist/rsc/revalidate.d.ts +3 -2
- package/dist/rsc/revalidate.d.ts.map +1 -1
- package/dist/{rsc-CbZ-BsWD.js → rsc-BYq2vvnh.js} +2 -2
- package/dist/{rsc-CbZ-BsWD.js.map → rsc-BYq2vvnh.js.map} +1 -1
- package/dist/server/contentRevalidationRoute.d.ts +4 -0
- package/dist/server/contentRevalidationRoute.d.ts.map +1 -0
- package/dist/server/opsConfig.d.ts +6 -1
- package/dist/server/opsConfig.d.ts.map +1 -1
- package/dist/server/productionRuntime.d.ts.map +1 -1
- package/dist/server/publishedSitemap.d.ts.map +1 -1
- package/dist/types/ISRConfig.d.ts +4 -0
- package/dist/types/ISRConfig.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/context/CacheTagContext.ts +20 -0
- package/src/defaults/entry.server.ssr.tsx +10 -0
- package/src/defaults/runtime/contentRevalidation.ts +9 -3
- package/src/defaults/runtime/createCachedFetcher.ts +45 -10
- package/src/defaults/runtime/defineServerEntry.tsx +26 -28
- package/src/defaults/runtime/defineSiteHooks.ts +42 -25
- package/src/defaults/runtime/renderCancellation.ts +10 -0
- package/src/types/ISRConfig.ts +4 -0
- package/dist/abVariantContext-BNInoflb.js.map +0 -1
- package/dist/contentRevalidation-D3SZwwbX.js.map +0 -1
- package/dist/createCachedFetcher-Y7zbGgjb.js.map +0 -1
- package/dist/createISRApp-DA3-5Ezk.js.map +0 -1
package/dist/rsc/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","names":[],"sources":["../../src/rsc/browser.ts"],"sourcesContent":["/**\n * Browser stub for isr-engine/rsc.\n *\n * Server Components may be referenced from a shared route manifest. Client builds must\n * never pull Node-only cache/action infrastructure just because those server modules\n * are statically discoverable. Browser condition resolves here and keeps these APIs\n * inert outside the RSC/server runtime.\n */\n\nimport type { ContentRevalidationOptions } from '../defaults/runtime/contentRevalidation';\nexport type { ContentRevalidationOptions } from '../defaults/runtime/contentRevalidation';\n\nexport class RevalidationError extends Error {}\n\nexport type RevalidateInvalidator = (\n target: { kind: 'path'; value: string } | { kind: 'tag'; value: string }\n) => Promise<void> | void;\n\nexport function cacheTag(): void {\n void 0;\n}\n\nexport function markUncacheable(): void {\n void 0;\n}\n\nexport function collectTags(): string[] {\n return [];\n}\n\nexport function debugTagStore(): void {\n void 0;\n}\n\nexport function isUncacheable(): boolean {\n return false;\n}\n\nexport function runWithTagStore<T>(fn: () => T | Promise<T>): T | Promise<T> {\n return fn();\n}\n\nexport async function revalidatePath(): Promise<void> {\n await Promise.resolve();\n}\n\nexport async function revalidateTag(): Promise<void> {\n await Promise.resolve();\n}\n\nexport async function revalidateContent(_options: ContentRevalidationOptions): Promise<void> {\n
|
|
1
|
+
{"version":3,"file":"browser.js","names":[],"sources":["../../src/rsc/browser.ts"],"sourcesContent":["/**\n * Browser stub for isr-engine/rsc.\n *\n * Server Components may be referenced from a shared route manifest. Client builds must\n * never pull Node-only cache/action infrastructure just because those server modules\n * are statically discoverable. Browser condition resolves here and keeps these APIs\n * inert outside the RSC/server runtime.\n */\n\nimport type { ContentRevalidationOptions } from '../defaults/runtime/contentRevalidation';\nexport type { ContentRevalidationOptions } from '../defaults/runtime/contentRevalidation';\n\nexport class RevalidationError extends Error {}\n\nexport type RevalidateInvalidator = (\n target: { kind: 'path'; value: string } | { kind: 'tag'; value: string }\n) => Promise<void> | void;\n\nexport function cacheTag(): void {\n void 0;\n}\n\nexport function markUncacheable(): void {\n void 0;\n}\n\nexport function collectTags(): string[] {\n return [];\n}\n\nexport function debugTagStore(): void {\n void 0;\n}\n\nexport function isUncacheable(): boolean {\n return false;\n}\n\nexport function runWithTagStore<T>(fn: () => T | Promise<T>): T | Promise<T> {\n return fn();\n}\n\nexport async function revalidatePath(): Promise<void> {\n await Promise.resolve();\n}\n\nexport async function revalidateTag(): Promise<void> {\n await Promise.resolve();\n}\n\nexport async function revalidateContent(_options: ContentRevalidationOptions): Promise<void> {\n throw new Error('revalidateContent requires an active ISR runtime');\n}\n\nexport function registerInvalidator(): () => void {\n return () => {\n void 0;\n };\n}\n\nexport const serverActionsRegistry = {\n initialize: async () => Promise.resolve(),\n cleanup: async () => Promise.resolve(),\n register: () => '',\n getAllActions: () => [],\n hasAction: () => false,\n getMetadata: () => undefined,\n};\n\nexport function createServerAction<T>(handler: T): T {\n return handler;\n}\n\nexport const ServerActionUtils = {\n isServer: () => false,\n isClient: () => true,\n getExecutionContext: () => ({\n environment: 'client' as const,\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : undefined,\n url: typeof window !== 'undefined' ? window.location.href : undefined,\n timestamp: new Date().toISOString(),\n }),\n};\n\nexport const SERVER_ACTION_ENDPOINT = '/_rsc/action';\nexport const LEGACY_SERVER_ACTION_ENDPOINT = '/api/server-actions';\n\nexport function getServerActionEndpointCandidates(primaryEndpoint?: string): string[] {\n return [\n primaryEndpoint || SERVER_ACTION_ENDPOINT,\n SERVER_ACTION_ENDPOINT,\n LEGACY_SERVER_ACTION_ENDPOINT,\n ];\n}\n\nexport function isLegacyServerActionEndpoint(endpoint: string): boolean {\n return endpoint === LEGACY_SERVER_ACTION_ENDPOINT;\n}\n\nexport function shouldSkipServerActionEndpointRetry(endpoint: string): boolean {\n return isLegacyServerActionEndpoint(endpoint);\n}\n\nexport function getVariant(): string | undefined {\n return undefined;\n}\n\n// 浏览器/客户端不持有 AsyncLocalStorage 请求上下文 —— 任何业务在 'use client'\n// 树里走到 getRequestContext() 都拿 undefined,跟 Server Component 里没有\n// 命中作用域时一致。空 stub 让 plugin-rsc 的 client/browser bundle 链不至于\n// 因为符号缺失炸开。\nexport function getRequestContext(): undefined {\n return undefined;\n}\n\nexport function getI18n(key: string, _params?: Record<string, unknown>, fallback = key): string {\n return fallback;\n}\n\nexport function getI18nLocale(fallback = ''): string {\n return fallback;\n}\n\nexport function getCurrentI18n(): null {\n return null;\n}\n\nexport function runWithI18n<T>(_intl: unknown, fn: () => T): T {\n return fn();\n}\n\nexport type I18nParams = Record<string, string | number | boolean | null | undefined>;\nexport type Translate = (key: string, params?: I18nParams, fallback?: string) => string;\n"],"mappings":";AAYA,IAAa,oBAAb,cAAuC,MAAM,CAAC;AAM9C,SAAgB,WAAiB,CAEjC;AAEA,SAAgB,kBAAwB,CAExC;AAEA,SAAgB,cAAwB;CACtC,OAAO,CAAC;AACV;AAEA,SAAgB,gBAAsB,CAEtC;AAEA,SAAgB,gBAAyB;CACvC,OAAO;AACT;AAEA,SAAgB,gBAAmB,IAA0C;CAC3E,OAAO,GAAG;AACZ;AAEA,eAAsB,iBAAgC;CACpD,MAAM,QAAQ,QAAQ;AACxB;AAEA,eAAsB,gBAA+B;CACnD,MAAM,QAAQ,QAAQ;AACxB;AAEA,eAAsB,kBAAkB,UAAqD;CAC3F,MAAM,IAAI,MAAM,kDAAkD;AACpE;AAEA,SAAgB,sBAAkC;CAChD,aAAa,CAEb;AACF;AAEA,IAAa,wBAAwB;CACnC,YAAY,YAAY,QAAQ,QAAQ;CACxC,SAAS,YAAY,QAAQ,QAAQ;CACrC,gBAAgB;CAChB,qBAAqB,CAAC;CACtB,iBAAiB;CACjB,mBAAmB,KAAA;AACrB;AAEA,SAAgB,mBAAsB,SAAe;CACnD,OAAO;AACT;AAEA,IAAa,oBAAoB;CAC/B,gBAAgB;CAChB,gBAAgB;CAChB,4BAA4B;EAC1B,aAAa;EACb,WAAW,OAAO,cAAc,cAAc,UAAU,YAAY,KAAA;EACpE,KAAK,OAAO,WAAW,cAAc,OAAO,SAAS,OAAO,KAAA;EAC5D,4BAAW,IAAI,KAAK,EAAA,CAAE,YAAY;CACpC;AACF;AAEA,IAAa,yBAAyB;AACtC,IAAa,gCAAgC;AAE7C,SAAgB,kCAAkC,iBAAoC;CACpF,OAAO;EACL,mBAAA;EACA;EACA;CACF;AACF;AAEA,SAAgB,6BAA6B,UAA2B;CACtE,OAAO,aAAa;AACtB;AAEA,SAAgB,oCAAoC,UAA2B;CAC7E,OAAO,6BAA6B,QAAQ;AAC9C;AAEA,SAAgB,aAAiC,CAEjD;AAMA,SAAgB,oBAA+B,CAE/C;AAEA,SAAgB,QAAQ,KAAa,SAAmC,WAAW,KAAa;CAC9F,OAAO;AACT;AAEA,SAAgB,cAAc,WAAW,IAAY;CACnD,OAAO;AACT;AAEA,SAAgB,iBAAuB;CACrC,OAAO;AACT;AAEA,SAAgB,YAAe,OAAgB,IAAgB;CAC7D,OAAO,GAAG;AACZ"}
|
package/dist/rsc/cacheTag.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* 导致 cacheTag 写入的 store 与 collectTags 读取的 store 不互通。
|
|
18
18
|
* 故本模块把 ALS 实例挂在 `globalThis` 上作为跨模块图单例(Symbol.for key)
|
|
19
19
|
*/
|
|
20
|
+
export { markUncacheable } from '../context/CacheTagContext';
|
|
20
21
|
/**
|
|
21
22
|
* 在独立的 tag 作用域中执行 fn —— 通常由 ISR 缓存中间件在每次请求前调用
|
|
22
23
|
*
|
|
@@ -24,14 +25,6 @@
|
|
|
24
25
|
* 写入本作用域,不会污染父作用域或兄弟请求
|
|
25
26
|
*/
|
|
26
27
|
export declare function runWithTagStore<T>(fn: () => T | Promise<T>): T | Promise<T>;
|
|
27
|
-
/**
|
|
28
|
-
* 在 Server Component / loader 内显式声明本次渲染产物**不应入缓存**。
|
|
29
|
-
* 适用场景:上游接口失败、降级渲染了一段错误提示 UI、命中风控/限流等
|
|
30
|
-
* —— 渲染结果是 200,但内容会让用户困惑或马上过期,不应被 ISR HIT 反复回放。
|
|
31
|
-
*
|
|
32
|
-
* 调用一次即可;后续 cacheTag(...) 仍可继续调用但不会改变 uncacheable 决定。
|
|
33
|
-
*/
|
|
34
|
-
export declare function markUncacheable(): void;
|
|
35
28
|
/** 读取本次渲染是否被标记为不可缓存(ISR 缓存中间件在响应捕获阶段调用) */
|
|
36
29
|
export declare function isUncacheable(): boolean;
|
|
37
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cacheTag.d.ts","sourceRoot":"","sources":["../../src/rsc/cacheTag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"cacheTag.d.ts","sourceRoot":"","sources":["../../src/rsc/cacheTag.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE3E;AAED,2CAA2C;AAC3C,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAUhD;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAGtC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAK,GAAG,IAAI,CAK9C"}
|
package/dist/rsc/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import {
|
|
1
|
+
import { C as getRequestId, S as getRequestContext, T as getUserId, a as isUncacheable, b as getAnonId, d as revalidatePath, f as revalidateTag, i as debugTagStore, l as registerInvalidator, n as cacheTag, o as runWithTagStore, r as collectTags, s as RevalidationError, t as getVariant, u as revalidateContent, w as getTraceId, x as getExperiments } from "../abVariantContext-yWZOqscY.js";
|
|
2
|
+
import { n as markUncacheable } from "../CacheTagContext-Btmq8KCD.js";
|
|
3
|
+
import { a as LEGACY_SERVER_ACTION_ENDPOINT, c as isLegacyServerActionEndpoint, d as createServerAction, f as serverActionsRegistry, i as getI18nLocale, l as shouldSkipServerActionEndpointRetry, n as runWithI18n, o as SERVER_ACTION_ENDPOINT, r as getI18n, s as getServerActionEndpointCandidates, t as getCurrentI18n, u as ServerActionUtils } from "../rsc-BYq2vvnh.js";
|
|
3
4
|
export { LEGACY_SERVER_ACTION_ENDPOINT, RevalidationError, SERVER_ACTION_ENDPOINT, ServerActionUtils, cacheTag, collectTags, createServerAction, debugTagStore, getAnonId, getCurrentI18n, getExperiments, getI18n, getI18nLocale, getRequestContext, getRequestId, getServerActionEndpointCandidates, getTraceId, getUserId, getVariant, isLegacyServerActionEndpoint, isUncacheable, markUncacheable, registerInvalidator, revalidateContent, revalidatePath, revalidateTag, runWithI18n, runWithTagStore, serverActionsRegistry, shouldSkipServerActionEndpointRetry };
|
package/dist/rsc/revalidate.d.ts
CHANGED
|
@@ -25,9 +25,10 @@
|
|
|
25
25
|
*
|
|
26
26
|
* 注意:
|
|
27
27
|
* - 本模块不持有任何缓存实现,纯做路由分发
|
|
28
|
-
* -
|
|
28
|
+
* - revalidatePath 与 revalidateTag 在无注册时保留 no-op;发布要求活跃的引擎运行时
|
|
29
29
|
*/
|
|
30
30
|
import { type ContentPublication, type ContentRevalidationOptions } from '../defaults/runtime/contentRevalidation';
|
|
31
|
+
import { type I18nConfig } from '../runtime/i18n';
|
|
31
32
|
/** Invalidator 签名:接收失效目标描述 */
|
|
32
33
|
export interface RevalidateInvalidator {
|
|
33
34
|
(target: RevalidateTarget): Promise<void> | void;
|
|
@@ -37,7 +38,7 @@ type ContentResponseInvalidator = (publication: ContentPublication) => Promise<v
|
|
|
37
38
|
* 注册一个 invalidator 实例(通常由 ISR 缓存中间件 / ISREngine 调用)
|
|
38
39
|
* 返回取消注册的函数
|
|
39
40
|
*/
|
|
40
|
-
export declare function registerInvalidator(fn: RevalidateInvalidator, invalidatePublication?: ContentResponseInvalidator): () => void;
|
|
41
|
+
export declare function registerInvalidator(fn: RevalidateInvalidator, invalidatePublication?: ContentResponseInvalidator, i18n?: I18nConfig): () => void;
|
|
41
42
|
/**
|
|
42
43
|
* 聚合失效错误 —— 当一个或多个 invalidator 失败时抛出。
|
|
43
44
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revalidate.d.ts","sourceRoot":"","sources":["../../src/rsc/revalidate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAChC,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"revalidate.d.ts","sourceRoot":"","sources":["../../src/rsc/revalidate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAChC,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9D,8BAA8B;AAC9B,MAAM,WAAW,qBAAqB;IACpC,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAClD;AAED,KAAK,0BAA0B,GAAG,CAAC,WAAW,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAkB5F;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,qBAAqB,EACzB,qBAAqB,CAAC,EAAE,0BAA0B,EAClD,IAAI,CAAC,EAAE,UAAU,GAChB,MAAM,IAAI,CAMZ;AAED;;;;;;;;;;GAUG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;gBAGvC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,SAAS,KAAK,EAAE;CAY3B;AAED,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,gBAAgB,EAAE,CAK/F;AA2DD;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;AAED,uFAAuF;AACvF,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAmC1F;AA8BD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,YAAY,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as getRequestContext, m as runtimeLogger } from "./abVariantContext-yWZOqscY.js";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
// src/rsc/ServerActions.ts
|
|
4
4
|
/**
|
|
@@ -159,4 +159,4 @@ function isIntlPayload(value) {
|
|
|
159
159
|
}
|
|
160
160
|
export { LEGACY_SERVER_ACTION_ENDPOINT as a, isLegacyServerActionEndpoint as c, createServerAction as d, serverActionsRegistry as f, getI18nLocale as i, shouldSkipServerActionEndpointRetry as l, runWithI18n as n, SERVER_ACTION_ENDPOINT as o, getI18n as r, getServerActionEndpointCandidates as s, getCurrentI18n as t, ServerActionUtils as u };
|
|
161
161
|
|
|
162
|
-
//# sourceMappingURL=rsc-
|
|
162
|
+
//# sourceMappingURL=rsc-BYq2vvnh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsc-
|
|
1
|
+
{"version":3,"file":"rsc-BYq2vvnh.js","names":["getCurrentI18n"],"sources":["../src/rsc/ServerActions.ts","../src/rsc/constants.ts","../src/runtime/i18n-store.ts","../src/defaults/runtime/i18n-server.ts"],"sourcesContent":["/**\n * Server Actions —— engine 级元数据注册\n *\n * 架构分工(方案 A 后):\n * - 协议传输:`@vitejs/plugin-rsc` 负责 encodeReply/decodeReply、loadServerAction、\n * Server Action 的 POST 路由、multipart 解码、响应 Flight 流等全部协议层工作\n * - 本模块职责:仅做元数据层面的注册表,供 engine 的调试 / 指标 / 管理面板使用\n *\n * 编写注意:\n * - 不重复实现执行/传输/序列化逻辑 —— 全部交给 plugin\n * - `createServerAction` 仅为便利 API:在 registry 中登记元数据,返回原函数\n * (不再伪造 `$$typeof`/`$$id` —— 这些由 plugin 的 transforms 在编译时注入到\n * `'use server'` 声明的模块导出上)\n */\n\nimport { runtimeLogger as logger } from '../logger/runtimeLogger';\n\nexport interface ServerActionMetadata {\n /** Action ID(应与 plugin 生成的 reference id 保持一致;自行注册时由调用方提供) */\n id: string;\n name: string;\n module?: string;\n line?: number;\n file?: string;\n}\n\nexport type ServerActionHandler = (...args: unknown[]) => Promise<unknown> | unknown;\n\nclass ServerActionsRegistry {\n private readonly metadata = new Map<string, ServerActionMetadata>();\n private initialized = false;\n\n async initialize(): Promise<void> {\n if (this.initialized) return;\n this.initialized = true;\n logger.info('✅ Server Actions Registry 已初始化');\n }\n\n async cleanup(): Promise<void> {\n this.metadata.clear();\n this.initialized = false;\n logger.info('✅ Server Actions Registry 已清理');\n }\n\n register(id: string, metadata: Omit<ServerActionMetadata, 'id'>): string {\n this.metadata.set(id, { id, ...metadata });\n return id;\n }\n\n getAllActions(): ServerActionMetadata[] {\n return Array.from(this.metadata.values());\n }\n\n hasAction(actionId: string): boolean {\n return this.metadata.has(actionId);\n }\n\n getMetadata(actionId: string): ServerActionMetadata | undefined {\n return this.metadata.get(actionId);\n }\n}\n\nexport const serverActionsRegistry = new ServerActionsRegistry();\n\n/**\n * 声明式注册:用于在服务端日志/管理面板中登记一个 action 的元数据\n *\n * 运行时执行请使用 `'use server'` 指令;本函数**不**改变执行语义,仅记录元数据\n */\nexport function createServerAction<T extends ServerActionHandler>(\n handler: T,\n metadata: Omit<ServerActionMetadata, 'id'> & { id: string }\n): T {\n serverActionsRegistry.register(metadata.id, metadata);\n return handler;\n}\n\nexport const ServerActionUtils = {\n isServer(): boolean {\n return typeof window === 'undefined';\n },\n isClient(): boolean {\n return typeof window !== 'undefined';\n },\n getExecutionContext() {\n if (this.isServer()) {\n return {\n environment: 'server' as const,\n nodeVersion: process.version,\n platform: process.platform,\n cwd: process.cwd(),\n };\n }\n return {\n environment: 'client' as const,\n userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : undefined,\n url: typeof window !== 'undefined' ? window.location.href : undefined,\n timestamp: new Date().toISOString(),\n };\n },\n};\n","/**\n * RSC / Flight 协议相关常量\n */\n\nexport const SERVER_ACTION_ENDPOINT = '/_rsc/action';\nexport const LEGACY_SERVER_ACTION_ENDPOINT = '/api/server-actions';\nexport const SERVER_ACTION_ENDPOINTS = [SERVER_ACTION_ENDPOINT, LEGACY_SERVER_ACTION_ENDPOINT];\n\nexport function getServerActionEndpointCandidates(primaryEndpoint?: string): string[] {\n const candidates = new Set<string>();\n const endpoint = primaryEndpoint || SERVER_ACTION_ENDPOINT;\n\n candidates.add(endpoint);\n candidates.add(SERVER_ACTION_ENDPOINT);\n candidates.add(LEGACY_SERVER_ACTION_ENDPOINT);\n\n return Array.from(candidates);\n}\n\nexport function isLegacyServerActionEndpoint(endpoint: string): boolean {\n return endpoint === LEGACY_SERVER_ACTION_ENDPOINT;\n}\n\nexport function shouldSkipServerActionEndpointRetry(endpoint: string): boolean {\n return isLegacyServerActionEndpoint(endpoint);\n}\n","import type { IntlPayload } from '../defaults/runtime/seo-runtime';\n\nexport type I18nParams = Record<string, string | number | boolean | null | undefined>;\n\nexport type Translate = (key: string, params?: I18nParams, fallback?: string) => string;\n\ntype ServerReader = () => IntlPayload | null | undefined;\n\ninterface I18nRuntimeState {\n clientIntl: IntlPayload | null;\n serverReader: ServerReader | null;\n keyPathCache: Map<string, string[]>;\n}\n\nconst I18N_RUNTIME_STATE_KEY = '__ISR_ENGINE_I18N_RUNTIME_STATE__';\n\nconst runtimeState = getRuntimeState();\n\nexport function setClientI18n(intl: IntlPayload | null | undefined): void {\n runtimeState.clientIntl = intl ?? null;\n}\n\nexport function registerServerI18nReader(reader: ServerReader): void {\n runtimeState.serverReader = reader;\n}\n\nexport function getCurrentI18n(): IntlPayload | null {\n return runtimeState.serverReader?.() ?? runtimeState.clientIntl;\n}\n\nexport function getI18nLocale(fallback = ''): string {\n return getCurrentI18n()?.locale ?? fallback;\n}\n\nexport const getI18n: Translate = (key, params, fallback = key) => {\n const value = readPath(getCurrentI18n()?.messages, key);\n const message = typeof value === 'string' && value.trim() ? value : fallback;\n return interpolate(message, params);\n};\n\nfunction readPath(source: unknown, key: string): unknown {\n let path = runtimeState.keyPathCache.get(key);\n if (!path) {\n path = key.split('.');\n runtimeState.keyPathCache.set(key, path);\n }\n\n let cur = source;\n for (const part of path) {\n if (!cur || typeof cur !== 'object' || !(part in cur)) return undefined;\n cur = (cur as Record<string, unknown>)[part];\n }\n return cur;\n}\n\nfunction getRuntimeState(): I18nRuntimeState {\n const globalState = globalThis as typeof globalThis & {\n [I18N_RUNTIME_STATE_KEY]?: I18nRuntimeState;\n };\n\n globalState[I18N_RUNTIME_STATE_KEY] ??= {\n clientIntl: null,\n serverReader: null,\n keyPathCache: new Map<string, string[]>(),\n };\n\n return globalState[I18N_RUNTIME_STATE_KEY];\n}\n\nfunction interpolate(message: string, params?: I18nParams): string {\n if (!params) return message;\n return message.replace(/\\{(\\w+)\\}/g, (match, name) => {\n const value = params[name];\n return value === undefined || value === null ? match : String(value);\n });\n}\n","import { AsyncLocalStorage } from 'node:async_hooks';\n\nimport type { IntlPayload } from './seo-runtime';\nimport { getI18n, getI18nLocale, registerServerI18nReader } from '../../runtime/i18n-store';\nimport { getRequestContext } from '../../context/RequestContext';\n\nconst store = new AsyncLocalStorage<IntlPayload | null>();\n\nexport function runWithI18n<T>(intl: IntlPayload | null | undefined, fn: () => T): T {\n return store.run(intl ?? null, fn);\n}\n\nexport function getCurrentI18n(): IntlPayload | null {\n const scoped = store.getStore();\n if (scoped) return scoped;\n const requestIntl = getRequestContext()?.intl;\n return isIntlPayload(requestIntl) ? requestIntl : null;\n}\n\nregisterServerI18nReader(getCurrentI18n);\n\nexport { getI18n, getI18nLocale };\nexport type { I18nParams, Translate } from '../../runtime/i18n-store';\n\nfunction isIntlPayload(value: unknown): value is IntlPayload {\n return !!value && typeof value === 'object' && typeof (value as IntlPayload).locale === 'string';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,IAAM,wBAAN,MAA4B;CAC1B,2BAA4B,IAAI,IAAkC;CAClE,cAAsB;CAEtB,MAAM,aAA4B;EAChC,IAAI,KAAK,aAAa;EACtB,KAAK,cAAc;EACnB,cAAO,KAAK,gCAAgC;CAC9C;CAEA,MAAM,UAAyB;EAC7B,KAAK,SAAS,MAAM;EACpB,KAAK,cAAc;EACnB,cAAO,KAAK,+BAA+B;CAC7C;CAEA,SAAS,IAAY,UAAoD;EACvE,KAAK,SAAS,IAAI,IAAI;GAAE;GAAI,GAAG;EAAS,CAAC;EACzC,OAAO;CACT;CAEA,gBAAwC;EACtC,OAAO,MAAM,KAAK,KAAK,SAAS,OAAO,CAAC;CAC1C;CAEA,UAAU,UAA2B;EACnC,OAAO,KAAK,SAAS,IAAI,QAAQ;CACnC;CAEA,YAAY,UAAoD;EAC9D,O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WAAW;AAC1F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentRevalidationRoute.d.ts","sourceRoot":"","sources":["../../src/server/contentRevalidationRoute.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,OAAO,EAAiD,MAAM,SAAS,CAAC;AAG/F,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AA+BrB,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAsBxF"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { RequestHandler } from 'express';
|
|
2
2
|
import type { ISRConfig, RequestLimitPolicy } from '../types/index.js';
|
|
3
|
+
type ReadOpsEndpoint = 'health' | 'metrics' | 'inventory';
|
|
4
|
+
type OpsEndpointName = ReadOpsEndpoint | 'contentRevalidation';
|
|
5
|
+
export declare const CONTENT_REVALIDATION_PATH = "/__isr/content/revalidate";
|
|
3
6
|
export interface ResolvedOpsEndpointConfig {
|
|
4
7
|
enabled: boolean;
|
|
5
8
|
public: boolean;
|
|
@@ -10,6 +13,7 @@ export interface ResolvedOpsConfig {
|
|
|
10
13
|
health: ResolvedOpsEndpointConfig;
|
|
11
14
|
metrics: ResolvedOpsEndpointConfig;
|
|
12
15
|
inventory: ResolvedOpsEndpointConfig;
|
|
16
|
+
contentRevalidation: ResolvedOpsEndpointConfig;
|
|
13
17
|
warnings: string[];
|
|
14
18
|
requestLimit?: RequestLimitPolicy;
|
|
15
19
|
}
|
|
@@ -19,5 +23,6 @@ export declare function getRuntimeOpsConfig(owner: object): ResolvedOpsConfig |
|
|
|
19
23
|
/** Share one ops admission budget across endpoint handlers owned by this runtime. */
|
|
20
24
|
export declare function getOpsRequestLimiter(resolved: ResolvedOpsConfig): RequestHandler;
|
|
21
25
|
export declare function resolveOpsConfig(config: Partial<ISRConfig> | undefined, env: 'development' | 'production'): ResolvedOpsConfig;
|
|
22
|
-
export declare function createOpsAuthMiddleware(endpoint:
|
|
26
|
+
export declare function createOpsAuthMiddleware(endpoint: OpsEndpointName, resolved: ResolvedOpsConfig): RequestHandler;
|
|
27
|
+
export {};
|
|
23
28
|
//# sourceMappingURL=opsConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opsConfig.d.ts","sourceRoot":"","sources":["../../src/server/opsConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"opsConfig.d.ts","sourceRoot":"","sources":["../../src/server/opsConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7D,KAAK,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AAC1D,KAAK,eAAe,GAAG,eAAe,GAAG,qBAAqB,CAAC;AAE/D,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,yBAAyB,CAAC;IAClC,OAAO,EAAE,yBAAyB,CAAC;IACnC,SAAS,EAAE,yBAAyB,CAAC;IACrC,mBAAmB,EAAE,yBAAyB,CAAC;IAC/C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAKD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAErF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEhF;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,cAAc,CAOhF;AA2DD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,EACtC,GAAG,EAAE,aAAa,GAAG,YAAY,GAChC,iBAAiB,CAkCnB;AAiED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,iBAAiB,GAC1B,cAAc,CA2BhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"productionRuntime.d.ts","sourceRoot":"","sources":["../../src/server/productionRuntime.ts"],"names":[],"mappings":"AAKA,OAAO,OAAO,EAAE,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"productionRuntime.d.ts","sourceRoot":"","sources":["../../src/server/productionRuntime.ts"],"names":[],"mappings":"AAKA,OAAO,OAAO,EAAE,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AAkChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAO5D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAWtC;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,MAAM,EAAE,CAS9F;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,aAAa,GAAG,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,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,GAC3D,OAAO,CAAC,cAAc,CAkBxB;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAyBrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publishedSitemap.d.ts","sourceRoot":"","sources":["../../src/server/publishedSitemap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"publishedSitemap.d.ts","sourceRoot":"","sources":["../../src/server/publishedSitemap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS;eA2BvD,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;;cAuB5C"}
|
|
@@ -180,6 +180,8 @@ export interface RuntimeSitemapConfig {
|
|
|
180
180
|
}) => readonly RuntimeSitemapEntry[] | Promise<readonly RuntimeSitemapEntry[]>;
|
|
181
181
|
/** Catalog cache TTL in milliseconds. Defaults to runtime.seo.ttl. */
|
|
182
182
|
ttl?: number;
|
|
183
|
+
/** Reuse a successful catalog on refresh errors for at most this long after expiry. Default 300000. */
|
|
184
|
+
staleIfErrorMs?: number;
|
|
183
185
|
}
|
|
184
186
|
export interface RuntimeSeoConfig {
|
|
185
187
|
/** 远端 SEO 端点;支持 {pathname} */
|
|
@@ -480,6 +482,8 @@ export interface ISRConfig {
|
|
|
480
482
|
enabled: boolean;
|
|
481
483
|
public: boolean;
|
|
482
484
|
};
|
|
485
|
+
/** Enable the authenticated Node production publication endpoint. Defaults to false. */
|
|
486
|
+
contentRevalidation?: boolean;
|
|
483
487
|
};
|
|
484
488
|
};
|
|
485
489
|
/** SSG 预生成配置 */
|
|
@@ -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,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,qDAAqD;IACrD,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,eAAe,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,0CAA0C;IAC1C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,0BAA0B;IAC1B,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAA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AAE,MAAM,GAAG,SAAS,CAAC;QACzB;;;;;;;WAOG;QACH,UAAU,EAAE,OAAO,CAAC;QACpB;;;;;;;;;;;WAWG;QACH,GAAG,EAAE;YACH,wEAAwE;YACxE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;YAC9B,0CAA0C;YAC1C,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,EAAE;gBACN,OAAO,EAAE,OAAO,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC;aACjB,CAAC;YACF,OAAO,EAAE;gBACP,OAAO,EAAE,OAAO,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC;aACjB,CAAC;YACF,SAAS,EAAE;gBACT,OAAO,EAAE,OAAO,CAAC;gBACjB,MAAM,EAAE,OAAO,CAAC;aACjB,CAAC;YACF,wFAAwF;YACxF,mBAAmB,CAAC,EAAE,OAAO,CAAC;SAC/B,CAAC;KACH,CAAC;IAEF,gBAAgB;IAChB,GAAG,EAAE;QACH,kDAAkD;QAClD,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,MAAM,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;QACnF,eAAe;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,2CAA2C;QAC3C,gBAAgB,EAAE,MAAM,CAAC;QACzB,0DAA0D;QAC1D,UAAU,EAAE,MAAM,CAAC;QACnB,4CAA4C;QAC5C,gBAAgB,EAAE,MAAM,CAAC;QACzB;;;WAGG;QACH,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isr-engine",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "ISR/SSG/Fallback rendering orchestration on Vite + React 19 RSC.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"test": "vitest run",
|
|
91
91
|
"pretest:browser": "pnpm run build",
|
|
92
92
|
"test:browser:production": "pnpm run build && playwright test --config playwright.production.config.ts",
|
|
93
|
-
"test:browser": "playwright test
|
|
93
|
+
"test:browser": "playwright test",
|
|
94
94
|
"bench": "node bench/runner.mjs",
|
|
95
95
|
"check": "pnpm run type-check && pnpm run lint && pnpm run test",
|
|
96
96
|
"audit:security": "pnpm audit --registry=https://registry.npmjs.org --audit-level=low",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
|
|
3
|
+
interface TagStore {
|
|
4
|
+
tags: Set<string>;
|
|
5
|
+
uncacheable: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// The Vite RSC bundle and the Node response cache share this request context.
|
|
9
|
+
const KEY = Symbol.for('isr-engine:cache-tag-als');
|
|
10
|
+
const runtime = globalThis as typeof globalThis & { [KEY]?: AsyncLocalStorage<TagStore> };
|
|
11
|
+
|
|
12
|
+
export function getCacheTagStorage(): AsyncLocalStorage<TagStore> {
|
|
13
|
+
return (runtime[KEY] ??= new AsyncLocalStorage<TagStore>());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Exclude a successful but degraded render from the shared response cache. */
|
|
17
|
+
export function markUncacheable(): void {
|
|
18
|
+
const store = getCacheTagStorage().getStore();
|
|
19
|
+
if (store) store.uncacheable = true;
|
|
20
|
+
}
|
|
@@ -19,6 +19,7 @@ import { injectRSCPayload } from 'rsc-html-stream/server';
|
|
|
19
19
|
import type { IntlPayload } from './runtime/seo-runtime';
|
|
20
20
|
import { setClientI18n } from '../runtime/i18n-store';
|
|
21
21
|
import { HydrationShell } from './runtime/hydration-shell';
|
|
22
|
+
import { createRenderErrorHandler, isRenderCancellation } from './runtime/renderCancellation';
|
|
22
23
|
// @ts-expect-error - 虚拟模块由 plugin-rsc 注入
|
|
23
24
|
import assetsManifest from 'virtual:vite-rsc/assets-manifest';
|
|
24
25
|
|
|
@@ -138,6 +139,7 @@ const CSR_SHELL_STYLES = `
|
|
|
138
139
|
export interface RenderHtmlOptions {
|
|
139
140
|
formState?: ReactFormState;
|
|
140
141
|
nonce?: string;
|
|
142
|
+
signal?: AbortSignal;
|
|
141
143
|
/** true 时跳过 bootstrap 脚本和 RSC 内联 payload,模拟禁用 JS 场景 */
|
|
142
144
|
debugNojs?: boolean;
|
|
143
145
|
/** 强制走 csr-shell 兜底(调试用 —— ?__csr-shell=1 触发) */
|
|
@@ -157,6 +159,8 @@ export async function renderHTML(
|
|
|
157
159
|
rscStream: ReadableStream<Uint8Array>,
|
|
158
160
|
options: RenderHtmlOptions = {}
|
|
159
161
|
): Promise<RenderHtmlResult> {
|
|
162
|
+
const { signal } = options;
|
|
163
|
+
signal?.throwIfAborted();
|
|
160
164
|
const [rscStream1, rscStream2] = rscStream.tee();
|
|
161
165
|
|
|
162
166
|
let payload: Promise<DefaultRscPayload> | undefined;
|
|
@@ -173,6 +177,7 @@ export async function renderHTML(
|
|
|
173
177
|
let htmlStream: ReadableStream<Uint8Array>;
|
|
174
178
|
let status: number | undefined;
|
|
175
179
|
let csrShellFallback = false;
|
|
180
|
+
const onError = createRenderErrorHandler(signal);
|
|
176
181
|
|
|
177
182
|
try {
|
|
178
183
|
if (options.forceCsrShell) throw new Error('forceCsrShell debug flag');
|
|
@@ -184,9 +189,12 @@ export async function renderHTML(
|
|
|
184
189
|
bootstrapScriptContent: options.debugNojs ? undefined : bootstrapScriptContent,
|
|
185
190
|
nonce: options.nonce,
|
|
186
191
|
formState: options.formState,
|
|
192
|
+
signal,
|
|
193
|
+
onError,
|
|
187
194
|
}
|
|
188
195
|
);
|
|
189
196
|
} catch (err) {
|
|
197
|
+
if (isRenderCancellation(signal, err)) throw err;
|
|
190
198
|
// FallbackChain 末端 csr-shell:SSR 渲染抛异常 → 不出 5xx 白屏,
|
|
191
199
|
// 改返回最小壳 HTML + self.__NO_HYDRATE=1,让浏览器走 createRoot 自救
|
|
192
200
|
csrShellFallback = true;
|
|
@@ -241,6 +249,8 @@ export async function renderHTML(
|
|
|
241
249
|
(options.apiBaseUrl ? `self.__API_BASE__=${JSON.stringify(options.apiBaseUrl)};` : '') +
|
|
242
250
|
(options.debugNojs ? '' : bootstrapScriptContent),
|
|
243
251
|
nonce: options.nonce,
|
|
252
|
+
signal,
|
|
253
|
+
onError,
|
|
244
254
|
}
|
|
245
255
|
);
|
|
246
256
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/** Data and response cache scopes to invalidate after a content write commits. */
|
|
2
2
|
export interface ContentRevalidationOptions {
|
|
3
|
+
/** Exact site paths, including any locale prefix. */
|
|
3
4
|
paths?: readonly string[];
|
|
5
|
+
/** Business pathnames expanded using the runtime's routing config and the supplied locales. */
|
|
6
|
+
localizedPaths?: readonly string[];
|
|
4
7
|
tags?: readonly string[];
|
|
5
8
|
locales?: readonly string[];
|
|
6
9
|
sitemap?: boolean;
|
|
@@ -8,7 +11,7 @@ export interface ContentRevalidationOptions {
|
|
|
8
11
|
|
|
9
12
|
export interface ContentPublication {
|
|
10
13
|
id: string;
|
|
11
|
-
scopes: Readonly<Required<ContentRevalidationOptions>>;
|
|
14
|
+
scopes: Readonly<Omit<Required<ContentRevalidationOptions>, 'localizedPaths'>>;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
type ContentInvalidation = ContentPublication['scopes'] & { allPageMetadata?: true };
|
|
@@ -63,11 +66,13 @@ export function invalidateContentCaches(
|
|
|
63
66
|
if (errors.length) throw new AggregateError(errors, 'Content metadata invalidation failed');
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
export function normalizeContentScopes(
|
|
69
|
+
export function normalizeContentScopes(
|
|
70
|
+
input: unknown
|
|
71
|
+
): ContentPublication['scopes'] & Pick<ContentRevalidationOptions, 'localizedPaths'> {
|
|
67
72
|
if (!input || typeof input !== 'object' || Array.isArray(input)) {
|
|
68
73
|
throw new TypeError('Invalid content revalidation scopes');
|
|
69
74
|
}
|
|
70
|
-
const { paths, tags, locales, sitemap } = input as ContentRevalidationOptions;
|
|
75
|
+
const { paths, localizedPaths, tags, locales, sitemap } = input as ContentRevalidationOptions;
|
|
71
76
|
function read(values: unknown): string[] {
|
|
72
77
|
if (values === undefined) return [];
|
|
73
78
|
if (
|
|
@@ -83,6 +88,7 @@ export function normalizeContentScopes(input: unknown): ContentPublication['scop
|
|
|
83
88
|
}
|
|
84
89
|
return {
|
|
85
90
|
paths: [...new Set(read(paths))],
|
|
91
|
+
...(localizedPaths !== undefined && { localizedPaths: [...new Set(read(localizedPaths))] }),
|
|
86
92
|
tags: [...new Set(read(tags))],
|
|
87
93
|
locales: [...new Set(read(locales).map(locale => locale.trim().toLowerCase()))],
|
|
88
94
|
sitemap: sitemap ?? false,
|
|
@@ -58,13 +58,17 @@ export interface CachedFetcherOptions<TArg, TValue> {
|
|
|
58
58
|
/** 从入参生成缓存 key */
|
|
59
59
|
key: (arg: TArg) => string;
|
|
60
60
|
/** 实际加载逻辑(network / fs / dynamic import 都可) */
|
|
61
|
-
fetch: (arg: TArg) => Promise<TValue>;
|
|
61
|
+
fetch: (arg: TArg, markDegraded?: () => void) => Promise<TValue>;
|
|
62
62
|
/** 缓存 TTL(毫秒),默认 60s */
|
|
63
63
|
ttl?: number;
|
|
64
64
|
/** LRU 容量,默认 500 */
|
|
65
65
|
max?: number;
|
|
66
66
|
/** 启用 stale-while-revalidate:过期仍返回旧值,后台异步刷新(默认 false) */
|
|
67
67
|
swr?: boolean;
|
|
68
|
+
/** Maximum time after expiry to reuse the last successful value on refresh errors. */
|
|
69
|
+
staleIfErrorMs?: number;
|
|
70
|
+
/** Called in each consumer's context when it receives a stale or degraded result. */
|
|
71
|
+
onDegraded?: () => void;
|
|
68
72
|
/** 拉取失败时的回退值(如不提供则抛错) */
|
|
69
73
|
fallback?: (arg: TArg, error: unknown) => TValue | Promise<TValue>;
|
|
70
74
|
}
|
|
@@ -75,6 +79,11 @@ interface Entry<TArg, TValue> {
|
|
|
75
79
|
expiresAt: number;
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
interface LoadResult<TValue> {
|
|
83
|
+
value: TValue;
|
|
84
|
+
degraded: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
78
87
|
export type CachedFetcher<TArg, TValue> = (arg: TArg) => Promise<TValue>;
|
|
79
88
|
|
|
80
89
|
export function createCachedFetcher<TArg, TValue>(
|
|
@@ -82,27 +91,50 @@ export function createCachedFetcher<TArg, TValue>(
|
|
|
82
91
|
): CachedFetcher<TArg, TValue> & { invalidate(matches?: (arg: TArg) => boolean): void } {
|
|
83
92
|
const ttl = opts.ttl ?? 60_000;
|
|
84
93
|
const max = opts.max ?? 500;
|
|
85
|
-
|
|
94
|
+
const staleIfErrorMs = opts.staleIfErrorMs ?? 0;
|
|
95
|
+
if (!Number.isSafeInteger(staleIfErrorMs) || staleIfErrorMs < 0) {
|
|
96
|
+
throw new RangeError('staleIfErrorMs must be a non-negative safe integer');
|
|
97
|
+
}
|
|
98
|
+
type Flight = { arg: TArg; promise?: Promise<LoadResult<TValue>> };
|
|
86
99
|
const cache = new TinyLRU<string, Entry<TArg, TValue>>(max);
|
|
87
100
|
const inflight = new Map<string, Flight>();
|
|
88
101
|
|
|
89
|
-
async function load(
|
|
102
|
+
async function load(
|
|
103
|
+
key: string,
|
|
104
|
+
flight: Flight,
|
|
105
|
+
previous?: Entry<TArg, TValue>
|
|
106
|
+
): Promise<LoadResult<TValue>> {
|
|
90
107
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
let degraded = false;
|
|
109
|
+
const value = await opts.fetch(flight.arg, () => {
|
|
110
|
+
degraded = true;
|
|
111
|
+
});
|
|
112
|
+
if (!degraded && inflight.get(key) === flight) {
|
|
93
113
|
cache.set(key, { arg: flight.arg, value, expiresAt: Date.now() + ttl });
|
|
94
114
|
}
|
|
95
|
-
return value;
|
|
115
|
+
return { value, degraded };
|
|
96
116
|
} catch (err) {
|
|
97
|
-
if (
|
|
117
|
+
if (
|
|
118
|
+
previous &&
|
|
119
|
+
staleIfErrorMs > 0 &&
|
|
120
|
+
inflight.get(key) === flight &&
|
|
121
|
+
Date.now() - previous.expiresAt < staleIfErrorMs
|
|
122
|
+
) {
|
|
123
|
+
return { value: previous.value, degraded: true };
|
|
124
|
+
}
|
|
125
|
+
if (opts.fallback) return { value: await opts.fallback(flight.arg, err), degraded: true };
|
|
98
126
|
throw err;
|
|
99
127
|
}
|
|
100
128
|
}
|
|
101
129
|
|
|
102
|
-
function startLoad(
|
|
130
|
+
function startLoad(
|
|
131
|
+
key: string,
|
|
132
|
+
arg: TArg,
|
|
133
|
+
previous?: Entry<TArg, TValue>
|
|
134
|
+
): Promise<LoadResult<TValue>> {
|
|
103
135
|
const flight: Flight = { arg };
|
|
104
136
|
inflight.set(key, flight);
|
|
105
|
-
flight.promise = load(key, flight).finally(() => {
|
|
137
|
+
flight.promise = load(key, flight, previous).finally(() => {
|
|
106
138
|
if (inflight.get(key) === flight) inflight.delete(key);
|
|
107
139
|
});
|
|
108
140
|
return flight.promise;
|
|
@@ -124,11 +156,14 @@ export function createCachedFetcher<TArg, TValue>(
|
|
|
124
156
|
/* 后台刷新失败保留旧值 */
|
|
125
157
|
});
|
|
126
158
|
}
|
|
159
|
+
opts.onDegraded?.();
|
|
127
160
|
return entry.value;
|
|
128
161
|
}
|
|
129
162
|
|
|
130
163
|
// miss 或非 SWR 过期:合并并发到同一个 promise
|
|
131
|
-
|
|
164
|
+
const result = await (inflight.get(key)?.promise ?? startLoad(key, arg, entry));
|
|
165
|
+
if (result.degraded) opts.onDegraded?.();
|
|
166
|
+
return result.value;
|
|
132
167
|
}
|
|
133
168
|
|
|
134
169
|
cachedFetcher.invalidate = (matches: (arg: TArg) => boolean = () => true): void => {
|