vue 2.7.0-alpha.4 → 2.7.0-alpha.7

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.
Files changed (58) hide show
  1. package/dist/compiler-sfc.js +14 -0
  2. package/dist/vue.common.dev.js +33 -27
  3. package/dist/vue.common.prod.js +3 -3
  4. package/dist/vue.esm.browser.js +33 -27
  5. package/dist/vue.esm.browser.min.js +3 -3
  6. package/dist/vue.esm.js +33 -27
  7. package/dist/vue.js +33 -27
  8. package/dist/vue.min.js +3 -3
  9. package/dist/vue.runtime.common.dev.js +26 -21
  10. package/dist/vue.runtime.common.prod.js +3 -3
  11. package/dist/vue.runtime.esm.js +26 -21
  12. package/dist/vue.runtime.js +26 -21
  13. package/dist/vue.runtime.min.js +3 -3
  14. package/dist/vue.runtime.mjs +26 -21
  15. package/package.json +25 -21
  16. package/packages/compiler-sfc/api-extractor.json +64 -0
  17. package/packages/compiler-sfc/dist/compiler-sfc.d.ts +259 -0
  18. package/packages/compiler-sfc/dist/compiler-sfc.js +17610 -2
  19. package/packages/compiler-sfc/node_modules/.bin/lessc +17 -0
  20. package/packages/compiler-sfc/node_modules/.bin/sass +2 -2
  21. package/packages/compiler-sfc/node_modules/.bin/stylus +17 -0
  22. package/packages/compiler-sfc/package.json +17 -12
  23. package/packages/compiler-sfc/src/babelUtils.ts +423 -0
  24. package/packages/compiler-sfc/src/compileScript.ts +1948 -0
  25. package/packages/compiler-sfc/src/compileStyle.ts +143 -0
  26. package/packages/compiler-sfc/src/compileTemplate.ts +197 -0
  27. package/packages/compiler-sfc/src/index.ts +15 -0
  28. package/packages/compiler-sfc/src/parse.ts +117 -0
  29. package/packages/compiler-sfc/src/{parser.ts → parseComponent.ts} +86 -17
  30. package/packages/compiler-sfc/src/stripWith.ts +60 -0
  31. package/packages/compiler-sfc/src/stylePlugins/scoped.ts +207 -0
  32. package/packages/compiler-sfc/src/stylePlugins/trim.ts +18 -0
  33. package/packages/compiler-sfc/src/stylePreprocessors.ts +135 -0
  34. package/packages/compiler-sfc/src/templateCompilerModules/assetUrl.ts +80 -0
  35. package/packages/compiler-sfc/src/templateCompilerModules/srcset.ts +76 -0
  36. package/packages/compiler-sfc/src/templateCompilerModules/utils.ts +64 -0
  37. package/packages/compiler-sfc/src/types.ts +95 -0
  38. package/packages/compiler-sfc/src/warn.ts +16 -0
  39. package/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap +1393 -0
  40. package/packages/compiler-sfc/test/compileScript.spec.ts +1708 -0
  41. package/packages/compiler-sfc/test/compileStyle.spec.ts +203 -0
  42. package/packages/compiler-sfc/test/compileTemplate.spec.ts +229 -0
  43. package/packages/compiler-sfc/test/parseComponent.spec.ts +266 -0
  44. package/packages/compiler-sfc/test/stripWith.spec.ts +55 -0
  45. package/packages/compiler-sfc/test/stylePluginScoped.spec.ts +137 -0
  46. package/packages/compiler-sfc/test/tsconfig.json +7 -0
  47. package/src/compiler/codegen/index.ts +0 -1
  48. package/src/compiler/helpers.ts +2 -2
  49. package/src/compiler/parser/html-parser.ts +17 -3
  50. package/src/compiler/parser/index.ts +7 -5
  51. package/src/core/instance/render.ts +2 -1
  52. package/src/core/vdom/helpers/normalize-scoped-slots.ts +23 -18
  53. package/src/platforms/web/entry-compiler.ts +1 -1
  54. package/src/types/compiler.ts +5 -27
  55. package/src/v3/apiSetup.ts +6 -1
  56. package/types/index.d.ts +1 -0
  57. package/types/jsx.d.ts +1337 -0
  58. package/src/platforms/web/entry-compiler-sfc.ts +0 -1
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var compilerSfc = require('@vue/compiler-sfc');
6
+
7
+
8
+
9
+ Object.keys(compilerSfc).forEach(function (k) {
10
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () { return compilerSfc[k]; }
13
+ });
14
+ });
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.0-alpha.4
2
+ * Vue.js v2.7.0-alpha.7
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -1492,6 +1492,9 @@ function initSetup(vm) {
1492
1492
  if (!isReserved(key)) {
1493
1493
  proxySetupProperty(vm, setupResult, key);
1494
1494
  }
1495
+ else {
1496
+ warn$2("Avoid using variables that start with _ or $ in setup().");
1497
+ }
1495
1498
  }
1496
1499
  }
1497
1500
  else if (setupResult !== undefined) {
@@ -1517,7 +1520,10 @@ function createSetupContext(vm) {
1517
1520
  get slots() {
1518
1521
  return initSlotsProxy(vm);
1519
1522
  },
1520
- emit: bind$1(vm.$emit, vm)
1523
+ emit: bind$1(vm.$emit, vm),
1524
+ expose: function () {
1525
+ // TODO
1526
+ }
1521
1527
  };
1522
1528
  }
1523
1529
  function initAttrsProxy(vm) {
@@ -2261,34 +2267,33 @@ function isAsyncPlaceholder(node) {
2261
2267
  return node.isComment && node.asyncFactory;
2262
2268
  }
2263
2269
 
2264
- function normalizeScopedSlots(ownerVm, slots, normalSlots) {
2270
+ function normalizeScopedSlots(ownerVm, scopedSlots, normalSlots, prevScopedSlots) {
2265
2271
  var res;
2266
- var prevSlots = ownerVm.$scopedSlots;
2267
2272
  var hasNormalSlots = Object.keys(normalSlots).length > 0;
2268
- var isStable = slots ? !!slots.$stable : !hasNormalSlots;
2269
- var key = slots && slots.$key;
2270
- if (!slots) {
2273
+ var isStable = scopedSlots ? !!scopedSlots.$stable : !hasNormalSlots;
2274
+ var key = scopedSlots && scopedSlots.$key;
2275
+ if (!scopedSlots) {
2271
2276
  res = {};
2272
2277
  }
2273
- else if (slots._normalized) {
2278
+ else if (scopedSlots._normalized) {
2274
2279
  // fast path 1: child component re-render only, parent did not change
2275
- return slots._normalized;
2280
+ return scopedSlots._normalized;
2276
2281
  }
2277
2282
  else if (isStable &&
2278
- prevSlots &&
2279
- prevSlots !== emptyObject &&
2280
- key === prevSlots.$key &&
2283
+ prevScopedSlots &&
2284
+ prevScopedSlots !== emptyObject &&
2285
+ key === prevScopedSlots.$key &&
2281
2286
  !hasNormalSlots &&
2282
- !prevSlots.$hasNormal) {
2287
+ !prevScopedSlots.$hasNormal) {
2283
2288
  // fast path 2: stable scoped slots w/ no normal slots to proxy,
2284
2289
  // only need to normalize once
2285
- return prevSlots;
2290
+ return prevScopedSlots;
2286
2291
  }
2287
2292
  else {
2288
2293
  res = {};
2289
- for (var key_1 in slots) {
2290
- if (slots[key_1] && key_1[0] !== '$') {
2291
- res[key_1] = normalizeScopedSlot(ownerVm, normalSlots, key_1, slots[key_1]);
2294
+ for (var key_1 in scopedSlots) {
2295
+ if (scopedSlots[key_1] && key_1[0] !== '$') {
2296
+ res[key_1] = normalizeScopedSlot(ownerVm, normalSlots, key_1, scopedSlots[key_1]);
2292
2297
  }
2293
2298
  }
2294
2299
  }
@@ -2300,8 +2305,8 @@ function normalizeScopedSlots(ownerVm, slots, normalSlots) {
2300
2305
  }
2301
2306
  // avoriaz seems to mock a non-extensible $scopedSlots object
2302
2307
  // and when that is passed down this would cause an error
2303
- if (slots && Object.isExtensible(slots)) {
2304
- slots._normalized = res;
2308
+ if (scopedSlots && Object.isExtensible(scopedSlots)) {
2309
+ scopedSlots._normalized = res;
2305
2310
  }
2306
2311
  def(res, '$stable', isStable);
2307
2312
  def(res, '$key', key);
@@ -3087,7 +3092,7 @@ function renderMixin(Vue) {
3087
3092
  var vm = this;
3088
3093
  var _a = vm.$options, render = _a.render, _parentVnode = _a._parentVnode;
3089
3094
  if (_parentVnode) {
3090
- vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots);
3095
+ vm.$scopedSlots = normalizeScopedSlots(vm.$parent, _parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
3091
3096
  if (vm._slotsProxy) {
3092
3097
  syncSetupSlots(vm._slotsProxy, vm.$scopedSlots);
3093
3098
  }
@@ -5798,7 +5803,7 @@ Object.defineProperty(Vue.prototype, '$ssrContext', {
5798
5803
  Object.defineProperty(Vue, 'FunctionalRenderContext', {
5799
5804
  value: FunctionalRenderContext
5800
5805
  });
5801
- Vue.version = '2.7.0-alpha.4';
5806
+ Vue.version = '2.7.0-alpha.7';
5802
5807
 
5803
5808
  // these are reserved for web because they are directly compiled away
5804
5809
  // during template compilation
@@ -9209,7 +9214,7 @@ function parseHTML(html, options) {
9209
9214
  if (comment.test(html)) {
9210
9215
  var commentEnd = html.indexOf('-->');
9211
9216
  if (commentEnd >= 0) {
9212
- if (options.shouldKeepComment) {
9217
+ if (options.shouldKeepComment && options.comment) {
9213
9218
  options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
9214
9219
  }
9215
9220
  advance(commentEnd + 3);
@@ -9619,10 +9624,12 @@ function parse(template, options) {
9619
9624
  attrs.forEach(function (attr) {
9620
9625
  if (invalidAttributeRE.test(attr.name)) {
9621
9626
  warn("Invalid dynamic argument expression: attribute names cannot contain " +
9622
- "spaces, quotes, <, >, / or =.", {
9623
- start: attr.start + attr.name.indexOf("["),
9624
- end: attr.start + attr.name.length
9625
- });
9627
+ "spaces, quotes, <, >, / or =.", options.outputSourceRange
9628
+ ? {
9629
+ start: attr.start + attr.name.indexOf("["),
9630
+ end: attr.start + attr.name.length
9631
+ }
9632
+ : undefined);
9626
9633
  }
9627
9634
  });
9628
9635
  }
@@ -10639,7 +10646,6 @@ var CodegenState = /** @class */ (function () {
10639
10646
  function CodegenState(options) {
10640
10647
  this.options = options;
10641
10648
  this.warn = options.warn || baseWarn;
10642
- //@ts-expect-error `this.transforms ` is a different type than `options.modules.transformCode`
10643
10649
  this.transforms = pluckModuleFunction(options.modules, 'transformCode');
10644
10650
  this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
10645
10651
  this.directives = extend(extend({}, baseDirectives), options.directives);