vue 2.7.0-alpha.8 → 2.7.0-alpha.9
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/vue.common.dev.js +87 -20
- package/dist/vue.common.prod.js +3 -3
- package/dist/vue.esm.browser.js +87 -21
- package/dist/vue.esm.browser.min.js +3 -3
- package/dist/vue.esm.js +93 -21
- package/dist/vue.js +93 -20
- package/dist/vue.min.js +3 -3
- package/dist/vue.runtime.common.dev.js +69 -19
- package/dist/vue.runtime.common.prod.js +3 -3
- package/dist/vue.runtime.esm.js +73 -20
- package/dist/vue.runtime.js +73 -19
- package/dist/vue.runtime.min.js +3 -3
- package/dist/vue.runtime.mjs +73 -20
- package/package.json +2 -2
- package/packages/compiler-sfc/dist/compiler-sfc.d.ts +188 -15
- package/packages/compiler-sfc/dist/compiler-sfc.js +49 -17
- package/packages/compiler-sfc/package.json +1 -1
- package/packages/compiler-sfc/src/compileScript.ts +9 -8
- package/packages/compiler-sfc/src/compileTemplate.ts +21 -6
- package/packages/compiler-sfc/src/{stripWith.ts → prefixIdentifiers.ts} +33 -5
- package/packages/compiler-sfc/src/types.ts +3 -14
- package/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap +69 -138
- package/packages/compiler-sfc/test/compileScript.spec.ts +3 -3
- package/packages/compiler-sfc/test/{stripWith.spec.ts → prefixIdentifiers.spec.ts} +45 -6
- package/src/compiler/codegen/index.ts +21 -2
- package/src/core/config.ts +2 -2
- package/src/core/util/debug.ts +1 -1
- package/src/core/util/options.ts +1 -1
- package/src/core/vdom/modules/directives.ts +4 -1
- package/src/global.d.ts +1 -0
- package/src/types/compiler.ts +5 -0
- package/src/types/component.ts +1 -0
- package/src/types/options.ts +8 -6
- package/src/v3/apiSetup.ts +77 -17
- package/src/v3/apiWatch.ts +2 -4
- package/src/v3/index.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/v3-generated.d.ts +6 -4
- package/types/v3-setup-helpers.d.ts +150 -0
package/dist/vue.common.dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Vue.js v2.7.0-alpha.
|
|
2
|
+
* Vue.js v2.7.0-alpha.9
|
|
3
3
|
* (c) 2014-2022 Evan You
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -1444,12 +1444,22 @@ function initSetup(vm) {
|
|
|
1444
1444
|
`return a render function instead.`);
|
|
1445
1445
|
}
|
|
1446
1446
|
vm._setupState = setupResult;
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1447
|
+
// __sfc indicates compiled bindings from <script setup>
|
|
1448
|
+
if (!setupResult.__sfc) {
|
|
1449
|
+
for (const key in setupResult) {
|
|
1450
|
+
if (!isReserved(key)) {
|
|
1451
|
+
proxyWithRefUnwrap(vm, setupResult, key);
|
|
1452
|
+
}
|
|
1453
|
+
else {
|
|
1454
|
+
warn$2(`Avoid using variables that start with _ or $ in setup().`);
|
|
1455
|
+
}
|
|
1450
1456
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1457
|
+
}
|
|
1458
|
+
else {
|
|
1459
|
+
// exposed for compiled render fn
|
|
1460
|
+
const proxy = (vm._setupProxy = {});
|
|
1461
|
+
for (const key in setupResult) {
|
|
1462
|
+
proxyWithRefUnwrap(proxy, setupResult, key);
|
|
1453
1463
|
}
|
|
1454
1464
|
}
|
|
1455
1465
|
}
|
|
@@ -1458,17 +1468,17 @@ function initSetup(vm) {
|
|
|
1458
1468
|
}
|
|
1459
1469
|
}
|
|
1460
1470
|
}
|
|
1461
|
-
function
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
Object.defineProperty(vm, key, {
|
|
1471
|
+
function proxyWithRefUnwrap(target, source, key) {
|
|
1472
|
+
let raw = source[key];
|
|
1473
|
+
Object.defineProperty(target, key, {
|
|
1465
1474
|
enumerable: true,
|
|
1466
1475
|
configurable: true,
|
|
1467
|
-
get:
|
|
1468
|
-
set:
|
|
1476
|
+
get: () => (isRef(raw) ? raw.value : raw),
|
|
1477
|
+
set: newVal => isRef(raw) ? (raw.value = newVal) : (raw = source[key] = newVal)
|
|
1469
1478
|
});
|
|
1470
1479
|
}
|
|
1471
1480
|
function createSetupContext(vm) {
|
|
1481
|
+
let exposeCalled = false;
|
|
1472
1482
|
return {
|
|
1473
1483
|
get attrs() {
|
|
1474
1484
|
return initAttrsProxy(vm);
|
|
@@ -1477,8 +1487,16 @@ function createSetupContext(vm) {
|
|
|
1477
1487
|
return initSlotsProxy(vm);
|
|
1478
1488
|
},
|
|
1479
1489
|
emit: bind$1(vm.$emit, vm),
|
|
1480
|
-
expose() {
|
|
1481
|
-
|
|
1490
|
+
expose(exposed) {
|
|
1491
|
+
{
|
|
1492
|
+
if (exposeCalled) {
|
|
1493
|
+
warn$2(`expose() should be called only once per setup().`, vm);
|
|
1494
|
+
}
|
|
1495
|
+
exposeCalled = true;
|
|
1496
|
+
}
|
|
1497
|
+
if (exposed) {
|
|
1498
|
+
Object.keys(exposed).forEach(key => proxyWithRefUnwrap(vm, exposed, key));
|
|
1499
|
+
}
|
|
1482
1500
|
}
|
|
1483
1501
|
};
|
|
1484
1502
|
}
|
|
@@ -1552,6 +1570,34 @@ function getContext() {
|
|
|
1552
1570
|
}
|
|
1553
1571
|
const vm = currentInstance;
|
|
1554
1572
|
return vm._setupContext || (vm._setupContext = createSetupContext(vm));
|
|
1573
|
+
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Runtime helper for merging default declarations. Imported by compiled code
|
|
1576
|
+
* only.
|
|
1577
|
+
* @internal
|
|
1578
|
+
*/
|
|
1579
|
+
function mergeDefaults(raw, defaults) {
|
|
1580
|
+
const props = isArray(raw)
|
|
1581
|
+
? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
|
|
1582
|
+
: raw;
|
|
1583
|
+
for (const key in defaults) {
|
|
1584
|
+
const opt = props[key];
|
|
1585
|
+
if (opt) {
|
|
1586
|
+
if (isArray(opt) || isFunction(opt)) {
|
|
1587
|
+
props[key] = { type: opt, default: defaults[key] };
|
|
1588
|
+
}
|
|
1589
|
+
else {
|
|
1590
|
+
opt.default = defaults[key];
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
else if (opt === null) {
|
|
1594
|
+
props[key] = { default: defaults[key] };
|
|
1595
|
+
}
|
|
1596
|
+
else {
|
|
1597
|
+
warn$2(`props default key "${key}" has no corresponding declaration.`);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
return props;
|
|
1555
1601
|
}
|
|
1556
1602
|
|
|
1557
1603
|
const sharedPropertyDefinition = {
|
|
@@ -4095,8 +4141,8 @@ function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigge
|
|
|
4095
4141
|
}
|
|
4096
4142
|
}
|
|
4097
4143
|
const warnInvalidSource = (s) => {
|
|
4098
|
-
warn$2(`Invalid watch source:
|
|
4099
|
-
`a reactive object, or an array of these types.`);
|
|
4144
|
+
warn$2(`Invalid watch source: ${s}. A watch source can only be a getter/effect ` +
|
|
4145
|
+
`function, a ref, a reactive object, or an array of these types.`);
|
|
4100
4146
|
};
|
|
4101
4147
|
const instance = currentInstance;
|
|
4102
4148
|
const call = (fn, type, args = null) => invokeWithErrorHandling(fn, null, args, instance, type);
|
|
@@ -4536,6 +4582,7 @@ var vca = /*#__PURE__*/Object.freeze({
|
|
|
4536
4582
|
getCurrentInstance: getCurrentInstance,
|
|
4537
4583
|
useSlots: useSlots,
|
|
4538
4584
|
useAttrs: useAttrs,
|
|
4585
|
+
mergeDefaults: mergeDefaults,
|
|
4539
4586
|
nextTick: nextTick,
|
|
4540
4587
|
set: set,
|
|
4541
4588
|
del: del,
|
|
@@ -5192,7 +5239,7 @@ function resolveAsset(options, type, id, warnMissing) {
|
|
|
5192
5239
|
// fallback to prototype chain
|
|
5193
5240
|
const res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
|
|
5194
5241
|
if (warnMissing && !res) {
|
|
5195
|
-
warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id
|
|
5242
|
+
warn$2('Failed to resolve ' + type.slice(0, -1) + ': ' + id);
|
|
5196
5243
|
}
|
|
5197
5244
|
return res;
|
|
5198
5245
|
}
|
|
@@ -5729,7 +5776,7 @@ Object.defineProperty(Vue.prototype, '$ssrContext', {
|
|
|
5729
5776
|
Object.defineProperty(Vue, 'FunctionalRenderContext', {
|
|
5730
5777
|
value: FunctionalRenderContext
|
|
5731
5778
|
});
|
|
5732
|
-
Vue.version = '2.7.0-alpha.
|
|
5779
|
+
Vue.version = '2.7.0-alpha.9';
|
|
5733
5780
|
|
|
5734
5781
|
// these are reserved for web because they are directly compiled away
|
|
5735
5782
|
// during template compilation
|
|
@@ -6878,7 +6925,10 @@ function normalizeDirectives(dirs, vm) {
|
|
|
6878
6925
|
dir.modifiers = emptyModifiers;
|
|
6879
6926
|
}
|
|
6880
6927
|
res[getRawDirName(dir)] = dir;
|
|
6881
|
-
|
|
6928
|
+
if (vm._setupState && vm._setupState.__sfc) {
|
|
6929
|
+
dir.def = resolveAsset(vm, '_setupState', 'v-' + dir.name);
|
|
6930
|
+
}
|
|
6931
|
+
dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
|
|
6882
6932
|
}
|
|
6883
6933
|
// $flow-disable-line
|
|
6884
6934
|
return res;
|
|
@@ -10609,8 +10659,19 @@ function genElement(el, state) {
|
|
|
10609
10659
|
if (!el.plain || (el.pre && state.maybeComponent(el))) {
|
|
10610
10660
|
data = genData(el, state);
|
|
10611
10661
|
}
|
|
10662
|
+
let tag;
|
|
10663
|
+
// check if this is a component in <script setup>
|
|
10664
|
+
const bindings = state.options.bindings;
|
|
10665
|
+
if (bindings && bindings.__isScriptSetup !== false) {
|
|
10666
|
+
tag =
|
|
10667
|
+
checkBindingType(bindings, el.tag) ||
|
|
10668
|
+
checkBindingType(bindings, camelize(el.tag)) ||
|
|
10669
|
+
checkBindingType(bindings, capitalize(camelize(el.tag)));
|
|
10670
|
+
}
|
|
10671
|
+
if (!tag)
|
|
10672
|
+
tag = `'${el.tag}'`;
|
|
10612
10673
|
const children = el.inlineTemplate ? null : genChildren(el, state, true);
|
|
10613
|
-
code = `_c(
|
|
10674
|
+
code = `_c(${tag}${data ? `,${data}` : '' // data
|
|
10614
10675
|
}${children ? `,${children}` : '' // children
|
|
10615
10676
|
})`;
|
|
10616
10677
|
}
|
|
@@ -10621,6 +10682,12 @@ function genElement(el, state) {
|
|
|
10621
10682
|
return code;
|
|
10622
10683
|
}
|
|
10623
10684
|
}
|
|
10685
|
+
function checkBindingType(bindings, key) {
|
|
10686
|
+
const type = bindings[key];
|
|
10687
|
+
if (type && type.startsWith('setup')) {
|
|
10688
|
+
return key;
|
|
10689
|
+
}
|
|
10690
|
+
}
|
|
10624
10691
|
// hoist static sub-trees out
|
|
10625
10692
|
function genStatic(el, state) {
|
|
10626
10693
|
el.staticProcessed = true;
|