babel-source 4.7.8 → 4.7.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.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/babel.js +89 -55
  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
- MTFkZmQ2ZDY4YzMwN2Q4NjNjY2ZlOGJjMzNjZTQ2ZDc3MTI3NWQ1OQ==
4
+ ZWVmZGQ1MDVhMjVmMGRkMTlkNTk5ZDI3YzMzMmUwZGU2MzIwMGQ5OQ==
5
5
  data.tar.gz: !binary |-
6
- ZDRmMzdhMTE1ODMzY2FiMGRiZWI4Mjg4MDAzMGU5NmZlZjYwMmVmMA==
6
+ MWFhODgwNWY1MDllZmMyZGQ3NDQzYzg2NDk1Zjk1MjlmZTk0MDc0Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2RmMWI3Y2Q3NTk2MWFiZTdjMjU2YWZhZmFmZGQwY2M3OWYzOGVlNmE5YmIx
10
- NzQ1MTJkNGIwZTFhMDlmOGE5MjQyMWFhZWRjMzNhY2JiYWUxNjUwNTUxOGRl
11
- ODkyM2JjNTAxMjcxYTdjYjBjZWJlOTE0OWE2MWY0MTEwODkzNzA=
9
+ NjhiMGU3NmFjMjJiOTUyMmYzY2QwNzExNWY2NzE5MzliODZiMzI3YTI0NDdh
10
+ NDNlMTY4N2M2Njg3M2ViODMxNzU1NWI0ZDhmZGQxZTJhNTk4YzQ0MWVmNDVm
11
+ MmQxNjk4OWFhMDk2NDk2YmYxZDgxYWExYTc5NDRmN2I3MDAzZjc=
12
12
  data.tar.gz: !binary |-
13
- MDI2OTE4Y2RiMmY1MjE1YzQwNzUzMDk0MTA2Mzk5ZDk1Mzk3M2VjY2EwOGRj
14
- ZDMwMzIxOWU2NjY5MzZkNWNhMDRkYjkwY2IxZjRhYzRmMmJiNWEzMjU3MzM5
15
- YjE1MzBmMzVjNjlmYzdmYTkyZDNjNmMzNDY1NGM0MTY0NTdmNDc=
13
+ M2Q3N2MwNzVkNDc3OGZhZDgzMjI4MzEwNDU2OTU5YWNmODVhMzI0NTYwYTEz
14
+ YWFiNWI5NjE1YTBkOTBkMzcyMTUxNTQyNjMwZmE5YjBmMzdlYTg0NjY3YzQ1
15
+ YmRlOGQwMDkzODUzZTQ4NTRkODNkMGE4ZDNmZDg5NzlhZDlmZDc=
@@ -3084,7 +3084,7 @@ var File = (function () {
3084
3084
  returnUsedHelpers: false,
3085
3085
  externalHelpers: false,
3086
3086
  auxilaryComment: "",
3087
- inputSourceMap: false,
3087
+ inputSourceMap: null,
3088
3088
  experimental: false,
3089
3089
  reactCompat: false,
3090
3090
  playground: false,
@@ -3225,10 +3225,12 @@ var File = (function () {
3225
3225
  File.prototype.parseInputSourceMap = function parseInputSourceMap(code) {
3226
3226
  var opts = this.opts;
3227
3227
 
3228
- var inputMap = convertSourceMap.fromSource(code);
3229
- if (inputMap) {
3230
- opts.inputSourceMap = inputMap.toObject();
3231
- code = convertSourceMap.removeComments(code);
3228
+ if (opts.inputSourceMap === false) {
3229
+ var inputMap = convertSourceMap.fromSource(code);
3230
+ if (inputMap) {
3231
+ opts.inputSourceMap = inputMap.toObject();
3232
+ code = convertSourceMap.removeComments(code);
3233
+ }
3232
3234
  }
3233
3235
 
3234
3236
  return code;
@@ -4232,7 +4234,7 @@ function bare(node, parent, scope) {
4232
4234
  if (node.id) return node;
4233
4235
 
4234
4236
  var id;
4235
- if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
4237
+ if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
4236
4238
  // { foo() {} };
4237
4239
  id = parent.key;
4238
4240
  } else if (t.isVariableDeclarator(parent)) {
@@ -4242,9 +4244,16 @@ function bare(node, parent, scope) {
4242
4244
  return node;
4243
4245
  }
4244
4246
 
4245
- if (!t.isIdentifier(id)) return node;
4247
+ var name;
4248
+ if (t.isLiteral(id)) {
4249
+ name = id.value;
4250
+ } else if (t.isIdentifier(id)) {
4251
+ name = id.name;
4252
+ } else {
4253
+ return;
4254
+ }
4246
4255
 
4247
- var name = t.toIdentifier(id.name);
4256
+ name = t.toIdentifier(name);
4248
4257
  id = t.identifier(name);
4249
4258
 
4250
4259
  var state = visit(node, name, scope);
@@ -6149,8 +6158,9 @@ function Loop(node, parent, scope, file) {
6149
6158
  t.ensureBlock(node);
6150
6159
  node.body._letDeclarators = [init];
6151
6160
  }
6152
- var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
6153
- blockScoping.run();
6161
+
6162
+ var blockScoping = new BlockScoping(this, node.body, parent, scope, file);
6163
+ return blockScoping.run();
6154
6164
  }
6155
6165
 
6156
6166
  function BlockStatement(block, parent, scope, file) {
@@ -6302,10 +6312,9 @@ var BlockScoping = (function () {
6302
6312
  * Description
6303
6313
  */
6304
6314
 
6305
- function BlockScoping(loopParent, block, parent, scope, file) {
6315
+ function BlockScoping(loopPath, block, parent, scope, file) {
6306
6316
  _classCallCheck(this, BlockScoping);
6307
6317
 
6308
- this.loopParent = loopParent;
6309
6318
  this.parent = parent;
6310
6319
  this.scope = scope;
6311
6320
  this.block = block;
@@ -6315,6 +6324,12 @@ var BlockScoping = (function () {
6315
6324
  this.hasLetReferences = false;
6316
6325
  this.letReferences = block._letReferences = object();
6317
6326
  this.body = [];
6327
+
6328
+ if (loopPath) {
6329
+ this.loopParent = loopPath.parent;
6330
+ this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
6331
+ this.loop = loopPath.node;
6332
+ }
6318
6333
  }
6319
6334
 
6320
6335
  /**
@@ -6339,6 +6354,10 @@ var BlockScoping = (function () {
6339
6354
  } else {
6340
6355
  this.remap();
6341
6356
  }
6357
+
6358
+ if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
6359
+ return t.labeledStatement(this.loopLabel, this.loop);
6360
+ }
6342
6361
  };
6343
6362
 
6344
6363
  /**
@@ -6377,11 +6396,11 @@ var BlockScoping = (function () {
6377
6396
 
6378
6397
  //
6379
6398
 
6380
- var loopParent = this.loopParent;
6381
- if (loopParent) {
6382
- traverseReplace(loopParent.right, loopParent, scope, remaps);
6383
- traverseReplace(loopParent.test, loopParent, scope, remaps);
6384
- traverseReplace(loopParent.update, loopParent, scope, remaps);
6399
+ var loop = this.loop;
6400
+ if (loop) {
6401
+ traverseReplace(loop.right, loop, scope, remaps);
6402
+ traverseReplace(loop.test, loop, scope, remaps);
6403
+ traverseReplace(loop.update, loop, scope, remaps);
6385
6404
  }
6386
6405
 
6387
6406
  scope.traverse(this.block, replaceVisitor, remaps);
@@ -6397,7 +6416,7 @@ var BlockScoping = (function () {
6397
6416
  var outsideRefs = this.outsideLetReferences;
6398
6417
 
6399
6418
  // remap loop heads with colliding variables
6400
- if (this.loopParent) {
6419
+ if (this.loop) {
6401
6420
  for (var name in outsideRefs) {
6402
6421
  var id = outsideRefs[name];
6403
6422
 
@@ -6518,7 +6537,7 @@ var BlockScoping = (function () {
6518
6537
  ignoreLabeless: false,
6519
6538
  innerLabels: [],
6520
6539
  hasReturn: false,
6521
- isLoop: !!this.loopParent,
6540
+ isLoop: !!this.loop,
6522
6541
  map: {}
6523
6542
  };
6524
6543
 
@@ -6582,7 +6601,7 @@ var BlockScoping = (function () {
6582
6601
 
6583
6602
  body.push(t.variableDeclaration("var", [t.variableDeclarator(ret, call)]));
6584
6603
 
6585
- var loopParent = this.loopParent;
6604
+ var loop = this.loop;
6586
6605
  var retCheck;
6587
6606
  var has = this.has;
6588
6607
  var cases = [];
@@ -6595,8 +6614,8 @@ var BlockScoping = (function () {
6595
6614
  }
6596
6615
 
6597
6616
  if (has.hasBreakContinue) {
6598
- if (!loopParent) {
6599
- throw new Error("Has no loop parent but we're trying to reassign breaks " + "and continues, something is going wrong here.");
6617
+ if (!loop) {
6618
+ throw new Error("Aren't in a loop and we're trying to reassign breaks and continues, something is going wrong here.");
6600
6619
  }
6601
6620
 
6602
6621
  for (var key in has.map) {
@@ -6611,6 +6630,16 @@ var BlockScoping = (function () {
6611
6630
  var single = cases[0];
6612
6631
  body.push(this.file.attachAuxiliaryComment(t.ifStatement(t.binaryExpression("===", ret, single.test), single.consequent[0])));
6613
6632
  } else {
6633
+ // #998
6634
+ for (var i = 0; i < cases.length; i++) {
6635
+ var caseConsequent = cases[i].consequent[0];
6636
+ if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
6637
+ var _ref;
6638
+
6639
+ caseConsequent.label = (_ref = this, !_ref.loopLabel && (_ref.loopLabel = this.file.scope.generateUidIdentifier("loop")), _ref.loopLabel);
6640
+ }
6641
+ }
6642
+
6614
6643
  body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
6615
6644
  }
6616
6645
  } else {
@@ -7561,11 +7590,8 @@ function ForOfStatement(node, parent, scope, file) {
7561
7590
  // todo: find out why this is necessary? #538
7562
7591
  loop._scopeInfo = node._scopeInfo;
7563
7592
 
7564
- if (build.replaceParent) {
7565
- this.parentPath.node = build.node;
7566
- } else {
7567
- return build.node;
7568
- }
7593
+ if (build.replaceParent) this.parentPath.node = build.node;
7594
+ return build.node;
7569
7595
  }
7570
7596
 
7571
7597
  var loose = function loose(node, parent, scope, file) {
@@ -17884,7 +17910,7 @@ switch(str.length){case 5:switch(str){case "break":case "catch":case "throw":cas
17884
17910
 
17885
17911
  expectRelational("<");
17886
17912
  while (!isRelational(">")) {
17887
- node.params.push(parseIdent());
17913
+ node.params.push(parseTypeAnnotatableIdentifier());
17888
17914
  if (!isRelational(">")) {
17889
17915
  expect(_comma);
17890
17916
  }
@@ -22295,8 +22321,9 @@ Buffer.TYPED_ARRAY_SUPPORT = (function () {
22295
22321
  * By augmenting the instances, we can avoid modifying the `Uint8Array`
22296
22322
  * prototype.
22297
22323
  */
22298
- function Buffer (subject, encoding, noZero) {
22299
- if (!(this instanceof Buffer)) return new Buffer(subject, encoding, noZero)
22324
+ function Buffer (subject, encoding) {
22325
+ var self = this
22326
+ if (!(self instanceof Buffer)) return new Buffer(subject, encoding)
22300
22327
 
22301
22328
  var type = typeof subject
22302
22329
  var length
@@ -22321,12 +22348,9 @@ function Buffer (subject, encoding, noZero) {
22321
22348
  if (length < 0) length = 0
22322
22349
  else length >>>= 0 // coerce to uint32
22323
22350
 
22324
- var self = this
22325
22351
  if (Buffer.TYPED_ARRAY_SUPPORT) {
22326
22352
  // Preferred: Return an augmented `Uint8Array` instance for best performance
22327
- /*eslint-disable consistent-this */
22328
- self = Buffer._augment(new Uint8Array(length))
22329
- /*eslint-enable consistent-this */
22353
+ self = Buffer._augment(new Uint8Array(length)) // eslint-disable-line consistent-this
22330
22354
  } else {
22331
22355
  // Fallback: Return THIS instance of Buffer (created by `new`)
22332
22356
  self.length = length
@@ -22350,7 +22374,7 @@ function Buffer (subject, encoding, noZero) {
22350
22374
  }
22351
22375
  } else if (type === 'string') {
22352
22376
  self.write(subject, 0, encoding)
22353
- } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
22377
+ } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT) {
22354
22378
  for (i = 0; i < length; i++) {
22355
22379
  self[i] = 0
22356
22380
  }
@@ -22361,10 +22385,10 @@ function Buffer (subject, encoding, noZero) {
22361
22385
  return self
22362
22386
  }
22363
22387
 
22364
- function SlowBuffer (subject, encoding, noZero) {
22365
- if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding, noZero)
22388
+ function SlowBuffer (subject, encoding) {
22389
+ if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
22366
22390
 
22367
- var buf = new Buffer(subject, encoding, noZero)
22391
+ var buf = new Buffer(subject, encoding)
22368
22392
  delete buf.parent
22369
22393
  return buf
22370
22394
  }
@@ -22412,7 +22436,7 @@ Buffer.isEncoding = function isEncoding (encoding) {
22412
22436
  }
22413
22437
 
22414
22438
  Buffer.concat = function concat (list, totalLength) {
22415
- if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')
22439
+ if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
22416
22440
 
22417
22441
  if (list.length === 0) {
22418
22442
  return new Buffer(0)
@@ -22805,7 +22829,7 @@ Buffer.prototype.slice = function slice (start, end) {
22805
22829
  newBuf = Buffer._augment(this.subarray(start, end))
22806
22830
  } else {
22807
22831
  var sliceLen = end - start
22808
- newBuf = new Buffer(sliceLen, undefined, true)
22832
+ newBuf = new Buffer(sliceLen, undefined)
22809
22833
  for (var i = 0; i < sliceLen; i++) {
22810
22834
  newBuf[i] = this[i + start]
22811
22835
  }
@@ -27569,7 +27593,7 @@ module.exports = (function () {
27569
27593
  var fs = require('fs');
27570
27594
  var path = require('path');
27571
27595
 
27572
- var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset:\S+;)?base64,(.*)$/mg;
27596
+ var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+;)?base64,(.*)$/mg;
27573
27597
  var mapFileCommentRx =
27574
27598
  // //# sourceMappingURL=foo.js.map /*# sourceMappingURL=foo.js.map */
27575
27599
  /(?:\/\/[@#][ \t]+sourceMappingURL=(.+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
@@ -43926,12 +43950,16 @@ define(function (require, exports, module) {
43926
43950
  };
43927
43951
 
43928
43952
  /**
43929
- * Returns all generated line and column information for the original source
43930
- * and line provided. The only argument is an object with the following
43931
- * properties:
43953
+ * Returns all generated line and column information for the original source,
43954
+ * line, and column provided. If no column is provided, returns all mappings
43955
+ * corresponding to a single line. Otherwise, returns all mappings
43956
+ * corresponding to a single line and column.
43957
+ *
43958
+ * The only argument is an object with the following properties:
43932
43959
  *
43933
43960
  * - source: The filename of the original source.
43934
43961
  * - line: The line number in the original source.
43962
+ * - column: Optional. the column number in the original source.
43935
43963
  *
43936
43964
  * and an array of objects is returned, each with the following properties:
43937
43965
  *
@@ -43942,12 +43970,12 @@ define(function (require, exports, module) {
43942
43970
  function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
43943
43971
  // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
43944
43972
  // returns the index of the closest mapping less than the needle. By
43945
- // setting needle.originalColumn to Infinity, we thus find the last
43946
- // mapping for the given line, provided such a mapping exists.
43973
+ // setting needle.originalColumn to 0, we thus find the last mapping for
43974
+ // the given line, provided such a mapping exists.
43947
43975
  var needle = {
43948
43976
  source: util.getArg(aArgs, 'source'),
43949
43977
  originalLine: util.getArg(aArgs, 'line'),
43950
- originalColumn: 0
43978
+ originalColumn: util.getArg(aArgs, 'column', 0)
43951
43979
  };
43952
43980
 
43953
43981
  if (this.sourceRoot != null) {
@@ -43964,11 +43992,15 @@ define(function (require, exports, module) {
43964
43992
  binarySearch.LEAST_UPPER_BOUND);
43965
43993
  if (index >= 0) {
43966
43994
  var mapping = this._originalMappings[index];
43995
+ var originalLine = mapping.originalLine;
43996
+ var originalColumn = mapping.originalColumn;
43967
43997
 
43968
43998
  // Iterate until either we run out of mappings, or we run into
43969
43999
  // a mapping for a different line. Since mappings are sorted, this is
43970
44000
  // guaranteed to find all mappings for the line we are searching for.
43971
- while (mapping && mapping.originalLine === needle.originalLine) {
44001
+ while (mapping && mapping.originalLine === originalLine &&
44002
+ (aArgs.column === undefined ||
44003
+ mapping.originalColumn === originalColumn)) {
43972
44004
  mappings.push({
43973
44005
  line: util.getArg(mapping, 'generatedLine', null),
43974
44006
  column: util.getArg(mapping, 'generatedColumn', null),
@@ -44404,11 +44436,13 @@ define(function (require, exports, module) {
44404
44436
  if (index >= 0) {
44405
44437
  var mapping = this._originalMappings[index];
44406
44438
 
44407
- return {
44408
- line: util.getArg(mapping, 'generatedLine', null),
44409
- column: util.getArg(mapping, 'generatedColumn', null),
44410
- lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
44411
- };
44439
+ if (mapping.source === needle.source) {
44440
+ return {
44441
+ line: util.getArg(mapping, 'generatedLine', null),
44442
+ column: util.getArg(mapping, 'generatedColumn', null),
44443
+ lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
44444
+ };
44445
+ }
44412
44446
  }
44413
44447
 
44414
44448
  return {
@@ -46173,7 +46207,7 @@ module.exports = function (str) {
46173
46207
  module.exports={
46174
46208
  "name": "babel",
46175
46209
  "description": "Turn ES6 code into readable vanilla ES5 with source maps",
46176
- "version": "4.7.8",
46210
+ "version": "4.7.9",
46177
46211
  "author": "Sebastian McKenzie <sebmck@gmail.com>",
46178
46212
  "homepage": "https://babeljs.io/",
46179
46213
  "repository": "babel/babel",
@@ -46208,7 +46242,7 @@ module.exports={
46208
46242
  "test": "make test"
46209
46243
  },
46210
46244
  "dependencies": {
46211
- "acorn-babel": "0.11.1-37",
46245
+ "acorn-babel": "0.11.1-38",
46212
46246
  "ast-types": "~0.7.0",
46213
46247
  "chalk": "^1.0.0",
46214
46248
  "chokidar": "^0.12.6",
@@ -1,7 +1,7 @@
1
1
  module Babel
2
2
  module Source
3
- VERSION = "4.7.8"
4
- DATE = Time.at(1426020594)
3
+ VERSION = "4.7.9"
4
+ DATE = Time.at(1426213814)
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: 4.7.8
4
+ version: 4.7.9
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-10 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: sebmck@gmail.com