@vue/server-renderer 3.2.33 → 3.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server-renderer.cjs.js +115 -132
- package/dist/server-renderer.cjs.prod.js +115 -132
- package/dist/server-renderer.d.ts +2 -0
- package/dist/server-renderer.esm-bundler.js +114 -132
- package/package.json +4 -4
|
@@ -6,31 +6,6 @@ var vue = require('vue');
|
|
|
6
6
|
var shared = require('@vue/shared');
|
|
7
7
|
var compilerSsr = require('@vue/compiler-ssr');
|
|
8
8
|
|
|
9
|
-
/*! *****************************************************************************
|
|
10
|
-
Copyright (c) Microsoft Corporation.
|
|
11
|
-
|
|
12
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
13
|
-
purpose with or without fee is hereby granted.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
16
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
17
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
18
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
20
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
21
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
22
|
-
***************************************************************************** */
|
|
23
|
-
|
|
24
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
25
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
27
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
28
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
29
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
30
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
9
|
// leading comma for empty string ""
|
|
35
10
|
const shouldIgnoreProp = shared.makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
36
11
|
function ssrRenderAttrs(props, tag) {
|
|
@@ -139,25 +114,24 @@ function ssrCompile(template, instance) {
|
|
|
139
114
|
|
|
140
115
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
141
116
|
parentPush('<!--teleport start-->');
|
|
117
|
+
const context = parentComponent.appContext.provides[vue.ssrContextKey];
|
|
118
|
+
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
119
|
+
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
120
|
+
// record current index of the target buffer to handle nested teleports
|
|
121
|
+
// since the parent needs to be rendered before the child
|
|
122
|
+
const bufferIndex = targetBuffer.length;
|
|
142
123
|
let teleportContent;
|
|
143
124
|
if (disabled) {
|
|
144
125
|
contentRenderFn(parentPush);
|
|
145
|
-
teleportContent =
|
|
126
|
+
teleportContent = `<!--teleport anchor-->`;
|
|
146
127
|
}
|
|
147
128
|
else {
|
|
148
129
|
const { getBuffer, push } = createBuffer();
|
|
149
130
|
contentRenderFn(push);
|
|
150
|
-
push(
|
|
131
|
+
push(`<!--teleport anchor-->`);
|
|
151
132
|
teleportContent = getBuffer();
|
|
152
133
|
}
|
|
153
|
-
|
|
154
|
-
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
155
|
-
if (teleportBuffers[target]) {
|
|
156
|
-
teleportBuffers[target].push(teleportContent);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
teleportBuffers[target] = [teleportContent];
|
|
160
|
-
}
|
|
134
|
+
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
161
135
|
parentPush('<!--teleport end-->');
|
|
162
136
|
}
|
|
163
137
|
|
|
@@ -218,7 +192,17 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
218
192
|
const comp = instance.type;
|
|
219
193
|
const { getBuffer, push } = createBuffer();
|
|
220
194
|
if (shared.isFunction(comp)) {
|
|
221
|
-
|
|
195
|
+
let root = renderComponentRoot(instance);
|
|
196
|
+
// #5817 scope ID attrs not falling through if functional component doesn't
|
|
197
|
+
// have props
|
|
198
|
+
if (!comp.props) {
|
|
199
|
+
for (const key in instance.attrs) {
|
|
200
|
+
if (key.startsWith(`data-v-`)) {
|
|
201
|
+
(root.props || (root.props = {}))[key] = ``;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
renderVNode(push, (instance.subTree = root), instance, slotScopeId);
|
|
222
206
|
}
|
|
223
207
|
else {
|
|
224
208
|
if ((!instance.render || instance.render === shared.NOOP) &&
|
|
@@ -244,7 +228,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
244
228
|
const scopeId = cur.vnode.scopeId;
|
|
245
229
|
if (scopeId) {
|
|
246
230
|
if (!hasCloned) {
|
|
247
|
-
attrs =
|
|
231
|
+
attrs = { ...attrs };
|
|
248
232
|
hasCloned = true;
|
|
249
233
|
}
|
|
250
234
|
attrs[scopeId] = '';
|
|
@@ -261,7 +245,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
261
245
|
}
|
|
262
246
|
if (slotScopeId) {
|
|
263
247
|
if (!hasCloned)
|
|
264
|
-
attrs =
|
|
248
|
+
attrs = { ...attrs };
|
|
265
249
|
attrs[slotScopeId.trim()] = '';
|
|
266
250
|
}
|
|
267
251
|
// set current rendering instance for asset resolution
|
|
@@ -275,7 +259,8 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
275
259
|
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId);
|
|
276
260
|
}
|
|
277
261
|
else {
|
|
278
|
-
|
|
262
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
263
|
+
vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
279
264
|
push(`<!---->`);
|
|
280
265
|
}
|
|
281
266
|
}
|
|
@@ -396,7 +381,9 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
396
381
|
const target = vnode.props && vnode.props.to;
|
|
397
382
|
const disabled = vnode.props && vnode.props.disabled;
|
|
398
383
|
if (!target) {
|
|
399
|
-
|
|
384
|
+
if (!disabled) {
|
|
385
|
+
vue.warn(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
386
|
+
}
|
|
400
387
|
return [];
|
|
401
388
|
}
|
|
402
389
|
if (!shared.isString(target)) {
|
|
@@ -409,30 +396,28 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
409
396
|
}
|
|
410
397
|
|
|
411
398
|
const { isVNode } = vue.ssrUtils;
|
|
412
|
-
function unrollBuffer(buffer) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
ret += yield unrollBuffer(item);
|
|
426
|
-
}
|
|
399
|
+
async function unrollBuffer(buffer) {
|
|
400
|
+
if (buffer.hasAsync) {
|
|
401
|
+
let ret = '';
|
|
402
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
403
|
+
let item = buffer[i];
|
|
404
|
+
if (shared.isPromise(item)) {
|
|
405
|
+
item = await item;
|
|
406
|
+
}
|
|
407
|
+
if (shared.isString(item)) {
|
|
408
|
+
ret += item;
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
ret += await unrollBuffer(item);
|
|
427
412
|
}
|
|
428
|
-
return ret;
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
432
|
-
// ticks
|
|
433
|
-
return unrollBufferSync(buffer);
|
|
434
413
|
}
|
|
435
|
-
|
|
414
|
+
return ret;
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
418
|
+
// ticks
|
|
419
|
+
return unrollBufferSync(buffer);
|
|
420
|
+
}
|
|
436
421
|
}
|
|
437
422
|
function unrollBufferSync(buffer) {
|
|
438
423
|
let ret = '';
|
|
@@ -448,58 +433,53 @@ function unrollBufferSync(buffer) {
|
|
|
448
433
|
}
|
|
449
434
|
return ret;
|
|
450
435
|
}
|
|
451
|
-
function renderToString(input, context = {}) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
});
|
|
436
|
+
async function renderToString(input, context = {}) {
|
|
437
|
+
if (isVNode(input)) {
|
|
438
|
+
// raw vnode, wrap with app (for context)
|
|
439
|
+
return renderToString(vue.createApp({ render: () => input }), context);
|
|
440
|
+
}
|
|
441
|
+
// rendering an app
|
|
442
|
+
const vnode = vue.createVNode(input._component, input._props);
|
|
443
|
+
vnode.appContext = input._context;
|
|
444
|
+
// provide the ssr context to the tree
|
|
445
|
+
input.provide(vue.ssrContextKey, context);
|
|
446
|
+
const buffer = await renderComponentVNode(vnode);
|
|
447
|
+
const result = await unrollBuffer(buffer);
|
|
448
|
+
await resolveTeleports(context);
|
|
449
|
+
return result;
|
|
466
450
|
}
|
|
467
|
-
function resolveTeleports(context) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
context.teleports[key] = yield unrollBuffer((yield Promise.all(context.__teleportBuffers[key])));
|
|
475
|
-
}
|
|
451
|
+
async function resolveTeleports(context) {
|
|
452
|
+
if (context.__teleportBuffers) {
|
|
453
|
+
context.teleports = context.teleports || {};
|
|
454
|
+
for (const key in context.__teleportBuffers) {
|
|
455
|
+
// note: it's OK to await sequentially here because the Promises were
|
|
456
|
+
// created eagerly in parallel.
|
|
457
|
+
context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
|
|
476
458
|
}
|
|
477
|
-
}
|
|
459
|
+
}
|
|
478
460
|
}
|
|
479
461
|
|
|
480
462
|
const { isVNode: isVNode$1 } = vue.ssrUtils;
|
|
481
|
-
function unrollBuffer$1(buffer, stream) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
yield unrollBuffer$1(item, stream);
|
|
494
|
-
}
|
|
463
|
+
async function unrollBuffer$1(buffer, stream) {
|
|
464
|
+
if (buffer.hasAsync) {
|
|
465
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
466
|
+
let item = buffer[i];
|
|
467
|
+
if (shared.isPromise(item)) {
|
|
468
|
+
item = await item;
|
|
469
|
+
}
|
|
470
|
+
if (shared.isString(item)) {
|
|
471
|
+
stream.push(item);
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
await unrollBuffer$1(item, stream);
|
|
495
475
|
}
|
|
496
476
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
}
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
480
|
+
// ticks
|
|
481
|
+
unrollBufferSync$1(buffer, stream);
|
|
482
|
+
}
|
|
503
483
|
}
|
|
504
484
|
function unrollBufferSync$1(buffer, stream) {
|
|
505
485
|
for (let i = 0; i < buffer.length; i++) {
|
|
@@ -525,6 +505,7 @@ function renderToSimpleStream(input, context, stream) {
|
|
|
525
505
|
input.provide(vue.ssrContextKey, context);
|
|
526
506
|
Promise.resolve(renderComponentVNode(vnode))
|
|
527
507
|
.then(buffer => unrollBuffer$1(buffer, stream))
|
|
508
|
+
.then(() => resolveTeleports(context))
|
|
528
509
|
.then(() => stream.push(null))
|
|
529
510
|
.catch(error => {
|
|
530
511
|
stream.destroy(error);
|
|
@@ -539,7 +520,7 @@ function renderToStream(input, context = {}) {
|
|
|
539
520
|
return renderToNodeStream(input, context);
|
|
540
521
|
}
|
|
541
522
|
function renderToNodeStream(input, context = {}) {
|
|
542
|
-
const stream = new (require('stream').Readable)()
|
|
523
|
+
const stream = new (require('stream').Readable)({ read() { } })
|
|
543
524
|
;
|
|
544
525
|
if (!stream) {
|
|
545
526
|
throw new Error(`ESM build of renderToStream() does not support renderToNodeStream(). ` +
|
|
@@ -604,18 +585,16 @@ function pipeToWebWritable(input, context = {}, writable) {
|
|
|
604
585
|
}
|
|
605
586
|
catch (e) { }
|
|
606
587
|
renderToSimpleStream(input, context, {
|
|
607
|
-
push(content) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
});
|
|
588
|
+
async push(content) {
|
|
589
|
+
if (hasReady) {
|
|
590
|
+
await writer.ready;
|
|
591
|
+
}
|
|
592
|
+
if (content != null) {
|
|
593
|
+
return writer.write(encoder.encode(content));
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
return writer.close();
|
|
597
|
+
}
|
|
619
598
|
},
|
|
620
599
|
destroy(err) {
|
|
621
600
|
// TODO better error handling?
|
|
@@ -632,6 +611,10 @@ function ssrRenderComponent(comp, props = null, children = null, parentComponent
|
|
|
632
611
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
633
612
|
// template-compiled slots are always rendered as fragments
|
|
634
613
|
push(`<!--[-->`);
|
|
614
|
+
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
615
|
+
push(`<!--]-->`);
|
|
616
|
+
}
|
|
617
|
+
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
635
618
|
const slotFn = slots[slotName];
|
|
636
619
|
if (slotFn) {
|
|
637
620
|
const slotBuffer = [];
|
|
@@ -668,11 +651,12 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, paren
|
|
|
668
651
|
else if (fallbackRenderFn) {
|
|
669
652
|
fallbackRenderFn();
|
|
670
653
|
}
|
|
671
|
-
push(`<!--]-->`);
|
|
672
654
|
}
|
|
673
|
-
const commentRE =
|
|
655
|
+
const commentRE = /<!--[^]*?-->/gm;
|
|
674
656
|
function isComment(item) {
|
|
675
|
-
return typeof item === 'string' &&
|
|
657
|
+
return (typeof item === 'string' &&
|
|
658
|
+
commentRE.test(item) &&
|
|
659
|
+
!item.replace(commentRE, '').trim());
|
|
676
660
|
}
|
|
677
661
|
|
|
678
662
|
function ssrInterpolate(value) {
|
|
@@ -952,15 +936,13 @@ function ssrRenderList(source, renderItem) {
|
|
|
952
936
|
}
|
|
953
937
|
}
|
|
954
938
|
|
|
955
|
-
function ssrRenderSuspense(push, { default: renderContent }) {
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
}
|
|
963
|
-
});
|
|
939
|
+
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
940
|
+
if (renderContent) {
|
|
941
|
+
renderContent();
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
push(`<!---->`);
|
|
945
|
+
}
|
|
964
946
|
}
|
|
965
947
|
|
|
966
948
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
@@ -1034,6 +1016,7 @@ exports.ssrRenderDynamicAttr = ssrRenderDynamicAttr;
|
|
|
1034
1016
|
exports.ssrRenderDynamicModel = ssrRenderDynamicModel;
|
|
1035
1017
|
exports.ssrRenderList = ssrRenderList;
|
|
1036
1018
|
exports.ssrRenderSlot = ssrRenderSlot;
|
|
1019
|
+
exports.ssrRenderSlotInner = ssrRenderSlotInner;
|
|
1037
1020
|
exports.ssrRenderStyle = ssrRenderStyle;
|
|
1038
1021
|
exports.ssrRenderSuspense = ssrRenderSuspense;
|
|
1039
1022
|
exports.ssrRenderTeleport = ssrRenderTeleport;
|
|
@@ -6,31 +6,6 @@ var vue = require('vue');
|
|
|
6
6
|
var shared = require('@vue/shared');
|
|
7
7
|
var compilerSsr = require('@vue/compiler-ssr');
|
|
8
8
|
|
|
9
|
-
/*! *****************************************************************************
|
|
10
|
-
Copyright (c) Microsoft Corporation.
|
|
11
|
-
|
|
12
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
13
|
-
purpose with or without fee is hereby granted.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
16
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
17
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
18
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
19
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
20
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
21
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
22
|
-
***************************************************************************** */
|
|
23
|
-
|
|
24
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
25
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
27
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
28
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
29
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
30
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
9
|
// leading comma for empty string ""
|
|
35
10
|
const shouldIgnoreProp = shared.makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
36
11
|
function ssrRenderAttrs(props, tag) {
|
|
@@ -136,25 +111,24 @@ function ssrCompile(template, instance) {
|
|
|
136
111
|
|
|
137
112
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
138
113
|
parentPush('<!--teleport start-->');
|
|
114
|
+
const context = parentComponent.appContext.provides[vue.ssrContextKey];
|
|
115
|
+
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
116
|
+
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
117
|
+
// record current index of the target buffer to handle nested teleports
|
|
118
|
+
// since the parent needs to be rendered before the child
|
|
119
|
+
const bufferIndex = targetBuffer.length;
|
|
139
120
|
let teleportContent;
|
|
140
121
|
if (disabled) {
|
|
141
122
|
contentRenderFn(parentPush);
|
|
142
|
-
teleportContent =
|
|
123
|
+
teleportContent = `<!--teleport anchor-->`;
|
|
143
124
|
}
|
|
144
125
|
else {
|
|
145
126
|
const { getBuffer, push } = createBuffer();
|
|
146
127
|
contentRenderFn(push);
|
|
147
|
-
push(
|
|
128
|
+
push(`<!--teleport anchor-->`);
|
|
148
129
|
teleportContent = getBuffer();
|
|
149
130
|
}
|
|
150
|
-
|
|
151
|
-
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
152
|
-
if (teleportBuffers[target]) {
|
|
153
|
-
teleportBuffers[target].push(teleportContent);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
teleportBuffers[target] = [teleportContent];
|
|
157
|
-
}
|
|
131
|
+
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
158
132
|
parentPush('<!--teleport end-->');
|
|
159
133
|
}
|
|
160
134
|
|
|
@@ -215,7 +189,17 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
215
189
|
const comp = instance.type;
|
|
216
190
|
const { getBuffer, push } = createBuffer();
|
|
217
191
|
if (shared.isFunction(comp)) {
|
|
218
|
-
|
|
192
|
+
let root = renderComponentRoot(instance);
|
|
193
|
+
// #5817 scope ID attrs not falling through if functional component doesn't
|
|
194
|
+
// have props
|
|
195
|
+
if (!comp.props) {
|
|
196
|
+
for (const key in instance.attrs) {
|
|
197
|
+
if (key.startsWith(`data-v-`)) {
|
|
198
|
+
(root.props || (root.props = {}))[key] = ``;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
renderVNode(push, (instance.subTree = root), instance, slotScopeId);
|
|
219
203
|
}
|
|
220
204
|
else {
|
|
221
205
|
if ((!instance.render || instance.render === shared.NOOP) &&
|
|
@@ -241,7 +225,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
241
225
|
const scopeId = cur.vnode.scopeId;
|
|
242
226
|
if (scopeId) {
|
|
243
227
|
if (!hasCloned) {
|
|
244
|
-
attrs =
|
|
228
|
+
attrs = { ...attrs };
|
|
245
229
|
hasCloned = true;
|
|
246
230
|
}
|
|
247
231
|
attrs[scopeId] = '';
|
|
@@ -258,7 +242,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
258
242
|
}
|
|
259
243
|
if (slotScopeId) {
|
|
260
244
|
if (!hasCloned)
|
|
261
|
-
attrs =
|
|
245
|
+
attrs = { ...attrs };
|
|
262
246
|
attrs[slotScopeId.trim()] = '';
|
|
263
247
|
}
|
|
264
248
|
// set current rendering instance for asset resolution
|
|
@@ -272,7 +256,8 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
272
256
|
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId);
|
|
273
257
|
}
|
|
274
258
|
else {
|
|
275
|
-
|
|
259
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
260
|
+
vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
276
261
|
push(`<!---->`);
|
|
277
262
|
}
|
|
278
263
|
}
|
|
@@ -393,7 +378,9 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
393
378
|
const target = vnode.props && vnode.props.to;
|
|
394
379
|
const disabled = vnode.props && vnode.props.disabled;
|
|
395
380
|
if (!target) {
|
|
396
|
-
|
|
381
|
+
if (!disabled) {
|
|
382
|
+
vue.warn(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
383
|
+
}
|
|
397
384
|
return [];
|
|
398
385
|
}
|
|
399
386
|
if (!shared.isString(target)) {
|
|
@@ -406,30 +393,28 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
406
393
|
}
|
|
407
394
|
|
|
408
395
|
const { isVNode } = vue.ssrUtils;
|
|
409
|
-
function unrollBuffer(buffer) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
ret += yield unrollBuffer(item);
|
|
423
|
-
}
|
|
396
|
+
async function unrollBuffer(buffer) {
|
|
397
|
+
if (buffer.hasAsync) {
|
|
398
|
+
let ret = '';
|
|
399
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
400
|
+
let item = buffer[i];
|
|
401
|
+
if (shared.isPromise(item)) {
|
|
402
|
+
item = await item;
|
|
403
|
+
}
|
|
404
|
+
if (shared.isString(item)) {
|
|
405
|
+
ret += item;
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
ret += await unrollBuffer(item);
|
|
424
409
|
}
|
|
425
|
-
return ret;
|
|
426
|
-
}
|
|
427
|
-
else {
|
|
428
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
429
|
-
// ticks
|
|
430
|
-
return unrollBufferSync(buffer);
|
|
431
410
|
}
|
|
432
|
-
|
|
411
|
+
return ret;
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
415
|
+
// ticks
|
|
416
|
+
return unrollBufferSync(buffer);
|
|
417
|
+
}
|
|
433
418
|
}
|
|
434
419
|
function unrollBufferSync(buffer) {
|
|
435
420
|
let ret = '';
|
|
@@ -445,58 +430,53 @@ function unrollBufferSync(buffer) {
|
|
|
445
430
|
}
|
|
446
431
|
return ret;
|
|
447
432
|
}
|
|
448
|
-
function renderToString(input, context = {}) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
});
|
|
433
|
+
async function renderToString(input, context = {}) {
|
|
434
|
+
if (isVNode(input)) {
|
|
435
|
+
// raw vnode, wrap with app (for context)
|
|
436
|
+
return renderToString(vue.createApp({ render: () => input }), context);
|
|
437
|
+
}
|
|
438
|
+
// rendering an app
|
|
439
|
+
const vnode = vue.createVNode(input._component, input._props);
|
|
440
|
+
vnode.appContext = input._context;
|
|
441
|
+
// provide the ssr context to the tree
|
|
442
|
+
input.provide(vue.ssrContextKey, context);
|
|
443
|
+
const buffer = await renderComponentVNode(vnode);
|
|
444
|
+
const result = await unrollBuffer(buffer);
|
|
445
|
+
await resolveTeleports(context);
|
|
446
|
+
return result;
|
|
463
447
|
}
|
|
464
|
-
function resolveTeleports(context) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
context.teleports[key] = yield unrollBuffer((yield Promise.all(context.__teleportBuffers[key])));
|
|
472
|
-
}
|
|
448
|
+
async function resolveTeleports(context) {
|
|
449
|
+
if (context.__teleportBuffers) {
|
|
450
|
+
context.teleports = context.teleports || {};
|
|
451
|
+
for (const key in context.__teleportBuffers) {
|
|
452
|
+
// note: it's OK to await sequentially here because the Promises were
|
|
453
|
+
// created eagerly in parallel.
|
|
454
|
+
context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
|
|
473
455
|
}
|
|
474
|
-
}
|
|
456
|
+
}
|
|
475
457
|
}
|
|
476
458
|
|
|
477
459
|
const { isVNode: isVNode$1 } = vue.ssrUtils;
|
|
478
|
-
function unrollBuffer$1(buffer, stream) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
yield unrollBuffer$1(item, stream);
|
|
491
|
-
}
|
|
460
|
+
async function unrollBuffer$1(buffer, stream) {
|
|
461
|
+
if (buffer.hasAsync) {
|
|
462
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
463
|
+
let item = buffer[i];
|
|
464
|
+
if (shared.isPromise(item)) {
|
|
465
|
+
item = await item;
|
|
466
|
+
}
|
|
467
|
+
if (shared.isString(item)) {
|
|
468
|
+
stream.push(item);
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
await unrollBuffer$1(item, stream);
|
|
492
472
|
}
|
|
493
473
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
477
|
+
// ticks
|
|
478
|
+
unrollBufferSync$1(buffer, stream);
|
|
479
|
+
}
|
|
500
480
|
}
|
|
501
481
|
function unrollBufferSync$1(buffer, stream) {
|
|
502
482
|
for (let i = 0; i < buffer.length; i++) {
|
|
@@ -522,6 +502,7 @@ function renderToSimpleStream(input, context, stream) {
|
|
|
522
502
|
input.provide(vue.ssrContextKey, context);
|
|
523
503
|
Promise.resolve(renderComponentVNode(vnode))
|
|
524
504
|
.then(buffer => unrollBuffer$1(buffer, stream))
|
|
505
|
+
.then(() => resolveTeleports(context))
|
|
525
506
|
.then(() => stream.push(null))
|
|
526
507
|
.catch(error => {
|
|
527
508
|
stream.destroy(error);
|
|
@@ -536,7 +517,7 @@ function renderToStream(input, context = {}) {
|
|
|
536
517
|
return renderToNodeStream(input, context);
|
|
537
518
|
}
|
|
538
519
|
function renderToNodeStream(input, context = {}) {
|
|
539
|
-
const stream = new (require('stream').Readable)()
|
|
520
|
+
const stream = new (require('stream').Readable)({ read() { } })
|
|
540
521
|
;
|
|
541
522
|
if (!stream) {
|
|
542
523
|
throw new Error(`ESM build of renderToStream() does not support renderToNodeStream(). ` +
|
|
@@ -601,18 +582,16 @@ function pipeToWebWritable(input, context = {}, writable) {
|
|
|
601
582
|
}
|
|
602
583
|
catch (e) { }
|
|
603
584
|
renderToSimpleStream(input, context, {
|
|
604
|
-
push(content) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
});
|
|
585
|
+
async push(content) {
|
|
586
|
+
if (hasReady) {
|
|
587
|
+
await writer.ready;
|
|
588
|
+
}
|
|
589
|
+
if (content != null) {
|
|
590
|
+
return writer.write(encoder.encode(content));
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
return writer.close();
|
|
594
|
+
}
|
|
616
595
|
},
|
|
617
596
|
destroy(err) {
|
|
618
597
|
// TODO better error handling?
|
|
@@ -629,6 +608,10 @@ function ssrRenderComponent(comp, props = null, children = null, parentComponent
|
|
|
629
608
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
630
609
|
// template-compiled slots are always rendered as fragments
|
|
631
610
|
push(`<!--[-->`);
|
|
611
|
+
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
612
|
+
push(`<!--]-->`);
|
|
613
|
+
}
|
|
614
|
+
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
632
615
|
const slotFn = slots[slotName];
|
|
633
616
|
if (slotFn) {
|
|
634
617
|
const slotBuffer = [];
|
|
@@ -665,11 +648,12 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, paren
|
|
|
665
648
|
else if (fallbackRenderFn) {
|
|
666
649
|
fallbackRenderFn();
|
|
667
650
|
}
|
|
668
|
-
push(`<!--]-->`);
|
|
669
651
|
}
|
|
670
|
-
const commentRE =
|
|
652
|
+
const commentRE = /<!--[^]*?-->/gm;
|
|
671
653
|
function isComment(item) {
|
|
672
|
-
return typeof item === 'string' &&
|
|
654
|
+
return (typeof item === 'string' &&
|
|
655
|
+
commentRE.test(item) &&
|
|
656
|
+
!item.replace(commentRE, '').trim());
|
|
673
657
|
}
|
|
674
658
|
|
|
675
659
|
function ssrInterpolate(value) {
|
|
@@ -704,15 +688,13 @@ function ssrRenderList(source, renderItem) {
|
|
|
704
688
|
}
|
|
705
689
|
}
|
|
706
690
|
|
|
707
|
-
function ssrRenderSuspense(push, { default: renderContent }) {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
}
|
|
715
|
-
});
|
|
691
|
+
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
692
|
+
if (renderContent) {
|
|
693
|
+
renderContent();
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
push(`<!---->`);
|
|
697
|
+
}
|
|
716
698
|
}
|
|
717
699
|
|
|
718
700
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
@@ -786,6 +768,7 @@ exports.ssrRenderDynamicAttr = ssrRenderDynamicAttr;
|
|
|
786
768
|
exports.ssrRenderDynamicModel = ssrRenderDynamicModel;
|
|
787
769
|
exports.ssrRenderList = ssrRenderList;
|
|
788
770
|
exports.ssrRenderSlot = ssrRenderSlot;
|
|
771
|
+
exports.ssrRenderSlotInner = ssrRenderSlotInner;
|
|
789
772
|
exports.ssrRenderStyle = ssrRenderStyle;
|
|
790
773
|
exports.ssrRenderSuspense = ssrRenderSuspense;
|
|
791
774
|
exports.ssrRenderTeleport = ssrRenderTeleport;
|
|
@@ -83,6 +83,8 @@ export declare function ssrRenderList(source: unknown, renderItem: (value: unkno
|
|
|
83
83
|
|
|
84
84
|
export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
|
|
85
85
|
|
|
86
|
+
export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
|
|
87
|
+
|
|
86
88
|
export declare function ssrRenderStyle(raw: unknown): string;
|
|
87
89
|
|
|
88
90
|
export declare function ssrRenderSuspense(push: PushFn, { default: renderContent }: Record<string, (() => void) | undefined>): Promise<void>;
|
|
@@ -2,31 +2,6 @@ import { ssrContextKey, warn as warn$1, Fragment, Static, Comment, Text, mergePr
|
|
|
2
2
|
import { makeMap, isOn, escapeHtml, normalizeClass, propsToAttrMap, isBooleanAttr, includeBooleanAttr, isSSRSafeAttrName, isString, normalizeStyle, stringifyStyle, escapeHtmlComment, isVoidTag, isPromise, isArray, isFunction, NOOP, toDisplayString, isObject, looseEqual, looseIndexOf } from '@vue/shared';
|
|
3
3
|
export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
|
|
4
4
|
|
|
5
|
-
/*! *****************************************************************************
|
|
6
|
-
Copyright (c) Microsoft Corporation.
|
|
7
|
-
|
|
8
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
-
purpose with or without fee is hereby granted.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */
|
|
19
|
-
|
|
20
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
21
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
5
|
// leading comma for empty string ""
|
|
31
6
|
const shouldIgnoreProp = makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
32
7
|
function ssrRenderAttrs(props, tag) {
|
|
@@ -108,25 +83,24 @@ function ssrCompile(template, instance) {
|
|
|
108
83
|
|
|
109
84
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
110
85
|
parentPush('<!--teleport start-->');
|
|
86
|
+
const context = parentComponent.appContext.provides[ssrContextKey];
|
|
87
|
+
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
88
|
+
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
89
|
+
// record current index of the target buffer to handle nested teleports
|
|
90
|
+
// since the parent needs to be rendered before the child
|
|
91
|
+
const bufferIndex = targetBuffer.length;
|
|
111
92
|
let teleportContent;
|
|
112
93
|
if (disabled) {
|
|
113
94
|
contentRenderFn(parentPush);
|
|
114
|
-
teleportContent =
|
|
95
|
+
teleportContent = `<!--teleport anchor-->`;
|
|
115
96
|
}
|
|
116
97
|
else {
|
|
117
98
|
const { getBuffer, push } = createBuffer();
|
|
118
99
|
contentRenderFn(push);
|
|
119
|
-
push(
|
|
100
|
+
push(`<!--teleport anchor-->`);
|
|
120
101
|
teleportContent = getBuffer();
|
|
121
102
|
}
|
|
122
|
-
|
|
123
|
-
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
124
|
-
if (teleportBuffers[target]) {
|
|
125
|
-
teleportBuffers[target].push(teleportContent);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
teleportBuffers[target] = [teleportContent];
|
|
129
|
-
}
|
|
103
|
+
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
130
104
|
parentPush('<!--teleport end-->');
|
|
131
105
|
}
|
|
132
106
|
|
|
@@ -187,7 +161,17 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
187
161
|
const comp = instance.type;
|
|
188
162
|
const { getBuffer, push } = createBuffer();
|
|
189
163
|
if (isFunction(comp)) {
|
|
190
|
-
|
|
164
|
+
let root = renderComponentRoot(instance);
|
|
165
|
+
// #5817 scope ID attrs not falling through if functional component doesn't
|
|
166
|
+
// have props
|
|
167
|
+
if (!comp.props) {
|
|
168
|
+
for (const key in instance.attrs) {
|
|
169
|
+
if (key.startsWith(`data-v-`)) {
|
|
170
|
+
(root.props || (root.props = {}))[key] = ``;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
renderVNode(push, (instance.subTree = root), instance, slotScopeId);
|
|
191
175
|
}
|
|
192
176
|
else {
|
|
193
177
|
if ((!instance.render || instance.render === NOOP) &&
|
|
@@ -213,7 +197,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
213
197
|
const scopeId = cur.vnode.scopeId;
|
|
214
198
|
if (scopeId) {
|
|
215
199
|
if (!hasCloned) {
|
|
216
|
-
attrs =
|
|
200
|
+
attrs = { ...attrs };
|
|
217
201
|
hasCloned = true;
|
|
218
202
|
}
|
|
219
203
|
attrs[scopeId] = '';
|
|
@@ -230,7 +214,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
230
214
|
}
|
|
231
215
|
if (slotScopeId) {
|
|
232
216
|
if (!hasCloned)
|
|
233
|
-
attrs =
|
|
217
|
+
attrs = { ...attrs };
|
|
234
218
|
attrs[slotScopeId.trim()] = '';
|
|
235
219
|
}
|
|
236
220
|
// set current rendering instance for asset resolution
|
|
@@ -244,7 +228,8 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
244
228
|
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId);
|
|
245
229
|
}
|
|
246
230
|
else {
|
|
247
|
-
|
|
231
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
232
|
+
warn$1(`Component ${componentName} is missing template or render function.`);
|
|
248
233
|
push(`<!---->`);
|
|
249
234
|
}
|
|
250
235
|
}
|
|
@@ -365,7 +350,9 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
365
350
|
const target = vnode.props && vnode.props.to;
|
|
366
351
|
const disabled = vnode.props && vnode.props.disabled;
|
|
367
352
|
if (!target) {
|
|
368
|
-
|
|
353
|
+
if (!disabled) {
|
|
354
|
+
warn$1(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
355
|
+
}
|
|
369
356
|
return [];
|
|
370
357
|
}
|
|
371
358
|
if (!isString(target)) {
|
|
@@ -378,30 +365,28 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
378
365
|
}
|
|
379
366
|
|
|
380
367
|
const { isVNode } = ssrUtils;
|
|
381
|
-
function unrollBuffer(buffer) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
ret += yield unrollBuffer(item);
|
|
395
|
-
}
|
|
368
|
+
async function unrollBuffer(buffer) {
|
|
369
|
+
if (buffer.hasAsync) {
|
|
370
|
+
let ret = '';
|
|
371
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
372
|
+
let item = buffer[i];
|
|
373
|
+
if (isPromise(item)) {
|
|
374
|
+
item = await item;
|
|
375
|
+
}
|
|
376
|
+
if (isString(item)) {
|
|
377
|
+
ret += item;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
ret += await unrollBuffer(item);
|
|
396
381
|
}
|
|
397
|
-
return ret;
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
401
|
-
// ticks
|
|
402
|
-
return unrollBufferSync(buffer);
|
|
403
382
|
}
|
|
404
|
-
|
|
383
|
+
return ret;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
387
|
+
// ticks
|
|
388
|
+
return unrollBufferSync(buffer);
|
|
389
|
+
}
|
|
405
390
|
}
|
|
406
391
|
function unrollBufferSync(buffer) {
|
|
407
392
|
let ret = '';
|
|
@@ -417,58 +402,53 @@ function unrollBufferSync(buffer) {
|
|
|
417
402
|
}
|
|
418
403
|
return ret;
|
|
419
404
|
}
|
|
420
|
-
function renderToString(input, context = {}) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
});
|
|
405
|
+
async function renderToString(input, context = {}) {
|
|
406
|
+
if (isVNode(input)) {
|
|
407
|
+
// raw vnode, wrap with app (for context)
|
|
408
|
+
return renderToString(createApp({ render: () => input }), context);
|
|
409
|
+
}
|
|
410
|
+
// rendering an app
|
|
411
|
+
const vnode = createVNode(input._component, input._props);
|
|
412
|
+
vnode.appContext = input._context;
|
|
413
|
+
// provide the ssr context to the tree
|
|
414
|
+
input.provide(ssrContextKey, context);
|
|
415
|
+
const buffer = await renderComponentVNode(vnode);
|
|
416
|
+
const result = await unrollBuffer(buffer);
|
|
417
|
+
await resolveTeleports(context);
|
|
418
|
+
return result;
|
|
435
419
|
}
|
|
436
|
-
function resolveTeleports(context) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
context.teleports[key] = yield unrollBuffer((yield Promise.all(context.__teleportBuffers[key])));
|
|
444
|
-
}
|
|
420
|
+
async function resolveTeleports(context) {
|
|
421
|
+
if (context.__teleportBuffers) {
|
|
422
|
+
context.teleports = context.teleports || {};
|
|
423
|
+
for (const key in context.__teleportBuffers) {
|
|
424
|
+
// note: it's OK to await sequentially here because the Promises were
|
|
425
|
+
// created eagerly in parallel.
|
|
426
|
+
context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
|
|
445
427
|
}
|
|
446
|
-
}
|
|
428
|
+
}
|
|
447
429
|
}
|
|
448
430
|
|
|
449
431
|
const { isVNode: isVNode$1 } = ssrUtils;
|
|
450
|
-
function unrollBuffer$1(buffer, stream) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
yield unrollBuffer$1(item, stream);
|
|
463
|
-
}
|
|
432
|
+
async function unrollBuffer$1(buffer, stream) {
|
|
433
|
+
if (buffer.hasAsync) {
|
|
434
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
435
|
+
let item = buffer[i];
|
|
436
|
+
if (isPromise(item)) {
|
|
437
|
+
item = await item;
|
|
438
|
+
}
|
|
439
|
+
if (isString(item)) {
|
|
440
|
+
stream.push(item);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
await unrollBuffer$1(item, stream);
|
|
464
444
|
}
|
|
465
445
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
449
|
+
// ticks
|
|
450
|
+
unrollBufferSync$1(buffer, stream);
|
|
451
|
+
}
|
|
472
452
|
}
|
|
473
453
|
function unrollBufferSync$1(buffer, stream) {
|
|
474
454
|
for (let i = 0; i < buffer.length; i++) {
|
|
@@ -494,6 +474,7 @@ function renderToSimpleStream(input, context, stream) {
|
|
|
494
474
|
input.provide(ssrContextKey, context);
|
|
495
475
|
Promise.resolve(renderComponentVNode(vnode))
|
|
496
476
|
.then(buffer => unrollBuffer$1(buffer, stream))
|
|
477
|
+
.then(() => resolveTeleports(context))
|
|
497
478
|
.then(() => stream.push(null))
|
|
498
479
|
.catch(error => {
|
|
499
480
|
stream.destroy(error);
|
|
@@ -571,18 +552,16 @@ function pipeToWebWritable(input, context = {}, writable) {
|
|
|
571
552
|
}
|
|
572
553
|
catch (e) { }
|
|
573
554
|
renderToSimpleStream(input, context, {
|
|
574
|
-
push(content) {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
});
|
|
555
|
+
async push(content) {
|
|
556
|
+
if (hasReady) {
|
|
557
|
+
await writer.ready;
|
|
558
|
+
}
|
|
559
|
+
if (content != null) {
|
|
560
|
+
return writer.write(encoder.encode(content));
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
return writer.close();
|
|
564
|
+
}
|
|
586
565
|
},
|
|
587
566
|
destroy(err) {
|
|
588
567
|
// TODO better error handling?
|
|
@@ -599,6 +578,10 @@ function ssrRenderComponent(comp, props = null, children = null, parentComponent
|
|
|
599
578
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
600
579
|
// template-compiled slots are always rendered as fragments
|
|
601
580
|
push(`<!--[-->`);
|
|
581
|
+
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
582
|
+
push(`<!--]-->`);
|
|
583
|
+
}
|
|
584
|
+
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
602
585
|
const slotFn = slots[slotName];
|
|
603
586
|
if (slotFn) {
|
|
604
587
|
const slotBuffer = [];
|
|
@@ -635,11 +618,12 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, paren
|
|
|
635
618
|
else if (fallbackRenderFn) {
|
|
636
619
|
fallbackRenderFn();
|
|
637
620
|
}
|
|
638
|
-
push(`<!--]-->`);
|
|
639
621
|
}
|
|
640
|
-
const commentRE =
|
|
622
|
+
const commentRE = /<!--[^]*?-->/gm;
|
|
641
623
|
function isComment(item) {
|
|
642
|
-
return typeof item === 'string' &&
|
|
624
|
+
return (typeof item === 'string' &&
|
|
625
|
+
commentRE.test(item) &&
|
|
626
|
+
!item.replace(commentRE, '').trim());
|
|
643
627
|
}
|
|
644
628
|
|
|
645
629
|
function ssrInterpolate(value) {
|
|
@@ -923,15 +907,13 @@ function ssrRenderList(source, renderItem) {
|
|
|
923
907
|
}
|
|
924
908
|
}
|
|
925
909
|
|
|
926
|
-
function ssrRenderSuspense(push, { default: renderContent }) {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
});
|
|
910
|
+
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
911
|
+
if (renderContent) {
|
|
912
|
+
renderContent();
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
push(`<!---->`);
|
|
916
|
+
}
|
|
935
917
|
}
|
|
936
918
|
|
|
937
919
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
@@ -984,4 +966,4 @@ function ssrGetDynamicModelProps(existingProps = {}, model) {
|
|
|
984
966
|
|
|
985
967
|
initDirectivesForSSR();
|
|
986
968
|
|
|
987
|
-
export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };
|
|
969
|
+
export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/server-renderer",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.35",
|
|
4
4
|
"description": "@vue/server-renderer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/server-renderer.esm-bundler.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/server-renderer#readme",
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"vue": "3.2.
|
|
34
|
+
"vue": "3.2.35"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@vue/shared": "3.2.
|
|
38
|
-
"@vue/compiler-ssr": "3.2.
|
|
37
|
+
"@vue/shared": "3.2.35",
|
|
38
|
+
"@vue/compiler-ssr": "3.2.35"
|
|
39
39
|
}
|
|
40
40
|
}
|