babel-source 5.3.1 → 5.3.2

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 (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/babel.js +80 -49
  3. data/lib/babel/source.rb +2 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTMxNjJhYjQ5OGE1ODFhNjBhNDI2NGQyMmQzNjc5YTYyNzk3MWYxNQ==
4
+ ZTViYzFmZGI5ZmIwZDNlZWUzNmM0MjI5NDU2MTA4Y2M0OTViYzRlZg==
5
5
  data.tar.gz: !binary |-
6
- NjA5ZGRmZjQ4MjM4ZmRiNTYxNmZiZDdlZTI0MjcxMjZhZGY5NTkzMQ==
6
+ NTkwODdhODA3ZWVhYTAyOWUzN2Y0MTk0YzdkMmRkZjFkNjNmOGZiYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTRlMjQ5MWU5ZWNkMjY5Zjk3MTViNjIwNzUxYzRiNjgzOWI0ZDQ5YjVkMTVk
10
- NTY1MzVkNGNmNGMwMDI1ODU1NGQzZWE1YWMxN2E3MzE0MDQ3MjY2YzMzOTlm
11
- ODJmMDQyZGQzNGU0MzYyNzMxMGMzYjg5YjRkYjIyYjgxMzY0YWQ=
9
+ YzdlZDIxZGFjZmE2M2M0YThmNzRhMzhjMGZiMTIxN2M3ZjY0NjUwMjFlNTI4
10
+ ZmM3YzU3Yjg5MmY3NTViOGNmYmY3ZDJiZjM0MmE5NWRhNTdiOTJlYzI3ZGU0
11
+ OGZlYzdjYjQwNGY2ZTFlOWY0MzZiODM2NzA3OTZmYjBlZWExZjY=
12
12
  data.tar.gz: !binary |-
13
- OTM3YmMzZmNiYjQ5YThmMDJjMmUyMjlmZmY3YzY4ZWEyNjQ0MGFlY2UzMjcy
14
- N2Q3NzRkNmY3ZjYwYWFkNWM3NTJkMjkzMzQ2NzEwMWNlNjc0Y2MxMjljMjQ1
15
- ZTI0OTZjODlkZWRmMTg3ZTM1ZjA5YzMyODA0N2I5YmY5MDk0MmE=
13
+ YTc2MjBkMWQ3NzMwYzI0NzU0Y2UxMmNkMzExMjU4NjQ1ZDhiOTRkZDg5ZjZj
14
+ Y2Y1Mzk2YWM2YjMzYzNlZTg4MzUyZGVjNGJlYWRmMzM3N2QwZDU1MDk4ZTVm
15
+ ZmM3ZGI0NzI5OTlmMTFkYmRhNTk2YTBhZTQxMjRhY2Q2OGI1YTI=
@@ -8549,16 +8549,6 @@ var File = (function () {
8549
8549
  this.path = _traversalPath2["default"].get(null, null, ast, ast, "program", this);
8550
8550
  this.scope = this.path.scope;
8551
8551
  this.ast = ast;
8552
-
8553
- this.path.traverse({
8554
- enter: function enter(node, parent, scope) {
8555
- if (this.isScope()) {
8556
- for (var key in scope.bindings) {
8557
- scope.bindings[key].setTypeAnnotation();
8558
- }
8559
- }
8560
- }
8561
- });
8562
8552
  };
8563
8553
 
8564
8554
  File.prototype.addAst = function addAst(ast) {
@@ -12925,9 +12915,13 @@ var BlockScoping = (function () {
12925
12915
  */
12926
12916
 
12927
12917
  BlockScoping.prototype.pushDeclar = function pushDeclar(node) {
12928
- this.body.push(t.variableDeclaration(node.kind, node.declarations.map(function (declar) {
12929
- return t.variableDeclarator(declar.id);
12930
- })));
12918
+ var declars = [];
12919
+ var names = t.getBindingIdentifiers(node);
12920
+ for (var name in names) {
12921
+ declars.push(t.variableDeclarator(names[name]));
12922
+ }
12923
+
12924
+ this.body.push(t.variableDeclaration(node.kind, declars));
12931
12925
 
12932
12926
  var replace = [];
12933
12927
 
@@ -13833,7 +13827,7 @@ function VariableDeclaration(node, parent, scope, file) {
13833
13827
  file: file
13834
13828
  });
13835
13829
 
13836
- if (t.isPattern(pattern) && patternId) {
13830
+ if (t.isPattern(pattern)) {
13837
13831
  destructuring.init(pattern, patternId);
13838
13832
 
13839
13833
  if (+i !== node.declarations.length - 1) {
@@ -14675,7 +14669,8 @@ var hasRest = function hasRest(node) {
14675
14669
  function Func(node, parent, scope, file) {
14676
14670
  if (!hasRest(node)) return;
14677
14671
 
14678
- var rest = node.params.pop().argument;
14672
+ var restParam = node.params.pop();
14673
+ var rest = restParam.argument;
14679
14674
 
14680
14675
  var argsId = t.identifier("arguments");
14681
14676
 
@@ -14740,6 +14735,7 @@ function Func(node, parent, scope, file) {
14740
14735
  }
14741
14736
 
14742
14737
  var loop = util.template("rest", {
14738
+ ARRAY_TYPE: restParam.typeAnnotation,
14743
14739
  ARGUMENTS: argsId,
14744
14740
  ARRAY_KEY: arrKey,
14745
14741
  ARRAY_LEN: arrLen,
@@ -16514,7 +16510,7 @@ function Property(node, parent, scope, file) {
16514
16510
  "use strict";
16515
16511
 
16516
16512
  exports.__esModule = true;
16517
- exports.Identifier = Identifier;
16513
+ exports.ReferencedIdentifier = ReferencedIdentifier;
16518
16514
  exports.FunctionDeclaration = FunctionDeclaration;
16519
16515
  exports.VariableDeclarator = VariableDeclarator;
16520
16516
  exports.ConditionalExpression = ConditionalExpression;
@@ -16549,9 +16545,7 @@ var metadata = {
16549
16545
 
16550
16546
  exports.metadata = metadata;
16551
16547
 
16552
- function Identifier(node, parent, scope) {
16553
- if (!this.isReferenced()) return;
16554
-
16548
+ function ReferencedIdentifier(node, parent, scope) {
16555
16549
  var binding = scope.getBinding(node.name);
16556
16550
  if (!binding || binding.references > 1 || !binding.constant) return;
16557
16551
  if (binding.kind === "param") return;
@@ -16560,10 +16554,10 @@ function Identifier(node, parent, scope) {
16560
16554
  if (t.isVariableDeclarator(replacement)) {
16561
16555
  replacement = replacement.init;
16562
16556
  }
16563
- t.toExpression(replacement);
16557
+ if (!replacement) return;
16564
16558
 
16559
+ t.toExpression(replacement);
16565
16560
  scope.removeBinding(node.name);
16566
-
16567
16561
  binding.path.remove();
16568
16562
  return replacement;
16569
16563
  }
@@ -16652,7 +16646,6 @@ exports.IfStatement = IfStatement;
16652
16646
  "use strict";
16653
16647
 
16654
16648
  exports.__esModule = true;
16655
- exports.Expression = Expression;
16656
16649
  exports.Identifier = Identifier;
16657
16650
 
16658
16651
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
@@ -16667,11 +16660,14 @@ var metadata = {
16667
16660
  };
16668
16661
 
16669
16662
  exports.metadata = metadata;
16663
+ var Expression = {
16664
+ exit: function exit(node, parent, scope) {
16665
+ var res = this.evaluate();
16666
+ if (res.confident) return t.valueToNode(res.value);
16667
+ }
16668
+ };
16670
16669
 
16671
- function Expression(node, parent, scope) {
16672
- var res = this.evaluate();
16673
- if (res.confident) return t.valueToNode(res.value);
16674
- }
16670
+ exports.Expression = Expression;
16675
16671
 
16676
16672
  function Identifier() {}
16677
16673
 
@@ -17203,6 +17199,7 @@ exports.metadata = metadata;
17203
17199
 
17204
17200
  function Program(ast) {
17205
17201
  _regenerator2["default"].transform(ast);
17202
+ this.stop();
17206
17203
  }
17207
17204
  },{"../../../types":167,"regenerator":456}],144:[function(require,module,exports){
17208
17205
  module.exports={
@@ -17935,6 +17932,15 @@ var Binding = (function () {
17935
17932
  this.references++;
17936
17933
  };
17937
17934
 
17935
+ /**
17936
+ * Description
17937
+ */
17938
+
17939
+ Binding.prototype.dereference = function dereference() {
17940
+ this.references--;
17941
+ this.referenced = !!this.references;
17942
+ };
17943
+
17938
17944
  /**
17939
17945
  * Description
17940
17946
  */
@@ -18316,6 +18322,8 @@ function evaluate() {
18316
18322
  return +arg;
18317
18323
  case "-":
18318
18324
  return -arg;
18325
+ case "~":
18326
+ return ~arg;
18319
18327
  }
18320
18328
  }
18321
18329
 
@@ -18406,11 +18414,13 @@ var referenceVisitor = {
18406
18414
  // eg. it's in a closure etc
18407
18415
  if (bindingInfo !== state.scope.getBinding(node.name)) return;
18408
18416
 
18409
- if (bindingInfo && bindingInfo.constant) {
18410
- state.bindings[node.name] = bindingInfo;
18411
- } else {
18412
- state.foundIncompatible = true;
18413
- this.stop();
18417
+ if (bindingInfo) {
18418
+ if (bindingInfo.constant) {
18419
+ state.bindings[node.name] = bindingInfo;
18420
+ } else {
18421
+ state.foundIncompatible = true;
18422
+ this.stop();
18423
+ }
18414
18424
  }
18415
18425
  }
18416
18426
  }
@@ -18803,14 +18813,16 @@ var TraversalPath = (function () {
18803
18813
  paths.push(TraversalPath.get(this, null, node, this.container, to));
18804
18814
  }
18805
18815
  }
18816
+
18817
+ return paths;
18806
18818
  };
18807
18819
 
18808
18820
  TraversalPath.prototype._containerInsertBefore = function _containerInsertBefore(nodes) {
18809
- this._containerInsert(this.key, nodes);
18821
+ return this._containerInsert(this.key, nodes);
18810
18822
  };
18811
18823
 
18812
18824
  TraversalPath.prototype._containerInsertAfter = function _containerInsertAfter(nodes) {
18813
- this._containerInsert(this.key + 1, nodes);
18825
+ return this._containerInsert(this.key + 1, nodes);
18814
18826
  };
18815
18827
 
18816
18828
  TraversalPath.prototype._maybePopFromStatements = function _maybePopFromStatements(nodes) {
@@ -19518,7 +19530,7 @@ var TraversalPath = (function () {
19518
19530
  annotation: null
19519
19531
  };
19520
19532
 
19521
- var type = this.node.typeAnnotation;
19533
+ var type = this.node && this.node.typeAnnotation;
19522
19534
 
19523
19535
  if (!type) {
19524
19536
  info.inferred = true;
@@ -19547,7 +19559,7 @@ var TraversalPath = (function () {
19547
19559
  if (!binding || !binding.constant) return;
19548
19560
 
19549
19561
  // todo: take into consideration infinite recursion #1149
19550
- return;
19562
+ //return;
19551
19563
 
19552
19564
  if (binding.path === this) {
19553
19565
  return this;
@@ -19593,36 +19605,36 @@ var TraversalPath = (function () {
19593
19605
  path = path.resolve();
19594
19606
  if (!path) return;
19595
19607
 
19596
- if (path.isRestElement() || path.parentPath.isRestElement() || path.isArrayExpression()) {
19608
+ if (path.isPreviousType("RestElement") || path.parentPath.isPreviousType("RestElement") || path.isPreviousType("ArrayExpression")) {
19597
19609
  return t.genericTypeAnnotation(t.identifier("Array"));
19598
19610
  }
19599
19611
 
19600
- if (path.parentPath.isTypeCastExpression()) {
19612
+ if (path.parentPath.isPreviousType("TypeCastExpression")) {
19601
19613
  return path.parentPath.node.typeAnnotation;
19602
19614
  }
19603
19615
 
19604
- if (path.isTypeCastExpression()) {
19616
+ if (path.isPreviousType("TypeCastExpression")) {
19605
19617
  return path.node.typeAnnotation;
19606
19618
  }
19607
19619
 
19608
- if (path.isObjectExpression()) {
19620
+ if (path.isPreviousType("ObjectExpression")) {
19609
19621
  return t.genericTypeAnnotation(t.identifier("Object"));
19610
19622
  }
19611
19623
 
19612
- if (path.isFunction()) {
19624
+ if (path.isPreviousType("Function")) {
19613
19625
  return t.identifier("Function");
19614
19626
  }
19615
19627
 
19616
- if (path.isLiteral()) {
19628
+ if (path.isPreviousType("Literal")) {
19617
19629
  var value = path.node.value;
19618
19630
  if ((0, _lodashLangIsString2["default"])(value)) return t.stringTypeAnnotation();
19619
19631
  if ((0, _lodashLangIsNumber2["default"])(value)) return t.numberTypeAnnotation();
19620
19632
  if ((0, _lodashLangIsBoolean2["default"])(value)) return t.booleanTypeAnnotation();
19621
19633
  }
19622
19634
 
19623
- if (path.isCallExpression()) {
19635
+ if (path.isPreviousType("CallExpression")) {
19624
19636
  var callee = path.get("callee").resolve();
19625
- if (callee && callee.isFunction()) return callee.node.returnType;
19637
+ if (callee && callee.isPreviousType("Function")) return callee.node.returnType;
19626
19638
  }
19627
19639
  };
19628
19640
 
@@ -20539,13 +20551,17 @@ var Scope = (function () {
20539
20551
  var declar = !unique && path.getData(dataKey);
20540
20552
 
20541
20553
  if (!declar) {
20542
- declar = t.variableDeclaration(opts.kind || "var", []);
20554
+ declar = t.variableDeclaration(kind, []);
20543
20555
  declar._generated = true;
20544
20556
  declar._blockHoist = 2;
20545
20557
 
20546
20558
  this.file.attachAuxiliaryComment(declar);
20547
20559
 
20548
- path.get("body")[0]._containerInsertBefore([declar]);
20560
+ var _path$get$0$_containerInsertBefore = path.get("body")[0]._containerInsertBefore([declar]);
20561
+
20562
+ var declarPath = _path$get$0$_containerInsertBefore[0];
20563
+
20564
+ this.registerBinding(kind, declarPath);
20549
20565
  if (!unique) path.setData(dataKey, declar);
20550
20566
  }
20551
20567
 
@@ -22180,12 +22196,27 @@ function isReferenced(node, parent) {
22180
22196
  return parent.id !== node;
22181
22197
 
22182
22198
  // no: export { foo as NODE };
22199
+ // yes: export { NODE as foo };
22200
+ // no: export { NODE as foo } from "foo";
22183
22201
  case "ExportSpecifier":
22184
- return parent.exported !== node;
22202
+ if (parent.source) {
22203
+ return false;
22204
+ } else {
22205
+ return parent.local === node;
22206
+ }
22207
+
22208
+ // no: import NODE from "foo";
22209
+ case "ImportDefaultSpecifier":
22210
+ return false;
22211
+
22212
+ // no: import * as NODE from "foo";
22213
+ case "ImportNamespaceSpecifier":
22214
+ return false;
22185
22215
 
22186
22216
  // no: import { NODE as foo } from "foo";
22217
+ // no: import { foo as NODE } from "foo";
22187
22218
  case "ImportSpecifier":
22188
- return parent.imported !== node;
22219
+ return false;
22189
22220
 
22190
22221
  // no: class NODE {}
22191
22222
  case "ClassDeclaration":
@@ -85869,7 +85900,7 @@ module.exports = function (str) {
85869
85900
  module.exports={
85870
85901
  "name": "babel-core",
85871
85902
  "description": "Turn ES6 code into readable vanilla ES5 with source maps",
85872
- "version": "5.3.1",
85903
+ "version": "5.3.2",
85873
85904
  "author": "Sebastian McKenzie <sebmck@gmail.com>",
85874
85905
  "homepage": "https://babeljs.io/",
85875
85906
  "license": "MIT",
@@ -85932,7 +85963,7 @@ module.exports={
85932
85963
  "user-home": "^1.1.1"
85933
85964
  },
85934
85965
  "devDependencies": {
85935
- "babel": "5.3.0",
85966
+ "babel": "5.3.1",
85936
85967
  "browserify": "^9.0.8",
85937
85968
  "chai": "^2.2.0",
85938
85969
  "eslint": "^0.18.0",
@@ -1,7 +1,7 @@
1
1
  module Babel
2
2
  module Source
3
- VERSION = "5.3.1"
4
- DATE = Time.at(1431483633)
3
+ VERSION = "5.3.2"
4
+ DATE = Time.at(1431543440)
5
5
  PATH = File.expand_path("../..", __FILE__)
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babel-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.1
4
+ version: 5.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian McKenzie