rwsdk 1.4.0 → 1.4.1

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,3 +1,7 @@
1
1
  import "./types/ssr";
2
+ import type { NavigationPendingOptions, NavigationPendingProps } from "../client/navigationPending.js";
3
+ import type { NavigationSnapshot } from "../client/navigationState.js";
2
4
  export * from "../lib/streams/consumeEventStream";
3
5
  export declare const navigate: () => void;
6
+ export declare function useNavigationPending(_options?: NavigationPendingOptions): NavigationSnapshot;
7
+ export declare function NavigationPending({ children }: NavigationPendingProps): string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null;
@@ -3,3 +3,12 @@ export * from "../lib/streams/consumeEventStream";
3
3
  export const navigate = () => {
4
4
  /* stub */
5
5
  };
6
+ export function useNavigationPending(_options = {}) {
7
+ return {
8
+ currentUrl: new URL("http://localhost/"),
9
+ pending: null,
10
+ };
11
+ }
12
+ export function NavigationPending({ children }) {
13
+ return children ?? null;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { renderToString } from "react-dom/server";
3
+ import { describe, expect, it } from "vitest";
4
+ import { NavigationPending, useNavigationPending } from "./clientSSR";
5
+ function NavigationSnapshotProbe() {
6
+ const snapshot = useNavigationPending();
7
+ return React.createElement("span", null, snapshot.pending === null ? "not-pending" : "pending");
8
+ }
9
+ describe("clientSSR entry", () => {
10
+ it("exports a no-op NavigationPending boundary for SSR/workerd builds", () => {
11
+ const html = renderToString(React.createElement(NavigationPending, null, "ready"));
12
+ expect(html).toContain("ready");
13
+ });
14
+ it("exports a non-pending navigation snapshot hook for SSR/workerd builds", () => {
15
+ const html = renderToString(React.createElement(NavigationSnapshotProbe));
16
+ expect(html).toContain("not-pending");
17
+ });
18
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rwsdk",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime",
5
5
  "type": "module",
6
6
  "bin": {