@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,857 +1,648 @@
|
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const { ensureValidVNode } = Vue.ssrUtils;
|
|
95
|
+
return renderComponentVNode((0, vue.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
96
|
+
}
|
|
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/server-renderer/src/helpers/ssrRenderList.ts
|
|
219
177
|
function ssrRenderList(source, renderItem) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const keys = Object.keys(source);
|
|
236
|
-
for (let i = 0, l = keys.length; i < l; i++) {
|
|
237
|
-
const key = keys[i];
|
|
238
|
-
renderItem(source[key], key, i);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
178
|
+
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);
|
|
179
|
+
else if (typeof source === "number") for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
180
|
+
else if ((0, _vue_shared.isObject)(source)) if (source[Symbol.iterator]) {
|
|
181
|
+
const arr = Array.from(source);
|
|
182
|
+
for (let i = 0, l = arr.length; i < l; i++) renderItem(arr[i], i);
|
|
183
|
+
} else {
|
|
184
|
+
const keys = Object.keys(source);
|
|
185
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
186
|
+
const key = keys[i];
|
|
187
|
+
renderItem(source[key], key, i);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region packages/server-renderer/src/helpers/ssrRenderSuspense.ts
|
|
244
193
|
async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} else {
|
|
248
|
-
push(`<!---->`);
|
|
249
|
-
}
|
|
194
|
+
if (renderContent) renderContent();
|
|
195
|
+
else push(`<!---->`);
|
|
250
196
|
}
|
|
251
|
-
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region packages/server-renderer/src/helpers/ssrGetDirectiveProps.ts
|
|
252
199
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return {};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const ssrLooseEqual = shared.looseEqual;
|
|
200
|
+
if (typeof dir !== "function" && dir.getSSRProps) return dir.getSSRProps({
|
|
201
|
+
dir,
|
|
202
|
+
instance: vue.ssrUtils.getComponentPublicInstance(instance.$),
|
|
203
|
+
value,
|
|
204
|
+
oldValue: void 0,
|
|
205
|
+
arg,
|
|
206
|
+
modifiers
|
|
207
|
+
}, null) || {};
|
|
208
|
+
return {};
|
|
209
|
+
}
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region packages/server-renderer/src/helpers/ssrVModelHelpers.ts
|
|
212
|
+
const ssrLooseEqual = _vue_shared.looseEqual;
|
|
270
213
|
function ssrLooseContain(arr, value) {
|
|
271
|
-
|
|
214
|
+
return (0, _vue_shared.looseIndexOf)(arr, value) > -1;
|
|
272
215
|
}
|
|
273
216
|
function ssrRenderDynamicModel(type, model, value) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
default:
|
|
280
|
-
return ssrRenderAttr("value", model);
|
|
281
|
-
}
|
|
217
|
+
switch (type) {
|
|
218
|
+
case "radio": return (0, _vue_shared.looseEqual)(model, value) ? " checked" : "";
|
|
219
|
+
case "checkbox": return ((0, _vue_shared.isArray)(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
|
|
220
|
+
default: return ssrRenderAttr("value", model);
|
|
221
|
+
}
|
|
282
222
|
}
|
|
283
223
|
function ssrGetDynamicModelProps(existingProps = {}, model) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ssrRenderSuspense: ssrRenderSuspense,
|
|
314
|
-
ssrRenderTeleport: ssrRenderTeleport,
|
|
315
|
-
ssrRenderVNode: renderVNode
|
|
224
|
+
const { type, value } = existingProps;
|
|
225
|
+
switch (type) {
|
|
226
|
+
case "radio": return (0, _vue_shared.looseEqual)(model, value) ? { checked: true } : null;
|
|
227
|
+
case "checkbox": return ((0, _vue_shared.isArray)(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
|
|
228
|
+
default: return { value: model };
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region packages/server-renderer/src/internal.ts
|
|
233
|
+
var internal_exports = /* @__PURE__ */ __exportAll({
|
|
234
|
+
ssrGetDirectiveProps: () => ssrGetDirectiveProps,
|
|
235
|
+
ssrGetDynamicModelProps: () => ssrGetDynamicModelProps,
|
|
236
|
+
ssrIncludeBooleanAttr: () => _vue_shared.includeBooleanAttr,
|
|
237
|
+
ssrInterpolate: () => ssrInterpolate,
|
|
238
|
+
ssrLooseContain: () => ssrLooseContain,
|
|
239
|
+
ssrLooseEqual: () => ssrLooseEqual,
|
|
240
|
+
ssrRenderAttr: () => ssrRenderAttr,
|
|
241
|
+
ssrRenderAttrs: () => ssrRenderAttrs,
|
|
242
|
+
ssrRenderClass: () => ssrRenderClass,
|
|
243
|
+
ssrRenderComponent: () => ssrRenderComponent,
|
|
244
|
+
ssrRenderDynamicAttr: () => ssrRenderDynamicAttr,
|
|
245
|
+
ssrRenderDynamicModel: () => ssrRenderDynamicModel,
|
|
246
|
+
ssrRenderList: () => ssrRenderList,
|
|
247
|
+
ssrRenderSlot: () => ssrRenderSlot,
|
|
248
|
+
ssrRenderSlotInner: () => ssrRenderSlotInner,
|
|
249
|
+
ssrRenderStyle: () => ssrRenderStyle,
|
|
250
|
+
ssrRenderSuspense: () => ssrRenderSuspense,
|
|
251
|
+
ssrRenderTeleport: () => ssrRenderTeleport,
|
|
252
|
+
ssrRenderVNode: () => renderVNode
|
|
316
253
|
});
|
|
317
|
-
|
|
318
|
-
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region packages/server-renderer/src/helpers/ssrCompile.ts
|
|
256
|
+
const compileCache = Object.create(null);
|
|
319
257
|
function ssrCompile(template, instance) {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
258
|
+
const Component = instance.type;
|
|
259
|
+
const { isCustomElement, compilerOptions } = instance.appContext.config;
|
|
260
|
+
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
|
261
|
+
const finalCompilerOptions = (0, _vue_shared.extend)((0, _vue_shared.extend)({
|
|
262
|
+
isCustomElement,
|
|
263
|
+
delimiters
|
|
264
|
+
}, compilerOptions), componentCompilerOptions);
|
|
265
|
+
finalCompilerOptions.isCustomElement = finalCompilerOptions.isCustomElement || _vue_shared.NO;
|
|
266
|
+
finalCompilerOptions.isNativeTag = finalCompilerOptions.isNativeTag || _vue_shared.NO;
|
|
267
|
+
const cacheKey = JSON.stringify({
|
|
268
|
+
template,
|
|
269
|
+
compilerOptions: finalCompilerOptions
|
|
270
|
+
}, (key, value) => {
|
|
271
|
+
return (0, _vue_shared.isFunction)(value) ? value.toString() : value;
|
|
272
|
+
});
|
|
273
|
+
const cached = compileCache[cacheKey];
|
|
274
|
+
if (cached) return cached;
|
|
275
|
+
finalCompilerOptions.onError = (err) => {
|
|
276
|
+
throw err;
|
|
277
|
+
};
|
|
278
|
+
const { code } = (0, _vue_compiler_ssr.compile)(template, finalCompilerOptions);
|
|
279
|
+
const requireMap = {
|
|
280
|
+
vue,
|
|
281
|
+
"vue/server-renderer": internal_exports
|
|
282
|
+
};
|
|
283
|
+
const fakeRequire = (id) => requireMap[id];
|
|
284
|
+
return compileCache[cacheKey] = Function("require", code)(fakeRequire);
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region packages/server-renderer/src/render.ts
|
|
288
|
+
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = vue.ssrUtils;
|
|
289
|
+
function cleanupContext(context) {
|
|
290
|
+
let firstError;
|
|
291
|
+
if (context.__watcherHandles) {
|
|
292
|
+
for (const unwatch of context.__watcherHandles) try {
|
|
293
|
+
unwatch();
|
|
294
|
+
} catch (err) {
|
|
295
|
+
if (firstError === void 0) firstError = err;
|
|
296
|
+
}
|
|
297
|
+
context.__watcherHandles.length = 0;
|
|
298
|
+
}
|
|
299
|
+
if (context.__instanceScopes) {
|
|
300
|
+
for (const scope of context.__instanceScopes) try {
|
|
301
|
+
scope.stop();
|
|
302
|
+
} catch (err) {
|
|
303
|
+
if (firstError === void 0) firstError = err;
|
|
304
|
+
}
|
|
305
|
+
context.__instanceScopes.length = 0;
|
|
306
|
+
}
|
|
307
|
+
if (firstError !== void 0) throw firstError;
|
|
308
|
+
}
|
|
371
309
|
function createBuffer() {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
};
|
|
310
|
+
let appendable = false;
|
|
311
|
+
const buffer = [];
|
|
312
|
+
return {
|
|
313
|
+
getBuffer() {
|
|
314
|
+
return buffer;
|
|
315
|
+
},
|
|
316
|
+
push(item) {
|
|
317
|
+
const isStringItem = (0, _vue_shared.isString)(item);
|
|
318
|
+
if (appendable && isStringItem) {
|
|
319
|
+
buffer[buffer.length - 1] += item;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
buffer.push(item);
|
|
323
|
+
appendable = isStringItem;
|
|
324
|
+
if ((0, _vue_shared.isPromise)(item) || (0, _vue_shared.isArray)(item) && item.hasAsync) buffer.hasAsync = true;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
391
327
|
}
|
|
392
328
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
let prefetches = instance.sp;
|
|
405
|
-
if (hasAsyncSetup || prefetches) {
|
|
406
|
-
const p = Promise.resolve(res).then(() => {
|
|
407
|
-
if (hasAsyncSetup) prefetches = instance.sp;
|
|
408
|
-
if (prefetches) {
|
|
409
|
-
return Promise.all(
|
|
410
|
-
prefetches.map((prefetch) => prefetch.call(instance.proxy))
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
}).catch(shared.NOOP);
|
|
414
|
-
return p.then(() => renderComponentSubTree(instance, slotScopeId));
|
|
415
|
-
} else {
|
|
416
|
-
return renderComponentSubTree(instance, slotScopeId);
|
|
417
|
-
}
|
|
329
|
+
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
330
|
+
const context = instance.appContext.provides[vue.ssrContextKey];
|
|
331
|
+
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
332
|
+
const res = setupComponent(instance, true);
|
|
333
|
+
const hasAsyncSetup = (0, _vue_shared.isPromise)(res);
|
|
334
|
+
let prefetches = instance.sp;
|
|
335
|
+
if (hasAsyncSetup || prefetches) return Promise.resolve(res).then(() => {
|
|
336
|
+
if (hasAsyncSetup) prefetches = instance.sp;
|
|
337
|
+
if (prefetches) return Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)));
|
|
338
|
+
}).catch(_vue_shared.NOOP).then(() => renderComponentSubTree(instance, slotScopeId));
|
|
339
|
+
else return renderComponentSubTree(instance, slotScopeId);
|
|
418
340
|
}
|
|
419
341
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
ssrRender(
|
|
467
|
-
instance.proxy,
|
|
468
|
-
push,
|
|
469
|
-
instance,
|
|
470
|
-
attrs,
|
|
471
|
-
// compiler-optimized bindings
|
|
472
|
-
instance.props,
|
|
473
|
-
instance.setupState,
|
|
474
|
-
instance.data,
|
|
475
|
-
instance.ctx
|
|
476
|
-
);
|
|
477
|
-
} finally {
|
|
478
|
-
setCurrentRenderingInstance(prev);
|
|
479
|
-
}
|
|
480
|
-
} else if (instance.render && instance.render !== shared.NOOP) {
|
|
481
|
-
renderVNode(
|
|
482
|
-
push,
|
|
483
|
-
instance.subTree = renderComponentRoot(instance),
|
|
484
|
-
instance,
|
|
485
|
-
slotScopeId
|
|
486
|
-
);
|
|
487
|
-
} else {
|
|
488
|
-
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
489
|
-
Vue.warn(`Component ${componentName} is missing template or render function.`);
|
|
490
|
-
push(`<!---->`);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
return getBuffer();
|
|
342
|
+
const comp = instance.type;
|
|
343
|
+
const { getBuffer, push } = createBuffer();
|
|
344
|
+
if ((0, _vue_shared.isFunction)(comp)) {
|
|
345
|
+
let root = renderComponentRoot(instance);
|
|
346
|
+
if (!comp.props) {
|
|
347
|
+
for (const key in instance.attrs) if (key.startsWith(`data-v-`)) (root.props || (root.props = {}))[key] = ``;
|
|
348
|
+
}
|
|
349
|
+
renderVNode(push, instance.subTree = root, instance, slotScopeId);
|
|
350
|
+
} else {
|
|
351
|
+
if ((!instance.render || instance.render === _vue_shared.NOOP) && !instance.ssrRender && !comp.ssrRender && (0, _vue_shared.isString)(comp.template)) comp.ssrRender = ssrCompile(comp.template, instance);
|
|
352
|
+
const ssrRender = instance.ssrRender || comp.ssrRender;
|
|
353
|
+
if (ssrRender) {
|
|
354
|
+
let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
|
|
355
|
+
let hasCloned = false;
|
|
356
|
+
let cur = instance;
|
|
357
|
+
while (true) {
|
|
358
|
+
const scopeId = cur.vnode.scopeId;
|
|
359
|
+
if (scopeId) {
|
|
360
|
+
if (!hasCloned) {
|
|
361
|
+
attrs = { ...attrs };
|
|
362
|
+
hasCloned = true;
|
|
363
|
+
}
|
|
364
|
+
attrs[scopeId] = "";
|
|
365
|
+
}
|
|
366
|
+
const parent = cur.parent;
|
|
367
|
+
if (parent && parent.subTree && parent.subTree === cur.vnode) cur = parent;
|
|
368
|
+
else break;
|
|
369
|
+
}
|
|
370
|
+
if (slotScopeId) {
|
|
371
|
+
if (!hasCloned) attrs = { ...attrs };
|
|
372
|
+
const slotScopeIdList = slotScopeId.trim().split(" ");
|
|
373
|
+
for (let i = 0; i < slotScopeIdList.length; i++) attrs[slotScopeIdList[i]] = "";
|
|
374
|
+
}
|
|
375
|
+
const prev = setCurrentRenderingInstance(instance);
|
|
376
|
+
try {
|
|
377
|
+
ssrRender(instance.proxy, push, instance, attrs, instance.props, instance.setupState, instance.data, instance.ctx);
|
|
378
|
+
} finally {
|
|
379
|
+
setCurrentRenderingInstance(prev);
|
|
380
|
+
}
|
|
381
|
+
} else if (instance.render && instance.render !== _vue_shared.NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
|
|
382
|
+
else {
|
|
383
|
+
(0, vue.warn)(`Component ${comp.name || comp.__file || `<Anonymous>`} is missing template or render function.`);
|
|
384
|
+
push(`<!---->`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return getBuffer();
|
|
494
388
|
}
|
|
495
389
|
function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
parentComponent,
|
|
521
|
-
slotScopeId
|
|
522
|
-
);
|
|
523
|
-
push(`<!--]-->`);
|
|
524
|
-
break;
|
|
525
|
-
default:
|
|
526
|
-
if (shapeFlag & 1) {
|
|
527
|
-
renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
528
|
-
} else if (shapeFlag & 6) {
|
|
529
|
-
push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
530
|
-
} else if (shapeFlag & 64) {
|
|
531
|
-
renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
532
|
-
} else if (shapeFlag & 128) {
|
|
533
|
-
renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
534
|
-
} else {
|
|
535
|
-
Vue.warn(
|
|
536
|
-
"[@vue/server-renderer] Invalid VNode type:",
|
|
537
|
-
type,
|
|
538
|
-
`(${typeof type})`
|
|
539
|
-
);
|
|
540
|
-
}
|
|
541
|
-
}
|
|
390
|
+
const { type, shapeFlag, children, dirs, props } = vnode;
|
|
391
|
+
if (dirs) vnode.props = applySSRDirectives(vnode, props, dirs);
|
|
392
|
+
switch (type) {
|
|
393
|
+
case vue.Text:
|
|
394
|
+
push((0, _vue_shared.escapeHtml)(children));
|
|
395
|
+
break;
|
|
396
|
+
case vue.Comment:
|
|
397
|
+
push(children ? `<!--${(0, _vue_shared.escapeHtmlComment)(children)}-->` : `<!---->`);
|
|
398
|
+
break;
|
|
399
|
+
case vue.Static:
|
|
400
|
+
push(children);
|
|
401
|
+
break;
|
|
402
|
+
case vue.Fragment:
|
|
403
|
+
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
404
|
+
push(`<!--[-->`);
|
|
405
|
+
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
406
|
+
push(`<!--]-->`);
|
|
407
|
+
break;
|
|
408
|
+
default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
409
|
+
else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
410
|
+
else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
411
|
+
else if (shapeFlag & 128) renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
412
|
+
else (0, vue.warn)("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
|
|
413
|
+
}
|
|
542
414
|
}
|
|
543
415
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
544
|
-
|
|
545
|
-
renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
546
|
-
}
|
|
416
|
+
for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
547
417
|
}
|
|
548
418
|
function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
if (!hasChildrenOverride) {
|
|
586
|
-
if (shapeFlag & 8) {
|
|
587
|
-
push(shared.escapeHtml(children));
|
|
588
|
-
} else if (shapeFlag & 16) {
|
|
589
|
-
renderVNodeChildren(
|
|
590
|
-
push,
|
|
591
|
-
children,
|
|
592
|
-
parentComponent,
|
|
593
|
-
slotScopeId
|
|
594
|
-
);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
push(`</${tag}>`);
|
|
598
|
-
}
|
|
419
|
+
const tag = vnode.type;
|
|
420
|
+
let { props, children, shapeFlag, scopeId } = vnode;
|
|
421
|
+
let openTag = `<${tag}`;
|
|
422
|
+
if (props) openTag += ssrRenderAttrs(props, tag);
|
|
423
|
+
if (scopeId) openTag += ` ${scopeId}`;
|
|
424
|
+
let curParent = parentComponent;
|
|
425
|
+
let curVnode = vnode;
|
|
426
|
+
while (curParent && curVnode === curParent.subTree) {
|
|
427
|
+
curVnode = curParent.vnode;
|
|
428
|
+
if (curVnode.scopeId) openTag += ` ${curVnode.scopeId}`;
|
|
429
|
+
curParent = curParent.parent;
|
|
430
|
+
}
|
|
431
|
+
if (slotScopeId) openTag += ` ${slotScopeId}`;
|
|
432
|
+
push(openTag + `>`);
|
|
433
|
+
if (!(0, _vue_shared.isVoidTag)(tag)) {
|
|
434
|
+
let hasChildrenOverride = false;
|
|
435
|
+
if (props) {
|
|
436
|
+
if (props.innerHTML) {
|
|
437
|
+
hasChildrenOverride = true;
|
|
438
|
+
push(props.innerHTML);
|
|
439
|
+
} else if (props.textContent) {
|
|
440
|
+
hasChildrenOverride = true;
|
|
441
|
+
push((0, _vue_shared.escapeHtml)(props.textContent));
|
|
442
|
+
} else if (tag === "textarea" && props.value) {
|
|
443
|
+
hasChildrenOverride = true;
|
|
444
|
+
push((0, _vue_shared.escapeHtml)(props.value));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
if (!hasChildrenOverride) {
|
|
448
|
+
if (shapeFlag & 8) push((0, _vue_shared.escapeHtml)(children));
|
|
449
|
+
else if (shapeFlag & 16) renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
450
|
+
}
|
|
451
|
+
push(`</${tag}>`);
|
|
452
|
+
}
|
|
599
453
|
}
|
|
600
454
|
function applySSRDirectives(vnode, rawProps, dirs) {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
return Vue.mergeProps(rawProps || {}, ...toMerge);
|
|
455
|
+
const toMerge = [];
|
|
456
|
+
for (let i = 0; i < dirs.length; i++) {
|
|
457
|
+
const binding = dirs[i];
|
|
458
|
+
const { dir: { getSSRProps } } = binding;
|
|
459
|
+
if (getSSRProps) {
|
|
460
|
+
const props = getSSRProps(binding, vnode);
|
|
461
|
+
if (props) toMerge.push(props);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return (0, vue.mergeProps)(rawProps || {}, ...toMerge);
|
|
613
465
|
}
|
|
614
466
|
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
renderVNodeChildren(
|
|
633
|
-
push2,
|
|
634
|
-
vnode.children,
|
|
635
|
-
parentComponent,
|
|
636
|
-
slotScopeId
|
|
637
|
-
);
|
|
638
|
-
},
|
|
639
|
-
target,
|
|
640
|
-
disabled || disabled === "",
|
|
641
|
-
parentComponent
|
|
642
|
-
);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
const { isVNode: isVNode$1 } = Vue.ssrUtils;
|
|
467
|
+
const target = vnode.props && vnode.props.to;
|
|
468
|
+
const disabled = vnode.props && vnode.props.disabled;
|
|
469
|
+
if (!target) {
|
|
470
|
+
if (!disabled) (0, vue.warn)(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
471
|
+
return [];
|
|
472
|
+
}
|
|
473
|
+
if (!(0, _vue_shared.isString)(target)) {
|
|
474
|
+
(0, vue.warn)(`[@vue/server-renderer] Teleport target must be a query selector string.`);
|
|
475
|
+
return [];
|
|
476
|
+
}
|
|
477
|
+
ssrRenderTeleport(push, (push) => {
|
|
478
|
+
renderVNodeChildren(push, vnode.children, parentComponent, slotScopeId);
|
|
479
|
+
}, target, disabled || disabled === "", parentComponent);
|
|
480
|
+
}
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region packages/server-renderer/src/renderToString.ts
|
|
483
|
+
const { isVNode: isVNode$1 } = vue.ssrUtils;
|
|
646
484
|
function nestedUnrollBuffer(buffer, parentRet, startIndex) {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
return nestedUnrollBuffer(buffer, "", i);
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
ret = result;
|
|
671
|
-
}
|
|
672
|
-
return ret;
|
|
485
|
+
if (!buffer.hasAsync) return parentRet + unrollBufferSync$1(buffer);
|
|
486
|
+
let ret = parentRet;
|
|
487
|
+
for (let i = startIndex; i < buffer.length; i += 1) {
|
|
488
|
+
const item = buffer[i];
|
|
489
|
+
if ((0, _vue_shared.isString)(item)) {
|
|
490
|
+
ret += item;
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
if ((0, _vue_shared.isPromise)(item)) return item.then((nestedItem) => {
|
|
494
|
+
buffer[i] = nestedItem;
|
|
495
|
+
return nestedUnrollBuffer(buffer, ret, i);
|
|
496
|
+
});
|
|
497
|
+
const result = nestedUnrollBuffer(item, ret, 0);
|
|
498
|
+
if ((0, _vue_shared.isPromise)(result)) return result.then((nestedItem) => {
|
|
499
|
+
buffer[i] = nestedItem;
|
|
500
|
+
return nestedUnrollBuffer(buffer, "", i);
|
|
501
|
+
});
|
|
502
|
+
ret = result;
|
|
503
|
+
}
|
|
504
|
+
return ret;
|
|
673
505
|
}
|
|
674
506
|
function unrollBuffer$1(buffer) {
|
|
675
|
-
|
|
507
|
+
return nestedUnrollBuffer(buffer, "", 0);
|
|
676
508
|
}
|
|
677
509
|
function unrollBufferSync$1(buffer) {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return ret;
|
|
510
|
+
let ret = "";
|
|
511
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
512
|
+
let item = buffer[i];
|
|
513
|
+
if ((0, _vue_shared.isString)(item)) ret += item;
|
|
514
|
+
else ret += unrollBufferSync$1(item);
|
|
515
|
+
}
|
|
516
|
+
return ret;
|
|
688
517
|
}
|
|
689
518
|
async function renderToString(input, context = {}) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
unwatch();
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
return result;
|
|
519
|
+
if (isVNode$1(input)) return renderToString((0, vue.createApp)({ render: () => input }), context);
|
|
520
|
+
const vnode = (0, vue.createVNode)(input._component, input._props);
|
|
521
|
+
vnode.appContext = input._context;
|
|
522
|
+
input.provide(vue.ssrContextKey, context);
|
|
523
|
+
try {
|
|
524
|
+
const result = await unrollBuffer$1(await renderComponentVNode(vnode));
|
|
525
|
+
await resolveTeleports(context);
|
|
526
|
+
return result;
|
|
527
|
+
} finally {
|
|
528
|
+
cleanupContext(context);
|
|
529
|
+
}
|
|
705
530
|
}
|
|
706
531
|
async function resolveTeleports(context) {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
const { isVNode } = Vue.ssrUtils;
|
|
532
|
+
if (context.__teleportBuffers) {
|
|
533
|
+
context.teleports = context.teleports || {};
|
|
534
|
+
for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(await Promise.all([context.__teleportBuffers[key]]));
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region packages/server-renderer/src/renderToStream.ts
|
|
539
|
+
const { isVNode } = vue.ssrUtils;
|
|
718
540
|
async function unrollBuffer(buffer, stream) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
stream.push(item);
|
|
727
|
-
} else {
|
|
728
|
-
await unrollBuffer(item, stream);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
} else {
|
|
732
|
-
unrollBufferSync(buffer, stream);
|
|
733
|
-
}
|
|
541
|
+
if (buffer.hasAsync) for (let i = 0; i < buffer.length; i++) {
|
|
542
|
+
let item = buffer[i];
|
|
543
|
+
if ((0, _vue_shared.isPromise)(item)) item = await item;
|
|
544
|
+
if ((0, _vue_shared.isString)(item)) stream.push(item);
|
|
545
|
+
else await unrollBuffer(item, stream);
|
|
546
|
+
}
|
|
547
|
+
else unrollBufferSync(buffer, stream);
|
|
734
548
|
}
|
|
735
549
|
function unrollBufferSync(buffer, stream) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
unrollBufferSync(item, stream);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
550
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
551
|
+
const item = buffer[i];
|
|
552
|
+
if ((0, _vue_shared.isString)(item)) stream.push(item);
|
|
553
|
+
else unrollBufferSync(item, stream);
|
|
554
|
+
}
|
|
744
555
|
}
|
|
745
556
|
function renderToSimpleStream(input, context, stream) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
557
|
+
if (isVNode(input)) return renderToSimpleStream((0, vue.createApp)({ render: () => input }), context, stream);
|
|
558
|
+
const vnode = (0, vue.createVNode)(input._component, input._props);
|
|
559
|
+
vnode.appContext = input._context;
|
|
560
|
+
input.provide(vue.ssrContextKey, context);
|
|
561
|
+
let cleaned = false;
|
|
562
|
+
const finalize = () => {
|
|
563
|
+
if (cleaned) return;
|
|
564
|
+
cleaned = true;
|
|
565
|
+
cleanupContext(context);
|
|
566
|
+
};
|
|
567
|
+
Promise.resolve().then(() => renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
|
568
|
+
finalize();
|
|
569
|
+
return stream.push(null);
|
|
570
|
+
}).catch((error) => {
|
|
571
|
+
try {
|
|
572
|
+
finalize();
|
|
573
|
+
} catch {}
|
|
574
|
+
stream.destroy(error);
|
|
575
|
+
});
|
|
576
|
+
return stream;
|
|
766
577
|
}
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated
|
|
580
|
+
*/
|
|
767
581
|
function renderToStream(input, context = {}) {
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
);
|
|
771
|
-
return renderToNodeStream(input, context);
|
|
582
|
+
console.warn(`[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`);
|
|
583
|
+
return renderToNodeStream(input, context);
|
|
772
584
|
}
|
|
773
585
|
function renderToNodeStream(input, context = {}) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
throw new Error(
|
|
778
|
-
`ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
|
|
779
|
-
);
|
|
780
|
-
}
|
|
781
|
-
return renderToSimpleStream(input, context, stream);
|
|
586
|
+
const stream = new (require("node:stream")).Readable({ read() {} });
|
|
587
|
+
if (!stream) throw new Error("ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.");
|
|
588
|
+
return renderToSimpleStream(input, context, stream);
|
|
782
589
|
}
|
|
783
590
|
function pipeToNodeWritable(input, context = {}, writable) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
writable.destroy(err);
|
|
794
|
-
}
|
|
795
|
-
});
|
|
591
|
+
renderToSimpleStream(input, context, {
|
|
592
|
+
push(content) {
|
|
593
|
+
if (content != null) writable.write(content);
|
|
594
|
+
else writable.end();
|
|
595
|
+
},
|
|
596
|
+
destroy(err) {
|
|
597
|
+
writable.destroy(err);
|
|
598
|
+
}
|
|
599
|
+
});
|
|
796
600
|
}
|
|
797
601
|
function renderToWebStream(input, context = {}) {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
});
|
|
820
|
-
},
|
|
821
|
-
cancel() {
|
|
822
|
-
cancelled = true;
|
|
823
|
-
}
|
|
824
|
-
});
|
|
602
|
+
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.");
|
|
603
|
+
const encoder = new TextEncoder();
|
|
604
|
+
let cancelled = false;
|
|
605
|
+
return new ReadableStream({
|
|
606
|
+
start(controller) {
|
|
607
|
+
renderToSimpleStream(input, context, {
|
|
608
|
+
push(content) {
|
|
609
|
+
if (cancelled) return;
|
|
610
|
+
if (content != null) controller.enqueue(encoder.encode(content));
|
|
611
|
+
else controller.close();
|
|
612
|
+
},
|
|
613
|
+
destroy(err) {
|
|
614
|
+
controller.error(err);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
},
|
|
618
|
+
cancel() {
|
|
619
|
+
cancelled = true;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
825
622
|
}
|
|
826
623
|
function pipeToWebWritable(input, context = {}, writable) {
|
|
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
|
-
Vue.initDirectivesForSSR();
|
|
853
|
-
|
|
854
|
-
exports.ssrIncludeBooleanAttr = shared.includeBooleanAttr;
|
|
624
|
+
const writer = writable.getWriter();
|
|
625
|
+
const encoder = new TextEncoder();
|
|
626
|
+
let hasReady = false;
|
|
627
|
+
try {
|
|
628
|
+
hasReady = (0, _vue_shared.isPromise)(writer.ready);
|
|
629
|
+
} catch (e) {}
|
|
630
|
+
renderToSimpleStream(input, context, {
|
|
631
|
+
async push(content) {
|
|
632
|
+
if (hasReady) await writer.ready;
|
|
633
|
+
if (content != null) return writer.write(encoder.encode(content));
|
|
634
|
+
else return writer.close();
|
|
635
|
+
},
|
|
636
|
+
destroy(err) {
|
|
637
|
+
console.log(err);
|
|
638
|
+
writer.close();
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region packages/server-renderer/src/index.ts
|
|
644
|
+
(0, vue.initDirectivesForSSR)();
|
|
645
|
+
//#endregion
|
|
855
646
|
exports.pipeToNodeWritable = pipeToNodeWritable;
|
|
856
647
|
exports.pipeToWebWritable = pipeToWebWritable;
|
|
857
648
|
exports.renderToNodeStream = renderToNodeStream;
|
|
@@ -861,6 +652,7 @@ exports.renderToString = renderToString;
|
|
|
861
652
|
exports.renderToWebStream = renderToWebStream;
|
|
862
653
|
exports.ssrGetDirectiveProps = ssrGetDirectiveProps;
|
|
863
654
|
exports.ssrGetDynamicModelProps = ssrGetDynamicModelProps;
|
|
655
|
+
exports.ssrIncludeBooleanAttr = _vue_shared.includeBooleanAttr;
|
|
864
656
|
exports.ssrInterpolate = ssrInterpolate;
|
|
865
657
|
exports.ssrLooseContain = ssrLooseContain;
|
|
866
658
|
exports.ssrLooseEqual = ssrLooseEqual;
|