@rangojs/router 0.0.0-experimental.preview.1774295612 → 0.0.0-experimental.preview.1774296851
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/bin/rango.js +1 -1
- package/dist/vite/index.js +2 -2
- package/package.json +1 -1
- package/src/browser/debug-channel.ts +8 -1
- package/src/browser/navigation-client.ts +5 -6
- package/src/browser/rsc-router.tsx +22 -7
- package/src/browser/server-action-bridge.ts +5 -6
- package/src/vite/plugins/virtual-entries.ts +1 -1
package/dist/bin/rango.js
CHANGED
package/dist/vite/index.js
CHANGED
|
@@ -1655,7 +1655,7 @@ async function initializeApp() {
|
|
|
1655
1655
|
createTemporaryReferenceSet,
|
|
1656
1656
|
};
|
|
1657
1657
|
|
|
1658
|
-
await initBrowserApp({ rscStream, deps });
|
|
1658
|
+
await initBrowserApp({ rscStream, deps, hot: import.meta.hot });
|
|
1659
1659
|
|
|
1660
1660
|
hydrateRoot(
|
|
1661
1661
|
document,
|
|
@@ -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.1774296851",
|
|
1749
1749
|
description: "Django-inspired RSC router with composable URL patterns",
|
|
1750
1750
|
keywords: [
|
|
1751
1751
|
"react",
|
package/package.json
CHANGED
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export const DEBUG_ID_HEADER = "X-RSC-Debug-Id";
|
|
12
|
+
|
|
13
|
+
// Stored by initBrowserApp from the virtual entry's import.meta.hot.
|
|
14
|
+
// Pre-bundled deps can't access import.meta.hot directly.
|
|
15
|
+
let _hot: any = null;
|
|
16
|
+
export function setHotRef(hot: any): void {
|
|
17
|
+
_hot = hot;
|
|
18
|
+
}
|
|
12
19
|
const DEBUG_S2C_EVENT = "rango:perf-s2c";
|
|
13
20
|
const DEBUG_S2C_BATCH_EVENT = "rango:perf-s2c-batch";
|
|
14
21
|
const DEBUG_C2S_EVENT = "rango:perf-c2s";
|
|
@@ -45,7 +52,7 @@ const base64ToBytes = (base64: string) =>
|
|
|
45
52
|
export function createClientDebugChannel(
|
|
46
53
|
debugId: string,
|
|
47
54
|
): ClientDebugChannel | null {
|
|
48
|
-
const hot =
|
|
55
|
+
const hot = _hot;
|
|
49
56
|
if (!hot) return null;
|
|
50
57
|
|
|
51
58
|
let closed = false;
|
|
@@ -143,12 +143,11 @@ export function createNavigationClient(
|
|
|
143
143
|
// generated it and already finished writing debug data to
|
|
144
144
|
// the relay. Creating the channel now sends "ready" which
|
|
145
145
|
// triggers an immediate flush of all buffered debug chunks.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
146
|
+
// No import.meta.hot check needed — the header only exists in dev.
|
|
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));
|
|
152
151
|
}
|
|
153
152
|
|
|
154
153
|
// Check for version mismatch - server wants us to reload
|
|
@@ -11,7 +11,7 @@ import { createEventController } from "./event-controller.js";
|
|
|
11
11
|
import { createNavigationClient } from "./navigation-client.js";
|
|
12
12
|
import { createServerActionBridge } from "./server-action-bridge.js";
|
|
13
13
|
import { createNavigationBridge } from "./navigation-bridge.js";
|
|
14
|
-
import { createClientDebugChannel } from "./debug-channel.js";
|
|
14
|
+
import { createClientDebugChannel, setHotRef } from "./debug-channel.js";
|
|
15
15
|
import { findSourceMapURL } from "../deps/browser.js";
|
|
16
16
|
import { NavigationProvider } from "./react/index.js";
|
|
17
17
|
import type {
|
|
@@ -96,6 +96,14 @@ export interface InitBrowserAppOptions {
|
|
|
96
96
|
* Only used when themeConfig is provided.
|
|
97
97
|
*/
|
|
98
98
|
initialTheme?: Theme;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Vite HMR hot module object (import.meta.hot from the virtual entry).
|
|
102
|
+
* Used for React Performance Tracks debug channel transport.
|
|
103
|
+
* Only available in dev — undefined in production.
|
|
104
|
+
* @internal
|
|
105
|
+
*/
|
|
106
|
+
hot?: any;
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
/**
|
|
@@ -139,15 +147,22 @@ export async function initBrowserApp(
|
|
|
139
147
|
linkInterception = true,
|
|
140
148
|
themeConfig,
|
|
141
149
|
initialTheme,
|
|
150
|
+
hot,
|
|
142
151
|
} = options;
|
|
143
152
|
|
|
153
|
+
// Store HMR hot ref for debug channel transport (pre-bundled deps
|
|
154
|
+
// can't access import.meta.hot directly).
|
|
155
|
+
if (hot) {
|
|
156
|
+
setHotRef(hot);
|
|
157
|
+
}
|
|
158
|
+
|
|
144
159
|
// Load initial payload from SSR-injected __FLIGHT_DATA__
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
//
|
|
150
|
-
//
|
|
160
|
+
// SSR debug channel is disabled — the server may still be rendering
|
|
161
|
+
// (streaming Suspense) when the client JS loads and hydrates. The debug
|
|
162
|
+
// writable hasn't closed yet, so the relay has no "done" signal and the
|
|
163
|
+
// batch won't flush. This blocks createFromReadableStream forever.
|
|
164
|
+
// Server Component tracks work for SPA navigations where the response
|
|
165
|
+
// is complete before we create the debug channel.
|
|
151
166
|
const initialPayload =
|
|
152
167
|
await deps.createFromReadableStream<RscPayload>(rscStream);
|
|
153
168
|
|
|
@@ -222,12 +222,11 @@ export function createServerActionBridge(
|
|
|
222
222
|
// abortAllActions() doesn't disrupt the in-progress Flight stream.
|
|
223
223
|
handle.signal.removeEventListener("abort", onHandleAbort);
|
|
224
224
|
|
|
225
|
-
// Dev-only: read debugId from response header
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
225
|
+
// Dev-only: read debugId from response header.
|
|
226
|
+
// No import.meta.hot check — the header only exists in dev.
|
|
227
|
+
const debugId = response.headers.get(DEBUG_ID_HEADER);
|
|
228
|
+
if (debugId) {
|
|
229
|
+
debugChannel = createClientDebugChannel(debugId) ?? undefined;
|
|
231
230
|
}
|
|
232
231
|
|
|
233
232
|
// Check for version mismatch - server wants us to reload
|