react 0.13.0-beta.1 → 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 (181) hide show
  1. package/dist/JSXTransformer.js +637 -263
  2. package/dist/react-with-addons.js +1397 -1027
  3. package/dist/react-with-addons.min.js +6 -6
  4. package/dist/react.js +1322 -961
  5. package/dist/react.min.js +6 -6
  6. package/lib/AutoFocusMixin.js +1 -1
  7. package/lib/BeforeInputEventPlugin.js +1 -5
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +1 -1
  10. package/lib/CSSPropertyOperations.js +1 -1
  11. package/lib/CallbackQueue.js +1 -1
  12. package/lib/ChangeEventPlugin.js +1 -1
  13. package/lib/ClientReactRootIndex.js +1 -1
  14. package/lib/DOMChildrenOperations.js +4 -43
  15. package/lib/DOMProperty.js +1 -1
  16. package/lib/DOMPropertyOperations.js +7 -14
  17. package/lib/Danger.js +1 -1
  18. package/lib/DefaultEventPluginOrder.js +2 -2
  19. package/lib/EnterLeaveEventPlugin.js +1 -1
  20. package/lib/EventConstants.js +1 -1
  21. package/lib/EventListener.js +1 -1
  22. package/lib/EventPluginHub.js +1 -1
  23. package/lib/EventPluginRegistry.js +1 -1
  24. package/lib/EventPluginUtils.js +3 -3
  25. package/lib/EventPropagators.js +1 -1
  26. package/lib/ExecutionEnvironment.js +1 -1
  27. package/lib/FallbackCompositionState.js +1 -1
  28. package/lib/HTMLDOMPropertyConfig.js +12 -5
  29. package/lib/LinkedStateMixin.js +1 -1
  30. package/lib/LinkedValueUtils.js +1 -1
  31. package/lib/LocalEventTrapMixin.js +1 -1
  32. package/lib/MobileSafariClickEventPlugin.js +1 -1
  33. package/lib/Object.assign.js +1 -1
  34. package/lib/PooledClass.js +1 -1
  35. package/lib/React.js +4 -9
  36. package/lib/ReactBrowserComponentMixin.js +1 -1
  37. package/lib/ReactBrowserEventEmitter.js +2 -2
  38. package/lib/ReactCSSTransitionGroup.js +1 -1
  39. package/lib/ReactCSSTransitionGroupChild.js +8 -5
  40. package/lib/ReactChildReconciler.js +1 -1
  41. package/lib/ReactChildren.js +3 -2
  42. package/lib/ReactClass.js +25 -23
  43. package/lib/ReactComponent.js +33 -18
  44. package/lib/ReactComponentBrowserEnvironment.js +1 -1
  45. package/lib/ReactComponentEnvironment.js +1 -1
  46. package/lib/ReactComponentWithPureRenderMixin.js +1 -1
  47. package/lib/ReactCompositeComponent.js +73 -40
  48. package/lib/ReactContext.js +13 -3
  49. package/lib/ReactCurrentOwner.js +1 -1
  50. package/lib/ReactDOM.js +1 -1
  51. package/lib/ReactDOMButton.js +1 -1
  52. package/lib/ReactDOMComponent.js +19 -19
  53. package/lib/ReactDOMForm.js +1 -1
  54. package/lib/ReactDOMIDOperations.js +3 -3
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +1 -1
  57. package/lib/ReactDOMInput.js +1 -1
  58. package/lib/ReactDOMOption.js +1 -1
  59. package/lib/ReactDOMSelect.js +1 -1
  60. package/lib/ReactDOMSelection.js +1 -1
  61. package/lib/ReactDOMTextComponent.js +3 -5
  62. package/lib/ReactDOMTextarea.js +1 -1
  63. package/lib/ReactDefaultBatchingStrategy.js +1 -1
  64. package/lib/ReactDefaultInjection.js +25 -1
  65. package/lib/ReactDefaultPerf.js +1 -1
  66. package/lib/ReactDefaultPerfAnalysis.js +1 -1
  67. package/lib/ReactElement.js +1 -1
  68. package/lib/ReactElementValidator.js +22 -45
  69. package/lib/ReactEmptyComponent.js +5 -5
  70. package/lib/ReactErrorUtils.js +1 -1
  71. package/lib/ReactEventEmitterMixin.js +1 -1
  72. package/lib/ReactEventListener.js +1 -1
  73. package/lib/ReactFragment.js +172 -0
  74. package/lib/ReactInjection.js +1 -1
  75. package/lib/ReactInputSelection.js +1 -1
  76. package/lib/ReactInstanceHandles.js +1 -1
  77. package/lib/ReactInstanceMap.js +1 -1
  78. package/lib/ReactLifeCycle.js +1 -1
  79. package/lib/ReactLink.js +1 -1
  80. package/lib/ReactMarkupChecksum.js +1 -1
  81. package/lib/ReactMount.js +28 -6
  82. package/lib/ReactMultiChild.js +1 -1
  83. package/lib/ReactMultiChildUpdateTypes.js +1 -1
  84. package/lib/ReactNativeComponent.js +7 -20
  85. package/lib/ReactOwner.js +1 -1
  86. package/lib/ReactPerf.js +1 -1
  87. package/lib/ReactPropTransferer.js +1 -1
  88. package/lib/ReactPropTypeLocationNames.js +1 -1
  89. package/lib/ReactPropTypeLocations.js +1 -1
  90. package/lib/ReactPropTypes.js +3 -3
  91. package/lib/ReactPutListenerQueue.js +1 -1
  92. package/lib/ReactReconcileTransaction.js +1 -1
  93. package/lib/ReactReconciler.js +15 -1
  94. package/lib/ReactRef.js +1 -2
  95. package/lib/ReactRootIndex.js +1 -1
  96. package/lib/ReactServerRendering.js +1 -1
  97. package/lib/ReactServerRenderingTransaction.js +1 -1
  98. package/lib/ReactStateSetters.js +1 -1
  99. package/lib/ReactTestUtils.js +1 -1
  100. package/lib/ReactTransitionChildMapping.js +7 -3
  101. package/lib/ReactTransitionEvents.js +1 -1
  102. package/lib/ReactTransitionGroup.js +5 -5
  103. package/lib/ReactUpdateQueue.js +63 -32
  104. package/lib/ReactUpdates.js +7 -2
  105. package/lib/ReactWithAddons.js +3 -1
  106. package/lib/SVGDOMPropertyConfig.js +1 -1
  107. package/lib/SelectEventPlugin.js +1 -1
  108. package/lib/ServerReactRootIndex.js +1 -1
  109. package/lib/SimpleEventPlugin.js +3 -3
  110. package/lib/SyntheticClipboardEvent.js +1 -1
  111. package/lib/SyntheticCompositionEvent.js +1 -1
  112. package/lib/SyntheticDragEvent.js +1 -1
  113. package/lib/SyntheticEvent.js +1 -1
  114. package/lib/SyntheticFocusEvent.js +1 -1
  115. package/lib/SyntheticInputEvent.js +1 -1
  116. package/lib/SyntheticKeyboardEvent.js +1 -1
  117. package/lib/SyntheticMouseEvent.js +1 -1
  118. package/lib/SyntheticTouchEvent.js +1 -1
  119. package/lib/SyntheticUIEvent.js +1 -1
  120. package/lib/SyntheticWheelEvent.js +1 -1
  121. package/lib/Transaction.js +1 -1
  122. package/lib/ViewportMetrics.js +1 -1
  123. package/lib/accumulateInto.js +1 -1
  124. package/lib/adler32.js +1 -1
  125. package/lib/camelize.js +1 -1
  126. package/lib/camelizeStyleName.js +1 -1
  127. package/lib/cloneWithProps.js +1 -1
  128. package/lib/containsNode.js +1 -1
  129. package/lib/{createArrayFrom.js → createArrayFromMixed.js} +6 -6
  130. package/lib/createFullPageComponent.js +1 -1
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +1 -1
  133. package/lib/dangerousStyleValue.js +1 -1
  134. package/lib/emptyFunction.js +1 -1
  135. package/lib/emptyObject.js +1 -1
  136. package/lib/{escapeTextForBrowser.js → escapeTextContentForBrowser.js} +4 -5
  137. package/lib/findDOMNode.js +1 -1
  138. package/lib/flattenChildren.js +1 -1
  139. package/lib/focusNode.js +1 -1
  140. package/lib/forEachAccumulated.js +1 -1
  141. package/lib/getActiveElement.js +1 -1
  142. package/lib/getEventCharCode.js +1 -1
  143. package/lib/getEventKey.js +1 -1
  144. package/lib/getEventModifierState.js +1 -1
  145. package/lib/getEventTarget.js +1 -1
  146. package/lib/getIteratorFn.js +1 -1
  147. package/lib/getMarkupWrap.js +1 -1
  148. package/lib/getNodeForCharacterOffset.js +1 -1
  149. package/lib/getReactRootElementInContainer.js +1 -1
  150. package/lib/getTextContentAccessor.js +1 -1
  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 +5 -1
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +1 -1
  157. package/lib/isNode.js +1 -1
  158. package/lib/isTextInputElement.js +1 -1
  159. package/lib/isTextNode.js +1 -1
  160. package/lib/joinClasses.js +1 -1
  161. package/lib/keyMirror.js +1 -1
  162. package/lib/keyOf.js +1 -1
  163. package/lib/mapObject.js +1 -1
  164. package/lib/memoizeStringOnly.js +1 -1
  165. package/lib/onlyChild.js +1 -1
  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 +1 -1
  170. package/lib/setTextContent.js +40 -0
  171. package/lib/shallowEqual.js +1 -1
  172. package/lib/shouldUpdateReactComponent.js +32 -10
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +6 -4
  175. package/lib/update.js +1 -1
  176. package/lib/warning.js +9 -2
  177. package/package.json +1 -1
  178. package/lib/copyProperties.js +0 -56
  179. package/lib/merge.js +0 -34
  180. package/lib/mergeInto.js +0 -24
  181. package/lib/monitorCodeUse.js +0 -30
@@ -1,9 +1,9 @@
1
1
  /**
2
- * JSXTransformer v0.13.0-beta.1
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
@@ -2202,34 +2202,6 @@ process.chdir = function (dir) {
2202
2202
  process.umask = function() { return 0; };
2203
2203
 
2204
2204
  },{}],8:[function(_dereq_,module,exports){
2205
- var Base62 = (function (my) {
2206
- 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"]
2207
-
2208
- my.encode = function(i){
2209
- if (i === 0) {return '0'}
2210
- var s = ''
2211
- while (i > 0) {
2212
- s = this.chars[i % 62] + s
2213
- i = Math.floor(i/62)
2214
- }
2215
- return s
2216
- };
2217
- my.decode = function(a,b,c,d){
2218
- for (
2219
- b = c = (
2220
- a === (/\W|_|^$/.test(a += "") || a)
2221
- ) - 1;
2222
- d = a.charCodeAt(c++);
2223
- )
2224
- b = b * 62 + d - [, 48, 29, 87][d >> 5];
2225
- return b
2226
- };
2227
-
2228
- return my;
2229
- }({}));
2230
-
2231
- module.exports = Base62
2232
- },{}],9:[function(_dereq_,module,exports){
2233
2205
  /*
2234
2206
  Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
2235
2207
  Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
@@ -2264,6 +2236,7 @@ module.exports = Base62
2264
2236
 
2265
2237
  /*jslint bitwise:true plusplus:true */
2266
2238
  /*global esprima:true, define:true, exports:true, window: true,
2239
+ throwErrorTolerant: true,
2267
2240
  throwError: true, generateStatement: true, peek: true,
2268
2241
  parseAssignmentExpression: true, parseBlock: true,
2269
2242
  parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
@@ -2283,6 +2256,7 @@ parseFunctionTypeParam: true,
2283
2256
  parsePrimaryType: true,
2284
2257
  parseTypeAlias: true,
2285
2258
  parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
2259
+ parseTypeParameterDeclaration: true,
2286
2260
  parseYieldExpression: true, parseAwaitExpression: true
2287
2261
  */
2288
2262
 
@@ -2291,6 +2265,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2291
2265
 
2292
2266
  // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
2293
2267
  // Rhino, and plain browser loading.
2268
+
2269
+ /* istanbul ignore next */
2294
2270
  if (typeof define === 'function' && define.amd) {
2295
2271
  define(['exports'], factory);
2296
2272
  } else if (typeof exports !== 'undefined') {
@@ -2446,6 +2422,7 @@ parseYieldExpression: true, parseAwaitExpression: true
2446
2422
  TryStatement: 'TryStatement',
2447
2423
  TypeAlias: 'TypeAlias',
2448
2424
  TypeAnnotation: 'TypeAnnotation',
2425
+ TypeCastExpression: 'TypeCastExpression',
2449
2426
  TypeofTypeAnnotation: 'TypeofTypeAnnotation',
2450
2427
  TypeParameterDeclaration: 'TypeParameterDeclaration',
2451
2428
  TypeParameterInstantiation: 'TypeParameterInstantiation',
@@ -2531,6 +2508,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2531
2508
  MissingFromClause: 'Missing from clause',
2532
2509
  NoAsAfterImportNamespace: 'Missing as after import *',
2533
2510
  InvalidModuleSpecifier: 'Invalid module specifier',
2511
+ IllegalImportDeclaration: 'Illegal import declaration',
2512
+ IllegalExportDeclaration: 'Illegal export declaration',
2534
2513
  NoUnintializedConst: 'Const must be initialized',
2535
2514
  ComprehensionRequiresBlock: 'Comprehension must have at least one block',
2536
2515
  ComprehensionError: 'Comprehension Error',
@@ -2559,11 +2538,37 @@ parseYieldExpression: true, parseAwaitExpression: true
2559
2538
  // Do NOT use this to enforce a certain condition on any user input.
2560
2539
 
2561
2540
  function assert(condition, message) {
2541
+ /* istanbul ignore if */
2562
2542
  if (!condition) {
2563
2543
  throw new Error('ASSERT: ' + message);
2564
2544
  }
2565
2545
  }
2566
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
+
2567
2572
  function isDecimalDigit(ch) {
2568
2573
  return (ch >= 48 && ch <= 57); // 0..9
2569
2574
  }
@@ -2924,6 +2929,23 @@ parseYieldExpression: true, parseAwaitExpression: true
2924
2929
  ch3,
2925
2930
  ch4;
2926
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
+
2927
2949
  switch (code) {
2928
2950
  // Check for most common single-character punctuators.
2929
2951
  case 40: // ( open bracket
@@ -3226,6 +3248,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3226
3248
 
3227
3249
  if (index < length) {
3228
3250
  ch = source.charCodeAt(index);
3251
+ /* istanbul ignore else */
3229
3252
  if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
3230
3253
  throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
3231
3254
  }
@@ -3356,6 +3379,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3356
3379
  octal = true;
3357
3380
  }
3358
3381
 
3382
+ /* istanbul ignore else */
3359
3383
  if (index < length && isOctalDigit(source[index])) {
3360
3384
  octal = true;
3361
3385
  code = code * 8 + '01234567'.indexOf(source[index++]);
@@ -3472,6 +3496,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3472
3496
  octal = true;
3473
3497
  }
3474
3498
 
3499
+ /* istanbul ignore else */
3475
3500
  if (index < length && isOctalDigit(source[index])) {
3476
3501
  octal = true;
3477
3502
  code = code * 8 + '01234567'.indexOf(source[index++]);
@@ -3604,6 +3629,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3604
3629
  ++index;
3605
3630
  restore = index;
3606
3631
  ch = scanHexEscape('u');
3632
+ /* istanbul ignore else */
3607
3633
  if (ch) {
3608
3634
  flags += ch;
3609
3635
  for (str += '\\u'; restore < index; ++restore) {
@@ -3614,6 +3640,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3614
3640
  flags += 'u';
3615
3641
  str += '\\u';
3616
3642
  }
3643
+ throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
3617
3644
  } else {
3618
3645
  str += '\\';
3619
3646
  }
@@ -3626,11 +3653,20 @@ parseYieldExpression: true, parseAwaitExpression: true
3626
3653
  tmp = pattern;
3627
3654
  if (flags.indexOf('u') >= 0) {
3628
3655
  // Replace each astral symbol and every Unicode code point
3629
- // escape sequence that represents such a symbol with a single
3630
- // ASCII symbol to avoid throwing on regular expressions that
3631
- // 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.
3632
3663
  tmp = tmp
3633
- .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
+ })
3634
3670
  .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
3635
3671
  }
3636
3672
 
@@ -3650,8 +3686,6 @@ parseYieldExpression: true, parseAwaitExpression: true
3650
3686
  value = null;
3651
3687
  }
3652
3688
 
3653
- peek();
3654
-
3655
3689
  if (extra.tokenize) {
3656
3690
  return {
3657
3691
  type: Token.RegularExpression,
@@ -3843,6 +3877,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3843
3877
  var adv, pos, line, start, result;
3844
3878
 
3845
3879
  // If we are collecting the tokens, don't grab the next one yet.
3880
+ /* istanbul ignore next */
3846
3881
  adv = (typeof extra.advance === 'function') ? extra.advance : advance;
3847
3882
 
3848
3883
  pos = index;
@@ -3850,6 +3885,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3850
3885
  start = lineStart;
3851
3886
 
3852
3887
  // Scan for the next immediate token.
3888
+ /* istanbul ignore if */
3853
3889
  if (lookahead === null) {
3854
3890
  lookahead = adv();
3855
3891
  }
@@ -3895,6 +3931,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3895
3931
  last = bottomRight[bottomRight.length - 1];
3896
3932
 
3897
3933
  if (node.type === Syntax.Program) {
3934
+ /* istanbul ignore else */
3898
3935
  if (node.body.length > 0) {
3899
3936
  return;
3900
3937
  }
@@ -4164,6 +4201,14 @@ parseYieldExpression: true, parseAwaitExpression: true
4164
4201
  };
4165
4202
  },
4166
4203
 
4204
+ createTypeCast: function (expression, typeAnnotation) {
4205
+ return {
4206
+ type: Syntax.TypeCastExpression,
4207
+ expression: expression,
4208
+ typeAnnotation: typeAnnotation
4209
+ };
4210
+ },
4211
+
4167
4212
  createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
4168
4213
  return {
4169
4214
  type: Syntax.FunctionTypeAnnotation,
@@ -4695,13 +4740,14 @@ parseYieldExpression: true, parseAwaitExpression: true
4695
4740
  return arrowExpr;
4696
4741
  },
4697
4742
 
4698
- createMethodDefinition: function (propertyType, kind, key, value) {
4743
+ createMethodDefinition: function (propertyType, kind, key, value, computed) {
4699
4744
  return {
4700
4745
  type: Syntax.MethodDefinition,
4701
4746
  key: key,
4702
4747
  value: value,
4703
4748
  kind: kind,
4704
- 'static': propertyType === ClassPropertyType["static"]
4749
+ 'static': propertyType === ClassPropertyType["static"],
4750
+ computed: computed
4705
4751
  };
4706
4752
  },
4707
4753
 
@@ -4808,11 +4854,12 @@ parseYieldExpression: true, parseAwaitExpression: true
4808
4854
  };
4809
4855
  },
4810
4856
 
4811
- createImportDeclaration: function (specifiers, source) {
4857
+ createImportDeclaration: function (specifiers, source, isType) {
4812
4858
  return {
4813
4859
  type: Syntax.ImportDeclaration,
4814
4860
  specifiers: specifiers,
4815
- source: source
4861
+ source: source,
4862
+ isType: isType
4816
4863
  };
4817
4864
  },
4818
4865
 
@@ -5232,10 +5279,10 @@ parseYieldExpression: true, parseAwaitExpression: true
5232
5279
 
5233
5280
  function parseObjectProperty() {
5234
5281
  var token, key, id, value, param, expr, computed,
5235
- marker = markerCreate(), returnType;
5282
+ marker = markerCreate(), returnType, typeParameters;
5236
5283
 
5237
5284
  token = lookahead;
5238
- computed = (token.value === '[');
5285
+ computed = (token.value === '[' && token.type === Token.Punctuator);
5239
5286
 
5240
5287
  if (token.type === Token.Identifier || computed || matchAsync()) {
5241
5288
  id = parseObjectPropertyKey();
@@ -5256,7 +5303,10 @@ parseYieldExpression: true, parseAwaitExpression: true
5256
5303
  );
5257
5304
  }
5258
5305
 
5259
- if (match('(')) {
5306
+ if (match('(') || match('<')) {
5307
+ if (match('<')) {
5308
+ typeParameters = parseTypeParameterDeclaration();
5309
+ }
5260
5310
  return markerApply(
5261
5311
  marker,
5262
5312
  delegate.createProperty(
@@ -5264,7 +5314,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5264
5314
  id,
5265
5315
  parsePropertyMethodFunction({
5266
5316
  generator: false,
5267
- async: false
5317
+ async: false,
5318
+ typeParameters: typeParameters
5268
5319
  }),
5269
5320
  true,
5270
5321
  false,
@@ -5337,6 +5388,10 @@ parseYieldExpression: true, parseAwaitExpression: true
5337
5388
  computed = (lookahead.value === '[');
5338
5389
  key = parseObjectPropertyKey();
5339
5390
 
5391
+ if (match('<')) {
5392
+ typeParameters = parseTypeParameterDeclaration();
5393
+ }
5394
+
5340
5395
  return markerApply(
5341
5396
  marker,
5342
5397
  delegate.createProperty(
@@ -5344,7 +5399,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5344
5399
  key,
5345
5400
  parsePropertyMethodFunction({
5346
5401
  generator: false,
5347
- async: true
5402
+ async: true,
5403
+ typeParameters: typeParameters
5348
5404
  }),
5349
5405
  true,
5350
5406
  false,
@@ -5374,19 +5430,46 @@ parseYieldExpression: true, parseAwaitExpression: true
5374
5430
 
5375
5431
  id = parseObjectPropertyKey();
5376
5432
 
5433
+ if (match('<')) {
5434
+ typeParameters = parseTypeParameterDeclaration();
5435
+ }
5436
+
5377
5437
  if (!match('(')) {
5378
5438
  throwUnexpected(lex());
5379
5439
  }
5380
5440
 
5381
- 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
+ ));
5382
5452
  }
5383
5453
  key = parseObjectPropertyKey();
5384
5454
  if (match(':')) {
5385
5455
  lex();
5386
5456
  return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
5387
5457
  }
5388
- if (match('(')) {
5389
- 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
+ ));
5390
5473
  }
5391
5474
  throwUnexpected(lex());
5392
5475
  }
@@ -5397,9 +5480,17 @@ parseYieldExpression: true, parseAwaitExpression: true
5397
5480
  return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
5398
5481
  }
5399
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
+
5400
5491
  function parseObjectInitialiser() {
5401
- var properties = [], property, name, key, kind, map = {}, toString = String,
5402
- marker = markerCreate();
5492
+ var properties = [], property, name, kind, storedKind, map = new StringMap(),
5493
+ marker = markerCreate(), toString = String;
5403
5494
 
5404
5495
  expect('{');
5405
5496
 
@@ -5416,9 +5507,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5416
5507
  }
5417
5508
  kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
5418
5509
 
5419
- key = '$' + name;
5420
- if (Object.prototype.hasOwnProperty.call(map, key)) {
5421
- if (map[key] === PropertyKind.Data) {
5510
+ if (map.has(name)) {
5511
+ storedKind = map.get(name);
5512
+ if (storedKind === PropertyKind.Data) {
5422
5513
  if (strict && kind === PropertyKind.Data) {
5423
5514
  throwErrorTolerant({}, Messages.StrictDuplicateProperty);
5424
5515
  } else if (kind !== PropertyKind.Data) {
@@ -5427,13 +5518,13 @@ parseYieldExpression: true, parseAwaitExpression: true
5427
5518
  } else {
5428
5519
  if (kind === PropertyKind.Data) {
5429
5520
  throwErrorTolerant({}, Messages.AccessorDataProperty);
5430
- } else if (map[key] & kind) {
5521
+ } else if (storedKind & kind) {
5431
5522
  throwErrorTolerant({}, Messages.AccessorGetSet);
5432
5523
  }
5433
5524
  }
5434
- map[key] |= kind;
5525
+ map.set(name, storedKind | kind);
5435
5526
  } else {
5436
- map[key] = kind;
5527
+ map.set(name, kind);
5437
5528
  }
5438
5529
  }
5439
5530
 
@@ -5477,14 +5568,24 @@ parseYieldExpression: true, parseAwaitExpression: true
5477
5568
  // 11.1.6 The Grouping Operator
5478
5569
 
5479
5570
  function parseGroupExpression() {
5480
- var expr;
5571
+ var expr, marker, typeAnnotation;
5481
5572
 
5482
5573
  expect('(');
5483
5574
 
5484
5575
  ++state.parenthesizedCount;
5485
5576
 
5577
+ marker = markerCreate();
5578
+
5486
5579
  expr = parseExpression();
5487
5580
 
5581
+ if (match(':')) {
5582
+ typeAnnotation = parseTypeAnnotation();
5583
+ expr = markerApply(marker, delegate.createTypeCast(
5584
+ expr,
5585
+ typeAnnotation
5586
+ ));
5587
+ }
5588
+
5488
5589
  expect(')');
5489
5590
 
5490
5591
  return expr;
@@ -5573,7 +5674,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5573
5674
 
5574
5675
  if (match('/') || match('/=')) {
5575
5676
  marker = markerCreate();
5576
- return markerApply(marker, delegate.createLiteral(scanRegExp()));
5677
+ expr = delegate.createLiteral(scanRegExp());
5678
+ peek();
5679
+ return markerApply(marker, expr);
5577
5680
  }
5578
5681
 
5579
5682
  if (type === Token.Template) {
@@ -5941,6 +6044,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5941
6044
 
5942
6045
  // 11.13 Assignment Operators
5943
6046
 
6047
+ // 12.14.5 AssignmentPattern
6048
+
5944
6049
  function reinterpretAsAssignmentBindingPattern(expr) {
5945
6050
  var i, len, property, element;
5946
6051
 
@@ -5964,6 +6069,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5964
6069
  expr.type = Syntax.ArrayPattern;
5965
6070
  for (i = 0, len = expr.elements.length; i < len; i += 1) {
5966
6071
  element = expr.elements[i];
6072
+ /* istanbul ignore else */
5967
6073
  if (element) {
5968
6074
  reinterpretAsAssignmentBindingPattern(element);
5969
6075
  }
@@ -5978,12 +6084,14 @@ parseYieldExpression: true, parseAwaitExpression: true
5978
6084
  throwError({}, Messages.ObjectPatternAsSpread);
5979
6085
  }
5980
6086
  } else {
6087
+ /* istanbul ignore else */
5981
6088
  if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
5982
6089
  throwError({}, Messages.InvalidLHSInAssignment);
5983
6090
  }
5984
6091
  }
5985
6092
  }
5986
6093
 
6094
+ // 13.2.3 BindingPattern
5987
6095
 
5988
6096
  function reinterpretAsDestructuredParameter(options, expr) {
5989
6097
  var i, len, property, element;
@@ -6014,10 +6122,14 @@ parseYieldExpression: true, parseAwaitExpression: true
6014
6122
  }
6015
6123
  } else if (expr.type === Syntax.Identifier) {
6016
6124
  validateParam(options, expr, expr.name);
6017
- } else {
6018
- if (expr.type !== Syntax.MemberExpression) {
6125
+ } else if (expr.type === Syntax.SpreadElement) {
6126
+ // BindingRestElement only allows BindingIdentifier
6127
+ if (expr.argument.type !== Syntax.Identifier) {
6019
6128
  throwError({}, Messages.InvalidLHSInFormalsList);
6020
6129
  }
6130
+ validateParam(options, expr.argument, expr.argument.name);
6131
+ } else {
6132
+ throwError({}, Messages.InvalidLHSInFormalsList);
6021
6133
  }
6022
6134
  }
6023
6135
 
@@ -6029,7 +6141,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6029
6141
  defaultCount = 0;
6030
6142
  rest = null;
6031
6143
  options = {
6032
- paramSet: {}
6144
+ paramSet: new StringMap()
6033
6145
  };
6034
6146
 
6035
6147
  for (i = 0, len = expressions.length; i < len; i += 1) {
@@ -6044,6 +6156,9 @@ parseYieldExpression: true, parseAwaitExpression: true
6044
6156
  defaults.push(null);
6045
6157
  } else if (param.type === Syntax.SpreadElement) {
6046
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
+ }
6047
6162
  reinterpretAsDestructuredParameter(options, param.argument);
6048
6163
  rest = param.argument;
6049
6164
  } else if (param.type === Syntax.AssignmentExpression) {
@@ -6112,7 +6227,8 @@ parseYieldExpression: true, parseAwaitExpression: true
6112
6227
 
6113
6228
  function parseAssignmentExpression() {
6114
6229
  var marker, expr, token, params, oldParenthesizedCount,
6115
- backtrackToken = lookahead, possiblyAsync = false;
6230
+ startsWithParen = false, backtrackToken = lookahead,
6231
+ possiblyAsync = false;
6116
6232
 
6117
6233
  if (matchYield()) {
6118
6234
  return parseYieldExpression();
@@ -6149,6 +6265,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6149
6265
  params.async = possiblyAsync;
6150
6266
  return parseArrowFunctionExpression(params, marker);
6151
6267
  }
6268
+ startsWithParen = true;
6152
6269
  }
6153
6270
 
6154
6271
  token = lookahead;
@@ -6168,6 +6285,13 @@ parseYieldExpression: true, parseAwaitExpression: true
6168
6285
  state.parenthesizedCount === (oldParenthesizedCount + 1))) {
6169
6286
  if (expr.type === Syntax.Identifier) {
6170
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 ]);
6171
6295
  } else if (expr.type === Syntax.SequenceExpression) {
6172
6296
  params = reinterpretAsCoverFormalsList(expr.expressions);
6173
6297
  }
@@ -6238,18 +6362,6 @@ parseYieldExpression: true, parseAwaitExpression: true
6238
6362
  sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
6239
6363
  }
6240
6364
 
6241
- if (match('=>')) {
6242
- // Do not allow nested parentheses on the LHS of the =>.
6243
- if (state.parenthesizedCount === oldParenthesizedCount || state.parenthesizedCount === (oldParenthesizedCount + 1)) {
6244
- expr = expr.type === Syntax.SequenceExpression ? expr.expressions : expressions;
6245
- coverFormalsList = reinterpretAsCoverFormalsList(expr);
6246
- if (coverFormalsList) {
6247
- return parseArrowFunctionExpression(coverFormalsList, marker);
6248
- }
6249
- }
6250
- throwUnexpected(lex());
6251
- }
6252
-
6253
6365
  if (spreadFound && lookahead2().value !== '=>') {
6254
6366
  throwError({}, Messages.IllegalSpread);
6255
6367
  }
@@ -6401,13 +6513,18 @@ parseYieldExpression: true, parseAwaitExpression: true
6401
6513
  function parseObjectType(allowStatic) {
6402
6514
  var callProperties = [], indexers = [], marker, optional = false,
6403
6515
  properties = [], property, propertyKey, propertyTypeAnnotation,
6404
- token, isStatic;
6516
+ token, isStatic, matchStatic;
6405
6517
 
6406
6518
  expect('{');
6407
6519
 
6408
6520
  while (!match('}')) {
6409
6521
  marker = markerCreate();
6410
- if (allowStatic && matchContextualKeyword('static')) {
6522
+ matchStatic =
6523
+ strict
6524
+ ? matchKeyword('static')
6525
+ : matchContextualKeyword('static');
6526
+
6527
+ if (allowStatic && matchStatic) {
6411
6528
  token = lex();
6412
6529
  isStatic = true;
6413
6530
  }
@@ -6787,6 +6904,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6787
6904
  markerApply(typeAnnotationMarker, id);
6788
6905
  }
6789
6906
  } else {
6907
+ /* istanbul ignore next */
6790
6908
  id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
6791
6909
  // 12.2.1
6792
6910
  if (strict && isRestrictedWord(id.name)) {
@@ -6941,10 +7059,11 @@ parseYieldExpression: true, parseAwaitExpression: true
6941
7059
  }
6942
7060
 
6943
7061
  // non-default export
6944
- if (lookahead.type === Token.Keyword) {
7062
+ if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
6945
7063
  // covers:
6946
7064
  // export var f = 1;
6947
7065
  switch (lookahead.value) {
7066
+ case 'type':
6948
7067
  case 'let':
6949
7068
  case 'const':
6950
7069
  case 'var':
@@ -6971,10 +7090,12 @@ parseYieldExpression: true, parseAwaitExpression: true
6971
7090
  }
6972
7091
 
6973
7092
  expect('{');
6974
- do {
6975
- isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
6976
- specifiers.push(parseExportSpecifier());
6977
- } while (match(',') && lex());
7093
+ if (!match('}')) {
7094
+ do {
7095
+ isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
7096
+ specifiers.push(parseExportSpecifier());
7097
+ } while (match(',') && lex());
7098
+ }
6978
7099
  expect('}');
6979
7100
 
6980
7101
  if (matchContextualKeyword('from')) {
@@ -7015,9 +7136,11 @@ parseYieldExpression: true, parseAwaitExpression: true
7015
7136
  var specifiers = [];
7016
7137
  // {foo, bar as bas}
7017
7138
  expect('{');
7018
- do {
7019
- specifiers.push(parseImportSpecifier());
7020
- } while (match(',') && lex());
7139
+ if (!match('}')) {
7140
+ do {
7141
+ specifiers.push(parseImportSpecifier());
7142
+ } while (match(',') && lex());
7143
+ }
7021
7144
  expect('}');
7022
7145
  return specifiers;
7023
7146
  }
@@ -7046,9 +7169,20 @@ parseYieldExpression: true, parseAwaitExpression: true
7046
7169
  }
7047
7170
 
7048
7171
  function parseImportDeclaration() {
7049
- var specifiers, src, marker = markerCreate();
7172
+ var specifiers, src, marker = markerCreate(), isType = false, token2;
7050
7173
 
7051
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
+
7052
7186
  specifiers = [];
7053
7187
 
7054
7188
  if (lookahead.type === Token.StringLiteral) {
@@ -7056,7 +7190,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7056
7190
  // import "foo";
7057
7191
  src = parseModuleSpecifier();
7058
7192
  consumeSemicolon();
7059
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
7193
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
7060
7194
  }
7061
7195
 
7062
7196
  if (!matchKeyword('default') && isIdentifierName(lookahead)) {
@@ -7088,7 +7222,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7088
7222
  src = parseModuleSpecifier();
7089
7223
  consumeSemicolon();
7090
7224
 
7091
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
7225
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
7092
7226
  }
7093
7227
 
7094
7228
  // 12.3 Empty Statement
@@ -7285,7 +7419,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7285
7419
  // 12.7 The continue statement
7286
7420
 
7287
7421
  function parseContinueStatement() {
7288
- var label = null, key, marker = markerCreate();
7422
+ var label = null, marker = markerCreate();
7289
7423
 
7290
7424
  expectKeyword('continue');
7291
7425
 
@@ -7311,8 +7445,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7311
7445
  if (lookahead.type === Token.Identifier) {
7312
7446
  label = parseVariableIdentifier();
7313
7447
 
7314
- key = '$' + label.name;
7315
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7448
+ if (!state.labelSet.has(label.name)) {
7316
7449
  throwError({}, Messages.UnknownLabel, label.name);
7317
7450
  }
7318
7451
  }
@@ -7329,7 +7462,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7329
7462
  // 12.8 The break statement
7330
7463
 
7331
7464
  function parseBreakStatement() {
7332
- var label = null, key, marker = markerCreate();
7465
+ var label = null, marker = markerCreate();
7333
7466
 
7334
7467
  expectKeyword('break');
7335
7468
 
@@ -7355,8 +7488,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7355
7488
  if (lookahead.type === Token.Identifier) {
7356
7489
  label = parseVariableIdentifier();
7357
7490
 
7358
- key = '$' + label.name;
7359
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7491
+ if (!state.labelSet.has(label.name)) {
7360
7492
  throwError({}, Messages.UnknownLabel, label.name);
7361
7493
  }
7362
7494
  }
@@ -7584,8 +7716,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7584
7716
  var type = lookahead.type,
7585
7717
  marker,
7586
7718
  expr,
7587
- labeledBody,
7588
- key;
7719
+ labeledBody;
7589
7720
 
7590
7721
  if (type === Token.EOF) {
7591
7722
  throwUnexpected(lookahead);
@@ -7652,14 +7783,13 @@ parseYieldExpression: true, parseAwaitExpression: true
7652
7783
  if ((expr.type === Syntax.Identifier) && match(':')) {
7653
7784
  lex();
7654
7785
 
7655
- key = '$' + expr.name;
7656
- if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7786
+ if (state.labelSet.has(expr.name)) {
7657
7787
  throwError({}, Messages.Redeclaration, 'Label', expr.name);
7658
7788
  }
7659
7789
 
7660
- state.labelSet[key] = true;
7790
+ state.labelSet.set(expr.name, true);
7661
7791
  labeledBody = parseStatement();
7662
- delete state.labelSet[key];
7792
+ state.labelSet['delete'](expr.name);
7663
7793
  return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
7664
7794
  }
7665
7795
 
@@ -7715,7 +7845,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7715
7845
  oldInFunctionBody = state.inFunctionBody;
7716
7846
  oldParenthesizedCount = state.parenthesizedCount;
7717
7847
 
7718
- state.labelSet = {};
7848
+ state.labelSet = new StringMap();
7719
7849
  state.inIteration = false;
7720
7850
  state.inSwitch = false;
7721
7851
  state.inFunctionBody = true;
@@ -7744,13 +7874,12 @@ parseYieldExpression: true, parseAwaitExpression: true
7744
7874
  }
7745
7875
 
7746
7876
  function validateParam(options, param, name) {
7747
- var key = '$' + name;
7748
7877
  if (strict) {
7749
7878
  if (isRestrictedWord(name)) {
7750
7879
  options.stricted = param;
7751
7880
  options.message = Messages.StrictParamName;
7752
7881
  }
7753
- if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
7882
+ if (options.paramSet.has(name)) {
7754
7883
  options.stricted = param;
7755
7884
  options.message = Messages.StrictParamDupe;
7756
7885
  }
@@ -7761,12 +7890,12 @@ parseYieldExpression: true, parseAwaitExpression: true
7761
7890
  } else if (isStrictModeReservedWord(name)) {
7762
7891
  options.firstRestricted = param;
7763
7892
  options.message = Messages.StrictReservedWord;
7764
- } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
7893
+ } else if (options.paramSet.has(name)) {
7765
7894
  options.firstRestricted = param;
7766
7895
  options.message = Messages.StrictParamDupe;
7767
7896
  }
7768
7897
  }
7769
- options.paramSet[key] = true;
7898
+ options.paramSet.set(name, true);
7770
7899
  }
7771
7900
 
7772
7901
  function parseParam(options) {
@@ -7848,7 +7977,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7848
7977
  expect('(');
7849
7978
 
7850
7979
  if (!match(')')) {
7851
- options.paramSet = {};
7980
+ options.paramSet = new StringMap();
7852
7981
  while (index < length) {
7853
7982
  if (!parseParam(options)) {
7854
7983
  break;
@@ -8063,19 +8192,60 @@ parseYieldExpression: true, parseAwaitExpression: true
8063
8192
 
8064
8193
  // 14 Classes
8065
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
+
8066
8233
  function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
8067
8234
  var token, param, propType, isValidDuplicateProp = false,
8068
8235
  isAsync, typeParameters, tokenValue, returnType,
8069
- annotationMarker;
8236
+ annotationMarker, propMap;
8070
8237
 
8071
8238
  propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
8072
8239
 
8240
+ propMap = existingPropNames[propType];
8241
+
8073
8242
  if (generator) {
8074
8243
  return delegate.createMethodDefinition(
8075
8244
  propType,
8076
8245
  '',
8077
8246
  key,
8078
- parsePropertyMethodFunction({ generator: true })
8247
+ parsePropertyMethodFunction({ generator: true }),
8248
+ computed
8079
8249
  );
8080
8250
  }
8081
8251
 
@@ -8086,21 +8256,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8086
8256
 
8087
8257
  // It is a syntax error if any other properties have a name
8088
8258
  // duplicating this one unless they are a setter
8089
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
8090
- isValidDuplicateProp =
8091
- // There isn't already a getter for this prop
8092
- existingPropNames[propType][key.name].get === undefined
8093
- // There isn't already a data prop by this name
8094
- && existingPropNames[propType][key.name].data === undefined
8095
- // The only existing prop by this name is a setter
8096
- && existingPropNames[propType][key.name].set !== undefined;
8097
- if (!isValidDuplicateProp) {
8098
- throwError(key, Messages.IllegalDuplicateClassProperty);
8099
- }
8100
- } else {
8101
- existingPropNames[propType][key.name] = {};
8259
+ if (!computed) {
8260
+ validateDuplicateProp(propMap, key, 'get');
8102
8261
  }
8103
- existingPropNames[propType][key.name].get = true;
8104
8262
 
8105
8263
  expect('(');
8106
8264
  expect(')');
@@ -8111,7 +8269,8 @@ parseYieldExpression: true, parseAwaitExpression: true
8111
8269
  propType,
8112
8270
  'get',
8113
8271
  key,
8114
- parsePropertyFunction({ generator: false, returnType: returnType })
8272
+ parsePropertyFunction({ generator: false, returnType: returnType }),
8273
+ computed
8115
8274
  );
8116
8275
  }
8117
8276
  if (tokenValue === 'set' && !match('(')) {
@@ -8119,21 +8278,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8119
8278
 
8120
8279
  // It is a syntax error if any other properties have a name
8121
8280
  // duplicating this one unless they are a getter
8122
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
8123
- isValidDuplicateProp =
8124
- // There isn't already a setter for this prop
8125
- existingPropNames[propType][key.name].set === undefined
8126
- // There isn't already a data prop by this name
8127
- && existingPropNames[propType][key.name].data === undefined
8128
- // The only existing prop by this name is a getter
8129
- && existingPropNames[propType][key.name].get !== undefined;
8130
- if (!isValidDuplicateProp) {
8131
- throwError(key, Messages.IllegalDuplicateClassProperty);
8132
- }
8133
- } else {
8134
- existingPropNames[propType][key.name] = {};
8281
+ if (!computed) {
8282
+ validateDuplicateProp(propMap, key, 'set');
8135
8283
  }
8136
- existingPropNames[propType][key.name].set = true;
8137
8284
 
8138
8285
  expect('(');
8139
8286
  token = lookahead;
@@ -8151,7 +8298,8 @@ parseYieldExpression: true, parseAwaitExpression: true
8151
8298
  generator: false,
8152
8299
  name: token,
8153
8300
  returnType: returnType
8154
- })
8301
+ }),
8302
+ computed
8155
8303
  );
8156
8304
  }
8157
8305
 
@@ -8166,12 +8314,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8166
8314
 
8167
8315
  // It is a syntax error if any other properties have the same name as a
8168
8316
  // non-getter, non-setter method
8169
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
8170
- throwError(key, Messages.IllegalDuplicateClassProperty);
8171
- } else {
8172
- existingPropNames[propType][key.name] = {};
8317
+ if (!computed) {
8318
+ validateDuplicateProp(propMap, key, 'data');
8173
8319
  }
8174
- existingPropNames[propType][key.name].data = true;
8175
8320
 
8176
8321
  return delegate.createMethodDefinition(
8177
8322
  propType,
@@ -8181,7 +8326,8 @@ parseYieldExpression: true, parseAwaitExpression: true
8181
8326
  generator: false,
8182
8327
  async: isAsync,
8183
8328
  typeParameters: typeParameters
8184
- })
8329
+ }),
8330
+ computed
8185
8331
  );
8186
8332
  }
8187
8333
 
@@ -8200,8 +8346,8 @@ parseYieldExpression: true, parseAwaitExpression: true
8200
8346
  }
8201
8347
 
8202
8348
  function parseClassElement(existingProps) {
8203
- var computed, generator = false, key, marker = markerCreate(),
8204
- isStatic = false;
8349
+ var computed = false, generator = false, key, marker = markerCreate(),
8350
+ isStatic = false, possiblyOpenBracketToken;
8205
8351
  if (match(';')) {
8206
8352
  lex();
8207
8353
  return;
@@ -8217,7 +8363,16 @@ parseYieldExpression: true, parseAwaitExpression: true
8217
8363
  generator = true;
8218
8364
  }
8219
8365
 
8220
- 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
+
8221
8376
  key = parseObjectPropertyKey();
8222
8377
 
8223
8378
  if (!generator && lookahead.value === ':') {
@@ -8236,8 +8391,8 @@ parseYieldExpression: true, parseAwaitExpression: true
8236
8391
  function parseClassBody() {
8237
8392
  var classElement, classElements = [], existingProps = {}, marker = markerCreate();
8238
8393
 
8239
- existingProps[ClassPropertyType["static"]] = {};
8240
- existingProps[ClassPropertyType.prototype] = {};
8394
+ existingProps[ClassPropertyType["static"]] = new StringMap();
8395
+ existingProps[ClassPropertyType.prototype] = new StringMap();
8241
8396
 
8242
8397
  expect('{');
8243
8398
 
@@ -8259,7 +8414,11 @@ parseYieldExpression: true, parseAwaitExpression: true
8259
8414
 
8260
8415
  function parseClassImplements() {
8261
8416
  var id, implemented = [], marker, typeParameters;
8262
- expectContextualKeyword('implements');
8417
+ if (strict) {
8418
+ expectKeyword('implements');
8419
+ } else {
8420
+ expectContextualKeyword('implements');
8421
+ }
8263
8422
  while (index < length) {
8264
8423
  marker = markerCreate();
8265
8424
  id = parseVariableIdentifier();
@@ -8282,11 +8441,17 @@ parseYieldExpression: true, parseAwaitExpression: true
8282
8441
 
8283
8442
  function parseClassExpression() {
8284
8443
  var id, implemented, previousYieldAllowed, superClass = null,
8285
- superTypeParameters, marker = markerCreate(), typeParameters;
8444
+ superTypeParameters, marker = markerCreate(), typeParameters,
8445
+ matchImplements;
8286
8446
 
8287
8447
  expectKeyword('class');
8288
8448
 
8289
- if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
8449
+ matchImplements =
8450
+ strict
8451
+ ? matchKeyword('implements')
8452
+ : matchContextualKeyword('implements');
8453
+
8454
+ if (!matchKeyword('extends') && !matchImplements && !match('{')) {
8290
8455
  id = parseVariableIdentifier();
8291
8456
  }
8292
8457
 
@@ -8305,7 +8470,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8305
8470
  state.yieldAllowed = previousYieldAllowed;
8306
8471
  }
8307
8472
 
8308
- if (matchContextualKeyword('implements')) {
8473
+ if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
8309
8474
  implemented = parseClassImplements();
8310
8475
  }
8311
8476
 
@@ -8342,7 +8507,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8342
8507
  state.yieldAllowed = previousYieldAllowed;
8343
8508
  }
8344
8509
 
8345
- if (matchContextualKeyword('implements')) {
8510
+ if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
8346
8511
  implemented = parseClassImplements();
8347
8512
  }
8348
8513
 
@@ -8367,6 +8532,17 @@ parseYieldExpression: true, parseAwaitExpression: true
8367
8532
  return parseConstLetDeclaration(lookahead.value);
8368
8533
  case 'function':
8369
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();
8370
8546
  default:
8371
8547
  return parseStatement();
8372
8548
  }
@@ -8405,7 +8581,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8405
8581
  }
8406
8582
 
8407
8583
  function parseProgramElement() {
8408
- if (lookahead.type === Token.Keyword) {
8584
+ var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule';
8585
+
8586
+ if (isModule && lookahead.type === Token.Keyword) {
8409
8587
  switch (lookahead.value) {
8410
8588
  case 'export':
8411
8589
  return parseExportDeclaration();
@@ -8457,7 +8635,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8457
8635
 
8458
8636
  function parseProgram() {
8459
8637
  var body, marker = markerCreate();
8460
- strict = false;
8638
+ strict = extra.sourceType === 'module';
8461
8639
  peek();
8462
8640
  body = parseProgramElements();
8463
8641
  return markerApply(marker, delegate.createProgram(body));
@@ -8885,12 +9063,15 @@ parseYieldExpression: true, parseAwaitExpression: true
8885
9063
  if (object.type === Syntax.XJSNamespacedName) {
8886
9064
  return object.namespace.name + ':' + object.name.name;
8887
9065
  }
9066
+ /* istanbul ignore else */
8888
9067
  if (object.type === Syntax.XJSMemberExpression) {
8889
9068
  return (
8890
9069
  getQualifiedXJSName(object.object) + '.' +
8891
9070
  getQualifiedXJSName(object.property)
8892
9071
  );
8893
9072
  }
9073
+ /* istanbul ignore next */
9074
+ throwUnexpected(object);
8894
9075
  }
8895
9076
 
8896
9077
  function isXJSIdentifierStart(ch) {
@@ -8951,6 +9132,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8951
9132
  if (!isNaN(code)) {
8952
9133
  return String.fromCharCode(code);
8953
9134
  }
9135
+ /* istanbul ignore else */
8954
9136
  } else if (XHTMLEntities[str]) {
8955
9137
  return XHTMLEntities[str];
8956
9138
  }
@@ -9024,9 +9206,9 @@ parseYieldExpression: true, parseAwaitExpression: true
9024
9206
  function advanceXJSChild() {
9025
9207
  var ch = source.charCodeAt(index);
9026
9208
 
9027
- // { (123) and < (60)
9028
- if (ch !== 123 && ch !== 60) {
9029
- return scanXJSText(['<', '{']);
9209
+ // '<' 60, '>' 62, '{' 123, '}' 125
9210
+ if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
9211
+ return scanXJSText(['<', '>', '{', '}']);
9030
9212
  }
9031
9213
 
9032
9214
  return scanPunctuator();
@@ -9186,8 +9368,10 @@ parseYieldExpression: true, parseAwaitExpression: true
9186
9368
  } else if (lookahead.type === Token.XJSText) {
9187
9369
  marker = markerCreatePreserveWhitespace();
9188
9370
  token = markerApply(marker, delegate.createLiteral(lex()));
9189
- } else {
9371
+ } else if (match('<')) {
9190
9372
  token = parseXJSElement();
9373
+ } else {
9374
+ throwUnexpected(lookahead);
9191
9375
  }
9192
9376
  return token;
9193
9377
  }
@@ -9346,9 +9530,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9346
9530
 
9347
9531
  function parseInterface() {
9348
9532
  var body, bodyMarker, extended = [], id, marker = markerCreate(),
9349
- typeParameters = null;
9533
+ typeParameters = null, previousStrict;
9534
+
9535
+ if (strict) {
9536
+ expectKeyword('interface');
9537
+ } else {
9538
+ expectContextualKeyword('interface');
9539
+ }
9350
9540
 
9351
- expectContextualKeyword('interface');
9352
9541
  return parseInterfaceish(marker, /* allowStatic */false);
9353
9542
  }
9354
9543
 
@@ -9461,6 +9650,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9461
9650
  function collectToken() {
9462
9651
  var start, loc, token, range, value, entry;
9463
9652
 
9653
+ /* istanbul ignore else */
9464
9654
  if (!state.inXJSChild) {
9465
9655
  skipComment();
9466
9656
  }
@@ -9520,6 +9710,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9520
9710
  };
9521
9711
 
9522
9712
  if (!extra.tokenize) {
9713
+ /* istanbul ignore next */
9523
9714
  // Pop the previous token, which is likely '/' or '/='
9524
9715
  if (extra.tokens.length > 0) {
9525
9716
  token = extra.tokens[extra.tokens.length - 1];
@@ -9601,12 +9792,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9601
9792
  var entry, result = {};
9602
9793
 
9603
9794
  for (entry in object) {
9795
+ /* istanbul ignore else */
9604
9796
  if (object.hasOwnProperty(entry)) {
9605
9797
  result[entry] = object[entry];
9606
9798
  }
9607
9799
  }
9608
9800
 
9609
9801
  for (entry in properties) {
9802
+ /* istanbul ignore else */
9610
9803
  if (properties.hasOwnProperty(entry)) {
9611
9804
  result[entry] = properties[entry];
9612
9805
  }
@@ -9635,7 +9828,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9635
9828
  state = {
9636
9829
  allowKeyword: true,
9637
9830
  allowIn: true,
9638
- labelSet: {},
9831
+ labelSet: new StringMap(),
9639
9832
  inFunctionBody: false,
9640
9833
  inIteration: false,
9641
9834
  inSwitch: false,
@@ -9665,17 +9858,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9665
9858
  extra.errors = [];
9666
9859
  }
9667
9860
 
9668
- if (length > 0) {
9669
- if (typeof source[0] === 'undefined') {
9670
- // Try first to convert to a string. This is good as fast path
9671
- // for old IE which understands string indexing for string
9672
- // literals only and not for string object.
9673
- if (code instanceof String) {
9674
- source = code.valueOf();
9675
- }
9676
- }
9677
- }
9678
-
9679
9861
  patch();
9680
9862
 
9681
9863
  try {
@@ -9736,7 +9918,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9736
9918
  state = {
9737
9919
  allowKeyword: false,
9738
9920
  allowIn: true,
9739
- labelSet: {},
9921
+ labelSet: new StringMap(),
9740
9922
  parenthesizedCount: 0,
9741
9923
  inFunctionBody: false,
9742
9924
  inIteration: false,
@@ -9764,6 +9946,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9764
9946
  });
9765
9947
  }
9766
9948
 
9949
+ extra.sourceType = options.sourceType;
9767
9950
  if (typeof options.tokens === 'boolean' && options.tokens) {
9768
9951
  extra.tokens = [];
9769
9952
  }
@@ -9782,17 +9965,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9782
9965
  }
9783
9966
  }
9784
9967
 
9785
- if (length > 0) {
9786
- if (typeof source[0] === 'undefined') {
9787
- // Try first to convert to a string. This is good as fast path
9788
- // for old IE which understands string indexing for string
9789
- // literals only and not for string object.
9790
- if (code instanceof String) {
9791
- source = code.valueOf();
9792
- }
9793
- }
9794
- }
9795
-
9796
9968
  patch();
9797
9969
  try {
9798
9970
  program = parseProgram();
@@ -9817,13 +9989,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9817
9989
  }
9818
9990
 
9819
9991
  // Sync with *.json manifests.
9820
- exports.version = '8001.1001.0-dev-harmony-fb';
9992
+ exports.version = '12001.1.0-dev-harmony-fb';
9821
9993
 
9822
9994
  exports.tokenize = tokenize;
9823
9995
 
9824
9996
  exports.parse = parse;
9825
9997
 
9826
9998
  // Deep copy.
9999
+ /* istanbul ignore next */
9827
10000
  exports.Syntax = (function () {
9828
10001
  var name, types = {};
9829
10002
 
@@ -9847,6 +10020,34 @@ parseYieldExpression: true, parseAwaitExpression: true
9847
10020
  }));
9848
10021
  /* vim: set sw=4 ts=4 et tw=80 : */
9849
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
9850
10051
  },{}],10:[function(_dereq_,module,exports){
9851
10052
  /*
9852
10053
  * Copyright 2009-2011 Mozilla Foundation and contributors
@@ -12105,7 +12306,12 @@ function _nodeIsClosureScopeBoundary(node, parentNode) {
12105
12306
  || parentNode.type === Syntax.FunctionExpression
12106
12307
  || parentNode.type === Syntax.ArrowFunctionExpression;
12107
12308
 
12108
- 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);
12109
12315
  }
12110
12316
 
12111
12317
  function _nodeIsBlockScopeBoundary(node, parentNode) {
@@ -12123,29 +12329,38 @@ function _nodeIsBlockScopeBoundary(node, parentNode) {
12123
12329
  * @param {object} state
12124
12330
  */
12125
12331
  function traverse(node, path, state) {
12332
+ /*jshint -W004*/
12126
12333
  // Create a scope stack entry if this is the first node we've encountered in
12127
12334
  // its local scope
12335
+ var startIndex = null;
12128
12336
  var parentNode = path[0];
12129
12337
  if (!Array.isArray(node) && state.localScope.parentNode !== parentNode) {
12130
12338
  if (_nodeIsClosureScopeBoundary(node, parentNode)) {
12131
- var scopeIsStrict =
12132
- state.scopeIsStrict
12133
- || node.body.length > 0
12134
- && node.body[0].type === Syntax.ExpressionStatement
12135
- && node.body[0].expression.type === Syntax.Literal
12136
- && 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
+ }
12137
12349
 
12138
12350
  if (node.type === Syntax.Program) {
12351
+ startIndex = state.g.buffer.length;
12139
12352
  state = utils.updateState(state, {
12140
12353
  scopeIsStrict: scopeIsStrict
12141
12354
  });
12142
12355
  } else {
12356
+ startIndex = state.g.buffer.length + 1;
12143
12357
  state = utils.updateState(state, {
12144
12358
  localScope: {
12145
12359
  parentNode: parentNode,
12146
12360
  parentScope: state.localScope,
12147
12361
  identifiers: {},
12148
- tempVarIndex: 0
12362
+ tempVarIndex: 0,
12363
+ tempVars: []
12149
12364
  },
12150
12365
  scopeIsStrict: scopeIsStrict
12151
12366
  });
@@ -12157,16 +12372,26 @@ function traverse(node, path, state) {
12157
12372
  // function
12158
12373
  if (parentNode.params.length > 0) {
12159
12374
  var param;
12375
+ var metadata = initScopeMetadata(parentNode, path.slice(1), path[0]);
12160
12376
  for (var i = 0; i < parentNode.params.length; i++) {
12161
12377
  param = parentNode.params[i];
12162
12378
  if (param.type === Syntax.Identifier) {
12163
- declareIdentInScope(
12164
- param.name, initScopeMetadata(parentNode), state
12165
- );
12379
+ declareIdentInScope(param.name, metadata, state);
12166
12380
  }
12167
12381
  }
12168
12382
  }
12169
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
+
12170
12395
  // Named FunctionExpressions scope their name within the body block of
12171
12396
  // themselves only
12172
12397
  if (parentNode.type === Syntax.FunctionExpression && parentNode.id) {
@@ -12182,18 +12407,24 @@ function traverse(node, path, state) {
12182
12407
  }
12183
12408
 
12184
12409
  if (_nodeIsBlockScopeBoundary(node, parentNode)) {
12410
+ startIndex = state.g.buffer.length;
12185
12411
  state = utils.updateState(state, {
12186
12412
  localScope: {
12187
12413
  parentNode: parentNode,
12188
12414
  parentScope: state.localScope,
12189
- identifiers: {}
12415
+ identifiers: {},
12416
+ tempVarIndex: 0,
12417
+ tempVars: []
12190
12418
  }
12191
12419
  });
12192
12420
 
12193
12421
  if (parentNode.type === Syntax.CatchClause) {
12194
- declareIdentInScope(
12195
- parentNode.param.name, initScopeMetadata(parentNode), state
12422
+ var metadata = initScopeMetadata(
12423
+ parentNode,
12424
+ path.slice(1),
12425
+ parentNode
12196
12426
  );
12427
+ declareIdentInScope(parentNode.param.name, metadata, state);
12197
12428
  }
12198
12429
  collectBlockIdentsAndTraverse(node, path, state);
12199
12430
  }
@@ -12207,6 +12438,11 @@ function traverse(node, path, state) {
12207
12438
  }
12208
12439
 
12209
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
+ }
12210
12446
  }
12211
12447
 
12212
12448
  function collectClosureIdentsAndTraverse(node, path, state) {
@@ -12232,6 +12468,7 @@ function collectBlockIdentsAndTraverse(node, path, state) {
12232
12468
  function visitLocalClosureIdentifiers(node, path, state) {
12233
12469
  var metaData;
12234
12470
  switch (node.type) {
12471
+ case Syntax.ArrowFunctionExpression:
12235
12472
  case Syntax.FunctionExpression:
12236
12473
  // Function expressions don't get their names (if there is one) added to
12237
12474
  // the closure scope they're defined in
@@ -12272,6 +12509,22 @@ function walker(node, path, state) {
12272
12509
 
12273
12510
  var _astCache = {};
12274
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
+
12275
12528
  /**
12276
12529
  * Applies all available transformations to the source
12277
12530
  * @param {array} visitors
@@ -12283,13 +12536,7 @@ function transform(visitors, source, options) {
12283
12536
  options = options || {};
12284
12537
  var ast;
12285
12538
  try {
12286
- var cachedAst = _astCache[source];
12287
- ast = cachedAst ||
12288
- (_astCache[source] = esprima.parse(source, {
12289
- comment: true,
12290
- loc: true,
12291
- range: true
12292
- }));
12539
+ ast = getAstForSource(source, options);
12293
12540
  } catch (e) {
12294
12541
  e.message = 'Parse Error: ' + e.message;
12295
12542
  throw e;
@@ -12316,7 +12563,7 @@ function transform(visitors, source, options) {
12316
12563
  exports.transform = transform;
12317
12564
  exports.Syntax = Syntax;
12318
12565
 
12319
- },{"./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){
12320
12567
  /**
12321
12568
  * Copyright 2013 Facebook, Inc.
12322
12569
  *
@@ -12361,7 +12608,8 @@ function createState(source, rootNode, transformOptions) {
12361
12608
  parentNode: rootNode,
12362
12609
  parentScope: null,
12363
12610
  identifiers: {},
12364
- tempVarIndex: 0
12611
+ tempVarIndex: 0,
12612
+ tempVars: []
12365
12613
  },
12366
12614
  /**
12367
12615
  * The name (and, if applicable, expression) of the super class
@@ -12578,29 +12826,87 @@ function getNodeSourceText(node, state) {
12578
12826
  return state.g.source.substring(node.range[0], node.range[1]);
12579
12827
  }
12580
12828
 
12581
- function replaceNonWhite(value) {
12829
+ function _replaceNonWhite(value) {
12582
12830
  return value.replace(nonWhiteRegexp, ' ');
12583
12831
  }
12584
12832
 
12585
12833
  /**
12586
12834
  * Removes all non-whitespace characters
12587
12835
  */
12588
- function stripNonWhite(value) {
12836
+ function _stripNonWhite(value) {
12589
12837
  return value.replace(nonWhiteRegexp, '');
12590
12838
  }
12591
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
+
12592
12898
  /**
12593
12899
  * Catches up as `catchup` but replaces non-whitespace chars with spaces.
12594
12900
  */
12595
12901
  function catchupWhiteOut(end, state) {
12596
- catchup(end, state, replaceNonWhite);
12902
+ catchup(end, state, _replaceNonWhite);
12597
12903
  }
12598
12904
 
12599
12905
  /**
12600
12906
  * Catches up as `catchup` but removes all non-whitespace characters.
12601
12907
  */
12602
12908
  function catchupWhiteSpace(end, state) {
12603
- catchup(end, state, stripNonWhite);
12909
+ catchup(end, state, _stripNonWhite);
12604
12910
  }
12605
12911
 
12606
12912
  /**
@@ -12683,6 +12989,7 @@ function append(str, state) {
12683
12989
  * @return {string}
12684
12990
  */
12685
12991
  function updateIndent(str, state) {
12992
+ /*jshint -W004*/
12686
12993
  var indentBy = state.indentBy;
12687
12994
  if (indentBy < 0) {
12688
12995
  for (var i = 0; i < -indentBy; i++) {
@@ -12774,6 +13081,17 @@ function declareIdentInLocalScope(identName, metaData, state) {
12774
13081
  }
12775
13082
 
12776
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) {
12777
13095
  return state.localScope.identifiers[identName];
12778
13096
  }
12779
13097
 
@@ -12889,6 +13207,7 @@ function containsChildMatching(node, matcher) {
12889
13207
  }
12890
13208
 
12891
13209
  var scopeTypes = {};
13210
+ scopeTypes[Syntax.ArrowFunctionExpression] = true;
12892
13211
  scopeTypes[Syntax.FunctionExpression] = true;
12893
13212
  scopeTypes[Syntax.FunctionDeclaration] = true;
12894
13213
  scopeTypes[Syntax.Program] = true;
@@ -12909,15 +13228,28 @@ function getTempVar(tempVarIndex) {
12909
13228
  return '$__' + tempVarIndex;
12910
13229
  }
12911
13230
 
12912
- function getTempVarWithValue(tempVarIndex, tempVarValue) {
12913
- return getTempVar(tempVarIndex) + '=' + tempVarValue;
13231
+ function injectTempVar(state) {
13232
+ var tempVar = '$__' + (state.localScope.tempVarIndex++);
13233
+ state.localScope.tempVars.push(tempVar);
13234
+ return tempVar;
12914
13235
  }
12915
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
+ }
13245
+ }
13246
+
13247
+ exports.analyzeAndTraverse = analyzeAndTraverse;
12916
13248
  exports.append = append;
12917
13249
  exports.catchup = catchup;
13250
+ exports.catchupNewlines = catchupNewlines;
12918
13251
  exports.catchupWhiteOut = catchupWhiteOut;
12919
13252
  exports.catchupWhiteSpace = catchupWhiteSpace;
12920
- exports.catchupNewlines = catchupNewlines;
12921
13253
  exports.containsChildMatching = containsChildMatching;
12922
13254
  exports.containsChildOfType = containsChildOfType;
12923
13255
  exports.createState = createState;
@@ -12925,21 +13257,23 @@ exports.declareIdentInLocalScope = declareIdentInLocalScope;
12925
13257
  exports.getBoundaryNode = getBoundaryNode;
12926
13258
  exports.getDocblock = getDocblock;
12927
13259
  exports.getLexicalBindingMetadata = getLexicalBindingMetadata;
12928
- exports.initScopeMetadata = initScopeMetadata;
12929
- exports.identWithinLexicalScope = identWithinLexicalScope;
13260
+ exports.getLocalBindingMetadata = getLocalBindingMetadata;
13261
+ exports.getNextSyntacticCharOffset = getNextSyntacticCharOffset;
13262
+ exports.getNodeSourceText = getNodeSourceText;
13263
+ exports.getOrderedChildren = getOrderedChildren;
13264
+ exports.getTempVar = getTempVar;
12930
13265
  exports.identInLocalScope = identInLocalScope;
13266
+ exports.identWithinLexicalScope = identWithinLexicalScope;
12931
13267
  exports.indentBefore = indentBefore;
13268
+ exports.initScopeMetadata = initScopeMetadata;
13269
+ exports.injectTempVar = injectTempVar;
13270
+ exports.injectTempVarDeclarations = injectTempVarDeclarations;
12932
13271
  exports.move = move;
12933
13272
  exports.scopeTypes = scopeTypes;
12934
13273
  exports.updateIndent = updateIndent;
12935
13274
  exports.updateState = updateState;
12936
- exports.analyzeAndTraverse = analyzeAndTraverse;
12937
- exports.getOrderedChildren = getOrderedChildren;
12938
- exports.getNodeSourceText = getNodeSourceText;
12939
- exports.getTempVar = getTempVar;
12940
- exports.getTempVarWithValue = getTempVarWithValue;
12941
13275
 
12942
- },{"./docblock":20,"esprima-fb":9}],23:[function(_dereq_,module,exports){
13276
+ },{"./docblock":20,"esprima-fb":8}],23:[function(_dereq_,module,exports){
12943
13277
  /**
12944
13278
  * Copyright 2013 Facebook, Inc.
12945
13279
  *
@@ -13099,7 +13433,7 @@ exports.visitorList = [
13099
13433
  ];
13100
13434
 
13101
13435
 
13102
- },{"../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){
13103
13437
  /**
13104
13438
  * Copyright 2013 Facebook, Inc.
13105
13439
  *
@@ -13283,6 +13617,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13283
13617
  if (methodNode.key.name === 'constructor') {
13284
13618
  utils.append('function ' + state.className, state);
13285
13619
  } else {
13620
+ var methodAccessorComputed = false;
13286
13621
  var methodAccessor;
13287
13622
  var prototypeOrStatic = methodNode["static"] ? '' : '.prototype';
13288
13623
  var objectAccessor = state.className + prototypeOrStatic;
@@ -13296,16 +13631,13 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13296
13631
  if (isGetter || isSetter) {
13297
13632
  methodAccessor = JSON.stringify(methodAccessor);
13298
13633
  } else if (reservedWordsHelper.isReservedWord(methodAccessor)) {
13299
- methodAccessor = '[' + JSON.stringify(methodAccessor) + ']';
13300
- } else {
13301
- methodAccessor = '.' + methodAccessor;
13634
+ methodAccessorComputed = true;
13635
+ methodAccessor = JSON.stringify(methodAccessor);
13302
13636
  }
13303
13637
  } else if (methodNode.key.type === Syntax.Literal) {
13304
13638
  // 'foo bar'() {} | get 'foo bar'() {} | set 'foo bar'() {}
13305
13639
  methodAccessor = JSON.stringify(methodNode.key.value);
13306
- if (!(isGetter || isSetter)) {
13307
- methodAccessor = '[' + methodAccessor + ']';
13308
- }
13640
+ methodAccessorComputed = true;
13309
13641
  }
13310
13642
 
13311
13643
  if (isSetter || isGetter) {
@@ -13313,16 +13645,35 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13313
13645
  'Object.defineProperty(' +
13314
13646
  objectAccessor + ',' +
13315
13647
  methodAccessor + ',' +
13316
- '{enumerable:true,configurable:true,' +
13648
+ '{configurable:true,' +
13317
13649
  methodNode.kind + ':function',
13318
13650
  state
13319
13651
  );
13320
13652
  } else {
13321
- utils.append(
13322
- objectAccessor +
13323
- methodAccessor + '=function' + (node.generator ? '*' : ''),
13324
- state
13325
- );
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
+ }
13326
13677
  }
13327
13678
  }
13328
13679
  utils.move(methodNode.key.range[1], state);
@@ -13338,9 +13689,13 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13338
13689
  path.shift();
13339
13690
  }
13340
13691
  }
13341
- utils.append(')', state);
13342
- utils.catchupWhiteSpace(node.body.range[0], state);
13343
- 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
+
13344
13699
  if (!state.scopeIsStrict) {
13345
13700
  utils.append('"use strict";', state);
13346
13701
  state = utils.updateState(state, {
@@ -13355,7 +13710,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13355
13710
  utils.catchup(node.body.range[1], state);
13356
13711
 
13357
13712
  if (methodNode.key.name !== 'constructor') {
13358
- if (isGetter || isSetter) {
13713
+ if (isGetter || isSetter || !state.g.opts.es3) {
13359
13714
  utils.append('})', state);
13360
13715
  }
13361
13716
  utils.append(';', state);
@@ -13668,7 +14023,7 @@ exports.visitorList = [
13668
14023
  visitSuperMemberExpression
13669
14024
  ];
13670
14025
 
13671
- },{"../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){
13672
14027
  /**
13673
14028
  * Copyright 2014 Facebook, Inc.
13674
14029
  *
@@ -13790,7 +14145,7 @@ function getDestructuredComponents(node, state) {
13790
14145
  } else {
13791
14146
  // Complex sub-structure.
13792
14147
  components.push(
13793
- utils.getTempVarWithValue(++state.localScope.tempVarIndex, accessor) +
14148
+ utils.getTempVar(++state.localScope.tempVarIndex) + '=' + accessor +
13794
14149
  ',' + getDestructuredComponents(value, state)
13795
14150
  );
13796
14151
  }
@@ -13950,7 +14305,7 @@ exports.visitorList = [
13950
14305
  exports.renderDestructuredComponents = renderDestructuredComponents;
13951
14306
 
13952
14307
 
13953
- },{"../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){
13954
14309
  /**
13955
14310
  * Copyright 2013 Facebook, Inc.
13956
14311
  *
@@ -14021,7 +14376,7 @@ exports.visitorList = [
14021
14376
  visitObjectConciseMethod
14022
14377
  ];
14023
14378
 
14024
- },{"../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){
14025
14380
  /**
14026
14381
  * Copyright 2013 Facebook, Inc.
14027
14382
  *
@@ -14076,7 +14431,7 @@ exports.visitorList = [
14076
14431
  ];
14077
14432
 
14078
14433
 
14079
- },{"../src/utils":22,"esprima-fb":9}],28:[function(_dereq_,module,exports){
14434
+ },{"../src/utils":22,"esprima-fb":8}],28:[function(_dereq_,module,exports){
14080
14435
  /**
14081
14436
  * Copyright 2013 Facebook, Inc.
14082
14437
  *
@@ -14159,8 +14514,8 @@ function renderRestParamSetup(functionNode, state) {
14159
14514
  var len = state.localScope.tempVarIndex++;
14160
14515
 
14161
14516
  return 'for (var ' + functionNode.rest.name + '=[],' +
14162
- utils.getTempVarWithValue(idx, functionNode.params.length) + ',' +
14163
- utils.getTempVarWithValue(len, 'arguments.length') + ';' +
14517
+ utils.getTempVar(idx) + '=' + functionNode.params.length + ',' +
14518
+ utils.getTempVar(len) + '=arguments.length;' +
14164
14519
  utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' +
14165
14520
  utils.getTempVar(idx) + '++) ' +
14166
14521
  functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);';
@@ -14184,7 +14539,7 @@ exports.visitorList = [
14184
14539
  visitFunctionBodyWithRestParam
14185
14540
  ];
14186
14541
 
14187
- },{"../src/utils":22,"esprima-fb":9}],29:[function(_dereq_,module,exports){
14542
+ },{"../src/utils":22,"esprima-fb":8}],29:[function(_dereq_,module,exports){
14188
14543
  /**
14189
14544
  * Copyright 2013 Facebook, Inc.
14190
14545
  *
@@ -14342,7 +14697,7 @@ exports.visitorList = [
14342
14697
  visitTaggedTemplateExpression
14343
14698
  ];
14344
14699
 
14345
- },{"../src/utils":22,"esprima-fb":9}],30:[function(_dereq_,module,exports){
14700
+ },{"../src/utils":22,"esprima-fb":8}],30:[function(_dereq_,module,exports){
14346
14701
  /**
14347
14702
  * Copyright 2013 Facebook, Inc.
14348
14703
  *
@@ -14366,7 +14721,6 @@ exports.visitorList = [
14366
14721
  */
14367
14722
 
14368
14723
  var Syntax = _dereq_('esprima-fb').Syntax;
14369
- var utils = _dereq_('../src/utils');
14370
14724
 
14371
14725
  // TODO: This is a pretty massive helper, it should only be defined once, in the
14372
14726
  // transform's runtime environment. We don't currently have a runtime though.
@@ -14425,7 +14779,7 @@ function renderRestExpression(accessorExpression, excludedProperties) {
14425
14779
 
14426
14780
  exports.renderRestExpression = renderRestExpression;
14427
14781
 
14428
- },{"../src/utils":22,"esprima-fb":9}],31:[function(_dereq_,module,exports){
14782
+ },{"esprima-fb":8}],31:[function(_dereq_,module,exports){
14429
14783
  /**
14430
14784
  * Copyright 2004-present Facebook. All Rights Reserved.
14431
14785
  */
@@ -14535,7 +14889,7 @@ exports.visitorList = [
14535
14889
  visitObjectLiteralSpread
14536
14890
  ];
14537
14891
 
14538
- },{"../src/utils":22,"esprima-fb":9}],32:[function(_dereq_,module,exports){
14892
+ },{"../src/utils":22,"esprima-fb":8}],32:[function(_dereq_,module,exports){
14539
14893
  /**
14540
14894
  * Copyright 2014 Facebook, Inc.
14541
14895
  *
@@ -14615,6 +14969,15 @@ visitTypeAlias.test = function(node, path, state) {
14615
14969
  return node.type === Syntax.TypeAlias;
14616
14970
  };
14617
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
+
14618
14981
  function visitInterfaceDeclaration(traverse, node, path, state) {
14619
14982
  utils.catchupWhiteOut(node.range[1], state);
14620
14983
  return false;
@@ -14629,13 +14992,14 @@ function visitDeclare(traverse, node, path, state) {
14629
14992
  }
14630
14993
  visitDeclare.test = function(node, path, state) {
14631
14994
  switch (node.type) {
14632
- case Syntax.DeclareVariable:
14633
- case Syntax.DeclareFunction:
14634
- case Syntax.DeclareClass:
14635
- case Syntax.DeclareModule: return true
14995
+ case Syntax.DeclareVariable:
14996
+ case Syntax.DeclareFunction:
14997
+ case Syntax.DeclareClass:
14998
+ case Syntax.DeclareModule:
14999
+ return true;
14636
15000
  }
14637
15001
  return false;
14638
- }
15002
+ };
14639
15003
 
14640
15004
  function visitFunctionParametricAnnotation(traverse, node, path, state) {
14641
15005
  utils.catchup(node.range[0], state);
@@ -14722,22 +15086,33 @@ visitMethod.test = function(node, path, state) {
14722
15086
  || (node.type === "MethodDefinition");
14723
15087
  };
14724
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
+
14725
15098
  exports.visitorList = [
14726
15099
  visitClassProperty,
14727
15100
  visitDeclare,
15101
+ visitImportType,
14728
15102
  visitInterfaceDeclaration,
14729
15103
  visitFunctionParametricAnnotation,
14730
15104
  visitFunctionReturnAnnotation,
14731
15105
  visitMethod,
14732
15106
  visitOptionalFunctionParameterAnnotation,
14733
15107
  visitTypeAlias,
15108
+ visitTypeCast,
14734
15109
  visitTypeAnnotatedIdentifier,
14735
15110
  visitTypeAnnotatedObjectOrArrayPattern
14736
15111
  ];
14737
15112
 
14738
- },{"../src/utils":22,"esprima-fb":9}],34:[function(_dereq_,module,exports){
15113
+ },{"../src/utils":22,"esprima-fb":8}],34:[function(_dereq_,module,exports){
14739
15114
  /**
14740
- * Copyright 2013-2014, Facebook, Inc.
15115
+ * Copyright 2013-2015, Facebook, Inc.
14741
15116
  * All rights reserved.
14742
15117
  *
14743
15118
  * This source code is licensed under the BSD-style license found in the
@@ -14795,7 +15170,6 @@ function visitReactTag(traverse, object, path, state) {
14795
15170
  // We assume that the React runtime is already in scope
14796
15171
  utils.append('React.createElement(', state);
14797
15172
 
14798
- // XJSMemberExpressions are not.
14799
15173
  if (nameObject.type === Syntax.XJSIdentifier && isTagName(nameObject.name)) {
14800
15174
  utils.append('"' + nameObject.name + '"', state);
14801
15175
  utils.move(nameObject.range[1], state);
@@ -14982,7 +15356,7 @@ exports.visitorList = [
14982
15356
 
14983
15357
  },{"./xjs":36,"jstransform":21,"jstransform/src/utils":22}],35:[function(_dereq_,module,exports){
14984
15358
  /**
14985
- * Copyright 2013-2014, Facebook, Inc.
15359
+ * Copyright 2013-2015, Facebook, Inc.
14986
15360
  * All rights reserved.
14987
15361
  *
14988
15362
  * This source code is licensed under the BSD-style license found in the
@@ -15077,7 +15451,7 @@ exports.visitorList = [
15077
15451
 
15078
15452
  },{"jstransform":21,"jstransform/src/utils":22}],36:[function(_dereq_,module,exports){
15079
15453
  /**
15080
- * Copyright 2013-2014, Facebook, Inc.
15454
+ * Copyright 2013-2015, Facebook, Inc.
15081
15455
  * All rights reserved.
15082
15456
  *
15083
15457
  * This source code is licensed under the BSD-style license found in the