@vue/server-renderer 3.6.0-beta.8 → 3.6.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server-renderer.cjs.js +102 -305
- package/dist/server-renderer.cjs.prod.js +100 -43
- package/dist/server-renderer.d.ts +3 -3
- package/dist/server-renderer.esm-browser.js +327 -119
- package/dist/server-renderer.esm-browser.prod.js +2 -2
- package/dist/server-renderer.esm-bundler.js +77 -796
- package/package.json +4 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/server-renderer v3.6.0-
|
|
2
|
+
* @vue/server-renderer v3.6.0-rc.1
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
import { Comment, Fragment, Static, Text, createApp, createVNode, initDirectivesForSSR, mergeProps, ssrContextKey, ssrUtils, warn } from "vue";
|
|
7
|
-
import {
|
|
6
|
+
import { Comment, Fragment, Static, Text, createApp, createVNode, handleError, initDirectivesForSSR, mergeProps, ssrContextKey, ssrUtils, warn } from "@vue/runtime-dom";
|
|
7
|
+
import { NOOP, escapeHtml, escapeHtmlComment, hasOwn, includeBooleanAttr, includeBooleanAttr as ssrIncludeBooleanAttr, isArray, isBooleanAttr, isFunction, isObject, isOn, isPromise, isRenderableAttrValue, isSSRSafeAttrName, isSVGTag, isString, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeCssVarValue, normalizeStyle, propsToAttrMap, stringifyStyle, toDisplayString } from "@vue/shared";
|
|
8
8
|
//#region packages/server-renderer/src/helpers/ssrRenderAttrs.ts
|
|
9
9
|
const shouldIgnoreProp = /* @__PURE__ */ makeMap(`,key,ref,innerHTML,textContent,ref_key,ref_for`);
|
|
10
10
|
function ssrRenderAttrs(props, tag) {
|
|
@@ -55,6 +55,11 @@ function ssrResetCssVars(raw) {
|
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region packages/server-renderer/src/helpers/ssrRenderComponent.ts
|
|
57
57
|
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
|
|
58
|
+
if (isString(comp)) {
|
|
59
|
+
const { getBuffer, push } = createBuffer();
|
|
60
|
+
renderVNode(push, createVNode(comp, props, children), parentComponent, slotScopeId);
|
|
61
|
+
return getBuffer();
|
|
62
|
+
}
|
|
58
63
|
return renderComponentVNode(createVNode(comp, props, children), parentComponent, slotScopeId);
|
|
59
64
|
}
|
|
60
65
|
//#endregion
|
|
@@ -128,6 +133,7 @@ function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parent
|
|
|
128
133
|
teleportContent = getBuffer();
|
|
129
134
|
}
|
|
130
135
|
targetBuffer.splice(bufferIndex, 0, teleportContent);
|
|
136
|
+
if (isPromise(teleportContent) || isArray(teleportContent) && teleportContent.hasAsync) targetBuffer.hasAsync = true;
|
|
131
137
|
parentPush("<!--teleport end-->");
|
|
132
138
|
}
|
|
133
139
|
//#endregion
|
|
@@ -136,794 +142,18 @@ function ssrInterpolate(value) {
|
|
|
136
142
|
return escapeHtml(toDisplayString(value));
|
|
137
143
|
}
|
|
138
144
|
//#endregion
|
|
139
|
-
//#region packages/reactivity/src/system.ts
|
|
140
|
-
let activeSub = void 0;
|
|
141
|
-
function setActiveSub(sub) {
|
|
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__ */
|
|
161
|
-
function isProxy(value) {
|
|
162
|
-
return value ? !!value["__v_raw"] : false;
|
|
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__ */
|
|
188
|
-
function toRaw(observed) {
|
|
189
|
-
const raw = observed && observed["__v_raw"];
|
|
190
|
-
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
191
|
-
}
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region packages/reactivity/src/ref.ts
|
|
194
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
195
|
-
function isRef(r) {
|
|
196
|
-
return r ? r["__v_isRef"] === true : false;
|
|
197
|
-
}
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region packages/runtime-core/src/warning.ts
|
|
200
|
-
const stack = [];
|
|
201
|
-
/**
|
|
202
|
-
* @internal
|
|
203
|
-
*/
|
|
204
|
-
function pushWarningContext$1(ctx) {
|
|
205
|
-
stack.push(ctx);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* @internal
|
|
209
|
-
*/
|
|
210
|
-
function popWarningContext$1() {
|
|
211
|
-
stack.pop();
|
|
212
|
-
}
|
|
213
|
-
let 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;
|
|
240
|
-
}
|
|
241
|
-
function getComponentTrace() {
|
|
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 */
|
|
260
|
-
function formatTrace(trace) {
|
|
261
|
-
const logs = [];
|
|
262
|
-
trace.forEach((entry, i) => {
|
|
263
|
-
logs.push(...i === 0 ? [] : [`\n`], ...formatTraceEntry(entry));
|
|
264
|
-
});
|
|
265
|
-
return logs;
|
|
266
|
-
}
|
|
267
|
-
function formatTraceEntry({ ctx, recurseCount }) {
|
|
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];
|
|
278
|
-
}
|
|
279
|
-
function formatProps(props) {
|
|
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;
|
|
287
|
-
}
|
|
288
|
-
function formatProp(key, value, raw) {
|
|
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
|
|
309
|
-
const ErrorTypeStrings = {
|
|
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"
|
|
341
|
-
};
|
|
342
|
-
function callWithErrorHandling(fn, instance, type, args) {
|
|
343
|
-
try {
|
|
344
|
-
return args ? fn(...args) : fn();
|
|
345
|
-
} catch (err) {
|
|
346
|
-
handleError(err, instance, type);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
function handleError(err, instance, type, throwInDev = true) {
|
|
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);
|
|
374
|
-
}
|
|
375
|
-
function logError(err, type, instance, throwInDev = true, throwInProd = false) {
|
|
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
|
|
388
|
-
const jobs = [];
|
|
389
|
-
let postJobs = [];
|
|
390
|
-
let activePostJobs = null;
|
|
391
|
-
let currentFlushPromise = null;
|
|
392
|
-
let jobsLength = 0;
|
|
393
|
-
let flushIndex = 0;
|
|
394
|
-
let postFlushIndex = 0;
|
|
395
|
-
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
396
|
-
const RECURSION_LIMIT = 100;
|
|
397
|
-
function nextTick(fn) {
|
|
398
|
-
const p = currentFlushPromise || resolvedPromise;
|
|
399
|
-
return fn ? p.then(this ? fn.bind(this) : fn) : p;
|
|
400
|
-
}
|
|
401
|
-
function findInsertionIndex(order, queue, start, end) {
|
|
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;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* @internal for runtime-vapor only
|
|
411
|
-
*/
|
|
412
|
-
function queueJob(job, id, isPre = 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;
|
|
428
|
-
}
|
|
429
|
-
const doFlushJobs = () => {
|
|
430
|
-
try {
|
|
431
|
-
flushJobs();
|
|
432
|
-
} catch (e) {
|
|
433
|
-
currentFlushPromise = null;
|
|
434
|
-
throw e;
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
function 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();
|
|
445
|
-
}
|
|
446
|
-
function flushPostFlushCbs(seen) {
|
|
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
|
-
}
|
|
469
|
-
}
|
|
470
|
-
function flushJobs(seen) {
|
|
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
|
-
}
|
|
499
|
-
}
|
|
500
|
-
function checkRecursiveUpdates(seen, fn) {
|
|
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
|
|
513
|
-
let isHmrUpdating = false;
|
|
514
|
-
const hmrDirtyComponents = /* @__PURE__ */ new Map();
|
|
515
|
-
const hmrDirtyComponentsMode = /* @__PURE__ */ new Map();
|
|
516
|
-
if (!!(process.env.NODE_ENV !== "production")) getGlobalThis().__VUE_HMR_RUNTIME__ = {
|
|
517
|
-
createRecord: tryWrap(createRecord),
|
|
518
|
-
rerender: tryWrap(rerender),
|
|
519
|
-
reload: tryWrap(reload)
|
|
520
|
-
};
|
|
521
|
-
const map = /* @__PURE__ */ new Map();
|
|
522
|
-
function createRecord(id, initialDef) {
|
|
523
|
-
if (map.has(id)) return false;
|
|
524
|
-
map.set(id, {
|
|
525
|
-
initialDef: normalizeClassComponent(initialDef),
|
|
526
|
-
instances: /* @__PURE__ */ new Set()
|
|
527
|
-
});
|
|
528
|
-
return true;
|
|
529
|
-
}
|
|
530
|
-
function normalizeClassComponent(component) {
|
|
531
|
-
return isClassComponent(component) ? component.__vccOpts : component;
|
|
532
|
-
}
|
|
533
|
-
function rerender(id, newRender) {
|
|
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
|
-
});
|
|
556
|
-
}
|
|
557
|
-
function reload(id, newComp) {
|
|
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
|
-
});
|
|
605
|
-
}
|
|
606
|
-
function updateComponentDef(oldComp, newComp) {
|
|
607
|
-
extend(oldComp, newComp);
|
|
608
|
-
for (const key in oldComp) if (key !== "__file" && !(key in newComp)) delete oldComp[key];
|
|
609
|
-
}
|
|
610
|
-
function tryWrap(fn) {
|
|
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;
|
|
623
|
-
let buffer = [];
|
|
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
|
-
*/
|
|
649
|
-
let currentRenderingInstance = null;
|
|
650
|
-
let currentScopeId = null;
|
|
651
|
-
//#endregion
|
|
652
|
-
//#region packages/runtime-core/src/components/Teleport.ts
|
|
653
|
-
const isTeleport = (type) => type.__isTeleport;
|
|
654
|
-
//#endregion
|
|
655
|
-
//#region packages/runtime-core/src/components/BaseTransition.ts
|
|
656
|
-
function setTransitionHooks(vnode, hooks) {
|
|
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
|
-
*/
|
|
678
|
-
const internalObjectProto = {};
|
|
679
|
-
const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
|
|
680
|
-
//#endregion
|
|
681
|
-
//#region packages/runtime-core/src/renderer.ts
|
|
682
|
-
function getVaporInterface(instance, vnode) {
|
|
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;
|
|
687
|
-
}
|
|
688
|
-
function isVaporComponent(type) {
|
|
689
|
-
if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating && hmrDirtyComponentsMode.has(type)) return hmrDirtyComponentsMode.get(type);
|
|
690
|
-
return type.__vapor;
|
|
691
|
-
}
|
|
692
|
-
//#endregion
|
|
693
|
-
//#region packages/runtime-core/src/components/Suspense.ts
|
|
694
|
-
const isSuspense = (type) => type.__isSuspense;
|
|
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");
|
|
700
|
-
function isVNode$2(value) {
|
|
701
|
-
return value ? value.__v_isVNode === true : false;
|
|
702
|
-
}
|
|
703
|
-
const createVNodeWithArgsTransform = (...args) => {
|
|
704
|
-
return _createVNode(...args);
|
|
705
|
-
};
|
|
706
|
-
const normalizeKey = ({ key }) => key != null ? key : null;
|
|
707
|
-
const normalizeRef = ({ ref, ref_key, ref_for }, i = currentRenderingInstance) => {
|
|
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;
|
|
715
|
-
};
|
|
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;
|
|
754
|
-
function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
|
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);
|
|
781
|
-
}
|
|
782
|
-
function guardReactiveProps(props) {
|
|
783
|
-
if (!props) return null;
|
|
784
|
-
return /* @__PURE__ */ isProxy(props) || isInternalObject(props) ? extend({}, props) : props;
|
|
785
|
-
}
|
|
786
|
-
function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
|
|
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;
|
|
822
|
-
}
|
|
823
|
-
/**
|
|
824
|
-
* Dev only, for HMR of hoisted vnodes reused in v-for
|
|
825
|
-
* https://github.com/vitejs/vite/issues/2022
|
|
826
|
-
*/
|
|
827
|
-
function deepCloneVNode(vnode) {
|
|
828
|
-
const cloned = cloneVNode(vnode);
|
|
829
|
-
if (isArray(vnode.children)) cloned.children = vnode.children.map(deepCloneVNode);
|
|
830
|
-
return cloned;
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* @private
|
|
834
|
-
*/
|
|
835
|
-
function createTextVNode(text = " ", flag = 0) {
|
|
836
|
-
return createVNode$1(Text$1, null, text, flag);
|
|
837
|
-
}
|
|
838
|
-
function normalizeChildren(vnode, children) {
|
|
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 (key !== "") ret[key] = toMerge[key];
|
|
883
|
-
}
|
|
884
|
-
return ret;
|
|
885
|
-
}
|
|
886
|
-
process.env.NODE_ENV;
|
|
887
|
-
const classifyRE = /(?:^|[-_])\w/g;
|
|
888
|
-
const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
|
|
889
|
-
function getComponentName(Component, includeInferred = true) {
|
|
890
|
-
return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
891
|
-
}
|
|
892
|
-
function formatComponentName(instance, Component, isRoot = false) {
|
|
893
|
-
let name = getComponentName(Component);
|
|
894
|
-
if (!name && Component.__file) {
|
|
895
|
-
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
896
|
-
if (match) name = match[1];
|
|
897
|
-
}
|
|
898
|
-
if (!name && instance) {
|
|
899
|
-
const inferFromRegistry = (registry) => {
|
|
900
|
-
for (const key in registry) if (registry[key] === Component) return key;
|
|
901
|
-
};
|
|
902
|
-
name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(instance.parent.type.components) || inferFromRegistry(instance.appContext.components);
|
|
903
|
-
}
|
|
904
|
-
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
905
|
-
}
|
|
906
|
-
function isClassComponent(value) {
|
|
907
|
-
return isFunction(value) && "__vccOpts" in value;
|
|
908
|
-
}
|
|
909
|
-
//#endregion
|
|
910
|
-
//#region packages/runtime-core/src/index.ts
|
|
911
|
-
const warn$1 = !!(process.env.NODE_ENV !== "production") ? warn$2 : NOOP;
|
|
912
|
-
process.env.NODE_ENV;
|
|
913
|
-
process.env.NODE_ENV;
|
|
914
|
-
//#endregion
|
|
915
145
|
//#region packages/server-renderer/src/helpers/ssrRenderList.ts
|
|
916
146
|
function ssrRenderList(source, renderItem) {
|
|
917
147
|
if (isArray(source) || isString(source)) for (let i = 0, l = source.length; i < l; i++) renderItem(source[i], i);
|
|
918
148
|
else if (typeof source === "number") {
|
|
919
149
|
if (!!(process.env.NODE_ENV !== "production") && (!Number.isInteger(source) || source < 0)) {
|
|
920
|
-
warn
|
|
150
|
+
warn(`The v-for range expects a positive integer value but got ${source}.`);
|
|
921
151
|
return;
|
|
922
152
|
}
|
|
923
153
|
for (let i = 0; i < source; i++) renderItem(i + 1, i);
|
|
924
154
|
} else if (isObject(source)) if (source[Symbol.iterator]) {
|
|
925
|
-
|
|
926
|
-
for (
|
|
155
|
+
let i = 0;
|
|
156
|
+
for (const item of source) renderItem(item, i++);
|
|
927
157
|
} else {
|
|
928
158
|
const keys = Object.keys(source);
|
|
929
159
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
@@ -934,7 +164,7 @@ function ssrRenderList(source, renderItem) {
|
|
|
934
164
|
}
|
|
935
165
|
//#endregion
|
|
936
166
|
//#region packages/server-renderer/src/helpers/ssrRenderSuspense.ts
|
|
937
|
-
|
|
167
|
+
function ssrRenderSuspense(push, { default: renderContent }) {
|
|
938
168
|
if (renderContent) renderContent();
|
|
939
169
|
else push(`<!---->`);
|
|
940
170
|
}
|
|
@@ -980,6 +210,26 @@ function ssrCompile(template, instance) {
|
|
|
980
210
|
//#endregion
|
|
981
211
|
//#region packages/server-renderer/src/render.ts
|
|
982
212
|
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode, pushWarningContext, popWarningContext } = ssrUtils;
|
|
213
|
+
function cleanupContext(context) {
|
|
214
|
+
let firstError;
|
|
215
|
+
if (context.__watcherHandles) {
|
|
216
|
+
for (const unwatch of context.__watcherHandles) try {
|
|
217
|
+
unwatch();
|
|
218
|
+
} catch (err) {
|
|
219
|
+
if (firstError === void 0) firstError = err;
|
|
220
|
+
}
|
|
221
|
+
context.__watcherHandles.length = 0;
|
|
222
|
+
}
|
|
223
|
+
if (context.__instanceScopes) {
|
|
224
|
+
for (const scope of context.__instanceScopes) try {
|
|
225
|
+
scope.stop();
|
|
226
|
+
} catch (err) {
|
|
227
|
+
if (firstError === void 0) firstError = err;
|
|
228
|
+
}
|
|
229
|
+
context.__instanceScopes.length = 0;
|
|
230
|
+
}
|
|
231
|
+
if (firstError !== void 0) throw firstError;
|
|
232
|
+
}
|
|
983
233
|
function createBuffer() {
|
|
984
234
|
let appendable = false;
|
|
985
235
|
const buffer = [];
|
|
@@ -1001,6 +251,8 @@ function createBuffer() {
|
|
|
1001
251
|
}
|
|
1002
252
|
function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
1003
253
|
const instance = vnode.component = createComponentInstance(vnode, parentComponent, null);
|
|
254
|
+
const context = instance.appContext.provides[ssrContextKey];
|
|
255
|
+
if (context) (context.__instanceScopes || (context.__instanceScopes = [])).push(instance.scope);
|
|
1004
256
|
if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(vnode);
|
|
1005
257
|
const res = setupComponent(instance, true);
|
|
1006
258
|
if (!!(process.env.NODE_ENV !== "production")) popWarningContext();
|
|
@@ -1010,7 +262,11 @@ function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
|
|
|
1010
262
|
if (hasAsyncSetup) prefetches = instance.sp;
|
|
1011
263
|
if (prefetches) return Promise.all(prefetches.map((prefetch) => prefetch.call(instance.proxy)));
|
|
1012
264
|
}).catch(NOOP).then(() => renderComponentSubTree(instance, slotScopeId));
|
|
1013
|
-
else
|
|
265
|
+
else try {
|
|
266
|
+
return renderComponentSubTree(instance, slotScopeId);
|
|
267
|
+
} catch (err) {
|
|
268
|
+
return Promise.reject(err);
|
|
269
|
+
}
|
|
1014
270
|
}
|
|
1015
271
|
function renderComponentSubTree(instance, slotScopeId) {
|
|
1016
272
|
if (!!(process.env.NODE_ENV !== "production")) pushWarningContext(instance.vnode);
|
|
@@ -1050,6 +306,8 @@ function renderComponentSubTree(instance, slotScopeId) {
|
|
|
1050
306
|
const prev = setCurrentRenderingInstance(instance);
|
|
1051
307
|
try {
|
|
1052
308
|
ssrRender(instance.proxy, push, instance, attrs, instance.props, instance.setupState, instance.data, instance.ctx);
|
|
309
|
+
} catch (err) {
|
|
310
|
+
handleError(err, instance, 1);
|
|
1053
311
|
} finally {
|
|
1054
312
|
setCurrentRenderingInstance(prev);
|
|
1055
313
|
}
|
|
@@ -1096,15 +354,25 @@ function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
|
|
|
1096
354
|
let { props, children, shapeFlag, scopeId } = vnode;
|
|
1097
355
|
let openTag = `<${tag}`;
|
|
1098
356
|
if (props) openTag += ssrRenderAttrs(props, tag);
|
|
1099
|
-
|
|
357
|
+
const renderedScopeIds = [];
|
|
358
|
+
const appendScopeId = (id) => {
|
|
359
|
+
if (id && (!props || !hasOwn(props, id)) && !renderedScopeIds.includes(id)) {
|
|
360
|
+
openTag += ` ${id}`;
|
|
361
|
+
renderedScopeIds.push(id);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
if (scopeId) appendScopeId(scopeId);
|
|
1100
365
|
let curParent = parentComponent;
|
|
1101
366
|
let curVnode = vnode;
|
|
1102
367
|
while (curParent && curVnode === curParent.subTree) {
|
|
1103
368
|
curVnode = curParent.vnode;
|
|
1104
|
-
if (curVnode.scopeId)
|
|
369
|
+
if (curVnode.scopeId) appendScopeId(curVnode.scopeId);
|
|
1105
370
|
curParent = curParent.parent;
|
|
1106
371
|
}
|
|
1107
|
-
if (slotScopeId)
|
|
372
|
+
if (slotScopeId) {
|
|
373
|
+
const slotScopeIdList = slotScopeId.trim().split(" ");
|
|
374
|
+
for (let i = 0; i < slotScopeIdList.length; i++) appendScopeId(slotScopeIdList[i]);
|
|
375
|
+
}
|
|
1108
376
|
push(openTag + `>`);
|
|
1109
377
|
if (!isVoidTag(tag)) {
|
|
1110
378
|
let hasChildrenOverride = false;
|
|
@@ -1196,15 +464,18 @@ async function renderToString(input, context = {}) {
|
|
|
1196
464
|
const vnode = createVNode(input._component, input._props);
|
|
1197
465
|
vnode.appContext = input._context;
|
|
1198
466
|
input.provide(ssrContextKey, context);
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
467
|
+
try {
|
|
468
|
+
const result = await unrollBuffer$1(await renderComponentVNode(vnode));
|
|
469
|
+
await resolveTeleports(context);
|
|
470
|
+
return result;
|
|
471
|
+
} finally {
|
|
472
|
+
cleanupContext(context);
|
|
473
|
+
}
|
|
1203
474
|
}
|
|
1204
475
|
async function resolveTeleports(context) {
|
|
1205
476
|
if (context.__teleportBuffers) {
|
|
1206
477
|
context.teleports = context.teleports || {};
|
|
1207
|
-
for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(
|
|
478
|
+
for (const key in context.__teleportBuffers) context.teleports[key] = await unrollBuffer$1(context.__teleportBuffers[key]);
|
|
1208
479
|
}
|
|
1209
480
|
}
|
|
1210
481
|
//#endregion
|
|
@@ -1221,7 +492,7 @@ async function unrollBuffer(buffer, stream) {
|
|
|
1221
492
|
}
|
|
1222
493
|
function unrollBufferSync(buffer, stream) {
|
|
1223
494
|
for (let i = 0; i < buffer.length; i++) {
|
|
1224
|
-
|
|
495
|
+
const item = buffer[i];
|
|
1225
496
|
if (isString(item)) stream.push(item);
|
|
1226
497
|
else unrollBufferSync(item, stream);
|
|
1227
498
|
}
|
|
@@ -1231,9 +502,19 @@ function renderToSimpleStream(input, context, stream) {
|
|
|
1231
502
|
const vnode = createVNode(input._component, input._props);
|
|
1232
503
|
vnode.appContext = input._context;
|
|
1233
504
|
input.provide(ssrContextKey, context);
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
505
|
+
let cleaned = false;
|
|
506
|
+
const finalize = () => {
|
|
507
|
+
if (cleaned) return;
|
|
508
|
+
cleaned = true;
|
|
509
|
+
cleanupContext(context);
|
|
510
|
+
};
|
|
511
|
+
Promise.resolve().then(() => renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
|
|
512
|
+
finalize();
|
|
513
|
+
return stream.push(null);
|
|
514
|
+
}).catch((error) => {
|
|
515
|
+
try {
|
|
516
|
+
finalize();
|
|
517
|
+
} catch {}
|
|
1237
518
|
stream.destroy(error);
|
|
1238
519
|
});
|
|
1239
520
|
return stream;
|