@timber-js/app 0.2.0-alpha.17 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"AA0FA;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAE/F;AA6ZD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;8BA/Q3C,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;AAiRhD,wBAAiE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/rsc-entry/index.ts"],"names":[],"mappings":"AA0FA;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAE/F;AAoZD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;8BAtQ3C,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC;AAwQhD,wBAAiE"}
@@ -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;AAC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gB,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.17",
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",
@@ -325,7 +325,6 @@ async function renderRoute(
325
325
  // Build the React element tree — loads modules, runs access checks,
326
326
  // resolves metadata. DenySignal/RedirectSignal propagate for HTTP handling.
327
327
  let routeResult;
328
- const _t0 = performance.now();
329
328
  try {
330
329
  routeResult = await buildRouteElement(_req, match, interception, clientStateTree);
331
330
  } catch (error) {
@@ -368,7 +367,6 @@ async function renderRoute(
368
367
  const { element, headElements, layoutComponents, deferSuspenseFor, skippedSegments } =
369
368
  routeResult;
370
369
 
371
- const _t1 = performance.now();
372
370
  // Build head HTML for injection into the SSR output.
373
371
  // Collects CSS, fonts, and modulepreload from the build manifest for matched segments.
374
372
  // In dev mode the manifest is empty — Vite HMR handles CSS/JS.
@@ -418,9 +416,7 @@ async function renderRoute(
418
416
  }
419
417
 
420
418
  // Render to RSC Flight stream with signal tracking.
421
- const _t2 = performance.now();
422
419
  const { rscStream, signals } = renderRscStream(element, _req);
423
- const _t3 = performance.now();
424
420
 
425
421
  // Synchronous redirect — redirect() in access.ts or a non-async component
426
422
  // throws during renderToReadableStream creation. Return HTTP redirect.
@@ -487,8 +483,7 @@ async function renderRoute(
487
483
  }
488
484
 
489
485
  // Pipe through SSR for HTML rendering with streaming Suspense support.
490
- const _t4 = performance.now();
491
- const _ssrResult = await renderSsrResponse({
486
+ return renderSsrResponse({
492
487
  req: _req,
493
488
  rscStream: rscStream!,
494
489
  signals,
@@ -501,10 +496,6 @@ async function renderRoute(
501
496
  headHtml,
502
497
  deferSuspenseFor,
503
498
  });
504
- const _t5 = performance.now();
505
- // eslint-disable-next-line no-console
506
- console.log(`[perf] build=${(_t1 - _t0).toFixed(1)}ms head=${(_t2 - _t1).toFixed(1)}ms rsc=${(_t3 - _t2).toFixed(1)}ms setup=${(_t4 - _t3).toFixed(1)}ms ssr=${(_t5 - _t4).toFixed(1)}ms total=${(_t5 - _t0).toFixed(1)}ms`);
507
- return _ssrResult;
508
499
  }
509
500
 
510
501
  // Re-export for generated entry points (e.g., Nitro node-server/bun) to wrap
@@ -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
- const [ssrStream, inlineStream] = rscStream.tee();
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