@vue/runtime-core 3.1.1 → 3.1.5
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/runtime-core.cjs.js +252 -71
- package/dist/runtime-core.cjs.prod.js +213 -55
- package/dist/runtime-core.d.ts +146 -12
- package/dist/runtime-core.esm-bundler.js +312 -135
- package/package.json +3 -3
|
@@ -421,11 +421,12 @@ function emit(instance, event, ...rawArgs) {
|
|
|
421
421
|
const onceHandler = props[handlerName + `Once`];
|
|
422
422
|
if (onceHandler) {
|
|
423
423
|
if (!instance.emitted) {
|
|
424
|
-
|
|
424
|
+
instance.emitted = {};
|
|
425
425
|
}
|
|
426
426
|
else if (instance.emitted[handlerName]) {
|
|
427
427
|
return;
|
|
428
428
|
}
|
|
429
|
+
instance.emitted[handlerName] = true;
|
|
429
430
|
callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
|
|
430
431
|
}
|
|
431
432
|
}
|
|
@@ -839,6 +840,12 @@ const SuspenseImpl = {
|
|
|
839
840
|
// Force-casted public typing for h and TSX props inference
|
|
840
841
|
const Suspense = (SuspenseImpl
|
|
841
842
|
);
|
|
843
|
+
function triggerEvent(vnode, name) {
|
|
844
|
+
const eventListener = vnode.props && vnode.props[name];
|
|
845
|
+
if (shared.isFunction(eventListener)) {
|
|
846
|
+
eventListener();
|
|
847
|
+
}
|
|
848
|
+
}
|
|
842
849
|
function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, rendererInternals) {
|
|
843
850
|
const { p: patch, o: { createElement } } = rendererInternals;
|
|
844
851
|
const hiddenContainer = createElement('div');
|
|
@@ -848,6 +855,9 @@ function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense
|
|
|
848
855
|
// now check if we have encountered any async deps
|
|
849
856
|
if (suspense.deps > 0) {
|
|
850
857
|
// has async
|
|
858
|
+
// invoke @fallback event
|
|
859
|
+
triggerEvent(vnode, 'onPending');
|
|
860
|
+
triggerEvent(vnode, 'onFallback');
|
|
851
861
|
// mount the fallback tree
|
|
852
862
|
patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context
|
|
853
863
|
isSVG, slotScopeIds);
|
|
@@ -935,10 +945,7 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, slotSc
|
|
|
935
945
|
else {
|
|
936
946
|
// root node toggled
|
|
937
947
|
// invoke @pending event
|
|
938
|
-
|
|
939
|
-
if (shared.isFunction(onPending)) {
|
|
940
|
-
onPending();
|
|
941
|
-
}
|
|
948
|
+
triggerEvent(n2, 'onPending');
|
|
942
949
|
// mount pending branch in off-dom container
|
|
943
950
|
suspense.pendingBranch = newBranch;
|
|
944
951
|
suspense.pendingId++;
|
|
@@ -1036,10 +1043,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
|
|
|
1036
1043
|
}
|
|
1037
1044
|
suspense.effects = [];
|
|
1038
1045
|
// invoke @resolve event
|
|
1039
|
-
|
|
1040
|
-
if (shared.isFunction(onResolve)) {
|
|
1041
|
-
onResolve();
|
|
1042
|
-
}
|
|
1046
|
+
triggerEvent(vnode, 'onResolve');
|
|
1043
1047
|
},
|
|
1044
1048
|
fallback(fallbackVNode) {
|
|
1045
1049
|
if (!suspense.pendingBranch) {
|
|
@@ -1047,10 +1051,7 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
|
|
|
1047
1051
|
}
|
|
1048
1052
|
const { vnode, activeBranch, parentComponent, container, isSVG } = suspense;
|
|
1049
1053
|
// invoke @fallback event
|
|
1050
|
-
|
|
1051
|
-
if (shared.isFunction(onFallback)) {
|
|
1052
|
-
onFallback();
|
|
1053
|
-
}
|
|
1054
|
+
triggerEvent(vnode, 'onFallback');
|
|
1054
1055
|
const anchor = next(activeBranch);
|
|
1055
1056
|
const mountFallback = () => {
|
|
1056
1057
|
if (!suspense.isInFallback) {
|
|
@@ -1065,11 +1066,11 @@ function createSuspenseBoundary(vnode, parent, parentComponent, container, hidde
|
|
|
1065
1066
|
if (delayEnter) {
|
|
1066
1067
|
activeBranch.transition.afterLeave = mountFallback;
|
|
1067
1068
|
}
|
|
1069
|
+
suspense.isInFallback = true;
|
|
1068
1070
|
// unmount current active branch
|
|
1069
1071
|
unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now
|
|
1070
1072
|
true // shouldRemove
|
|
1071
1073
|
);
|
|
1072
|
-
suspense.isInFallback = true;
|
|
1073
1074
|
if (!delayEnter) {
|
|
1074
1075
|
mountFallback();
|
|
1075
1076
|
}
|
|
@@ -1251,7 +1252,7 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
|
|
1251
1252
|
}
|
|
1252
1253
|
else if (arguments.length > 1) {
|
|
1253
1254
|
return treatDefaultAsFactory && shared.isFunction(defaultValue)
|
|
1254
|
-
? defaultValue()
|
|
1255
|
+
? defaultValue.call(instance.proxy)
|
|
1255
1256
|
: defaultValue;
|
|
1256
1257
|
}
|
|
1257
1258
|
else ;
|
|
@@ -1457,9 +1458,11 @@ function createPathGetter(ctx, path) {
|
|
|
1457
1458
|
};
|
|
1458
1459
|
}
|
|
1459
1460
|
function traverse(value, seen = new Set()) {
|
|
1460
|
-
if (!shared.isObject(value) ||
|
|
1461
|
-
|
|
1462
|
-
|
|
1461
|
+
if (!shared.isObject(value) || value["__v_skip" /* SKIP */]) {
|
|
1462
|
+
return value;
|
|
1463
|
+
}
|
|
1464
|
+
seen = seen || new Set();
|
|
1465
|
+
if (seen.has(value)) {
|
|
1463
1466
|
return value;
|
|
1464
1467
|
}
|
|
1465
1468
|
seen.add(value);
|
|
@@ -2353,13 +2356,16 @@ function applyOptions(instance) {
|
|
|
2353
2356
|
registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
|
2354
2357
|
if (shared.isArray(expose)) {
|
|
2355
2358
|
if (expose.length) {
|
|
2356
|
-
const exposed = instance.exposed || (instance.exposed =
|
|
2359
|
+
const exposed = instance.exposed || (instance.exposed = {});
|
|
2357
2360
|
expose.forEach(key => {
|
|
2358
|
-
|
|
2361
|
+
Object.defineProperty(exposed, key, {
|
|
2362
|
+
get: () => publicThis[key],
|
|
2363
|
+
set: val => (publicThis[key] = val)
|
|
2364
|
+
});
|
|
2359
2365
|
});
|
|
2360
2366
|
}
|
|
2361
2367
|
else if (!instance.exposed) {
|
|
2362
|
-
instance.exposed =
|
|
2368
|
+
instance.exposed = {};
|
|
2363
2369
|
}
|
|
2364
2370
|
}
|
|
2365
2371
|
// options that are handled when creating the instance but also need to be
|
|
@@ -2482,25 +2488,23 @@ const internalOptionMergeStrats = {
|
|
|
2482
2488
|
methods: mergeObjectOptions,
|
|
2483
2489
|
computed: mergeObjectOptions,
|
|
2484
2490
|
// lifecycle
|
|
2485
|
-
beforeCreate:
|
|
2486
|
-
created:
|
|
2487
|
-
beforeMount:
|
|
2488
|
-
mounted:
|
|
2489
|
-
beforeUpdate:
|
|
2490
|
-
updated:
|
|
2491
|
-
beforeDestroy:
|
|
2492
|
-
destroyed:
|
|
2493
|
-
activated:
|
|
2494
|
-
deactivated:
|
|
2495
|
-
errorCaptured:
|
|
2496
|
-
serverPrefetch:
|
|
2491
|
+
beforeCreate: mergeAsArray,
|
|
2492
|
+
created: mergeAsArray,
|
|
2493
|
+
beforeMount: mergeAsArray,
|
|
2494
|
+
mounted: mergeAsArray,
|
|
2495
|
+
beforeUpdate: mergeAsArray,
|
|
2496
|
+
updated: mergeAsArray,
|
|
2497
|
+
beforeDestroy: mergeAsArray,
|
|
2498
|
+
destroyed: mergeAsArray,
|
|
2499
|
+
activated: mergeAsArray,
|
|
2500
|
+
deactivated: mergeAsArray,
|
|
2501
|
+
errorCaptured: mergeAsArray,
|
|
2502
|
+
serverPrefetch: mergeAsArray,
|
|
2497
2503
|
// assets
|
|
2498
2504
|
components: mergeObjectOptions,
|
|
2499
2505
|
directives: mergeObjectOptions,
|
|
2500
|
-
// watch
|
|
2501
|
-
|
|
2502
|
-
// on the watch-specific behavior, just expose the object merge strat.
|
|
2503
|
-
watch: mergeObjectOptions,
|
|
2506
|
+
// watch
|
|
2507
|
+
watch: mergeWatchOptions,
|
|
2504
2508
|
// provide / inject
|
|
2505
2509
|
provide: mergeDataFn,
|
|
2506
2510
|
inject: mergeInject
|
|
@@ -2529,11 +2533,22 @@ function normalizeInject(raw) {
|
|
|
2529
2533
|
}
|
|
2530
2534
|
return raw;
|
|
2531
2535
|
}
|
|
2532
|
-
function
|
|
2536
|
+
function mergeAsArray(to, from) {
|
|
2533
2537
|
return to ? [...new Set([].concat(to, from))] : from;
|
|
2534
2538
|
}
|
|
2535
2539
|
function mergeObjectOptions(to, from) {
|
|
2536
2540
|
return to ? shared.extend(shared.extend(Object.create(null), to), from) : from;
|
|
2541
|
+
}
|
|
2542
|
+
function mergeWatchOptions(to, from) {
|
|
2543
|
+
if (!to)
|
|
2544
|
+
return from;
|
|
2545
|
+
if (!from)
|
|
2546
|
+
return to;
|
|
2547
|
+
const merged = shared.extend(Object.create(null), to);
|
|
2548
|
+
for (const key in from) {
|
|
2549
|
+
merged[key] = mergeAsArray(to[key], from[key]);
|
|
2550
|
+
}
|
|
2551
|
+
return merged;
|
|
2537
2552
|
}
|
|
2538
2553
|
|
|
2539
2554
|
function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison
|
|
@@ -2947,6 +2962,9 @@ function withDirectives(vnode, directives) {
|
|
|
2947
2962
|
updated: dir
|
|
2948
2963
|
};
|
|
2949
2964
|
}
|
|
2965
|
+
if (dir.deep) {
|
|
2966
|
+
traverse(value);
|
|
2967
|
+
}
|
|
2950
2968
|
bindings.push({
|
|
2951
2969
|
dir,
|
|
2952
2970
|
instance,
|
|
@@ -3018,6 +3036,7 @@ function createAppAPI(render, hydrate) {
|
|
|
3018
3036
|
_props: rootProps,
|
|
3019
3037
|
_container: null,
|
|
3020
3038
|
_context: context,
|
|
3039
|
+
_instance: null,
|
|
3021
3040
|
version,
|
|
3022
3041
|
get config() {
|
|
3023
3042
|
return context.config;
|
|
@@ -3105,6 +3124,11 @@ const isComment = (node) => node.nodeType === 8 /* COMMENT */;
|
|
|
3105
3124
|
function createHydrationFunctions(rendererInternals) {
|
|
3106
3125
|
const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
|
|
3107
3126
|
const hydrate = (vnode, container) => {
|
|
3127
|
+
if (!container.hasChildNodes()) {
|
|
3128
|
+
patch(null, vnode, container);
|
|
3129
|
+
flushPostFlushCbs();
|
|
3130
|
+
return;
|
|
3131
|
+
}
|
|
3108
3132
|
hasMismatch = false;
|
|
3109
3133
|
hydrateNode(container.firstChild, vnode, null, null, null);
|
|
3110
3134
|
flushPostFlushCbs();
|
|
@@ -3234,19 +3258,24 @@ function createHydrationFunctions(rendererInternals) {
|
|
|
3234
3258
|
};
|
|
3235
3259
|
const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
|
3236
3260
|
optimized = optimized || !!vnode.dynamicChildren;
|
|
3237
|
-
const { props, patchFlag, shapeFlag, dirs } = vnode;
|
|
3261
|
+
const { type, props, patchFlag, shapeFlag, dirs } = vnode;
|
|
3262
|
+
// #4006 for form elements with non-string v-model value bindings
|
|
3263
|
+
// e.g. <option :value="obj">, <input type="checkbox" :true-value="1">
|
|
3264
|
+
const forcePatchValue = (type === 'input' && dirs) || type === 'option';
|
|
3238
3265
|
// skip props & children if this is hoisted static nodes
|
|
3239
|
-
if (patchFlag !== -1 /* HOISTED */) {
|
|
3266
|
+
if (forcePatchValue || patchFlag !== -1 /* HOISTED */) {
|
|
3240
3267
|
if (dirs) {
|
|
3241
3268
|
invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
|
3242
3269
|
}
|
|
3243
3270
|
// props
|
|
3244
3271
|
if (props) {
|
|
3245
|
-
if (
|
|
3272
|
+
if (forcePatchValue ||
|
|
3273
|
+
!optimized ||
|
|
3246
3274
|
(patchFlag & 16 /* FULL_PROPS */ ||
|
|
3247
3275
|
patchFlag & 32 /* HYDRATE_EVENTS */)) {
|
|
3248
3276
|
for (const key in props) {
|
|
3249
|
-
if (
|
|
3277
|
+
if ((forcePatchValue && key.endsWith('value')) ||
|
|
3278
|
+
(shared.isOn(key) && !shared.isReservedProp(key))) {
|
|
3250
3279
|
patchProp(el, key, null, props[key]);
|
|
3251
3280
|
}
|
|
3252
3281
|
}
|
|
@@ -3398,7 +3427,7 @@ const setRef = (rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) =>
|
|
|
3398
3427
|
return;
|
|
3399
3428
|
}
|
|
3400
3429
|
const refValue = vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */
|
|
3401
|
-
? vnode.component
|
|
3430
|
+
? getExposeProxy(vnode.component) || vnode.component.proxy
|
|
3402
3431
|
: vnode.el;
|
|
3403
3432
|
const value = isUnmount ? null : refValue;
|
|
3404
3433
|
const { i: owner, r: ref } = rawRef;
|
|
@@ -3483,7 +3512,7 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
3483
3512
|
const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, forcePatchProp: hostForcePatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = shared.NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
|
|
3484
3513
|
// Note: functions inside this closure should use `const xxx = () => {}`
|
|
3485
3514
|
// style in order to prevent being inlined by minifiers.
|
|
3486
|
-
const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized =
|
|
3515
|
+
const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
|
|
3487
3516
|
// patching & not same type, unmount old tree
|
|
3488
3517
|
if (n1 && !isSameVNodeType(n1, n2)) {
|
|
3489
3518
|
anchor = getNextHostNode(n1);
|
|
@@ -3601,7 +3630,7 @@ function baseCreateRenderer(options, createHydrationFns) {
|
|
|
3601
3630
|
hostSetElementText(el, vnode.children);
|
|
3602
3631
|
}
|
|
3603
3632
|
else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
|
|
3604
|
-
mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized
|
|
3633
|
+
mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized);
|
|
3605
3634
|
}
|
|
3606
3635
|
if (dirs) {
|
|
3607
3636
|
invokeDirectiveHook(vnode, null, parentComponent, 'created');
|
|
@@ -4996,7 +5025,6 @@ function _createVNode(type, props = null, children = null, patchFlag = 0, dynami
|
|
|
4996
5025
|
anchor: null,
|
|
4997
5026
|
target: null,
|
|
4998
5027
|
targetAnchor: null,
|
|
4999
|
-
staticCount: 0,
|
|
5000
5028
|
shapeFlag,
|
|
5001
5029
|
patchFlag,
|
|
5002
5030
|
dynamicProps,
|
|
@@ -5342,7 +5370,7 @@ const getPublicInstance = (i) => {
|
|
|
5342
5370
|
if (!i)
|
|
5343
5371
|
return null;
|
|
5344
5372
|
if (isStatefulComponent(i))
|
|
5345
|
-
return i
|
|
5373
|
+
return getExposeProxy(i) || i.proxy;
|
|
5346
5374
|
return getPublicInstance(i.parent);
|
|
5347
5375
|
};
|
|
5348
5376
|
const publicPropertiesMap = shared.extend(Object.create(null), {
|
|
@@ -5364,10 +5392,6 @@ const publicPropertiesMap = shared.extend(Object.create(null), {
|
|
|
5364
5392
|
const PublicInstanceProxyHandlers = {
|
|
5365
5393
|
get({ _: instance }, key) {
|
|
5366
5394
|
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
|
|
5367
|
-
// let @vue/reactivity know it should never observe Vue public instances.
|
|
5368
|
-
if (key === "__v_skip" /* SKIP */) {
|
|
5369
|
-
return true;
|
|
5370
|
-
}
|
|
5371
5395
|
// data / props / ctx
|
|
5372
5396
|
// This getter gets called for every property access on the render context
|
|
5373
5397
|
// during render and is a major hotspot. The most expensive part of this
|
|
@@ -5509,6 +5533,7 @@ function createComponentInstance(vnode, parent, suspense) {
|
|
|
5509
5533
|
render: null,
|
|
5510
5534
|
proxy: null,
|
|
5511
5535
|
exposed: null,
|
|
5536
|
+
exposeProxy: null,
|
|
5512
5537
|
withProxy: null,
|
|
5513
5538
|
effects: null,
|
|
5514
5539
|
provides: parent ? parent.provides : Object.create(appContext.provides),
|
|
@@ -5595,7 +5620,7 @@ function setupStatefulComponent(instance, isSSR) {
|
|
|
5595
5620
|
instance.accessCache = Object.create(null);
|
|
5596
5621
|
// 1. create public instance / render proxy
|
|
5597
5622
|
// also mark it raw so it's never observed
|
|
5598
|
-
instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
|
|
5623
|
+
instance.proxy = reactivity.markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
|
|
5599
5624
|
// 2. call setup()
|
|
5600
5625
|
const { setup } = Component;
|
|
5601
5626
|
if (setup) {
|
|
@@ -5607,6 +5632,10 @@ function setupStatefulComponent(instance, isSSR) {
|
|
|
5607
5632
|
reactivity.resetTracking();
|
|
5608
5633
|
currentInstance = null;
|
|
5609
5634
|
if (shared.isPromise(setupResult)) {
|
|
5635
|
+
const unsetInstance = () => {
|
|
5636
|
+
currentInstance = null;
|
|
5637
|
+
};
|
|
5638
|
+
setupResult.then(unsetInstance, unsetInstance);
|
|
5610
5639
|
if (isSSR) {
|
|
5611
5640
|
// return the promise so server-renderer can wait on it
|
|
5612
5641
|
return setupResult
|
|
@@ -5705,7 +5734,7 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
|
|
|
5705
5734
|
}
|
|
5706
5735
|
function createSetupContext(instance) {
|
|
5707
5736
|
const expose = exposed => {
|
|
5708
|
-
instance.exposed =
|
|
5737
|
+
instance.exposed = exposed || {};
|
|
5709
5738
|
};
|
|
5710
5739
|
{
|
|
5711
5740
|
return {
|
|
@@ -5716,6 +5745,21 @@ function createSetupContext(instance) {
|
|
|
5716
5745
|
};
|
|
5717
5746
|
}
|
|
5718
5747
|
}
|
|
5748
|
+
function getExposeProxy(instance) {
|
|
5749
|
+
if (instance.exposed) {
|
|
5750
|
+
return (instance.exposeProxy ||
|
|
5751
|
+
(instance.exposeProxy = new Proxy(reactivity.proxyRefs(reactivity.markRaw(instance.exposed)), {
|
|
5752
|
+
get(target, key) {
|
|
5753
|
+
if (key in target) {
|
|
5754
|
+
return target[key];
|
|
5755
|
+
}
|
|
5756
|
+
else if (key in publicPropertiesMap) {
|
|
5757
|
+
return publicPropertiesMap[key](instance);
|
|
5758
|
+
}
|
|
5759
|
+
}
|
|
5760
|
+
})));
|
|
5761
|
+
}
|
|
5762
|
+
}
|
|
5719
5763
|
// record effects created during a component's setup() so that they can be
|
|
5720
5764
|
// stopped when the component unmounts
|
|
5721
5765
|
function recordInstanceBoundEffect(effect, instance = currentInstance) {
|
|
@@ -5764,17 +5808,124 @@ function computed(getterOrOptions) {
|
|
|
5764
5808
|
return c;
|
|
5765
5809
|
}
|
|
5766
5810
|
|
|
5811
|
+
const isFunction = (val) => typeof val === 'function';
|
|
5812
|
+
const isObject = (val) => val !== null && typeof val === 'object';
|
|
5813
|
+
const isPromise = (val) => {
|
|
5814
|
+
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
5815
|
+
};
|
|
5816
|
+
|
|
5767
5817
|
// implementation
|
|
5768
5818
|
function defineProps() {
|
|
5769
5819
|
return null;
|
|
5770
5820
|
}
|
|
5771
5821
|
// implementation
|
|
5772
|
-
function
|
|
5822
|
+
function defineEmits() {
|
|
5773
5823
|
return null;
|
|
5774
5824
|
}
|
|
5825
|
+
/**
|
|
5826
|
+
* @deprecated use `defineEmits` instead.
|
|
5827
|
+
*/
|
|
5828
|
+
const defineEmit = defineEmits;
|
|
5829
|
+
/**
|
|
5830
|
+
* Vue `<script setup>` compiler macro for declaring a component's exposed
|
|
5831
|
+
* instance properties when it is accessed by a parent component via template
|
|
5832
|
+
* refs.
|
|
5833
|
+
*
|
|
5834
|
+
* `<script setup>` components are closed by default - i.e. varaibles inside
|
|
5835
|
+
* the `<script setup>` scope is not exposed to parent unless explicitly exposed
|
|
5836
|
+
* via `defineExpose`.
|
|
5837
|
+
*
|
|
5838
|
+
* This is only usable inside `<script setup>`, is compiled away in the
|
|
5839
|
+
* output and should **not** be actually called at runtime.
|
|
5840
|
+
*/
|
|
5841
|
+
function defineExpose(exposed) {
|
|
5842
|
+
}
|
|
5843
|
+
/**
|
|
5844
|
+
* Vue `<script setup>` compiler macro for providing props default values when
|
|
5845
|
+
* using type-based `defineProps` decalration.
|
|
5846
|
+
*
|
|
5847
|
+
* Example usage:
|
|
5848
|
+
* ```ts
|
|
5849
|
+
* withDefaults(defineProps<{
|
|
5850
|
+
* size?: number
|
|
5851
|
+
* labels?: string[]
|
|
5852
|
+
* }>(), {
|
|
5853
|
+
* size: 3,
|
|
5854
|
+
* labels: () => ['default label']
|
|
5855
|
+
* })
|
|
5856
|
+
* ```
|
|
5857
|
+
*
|
|
5858
|
+
* This is only usable inside `<script setup>`, is compiled away in the output
|
|
5859
|
+
* and should **not** be actually called at runtime.
|
|
5860
|
+
*/
|
|
5861
|
+
function withDefaults(props, defaults) {
|
|
5862
|
+
return null;
|
|
5863
|
+
}
|
|
5864
|
+
/**
|
|
5865
|
+
* @deprecated use `useSlots` and `useAttrs` instead.
|
|
5866
|
+
*/
|
|
5775
5867
|
function useContext() {
|
|
5868
|
+
return getContext();
|
|
5869
|
+
}
|
|
5870
|
+
function useSlots() {
|
|
5871
|
+
return getContext().slots;
|
|
5872
|
+
}
|
|
5873
|
+
function useAttrs() {
|
|
5874
|
+
return getContext().attrs;
|
|
5875
|
+
}
|
|
5876
|
+
function getContext() {
|
|
5776
5877
|
const i = getCurrentInstance();
|
|
5777
5878
|
return i.setupContext || (i.setupContext = createSetupContext(i));
|
|
5879
|
+
}
|
|
5880
|
+
/**
|
|
5881
|
+
* Runtime helper for merging default declarations. Imported by compiled code
|
|
5882
|
+
* only.
|
|
5883
|
+
* @internal
|
|
5884
|
+
*/
|
|
5885
|
+
function mergeDefaults(
|
|
5886
|
+
// the base props is compiler-generated and guaranteed to be in this shape.
|
|
5887
|
+
props, defaults) {
|
|
5888
|
+
for (const key in defaults) {
|
|
5889
|
+
const val = props[key];
|
|
5890
|
+
if (val) {
|
|
5891
|
+
val.default = defaults[key];
|
|
5892
|
+
}
|
|
5893
|
+
else if (val === null) {
|
|
5894
|
+
props[key] = { default: defaults[key] };
|
|
5895
|
+
}
|
|
5896
|
+
else ;
|
|
5897
|
+
}
|
|
5898
|
+
return props;
|
|
5899
|
+
}
|
|
5900
|
+
/**
|
|
5901
|
+
* `<script setup>` helper for persisting the current instance context over
|
|
5902
|
+
* async/await flows.
|
|
5903
|
+
*
|
|
5904
|
+
* `@vue/compiler-sfc` converts the following:
|
|
5905
|
+
*
|
|
5906
|
+
* ```ts
|
|
5907
|
+
* const x = await foo()
|
|
5908
|
+
* ```
|
|
5909
|
+
*
|
|
5910
|
+
* into:
|
|
5911
|
+
*
|
|
5912
|
+
* ```ts
|
|
5913
|
+
* let __temp, __restore
|
|
5914
|
+
* const x = (([__temp, __restore] = withAsyncContext(() => foo())),__temp=await __temp,__restore(),__temp)
|
|
5915
|
+
* ```
|
|
5916
|
+
* @internal
|
|
5917
|
+
*/
|
|
5918
|
+
function withAsyncContext(getAwaitable) {
|
|
5919
|
+
const ctx = getCurrentInstance();
|
|
5920
|
+
let awaitable = getAwaitable();
|
|
5921
|
+
setCurrentInstance(null);
|
|
5922
|
+
if (isPromise(awaitable)) {
|
|
5923
|
+
awaitable = awaitable.catch(e => {
|
|
5924
|
+
setCurrentInstance(ctx);
|
|
5925
|
+
throw e;
|
|
5926
|
+
});
|
|
5927
|
+
}
|
|
5928
|
+
return [awaitable, () => setCurrentInstance(ctx)];
|
|
5778
5929
|
}
|
|
5779
5930
|
|
|
5780
5931
|
// Actual implementation
|
|
@@ -5825,7 +5976,7 @@ function initCustomFormatter() {
|
|
|
5825
5976
|
}
|
|
5826
5977
|
|
|
5827
5978
|
// Core API ------------------------------------------------------------------
|
|
5828
|
-
const version = "3.1.
|
|
5979
|
+
const version = "3.1.5";
|
|
5829
5980
|
const _ssrUtils = {
|
|
5830
5981
|
createComponentInstance,
|
|
5831
5982
|
setupComponent,
|
|
@@ -5894,6 +6045,8 @@ exports.createVNode = createVNode;
|
|
|
5894
6045
|
exports.defineAsyncComponent = defineAsyncComponent;
|
|
5895
6046
|
exports.defineComponent = defineComponent;
|
|
5896
6047
|
exports.defineEmit = defineEmit;
|
|
6048
|
+
exports.defineEmits = defineEmits;
|
|
6049
|
+
exports.defineExpose = defineExpose;
|
|
5897
6050
|
exports.defineProps = defineProps;
|
|
5898
6051
|
exports.getCurrentInstance = getCurrentInstance;
|
|
5899
6052
|
exports.getTransitionRawChildren = getTransitionRawChildren;
|
|
@@ -5903,6 +6056,7 @@ exports.initCustomFormatter = initCustomFormatter;
|
|
|
5903
6056
|
exports.inject = inject;
|
|
5904
6057
|
exports.isRuntimeOnly = isRuntimeOnly;
|
|
5905
6058
|
exports.isVNode = isVNode;
|
|
6059
|
+
exports.mergeDefaults = mergeDefaults;
|
|
5906
6060
|
exports.mergeProps = mergeProps;
|
|
5907
6061
|
exports.nextTick = nextTick;
|
|
5908
6062
|
exports.onActivated = onActivated;
|
|
@@ -5937,13 +6091,17 @@ exports.ssrContextKey = ssrContextKey;
|
|
|
5937
6091
|
exports.ssrUtils = ssrUtils;
|
|
5938
6092
|
exports.toHandlers = toHandlers;
|
|
5939
6093
|
exports.transformVNodeArgs = transformVNodeArgs;
|
|
6094
|
+
exports.useAttrs = useAttrs;
|
|
5940
6095
|
exports.useContext = useContext;
|
|
5941
6096
|
exports.useSSRContext = useSSRContext;
|
|
6097
|
+
exports.useSlots = useSlots;
|
|
5942
6098
|
exports.useTransitionState = useTransitionState;
|
|
5943
6099
|
exports.version = version;
|
|
5944
6100
|
exports.warn = warn;
|
|
5945
6101
|
exports.watch = watch;
|
|
5946
6102
|
exports.watchEffect = watchEffect;
|
|
6103
|
+
exports.withAsyncContext = withAsyncContext;
|
|
5947
6104
|
exports.withCtx = withCtx;
|
|
6105
|
+
exports.withDefaults = withDefaults;
|
|
5948
6106
|
exports.withDirectives = withDirectives;
|
|
5949
6107
|
exports.withScopeId = withScopeId;
|