@vue/server-renderer 3.2.47 → 3.3.0-alpha.10
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 +844 -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 +6830 -7393
- package/dist/server-renderer.esm-browser.prod.js +1 -1
- package/dist/server-renderer.esm-bundler.js +821 -853
- package/package.json +4 -4
|
@@ -1,1011 +1,979 @@
|
|
|
1
1
|
import { createVNode, ssrContextKey, warn as warn$1, Fragment, Static, Comment, Text, mergeProps, ssrUtils, createApp, initDirectivesForSSR } from 'vue';
|
|
2
|
-
import { makeMap, isOn, isSVGTag, propsToAttrMap, isBooleanAttr, includeBooleanAttr, isSSRSafeAttrName, escapeHtml, normalizeClass, isString, normalizeStyle, stringifyStyle, isArray, toDisplayString, isFunction, isObject, looseEqual, looseIndexOf, isPromise, NOOP, escapeHtmlComment, isVoidTag } from '@vue/shared';
|
|
2
|
+
import { makeMap, isOn, isSVGTag, propsToAttrMap, isBooleanAttr, includeBooleanAttr, isSSRSafeAttrName, escapeHtml, normalizeClass, isString, normalizeStyle, stringifyStyle, isArray, toDisplayString, isFunction, getGlobalThis, isObject, looseEqual, looseIndexOf, isPromise, NOOP, escapeHtmlComment, isVoidTag } from '@vue/shared';
|
|
3
3
|
export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const shouldIgnoreProp = makeMap(
|
|
6
|
+
`,key,ref,innerHTML,textContent,ref_key,ref_for`
|
|
7
|
+
);
|
|
7
8
|
function ssrRenderAttrs(props, tag) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
ret += ssrRenderDynamicAttr(key, value, tag);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return ret;
|
|
9
|
+
let ret = "";
|
|
10
|
+
for (const key in props) {
|
|
11
|
+
if (shouldIgnoreProp(key) || isOn(key) || tag === "textarea" && key === "value") {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const value = props[key];
|
|
15
|
+
if (key === "class") {
|
|
16
|
+
ret += ` class="${ssrRenderClass(value)}"`;
|
|
17
|
+
} else if (key === "style") {
|
|
18
|
+
ret += ` style="${ssrRenderStyle(value)}"`;
|
|
19
|
+
} else {
|
|
20
|
+
ret += ssrRenderDynamicAttr(key, value, tag);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ret;
|
|
27
24
|
}
|
|
28
|
-
// render an attr with dynamic (unknown) key.
|
|
29
25
|
function ssrRenderDynamicAttr(key, value, tag) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return ``;
|
|
45
|
-
}
|
|
26
|
+
if (!isRenderableValue(value)) {
|
|
27
|
+
return ``;
|
|
28
|
+
}
|
|
29
|
+
const attrKey = tag && (tag.indexOf("-") > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase();
|
|
30
|
+
if (isBooleanAttr(attrKey)) {
|
|
31
|
+
return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
|
|
32
|
+
} else if (isSSRSafeAttrName(attrKey)) {
|
|
33
|
+
return value === "" ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`;
|
|
34
|
+
} else {
|
|
35
|
+
console.warn(
|
|
36
|
+
`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
|
|
37
|
+
);
|
|
38
|
+
return ``;
|
|
39
|
+
}
|
|
46
40
|
}
|
|
47
|
-
// Render a v-bind attr with static key. The key is pre-processed at compile
|
|
48
|
-
// time and we only need to check and escape value.
|
|
49
41
|
function ssrRenderAttr(key, value) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
if (!isRenderableValue(value)) {
|
|
43
|
+
return ``;
|
|
44
|
+
}
|
|
45
|
+
return ` ${key}="${escapeHtml(value)}"`;
|
|
54
46
|
}
|
|
55
47
|
function isRenderableValue(value) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
if (value == null) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const type = typeof value;
|
|
52
|
+
return type === "string" || type === "number" || type === "boolean";
|
|
61
53
|
}
|
|
62
54
|
function ssrRenderClass(raw) {
|
|
63
|
-
|
|
55
|
+
return escapeHtml(normalizeClass(raw));
|
|
64
56
|
}
|
|
65
57
|
function ssrRenderStyle(raw) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
if (!raw) {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
if (isString(raw)) {
|
|
62
|
+
return escapeHtml(raw);
|
|
63
|
+
}
|
|
64
|
+
const styles = normalizeStyle(raw);
|
|
65
|
+
return escapeHtml(stringifyStyle(styles));
|
|
74
66
|
}
|
|
75
67
|
|
|
76
68
|
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
77
|
-
|
|
69
|
+
return renderComponentVNode(
|
|
70
|
+
createVNode(comp, props, children),
|
|
71
|
+
parentComponent,
|
|
72
|
+
slotScopeId
|
|
73
|
+
);
|
|
78
74
|
}
|
|
79
75
|
|
|
80
76
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
push(`<!--[-->`);
|
|
78
|
+
ssrRenderSlotInner(
|
|
79
|
+
slots,
|
|
80
|
+
slotName,
|
|
81
|
+
slotProps,
|
|
82
|
+
fallbackRenderFn,
|
|
83
|
+
push,
|
|
84
|
+
parentComponent,
|
|
85
|
+
slotScopeId
|
|
86
|
+
);
|
|
87
|
+
push(`<!--]-->`);
|
|
85
88
|
}
|
|
86
89
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
const slotFn = slots[slotName];
|
|
91
|
+
if (slotFn) {
|
|
92
|
+
const slotBuffer = [];
|
|
93
|
+
const bufferedPush = (item) => {
|
|
94
|
+
slotBuffer.push(item);
|
|
95
|
+
};
|
|
96
|
+
const ret = slotFn(
|
|
97
|
+
slotProps,
|
|
98
|
+
bufferedPush,
|
|
99
|
+
parentComponent,
|
|
100
|
+
slotScopeId ? " " + slotScopeId : ""
|
|
101
|
+
);
|
|
102
|
+
if (isArray(ret)) {
|
|
103
|
+
renderVNodeChildren(push, ret, parentComponent, slotScopeId);
|
|
104
|
+
} else {
|
|
105
|
+
let isEmptySlot = true;
|
|
106
|
+
if (transition) {
|
|
107
|
+
isEmptySlot = false;
|
|
108
|
+
} else {
|
|
109
|
+
for (let i = 0; i < slotBuffer.length; i++) {
|
|
110
|
+
if (!isComment(slotBuffer[i])) {
|
|
111
|
+
isEmptySlot = false;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
97
114
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (transition) {
|
|
103
|
-
isEmptySlot = false;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
for (let i = 0; i < slotBuffer.length; i++) {
|
|
107
|
-
if (!isComment(slotBuffer[i])) {
|
|
108
|
-
isEmptySlot = false;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (isEmptySlot) {
|
|
114
|
-
if (fallbackRenderFn) {
|
|
115
|
-
fallbackRenderFn();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
for (let i = 0; i < slotBuffer.length; i++) {
|
|
120
|
-
push(slotBuffer[i]);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
115
|
+
}
|
|
116
|
+
if (isEmptySlot) {
|
|
117
|
+
if (fallbackRenderFn) {
|
|
118
|
+
fallbackRenderFn();
|
|
123
119
|
}
|
|
120
|
+
} else {
|
|
121
|
+
for (let i = 0; i < slotBuffer.length; i++) {
|
|
122
|
+
push(slotBuffer[i]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
124
125
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
} else if (fallbackRenderFn) {
|
|
127
|
+
fallbackRenderFn();
|
|
128
|
+
}
|
|
128
129
|
}
|
|
129
130
|
const commentTestRE = /^<!--.*-->$/s;
|
|
130
131
|
const commentRE = /<!--[^]*?-->/gm;
|
|
131
132
|
function isComment(item) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return !item.replace(commentRE, '').trim();
|
|
133
|
+
if (typeof item !== "string" || !commentTestRE.test(item))
|
|
134
|
+
return false;
|
|
135
|
+
if (item.length <= 8)
|
|
136
|
+
return true;
|
|
137
|
+
return !item.replace(commentRE, "").trim();
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
160
|
-
parentPush('<!--teleport end-->');
|
|
141
|
+
parentPush("<!--teleport start-->");
|
|
142
|
+
const context = parentComponent.appContext.provides[ssrContextKey];
|
|
143
|
+
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
144
|
+
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
145
|
+
const bufferIndex = targetBuffer.length;
|
|
146
|
+
let teleportContent;
|
|
147
|
+
if (disabled) {
|
|
148
|
+
contentRenderFn(parentPush);
|
|
149
|
+
teleportContent = `<!--teleport anchor-->`;
|
|
150
|
+
} else {
|
|
151
|
+
const { getBuffer, push } = createBuffer();
|
|
152
|
+
contentRenderFn(push);
|
|
153
|
+
push(`<!--teleport anchor-->`);
|
|
154
|
+
teleportContent = getBuffer();
|
|
155
|
+
}
|
|
156
|
+
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
157
|
+
parentPush("<!--teleport end-->");
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
function ssrInterpolate(value) {
|
|
164
|
-
|
|
161
|
+
return escapeHtml(toDisplayString(value));
|
|
165
162
|
}
|
|
166
163
|
|
|
167
|
-
Symbol(
|
|
168
|
-
Symbol(
|
|
164
|
+
Symbol(process.env.NODE_ENV !== "production" ? "iterate" : "");
|
|
165
|
+
Symbol(process.env.NODE_ENV !== "production" ? "Map key iterate" : "");
|
|
169
166
|
let shouldTrack = true;
|
|
170
167
|
const trackStack = [];
|
|
171
168
|
function pauseTracking() {
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
trackStack.push(shouldTrack);
|
|
170
|
+
shouldTrack = false;
|
|
174
171
|
}
|
|
175
172
|
function resetTracking() {
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
const last = trackStack.pop();
|
|
174
|
+
shouldTrack = last === void 0 ? true : last;
|
|
178
175
|
}
|
|
179
176
|
|
|
180
177
|
function toRaw(observed) {
|
|
181
|
-
|
|
182
|
-
|
|
178
|
+
const raw = observed && observed["__v_raw"];
|
|
179
|
+
return raw ? toRaw(raw) : observed;
|
|
183
180
|
}
|
|
184
181
|
|
|
185
182
|
function isRef(r) {
|
|
186
|
-
|
|
183
|
+
return !!(r && r.__v_isRef === true);
|
|
187
184
|
}
|
|
188
185
|
|
|
189
186
|
const stack = [];
|
|
190
187
|
function pushWarningContext(vnode) {
|
|
191
|
-
|
|
188
|
+
stack.push(vnode);
|
|
192
189
|
}
|
|
193
190
|
function popWarningContext() {
|
|
194
|
-
|
|
191
|
+
stack.pop();
|
|
195
192
|
}
|
|
196
193
|
function warn(msg, ...args) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
194
|
+
if (!process.env.NODE_ENV !== "production")
|
|
195
|
+
return;
|
|
196
|
+
pauseTracking();
|
|
197
|
+
const instance = stack.length ? stack[stack.length - 1].component : null;
|
|
198
|
+
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
199
|
+
const trace = getComponentTrace();
|
|
200
|
+
if (appWarnHandler) {
|
|
201
|
+
callWithErrorHandling(
|
|
202
|
+
appWarnHandler,
|
|
203
|
+
instance,
|
|
204
|
+
11,
|
|
205
|
+
[
|
|
206
|
+
msg + args.join(""),
|
|
207
|
+
instance && instance.proxy,
|
|
208
|
+
trace.map(
|
|
209
|
+
({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
|
210
|
+
).join("\n"),
|
|
211
|
+
trace
|
|
212
|
+
]
|
|
213
|
+
);
|
|
214
|
+
} else {
|
|
215
|
+
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
216
|
+
if (trace.length && // avoid spamming console during tests
|
|
217
|
+
true) {
|
|
218
|
+
warnArgs.push(`
|
|
219
|
+
`, ...formatTrace(trace));
|
|
220
|
+
}
|
|
221
|
+
console.warn(...warnArgs);
|
|
222
|
+
}
|
|
223
|
+
resetTracking();
|
|
226
224
|
}
|
|
227
225
|
function getComponentTrace() {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
248
|
-
currentVNode = parentInstance && parentInstance.vnode;
|
|
249
|
-
}
|
|
250
|
-
return normalizedStack;
|
|
226
|
+
let currentVNode = stack[stack.length - 1];
|
|
227
|
+
if (!currentVNode) {
|
|
228
|
+
return [];
|
|
229
|
+
}
|
|
230
|
+
const normalizedStack = [];
|
|
231
|
+
while (currentVNode) {
|
|
232
|
+
const last = normalizedStack[0];
|
|
233
|
+
if (last && last.vnode === currentVNode) {
|
|
234
|
+
last.recurseCount++;
|
|
235
|
+
} else {
|
|
236
|
+
normalizedStack.push({
|
|
237
|
+
vnode: currentVNode,
|
|
238
|
+
recurseCount: 0
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
242
|
+
currentVNode = parentInstance && parentInstance.vnode;
|
|
243
|
+
}
|
|
244
|
+
return normalizedStack;
|
|
251
245
|
}
|
|
252
|
-
/* istanbul ignore next */
|
|
253
246
|
function formatTrace(trace) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
247
|
+
const logs = [];
|
|
248
|
+
trace.forEach((entry, i) => {
|
|
249
|
+
logs.push(...i === 0 ? [] : [`
|
|
250
|
+
`], ...formatTraceEntry(entry));
|
|
251
|
+
});
|
|
252
|
+
return logs;
|
|
259
253
|
}
|
|
260
254
|
function formatTraceEntry({ vnode, recurseCount }) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
255
|
+
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
256
|
+
const isRoot = vnode.component ? vnode.component.parent == null : false;
|
|
257
|
+
const open = ` at <${formatComponentName(
|
|
258
|
+
vnode.component,
|
|
259
|
+
vnode.type,
|
|
260
|
+
isRoot
|
|
261
|
+
)}`;
|
|
262
|
+
const close = `>` + postfix;
|
|
263
|
+
return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
|
264
|
+
}
|
|
270
265
|
function formatProps(props) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
266
|
+
const res = [];
|
|
267
|
+
const keys = Object.keys(props);
|
|
268
|
+
keys.slice(0, 3).forEach((key) => {
|
|
269
|
+
res.push(...formatProp(key, props[key]));
|
|
270
|
+
});
|
|
271
|
+
if (keys.length > 3) {
|
|
272
|
+
res.push(` ...`);
|
|
273
|
+
}
|
|
274
|
+
return res;
|
|
280
275
|
}
|
|
281
|
-
/* istanbul ignore next */
|
|
282
276
|
function formatProp(key, value, raw) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
value = toRaw(value);
|
|
301
|
-
return raw ? value : [`${key}=`, value];
|
|
302
|
-
}
|
|
277
|
+
if (isString(value)) {
|
|
278
|
+
value = JSON.stringify(value);
|
|
279
|
+
return raw ? value : [`${key}=${value}`];
|
|
280
|
+
} else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
|
281
|
+
return raw ? value : [`${key}=${value}`];
|
|
282
|
+
} else if (isRef(value)) {
|
|
283
|
+
value = formatProp(key, toRaw(value.value), true);
|
|
284
|
+
return raw ? value : [`${key}=Ref<`, value, `>`];
|
|
285
|
+
} else if (isFunction(value)) {
|
|
286
|
+
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
287
|
+
} else {
|
|
288
|
+
value = toRaw(value);
|
|
289
|
+
return raw ? value : [`${key}=`, value];
|
|
290
|
+
}
|
|
303
291
|
}
|
|
304
292
|
|
|
305
293
|
const ErrorTypeStrings = {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
|
|
294
|
+
["sp"]: "serverPrefetch hook",
|
|
295
|
+
["bc"]: "beforeCreate hook",
|
|
296
|
+
["c"]: "created hook",
|
|
297
|
+
["bm"]: "beforeMount hook",
|
|
298
|
+
["m"]: "mounted hook",
|
|
299
|
+
["bu"]: "beforeUpdate hook",
|
|
300
|
+
["u"]: "updated",
|
|
301
|
+
["bum"]: "beforeUnmount hook",
|
|
302
|
+
["um"]: "unmounted hook",
|
|
303
|
+
["a"]: "activated hook",
|
|
304
|
+
["da"]: "deactivated hook",
|
|
305
|
+
["ec"]: "errorCaptured hook",
|
|
306
|
+
["rtc"]: "renderTracked hook",
|
|
307
|
+
["rtg"]: "renderTriggered hook",
|
|
308
|
+
[0]: "setup function",
|
|
309
|
+
[1]: "render function",
|
|
310
|
+
[2]: "watcher getter",
|
|
311
|
+
[3]: "watcher callback",
|
|
312
|
+
[4]: "watcher cleanup function",
|
|
313
|
+
[5]: "native event handler",
|
|
314
|
+
[6]: "component event handler",
|
|
315
|
+
[7]: "vnode hook",
|
|
316
|
+
[8]: "directive hook",
|
|
317
|
+
[9]: "transition hook",
|
|
318
|
+
[10]: "app errorHandler",
|
|
319
|
+
[11]: "app warnHandler",
|
|
320
|
+
[12]: "ref function",
|
|
321
|
+
[13]: "async component loader",
|
|
322
|
+
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
|
|
336
323
|
};
|
|
337
324
|
function callWithErrorHandling(fn, instance, type, args) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return res;
|
|
325
|
+
let res;
|
|
326
|
+
try {
|
|
327
|
+
res = args ? fn(...args) : fn();
|
|
328
|
+
} catch (err) {
|
|
329
|
+
handleError(err, instance, type);
|
|
330
|
+
}
|
|
331
|
+
return res;
|
|
346
332
|
}
|
|
347
333
|
function handleError(err, instance, type, throwInDev = true) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
for (let i = 0; i < errorCapturedHooks.length; i++) {
|
|
359
|
-
if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
cur = cur.parent;
|
|
365
|
-
}
|
|
366
|
-
// app-level handling
|
|
367
|
-
const appErrorHandler = instance.appContext.config.errorHandler;
|
|
368
|
-
if (appErrorHandler) {
|
|
369
|
-
callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
|
|
334
|
+
const contextVNode = instance ? instance.vnode : null;
|
|
335
|
+
if (instance) {
|
|
336
|
+
let cur = instance.parent;
|
|
337
|
+
const exposedInstance = instance.proxy;
|
|
338
|
+
const errorInfo = process.env.NODE_ENV !== "production" ? ErrorTypeStrings[type] : type;
|
|
339
|
+
while (cur) {
|
|
340
|
+
const errorCapturedHooks = cur.ec;
|
|
341
|
+
if (errorCapturedHooks) {
|
|
342
|
+
for (let i = 0; i < errorCapturedHooks.length; i++) {
|
|
343
|
+
if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
|
370
344
|
return;
|
|
345
|
+
}
|
|
371
346
|
}
|
|
347
|
+
}
|
|
348
|
+
cur = cur.parent;
|
|
349
|
+
}
|
|
350
|
+
const appErrorHandler = instance.appContext.config.errorHandler;
|
|
351
|
+
if (appErrorHandler) {
|
|
352
|
+
callWithErrorHandling(
|
|
353
|
+
appErrorHandler,
|
|
354
|
+
null,
|
|
355
|
+
10,
|
|
356
|
+
[err, exposedInstance, errorInfo]
|
|
357
|
+
);
|
|
358
|
+
return;
|
|
372
359
|
}
|
|
373
|
-
|
|
360
|
+
}
|
|
361
|
+
logError(err, type, contextVNode, throwInDev);
|
|
374
362
|
}
|
|
375
363
|
function logError(err, type, contextVNode, throwInDev = true) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
382
|
-
if (contextVNode) {
|
|
383
|
-
popWarningContext();
|
|
384
|
-
}
|
|
385
|
-
// crash in dev by default so it's more noticeable
|
|
386
|
-
if (throwInDev) {
|
|
387
|
-
throw err;
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
console.error(err);
|
|
391
|
-
}
|
|
364
|
+
if (process.env.NODE_ENV !== "production") {
|
|
365
|
+
const info = ErrorTypeStrings[type];
|
|
366
|
+
if (contextVNode) {
|
|
367
|
+
pushWarningContext(contextVNode);
|
|
392
368
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
369
|
+
warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
370
|
+
if (contextVNode) {
|
|
371
|
+
popWarningContext();
|
|
396
372
|
}
|
|
373
|
+
if (throwInDev) {
|
|
374
|
+
throw err;
|
|
375
|
+
} else {
|
|
376
|
+
console.error(err);
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
console.error(err);
|
|
380
|
+
}
|
|
397
381
|
}
|
|
398
382
|
|
|
383
|
+
let globalCurrentInstanceSetters;
|
|
384
|
+
let settersKey = "__VUE_INSTANCE_SETTERS__";
|
|
385
|
+
{
|
|
386
|
+
if (!(globalCurrentInstanceSetters = getGlobalThis()[settersKey])) {
|
|
387
|
+
globalCurrentInstanceSetters = getGlobalThis()[settersKey] = [];
|
|
388
|
+
}
|
|
389
|
+
globalCurrentInstanceSetters.push((i) => i);
|
|
390
|
+
}
|
|
399
391
|
const classifyRE = /(?:^|[-_])(\w)/g;
|
|
400
|
-
const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g,
|
|
392
|
+
const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
401
393
|
function getComponentName(Component, includeInferred = true) {
|
|
402
|
-
|
|
403
|
-
? Component.displayName || Component.name
|
|
404
|
-
: Component.name || (includeInferred && Component.__name);
|
|
394
|
+
return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
405
395
|
}
|
|
406
|
-
/* istanbul ignore next */
|
|
407
396
|
function formatComponentName(instance, Component, isRoot = false) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
397
|
+
let name = getComponentName(Component);
|
|
398
|
+
if (!name && Component.__file) {
|
|
399
|
+
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
400
|
+
if (match) {
|
|
401
|
+
name = match[1];
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (!name && instance && instance.parent) {
|
|
405
|
+
const inferFromRegistry = (registry) => {
|
|
406
|
+
for (const key in registry) {
|
|
407
|
+
if (registry[key] === Component) {
|
|
408
|
+
return key;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
name = inferFromRegistry(
|
|
413
|
+
instance.components || instance.parent.type.components
|
|
414
|
+
) || inferFromRegistry(instance.appContext.components);
|
|
415
|
+
}
|
|
416
|
+
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
429
417
|
}
|
|
430
418
|
|
|
431
419
|
function ssrRenderList(source, renderItem) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
420
|
+
if (isArray(source) || isString(source)) {
|
|
421
|
+
for (let i = 0, l = source.length; i < l; i++) {
|
|
422
|
+
renderItem(source[i], i);
|
|
423
|
+
}
|
|
424
|
+
} else if (typeof source === "number") {
|
|
425
|
+
if (process.env.NODE_ENV !== "production" && !Number.isInteger(source)) {
|
|
426
|
+
warn(`The v-for range expect an integer value but got ${source}.`);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
for (let i = 0; i < source; i++) {
|
|
430
|
+
renderItem(i + 1, i);
|
|
431
|
+
}
|
|
432
|
+
} else if (isObject(source)) {
|
|
433
|
+
if (source[Symbol.iterator]) {
|
|
434
|
+
const arr = Array.from(source);
|
|
435
|
+
for (let i = 0, l = arr.length; i < l; i++) {
|
|
436
|
+
renderItem(arr[i], i);
|
|
437
|
+
}
|
|
438
|
+
} else {
|
|
439
|
+
const keys = Object.keys(source);
|
|
440
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
441
|
+
const key = keys[i];
|
|
442
|
+
renderItem(source[key], key, i);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
461
446
|
}
|
|
462
447
|
|
|
463
448
|
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
449
|
+
if (renderContent) {
|
|
450
|
+
renderContent();
|
|
451
|
+
} else {
|
|
452
|
+
push(`<!---->`);
|
|
453
|
+
}
|
|
470
454
|
}
|
|
471
455
|
|
|
472
456
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
457
|
+
if (typeof dir !== "function" && dir.getSSRProps) {
|
|
458
|
+
return dir.getSSRProps(
|
|
459
|
+
{
|
|
460
|
+
dir,
|
|
461
|
+
instance,
|
|
462
|
+
value,
|
|
463
|
+
oldValue: void 0,
|
|
464
|
+
arg,
|
|
465
|
+
modifiers
|
|
466
|
+
},
|
|
467
|
+
null
|
|
468
|
+
) || {};
|
|
469
|
+
}
|
|
470
|
+
return {};
|
|
484
471
|
}
|
|
485
472
|
|
|
486
473
|
const ssrLooseEqual = looseEqual;
|
|
487
474
|
function ssrLooseContain(arr, value) {
|
|
488
|
-
|
|
475
|
+
return looseIndexOf(arr, value) > -1;
|
|
489
476
|
}
|
|
490
|
-
// for <input :type="type" v-model="model" value="value">
|
|
491
477
|
function ssrRenderDynamicModel(type, model, value) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return ssrRenderAttr('value', model);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
// for <input v-bind="obj" v-model="model">
|
|
478
|
+
switch (type) {
|
|
479
|
+
case "radio":
|
|
480
|
+
return looseEqual(model, value) ? " checked" : "";
|
|
481
|
+
case "checkbox":
|
|
482
|
+
return (isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
|
|
483
|
+
default:
|
|
484
|
+
return ssrRenderAttr("value", model);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
505
487
|
function ssrGetDynamicModelProps(existingProps = {}, model) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
// text types
|
|
516
|
-
return { value: model };
|
|
517
|
-
}
|
|
488
|
+
const { type, value } = existingProps;
|
|
489
|
+
switch (type) {
|
|
490
|
+
case "radio":
|
|
491
|
+
return looseEqual(model, value) ? { checked: true } : null;
|
|
492
|
+
case "checkbox":
|
|
493
|
+
return (isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
|
|
494
|
+
default:
|
|
495
|
+
return { value: model };
|
|
496
|
+
}
|
|
518
497
|
}
|
|
519
498
|
|
|
520
499
|
function ssrCompile(template, instance) {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
500
|
+
{
|
|
501
|
+
throw new Error(
|
|
502
|
+
`On-the-fly template compilation is not supported in the ESM build of @vue/server-renderer. All templates must be pre-compiled into render functions.`
|
|
503
|
+
);
|
|
504
|
+
}
|
|
527
505
|
}
|
|
528
506
|
|
|
529
|
-
const {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
507
|
+
const {
|
|
508
|
+
createComponentInstance,
|
|
509
|
+
setCurrentRenderingInstance,
|
|
510
|
+
setupComponent,
|
|
511
|
+
renderComponentRoot,
|
|
512
|
+
normalizeVNode
|
|
513
|
+
} = ssrUtils;
|
|
536
514
|
function createBuffer() {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
buffer.hasAsync = true;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
};
|
|
515
|
+
let appendable = false;
|
|
516
|
+
const buffer = [];
|
|
517
|
+
return {
|
|
518
|
+
getBuffer() {
|
|
519
|
+
return buffer;
|
|
520
|
+
},
|
|
521
|
+
push(item) {
|
|
522
|
+
const isStringItem = isString(item);
|
|
523
|
+
if (appendable && isStringItem) {
|
|
524
|
+
buffer[buffer.length - 1] += item;
|
|
525
|
+
} else {
|
|
526
|
+
buffer.push(item);
|
|
527
|
+
}
|
|
528
|
+
appendable = isStringItem;
|
|
529
|
+
if (isPromise(item) || isArray(item) && item.hasAsync) {
|
|
530
|
+
buffer.hasAsync = true;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
};
|
|
560
534
|
}
|
|
561
535
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
536
|
+
const instance = createComponentInstance(vnode, parentComponent, null);
|
|
537
|
+
const res = setupComponent(
|
|
538
|
+
instance,
|
|
539
|
+
true
|
|
540
|
+
/* isSSR */
|
|
541
|
+
);
|
|
542
|
+
const hasAsyncSetup = isPromise(res);
|
|
543
|
+
const prefetches = instance.sp;
|
|
544
|
+
if (hasAsyncSetup || prefetches) {
|
|
545
|
+
let p = hasAsyncSetup ? res : Promise.resolve();
|
|
546
|
+
if (prefetches) {
|
|
547
|
+
p = p.then(
|
|
548
|
+
() => Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)))
|
|
549
|
+
).catch(() => {
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
return p.then(() => renderComponentSubTree(instance, slotScopeId));
|
|
553
|
+
} else {
|
|
554
|
+
return renderComponentSubTree(instance, slotScopeId);
|
|
555
|
+
}
|
|
581
556
|
}
|
|
582
557
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
if (
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
push(`<!---->`);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
return getBuffer();
|
|
558
|
+
const comp = instance.type;
|
|
559
|
+
const { getBuffer, push } = createBuffer();
|
|
560
|
+
if (isFunction(comp)) {
|
|
561
|
+
let root = renderComponentRoot(instance);
|
|
562
|
+
if (!comp.props) {
|
|
563
|
+
for (const key in instance.attrs) {
|
|
564
|
+
if (key.startsWith(`data-v-`)) {
|
|
565
|
+
(root.props || (root.props = {}))[key] = ``;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
renderVNode(push, instance.subTree = root, instance, slotScopeId);
|
|
570
|
+
} else {
|
|
571
|
+
if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) {
|
|
572
|
+
comp.ssrRender = ssrCompile(comp.template);
|
|
573
|
+
}
|
|
574
|
+
for (const e of instance.scope.effects) {
|
|
575
|
+
if (e.computed)
|
|
576
|
+
e.computed._cacheable = true;
|
|
577
|
+
}
|
|
578
|
+
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
579
|
+
if (ssrRender) {
|
|
580
|
+
let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|
|
581
|
+
let hasCloned = false;
|
|
582
|
+
let cur = instance;
|
|
583
|
+
while (true) {
|
|
584
|
+
const scopeId = cur.vnode.scopeId;
|
|
585
|
+
if (scopeId) {
|
|
586
|
+
if (!hasCloned) {
|
|
587
|
+
attrs = { ...attrs };
|
|
588
|
+
hasCloned = true;
|
|
589
|
+
}
|
|
590
|
+
attrs[scopeId] = "";
|
|
591
|
+
}
|
|
592
|
+
const parent = cur.parent;
|
|
593
|
+
if (parent && parent.subTree && parent.subTree === cur.vnode) {
|
|
594
|
+
cur = parent;
|
|
595
|
+
} else {
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
if (slotScopeId) {
|
|
600
|
+
if (!hasCloned)
|
|
601
|
+
attrs = { ...attrs };
|
|
602
|
+
attrs[slotScopeId.trim()] = "";
|
|
603
|
+
}
|
|
604
|
+
const prev = setCurrentRenderingInstance(instance);
|
|
605
|
+
try {
|
|
606
|
+
ssrRender(
|
|
607
|
+
instance.proxy,
|
|
608
|
+
push,
|
|
609
|
+
instance,
|
|
610
|
+
attrs,
|
|
611
|
+
// compiler-optimized bindings
|
|
612
|
+
instance.props,
|
|
613
|
+
instance.setupState,
|
|
614
|
+
instance.data,
|
|
615
|
+
instance.ctx
|
|
616
|
+
);
|
|
617
|
+
} finally {
|
|
618
|
+
setCurrentRenderingInstance(prev);
|
|
619
|
+
}
|
|
620
|
+
} else if (instance.render && instance.render !== NOOP) {
|
|
621
|
+
renderVNode(
|
|
622
|
+
push,
|
|
623
|
+
instance.subTree = renderComponentRoot(instance),
|
|
624
|
+
instance,
|
|
625
|
+
slotScopeId
|
|
626
|
+
);
|
|
627
|
+
} else {
|
|
628
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
629
|
+
warn$1(`Component ${componentName} is missing template or render function.`);
|
|
630
|
+
push(`<!---->`);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return getBuffer();
|
|
663
634
|
}
|
|
664
635
|
function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
636
|
+
const { type, shapeFlag, children } = vnode;
|
|
637
|
+
switch (type) {
|
|
638
|
+
case Text:
|
|
639
|
+
push(escapeHtml(children));
|
|
640
|
+
break;
|
|
641
|
+
case Comment:
|
|
642
|
+
push(
|
|
643
|
+
children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`
|
|
644
|
+
);
|
|
645
|
+
break;
|
|
646
|
+
case Static:
|
|
647
|
+
push(children);
|
|
648
|
+
break;
|
|
649
|
+
case Fragment:
|
|
650
|
+
if (vnode.slotScopeIds) {
|
|
651
|
+
slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
652
|
+
}
|
|
653
|
+
push(`<!--[-->`);
|
|
654
|
+
renderVNodeChildren(
|
|
655
|
+
push,
|
|
656
|
+
children,
|
|
657
|
+
parentComponent,
|
|
658
|
+
slotScopeId
|
|
659
|
+
);
|
|
660
|
+
push(`<!--]-->`);
|
|
661
|
+
break;
|
|
662
|
+
default:
|
|
663
|
+
if (shapeFlag & 1) {
|
|
664
|
+
renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
665
|
+
} else if (shapeFlag & 6) {
|
|
666
|
+
push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
667
|
+
} else if (shapeFlag & 64) {
|
|
668
|
+
renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
669
|
+
} else if (shapeFlag & 128) {
|
|
670
|
+
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
671
|
+
} else {
|
|
672
|
+
warn$1(
|
|
673
|
+
"[@vue/server-renderer] Invalid VNode type:",
|
|
674
|
+
type,
|
|
675
|
+
`(${typeof type})`
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
702
679
|
}
|
|
703
680
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
681
|
+
for (let i = 0; i < children.length; i++) {
|
|
682
|
+
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
683
|
+
}
|
|
707
684
|
}
|
|
708
685
|
function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
686
|
+
const tag = vnode.type;
|
|
687
|
+
let { props, children, shapeFlag, scopeId, dirs } = vnode;
|
|
688
|
+
let openTag = `<${tag}`;
|
|
689
|
+
if (dirs) {
|
|
690
|
+
props = applySSRDirectives(vnode, props, dirs);
|
|
691
|
+
}
|
|
692
|
+
if (props) {
|
|
693
|
+
openTag += ssrRenderAttrs(props, tag);
|
|
694
|
+
}
|
|
695
|
+
if (scopeId) {
|
|
696
|
+
openTag += ` ${scopeId}`;
|
|
697
|
+
}
|
|
698
|
+
let curParent = parentComponent;
|
|
699
|
+
let curVnode = vnode;
|
|
700
|
+
while (curParent && curVnode === curParent.subTree) {
|
|
701
|
+
curVnode = curParent.vnode;
|
|
702
|
+
if (curVnode.scopeId) {
|
|
703
|
+
openTag += ` ${curVnode.scopeId}`;
|
|
704
|
+
}
|
|
705
|
+
curParent = curParent.parent;
|
|
706
|
+
}
|
|
707
|
+
if (slotScopeId) {
|
|
708
|
+
openTag += ` ${slotScopeId}`;
|
|
709
|
+
}
|
|
710
|
+
push(openTag + `>`);
|
|
711
|
+
if (!isVoidTag(tag)) {
|
|
712
|
+
let hasChildrenOverride = false;
|
|
715
713
|
if (props) {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}
|
|
742
|
-
else if (props.textContent) {
|
|
743
|
-
hasChildrenOverride = true;
|
|
744
|
-
push(escapeHtml(props.textContent));
|
|
745
|
-
}
|
|
746
|
-
else if (tag === 'textarea' && props.value) {
|
|
747
|
-
hasChildrenOverride = true;
|
|
748
|
-
push(escapeHtml(props.value));
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
if (!hasChildrenOverride) {
|
|
752
|
-
if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
|
|
753
|
-
push(escapeHtml(children));
|
|
754
|
-
}
|
|
755
|
-
else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
|
|
756
|
-
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
push(`</${tag}>`);
|
|
760
|
-
}
|
|
714
|
+
if (props.innerHTML) {
|
|
715
|
+
hasChildrenOverride = true;
|
|
716
|
+
push(props.innerHTML);
|
|
717
|
+
} else if (props.textContent) {
|
|
718
|
+
hasChildrenOverride = true;
|
|
719
|
+
push(escapeHtml(props.textContent));
|
|
720
|
+
} else if (tag === "textarea" && props.value) {
|
|
721
|
+
hasChildrenOverride = true;
|
|
722
|
+
push(escapeHtml(props.value));
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (!hasChildrenOverride) {
|
|
726
|
+
if (shapeFlag & 8) {
|
|
727
|
+
push(escapeHtml(children));
|
|
728
|
+
} else if (shapeFlag & 16) {
|
|
729
|
+
renderVNodeChildren(
|
|
730
|
+
push,
|
|
731
|
+
children,
|
|
732
|
+
parentComponent,
|
|
733
|
+
slotScopeId
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
push(`</${tag}>`);
|
|
738
|
+
}
|
|
761
739
|
}
|
|
762
740
|
function applySSRDirectives(vnode, rawProps, dirs) {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
741
|
+
const toMerge = [];
|
|
742
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
743
|
+
const binding = dirs[i];
|
|
744
|
+
const {
|
|
745
|
+
dir: { getSSRProps }
|
|
746
|
+
} = binding;
|
|
747
|
+
if (getSSRProps) {
|
|
748
|
+
const props = getSSRProps(binding, vnode);
|
|
749
|
+
if (props)
|
|
750
|
+
toMerge.push(props);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
return mergeProps(rawProps || {}, ...toMerge);
|
|
774
754
|
}
|
|
775
755
|
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
756
|
+
const target = vnode.props && vnode.props.to;
|
|
757
|
+
const disabled = vnode.props && vnode.props.disabled;
|
|
758
|
+
if (!target) {
|
|
759
|
+
if (!disabled) {
|
|
760
|
+
warn$1(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
761
|
+
}
|
|
762
|
+
return [];
|
|
763
|
+
}
|
|
764
|
+
if (!isString(target)) {
|
|
765
|
+
warn$1(
|
|
766
|
+
`[@vue/server-renderer] Teleport target must be a query selector string.`
|
|
767
|
+
);
|
|
768
|
+
return [];
|
|
769
|
+
}
|
|
770
|
+
ssrRenderTeleport(
|
|
771
|
+
push,
|
|
772
|
+
(push2) => {
|
|
773
|
+
renderVNodeChildren(
|
|
774
|
+
push2,
|
|
775
|
+
vnode.children,
|
|
776
|
+
parentComponent,
|
|
777
|
+
slotScopeId
|
|
778
|
+
);
|
|
779
|
+
},
|
|
780
|
+
target,
|
|
781
|
+
disabled || disabled === "",
|
|
782
|
+
parentComponent
|
|
783
|
+
);
|
|
791
784
|
}
|
|
792
785
|
|
|
793
786
|
const { isVNode: isVNode$1 } = ssrUtils;
|
|
794
787
|
async function unrollBuffer$1(buffer) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
return ret;
|
|
810
|
-
}
|
|
811
|
-
else {
|
|
812
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
813
|
-
// ticks
|
|
814
|
-
return unrollBufferSync$1(buffer);
|
|
788
|
+
if (buffer.hasAsync) {
|
|
789
|
+
let ret = "";
|
|
790
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
791
|
+
let item = buffer[i];
|
|
792
|
+
if (isPromise(item)) {
|
|
793
|
+
item = await item;
|
|
794
|
+
}
|
|
795
|
+
if (isString(item)) {
|
|
796
|
+
ret += item;
|
|
797
|
+
} else {
|
|
798
|
+
ret += await unrollBuffer$1(item);
|
|
799
|
+
}
|
|
815
800
|
}
|
|
801
|
+
return ret;
|
|
802
|
+
} else {
|
|
803
|
+
return unrollBufferSync$1(buffer);
|
|
804
|
+
}
|
|
816
805
|
}
|
|
817
806
|
function unrollBufferSync$1(buffer) {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
// since this is a sync buffer, child buffers are never promises
|
|
826
|
-
ret += unrollBufferSync$1(item);
|
|
827
|
-
}
|
|
807
|
+
let ret = "";
|
|
808
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
809
|
+
let item = buffer[i];
|
|
810
|
+
if (isString(item)) {
|
|
811
|
+
ret += item;
|
|
812
|
+
} else {
|
|
813
|
+
ret += unrollBufferSync$1(item);
|
|
828
814
|
}
|
|
829
|
-
|
|
815
|
+
}
|
|
816
|
+
return ret;
|
|
830
817
|
}
|
|
831
818
|
async function renderToString(input, context = {}) {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
return result;
|
|
819
|
+
if (isVNode$1(input)) {
|
|
820
|
+
return renderToString(createApp({ render: () => input }), context);
|
|
821
|
+
}
|
|
822
|
+
const vnode = createVNode(input._component, input._props);
|
|
823
|
+
vnode.appContext = input._context;
|
|
824
|
+
input.provide(ssrContextKey, context);
|
|
825
|
+
const buffer = await renderComponentVNode(vnode);
|
|
826
|
+
const result = await unrollBuffer$1(buffer);
|
|
827
|
+
await resolveTeleports(context);
|
|
828
|
+
if (context.__watcherHandles) {
|
|
829
|
+
for (const unwatch of context.__watcherHandles) {
|
|
830
|
+
unwatch();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return result;
|
|
850
834
|
}
|
|
851
835
|
async function resolveTeleports(context) {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}
|
|
836
|
+
if (context.__teleportBuffers) {
|
|
837
|
+
context.teleports = context.teleports || {};
|
|
838
|
+
for (const key in context.__teleportBuffers) {
|
|
839
|
+
context.teleports[key] = await unrollBuffer$1(
|
|
840
|
+
await Promise.all([context.__teleportBuffers[key]])
|
|
841
|
+
);
|
|
859
842
|
}
|
|
843
|
+
}
|
|
860
844
|
}
|
|
861
845
|
|
|
862
846
|
const { isVNode } = ssrUtils;
|
|
863
847
|
async function unrollBuffer(buffer, stream) {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
// sync buffer can be more efficiently unrolled without unnecessary await
|
|
880
|
-
// ticks
|
|
881
|
-
unrollBufferSync(buffer, stream);
|
|
882
|
-
}
|
|
848
|
+
if (buffer.hasAsync) {
|
|
849
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
850
|
+
let item = buffer[i];
|
|
851
|
+
if (isPromise(item)) {
|
|
852
|
+
item = await item;
|
|
853
|
+
}
|
|
854
|
+
if (isString(item)) {
|
|
855
|
+
stream.push(item);
|
|
856
|
+
} else {
|
|
857
|
+
await unrollBuffer(item, stream);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
} else {
|
|
861
|
+
unrollBufferSync(buffer, stream);
|
|
862
|
+
}
|
|
883
863
|
}
|
|
884
864
|
function unrollBufferSync(buffer, stream) {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
// since this is a sync buffer, child buffers are never promises
|
|
892
|
-
unrollBufferSync(item, stream);
|
|
893
|
-
}
|
|
865
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
866
|
+
let item = buffer[i];
|
|
867
|
+
if (isString(item)) {
|
|
868
|
+
stream.push(item);
|
|
869
|
+
} else {
|
|
870
|
+
unrollBufferSync(item, stream);
|
|
894
871
|
}
|
|
872
|
+
}
|
|
895
873
|
}
|
|
896
874
|
function renderToSimpleStream(input, context, stream) {
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
stream.destroy(error);
|
|
919
|
-
});
|
|
920
|
-
return stream;
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* @deprecated
|
|
924
|
-
*/
|
|
875
|
+
if (isVNode(input)) {
|
|
876
|
+
return renderToSimpleStream(
|
|
877
|
+
createApp({ render: () => input }),
|
|
878
|
+
context,
|
|
879
|
+
stream
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
const vnode = createVNode(input._component, input._props);
|
|
883
|
+
vnode.appContext = input._context;
|
|
884
|
+
input.provide(ssrContextKey, context);
|
|
885
|
+
Promise.resolve(renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
|
886
|
+
if (context.__watcherHandles) {
|
|
887
|
+
for (const unwatch of context.__watcherHandles) {
|
|
888
|
+
unwatch();
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}).then(() => stream.push(null)).catch((error) => {
|
|
892
|
+
stream.destroy(error);
|
|
893
|
+
});
|
|
894
|
+
return stream;
|
|
895
|
+
}
|
|
925
896
|
function renderToStream(input, context = {}) {
|
|
926
|
-
|
|
927
|
-
|
|
897
|
+
console.warn(
|
|
898
|
+
`[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`
|
|
899
|
+
);
|
|
900
|
+
return renderToNodeStream(input, context);
|
|
928
901
|
}
|
|
929
902
|
function renderToNodeStream(input, context = {}) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
903
|
+
{
|
|
904
|
+
throw new Error(
|
|
905
|
+
`ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
|
|
906
|
+
);
|
|
907
|
+
}
|
|
935
908
|
}
|
|
936
909
|
function pipeToNodeWritable(input, context = {}, writable) {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
});
|
|
910
|
+
renderToSimpleStream(input, context, {
|
|
911
|
+
push(content) {
|
|
912
|
+
if (content != null) {
|
|
913
|
+
writable.write(content);
|
|
914
|
+
} else {
|
|
915
|
+
writable.end();
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
destroy(err) {
|
|
919
|
+
writable.destroy(err);
|
|
920
|
+
}
|
|
921
|
+
});
|
|
950
922
|
}
|
|
951
923
|
function renderToWebStream(input, context = {}) {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
destroy(err) {
|
|
973
|
-
controller.error(err);
|
|
974
|
-
}
|
|
975
|
-
});
|
|
924
|
+
if (typeof ReadableStream !== "function") {
|
|
925
|
+
throw new Error(
|
|
926
|
+
`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.`
|
|
927
|
+
);
|
|
928
|
+
}
|
|
929
|
+
const encoder = new TextEncoder();
|
|
930
|
+
let cancelled = false;
|
|
931
|
+
return new ReadableStream({
|
|
932
|
+
start(controller) {
|
|
933
|
+
renderToSimpleStream(input, context, {
|
|
934
|
+
push(content) {
|
|
935
|
+
if (cancelled)
|
|
936
|
+
return;
|
|
937
|
+
if (content != null) {
|
|
938
|
+
controller.enqueue(encoder.encode(content));
|
|
939
|
+
} else {
|
|
940
|
+
controller.close();
|
|
941
|
+
}
|
|
976
942
|
},
|
|
977
|
-
|
|
978
|
-
|
|
943
|
+
destroy(err) {
|
|
944
|
+
controller.error(err);
|
|
979
945
|
}
|
|
980
|
-
|
|
946
|
+
});
|
|
947
|
+
},
|
|
948
|
+
cancel() {
|
|
949
|
+
cancelled = true;
|
|
950
|
+
}
|
|
951
|
+
});
|
|
981
952
|
}
|
|
982
953
|
function pipeToWebWritable(input, context = {}, writable) {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
writer.close();
|
|
1007
|
-
}
|
|
1008
|
-
});
|
|
954
|
+
const writer = writable.getWriter();
|
|
955
|
+
const encoder = new TextEncoder();
|
|
956
|
+
let hasReady = false;
|
|
957
|
+
try {
|
|
958
|
+
hasReady = isPromise(writer.ready);
|
|
959
|
+
} catch (e) {
|
|
960
|
+
}
|
|
961
|
+
renderToSimpleStream(input, context, {
|
|
962
|
+
async push(content) {
|
|
963
|
+
if (hasReady) {
|
|
964
|
+
await writer.ready;
|
|
965
|
+
}
|
|
966
|
+
if (content != null) {
|
|
967
|
+
return writer.write(encoder.encode(content));
|
|
968
|
+
} else {
|
|
969
|
+
return writer.close();
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
destroy(err) {
|
|
973
|
+
console.log(err);
|
|
974
|
+
writer.close();
|
|
975
|
+
}
|
|
976
|
+
});
|
|
1009
977
|
}
|
|
1010
978
|
|
|
1011
979
|
initDirectivesForSSR();
|