@vue/server-renderer 3.6.0-beta.9 → 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 +171 -327
- package/dist/server-renderer.cjs.prod.js +169 -63
- package/dist/server-renderer.d.ts +8 -11
- package/dist/server-renderer.esm-browser.js +956 -481
- package/dist/server-renderer.esm-browser.prod.js +2 -2
- package/dist/server-renderer.esm-bundler.js +149 -820
- package/package.json +4 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.6.0-
|
|
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,17 +33,17 @@ 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));
|
|
40
40
|
//#endregion
|
|
41
|
-
let
|
|
42
|
-
|
|
41
|
+
let _vue_runtime_dom = require("@vue/runtime-dom");
|
|
42
|
+
_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,53 +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
|
-
return renderComponentVNode((0, vue.createVNode)(comp, props, children), parentComponent, slotScopeId);
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
94
|
//#region packages/server-renderer/src/helpers/ssrRenderSlot.ts
|
|
99
|
-
const { ensureValidVNode } =
|
|
95
|
+
const { ensureValidVNode, rawVaporSlotKey: rawVaporSlotKey$1 } = _vue_runtime_dom.ssrUtils;
|
|
96
|
+
let vaporSlots = 0;
|
|
100
97
|
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
|
|
101
|
-
push(`<!--[-->`);
|
|
102
98
|
ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
|
|
103
|
-
push(`<!--]-->`);
|
|
104
99
|
}
|
|
105
100
|
function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
|
|
106
101
|
const slotFn = slots[slotName];
|
|
102
|
+
let fallback = false;
|
|
107
103
|
if (slotFn) {
|
|
104
|
+
if (slotFn[rawVaporSlotKey$1]) vaporSlots++;
|
|
105
|
+
const before = vaporSlots;
|
|
108
106
|
const slotBuffer = [];
|
|
109
107
|
const bufferedPush = (item) => {
|
|
110
108
|
slotBuffer.push(item);
|
|
111
109
|
};
|
|
112
|
-
const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
110
|
+
const ret = slotFn(slotProps || {}, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
|
|
111
|
+
let vnodes;
|
|
113
112
|
if ((0, _vue_shared.isArray)(ret)) {
|
|
114
|
-
|
|
115
|
-
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);
|
|
116
125
|
else if (fallbackRenderFn) fallbackRenderFn();
|
|
117
126
|
else if (transition) push(`<!---->`);
|
|
118
127
|
} else {
|
|
119
128
|
let isEmptySlot = true;
|
|
120
|
-
|
|
129
|
+
const owner = (0, _vue_runtime_dom.getCurrentInstance)();
|
|
130
|
+
if (transition || !(owner && owner.type.__vapor) && !fallbackRenderFn && vaporSlots !== before) isEmptySlot = false;
|
|
121
131
|
else for (let i = 0; i < slotBuffer.length; i++) if (!isComment(slotBuffer[i])) {
|
|
122
132
|
isEmptySlot = false;
|
|
123
133
|
break;
|
|
124
134
|
}
|
|
135
|
+
if (!transition) {
|
|
136
|
+
fallback = isEmptySlot && !!fallbackRenderFn;
|
|
137
|
+
push(fallback ? `<!--(-->` : `<!--[-->`);
|
|
138
|
+
}
|
|
125
139
|
if (isEmptySlot) {
|
|
126
140
|
if (fallbackRenderFn) fallbackRenderFn();
|
|
127
141
|
} else {
|
|
128
142
|
let start = 0;
|
|
129
143
|
let end = slotBuffer.length;
|
|
130
|
-
if (transition
|
|
131
|
-
|
|
132
|
-
end
|
|
144
|
+
if (transition) {
|
|
145
|
+
const first = slotBuffer[0];
|
|
146
|
+
if ((first === "<!--[-->" || first === "<!--(-->") && slotBuffer[end - 1] === (first === "<!--(-->" ? "<!--)-->" : "<!--]-->")) {
|
|
147
|
+
start++;
|
|
148
|
+
end--;
|
|
149
|
+
}
|
|
133
150
|
}
|
|
134
151
|
if (start < end) for (let i = start; i < end; i++) push(slotBuffer[i]);
|
|
135
152
|
else if (transition) push(`<!---->`);
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
|
-
} else
|
|
139
|
-
|
|
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 ? `<!--)-->` : `<!--]-->`);
|
|
140
164
|
}
|
|
141
165
|
const commentTestRE = /^<!--[\s\S]*-->$/;
|
|
142
166
|
const commentRE = /<!--[^]*?-->/gm;
|
|
@@ -146,10 +170,20 @@ function isComment(item) {
|
|
|
146
170
|
return !item.replace(commentRE, "").trim();
|
|
147
171
|
}
|
|
148
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
|
|
149
183
|
//#region packages/server-renderer/src/helpers/ssrRenderTeleport.ts
|
|
150
184
|
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
|
|
151
185
|
parentPush("<!--teleport start-->");
|
|
152
|
-
const context = parentComponent.appContext.provides[
|
|
186
|
+
const context = parentComponent.appContext.provides[_vue_runtime_dom.ssrContextKey];
|
|
153
187
|
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
|
|
154
188
|
const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
|
|
155
189
|
const bufferIndex = targetBuffer.length;
|
|
@@ -165,6 +199,7 @@ function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parent
|
|
|
165
199
|
teleportContent = getBuffer();
|
|
166
200
|
}
|
|
167
201
|
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
202
|
+
if ((0, _vue_shared.isPromise)(teleportContent) || (0, _vue_shared.isArray)(teleportContent) && teleportContent.hasAsync) targetBuffer.hasAsync = true;
|
|
168
203
|
parentPush("<!--teleport end-->");
|
|
169
204
|
}
|
|
170
205
|
//#endregion
|
|
@@ -177,20 +212,22 @@ function ssrInterpolate(value) {
|
|
|
177
212
|
function ssrRenderList(source, renderItem) {
|
|
178
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);
|
|
179
214
|
else if (typeof source === "number") for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
180
|
-
else if ((0, _vue_shared.isObject)(source))
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
+
}
|
|
188
225
|
}
|
|
189
226
|
}
|
|
190
227
|
}
|
|
191
228
|
//#endregion
|
|
192
229
|
//#region packages/server-renderer/src/helpers/ssrRenderSuspense.ts
|
|
193
|
-
|
|
230
|
+
function ssrRenderSuspense(push, { default: renderContent }) {
|
|
194
231
|
if (renderContent) renderContent();
|
|
195
232
|
else push(`<!---->`);
|
|
196
233
|
}
|
|
@@ -199,7 +236,7 @@ async function ssrRenderSuspense(push, { default: renderContent }) {
|
|
|
199
236
|
function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
|
|
200
237
|
if (typeof dir !== "function" && dir.getSSRProps) return dir.getSSRProps({
|
|
201
238
|
dir,
|
|
202
|
-
instance:
|
|
239
|
+
instance: _vue_runtime_dom.ssrUtils.getComponentPublicInstance(instance.$),
|
|
203
240
|
value,
|
|
204
241
|
oldValue: void 0,
|
|
205
242
|
arg,
|
|
@@ -277,7 +314,7 @@ function ssrCompile(template, instance) {
|
|
|
277
314
|
};
|
|
278
315
|
const { code } = (0, _vue_compiler_ssr.compile)(template, finalCompilerOptions);
|
|
279
316
|
const requireMap = {
|
|
280
|
-
vue,
|
|
317
|
+
vue: _vue_runtime_dom,
|
|
281
318
|
"vue/server-renderer": internal_exports
|
|
282
319
|
};
|
|
283
320
|
const fakeRequire = (id) => requireMap[id];
|
|
@@ -285,7 +322,7 @@ function ssrCompile(template, instance) {
|
|
|
285
322
|
}
|
|
286
323
|
//#endregion
|
|
287
324
|
//#region packages/server-renderer/src/render.ts
|
|
288
|
-
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } =
|
|
325
|
+
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, isVNode: isVNode$2, normalizeVNode, pushWarningContext, popWarningContext, VaporSlot, rawVaporSlotKey, invokeSlotFallback } = _vue_runtime_dom.ssrUtils;
|
|
289
326
|
function cleanupContext(context) {
|
|
290
327
|
let firstError;
|
|
291
328
|
if (context.__watcherHandles) {
|
|
@@ -325,9 +362,43 @@ function createBuffer() {
|
|
|
325
362
|
}
|
|
326
363
|
};
|
|
327
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
|
+
}
|
|
328
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
|
+
}
|
|
329
400
|
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
330
|
-
const context = instance.appContext.provides[
|
|
401
|
+
const context = instance.appContext.provides[_vue_runtime_dom.ssrContextKey];
|
|
331
402
|
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
332
403
|
const res = setupComponent(instance, true);
|
|
333
404
|
const hasAsyncSetup = (0, _vue_shared.isPromise)(res);
|
|
@@ -336,7 +407,11 @@ function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
|
336
407
|
if (hasAsyncSetup) prefetches = instance.sp;
|
|
337
408
|
if (prefetches) return Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)));
|
|
338
409
|
}).catch(_vue_shared.NOOP).then(() => renderComponentSubTree(instance, slotScopeId));
|
|
339
|
-
else
|
|
410
|
+
else try {
|
|
411
|
+
return renderComponentSubTree(instance, slotScopeId);
|
|
412
|
+
} catch (err) {
|
|
413
|
+
return Promise.reject(err);
|
|
414
|
+
}
|
|
340
415
|
}
|
|
341
416
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
342
417
|
const comp = instance.type;
|
|
@@ -375,12 +450,15 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
375
450
|
const prev = setCurrentRenderingInstance(instance);
|
|
376
451
|
try {
|
|
377
452
|
ssrRender(instance.proxy, push, instance, attrs, instance.props, instance.setupState, instance.data, instance.ctx);
|
|
453
|
+
} catch (err) {
|
|
454
|
+
(0, _vue_runtime_dom.handleError)(err, instance, 1);
|
|
378
455
|
} finally {
|
|
379
456
|
setCurrentRenderingInstance(prev);
|
|
380
457
|
}
|
|
381
458
|
} else if (instance.render && instance.render !== _vue_shared.NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
|
|
382
459
|
else {
|
|
383
|
-
|
|
460
|
+
const componentName = comp.name || comp.__file || `<Anonymous>`;
|
|
461
|
+
(0, _vue_runtime_dom.warn)(`Component ${componentName} is missing template or render function.`);
|
|
384
462
|
push(`<!---->`);
|
|
385
463
|
}
|
|
386
464
|
}
|
|
@@ -390,28 +468,46 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
390
468
|
const { type, shapeFlag, children, dirs, props } = vnode;
|
|
391
469
|
if (dirs) vnode.props = applySSRDirectives(vnode, props, dirs);
|
|
392
470
|
switch (type) {
|
|
393
|
-
case
|
|
471
|
+
case _vue_runtime_dom.Text:
|
|
394
472
|
push((0, _vue_shared.escapeHtml)(children));
|
|
395
473
|
break;
|
|
396
|
-
case
|
|
474
|
+
case _vue_runtime_dom.Comment:
|
|
397
475
|
push(children ? `<!--${(0, _vue_shared.escapeHtmlComment)(children)}-->` : `<!---->`);
|
|
398
476
|
break;
|
|
399
|
-
case
|
|
477
|
+
case _vue_runtime_dom.Static:
|
|
400
478
|
push(children);
|
|
401
479
|
break;
|
|
402
|
-
case
|
|
480
|
+
case _vue_runtime_dom.Fragment: {
|
|
403
481
|
if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
|
|
404
|
-
|
|
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 ? `<!--(-->` : `<!--[-->`);
|
|
405
489
|
renderVNodeChildren(push, children, parentComponent, slotScopeId);
|
|
406
|
-
push(`<!--]-->`);
|
|
490
|
+
push(isFallback ? `<!--)-->` : `<!--]-->`);
|
|
407
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
|
+
}
|
|
408
499
|
default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
|
|
409
500
|
else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
|
|
410
501
|
else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
|
|
411
502
|
else if (shapeFlag & 128) renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
|
|
412
|
-
else (0,
|
|
503
|
+
else (0, _vue_runtime_dom.warn)("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
|
|
413
504
|
}
|
|
414
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
|
+
}
|
|
415
511
|
function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
|
|
416
512
|
for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
|
|
417
513
|
}
|
|
@@ -420,15 +516,25 @@ function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
420
516
|
let { props, children, shapeFlag, scopeId } = vnode;
|
|
421
517
|
let openTag = `<${tag}`;
|
|
422
518
|
if (props) openTag += ssrRenderAttrs(props, tag);
|
|
423
|
-
|
|
519
|
+
const renderedScopeIds = [];
|
|
520
|
+
const appendScopeId = (id) => {
|
|
521
|
+
if (id && (!props || !(0, _vue_shared.hasOwn)(props, id)) && !renderedScopeIds.includes(id)) {
|
|
522
|
+
openTag += ` ${id}`;
|
|
523
|
+
renderedScopeIds.push(id);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
if (scopeId) appendScopeId(scopeId);
|
|
424
527
|
let curParent = parentComponent;
|
|
425
528
|
let curVnode = vnode;
|
|
426
529
|
while (curParent && curVnode === curParent.subTree) {
|
|
427
530
|
curVnode = curParent.vnode;
|
|
428
|
-
if (curVnode.scopeId)
|
|
531
|
+
if (curVnode.scopeId) appendScopeId(curVnode.scopeId);
|
|
429
532
|
curParent = curParent.parent;
|
|
430
533
|
}
|
|
431
|
-
if (slotScopeId)
|
|
534
|
+
if (slotScopeId) {
|
|
535
|
+
const slotScopeIdList = slotScopeId.trim().split(" ");
|
|
536
|
+
for (let i = 0; i < slotScopeIdList.length; i++) appendScopeId(slotScopeIdList[i]);
|
|
537
|
+
}
|
|
432
538
|
push(openTag + `>`);
|
|
433
539
|
if (!(0, _vue_shared.isVoidTag)(tag)) {
|
|
434
540
|
let hasChildrenOverride = false;
|
|
@@ -461,17 +567,17 @@ function applySSRDirectives(vnode, rawProps, dirs) {
|
|
|
461
567
|
if (props) toMerge.push(props);
|
|
462
568
|
}
|
|
463
569
|
}
|
|
464
|
-
return (0,
|
|
570
|
+
return (0, _vue_runtime_dom.mergeProps)(rawProps || {}, ...toMerge);
|
|
465
571
|
}
|
|
466
572
|
function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
467
573
|
const target = vnode.props && vnode.props.to;
|
|
468
574
|
const disabled = vnode.props && vnode.props.disabled;
|
|
469
575
|
if (!target) {
|
|
470
|
-
if (!disabled) (0,
|
|
576
|
+
if (!disabled) (0, _vue_runtime_dom.warn)(`[@vue/server-renderer] Teleport is missing target prop.`);
|
|
471
577
|
return [];
|
|
472
578
|
}
|
|
473
579
|
if (!(0, _vue_shared.isString)(target)) {
|
|
474
|
-
(0,
|
|
580
|
+
(0, _vue_runtime_dom.warn)(`[@vue/server-renderer] Teleport target must be a query selector string.`);
|
|
475
581
|
return [];
|
|
476
582
|
}
|
|
477
583
|
ssrRenderTeleport(push, (push) => {
|
|
@@ -480,7 +586,7 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
480
586
|
}
|
|
481
587
|
//#endregion
|
|
482
588
|
//#region packages/server-renderer/src/renderToString.ts
|
|
483
|
-
const { isVNode: isVNode$1 } =
|
|
589
|
+
const { isVNode: isVNode$1 } = _vue_runtime_dom.ssrUtils;
|
|
484
590
|
function nestedUnrollBuffer(buffer, parentRet, startIndex) {
|
|
485
591
|
if (!buffer.hasAsync) return parentRet + unrollBufferSync$1(buffer);
|
|
486
592
|
let ret = parentRet;
|
|
@@ -516,10 +622,10 @@ function unrollBufferSync$1(buffer) {
|
|
|
516
622
|
return ret;
|
|
517
623
|
}
|
|
518
624
|
async function renderToString(input, context = {}) {
|
|
519
|
-
if (isVNode$1(input)) return renderToString((0,
|
|
520
|
-
const vnode = (0,
|
|
625
|
+
if (isVNode$1(input)) return renderToString((0, _vue_runtime_dom.createApp)({ render: () => input }), context);
|
|
626
|
+
const vnode = (0, _vue_runtime_dom.createVNode)(input._component, input._props);
|
|
521
627
|
vnode.appContext = input._context;
|
|
522
|
-
input.provide(
|
|
628
|
+
input.provide(_vue_runtime_dom.ssrContextKey, context);
|
|
523
629
|
try {
|
|
524
630
|
const result = await unrollBuffer$1(await renderComponentVNode(vnode));
|
|
525
631
|
await resolveTeleports(context);
|
|
@@ -531,12 +637,12 @@ async function renderToString(input, context = {}) {
|
|
|
531
637
|
async function resolveTeleports(context) {
|
|
532
638
|
if (context.__teleportBuffers) {
|
|
533
639
|
context.teleports = context.teleports || {};
|
|
534
|
-
for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(
|
|
640
|
+
for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(context.__teleportBuffers[key]);
|
|
535
641
|
}
|
|
536
642
|
}
|
|
537
643
|
//#endregion
|
|
538
644
|
//#region packages/server-renderer/src/renderToStream.ts
|
|
539
|
-
const { isVNode } =
|
|
645
|
+
const { isVNode } = _vue_runtime_dom.ssrUtils;
|
|
540
646
|
async function unrollBuffer(buffer, stream) {
|
|
541
647
|
if (buffer.hasAsync) for (let i = 0; i < buffer.length; i++) {
|
|
542
648
|
let item = buffer[i];
|
|
@@ -554,10 +660,10 @@ function unrollBufferSync(buffer, stream) {
|
|
|
554
660
|
}
|
|
555
661
|
}
|
|
556
662
|
function renderToSimpleStream(input, context, stream) {
|
|
557
|
-
if (isVNode(input)) return renderToSimpleStream((0,
|
|
558
|
-
const vnode = (0,
|
|
663
|
+
if (isVNode(input)) return renderToSimpleStream((0, _vue_runtime_dom.createApp)({ render: () => input }), context, stream);
|
|
664
|
+
const vnode = (0, _vue_runtime_dom.createVNode)(input._component, input._props);
|
|
559
665
|
vnode.appContext = input._context;
|
|
560
|
-
input.provide(
|
|
666
|
+
input.provide(_vue_runtime_dom.ssrContextKey, context);
|
|
561
667
|
let cleaned = false;
|
|
562
668
|
const finalize = () => {
|
|
563
669
|
if (cleaned) return;
|
|
@@ -641,7 +747,7 @@ function pipeToWebWritable(input, context = {}, writable) {
|
|
|
641
747
|
}
|
|
642
748
|
//#endregion
|
|
643
749
|
//#region packages/server-renderer/src/index.ts
|
|
644
|
-
(0,
|
|
750
|
+
(0, _vue_runtime_dom.initDirectivesForSSR)();
|
|
645
751
|
//#endregion
|
|
646
752
|
exports.pipeToNodeWritable = pipeToNodeWritable;
|
|
647
753
|
exports.pipeToWebWritable = pipeToWebWritable;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { App, Component, ComponentInternalInstance, ComponentPublicInstance, Directive, Slots, VNode } from "vue";
|
|
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,11 +35,11 @@ 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
|
-
export declare function ssrRenderComponent(comp: Component, props?: Props | null, children?: Slots | SSRSlots | null, parentComponent?: ComponentInternalInstance | null, slotScopeId?: string): SSRBuffer | Promise<SSRBuffer>;
|
|
42
|
+
export declare function ssrRenderComponent(comp: Component | string, props?: Props | null, children?: Slots | SSRSlots | null, parentComponent?: ComponentInternalInstance | null, slotScopeId?: string): SSRBuffer | Promise<SSRBuffer>;
|
|
44
43
|
//#endregion
|
|
45
44
|
//#region temp/packages/server-renderer/src/helpers/ssrRenderTeleport.d.ts
|
|
46
45
|
export declare function ssrRenderTeleport(parentPush: PushFn, contentRenderFn: (push: PushFn) => void, target: string, disabled: boolean, parentComponent: ComponentInternalInstance): void;
|
|
@@ -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>): Promise<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;
|