react 0.12.2 → 0.13.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/JSXTransformer.js +986 -511
  2. package/dist/react-with-addons.js +6076 -4560
  3. package/dist/react-with-addons.min.js +6 -7
  4. package/dist/react.js +5386 -4170
  5. package/dist/react.min.js +6 -7
  6. package/lib/AutoFocusMixin.js +2 -2
  7. package/lib/BeforeInputEventPlugin.js +388 -115
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +2 -2
  10. package/lib/CSSPropertyOperations.js +58 -11
  11. package/lib/CallbackQueue.js +3 -3
  12. package/lib/ChangeEventPlugin.js +4 -4
  13. package/lib/ClientReactRootIndex.js +2 -2
  14. package/lib/DOMChildrenOperations.js +10 -47
  15. package/lib/DOMProperty.js +2 -2
  16. package/lib/DOMPropertyOperations.js +11 -16
  17. package/lib/Danger.js +8 -7
  18. package/lib/DefaultEventPluginOrder.js +3 -4
  19. package/lib/EnterLeaveEventPlugin.js +2 -2
  20. package/lib/EventConstants.js +2 -2
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +10 -8
  23. package/lib/EventPluginRegistry.js +2 -2
  24. package/lib/EventPluginUtils.js +4 -4
  25. package/lib/EventPropagators.js +2 -2
  26. package/lib/ExecutionEnvironment.js +3 -4
  27. package/lib/FallbackCompositionState.js +89 -0
  28. package/lib/HTMLDOMPropertyConfig.js +23 -10
  29. package/lib/LinkedStateMixin.js +2 -2
  30. package/lib/LinkedValueUtils.js +4 -4
  31. package/lib/LocalEventTrapMixin.js +10 -3
  32. package/lib/MobileSafariClickEventPlugin.js +2 -2
  33. package/lib/Object.assign.js +4 -2
  34. package/lib/PooledClass.js +2 -2
  35. package/lib/React.js +19 -58
  36. package/lib/ReactBrowserComponentMixin.js +4 -14
  37. package/lib/ReactBrowserEventEmitter.js +6 -8
  38. package/lib/ReactCSSTransitionGroup.js +5 -2
  39. package/lib/ReactCSSTransitionGroupChild.js +20 -7
  40. package/lib/ReactChildReconciler.js +125 -0
  41. package/lib/ReactChildren.js +13 -10
  42. package/lib/ReactClass.js +918 -0
  43. package/lib/ReactComponent.js +98 -406
  44. package/lib/ReactComponentBrowserEnvironment.js +11 -84
  45. package/lib/ReactComponentEnvironment.js +57 -0
  46. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  47. package/lib/ReactCompositeComponent.js +574 -1140
  48. package/lib/ReactContext.js +17 -3
  49. package/lib/ReactCurrentOwner.js +2 -2
  50. package/lib/ReactDOM.js +4 -9
  51. package/lib/ReactDOMButton.js +6 -7
  52. package/lib/ReactDOMComponent.js +123 -105
  53. package/lib/ReactDOMForm.js +6 -7
  54. package/lib/ReactDOMIDOperations.js +59 -77
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +5 -7
  57. package/lib/ReactDOMInput.js +6 -7
  58. package/lib/ReactDOMOption.js +6 -7
  59. package/lib/ReactDOMSelect.js +58 -66
  60. package/lib/ReactDOMSelection.js +7 -3
  61. package/lib/{ReactTextComponent.js → ReactDOMTextComponent.js} +48 -37
  62. package/lib/ReactDOMTextarea.js +6 -7
  63. package/lib/ReactDefaultBatchingStrategy.js +5 -5
  64. package/lib/ReactDefaultInjection.js +39 -9
  65. package/lib/ReactDefaultPerf.js +17 -8
  66. package/lib/ReactDefaultPerfAnalysis.js +2 -2
  67. package/lib/ReactElement.js +23 -15
  68. package/lib/ReactElementValidator.js +206 -89
  69. package/lib/ReactEmptyComponent.js +33 -15
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +2 -2
  72. package/lib/ReactEventListener.js +4 -5
  73. package/lib/ReactFragment.js +172 -0
  74. package/lib/ReactInjection.js +8 -6
  75. package/lib/ReactInputSelection.js +4 -5
  76. package/lib/ReactInstanceHandles.js +4 -3
  77. package/lib/ReactInstanceMap.js +47 -0
  78. package/lib/ReactLifeCycle.js +35 -0
  79. package/lib/ReactLink.js +2 -2
  80. package/lib/ReactMarkupChecksum.js +2 -2
  81. package/lib/ReactMount.js +264 -71
  82. package/lib/ReactMultiChild.js +50 -48
  83. package/lib/ReactMultiChildUpdateTypes.js +2 -2
  84. package/lib/ReactNativeComponent.js +59 -25
  85. package/lib/ReactOwner.js +5 -49
  86. package/lib/ReactPerf.js +22 -2
  87. package/lib/ReactPropTransferer.js +3 -58
  88. package/lib/ReactPropTypeLocationNames.js +2 -2
  89. package/lib/ReactPropTypeLocations.js +2 -2
  90. package/lib/ReactPropTypes.js +17 -25
  91. package/lib/ReactPutListenerQueue.js +2 -2
  92. package/lib/ReactReconcileTransaction.js +2 -2
  93. package/lib/ReactReconciler.js +121 -0
  94. package/lib/ReactRef.js +69 -0
  95. package/lib/ReactRootIndex.js +2 -2
  96. package/lib/ReactServerRendering.js +6 -4
  97. package/lib/ReactServerRenderingTransaction.js +2 -2
  98. package/lib/ReactStateSetters.js +2 -2
  99. package/lib/ReactTestUtils.js +113 -27
  100. package/lib/ReactTransitionChildMapping.js +8 -4
  101. package/lib/ReactTransitionEvents.js +2 -2
  102. package/lib/ReactTransitionGroup.js +53 -12
  103. package/lib/ReactUpdateQueue.js +295 -0
  104. package/lib/ReactUpdates.js +54 -62
  105. package/lib/ReactWithAddons.js +4 -2
  106. package/lib/SVGDOMPropertyConfig.js +2 -2
  107. package/lib/SelectEventPlugin.js +4 -4
  108. package/lib/ServerReactRootIndex.js +2 -2
  109. package/lib/SimpleEventPlugin.js +4 -4
  110. package/lib/SyntheticClipboardEvent.js +2 -3
  111. package/lib/SyntheticCompositionEvent.js +2 -3
  112. package/lib/SyntheticDragEvent.js +2 -2
  113. package/lib/SyntheticEvent.js +12 -4
  114. package/lib/SyntheticFocusEvent.js +2 -2
  115. package/lib/SyntheticInputEvent.js +2 -3
  116. package/lib/SyntheticKeyboardEvent.js +2 -2
  117. package/lib/SyntheticMouseEvent.js +3 -5
  118. package/lib/SyntheticTouchEvent.js +2 -2
  119. package/lib/SyntheticUIEvent.js +2 -2
  120. package/lib/SyntheticWheelEvent.js +2 -2
  121. package/lib/Transaction.js +4 -4
  122. package/lib/ViewportMetrics.js +3 -6
  123. package/lib/accumulateInto.js +2 -2
  124. package/lib/adler32.js +2 -2
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +4 -4
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +4 -4
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +1 -1
  133. package/lib/dangerousStyleValue.js +2 -2
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +10 -11
  137. package/lib/findDOMNode.js +51 -0
  138. package/lib/flattenChildren.js +12 -23
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +2 -2
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +2 -2
  143. package/lib/getEventKey.js +2 -2
  144. package/lib/getEventModifierState.js +2 -2
  145. package/lib/getEventTarget.js +2 -2
  146. package/lib/getIteratorFn.js +42 -0
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +3 -3
  149. package/lib/getReactRootElementInContainer.js +2 -2
  150. package/lib/getTextContentAccessor.js +2 -2
  151. package/lib/getUnboundedScrollPosition.js +1 -1
  152. package/lib/hyphenate.js +1 -1
  153. package/lib/hyphenateStyleName.js +1 -1
  154. package/lib/instantiateReactComponent.js +90 -68
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +2 -2
  157. package/lib/isNode.js +4 -5
  158. package/lib/isTextInputElement.js +3 -4
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +2 -2
  161. package/lib/keyMirror.js +2 -2
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +5 -6
  165. package/lib/onlyChild.js +2 -2
  166. package/lib/performance.js +1 -1
  167. package/lib/performanceNow.js +1 -1
  168. package/lib/quoteAttributeValueForBrowser.js +26 -0
  169. package/lib/setInnerHTML.js +13 -2
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +2 -2
  172. package/lib/shouldUpdateReactComponent.js +71 -7
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +114 -56
  175. package/lib/update.js +2 -2
  176. package/lib/warning.js +20 -2
  177. package/package.json +1 -1
  178. package/lib/CompositionEventPlugin.js +0 -257
  179. package/lib/ReactLegacyElement.js +0 -243
  180. package/lib/copyProperties.js +0 -54
  181. package/lib/deprecated.js +0 -47
  182. package/lib/merge.js +0 -34
  183. package/lib/mergeInto.js +0 -24
  184. package/lib/monitorCodeUse.js +0 -30
@@ -1,9 +1,9 @@
1
1
  /**
2
- * JSXTransformer v0.12.2
2
+ * JSXTransformer v0.13.0-beta.2
3
3
  */
4
4
  !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSXTransformer=e()}}(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
  /**
6
- * Copyright 2013-2014, Facebook, Inc.
6
+ * Copyright 2013-2015, Facebook, Inc.
7
7
  * All rights reserved.
8
8
  *
9
9
  * This source code is licensed under the BSD-style license found in the
@@ -86,6 +86,13 @@ function exec(source, options) {
86
86
  */
87
87
  function createSourceCodeErrorMessage(code, e) {
88
88
  var sourceLines = code.split('\n');
89
+ // e.lineNumber is non-standard so we can't depend on its availability. If
90
+ // we're in a browser where it isn't supported, don't even bother trying to
91
+ // format anything. We may also hit a case where the line number is reported
92
+ // incorrectly and is outside the bounds of the actual code. Handle that too.
93
+ if (!e.lineNumber || e.lineNumber > sourceLines.length) {
94
+ return '';
95
+ }
89
96
  var erroneousLine = sourceLines[e.lineNumber - 1];
90
97
 
91
98
  // Removes any leading indenting spaces and gets the number of
@@ -134,7 +141,7 @@ function transformCode(code, url, options) {
134
141
  // The error will correctly point to `url` in Firefox.
135
142
  e.fileName = url;
136
143
  }
137
- e.message += url + ':' + e.lineNumber + ':' + e.column;
144
+ e.message += url + ':' + e.lineNumber + ':' + e.columnNumber;
138
145
  } else {
139
146
  e.message += location.href;
140
147
  }
@@ -251,7 +258,7 @@ function loadScripts(scripts) {
251
258
  sourceMap: true
252
259
  };
253
260
  if (/;harmony=true(;|$)/.test(script.type)) {
254
- options.harmony = true
261
+ options.harmony = true;
255
262
  }
256
263
  if (/;stripTypes=true(;|$)/.test(script.type)) {
257
264
  options.stripTypes = true;
@@ -355,11 +362,12 @@ var ieee754 = _dereq_('ieee754')
355
362
  var isArray = _dereq_('is-array')
356
363
 
357
364
  exports.Buffer = Buffer
358
- exports.SlowBuffer = Buffer
365
+ exports.SlowBuffer = SlowBuffer
359
366
  exports.INSPECT_MAX_BYTES = 50
360
367
  Buffer.poolSize = 8192 // not used by this implementation
361
368
 
362
369
  var kMaxLength = 0x3fffffff
370
+ var rootParent = {}
363
371
 
364
372
  /**
365
373
  * If `Buffer.TYPED_ARRAY_SUPPORT`:
@@ -419,8 +427,6 @@ function Buffer (subject, encoding, noZero) {
419
427
  if (type === 'number')
420
428
  length = subject > 0 ? subject >>> 0 : 0
421
429
  else if (type === 'string') {
422
- if (encoding === 'base64')
423
- subject = base64clean(subject)
424
430
  length = Buffer.byteLength(subject, encoding)
425
431
  } else if (type === 'object' && subject !== null) { // assume object is array-like
426
432
  if (subject.type === 'Buffer' && isArray(subject.data))
@@ -429,7 +435,7 @@ function Buffer (subject, encoding, noZero) {
429
435
  } else
430
436
  throw new TypeError('must start with number, buffer, array or string')
431
437
 
432
- if (this.length > kMaxLength)
438
+ if (length > kMaxLength)
433
439
  throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
434
440
  'size: 0x' + kMaxLength.toString(16) + ' bytes')
435
441
 
@@ -465,6 +471,18 @@ function Buffer (subject, encoding, noZero) {
465
471
  }
466
472
  }
467
473
 
474
+ if (length > 0 && length <= Buffer.poolSize)
475
+ buf.parent = rootParent
476
+
477
+ return buf
478
+ }
479
+
480
+ function SlowBuffer(subject, encoding, noZero) {
481
+ if (!(this instanceof SlowBuffer))
482
+ return new SlowBuffer(subject, encoding, noZero)
483
+
484
+ var buf = new Buffer(subject, encoding, noZero)
485
+ delete buf.parent
468
486
  return buf
469
487
  }
470
488
 
@@ -615,7 +633,7 @@ Buffer.prototype.toString = function (encoding, start, end) {
615
633
  }
616
634
 
617
635
  Buffer.prototype.equals = function (b) {
618
- if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
636
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
619
637
  return Buffer.compare(this, b) === 0
620
638
  }
621
639
 
@@ -675,7 +693,7 @@ function hexWrite (buf, string, offset, length) {
675
693
  }
676
694
 
677
695
  function utf8Write (buf, string, offset, length) {
678
- var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
696
+ var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
679
697
  return charsWritten
680
698
  }
681
699
 
@@ -694,7 +712,7 @@ function base64Write (buf, string, offset, length) {
694
712
  }
695
713
 
696
714
  function utf16leWrite (buf, string, offset, length) {
697
- var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
715
+ var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length, 2)
698
716
  return charsWritten
699
717
  }
700
718
 
@@ -714,6 +732,10 @@ Buffer.prototype.write = function (string, offset, length, encoding) {
714
732
  }
715
733
 
716
734
  offset = Number(offset) || 0
735
+
736
+ if (length < 0 || offset < 0 || offset > this.length)
737
+ throw new RangeError('attempt to write outside buffer bounds');
738
+
717
739
  var remaining = this.length - offset
718
740
  if (!length) {
719
741
  length = remaining
@@ -792,13 +814,19 @@ function asciiSlice (buf, start, end) {
792
814
  end = Math.min(buf.length, end)
793
815
 
794
816
  for (var i = start; i < end; i++) {
795
- ret += String.fromCharCode(buf[i])
817
+ ret += String.fromCharCode(buf[i] & 0x7F)
796
818
  }
797
819
  return ret
798
820
  }
799
821
 
800
822
  function binarySlice (buf, start, end) {
801
- return asciiSlice(buf, start, end)
823
+ var ret = ''
824
+ end = Math.min(buf.length, end)
825
+
826
+ for (var i = start; i < end; i++) {
827
+ ret += String.fromCharCode(buf[i])
828
+ }
829
+ return ret
802
830
  }
803
831
 
804
832
  function hexSlice (buf, start, end) {
@@ -847,16 +875,21 @@ Buffer.prototype.slice = function (start, end) {
847
875
  if (end < start)
848
876
  end = start
849
877
 
878
+ var newBuf
850
879
  if (Buffer.TYPED_ARRAY_SUPPORT) {
851
- return Buffer._augment(this.subarray(start, end))
880
+ newBuf = Buffer._augment(this.subarray(start, end))
852
881
  } else {
853
882
  var sliceLen = end - start
854
- var newBuf = new Buffer(sliceLen, undefined, true)
883
+ newBuf = new Buffer(sliceLen, undefined, true)
855
884
  for (var i = 0; i < sliceLen; i++) {
856
885
  newBuf[i] = this[i + start]
857
886
  }
858
- return newBuf
859
887
  }
888
+
889
+ if (newBuf.length)
890
+ newBuf.parent = this.parent || this
891
+
892
+ return newBuf
860
893
  }
861
894
 
862
895
  /*
@@ -869,6 +902,35 @@ function checkOffset (offset, ext, length) {
869
902
  throw new RangeError('Trying to access beyond buffer length')
870
903
  }
871
904
 
905
+ Buffer.prototype.readUIntLE = function (offset, byteLength, noAssert) {
906
+ offset = offset >>> 0
907
+ byteLength = byteLength >>> 0
908
+ if (!noAssert)
909
+ checkOffset(offset, byteLength, this.length)
910
+
911
+ var val = this[offset]
912
+ var mul = 1
913
+ var i = 0
914
+ while (++i < byteLength && (mul *= 0x100))
915
+ val += this[offset + i] * mul
916
+
917
+ return val
918
+ }
919
+
920
+ Buffer.prototype.readUIntBE = function (offset, byteLength, noAssert) {
921
+ offset = offset >>> 0
922
+ byteLength = byteLength >>> 0
923
+ if (!noAssert)
924
+ checkOffset(offset, byteLength, this.length)
925
+
926
+ var val = this[offset + --byteLength]
927
+ var mul = 1
928
+ while (byteLength > 0 && (mul *= 0x100))
929
+ val += this[offset + --byteLength] * mul;
930
+
931
+ return val
932
+ }
933
+
872
934
  Buffer.prototype.readUInt8 = function (offset, noAssert) {
873
935
  if (!noAssert)
874
936
  checkOffset(offset, 1, this.length)
@@ -907,6 +969,44 @@ Buffer.prototype.readUInt32BE = function (offset, noAssert) {
907
969
  this[offset + 3])
908
970
  }
909
971
 
972
+ Buffer.prototype.readIntLE = function (offset, byteLength, noAssert) {
973
+ offset = offset >>> 0
974
+ byteLength = byteLength >>> 0
975
+ if (!noAssert)
976
+ checkOffset(offset, byteLength, this.length)
977
+
978
+ var val = this[offset]
979
+ var mul = 1
980
+ var i = 0
981
+ while (++i < byteLength && (mul *= 0x100))
982
+ val += this[offset + i] * mul
983
+ mul *= 0x80
984
+
985
+ if (val >= mul)
986
+ val -= Math.pow(2, 8 * byteLength)
987
+
988
+ return val
989
+ }
990
+
991
+ Buffer.prototype.readIntBE = function (offset, byteLength, noAssert) {
992
+ offset = offset >>> 0
993
+ byteLength = byteLength >>> 0
994
+ if (!noAssert)
995
+ checkOffset(offset, byteLength, this.length)
996
+
997
+ var i = byteLength
998
+ var mul = 1
999
+ var val = this[offset + --i]
1000
+ while (i > 0 && (mul *= 0x100))
1001
+ val += this[offset + --i] * mul
1002
+ mul *= 0x80
1003
+
1004
+ if (val >= mul)
1005
+ val -= Math.pow(2, 8 * byteLength)
1006
+
1007
+ return val
1008
+ }
1009
+
910
1010
  Buffer.prototype.readInt8 = function (offset, noAssert) {
911
1011
  if (!noAssert)
912
1012
  checkOffset(offset, 1, this.length)
@@ -975,8 +1075,40 @@ Buffer.prototype.readDoubleBE = function (offset, noAssert) {
975
1075
 
976
1076
  function checkInt (buf, value, offset, ext, max, min) {
977
1077
  if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
978
- if (value > max || value < min) throw new TypeError('value is out of bounds')
979
- if (offset + ext > buf.length) throw new TypeError('index out of range')
1078
+ if (value > max || value < min) throw new RangeError('value is out of bounds')
1079
+ if (offset + ext > buf.length) throw new RangeError('index out of range')
1080
+ }
1081
+
1082
+ Buffer.prototype.writeUIntLE = function (value, offset, byteLength, noAssert) {
1083
+ value = +value
1084
+ offset = offset >>> 0
1085
+ byteLength = byteLength >>> 0
1086
+ if (!noAssert)
1087
+ checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1088
+
1089
+ var mul = 1
1090
+ var i = 0
1091
+ this[offset] = value & 0xFF
1092
+ while (++i < byteLength && (mul *= 0x100))
1093
+ this[offset + i] = (value / mul) >>> 0 & 0xFF
1094
+
1095
+ return offset + byteLength
1096
+ }
1097
+
1098
+ Buffer.prototype.writeUIntBE = function (value, offset, byteLength, noAssert) {
1099
+ value = +value
1100
+ offset = offset >>> 0
1101
+ byteLength = byteLength >>> 0
1102
+ if (!noAssert)
1103
+ checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1104
+
1105
+ var i = byteLength - 1
1106
+ var mul = 1
1107
+ this[offset + i] = value & 0xFF
1108
+ while (--i >= 0 && (mul *= 0x100))
1109
+ this[offset + i] = (value / mul) >>> 0 & 0xFF
1110
+
1111
+ return offset + byteLength
980
1112
  }
981
1113
 
982
1114
  Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
@@ -1056,6 +1188,50 @@ Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
1056
1188
  return offset + 4
1057
1189
  }
1058
1190
 
1191
+ Buffer.prototype.writeIntLE = function (value, offset, byteLength, noAssert) {
1192
+ value = +value
1193
+ offset = offset >>> 0
1194
+ if (!noAssert) {
1195
+ checkInt(this,
1196
+ value,
1197
+ offset,
1198
+ byteLength,
1199
+ Math.pow(2, 8 * byteLength - 1) - 1,
1200
+ -Math.pow(2, 8 * byteLength - 1))
1201
+ }
1202
+
1203
+ var i = 0
1204
+ var mul = 1
1205
+ var sub = value < 0 ? 1 : 0
1206
+ this[offset] = value & 0xFF
1207
+ while (++i < byteLength && (mul *= 0x100))
1208
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1209
+
1210
+ return offset + byteLength
1211
+ }
1212
+
1213
+ Buffer.prototype.writeIntBE = function (value, offset, byteLength, noAssert) {
1214
+ value = +value
1215
+ offset = offset >>> 0
1216
+ if (!noAssert) {
1217
+ checkInt(this,
1218
+ value,
1219
+ offset,
1220
+ byteLength,
1221
+ Math.pow(2, 8 * byteLength - 1) - 1,
1222
+ -Math.pow(2, 8 * byteLength - 1))
1223
+ }
1224
+
1225
+ var i = byteLength - 1
1226
+ var mul = 1
1227
+ var sub = value < 0 ? 1 : 0
1228
+ this[offset + i] = value & 0xFF
1229
+ while (--i >= 0 && (mul *= 0x100))
1230
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1231
+
1232
+ return offset + byteLength
1233
+ }
1234
+
1059
1235
  Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
1060
1236
  value = +value
1061
1237
  offset = offset >>> 0
@@ -1121,8 +1297,9 @@ Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
1121
1297
  }
1122
1298
 
1123
1299
  function checkIEEE754 (buf, value, offset, ext, max, min) {
1124
- if (value > max || value < min) throw new TypeError('value is out of bounds')
1125
- if (offset + ext > buf.length) throw new TypeError('index out of range')
1300
+ if (value > max || value < min) throw new RangeError('value is out of bounds')
1301
+ if (offset + ext > buf.length) throw new RangeError('index out of range')
1302
+ if (offset < 0) throw new RangeError('index out of range')
1126
1303
  }
1127
1304
 
1128
1305
  function writeFloat (buf, value, offset, littleEndian, noAssert) {
@@ -1161,18 +1338,19 @@ Buffer.prototype.copy = function (target, target_start, start, end) {
1161
1338
 
1162
1339
  if (!start) start = 0
1163
1340
  if (!end && end !== 0) end = this.length
1341
+ if (target_start >= target.length) target_start = target.length
1164
1342
  if (!target_start) target_start = 0
1343
+ if (end > 0 && end < start) end = start
1165
1344
 
1166
1345
  // Copy 0 bytes; we're done
1167
- if (end === start) return
1168
- if (target.length === 0 || source.length === 0) return
1346
+ if (end === start) return 0
1347
+ if (target.length === 0 || source.length === 0) return 0
1169
1348
 
1170
1349
  // Fatal error conditions
1171
- if (end < start) throw new TypeError('sourceEnd < sourceStart')
1172
- if (target_start < 0 || target_start >= target.length)
1173
- throw new TypeError('targetStart out of bounds')
1174
- if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds')
1175
- if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds')
1350
+ if (target_start < 0)
1351
+ throw new RangeError('targetStart out of bounds')
1352
+ if (start < 0 || start >= source.length) throw new RangeError('sourceStart out of bounds')
1353
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
1176
1354
 
1177
1355
  // Are we oob?
1178
1356
  if (end > this.length)
@@ -1189,6 +1367,8 @@ Buffer.prototype.copy = function (target, target_start, start, end) {
1189
1367
  } else {
1190
1368
  target._set(this.subarray(start, start + len), target_start)
1191
1369
  }
1370
+
1371
+ return len
1192
1372
  }
1193
1373
 
1194
1374
  // fill(value, start=0, end=buffer.length)
@@ -1197,14 +1377,14 @@ Buffer.prototype.fill = function (value, start, end) {
1197
1377
  if (!start) start = 0
1198
1378
  if (!end) end = this.length
1199
1379
 
1200
- if (end < start) throw new TypeError('end < start')
1380
+ if (end < start) throw new RangeError('end < start')
1201
1381
 
1202
1382
  // Fill 0 bytes; we're done
1203
1383
  if (end === start) return
1204
1384
  if (this.length === 0) return
1205
1385
 
1206
- if (start < 0 || start >= this.length) throw new TypeError('start out of bounds')
1207
- if (end < 0 || end > this.length) throw new TypeError('end out of bounds')
1386
+ if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
1387
+ if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
1208
1388
 
1209
1389
  var i
1210
1390
  if (typeof value === 'number') {
@@ -1270,11 +1450,15 @@ Buffer._augment = function (arr) {
1270
1450
  arr.compare = BP.compare
1271
1451
  arr.copy = BP.copy
1272
1452
  arr.slice = BP.slice
1453
+ arr.readUIntLE = BP.readUIntLE
1454
+ arr.readUIntBE = BP.readUIntBE
1273
1455
  arr.readUInt8 = BP.readUInt8
1274
1456
  arr.readUInt16LE = BP.readUInt16LE
1275
1457
  arr.readUInt16BE = BP.readUInt16BE
1276
1458
  arr.readUInt32LE = BP.readUInt32LE
1277
1459
  arr.readUInt32BE = BP.readUInt32BE
1460
+ arr.readIntLE = BP.readIntLE
1461
+ arr.readIntBE = BP.readIntBE
1278
1462
  arr.readInt8 = BP.readInt8
1279
1463
  arr.readInt16LE = BP.readInt16LE
1280
1464
  arr.readInt16BE = BP.readInt16BE
@@ -1285,10 +1469,14 @@ Buffer._augment = function (arr) {
1285
1469
  arr.readDoubleLE = BP.readDoubleLE
1286
1470
  arr.readDoubleBE = BP.readDoubleBE
1287
1471
  arr.writeUInt8 = BP.writeUInt8
1472
+ arr.writeUIntLE = BP.writeUIntLE
1473
+ arr.writeUIntBE = BP.writeUIntBE
1288
1474
  arr.writeUInt16LE = BP.writeUInt16LE
1289
1475
  arr.writeUInt16BE = BP.writeUInt16BE
1290
1476
  arr.writeUInt32LE = BP.writeUInt32LE
1291
1477
  arr.writeUInt32BE = BP.writeUInt32BE
1478
+ arr.writeIntLE = BP.writeIntLE
1479
+ arr.writeIntBE = BP.writeIntBE
1292
1480
  arr.writeInt8 = BP.writeInt8
1293
1481
  arr.writeInt16LE = BP.writeInt16LE
1294
1482
  arr.writeInt16BE = BP.writeInt16BE
@@ -1305,11 +1493,13 @@ Buffer._augment = function (arr) {
1305
1493
  return arr
1306
1494
  }
1307
1495
 
1308
- var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
1496
+ var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
1309
1497
 
1310
1498
  function base64clean (str) {
1311
1499
  // Node strips out invalid characters like \n and \t from the string, base64-js does not
1312
1500
  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
1501
+ // Node converts strings with length < 2 to ''
1502
+ if (str.length < 2) return ''
1313
1503
  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1314
1504
  while (str.length % 4 !== 0) {
1315
1505
  str = str + '='
@@ -1333,22 +1523,100 @@ function toHex (n) {
1333
1523
  return n.toString(16)
1334
1524
  }
1335
1525
 
1336
- function utf8ToBytes (str) {
1337
- var byteArray = []
1338
- for (var i = 0; i < str.length; i++) {
1339
- var b = str.charCodeAt(i)
1340
- if (b <= 0x7F) {
1341
- byteArray.push(b)
1342
- } else {
1343
- var start = i
1344
- if (b >= 0xD800 && b <= 0xDFFF) i++
1345
- var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
1346
- for (var j = 0; j < h.length; j++) {
1347
- byteArray.push(parseInt(h[j], 16))
1526
+ function utf8ToBytes(string, units) {
1527
+ var codePoint, length = string.length
1528
+ var leadSurrogate = null
1529
+ units = units || Infinity
1530
+ var bytes = []
1531
+ var i = 0
1532
+
1533
+ for (; i<length; i++) {
1534
+ codePoint = string.charCodeAt(i)
1535
+
1536
+ // is surrogate component
1537
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
1538
+
1539
+ // last char was a lead
1540
+ if (leadSurrogate) {
1541
+
1542
+ // 2 leads in a row
1543
+ if (codePoint < 0xDC00) {
1544
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1545
+ leadSurrogate = codePoint
1546
+ continue
1547
+ }
1548
+
1549
+ // valid surrogate pair
1550
+ else {
1551
+ codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
1552
+ leadSurrogate = null
1553
+ }
1348
1554
  }
1555
+
1556
+ // no lead yet
1557
+ else {
1558
+
1559
+ // unexpected trail
1560
+ if (codePoint > 0xDBFF) {
1561
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1562
+ continue
1563
+ }
1564
+
1565
+ // unpaired lead
1566
+ else if (i + 1 === length) {
1567
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1568
+ continue
1569
+ }
1570
+
1571
+ // valid lead
1572
+ else {
1573
+ leadSurrogate = codePoint
1574
+ continue
1575
+ }
1576
+ }
1577
+ }
1578
+
1579
+ // valid bmp char, but last char was a lead
1580
+ else if (leadSurrogate) {
1581
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1582
+ leadSurrogate = null
1583
+ }
1584
+
1585
+ // encode utf8
1586
+ if (codePoint < 0x80) {
1587
+ if ((units -= 1) < 0) break
1588
+ bytes.push(codePoint)
1589
+ }
1590
+ else if (codePoint < 0x800) {
1591
+ if ((units -= 2) < 0) break
1592
+ bytes.push(
1593
+ codePoint >> 0x6 | 0xC0,
1594
+ codePoint & 0x3F | 0x80
1595
+ );
1596
+ }
1597
+ else if (codePoint < 0x10000) {
1598
+ if ((units -= 3) < 0) break
1599
+ bytes.push(
1600
+ codePoint >> 0xC | 0xE0,
1601
+ codePoint >> 0x6 & 0x3F | 0x80,
1602
+ codePoint & 0x3F | 0x80
1603
+ );
1604
+ }
1605
+ else if (codePoint < 0x200000) {
1606
+ if ((units -= 4) < 0) break
1607
+ bytes.push(
1608
+ codePoint >> 0x12 | 0xF0,
1609
+ codePoint >> 0xC & 0x3F | 0x80,
1610
+ codePoint >> 0x6 & 0x3F | 0x80,
1611
+ codePoint & 0x3F | 0x80
1612
+ );
1613
+ }
1614
+ else {
1615
+ throw new Error('Invalid code point')
1349
1616
  }
1350
1617
  }
1351
- return byteArray
1618
+
1619
+ return bytes
1352
1620
  }
1353
1621
 
1354
1622
  function asciiToBytes (str) {
@@ -1360,10 +1628,13 @@ function asciiToBytes (str) {
1360
1628
  return byteArray
1361
1629
  }
1362
1630
 
1363
- function utf16leToBytes (str) {
1631
+ function utf16leToBytes (str, units) {
1364
1632
  var c, hi, lo
1365
1633
  var byteArray = []
1366
1634
  for (var i = 0; i < str.length; i++) {
1635
+
1636
+ if ((units -= 2) < 0) break
1637
+
1367
1638
  c = str.charCodeAt(i)
1368
1639
  hi = c >> 8
1369
1640
  lo = c % 256
@@ -1375,10 +1646,11 @@ function utf16leToBytes (str) {
1375
1646
  }
1376
1647
 
1377
1648
  function base64ToBytes (str) {
1378
- return base64.toByteArray(str)
1649
+ return base64.toByteArray(base64clean(str))
1379
1650
  }
1380
1651
 
1381
- function blitBuffer (src, dst, offset, length) {
1652
+ function blitBuffer (src, dst, offset, length, unitSize) {
1653
+ if (unitSize) length -= length % unitSize;
1382
1654
  for (var i = 0; i < length; i++) {
1383
1655
  if ((i + offset >= dst.length) || (i >= src.length))
1384
1656
  break
@@ -1410,12 +1682,16 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1410
1682
  var NUMBER = '0'.charCodeAt(0)
1411
1683
  var LOWER = 'a'.charCodeAt(0)
1412
1684
  var UPPER = 'A'.charCodeAt(0)
1685
+ var PLUS_URL_SAFE = '-'.charCodeAt(0)
1686
+ var SLASH_URL_SAFE = '_'.charCodeAt(0)
1413
1687
 
1414
1688
  function decode (elt) {
1415
1689
  var code = elt.charCodeAt(0)
1416
- if (code === PLUS)
1690
+ if (code === PLUS ||
1691
+ code === PLUS_URL_SAFE)
1417
1692
  return 62 // '+'
1418
- if (code === SLASH)
1693
+ if (code === SLASH ||
1694
+ code === SLASH_URL_SAFE)
1419
1695
  return 63 // '/'
1420
1696
  if (code < NUMBER)
1421
1697
  return -1 //no match
@@ -1870,69 +2146,39 @@ var substr = 'ab'.substr(-1) === 'b'
1870
2146
  // shim for using process in browser
1871
2147
 
1872
2148
  var process = module.exports = {};
2149
+ var queue = [];
2150
+ var draining = false;
1873
2151
 
1874
- process.nextTick = (function () {
1875
- var canSetImmediate = typeof window !== 'undefined'
1876
- && window.setImmediate;
1877
- var canMutationObserver = typeof window !== 'undefined'
1878
- && window.MutationObserver;
1879
- var canPost = typeof window !== 'undefined'
1880
- && window.postMessage && window.addEventListener
1881
- ;
1882
-
1883
- if (canSetImmediate) {
1884
- return function (f) { return window.setImmediate(f) };
2152
+ function drainQueue() {
2153
+ if (draining) {
2154
+ return;
1885
2155
  }
1886
-
1887
- var queue = [];
1888
-
1889
- if (canMutationObserver) {
1890
- var hiddenDiv = document.createElement("div");
1891
- var observer = new MutationObserver(function () {
1892
- var queueList = queue.slice();
1893
- queue.length = 0;
1894
- queueList.forEach(function (fn) {
1895
- fn();
1896
- });
1897
- });
1898
-
1899
- observer.observe(hiddenDiv, { attributes: true });
1900
-
1901
- return function nextTick(fn) {
1902
- if (!queue.length) {
1903
- hiddenDiv.setAttribute('yes', 'no');
1904
- }
1905
- queue.push(fn);
1906
- };
2156
+ draining = true;
2157
+ var currentQueue;
2158
+ var len = queue.length;
2159
+ while(len) {
2160
+ currentQueue = queue;
2161
+ queue = [];
2162
+ var i = -1;
2163
+ while (++i < len) {
2164
+ currentQueue[i]();
2165
+ }
2166
+ len = queue.length;
1907
2167
  }
1908
-
1909
- if (canPost) {
1910
- window.addEventListener('message', function (ev) {
1911
- var source = ev.source;
1912
- if ((source === window || source === null) && ev.data === 'process-tick') {
1913
- ev.stopPropagation();
1914
- if (queue.length > 0) {
1915
- var fn = queue.shift();
1916
- fn();
1917
- }
1918
- }
1919
- }, true);
1920
-
1921
- return function nextTick(fn) {
1922
- queue.push(fn);
1923
- window.postMessage('process-tick', '*');
1924
- };
2168
+ draining = false;
2169
+ }
2170
+ process.nextTick = function (fun) {
2171
+ queue.push(fun);
2172
+ if (!draining) {
2173
+ setTimeout(drainQueue, 0);
1925
2174
  }
1926
-
1927
- return function nextTick(fn) {
1928
- setTimeout(fn, 0);
1929
- };
1930
- })();
2175
+ };
1931
2176
 
1932
2177
  process.title = 'browser';
1933
2178
  process.browser = true;
1934
2179
  process.env = {};
1935
2180
  process.argv = [];
2181
+ process.version = ''; // empty string to avoid regexp issues
1936
2182
 
1937
2183
  function noop() {}
1938
2184
 
@@ -1953,36 +2199,9 @@ process.cwd = function () { return '/' };
1953
2199
  process.chdir = function (dir) {
1954
2200
  throw new Error('process.chdir is not supported');
1955
2201
  };
2202
+ process.umask = function() { return 0; };
1956
2203
 
1957
2204
  },{}],8:[function(_dereq_,module,exports){
1958
- var Base62 = (function (my) {
1959
- my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
1960
-
1961
- my.encode = function(i){
1962
- if (i === 0) {return '0'}
1963
- var s = ''
1964
- while (i > 0) {
1965
- s = this.chars[i % 62] + s
1966
- i = Math.floor(i/62)
1967
- }
1968
- return s
1969
- };
1970
- my.decode = function(a,b,c,d){
1971
- for (
1972
- b = c = (
1973
- a === (/\W|_|^$/.test(a += "") || a)
1974
- ) - 1;
1975
- d = a.charCodeAt(c++);
1976
- )
1977
- b = b * 62 + d - [, 48, 29, 87][d >> 5];
1978
- return b
1979
- };
1980
-
1981
- return my;
1982
- }({}));
1983
-
1984
- module.exports = Base62
1985
- },{}],9:[function(_dereq_,module,exports){
1986
2205
  /*
1987
2206
  Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
1988
2207
  Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
@@ -2017,6 +2236,7 @@ module.exports = Base62
2017
2236
 
2018
2237
  /*jslint bitwise:true plusplus:true */
2019
2238
  /*global esprima:true, define:true, exports:true, window: true,
2239
+ throwErrorTolerant: true,
2020
2240
  throwError: true, generateStatement: true, peek: true,
2021
2241
  parseAssignmentExpression: true, parseBlock: true,
2022
2242
  parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
@@ -2036,6 +2256,7 @@ parseFunctionTypeParam: true,
2036
2256
  parsePrimaryType: true,
2037
2257
  parseTypeAlias: true,
2038
2258
  parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
2259
+ parseTypeParameterDeclaration: true,
2039
2260
  parseYieldExpression: true, parseAwaitExpression: true
2040
2261
  */
2041
2262
 
@@ -2044,6 +2265,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2044
2265
 
2045
2266
  // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
2046
2267
  // Rhino, and plain browser loading.
2268
+
2269
+ /* istanbul ignore next */
2047
2270
  if (typeof define === 'function' && define.amd) {
2048
2271
  define(['exports'], factory);
2049
2272
  } else if (typeof exports !== 'undefined') {
@@ -2199,6 +2422,7 @@ parseYieldExpression: true, parseAwaitExpression: true
2199
2422
  TryStatement: 'TryStatement',
2200
2423
  TypeAlias: 'TypeAlias',
2201
2424
  TypeAnnotation: 'TypeAnnotation',
2425
+ TypeCastExpression: 'TypeCastExpression',
2202
2426
  TypeofTypeAnnotation: 'TypeofTypeAnnotation',
2203
2427
  TypeParameterDeclaration: 'TypeParameterDeclaration',
2204
2428
  TypeParameterInstantiation: 'TypeParameterInstantiation',
@@ -2284,6 +2508,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2284
2508
  MissingFromClause: 'Missing from clause',
2285
2509
  NoAsAfterImportNamespace: 'Missing as after import *',
2286
2510
  InvalidModuleSpecifier: 'Invalid module specifier',
2511
+ IllegalImportDeclaration: 'Illegal import declaration',
2512
+ IllegalExportDeclaration: 'Illegal export declaration',
2287
2513
  NoUnintializedConst: 'Const must be initialized',
2288
2514
  ComprehensionRequiresBlock: 'Comprehension must have at least one block',
2289
2515
  ComprehensionError: 'Comprehension Error',
@@ -2312,11 +2538,37 @@ parseYieldExpression: true, parseAwaitExpression: true
2312
2538
  // Do NOT use this to enforce a certain condition on any user input.
2313
2539
 
2314
2540
  function assert(condition, message) {
2541
+ /* istanbul ignore if */
2315
2542
  if (!condition) {
2316
2543
  throw new Error('ASSERT: ' + message);
2317
2544
  }
2318
2545
  }
2319
2546
 
2547
+ function StringMap() {
2548
+ this.$data = {};
2549
+ }
2550
+
2551
+ StringMap.prototype.get = function (key) {
2552
+ key = '$' + key;
2553
+ return this.$data[key];
2554
+ };
2555
+
2556
+ StringMap.prototype.set = function (key, value) {
2557
+ key = '$' + key;
2558
+ this.$data[key] = value;
2559
+ return this;
2560
+ };
2561
+
2562
+ StringMap.prototype.has = function (key) {
2563
+ key = '$' + key;
2564
+ return Object.prototype.hasOwnProperty.call(this.$data, key);
2565
+ };
2566
+
2567
+ StringMap.prototype['delete'] = function (key) {
2568
+ key = '$' + key;
2569
+ return delete this.$data[key];
2570
+ };
2571
+
2320
2572
  function isDecimalDigit(ch) {
2321
2573
  return (ch >= 48 && ch <= 57); // 0..9
2322
2574
  }
@@ -2677,6 +2929,23 @@ parseYieldExpression: true, parseAwaitExpression: true
2677
2929
  ch3,
2678
2930
  ch4;
2679
2931
 
2932
+ if (state.inXJSTag || state.inXJSChild) {
2933
+ // Don't need to check for '{' and '}' as it's already handled
2934
+ // correctly by default.
2935
+ switch (code) {
2936
+ case 60: // <
2937
+ case 62: // >
2938
+ ++index;
2939
+ return {
2940
+ type: Token.Punctuator,
2941
+ value: String.fromCharCode(code),
2942
+ lineNumber: lineNumber,
2943
+ lineStart: lineStart,
2944
+ range: [start, index]
2945
+ };
2946
+ }
2947
+ }
2948
+
2680
2949
  switch (code) {
2681
2950
  // Check for most common single-character punctuators.
2682
2951
  case 40: // ( open bracket
@@ -2979,6 +3248,7 @@ parseYieldExpression: true, parseAwaitExpression: true
2979
3248
 
2980
3249
  if (index < length) {
2981
3250
  ch = source.charCodeAt(index);
3251
+ /* istanbul ignore else */
2982
3252
  if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
2983
3253
  throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2984
3254
  }
@@ -3109,6 +3379,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3109
3379
  octal = true;
3110
3380
  }
3111
3381
 
3382
+ /* istanbul ignore else */
3112
3383
  if (index < length && isOctalDigit(source[index])) {
3113
3384
  octal = true;
3114
3385
  code = code * 8 + '01234567'.indexOf(source[index++]);
@@ -3225,6 +3496,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3225
3496
  octal = true;
3226
3497
  }
3227
3498
 
3499
+ /* istanbul ignore else */
3228
3500
  if (index < length && isOctalDigit(source[index])) {
3229
3501
  octal = true;
3230
3502
  code = code * 8 + '01234567'.indexOf(source[index++]);
@@ -3357,6 +3629,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3357
3629
  ++index;
3358
3630
  restore = index;
3359
3631
  ch = scanHexEscape('u');
3632
+ /* istanbul ignore else */
3360
3633
  if (ch) {
3361
3634
  flags += ch;
3362
3635
  for (str += '\\u'; restore < index; ++restore) {
@@ -3367,6 +3640,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3367
3640
  flags += 'u';
3368
3641
  str += '\\u';
3369
3642
  }
3643
+ throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
3370
3644
  } else {
3371
3645
  str += '\\';
3372
3646
  }
@@ -3379,11 +3653,20 @@ parseYieldExpression: true, parseAwaitExpression: true
3379
3653
  tmp = pattern;
3380
3654
  if (flags.indexOf('u') >= 0) {
3381
3655
  // Replace each astral symbol and every Unicode code point
3382
- // escape sequence that represents such a symbol with a single
3383
- // ASCII symbol to avoid throwing on regular expressions that
3384
- // are only valid in combination with the `/u` flag.
3656
+ // escape sequence with a single ASCII symbol to avoid throwing on
3657
+ // regular expressions that are only valid in combination with the
3658
+ // `/u` flag.
3659
+ // Note: replacing with the ASCII symbol `x` might cause false
3660
+ // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
3661
+ // perfectly valid pattern that is equivalent to `[a-b]`, but it
3662
+ // would be replaced by `[x-b]` which throws an error.
3385
3663
  tmp = tmp
3386
- .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
3664
+ .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
3665
+ if (parseInt($1, 16) <= 0x10FFFF) {
3666
+ return 'x';
3667
+ }
3668
+ throwError({}, Messages.InvalidRegExp);
3669
+ })
3387
3670
  .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
3388
3671
  }
3389
3672
 
@@ -3403,8 +3686,6 @@ parseYieldExpression: true, parseAwaitExpression: true
3403
3686
  value = null;
3404
3687
  }
3405
3688
 
3406
- peek();
3407
-
3408
3689
  if (extra.tokenize) {
3409
3690
  return {
3410
3691
  type: Token.RegularExpression,
@@ -3596,6 +3877,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3596
3877
  var adv, pos, line, start, result;
3597
3878
 
3598
3879
  // If we are collecting the tokens, don't grab the next one yet.
3880
+ /* istanbul ignore next */
3599
3881
  adv = (typeof extra.advance === 'function') ? extra.advance : advance;
3600
3882
 
3601
3883
  pos = index;
@@ -3603,6 +3885,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3603
3885
  start = lineStart;
3604
3886
 
3605
3887
  // Scan for the next immediate token.
3888
+ /* istanbul ignore if */
3606
3889
  if (lookahead === null) {
3607
3890
  lookahead = adv();
3608
3891
  }
@@ -3648,6 +3931,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3648
3931
  last = bottomRight[bottomRight.length - 1];
3649
3932
 
3650
3933
  if (node.type === Syntax.Program) {
3934
+ /* istanbul ignore else */
3651
3935
  if (node.body.length > 0) {
3652
3936
  return;
3653
3937
  }
@@ -3917,6 +4201,14 @@ parseYieldExpression: true, parseAwaitExpression: true
3917
4201
  };
3918
4202
  },
3919
4203
 
4204
+ createTypeCast: function (expression, typeAnnotation) {
4205
+ return {
4206
+ type: Syntax.TypeCastExpression,
4207
+ expression: expression,
4208
+ typeAnnotation: typeAnnotation
4209
+ };
4210
+ },
4211
+
3920
4212
  createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
3921
4213
  return {
3922
4214
  type: Syntax.FunctionTypeAnnotation,
@@ -4448,13 +4740,14 @@ parseYieldExpression: true, parseAwaitExpression: true
4448
4740
  return arrowExpr;
4449
4741
  },
4450
4742
 
4451
- createMethodDefinition: function (propertyType, kind, key, value) {
4743
+ createMethodDefinition: function (propertyType, kind, key, value, computed) {
4452
4744
  return {
4453
4745
  type: Syntax.MethodDefinition,
4454
4746
  key: key,
4455
4747
  value: value,
4456
4748
  kind: kind,
4457
- 'static': propertyType === ClassPropertyType["static"]
4749
+ 'static': propertyType === ClassPropertyType["static"],
4750
+ computed: computed
4458
4751
  };
4459
4752
  },
4460
4753
 
@@ -4561,11 +4854,12 @@ parseYieldExpression: true, parseAwaitExpression: true
4561
4854
  };
4562
4855
  },
4563
4856
 
4564
- createImportDeclaration: function (specifiers, source) {
4857
+ createImportDeclaration: function (specifiers, source, isType) {
4565
4858
  return {
4566
4859
  type: Syntax.ImportDeclaration,
4567
4860
  specifiers: specifiers,
4568
- source: source
4861
+ source: source,
4862
+ isType: isType
4569
4863
  };
4570
4864
  },
4571
4865
 
@@ -4985,10 +5279,10 @@ parseYieldExpression: true, parseAwaitExpression: true
4985
5279
 
4986
5280
  function parseObjectProperty() {
4987
5281
  var token, key, id, value, param, expr, computed,
4988
- marker = markerCreate(), returnType;
5282
+ marker = markerCreate(), returnType, typeParameters;
4989
5283
 
4990
5284
  token = lookahead;
4991
- computed = (token.value === '[');
5285
+ computed = (token.value === '[' && token.type === Token.Punctuator);
4992
5286
 
4993
5287
  if (token.type === Token.Identifier || computed || matchAsync()) {
4994
5288
  id = parseObjectPropertyKey();
@@ -5009,7 +5303,10 @@ parseYieldExpression: true, parseAwaitExpression: true
5009
5303
  );
5010
5304
  }
5011
5305
 
5012
- if (match('(')) {
5306
+ if (match('(') || match('<')) {
5307
+ if (match('<')) {
5308
+ typeParameters = parseTypeParameterDeclaration();
5309
+ }
5013
5310
  return markerApply(
5014
5311
  marker,
5015
5312
  delegate.createProperty(
@@ -5017,7 +5314,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5017
5314
  id,
5018
5315
  parsePropertyMethodFunction({
5019
5316
  generator: false,
5020
- async: false
5317
+ async: false,
5318
+ typeParameters: typeParameters
5021
5319
  }),
5022
5320
  true,
5023
5321
  false,
@@ -5090,6 +5388,10 @@ parseYieldExpression: true, parseAwaitExpression: true
5090
5388
  computed = (lookahead.value === '[');
5091
5389
  key = parseObjectPropertyKey();
5092
5390
 
5391
+ if (match('<')) {
5392
+ typeParameters = parseTypeParameterDeclaration();
5393
+ }
5394
+
5093
5395
  return markerApply(
5094
5396
  marker,
5095
5397
  delegate.createProperty(
@@ -5097,7 +5399,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5097
5399
  key,
5098
5400
  parsePropertyMethodFunction({
5099
5401
  generator: false,
5100
- async: true
5402
+ async: true,
5403
+ typeParameters: typeParameters
5101
5404
  }),
5102
5405
  true,
5103
5406
  false,
@@ -5127,19 +5430,46 @@ parseYieldExpression: true, parseAwaitExpression: true
5127
5430
 
5128
5431
  id = parseObjectPropertyKey();
5129
5432
 
5433
+ if (match('<')) {
5434
+ typeParameters = parseTypeParameterDeclaration();
5435
+ }
5436
+
5130
5437
  if (!match('(')) {
5131
5438
  throwUnexpected(lex());
5132
5439
  }
5133
5440
 
5134
- return markerApply(marker, delegate.createProperty('init', id, parsePropertyMethodFunction({ generator: true }), true, false, computed));
5441
+ return markerApply(marker, delegate.createProperty(
5442
+ 'init',
5443
+ id,
5444
+ parsePropertyMethodFunction({
5445
+ generator: true,
5446
+ typeParameters: typeParameters
5447
+ }),
5448
+ true,
5449
+ false,
5450
+ computed
5451
+ ));
5135
5452
  }
5136
5453
  key = parseObjectPropertyKey();
5137
5454
  if (match(':')) {
5138
5455
  lex();
5139
5456
  return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
5140
5457
  }
5141
- if (match('(')) {
5142
- return markerApply(marker, delegate.createProperty('init', key, parsePropertyMethodFunction({ generator: false }), true, false, false));
5458
+ if (match('(') || match('<')) {
5459
+ if (match('<')) {
5460
+ typeParameters = parseTypeParameterDeclaration();
5461
+ }
5462
+ return markerApply(marker, delegate.createProperty(
5463
+ 'init',
5464
+ key,
5465
+ parsePropertyMethodFunction({
5466
+ generator: false,
5467
+ typeParameters: typeParameters
5468
+ }),
5469
+ true,
5470
+ false,
5471
+ false
5472
+ ));
5143
5473
  }
5144
5474
  throwUnexpected(lex());
5145
5475
  }
@@ -5150,9 +5480,17 @@ parseYieldExpression: true, parseAwaitExpression: true
5150
5480
  return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
5151
5481
  }
5152
5482
 
5483
+ function getFieldName(key) {
5484
+ var toString = String;
5485
+ if (key.type === Syntax.Identifier) {
5486
+ return key.name;
5487
+ }
5488
+ return toString(key.value);
5489
+ }
5490
+
5153
5491
  function parseObjectInitialiser() {
5154
- var properties = [], property, name, key, kind, map = {}, toString = String,
5155
- marker = markerCreate();
5492
+ var properties = [], property, name, kind, storedKind, map = new StringMap(),
5493
+ marker = markerCreate(), toString = String;
5156
5494
 
5157
5495
  expect('{');
5158
5496
 
@@ -5169,9 +5507,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5169
5507
  }
5170
5508
  kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
5171
5509
 
5172
- key = '$' + name;
5173
- if (Object.prototype.hasOwnProperty.call(map, key)) {
5174
- if (map[key] === PropertyKind.Data) {
5510
+ if (map.has(name)) {
5511
+ storedKind = map.get(name);
5512
+ if (storedKind === PropertyKind.Data) {
5175
5513
  if (strict && kind === PropertyKind.Data) {
5176
5514
  throwErrorTolerant({}, Messages.StrictDuplicateProperty);
5177
5515
  } else if (kind !== PropertyKind.Data) {
@@ -5180,13 +5518,13 @@ parseYieldExpression: true, parseAwaitExpression: true
5180
5518
  } else {
5181
5519
  if (kind === PropertyKind.Data) {
5182
5520
  throwErrorTolerant({}, Messages.AccessorDataProperty);
5183
- } else if (map[key] & kind) {
5521
+ } else if (storedKind & kind) {
5184
5522
  throwErrorTolerant({}, Messages.AccessorGetSet);
5185
5523
  }
5186
5524
  }
5187
- map[key] |= kind;
5525
+ map.set(name, storedKind | kind);
5188
5526
  } else {
5189
- map[key] = kind;
5527
+ map.set(name, kind);
5190
5528
  }
5191
5529
  }
5192
5530
 
@@ -5230,14 +5568,24 @@ parseYieldExpression: true, parseAwaitExpression: true
5230
5568
  // 11.1.6 The Grouping Operator
5231
5569
 
5232
5570
  function parseGroupExpression() {
5233
- var expr;
5571
+ var expr, marker, typeAnnotation;
5234
5572
 
5235
5573
  expect('(');
5236
5574
 
5237
5575
  ++state.parenthesizedCount;
5238
5576
 
5577
+ marker = markerCreate();
5578
+
5239
5579
  expr = parseExpression();
5240
5580
 
5581
+ if (match(':')) {
5582
+ typeAnnotation = parseTypeAnnotation();
5583
+ expr = markerApply(marker, delegate.createTypeCast(
5584
+ expr,
5585
+ typeAnnotation
5586
+ ));
5587
+ }
5588
+
5241
5589
  expect(')');
5242
5590
 
5243
5591
  return expr;
@@ -5326,7 +5674,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5326
5674
 
5327
5675
  if (match('/') || match('/=')) {
5328
5676
  marker = markerCreate();
5329
- return markerApply(marker, delegate.createLiteral(scanRegExp()));
5677
+ expr = delegate.createLiteral(scanRegExp());
5678
+ peek();
5679
+ return markerApply(marker, expr);
5330
5680
  }
5331
5681
 
5332
5682
  if (type === Token.Template) {
@@ -5694,6 +6044,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5694
6044
 
5695
6045
  // 11.13 Assignment Operators
5696
6046
 
6047
+ // 12.14.5 AssignmentPattern
6048
+
5697
6049
  function reinterpretAsAssignmentBindingPattern(expr) {
5698
6050
  var i, len, property, element;
5699
6051
 
@@ -5717,6 +6069,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5717
6069
  expr.type = Syntax.ArrayPattern;
5718
6070
  for (i = 0, len = expr.elements.length; i < len; i += 1) {
5719
6071
  element = expr.elements[i];
6072
+ /* istanbul ignore else */
5720
6073
  if (element) {
5721
6074
  reinterpretAsAssignmentBindingPattern(element);
5722
6075
  }
@@ -5731,12 +6084,14 @@ parseYieldExpression: true, parseAwaitExpression: true
5731
6084
  throwError({}, Messages.ObjectPatternAsSpread);
5732
6085
  }
5733
6086
  } else {
6087
+ /* istanbul ignore else */
5734
6088
  if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
5735
6089
  throwError({}, Messages.InvalidLHSInAssignment);
5736
6090
  }
5737
6091
  }
5738
6092
  }
5739
6093
 
6094
+ // 13.2.3 BindingPattern
5740
6095
 
5741
6096
  function reinterpretAsDestructuredParameter(options, expr) {
5742
6097
  var i, len, property, element;
@@ -5767,10 +6122,14 @@ parseYieldExpression: true, parseAwaitExpression: true
5767
6122
  }
5768
6123
  } else if (expr.type === Syntax.Identifier) {
5769
6124
  validateParam(options, expr, expr.name);
5770
- } else {
5771
- if (expr.type !== Syntax.MemberExpression) {
6125
+ } else if (expr.type === Syntax.SpreadElement) {
6126
+ // BindingRestElement only allows BindingIdentifier
6127
+ if (expr.argument.type !== Syntax.Identifier) {
5772
6128
  throwError({}, Messages.InvalidLHSInFormalsList);
5773
6129
  }
6130
+ validateParam(options, expr.argument, expr.argument.name);
6131
+ } else {
6132
+ throwError({}, Messages.InvalidLHSInFormalsList);
5774
6133
  }
5775
6134
  }
5776
6135
 
@@ -5782,7 +6141,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5782
6141
  defaultCount = 0;
5783
6142
  rest = null;
5784
6143
  options = {
5785
- paramSet: {}
6144
+ paramSet: new StringMap()
5786
6145
  };
5787
6146
 
5788
6147
  for (i = 0, len = expressions.length; i < len; i += 1) {
@@ -5797,6 +6156,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5797
6156
  defaults.push(null);
5798
6157
  } else if (param.type === Syntax.SpreadElement) {
5799
6158
  assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
6159
+ if (param.argument.type !== Syntax.Identifier) {
6160
+ throwError({}, Messages.InvalidLHSInFormalsList);
6161
+ }
5800
6162
  reinterpretAsDestructuredParameter(options, param.argument);
5801
6163
  rest = param.argument;
5802
6164
  } else if (param.type === Syntax.AssignmentExpression) {
@@ -5865,7 +6227,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5865
6227
 
5866
6228
  function parseAssignmentExpression() {
5867
6229
  var marker, expr, token, params, oldParenthesizedCount,
5868
- backtrackToken = lookahead, possiblyAsync = false;
6230
+ startsWithParen = false, backtrackToken = lookahead,
6231
+ possiblyAsync = false;
5869
6232
 
5870
6233
  if (matchYield()) {
5871
6234
  return parseYieldExpression();
@@ -5902,6 +6265,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5902
6265
  params.async = possiblyAsync;
5903
6266
  return parseArrowFunctionExpression(params, marker);
5904
6267
  }
6268
+ startsWithParen = true;
5905
6269
  }
5906
6270
 
5907
6271
  token = lookahead;
@@ -5921,6 +6285,13 @@ parseYieldExpression: true, parseAwaitExpression: true
5921
6285
  state.parenthesizedCount === (oldParenthesizedCount + 1))) {
5922
6286
  if (expr.type === Syntax.Identifier) {
5923
6287
  params = reinterpretAsCoverFormalsList([ expr ]);
6288
+ } else if (expr.type === Syntax.AssignmentExpression ||
6289
+ expr.type === Syntax.ArrayExpression ||
6290
+ expr.type === Syntax.ObjectExpression) {
6291
+ if (!startsWithParen) {
6292
+ throwUnexpected(lex());
6293
+ }
6294
+ params = reinterpretAsCoverFormalsList([ expr ]);
5924
6295
  } else if (expr.type === Syntax.SequenceExpression) {
5925
6296
  params = reinterpretAsCoverFormalsList(expr.expressions);
5926
6297
  }
@@ -5991,18 +6362,6 @@ parseYieldExpression: true, parseAwaitExpression: true
5991
6362
  sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
5992
6363
  }
5993
6364
 
5994
- if (match('=>')) {
5995
- // Do not allow nested parentheses on the LHS of the =>.
5996
- if (state.parenthesizedCount === oldParenthesizedCount || state.parenthesizedCount === (oldParenthesizedCount + 1)) {
5997
- expr = expr.type === Syntax.SequenceExpression ? expr.expressions : expressions;
5998
- coverFormalsList = reinterpretAsCoverFormalsList(expr);
5999
- if (coverFormalsList) {
6000
- return parseArrowFunctionExpression(coverFormalsList, marker);
6001
- }
6002
- }
6003
- throwUnexpected(lex());
6004
- }
6005
-
6006
6365
  if (spreadFound && lookahead2().value !== '=>') {
6007
6366
  throwError({}, Messages.IllegalSpread);
6008
6367
  }
@@ -6154,13 +6513,18 @@ parseYieldExpression: true, parseAwaitExpression: true
6154
6513
  function parseObjectType(allowStatic) {
6155
6514
  var callProperties = [], indexers = [], marker, optional = false,
6156
6515
  properties = [], property, propertyKey, propertyTypeAnnotation,
6157
- token, isStatic;
6516
+ token, isStatic, matchStatic;
6158
6517
 
6159
6518
  expect('{');
6160
6519
 
6161
6520
  while (!match('}')) {
6162
6521
  marker = markerCreate();
6163
- if (allowStatic && matchContextualKeyword('static')) {
6522
+ matchStatic =
6523
+ strict
6524
+ ? matchKeyword('static')
6525
+ : matchContextualKeyword('static');
6526
+
6527
+ if (allowStatic && matchStatic) {
6164
6528
  token = lex();
6165
6529
  isStatic = true;
6166
6530
  }
@@ -6540,6 +6904,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6540
6904
  markerApply(typeAnnotationMarker, id);
6541
6905
  }
6542
6906
  } else {
6907
+ /* istanbul ignore next */
6543
6908
  id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
6544
6909
  // 12.2.1
6545
6910
  if (strict && isRestrictedWord(id.name)) {
@@ -6694,10 +7059,11 @@ parseYieldExpression: true, parseAwaitExpression: true
6694
7059
  }
6695
7060
 
6696
7061
  // non-default export
6697
- if (lookahead.type === Token.Keyword) {
7062
+ if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
6698
7063
  // covers:
6699
7064
  // export var f = 1;
6700
7065
  switch (lookahead.value) {
7066
+ case 'type':
6701
7067
  case 'let':
6702
7068
  case 'const':
6703
7069
  case 'var':
@@ -6724,10 +7090,12 @@ parseYieldExpression: true, parseAwaitExpression: true
6724
7090
  }
6725
7091
 
6726
7092
  expect('{');
6727
- do {
6728
- isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
6729
- specifiers.push(parseExportSpecifier());
6730
- } while (match(',') && lex());
7093
+ if (!match('}')) {
7094
+ do {
7095
+ isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
7096
+ specifiers.push(parseExportSpecifier());
7097
+ } while (match(',') && lex());
7098
+ }
6731
7099
  expect('}');
6732
7100
 
6733
7101
  if (matchContextualKeyword('from')) {
@@ -6768,9 +7136,11 @@ parseYieldExpression: true, parseAwaitExpression: true
6768
7136
  var specifiers = [];
6769
7137
  // {foo, bar as bas}
6770
7138
  expect('{');
6771
- do {
6772
- specifiers.push(parseImportSpecifier());
6773
- } while (match(',') && lex());
7139
+ if (!match('}')) {
7140
+ do {
7141
+ specifiers.push(parseImportSpecifier());
7142
+ } while (match(',') && lex());
7143
+ }
6774
7144
  expect('}');
6775
7145
  return specifiers;
6776
7146
  }
@@ -6799,9 +7169,20 @@ parseYieldExpression: true, parseAwaitExpression: true
6799
7169
  }
6800
7170
 
6801
7171
  function parseImportDeclaration() {
6802
- var specifiers, src, marker = markerCreate();
7172
+ var specifiers, src, marker = markerCreate(), isType = false, token2;
6803
7173
 
6804
7174
  expectKeyword('import');
7175
+
7176
+ if (matchContextualKeyword('type')) {
7177
+ token2 = lookahead2();
7178
+ if ((token2.type === Token.Identifier && token2.value !== 'from') ||
7179
+ (token2.type === Token.Punctuator &&
7180
+ (token2.value === '{' || token2.value === '*'))) {
7181
+ isType = true;
7182
+ lex();
7183
+ }
7184
+ }
7185
+
6805
7186
  specifiers = [];
6806
7187
 
6807
7188
  if (lookahead.type === Token.StringLiteral) {
@@ -6809,7 +7190,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6809
7190
  // import "foo";
6810
7191
  src = parseModuleSpecifier();
6811
7192
  consumeSemicolon();
6812
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
7193
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
6813
7194
  }
6814
7195
 
6815
7196
  if (!matchKeyword('default') && isIdentifierName(lookahead)) {
@@ -6841,7 +7222,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6841
7222
  src = parseModuleSpecifier();
6842
7223
  consumeSemicolon();
6843
7224
 
6844
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
7225
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
6845
7226
  }
6846
7227
 
6847
7228
  // 12.3 Empty Statement
@@ -7038,7 +7419,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7038
7419
  // 12.7 The continue statement
7039
7420
 
7040
7421
  function parseContinueStatement() {
7041
- var label = null, key, marker = markerCreate();
7422
+ var label = null, marker = markerCreate();
7042
7423
 
7043
7424
  expectKeyword('continue');
7044
7425
 
@@ -7064,8 +7445,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7064
7445
  if (lookahead.type === Token.Identifier) {
7065
7446
  label = parseVariableIdentifier();
7066
7447
 
7067
- key = '$' + label.name;
7068
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7448
+ if (!state.labelSet.has(label.name)) {
7069
7449
  throwError({}, Messages.UnknownLabel, label.name);
7070
7450
  }
7071
7451
  }
@@ -7082,7 +7462,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7082
7462
  // 12.8 The break statement
7083
7463
 
7084
7464
  function parseBreakStatement() {
7085
- var label = null, key, marker = markerCreate();
7465
+ var label = null, marker = markerCreate();
7086
7466
 
7087
7467
  expectKeyword('break');
7088
7468
 
@@ -7108,8 +7488,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7108
7488
  if (lookahead.type === Token.Identifier) {
7109
7489
  label = parseVariableIdentifier();
7110
7490
 
7111
- key = '$' + label.name;
7112
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7491
+ if (!state.labelSet.has(label.name)) {
7113
7492
  throwError({}, Messages.UnknownLabel, label.name);
7114
7493
  }
7115
7494
  }
@@ -7337,8 +7716,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7337
7716
  var type = lookahead.type,
7338
7717
  marker,
7339
7718
  expr,
7340
- labeledBody,
7341
- key;
7719
+ labeledBody;
7342
7720
 
7343
7721
  if (type === Token.EOF) {
7344
7722
  throwUnexpected(lookahead);
@@ -7405,14 +7783,13 @@ parseYieldExpression: true, parseAwaitExpression: true
7405
7783
  if ((expr.type === Syntax.Identifier) && match(':')) {
7406
7784
  lex();
7407
7785
 
7408
- key = '$' + expr.name;
7409
- if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7786
+ if (state.labelSet.has(expr.name)) {
7410
7787
  throwError({}, Messages.Redeclaration, 'Label', expr.name);
7411
7788
  }
7412
7789
 
7413
- state.labelSet[key] = true;
7790
+ state.labelSet.set(expr.name, true);
7414
7791
  labeledBody = parseStatement();
7415
- delete state.labelSet[key];
7792
+ state.labelSet['delete'](expr.name);
7416
7793
  return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
7417
7794
  }
7418
7795
 
@@ -7468,7 +7845,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7468
7845
  oldInFunctionBody = state.inFunctionBody;
7469
7846
  oldParenthesizedCount = state.parenthesizedCount;
7470
7847
 
7471
- state.labelSet = {};
7848
+ state.labelSet = new StringMap();
7472
7849
  state.inIteration = false;
7473
7850
  state.inSwitch = false;
7474
7851
  state.inFunctionBody = true;
@@ -7497,13 +7874,12 @@ parseYieldExpression: true, parseAwaitExpression: true
7497
7874
  }
7498
7875
 
7499
7876
  function validateParam(options, param, name) {
7500
- var key = '$' + name;
7501
7877
  if (strict) {
7502
7878
  if (isRestrictedWord(name)) {
7503
7879
  options.stricted = param;
7504
7880
  options.message = Messages.StrictParamName;
7505
7881
  }
7506
- if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
7882
+ if (options.paramSet.has(name)) {
7507
7883
  options.stricted = param;
7508
7884
  options.message = Messages.StrictParamDupe;
7509
7885
  }
@@ -7514,12 +7890,12 @@ parseYieldExpression: true, parseAwaitExpression: true
7514
7890
  } else if (isStrictModeReservedWord(name)) {
7515
7891
  options.firstRestricted = param;
7516
7892
  options.message = Messages.StrictReservedWord;
7517
- } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
7893
+ } else if (options.paramSet.has(name)) {
7518
7894
  options.firstRestricted = param;
7519
7895
  options.message = Messages.StrictParamDupe;
7520
7896
  }
7521
7897
  }
7522
- options.paramSet[key] = true;
7898
+ options.paramSet.set(name, true);
7523
7899
  }
7524
7900
 
7525
7901
  function parseParam(options) {
@@ -7601,7 +7977,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7601
7977
  expect('(');
7602
7978
 
7603
7979
  if (!match(')')) {
7604
- options.paramSet = {};
7980
+ options.paramSet = new StringMap();
7605
7981
  while (index < length) {
7606
7982
  if (!parseParam(options)) {
7607
7983
  break;
@@ -7816,19 +8192,60 @@ parseYieldExpression: true, parseAwaitExpression: true
7816
8192
 
7817
8193
  // 14 Classes
7818
8194
 
8195
+ function validateDuplicateProp(propMap, key, accessor) {
8196
+ var propInfo, reversed, name, isValidDuplicateProp;
8197
+
8198
+ name = getFieldName(key);
8199
+
8200
+ if (propMap.has(name)) {
8201
+ propInfo = propMap.get(name);
8202
+ if (accessor === 'data') {
8203
+ isValidDuplicateProp = false;
8204
+ } else {
8205
+ if (accessor === 'get') {
8206
+ reversed = 'set';
8207
+ } else {
8208
+ reversed = 'get';
8209
+ }
8210
+
8211
+ isValidDuplicateProp =
8212
+ // There isn't already a specified accessor for this prop
8213
+ propInfo[accessor] === undefined
8214
+ // There isn't already a data prop by this name
8215
+ && propInfo.data === undefined
8216
+ // The only existing prop by this name is a reversed accessor
8217
+ && propInfo[reversed] !== undefined;
8218
+ }
8219
+ if (!isValidDuplicateProp) {
8220
+ throwError(key, Messages.IllegalDuplicateClassProperty);
8221
+ }
8222
+ } else {
8223
+ propInfo = {
8224
+ get: undefined,
8225
+ set: undefined,
8226
+ data: undefined
8227
+ };
8228
+ propMap.set(name, propInfo);
8229
+ }
8230
+ propInfo[accessor] = true;
8231
+ }
8232
+
7819
8233
  function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
7820
8234
  var token, param, propType, isValidDuplicateProp = false,
7821
8235
  isAsync, typeParameters, tokenValue, returnType,
7822
- annotationMarker;
8236
+ annotationMarker, propMap;
7823
8237
 
7824
8238
  propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
7825
8239
 
8240
+ propMap = existingPropNames[propType];
8241
+
7826
8242
  if (generator) {
7827
8243
  return delegate.createMethodDefinition(
7828
8244
  propType,
7829
8245
  '',
7830
8246
  key,
7831
- parsePropertyMethodFunction({ generator: true })
8247
+ parsePropertyMethodFunction({ generator: true }),
8248
+ computed
7832
8249
  );
7833
8250
  }
7834
8251
 
@@ -7839,21 +8256,9 @@ parseYieldExpression: true, parseAwaitExpression: true
7839
8256
 
7840
8257
  // It is a syntax error if any other properties have a name
7841
8258
  // duplicating this one unless they are a setter
7842
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
7843
- isValidDuplicateProp =
7844
- // There isn't already a getter for this prop
7845
- existingPropNames[propType][key.name].get === undefined
7846
- // There isn't already a data prop by this name
7847
- && existingPropNames[propType][key.name].data === undefined
7848
- // The only existing prop by this name is a setter
7849
- && existingPropNames[propType][key.name].set !== undefined;
7850
- if (!isValidDuplicateProp) {
7851
- throwError(key, Messages.IllegalDuplicateClassProperty);
7852
- }
7853
- } else {
7854
- existingPropNames[propType][key.name] = {};
8259
+ if (!computed) {
8260
+ validateDuplicateProp(propMap, key, 'get');
7855
8261
  }
7856
- existingPropNames[propType][key.name].get = true;
7857
8262
 
7858
8263
  expect('(');
7859
8264
  expect(')');
@@ -7864,7 +8269,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7864
8269
  propType,
7865
8270
  'get',
7866
8271
  key,
7867
- parsePropertyFunction({ generator: false, returnType: returnType })
8272
+ parsePropertyFunction({ generator: false, returnType: returnType }),
8273
+ computed
7868
8274
  );
7869
8275
  }
7870
8276
  if (tokenValue === 'set' && !match('(')) {
@@ -7872,21 +8278,9 @@ parseYieldExpression: true, parseAwaitExpression: true
7872
8278
 
7873
8279
  // It is a syntax error if any other properties have a name
7874
8280
  // duplicating this one unless they are a getter
7875
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
7876
- isValidDuplicateProp =
7877
- // There isn't already a setter for this prop
7878
- existingPropNames[propType][key.name].set === undefined
7879
- // There isn't already a data prop by this name
7880
- && existingPropNames[propType][key.name].data === undefined
7881
- // The only existing prop by this name is a getter
7882
- && existingPropNames[propType][key.name].get !== undefined;
7883
- if (!isValidDuplicateProp) {
7884
- throwError(key, Messages.IllegalDuplicateClassProperty);
7885
- }
7886
- } else {
7887
- existingPropNames[propType][key.name] = {};
8281
+ if (!computed) {
8282
+ validateDuplicateProp(propMap, key, 'set');
7888
8283
  }
7889
- existingPropNames[propType][key.name].set = true;
7890
8284
 
7891
8285
  expect('(');
7892
8286
  token = lookahead;
@@ -7904,7 +8298,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7904
8298
  generator: false,
7905
8299
  name: token,
7906
8300
  returnType: returnType
7907
- })
8301
+ }),
8302
+ computed
7908
8303
  );
7909
8304
  }
7910
8305
 
@@ -7919,12 +8314,9 @@ parseYieldExpression: true, parseAwaitExpression: true
7919
8314
 
7920
8315
  // It is a syntax error if any other properties have the same name as a
7921
8316
  // non-getter, non-setter method
7922
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
7923
- throwError(key, Messages.IllegalDuplicateClassProperty);
7924
- } else {
7925
- existingPropNames[propType][key.name] = {};
8317
+ if (!computed) {
8318
+ validateDuplicateProp(propMap, key, 'data');
7926
8319
  }
7927
- existingPropNames[propType][key.name].data = true;
7928
8320
 
7929
8321
  return delegate.createMethodDefinition(
7930
8322
  propType,
@@ -7934,7 +8326,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7934
8326
  generator: false,
7935
8327
  async: isAsync,
7936
8328
  typeParameters: typeParameters
7937
- })
8329
+ }),
8330
+ computed
7938
8331
  );
7939
8332
  }
7940
8333
 
@@ -7953,8 +8346,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7953
8346
  }
7954
8347
 
7955
8348
  function parseClassElement(existingProps) {
7956
- var computed, generator = false, key, marker = markerCreate(),
7957
- isStatic = false;
8349
+ var computed = false, generator = false, key, marker = markerCreate(),
8350
+ isStatic = false, possiblyOpenBracketToken;
7958
8351
  if (match(';')) {
7959
8352
  lex();
7960
8353
  return;
@@ -7970,7 +8363,16 @@ parseYieldExpression: true, parseAwaitExpression: true
7970
8363
  generator = true;
7971
8364
  }
7972
8365
 
7973
- computed = (lookahead.value === '[');
8366
+ possiblyOpenBracketToken = lookahead;
8367
+ if (matchContextualKeyword('get') || matchContextualKeyword('set')) {
8368
+ possiblyOpenBracketToken = lookahead2();
8369
+ }
8370
+
8371
+ if (possiblyOpenBracketToken.type === Token.Punctuator
8372
+ && possiblyOpenBracketToken.value === '[') {
8373
+ computed = true;
8374
+ }
8375
+
7974
8376
  key = parseObjectPropertyKey();
7975
8377
 
7976
8378
  if (!generator && lookahead.value === ':') {
@@ -7989,8 +8391,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7989
8391
  function parseClassBody() {
7990
8392
  var classElement, classElements = [], existingProps = {}, marker = markerCreate();
7991
8393
 
7992
- existingProps[ClassPropertyType["static"]] = {};
7993
- existingProps[ClassPropertyType.prototype] = {};
8394
+ existingProps[ClassPropertyType["static"]] = new StringMap();
8395
+ existingProps[ClassPropertyType.prototype] = new StringMap();
7994
8396
 
7995
8397
  expect('{');
7996
8398
 
@@ -8012,7 +8414,11 @@ parseYieldExpression: true, parseAwaitExpression: true
8012
8414
 
8013
8415
  function parseClassImplements() {
8014
8416
  var id, implemented = [], marker, typeParameters;
8015
- expectContextualKeyword('implements');
8417
+ if (strict) {
8418
+ expectKeyword('implements');
8419
+ } else {
8420
+ expectContextualKeyword('implements');
8421
+ }
8016
8422
  while (index < length) {
8017
8423
  marker = markerCreate();
8018
8424
  id = parseVariableIdentifier();
@@ -8035,11 +8441,17 @@ parseYieldExpression: true, parseAwaitExpression: true
8035
8441
 
8036
8442
  function parseClassExpression() {
8037
8443
  var id, implemented, previousYieldAllowed, superClass = null,
8038
- superTypeParameters, marker = markerCreate(), typeParameters;
8444
+ superTypeParameters, marker = markerCreate(), typeParameters,
8445
+ matchImplements;
8039
8446
 
8040
8447
  expectKeyword('class');
8041
8448
 
8042
- if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
8449
+ matchImplements =
8450
+ strict
8451
+ ? matchKeyword('implements')
8452
+ : matchContextualKeyword('implements');
8453
+
8454
+ if (!matchKeyword('extends') && !matchImplements && !match('{')) {
8043
8455
  id = parseVariableIdentifier();
8044
8456
  }
8045
8457
 
@@ -8058,7 +8470,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8058
8470
  state.yieldAllowed = previousYieldAllowed;
8059
8471
  }
8060
8472
 
8061
- if (matchContextualKeyword('implements')) {
8473
+ if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
8062
8474
  implemented = parseClassImplements();
8063
8475
  }
8064
8476
 
@@ -8095,7 +8507,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8095
8507
  state.yieldAllowed = previousYieldAllowed;
8096
8508
  }
8097
8509
 
8098
- if (matchContextualKeyword('implements')) {
8510
+ if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
8099
8511
  implemented = parseClassImplements();
8100
8512
  }
8101
8513
 
@@ -8120,6 +8532,17 @@ parseYieldExpression: true, parseAwaitExpression: true
8120
8532
  return parseConstLetDeclaration(lookahead.value);
8121
8533
  case 'function':
8122
8534
  return parseFunctionDeclaration();
8535
+ case 'export':
8536
+ throwErrorTolerant({}, Messages.IllegalExportDeclaration);
8537
+ return parseExportDeclaration();
8538
+ case 'import':
8539
+ throwErrorTolerant({}, Messages.IllegalImportDeclaration);
8540
+ return parseImportDeclaration();
8541
+ case 'interface':
8542
+ if (lookahead2().type === Token.Identifier) {
8543
+ return parseInterface();
8544
+ }
8545
+ return parseStatement();
8123
8546
  default:
8124
8547
  return parseStatement();
8125
8548
  }
@@ -8158,7 +8581,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8158
8581
  }
8159
8582
 
8160
8583
  function parseProgramElement() {
8161
- if (lookahead.type === Token.Keyword) {
8584
+ var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule';
8585
+
8586
+ if (isModule && lookahead.type === Token.Keyword) {
8162
8587
  switch (lookahead.value) {
8163
8588
  case 'export':
8164
8589
  return parseExportDeclaration();
@@ -8210,7 +8635,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8210
8635
 
8211
8636
  function parseProgram() {
8212
8637
  var body, marker = markerCreate();
8213
- strict = false;
8638
+ strict = extra.sourceType === 'module';
8214
8639
  peek();
8215
8640
  body = parseProgramElements();
8216
8641
  return markerApply(marker, delegate.createProgram(body));
@@ -8638,12 +9063,15 @@ parseYieldExpression: true, parseAwaitExpression: true
8638
9063
  if (object.type === Syntax.XJSNamespacedName) {
8639
9064
  return object.namespace.name + ':' + object.name.name;
8640
9065
  }
9066
+ /* istanbul ignore else */
8641
9067
  if (object.type === Syntax.XJSMemberExpression) {
8642
9068
  return (
8643
9069
  getQualifiedXJSName(object.object) + '.' +
8644
9070
  getQualifiedXJSName(object.property)
8645
9071
  );
8646
9072
  }
9073
+ /* istanbul ignore next */
9074
+ throwUnexpected(object);
8647
9075
  }
8648
9076
 
8649
9077
  function isXJSIdentifierStart(ch) {
@@ -8704,6 +9132,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8704
9132
  if (!isNaN(code)) {
8705
9133
  return String.fromCharCode(code);
8706
9134
  }
9135
+ /* istanbul ignore else */
8707
9136
  } else if (XHTMLEntities[str]) {
8708
9137
  return XHTMLEntities[str];
8709
9138
  }
@@ -8777,9 +9206,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8777
9206
  function advanceXJSChild() {
8778
9207
  var ch = source.charCodeAt(index);
8779
9208
 
8780
- // { (123) and < (60)
8781
- if (ch !== 123 && ch !== 60) {
8782
- return scanXJSText(['<', '{']);
9209
+ // '<' 60, '>' 62, '{' 123, '}' 125
9210
+ if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
9211
+ return scanXJSText(['<', '>', '{', '}']);
8783
9212
  }
8784
9213
 
8785
9214
  return scanPunctuator();
@@ -8939,8 +9368,10 @@ parseYieldExpression: true, parseAwaitExpression: true
8939
9368
  } else if (lookahead.type === Token.XJSText) {
8940
9369
  marker = markerCreatePreserveWhitespace();
8941
9370
  token = markerApply(marker, delegate.createLiteral(lex()));
8942
- } else {
9371
+ } else if (match('<')) {
8943
9372
  token = parseXJSElement();
9373
+ } else {
9374
+ throwUnexpected(lookahead);
8944
9375
  }
8945
9376
  return token;
8946
9377
  }
@@ -9099,9 +9530,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9099
9530
 
9100
9531
  function parseInterface() {
9101
9532
  var body, bodyMarker, extended = [], id, marker = markerCreate(),
9102
- typeParameters = null;
9533
+ typeParameters = null, previousStrict;
9534
+
9535
+ if (strict) {
9536
+ expectKeyword('interface');
9537
+ } else {
9538
+ expectContextualKeyword('interface');
9539
+ }
9103
9540
 
9104
- expectContextualKeyword('interface');
9105
9541
  return parseInterfaceish(marker, /* allowStatic */false);
9106
9542
  }
9107
9543
 
@@ -9214,6 +9650,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9214
9650
  function collectToken() {
9215
9651
  var start, loc, token, range, value, entry;
9216
9652
 
9653
+ /* istanbul ignore else */
9217
9654
  if (!state.inXJSChild) {
9218
9655
  skipComment();
9219
9656
  }
@@ -9273,6 +9710,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9273
9710
  };
9274
9711
 
9275
9712
  if (!extra.tokenize) {
9713
+ /* istanbul ignore next */
9276
9714
  // Pop the previous token, which is likely '/' or '/='
9277
9715
  if (extra.tokens.length > 0) {
9278
9716
  token = extra.tokens[extra.tokens.length - 1];
@@ -9354,12 +9792,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9354
9792
  var entry, result = {};
9355
9793
 
9356
9794
  for (entry in object) {
9795
+ /* istanbul ignore else */
9357
9796
  if (object.hasOwnProperty(entry)) {
9358
9797
  result[entry] = object[entry];
9359
9798
  }
9360
9799
  }
9361
9800
 
9362
9801
  for (entry in properties) {
9802
+ /* istanbul ignore else */
9363
9803
  if (properties.hasOwnProperty(entry)) {
9364
9804
  result[entry] = properties[entry];
9365
9805
  }
@@ -9388,7 +9828,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9388
9828
  state = {
9389
9829
  allowKeyword: true,
9390
9830
  allowIn: true,
9391
- labelSet: {},
9831
+ labelSet: new StringMap(),
9392
9832
  inFunctionBody: false,
9393
9833
  inIteration: false,
9394
9834
  inSwitch: false,
@@ -9418,17 +9858,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9418
9858
  extra.errors = [];
9419
9859
  }
9420
9860
 
9421
- if (length > 0) {
9422
- if (typeof source[0] === 'undefined') {
9423
- // Try first to convert to a string. This is good as fast path
9424
- // for old IE which understands string indexing for string
9425
- // literals only and not for string object.
9426
- if (code instanceof String) {
9427
- source = code.valueOf();
9428
- }
9429
- }
9430
- }
9431
-
9432
9861
  patch();
9433
9862
 
9434
9863
  try {
@@ -9489,7 +9918,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9489
9918
  state = {
9490
9919
  allowKeyword: false,
9491
9920
  allowIn: true,
9492
- labelSet: {},
9921
+ labelSet: new StringMap(),
9493
9922
  parenthesizedCount: 0,
9494
9923
  inFunctionBody: false,
9495
9924
  inIteration: false,
@@ -9517,6 +9946,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9517
9946
  });
9518
9947
  }
9519
9948
 
9949
+ extra.sourceType = options.sourceType;
9520
9950
  if (typeof options.tokens === 'boolean' && options.tokens) {
9521
9951
  extra.tokens = [];
9522
9952
  }
@@ -9535,17 +9965,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9535
9965
  }
9536
9966
  }
9537
9967
 
9538
- if (length > 0) {
9539
- if (typeof source[0] === 'undefined') {
9540
- // Try first to convert to a string. This is good as fast path
9541
- // for old IE which understands string indexing for string
9542
- // literals only and not for string object.
9543
- if (code instanceof String) {
9544
- source = code.valueOf();
9545
- }
9546
- }
9547
- }
9548
-
9549
9968
  patch();
9550
9969
  try {
9551
9970
  program = parseProgram();
@@ -9570,13 +9989,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9570
9989
  }
9571
9990
 
9572
9991
  // Sync with *.json manifests.
9573
- exports.version = '8001.1001.0-dev-harmony-fb';
9992
+ exports.version = '12001.1.0-dev-harmony-fb';
9574
9993
 
9575
9994
  exports.tokenize = tokenize;
9576
9995
 
9577
9996
  exports.parse = parse;
9578
9997
 
9579
9998
  // Deep copy.
9999
+ /* istanbul ignore next */
9580
10000
  exports.Syntax = (function () {
9581
10001
  var name, types = {};
9582
10002
 
@@ -9600,6 +10020,34 @@ parseYieldExpression: true, parseAwaitExpression: true
9600
10020
  }));
9601
10021
  /* vim: set sw=4 ts=4 et tw=80 : */
9602
10022
 
10023
+ },{}],9:[function(_dereq_,module,exports){
10024
+ var Base62 = (function (my) {
10025
+ my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
10026
+
10027
+ my.encode = function(i){
10028
+ if (i === 0) {return '0'}
10029
+ var s = ''
10030
+ while (i > 0) {
10031
+ s = this.chars[i % 62] + s
10032
+ i = Math.floor(i/62)
10033
+ }
10034
+ return s
10035
+ };
10036
+ my.decode = function(a,b,c,d){
10037
+ for (
10038
+ b = c = (
10039
+ a === (/\W|_|^$/.test(a += "") || a)
10040
+ ) - 1;
10041
+ d = a.charCodeAt(c++);
10042
+ )
10043
+ b = b * 62 + d - [, 48, 29, 87][d >> 5];
10044
+ return b
10045
+ };
10046
+
10047
+ return my;
10048
+ }({}));
10049
+
10050
+ module.exports = Base62
9603
10051
  },{}],10:[function(_dereq_,module,exports){
9604
10052
  /*
9605
10053
  * Copyright 2009-2011 Mozilla Foundation and contributors
@@ -11858,7 +12306,12 @@ function _nodeIsClosureScopeBoundary(node, parentNode) {
11858
12306
  || parentNode.type === Syntax.FunctionExpression
11859
12307
  || parentNode.type === Syntax.ArrowFunctionExpression;
11860
12308
 
11861
- return node.type === Syntax.BlockStatement && parentIsFunction;
12309
+ var parentIsCurlylessArrowFunc =
12310
+ parentNode.type === Syntax.ArrowFunctionExpression
12311
+ && node === parentNode.body;
12312
+
12313
+ return parentIsFunction
12314
+ && (node.type === Syntax.BlockStatement || parentIsCurlylessArrowFunc);
11862
12315
  }
11863
12316
 
11864
12317
  function _nodeIsBlockScopeBoundary(node, parentNode) {
@@ -11876,29 +12329,38 @@ function _nodeIsBlockScopeBoundary(node, parentNode) {
11876
12329
  * @param {object} state
11877
12330
  */
11878
12331
  function traverse(node, path, state) {
12332
+ /*jshint -W004*/
11879
12333
  // Create a scope stack entry if this is the first node we've encountered in
11880
12334
  // its local scope
12335
+ var startIndex = null;
11881
12336
  var parentNode = path[0];
11882
12337
  if (!Array.isArray(node) && state.localScope.parentNode !== parentNode) {
11883
12338
  if (_nodeIsClosureScopeBoundary(node, parentNode)) {
11884
- var scopeIsStrict =
11885
- state.scopeIsStrict
11886
- || node.body.length > 0
11887
- && node.body[0].type === Syntax.ExpressionStatement
11888
- && node.body[0].expression.type === Syntax.Literal
11889
- && node.body[0].expression.value === 'use strict';
12339
+ var scopeIsStrict = state.scopeIsStrict;
12340
+ if (!scopeIsStrict
12341
+ && (node.type === Syntax.BlockStatement
12342
+ || node.type === Syntax.Program)) {
12343
+ scopeIsStrict =
12344
+ node.body.length > 0
12345
+ && node.body[0].type === Syntax.ExpressionStatement
12346
+ && node.body[0].expression.type === Syntax.Literal
12347
+ && node.body[0].expression.value === 'use strict';
12348
+ }
11890
12349
 
11891
12350
  if (node.type === Syntax.Program) {
12351
+ startIndex = state.g.buffer.length;
11892
12352
  state = utils.updateState(state, {
11893
12353
  scopeIsStrict: scopeIsStrict
11894
12354
  });
11895
12355
  } else {
12356
+ startIndex = state.g.buffer.length + 1;
11896
12357
  state = utils.updateState(state, {
11897
12358
  localScope: {
11898
12359
  parentNode: parentNode,
11899
12360
  parentScope: state.localScope,
11900
12361
  identifiers: {},
11901
- tempVarIndex: 0
12362
+ tempVarIndex: 0,
12363
+ tempVars: []
11902
12364
  },
11903
12365
  scopeIsStrict: scopeIsStrict
11904
12366
  });
@@ -11910,16 +12372,26 @@ function traverse(node, path, state) {
11910
12372
  // function
11911
12373
  if (parentNode.params.length > 0) {
11912
12374
  var param;
12375
+ var metadata = initScopeMetadata(parentNode, path.slice(1), path[0]);
11913
12376
  for (var i = 0; i < parentNode.params.length; i++) {
11914
12377
  param = parentNode.params[i];
11915
12378
  if (param.type === Syntax.Identifier) {
11916
- declareIdentInScope(
11917
- param.name, initScopeMetadata(parentNode), state
11918
- );
12379
+ declareIdentInScope(param.name, metadata, state);
11919
12380
  }
11920
12381
  }
11921
12382
  }
11922
12383
 
12384
+ // Include rest arg identifiers in the scope boundaries of their
12385
+ // functions
12386
+ if (parentNode.rest) {
12387
+ var metadata = initScopeMetadata(
12388
+ parentNode,
12389
+ path.slice(1),
12390
+ path[0]
12391
+ );
12392
+ declareIdentInScope(parentNode.rest.name, metadata, state);
12393
+ }
12394
+
11923
12395
  // Named FunctionExpressions scope their name within the body block of
11924
12396
  // themselves only
11925
12397
  if (parentNode.type === Syntax.FunctionExpression && parentNode.id) {
@@ -11935,18 +12407,24 @@ function traverse(node, path, state) {
11935
12407
  }
11936
12408
 
11937
12409
  if (_nodeIsBlockScopeBoundary(node, parentNode)) {
12410
+ startIndex = state.g.buffer.length;
11938
12411
  state = utils.updateState(state, {
11939
12412
  localScope: {
11940
12413
  parentNode: parentNode,
11941
12414
  parentScope: state.localScope,
11942
- identifiers: {}
12415
+ identifiers: {},
12416
+ tempVarIndex: 0,
12417
+ tempVars: []
11943
12418
  }
11944
12419
  });
11945
12420
 
11946
12421
  if (parentNode.type === Syntax.CatchClause) {
11947
- declareIdentInScope(
11948
- parentNode.param.name, initScopeMetadata(parentNode), state
12422
+ var metadata = initScopeMetadata(
12423
+ parentNode,
12424
+ path.slice(1),
12425
+ parentNode
11949
12426
  );
12427
+ declareIdentInScope(parentNode.param.name, metadata, state);
11950
12428
  }
11951
12429
  collectBlockIdentsAndTraverse(node, path, state);
11952
12430
  }
@@ -11960,6 +12438,11 @@ function traverse(node, path, state) {
11960
12438
  }
11961
12439
 
11962
12440
  utils.analyzeAndTraverse(walker, traverser, node, path, state);
12441
+
12442
+ // Inject temp variables into the scope.
12443
+ if (startIndex !== null) {
12444
+ utils.injectTempVarDeclarations(state, startIndex);
12445
+ }
11963
12446
  }
11964
12447
 
11965
12448
  function collectClosureIdentsAndTraverse(node, path, state) {
@@ -11985,6 +12468,7 @@ function collectBlockIdentsAndTraverse(node, path, state) {
11985
12468
  function visitLocalClosureIdentifiers(node, path, state) {
11986
12469
  var metaData;
11987
12470
  switch (node.type) {
12471
+ case Syntax.ArrowFunctionExpression:
11988
12472
  case Syntax.FunctionExpression:
11989
12473
  // Function expressions don't get their names (if there is one) added to
11990
12474
  // the closure scope they're defined in
@@ -12025,6 +12509,22 @@ function walker(node, path, state) {
12025
12509
 
12026
12510
  var _astCache = {};
12027
12511
 
12512
+ function getAstForSource(source, options) {
12513
+ if (_astCache[source] && !options.disableAstCache) {
12514
+ return _astCache[source];
12515
+ }
12516
+ var ast = esprima.parse(source, {
12517
+ comment: true,
12518
+ loc: true,
12519
+ range: true,
12520
+ sourceType: options.sourceType
12521
+ });
12522
+ if (!options.disableAstCache) {
12523
+ _astCache[source] = ast;
12524
+ }
12525
+ return ast;
12526
+ }
12527
+
12028
12528
  /**
12029
12529
  * Applies all available transformations to the source
12030
12530
  * @param {array} visitors
@@ -12036,13 +12536,7 @@ function transform(visitors, source, options) {
12036
12536
  options = options || {};
12037
12537
  var ast;
12038
12538
  try {
12039
- var cachedAst = _astCache[source];
12040
- ast = cachedAst ||
12041
- (_astCache[source] = esprima.parse(source, {
12042
- comment: true,
12043
- loc: true,
12044
- range: true
12045
- }));
12539
+ ast = getAstForSource(source, options);
12046
12540
  } catch (e) {
12047
12541
  e.message = 'Parse Error: ' + e.message;
12048
12542
  throw e;
@@ -12069,7 +12563,7 @@ function transform(visitors, source, options) {
12069
12563
  exports.transform = transform;
12070
12564
  exports.Syntax = Syntax;
12071
12565
 
12072
- },{"./utils":22,"esprima-fb":9,"source-map":10}],22:[function(_dereq_,module,exports){
12566
+ },{"./utils":22,"esprima-fb":8,"source-map":10}],22:[function(_dereq_,module,exports){
12073
12567
  /**
12074
12568
  * Copyright 2013 Facebook, Inc.
12075
12569
  *
@@ -12114,7 +12608,8 @@ function createState(source, rootNode, transformOptions) {
12114
12608
  parentNode: rootNode,
12115
12609
  parentScope: null,
12116
12610
  identifiers: {},
12117
- tempVarIndex: 0
12611
+ tempVarIndex: 0,
12612
+ tempVars: []
12118
12613
  },
12119
12614
  /**
12120
12615
  * The name (and, if applicable, expression) of the super class
@@ -12331,29 +12826,87 @@ function getNodeSourceText(node, state) {
12331
12826
  return state.g.source.substring(node.range[0], node.range[1]);
12332
12827
  }
12333
12828
 
12334
- function replaceNonWhite(value) {
12829
+ function _replaceNonWhite(value) {
12335
12830
  return value.replace(nonWhiteRegexp, ' ');
12336
12831
  }
12337
12832
 
12338
12833
  /**
12339
12834
  * Removes all non-whitespace characters
12340
12835
  */
12341
- function stripNonWhite(value) {
12836
+ function _stripNonWhite(value) {
12342
12837
  return value.replace(nonWhiteRegexp, '');
12343
12838
  }
12344
12839
 
12840
+ /**
12841
+ * Finds the position of the next instance of the specified syntactic char in
12842
+ * the pending source.
12843
+ *
12844
+ * NOTE: This will skip instances of the specified char if they sit inside a
12845
+ * comment body.
12846
+ *
12847
+ * NOTE: This function also assumes that the buffer's current position is not
12848
+ * already within a comment or a string. This is rarely the case since all
12849
+ * of the buffer-advancement utility methods tend to be used on syntactic
12850
+ * nodes' range values -- but it's a small gotcha that's worth mentioning.
12851
+ */
12852
+ function getNextSyntacticCharOffset(char, state) {
12853
+ var pendingSource = state.g.source.substring(state.g.position);
12854
+ var pendingSourceLines = pendingSource.split('\n');
12855
+
12856
+ var charOffset = 0;
12857
+ var line;
12858
+ var withinBlockComment = false;
12859
+ var withinString = false;
12860
+ lineLoop: while ((line = pendingSourceLines.shift()) !== undefined) {
12861
+ var lineEndPos = charOffset + line.length;
12862
+ charLoop: for (; charOffset < lineEndPos; charOffset++) {
12863
+ var currChar = pendingSource[charOffset];
12864
+ if (currChar === '"' || currChar === '\'') {
12865
+ withinString = !withinString;
12866
+ continue charLoop;
12867
+ } else if (withinString) {
12868
+ continue charLoop;
12869
+ } else if (charOffset + 1 < lineEndPos) {
12870
+ var nextTwoChars = currChar + line[charOffset + 1];
12871
+ if (nextTwoChars === '//') {
12872
+ charOffset = lineEndPos + 1;
12873
+ continue lineLoop;
12874
+ } else if (nextTwoChars === '/*') {
12875
+ withinBlockComment = true;
12876
+ charOffset += 1;
12877
+ continue charLoop;
12878
+ } else if (nextTwoChars === '*/') {
12879
+ withinBlockComment = false;
12880
+ charOffset += 1;
12881
+ continue charLoop;
12882
+ }
12883
+ }
12884
+
12885
+ if (!withinBlockComment && currChar === char) {
12886
+ return charOffset + state.g.position;
12887
+ }
12888
+ }
12889
+
12890
+ // Account for '\n'
12891
+ charOffset++;
12892
+ withinString = false;
12893
+ }
12894
+
12895
+ throw new Error('`' + char + '` not found!');
12896
+ }
12897
+
12345
12898
  /**
12346
12899
  * Catches up as `catchup` but replaces non-whitespace chars with spaces.
12347
12900
  */
12348
12901
  function catchupWhiteOut(end, state) {
12349
- catchup(end, state, replaceNonWhite);
12902
+ catchup(end, state, _replaceNonWhite);
12350
12903
  }
12351
12904
 
12352
12905
  /**
12353
12906
  * Catches up as `catchup` but removes all non-whitespace characters.
12354
12907
  */
12355
12908
  function catchupWhiteSpace(end, state) {
12356
- catchup(end, state, stripNonWhite);
12909
+ catchup(end, state, _stripNonWhite);
12357
12910
  }
12358
12911
 
12359
12912
  /**
@@ -12436,6 +12989,7 @@ function append(str, state) {
12436
12989
  * @return {string}
12437
12990
  */
12438
12991
  function updateIndent(str, state) {
12992
+ /*jshint -W004*/
12439
12993
  var indentBy = state.indentBy;
12440
12994
  if (indentBy < 0) {
12441
12995
  for (var i = 0; i < -indentBy; i++) {
@@ -12527,6 +13081,17 @@ function declareIdentInLocalScope(identName, metaData, state) {
12527
13081
  }
12528
13082
 
12529
13083
  function getLexicalBindingMetadata(identName, state) {
13084
+ var currScope = state.localScope;
13085
+ while (currScope) {
13086
+ if (currScope.identifiers[identName] !== undefined) {
13087
+ return currScope.identifiers[identName];
13088
+ }
13089
+
13090
+ currScope = currScope.parentScope;
13091
+ }
13092
+ }
13093
+
13094
+ function getLocalBindingMetadata(identName, state) {
12530
13095
  return state.localScope.identifiers[identName];
12531
13096
  }
12532
13097
 
@@ -12642,6 +13207,7 @@ function containsChildMatching(node, matcher) {
12642
13207
  }
12643
13208
 
12644
13209
  var scopeTypes = {};
13210
+ scopeTypes[Syntax.ArrowFunctionExpression] = true;
12645
13211
  scopeTypes[Syntax.FunctionExpression] = true;
12646
13212
  scopeTypes[Syntax.FunctionDeclaration] = true;
12647
13213
  scopeTypes[Syntax.Program] = true;
@@ -12662,15 +13228,28 @@ function getTempVar(tempVarIndex) {
12662
13228
  return '$__' + tempVarIndex;
12663
13229
  }
12664
13230
 
12665
- function getTempVarWithValue(tempVarIndex, tempVarValue) {
12666
- return getTempVar(tempVarIndex) + '=' + tempVarValue;
13231
+ function injectTempVar(state) {
13232
+ var tempVar = '$__' + (state.localScope.tempVarIndex++);
13233
+ state.localScope.tempVars.push(tempVar);
13234
+ return tempVar;
13235
+ }
13236
+
13237
+ function injectTempVarDeclarations(state, index) {
13238
+ if (state.localScope.tempVars.length) {
13239
+ state.g.buffer =
13240
+ state.g.buffer.slice(0, index) +
13241
+ 'var ' + state.localScope.tempVars.join(', ') + ';' +
13242
+ state.g.buffer.slice(index);
13243
+ state.localScope.tempVars = [];
13244
+ }
12667
13245
  }
12668
13246
 
13247
+ exports.analyzeAndTraverse = analyzeAndTraverse;
12669
13248
  exports.append = append;
12670
13249
  exports.catchup = catchup;
13250
+ exports.catchupNewlines = catchupNewlines;
12671
13251
  exports.catchupWhiteOut = catchupWhiteOut;
12672
13252
  exports.catchupWhiteSpace = catchupWhiteSpace;
12673
- exports.catchupNewlines = catchupNewlines;
12674
13253
  exports.containsChildMatching = containsChildMatching;
12675
13254
  exports.containsChildOfType = containsChildOfType;
12676
13255
  exports.createState = createState;
@@ -12678,21 +13257,23 @@ exports.declareIdentInLocalScope = declareIdentInLocalScope;
12678
13257
  exports.getBoundaryNode = getBoundaryNode;
12679
13258
  exports.getDocblock = getDocblock;
12680
13259
  exports.getLexicalBindingMetadata = getLexicalBindingMetadata;
12681
- exports.initScopeMetadata = initScopeMetadata;
12682
- exports.identWithinLexicalScope = identWithinLexicalScope;
13260
+ exports.getLocalBindingMetadata = getLocalBindingMetadata;
13261
+ exports.getNextSyntacticCharOffset = getNextSyntacticCharOffset;
13262
+ exports.getNodeSourceText = getNodeSourceText;
13263
+ exports.getOrderedChildren = getOrderedChildren;
13264
+ exports.getTempVar = getTempVar;
12683
13265
  exports.identInLocalScope = identInLocalScope;
13266
+ exports.identWithinLexicalScope = identWithinLexicalScope;
12684
13267
  exports.indentBefore = indentBefore;
13268
+ exports.initScopeMetadata = initScopeMetadata;
13269
+ exports.injectTempVar = injectTempVar;
13270
+ exports.injectTempVarDeclarations = injectTempVarDeclarations;
12685
13271
  exports.move = move;
12686
13272
  exports.scopeTypes = scopeTypes;
12687
13273
  exports.updateIndent = updateIndent;
12688
13274
  exports.updateState = updateState;
12689
- exports.analyzeAndTraverse = analyzeAndTraverse;
12690
- exports.getOrderedChildren = getOrderedChildren;
12691
- exports.getNodeSourceText = getNodeSourceText;
12692
- exports.getTempVar = getTempVar;
12693
- exports.getTempVarWithValue = getTempVarWithValue;
12694
13275
 
12695
- },{"./docblock":20,"esprima-fb":9}],23:[function(_dereq_,module,exports){
13276
+ },{"./docblock":20,"esprima-fb":8}],23:[function(_dereq_,module,exports){
12696
13277
  /**
12697
13278
  * Copyright 2013 Facebook, Inc.
12698
13279
  *
@@ -12852,7 +13433,7 @@ exports.visitorList = [
12852
13433
  ];
12853
13434
 
12854
13435
 
12855
- },{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":9}],24:[function(_dereq_,module,exports){
13436
+ },{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":8}],24:[function(_dereq_,module,exports){
12856
13437
  /**
12857
13438
  * Copyright 2013 Facebook, Inc.
12858
13439
  *
@@ -13036,6 +13617,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13036
13617
  if (methodNode.key.name === 'constructor') {
13037
13618
  utils.append('function ' + state.className, state);
13038
13619
  } else {
13620
+ var methodAccessorComputed = false;
13039
13621
  var methodAccessor;
13040
13622
  var prototypeOrStatic = methodNode["static"] ? '' : '.prototype';
13041
13623
  var objectAccessor = state.className + prototypeOrStatic;
@@ -13049,16 +13631,13 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13049
13631
  if (isGetter || isSetter) {
13050
13632
  methodAccessor = JSON.stringify(methodAccessor);
13051
13633
  } else if (reservedWordsHelper.isReservedWord(methodAccessor)) {
13052
- methodAccessor = '[' + JSON.stringify(methodAccessor) + ']';
13053
- } else {
13054
- methodAccessor = '.' + methodAccessor;
13634
+ methodAccessorComputed = true;
13635
+ methodAccessor = JSON.stringify(methodAccessor);
13055
13636
  }
13056
13637
  } else if (methodNode.key.type === Syntax.Literal) {
13057
13638
  // 'foo bar'() {} | get 'foo bar'() {} | set 'foo bar'() {}
13058
13639
  methodAccessor = JSON.stringify(methodNode.key.value);
13059
- if (!(isGetter || isSetter)) {
13060
- methodAccessor = '[' + methodAccessor + ']';
13061
- }
13640
+ methodAccessorComputed = true;
13062
13641
  }
13063
13642
 
13064
13643
  if (isSetter || isGetter) {
@@ -13066,16 +13645,35 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13066
13645
  'Object.defineProperty(' +
13067
13646
  objectAccessor + ',' +
13068
13647
  methodAccessor + ',' +
13069
- '{enumerable:true,configurable:true,' +
13648
+ '{configurable:true,' +
13070
13649
  methodNode.kind + ':function',
13071
13650
  state
13072
13651
  );
13073
13652
  } else {
13074
- utils.append(
13075
- objectAccessor +
13076
- methodAccessor + '=function' + (node.generator ? '*' : ''),
13077
- state
13078
- );
13653
+ if (state.g.opts.es3) {
13654
+ if (methodAccessorComputed) {
13655
+ methodAccessor = '[' + methodAccessor + ']';
13656
+ } else {
13657
+ methodAccessor = '.' + methodAccessor;
13658
+ }
13659
+ utils.append(
13660
+ objectAccessor +
13661
+ methodAccessor + '=function' + (node.generator ? '*' : ''),
13662
+ state
13663
+ );
13664
+ } else {
13665
+ if (!methodAccessorComputed) {
13666
+ methodAccessor = JSON.stringify(methodAccessor);
13667
+ }
13668
+ utils.append(
13669
+ 'Object.defineProperty(' +
13670
+ objectAccessor + ',' +
13671
+ methodAccessor + ',' +
13672
+ '{writable:true,configurable:true,' +
13673
+ 'value:function' + (node.generator ? '*' : ''),
13674
+ state
13675
+ );
13676
+ }
13079
13677
  }
13080
13678
  }
13081
13679
  utils.move(methodNode.key.range[1], state);
@@ -13091,9 +13689,13 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13091
13689
  path.shift();
13092
13690
  }
13093
13691
  }
13094
- utils.append(')', state);
13095
- utils.catchupWhiteSpace(node.body.range[0], state);
13096
- utils.append('{', state);
13692
+
13693
+ var closingParenPosition = utils.getNextSyntacticCharOffset(')', state);
13694
+ utils.catchupWhiteSpace(closingParenPosition, state);
13695
+
13696
+ var openingBracketPosition = utils.getNextSyntacticCharOffset('{', state);
13697
+ utils.catchup(openingBracketPosition + 1, state);
13698
+
13097
13699
  if (!state.scopeIsStrict) {
13098
13700
  utils.append('"use strict";', state);
13099
13701
  state = utils.updateState(state, {
@@ -13108,7 +13710,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13108
13710
  utils.catchup(node.body.range[1], state);
13109
13711
 
13110
13712
  if (methodNode.key.name !== 'constructor') {
13111
- if (isGetter || isSetter) {
13713
+ if (isGetter || isSetter || !state.g.opts.es3) {
13112
13714
  utils.append('})', state);
13113
13715
  }
13114
13716
  utils.append(';', state);
@@ -13421,7 +14023,7 @@ exports.visitorList = [
13421
14023
  visitSuperMemberExpression
13422
14024
  ];
13423
14025
 
13424
- },{"../src/utils":22,"./reserved-words-helper":32,"base62":8,"esprima-fb":9}],25:[function(_dereq_,module,exports){
14026
+ },{"../src/utils":22,"./reserved-words-helper":32,"base62":9,"esprima-fb":8}],25:[function(_dereq_,module,exports){
13425
14027
  /**
13426
14028
  * Copyright 2014 Facebook, Inc.
13427
14029
  *
@@ -13543,7 +14145,7 @@ function getDestructuredComponents(node, state) {
13543
14145
  } else {
13544
14146
  // Complex sub-structure.
13545
14147
  components.push(
13546
- utils.getTempVarWithValue(++state.localScope.tempVarIndex, accessor) +
14148
+ utils.getTempVar(++state.localScope.tempVarIndex) + '=' + accessor +
13547
14149
  ',' + getDestructuredComponents(value, state)
13548
14150
  );
13549
14151
  }
@@ -13703,7 +14305,7 @@ exports.visitorList = [
13703
14305
  exports.renderDestructuredComponents = renderDestructuredComponents;
13704
14306
 
13705
14307
 
13706
- },{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":9}],26:[function(_dereq_,module,exports){
14308
+ },{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":8}],26:[function(_dereq_,module,exports){
13707
14309
  /**
13708
14310
  * Copyright 2013 Facebook, Inc.
13709
14311
  *
@@ -13774,7 +14376,7 @@ exports.visitorList = [
13774
14376
  visitObjectConciseMethod
13775
14377
  ];
13776
14378
 
13777
- },{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":9}],27:[function(_dereq_,module,exports){
14379
+ },{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":8}],27:[function(_dereq_,module,exports){
13778
14380
  /**
13779
14381
  * Copyright 2013 Facebook, Inc.
13780
14382
  *
@@ -13829,7 +14431,7 @@ exports.visitorList = [
13829
14431
  ];
13830
14432
 
13831
14433
 
13832
- },{"../src/utils":22,"esprima-fb":9}],28:[function(_dereq_,module,exports){
14434
+ },{"../src/utils":22,"esprima-fb":8}],28:[function(_dereq_,module,exports){
13833
14435
  /**
13834
14436
  * Copyright 2013 Facebook, Inc.
13835
14437
  *
@@ -13912,8 +14514,8 @@ function renderRestParamSetup(functionNode, state) {
13912
14514
  var len = state.localScope.tempVarIndex++;
13913
14515
 
13914
14516
  return 'for (var ' + functionNode.rest.name + '=[],' +
13915
- utils.getTempVarWithValue(idx, functionNode.params.length) + ',' +
13916
- utils.getTempVarWithValue(len, 'arguments.length') + ';' +
14517
+ utils.getTempVar(idx) + '=' + functionNode.params.length + ',' +
14518
+ utils.getTempVar(len) + '=arguments.length;' +
13917
14519
  utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' +
13918
14520
  utils.getTempVar(idx) + '++) ' +
13919
14521
  functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);';
@@ -13937,7 +14539,7 @@ exports.visitorList = [
13937
14539
  visitFunctionBodyWithRestParam
13938
14540
  ];
13939
14541
 
13940
- },{"../src/utils":22,"esprima-fb":9}],29:[function(_dereq_,module,exports){
14542
+ },{"../src/utils":22,"esprima-fb":8}],29:[function(_dereq_,module,exports){
13941
14543
  /**
13942
14544
  * Copyright 2013 Facebook, Inc.
13943
14545
  *
@@ -14095,7 +14697,7 @@ exports.visitorList = [
14095
14697
  visitTaggedTemplateExpression
14096
14698
  ];
14097
14699
 
14098
- },{"../src/utils":22,"esprima-fb":9}],30:[function(_dereq_,module,exports){
14700
+ },{"../src/utils":22,"esprima-fb":8}],30:[function(_dereq_,module,exports){
14099
14701
  /**
14100
14702
  * Copyright 2013 Facebook, Inc.
14101
14703
  *
@@ -14119,7 +14721,6 @@ exports.visitorList = [
14119
14721
  */
14120
14722
 
14121
14723
  var Syntax = _dereq_('esprima-fb').Syntax;
14122
- var utils = _dereq_('../src/utils');
14123
14724
 
14124
14725
  // TODO: This is a pretty massive helper, it should only be defined once, in the
14125
14726
  // transform's runtime environment. We don't currently have a runtime though.
@@ -14178,7 +14779,7 @@ function renderRestExpression(accessorExpression, excludedProperties) {
14178
14779
 
14179
14780
  exports.renderRestExpression = renderRestExpression;
14180
14781
 
14181
- },{"../src/utils":22,"esprima-fb":9}],31:[function(_dereq_,module,exports){
14782
+ },{"esprima-fb":8}],31:[function(_dereq_,module,exports){
14182
14783
  /**
14183
14784
  * Copyright 2004-present Facebook. All Rights Reserved.
14184
14785
  */
@@ -14288,7 +14889,7 @@ exports.visitorList = [
14288
14889
  visitObjectLiteralSpread
14289
14890
  ];
14290
14891
 
14291
- },{"../src/utils":22,"esprima-fb":9}],32:[function(_dereq_,module,exports){
14892
+ },{"../src/utils":22,"esprima-fb":8}],32:[function(_dereq_,module,exports){
14292
14893
  /**
14293
14894
  * Copyright 2014 Facebook, Inc.
14294
14895
  *
@@ -14368,6 +14969,15 @@ visitTypeAlias.test = function(node, path, state) {
14368
14969
  return node.type === Syntax.TypeAlias;
14369
14970
  };
14370
14971
 
14972
+ function visitTypeCast(traverse, node, path, state) {
14973
+ utils.catchup(node.typeAnnotation.range[0], state);
14974
+ utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
14975
+ return false;
14976
+ }
14977
+ visitTypeCast.test = function(node, path, state) {
14978
+ return node.type === Syntax.TypeCastExpression;
14979
+ };
14980
+
14371
14981
  function visitInterfaceDeclaration(traverse, node, path, state) {
14372
14982
  utils.catchupWhiteOut(node.range[1], state);
14373
14983
  return false;
@@ -14382,13 +14992,14 @@ function visitDeclare(traverse, node, path, state) {
14382
14992
  }
14383
14993
  visitDeclare.test = function(node, path, state) {
14384
14994
  switch (node.type) {
14385
- case Syntax.DeclareVariable:
14386
- case Syntax.DeclareFunction:
14387
- case Syntax.DeclareClass:
14388
- case Syntax.DeclareModule: return true
14995
+ case Syntax.DeclareVariable:
14996
+ case Syntax.DeclareFunction:
14997
+ case Syntax.DeclareClass:
14998
+ case Syntax.DeclareModule:
14999
+ return true;
14389
15000
  }
14390
15001
  return false;
14391
- }
15002
+ };
14392
15003
 
14393
15004
  function visitFunctionParametricAnnotation(traverse, node, path, state) {
14394
15005
  utils.catchup(node.range[0], state);
@@ -14475,22 +15086,33 @@ visitMethod.test = function(node, path, state) {
14475
15086
  || (node.type === "MethodDefinition");
14476
15087
  };
14477
15088
 
15089
+ function visitImportType(traverse, node, path, state) {
15090
+ utils.catchupWhiteOut(node.range[1], state);
15091
+ return false;
15092
+ }
15093
+ visitImportType.test = function(node, path, state) {
15094
+ return node.type === 'ImportDeclaration'
15095
+ && node.isType;
15096
+ };
15097
+
14478
15098
  exports.visitorList = [
14479
15099
  visitClassProperty,
14480
15100
  visitDeclare,
15101
+ visitImportType,
14481
15102
  visitInterfaceDeclaration,
14482
15103
  visitFunctionParametricAnnotation,
14483
15104
  visitFunctionReturnAnnotation,
14484
15105
  visitMethod,
14485
15106
  visitOptionalFunctionParameterAnnotation,
14486
15107
  visitTypeAlias,
15108
+ visitTypeCast,
14487
15109
  visitTypeAnnotatedIdentifier,
14488
15110
  visitTypeAnnotatedObjectOrArrayPattern
14489
15111
  ];
14490
15112
 
14491
- },{"../src/utils":22,"esprima-fb":9}],34:[function(_dereq_,module,exports){
15113
+ },{"../src/utils":22,"esprima-fb":8}],34:[function(_dereq_,module,exports){
14492
15114
  /**
14493
- * Copyright 2013-2014, Facebook, Inc.
15115
+ * Copyright 2013-2015, Facebook, Inc.
14494
15116
  * All rights reserved.
14495
15117
  *
14496
15118
  * This source code is licensed under the BSD-style license found in the
@@ -14503,7 +15125,6 @@ exports.visitorList = [
14503
15125
  var Syntax = _dereq_('jstransform').Syntax;
14504
15126
  var utils = _dereq_('jstransform/src/utils');
14505
15127
 
14506
- var FALLBACK_TAGS = _dereq_('./xjs').knownTags;
14507
15128
  var renderXJSExpressionContainer =
14508
15129
  _dereq_('./xjs').renderXJSExpressionContainer;
14509
15130
  var renderXJSLiteral = _dereq_('./xjs').renderXJSLiteral;
@@ -14549,17 +15170,7 @@ function visitReactTag(traverse, object, path, state) {
14549
15170
  // We assume that the React runtime is already in scope
14550
15171
  utils.append('React.createElement(', state);
14551
15172
 
14552
- // Identifiers with lower case or hypthens are fallback tags (strings).
14553
- // XJSMemberExpressions are not.
14554
15173
  if (nameObject.type === Syntax.XJSIdentifier && isTagName(nameObject.name)) {
14555
- // This is a temporary error message to assist upgrades
14556
- if (!FALLBACK_TAGS.hasOwnProperty(nameObject.name)) {
14557
- throw new Error(
14558
- 'Lower case component names (' + nameObject.name + ') are no longer ' +
14559
- 'supported in JSX: See http://fb.me/react-jsx-lower-case'
14560
- );
14561
- }
14562
-
14563
15174
  utils.append('"' + nameObject.name + '"', state);
14564
15175
  utils.move(nameObject.range[1], state);
14565
15176
  } else {
@@ -14745,7 +15356,7 @@ exports.visitorList = [
14745
15356
 
14746
15357
  },{"./xjs":36,"jstransform":21,"jstransform/src/utils":22}],35:[function(_dereq_,module,exports){
14747
15358
  /**
14748
- * Copyright 2013-2014, Facebook, Inc.
15359
+ * Copyright 2013-2015, Facebook, Inc.
14749
15360
  * All rights reserved.
14750
15361
  *
14751
15362
  * This source code is licensed under the BSD-style license found in the
@@ -14840,7 +15451,7 @@ exports.visitorList = [
14840
15451
 
14841
15452
  },{"jstransform":21,"jstransform/src/utils":22}],36:[function(_dereq_,module,exports){
14842
15453
  /**
14843
- * Copyright 2013-2014, Facebook, Inc.
15454
+ * Copyright 2013-2015, Facebook, Inc.
14844
15455
  * All rights reserved.
14845
15456
  *
14846
15457
  * This source code is licensed under the BSD-style license found in the
@@ -14852,142 +15463,6 @@ exports.visitorList = [
14852
15463
  var Syntax = _dereq_('jstransform').Syntax;
14853
15464
  var utils = _dereq_('jstransform/src/utils');
14854
15465
 
14855
- var knownTags = {
14856
- a: true,
14857
- abbr: true,
14858
- address: true,
14859
- applet: true,
14860
- area: true,
14861
- article: true,
14862
- aside: true,
14863
- audio: true,
14864
- b: true,
14865
- base: true,
14866
- bdi: true,
14867
- bdo: true,
14868
- big: true,
14869
- blockquote: true,
14870
- body: true,
14871
- br: true,
14872
- button: true,
14873
- canvas: true,
14874
- caption: true,
14875
- circle: true,
14876
- cite: true,
14877
- code: true,
14878
- col: true,
14879
- colgroup: true,
14880
- command: true,
14881
- data: true,
14882
- datalist: true,
14883
- dd: true,
14884
- defs: true,
14885
- del: true,
14886
- details: true,
14887
- dfn: true,
14888
- dialog: true,
14889
- div: true,
14890
- dl: true,
14891
- dt: true,
14892
- ellipse: true,
14893
- em: true,
14894
- embed: true,
14895
- fieldset: true,
14896
- figcaption: true,
14897
- figure: true,
14898
- footer: true,
14899
- form: true,
14900
- g: true,
14901
- h1: true,
14902
- h2: true,
14903
- h3: true,
14904
- h4: true,
14905
- h5: true,
14906
- h6: true,
14907
- head: true,
14908
- header: true,
14909
- hgroup: true,
14910
- hr: true,
14911
- html: true,
14912
- i: true,
14913
- iframe: true,
14914
- img: true,
14915
- input: true,
14916
- ins: true,
14917
- kbd: true,
14918
- keygen: true,
14919
- label: true,
14920
- legend: true,
14921
- li: true,
14922
- line: true,
14923
- linearGradient: true,
14924
- link: true,
14925
- main: true,
14926
- map: true,
14927
- mark: true,
14928
- marquee: true,
14929
- mask: false,
14930
- menu: true,
14931
- menuitem: true,
14932
- meta: true,
14933
- meter: true,
14934
- nav: true,
14935
- noscript: true,
14936
- object: true,
14937
- ol: true,
14938
- optgroup: true,
14939
- option: true,
14940
- output: true,
14941
- p: true,
14942
- param: true,
14943
- path: true,
14944
- pattern: false,
14945
- picture: true,
14946
- polygon: true,
14947
- polyline: true,
14948
- pre: true,
14949
- progress: true,
14950
- q: true,
14951
- radialGradient: true,
14952
- rect: true,
14953
- rp: true,
14954
- rt: true,
14955
- ruby: true,
14956
- s: true,
14957
- samp: true,
14958
- script: true,
14959
- section: true,
14960
- select: true,
14961
- small: true,
14962
- source: true,
14963
- span: true,
14964
- stop: true,
14965
- strong: true,
14966
- style: true,
14967
- sub: true,
14968
- summary: true,
14969
- sup: true,
14970
- svg: true,
14971
- table: true,
14972
- tbody: true,
14973
- td: true,
14974
- text: true,
14975
- textarea: true,
14976
- tfoot: true,
14977
- th: true,
14978
- thead: true,
14979
- time: true,
14980
- title: true,
14981
- tr: true,
14982
- track: true,
14983
- tspan: true,
14984
- u: true,
14985
- ul: true,
14986
- 'var': true,
14987
- video: true,
14988
- wbr: true
14989
- };
14990
-
14991
15466
  function renderXJSLiteral(object, isLast, state, start, end) {
14992
15467
  var lines = object.value.split(/\r\n|\n|\r/);
14993
15468
 
@@ -15055,6 +15530,7 @@ function renderXJSLiteral(object, isLast, state, start, end) {
15055
15530
  function renderXJSExpressionContainer(traverse, object, isLast, path, state) {
15056
15531
  // Plus 1 to skip `{`.
15057
15532
  utils.move(object.range[0] + 1, state);
15533
+ utils.catchup(object.expression.range[0], state);
15058
15534
  traverse(object.expression, path, state);
15059
15535
 
15060
15536
  if (!isLast && object.expression.type !== Syntax.XJSEmptyExpression) {
@@ -15081,7 +15557,6 @@ function trimLeft(value) {
15081
15557
  return value.replace(/^[ ]+/, '');
15082
15558
  }
15083
15559
 
15084
- exports.knownTags = knownTags;
15085
15560
  exports.renderXJSExpressionContainer = renderXJSExpressionContainer;
15086
15561
  exports.renderXJSLiteral = renderXJSLiteral;
15087
15562
  exports.quoteAttrName = quoteAttrName;