@vue/server-renderer 3.6.0-alpha.7 → 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 +6124 -8167
- package/dist/server-renderer.esm-browser.prod.js +5 -4
- package/dist/server-renderer.esm-bundler.js +1157 -1511
- package/package.json +4 -4
|
@@ -1,1127 +1,923 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.6.0-
|
|
3
|
-
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
-
* @license MIT
|
|
5
|
-
**/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
2
|
+
* @vue/server-renderer v3.6.0-beta.10
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
Object.defineProperties(exports, {
|
|
7
|
+
__esModule: { value: true },
|
|
8
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
9
|
+
});
|
|
10
|
+
//#region \0rolldown/runtime.js
|
|
11
|
+
var __create = Object.create;
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __exportAll = (all, no_symbols) => {
|
|
18
|
+
let target = {};
|
|
19
|
+
for (var name in all) __defProp(target, name, {
|
|
20
|
+
get: all[name],
|
|
21
|
+
enumerable: true
|
|
22
|
+
});
|
|
23
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
24
|
+
return target;
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
28
|
+
key = keys[i];
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
30
|
+
get: ((k) => from[k]).bind(null, key),
|
|
31
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
+
value: mod,
|
|
38
|
+
enumerable: true
|
|
39
|
+
}) : target, mod));
|
|
40
|
+
//#endregion
|
|
41
|
+
let vue = require("vue");
|
|
42
|
+
vue = __toESM(vue);
|
|
43
|
+
let _vue_shared = require("@vue/shared");
|
|
44
|
+
let _vue_compiler_ssr = require("@vue/compiler-ssr");
|
|
45
|
+
//#region packages/server-renderer/src/helpers/ssrRenderAttrs.ts
|
|
46
|
+
const shouldIgnoreProp = /* @__PURE__ */ (0, _vue_shared.makeMap)(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
30
47
|
function ssrRenderAttrs(props, tag) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} else {
|
|
44
|
-
ret += ssrRenderDynamicAttr(key, value, tag);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return ret;
|
|
48
|
+
let ret = "";
|
|
49
|
+
for (let key in props) {
|
|
50
|
+
if (shouldIgnoreProp(key) || (0, _vue_shared.isOn)(key) || tag === "textarea" && key === "value" || key.startsWith(".")) continue;
|
|
51
|
+
const value = props[key];
|
|
52
|
+
if (key.startsWith("^")) key = key.slice(1);
|
|
53
|
+
if (key === "class") ret += ` class="${ssrRenderClass(value)}"`;
|
|
54
|
+
else if (key === "style") ret += ` style="${ssrRenderStyle(value)}"`;
|
|
55
|
+
else if (key === "className") {
|
|
56
|
+
if (value != null) ret += ` class="${(0, _vue_shared.escapeHtml)(String(value))}"`;
|
|
57
|
+
} else ret += ssrRenderDynamicAttr(key, value, tag);
|
|
58
|
+
}
|
|
59
|
+
return ret;
|
|
48
60
|
}
|
|
49
61
|
function ssrRenderDynamicAttr(key, value, tag) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} else {
|
|
59
|
-
console.warn(
|
|
60
|
-
`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
|
|
61
|
-
);
|
|
62
|
-
return ``;
|
|
63
|
-
}
|
|
62
|
+
if (!(0, _vue_shared.isRenderableAttrValue)(value)) return ``;
|
|
63
|
+
const attrKey = tag && (tag.indexOf("-") > 0 || (0, _vue_shared.isSVGTag)(tag)) ? key : _vue_shared.propsToAttrMap[key] || key.toLowerCase();
|
|
64
|
+
if ((0, _vue_shared.isBooleanAttr)(attrKey)) return (0, _vue_shared.includeBooleanAttr)(value) ? ` ${attrKey}` : ``;
|
|
65
|
+
else if ((0, _vue_shared.isSSRSafeAttrName)(attrKey)) return value === "" ? ` ${attrKey}` : ` ${attrKey}="${(0, _vue_shared.escapeHtml)(value)}"`;
|
|
66
|
+
else {
|
|
67
|
+
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
|
|
68
|
+
return ``;
|
|
69
|
+
}
|
|
64
70
|
}
|
|
65
71
|
function ssrRenderAttr(key, value) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
return ` ${key}="${shared.escapeHtml(value)}"`;
|
|
72
|
+
if (!(0, _vue_shared.isRenderableAttrValue)(value)) return ``;
|
|
73
|
+
return ` ${key}="${(0, _vue_shared.escapeHtml)(value)}"`;
|
|
70
74
|
}
|
|
71
75
|
function ssrRenderClass(raw) {
|
|
72
|
-
|
|
76
|
+
return (0, _vue_shared.escapeHtml)((0, _vue_shared.normalizeClass)(raw));
|
|
73
77
|
}
|
|
74
78
|
function ssrRenderStyle(raw) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (shared.isString(raw)) {
|
|
79
|
-
return shared.escapeHtml(raw);
|
|
80
|
-
}
|
|
81
|
-
const styles = shared.normalizeStyle(ssrResetCssVars(raw));
|
|
82
|
-
return shared.escapeHtml(shared.stringifyStyle(styles));
|
|
79
|
+
if (!raw) return "";
|
|
80
|
+
if ((0, _vue_shared.isString)(raw)) return (0, _vue_shared.escapeHtml)(raw);
|
|
81
|
+
return (0, _vue_shared.escapeHtml)((0, _vue_shared.stringifyStyle)((0, _vue_shared.normalizeStyle)(ssrResetCssVars(raw))));
|
|
83
82
|
}
|
|
84
83
|
function ssrResetCssVars(raw) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
return raw;
|
|
97
|
-
}
|
|
98
|
-
|
|
84
|
+
if (!(0, _vue_shared.isArray)(raw) && (0, _vue_shared.isObject)(raw)) {
|
|
85
|
+
const res = {};
|
|
86
|
+
for (const key in raw) if (key.startsWith(":--")) res[key.slice(1)] = (0, _vue_shared.normalizeCssVarValue)(raw[key]);
|
|
87
|
+
else res[key] = raw[key];
|
|
88
|
+
return res;
|
|
89
|
+
}
|
|
90
|
+
return raw;
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
99
94
|
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
100
|
-
|
|
101
|
-
Vue.createVNode(comp, props, children),
|
|
102
|
-
parentComponent,
|
|
103
|
-
slotScopeId
|
|
104
|
-
);
|
|
95
|
+
return renderComponentVNode((0, vue.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
105
96
|
}
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region packages/server-renderer/src/helpers/ssrRenderSlot.ts
|
|
99
|
+
const { ensureValidVNode } = vue.ssrUtils;
|
|
108
100
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
slotName,
|
|
113
|
-
slotProps,
|
|
114
|
-
fallbackRenderFn,
|
|
115
|
-
push,
|
|
116
|
-
parentComponent,
|
|
117
|
-
slotScopeId
|
|
118
|
-
);
|
|
119
|
-
push(`<!--]-->`);
|
|
101
|
+
push(`<!--[-->`);
|
|
102
|
+
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
103
|
+
push(`<!--]-->`);
|
|
120
104
|
}
|
|
121
105
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (isEmptySlot) {
|
|
161
|
-
if (fallbackRenderFn) {
|
|
162
|
-
fallbackRenderFn();
|
|
163
|
-
}
|
|
164
|
-
} else {
|
|
165
|
-
let start = 0;
|
|
166
|
-
let end = slotBuffer.length;
|
|
167
|
-
if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
|
|
168
|
-
start++;
|
|
169
|
-
end--;
|
|
170
|
-
}
|
|
171
|
-
if (start < end) {
|
|
172
|
-
for (let i = start; i < end; i++) {
|
|
173
|
-
push(slotBuffer[i]);
|
|
174
|
-
}
|
|
175
|
-
} else if (transition) {
|
|
176
|
-
push(`<!---->`);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
} else if (fallbackRenderFn) {
|
|
181
|
-
fallbackRenderFn();
|
|
182
|
-
} else if (transition) {
|
|
183
|
-
push(`<!---->`);
|
|
184
|
-
}
|
|
106
|
+
const slotFn = slots[slotName];
|
|
107
|
+
if (slotFn) {
|
|
108
|
+
const slotBuffer = [];
|
|
109
|
+
const bufferedPush = (item) => {
|
|
110
|
+
slotBuffer.push(item);
|
|
111
|
+
};
|
|
112
|
+
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
113
|
+
if ((0, _vue_shared.isArray)(ret)) {
|
|
114
|
+
const validSlotContent = ensureValidVNode(ret);
|
|
115
|
+
if (validSlotContent) renderVNodeChildren(push, validSlotContent, parentComponent, slotScopeId);
|
|
116
|
+
else if (fallbackRenderFn) fallbackRenderFn();
|
|
117
|
+
else if (transition) push(`<!---->`);
|
|
118
|
+
} else {
|
|
119
|
+
let isEmptySlot = true;
|
|
120
|
+
if (transition) isEmptySlot = false;
|
|
121
|
+
else for (let i = 0; i < slotBuffer.length; i++) if (!isComment(slotBuffer[i])) {
|
|
122
|
+
isEmptySlot = false;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
if (isEmptySlot) {
|
|
126
|
+
if (fallbackRenderFn) fallbackRenderFn();
|
|
127
|
+
} else {
|
|
128
|
+
let start = 0;
|
|
129
|
+
let end = slotBuffer.length;
|
|
130
|
+
if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
|
|
131
|
+
start++;
|
|
132
|
+
end--;
|
|
133
|
+
}
|
|
134
|
+
if (start < end) for (let i = start; i < end; i++) push(slotBuffer[i]);
|
|
135
|
+
else if (transition) push(`<!---->`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} else if (fallbackRenderFn) fallbackRenderFn();
|
|
139
|
+
else if (transition) push(`<!---->`);
|
|
185
140
|
}
|
|
186
141
|
const commentTestRE = /^<!--[\s\S]*-->$/;
|
|
187
142
|
const commentRE = /<!--[^]*?-->/gm;
|
|
188
143
|
function isComment(item) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
144
|
+
if (typeof item !== "string" || !commentTestRE.test(item)) return false;
|
|
145
|
+
if (item.length <= 8) return true;
|
|
146
|
+
return !item.replace(commentRE, "").trim();
|
|
192
147
|
}
|
|
193
|
-
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region packages/server-renderer/src/helpers/ssrRenderTeleport.ts
|
|
194
150
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
151
|
+
parentPush("<!--teleport start-->");
|
|
152
|
+
const context = parentComponent.appContext.provides[vue.ssrContextKey];
|
|
153
|
+
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
154
|
+
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
155
|
+
const bufferIndex = targetBuffer.length;
|
|
156
|
+
let teleportContent;
|
|
157
|
+
if (disabled) {
|
|
158
|
+
contentRenderFn(parentPush);
|
|
159
|
+
teleportContent = `<!--teleport start anchor--><!--teleport anchor-->`;
|
|
160
|
+
} else {
|
|
161
|
+
const { getBuffer, push } = createBuffer();
|
|
162
|
+
push(`<!--teleport start anchor-->`);
|
|
163
|
+
contentRenderFn(push);
|
|
164
|
+
push(`<!--teleport anchor-->`);
|
|
165
|
+
teleportContent = getBuffer();
|
|
166
|
+
}
|
|
167
|
+
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
168
|
+
parentPush("<!--teleport end-->");
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region packages/server-renderer/src/helpers/ssrInterpolate.ts
|
|
215
172
|
function ssrInterpolate(value) {
|
|
216
|
-
|
|
173
|
+
return (0, _vue_shared.escapeHtml)((0, _vue_shared.toDisplayString)(value));
|
|
217
174
|
}
|
|
218
|
-
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region packages/reactivity/src/system.ts
|
|
219
177
|
let activeSub = void 0;
|
|
220
178
|
function setActiveSub(sub) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
179
|
+
try {
|
|
180
|
+
return activeSub;
|
|
181
|
+
} finally {
|
|
182
|
+
activeSub = sub;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region packages/reactivity/src/reactive.ts
|
|
187
|
+
/**
|
|
188
|
+
* Returns the raw, original object of a Vue-created proxy.
|
|
189
|
+
*
|
|
190
|
+
* `toRaw()` can return the original object from proxies created by
|
|
191
|
+
* {@link reactive}, {@link readonly}, {@link shallowReactive} or
|
|
192
|
+
* {@link shallowReadonly}.
|
|
193
|
+
*
|
|
194
|
+
* This is an escape hatch that can be used to temporarily read without
|
|
195
|
+
* incurring proxy access / tracking overhead or write without triggering
|
|
196
|
+
* changes. It is **not** recommended to hold a persistent reference to the
|
|
197
|
+
* original object. Use with caution.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```js
|
|
201
|
+
* const foo = {}
|
|
202
|
+
* const reactiveFoo = reactive(foo)
|
|
203
|
+
*
|
|
204
|
+
* console.log(toRaw(reactiveFoo) === foo) // true
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @param observed - The object for which the "raw" value is requested.
|
|
208
|
+
* @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
|
|
209
|
+
*/
|
|
210
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
228
211
|
function toRaw(observed) {
|
|
229
|
-
|
|
230
|
-
|
|
212
|
+
const raw = observed && observed["__v_raw"];
|
|
213
|
+
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
231
214
|
}
|
|
232
|
-
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region packages/reactivity/src/ref.ts
|
|
217
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
233
218
|
function isRef(r) {
|
|
234
|
-
|
|
219
|
+
return r ? r["__v_isRef"] === true : false;
|
|
235
220
|
}
|
|
236
|
-
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region packages/runtime-core/src/warning.ts
|
|
237
223
|
const stack = [];
|
|
224
|
+
/**
|
|
225
|
+
* @internal
|
|
226
|
+
*/
|
|
238
227
|
function pushWarningContext$1(ctx) {
|
|
239
|
-
|
|
228
|
+
stack.push(ctx);
|
|
240
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* @internal
|
|
232
|
+
*/
|
|
241
233
|
function popWarningContext$1() {
|
|
242
|
-
|
|
234
|
+
stack.pop();
|
|
243
235
|
}
|
|
244
236
|
let isWarning = false;
|
|
245
|
-
function warn$
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
} else {
|
|
272
|
-
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
273
|
-
if (trace.length && // avoid spamming console during tests
|
|
274
|
-
true) {
|
|
275
|
-
warnArgs.push(`
|
|
276
|
-
`, ...formatTrace(trace));
|
|
277
|
-
}
|
|
278
|
-
console.warn(...warnArgs);
|
|
279
|
-
}
|
|
280
|
-
setActiveSub(prevSub);
|
|
281
|
-
isWarning = false;
|
|
237
|
+
function warn$3(msg, ...args) {
|
|
238
|
+
if (isWarning) return;
|
|
239
|
+
isWarning = true;
|
|
240
|
+
const prevSub = setActiveSub();
|
|
241
|
+
const entry = stack.length ? stack[stack.length - 1] : null;
|
|
242
|
+
const instance = isVNode$2(entry) ? entry.component : entry;
|
|
243
|
+
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
244
|
+
const trace = getComponentTrace();
|
|
245
|
+
if (appWarnHandler) callWithErrorHandling(appWarnHandler, instance, 11, [
|
|
246
|
+
msg + args.map((a) => {
|
|
247
|
+
const toString = a.toString;
|
|
248
|
+
return toString == null ? JSON.stringify(a) : toString.call(a);
|
|
249
|
+
}).join(""),
|
|
250
|
+
instance && instance.proxy || instance,
|
|
251
|
+
trace.map(({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`).join("\n"),
|
|
252
|
+
trace
|
|
253
|
+
]);
|
|
254
|
+
else {
|
|
255
|
+
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
|
|
256
|
+
if (trace.length && true)
|
|
257
|
+
/* v8 ignore next 2 */
|
|
258
|
+
warnArgs.push(`\n`, ...formatTrace(trace));
|
|
259
|
+
console.warn(...warnArgs);
|
|
260
|
+
}
|
|
261
|
+
setActiveSub(prevSub);
|
|
262
|
+
isWarning = false;
|
|
282
263
|
}
|
|
283
264
|
function getComponentTrace() {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
} else {
|
|
303
|
-
currentCtx = currentCtx.parent;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return normalizedStack;
|
|
307
|
-
}
|
|
265
|
+
let currentCtx = stack[stack.length - 1];
|
|
266
|
+
if (!currentCtx) return [];
|
|
267
|
+
const normalizedStack = [];
|
|
268
|
+
while (currentCtx) {
|
|
269
|
+
const last = normalizedStack[0];
|
|
270
|
+
if (last && last.ctx === currentCtx) last.recurseCount++;
|
|
271
|
+
else normalizedStack.push({
|
|
272
|
+
ctx: currentCtx,
|
|
273
|
+
recurseCount: 0
|
|
274
|
+
});
|
|
275
|
+
if (isVNode$2(currentCtx)) {
|
|
276
|
+
const parent = currentCtx.component && currentCtx.component.parent;
|
|
277
|
+
currentCtx = parent && parent.vnode || parent;
|
|
278
|
+
} else currentCtx = currentCtx.parent;
|
|
279
|
+
}
|
|
280
|
+
return normalizedStack;
|
|
281
|
+
}
|
|
282
|
+
/* v8 ignore start */
|
|
308
283
|
function formatTrace(trace) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
return logs;
|
|
284
|
+
const logs = [];
|
|
285
|
+
trace.forEach((entry, i) => {
|
|
286
|
+
logs.push(...i === 0 ? [] : [`\n`], ...formatTraceEntry(entry));
|
|
287
|
+
});
|
|
288
|
+
return logs;
|
|
315
289
|
}
|
|
316
290
|
function formatTraceEntry({ ctx, recurseCount }) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
291
|
+
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
292
|
+
const instance = isVNode$2(ctx) ? ctx.component : ctx;
|
|
293
|
+
const isRoot = instance ? instance.parent == null : false;
|
|
294
|
+
const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`;
|
|
295
|
+
const close = `>` + postfix;
|
|
296
|
+
return ctx.props ? [
|
|
297
|
+
open,
|
|
298
|
+
...formatProps(ctx.props),
|
|
299
|
+
close
|
|
300
|
+
] : [open + close];
|
|
323
301
|
}
|
|
324
302
|
function formatProps(props) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
return res;
|
|
303
|
+
const res = [];
|
|
304
|
+
const keys = Object.keys(props);
|
|
305
|
+
keys.slice(0, 3).forEach((key) => {
|
|
306
|
+
res.push(...formatProp(key, props[key]));
|
|
307
|
+
});
|
|
308
|
+
if (keys.length > 3) res.push(` ...`);
|
|
309
|
+
return res;
|
|
334
310
|
}
|
|
335
311
|
function formatProp(key, value, raw) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
312
|
+
if ((0, _vue_shared.isString)(value)) {
|
|
313
|
+
value = JSON.stringify(value);
|
|
314
|
+
return raw ? value : [`${key}=${value}`];
|
|
315
|
+
} else if (typeof value === "number" || typeof value === "boolean" || value == null) return raw ? value : [`${key}=${value}`];
|
|
316
|
+
else if (/* @__PURE__ */ isRef(value)) {
|
|
317
|
+
value = formatProp(key, /* @__PURE__ */ toRaw(value.value), true);
|
|
318
|
+
return raw ? value : [
|
|
319
|
+
`${key}=Ref<`,
|
|
320
|
+
value,
|
|
321
|
+
`>`
|
|
322
|
+
];
|
|
323
|
+
} else if ((0, _vue_shared.isFunction)(value)) return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
324
|
+
else {
|
|
325
|
+
value = /* @__PURE__ */ toRaw(value);
|
|
326
|
+
return raw ? value : [`${key}=`, value];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/* v8 ignore stop */
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region packages/runtime-core/src/errorHandling.ts
|
|
352
332
|
const ErrorTypeStrings = {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
333
|
+
["sp"]: "serverPrefetch hook",
|
|
334
|
+
["bc"]: "beforeCreate hook",
|
|
335
|
+
["c"]: "created hook",
|
|
336
|
+
["bm"]: "beforeMount hook",
|
|
337
|
+
["m"]: "mounted hook",
|
|
338
|
+
["bu"]: "beforeUpdate hook",
|
|
339
|
+
["u"]: "updated",
|
|
340
|
+
["bum"]: "beforeUnmount hook",
|
|
341
|
+
["um"]: "unmounted hook",
|
|
342
|
+
["a"]: "activated hook",
|
|
343
|
+
["da"]: "deactivated hook",
|
|
344
|
+
["ec"]: "errorCaptured hook",
|
|
345
|
+
["rtc"]: "renderTracked hook",
|
|
346
|
+
["rtg"]: "renderTriggered hook",
|
|
347
|
+
[0]: "setup function",
|
|
348
|
+
[1]: "render function",
|
|
349
|
+
[2]: "watcher getter",
|
|
350
|
+
[3]: "watcher callback",
|
|
351
|
+
[4]: "watcher cleanup function",
|
|
352
|
+
[5]: "native event handler",
|
|
353
|
+
[6]: "component event handler",
|
|
354
|
+
[7]: "vnode hook",
|
|
355
|
+
[8]: "directive hook",
|
|
356
|
+
[9]: "transition hook",
|
|
357
|
+
[10]: "app errorHandler",
|
|
358
|
+
[11]: "app warnHandler",
|
|
359
|
+
[12]: "ref function",
|
|
360
|
+
[13]: "async component loader",
|
|
361
|
+
[14]: "scheduler flush",
|
|
362
|
+
[15]: "component update",
|
|
363
|
+
[16]: "app unmount cleanup function"
|
|
384
364
|
};
|
|
385
365
|
function callWithErrorHandling(fn, instance, type, args) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
366
|
+
try {
|
|
367
|
+
return args ? fn(...args) : fn();
|
|
368
|
+
} catch (err) {
|
|
369
|
+
handleError(err, instance, type);
|
|
370
|
+
}
|
|
391
371
|
}
|
|
392
372
|
function handleError(err, instance, type, throwInDev = true) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction);
|
|
373
|
+
const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || _vue_shared.EMPTY_OBJ;
|
|
374
|
+
if (instance) {
|
|
375
|
+
let cur = instance.parent;
|
|
376
|
+
const exposedInstance = instance.proxy || instance;
|
|
377
|
+
const errorInfo = ErrorTypeStrings[type];
|
|
378
|
+
while (cur) {
|
|
379
|
+
const errorCapturedHooks = cur.ec;
|
|
380
|
+
if (errorCapturedHooks) {
|
|
381
|
+
for (let i = 0; i < errorCapturedHooks.length; i++) if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) return;
|
|
382
|
+
}
|
|
383
|
+
cur = cur.parent;
|
|
384
|
+
}
|
|
385
|
+
if (errorHandler) {
|
|
386
|
+
const prevSub = setActiveSub();
|
|
387
|
+
callWithErrorHandling(errorHandler, null, 10, [
|
|
388
|
+
err,
|
|
389
|
+
exposedInstance,
|
|
390
|
+
errorInfo
|
|
391
|
+
]);
|
|
392
|
+
setActiveSub(prevSub);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction);
|
|
421
397
|
}
|
|
422
398
|
function logError(err, type, instance, throwInDev = true, throwInProd = false) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
} else {
|
|
435
|
-
console.error(err);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
399
|
+
{
|
|
400
|
+
const info = ErrorTypeStrings[type];
|
|
401
|
+
if (instance) pushWarningContext$1(instance);
|
|
402
|
+
warn$3(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
|
|
403
|
+
if (instance) popWarningContext$1();
|
|
404
|
+
if (throwInDev) throw err;
|
|
405
|
+
else console.error(err);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region packages/runtime-core/src/vnode.ts
|
|
440
410
|
function isVNode$2(value) {
|
|
441
|
-
|
|
411
|
+
return value ? value.__v_isVNode === true : false;
|
|
442
412
|
}
|
|
443
|
-
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region packages/runtime-core/src/component.ts
|
|
444
415
|
const classifyRE = /(?:^|[-_])\w/g;
|
|
445
416
|
const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
446
417
|
function getComponentName(Component, includeInferred = true) {
|
|
447
|
-
|
|
418
|
+
return (0, _vue_shared.isFunction)(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
448
419
|
}
|
|
449
420
|
function formatComponentName(instance, Component, isRoot = false) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
const warn = warn$1 ;
|
|
473
|
-
|
|
421
|
+
let name = getComponentName(Component);
|
|
422
|
+
if (!name && Component.__file) {
|
|
423
|
+
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
424
|
+
if (match) name = match[1];
|
|
425
|
+
}
|
|
426
|
+
if (!name && instance) {
|
|
427
|
+
const inferFromRegistry = (registry) => {
|
|
428
|
+
for (const key in registry) if (registry[key] === Component) return key;
|
|
429
|
+
};
|
|
430
|
+
name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
|
431
|
+
}
|
|
432
|
+
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
433
|
+
}
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region packages/runtime-core/src/index.ts
|
|
436
|
+
const warn$2 = warn$3;
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region packages/server-renderer/src/helpers/ssrRenderList.ts
|
|
474
439
|
function ssrRenderList(source, renderItem) {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
for (let i = 0, l = keys.length; i < l; i++) {
|
|
496
|
-
const key = keys[i];
|
|
497
|
-
renderItem(source[key], key, i);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
440
|
+
if ((0, _vue_shared.isArray)(source) || (0, _vue_shared.isString)(source)) for (let i = 0, l = source.length; i < l; i++) renderItem(source[i], i);
|
|
441
|
+
else if (typeof source === "number") {
|
|
442
|
+
if (!Number.isInteger(source) || source < 0) {
|
|
443
|
+
warn$2(`The v-for range expects a positive integer value but got ${source}.`);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
447
|
+
} else if ((0, _vue_shared.isObject)(source)) if (source[Symbol.iterator]) {
|
|
448
|
+
const arr = Array.from(source);
|
|
449
|
+
for (let i = 0, l = arr.length; i < l; i++) renderItem(arr[i], i);
|
|
450
|
+
} else {
|
|
451
|
+
const keys = Object.keys(source);
|
|
452
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
453
|
+
const key = keys[i];
|
|
454
|
+
renderItem(source[key], key, i);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region packages/server-renderer/src/helpers/ssrRenderSuspense.ts
|
|
503
460
|
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
} else {
|
|
507
|
-
push(`<!---->`);
|
|
508
|
-
}
|
|
461
|
+
if (renderContent) renderContent();
|
|
462
|
+
else push(`<!---->`);
|
|
509
463
|
}
|
|
510
|
-
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region packages/server-renderer/src/helpers/ssrGetDirectiveProps.ts
|
|
511
466
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return {};
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
const ssrLooseEqual = shared.looseEqual;
|
|
467
|
+
if (typeof dir !== "function" && dir.getSSRProps) return dir.getSSRProps({
|
|
468
|
+
dir,
|
|
469
|
+
instance: vue.ssrUtils.getComponentPublicInstance(instance.$),
|
|
470
|
+
value,
|
|
471
|
+
oldValue: void 0,
|
|
472
|
+
arg,
|
|
473
|
+
modifiers
|
|
474
|
+
}, null) || {};
|
|
475
|
+
return {};
|
|
476
|
+
}
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region packages/server-renderer/src/helpers/ssrVModelHelpers.ts
|
|
479
|
+
const ssrLooseEqual = _vue_shared.looseEqual;
|
|
529
480
|
function ssrLooseContain(arr, value) {
|
|
530
|
-
|
|
481
|
+
return (0, _vue_shared.looseIndexOf)(arr, value) > -1;
|
|
531
482
|
}
|
|
532
483
|
function ssrRenderDynamicModel(type, model, value) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
default:
|
|
539
|
-
return ssrRenderAttr("value", model);
|
|
540
|
-
}
|
|
484
|
+
switch (type) {
|
|
485
|
+
case "radio": return (0, _vue_shared.looseEqual)(model, value) ? " checked" : "";
|
|
486
|
+
case "checkbox": return ((0, _vue_shared.isArray)(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
|
|
487
|
+
default: return ssrRenderAttr("value", model);
|
|
488
|
+
}
|
|
541
489
|
}
|
|
542
490
|
function ssrGetDynamicModelProps(existingProps = {}, model) {
|
|
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
|
-
|
|
571
|
-
|
|
572
|
-
ssrRenderSuspense: ssrRenderSuspense,
|
|
573
|
-
ssrRenderTeleport: ssrRenderTeleport,
|
|
574
|
-
ssrRenderVNode: renderVNode
|
|
491
|
+
const { type, value } = existingProps;
|
|
492
|
+
switch (type) {
|
|
493
|
+
case "radio": return (0, _vue_shared.looseEqual)(model, value) ? { checked: true } : null;
|
|
494
|
+
case "checkbox": return ((0, _vue_shared.isArray)(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
|
|
495
|
+
default: return { value: model };
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region packages/server-renderer/src/internal.ts
|
|
500
|
+
var internal_exports = /* @__PURE__ */ __exportAll({
|
|
501
|
+
ssrGetDirectiveProps: () => ssrGetDirectiveProps,
|
|
502
|
+
ssrGetDynamicModelProps: () => ssrGetDynamicModelProps,
|
|
503
|
+
ssrIncludeBooleanAttr: () => _vue_shared.includeBooleanAttr,
|
|
504
|
+
ssrInterpolate: () => ssrInterpolate,
|
|
505
|
+
ssrLooseContain: () => ssrLooseContain,
|
|
506
|
+
ssrLooseEqual: () => ssrLooseEqual,
|
|
507
|
+
ssrRenderAttr: () => ssrRenderAttr,
|
|
508
|
+
ssrRenderAttrs: () => ssrRenderAttrs,
|
|
509
|
+
ssrRenderClass: () => ssrRenderClass,
|
|
510
|
+
ssrRenderComponent: () => ssrRenderComponent,
|
|
511
|
+
ssrRenderDynamicAttr: () => ssrRenderDynamicAttr,
|
|
512
|
+
ssrRenderDynamicModel: () => ssrRenderDynamicModel,
|
|
513
|
+
ssrRenderList: () => ssrRenderList,
|
|
514
|
+
ssrRenderSlot: () => ssrRenderSlot,
|
|
515
|
+
ssrRenderSlotInner: () => ssrRenderSlotInner,
|
|
516
|
+
ssrRenderStyle: () => ssrRenderStyle,
|
|
517
|
+
ssrRenderSuspense: () => ssrRenderSuspense,
|
|
518
|
+
ssrRenderTeleport: () => ssrRenderTeleport,
|
|
519
|
+
ssrRenderVNode: () => renderVNode
|
|
575
520
|
});
|
|
576
|
-
|
|
577
|
-
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region packages/server-renderer/src/helpers/ssrCompile.ts
|
|
523
|
+
const compileCache = Object.create(null);
|
|
578
524
|
function ssrCompile(template, instance) {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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
|
-
|
|
525
|
+
const Component = instance.type;
|
|
526
|
+
const { isCustomElement, compilerOptions } = instance.appContext.config;
|
|
527
|
+
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
|
528
|
+
const finalCompilerOptions = (0, _vue_shared.extend)((0, _vue_shared.extend)({
|
|
529
|
+
isCustomElement,
|
|
530
|
+
delimiters
|
|
531
|
+
}, compilerOptions), componentCompilerOptions);
|
|
532
|
+
finalCompilerOptions.isCustomElement = finalCompilerOptions.isCustomElement || _vue_shared.NO;
|
|
533
|
+
finalCompilerOptions.isNativeTag = finalCompilerOptions.isNativeTag || _vue_shared.NO;
|
|
534
|
+
const cacheKey = JSON.stringify({
|
|
535
|
+
template,
|
|
536
|
+
compilerOptions: finalCompilerOptions
|
|
537
|
+
}, (key, value) => {
|
|
538
|
+
return (0, _vue_shared.isFunction)(value) ? value.toString() : value;
|
|
539
|
+
});
|
|
540
|
+
const cached = compileCache[cacheKey];
|
|
541
|
+
if (cached) return cached;
|
|
542
|
+
finalCompilerOptions.onError = (err) => {
|
|
543
|
+
{
|
|
544
|
+
const message = `[@vue/server-renderer] Template compilation error: ${err.message}`;
|
|
545
|
+
const codeFrame = err.loc && (0, _vue_shared.generateCodeFrame)(template, err.loc.start.offset, err.loc.end.offset);
|
|
546
|
+
(0, vue.warn)(codeFrame ? `${message}\n${codeFrame}` : message);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
const { code } = (0, _vue_compiler_ssr.compile)(template, finalCompilerOptions);
|
|
550
|
+
const requireMap = {
|
|
551
|
+
vue,
|
|
552
|
+
"vue/server-renderer": internal_exports
|
|
553
|
+
};
|
|
554
|
+
const fakeRequire = (id) => requireMap[id];
|
|
555
|
+
return compileCache[cacheKey] = Function("require", code)(fakeRequire);
|
|
556
|
+
}
|
|
557
|
+
//#endregion
|
|
558
|
+
//#region packages/server-renderer/src/render.ts
|
|
559
|
+
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = vue.ssrUtils;
|
|
560
|
+
function cleanupContext(context) {
|
|
561
|
+
let firstError;
|
|
562
|
+
if (context.__watcherHandles) {
|
|
563
|
+
for (const unwatch of context.__watcherHandles) try {
|
|
564
|
+
unwatch();
|
|
565
|
+
} catch (err) {
|
|
566
|
+
if (firstError === void 0) firstError = err;
|
|
567
|
+
}
|
|
568
|
+
context.__watcherHandles.length = 0;
|
|
569
|
+
}
|
|
570
|
+
if (context.__instanceScopes) {
|
|
571
|
+
for (const scope of context.__instanceScopes) try {
|
|
572
|
+
scope.stop();
|
|
573
|
+
} catch (err) {
|
|
574
|
+
if (firstError === void 0) firstError = err;
|
|
575
|
+
}
|
|
576
|
+
context.__instanceScopes.length = 0;
|
|
577
|
+
}
|
|
578
|
+
if (firstError !== void 0) throw firstError;
|
|
626
579
|
}
|
|
627
|
-
|
|
628
|
-
const {
|
|
629
|
-
createComponentInstance,
|
|
630
|
-
setCurrentRenderingInstance,
|
|
631
|
-
setupComponent,
|
|
632
|
-
renderComponentRoot,
|
|
633
|
-
normalizeVNode,
|
|
634
|
-
pushWarningContext,
|
|
635
|
-
popWarningContext
|
|
636
|
-
} = Vue.ssrUtils;
|
|
637
580
|
function createBuffer() {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
};
|
|
581
|
+
let appendable = false;
|
|
582
|
+
const buffer = [];
|
|
583
|
+
return {
|
|
584
|
+
getBuffer() {
|
|
585
|
+
return buffer;
|
|
586
|
+
},
|
|
587
|
+
push(item) {
|
|
588
|
+
const isStringItem = (0, _vue_shared.isString)(item);
|
|
589
|
+
if (appendable && isStringItem) {
|
|
590
|
+
buffer[buffer.length - 1] += item;
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
buffer.push(item);
|
|
594
|
+
appendable = isStringItem;
|
|
595
|
+
if ((0, _vue_shared.isPromise)(item) || (0, _vue_shared.isArray)(item) && item.hasAsync) buffer.hasAsync = true;
|
|
596
|
+
}
|
|
597
|
+
};
|
|
657
598
|
}
|
|
658
599
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
let prefetches = instance.sp;
|
|
673
|
-
if (hasAsyncSetup || prefetches) {
|
|
674
|
-
const p = Promise.resolve(res).then(() => {
|
|
675
|
-
if (hasAsyncSetup) prefetches = instance.sp;
|
|
676
|
-
if (prefetches) {
|
|
677
|
-
return Promise.all(
|
|
678
|
-
prefetches.map((prefetch) => prefetch.call(instance.proxy))
|
|
679
|
-
);
|
|
680
|
-
}
|
|
681
|
-
}).catch(shared.NOOP);
|
|
682
|
-
return p.then(() => renderComponentSubTree(instance, slotScopeId));
|
|
683
|
-
} else {
|
|
684
|
-
return renderComponentSubTree(instance, slotScopeId);
|
|
685
|
-
}
|
|
600
|
+
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
601
|
+
const context = instance.appContext.provides[vue.ssrContextKey];
|
|
602
|
+
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
603
|
+
pushWarningContext(vnode);
|
|
604
|
+
const res = setupComponent(instance, true);
|
|
605
|
+
popWarningContext();
|
|
606
|
+
const hasAsyncSetup = (0, _vue_shared.isPromise)(res);
|
|
607
|
+
let prefetches = instance.sp;
|
|
608
|
+
if (hasAsyncSetup || prefetches) return Promise.resolve(res).then(() => {
|
|
609
|
+
if (hasAsyncSetup) prefetches = instance.sp;
|
|
610
|
+
if (prefetches) return Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)));
|
|
611
|
+
}).catch(_vue_shared.NOOP).then(() => renderComponentSubTree(instance, slotScopeId));
|
|
612
|
+
else return renderComponentSubTree(instance, slotScopeId);
|
|
686
613
|
}
|
|
687
614
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
instance.proxy,
|
|
737
|
-
push,
|
|
738
|
-
instance,
|
|
739
|
-
attrs,
|
|
740
|
-
// compiler-optimized bindings
|
|
741
|
-
instance.props,
|
|
742
|
-
instance.setupState,
|
|
743
|
-
instance.data,
|
|
744
|
-
instance.ctx
|
|
745
|
-
);
|
|
746
|
-
} finally {
|
|
747
|
-
setCurrentRenderingInstance(prev);
|
|
748
|
-
}
|
|
749
|
-
} else if (instance.render && instance.render !== shared.NOOP) {
|
|
750
|
-
renderVNode(
|
|
751
|
-
push,
|
|
752
|
-
instance.subTree = renderComponentRoot(instance),
|
|
753
|
-
instance,
|
|
754
|
-
slotScopeId
|
|
755
|
-
);
|
|
756
|
-
} else {
|
|
757
|
-
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
758
|
-
Vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
759
|
-
push(`<!---->`);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
popWarningContext();
|
|
763
|
-
return getBuffer();
|
|
615
|
+
pushWarningContext(instance.vnode);
|
|
616
|
+
const comp = instance.type;
|
|
617
|
+
const { getBuffer, push } = createBuffer();
|
|
618
|
+
if ((0, _vue_shared.isFunction)(comp)) {
|
|
619
|
+
let root = renderComponentRoot(instance);
|
|
620
|
+
if (!comp.props) {
|
|
621
|
+
for (const key in instance.attrs) if (key.startsWith(`data-v-`)) (root.props || (root.props = {}))[key] = ``;
|
|
622
|
+
}
|
|
623
|
+
renderVNode(push, instance.subTree = root, instance, slotScopeId);
|
|
624
|
+
} else {
|
|
625
|
+
if ((!instance.render || instance.render === _vue_shared.NOOP) && !instance.ssrRender && !comp.ssrRender && (0, _vue_shared.isString)(comp.template)) comp.ssrRender = ssrCompile(comp.template, instance);
|
|
626
|
+
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
627
|
+
if (ssrRender) {
|
|
628
|
+
let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|
|
629
|
+
let hasCloned = false;
|
|
630
|
+
let cur = instance;
|
|
631
|
+
while (true) {
|
|
632
|
+
const scopeId = cur.vnode.scopeId;
|
|
633
|
+
if (scopeId) {
|
|
634
|
+
if (!hasCloned) {
|
|
635
|
+
attrs = { ...attrs };
|
|
636
|
+
hasCloned = true;
|
|
637
|
+
}
|
|
638
|
+
attrs[scopeId] = "";
|
|
639
|
+
}
|
|
640
|
+
const parent = cur.parent;
|
|
641
|
+
if (parent && parent.subTree && parent.subTree === cur.vnode) cur = parent;
|
|
642
|
+
else break;
|
|
643
|
+
}
|
|
644
|
+
if (slotScopeId) {
|
|
645
|
+
if (!hasCloned) attrs = { ...attrs };
|
|
646
|
+
const slotScopeIdList = slotScopeId.trim().split(" ");
|
|
647
|
+
for (let i = 0; i < slotScopeIdList.length; i++) attrs[slotScopeIdList[i]] = "";
|
|
648
|
+
}
|
|
649
|
+
const prev = setCurrentRenderingInstance(instance);
|
|
650
|
+
try {
|
|
651
|
+
ssrRender(instance.proxy, push, instance, attrs, instance.props, instance.setupState, instance.data, instance.ctx);
|
|
652
|
+
} finally {
|
|
653
|
+
setCurrentRenderingInstance(prev);
|
|
654
|
+
}
|
|
655
|
+
} else if (instance.render && instance.render !== _vue_shared.NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
|
|
656
|
+
else {
|
|
657
|
+
(0, vue.warn)(`Component ${comp.name || comp.__file || `<Anonymous>`} is missing template or render function.`);
|
|
658
|
+
push(`<!---->`);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
popWarningContext();
|
|
662
|
+
return getBuffer();
|
|
764
663
|
}
|
|
765
664
|
function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
parentComponent,
|
|
791
|
-
slotScopeId
|
|
792
|
-
);
|
|
793
|
-
push(`<!--]-->`);
|
|
794
|
-
break;
|
|
795
|
-
default:
|
|
796
|
-
if (shapeFlag & 1) {
|
|
797
|
-
renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
798
|
-
} else if (shapeFlag & 6) {
|
|
799
|
-
push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
800
|
-
} else if (shapeFlag & 64) {
|
|
801
|
-
renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
802
|
-
} else if (shapeFlag & 128) {
|
|
803
|
-
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
804
|
-
} else {
|
|
805
|
-
Vue.warn(
|
|
806
|
-
"[@vue/server-renderer] Invalid VNode type:",
|
|
807
|
-
type,
|
|
808
|
-
`(${typeof type})`
|
|
809
|
-
);
|
|
810
|
-
}
|
|
811
|
-
}
|
|
665
|
+
const { type, shapeFlag, children, dirs, props } = vnode;
|
|
666
|
+
if (dirs) vnode.props = applySSRDirectives(vnode, props, dirs);
|
|
667
|
+
switch (type) {
|
|
668
|
+
case vue.Text:
|
|
669
|
+
push((0, _vue_shared.escapeHtml)(children));
|
|
670
|
+
break;
|
|
671
|
+
case vue.Comment:
|
|
672
|
+
push(children ? `<!--${(0, _vue_shared.escapeHtmlComment)(children)}-->` : `<!---->`);
|
|
673
|
+
break;
|
|
674
|
+
case vue.Static:
|
|
675
|
+
push(children);
|
|
676
|
+
break;
|
|
677
|
+
case vue.Fragment:
|
|
678
|
+
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
679
|
+
push(`<!--[-->`);
|
|
680
|
+
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
681
|
+
push(`<!--]-->`);
|
|
682
|
+
break;
|
|
683
|
+
default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
684
|
+
else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
685
|
+
else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
686
|
+
else if (shapeFlag & 128) renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
687
|
+
else (0, vue.warn)("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
|
|
688
|
+
}
|
|
812
689
|
}
|
|
813
690
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
814
|
-
|
|
815
|
-
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
816
|
-
}
|
|
691
|
+
for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
817
692
|
}
|
|
818
693
|
function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
if (!hasChildrenOverride) {
|
|
856
|
-
if (shapeFlag & 8) {
|
|
857
|
-
push(shared.escapeHtml(children));
|
|
858
|
-
} else if (shapeFlag & 16) {
|
|
859
|
-
renderVNodeChildren(
|
|
860
|
-
push,
|
|
861
|
-
children,
|
|
862
|
-
parentComponent,
|
|
863
|
-
slotScopeId
|
|
864
|
-
);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
push(`</${tag}>`);
|
|
868
|
-
}
|
|
694
|
+
const tag = vnode.type;
|
|
695
|
+
let { props, children, shapeFlag, scopeId } = vnode;
|
|
696
|
+
let openTag = `<${tag}`;
|
|
697
|
+
if (props) openTag += ssrRenderAttrs(props, tag);
|
|
698
|
+
if (scopeId) openTag += ` ${scopeId}`;
|
|
699
|
+
let curParent = parentComponent;
|
|
700
|
+
let curVnode = vnode;
|
|
701
|
+
while (curParent && curVnode === curParent.subTree) {
|
|
702
|
+
curVnode = curParent.vnode;
|
|
703
|
+
if (curVnode.scopeId) openTag += ` ${curVnode.scopeId}`;
|
|
704
|
+
curParent = curParent.parent;
|
|
705
|
+
}
|
|
706
|
+
if (slotScopeId) openTag += ` ${slotScopeId}`;
|
|
707
|
+
push(openTag + `>`);
|
|
708
|
+
if (!(0, _vue_shared.isVoidTag)(tag)) {
|
|
709
|
+
let hasChildrenOverride = false;
|
|
710
|
+
if (props) {
|
|
711
|
+
if (props.innerHTML) {
|
|
712
|
+
hasChildrenOverride = true;
|
|
713
|
+
push(props.innerHTML);
|
|
714
|
+
} else if (props.textContent) {
|
|
715
|
+
hasChildrenOverride = true;
|
|
716
|
+
push((0, _vue_shared.escapeHtml)(props.textContent));
|
|
717
|
+
} else if (tag === "textarea" && props.value) {
|
|
718
|
+
hasChildrenOverride = true;
|
|
719
|
+
push((0, _vue_shared.escapeHtml)(props.value));
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
if (!hasChildrenOverride) {
|
|
723
|
+
if (shapeFlag & 8) push((0, _vue_shared.escapeHtml)(children));
|
|
724
|
+
else if (shapeFlag & 16) renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
725
|
+
}
|
|
726
|
+
push(`</${tag}>`);
|
|
727
|
+
}
|
|
869
728
|
}
|
|
870
729
|
function applySSRDirectives(vnode, rawProps, dirs) {
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
}
|
|
882
|
-
return Vue.mergeProps(rawProps || {}, ...toMerge);
|
|
730
|
+
const toMerge = [];
|
|
731
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
732
|
+
const binding = dirs[i];
|
|
733
|
+
const { dir: { getSSRProps } } = binding;
|
|
734
|
+
if (getSSRProps) {
|
|
735
|
+
const props = getSSRProps(binding, vnode);
|
|
736
|
+
if (props) toMerge.push(props);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return (0, vue.mergeProps)(rawProps || {}, ...toMerge);
|
|
883
740
|
}
|
|
884
741
|
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
renderVNodeChildren(
|
|
903
|
-
push2,
|
|
904
|
-
vnode.children,
|
|
905
|
-
parentComponent,
|
|
906
|
-
slotScopeId
|
|
907
|
-
);
|
|
908
|
-
},
|
|
909
|
-
target,
|
|
910
|
-
disabled || disabled === "",
|
|
911
|
-
parentComponent
|
|
912
|
-
);
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
const { isVNode: isVNode$1 } = Vue.ssrUtils;
|
|
742
|
+
const target = vnode.props && vnode.props.to;
|
|
743
|
+
const disabled = vnode.props && vnode.props.disabled;
|
|
744
|
+
if (!target) {
|
|
745
|
+
if (!disabled) (0, vue.warn)(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
746
|
+
return [];
|
|
747
|
+
}
|
|
748
|
+
if (!(0, _vue_shared.isString)(target)) {
|
|
749
|
+
(0, vue.warn)(`[@vue/server-renderer] Teleport target must be a query selector string.`);
|
|
750
|
+
return [];
|
|
751
|
+
}
|
|
752
|
+
ssrRenderTeleport(push, (push) => {
|
|
753
|
+
renderVNodeChildren(push, vnode.children, parentComponent, slotScopeId);
|
|
754
|
+
}, target, disabled || disabled === "", parentComponent);
|
|
755
|
+
}
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region packages/server-renderer/src/renderToString.ts
|
|
758
|
+
const { isVNode: isVNode$1 } = vue.ssrUtils;
|
|
916
759
|
function nestedUnrollBuffer(buffer, parentRet, startIndex) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
return nestedUnrollBuffer(buffer, "", i);
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
ret = result;
|
|
941
|
-
}
|
|
942
|
-
return ret;
|
|
760
|
+
if (!buffer.hasAsync) return parentRet + unrollBufferSync$1(buffer);
|
|
761
|
+
let ret = parentRet;
|
|
762
|
+
for (let i = startIndex; i < buffer.length; i += 1) {
|
|
763
|
+
const item = buffer[i];
|
|
764
|
+
if ((0, _vue_shared.isString)(item)) {
|
|
765
|
+
ret += item;
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if ((0, _vue_shared.isPromise)(item)) return item.then((nestedItem) => {
|
|
769
|
+
buffer[i] = nestedItem;
|
|
770
|
+
return nestedUnrollBuffer(buffer, ret, i);
|
|
771
|
+
});
|
|
772
|
+
const result = nestedUnrollBuffer(item, ret, 0);
|
|
773
|
+
if ((0, _vue_shared.isPromise)(result)) return result.then((nestedItem) => {
|
|
774
|
+
buffer[i] = nestedItem;
|
|
775
|
+
return nestedUnrollBuffer(buffer, "", i);
|
|
776
|
+
});
|
|
777
|
+
ret = result;
|
|
778
|
+
}
|
|
779
|
+
return ret;
|
|
943
780
|
}
|
|
944
781
|
function unrollBuffer$1(buffer) {
|
|
945
|
-
|
|
782
|
+
return nestedUnrollBuffer(buffer, "", 0);
|
|
946
783
|
}
|
|
947
784
|
function unrollBufferSync$1(buffer) {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
return ret;
|
|
785
|
+
let ret = "";
|
|
786
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
787
|
+
let item = buffer[i];
|
|
788
|
+
if ((0, _vue_shared.isString)(item)) ret += item;
|
|
789
|
+
else ret += unrollBufferSync$1(item);
|
|
790
|
+
}
|
|
791
|
+
return ret;
|
|
958
792
|
}
|
|
959
793
|
async function renderToString(input, context = {}) {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
unwatch();
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
return result;
|
|
794
|
+
if (isVNode$1(input)) return renderToString((0, vue.createApp)({ render: () => input }), context);
|
|
795
|
+
const vnode = (0, vue.createVNode)(input._component, input._props);
|
|
796
|
+
vnode.appContext = input._context;
|
|
797
|
+
input.provide(vue.ssrContextKey, context);
|
|
798
|
+
try {
|
|
799
|
+
const result = await unrollBuffer$1(await renderComponentVNode(vnode));
|
|
800
|
+
await resolveTeleports(context);
|
|
801
|
+
return result;
|
|
802
|
+
} finally {
|
|
803
|
+
cleanupContext(context);
|
|
804
|
+
}
|
|
975
805
|
}
|
|
976
806
|
async function resolveTeleports(context) {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
const { isVNode } = Vue.ssrUtils;
|
|
807
|
+
if (context.__teleportBuffers) {
|
|
808
|
+
context.teleports = context.teleports || {};
|
|
809
|
+
for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(await Promise.all([context.__teleportBuffers[key]]));
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region packages/server-renderer/src/renderToStream.ts
|
|
814
|
+
const { isVNode } = vue.ssrUtils;
|
|
988
815
|
async function unrollBuffer(buffer, stream) {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
stream.push(item);
|
|
997
|
-
} else {
|
|
998
|
-
await unrollBuffer(item, stream);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
} else {
|
|
1002
|
-
unrollBufferSync(buffer, stream);
|
|
1003
|
-
}
|
|
816
|
+
if (buffer.hasAsync) for (let i = 0; i < buffer.length; i++) {
|
|
817
|
+
let item = buffer[i];
|
|
818
|
+
if ((0, _vue_shared.isPromise)(item)) item = await item;
|
|
819
|
+
if ((0, _vue_shared.isString)(item)) stream.push(item);
|
|
820
|
+
else await unrollBuffer(item, stream);
|
|
821
|
+
}
|
|
822
|
+
else unrollBufferSync(buffer, stream);
|
|
1004
823
|
}
|
|
1005
824
|
function unrollBufferSync(buffer, stream) {
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
unrollBufferSync(item, stream);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
825
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
826
|
+
const item = buffer[i];
|
|
827
|
+
if ((0, _vue_shared.isString)(item)) stream.push(item);
|
|
828
|
+
else unrollBufferSync(item, stream);
|
|
829
|
+
}
|
|
1014
830
|
}
|
|
1015
831
|
function renderToSimpleStream(input, context, stream) {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
832
|
+
if (isVNode(input)) return renderToSimpleStream((0, vue.createApp)({ render: () => input }), context, stream);
|
|
833
|
+
const vnode = (0, vue.createVNode)(input._component, input._props);
|
|
834
|
+
vnode.appContext = input._context;
|
|
835
|
+
input.provide(vue.ssrContextKey, context);
|
|
836
|
+
let cleaned = false;
|
|
837
|
+
const finalize = () => {
|
|
838
|
+
if (cleaned) return;
|
|
839
|
+
cleaned = true;
|
|
840
|
+
cleanupContext(context);
|
|
841
|
+
};
|
|
842
|
+
Promise.resolve().then(() => renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
|
843
|
+
finalize();
|
|
844
|
+
return stream.push(null);
|
|
845
|
+
}).catch((error) => {
|
|
846
|
+
try {
|
|
847
|
+
finalize();
|
|
848
|
+
} catch {}
|
|
849
|
+
stream.destroy(error);
|
|
850
|
+
});
|
|
851
|
+
return stream;
|
|
1036
852
|
}
|
|
853
|
+
/**
|
|
854
|
+
* @deprecated
|
|
855
|
+
*/
|
|
1037
856
|
function renderToStream(input, context = {}) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
);
|
|
1041
|
-
return renderToNodeStream(input, context);
|
|
857
|
+
console.warn(`[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`);
|
|
858
|
+
return renderToNodeStream(input, context);
|
|
1042
859
|
}
|
|
1043
860
|
function renderToNodeStream(input, context = {}) {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
throw new Error(
|
|
1048
|
-
`ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
|
|
1049
|
-
);
|
|
1050
|
-
}
|
|
1051
|
-
return renderToSimpleStream(input, context, stream);
|
|
861
|
+
const stream = new (require("node:stream")).Readable({ read() {} });
|
|
862
|
+
if (!stream) throw new Error("ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.");
|
|
863
|
+
return renderToSimpleStream(input, context, stream);
|
|
1052
864
|
}
|
|
1053
865
|
function pipeToNodeWritable(input, context = {}, writable) {
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
writable.destroy(err);
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
866
|
+
renderToSimpleStream(input, context, {
|
|
867
|
+
push(content) {
|
|
868
|
+
if (content != null) writable.write(content);
|
|
869
|
+
else writable.end();
|
|
870
|
+
},
|
|
871
|
+
destroy(err) {
|
|
872
|
+
writable.destroy(err);
|
|
873
|
+
}
|
|
874
|
+
});
|
|
1066
875
|
}
|
|
1067
876
|
function renderToWebStream(input, context = {}) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
},
|
|
1091
|
-
cancel() {
|
|
1092
|
-
cancelled = true;
|
|
1093
|
-
}
|
|
1094
|
-
});
|
|
877
|
+
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.");
|
|
878
|
+
const encoder = new TextEncoder();
|
|
879
|
+
let cancelled = false;
|
|
880
|
+
return new ReadableStream({
|
|
881
|
+
start(controller) {
|
|
882
|
+
renderToSimpleStream(input, context, {
|
|
883
|
+
push(content) {
|
|
884
|
+
if (cancelled) return;
|
|
885
|
+
if (content != null) controller.enqueue(encoder.encode(content));
|
|
886
|
+
else controller.close();
|
|
887
|
+
},
|
|
888
|
+
destroy(err) {
|
|
889
|
+
controller.error(err);
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
},
|
|
893
|
+
cancel() {
|
|
894
|
+
cancelled = true;
|
|
895
|
+
}
|
|
896
|
+
});
|
|
1095
897
|
}
|
|
1096
898
|
function pipeToWebWritable(input, context = {}, writable) {
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
Vue.initDirectivesForSSR();
|
|
1123
|
-
|
|
1124
|
-
exports.ssrIncludeBooleanAttr = shared.includeBooleanAttr;
|
|
899
|
+
const writer = writable.getWriter();
|
|
900
|
+
const encoder = new TextEncoder();
|
|
901
|
+
let hasReady = false;
|
|
902
|
+
try {
|
|
903
|
+
hasReady = (0, _vue_shared.isPromise)(writer.ready);
|
|
904
|
+
} catch (e) {}
|
|
905
|
+
renderToSimpleStream(input, context, {
|
|
906
|
+
async push(content) {
|
|
907
|
+
if (hasReady) await writer.ready;
|
|
908
|
+
if (content != null) return writer.write(encoder.encode(content));
|
|
909
|
+
else return writer.close();
|
|
910
|
+
},
|
|
911
|
+
destroy(err) {
|
|
912
|
+
console.log(err);
|
|
913
|
+
writer.close();
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
//#endregion
|
|
918
|
+
//#region packages/server-renderer/src/index.ts
|
|
919
|
+
(0, vue.initDirectivesForSSR)();
|
|
920
|
+
//#endregion
|
|
1125
921
|
exports.pipeToNodeWritable = pipeToNodeWritable;
|
|
1126
922
|
exports.pipeToWebWritable = pipeToWebWritable;
|
|
1127
923
|
exports.renderToNodeStream = renderToNodeStream;
|
|
@@ -1131,6 +927,7 @@ exports.renderToString = renderToString;
|
|
|
1131
927
|
exports.renderToWebStream = renderToWebStream;
|
|
1132
928
|
exports.ssrGetDirectiveProps = ssrGetDirectiveProps;
|
|
1133
929
|
exports.ssrGetDynamicModelProps = ssrGetDynamicModelProps;
|
|
930
|
+
exports.ssrIncludeBooleanAttr = _vue_shared.includeBooleanAttr;
|
|
1134
931
|
exports.ssrInterpolate = ssrInterpolate;
|
|
1135
932
|
exports.ssrLooseContain = ssrLooseContain;
|
|
1136
933
|
exports.ssrLooseEqual = ssrLooseEqual;
|