@vue/server-renderer 3.1.0 → 3.1.4
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 +104 -68
- package/dist/server-renderer.cjs.prod.js +103 -68
- package/package.json +4 -4
|
@@ -7,6 +7,31 @@ var shared = require('@vue/shared');
|
|
|
7
7
|
var compilerSsr = require('@vue/compiler-ssr');
|
|
8
8
|
var stream = require('stream');
|
|
9
9
|
|
|
10
|
+
/*! *****************************************************************************
|
|
11
|
+
Copyright (c) Microsoft Corporation.
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
***************************************************************************** */
|
|
24
|
+
|
|
25
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
10
35
|
// leading comma for empty string ""
|
|
11
36
|
const shouldIgnoreProp = shared.makeMap(`,key,ref,innerHTML,textContent`);
|
|
12
37
|
function ssrRenderAttrs(props, tag) {
|
|
@@ -200,7 +225,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
200
225
|
const scopeId = cur.vnode.scopeId;
|
|
201
226
|
if (scopeId) {
|
|
202
227
|
if (!hasCloned) {
|
|
203
|
-
attrs = {
|
|
228
|
+
attrs = Object.assign({}, attrs);
|
|
204
229
|
hasCloned = true;
|
|
205
230
|
}
|
|
206
231
|
attrs[scopeId] = '';
|
|
@@ -217,7 +242,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
217
242
|
}
|
|
218
243
|
if (slotScopeId) {
|
|
219
244
|
if (!hasCloned)
|
|
220
|
-
attrs = {
|
|
245
|
+
attrs = Object.assign({}, attrs);
|
|
221
246
|
attrs[slotScopeId.trim()] = '';
|
|
222
247
|
}
|
|
223
248
|
// set current rendering instance for asset resolution
|
|
@@ -365,28 +390,30 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
365
390
|
}
|
|
366
391
|
|
|
367
392
|
const { isVNode } = vue.ssrUtils;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
let
|
|
373
|
-
|
|
374
|
-
item
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
393
|
+
function unrollBuffer(buffer) {
|
|
394
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
395
|
+
if (buffer.hasAsync) {
|
|
396
|
+
let ret = '';
|
|
397
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
398
|
+
let item = buffer[i];
|
|
399
|
+
if (shared.isPromise(item)) {
|
|
400
|
+
item = yield item;
|
|
401
|
+
}
|
|
402
|
+
if (shared.isString(item)) {
|
|
403
|
+
ret += item;
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
ret += yield unrollBuffer(item);
|
|
407
|
+
}
|
|
381
408
|
}
|
|
409
|
+
return ret;
|
|
382
410
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
411
|
+
else {
|
|
412
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
413
|
+
// ticks
|
|
414
|
+
return unrollBufferSync(buffer);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
390
417
|
}
|
|
391
418
|
function unrollBufferSync(buffer) {
|
|
392
419
|
let ret = '';
|
|
@@ -402,52 +429,58 @@ function unrollBufferSync(buffer) {
|
|
|
402
429
|
}
|
|
403
430
|
return ret;
|
|
404
431
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
432
|
+
function renderToString(input, context = {}) {
|
|
433
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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 = yield renderComponentVNode(vnode);
|
|
444
|
+
yield resolveTeleports(context);
|
|
445
|
+
return unrollBuffer(buffer);
|
|
446
|
+
});
|
|
418
447
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
448
|
+
function resolveTeleports(context) {
|
|
449
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
450
|
+
if (context.__teleportBuffers) {
|
|
451
|
+
context.teleports = context.teleports || {};
|
|
452
|
+
for (const key in context.__teleportBuffers) {
|
|
453
|
+
// note: it's OK to await sequentially here because the Promises were
|
|
454
|
+
// created eagerly in parallel.
|
|
455
|
+
context.teleports[key] = yield unrollBuffer((yield Promise.all(context.__teleportBuffers[key])));
|
|
456
|
+
}
|
|
426
457
|
}
|
|
427
|
-
}
|
|
458
|
+
});
|
|
428
459
|
}
|
|
429
460
|
|
|
430
461
|
const { isVNode: isVNode$1 } = vue.ssrUtils;
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
let
|
|
435
|
-
|
|
436
|
-
item
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
462
|
+
function unrollBuffer$1(buffer, stream) {
|
|
463
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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 = yield item;
|
|
469
|
+
}
|
|
470
|
+
if (shared.isString(item)) {
|
|
471
|
+
stream.push(item);
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
yield unrollBuffer$1(item, stream);
|
|
475
|
+
}
|
|
443
476
|
}
|
|
444
477
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
478
|
+
else {
|
|
479
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
480
|
+
// ticks
|
|
481
|
+
unrollBufferSync$1(buffer, stream);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
451
484
|
}
|
|
452
485
|
function unrollBufferSync$1(buffer, stream) {
|
|
453
486
|
for (let i = 0; i < buffer.length; i++) {
|
|
@@ -656,6 +689,7 @@ function formatProp(key, value, raw) {
|
|
|
656
689
|
}
|
|
657
690
|
|
|
658
691
|
const ErrorTypeStrings = {
|
|
692
|
+
["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
|
|
659
693
|
["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
|
|
660
694
|
["c" /* CREATED */]: 'created hook',
|
|
661
695
|
["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
|
|
@@ -808,13 +842,15 @@ function ssrRenderList(source, renderItem) {
|
|
|
808
842
|
}
|
|
809
843
|
}
|
|
810
844
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
renderContent
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
845
|
+
function ssrRenderSuspense(push, { default: renderContent }) {
|
|
846
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
847
|
+
if (renderContent) {
|
|
848
|
+
renderContent();
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
push(`<!---->`);
|
|
852
|
+
}
|
|
853
|
+
});
|
|
818
854
|
}
|
|
819
855
|
|
|
820
856
|
const ssrLooseEqual = shared.looseEqual;
|
|
@@ -7,6 +7,31 @@ var shared = require('@vue/shared');
|
|
|
7
7
|
var compilerSsr = require('@vue/compiler-ssr');
|
|
8
8
|
var stream = require('stream');
|
|
9
9
|
|
|
10
|
+
/*! *****************************************************************************
|
|
11
|
+
Copyright (c) Microsoft Corporation.
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
***************************************************************************** */
|
|
24
|
+
|
|
25
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
10
35
|
// leading comma for empty string ""
|
|
11
36
|
const shouldIgnoreProp = shared.makeMap(`,key,ref,innerHTML,textContent`);
|
|
12
37
|
function ssrRenderAttrs(props, tag) {
|
|
@@ -197,7 +222,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
197
222
|
const scopeId = cur.vnode.scopeId;
|
|
198
223
|
if (scopeId) {
|
|
199
224
|
if (!hasCloned) {
|
|
200
|
-
attrs = {
|
|
225
|
+
attrs = Object.assign({}, attrs);
|
|
201
226
|
hasCloned = true;
|
|
202
227
|
}
|
|
203
228
|
attrs[scopeId] = '';
|
|
@@ -214,7 +239,7 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
214
239
|
}
|
|
215
240
|
if (slotScopeId) {
|
|
216
241
|
if (!hasCloned)
|
|
217
|
-
attrs = {
|
|
242
|
+
attrs = Object.assign({}, attrs);
|
|
218
243
|
attrs[slotScopeId.trim()] = '';
|
|
219
244
|
}
|
|
220
245
|
// set current rendering instance for asset resolution
|
|
@@ -362,28 +387,30 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
362
387
|
}
|
|
363
388
|
|
|
364
389
|
const { isVNode } = vue.ssrUtils;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
let
|
|
370
|
-
|
|
371
|
-
item
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
390
|
+
function unrollBuffer(buffer) {
|
|
391
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
392
|
+
if (buffer.hasAsync) {
|
|
393
|
+
let ret = '';
|
|
394
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
395
|
+
let item = buffer[i];
|
|
396
|
+
if (shared.isPromise(item)) {
|
|
397
|
+
item = yield item;
|
|
398
|
+
}
|
|
399
|
+
if (shared.isString(item)) {
|
|
400
|
+
ret += item;
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
ret += yield unrollBuffer(item);
|
|
404
|
+
}
|
|
378
405
|
}
|
|
406
|
+
return ret;
|
|
379
407
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
408
|
+
else {
|
|
409
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
410
|
+
// ticks
|
|
411
|
+
return unrollBufferSync(buffer);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
387
414
|
}
|
|
388
415
|
function unrollBufferSync(buffer) {
|
|
389
416
|
let ret = '';
|
|
@@ -399,52 +426,58 @@ function unrollBufferSync(buffer) {
|
|
|
399
426
|
}
|
|
400
427
|
return ret;
|
|
401
428
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
429
|
+
function renderToString(input, context = {}) {
|
|
430
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
431
|
+
if (isVNode(input)) {
|
|
432
|
+
// raw vnode, wrap with app (for context)
|
|
433
|
+
return renderToString(vue.createApp({ render: () => input }), context);
|
|
434
|
+
}
|
|
435
|
+
// rendering an app
|
|
436
|
+
const vnode = vue.createVNode(input._component, input._props);
|
|
437
|
+
vnode.appContext = input._context;
|
|
438
|
+
// provide the ssr context to the tree
|
|
439
|
+
input.provide(vue.ssrContextKey, context);
|
|
440
|
+
const buffer = yield renderComponentVNode(vnode);
|
|
441
|
+
yield resolveTeleports(context);
|
|
442
|
+
return unrollBuffer(buffer);
|
|
443
|
+
});
|
|
415
444
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
445
|
+
function resolveTeleports(context) {
|
|
446
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
447
|
+
if (context.__teleportBuffers) {
|
|
448
|
+
context.teleports = context.teleports || {};
|
|
449
|
+
for (const key in context.__teleportBuffers) {
|
|
450
|
+
// note: it's OK to await sequentially here because the Promises were
|
|
451
|
+
// created eagerly in parallel.
|
|
452
|
+
context.teleports[key] = yield unrollBuffer((yield Promise.all(context.__teleportBuffers[key])));
|
|
453
|
+
}
|
|
423
454
|
}
|
|
424
|
-
}
|
|
455
|
+
});
|
|
425
456
|
}
|
|
426
457
|
|
|
427
458
|
const { isVNode: isVNode$1 } = vue.ssrUtils;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
let
|
|
432
|
-
|
|
433
|
-
item
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
459
|
+
function unrollBuffer$1(buffer, stream) {
|
|
460
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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 = yield item;
|
|
466
|
+
}
|
|
467
|
+
if (shared.isString(item)) {
|
|
468
|
+
stream.push(item);
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
yield unrollBuffer$1(item, stream);
|
|
472
|
+
}
|
|
440
473
|
}
|
|
441
474
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
475
|
+
else {
|
|
476
|
+
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
477
|
+
// ticks
|
|
478
|
+
unrollBufferSync$1(buffer, stream);
|
|
479
|
+
}
|
|
480
|
+
});
|
|
448
481
|
}
|
|
449
482
|
function unrollBufferSync$1(buffer, stream) {
|
|
450
483
|
for (let i = 0; i < buffer.length; i++) {
|
|
@@ -562,13 +595,15 @@ function ssrRenderList(source, renderItem) {
|
|
|
562
595
|
}
|
|
563
596
|
}
|
|
564
597
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
renderContent
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
598
|
+
function ssrRenderSuspense(push, { default: renderContent }) {
|
|
599
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
600
|
+
if (renderContent) {
|
|
601
|
+
renderContent();
|
|
602
|
+
}
|
|
603
|
+
else {
|
|
604
|
+
push(`<!---->`);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
572
607
|
}
|
|
573
608
|
|
|
574
609
|
const ssrLooseEqual = shared.looseEqual;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/server-renderer",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"description": "@vue/server-renderer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "dist/server-renderer.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/server-renderer#readme",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"vue": "3.1.
|
|
31
|
+
"vue": "3.1.4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@vue/shared": "3.1.
|
|
35
|
-
"@vue/compiler-ssr": "3.1.
|
|
34
|
+
"@vue/shared": "3.1.4",
|
|
35
|
+
"@vue/compiler-ssr": "3.1.4"
|
|
36
36
|
}
|
|
37
37
|
}
|