@timber-js/app 0.2.0-alpha.18 → 0.2.0-alpha.19
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/server/rsc-entry/ssr-renderer.d.ts.map +1 -1
- package/dist/server/ssr-entry.d.ts.map +1 -1
- package/dist/server/ssr-render.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/server/rsc-entry/ssr-renderer.ts +30 -1
- package/src/server/ssr-entry.ts +0 -8
- package/src/server/ssr-render.ts +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-renderer.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/ssr-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAYrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,UAAU,gBAAgB;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACtC,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"ssr-renderer.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/ssr-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAYrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,UAAU,gBAAgB;IACxB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACtC,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;IACzC,KAAK,EAAE,UAAU,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,qBAAqB,CAAC;IACvC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmMjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-entry.d.ts","sourceRoot":"","sources":["../../src/server/ssr-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA6BH;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,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AC;IACnB,6CAA6C;IAC7C,eAAe,EAAE,OAAO,CAAC;IACzB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qEAAqE;IACrE,SAAS,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACvC;;;0DAGsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;iFAE6E;IAC7E,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;4DACwD;IACxD,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,cAAc,CAAC,UAAU,CAAC,EACrC,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,QAAQ,CAAC,CA4EnB;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr-render.d.ts","sourceRoot":"","sources":["../../src/server/ssr-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAmBvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,SAAS,EAClB,OAAO,CAAC,EAAE;IAAE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAC7F,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"ssr-render.d.ts","sourceRoot":"","sources":["../../src/server/ssr-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAmBvC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,SAAS,EAClB,OAAO,CAAC,EAAE;IAAE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAC7F,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAmDrC;AAED;;;;;;;;;;;;GAYG;AACH,2CAA2C;AAC3C,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,EAClC,MAAM,CAAC,EAAE,WAAW,GACnB,cAAc,CAAC,UAAU,CAAC,CAkC5B;AAeD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,EACtC,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,OAAO,GACvB,QAAQ,CASV"}
|
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.19",
|
|
4
4
|
"description": "Vite-native React framework for Cloudflare Workers — correct HTTP semantics, real status codes, pages that work without JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare-workers",
|
|
@@ -81,7 +81,36 @@ export async function renderSsrResponse(opts: SsrRenderOptions): Promise<Respons
|
|
|
81
81
|
|
|
82
82
|
// Tee the RSC stream — one copy goes to SSR for HTML rendering,
|
|
83
83
|
// the other is inlined in the HTML for client-side hydration.
|
|
84
|
-
|
|
84
|
+
//
|
|
85
|
+
// EXPERIMENT: Buffer the entire RSC stream before SSR to measure
|
|
86
|
+
// if the interleaved RSC→SSR pull pattern is the bottleneck.
|
|
87
|
+
const _bufStart = performance.now();
|
|
88
|
+
const _rscReader = rscStream.getReader();
|
|
89
|
+
const _chunks: Uint8Array[] = [];
|
|
90
|
+
let _totalBytes = 0;
|
|
91
|
+
for (;;) {
|
|
92
|
+
const { done, value } = await _rscReader.read();
|
|
93
|
+
if (done) break;
|
|
94
|
+
_chunks.push(value);
|
|
95
|
+
_totalBytes += value.length;
|
|
96
|
+
}
|
|
97
|
+
const _bufEnd = performance.now();
|
|
98
|
+
|
|
99
|
+
// Reconstruct two streams from the buffered chunks
|
|
100
|
+
const ssrStream = new ReadableStream<Uint8Array>({
|
|
101
|
+
start(controller) {
|
|
102
|
+
for (const chunk of _chunks) controller.enqueue(chunk);
|
|
103
|
+
controller.close();
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
const inlineStream = new ReadableStream<Uint8Array>({
|
|
107
|
+
start(controller) {
|
|
108
|
+
for (const chunk of _chunks) controller.enqueue(chunk);
|
|
109
|
+
controller.close();
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
// eslint-disable-next-line no-console
|
|
113
|
+
console.log(`[rsc-buf] buffered ${_totalBytes} bytes (${_chunks.length} chunks) in ${(_bufEnd - _bufStart).toFixed(1)}ms`);
|
|
85
114
|
|
|
86
115
|
// Embed segment metadata in HTML for initial hydration.
|
|
87
116
|
// The client reads this to populate its segment cache before the
|
package/src/server/ssr-entry.ts
CHANGED
|
@@ -137,9 +137,7 @@ export async function handleSsr(
|
|
|
137
137
|
// createFromReadableStream resolves client component references
|
|
138
138
|
// (from "use client" modules) using the SSR environment's module
|
|
139
139
|
// map, importing the actual components for server-side rendering.
|
|
140
|
-
const _s0 = performance.now();
|
|
141
140
|
const element = createFromReadableStream(rscStream) as React.ReactNode;
|
|
142
|
-
const _s1 = performance.now();
|
|
143
141
|
|
|
144
142
|
// Wrap with a server-safe nuqs adapter so that 'use client' components
|
|
145
143
|
// that call nuqs hooks (useQueryStates, useQueryState) can SSR correctly.
|
|
@@ -147,7 +145,6 @@ export async function handleSsr(
|
|
|
147
145
|
// over after hydration. This provider supplies the request's search params
|
|
148
146
|
// as a static snapshot so nuqs renders the right initial values on the server.
|
|
149
147
|
const wrappedElement = withNuqsSsrAdapter(navContext.searchParams, element);
|
|
150
|
-
const _s2 = performance.now();
|
|
151
148
|
|
|
152
149
|
// Render to HTML stream (waits for onShellReady).
|
|
153
150
|
// Pass bootstrapScriptContent so React injects a non-deferred <script>
|
|
@@ -177,15 +174,10 @@ export async function handleSsr(
|
|
|
177
174
|
);
|
|
178
175
|
}
|
|
179
176
|
|
|
180
|
-
const _s3 = performance.now();
|
|
181
177
|
// Inject metadata into <head>, then interleave RSC payload chunks
|
|
182
178
|
// into the body as they arrive from the tee'd RSC stream.
|
|
183
179
|
let outputStream = injectHead(htmlStream, navContext.headHtml);
|
|
184
180
|
outputStream = injectRscPayload(outputStream, navContext.rscStream);
|
|
185
|
-
const _s4 = performance.now();
|
|
186
|
-
|
|
187
|
-
// eslint-disable-next-line no-console
|
|
188
|
-
console.log(`[ssr] decode=${(_s1 - _s0).toFixed(1)}ms nuqs=${(_s2 - _s1).toFixed(1)}ms renderToStream=${(_s3 - _s2).toFixed(1)}ms transforms=${(_s4 - _s3).toFixed(1)}ms total=${(_s4 - _s0).toFixed(1)}ms`);
|
|
189
181
|
|
|
190
182
|
// Build and return the Response.
|
|
191
183
|
return buildSsrResponse(outputStream, navContext.statusCode, navContext.responseHeaders);
|
package/src/server/ssr-render.ts
CHANGED
|
@@ -56,7 +56,6 @@ export async function renderSsrStream(
|
|
|
56
56
|
options?: { bootstrapScriptContent?: string; deferSuspenseFor?: number; signal?: AbortSignal }
|
|
57
57
|
): Promise<ReadableStream<Uint8Array>> {
|
|
58
58
|
const signal = options?.signal;
|
|
59
|
-
const _r0 = performance.now();
|
|
60
59
|
const stream = await renderToReadableStream(element, {
|
|
61
60
|
bootstrapScriptContent: options?.bootstrapScriptContent || undefined,
|
|
62
61
|
signal,
|
|
@@ -67,9 +66,6 @@ export async function renderSsrStream(
|
|
|
67
66
|
console.error('[timber] SSR render error:', formatSsrError(error));
|
|
68
67
|
},
|
|
69
68
|
});
|
|
70
|
-
const _r1 = performance.now();
|
|
71
|
-
// eslint-disable-next-line no-console
|
|
72
|
-
console.log(`[ssr-render] renderToReadableStream onShellReady=${(_r1 - _r0).toFixed(1)}ms`);
|
|
73
69
|
|
|
74
70
|
// Prevent unhandled promise rejection from streaming-phase errors.
|
|
75
71
|
// React DOM Server exposes `allReady` — a promise that resolves when
|