@timber-js/app 0.2.0-alpha.220 → 0.2.0-alpha.221
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/dist/_chunks/{actions-BwkmAYXq.js → actions-BDqn4Oxj.js} +2 -2
- package/dist/_chunks/{actions-BwkmAYXq.js.map → actions-BDqn4Oxj.js.map} +1 -1
- package/dist/_chunks/{cache-api-LA3sBpUS.js → cache-api-GE4AOe2H.js} +30 -151
- package/dist/_chunks/cache-api-GE4AOe2H.js.map +1 -0
- package/dist/_chunks/dev-server-BiWNMBVU.js +1 -0
- package/dist/_chunks/{dev-server-DnODXuNM.js → dev-server-DIy-SY-J.js} +11 -6
- package/dist/_chunks/{dev-server-DnODXuNM.js.map → dev-server-DIy-SY-J.js.map} +1 -1
- package/dist/_chunks/dev-store-BOa304m_.js +283 -0
- package/dist/_chunks/dev-store-BOa304m_.js.map +1 -0
- package/dist/_chunks/{error-boundary-xxxLtXt6.js → error-boundary-Bc8QPZuq.js} +71 -21
- package/dist/_chunks/error-boundary-Bc8QPZuq.js.map +1 -0
- package/dist/_chunks/{flight-source-node-0dE-t3kq.js → flight-source-node-HptmGMT8.js} +6 -7
- package/dist/_chunks/flight-source-node-HptmGMT8.js.map +1 -0
- package/dist/_chunks/{node-response-Dibufw_b.js → node-response-rkQqcFGq.js} +48 -2
- package/dist/_chunks/node-response-rkQqcFGq.js.map +1 -0
- package/dist/_chunks/{purge-store-Byr8XOjU.js → purge-store-WZaxu-3m.js} +2 -2
- package/dist/_chunks/purge-store-WZaxu-3m.js.map +1 -0
- package/dist/_chunks/{render-timeout-DOf_BBcO.js → render-timeout-joFhz4KH.js} +1 -10
- package/dist/_chunks/render-timeout-joFhz4KH.js.map +1 -0
- package/dist/cache/cache-api.d.ts.map +1 -1
- package/dist/cache/handler-store.d.ts +13 -1
- package/dist/cache/handler-store.d.ts.map +1 -1
- package/dist/cache/index.js +2 -1
- package/dist/cache/invalidation-epoch.d.ts +7 -0
- package/dist/cache/invalidation-epoch.d.ts.map +1 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/purge-store.d.ts +10 -1
- package/dist/cdn/purge-store.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/error-boundary.js +1 -1
- package/dist/client/index.js +6 -15
- package/dist/client/index.js.map +1 -1
- package/dist/client/internal.js +37 -64
- package/dist/client/internal.js.map +1 -1
- package/dist/client/link.d.ts.map +1 -1
- package/dist/client/navigation-transition.d.ts +68 -14
- package/dist/client/navigation-transition.d.ts.map +1 -1
- package/dist/client/router-effects.d.ts +35 -31
- package/dist/client/router-effects.d.ts.map +1 -1
- package/dist/client/router-pipeline.d.ts +2 -6
- package/dist/client/router-pipeline.d.ts.map +1 -1
- package/dist/client/router-types.d.ts +10 -30
- package/dist/client/router-types.d.ts.map +1 -1
- package/dist/client/router.d.ts.map +1 -1
- package/dist/dev-tools/logs.d.ts +2 -2
- package/dist/dev-tools/logs.d.ts.map +1 -1
- package/dist/index.js +144 -51
- package/dist/index.js.map +1 -1
- package/dist/plugins/dev-server.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts +5 -0
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/orphaned-modules.d.ts +57 -0
- package/dist/plugins/orphaned-modules.d.ts.map +1 -0
- package/dist/plugins/prebuilt.d.ts +6 -6
- package/dist/plugins/prerender-sugar.d.ts.map +1 -1
- package/dist/plugins/routing.d.ts +1 -1
- package/dist/plugins/routing.d.ts.map +1 -1
- package/dist/rsc-runtime/dev-reference-cache.d.ts +47 -0
- package/dist/rsc-runtime/dev-reference-cache.d.ts.map +1 -0
- package/dist/rsc-runtime/rsc.d.ts +0 -15
- package/dist/rsc-runtime/rsc.d.ts.map +1 -1
- package/dist/rsc-runtime/ssr.d.ts +0 -11
- package/dist/rsc-runtime/ssr.d.ts.map +1 -1
- package/dist/server/abort-scope.d.ts +27 -0
- package/dist/server/abort-scope.d.ts.map +1 -0
- package/dist/server/flight-source-node.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/instrumentation.d.ts +2 -1
- package/dist/server/instrumentation.d.ts.map +1 -1
- package/dist/server/internal.d.ts +1 -1
- package/dist/server/internal.d.ts.map +1 -1
- package/dist/server/internal.js +328 -132
- package/dist/server/internal.js.map +1 -1
- package/dist/server/pipeline-helpers.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +10 -7
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/prebuilt/cache-key.d.ts +26 -0
- package/dist/server/prebuilt/cache-key.d.ts.map +1 -1
- package/dist/server/prebuilt/capture-render.d.ts +9 -4
- package/dist/server/prebuilt/capture-render.d.ts.map +1 -1
- package/dist/server/prebuilt/capture-routes.d.ts +1 -1
- package/dist/server/prebuilt/dev-store.d.ts +103 -0
- package/dist/server/prebuilt/dev-store.d.ts.map +1 -0
- package/dist/server/prebuilt/overlay.d.ts +5 -0
- package/dist/server/prebuilt/overlay.d.ts.map +1 -1
- package/dist/server/prebuilt/payload-source.d.ts +8 -0
- package/dist/server/prebuilt/payload-source.d.ts.map +1 -1
- package/dist/server/prebuilt/slots.d.ts +5 -6
- package/dist/server/prebuilt/slots.d.ts.map +1 -1
- package/dist/server/prebuilt-builder.d.ts.map +1 -1
- package/dist/server/prebuilt-runtime.d.ts +5 -10
- package/dist/server/prebuilt-runtime.d.ts.map +1 -1
- package/dist/server/render-timeout.d.ts.map +1 -1
- package/dist/server/rsc-entry/action-dispatcher.d.ts.map +1 -1
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/ssr-render.d.ts.map +1 -1
- package/docs/api/32-api-cache.mdx +2 -0
- package/docs/learn/10-caching.mdx +12 -0
- package/docs/learn/11-middleware.mdx +2 -0
- package/package.json +1 -1
- package/src/cache/cache-api.ts +7 -1
- package/src/cache/handler-store.ts +38 -1
- package/src/cache/invalidation-epoch.ts +18 -6
- package/src/cache/timber-cache.ts +6 -2
- package/src/cdn/purge-store.ts +29 -1
- package/src/client/browser-entry/action-dispatch.ts +5 -5
- package/src/client/browser-entry/router-init.ts +2 -4
- package/src/client/link.tsx +14 -18
- package/src/client/navigation-transition.ts +86 -33
- package/src/client/router-effects.ts +70 -45
- package/src/client/router-lifecycle.ts +1 -1
- package/src/client/router-pipeline.ts +52 -65
- package/src/client/router-types.ts +11 -31
- package/src/client/router.ts +98 -104
- package/src/dev-tools/logs.ts +76 -50
- package/src/plugins/dev-server.ts +23 -8
- package/src/plugins/entries.ts +6 -0
- package/src/plugins/orphaned-modules.ts +78 -0
- package/src/plugins/prebuilt.ts +17 -17
- package/src/plugins/prerender-sugar.ts +38 -6
- package/src/plugins/routing.ts +23 -1
- package/src/rsc-runtime/dev-reference-cache.ts +115 -0
- package/src/rsc-runtime/rsc.ts +10 -0
- package/src/rsc-runtime/ssr.ts +10 -0
- package/src/server/abort-scope.ts +49 -0
- package/src/server/flight-source-node.ts +5 -4
- package/src/server/instrumentation.ts +32 -8
- package/src/server/internal.ts +1 -6
- package/src/server/pipeline-helpers.ts +5 -3
- package/src/server/pipeline.ts +31 -20
- package/src/server/prebuilt/cache-key.ts +41 -0
- package/src/server/prebuilt/capture-render.ts +10 -6
- package/src/server/prebuilt/capture-routes.ts +1 -1
- package/src/server/prebuilt/dev-store.ts +173 -0
- package/src/server/prebuilt/overlay.ts +7 -1
- package/src/server/prebuilt/payload-source.ts +19 -0
- package/src/server/prebuilt/slots.ts +5 -6
- package/src/server/prebuilt-builder.ts +3 -2
- package/src/server/prebuilt-runtime.ts +174 -176
- package/src/server/render-timeout.ts +12 -17
- package/src/server/rsc-entry/action-dispatcher.ts +3 -1
- package/src/server/rsc-entry/index.ts +47 -13
- package/src/server/ssr-render.ts +9 -11
- package/dist/_chunks/cache-api-LA3sBpUS.js.map +0 -1
- package/dist/_chunks/dev-server-DkytOEG2.js +0 -1
- package/dist/_chunks/error-boundary-xxxLtXt6.js.map +0 -1
- package/dist/_chunks/flight-source-node-0dE-t3kq.js.map +0 -1
- package/dist/_chunks/node-response-Dibufw_b.js.map +0 -1
- package/dist/_chunks/purge-store-Byr8XOjU.js.map +0 -1
- package/dist/_chunks/render-timeout-DOf_BBcO.js.map +0 -1
package/dist/server/internal.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { r as
|
|
1
|
+
import { c as drainWithDeadline, d as onAbortUntil, i as withResponseInit, n as discardResponseBody, o as concatBytes, r as nodeBodyOps, u as wrapResponseWithStreamTiming } from "../_chunks/node-response-rkQqcFGq.js";
|
|
2
|
+
import { r as RenderTimeoutError, t as DEFAULT_RENDER_TIMEOUT_MS } from "../_chunks/render-timeout-joFhz4KH.js";
|
|
2
3
|
import { n as isRscContentType, r as isRscRequest } from "../_chunks/rsc-media-type-DDc7duTD.js";
|
|
3
4
|
import { i as getMetadataRouteServePath, n as classifyMetadataRoute, r as getMetadataRouteAutoLink, t as METADATA_ROUTE_CONVENTIONS } from "../_chunks/metadata-routes-B3XJNyIH.js";
|
|
4
5
|
import { i as canonicalize, r as canonicalRequestPath } from "../_chunks/canonicalize-BAWkWiKK.js";
|
|
6
|
+
import { a as discardDevEntry, c as isDevPrebuiltCacheBypassed, d as setDevSeed, f as currentInvalidationEpoch, h as wasInvalidatedSince, l as isDevPrebuiltStoreActive, n as clearDevPrebuiltStore, o as getDevSeed, p as lastInvalidationEpochFor, u as isHardReload } from "../_chunks/dev-store-BOa304m_.js";
|
|
5
7
|
import { n as classifyUrlSegment, r as effectiveUrlSegment } from "../_chunks/segment-classify-C539Pa2O.js";
|
|
6
8
|
import { t as computeSegmentTreePaths } from "../_chunks/segment-keys-D5hu1hz4.js";
|
|
7
9
|
import { i as requestContextAls, n as prebuiltCaptureAls, o as timingAls, t as earlyHintsSenderAls } from "../_chunks/als-registry-BZqHCtq-.js";
|
|
8
10
|
import { C as isRedirectSignal, F as withSpan, M as replaceTraceId, N as runWithTraceId, O as generateTraceId, P as setSpanAttribute, S as isDenySignal, _ as setLogger, a as logMiddlewareError, c as logRenderError, d as logRouteError, f as logRouteSetupError, g as logWaitUntilUnsupported, h as logWaitUntilRejected, j as getTraceId, k as getOtelTraceId, l as logRequestCompleted, m as logSwrRefetchFailed, n as logCacheMiss, o as logMiddlewareShortCircuit, p as logSlowRequest, r as logCsrfRejected, s as logProxyError, t as getLogger, u as logRequestReceived, v as swallow, w as isDebug, x as isControlFlowSignal } from "../_chunks/logger-CbLdcy-W.js";
|
|
9
11
|
import { i as collectRouteModulepreloads, n as collectRouteCss, r as collectRouteFonts } from "../_chunks/build-manifest-DWppEdLB.js";
|
|
10
12
|
import { i as isRscCacheKeyShape, n as RSC_KEY_PARAM, r as appVisibleSearch, s as rscCacheKey, t as RSC_KEY_HEADERS } from "../_chunks/rsc-cache-key-ClUiXQnK.js";
|
|
11
|
-
import { C as setMutableCookieContext, S as setMatchedSegmentPath, T as runOutsideReactCacheScope, b as markResponseFlushed, f as getCookie, g as getHeader, h as applyRequestHeaderOverlay, i as coerce, m as getSetCookieHeaders, o as DenySignal, s as RedirectSignal, t as executeAction, v as getSearchParams, w as setSegmentParams, x as runWithRequestContext, y as getSegmentParams } from "../_chunks/actions-
|
|
12
|
-
import { a as
|
|
13
|
+
import { C as setMutableCookieContext, S as setMatchedSegmentPath, T as runOutsideReactCacheScope, b as markResponseFlushed, f as getCookie, g as getHeader, h as applyRequestHeaderOverlay, i as coerce, m as getSetCookieHeaders, o as DenySignal, s as RedirectSignal, t as executeAction, v as getSearchParams, w as setSegmentParams, x as runWithRequestContext, y as getSegmentParams } from "../_chunks/actions-BDqn4Oxj.js";
|
|
14
|
+
import { a as hasPrebuiltPayloadSource, c as setPrebuiltPayloadSource, h as getWaitUntil, i as storeOverlayEntry, l as applyReloadHeaders, n as lookupOverlay, o as isParamIndependent, r as overlayKey, s as lookupArtifactSeed, u as checkVersionSkew } from "../_chunks/cache-api-GE4AOe2H.js";
|
|
13
15
|
import { n as createSingleflight } from "../_chunks/singleflight-BeVMMKi0.js";
|
|
14
|
-
import { c as drainWithDeadline, i as withResponseInit, n as discardResponseBody, o as concatBytes, r as nodeBodyOps, u as wrapResponseWithStreamTiming } from "../_chunks/node-response-Dibufw_b.js";
|
|
15
16
|
import { n as toBracketKey } from "../_chunks/resolve-schema-CBR6Lm4i.js";
|
|
16
17
|
import { t as normalizeParamValue } from "../_chunks/param-value-C8TNYchQ.js";
|
|
17
18
|
import { l as TIMBER_ERROR_HEADER, t as StatusPageMarker } from "../_chunks/status-page-marker-BRX9Ib-d.js";
|
|
@@ -119,7 +120,17 @@ function getServerTimingHeader() {
|
|
|
119
120
|
*
|
|
120
121
|
* See design/17-logging.md §"instrumentation.ts — The Entry Point"
|
|
121
122
|
*/
|
|
122
|
-
|
|
123
|
+
/**
|
|
124
|
+
* The loader the current hooks came from. One app passes one loader
|
|
125
|
+
* (`virtual:timber-instrumentation`), so a second call with it is a no-op.
|
|
126
|
+
* In dev a new loader means instrumentation.ts changed: the RSC entry is an
|
|
127
|
+
* HMR boundary (design/21 §HMR Wiring), so editing instrumentation.ts
|
|
128
|
+
* re-executes the virtual loader module and the entry, while this module
|
|
129
|
+
* keeps its state. The new module then replaces the old one's hooks.
|
|
130
|
+
*/
|
|
131
|
+
var _loadedFrom = null;
|
|
132
|
+
/** The framework logger before any instrumentation module replaced it. */
|
|
133
|
+
var _loggerBeforeLoad = null;
|
|
123
134
|
var _onRequestError = null;
|
|
124
135
|
/**
|
|
125
136
|
* Load and initialize the user's instrumentation.ts module.
|
|
@@ -132,8 +143,13 @@ var _onRequestError = null;
|
|
|
132
143
|
* Returns null if no instrumentation.ts exists.
|
|
133
144
|
*/
|
|
134
145
|
async function loadInstrumentation(loader) {
|
|
135
|
-
if (
|
|
136
|
-
|
|
146
|
+
if (_loadedFrom === loader) return;
|
|
147
|
+
if (_loadedFrom === null) _loggerBeforeLoad = getLogger();
|
|
148
|
+
else {
|
|
149
|
+
_onRequestError = null;
|
|
150
|
+
setLogger(_loggerBeforeLoad);
|
|
151
|
+
}
|
|
152
|
+
_loadedFrom = loader;
|
|
137
153
|
let mod;
|
|
138
154
|
try {
|
|
139
155
|
mod = await loader();
|
|
@@ -148,6 +164,9 @@ async function loadInstrumentation(loader) {
|
|
|
148
164
|
await mod.register();
|
|
149
165
|
} catch (error) {
|
|
150
166
|
console.error("[timber] instrumentation.ts register() threw:", error);
|
|
167
|
+
_onRequestError = null;
|
|
168
|
+
if (_loggerBeforeLoad) setLogger(_loggerBeforeLoad);
|
|
169
|
+
_loadedFrom = null;
|
|
151
170
|
throw error;
|
|
152
171
|
}
|
|
153
172
|
}
|
|
@@ -745,14 +764,14 @@ async function runBackgroundFlight(signal, work, log) {
|
|
|
745
764
|
const request = requestContextAls.getStore()?.request;
|
|
746
765
|
if (request && isReportableError(error)) fireInBackground(callHook(error, request, "render"));
|
|
747
766
|
};
|
|
748
|
-
const
|
|
749
|
-
signal
|
|
767
|
+
const settled = new AbortController();
|
|
768
|
+
onAbortUntil(signal, () => failed(signal.reason), settled.signal);
|
|
750
769
|
try {
|
|
751
770
|
await work();
|
|
752
771
|
} catch (error) {
|
|
753
772
|
if (!signal.aborted) failed(error);
|
|
754
773
|
} finally {
|
|
755
|
-
|
|
774
|
+
settled.abort();
|
|
756
775
|
}
|
|
757
776
|
}
|
|
758
777
|
function reportedPhase(source, apiRoute) {
|
|
@@ -1916,7 +1935,7 @@ function createPipeline(config) {
|
|
|
1916
1935
|
const slowRequestMs = config.slowRequestMs ?? 3e3;
|
|
1917
1936
|
const serverTiming = config.serverTiming ?? "total";
|
|
1918
1937
|
let activeRequests = 0;
|
|
1919
|
-
|
|
1938
|
+
return async (req) => {
|
|
1920
1939
|
const url = new URL(req.url);
|
|
1921
1940
|
const method = req.method;
|
|
1922
1941
|
const path = url.pathname;
|
|
@@ -1962,7 +1981,8 @@ function createPipeline(config) {
|
|
|
1962
1981
|
const redirect = canonicalRedirect(req, canonicalPath, stripTrailingSlash, config.matchRoute);
|
|
1963
1982
|
if (redirect) return redirect;
|
|
1964
1983
|
if (config.dispatchAction) {
|
|
1965
|
-
const
|
|
1984
|
+
const reenter = (rerenderReq, reentry) => runWithRequestContext(rerenderReq, () => handleRequest(config, rerenderReq, rerenderReq.method, canonicalPath, true), reentry);
|
|
1985
|
+
const actionResult = await config.dispatchAction(canonicalReq, canonicalPath, reenter);
|
|
1966
1986
|
if (actionResult) return actionResult;
|
|
1967
1987
|
}
|
|
1968
1988
|
return handleRequest(config, canonicalReq, method, canonicalPath, true);
|
|
@@ -2025,14 +2045,9 @@ function createPipeline(config) {
|
|
|
2025
2045
|
};
|
|
2026
2046
|
return serverTiming === "detailed" ? runWithTimingCollector(runRequest) : runRequest();
|
|
2027
2047
|
};
|
|
2028
|
-
return runWithRequestContext(req, inRequestContext
|
|
2029
|
-
cookies: reentry?.cookies,
|
|
2030
|
-
formState: reentry?.formState,
|
|
2031
|
-
actionError: reentry?.actionError
|
|
2032
|
-
});
|
|
2048
|
+
return runWithRequestContext(req, inRequestContext);
|
|
2033
2049
|
});
|
|
2034
2050
|
};
|
|
2035
|
-
return pipelineFn;
|
|
2036
2051
|
}
|
|
2037
2052
|
//#endregion
|
|
2038
2053
|
//#region src/server/early-hints.ts
|
|
@@ -3706,6 +3721,42 @@ function computeComponentCacheKey(props, params) {
|
|
|
3706
3721
|
}
|
|
3707
3722
|
return createHash("sha256").update(canonical).digest("hex").slice(0, 16);
|
|
3708
3723
|
}
|
|
3724
|
+
/**
|
|
3725
|
+
* Resolve the params the cache key may faithfully hash, or null if this
|
|
3726
|
+
* render is unkeyable.
|
|
3727
|
+
*
|
|
3728
|
+
* A wrapper rendered inside a parallel slot reads params merged with that
|
|
3729
|
+
* slot's overrides (`getSegmentParams`: `{...segmentParams, ...slotParams}`)
|
|
3730
|
+
* — but the cache key hashes only the route-level params, and the wrapper
|
|
3731
|
+
* cannot know which slot it renders under. The route params are usable
|
|
3732
|
+
* only when every slot's merged view canonicalizes identically to them;
|
|
3733
|
+
* otherwise two renders with the same key could see different effective
|
|
3734
|
+
* inputs and a hit could serve the WRONG cached subtree — so the render
|
|
3735
|
+
* goes live: slower, never wrong. (Build-time capture doesn't model slot
|
|
3736
|
+
* params either, so a divergent request could never have a faithful
|
|
3737
|
+
* entry. Codex review on PR #835; revisit with segment-path-scoped keys
|
|
3738
|
+
* if slot-scoped prebuilt is ever needed.)
|
|
3739
|
+
*
|
|
3740
|
+
* Comparison happens through `tryCanonicalize` — the same single
|
|
3741
|
+
* definition of value equality the cache key uses — so anything it
|
|
3742
|
+
* cannot represent faithfully (bigint-coerced codec params, accessors,
|
|
3743
|
+
* aliases, …) is unkeyable here too, and this guard can never throw.
|
|
3744
|
+
*/
|
|
3745
|
+
function resolveKeyParams(store) {
|
|
3746
|
+
const main = store.segmentParams ?? {};
|
|
3747
|
+
const slots = store.slotParams;
|
|
3748
|
+
if (!slots || Object.keys(slots).length === 0) return main;
|
|
3749
|
+
const mainCanonical = tryCanonicalize({ ...main });
|
|
3750
|
+
if (mainCanonical === null) return null;
|
|
3751
|
+
for (const slotParams of Object.values(slots)) {
|
|
3752
|
+
const merged = tryCanonicalize({
|
|
3753
|
+
...main,
|
|
3754
|
+
...slotParams
|
|
3755
|
+
});
|
|
3756
|
+
if (merged === null || merged !== mainCanonical) return null;
|
|
3757
|
+
}
|
|
3758
|
+
return main;
|
|
3759
|
+
}
|
|
3709
3760
|
//#endregion
|
|
3710
3761
|
//#region src/client/slot-context.ts
|
|
3711
3762
|
/**
|
|
@@ -3891,6 +3942,37 @@ function warnNestingClamps(outer, nested, warnedPairs, log) {
|
|
|
3891
3942
|
}
|
|
3892
3943
|
return count;
|
|
3893
3944
|
}
|
|
3945
|
+
//#endregion
|
|
3946
|
+
//#region src/server/prebuilt/slots.ts
|
|
3947
|
+
/**
|
|
3948
|
+
* Slot-component helpers for cache.component (TIM-1173).
|
|
3949
|
+
*
|
|
3950
|
+
* A `slots: ['children', ...]` declaration caches the component's output
|
|
3951
|
+
* as a shell with a stable <SlotOutlet slot={name} /> client-reference
|
|
3952
|
+
* hole per declared slot prop; live slot content composes in per instance
|
|
3953
|
+
* at request time via SlotsProvider/SlotContext. This generalizes the
|
|
3954
|
+
* TIM-1181 layout mechanism to explicitly declared, named slots on any
|
|
3955
|
+
* cached component. Layouts use the same mechanism with a `children` slot.
|
|
3956
|
+
*
|
|
3957
|
+
* The `__prebuilt` wrapper builds its slot render from these helpers, in
|
|
3958
|
+
* dev and production alike. See design/45-cache-lifetimes.md §Slot
|
|
3959
|
+
* Components.
|
|
3960
|
+
*/
|
|
3961
|
+
/**
|
|
3962
|
+
* Framework-internal slot name for layout children. Uses a prefix that
|
|
3963
|
+
* cannot collide with user-declared slot names (which are React prop
|
|
3964
|
+
* names). Layout children flow through SlotsProvider/SlotOutlet with
|
|
3965
|
+
* this key instead of the bare "children" key, so a cached component
|
|
3966
|
+
* with `slots: ['children']` inside a layout never shadows the layout's
|
|
3967
|
+
* own children delivery.
|
|
3968
|
+
*
|
|
3969
|
+
* Defined here (a server module) rather than in `client/slot-context.ts`
|
|
3970
|
+
* (`'use client'`) because RSC's client-reference proxying would replace
|
|
3971
|
+
* the string value with a proxy object in the server environment. The
|
|
3972
|
+
* client-side SlotOutlet receives this value via props, so it doesn't
|
|
3973
|
+
* need the constant. See TIM-1191.
|
|
3974
|
+
*/
|
|
3975
|
+
var LAYOUT_CHILDREN_SLOT = "\0timber:children";
|
|
3894
3976
|
/**
|
|
3895
3977
|
* Is this value the framework-injected layout children slot outlet
|
|
3896
3978
|
* (`<SlotOutlet slot={LAYOUT_CHILDREN_SLOT} />`)? Layout components
|
|
@@ -3948,9 +4030,8 @@ function isDenseStringArray(value) {
|
|
|
3948
4030
|
}
|
|
3949
4031
|
}
|
|
3950
4032
|
/**
|
|
3951
|
-
* Validate the `slots` option.
|
|
3952
|
-
*
|
|
3953
|
-
* active in production, so the tree shape a component sees never
|
|
4033
|
+
* Validate the `slots` option. The `__prebuilt` wrapper gates on this in
|
|
4034
|
+
* dev and production alike, so the tree shape a component sees never
|
|
3954
4035
|
* diverges between the two.
|
|
3955
4036
|
*/
|
|
3956
4037
|
function resolveSlotNames(id, options) {
|
|
@@ -4197,7 +4278,7 @@ function noteWrapperRender(innerId, options, props) {
|
|
|
4197
4278
|
}
|
|
4198
4279
|
//#endregion
|
|
4199
4280
|
//#region src/server/flight-source.ts
|
|
4200
|
-
var nodeFlight = typeof process !== "undefined" && process.release?.name === "node" && !(typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") ? await import("../_chunks/flight-source-node-
|
|
4281
|
+
var nodeFlight = typeof process !== "undefined" && process.release?.name === "node" && !(typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") ? await import("../_chunks/flight-source-node-HptmGMT8.js") : null;
|
|
4201
4282
|
/** The Node helpers, which a `kind: 'node'` source can only exist alongside. */
|
|
4202
4283
|
function requireNodeFlight() {
|
|
4203
4284
|
if (!nodeFlight) throw new Error("[timber] a Node Flight source reached a runtime without node:stream");
|
|
@@ -4258,6 +4339,133 @@ async function collectFlightBytes(source, timeoutMs, label) {
|
|
|
4258
4339
|
return concatBytes(chunks.map(flightChunkBytes));
|
|
4259
4340
|
}
|
|
4260
4341
|
//#endregion
|
|
4342
|
+
//#region src/server/prebuilt/synthetic-store.ts
|
|
4343
|
+
/**
|
|
4344
|
+
* Thrown when a prerendered component touches per-request context at
|
|
4345
|
+
* build time. The capture pass treats this as a HARD build error —
|
|
4346
|
+
* it indicates a design mistake, not transient bad data (design/44
|
|
4347
|
+
* §Build-Phase Error Handling).
|
|
4348
|
+
*/
|
|
4349
|
+
var BuildTimeContextError = class extends Error {
|
|
4350
|
+
/** The per-request API that was called (e.g. "cookies()"). */
|
|
4351
|
+
api;
|
|
4352
|
+
constructor(componentId, api) {
|
|
4353
|
+
super(`[timber] cache.component "${componentId}": ${api} cannot be used in a prerendered component — there is no request at build time. Prerendered components may read segment params and timber.cache data only. Remove the ${api} call, or drop { prerender: true } and render this component per-request. (design/44-render-at-build-time.md §Param Injection)`);
|
|
4354
|
+
this.name = "BuildTimeContextError";
|
|
4355
|
+
this.api = api;
|
|
4356
|
+
}
|
|
4357
|
+
};
|
|
4358
|
+
/**
|
|
4359
|
+
* Create the synthetic per-combo store. `segmentParams` must already be
|
|
4360
|
+
* coerced through the route's codecs — cache-key parity with request time
|
|
4361
|
+
* depends on hashing the exact record `coerceSegmentParams` produces.
|
|
4362
|
+
*/
|
|
4363
|
+
function createBuildTimeStore(componentId, segmentParams) {
|
|
4364
|
+
const violations = [];
|
|
4365
|
+
const handle = {
|
|
4366
|
+
store: null,
|
|
4367
|
+
violations,
|
|
4368
|
+
segmentParamsRead: false
|
|
4369
|
+
};
|
|
4370
|
+
const store = {
|
|
4371
|
+
request: null,
|
|
4372
|
+
headers: new Headers(),
|
|
4373
|
+
originalHeaders: new Headers(),
|
|
4374
|
+
cookieHeader: "",
|
|
4375
|
+
searchParams: new URLSearchParams(),
|
|
4376
|
+
searchString: "",
|
|
4377
|
+
segmentParams,
|
|
4378
|
+
cookieJar: /* @__PURE__ */ new Map(),
|
|
4379
|
+
flushed: false,
|
|
4380
|
+
mutableContext: false
|
|
4381
|
+
};
|
|
4382
|
+
const violate = (api) => {
|
|
4383
|
+
const error = new BuildTimeContextError(componentId, api);
|
|
4384
|
+
violations.push(error);
|
|
4385
|
+
throw error;
|
|
4386
|
+
};
|
|
4387
|
+
Object.defineProperties(store, {
|
|
4388
|
+
headers: { get: () => violate("headers()") },
|
|
4389
|
+
parsedCookies: { get: () => violate("cookies()") },
|
|
4390
|
+
searchParams: { get: () => violate("searchParams") },
|
|
4391
|
+
mutableContext: { get: () => violate("cookies()") },
|
|
4392
|
+
segmentParams: {
|
|
4393
|
+
get: () => {
|
|
4394
|
+
handle.segmentParamsRead = true;
|
|
4395
|
+
return segmentParams;
|
|
4396
|
+
},
|
|
4397
|
+
enumerable: true
|
|
4398
|
+
}
|
|
4399
|
+
});
|
|
4400
|
+
handle.store = store;
|
|
4401
|
+
return handle;
|
|
4402
|
+
}
|
|
4403
|
+
//#endregion
|
|
4404
|
+
//#region src/server/prebuilt/capture-render.ts
|
|
4405
|
+
/**
|
|
4406
|
+
* One build-time capture entry: render a registered component in isolation
|
|
4407
|
+
* under the synthetic build store and drain its flight payload under a
|
|
4408
|
+
* deadline. Run by the post-build capture pass (server/prebuilt-builder.ts)
|
|
4409
|
+
* and, in dev, by the first request for a prerender entry
|
|
4410
|
+
* (server/prebuilt-runtime.ts, TIM-1588) — which is why the flight renderer
|
|
4411
|
+
* is a parameter: the request-time runtime renders through the functions
|
|
4412
|
+
* the RSC entry injected.
|
|
4413
|
+
*/
|
|
4414
|
+
/**
|
|
4415
|
+
* Render one (component, props, coerced-params) entry in isolation and drain
|
|
4416
|
+
* its flight payload. Any `onError` during serialization fails the entry —
|
|
4417
|
+
* a payload with an embedded error row would replay that error on every
|
|
4418
|
+
* future request, so only fully clean renders are captured.
|
|
4419
|
+
*/
|
|
4420
|
+
async function renderEntry(registration, props, coercedParams, timeoutMs, isLayout, renderFlight) {
|
|
4421
|
+
const storeHandle = createBuildTimeStore(registration.id, coercedParams);
|
|
4422
|
+
const { store, violations } = storeHandle;
|
|
4423
|
+
let failure = null;
|
|
4424
|
+
const capture = createCaptureScope(registration.id, registration.options, props);
|
|
4425
|
+
let bytes = null;
|
|
4426
|
+
let resolvedTags;
|
|
4427
|
+
try {
|
|
4428
|
+
const renderProps = isLayout && !("children" in props) ? {
|
|
4429
|
+
...props,
|
|
4430
|
+
children: createElement(SlotOutlet, { slot: LAYOUT_CHILDREN_SLOT })
|
|
4431
|
+
} : props;
|
|
4432
|
+
bytes = await capture.run(() => requestContextAls.run(store, async () => {
|
|
4433
|
+
const drained = await collectFlightBytes(renderFlight(createElement(registration.component, renderProps), { onError(error) {
|
|
4434
|
+
failure ??= error ?? /* @__PURE__ */ new Error("unknown render error");
|
|
4435
|
+
return "timber-prebuilt-capture-error";
|
|
4436
|
+
} }), timeoutMs, "render");
|
|
4437
|
+
const tags = resolveTags(registration.options, props);
|
|
4438
|
+
resolvedTags = tags.length > 0 ? tags : void 0;
|
|
4439
|
+
return drained;
|
|
4440
|
+
}));
|
|
4441
|
+
} catch (error) {
|
|
4442
|
+
failure ??= error;
|
|
4443
|
+
}
|
|
4444
|
+
const nested = capture.nestedRenders();
|
|
4445
|
+
const { segmentParamsRead } = storeHandle;
|
|
4446
|
+
if (violations.length > 0) return {
|
|
4447
|
+
bytes: null,
|
|
4448
|
+
failure: violations[0],
|
|
4449
|
+
nested,
|
|
4450
|
+
resolvedTags,
|
|
4451
|
+
segmentParamsRead
|
|
4452
|
+
};
|
|
4453
|
+
if (failure !== null) return {
|
|
4454
|
+
bytes: null,
|
|
4455
|
+
failure,
|
|
4456
|
+
nested,
|
|
4457
|
+
resolvedTags,
|
|
4458
|
+
segmentParamsRead
|
|
4459
|
+
};
|
|
4460
|
+
return {
|
|
4461
|
+
bytes,
|
|
4462
|
+
failure: null,
|
|
4463
|
+
nested,
|
|
4464
|
+
resolvedTags,
|
|
4465
|
+
segmentParamsRead
|
|
4466
|
+
};
|
|
4467
|
+
}
|
|
4468
|
+
//#endregion
|
|
4261
4469
|
//#region src/server/prebuilt-runtime.ts
|
|
4262
4470
|
/**
|
|
4263
4471
|
* Prebuilt component runtime — registration target for the timber-prebuilt
|
|
@@ -4265,9 +4473,11 @@ async function collectFlightBytes(source, timeoutMs, label) {
|
|
|
4265
4473
|
* cache.component (TIM-1140).
|
|
4266
4474
|
*
|
|
4267
4475
|
* `cache.component(fn, opts)` call sites are rewritten at build time to
|
|
4268
|
-
* `__prebuilt(stableId, fn, opts)
|
|
4269
|
-
*
|
|
4270
|
-
*
|
|
4476
|
+
* `__prebuilt(stableId, fn, opts)`, in dev and production alike. It is
|
|
4477
|
+
* exported via #server-internal — framework plumbing, never called by user
|
|
4478
|
+
* code directly. In dev the build artifact is replaced by the in-memory dev
|
|
4479
|
+
* store (prebuilt/dev-store.ts): a prerender entry is captured on its first
|
|
4480
|
+
* request and served until a watched file changes (TIM-1588).
|
|
4271
4481
|
*
|
|
4272
4482
|
* Cache hits are served by FLIGHT REVIVAL: the cached `.flight` payload is
|
|
4273
4483
|
* decoded back into React elements inside the RSC environment with
|
|
@@ -4309,61 +4519,12 @@ var warnedNestingPairs = /* @__PURE__ */ new Set();
|
|
|
4309
4519
|
/**
|
|
4310
4520
|
* Server-side component registry, keyed by stable component ID. Populated at
|
|
4311
4521
|
* module load time by `__prebuilt` calls; consumed by the post-build capture
|
|
4312
|
-
* pass (TIM-1119). Never serialized — component functions are not
|
|
4522
|
+
* pass (TIM-1119). Not written in dev, where nothing walks it. Never serialized — component functions are not
|
|
4313
4523
|
* Flight-serializable.
|
|
4314
4524
|
*/
|
|
4315
4525
|
var registry = /* @__PURE__ */ new Map();
|
|
4316
|
-
/**
|
|
4317
|
-
|
|
4318
|
-
* render is unkeyable.
|
|
4319
|
-
*
|
|
4320
|
-
* A wrapper rendered inside a parallel slot reads params merged with that
|
|
4321
|
-
* slot's overrides (`getSegmentParams`: `{...segmentParams, ...slotParams}`)
|
|
4322
|
-
* — but the cache key hashes only the route-level params, and the wrapper
|
|
4323
|
-
* cannot know which slot it renders under. The route params are usable
|
|
4324
|
-
* only when every slot's merged view canonicalizes identically to them;
|
|
4325
|
-
* otherwise two renders with the same key could see different effective
|
|
4326
|
-
* inputs and a hit could serve the WRONG cached subtree — so the render
|
|
4327
|
-
* goes live: slower, never wrong. (Build-time capture doesn't model slot
|
|
4328
|
-
* params either, so a divergent request could never have a faithful
|
|
4329
|
-
* entry. Codex review on PR #835; revisit with segment-path-scoped keys
|
|
4330
|
-
* if slot-scoped prebuilt is ever needed.)
|
|
4331
|
-
*
|
|
4332
|
-
* Comparison happens through `tryCanonicalize` — the same single
|
|
4333
|
-
* definition of value equality the cache key uses — so anything it
|
|
4334
|
-
* cannot represent faithfully (bigint-coerced codec params, accessors,
|
|
4335
|
-
* aliases, …) is unkeyable here too, and this guard can never throw.
|
|
4336
|
-
*/
|
|
4337
|
-
function resolveKeyParams(store) {
|
|
4338
|
-
const main = store.segmentParams ?? {};
|
|
4339
|
-
const slots = store.slotParams;
|
|
4340
|
-
if (!slots || Object.keys(slots).length === 0) return main;
|
|
4341
|
-
const mainCanonical = tryCanonicalize({ ...main });
|
|
4342
|
-
if (mainCanonical === null) return null;
|
|
4343
|
-
for (const slotParams of Object.values(slots)) {
|
|
4344
|
-
const merged = tryCanonicalize({
|
|
4345
|
-
...main,
|
|
4346
|
-
...slotParams
|
|
4347
|
-
});
|
|
4348
|
-
if (merged === null || merged !== mainCanonical) return null;
|
|
4349
|
-
}
|
|
4350
|
-
return main;
|
|
4351
|
-
}
|
|
4352
|
-
/**
|
|
4353
|
-
* Mirror the production cache-key decision for a slot render, with no
|
|
4354
|
-
* cache IO — used by the dev wrapper so slot substitution happens in dev
|
|
4355
|
-
* exactly when production would serve the cache path rather than the
|
|
4356
|
-
* live fallback (dev/prod parity, codex P2 on PR #890): requires an ALS
|
|
4357
|
-
* store, keyable params (slot-param divergence unkeys), and keyable data
|
|
4358
|
-
* props (after the children slot outlet strip).
|
|
4359
|
-
*/
|
|
4360
|
-
function isSlotRenderKeyable(dataProps) {
|
|
4361
|
-
const store = requestContextAls.getStore();
|
|
4362
|
-
if (!store) return false;
|
|
4363
|
-
const keyParams = resolveKeyParams(store);
|
|
4364
|
-
if (keyParams === null) return false;
|
|
4365
|
-
return computeComponentCacheKey(withoutChildrenOutlet(dataProps), keyParams) !== null;
|
|
4366
|
-
}
|
|
4526
|
+
/** Dev: IDs registered so far, to detect a module re-evaluating (no functions held). */
|
|
4527
|
+
var devRegisteredIds = /* @__PURE__ */ new Set();
|
|
4367
4528
|
/** Wrap payload bytes as a single-chunk ReadableStream for the decoder. */
|
|
4368
4529
|
function bytesToStream(bytes) {
|
|
4369
4530
|
return new ReadableStream({ start(controller) {
|
|
@@ -4379,11 +4540,11 @@ function bytesToStream(bytes) {
|
|
|
4379
4540
|
*
|
|
4380
4541
|
* Null on any miss — the caller renders live with the original props.
|
|
4381
4542
|
*/
|
|
4382
|
-
async function tryReviveSlotShell(
|
|
4543
|
+
async function tryReviveSlotShell(registration, slots, props) {
|
|
4383
4544
|
const render = prepareSlotRender(props, slots);
|
|
4384
4545
|
if (render === null) return null;
|
|
4385
4546
|
const { shellProps, dataProps, slotValues } = render;
|
|
4386
|
-
const revived = await tryRevivePayload(
|
|
4547
|
+
const revived = await tryRevivePayload(registration, shellProps, dataProps);
|
|
4387
4548
|
if (revived === null) return null;
|
|
4388
4549
|
return { element: wrapInSlotsProvider(revived.element, slotValues) };
|
|
4389
4550
|
}
|
|
@@ -4518,16 +4679,77 @@ function backgroundRerender(id, component, props, cacheKey, options, hasSeed, sn
|
|
|
4518
4679
|
console.warn("[timber] cache.component SWR background re-render has no waitUntil — the re-render may be killed when the handler returns on serverless platforms. Ensure the adapter wires runWithWaitUntil().");
|
|
4519
4680
|
}
|
|
4520
4681
|
}
|
|
4682
|
+
/** Components already announced by the one-time dev log. */
|
|
4683
|
+
var devLoggedIds = /* @__PURE__ */ new Set();
|
|
4684
|
+
/**
|
|
4685
|
+
* Dev: the seed for a prerender entry — the stored capture, or a new one
|
|
4686
|
+
* rendered exactly as the build would render it (synthetic store, isolated
|
|
4687
|
+
* render, nested wrappers baked flat) and stored until the next source
|
|
4688
|
+
* change (prebuilt/dev-store.ts).
|
|
4689
|
+
*
|
|
4690
|
+
* Throws the BuildTimeContextError when the component read request
|
|
4691
|
+
* context: `pnpm build` would fail on it, so dev fails too. Null on any
|
|
4692
|
+
* other capture failure — the live render that follows reproduces the
|
|
4693
|
+
* error, deny(), or redirect() with its normal semantics.
|
|
4694
|
+
*/
|
|
4695
|
+
async function resolveDevSeed(registration, props, keyParams, cacheKey) {
|
|
4696
|
+
const { id, options } = registration;
|
|
4697
|
+
const stored = getDevSeed(id, cacheKey);
|
|
4698
|
+
if (stored) return {
|
|
4699
|
+
payload: stored.bytes,
|
|
4700
|
+
capturedAt: stored.capturedAt
|
|
4701
|
+
};
|
|
4702
|
+
const tags = resolveTags(options, props);
|
|
4703
|
+
const oKey = overlayKey(id, cacheKey);
|
|
4704
|
+
const sfKey = `prebuilt-dev:${id}:${cacheKey}\0${lastInvalidationEpochFor(oKey, tags)}`;
|
|
4705
|
+
try {
|
|
4706
|
+
return await componentSingleflight.do(sfKey, async (signal) => {
|
|
4707
|
+
const startEpoch = currentInvalidationEpoch();
|
|
4708
|
+
const capturedAt = Date.now();
|
|
4709
|
+
const { renderFlight } = requireRscFunctions();
|
|
4710
|
+
const outcome = await runOutsideReactCacheScope(() => renderEntry(registration, props, keyParams, getCaptureTimeoutMs(), false, renderFlight));
|
|
4711
|
+
if (outcome.failure instanceof BuildTimeContextError) throw outcome.failure;
|
|
4712
|
+
if (outcome.bytes === null) return null;
|
|
4713
|
+
if (await revivePayload(id, outcome.bytes, "not storing the dev capture") === null) return null;
|
|
4714
|
+
if (!signal.aborted && !wasInvalidatedSince(startEpoch, oKey, tags)) {
|
|
4715
|
+
setDevSeed(id, cacheKey, {
|
|
4716
|
+
bytes: outcome.bytes,
|
|
4717
|
+
tags,
|
|
4718
|
+
capturedAt
|
|
4719
|
+
});
|
|
4720
|
+
warnNestingClamps({
|
|
4721
|
+
id,
|
|
4722
|
+
options,
|
|
4723
|
+
tags
|
|
4724
|
+
}, outcome.nested, warnedNestingPairs, (m) => console.warn(m));
|
|
4725
|
+
if (!devLoggedIds.has(id)) {
|
|
4726
|
+
devLoggedIds.add(id);
|
|
4727
|
+
console.log(`[timber] cache.component "${id}": prerendered in dev — served from memory until a file changes. A hard reload (Cache-Control: no-cache) renders it again.`);
|
|
4728
|
+
}
|
|
4729
|
+
}
|
|
4730
|
+
return {
|
|
4731
|
+
payload: outcome.bytes,
|
|
4732
|
+
capturedAt
|
|
4733
|
+
};
|
|
4734
|
+
});
|
|
4735
|
+
} catch (error) {
|
|
4736
|
+
if (error instanceof BuildTimeContextError) throw error;
|
|
4737
|
+
console.error(`[timber] cache.component dev capture failed for "${id}":`, error);
|
|
4738
|
+
return null;
|
|
4739
|
+
}
|
|
4740
|
+
}
|
|
4521
4741
|
/**
|
|
4522
|
-
* Try to serve this render from the prebuilt cache: overlay →
|
|
4742
|
+
* Try to serve this render from the prebuilt cache: overlay → seed →
|
|
4523
4743
|
* live render. Handles ISR (SWR, tombstones, re-renders) per design/45.
|
|
4524
4744
|
*
|
|
4525
4745
|
* Null on any miss — the caller renders live.
|
|
4526
4746
|
*/
|
|
4527
|
-
async function tryRevivePayload(
|
|
4747
|
+
async function tryRevivePayload(registration, props, keyPropsOverride) {
|
|
4748
|
+
const { id, options, component } = registration;
|
|
4528
4749
|
const hasSource = hasPrebuiltPayloadSource();
|
|
4750
|
+
const devStore = isDevPrebuiltStoreActive();
|
|
4529
4751
|
const hasRuntime = hasRuntimeLifetime(options);
|
|
4530
|
-
if (!hasSource && !hasRuntime) return null;
|
|
4752
|
+
if (!hasSource && !devStore && !hasRuntime) return null;
|
|
4531
4753
|
const store = requestContextAls.getStore();
|
|
4532
4754
|
if (!store) return null;
|
|
4533
4755
|
const keyParams = (options.prerender ? await isParamIndependent(id) : false) ? {} : resolveKeyParams(store);
|
|
@@ -4535,45 +4757,37 @@ async function tryRevivePayload(id, options, props, keyPropsOverride) {
|
|
|
4535
4757
|
const cacheKey = computeComponentCacheKey(withoutChildrenOutlet(keyPropsOverride ?? props ?? {}), keyParams);
|
|
4536
4758
|
if (cacheKey === null) return null;
|
|
4537
4759
|
const outcome = options.fallbackOnMissingSegmentParams === false ? "failing the render (fallbackOnMissingSegmentParams: false)" : "rendering dynamically";
|
|
4538
|
-
|
|
4760
|
+
if (devStore && isHardReload(store.originalHeaders)) await discardDevEntry(id, cacheKey, overlayKey(id, cacheKey));
|
|
4539
4761
|
if (hasRuntime) {
|
|
4540
4762
|
const overlayResult = await lookupOverlay(id, cacheKey);
|
|
4541
4763
|
if (overlayResult) {
|
|
4542
4764
|
const overlayHasSeed = overlayResult.record?.s ?? false;
|
|
4543
|
-
if (overlayResult.kind === "tombstone")
|
|
4544
|
-
if (component) return await inlineRerender(id, component, props, cacheKey, options, true, outcome);
|
|
4545
|
-
return null;
|
|
4546
|
-
}
|
|
4765
|
+
if (overlayResult.kind === "tombstone") return await inlineRerender(id, component, props, cacheKey, options, true, outcome);
|
|
4547
4766
|
if (overlayResult.kind === "fresh" && overlayResult.payload) return await revivePayload(id, overlayResult.payload, outcome);
|
|
4548
4767
|
if (overlayResult.kind === "stale" && overlayResult.payload) {
|
|
4549
|
-
if (options.staleWhileRevalidate
|
|
4768
|
+
if (options.staleWhileRevalidate) {
|
|
4550
4769
|
backgroundRerender(id, component, props, cacheKey, options, overlayHasSeed, snapshotRequestContext(store));
|
|
4551
4770
|
return await revivePayload(id, overlayResult.payload, outcome);
|
|
4552
4771
|
}
|
|
4553
|
-
|
|
4554
|
-
return null;
|
|
4772
|
+
return await inlineRerender(id, component, props, cacheKey, options, overlayHasSeed, outcome);
|
|
4555
4773
|
}
|
|
4556
4774
|
}
|
|
4557
4775
|
}
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
if (
|
|
4561
|
-
if (
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
backgroundRerender(id, component, props, cacheKey, options, true, snapshotRequestContext(store));
|
|
4566
|
-
return await revivePayload(id, artifactPayload, outcome);
|
|
4567
|
-
}
|
|
4568
|
-
if (component) return await inlineRerender(id, component, props, cacheKey, options, true, outcome);
|
|
4569
|
-
return null;
|
|
4776
|
+
const seed = devStore ? options.prerender ? await resolveDevSeed(registration, props, keyParams, cacheKey) : null : hasSource ? await lookupArtifactSeed(id, cacheKey, options.ttl !== void 0) : null;
|
|
4777
|
+
if (seed !== null) {
|
|
4778
|
+
if (options.ttl !== void 0) {
|
|
4779
|
+
if ((Date.now() - seed.capturedAt) / 1e3 > options.ttl) {
|
|
4780
|
+
if (options.staleWhileRevalidate) {
|
|
4781
|
+
backgroundRerender(id, component, props, cacheKey, options, true, snapshotRequestContext(store));
|
|
4782
|
+
return await revivePayload(id, seed.payload, outcome);
|
|
4570
4783
|
}
|
|
4784
|
+
return await inlineRerender(id, component, props, cacheKey, options, true, outcome);
|
|
4571
4785
|
}
|
|
4572
|
-
return await revivePayload(id, artifactPayload, outcome);
|
|
4573
4786
|
}
|
|
4574
|
-
|
|
4787
|
+
return await revivePayload(id, seed.payload, outcome);
|
|
4575
4788
|
}
|
|
4576
|
-
if (
|
|
4789
|
+
if (hasSource && options.prerender) console.warn(`[timber] cache.component cache miss: "${id}" with params ${JSON.stringify(store.segmentParams ?? {})} — ${outcome}`);
|
|
4790
|
+
if (hasRuntime && options.fallbackOnMissingSegmentParams !== false) return await inlineRerender(id, component, props, cacheKey, options, false, outcome);
|
|
4577
4791
|
return null;
|
|
4578
4792
|
}
|
|
4579
4793
|
/**
|
|
@@ -4596,15 +4810,20 @@ function __prebuilt(id, component, options = {}) {
|
|
|
4596
4810
|
...options,
|
|
4597
4811
|
slots: void 0
|
|
4598
4812
|
};
|
|
4599
|
-
|
|
4813
|
+
const registration = {
|
|
4600
4814
|
id,
|
|
4601
4815
|
component,
|
|
4602
4816
|
options
|
|
4603
|
-
}
|
|
4817
|
+
};
|
|
4818
|
+
if (isDevPrebuiltStoreActive()) {
|
|
4819
|
+
if (devRegisteredIds.has(id)) clearDevPrebuiltStore();
|
|
4820
|
+
devRegisteredIds.add(id);
|
|
4821
|
+
} else registry.set(id, registration);
|
|
4604
4822
|
const wrapper = async (props) => {
|
|
4605
4823
|
noteWrapperRender(id, options, props);
|
|
4606
4824
|
if (isCaptureActive()) return createElement(component, props);
|
|
4607
|
-
|
|
4825
|
+
if (isDevPrebuiltCacheBypassed()) return createElement(component, props);
|
|
4826
|
+
const revived = slots ? await tryReviveSlotShell(registration, slots, props) : await tryRevivePayload(registration, props);
|
|
4608
4827
|
if (revived !== null) return revived.element;
|
|
4609
4828
|
if (options.fallbackOnMissingSegmentParams === false) throw new Error(`[timber] cache.component "${id}": no prebuilt payload for the current params and fallbackOnMissingSegmentParams is false`);
|
|
4610
4829
|
return createElement(component, props);
|
|
@@ -4620,30 +4839,7 @@ function getPrebuiltRegistration(id) {
|
|
|
4620
4839
|
function getPrebuiltRegistry() {
|
|
4621
4840
|
return registry;
|
|
4622
4841
|
}
|
|
4623
|
-
/**
|
|
4624
|
-
* Dev-mode wrapper injected by the timber-prebuilt transform: a no-op that
|
|
4625
|
-
* renders the component dynamically on every request, logging once per
|
|
4626
|
-
* component on first render so the production behavior difference is visible.
|
|
4627
|
-
* See design/44 §Dev Mode.
|
|
4628
|
-
*/
|
|
4629
|
-
function __prebuiltDev(name, component, options = {}) {
|
|
4630
|
-
const resolution = resolveSlotNames(name, options);
|
|
4631
|
-
const slots = resolution.kind === "active" ? resolution.slots : null;
|
|
4632
|
-
let logged = false;
|
|
4633
|
-
const wrapper = (props) => {
|
|
4634
|
-
if (!logged) {
|
|
4635
|
-
logged = true;
|
|
4636
|
-
console.log(`[timber] cache.component: "${name}" — rendering dynamically (dev mode)`);
|
|
4637
|
-
}
|
|
4638
|
-
if (slots) {
|
|
4639
|
-
const render = prepareSlotRender(props, slots);
|
|
4640
|
-
if (render !== null && isSlotRenderKeyable(render.dataProps)) return wrapInSlotsProvider(createElement(component, render.shellProps), render.slotValues);
|
|
4641
|
-
}
|
|
4642
|
-
return createElement(component, props);
|
|
4643
|
-
};
|
|
4644
|
-
return wrapper;
|
|
4645
|
-
}
|
|
4646
4842
|
//#endregion
|
|
4647
|
-
export { AccessGate, DEFAULT_LIMITS, DenySignal, METADATA_ROUTE_CONVENTIONS, RedirectSignal, RenderTimeoutError, SlotAccessGate, __prebuilt,
|
|
4843
|
+
export { AccessGate, DEFAULT_LIMITS, DenySignal, METADATA_ROUTE_CONVENTIONS, RedirectSignal, RenderTimeoutError, SlotAccessGate, __prebuilt, callOnRequestError, canonicalize, classifyMetadataRoute, coerce, collectEarlyHintHeaders, computeComponentCacheKey, createPipeline, enforceBodyLimits, executeAction, formatLinkHeader, generateTraceId, getCookie, getHeader, getLogger, getMetadataRouteAutoLink, getMetadataRouteServePath, getPrebuiltRegistration, getPrebuiltRegistry, getSearchParams, getSegmentParams, getSetCookieHeaders, handleRouteRequest, hasOnRequestError, hasPrebuiltPayloadSource, loadInstrumentation, logCacheMiss, logMiddlewareError, logMiddlewareShortCircuit, logProxyError, logRenderError, logRequestCompleted, logRequestReceived, logSlowRequest, logSwrRefetchFailed, logWaitUntilRejected, logWaitUntilUnsupported, markResponseFlushed, parseBodySize, renderMetadataToElements, replaceTraceId, resolveAllowedMethods, resolveMetadata, resolveMetadataUrls, resolveSlotDenied, resolveStatusFile, resolveTitle, runMiddleware, runProxy, runWithEarlyHintsSender, runWithRequestContext, runWithTraceId, sendEarlyHints103, setLogger, setMutableCookieContext, setPrebuiltPayloadSource, setSegmentParams };
|
|
4648
4844
|
|
|
4649
4845
|
//# sourceMappingURL=internal.js.map
|