@timber-js/app 0.2.0-alpha.27 → 0.2.0-alpha.28
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":"ssr-entry.d.ts","sourceRoot":"","sources":["../../src/server/ssr-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"ssr-entry.d.ts","sourceRoot":"","sources":["../../src/server/ssr-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiEH;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC1C,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;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,CA6HnB;AAED,eAAe,SAAS,CAAC"}
|
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.28",
|
|
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",
|
package/src/server/ssr-entry.ts
CHANGED
|
@@ -32,6 +32,36 @@ import { withSpan } from './tracing.js';
|
|
|
32
32
|
import { setCurrentParams } from '#/client/use-params.js';
|
|
33
33
|
import { registerSsrDataProvider, type SsrData } from '#/client/ssr-data.js';
|
|
34
34
|
|
|
35
|
+
// Pre-import Node.js stream modules at module load time — not per-request.
|
|
36
|
+
// Dynamic imports of node-stream-transforms and node:stream/promises were
|
|
37
|
+
// costing 3-17ms per request due to module resolution overhead.
|
|
38
|
+
let _nodeStreamImports: {
|
|
39
|
+
createNodeHeadInjector: typeof import('./node-stream-transforms.js').createNodeHeadInjector;
|
|
40
|
+
createNodeFlightInjector: typeof import('./node-stream-transforms.js').createNodeFlightInjector;
|
|
41
|
+
createNodeErrorHandler: typeof import('./node-stream-transforms.js').createNodeErrorHandler;
|
|
42
|
+
pipeline: typeof import('node:stream/promises').pipeline;
|
|
43
|
+
PassThrough: typeof import('node:stream').PassThrough;
|
|
44
|
+
} | null = null;
|
|
45
|
+
|
|
46
|
+
if (useNodeStreams) {
|
|
47
|
+
try {
|
|
48
|
+
const [transforms, streamPromises, stream] = await Promise.all([
|
|
49
|
+
import('./node-stream-transforms.js'),
|
|
50
|
+
import('node:stream/promises'),
|
|
51
|
+
import('node:stream'),
|
|
52
|
+
]);
|
|
53
|
+
_nodeStreamImports = {
|
|
54
|
+
createNodeHeadInjector: transforms.createNodeHeadInjector,
|
|
55
|
+
createNodeFlightInjector: transforms.createNodeFlightInjector,
|
|
56
|
+
createNodeErrorHandler: transforms.createNodeErrorHandler,
|
|
57
|
+
pipeline: streamPromises.pipeline,
|
|
58
|
+
PassThrough: stream.PassThrough,
|
|
59
|
+
};
|
|
60
|
+
} catch {
|
|
61
|
+
// Fall back to Web Streams path
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
35
65
|
// ─── SSR Data ALS ─────────────────────────────────────────────────────────
|
|
36
66
|
//
|
|
37
67
|
// Per-request SSR data stored in AsyncLocalStorage, ensuring correct
|
|
@@ -166,11 +196,9 @@ export async function handleSsr(
|
|
|
166
196
|
// Entire pipeline stays in C++ native streams until the Response boundary.
|
|
167
197
|
// - Workers: renderToReadableStream → Web TransformStream pipeline → Response
|
|
168
198
|
// Web Streams are V8-native C++ built-ins on Workers.
|
|
169
|
-
if (
|
|
199
|
+
if (_nodeStreamImports) {
|
|
170
200
|
// Node.js fast path: full pipeline in native streams
|
|
171
|
-
const { createNodeHeadInjector, createNodeFlightInjector, createNodeErrorHandler } =
|
|
172
|
-
await import('./node-stream-transforms.js');
|
|
173
|
-
const { pipeline } = await import('node:stream/promises');
|
|
201
|
+
const { createNodeHeadInjector, createNodeFlightInjector, createNodeErrorHandler, pipeline, PassThrough } = _nodeStreamImports;
|
|
174
202
|
|
|
175
203
|
const _s3 = performance.now();
|
|
176
204
|
let nodeHtmlStream: import('node:stream').Readable;
|
|
@@ -199,7 +227,6 @@ export async function handleSsr(
|
|
|
199
227
|
// Pipe through the chain. pipeline() handles backpressure and error propagation.
|
|
200
228
|
// The last stream in the chain is the output — convert to Web ReadableStream
|
|
201
229
|
// only at the Response boundary.
|
|
202
|
-
const { PassThrough } = await import('node:stream');
|
|
203
230
|
const output = new PassThrough();
|
|
204
231
|
pipeline(nodeHtmlStream, errorHandler, headInjector, flightInjector, output).catch(() => {
|
|
205
232
|
// Pipeline errors are handled by errorHandler transform
|