@timber-js/app 0.2.0-alpha.217 → 0.2.0-alpha.218
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-CUh3cClk.js.map +1 -1
- package/dist/_chunks/cloudflare-Byxl8FWP.js.map +1 -1
- package/dist/_chunks/dev-server-B8zsT-ee.js.map +1 -1
- package/dist/_chunks/dist-DtrJyBbw.js.map +1 -1
- package/dist/_chunks/graph-cache-CYiUS2aS.js.map +1 -1
- package/dist/_chunks/use-query-states-I3JMng6J.js.map +1 -1
- package/dist/adapters/cloudflare.js +1 -2
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/analyze/graph-command.js.map +1 -1
- package/dist/client/error-boundary.js +1 -2
- package/dist/cookies/index.js.map +1 -1
- package/dist/index.js +29 -26
- package/dist/index.js.map +1 -1
- package/dist/plugins/build-manifest.d.ts.map +1 -1
- package/dist/search-params/index.js.map +1 -1
- package/dist/server/internal.js +11 -2
- package/dist/server/internal.js.map +1 -1
- package/dist/server/pipeline-metadata.d.ts +9 -0
- package/dist/server/pipeline-metadata.d.ts.map +1 -1
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/sitemap-handler.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/client/browser-entry/index.ts +7 -1
- package/src/plugins/build-manifest.ts +12 -27
- package/src/server/pipeline-metadata.ts +11 -1
- package/src/server/pipeline-phases.ts +9 -2
- package/src/server/sitemap-handler.ts +14 -21
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
* See design/16-metadata.md §"Metadata Routes"
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Cache-Control the framework sets on metadata route responses it produces:
|
|
11
|
+
* static files, serialized handler results (sitemap, robots, manifest) and
|
|
12
|
+
* the auto-generated sitemap. A Response a handler returns is sent with its
|
|
13
|
+
* own headers only — the framework adds no default to it.
|
|
14
|
+
*
|
|
15
|
+
* See design/16-metadata.md §"Caching" (under "Metadata Routes")
|
|
16
|
+
*/
|
|
17
|
+
export declare const METADATA_CACHE_CONTROL = "public, max-age=14400, must-revalidate";
|
|
9
18
|
/**
|
|
10
19
|
* Serve a static metadata file by reading it from disk.
|
|
11
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-metadata.d.ts","sourceRoot":"","sources":["../../src/server/pipeline-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"pipeline-metadata.d.ts","sourceRoot":"","sources":["../../src/server/pipeline-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,2CAA2C,CAAC;AAc/E;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,OAAO,oBAAoB,EAAE,kBAAkB,GACzD,OAAO,CAAC,QAAQ,CAAC,CAanB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,GACD,MAAM,CAoBR;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,MAAM,CAMnE;AAED,qCAAqC;AACrC,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline-phases.d.ts","sourceRoot":"","sources":["../../src/server/pipeline-phases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"pipeline-phases.d.ts","sourceRoot":"","sources":["../../src/server/pipeline-phases.ts"],"names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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sitemap-handler.d.ts","sourceRoot":"","sources":["../../src/server/sitemap-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"sitemap-handler.d.ts","sourceRoot":"","sources":["../../src/server/sitemap-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAevD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,WAAW,EACjB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,SAAS,CAuG9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@timber-js/app",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.218",
|
|
4
4
|
"description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare-workers",
|
|
@@ -152,13 +152,13 @@
|
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
154
154
|
"@opentelemetry/api": "^1.9.1",
|
|
155
|
-
"@opentelemetry/context-async-hooks": "^2.
|
|
156
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
155
|
+
"@opentelemetry/context-async-hooks": "^2.12.0",
|
|
156
|
+
"@opentelemetry/sdk-trace-base": "^2.12.0",
|
|
157
157
|
"cookie": "^2.0.1",
|
|
158
158
|
"jsonc-parser": "^3.3.1",
|
|
159
|
-
"magic-string": "^1.4.
|
|
159
|
+
"magic-string": "^1.4.3",
|
|
160
160
|
"nitro": "3.0.260903-beta",
|
|
161
|
-
"oxc-transform-react": "^0.
|
|
161
|
+
"oxc-transform-react": "^0.153.0",
|
|
162
162
|
"srvx": "^1.0.5"
|
|
163
163
|
},
|
|
164
164
|
"peerDependencies": {
|
|
@@ -167,10 +167,10 @@
|
|
|
167
167
|
"@content-collections/vite": "^0.2.0 || ^0.3.0",
|
|
168
168
|
"@typescript/native-preview": "^7.0.0-dev.0",
|
|
169
169
|
"@vitejs/plugin-react": "^6.1.0",
|
|
170
|
-
"@vitejs/plugin-rsc": "
|
|
170
|
+
"@vitejs/plugin-rsc": "^0.5.35",
|
|
171
171
|
"nuqs": "^2.0.0",
|
|
172
|
-
"react": "
|
|
173
|
-
"react-dom": "
|
|
172
|
+
"react": "19.3.0",
|
|
173
|
+
"react-dom": "19.3.0",
|
|
174
174
|
"satteri": "^0.9.5",
|
|
175
175
|
"vite": "8.3.0",
|
|
176
176
|
"vite-plugin-satteri": "^0.2.15",
|
|
@@ -78,7 +78,13 @@ function bootstrap(runtimeConfig: typeof config, formState: ReactFormState | nul
|
|
|
78
78
|
|
|
79
79
|
// Static mode: fetch _rsc/*.rsc files instead of route URLs with
|
|
80
80
|
// Accept headers. Static hosts ignore Accept headers (TIM-1243).
|
|
81
|
-
|
|
81
|
+
// Only for built output — the .rsc files exist only after static
|
|
82
|
+
// generation, and `timber dev` renders route URLs on request like
|
|
83
|
+
// server mode, so dev keeps the Accept-header fetch path.
|
|
84
|
+
if (
|
|
85
|
+
(runtimeConfig as Record<string, unknown>).output === 'static' &&
|
|
86
|
+
!(runtimeConfig as Record<string, unknown>).dev
|
|
87
|
+
) {
|
|
82
88
|
setStaticMode(true);
|
|
83
89
|
}
|
|
84
90
|
|
|
@@ -22,7 +22,6 @@ import type { Plugin, ResolvedConfig } from 'vite';
|
|
|
22
22
|
import type { PluginContext } from '../plugin-context.ts';
|
|
23
23
|
import { EMPTY_BUILD_MANIFEST, type BuildManifest } from '../server/build-manifest.ts';
|
|
24
24
|
import type { SegmentNode, RouteFile } from '../routing/types.ts';
|
|
25
|
-
import { isDynamicMetadataExtension } from '../server/metadata-routes.ts';
|
|
26
25
|
|
|
27
26
|
// Rollup types used by generateBundle hook — imported from vite which re-exports them.
|
|
28
27
|
// We define minimal interfaces here to avoid a direct 'rollup' dependency.
|
|
@@ -217,36 +216,22 @@ function collectTransitiveBundleDeps(
|
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
/**
|
|
220
|
-
* Walk the route tree and compute short content hashes for metadata route
|
|
221
|
-
*
|
|
222
|
-
*
|
|
219
|
+
* Walk the route tree and compute short content hashes for metadata route
|
|
220
|
+
* files, used to cache-bust the auto-linked opengraph-image URL in <head>.
|
|
221
|
+
* A dynamic handler (.ts/.tsx) is hashed by its source: its output can depend
|
|
222
|
+
* on runtime data too, but the source is the best build-time signal there is.
|
|
223
|
+
* An unreadable file gets no hash, and the link falls back to the per-startup
|
|
224
|
+
* nonce.
|
|
223
225
|
*/
|
|
224
226
|
function computeMetadataRouteHashes(node: SegmentNode<RouteFile>): Record<string, string> {
|
|
225
227
|
const hashes: Record<string, string> = {};
|
|
226
228
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const hash = createHash('sha256').update(content).digest('hex').slice(0, 8);
|
|
234
|
-
hashes[file.filePath] = hash;
|
|
235
|
-
} catch {
|
|
236
|
-
// File unreadable — skip hash, DEV_NONCE fallback applies
|
|
237
|
-
}
|
|
238
|
-
} else {
|
|
239
|
-
// For dynamic files (.ts/.tsx), hash the source file as a reasonable
|
|
240
|
-
// approximation — the output depends on runtime data too, but the
|
|
241
|
-
// source change is the best build-time signal we have.
|
|
242
|
-
try {
|
|
243
|
-
const content = readFileSync(file.filePath);
|
|
244
|
-
const hash = createHash('sha256').update(content).digest('hex').slice(0, 8);
|
|
245
|
-
hashes[file.filePath] = hash;
|
|
246
|
-
} catch {
|
|
247
|
-
// File unreadable — skip
|
|
248
|
-
}
|
|
249
|
-
}
|
|
229
|
+
for (const file of Object.values(node.metadataRoutes ?? {})) {
|
|
230
|
+
try {
|
|
231
|
+
const content = readFileSync(file.filePath);
|
|
232
|
+
hashes[file.filePath] = createHash('sha256').update(content).digest('hex').slice(0, 8);
|
|
233
|
+
} catch {
|
|
234
|
+
// File unreadable — skip hash, dev nonce fallback applies
|
|
250
235
|
}
|
|
251
236
|
}
|
|
252
237
|
|
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
|
|
10
10
|
import { readFile } from 'node:fs/promises';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Cache-Control the framework sets on metadata route responses it produces:
|
|
14
|
+
* static files, serialized handler results (sitemap, robots, manifest) and
|
|
15
|
+
* the auto-generated sitemap. A Response a handler returns is sent with its
|
|
16
|
+
* own headers only — the framework adds no default to it.
|
|
17
|
+
*
|
|
18
|
+
* See design/16-metadata.md §"Caching" (under "Metadata Routes")
|
|
19
|
+
*/
|
|
20
|
+
export const METADATA_CACHE_CONTROL = 'public, max-age=14400, must-revalidate';
|
|
21
|
+
|
|
12
22
|
/**
|
|
13
23
|
* Content types that are text-based and should include charset=utf-8.
|
|
14
24
|
* Binary formats (images) should not include charset.
|
|
@@ -41,7 +51,7 @@ export async function serveStaticMetadataFile(
|
|
|
41
51
|
const headers: Record<string, string> = {
|
|
42
52
|
'Content-Type': isText ? `${contentType}; charset=utf-8` : contentType,
|
|
43
53
|
'Content-Length': String(body.byteLength),
|
|
44
|
-
'Cache-Control':
|
|
54
|
+
'Cache-Control': METADATA_CACHE_CONTROL,
|
|
45
55
|
};
|
|
46
56
|
|
|
47
57
|
return new Response(body, { status: 200, headers });
|
|
@@ -28,7 +28,11 @@ import { logRenderError } from './logger.ts';
|
|
|
28
28
|
import { isDenySignal, isRedirectSignal } from './signal-identity.ts';
|
|
29
29
|
import { ParamCoercionError } from './param-coercion.ts';
|
|
30
30
|
import { checkVersionSkew, applyReloadHeaders } from './version-skew.ts';
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
METADATA_CACHE_CONTROL,
|
|
33
|
+
serveStaticMetadataFile,
|
|
34
|
+
serializeSitemap,
|
|
35
|
+
} from './pipeline-metadata.ts';
|
|
32
36
|
import { loadModule } from './safe-load.ts';
|
|
33
37
|
import { resolveInterceptedRoute } from './pipeline-interception.ts';
|
|
34
38
|
import { isApiRouteChain } from './route-matcher.ts';
|
|
@@ -271,6 +275,9 @@ export async function handleRequest(
|
|
|
271
275
|
// If the handler returns a Response, normalize headers so the
|
|
272
276
|
// outer Server-Timing writer can append without hitting an
|
|
273
277
|
// immutable header bag (e.g. user returns Response.redirect()).
|
|
278
|
+
// No default Cache-Control here: the handler runs in the request
|
|
279
|
+
// context and may vary on cookies or headers, so a public default
|
|
280
|
+
// could serve one user's response to another (#1064).
|
|
274
281
|
if (handlerResult instanceof Response) {
|
|
275
282
|
return cloneWithMutableHeaders(handlerResult);
|
|
276
283
|
}
|
|
@@ -294,7 +301,7 @@ export async function handleRequest(
|
|
|
294
301
|
status: 200,
|
|
295
302
|
headers: {
|
|
296
303
|
'Content-Type': `${contentType}; charset=utf-8`,
|
|
297
|
-
'Cache-Control':
|
|
304
|
+
'Cache-Control': METADATA_CACHE_CONTROL,
|
|
298
305
|
},
|
|
299
306
|
});
|
|
300
307
|
} catch (error) {
|
|
@@ -17,8 +17,19 @@ import {
|
|
|
17
17
|
type SitemapResult,
|
|
18
18
|
} from './sitemap-generator.ts';
|
|
19
19
|
import { loadModule } from './safe-load.ts';
|
|
20
|
+
import { METADATA_CACHE_CONTROL } from './pipeline-metadata.ts';
|
|
20
21
|
import type { SegmentNode } from '../routing/types.ts';
|
|
21
22
|
|
|
23
|
+
function xmlResponse(xml: string): Response {
|
|
24
|
+
return new Response(xml, {
|
|
25
|
+
status: 200,
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/xml; charset=utf-8',
|
|
28
|
+
'Cache-Control': METADATA_CACHE_CONTROL,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
/** Regex to match /sitemap/N.xml where N is a non-negative integer. */
|
|
23
34
|
const SITEMAP_PAGE_PATTERN = /^\/sitemap\/(\d+)\.xml$/;
|
|
24
35
|
|
|
@@ -109,13 +120,7 @@ export function createAutoSitemapHandler(
|
|
|
109
120
|
if (pathname === '/sitemap.xml') {
|
|
110
121
|
const result = await getOrGenerateSitemap();
|
|
111
122
|
const xml = result.type === 'single' ? result.xml : result.indexXml;
|
|
112
|
-
return
|
|
113
|
-
status: 200,
|
|
114
|
-
headers: {
|
|
115
|
-
'Content-Type': 'application/xml; charset=utf-8',
|
|
116
|
-
'Cache-Control': 'public, max-age=14400, must-revalidate',
|
|
117
|
-
},
|
|
118
|
-
});
|
|
123
|
+
return xmlResponse(xml);
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
// Handle /sitemap/N.xml (paginated sub-sitemaps)
|
|
@@ -126,13 +131,7 @@ export function createAutoSitemapHandler(
|
|
|
126
131
|
// No pagination — only page 0 is valid for a single sitemap
|
|
127
132
|
const pageIndex = parseInt(pageMatch[1], 10);
|
|
128
133
|
if (pageIndex === 0) {
|
|
129
|
-
return
|
|
130
|
-
status: 200,
|
|
131
|
-
headers: {
|
|
132
|
-
'Content-Type': 'application/xml; charset=utf-8',
|
|
133
|
-
'Cache-Control': 'public, max-age=14400, must-revalidate',
|
|
134
|
-
},
|
|
135
|
-
});
|
|
134
|
+
return xmlResponse(result.xml);
|
|
136
135
|
}
|
|
137
136
|
return new Response(null, { status: 404 });
|
|
138
137
|
}
|
|
@@ -142,13 +141,7 @@ export function createAutoSitemapHandler(
|
|
|
142
141
|
if (!pageXml) {
|
|
143
142
|
return new Response(null, { status: 404 });
|
|
144
143
|
}
|
|
145
|
-
return
|
|
146
|
-
status: 200,
|
|
147
|
-
headers: {
|
|
148
|
-
'Content-Type': 'application/xml; charset=utf-8',
|
|
149
|
-
'Cache-Control': 'public, max-age=14400, must-revalidate',
|
|
150
|
-
},
|
|
151
|
-
});
|
|
144
|
+
return xmlResponse(pageXml);
|
|
152
145
|
}
|
|
153
146
|
|
|
154
147
|
// Not a sitemap URL — pass through
|