File tree Expand file tree Collapse file tree 8 files changed +18
-18
lines changed
packages/plugin-rsc/examples
starter-cf-single/src/framework Expand file tree Collapse file tree 8 files changed +18
-18
lines changed Original file line number Diff line number Diff line change 11import * as ReactClient from '@vitejs/plugin-rsc/browser'
2- import { getRscStreamFromHtml } from '@vitejs/plugin-rsc/rsc-html-stream/browser'
32import React from 'react'
43import * as ReactDOMClient from 'react-dom/client'
4+ import { rscStream } from 'rsc-html-stream/client'
55import type { RscPayload } from './entry.rsc'
66
77async function main ( ) {
@@ -12,7 +12,7 @@ async function main() {
1212 // deserialize RSC stream back to React VDOM for CSR
1313 const initialPayload = await ReactClient . createFromReadableStream < RscPayload > (
1414 // initial RSC stream is injected in SSR stream as <script>...FLIGHT_DATA...</script>
15- getRscStreamFromHtml ( ) ,
15+ rscStream ,
1616 )
1717
1818 // browser root component to (re-)render RSC payload as state
Original file line number Diff line number Diff line change 1- import { injectRscStreamToHtml } from '@vitejs/plugin-rsc/rsc-html-stream/ssr' // helper API
21import * as ReactClient from '@vitejs/plugin-rsc/ssr' // RSC API
32import React from 'react'
43import type { ReactFormState } from 'react-dom/client'
54import * as ReactDOMServer from 'react-dom/server.edge'
5+ import { injectRSCPayload } from 'rsc-html-stream/server'
66import type { RscPayload } from './entry.rsc'
77
88export async function renderHTML (
@@ -42,8 +42,9 @@ export async function renderHTML(
4242 let responseStream : ReadableStream < Uint8Array > = htmlStream
4343 if ( ! options ?. debugNojs ) {
4444 // initial RSC stream is injected in HTML stream as <script>...FLIGHT_DATA...</script>
45+ // using utility made by devongovett https://github.com/devongovett/rsc-html-stream
4546 responseStream = responseStream . pipeThrough (
46- injectRscStreamToHtml ( rscStream2 , {
47+ injectRSCPayload ( rscStream2 , {
4748 nonce : options ?. nonce ,
4849 } ) ,
4950 )
Original file line number Diff line number Diff line change 11import * as ReactClient from '@vitejs/plugin-rsc/browser'
2- import { getRscStreamFromHtml } from '@vitejs/plugin- rsc/rsc -html-stream/browser '
2+ import { rscStream } from 'rsc-html-stream/client '
33import React from 'react'
44import ReactDomClient from 'react-dom/client'
55import { RSC_POSTFIX , type RscPayload } from './shared'
@@ -12,9 +12,8 @@ async function hydrate(): Promise<void> {
1212 setPayload ( payload )
1313 }
1414
15- const initialPayload = await ReactClient . createFromReadableStream < RscPayload > (
16- getRscStreamFromHtml ( ) ,
17- )
15+ const initialPayload =
16+ await ReactClient . createFromReadableStream < RscPayload > ( rscStream )
1817
1918 let setPayload : ( v : RscPayload ) => void
2019
Original file line number Diff line number Diff line change 1- import { injectRscStreamToHtml } from '@vitejs/plugin- rsc/rsc -html-stream/ssr '
1+ import { injectRSCPayload } from 'rsc-html-stream/server '
22import * as ReactClient from '@vitejs/plugin-rsc/ssr'
33import React from 'react'
44import * as ReactDomServer from 'react-dom/server.edge'
@@ -24,6 +24,6 @@ export async function renderHtml(rscStream: ReadableStream<Uint8Array>) {
2424 await htmlStream . allReady
2525
2626 let responseStream : ReadableStream < Uint8Array > = htmlStream
27- responseStream = responseStream . pipeThrough ( injectRscStreamToHtml ( rscStream2 ) )
27+ responseStream = responseStream . pipeThrough ( injectRSCPayload ( rscStream2 ) )
2828 return responseStream
2929}
Original file line number Diff line number Diff line change 11import * as ReactClient from '@vitejs/plugin-rsc/browser'
2- import { getRscStreamFromHtml } from '@vitejs/plugin-rsc/rsc-html-stream/browser'
32import React from 'react'
43import * as ReactDOMClient from 'react-dom/client'
4+ import { rscStream } from 'rsc-html-stream/client'
55import type { RscPayload } from './entry.rsc'
66
77async function main ( ) {
@@ -12,7 +12,7 @@ async function main() {
1212 // deserialize RSC stream back to React VDOM for CSR
1313 const initialPayload = await ReactClient . createFromReadableStream < RscPayload > (
1414 // initial RSC stream is injected in SSR stream as <script>...FLIGHT_DATA...</script>
15- getRscStreamFromHtml ( ) ,
15+ rscStream ,
1616 )
1717
1818 // browser root component to (re-)render RSC payload as state
Original file line number Diff line number Diff line change 1- import { injectRscStreamToHtml } from '@vitejs/plugin-rsc/rsc-html-stream/ssr' // helper API
21import * as ReactClient from '@vitejs/plugin-rsc/ssr' // RSC API
32import React from 'react'
43import type { ReactFormState } from 'react-dom/client'
54import * as ReactDOMServer from 'react-dom/server.edge'
5+ import { injectRSCPayload } from 'rsc-html-stream/server'
66import type { RscPayload } from './entry.rsc'
77
88export type RenderHTML = typeof renderHTML
@@ -45,7 +45,7 @@ export async function renderHTML(
4545 if ( ! options ?. debugNojs ) {
4646 // initial RSC stream is injected in HTML stream as <script>...FLIGHT_DATA...</script>
4747 responseStream = responseStream . pipeThrough (
48- injectRscStreamToHtml ( rscStream2 , {
48+ injectRSCPayload ( rscStream2 , {
4949 nonce : options ?. nonce ,
5050 } ) ,
5151 )
Original file line number Diff line number Diff line change 11import * as ReactClient from '@vitejs/plugin-rsc/browser'
2- import { getRscStreamFromHtml } from '@vitejs/plugin- rsc/rsc -html-stream/browser '
2+ import { rscStream } from 'rsc-html-stream/client '
33import React from 'react'
44import * as ReactDOMClient from 'react-dom/client'
55import type { RscPayload } from './entry.rsc'
@@ -12,7 +12,7 @@ async function main() {
1212 // deserialize RSC stream back to React VDOM for CSR
1313 const initialPayload = await ReactClient . createFromReadableStream < RscPayload > (
1414 // initial RSC stream is injected in SSR stream as <script>...FLIGHT_DATA...</script>
15- getRscStreamFromHtml ( ) ,
15+ rscStream ,
1616 )
1717
1818 // browser root component to (re-)render RSC payload as state
Original file line number Diff line number Diff line change 1- import { injectRscStreamToHtml } from '@vitejs/plugin-rsc/rsc-html-stream/ssr' // helper API
21import * as ReactClient from '@vitejs/plugin-rsc/ssr' // RSC API
32import React from 'react'
43import type { ReactFormState } from 'react-dom/client'
54import * as ReactDOMServer from 'react-dom/server.edge'
5+ import { injectRSCPayload } from 'rsc-html-stream/server'
66import type { RscPayload } from './entry.rsc'
77
88export async function renderHTML (
@@ -43,7 +43,7 @@ export async function renderHTML(
4343 if ( ! options ?. debugNojs ) {
4444 // initial RSC stream is injected in HTML stream as <script>...FLIGHT_DATA...</script>
4545 responseStream = responseStream . pipeThrough (
46- injectRscStreamToHtml ( rscStream2 , {
46+ injectRSCPayload ( rscStream2 , {
4747 nonce : options ?. nonce ,
4848 } ) ,
4949 )
You can’t perform that action at this time.
0 commit comments