@vue/server-renderer 3.2.47 → 3.3.0-alpha.2
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 +836 -864
- package/dist/server-renderer.cjs.prod.js +639 -656
- package/dist/server-renderer.d.ts +71 -101
- package/dist/server-renderer.esm-browser.js +6724 -7333
- package/dist/server-renderer.esm-browser.prod.js +1 -1
- package/dist/server-renderer.esm-bundler.js +812 -852
- package/package.json +4 -4
|
@@ -19,255 +19,241 @@ function _interopNamespaceDefault(e) {
|
|
|
19
19
|
|
|
20
20
|
var Vue__namespace = /*#__PURE__*/_interopNamespaceDefault(Vue);
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const shouldIgnoreProp = shared.makeMap(
|
|
23
|
+
`,key,ref,innerHTML,textContent,ref_key,ref_for`
|
|
24
|
+
);
|
|
24
25
|
function ssrRenderAttrs(props, tag) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ret += ` style="${ssrRenderStyle(value)}"`;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
ret += ssrRenderDynamicAttr(key, value, tag);
|
|
41
|
-
}
|
|
26
|
+
let ret = "";
|
|
27
|
+
for (const key in props) {
|
|
28
|
+
if (shouldIgnoreProp(key) || shared.isOn(key) || tag === "textarea" && key === "value") {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const value = props[key];
|
|
32
|
+
if (key === "class") {
|
|
33
|
+
ret += ` class="${ssrRenderClass(value)}"`;
|
|
34
|
+
} else if (key === "style") {
|
|
35
|
+
ret += ` style="${ssrRenderStyle(value)}"`;
|
|
36
|
+
} else {
|
|
37
|
+
ret += ssrRenderDynamicAttr(key, value, tag);
|
|
42
38
|
}
|
|
43
|
-
|
|
39
|
+
}
|
|
40
|
+
return ret;
|
|
44
41
|
}
|
|
45
|
-
// render an attr with dynamic (unknown) key.
|
|
46
42
|
function ssrRenderDynamicAttr(key, value, tag) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return ``;
|
|
62
|
-
}
|
|
43
|
+
if (!isRenderableValue(value)) {
|
|
44
|
+
return ``;
|
|
45
|
+
}
|
|
46
|
+
const attrKey = tag && (tag.indexOf("-") > 0 || shared.isSVGTag(tag)) ? key : shared.propsToAttrMap[key] || key.toLowerCase();
|
|
47
|
+
if (shared.isBooleanAttr(attrKey)) {
|
|
48
|
+
return shared.includeBooleanAttr(value) ? ` ${attrKey}` : ``;
|
|
49
|
+
} else if (shared.isSSRSafeAttrName(attrKey)) {
|
|
50
|
+
return value === "" ? ` ${attrKey}` : ` ${attrKey}="${shared.escapeHtml(value)}"`;
|
|
51
|
+
} else {
|
|
52
|
+
console.warn(
|
|
53
|
+
`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
|
|
54
|
+
);
|
|
55
|
+
return ``;
|
|
56
|
+
}
|
|
63
57
|
}
|
|
64
|
-
// Render a v-bind attr with static key. The key is pre-processed at compile
|
|
65
|
-
// time and we only need to check and escape value.
|
|
66
58
|
function ssrRenderAttr(key, value) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
if (!isRenderableValue(value)) {
|
|
60
|
+
return ``;
|
|
61
|
+
}
|
|
62
|
+
return ` ${key}="${shared.escapeHtml(value)}"`;
|
|
71
63
|
}
|
|
72
64
|
function isRenderableValue(value) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
65
|
+
if (value == null) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const type = typeof value;
|
|
69
|
+
return type === "string" || type === "number" || type === "boolean";
|
|
78
70
|
}
|
|
79
71
|
function ssrRenderClass(raw) {
|
|
80
|
-
|
|
72
|
+
return shared.escapeHtml(shared.normalizeClass(raw));
|
|
81
73
|
}
|
|
82
74
|
function ssrRenderStyle(raw) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
75
|
+
if (!raw) {
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
if (shared.isString(raw)) {
|
|
79
|
+
return shared.escapeHtml(raw);
|
|
80
|
+
}
|
|
81
|
+
const styles = shared.normalizeStyle(raw);
|
|
82
|
+
return shared.escapeHtml(shared.stringifyStyle(styles));
|
|
91
83
|
}
|
|
92
84
|
|
|
93
85
|
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
94
|
-
|
|
86
|
+
return renderComponentVNode(
|
|
87
|
+
Vue.createVNode(comp, props, children),
|
|
88
|
+
parentComponent,
|
|
89
|
+
slotScopeId
|
|
90
|
+
);
|
|
95
91
|
}
|
|
96
92
|
|
|
97
93
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
push(`<!--[-->`);
|
|
95
|
+
ssrRenderSlotInner(
|
|
96
|
+
slots,
|
|
97
|
+
slotName,
|
|
98
|
+
slotProps,
|
|
99
|
+
fallbackRenderFn,
|
|
100
|
+
push,
|
|
101
|
+
parentComponent,
|
|
102
|
+
slotScopeId
|
|
103
|
+
);
|
|
104
|
+
push(`<!--]-->`);
|
|
102
105
|
}
|
|
103
106
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
const slotFn = slots[slotName];
|
|
108
|
+
if (slotFn) {
|
|
109
|
+
const slotBuffer = [];
|
|
110
|
+
const bufferedPush = (item) => {
|
|
111
|
+
slotBuffer.push(item);
|
|
112
|
+
};
|
|
113
|
+
const ret = slotFn(
|
|
114
|
+
slotProps,
|
|
115
|
+
bufferedPush,
|
|
116
|
+
parentComponent,
|
|
117
|
+
slotScopeId ? " " + slotScopeId : ""
|
|
118
|
+
);
|
|
119
|
+
if (shared.isArray(ret)) {
|
|
120
|
+
renderVNodeChildren(push, ret, parentComponent, slotScopeId);
|
|
121
|
+
} else {
|
|
122
|
+
let isEmptySlot = true;
|
|
123
|
+
if (transition) {
|
|
124
|
+
isEmptySlot = false;
|
|
125
|
+
} else {
|
|
126
|
+
for (let i = 0; i < slotBuffer.length; i++) {
|
|
127
|
+
if (!isComment(slotBuffer[i])) {
|
|
128
|
+
isEmptySlot = false;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
114
131
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (transition) {
|
|
120
|
-
isEmptySlot = false;
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
for (let i = 0; i < slotBuffer.length; i++) {
|
|
124
|
-
if (!isComment(slotBuffer[i])) {
|
|
125
|
-
isEmptySlot = false;
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (isEmptySlot) {
|
|
131
|
-
if (fallbackRenderFn) {
|
|
132
|
-
fallbackRenderFn();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
for (let i = 0; i < slotBuffer.length; i++) {
|
|
137
|
-
push(slotBuffer[i]);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
132
|
+
}
|
|
133
|
+
if (isEmptySlot) {
|
|
134
|
+
if (fallbackRenderFn) {
|
|
135
|
+
fallbackRenderFn();
|
|
140
136
|
}
|
|
137
|
+
} else {
|
|
138
|
+
for (let i = 0; i < slotBuffer.length; i++) {
|
|
139
|
+
push(slotBuffer[i]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
141
142
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
} else if (fallbackRenderFn) {
|
|
144
|
+
fallbackRenderFn();
|
|
145
|
+
}
|
|
145
146
|
}
|
|
146
147
|
const commentTestRE = /^<!--.*-->$/s;
|
|
147
148
|
const commentRE = /<!--[^]*?-->/gm;
|
|
148
149
|
function isComment(item) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return !item.replace(commentRE, '').trim();
|
|
150
|
+
if (typeof item !== "string" || !commentTestRE.test(item))
|
|
151
|
+
return false;
|
|
152
|
+
if (item.length <= 8)
|
|
153
|
+
return true;
|
|
154
|
+
return !item.replace(commentRE, "").trim();
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
177
|
-
parentPush('<!--teleport end-->');
|
|
158
|
+
parentPush("<!--teleport start-->");
|
|
159
|
+
const context = parentComponent.appContext.provides[Vue.ssrContextKey];
|
|
160
|
+
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
161
|
+
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
162
|
+
const bufferIndex = targetBuffer.length;
|
|
163
|
+
let teleportContent;
|
|
164
|
+
if (disabled) {
|
|
165
|
+
contentRenderFn(parentPush);
|
|
166
|
+
teleportContent = `<!--teleport anchor-->`;
|
|
167
|
+
} else {
|
|
168
|
+
const { getBuffer, push } = createBuffer();
|
|
169
|
+
contentRenderFn(push);
|
|
170
|
+
push(`<!--teleport anchor-->`);
|
|
171
|
+
teleportContent = getBuffer();
|
|
172
|
+
}
|
|
173
|
+
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
174
|
+
parentPush("<!--teleport end-->");
|
|
178
175
|
}
|
|
179
176
|
|
|
180
177
|
function ssrInterpolate(value) {
|
|
181
|
-
|
|
178
|
+
return shared.escapeHtml(shared.toDisplayString(value));
|
|
182
179
|
}
|
|
183
180
|
|
|
184
181
|
function ssrRenderList(source, renderItem) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const key = keys[i];
|
|
206
|
-
renderItem(source[key], key, i);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
182
|
+
if (shared.isArray(source) || shared.isString(source)) {
|
|
183
|
+
for (let i = 0, l = source.length; i < l; i++) {
|
|
184
|
+
renderItem(source[i], i);
|
|
185
|
+
}
|
|
186
|
+
} else if (typeof source === "number") {
|
|
187
|
+
for (let i = 0; i < source; i++) {
|
|
188
|
+
renderItem(i + 1, i);
|
|
189
|
+
}
|
|
190
|
+
} else if (shared.isObject(source)) {
|
|
191
|
+
if (source[Symbol.iterator]) {
|
|
192
|
+
const arr = Array.from(source);
|
|
193
|
+
for (let i = 0, l = arr.length; i < l; i++) {
|
|
194
|
+
renderItem(arr[i], i);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
const keys = Object.keys(source);
|
|
198
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
199
|
+
const key = keys[i];
|
|
200
|
+
renderItem(source[key], key, i);
|
|
201
|
+
}
|
|
209
202
|
}
|
|
203
|
+
}
|
|
210
204
|
}
|
|
211
205
|
|
|
212
206
|
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
207
|
+
if (renderContent) {
|
|
208
|
+
renderContent();
|
|
209
|
+
} else {
|
|
210
|
+
push(`<!---->`);
|
|
211
|
+
}
|
|
219
212
|
}
|
|
220
213
|
|
|
221
214
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
215
|
+
if (typeof dir !== "function" && dir.getSSRProps) {
|
|
216
|
+
return dir.getSSRProps(
|
|
217
|
+
{
|
|
218
|
+
dir,
|
|
219
|
+
instance,
|
|
220
|
+
value,
|
|
221
|
+
oldValue: void 0,
|
|
222
|
+
arg,
|
|
223
|
+
modifiers
|
|
224
|
+
},
|
|
225
|
+
null
|
|
226
|
+
) || {};
|
|
227
|
+
}
|
|
228
|
+
return {};
|
|
233
229
|
}
|
|
234
230
|
|
|
235
231
|
const ssrLooseEqual = shared.looseEqual;
|
|
236
232
|
function ssrLooseContain(arr, value) {
|
|
237
|
-
|
|
233
|
+
return shared.looseIndexOf(arr, value) > -1;
|
|
238
234
|
}
|
|
239
|
-
// for <input :type="type" v-model="model" value="value">
|
|
240
235
|
function ssrRenderDynamicModel(type, model, value) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
// text types
|
|
250
|
-
return ssrRenderAttr('value', model);
|
|
251
|
-
}
|
|
236
|
+
switch (type) {
|
|
237
|
+
case "radio":
|
|
238
|
+
return shared.looseEqual(model, value) ? " checked" : "";
|
|
239
|
+
case "checkbox":
|
|
240
|
+
return (shared.isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
|
|
241
|
+
default:
|
|
242
|
+
return ssrRenderAttr("value", model);
|
|
243
|
+
}
|
|
252
244
|
}
|
|
253
|
-
// for <input v-bind="obj" v-model="model">
|
|
254
245
|
function ssrGetDynamicModelProps(existingProps = {}, model) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
// text types
|
|
265
|
-
return { value: model };
|
|
266
|
-
}
|
|
246
|
+
const { type, value } = existingProps;
|
|
247
|
+
switch (type) {
|
|
248
|
+
case "radio":
|
|
249
|
+
return shared.looseEqual(model, value) ? { checked: true } : null;
|
|
250
|
+
case "checkbox":
|
|
251
|
+
return (shared.isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
|
|
252
|
+
default:
|
|
253
|
+
return { value: model };
|
|
254
|
+
}
|
|
267
255
|
}
|
|
268
256
|
|
|
269
|
-
// internal runtime helpers
|
|
270
|
-
|
|
271
257
|
var helpers = /*#__PURE__*/Object.freeze({
|
|
272
258
|
__proto__: null,
|
|
273
259
|
ssrGetDirectiveProps: ssrGetDirectiveProps,
|
|
@@ -291,526 +277,523 @@ var helpers = /*#__PURE__*/Object.freeze({
|
|
|
291
277
|
ssrRenderVNode: renderVNode
|
|
292
278
|
});
|
|
293
279
|
|
|
294
|
-
const compileCache = Object.create(null);
|
|
280
|
+
const compileCache = /* @__PURE__ */ Object.create(null);
|
|
295
281
|
function ssrCompile(template, instance) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
282
|
+
const Component = instance.type;
|
|
283
|
+
const { isCustomElement, compilerOptions } = instance.appContext.config;
|
|
284
|
+
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
|
285
|
+
const finalCompilerOptions = shared.extend(
|
|
286
|
+
shared.extend(
|
|
287
|
+
{
|
|
301
288
|
isCustomElement,
|
|
302
289
|
delimiters
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
290
|
+
},
|
|
291
|
+
compilerOptions
|
|
292
|
+
),
|
|
293
|
+
componentCompilerOptions
|
|
294
|
+
);
|
|
295
|
+
finalCompilerOptions.isCustomElement = finalCompilerOptions.isCustomElement || shared.NO;
|
|
296
|
+
finalCompilerOptions.isNativeTag = finalCompilerOptions.isNativeTag || shared.NO;
|
|
297
|
+
const cacheKey = JSON.stringify(
|
|
298
|
+
{
|
|
299
|
+
template,
|
|
300
|
+
compilerOptions: finalCompilerOptions
|
|
301
|
+
},
|
|
302
|
+
(key, value) => {
|
|
303
|
+
return shared.isFunction(value) ? value.toString() : value;
|
|
304
|
+
}
|
|
305
|
+
);
|
|
306
|
+
const cached = compileCache[cacheKey];
|
|
307
|
+
if (cached) {
|
|
308
|
+
return cached;
|
|
309
|
+
}
|
|
310
|
+
finalCompilerOptions.onError = (err) => {
|
|
311
|
+
{
|
|
312
|
+
throw err;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
const { code } = compilerSsr.compile(template, finalCompilerOptions);
|
|
316
|
+
const requireMap = {
|
|
317
|
+
vue: Vue__namespace,
|
|
318
|
+
"vue/server-renderer": helpers
|
|
319
|
+
};
|
|
320
|
+
const fakeRequire = (id) => requireMap[id];
|
|
321
|
+
return compileCache[cacheKey] = Function("require", code)(fakeRequire);
|
|
329
322
|
}
|
|
330
323
|
|
|
331
|
-
const {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
324
|
+
const {
|
|
325
|
+
createComponentInstance,
|
|
326
|
+
setCurrentRenderingInstance,
|
|
327
|
+
setupComponent,
|
|
328
|
+
renderComponentRoot,
|
|
329
|
+
normalizeVNode
|
|
330
|
+
} = Vue.ssrUtils;
|
|
338
331
|
function createBuffer() {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
buffer.hasAsync = true;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
};
|
|
332
|
+
let appendable = false;
|
|
333
|
+
const buffer = [];
|
|
334
|
+
return {
|
|
335
|
+
getBuffer() {
|
|
336
|
+
return buffer;
|
|
337
|
+
},
|
|
338
|
+
push(item) {
|
|
339
|
+
const isStringItem = shared.isString(item);
|
|
340
|
+
if (appendable && isStringItem) {
|
|
341
|
+
buffer[buffer.length - 1] += item;
|
|
342
|
+
} else {
|
|
343
|
+
buffer.push(item);
|
|
344
|
+
}
|
|
345
|
+
appendable = isStringItem;
|
|
346
|
+
if (shared.isPromise(item) || shared.isArray(item) && item.hasAsync) {
|
|
347
|
+
buffer.hasAsync = true;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
};
|
|
362
351
|
}
|
|
363
352
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
353
|
+
const instance = createComponentInstance(vnode, parentComponent, null);
|
|
354
|
+
const res = setupComponent(
|
|
355
|
+
instance,
|
|
356
|
+
true
|
|
357
|
+
/* isSSR */
|
|
358
|
+
);
|
|
359
|
+
const hasAsyncSetup = shared.isPromise(res);
|
|
360
|
+
const prefetches = instance.sp;
|
|
361
|
+
if (hasAsyncSetup || prefetches) {
|
|
362
|
+
let p = hasAsyncSetup ? res : Promise.resolve();
|
|
363
|
+
if (prefetches) {
|
|
364
|
+
p = p.then(
|
|
365
|
+
() => Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)))
|
|
366
|
+
).catch(() => {
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
return p.then(() => renderComponentSubTree(instance, slotScopeId));
|
|
370
|
+
} else {
|
|
371
|
+
return renderComponentSubTree(instance, slotScopeId);
|
|
372
|
+
}
|
|
383
373
|
}
|
|
384
374
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
375
|
+
const comp = instance.type;
|
|
376
|
+
const { getBuffer, push } = createBuffer();
|
|
377
|
+
if (shared.isFunction(comp)) {
|
|
378
|
+
let root = renderComponentRoot(instance);
|
|
379
|
+
if (!comp.props) {
|
|
380
|
+
for (const key in instance.attrs) {
|
|
381
|
+
if (key.startsWith(`data-v-`)) {
|
|
382
|
+
(root.props || (root.props = {}))[key] = ``;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
renderVNode(push, instance.subTree = root, instance, slotScopeId);
|
|
387
|
+
} else {
|
|
388
|
+
if ((!instance.render || instance.render === shared.NOOP) && !instance.ssrRender && !comp.ssrRender && shared.isString(comp.template)) {
|
|
389
|
+
comp.ssrRender = ssrCompile(comp.template, instance);
|
|
390
|
+
}
|
|
391
|
+
for (const e of instance.scope.effects) {
|
|
392
|
+
if (e.computed)
|
|
393
|
+
e.computed._cacheable = true;
|
|
394
|
+
}
|
|
395
|
+
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
396
|
+
if (ssrRender) {
|
|
397
|
+
let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|
|
398
|
+
let hasCloned = false;
|
|
399
|
+
let cur = instance;
|
|
400
|
+
while (true) {
|
|
401
|
+
const scopeId = cur.vnode.scopeId;
|
|
402
|
+
if (scopeId) {
|
|
403
|
+
if (!hasCloned) {
|
|
404
|
+
attrs = { ...attrs };
|
|
405
|
+
hasCloned = true;
|
|
406
|
+
}
|
|
407
|
+
attrs[scopeId] = "";
|
|
408
|
+
}
|
|
409
|
+
const parent = cur.parent;
|
|
410
|
+
if (parent && parent.subTree && parent.subTree === cur.vnode) {
|
|
411
|
+
cur = parent;
|
|
412
|
+
} else {
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (slotScopeId) {
|
|
417
|
+
if (!hasCloned)
|
|
418
|
+
attrs = { ...attrs };
|
|
419
|
+
attrs[slotScopeId.trim()] = "";
|
|
420
|
+
}
|
|
421
|
+
const prev = setCurrentRenderingInstance(instance);
|
|
422
|
+
try {
|
|
423
|
+
ssrRender(
|
|
424
|
+
instance.proxy,
|
|
425
|
+
push,
|
|
426
|
+
instance,
|
|
427
|
+
attrs,
|
|
428
|
+
// compiler-optimized bindings
|
|
429
|
+
instance.props,
|
|
430
|
+
instance.setupState,
|
|
431
|
+
instance.data,
|
|
432
|
+
instance.ctx
|
|
433
|
+
);
|
|
434
|
+
} finally {
|
|
435
|
+
setCurrentRenderingInstance(prev);
|
|
436
|
+
}
|
|
437
|
+
} else if (instance.render && instance.render !== shared.NOOP) {
|
|
438
|
+
renderVNode(
|
|
439
|
+
push,
|
|
440
|
+
instance.subTree = renderComponentRoot(instance),
|
|
441
|
+
instance,
|
|
442
|
+
slotScopeId
|
|
443
|
+
);
|
|
444
|
+
} else {
|
|
445
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
446
|
+
Vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
447
|
+
push(`<!---->`);
|
|
399
448
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
!instance.ssrRender &&
|
|
403
|
-
!comp.ssrRender &&
|
|
404
|
-
shared.isString(comp.template)) {
|
|
405
|
-
comp.ssrRender = ssrCompile(comp.template, instance);
|
|
406
|
-
}
|
|
407
|
-
// perf: enable caching of computed getters during render
|
|
408
|
-
// since there cannot be state mutations during render.
|
|
409
|
-
for (const e of instance.scope.effects) {
|
|
410
|
-
if (e.computed)
|
|
411
|
-
e.computed._cacheable = true;
|
|
412
|
-
}
|
|
413
|
-
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
414
|
-
if (ssrRender) {
|
|
415
|
-
// optimized
|
|
416
|
-
// resolve fallthrough attrs
|
|
417
|
-
let attrs = instance.inheritAttrs !== false ? instance.attrs : undefined;
|
|
418
|
-
let hasCloned = false;
|
|
419
|
-
let cur = instance;
|
|
420
|
-
while (true) {
|
|
421
|
-
const scopeId = cur.vnode.scopeId;
|
|
422
|
-
if (scopeId) {
|
|
423
|
-
if (!hasCloned) {
|
|
424
|
-
attrs = { ...attrs };
|
|
425
|
-
hasCloned = true;
|
|
426
|
-
}
|
|
427
|
-
attrs[scopeId] = '';
|
|
428
|
-
}
|
|
429
|
-
const parent = cur.parent;
|
|
430
|
-
if (parent && parent.subTree && parent.subTree === cur.vnode) {
|
|
431
|
-
// parent is a non-SSR compiled component and is rendering this
|
|
432
|
-
// component as root. inherit its scopeId if present.
|
|
433
|
-
cur = parent;
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
break;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
if (slotScopeId) {
|
|
440
|
-
if (!hasCloned)
|
|
441
|
-
attrs = { ...attrs };
|
|
442
|
-
attrs[slotScopeId.trim()] = '';
|
|
443
|
-
}
|
|
444
|
-
// set current rendering instance for asset resolution
|
|
445
|
-
const prev = setCurrentRenderingInstance(instance);
|
|
446
|
-
try {
|
|
447
|
-
ssrRender(instance.proxy, push, instance, attrs,
|
|
448
|
-
// compiler-optimized bindings
|
|
449
|
-
instance.props, instance.setupState, instance.data, instance.ctx);
|
|
450
|
-
}
|
|
451
|
-
finally {
|
|
452
|
-
setCurrentRenderingInstance(prev);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
else if (instance.render && instance.render !== shared.NOOP) {
|
|
456
|
-
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId);
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
460
|
-
Vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
461
|
-
push(`<!---->`);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return getBuffer();
|
|
449
|
+
}
|
|
450
|
+
return getBuffer();
|
|
465
451
|
}
|
|
466
452
|
function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
453
|
+
const { type, shapeFlag, children } = vnode;
|
|
454
|
+
switch (type) {
|
|
455
|
+
case Vue.Text:
|
|
456
|
+
push(shared.escapeHtml(children));
|
|
457
|
+
break;
|
|
458
|
+
case Vue.Comment:
|
|
459
|
+
push(
|
|
460
|
+
children ? `<!--${shared.escapeHtmlComment(children)}-->` : `<!---->`
|
|
461
|
+
);
|
|
462
|
+
break;
|
|
463
|
+
case Vue.Static:
|
|
464
|
+
push(children);
|
|
465
|
+
break;
|
|
466
|
+
case Vue.Fragment:
|
|
467
|
+
if (vnode.slotScopeIds) {
|
|
468
|
+
slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
469
|
+
}
|
|
470
|
+
push(`<!--[-->`);
|
|
471
|
+
renderVNodeChildren(
|
|
472
|
+
push,
|
|
473
|
+
children,
|
|
474
|
+
parentComponent,
|
|
475
|
+
slotScopeId
|
|
476
|
+
);
|
|
477
|
+
push(`<!--]-->`);
|
|
478
|
+
break;
|
|
479
|
+
default:
|
|
480
|
+
if (shapeFlag & 1) {
|
|
481
|
+
renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
482
|
+
} else if (shapeFlag & 6) {
|
|
483
|
+
push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
484
|
+
} else if (shapeFlag & 64) {
|
|
485
|
+
renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
486
|
+
} else if (shapeFlag & 128) {
|
|
487
|
+
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
488
|
+
} else {
|
|
489
|
+
Vue.warn(
|
|
490
|
+
"[@vue/server-renderer] Invalid VNode type:",
|
|
491
|
+
type,
|
|
492
|
+
`(${typeof type})`
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
504
496
|
}
|
|
505
497
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
498
|
+
for (let i = 0; i < children.length; i++) {
|
|
499
|
+
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
500
|
+
}
|
|
509
501
|
}
|
|
510
502
|
function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
503
|
+
const tag = vnode.type;
|
|
504
|
+
let { props, children, shapeFlag, scopeId, dirs } = vnode;
|
|
505
|
+
let openTag = `<${tag}`;
|
|
506
|
+
if (dirs) {
|
|
507
|
+
props = applySSRDirectives(vnode, props, dirs);
|
|
508
|
+
}
|
|
509
|
+
if (props) {
|
|
510
|
+
openTag += ssrRenderAttrs(props, tag);
|
|
511
|
+
}
|
|
512
|
+
if (scopeId) {
|
|
513
|
+
openTag += ` ${scopeId}`;
|
|
514
|
+
}
|
|
515
|
+
let curParent = parentComponent;
|
|
516
|
+
let curVnode = vnode;
|
|
517
|
+
while (curParent && curVnode === curParent.subTree) {
|
|
518
|
+
curVnode = curParent.vnode;
|
|
519
|
+
if (curVnode.scopeId) {
|
|
520
|
+
openTag += ` ${curVnode.scopeId}`;
|
|
521
|
+
}
|
|
522
|
+
curParent = curParent.parent;
|
|
523
|
+
}
|
|
524
|
+
if (slotScopeId) {
|
|
525
|
+
openTag += ` ${slotScopeId}`;
|
|
526
|
+
}
|
|
527
|
+
push(openTag + `>`);
|
|
528
|
+
if (!shared.isVoidTag(tag)) {
|
|
529
|
+
let hasChildrenOverride = false;
|
|
517
530
|
if (props) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
else if (props.textContent) {
|
|
545
|
-
hasChildrenOverride = true;
|
|
546
|
-
push(shared.escapeHtml(props.textContent));
|
|
547
|
-
}
|
|
548
|
-
else if (tag === 'textarea' && props.value) {
|
|
549
|
-
hasChildrenOverride = true;
|
|
550
|
-
push(shared.escapeHtml(props.value));
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
if (!hasChildrenOverride) {
|
|
554
|
-
if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
|
|
555
|
-
push(shared.escapeHtml(children));
|
|
556
|
-
}
|
|
557
|
-
else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
|
|
558
|
-
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
push(`</${tag}>`);
|
|
562
|
-
}
|
|
531
|
+
if (props.innerHTML) {
|
|
532
|
+
hasChildrenOverride = true;
|
|
533
|
+
push(props.innerHTML);
|
|
534
|
+
} else if (props.textContent) {
|
|
535
|
+
hasChildrenOverride = true;
|
|
536
|
+
push(shared.escapeHtml(props.textContent));
|
|
537
|
+
} else if (tag === "textarea" && props.value) {
|
|
538
|
+
hasChildrenOverride = true;
|
|
539
|
+
push(shared.escapeHtml(props.value));
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (!hasChildrenOverride) {
|
|
543
|
+
if (shapeFlag & 8) {
|
|
544
|
+
push(shared.escapeHtml(children));
|
|
545
|
+
} else if (shapeFlag & 16) {
|
|
546
|
+
renderVNodeChildren(
|
|
547
|
+
push,
|
|
548
|
+
children,
|
|
549
|
+
parentComponent,
|
|
550
|
+
slotScopeId
|
|
551
|
+
);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
push(`</${tag}>`);
|
|
555
|
+
}
|
|
563
556
|
}
|
|
564
557
|
function applySSRDirectives(vnode, rawProps, dirs) {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
558
|
+
const toMerge = [];
|
|
559
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
560
|
+
const binding = dirs[i];
|
|
561
|
+
const {
|
|
562
|
+
dir: { getSSRProps }
|
|
563
|
+
} = binding;
|
|
564
|
+
if (getSSRProps) {
|
|
565
|
+
const props = getSSRProps(binding, vnode);
|
|
566
|
+
if (props)
|
|
567
|
+
toMerge.push(props);
|
|
574
568
|
}
|
|
575
|
-
|
|
569
|
+
}
|
|
570
|
+
return Vue.mergeProps(rawProps || {}, ...toMerge);
|
|
576
571
|
}
|
|
577
572
|
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
return [];
|
|
573
|
+
const target = vnode.props && vnode.props.to;
|
|
574
|
+
const disabled = vnode.props && vnode.props.disabled;
|
|
575
|
+
if (!target) {
|
|
576
|
+
if (!disabled) {
|
|
577
|
+
Vue.warn(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
585
578
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
579
|
+
return [];
|
|
580
|
+
}
|
|
581
|
+
if (!shared.isString(target)) {
|
|
582
|
+
Vue.warn(
|
|
583
|
+
`[@vue/server-renderer] Teleport target must be a query selector string.`
|
|
584
|
+
);
|
|
585
|
+
return [];
|
|
586
|
+
}
|
|
587
|
+
ssrRenderTeleport(
|
|
588
|
+
push,
|
|
589
|
+
(push2) => {
|
|
590
|
+
renderVNodeChildren(
|
|
591
|
+
push2,
|
|
592
|
+
vnode.children,
|
|
593
|
+
parentComponent,
|
|
594
|
+
slotScopeId
|
|
595
|
+
);
|
|
596
|
+
},
|
|
597
|
+
target,
|
|
598
|
+
disabled || disabled === "",
|
|
599
|
+
parentComponent
|
|
600
|
+
);
|
|
593
601
|
}
|
|
594
602
|
|
|
595
603
|
const { isVNode: isVNode$1 } = Vue.ssrUtils;
|
|
596
604
|
async function unrollBuffer$1(buffer) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
return ret;
|
|
612
|
-
}
|
|
613
|
-
else {
|
|
614
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
615
|
-
// ticks
|
|
616
|
-
return unrollBufferSync$1(buffer);
|
|
605
|
+
if (buffer.hasAsync) {
|
|
606
|
+
let ret = "";
|
|
607
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
608
|
+
let item = buffer[i];
|
|
609
|
+
if (shared.isPromise(item)) {
|
|
610
|
+
item = await item;
|
|
611
|
+
}
|
|
612
|
+
if (shared.isString(item)) {
|
|
613
|
+
ret += item;
|
|
614
|
+
} else {
|
|
615
|
+
ret += await unrollBuffer$1(item);
|
|
616
|
+
}
|
|
617
617
|
}
|
|
618
|
+
return ret;
|
|
619
|
+
} else {
|
|
620
|
+
return unrollBufferSync$1(buffer);
|
|
621
|
+
}
|
|
618
622
|
}
|
|
619
623
|
function unrollBufferSync$1(buffer) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
// since this is a sync buffer, child buffers are never promises
|
|
628
|
-
ret += unrollBufferSync$1(item);
|
|
629
|
-
}
|
|
624
|
+
let ret = "";
|
|
625
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
626
|
+
let item = buffer[i];
|
|
627
|
+
if (shared.isString(item)) {
|
|
628
|
+
ret += item;
|
|
629
|
+
} else {
|
|
630
|
+
ret += unrollBufferSync$1(item);
|
|
630
631
|
}
|
|
631
|
-
|
|
632
|
+
}
|
|
633
|
+
return ret;
|
|
632
634
|
}
|
|
633
635
|
async function renderToString(input, context = {}) {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
if (context.__watcherHandles) {
|
|
647
|
-
for (const unwatch of context.__watcherHandles) {
|
|
648
|
-
unwatch();
|
|
649
|
-
}
|
|
636
|
+
if (isVNode$1(input)) {
|
|
637
|
+
return renderToString(Vue.createApp({ render: () => input }), context);
|
|
638
|
+
}
|
|
639
|
+
const vnode = Vue.createVNode(input._component, input._props);
|
|
640
|
+
vnode.appContext = input._context;
|
|
641
|
+
input.provide(Vue.ssrContextKey, context);
|
|
642
|
+
const buffer = await renderComponentVNode(vnode);
|
|
643
|
+
const result = await unrollBuffer$1(buffer);
|
|
644
|
+
await resolveTeleports(context);
|
|
645
|
+
if (context.__watcherHandles) {
|
|
646
|
+
for (const unwatch of context.__watcherHandles) {
|
|
647
|
+
unwatch();
|
|
650
648
|
}
|
|
651
|
-
|
|
649
|
+
}
|
|
650
|
+
return result;
|
|
652
651
|
}
|
|
653
652
|
async function resolveTeleports(context) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
653
|
+
if (context.__teleportBuffers) {
|
|
654
|
+
context.teleports = context.teleports || {};
|
|
655
|
+
for (const key in context.__teleportBuffers) {
|
|
656
|
+
context.teleports[key] = await unrollBuffer$1(
|
|
657
|
+
await Promise.all([context.__teleportBuffers[key]])
|
|
658
|
+
);
|
|
661
659
|
}
|
|
660
|
+
}
|
|
662
661
|
}
|
|
663
662
|
|
|
664
663
|
const { isVNode } = Vue.ssrUtils;
|
|
665
664
|
async function unrollBuffer(buffer, stream) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
682
|
-
// ticks
|
|
683
|
-
unrollBufferSync(buffer, stream);
|
|
684
|
-
}
|
|
665
|
+
if (buffer.hasAsync) {
|
|
666
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
667
|
+
let item = buffer[i];
|
|
668
|
+
if (shared.isPromise(item)) {
|
|
669
|
+
item = await item;
|
|
670
|
+
}
|
|
671
|
+
if (shared.isString(item)) {
|
|
672
|
+
stream.push(item);
|
|
673
|
+
} else {
|
|
674
|
+
await unrollBuffer(item, stream);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
} else {
|
|
678
|
+
unrollBufferSync(buffer, stream);
|
|
679
|
+
}
|
|
685
680
|
}
|
|
686
681
|
function unrollBufferSync(buffer, stream) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
// since this is a sync buffer, child buffers are never promises
|
|
694
|
-
unrollBufferSync(item, stream);
|
|
695
|
-
}
|
|
682
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
683
|
+
let item = buffer[i];
|
|
684
|
+
if (shared.isString(item)) {
|
|
685
|
+
stream.push(item);
|
|
686
|
+
} else {
|
|
687
|
+
unrollBufferSync(item, stream);
|
|
696
688
|
}
|
|
689
|
+
}
|
|
697
690
|
}
|
|
698
691
|
function renderToSimpleStream(input, context, stream) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
692
|
+
if (isVNode(input)) {
|
|
693
|
+
return renderToSimpleStream(
|
|
694
|
+
Vue.createApp({ render: () => input }),
|
|
695
|
+
context,
|
|
696
|
+
stream
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
const vnode = Vue.createVNode(input._component, input._props);
|
|
700
|
+
vnode.appContext = input._context;
|
|
701
|
+
input.provide(Vue.ssrContextKey, context);
|
|
702
|
+
Promise.resolve(renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
|
703
|
+
if (context.__watcherHandles) {
|
|
704
|
+
for (const unwatch of context.__watcherHandles) {
|
|
705
|
+
unwatch();
|
|
706
|
+
}
|
|
702
707
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
Promise.resolve(renderComponentVNode(vnode))
|
|
709
|
-
.then(buffer => unrollBuffer(buffer, stream))
|
|
710
|
-
.then(() => resolveTeleports(context))
|
|
711
|
-
.then(() => {
|
|
712
|
-
if (context.__watcherHandles) {
|
|
713
|
-
for (const unwatch of context.__watcherHandles) {
|
|
714
|
-
unwatch();
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
})
|
|
718
|
-
.then(() => stream.push(null))
|
|
719
|
-
.catch(error => {
|
|
720
|
-
stream.destroy(error);
|
|
721
|
-
});
|
|
722
|
-
return stream;
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* @deprecated
|
|
726
|
-
*/
|
|
708
|
+
}).then(() => stream.push(null)).catch((error) => {
|
|
709
|
+
stream.destroy(error);
|
|
710
|
+
});
|
|
711
|
+
return stream;
|
|
712
|
+
}
|
|
727
713
|
function renderToStream(input, context = {}) {
|
|
728
|
-
|
|
729
|
-
|
|
714
|
+
console.warn(
|
|
715
|
+
`[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`
|
|
716
|
+
);
|
|
717
|
+
return renderToNodeStream(input, context);
|
|
730
718
|
}
|
|
731
719
|
function renderToNodeStream(input, context = {}) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
720
|
+
const stream = new (require("stream")).Readable({ read() {
|
|
721
|
+
} }) ;
|
|
722
|
+
if (!stream) {
|
|
723
|
+
throw new Error(
|
|
724
|
+
`ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
|
|
725
|
+
);
|
|
726
|
+
}
|
|
727
|
+
return renderToSimpleStream(input, context, stream);
|
|
740
728
|
}
|
|
741
729
|
function pipeToNodeWritable(input, context = {}, writable) {
|
|
742
|
-
|
|
730
|
+
renderToSimpleStream(input, context, {
|
|
731
|
+
push(content) {
|
|
732
|
+
if (content != null) {
|
|
733
|
+
writable.write(content);
|
|
734
|
+
} else {
|
|
735
|
+
writable.end();
|
|
736
|
+
}
|
|
737
|
+
},
|
|
738
|
+
destroy(err) {
|
|
739
|
+
writable.destroy(err);
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
function renderToWebStream(input, context = {}) {
|
|
744
|
+
if (typeof ReadableStream !== "function") {
|
|
745
|
+
throw new Error(
|
|
746
|
+
`ReadableStream constructor is not available in the global scope. If the target environment does support web streams, consider using pipeToWebWritable() with an existing WritableStream instance instead.`
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
const encoder = new TextEncoder();
|
|
750
|
+
let cancelled = false;
|
|
751
|
+
return new ReadableStream({
|
|
752
|
+
start(controller) {
|
|
753
|
+
renderToSimpleStream(input, context, {
|
|
743
754
|
push(content) {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
755
|
+
if (cancelled)
|
|
756
|
+
return;
|
|
757
|
+
if (content != null) {
|
|
758
|
+
controller.enqueue(encoder.encode(content));
|
|
759
|
+
} else {
|
|
760
|
+
controller.close();
|
|
761
|
+
}
|
|
750
762
|
},
|
|
751
763
|
destroy(err) {
|
|
752
|
-
|
|
764
|
+
controller.error(err);
|
|
753
765
|
}
|
|
754
|
-
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
throw new Error(`ReadableStream constructor is not available in the global scope. ` +
|
|
759
|
-
`If the target environment does support web streams, consider using ` +
|
|
760
|
-
`pipeToWebWritable() with an existing WritableStream instance instead.`);
|
|
766
|
+
});
|
|
767
|
+
},
|
|
768
|
+
cancel() {
|
|
769
|
+
cancelled = true;
|
|
761
770
|
}
|
|
762
|
-
|
|
763
|
-
let cancelled = false;
|
|
764
|
-
return new ReadableStream({
|
|
765
|
-
start(controller) {
|
|
766
|
-
renderToSimpleStream(input, context, {
|
|
767
|
-
push(content) {
|
|
768
|
-
if (cancelled)
|
|
769
|
-
return;
|
|
770
|
-
if (content != null) {
|
|
771
|
-
controller.enqueue(encoder.encode(content));
|
|
772
|
-
}
|
|
773
|
-
else {
|
|
774
|
-
controller.close();
|
|
775
|
-
}
|
|
776
|
-
},
|
|
777
|
-
destroy(err) {
|
|
778
|
-
controller.error(err);
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
},
|
|
782
|
-
cancel() {
|
|
783
|
-
cancelled = true;
|
|
784
|
-
}
|
|
785
|
-
});
|
|
771
|
+
});
|
|
786
772
|
}
|
|
787
773
|
function pipeToWebWritable(input, context = {}, writable) {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
writer.close();
|
|
812
|
-
}
|
|
813
|
-
});
|
|
774
|
+
const writer = writable.getWriter();
|
|
775
|
+
const encoder = new TextEncoder();
|
|
776
|
+
let hasReady = false;
|
|
777
|
+
try {
|
|
778
|
+
hasReady = shared.isPromise(writer.ready);
|
|
779
|
+
} catch (e) {
|
|
780
|
+
}
|
|
781
|
+
renderToSimpleStream(input, context, {
|
|
782
|
+
async push(content) {
|
|
783
|
+
if (hasReady) {
|
|
784
|
+
await writer.ready;
|
|
785
|
+
}
|
|
786
|
+
if (content != null) {
|
|
787
|
+
return writer.write(encoder.encode(content));
|
|
788
|
+
} else {
|
|
789
|
+
return writer.close();
|
|
790
|
+
}
|
|
791
|
+
},
|
|
792
|
+
destroy(err) {
|
|
793
|
+
console.log(err);
|
|
794
|
+
writer.close();
|
|
795
|
+
}
|
|
796
|
+
});
|
|
814
797
|
}
|
|
815
798
|
|
|
816
799
|
Vue.initDirectivesForSSR();
|