react 0.13.0-rc1 → 0.13.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * JSXTransformer v0.13.0-rc1
2
+ * JSXTransformer v0.13.2
3
3
  */
4
4
  (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
5
5
  /**
@@ -401,8 +401,8 @@ function processOptions(opts) {
401
401
  if (opts.es6module) {
402
402
  options.sourceType = 'module';
403
403
  }
404
- if (opts.nonStrictEs6Module) {
405
- options.sourceType = 'nonStrict6Module';
404
+ if (opts.nonStrictEs6module) {
405
+ options.sourceType = 'nonStrictModule';
406
406
  }
407
407
 
408
408
  // Instead of doing any fancy validation, only look for 'es3'. If we have
@@ -502,41 +502,36 @@ Buffer.TYPED_ARRAY_SUPPORT = (function () {
502
502
  * By augmenting the instances, we can avoid modifying the `Uint8Array`
503
503
  * prototype.
504
504
  */
505
- function Buffer (subject, encoding, noZero) {
506
- if (!(this instanceof Buffer))
507
- return new Buffer(subject, encoding, noZero)
505
+ function Buffer (subject, encoding) {
506
+ var self = this
507
+ if (!(self instanceof Buffer)) return new Buffer(subject, encoding)
508
508
 
509
509
  var type = typeof subject
510
-
511
- // Find the length
512
510
  var length
511
+
513
512
  if (type === 'number') {
514
513
  length = +subject
515
514
  } else if (type === 'string') {
516
515
  length = Buffer.byteLength(subject, encoding)
517
- } else if (type === 'object' && subject !== null) { // assume object is array-like
518
- if (subject.type === 'Buffer' && isArray(subject.data))
519
- subject = subject.data
516
+ } else if (type === 'object' && subject !== null) {
517
+ // assume object is array-like
518
+ if (subject.type === 'Buffer' && isArray(subject.data)) subject = subject.data
520
519
  length = +subject.length
521
520
  } else {
522
521
  throw new TypeError('must start with number, buffer, array or string')
523
522
  }
524
523
 
525
- if (length > kMaxLength)
526
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
527
- 'size: 0x' + kMaxLength.toString(16) + ' bytes')
524
+ if (length > kMaxLength) {
525
+ throw new RangeError('Attempt to allocate Buffer larger than maximum size: 0x' +
526
+ kMaxLength.toString(16) + ' bytes')
527
+ }
528
528
 
529
- if (length < 0)
530
- length = 0
531
- else
532
- length >>>= 0 // Coerce to uint32.
529
+ if (length < 0) length = 0
530
+ else length >>>= 0 // coerce to uint32
533
531
 
534
- var self = this
535
532
  if (Buffer.TYPED_ARRAY_SUPPORT) {
536
533
  // Preferred: Return an augmented `Uint8Array` instance for best performance
537
- /*eslint-disable consistent-this */
538
- self = Buffer._augment(new Uint8Array(length))
539
- /*eslint-enable consistent-this */
534
+ self = Buffer._augment(new Uint8Array(length)) // eslint-disable-line consistent-this
540
535
  } else {
541
536
  // Fallback: Return THIS instance of Buffer (created by `new`)
542
537
  self.length = length
@@ -550,42 +545,43 @@ function Buffer (subject, encoding, noZero) {
550
545
  } else if (isArrayish(subject)) {
551
546
  // Treat array-ish objects as a byte array
552
547
  if (Buffer.isBuffer(subject)) {
553
- for (i = 0; i < length; i++)
548
+ for (i = 0; i < length; i++) {
554
549
  self[i] = subject.readUInt8(i)
550
+ }
555
551
  } else {
556
- for (i = 0; i < length; i++)
552
+ for (i = 0; i < length; i++) {
557
553
  self[i] = ((subject[i] % 256) + 256) % 256
554
+ }
558
555
  }
559
556
  } else if (type === 'string') {
560
557
  self.write(subject, 0, encoding)
561
- } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
558
+ } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT) {
562
559
  for (i = 0; i < length; i++) {
563
560
  self[i] = 0
564
561
  }
565
562
  }
566
563
 
567
- if (length > 0 && length <= Buffer.poolSize)
568
- self.parent = rootParent
564
+ if (length > 0 && length <= Buffer.poolSize) self.parent = rootParent
569
565
 
570
566
  return self
571
567
  }
572
568
 
573
- function SlowBuffer (subject, encoding, noZero) {
574
- if (!(this instanceof SlowBuffer))
575
- return new SlowBuffer(subject, encoding, noZero)
569
+ function SlowBuffer (subject, encoding) {
570
+ if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
576
571
 
577
- var buf = new Buffer(subject, encoding, noZero)
572
+ var buf = new Buffer(subject, encoding)
578
573
  delete buf.parent
579
574
  return buf
580
575
  }
581
576
 
582
- Buffer.isBuffer = function (b) {
577
+ Buffer.isBuffer = function isBuffer (b) {
583
578
  return !!(b != null && b._isBuffer)
584
579
  }
585
580
 
586
- Buffer.compare = function (a, b) {
587
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b))
581
+ Buffer.compare = function compare (a, b) {
582
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
588
583
  throw new TypeError('Arguments must be Buffers')
584
+ }
589
585
 
590
586
  if (a === b) return 0
591
587
 
@@ -601,7 +597,7 @@ Buffer.compare = function (a, b) {
601
597
  return 0
602
598
  }
603
599
 
604
- Buffer.isEncoding = function (encoding) {
600
+ Buffer.isEncoding = function isEncoding (encoding) {
605
601
  switch (String(encoding).toLowerCase()) {
606
602
  case 'hex':
607
603
  case 'utf8':
@@ -620,8 +616,8 @@ Buffer.isEncoding = function (encoding) {
620
616
  }
621
617
  }
622
618
 
623
- Buffer.concat = function (list, totalLength) {
624
- if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')
619
+ Buffer.concat = function concat (list, totalLength) {
620
+ if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
625
621
 
626
622
  if (list.length === 0) {
627
623
  return new Buffer(0)
@@ -647,7 +643,7 @@ Buffer.concat = function (list, totalLength) {
647
643
  return buf
648
644
  }
649
645
 
650
- Buffer.byteLength = function (str, encoding) {
646
+ Buffer.byteLength = function byteLength (str, encoding) {
651
647
  var ret
652
648
  str = str + ''
653
649
  switch (encoding || 'utf8') {
@@ -683,7 +679,7 @@ Buffer.prototype.length = undefined
683
679
  Buffer.prototype.parent = undefined
684
680
 
685
681
  // toString(encoding, start=0, end=buffer.length)
686
- Buffer.prototype.toString = function (encoding, start, end) {
682
+ Buffer.prototype.toString = function toString (encoding, start, end) {
687
683
  var loweredCase = false
688
684
 
689
685
  start = start >>> 0
@@ -719,45 +715,84 @@ Buffer.prototype.toString = function (encoding, start, end) {
719
715
  return utf16leSlice(this, start, end)
720
716
 
721
717
  default:
722
- if (loweredCase)
723
- throw new TypeError('Unknown encoding: ' + encoding)
718
+ if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
724
719
  encoding = (encoding + '').toLowerCase()
725
720
  loweredCase = true
726
721
  }
727
722
  }
728
723
  }
729
724
 
730
- Buffer.prototype.equals = function (b) {
725
+ Buffer.prototype.equals = function equals (b) {
731
726
  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
732
727
  if (this === b) return true
733
728
  return Buffer.compare(this, b) === 0
734
729
  }
735
730
 
736
- Buffer.prototype.inspect = function () {
731
+ Buffer.prototype.inspect = function inspect () {
737
732
  var str = ''
738
733
  var max = exports.INSPECT_MAX_BYTES
739
734
  if (this.length > 0) {
740
735
  str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
741
- if (this.length > max)
742
- str += ' ... '
736
+ if (this.length > max) str += ' ... '
743
737
  }
744
738
  return '<Buffer ' + str + '>'
745
739
  }
746
740
 
747
- Buffer.prototype.compare = function (b) {
741
+ Buffer.prototype.compare = function compare (b) {
748
742
  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
749
743
  if (this === b) return 0
750
744
  return Buffer.compare(this, b)
751
745
  }
752
746
 
747
+ Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
748
+ if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
749
+ else if (byteOffset < -0x80000000) byteOffset = -0x80000000
750
+ byteOffset >>= 0
751
+
752
+ if (this.length === 0) return -1
753
+ if (byteOffset >= this.length) return -1
754
+
755
+ // Negative offsets start from the end of the buffer
756
+ if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
757
+
758
+ if (typeof val === 'string') {
759
+ if (val.length === 0) return -1 // special case: looking for empty string always fails
760
+ return String.prototype.indexOf.call(this, val, byteOffset)
761
+ }
762
+ if (Buffer.isBuffer(val)) {
763
+ return arrayIndexOf(this, val, byteOffset)
764
+ }
765
+ if (typeof val === 'number') {
766
+ if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
767
+ return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
768
+ }
769
+ return arrayIndexOf(this, [ val ], byteOffset)
770
+ }
771
+
772
+ function arrayIndexOf (arr, val, byteOffset) {
773
+ var foundIndex = -1
774
+ for (var i = 0; byteOffset + i < arr.length; i++) {
775
+ if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
776
+ if (foundIndex === -1) foundIndex = i
777
+ if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
778
+ } else {
779
+ foundIndex = -1
780
+ }
781
+ }
782
+ return -1
783
+ }
784
+
785
+ throw new TypeError('val must be string, number or Buffer')
786
+ }
787
+
753
788
  // `get` will be removed in Node 0.13+
754
- Buffer.prototype.get = function (offset) {
789
+ Buffer.prototype.get = function get (offset) {
755
790
  console.log('.get() is deprecated. Access using array indexes instead.')
756
791
  return this.readUInt8(offset)
757
792
  }
758
793
 
759
794
  // `set` will be removed in Node 0.13+
760
- Buffer.prototype.set = function (v, offset) {
795
+ Buffer.prototype.set = function set (v, offset) {
761
796
  console.log('.set() is deprecated. Access using array indexes instead.')
762
797
  return this.writeUInt8(v, offset)
763
798
  }
@@ -782,9 +817,9 @@ function hexWrite (buf, string, offset, length) {
782
817
  length = strLen / 2
783
818
  }
784
819
  for (var i = 0; i < length; i++) {
785
- var byte = parseInt(string.substr(i * 2, 2), 16)
786
- if (isNaN(byte)) throw new Error('Invalid hex string')
787
- buf[offset + i] = byte
820
+ var parsed = parseInt(string.substr(i * 2, 2), 16)
821
+ if (isNaN(parsed)) throw new Error('Invalid hex string')
822
+ buf[offset + i] = parsed
788
823
  }
789
824
  return i
790
825
  }
@@ -813,7 +848,7 @@ function utf16leWrite (buf, string, offset, length) {
813
848
  return charsWritten
814
849
  }
815
850
 
816
- Buffer.prototype.write = function (string, offset, length, encoding) {
851
+ Buffer.prototype.write = function write (string, offset, length, encoding) {
817
852
  // Support both (string, offset, length, encoding)
818
853
  // and the legacy (string, encoding, offset, length)
819
854
  if (isFinite(offset)) {
@@ -830,8 +865,9 @@ Buffer.prototype.write = function (string, offset, length, encoding) {
830
865
 
831
866
  offset = Number(offset) || 0
832
867
 
833
- if (length < 0 || offset < 0 || offset > this.length)
868
+ if (length < 0 || offset < 0 || offset > this.length) {
834
869
  throw new RangeError('attempt to write outside buffer bounds')
870
+ }
835
871
 
836
872
  var remaining = this.length - offset
837
873
  if (!length) {
@@ -874,7 +910,7 @@ Buffer.prototype.write = function (string, offset, length, encoding) {
874
910
  return ret
875
911
  }
876
912
 
877
- Buffer.prototype.toJSON = function () {
913
+ Buffer.prototype.toJSON = function toJSON () {
878
914
  return {
879
915
  type: 'Buffer',
880
916
  data: Array.prototype.slice.call(this._arr || this, 0)
@@ -948,43 +984,39 @@ function utf16leSlice (buf, start, end) {
948
984
  return res
949
985
  }
950
986
 
951
- Buffer.prototype.slice = function (start, end) {
987
+ Buffer.prototype.slice = function slice (start, end) {
952
988
  var len = this.length
953
989
  start = ~~start
954
990
  end = end === undefined ? len : ~~end
955
991
 
956
992
  if (start < 0) {
957
993
  start += len
958
- if (start < 0)
959
- start = 0
994
+ if (start < 0) start = 0
960
995
  } else if (start > len) {
961
996
  start = len
962
997
  }
963
998
 
964
999
  if (end < 0) {
965
1000
  end += len
966
- if (end < 0)
967
- end = 0
1001
+ if (end < 0) end = 0
968
1002
  } else if (end > len) {
969
1003
  end = len
970
1004
  }
971
1005
 
972
- if (end < start)
973
- end = start
1006
+ if (end < start) end = start
974
1007
 
975
1008
  var newBuf
976
1009
  if (Buffer.TYPED_ARRAY_SUPPORT) {
977
1010
  newBuf = Buffer._augment(this.subarray(start, end))
978
1011
  } else {
979
1012
  var sliceLen = end - start
980
- newBuf = new Buffer(sliceLen, undefined, true)
1013
+ newBuf = new Buffer(sliceLen, undefined)
981
1014
  for (var i = 0; i < sliceLen; i++) {
982
1015
  newBuf[i] = this[i + start]
983
1016
  }
984
1017
  }
985
1018
 
986
- if (newBuf.length)
987
- newBuf.parent = this.parent || this
1019
+ if (newBuf.length) newBuf.parent = this.parent || this
988
1020
 
989
1021
  return newBuf
990
1022
  }
@@ -993,62 +1025,58 @@ Buffer.prototype.slice = function (start, end) {
993
1025
  * Need to make sure that buffer isn't trying to write out of bounds.
994
1026
  */
995
1027
  function checkOffset (offset, ext, length) {
996
- if ((offset % 1) !== 0 || offset < 0)
997
- throw new RangeError('offset is not uint')
998
- if (offset + ext > length)
999
- throw new RangeError('Trying to access beyond buffer length')
1028
+ if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1029
+ if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1000
1030
  }
1001
1031
 
1002
- Buffer.prototype.readUIntLE = function (offset, byteLength, noAssert) {
1032
+ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1003
1033
  offset = offset >>> 0
1004
1034
  byteLength = byteLength >>> 0
1005
- if (!noAssert)
1006
- checkOffset(offset, byteLength, this.length)
1035
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
1007
1036
 
1008
1037
  var val = this[offset]
1009
1038
  var mul = 1
1010
1039
  var i = 0
1011
- while (++i < byteLength && (mul *= 0x100))
1040
+ while (++i < byteLength && (mul *= 0x100)) {
1012
1041
  val += this[offset + i] * mul
1042
+ }
1013
1043
 
1014
1044
  return val
1015
1045
  }
1016
1046
 
1017
- Buffer.prototype.readUIntBE = function (offset, byteLength, noAssert) {
1047
+ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1018
1048
  offset = offset >>> 0
1019
1049
  byteLength = byteLength >>> 0
1020
- if (!noAssert)
1050
+ if (!noAssert) {
1021
1051
  checkOffset(offset, byteLength, this.length)
1052
+ }
1022
1053
 
1023
1054
  var val = this[offset + --byteLength]
1024
1055
  var mul = 1
1025
- while (byteLength > 0 && (mul *= 0x100))
1056
+ while (byteLength > 0 && (mul *= 0x100)) {
1026
1057
  val += this[offset + --byteLength] * mul
1058
+ }
1027
1059
 
1028
1060
  return val
1029
1061
  }
1030
1062
 
1031
- Buffer.prototype.readUInt8 = function (offset, noAssert) {
1032
- if (!noAssert)
1033
- checkOffset(offset, 1, this.length)
1063
+ Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1064
+ if (!noAssert) checkOffset(offset, 1, this.length)
1034
1065
  return this[offset]
1035
1066
  }
1036
1067
 
1037
- Buffer.prototype.readUInt16LE = function (offset, noAssert) {
1038
- if (!noAssert)
1039
- checkOffset(offset, 2, this.length)
1068
+ Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1069
+ if (!noAssert) checkOffset(offset, 2, this.length)
1040
1070
  return this[offset] | (this[offset + 1] << 8)
1041
1071
  }
1042
1072
 
1043
- Buffer.prototype.readUInt16BE = function (offset, noAssert) {
1044
- if (!noAssert)
1045
- checkOffset(offset, 2, this.length)
1073
+ Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1074
+ if (!noAssert) checkOffset(offset, 2, this.length)
1046
1075
  return (this[offset] << 8) | this[offset + 1]
1047
1076
  }
1048
1077
 
1049
- Buffer.prototype.readUInt32LE = function (offset, noAssert) {
1050
- if (!noAssert)
1051
- checkOffset(offset, 4, this.length)
1078
+ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1079
+ if (!noAssert) checkOffset(offset, 4, this.length)
1052
1080
 
1053
1081
  return ((this[offset]) |
1054
1082
  (this[offset + 1] << 8) |
@@ -1056,117 +1084,104 @@ Buffer.prototype.readUInt32LE = function (offset, noAssert) {
1056
1084
  (this[offset + 3] * 0x1000000)
1057
1085
  }
1058
1086
 
1059
- Buffer.prototype.readUInt32BE = function (offset, noAssert) {
1060
- if (!noAssert)
1061
- checkOffset(offset, 4, this.length)
1087
+ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1088
+ if (!noAssert) checkOffset(offset, 4, this.length)
1062
1089
 
1063
1090
  return (this[offset] * 0x1000000) +
1064
- ((this[offset + 1] << 16) |
1065
- (this[offset + 2] << 8) |
1066
- this[offset + 3])
1091
+ ((this[offset + 1] << 16) |
1092
+ (this[offset + 2] << 8) |
1093
+ this[offset + 3])
1067
1094
  }
1068
1095
 
1069
- Buffer.prototype.readIntLE = function (offset, byteLength, noAssert) {
1096
+ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1070
1097
  offset = offset >>> 0
1071
1098
  byteLength = byteLength >>> 0
1072
- if (!noAssert)
1073
- checkOffset(offset, byteLength, this.length)
1099
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
1074
1100
 
1075
1101
  var val = this[offset]
1076
1102
  var mul = 1
1077
1103
  var i = 0
1078
- while (++i < byteLength && (mul *= 0x100))
1104
+ while (++i < byteLength && (mul *= 0x100)) {
1079
1105
  val += this[offset + i] * mul
1106
+ }
1080
1107
  mul *= 0x80
1081
1108
 
1082
- if (val >= mul)
1083
- val -= Math.pow(2, 8 * byteLength)
1109
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1084
1110
 
1085
1111
  return val
1086
1112
  }
1087
1113
 
1088
- Buffer.prototype.readIntBE = function (offset, byteLength, noAssert) {
1114
+ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1089
1115
  offset = offset >>> 0
1090
1116
  byteLength = byteLength >>> 0
1091
- if (!noAssert)
1092
- checkOffset(offset, byteLength, this.length)
1117
+ if (!noAssert) checkOffset(offset, byteLength, this.length)
1093
1118
 
1094
1119
  var i = byteLength
1095
1120
  var mul = 1
1096
1121
  var val = this[offset + --i]
1097
- while (i > 0 && (mul *= 0x100))
1122
+ while (i > 0 && (mul *= 0x100)) {
1098
1123
  val += this[offset + --i] * mul
1124
+ }
1099
1125
  mul *= 0x80
1100
1126
 
1101
- if (val >= mul)
1102
- val -= Math.pow(2, 8 * byteLength)
1127
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1103
1128
 
1104
1129
  return val
1105
1130
  }
1106
1131
 
1107
- Buffer.prototype.readInt8 = function (offset, noAssert) {
1108
- if (!noAssert)
1109
- checkOffset(offset, 1, this.length)
1110
- if (!(this[offset] & 0x80))
1111
- return (this[offset])
1132
+ Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1133
+ if (!noAssert) checkOffset(offset, 1, this.length)
1134
+ if (!(this[offset] & 0x80)) return (this[offset])
1112
1135
  return ((0xff - this[offset] + 1) * -1)
1113
1136
  }
1114
1137
 
1115
- Buffer.prototype.readInt16LE = function (offset, noAssert) {
1116
- if (!noAssert)
1117
- checkOffset(offset, 2, this.length)
1138
+ Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1139
+ if (!noAssert) checkOffset(offset, 2, this.length)
1118
1140
  var val = this[offset] | (this[offset + 1] << 8)
1119
1141
  return (val & 0x8000) ? val | 0xFFFF0000 : val
1120
1142
  }
1121
1143
 
1122
- Buffer.prototype.readInt16BE = function (offset, noAssert) {
1123
- if (!noAssert)
1124
- checkOffset(offset, 2, this.length)
1144
+ Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1145
+ if (!noAssert) checkOffset(offset, 2, this.length)
1125
1146
  var val = this[offset + 1] | (this[offset] << 8)
1126
1147
  return (val & 0x8000) ? val | 0xFFFF0000 : val
1127
1148
  }
1128
1149
 
1129
- Buffer.prototype.readInt32LE = function (offset, noAssert) {
1130
- if (!noAssert)
1131
- checkOffset(offset, 4, this.length)
1150
+ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1151
+ if (!noAssert) checkOffset(offset, 4, this.length)
1132
1152
 
1133
1153
  return (this[offset]) |
1134
- (this[offset + 1] << 8) |
1135
- (this[offset + 2] << 16) |
1136
- (this[offset + 3] << 24)
1154
+ (this[offset + 1] << 8) |
1155
+ (this[offset + 2] << 16) |
1156
+ (this[offset + 3] << 24)
1137
1157
  }
1138
1158
 
1139
- Buffer.prototype.readInt32BE = function (offset, noAssert) {
1140
- if (!noAssert)
1141
- checkOffset(offset, 4, this.length)
1159
+ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1160
+ if (!noAssert) checkOffset(offset, 4, this.length)
1142
1161
 
1143
1162
  return (this[offset] << 24) |
1144
- (this[offset + 1] << 16) |
1145
- (this[offset + 2] << 8) |
1146
- (this[offset + 3])
1163
+ (this[offset + 1] << 16) |
1164
+ (this[offset + 2] << 8) |
1165
+ (this[offset + 3])
1147
1166
  }
1148
1167
 
1149
- Buffer.prototype.readFloatLE = function (offset, noAssert) {
1150
- if (!noAssert)
1151
- checkOffset(offset, 4, this.length)
1168
+ Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1169
+ if (!noAssert) checkOffset(offset, 4, this.length)
1152
1170
  return ieee754.read(this, offset, true, 23, 4)
1153
1171
  }
1154
1172
 
1155
- Buffer.prototype.readFloatBE = function (offset, noAssert) {
1156
- if (!noAssert)
1157
- checkOffset(offset, 4, this.length)
1173
+ Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1174
+ if (!noAssert) checkOffset(offset, 4, this.length)
1158
1175
  return ieee754.read(this, offset, false, 23, 4)
1159
1176
  }
1160
1177
 
1161
- Buffer.prototype.readDoubleLE = function (offset, noAssert) {
1162
- if (!noAssert)
1163
- checkOffset(offset, 8, this.length)
1178
+ Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1179
+ if (!noAssert) checkOffset(offset, 8, this.length)
1164
1180
  return ieee754.read(this, offset, true, 52, 8)
1165
1181
  }
1166
1182
 
1167
- Buffer.prototype.readDoubleBE = function (offset, noAssert) {
1168
- if (!noAssert)
1169
- checkOffset(offset, 8, this.length)
1183
+ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1184
+ if (!noAssert) checkOffset(offset, 8, this.length)
1170
1185
  return ieee754.read(this, offset, false, 52, 8)
1171
1186
  }
1172
1187
 
@@ -1176,43 +1191,42 @@ function checkInt (buf, value, offset, ext, max, min) {
1176
1191
  if (offset + ext > buf.length) throw new RangeError('index out of range')
1177
1192
  }
1178
1193
 
1179
- Buffer.prototype.writeUIntLE = function (value, offset, byteLength, noAssert) {
1194
+ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1180
1195
  value = +value
1181
1196
  offset = offset >>> 0
1182
1197
  byteLength = byteLength >>> 0
1183
- if (!noAssert)
1184
- checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1198
+ if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1185
1199
 
1186
1200
  var mul = 1
1187
1201
  var i = 0
1188
1202
  this[offset] = value & 0xFF
1189
- while (++i < byteLength && (mul *= 0x100))
1203
+ while (++i < byteLength && (mul *= 0x100)) {
1190
1204
  this[offset + i] = (value / mul) >>> 0 & 0xFF
1205
+ }
1191
1206
 
1192
1207
  return offset + byteLength
1193
1208
  }
1194
1209
 
1195
- Buffer.prototype.writeUIntBE = function (value, offset, byteLength, noAssert) {
1210
+ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1196
1211
  value = +value
1197
1212
  offset = offset >>> 0
1198
1213
  byteLength = byteLength >>> 0
1199
- if (!noAssert)
1200
- checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1214
+ if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1201
1215
 
1202
1216
  var i = byteLength - 1
1203
1217
  var mul = 1
1204
1218
  this[offset + i] = value & 0xFF
1205
- while (--i >= 0 && (mul *= 0x100))
1219
+ while (--i >= 0 && (mul *= 0x100)) {
1206
1220
  this[offset + i] = (value / mul) >>> 0 & 0xFF
1221
+ }
1207
1222
 
1208
1223
  return offset + byteLength
1209
1224
  }
1210
1225
 
1211
- Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
1226
+ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1212
1227
  value = +value
1213
1228
  offset = offset >>> 0
1214
- if (!noAssert)
1215
- checkInt(this, value, offset, 1, 0xff, 0)
1229
+ if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1216
1230
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1217
1231
  this[offset] = value
1218
1232
  return offset + 1
@@ -1226,27 +1240,29 @@ function objectWriteUInt16 (buf, value, offset, littleEndian) {
1226
1240
  }
1227
1241
  }
1228
1242
 
1229
- Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
1243
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1230
1244
  value = +value
1231
1245
  offset = offset >>> 0
1232
- if (!noAssert)
1233
- checkInt(this, value, offset, 2, 0xffff, 0)
1246
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1234
1247
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1235
1248
  this[offset] = value
1236
1249
  this[offset + 1] = (value >>> 8)
1237
- } else objectWriteUInt16(this, value, offset, true)
1250
+ } else {
1251
+ objectWriteUInt16(this, value, offset, true)
1252
+ }
1238
1253
  return offset + 2
1239
1254
  }
1240
1255
 
1241
- Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
1256
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1242
1257
  value = +value
1243
1258
  offset = offset >>> 0
1244
- if (!noAssert)
1245
- checkInt(this, value, offset, 2, 0xffff, 0)
1259
+ if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1246
1260
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1247
1261
  this[offset] = (value >>> 8)
1248
1262
  this[offset + 1] = value
1249
- } else objectWriteUInt16(this, value, offset, false)
1263
+ } else {
1264
+ objectWriteUInt16(this, value, offset, false)
1265
+ }
1250
1266
  return offset + 2
1251
1267
  }
1252
1268
 
@@ -1257,139 +1273,144 @@ function objectWriteUInt32 (buf, value, offset, littleEndian) {
1257
1273
  }
1258
1274
  }
1259
1275
 
1260
- Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
1276
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1261
1277
  value = +value
1262
1278
  offset = offset >>> 0
1263
- if (!noAssert)
1264
- checkInt(this, value, offset, 4, 0xffffffff, 0)
1279
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1265
1280
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1266
1281
  this[offset + 3] = (value >>> 24)
1267
1282
  this[offset + 2] = (value >>> 16)
1268
1283
  this[offset + 1] = (value >>> 8)
1269
1284
  this[offset] = value
1270
- } else objectWriteUInt32(this, value, offset, true)
1285
+ } else {
1286
+ objectWriteUInt32(this, value, offset, true)
1287
+ }
1271
1288
  return offset + 4
1272
1289
  }
1273
1290
 
1274
- Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
1291
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1275
1292
  value = +value
1276
1293
  offset = offset >>> 0
1277
- if (!noAssert)
1278
- checkInt(this, value, offset, 4, 0xffffffff, 0)
1294
+ if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1279
1295
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1280
1296
  this[offset] = (value >>> 24)
1281
1297
  this[offset + 1] = (value >>> 16)
1282
1298
  this[offset + 2] = (value >>> 8)
1283
1299
  this[offset + 3] = value
1284
- } else objectWriteUInt32(this, value, offset, false)
1300
+ } else {
1301
+ objectWriteUInt32(this, value, offset, false)
1302
+ }
1285
1303
  return offset + 4
1286
1304
  }
1287
1305
 
1288
- Buffer.prototype.writeIntLE = function (value, offset, byteLength, noAssert) {
1306
+ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1289
1307
  value = +value
1290
1308
  offset = offset >>> 0
1291
1309
  if (!noAssert) {
1292
- checkInt(this,
1293
- value,
1294
- offset,
1295
- byteLength,
1296
- Math.pow(2, 8 * byteLength - 1) - 1,
1297
- -Math.pow(2, 8 * byteLength - 1))
1310
+ checkInt(
1311
+ this, value, offset, byteLength,
1312
+ Math.pow(2, 8 * byteLength - 1) - 1,
1313
+ -Math.pow(2, 8 * byteLength - 1)
1314
+ )
1298
1315
  }
1299
1316
 
1300
1317
  var i = 0
1301
1318
  var mul = 1
1302
1319
  var sub = value < 0 ? 1 : 0
1303
1320
  this[offset] = value & 0xFF
1304
- while (++i < byteLength && (mul *= 0x100))
1321
+ while (++i < byteLength && (mul *= 0x100)) {
1305
1322
  this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1323
+ }
1306
1324
 
1307
1325
  return offset + byteLength
1308
1326
  }
1309
1327
 
1310
- Buffer.prototype.writeIntBE = function (value, offset, byteLength, noAssert) {
1328
+ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1311
1329
  value = +value
1312
1330
  offset = offset >>> 0
1313
1331
  if (!noAssert) {
1314
- checkInt(this,
1315
- value,
1316
- offset,
1317
- byteLength,
1318
- Math.pow(2, 8 * byteLength - 1) - 1,
1319
- -Math.pow(2, 8 * byteLength - 1))
1332
+ checkInt(
1333
+ this, value, offset, byteLength,
1334
+ Math.pow(2, 8 * byteLength - 1) - 1,
1335
+ -Math.pow(2, 8 * byteLength - 1)
1336
+ )
1320
1337
  }
1321
1338
 
1322
1339
  var i = byteLength - 1
1323
1340
  var mul = 1
1324
1341
  var sub = value < 0 ? 1 : 0
1325
1342
  this[offset + i] = value & 0xFF
1326
- while (--i >= 0 && (mul *= 0x100))
1343
+ while (--i >= 0 && (mul *= 0x100)) {
1327
1344
  this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1345
+ }
1328
1346
 
1329
1347
  return offset + byteLength
1330
1348
  }
1331
1349
 
1332
- Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
1350
+ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1333
1351
  value = +value
1334
1352
  offset = offset >>> 0
1335
- if (!noAssert)
1336
- checkInt(this, value, offset, 1, 0x7f, -0x80)
1353
+ if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1337
1354
  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1338
1355
  if (value < 0) value = 0xff + value + 1
1339
1356
  this[offset] = value
1340
1357
  return offset + 1
1341
1358
  }
1342
1359
 
1343
- Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
1360
+ Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1344
1361
  value = +value
1345
1362
  offset = offset >>> 0
1346
- if (!noAssert)
1347
- checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1363
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1348
1364
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1349
1365
  this[offset] = value
1350
1366
  this[offset + 1] = (value >>> 8)
1351
- } else objectWriteUInt16(this, value, offset, true)
1367
+ } else {
1368
+ objectWriteUInt16(this, value, offset, true)
1369
+ }
1352
1370
  return offset + 2
1353
1371
  }
1354
1372
 
1355
- Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
1373
+ Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
1356
1374
  value = +value
1357
1375
  offset = offset >>> 0
1358
- if (!noAssert)
1359
- checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1376
+ if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1360
1377
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1361
1378
  this[offset] = (value >>> 8)
1362
1379
  this[offset + 1] = value
1363
- } else objectWriteUInt16(this, value, offset, false)
1380
+ } else {
1381
+ objectWriteUInt16(this, value, offset, false)
1382
+ }
1364
1383
  return offset + 2
1365
1384
  }
1366
1385
 
1367
- Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
1386
+ Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
1368
1387
  value = +value
1369
1388
  offset = offset >>> 0
1370
- if (!noAssert)
1371
- checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1389
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1372
1390
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1373
1391
  this[offset] = value
1374
1392
  this[offset + 1] = (value >>> 8)
1375
1393
  this[offset + 2] = (value >>> 16)
1376
1394
  this[offset + 3] = (value >>> 24)
1377
- } else objectWriteUInt32(this, value, offset, true)
1395
+ } else {
1396
+ objectWriteUInt32(this, value, offset, true)
1397
+ }
1378
1398
  return offset + 4
1379
1399
  }
1380
1400
 
1381
- Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
1401
+ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
1382
1402
  value = +value
1383
1403
  offset = offset >>> 0
1384
- if (!noAssert)
1385
- checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1404
+ if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1386
1405
  if (value < 0) value = 0xffffffff + value + 1
1387
1406
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1388
1407
  this[offset] = (value >>> 24)
1389
1408
  this[offset + 1] = (value >>> 16)
1390
1409
  this[offset + 2] = (value >>> 8)
1391
1410
  this[offset + 3] = value
1392
- } else objectWriteUInt32(this, value, offset, false)
1411
+ } else {
1412
+ objectWriteUInt32(this, value, offset, false)
1413
+ }
1393
1414
  return offset + 4
1394
1415
  }
1395
1416
 
@@ -1400,39 +1421,39 @@ function checkIEEE754 (buf, value, offset, ext, max, min) {
1400
1421
  }
1401
1422
 
1402
1423
  function writeFloat (buf, value, offset, littleEndian, noAssert) {
1403
- if (!noAssert)
1424
+ if (!noAssert) {
1404
1425
  checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1426
+ }
1405
1427
  ieee754.write(buf, value, offset, littleEndian, 23, 4)
1406
1428
  return offset + 4
1407
1429
  }
1408
1430
 
1409
- Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
1431
+ Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
1410
1432
  return writeFloat(this, value, offset, true, noAssert)
1411
1433
  }
1412
1434
 
1413
- Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
1435
+ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
1414
1436
  return writeFloat(this, value, offset, false, noAssert)
1415
1437
  }
1416
1438
 
1417
1439
  function writeDouble (buf, value, offset, littleEndian, noAssert) {
1418
- if (!noAssert)
1440
+ if (!noAssert) {
1419
1441
  checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1442
+ }
1420
1443
  ieee754.write(buf, value, offset, littleEndian, 52, 8)
1421
1444
  return offset + 8
1422
1445
  }
1423
1446
 
1424
- Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
1447
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
1425
1448
  return writeDouble(this, value, offset, true, noAssert)
1426
1449
  }
1427
1450
 
1428
- Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
1451
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
1429
1452
  return writeDouble(this, value, offset, false, noAssert)
1430
1453
  }
1431
1454
 
1432
1455
  // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1433
- Buffer.prototype.copy = function (target, target_start, start, end) {
1434
- var self = this // source
1435
-
1456
+ Buffer.prototype.copy = function copy (target, target_start, start, end) {
1436
1457
  if (!start) start = 0
1437
1458
  if (!end && end !== 0) end = this.length
1438
1459
  if (target_start >= target.length) target_start = target.length
@@ -1441,19 +1462,20 @@ Buffer.prototype.copy = function (target, target_start, start, end) {
1441
1462
 
1442
1463
  // Copy 0 bytes; we're done
1443
1464
  if (end === start) return 0
1444
- if (target.length === 0 || self.length === 0) return 0
1465
+ if (target.length === 0 || this.length === 0) return 0
1445
1466
 
1446
1467
  // Fatal error conditions
1447
- if (target_start < 0)
1468
+ if (target_start < 0) {
1448
1469
  throw new RangeError('targetStart out of bounds')
1449
- if (start < 0 || start >= self.length) throw new RangeError('sourceStart out of bounds')
1470
+ }
1471
+ if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
1450
1472
  if (end < 0) throw new RangeError('sourceEnd out of bounds')
1451
1473
 
1452
1474
  // Are we oob?
1453
- if (end > this.length)
1454
- end = this.length
1455
- if (target.length - target_start < end - start)
1475
+ if (end > this.length) end = this.length
1476
+ if (target.length - target_start < end - start) {
1456
1477
  end = target.length - target_start + start
1478
+ }
1457
1479
 
1458
1480
  var len = end - start
1459
1481
 
@@ -1469,7 +1491,7 @@ Buffer.prototype.copy = function (target, target_start, start, end) {
1469
1491
  }
1470
1492
 
1471
1493
  // fill(value, start=0, end=buffer.length)
1472
- Buffer.prototype.fill = function (value, start, end) {
1494
+ Buffer.prototype.fill = function fill (value, start, end) {
1473
1495
  if (!value) value = 0
1474
1496
  if (!start) start = 0
1475
1497
  if (!end) end = this.length
@@ -1503,7 +1525,7 @@ Buffer.prototype.fill = function (value, start, end) {
1503
1525
  * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
1504
1526
  * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
1505
1527
  */
1506
- Buffer.prototype.toArrayBuffer = function () {
1528
+ Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
1507
1529
  if (typeof Uint8Array !== 'undefined') {
1508
1530
  if (Buffer.TYPED_ARRAY_SUPPORT) {
1509
1531
  return (new Buffer(this)).buffer
@@ -1527,12 +1549,11 @@ var BP = Buffer.prototype
1527
1549
  /**
1528
1550
  * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
1529
1551
  */
1530
- Buffer._augment = function (arr) {
1552
+ Buffer._augment = function _augment (arr) {
1531
1553
  arr.constructor = Buffer
1532
1554
  arr._isBuffer = true
1533
1555
 
1534
- // save reference to original Uint8Array get/set methods before overwriting
1535
- arr._get = arr.get
1556
+ // save reference to original Uint8Array set method before overwriting
1536
1557
  arr._set = arr.set
1537
1558
 
1538
1559
  // deprecated, will be removed in node 0.13+
@@ -1545,6 +1566,7 @@ Buffer._augment = function (arr) {
1545
1566
  arr.toJSON = BP.toJSON
1546
1567
  arr.equals = BP.equals
1547
1568
  arr.compare = BP.compare
1569
+ arr.indexOf = BP.indexOf
1548
1570
  arr.copy = BP.copy
1549
1571
  arr.slice = BP.slice
1550
1572
  arr.readUIntLE = BP.readUIntLE
@@ -1732,8 +1754,7 @@ function base64ToBytes (str) {
1732
1754
 
1733
1755
  function blitBuffer (src, dst, offset, length) {
1734
1756
  for (var i = 0; i < length; i++) {
1735
- if ((i + offset >= dst.length) || (i >= src.length))
1736
- break
1757
+ if ((i + offset >= dst.length) || (i >= src.length)) break
1737
1758
  dst[i + offset] = src[i]
1738
1759
  }
1739
1760
  return i
@@ -2259,6 +2280,7 @@ process.browser = true;
2259
2280
  process.env = {};
2260
2281
  process.argv = [];
2261
2282
  process.version = ''; // empty string to avoid regexp issues
2283
+ process.versions = {};
2262
2284
 
2263
2285
  function noop() {}
2264
2286
 
@@ -2314,32 +2336,6 @@ process.umask = function() { return 0; };
2314
2336
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2315
2337
  */
2316
2338
 
2317
- /*jslint bitwise:true plusplus:true */
2318
- /*global esprima:true, define:true, exports:true, window: true,
2319
- throwErrorTolerant: true,
2320
- throwError: true, generateStatement: true, peek: true,
2321
- parseAssignmentExpression: true, parseBlock: true,
2322
- parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
2323
- parseDeclareClass: true, parseDeclareFunction: true,
2324
- parseDeclareModule: true, parseDeclareVariable: true,
2325
- parseForStatement: true,
2326
- parseFunctionDeclaration: true, parseFunctionExpression: true,
2327
- parseFunctionSourceElements: true, parseVariableIdentifier: true,
2328
- parseImportSpecifier: true, parseInterface: true,
2329
- parseLeftHandSideExpression: true, parseParams: true, validateParam: true,
2330
- parseSpreadOrAssignmentExpression: true,
2331
- parseStatement: true, parseSourceElement: true, parseConciseBody: true,
2332
- advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
2333
- scanXJSStringLiteral: true, scanXJSIdentifier: true,
2334
- parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
2335
- parseFunctionTypeParam: true,
2336
- parsePrimaryType: true,
2337
- parseTypeAlias: true,
2338
- parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
2339
- parseTypeParameterDeclaration: true,
2340
- parseYieldExpression: true, parseAwaitExpression: true
2341
- */
2342
-
2343
2339
  (function (root, factory) {
2344
2340
  'use strict';
2345
2341
 
@@ -2389,8 +2385,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2389
2385
  StringLiteral: 8,
2390
2386
  RegularExpression: 9,
2391
2387
  Template: 10,
2392
- XJSIdentifier: 11,
2393
- XJSText: 12
2388
+ JSXIdentifier: 11,
2389
+ JSXText: 12
2394
2390
  };
2395
2391
 
2396
2392
  TokenName = {};
@@ -2402,8 +2398,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2402
2398
  TokenName[Token.NumericLiteral] = 'Numeric';
2403
2399
  TokenName[Token.Punctuator] = 'Punctuator';
2404
2400
  TokenName[Token.StringLiteral] = 'String';
2405
- TokenName[Token.XJSIdentifier] = 'XJSIdentifier';
2406
- TokenName[Token.XJSText] = 'XJSText';
2401
+ TokenName[Token.JSXIdentifier] = 'JSXIdentifier';
2402
+ TokenName[Token.JSXText] = 'JSXText';
2407
2403
  TokenName[Token.RegularExpression] = 'RegularExpression';
2408
2404
 
2409
2405
  // A function following one of those tokens is an expression.
@@ -2514,17 +2510,17 @@ parseYieldExpression: true, parseAwaitExpression: true
2514
2510
  VoidTypeAnnotation: 'VoidTypeAnnotation',
2515
2511
  WhileStatement: 'WhileStatement',
2516
2512
  WithStatement: 'WithStatement',
2517
- XJSIdentifier: 'XJSIdentifier',
2518
- XJSNamespacedName: 'XJSNamespacedName',
2519
- XJSMemberExpression: 'XJSMemberExpression',
2520
- XJSEmptyExpression: 'XJSEmptyExpression',
2521
- XJSExpressionContainer: 'XJSExpressionContainer',
2522
- XJSElement: 'XJSElement',
2523
- XJSClosingElement: 'XJSClosingElement',
2524
- XJSOpeningElement: 'XJSOpeningElement',
2525
- XJSAttribute: 'XJSAttribute',
2526
- XJSSpreadAttribute: 'XJSSpreadAttribute',
2527
- XJSText: 'XJSText',
2513
+ JSXIdentifier: 'JSXIdentifier',
2514
+ JSXNamespacedName: 'JSXNamespacedName',
2515
+ JSXMemberExpression: 'JSXMemberExpression',
2516
+ JSXEmptyExpression: 'JSXEmptyExpression',
2517
+ JSXExpressionContainer: 'JSXExpressionContainer',
2518
+ JSXElement: 'JSXElement',
2519
+ JSXClosingElement: 'JSXClosingElement',
2520
+ JSXOpeningElement: 'JSXOpeningElement',
2521
+ JSXAttribute: 'JSXAttribute',
2522
+ JSXSpreadAttribute: 'JSXSpreadAttribute',
2523
+ JSXText: 'JSXText',
2528
2524
  YieldExpression: 'YieldExpression',
2529
2525
  AwaitExpression: 'AwaitExpression'
2530
2526
  };
@@ -2542,32 +2538,33 @@ parseYieldExpression: true, parseAwaitExpression: true
2542
2538
 
2543
2539
  // Error messages should be identical to V8.
2544
2540
  Messages = {
2545
- UnexpectedToken: 'Unexpected token %0',
2546
- UnexpectedNumber: 'Unexpected number',
2547
- UnexpectedString: 'Unexpected string',
2548
- UnexpectedIdentifier: 'Unexpected identifier',
2549
- UnexpectedReserved: 'Unexpected reserved word',
2550
- UnexpectedTemplate: 'Unexpected quasi %0',
2551
- UnexpectedEOS: 'Unexpected end of input',
2552
- NewlineAfterThrow: 'Illegal newline after throw',
2541
+ UnexpectedToken: 'Unexpected token %0',
2542
+ UnexpectedNumber: 'Unexpected number',
2543
+ UnexpectedString: 'Unexpected string',
2544
+ UnexpectedIdentifier: 'Unexpected identifier',
2545
+ UnexpectedReserved: 'Unexpected reserved word',
2546
+ UnexpectedTemplate: 'Unexpected quasi %0',
2547
+ UnexpectedEOS: 'Unexpected end of input',
2548
+ NewlineAfterThrow: 'Illegal newline after throw',
2553
2549
  InvalidRegExp: 'Invalid regular expression',
2554
- UnterminatedRegExp: 'Invalid regular expression: missing /',
2555
- InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
2556
- InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
2557
- InvalidLHSInForIn: 'Invalid left-hand side in for-in',
2550
+ UnterminatedRegExp: 'Invalid regular expression: missing /',
2551
+ InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
2552
+ InvalidLHSInFormalsList: 'Invalid left-hand side in formals list',
2553
+ InvalidLHSInForIn: 'Invalid left-hand side in for-in',
2558
2554
  MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
2559
- NoCatchOrFinally: 'Missing catch or finally after try',
2555
+ NoCatchOrFinally: 'Missing catch or finally after try',
2560
2556
  UnknownLabel: 'Undefined label \'%0\'',
2561
2557
  Redeclaration: '%0 \'%1\' has already been declared',
2562
2558
  IllegalContinue: 'Illegal continue statement',
2563
2559
  IllegalBreak: 'Illegal break statement',
2564
2560
  IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
2561
+ IllegalClassConstructorProperty: 'Illegal constructor property in class definition',
2565
2562
  IllegalReturn: 'Illegal return statement',
2566
2563
  IllegalSpread: 'Illegal spread element',
2567
- StrictModeWith: 'Strict mode code may not include a with statement',
2568
- StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
2569
- StrictVarName: 'Variable name may not be eval or arguments in strict mode',
2570
- StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
2564
+ StrictModeWith: 'Strict mode code may not include a with statement',
2565
+ StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
2566
+ StrictVarName: 'Variable name may not be eval or arguments in strict mode',
2567
+ StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
2571
2568
  StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
2572
2569
  ParameterAfterRestParameter: 'Rest parameter must be final parameter of an argument list',
2573
2570
  DefaultRestParameter: 'Rest parameter can not have a default value',
@@ -2575,28 +2572,28 @@ parseYieldExpression: true, parseAwaitExpression: true
2575
2572
  PropertyAfterSpreadProperty: 'A rest property must be the final property of an object literal',
2576
2573
  ObjectPatternAsRestParameter: 'Invalid rest parameter',
2577
2574
  ObjectPatternAsSpread: 'Invalid spread argument',
2578
- StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
2579
- StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
2580
- StrictDelete: 'Delete of an unqualified identifier in strict mode.',
2581
- StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
2582
- AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
2583
- AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
2584
- StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
2585
- StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
2586
- StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
2587
- StrictReservedWord: 'Use of future reserved word in strict mode',
2575
+ StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
2576
+ StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
2577
+ StrictDelete: 'Delete of an unqualified identifier in strict mode.',
2578
+ StrictDuplicateProperty: 'Duplicate data property in object literal not allowed in strict mode',
2579
+ AccessorDataProperty: 'Object literal may not have data and accessor property with the same name',
2580
+ AccessorGetSet: 'Object literal may not have multiple get/set accessors with the same name',
2581
+ StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
2582
+ StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
2583
+ StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
2584
+ StrictReservedWord: 'Use of future reserved word in strict mode',
2588
2585
  MissingFromClause: 'Missing from clause',
2589
2586
  NoAsAfterImportNamespace: 'Missing as after import *',
2590
2587
  InvalidModuleSpecifier: 'Invalid module specifier',
2591
2588
  IllegalImportDeclaration: 'Illegal import declaration',
2592
2589
  IllegalExportDeclaration: 'Illegal export declaration',
2593
- NoUnintializedConst: 'Const must be initialized',
2590
+ NoUninitializedConst: 'Const must be initialized',
2594
2591
  ComprehensionRequiresBlock: 'Comprehension must have at least one block',
2595
- ComprehensionError: 'Comprehension Error',
2596
- EachNotAllowed: 'Each is not supported',
2597
- InvalidXJSAttributeValue: 'XJS value should be either an expression or a quoted XJS text',
2598
- ExpectedXJSClosingTag: 'Expected corresponding XJS closing tag for %0',
2599
- AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag',
2592
+ ComprehensionError: 'Comprehension Error',
2593
+ EachNotAllowed: 'Each is not supported',
2594
+ InvalidJSXAttributeValue: 'JSX value should be either an expression or a quoted JSX text',
2595
+ ExpectedJSXClosingTag: 'Expected corresponding JSX closing tag for %0',
2596
+ AdjacentJSXElements: 'Adjacent JSX elements must be wrapped in an enclosing tag',
2600
2597
  ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
2601
2598
  'you are trying to write a function type, but you ended up ' +
2602
2599
  'writing a grouped type followed by an =>, which is a syntax ' +
@@ -2644,7 +2641,7 @@ parseYieldExpression: true, parseAwaitExpression: true
2644
2641
  return Object.prototype.hasOwnProperty.call(this.$data, key);
2645
2642
  };
2646
2643
 
2647
- StringMap.prototype['delete'] = function (key) {
2644
+ StringMap.prototype["delete"] = function (key) {
2648
2645
  key = '$' + key;
2649
2646
  return delete this.$data[key];
2650
2647
  };
@@ -2776,69 +2773,134 @@ parseYieldExpression: true, parseAwaitExpression: true
2776
2773
 
2777
2774
  // 7.4 Comments
2778
2775
 
2779
- function skipComment() {
2780
- var ch, blockComment, lineComment;
2776
+ function addComment(type, value, start, end, loc) {
2777
+ var comment;
2778
+ assert(typeof start === 'number', 'Comment must have valid position');
2781
2779
 
2782
- blockComment = false;
2783
- lineComment = false;
2780
+ // Because the way the actual token is scanned, often the comments
2781
+ // (if any) are skipped twice during the lexical analysis.
2782
+ // Thus, we need to skip adding a comment if the comment array already
2783
+ // handled it.
2784
+ if (state.lastCommentStart >= start) {
2785
+ return;
2786
+ }
2787
+ state.lastCommentStart = start;
2788
+
2789
+ comment = {
2790
+ type: type,
2791
+ value: value
2792
+ };
2793
+ if (extra.range) {
2794
+ comment.range = [start, end];
2795
+ }
2796
+ if (extra.loc) {
2797
+ comment.loc = loc;
2798
+ }
2799
+ extra.comments.push(comment);
2800
+ if (extra.attachComment) {
2801
+ extra.leadingComments.push(comment);
2802
+ extra.trailingComments.push(comment);
2803
+ }
2804
+ }
2805
+
2806
+ function skipSingleLineComment() {
2807
+ var start, loc, ch, comment;
2808
+
2809
+ start = index - 2;
2810
+ loc = {
2811
+ start: {
2812
+ line: lineNumber,
2813
+ column: index - lineStart - 2
2814
+ }
2815
+ };
2784
2816
 
2785
2817
  while (index < length) {
2786
2818
  ch = source.charCodeAt(index);
2819
+ ++index;
2820
+ if (isLineTerminator(ch)) {
2821
+ if (extra.comments) {
2822
+ comment = source.slice(start + 2, index - 1);
2823
+ loc.end = {
2824
+ line: lineNumber,
2825
+ column: index - lineStart - 1
2826
+ };
2827
+ addComment('Line', comment, start, index - 1, loc);
2828
+ }
2829
+ if (ch === 13 && source.charCodeAt(index) === 10) {
2830
+ ++index;
2831
+ }
2832
+ ++lineNumber;
2833
+ lineStart = index;
2834
+ return;
2835
+ }
2836
+ }
2787
2837
 
2788
- if (lineComment) {
2789
- ++index;
2790
- if (isLineTerminator(ch)) {
2791
- lineComment = false;
2792
- if (ch === 13 && source.charCodeAt(index) === 10) {
2793
- ++index;
2794
- }
2795
- ++lineNumber;
2796
- lineStart = index;
2838
+ if (extra.comments) {
2839
+ comment = source.slice(start + 2, index);
2840
+ loc.end = {
2841
+ line: lineNumber,
2842
+ column: index - lineStart
2843
+ };
2844
+ addComment('Line', comment, start, index, loc);
2845
+ }
2846
+ }
2847
+
2848
+ function skipMultiLineComment() {
2849
+ var start, loc, ch, comment;
2850
+
2851
+ if (extra.comments) {
2852
+ start = index - 2;
2853
+ loc = {
2854
+ start: {
2855
+ line: lineNumber,
2856
+ column: index - lineStart - 2
2797
2857
  }
2798
- } else if (blockComment) {
2799
- if (isLineTerminator(ch)) {
2800
- if (ch === 13) {
2801
- ++index;
2802
- }
2803
- if (ch !== 13 || source.charCodeAt(index) === 10) {
2804
- ++lineNumber;
2805
- ++index;
2806
- lineStart = index;
2807
- if (index >= length) {
2808
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2809
- }
2810
- }
2811
- } else {
2812
- ch = source.charCodeAt(index++);
2813
- if (index >= length) {
2814
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2815
- }
2816
- // Block comment ends with '*/' (char #42, char #47).
2817
- if (ch === 42) {
2818
- ch = source.charCodeAt(index);
2819
- if (ch === 47) {
2820
- ++index;
2821
- blockComment = false;
2822
- }
2823
- }
2858
+ };
2859
+ }
2860
+
2861
+ while (index < length) {
2862
+ ch = source.charCodeAt(index);
2863
+ if (isLineTerminator(ch)) {
2864
+ if (ch === 13 && source.charCodeAt(index + 1) === 10) {
2865
+ ++index;
2824
2866
  }
2825
- } else if (ch === 47) {
2826
- ch = source.charCodeAt(index + 1);
2827
- // Line comment starts with '//' (char #47, char #47).
2828
- if (ch === 47) {
2829
- index += 2;
2830
- lineComment = true;
2831
- } else if (ch === 42) {
2832
- // Block comment starts with '/*' (char #47, char #42).
2833
- index += 2;
2834
- blockComment = true;
2835
- if (index >= length) {
2836
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2867
+ ++lineNumber;
2868
+ ++index;
2869
+ lineStart = index;
2870
+ if (index >= length) {
2871
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2872
+ }
2873
+ } else if (ch === 42) {
2874
+ // Block comment ends with '*/' (char #42, char #47).
2875
+ if (source.charCodeAt(index + 1) === 47) {
2876
+ ++index;
2877
+ ++index;
2878
+ if (extra.comments) {
2879
+ comment = source.slice(start + 2, index - 2);
2880
+ loc.end = {
2881
+ line: lineNumber,
2882
+ column: index - lineStart
2883
+ };
2884
+ addComment('Block', comment, start, index, loc);
2837
2885
  }
2838
- } else {
2839
- break;
2886
+ return;
2840
2887
  }
2841
- } else if (isWhiteSpace(ch)) {
2888
+ ++index;
2889
+ } else {
2890
+ ++index;
2891
+ }
2892
+ }
2893
+
2894
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2895
+ }
2896
+
2897
+ function skipComment() {
2898
+ var ch;
2899
+
2900
+ while (index < length) {
2901
+ ch = source.charCodeAt(index);
2902
+
2903
+ if (isWhiteSpace(ch)) {
2842
2904
  ++index;
2843
2905
  } else if (isLineTerminator(ch)) {
2844
2906
  ++index;
@@ -2847,6 +2909,19 @@ parseYieldExpression: true, parseAwaitExpression: true
2847
2909
  }
2848
2910
  ++lineNumber;
2849
2911
  lineStart = index;
2912
+ } else if (ch === 47) { // 47 is '/'
2913
+ ch = source.charCodeAt(index + 1);
2914
+ if (ch === 47) {
2915
+ ++index;
2916
+ ++index;
2917
+ skipSingleLineComment();
2918
+ } else if (ch === 42) { // 42 is '*'
2919
+ ++index;
2920
+ ++index;
2921
+ skipMultiLineComment();
2922
+ } else {
2923
+ break;
2924
+ }
2850
2925
  } else {
2851
2926
  break;
2852
2927
  }
@@ -3009,7 +3084,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3009
3084
  ch3,
3010
3085
  ch4;
3011
3086
 
3012
- if (state.inXJSTag || state.inXJSChild) {
3087
+ if (state.inJSXTag || state.inJSXChild) {
3013
3088
  // Don't need to check for '{' and '}' as it's already handled
3014
3089
  // correctly by default.
3015
3090
  switch (code) {
@@ -3125,7 +3200,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3125
3200
 
3126
3201
  // 3-character punctuators: === !== >>> <<= >>=
3127
3202
 
3128
- if (ch1 === '>' && ch2 === '>' && ch3 === '>') {
3203
+ if (ch1 === '>' && ch2 === '>' && ch3 === '>' && !state.inType) {
3129
3204
  index += 3;
3130
3205
  return {
3131
3206
  type: Token.Punctuator,
@@ -3249,6 +3324,41 @@ parseYieldExpression: true, parseAwaitExpression: true
3249
3324
  };
3250
3325
  }
3251
3326
 
3327
+ function scanBinaryLiteral(start) {
3328
+ var ch, number;
3329
+
3330
+ number = '';
3331
+
3332
+ while (index < length) {
3333
+ ch = source[index];
3334
+ if (ch !== '0' && ch !== '1') {
3335
+ break;
3336
+ }
3337
+ number += source[index++];
3338
+ }
3339
+
3340
+ if (number.length === 0) {
3341
+ // only 0b or 0B
3342
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3343
+ }
3344
+
3345
+ if (index < length) {
3346
+ ch = source.charCodeAt(index);
3347
+ /* istanbul ignore else */
3348
+ if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
3349
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3350
+ }
3351
+ }
3352
+
3353
+ return {
3354
+ type: Token.NumericLiteral,
3355
+ value: parseInt(number, 2),
3356
+ lineNumber: lineNumber,
3357
+ lineStart: lineStart,
3358
+ range: [start, index]
3359
+ };
3360
+ }
3361
+
3252
3362
  function scanOctalLiteral(prefix, start) {
3253
3363
  var number, octal;
3254
3364
 
@@ -3288,7 +3398,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3288
3398
  }
3289
3399
 
3290
3400
  function scanNumericLiteral() {
3291
- var number, start, ch, octal;
3401
+ var number, start, ch;
3292
3402
 
3293
3403
  ch = source[index];
3294
3404
  assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
@@ -3311,35 +3421,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3311
3421
  }
3312
3422
  if (ch === 'b' || ch === 'B') {
3313
3423
  ++index;
3314
- number = '';
3315
-
3316
- while (index < length) {
3317
- ch = source[index];
3318
- if (ch !== '0' && ch !== '1') {
3319
- break;
3320
- }
3321
- number += source[index++];
3322
- }
3323
-
3324
- if (number.length === 0) {
3325
- // only 0b or 0B
3326
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3327
- }
3328
-
3329
- if (index < length) {
3330
- ch = source.charCodeAt(index);
3331
- /* istanbul ignore else */
3332
- if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
3333
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3334
- }
3335
- }
3336
- return {
3337
- type: Token.NumericLiteral,
3338
- value: parseInt(number, 2),
3339
- lineNumber: lineNumber,
3340
- lineStart: lineStart,
3341
- range: [start, index]
3342
- };
3424
+ return scanBinaryLiteral(start);
3343
3425
  }
3344
3426
  if (ch === 'o' || ch === 'O' || isOctalDigit(ch)) {
3345
3427
  return scanOctalLiteral(ch, start);
@@ -3480,7 +3562,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3480
3562
  }
3481
3563
  } else {
3482
3564
  ++lineNumber;
3483
- if (ch === '\r' && source[index] === '\n') {
3565
+ if (ch === '\r' && source[index] === '\n') {
3484
3566
  ++index;
3485
3567
  }
3486
3568
  lineStart = index;
@@ -3597,14 +3679,14 @@ parseYieldExpression: true, parseAwaitExpression: true
3597
3679
  }
3598
3680
  } else {
3599
3681
  ++lineNumber;
3600
- if (ch === '\r' && source[index] === '\n') {
3682
+ if (ch === '\r' && source[index] === '\n') {
3601
3683
  ++index;
3602
3684
  }
3603
3685
  lineStart = index;
3604
3686
  }
3605
3687
  } else if (isLineTerminator(ch.charCodeAt(0))) {
3606
3688
  ++lineNumber;
3607
- if (ch === '\r' && source[index] === '\n') {
3689
+ if (ch === '\r' && source[index] === '\n') {
3608
3690
  ++index;
3609
3691
  }
3610
3692
  lineStart = index;
@@ -3651,39 +3733,77 @@ parseYieldExpression: true, parseAwaitExpression: true
3651
3733
  return template;
3652
3734
  }
3653
3735
 
3654
- function scanRegExp() {
3655
- var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false, tmp;
3736
+ function testRegExp(pattern, flags) {
3737
+ var tmp = pattern,
3738
+ value;
3656
3739
 
3657
- lookahead = null;
3658
- skipComment();
3740
+ if (flags.indexOf('u') >= 0) {
3741
+ // Replace each astral symbol and every Unicode code point
3742
+ // escape sequence with a single ASCII symbol to avoid throwing on
3743
+ // regular expressions that are only valid in combination with the
3744
+ // `/u` flag.
3745
+ // Note: replacing with the ASCII symbol `x` might cause false
3746
+ // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
3747
+ // perfectly valid pattern that is equivalent to `[a-b]`, but it
3748
+ // would be replaced by `[x-b]` which throws an error.
3749
+ tmp = tmp
3750
+ .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
3751
+ if (parseInt($1, 16) <= 0x10FFFF) {
3752
+ return 'x';
3753
+ }
3754
+ throwError({}, Messages.InvalidRegExp);
3755
+ })
3756
+ .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
3757
+ }
3758
+
3759
+ // First, detect invalid regular expressions.
3760
+ try {
3761
+ value = new RegExp(tmp);
3762
+ } catch (e) {
3763
+ throwError({}, Messages.InvalidRegExp);
3764
+ }
3765
+
3766
+ // Return a regular expression object for this pattern-flag pair, or
3767
+ // `null` in case the current environment doesn't support the flags it
3768
+ // uses.
3769
+ try {
3770
+ return new RegExp(pattern, flags);
3771
+ } catch (exception) {
3772
+ return null;
3773
+ }
3774
+ }
3775
+
3776
+ function scanRegExpBody() {
3777
+ var ch, str, classMarker, terminated, body;
3659
3778
 
3660
- start = index;
3661
3779
  ch = source[index];
3662
3780
  assert(ch === '/', 'Regular expression literal must start with a slash');
3663
3781
  str = source[index++];
3664
3782
 
3783
+ classMarker = false;
3784
+ terminated = false;
3665
3785
  while (index < length) {
3666
3786
  ch = source[index++];
3667
3787
  str += ch;
3668
- if (classMarker) {
3788
+ if (ch === '\\') {
3789
+ ch = source[index++];
3790
+ // ECMA-262 7.8.5
3791
+ if (isLineTerminator(ch.charCodeAt(0))) {
3792
+ throwError({}, Messages.UnterminatedRegExp);
3793
+ }
3794
+ str += ch;
3795
+ } else if (isLineTerminator(ch.charCodeAt(0))) {
3796
+ throwError({}, Messages.UnterminatedRegExp);
3797
+ } else if (classMarker) {
3669
3798
  if (ch === ']') {
3670
3799
  classMarker = false;
3671
3800
  }
3672
3801
  } else {
3673
- if (ch === '\\') {
3674
- ch = source[index++];
3675
- // ECMA-262 7.8.5
3676
- if (isLineTerminator(ch.charCodeAt(0))) {
3677
- throwError({}, Messages.UnterminatedRegExp);
3678
- }
3679
- str += ch;
3680
- } else if (ch === '/') {
3802
+ if (ch === '/') {
3681
3803
  terminated = true;
3682
3804
  break;
3683
3805
  } else if (ch === '[') {
3684
3806
  classMarker = true;
3685
- } else if (isLineTerminator(ch.charCodeAt(0))) {
3686
- throwError({}, Messages.UnterminatedRegExp);
3687
3807
  }
3688
3808
  }
3689
3809
  }
@@ -3693,8 +3813,17 @@ parseYieldExpression: true, parseAwaitExpression: true
3693
3813
  }
3694
3814
 
3695
3815
  // Exclude leading and trailing slash.
3696
- pattern = str.substr(1, str.length - 2);
3816
+ body = str.substr(1, str.length - 2);
3817
+ return {
3818
+ value: body,
3819
+ literal: str
3820
+ };
3821
+ }
3822
+
3823
+ function scanRegExpFlags() {
3824
+ var ch, str, flags, restore;
3697
3825
 
3826
+ str = '';
3698
3827
  flags = '';
3699
3828
  while (index < length) {
3700
3829
  ch = source[index];
@@ -3709,7 +3838,6 @@ parseYieldExpression: true, parseAwaitExpression: true
3709
3838
  ++index;
3710
3839
  restore = index;
3711
3840
  ch = scanHexEscape('u');
3712
- /* istanbul ignore else */
3713
3841
  if (ch) {
3714
3842
  flags += ch;
3715
3843
  for (str += '\\u'; restore < index; ++restore) {
@@ -3723,6 +3851,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3723
3851
  throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
3724
3852
  } else {
3725
3853
  str += '\\';
3854
+ throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
3726
3855
  }
3727
3856
  } else {
3728
3857
  flags += ch;
@@ -3730,61 +3859,43 @@ parseYieldExpression: true, parseAwaitExpression: true
3730
3859
  }
3731
3860
  }
3732
3861
 
3733
- tmp = pattern;
3734
- if (flags.indexOf('u') >= 0) {
3735
- // Replace each astral symbol and every Unicode code point
3736
- // escape sequence with a single ASCII symbol to avoid throwing on
3737
- // regular expressions that are only valid in combination with the
3738
- // `/u` flag.
3739
- // Note: replacing with the ASCII symbol `x` might cause false
3740
- // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
3741
- // perfectly valid pattern that is equivalent to `[a-b]`, but it
3742
- // would be replaced by `[x-b]` which throws an error.
3743
- tmp = tmp
3744
- .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
3745
- if (parseInt($1, 16) <= 0x10FFFF) {
3746
- return 'x';
3747
- }
3748
- throwError({}, Messages.InvalidRegExp);
3749
- })
3750
- .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
3751
- }
3862
+ return {
3863
+ value: flags,
3864
+ literal: str
3865
+ };
3866
+ }
3752
3867
 
3753
- // First, detect invalid regular expressions.
3754
- try {
3755
- value = new RegExp(tmp);
3756
- } catch (e) {
3757
- throwError({}, Messages.InvalidRegExp);
3758
- }
3868
+ function scanRegExp() {
3869
+ var start, body, flags, value;
3759
3870
 
3760
- // Return a regular expression object for this pattern-flag pair, or
3761
- // `null` in case the current environment doesn't support the flags it
3762
- // uses.
3763
- try {
3764
- value = new RegExp(pattern, flags);
3765
- } catch (exception) {
3766
- value = null;
3767
- }
3871
+ lookahead = null;
3872
+ skipComment();
3873
+ start = index;
3874
+
3875
+ body = scanRegExpBody();
3876
+ flags = scanRegExpFlags();
3877
+ value = testRegExp(body.value, flags.value);
3768
3878
 
3769
3879
  if (extra.tokenize) {
3770
3880
  return {
3771
3881
  type: Token.RegularExpression,
3772
3882
  value: value,
3773
3883
  regex: {
3774
- pattern: pattern,
3775
- flags: flags
3884
+ pattern: body.value,
3885
+ flags: flags.value
3776
3886
  },
3777
3887
  lineNumber: lineNumber,
3778
3888
  lineStart: lineStart,
3779
3889
  range: [start, index]
3780
3890
  };
3781
3891
  }
3892
+
3782
3893
  return {
3783
- literal: str,
3894
+ literal: body.literal + flags.literal,
3784
3895
  value: value,
3785
3896
  regex: {
3786
- pattern: pattern,
3787
- flags: flags
3897
+ pattern: body.value,
3898
+ flags: flags.value
3788
3899
  },
3789
3900
  range: [start, index]
3790
3901
  };
@@ -3851,7 +3962,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3851
3962
  }
3852
3963
  return scanRegExp();
3853
3964
  }
3854
- if (prevToken.type === 'Keyword') {
3965
+ if (prevToken.type === 'Keyword' && prevToken.value !== 'this') {
3855
3966
  return scanRegExp();
3856
3967
  }
3857
3968
  return scanPunctuator();
@@ -3860,7 +3971,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3860
3971
  function advance() {
3861
3972
  var ch;
3862
3973
 
3863
- if (!state.inXJSChild) {
3974
+ if (!state.inJSXChild) {
3864
3975
  skipComment();
3865
3976
  }
3866
3977
 
@@ -3873,8 +3984,8 @@ parseYieldExpression: true, parseAwaitExpression: true
3873
3984
  };
3874
3985
  }
3875
3986
 
3876
- if (state.inXJSChild) {
3877
- return advanceXJSChild();
3987
+ if (state.inJSXChild) {
3988
+ return advanceJSXChild();
3878
3989
  }
3879
3990
 
3880
3991
  ch = source.charCodeAt(index);
@@ -3886,14 +3997,14 @@ parseYieldExpression: true, parseAwaitExpression: true
3886
3997
 
3887
3998
  // String literal starts with single quote (#39) or double quote (#34).
3888
3999
  if (ch === 39 || ch === 34) {
3889
- if (state.inXJSTag) {
3890
- return scanXJSStringLiteral();
4000
+ if (state.inJSXTag) {
4001
+ return scanJSXStringLiteral();
3891
4002
  }
3892
4003
  return scanStringLiteral();
3893
4004
  }
3894
4005
 
3895
- if (state.inXJSTag && isXJSIdentifierStart(ch)) {
3896
- return scanXJSIdentifier();
4006
+ if (state.inJSXTag && isJSXIdentifierStart(ch)) {
4007
+ return scanJSXIdentifier();
3897
4008
  }
3898
4009
 
3899
4010
  if (ch === 96) {
@@ -4504,78 +4615,78 @@ parseYieldExpression: true, parseAwaitExpression: true
4504
4615
  };
4505
4616
  },
4506
4617
 
4507
- createXJSAttribute: function (name, value) {
4618
+ createJSXAttribute: function (name, value) {
4508
4619
  return {
4509
- type: Syntax.XJSAttribute,
4620
+ type: Syntax.JSXAttribute,
4510
4621
  name: name,
4511
4622
  value: value || null
4512
4623
  };
4513
4624
  },
4514
4625
 
4515
- createXJSSpreadAttribute: function (argument) {
4626
+ createJSXSpreadAttribute: function (argument) {
4516
4627
  return {
4517
- type: Syntax.XJSSpreadAttribute,
4628
+ type: Syntax.JSXSpreadAttribute,
4518
4629
  argument: argument
4519
4630
  };
4520
4631
  },
4521
4632
 
4522
- createXJSIdentifier: function (name) {
4633
+ createJSXIdentifier: function (name) {
4523
4634
  return {
4524
- type: Syntax.XJSIdentifier,
4635
+ type: Syntax.JSXIdentifier,
4525
4636
  name: name
4526
4637
  };
4527
4638
  },
4528
4639
 
4529
- createXJSNamespacedName: function (namespace, name) {
4640
+ createJSXNamespacedName: function (namespace, name) {
4530
4641
  return {
4531
- type: Syntax.XJSNamespacedName,
4642
+ type: Syntax.JSXNamespacedName,
4532
4643
  namespace: namespace,
4533
4644
  name: name
4534
4645
  };
4535
4646
  },
4536
4647
 
4537
- createXJSMemberExpression: function (object, property) {
4648
+ createJSXMemberExpression: function (object, property) {
4538
4649
  return {
4539
- type: Syntax.XJSMemberExpression,
4650
+ type: Syntax.JSXMemberExpression,
4540
4651
  object: object,
4541
4652
  property: property
4542
4653
  };
4543
4654
  },
4544
4655
 
4545
- createXJSElement: function (openingElement, closingElement, children) {
4656
+ createJSXElement: function (openingElement, closingElement, children) {
4546
4657
  return {
4547
- type: Syntax.XJSElement,
4658
+ type: Syntax.JSXElement,
4548
4659
  openingElement: openingElement,
4549
4660
  closingElement: closingElement,
4550
4661
  children: children
4551
4662
  };
4552
4663
  },
4553
4664
 
4554
- createXJSEmptyExpression: function () {
4665
+ createJSXEmptyExpression: function () {
4555
4666
  return {
4556
- type: Syntax.XJSEmptyExpression
4667
+ type: Syntax.JSXEmptyExpression
4557
4668
  };
4558
4669
  },
4559
4670
 
4560
- createXJSExpressionContainer: function (expression) {
4671
+ createJSXExpressionContainer: function (expression) {
4561
4672
  return {
4562
- type: Syntax.XJSExpressionContainer,
4673
+ type: Syntax.JSXExpressionContainer,
4563
4674
  expression: expression
4564
4675
  };
4565
4676
  },
4566
4677
 
4567
- createXJSOpeningElement: function (name, attributes, selfClosing) {
4678
+ createJSXOpeningElement: function (name, attributes, selfClosing) {
4568
4679
  return {
4569
- type: Syntax.XJSOpeningElement,
4680
+ type: Syntax.JSXOpeningElement,
4570
4681
  name: name,
4571
4682
  selfClosing: selfClosing,
4572
4683
  attributes: attributes
4573
4684
  };
4574
4685
  },
4575
4686
 
4576
- createXJSClosingElement: function (name) {
4687
+ createJSXClosingElement: function (name) {
4577
4688
  return {
4578
- type: Syntax.XJSClosingElement,
4689
+ type: Syntax.JSXClosingElement,
4579
4690
  name: name
4580
4691
  };
4581
4692
  },
@@ -4916,13 +5027,13 @@ parseYieldExpression: true, parseAwaitExpression: true
4916
5027
  };
4917
5028
  },
4918
5029
 
4919
- createExportDeclaration: function (isDefault, declaration, specifiers, source) {
5030
+ createExportDeclaration: function (isDefault, declaration, specifiers, src) {
4920
5031
  return {
4921
5032
  type: Syntax.ExportDeclaration,
4922
5033
  'default': !!isDefault,
4923
5034
  declaration: declaration,
4924
5035
  specifiers: specifiers,
4925
- source: source
5036
+ source: src
4926
5037
  };
4927
5038
  },
4928
5039
 
@@ -4934,20 +5045,20 @@ parseYieldExpression: true, parseAwaitExpression: true
4934
5045
  };
4935
5046
  },
4936
5047
 
4937
- createImportDeclaration: function (specifiers, source, isType) {
5048
+ createImportDeclaration: function (specifiers, src, isType) {
4938
5049
  return {
4939
5050
  type: Syntax.ImportDeclaration,
4940
5051
  specifiers: specifiers,
4941
- source: source,
5052
+ source: src,
4942
5053
  isType: isType
4943
5054
  };
4944
5055
  },
4945
5056
 
4946
- createYieldExpression: function (argument, delegate) {
5057
+ createYieldExpression: function (argument, dlg) {
4947
5058
  return {
4948
5059
  type: Syntax.YieldExpression,
4949
5060
  argument: argument,
4950
- delegate: delegate
5061
+ delegate: dlg
4951
5062
  };
4952
5063
  },
4953
5064
 
@@ -4993,9 +5104,9 @@ parseYieldExpression: true, parseAwaitExpression: true
4993
5104
  args = Array.prototype.slice.call(arguments, 2),
4994
5105
  msg = messageFormat.replace(
4995
5106
  /%(\d)/g,
4996
- function (whole, index) {
4997
- assert(index < args.length, 'Message reference must be in range');
4998
- return args[index];
5107
+ function (whole, idx) {
5108
+ assert(idx < args.length, 'Message reference must be in range');
5109
+ return args[idx];
4999
5110
  }
5000
5111
  );
5001
5112
 
@@ -5039,7 +5150,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5039
5150
  throwError(token, Messages.UnexpectedNumber);
5040
5151
  }
5041
5152
 
5042
- if (token.type === Token.StringLiteral || token.type === Token.XJSText) {
5153
+ if (token.type === Token.StringLiteral || token.type === Token.JSXText) {
5043
5154
  throwError(token, Messages.UnexpectedString);
5044
5155
  }
5045
5156
 
@@ -5202,7 +5313,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5202
5313
  // 11.1.4 Array Initialiser
5203
5314
 
5204
5315
  function parseArrayInitialiser() {
5205
- var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true, body,
5316
+ var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true,
5206
5317
  marker = markerCreate();
5207
5318
 
5208
5319
  expect('[');
@@ -5358,7 +5469,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5358
5469
  }
5359
5470
 
5360
5471
  function parseObjectProperty() {
5361
- var token, key, id, value, param, expr, computed,
5472
+ var token, key, id, param, computed,
5362
5473
  marker = markerCreate(), returnType, typeParameters;
5363
5474
 
5364
5475
  token = lookahead;
@@ -5764,7 +5875,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5764
5875
  }
5765
5876
 
5766
5877
  if (match('<')) {
5767
- return parseXJSElement();
5878
+ return parseJSXElement();
5768
5879
  }
5769
5880
 
5770
5881
  throwUnexpected(lex());
@@ -6412,9 +6523,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6412
6523
  // 11.14 Comma Operator
6413
6524
 
6414
6525
  function parseExpression() {
6415
- var marker, expr, expressions, sequence, coverFormalsList, spreadFound, oldParenthesizedCount;
6416
-
6417
- oldParenthesizedCount = state.parenthesizedCount;
6526
+ var marker, expr, expressions, sequence, spreadFound;
6418
6527
 
6419
6528
  marker = markerCreate();
6420
6529
  expr = parseAssignmentExpression();
@@ -6488,7 +6597,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6488
6597
 
6489
6598
  expect('<');
6490
6599
  while (!match('>')) {
6491
- paramTypes.push(parseVariableIdentifier());
6600
+ paramTypes.push(parseTypeAnnotatableIdentifier());
6492
6601
  if (!match('>')) {
6493
6602
  expect(',');
6494
6603
  }
@@ -6592,7 +6701,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6592
6701
 
6593
6702
  function parseObjectType(allowStatic) {
6594
6703
  var callProperties = [], indexers = [], marker, optional = false,
6595
- properties = [], property, propertyKey, propertyTypeAnnotation,
6704
+ properties = [], propertyKey, propertyTypeAnnotation,
6596
6705
  token, isStatic, matchStatic;
6597
6706
 
6598
6707
  expect('{');
@@ -6656,9 +6765,8 @@ parseYieldExpression: true, parseAwaitExpression: true
6656
6765
  }
6657
6766
 
6658
6767
  function parseGenericType() {
6659
- var marker = markerCreate(), returnType = null,
6660
- typeParameters = null, typeIdentifier,
6661
- typeIdentifierMarker = markerCreate;
6768
+ var marker = markerCreate(),
6769
+ typeParameters = null, typeIdentifier;
6662
6770
 
6663
6771
  typeIdentifier = parseVariableIdentifier();
6664
6772
 
@@ -6748,7 +6856,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6748
6856
  // primary types are kind of like primary expressions...they're the
6749
6857
  // primitives with which other types are constructed.
6750
6858
  function parsePrimaryType() {
6751
- var typeIdentifier = null, params = null, returnType = null,
6859
+ var params = null, returnType = null,
6752
6860
  marker = markerCreate(), rest = null, tmp,
6753
6861
  typeParameters, token, type, isGroupedType = false;
6754
6862
 
@@ -6994,7 +7102,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6994
7102
 
6995
7103
  if (kind === 'const') {
6996
7104
  if (!match('=')) {
6997
- throwError({}, Messages.NoUnintializedConst);
7105
+ throwError({}, Messages.NoUninitializedConst);
6998
7106
  }
6999
7107
  expect('=');
7000
7108
  init = parseAssignmentExpression();
@@ -7086,7 +7194,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7086
7194
  }
7087
7195
 
7088
7196
  function parseExportDeclaration() {
7089
- var backtrackToken, id, previousAllowKeyword, declaration = null,
7197
+ var declaration = null,
7198
+ possibleIdentifierToken, sourceElement,
7090
7199
  isExportFromIdentifier,
7091
7200
  src = null, specifiers = [],
7092
7201
  marker = markerCreate();
@@ -7098,20 +7207,17 @@ parseYieldExpression: true, parseAwaitExpression: true
7098
7207
  // export default ...
7099
7208
  lex();
7100
7209
  if (matchKeyword('function') || matchKeyword('class')) {
7101
- backtrackToken = lookahead;
7102
- lex();
7103
- if (isIdentifierName(lookahead)) {
7210
+ possibleIdentifierToken = lookahead2();
7211
+ if (isIdentifierName(possibleIdentifierToken)) {
7104
7212
  // covers:
7105
7213
  // export default function foo () {}
7106
7214
  // export default class foo {}
7107
- id = parseNonComputedProperty();
7108
- rewind(backtrackToken);
7109
- return markerApply(marker, delegate.createExportDeclaration(true, parseSourceElement(), [id], null));
7215
+ sourceElement = parseSourceElement();
7216
+ return markerApply(marker, delegate.createExportDeclaration(true, sourceElement, [sourceElement.id], null));
7110
7217
  }
7111
7218
  // covers:
7112
7219
  // export default function () {}
7113
7220
  // export default class {}
7114
- rewind(backtrackToken);
7115
7221
  switch (lookahead.value) {
7116
7222
  case 'class':
7117
7223
  return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
@@ -7869,7 +7975,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7869
7975
 
7870
7976
  state.labelSet.set(expr.name, true);
7871
7977
  labeledBody = parseStatement();
7872
- state.labelSet['delete'](expr.name);
7978
+ state.labelSet["delete"](expr.name);
7873
7979
  return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
7874
7980
  }
7875
7981
 
@@ -8270,55 +8376,25 @@ parseYieldExpression: true, parseAwaitExpression: true
8270
8376
  return markerApply(marker, delegate.createAwaitExpression(expr));
8271
8377
  }
8272
8378
 
8273
- // 14 Classes
8274
-
8275
- function validateDuplicateProp(propMap, key, accessor) {
8276
- var propInfo, reversed, name, isValidDuplicateProp;
8379
+ // 14 Functions and classes
8277
8380
 
8278
- name = getFieldName(key);
8381
+ // 14.1 Functions is defined above (13 in ES5)
8382
+ // 14.2 Arrow Functions Definitions is defined in (7.3 assignments)
8279
8383
 
8280
- if (propMap.has(name)) {
8281
- propInfo = propMap.get(name);
8282
- if (accessor === 'data') {
8283
- isValidDuplicateProp = false;
8284
- } else {
8285
- if (accessor === 'get') {
8286
- reversed = 'set';
8287
- } else {
8288
- reversed = 'get';
8289
- }
8290
-
8291
- isValidDuplicateProp =
8292
- // There isn't already a specified accessor for this prop
8293
- propInfo[accessor] === undefined
8294
- // There isn't already a data prop by this name
8295
- && propInfo.data === undefined
8296
- // The only existing prop by this name is a reversed accessor
8297
- && propInfo[reversed] !== undefined;
8298
- }
8299
- if (!isValidDuplicateProp) {
8300
- throwError(key, Messages.IllegalDuplicateClassProperty);
8301
- }
8302
- } else {
8303
- propInfo = {
8304
- get: undefined,
8305
- set: undefined,
8306
- data: undefined
8307
- };
8308
- propMap.set(name, propInfo);
8309
- }
8310
- propInfo[accessor] = true;
8384
+ // 14.3 Method Definitions
8385
+ // 14.3.7
8386
+ function specialMethod(methodDefinition) {
8387
+ return methodDefinition.kind === 'get' ||
8388
+ methodDefinition.kind === 'set' ||
8389
+ methodDefinition.value.generator;
8311
8390
  }
8312
8391
 
8313
- function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
8314
- var token, param, propType, isValidDuplicateProp = false,
8315
- isAsync, typeParameters, tokenValue, returnType,
8316
- annotationMarker, propMap;
8392
+ function parseMethodDefinition(key, isStatic, generator, computed) {
8393
+ var token, param, propType,
8394
+ isAsync, typeParameters, tokenValue, returnType;
8317
8395
 
8318
8396
  propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
8319
8397
 
8320
- propMap = existingPropNames[propType];
8321
-
8322
8398
  if (generator) {
8323
8399
  return delegate.createMethodDefinition(
8324
8400
  propType,
@@ -8334,12 +8410,6 @@ parseYieldExpression: true, parseAwaitExpression: true
8334
8410
  if (tokenValue === 'get' && !match('(')) {
8335
8411
  key = parseObjectPropertyKey();
8336
8412
 
8337
- // It is a syntax error if any other properties have a name
8338
- // duplicating this one unless they are a setter
8339
- if (!computed) {
8340
- validateDuplicateProp(propMap, key, 'get');
8341
- }
8342
-
8343
8413
  expect('(');
8344
8414
  expect(')');
8345
8415
  if (match(':')) {
@@ -8356,12 +8426,6 @@ parseYieldExpression: true, parseAwaitExpression: true
8356
8426
  if (tokenValue === 'set' && !match('(')) {
8357
8427
  key = parseObjectPropertyKey();
8358
8428
 
8359
- // It is a syntax error if any other properties have a name
8360
- // duplicating this one unless they are a getter
8361
- if (!computed) {
8362
- validateDuplicateProp(propMap, key, 'set');
8363
- }
8364
-
8365
8429
  expect('(');
8366
8430
  token = lookahead;
8367
8431
  param = [ parseTypeAnnotatableIdentifier() ];
@@ -8392,12 +8456,6 @@ parseYieldExpression: true, parseAwaitExpression: true
8392
8456
  key = parseObjectPropertyKey();
8393
8457
  }
8394
8458
 
8395
- // It is a syntax error if any other properties have the same name as a
8396
- // non-getter, non-setter method
8397
- if (!computed) {
8398
- validateDuplicateProp(propMap, key, 'data');
8399
- }
8400
-
8401
8459
  return delegate.createMethodDefinition(
8402
8460
  propType,
8403
8461
  '',
@@ -8411,7 +8469,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8411
8469
  );
8412
8470
  }
8413
8471
 
8414
- function parseClassProperty(existingPropNames, key, computed, isStatic) {
8472
+ function parseClassProperty(key, computed, isStatic) {
8415
8473
  var typeAnnotation;
8416
8474
 
8417
8475
  typeAnnotation = parseTypeAnnotation();
@@ -8425,12 +8483,12 @@ parseYieldExpression: true, parseAwaitExpression: true
8425
8483
  );
8426
8484
  }
8427
8485
 
8428
- function parseClassElement(existingProps) {
8486
+ function parseClassElement() {
8429
8487
  var computed = false, generator = false, key, marker = markerCreate(),
8430
8488
  isStatic = false, possiblyOpenBracketToken;
8431
8489
  if (match(';')) {
8432
8490
  lex();
8433
- return;
8491
+ return undefined;
8434
8492
  }
8435
8493
 
8436
8494
  if (lookahead.value === 'static') {
@@ -8456,11 +8514,10 @@ parseYieldExpression: true, parseAwaitExpression: true
8456
8514
  key = parseObjectPropertyKey();
8457
8515
 
8458
8516
  if (!generator && lookahead.value === ':') {
8459
- return markerApply(marker, parseClassProperty(existingProps, key, computed, isStatic));
8517
+ return markerApply(marker, parseClassProperty(key, computed, isStatic));
8460
8518
  }
8461
8519
 
8462
8520
  return markerApply(marker, parseMethodDefinition(
8463
- existingProps,
8464
8521
  key,
8465
8522
  isStatic,
8466
8523
  generator,
@@ -8469,7 +8526,8 @@ parseYieldExpression: true, parseAwaitExpression: true
8469
8526
  }
8470
8527
 
8471
8528
  function parseClassBody() {
8472
- var classElement, classElements = [], existingProps = {}, marker = markerCreate();
8529
+ var classElement, classElements = [], existingProps = {},
8530
+ marker = markerCreate(), propName, propType;
8473
8531
 
8474
8532
  existingProps[ClassPropertyType["static"]] = new StringMap();
8475
8533
  existingProps[ClassPropertyType.prototype] = new StringMap();
@@ -8484,6 +8542,25 @@ parseYieldExpression: true, parseAwaitExpression: true
8484
8542
 
8485
8543
  if (typeof classElement !== 'undefined') {
8486
8544
  classElements.push(classElement);
8545
+
8546
+ propName = !classElement.computed && getFieldName(classElement.key);
8547
+ if (propName !== false) {
8548
+ propType = classElement["static"] ?
8549
+ ClassPropertyType["static"] :
8550
+ ClassPropertyType.prototype;
8551
+
8552
+ if (classElement.type === Syntax.MethodDefinition) {
8553
+ if (propName === 'constructor' && !classElement["static"]) {
8554
+ if (specialMethod(classElement)) {
8555
+ throwError(classElement, Messages.IllegalClassConstructorProperty);
8556
+ }
8557
+ if (existingProps[ClassPropertyType.prototype].has('constructor')) {
8558
+ throwError(classElement.key, Messages.IllegalDuplicateClassProperty);
8559
+ }
8560
+ }
8561
+ existingProps[propType].set(propName, true);
8562
+ }
8563
+ }
8487
8564
  }
8488
8565
  }
8489
8566
 
@@ -8697,188 +8774,31 @@ parseYieldExpression: true, parseAwaitExpression: true
8697
8774
  throwErrorTolerant(firstRestricted, Messages.StrictOctalLiteral);
8698
8775
  }
8699
8776
  } else {
8700
- if (!firstRestricted && token.octal) {
8701
- firstRestricted = token;
8702
- }
8703
- }
8704
- }
8705
-
8706
- while (index < length) {
8707
- sourceElement = parseProgramElement();
8708
- if (typeof sourceElement === 'undefined') {
8709
- break;
8710
- }
8711
- sourceElements.push(sourceElement);
8712
- }
8713
- return sourceElements;
8714
- }
8715
-
8716
- function parseProgram() {
8717
- var body, marker = markerCreate();
8718
- strict = extra.sourceType === 'module';
8719
- peek();
8720
- body = parseProgramElements();
8721
- return markerApply(marker, delegate.createProgram(body));
8722
- }
8723
-
8724
- // The following functions are needed only when the option to preserve
8725
- // the comments is active.
8726
-
8727
- function addComment(type, value, start, end, loc) {
8728
- var comment;
8729
-
8730
- assert(typeof start === 'number', 'Comment must have valid position');
8731
-
8732
- // Because the way the actual token is scanned, often the comments
8733
- // (if any) are skipped twice during the lexical analysis.
8734
- // Thus, we need to skip adding a comment if the comment array already
8735
- // handled it.
8736
- if (state.lastCommentStart >= start) {
8737
- return;
8738
- }
8739
- state.lastCommentStart = start;
8740
-
8741
- comment = {
8742
- type: type,
8743
- value: value
8744
- };
8745
- if (extra.range) {
8746
- comment.range = [start, end];
8747
- }
8748
- if (extra.loc) {
8749
- comment.loc = loc;
8750
- }
8751
- extra.comments.push(comment);
8752
- if (extra.attachComment) {
8753
- extra.leadingComments.push(comment);
8754
- extra.trailingComments.push(comment);
8755
- }
8756
- }
8757
-
8758
- function scanComment() {
8759
- var comment, ch, loc, start, blockComment, lineComment;
8760
-
8761
- comment = '';
8762
- blockComment = false;
8763
- lineComment = false;
8764
-
8765
- while (index < length) {
8766
- ch = source[index];
8767
-
8768
- if (lineComment) {
8769
- ch = source[index++];
8770
- if (isLineTerminator(ch.charCodeAt(0))) {
8771
- loc.end = {
8772
- line: lineNumber,
8773
- column: index - lineStart - 1
8774
- };
8775
- lineComment = false;
8776
- addComment('Line', comment, start, index - 1, loc);
8777
- if (ch === '\r' && source[index] === '\n') {
8778
- ++index;
8779
- }
8780
- ++lineNumber;
8781
- lineStart = index;
8782
- comment = '';
8783
- } else if (index >= length) {
8784
- lineComment = false;
8785
- comment += ch;
8786
- loc.end = {
8787
- line: lineNumber,
8788
- column: length - lineStart
8789
- };
8790
- addComment('Line', comment, start, length, loc);
8791
- } else {
8792
- comment += ch;
8793
- }
8794
- } else if (blockComment) {
8795
- if (isLineTerminator(ch.charCodeAt(0))) {
8796
- if (ch === '\r') {
8797
- ++index;
8798
- comment += '\r';
8799
- }
8800
- if (ch !== '\r' || source[index] === '\n') {
8801
- comment += source[index];
8802
- ++lineNumber;
8803
- ++index;
8804
- lineStart = index;
8805
- if (index >= length) {
8806
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
8807
- }
8808
- }
8809
- } else {
8810
- ch = source[index++];
8811
- if (index >= length) {
8812
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
8813
- }
8814
- comment += ch;
8815
- if (ch === '*') {
8816
- ch = source[index];
8817
- if (ch === '/') {
8818
- comment = comment.substr(0, comment.length - 1);
8819
- blockComment = false;
8820
- ++index;
8821
- loc.end = {
8822
- line: lineNumber,
8823
- column: index - lineStart
8824
- };
8825
- addComment('Block', comment, start, index, loc);
8826
- comment = '';
8827
- }
8828
- }
8829
- }
8830
- } else if (ch === '/') {
8831
- ch = source[index + 1];
8832
- if (ch === '/') {
8833
- loc = {
8834
- start: {
8835
- line: lineNumber,
8836
- column: index - lineStart
8837
- }
8838
- };
8839
- start = index;
8840
- index += 2;
8841
- lineComment = true;
8842
- if (index >= length) {
8843
- loc.end = {
8844
- line: lineNumber,
8845
- column: index - lineStart
8846
- };
8847
- lineComment = false;
8848
- addComment('Line', comment, start, index, loc);
8849
- }
8850
- } else if (ch === '*') {
8851
- start = index;
8852
- index += 2;
8853
- blockComment = true;
8854
- loc = {
8855
- start: {
8856
- line: lineNumber,
8857
- column: index - lineStart - 2
8858
- }
8859
- };
8860
- if (index >= length) {
8861
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
8862
- }
8863
- } else {
8864
- break;
8865
- }
8866
- } else if (isWhiteSpace(ch.charCodeAt(0))) {
8867
- ++index;
8868
- } else if (isLineTerminator(ch.charCodeAt(0))) {
8869
- ++index;
8870
- if (ch === '\r' && source[index] === '\n') {
8871
- ++index;
8872
- }
8873
- ++lineNumber;
8874
- lineStart = index;
8875
- } else {
8777
+ if (!firstRestricted && token.octal) {
8778
+ firstRestricted = token;
8779
+ }
8780
+ }
8781
+ }
8782
+
8783
+ while (index < length) {
8784
+ sourceElement = parseProgramElement();
8785
+ if (typeof sourceElement === 'undefined') {
8876
8786
  break;
8877
8787
  }
8788
+ sourceElements.push(sourceElement);
8878
8789
  }
8790
+ return sourceElements;
8791
+ }
8792
+
8793
+ function parseProgram() {
8794
+ var body, marker = markerCreate();
8795
+ strict = extra.sourceType === 'module';
8796
+ peek();
8797
+ body = parseProgramElements();
8798
+ return markerApply(marker, delegate.createProgram(body));
8879
8799
  }
8880
8800
 
8881
- // 16 XJS
8801
+ // 16 JSX
8882
8802
 
8883
8803
  XHTMLEntities = {
8884
8804
  quot: '\u0022',
@@ -9136,48 +9056,48 @@ parseYieldExpression: true, parseAwaitExpression: true
9136
9056
  diams: '\u2666'
9137
9057
  };
9138
9058
 
9139
- function getQualifiedXJSName(object) {
9140
- if (object.type === Syntax.XJSIdentifier) {
9059
+ function getQualifiedJSXName(object) {
9060
+ if (object.type === Syntax.JSXIdentifier) {
9141
9061
  return object.name;
9142
9062
  }
9143
- if (object.type === Syntax.XJSNamespacedName) {
9063
+ if (object.type === Syntax.JSXNamespacedName) {
9144
9064
  return object.namespace.name + ':' + object.name.name;
9145
9065
  }
9146
9066
  /* istanbul ignore else */
9147
- if (object.type === Syntax.XJSMemberExpression) {
9067
+ if (object.type === Syntax.JSXMemberExpression) {
9148
9068
  return (
9149
- getQualifiedXJSName(object.object) + '.' +
9150
- getQualifiedXJSName(object.property)
9069
+ getQualifiedJSXName(object.object) + '.' +
9070
+ getQualifiedJSXName(object.property)
9151
9071
  );
9152
9072
  }
9153
9073
  /* istanbul ignore next */
9154
9074
  throwUnexpected(object);
9155
9075
  }
9156
9076
 
9157
- function isXJSIdentifierStart(ch) {
9077
+ function isJSXIdentifierStart(ch) {
9158
9078
  // exclude backslash (\)
9159
9079
  return (ch !== 92) && isIdentifierStart(ch);
9160
9080
  }
9161
9081
 
9162
- function isXJSIdentifierPart(ch) {
9082
+ function isJSXIdentifierPart(ch) {
9163
9083
  // exclude backslash (\) and add hyphen (-)
9164
9084
  return (ch !== 92) && (ch === 45 || isIdentifierPart(ch));
9165
9085
  }
9166
9086
 
9167
- function scanXJSIdentifier() {
9087
+ function scanJSXIdentifier() {
9168
9088
  var ch, start, value = '';
9169
9089
 
9170
9090
  start = index;
9171
9091
  while (index < length) {
9172
9092
  ch = source.charCodeAt(index);
9173
- if (!isXJSIdentifierPart(ch)) {
9093
+ if (!isJSXIdentifierPart(ch)) {
9174
9094
  break;
9175
9095
  }
9176
9096
  value += source[index++];
9177
9097
  }
9178
9098
 
9179
9099
  return {
9180
- type: Token.XJSIdentifier,
9100
+ type: Token.JSXIdentifier,
9181
9101
  value: value,
9182
9102
  lineNumber: lineNumber,
9183
9103
  lineStart: lineStart,
@@ -9185,7 +9105,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9185
9105
  };
9186
9106
  }
9187
9107
 
9188
- function scanXJSEntity() {
9108
+ function scanJSXEntity() {
9189
9109
  var ch, str = '', start = index, count = 0, code;
9190
9110
  ch = source[index];
9191
9111
  assert(ch === '&', 'Entity must start with an ampersand');
@@ -9223,7 +9143,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9223
9143
  return '&';
9224
9144
  }
9225
9145
 
9226
- function scanXJSText(stopChars) {
9146
+ function scanJSXText(stopChars) {
9227
9147
  var ch, str = '', start;
9228
9148
  start = index;
9229
9149
  while (index < length) {
@@ -9232,7 +9152,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9232
9152
  break;
9233
9153
  }
9234
9154
  if (ch === '&') {
9235
- str += scanXJSEntity();
9155
+ str += scanJSXEntity();
9236
9156
  } else {
9237
9157
  index++;
9238
9158
  if (ch === '\r' && source[index] === '\n') {
@@ -9248,7 +9168,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9248
9168
  }
9249
9169
  }
9250
9170
  return {
9251
- type: Token.XJSText,
9171
+ type: Token.JSXText,
9252
9172
  value: str,
9253
9173
  lineNumber: lineNumber,
9254
9174
  lineStart: lineStart,
@@ -9256,7 +9176,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9256
9176
  };
9257
9177
  }
9258
9178
 
9259
- function scanXJSStringLiteral() {
9179
+ function scanJSXStringLiteral() {
9260
9180
  var innerToken, quote, start;
9261
9181
 
9262
9182
  quote = source[index];
@@ -9266,7 +9186,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9266
9186
  start = index;
9267
9187
  ++index;
9268
9188
 
9269
- innerToken = scanXJSText([quote]);
9189
+ innerToken = scanJSXText([quote]);
9270
9190
 
9271
9191
  if (quote !== source[index]) {
9272
9192
  throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
@@ -9280,256 +9200,256 @@ parseYieldExpression: true, parseAwaitExpression: true
9280
9200
  }
9281
9201
 
9282
9202
  /**
9283
- * Between XJS opening and closing tags (e.g. <foo>HERE</foo>), anything that
9284
- * is not another XJS tag and is not an expression wrapped by {} is text.
9203
+ * Between JSX opening and closing tags (e.g. <foo>HERE</foo>), anything that
9204
+ * is not another JSX tag and is not an expression wrapped by {} is text.
9285
9205
  */
9286
- function advanceXJSChild() {
9206
+ function advanceJSXChild() {
9287
9207
  var ch = source.charCodeAt(index);
9288
9208
 
9289
9209
  // '<' 60, '>' 62, '{' 123, '}' 125
9290
9210
  if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
9291
- return scanXJSText(['<', '>', '{', '}']);
9211
+ return scanJSXText(['<', '>', '{', '}']);
9292
9212
  }
9293
9213
 
9294
9214
  return scanPunctuator();
9295
9215
  }
9296
9216
 
9297
- function parseXJSIdentifier() {
9217
+ function parseJSXIdentifier() {
9298
9218
  var token, marker = markerCreate();
9299
9219
 
9300
- if (lookahead.type !== Token.XJSIdentifier) {
9220
+ if (lookahead.type !== Token.JSXIdentifier) {
9301
9221
  throwUnexpected(lookahead);
9302
9222
  }
9303
9223
 
9304
9224
  token = lex();
9305
- return markerApply(marker, delegate.createXJSIdentifier(token.value));
9225
+ return markerApply(marker, delegate.createJSXIdentifier(token.value));
9306
9226
  }
9307
9227
 
9308
- function parseXJSNamespacedName() {
9228
+ function parseJSXNamespacedName() {
9309
9229
  var namespace, name, marker = markerCreate();
9310
9230
 
9311
- namespace = parseXJSIdentifier();
9231
+ namespace = parseJSXIdentifier();
9312
9232
  expect(':');
9313
- name = parseXJSIdentifier();
9233
+ name = parseJSXIdentifier();
9314
9234
 
9315
- return markerApply(marker, delegate.createXJSNamespacedName(namespace, name));
9235
+ return markerApply(marker, delegate.createJSXNamespacedName(namespace, name));
9316
9236
  }
9317
9237
 
9318
- function parseXJSMemberExpression() {
9238
+ function parseJSXMemberExpression() {
9319
9239
  var marker = markerCreate(),
9320
- expr = parseXJSIdentifier();
9240
+ expr = parseJSXIdentifier();
9321
9241
 
9322
9242
  while (match('.')) {
9323
9243
  lex();
9324
- expr = markerApply(marker, delegate.createXJSMemberExpression(expr, parseXJSIdentifier()));
9244
+ expr = markerApply(marker, delegate.createJSXMemberExpression(expr, parseJSXIdentifier()));
9325
9245
  }
9326
9246
 
9327
9247
  return expr;
9328
9248
  }
9329
9249
 
9330
- function parseXJSElementName() {
9250
+ function parseJSXElementName() {
9331
9251
  if (lookahead2().value === ':') {
9332
- return parseXJSNamespacedName();
9252
+ return parseJSXNamespacedName();
9333
9253
  }
9334
9254
  if (lookahead2().value === '.') {
9335
- return parseXJSMemberExpression();
9255
+ return parseJSXMemberExpression();
9336
9256
  }
9337
9257
 
9338
- return parseXJSIdentifier();
9258
+ return parseJSXIdentifier();
9339
9259
  }
9340
9260
 
9341
- function parseXJSAttributeName() {
9261
+ function parseJSXAttributeName() {
9342
9262
  if (lookahead2().value === ':') {
9343
- return parseXJSNamespacedName();
9263
+ return parseJSXNamespacedName();
9344
9264
  }
9345
9265
 
9346
- return parseXJSIdentifier();
9266
+ return parseJSXIdentifier();
9347
9267
  }
9348
9268
 
9349
- function parseXJSAttributeValue() {
9269
+ function parseJSXAttributeValue() {
9350
9270
  var value, marker;
9351
9271
  if (match('{')) {
9352
- value = parseXJSExpressionContainer();
9353
- if (value.expression.type === Syntax.XJSEmptyExpression) {
9272
+ value = parseJSXExpressionContainer();
9273
+ if (value.expression.type === Syntax.JSXEmptyExpression) {
9354
9274
  throwError(
9355
9275
  value,
9356
- 'XJS attributes must only be assigned a non-empty ' +
9276
+ 'JSX attributes must only be assigned a non-empty ' +
9357
9277
  'expression'
9358
9278
  );
9359
9279
  }
9360
9280
  } else if (match('<')) {
9361
- value = parseXJSElement();
9362
- } else if (lookahead.type === Token.XJSText) {
9281
+ value = parseJSXElement();
9282
+ } else if (lookahead.type === Token.JSXText) {
9363
9283
  marker = markerCreate();
9364
9284
  value = markerApply(marker, delegate.createLiteral(lex()));
9365
9285
  } else {
9366
- throwError({}, Messages.InvalidXJSAttributeValue);
9286
+ throwError({}, Messages.InvalidJSXAttributeValue);
9367
9287
  }
9368
9288
  return value;
9369
9289
  }
9370
9290
 
9371
- function parseXJSEmptyExpression() {
9291
+ function parseJSXEmptyExpression() {
9372
9292
  var marker = markerCreatePreserveWhitespace();
9373
9293
  while (source.charAt(index) !== '}') {
9374
9294
  index++;
9375
9295
  }
9376
- return markerApply(marker, delegate.createXJSEmptyExpression());
9296
+ return markerApply(marker, delegate.createJSXEmptyExpression());
9377
9297
  }
9378
9298
 
9379
- function parseXJSExpressionContainer() {
9380
- var expression, origInXJSChild, origInXJSTag, marker = markerCreate();
9299
+ function parseJSXExpressionContainer() {
9300
+ var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
9381
9301
 
9382
- origInXJSChild = state.inXJSChild;
9383
- origInXJSTag = state.inXJSTag;
9384
- state.inXJSChild = false;
9385
- state.inXJSTag = false;
9302
+ origInJSXChild = state.inJSXChild;
9303
+ origInJSXTag = state.inJSXTag;
9304
+ state.inJSXChild = false;
9305
+ state.inJSXTag = false;
9386
9306
 
9387
9307
  expect('{');
9388
9308
 
9389
9309
  if (match('}')) {
9390
- expression = parseXJSEmptyExpression();
9310
+ expression = parseJSXEmptyExpression();
9391
9311
  } else {
9392
9312
  expression = parseExpression();
9393
9313
  }
9394
9314
 
9395
- state.inXJSChild = origInXJSChild;
9396
- state.inXJSTag = origInXJSTag;
9315
+ state.inJSXChild = origInJSXChild;
9316
+ state.inJSXTag = origInJSXTag;
9397
9317
 
9398
9318
  expect('}');
9399
9319
 
9400
- return markerApply(marker, delegate.createXJSExpressionContainer(expression));
9320
+ return markerApply(marker, delegate.createJSXExpressionContainer(expression));
9401
9321
  }
9402
9322
 
9403
- function parseXJSSpreadAttribute() {
9404
- var expression, origInXJSChild, origInXJSTag, marker = markerCreate();
9323
+ function parseJSXSpreadAttribute() {
9324
+ var expression, origInJSXChild, origInJSXTag, marker = markerCreate();
9405
9325
 
9406
- origInXJSChild = state.inXJSChild;
9407
- origInXJSTag = state.inXJSTag;
9408
- state.inXJSChild = false;
9409
- state.inXJSTag = false;
9326
+ origInJSXChild = state.inJSXChild;
9327
+ origInJSXTag = state.inJSXTag;
9328
+ state.inJSXChild = false;
9329
+ state.inJSXTag = false;
9410
9330
 
9411
9331
  expect('{');
9412
9332
  expect('...');
9413
9333
 
9414
9334
  expression = parseAssignmentExpression();
9415
9335
 
9416
- state.inXJSChild = origInXJSChild;
9417
- state.inXJSTag = origInXJSTag;
9336
+ state.inJSXChild = origInJSXChild;
9337
+ state.inJSXTag = origInJSXTag;
9418
9338
 
9419
9339
  expect('}');
9420
9340
 
9421
- return markerApply(marker, delegate.createXJSSpreadAttribute(expression));
9341
+ return markerApply(marker, delegate.createJSXSpreadAttribute(expression));
9422
9342
  }
9423
9343
 
9424
- function parseXJSAttribute() {
9344
+ function parseJSXAttribute() {
9425
9345
  var name, marker;
9426
9346
 
9427
9347
  if (match('{')) {
9428
- return parseXJSSpreadAttribute();
9348
+ return parseJSXSpreadAttribute();
9429
9349
  }
9430
9350
 
9431
9351
  marker = markerCreate();
9432
9352
 
9433
- name = parseXJSAttributeName();
9353
+ name = parseJSXAttributeName();
9434
9354
 
9435
9355
  // HTML empty attribute
9436
9356
  if (match('=')) {
9437
9357
  lex();
9438
- return markerApply(marker, delegate.createXJSAttribute(name, parseXJSAttributeValue()));
9358
+ return markerApply(marker, delegate.createJSXAttribute(name, parseJSXAttributeValue()));
9439
9359
  }
9440
9360
 
9441
- return markerApply(marker, delegate.createXJSAttribute(name));
9361
+ return markerApply(marker, delegate.createJSXAttribute(name));
9442
9362
  }
9443
9363
 
9444
- function parseXJSChild() {
9364
+ function parseJSXChild() {
9445
9365
  var token, marker;
9446
9366
  if (match('{')) {
9447
- token = parseXJSExpressionContainer();
9448
- } else if (lookahead.type === Token.XJSText) {
9367
+ token = parseJSXExpressionContainer();
9368
+ } else if (lookahead.type === Token.JSXText) {
9449
9369
  marker = markerCreatePreserveWhitespace();
9450
9370
  token = markerApply(marker, delegate.createLiteral(lex()));
9451
9371
  } else if (match('<')) {
9452
- token = parseXJSElement();
9372
+ token = parseJSXElement();
9453
9373
  } else {
9454
9374
  throwUnexpected(lookahead);
9455
9375
  }
9456
9376
  return token;
9457
9377
  }
9458
9378
 
9459
- function parseXJSClosingElement() {
9460
- var name, origInXJSChild, origInXJSTag, marker = markerCreate();
9461
- origInXJSChild = state.inXJSChild;
9462
- origInXJSTag = state.inXJSTag;
9463
- state.inXJSChild = false;
9464
- state.inXJSTag = true;
9379
+ function parseJSXClosingElement() {
9380
+ var name, origInJSXChild, origInJSXTag, marker = markerCreate();
9381
+ origInJSXChild = state.inJSXChild;
9382
+ origInJSXTag = state.inJSXTag;
9383
+ state.inJSXChild = false;
9384
+ state.inJSXTag = true;
9465
9385
  expect('<');
9466
9386
  expect('/');
9467
- name = parseXJSElementName();
9387
+ name = parseJSXElementName();
9468
9388
  // Because advance() (called by lex() called by expect()) expects there
9469
9389
  // to be a valid token after >, it needs to know whether to look for a
9470
- // standard JS token or an XJS text node
9471
- state.inXJSChild = origInXJSChild;
9472
- state.inXJSTag = origInXJSTag;
9390
+ // standard JS token or an JSX text node
9391
+ state.inJSXChild = origInJSXChild;
9392
+ state.inJSXTag = origInJSXTag;
9473
9393
  expect('>');
9474
- return markerApply(marker, delegate.createXJSClosingElement(name));
9394
+ return markerApply(marker, delegate.createJSXClosingElement(name));
9475
9395
  }
9476
9396
 
9477
- function parseXJSOpeningElement() {
9478
- var name, attribute, attributes = [], selfClosing = false, origInXJSChild, origInXJSTag, marker = markerCreate();
9397
+ function parseJSXOpeningElement() {
9398
+ var name, attributes = [], selfClosing = false, origInJSXChild, origInJSXTag, marker = markerCreate();
9479
9399
 
9480
- origInXJSChild = state.inXJSChild;
9481
- origInXJSTag = state.inXJSTag;
9482
- state.inXJSChild = false;
9483
- state.inXJSTag = true;
9400
+ origInJSXChild = state.inJSXChild;
9401
+ origInJSXTag = state.inJSXTag;
9402
+ state.inJSXChild = false;
9403
+ state.inJSXTag = true;
9484
9404
 
9485
9405
  expect('<');
9486
9406
 
9487
- name = parseXJSElementName();
9407
+ name = parseJSXElementName();
9488
9408
 
9489
9409
  while (index < length &&
9490
9410
  lookahead.value !== '/' &&
9491
9411
  lookahead.value !== '>') {
9492
- attributes.push(parseXJSAttribute());
9412
+ attributes.push(parseJSXAttribute());
9493
9413
  }
9494
9414
 
9495
- state.inXJSTag = origInXJSTag;
9415
+ state.inJSXTag = origInJSXTag;
9496
9416
 
9497
9417
  if (lookahead.value === '/') {
9498
9418
  expect('/');
9499
9419
  // Because advance() (called by lex() called by expect()) expects
9500
9420
  // there to be a valid token after >, it needs to know whether to
9501
- // look for a standard JS token or an XJS text node
9502
- state.inXJSChild = origInXJSChild;
9421
+ // look for a standard JS token or an JSX text node
9422
+ state.inJSXChild = origInJSXChild;
9503
9423
  expect('>');
9504
9424
  selfClosing = true;
9505
9425
  } else {
9506
- state.inXJSChild = true;
9426
+ state.inJSXChild = true;
9507
9427
  expect('>');
9508
9428
  }
9509
- return markerApply(marker, delegate.createXJSOpeningElement(name, attributes, selfClosing));
9429
+ return markerApply(marker, delegate.createJSXOpeningElement(name, attributes, selfClosing));
9510
9430
  }
9511
9431
 
9512
- function parseXJSElement() {
9513
- var openingElement, closingElement = null, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
9432
+ function parseJSXElement() {
9433
+ var openingElement, closingElement = null, children = [], origInJSXChild, origInJSXTag, marker = markerCreate();
9514
9434
 
9515
- origInXJSChild = state.inXJSChild;
9516
- origInXJSTag = state.inXJSTag;
9517
- openingElement = parseXJSOpeningElement();
9435
+ origInJSXChild = state.inJSXChild;
9436
+ origInJSXTag = state.inJSXTag;
9437
+ openingElement = parseJSXOpeningElement();
9518
9438
 
9519
9439
  if (!openingElement.selfClosing) {
9520
9440
  while (index < length) {
9521
- state.inXJSChild = false; // Call lookahead2() with inXJSChild = false because </ should not be considered in the child
9441
+ state.inJSXChild = false; // Call lookahead2() with inJSXChild = false because </ should not be considered in the child
9522
9442
  if (lookahead.value === '<' && lookahead2().value === '/') {
9523
9443
  break;
9524
9444
  }
9525
- state.inXJSChild = true;
9526
- children.push(parseXJSChild());
9445
+ state.inJSXChild = true;
9446
+ children.push(parseJSXChild());
9527
9447
  }
9528
- state.inXJSChild = origInXJSChild;
9529
- state.inXJSTag = origInXJSTag;
9530
- closingElement = parseXJSClosingElement();
9531
- if (getQualifiedXJSName(closingElement.name) !== getQualifiedXJSName(openingElement.name)) {
9532
- throwError({}, Messages.ExpectedXJSClosingTag, getQualifiedXJSName(openingElement.name));
9448
+ state.inJSXChild = origInJSXChild;
9449
+ state.inJSXTag = origInJSXTag;
9450
+ closingElement = parseJSXClosingElement();
9451
+ if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
9452
+ throwError({}, Messages.ExpectedJSXClosingTag, getQualifiedJSXName(openingElement.name));
9533
9453
  }
9534
9454
  }
9535
9455
 
@@ -9538,15 +9458,15 @@ parseYieldExpression: true, parseAwaitExpression: true
9538
9458
  // var x = <div>one</div><div>two</div>;
9539
9459
  //
9540
9460
  // the default error message is a bit incomprehensible. Since it's
9541
- // rarely (never?) useful to write a less-than sign after an XJS
9461
+ // rarely (never?) useful to write a less-than sign after an JSX
9542
9462
  // element, we disallow it here in the parser in order to provide a
9543
9463
  // better error message. (In the rare case that the less-than operator
9544
9464
  // was intended, the left tag can be wrapped in parentheses.)
9545
- if (!origInXJSChild && match('<')) {
9546
- throwError(lookahead, Messages.AdjacentXJSElements);
9465
+ if (!origInJSXChild && match('<')) {
9466
+ throwError(lookahead, Messages.AdjacentJSXElements);
9547
9467
  }
9548
9468
 
9549
- return markerApply(marker, delegate.createXJSElement(openingElement, closingElement, children));
9469
+ return markerApply(marker, delegate.createJSXElement(openingElement, closingElement, children));
9550
9470
  }
9551
9471
 
9552
9472
  function parseTypeAlias() {
@@ -9609,8 +9529,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9609
9529
  }
9610
9530
 
9611
9531
  function parseInterface() {
9612
- var body, bodyMarker, extended = [], id, marker = markerCreate(),
9613
- typeParameters = null, previousStrict;
9532
+ var marker = markerCreate();
9614
9533
 
9615
9534
  if (strict) {
9616
9535
  expectKeyword('interface');
@@ -9728,14 +9647,13 @@ parseYieldExpression: true, parseAwaitExpression: true
9728
9647
  }
9729
9648
 
9730
9649
  function collectToken() {
9731
- var start, loc, token, range, value, entry;
9650
+ var loc, token, range, value, entry;
9732
9651
 
9733
9652
  /* istanbul ignore else */
9734
- if (!state.inXJSChild) {
9653
+ if (!state.inJSXChild) {
9735
9654
  skipComment();
9736
9655
  }
9737
9656
 
9738
- start = index;
9739
9657
  loc = {
9740
9658
  start: {
9741
9659
  line: lineNumber,
@@ -9841,11 +9759,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9841
9759
  }
9842
9760
 
9843
9761
  function patch() {
9844
- if (extra.comments) {
9845
- extra.skipComment = skipComment;
9846
- skipComment = scanComment;
9847
- }
9848
-
9849
9762
  if (typeof extra.tokens !== 'undefined') {
9850
9763
  extra.advance = advance;
9851
9764
  extra.scanRegExp = scanRegExp;
@@ -9856,10 +9769,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9856
9769
  }
9857
9770
 
9858
9771
  function unpatch() {
9859
- if (typeof extra.skipComment === 'function') {
9860
- skipComment = extra.skipComment;
9861
- }
9862
-
9863
9772
  if (typeof extra.scanRegExp === 'function') {
9864
9773
  advance = extra.advance;
9865
9774
  scanRegExp = extra.scanRegExp;
@@ -10003,8 +9912,8 @@ parseYieldExpression: true, parseAwaitExpression: true
10003
9912
  inFunctionBody: false,
10004
9913
  inIteration: false,
10005
9914
  inSwitch: false,
10006
- inXJSChild: false,
10007
- inXJSTag: false,
9915
+ inJSXChild: false,
9916
+ inJSXTag: false,
10008
9917
  inType: false,
10009
9918
  lastCommentStart: -1,
10010
9919
  yieldAllowed: false,
@@ -10069,7 +9978,7 @@ parseYieldExpression: true, parseAwaitExpression: true
10069
9978
  }
10070
9979
 
10071
9980
  // Sync with *.json manifests.
10072
- exports.version = '12001.1.0-dev-harmony-fb';
9981
+ exports.version = '13001.1001.0-dev-harmony-fb';
10073
9982
 
10074
9983
  exports.tokenize = tokenize;
10075
9984
 
@@ -15125,10 +15034,35 @@ RESERVED_WORDS.forEach(function(k) {
15125
15034
  reservedWordsMap[k] = true;
15126
15035
  });
15127
15036
 
15037
+ /**
15038
+ * This list should not grow as new reserved words are introdued. This list is
15039
+ * of words that need to be quoted because ES3-ish browsers do not allow their
15040
+ * use as identifier names.
15041
+ */
15042
+ var ES3_FUTURE_RESERVED_WORDS = [
15043
+ 'enum', 'implements', 'package', 'protected', 'static', 'interface',
15044
+ 'private', 'public'
15045
+ ];
15046
+
15047
+ var ES3_RESERVED_WORDS = [].concat(
15048
+ KEYWORDS,
15049
+ ES3_FUTURE_RESERVED_WORDS,
15050
+ LITERALS
15051
+ );
15052
+
15053
+ var es3ReservedWordsMap = Object.create(null);
15054
+ ES3_RESERVED_WORDS.forEach(function(k) {
15055
+ es3ReservedWordsMap[k] = true;
15056
+ });
15057
+
15128
15058
  exports.isReservedWord = function(word) {
15129
15059
  return !!reservedWordsMap[word];
15130
15060
  };
15131
15061
 
15062
+ exports.isES3ReservedWord = function(word) {
15063
+ return !!es3ReservedWordsMap[word];
15064
+ };
15065
+
15132
15066
  },{}],35:[function(_dereq_,module,exports){
15133
15067
  /**
15134
15068
  * Copyright 2014 Facebook, Inc.
@@ -15174,7 +15108,7 @@ visitProperty.test = function(node) {
15174
15108
  !node.method &&
15175
15109
  !node.shorthand &&
15176
15110
  !node.computed &&
15177
- reserverdWordsHelper.isReservedWord(node.key.name);
15111
+ reserverdWordsHelper.isES3ReservedWord(node.key.name);
15178
15112
  };
15179
15113
 
15180
15114
  function visitMemberExpression(traverse, node, path, state) {
@@ -15191,7 +15125,7 @@ function visitMemberExpression(traverse, node, path, state) {
15191
15125
  visitMemberExpression.test = function(node) {
15192
15126
  return node.type === Syntax.MemberExpression &&
15193
15127
  node.property.type === Syntax.Identifier &&
15194
- reserverdWordsHelper.isReservedWord(node.property.name);
15128
+ reserverdWordsHelper.isES3ReservedWord(node.property.name);
15195
15129
  };
15196
15130
 
15197
15131
  exports.visitorList = [
@@ -15229,6 +15163,10 @@ visitTypeAlias.test = function(node, path, state) {
15229
15163
  };
15230
15164
 
15231
15165
  function visitTypeCast(traverse, node, path, state) {
15166
+ path.unshift(node);
15167
+ traverse(node.expression, path, state);
15168
+ path.shift();
15169
+
15232
15170
  utils.catchup(node.typeAnnotation.range[0], state);
15233
15171
  utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
15234
15172
  return false;
@@ -15380,16 +15318,129 @@ exports.visitorList = [
15380
15318
  */
15381
15319
  /*global exports:true*/
15382
15320
  'use strict';
15321
+ var Syntax = _dereq_('jstransform').Syntax;
15322
+ var utils = _dereq_('jstransform/src/utils');
15323
+
15324
+ function renderJSXLiteral(object, isLast, state, start, end) {
15325
+ var lines = object.value.split(/\r\n|\n|\r/);
15326
+
15327
+ if (start) {
15328
+ utils.append(start, state);
15329
+ }
15330
+
15331
+ var lastNonEmptyLine = 0;
15332
+
15333
+ lines.forEach(function(line, index) {
15334
+ if (line.match(/[^ \t]/)) {
15335
+ lastNonEmptyLine = index;
15336
+ }
15337
+ });
15338
+
15339
+ lines.forEach(function(line, index) {
15340
+ var isFirstLine = index === 0;
15341
+ var isLastLine = index === lines.length - 1;
15342
+ var isLastNonEmptyLine = index === lastNonEmptyLine;
15343
+
15344
+ // replace rendered whitespace tabs with spaces
15345
+ var trimmedLine = line.replace(/\t/g, ' ');
15346
+
15347
+ // trim whitespace touching a newline
15348
+ if (!isFirstLine) {
15349
+ trimmedLine = trimmedLine.replace(/^[ ]+/, '');
15350
+ }
15351
+ if (!isLastLine) {
15352
+ trimmedLine = trimmedLine.replace(/[ ]+$/, '');
15353
+ }
15354
+
15355
+ if (!isFirstLine) {
15356
+ utils.append(line.match(/^[ \t]*/)[0], state);
15357
+ }
15358
+
15359
+ if (trimmedLine || isLastNonEmptyLine) {
15360
+ utils.append(
15361
+ JSON.stringify(trimmedLine) +
15362
+ (!isLastNonEmptyLine ? ' + \' \' +' : ''),
15363
+ state);
15364
+
15365
+ if (isLastNonEmptyLine) {
15366
+ if (end) {
15367
+ utils.append(end, state);
15368
+ }
15369
+ if (!isLast) {
15370
+ utils.append(', ', state);
15371
+ }
15372
+ }
15373
+
15374
+ // only restore tail whitespace if line had literals
15375
+ if (trimmedLine && !isLastLine) {
15376
+ utils.append(line.match(/[ \t]*$/)[0], state);
15377
+ }
15378
+ }
15379
+
15380
+ if (!isLastLine) {
15381
+ utils.append('\n', state);
15382
+ }
15383
+ });
15384
+
15385
+ utils.move(object.range[1], state);
15386
+ }
15387
+
15388
+ function renderJSXExpressionContainer(traverse, object, isLast, path, state) {
15389
+ // Plus 1 to skip `{`.
15390
+ utils.move(object.range[0] + 1, state);
15391
+ utils.catchup(object.expression.range[0], state);
15392
+ traverse(object.expression, path, state);
15393
+
15394
+ if (!isLast && object.expression.type !== Syntax.JSXEmptyExpression) {
15395
+ // If we need to append a comma, make sure to do so after the expression.
15396
+ utils.catchup(object.expression.range[1], state, trimLeft);
15397
+ utils.append(', ', state);
15398
+ }
15399
+
15400
+ // Minus 1 to skip `}`.
15401
+ utils.catchup(object.range[1] - 1, state, trimLeft);
15402
+ utils.move(object.range[1], state);
15403
+ return false;
15404
+ }
15405
+
15406
+ function quoteAttrName(attr) {
15407
+ // Quote invalid JS identifiers.
15408
+ if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) {
15409
+ return '"' + attr + '"';
15410
+ }
15411
+ return attr;
15412
+ }
15413
+
15414
+ function trimLeft(value) {
15415
+ return value.replace(/^[ ]+/, '');
15416
+ }
15417
+
15418
+ exports.renderJSXExpressionContainer = renderJSXExpressionContainer;
15419
+ exports.renderJSXLiteral = renderJSXLiteral;
15420
+ exports.quoteAttrName = quoteAttrName;
15421
+ exports.trimLeft = trimLeft;
15422
+
15423
+ },{"jstransform":22,"jstransform/src/utils":23}],38:[function(_dereq_,module,exports){
15424
+ /**
15425
+ * Copyright 2013-2015, Facebook, Inc.
15426
+ * All rights reserved.
15427
+ *
15428
+ * This source code is licensed under the BSD-style license found in the
15429
+ * LICENSE file in the root directory of this source tree. An additional grant
15430
+ * of patent rights can be found in the PATENTS file in the same directory.
15431
+ */
15432
+ /*global exports:true*/
15433
+ 'use strict';
15383
15434
 
15384
15435
  var Syntax = _dereq_('jstransform').Syntax;
15385
15436
  var utils = _dereq_('jstransform/src/utils');
15386
15437
 
15387
- var renderXJSExpressionContainer =
15388
- _dereq_('./xjs').renderXJSExpressionContainer;
15389
- var renderXJSLiteral = _dereq_('./xjs').renderXJSLiteral;
15390
- var quoteAttrName = _dereq_('./xjs').quoteAttrName;
15438
+ var renderJSXExpressionContainer =
15439
+ _dereq_('./jsx').renderJSXExpressionContainer;
15440
+ var renderJSXLiteral = _dereq_('./jsx').renderJSXLiteral;
15441
+ var quoteAttrName = _dereq_('./jsx').quoteAttrName;
15391
15442
 
15392
- var trimLeft = _dereq_('./xjs').trimLeft;
15443
+ var trimLeft = _dereq_('./jsx').trimLeft;
15393
15444
 
15394
15445
  /**
15395
15446
  * Customized desugar processor for React JSX. Currently:
@@ -15422,20 +15473,20 @@ function visitReactTag(traverse, object, path, state) {
15422
15473
 
15423
15474
  utils.catchup(openingElement.range[0], state, trimLeft);
15424
15475
 
15425
- if (nameObject.type === Syntax.XJSNamespacedName && nameObject.namespace) {
15476
+ if (nameObject.type === Syntax.JSXNamespacedName && nameObject.namespace) {
15426
15477
  throw new Error('Namespace tags are not supported. ReactJSX is not XML.');
15427
15478
  }
15428
15479
 
15429
15480
  // We assume that the React runtime is already in scope
15430
15481
  utils.append('React.createElement(', state);
15431
15482
 
15432
- if (nameObject.type === Syntax.XJSIdentifier && isTagName(nameObject.name)) {
15483
+ if (nameObject.type === Syntax.JSXIdentifier && isTagName(nameObject.name)) {
15433
15484
  utils.append('"' + nameObject.name + '"', state);
15434
15485
  utils.move(nameObject.range[1], state);
15435
15486
  } else {
15436
15487
  // Use utils.catchup in this case so we can easily handle
15437
- // XJSMemberExpressions which look like Foo.Bar.Baz. This also handles
15438
- // XJSIdentifiers that aren't fallback tags.
15488
+ // JSXMemberExpressions which look like Foo.Bar.Baz. This also handles
15489
+ // JSXIdentifiers that aren't fallback tags.
15439
15490
  utils.move(nameObject.range[0], state);
15440
15491
  utils.catchup(nameObject.range[1], state);
15441
15492
  }
@@ -15445,7 +15496,7 @@ function visitReactTag(traverse, object, path, state) {
15445
15496
  var hasAttributes = attributesObject.length;
15446
15497
 
15447
15498
  var hasAtLeastOneSpreadProperty = attributesObject.some(function(attr) {
15448
- return attr.type === Syntax.XJSSpreadAttribute;
15499
+ return attr.type === Syntax.JSXSpreadAttribute;
15449
15500
  });
15450
15501
 
15451
15502
  // if we don't have any attributes, pass in null
@@ -15464,7 +15515,7 @@ function visitReactTag(traverse, object, path, state) {
15464
15515
  attributesObject.forEach(function(attr, index) {
15465
15516
  var isLast = index === attributesObject.length - 1;
15466
15517
 
15467
- if (attr.type === Syntax.XJSSpreadAttribute) {
15518
+ if (attr.type === Syntax.JSXSpreadAttribute) {
15468
15519
  // Close the previous object or initial object
15469
15520
  if (!previousWasSpread) {
15470
15521
  utils.append('}, ', state);
@@ -15497,7 +15548,7 @@ function visitReactTag(traverse, object, path, state) {
15497
15548
 
15498
15549
  // If the next attribute is a spread, we're effective last in this object
15499
15550
  if (!isLast) {
15500
- isLast = attributesObject[index + 1].type === Syntax.XJSSpreadAttribute;
15551
+ isLast = attributesObject[index + 1].type === Syntax.JSXSpreadAttribute;
15501
15552
  }
15502
15553
 
15503
15554
  if (attr.name.namespace) {
@@ -15526,9 +15577,9 @@ function visitReactTag(traverse, object, path, state) {
15526
15577
  // Use catchupNewlines to skip over the '=' in the attribute
15527
15578
  utils.catchupNewlines(attr.value.range[0], state);
15528
15579
  if (attr.value.type === Syntax.Literal) {
15529
- renderXJSLiteral(attr.value, isLast, state);
15580
+ renderJSXLiteral(attr.value, isLast, state);
15530
15581
  } else {
15531
- renderXJSExpressionContainer(traverse, attr.value, isLast, path, state);
15582
+ renderJSXExpressionContainer(traverse, attr.value, isLast, path, state);
15532
15583
  }
15533
15584
  }
15534
15585
 
@@ -15561,8 +15612,8 @@ function visitReactTag(traverse, object, path, state) {
15561
15612
  var lastRenderableIndex;
15562
15613
 
15563
15614
  childrenToRender.forEach(function(child, index) {
15564
- if (child.type !== Syntax.XJSExpressionContainer ||
15565
- child.expression.type !== Syntax.XJSEmptyExpression) {
15615
+ if (child.type !== Syntax.JSXExpressionContainer ||
15616
+ child.expression.type !== Syntax.JSXEmptyExpression) {
15566
15617
  lastRenderableIndex = index;
15567
15618
  }
15568
15619
  });
@@ -15577,9 +15628,9 @@ function visitReactTag(traverse, object, path, state) {
15577
15628
  var isLast = index >= lastRenderableIndex;
15578
15629
 
15579
15630
  if (child.type === Syntax.Literal) {
15580
- renderXJSLiteral(child, isLast, state);
15581
- } else if (child.type === Syntax.XJSExpressionContainer) {
15582
- renderXJSExpressionContainer(traverse, child, isLast, path, state);
15631
+ renderJSXLiteral(child, isLast, state);
15632
+ } else if (child.type === Syntax.JSXExpressionContainer) {
15633
+ renderJSXExpressionContainer(traverse, child, isLast, path, state);
15583
15634
  } else {
15584
15635
  traverse(child, path, state);
15585
15636
  if (!isLast) {
@@ -15606,14 +15657,14 @@ function visitReactTag(traverse, object, path, state) {
15606
15657
  }
15607
15658
 
15608
15659
  visitReactTag.test = function(object, path, state) {
15609
- return object.type === Syntax.XJSElement;
15660
+ return object.type === Syntax.JSXElement;
15610
15661
  };
15611
15662
 
15612
15663
  exports.visitorList = [
15613
15664
  visitReactTag
15614
15665
  ];
15615
15666
 
15616
- },{"./xjs":39,"jstransform":22,"jstransform/src/utils":23}],38:[function(_dereq_,module,exports){
15667
+ },{"./jsx":37,"jstransform":22,"jstransform/src/utils":23}],39:[function(_dereq_,module,exports){
15617
15668
  /**
15618
15669
  * Copyright 2013-2015, Facebook, Inc.
15619
15670
  * All rights reserved.
@@ -15708,119 +15759,6 @@ exports.visitorList = [
15708
15759
  visitReactDisplayName
15709
15760
  ];
15710
15761
 
15711
- },{"jstransform":22,"jstransform/src/utils":23}],39:[function(_dereq_,module,exports){
15712
- /**
15713
- * Copyright 2013-2015, Facebook, Inc.
15714
- * All rights reserved.
15715
- *
15716
- * This source code is licensed under the BSD-style license found in the
15717
- * LICENSE file in the root directory of this source tree. An additional grant
15718
- * of patent rights can be found in the PATENTS file in the same directory.
15719
- */
15720
- /*global exports:true*/
15721
- 'use strict';
15722
- var Syntax = _dereq_('jstransform').Syntax;
15723
- var utils = _dereq_('jstransform/src/utils');
15724
-
15725
- function renderXJSLiteral(object, isLast, state, start, end) {
15726
- var lines = object.value.split(/\r\n|\n|\r/);
15727
-
15728
- if (start) {
15729
- utils.append(start, state);
15730
- }
15731
-
15732
- var lastNonEmptyLine = 0;
15733
-
15734
- lines.forEach(function(line, index) {
15735
- if (line.match(/[^ \t]/)) {
15736
- lastNonEmptyLine = index;
15737
- }
15738
- });
15739
-
15740
- lines.forEach(function(line, index) {
15741
- var isFirstLine = index === 0;
15742
- var isLastLine = index === lines.length - 1;
15743
- var isLastNonEmptyLine = index === lastNonEmptyLine;
15744
-
15745
- // replace rendered whitespace tabs with spaces
15746
- var trimmedLine = line.replace(/\t/g, ' ');
15747
-
15748
- // trim whitespace touching a newline
15749
- if (!isFirstLine) {
15750
- trimmedLine = trimmedLine.replace(/^[ ]+/, '');
15751
- }
15752
- if (!isLastLine) {
15753
- trimmedLine = trimmedLine.replace(/[ ]+$/, '');
15754
- }
15755
-
15756
- if (!isFirstLine) {
15757
- utils.append(line.match(/^[ \t]*/)[0], state);
15758
- }
15759
-
15760
- if (trimmedLine || isLastNonEmptyLine) {
15761
- utils.append(
15762
- JSON.stringify(trimmedLine) +
15763
- (!isLastNonEmptyLine ? ' + \' \' +' : ''),
15764
- state);
15765
-
15766
- if (isLastNonEmptyLine) {
15767
- if (end) {
15768
- utils.append(end, state);
15769
- }
15770
- if (!isLast) {
15771
- utils.append(', ', state);
15772
- }
15773
- }
15774
-
15775
- // only restore tail whitespace if line had literals
15776
- if (trimmedLine && !isLastLine) {
15777
- utils.append(line.match(/[ \t]*$/)[0], state);
15778
- }
15779
- }
15780
-
15781
- if (!isLastLine) {
15782
- utils.append('\n', state);
15783
- }
15784
- });
15785
-
15786
- utils.move(object.range[1], state);
15787
- }
15788
-
15789
- function renderXJSExpressionContainer(traverse, object, isLast, path, state) {
15790
- // Plus 1 to skip `{`.
15791
- utils.move(object.range[0] + 1, state);
15792
- utils.catchup(object.expression.range[0], state);
15793
- traverse(object.expression, path, state);
15794
-
15795
- if (!isLast && object.expression.type !== Syntax.XJSEmptyExpression) {
15796
- // If we need to append a comma, make sure to do so after the expression.
15797
- utils.catchup(object.expression.range[1], state, trimLeft);
15798
- utils.append(', ', state);
15799
- }
15800
-
15801
- // Minus 1 to skip `}`.
15802
- utils.catchup(object.range[1] - 1, state, trimLeft);
15803
- utils.move(object.range[1], state);
15804
- return false;
15805
- }
15806
-
15807
- function quoteAttrName(attr) {
15808
- // Quote invalid JS identifiers.
15809
- if (!/^[a-z_$][a-z\d_$]*$/i.test(attr)) {
15810
- return '"' + attr + '"';
15811
- }
15812
- return attr;
15813
- }
15814
-
15815
- function trimLeft(value) {
15816
- return value.replace(/^[ ]+/, '');
15817
- }
15818
-
15819
- exports.renderXJSExpressionContainer = renderXJSExpressionContainer;
15820
- exports.renderXJSLiteral = renderXJSLiteral;
15821
- exports.quoteAttrName = quoteAttrName;
15822
- exports.trimLeft = trimLeft;
15823
-
15824
15762
  },{"jstransform":22,"jstransform/src/utils":23}],40:[function(_dereq_,module,exports){
15825
15763
  /*global exports:true*/
15826
15764
 
@@ -15948,7 +15886,7 @@ exports.getVisitorsBySet = getVisitorsBySet;
15948
15886
  exports.getAllVisitors = getAllVisitors;
15949
15887
  exports.transformVisitors = transformVisitors;
15950
15888
 
15951
- },{"./transforms/react":37,"./transforms/reactDisplayName":38,"jstransform/visitors/es6-arrow-function-visitors":24,"jstransform/visitors/es6-call-spread-visitors":25,"jstransform/visitors/es6-class-visitors":26,"jstransform/visitors/es6-destructuring-visitors":27,"jstransform/visitors/es6-object-concise-method-visitors":28,"jstransform/visitors/es6-object-short-notation-visitors":29,"jstransform/visitors/es6-rest-param-visitors":30,"jstransform/visitors/es6-template-visitors":31,"jstransform/visitors/es7-spread-property-visitors":33,"jstransform/visitors/reserved-words-visitors":35}],41:[function(_dereq_,module,exports){
15889
+ },{"./transforms/react":38,"./transforms/reactDisplayName":39,"jstransform/visitors/es6-arrow-function-visitors":24,"jstransform/visitors/es6-call-spread-visitors":25,"jstransform/visitors/es6-class-visitors":26,"jstransform/visitors/es6-destructuring-visitors":27,"jstransform/visitors/es6-object-concise-method-visitors":28,"jstransform/visitors/es6-object-short-notation-visitors":29,"jstransform/visitors/es6-rest-param-visitors":30,"jstransform/visitors/es6-template-visitors":31,"jstransform/visitors/es7-spread-property-visitors":33,"jstransform/visitors/reserved-words-visitors":35}],41:[function(_dereq_,module,exports){
15952
15890
  /**
15953
15891
  * Copyright 2013-2015, Facebook, Inc.
15954
15892
  * All rights reserved.