react 0.13.0-alpha.1 → 0.13.0-rc1

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 (182) hide show
  1. package/dist/JSXTransformer.js +1376 -596
  2. package/dist/react-with-addons.js +3256 -2363
  3. package/dist/react-with-addons.min.js +7 -7
  4. package/dist/react.js +3092 -2266
  5. package/dist/react.min.js +6 -7
  6. package/lib/AutoFocusMixin.js +2 -2
  7. package/lib/BeforeInputEventPlugin.js +5 -9
  8. package/lib/CSSCore.js +1 -1
  9. package/lib/CSSProperty.js +4 -2
  10. package/lib/CSSPropertyOperations.js +44 -17
  11. package/lib/CallbackQueue.js +3 -3
  12. package/lib/ChangeEventPlugin.js +2 -2
  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 +7 -6
  18. package/lib/DefaultEventPluginOrder.js +3 -3
  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 +1 -1
  27. package/lib/FallbackCompositionState.js +7 -5
  28. package/lib/HTMLDOMPropertyConfig.js +22 -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 +2 -2
  34. package/lib/PooledClass.js +2 -2
  35. package/lib/React.js +9 -13
  36. package/lib/ReactBrowserComponentMixin.js +2 -2
  37. package/lib/ReactBrowserEventEmitter.js +4 -4
  38. package/lib/ReactCSSTransitionGroup.js +2 -2
  39. package/lib/ReactCSSTransitionGroupChild.js +12 -7
  40. package/lib/ReactChildReconciler.js +11 -7
  41. package/lib/ReactChildren.js +13 -10
  42. package/lib/ReactClass.js +161 -135
  43. package/lib/ReactComponent.js +100 -158
  44. package/lib/ReactComponentBrowserEnvironment.js +2 -2
  45. package/lib/ReactComponentEnvironment.js +3 -3
  46. package/lib/ReactComponentWithPureRenderMixin.js +2 -2
  47. package/lib/ReactCompositeComponent.js +336 -484
  48. package/lib/ReactContext.js +14 -4
  49. package/lib/ReactCurrentOwner.js +2 -2
  50. package/lib/ReactDOM.js +2 -2
  51. package/lib/ReactDOMButton.js +2 -2
  52. package/lib/ReactDOMComponent.js +42 -52
  53. package/lib/ReactDOMForm.js +2 -2
  54. package/lib/ReactDOMIDOperations.js +4 -4
  55. package/lib/ReactDOMIframe.js +43 -0
  56. package/lib/ReactDOMImg.js +2 -2
  57. package/lib/ReactDOMInput.js +2 -2
  58. package/lib/ReactDOMOption.js +2 -2
  59. package/lib/ReactDOMSelect.js +3 -3
  60. package/lib/ReactDOMSelection.js +2 -2
  61. package/lib/ReactDOMTextComponent.js +4 -13
  62. package/lib/ReactDOMTextarea.js +2 -2
  63. package/lib/ReactDefaultBatchingStrategy.js +5 -5
  64. package/lib/ReactDefaultInjection.js +26 -2
  65. package/lib/ReactDefaultPerf.js +12 -4
  66. package/lib/ReactDefaultPerfAnalysis.js +1 -1
  67. package/lib/ReactElement.js +7 -5
  68. package/lib/ReactElementValidator.js +185 -65
  69. package/lib/ReactEmptyComponent.js +17 -6
  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 +180 -0
  74. package/lib/ReactInjection.js +2 -2
  75. package/lib/ReactInputSelection.js +2 -2
  76. package/lib/ReactInstanceHandles.js +4 -3
  77. package/lib/ReactInstanceMap.js +2 -2
  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 +87 -23
  82. package/lib/ReactMultiChild.js +19 -7
  83. package/lib/ReactMultiChildUpdateTypes.js +2 -2
  84. package/lib/ReactNativeComponent.js +34 -37
  85. package/lib/ReactOwner.js +2 -2
  86. package/lib/ReactPerf.js +2 -2
  87. package/lib/ReactPropTransferer.js +3 -3
  88. package/lib/ReactPropTypeLocationNames.js +2 -2
  89. package/lib/ReactPropTypeLocations.js +2 -2
  90. package/lib/ReactPropTypes.js +16 -8
  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 +41 -68
  95. package/lib/ReactRootIndex.js +2 -2
  96. package/lib/ReactServerRendering.js +4 -3
  97. package/lib/ReactServerRenderingTransaction.js +2 -2
  98. package/lib/ReactStateSetters.js +2 -2
  99. package/lib/ReactTestUtils.js +49 -8
  100. package/lib/ReactTransitionChildMapping.js +8 -4
  101. package/lib/ReactTransitionEvents.js +2 -2
  102. package/lib/ReactTransitionGroup.js +6 -6
  103. package/lib/ReactUpdateQueue.js +295 -0
  104. package/lib/ReactUpdates.js +13 -22
  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 +2 -2
  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 +5 -5
  122. package/lib/ViewportMetrics.js +2 -2
  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 +2 -2
  131. package/lib/createNodesFromMarkup.js +4 -4
  132. package/lib/cx.js +16 -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 +26 -9
  138. package/lib/flattenChildren.js +11 -9
  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 +2 -2
  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 +21 -21
  155. package/lib/invariant.js +1 -1
  156. package/lib/isEventSupported.js +2 -2
  157. package/lib/isNode.js +1 -1
  158. package/lib/isTextInputElement.js +2 -2
  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 +64 -8
  173. package/lib/toArray.js +2 -2
  174. package/lib/traverseAllChildren.js +19 -5
  175. package/lib/update.js +2 -2
  176. package/lib/warning.js +20 -2
  177. package/package.json +1 -1
  178. package/lib/accumulate.js +0 -47
  179. package/lib/copyProperties.js +0 -56
  180. package/lib/merge.js +0 -34
  181. package/lib/mergeInto.js +0 -24
  182. package/lib/monitorCodeUse.js +0 -30
@@ -1,9 +1,9 @@
1
1
  /**
2
- * JSXTransformer v0.13.0-alpha.1
2
+ * JSXTransformer v0.13.0-rc1
3
3
  */
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){
4
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JSXTransformer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
5
5
  /**
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
@@ -12,13 +12,13 @@
12
12
  */
13
13
  /* jshint browser: true */
14
14
  /* jslint evil: true */
15
+ /*eslint-disable no-eval */
16
+ /*eslint-disable block-scoped-var */
15
17
 
16
18
  'use strict';
17
19
 
18
- var buffer = _dereq_('buffer');
19
- var transform = _dereq_('jstransform').transform;
20
- var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
21
- var visitors = _dereq_('./fbtransform/visitors');
20
+ var ReactTools = _dereq_('../main');
21
+ var inlineSourceMap = _dereq_('./inline-source-map');
22
22
 
23
23
  var headEl;
24
24
  var dummyAnchor;
@@ -38,26 +38,18 @@ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
38
38
  * @return {object} object as returned from jstransform
39
39
  */
40
40
  function transformReact(source, options) {
41
- // TODO: just use react-tools
42
41
  options = options || {};
43
- var visitorList;
44
- if (options.harmony) {
45
- visitorList = visitors.getAllVisitors();
46
- } else {
47
- visitorList = visitors.transformVisitors.react;
48
- }
49
42
 
50
- if (options.stripTypes) {
51
- // Stripping types needs to happen before the other transforms
52
- // unfortunately, due to bad interactions. For example,
53
- // es6-rest-param-visitors conflict with stripping rest param type
54
- // annotation
55
- source = transform(typesSyntax.visitorList, source, options).code;
43
+ // Force the sourcemaps option manually. We don't want to use it if it will
44
+ // break (see above note about supportsAccessors). We'll only override the
45
+ // value here if sourceMap was specified and is truthy. This guarantees that
46
+ // we won't override any user intent (since this method is exposed publicly).
47
+ if (options.sourceMap) {
48
+ options.sourceMap = supportsAccessors;
56
49
  }
57
50
 
58
- return transform(visitorList, source, {
59
- sourceMap: supportsAccessors && options.sourceMap
60
- });
51
+ // Otherwise just pass all options straight through to react-tools.
52
+ return ReactTools.transformWithDetails(source, options);
61
53
  }
62
54
 
63
55
  /**
@@ -86,6 +78,13 @@ function exec(source, options) {
86
78
  */
87
79
  function createSourceCodeErrorMessage(code, e) {
88
80
  var sourceLines = code.split('\n');
81
+ // e.lineNumber is non-standard so we can't depend on its availability. If
82
+ // we're in a browser where it isn't supported, don't even bother trying to
83
+ // format anything. We may also hit a case where the line number is reported
84
+ // incorrectly and is outside the bounds of the actual code. Handle that too.
85
+ if (!e.lineNumber || e.lineNumber > sourceLines.length) {
86
+ return '';
87
+ }
89
88
  var erroneousLine = sourceLines[e.lineNumber - 1];
90
89
 
91
90
  // Removes any leading indenting spaces and gets the number of
@@ -134,7 +133,7 @@ function transformCode(code, url, options) {
134
133
  // The error will correctly point to `url` in Firefox.
135
134
  e.fileName = url;
136
135
  }
137
- e.message += url + ':' + e.lineNumber + ':' + e.column;
136
+ e.message += url + ':' + e.lineNumber + ':' + e.columnNumber;
138
137
  } else {
139
138
  e.message += location.href;
140
139
  }
@@ -146,10 +145,9 @@ function transformCode(code, url, options) {
146
145
  return transformed.code;
147
146
  }
148
147
 
149
- var map = transformed.sourceMap.toJSON();
150
148
  var source;
151
149
  if (url == null) {
152
- source = "Inline JSX script";
150
+ source = 'Inline JSX script';
153
151
  inlineScriptCount++;
154
152
  if (inlineScriptCount > 1) {
155
153
  source += ' (' + inlineScriptCount + ')';
@@ -162,13 +160,11 @@ function transformCode(code, url, options) {
162
160
  dummyAnchor.href = url;
163
161
  source = dummyAnchor.pathname.substr(1);
164
162
  }
165
- map.sources = [source];
166
- map.sourcesContent = [code];
167
163
 
168
164
  return (
169
165
  transformed.code +
170
- '\n//# sourceMappingURL=data:application/json;base64,' +
171
- buffer.Buffer(JSON.stringify(map)).toString('base64')
166
+ '\n' +
167
+ inlineSourceMap(transformed.sourceMap, code, source)
172
168
  );
173
169
  }
174
170
 
@@ -212,7 +208,7 @@ function load(url, successCallback, errorCallback) {
212
208
  successCallback(xhr.responseText);
213
209
  } else {
214
210
  errorCallback();
215
- throw new Error("Could not load " + url);
211
+ throw new Error('Could not load ' + url);
216
212
  }
217
213
  }
218
214
  };
@@ -326,7 +322,7 @@ function runScripts() {
326
322
 
327
323
  // Listen for load event if we're in a browser and then kick off finding and
328
324
  // running of scripts.
329
- if (typeof window !== "undefined" && window !== null) {
325
+ if (typeof window !== 'undefined' && window !== null) {
330
326
  headEl = document.getElementsByTagName('head')[0];
331
327
  dummyAnchor = document.createElement('a');
332
328
 
@@ -342,7 +338,104 @@ module.exports = {
342
338
  exec: exec
343
339
  };
344
340
 
345
- },{"./fbtransform/visitors":37,"buffer":2,"jstransform":21,"jstransform/visitors/type-syntax":33}],2:[function(_dereq_,module,exports){
341
+ },{"../main":2,"./inline-source-map":41}],2:[function(_dereq_,module,exports){
342
+ /**
343
+ * Copyright 2013-2015, Facebook, Inc.
344
+ * All rights reserved.
345
+ *
346
+ * This source code is licensed under the BSD-style license found in the
347
+ * LICENSE file in the root directory of this source tree. An additional grant
348
+ * of patent rights can be found in the PATENTS file in the same directory.
349
+ */
350
+
351
+ 'use strict';
352
+ /*eslint-disable no-undef*/
353
+ var visitors = _dereq_('./vendor/fbtransform/visitors');
354
+ var transform = _dereq_('jstransform').transform;
355
+ var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
356
+ var inlineSourceMap = _dereq_('./vendor/inline-source-map');
357
+
358
+ module.exports = {
359
+ transform: function(input, options) {
360
+ options = processOptions(options);
361
+ var output = innerTransform(input, options);
362
+ var result = output.code;
363
+ if (options.sourceMap) {
364
+ var map = inlineSourceMap(
365
+ output.sourceMap,
366
+ input,
367
+ options.filename
368
+ );
369
+ result += '\n' + map;
370
+ }
371
+ return result;
372
+ },
373
+ transformWithDetails: function(input, options) {
374
+ options = processOptions(options);
375
+ var output = innerTransform(input, options);
376
+ var result = {};
377
+ result.code = output.code;
378
+ if (options.sourceMap) {
379
+ result.sourceMap = output.sourceMap.toJSON();
380
+ }
381
+ if (options.filename) {
382
+ result.sourceMap.sources = [options.filename];
383
+ }
384
+ return result;
385
+ }
386
+ };
387
+
388
+ /**
389
+ * Only copy the values that we need. We'll do some preprocessing to account for
390
+ * converting command line flags to options that jstransform can actually use.
391
+ */
392
+ function processOptions(opts) {
393
+ opts = opts || {};
394
+ var options = {};
395
+
396
+ options.harmony = opts.harmony;
397
+ options.stripTypes = opts.stripTypes;
398
+ options.sourceMap = opts.sourceMap;
399
+ options.filename = opts.sourceFilename;
400
+
401
+ if (opts.es6module) {
402
+ options.sourceType = 'module';
403
+ }
404
+ if (opts.nonStrictEs6Module) {
405
+ options.sourceType = 'nonStrict6Module';
406
+ }
407
+
408
+ // Instead of doing any fancy validation, only look for 'es3'. If we have
409
+ // that, then use it. Otherwise use 'es5'.
410
+ options.es3 = opts.target === 'es3';
411
+ options.es5 = !options.es3;
412
+
413
+ return options;
414
+ }
415
+
416
+ function innerTransform(input, options) {
417
+ var visitorSets = ['react'];
418
+ if (options.harmony) {
419
+ visitorSets.push('harmony');
420
+ }
421
+
422
+ if (options.es3) {
423
+ visitorSets.push('es3');
424
+ }
425
+
426
+ if (options.stripTypes) {
427
+ // Stripping types needs to happen before the other transforms
428
+ // unfortunately, due to bad interactions. For example,
429
+ // es6-rest-param-visitors conflict with stripping rest param type
430
+ // annotation
431
+ input = transform(typesSyntax.visitorList, input, options).code;
432
+ }
433
+
434
+ var visitorList = visitors.getVisitorsBySet(visitorSets);
435
+ return transform(visitorList, input, options);
436
+ }
437
+
438
+ },{"./vendor/fbtransform/visitors":40,"./vendor/inline-source-map":41,"jstransform":22,"jstransform/visitors/type-syntax":36}],3:[function(_dereq_,module,exports){
346
439
  /*!
347
440
  * The buffer module from node.js, for the browser.
348
441
  *
@@ -355,11 +448,12 @@ var ieee754 = _dereq_('ieee754')
355
448
  var isArray = _dereq_('is-array')
356
449
 
357
450
  exports.Buffer = Buffer
358
- exports.SlowBuffer = Buffer
451
+ exports.SlowBuffer = SlowBuffer
359
452
  exports.INSPECT_MAX_BYTES = 50
360
453
  Buffer.poolSize = 8192 // not used by this implementation
361
454
 
362
455
  var kMaxLength = 0x3fffffff
456
+ var rootParent = {}
363
457
 
364
458
  /**
365
459
  * If `Buffer.TYPED_ARRAY_SUPPORT`:
@@ -388,7 +482,7 @@ Buffer.TYPED_ARRAY_SUPPORT = (function () {
388
482
  var buf = new ArrayBuffer(0)
389
483
  var arr = new Uint8Array(buf)
390
484
  arr.foo = function () { return 42 }
391
- return 42 === arr.foo() && // typed array instances can be augmented
485
+ return arr.foo() === 42 && // typed array instances can be augmented
392
486
  typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
393
487
  new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
394
488
  } catch (e) {
@@ -416,55 +510,72 @@ function Buffer (subject, encoding, noZero) {
416
510
 
417
511
  // Find the length
418
512
  var length
419
- if (type === 'number')
420
- length = subject > 0 ? subject >>> 0 : 0
421
- else if (type === 'string') {
422
- if (encoding === 'base64')
423
- subject = base64clean(subject)
513
+ if (type === 'number') {
514
+ length = +subject
515
+ } else if (type === 'string') {
424
516
  length = Buffer.byteLength(subject, encoding)
425
517
  } else if (type === 'object' && subject !== null) { // assume object is array-like
426
518
  if (subject.type === 'Buffer' && isArray(subject.data))
427
519
  subject = subject.data
428
- length = +subject.length > 0 ? Math.floor(+subject.length) : 0
429
- } else
520
+ length = +subject.length
521
+ } else {
430
522
  throw new TypeError('must start with number, buffer, array or string')
523
+ }
431
524
 
432
- if (this.length > kMaxLength)
525
+ if (length > kMaxLength)
433
526
  throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
434
527
  'size: 0x' + kMaxLength.toString(16) + ' bytes')
435
528
 
436
- var buf
529
+ if (length < 0)
530
+ length = 0
531
+ else
532
+ length >>>= 0 // Coerce to uint32.
533
+
534
+ var self = this
437
535
  if (Buffer.TYPED_ARRAY_SUPPORT) {
438
536
  // Preferred: Return an augmented `Uint8Array` instance for best performance
439
- buf = Buffer._augment(new Uint8Array(length))
537
+ /*eslint-disable consistent-this */
538
+ self = Buffer._augment(new Uint8Array(length))
539
+ /*eslint-enable consistent-this */
440
540
  } else {
441
541
  // Fallback: Return THIS instance of Buffer (created by `new`)
442
- buf = this
443
- buf.length = length
444
- buf._isBuffer = true
542
+ self.length = length
543
+ self._isBuffer = true
445
544
  }
446
545
 
447
546
  var i
448
547
  if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
449
548
  // Speed optimization -- use set if we're copying from a typed array
450
- buf._set(subject)
549
+ self._set(subject)
451
550
  } else if (isArrayish(subject)) {
452
551
  // Treat array-ish objects as a byte array
453
552
  if (Buffer.isBuffer(subject)) {
454
553
  for (i = 0; i < length; i++)
455
- buf[i] = subject.readUInt8(i)
554
+ self[i] = subject.readUInt8(i)
456
555
  } else {
457
556
  for (i = 0; i < length; i++)
458
- buf[i] = ((subject[i] % 256) + 256) % 256
557
+ self[i] = ((subject[i] % 256) + 256) % 256
459
558
  }
460
559
  } else if (type === 'string') {
461
- buf.write(subject, 0, encoding)
560
+ self.write(subject, 0, encoding)
462
561
  } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
463
562
  for (i = 0; i < length; i++) {
464
- buf[i] = 0
563
+ self[i] = 0
465
564
  }
466
565
  }
467
566
 
567
+ if (length > 0 && length <= Buffer.poolSize)
568
+ self.parent = rootParent
569
+
570
+ return self
571
+ }
572
+
573
+ function SlowBuffer (subject, encoding, noZero) {
574
+ if (!(this instanceof SlowBuffer))
575
+ return new SlowBuffer(subject, encoding, noZero)
576
+
577
+ var buf = new Buffer(subject, encoding, noZero)
578
+ delete buf.parent
468
579
  return buf
469
580
  }
470
581
 
@@ -476,6 +587,8 @@ Buffer.compare = function (a, b) {
476
587
  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b))
477
588
  throw new TypeError('Arguments must be Buffers')
478
589
 
590
+ if (a === b) return 0
591
+
479
592
  var x = a.length
480
593
  var y = b.length
481
594
  for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
@@ -615,7 +728,8 @@ Buffer.prototype.toString = function (encoding, start, end) {
615
728
  }
616
729
 
617
730
  Buffer.prototype.equals = function (b) {
618
- if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
731
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
732
+ if (this === b) return true
619
733
  return Buffer.compare(this, b) === 0
620
734
  }
621
735
 
@@ -632,6 +746,7 @@ Buffer.prototype.inspect = function () {
632
746
 
633
747
  Buffer.prototype.compare = function (b) {
634
748
  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
749
+ if (this === b) return 0
635
750
  return Buffer.compare(this, b)
636
751
  }
637
752
 
@@ -675,7 +790,7 @@ function hexWrite (buf, string, offset, length) {
675
790
  }
676
791
 
677
792
  function utf8Write (buf, string, offset, length) {
678
- var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
793
+ var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
679
794
  return charsWritten
680
795
  }
681
796
 
@@ -694,7 +809,7 @@ function base64Write (buf, string, offset, length) {
694
809
  }
695
810
 
696
811
  function utf16leWrite (buf, string, offset, length) {
697
- var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length, 2)
812
+ var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
698
813
  return charsWritten
699
814
  }
700
815
 
@@ -714,6 +829,10 @@ Buffer.prototype.write = function (string, offset, length, encoding) {
714
829
  }
715
830
 
716
831
  offset = Number(offset) || 0
832
+
833
+ if (length < 0 || offset < 0 || offset > this.length)
834
+ throw new RangeError('attempt to write outside buffer bounds')
835
+
717
836
  var remaining = this.length - offset
718
837
  if (!length) {
719
838
  length = remaining
@@ -792,13 +911,19 @@ function asciiSlice (buf, start, end) {
792
911
  end = Math.min(buf.length, end)
793
912
 
794
913
  for (var i = start; i < end; i++) {
795
- ret += String.fromCharCode(buf[i])
914
+ ret += String.fromCharCode(buf[i] & 0x7F)
796
915
  }
797
916
  return ret
798
917
  }
799
918
 
800
919
  function binarySlice (buf, start, end) {
801
- return asciiSlice(buf, start, end)
920
+ var ret = ''
921
+ end = Math.min(buf.length, end)
922
+
923
+ for (var i = start; i < end; i++) {
924
+ ret += String.fromCharCode(buf[i])
925
+ }
926
+ return ret
802
927
  }
803
928
 
804
929
  function hexSlice (buf, start, end) {
@@ -829,7 +954,7 @@ Buffer.prototype.slice = function (start, end) {
829
954
  end = end === undefined ? len : ~~end
830
955
 
831
956
  if (start < 0) {
832
- start += len;
957
+ start += len
833
958
  if (start < 0)
834
959
  start = 0
835
960
  } else if (start > len) {
@@ -847,16 +972,21 @@ Buffer.prototype.slice = function (start, end) {
847
972
  if (end < start)
848
973
  end = start
849
974
 
975
+ var newBuf
850
976
  if (Buffer.TYPED_ARRAY_SUPPORT) {
851
- return Buffer._augment(this.subarray(start, end))
977
+ newBuf = Buffer._augment(this.subarray(start, end))
852
978
  } else {
853
979
  var sliceLen = end - start
854
- var newBuf = new Buffer(sliceLen, undefined, true)
980
+ newBuf = new Buffer(sliceLen, undefined, true)
855
981
  for (var i = 0; i < sliceLen; i++) {
856
982
  newBuf[i] = this[i + start]
857
983
  }
858
- return newBuf
859
984
  }
985
+
986
+ if (newBuf.length)
987
+ newBuf.parent = this.parent || this
988
+
989
+ return newBuf
860
990
  }
861
991
 
862
992
  /*
@@ -869,6 +999,35 @@ function checkOffset (offset, ext, length) {
869
999
  throw new RangeError('Trying to access beyond buffer length')
870
1000
  }
871
1001
 
1002
+ Buffer.prototype.readUIntLE = function (offset, byteLength, noAssert) {
1003
+ offset = offset >>> 0
1004
+ byteLength = byteLength >>> 0
1005
+ if (!noAssert)
1006
+ checkOffset(offset, byteLength, this.length)
1007
+
1008
+ var val = this[offset]
1009
+ var mul = 1
1010
+ var i = 0
1011
+ while (++i < byteLength && (mul *= 0x100))
1012
+ val += this[offset + i] * mul
1013
+
1014
+ return val
1015
+ }
1016
+
1017
+ Buffer.prototype.readUIntBE = function (offset, byteLength, noAssert) {
1018
+ offset = offset >>> 0
1019
+ byteLength = byteLength >>> 0
1020
+ if (!noAssert)
1021
+ checkOffset(offset, byteLength, this.length)
1022
+
1023
+ var val = this[offset + --byteLength]
1024
+ var mul = 1
1025
+ while (byteLength > 0 && (mul *= 0x100))
1026
+ val += this[offset + --byteLength] * mul
1027
+
1028
+ return val
1029
+ }
1030
+
872
1031
  Buffer.prototype.readUInt8 = function (offset, noAssert) {
873
1032
  if (!noAssert)
874
1033
  checkOffset(offset, 1, this.length)
@@ -907,6 +1066,44 @@ Buffer.prototype.readUInt32BE = function (offset, noAssert) {
907
1066
  this[offset + 3])
908
1067
  }
909
1068
 
1069
+ Buffer.prototype.readIntLE = function (offset, byteLength, noAssert) {
1070
+ offset = offset >>> 0
1071
+ byteLength = byteLength >>> 0
1072
+ if (!noAssert)
1073
+ checkOffset(offset, byteLength, this.length)
1074
+
1075
+ var val = this[offset]
1076
+ var mul = 1
1077
+ var i = 0
1078
+ while (++i < byteLength && (mul *= 0x100))
1079
+ val += this[offset + i] * mul
1080
+ mul *= 0x80
1081
+
1082
+ if (val >= mul)
1083
+ val -= Math.pow(2, 8 * byteLength)
1084
+
1085
+ return val
1086
+ }
1087
+
1088
+ Buffer.prototype.readIntBE = function (offset, byteLength, noAssert) {
1089
+ offset = offset >>> 0
1090
+ byteLength = byteLength >>> 0
1091
+ if (!noAssert)
1092
+ checkOffset(offset, byteLength, this.length)
1093
+
1094
+ var i = byteLength
1095
+ var mul = 1
1096
+ var val = this[offset + --i]
1097
+ while (i > 0 && (mul *= 0x100))
1098
+ val += this[offset + --i] * mul
1099
+ mul *= 0x80
1100
+
1101
+ if (val >= mul)
1102
+ val -= Math.pow(2, 8 * byteLength)
1103
+
1104
+ return val
1105
+ }
1106
+
910
1107
  Buffer.prototype.readInt8 = function (offset, noAssert) {
911
1108
  if (!noAssert)
912
1109
  checkOffset(offset, 1, this.length)
@@ -975,8 +1172,40 @@ Buffer.prototype.readDoubleBE = function (offset, noAssert) {
975
1172
 
976
1173
  function checkInt (buf, value, offset, ext, max, min) {
977
1174
  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')
1175
+ if (value > max || value < min) throw new RangeError('value is out of bounds')
1176
+ if (offset + ext > buf.length) throw new RangeError('index out of range')
1177
+ }
1178
+
1179
+ Buffer.prototype.writeUIntLE = function (value, offset, byteLength, noAssert) {
1180
+ value = +value
1181
+ offset = offset >>> 0
1182
+ byteLength = byteLength >>> 0
1183
+ if (!noAssert)
1184
+ checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1185
+
1186
+ var mul = 1
1187
+ var i = 0
1188
+ this[offset] = value & 0xFF
1189
+ while (++i < byteLength && (mul *= 0x100))
1190
+ this[offset + i] = (value / mul) >>> 0 & 0xFF
1191
+
1192
+ return offset + byteLength
1193
+ }
1194
+
1195
+ Buffer.prototype.writeUIntBE = function (value, offset, byteLength, noAssert) {
1196
+ value = +value
1197
+ offset = offset >>> 0
1198
+ byteLength = byteLength >>> 0
1199
+ if (!noAssert)
1200
+ checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1201
+
1202
+ var i = byteLength - 1
1203
+ var mul = 1
1204
+ this[offset + i] = value & 0xFF
1205
+ while (--i >= 0 && (mul *= 0x100))
1206
+ this[offset + i] = (value / mul) >>> 0 & 0xFF
1207
+
1208
+ return offset + byteLength
980
1209
  }
981
1210
 
982
1211
  Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
@@ -1056,6 +1285,50 @@ Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
1056
1285
  return offset + 4
1057
1286
  }
1058
1287
 
1288
+ Buffer.prototype.writeIntLE = function (value, offset, byteLength, noAssert) {
1289
+ value = +value
1290
+ offset = offset >>> 0
1291
+ if (!noAssert) {
1292
+ checkInt(this,
1293
+ value,
1294
+ offset,
1295
+ byteLength,
1296
+ Math.pow(2, 8 * byteLength - 1) - 1,
1297
+ -Math.pow(2, 8 * byteLength - 1))
1298
+ }
1299
+
1300
+ var i = 0
1301
+ var mul = 1
1302
+ var sub = value < 0 ? 1 : 0
1303
+ this[offset] = value & 0xFF
1304
+ while (++i < byteLength && (mul *= 0x100))
1305
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1306
+
1307
+ return offset + byteLength
1308
+ }
1309
+
1310
+ Buffer.prototype.writeIntBE = function (value, offset, byteLength, noAssert) {
1311
+ value = +value
1312
+ offset = offset >>> 0
1313
+ if (!noAssert) {
1314
+ checkInt(this,
1315
+ value,
1316
+ offset,
1317
+ byteLength,
1318
+ Math.pow(2, 8 * byteLength - 1) - 1,
1319
+ -Math.pow(2, 8 * byteLength - 1))
1320
+ }
1321
+
1322
+ var i = byteLength - 1
1323
+ var mul = 1
1324
+ var sub = value < 0 ? 1 : 0
1325
+ this[offset + i] = value & 0xFF
1326
+ while (--i >= 0 && (mul *= 0x100))
1327
+ this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1328
+
1329
+ return offset + byteLength
1330
+ }
1331
+
1059
1332
  Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
1060
1333
  value = +value
1061
1334
  offset = offset >>> 0
@@ -1121,8 +1394,9 @@ Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
1121
1394
  }
1122
1395
 
1123
1396
  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')
1397
+ if (value > max || value < min) throw new RangeError('value is out of bounds')
1398
+ if (offset + ext > buf.length) throw new RangeError('index out of range')
1399
+ if (offset < 0) throw new RangeError('index out of range')
1126
1400
  }
1127
1401
 
1128
1402
  function writeFloat (buf, value, offset, littleEndian, noAssert) {
@@ -1157,22 +1431,23 @@ Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
1157
1431
 
1158
1432
  // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1159
1433
  Buffer.prototype.copy = function (target, target_start, start, end) {
1160
- var source = this
1434
+ var self = this // source
1161
1435
 
1162
1436
  if (!start) start = 0
1163
1437
  if (!end && end !== 0) end = this.length
1438
+ if (target_start >= target.length) target_start = target.length
1164
1439
  if (!target_start) target_start = 0
1440
+ if (end > 0 && end < start) end = start
1165
1441
 
1166
1442
  // Copy 0 bytes; we're done
1167
- if (end === start) return
1168
- if (target.length === 0 || source.length === 0) return
1443
+ if (end === start) return 0
1444
+ if (target.length === 0 || self.length === 0) return 0
1169
1445
 
1170
1446
  // 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')
1447
+ if (target_start < 0)
1448
+ throw new RangeError('targetStart out of bounds')
1449
+ if (start < 0 || start >= self.length) throw new RangeError('sourceStart out of bounds')
1450
+ if (end < 0) throw new RangeError('sourceEnd out of bounds')
1176
1451
 
1177
1452
  // Are we oob?
1178
1453
  if (end > this.length)
@@ -1189,6 +1464,8 @@ Buffer.prototype.copy = function (target, target_start, start, end) {
1189
1464
  } else {
1190
1465
  target._set(this.subarray(start, start + len), target_start)
1191
1466
  }
1467
+
1468
+ return len
1192
1469
  }
1193
1470
 
1194
1471
  // fill(value, start=0, end=buffer.length)
@@ -1197,14 +1474,14 @@ Buffer.prototype.fill = function (value, start, end) {
1197
1474
  if (!start) start = 0
1198
1475
  if (!end) end = this.length
1199
1476
 
1200
- if (end < start) throw new TypeError('end < start')
1477
+ if (end < start) throw new RangeError('end < start')
1201
1478
 
1202
1479
  // Fill 0 bytes; we're done
1203
1480
  if (end === start) return
1204
1481
  if (this.length === 0) return
1205
1482
 
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')
1483
+ if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
1484
+ if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
1208
1485
 
1209
1486
  var i
1210
1487
  if (typeof value === 'number') {
@@ -1270,11 +1547,15 @@ Buffer._augment = function (arr) {
1270
1547
  arr.compare = BP.compare
1271
1548
  arr.copy = BP.copy
1272
1549
  arr.slice = BP.slice
1550
+ arr.readUIntLE = BP.readUIntLE
1551
+ arr.readUIntBE = BP.readUIntBE
1273
1552
  arr.readUInt8 = BP.readUInt8
1274
1553
  arr.readUInt16LE = BP.readUInt16LE
1275
1554
  arr.readUInt16BE = BP.readUInt16BE
1276
1555
  arr.readUInt32LE = BP.readUInt32LE
1277
1556
  arr.readUInt32BE = BP.readUInt32BE
1557
+ arr.readIntLE = BP.readIntLE
1558
+ arr.readIntBE = BP.readIntBE
1278
1559
  arr.readInt8 = BP.readInt8
1279
1560
  arr.readInt16LE = BP.readInt16LE
1280
1561
  arr.readInt16BE = BP.readInt16BE
@@ -1285,10 +1566,14 @@ Buffer._augment = function (arr) {
1285
1566
  arr.readDoubleLE = BP.readDoubleLE
1286
1567
  arr.readDoubleBE = BP.readDoubleBE
1287
1568
  arr.writeUInt8 = BP.writeUInt8
1569
+ arr.writeUIntLE = BP.writeUIntLE
1570
+ arr.writeUIntBE = BP.writeUIntBE
1288
1571
  arr.writeUInt16LE = BP.writeUInt16LE
1289
1572
  arr.writeUInt16BE = BP.writeUInt16BE
1290
1573
  arr.writeUInt32LE = BP.writeUInt32LE
1291
1574
  arr.writeUInt32BE = BP.writeUInt32BE
1575
+ arr.writeIntLE = BP.writeIntLE
1576
+ arr.writeIntBE = BP.writeIntBE
1292
1577
  arr.writeInt8 = BP.writeInt8
1293
1578
  arr.writeInt16LE = BP.writeInt16LE
1294
1579
  arr.writeInt16BE = BP.writeInt16BE
@@ -1305,11 +1590,13 @@ Buffer._augment = function (arr) {
1305
1590
  return arr
1306
1591
  }
1307
1592
 
1308
- var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
1593
+ var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g
1309
1594
 
1310
1595
  function base64clean (str) {
1311
1596
  // Node strips out invalid characters like \n and \t from the string, base64-js does not
1312
1597
  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
1598
+ // Node converts strings with length < 2 to ''
1599
+ if (str.length < 2) return ''
1313
1600
  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1314
1601
  while (str.length % 4 !== 0) {
1315
1602
  str = str + '='
@@ -1333,22 +1620,85 @@ function toHex (n) {
1333
1620
  return n.toString(16)
1334
1621
  }
1335
1622
 
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))
1623
+ function utf8ToBytes (string, units) {
1624
+ units = units || Infinity
1625
+ var codePoint
1626
+ var length = string.length
1627
+ var leadSurrogate = null
1628
+ var bytes = []
1629
+ var i = 0
1630
+
1631
+ for (; i < length; i++) {
1632
+ codePoint = string.charCodeAt(i)
1633
+
1634
+ // is surrogate component
1635
+ if (codePoint > 0xD7FF && codePoint < 0xE000) {
1636
+ // last char was a lead
1637
+ if (leadSurrogate) {
1638
+ // 2 leads in a row
1639
+ if (codePoint < 0xDC00) {
1640
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1641
+ leadSurrogate = codePoint
1642
+ continue
1643
+ } else {
1644
+ // valid surrogate pair
1645
+ codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
1646
+ leadSurrogate = null
1647
+ }
1648
+ } else {
1649
+ // no lead yet
1650
+
1651
+ if (codePoint > 0xDBFF) {
1652
+ // unexpected trail
1653
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1654
+ continue
1655
+ } else if (i + 1 === length) {
1656
+ // unpaired lead
1657
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1658
+ continue
1659
+ } else {
1660
+ // valid lead
1661
+ leadSurrogate = codePoint
1662
+ continue
1663
+ }
1348
1664
  }
1665
+ } else if (leadSurrogate) {
1666
+ // valid bmp char, but last char was a lead
1667
+ if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
1668
+ leadSurrogate = null
1669
+ }
1670
+
1671
+ // encode utf8
1672
+ if (codePoint < 0x80) {
1673
+ if ((units -= 1) < 0) break
1674
+ bytes.push(codePoint)
1675
+ } else if (codePoint < 0x800) {
1676
+ if ((units -= 2) < 0) break
1677
+ bytes.push(
1678
+ codePoint >> 0x6 | 0xC0,
1679
+ codePoint & 0x3F | 0x80
1680
+ )
1681
+ } else if (codePoint < 0x10000) {
1682
+ if ((units -= 3) < 0) break
1683
+ bytes.push(
1684
+ codePoint >> 0xC | 0xE0,
1685
+ codePoint >> 0x6 & 0x3F | 0x80,
1686
+ codePoint & 0x3F | 0x80
1687
+ )
1688
+ } else if (codePoint < 0x200000) {
1689
+ if ((units -= 4) < 0) break
1690
+ bytes.push(
1691
+ codePoint >> 0x12 | 0xF0,
1692
+ codePoint >> 0xC & 0x3F | 0x80,
1693
+ codePoint >> 0x6 & 0x3F | 0x80,
1694
+ codePoint & 0x3F | 0x80
1695
+ )
1696
+ } else {
1697
+ throw new Error('Invalid code point')
1349
1698
  }
1350
1699
  }
1351
- return byteArray
1700
+
1701
+ return bytes
1352
1702
  }
1353
1703
 
1354
1704
  function asciiToBytes (str) {
@@ -1360,10 +1710,12 @@ function asciiToBytes (str) {
1360
1710
  return byteArray
1361
1711
  }
1362
1712
 
1363
- function utf16leToBytes (str) {
1713
+ function utf16leToBytes (str, units) {
1364
1714
  var c, hi, lo
1365
1715
  var byteArray = []
1366
1716
  for (var i = 0; i < str.length; i++) {
1717
+ if ((units -= 2) < 0) break
1718
+
1367
1719
  c = str.charCodeAt(i)
1368
1720
  hi = c >> 8
1369
1721
  lo = c % 256
@@ -1375,11 +1727,10 @@ function utf16leToBytes (str) {
1375
1727
  }
1376
1728
 
1377
1729
  function base64ToBytes (str) {
1378
- return base64.toByteArray(str)
1730
+ return base64.toByteArray(base64clean(str))
1379
1731
  }
1380
1732
 
1381
- function blitBuffer (src, dst, offset, length, unitSize) {
1382
- if (unitSize) length -= length % unitSize;
1733
+ function blitBuffer (src, dst, offset, length) {
1383
1734
  for (var i = 0; i < length; i++) {
1384
1735
  if ((i + offset >= dst.length) || (i >= src.length))
1385
1736
  break
@@ -1396,7 +1747,7 @@ function decodeUtf8Char (str) {
1396
1747
  }
1397
1748
  }
1398
1749
 
1399
- },{"base64-js":3,"ieee754":4,"is-array":5}],3:[function(_dereq_,module,exports){
1750
+ },{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(_dereq_,module,exports){
1400
1751
  var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1401
1752
 
1402
1753
  ;(function (exports) {
@@ -1411,12 +1762,16 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1411
1762
  var NUMBER = '0'.charCodeAt(0)
1412
1763
  var LOWER = 'a'.charCodeAt(0)
1413
1764
  var UPPER = 'A'.charCodeAt(0)
1765
+ var PLUS_URL_SAFE = '-'.charCodeAt(0)
1766
+ var SLASH_URL_SAFE = '_'.charCodeAt(0)
1414
1767
 
1415
1768
  function decode (elt) {
1416
1769
  var code = elt.charCodeAt(0)
1417
- if (code === PLUS)
1770
+ if (code === PLUS ||
1771
+ code === PLUS_URL_SAFE)
1418
1772
  return 62 // '+'
1419
- if (code === SLASH)
1773
+ if (code === SLASH ||
1774
+ code === SLASH_URL_SAFE)
1420
1775
  return 63 // '/'
1421
1776
  if (code < NUMBER)
1422
1777
  return -1 //no match
@@ -1518,7 +1873,7 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1518
1873
  exports.fromByteArray = uint8ToBase64
1519
1874
  }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
1520
1875
 
1521
- },{}],4:[function(_dereq_,module,exports){
1876
+ },{}],5:[function(_dereq_,module,exports){
1522
1877
  exports.read = function(buffer, offset, isLE, mLen, nBytes) {
1523
1878
  var e, m,
1524
1879
  eLen = nBytes * 8 - mLen - 1,
@@ -1604,7 +1959,7 @@ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
1604
1959
  buffer[offset + i - d] |= s * 128;
1605
1960
  };
1606
1961
 
1607
- },{}],5:[function(_dereq_,module,exports){
1962
+ },{}],6:[function(_dereq_,module,exports){
1608
1963
 
1609
1964
  /**
1610
1965
  * isArray
@@ -1639,7 +1994,7 @@ module.exports = isArray || function (val) {
1639
1994
  return !! val && '[object Array]' == str.call(val);
1640
1995
  };
1641
1996
 
1642
- },{}],6:[function(_dereq_,module,exports){
1997
+ },{}],7:[function(_dereq_,module,exports){
1643
1998
  (function (process){
1644
1999
  // Copyright Joyent, Inc. and other Node contributors.
1645
2000
  //
@@ -1867,73 +2222,43 @@ var substr = 'ab'.substr(-1) === 'b'
1867
2222
  ;
1868
2223
 
1869
2224
  }).call(this,_dereq_('_process'))
1870
- },{"_process":7}],7:[function(_dereq_,module,exports){
2225
+ },{"_process":8}],8:[function(_dereq_,module,exports){
1871
2226
  // shim for using process in browser
1872
2227
 
1873
2228
  var process = module.exports = {};
2229
+ var queue = [];
2230
+ var draining = false;
1874
2231
 
1875
- process.nextTick = (function () {
1876
- var canSetImmediate = typeof window !== 'undefined'
1877
- && window.setImmediate;
1878
- var canMutationObserver = typeof window !== 'undefined'
1879
- && window.MutationObserver;
1880
- var canPost = typeof window !== 'undefined'
1881
- && window.postMessage && window.addEventListener
1882
- ;
1883
-
1884
- if (canSetImmediate) {
1885
- return function (f) { return window.setImmediate(f) };
2232
+ function drainQueue() {
2233
+ if (draining) {
2234
+ return;
1886
2235
  }
1887
-
1888
- var queue = [];
1889
-
1890
- if (canMutationObserver) {
1891
- var hiddenDiv = document.createElement("div");
1892
- var observer = new MutationObserver(function () {
1893
- var queueList = queue.slice();
1894
- queue.length = 0;
1895
- queueList.forEach(function (fn) {
1896
- fn();
1897
- });
1898
- });
1899
-
1900
- observer.observe(hiddenDiv, { attributes: true });
1901
-
1902
- return function nextTick(fn) {
1903
- if (!queue.length) {
1904
- hiddenDiv.setAttribute('yes', 'no');
1905
- }
1906
- queue.push(fn);
1907
- };
2236
+ draining = true;
2237
+ var currentQueue;
2238
+ var len = queue.length;
2239
+ while(len) {
2240
+ currentQueue = queue;
2241
+ queue = [];
2242
+ var i = -1;
2243
+ while (++i < len) {
2244
+ currentQueue[i]();
2245
+ }
2246
+ len = queue.length;
1908
2247
  }
1909
-
1910
- if (canPost) {
1911
- window.addEventListener('message', function (ev) {
1912
- var source = ev.source;
1913
- if ((source === window || source === null) && ev.data === 'process-tick') {
1914
- ev.stopPropagation();
1915
- if (queue.length > 0) {
1916
- var fn = queue.shift();
1917
- fn();
1918
- }
1919
- }
1920
- }, true);
1921
-
1922
- return function nextTick(fn) {
1923
- queue.push(fn);
1924
- window.postMessage('process-tick', '*');
1925
- };
2248
+ draining = false;
2249
+ }
2250
+ process.nextTick = function (fun) {
2251
+ queue.push(fun);
2252
+ if (!draining) {
2253
+ setTimeout(drainQueue, 0);
1926
2254
  }
1927
-
1928
- return function nextTick(fn) {
1929
- setTimeout(fn, 0);
1930
- };
1931
- })();
2255
+ };
1932
2256
 
1933
2257
  process.title = 'browser';
1934
2258
  process.browser = true;
1935
2259
  process.env = {};
1936
2260
  process.argv = [];
2261
+ process.version = ''; // empty string to avoid regexp issues
1937
2262
 
1938
2263
  function noop() {}
1939
2264
 
@@ -1954,35 +2279,8 @@ process.cwd = function () { return '/' };
1954
2279
  process.chdir = function (dir) {
1955
2280
  throw new Error('process.chdir is not supported');
1956
2281
  };
2282
+ process.umask = function() { return 0; };
1957
2283
 
1958
- },{}],8:[function(_dereq_,module,exports){
1959
- var Base62 = (function (my) {
1960
- 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"]
1961
-
1962
- my.encode = function(i){
1963
- if (i === 0) {return '0'}
1964
- var s = ''
1965
- while (i > 0) {
1966
- s = this.chars[i % 62] + s
1967
- i = Math.floor(i/62)
1968
- }
1969
- return s
1970
- };
1971
- my.decode = function(a,b,c,d){
1972
- for (
1973
- b = c = (
1974
- a === (/\W|_|^$/.test(a += "") || a)
1975
- ) - 1;
1976
- d = a.charCodeAt(c++);
1977
- )
1978
- b = b * 62 + d - [, 48, 29, 87][d >> 5];
1979
- return b
1980
- };
1981
-
1982
- return my;
1983
- }({}));
1984
-
1985
- module.exports = Base62
1986
2284
  },{}],9:[function(_dereq_,module,exports){
1987
2285
  /*
1988
2286
  Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
@@ -2018,6 +2316,7 @@ module.exports = Base62
2018
2316
 
2019
2317
  /*jslint bitwise:true plusplus:true */
2020
2318
  /*global esprima:true, define:true, exports:true, window: true,
2319
+ throwErrorTolerant: true,
2021
2320
  throwError: true, generateStatement: true, peek: true,
2022
2321
  parseAssignmentExpression: true, parseBlock: true,
2023
2322
  parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
@@ -2037,6 +2336,7 @@ parseFunctionTypeParam: true,
2037
2336
  parsePrimaryType: true,
2038
2337
  parseTypeAlias: true,
2039
2338
  parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
2339
+ parseTypeParameterDeclaration: true,
2040
2340
  parseYieldExpression: true, parseAwaitExpression: true
2041
2341
  */
2042
2342
 
@@ -2045,6 +2345,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2045
2345
 
2046
2346
  // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
2047
2347
  // Rhino, and plain browser loading.
2348
+
2349
+ /* istanbul ignore next */
2048
2350
  if (typeof define === 'function' && define.amd) {
2049
2351
  define(['exports'], factory);
2050
2352
  } else if (typeof exports !== 'undefined') {
@@ -2200,6 +2502,7 @@ parseYieldExpression: true, parseAwaitExpression: true
2200
2502
  TryStatement: 'TryStatement',
2201
2503
  TypeAlias: 'TypeAlias',
2202
2504
  TypeAnnotation: 'TypeAnnotation',
2505
+ TypeCastExpression: 'TypeCastExpression',
2203
2506
  TypeofTypeAnnotation: 'TypeofTypeAnnotation',
2204
2507
  TypeParameterDeclaration: 'TypeParameterDeclaration',
2205
2508
  TypeParameterInstantiation: 'TypeParameterInstantiation',
@@ -2285,6 +2588,8 @@ parseYieldExpression: true, parseAwaitExpression: true
2285
2588
  MissingFromClause: 'Missing from clause',
2286
2589
  NoAsAfterImportNamespace: 'Missing as after import *',
2287
2590
  InvalidModuleSpecifier: 'Invalid module specifier',
2591
+ IllegalImportDeclaration: 'Illegal import declaration',
2592
+ IllegalExportDeclaration: 'Illegal export declaration',
2288
2593
  NoUnintializedConst: 'Const must be initialized',
2289
2594
  ComprehensionRequiresBlock: 'Comprehension must have at least one block',
2290
2595
  ComprehensionError: 'Comprehension Error',
@@ -2313,11 +2618,37 @@ parseYieldExpression: true, parseAwaitExpression: true
2313
2618
  // Do NOT use this to enforce a certain condition on any user input.
2314
2619
 
2315
2620
  function assert(condition, message) {
2621
+ /* istanbul ignore if */
2316
2622
  if (!condition) {
2317
2623
  throw new Error('ASSERT: ' + message);
2318
2624
  }
2319
2625
  }
2320
2626
 
2627
+ function StringMap() {
2628
+ this.$data = {};
2629
+ }
2630
+
2631
+ StringMap.prototype.get = function (key) {
2632
+ key = '$' + key;
2633
+ return this.$data[key];
2634
+ };
2635
+
2636
+ StringMap.prototype.set = function (key, value) {
2637
+ key = '$' + key;
2638
+ this.$data[key] = value;
2639
+ return this;
2640
+ };
2641
+
2642
+ StringMap.prototype.has = function (key) {
2643
+ key = '$' + key;
2644
+ return Object.prototype.hasOwnProperty.call(this.$data, key);
2645
+ };
2646
+
2647
+ StringMap.prototype['delete'] = function (key) {
2648
+ key = '$' + key;
2649
+ return delete this.$data[key];
2650
+ };
2651
+
2321
2652
  function isDecimalDigit(ch) {
2322
2653
  return (ch >= 48 && ch <= 57); // 0..9
2323
2654
  }
@@ -2678,6 +3009,23 @@ parseYieldExpression: true, parseAwaitExpression: true
2678
3009
  ch3,
2679
3010
  ch4;
2680
3011
 
3012
+ if (state.inXJSTag || state.inXJSChild) {
3013
+ // Don't need to check for '{' and '}' as it's already handled
3014
+ // correctly by default.
3015
+ switch (code) {
3016
+ case 60: // <
3017
+ case 62: // >
3018
+ ++index;
3019
+ return {
3020
+ type: Token.Punctuator,
3021
+ value: String.fromCharCode(code),
3022
+ lineNumber: lineNumber,
3023
+ lineStart: lineStart,
3024
+ range: [start, index]
3025
+ };
3026
+ }
3027
+ }
3028
+
2681
3029
  switch (code) {
2682
3030
  // Check for most common single-character punctuators.
2683
3031
  case 40: // ( open bracket
@@ -2980,6 +3328,7 @@ parseYieldExpression: true, parseAwaitExpression: true
2980
3328
 
2981
3329
  if (index < length) {
2982
3330
  ch = source.charCodeAt(index);
3331
+ /* istanbul ignore else */
2983
3332
  if (isIdentifierStart(ch) || isDecimalDigit(ch)) {
2984
3333
  throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2985
3334
  }
@@ -3110,6 +3459,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3110
3459
  octal = true;
3111
3460
  }
3112
3461
 
3462
+ /* istanbul ignore else */
3113
3463
  if (index < length && isOctalDigit(source[index])) {
3114
3464
  octal = true;
3115
3465
  code = code * 8 + '01234567'.indexOf(source[index++]);
@@ -3226,6 +3576,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3226
3576
  octal = true;
3227
3577
  }
3228
3578
 
3579
+ /* istanbul ignore else */
3229
3580
  if (index < length && isOctalDigit(source[index])) {
3230
3581
  octal = true;
3231
3582
  code = code * 8 + '01234567'.indexOf(source[index++]);
@@ -3358,6 +3709,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3358
3709
  ++index;
3359
3710
  restore = index;
3360
3711
  ch = scanHexEscape('u');
3712
+ /* istanbul ignore else */
3361
3713
  if (ch) {
3362
3714
  flags += ch;
3363
3715
  for (str += '\\u'; restore < index; ++restore) {
@@ -3368,6 +3720,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3368
3720
  flags += 'u';
3369
3721
  str += '\\u';
3370
3722
  }
3723
+ throwErrorTolerant({}, Messages.UnexpectedToken, 'ILLEGAL');
3371
3724
  } else {
3372
3725
  str += '\\';
3373
3726
  }
@@ -3380,11 +3733,20 @@ parseYieldExpression: true, parseAwaitExpression: true
3380
3733
  tmp = pattern;
3381
3734
  if (flags.indexOf('u') >= 0) {
3382
3735
  // Replace each astral symbol and every Unicode code point
3383
- // escape sequence that represents such a symbol with a single
3384
- // ASCII symbol to avoid throwing on regular expressions that
3385
- // are only valid in combination with the `/u` flag.
3736
+ // escape sequence with a single ASCII symbol to avoid throwing on
3737
+ // regular expressions that are only valid in combination with the
3738
+ // `/u` flag.
3739
+ // Note: replacing with the ASCII symbol `x` might cause false
3740
+ // negatives in unlikely scenarios. For example, `[\u{61}-b]` is a
3741
+ // perfectly valid pattern that is equivalent to `[a-b]`, but it
3742
+ // would be replaced by `[x-b]` which throws an error.
3386
3743
  tmp = tmp
3387
- .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
3744
+ .replace(/\\u\{([0-9a-fA-F]+)\}/g, function ($0, $1) {
3745
+ if (parseInt($1, 16) <= 0x10FFFF) {
3746
+ return 'x';
3747
+ }
3748
+ throwError({}, Messages.InvalidRegExp);
3749
+ })
3388
3750
  .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
3389
3751
  }
3390
3752
 
@@ -3404,8 +3766,6 @@ parseYieldExpression: true, parseAwaitExpression: true
3404
3766
  value = null;
3405
3767
  }
3406
3768
 
3407
- peek();
3408
-
3409
3769
  if (extra.tokenize) {
3410
3770
  return {
3411
3771
  type: Token.RegularExpression,
@@ -3597,6 +3957,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3597
3957
  var adv, pos, line, start, result;
3598
3958
 
3599
3959
  // If we are collecting the tokens, don't grab the next one yet.
3960
+ /* istanbul ignore next */
3600
3961
  adv = (typeof extra.advance === 'function') ? extra.advance : advance;
3601
3962
 
3602
3963
  pos = index;
@@ -3604,6 +3965,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3604
3965
  start = lineStart;
3605
3966
 
3606
3967
  // Scan for the next immediate token.
3968
+ /* istanbul ignore if */
3607
3969
  if (lookahead === null) {
3608
3970
  lookahead = adv();
3609
3971
  }
@@ -3649,6 +4011,7 @@ parseYieldExpression: true, parseAwaitExpression: true
3649
4011
  last = bottomRight[bottomRight.length - 1];
3650
4012
 
3651
4013
  if (node.type === Syntax.Program) {
4014
+ /* istanbul ignore else */
3652
4015
  if (node.body.length > 0) {
3653
4016
  return;
3654
4017
  }
@@ -3918,6 +4281,14 @@ parseYieldExpression: true, parseAwaitExpression: true
3918
4281
  };
3919
4282
  },
3920
4283
 
4284
+ createTypeCast: function (expression, typeAnnotation) {
4285
+ return {
4286
+ type: Syntax.TypeCastExpression,
4287
+ expression: expression,
4288
+ typeAnnotation: typeAnnotation
4289
+ };
4290
+ },
4291
+
3921
4292
  createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
3922
4293
  return {
3923
4294
  type: Syntax.FunctionTypeAnnotation,
@@ -4449,13 +4820,14 @@ parseYieldExpression: true, parseAwaitExpression: true
4449
4820
  return arrowExpr;
4450
4821
  },
4451
4822
 
4452
- createMethodDefinition: function (propertyType, kind, key, value) {
4823
+ createMethodDefinition: function (propertyType, kind, key, value, computed) {
4453
4824
  return {
4454
4825
  type: Syntax.MethodDefinition,
4455
4826
  key: key,
4456
4827
  value: value,
4457
4828
  kind: kind,
4458
- 'static': propertyType === ClassPropertyType["static"]
4829
+ 'static': propertyType === ClassPropertyType["static"],
4830
+ computed: computed
4459
4831
  };
4460
4832
  },
4461
4833
 
@@ -4562,11 +4934,12 @@ parseYieldExpression: true, parseAwaitExpression: true
4562
4934
  };
4563
4935
  },
4564
4936
 
4565
- createImportDeclaration: function (specifiers, source) {
4937
+ createImportDeclaration: function (specifiers, source, isType) {
4566
4938
  return {
4567
4939
  type: Syntax.ImportDeclaration,
4568
4940
  specifiers: specifiers,
4569
- source: source
4941
+ source: source,
4942
+ isType: isType
4570
4943
  };
4571
4944
  },
4572
4945
 
@@ -4986,10 +5359,10 @@ parseYieldExpression: true, parseAwaitExpression: true
4986
5359
 
4987
5360
  function parseObjectProperty() {
4988
5361
  var token, key, id, value, param, expr, computed,
4989
- marker = markerCreate(), returnType;
5362
+ marker = markerCreate(), returnType, typeParameters;
4990
5363
 
4991
5364
  token = lookahead;
4992
- computed = (token.value === '[');
5365
+ computed = (token.value === '[' && token.type === Token.Punctuator);
4993
5366
 
4994
5367
  if (token.type === Token.Identifier || computed || matchAsync()) {
4995
5368
  id = parseObjectPropertyKey();
@@ -5010,7 +5383,10 @@ parseYieldExpression: true, parseAwaitExpression: true
5010
5383
  );
5011
5384
  }
5012
5385
 
5013
- if (match('(')) {
5386
+ if (match('(') || match('<')) {
5387
+ if (match('<')) {
5388
+ typeParameters = parseTypeParameterDeclaration();
5389
+ }
5014
5390
  return markerApply(
5015
5391
  marker,
5016
5392
  delegate.createProperty(
@@ -5018,7 +5394,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5018
5394
  id,
5019
5395
  parsePropertyMethodFunction({
5020
5396
  generator: false,
5021
- async: false
5397
+ async: false,
5398
+ typeParameters: typeParameters
5022
5399
  }),
5023
5400
  true,
5024
5401
  false,
@@ -5091,6 +5468,10 @@ parseYieldExpression: true, parseAwaitExpression: true
5091
5468
  computed = (lookahead.value === '[');
5092
5469
  key = parseObjectPropertyKey();
5093
5470
 
5471
+ if (match('<')) {
5472
+ typeParameters = parseTypeParameterDeclaration();
5473
+ }
5474
+
5094
5475
  return markerApply(
5095
5476
  marker,
5096
5477
  delegate.createProperty(
@@ -5098,7 +5479,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5098
5479
  key,
5099
5480
  parsePropertyMethodFunction({
5100
5481
  generator: false,
5101
- async: true
5482
+ async: true,
5483
+ typeParameters: typeParameters
5102
5484
  }),
5103
5485
  true,
5104
5486
  false,
@@ -5128,19 +5510,46 @@ parseYieldExpression: true, parseAwaitExpression: true
5128
5510
 
5129
5511
  id = parseObjectPropertyKey();
5130
5512
 
5513
+ if (match('<')) {
5514
+ typeParameters = parseTypeParameterDeclaration();
5515
+ }
5516
+
5131
5517
  if (!match('(')) {
5132
5518
  throwUnexpected(lex());
5133
5519
  }
5134
5520
 
5135
- return markerApply(marker, delegate.createProperty('init', id, parsePropertyMethodFunction({ generator: true }), true, false, computed));
5521
+ return markerApply(marker, delegate.createProperty(
5522
+ 'init',
5523
+ id,
5524
+ parsePropertyMethodFunction({
5525
+ generator: true,
5526
+ typeParameters: typeParameters
5527
+ }),
5528
+ true,
5529
+ false,
5530
+ computed
5531
+ ));
5136
5532
  }
5137
5533
  key = parseObjectPropertyKey();
5138
5534
  if (match(':')) {
5139
5535
  lex();
5140
5536
  return markerApply(marker, delegate.createProperty('init', key, parseAssignmentExpression(), false, false, false));
5141
5537
  }
5142
- if (match('(')) {
5143
- return markerApply(marker, delegate.createProperty('init', key, parsePropertyMethodFunction({ generator: false }), true, false, false));
5538
+ if (match('(') || match('<')) {
5539
+ if (match('<')) {
5540
+ typeParameters = parseTypeParameterDeclaration();
5541
+ }
5542
+ return markerApply(marker, delegate.createProperty(
5543
+ 'init',
5544
+ key,
5545
+ parsePropertyMethodFunction({
5546
+ generator: false,
5547
+ typeParameters: typeParameters
5548
+ }),
5549
+ true,
5550
+ false,
5551
+ false
5552
+ ));
5144
5553
  }
5145
5554
  throwUnexpected(lex());
5146
5555
  }
@@ -5151,9 +5560,17 @@ parseYieldExpression: true, parseAwaitExpression: true
5151
5560
  return markerApply(marker, delegate.createSpreadProperty(parseAssignmentExpression()));
5152
5561
  }
5153
5562
 
5563
+ function getFieldName(key) {
5564
+ var toString = String;
5565
+ if (key.type === Syntax.Identifier) {
5566
+ return key.name;
5567
+ }
5568
+ return toString(key.value);
5569
+ }
5570
+
5154
5571
  function parseObjectInitialiser() {
5155
- var properties = [], property, name, key, kind, map = {}, toString = String,
5156
- marker = markerCreate();
5572
+ var properties = [], property, name, kind, storedKind, map = new StringMap(),
5573
+ marker = markerCreate(), toString = String;
5157
5574
 
5158
5575
  expect('{');
5159
5576
 
@@ -5170,9 +5587,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5170
5587
  }
5171
5588
  kind = (property.kind === 'init') ? PropertyKind.Data : (property.kind === 'get') ? PropertyKind.Get : PropertyKind.Set;
5172
5589
 
5173
- key = '$' + name;
5174
- if (Object.prototype.hasOwnProperty.call(map, key)) {
5175
- if (map[key] === PropertyKind.Data) {
5590
+ if (map.has(name)) {
5591
+ storedKind = map.get(name);
5592
+ if (storedKind === PropertyKind.Data) {
5176
5593
  if (strict && kind === PropertyKind.Data) {
5177
5594
  throwErrorTolerant({}, Messages.StrictDuplicateProperty);
5178
5595
  } else if (kind !== PropertyKind.Data) {
@@ -5181,13 +5598,13 @@ parseYieldExpression: true, parseAwaitExpression: true
5181
5598
  } else {
5182
5599
  if (kind === PropertyKind.Data) {
5183
5600
  throwErrorTolerant({}, Messages.AccessorDataProperty);
5184
- } else if (map[key] & kind) {
5601
+ } else if (storedKind & kind) {
5185
5602
  throwErrorTolerant({}, Messages.AccessorGetSet);
5186
5603
  }
5187
5604
  }
5188
- map[key] |= kind;
5605
+ map.set(name, storedKind | kind);
5189
5606
  } else {
5190
- map[key] = kind;
5607
+ map.set(name, kind);
5191
5608
  }
5192
5609
  }
5193
5610
 
@@ -5231,14 +5648,24 @@ parseYieldExpression: true, parseAwaitExpression: true
5231
5648
  // 11.1.6 The Grouping Operator
5232
5649
 
5233
5650
  function parseGroupExpression() {
5234
- var expr;
5651
+ var expr, marker, typeAnnotation;
5235
5652
 
5236
5653
  expect('(');
5237
5654
 
5238
5655
  ++state.parenthesizedCount;
5239
5656
 
5657
+ marker = markerCreate();
5658
+
5240
5659
  expr = parseExpression();
5241
5660
 
5661
+ if (match(':')) {
5662
+ typeAnnotation = parseTypeAnnotation();
5663
+ expr = markerApply(marker, delegate.createTypeCast(
5664
+ expr,
5665
+ typeAnnotation
5666
+ ));
5667
+ }
5668
+
5242
5669
  expect(')');
5243
5670
 
5244
5671
  return expr;
@@ -5327,7 +5754,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5327
5754
 
5328
5755
  if (match('/') || match('/=')) {
5329
5756
  marker = markerCreate();
5330
- return markerApply(marker, delegate.createLiteral(scanRegExp()));
5757
+ expr = delegate.createLiteral(scanRegExp());
5758
+ peek();
5759
+ return markerApply(marker, expr);
5331
5760
  }
5332
5761
 
5333
5762
  if (type === Token.Template) {
@@ -5695,6 +6124,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5695
6124
 
5696
6125
  // 11.13 Assignment Operators
5697
6126
 
6127
+ // 12.14.5 AssignmentPattern
6128
+
5698
6129
  function reinterpretAsAssignmentBindingPattern(expr) {
5699
6130
  var i, len, property, element;
5700
6131
 
@@ -5718,6 +6149,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5718
6149
  expr.type = Syntax.ArrayPattern;
5719
6150
  for (i = 0, len = expr.elements.length; i < len; i += 1) {
5720
6151
  element = expr.elements[i];
6152
+ /* istanbul ignore else */
5721
6153
  if (element) {
5722
6154
  reinterpretAsAssignmentBindingPattern(element);
5723
6155
  }
@@ -5732,12 +6164,14 @@ parseYieldExpression: true, parseAwaitExpression: true
5732
6164
  throwError({}, Messages.ObjectPatternAsSpread);
5733
6165
  }
5734
6166
  } else {
6167
+ /* istanbul ignore else */
5735
6168
  if (expr.type !== Syntax.MemberExpression && expr.type !== Syntax.CallExpression && expr.type !== Syntax.NewExpression) {
5736
6169
  throwError({}, Messages.InvalidLHSInAssignment);
5737
6170
  }
5738
6171
  }
5739
6172
  }
5740
6173
 
6174
+ // 13.2.3 BindingPattern
5741
6175
 
5742
6176
  function reinterpretAsDestructuredParameter(options, expr) {
5743
6177
  var i, len, property, element;
@@ -5768,10 +6202,14 @@ parseYieldExpression: true, parseAwaitExpression: true
5768
6202
  }
5769
6203
  } else if (expr.type === Syntax.Identifier) {
5770
6204
  validateParam(options, expr, expr.name);
5771
- } else {
5772
- if (expr.type !== Syntax.MemberExpression) {
6205
+ } else if (expr.type === Syntax.SpreadElement) {
6206
+ // BindingRestElement only allows BindingIdentifier
6207
+ if (expr.argument.type !== Syntax.Identifier) {
5773
6208
  throwError({}, Messages.InvalidLHSInFormalsList);
5774
6209
  }
6210
+ validateParam(options, expr.argument, expr.argument.name);
6211
+ } else {
6212
+ throwError({}, Messages.InvalidLHSInFormalsList);
5775
6213
  }
5776
6214
  }
5777
6215
 
@@ -5783,7 +6221,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5783
6221
  defaultCount = 0;
5784
6222
  rest = null;
5785
6223
  options = {
5786
- paramSet: {}
6224
+ paramSet: new StringMap()
5787
6225
  };
5788
6226
 
5789
6227
  for (i = 0, len = expressions.length; i < len; i += 1) {
@@ -5798,6 +6236,9 @@ parseYieldExpression: true, parseAwaitExpression: true
5798
6236
  defaults.push(null);
5799
6237
  } else if (param.type === Syntax.SpreadElement) {
5800
6238
  assert(i === len - 1, 'It is guaranteed that SpreadElement is last element by parseExpression');
6239
+ if (param.argument.type !== Syntax.Identifier) {
6240
+ throwError({}, Messages.InvalidLHSInFormalsList);
6241
+ }
5801
6242
  reinterpretAsDestructuredParameter(options, param.argument);
5802
6243
  rest = param.argument;
5803
6244
  } else if (param.type === Syntax.AssignmentExpression) {
@@ -5866,7 +6307,8 @@ parseYieldExpression: true, parseAwaitExpression: true
5866
6307
 
5867
6308
  function parseAssignmentExpression() {
5868
6309
  var marker, expr, token, params, oldParenthesizedCount,
5869
- backtrackToken = lookahead, possiblyAsync = false;
6310
+ startsWithParen = false, backtrackToken = lookahead,
6311
+ possiblyAsync = false;
5870
6312
 
5871
6313
  if (matchYield()) {
5872
6314
  return parseYieldExpression();
@@ -5903,6 +6345,7 @@ parseYieldExpression: true, parseAwaitExpression: true
5903
6345
  params.async = possiblyAsync;
5904
6346
  return parseArrowFunctionExpression(params, marker);
5905
6347
  }
6348
+ startsWithParen = true;
5906
6349
  }
5907
6350
 
5908
6351
  token = lookahead;
@@ -5922,6 +6365,13 @@ parseYieldExpression: true, parseAwaitExpression: true
5922
6365
  state.parenthesizedCount === (oldParenthesizedCount + 1))) {
5923
6366
  if (expr.type === Syntax.Identifier) {
5924
6367
  params = reinterpretAsCoverFormalsList([ expr ]);
6368
+ } else if (expr.type === Syntax.AssignmentExpression ||
6369
+ expr.type === Syntax.ArrayExpression ||
6370
+ expr.type === Syntax.ObjectExpression) {
6371
+ if (!startsWithParen) {
6372
+ throwUnexpected(lex());
6373
+ }
6374
+ params = reinterpretAsCoverFormalsList([ expr ]);
5925
6375
  } else if (expr.type === Syntax.SequenceExpression) {
5926
6376
  params = reinterpretAsCoverFormalsList(expr.expressions);
5927
6377
  }
@@ -5992,18 +6442,6 @@ parseYieldExpression: true, parseAwaitExpression: true
5992
6442
  sequence = markerApply(marker, delegate.createSequenceExpression(expressions));
5993
6443
  }
5994
6444
 
5995
- if (match('=>')) {
5996
- // Do not allow nested parentheses on the LHS of the =>.
5997
- if (state.parenthesizedCount === oldParenthesizedCount || state.parenthesizedCount === (oldParenthesizedCount + 1)) {
5998
- expr = expr.type === Syntax.SequenceExpression ? expr.expressions : expressions;
5999
- coverFormalsList = reinterpretAsCoverFormalsList(expr);
6000
- if (coverFormalsList) {
6001
- return parseArrowFunctionExpression(coverFormalsList, marker);
6002
- }
6003
- }
6004
- throwUnexpected(lex());
6005
- }
6006
-
6007
6445
  if (spreadFound && lookahead2().value !== '=>') {
6008
6446
  throwError({}, Messages.IllegalSpread);
6009
6447
  }
@@ -6155,13 +6593,18 @@ parseYieldExpression: true, parseAwaitExpression: true
6155
6593
  function parseObjectType(allowStatic) {
6156
6594
  var callProperties = [], indexers = [], marker, optional = false,
6157
6595
  properties = [], property, propertyKey, propertyTypeAnnotation,
6158
- token, isStatic;
6596
+ token, isStatic, matchStatic;
6159
6597
 
6160
6598
  expect('{');
6161
6599
 
6162
6600
  while (!match('}')) {
6163
6601
  marker = markerCreate();
6164
- if (allowStatic && matchContextualKeyword('static')) {
6602
+ matchStatic =
6603
+ strict
6604
+ ? matchKeyword('static')
6605
+ : matchContextualKeyword('static');
6606
+
6607
+ if (allowStatic && matchStatic) {
6165
6608
  token = lex();
6166
6609
  isStatic = true;
6167
6610
  }
@@ -6541,6 +6984,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6541
6984
  markerApply(typeAnnotationMarker, id);
6542
6985
  }
6543
6986
  } else {
6987
+ /* istanbul ignore next */
6544
6988
  id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
6545
6989
  // 12.2.1
6546
6990
  if (strict && isRestrictedWord(id.name)) {
@@ -6695,10 +7139,11 @@ parseYieldExpression: true, parseAwaitExpression: true
6695
7139
  }
6696
7140
 
6697
7141
  // non-default export
6698
- if (lookahead.type === Token.Keyword) {
7142
+ if (lookahead.type === Token.Keyword || matchContextualKeyword('type')) {
6699
7143
  // covers:
6700
7144
  // export var f = 1;
6701
7145
  switch (lookahead.value) {
7146
+ case 'type':
6702
7147
  case 'let':
6703
7148
  case 'const':
6704
7149
  case 'var':
@@ -6725,10 +7170,12 @@ parseYieldExpression: true, parseAwaitExpression: true
6725
7170
  }
6726
7171
 
6727
7172
  expect('{');
6728
- do {
6729
- isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
6730
- specifiers.push(parseExportSpecifier());
6731
- } while (match(',') && lex());
7173
+ if (!match('}')) {
7174
+ do {
7175
+ isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
7176
+ specifiers.push(parseExportSpecifier());
7177
+ } while (match(',') && lex());
7178
+ }
6732
7179
  expect('}');
6733
7180
 
6734
7181
  if (matchContextualKeyword('from')) {
@@ -6769,9 +7216,11 @@ parseYieldExpression: true, parseAwaitExpression: true
6769
7216
  var specifiers = [];
6770
7217
  // {foo, bar as bas}
6771
7218
  expect('{');
6772
- do {
6773
- specifiers.push(parseImportSpecifier());
6774
- } while (match(',') && lex());
7219
+ if (!match('}')) {
7220
+ do {
7221
+ specifiers.push(parseImportSpecifier());
7222
+ } while (match(',') && lex());
7223
+ }
6775
7224
  expect('}');
6776
7225
  return specifiers;
6777
7226
  }
@@ -6800,9 +7249,20 @@ parseYieldExpression: true, parseAwaitExpression: true
6800
7249
  }
6801
7250
 
6802
7251
  function parseImportDeclaration() {
6803
- var specifiers, src, marker = markerCreate();
7252
+ var specifiers, src, marker = markerCreate(), isType = false, token2;
6804
7253
 
6805
7254
  expectKeyword('import');
7255
+
7256
+ if (matchContextualKeyword('type')) {
7257
+ token2 = lookahead2();
7258
+ if ((token2.type === Token.Identifier && token2.value !== 'from') ||
7259
+ (token2.type === Token.Punctuator &&
7260
+ (token2.value === '{' || token2.value === '*'))) {
7261
+ isType = true;
7262
+ lex();
7263
+ }
7264
+ }
7265
+
6806
7266
  specifiers = [];
6807
7267
 
6808
7268
  if (lookahead.type === Token.StringLiteral) {
@@ -6810,7 +7270,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6810
7270
  // import "foo";
6811
7271
  src = parseModuleSpecifier();
6812
7272
  consumeSemicolon();
6813
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
7273
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
6814
7274
  }
6815
7275
 
6816
7276
  if (!matchKeyword('default') && isIdentifierName(lookahead)) {
@@ -6842,7 +7302,7 @@ parseYieldExpression: true, parseAwaitExpression: true
6842
7302
  src = parseModuleSpecifier();
6843
7303
  consumeSemicolon();
6844
7304
 
6845
- return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
7305
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src, isType));
6846
7306
  }
6847
7307
 
6848
7308
  // 12.3 Empty Statement
@@ -7039,7 +7499,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7039
7499
  // 12.7 The continue statement
7040
7500
 
7041
7501
  function parseContinueStatement() {
7042
- var label = null, key, marker = markerCreate();
7502
+ var label = null, marker = markerCreate();
7043
7503
 
7044
7504
  expectKeyword('continue');
7045
7505
 
@@ -7065,8 +7525,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7065
7525
  if (lookahead.type === Token.Identifier) {
7066
7526
  label = parseVariableIdentifier();
7067
7527
 
7068
- key = '$' + label.name;
7069
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7528
+ if (!state.labelSet.has(label.name)) {
7070
7529
  throwError({}, Messages.UnknownLabel, label.name);
7071
7530
  }
7072
7531
  }
@@ -7083,7 +7542,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7083
7542
  // 12.8 The break statement
7084
7543
 
7085
7544
  function parseBreakStatement() {
7086
- var label = null, key, marker = markerCreate();
7545
+ var label = null, marker = markerCreate();
7087
7546
 
7088
7547
  expectKeyword('break');
7089
7548
 
@@ -7109,8 +7568,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7109
7568
  if (lookahead.type === Token.Identifier) {
7110
7569
  label = parseVariableIdentifier();
7111
7570
 
7112
- key = '$' + label.name;
7113
- if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7571
+ if (!state.labelSet.has(label.name)) {
7114
7572
  throwError({}, Messages.UnknownLabel, label.name);
7115
7573
  }
7116
7574
  }
@@ -7338,8 +7796,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7338
7796
  var type = lookahead.type,
7339
7797
  marker,
7340
7798
  expr,
7341
- labeledBody,
7342
- key;
7799
+ labeledBody;
7343
7800
 
7344
7801
  if (type === Token.EOF) {
7345
7802
  throwUnexpected(lookahead);
@@ -7406,14 +7863,13 @@ parseYieldExpression: true, parseAwaitExpression: true
7406
7863
  if ((expr.type === Syntax.Identifier) && match(':')) {
7407
7864
  lex();
7408
7865
 
7409
- key = '$' + expr.name;
7410
- if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) {
7866
+ if (state.labelSet.has(expr.name)) {
7411
7867
  throwError({}, Messages.Redeclaration, 'Label', expr.name);
7412
7868
  }
7413
7869
 
7414
- state.labelSet[key] = true;
7870
+ state.labelSet.set(expr.name, true);
7415
7871
  labeledBody = parseStatement();
7416
- delete state.labelSet[key];
7872
+ state.labelSet['delete'](expr.name);
7417
7873
  return markerApply(marker, delegate.createLabeledStatement(expr, labeledBody));
7418
7874
  }
7419
7875
 
@@ -7469,7 +7925,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7469
7925
  oldInFunctionBody = state.inFunctionBody;
7470
7926
  oldParenthesizedCount = state.parenthesizedCount;
7471
7927
 
7472
- state.labelSet = {};
7928
+ state.labelSet = new StringMap();
7473
7929
  state.inIteration = false;
7474
7930
  state.inSwitch = false;
7475
7931
  state.inFunctionBody = true;
@@ -7498,13 +7954,12 @@ parseYieldExpression: true, parseAwaitExpression: true
7498
7954
  }
7499
7955
 
7500
7956
  function validateParam(options, param, name) {
7501
- var key = '$' + name;
7502
7957
  if (strict) {
7503
7958
  if (isRestrictedWord(name)) {
7504
7959
  options.stricted = param;
7505
7960
  options.message = Messages.StrictParamName;
7506
7961
  }
7507
- if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
7962
+ if (options.paramSet.has(name)) {
7508
7963
  options.stricted = param;
7509
7964
  options.message = Messages.StrictParamDupe;
7510
7965
  }
@@ -7515,12 +7970,12 @@ parseYieldExpression: true, parseAwaitExpression: true
7515
7970
  } else if (isStrictModeReservedWord(name)) {
7516
7971
  options.firstRestricted = param;
7517
7972
  options.message = Messages.StrictReservedWord;
7518
- } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
7973
+ } else if (options.paramSet.has(name)) {
7519
7974
  options.firstRestricted = param;
7520
7975
  options.message = Messages.StrictParamDupe;
7521
7976
  }
7522
7977
  }
7523
- options.paramSet[key] = true;
7978
+ options.paramSet.set(name, true);
7524
7979
  }
7525
7980
 
7526
7981
  function parseParam(options) {
@@ -7602,7 +8057,7 @@ parseYieldExpression: true, parseAwaitExpression: true
7602
8057
  expect('(');
7603
8058
 
7604
8059
  if (!match(')')) {
7605
- options.paramSet = {};
8060
+ options.paramSet = new StringMap();
7606
8061
  while (index < length) {
7607
8062
  if (!parseParam(options)) {
7608
8063
  break;
@@ -7817,19 +8272,60 @@ parseYieldExpression: true, parseAwaitExpression: true
7817
8272
 
7818
8273
  // 14 Classes
7819
8274
 
8275
+ function validateDuplicateProp(propMap, key, accessor) {
8276
+ var propInfo, reversed, name, isValidDuplicateProp;
8277
+
8278
+ name = getFieldName(key);
8279
+
8280
+ if (propMap.has(name)) {
8281
+ propInfo = propMap.get(name);
8282
+ if (accessor === 'data') {
8283
+ isValidDuplicateProp = false;
8284
+ } else {
8285
+ if (accessor === 'get') {
8286
+ reversed = 'set';
8287
+ } else {
8288
+ reversed = 'get';
8289
+ }
8290
+
8291
+ isValidDuplicateProp =
8292
+ // There isn't already a specified accessor for this prop
8293
+ propInfo[accessor] === undefined
8294
+ // There isn't already a data prop by this name
8295
+ && propInfo.data === undefined
8296
+ // The only existing prop by this name is a reversed accessor
8297
+ && propInfo[reversed] !== undefined;
8298
+ }
8299
+ if (!isValidDuplicateProp) {
8300
+ throwError(key, Messages.IllegalDuplicateClassProperty);
8301
+ }
8302
+ } else {
8303
+ propInfo = {
8304
+ get: undefined,
8305
+ set: undefined,
8306
+ data: undefined
8307
+ };
8308
+ propMap.set(name, propInfo);
8309
+ }
8310
+ propInfo[accessor] = true;
8311
+ }
8312
+
7820
8313
  function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
7821
8314
  var token, param, propType, isValidDuplicateProp = false,
7822
8315
  isAsync, typeParameters, tokenValue, returnType,
7823
- annotationMarker;
8316
+ annotationMarker, propMap;
7824
8317
 
7825
8318
  propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
7826
8319
 
8320
+ propMap = existingPropNames[propType];
8321
+
7827
8322
  if (generator) {
7828
8323
  return delegate.createMethodDefinition(
7829
8324
  propType,
7830
8325
  '',
7831
8326
  key,
7832
- parsePropertyMethodFunction({ generator: true })
8327
+ parsePropertyMethodFunction({ generator: true }),
8328
+ computed
7833
8329
  );
7834
8330
  }
7835
8331
 
@@ -7840,21 +8336,9 @@ parseYieldExpression: true, parseAwaitExpression: true
7840
8336
 
7841
8337
  // It is a syntax error if any other properties have a name
7842
8338
  // duplicating this one unless they are a setter
7843
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
7844
- isValidDuplicateProp =
7845
- // There isn't already a getter for this prop
7846
- existingPropNames[propType][key.name].get === undefined
7847
- // There isn't already a data prop by this name
7848
- && existingPropNames[propType][key.name].data === undefined
7849
- // The only existing prop by this name is a setter
7850
- && existingPropNames[propType][key.name].set !== undefined;
7851
- if (!isValidDuplicateProp) {
7852
- throwError(key, Messages.IllegalDuplicateClassProperty);
7853
- }
7854
- } else {
7855
- existingPropNames[propType][key.name] = {};
8339
+ if (!computed) {
8340
+ validateDuplicateProp(propMap, key, 'get');
7856
8341
  }
7857
- existingPropNames[propType][key.name].get = true;
7858
8342
 
7859
8343
  expect('(');
7860
8344
  expect(')');
@@ -7865,7 +8349,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7865
8349
  propType,
7866
8350
  'get',
7867
8351
  key,
7868
- parsePropertyFunction({ generator: false, returnType: returnType })
8352
+ parsePropertyFunction({ generator: false, returnType: returnType }),
8353
+ computed
7869
8354
  );
7870
8355
  }
7871
8356
  if (tokenValue === 'set' && !match('(')) {
@@ -7873,21 +8358,9 @@ parseYieldExpression: true, parseAwaitExpression: true
7873
8358
 
7874
8359
  // It is a syntax error if any other properties have a name
7875
8360
  // duplicating this one unless they are a getter
7876
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
7877
- isValidDuplicateProp =
7878
- // There isn't already a setter for this prop
7879
- existingPropNames[propType][key.name].set === undefined
7880
- // There isn't already a data prop by this name
7881
- && existingPropNames[propType][key.name].data === undefined
7882
- // The only existing prop by this name is a getter
7883
- && existingPropNames[propType][key.name].get !== undefined;
7884
- if (!isValidDuplicateProp) {
7885
- throwError(key, Messages.IllegalDuplicateClassProperty);
7886
- }
7887
- } else {
7888
- existingPropNames[propType][key.name] = {};
8361
+ if (!computed) {
8362
+ validateDuplicateProp(propMap, key, 'set');
7889
8363
  }
7890
- existingPropNames[propType][key.name].set = true;
7891
8364
 
7892
8365
  expect('(');
7893
8366
  token = lookahead;
@@ -7905,7 +8378,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7905
8378
  generator: false,
7906
8379
  name: token,
7907
8380
  returnType: returnType
7908
- })
8381
+ }),
8382
+ computed
7909
8383
  );
7910
8384
  }
7911
8385
 
@@ -7920,12 +8394,9 @@ parseYieldExpression: true, parseAwaitExpression: true
7920
8394
 
7921
8395
  // It is a syntax error if any other properties have the same name as a
7922
8396
  // non-getter, non-setter method
7923
- if (existingPropNames[propType].hasOwnProperty(key.name)) {
7924
- throwError(key, Messages.IllegalDuplicateClassProperty);
7925
- } else {
7926
- existingPropNames[propType][key.name] = {};
8397
+ if (!computed) {
8398
+ validateDuplicateProp(propMap, key, 'data');
7927
8399
  }
7928
- existingPropNames[propType][key.name].data = true;
7929
8400
 
7930
8401
  return delegate.createMethodDefinition(
7931
8402
  propType,
@@ -7935,7 +8406,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7935
8406
  generator: false,
7936
8407
  async: isAsync,
7937
8408
  typeParameters: typeParameters
7938
- })
8409
+ }),
8410
+ computed
7939
8411
  );
7940
8412
  }
7941
8413
 
@@ -7954,8 +8426,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7954
8426
  }
7955
8427
 
7956
8428
  function parseClassElement(existingProps) {
7957
- var computed, generator = false, key, marker = markerCreate(),
7958
- isStatic = false;
8429
+ var computed = false, generator = false, key, marker = markerCreate(),
8430
+ isStatic = false, possiblyOpenBracketToken;
7959
8431
  if (match(';')) {
7960
8432
  lex();
7961
8433
  return;
@@ -7971,7 +8443,16 @@ parseYieldExpression: true, parseAwaitExpression: true
7971
8443
  generator = true;
7972
8444
  }
7973
8445
 
7974
- computed = (lookahead.value === '[');
8446
+ possiblyOpenBracketToken = lookahead;
8447
+ if (matchContextualKeyword('get') || matchContextualKeyword('set')) {
8448
+ possiblyOpenBracketToken = lookahead2();
8449
+ }
8450
+
8451
+ if (possiblyOpenBracketToken.type === Token.Punctuator
8452
+ && possiblyOpenBracketToken.value === '[') {
8453
+ computed = true;
8454
+ }
8455
+
7975
8456
  key = parseObjectPropertyKey();
7976
8457
 
7977
8458
  if (!generator && lookahead.value === ':') {
@@ -7990,8 +8471,8 @@ parseYieldExpression: true, parseAwaitExpression: true
7990
8471
  function parseClassBody() {
7991
8472
  var classElement, classElements = [], existingProps = {}, marker = markerCreate();
7992
8473
 
7993
- existingProps[ClassPropertyType["static"]] = {};
7994
- existingProps[ClassPropertyType.prototype] = {};
8474
+ existingProps[ClassPropertyType["static"]] = new StringMap();
8475
+ existingProps[ClassPropertyType.prototype] = new StringMap();
7995
8476
 
7996
8477
  expect('{');
7997
8478
 
@@ -8013,7 +8494,11 @@ parseYieldExpression: true, parseAwaitExpression: true
8013
8494
 
8014
8495
  function parseClassImplements() {
8015
8496
  var id, implemented = [], marker, typeParameters;
8016
- expectContextualKeyword('implements');
8497
+ if (strict) {
8498
+ expectKeyword('implements');
8499
+ } else {
8500
+ expectContextualKeyword('implements');
8501
+ }
8017
8502
  while (index < length) {
8018
8503
  marker = markerCreate();
8019
8504
  id = parseVariableIdentifier();
@@ -8036,11 +8521,17 @@ parseYieldExpression: true, parseAwaitExpression: true
8036
8521
 
8037
8522
  function parseClassExpression() {
8038
8523
  var id, implemented, previousYieldAllowed, superClass = null,
8039
- superTypeParameters, marker = markerCreate(), typeParameters;
8524
+ superTypeParameters, marker = markerCreate(), typeParameters,
8525
+ matchImplements;
8040
8526
 
8041
8527
  expectKeyword('class');
8042
8528
 
8043
- if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
8529
+ matchImplements =
8530
+ strict
8531
+ ? matchKeyword('implements')
8532
+ : matchContextualKeyword('implements');
8533
+
8534
+ if (!matchKeyword('extends') && !matchImplements && !match('{')) {
8044
8535
  id = parseVariableIdentifier();
8045
8536
  }
8046
8537
 
@@ -8059,7 +8550,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8059
8550
  state.yieldAllowed = previousYieldAllowed;
8060
8551
  }
8061
8552
 
8062
- if (matchContextualKeyword('implements')) {
8553
+ if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
8063
8554
  implemented = parseClassImplements();
8064
8555
  }
8065
8556
 
@@ -8096,7 +8587,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8096
8587
  state.yieldAllowed = previousYieldAllowed;
8097
8588
  }
8098
8589
 
8099
- if (matchContextualKeyword('implements')) {
8590
+ if (strict ? matchKeyword('implements') : matchContextualKeyword('implements')) {
8100
8591
  implemented = parseClassImplements();
8101
8592
  }
8102
8593
 
@@ -8121,6 +8612,17 @@ parseYieldExpression: true, parseAwaitExpression: true
8121
8612
  return parseConstLetDeclaration(lookahead.value);
8122
8613
  case 'function':
8123
8614
  return parseFunctionDeclaration();
8615
+ case 'export':
8616
+ throwErrorTolerant({}, Messages.IllegalExportDeclaration);
8617
+ return parseExportDeclaration();
8618
+ case 'import':
8619
+ throwErrorTolerant({}, Messages.IllegalImportDeclaration);
8620
+ return parseImportDeclaration();
8621
+ case 'interface':
8622
+ if (lookahead2().type === Token.Identifier) {
8623
+ return parseInterface();
8624
+ }
8625
+ return parseStatement();
8124
8626
  default:
8125
8627
  return parseStatement();
8126
8628
  }
@@ -8159,7 +8661,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8159
8661
  }
8160
8662
 
8161
8663
  function parseProgramElement() {
8162
- if (lookahead.type === Token.Keyword) {
8664
+ var isModule = extra.sourceType === 'module' || extra.sourceType === 'nonStrictModule';
8665
+
8666
+ if (isModule && lookahead.type === Token.Keyword) {
8163
8667
  switch (lookahead.value) {
8164
8668
  case 'export':
8165
8669
  return parseExportDeclaration();
@@ -8211,7 +8715,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8211
8715
 
8212
8716
  function parseProgram() {
8213
8717
  var body, marker = markerCreate();
8214
- strict = false;
8718
+ strict = extra.sourceType === 'module';
8215
8719
  peek();
8216
8720
  body = parseProgramElements();
8217
8721
  return markerApply(marker, delegate.createProgram(body));
@@ -8639,12 +9143,15 @@ parseYieldExpression: true, parseAwaitExpression: true
8639
9143
  if (object.type === Syntax.XJSNamespacedName) {
8640
9144
  return object.namespace.name + ':' + object.name.name;
8641
9145
  }
9146
+ /* istanbul ignore else */
8642
9147
  if (object.type === Syntax.XJSMemberExpression) {
8643
9148
  return (
8644
9149
  getQualifiedXJSName(object.object) + '.' +
8645
9150
  getQualifiedXJSName(object.property)
8646
9151
  );
8647
9152
  }
9153
+ /* istanbul ignore next */
9154
+ throwUnexpected(object);
8648
9155
  }
8649
9156
 
8650
9157
  function isXJSIdentifierStart(ch) {
@@ -8705,6 +9212,7 @@ parseYieldExpression: true, parseAwaitExpression: true
8705
9212
  if (!isNaN(code)) {
8706
9213
  return String.fromCharCode(code);
8707
9214
  }
9215
+ /* istanbul ignore else */
8708
9216
  } else if (XHTMLEntities[str]) {
8709
9217
  return XHTMLEntities[str];
8710
9218
  }
@@ -8778,9 +9286,9 @@ parseYieldExpression: true, parseAwaitExpression: true
8778
9286
  function advanceXJSChild() {
8779
9287
  var ch = source.charCodeAt(index);
8780
9288
 
8781
- // { (123) and < (60)
8782
- if (ch !== 123 && ch !== 60) {
8783
- return scanXJSText(['<', '{']);
9289
+ // '<' 60, '>' 62, '{' 123, '}' 125
9290
+ if (ch !== 60 && ch !== 62 && ch !== 123 && ch !== 125) {
9291
+ return scanXJSText(['<', '>', '{', '}']);
8784
9292
  }
8785
9293
 
8786
9294
  return scanPunctuator();
@@ -8940,8 +9448,10 @@ parseYieldExpression: true, parseAwaitExpression: true
8940
9448
  } else if (lookahead.type === Token.XJSText) {
8941
9449
  marker = markerCreatePreserveWhitespace();
8942
9450
  token = markerApply(marker, delegate.createLiteral(lex()));
8943
- } else {
9451
+ } else if (match('<')) {
8944
9452
  token = parseXJSElement();
9453
+ } else {
9454
+ throwUnexpected(lookahead);
8945
9455
  }
8946
9456
  return token;
8947
9457
  }
@@ -9100,9 +9610,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9100
9610
 
9101
9611
  function parseInterface() {
9102
9612
  var body, bodyMarker, extended = [], id, marker = markerCreate(),
9103
- typeParameters = null;
9613
+ typeParameters = null, previousStrict;
9614
+
9615
+ if (strict) {
9616
+ expectKeyword('interface');
9617
+ } else {
9618
+ expectContextualKeyword('interface');
9619
+ }
9104
9620
 
9105
- expectContextualKeyword('interface');
9106
9621
  return parseInterfaceish(marker, /* allowStatic */false);
9107
9622
  }
9108
9623
 
@@ -9215,6 +9730,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9215
9730
  function collectToken() {
9216
9731
  var start, loc, token, range, value, entry;
9217
9732
 
9733
+ /* istanbul ignore else */
9218
9734
  if (!state.inXJSChild) {
9219
9735
  skipComment();
9220
9736
  }
@@ -9274,6 +9790,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9274
9790
  };
9275
9791
 
9276
9792
  if (!extra.tokenize) {
9793
+ /* istanbul ignore next */
9277
9794
  // Pop the previous token, which is likely '/' or '/='
9278
9795
  if (extra.tokens.length > 0) {
9279
9796
  token = extra.tokens[extra.tokens.length - 1];
@@ -9355,12 +9872,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9355
9872
  var entry, result = {};
9356
9873
 
9357
9874
  for (entry in object) {
9875
+ /* istanbul ignore else */
9358
9876
  if (object.hasOwnProperty(entry)) {
9359
9877
  result[entry] = object[entry];
9360
9878
  }
9361
9879
  }
9362
9880
 
9363
9881
  for (entry in properties) {
9882
+ /* istanbul ignore else */
9364
9883
  if (properties.hasOwnProperty(entry)) {
9365
9884
  result[entry] = properties[entry];
9366
9885
  }
@@ -9389,7 +9908,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9389
9908
  state = {
9390
9909
  allowKeyword: true,
9391
9910
  allowIn: true,
9392
- labelSet: {},
9911
+ labelSet: new StringMap(),
9393
9912
  inFunctionBody: false,
9394
9913
  inIteration: false,
9395
9914
  inSwitch: false,
@@ -9419,17 +9938,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9419
9938
  extra.errors = [];
9420
9939
  }
9421
9940
 
9422
- if (length > 0) {
9423
- if (typeof source[0] === 'undefined') {
9424
- // Try first to convert to a string. This is good as fast path
9425
- // for old IE which understands string indexing for string
9426
- // literals only and not for string object.
9427
- if (code instanceof String) {
9428
- source = code.valueOf();
9429
- }
9430
- }
9431
- }
9432
-
9433
9941
  patch();
9434
9942
 
9435
9943
  try {
@@ -9490,7 +9998,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9490
9998
  state = {
9491
9999
  allowKeyword: false,
9492
10000
  allowIn: true,
9493
- labelSet: {},
10001
+ labelSet: new StringMap(),
9494
10002
  parenthesizedCount: 0,
9495
10003
  inFunctionBody: false,
9496
10004
  inIteration: false,
@@ -9518,6 +10026,7 @@ parseYieldExpression: true, parseAwaitExpression: true
9518
10026
  });
9519
10027
  }
9520
10028
 
10029
+ extra.sourceType = options.sourceType;
9521
10030
  if (typeof options.tokens === 'boolean' && options.tokens) {
9522
10031
  extra.tokens = [];
9523
10032
  }
@@ -9536,17 +10045,6 @@ parseYieldExpression: true, parseAwaitExpression: true
9536
10045
  }
9537
10046
  }
9538
10047
 
9539
- if (length > 0) {
9540
- if (typeof source[0] === 'undefined') {
9541
- // Try first to convert to a string. This is good as fast path
9542
- // for old IE which understands string indexing for string
9543
- // literals only and not for string object.
9544
- if (code instanceof String) {
9545
- source = code.valueOf();
9546
- }
9547
- }
9548
- }
9549
-
9550
10048
  patch();
9551
10049
  try {
9552
10050
  program = parseProgram();
@@ -9571,13 +10069,14 @@ parseYieldExpression: true, parseAwaitExpression: true
9571
10069
  }
9572
10070
 
9573
10071
  // Sync with *.json manifests.
9574
- exports.version = '8001.1001.0-dev-harmony-fb';
10072
+ exports.version = '12001.1.0-dev-harmony-fb';
9575
10073
 
9576
10074
  exports.tokenize = tokenize;
9577
10075
 
9578
10076
  exports.parse = parse;
9579
10077
 
9580
10078
  // Deep copy.
10079
+ /* istanbul ignore next */
9581
10080
  exports.Syntax = (function () {
9582
10081
  var name, types = {};
9583
10082
 
@@ -9602,6 +10101,34 @@ parseYieldExpression: true, parseAwaitExpression: true
9602
10101
  /* vim: set sw=4 ts=4 et tw=80 : */
9603
10102
 
9604
10103
  },{}],10:[function(_dereq_,module,exports){
10104
+ var Base62 = (function (my) {
10105
+ 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"]
10106
+
10107
+ my.encode = function(i){
10108
+ if (i === 0) {return '0'}
10109
+ var s = ''
10110
+ while (i > 0) {
10111
+ s = this.chars[i % 62] + s
10112
+ i = Math.floor(i/62)
10113
+ }
10114
+ return s
10115
+ };
10116
+ my.decode = function(a,b,c,d){
10117
+ for (
10118
+ b = c = (
10119
+ a === (/\W|_|^$/.test(a += "") || a)
10120
+ ) - 1;
10121
+ d = a.charCodeAt(c++);
10122
+ )
10123
+ b = b * 62 + d - [, 48, 29, 87][d >> 5];
10124
+ return b
10125
+ };
10126
+
10127
+ return my;
10128
+ }({}));
10129
+
10130
+ module.exports = Base62
10131
+ },{}],11:[function(_dereq_,module,exports){
9605
10132
  /*
9606
10133
  * Copyright 2009-2011 Mozilla Foundation and contributors
9607
10134
  * Licensed under the New BSD license. See LICENSE.txt or:
@@ -9611,7 +10138,7 @@ exports.SourceMapGenerator = _dereq_('./source-map/source-map-generator').Source
9611
10138
  exports.SourceMapConsumer = _dereq_('./source-map/source-map-consumer').SourceMapConsumer;
9612
10139
  exports.SourceNode = _dereq_('./source-map/source-node').SourceNode;
9613
10140
 
9614
- },{"./source-map/source-map-consumer":15,"./source-map/source-map-generator":16,"./source-map/source-node":17}],11:[function(_dereq_,module,exports){
10141
+ },{"./source-map/source-map-consumer":16,"./source-map/source-map-generator":17,"./source-map/source-node":18}],12:[function(_dereq_,module,exports){
9615
10142
  /* -*- Mode: js; js-indent-level: 2; -*- */
9616
10143
  /*
9617
10144
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9710,7 +10237,7 @@ define(function (_dereq_, exports, module) {
9710
10237
 
9711
10238
  });
9712
10239
 
9713
- },{"./util":18,"amdefine":19}],12:[function(_dereq_,module,exports){
10240
+ },{"./util":19,"amdefine":20}],13:[function(_dereq_,module,exports){
9714
10241
  /* -*- Mode: js; js-indent-level: 2; -*- */
9715
10242
  /*
9716
10243
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9856,7 +10383,7 @@ define(function (_dereq_, exports, module) {
9856
10383
 
9857
10384
  });
9858
10385
 
9859
- },{"./base64":13,"amdefine":19}],13:[function(_dereq_,module,exports){
10386
+ },{"./base64":14,"amdefine":20}],14:[function(_dereq_,module,exports){
9860
10387
  /* -*- Mode: js; js-indent-level: 2; -*- */
9861
10388
  /*
9862
10389
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9900,7 +10427,7 @@ define(function (_dereq_, exports, module) {
9900
10427
 
9901
10428
  });
9902
10429
 
9903
- },{"amdefine":19}],14:[function(_dereq_,module,exports){
10430
+ },{"amdefine":20}],15:[function(_dereq_,module,exports){
9904
10431
  /* -*- Mode: js; js-indent-level: 2; -*- */
9905
10432
  /*
9906
10433
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9983,7 +10510,7 @@ define(function (_dereq_, exports, module) {
9983
10510
 
9984
10511
  });
9985
10512
 
9986
- },{"amdefine":19}],15:[function(_dereq_,module,exports){
10513
+ },{"amdefine":20}],16:[function(_dereq_,module,exports){
9987
10514
  /* -*- Mode: js; js-indent-level: 2; -*- */
9988
10515
  /*
9989
10516
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10462,7 +10989,7 @@ define(function (_dereq_, exports, module) {
10462
10989
 
10463
10990
  });
10464
10991
 
10465
- },{"./array-set":11,"./base64-vlq":12,"./binary-search":14,"./util":18,"amdefine":19}],16:[function(_dereq_,module,exports){
10992
+ },{"./array-set":12,"./base64-vlq":13,"./binary-search":15,"./util":19,"amdefine":20}],17:[function(_dereq_,module,exports){
10466
10993
  /* -*- Mode: js; js-indent-level: 2; -*- */
10467
10994
  /*
10468
10995
  * Copyright 2011 Mozilla Foundation and contributors
@@ -10844,7 +11371,7 @@ define(function (_dereq_, exports, module) {
10844
11371
 
10845
11372
  });
10846
11373
 
10847
- },{"./array-set":11,"./base64-vlq":12,"./util":18,"amdefine":19}],17:[function(_dereq_,module,exports){
11374
+ },{"./array-set":12,"./base64-vlq":13,"./util":19,"amdefine":20}],18:[function(_dereq_,module,exports){
10848
11375
  /* -*- Mode: js; js-indent-level: 2; -*- */
10849
11376
  /*
10850
11377
  * Copyright 2011 Mozilla Foundation and contributors
@@ -11217,7 +11744,7 @@ define(function (_dereq_, exports, module) {
11217
11744
 
11218
11745
  });
11219
11746
 
11220
- },{"./source-map-generator":16,"./util":18,"amdefine":19}],18:[function(_dereq_,module,exports){
11747
+ },{"./source-map-generator":17,"./util":19,"amdefine":20}],19:[function(_dereq_,module,exports){
11221
11748
  /* -*- Mode: js; js-indent-level: 2; -*- */
11222
11749
  /*
11223
11750
  * Copyright 2011 Mozilla Foundation and contributors
@@ -11424,7 +11951,7 @@ define(function (_dereq_, exports, module) {
11424
11951
 
11425
11952
  });
11426
11953
 
11427
- },{"amdefine":19}],19:[function(_dereq_,module,exports){
11954
+ },{"amdefine":20}],20:[function(_dereq_,module,exports){
11428
11955
  (function (process,__filename){
11429
11956
  /** vim: et:ts=4:sw=4:sts=4
11430
11957
  * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
@@ -11727,7 +12254,7 @@ function amdefine(module, requireFn) {
11727
12254
  module.exports = amdefine;
11728
12255
 
11729
12256
  }).call(this,_dereq_('_process'),"/node_modules/jstransform/node_modules/source-map/node_modules/amdefine/amdefine.js")
11730
- },{"_process":7,"path":6}],20:[function(_dereq_,module,exports){
12257
+ },{"_process":8,"path":7}],21:[function(_dereq_,module,exports){
11731
12258
  /**
11732
12259
  * Copyright 2013 Facebook, Inc.
11733
12260
  *
@@ -11815,7 +12342,7 @@ exports.extract = extract;
11815
12342
  exports.parse = parse;
11816
12343
  exports.parseAsObject = parseAsObject;
11817
12344
 
11818
- },{}],21:[function(_dereq_,module,exports){
12345
+ },{}],22:[function(_dereq_,module,exports){
11819
12346
  /**
11820
12347
  * Copyright 2013 Facebook, Inc.
11821
12348
  *
@@ -11859,7 +12386,12 @@ function _nodeIsClosureScopeBoundary(node, parentNode) {
11859
12386
  || parentNode.type === Syntax.FunctionExpression
11860
12387
  || parentNode.type === Syntax.ArrowFunctionExpression;
11861
12388
 
11862
- return node.type === Syntax.BlockStatement && parentIsFunction;
12389
+ var parentIsCurlylessArrowFunc =
12390
+ parentNode.type === Syntax.ArrowFunctionExpression
12391
+ && node === parentNode.body;
12392
+
12393
+ return parentIsFunction
12394
+ && (node.type === Syntax.BlockStatement || parentIsCurlylessArrowFunc);
11863
12395
  }
11864
12396
 
11865
12397
  function _nodeIsBlockScopeBoundary(node, parentNode) {
@@ -11877,29 +12409,38 @@ function _nodeIsBlockScopeBoundary(node, parentNode) {
11877
12409
  * @param {object} state
11878
12410
  */
11879
12411
  function traverse(node, path, state) {
12412
+ /*jshint -W004*/
11880
12413
  // Create a scope stack entry if this is the first node we've encountered in
11881
12414
  // its local scope
12415
+ var startIndex = null;
11882
12416
  var parentNode = path[0];
11883
12417
  if (!Array.isArray(node) && state.localScope.parentNode !== parentNode) {
11884
12418
  if (_nodeIsClosureScopeBoundary(node, parentNode)) {
11885
- var scopeIsStrict =
11886
- state.scopeIsStrict
11887
- || node.body.length > 0
11888
- && node.body[0].type === Syntax.ExpressionStatement
11889
- && node.body[0].expression.type === Syntax.Literal
11890
- && node.body[0].expression.value === 'use strict';
12419
+ var scopeIsStrict = state.scopeIsStrict;
12420
+ if (!scopeIsStrict
12421
+ && (node.type === Syntax.BlockStatement
12422
+ || node.type === Syntax.Program)) {
12423
+ scopeIsStrict =
12424
+ node.body.length > 0
12425
+ && node.body[0].type === Syntax.ExpressionStatement
12426
+ && node.body[0].expression.type === Syntax.Literal
12427
+ && node.body[0].expression.value === 'use strict';
12428
+ }
11891
12429
 
11892
12430
  if (node.type === Syntax.Program) {
12431
+ startIndex = state.g.buffer.length;
11893
12432
  state = utils.updateState(state, {
11894
12433
  scopeIsStrict: scopeIsStrict
11895
12434
  });
11896
12435
  } else {
12436
+ startIndex = state.g.buffer.length + 1;
11897
12437
  state = utils.updateState(state, {
11898
12438
  localScope: {
11899
12439
  parentNode: parentNode,
11900
12440
  parentScope: state.localScope,
11901
12441
  identifiers: {},
11902
- tempVarIndex: 0
12442
+ tempVarIndex: 0,
12443
+ tempVars: []
11903
12444
  },
11904
12445
  scopeIsStrict: scopeIsStrict
11905
12446
  });
@@ -11911,16 +12452,26 @@ function traverse(node, path, state) {
11911
12452
  // function
11912
12453
  if (parentNode.params.length > 0) {
11913
12454
  var param;
12455
+ var metadata = initScopeMetadata(parentNode, path.slice(1), path[0]);
11914
12456
  for (var i = 0; i < parentNode.params.length; i++) {
11915
12457
  param = parentNode.params[i];
11916
12458
  if (param.type === Syntax.Identifier) {
11917
- declareIdentInScope(
11918
- param.name, initScopeMetadata(parentNode), state
11919
- );
12459
+ declareIdentInScope(param.name, metadata, state);
11920
12460
  }
11921
12461
  }
11922
12462
  }
11923
12463
 
12464
+ // Include rest arg identifiers in the scope boundaries of their
12465
+ // functions
12466
+ if (parentNode.rest) {
12467
+ var metadata = initScopeMetadata(
12468
+ parentNode,
12469
+ path.slice(1),
12470
+ path[0]
12471
+ );
12472
+ declareIdentInScope(parentNode.rest.name, metadata, state);
12473
+ }
12474
+
11924
12475
  // Named FunctionExpressions scope their name within the body block of
11925
12476
  // themselves only
11926
12477
  if (parentNode.type === Syntax.FunctionExpression && parentNode.id) {
@@ -11936,18 +12487,24 @@ function traverse(node, path, state) {
11936
12487
  }
11937
12488
 
11938
12489
  if (_nodeIsBlockScopeBoundary(node, parentNode)) {
12490
+ startIndex = state.g.buffer.length;
11939
12491
  state = utils.updateState(state, {
11940
12492
  localScope: {
11941
12493
  parentNode: parentNode,
11942
12494
  parentScope: state.localScope,
11943
- identifiers: {}
12495
+ identifiers: {},
12496
+ tempVarIndex: 0,
12497
+ tempVars: []
11944
12498
  }
11945
12499
  });
11946
12500
 
11947
12501
  if (parentNode.type === Syntax.CatchClause) {
11948
- declareIdentInScope(
11949
- parentNode.param.name, initScopeMetadata(parentNode), state
12502
+ var metadata = initScopeMetadata(
12503
+ parentNode,
12504
+ path.slice(1),
12505
+ parentNode
11950
12506
  );
12507
+ declareIdentInScope(parentNode.param.name, metadata, state);
11951
12508
  }
11952
12509
  collectBlockIdentsAndTraverse(node, path, state);
11953
12510
  }
@@ -11961,6 +12518,11 @@ function traverse(node, path, state) {
11961
12518
  }
11962
12519
 
11963
12520
  utils.analyzeAndTraverse(walker, traverser, node, path, state);
12521
+
12522
+ // Inject temp variables into the scope.
12523
+ if (startIndex !== null) {
12524
+ utils.injectTempVarDeclarations(state, startIndex);
12525
+ }
11964
12526
  }
11965
12527
 
11966
12528
  function collectClosureIdentsAndTraverse(node, path, state) {
@@ -11986,6 +12548,7 @@ function collectBlockIdentsAndTraverse(node, path, state) {
11986
12548
  function visitLocalClosureIdentifiers(node, path, state) {
11987
12549
  var metaData;
11988
12550
  switch (node.type) {
12551
+ case Syntax.ArrowFunctionExpression:
11989
12552
  case Syntax.FunctionExpression:
11990
12553
  // Function expressions don't get their names (if there is one) added to
11991
12554
  // the closure scope they're defined in
@@ -12026,6 +12589,22 @@ function walker(node, path, state) {
12026
12589
 
12027
12590
  var _astCache = {};
12028
12591
 
12592
+ function getAstForSource(source, options) {
12593
+ if (_astCache[source] && !options.disableAstCache) {
12594
+ return _astCache[source];
12595
+ }
12596
+ var ast = esprima.parse(source, {
12597
+ comment: true,
12598
+ loc: true,
12599
+ range: true,
12600
+ sourceType: options.sourceType
12601
+ });
12602
+ if (!options.disableAstCache) {
12603
+ _astCache[source] = ast;
12604
+ }
12605
+ return ast;
12606
+ }
12607
+
12029
12608
  /**
12030
12609
  * Applies all available transformations to the source
12031
12610
  * @param {array} visitors
@@ -12037,13 +12616,7 @@ function transform(visitors, source, options) {
12037
12616
  options = options || {};
12038
12617
  var ast;
12039
12618
  try {
12040
- var cachedAst = _astCache[source];
12041
- ast = cachedAst ||
12042
- (_astCache[source] = esprima.parse(source, {
12043
- comment: true,
12044
- loc: true,
12045
- range: true
12046
- }));
12619
+ ast = getAstForSource(source, options);
12047
12620
  } catch (e) {
12048
12621
  e.message = 'Parse Error: ' + e.message;
12049
12622
  throw e;
@@ -12070,7 +12643,7 @@ function transform(visitors, source, options) {
12070
12643
  exports.transform = transform;
12071
12644
  exports.Syntax = Syntax;
12072
12645
 
12073
- },{"./utils":22,"esprima-fb":9,"source-map":10}],22:[function(_dereq_,module,exports){
12646
+ },{"./utils":23,"esprima-fb":9,"source-map":11}],23:[function(_dereq_,module,exports){
12074
12647
  /**
12075
12648
  * Copyright 2013 Facebook, Inc.
12076
12649
  *
@@ -12115,7 +12688,8 @@ function createState(source, rootNode, transformOptions) {
12115
12688
  parentNode: rootNode,
12116
12689
  parentScope: null,
12117
12690
  identifiers: {},
12118
- tempVarIndex: 0
12691
+ tempVarIndex: 0,
12692
+ tempVars: []
12119
12693
  },
12120
12694
  /**
12121
12695
  * The name (and, if applicable, expression) of the super class
@@ -12332,29 +12906,87 @@ function getNodeSourceText(node, state) {
12332
12906
  return state.g.source.substring(node.range[0], node.range[1]);
12333
12907
  }
12334
12908
 
12335
- function replaceNonWhite(value) {
12909
+ function _replaceNonWhite(value) {
12336
12910
  return value.replace(nonWhiteRegexp, ' ');
12337
12911
  }
12338
12912
 
12339
12913
  /**
12340
12914
  * Removes all non-whitespace characters
12341
12915
  */
12342
- function stripNonWhite(value) {
12916
+ function _stripNonWhite(value) {
12343
12917
  return value.replace(nonWhiteRegexp, '');
12344
12918
  }
12345
12919
 
12920
+ /**
12921
+ * Finds the position of the next instance of the specified syntactic char in
12922
+ * the pending source.
12923
+ *
12924
+ * NOTE: This will skip instances of the specified char if they sit inside a
12925
+ * comment body.
12926
+ *
12927
+ * NOTE: This function also assumes that the buffer's current position is not
12928
+ * already within a comment or a string. This is rarely the case since all
12929
+ * of the buffer-advancement utility methods tend to be used on syntactic
12930
+ * nodes' range values -- but it's a small gotcha that's worth mentioning.
12931
+ */
12932
+ function getNextSyntacticCharOffset(char, state) {
12933
+ var pendingSource = state.g.source.substring(state.g.position);
12934
+ var pendingSourceLines = pendingSource.split('\n');
12935
+
12936
+ var charOffset = 0;
12937
+ var line;
12938
+ var withinBlockComment = false;
12939
+ var withinString = false;
12940
+ lineLoop: while ((line = pendingSourceLines.shift()) !== undefined) {
12941
+ var lineEndPos = charOffset + line.length;
12942
+ charLoop: for (; charOffset < lineEndPos; charOffset++) {
12943
+ var currChar = pendingSource[charOffset];
12944
+ if (currChar === '"' || currChar === '\'') {
12945
+ withinString = !withinString;
12946
+ continue charLoop;
12947
+ } else if (withinString) {
12948
+ continue charLoop;
12949
+ } else if (charOffset + 1 < lineEndPos) {
12950
+ var nextTwoChars = currChar + line[charOffset + 1];
12951
+ if (nextTwoChars === '//') {
12952
+ charOffset = lineEndPos + 1;
12953
+ continue lineLoop;
12954
+ } else if (nextTwoChars === '/*') {
12955
+ withinBlockComment = true;
12956
+ charOffset += 1;
12957
+ continue charLoop;
12958
+ } else if (nextTwoChars === '*/') {
12959
+ withinBlockComment = false;
12960
+ charOffset += 1;
12961
+ continue charLoop;
12962
+ }
12963
+ }
12964
+
12965
+ if (!withinBlockComment && currChar === char) {
12966
+ return charOffset + state.g.position;
12967
+ }
12968
+ }
12969
+
12970
+ // Account for '\n'
12971
+ charOffset++;
12972
+ withinString = false;
12973
+ }
12974
+
12975
+ throw new Error('`' + char + '` not found!');
12976
+ }
12977
+
12346
12978
  /**
12347
12979
  * Catches up as `catchup` but replaces non-whitespace chars with spaces.
12348
12980
  */
12349
12981
  function catchupWhiteOut(end, state) {
12350
- catchup(end, state, replaceNonWhite);
12982
+ catchup(end, state, _replaceNonWhite);
12351
12983
  }
12352
12984
 
12353
12985
  /**
12354
12986
  * Catches up as `catchup` but removes all non-whitespace characters.
12355
12987
  */
12356
12988
  function catchupWhiteSpace(end, state) {
12357
- catchup(end, state, stripNonWhite);
12989
+ catchup(end, state, _stripNonWhite);
12358
12990
  }
12359
12991
 
12360
12992
  /**
@@ -12437,6 +13069,7 @@ function append(str, state) {
12437
13069
  * @return {string}
12438
13070
  */
12439
13071
  function updateIndent(str, state) {
13072
+ /*jshint -W004*/
12440
13073
  var indentBy = state.indentBy;
12441
13074
  if (indentBy < 0) {
12442
13075
  for (var i = 0; i < -indentBy; i++) {
@@ -12528,6 +13161,17 @@ function declareIdentInLocalScope(identName, metaData, state) {
12528
13161
  }
12529
13162
 
12530
13163
  function getLexicalBindingMetadata(identName, state) {
13164
+ var currScope = state.localScope;
13165
+ while (currScope) {
13166
+ if (currScope.identifiers[identName] !== undefined) {
13167
+ return currScope.identifiers[identName];
13168
+ }
13169
+
13170
+ currScope = currScope.parentScope;
13171
+ }
13172
+ }
13173
+
13174
+ function getLocalBindingMetadata(identName, state) {
12531
13175
  return state.localScope.identifiers[identName];
12532
13176
  }
12533
13177
 
@@ -12643,6 +13287,7 @@ function containsChildMatching(node, matcher) {
12643
13287
  }
12644
13288
 
12645
13289
  var scopeTypes = {};
13290
+ scopeTypes[Syntax.ArrowFunctionExpression] = true;
12646
13291
  scopeTypes[Syntax.FunctionExpression] = true;
12647
13292
  scopeTypes[Syntax.FunctionDeclaration] = true;
12648
13293
  scopeTypes[Syntax.Program] = true;
@@ -12663,15 +13308,28 @@ function getTempVar(tempVarIndex) {
12663
13308
  return '$__' + tempVarIndex;
12664
13309
  }
12665
13310
 
12666
- function getTempVarWithValue(tempVarIndex, tempVarValue) {
12667
- return getTempVar(tempVarIndex) + '=' + tempVarValue;
13311
+ function injectTempVar(state) {
13312
+ var tempVar = '$__' + (state.localScope.tempVarIndex++);
13313
+ state.localScope.tempVars.push(tempVar);
13314
+ return tempVar;
13315
+ }
13316
+
13317
+ function injectTempVarDeclarations(state, index) {
13318
+ if (state.localScope.tempVars.length) {
13319
+ state.g.buffer =
13320
+ state.g.buffer.slice(0, index) +
13321
+ 'var ' + state.localScope.tempVars.join(', ') + ';' +
13322
+ state.g.buffer.slice(index);
13323
+ state.localScope.tempVars = [];
13324
+ }
12668
13325
  }
12669
13326
 
13327
+ exports.analyzeAndTraverse = analyzeAndTraverse;
12670
13328
  exports.append = append;
12671
13329
  exports.catchup = catchup;
13330
+ exports.catchupNewlines = catchupNewlines;
12672
13331
  exports.catchupWhiteOut = catchupWhiteOut;
12673
13332
  exports.catchupWhiteSpace = catchupWhiteSpace;
12674
- exports.catchupNewlines = catchupNewlines;
12675
13333
  exports.containsChildMatching = containsChildMatching;
12676
13334
  exports.containsChildOfType = containsChildOfType;
12677
13335
  exports.createState = createState;
@@ -12679,21 +13337,23 @@ exports.declareIdentInLocalScope = declareIdentInLocalScope;
12679
13337
  exports.getBoundaryNode = getBoundaryNode;
12680
13338
  exports.getDocblock = getDocblock;
12681
13339
  exports.getLexicalBindingMetadata = getLexicalBindingMetadata;
12682
- exports.initScopeMetadata = initScopeMetadata;
12683
- exports.identWithinLexicalScope = identWithinLexicalScope;
13340
+ exports.getLocalBindingMetadata = getLocalBindingMetadata;
13341
+ exports.getNextSyntacticCharOffset = getNextSyntacticCharOffset;
13342
+ exports.getNodeSourceText = getNodeSourceText;
13343
+ exports.getOrderedChildren = getOrderedChildren;
13344
+ exports.getTempVar = getTempVar;
12684
13345
  exports.identInLocalScope = identInLocalScope;
13346
+ exports.identWithinLexicalScope = identWithinLexicalScope;
12685
13347
  exports.indentBefore = indentBefore;
13348
+ exports.initScopeMetadata = initScopeMetadata;
13349
+ exports.injectTempVar = injectTempVar;
13350
+ exports.injectTempVarDeclarations = injectTempVarDeclarations;
12686
13351
  exports.move = move;
12687
13352
  exports.scopeTypes = scopeTypes;
12688
13353
  exports.updateIndent = updateIndent;
12689
13354
  exports.updateState = updateState;
12690
- exports.analyzeAndTraverse = analyzeAndTraverse;
12691
- exports.getOrderedChildren = getOrderedChildren;
12692
- exports.getNodeSourceText = getNodeSourceText;
12693
- exports.getTempVar = getTempVar;
12694
- exports.getTempVarWithValue = getTempVarWithValue;
12695
13355
 
12696
- },{"./docblock":20,"esprima-fb":9}],23:[function(_dereq_,module,exports){
13356
+ },{"./docblock":21,"esprima-fb":9}],24:[function(_dereq_,module,exports){
12697
13357
  /**
12698
13358
  * Copyright 2013 Facebook, Inc.
12699
13359
  *
@@ -12853,7 +13513,116 @@ exports.visitorList = [
12853
13513
  ];
12854
13514
 
12855
13515
 
12856
- },{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":9}],24:[function(_dereq_,module,exports){
13516
+ },{"../src/utils":23,"./es6-destructuring-visitors":27,"./es6-rest-param-visitors":30,"esprima-fb":9}],25:[function(_dereq_,module,exports){
13517
+ /**
13518
+ * Copyright 2004-present Facebook. All Rights Reserved.
13519
+ */
13520
+ /*global exports:true*/
13521
+
13522
+ /**
13523
+ * Implements ES6 call spread.
13524
+ *
13525
+ * instance.method(a, b, c, ...d)
13526
+ *
13527
+ * instance.method.apply(instance, [a, b, c].concat(d))
13528
+ *
13529
+ */
13530
+
13531
+ var Syntax = _dereq_('esprima-fb').Syntax;
13532
+ var utils = _dereq_('../src/utils');
13533
+
13534
+ function process(traverse, node, path, state) {
13535
+ utils.move(node.range[0], state);
13536
+ traverse(node, path, state);
13537
+ utils.catchup(node.range[1], state);
13538
+ }
13539
+
13540
+ function visitCallSpread(traverse, node, path, state) {
13541
+ utils.catchup(node.range[0], state);
13542
+
13543
+ if (node.type === Syntax.NewExpression) {
13544
+ // Input = new Set(1, 2, ...list)
13545
+ // Output = new (Function.prototype.bind.apply(Set, [null, 1, 2].concat(list)))
13546
+ utils.append('new (Function.prototype.bind.apply(', state);
13547
+ process(traverse, node.callee, path, state);
13548
+ } else if (node.callee.type === Syntax.MemberExpression) {
13549
+ // Input = get().fn(1, 2, ...more)
13550
+ // Output = (_ = get()).fn.apply(_, [1, 2].apply(more))
13551
+ var tempVar = utils.injectTempVar(state);
13552
+ utils.append('(' + tempVar + ' = ', state);
13553
+ process(traverse, node.callee.object, path, state);
13554
+ utils.append(')', state);
13555
+ if (node.callee.property.type === Syntax.Identifier) {
13556
+ utils.append('.', state);
13557
+ process(traverse, node.callee.property, path, state);
13558
+ } else {
13559
+ utils.append('[', state);
13560
+ process(traverse, node.callee.property, path, state);
13561
+ utils.append(']', state);
13562
+ }
13563
+ utils.append('.apply(' + tempVar, state);
13564
+ } else {
13565
+ // Input = max(1, 2, ...list)
13566
+ // Output = max.apply(null, [1, 2].concat(list))
13567
+ var needsToBeWrappedInParenthesis =
13568
+ node.callee.type === Syntax.FunctionDeclaration ||
13569
+ node.callee.type === Syntax.FunctionExpression;
13570
+ if (needsToBeWrappedInParenthesis) {
13571
+ utils.append('(', state);
13572
+ }
13573
+ process(traverse, node.callee, path, state);
13574
+ if (needsToBeWrappedInParenthesis) {
13575
+ utils.append(')', state);
13576
+ }
13577
+ utils.append('.apply(null', state);
13578
+ }
13579
+ utils.append(', ', state);
13580
+
13581
+ var args = node.arguments.slice();
13582
+ var spread = args.pop();
13583
+ if (args.length || node.type === Syntax.NewExpression) {
13584
+ utils.append('[', state);
13585
+ if (node.type === Syntax.NewExpression) {
13586
+ utils.append('null' + (args.length ? ', ' : ''), state);
13587
+ }
13588
+ while (args.length) {
13589
+ var arg = args.shift();
13590
+ utils.move(arg.range[0], state);
13591
+ traverse(arg, path, state);
13592
+ if (args.length) {
13593
+ utils.catchup(args[0].range[0], state);
13594
+ } else {
13595
+ utils.catchup(arg.range[1], state);
13596
+ }
13597
+ }
13598
+ utils.append('].concat(', state);
13599
+ process(traverse, spread.argument, path, state);
13600
+ utils.append(')', state);
13601
+ } else {
13602
+ process(traverse, spread.argument, path, state);
13603
+ }
13604
+ utils.append(node.type === Syntax.NewExpression ? '))' : ')', state);
13605
+
13606
+ utils.move(node.range[1], state);
13607
+ return false;
13608
+ }
13609
+
13610
+ visitCallSpread.test = function(node, path, state) {
13611
+ return (
13612
+ (
13613
+ node.type === Syntax.CallExpression ||
13614
+ node.type === Syntax.NewExpression
13615
+ ) &&
13616
+ node.arguments.length > 0 &&
13617
+ node.arguments[node.arguments.length - 1].type === Syntax.SpreadElement
13618
+ );
13619
+ };
13620
+
13621
+ exports.visitorList = [
13622
+ visitCallSpread
13623
+ ];
13624
+
13625
+ },{"../src/utils":23,"esprima-fb":9}],26:[function(_dereq_,module,exports){
12857
13626
  /**
12858
13627
  * Copyright 2013 Facebook, Inc.
12859
13628
  *
@@ -13037,6 +13806,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13037
13806
  if (methodNode.key.name === 'constructor') {
13038
13807
  utils.append('function ' + state.className, state);
13039
13808
  } else {
13809
+ var methodAccessorComputed = false;
13040
13810
  var methodAccessor;
13041
13811
  var prototypeOrStatic = methodNode["static"] ? '' : '.prototype';
13042
13812
  var objectAccessor = state.className + prototypeOrStatic;
@@ -13050,16 +13820,13 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13050
13820
  if (isGetter || isSetter) {
13051
13821
  methodAccessor = JSON.stringify(methodAccessor);
13052
13822
  } else if (reservedWordsHelper.isReservedWord(methodAccessor)) {
13053
- methodAccessor = '[' + JSON.stringify(methodAccessor) + ']';
13054
- } else {
13055
- methodAccessor = '.' + methodAccessor;
13823
+ methodAccessorComputed = true;
13824
+ methodAccessor = JSON.stringify(methodAccessor);
13056
13825
  }
13057
13826
  } else if (methodNode.key.type === Syntax.Literal) {
13058
13827
  // 'foo bar'() {} | get 'foo bar'() {} | set 'foo bar'() {}
13059
13828
  methodAccessor = JSON.stringify(methodNode.key.value);
13060
- if (!(isGetter || isSetter)) {
13061
- methodAccessor = '[' + methodAccessor + ']';
13062
- }
13829
+ methodAccessorComputed = true;
13063
13830
  }
13064
13831
 
13065
13832
  if (isSetter || isGetter) {
@@ -13067,16 +13834,35 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13067
13834
  'Object.defineProperty(' +
13068
13835
  objectAccessor + ',' +
13069
13836
  methodAccessor + ',' +
13070
- '{enumerable:true,configurable:true,' +
13837
+ '{configurable:true,' +
13071
13838
  methodNode.kind + ':function',
13072
13839
  state
13073
13840
  );
13074
13841
  } else {
13075
- utils.append(
13076
- objectAccessor +
13077
- methodAccessor + '=function' + (node.generator ? '*' : ''),
13078
- state
13079
- );
13842
+ if (state.g.opts.es3) {
13843
+ if (methodAccessorComputed) {
13844
+ methodAccessor = '[' + methodAccessor + ']';
13845
+ } else {
13846
+ methodAccessor = '.' + methodAccessor;
13847
+ }
13848
+ utils.append(
13849
+ objectAccessor +
13850
+ methodAccessor + '=function' + (node.generator ? '*' : ''),
13851
+ state
13852
+ );
13853
+ } else {
13854
+ if (!methodAccessorComputed) {
13855
+ methodAccessor = JSON.stringify(methodAccessor);
13856
+ }
13857
+ utils.append(
13858
+ 'Object.defineProperty(' +
13859
+ objectAccessor + ',' +
13860
+ methodAccessor + ',' +
13861
+ '{writable:true,configurable:true,' +
13862
+ 'value:function' + (node.generator ? '*' : ''),
13863
+ state
13864
+ );
13865
+ }
13080
13866
  }
13081
13867
  }
13082
13868
  utils.move(methodNode.key.range[1], state);
@@ -13092,9 +13878,13 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13092
13878
  path.shift();
13093
13879
  }
13094
13880
  }
13095
- utils.append(')', state);
13096
- utils.catchupWhiteSpace(node.body.range[0], state);
13097
- utils.append('{', state);
13881
+
13882
+ var closingParenPosition = utils.getNextSyntacticCharOffset(')', state);
13883
+ utils.catchupWhiteSpace(closingParenPosition, state);
13884
+
13885
+ var openingBracketPosition = utils.getNextSyntacticCharOffset('{', state);
13886
+ utils.catchup(openingBracketPosition + 1, state);
13887
+
13098
13888
  if (!state.scopeIsStrict) {
13099
13889
  utils.append('"use strict";', state);
13100
13890
  state = utils.updateState(state, {
@@ -13109,7 +13899,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
13109
13899
  utils.catchup(node.body.range[1], state);
13110
13900
 
13111
13901
  if (methodNode.key.name !== 'constructor') {
13112
- if (isGetter || isSetter) {
13902
+ if (isGetter || isSetter || !state.g.opts.es3) {
13113
13903
  utils.append('})', state);
13114
13904
  }
13115
13905
  utils.append(';', state);
@@ -13422,7 +14212,7 @@ exports.visitorList = [
13422
14212
  visitSuperMemberExpression
13423
14213
  ];
13424
14214
 
13425
- },{"../src/utils":22,"./reserved-words-helper":32,"base62":8,"esprima-fb":9}],25:[function(_dereq_,module,exports){
14215
+ },{"../src/utils":23,"./reserved-words-helper":34,"base62":10,"esprima-fb":9}],27:[function(_dereq_,module,exports){
13426
14216
  /**
13427
14217
  * Copyright 2014 Facebook, Inc.
13428
14218
  *
@@ -13544,7 +14334,7 @@ function getDestructuredComponents(node, state) {
13544
14334
  } else {
13545
14335
  // Complex sub-structure.
13546
14336
  components.push(
13547
- utils.getTempVarWithValue(++state.localScope.tempVarIndex, accessor) +
14337
+ utils.getTempVar(++state.localScope.tempVarIndex) + '=' + accessor +
13548
14338
  ',' + getDestructuredComponents(value, state)
13549
14339
  );
13550
14340
  }
@@ -13704,7 +14494,7 @@ exports.visitorList = [
13704
14494
  exports.renderDestructuredComponents = renderDestructuredComponents;
13705
14495
 
13706
14496
 
13707
- },{"../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){
14497
+ },{"../src/utils":23,"./es6-rest-param-visitors":30,"./es7-rest-property-helpers":32,"./reserved-words-helper":34,"esprima-fb":9}],28:[function(_dereq_,module,exports){
13708
14498
  /**
13709
14499
  * Copyright 2013 Facebook, Inc.
13710
14500
  *
@@ -13775,7 +14565,7 @@ exports.visitorList = [
13775
14565
  visitObjectConciseMethod
13776
14566
  ];
13777
14567
 
13778
- },{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":9}],27:[function(_dereq_,module,exports){
14568
+ },{"../src/utils":23,"./reserved-words-helper":34,"esprima-fb":9}],29:[function(_dereq_,module,exports){
13779
14569
  /**
13780
14570
  * Copyright 2013 Facebook, Inc.
13781
14571
  *
@@ -13830,7 +14620,7 @@ exports.visitorList = [
13830
14620
  ];
13831
14621
 
13832
14622
 
13833
- },{"../src/utils":22,"esprima-fb":9}],28:[function(_dereq_,module,exports){
14623
+ },{"../src/utils":23,"esprima-fb":9}],30:[function(_dereq_,module,exports){
13834
14624
  /**
13835
14625
  * Copyright 2013 Facebook, Inc.
13836
14626
  *
@@ -13913,8 +14703,8 @@ function renderRestParamSetup(functionNode, state) {
13913
14703
  var len = state.localScope.tempVarIndex++;
13914
14704
 
13915
14705
  return 'for (var ' + functionNode.rest.name + '=[],' +
13916
- utils.getTempVarWithValue(idx, functionNode.params.length) + ',' +
13917
- utils.getTempVarWithValue(len, 'arguments.length') + ';' +
14706
+ utils.getTempVar(idx) + '=' + functionNode.params.length + ',' +
14707
+ utils.getTempVar(len) + '=arguments.length;' +
13918
14708
  utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' +
13919
14709
  utils.getTempVar(idx) + '++) ' +
13920
14710
  functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);';
@@ -13938,7 +14728,7 @@ exports.visitorList = [
13938
14728
  visitFunctionBodyWithRestParam
13939
14729
  ];
13940
14730
 
13941
- },{"../src/utils":22,"esprima-fb":9}],29:[function(_dereq_,module,exports){
14731
+ },{"../src/utils":23,"esprima-fb":9}],31:[function(_dereq_,module,exports){
13942
14732
  /**
13943
14733
  * Copyright 2013 Facebook, Inc.
13944
14734
  *
@@ -14096,7 +14886,7 @@ exports.visitorList = [
14096
14886
  visitTaggedTemplateExpression
14097
14887
  ];
14098
14888
 
14099
- },{"../src/utils":22,"esprima-fb":9}],30:[function(_dereq_,module,exports){
14889
+ },{"../src/utils":23,"esprima-fb":9}],32:[function(_dereq_,module,exports){
14100
14890
  /**
14101
14891
  * Copyright 2013 Facebook, Inc.
14102
14892
  *
@@ -14120,7 +14910,6 @@ exports.visitorList = [
14120
14910
  */
14121
14911
 
14122
14912
  var Syntax = _dereq_('esprima-fb').Syntax;
14123
- var utils = _dereq_('../src/utils');
14124
14913
 
14125
14914
  // TODO: This is a pretty massive helper, it should only be defined once, in the
14126
14915
  // transform's runtime environment. We don't currently have a runtime though.
@@ -14179,7 +14968,7 @@ function renderRestExpression(accessorExpression, excludedProperties) {
14179
14968
 
14180
14969
  exports.renderRestExpression = renderRestExpression;
14181
14970
 
14182
- },{"../src/utils":22,"esprima-fb":9}],31:[function(_dereq_,module,exports){
14971
+ },{"esprima-fb":9}],33:[function(_dereq_,module,exports){
14183
14972
  /**
14184
14973
  * Copyright 2004-present Facebook. All Rights Reserved.
14185
14974
  */
@@ -14289,7 +15078,7 @@ exports.visitorList = [
14289
15078
  visitObjectLiteralSpread
14290
15079
  ];
14291
15080
 
14292
- },{"../src/utils":22,"esprima-fb":9}],32:[function(_dereq_,module,exports){
15081
+ },{"../src/utils":23,"esprima-fb":9}],34:[function(_dereq_,module,exports){
14293
15082
  /**
14294
15083
  * Copyright 2014 Facebook, Inc.
14295
15084
  *
@@ -14340,7 +15129,77 @@ exports.isReservedWord = function(word) {
14340
15129
  return !!reservedWordsMap[word];
14341
15130
  };
14342
15131
 
14343
- },{}],33:[function(_dereq_,module,exports){
15132
+ },{}],35:[function(_dereq_,module,exports){
15133
+ /**
15134
+ * Copyright 2014 Facebook, Inc.
15135
+ *
15136
+ * Licensed under the Apache License, Version 2.0 (the "License");
15137
+ * you may not use this file except in compliance with the License.
15138
+ * You may obtain a copy of the License at
15139
+ *
15140
+ * http://www.apache.org/licenses/LICENSE-2.0
15141
+ *
15142
+ * Unless required by applicable law or agreed to in writing, software
15143
+ * distributed under the License is distributed on an "AS IS" BASIS,
15144
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15145
+ * See the License for the specific language governing permissions and
15146
+ * limitations under the License.
15147
+ *
15148
+ */
15149
+ /*global exports:true*/
15150
+
15151
+ var Syntax = _dereq_('esprima-fb').Syntax;
15152
+ var utils = _dereq_('../src/utils');
15153
+ var reserverdWordsHelper = _dereq_('./reserved-words-helper');
15154
+
15155
+ /**
15156
+ * Code adapted from https://github.com/spicyj/es3ify
15157
+ * The MIT License (MIT)
15158
+ * Copyright (c) 2014 Ben Alpert
15159
+ */
15160
+
15161
+ function visitProperty(traverse, node, path, state) {
15162
+ utils.catchup(node.key.range[0], state);
15163
+ utils.append('"', state);
15164
+ utils.catchup(node.key.range[1], state);
15165
+ utils.append('"', state);
15166
+ utils.catchup(node.value.range[0], state);
15167
+ traverse(node.value, path, state);
15168
+ return false;
15169
+ }
15170
+
15171
+ visitProperty.test = function(node) {
15172
+ return node.type === Syntax.Property &&
15173
+ node.key.type === Syntax.Identifier &&
15174
+ !node.method &&
15175
+ !node.shorthand &&
15176
+ !node.computed &&
15177
+ reserverdWordsHelper.isReservedWord(node.key.name);
15178
+ };
15179
+
15180
+ function visitMemberExpression(traverse, node, path, state) {
15181
+ traverse(node.object, path, state);
15182
+ utils.catchup(node.property.range[0] - 1, state);
15183
+ utils.append('[', state);
15184
+ utils.catchupWhiteSpace(node.property.range[0], state);
15185
+ utils.append('"', state);
15186
+ utils.catchup(node.property.range[1], state);
15187
+ utils.append('"]', state);
15188
+ return false;
15189
+ }
15190
+
15191
+ visitMemberExpression.test = function(node) {
15192
+ return node.type === Syntax.MemberExpression &&
15193
+ node.property.type === Syntax.Identifier &&
15194
+ reserverdWordsHelper.isReservedWord(node.property.name);
15195
+ };
15196
+
15197
+ exports.visitorList = [
15198
+ visitProperty,
15199
+ visitMemberExpression
15200
+ ];
15201
+
15202
+ },{"../src/utils":23,"./reserved-words-helper":34,"esprima-fb":9}],36:[function(_dereq_,module,exports){
14344
15203
  var esprima = _dereq_('esprima-fb');
14345
15204
  var utils = _dereq_('../src/utils');
14346
15205
 
@@ -14369,6 +15228,15 @@ visitTypeAlias.test = function(node, path, state) {
14369
15228
  return node.type === Syntax.TypeAlias;
14370
15229
  };
14371
15230
 
15231
+ function visitTypeCast(traverse, node, path, state) {
15232
+ utils.catchup(node.typeAnnotation.range[0], state);
15233
+ utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
15234
+ return false;
15235
+ }
15236
+ visitTypeCast.test = function(node, path, state) {
15237
+ return node.type === Syntax.TypeCastExpression;
15238
+ };
15239
+
14372
15240
  function visitInterfaceDeclaration(traverse, node, path, state) {
14373
15241
  utils.catchupWhiteOut(node.range[1], state);
14374
15242
  return false;
@@ -14383,13 +15251,14 @@ function visitDeclare(traverse, node, path, state) {
14383
15251
  }
14384
15252
  visitDeclare.test = function(node, path, state) {
14385
15253
  switch (node.type) {
14386
- case Syntax.DeclareVariable:
14387
- case Syntax.DeclareFunction:
14388
- case Syntax.DeclareClass:
14389
- case Syntax.DeclareModule: return true
15254
+ case Syntax.DeclareVariable:
15255
+ case Syntax.DeclareFunction:
15256
+ case Syntax.DeclareClass:
15257
+ case Syntax.DeclareModule:
15258
+ return true;
14390
15259
  }
14391
15260
  return false;
14392
- }
15261
+ };
14393
15262
 
14394
15263
  function visitFunctionParametricAnnotation(traverse, node, path, state) {
14395
15264
  utils.catchup(node.range[0], state);
@@ -14476,22 +15345,33 @@ visitMethod.test = function(node, path, state) {
14476
15345
  || (node.type === "MethodDefinition");
14477
15346
  };
14478
15347
 
15348
+ function visitImportType(traverse, node, path, state) {
15349
+ utils.catchupWhiteOut(node.range[1], state);
15350
+ return false;
15351
+ }
15352
+ visitImportType.test = function(node, path, state) {
15353
+ return node.type === 'ImportDeclaration'
15354
+ && node.isType;
15355
+ };
15356
+
14479
15357
  exports.visitorList = [
14480
15358
  visitClassProperty,
14481
15359
  visitDeclare,
15360
+ visitImportType,
14482
15361
  visitInterfaceDeclaration,
14483
15362
  visitFunctionParametricAnnotation,
14484
15363
  visitFunctionReturnAnnotation,
14485
15364
  visitMethod,
14486
15365
  visitOptionalFunctionParameterAnnotation,
14487
15366
  visitTypeAlias,
15367
+ visitTypeCast,
14488
15368
  visitTypeAnnotatedIdentifier,
14489
15369
  visitTypeAnnotatedObjectOrArrayPattern
14490
15370
  ];
14491
15371
 
14492
- },{"../src/utils":22,"esprima-fb":9}],34:[function(_dereq_,module,exports){
15372
+ },{"../src/utils":23,"esprima-fb":9}],37:[function(_dereq_,module,exports){
14493
15373
  /**
14494
- * Copyright 2013-2014, Facebook, Inc.
15374
+ * Copyright 2013-2015, Facebook, Inc.
14495
15375
  * All rights reserved.
14496
15376
  *
14497
15377
  * This source code is licensed under the BSD-style license found in the
@@ -14499,12 +15379,11 @@ exports.visitorList = [
14499
15379
  * of patent rights can be found in the PATENTS file in the same directory.
14500
15380
  */
14501
15381
  /*global exports:true*/
14502
- "use strict";
15382
+ 'use strict';
14503
15383
 
14504
15384
  var Syntax = _dereq_('jstransform').Syntax;
14505
15385
  var utils = _dereq_('jstransform/src/utils');
14506
15386
 
14507
- var FALLBACK_TAGS = _dereq_('./xjs').knownTags;
14508
15387
  var renderXJSExpressionContainer =
14509
15388
  _dereq_('./xjs').renderXJSExpressionContainer;
14510
15389
  var renderXJSLiteral = _dereq_('./xjs').renderXJSLiteral;
@@ -14550,17 +15429,7 @@ function visitReactTag(traverse, object, path, state) {
14550
15429
  // We assume that the React runtime is already in scope
14551
15430
  utils.append('React.createElement(', state);
14552
15431
 
14553
- // Identifiers with lower case or hypthens are fallback tags (strings).
14554
- // XJSMemberExpressions are not.
14555
15432
  if (nameObject.type === Syntax.XJSIdentifier && isTagName(nameObject.name)) {
14556
- // This is a temporary error message to assist upgrades
14557
- if (!FALLBACK_TAGS.hasOwnProperty(nameObject.name)) {
14558
- throw new Error(
14559
- 'Lower case component names (' + nameObject.name + ') are no longer ' +
14560
- 'supported in JSX: See http://fb.me/react-jsx-lower-case'
14561
- );
14562
- }
14563
-
14564
15433
  utils.append('"' + nameObject.name + '"', state);
14565
15434
  utils.move(nameObject.range[1], state);
14566
15435
  } else {
@@ -14744,9 +15613,9 @@ exports.visitorList = [
14744
15613
  visitReactTag
14745
15614
  ];
14746
15615
 
14747
- },{"./xjs":36,"jstransform":21,"jstransform/src/utils":22}],35:[function(_dereq_,module,exports){
15616
+ },{"./xjs":39,"jstransform":22,"jstransform/src/utils":23}],38:[function(_dereq_,module,exports){
14748
15617
  /**
14749
- * Copyright 2013-2014, Facebook, Inc.
15618
+ * Copyright 2013-2015, Facebook, Inc.
14750
15619
  * All rights reserved.
14751
15620
  *
14752
15621
  * This source code is licensed under the BSD-style license found in the
@@ -14754,7 +15623,7 @@ exports.visitorList = [
14754
15623
  * of patent rights can be found in the PATENTS file in the same directory.
14755
15624
  */
14756
15625
  /*global exports:true*/
14757
- "use strict";
15626
+ 'use strict';
14758
15627
 
14759
15628
  var Syntax = _dereq_('jstransform').Syntax;
14760
15629
  var utils = _dereq_('jstransform/src/utils');
@@ -14767,10 +15636,10 @@ function addDisplayName(displayName, object, state) {
14767
15636
  object.callee.object.name === 'React' &&
14768
15637
  object.callee.property.type === Syntax.Identifier &&
14769
15638
  object.callee.property.name === 'createClass' &&
14770
- object['arguments'].length === 1 &&
14771
- object['arguments'][0].type === Syntax.ObjectExpression) {
15639
+ object.arguments.length === 1 &&
15640
+ object.arguments[0].type === Syntax.ObjectExpression) {
14772
15641
  // Verify that the displayName property isn't already set
14773
- var properties = object['arguments'][0].properties;
15642
+ var properties = object.arguments[0].properties;
14774
15643
  var safe = properties.every(function(property) {
14775
15644
  var value = property.key.type === Syntax.Identifier ?
14776
15645
  property.key.name :
@@ -14779,7 +15648,7 @@ function addDisplayName(displayName, object, state) {
14779
15648
  });
14780
15649
 
14781
15650
  if (safe) {
14782
- utils.catchup(object['arguments'][0].range[0] + 1, state);
15651
+ utils.catchup(object.arguments[0].range[0] + 1, state);
14783
15652
  utils.append('displayName: "' + displayName + '",', state);
14784
15653
  }
14785
15654
  }
@@ -14839,9 +15708,9 @@ exports.visitorList = [
14839
15708
  visitReactDisplayName
14840
15709
  ];
14841
15710
 
14842
- },{"jstransform":21,"jstransform/src/utils":22}],36:[function(_dereq_,module,exports){
15711
+ },{"jstransform":22,"jstransform/src/utils":23}],39:[function(_dereq_,module,exports){
14843
15712
  /**
14844
- * Copyright 2013-2014, Facebook, Inc.
15713
+ * Copyright 2013-2015, Facebook, Inc.
14845
15714
  * All rights reserved.
14846
15715
  *
14847
15716
  * This source code is licensed under the BSD-style license found in the
@@ -14849,146 +15718,10 @@ exports.visitorList = [
14849
15718
  * of patent rights can be found in the PATENTS file in the same directory.
14850
15719
  */
14851
15720
  /*global exports:true*/
14852
- "use strict";
15721
+ 'use strict';
14853
15722
  var Syntax = _dereq_('jstransform').Syntax;
14854
15723
  var utils = _dereq_('jstransform/src/utils');
14855
15724
 
14856
- var knownTags = {
14857
- a: true,
14858
- abbr: true,
14859
- address: true,
14860
- applet: true,
14861
- area: true,
14862
- article: true,
14863
- aside: true,
14864
- audio: true,
14865
- b: true,
14866
- base: true,
14867
- bdi: true,
14868
- bdo: true,
14869
- big: true,
14870
- blockquote: true,
14871
- body: true,
14872
- br: true,
14873
- button: true,
14874
- canvas: true,
14875
- caption: true,
14876
- circle: true,
14877
- cite: true,
14878
- code: true,
14879
- col: true,
14880
- colgroup: true,
14881
- command: true,
14882
- data: true,
14883
- datalist: true,
14884
- dd: true,
14885
- defs: true,
14886
- del: true,
14887
- details: true,
14888
- dfn: true,
14889
- dialog: true,
14890
- div: true,
14891
- dl: true,
14892
- dt: true,
14893
- ellipse: true,
14894
- em: true,
14895
- embed: true,
14896
- fieldset: true,
14897
- figcaption: true,
14898
- figure: true,
14899
- footer: true,
14900
- form: true,
14901
- g: true,
14902
- h1: true,
14903
- h2: true,
14904
- h3: true,
14905
- h4: true,
14906
- h5: true,
14907
- h6: true,
14908
- head: true,
14909
- header: true,
14910
- hgroup: true,
14911
- hr: true,
14912
- html: true,
14913
- i: true,
14914
- iframe: true,
14915
- img: true,
14916
- input: true,
14917
- ins: true,
14918
- kbd: true,
14919
- keygen: true,
14920
- label: true,
14921
- legend: true,
14922
- li: true,
14923
- line: true,
14924
- linearGradient: true,
14925
- link: true,
14926
- main: true,
14927
- map: true,
14928
- mark: true,
14929
- marquee: true,
14930
- mask: false,
14931
- menu: true,
14932
- menuitem: true,
14933
- meta: true,
14934
- meter: true,
14935
- nav: true,
14936
- noscript: true,
14937
- object: true,
14938
- ol: true,
14939
- optgroup: true,
14940
- option: true,
14941
- output: true,
14942
- p: true,
14943
- param: true,
14944
- path: true,
14945
- pattern: false,
14946
- picture: true,
14947
- polygon: true,
14948
- polyline: true,
14949
- pre: true,
14950
- progress: true,
14951
- q: true,
14952
- radialGradient: true,
14953
- rect: true,
14954
- rp: true,
14955
- rt: true,
14956
- ruby: true,
14957
- s: true,
14958
- samp: true,
14959
- script: true,
14960
- section: true,
14961
- select: true,
14962
- small: true,
14963
- source: true,
14964
- span: true,
14965
- stop: true,
14966
- strong: true,
14967
- style: true,
14968
- sub: true,
14969
- summary: true,
14970
- sup: true,
14971
- svg: true,
14972
- table: true,
14973
- tbody: true,
14974
- td: true,
14975
- text: true,
14976
- textarea: true,
14977
- tfoot: true,
14978
- th: true,
14979
- thead: true,
14980
- time: true,
14981
- title: true,
14982
- tr: true,
14983
- track: true,
14984
- tspan: true,
14985
- u: true,
14986
- ul: true,
14987
- 'var': true,
14988
- video: true,
14989
- wbr: true
14990
- };
14991
-
14992
15725
  function renderXJSLiteral(object, isLast, state, start, end) {
14993
15726
  var lines = object.value.split(/\r\n|\n|\r/);
14994
15727
 
@@ -14998,13 +15731,13 @@ function renderXJSLiteral(object, isLast, state, start, end) {
14998
15731
 
14999
15732
  var lastNonEmptyLine = 0;
15000
15733
 
15001
- lines.forEach(function (line, index) {
15734
+ lines.forEach(function(line, index) {
15002
15735
  if (line.match(/[^ \t]/)) {
15003
15736
  lastNonEmptyLine = index;
15004
15737
  }
15005
15738
  });
15006
15739
 
15007
- lines.forEach(function (line, index) {
15740
+ lines.forEach(function(line, index) {
15008
15741
  var isFirstLine = index === 0;
15009
15742
  var isLastLine = index === lines.length - 1;
15010
15743
  var isLastNonEmptyLine = index === lastNonEmptyLine;
@@ -15027,7 +15760,7 @@ function renderXJSLiteral(object, isLast, state, start, end) {
15027
15760
  if (trimmedLine || isLastNonEmptyLine) {
15028
15761
  utils.append(
15029
15762
  JSON.stringify(trimmedLine) +
15030
- (!isLastNonEmptyLine ? " + ' ' +" : ''),
15763
+ (!isLastNonEmptyLine ? ' + \' \' +' : ''),
15031
15764
  state);
15032
15765
 
15033
15766
  if (isLastNonEmptyLine) {
@@ -15083,24 +15816,34 @@ function trimLeft(value) {
15083
15816
  return value.replace(/^[ ]+/, '');
15084
15817
  }
15085
15818
 
15086
- exports.knownTags = knownTags;
15087
15819
  exports.renderXJSExpressionContainer = renderXJSExpressionContainer;
15088
15820
  exports.renderXJSLiteral = renderXJSLiteral;
15089
15821
  exports.quoteAttrName = quoteAttrName;
15090
15822
  exports.trimLeft = trimLeft;
15091
15823
 
15092
- },{"jstransform":21,"jstransform/src/utils":22}],37:[function(_dereq_,module,exports){
15824
+ },{"jstransform":22,"jstransform/src/utils":23}],40:[function(_dereq_,module,exports){
15093
15825
  /*global exports:true*/
15094
- var es6ArrowFunctions = _dereq_('jstransform/visitors/es6-arrow-function-visitors');
15826
+
15827
+ 'use strict';
15828
+
15829
+ var es6ArrowFunctions =
15830
+ _dereq_('jstransform/visitors/es6-arrow-function-visitors');
15095
15831
  var es6Classes = _dereq_('jstransform/visitors/es6-class-visitors');
15096
- var es6Destructuring = _dereq_('jstransform/visitors/es6-destructuring-visitors');
15097
- var es6ObjectConciseMethod = _dereq_('jstransform/visitors/es6-object-concise-method-visitors');
15098
- var es6ObjectShortNotation = _dereq_('jstransform/visitors/es6-object-short-notation-visitors');
15832
+ var es6Destructuring =
15833
+ _dereq_('jstransform/visitors/es6-destructuring-visitors');
15834
+ var es6ObjectConciseMethod =
15835
+ _dereq_('jstransform/visitors/es6-object-concise-method-visitors');
15836
+ var es6ObjectShortNotation =
15837
+ _dereq_('jstransform/visitors/es6-object-short-notation-visitors');
15099
15838
  var es6RestParameters = _dereq_('jstransform/visitors/es6-rest-param-visitors');
15100
15839
  var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors');
15101
- var es7SpreadProperty = _dereq_('jstransform/visitors/es7-spread-property-visitors');
15840
+ var es6CallSpread =
15841
+ _dereq_('jstransform/visitors/es6-call-spread-visitors');
15842
+ var es7SpreadProperty =
15843
+ _dereq_('jstransform/visitors/es7-spread-property-visitors');
15102
15844
  var react = _dereq_('./transforms/react');
15103
15845
  var reactDisplayName = _dereq_('./transforms/reactDisplayName');
15846
+ var reservedWords = _dereq_('jstransform/visitors/reserved-words-visitors');
15104
15847
 
15105
15848
  /**
15106
15849
  * Map from transformName => orderedListOfVisitors.
@@ -15113,8 +15856,10 @@ var transformVisitors = {
15113
15856
  'es6-object-short-notation': es6ObjectShortNotation.visitorList,
15114
15857
  'es6-rest-params': es6RestParameters.visitorList,
15115
15858
  'es6-templates': es6Templates.visitorList,
15859
+ 'es6-call-spread': es6CallSpread.visitorList,
15116
15860
  'es7-spread-property': es7SpreadProperty.visitorList,
15117
- 'react': react.visitorList.concat(reactDisplayName.visitorList)
15861
+ 'react': react.visitorList.concat(reactDisplayName.visitorList),
15862
+ 'reserved-words': reservedWords.visitorList
15118
15863
  };
15119
15864
 
15120
15865
  var transformSets = {
@@ -15126,8 +15871,12 @@ var transformSets = {
15126
15871
  'es6-rest-params',
15127
15872
  'es6-templates',
15128
15873
  'es6-destructuring',
15874
+ 'es6-call-spread',
15129
15875
  'es7-spread-property'
15130
15876
  ],
15877
+ 'es3': [
15878
+ 'reserved-words'
15879
+ ],
15131
15880
  'react': [
15132
15881
  'react'
15133
15882
  ]
@@ -15137,6 +15886,7 @@ var transformSets = {
15137
15886
  * Specifies the order in which each transform should run.
15138
15887
  */
15139
15888
  var transformRunOrder = [
15889
+ 'reserved-words',
15140
15890
  'es6-arrow-functions',
15141
15891
  'es6-object-concise-method',
15142
15892
  'es6-object-short-notation',
@@ -15144,6 +15894,7 @@ var transformRunOrder = [
15144
15894
  'es6-rest-params',
15145
15895
  'es6-templates',
15146
15896
  'es6-destructuring',
15897
+ 'es6-call-spread',
15147
15898
  'es7-spread-property',
15148
15899
  'react'
15149
15900
  ];
@@ -15197,5 +15948,34 @@ exports.getVisitorsBySet = getVisitorsBySet;
15197
15948
  exports.getAllVisitors = getAllVisitors;
15198
15949
  exports.transformVisitors = transformVisitors;
15199
15950
 
15200
- },{"./transforms/react":34,"./transforms/reactDisplayName":35,"jstransform/visitors/es6-arrow-function-visitors":23,"jstransform/visitors/es6-class-visitors":24,"jstransform/visitors/es6-destructuring-visitors":25,"jstransform/visitors/es6-object-concise-method-visitors":26,"jstransform/visitors/es6-object-short-notation-visitors":27,"jstransform/visitors/es6-rest-param-visitors":28,"jstransform/visitors/es6-template-visitors":29,"jstransform/visitors/es7-spread-property-visitors":31}]},{},[1])(1)
15951
+ },{"./transforms/react":37,"./transforms/reactDisplayName":38,"jstransform/visitors/es6-arrow-function-visitors":24,"jstransform/visitors/es6-call-spread-visitors":25,"jstransform/visitors/es6-class-visitors":26,"jstransform/visitors/es6-destructuring-visitors":27,"jstransform/visitors/es6-object-concise-method-visitors":28,"jstransform/visitors/es6-object-short-notation-visitors":29,"jstransform/visitors/es6-rest-param-visitors":30,"jstransform/visitors/es6-template-visitors":31,"jstransform/visitors/es7-spread-property-visitors":33,"jstransform/visitors/reserved-words-visitors":35}],41:[function(_dereq_,module,exports){
15952
+ /**
15953
+ * Copyright 2013-2015, Facebook, Inc.
15954
+ * All rights reserved.
15955
+ *
15956
+ * This source code is licensed under the BSD-style license found in the
15957
+ * LICENSE file in the root directory of this source tree. An additional grant
15958
+ * of patent rights can be found in the PATENTS file in the same directory.
15959
+ */
15960
+
15961
+ 'use strict';
15962
+ /*eslint-disable no-undef*/
15963
+ var Buffer = _dereq_('buffer').Buffer;
15964
+
15965
+ function inlineSourceMap(sourceMap, sourceCode, sourceFilename) {
15966
+ // This can be used with a sourcemap that has already has toJSON called on it.
15967
+ // Check first.
15968
+ var json = sourceMap;
15969
+ if (typeof sourceMap.toJSON === 'function') {
15970
+ json = sourceMap.toJSON();
15971
+ }
15972
+ json.sources = [sourceFilename];
15973
+ json.sourcesContent = [sourceCode];
15974
+ var base64 = Buffer(JSON.stringify(json)).toString('base64');
15975
+ return '//# sourceMappingURL=data:application/json;base64,' + base64;
15976
+ }
15977
+
15978
+ module.exports = inlineSourceMap;
15979
+
15980
+ },{"buffer":3}]},{},[1])(1)
15201
15981
  });