babel-source 5.0.0.beta2 → 5.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/babel.js +62 -13
  3. data/lib/babel/source.rb +2 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTU2NzYxZWVkNjY3N2IyZjdlNzRlYzg3OWVjNjRhZTBhMjAwNDYxYg==
4
+ NGE4OWNjYTY1YmYxN2VmMGU1MjUyZGY2NTYwNDE3ZjQxYjBlOGU5OQ==
5
5
  data.tar.gz: !binary |-
6
- NDM3YjY3ZGFhNGUwNjM1MmYxZWZmNmQxMDU5YTI3YzI0N2EwYmIzOQ==
6
+ Y2VhMGZjZmQ4ZTQ4N2QzMWY2YjZmYTJjMjg3MDg5NjI5OWRjMmFlNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDdjZmRmNzJhMjg2MGQ1NjdiNTRkNzRjMWU1YjYyMjI4MWY1OTc2NjhmMDEy
10
- OGIxYzY3MTEzYmMyMTNhYzdhYWY0Njg4MDYzMzRlMGRhMWQ1NWMzOTgxMDc2
11
- OWVhNzlkOTlmZjEzNTZhMjE4ZGYyYmQ5YWJmYjAwMWU2MDRiYTQ=
9
+ Y2FhMTNiMmYzYjlmNWQyOTE3NjBmZDBkYTRjZDkzZTliYzRkNjgyODNkMTFi
10
+ YTYyNDI1YzYxZDZkMWQ3N2VjMTZkNDM4YWU0YTYxN2M5YWM2YTY5MTU5ODEw
11
+ NzA4NDRjMWI2NjczOWNmYThkMzdkYTk5ODZmYmJiNzVlYjBmMjk=
12
12
  data.tar.gz: !binary |-
13
- OTM5M2NkNDlhNWI3NDRjMjc0ZWZiNzNkZjYzN2NmZTM3YmYwODkzZDczOWUx
14
- YTdmY2ZiZjM1MTRlNjBlNTE1MmRiZmFkMTU3OGQ3MzVlNGE5ZjI0YjYzOWVj
15
- NGY5OWVlMDgxNDljNjkzYzk1MTkyN2IxMWUzNjhhNGU1NmQzY2Q=
13
+ MDRkMzNmM2U5NzkyNTE2MDZiZjU3MTUzYjQ4NTMyY2I2NGVlZTU3NGI1NWMx
14
+ YWVjOWU1ODI5NDAyMzFjYTE1NjAzOTQxM2ExOGI2ZGI5Mjg4NjQ5MzM5ZTY0
15
+ MmE2NWE3MmU5MTIzZTM1OTg4OWRjODE0Yjc0NTU0ZjQyZTQ3N2M=
@@ -8761,6 +8761,13 @@ module.exports={
8761
8761
  "shorthand": "L"
8762
8762
  },
8763
8763
 
8764
+ "jsxPragma": {
8765
+ "type": "string",
8766
+ "description": "Custom pragma to use with JSX (same functionality as @jsx comments)",
8767
+ "default": "React.createElement",
8768
+ "shorthand": "P"
8769
+ },
8770
+
8764
8771
  "ignore": {
8765
8772
  "type": "list"
8766
8773
  },
@@ -15333,7 +15340,7 @@ var t = _interopRequireWildcard(require("../../../types"));
15333
15340
  var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
15334
15341
 
15335
15342
  function Program(node, parent, scope, file) {
15336
- var id = "React.createElement";
15343
+ var id = file.opts.jsxPragma;
15337
15344
 
15338
15345
  for (var i = 0; i < file.ast.comments.length; i++) {
15339
15346
  var comment = file.ast.comments[i];
@@ -16570,7 +16577,16 @@ var TraversalPath = (function () {
16570
16577
  TraversalPath.prototype.insertBefore = function insertBefore(nodes) {
16571
16578
  this.checkNodes(nodes);
16572
16579
 
16573
- if (this.isPreviousType("Expression")) {
16580
+ if (this.isPreviousType("Statement")) {
16581
+ if (Array.isArray(this.container)) {
16582
+ this._containerInsertBefore(nodes);
16583
+ } else if (this.isStatementOrBlock()) {
16584
+ if (this.node) nodes.push(this.node);
16585
+ this.container[this.key] = t.blockStatement(nodes);
16586
+ } else {
16587
+ throw new Error("no idea what to do with this");
16588
+ }
16589
+ } else if (this.isPreviousType("Expression")) {
16574
16590
  if (this.node) nodes.push(this.node);
16575
16591
  this.replaceExpressionWithStatements(nodes);
16576
16592
  } else {
@@ -16578,11 +16594,11 @@ var TraversalPath = (function () {
16578
16594
  }
16579
16595
  };
16580
16596
 
16581
- TraversalPath.prototype._containerInsertAfter = function _containerInsertAfter(nodes) {
16582
- this.updateSiblingKeys(this.key + 1, nodes.length);
16597
+ TraversalPath.prototype._containerInsert = function _containerInsert(from, nodes) {
16598
+ this.updateSiblingKeys(from, nodes.length);
16583
16599
 
16584
16600
  for (var i = 0; i < nodes.length; i++) {
16585
- var to = this.key + 1 + i;
16601
+ var to = from + i;
16586
16602
  this.container.splice(to, 0, nodes[i]);
16587
16603
 
16588
16604
  if (this.context) {
@@ -16591,13 +16607,26 @@ var TraversalPath = (function () {
16591
16607
  }
16592
16608
  };
16593
16609
 
16610
+ TraversalPath.prototype._containerInsertBefore = function _containerInsertBefore(nodes) {
16611
+ this._containerInsert(this.key, nodes);
16612
+ };
16613
+
16614
+ TraversalPath.prototype._containerInsertAfter = function _containerInsertAfter(nodes) {
16615
+ this._containerInsert(this.key + 1, nodes);
16616
+ };
16617
+
16618
+ TraversalPath.prototype.isStatementOrBlock = function isStatementOrBlock() {
16619
+ return includes(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.container);
16620
+ };
16621
+
16594
16622
  TraversalPath.prototype.insertAfter = function insertAfter(nodes) {
16595
16623
  this.checkNodes(nodes);
16596
16624
 
16597
16625
  if (this.isPreviousType("Statement")) {
16598
16626
  if (Array.isArray(this.container)) {
16599
16627
  this._containerInsertAfter(nodes);
16600
- } else if (includes(t.STATEMENT_OR_BLOCK_KEYS, this.key) && !t.isBlockStatement(this.container)) {
16628
+ } else if (this.isStatementOrBlock()) {
16629
+ if (this.node) nodes.unshift(this.node);
16601
16630
  this.container[this.key] = t.blockStatement(nodes);
16602
16631
  } else {
16603
16632
  throw new Error("no idea what to do with this");
@@ -16766,6 +16795,24 @@ var TraversalPath = (function () {
16766
16795
  }
16767
16796
  };
16768
16797
 
16798
+ TraversalPath.prototype.getStatementParent = function getStatementParent() {
16799
+ var path = this;
16800
+
16801
+ do {
16802
+ if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
16803
+ break;
16804
+ } else {
16805
+ path = path.parentPath;
16806
+ }
16807
+ } while (path);
16808
+
16809
+ if (path && (path.isProgram() || path.isFile())) {
16810
+ throw new Error("File/Program node, we can't possibly find a statement parent to this");
16811
+ }
16812
+
16813
+ return path;
16814
+ };
16815
+
16769
16816
  TraversalPath.prototype.getLastStatements = function getLastStatements() {
16770
16817
  var paths = [];
16771
16818
 
@@ -17987,15 +18034,15 @@ module.exports={
17987
18034
  "UnionTypeAnnotation": ["Flow"],
17988
18035
  "VoidTypeAnnotation": ["Flow"],
17989
18036
 
17990
- "JSXAttribute": ["JSX"],
17991
- "JSXClosingElement": ["JSX"],
17992
- "JSXElement": ["JSX", "Expression"],
17993
- "JSXEmptyExpression": ["JSX"],
17994
- "JSXExpressionContainer": ["JSX"],
18037
+ "JSXAttribute": ["JSX", "Immutable"],
18038
+ "JSXClosingElement": ["JSX", "Immutable"],
18039
+ "JSXElement": ["JSX", "Immutable", "Expression"],
18040
+ "JSXEmptyExpression": ["JSX", "Immutable"],
18041
+ "JSXExpressionContainer": ["JSX", "Immutable"],
17995
18042
  "JSXIdentifier": ["JSX"],
17996
18043
  "JSXMemberExpression": ["JSX"],
17997
18044
  "JSXNamespacedName": ["JSX"],
17998
- "JSXOpeningElement": ["JSX"],
18045
+ "JSXOpeningElement": ["JSX", "Immutable"],
17999
18046
  "JSXSpreadAttribute": ["JSX"]
18000
18047
  }
18001
18048
 
@@ -19133,6 +19180,8 @@ function isScope(node, parent) {
19133
19180
  }
19134
19181
 
19135
19182
  function isImmutable(node) {
19183
+ if (t.isType(node.type, "Immutable")) return true;
19184
+
19136
19185
  if (t.isLiteral(node)) {
19137
19186
  if (node.regex) {
19138
19187
  // regexes are mutable
@@ -47989,7 +48038,7 @@ module.exports = function (str) {
47989
48038
  module.exports={
47990
48039
  "name": "babel",
47991
48040
  "description": "Turn ES6 code into readable vanilla ES5 with source maps",
47992
- "version": "5.0.0-beta2",
48041
+ "version": "5.0.0-beta3",
47993
48042
  "author": "Sebastian McKenzie <sebmck@gmail.com>",
47994
48043
  "homepage": "https://babeljs.io/",
47995
48044
  "repository": "babel/babel",
@@ -1,7 +1,7 @@
1
1
  module Babel
2
2
  module Source
3
- VERSION = "5.0.0.beta2"
4
- DATE = Time.at(1427482017)
3
+ VERSION = "5.0.0.beta3"
4
+ DATE = Time.at(1427554350)
5
5
  PATH = File.expand_path("../..", __FILE__)
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babel-source
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta2
4
+ version: 5.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian McKenzie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-27 00:00:00.000000000 Z
11
+ date: 2015-03-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: sebmck@gmail.com