@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 CHANGED
@@ -931,7 +931,7 @@ async function initializeApp() {
931
931
  createTemporaryReferenceSet,
932
932
  };
933
933
 
934
- await initBrowserApp({ rscStream, deps });
934
+ await initBrowserApp({ rscStream, deps, hot: import.meta.hot });
935
935
 
936
936
  hydrateRoot(
937
937
  document,
@@ -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.1774295612",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rangojs/router",
3
- "version": "0.0.0-experimental.preview.1774295612",
3
+ "version": "0.0.0-experimental.preview.1774296851",
4
4
  "description": "Django-inspired RSC router with composable URL patterns",
5
5
  "keywords": [
6
6
  "react",
@@ -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 = (import.meta as any).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
- 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
- }
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
- // Note: debug channel is NOT used for hydration. The WS transport is
146
- // unreliable during initial page load (JS loads after server finishes
147
- // rendering, so the "ready" signal arrives too late and chunks are dropped).
148
- // If createFromReadableStream hangs on a stalled debug stream, the entire
149
- // app never initializes — blocking all subsequent SPA navigations.
150
- // Server Component tracks are available for SPA navigations instead.
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
- if ((import.meta as any).hot) {
227
- const debugId = response.headers.get(DEBUG_ID_HEADER);
228
- if (debugId) {
229
- debugChannel = createClientDebugChannel(debugId) ?? undefined;
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
@@ -25,7 +25,7 @@ async function initializeApp() {
25
25
  createTemporaryReferenceSet,
26
26
  };
27
27
 
28
- await initBrowserApp({ rscStream, deps });
28
+ await initBrowserApp({ rscStream, deps, hot: import.meta.hot });
29
29
 
30
30
  hydrateRoot(
31
31
  document,