MCPcopy
hub / github.com/vuejs/core / renderToSimpleStream

Function renderToSimpleStream

packages/server-renderer/src/renderToStream.ts:56–92  ·  view source on GitHub ↗
(
  input: App | VNode,
  context: SSRContext,
  stream: T,
)

Source from the content-addressed store, hash-verified

54}
55
56export 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

Callers 5

renderToNodeStreamFunction · 0.85
pipeToNodeWritableFunction · 0.85
startFunction · 0.85
pipeToWebWritableFunction · 0.85

Calls 8

renderComponentVNodeFunction · 0.90
resolveTeleportsFunction · 0.90
isVNodeFunction · 0.85
provideMethod · 0.80
destroyMethod · 0.80
unrollBufferFunction · 0.70
resolveMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected