( input: App | VNode, context: SSRContext, stream: T, )
| 54 | } |
| 55 | |
| 56 | export function renderToSimpleStream<T extends SimpleReadable>( |
| 57 | input: App | VNode, |
| 58 | context: SSRContext, |
| 59 | stream: T, |
| 60 | ): T { |
| 61 | if (isVNode(input)) { |
| 62 | // raw vnode, wrap with app (for context) |
| 63 | return renderToSimpleStream( |
| 64 | createApp({ render: () => input }), |
| 65 | context, |
| 66 | stream, |
| 67 | ) |
| 68 | } |
| 69 | |
| 70 | // rendering an app |
| 71 | const vnode = createVNode(input._component, input._props) |
| 72 | vnode.appContext = input._context |
| 73 | // provide the ssr context to the tree |
| 74 | input.provide(ssrContextKey, context) |
| 75 | |
| 76 | Promise.resolve(renderComponentVNode(vnode)) |
| 77 | .then(buffer => unrollBuffer(buffer, stream)) |
| 78 | .then(() => resolveTeleports(context)) |
| 79 | .then(() => { |
| 80 | if (context.__watcherHandles) { |
| 81 | for (const unwatch of context.__watcherHandles) { |
| 82 | unwatch() |
| 83 | } |
| 84 | } |
| 85 | }) |
| 86 | .then(() => stream.push(null)) |
| 87 | .catch(error => { |
| 88 | stream.destroy(error) |
| 89 | }) |
| 90 | |
| 91 | return stream |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @deprecated |
no test coverage detected