@rangojs/router 0.0.0-experimental.preview.1774295247 → 0.0.0-experimental.preview.1774295612
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/vite/index.js
CHANGED
|
@@ -1745,7 +1745,7 @@ import { resolve } from "node:path";
|
|
|
1745
1745
|
// package.json
|
|
1746
1746
|
var package_default = {
|
|
1747
1747
|
name: "@rangojs/router",
|
|
1748
|
-
version: "0.0.0-experimental.preview.
|
|
1748
|
+
version: "0.0.0-experimental.preview.1774295612",
|
|
1749
1749
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1750
1750
|
keywords: [
|
|
1751
1751
|
"react",
|
package/package.json
CHANGED
|
@@ -119,13 +119,6 @@ export function createNavigationClient(
|
|
|
119
119
|
|
|
120
120
|
/** Start a fresh navigation fetch (no cache / inflight hit). */
|
|
121
121
|
const doFreshFetch = (): Promise<Response> => {
|
|
122
|
-
// Dev-only: generate debugId for React Performance Tracks.
|
|
123
|
-
// The debug channel is created AFTER response headers arrive,
|
|
124
|
-
// so the server has time to finish writing debug data before
|
|
125
|
-
// the client sends "ready".
|
|
126
|
-
const debugId = (import.meta as any).hot
|
|
127
|
-
? crypto.randomUUID()
|
|
128
|
-
: undefined;
|
|
129
122
|
debugChannel = null;
|
|
130
123
|
|
|
131
124
|
if (tx) {
|
|
@@ -143,16 +136,19 @@ export function createNavigationClient(
|
|
|
143
136
|
"X-RSC-Router-Intercept-Source": interceptSourceUrl,
|
|
144
137
|
}),
|
|
145
138
|
...(hmr && { "X-RSC-HMR": "1" }),
|
|
146
|
-
...(debugId && { [DEBUG_ID_HEADER]: debugId }),
|
|
147
139
|
},
|
|
148
140
|
signal,
|
|
149
141
|
}).then((response) => {
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
142
|
+
// Dev-only: read debugId from response header. The server
|
|
143
|
+
// generated it and already finished writing debug data to
|
|
144
|
+
// the relay. Creating the channel now sends "ready" which
|
|
145
|
+
// triggers an immediate flush of all buffered debug chunks.
|
|
146
|
+
if ((import.meta as any).hot) {
|
|
147
|
+
const debugId = response.headers.get(DEBUG_ID_HEADER);
|
|
148
|
+
if (debugId) {
|
|
149
|
+
debugChannel = createClientDebugChannel(debugId);
|
|
150
|
+
console.log("[perf-tracks] client: debug channel from response header for", debugId.slice(0, 8));
|
|
151
|
+
}
|
|
156
152
|
}
|
|
157
153
|
|
|
158
154
|
// Check for version mismatch - server wants us to reload
|
|
@@ -202,13 +202,7 @@ export function createServerActionBridge(
|
|
|
202
202
|
const onHandleAbort = () => fetchAbort.abort();
|
|
203
203
|
handle.signal.addEventListener("abort", onHandleAbort, { once: true });
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
const debugId = (import.meta as any).hot
|
|
207
|
-
? crypto.randomUUID()
|
|
208
|
-
: undefined;
|
|
209
|
-
const debugChannel = debugId
|
|
210
|
-
? (createClientDebugChannel(debugId) ?? undefined)
|
|
211
|
-
: undefined;
|
|
205
|
+
let debugChannel: ClientDebugChannel | undefined;
|
|
212
206
|
|
|
213
207
|
// Send action request with stream tracking
|
|
214
208
|
const responsePromise = fetch(url, {
|
|
@@ -217,11 +211,9 @@ export function createServerActionBridge(
|
|
|
217
211
|
"rsc-action": id,
|
|
218
212
|
"X-RSC-Router-Client-Path": segmentState.currentUrl,
|
|
219
213
|
...(tx && { "X-RSC-Router-Request-Id": tx.requestId }),
|
|
220
|
-
// Send intercept source URL so server can maintain intercept context
|
|
221
214
|
...(interceptSourceUrl && {
|
|
222
215
|
"X-RSC-Router-Intercept-Source": interceptSourceUrl,
|
|
223
216
|
}),
|
|
224
|
-
...(debugId && { [DEBUG_ID_HEADER]: debugId }),
|
|
225
217
|
},
|
|
226
218
|
body: encodedBody,
|
|
227
219
|
signal: fetchAbort.signal,
|
|
@@ -230,6 +222,14 @@ export function createServerActionBridge(
|
|
|
230
222
|
// abortAllActions() doesn't disrupt the in-progress Flight stream.
|
|
231
223
|
handle.signal.removeEventListener("abort", onHandleAbort);
|
|
232
224
|
|
|
225
|
+
// Dev-only: read debugId from response header
|
|
226
|
+
if ((import.meta as any).hot) {
|
|
227
|
+
const debugId = response.headers.get(DEBUG_ID_HEADER);
|
|
228
|
+
if (debugId) {
|
|
229
|
+
debugChannel = createClientDebugChannel(debugId) ?? undefined;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
233
|
// Check for version mismatch - server wants us to reload
|
|
234
234
|
const reload = extractRscHeaderUrl(response, "X-RSC-Reload");
|
|
235
235
|
if (reload === "blocked") {
|
package/src/rsc/handler.ts
CHANGED
|
@@ -426,16 +426,17 @@ export function createRSCHandler<
|
|
|
426
426
|
requestContext._debugPerformance = true;
|
|
427
427
|
requestContext._metricsStore = earlyMetricsStore;
|
|
428
428
|
}
|
|
429
|
-
// Dev-only: wire debug channel for React Performance Tracks
|
|
429
|
+
// Dev-only: wire debug channel for React Performance Tracks.
|
|
430
|
+
// Server generates the debugId and includes it in the response header.
|
|
431
|
+
// Client reads it after the response arrives and creates the matching channel.
|
|
430
432
|
if (process.env.NODE_ENV !== "production") {
|
|
431
|
-
|
|
432
|
-
// SSR requests have no client — generate one and create the channel directly.
|
|
433
|
-
const clientDebugId = request.headers.get(DEBUG_ID_HEADER);
|
|
434
|
-
const debugId = clientDebugId || crypto.randomUUID();
|
|
433
|
+
const debugId = crypto.randomUUID();
|
|
435
434
|
const channel = createServerDebugChannel(debugId, request.url);
|
|
436
435
|
if (channel) {
|
|
437
436
|
requestContext._debugChannel = channel;
|
|
438
437
|
requestContext._debugId = debugId;
|
|
438
|
+
// Set response header so client can read it
|
|
439
|
+
requestContext.header(DEBUG_ID_HEADER, debugId);
|
|
439
440
|
console.log("[perf-tracks] debug channel attached for", debugId);
|
|
440
441
|
}
|
|
441
442
|
}
|