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