@vue/server-renderer 3.6.0-rc.1 → 3.6.0-rc.11
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 +132 -40
- package/dist/server-renderer.cjs.prod.js +132 -40
- package/dist/server-renderer.d.ts +6 -9
- package/dist/server-renderer.esm-browser.js +874 -451
- package/dist/server-renderer.esm-browser.prod.js +2 -2
- package/dist/server-renderer.esm-bundler.js +132 -40
- package/package.json +4 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.6.0-rc.
|
|
2
|
+
* @vue/server-renderer v3.6.0-rc.11
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
import { Comment, Fragment, Static, Text, createApp, createVNode, handleError, initDirectivesForSSR, mergeProps, ssrContextKey, ssrUtils, warn } from "@vue/runtime-dom";
|
|
6
|
+
import { Comment, Fragment, Static, Text, createApp, createVNode, getCurrentInstance, handleError, initDirectivesForSSR, mergeProps, renderSlot, ssrContextKey, ssrUtils, warn } from "@vue/runtime-dom";
|
|
7
7
|
import { NOOP, escapeHtml, escapeHtmlComment, hasOwn, includeBooleanAttr, includeBooleanAttr as ssrIncludeBooleanAttr, isArray, isBooleanAttr, isFunction, isObject, isOn, isPromise, isRenderableAttrValue, isSSRSafeAttrName, isSVGTag, isString, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeCssVarValue, normalizeStyle, propsToAttrMap, stringifyStyle, toDisplayString } from "@vue/shared";
|
|
8
8
|
//#region packages/server-renderer/src/helpers/ssrRenderAttrs.ts
|
|
9
|
-
const shouldIgnoreProp =
|
|
9
|
+
const shouldIgnoreProp = /*@__PURE__*/ makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
10
10
|
function ssrRenderAttrs(props, tag) {
|
|
11
11
|
let ret = "";
|
|
12
12
|
for (let key in props) {
|
|
@@ -24,7 +24,7 @@ function ssrRenderAttrs(props, tag) {
|
|
|
24
24
|
function ssrRenderDynamicAttr(key, value, tag) {
|
|
25
25
|
if (!isRenderableAttrValue(value)) return ``;
|
|
26
26
|
const attrKey = tag && (tag.indexOf("-") > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase();
|
|
27
|
-
if (isBooleanAttr(attrKey)) return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
|
|
27
|
+
if (isBooleanAttr(attrKey) || attrKey === "hidden" && (typeof value === "boolean" || typeof value === "number")) return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
|
|
28
28
|
else if (isSSRSafeAttrName(attrKey)) return value === "" ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`;
|
|
29
29
|
else {
|
|
30
30
|
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
|
|
@@ -41,7 +41,8 @@ function ssrRenderClass(raw) {
|
|
|
41
41
|
function ssrRenderStyle(raw) {
|
|
42
42
|
if (!raw) return "";
|
|
43
43
|
if (isString(raw)) return escapeHtml(raw);
|
|
44
|
-
|
|
44
|
+
const styles = normalizeStyle(ssrResetCssVars(raw));
|
|
45
|
+
return escapeHtml(stringifyStyle(styles));
|
|
45
46
|
}
|
|
46
47
|
function ssrResetCssVars(raw) {
|
|
47
48
|
if (!isArray(raw) && isObject(raw)) {
|
|
@@ -53,58 +54,76 @@ function ssrResetCssVars(raw) {
|
|
|
53
54
|
return raw;
|
|
54
55
|
}
|
|
55
56
|
//#endregion
|
|
56
|
-
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
57
|
-
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
58
|
-
if (isString(comp)) {
|
|
59
|
-
const { getBuffer, push } = createBuffer();
|
|
60
|
-
renderVNode(push, createVNode(comp, props, children), parentComponent, slotScopeId);
|
|
61
|
-
return getBuffer();
|
|
62
|
-
}
|
|
63
|
-
return renderComponentVNode(createVNode(comp, props, children), parentComponent, slotScopeId);
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
57
|
//#region packages/server-renderer/src/helpers/ssrRenderSlot.ts
|
|
67
|
-
const { ensureValidVNode } = ssrUtils;
|
|
58
|
+
const { ensureValidVNode, rawVaporSlotKey: rawVaporSlotKey$1 } = ssrUtils;
|
|
59
|
+
let vaporSlots = 0;
|
|
68
60
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
69
|
-
push(`<!--[-->`);
|
|
70
61
|
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
71
|
-
push(`<!--]-->`);
|
|
72
62
|
}
|
|
73
63
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
74
64
|
const slotFn = slots[slotName];
|
|
65
|
+
let fallback = false;
|
|
75
66
|
if (slotFn) {
|
|
67
|
+
if (slotFn[rawVaporSlotKey$1]) vaporSlots++;
|
|
68
|
+
const before = vaporSlots;
|
|
76
69
|
const slotBuffer = [];
|
|
77
70
|
const bufferedPush = (item) => {
|
|
78
71
|
slotBuffer.push(item);
|
|
79
72
|
};
|
|
80
|
-
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
73
|
+
const ret = slotFn(slotProps || {}, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
74
|
+
let vnodes;
|
|
81
75
|
if (isArray(ret)) {
|
|
82
|
-
|
|
83
|
-
if (
|
|
76
|
+
vnodes = ensureValidVNode(ret);
|
|
77
|
+
if (vnodes && isVaporSlotContent(vnodes)) {
|
|
78
|
+
renderVNodeChildren(bufferedPush, vnodes, parentComponent, slotScopeId);
|
|
79
|
+
vnodes = void 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (vnodes !== void 0) {
|
|
83
|
+
if (!transition) {
|
|
84
|
+
fallback = !vnodes && !!fallbackRenderFn;
|
|
85
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
86
|
+
}
|
|
87
|
+
if (vnodes) renderVNodeChildren(push, vnodes, parentComponent, slotScopeId);
|
|
84
88
|
else if (fallbackRenderFn) fallbackRenderFn();
|
|
85
89
|
else if (transition) push(`<!---->`);
|
|
86
90
|
} else {
|
|
87
91
|
let isEmptySlot = true;
|
|
88
|
-
|
|
92
|
+
const owner = getCurrentInstance();
|
|
93
|
+
if (transition || !(owner && owner.type.__vapor) && !fallbackRenderFn && vaporSlots !== before) isEmptySlot = false;
|
|
89
94
|
else for (let i = 0; i < slotBuffer.length; i++) if (!isComment(slotBuffer[i])) {
|
|
90
95
|
isEmptySlot = false;
|
|
91
96
|
break;
|
|
92
97
|
}
|
|
98
|
+
if (!transition) {
|
|
99
|
+
fallback = isEmptySlot && !!fallbackRenderFn;
|
|
100
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
101
|
+
}
|
|
93
102
|
if (isEmptySlot) {
|
|
94
103
|
if (fallbackRenderFn) fallbackRenderFn();
|
|
95
104
|
} else {
|
|
96
105
|
let start = 0;
|
|
97
106
|
let end = slotBuffer.length;
|
|
98
|
-
if (transition
|
|
99
|
-
|
|
100
|
-
end
|
|
107
|
+
if (transition) {
|
|
108
|
+
const first = slotBuffer[0];
|
|
109
|
+
if ((first === "<!--[-->" || first === "<!--(-->") && slotBuffer[end - 1] === (first === "<!--(-->" ? "<!--)-->" : "<!--]-->")) {
|
|
110
|
+
start++;
|
|
111
|
+
end--;
|
|
112
|
+
}
|
|
101
113
|
}
|
|
102
114
|
if (start < end) for (let i = start; i < end; i++) push(slotBuffer[i]);
|
|
103
115
|
else if (transition) push(`<!---->`);
|
|
104
116
|
}
|
|
105
117
|
}
|
|
106
|
-
} else
|
|
107
|
-
|
|
118
|
+
} else {
|
|
119
|
+
if (!transition) {
|
|
120
|
+
fallback = !!fallbackRenderFn;
|
|
121
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
122
|
+
}
|
|
123
|
+
if (fallbackRenderFn) fallbackRenderFn();
|
|
124
|
+
else if (transition) push(`<!---->`);
|
|
125
|
+
}
|
|
126
|
+
if (!transition) push(fallback ? `<!--)-->` : `<!--]-->`);
|
|
108
127
|
}
|
|
109
128
|
const commentTestRE = /^<!--[\s\S]*-->$/;
|
|
110
129
|
const commentRE = /<!--[^]*?-->/gm;
|
|
@@ -114,6 +133,16 @@ function isComment(item) {
|
|
|
114
133
|
return !item.replace(commentRE, "").trim();
|
|
115
134
|
}
|
|
116
135
|
//#endregion
|
|
136
|
+
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
137
|
+
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
138
|
+
if (isString(comp)) {
|
|
139
|
+
const { getBuffer, push } = createBuffer();
|
|
140
|
+
renderVNode(push, createVNode(comp, props, children), parentComponent, slotScopeId);
|
|
141
|
+
return getBuffer();
|
|
142
|
+
}
|
|
143
|
+
return renderComponentVNode(createVNode(comp, props, children), parentComponent, slotScopeId);
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
117
146
|
//#region packages/server-renderer/src/helpers/ssrRenderTeleport.ts
|
|
118
147
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
119
148
|
parentPush("<!--teleport start-->");
|
|
@@ -151,14 +180,16 @@ function ssrRenderList(source, renderItem) {
|
|
|
151
180
|
return;
|
|
152
181
|
}
|
|
153
182
|
for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
154
|
-
} else if (isObject(source))
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
183
|
+
} else if (isObject(source)) {
|
|
184
|
+
if (source[Symbol.iterator]) {
|
|
185
|
+
let i = 0;
|
|
186
|
+
for (const item of source) renderItem(item, i++);
|
|
187
|
+
} else {
|
|
188
|
+
const keys = Object.keys(source);
|
|
189
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
190
|
+
const key = keys[i];
|
|
191
|
+
renderItem(source[key], key, i);
|
|
192
|
+
}
|
|
162
193
|
}
|
|
163
194
|
}
|
|
164
195
|
}
|
|
@@ -209,7 +240,7 @@ function ssrCompile(template, instance) {
|
|
|
209
240
|
}
|
|
210
241
|
//#endregion
|
|
211
242
|
//#region packages/server-renderer/src/render.ts
|
|
212
|
-
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = ssrUtils;
|
|
243
|
+
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, isVNode: isVNode$2, normalizeVNode, pushWarningContext, popWarningContext, VaporSlot, rawVaporSlotKey, invokeSlotFallback } = ssrUtils;
|
|
213
244
|
function cleanupContext(context) {
|
|
214
245
|
let firstError;
|
|
215
246
|
if (context.__watcherHandles) {
|
|
@@ -249,7 +280,49 @@ function createBuffer() {
|
|
|
249
280
|
}
|
|
250
281
|
};
|
|
251
282
|
}
|
|
283
|
+
const vaporOutlets = /* @__PURE__ */ new WeakMap();
|
|
284
|
+
const vaporInterface = { attachSlotOutlet(content, fallback, owner) {
|
|
285
|
+
const lone = isVaporSlotContent(content);
|
|
286
|
+
if (lone) vaporOutlets.set(content, {
|
|
287
|
+
fallback,
|
|
288
|
+
owner
|
|
289
|
+
});
|
|
290
|
+
return lone;
|
|
291
|
+
} };
|
|
292
|
+
function isVaporSlotContent(children) {
|
|
293
|
+
const lone = findVaporSlot(children);
|
|
294
|
+
vaporSlot = null;
|
|
295
|
+
return lone;
|
|
296
|
+
}
|
|
297
|
+
let vaporSlot = null;
|
|
298
|
+
function findVaporSlot(children) {
|
|
299
|
+
for (let i = 0; i < children.length; i++) {
|
|
300
|
+
const child = children[i];
|
|
301
|
+
if (!isVNode$2(child)) return false;
|
|
302
|
+
if (child.type === VaporSlot) {
|
|
303
|
+
if (vaporSlot) return false;
|
|
304
|
+
vaporSlot = child;
|
|
305
|
+
} else if (child.type === Fragment) {
|
|
306
|
+
if (child.patchFlag > 0 && child.patchFlag & 384 || !findVaporSlot(child.children)) return false;
|
|
307
|
+
} else if (child.type !== Comment) return false;
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
252
311
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
312
|
+
const ctx = vnode.ctx;
|
|
313
|
+
const slots = vnode.children;
|
|
314
|
+
if (vnode.shapeFlag & 32 && ctx && ctx.type.__vapor && slots._) {
|
|
315
|
+
for (const name in slots) {
|
|
316
|
+
const slot = slots[name];
|
|
317
|
+
if (isFunction(slot) && !slot[rawVaporSlotKey]) {
|
|
318
|
+
const wrapped = (props, push, parent, scopeId) => push ? slot(props, push, parent, scopeId) : [renderSlot({ [name]: slot }, name, props)];
|
|
319
|
+
slot[rawVaporSlotKey] = wrapped[rawVaporSlotKey] = slot;
|
|
320
|
+
wrapped._n = true;
|
|
321
|
+
slots[name] = wrapped;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (!ctx.appContext.vapor) ctx.appContext.vapor = vaporInterface;
|
|
325
|
+
}
|
|
253
326
|
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
254
327
|
const context = instance.appContext.provides[ssrContextKey];
|
|
255
328
|
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
@@ -313,7 +386,8 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
313
386
|
}
|
|
314
387
|
} else if (instance.render && instance.render !== NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
|
|
315
388
|
else {
|
|
316
|
-
|
|
389
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
390
|
+
warn(`Component ${componentName} is missing template or render function.`);
|
|
317
391
|
push(`<!---->`);
|
|
318
392
|
}
|
|
319
393
|
}
|
|
@@ -333,12 +407,25 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
333
407
|
case Static:
|
|
334
408
|
push(children);
|
|
335
409
|
break;
|
|
336
|
-
case Fragment:
|
|
410
|
+
case Fragment: {
|
|
337
411
|
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
338
|
-
|
|
412
|
+
const outlet = vnode.vo && vaporOutlets.get(children);
|
|
413
|
+
if (outlet) {
|
|
414
|
+
renderVaporOutlet(push, (_, push) => renderVNodeChildren(push, children, parentComponent, slotScopeId), null, outlet, parentComponent, slotScopeId);
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
const isFallback = shapeFlag & 1024;
|
|
418
|
+
push(isFallback ? `<!--(-->` : `<!--[-->`);
|
|
339
419
|
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
340
|
-
push(`<!--]-->`);
|
|
420
|
+
push(isFallback ? `<!--)-->` : `<!--]-->`);
|
|
341
421
|
break;
|
|
422
|
+
}
|
|
423
|
+
case VaporSlot: {
|
|
424
|
+
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
425
|
+
const { slot, outlets } = vnode.vs;
|
|
426
|
+
renderVaporOutlet(push, slot, vnode.props, outlets && outlets[0], parentComponent, slotScopeId);
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
342
429
|
default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
343
430
|
else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
344
431
|
else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
@@ -346,6 +433,11 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
346
433
|
else warn("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
|
|
347
434
|
}
|
|
348
435
|
}
|
|
436
|
+
function renderVaporOutlet(push, slot, props, outlet, parentComponent, slotScopeId) {
|
|
437
|
+
const prev = setCurrentRenderingInstance(parentComponent);
|
|
438
|
+
ssrRenderSlot({ default: slot }, "default", props, outlet ? () => renderVNodeChildren(push, invokeSlotFallback(outlet.fallback, outlet.owner), parentComponent, slotScopeId) : null, push, parentComponent, slotScopeId);
|
|
439
|
+
setCurrentRenderingInstance(prev);
|
|
440
|
+
}
|
|
349
441
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
350
442
|
for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
351
443
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/server-renderer",
|
|
3
|
-
"version": "3.6.0-rc.
|
|
3
|
+
"version": "3.6.0-rc.11",
|
|
4
4
|
"description": "@vue/server-renderer",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/server-renderer.esm-bundler.js",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/server-renderer#readme",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@vue/shared": "3.6.0-rc.
|
|
50
|
-
"@vue/compiler-ssr": "3.6.0-rc.
|
|
51
|
-
"@vue/runtime-dom": "3.6.0-rc.
|
|
49
|
+
"@vue/shared": "3.6.0-rc.11",
|
|
50
|
+
"@vue/compiler-ssr": "3.6.0-rc.11",
|
|
51
|
+
"@vue/runtime-dom": "3.6.0-rc.11"
|
|
52
52
|
}
|
|
53
53
|
}
|