@parcel/rsc 2.13.1-canary.3403 → 2.13.1-canary.3410

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/lib/client.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  /* @jsxRuntime automatic */ import { ReactNode } from 'react';
2
2
  import { HydrationOptions } from 'react-dom/client';
3
+ type CallServerCallback = <T>(id: string, args: any[]) => Promise<T>;
4
+ export declare function setServerCallback(cb: CallServerCallback): void;
3
5
  export type CallServerCallback = <T>(id: string, args: any[]) => Promise<T>;
4
6
  export interface HydrateOptions extends HydrationOptions {
5
- handleServerAction?: CallServerCallback;
7
+ callServer?: CallServerCallback;
6
8
  onHmrReload?: () => void;
7
9
  }
8
10
  export declare function hydrate(options?: HydrateOptions): (value: ReactNode, cb?: () => void) => void;
@@ -10,3 +12,4 @@ export interface RSCRequestInit extends Omit<RequestInit, 'body'> {
10
12
  body?: any;
11
13
  }
12
14
  export declare function fetchRSC<T>(url: string | URL | Request, options?: RSCRequestInit): Promise<T>;
15
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/rsc",
3
- "version": "2.13.1-canary.3403+1e6f4b373",
3
+ "version": "2.13.1-canary.3410+9d4799570",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,6 +15,9 @@
15
15
  },
16
16
  "sideEffects": false,
17
17
  "exports": {
18
+ ".": {
19
+ "types": "./src/ssg.d.ts"
20
+ },
18
21
  "./client": {
19
22
  "types": "./lib/client.d.ts",
20
23
  "default": "./src/client.tsx"
@@ -41,5 +44,5 @@
41
44
  "react": "^19",
42
45
  "react-dom": "^19"
43
46
  },
44
- "gitHead": "1e6f4b37336bf6dcf2406bc648131f28c7d0012a"
47
+ "gitHead": "9d4799570916170906aca646f5c55353f8e19fc5"
45
48
  }
package/src/client.tsx CHANGED
@@ -1,8 +1,13 @@
1
1
  /* @jsxRuntime automatic */
2
- import { ReactNode, startTransition, useInsertionEffect } from 'react';
3
- import {createFromReadableStream, createFromFetch, encodeReply, setServerCallback, createTemporaryReferenceSet} from 'react-server-dom-parcel/client';
2
+ import {ReactNode, startTransition, useInsertionEffect} from 'react';
3
+ import {createFromReadableStream, createFromFetch, encodeReply, setServerCallback as setReactServerCallback, createTemporaryReferenceSet} from 'react-server-dom-parcel/client';
4
4
  import {rscStream} from 'rsc-html-stream/client';
5
- import { hydrateRoot, HydrationOptions, Root } from 'react-dom/client';
5
+ import {hydrateRoot, HydrationOptions, Root} from 'react-dom/client';
6
+
7
+ type CallServerCallback = <T>(id: string, args: any[]) => Promise<T>;
8
+ export function setServerCallback(cb: CallServerCallback): void {
9
+ return setReactServerCallback(cb);
10
+ }
6
11
 
7
12
  // Stream in initial RSC payload embedded in the HTML.
8
13
  let initialRSCPayload: Promise<ReactNode>;
@@ -16,13 +21,13 @@ function RSCRoot({value, cb}: {value?: ReactNode, cb?: () => void}) {
16
21
 
17
22
  export type CallServerCallback = <T>(id: string, args: any[]) => Promise<T>;
18
23
  export interface HydrateOptions extends HydrationOptions {
19
- handleServerAction?: CallServerCallback,
24
+ callServer?: CallServerCallback,
20
25
  onHmrReload?: () => void
21
26
  }
22
27
 
23
28
  export function hydrate(options?: HydrateOptions): (value: ReactNode, cb?: () => void) => void {
24
- if (options?.handleServerAction) {
25
- setServerCallback(options.handleServerAction);
29
+ if (options?.callServer) {
30
+ setServerCallback(options.callServer);
26
31
  }
27
32
 
28
33
  if (options?.onHmrReload) {
package/src/ssg.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export interface Page {
2
+ url: string;
3
+ name: string;
4
+ tableOfContents?: TocNode[];
5
+ exports?: Record<string, any>;
6
+ }
7
+
8
+ export interface TocNode {
9
+ title: string;
10
+ level: number;
11
+ children: TocNode[];
12
+ }
13
+
14
+ export interface PageProps {
15
+ pages: Page[];
16
+ currentPage: Page;
17
+ }