-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
40 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "vinxi", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"type": "module", | ||
"author": "Nikhil Saraf <[email protected]>", | ||
"files": [ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,37 @@ | ||
/// <reference types="vinxi/server" /> | ||
import { renderAsset } from "@vinxi/react"; | ||
import React, { Suspense } from "react"; | ||
import { renderToPipeableStream } from "react-dom/server"; | ||
import { eventHandler } from "vinxi/runtime/server"; | ||
|
||
import { renderAsset } from "./render-asset"; | ||
import App from "./root"; | ||
|
||
export default eventHandler(async (event) => { | ||
const clientManifest = import.meta.env.MANIFEST["client"]; | ||
const assets = await clientManifest.inputs[clientManifest.handler].assets(); | ||
|
||
function Assets() { | ||
return <>{assets.map((asset) => renderAsset(asset))}</>; | ||
} | ||
|
||
const events = {}; | ||
const stream = renderToPipeableStream( | ||
<App | ||
assets={ | ||
<Suspense> | ||
<Assets /> | ||
</Suspense> | ||
} | ||
/>, | ||
{ | ||
onAllReady: () => { | ||
events["end"]?.(); | ||
const stream = await new Promise(async (resolve) => { | ||
const stream = renderToPipeableStream( | ||
<App assets={<Suspense>{assets.map((m) => renderAsset(m))}</Suspense>} />, | ||
{ | ||
onShellReady() { | ||
resolve(stream); | ||
}, | ||
bootstrapModules: [ | ||
clientManifest.inputs[clientManifest.handler].output.path, | ||
], | ||
bootstrapScriptContent: `window.manifest = ${JSON.stringify( | ||
await clientManifest.json(), | ||
)}`, | ||
}, | ||
bootstrapModules: [ | ||
clientManifest.inputs[clientManifest.handler].output.path, | ||
], | ||
bootstrapScriptContent: `window.manifest = ${JSON.stringify( | ||
await clientManifest.json(), | ||
)}`, | ||
}, | ||
); | ||
); | ||
}); | ||
|
||
// @ts-ignore | ||
stream.on = (event, listener) => { | ||
events[event] = listener; | ||
}; | ||
|
||
event.node.res.setHeader("Content-Type", "text/html"); | ||
|
||
return stream; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters