@vue/server-renderer
Advanced tools
Comparing version 3.0.0-alpha.6 to 3.0.0-alpha.7
@@ -355,5 +355,7 @@ 'use strict'; | ||
return { | ||
buffer, | ||
hasAsync() { | ||
return hasAsync; | ||
getBuffer() { | ||
// If the current component's buffer contains any Promise from async children, | ||
// then it must return a Promise too. Otherwise this is a component that | ||
// contains only sync children so we can avoid the async book-keeping overhead. | ||
return hasAsync ? Promise.all(buffer) : buffer; | ||
}, | ||
@@ -390,3 +392,2 @@ push(item) { | ||
async function renderToString(input, context = {}) { | ||
let buffer; | ||
if (isVNode(input)) { | ||
@@ -396,19 +397,9 @@ // raw vnode, wrap with app (for context) | ||
} | ||
else { | ||
// rendering an app | ||
const vnode = vue.createVNode(input._component, input._props); | ||
vnode.appContext = input._context; | ||
// provide the ssr context to the tree | ||
input.provide(vue.ssrContextKey, context); | ||
buffer = await renderComponentVNode(vnode); | ||
} | ||
// resolve portals | ||
if (context.__portalBuffers) { | ||
context.portals = context.portals || {}; | ||
for (const key in context.__portalBuffers) { | ||
// note: it's OK to await sequentially here because the Promises were | ||
// created eagerly in parallel. | ||
context.portals[key] = unrollBuffer(await context.__portalBuffers[key]); | ||
} | ||
} | ||
// rendering an app | ||
const vnode = vue.createVNode(input._component, input._props); | ||
vnode.appContext = input._context; | ||
// provide the ssr context to the tree | ||
input.provide(vue.ssrContextKey, context); | ||
const buffer = await renderComponentVNode(vnode); | ||
await resolvePortals(context); | ||
return unrollBuffer(buffer); | ||
@@ -451,3 +442,3 @@ } | ||
const comp = instance.type; | ||
const { buffer, push, hasAsync } = createBuffer(); | ||
const { getBuffer, push } = createBuffer(); | ||
if (isFunction(comp)) { | ||
@@ -474,6 +465,3 @@ renderVNode(push, renderComponentRoot(instance), instance); | ||
} | ||
// If the current component's buffer contains any Promise from async children, | ||
// then it must return a Promise too. Otherwise this is a component that | ||
// contains only sync children so we can avoid the async book-keeping overhead. | ||
return hasAsync() ? Promise.all(buffer) : buffer; | ||
return getBuffer(); | ||
} | ||
@@ -570,10 +558,18 @@ function renderVNode(push, vnode, parentComponent) { | ||
} | ||
const { buffer, push, hasAsync } = createBuffer(); | ||
const { getBuffer, push } = createBuffer(); | ||
renderVNodeChildren(push, vnode.children, parentComponent); | ||
const context = parentComponent.appContext.provides[vue.ssrContextKey]; | ||
const portalBuffers = context.__portalBuffers || (context.__portalBuffers = {}); | ||
portalBuffers[target] = hasAsync() | ||
? Promise.all(buffer) | ||
: buffer; | ||
portalBuffers[target] = getBuffer(); | ||
} | ||
async function resolvePortals(context) { | ||
if (context.__portalBuffers) { | ||
context.portals = context.portals || {}; | ||
for (const key in context.__portalBuffers) { | ||
// note: it's OK to await sequentially here because the Promises were | ||
// created eagerly in parallel. | ||
context.portals[key] = unrollBuffer(await context.__portalBuffers[key]); | ||
} | ||
} | ||
} | ||
@@ -580,0 +576,0 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent) { |
@@ -319,5 +319,7 @@ 'use strict'; | ||
return { | ||
buffer, | ||
hasAsync() { | ||
return hasAsync; | ||
getBuffer() { | ||
// If the current component's buffer contains any Promise from async children, | ||
// then it must return a Promise too. Otherwise this is a component that | ||
// contains only sync children so we can avoid the async book-keeping overhead. | ||
return hasAsync ? Promise.all(buffer) : buffer; | ||
}, | ||
@@ -354,3 +356,2 @@ push(item) { | ||
async function renderToString(input, context = {}) { | ||
let buffer; | ||
if (isVNode(input)) { | ||
@@ -360,19 +361,9 @@ // raw vnode, wrap with app (for context) | ||
} | ||
else { | ||
// rendering an app | ||
const vnode = vue.createVNode(input._component, input._props); | ||
vnode.appContext = input._context; | ||
// provide the ssr context to the tree | ||
input.provide(vue.ssrContextKey, context); | ||
buffer = await renderComponentVNode(vnode); | ||
} | ||
// resolve portals | ||
if (context.__portalBuffers) { | ||
context.portals = context.portals || {}; | ||
for (const key in context.__portalBuffers) { | ||
// note: it's OK to await sequentially here because the Promises were | ||
// created eagerly in parallel. | ||
context.portals[key] = unrollBuffer(await context.__portalBuffers[key]); | ||
} | ||
} | ||
// rendering an app | ||
const vnode = vue.createVNode(input._component, input._props); | ||
vnode.appContext = input._context; | ||
// provide the ssr context to the tree | ||
input.provide(vue.ssrContextKey, context); | ||
const buffer = await renderComponentVNode(vnode); | ||
await resolvePortals(context); | ||
return unrollBuffer(buffer); | ||
@@ -412,3 +403,3 @@ } | ||
const comp = instance.type; | ||
const { buffer, push, hasAsync } = createBuffer(); | ||
const { getBuffer, push } = createBuffer(); | ||
if (isFunction(comp)) { | ||
@@ -435,6 +426,3 @@ renderVNode(push, renderComponentRoot(instance), instance); | ||
} | ||
// If the current component's buffer contains any Promise from async children, | ||
// then it must return a Promise too. Otherwise this is a component that | ||
// contains only sync children so we can avoid the async book-keeping overhead. | ||
return hasAsync() ? Promise.all(buffer) : buffer; | ||
return getBuffer(); | ||
} | ||
@@ -531,10 +519,18 @@ function renderVNode(push, vnode, parentComponent) { | ||
} | ||
const { buffer, push, hasAsync } = createBuffer(); | ||
const { getBuffer, push } = createBuffer(); | ||
renderVNodeChildren(push, vnode.children, parentComponent); | ||
const context = parentComponent.appContext.provides[vue.ssrContextKey]; | ||
const portalBuffers = context.__portalBuffers || (context.__portalBuffers = {}); | ||
portalBuffers[target] = hasAsync() | ||
? Promise.all(buffer) | ||
: buffer; | ||
portalBuffers[target] = getBuffer(); | ||
} | ||
async function resolvePortals(context) { | ||
if (context.__portalBuffers) { | ||
context.portals = context.portals || {}; | ||
for (const key in context.__portalBuffers) { | ||
// note: it's OK to await sequentially here because the Promises were | ||
// created eagerly in parallel. | ||
context.portals[key] = unrollBuffer(await context.__portalBuffers[key]); | ||
} | ||
} | ||
} | ||
@@ -541,0 +537,0 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent) { |
{ | ||
"name": "@vue/server-renderer", | ||
"version": "3.0.0-alpha.6", | ||
"version": "3.0.0-alpha.7", | ||
"description": "@vue/server-renderer", | ||
@@ -30,7 +30,7 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"vue": "3.0.0-alpha.6" | ||
"vue": "3.0.0-alpha.7" | ||
}, | ||
"dependencies": { | ||
"@vue/compiler-ssr": "3.0.0-alpha.6" | ||
"@vue/compiler-ssr": "3.0.0-alpha.7" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50181
1319
+ Added@vue/compiler-core@3.0.0-alpha.7(transitive)
+ Added@vue/compiler-dom@3.0.0-alpha.7(transitive)
+ Added@vue/compiler-ssr@3.0.0-alpha.7(transitive)
+ Added@vue/reactivity@3.0.0-alpha.7(transitive)
+ Added@vue/runtime-core@3.0.0-alpha.7(transitive)
+ Added@vue/runtime-dom@3.0.0-alpha.7(transitive)
+ Addedvue@3.0.0-alpha.7(transitive)
- Removed@vue/compiler-core@3.0.0-alpha.6(transitive)
- Removed@vue/compiler-dom@3.0.0-alpha.6(transitive)
- Removed@vue/compiler-ssr@3.0.0-alpha.6(transitive)
- Removed@vue/reactivity@3.0.0-alpha.6(transitive)
- Removed@vue/runtime-core@3.0.0-alpha.6(transitive)
- Removed@vue/runtime-dom@3.0.0-alpha.6(transitive)
- Removedvue@3.0.0-alpha.6(transitive)