@vue/server-renderer 3.6.0-rc.1 → 3.6.0-rc.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/dist/server-renderer.cjs.js +124 -40
- package/dist/server-renderer.cjs.prod.js +124 -40
- package/dist/server-renderer.d.ts +6 -9
- package/dist/server-renderer.esm-browser.js +777 -451
- package/dist/server-renderer.esm-browser.prod.js +2 -2
- package/dist/server-renderer.esm-bundler.js +124 -40
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.6.0-rc.
|
|
2
|
+
* @vue/server-renderer v3.6.0-rc.10
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -33,7 +33,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
33
|
}
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
37
37
|
value: mod,
|
|
38
38
|
enumerable: true
|
|
39
39
|
}) : target, mod));
|
|
@@ -43,7 +43,7 @@ _vue_runtime_dom = __toESM(_vue_runtime_dom);
|
|
|
43
43
|
let _vue_shared = require("@vue/shared");
|
|
44
44
|
let _vue_compiler_ssr = require("@vue/compiler-ssr");
|
|
45
45
|
//#region packages/server-renderer/src/helpers/ssrRenderAttrs.ts
|
|
46
|
-
const shouldIgnoreProp =
|
|
46
|
+
const shouldIgnoreProp = /*@__PURE__*/ (0, _vue_shared.makeMap)(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
47
47
|
function ssrRenderAttrs(props, tag) {
|
|
48
48
|
let ret = "";
|
|
49
49
|
for (let key in props) {
|
|
@@ -61,7 +61,7 @@ function ssrRenderAttrs(props, tag) {
|
|
|
61
61
|
function ssrRenderDynamicAttr(key, value, tag) {
|
|
62
62
|
if (!(0, _vue_shared.isRenderableAttrValue)(value)) return ``;
|
|
63
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}` : ``;
|
|
64
|
+
if ((0, _vue_shared.isBooleanAttr)(attrKey) || attrKey === "hidden" && (typeof value === "boolean" || typeof value === "number")) return (0, _vue_shared.includeBooleanAttr)(value) ? ` ${attrKey}` : ``;
|
|
65
65
|
else if ((0, _vue_shared.isSSRSafeAttrName)(attrKey)) return value === "" ? ` ${attrKey}` : ` ${attrKey}="${(0, _vue_shared.escapeHtml)(value)}"`;
|
|
66
66
|
else {
|
|
67
67
|
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
|
|
@@ -78,7 +78,8 @@ function ssrRenderClass(raw) {
|
|
|
78
78
|
function ssrRenderStyle(raw) {
|
|
79
79
|
if (!raw) return "";
|
|
80
80
|
if ((0, _vue_shared.isString)(raw)) return (0, _vue_shared.escapeHtml)(raw);
|
|
81
|
-
|
|
81
|
+
const styles = (0, _vue_shared.normalizeStyle)(ssrResetCssVars(raw));
|
|
82
|
+
return (0, _vue_shared.escapeHtml)((0, _vue_shared.stringifyStyle)(styles));
|
|
82
83
|
}
|
|
83
84
|
function ssrResetCssVars(raw) {
|
|
84
85
|
if (!(0, _vue_shared.isArray)(raw) && (0, _vue_shared.isObject)(raw)) {
|
|
@@ -90,58 +91,76 @@ function ssrResetCssVars(raw) {
|
|
|
90
91
|
return raw;
|
|
91
92
|
}
|
|
92
93
|
//#endregion
|
|
93
|
-
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
94
|
-
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
95
|
-
if ((0, _vue_shared.isString)(comp)) {
|
|
96
|
-
const { getBuffer, push } = createBuffer();
|
|
97
|
-
renderVNode(push, (0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
98
|
-
return getBuffer();
|
|
99
|
-
}
|
|
100
|
-
return renderComponentVNode((0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
94
|
//#region packages/server-renderer/src/helpers/ssrRenderSlot.ts
|
|
104
|
-
const { ensureValidVNode } = _vue_runtime_dom.ssrUtils;
|
|
95
|
+
const { ensureValidVNode, rawVaporSlotKey: rawVaporSlotKey$1 } = _vue_runtime_dom.ssrUtils;
|
|
96
|
+
let vaporSlots = 0;
|
|
105
97
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
106
|
-
push(`<!--[-->`);
|
|
107
98
|
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
108
|
-
push(`<!--]-->`);
|
|
109
99
|
}
|
|
110
100
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
111
101
|
const slotFn = slots[slotName];
|
|
102
|
+
let fallback = false;
|
|
112
103
|
if (slotFn) {
|
|
104
|
+
if (slotFn[rawVaporSlotKey$1]) vaporSlots++;
|
|
105
|
+
const before = vaporSlots;
|
|
113
106
|
const slotBuffer = [];
|
|
114
107
|
const bufferedPush = (item) => {
|
|
115
108
|
slotBuffer.push(item);
|
|
116
109
|
};
|
|
117
|
-
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
110
|
+
const ret = slotFn(slotProps || {}, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
111
|
+
let vnodes;
|
|
118
112
|
if ((0, _vue_shared.isArray)(ret)) {
|
|
119
|
-
|
|
120
|
-
if (
|
|
113
|
+
vnodes = ensureValidVNode(ret);
|
|
114
|
+
if (vnodes && isVaporSlotContent(vnodes)) {
|
|
115
|
+
renderVNodeChildren(bufferedPush, vnodes, parentComponent, slotScopeId);
|
|
116
|
+
vnodes = void 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (vnodes !== void 0) {
|
|
120
|
+
if (!transition) {
|
|
121
|
+
fallback = !vnodes && !!fallbackRenderFn;
|
|
122
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
123
|
+
}
|
|
124
|
+
if (vnodes) renderVNodeChildren(push, vnodes, parentComponent, slotScopeId);
|
|
121
125
|
else if (fallbackRenderFn) fallbackRenderFn();
|
|
122
126
|
else if (transition) push(`<!---->`);
|
|
123
127
|
} else {
|
|
124
128
|
let isEmptySlot = true;
|
|
125
|
-
|
|
129
|
+
const owner = (0, _vue_runtime_dom.getCurrentInstance)();
|
|
130
|
+
if (transition || !(owner && owner.type.__vapor) && !fallbackRenderFn && vaporSlots !== before) isEmptySlot = false;
|
|
126
131
|
else for (let i = 0; i < slotBuffer.length; i++) if (!isComment(slotBuffer[i])) {
|
|
127
132
|
isEmptySlot = false;
|
|
128
133
|
break;
|
|
129
134
|
}
|
|
135
|
+
if (!transition) {
|
|
136
|
+
fallback = isEmptySlot && !!fallbackRenderFn;
|
|
137
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
138
|
+
}
|
|
130
139
|
if (isEmptySlot) {
|
|
131
140
|
if (fallbackRenderFn) fallbackRenderFn();
|
|
132
141
|
} else {
|
|
133
142
|
let start = 0;
|
|
134
143
|
let end = slotBuffer.length;
|
|
135
|
-
if (transition
|
|
136
|
-
|
|
137
|
-
end
|
|
144
|
+
if (transition) {
|
|
145
|
+
const first = slotBuffer[0];
|
|
146
|
+
if ((first === "<!--[-->" || first === "<!--(-->") && slotBuffer[end - 1] === (first === "<!--(-->" ? "<!--)-->" : "<!--]-->")) {
|
|
147
|
+
start++;
|
|
148
|
+
end--;
|
|
149
|
+
}
|
|
138
150
|
}
|
|
139
151
|
if (start < end) for (let i = start; i < end; i++) push(slotBuffer[i]);
|
|
140
152
|
else if (transition) push(`<!---->`);
|
|
141
153
|
}
|
|
142
154
|
}
|
|
143
|
-
} else
|
|
144
|
-
|
|
155
|
+
} else {
|
|
156
|
+
if (!transition) {
|
|
157
|
+
fallback = !!fallbackRenderFn;
|
|
158
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
159
|
+
}
|
|
160
|
+
if (fallbackRenderFn) fallbackRenderFn();
|
|
161
|
+
else if (transition) push(`<!---->`);
|
|
162
|
+
}
|
|
163
|
+
if (!transition) push(fallback ? `<!--)-->` : `<!--]-->`);
|
|
145
164
|
}
|
|
146
165
|
const commentTestRE = /^<!--[\s\S]*-->$/;
|
|
147
166
|
const commentRE = /<!--[^]*?-->/gm;
|
|
@@ -151,6 +170,16 @@ function isComment(item) {
|
|
|
151
170
|
return !item.replace(commentRE, "").trim();
|
|
152
171
|
}
|
|
153
172
|
//#endregion
|
|
173
|
+
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
174
|
+
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
175
|
+
if ((0, _vue_shared.isString)(comp)) {
|
|
176
|
+
const { getBuffer, push } = createBuffer();
|
|
177
|
+
renderVNode(push, (0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
178
|
+
return getBuffer();
|
|
179
|
+
}
|
|
180
|
+
return renderComponentVNode((0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
154
183
|
//#region packages/server-renderer/src/helpers/ssrRenderTeleport.ts
|
|
155
184
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
156
185
|
parentPush("<!--teleport start-->");
|
|
@@ -188,14 +217,16 @@ function ssrRenderList(source, renderItem) {
|
|
|
188
217
|
return;
|
|
189
218
|
}
|
|
190
219
|
for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
191
|
-
} else if ((0, _vue_shared.isObject)(source))
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
220
|
+
} else if ((0, _vue_shared.isObject)(source)) {
|
|
221
|
+
if (source[Symbol.iterator]) {
|
|
222
|
+
let i = 0;
|
|
223
|
+
for (const item of source) renderItem(item, i++);
|
|
224
|
+
} else {
|
|
225
|
+
const keys = Object.keys(source);
|
|
226
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
227
|
+
const key = keys[i];
|
|
228
|
+
renderItem(source[key], key, i);
|
|
229
|
+
}
|
|
199
230
|
}
|
|
200
231
|
}
|
|
201
232
|
}
|
|
@@ -300,7 +331,7 @@ function ssrCompile(template, instance) {
|
|
|
300
331
|
}
|
|
301
332
|
//#endregion
|
|
302
333
|
//#region packages/server-renderer/src/render.ts
|
|
303
|
-
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = _vue_runtime_dom.ssrUtils;
|
|
334
|
+
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, isVNode: isVNode$2, normalizeVNode, pushWarningContext, popWarningContext, VaporSlot, rawVaporSlotKey, invokeSlotFallback } = _vue_runtime_dom.ssrUtils;
|
|
304
335
|
function cleanupContext(context) {
|
|
305
336
|
let firstError;
|
|
306
337
|
if (context.__watcherHandles) {
|
|
@@ -340,7 +371,41 @@ function createBuffer() {
|
|
|
340
371
|
}
|
|
341
372
|
};
|
|
342
373
|
}
|
|
374
|
+
const vaporOutlets = /* @__PURE__ */ new WeakMap();
|
|
375
|
+
const vaporInterface = { attachSlotOutlet(content, fallback, owner) {
|
|
376
|
+
const lone = isVaporSlotContent(content);
|
|
377
|
+
if (lone) vaporOutlets.set(content, {
|
|
378
|
+
fallback,
|
|
379
|
+
owner
|
|
380
|
+
});
|
|
381
|
+
return lone;
|
|
382
|
+
} };
|
|
383
|
+
function isVaporSlotContent(children) {
|
|
384
|
+
const lone = findVaporSlot(children);
|
|
385
|
+
vaporSlot = null;
|
|
386
|
+
return lone;
|
|
387
|
+
}
|
|
388
|
+
let vaporSlot = null;
|
|
389
|
+
function findVaporSlot(children) {
|
|
390
|
+
for (let i = 0; i < children.length; i++) {
|
|
391
|
+
const child = children[i];
|
|
392
|
+
if (!isVNode$2(child)) return false;
|
|
393
|
+
if (child.type === VaporSlot) {
|
|
394
|
+
if (vaporSlot) return false;
|
|
395
|
+
vaporSlot = child;
|
|
396
|
+
} else if (child.type === _vue_runtime_dom.Fragment) {
|
|
397
|
+
if (child.patchFlag > 0 && child.patchFlag & 384 || !findVaporSlot(child.children)) return false;
|
|
398
|
+
} else if (child.type !== _vue_runtime_dom.Comment) return false;
|
|
399
|
+
}
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
343
402
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
403
|
+
const ctx = vnode.ctx;
|
|
404
|
+
if (vnode.shapeFlag & 32 && ctx && ctx.type.__vapor) {
|
|
405
|
+
const slots = vnode.children;
|
|
406
|
+
for (const name in slots) if ((0, _vue_shared.isFunction)(slots[name])) slots[name][rawVaporSlotKey] = slots[name];
|
|
407
|
+
if (!ctx.appContext.vapor) ctx.appContext.vapor = vaporInterface;
|
|
408
|
+
}
|
|
344
409
|
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
345
410
|
const context = instance.appContext.provides[_vue_runtime_dom.ssrContextKey];
|
|
346
411
|
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
@@ -404,7 +469,8 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
404
469
|
}
|
|
405
470
|
} else if (instance.render && instance.render !== _vue_shared.NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
|
|
406
471
|
else {
|
|
407
|
-
|
|
472
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
473
|
+
(0, _vue_runtime_dom.warn)(`Component ${componentName} is missing template or render function.`);
|
|
408
474
|
push(`<!---->`);
|
|
409
475
|
}
|
|
410
476
|
}
|
|
@@ -424,12 +490,25 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
424
490
|
case _vue_runtime_dom.Static:
|
|
425
491
|
push(children);
|
|
426
492
|
break;
|
|
427
|
-
case _vue_runtime_dom.Fragment:
|
|
493
|
+
case _vue_runtime_dom.Fragment: {
|
|
428
494
|
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
429
|
-
|
|
495
|
+
const outlet = vnode.vo && vaporOutlets.get(children);
|
|
496
|
+
if (outlet) {
|
|
497
|
+
renderVaporOutlet(push, (_, push) => renderVNodeChildren(push, children, parentComponent, slotScopeId), null, outlet, parentComponent, slotScopeId);
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
const isFallback = shapeFlag & 1024;
|
|
501
|
+
push(isFallback ? `<!--(-->` : `<!--[-->`);
|
|
430
502
|
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
431
|
-
push(`<!--]-->`);
|
|
503
|
+
push(isFallback ? `<!--)-->` : `<!--]-->`);
|
|
432
504
|
break;
|
|
505
|
+
}
|
|
506
|
+
case VaporSlot: {
|
|
507
|
+
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
508
|
+
const { slot, outlets } = vnode.vs;
|
|
509
|
+
renderVaporOutlet(push, slot, vnode.props, outlets && outlets[0], parentComponent, slotScopeId);
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
433
512
|
default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
434
513
|
else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
435
514
|
else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
@@ -437,6 +516,11 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
437
516
|
else (0, _vue_runtime_dom.warn)("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
|
|
438
517
|
}
|
|
439
518
|
}
|
|
519
|
+
function renderVaporOutlet(push, slot, props, outlet, parentComponent, slotScopeId) {
|
|
520
|
+
const prev = setCurrentRenderingInstance(parentComponent);
|
|
521
|
+
ssrRenderSlot({ default: slot }, "default", props, outlet ? () => renderVNodeChildren(push, invokeSlotFallback(outlet.fallback, outlet.owner), parentComponent, slotScopeId) : null, push, parentComponent, slotScopeId);
|
|
522
|
+
setCurrentRenderingInstance(prev);
|
|
523
|
+
}
|
|
440
524
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
441
525
|
for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
442
526
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.6.0-rc.
|
|
2
|
+
* @vue/server-renderer v3.6.0-rc.10
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -33,7 +33,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
33
|
}
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
37
37
|
value: mod,
|
|
38
38
|
enumerable: true
|
|
39
39
|
}) : target, mod));
|
|
@@ -43,7 +43,7 @@ _vue_runtime_dom = __toESM(_vue_runtime_dom);
|
|
|
43
43
|
let _vue_shared = require("@vue/shared");
|
|
44
44
|
let _vue_compiler_ssr = require("@vue/compiler-ssr");
|
|
45
45
|
//#region packages/server-renderer/src/helpers/ssrRenderAttrs.ts
|
|
46
|
-
const shouldIgnoreProp =
|
|
46
|
+
const shouldIgnoreProp = /*@__PURE__*/ (0, _vue_shared.makeMap)(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
47
47
|
function ssrRenderAttrs(props, tag) {
|
|
48
48
|
let ret = "";
|
|
49
49
|
for (let key in props) {
|
|
@@ -61,7 +61,7 @@ function ssrRenderAttrs(props, tag) {
|
|
|
61
61
|
function ssrRenderDynamicAttr(key, value, tag) {
|
|
62
62
|
if (!(0, _vue_shared.isRenderableAttrValue)(value)) return ``;
|
|
63
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}` : ``;
|
|
64
|
+
if ((0, _vue_shared.isBooleanAttr)(attrKey) || attrKey === "hidden" && (typeof value === "boolean" || typeof value === "number")) return (0, _vue_shared.includeBooleanAttr)(value) ? ` ${attrKey}` : ``;
|
|
65
65
|
else if ((0, _vue_shared.isSSRSafeAttrName)(attrKey)) return value === "" ? ` ${attrKey}` : ` ${attrKey}="${(0, _vue_shared.escapeHtml)(value)}"`;
|
|
66
66
|
else {
|
|
67
67
|
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
|
|
@@ -78,7 +78,8 @@ function ssrRenderClass(raw) {
|
|
|
78
78
|
function ssrRenderStyle(raw) {
|
|
79
79
|
if (!raw) return "";
|
|
80
80
|
if ((0, _vue_shared.isString)(raw)) return (0, _vue_shared.escapeHtml)(raw);
|
|
81
|
-
|
|
81
|
+
const styles = (0, _vue_shared.normalizeStyle)(ssrResetCssVars(raw));
|
|
82
|
+
return (0, _vue_shared.escapeHtml)((0, _vue_shared.stringifyStyle)(styles));
|
|
82
83
|
}
|
|
83
84
|
function ssrResetCssVars(raw) {
|
|
84
85
|
if (!(0, _vue_shared.isArray)(raw) && (0, _vue_shared.isObject)(raw)) {
|
|
@@ -90,58 +91,76 @@ function ssrResetCssVars(raw) {
|
|
|
90
91
|
return raw;
|
|
91
92
|
}
|
|
92
93
|
//#endregion
|
|
93
|
-
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
94
|
-
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
95
|
-
if ((0, _vue_shared.isString)(comp)) {
|
|
96
|
-
const { getBuffer, push } = createBuffer();
|
|
97
|
-
renderVNode(push, (0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
98
|
-
return getBuffer();
|
|
99
|
-
}
|
|
100
|
-
return renderComponentVNode((0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
101
|
-
}
|
|
102
|
-
//#endregion
|
|
103
94
|
//#region packages/server-renderer/src/helpers/ssrRenderSlot.ts
|
|
104
|
-
const { ensureValidVNode } = _vue_runtime_dom.ssrUtils;
|
|
95
|
+
const { ensureValidVNode, rawVaporSlotKey: rawVaporSlotKey$1 } = _vue_runtime_dom.ssrUtils;
|
|
96
|
+
let vaporSlots = 0;
|
|
105
97
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
106
|
-
push(`<!--[-->`);
|
|
107
98
|
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
108
|
-
push(`<!--]-->`);
|
|
109
99
|
}
|
|
110
100
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
111
101
|
const slotFn = slots[slotName];
|
|
102
|
+
let fallback = false;
|
|
112
103
|
if (slotFn) {
|
|
104
|
+
if (slotFn[rawVaporSlotKey$1]) vaporSlots++;
|
|
105
|
+
const before = vaporSlots;
|
|
113
106
|
const slotBuffer = [];
|
|
114
107
|
const bufferedPush = (item) => {
|
|
115
108
|
slotBuffer.push(item);
|
|
116
109
|
};
|
|
117
|
-
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
110
|
+
const ret = slotFn(slotProps || {}, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
111
|
+
let vnodes;
|
|
118
112
|
if ((0, _vue_shared.isArray)(ret)) {
|
|
119
|
-
|
|
120
|
-
if (
|
|
113
|
+
vnodes = ensureValidVNode(ret);
|
|
114
|
+
if (vnodes && isVaporSlotContent(vnodes)) {
|
|
115
|
+
renderVNodeChildren(bufferedPush, vnodes, parentComponent, slotScopeId);
|
|
116
|
+
vnodes = void 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (vnodes !== void 0) {
|
|
120
|
+
if (!transition) {
|
|
121
|
+
fallback = !vnodes && !!fallbackRenderFn;
|
|
122
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
123
|
+
}
|
|
124
|
+
if (vnodes) renderVNodeChildren(push, vnodes, parentComponent, slotScopeId);
|
|
121
125
|
else if (fallbackRenderFn) fallbackRenderFn();
|
|
122
126
|
else if (transition) push(`<!---->`);
|
|
123
127
|
} else {
|
|
124
128
|
let isEmptySlot = true;
|
|
125
|
-
|
|
129
|
+
const owner = (0, _vue_runtime_dom.getCurrentInstance)();
|
|
130
|
+
if (transition || !(owner && owner.type.__vapor) && !fallbackRenderFn && vaporSlots !== before) isEmptySlot = false;
|
|
126
131
|
else for (let i = 0; i < slotBuffer.length; i++) if (!isComment(slotBuffer[i])) {
|
|
127
132
|
isEmptySlot = false;
|
|
128
133
|
break;
|
|
129
134
|
}
|
|
135
|
+
if (!transition) {
|
|
136
|
+
fallback = isEmptySlot && !!fallbackRenderFn;
|
|
137
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
138
|
+
}
|
|
130
139
|
if (isEmptySlot) {
|
|
131
140
|
if (fallbackRenderFn) fallbackRenderFn();
|
|
132
141
|
} else {
|
|
133
142
|
let start = 0;
|
|
134
143
|
let end = slotBuffer.length;
|
|
135
|
-
if (transition
|
|
136
|
-
|
|
137
|
-
end
|
|
144
|
+
if (transition) {
|
|
145
|
+
const first = slotBuffer[0];
|
|
146
|
+
if ((first === "<!--[-->" || first === "<!--(-->") && slotBuffer[end - 1] === (first === "<!--(-->" ? "<!--)-->" : "<!--]-->")) {
|
|
147
|
+
start++;
|
|
148
|
+
end--;
|
|
149
|
+
}
|
|
138
150
|
}
|
|
139
151
|
if (start < end) for (let i = start; i < end; i++) push(slotBuffer[i]);
|
|
140
152
|
else if (transition) push(`<!---->`);
|
|
141
153
|
}
|
|
142
154
|
}
|
|
143
|
-
} else
|
|
144
|
-
|
|
155
|
+
} else {
|
|
156
|
+
if (!transition) {
|
|
157
|
+
fallback = !!fallbackRenderFn;
|
|
158
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
159
|
+
}
|
|
160
|
+
if (fallbackRenderFn) fallbackRenderFn();
|
|
161
|
+
else if (transition) push(`<!---->`);
|
|
162
|
+
}
|
|
163
|
+
if (!transition) push(fallback ? `<!--)-->` : `<!--]-->`);
|
|
145
164
|
}
|
|
146
165
|
const commentTestRE = /^<!--[\s\S]*-->$/;
|
|
147
166
|
const commentRE = /<!--[^]*?-->/gm;
|
|
@@ -151,6 +170,16 @@ function isComment(item) {
|
|
|
151
170
|
return !item.replace(commentRE, "").trim();
|
|
152
171
|
}
|
|
153
172
|
//#endregion
|
|
173
|
+
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
174
|
+
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
175
|
+
if ((0, _vue_shared.isString)(comp)) {
|
|
176
|
+
const { getBuffer, push } = createBuffer();
|
|
177
|
+
renderVNode(push, (0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
178
|
+
return getBuffer();
|
|
179
|
+
}
|
|
180
|
+
return renderComponentVNode((0, _vue_runtime_dom.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
181
|
+
}
|
|
182
|
+
//#endregion
|
|
154
183
|
//#region packages/server-renderer/src/helpers/ssrRenderTeleport.ts
|
|
155
184
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
156
185
|
parentPush("<!--teleport start-->");
|
|
@@ -183,14 +212,16 @@ function ssrInterpolate(value) {
|
|
|
183
212
|
function ssrRenderList(source, renderItem) {
|
|
184
213
|
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);
|
|
185
214
|
else if (typeof source === "number") for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
186
|
-
else if ((0, _vue_shared.isObject)(source))
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
215
|
+
else if ((0, _vue_shared.isObject)(source)) {
|
|
216
|
+
if (source[Symbol.iterator]) {
|
|
217
|
+
let i = 0;
|
|
218
|
+
for (const item of source) renderItem(item, i++);
|
|
219
|
+
} else {
|
|
220
|
+
const keys = Object.keys(source);
|
|
221
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
222
|
+
const key = keys[i];
|
|
223
|
+
renderItem(source[key], key, i);
|
|
224
|
+
}
|
|
194
225
|
}
|
|
195
226
|
}
|
|
196
227
|
}
|
|
@@ -291,7 +322,7 @@ function ssrCompile(template, instance) {
|
|
|
291
322
|
}
|
|
292
323
|
//#endregion
|
|
293
324
|
//#region packages/server-renderer/src/render.ts
|
|
294
|
-
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = _vue_runtime_dom.ssrUtils;
|
|
325
|
+
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, isVNode: isVNode$2, normalizeVNode, pushWarningContext, popWarningContext, VaporSlot, rawVaporSlotKey, invokeSlotFallback } = _vue_runtime_dom.ssrUtils;
|
|
295
326
|
function cleanupContext(context) {
|
|
296
327
|
let firstError;
|
|
297
328
|
if (context.__watcherHandles) {
|
|
@@ -331,7 +362,41 @@ function createBuffer() {
|
|
|
331
362
|
}
|
|
332
363
|
};
|
|
333
364
|
}
|
|
365
|
+
const vaporOutlets = /* @__PURE__ */ new WeakMap();
|
|
366
|
+
const vaporInterface = { attachSlotOutlet(content, fallback, owner) {
|
|
367
|
+
const lone = isVaporSlotContent(content);
|
|
368
|
+
if (lone) vaporOutlets.set(content, {
|
|
369
|
+
fallback,
|
|
370
|
+
owner
|
|
371
|
+
});
|
|
372
|
+
return lone;
|
|
373
|
+
} };
|
|
374
|
+
function isVaporSlotContent(children) {
|
|
375
|
+
const lone = findVaporSlot(children);
|
|
376
|
+
vaporSlot = null;
|
|
377
|
+
return lone;
|
|
378
|
+
}
|
|
379
|
+
let vaporSlot = null;
|
|
380
|
+
function findVaporSlot(children) {
|
|
381
|
+
for (let i = 0; i < children.length; i++) {
|
|
382
|
+
const child = children[i];
|
|
383
|
+
if (!isVNode$2(child)) return false;
|
|
384
|
+
if (child.type === VaporSlot) {
|
|
385
|
+
if (vaporSlot) return false;
|
|
386
|
+
vaporSlot = child;
|
|
387
|
+
} else if (child.type === _vue_runtime_dom.Fragment) {
|
|
388
|
+
if (child.patchFlag > 0 && child.patchFlag & 384 || !findVaporSlot(child.children)) return false;
|
|
389
|
+
} else if (child.type !== _vue_runtime_dom.Comment) return false;
|
|
390
|
+
}
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
334
393
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
394
|
+
const ctx = vnode.ctx;
|
|
395
|
+
if (vnode.shapeFlag & 32 && ctx && ctx.type.__vapor) {
|
|
396
|
+
const slots = vnode.children;
|
|
397
|
+
for (const name in slots) if ((0, _vue_shared.isFunction)(slots[name])) slots[name][rawVaporSlotKey] = slots[name];
|
|
398
|
+
if (!ctx.appContext.vapor) ctx.appContext.vapor = vaporInterface;
|
|
399
|
+
}
|
|
335
400
|
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
336
401
|
const context = instance.appContext.provides[_vue_runtime_dom.ssrContextKey];
|
|
337
402
|
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
@@ -392,7 +457,8 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
392
457
|
}
|
|
393
458
|
} else if (instance.render && instance.render !== _vue_shared.NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
|
|
394
459
|
else {
|
|
395
|
-
|
|
460
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
461
|
+
(0, _vue_runtime_dom.warn)(`Component ${componentName} is missing template or render function.`);
|
|
396
462
|
push(`<!---->`);
|
|
397
463
|
}
|
|
398
464
|
}
|
|
@@ -411,12 +477,25 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
411
477
|
case _vue_runtime_dom.Static:
|
|
412
478
|
push(children);
|
|
413
479
|
break;
|
|
414
|
-
case _vue_runtime_dom.Fragment:
|
|
480
|
+
case _vue_runtime_dom.Fragment: {
|
|
415
481
|
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
416
|
-
|
|
482
|
+
const outlet = vnode.vo && vaporOutlets.get(children);
|
|
483
|
+
if (outlet) {
|
|
484
|
+
renderVaporOutlet(push, (_, push) => renderVNodeChildren(push, children, parentComponent, slotScopeId), null, outlet, parentComponent, slotScopeId);
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
const isFallback = shapeFlag & 1024;
|
|
488
|
+
push(isFallback ? `<!--(-->` : `<!--[-->`);
|
|
417
489
|
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
418
|
-
push(`<!--]-->`);
|
|
490
|
+
push(isFallback ? `<!--)-->` : `<!--]-->`);
|
|
419
491
|
break;
|
|
492
|
+
}
|
|
493
|
+
case VaporSlot: {
|
|
494
|
+
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
495
|
+
const { slot, outlets } = vnode.vs;
|
|
496
|
+
renderVaporOutlet(push, slot, vnode.props, outlets && outlets[0], parentComponent, slotScopeId);
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
420
499
|
default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
421
500
|
else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
422
501
|
else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
@@ -424,6 +503,11 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
424
503
|
else (0, _vue_runtime_dom.warn)("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
|
|
425
504
|
}
|
|
426
505
|
}
|
|
506
|
+
function renderVaporOutlet(push, slot, props, outlet, parentComponent, slotScopeId) {
|
|
507
|
+
const prev = setCurrentRenderingInstance(parentComponent);
|
|
508
|
+
ssrRenderSlot({ default: slot }, "default", props, outlet ? () => renderVNodeChildren(push, invokeSlotFallback(outlet.fallback, outlet.owner), parentComponent, slotScopeId) : null, push, parentComponent, slotScopeId);
|
|
509
|
+
setCurrentRenderingInstance(prev);
|
|
510
|
+
}
|
|
427
511
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
428
512
|
for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
429
513
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { App, Component, ComponentInternalInstance, ComponentPublicInstance, Directive, Slots, VNode } from "@vue/runtime-dom";
|
|
2
2
|
import { Readable, Writable } from "node:stream";
|
|
3
3
|
import { includeBooleanAttr as ssrIncludeBooleanAttr } from "@vue/shared";
|
|
4
|
-
|
|
5
4
|
//#region temp/packages/server-renderer/src/render.d.ts
|
|
6
5
|
type SSRBuffer = SSRBufferItem[] & {
|
|
7
6
|
hasAsync?: boolean;
|
|
@@ -25,8 +24,8 @@ export interface SimpleReadable {
|
|
|
25
24
|
}
|
|
26
25
|
export declare function renderToSimpleStream<T extends SimpleReadable>(input: App | VNode, context: SSRContext, stream: T): T;
|
|
27
26
|
/**
|
|
28
|
-
* @deprecated
|
|
29
|
-
*/
|
|
27
|
+
* @deprecated
|
|
28
|
+
*/
|
|
30
29
|
export declare function renderToStream(input: App | VNode, context?: SSRContext): Readable;
|
|
31
30
|
export declare function renderToNodeStream(input: App | VNode, context?: SSRContext): Readable;
|
|
32
31
|
export declare function pipeToNodeWritable(input: App | VNode, context: SSRContext | undefined, writable: Writable): void;
|
|
@@ -36,8 +35,8 @@ export declare function pipeToWebWritable(input: App | VNode, context: SSRContex
|
|
|
36
35
|
//#region temp/packages/server-renderer/src/helpers/ssrRenderSlot.d.ts
|
|
37
36
|
type SSRSlots = Record<string, SSRSlot>;
|
|
38
37
|
type SSRSlot = (props: Props, push: PushFn, parentComponent: ComponentInternalInstance | null, scopeId: string | null) => void;
|
|
39
|
-
export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
|
|
40
|
-
export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string, transition?: boolean): void;
|
|
38
|
+
export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props | null | undefined, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
|
|
39
|
+
export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props | null | undefined, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string, transition?: boolean): void;
|
|
41
40
|
//#endregion
|
|
42
41
|
//#region temp/packages/server-renderer/src/helpers/ssrRenderComponent.d.ts
|
|
43
42
|
export declare function ssrRenderComponent(comp: Component | string, props?: Props | null, children?: Slots | SSRSlots | null, parentComponent?: ComponentInternalInstance | null, slotScopeId?: string): SSRBuffer | Promise<SSRBuffer>;
|
|
@@ -59,9 +58,7 @@ export declare function ssrInterpolate(value: unknown): string;
|
|
|
59
58
|
export declare function ssrRenderList(source: unknown, renderItem: (value: unknown, key: string | number, index?: number) => void): void;
|
|
60
59
|
//#endregion
|
|
61
60
|
//#region temp/packages/server-renderer/src/helpers/ssrRenderSuspense.d.ts
|
|
62
|
-
export declare function ssrRenderSuspense(push: PushFn, {
|
|
63
|
-
default: renderContent
|
|
64
|
-
}: Record<string, (() => void) | undefined>): void;
|
|
61
|
+
export declare function ssrRenderSuspense(push: PushFn, { default: renderContent }: Record<string, (() => void) | undefined>): void;
|
|
65
62
|
//#endregion
|
|
66
63
|
//#region temp/packages/server-renderer/src/helpers/ssrGetDirectiveProps.d.ts
|
|
67
64
|
export declare function ssrGetDirectiveProps(instance: ComponentPublicInstance, dir: Directive, value?: any, arg?: string, modifiers?: Record<string, boolean>): Record<string, any>;
|
|
@@ -70,7 +67,7 @@ export declare function ssrGetDirectiveProps(instance: ComponentPublicInstance,
|
|
|
70
67
|
export declare const ssrLooseEqual: (a: unknown, b: unknown) => boolean;
|
|
71
68
|
export declare function ssrLooseContain(arr: unknown[], value: unknown): boolean;
|
|
72
69
|
export declare function ssrRenderDynamicModel(type: unknown, model: unknown, value: unknown): string;
|
|
73
|
-
export declare function ssrGetDynamicModelProps(existingProps: any, model: unknown): {
|
|
70
|
+
export declare function ssrGetDynamicModelProps(existingProps: any | undefined, model: unknown): {
|
|
74
71
|
checked: true;
|
|
75
72
|
} | {
|
|
76
73
|
value: any;
|