@timber-js/app 0.2.0-alpha.166 → 0.2.0-alpha.168
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-CDPfMp_I.js → actions-O_LsyCE4.js} +3 -3
- package/dist/_chunks/{actions-CDPfMp_I.js.map → actions-O_LsyCE4.js.map} +1 -1
- package/dist/_chunks/{cache-api-DygSeKCB.js → cache-api-B-lhk9p4.js} +107 -58
- package/dist/_chunks/cache-api-B-lhk9p4.js.map +1 -0
- package/dist/_chunks/{cli-schema-sync-EXGYPhI2.js → cli-schema-sync-B73L6pMq.js} +5 -3
- package/dist/_chunks/cli-schema-sync-B73L6pMq.js.map +1 -0
- package/dist/_chunks/cloudflare-AHoWYTYr.js +1188 -0
- package/dist/_chunks/cloudflare-AHoWYTYr.js.map +1 -0
- package/dist/_chunks/json-lossy-check-ClNvBM_3.js +63 -0
- package/dist/_chunks/json-lossy-check-ClNvBM_3.js.map +1 -0
- package/dist/_chunks/{logger-t3uxAmbX.js → logger-AWfuX-KJ.js} +2 -19
- package/dist/_chunks/logger-AWfuX-KJ.js.map +1 -0
- package/dist/_chunks/{walkers-DBVzXuWc.js → walkers-CoOC8Hga.js} +2 -2
- package/dist/_chunks/{walkers-DBVzXuWc.js.map → walkers-CoOC8Hga.js.map} +1 -1
- package/dist/adapters/cloudflare-dev.js +1 -1
- package/dist/adapters/cloudflare-kv-cache.d.ts.map +1 -1
- package/dist/adapters/cloudflare-kv-cache.js +10 -3
- package/dist/adapters/cloudflare-kv-cache.js.map +1 -1
- package/dist/adapters/cloudflare.d.ts +12 -1
- package/dist/adapters/cloudflare.d.ts.map +1 -1
- package/dist/adapters/cloudflare.js +2 -461
- package/dist/adapters/types.d.ts +2 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/cache/cache-api.d.ts +33 -11
- package/dist/cache/cache-api.d.ts.map +1 -1
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cache/json-lossy-check.d.ts +11 -0
- package/dist/cache/json-lossy-check.d.ts.map +1 -0
- package/dist/cache/redis-handler.d.ts +42 -0
- package/dist/cache/redis-handler.d.ts.map +1 -1
- package/dist/cache/singleflight.d.ts.map +1 -1
- package/dist/cache/stores/cloudflare-kv.d.ts +1 -1
- package/dist/cache/stores/cloudflare-kv.d.ts.map +1 -1
- package/dist/cache/stores/memory.d.ts +1 -1
- package/dist/cache/stores/memory.d.ts.map +1 -1
- package/dist/cache/stores/redis.d.ts +1 -1
- package/dist/cache/stores/redis.d.ts.map +1 -1
- package/dist/cache/stores/vercel.d.ts +1 -1
- package/dist/cache/stores/vercel.d.ts.map +1 -1
- package/dist/cache/tag-aware-handler.d.ts.map +1 -1
- package/dist/cache/timber-cache.d.ts.map +1 -1
- package/dist/cdn/cloudflare-purge.d.ts.map +1 -1
- package/dist/cdn/fastly-purge.d.ts.map +1 -1
- package/dist/cdn/workers-cache-purge.d.ts.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/client/browser-entry/post-hydration.d.ts.map +1 -1
- package/dist/client/browser-entry/router-init.d.ts +1 -0
- package/dist/client/browser-entry/router-init.d.ts.map +1 -1
- package/dist/client/child-segment-context.d.ts +2 -2
- package/dist/client/child-segment-context.d.ts.map +1 -1
- package/dist/client/error-boundary.d.ts.map +1 -1
- package/dist/client/history.d.ts +10 -0
- package/dist/client/history.d.ts.map +1 -1
- package/dist/client/internal.js +141 -116
- package/dist/client/internal.js.map +1 -1
- package/dist/client/router.d.ts +6 -0
- package/dist/client/router.d.ts.map +1 -1
- package/dist/client/rsc-fetch.d.ts.map +1 -1
- package/dist/client/segment-cache.d.ts.map +1 -1
- package/dist/client/segment-update-context.d.ts +3 -3
- package/dist/client/segment-update-context.d.ts.map +1 -1
- package/dist/client/slot-outlet.d.ts +1 -1
- package/dist/codec.d.ts.map +1 -1
- package/dist/codec.js +2 -1
- package/dist/codec.js.map +1 -1
- package/dist/config-types.d.ts +16 -37
- package/dist/config-types.d.ts.map +1 -1
- package/dist/config-validation.d.ts.map +1 -1
- package/dist/dev-tools/instrumentation.d.ts.map +1 -1
- package/dist/fonts/pipeline.d.ts +19 -0
- package/dist/fonts/pipeline.d.ts.map +1 -1
- package/dist/fonts/transform.d.ts.map +1 -1
- package/dist/fonts/virtual-modules.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +378 -109
- package/dist/index.js.map +1 -1
- package/dist/plugin-context.d.ts.map +1 -1
- package/dist/plugins/adapter-build.d.ts +1 -0
- package/dist/plugins/adapter-build.d.ts.map +1 -1
- package/dist/plugins/cache.d.ts +8 -8
- package/dist/plugins/cache.d.ts.map +1 -1
- package/dist/plugins/entries.d.ts +27 -3
- package/dist/plugins/entries.d.ts.map +1 -1
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/dist/plugins/server-bundle.d.ts.map +1 -1
- package/dist/routing/index.js +2 -2
- package/dist/server/action-client.d.ts +1 -1
- package/dist/server/action-client.d.ts.map +1 -1
- package/dist/server/als-registry.d.ts +7 -0
- package/dist/server/als-registry.d.ts.map +1 -1
- package/dist/server/body-limits.d.ts.map +1 -1
- package/dist/server/deny-boundary.d.ts +3 -1
- package/dist/server/deny-boundary.d.ts.map +1 -1
- package/dist/server/form-data.d.ts.map +1 -1
- package/dist/server/html-injector-core.d.ts.map +1 -1
- package/dist/server/index.js +20 -3
- package/dist/server/index.js.map +1 -1
- package/dist/server/internal.js +28 -41
- package/dist/server/internal.js.map +1 -1
- package/dist/server/middleware-runner.d.ts +0 -17
- package/dist/server/middleware-runner.d.ts.map +1 -1
- package/dist/server/param-coercion.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts +6 -3
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/pipeline.d.ts +18 -0
- package/dist/server/pipeline.d.ts.map +1 -1
- package/dist/server/prebuilt/capture-state.d.ts.map +1 -1
- package/dist/server/prebuilt/synthetic-store.d.ts.map +1 -1
- package/dist/server/primitives.d.ts.map +1 -1
- package/dist/server/render-timeout.d.ts.map +1 -1
- package/dist/server/route-element-builder.d.ts +9 -0
- package/dist/server/route-element-builder.d.ts.map +1 -1
- package/dist/server/rsc-entry/action-middleware-runner.d.ts +14 -14
- package/dist/server/rsc-entry/index.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts +1 -0
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/dist/server/rsc-entry/revalidate-renderer.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-payload.d.ts.map +1 -1
- package/dist/server/rsc-entry/rsc-stream.d.ts +8 -0
- package/dist/server/rsc-entry/rsc-stream.d.ts.map +1 -1
- package/dist/server/rsc-entry/wrap-action-dispatch.d.ts +44 -74
- package/dist/server/rsc-entry/wrap-action-dispatch.d.ts.map +1 -1
- package/dist/server/safe-load.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/shared/redirect-type.d.ts +2 -2
- package/dist/shared/redirect-type.d.ts.map +1 -1
- package/dist/shims/font-google.d.ts.map +1 -1
- package/dist/shims/image.d.ts +120 -120
- package/dist/shims/image.d.ts.map +1 -1
- package/docs/api/32-api-cache.mdx +116 -4
- package/docs/api/34-api-config.mdx +0 -26
- package/docs/learn/09-caching.mdx +126 -10
- package/docs/learn/12-client-navigation.mdx +9 -1
- package/docs/learn/13-configuration.mdx +6 -8
- package/docs/learn/14-deploying.mdx +18 -18
- package/docs/more/03-coming-from-nextjs.mdx +2 -2
- package/docs/more/04-metadata-and-fonts.mdx +1 -1
- package/docs/more/50-ai-agent-instructions.mdx +5 -5
- package/package.json +6 -5
- package/src/adapters/cloudflare-kv-cache.ts +27 -6
- package/src/adapters/cloudflare.ts +63 -25
- package/src/adapters/types.ts +2 -0
- package/src/cache/cache-api.ts +84 -84
- package/src/cache/index.ts +1 -1
- package/src/cache/json-lossy-check.ts +75 -0
- package/src/cache/redis-handler.ts +65 -14
- package/src/cache/timber-cache.ts +10 -2
- package/src/client/browser-entry/index.ts +2 -0
- package/src/client/browser-entry/post-hydration.ts +16 -9
- package/src/client/browser-entry/router-init.ts +2 -0
- package/src/client/history.ts +11 -0
- package/src/client/router.ts +224 -208
- package/src/codec.ts +3 -1
- package/src/config-types.ts +16 -37
- package/src/config-validation.ts +7 -5
- package/src/fonts/pipeline.ts +32 -0
- package/src/fonts/transform.ts +30 -24
- package/src/plugins/adapter-build.ts +132 -13
- package/src/plugins/cache.ts +45 -30
- package/src/plugins/entries.ts +40 -43
- package/src/plugins/fonts.ts +30 -0
- package/src/plugins/server-bundle.ts +7 -15
- package/src/routing/scanner.ts +7 -0
- package/src/server/action-client.ts +1 -1
- package/src/server/als-registry.ts +7 -0
- package/src/server/deny-boundary.ts +6 -3
- package/src/server/middleware-runner.ts +0 -44
- package/src/server/param-coercion.ts +1 -0
- package/src/server/pipeline-phases.ts +11 -13
- package/src/server/pipeline.ts +51 -3
- package/src/server/route-element-builder.ts +59 -9
- package/src/server/rsc-entry/action-middleware-runner.ts +14 -14
- package/src/server/rsc-entry/index.ts +30 -40
- package/src/server/rsc-entry/render-route.ts +6 -2
- package/src/server/rsc-entry/rsc-payload.ts +21 -4
- package/src/server/rsc-entry/rsc-stream.ts +8 -0
- package/src/server/rsc-entry/wrap-action-dispatch.ts +109 -372
- package/dist/_chunks/cache-api-DygSeKCB.js.map +0 -1
- package/dist/_chunks/cli-schema-sync-EXGYPhI2.js.map +0 -1
- package/dist/_chunks/logger-t3uxAmbX.js.map +0 -1
- package/dist/_chunks/tree-match-D2l830j2.js +0 -102
- package/dist/_chunks/tree-match-D2l830j2.js.map +0 -1
- package/dist/adapters/cloudflare.js.map +0 -1
package/dist/server/internal.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a as classifyMetadataRoute, i as METADATA_ROUTE_CONVENTIONS, o as getMetadataRouteAutoLink, r as canonicalize, s as getMetadataRouteServePath } from "../_chunks/canonicalize-P41GR6tY.js";
|
|
2
2
|
import { n as classifyUrlSegment } from "../_chunks/segment-classify-CDDRVKs7.js";
|
|
3
|
-
import { A as
|
|
4
|
-
import { i as coerce, t as executeAction } from "../_chunks/actions-
|
|
5
|
-
import { a as getManifestEntry, b as wasInvalidatedSince, c as lookupPrebuiltPayload, d as checkVersionSkew, i as storeOverlayEntry, l as setPrebuiltPayloadSource, n as lookupOverlay, o as hasPrebuiltPayloadSource, r as overlayKey, s as isParamIndependent, u as applyReloadHeaders, v as currentInvalidationEpoch, x as createSingleflight, y as lastInvalidationEpochFor } from "../_chunks/cache-api-
|
|
3
|
+
import { $ as timingAls, A as setMatchedSegmentPath, C as applyRequestHeaderOverlay, D as getSegmentParams, E as getSearchParams, F as getSetCookieHeaders, G as replaceTraceId, H as getOtelTraceId, I as getWaitUntil, J as withSpan, K as runWithTraceId, L as isDebug, M as setSegmentParams, N as getCookie, O as markResponseFlushed, V as generateTraceId, W as getTraceId, Y as earlyHintsSenderAls, Z as requestContextAls, _ as RedirectSignal, a as logProxyError, c as logRequestReceived, d as logSwrRefetchFailed, f as logWaitUntilRejected, g as DenySignal, h as swallow, i as logMiddlewareShortCircuit, j as setMutableCookieContext, k as runWithRequestContext, l as logRouteError, m as setLogger, n as logCacheMiss, o as logRenderError, p as logWaitUntilUnsupported, q as setSpanAttribute, r as logMiddlewareError, s as logRequestCompleted, t as getLogger, u as logSlowRequest, v as RenderError, w as getHeader } from "../_chunks/logger-AWfuX-KJ.js";
|
|
4
|
+
import { i as coerce, t as executeAction } from "../_chunks/actions-O_LsyCE4.js";
|
|
5
|
+
import { a as getManifestEntry, b as wasInvalidatedSince, c as lookupPrebuiltPayload, d as checkVersionSkew, i as storeOverlayEntry, l as setPrebuiltPayloadSource, n as lookupOverlay, o as hasPrebuiltPayloadSource, r as overlayKey, s as isParamIndependent, u as applyReloadHeaders, v as currentInvalidationEpoch, x as createSingleflight, y as lastInvalidationEpochFor } from "../_chunks/cache-api-B-lhk9p4.js";
|
|
6
6
|
import "../client/error-boundary.js";
|
|
7
7
|
import { n as toBracketKey } from "../_chunks/resolve-schema-Dz3fcFUo.js";
|
|
8
8
|
import "../_chunks/segment-context-ZDnXDkbz.js";
|
|
@@ -403,35 +403,6 @@ async function runMiddlewareChain(chain, ctx) {
|
|
|
403
403
|
if (result instanceof Response) return result;
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
/**
|
|
407
|
-
* Per-request marker for synthetic re-render requests that should NOT
|
|
408
|
-
* re-execute `middleware.ts`. The action-dispatch wrapper runs middleware
|
|
409
|
-
* once on the inbound action POST; when validation fails on the no-JS
|
|
410
|
-
* path, it builds a synthetic GET that flows through the normal pipeline
|
|
411
|
-
* to render the page with `getFormFlash()` data. Without this marker, the
|
|
412
|
-
* pipeline would run middleware a second time on that synthetic GET.
|
|
413
|
-
*
|
|
414
|
-
* The set is keyed by the synthetic Request object itself, so the entry
|
|
415
|
-
* lives exactly as long as the request and is garbage-collected with it.
|
|
416
|
-
* Cannot be set or detected by user code — there is no header, no URL
|
|
417
|
-
* parameter, nothing on the wire that an attacker could spoof.
|
|
418
|
-
*
|
|
419
|
-
* See TIM-871.
|
|
420
|
-
*
|
|
421
|
-
* @internal — framework use only.
|
|
422
|
-
*/
|
|
423
|
-
var middlewareBypassRequests = /* @__PURE__ */ new WeakSet();
|
|
424
|
-
/**
|
|
425
|
-
* Check whether a request was marked to bypass middleware.
|
|
426
|
-
*
|
|
427
|
-
* Called by `handleRequest` in pipeline-phases.ts before invoking the
|
|
428
|
-
* middleware phase. Returns false for any request not explicitly marked.
|
|
429
|
-
*
|
|
430
|
-
* @internal
|
|
431
|
-
*/
|
|
432
|
-
function shouldBypassMiddleware(req) {
|
|
433
|
-
return middlewareBypassRequests.has(req);
|
|
434
|
-
}
|
|
435
406
|
//#endregion
|
|
436
407
|
//#region src/server/metadata-social.ts
|
|
437
408
|
/**
|
|
@@ -1433,7 +1404,10 @@ function renderDenyEntry(entry, status, data) {
|
|
|
1433
1404
|
*/
|
|
1434
1405
|
function setDenyStatus(status) {
|
|
1435
1406
|
const store = requestContextAls.getStore();
|
|
1436
|
-
if (store)
|
|
1407
|
+
if (store) {
|
|
1408
|
+
store.denyStatus = status;
|
|
1409
|
+
store.onDenyStatus?.();
|
|
1410
|
+
}
|
|
1437
1411
|
}
|
|
1438
1412
|
//#endregion
|
|
1439
1413
|
//#region src/server/access-gate.tsx
|
|
@@ -1580,6 +1554,7 @@ async function coerceSegmentParams(match) {
|
|
|
1580
1554
|
const codec = globalCodecs[bracketKey];
|
|
1581
1555
|
if (!codec) continue;
|
|
1582
1556
|
const key = segment.paramName;
|
|
1557
|
+
if (!(key in mergeTarget)) continue;
|
|
1583
1558
|
try {
|
|
1584
1559
|
mergeTarget[key] = sanitizeParamValue(codec.parse(mergeTarget[key]));
|
|
1585
1560
|
} catch (err) {
|
|
@@ -2036,16 +2011,20 @@ function validateInterceptionHeader(raw, stripTrailingSlash) {
|
|
|
2036
2011
|
return result.pathname;
|
|
2037
2012
|
}
|
|
2038
2013
|
/**
|
|
2039
|
-
* Run the proxy.ts phase. Calls user proxy code
|
|
2040
|
-
*
|
|
2014
|
+
* Run the proxy.ts phase. Calls user proxy code with a `next()` continuation.
|
|
2015
|
+
*
|
|
2016
|
+
* When `next` is provided, it replaces the default `handleRequest` as the
|
|
2017
|
+
* continuation — this lets the pipeline inject action dispatch between proxy
|
|
2018
|
+
* and route matching (TIM-1213). The proxy resolver was picked at pipeline
|
|
2041
2019
|
* construction time so the hot path sees no per-request branching on the
|
|
2042
2020
|
* `ProxyConfig` discriminant.
|
|
2043
2021
|
*/
|
|
2044
|
-
async function runProxyPhase(config, getProxy, req, method, path) {
|
|
2022
|
+
async function runProxyPhase(config, getProxy, req, method, path, next) {
|
|
2045
2023
|
const detailed = config.serverTiming === "detailed";
|
|
2046
2024
|
try {
|
|
2047
2025
|
const proxyExport = await getProxy();
|
|
2048
|
-
const
|
|
2026
|
+
const continuation = next ?? (() => handleRequest(config, req, method, path, true));
|
|
2027
|
+
const proxyFn = () => runProxy(proxyExport, req, continuation);
|
|
2049
2028
|
return {
|
|
2050
2029
|
kind: "response",
|
|
2051
2030
|
phase: "proxy",
|
|
@@ -2313,7 +2292,7 @@ async function handleRequest(config, req, method, path, pathIsCanonical) {
|
|
|
2313
2292
|
setSegmentParams(match.segmentParams);
|
|
2314
2293
|
const segmentPath = match.segments.map((s) => s.segmentName).filter(Boolean).join("/") || "/";
|
|
2315
2294
|
setMatchedSegmentPath(segmentPath.startsWith("/") ? segmentPath : `/${segmentPath}`);
|
|
2316
|
-
return outcomeToResponse(config,
|
|
2295
|
+
return outcomeToResponse(config, match.middlewareChain.length > 0 ? await runMiddlewarePhase(config, req, match, responseHeaders, requestHeaderOverlay, {
|
|
2317
2296
|
canonicalPathname,
|
|
2318
2297
|
interception
|
|
2319
2298
|
}) : await runRenderPhase(config, req, match, responseHeaders, requestHeaderOverlay, {
|
|
@@ -2344,7 +2323,7 @@ function createPipeline(config) {
|
|
|
2344
2323
|
const slowRequestMs = config.slowRequestMs ?? 3e3;
|
|
2345
2324
|
const serverTiming = config.serverTiming ?? "total";
|
|
2346
2325
|
let activeRequests = 0;
|
|
2347
|
-
|
|
2326
|
+
const pipelineFn = async (req) => {
|
|
2348
2327
|
const url = new URL(req.url);
|
|
2349
2328
|
const method = req.method;
|
|
2350
2329
|
const path = url.pathname;
|
|
@@ -2376,13 +2355,20 @@ function createPipeline(config) {
|
|
|
2376
2355
|
canonicalUrl.pathname = canonicalPath;
|
|
2377
2356
|
canonicalReq = new Request(canonicalUrl.toString(), req);
|
|
2378
2357
|
}
|
|
2358
|
+
const innerHandler = async () => {
|
|
2359
|
+
if (config.dispatchAction) {
|
|
2360
|
+
const actionResult = await config.dispatchAction(canonicalReq, canonicalPath, pipelineFn);
|
|
2361
|
+
if (actionResult) return actionResult;
|
|
2362
|
+
}
|
|
2363
|
+
return handleRequest(config, canonicalReq, method, canonicalPath, true);
|
|
2364
|
+
};
|
|
2379
2365
|
let result;
|
|
2380
|
-
if (proxyResolver) result = await outcomeToResponse(config, await runProxyPhase(config, proxyResolver, canonicalReq, method, canonicalPath), {
|
|
2366
|
+
if (proxyResolver) result = await outcomeToResponse(config, await runProxyPhase(config, proxyResolver, canonicalReq, method, canonicalPath, innerHandler), {
|
|
2381
2367
|
req: canonicalReq,
|
|
2382
2368
|
method,
|
|
2383
2369
|
path: canonicalPath
|
|
2384
2370
|
});
|
|
2385
|
-
else result = await
|
|
2371
|
+
else result = await innerHandler();
|
|
2386
2372
|
await setSpanAttribute("http.response.status_code", result.status);
|
|
2387
2373
|
const varyTokens = ["Accept"];
|
|
2388
2374
|
if (config.interceptionRewrites?.length) varyTokens.push("X-Timber-URL");
|
|
@@ -2428,6 +2414,7 @@ function createPipeline(config) {
|
|
|
2428
2414
|
});
|
|
2429
2415
|
});
|
|
2430
2416
|
};
|
|
2417
|
+
return pipelineFn;
|
|
2431
2418
|
}
|
|
2432
2419
|
//#endregion
|
|
2433
2420
|
//#region src/server/build-manifest.ts
|