@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,515 +19,486 @@ 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
|
let shouldTrack = true;
|
|
185
182
|
const trackStack = [];
|
|
186
183
|
function pauseTracking() {
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
trackStack.push(shouldTrack);
|
|
185
|
+
shouldTrack = false;
|
|
189
186
|
}
|
|
190
187
|
function resetTracking() {
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
const last = trackStack.pop();
|
|
189
|
+
shouldTrack = last === void 0 ? true : last;
|
|
193
190
|
}
|
|
194
191
|
|
|
195
192
|
function toRaw(observed) {
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
const raw = observed && observed["__v_raw"];
|
|
194
|
+
return raw ? toRaw(raw) : observed;
|
|
198
195
|
}
|
|
199
196
|
|
|
200
197
|
function isRef(r) {
|
|
201
|
-
|
|
198
|
+
return !!(r && r.__v_isRef === true);
|
|
202
199
|
}
|
|
203
200
|
|
|
204
201
|
const stack = [];
|
|
205
202
|
function pushWarningContext(vnode) {
|
|
206
|
-
|
|
203
|
+
stack.push(vnode);
|
|
207
204
|
}
|
|
208
205
|
function popWarningContext() {
|
|
209
|
-
|
|
206
|
+
stack.pop();
|
|
210
207
|
}
|
|
211
208
|
function warn(msg, ...args) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
209
|
+
pauseTracking();
|
|
210
|
+
const instance = stack.length ? stack[stack.length - 1].component : null;
|
|
211
|
+
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
212
|
+
const trace = getComponentTrace();
|
|
213
|
+
if (appWarnHandler) {
|
|
214
|
+
callWithErrorHandling(
|
|
215
|
+
appWarnHandler,
|
|
216
|
+
instance,
|
|
217
|
+
11,
|
|
218
|
+
[
|
|
219
|
+
msg + args.join(""),
|
|
220
|
+
instance && instance.proxy,
|
|
221
|
+
trace.map(
|
|
222
|
+
({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
|
223
|
+
).join("\n"),
|
|
224
|
+
trace
|
|
225
|
+
]
|
|
226
|
+
);
|
|
227
|
+
} else {
|
|
228
|
+
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
229
|
+
if (trace.length && // avoid spamming console during tests
|
|
230
|
+
true) {
|
|
231
|
+
warnArgs.push(`
|
|
232
|
+
`, ...formatTrace(trace));
|
|
233
|
+
}
|
|
234
|
+
console.warn(...warnArgs);
|
|
235
|
+
}
|
|
236
|
+
resetTracking();
|
|
239
237
|
}
|
|
240
238
|
function getComponentTrace() {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
261
|
-
currentVNode = parentInstance && parentInstance.vnode;
|
|
262
|
-
}
|
|
263
|
-
return normalizedStack;
|
|
239
|
+
let currentVNode = stack[stack.length - 1];
|
|
240
|
+
if (!currentVNode) {
|
|
241
|
+
return [];
|
|
242
|
+
}
|
|
243
|
+
const normalizedStack = [];
|
|
244
|
+
while (currentVNode) {
|
|
245
|
+
const last = normalizedStack[0];
|
|
246
|
+
if (last && last.vnode === currentVNode) {
|
|
247
|
+
last.recurseCount++;
|
|
248
|
+
} else {
|
|
249
|
+
normalizedStack.push({
|
|
250
|
+
vnode: currentVNode,
|
|
251
|
+
recurseCount: 0
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
255
|
+
currentVNode = parentInstance && parentInstance.vnode;
|
|
256
|
+
}
|
|
257
|
+
return normalizedStack;
|
|
264
258
|
}
|
|
265
|
-
/* istanbul ignore next */
|
|
266
259
|
function formatTrace(trace) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
260
|
+
const logs = [];
|
|
261
|
+
trace.forEach((entry, i) => {
|
|
262
|
+
logs.push(...i === 0 ? [] : [`
|
|
263
|
+
`], ...formatTraceEntry(entry));
|
|
264
|
+
});
|
|
265
|
+
return logs;
|
|
272
266
|
}
|
|
273
267
|
function formatTraceEntry({ vnode, recurseCount }) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
268
|
+
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
269
|
+
const isRoot = vnode.component ? vnode.component.parent == null : false;
|
|
270
|
+
const open = ` at <${formatComponentName(
|
|
271
|
+
vnode.component,
|
|
272
|
+
vnode.type,
|
|
273
|
+
isRoot
|
|
274
|
+
)}`;
|
|
275
|
+
const close = `>` + postfix;
|
|
276
|
+
return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
|
281
277
|
}
|
|
282
|
-
/* istanbul ignore next */
|
|
283
278
|
function formatProps(props) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
279
|
+
const res = [];
|
|
280
|
+
const keys = Object.keys(props);
|
|
281
|
+
keys.slice(0, 3).forEach((key) => {
|
|
282
|
+
res.push(...formatProp(key, props[key]));
|
|
283
|
+
});
|
|
284
|
+
if (keys.length > 3) {
|
|
285
|
+
res.push(` ...`);
|
|
286
|
+
}
|
|
287
|
+
return res;
|
|
293
288
|
}
|
|
294
|
-
/* istanbul ignore next */
|
|
295
289
|
function formatProp(key, value, raw) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
value = toRaw(value);
|
|
314
|
-
return raw ? value : [`${key}=`, value];
|
|
315
|
-
}
|
|
290
|
+
if (shared.isString(value)) {
|
|
291
|
+
value = JSON.stringify(value);
|
|
292
|
+
return raw ? value : [`${key}=${value}`];
|
|
293
|
+
} else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
|
294
|
+
return raw ? value : [`${key}=${value}`];
|
|
295
|
+
} else if (isRef(value)) {
|
|
296
|
+
value = formatProp(key, toRaw(value.value), true);
|
|
297
|
+
return raw ? value : [`${key}=Ref<`, value, `>`];
|
|
298
|
+
} else if (shared.isFunction(value)) {
|
|
299
|
+
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
300
|
+
} else {
|
|
301
|
+
value = toRaw(value);
|
|
302
|
+
return raw ? value : [`${key}=`, value];
|
|
303
|
+
}
|
|
316
304
|
}
|
|
317
305
|
|
|
318
306
|
const ErrorTypeStrings = {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
|
|
307
|
+
["sp"]: "serverPrefetch hook",
|
|
308
|
+
["bc"]: "beforeCreate hook",
|
|
309
|
+
["c"]: "created hook",
|
|
310
|
+
["bm"]: "beforeMount hook",
|
|
311
|
+
["m"]: "mounted hook",
|
|
312
|
+
["bu"]: "beforeUpdate hook",
|
|
313
|
+
["u"]: "updated",
|
|
314
|
+
["bum"]: "beforeUnmount hook",
|
|
315
|
+
["um"]: "unmounted hook",
|
|
316
|
+
["a"]: "activated hook",
|
|
317
|
+
["da"]: "deactivated hook",
|
|
318
|
+
["ec"]: "errorCaptured hook",
|
|
319
|
+
["rtc"]: "renderTracked hook",
|
|
320
|
+
["rtg"]: "renderTriggered hook",
|
|
321
|
+
[0]: "setup function",
|
|
322
|
+
[1]: "render function",
|
|
323
|
+
[2]: "watcher getter",
|
|
324
|
+
[3]: "watcher callback",
|
|
325
|
+
[4]: "watcher cleanup function",
|
|
326
|
+
[5]: "native event handler",
|
|
327
|
+
[6]: "component event handler",
|
|
328
|
+
[7]: "vnode hook",
|
|
329
|
+
[8]: "directive hook",
|
|
330
|
+
[9]: "transition hook",
|
|
331
|
+
[10]: "app errorHandler",
|
|
332
|
+
[11]: "app warnHandler",
|
|
333
|
+
[12]: "ref function",
|
|
334
|
+
[13]: "async component loader",
|
|
335
|
+
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
|
|
349
336
|
};
|
|
350
337
|
function callWithErrorHandling(fn, instance, type, args) {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return res;
|
|
338
|
+
let res;
|
|
339
|
+
try {
|
|
340
|
+
res = args ? fn(...args) : fn();
|
|
341
|
+
} catch (err) {
|
|
342
|
+
handleError(err, instance, type);
|
|
343
|
+
}
|
|
344
|
+
return res;
|
|
359
345
|
}
|
|
360
346
|
function handleError(err, instance, type, throwInDev = true) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
for (let i = 0; i < errorCapturedHooks.length; i++) {
|
|
372
|
-
if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
cur = cur.parent;
|
|
378
|
-
}
|
|
379
|
-
// app-level handling
|
|
380
|
-
const appErrorHandler = instance.appContext.config.errorHandler;
|
|
381
|
-
if (appErrorHandler) {
|
|
382
|
-
callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
|
|
347
|
+
const contextVNode = instance ? instance.vnode : null;
|
|
348
|
+
if (instance) {
|
|
349
|
+
let cur = instance.parent;
|
|
350
|
+
const exposedInstance = instance.proxy;
|
|
351
|
+
const errorInfo = ErrorTypeStrings[type] ;
|
|
352
|
+
while (cur) {
|
|
353
|
+
const errorCapturedHooks = cur.ec;
|
|
354
|
+
if (errorCapturedHooks) {
|
|
355
|
+
for (let i = 0; i < errorCapturedHooks.length; i++) {
|
|
356
|
+
if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
|
383
357
|
return;
|
|
358
|
+
}
|
|
384
359
|
}
|
|
360
|
+
}
|
|
361
|
+
cur = cur.parent;
|
|
362
|
+
}
|
|
363
|
+
const appErrorHandler = instance.appContext.config.errorHandler;
|
|
364
|
+
if (appErrorHandler) {
|
|
365
|
+
callWithErrorHandling(
|
|
366
|
+
appErrorHandler,
|
|
367
|
+
null,
|
|
368
|
+
10,
|
|
369
|
+
[err, exposedInstance, errorInfo]
|
|
370
|
+
);
|
|
371
|
+
return;
|
|
385
372
|
}
|
|
386
|
-
|
|
373
|
+
}
|
|
374
|
+
logError(err, type, contextVNode, throwInDev);
|
|
387
375
|
}
|
|
388
376
|
function logError(err, type, contextVNode, throwInDev = true) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
395
|
-
if (contextVNode) {
|
|
396
|
-
popWarningContext();
|
|
397
|
-
}
|
|
398
|
-
// crash in dev by default so it's more noticeable
|
|
399
|
-
if (throwInDev) {
|
|
400
|
-
throw err;
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
console.error(err);
|
|
404
|
-
}
|
|
377
|
+
{
|
|
378
|
+
const info = ErrorTypeStrings[type];
|
|
379
|
+
if (contextVNode) {
|
|
380
|
+
pushWarningContext(contextVNode);
|
|
405
381
|
}
|
|
382
|
+
warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
383
|
+
if (contextVNode) {
|
|
384
|
+
popWarningContext();
|
|
385
|
+
}
|
|
386
|
+
if (throwInDev) {
|
|
387
|
+
throw err;
|
|
388
|
+
} else {
|
|
389
|
+
console.error(err);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
406
392
|
}
|
|
407
393
|
|
|
408
394
|
const classifyRE = /(?:^|[-_])(\w)/g;
|
|
409
|
-
const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g,
|
|
395
|
+
const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
410
396
|
function getComponentName(Component, includeInferred = true) {
|
|
411
|
-
|
|
412
|
-
? Component.displayName || Component.name
|
|
413
|
-
: Component.name || (includeInferred && Component.__name);
|
|
397
|
+
return shared.isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
414
398
|
}
|
|
415
|
-
/* istanbul ignore next */
|
|
416
399
|
function formatComponentName(instance, Component, isRoot = false) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (!name && instance && instance.parent) {
|
|
425
|
-
// try to infer the name based on reverse resolution
|
|
426
|
-
const inferFromRegistry = (registry) => {
|
|
427
|
-
for (const key in registry) {
|
|
428
|
-
if (registry[key] === Component) {
|
|
429
|
-
return key;
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
name =
|
|
434
|
-
inferFromRegistry(instance.components ||
|
|
435
|
-
instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
|
400
|
+
let name = getComponentName(Component);
|
|
401
|
+
if (!name && Component.__file) {
|
|
402
|
+
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
403
|
+
if (match) {
|
|
404
|
+
name = match[1];
|
|
436
405
|
}
|
|
437
|
-
|
|
406
|
+
}
|
|
407
|
+
if (!name && instance && instance.parent) {
|
|
408
|
+
const inferFromRegistry = (registry) => {
|
|
409
|
+
for (const key in registry) {
|
|
410
|
+
if (registry[key] === Component) {
|
|
411
|
+
return key;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
name = inferFromRegistry(
|
|
416
|
+
instance.components || instance.parent.type.components
|
|
417
|
+
) || inferFromRegistry(instance.appContext.components);
|
|
418
|
+
}
|
|
419
|
+
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
438
420
|
}
|
|
439
421
|
|
|
440
422
|
function ssrRenderList(source, renderItem) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
const key = keys[i];
|
|
466
|
-
renderItem(source[key], key, i);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
423
|
+
if (shared.isArray(source) || shared.isString(source)) {
|
|
424
|
+
for (let i = 0, l = source.length; i < l; i++) {
|
|
425
|
+
renderItem(source[i], i);
|
|
426
|
+
}
|
|
427
|
+
} else if (typeof source === "number") {
|
|
428
|
+
if (!Number.isInteger(source)) {
|
|
429
|
+
warn(`The v-for range expect an integer value but got ${source}.`);
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
for (let i = 0; i < source; i++) {
|
|
433
|
+
renderItem(i + 1, i);
|
|
434
|
+
}
|
|
435
|
+
} else if (shared.isObject(source)) {
|
|
436
|
+
if (source[Symbol.iterator]) {
|
|
437
|
+
const arr = Array.from(source);
|
|
438
|
+
for (let i = 0, l = arr.length; i < l; i++) {
|
|
439
|
+
renderItem(arr[i], i);
|
|
440
|
+
}
|
|
441
|
+
} else {
|
|
442
|
+
const keys = Object.keys(source);
|
|
443
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
444
|
+
const key = keys[i];
|
|
445
|
+
renderItem(source[key], key, i);
|
|
446
|
+
}
|
|
469
447
|
}
|
|
448
|
+
}
|
|
470
449
|
}
|
|
471
450
|
|
|
472
451
|
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
}
|
|
452
|
+
if (renderContent) {
|
|
453
|
+
renderContent();
|
|
454
|
+
} else {
|
|
455
|
+
push(`<!---->`);
|
|
456
|
+
}
|
|
479
457
|
}
|
|
480
458
|
|
|
481
459
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
460
|
+
if (typeof dir !== "function" && dir.getSSRProps) {
|
|
461
|
+
return dir.getSSRProps(
|
|
462
|
+
{
|
|
463
|
+
dir,
|
|
464
|
+
instance,
|
|
465
|
+
value,
|
|
466
|
+
oldValue: void 0,
|
|
467
|
+
arg,
|
|
468
|
+
modifiers
|
|
469
|
+
},
|
|
470
|
+
null
|
|
471
|
+
) || {};
|
|
472
|
+
}
|
|
473
|
+
return {};
|
|
493
474
|
}
|
|
494
475
|
|
|
495
476
|
const ssrLooseEqual = shared.looseEqual;
|
|
496
477
|
function ssrLooseContain(arr, value) {
|
|
497
|
-
|
|
478
|
+
return shared.looseIndexOf(arr, value) > -1;
|
|
498
479
|
}
|
|
499
|
-
// for <input :type="type" v-model="model" value="value">
|
|
500
480
|
function ssrRenderDynamicModel(type, model, value) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
// text types
|
|
510
|
-
return ssrRenderAttr('value', model);
|
|
511
|
-
}
|
|
481
|
+
switch (type) {
|
|
482
|
+
case "radio":
|
|
483
|
+
return shared.looseEqual(model, value) ? " checked" : "";
|
|
484
|
+
case "checkbox":
|
|
485
|
+
return (shared.isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
|
|
486
|
+
default:
|
|
487
|
+
return ssrRenderAttr("value", model);
|
|
488
|
+
}
|
|
512
489
|
}
|
|
513
|
-
// for <input v-bind="obj" v-model="model">
|
|
514
490
|
function ssrGetDynamicModelProps(existingProps = {}, model) {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
// text types
|
|
525
|
-
return { value: model };
|
|
526
|
-
}
|
|
491
|
+
const { type, value } = existingProps;
|
|
492
|
+
switch (type) {
|
|
493
|
+
case "radio":
|
|
494
|
+
return shared.looseEqual(model, value) ? { checked: true } : null;
|
|
495
|
+
case "checkbox":
|
|
496
|
+
return (shared.isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
|
|
497
|
+
default:
|
|
498
|
+
return { value: model };
|
|
499
|
+
}
|
|
527
500
|
}
|
|
528
501
|
|
|
529
|
-
// internal runtime helpers
|
|
530
|
-
|
|
531
502
|
var helpers = /*#__PURE__*/Object.freeze({
|
|
532
503
|
__proto__: null,
|
|
533
504
|
ssrGetDirectiveProps: ssrGetDirectiveProps,
|
|
@@ -551,529 +522,530 @@ var helpers = /*#__PURE__*/Object.freeze({
|
|
|
551
522
|
ssrRenderVNode: renderVNode
|
|
552
523
|
});
|
|
553
524
|
|
|
554
|
-
const compileCache = Object.create(null);
|
|
525
|
+
const compileCache = /* @__PURE__ */ Object.create(null);
|
|
555
526
|
function ssrCompile(template, instance) {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
527
|
+
const Component = instance.type;
|
|
528
|
+
const { isCustomElement, compilerOptions } = instance.appContext.config;
|
|
529
|
+
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
|
530
|
+
const finalCompilerOptions = shared.extend(
|
|
531
|
+
shared.extend(
|
|
532
|
+
{
|
|
561
533
|
isCustomElement,
|
|
562
534
|
delimiters
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
535
|
+
},
|
|
536
|
+
compilerOptions
|
|
537
|
+
),
|
|
538
|
+
componentCompilerOptions
|
|
539
|
+
);
|
|
540
|
+
finalCompilerOptions.isCustomElement = finalCompilerOptions.isCustomElement || shared.NO;
|
|
541
|
+
finalCompilerOptions.isNativeTag = finalCompilerOptions.isNativeTag || shared.NO;
|
|
542
|
+
const cacheKey = JSON.stringify(
|
|
543
|
+
{
|
|
544
|
+
template,
|
|
545
|
+
compilerOptions: finalCompilerOptions
|
|
546
|
+
},
|
|
547
|
+
(key, value) => {
|
|
548
|
+
return shared.isFunction(value) ? value.toString() : value;
|
|
549
|
+
}
|
|
550
|
+
);
|
|
551
|
+
const cached = compileCache[cacheKey];
|
|
552
|
+
if (cached) {
|
|
553
|
+
return cached;
|
|
554
|
+
}
|
|
555
|
+
finalCompilerOptions.onError = (err) => {
|
|
556
|
+
{
|
|
557
|
+
const message = `[@vue/server-renderer] Template compilation error: ${err.message}`;
|
|
558
|
+
const codeFrame = err.loc && shared.generateCodeFrame(
|
|
568
559
|
template,
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
};
|
|
585
|
-
const { code } = compilerSsr.compile(template, finalCompilerOptions);
|
|
586
|
-
const requireMap = {
|
|
587
|
-
vue: Vue__namespace,
|
|
588
|
-
'vue/server-renderer': helpers
|
|
589
|
-
};
|
|
590
|
-
const fakeRequire = (id) => requireMap[id];
|
|
591
|
-
return (compileCache[cacheKey] = Function('require', code)(fakeRequire));
|
|
560
|
+
err.loc.start.offset,
|
|
561
|
+
err.loc.end.offset
|
|
562
|
+
);
|
|
563
|
+
Vue.warn(codeFrame ? `${message}
|
|
564
|
+
${codeFrame}` : message);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
const { code } = compilerSsr.compile(template, finalCompilerOptions);
|
|
568
|
+
const requireMap = {
|
|
569
|
+
vue: Vue__namespace,
|
|
570
|
+
"vue/server-renderer": helpers
|
|
571
|
+
};
|
|
572
|
+
const fakeRequire = (id) => requireMap[id];
|
|
573
|
+
return compileCache[cacheKey] = Function("require", code)(fakeRequire);
|
|
592
574
|
}
|
|
593
575
|
|
|
594
|
-
const {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
576
|
+
const {
|
|
577
|
+
createComponentInstance,
|
|
578
|
+
setCurrentRenderingInstance,
|
|
579
|
+
setupComponent,
|
|
580
|
+
renderComponentRoot,
|
|
581
|
+
normalizeVNode
|
|
582
|
+
} = Vue.ssrUtils;
|
|
601
583
|
function createBuffer() {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
buffer.hasAsync = true;
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
};
|
|
584
|
+
let appendable = false;
|
|
585
|
+
const buffer = [];
|
|
586
|
+
return {
|
|
587
|
+
getBuffer() {
|
|
588
|
+
return buffer;
|
|
589
|
+
},
|
|
590
|
+
push(item) {
|
|
591
|
+
const isStringItem = shared.isString(item);
|
|
592
|
+
if (appendable && isStringItem) {
|
|
593
|
+
buffer[buffer.length - 1] += item;
|
|
594
|
+
} else {
|
|
595
|
+
buffer.push(item);
|
|
596
|
+
}
|
|
597
|
+
appendable = isStringItem;
|
|
598
|
+
if (shared.isPromise(item) || shared.isArray(item) && item.hasAsync) {
|
|
599
|
+
buffer.hasAsync = true;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
};
|
|
625
603
|
}
|
|
626
604
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
605
|
+
const instance = createComponentInstance(vnode, parentComponent, null);
|
|
606
|
+
const res = setupComponent(
|
|
607
|
+
instance,
|
|
608
|
+
true
|
|
609
|
+
/* isSSR */
|
|
610
|
+
);
|
|
611
|
+
const hasAsyncSetup = shared.isPromise(res);
|
|
612
|
+
const prefetches = instance.sp;
|
|
613
|
+
if (hasAsyncSetup || prefetches) {
|
|
614
|
+
let p = hasAsyncSetup ? res : Promise.resolve();
|
|
615
|
+
if (prefetches) {
|
|
616
|
+
p = p.then(
|
|
617
|
+
() => Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)))
|
|
618
|
+
).catch(() => {
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
return p.then(() => renderComponentSubTree(instance, slotScopeId));
|
|
622
|
+
} else {
|
|
623
|
+
return renderComponentSubTree(instance, slotScopeId);
|
|
624
|
+
}
|
|
646
625
|
}
|
|
647
626
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (
|
|
655
|
-
|
|
656
|
-
if (key.startsWith(`data-v-`)) {
|
|
657
|
-
(root.props || (root.props = {}))[key] = ``;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
renderVNode(push, (instance.subTree = root), instance, slotScopeId);
|
|
662
|
-
}
|
|
663
|
-
else {
|
|
664
|
-
if ((!instance.render || instance.render === shared.NOOP) &&
|
|
665
|
-
!instance.ssrRender &&
|
|
666
|
-
!comp.ssrRender &&
|
|
667
|
-
shared.isString(comp.template)) {
|
|
668
|
-
comp.ssrRender = ssrCompile(comp.template, instance);
|
|
627
|
+
const comp = instance.type;
|
|
628
|
+
const { getBuffer, push } = createBuffer();
|
|
629
|
+
if (shared.isFunction(comp)) {
|
|
630
|
+
let root = renderComponentRoot(instance);
|
|
631
|
+
if (!comp.props) {
|
|
632
|
+
for (const key in instance.attrs) {
|
|
633
|
+
if (key.startsWith(`data-v-`)) {
|
|
634
|
+
(root.props || (root.props = {}))[key] = ``;
|
|
669
635
|
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
renderVNode(push, instance.subTree = root, instance, slotScopeId);
|
|
639
|
+
} else {
|
|
640
|
+
if ((!instance.render || instance.render === shared.NOOP) && !instance.ssrRender && !comp.ssrRender && shared.isString(comp.template)) {
|
|
641
|
+
comp.ssrRender = ssrCompile(comp.template, instance);
|
|
642
|
+
}
|
|
643
|
+
for (const e of instance.scope.effects) {
|
|
644
|
+
if (e.computed)
|
|
645
|
+
e.computed._cacheable = true;
|
|
646
|
+
}
|
|
647
|
+
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
648
|
+
if (ssrRender) {
|
|
649
|
+
let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|
|
650
|
+
let hasCloned = false;
|
|
651
|
+
let cur = instance;
|
|
652
|
+
while (true) {
|
|
653
|
+
const scopeId = cur.vnode.scopeId;
|
|
654
|
+
if (scopeId) {
|
|
655
|
+
if (!hasCloned) {
|
|
656
|
+
attrs = { ...attrs };
|
|
657
|
+
hasCloned = true;
|
|
658
|
+
}
|
|
659
|
+
attrs[scopeId] = "";
|
|
675
660
|
}
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
let hasCloned = false;
|
|
682
|
-
let cur = instance;
|
|
683
|
-
while (true) {
|
|
684
|
-
const scopeId = cur.vnode.scopeId;
|
|
685
|
-
if (scopeId) {
|
|
686
|
-
if (!hasCloned) {
|
|
687
|
-
attrs = { ...attrs };
|
|
688
|
-
hasCloned = true;
|
|
689
|
-
}
|
|
690
|
-
attrs[scopeId] = '';
|
|
691
|
-
}
|
|
692
|
-
const parent = cur.parent;
|
|
693
|
-
if (parent && parent.subTree && parent.subTree === cur.vnode) {
|
|
694
|
-
// parent is a non-SSR compiled component and is rendering this
|
|
695
|
-
// component as root. inherit its scopeId if present.
|
|
696
|
-
cur = parent;
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
break;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
if (slotScopeId) {
|
|
703
|
-
if (!hasCloned)
|
|
704
|
-
attrs = { ...attrs };
|
|
705
|
-
attrs[slotScopeId.trim()] = '';
|
|
706
|
-
}
|
|
707
|
-
// set current rendering instance for asset resolution
|
|
708
|
-
const prev = setCurrentRenderingInstance(instance);
|
|
709
|
-
try {
|
|
710
|
-
ssrRender(instance.proxy, push, instance, attrs,
|
|
711
|
-
// compiler-optimized bindings
|
|
712
|
-
instance.props, instance.setupState, instance.data, instance.ctx);
|
|
713
|
-
}
|
|
714
|
-
finally {
|
|
715
|
-
setCurrentRenderingInstance(prev);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
else if (instance.render && instance.render !== shared.NOOP) {
|
|
719
|
-
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId);
|
|
720
|
-
}
|
|
721
|
-
else {
|
|
722
|
-
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
723
|
-
Vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
724
|
-
push(`<!---->`);
|
|
661
|
+
const parent = cur.parent;
|
|
662
|
+
if (parent && parent.subTree && parent.subTree === cur.vnode) {
|
|
663
|
+
cur = parent;
|
|
664
|
+
} else {
|
|
665
|
+
break;
|
|
725
666
|
}
|
|
667
|
+
}
|
|
668
|
+
if (slotScopeId) {
|
|
669
|
+
if (!hasCloned)
|
|
670
|
+
attrs = { ...attrs };
|
|
671
|
+
attrs[slotScopeId.trim()] = "";
|
|
672
|
+
}
|
|
673
|
+
const prev = setCurrentRenderingInstance(instance);
|
|
674
|
+
try {
|
|
675
|
+
ssrRender(
|
|
676
|
+
instance.proxy,
|
|
677
|
+
push,
|
|
678
|
+
instance,
|
|
679
|
+
attrs,
|
|
680
|
+
// compiler-optimized bindings
|
|
681
|
+
instance.props,
|
|
682
|
+
instance.setupState,
|
|
683
|
+
instance.data,
|
|
684
|
+
instance.ctx
|
|
685
|
+
);
|
|
686
|
+
} finally {
|
|
687
|
+
setCurrentRenderingInstance(prev);
|
|
688
|
+
}
|
|
689
|
+
} else if (instance.render && instance.render !== shared.NOOP) {
|
|
690
|
+
renderVNode(
|
|
691
|
+
push,
|
|
692
|
+
instance.subTree = renderComponentRoot(instance),
|
|
693
|
+
instance,
|
|
694
|
+
slotScopeId
|
|
695
|
+
);
|
|
696
|
+
} else {
|
|
697
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
698
|
+
Vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
699
|
+
push(`<!---->`);
|
|
726
700
|
}
|
|
727
|
-
|
|
701
|
+
}
|
|
702
|
+
return getBuffer();
|
|
728
703
|
}
|
|
729
704
|
function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
705
|
+
const { type, shapeFlag, children } = vnode;
|
|
706
|
+
switch (type) {
|
|
707
|
+
case Vue.Text:
|
|
708
|
+
push(shared.escapeHtml(children));
|
|
709
|
+
break;
|
|
710
|
+
case Vue.Comment:
|
|
711
|
+
push(
|
|
712
|
+
children ? `<!--${shared.escapeHtmlComment(children)}-->` : `<!---->`
|
|
713
|
+
);
|
|
714
|
+
break;
|
|
715
|
+
case Vue.Static:
|
|
716
|
+
push(children);
|
|
717
|
+
break;
|
|
718
|
+
case Vue.Fragment:
|
|
719
|
+
if (vnode.slotScopeIds) {
|
|
720
|
+
slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
721
|
+
}
|
|
722
|
+
push(`<!--[-->`);
|
|
723
|
+
renderVNodeChildren(
|
|
724
|
+
push,
|
|
725
|
+
children,
|
|
726
|
+
parentComponent,
|
|
727
|
+
slotScopeId
|
|
728
|
+
);
|
|
729
|
+
push(`<!--]-->`);
|
|
730
|
+
break;
|
|
731
|
+
default:
|
|
732
|
+
if (shapeFlag & 1) {
|
|
733
|
+
renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
734
|
+
} else if (shapeFlag & 6) {
|
|
735
|
+
push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
736
|
+
} else if (shapeFlag & 64) {
|
|
737
|
+
renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
738
|
+
} else if (shapeFlag & 128) {
|
|
739
|
+
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
740
|
+
} else {
|
|
741
|
+
Vue.warn(
|
|
742
|
+
"[@vue/server-renderer] Invalid VNode type:",
|
|
743
|
+
type,
|
|
744
|
+
`(${typeof type})`
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
767
748
|
}
|
|
768
749
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
750
|
+
for (let i = 0; i < children.length; i++) {
|
|
751
|
+
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
752
|
+
}
|
|
772
753
|
}
|
|
773
754
|
function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
755
|
+
const tag = vnode.type;
|
|
756
|
+
let { props, children, shapeFlag, scopeId, dirs } = vnode;
|
|
757
|
+
let openTag = `<${tag}`;
|
|
758
|
+
if (dirs) {
|
|
759
|
+
props = applySSRDirectives(vnode, props, dirs);
|
|
760
|
+
}
|
|
761
|
+
if (props) {
|
|
762
|
+
openTag += ssrRenderAttrs(props, tag);
|
|
763
|
+
}
|
|
764
|
+
if (scopeId) {
|
|
765
|
+
openTag += ` ${scopeId}`;
|
|
766
|
+
}
|
|
767
|
+
let curParent = parentComponent;
|
|
768
|
+
let curVnode = vnode;
|
|
769
|
+
while (curParent && curVnode === curParent.subTree) {
|
|
770
|
+
curVnode = curParent.vnode;
|
|
771
|
+
if (curVnode.scopeId) {
|
|
772
|
+
openTag += ` ${curVnode.scopeId}`;
|
|
773
|
+
}
|
|
774
|
+
curParent = curParent.parent;
|
|
775
|
+
}
|
|
776
|
+
if (slotScopeId) {
|
|
777
|
+
openTag += ` ${slotScopeId}`;
|
|
778
|
+
}
|
|
779
|
+
push(openTag + `>`);
|
|
780
|
+
if (!shared.isVoidTag(tag)) {
|
|
781
|
+
let hasChildrenOverride = false;
|
|
780
782
|
if (props) {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
else if (props.textContent) {
|
|
808
|
-
hasChildrenOverride = true;
|
|
809
|
-
push(shared.escapeHtml(props.textContent));
|
|
810
|
-
}
|
|
811
|
-
else if (tag === 'textarea' && props.value) {
|
|
812
|
-
hasChildrenOverride = true;
|
|
813
|
-
push(shared.escapeHtml(props.value));
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
if (!hasChildrenOverride) {
|
|
817
|
-
if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
|
|
818
|
-
push(shared.escapeHtml(children));
|
|
819
|
-
}
|
|
820
|
-
else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
|
|
821
|
-
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
push(`</${tag}>`);
|
|
825
|
-
}
|
|
783
|
+
if (props.innerHTML) {
|
|
784
|
+
hasChildrenOverride = true;
|
|
785
|
+
push(props.innerHTML);
|
|
786
|
+
} else if (props.textContent) {
|
|
787
|
+
hasChildrenOverride = true;
|
|
788
|
+
push(shared.escapeHtml(props.textContent));
|
|
789
|
+
} else if (tag === "textarea" && props.value) {
|
|
790
|
+
hasChildrenOverride = true;
|
|
791
|
+
push(shared.escapeHtml(props.value));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
if (!hasChildrenOverride) {
|
|
795
|
+
if (shapeFlag & 8) {
|
|
796
|
+
push(shared.escapeHtml(children));
|
|
797
|
+
} else if (shapeFlag & 16) {
|
|
798
|
+
renderVNodeChildren(
|
|
799
|
+
push,
|
|
800
|
+
children,
|
|
801
|
+
parentComponent,
|
|
802
|
+
slotScopeId
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
push(`</${tag}>`);
|
|
807
|
+
}
|
|
826
808
|
}
|
|
827
809
|
function applySSRDirectives(vnode, rawProps, dirs) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
810
|
+
const toMerge = [];
|
|
811
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
812
|
+
const binding = dirs[i];
|
|
813
|
+
const {
|
|
814
|
+
dir: { getSSRProps }
|
|
815
|
+
} = binding;
|
|
816
|
+
if (getSSRProps) {
|
|
817
|
+
const props = getSSRProps(binding, vnode);
|
|
818
|
+
if (props)
|
|
819
|
+
toMerge.push(props);
|
|
837
820
|
}
|
|
838
|
-
|
|
821
|
+
}
|
|
822
|
+
return Vue.mergeProps(rawProps || {}, ...toMerge);
|
|
839
823
|
}
|
|
840
824
|
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
}
|
|
847
|
-
return [];
|
|
848
|
-
}
|
|
849
|
-
if (!shared.isString(target)) {
|
|
850
|
-
Vue.warn(`[@vue/server-renderer] Teleport target must be a query selector string.`);
|
|
851
|
-
return [];
|
|
825
|
+
const target = vnode.props && vnode.props.to;
|
|
826
|
+
const disabled = vnode.props && vnode.props.disabled;
|
|
827
|
+
if (!target) {
|
|
828
|
+
if (!disabled) {
|
|
829
|
+
Vue.warn(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
852
830
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
831
|
+
return [];
|
|
832
|
+
}
|
|
833
|
+
if (!shared.isString(target)) {
|
|
834
|
+
Vue.warn(
|
|
835
|
+
`[@vue/server-renderer] Teleport target must be a query selector string.`
|
|
836
|
+
);
|
|
837
|
+
return [];
|
|
838
|
+
}
|
|
839
|
+
ssrRenderTeleport(
|
|
840
|
+
push,
|
|
841
|
+
(push2) => {
|
|
842
|
+
renderVNodeChildren(
|
|
843
|
+
push2,
|
|
844
|
+
vnode.children,
|
|
845
|
+
parentComponent,
|
|
846
|
+
slotScopeId
|
|
847
|
+
);
|
|
848
|
+
},
|
|
849
|
+
target,
|
|
850
|
+
disabled || disabled === "",
|
|
851
|
+
parentComponent
|
|
852
|
+
);
|
|
856
853
|
}
|
|
857
854
|
|
|
858
855
|
const { isVNode: isVNode$1 } = Vue.ssrUtils;
|
|
859
856
|
async function unrollBuffer$1(buffer) {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
return ret;
|
|
875
|
-
}
|
|
876
|
-
else {
|
|
877
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
878
|
-
// ticks
|
|
879
|
-
return unrollBufferSync$1(buffer);
|
|
857
|
+
if (buffer.hasAsync) {
|
|
858
|
+
let ret = "";
|
|
859
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
860
|
+
let item = buffer[i];
|
|
861
|
+
if (shared.isPromise(item)) {
|
|
862
|
+
item = await item;
|
|
863
|
+
}
|
|
864
|
+
if (shared.isString(item)) {
|
|
865
|
+
ret += item;
|
|
866
|
+
} else {
|
|
867
|
+
ret += await unrollBuffer$1(item);
|
|
868
|
+
}
|
|
880
869
|
}
|
|
870
|
+
return ret;
|
|
871
|
+
} else {
|
|
872
|
+
return unrollBufferSync$1(buffer);
|
|
873
|
+
}
|
|
881
874
|
}
|
|
882
875
|
function unrollBufferSync$1(buffer) {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
// since this is a sync buffer, child buffers are never promises
|
|
891
|
-
ret += unrollBufferSync$1(item);
|
|
892
|
-
}
|
|
876
|
+
let ret = "";
|
|
877
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
878
|
+
let item = buffer[i];
|
|
879
|
+
if (shared.isString(item)) {
|
|
880
|
+
ret += item;
|
|
881
|
+
} else {
|
|
882
|
+
ret += unrollBufferSync$1(item);
|
|
893
883
|
}
|
|
894
|
-
|
|
884
|
+
}
|
|
885
|
+
return ret;
|
|
895
886
|
}
|
|
896
887
|
async function renderToString(input, context = {}) {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
if (context.__watcherHandles) {
|
|
910
|
-
for (const unwatch of context.__watcherHandles) {
|
|
911
|
-
unwatch();
|
|
912
|
-
}
|
|
888
|
+
if (isVNode$1(input)) {
|
|
889
|
+
return renderToString(Vue.createApp({ render: () => input }), context);
|
|
890
|
+
}
|
|
891
|
+
const vnode = Vue.createVNode(input._component, input._props);
|
|
892
|
+
vnode.appContext = input._context;
|
|
893
|
+
input.provide(Vue.ssrContextKey, context);
|
|
894
|
+
const buffer = await renderComponentVNode(vnode);
|
|
895
|
+
const result = await unrollBuffer$1(buffer);
|
|
896
|
+
await resolveTeleports(context);
|
|
897
|
+
if (context.__watcherHandles) {
|
|
898
|
+
for (const unwatch of context.__watcherHandles) {
|
|
899
|
+
unwatch();
|
|
913
900
|
}
|
|
914
|
-
|
|
901
|
+
}
|
|
902
|
+
return result;
|
|
915
903
|
}
|
|
916
904
|
async function resolveTeleports(context) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
905
|
+
if (context.__teleportBuffers) {
|
|
906
|
+
context.teleports = context.teleports || {};
|
|
907
|
+
for (const key in context.__teleportBuffers) {
|
|
908
|
+
context.teleports[key] = await unrollBuffer$1(
|
|
909
|
+
await Promise.all([context.__teleportBuffers[key]])
|
|
910
|
+
);
|
|
924
911
|
}
|
|
912
|
+
}
|
|
925
913
|
}
|
|
926
914
|
|
|
927
915
|
const { isVNode } = Vue.ssrUtils;
|
|
928
916
|
async function unrollBuffer(buffer, stream) {
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
945
|
-
// ticks
|
|
946
|
-
unrollBufferSync(buffer, stream);
|
|
947
|
-
}
|
|
917
|
+
if (buffer.hasAsync) {
|
|
918
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
919
|
+
let item = buffer[i];
|
|
920
|
+
if (shared.isPromise(item)) {
|
|
921
|
+
item = await item;
|
|
922
|
+
}
|
|
923
|
+
if (shared.isString(item)) {
|
|
924
|
+
stream.push(item);
|
|
925
|
+
} else {
|
|
926
|
+
await unrollBuffer(item, stream);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
} else {
|
|
930
|
+
unrollBufferSync(buffer, stream);
|
|
931
|
+
}
|
|
948
932
|
}
|
|
949
933
|
function unrollBufferSync(buffer, stream) {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
// since this is a sync buffer, child buffers are never promises
|
|
957
|
-
unrollBufferSync(item, stream);
|
|
958
|
-
}
|
|
934
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
935
|
+
let item = buffer[i];
|
|
936
|
+
if (shared.isString(item)) {
|
|
937
|
+
stream.push(item);
|
|
938
|
+
} else {
|
|
939
|
+
unrollBufferSync(item, stream);
|
|
959
940
|
}
|
|
941
|
+
}
|
|
960
942
|
}
|
|
961
943
|
function renderToSimpleStream(input, context, stream) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
.catch(error => {
|
|
983
|
-
stream.destroy(error);
|
|
984
|
-
});
|
|
985
|
-
return stream;
|
|
944
|
+
if (isVNode(input)) {
|
|
945
|
+
return renderToSimpleStream(
|
|
946
|
+
Vue.createApp({ render: () => input }),
|
|
947
|
+
context,
|
|
948
|
+
stream
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
const vnode = Vue.createVNode(input._component, input._props);
|
|
952
|
+
vnode.appContext = input._context;
|
|
953
|
+
input.provide(Vue.ssrContextKey, context);
|
|
954
|
+
Promise.resolve(renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
|
955
|
+
if (context.__watcherHandles) {
|
|
956
|
+
for (const unwatch of context.__watcherHandles) {
|
|
957
|
+
unwatch();
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}).then(() => stream.push(null)).catch((error) => {
|
|
961
|
+
stream.destroy(error);
|
|
962
|
+
});
|
|
963
|
+
return stream;
|
|
986
964
|
}
|
|
987
|
-
/**
|
|
988
|
-
* @deprecated
|
|
989
|
-
*/
|
|
990
965
|
function renderToStream(input, context = {}) {
|
|
991
|
-
|
|
992
|
-
|
|
966
|
+
console.warn(
|
|
967
|
+
`[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`
|
|
968
|
+
);
|
|
969
|
+
return renderToNodeStream(input, context);
|
|
993
970
|
}
|
|
994
971
|
function renderToNodeStream(input, context = {}) {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
972
|
+
const stream = new (require("stream")).Readable({ read() {
|
|
973
|
+
} }) ;
|
|
974
|
+
if (!stream) {
|
|
975
|
+
throw new Error(
|
|
976
|
+
`ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
return renderToSimpleStream(input, context, stream);
|
|
1003
980
|
}
|
|
1004
981
|
function pipeToNodeWritable(input, context = {}, writable) {
|
|
1005
|
-
|
|
982
|
+
renderToSimpleStream(input, context, {
|
|
983
|
+
push(content) {
|
|
984
|
+
if (content != null) {
|
|
985
|
+
writable.write(content);
|
|
986
|
+
} else {
|
|
987
|
+
writable.end();
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
destroy(err) {
|
|
991
|
+
writable.destroy(err);
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
function renderToWebStream(input, context = {}) {
|
|
996
|
+
if (typeof ReadableStream !== "function") {
|
|
997
|
+
throw new Error(
|
|
998
|
+
`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.`
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
const encoder = new TextEncoder();
|
|
1002
|
+
let cancelled = false;
|
|
1003
|
+
return new ReadableStream({
|
|
1004
|
+
start(controller) {
|
|
1005
|
+
renderToSimpleStream(input, context, {
|
|
1006
1006
|
push(content) {
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1007
|
+
if (cancelled)
|
|
1008
|
+
return;
|
|
1009
|
+
if (content != null) {
|
|
1010
|
+
controller.enqueue(encoder.encode(content));
|
|
1011
|
+
} else {
|
|
1012
|
+
controller.close();
|
|
1013
|
+
}
|
|
1013
1014
|
},
|
|
1014
1015
|
destroy(err) {
|
|
1015
|
-
|
|
1016
|
+
controller.error(err);
|
|
1016
1017
|
}
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
throw new Error(`ReadableStream constructor is not available in the global scope. ` +
|
|
1022
|
-
`If the target environment does support web streams, consider using ` +
|
|
1023
|
-
`pipeToWebWritable() with an existing WritableStream instance instead.`);
|
|
1018
|
+
});
|
|
1019
|
+
},
|
|
1020
|
+
cancel() {
|
|
1021
|
+
cancelled = true;
|
|
1024
1022
|
}
|
|
1025
|
-
|
|
1026
|
-
let cancelled = false;
|
|
1027
|
-
return new ReadableStream({
|
|
1028
|
-
start(controller) {
|
|
1029
|
-
renderToSimpleStream(input, context, {
|
|
1030
|
-
push(content) {
|
|
1031
|
-
if (cancelled)
|
|
1032
|
-
return;
|
|
1033
|
-
if (content != null) {
|
|
1034
|
-
controller.enqueue(encoder.encode(content));
|
|
1035
|
-
}
|
|
1036
|
-
else {
|
|
1037
|
-
controller.close();
|
|
1038
|
-
}
|
|
1039
|
-
},
|
|
1040
|
-
destroy(err) {
|
|
1041
|
-
controller.error(err);
|
|
1042
|
-
}
|
|
1043
|
-
});
|
|
1044
|
-
},
|
|
1045
|
-
cancel() {
|
|
1046
|
-
cancelled = true;
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1023
|
+
});
|
|
1049
1024
|
}
|
|
1050
1025
|
function pipeToWebWritable(input, context = {}, writable) {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
writer.close();
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
1026
|
+
const writer = writable.getWriter();
|
|
1027
|
+
const encoder = new TextEncoder();
|
|
1028
|
+
let hasReady = false;
|
|
1029
|
+
try {
|
|
1030
|
+
hasReady = shared.isPromise(writer.ready);
|
|
1031
|
+
} catch (e) {
|
|
1032
|
+
}
|
|
1033
|
+
renderToSimpleStream(input, context, {
|
|
1034
|
+
async push(content) {
|
|
1035
|
+
if (hasReady) {
|
|
1036
|
+
await writer.ready;
|
|
1037
|
+
}
|
|
1038
|
+
if (content != null) {
|
|
1039
|
+
return writer.write(encoder.encode(content));
|
|
1040
|
+
} else {
|
|
1041
|
+
return writer.close();
|
|
1042
|
+
}
|
|
1043
|
+
},
|
|
1044
|
+
destroy(err) {
|
|
1045
|
+
console.log(err);
|
|
1046
|
+
writer.close();
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1077
1049
|
}
|
|
1078
1050
|
|
|
1079
1051
|
Vue.initDirectivesForSSR();
|