@vue/server-renderer 3.6.0-beta.1 → 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.
@@ -1,432 +1,390 @@
1
1
  /**
2
- * @vue/server-renderer v3.6.0-beta.1
3
- * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
- * @license MIT
5
- **/
6
- import { createVNode as createVNode$1, ssrUtils, ssrContextKey, warn as warn$2, Fragment as Fragment$1, Static, Comment as Comment$1, Text as Text$1, mergeProps as mergeProps$1, createApp, initDirectivesForSSR } from 'vue';
7
- import { makeMap, isOn, isRenderableAttrValue, isSVGTag, propsToAttrMap, isBooleanAttr, includeBooleanAttr, isSSRSafeAttrName, escapeHtml, normalizeClass, isString, normalizeStyle, stringifyStyle, isArray, isObject, normalizeCssVarValue, toDisplayString, isFunction, EMPTY_OBJ, getGlobalThis, extend, NOOP, looseEqual, looseIndexOf, escapeHtmlComment, isPromise, isVoidTag } from '@vue/shared';
8
- export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
9
-
10
- const shouldIgnoreProp = /* @__PURE__ */ makeMap(
11
- `,key,ref,innerHTML,textContent,ref_key,ref_for`
12
- );
2
+ * @vue/server-renderer v3.6.0-beta.10
3
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
+ * @license MIT
5
+ **/
6
+ import { Comment, Fragment, Static, Text, createApp, createVNode, initDirectivesForSSR, mergeProps, ssrContextKey, ssrUtils, warn } from "vue";
7
+ import { EMPTY_OBJ, NOOP, escapeHtml, escapeHtmlComment, extend, getGlobalThis, includeBooleanAttr, includeBooleanAttr as ssrIncludeBooleanAttr, isArray, isBooleanAttr, isFunction, isModelListener, isObject, isOn, isPromise, isRenderableAttrValue, isSSRSafeAttrName, isSVGTag, isString, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeCssVarValue, normalizeStyle, propsToAttrMap, stringifyStyle, toDisplayString } from "@vue/shared";
8
+ //#region packages/server-renderer/src/helpers/ssrRenderAttrs.ts
9
+ const shouldIgnoreProp = /* @__PURE__ */ makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
13
10
  function ssrRenderAttrs(props, tag) {
14
- let ret = "";
15
- for (const key in props) {
16
- if (shouldIgnoreProp(key) || isOn(key) || tag === "textarea" && key === "value") {
17
- continue;
18
- }
19
- const value = props[key];
20
- if (key === "class") {
21
- ret += ` class="${ssrRenderClass(value)}"`;
22
- } else if (key === "style") {
23
- ret += ` style="${ssrRenderStyle(value)}"`;
24
- } else if (key === "className") {
25
- ret += ` class="${String(value)}"`;
26
- } else {
27
- ret += ssrRenderDynamicAttr(key, value, tag);
28
- }
29
- }
30
- return ret;
11
+ let ret = "";
12
+ for (let key in props) {
13
+ if (shouldIgnoreProp(key) || isOn(key) || tag === "textarea" && key === "value" || key.startsWith(".")) continue;
14
+ const value = props[key];
15
+ if (key.startsWith("^")) key = key.slice(1);
16
+ if (key === "class") ret += ` class="${ssrRenderClass(value)}"`;
17
+ else if (key === "style") ret += ` style="${ssrRenderStyle(value)}"`;
18
+ else if (key === "className") {
19
+ if (value != null) ret += ` class="${escapeHtml(String(value))}"`;
20
+ } else ret += ssrRenderDynamicAttr(key, value, tag);
21
+ }
22
+ return ret;
31
23
  }
32
24
  function ssrRenderDynamicAttr(key, value, tag) {
33
- if (!isRenderableAttrValue(value)) {
34
- return ``;
35
- }
36
- const attrKey = tag && (tag.indexOf("-") > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase();
37
- if (isBooleanAttr(attrKey)) {
38
- return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
39
- } else if (isSSRSafeAttrName(attrKey)) {
40
- return value === "" ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`;
41
- } else {
42
- console.warn(
43
- `[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
44
- );
45
- return ``;
46
- }
25
+ if (!isRenderableAttrValue(value)) return ``;
26
+ const attrKey = tag && (tag.indexOf("-") > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase();
27
+ if (isBooleanAttr(attrKey)) return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
28
+ else if (isSSRSafeAttrName(attrKey)) return value === "" ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`;
29
+ else {
30
+ console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
31
+ return ``;
32
+ }
47
33
  }
48
34
  function ssrRenderAttr(key, value) {
49
- if (!isRenderableAttrValue(value)) {
50
- return ``;
51
- }
52
- return ` ${key}="${escapeHtml(value)}"`;
35
+ if (!isRenderableAttrValue(value)) return ``;
36
+ return ` ${key}="${escapeHtml(value)}"`;
53
37
  }
54
38
  function ssrRenderClass(raw) {
55
- return escapeHtml(normalizeClass(raw));
39
+ return escapeHtml(normalizeClass(raw));
56
40
  }
57
41
  function ssrRenderStyle(raw) {
58
- if (!raw) {
59
- return "";
60
- }
61
- if (isString(raw)) {
62
- return escapeHtml(raw);
63
- }
64
- const styles = normalizeStyle(ssrResetCssVars(raw));
65
- return escapeHtml(stringifyStyle(styles));
42
+ if (!raw) return "";
43
+ if (isString(raw)) return escapeHtml(raw);
44
+ return escapeHtml(stringifyStyle(normalizeStyle(ssrResetCssVars(raw))));
66
45
  }
67
46
  function ssrResetCssVars(raw) {
68
- if (!isArray(raw) && isObject(raw)) {
69
- const res = {};
70
- for (const key in raw) {
71
- if (key.startsWith(":--")) {
72
- res[key.slice(1)] = normalizeCssVarValue(raw[key]);
73
- } else {
74
- res[key] = raw[key];
75
- }
76
- }
77
- return res;
78
- }
79
- return raw;
80
- }
81
-
47
+ if (!isArray(raw) && isObject(raw)) {
48
+ const res = {};
49
+ for (const key in raw) if (key.startsWith(":--")) res[key.slice(1)] = normalizeCssVarValue(raw[key]);
50
+ else res[key] = raw[key];
51
+ return res;
52
+ }
53
+ return raw;
54
+ }
55
+ //#endregion
56
+ //#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
82
57
  function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
83
- return renderComponentVNode(
84
- createVNode$1(comp, props, children),
85
- parentComponent,
86
- slotScopeId
87
- );
58
+ return renderComponentVNode(createVNode(comp, props, children), parentComponent, slotScopeId);
88
59
  }
89
-
60
+ //#endregion
61
+ //#region packages/server-renderer/src/helpers/ssrRenderSlot.ts
90
62
  const { ensureValidVNode } = ssrUtils;
91
63
  function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
92
- push(`<!--[-->`);
93
- ssrRenderSlotInner(
94
- slots,
95
- slotName,
96
- slotProps,
97
- fallbackRenderFn,
98
- push,
99
- parentComponent,
100
- slotScopeId
101
- );
102
- push(`<!--]-->`);
64
+ push(`<!--[-->`);
65
+ ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
66
+ push(`<!--]-->`);
103
67
  }
104
68
  function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
105
- const slotFn = slots[slotName];
106
- if (slotFn) {
107
- const slotBuffer = [];
108
- const bufferedPush = (item) => {
109
- slotBuffer.push(item);
110
- };
111
- const ret = slotFn(
112
- slotProps,
113
- bufferedPush,
114
- parentComponent,
115
- slotScopeId ? " " + slotScopeId : ""
116
- );
117
- if (isArray(ret)) {
118
- const validSlotContent = ensureValidVNode(ret);
119
- if (validSlotContent) {
120
- renderVNodeChildren(
121
- push,
122
- validSlotContent,
123
- parentComponent,
124
- slotScopeId
125
- );
126
- } else if (fallbackRenderFn) {
127
- fallbackRenderFn();
128
- } else if (transition) {
129
- push(`<!---->`);
130
- }
131
- } else {
132
- let isEmptySlot = true;
133
- if (transition) {
134
- isEmptySlot = false;
135
- } else {
136
- for (let i = 0; i < slotBuffer.length; i++) {
137
- if (!isComment(slotBuffer[i])) {
138
- isEmptySlot = false;
139
- break;
140
- }
141
- }
142
- }
143
- if (isEmptySlot) {
144
- if (fallbackRenderFn) {
145
- fallbackRenderFn();
146
- }
147
- } else {
148
- let start = 0;
149
- let end = slotBuffer.length;
150
- if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
151
- start++;
152
- end--;
153
- }
154
- if (start < end) {
155
- for (let i = start; i < end; i++) {
156
- push(slotBuffer[i]);
157
- }
158
- } else if (transition) {
159
- push(`<!---->`);
160
- }
161
- }
162
- }
163
- } else if (fallbackRenderFn) {
164
- fallbackRenderFn();
165
- } else if (transition) {
166
- push(`<!---->`);
167
- }
69
+ const slotFn = slots[slotName];
70
+ if (slotFn) {
71
+ const slotBuffer = [];
72
+ const bufferedPush = (item) => {
73
+ slotBuffer.push(item);
74
+ };
75
+ const ret = slotFn(slotProps, bufferedPush, parentComponent, slotScopeId ? " " + slotScopeId : "");
76
+ if (isArray(ret)) {
77
+ const validSlotContent = ensureValidVNode(ret);
78
+ if (validSlotContent) renderVNodeChildren(push, validSlotContent, parentComponent, slotScopeId);
79
+ else if (fallbackRenderFn) fallbackRenderFn();
80
+ else if (transition) push(`<!---->`);
81
+ } else {
82
+ let isEmptySlot = true;
83
+ if (transition) isEmptySlot = false;
84
+ else for (let i = 0; i < slotBuffer.length; i++) if (!isComment(slotBuffer[i])) {
85
+ isEmptySlot = false;
86
+ break;
87
+ }
88
+ if (isEmptySlot) {
89
+ if (fallbackRenderFn) fallbackRenderFn();
90
+ } else {
91
+ let start = 0;
92
+ let end = slotBuffer.length;
93
+ if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
94
+ start++;
95
+ end--;
96
+ }
97
+ if (start < end) for (let i = start; i < end; i++) push(slotBuffer[i]);
98
+ else if (transition) push(`<!---->`);
99
+ }
100
+ }
101
+ } else if (fallbackRenderFn) fallbackRenderFn();
102
+ else if (transition) push(`<!---->`);
168
103
  }
169
104
  const commentTestRE = /^<!--[\s\S]*-->$/;
170
105
  const commentRE = /<!--[^]*?-->/gm;
171
106
  function isComment(item) {
172
- if (typeof item !== "string" || !commentTestRE.test(item)) return false;
173
- if (item.length <= 8) return true;
174
- return !item.replace(commentRE, "").trim();
107
+ if (typeof item !== "string" || !commentTestRE.test(item)) return false;
108
+ if (item.length <= 8) return true;
109
+ return !item.replace(commentRE, "").trim();
175
110
  }
176
-
111
+ //#endregion
112
+ //#region packages/server-renderer/src/helpers/ssrRenderTeleport.ts
177
113
  function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
178
- parentPush("<!--teleport start-->");
179
- const context = parentComponent.appContext.provides[ssrContextKey];
180
- const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
181
- const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
182
- const bufferIndex = targetBuffer.length;
183
- let teleportContent;
184
- if (disabled) {
185
- contentRenderFn(parentPush);
186
- teleportContent = `<!--teleport start anchor--><!--teleport anchor-->`;
187
- } else {
188
- const { getBuffer, push } = createBuffer();
189
- push(`<!--teleport start anchor-->`);
190
- contentRenderFn(push);
191
- push(`<!--teleport anchor-->`);
192
- teleportContent = getBuffer();
193
- }
194
- targetBuffer.splice(bufferIndex, 0, teleportContent);
195
- parentPush("<!--teleport end-->");
196
- }
197
-
114
+ parentPush("<!--teleport start-->");
115
+ const context = parentComponent.appContext.provides[ssrContextKey];
116
+ const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
117
+ const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
118
+ const bufferIndex = targetBuffer.length;
119
+ let teleportContent;
120
+ if (disabled) {
121
+ contentRenderFn(parentPush);
122
+ teleportContent = `<!--teleport start anchor--><!--teleport anchor-->`;
123
+ } else {
124
+ const { getBuffer, push } = createBuffer();
125
+ push(`<!--teleport start anchor-->`);
126
+ contentRenderFn(push);
127
+ push(`<!--teleport anchor-->`);
128
+ teleportContent = getBuffer();
129
+ }
130
+ targetBuffer.splice(bufferIndex, 0, teleportContent);
131
+ parentPush("<!--teleport end-->");
132
+ }
133
+ //#endregion
134
+ //#region packages/server-renderer/src/helpers/ssrInterpolate.ts
198
135
  function ssrInterpolate(value) {
199
- return escapeHtml(toDisplayString(value));
136
+ return escapeHtml(toDisplayString(value));
200
137
  }
201
-
138
+ //#endregion
139
+ //#region packages/reactivity/src/system.ts
202
140
  let activeSub = void 0;
203
141
  function setActiveSub(sub) {
204
- try {
205
- return activeSub;
206
- } finally {
207
- activeSub = sub;
208
- }
209
- }
210
-
142
+ try {
143
+ return activeSub;
144
+ } finally {
145
+ activeSub = sub;
146
+ }
147
+ }
148
+ Symbol(!!(process.env.NODE_ENV !== "production") ? "Object iterate" : "");
149
+ Symbol(!!(process.env.NODE_ENV !== "production") ? "Map keys iterate" : "");
150
+ Symbol(!!(process.env.NODE_ENV !== "production") ? "Array iterate" : "");
151
+ //#endregion
152
+ //#region packages/reactivity/src/reactive.ts
153
+ /**
154
+ * Checks if an object is a proxy created by {@link reactive},
155
+ * {@link readonly}, {@link shallowReactive} or {@link shallowReadonly}.
156
+ *
157
+ * @param value - The value to check.
158
+ * @see {@link https://vuejs.org/api/reactivity-utilities.html#isproxy}
159
+ */
160
+ /* @__NO_SIDE_EFFECTS__ */
211
161
  function isProxy(value) {
212
- return value ? !!value["__v_raw"] : false;
162
+ return value ? !!value["__v_raw"] : false;
213
163
  }
164
+ /**
165
+ * Returns the raw, original object of a Vue-created proxy.
166
+ *
167
+ * `toRaw()` can return the original object from proxies created by
168
+ * {@link reactive}, {@link readonly}, {@link shallowReactive} or
169
+ * {@link shallowReadonly}.
170
+ *
171
+ * This is an escape hatch that can be used to temporarily read without
172
+ * incurring proxy access / tracking overhead or write without triggering
173
+ * changes. It is **not** recommended to hold a persistent reference to the
174
+ * original object. Use with caution.
175
+ *
176
+ * @example
177
+ * ```js
178
+ * const foo = {}
179
+ * const reactiveFoo = reactive(foo)
180
+ *
181
+ * console.log(toRaw(reactiveFoo) === foo) // true
182
+ * ```
183
+ *
184
+ * @param observed - The object for which the "raw" value is requested.
185
+ * @see {@link https://vuejs.org/api/reactivity-advanced.html#toraw}
186
+ */
187
+ /* @__NO_SIDE_EFFECTS__ */
214
188
  function toRaw(observed) {
215
- const raw = observed && observed["__v_raw"];
216
- return raw ? toRaw(raw) : observed;
189
+ const raw = observed && observed["__v_raw"];
190
+ return raw ? /* @__PURE__ */ toRaw(raw) : observed;
217
191
  }
218
-
192
+ //#endregion
193
+ //#region packages/reactivity/src/ref.ts
194
+ /* @__NO_SIDE_EFFECTS__ */
219
195
  function isRef(r) {
220
- return r ? r["__v_isRef"] === true : false;
196
+ return r ? r["__v_isRef"] === true : false;
221
197
  }
222
-
198
+ //#endregion
199
+ //#region packages/runtime-core/src/warning.ts
223
200
  const stack = [];
201
+ /**
202
+ * @internal
203
+ */
224
204
  function pushWarningContext$1(ctx) {
225
- stack.push(ctx);
205
+ stack.push(ctx);
226
206
  }
207
+ /**
208
+ * @internal
209
+ */
227
210
  function popWarningContext$1() {
228
- stack.pop();
211
+ stack.pop();
229
212
  }
230
213
  let isWarning = false;
231
- function warn$1(msg, ...args) {
232
- if (isWarning) return;
233
- isWarning = true;
234
- const prevSub = setActiveSub();
235
- const entry = stack.length ? stack[stack.length - 1] : null;
236
- const instance = isVNode$2(entry) ? entry.component : entry;
237
- const appWarnHandler = instance && instance.appContext.config.warnHandler;
238
- const trace = getComponentTrace();
239
- if (appWarnHandler) {
240
- callWithErrorHandling(
241
- appWarnHandler,
242
- instance,
243
- 11,
244
- [
245
- // eslint-disable-next-line no-restricted-syntax
246
- msg + args.map((a) => {
247
- var _a, _b;
248
- return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
249
- }).join(""),
250
- instance && instance.proxy || instance,
251
- trace.map(
252
- ({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`
253
- ).join("\n"),
254
- trace
255
- ]
256
- );
257
- } else {
258
- const warnArgs = [`[Vue warn]: ${msg}`, ...args];
259
- if (trace.length && // avoid spamming console during tests
260
- true) {
261
- warnArgs.push(`
262
- `, ...formatTrace(trace));
263
- }
264
- console.warn(...warnArgs);
265
- }
266
- setActiveSub(prevSub);
267
- isWarning = false;
214
+ function warn$2(msg, ...args) {
215
+ if (isWarning) return;
216
+ isWarning = true;
217
+ const prevSub = setActiveSub();
218
+ const entry = stack.length ? stack[stack.length - 1] : null;
219
+ const instance = isVNode$2(entry) ? entry.component : entry;
220
+ const appWarnHandler = instance && instance.appContext.config.warnHandler;
221
+ const trace = getComponentTrace();
222
+ if (appWarnHandler) callWithErrorHandling(appWarnHandler, instance, 11, [
223
+ msg + args.map((a) => {
224
+ const toString = a.toString;
225
+ return toString == null ? JSON.stringify(a) : toString.call(a);
226
+ }).join(""),
227
+ instance && instance.proxy || instance,
228
+ trace.map(({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`).join("\n"),
229
+ trace
230
+ ]);
231
+ else {
232
+ const warnArgs = [`[Vue warn]: ${msg}`, ...args];
233
+ if (trace.length && true)
234
+ /* v8 ignore next 2 */
235
+ warnArgs.push(`\n`, ...formatTrace(trace));
236
+ console.warn(...warnArgs);
237
+ }
238
+ setActiveSub(prevSub);
239
+ isWarning = false;
268
240
  }
269
241
  function getComponentTrace() {
270
- let currentCtx = stack[stack.length - 1];
271
- if (!currentCtx) {
272
- return [];
273
- }
274
- const normalizedStack = [];
275
- while (currentCtx) {
276
- const last = normalizedStack[0];
277
- if (last && last.ctx === currentCtx) {
278
- last.recurseCount++;
279
- } else {
280
- normalizedStack.push({
281
- ctx: currentCtx,
282
- recurseCount: 0
283
- });
284
- }
285
- if (isVNode$2(currentCtx)) {
286
- const parent = currentCtx.component && currentCtx.component.parent;
287
- currentCtx = parent && parent.vnode || parent;
288
- } else {
289
- currentCtx = currentCtx.parent;
290
- }
291
- }
292
- return normalizedStack;
293
- }
242
+ let currentCtx = stack[stack.length - 1];
243
+ if (!currentCtx) return [];
244
+ const normalizedStack = [];
245
+ while (currentCtx) {
246
+ const last = normalizedStack[0];
247
+ if (last && last.ctx === currentCtx) last.recurseCount++;
248
+ else normalizedStack.push({
249
+ ctx: currentCtx,
250
+ recurseCount: 0
251
+ });
252
+ if (isVNode$2(currentCtx)) {
253
+ const parent = currentCtx.component && currentCtx.component.parent;
254
+ currentCtx = parent && parent.vnode || parent;
255
+ } else currentCtx = currentCtx.parent;
256
+ }
257
+ return normalizedStack;
258
+ }
259
+ /* v8 ignore start */
294
260
  function formatTrace(trace) {
295
- const logs = [];
296
- trace.forEach((entry, i) => {
297
- logs.push(...i === 0 ? [] : [`
298
- `], ...formatTraceEntry(entry));
299
- });
300
- return logs;
261
+ const logs = [];
262
+ trace.forEach((entry, i) => {
263
+ logs.push(...i === 0 ? [] : [`\n`], ...formatTraceEntry(entry));
264
+ });
265
+ return logs;
301
266
  }
302
267
  function formatTraceEntry({ ctx, recurseCount }) {
303
- const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
304
- const instance = isVNode$2(ctx) ? ctx.component : ctx;
305
- const isRoot = instance ? instance.parent == null : false;
306
- const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`;
307
- const close = `>` + postfix;
308
- return ctx.props ? [open, ...formatProps(ctx.props), close] : [open + close];
268
+ const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
269
+ const instance = isVNode$2(ctx) ? ctx.component : ctx;
270
+ const isRoot = instance ? instance.parent == null : false;
271
+ const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`;
272
+ const close = `>` + postfix;
273
+ return ctx.props ? [
274
+ open,
275
+ ...formatProps(ctx.props),
276
+ close
277
+ ] : [open + close];
309
278
  }
310
279
  function formatProps(props) {
311
- const res = [];
312
- const keys = Object.keys(props);
313
- keys.slice(0, 3).forEach((key) => {
314
- res.push(...formatProp(key, props[key]));
315
- });
316
- if (keys.length > 3) {
317
- res.push(` ...`);
318
- }
319
- return res;
280
+ const res = [];
281
+ const keys = Object.keys(props);
282
+ keys.slice(0, 3).forEach((key) => {
283
+ res.push(...formatProp(key, props[key]));
284
+ });
285
+ if (keys.length > 3) res.push(` ...`);
286
+ return res;
320
287
  }
321
288
  function formatProp(key, value, raw) {
322
- if (isString(value)) {
323
- value = JSON.stringify(value);
324
- return raw ? value : [`${key}=${value}`];
325
- } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
326
- return raw ? value : [`${key}=${value}`];
327
- } else if (isRef(value)) {
328
- value = formatProp(key, toRaw(value.value), true);
329
- return raw ? value : [`${key}=Ref<`, value, `>`];
330
- } else if (isFunction(value)) {
331
- return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
332
- } else {
333
- value = toRaw(value);
334
- return raw ? value : [`${key}=`, value];
335
- }
336
- }
337
-
289
+ if (isString(value)) {
290
+ value = JSON.stringify(value);
291
+ return raw ? value : [`${key}=${value}`];
292
+ } else if (typeof value === "number" || typeof value === "boolean" || value == null) return raw ? value : [`${key}=${value}`];
293
+ else if (/* @__PURE__ */ isRef(value)) {
294
+ value = formatProp(key, /* @__PURE__ */ toRaw(value.value), true);
295
+ return raw ? value : [
296
+ `${key}=Ref<`,
297
+ value,
298
+ `>`
299
+ ];
300
+ } else if (isFunction(value)) return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
301
+ else {
302
+ value = /* @__PURE__ */ toRaw(value);
303
+ return raw ? value : [`${key}=`, value];
304
+ }
305
+ }
306
+ /* v8 ignore stop */
307
+ //#endregion
308
+ //#region packages/runtime-core/src/errorHandling.ts
338
309
  const ErrorTypeStrings = {
339
- ["sp"]: "serverPrefetch hook",
340
- ["bc"]: "beforeCreate hook",
341
- ["c"]: "created hook",
342
- ["bm"]: "beforeMount hook",
343
- ["m"]: "mounted hook",
344
- ["bu"]: "beforeUpdate hook",
345
- ["u"]: "updated",
346
- ["bum"]: "beforeUnmount hook",
347
- ["um"]: "unmounted hook",
348
- ["a"]: "activated hook",
349
- ["da"]: "deactivated hook",
350
- ["ec"]: "errorCaptured hook",
351
- ["rtc"]: "renderTracked hook",
352
- ["rtg"]: "renderTriggered hook",
353
- [0]: "setup function",
354
- [1]: "render function",
355
- [2]: "watcher getter",
356
- [3]: "watcher callback",
357
- [4]: "watcher cleanup function",
358
- [5]: "native event handler",
359
- [6]: "component event handler",
360
- [7]: "vnode hook",
361
- [8]: "directive hook",
362
- [9]: "transition hook",
363
- [10]: "app errorHandler",
364
- [11]: "app warnHandler",
365
- [12]: "ref function",
366
- [13]: "async component loader",
367
- [14]: "scheduler flush",
368
- [15]: "component update",
369
- [16]: "app unmount cleanup function"
310
+ ["sp"]: "serverPrefetch hook",
311
+ ["bc"]: "beforeCreate hook",
312
+ ["c"]: "created hook",
313
+ ["bm"]: "beforeMount hook",
314
+ ["m"]: "mounted hook",
315
+ ["bu"]: "beforeUpdate hook",
316
+ ["u"]: "updated",
317
+ ["bum"]: "beforeUnmount hook",
318
+ ["um"]: "unmounted hook",
319
+ ["a"]: "activated hook",
320
+ ["da"]: "deactivated hook",
321
+ ["ec"]: "errorCaptured hook",
322
+ ["rtc"]: "renderTracked hook",
323
+ ["rtg"]: "renderTriggered hook",
324
+ [0]: "setup function",
325
+ [1]: "render function",
326
+ [2]: "watcher getter",
327
+ [3]: "watcher callback",
328
+ [4]: "watcher cleanup function",
329
+ [5]: "native event handler",
330
+ [6]: "component event handler",
331
+ [7]: "vnode hook",
332
+ [8]: "directive hook",
333
+ [9]: "transition hook",
334
+ [10]: "app errorHandler",
335
+ [11]: "app warnHandler",
336
+ [12]: "ref function",
337
+ [13]: "async component loader",
338
+ [14]: "scheduler flush",
339
+ [15]: "component update",
340
+ [16]: "app unmount cleanup function"
370
341
  };
371
342
  function callWithErrorHandling(fn, instance, type, args) {
372
- try {
373
- return args ? fn(...args) : fn();
374
- } catch (err) {
375
- handleError(err, instance, type);
376
- }
343
+ try {
344
+ return args ? fn(...args) : fn();
345
+ } catch (err) {
346
+ handleError(err, instance, type);
347
+ }
377
348
  }
378
349
  function handleError(err, instance, type, throwInDev = true) {
379
- const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ;
380
- if (instance) {
381
- let cur = instance.parent;
382
- const exposedInstance = instance.proxy || instance;
383
- const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : `https://vuejs.org/error-reference/#runtime-${type}`;
384
- while (cur) {
385
- const errorCapturedHooks = cur.ec;
386
- if (errorCapturedHooks) {
387
- for (let i = 0; i < errorCapturedHooks.length; i++) {
388
- if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
389
- return;
390
- }
391
- }
392
- }
393
- cur = cur.parent;
394
- }
395
- if (errorHandler) {
396
- const prevSub = setActiveSub();
397
- callWithErrorHandling(errorHandler, null, 10, [
398
- err,
399
- exposedInstance,
400
- errorInfo
401
- ]);
402
- setActiveSub(prevSub);
403
- return;
404
- }
405
- }
406
- logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction);
350
+ const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ;
351
+ if (instance) {
352
+ let cur = instance.parent;
353
+ const exposedInstance = instance.proxy || instance;
354
+ const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : `https://vuejs.org/error-reference/#runtime-${type}`;
355
+ while (cur) {
356
+ const errorCapturedHooks = cur.ec;
357
+ if (errorCapturedHooks) {
358
+ for (let i = 0; i < errorCapturedHooks.length; i++) if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) return;
359
+ }
360
+ cur = cur.parent;
361
+ }
362
+ if (errorHandler) {
363
+ const prevSub = setActiveSub();
364
+ callWithErrorHandling(errorHandler, null, 10, [
365
+ err,
366
+ exposedInstance,
367
+ errorInfo
368
+ ]);
369
+ setActiveSub(prevSub);
370
+ return;
371
+ }
372
+ }
373
+ logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction);
407
374
  }
408
375
  function logError(err, type, instance, throwInDev = true, throwInProd = false) {
409
- if (!!(process.env.NODE_ENV !== "production")) {
410
- const info = ErrorTypeStrings[type];
411
- if (instance) {
412
- pushWarningContext$1(instance);
413
- }
414
- warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
415
- if (instance) {
416
- popWarningContext$1();
417
- }
418
- if (throwInDev) {
419
- throw err;
420
- } else {
421
- console.error(err);
422
- }
423
- } else if (throwInProd) {
424
- throw err;
425
- } else {
426
- console.error(err);
427
- }
428
- }
429
-
376
+ if (!!(process.env.NODE_ENV !== "production")) {
377
+ const info = ErrorTypeStrings[type];
378
+ if (instance) pushWarningContext$1(instance);
379
+ warn$2(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
380
+ if (instance) popWarningContext$1();
381
+ if (throwInDev) throw err;
382
+ else console.error(err);
383
+ } else if (throwInProd) throw err;
384
+ else console.error(err);
385
+ }
386
+ //#endregion
387
+ //#region packages/runtime-core/src/scheduler.ts
430
388
  const jobs = [];
431
389
  let postJobs = [];
432
390
  let activePostJobs = null;
@@ -437,1261 +395,949 @@ let postFlushIndex = 0;
437
395
  const resolvedPromise = /* @__PURE__ */ Promise.resolve();
438
396
  const RECURSION_LIMIT = 100;
439
397
  function nextTick(fn) {
440
- const p = currentFlushPromise || resolvedPromise;
441
- return fn ? p.then(this ? fn.bind(this) : fn) : p;
398
+ const p = currentFlushPromise || resolvedPromise;
399
+ return fn ? p.then(this ? fn.bind(this) : fn) : p;
442
400
  }
443
401
  function findInsertionIndex(order, queue, start, end) {
444
- while (start < end) {
445
- const middle = start + end >>> 1;
446
- if (queue[middle].order <= order) {
447
- start = middle + 1;
448
- } else {
449
- end = middle;
450
- }
451
- }
452
- return start;
402
+ while (start < end) {
403
+ const middle = start + end >>> 1;
404
+ if (queue[middle].order <= order) start = middle + 1;
405
+ else end = middle;
406
+ }
407
+ return start;
453
408
  }
409
+ /**
410
+ * @internal for runtime-vapor only
411
+ */
454
412
  function queueJob(job, id, isPre = false) {
455
- if (queueJobWorker(
456
- job,
457
- isPre ? -2 : Infinity ,
458
- jobs,
459
- jobsLength,
460
- flushIndex
461
- )) {
462
- jobsLength++;
463
- queueFlush();
464
- }
465
- }
466
- function queueJobWorker(job, order, queue, length, flushIndex2) {
467
- const flags = job.flags;
468
- if (!(flags & 1)) {
469
- job.flags = flags | 1;
470
- job.order = order;
471
- if (flushIndex2 === length || // fast path when the job id is larger than the tail
472
- order >= queue[length - 1].order) {
473
- queue[length] = job;
474
- } else {
475
- queue.splice(findInsertionIndex(order, queue, flushIndex2, length), 0, job);
476
- }
477
- return true;
478
- }
479
- return false;
413
+ if (queueJobWorker(job, id === void 0 ? isPre ? -2 : Infinity : isPre ? id * 2 : id * 2 + 1, jobs, jobsLength, flushIndex)) {
414
+ jobsLength++;
415
+ queueFlush();
416
+ }
417
+ }
418
+ function queueJobWorker(job, order, queue, length, flushIndex) {
419
+ const flags = job.flags;
420
+ if (!(flags & 1)) {
421
+ job.flags = flags | 1;
422
+ job.order = order;
423
+ if (flushIndex === length || order >= queue[length - 1].order) queue[length] = job;
424
+ else queue.splice(findInsertionIndex(order, queue, flushIndex, length), 0, job);
425
+ return true;
426
+ }
427
+ return false;
480
428
  }
481
429
  const doFlushJobs = () => {
482
- try {
483
- flushJobs();
484
- } catch (e) {
485
- currentFlushPromise = null;
486
- throw e;
487
- }
430
+ try {
431
+ flushJobs();
432
+ } catch (e) {
433
+ currentFlushPromise = null;
434
+ throw e;
435
+ }
488
436
  };
489
437
  function queueFlush() {
490
- if (!currentFlushPromise) {
491
- currentFlushPromise = resolvedPromise.then(doFlushJobs);
492
- }
493
- }
494
- function queuePostFlushCb(jobs2, id = Infinity) {
495
- if (!isArray(jobs2)) {
496
- if (activePostJobs && id === -1) {
497
- activePostJobs.splice(postFlushIndex, 0, jobs2);
498
- } else {
499
- queueJobWorker(jobs2, id, postJobs, postJobs.length, 0);
500
- }
501
- } else {
502
- for (const job of jobs2) {
503
- queueJobWorker(job, id, postJobs, postJobs.length, 0);
504
- }
505
- }
506
- queueFlush();
438
+ if (!currentFlushPromise) currentFlushPromise = resolvedPromise.then(doFlushJobs);
439
+ }
440
+ function queuePostFlushCb(jobs, id = Infinity) {
441
+ if (!isArray(jobs)) if (activePostJobs && id === -1) activePostJobs.splice(postFlushIndex, 0, jobs);
442
+ else queueJobWorker(jobs, id, postJobs, postJobs.length, 0);
443
+ else for (const job of jobs) queueJobWorker(job, id, postJobs, postJobs.length, 0);
444
+ queueFlush();
507
445
  }
508
446
  function flushPostFlushCbs(seen) {
509
- if (postJobs.length) {
510
- if (activePostJobs) {
511
- activePostJobs.push(...postJobs);
512
- postJobs.length = 0;
513
- return;
514
- }
515
- activePostJobs = postJobs;
516
- postJobs = [];
517
- if (!!(process.env.NODE_ENV !== "production")) {
518
- seen = seen || /* @__PURE__ */ new Map();
519
- }
520
- while (postFlushIndex < activePostJobs.length) {
521
- const cb = activePostJobs[postFlushIndex++];
522
- if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) {
523
- continue;
524
- }
525
- if (cb.flags & 2) {
526
- cb.flags &= -2;
527
- }
528
- if (!(cb.flags & 4)) {
529
- try {
530
- cb();
531
- } finally {
532
- cb.flags &= -2;
533
- }
534
- }
535
- }
536
- activePostJobs = null;
537
- postFlushIndex = 0;
538
- }
447
+ if (postJobs.length) {
448
+ if (activePostJobs) {
449
+ activePostJobs.push(...postJobs);
450
+ postJobs.length = 0;
451
+ return;
452
+ }
453
+ activePostJobs = postJobs;
454
+ postJobs = [];
455
+ if (!!(process.env.NODE_ENV !== "production")) seen = seen || /* @__PURE__ */ new Map();
456
+ while (postFlushIndex < activePostJobs.length) {
457
+ const cb = activePostJobs[postFlushIndex++];
458
+ if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, cb)) continue;
459
+ if (cb.flags & 2) cb.flags &= -2;
460
+ if (!(cb.flags & 4)) try {
461
+ cb();
462
+ } finally {
463
+ cb.flags &= -2;
464
+ }
465
+ }
466
+ activePostJobs = null;
467
+ postFlushIndex = 0;
468
+ }
539
469
  }
540
470
  function flushJobs(seen) {
541
- if (!!(process.env.NODE_ENV !== "production")) {
542
- seen || (seen = /* @__PURE__ */ new Map());
543
- }
544
- try {
545
- while (flushIndex < jobsLength) {
546
- const job = jobs[flushIndex];
547
- jobs[flushIndex++] = void 0;
548
- if (!(job.flags & 4)) {
549
- if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, job)) {
550
- continue;
551
- }
552
- if (job.flags & 2) {
553
- job.flags &= ~1;
554
- }
555
- try {
556
- job();
557
- } catch (err) {
558
- handleError(
559
- err,
560
- job.i,
561
- job.i ? 15 : 14
562
- );
563
- } finally {
564
- if (!(job.flags & 2)) {
565
- job.flags &= ~1;
566
- }
567
- }
568
- }
569
- }
570
- } finally {
571
- while (flushIndex < jobsLength) {
572
- jobs[flushIndex].flags &= -2;
573
- jobs[flushIndex++] = void 0;
574
- }
575
- flushIndex = 0;
576
- jobsLength = 0;
577
- flushPostFlushCbs(seen);
578
- currentFlushPromise = null;
579
- if (jobsLength || postJobs.length) {
580
- flushJobs(seen);
581
- }
582
- }
471
+ if (!!(process.env.NODE_ENV !== "production")) seen || (seen = /* @__PURE__ */ new Map());
472
+ try {
473
+ while (flushIndex < jobsLength) {
474
+ const job = jobs[flushIndex];
475
+ jobs[flushIndex++] = void 0;
476
+ if (!(job.flags & 4)) {
477
+ if (!!(process.env.NODE_ENV !== "production") && checkRecursiveUpdates(seen, job)) continue;
478
+ if (job.flags & 2) job.flags &= -2;
479
+ try {
480
+ job();
481
+ } catch (err) {
482
+ handleError(err, job.i, job.i ? 15 : 14);
483
+ } finally {
484
+ if (!(job.flags & 2)) job.flags &= -2;
485
+ }
486
+ }
487
+ }
488
+ } finally {
489
+ while (flushIndex < jobsLength) {
490
+ jobs[flushIndex].flags &= -2;
491
+ jobs[flushIndex++] = void 0;
492
+ }
493
+ flushIndex = 0;
494
+ jobsLength = 0;
495
+ flushPostFlushCbs(seen);
496
+ currentFlushPromise = null;
497
+ if (jobsLength || postJobs.length) flushJobs(seen);
498
+ }
583
499
  }
584
500
  function checkRecursiveUpdates(seen, fn) {
585
- const count = seen.get(fn) || 0;
586
- if (count > RECURSION_LIMIT) {
587
- const instance = fn.i;
588
- const componentName = instance && getComponentName(instance.type);
589
- handleError(
590
- `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
591
- null,
592
- 10
593
- );
594
- return true;
595
- }
596
- seen.set(fn, count + 1);
597
- return false;
598
- }
599
-
501
+ const count = seen.get(fn) || 0;
502
+ if (count > RECURSION_LIMIT) {
503
+ const instance = fn.i;
504
+ const componentName = instance && getComponentName(instance.type);
505
+ handleError(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`, null, 10);
506
+ return true;
507
+ }
508
+ seen.set(fn, count + 1);
509
+ return false;
510
+ }
511
+ //#endregion
512
+ //#region packages/runtime-core/src/hmr.ts
600
513
  let isHmrUpdating = false;
601
514
  const hmrDirtyComponents = /* @__PURE__ */ new Map();
602
515
  const hmrDirtyComponentsMode = /* @__PURE__ */ new Map();
603
- if (!!(process.env.NODE_ENV !== "production")) {
604
- getGlobalThis().__VUE_HMR_RUNTIME__ = {
605
- createRecord: tryWrap(createRecord),
606
- rerender: tryWrap(rerender),
607
- reload: tryWrap(reload)
608
- };
609
- }
516
+ if (!!(process.env.NODE_ENV !== "production")) getGlobalThis().__VUE_HMR_RUNTIME__ = {
517
+ createRecord: tryWrap(createRecord),
518
+ rerender: tryWrap(rerender),
519
+ reload: tryWrap(reload)
520
+ };
610
521
  const map = /* @__PURE__ */ new Map();
611
522
  function createRecord(id, initialDef) {
612
- if (map.has(id)) {
613
- return false;
614
- }
615
- map.set(id, {
616
- initialDef: normalizeClassComponent(initialDef),
617
- instances: /* @__PURE__ */ new Set()
618
- });
619
- return true;
523
+ if (map.has(id)) return false;
524
+ map.set(id, {
525
+ initialDef: normalizeClassComponent(initialDef),
526
+ instances: /* @__PURE__ */ new Set()
527
+ });
528
+ return true;
620
529
  }
621
530
  function normalizeClassComponent(component) {
622
- return isClassComponent(component) ? component.__vccOpts : component;
531
+ return isClassComponent(component) ? component.__vccOpts : component;
623
532
  }
624
533
  function rerender(id, newRender) {
625
- const record = map.get(id);
626
- if (!record) {
627
- return;
628
- }
629
- record.initialDef.render = newRender;
630
- [...record.instances].forEach((instance) => {
631
- if (newRender) {
632
- instance.render = newRender;
633
- normalizeClassComponent(instance.type).render = newRender;
634
- }
635
- isHmrUpdating = true;
636
- if (instance.vapor) {
637
- if (!instance.isUnmounted) instance.hmrRerender();
638
- } else {
639
- const i = instance;
640
- if (!(i.effect.flags & 1024)) {
641
- i.renderCache = [];
642
- i.effect.run();
643
- }
644
- }
645
- nextTick(() => {
646
- isHmrUpdating = false;
647
- });
648
- });
534
+ const record = map.get(id);
535
+ if (!record) return;
536
+ record.initialDef.render = newRender;
537
+ [...record.instances].forEach((instance) => {
538
+ if (newRender) {
539
+ instance.render = newRender;
540
+ normalizeClassComponent(instance.type).render = newRender;
541
+ }
542
+ isHmrUpdating = true;
543
+ if (instance.vapor) {
544
+ if (!instance.isUnmounted) instance.hmrRerender();
545
+ } else {
546
+ const i = instance;
547
+ if (!(i.effect.flags & 1024)) {
548
+ i.renderCache = [];
549
+ i.effect.run();
550
+ }
551
+ }
552
+ nextTick(() => {
553
+ isHmrUpdating = false;
554
+ });
555
+ });
649
556
  }
650
557
  function reload(id, newComp) {
651
- const record = map.get(id);
652
- if (!record) return;
653
- newComp = normalizeClassComponent(newComp);
654
- const isVapor = record.initialDef.__vapor;
655
- updateComponentDef(record.initialDef, newComp);
656
- const instances = [...record.instances];
657
- if (isVapor && newComp.__vapor && !instances.some((i) => i.ceReload)) {
658
- for (const instance of instances) {
659
- if (instance.root && instance.root.ce && instance !== instance.root) {
660
- instance.root.ce._removeChildStyle(instance.type);
661
- }
662
- }
663
- for (const instance of instances) {
664
- instance.hmrReload(newComp);
665
- }
666
- } else {
667
- for (const instance of instances) {
668
- const oldComp = normalizeClassComponent(instance.type);
669
- let dirtyInstances = hmrDirtyComponents.get(oldComp);
670
- if (!dirtyInstances) {
671
- if (oldComp !== record.initialDef) {
672
- updateComponentDef(oldComp, newComp);
673
- }
674
- hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
675
- }
676
- dirtyInstances.add(instance);
677
- hmrDirtyComponentsMode.set(oldComp, !!isVapor);
678
- instance.appContext.propsCache.delete(instance.type);
679
- instance.appContext.emitsCache.delete(instance.type);
680
- instance.appContext.optionsCache.delete(instance.type);
681
- if (instance.ceReload) {
682
- dirtyInstances.add(instance);
683
- instance.ceReload(newComp.styles);
684
- dirtyInstances.delete(instance);
685
- } else if (instance.parent) {
686
- queueJob(() => {
687
- isHmrUpdating = true;
688
- const parent = instance.parent;
689
- if (parent.vapor) {
690
- parent.hmrRerender();
691
- } else {
692
- if (!(parent.effect.flags & 1024)) {
693
- parent.renderCache = [];
694
- parent.effect.run();
695
- }
696
- }
697
- nextTick(() => {
698
- isHmrUpdating = false;
699
- });
700
- dirtyInstances.delete(instance);
701
- });
702
- } else if (instance.appContext.reload) {
703
- instance.appContext.reload();
704
- } else if (typeof window !== "undefined") {
705
- window.location.reload();
706
- } else {
707
- console.warn(
708
- "[HMR] Root or manually mounted instance modified. Full reload required."
709
- );
710
- }
711
- if (instance.root.ce && instance !== instance.root) {
712
- instance.root.ce._removeChildStyle(oldComp);
713
- }
714
- }
715
- }
716
- queuePostFlushCb(() => {
717
- hmrDirtyComponents.clear();
718
- hmrDirtyComponentsMode.clear();
719
- });
558
+ const record = map.get(id);
559
+ if (!record) return;
560
+ newComp = normalizeClassComponent(newComp);
561
+ const isVapor = record.initialDef.__vapor;
562
+ updateComponentDef(record.initialDef, newComp);
563
+ const instances = [...record.instances];
564
+ if (isVapor && newComp.__vapor && !instances.some((i) => i.ceReload)) {
565
+ for (const instance of instances) if (instance.root && instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(instance.type);
566
+ for (const instance of instances) instance.hmrReload(newComp);
567
+ } else for (const instance of instances) {
568
+ const oldComp = normalizeClassComponent(instance.type);
569
+ let dirtyInstances = hmrDirtyComponents.get(oldComp);
570
+ if (!dirtyInstances) {
571
+ if (oldComp !== record.initialDef) updateComponentDef(oldComp, newComp);
572
+ hmrDirtyComponents.set(oldComp, dirtyInstances = /* @__PURE__ */ new Set());
573
+ }
574
+ dirtyInstances.add(instance);
575
+ hmrDirtyComponentsMode.set(oldComp, !!isVapor);
576
+ instance.appContext.propsCache.delete(instance.type);
577
+ instance.appContext.emitsCache.delete(instance.type);
578
+ instance.appContext.optionsCache.delete(instance.type);
579
+ if (instance.ceReload) {
580
+ dirtyInstances.add(instance);
581
+ instance.ceReload(newComp.styles);
582
+ dirtyInstances.delete(instance);
583
+ } else if (instance.parent) queueJob(() => {
584
+ isHmrUpdating = true;
585
+ const parent = instance.parent;
586
+ if (parent.vapor) parent.hmrRerender();
587
+ else if (!(parent.effect.flags & 1024)) {
588
+ parent.renderCache = [];
589
+ parent.effect.run();
590
+ }
591
+ nextTick(() => {
592
+ isHmrUpdating = false;
593
+ });
594
+ dirtyInstances.delete(instance);
595
+ });
596
+ else if (instance.appContext.reload) instance.appContext.reload();
597
+ else if (typeof window !== "undefined") window.location.reload();
598
+ else console.warn("[HMR] Root or manually mounted instance modified. Full reload required.");
599
+ if (instance.root.ce && instance !== instance.root) instance.root.ce._removeChildStyle(oldComp);
600
+ }
601
+ queuePostFlushCb(() => {
602
+ hmrDirtyComponents.clear();
603
+ hmrDirtyComponentsMode.clear();
604
+ });
720
605
  }
721
606
  function updateComponentDef(oldComp, newComp) {
722
- extend(oldComp, newComp);
723
- for (const key in oldComp) {
724
- if (key !== "__file" && !(key in newComp)) {
725
- delete oldComp[key];
726
- }
727
- }
607
+ extend(oldComp, newComp);
608
+ for (const key in oldComp) if (key !== "__file" && !(key in newComp)) delete oldComp[key];
728
609
  }
729
610
  function tryWrap(fn) {
730
- return (id, arg) => {
731
- try {
732
- return fn(id, arg);
733
- } catch (e) {
734
- console.error(e);
735
- console.warn(
736
- `[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
737
- );
738
- }
739
- };
740
- }
741
-
742
- let devtools;
611
+ return (id, arg) => {
612
+ try {
613
+ return fn(id, arg);
614
+ } catch (e) {
615
+ console.error(e);
616
+ console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required.");
617
+ }
618
+ };
619
+ }
620
+ //#endregion
621
+ //#region packages/runtime-core/src/devtools.ts
622
+ let devtools$1;
743
623
  let buffer = [];
744
- function setDevtoolsHook(hook, target) {
745
- var _a, _b;
746
- devtools = hook;
747
- if (devtools) {
748
- devtools.enabled = true;
749
- buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
750
- buffer = [];
751
- } else if (
752
- // handle late devtools injection - only do this if we are in an actual
753
- // browser environment to avoid the timer handle stalling test runner exit
754
- // (#4815)
755
- typeof window !== "undefined" && // some envs mock window but not fully
756
- window.HTMLElement && // also exclude jsdom
757
- // eslint-disable-next-line no-restricted-syntax
758
- !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
759
- ) {
760
- const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
761
- replay.push((newHook) => {
762
- setDevtoolsHook(newHook, target);
763
- });
764
- setTimeout(() => {
765
- if (!devtools) {
766
- target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
767
- buffer = [];
768
- }
769
- }, 3e3);
770
- } else {
771
- buffer = [];
772
- }
773
- }
774
-
624
+ function setDevtoolsHook$1(hook, target) {
625
+ var _window$navigator;
626
+ devtools$1 = hook;
627
+ if (devtools$1) {
628
+ devtools$1.enabled = true;
629
+ buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
630
+ buffer = [];
631
+ } else if (typeof window !== "undefined" && window.HTMLElement && !((_window$navigator = window.navigator) === null || _window$navigator === void 0 || (_window$navigator = _window$navigator.userAgent) === null || _window$navigator === void 0 ? void 0 : _window$navigator.includes("jsdom"))) {
632
+ (target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []).push((newHook) => {
633
+ setDevtoolsHook$1(newHook, target);
634
+ });
635
+ setTimeout(() => {
636
+ if (!devtools$1) {
637
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
638
+ buffer = [];
639
+ }
640
+ }, 3e3);
641
+ } else buffer = [];
642
+ }
643
+ //#endregion
644
+ //#region packages/runtime-core/src/componentRenderContext.ts
645
+ /**
646
+ * mark the current rendering instance for asset resolution (e.g.
647
+ * resolveComponent, resolveDirective) during render
648
+ */
775
649
  let currentRenderingInstance = null;
776
650
  let currentScopeId = null;
777
-
651
+ //#endregion
652
+ //#region packages/runtime-core/src/components/Teleport.ts
778
653
  const isTeleport = (type) => type.__isTeleport;
779
-
654
+ //#endregion
655
+ //#region packages/runtime-core/src/components/BaseTransition.ts
780
656
  function setTransitionHooks(vnode, hooks) {
781
- if (vnode.shapeFlag & 6 && vnode.component) {
782
- if (isVaporComponent(vnode.type)) {
783
- getVaporInterface(vnode.component, vnode).setTransitionHooks(
784
- vnode.component,
785
- hooks
786
- );
787
- } else {
788
- vnode.transition = hooks;
789
- setTransitionHooks(vnode.component.subTree, hooks);
790
- }
791
- } else if (vnode.shapeFlag & 128) {
792
- vnode.ssContent.transition = hooks.clone(vnode.ssContent);
793
- vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
794
- } else {
795
- vnode.transition = hooks;
796
- }
797
- }
798
-
799
- const NULL_DYNAMIC_COMPONENT = /* @__PURE__ */ Symbol.for("v-ndc");
800
-
657
+ if (vnode.shapeFlag & 6 && vnode.component) if (isVaporComponent(vnode.type)) getVaporInterface(vnode.component, vnode).setTransitionHooks(vnode.component, hooks);
658
+ else {
659
+ vnode.transition = hooks;
660
+ setTransitionHooks(vnode.component.subTree, hooks);
661
+ }
662
+ else if (vnode.shapeFlag & 128) {
663
+ vnode.ssContent.transition = hooks.clone(vnode.ssContent);
664
+ vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
665
+ } else vnode.transition = hooks;
666
+ }
667
+ //#endregion
668
+ //#region packages/runtime-core/src/helpers/resolveAssets.ts
669
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
670
+ //#endregion
671
+ //#region packages/runtime-core/src/internalObject.ts
672
+ /**
673
+ * Used during vnode props/slots normalization to check if the vnode props/slots
674
+ * are the internal attrs / slots object of a component via
675
+ * `Object.getPrototypeOf`. This is more performant than defining a
676
+ * non-enumerable property. (one of the optimizations done for ssr-benchmark)
677
+ */
801
678
  const internalObjectProto = {};
802
679
  const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
803
-
680
+ //#endregion
681
+ //#region packages/runtime-core/src/renderer.ts
804
682
  function getVaporInterface(instance, vnode) {
805
- const ctx = instance ? instance.appContext : vnode.appContext;
806
- const res = ctx && ctx.vapor;
807
- if (!!(process.env.NODE_ENV !== "production") && !res) {
808
- warn$1(
809
- `Vapor component found in vdom tree but vapor-in-vdom interop was not installed. Make sure to install it:
810
- \`\`\`
811
- import { vaporInteropPlugin } from 'vue'
812
- app.use(vaporInteropPlugin)
813
- \`\`\``
814
- );
815
- }
816
- return res;
683
+ const ctx = instance ? instance.appContext : vnode.appContext;
684
+ const res = ctx && ctx.vapor;
685
+ if (!!(process.env.NODE_ENV !== "production") && !res) warn$2("Vapor component found in vdom tree but vapor-in-vdom interop was not installed. Make sure to install it:\n```\nimport { vaporInteropPlugin } from 'vue'\napp.use(vaporInteropPlugin)\n```");
686
+ return res;
817
687
  }
818
688
  function isVaporComponent(type) {
819
- if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating && hmrDirtyComponentsMode.has(type)) {
820
- return hmrDirtyComponentsMode.get(type);
821
- }
822
- return type.__vapor;
689
+ if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating && hmrDirtyComponentsMode.has(type)) return hmrDirtyComponentsMode.get(type);
690
+ return type.__vapor;
823
691
  }
824
-
692
+ //#endregion
693
+ //#region packages/runtime-core/src/components/Suspense.ts
825
694
  const isSuspense = (type) => type.__isSuspense;
826
-
827
- const Fragment = /* @__PURE__ */ Symbol.for("v-fgt");
828
- const Text = /* @__PURE__ */ Symbol.for("v-txt");
829
- const Comment = /* @__PURE__ */ Symbol.for("v-cmt");
695
+ //#endregion
696
+ //#region packages/runtime-core/src/vnode.ts
697
+ const Fragment$1 = Symbol.for("v-fgt");
698
+ const Text$1 = Symbol.for("v-txt");
699
+ const Comment$1 = Symbol.for("v-cmt");
830
700
  function isVNode$2(value) {
831
- return value ? value.__v_isVNode === true : false;
701
+ return value ? value.__v_isVNode === true : false;
832
702
  }
833
703
  const createVNodeWithArgsTransform = (...args) => {
834
- return _createVNode(
835
- ...args
836
- );
704
+ return _createVNode(...args);
837
705
  };
838
706
  const normalizeKey = ({ key }) => key != null ? key : null;
839
707
  const normalizeRef = ({ ref, ref_key, ref_for }, i = currentRenderingInstance) => {
840
- if (typeof ref === "number") {
841
- ref = "" + ref;
842
- }
843
- return ref != null ? isString(ref) || isRef(ref) || isFunction(ref) ? { i, r: ref, k: ref_key, f: !!ref_for } : ref : null;
708
+ if (typeof ref === "number") ref = "" + ref;
709
+ return ref != null ? isString(ref) || /* @__PURE__ */ isRef(ref) || isFunction(ref) ? {
710
+ i,
711
+ r: ref,
712
+ k: ref_key,
713
+ f: !!ref_for
714
+ } : ref : null;
844
715
  };
845
- function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
846
- const vnode = {
847
- __v_isVNode: true,
848
- __v_skip: true,
849
- type,
850
- props,
851
- key: props && normalizeKey(props),
852
- ref: props && normalizeRef(props),
853
- scopeId: currentScopeId,
854
- slotScopeIds: null,
855
- children,
856
- component: null,
857
- suspense: null,
858
- ssContent: null,
859
- ssFallback: null,
860
- dirs: null,
861
- transition: null,
862
- el: null,
863
- anchor: null,
864
- target: null,
865
- targetStart: null,
866
- targetAnchor: null,
867
- staticCount: 0,
868
- shapeFlag,
869
- patchFlag,
870
- dynamicProps,
871
- dynamicChildren: null,
872
- appContext: null,
873
- ctx: currentRenderingInstance
874
- };
875
- if (needFullChildrenNormalization) {
876
- normalizeChildren(vnode, children);
877
- if (shapeFlag & 128) {
878
- type.normalize(vnode);
879
- }
880
- } else if (children) {
881
- vnode.shapeFlag |= isString(children) ? 8 : 16;
882
- }
883
- if (!!(process.env.NODE_ENV !== "production") && vnode.key !== vnode.key) {
884
- warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
885
- }
886
- return vnode;
887
- }
888
- const createVNode = !!(process.env.NODE_ENV !== "production") ? createVNodeWithArgsTransform : _createVNode;
716
+ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment$1 ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
717
+ const vnode = {
718
+ __v_isVNode: true,
719
+ __v_skip: true,
720
+ type,
721
+ props,
722
+ key: props && normalizeKey(props),
723
+ ref: props && normalizeRef(props),
724
+ scopeId: currentScopeId,
725
+ slotScopeIds: null,
726
+ children,
727
+ component: null,
728
+ suspense: null,
729
+ ssContent: null,
730
+ ssFallback: null,
731
+ dirs: null,
732
+ transition: null,
733
+ el: null,
734
+ anchor: null,
735
+ target: null,
736
+ targetStart: null,
737
+ targetAnchor: null,
738
+ staticCount: 0,
739
+ shapeFlag,
740
+ patchFlag,
741
+ dynamicProps,
742
+ dynamicChildren: null,
743
+ appContext: null,
744
+ ctx: currentRenderingInstance
745
+ };
746
+ if (needFullChildrenNormalization) {
747
+ normalizeChildren(vnode, children);
748
+ if (shapeFlag & 128) type.normalize(vnode);
749
+ } else if (children) vnode.shapeFlag |= isString(children) ? 8 : 16;
750
+ if (!!(process.env.NODE_ENV !== "production") && vnode.key !== vnode.key) warn$2(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
751
+ return vnode;
752
+ }
753
+ const createVNode$1 = !!(process.env.NODE_ENV !== "production") ? createVNodeWithArgsTransform : _createVNode;
889
754
  function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
890
- if (!type || type === NULL_DYNAMIC_COMPONENT) {
891
- if (!!(process.env.NODE_ENV !== "production") && !type) {
892
- warn$1(`Invalid vnode type when creating vnode: ${type}.`);
893
- }
894
- type = Comment;
895
- }
896
- if (isVNode$2(type)) {
897
- const cloned = cloneVNode(
898
- type,
899
- props,
900
- true
901
- /* mergeRef: true */
902
- );
903
- if (children) {
904
- normalizeChildren(cloned, children);
905
- }
906
- cloned.patchFlag = -2;
907
- return cloned;
908
- }
909
- if (isClassComponent(type)) {
910
- type = type.__vccOpts;
911
- }
912
- if (props) {
913
- props = guardReactiveProps(props);
914
- let { class: klass, style } = props;
915
- if (klass && !isString(klass)) {
916
- props.class = normalizeClass(klass);
917
- }
918
- if (isObject(style)) {
919
- if (isProxy(style) && !isArray(style)) {
920
- style = extend({}, style);
921
- }
922
- props.style = normalizeStyle(style);
923
- }
924
- }
925
- const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
926
- if (!!(process.env.NODE_ENV !== "production") && shapeFlag & 4 && isProxy(type)) {
927
- type = toRaw(type);
928
- warn$1(
929
- `Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
930
- `
931
- Component that was made reactive: `,
932
- type
933
- );
934
- }
935
- return createBaseVNode(
936
- type,
937
- props,
938
- children,
939
- patchFlag,
940
- dynamicProps,
941
- shapeFlag,
942
- isBlockNode,
943
- true
944
- );
755
+ if (!type || type === NULL_DYNAMIC_COMPONENT) {
756
+ if (!!(process.env.NODE_ENV !== "production") && !type) warn$2(`Invalid vnode type when creating vnode: ${type}.`);
757
+ type = Comment$1;
758
+ }
759
+ if (isVNode$2(type)) {
760
+ const cloned = cloneVNode(type, props, true);
761
+ if (children) normalizeChildren(cloned, children);
762
+ cloned.patchFlag = -2;
763
+ return cloned;
764
+ }
765
+ if (isClassComponent(type)) type = type.__vccOpts;
766
+ if (props) {
767
+ props = guardReactiveProps(props);
768
+ let { class: klass, style } = props;
769
+ if (klass && !isString(klass)) props.class = normalizeClass(klass);
770
+ if (isObject(style)) {
771
+ if (/* @__PURE__ */ isProxy(style) && !isArray(style)) style = extend({}, style);
772
+ props.style = normalizeStyle(style);
773
+ }
774
+ }
775
+ const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction(type) ? 2 : 0;
776
+ if (!!(process.env.NODE_ENV !== "production") && shapeFlag & 4 && /* @__PURE__ */ isProxy(type)) {
777
+ type = /* @__PURE__ */ toRaw(type);
778
+ warn$2("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", `\nComponent that was made reactive: `, type);
779
+ }
780
+ return createBaseVNode(type, props, children, patchFlag, dynamicProps, shapeFlag, isBlockNode, true);
945
781
  }
946
782
  function guardReactiveProps(props) {
947
- if (!props) return null;
948
- return isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
783
+ if (!props) return null;
784
+ return /* @__PURE__ */ isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
949
785
  }
950
786
  function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
951
- const { props, ref, patchFlag, children, transition } = vnode;
952
- const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
953
- const cloned = {
954
- __v_isVNode: true,
955
- __v_skip: true,
956
- type: vnode.type,
957
- props: mergedProps,
958
- key: mergedProps && normalizeKey(mergedProps),
959
- ref: extraProps && extraProps.ref ? (
960
- // #2078 in the case of <component :is="vnode" ref="extra"/>
961
- // if the vnode itself already has a ref, cloneVNode will need to merge
962
- // the refs so the single vnode can be set on multiple refs
963
- mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps)
964
- ) : ref,
965
- scopeId: vnode.scopeId,
966
- slotScopeIds: vnode.slotScopeIds,
967
- children: !!(process.env.NODE_ENV !== "production") && patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
968
- target: vnode.target,
969
- targetStart: vnode.targetStart,
970
- targetAnchor: vnode.targetAnchor,
971
- staticCount: vnode.staticCount,
972
- shapeFlag: vnode.shapeFlag,
973
- // if the vnode is cloned with extra props, we can no longer assume its
974
- // existing patch flag to be reliable and need to add the FULL_PROPS flag.
975
- // note: preserve flag for fragments since they use the flag for children
976
- // fast paths only.
977
- patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
978
- dynamicProps: vnode.dynamicProps,
979
- dynamicChildren: vnode.dynamicChildren,
980
- appContext: vnode.appContext,
981
- dirs: vnode.dirs,
982
- transition,
983
- // These should technically only be non-null on mounted VNodes. However,
984
- // they *should* be copied for kept-alive vnodes. So we just always copy
985
- // them since them being non-null during a mount doesn't affect the logic as
986
- // they will simply be overwritten.
987
- component: vnode.component,
988
- suspense: vnode.suspense,
989
- ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
990
- ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
991
- placeholder: vnode.placeholder,
992
- el: vnode.el,
993
- anchor: vnode.anchor,
994
- ctx: vnode.ctx,
995
- ce: vnode.ce
996
- };
997
- if (transition && cloneTransition) {
998
- setTransitionHooks(
999
- cloned,
1000
- transition.clone(cloned)
1001
- );
1002
- }
1003
- return cloned;
787
+ const { props, ref, patchFlag, children, transition } = vnode;
788
+ const mergedProps = extraProps ? mergeProps$1(props || {}, extraProps) : props;
789
+ const cloned = {
790
+ __v_isVNode: true,
791
+ __v_skip: true,
792
+ type: vnode.type,
793
+ props: mergedProps,
794
+ key: mergedProps && normalizeKey(mergedProps),
795
+ ref: extraProps && extraProps.ref ? mergeRef && ref ? isArray(ref) ? ref.concat(normalizeRef(extraProps)) : [ref, normalizeRef(extraProps)] : normalizeRef(extraProps) : ref,
796
+ scopeId: vnode.scopeId,
797
+ slotScopeIds: vnode.slotScopeIds,
798
+ children: !!(process.env.NODE_ENV !== "production") && patchFlag === -1 && isArray(children) ? children.map(deepCloneVNode) : children,
799
+ target: vnode.target,
800
+ targetStart: vnode.targetStart,
801
+ targetAnchor: vnode.targetAnchor,
802
+ staticCount: vnode.staticCount,
803
+ shapeFlag: vnode.shapeFlag,
804
+ patchFlag: extraProps && vnode.type !== Fragment$1 ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
805
+ dynamicProps: vnode.dynamicProps,
806
+ dynamicChildren: vnode.dynamicChildren,
807
+ appContext: vnode.appContext,
808
+ dirs: vnode.dirs,
809
+ transition,
810
+ component: vnode.component,
811
+ suspense: vnode.suspense,
812
+ ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
813
+ ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
814
+ placeholder: vnode.placeholder,
815
+ el: vnode.el,
816
+ anchor: vnode.anchor,
817
+ ctx: vnode.ctx,
818
+ ce: vnode.ce
819
+ };
820
+ if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
821
+ return cloned;
1004
822
  }
823
+ /**
824
+ * Dev only, for HMR of hoisted vnodes reused in v-for
825
+ * https://github.com/vitejs/vite/issues/2022
826
+ */
1005
827
  function deepCloneVNode(vnode) {
1006
- const cloned = cloneVNode(vnode);
1007
- if (isArray(vnode.children)) {
1008
- cloned.children = vnode.children.map(deepCloneVNode);
1009
- }
1010
- return cloned;
828
+ const cloned = cloneVNode(vnode);
829
+ if (isArray(vnode.children)) cloned.children = vnode.children.map(deepCloneVNode);
830
+ return cloned;
1011
831
  }
832
+ /**
833
+ * @private
834
+ */
1012
835
  function createTextVNode(text = " ", flag = 0) {
1013
- return createVNode(Text, null, text, flag);
836
+ return createVNode$1(Text$1, null, text, flag);
1014
837
  }
1015
838
  function normalizeChildren(vnode, children) {
1016
- let type = 0;
1017
- const { shapeFlag } = vnode;
1018
- if (children == null) {
1019
- children = null;
1020
- } else if (isArray(children)) {
1021
- type = 16;
1022
- } else if (typeof children === "object") {
1023
- if (shapeFlag & (1 | 64)) {
1024
- const slot = children.default;
1025
- if (slot) {
1026
- slot._c && (slot._d = false);
1027
- normalizeChildren(vnode, slot());
1028
- slot._c && (slot._d = true);
1029
- }
1030
- return;
1031
- } else {
1032
- type = 32;
1033
- const slotFlag = children._;
1034
- if (!slotFlag && !isInternalObject(children)) {
1035
- children._ctx = currentRenderingInstance;
1036
- }
1037
- }
1038
- } else if (isFunction(children)) {
1039
- children = { default: children, _ctx: currentRenderingInstance };
1040
- type = 32;
1041
- } else {
1042
- children = String(children);
1043
- if (shapeFlag & 64) {
1044
- type = 16;
1045
- children = [createTextVNode(children)];
1046
- } else {
1047
- type = 8;
1048
- }
1049
- }
1050
- vnode.children = children;
1051
- vnode.shapeFlag |= type;
1052
- }
1053
- function mergeProps(...args) {
1054
- const ret = {};
1055
- for (let i = 0; i < args.length; i++) {
1056
- const toMerge = args[i];
1057
- for (const key in toMerge) {
1058
- if (key === "class") {
1059
- if (ret.class !== toMerge.class) {
1060
- ret.class = normalizeClass([ret.class, toMerge.class]);
1061
- }
1062
- } else if (key === "style") {
1063
- ret.style = normalizeStyle([ret.style, toMerge.style]);
1064
- } else if (isOn(key)) {
1065
- const existing = ret[key];
1066
- const incoming = toMerge[key];
1067
- if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) {
1068
- ret[key] = existing ? [].concat(existing, incoming) : incoming;
1069
- }
1070
- } else if (key !== "") {
1071
- ret[key] = toMerge[key];
1072
- }
1073
- }
1074
- }
1075
- return ret;
1076
- }
1077
-
1078
- !!(process.env.NODE_ENV !== "production") ? {
1079
- } : {
1080
- };
839
+ let type = 0;
840
+ const { shapeFlag } = vnode;
841
+ if (children == null) children = null;
842
+ else if (isArray(children)) type = 16;
843
+ else if (typeof children === "object") if (shapeFlag & 65) {
844
+ const slot = children.default;
845
+ if (slot) {
846
+ slot._c && (slot._d = false);
847
+ normalizeChildren(vnode, slot());
848
+ slot._c && (slot._d = true);
849
+ }
850
+ return;
851
+ } else {
852
+ type = 32;
853
+ if (!children._ && !isInternalObject(children)) children._ctx = currentRenderingInstance;
854
+ }
855
+ else if (isFunction(children)) {
856
+ children = {
857
+ default: children,
858
+ _ctx: currentRenderingInstance
859
+ };
860
+ type = 32;
861
+ } else {
862
+ children = String(children);
863
+ if (shapeFlag & 64) {
864
+ type = 16;
865
+ children = [createTextVNode(children)];
866
+ } else type = 8;
867
+ }
868
+ vnode.children = children;
869
+ vnode.shapeFlag |= type;
870
+ }
871
+ function mergeProps$1(...args) {
872
+ const ret = {};
873
+ for (let i = 0; i < args.length; i++) {
874
+ const toMerge = args[i];
875
+ for (const key in toMerge) if (key === "class") {
876
+ if (ret.class !== toMerge.class) ret.class = normalizeClass([ret.class, toMerge.class]);
877
+ } else if (key === "style") ret.style = normalizeStyle([ret.style, toMerge.style]);
878
+ else if (isOn(key)) {
879
+ const existing = ret[key];
880
+ const incoming = toMerge[key];
881
+ if (incoming && existing !== incoming && !(isArray(existing) && existing.includes(incoming))) ret[key] = existing ? [].concat(existing, incoming) : incoming;
882
+ else if (incoming == null && existing == null && !isModelListener(key)) ret[key] = incoming;
883
+ } else if (key !== "") ret[key] = toMerge[key];
884
+ }
885
+ return ret;
886
+ }
887
+ process.env.NODE_ENV;
1081
888
  const classifyRE = /(?:^|[-_])\w/g;
1082
889
  const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
1083
890
  function getComponentName(Component, includeInferred = true) {
1084
- return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
891
+ return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
1085
892
  }
1086
893
  function formatComponentName(instance, Component, isRoot = false) {
1087
- let name = getComponentName(Component);
1088
- if (!name && Component.__file) {
1089
- const match = Component.__file.match(/([^/\\]+)\.\w+$/);
1090
- if (match) {
1091
- name = match[1];
1092
- }
1093
- }
1094
- if (!name && instance) {
1095
- const inferFromRegistry = (registry) => {
1096
- for (const key in registry) {
1097
- if (registry[key] === Component) {
1098
- return key;
1099
- }
1100
- }
1101
- };
1102
- name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(
1103
- instance.parent.type.components
1104
- ) || inferFromRegistry(instance.appContext.components);
1105
- }
1106
- return name ? classify(name) : isRoot ? `App` : `Anonymous`;
894
+ let name = getComponentName(Component);
895
+ if (!name && Component.__file) {
896
+ const match = Component.__file.match(/([^/\\]+)\.\w+$/);
897
+ if (match) name = match[1];
898
+ }
899
+ if (!name && instance) {
900
+ const inferFromRegistry = (registry) => {
901
+ for (const key in registry) if (registry[key] === Component) return key;
902
+ };
903
+ name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
904
+ }
905
+ return name ? classify(name) : isRoot ? `App` : `Anonymous`;
1107
906
  }
1108
907
  function isClassComponent(value) {
1109
- return isFunction(value) && "__vccOpts" in value;
1110
- }
1111
-
1112
- const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
1113
- !!(process.env.NODE_ENV !== "production") || true ? devtools : void 0;
1114
- !!(process.env.NODE_ENV !== "production") || true ? setDevtoolsHook : NOOP;
1115
-
908
+ return isFunction(value) && "__vccOpts" in value;
909
+ }
910
+ //#endregion
911
+ //#region packages/runtime-core/src/index.ts
912
+ const warn$1 = !!(process.env.NODE_ENV !== "production") ? warn$2 : NOOP;
913
+ process.env.NODE_ENV;
914
+ process.env.NODE_ENV;
915
+ //#endregion
916
+ //#region packages/server-renderer/src/helpers/ssrRenderList.ts
1116
917
  function ssrRenderList(source, renderItem) {
1117
- if (isArray(source) || isString(source)) {
1118
- for (let i = 0, l = source.length; i < l; i++) {
1119
- renderItem(source[i], i);
1120
- }
1121
- } else if (typeof source === "number") {
1122
- if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
1123
- warn(`The v-for range expect an integer value but got ${source}.`);
1124
- return;
1125
- }
1126
- for (let i = 0; i < source; i++) {
1127
- renderItem(i + 1, i);
1128
- }
1129
- } else if (isObject(source)) {
1130
- if (source[Symbol.iterator]) {
1131
- const arr = Array.from(source);
1132
- for (let i = 0, l = arr.length; i < l; i++) {
1133
- renderItem(arr[i], i);
1134
- }
1135
- } else {
1136
- const keys = Object.keys(source);
1137
- for (let i = 0, l = keys.length; i < l; i++) {
1138
- const key = keys[i];
1139
- renderItem(source[key], key, i);
1140
- }
1141
- }
1142
- }
1143
- }
1144
-
918
+ if (isArray(source) || isString(source)) for (let i = 0, l = source.length; i < l; i++) renderItem(source[i], i);
919
+ else if (typeof source === "number") {
920
+ if (!!(process.env.NODE_ENV !== "production") && (!Number.isInteger(source) || source < 0)) {
921
+ warn$1(`The v-for range expects a positive integer value but got ${source}.`);
922
+ return;
923
+ }
924
+ for (let i = 0; i < source; i++) renderItem(i + 1, i);
925
+ } else if (isObject(source)) if (source[Symbol.iterator]) {
926
+ const arr = Array.from(source);
927
+ for (let i = 0, l = arr.length; i < l; i++) renderItem(arr[i], i);
928
+ } else {
929
+ const keys = Object.keys(source);
930
+ for (let i = 0, l = keys.length; i < l; i++) {
931
+ const key = keys[i];
932
+ renderItem(source[key], key, i);
933
+ }
934
+ }
935
+ }
936
+ //#endregion
937
+ //#region packages/server-renderer/src/helpers/ssrRenderSuspense.ts
1145
938
  async function ssrRenderSuspense(push, { default: renderContent }) {
1146
- if (renderContent) {
1147
- renderContent();
1148
- } else {
1149
- push(`<!---->`);
1150
- }
939
+ if (renderContent) renderContent();
940
+ else push(`<!---->`);
1151
941
  }
1152
-
942
+ //#endregion
943
+ //#region packages/server-renderer/src/helpers/ssrGetDirectiveProps.ts
1153
944
  function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
1154
- if (typeof dir !== "function" && dir.getSSRProps) {
1155
- return dir.getSSRProps(
1156
- {
1157
- dir,
1158
- instance: ssrUtils.getComponentPublicInstance(instance.$),
1159
- value,
1160
- oldValue: void 0,
1161
- arg,
1162
- modifiers
1163
- },
1164
- null
1165
- ) || {};
1166
- }
1167
- return {};
1168
- }
1169
-
945
+ if (typeof dir !== "function" && dir.getSSRProps) return dir.getSSRProps({
946
+ dir,
947
+ instance: ssrUtils.getComponentPublicInstance(instance.$),
948
+ value,
949
+ oldValue: void 0,
950
+ arg,
951
+ modifiers
952
+ }, null) || {};
953
+ return {};
954
+ }
955
+ //#endregion
956
+ //#region packages/server-renderer/src/helpers/ssrVModelHelpers.ts
1170
957
  const ssrLooseEqual = looseEqual;
1171
958
  function ssrLooseContain(arr, value) {
1172
- return looseIndexOf(arr, value) > -1;
959
+ return looseIndexOf(arr, value) > -1;
1173
960
  }
1174
961
  function ssrRenderDynamicModel(type, model, value) {
1175
- switch (type) {
1176
- case "radio":
1177
- return looseEqual(model, value) ? " checked" : "";
1178
- case "checkbox":
1179
- return (isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
1180
- default:
1181
- return ssrRenderAttr("value", model);
1182
- }
962
+ switch (type) {
963
+ case "radio": return looseEqual(model, value) ? " checked" : "";
964
+ case "checkbox": return (isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
965
+ default: return ssrRenderAttr("value", model);
966
+ }
1183
967
  }
1184
968
  function ssrGetDynamicModelProps(existingProps = {}, model) {
1185
- const { type, value } = existingProps;
1186
- switch (type) {
1187
- case "radio":
1188
- return looseEqual(model, value) ? { checked: true } : null;
1189
- case "checkbox":
1190
- return (isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
1191
- default:
1192
- return { value: model };
1193
- }
1194
- }
1195
-
969
+ const { type, value } = existingProps;
970
+ switch (type) {
971
+ case "radio": return looseEqual(model, value) ? { checked: true } : null;
972
+ case "checkbox": return (isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
973
+ default: return { value: model };
974
+ }
975
+ }
976
+ //#endregion
977
+ //#region packages/server-renderer/src/helpers/ssrCompile.ts
1196
978
  function ssrCompile(template, instance) {
1197
- {
1198
- throw new Error(
1199
- `On-the-fly template compilation is not supported in the ESM build of @vue/server-renderer. All templates must be pre-compiled into render functions.`
1200
- );
1201
- }
1202
- }
1203
-
1204
- const {
1205
- createComponentInstance,
1206
- setCurrentRenderingInstance,
1207
- setupComponent,
1208
- renderComponentRoot,
1209
- normalizeVNode,
1210
- pushWarningContext,
1211
- popWarningContext
1212
- } = ssrUtils;
979
+ throw new Error("On-the-fly template compilation is not supported in the ESM build of @vue/server-renderer. All templates must be pre-compiled into render functions.");
980
+ }
981
+ //#endregion
982
+ //#region packages/server-renderer/src/render.ts
983
+ const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = ssrUtils;
984
+ function cleanupContext(context) {
985
+ let firstError;
986
+ if (context.__watcherHandles) {
987
+ for (const unwatch of context.__watcherHandles) try {
988
+ unwatch();
989
+ } catch (err) {
990
+ if (firstError === void 0) firstError = err;
991
+ }
992
+ context.__watcherHandles.length = 0;
993
+ }
994
+ if (context.__instanceScopes) {
995
+ for (const scope of context.__instanceScopes) try {
996
+ scope.stop();
997
+ } catch (err) {
998
+ if (firstError === void 0) firstError = err;
999
+ }
1000
+ context.__instanceScopes.length = 0;
1001
+ }
1002
+ if (firstError !== void 0) throw firstError;
1003
+ }
1213
1004
  function createBuffer() {
1214
- let appendable = false;
1215
- const buffer = [];
1216
- return {
1217
- getBuffer() {
1218
- return buffer;
1219
- },
1220
- push(item) {
1221
- const isStringItem = isString(item);
1222
- if (appendable && isStringItem) {
1223
- buffer[buffer.length - 1] += item;
1224
- return;
1225
- }
1226
- buffer.push(item);
1227
- appendable = isStringItem;
1228
- if (isPromise(item) || isArray(item) && item.hasAsync) {
1229
- buffer.hasAsync = true;
1230
- }
1231
- }
1232
- };
1005
+ let appendable = false;
1006
+ const buffer = [];
1007
+ return {
1008
+ getBuffer() {
1009
+ return buffer;
1010
+ },
1011
+ push(item) {
1012
+ const isStringItem = isString(item);
1013
+ if (appendable && isStringItem) {
1014
+ buffer[buffer.length - 1] += item;
1015
+ return;
1016
+ }
1017
+ buffer.push(item);
1018
+ appendable = isStringItem;
1019
+ if (isPromise(item) || isArray(item) && item.hasAsync) buffer.hasAsync = true;
1020
+ }
1021
+ };
1233
1022
  }
1234
1023
  function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
1235
- const instance = vnode.component = createComponentInstance(
1236
- vnode,
1237
- parentComponent,
1238
- null
1239
- );
1240
- if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(vnode);
1241
- const res = setupComponent(
1242
- instance,
1243
- true
1244
- /* isSSR */
1245
- );
1246
- if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
1247
- const hasAsyncSetup = isPromise(res);
1248
- let prefetches = instance.sp;
1249
- if (hasAsyncSetup || prefetches) {
1250
- const p = Promise.resolve(res).then(() => {
1251
- if (hasAsyncSetup) prefetches = instance.sp;
1252
- if (prefetches) {
1253
- return Promise.all(
1254
- prefetches.map((prefetch) => prefetch.call(instance.proxy))
1255
- );
1256
- }
1257
- }).catch(NOOP);
1258
- return p.then(() => renderComponentSubTree(instance, slotScopeId));
1259
- } else {
1260
- return renderComponentSubTree(instance, slotScopeId);
1261
- }
1024
+ const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
1025
+ const context = instance.appContext.provides[ssrContextKey];
1026
+ if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
1027
+ if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(vnode);
1028
+ const res = setupComponent(instance, true);
1029
+ if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
1030
+ const hasAsyncSetup = isPromise(res);
1031
+ let prefetches = instance.sp;
1032
+ if (hasAsyncSetup || prefetches) return Promise.resolve(res).then(() => {
1033
+ if (hasAsyncSetup) prefetches = instance.sp;
1034
+ if (prefetches) return Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)));
1035
+ }).catch(NOOP).then(() => renderComponentSubTree(instance, slotScopeId));
1036
+ else return renderComponentSubTree(instance, slotScopeId);
1262
1037
  }
1263
1038
  function renderComponentSubTree(instance, slotScopeId) {
1264
- if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(instance.vnode);
1265
- const comp = instance.type;
1266
- const { getBuffer, push } = createBuffer();
1267
- if (isFunction(comp)) {
1268
- let root = renderComponentRoot(instance);
1269
- if (!comp.props) {
1270
- for (const key in instance.attrs) {
1271
- if (key.startsWith(`data-v-`)) {
1272
- (root.props || (root.props = {}))[key] = ``;
1273
- }
1274
- }
1275
- }
1276
- renderVNode(push, instance.subTree = root, instance, slotScopeId);
1277
- } else {
1278
- if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) {
1279
- comp.ssrRender = ssrCompile(comp.template);
1280
- }
1281
- const ssrRender = instance.ssrRender || comp.ssrRender;
1282
- if (ssrRender) {
1283
- let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
1284
- let hasCloned = false;
1285
- let cur = instance;
1286
- while (true) {
1287
- const scopeId = cur.vnode.scopeId;
1288
- if (scopeId) {
1289
- if (!hasCloned) {
1290
- attrs = { ...attrs };
1291
- hasCloned = true;
1292
- }
1293
- attrs[scopeId] = "";
1294
- }
1295
- const parent = cur.parent;
1296
- if (parent && parent.subTree && parent.subTree === cur.vnode) {
1297
- cur = parent;
1298
- } else {
1299
- break;
1300
- }
1301
- }
1302
- if (slotScopeId) {
1303
- if (!hasCloned) attrs = { ...attrs };
1304
- const slotScopeIdList = slotScopeId.trim().split(" ");
1305
- for (let i = 0; i < slotScopeIdList.length; i++) {
1306
- attrs[slotScopeIdList[i]] = "";
1307
- }
1308
- }
1309
- const prev = setCurrentRenderingInstance(instance);
1310
- try {
1311
- ssrRender(
1312
- instance.proxy,
1313
- push,
1314
- instance,
1315
- attrs,
1316
- // compiler-optimized bindings
1317
- instance.props,
1318
- instance.setupState,
1319
- instance.data,
1320
- instance.ctx
1321
- );
1322
- } finally {
1323
- setCurrentRenderingInstance(prev);
1324
- }
1325
- } else if (instance.render && instance.render !== NOOP) {
1326
- renderVNode(
1327
- push,
1328
- instance.subTree = renderComponentRoot(instance),
1329
- instance,
1330
- slotScopeId
1331
- );
1332
- } else {
1333
- const componentName = comp.name || comp.__file || `<Anonymous>`;
1334
- warn$2(`Component ${componentName} is missing template or render function.`);
1335
- push(`<!---->`);
1336
- }
1337
- }
1338
- if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
1339
- return getBuffer();
1039
+ if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(instance.vnode);
1040
+ const comp = instance.type;
1041
+ const { getBuffer, push } = createBuffer();
1042
+ if (isFunction(comp)) {
1043
+ let root = renderComponentRoot(instance);
1044
+ if (!comp.props) {
1045
+ for (const key in instance.attrs) if (key.startsWith(`data-v-`)) (root.props || (root.props = {}))[key] = ``;
1046
+ }
1047
+ renderVNode(push, instance.subTree = root, instance, slotScopeId);
1048
+ } else {
1049
+ if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) comp.ssrRender = ssrCompile(comp.template, instance);
1050
+ const ssrRender = instance.ssrRender || comp.ssrRender;
1051
+ if (ssrRender) {
1052
+ let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
1053
+ let hasCloned = false;
1054
+ let cur = instance;
1055
+ while (true) {
1056
+ const scopeId = cur.vnode.scopeId;
1057
+ if (scopeId) {
1058
+ if (!hasCloned) {
1059
+ attrs = { ...attrs };
1060
+ hasCloned = true;
1061
+ }
1062
+ attrs[scopeId] = "";
1063
+ }
1064
+ const parent = cur.parent;
1065
+ if (parent && parent.subTree && parent.subTree === cur.vnode) cur = parent;
1066
+ else break;
1067
+ }
1068
+ if (slotScopeId) {
1069
+ if (!hasCloned) attrs = { ...attrs };
1070
+ const slotScopeIdList = slotScopeId.trim().split(" ");
1071
+ for (let i = 0; i < slotScopeIdList.length; i++) attrs[slotScopeIdList[i]] = "";
1072
+ }
1073
+ const prev = setCurrentRenderingInstance(instance);
1074
+ try {
1075
+ ssrRender(instance.proxy, push, instance, attrs, instance.props, instance.setupState, instance.data, instance.ctx);
1076
+ } finally {
1077
+ setCurrentRenderingInstance(prev);
1078
+ }
1079
+ } else if (instance.render && instance.render !== NOOP) renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
1080
+ else {
1081
+ warn(`Component ${comp.name || comp.__file || `<Anonymous>`} is missing template or render function.`);
1082
+ push(`<!---->`);
1083
+ }
1084
+ }
1085
+ if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
1086
+ return getBuffer();
1340
1087
  }
1341
1088
  function renderVNode(push, vnode, parentComponent, slotScopeId) {
1342
- const { type, shapeFlag, children, dirs, props } = vnode;
1343
- if (dirs) {
1344
- vnode.props = applySSRDirectives(vnode, props, dirs);
1345
- }
1346
- switch (type) {
1347
- case Text$1:
1348
- push(escapeHtml(children));
1349
- break;
1350
- case Comment$1:
1351
- push(
1352
- children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`
1353
- );
1354
- break;
1355
- case Static:
1356
- push(children);
1357
- break;
1358
- case Fragment$1:
1359
- if (vnode.slotScopeIds) {
1360
- slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
1361
- }
1362
- push(`<!--[-->`);
1363
- renderVNodeChildren(
1364
- push,
1365
- children,
1366
- parentComponent,
1367
- slotScopeId
1368
- );
1369
- push(`<!--]-->`);
1370
- break;
1371
- default:
1372
- if (shapeFlag & 1) {
1373
- renderElementVNode(push, vnode, parentComponent, slotScopeId);
1374
- } else if (shapeFlag & 6) {
1375
- push(renderComponentVNode(vnode, parentComponent, slotScopeId));
1376
- } else if (shapeFlag & 64) {
1377
- renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
1378
- } else if (shapeFlag & 128) {
1379
- renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
1380
- } else {
1381
- warn$2(
1382
- "[@vue/server-renderer] Invalid VNode type:",
1383
- type,
1384
- `(${typeof type})`
1385
- );
1386
- }
1387
- }
1089
+ const { type, shapeFlag, children, dirs, props } = vnode;
1090
+ if (dirs) vnode.props = applySSRDirectives(vnode, props, dirs);
1091
+ switch (type) {
1092
+ case Text:
1093
+ push(escapeHtml(children));
1094
+ break;
1095
+ case Comment:
1096
+ push(children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`);
1097
+ break;
1098
+ case Static:
1099
+ push(children);
1100
+ break;
1101
+ case Fragment:
1102
+ if (vnode.slotScopeIds) slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
1103
+ push(`<!--[-->`);
1104
+ renderVNodeChildren(push, children, parentComponent, slotScopeId);
1105
+ push(`<!--]-->`);
1106
+ break;
1107
+ default: if (shapeFlag & 1) renderElementVNode(push, vnode, parentComponent, slotScopeId);
1108
+ else if (shapeFlag & 6) push(renderComponentVNode(vnode, parentComponent, slotScopeId));
1109
+ else if (shapeFlag & 64) renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
1110
+ else if (shapeFlag & 128) renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
1111
+ else warn("[@vue/server-renderer] Invalid VNode type:", type, `(${typeof type})`);
1112
+ }
1388
1113
  }
1389
1114
  function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
1390
- for (let i = 0; i < children.length; i++) {
1391
- renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
1392
- }
1115
+ for (let i = 0; i < children.length; i++) renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
1393
1116
  }
1394
1117
  function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
1395
- const tag = vnode.type;
1396
- let { props, children, shapeFlag, scopeId } = vnode;
1397
- let openTag = `<${tag}`;
1398
- if (props) {
1399
- openTag += ssrRenderAttrs(props, tag);
1400
- }
1401
- if (scopeId) {
1402
- openTag += ` ${scopeId}`;
1403
- }
1404
- let curParent = parentComponent;
1405
- let curVnode = vnode;
1406
- while (curParent && curVnode === curParent.subTree) {
1407
- curVnode = curParent.vnode;
1408
- if (curVnode.scopeId) {
1409
- openTag += ` ${curVnode.scopeId}`;
1410
- }
1411
- curParent = curParent.parent;
1412
- }
1413
- if (slotScopeId) {
1414
- openTag += ` ${slotScopeId}`;
1415
- }
1416
- push(openTag + `>`);
1417
- if (!isVoidTag(tag)) {
1418
- let hasChildrenOverride = false;
1419
- if (props) {
1420
- if (props.innerHTML) {
1421
- hasChildrenOverride = true;
1422
- push(props.innerHTML);
1423
- } else if (props.textContent) {
1424
- hasChildrenOverride = true;
1425
- push(escapeHtml(props.textContent));
1426
- } else if (tag === "textarea" && props.value) {
1427
- hasChildrenOverride = true;
1428
- push(escapeHtml(props.value));
1429
- }
1430
- }
1431
- if (!hasChildrenOverride) {
1432
- if (shapeFlag & 8) {
1433
- push(escapeHtml(children));
1434
- } else if (shapeFlag & 16) {
1435
- renderVNodeChildren(
1436
- push,
1437
- children,
1438
- parentComponent,
1439
- slotScopeId
1440
- );
1441
- }
1442
- }
1443
- push(`</${tag}>`);
1444
- }
1118
+ const tag = vnode.type;
1119
+ let { props, children, shapeFlag, scopeId } = vnode;
1120
+ let openTag = `<${tag}`;
1121
+ if (props) openTag += ssrRenderAttrs(props, tag);
1122
+ if (scopeId) openTag += ` ${scopeId}`;
1123
+ let curParent = parentComponent;
1124
+ let curVnode = vnode;
1125
+ while (curParent && curVnode === curParent.subTree) {
1126
+ curVnode = curParent.vnode;
1127
+ if (curVnode.scopeId) openTag += ` ${curVnode.scopeId}`;
1128
+ curParent = curParent.parent;
1129
+ }
1130
+ if (slotScopeId) openTag += ` ${slotScopeId}`;
1131
+ push(openTag + `>`);
1132
+ if (!isVoidTag(tag)) {
1133
+ let hasChildrenOverride = false;
1134
+ if (props) {
1135
+ if (props.innerHTML) {
1136
+ hasChildrenOverride = true;
1137
+ push(props.innerHTML);
1138
+ } else if (props.textContent) {
1139
+ hasChildrenOverride = true;
1140
+ push(escapeHtml(props.textContent));
1141
+ } else if (tag === "textarea" && props.value) {
1142
+ hasChildrenOverride = true;
1143
+ push(escapeHtml(props.value));
1144
+ }
1145
+ }
1146
+ if (!hasChildrenOverride) {
1147
+ if (shapeFlag & 8) push(escapeHtml(children));
1148
+ else if (shapeFlag & 16) renderVNodeChildren(push, children, parentComponent, slotScopeId);
1149
+ }
1150
+ push(`</${tag}>`);
1151
+ }
1445
1152
  }
1446
1153
  function applySSRDirectives(vnode, rawProps, dirs) {
1447
- const toMerge = [];
1448
- for (let i = 0; i < dirs.length; i++) {
1449
- const binding = dirs[i];
1450
- const {
1451
- dir: { getSSRProps }
1452
- } = binding;
1453
- if (getSSRProps) {
1454
- const props = getSSRProps(binding, vnode);
1455
- if (props) toMerge.push(props);
1456
- }
1457
- }
1458
- return mergeProps$1(rawProps || {}, ...toMerge);
1154
+ const toMerge = [];
1155
+ for (let i = 0; i < dirs.length; i++) {
1156
+ const binding = dirs[i];
1157
+ const { dir: { getSSRProps } } = binding;
1158
+ if (getSSRProps) {
1159
+ const props = getSSRProps(binding, vnode);
1160
+ if (props) toMerge.push(props);
1161
+ }
1162
+ }
1163
+ return mergeProps(rawProps || {}, ...toMerge);
1459
1164
  }
1460
1165
  function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
1461
- const target = vnode.props && vnode.props.to;
1462
- const disabled = vnode.props && vnode.props.disabled;
1463
- if (!target) {
1464
- if (!disabled) {
1465
- warn$2(`[@vue/server-renderer] Teleport is missing target prop.`);
1466
- }
1467
- return [];
1468
- }
1469
- if (!isString(target)) {
1470
- warn$2(
1471
- `[@vue/server-renderer] Teleport target must be a query selector string.`
1472
- );
1473
- return [];
1474
- }
1475
- ssrRenderTeleport(
1476
- push,
1477
- (push2) => {
1478
- renderVNodeChildren(
1479
- push2,
1480
- vnode.children,
1481
- parentComponent,
1482
- slotScopeId
1483
- );
1484
- },
1485
- target,
1486
- disabled || disabled === "",
1487
- parentComponent
1488
- );
1489
- }
1490
-
1166
+ const target = vnode.props && vnode.props.to;
1167
+ const disabled = vnode.props && vnode.props.disabled;
1168
+ if (!target) {
1169
+ if (!disabled) warn(`[@vue/server-renderer] Teleport is missing target prop.`);
1170
+ return [];
1171
+ }
1172
+ if (!isString(target)) {
1173
+ warn(`[@vue/server-renderer] Teleport target must be a query selector string.`);
1174
+ return [];
1175
+ }
1176
+ ssrRenderTeleport(push, (push) => {
1177
+ renderVNodeChildren(push, vnode.children, parentComponent, slotScopeId);
1178
+ }, target, disabled || disabled === "", parentComponent);
1179
+ }
1180
+ //#endregion
1181
+ //#region packages/server-renderer/src/renderToString.ts
1491
1182
  const { isVNode: isVNode$1 } = ssrUtils;
1492
1183
  function nestedUnrollBuffer(buffer, parentRet, startIndex) {
1493
- if (!buffer.hasAsync) {
1494
- return parentRet + unrollBufferSync$1(buffer);
1495
- }
1496
- let ret = parentRet;
1497
- for (let i = startIndex; i < buffer.length; i += 1) {
1498
- const item = buffer[i];
1499
- if (isString(item)) {
1500
- ret += item;
1501
- continue;
1502
- }
1503
- if (isPromise(item)) {
1504
- return item.then((nestedItem) => {
1505
- buffer[i] = nestedItem;
1506
- return nestedUnrollBuffer(buffer, ret, i);
1507
- });
1508
- }
1509
- const result = nestedUnrollBuffer(item, ret, 0);
1510
- if (isPromise(result)) {
1511
- return result.then((nestedItem) => {
1512
- buffer[i] = nestedItem;
1513
- return nestedUnrollBuffer(buffer, "", i);
1514
- });
1515
- }
1516
- ret = result;
1517
- }
1518
- return ret;
1184
+ if (!buffer.hasAsync) return parentRet + unrollBufferSync$1(buffer);
1185
+ let ret = parentRet;
1186
+ for (let i = startIndex; i < buffer.length; i += 1) {
1187
+ const item = buffer[i];
1188
+ if (isString(item)) {
1189
+ ret += item;
1190
+ continue;
1191
+ }
1192
+ if (isPromise(item)) return item.then((nestedItem) => {
1193
+ buffer[i] = nestedItem;
1194
+ return nestedUnrollBuffer(buffer, ret, i);
1195
+ });
1196
+ const result = nestedUnrollBuffer(item, ret, 0);
1197
+ if (isPromise(result)) return result.then((nestedItem) => {
1198
+ buffer[i] = nestedItem;
1199
+ return nestedUnrollBuffer(buffer, "", i);
1200
+ });
1201
+ ret = result;
1202
+ }
1203
+ return ret;
1519
1204
  }
1520
1205
  function unrollBuffer$1(buffer) {
1521
- return nestedUnrollBuffer(buffer, "", 0);
1206
+ return nestedUnrollBuffer(buffer, "", 0);
1522
1207
  }
1523
1208
  function unrollBufferSync$1(buffer) {
1524
- let ret = "";
1525
- for (let i = 0; i < buffer.length; i++) {
1526
- let item = buffer[i];
1527
- if (isString(item)) {
1528
- ret += item;
1529
- } else {
1530
- ret += unrollBufferSync$1(item);
1531
- }
1532
- }
1533
- return ret;
1209
+ let ret = "";
1210
+ for (let i = 0; i < buffer.length; i++) {
1211
+ let item = buffer[i];
1212
+ if (isString(item)) ret += item;
1213
+ else ret += unrollBufferSync$1(item);
1214
+ }
1215
+ return ret;
1534
1216
  }
1535
1217
  async function renderToString(input, context = {}) {
1536
- if (isVNode$1(input)) {
1537
- return renderToString(createApp({ render: () => input }), context);
1538
- }
1539
- const vnode = createVNode$1(input._component, input._props);
1540
- vnode.appContext = input._context;
1541
- input.provide(ssrContextKey, context);
1542
- const buffer = await renderComponentVNode(vnode);
1543
- const result = await unrollBuffer$1(buffer);
1544
- await resolveTeleports(context);
1545
- if (context.__watcherHandles) {
1546
- for (const unwatch of context.__watcherHandles) {
1547
- unwatch();
1548
- }
1549
- }
1550
- return result;
1218
+ if (isVNode$1(input)) return renderToString(createApp({ render: () => input }), context);
1219
+ const vnode = createVNode(input._component, input._props);
1220
+ vnode.appContext = input._context;
1221
+ input.provide(ssrContextKey, context);
1222
+ try {
1223
+ const result = await unrollBuffer$1(await renderComponentVNode(vnode));
1224
+ await resolveTeleports(context);
1225
+ return result;
1226
+ } finally {
1227
+ cleanupContext(context);
1228
+ }
1551
1229
  }
1552
1230
  async function resolveTeleports(context) {
1553
- if (context.__teleportBuffers) {
1554
- context.teleports = context.teleports || {};
1555
- for (const key in context.__teleportBuffers) {
1556
- context.teleports[key] = await unrollBuffer$1(
1557
- await Promise.all([context.__teleportBuffers[key]])
1558
- );
1559
- }
1560
- }
1561
- }
1562
-
1231
+ if (context.__teleportBuffers) {
1232
+ context.teleports = context.teleports || {};
1233
+ for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(await Promise.all([context.__teleportBuffers[key]]));
1234
+ }
1235
+ }
1236
+ //#endregion
1237
+ //#region packages/server-renderer/src/renderToStream.ts
1563
1238
  const { isVNode } = ssrUtils;
1564
1239
  async function unrollBuffer(buffer, stream) {
1565
- if (buffer.hasAsync) {
1566
- for (let i = 0; i < buffer.length; i++) {
1567
- let item = buffer[i];
1568
- if (isPromise(item)) {
1569
- item = await item;
1570
- }
1571
- if (isString(item)) {
1572
- stream.push(item);
1573
- } else {
1574
- await unrollBuffer(item, stream);
1575
- }
1576
- }
1577
- } else {
1578
- unrollBufferSync(buffer, stream);
1579
- }
1240
+ if (buffer.hasAsync) for (let i = 0; i < buffer.length; i++) {
1241
+ let item = buffer[i];
1242
+ if (isPromise(item)) item = await item;
1243
+ if (isString(item)) stream.push(item);
1244
+ else await unrollBuffer(item, stream);
1245
+ }
1246
+ else unrollBufferSync(buffer, stream);
1580
1247
  }
1581
1248
  function unrollBufferSync(buffer, stream) {
1582
- for (let i = 0; i < buffer.length; i++) {
1583
- let item = buffer[i];
1584
- if (isString(item)) {
1585
- stream.push(item);
1586
- } else {
1587
- unrollBufferSync(item, stream);
1588
- }
1589
- }
1249
+ for (let i = 0; i < buffer.length; i++) {
1250
+ const item = buffer[i];
1251
+ if (isString(item)) stream.push(item);
1252
+ else unrollBufferSync(item, stream);
1253
+ }
1590
1254
  }
1591
1255
  function renderToSimpleStream(input, context, stream) {
1592
- if (isVNode(input)) {
1593
- return renderToSimpleStream(
1594
- createApp({ render: () => input }),
1595
- context,
1596
- stream
1597
- );
1598
- }
1599
- const vnode = createVNode$1(input._component, input._props);
1600
- vnode.appContext = input._context;
1601
- input.provide(ssrContextKey, context);
1602
- Promise.resolve(renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
1603
- if (context.__watcherHandles) {
1604
- for (const unwatch of context.__watcherHandles) {
1605
- unwatch();
1606
- }
1607
- }
1608
- }).then(() => stream.push(null)).catch((error) => {
1609
- stream.destroy(error);
1610
- });
1611
- return stream;
1256
+ if (isVNode(input)) return renderToSimpleStream(createApp({ render: () => input }), context, stream);
1257
+ const vnode = createVNode(input._component, input._props);
1258
+ vnode.appContext = input._context;
1259
+ input.provide(ssrContextKey, context);
1260
+ let cleaned = false;
1261
+ const finalize = () => {
1262
+ if (cleaned) return;
1263
+ cleaned = true;
1264
+ cleanupContext(context);
1265
+ };
1266
+ Promise.resolve().then(() => renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
1267
+ finalize();
1268
+ return stream.push(null);
1269
+ }).catch((error) => {
1270
+ try {
1271
+ finalize();
1272
+ } catch {}
1273
+ stream.destroy(error);
1274
+ });
1275
+ return stream;
1612
1276
  }
1277
+ /**
1278
+ * @deprecated
1279
+ */
1613
1280
  function renderToStream(input, context = {}) {
1614
- console.warn(
1615
- `[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`
1616
- );
1617
- return renderToNodeStream(input, context);
1281
+ console.warn(`[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`);
1282
+ return renderToNodeStream(input, context);
1618
1283
  }
1619
1284
  function renderToNodeStream(input, context = {}) {
1620
- {
1621
- throw new Error(
1622
- `ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
1623
- );
1624
- }
1285
+ throw new Error("ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.");
1625
1286
  }
1626
1287
  function pipeToNodeWritable(input, context = {}, writable) {
1627
- renderToSimpleStream(input, context, {
1628
- push(content) {
1629
- if (content != null) {
1630
- writable.write(content);
1631
- } else {
1632
- writable.end();
1633
- }
1634
- },
1635
- destroy(err) {
1636
- writable.destroy(err);
1637
- }
1638
- });
1288
+ renderToSimpleStream(input, context, {
1289
+ push(content) {
1290
+ if (content != null) writable.write(content);
1291
+ else writable.end();
1292
+ },
1293
+ destroy(err) {
1294
+ writable.destroy(err);
1295
+ }
1296
+ });
1639
1297
  }
1640
1298
  function renderToWebStream(input, context = {}) {
1641
- if (typeof ReadableStream !== "function") {
1642
- throw new Error(
1643
- `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.`
1644
- );
1645
- }
1646
- const encoder = new TextEncoder();
1647
- let cancelled = false;
1648
- return new ReadableStream({
1649
- start(controller) {
1650
- renderToSimpleStream(input, context, {
1651
- push(content) {
1652
- if (cancelled) return;
1653
- if (content != null) {
1654
- controller.enqueue(encoder.encode(content));
1655
- } else {
1656
- controller.close();
1657
- }
1658
- },
1659
- destroy(err) {
1660
- controller.error(err);
1661
- }
1662
- });
1663
- },
1664
- cancel() {
1665
- cancelled = true;
1666
- }
1667
- });
1299
+ 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.");
1300
+ const encoder = new TextEncoder();
1301
+ let cancelled = false;
1302
+ return new ReadableStream({
1303
+ start(controller) {
1304
+ renderToSimpleStream(input, context, {
1305
+ push(content) {
1306
+ if (cancelled) return;
1307
+ if (content != null) controller.enqueue(encoder.encode(content));
1308
+ else controller.close();
1309
+ },
1310
+ destroy(err) {
1311
+ controller.error(err);
1312
+ }
1313
+ });
1314
+ },
1315
+ cancel() {
1316
+ cancelled = true;
1317
+ }
1318
+ });
1668
1319
  }
1669
1320
  function pipeToWebWritable(input, context = {}, writable) {
1670
- const writer = writable.getWriter();
1671
- const encoder = new TextEncoder();
1672
- let hasReady = false;
1673
- try {
1674
- hasReady = isPromise(writer.ready);
1675
- } catch (e) {
1676
- }
1677
- renderToSimpleStream(input, context, {
1678
- async push(content) {
1679
- if (hasReady) {
1680
- await writer.ready;
1681
- }
1682
- if (content != null) {
1683
- return writer.write(encoder.encode(content));
1684
- } else {
1685
- return writer.close();
1686
- }
1687
- },
1688
- destroy(err) {
1689
- console.log(err);
1690
- writer.close();
1691
- }
1692
- });
1693
- }
1694
-
1321
+ const writer = writable.getWriter();
1322
+ const encoder = new TextEncoder();
1323
+ let hasReady = false;
1324
+ try {
1325
+ hasReady = isPromise(writer.ready);
1326
+ } catch (e) {}
1327
+ renderToSimpleStream(input, context, {
1328
+ async push(content) {
1329
+ if (hasReady) await writer.ready;
1330
+ if (content != null) return writer.write(encoder.encode(content));
1331
+ else return writer.close();
1332
+ },
1333
+ destroy(err) {
1334
+ console.log(err);
1335
+ writer.close();
1336
+ }
1337
+ });
1338
+ }
1339
+ //#endregion
1340
+ //#region packages/server-renderer/src/index.ts
1695
1341
  initDirectivesForSSR();
1696
-
1697
- export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };
1342
+ //#endregion
1343
+ export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, ssrIncludeBooleanAttr, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };