@timber-js/app 0.2.0-alpha.245 → 0.2.0-alpha.246
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/dev-span-0aG7Q_Ph.js.map +1 -1
- package/dist/native/rsc/server/build-manifest.js +1 -4
- package/dist/native/rsc/server/build-manifest.js.map +1 -1
- package/dist/native/rsc/server/early-hints.js +2 -1
- package/dist/native/rsc/server/early-hints.js.map +1 -1
- package/dist/native/rsc/server/pipeline-phases.js +2 -8
- package/dist/native/rsc/server/pipeline-phases.js.map +1 -1
- package/dist/native/rsc/server/rsc-entry/render-route.js +1 -3
- package/dist/native/rsc/server/rsc-entry/render-route.js.map +1 -1
- package/dist/native/ssr/server/build-manifest.js.map +1 -1
- package/dist/native/ssr/server/early-hints.js +2 -1
- package/dist/native/ssr/server/early-hints.js.map +1 -1
- package/dist/native/ssr/server/pipeline-phases.js +2 -8
- package/dist/native/ssr/server/pipeline-phases.js.map +1 -1
- package/dist/server/build-manifest.d.ts +2 -8
- package/dist/server/build-manifest.d.ts.map +1 -1
- package/dist/server/early-hints.d.ts +2 -2
- package/dist/server/early-hints.d.ts.map +1 -1
- package/dist/server/internal.js +85 -91
- package/dist/server/internal.js.map +1 -1
- package/dist/server/pipeline-phases.d.ts.map +1 -1
- package/dist/server/rsc-entry/render-route.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/server/build-manifest.ts +2 -17
- package/src/server/early-hints.ts +11 -6
- package/src/server/pipeline-phases.ts +2 -14
- package/src/server/rsc-entry/render-route.ts +9 -11
|
@@ -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":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;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.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/render-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"render-route.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/render-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAO1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAG9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAQ/D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,mEAAmE;IACnE,cAAc,EAAE,sBAAsB,CAAC;IACvC,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAClE;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,UAAU,EACjB,eAAe,EAAE,OAAO,EACxB,IAAI,EAAE,eAAe,EACrB,YAAY,CAAC,EAAE,mBAAmB,GACjC,OAAO,CAAC,QAAQ,CAAC,CA2JnB"}
|
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.246",
|
|
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",
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The build manifest maps route segment file paths to their output
|
|
5
5
|
* chunks from Vite's client build. This enables:
|
|
6
|
-
* - <link rel="stylesheet">
|
|
6
|
+
* - 103 Early Hints / Link preloads for per-route CSS (the <link rel="stylesheet">
|
|
7
|
+
* tags themselves come from React Float, never from this manifest)
|
|
7
8
|
* - <script type="module"> with hashed URLs in production
|
|
8
9
|
* - <link rel="modulepreload"> for client chunk dependencies
|
|
9
10
|
* - Link preload headers for Early Hints (103)
|
|
@@ -94,22 +95,6 @@ export function collectRouteCss(segments: SegmentWithFiles[], manifest: BuildMan
|
|
|
94
95
|
return result;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
/**
|
|
98
|
-
* Generate <link rel="stylesheet"> tags for CSS URLs.
|
|
99
|
-
*
|
|
100
|
-
* Returns an HTML string to prepend to headHtml for injection
|
|
101
|
-
* via injectHead() before </head>.
|
|
102
|
-
*/
|
|
103
|
-
export function buildCssLinkTags(cssUrls: string[]): string {
|
|
104
|
-
// Emit only <link rel="stylesheet"> — no preload tags. CSS preloading
|
|
105
|
-
// is handled by 103 Early Hints (Link header) which fires before the
|
|
106
|
-
// HTML stream. Float also emits `<link rel="stylesheet" data-precedence>`
|
|
107
|
-
// at the top of <head> during Fizz rendering — the browser discovers
|
|
108
|
-
// CSS from that tag. A <link rel="preload"> here would arrive *after*
|
|
109
|
-
// Float's stylesheet tag and trigger "Preload was ignored" warnings.
|
|
110
|
-
return cssUrls.map((url) => `<link rel="stylesheet" href="${url}">`).join('');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
98
|
// ─── Font utilities ──────────────────────────────────────────────────────
|
|
114
99
|
|
|
115
100
|
/**
|
|
@@ -67,7 +67,7 @@ export interface EarlyHint {
|
|
|
67
67
|
* browser deduplicates them correctly.
|
|
68
68
|
*
|
|
69
69
|
* Examples:
|
|
70
|
-
* `</styles/root.css>; as=style; rel=preload`
|
|
70
|
+
* `</styles/root.css>; as=style; rel=preload; crossorigin=anonymous`
|
|
71
71
|
* `</fonts/inter.woff2>; as=font; rel=preload; crossorigin=anonymous`
|
|
72
72
|
* `</_timber/client.js>; rel=modulepreload`
|
|
73
73
|
* `<https://fonts.googleapis.com>; rel=preconnect`
|
|
@@ -100,7 +100,7 @@ export interface EarlyHintOptions {
|
|
|
100
100
|
* Collect all Link header strings for a matched route's segment chain.
|
|
101
101
|
*
|
|
102
102
|
* Walks the build manifest to emit hints for:
|
|
103
|
-
* - CSS stylesheets (as=style; rel=preload)
|
|
103
|
+
* - CSS stylesheets (as=style; rel=preload; crossorigin=anonymous)
|
|
104
104
|
* - Font assets (as=font; rel=preload; crossorigin)
|
|
105
105
|
* - JS modulepreload hints (rel=modulepreload) — unless skipJs is set
|
|
106
106
|
*
|
|
@@ -126,11 +126,16 @@ export function collectEarlyHintHeaders(
|
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
// Per-route CSS — as=style; rel=preload
|
|
130
|
-
// The
|
|
131
|
-
//
|
|
129
|
+
// Per-route CSS — as=style; rel=preload; crossorigin=anonymous
|
|
130
|
+
// The stylesheet the browser applies is React Float's
|
|
131
|
+
// `<link rel="stylesheet" crossorigin="anonymous">` from @vitejs/plugin-rsc.
|
|
132
|
+
// A preload only satisfies a later request with the same CORS mode, so a
|
|
133
|
+
// no-cors preload would be a wasted, separate download.
|
|
132
134
|
for (const url of collectRouteCss(segments, manifest)) {
|
|
133
|
-
add(
|
|
135
|
+
add(
|
|
136
|
+
url,
|
|
137
|
+
formatLinkHeader({ href: url, rel: 'preload', as: 'style', crossOrigin: 'anonymous' })
|
|
138
|
+
);
|
|
134
139
|
}
|
|
135
140
|
|
|
136
141
|
// Fonts — as=font; rel=preload; crossorigin (crossorigin required per spec)
|
|
@@ -16,6 +16,7 @@ import { canonicalize } from './canonicalize.ts';
|
|
|
16
16
|
import { runProxy } from './proxy.ts';
|
|
17
17
|
import { runMiddlewareChain } from './middleware-runner.ts';
|
|
18
18
|
import { withTiming } from './server-timing.ts';
|
|
19
|
+
import { formatLinkHeader } from './early-hints.ts';
|
|
19
20
|
import {
|
|
20
21
|
applyRequestHeaderOverlay,
|
|
21
22
|
setMutableCookieContext,
|
|
@@ -123,20 +124,7 @@ export async function runMiddlewarePhase(
|
|
|
123
124
|
return requestCspNonce();
|
|
124
125
|
},
|
|
125
126
|
earlyHints: (hints) => {
|
|
126
|
-
for (const hint of hints)
|
|
127
|
-
// Match Cloudflare's cached Early Hints attribute order: `as` before `rel`.
|
|
128
|
-
// Cloudflare caches Link headers and re-emits them on subsequent 200s.
|
|
129
|
-
// If our order differs, the browser sees duplicate preloads and warns.
|
|
130
|
-
let value: string;
|
|
131
|
-
if (hint.as !== undefined) {
|
|
132
|
-
value = `<${hint.href}>; as=${hint.as}; rel=${hint.rel}`;
|
|
133
|
-
} else {
|
|
134
|
-
value = `<${hint.href}>; rel=${hint.rel}`;
|
|
135
|
-
}
|
|
136
|
-
if (hint.crossOrigin !== undefined) value += `; crossorigin=${hint.crossOrigin}`;
|
|
137
|
-
if (hint.fetchPriority !== undefined) value += `; fetchpriority=${hint.fetchPriority}`;
|
|
138
|
-
responseHeaders.append('Link', value);
|
|
139
|
-
}
|
|
127
|
+
for (const hint of hints) responseHeaders.append('Link', formatLinkHeader(hint));
|
|
140
128
|
},
|
|
141
129
|
};
|
|
142
130
|
|
|
@@ -19,10 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
import type { BuildManifest } from '../build-manifest.ts';
|
|
21
21
|
import {
|
|
22
|
-
buildCssLinkTags,
|
|
23
22
|
buildFontPreloadTags,
|
|
24
23
|
buildModulepreloadTags,
|
|
25
|
-
collectRouteCss,
|
|
26
24
|
collectRouteFonts,
|
|
27
25
|
collectRouteModulepreloads,
|
|
28
26
|
} from '../build-manifest.ts';
|
|
@@ -175,15 +173,15 @@ export async function renderRoute(
|
|
|
175
173
|
headHtml += buildFontPreloadTags(fontEntries);
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
// No <link rel="stylesheet"> is spliced here. @vitejs/plugin-rsc renders
|
|
177
|
+
// each server component module's CSS as a React <link precedence> element
|
|
178
|
+
// (client-reference CSS through preinit()), and Float hoists those to the
|
|
179
|
+
// top of <head>. Layouts and pages always render in the shell (timber has
|
|
180
|
+
// no loading.tsx boundary), so every segment's CSS is already there. A
|
|
181
|
+
// second, string-spliced tag for the same URL is invisible to Float and
|
|
182
|
+
// differs in CORS mode (no crossorigin), so the browser fetched the file
|
|
183
|
+
// twice. The 103 / Link preload (early-hints.ts) is what gets CSS loading
|
|
184
|
+
// before the HTML arrives.
|
|
187
185
|
|
|
188
186
|
// Skip modulepreload tags when client JavaScript is disabled — no JS to preload.
|
|
189
187
|
if (!clientJsDisabled) {
|