@vue/server-renderer 3.6.0-beta.1 → 3.6.0-beta.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/README.md +2 -2
- package/dist/server-renderer.cjs.js +810 -1013
- package/dist/server-renderer.cjs.prod.js +572 -780
- package/dist/server-renderer.d.ts +40 -26
- package/dist/server-renderer.esm-browser.js +6120 -8195
- package/dist/server-renderer.esm-browser.prod.js +5 -4
- package/dist/server-renderer.esm-bundler.js +1158 -1512
- package/package.json +4 -4
|
@@ -1,432 +1,390 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.6.0-beta.
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const shouldIgnoreProp = /* @__PURE__ */ makeMap(
|
|
11
|
-
`,key,ref,innerHTML,textContent,ref_key,ref_for`
|
|
12
|
-
);
|
|
2
|
+
* @vue/server-renderer v3.6.0-beta.10
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
import { Comment, Fragment, Static, Text, createApp, createVNode, initDirectivesForSSR, mergeProps, ssrContextKey, ssrUtils, warn } from "vue";
|
|
7
|
+
import { EMPTY_OBJ, NOOP, escapeHtml, escapeHtmlComment, extend, getGlobalThis, includeBooleanAttr, includeBooleanAttr as ssrIncludeBooleanAttr, isArray, isBooleanAttr, isFunction, isModelListener, isObject, isOn, isPromise, isRenderableAttrValue, isSSRSafeAttrName, isSVGTag, isString, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeCssVarValue, normalizeStyle, propsToAttrMap, stringifyStyle, toDisplayString } from "@vue/shared";
|
|
8
|
+
//#region packages/server-renderer/src/helpers/ssrRenderAttrs.ts
|
|
9
|
+
const shouldIgnoreProp = /* @__PURE__ */ makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
13
10
|
function ssrRenderAttrs(props, tag) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} else {
|
|
27
|
-
ret += ssrRenderDynamicAttr(key, value, tag);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return ret;
|
|
11
|
+
let ret = "";
|
|
12
|
+
for (let key in props) {
|
|
13
|
+
if (shouldIgnoreProp(key) || isOn(key) || tag === "textarea" && key === "value" || key.startsWith(".")) continue;
|
|
14
|
+
const value = props[key];
|
|
15
|
+
if (key.startsWith("^")) key = key.slice(1);
|
|
16
|
+
if (key === "class") ret += ` class="${ssrRenderClass(value)}"`;
|
|
17
|
+
else if (key === "style") ret += ` style="${ssrRenderStyle(value)}"`;
|
|
18
|
+
else if (key === "className") {
|
|
19
|
+
if (value != null) ret += ` class="${escapeHtml(String(value))}"`;
|
|
20
|
+
} else ret += ssrRenderDynamicAttr(key, value, tag);
|
|
21
|
+
}
|
|
22
|
+
return ret;
|
|
31
23
|
}
|
|
32
24
|
function ssrRenderDynamicAttr(key, value, tag) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} else {
|
|
42
|
-
console.warn(
|
|
43
|
-
`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
|
|
44
|
-
);
|
|
45
|
-
return ``;
|
|
46
|
-
}
|
|
25
|
+
if (!isRenderableAttrValue(value)) return ``;
|
|
26
|
+
const attrKey = tag && (tag.indexOf("-") > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase();
|
|
27
|
+
if (isBooleanAttr(attrKey)) return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
|
|
28
|
+
else if (isSSRSafeAttrName(attrKey)) return value === "" ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`;
|
|
29
|
+
else {
|
|
30
|
+
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
|
|
31
|
+
return ``;
|
|
32
|
+
}
|
|
47
33
|
}
|
|
48
34
|
function ssrRenderAttr(key, value) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
return ` ${key}="${escapeHtml(value)}"`;
|
|
35
|
+
if (!isRenderableAttrValue(value)) return ``;
|
|
36
|
+
return ` ${key}="${escapeHtml(value)}"`;
|
|
53
37
|
}
|
|
54
38
|
function ssrRenderClass(raw) {
|
|
55
|
-
|
|
39
|
+
return escapeHtml(normalizeClass(raw));
|
|
56
40
|
}
|
|
57
41
|
function ssrRenderStyle(raw) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (isString(raw)) {
|
|
62
|
-
return escapeHtml(raw);
|
|
63
|
-
}
|
|
64
|
-
const styles = normalizeStyle(ssrResetCssVars(raw));
|
|
65
|
-
return escapeHtml(stringifyStyle(styles));
|
|
42
|
+
if (!raw) return "";
|
|
43
|
+
if (isString(raw)) return escapeHtml(raw);
|
|
44
|
+
return escapeHtml(stringifyStyle(normalizeStyle(ssrResetCssVars(raw))));
|
|
66
45
|
}
|
|
67
46
|
function ssrResetCssVars(raw) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
return raw;
|
|
80
|
-
}
|
|
81
|
-
|
|
47
|
+
if (!isArray(raw) && isObject(raw)) {
|
|
48
|
+
const res = {};
|
|
49
|
+
for (const key in raw) if (key.startsWith(":--")) res[key.slice(1)] = normalizeCssVarValue(raw[key]);
|
|
50
|
+
else res[key] = raw[key];
|
|
51
|
+
return res;
|
|
52
|
+
}
|
|
53
|
+
return raw;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
82
57
|
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
83
|
-
|
|
84
|
-
createVNode$1(comp, props, children),
|
|
85
|
-
parentComponent,
|
|
86
|
-
slotScopeId
|
|
87
|
-
);
|
|
58
|
+
return renderComponentVNode(createVNode(comp, props, children), parentComponent, slotScopeId);
|
|
88
59
|
}
|
|
89
|
-
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region packages/server-renderer/src/helpers/ssrRenderSlot.ts
|
|
90
62
|
const { ensureValidVNode } = ssrUtils;
|
|
91
63
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
slotName,
|
|
96
|
-
slotProps,
|
|
97
|
-
fallbackRenderFn,
|
|
98
|
-
push,
|
|
99
|
-
parentComponent,
|
|
100
|
-
slotScopeId
|
|
101
|
-
);
|
|
102
|
-
push(`<!--]-->`);
|
|
64
|
+
push(`<!--[-->`);
|
|
65
|
+
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
66
|
+
push(`<!--]-->`);
|
|
103
67
|
}
|
|
104
68
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (isEmptySlot) {
|
|
144
|
-
if (fallbackRenderFn) {
|
|
145
|
-
fallbackRenderFn();
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
let start = 0;
|
|
149
|
-
let end = slotBuffer.length;
|
|
150
|
-
if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
|
|
151
|
-
start++;
|
|
152
|
-
end--;
|
|
153
|
-
}
|
|
154
|
-
if (start < end) {
|
|
155
|
-
for (let i = start; i < end; i++) {
|
|
156
|
-
push(slotBuffer[i]);
|
|
157
|
-
}
|
|
158
|
-
} else if (transition) {
|
|
159
|
-
push(`<!---->`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
} else if (fallbackRenderFn) {
|
|
164
|
-
fallbackRenderFn();
|
|
165
|
-
} else if (transition) {
|
|
166
|
-
push(`<!---->`);
|
|
167
|
-
}
|
|
69
|
+
const slotFn = slots[slotName];
|
|
70
|
+
if (slotFn) {
|
|
71
|
+
const slotBuffer = [];
|
|
72
|
+
const bufferedPush = (item) => {
|
|
73
|
+
slotBuffer.push(item);
|
|
74
|
+
};
|
|
75
|
+
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
76
|
+
if (isArray(ret)) {
|
|
77
|
+
const validSlotContent = ensureValidVNode(ret);
|
|
78
|
+
if (validSlotContent) renderVNodeChildren(push, validSlotContent, parentComponent, slotScopeId);
|
|
79
|
+
else if (fallbackRenderFn) fallbackRenderFn();
|
|
80
|
+
else if (transition) push(`<!---->`);
|
|
81
|
+
} else {
|
|
82
|
+
let isEmptySlot = true;
|
|
83
|
+
if (transition) isEmptySlot = false;
|
|
84
|
+
else for (let i = 0; i < slotBuffer.length; i++) if (!isComment(slotBuffer[i])) {
|
|
85
|
+
isEmptySlot = false;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
if (isEmptySlot) {
|
|
89
|
+
if (fallbackRenderFn) fallbackRenderFn();
|
|
90
|
+
} else {
|
|
91
|
+
let start = 0;
|
|
92
|
+
let end = slotBuffer.length;
|
|
93
|
+
if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
|
|
94
|
+
start++;
|
|
95
|
+
end--;
|
|
96
|
+
}
|
|
97
|
+
if (start < end) for (let i = start; i < end; i++) push(slotBuffer[i]);
|
|
98
|
+
else if (transition) push(`<!---->`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} else if (fallbackRenderFn) fallbackRenderFn();
|
|
102
|
+
else if (transition) push(`<!---->`);
|
|
168
103
|
}
|
|
169
104
|
const commentTestRE = /^<!--[\s\S]*-->$/;
|
|
170
105
|
const commentRE = /<!--[^]*?-->/gm;
|
|
171
106
|
function isComment(item) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
107
|
+
if (typeof item !== "string" || !commentTestRE.test(item)) return false;
|
|
108
|
+
if (item.length <= 8) return true;
|
|
109
|
+
return !item.replace(commentRE, "").trim();
|
|
175
110
|
}
|
|
176
|
-
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region packages/server-renderer/src/helpers/ssrRenderTeleport.ts
|
|
177
113
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
114
|
+
parentPush("<!--teleport start-->");
|
|
115
|
+
const context = parentComponent.appContext.provides[ssrContextKey];
|
|
116
|
+
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
117
|
+
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
118
|
+
const bufferIndex = targetBuffer.length;
|
|
119
|
+
let teleportContent;
|
|
120
|
+
if (disabled) {
|
|
121
|
+
contentRenderFn(parentPush);
|
|
122
|
+
teleportContent = `<!--teleport start anchor--><!--teleport anchor-->`;
|
|
123
|
+
} else {
|
|
124
|
+
const { getBuffer, push } = createBuffer();
|
|
125
|
+
push(`<!--teleport start anchor-->`);
|
|
126
|
+
contentRenderFn(push);
|
|
127
|
+
push(`<!--teleport anchor-->`);
|
|
128
|
+
teleportContent = getBuffer();
|
|
129
|
+
}
|
|
130
|
+
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
131
|
+
parentPush("<!--teleport end-->");
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region packages/server-renderer/src/helpers/ssrInterpolate.ts
|
|
198
135
|
function ssrInterpolate(value) {
|
|
199
|
-
|
|
136
|
+
return escapeHtml(toDisplayString(value));
|
|
200
137
|
}
|
|
201
|
-
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region packages/reactivity/src/system.ts
|
|
202
140
|
let activeSub = void 0;
|
|
203
141
|
function setActiveSub(sub) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
142
|
+
try {
|
|
143
|
+
return activeSub;
|
|
144
|
+
} finally {
|
|
145
|
+
activeSub = sub;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
|
|
149
|
+
Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
|
|
150
|
+
Symbol(!!(process.env.NODE_ENV !== "production") ? "Array iterate" : "");
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region packages/reactivity/src/reactive.ts
|
|
153
|
+
/**
|
|
154
|
+
* Checks if an object is a proxy created by {@link reactive},
|
|
155
|
+
* {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
|
|
156
|
+
*
|
|
157
|
+
* @param value - The value to check.
|
|
158
|
+
* @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
|
|
159
|
+
*/
|
|
160
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
211
161
|
function isProxy(value) {
|
|
212
|
-
|
|
162
|
+
return value ? !!value["__v_raw"] : false;
|
|
213
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Returns the raw, original object of a Vue-created proxy.
|
|
166
|
+
*
|
|
167
|
+
* `toRaw()` can return the original object from proxies created by
|
|
168
|
+
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
|
|
169
|
+
* {@link shallowReadonly}.
|
|
170
|
+
*
|
|
171
|
+
* This is an escape hatch that can be used to temporarily read without
|
|
172
|
+
* incurring proxy access / tracking overhead or write without triggering
|
|
173
|
+
* changes. It is **not** recommended to hold a persistent reference to the
|
|
174
|
+
* original object. Use with caution.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```js
|
|
178
|
+
* const foo = {}
|
|
179
|
+
* const reactiveFoo = reactive(foo)
|
|
180
|
+
*
|
|
181
|
+
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* @param observed - The object for which the "raw" value is requested.
|
|
185
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
186
|
+
*/
|
|
187
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
214
188
|
function toRaw(observed) {
|
|
215
|
-
|
|
216
|
-
|
|
189
|
+
const raw = observed && observed["__v_raw"];
|
|
190
|
+
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
217
191
|
}
|
|
218
|
-
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region packages/reactivity/src/ref.ts
|
|
194
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
219
195
|
function isRef(r) {
|
|
220
|
-
|
|
196
|
+
return r ? r["__v_isRef"] === true : false;
|
|
221
197
|
}
|
|
222
|
-
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region packages/runtime-core/src/warning.ts
|
|
223
200
|
const stack = [];
|
|
201
|
+
/**
|
|
202
|
+
* @internal
|
|
203
|
+
*/
|
|
224
204
|
function pushWarningContext$1(ctx) {
|
|
225
|
-
|
|
205
|
+
stack.push(ctx);
|
|
226
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
227
210
|
function popWarningContext$1() {
|
|
228
|
-
|
|
211
|
+
stack.pop();
|
|
229
212
|
}
|
|
230
213
|
let isWarning = false;
|
|
231
|
-
function warn$
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
} else {
|
|
258
|
-
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
259
|
-
if (trace.length && // avoid spamming console during tests
|
|
260
|
-
true) {
|
|
261
|
-
warnArgs.push(`
|
|
262
|
-
`, ...formatTrace(trace));
|
|
263
|
-
}
|
|
264
|
-
console.warn(...warnArgs);
|
|
265
|
-
}
|
|
266
|
-
setActiveSub(prevSub);
|
|
267
|
-
isWarning = false;
|
|
214
|
+
function warn$2(msg, ...args) {
|
|
215
|
+
if (isWarning) return;
|
|
216
|
+
isWarning = true;
|
|
217
|
+
const prevSub = setActiveSub();
|
|
218
|
+
const entry = stack.length ? stack[stack.length - 1] : null;
|
|
219
|
+
const instance = isVNode$2(entry) ? entry.component : entry;
|
|
220
|
+
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
221
|
+
const trace = getComponentTrace();
|
|
222
|
+
if (appWarnHandler) callWithErrorHandling(appWarnHandler, instance, 11, [
|
|
223
|
+
msg + args.map((a) => {
|
|
224
|
+
const toString = a.toString;
|
|
225
|
+
return toString == null ? JSON.stringify(a) : toString.call(a);
|
|
226
|
+
}).join(""),
|
|
227
|
+
instance && instance.proxy || instance,
|
|
228
|
+
trace.map(({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`).join("\n"),
|
|
229
|
+
trace
|
|
230
|
+
]);
|
|
231
|
+
else {
|
|
232
|
+
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
233
|
+
if (trace.length && true)
|
|
234
|
+
/* v8 ignore next 2 */
|
|
235
|
+
warnArgs.push(`\n`, ...formatTrace(trace));
|
|
236
|
+
console.warn(...warnArgs);
|
|
237
|
+
}
|
|
238
|
+
setActiveSub(prevSub);
|
|
239
|
+
isWarning = false;
|
|
268
240
|
}
|
|
269
241
|
function getComponentTrace() {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
} else {
|
|
289
|
-
currentCtx = currentCtx.parent;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return normalizedStack;
|
|
293
|
-
}
|
|
242
|
+
let currentCtx = stack[stack.length - 1];
|
|
243
|
+
if (!currentCtx) return [];
|
|
244
|
+
const normalizedStack = [];
|
|
245
|
+
while (currentCtx) {
|
|
246
|
+
const last = normalizedStack[0];
|
|
247
|
+
if (last && last.ctx === currentCtx) last.recurseCount++;
|
|
248
|
+
else normalizedStack.push({
|
|
249
|
+
ctx: currentCtx,
|
|
250
|
+
recurseCount: 0
|
|
251
|
+
});
|
|
252
|
+
if (isVNode$2(currentCtx)) {
|
|
253
|
+
const parent = currentCtx.component && currentCtx.component.parent;
|
|
254
|
+
currentCtx = parent && parent.vnode || parent;
|
|
255
|
+
} else currentCtx = currentCtx.parent;
|
|
256
|
+
}
|
|
257
|
+
return normalizedStack;
|
|
258
|
+
}
|
|
259
|
+
/* v8 ignore start */
|
|
294
260
|
function formatTrace(trace) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return logs;
|
|
261
|
+
const logs = [];
|
|
262
|
+
trace.forEach((entry, i) => {
|
|
263
|
+
logs.push(...i === 0 ? [] : [`\n`], ...formatTraceEntry(entry));
|
|
264
|
+
});
|
|
265
|
+
return logs;
|
|
301
266
|
}
|
|
302
267
|
function formatTraceEntry({ ctx, recurseCount }) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
268
|
+
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
269
|
+
const instance = isVNode$2(ctx) ? ctx.component : ctx;
|
|
270
|
+
const isRoot = instance ? instance.parent == null : false;
|
|
271
|
+
const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`;
|
|
272
|
+
const close = `>` + postfix;
|
|
273
|
+
return ctx.props ? [
|
|
274
|
+
open,
|
|
275
|
+
...formatProps(ctx.props),
|
|
276
|
+
close
|
|
277
|
+
] : [open + close];
|
|
309
278
|
}
|
|
310
279
|
function formatProps(props) {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
return res;
|
|
280
|
+
const res = [];
|
|
281
|
+
const keys = Object.keys(props);
|
|
282
|
+
keys.slice(0, 3).forEach((key) => {
|
|
283
|
+
res.push(...formatProp(key, props[key]));
|
|
284
|
+
});
|
|
285
|
+
if (keys.length > 3) res.push(` ...`);
|
|
286
|
+
return res;
|
|
320
287
|
}
|
|
321
288
|
function formatProp(key, value, raw) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
|
|
289
|
+
if (isString(value)) {
|
|
290
|
+
value = JSON.stringify(value);
|
|
291
|
+
return raw ? value : [`${key}=${value}`];
|
|
292
|
+
} else if (typeof value === "number" || typeof value === "boolean" || value == null) return raw ? value : [`${key}=${value}`];
|
|
293
|
+
else if (/* @__PURE__ */ isRef(value)) {
|
|
294
|
+
value = formatProp(key, /* @__PURE__ */ toRaw(value.value), true);
|
|
295
|
+
return raw ? value : [
|
|
296
|
+
`${key}=Ref<`,
|
|
297
|
+
value,
|
|
298
|
+
`>`
|
|
299
|
+
];
|
|
300
|
+
} else if (isFunction(value)) return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
301
|
+
else {
|
|
302
|
+
value = /* @__PURE__ */ toRaw(value);
|
|
303
|
+
return raw ? value : [`${key}=`, value];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/* v8 ignore stop */
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region packages/runtime-core/src/errorHandling.ts
|
|
338
309
|
const ErrorTypeStrings = {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
310
|
+
["sp"]: "serverPrefetch hook",
|
|
311
|
+
["bc"]: "beforeCreate hook",
|
|
312
|
+
["c"]: "created hook",
|
|
313
|
+
["bm"]: "beforeMount hook",
|
|
314
|
+
["m"]: "mounted hook",
|
|
315
|
+
["bu"]: "beforeUpdate hook",
|
|
316
|
+
["u"]: "updated",
|
|
317
|
+
["bum"]: "beforeUnmount hook",
|
|
318
|
+
["um"]: "unmounted hook",
|
|
319
|
+
["a"]: "activated hook",
|
|
320
|
+
["da"]: "deactivated hook",
|
|
321
|
+
["ec"]: "errorCaptured hook",
|
|
322
|
+
["rtc"]: "renderTracked hook",
|
|
323
|
+
["rtg"]: "renderTriggered hook",
|
|
324
|
+
[0]: "setup function",
|
|
325
|
+
[1]: "render function",
|
|
326
|
+
[2]: "watcher getter",
|
|
327
|
+
[3]: "watcher callback",
|
|
328
|
+
[4]: "watcher cleanup function",
|
|
329
|
+
[5]: "native event handler",
|
|
330
|
+
[6]: "component event handler",
|
|
331
|
+
[7]: "vnode hook",
|
|
332
|
+
[8]: "directive hook",
|
|
333
|
+
[9]: "transition hook",
|
|
334
|
+
[10]: "app errorHandler",
|
|
335
|
+
[11]: "app warnHandler",
|
|
336
|
+
[12]: "ref function",
|
|
337
|
+
[13]: "async component loader",
|
|
338
|
+
[14]: "scheduler flush",
|
|
339
|
+
[15]: "component update",
|
|
340
|
+
[16]: "app unmount cleanup function"
|
|
370
341
|
};
|
|
371
342
|
function callWithErrorHandling(fn, instance, type, args) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
343
|
+
try {
|
|
344
|
+
return args ? fn(...args) : fn();
|
|
345
|
+
} catch (err) {
|
|
346
|
+
handleError(err, instance, type);
|
|
347
|
+
}
|
|
377
348
|
}
|
|
378
349
|
function handleError(err, instance, type, throwInDev = true) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction);
|
|
350
|
+
const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ;
|
|
351
|
+
if (instance) {
|
|
352
|
+
let cur = instance.parent;
|
|
353
|
+
const exposedInstance = instance.proxy || instance;
|
|
354
|
+
const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : `https://vuejs.org/error-reference/#runtime-${type}`;
|
|
355
|
+
while (cur) {
|
|
356
|
+
const errorCapturedHooks = cur.ec;
|
|
357
|
+
if (errorCapturedHooks) {
|
|
358
|
+
for (let i = 0; i < errorCapturedHooks.length; i++) if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) return;
|
|
359
|
+
}
|
|
360
|
+
cur = cur.parent;
|
|
361
|
+
}
|
|
362
|
+
if (errorHandler) {
|
|
363
|
+
const prevSub = setActiveSub();
|
|
364
|
+
callWithErrorHandling(errorHandler, null, 10, [
|
|
365
|
+
err,
|
|
366
|
+
exposedInstance,
|
|
367
|
+
errorInfo
|
|
368
|
+
]);
|
|
369
|
+
setActiveSub(prevSub);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction);
|
|
407
374
|
}
|
|
408
375
|
function logError(err, type, instance, throwInDev = true, throwInProd = false) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
console.error(err);
|
|
422
|
-
}
|
|
423
|
-
} else if (throwInProd) {
|
|
424
|
-
throw err;
|
|
425
|
-
} else {
|
|
426
|
-
console.error(err);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
376
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
377
|
+
const info = ErrorTypeStrings[type];
|
|
378
|
+
if (instance) pushWarningContext$1(instance);
|
|
379
|
+
warn$2(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
380
|
+
if (instance) popWarningContext$1();
|
|
381
|
+
if (throwInDev) throw err;
|
|
382
|
+
else console.error(err);
|
|
383
|
+
} else if (throwInProd) throw err;
|
|
384
|
+
else console.error(err);
|
|
385
|
+
}
|
|
386
|
+
//#endregion
|
|
387
|
+
//#region packages/runtime-core/src/scheduler.ts
|
|
430
388
|
const jobs = [];
|
|
431
389
|
let postJobs = [];
|
|
432
390
|
let activePostJobs = null;
|
|
@@ -437,1261 +395,949 @@ let postFlushIndex = 0;
|
|
|
437
395
|
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
438
396
|
const RECURSION_LIMIT = 100;
|
|
439
397
|
function nextTick(fn) {
|
|
440
|
-
|
|
441
|
-
|
|
398
|
+
const p = currentFlushPromise || resolvedPromise;
|
|
399
|
+
return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
|
442
400
|
}
|
|
443
401
|
function findInsertionIndex(order, queue, start, end) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return start;
|
|
402
|
+
while (start < end) {
|
|
403
|
+
const middle = start + end >>> 1;
|
|
404
|
+
if (queue[middle].order <= order) start = middle + 1;
|
|
405
|
+
else end = middle;
|
|
406
|
+
}
|
|
407
|
+
return start;
|
|
453
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* @internal for runtime-vapor only
|
|
411
|
+
*/
|
|
454
412
|
function queueJob(job, id, isPre = false) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
job.order = order;
|
|
471
|
-
if (flushIndex2 === length || // fast path when the job id is larger than the tail
|
|
472
|
-
order >= queue[length - 1].order) {
|
|
473
|
-
queue[length] = job;
|
|
474
|
-
} else {
|
|
475
|
-
queue.splice(findInsertionIndex(order, queue, flushIndex2, length), 0, job);
|
|
476
|
-
}
|
|
477
|
-
return true;
|
|
478
|
-
}
|
|
479
|
-
return false;
|
|
413
|
+
if (queueJobWorker(job, id === void 0 ? isPre ? -2 : Infinity : isPre ? id * 2 : id * 2 + 1, jobs, jobsLength, flushIndex)) {
|
|
414
|
+
jobsLength++;
|
|
415
|
+
queueFlush();
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function queueJobWorker(job, order, queue, length, flushIndex) {
|
|
419
|
+
const flags = job.flags;
|
|
420
|
+
if (!(flags & 1)) {
|
|
421
|
+
job.flags = flags | 1;
|
|
422
|
+
job.order = order;
|
|
423
|
+
if (flushIndex === length || order >= queue[length - 1].order) queue[length] = job;
|
|
424
|
+
else queue.splice(findInsertionIndex(order, queue, flushIndex, length), 0, job);
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
480
428
|
}
|
|
481
429
|
const doFlushJobs = () => {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
430
|
+
try {
|
|
431
|
+
flushJobs();
|
|
432
|
+
} catch (e) {
|
|
433
|
+
currentFlushPromise = null;
|
|
434
|
+
throw e;
|
|
435
|
+
}
|
|
488
436
|
};
|
|
489
437
|
function queueFlush() {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
activePostJobs.splice(postFlushIndex, 0, jobs2);
|
|
498
|
-
} else {
|
|
499
|
-
queueJobWorker(jobs2, id, postJobs, postJobs.length, 0);
|
|
500
|
-
}
|
|
501
|
-
} else {
|
|
502
|
-
for (const job of jobs2) {
|
|
503
|
-
queueJobWorker(job, id, postJobs, postJobs.length, 0);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
queueFlush();
|
|
438
|
+
if (!currentFlushPromise) currentFlushPromise = resolvedPromise.then(doFlushJobs);
|
|
439
|
+
}
|
|
440
|
+
function queuePostFlushCb(jobs, id = Infinity) {
|
|
441
|
+
if (!isArray(jobs)) if (activePostJobs && id === -1) activePostJobs.splice(postFlushIndex, 0, jobs);
|
|
442
|
+
else queueJobWorker(jobs, id, postJobs, postJobs.length, 0);
|
|
443
|
+
else for (const job of jobs) queueJobWorker(job, id, postJobs, postJobs.length, 0);
|
|
444
|
+
queueFlush();
|
|
507
445
|
}
|
|
508
446
|
function flushPostFlushCbs(seen) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
} finally {
|
|
532
|
-
cb.flags &= -2;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
activePostJobs = null;
|
|
537
|
-
postFlushIndex = 0;
|
|
538
|
-
}
|
|
447
|
+
if (postJobs.length) {
|
|
448
|
+
if (activePostJobs) {
|
|
449
|
+
activePostJobs.push(...postJobs);
|
|
450
|
+
postJobs.length = 0;
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
activePostJobs = postJobs;
|
|
454
|
+
postJobs = [];
|
|
455
|
+
if (!!(process.env.NODE_ENV !== "production")) seen = seen || /* @__PURE__ */ new Map();
|
|
456
|
+
while (postFlushIndex < activePostJobs.length) {
|
|
457
|
+
const cb = activePostJobs[postFlushIndex++];
|
|
458
|
+
if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) continue;
|
|
459
|
+
if (cb.flags & 2) cb.flags &= -2;
|
|
460
|
+
if (!(cb.flags & 4)) try {
|
|
461
|
+
cb();
|
|
462
|
+
} finally {
|
|
463
|
+
cb.flags &= -2;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
activePostJobs = null;
|
|
467
|
+
postFlushIndex = 0;
|
|
468
|
+
}
|
|
539
469
|
}
|
|
540
470
|
function flushJobs(seen) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
} finally {
|
|
571
|
-
while (flushIndex < jobsLength) {
|
|
572
|
-
jobs[flushIndex].flags &= -2;
|
|
573
|
-
jobs[flushIndex++] = void 0;
|
|
574
|
-
}
|
|
575
|
-
flushIndex = 0;
|
|
576
|
-
jobsLength = 0;
|
|
577
|
-
flushPostFlushCbs(seen);
|
|
578
|
-
currentFlushPromise = null;
|
|
579
|
-
if (jobsLength || postJobs.length) {
|
|
580
|
-
flushJobs(seen);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
471
|
+
if (!!(process.env.NODE_ENV !== "production")) seen || (seen = /* @__PURE__ */ new Map());
|
|
472
|
+
try {
|
|
473
|
+
while (flushIndex < jobsLength) {
|
|
474
|
+
const job = jobs[flushIndex];
|
|
475
|
+
jobs[flushIndex++] = void 0;
|
|
476
|
+
if (!(job.flags & 4)) {
|
|
477
|
+
if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, job)) continue;
|
|
478
|
+
if (job.flags & 2) job.flags &= -2;
|
|
479
|
+
try {
|
|
480
|
+
job();
|
|
481
|
+
} catch (err) {
|
|
482
|
+
handleError(err, job.i, job.i ? 15 : 14);
|
|
483
|
+
} finally {
|
|
484
|
+
if (!(job.flags & 2)) job.flags &= -2;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
} finally {
|
|
489
|
+
while (flushIndex < jobsLength) {
|
|
490
|
+
jobs[flushIndex].flags &= -2;
|
|
491
|
+
jobs[flushIndex++] = void 0;
|
|
492
|
+
}
|
|
493
|
+
flushIndex = 0;
|
|
494
|
+
jobsLength = 0;
|
|
495
|
+
flushPostFlushCbs(seen);
|
|
496
|
+
currentFlushPromise = null;
|
|
497
|
+
if (jobsLength || postJobs.length) flushJobs(seen);
|
|
498
|
+
}
|
|
583
499
|
}
|
|
584
500
|
function checkRecursiveUpdates(seen, fn) {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
return false;
|
|
598
|
-
}
|
|
599
|
-
|
|
501
|
+
const count = seen.get(fn) || 0;
|
|
502
|
+
if (count > RECURSION_LIMIT) {
|
|
503
|
+
const instance = fn.i;
|
|
504
|
+
const componentName = instance && getComponentName(instance.type);
|
|
505
|
+
handleError(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`, null, 10);
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
seen.set(fn, count + 1);
|
|
509
|
+
return false;
|
|
510
|
+
}
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region packages/runtime-core/src/hmr.ts
|
|
600
513
|
let isHmrUpdating = false;
|
|
601
514
|
const hmrDirtyComponents = /* @__PURE__ */ new Map();
|
|
602
515
|
const hmrDirtyComponentsMode = /* @__PURE__ */ new Map();
|
|
603
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
};
|
|
609
|
-
}
|
|
516
|
+
if (!!(process.env.NODE_ENV !== "production")) getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
|
517
|
+
createRecord: tryWrap(createRecord),
|
|
518
|
+
rerender: tryWrap(rerender),
|
|
519
|
+
reload: tryWrap(reload)
|
|
520
|
+
};
|
|
610
521
|
const map = /* @__PURE__ */ new Map();
|
|
611
522
|
function createRecord(id, initialDef) {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
});
|
|
619
|
-
return true;
|
|
523
|
+
if (map.has(id)) return false;
|
|
524
|
+
map.set(id, {
|
|
525
|
+
initialDef: normalizeClassComponent(initialDef),
|
|
526
|
+
instances: /* @__PURE__ */ new Set()
|
|
527
|
+
});
|
|
528
|
+
return true;
|
|
620
529
|
}
|
|
621
530
|
function normalizeClassComponent(component) {
|
|
622
|
-
|
|
531
|
+
return isClassComponent(component) ? component.__vccOpts : component;
|
|
623
532
|
}
|
|
624
533
|
function rerender(id, newRender) {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
});
|
|
648
|
-
});
|
|
534
|
+
const record = map.get(id);
|
|
535
|
+
if (!record) return;
|
|
536
|
+
record.initialDef.render = newRender;
|
|
537
|
+
[...record.instances].forEach((instance) => {
|
|
538
|
+
if (newRender) {
|
|
539
|
+
instance.render = newRender;
|
|
540
|
+
normalizeClassComponent(instance.type).render = newRender;
|
|
541
|
+
}
|
|
542
|
+
isHmrUpdating = true;
|
|
543
|
+
if (instance.vapor) {
|
|
544
|
+
if (!instance.isUnmounted) instance.hmrRerender();
|
|
545
|
+
} else {
|
|
546
|
+
const i = instance;
|
|
547
|
+
if (!(i.effect.flags & 1024)) {
|
|
548
|
+
i.renderCache = [];
|
|
549
|
+
i.effect.run();
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
nextTick(() => {
|
|
553
|
+
isHmrUpdating = false;
|
|
554
|
+
});
|
|
555
|
+
});
|
|
649
556
|
}
|
|
650
557
|
function reload(id, newComp) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
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
|
-
isHmrUpdating = false;
|
|
699
|
-
});
|
|
700
|
-
dirtyInstances.delete(instance);
|
|
701
|
-
});
|
|
702
|
-
} else if (instance.appContext.reload) {
|
|
703
|
-
instance.appContext.reload();
|
|
704
|
-
} else if (typeof window !== "undefined") {
|
|
705
|
-
window.location.reload();
|
|
706
|
-
} else {
|
|
707
|
-
console.warn(
|
|
708
|
-
"[HMR] Root or manually mounted instance modified. Full reload required."
|
|
709
|
-
);
|
|
710
|
-
}
|
|
711
|
-
if (instance.root.ce && instance !== instance.root) {
|
|
712
|
-
instance.root.ce._removeChildStyle(oldComp);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
queuePostFlushCb(() => {
|
|
717
|
-
hmrDirtyComponents.clear();
|
|
718
|
-
hmrDirtyComponentsMode.clear();
|
|
719
|
-
});
|
|
558
|
+
const record = map.get(id);
|
|
559
|
+
if (!record) return;
|
|
560
|
+
newComp = normalizeClassComponent(newComp);
|
|
561
|
+
const isVapor = record.initialDef.__vapor;
|
|
562
|
+
updateComponentDef(record.initialDef, newComp);
|
|
563
|
+
const instances = [...record.instances];
|
|
564
|
+
if (isVapor && newComp.__vapor && !instances.some((i) => i.ceReload)) {
|
|
565
|
+
for (const instance of instances) if (instance.root && instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(instance.type);
|
|
566
|
+
for (const instance of instances) instance.hmrReload(newComp);
|
|
567
|
+
} else for (const instance of instances) {
|
|
568
|
+
const oldComp = normalizeClassComponent(instance.type);
|
|
569
|
+
let dirtyInstances = hmrDirtyComponents.get(oldComp);
|
|
570
|
+
if (!dirtyInstances) {
|
|
571
|
+
if (oldComp !== record.initialDef) updateComponentDef(oldComp, newComp);
|
|
572
|
+
hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
|
|
573
|
+
}
|
|
574
|
+
dirtyInstances.add(instance);
|
|
575
|
+
hmrDirtyComponentsMode.set(oldComp, !!isVapor);
|
|
576
|
+
instance.appContext.propsCache.delete(instance.type);
|
|
577
|
+
instance.appContext.emitsCache.delete(instance.type);
|
|
578
|
+
instance.appContext.optionsCache.delete(instance.type);
|
|
579
|
+
if (instance.ceReload) {
|
|
580
|
+
dirtyInstances.add(instance);
|
|
581
|
+
instance.ceReload(newComp.styles);
|
|
582
|
+
dirtyInstances.delete(instance);
|
|
583
|
+
} else if (instance.parent) queueJob(() => {
|
|
584
|
+
isHmrUpdating = true;
|
|
585
|
+
const parent = instance.parent;
|
|
586
|
+
if (parent.vapor) parent.hmrRerender();
|
|
587
|
+
else if (!(parent.effect.flags & 1024)) {
|
|
588
|
+
parent.renderCache = [];
|
|
589
|
+
parent.effect.run();
|
|
590
|
+
}
|
|
591
|
+
nextTick(() => {
|
|
592
|
+
isHmrUpdating = false;
|
|
593
|
+
});
|
|
594
|
+
dirtyInstances.delete(instance);
|
|
595
|
+
});
|
|
596
|
+
else if (instance.appContext.reload) instance.appContext.reload();
|
|
597
|
+
else if (typeof window !== "undefined") window.location.reload();
|
|
598
|
+
else console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
|
|
599
|
+
if (instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(oldComp);
|
|
600
|
+
}
|
|
601
|
+
queuePostFlushCb(() => {
|
|
602
|
+
hmrDirtyComponents.clear();
|
|
603
|
+
hmrDirtyComponentsMode.clear();
|
|
604
|
+
});
|
|
720
605
|
}
|
|
721
606
|
function updateComponentDef(oldComp, newComp) {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
if (key !== "__file" && !(key in newComp)) {
|
|
725
|
-
delete oldComp[key];
|
|
726
|
-
}
|
|
727
|
-
}
|
|
607
|
+
extend(oldComp, newComp);
|
|
608
|
+
for (const key in oldComp) if (key !== "__file" && !(key in newComp)) delete oldComp[key];
|
|
728
609
|
}
|
|
729
610
|
function tryWrap(fn) {
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
let devtools;
|
|
611
|
+
return (id, arg) => {
|
|
612
|
+
try {
|
|
613
|
+
return fn(id, arg);
|
|
614
|
+
} catch (e) {
|
|
615
|
+
console.error(e);
|
|
616
|
+
console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required.");
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region packages/runtime-core/src/devtools.ts
|
|
622
|
+
let devtools$1;
|
|
743
623
|
let buffer = [];
|
|
744
|
-
function setDevtoolsHook(hook, target) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
}, 3e3);
|
|
770
|
-
} else {
|
|
771
|
-
buffer = [];
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
624
|
+
function setDevtoolsHook$1(hook, target) {
|
|
625
|
+
var _window$navigator;
|
|
626
|
+
devtools$1 = hook;
|
|
627
|
+
if (devtools$1) {
|
|
628
|
+
devtools$1.enabled = true;
|
|
629
|
+
buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
|
|
630
|
+
buffer = [];
|
|
631
|
+
} else if (typeof window !== "undefined" && window.HTMLElement && !((_window$navigator = window.navigator) === null || _window$navigator === void 0 || (_window$navigator = _window$navigator.userAgent) === null || _window$navigator === void 0 ? void 0 : _window$navigator.includes("jsdom"))) {
|
|
632
|
+
(target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((newHook) => {
|
|
633
|
+
setDevtoolsHook$1(newHook, target);
|
|
634
|
+
});
|
|
635
|
+
setTimeout(() => {
|
|
636
|
+
if (!devtools$1) {
|
|
637
|
+
target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
|
638
|
+
buffer = [];
|
|
639
|
+
}
|
|
640
|
+
}, 3e3);
|
|
641
|
+
} else buffer = [];
|
|
642
|
+
}
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region packages/runtime-core/src/componentRenderContext.ts
|
|
645
|
+
/**
|
|
646
|
+
* mark the current rendering instance for asset resolution (e.g.
|
|
647
|
+
* resolveComponent, resolveDirective) during render
|
|
648
|
+
*/
|
|
775
649
|
let currentRenderingInstance = null;
|
|
776
650
|
let currentScopeId = null;
|
|
777
|
-
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region packages/runtime-core/src/components/Teleport.ts
|
|
778
653
|
const isTeleport = (type) => type.__isTeleport;
|
|
779
|
-
|
|
654
|
+
//#endregion
|
|
655
|
+
//#region packages/runtime-core/src/components/BaseTransition.ts
|
|
780
656
|
function setTransitionHooks(vnode, hooks) {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
657
|
+
if (vnode.shapeFlag & 6 && vnode.component) if (isVaporComponent(vnode.type)) getVaporInterface(vnode.component, vnode).setTransitionHooks(vnode.component, hooks);
|
|
658
|
+
else {
|
|
659
|
+
vnode.transition = hooks;
|
|
660
|
+
setTransitionHooks(vnode.component.subTree, hooks);
|
|
661
|
+
}
|
|
662
|
+
else if (vnode.shapeFlag & 128) {
|
|
663
|
+
vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
|
664
|
+
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
|
665
|
+
} else vnode.transition = hooks;
|
|
666
|
+
}
|
|
667
|
+
//#endregion
|
|
668
|
+
//#region packages/runtime-core/src/helpers/resolveAssets.ts
|
|
669
|
+
const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region packages/runtime-core/src/internalObject.ts
|
|
672
|
+
/**
|
|
673
|
+
* Used during vnode props/slots normalization to check if the vnode props/slots
|
|
674
|
+
* are the internal attrs / slots object of a component via
|
|
675
|
+
* `Object.getPrototypeOf`. This is more performant than defining a
|
|
676
|
+
* non-enumerable property. (one of the optimizations done for ssr-benchmark)
|
|
677
|
+
*/
|
|
801
678
|
const internalObjectProto = {};
|
|
802
679
|
const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
|
|
803
|
-
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region packages/runtime-core/src/renderer.ts
|
|
804
682
|
function getVaporInterface(instance, vnode) {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
`Vapor component found in vdom tree but vapor-in-vdom interop was not installed. Make sure to install it:
|
|
810
|
-
\`\`\`
|
|
811
|
-
import { vaporInteropPlugin } from 'vue'
|
|
812
|
-
app.use(vaporInteropPlugin)
|
|
813
|
-
\`\`\``
|
|
814
|
-
);
|
|
815
|
-
}
|
|
816
|
-
return res;
|
|
683
|
+
const ctx = instance ? instance.appContext : vnode.appContext;
|
|
684
|
+
const res = ctx && ctx.vapor;
|
|
685
|
+
if (!!(process.env.NODE_ENV !== "production") && !res) warn$2("Vapor component found in vdom tree but vapor-in-vdom interop was not installed. Make sure to install it:\n```\nimport { vaporInteropPlugin } from 'vue'\napp.use(vaporInteropPlugin)\n```");
|
|
686
|
+
return res;
|
|
817
687
|
}
|
|
818
688
|
function isVaporComponent(type) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}
|
|
822
|
-
return type.__vapor;
|
|
689
|
+
if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating && hmrDirtyComponentsMode.has(type)) return hmrDirtyComponentsMode.get(type);
|
|
690
|
+
return type.__vapor;
|
|
823
691
|
}
|
|
824
|
-
|
|
692
|
+
//#endregion
|
|
693
|
+
//#region packages/runtime-core/src/components/Suspense.ts
|
|
825
694
|
const isSuspense = (type) => type.__isSuspense;
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
const
|
|
829
|
-
const
|
|
695
|
+
//#endregion
|
|
696
|
+
//#region packages/runtime-core/src/vnode.ts
|
|
697
|
+
const Fragment$1 = Symbol.for("v-fgt");
|
|
698
|
+
const Text$1 = Symbol.for("v-txt");
|
|
699
|
+
const Comment$1 = Symbol.for("v-cmt");
|
|
830
700
|
function isVNode$2(value) {
|
|
831
|
-
|
|
701
|
+
return value ? value.__v_isVNode === true : false;
|
|
832
702
|
}
|
|
833
703
|
const createVNodeWithArgsTransform = (...args) => {
|
|
834
|
-
|
|
835
|
-
...args
|
|
836
|
-
);
|
|
704
|
+
return _createVNode(...args);
|
|
837
705
|
};
|
|
838
706
|
const normalizeKey = ({ key }) => key != null ? key : null;
|
|
839
707
|
const normalizeRef = ({ ref, ref_key, ref_for }, i = currentRenderingInstance) => {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
708
|
+
if (typeof ref === "number") ref = "" + ref;
|
|
709
|
+
return ref != null ? isString(ref) || /* @__PURE__ */ isRef(ref) || isFunction(ref) ? {
|
|
710
|
+
i,
|
|
711
|
+
r: ref,
|
|
712
|
+
k: ref_key,
|
|
713
|
+
f: !!ref_for
|
|
714
|
+
} : ref : null;
|
|
844
715
|
};
|
|
845
|
-
function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
if (!!(process.env.NODE_ENV !== "production") && vnode.key !== vnode.key) {
|
|
884
|
-
warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
|
885
|
-
}
|
|
886
|
-
return vnode;
|
|
887
|
-
}
|
|
888
|
-
const createVNode = !!(process.env.NODE_ENV !== "production") ? createVNodeWithArgsTransform : _createVNode;
|
|
716
|
+
function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment$1 ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
|
717
|
+
const vnode = {
|
|
718
|
+
__v_isVNode: true,
|
|
719
|
+
__v_skip: true,
|
|
720
|
+
type,
|
|
721
|
+
props,
|
|
722
|
+
key: props && normalizeKey(props),
|
|
723
|
+
ref: props && normalizeRef(props),
|
|
724
|
+
scopeId: currentScopeId,
|
|
725
|
+
slotScopeIds: null,
|
|
726
|
+
children,
|
|
727
|
+
component: null,
|
|
728
|
+
suspense: null,
|
|
729
|
+
ssContent: null,
|
|
730
|
+
ssFallback: null,
|
|
731
|
+
dirs: null,
|
|
732
|
+
transition: null,
|
|
733
|
+
el: null,
|
|
734
|
+
anchor: null,
|
|
735
|
+
target: null,
|
|
736
|
+
targetStart: null,
|
|
737
|
+
targetAnchor: null,
|
|
738
|
+
staticCount: 0,
|
|
739
|
+
shapeFlag,
|
|
740
|
+
patchFlag,
|
|
741
|
+
dynamicProps,
|
|
742
|
+
dynamicChildren: null,
|
|
743
|
+
appContext: null,
|
|
744
|
+
ctx: currentRenderingInstance
|
|
745
|
+
};
|
|
746
|
+
if (needFullChildrenNormalization) {
|
|
747
|
+
normalizeChildren(vnode, children);
|
|
748
|
+
if (shapeFlag & 128) type.normalize(vnode);
|
|
749
|
+
} else if (children) vnode.shapeFlag |= isString(children) ? 8 : 16;
|
|
750
|
+
if (!!(process.env.NODE_ENV !== "production") && vnode.key !== vnode.key) warn$2(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
|
|
751
|
+
return vnode;
|
|
752
|
+
}
|
|
753
|
+
const createVNode$1 = !!(process.env.NODE_ENV !== "production") ? createVNodeWithArgsTransform : _createVNode;
|
|
889
754
|
function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
props.class = normalizeClass(klass);
|
|
917
|
-
}
|
|
918
|
-
if (isObject(style)) {
|
|
919
|
-
if (isProxy(style) && !isArray(style)) {
|
|
920
|
-
style = extend({}, style);
|
|
921
|
-
}
|
|
922
|
-
props.style = normalizeStyle(style);
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
|
|
926
|
-
if (!!(process.env.NODE_ENV !== "production") && shapeFlag & 4 && isProxy(type)) {
|
|
927
|
-
type = toRaw(type);
|
|
928
|
-
warn$1(
|
|
929
|
-
`Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
|
|
930
|
-
`
|
|
931
|
-
Component that was made reactive: `,
|
|
932
|
-
type
|
|
933
|
-
);
|
|
934
|
-
}
|
|
935
|
-
return createBaseVNode(
|
|
936
|
-
type,
|
|
937
|
-
props,
|
|
938
|
-
children,
|
|
939
|
-
patchFlag,
|
|
940
|
-
dynamicProps,
|
|
941
|
-
shapeFlag,
|
|
942
|
-
isBlockNode,
|
|
943
|
-
true
|
|
944
|
-
);
|
|
755
|
+
if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
|
756
|
+
if (!!(process.env.NODE_ENV !== "production") && !type) warn$2(`Invalid vnode type when creating vnode: ${type}.`);
|
|
757
|
+
type = Comment$1;
|
|
758
|
+
}
|
|
759
|
+
if (isVNode$2(type)) {
|
|
760
|
+
const cloned = cloneVNode(type, props, true);
|
|
761
|
+
if (children) normalizeChildren(cloned, children);
|
|
762
|
+
cloned.patchFlag = -2;
|
|
763
|
+
return cloned;
|
|
764
|
+
}
|
|
765
|
+
if (isClassComponent(type)) type = type.__vccOpts;
|
|
766
|
+
if (props) {
|
|
767
|
+
props = guardReactiveProps(props);
|
|
768
|
+
let { class: klass, style } = props;
|
|
769
|
+
if (klass && !isString(klass)) props.class = normalizeClass(klass);
|
|
770
|
+
if (isObject(style)) {
|
|
771
|
+
if (/* @__PURE__ */ isProxy(style) && !isArray(style)) style = extend({}, style);
|
|
772
|
+
props.style = normalizeStyle(style);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
|
|
776
|
+
if (!!(process.env.NODE_ENV !== "production") && shapeFlag & 4 && /* @__PURE__ */ isProxy(type)) {
|
|
777
|
+
type = /* @__PURE__ */ toRaw(type);
|
|
778
|
+
warn$2("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", `\nComponent that was made reactive: `, type);
|
|
779
|
+
}
|
|
780
|
+
return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
|
|
945
781
|
}
|
|
946
782
|
function guardReactiveProps(props) {
|
|
947
|
-
|
|
948
|
-
|
|
783
|
+
if (!props) return null;
|
|
784
|
+
return /* @__PURE__ */ isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
|
|
949
785
|
}
|
|
950
786
|
function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
// they will simply be overwritten.
|
|
987
|
-
component: vnode.component,
|
|
988
|
-
suspense: vnode.suspense,
|
|
989
|
-
ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
|
990
|
-
ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
|
991
|
-
placeholder: vnode.placeholder,
|
|
992
|
-
el: vnode.el,
|
|
993
|
-
anchor: vnode.anchor,
|
|
994
|
-
ctx: vnode.ctx,
|
|
995
|
-
ce: vnode.ce
|
|
996
|
-
};
|
|
997
|
-
if (transition && cloneTransition) {
|
|
998
|
-
setTransitionHooks(
|
|
999
|
-
cloned,
|
|
1000
|
-
transition.clone(cloned)
|
|
1001
|
-
);
|
|
1002
|
-
}
|
|
1003
|
-
return cloned;
|
|
787
|
+
const { props, ref, patchFlag, children, transition } = vnode;
|
|
788
|
+
const mergedProps = extraProps ? mergeProps$1(props || {}, extraProps) : props;
|
|
789
|
+
const cloned = {
|
|
790
|
+
__v_isVNode: true,
|
|
791
|
+
__v_skip: true,
|
|
792
|
+
type: vnode.type,
|
|
793
|
+
props: mergedProps,
|
|
794
|
+
key: mergedProps && normalizeKey(mergedProps),
|
|
795
|
+
ref: extraProps && extraProps.ref ? mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps) : ref,
|
|
796
|
+
scopeId: vnode.scopeId,
|
|
797
|
+
slotScopeIds: vnode.slotScopeIds,
|
|
798
|
+
children: !!(process.env.NODE_ENV !== "production") && patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
|
|
799
|
+
target: vnode.target,
|
|
800
|
+
targetStart: vnode.targetStart,
|
|
801
|
+
targetAnchor: vnode.targetAnchor,
|
|
802
|
+
staticCount: vnode.staticCount,
|
|
803
|
+
shapeFlag: vnode.shapeFlag,
|
|
804
|
+
patchFlag: extraProps && vnode.type !== Fragment$1 ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
|
805
|
+
dynamicProps: vnode.dynamicProps,
|
|
806
|
+
dynamicChildren: vnode.dynamicChildren,
|
|
807
|
+
appContext: vnode.appContext,
|
|
808
|
+
dirs: vnode.dirs,
|
|
809
|
+
transition,
|
|
810
|
+
component: vnode.component,
|
|
811
|
+
suspense: vnode.suspense,
|
|
812
|
+
ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
|
813
|
+
ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
|
814
|
+
placeholder: vnode.placeholder,
|
|
815
|
+
el: vnode.el,
|
|
816
|
+
anchor: vnode.anchor,
|
|
817
|
+
ctx: vnode.ctx,
|
|
818
|
+
ce: vnode.ce
|
|
819
|
+
};
|
|
820
|
+
if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
|
|
821
|
+
return cloned;
|
|
1004
822
|
}
|
|
823
|
+
/**
|
|
824
|
+
* Dev only, for HMR of hoisted vnodes reused in v-for
|
|
825
|
+
* https://github.com/vitejs/vite/issues/2022
|
|
826
|
+
*/
|
|
1005
827
|
function deepCloneVNode(vnode) {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
}
|
|
1010
|
-
return cloned;
|
|
828
|
+
const cloned = cloneVNode(vnode);
|
|
829
|
+
if (isArray(vnode.children)) cloned.children = vnode.children.map(deepCloneVNode);
|
|
830
|
+
return cloned;
|
|
1011
831
|
}
|
|
832
|
+
/**
|
|
833
|
+
* @private
|
|
834
|
+
*/
|
|
1012
835
|
function createTextVNode(text = " ", flag = 0) {
|
|
1013
|
-
|
|
836
|
+
return createVNode$1(Text$1, null, text, flag);
|
|
1014
837
|
}
|
|
1015
838
|
function normalizeChildren(vnode, children) {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
const existing = ret[key];
|
|
1066
|
-
const incoming = toMerge[key];
|
|
1067
|
-
if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
|
|
1068
|
-
ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
|
1069
|
-
}
|
|
1070
|
-
} else if (key !== "") {
|
|
1071
|
-
ret[key] = toMerge[key];
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return ret;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
!!(process.env.NODE_ENV !== "production") ? {
|
|
1079
|
-
} : {
|
|
1080
|
-
};
|
|
839
|
+
let type = 0;
|
|
840
|
+
const { shapeFlag } = vnode;
|
|
841
|
+
if (children == null) children = null;
|
|
842
|
+
else if (isArray(children)) type = 16;
|
|
843
|
+
else if (typeof children === "object") if (shapeFlag & 65) {
|
|
844
|
+
const slot = children.default;
|
|
845
|
+
if (slot) {
|
|
846
|
+
slot._c && (slot._d = false);
|
|
847
|
+
normalizeChildren(vnode, slot());
|
|
848
|
+
slot._c && (slot._d = true);
|
|
849
|
+
}
|
|
850
|
+
return;
|
|
851
|
+
} else {
|
|
852
|
+
type = 32;
|
|
853
|
+
if (!children._ && !isInternalObject(children)) children._ctx = currentRenderingInstance;
|
|
854
|
+
}
|
|
855
|
+
else if (isFunction(children)) {
|
|
856
|
+
children = {
|
|
857
|
+
default: children,
|
|
858
|
+
_ctx: currentRenderingInstance
|
|
859
|
+
};
|
|
860
|
+
type = 32;
|
|
861
|
+
} else {
|
|
862
|
+
children = String(children);
|
|
863
|
+
if (shapeFlag & 64) {
|
|
864
|
+
type = 16;
|
|
865
|
+
children = [createTextVNode(children)];
|
|
866
|
+
} else type = 8;
|
|
867
|
+
}
|
|
868
|
+
vnode.children = children;
|
|
869
|
+
vnode.shapeFlag |= type;
|
|
870
|
+
}
|
|
871
|
+
function mergeProps$1(...args) {
|
|
872
|
+
const ret = {};
|
|
873
|
+
for (let i = 0; i < args.length; i++) {
|
|
874
|
+
const toMerge = args[i];
|
|
875
|
+
for (const key in toMerge) if (key === "class") {
|
|
876
|
+
if (ret.class !== toMerge.class) ret.class = normalizeClass([ret.class, toMerge.class]);
|
|
877
|
+
} else if (key === "style") ret.style = normalizeStyle([ret.style, toMerge.style]);
|
|
878
|
+
else if (isOn(key)) {
|
|
879
|
+
const existing = ret[key];
|
|
880
|
+
const incoming = toMerge[key];
|
|
881
|
+
if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
|
882
|
+
else if (incoming == null && existing == null && !isModelListener(key)) ret[key] = incoming;
|
|
883
|
+
} else if (key !== "") ret[key] = toMerge[key];
|
|
884
|
+
}
|
|
885
|
+
return ret;
|
|
886
|
+
}
|
|
887
|
+
process.env.NODE_ENV;
|
|
1081
888
|
const classifyRE = /(?:^|[-_])\w/g;
|
|
1082
889
|
const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
1083
890
|
function getComponentName(Component, includeInferred = true) {
|
|
1084
|
-
|
|
891
|
+
return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
1085
892
|
}
|
|
1086
893
|
function formatComponentName(instance, Component, isRoot = false) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
1102
|
-
name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(
|
|
1103
|
-
instance.parent.type.components
|
|
1104
|
-
) || inferFromRegistry(instance.appContext.components);
|
|
1105
|
-
}
|
|
1106
|
-
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
894
|
+
let name = getComponentName(Component);
|
|
895
|
+
if (!name && Component.__file) {
|
|
896
|
+
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
897
|
+
if (match) name = match[1];
|
|
898
|
+
}
|
|
899
|
+
if (!name && instance) {
|
|
900
|
+
const inferFromRegistry = (registry) => {
|
|
901
|
+
for (const key in registry) if (registry[key] === Component) return key;
|
|
902
|
+
};
|
|
903
|
+
name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
|
904
|
+
}
|
|
905
|
+
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
1107
906
|
}
|
|
1108
907
|
function isClassComponent(value) {
|
|
1109
|
-
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
!!(process.env.NODE_ENV !== "production")
|
|
1114
|
-
|
|
1115
|
-
|
|
908
|
+
return isFunction(value) && "__vccOpts" in value;
|
|
909
|
+
}
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region packages/runtime-core/src/index.ts
|
|
912
|
+
const warn$1 = !!(process.env.NODE_ENV !== "production") ? warn$2 : NOOP;
|
|
913
|
+
process.env.NODE_ENV;
|
|
914
|
+
process.env.NODE_ENV;
|
|
915
|
+
//#endregion
|
|
916
|
+
//#region packages/server-renderer/src/helpers/ssrRenderList.ts
|
|
1116
917
|
function ssrRenderList(source, renderItem) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
for (let i = 0, l = keys.length; i < l; i++) {
|
|
1138
|
-
const key = keys[i];
|
|
1139
|
-
renderItem(source[key], key, i);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
}
|
|
1144
|
-
|
|
918
|
+
if (isArray(source) || isString(source)) for (let i = 0, l = source.length; i < l; i++) renderItem(source[i], i);
|
|
919
|
+
else if (typeof source === "number") {
|
|
920
|
+
if (!!(process.env.NODE_ENV !== "production") && (!Number.isInteger(source) || source < 0)) {
|
|
921
|
+
warn$1(`The v-for range expects a positive integer value but got ${source}.`);
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
925
|
+
} else if (isObject(source)) if (source[Symbol.iterator]) {
|
|
926
|
+
const arr = Array.from(source);
|
|
927
|
+
for (let i = 0, l = arr.length; i < l; i++) renderItem(arr[i], i);
|
|
928
|
+
} else {
|
|
929
|
+
const keys = Object.keys(source);
|
|
930
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
931
|
+
const key = keys[i];
|
|
932
|
+
renderItem(source[key], key, i);
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
//#endregion
|
|
937
|
+
//#region packages/server-renderer/src/helpers/ssrRenderSuspense.ts
|
|
1145
938
|
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
} else {
|
|
1149
|
-
push(`<!---->`);
|
|
1150
|
-
}
|
|
939
|
+
if (renderContent) renderContent();
|
|
940
|
+
else push(`<!---->`);
|
|
1151
941
|
}
|
|
1152
|
-
|
|
942
|
+
//#endregion
|
|
943
|
+
//#region packages/server-renderer/src/helpers/ssrGetDirectiveProps.ts
|
|
1153
944
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
}
|
|
1167
|
-
return {};
|
|
1168
|
-
}
|
|
1169
|
-
|
|
945
|
+
if (typeof dir !== "function" && dir.getSSRProps) return dir.getSSRProps({
|
|
946
|
+
dir,
|
|
947
|
+
instance: ssrUtils.getComponentPublicInstance(instance.$),
|
|
948
|
+
value,
|
|
949
|
+
oldValue: void 0,
|
|
950
|
+
arg,
|
|
951
|
+
modifiers
|
|
952
|
+
}, null) || {};
|
|
953
|
+
return {};
|
|
954
|
+
}
|
|
955
|
+
//#endregion
|
|
956
|
+
//#region packages/server-renderer/src/helpers/ssrVModelHelpers.ts
|
|
1170
957
|
const ssrLooseEqual = looseEqual;
|
|
1171
958
|
function ssrLooseContain(arr, value) {
|
|
1172
|
-
|
|
959
|
+
return looseIndexOf(arr, value) > -1;
|
|
1173
960
|
}
|
|
1174
961
|
function ssrRenderDynamicModel(type, model, value) {
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
default:
|
|
1181
|
-
return ssrRenderAttr("value", model);
|
|
1182
|
-
}
|
|
962
|
+
switch (type) {
|
|
963
|
+
case "radio": return looseEqual(model, value) ? " checked" : "";
|
|
964
|
+
case "checkbox": return (isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
|
|
965
|
+
default: return ssrRenderAttr("value", model);
|
|
966
|
+
}
|
|
1183
967
|
}
|
|
1184
968
|
function ssrGetDynamicModelProps(existingProps = {}, model) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
}
|
|
1195
|
-
|
|
969
|
+
const { type, value } = existingProps;
|
|
970
|
+
switch (type) {
|
|
971
|
+
case "radio": return looseEqual(model, value) ? { checked: true } : null;
|
|
972
|
+
case "checkbox": return (isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
|
|
973
|
+
default: return { value: model };
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
//#endregion
|
|
977
|
+
//#region packages/server-renderer/src/helpers/ssrCompile.ts
|
|
1196
978
|
function ssrCompile(template, instance) {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
979
|
+
throw new Error("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.");
|
|
980
|
+
}
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region packages/server-renderer/src/render.ts
|
|
983
|
+
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = ssrUtils;
|
|
984
|
+
function cleanupContext(context) {
|
|
985
|
+
let firstError;
|
|
986
|
+
if (context.__watcherHandles) {
|
|
987
|
+
for (const unwatch of context.__watcherHandles) try {
|
|
988
|
+
unwatch();
|
|
989
|
+
} catch (err) {
|
|
990
|
+
if (firstError === void 0) firstError = err;
|
|
991
|
+
}
|
|
992
|
+
context.__watcherHandles.length = 0;
|
|
993
|
+
}
|
|
994
|
+
if (context.__instanceScopes) {
|
|
995
|
+
for (const scope of context.__instanceScopes) try {
|
|
996
|
+
scope.stop();
|
|
997
|
+
} catch (err) {
|
|
998
|
+
if (firstError === void 0) firstError = err;
|
|
999
|
+
}
|
|
1000
|
+
context.__instanceScopes.length = 0;
|
|
1001
|
+
}
|
|
1002
|
+
if (firstError !== void 0) throw firstError;
|
|
1003
|
+
}
|
|
1213
1004
|
function createBuffer() {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
}
|
|
1232
|
-
};
|
|
1005
|
+
let appendable = false;
|
|
1006
|
+
const buffer = [];
|
|
1007
|
+
return {
|
|
1008
|
+
getBuffer() {
|
|
1009
|
+
return buffer;
|
|
1010
|
+
},
|
|
1011
|
+
push(item) {
|
|
1012
|
+
const isStringItem = isString(item);
|
|
1013
|
+
if (appendable && isStringItem) {
|
|
1014
|
+
buffer[buffer.length - 1] += item;
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
buffer.push(item);
|
|
1018
|
+
appendable = isStringItem;
|
|
1019
|
+
if (isPromise(item) || isArray(item) && item.hasAsync) buffer.hasAsync = true;
|
|
1020
|
+
}
|
|
1021
|
+
};
|
|
1233
1022
|
}
|
|
1234
1023
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
let prefetches = instance.sp;
|
|
1249
|
-
if (hasAsyncSetup || prefetches) {
|
|
1250
|
-
const p = Promise.resolve(res).then(() => {
|
|
1251
|
-
if (hasAsyncSetup) prefetches = instance.sp;
|
|
1252
|
-
if (prefetches) {
|
|
1253
|
-
return Promise.all(
|
|
1254
|
-
prefetches.map((prefetch) => prefetch.call(instance.proxy))
|
|
1255
|
-
);
|
|
1256
|
-
}
|
|
1257
|
-
}).catch(NOOP);
|
|
1258
|
-
return p.then(() => renderComponentSubTree(instance, slotScopeId));
|
|
1259
|
-
} else {
|
|
1260
|
-
return renderComponentSubTree(instance, slotScopeId);
|
|
1261
|
-
}
|
|
1024
|
+
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
1025
|
+
const context = instance.appContext.provides[ssrContextKey];
|
|
1026
|
+
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
1027
|
+
if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(vnode);
|
|
1028
|
+
const res = setupComponent(instance, true);
|
|
1029
|
+
if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
|
|
1030
|
+
const hasAsyncSetup = isPromise(res);
|
|
1031
|
+
let prefetches = instance.sp;
|
|
1032
|
+
if (hasAsyncSetup || prefetches) return Promise.resolve(res).then(() => {
|
|
1033
|
+
if (hasAsyncSetup) prefetches = instance.sp;
|
|
1034
|
+
if (prefetches) return Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)));
|
|
1035
|
+
}).catch(NOOP).then(() => renderComponentSubTree(instance, slotScopeId));
|
|
1036
|
+
else return renderComponentSubTree(instance, slotScopeId);
|
|
1262
1037
|
}
|
|
1263
1038
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
instance.proxy,
|
|
1313
|
-
push,
|
|
1314
|
-
instance,
|
|
1315
|
-
attrs,
|
|
1316
|
-
// compiler-optimized bindings
|
|
1317
|
-
instance.props,
|
|
1318
|
-
instance.setupState,
|
|
1319
|
-
instance.data,
|
|
1320
|
-
instance.ctx
|
|
1321
|
-
);
|
|
1322
|
-
} finally {
|
|
1323
|
-
setCurrentRenderingInstance(prev);
|
|
1324
|
-
}
|
|
1325
|
-
} else if (instance.render && instance.render !== NOOP) {
|
|
1326
|
-
renderVNode(
|
|
1327
|
-
push,
|
|
1328
|
-
instance.subTree = renderComponentRoot(instance),
|
|
1329
|
-
instance,
|
|
1330
|
-
slotScopeId
|
|
1331
|
-
);
|
|
1332
|
-
} else {
|
|
1333
|
-
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
1334
|
-
warn$2(`Component ${componentName} is missing template or render function.`);
|
|
1335
|
-
push(`<!---->`);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
|
|
1339
|
-
return getBuffer();
|
|
1039
|
+
if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(instance.vnode);
|
|
1040
|
+
const comp = instance.type;
|
|
1041
|
+
const { getBuffer, push } = createBuffer();
|
|
1042
|
+
if (isFunction(comp)) {
|
|
1043
|
+
let root = renderComponentRoot(instance);
|
|
1044
|
+
if (!comp.props) {
|
|
1045
|
+
for (const key in instance.attrs) if (key.startsWith(`data-v-`)) (root.props || (root.props = {}))[key] = ``;
|
|
1046
|
+
}
|
|
1047
|
+
renderVNode(push, instance.subTree = root, instance, slotScopeId);
|
|
1048
|
+
} else {
|
|
1049
|
+
if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) comp.ssrRender = ssrCompile(comp.template, instance);
|
|
1050
|
+
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
1051
|
+
if (ssrRender) {
|
|
1052
|
+
let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|
|
1053
|
+
let hasCloned = false;
|
|
1054
|
+
let cur = instance;
|
|
1055
|
+
while (true) {
|
|
1056
|
+
const scopeId = cur.vnode.scopeId;
|
|
1057
|
+
if (scopeId) {
|
|
1058
|
+
if (!hasCloned) {
|
|
1059
|
+
attrs = { ...attrs };
|
|
1060
|
+
hasCloned = true;
|
|
1061
|
+
}
|
|
1062
|
+
attrs[scopeId] = "";
|
|
1063
|
+
}
|
|
1064
|
+
const parent = cur.parent;
|
|
1065
|
+
if (parent && parent.subTree && parent.subTree === cur.vnode) cur = parent;
|
|
1066
|
+
else break;
|
|
1067
|
+
}
|
|
1068
|
+
if (slotScopeId) {
|
|
1069
|
+
if (!hasCloned) attrs = { ...attrs };
|
|
1070
|
+
const slotScopeIdList = slotScopeId.trim().split(" ");
|
|
1071
|
+
for (let i = 0; i < slotScopeIdList.length; i++) attrs[slotScopeIdList[i]] = "";
|
|
1072
|
+
}
|
|
1073
|
+
const prev = setCurrentRenderingInstance(instance);
|
|
1074
|
+
try {
|
|
1075
|
+
ssrRender(instance.proxy, push, instance, attrs, instance.props, instance.setupState, instance.data, instance.ctx);
|
|
1076
|
+
} finally {
|
|
1077
|
+
setCurrentRenderingInstance(prev);
|
|
1078
|
+
}
|
|
1079
|
+
} else if (instance.render && instance.render !== NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
|
|
1080
|
+
else {
|
|
1081
|
+
warn(`Component ${comp.name || comp.__file || `<Anonymous>`} is missing template or render function.`);
|
|
1082
|
+
push(`<!---->`);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
|
|
1086
|
+
return getBuffer();
|
|
1340
1087
|
}
|
|
1341
1088
|
function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
parentComponent,
|
|
1367
|
-
slotScopeId
|
|
1368
|
-
);
|
|
1369
|
-
push(`<!--]-->`);
|
|
1370
|
-
break;
|
|
1371
|
-
default:
|
|
1372
|
-
if (shapeFlag & 1) {
|
|
1373
|
-
renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
1374
|
-
} else if (shapeFlag & 6) {
|
|
1375
|
-
push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
1376
|
-
} else if (shapeFlag & 64) {
|
|
1377
|
-
renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
1378
|
-
} else if (shapeFlag & 128) {
|
|
1379
|
-
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
1380
|
-
} else {
|
|
1381
|
-
warn$2(
|
|
1382
|
-
"[@vue/server-renderer] Invalid VNode type:",
|
|
1383
|
-
type,
|
|
1384
|
-
`(${typeof type})`
|
|
1385
|
-
);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1089
|
+
const { type, shapeFlag, children, dirs, props } = vnode;
|
|
1090
|
+
if (dirs) vnode.props = applySSRDirectives(vnode, props, dirs);
|
|
1091
|
+
switch (type) {
|
|
1092
|
+
case Text:
|
|
1093
|
+
push(escapeHtml(children));
|
|
1094
|
+
break;
|
|
1095
|
+
case Comment:
|
|
1096
|
+
push(children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`);
|
|
1097
|
+
break;
|
|
1098
|
+
case Static:
|
|
1099
|
+
push(children);
|
|
1100
|
+
break;
|
|
1101
|
+
case Fragment:
|
|
1102
|
+
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
1103
|
+
push(`<!--[-->`);
|
|
1104
|
+
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
1105
|
+
push(`<!--]-->`);
|
|
1106
|
+
break;
|
|
1107
|
+
default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
1108
|
+
else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
1109
|
+
else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
1110
|
+
else if (shapeFlag & 128) renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
1111
|
+
else warn("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
|
|
1112
|
+
}
|
|
1388
1113
|
}
|
|
1389
1114
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
1390
|
-
|
|
1391
|
-
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
1392
|
-
}
|
|
1115
|
+
for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
1393
1116
|
}
|
|
1394
1117
|
function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
if (!hasChildrenOverride) {
|
|
1432
|
-
if (shapeFlag & 8) {
|
|
1433
|
-
push(escapeHtml(children));
|
|
1434
|
-
} else if (shapeFlag & 16) {
|
|
1435
|
-
renderVNodeChildren(
|
|
1436
|
-
push,
|
|
1437
|
-
children,
|
|
1438
|
-
parentComponent,
|
|
1439
|
-
slotScopeId
|
|
1440
|
-
);
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
push(`</${tag}>`);
|
|
1444
|
-
}
|
|
1118
|
+
const tag = vnode.type;
|
|
1119
|
+
let { props, children, shapeFlag, scopeId } = vnode;
|
|
1120
|
+
let openTag = `<${tag}`;
|
|
1121
|
+
if (props) openTag += ssrRenderAttrs(props, tag);
|
|
1122
|
+
if (scopeId) openTag += ` ${scopeId}`;
|
|
1123
|
+
let curParent = parentComponent;
|
|
1124
|
+
let curVnode = vnode;
|
|
1125
|
+
while (curParent && curVnode === curParent.subTree) {
|
|
1126
|
+
curVnode = curParent.vnode;
|
|
1127
|
+
if (curVnode.scopeId) openTag += ` ${curVnode.scopeId}`;
|
|
1128
|
+
curParent = curParent.parent;
|
|
1129
|
+
}
|
|
1130
|
+
if (slotScopeId) openTag += ` ${slotScopeId}`;
|
|
1131
|
+
push(openTag + `>`);
|
|
1132
|
+
if (!isVoidTag(tag)) {
|
|
1133
|
+
let hasChildrenOverride = false;
|
|
1134
|
+
if (props) {
|
|
1135
|
+
if (props.innerHTML) {
|
|
1136
|
+
hasChildrenOverride = true;
|
|
1137
|
+
push(props.innerHTML);
|
|
1138
|
+
} else if (props.textContent) {
|
|
1139
|
+
hasChildrenOverride = true;
|
|
1140
|
+
push(escapeHtml(props.textContent));
|
|
1141
|
+
} else if (tag === "textarea" && props.value) {
|
|
1142
|
+
hasChildrenOverride = true;
|
|
1143
|
+
push(escapeHtml(props.value));
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
if (!hasChildrenOverride) {
|
|
1147
|
+
if (shapeFlag & 8) push(escapeHtml(children));
|
|
1148
|
+
else if (shapeFlag & 16) renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
1149
|
+
}
|
|
1150
|
+
push(`</${tag}>`);
|
|
1151
|
+
}
|
|
1445
1152
|
}
|
|
1446
1153
|
function applySSRDirectives(vnode, rawProps, dirs) {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
}
|
|
1458
|
-
return mergeProps$1(rawProps || {}, ...toMerge);
|
|
1154
|
+
const toMerge = [];
|
|
1155
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
1156
|
+
const binding = dirs[i];
|
|
1157
|
+
const { dir: { getSSRProps } } = binding;
|
|
1158
|
+
if (getSSRProps) {
|
|
1159
|
+
const props = getSSRProps(binding, vnode);
|
|
1160
|
+
if (props) toMerge.push(props);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return mergeProps(rawProps || {}, ...toMerge);
|
|
1459
1164
|
}
|
|
1460
1165
|
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
(push2) => {
|
|
1478
|
-
renderVNodeChildren(
|
|
1479
|
-
push2,
|
|
1480
|
-
vnode.children,
|
|
1481
|
-
parentComponent,
|
|
1482
|
-
slotScopeId
|
|
1483
|
-
);
|
|
1484
|
-
},
|
|
1485
|
-
target,
|
|
1486
|
-
disabled || disabled === "",
|
|
1487
|
-
parentComponent
|
|
1488
|
-
);
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1166
|
+
const target = vnode.props && vnode.props.to;
|
|
1167
|
+
const disabled = vnode.props && vnode.props.disabled;
|
|
1168
|
+
if (!target) {
|
|
1169
|
+
if (!disabled) warn(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
1170
|
+
return [];
|
|
1171
|
+
}
|
|
1172
|
+
if (!isString(target)) {
|
|
1173
|
+
warn(`[@vue/server-renderer] Teleport target must be a query selector string.`);
|
|
1174
|
+
return [];
|
|
1175
|
+
}
|
|
1176
|
+
ssrRenderTeleport(push, (push) => {
|
|
1177
|
+
renderVNodeChildren(push, vnode.children, parentComponent, slotScopeId);
|
|
1178
|
+
}, target, disabled || disabled === "", parentComponent);
|
|
1179
|
+
}
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region packages/server-renderer/src/renderToString.ts
|
|
1491
1182
|
const { isVNode: isVNode$1 } = ssrUtils;
|
|
1492
1183
|
function nestedUnrollBuffer(buffer, parentRet, startIndex) {
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
return nestedUnrollBuffer(buffer, "", i);
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1516
|
-
ret = result;
|
|
1517
|
-
}
|
|
1518
|
-
return ret;
|
|
1184
|
+
if (!buffer.hasAsync) return parentRet + unrollBufferSync$1(buffer);
|
|
1185
|
+
let ret = parentRet;
|
|
1186
|
+
for (let i = startIndex; i < buffer.length; i += 1) {
|
|
1187
|
+
const item = buffer[i];
|
|
1188
|
+
if (isString(item)) {
|
|
1189
|
+
ret += item;
|
|
1190
|
+
continue;
|
|
1191
|
+
}
|
|
1192
|
+
if (isPromise(item)) return item.then((nestedItem) => {
|
|
1193
|
+
buffer[i] = nestedItem;
|
|
1194
|
+
return nestedUnrollBuffer(buffer, ret, i);
|
|
1195
|
+
});
|
|
1196
|
+
const result = nestedUnrollBuffer(item, ret, 0);
|
|
1197
|
+
if (isPromise(result)) return result.then((nestedItem) => {
|
|
1198
|
+
buffer[i] = nestedItem;
|
|
1199
|
+
return nestedUnrollBuffer(buffer, "", i);
|
|
1200
|
+
});
|
|
1201
|
+
ret = result;
|
|
1202
|
+
}
|
|
1203
|
+
return ret;
|
|
1519
1204
|
}
|
|
1520
1205
|
function unrollBuffer$1(buffer) {
|
|
1521
|
-
|
|
1206
|
+
return nestedUnrollBuffer(buffer, "", 0);
|
|
1522
1207
|
}
|
|
1523
1208
|
function unrollBufferSync$1(buffer) {
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
return ret;
|
|
1209
|
+
let ret = "";
|
|
1210
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
1211
|
+
let item = buffer[i];
|
|
1212
|
+
if (isString(item)) ret += item;
|
|
1213
|
+
else ret += unrollBufferSync$1(item);
|
|
1214
|
+
}
|
|
1215
|
+
return ret;
|
|
1534
1216
|
}
|
|
1535
1217
|
async function renderToString(input, context = {}) {
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
unwatch();
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
return result;
|
|
1218
|
+
if (isVNode$1(input)) return renderToString(createApp({ render: () => input }), context);
|
|
1219
|
+
const vnode = createVNode(input._component, input._props);
|
|
1220
|
+
vnode.appContext = input._context;
|
|
1221
|
+
input.provide(ssrContextKey, context);
|
|
1222
|
+
try {
|
|
1223
|
+
const result = await unrollBuffer$1(await renderComponentVNode(vnode));
|
|
1224
|
+
await resolveTeleports(context);
|
|
1225
|
+
return result;
|
|
1226
|
+
} finally {
|
|
1227
|
+
cleanupContext(context);
|
|
1228
|
+
}
|
|
1551
1229
|
}
|
|
1552
1230
|
async function resolveTeleports(context) {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1231
|
+
if (context.__teleportBuffers) {
|
|
1232
|
+
context.teleports = context.teleports || {};
|
|
1233
|
+
for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(await Promise.all([context.__teleportBuffers[key]]));
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region packages/server-renderer/src/renderToStream.ts
|
|
1563
1238
|
const { isVNode } = ssrUtils;
|
|
1564
1239
|
async function unrollBuffer(buffer, stream) {
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
stream.push(item);
|
|
1573
|
-
} else {
|
|
1574
|
-
await unrollBuffer(item, stream);
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
} else {
|
|
1578
|
-
unrollBufferSync(buffer, stream);
|
|
1579
|
-
}
|
|
1240
|
+
if (buffer.hasAsync) for (let i = 0; i < buffer.length; i++) {
|
|
1241
|
+
let item = buffer[i];
|
|
1242
|
+
if (isPromise(item)) item = await item;
|
|
1243
|
+
if (isString(item)) stream.push(item);
|
|
1244
|
+
else await unrollBuffer(item, stream);
|
|
1245
|
+
}
|
|
1246
|
+
else unrollBufferSync(buffer, stream);
|
|
1580
1247
|
}
|
|
1581
1248
|
function unrollBufferSync(buffer, stream) {
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
unrollBufferSync(item, stream);
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1249
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
1250
|
+
const item = buffer[i];
|
|
1251
|
+
if (isString(item)) stream.push(item);
|
|
1252
|
+
else unrollBufferSync(item, stream);
|
|
1253
|
+
}
|
|
1590
1254
|
}
|
|
1591
1255
|
function renderToSimpleStream(input, context, stream) {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1256
|
+
if (isVNode(input)) return renderToSimpleStream(createApp({ render: () => input }), context, stream);
|
|
1257
|
+
const vnode = createVNode(input._component, input._props);
|
|
1258
|
+
vnode.appContext = input._context;
|
|
1259
|
+
input.provide(ssrContextKey, context);
|
|
1260
|
+
let cleaned = false;
|
|
1261
|
+
const finalize = () => {
|
|
1262
|
+
if (cleaned) return;
|
|
1263
|
+
cleaned = true;
|
|
1264
|
+
cleanupContext(context);
|
|
1265
|
+
};
|
|
1266
|
+
Promise.resolve().then(() => renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
|
1267
|
+
finalize();
|
|
1268
|
+
return stream.push(null);
|
|
1269
|
+
}).catch((error) => {
|
|
1270
|
+
try {
|
|
1271
|
+
finalize();
|
|
1272
|
+
} catch {}
|
|
1273
|
+
stream.destroy(error);
|
|
1274
|
+
});
|
|
1275
|
+
return stream;
|
|
1612
1276
|
}
|
|
1277
|
+
/**
|
|
1278
|
+
* @deprecated
|
|
1279
|
+
*/
|
|
1613
1280
|
function renderToStream(input, context = {}) {
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
);
|
|
1617
|
-
return renderToNodeStream(input, context);
|
|
1281
|
+
console.warn(`[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`);
|
|
1282
|
+
return renderToNodeStream(input, context);
|
|
1618
1283
|
}
|
|
1619
1284
|
function renderToNodeStream(input, context = {}) {
|
|
1620
|
-
|
|
1621
|
-
throw new Error(
|
|
1622
|
-
`ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
|
|
1623
|
-
);
|
|
1624
|
-
}
|
|
1285
|
+
throw new Error("ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.");
|
|
1625
1286
|
}
|
|
1626
1287
|
function pipeToNodeWritable(input, context = {}, writable) {
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
writable.destroy(err);
|
|
1637
|
-
}
|
|
1638
|
-
});
|
|
1288
|
+
renderToSimpleStream(input, context, {
|
|
1289
|
+
push(content) {
|
|
1290
|
+
if (content != null) writable.write(content);
|
|
1291
|
+
else writable.end();
|
|
1292
|
+
},
|
|
1293
|
+
destroy(err) {
|
|
1294
|
+
writable.destroy(err);
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1639
1297
|
}
|
|
1640
1298
|
function renderToWebStream(input, context = {}) {
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
}
|
|
1662
|
-
});
|
|
1663
|
-
},
|
|
1664
|
-
cancel() {
|
|
1665
|
-
cancelled = true;
|
|
1666
|
-
}
|
|
1667
|
-
});
|
|
1299
|
+
if (typeof ReadableStream !== "function") throw new Error("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.");
|
|
1300
|
+
const encoder = new TextEncoder();
|
|
1301
|
+
let cancelled = false;
|
|
1302
|
+
return new ReadableStream({
|
|
1303
|
+
start(controller) {
|
|
1304
|
+
renderToSimpleStream(input, context, {
|
|
1305
|
+
push(content) {
|
|
1306
|
+
if (cancelled) return;
|
|
1307
|
+
if (content != null) controller.enqueue(encoder.encode(content));
|
|
1308
|
+
else controller.close();
|
|
1309
|
+
},
|
|
1310
|
+
destroy(err) {
|
|
1311
|
+
controller.error(err);
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
},
|
|
1315
|
+
cancel() {
|
|
1316
|
+
cancelled = true;
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1668
1319
|
}
|
|
1669
1320
|
function pipeToWebWritable(input, context = {}, writable) {
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
writer.close();
|
|
1691
|
-
}
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1321
|
+
const writer = writable.getWriter();
|
|
1322
|
+
const encoder = new TextEncoder();
|
|
1323
|
+
let hasReady = false;
|
|
1324
|
+
try {
|
|
1325
|
+
hasReady = isPromise(writer.ready);
|
|
1326
|
+
} catch (e) {}
|
|
1327
|
+
renderToSimpleStream(input, context, {
|
|
1328
|
+
async push(content) {
|
|
1329
|
+
if (hasReady) await writer.ready;
|
|
1330
|
+
if (content != null) return writer.write(encoder.encode(content));
|
|
1331
|
+
else return writer.close();
|
|
1332
|
+
},
|
|
1333
|
+
destroy(err) {
|
|
1334
|
+
console.log(err);
|
|
1335
|
+
writer.close();
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
//#endregion
|
|
1340
|
+
//#region packages/server-renderer/src/index.ts
|
|
1695
1341
|
initDirectivesForSSR();
|
|
1696
|
-
|
|
1697
|
-
export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };
|
|
1342
|
+
//#endregion
|
|
1343
|
+
export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, ssrIncludeBooleanAttr, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };
|