react 0.11.0-rc1 → 0.12.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 (173) hide show
  1. package/dist/JSXTransformer.js +1830 -1417
  2. package/dist/react-with-addons.js +3082 -3531
  3. package/dist/react-with-addons.min.js +11 -17
  4. package/dist/react.js +2941 -3304
  5. package/dist/react.min.js +11 -16
  6. package/lib/AutoFocusMixin.js +5 -12
  7. package/lib/BeforeInputEventPlugin.js +12 -14
  8. package/lib/CSSCore.js +6 -13
  9. package/lib/CSSProperty.js +5 -12
  10. package/lib/CSSPropertyOperations.js +46 -12
  11. package/lib/CallbackQueue.js +7 -14
  12. package/lib/ChangeEventPlugin.js +5 -12
  13. package/lib/ClientReactRootIndex.js +5 -12
  14. package/lib/CompositionEventPlugin.js +5 -12
  15. package/lib/DOMChildrenOperations.js +8 -15
  16. package/lib/DOMProperty.js +16 -19
  17. package/lib/DOMPropertyOperations.js +14 -14
  18. package/lib/Danger.js +12 -17
  19. package/lib/DefaultEventPluginOrder.js +5 -12
  20. package/lib/EnterLeaveEventPlugin.js +5 -12
  21. package/lib/EventConstants.js +5 -12
  22. package/lib/EventListener.js +14 -0
  23. package/lib/EventPluginHub.js +8 -26
  24. package/lib/EventPluginRegistry.js +5 -12
  25. package/lib/EventPluginUtils.js +5 -12
  26. package/lib/EventPropagators.js +12 -17
  27. package/lib/ExecutionEnvironment.js +5 -12
  28. package/lib/HTMLDOMPropertyConfig.js +14 -16
  29. package/lib/LinkedStateMixin.js +5 -12
  30. package/lib/LinkedValueUtils.js +5 -12
  31. package/lib/LocalEventTrapMixin.js +8 -14
  32. package/lib/MobileSafariClickEventPlugin.js +5 -12
  33. package/lib/Object.assign.js +45 -0
  34. package/lib/PooledClass.js +5 -12
  35. package/lib/React.js +92 -38
  36. package/lib/ReactBrowserComponentMixin.js +5 -12
  37. package/lib/ReactBrowserEventEmitter.js +7 -14
  38. package/lib/ReactCSSTransitionGroup.js +15 -17
  39. package/lib/ReactCSSTransitionGroupChild.js +9 -13
  40. package/lib/ReactChildren.js +5 -12
  41. package/lib/ReactComponent.js +61 -68
  42. package/lib/ReactComponentBrowserEnvironment.js +5 -12
  43. package/lib/ReactComponentWithPureRenderMixin.js +5 -12
  44. package/lib/ReactCompositeComponent.js +199 -180
  45. package/lib/ReactContext.js +8 -15
  46. package/lib/ReactCurrentOwner.js +5 -12
  47. package/lib/ReactDOM.js +145 -175
  48. package/lib/ReactDOMButton.js +8 -14
  49. package/lib/ReactDOMComponent.js +103 -38
  50. package/lib/ReactDOMForm.js +9 -15
  51. package/lib/ReactDOMIDOperations.js +5 -12
  52. package/lib/ReactDOMImg.js +8 -14
  53. package/lib/ReactDOMInput.js +30 -38
  54. package/lib/ReactDOMOption.js +8 -14
  55. package/lib/ReactDOMSelect.js +25 -24
  56. package/lib/ReactDOMSelection.js +11 -18
  57. package/lib/ReactDOMTextarea.js +19 -24
  58. package/lib/ReactDefaultBatchingStrategy.js +14 -18
  59. package/lib/ReactDefaultInjection.js +23 -26
  60. package/lib/ReactDefaultPerf.js +13 -16
  61. package/lib/ReactDefaultPerfAnalysis.js +18 -17
  62. package/lib/ReactElement.js +229 -0
  63. package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +48 -65
  64. package/lib/ReactEmptyComponent.js +8 -13
  65. package/lib/ReactErrorUtils.js +5 -12
  66. package/lib/ReactEventEmitterMixin.js +5 -12
  67. package/lib/ReactEventListener.js +7 -14
  68. package/lib/ReactInjection.js +7 -14
  69. package/lib/ReactInputSelection.js +5 -12
  70. package/lib/ReactInstanceHandles.js +5 -12
  71. package/lib/ReactLegacyElement.js +232 -0
  72. package/lib/ReactLink.js +5 -12
  73. package/lib/ReactMarkupChecksum.js +5 -12
  74. package/lib/ReactMount.js +45 -32
  75. package/lib/ReactMultiChild.js +14 -18
  76. package/lib/ReactMultiChildUpdateTypes.js +5 -12
  77. package/lib/ReactNativeComponent.js +69 -0
  78. package/lib/ReactOwner.js +5 -12
  79. package/lib/ReactPerf.js +8 -13
  80. package/lib/ReactPropTransferer.js +34 -33
  81. package/lib/ReactPropTypeLocationNames.js +5 -12
  82. package/lib/ReactPropTypeLocations.js +5 -12
  83. package/lib/ReactPropTypes.js +38 -29
  84. package/lib/ReactPutListenerQueue.js +7 -14
  85. package/lib/ReactReconcileTransaction.js +7 -15
  86. package/lib/ReactRootIndex.js +5 -12
  87. package/lib/ReactServerRendering.js +21 -34
  88. package/lib/ReactServerRenderingTransaction.js +11 -15
  89. package/lib/ReactStateSetters.js +5 -12
  90. package/lib/ReactTestUtils.js +31 -33
  91. package/lib/ReactTextComponent.js +18 -21
  92. package/lib/ReactTransitionChildMapping.js +6 -13
  93. package/lib/ReactTransitionEvents.js +5 -12
  94. package/lib/ReactTransitionGroup.js +14 -17
  95. package/lib/ReactUpdates.js +43 -22
  96. package/lib/ReactWithAddons.js +7 -13
  97. package/lib/SVGDOMPropertyConfig.js +5 -12
  98. package/lib/SelectEventPlugin.js +13 -20
  99. package/lib/ServerReactRootIndex.js +5 -12
  100. package/lib/SimpleEventPlugin.js +20 -15
  101. package/lib/SyntheticClipboardEvent.js +5 -12
  102. package/lib/SyntheticCompositionEvent.js +5 -12
  103. package/lib/SyntheticDragEvent.js +5 -12
  104. package/lib/SyntheticEvent.js +9 -17
  105. package/lib/SyntheticFocusEvent.js +5 -12
  106. package/lib/SyntheticInputEvent.js +4 -11
  107. package/lib/SyntheticKeyboardEvent.js +17 -19
  108. package/lib/SyntheticMouseEvent.js +6 -13
  109. package/lib/SyntheticTouchEvent.js +5 -12
  110. package/lib/SyntheticUIEvent.js +5 -12
  111. package/lib/SyntheticWheelEvent.js +5 -12
  112. package/lib/Transaction.js +5 -12
  113. package/lib/ViewportMetrics.js +5 -12
  114. package/lib/accumulateInto.js +62 -0
  115. package/lib/adler32.js +6 -13
  116. package/lib/camelize.js +30 -0
  117. package/lib/camelizeStyleName.js +40 -0
  118. package/lib/cloneWithProps.js +9 -15
  119. package/lib/containsNode.js +5 -12
  120. package/lib/copyProperties.js +12 -12
  121. package/lib/createArrayFrom.js +5 -12
  122. package/lib/createFullPageComponent.js +12 -18
  123. package/lib/createNodesFromMarkup.js +5 -12
  124. package/lib/cx.js +5 -12
  125. package/lib/dangerousStyleValue.js +5 -12
  126. package/lib/deprecated.js +47 -0
  127. package/lib/emptyFunction.js +11 -22
  128. package/lib/emptyObject.js +5 -12
  129. package/lib/escapeTextForBrowser.js +5 -12
  130. package/lib/flattenChildren.js +19 -13
  131. package/lib/focusNode.js +10 -16
  132. package/lib/forEachAccumulated.js +5 -12
  133. package/lib/getActiveElement.js +5 -12
  134. package/lib/getEventCharCode.js +50 -0
  135. package/lib/getEventKey.js +9 -21
  136. package/lib/getEventModifierState.js +10 -17
  137. package/lib/getEventTarget.js +5 -12
  138. package/lib/getMarkupWrap.js +5 -12
  139. package/lib/getNodeForCharacterOffset.js +5 -12
  140. package/lib/getReactRootElementInContainer.js +5 -12
  141. package/lib/getTextContentAccessor.js +5 -12
  142. package/lib/getUnboundedScrollPosition.js +5 -12
  143. package/lib/hyphenate.js +5 -12
  144. package/lib/hyphenateStyleName.js +8 -15
  145. package/lib/instantiateReactComponent.js +90 -42
  146. package/lib/invariant.js +5 -12
  147. package/lib/isEventSupported.js +5 -12
  148. package/lib/isNode.js +5 -12
  149. package/lib/isTextInputElement.js +5 -12
  150. package/lib/isTextNode.js +5 -12
  151. package/lib/joinClasses.js +8 -13
  152. package/lib/keyMirror.js +5 -12
  153. package/lib/keyOf.js +5 -12
  154. package/lib/mapObject.js +35 -36
  155. package/lib/memoizeStringOnly.js +5 -12
  156. package/lib/merge.js +14 -17
  157. package/lib/mergeInto.js +13 -35
  158. package/lib/monitorCodeUse.js +5 -12
  159. package/lib/onlyChild.js +8 -15
  160. package/lib/performance.js +5 -12
  161. package/lib/performanceNow.js +5 -12
  162. package/lib/setInnerHTML.js +19 -20
  163. package/lib/shallowEqual.js +6 -13
  164. package/lib/shouldUpdateReactComponent.js +14 -22
  165. package/lib/toArray.js +5 -12
  166. package/lib/traverseAllChildren.js +34 -48
  167. package/lib/update.js +8 -15
  168. package/lib/warning.js +5 -12
  169. package/package.json +3 -8
  170. package/lib/ReactDescriptor.js +0 -243
  171. package/lib/accumulate.js +0 -54
  172. package/lib/mergeHelpers.js +0 -147
  173. package/lib/mixInto.js +0 -34
@@ -1,310 +1,336 @@
1
1
  /**
2
- * JSXTransformer v0.11.0-rc1
2
+ * JSXTransformer v0.12.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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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
- (function (process,__filename){
6
- /** vim: et:ts=4:sw=4:sts=4
7
- * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
8
- * Available via the MIT or new BSD license.
9
- * see: http://github.com/jrburke/amdefine for details
10
- */
11
-
12
- /*jslint node: true */
13
- /*global module, process */
14
- 'use strict';
15
-
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){
16
5
  /**
17
- * Creates a define for node.
18
- * @param {Object} module the "module" object that is defined by Node for the
19
- * current module.
20
- * @param {Function} [requireFn]. Node's require function for the current module.
21
- * It only needs to be passed in Node versions before 0.5, when module.require
22
- * did not exist.
23
- * @returns {Function} a define function that is usable for the current node
24
- * module.
6
+ * Copyright 2013-2014, Facebook, Inc.
7
+ * All rights reserved.
8
+ *
9
+ * This source code is licensed under the BSD-style license found in the
10
+ * LICENSE file in the root directory of this source tree. An additional grant
11
+ * of patent rights can be found in the PATENTS file in the same directory.
25
12
  */
26
- function amdefine(module, requireFn) {
27
- 'use strict';
28
- var defineCache = {},
29
- loaderCache = {},
30
- alreadyCalled = false,
31
- path = _dereq_('path'),
32
- makeRequire, stringRequire;
33
-
34
- /**
35
- * Trims the . and .. from an array of path segments.
36
- * It will keep a leading path segment if a .. will become
37
- * the first path segment, to help with module name lookups,
38
- * which act like paths, but can be remapped. But the end result,
39
- * all paths that use this function should look normalized.
40
- * NOTE: this method MODIFIES the input array.
41
- * @param {Array} ary the array of path segments.
42
- */
43
- function trimDots(ary) {
44
- var i, part;
45
- for (i = 0; ary[i]; i+= 1) {
46
- part = ary[i];
47
- if (part === '.') {
48
- ary.splice(i, 1);
49
- i -= 1;
50
- } else if (part === '..') {
51
- if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
52
- //End of the line. Keep at least one non-dot
53
- //path segment at the front so it can be mapped
54
- //correctly to disk. Otherwise, there is likely
55
- //no path mapping for a path starting with '..'.
56
- //This can still fail, but catches the most reasonable
57
- //uses of ..
58
- break;
59
- } else if (i > 0) {
60
- ary.splice(i - 1, 2);
61
- i -= 2;
62
- }
63
- }
64
- }
65
- }
13
+ /* jshint browser: true */
14
+ /* jslint evil: true */
66
15
 
67
- function normalize(name, baseName) {
68
- var baseParts;
16
+ 'use strict';
69
17
 
70
- //Adjust any relative paths.
71
- if (name && name.charAt(0) === '.') {
72
- //If have a base name, try to normalize against it,
73
- //otherwise, assume it is a top-level require that will
74
- //be relative to baseUrl in the end.
75
- if (baseName) {
76
- baseParts = baseName.split('/');
77
- baseParts = baseParts.slice(0, baseParts.length - 1);
78
- baseParts = baseParts.concat(name.split('/'));
79
- trimDots(baseParts);
80
- name = baseParts.join('/');
81
- }
82
- }
18
+ var buffer = _dereq_('buffer');
19
+ var transform = _dereq_('jstransform').transform;
20
+ var visitors = _dereq_('./fbtransform/visitors');
83
21
 
84
- return name;
85
- }
22
+ var headEl;
23
+ var dummyAnchor;
24
+ var inlineScriptCount = 0;
86
25
 
87
- /**
88
- * Create the normalize() function passed to a loader plugin's
89
- * normalize method.
90
- */
91
- function makeNormalize(relName) {
92
- return function (name) {
93
- return normalize(name, relName);
94
- };
95
- }
26
+ // The source-map library relies on Object.defineProperty, but IE8 doesn't
27
+ // support it fully even with es5-sham. Indeed, es5-sham's defineProperty
28
+ // throws when Object.prototype.__defineGetter__ is missing, so we skip building
29
+ // the source map in that case.
30
+ var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
96
31
 
97
- function makeLoad(id) {
98
- function load(value) {
99
- loaderCache[id] = value;
100
- }
32
+ /**
33
+ * Run provided code through jstransform.
34
+ *
35
+ * @param {string} source Original source code
36
+ * @param {object?} options Options to pass to jstransform
37
+ * @return {object} object as returned from jstransform
38
+ */
39
+ function transformReact(source, options) {
40
+ // TODO: just use react-tools
41
+ options = options || {};
42
+ var visitorList;
43
+ if (options.harmony) {
44
+ visitorList = visitors.getAllVisitors();
45
+ } else {
46
+ visitorList = visitors.transformVisitors.react;
47
+ }
101
48
 
102
- load.fromText = function (id, text) {
103
- //This one is difficult because the text can/probably uses
104
- //define, and any relative paths and requires should be relative
105
- //to that id was it would be found on disk. But this would require
106
- //bootstrapping a module/require fairly deeply from node core.
107
- //Not sure how best to go about that yet.
108
- throw new Error('amdefine does not implement load.fromText');
109
- };
49
+ return transform(visitorList, source, {
50
+ sourceMap: supportsAccessors && options.sourceMap
51
+ });
52
+ }
110
53
 
111
- return load;
112
- }
54
+ /**
55
+ * Eval provided source after transforming it.
56
+ *
57
+ * @param {string} source Original source code
58
+ * @param {object?} options Options to pass to jstransform
59
+ */
60
+ function exec(source, options) {
61
+ return eval(transformReact(source, options).code);
62
+ }
113
63
 
114
- makeRequire = function (systemRequire, exports, module, relId) {
115
- function amdRequire(deps, callback) {
116
- if (typeof deps === 'string') {
117
- //Synchronous, single module require('')
118
- return stringRequire(systemRequire, exports, module, deps, relId);
119
- } else {
120
- //Array of dependencies with a callback.
64
+ /**
65
+ * This method returns a nicely formated line of code pointing to the exact
66
+ * location of the error `e`. The line is limited in size so big lines of code
67
+ * are also shown in a readable way.
68
+ *
69
+ * Example:
70
+ * ... x', overflow:'scroll'}} id={} onScroll={this.scroll} class=" ...
71
+ * ^
72
+ *
73
+ * @param {string} code The full string of code
74
+ * @param {Error} e The error being thrown
75
+ * @return {string} formatted message
76
+ * @internal
77
+ */
78
+ function createSourceCodeErrorMessage(code, e) {
79
+ var sourceLines = code.split('\n');
80
+ var erroneousLine = sourceLines[e.lineNumber - 1];
121
81
 
122
- //Convert the dependencies to modules.
123
- deps = deps.map(function (depName) {
124
- return stringRequire(systemRequire, exports, module, depName, relId);
125
- });
82
+ // Removes any leading indenting spaces and gets the number of
83
+ // chars indenting the `erroneousLine`
84
+ var indentation = 0;
85
+ erroneousLine = erroneousLine.replace(/^\s+/, function(leadingSpaces) {
86
+ indentation = leadingSpaces.length;
87
+ return '';
88
+ });
126
89
 
127
- //Wait for next tick to call back the require call.
128
- process.nextTick(function () {
129
- callback.apply(null, deps);
130
- });
131
- }
132
- }
90
+ // Defines the number of characters that are going to show
91
+ // before and after the erroneous code
92
+ var LIMIT = 30;
93
+ var errorColumn = e.column - indentation;
133
94
 
134
- amdRequire.toUrl = function (filePath) {
135
- if (filePath.indexOf('.') === 0) {
136
- return normalize(filePath, path.dirname(module.filename));
137
- } else {
138
- return filePath;
139
- }
140
- };
95
+ if (errorColumn > LIMIT) {
96
+ erroneousLine = '... ' + erroneousLine.slice(errorColumn - LIMIT);
97
+ errorColumn = 4 + LIMIT;
98
+ }
99
+ if (erroneousLine.length - errorColumn > LIMIT) {
100
+ erroneousLine = erroneousLine.slice(0, errorColumn + LIMIT) + ' ...';
101
+ }
102
+ var message = '\n\n' + erroneousLine + '\n';
103
+ message += new Array(errorColumn - 1).join(' ') + '^';
104
+ return message;
105
+ }
141
106
 
142
- return amdRequire;
143
- };
107
+ /**
108
+ * Actually transform the code.
109
+ *
110
+ * @param {string} code
111
+ * @param {string?} url
112
+ * @param {object?} options
113
+ * @return {string} The transformed code.
114
+ * @internal
115
+ */
116
+ function transformCode(code, url, options) {
117
+ try {
118
+ var transformed = transformReact(code, options);
119
+ } catch(e) {
120
+ e.message += '\n at ';
121
+ if (url) {
122
+ if ('fileName' in e) {
123
+ // We set `fileName` if it's supported by this error object and
124
+ // a `url` was provided.
125
+ // The error will correctly point to `url` in Firefox.
126
+ e.fileName = url;
127
+ }
128
+ e.message += url + ':' + e.lineNumber + ':' + e.column;
129
+ } else {
130
+ e.message += location.href;
131
+ }
132
+ e.message += createSourceCodeErrorMessage(code, e);
133
+ throw e;
134
+ }
144
135
 
145
- //Favor explicit value, passed in if the module wants to support Node 0.4.
146
- requireFn = requireFn || function req() {
147
- return module.require.apply(module, arguments);
148
- };
136
+ if (!transformed.sourceMap) {
137
+ return transformed.code;
138
+ }
149
139
 
150
- function runFactory(id, deps, factory) {
151
- var r, e, m, result;
140
+ var map = transformed.sourceMap.toJSON();
141
+ var source;
142
+ if (url == null) {
143
+ source = "Inline JSX script";
144
+ inlineScriptCount++;
145
+ if (inlineScriptCount > 1) {
146
+ source += ' (' + inlineScriptCount + ')';
147
+ }
148
+ } else if (dummyAnchor) {
149
+ // Firefox has problems when the sourcemap source is a proper URL with a
150
+ // protocol and hostname, so use the pathname. We could use just the
151
+ // filename, but hopefully using the full path will prevent potential
152
+ // issues where the same filename exists in multiple directories.
153
+ dummyAnchor.href = url;
154
+ source = dummyAnchor.pathname.substr(1);
155
+ }
156
+ map.sources = [source];
157
+ map.sourcesContent = [code];
152
158
 
153
- if (id) {
154
- e = loaderCache[id] = {};
155
- m = {
156
- id: id,
157
- uri: __filename,
158
- exports: e
159
- };
160
- r = makeRequire(requireFn, e, m, id);
161
- } else {
162
- //Only support one define call per file
163
- if (alreadyCalled) {
164
- throw new Error('amdefine with no module ID cannot be called more than once per file.');
165
- }
166
- alreadyCalled = true;
159
+ return (
160
+ transformed.code +
161
+ '\n//# sourceMappingURL=data:application/json;base64,' +
162
+ buffer.Buffer(JSON.stringify(map)).toString('base64')
163
+ );
164
+ }
167
165
 
168
- //Use the real variables from node
169
- //Use module.exports for exports, since
170
- //the exports in here is amdefine exports.
171
- e = module.exports;
172
- m = module;
173
- r = makeRequire(requireFn, e, m, module.id);
174
- }
175
166
 
176
- //If there are dependencies, they are strings, so need
177
- //to convert them to dependency values.
178
- if (deps) {
179
- deps = deps.map(function (depName) {
180
- return r(depName);
181
- });
182
- }
167
+ /**
168
+ * Appends a script element at the end of the <head> with the content of code,
169
+ * after transforming it.
170
+ *
171
+ * @param {string} code The original source code
172
+ * @param {string?} url Where the code came from. null if inline
173
+ * @param {object?} options Options to pass to jstransform
174
+ * @internal
175
+ */
176
+ function run(code, url, options) {
177
+ var scriptEl = document.createElement('script');
178
+ scriptEl.text = transformCode(code, url, options);
179
+ headEl.appendChild(scriptEl);
180
+ }
183
181
 
184
- //Call the factory with the right dependencies.
185
- if (typeof factory === 'function') {
186
- result = factory.apply(m.exports, deps);
187
- } else {
188
- result = factory;
189
- }
182
+ /**
183
+ * Load script from the provided url and pass the content to the callback.
184
+ *
185
+ * @param {string} url The location of the script src
186
+ * @param {function} callback Function to call with the content of url
187
+ * @internal
188
+ */
189
+ function load(url, successCallback, errorCallback) {
190
+ var xhr;
191
+ xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP')
192
+ : new XMLHttpRequest();
190
193
 
191
- if (result !== undefined) {
192
- m.exports = result;
193
- if (id) {
194
- loaderCache[id] = m.exports;
195
- }
196
- }
194
+ // async, however scripts will be executed in the order they are in the
195
+ // DOM to mirror normal script loading.
196
+ xhr.open('GET', url, true);
197
+ if ('overrideMimeType' in xhr) {
198
+ xhr.overrideMimeType('text/plain');
199
+ }
200
+ xhr.onreadystatechange = function() {
201
+ if (xhr.readyState === 4) {
202
+ if (xhr.status === 0 || xhr.status === 200) {
203
+ successCallback(xhr.responseText);
204
+ } else {
205
+ errorCallback();
206
+ throw new Error("Could not load " + url);
207
+ }
197
208
  }
209
+ };
210
+ return xhr.send(null);
211
+ }
198
212
 
199
- stringRequire = function (systemRequire, exports, module, id, relId) {
200
- //Split the ID by a ! so that
201
- var index = id.indexOf('!'),
202
- originalId = id,
203
- prefix, plugin;
213
+ /**
214
+ * Loop over provided script tags and get the content, via innerHTML if an
215
+ * inline script, or by using XHR. Transforms are applied if needed. The scripts
216
+ * are executed in the order they are found on the page.
217
+ *
218
+ * @param {array} scripts The <script> elements to load and run.
219
+ * @internal
220
+ */
221
+ function loadScripts(scripts) {
222
+ var result = [];
223
+ var count = scripts.length;
204
224
 
205
- if (index === -1) {
206
- id = normalize(id, relId);
225
+ function check() {
226
+ var script, i;
207
227
 
208
- //Straight module lookup. If it is one of the special dependencies,
209
- //deal with it, otherwise, delegate to node.
210
- if (id === 'require') {
211
- return makeRequire(systemRequire, exports, module, relId);
212
- } else if (id === 'exports') {
213
- return exports;
214
- } else if (id === 'module') {
215
- return module;
216
- } else if (loaderCache.hasOwnProperty(id)) {
217
- return loaderCache[id];
218
- } else if (defineCache[id]) {
219
- runFactory.apply(null, defineCache[id]);
220
- return loaderCache[id];
221
- } else {
222
- if(systemRequire) {
223
- return systemRequire(originalId);
224
- } else {
225
- throw new Error('No module with ID: ' + id);
226
- }
227
- }
228
- } else {
229
- //There is a plugin in play.
230
- prefix = id.substring(0, index);
231
- id = id.substring(index + 1, id.length);
228
+ for (i = 0; i < count; i++) {
229
+ script = result[i];
232
230
 
233
- plugin = stringRequire(systemRequire, exports, module, prefix, relId);
231
+ if (script.loaded && !script.executed) {
232
+ script.executed = true;
233
+ run(script.content, script.url, script.options);
234
+ } else if (!script.loaded && !script.error && !script.async) {
235
+ break;
236
+ }
237
+ }
238
+ }
234
239
 
235
- if (plugin.normalize) {
236
- id = plugin.normalize(id, makeNormalize(relId));
237
- } else {
238
- //Normalize the ID normally.
239
- id = normalize(id, relId);
240
- }
240
+ scripts.forEach(function(script, i) {
241
+ var options = {
242
+ sourceMap: true
243
+ };
244
+ if (/;harmony=true(;|$)/.test(script.type)) {
245
+ options.harmony = true
246
+ }
241
247
 
242
- if (loaderCache[id]) {
243
- return loaderCache[id];
244
- } else {
245
- plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
248
+ // script.async is always true for non-javascript script tags
249
+ var async = script.hasAttribute('async');
246
250
 
247
- return loaderCache[id];
248
- }
249
- }
250
- };
251
+ if (script.src) {
252
+ result[i] = {
253
+ async: async,
254
+ error: false,
255
+ executed: false,
256
+ content: null,
257
+ loaded: false,
258
+ url: script.src,
259
+ options: options
260
+ };
251
261
 
252
- //Create a define function specific to the module asking for amdefine.
253
- function define(id, deps, factory) {
254
- if (Array.isArray(id)) {
255
- factory = deps;
256
- deps = id;
257
- id = undefined;
258
- } else if (typeof id !== 'string') {
259
- factory = id;
260
- id = deps = undefined;
261
- }
262
+ load(script.src, function(content) {
263
+ result[i].loaded = true;
264
+ result[i].content = content;
265
+ check();
266
+ }, function() {
267
+ result[i].error = true;
268
+ check();
269
+ });
270
+ } else {
271
+ result[i] = {
272
+ async: async,
273
+ error: false,
274
+ executed: false,
275
+ content: script.innerHTML,
276
+ loaded: true,
277
+ url: null,
278
+ options: options
279
+ };
280
+ }
281
+ });
262
282
 
263
- if (deps && !Array.isArray(deps)) {
264
- factory = deps;
265
- deps = undefined;
266
- }
283
+ check();
284
+ }
267
285
 
268
- if (!deps) {
269
- deps = ['require', 'exports', 'module'];
270
- }
286
+ /**
287
+ * Find and run all script tags with type="text/jsx".
288
+ *
289
+ * @internal
290
+ */
291
+ function runScripts() {
292
+ var scripts = document.getElementsByTagName('script');
271
293
 
272
- //Set up properties for this module. If an ID, then use
273
- //internal cache. If no ID, then use the external variables
274
- //for this node module.
275
- if (id) {
276
- //Put the module in deep freeze until there is a
277
- //require call for it.
278
- defineCache[id] = [id, deps, factory];
279
- } else {
280
- runFactory(id, deps, factory);
281
- }
294
+ // Array.prototype.slice cannot be used on NodeList on IE8
295
+ var jsxScripts = [];
296
+ for (var i = 0; i < scripts.length; i++) {
297
+ if (/^text\/jsx(;|$)/.test(scripts.item(i).type)) {
298
+ jsxScripts.push(scripts.item(i));
282
299
  }
300
+ }
283
301
 
284
- //define.require, which has access to all the values in the
285
- //cache. Useful for AMD modules that all have IDs in the file,
286
- //but need to finally export a value to node based on one of those
287
- //IDs.
288
- define.require = function (id) {
289
- if (loaderCache[id]) {
290
- return loaderCache[id];
291
- }
302
+ if (jsxScripts.length < 1) {
303
+ return;
304
+ }
292
305
 
293
- if (defineCache[id]) {
294
- runFactory.apply(null, defineCache[id]);
295
- return loaderCache[id];
296
- }
297
- };
306
+ console.warn(
307
+ 'You are using the in-browser JSX transformer. Be sure to precompile ' +
308
+ 'your JSX for production - ' +
309
+ 'http://facebook.github.io/react/docs/tooling-integration.html#jsx'
310
+ );
298
311
 
299
- define.amd = {};
312
+ loadScripts(jsxScripts);
313
+ }
300
314
 
301
- return define;
315
+ // Listen for load event if we're in a browser and then kick off finding and
316
+ // running of scripts.
317
+ if (typeof window !== "undefined" && window !== null) {
318
+ headEl = document.getElementsByTagName('head')[0];
319
+ dummyAnchor = document.createElement('a');
320
+
321
+ if (window.addEventListener) {
322
+ window.addEventListener('DOMContentLoaded', runScripts, false);
323
+ } else {
324
+ window.attachEvent('onload', runScripts);
325
+ }
302
326
  }
303
327
 
304
- module.exports = amdefine;
328
+ module.exports = {
329
+ transform: transformReact,
330
+ exec: exec
331
+ };
305
332
 
306
- }).call(this,_dereq_("FWaASH"),"/../node_modules/amdefine/amdefine.js")
307
- },{"FWaASH":6,"path":5}],2:[function(_dereq_,module,exports){
333
+ },{"./fbtransform/visitors":37,"buffer":2,"jstransform":21}],2:[function(_dereq_,module,exports){
308
334
  /*!
309
335
  * The buffer module from node.js, for the browser.
310
336
  *
@@ -314,29 +340,45 @@ module.exports = amdefine;
314
340
 
315
341
  var base64 = _dereq_('base64-js')
316
342
  var ieee754 = _dereq_('ieee754')
343
+ var isArray = _dereq_('is-array')
317
344
 
318
345
  exports.Buffer = Buffer
319
346
  exports.SlowBuffer = Buffer
320
347
  exports.INSPECT_MAX_BYTES = 50
321
- Buffer.poolSize = 8192
348
+ Buffer.poolSize = 8192 // not used by this implementation
349
+
350
+ var kMaxLength = 0x3fffffff
322
351
 
323
352
  /**
324
- * If `Buffer._useTypedArrays`:
353
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
325
354
  * === true Use Uint8Array implementation (fastest)
326
- * === false Use Object implementation (compatible down to IE6)
355
+ * === false Use Object implementation (most compatible, even IE6)
356
+ *
357
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
358
+ * Opera 11.6+, iOS 4.2+.
359
+ *
360
+ * Note:
361
+ *
362
+ * - Implementation must support adding new properties to `Uint8Array` instances.
363
+ * Firefox 4-29 lacked support, fixed in Firefox 30+.
364
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
365
+ *
366
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
367
+ *
368
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
369
+ * incorrect length in some situations.
370
+ *
371
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will
372
+ * get the Object implementation, which is slower but will work correctly.
327
373
  */
328
- Buffer._useTypedArrays = (function () {
329
- // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
330
- // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
331
- // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
332
- // because we need to be able to add all the node Buffer API methods. This is an issue
333
- // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
374
+ Buffer.TYPED_ARRAY_SUPPORT = (function () {
334
375
  try {
335
376
  var buf = new ArrayBuffer(0)
336
377
  var arr = new Uint8Array(buf)
337
378
  arr.foo = function () { return 42 }
338
- return 42 === arr.foo() &&
339
- typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
379
+ return 42 === arr.foo() && // typed array instances can be augmented
380
+ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
381
+ new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
340
382
  } catch (e) {
341
383
  return false
342
384
  }
@@ -360,23 +402,27 @@ function Buffer (subject, encoding, noZero) {
360
402
 
361
403
  var type = typeof subject
362
404
 
363
- if (encoding === 'base64' && type === 'string') {
364
- subject = base64clean(subject)
365
- }
366
-
367
405
  // Find the length
368
406
  var length
369
407
  if (type === 'number')
370
- length = coerce(subject)
371
- else if (type === 'string')
408
+ length = subject > 0 ? subject >>> 0 : 0
409
+ else if (type === 'string') {
410
+ if (encoding === 'base64')
411
+ subject = base64clean(subject)
372
412
  length = Buffer.byteLength(subject, encoding)
373
- else if (type === 'object')
374
- length = coerce(subject.length) // assume that object is array-like
375
- else
376
- throw new Error('First argument needs to be a number, array or string.')
413
+ } else if (type === 'object' && subject !== null) { // assume object is array-like
414
+ if (subject.type === 'Buffer' && isArray(subject.data))
415
+ subject = subject.data
416
+ length = +subject.length > 0 ? Math.floor(+subject.length) : 0
417
+ } else
418
+ throw new TypeError('must start with number, buffer, array or string')
419
+
420
+ if (this.length > kMaxLength)
421
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
422
+ 'size: 0x' + kMaxLength.toString(16) + ' bytes')
377
423
 
378
424
  var buf
379
- if (Buffer._useTypedArrays) {
425
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
380
426
  // Preferred: Return an augmented `Uint8Array` instance for best performance
381
427
  buf = Buffer._augment(new Uint8Array(length))
382
428
  } else {
@@ -387,7 +433,7 @@ function Buffer (subject, encoding, noZero) {
387
433
  }
388
434
 
389
435
  var i
390
- if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
436
+ if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
391
437
  // Speed optimization -- use set if we're copying from a typed array
392
438
  buf._set(subject)
393
439
  } else if (isArrayish(subject)) {
@@ -401,7 +447,7 @@ function Buffer (subject, encoding, noZero) {
401
447
  }
402
448
  } else if (type === 'string') {
403
449
  buf.write(subject, 0, encoding)
404
- } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
450
+ } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
405
451
  for (i = 0; i < length; i++) {
406
452
  buf[i] = 0
407
453
  }
@@ -410,8 +456,25 @@ function Buffer (subject, encoding, noZero) {
410
456
  return buf
411
457
  }
412
458
 
413
- // STATIC METHODS
414
- // ==============
459
+ Buffer.isBuffer = function (b) {
460
+ return !!(b != null && b._isBuffer)
461
+ }
462
+
463
+ Buffer.compare = function (a, b) {
464
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b))
465
+ throw new TypeError('Arguments must be Buffers')
466
+
467
+ var x = a.length
468
+ var y = b.length
469
+ for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
470
+ if (i !== len) {
471
+ x = a[i]
472
+ y = b[i]
473
+ }
474
+ if (x < y) return -1
475
+ if (y < x) return 1
476
+ return 0
477
+ }
415
478
 
416
479
  Buffer.isEncoding = function (encoding) {
417
480
  switch (String(encoding).toLowerCase()) {
@@ -432,43 +495,8 @@ Buffer.isEncoding = function (encoding) {
432
495
  }
433
496
  }
434
497
 
435
- Buffer.isBuffer = function (b) {
436
- return !!(b !== null && b !== undefined && b._isBuffer)
437
- }
438
-
439
- Buffer.byteLength = function (str, encoding) {
440
- var ret
441
- str = str.toString()
442
- switch (encoding || 'utf8') {
443
- case 'hex':
444
- ret = str.length / 2
445
- break
446
- case 'utf8':
447
- case 'utf-8':
448
- ret = utf8ToBytes(str).length
449
- break
450
- case 'ascii':
451
- case 'binary':
452
- case 'raw':
453
- ret = str.length
454
- break
455
- case 'base64':
456
- ret = base64ToBytes(str).length
457
- break
458
- case 'ucs2':
459
- case 'ucs-2':
460
- case 'utf16le':
461
- case 'utf-16le':
462
- ret = str.length * 2
463
- break
464
- default:
465
- throw new Error('Unknown encoding')
466
- }
467
- return ret
468
- }
469
-
470
498
  Buffer.concat = function (list, totalLength) {
471
- assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
499
+ if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')
472
500
 
473
501
  if (list.length === 0) {
474
502
  return new Buffer(0)
@@ -494,26 +522,118 @@ Buffer.concat = function (list, totalLength) {
494
522
  return buf
495
523
  }
496
524
 
497
- Buffer.compare = function (a, b) {
498
- assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
499
- var x = a.length
500
- var y = b.length
501
- for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
502
- if (i !== len) {
503
- x = a[i]
504
- y = b[i]
525
+ Buffer.byteLength = function (str, encoding) {
526
+ var ret
527
+ str = str + ''
528
+ switch (encoding || 'utf8') {
529
+ case 'ascii':
530
+ case 'binary':
531
+ case 'raw':
532
+ ret = str.length
533
+ break
534
+ case 'ucs2':
535
+ case 'ucs-2':
536
+ case 'utf16le':
537
+ case 'utf-16le':
538
+ ret = str.length * 2
539
+ break
540
+ case 'hex':
541
+ ret = str.length >>> 1
542
+ break
543
+ case 'utf8':
544
+ case 'utf-8':
545
+ ret = utf8ToBytes(str).length
546
+ break
547
+ case 'base64':
548
+ ret = base64ToBytes(str).length
549
+ break
550
+ default:
551
+ ret = str.length
505
552
  }
506
- if (x < y) {
507
- return -1
553
+ return ret
554
+ }
555
+
556
+ // pre-set for values that may exist in the future
557
+ Buffer.prototype.length = undefined
558
+ Buffer.prototype.parent = undefined
559
+
560
+ // toString(encoding, start=0, end=buffer.length)
561
+ Buffer.prototype.toString = function (encoding, start, end) {
562
+ var loweredCase = false
563
+
564
+ start = start >>> 0
565
+ end = end === undefined || end === Infinity ? this.length : end >>> 0
566
+
567
+ if (!encoding) encoding = 'utf8'
568
+ if (start < 0) start = 0
569
+ if (end > this.length) end = this.length
570
+ if (end <= start) return ''
571
+
572
+ while (true) {
573
+ switch (encoding) {
574
+ case 'hex':
575
+ return hexSlice(this, start, end)
576
+
577
+ case 'utf8':
578
+ case 'utf-8':
579
+ return utf8Slice(this, start, end)
580
+
581
+ case 'ascii':
582
+ return asciiSlice(this, start, end)
583
+
584
+ case 'binary':
585
+ return binarySlice(this, start, end)
586
+
587
+ case 'base64':
588
+ return base64Slice(this, start, end)
589
+
590
+ case 'ucs2':
591
+ case 'ucs-2':
592
+ case 'utf16le':
593
+ case 'utf-16le':
594
+ return utf16leSlice(this, start, end)
595
+
596
+ default:
597
+ if (loweredCase)
598
+ throw new TypeError('Unknown encoding: ' + encoding)
599
+ encoding = (encoding + '').toLowerCase()
600
+ loweredCase = true
601
+ }
508
602
  }
509
- if (y < x) {
510
- return 1
603
+ }
604
+
605
+ Buffer.prototype.equals = function (b) {
606
+ if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
607
+ return Buffer.compare(this, b) === 0
608
+ }
609
+
610
+ Buffer.prototype.inspect = function () {
611
+ var str = ''
612
+ var max = exports.INSPECT_MAX_BYTES
613
+ if (this.length > 0) {
614
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
615
+ if (this.length > max)
616
+ str += ' ... '
511
617
  }
512
- return 0
618
+ return '<Buffer ' + str + '>'
619
+ }
620
+
621
+ Buffer.prototype.compare = function (b) {
622
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
623
+ return Buffer.compare(this, b)
513
624
  }
514
625
 
515
- // BUFFER INSTANCE METHODS
516
- // =======================
626
+ // `get` will be removed in Node 0.13+
627
+ Buffer.prototype.get = function (offset) {
628
+ console.log('.get() is deprecated. Access using array indexes instead.')
629
+ return this.readUInt8(offset)
630
+ }
631
+
632
+ // `set` will be removed in Node 0.13+
633
+ Buffer.prototype.set = function (v, offset) {
634
+ console.log('.set() is deprecated. Access using array indexes instead.')
635
+ return this.writeUInt8(v, offset)
636
+ }
517
637
 
518
638
  function hexWrite (buf, string, offset, length) {
519
639
  offset = Number(offset) || 0
@@ -529,14 +649,14 @@ function hexWrite (buf, string, offset, length) {
529
649
 
530
650
  // must be an even number of digits
531
651
  var strLen = string.length
532
- assert(strLen % 2 === 0, 'Invalid hex string')
652
+ if (strLen % 2 !== 0) throw new Error('Invalid hex string')
533
653
 
534
654
  if (length > strLen / 2) {
535
655
  length = strLen / 2
536
656
  }
537
657
  for (var i = 0; i < length; i++) {
538
658
  var byte = parseInt(string.substr(i * 2, 2), 16)
539
- assert(!isNaN(byte), 'Invalid hex string')
659
+ if (isNaN(byte)) throw new Error('Invalid hex string')
540
660
  buf[offset + i] = byte
541
661
  }
542
662
  return i
@@ -601,119 +721,32 @@ Buffer.prototype.write = function (string, offset, length, encoding) {
601
721
  case 'utf8':
602
722
  case 'utf-8':
603
723
  ret = utf8Write(this, string, offset, length)
604
- break
605
- case 'ascii':
606
- ret = asciiWrite(this, string, offset, length)
607
- break
608
- case 'binary':
609
- ret = binaryWrite(this, string, offset, length)
610
- break
611
- case 'base64':
612
- ret = base64Write(this, string, offset, length)
613
- break
614
- case 'ucs2':
615
- case 'ucs-2':
616
- case 'utf16le':
617
- case 'utf-16le':
618
- ret = utf16leWrite(this, string, offset, length)
619
- break
620
- default:
621
- throw new Error('Unknown encoding')
622
- }
623
- return ret
624
- }
625
-
626
- Buffer.prototype.toString = function (encoding, start, end) {
627
- var self = this
628
-
629
- encoding = String(encoding || 'utf8').toLowerCase()
630
- start = Number(start) || 0
631
- end = (end === undefined) ? self.length : Number(end)
632
-
633
- // Fastpath empty strings
634
- if (end === start)
635
- return ''
636
-
637
- var ret
638
- switch (encoding) {
639
- case 'hex':
640
- ret = hexSlice(self, start, end)
641
- break
642
- case 'utf8':
643
- case 'utf-8':
644
- ret = utf8Slice(self, start, end)
645
- break
646
- case 'ascii':
647
- ret = asciiSlice(self, start, end)
648
- break
649
- case 'binary':
650
- ret = binarySlice(self, start, end)
651
- break
652
- case 'base64':
653
- ret = base64Slice(self, start, end)
654
- break
655
- case 'ucs2':
656
- case 'ucs-2':
657
- case 'utf16le':
658
- case 'utf-16le':
659
- ret = utf16leSlice(self, start, end)
660
- break
661
- default:
662
- throw new Error('Unknown encoding')
663
- }
664
- return ret
665
- }
666
-
667
- Buffer.prototype.toJSON = function () {
668
- return {
669
- type: 'Buffer',
670
- data: Array.prototype.slice.call(this._arr || this, 0)
671
- }
672
- }
673
-
674
- Buffer.prototype.equals = function (b) {
675
- assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
676
- return Buffer.compare(this, b) === 0
677
- }
678
-
679
- Buffer.prototype.compare = function (b) {
680
- assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
681
- return Buffer.compare(this, b)
682
- }
683
-
684
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
685
- Buffer.prototype.copy = function (target, target_start, start, end) {
686
- var source = this
687
-
688
- if (!start) start = 0
689
- if (!end && end !== 0) end = this.length
690
- if (!target_start) target_start = 0
691
-
692
- // Copy 0 bytes; we're done
693
- if (end === start) return
694
- if (target.length === 0 || source.length === 0) return
695
-
696
- // Fatal error conditions
697
- assert(end >= start, 'sourceEnd < sourceStart')
698
- assert(target_start >= 0 && target_start < target.length,
699
- 'targetStart out of bounds')
700
- assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
701
- assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
702
-
703
- // Are we oob?
704
- if (end > this.length)
705
- end = this.length
706
- if (target.length - target_start < end - start)
707
- end = target.length - target_start + start
708
-
709
- var len = end - start
724
+ break
725
+ case 'ascii':
726
+ ret = asciiWrite(this, string, offset, length)
727
+ break
728
+ case 'binary':
729
+ ret = binaryWrite(this, string, offset, length)
730
+ break
731
+ case 'base64':
732
+ ret = base64Write(this, string, offset, length)
733
+ break
734
+ case 'ucs2':
735
+ case 'ucs-2':
736
+ case 'utf16le':
737
+ case 'utf-16le':
738
+ ret = utf16leWrite(this, string, offset, length)
739
+ break
740
+ default:
741
+ throw new TypeError('Unknown encoding: ' + encoding)
742
+ }
743
+ return ret
744
+ }
710
745
 
711
- if (len < 100 || !Buffer._useTypedArrays) {
712
- for (var i = 0; i < len; i++) {
713
- target[i + target_start] = this[i + start]
714
- }
715
- } else {
716
- target._set(this.subarray(start, start + len), target_start)
746
+ Buffer.prototype.toJSON = function () {
747
+ return {
748
+ type: 'Buffer',
749
+ data: Array.prototype.slice.call(this._arr || this, 0)
717
750
  }
718
751
  }
719
752
 
@@ -780,10 +813,29 @@ function utf16leSlice (buf, start, end) {
780
813
 
781
814
  Buffer.prototype.slice = function (start, end) {
782
815
  var len = this.length
783
- start = clamp(start, len, 0)
784
- end = clamp(end, len, len)
816
+ start = ~~start
817
+ end = end === undefined ? len : ~~end
818
+
819
+ if (start < 0) {
820
+ start += len;
821
+ if (start < 0)
822
+ start = 0
823
+ } else if (start > len) {
824
+ start = len
825
+ }
826
+
827
+ if (end < 0) {
828
+ end += len
829
+ if (end < 0)
830
+ end = 0
831
+ } else if (end > len) {
832
+ end = len
833
+ }
834
+
835
+ if (end < start)
836
+ end = start
785
837
 
786
- if (Buffer._useTypedArrays) {
838
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
787
839
  return Buffer._augment(this.subarray(start, end))
788
840
  } else {
789
841
  var sliceLen = end - start
@@ -795,365 +847,275 @@ Buffer.prototype.slice = function (start, end) {
795
847
  }
796
848
  }
797
849
 
798
- // `get` will be removed in Node 0.13+
799
- Buffer.prototype.get = function (offset) {
800
- console.log('.get() is deprecated. Access using array indexes instead.')
801
- return this.readUInt8(offset)
802
- }
803
-
804
- // `set` will be removed in Node 0.13+
805
- Buffer.prototype.set = function (v, offset) {
806
- console.log('.set() is deprecated. Access using array indexes instead.')
807
- return this.writeUInt8(v, offset)
850
+ /*
851
+ * Need to make sure that buffer isn't trying to write out of bounds.
852
+ */
853
+ function checkOffset (offset, ext, length) {
854
+ if ((offset % 1) !== 0 || offset < 0)
855
+ throw new RangeError('offset is not uint')
856
+ if (offset + ext > length)
857
+ throw new RangeError('Trying to access beyond buffer length')
808
858
  }
809
859
 
810
860
  Buffer.prototype.readUInt8 = function (offset, noAssert) {
811
- if (!noAssert) {
812
- assert(offset !== undefined && offset !== null, 'missing offset')
813
- assert(offset < this.length, 'Trying to read beyond buffer length')
814
- }
815
-
816
- if (offset >= this.length)
817
- return
818
-
861
+ if (!noAssert)
862
+ checkOffset(offset, 1, this.length)
819
863
  return this[offset]
820
864
  }
821
865
 
822
- function readUInt16 (buf, offset, littleEndian, noAssert) {
823
- if (!noAssert) {
824
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
825
- assert(offset !== undefined && offset !== null, 'missing offset')
826
- assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
827
- }
828
-
829
- var len = buf.length
830
- if (offset >= len)
831
- return
832
-
833
- var val
834
- if (littleEndian) {
835
- val = buf[offset]
836
- if (offset + 1 < len)
837
- val |= buf[offset + 1] << 8
838
- } else {
839
- val = buf[offset] << 8
840
- if (offset + 1 < len)
841
- val |= buf[offset + 1]
842
- }
843
- return val
844
- }
845
-
846
866
  Buffer.prototype.readUInt16LE = function (offset, noAssert) {
847
- return readUInt16(this, offset, true, noAssert)
867
+ if (!noAssert)
868
+ checkOffset(offset, 2, this.length)
869
+ return this[offset] | (this[offset + 1] << 8)
848
870
  }
849
871
 
850
872
  Buffer.prototype.readUInt16BE = function (offset, noAssert) {
851
- return readUInt16(this, offset, false, noAssert)
852
- }
853
-
854
- function readUInt32 (buf, offset, littleEndian, noAssert) {
855
- if (!noAssert) {
856
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
857
- assert(offset !== undefined && offset !== null, 'missing offset')
858
- assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
859
- }
860
-
861
- var len = buf.length
862
- if (offset >= len)
863
- return
864
-
865
- var val
866
- if (littleEndian) {
867
- if (offset + 2 < len)
868
- val = buf[offset + 2] << 16
869
- if (offset + 1 < len)
870
- val |= buf[offset + 1] << 8
871
- val |= buf[offset]
872
- if (offset + 3 < len)
873
- val = val + (buf[offset + 3] << 24 >>> 0)
874
- } else {
875
- if (offset + 1 < len)
876
- val = buf[offset + 1] << 16
877
- if (offset + 2 < len)
878
- val |= buf[offset + 2] << 8
879
- if (offset + 3 < len)
880
- val |= buf[offset + 3]
881
- val = val + (buf[offset] << 24 >>> 0)
882
- }
883
- return val
873
+ if (!noAssert)
874
+ checkOffset(offset, 2, this.length)
875
+ return (this[offset] << 8) | this[offset + 1]
884
876
  }
885
877
 
886
878
  Buffer.prototype.readUInt32LE = function (offset, noAssert) {
887
- return readUInt32(this, offset, true, noAssert)
888
- }
879
+ if (!noAssert)
880
+ checkOffset(offset, 4, this.length)
889
881
 
890
- Buffer.prototype.readUInt32BE = function (offset, noAssert) {
891
- return readUInt32(this, offset, false, noAssert)
882
+ return ((this[offset]) |
883
+ (this[offset + 1] << 8) |
884
+ (this[offset + 2] << 16)) +
885
+ (this[offset + 3] * 0x1000000)
892
886
  }
893
887
 
894
- Buffer.prototype.readInt8 = function (offset, noAssert) {
895
- if (!noAssert) {
896
- assert(offset !== undefined && offset !== null,
897
- 'missing offset')
898
- assert(offset < this.length, 'Trying to read beyond buffer length')
899
- }
900
-
901
- if (offset >= this.length)
902
- return
888
+ Buffer.prototype.readUInt32BE = function (offset, noAssert) {
889
+ if (!noAssert)
890
+ checkOffset(offset, 4, this.length)
903
891
 
904
- var neg = this[offset] & 0x80
905
- if (neg)
906
- return (0xff - this[offset] + 1) * -1
907
- else
908
- return this[offset]
892
+ return (this[offset] * 0x1000000) +
893
+ ((this[offset + 1] << 16) |
894
+ (this[offset + 2] << 8) |
895
+ this[offset + 3])
909
896
  }
910
897
 
911
- function readInt16 (buf, offset, littleEndian, noAssert) {
912
- if (!noAssert) {
913
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
914
- assert(offset !== undefined && offset !== null, 'missing offset')
915
- assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
916
- }
917
-
918
- var len = buf.length
919
- if (offset >= len)
920
- return
921
-
922
- var val = readUInt16(buf, offset, littleEndian, true)
923
- var neg = val & 0x8000
924
- if (neg)
925
- return (0xffff - val + 1) * -1
926
- else
927
- return val
898
+ Buffer.prototype.readInt8 = function (offset, noAssert) {
899
+ if (!noAssert)
900
+ checkOffset(offset, 1, this.length)
901
+ if (!(this[offset] & 0x80))
902
+ return (this[offset])
903
+ return ((0xff - this[offset] + 1) * -1)
928
904
  }
929
905
 
930
906
  Buffer.prototype.readInt16LE = function (offset, noAssert) {
931
- return readInt16(this, offset, true, noAssert)
907
+ if (!noAssert)
908
+ checkOffset(offset, 2, this.length)
909
+ var val = this[offset] | (this[offset + 1] << 8)
910
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
932
911
  }
933
912
 
934
913
  Buffer.prototype.readInt16BE = function (offset, noAssert) {
935
- return readInt16(this, offset, false, noAssert)
936
- }
937
-
938
- function readInt32 (buf, offset, littleEndian, noAssert) {
939
- if (!noAssert) {
940
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
941
- assert(offset !== undefined && offset !== null, 'missing offset')
942
- assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
943
- }
944
-
945
- var len = buf.length
946
- if (offset >= len)
947
- return
948
-
949
- var val = readUInt32(buf, offset, littleEndian, true)
950
- var neg = val & 0x80000000
951
- if (neg)
952
- return (0xffffffff - val + 1) * -1
953
- else
954
- return val
914
+ if (!noAssert)
915
+ checkOffset(offset, 2, this.length)
916
+ var val = this[offset + 1] | (this[offset] << 8)
917
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
955
918
  }
956
919
 
957
920
  Buffer.prototype.readInt32LE = function (offset, noAssert) {
958
- return readInt32(this, offset, true, noAssert)
959
- }
921
+ if (!noAssert)
922
+ checkOffset(offset, 4, this.length)
960
923
 
961
- Buffer.prototype.readInt32BE = function (offset, noAssert) {
962
- return readInt32(this, offset, false, noAssert)
924
+ return (this[offset]) |
925
+ (this[offset + 1] << 8) |
926
+ (this[offset + 2] << 16) |
927
+ (this[offset + 3] << 24)
963
928
  }
964
929
 
965
- function readFloat (buf, offset, littleEndian, noAssert) {
966
- if (!noAssert) {
967
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
968
- assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
969
- }
930
+ Buffer.prototype.readInt32BE = function (offset, noAssert) {
931
+ if (!noAssert)
932
+ checkOffset(offset, 4, this.length)
970
933
 
971
- return ieee754.read(buf, offset, littleEndian, 23, 4)
934
+ return (this[offset] << 24) |
935
+ (this[offset + 1] << 16) |
936
+ (this[offset + 2] << 8) |
937
+ (this[offset + 3])
972
938
  }
973
939
 
974
940
  Buffer.prototype.readFloatLE = function (offset, noAssert) {
975
- return readFloat(this, offset, true, noAssert)
941
+ if (!noAssert)
942
+ checkOffset(offset, 4, this.length)
943
+ return ieee754.read(this, offset, true, 23, 4)
976
944
  }
977
945
 
978
946
  Buffer.prototype.readFloatBE = function (offset, noAssert) {
979
- return readFloat(this, offset, false, noAssert)
980
- }
981
-
982
- function readDouble (buf, offset, littleEndian, noAssert) {
983
- if (!noAssert) {
984
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
985
- assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
986
- }
987
-
988
- return ieee754.read(buf, offset, littleEndian, 52, 8)
947
+ if (!noAssert)
948
+ checkOffset(offset, 4, this.length)
949
+ return ieee754.read(this, offset, false, 23, 4)
989
950
  }
990
951
 
991
952
  Buffer.prototype.readDoubleLE = function (offset, noAssert) {
992
- return readDouble(this, offset, true, noAssert)
953
+ if (!noAssert)
954
+ checkOffset(offset, 8, this.length)
955
+ return ieee754.read(this, offset, true, 52, 8)
993
956
  }
994
957
 
995
958
  Buffer.prototype.readDoubleBE = function (offset, noAssert) {
996
- return readDouble(this, offset, false, noAssert)
959
+ if (!noAssert)
960
+ checkOffset(offset, 8, this.length)
961
+ return ieee754.read(this, offset, false, 52, 8)
997
962
  }
998
963
 
999
- Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
1000
- if (!noAssert) {
1001
- assert(value !== undefined && value !== null, 'missing value')
1002
- assert(offset !== undefined && offset !== null, 'missing offset')
1003
- assert(offset < this.length, 'trying to write beyond buffer length')
1004
- verifuint(value, 0xff)
1005
- }
1006
-
1007
- if (offset >= this.length) return
964
+ function checkInt (buf, value, offset, ext, max, min) {
965
+ if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
966
+ if (value > max || value < min) throw new TypeError('value is out of bounds')
967
+ if (offset + ext > buf.length) throw new TypeError('index out of range')
968
+ }
1008
969
 
970
+ Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
971
+ value = +value
972
+ offset = offset >>> 0
973
+ if (!noAssert)
974
+ checkInt(this, value, offset, 1, 0xff, 0)
975
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1009
976
  this[offset] = value
1010
977
  return offset + 1
1011
978
  }
1012
979
 
1013
- function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
1014
- if (!noAssert) {
1015
- assert(value !== undefined && value !== null, 'missing value')
1016
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1017
- assert(offset !== undefined && offset !== null, 'missing offset')
1018
- assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
1019
- verifuint(value, 0xffff)
1020
- }
1021
-
1022
- var len = buf.length
1023
- if (offset >= len)
1024
- return
1025
-
1026
- for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
1027
- buf[offset + i] =
1028
- (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1029
- (littleEndian ? i : 1 - i) * 8
980
+ function objectWriteUInt16 (buf, value, offset, littleEndian) {
981
+ if (value < 0) value = 0xffff + value + 1
982
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
983
+ buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
984
+ (littleEndian ? i : 1 - i) * 8
1030
985
  }
1031
- return offset + 2
1032
986
  }
1033
987
 
1034
988
  Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
1035
- return writeUInt16(this, value, offset, true, noAssert)
989
+ value = +value
990
+ offset = offset >>> 0
991
+ if (!noAssert)
992
+ checkInt(this, value, offset, 2, 0xffff, 0)
993
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
994
+ this[offset] = value
995
+ this[offset + 1] = (value >>> 8)
996
+ } else objectWriteUInt16(this, value, offset, true)
997
+ return offset + 2
1036
998
  }
1037
999
 
1038
1000
  Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
1039
- return writeUInt16(this, value, offset, false, noAssert)
1001
+ value = +value
1002
+ offset = offset >>> 0
1003
+ if (!noAssert)
1004
+ checkInt(this, value, offset, 2, 0xffff, 0)
1005
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1006
+ this[offset] = (value >>> 8)
1007
+ this[offset + 1] = value
1008
+ } else objectWriteUInt16(this, value, offset, false)
1009
+ return offset + 2
1040
1010
  }
1041
1011
 
1042
- function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
1043
- if (!noAssert) {
1044
- assert(value !== undefined && value !== null, 'missing value')
1045
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1046
- assert(offset !== undefined && offset !== null, 'missing offset')
1047
- assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
1048
- verifuint(value, 0xffffffff)
1049
- }
1050
-
1051
- var len = buf.length
1052
- if (offset >= len)
1053
- return
1054
-
1055
- for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
1056
- buf[offset + i] =
1057
- (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1012
+ function objectWriteUInt32 (buf, value, offset, littleEndian) {
1013
+ if (value < 0) value = 0xffffffff + value + 1
1014
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
1015
+ buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1058
1016
  }
1059
- return offset + 4
1060
1017
  }
1061
1018
 
1062
1019
  Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
1063
- return writeUInt32(this, value, offset, true, noAssert)
1020
+ value = +value
1021
+ offset = offset >>> 0
1022
+ if (!noAssert)
1023
+ checkInt(this, value, offset, 4, 0xffffffff, 0)
1024
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1025
+ this[offset + 3] = (value >>> 24)
1026
+ this[offset + 2] = (value >>> 16)
1027
+ this[offset + 1] = (value >>> 8)
1028
+ this[offset] = value
1029
+ } else objectWriteUInt32(this, value, offset, true)
1030
+ return offset + 4
1064
1031
  }
1065
1032
 
1066
1033
  Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
1067
- return writeUInt32(this, value, offset, false, noAssert)
1034
+ value = +value
1035
+ offset = offset >>> 0
1036
+ if (!noAssert)
1037
+ checkInt(this, value, offset, 4, 0xffffffff, 0)
1038
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1039
+ this[offset] = (value >>> 24)
1040
+ this[offset + 1] = (value >>> 16)
1041
+ this[offset + 2] = (value >>> 8)
1042
+ this[offset + 3] = value
1043
+ } else objectWriteUInt32(this, value, offset, false)
1044
+ return offset + 4
1068
1045
  }
1069
1046
 
1070
1047
  Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
1071
- if (!noAssert) {
1072
- assert(value !== undefined && value !== null, 'missing value')
1073
- assert(offset !== undefined && offset !== null, 'missing offset')
1074
- assert(offset < this.length, 'Trying to write beyond buffer length')
1075
- verifsint(value, 0x7f, -0x80)
1076
- }
1077
-
1078
- if (offset >= this.length)
1079
- return
1080
-
1081
- if (value >= 0)
1082
- this.writeUInt8(value, offset, noAssert)
1083
- else
1084
- this.writeUInt8(0xff + value + 1, offset, noAssert)
1048
+ value = +value
1049
+ offset = offset >>> 0
1050
+ if (!noAssert)
1051
+ checkInt(this, value, offset, 1, 0x7f, -0x80)
1052
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1053
+ if (value < 0) value = 0xff + value + 1
1054
+ this[offset] = value
1085
1055
  return offset + 1
1086
1056
  }
1087
1057
 
1088
- function writeInt16 (buf, value, offset, littleEndian, noAssert) {
1089
- if (!noAssert) {
1090
- assert(value !== undefined && value !== null, 'missing value')
1091
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1092
- assert(offset !== undefined && offset !== null, 'missing offset')
1093
- assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
1094
- verifsint(value, 0x7fff, -0x8000)
1095
- }
1096
-
1097
- var len = buf.length
1098
- if (offset >= len)
1099
- return
1100
-
1101
- if (value >= 0)
1102
- writeUInt16(buf, value, offset, littleEndian, noAssert)
1103
- else
1104
- writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
1105
- return offset + 2
1106
- }
1107
-
1108
1058
  Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
1109
- return writeInt16(this, value, offset, true, noAssert)
1059
+ value = +value
1060
+ offset = offset >>> 0
1061
+ if (!noAssert)
1062
+ checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1063
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1064
+ this[offset] = value
1065
+ this[offset + 1] = (value >>> 8)
1066
+ } else objectWriteUInt16(this, value, offset, true)
1067
+ return offset + 2
1110
1068
  }
1111
1069
 
1112
1070
  Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
1113
- return writeInt16(this, value, offset, false, noAssert)
1071
+ value = +value
1072
+ offset = offset >>> 0
1073
+ if (!noAssert)
1074
+ checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1075
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1076
+ this[offset] = (value >>> 8)
1077
+ this[offset + 1] = value
1078
+ } else objectWriteUInt16(this, value, offset, false)
1079
+ return offset + 2
1114
1080
  }
1115
1081
 
1116
- function writeInt32 (buf, value, offset, littleEndian, noAssert) {
1117
- if (!noAssert) {
1118
- assert(value !== undefined && value !== null, 'missing value')
1119
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1120
- assert(offset !== undefined && offset !== null, 'missing offset')
1121
- assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
1122
- verifsint(value, 0x7fffffff, -0x80000000)
1123
- }
1124
-
1125
- var len = buf.length
1126
- if (offset >= len)
1127
- return
1128
-
1129
- if (value >= 0)
1130
- writeUInt32(buf, value, offset, littleEndian, noAssert)
1131
- else
1132
- writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
1082
+ Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
1083
+ value = +value
1084
+ offset = offset >>> 0
1085
+ if (!noAssert)
1086
+ checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1087
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1088
+ this[offset] = value
1089
+ this[offset + 1] = (value >>> 8)
1090
+ this[offset + 2] = (value >>> 16)
1091
+ this[offset + 3] = (value >>> 24)
1092
+ } else objectWriteUInt32(this, value, offset, true)
1133
1093
  return offset + 4
1134
1094
  }
1135
1095
 
1136
- Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
1137
- return writeInt32(this, value, offset, true, noAssert)
1096
+ Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
1097
+ value = +value
1098
+ offset = offset >>> 0
1099
+ if (!noAssert)
1100
+ checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
1101
+ if (value < 0) value = 0xffffffff + value + 1
1102
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1103
+ this[offset] = (value >>> 24)
1104
+ this[offset + 1] = (value >>> 16)
1105
+ this[offset + 2] = (value >>> 8)
1106
+ this[offset + 3] = value
1107
+ } else objectWriteUInt32(this, value, offset, false)
1108
+ return offset + 4
1138
1109
  }
1139
1110
 
1140
- Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
1141
- return writeInt32(this, value, offset, false, noAssert)
1111
+ function checkIEEE754 (buf, value, offset, ext, max, min) {
1112
+ if (value > max || value < min) throw new TypeError('value is out of bounds')
1113
+ if (offset + ext > buf.length) throw new TypeError('index out of range')
1142
1114
  }
1143
1115
 
1144
1116
  function writeFloat (buf, value, offset, littleEndian, noAssert) {
1145
- if (!noAssert) {
1146
- assert(value !== undefined && value !== null, 'missing value')
1147
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1148
- assert(offset !== undefined && offset !== null, 'missing offset')
1149
- assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
1150
- verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
1151
- }
1152
-
1153
- var len = buf.length
1154
- if (offset >= len)
1155
- return
1156
-
1117
+ if (!noAssert)
1118
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
1157
1119
  ieee754.write(buf, value, offset, littleEndian, 23, 4)
1158
1120
  return offset + 4
1159
1121
  }
@@ -1167,19 +1129,8 @@ Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
1167
1129
  }
1168
1130
 
1169
1131
  function writeDouble (buf, value, offset, littleEndian, noAssert) {
1170
- if (!noAssert) {
1171
- assert(value !== undefined && value !== null, 'missing value')
1172
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
1173
- assert(offset !== undefined && offset !== null, 'missing offset')
1174
- assert(offset + 7 < buf.length,
1175
- 'Trying to write beyond buffer length')
1176
- verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
1177
- }
1178
-
1179
- var len = buf.length
1180
- if (offset >= len)
1181
- return
1182
-
1132
+ if (!noAssert)
1133
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
1183
1134
  ieee754.write(buf, value, offset, littleEndian, 52, 8)
1184
1135
  return offset + 8
1185
1136
  }
@@ -1192,20 +1143,56 @@ Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
1192
1143
  return writeDouble(this, value, offset, false, noAssert)
1193
1144
  }
1194
1145
 
1146
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1147
+ Buffer.prototype.copy = function (target, target_start, start, end) {
1148
+ var source = this
1149
+
1150
+ if (!start) start = 0
1151
+ if (!end && end !== 0) end = this.length
1152
+ if (!target_start) target_start = 0
1153
+
1154
+ // Copy 0 bytes; we're done
1155
+ if (end === start) return
1156
+ if (target.length === 0 || source.length === 0) return
1157
+
1158
+ // Fatal error conditions
1159
+ if (end < start) throw new TypeError('sourceEnd < sourceStart')
1160
+ if (target_start < 0 || target_start >= target.length)
1161
+ throw new TypeError('targetStart out of bounds')
1162
+ if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds')
1163
+ if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds')
1164
+
1165
+ // Are we oob?
1166
+ if (end > this.length)
1167
+ end = this.length
1168
+ if (target.length - target_start < end - start)
1169
+ end = target.length - target_start + start
1170
+
1171
+ var len = end - start
1172
+
1173
+ if (len < 100 || !Buffer.TYPED_ARRAY_SUPPORT) {
1174
+ for (var i = 0; i < len; i++) {
1175
+ target[i + target_start] = this[i + start]
1176
+ }
1177
+ } else {
1178
+ target._set(this.subarray(start, start + len), target_start)
1179
+ }
1180
+ }
1181
+
1195
1182
  // fill(value, start=0, end=buffer.length)
1196
1183
  Buffer.prototype.fill = function (value, start, end) {
1197
1184
  if (!value) value = 0
1198
1185
  if (!start) start = 0
1199
1186
  if (!end) end = this.length
1200
1187
 
1201
- assert(end >= start, 'end < start')
1188
+ if (end < start) throw new TypeError('end < start')
1202
1189
 
1203
1190
  // Fill 0 bytes; we're done
1204
1191
  if (end === start) return
1205
1192
  if (this.length === 0) return
1206
1193
 
1207
- assert(start >= 0 && start < this.length, 'start out of bounds')
1208
- assert(end >= 0 && end <= this.length, 'end out of bounds')
1194
+ if (start < 0 || start >= this.length) throw new TypeError('start out of bounds')
1195
+ if (end < 0 || end > this.length) throw new TypeError('end out of bounds')
1209
1196
 
1210
1197
  var i
1211
1198
  if (typeof value === 'number') {
@@ -1223,26 +1210,13 @@ Buffer.prototype.fill = function (value, start, end) {
1223
1210
  return this
1224
1211
  }
1225
1212
 
1226
- Buffer.prototype.inspect = function () {
1227
- var out = []
1228
- var len = this.length
1229
- for (var i = 0; i < len; i++) {
1230
- out[i] = toHex(this[i])
1231
- if (i === exports.INSPECT_MAX_BYTES) {
1232
- out[i + 1] = '...'
1233
- break
1234
- }
1235
- }
1236
- return '<Buffer ' + out.join(' ') + '>'
1237
- }
1238
-
1239
1213
  /**
1240
1214
  * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
1241
1215
  * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
1242
1216
  */
1243
1217
  Buffer.prototype.toArrayBuffer = function () {
1244
1218
  if (typeof Uint8Array !== 'undefined') {
1245
- if (Buffer._useTypedArrays) {
1219
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
1246
1220
  return (new Buffer(this)).buffer
1247
1221
  } else {
1248
1222
  var buf = new Uint8Array(this.length)
@@ -1252,7 +1226,7 @@ Buffer.prototype.toArrayBuffer = function () {
1252
1226
  return buf.buffer
1253
1227
  }
1254
1228
  } else {
1255
- throw new Error('Buffer.toArrayBuffer not supported in this browser')
1229
+ throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
1256
1230
  }
1257
1231
  }
1258
1232
 
@@ -1335,31 +1309,6 @@ function stringtrim (str) {
1335
1309
  return str.replace(/^\s+|\s+$/g, '')
1336
1310
  }
1337
1311
 
1338
- // slice(start, end)
1339
- function clamp (index, len, defaultValue) {
1340
- if (typeof index !== 'number') return defaultValue
1341
- index = ~~index; // Coerce to integer.
1342
- if (index >= len) return len
1343
- if (index >= 0) return index
1344
- index += len
1345
- if (index >= 0) return index
1346
- return 0
1347
- }
1348
-
1349
- function coerce (length) {
1350
- // Coerce length to a number (possibly NaN), round up
1351
- // in case it's fractional (e.g. 123.456) then do a
1352
- // double negate to coerce a NaN to 0. Easy, right?
1353
- length = ~~Math.ceil(+length)
1354
- return length < 0 ? 0 : length
1355
- }
1356
-
1357
- function isArray (subject) {
1358
- return (Array.isArray || function (subject) {
1359
- return Object.prototype.toString.call(subject) === '[object Array]'
1360
- })(subject)
1361
- }
1362
-
1363
1312
  function isArrayish (subject) {
1364
1313
  return isArray(subject) || Buffer.isBuffer(subject) ||
1365
1314
  subject && typeof subject === 'object' &&
@@ -1433,36 +1382,7 @@ function decodeUtf8Char (str) {
1433
1382
  }
1434
1383
  }
1435
1384
 
1436
- /*
1437
- * We have to make sure that the value is a valid integer. This means that it
1438
- * is non-negative. It has no fractional component and that it does not
1439
- * exceed the maximum allowed value.
1440
- */
1441
- function verifuint (value, max) {
1442
- assert(typeof value === 'number', 'cannot write a non-number as a number')
1443
- assert(value >= 0, 'specified a negative value for writing an unsigned value')
1444
- assert(value <= max, 'value is larger than maximum value for type')
1445
- assert(Math.floor(value) === value, 'value has a fractional component')
1446
- }
1447
-
1448
- function verifsint (value, max, min) {
1449
- assert(typeof value === 'number', 'cannot write a non-number as a number')
1450
- assert(value <= max, 'value larger than maximum allowed value')
1451
- assert(value >= min, 'value smaller than minimum allowed value')
1452
- assert(Math.floor(value) === value, 'value has a fractional component')
1453
- }
1454
-
1455
- function verifIEEE754 (value, max, min) {
1456
- assert(typeof value === 'number', 'cannot write a non-number as a number')
1457
- assert(value <= max, 'value larger than maximum allowed value')
1458
- assert(value >= min, 'value smaller than minimum allowed value')
1459
- }
1460
-
1461
- function assert (test, message) {
1462
- if (!test) throw new Error(message || 'Failed assertion')
1463
- }
1464
-
1465
- },{"base64-js":3,"ieee754":4}],3:[function(_dereq_,module,exports){
1385
+ },{"base64-js":3,"ieee754":4,"is-array":5}],3:[function(_dereq_,module,exports){
1466
1386
  var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
1467
1387
 
1468
1388
  ;(function (exports) {
@@ -1671,6 +1591,41 @@ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
1671
1591
  };
1672
1592
 
1673
1593
  },{}],5:[function(_dereq_,module,exports){
1594
+
1595
+ /**
1596
+ * isArray
1597
+ */
1598
+
1599
+ var isArray = Array.isArray;
1600
+
1601
+ /**
1602
+ * toString
1603
+ */
1604
+
1605
+ var str = Object.prototype.toString;
1606
+
1607
+ /**
1608
+ * Whether or not the given `val`
1609
+ * is an array.
1610
+ *
1611
+ * example:
1612
+ *
1613
+ * isArray([]);
1614
+ * // > true
1615
+ * isArray(arguments);
1616
+ * // > false
1617
+ * isArray('');
1618
+ * // > false
1619
+ *
1620
+ * @param {mixed} val
1621
+ * @return {bool}
1622
+ */
1623
+
1624
+ module.exports = isArray || function (val) {
1625
+ return !! val && '[object Array]' == str.call(val);
1626
+ };
1627
+
1628
+ },{}],6:[function(_dereq_,module,exports){
1674
1629
  (function (process){
1675
1630
  // Copyright Joyent, Inc. and other Node contributors.
1676
1631
  //
@@ -1897,8 +1852,8 @@ var substr = 'ab'.substr(-1) === 'b'
1897
1852
  }
1898
1853
  ;
1899
1854
 
1900
- }).call(this,_dereq_("FWaASH"))
1901
- },{"FWaASH":6}],6:[function(_dereq_,module,exports){
1855
+ }).call(this,_dereq_('_process'))
1856
+ },{"_process":7}],7:[function(_dereq_,module,exports){
1902
1857
  // shim for using process in browser
1903
1858
 
1904
1859
  var process = module.exports = {};
@@ -1906,6 +1861,8 @@ var process = module.exports = {};
1906
1861
  process.nextTick = (function () {
1907
1862
  var canSetImmediate = typeof window !== 'undefined'
1908
1863
  && window.setImmediate;
1864
+ var canMutationObserver = typeof window !== 'undefined'
1865
+ && window.MutationObserver;
1909
1866
  var canPost = typeof window !== 'undefined'
1910
1867
  && window.postMessage && window.addEventListener
1911
1868
  ;
@@ -1914,8 +1871,29 @@ process.nextTick = (function () {
1914
1871
  return function (f) { return window.setImmediate(f) };
1915
1872
  }
1916
1873
 
1874
+ var queue = [];
1875
+
1876
+ if (canMutationObserver) {
1877
+ var hiddenDiv = document.createElement("div");
1878
+ var observer = new MutationObserver(function () {
1879
+ var queueList = queue.slice();
1880
+ queue.length = 0;
1881
+ queueList.forEach(function (fn) {
1882
+ fn();
1883
+ });
1884
+ });
1885
+
1886
+ observer.observe(hiddenDiv, { attributes: true });
1887
+
1888
+ return function nextTick(fn) {
1889
+ if (!queue.length) {
1890
+ hiddenDiv.setAttribute('yes', 'no');
1891
+ }
1892
+ queue.push(fn);
1893
+ };
1894
+ }
1895
+
1917
1896
  if (canPost) {
1918
- var queue = [];
1919
1897
  window.addEventListener('message', function (ev) {
1920
1898
  var source = ev.source;
1921
1899
  if ((source === window || source === null) && ev.data === 'process-tick') {
@@ -1955,7 +1933,7 @@ process.emit = noop;
1955
1933
 
1956
1934
  process.binding = function (name) {
1957
1935
  throw new Error('process.binding is not supported');
1958
- }
1936
+ };
1959
1937
 
1960
1938
  // TODO(shtylman)
1961
1939
  process.cwd = function () { return '/' };
@@ -1963,7 +1941,7 @@ process.chdir = function (dir) {
1963
1941
  throw new Error('process.chdir is not supported');
1964
1942
  };
1965
1943
 
1966
- },{}],7:[function(_dereq_,module,exports){
1944
+ },{}],8:[function(_dereq_,module,exports){
1967
1945
  /*
1968
1946
  Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
1969
1947
  Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
@@ -2409,14 +2387,16 @@ parseYieldExpression: true
2409
2387
  }
2410
2388
  } else if (blockComment) {
2411
2389
  if (isLineTerminator(ch)) {
2412
- if (ch === 13 && source.charCodeAt(index + 1) === 10) {
2390
+ if (ch === 13) {
2413
2391
  ++index;
2414
2392
  }
2415
- ++lineNumber;
2416
- ++index;
2417
- lineStart = index;
2418
- if (index >= length) {
2419
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2393
+ if (ch !== 13 || source.charCodeAt(index) === 10) {
2394
+ ++lineNumber;
2395
+ ++index;
2396
+ lineStart = index;
2397
+ if (index >= length) {
2398
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
2399
+ }
2420
2400
  }
2421
2401
  } else {
2422
2402
  ch = source.charCodeAt(index++);
@@ -3072,6 +3052,7 @@ parseYieldExpression: true
3072
3052
  if (ch === '\r' && source[index] === '\n') {
3073
3053
  ++index;
3074
3054
  }
3055
+ lineStart = index;
3075
3056
  }
3076
3057
  } else if (isLineTerminator(ch.charCodeAt(0))) {
3077
3058
  break;
@@ -3187,12 +3168,14 @@ parseYieldExpression: true
3187
3168
  if (ch === '\r' && source[index] === '\n') {
3188
3169
  ++index;
3189
3170
  }
3171
+ lineStart = index;
3190
3172
  }
3191
3173
  } else if (isLineTerminator(ch.charCodeAt(0))) {
3192
3174
  ++lineNumber;
3193
3175
  if (ch === '\r' && source[index] === '\n') {
3194
3176
  ++index;
3195
3177
  }
3178
+ lineStart = index;
3196
3179
  cooked += '\n';
3197
3180
  } else {
3198
3181
  cooked += ch;
@@ -3536,11 +3519,62 @@ parseYieldExpression: true
3536
3519
  return {offset: index, line: lineNumber, col: index - lineStart};
3537
3520
  }
3538
3521
 
3539
- function markerCreatePreserveWhitespace() {
3540
- if (!extra.loc && !extra.range) {
3541
- return undefined;
3522
+ function markerCreatePreserveWhitespace() {
3523
+ if (!extra.loc && !extra.range) {
3524
+ return undefined;
3525
+ }
3526
+ return {offset: index, line: lineNumber, col: index - lineStart};
3527
+ }
3528
+
3529
+ function processComment(node) {
3530
+ var lastChild,
3531
+ trailingComments,
3532
+ bottomRight = extra.bottomRightStack,
3533
+ last = bottomRight[bottomRight.length - 1];
3534
+
3535
+ if (node.type === Syntax.Program) {
3536
+ if (node.body.length > 0) {
3537
+ return;
3538
+ }
3539
+ }
3540
+
3541
+ if (extra.trailingComments.length > 0) {
3542
+ if (extra.trailingComments[0].range[0] >= node.range[1]) {
3543
+ trailingComments = extra.trailingComments;
3544
+ extra.trailingComments = [];
3545
+ } else {
3546
+ extra.trailingComments.length = 0;
3547
+ }
3548
+ } else {
3549
+ if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
3550
+ trailingComments = last.trailingComments;
3551
+ delete last.trailingComments;
3552
+ }
3553
+ }
3554
+
3555
+ // Eating the stack.
3556
+ if (last) {
3557
+ while (last && last.range[0] >= node.range[0]) {
3558
+ lastChild = last;
3559
+ last = bottomRight.pop();
3560
+ }
3561
+ }
3562
+
3563
+ if (lastChild) {
3564
+ if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
3565
+ node.leadingComments = lastChild.leadingComments;
3566
+ delete lastChild.leadingComments;
3567
+ }
3568
+ } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
3569
+ node.leadingComments = extra.leadingComments;
3570
+ extra.leadingComments = [];
3571
+ }
3572
+
3573
+ if (trailingComments) {
3574
+ node.trailingComments = trailingComments;
3542
3575
  }
3543
- return {offset: index, line: lineNumber, col: index - lineStart};
3576
+
3577
+ bottomRight.push(node);
3544
3578
  }
3545
3579
 
3546
3580
  function markerApply(marker, node) {
@@ -3560,6 +3594,9 @@ parseYieldExpression: true
3560
3594
  };
3561
3595
  node = delegate.postProcess(node);
3562
3596
  }
3597
+ if (extra.attachComment) {
3598
+ processComment(node);
3599
+ }
3563
3600
  return node;
3564
3601
  }
3565
3602
 
@@ -3769,10 +3806,11 @@ parseYieldExpression: true
3769
3806
  };
3770
3807
  },
3771
3808
 
3772
- createObjectTypeAnnotation: function (properties) {
3809
+ createObjectTypeAnnotation: function (properties, nullable) {
3773
3810
  return {
3774
3811
  type: Syntax.ObjectTypeAnnotation,
3775
- properties: properties
3812
+ properties: properties,
3813
+ nullable: nullable
3776
3814
  };
3777
3815
  },
3778
3816
 
@@ -3795,7 +3833,7 @@ parseYieldExpression: true
3795
3833
  return {
3796
3834
  type: Syntax.XJSAttribute,
3797
3835
  name: name,
3798
- value: value
3836
+ value: value || null
3799
3837
  };
3800
3838
  },
3801
3839
 
@@ -4369,7 +4407,8 @@ parseYieldExpression: true
4369
4407
  }
4370
4408
 
4371
4409
  function consumeSemicolon() {
4372
- var line;
4410
+ var line, oldIndex = index, oldLineNumber = lineNumber,
4411
+ oldLineStart = lineStart, oldLookahead = lookahead;
4373
4412
 
4374
4413
  // Catch the very common case first: immediately a semicolon (char #59).
4375
4414
  if (source.charCodeAt(index) === 59) {
@@ -4380,6 +4419,10 @@ parseYieldExpression: true
4380
4419
  line = lineNumber;
4381
4420
  skipComment();
4382
4421
  if (lineNumber !== line) {
4422
+ index = oldIndex;
4423
+ lineNumber = oldLineNumber;
4424
+ lineStart = oldLineStart;
4425
+ lookahead = oldLookahead;
4383
4426
  return;
4384
4427
  }
4385
4428
 
@@ -5475,7 +5518,7 @@ parseYieldExpression: true
5475
5518
 
5476
5519
  // 12.2 Variable Statement
5477
5520
 
5478
- function parseObjectTypeAnnotation() {
5521
+ function parseObjectTypeAnnotation(nullable) {
5479
5522
  var isMethod, marker, properties = [], property, propertyKey,
5480
5523
  propertyTypeAnnotation;
5481
5524
 
@@ -5505,7 +5548,7 @@ parseYieldExpression: true
5505
5548
 
5506
5549
  expect('}');
5507
5550
 
5508
- return delegate.createObjectTypeAnnotation(properties);
5551
+ return delegate.createObjectTypeAnnotation(properties, nullable);
5509
5552
  }
5510
5553
 
5511
5554
  function parseVoidTypeAnnotation() {
@@ -5540,15 +5583,15 @@ parseYieldExpression: true
5540
5583
  expect(':');
5541
5584
  }
5542
5585
 
5543
- if (match('{')) {
5544
- return markerApply(marker, parseObjectTypeAnnotation());
5545
- }
5546
-
5547
5586
  if (match('?')) {
5548
5587
  lex();
5549
5588
  nullable = true;
5550
5589
  }
5551
5590
 
5591
+ if (match('{')) {
5592
+ return markerApply(marker, parseObjectTypeAnnotation(nullable));
5593
+ }
5594
+
5552
5595
  if (lookahead.type === Token.Identifier) {
5553
5596
  typeIdentifier = parseVariableIdentifier();
5554
5597
  if (match('<')) {
@@ -5576,7 +5619,7 @@ parseYieldExpression: true
5576
5619
  if (!matchKeyword('void')) {
5577
5620
  throwUnexpected(lookahead);
5578
5621
  } else {
5579
- return parseVoidTypeAnnotation();
5622
+ return markerApply(marker, parseVoidTypeAnnotation());
5580
5623
  }
5581
5624
  }
5582
5625
 
@@ -7136,6 +7179,10 @@ parseYieldExpression: true
7136
7179
  comment.loc = loc;
7137
7180
  }
7138
7181
  extra.comments.push(comment);
7182
+ if (extra.attachComment) {
7183
+ extra.leadingComments.push(comment);
7184
+ extra.trailingComments.push(comment);
7185
+ }
7139
7186
  }
7140
7187
 
7141
7188
  function scanComment() {
@@ -7176,17 +7223,18 @@ parseYieldExpression: true
7176
7223
  }
7177
7224
  } else if (blockComment) {
7178
7225
  if (isLineTerminator(ch.charCodeAt(0))) {
7179
- if (ch === '\r' && source[index + 1] === '\n') {
7226
+ if (ch === '\r') {
7180
7227
  ++index;
7181
- comment += '\r\n';
7182
- } else {
7183
- comment += ch;
7228
+ comment += '\r';
7184
7229
  }
7185
- ++lineNumber;
7186
- ++index;
7187
- lineStart = index;
7188
- if (index >= length) {
7189
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
7230
+ if (ch !== '\r' || source[index] === '\n') {
7231
+ comment += source[index];
7232
+ ++lineNumber;
7233
+ ++index;
7234
+ lineStart = index;
7235
+ if (index >= length) {
7236
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
7237
+ }
7190
7238
  }
7191
7239
  } else {
7192
7240
  ch = source[index++];
@@ -7599,6 +7647,11 @@ parseYieldExpression: true
7599
7647
  str += scanXJSEntity();
7600
7648
  } else {
7601
7649
  index++;
7650
+ if (ch === '\r' && source[index] === '\n') {
7651
+ str += ch;
7652
+ ch = source[index];
7653
+ index++;
7654
+ }
7602
7655
  if (isLineTerminator(ch.charCodeAt(0))) {
7603
7656
  ++lineNumber;
7604
7657
  lineStart = index;
@@ -7867,7 +7920,7 @@ parseYieldExpression: true
7867
7920
  }
7868
7921
 
7869
7922
  function parseXJSElement() {
7870
- var openingElement, closingElement, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
7923
+ var openingElement, closingElement = null, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
7871
7924
 
7872
7925
  origInXJSChild = state.inXJSChild;
7873
7926
  origInXJSTag = state.inXJSTag;
@@ -8185,6 +8238,7 @@ parseYieldExpression: true
8185
8238
  if (typeof options !== 'undefined') {
8186
8239
  extra.range = (typeof options.range === 'boolean') && options.range;
8187
8240
  extra.loc = (typeof options.loc === 'boolean') && options.loc;
8241
+ extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
8188
8242
 
8189
8243
  if (extra.loc && options.source !== null && options.source !== undefined) {
8190
8244
  delegate = extend(delegate, {
@@ -8204,6 +8258,13 @@ parseYieldExpression: true
8204
8258
  if (typeof options.tolerant === 'boolean' && options.tolerant) {
8205
8259
  extra.errors = [];
8206
8260
  }
8261
+ if (extra.attachComment) {
8262
+ extra.range = true;
8263
+ extra.comments = [];
8264
+ extra.bottomRightStack = [];
8265
+ extra.trailingComments = [];
8266
+ extra.leadingComments = [];
8267
+ }
8207
8268
  }
8208
8269
 
8209
8270
  if (length > 0) {
@@ -8241,7 +8302,7 @@ parseYieldExpression: true
8241
8302
  }
8242
8303
 
8243
8304
  // Sync with *.json manifests.
8244
- exports.version = '4001.3001.0000-dev-harmony-fb';
8305
+ exports.version = '6001.0001.0000-dev-harmony-fb';
8245
8306
 
8246
8307
  exports.tokenize = tokenize;
8247
8308
 
@@ -8271,7 +8332,7 @@ parseYieldExpression: true
8271
8332
  }));
8272
8333
  /* vim: set sw=4 ts=4 et tw=80 : */
8273
8334
 
8274
- },{}],8:[function(_dereq_,module,exports){
8335
+ },{}],9:[function(_dereq_,module,exports){
8275
8336
  var Base62 = (function (my) {
8276
8337
  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"]
8277
8338
 
@@ -8299,7 +8360,7 @@ var Base62 = (function (my) {
8299
8360
  }({}));
8300
8361
 
8301
8362
  module.exports = Base62
8302
- },{}],9:[function(_dereq_,module,exports){
8363
+ },{}],10:[function(_dereq_,module,exports){
8303
8364
  /*
8304
8365
  * Copyright 2009-2011 Mozilla Foundation and contributors
8305
8366
  * Licensed under the New BSD license. See LICENSE.txt or:
@@ -8309,7 +8370,7 @@ exports.SourceMapGenerator = _dereq_('./source-map/source-map-generator').Source
8309
8370
  exports.SourceMapConsumer = _dereq_('./source-map/source-map-consumer').SourceMapConsumer;
8310
8371
  exports.SourceNode = _dereq_('./source-map/source-node').SourceNode;
8311
8372
 
8312
- },{"./source-map/source-map-consumer":14,"./source-map/source-map-generator":15,"./source-map/source-node":16}],10:[function(_dereq_,module,exports){
8373
+ },{"./source-map/source-map-consumer":15,"./source-map/source-map-generator":16,"./source-map/source-node":17}],11:[function(_dereq_,module,exports){
8313
8374
  /* -*- Mode: js; js-indent-level: 2; -*- */
8314
8375
  /*
8315
8376
  * Copyright 2011 Mozilla Foundation and contributors
@@ -8408,7 +8469,7 @@ define(function (_dereq_, exports, module) {
8408
8469
 
8409
8470
  });
8410
8471
 
8411
- },{"./util":17,"amdefine":1}],11:[function(_dereq_,module,exports){
8472
+ },{"./util":18,"amdefine":19}],12:[function(_dereq_,module,exports){
8412
8473
  /* -*- Mode: js; js-indent-level: 2; -*- */
8413
8474
  /*
8414
8475
  * Copyright 2011 Mozilla Foundation and contributors
@@ -8554,7 +8615,7 @@ define(function (_dereq_, exports, module) {
8554
8615
 
8555
8616
  });
8556
8617
 
8557
- },{"./base64":12,"amdefine":1}],12:[function(_dereq_,module,exports){
8618
+ },{"./base64":13,"amdefine":19}],13:[function(_dereq_,module,exports){
8558
8619
  /* -*- Mode: js; js-indent-level: 2; -*- */
8559
8620
  /*
8560
8621
  * Copyright 2011 Mozilla Foundation and contributors
@@ -8598,7 +8659,7 @@ define(function (_dereq_, exports, module) {
8598
8659
 
8599
8660
  });
8600
8661
 
8601
- },{"amdefine":1}],13:[function(_dereq_,module,exports){
8662
+ },{"amdefine":19}],14:[function(_dereq_,module,exports){
8602
8663
  /* -*- Mode: js; js-indent-level: 2; -*- */
8603
8664
  /*
8604
8665
  * Copyright 2011 Mozilla Foundation and contributors
@@ -8681,7 +8742,7 @@ define(function (_dereq_, exports, module) {
8681
8742
 
8682
8743
  });
8683
8744
 
8684
- },{"amdefine":1}],14:[function(_dereq_,module,exports){
8745
+ },{"amdefine":19}],15:[function(_dereq_,module,exports){
8685
8746
  /* -*- Mode: js; js-indent-level: 2; -*- */
8686
8747
  /*
8687
8748
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9160,7 +9221,7 @@ define(function (_dereq_, exports, module) {
9160
9221
 
9161
9222
  });
9162
9223
 
9163
- },{"./array-set":10,"./base64-vlq":11,"./binary-search":13,"./util":17,"amdefine":1}],15:[function(_dereq_,module,exports){
9224
+ },{"./array-set":11,"./base64-vlq":12,"./binary-search":14,"./util":18,"amdefine":19}],16:[function(_dereq_,module,exports){
9164
9225
  /* -*- Mode: js; js-indent-level: 2; -*- */
9165
9226
  /*
9166
9227
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9542,7 +9603,7 @@ define(function (_dereq_, exports, module) {
9542
9603
 
9543
9604
  });
9544
9605
 
9545
- },{"./array-set":10,"./base64-vlq":11,"./util":17,"amdefine":1}],16:[function(_dereq_,module,exports){
9606
+ },{"./array-set":11,"./base64-vlq":12,"./util":18,"amdefine":19}],17:[function(_dereq_,module,exports){
9546
9607
  /* -*- Mode: js; js-indent-level: 2; -*- */
9547
9608
  /*
9548
9609
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9915,7 +9976,7 @@ define(function (_dereq_, exports, module) {
9915
9976
 
9916
9977
  });
9917
9978
 
9918
- },{"./source-map-generator":15,"./util":17,"amdefine":1}],17:[function(_dereq_,module,exports){
9979
+ },{"./source-map-generator":16,"./util":18,"amdefine":19}],18:[function(_dereq_,module,exports){
9919
9980
  /* -*- Mode: js; js-indent-level: 2; -*- */
9920
9981
  /*
9921
9982
  * Copyright 2011 Mozilla Foundation and contributors
@@ -9945,184 +10006,487 @@ define(function (_dereq_, exports, module) {
9945
10006
  } else {
9946
10007
  throw new Error('"' + aName + '" is a required argument.');
9947
10008
  }
9948
- }
9949
- exports.getArg = getArg;
10009
+ }
10010
+ exports.getArg = getArg;
10011
+
10012
+ var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/;
10013
+ var dataUrlRegexp = /^data:.+\,.+/;
10014
+
10015
+ function urlParse(aUrl) {
10016
+ var match = aUrl.match(urlRegexp);
10017
+ if (!match) {
10018
+ return null;
10019
+ }
10020
+ return {
10021
+ scheme: match[1],
10022
+ auth: match[3],
10023
+ host: match[4],
10024
+ port: match[6],
10025
+ path: match[7]
10026
+ };
10027
+ }
10028
+ exports.urlParse = urlParse;
10029
+
10030
+ function urlGenerate(aParsedUrl) {
10031
+ var url = aParsedUrl.scheme + "://";
10032
+ if (aParsedUrl.auth) {
10033
+ url += aParsedUrl.auth + "@"
10034
+ }
10035
+ if (aParsedUrl.host) {
10036
+ url += aParsedUrl.host;
10037
+ }
10038
+ if (aParsedUrl.port) {
10039
+ url += ":" + aParsedUrl.port
10040
+ }
10041
+ if (aParsedUrl.path) {
10042
+ url += aParsedUrl.path;
10043
+ }
10044
+ return url;
10045
+ }
10046
+ exports.urlGenerate = urlGenerate;
10047
+
10048
+ function join(aRoot, aPath) {
10049
+ var url;
10050
+
10051
+ if (aPath.match(urlRegexp) || aPath.match(dataUrlRegexp)) {
10052
+ return aPath;
10053
+ }
10054
+
10055
+ if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) {
10056
+ url.path = aPath;
10057
+ return urlGenerate(url);
10058
+ }
10059
+
10060
+ return aRoot.replace(/\/$/, '') + '/' + aPath;
10061
+ }
10062
+ exports.join = join;
10063
+
10064
+ /**
10065
+ * Because behavior goes wacky when you set `__proto__` on objects, we
10066
+ * have to prefix all the strings in our set with an arbitrary character.
10067
+ *
10068
+ * See https://github.com/mozilla/source-map/pull/31 and
10069
+ * https://github.com/mozilla/source-map/issues/30
10070
+ *
10071
+ * @param String aStr
10072
+ */
10073
+ function toSetString(aStr) {
10074
+ return '$' + aStr;
10075
+ }
10076
+ exports.toSetString = toSetString;
10077
+
10078
+ function fromSetString(aStr) {
10079
+ return aStr.substr(1);
10080
+ }
10081
+ exports.fromSetString = fromSetString;
10082
+
10083
+ function relative(aRoot, aPath) {
10084
+ aRoot = aRoot.replace(/\/$/, '');
10085
+
10086
+ var url = urlParse(aRoot);
10087
+ if (aPath.charAt(0) == "/" && url && url.path == "/") {
10088
+ return aPath.slice(1);
10089
+ }
10090
+
10091
+ return aPath.indexOf(aRoot + '/') === 0
10092
+ ? aPath.substr(aRoot.length + 1)
10093
+ : aPath;
10094
+ }
10095
+ exports.relative = relative;
10096
+
10097
+ function strcmp(aStr1, aStr2) {
10098
+ var s1 = aStr1 || "";
10099
+ var s2 = aStr2 || "";
10100
+ return (s1 > s2) - (s1 < s2);
10101
+ }
10102
+
10103
+ /**
10104
+ * Comparator between two mappings where the original positions are compared.
10105
+ *
10106
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
10107
+ * mappings with the same original source/line/column, but different generated
10108
+ * line and column the same. Useful when searching for a mapping with a
10109
+ * stubbed out mapping.
10110
+ */
10111
+ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
10112
+ var cmp;
10113
+
10114
+ cmp = strcmp(mappingA.source, mappingB.source);
10115
+ if (cmp) {
10116
+ return cmp;
10117
+ }
10118
+
10119
+ cmp = mappingA.originalLine - mappingB.originalLine;
10120
+ if (cmp) {
10121
+ return cmp;
10122
+ }
10123
+
10124
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
10125
+ if (cmp || onlyCompareOriginal) {
10126
+ return cmp;
10127
+ }
10128
+
10129
+ cmp = strcmp(mappingA.name, mappingB.name);
10130
+ if (cmp) {
10131
+ return cmp;
10132
+ }
10133
+
10134
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
10135
+ if (cmp) {
10136
+ return cmp;
10137
+ }
10138
+
10139
+ return mappingA.generatedColumn - mappingB.generatedColumn;
10140
+ };
10141
+ exports.compareByOriginalPositions = compareByOriginalPositions;
10142
+
10143
+ /**
10144
+ * Comparator between two mappings where the generated positions are
10145
+ * compared.
10146
+ *
10147
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
10148
+ * mappings with the same generated line and column, but different
10149
+ * source/name/original line and column the same. Useful when searching for a
10150
+ * mapping with a stubbed out mapping.
10151
+ */
10152
+ function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
10153
+ var cmp;
10154
+
10155
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
10156
+ if (cmp) {
10157
+ return cmp;
10158
+ }
10159
+
10160
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
10161
+ if (cmp || onlyCompareGenerated) {
10162
+ return cmp;
10163
+ }
10164
+
10165
+ cmp = strcmp(mappingA.source, mappingB.source);
10166
+ if (cmp) {
10167
+ return cmp;
10168
+ }
10169
+
10170
+ cmp = mappingA.originalLine - mappingB.originalLine;
10171
+ if (cmp) {
10172
+ return cmp;
10173
+ }
10174
+
10175
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
10176
+ if (cmp) {
10177
+ return cmp;
10178
+ }
10179
+
10180
+ return strcmp(mappingA.name, mappingB.name);
10181
+ };
10182
+ exports.compareByGeneratedPositions = compareByGeneratedPositions;
10183
+
10184
+ });
10185
+
10186
+ },{"amdefine":19}],19:[function(_dereq_,module,exports){
10187
+ (function (process,__filename){
10188
+ /** vim: et:ts=4:sw=4:sts=4
10189
+ * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
10190
+ * Available via the MIT or new BSD license.
10191
+ * see: http://github.com/jrburke/amdefine for details
10192
+ */
10193
+
10194
+ /*jslint node: true */
10195
+ /*global module, process */
10196
+ 'use strict';
10197
+
10198
+ /**
10199
+ * Creates a define for node.
10200
+ * @param {Object} module the "module" object that is defined by Node for the
10201
+ * current module.
10202
+ * @param {Function} [requireFn]. Node's require function for the current module.
10203
+ * It only needs to be passed in Node versions before 0.5, when module.require
10204
+ * did not exist.
10205
+ * @returns {Function} a define function that is usable for the current node
10206
+ * module.
10207
+ */
10208
+ function amdefine(module, requireFn) {
10209
+ 'use strict';
10210
+ var defineCache = {},
10211
+ loaderCache = {},
10212
+ alreadyCalled = false,
10213
+ path = _dereq_('path'),
10214
+ makeRequire, stringRequire;
10215
+
10216
+ /**
10217
+ * Trims the . and .. from an array of path segments.
10218
+ * It will keep a leading path segment if a .. will become
10219
+ * the first path segment, to help with module name lookups,
10220
+ * which act like paths, but can be remapped. But the end result,
10221
+ * all paths that use this function should look normalized.
10222
+ * NOTE: this method MODIFIES the input array.
10223
+ * @param {Array} ary the array of path segments.
10224
+ */
10225
+ function trimDots(ary) {
10226
+ var i, part;
10227
+ for (i = 0; ary[i]; i+= 1) {
10228
+ part = ary[i];
10229
+ if (part === '.') {
10230
+ ary.splice(i, 1);
10231
+ i -= 1;
10232
+ } else if (part === '..') {
10233
+ if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
10234
+ //End of the line. Keep at least one non-dot
10235
+ //path segment at the front so it can be mapped
10236
+ //correctly to disk. Otherwise, there is likely
10237
+ //no path mapping for a path starting with '..'.
10238
+ //This can still fail, but catches the most reasonable
10239
+ //uses of ..
10240
+ break;
10241
+ } else if (i > 0) {
10242
+ ary.splice(i - 1, 2);
10243
+ i -= 2;
10244
+ }
10245
+ }
10246
+ }
10247
+ }
9950
10248
 
9951
- var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/;
9952
- var dataUrlRegexp = /^data:.+\,.+/;
10249
+ function normalize(name, baseName) {
10250
+ var baseParts;
9953
10251
 
9954
- function urlParse(aUrl) {
9955
- var match = aUrl.match(urlRegexp);
9956
- if (!match) {
9957
- return null;
9958
- }
9959
- return {
9960
- scheme: match[1],
9961
- auth: match[3],
9962
- host: match[4],
9963
- port: match[6],
9964
- path: match[7]
9965
- };
9966
- }
9967
- exports.urlParse = urlParse;
10252
+ //Adjust any relative paths.
10253
+ if (name && name.charAt(0) === '.') {
10254
+ //If have a base name, try to normalize against it,
10255
+ //otherwise, assume it is a top-level require that will
10256
+ //be relative to baseUrl in the end.
10257
+ if (baseName) {
10258
+ baseParts = baseName.split('/');
10259
+ baseParts = baseParts.slice(0, baseParts.length - 1);
10260
+ baseParts = baseParts.concat(name.split('/'));
10261
+ trimDots(baseParts);
10262
+ name = baseParts.join('/');
10263
+ }
10264
+ }
9968
10265
 
9969
- function urlGenerate(aParsedUrl) {
9970
- var url = aParsedUrl.scheme + "://";
9971
- if (aParsedUrl.auth) {
9972
- url += aParsedUrl.auth + "@"
9973
- }
9974
- if (aParsedUrl.host) {
9975
- url += aParsedUrl.host;
9976
- }
9977
- if (aParsedUrl.port) {
9978
- url += ":" + aParsedUrl.port
10266
+ return name;
9979
10267
  }
9980
- if (aParsedUrl.path) {
9981
- url += aParsedUrl.path;
10268
+
10269
+ /**
10270
+ * Create the normalize() function passed to a loader plugin's
10271
+ * normalize method.
10272
+ */
10273
+ function makeNormalize(relName) {
10274
+ return function (name) {
10275
+ return normalize(name, relName);
10276
+ };
9982
10277
  }
9983
- return url;
9984
- }
9985
- exports.urlGenerate = urlGenerate;
9986
10278
 
9987
- function join(aRoot, aPath) {
9988
- var url;
10279
+ function makeLoad(id) {
10280
+ function load(value) {
10281
+ loaderCache[id] = value;
10282
+ }
9989
10283
 
9990
- if (aPath.match(urlRegexp) || aPath.match(dataUrlRegexp)) {
9991
- return aPath;
9992
- }
10284
+ load.fromText = function (id, text) {
10285
+ //This one is difficult because the text can/probably uses
10286
+ //define, and any relative paths and requires should be relative
10287
+ //to that id was it would be found on disk. But this would require
10288
+ //bootstrapping a module/require fairly deeply from node core.
10289
+ //Not sure how best to go about that yet.
10290
+ throw new Error('amdefine does not implement load.fromText');
10291
+ };
9993
10292
 
9994
- if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) {
9995
- url.path = aPath;
9996
- return urlGenerate(url);
10293
+ return load;
9997
10294
  }
9998
10295
 
9999
- return aRoot.replace(/\/$/, '') + '/' + aPath;
10000
- }
10001
- exports.join = join;
10296
+ makeRequire = function (systemRequire, exports, module, relId) {
10297
+ function amdRequire(deps, callback) {
10298
+ if (typeof deps === 'string') {
10299
+ //Synchronous, single module require('')
10300
+ return stringRequire(systemRequire, exports, module, deps, relId);
10301
+ } else {
10302
+ //Array of dependencies with a callback.
10002
10303
 
10003
- /**
10004
- * Because behavior goes wacky when you set `__proto__` on objects, we
10005
- * have to prefix all the strings in our set with an arbitrary character.
10006
- *
10007
- * See https://github.com/mozilla/source-map/pull/31 and
10008
- * https://github.com/mozilla/source-map/issues/30
10009
- *
10010
- * @param String aStr
10011
- */
10012
- function toSetString(aStr) {
10013
- return '$' + aStr;
10014
- }
10015
- exports.toSetString = toSetString;
10304
+ //Convert the dependencies to modules.
10305
+ deps = deps.map(function (depName) {
10306
+ return stringRequire(systemRequire, exports, module, depName, relId);
10307
+ });
10016
10308
 
10017
- function fromSetString(aStr) {
10018
- return aStr.substr(1);
10019
- }
10020
- exports.fromSetString = fromSetString;
10309
+ //Wait for next tick to call back the require call.
10310
+ process.nextTick(function () {
10311
+ callback.apply(null, deps);
10312
+ });
10313
+ }
10314
+ }
10021
10315
 
10022
- function relative(aRoot, aPath) {
10023
- aRoot = aRoot.replace(/\/$/, '');
10316
+ amdRequire.toUrl = function (filePath) {
10317
+ if (filePath.indexOf('.') === 0) {
10318
+ return normalize(filePath, path.dirname(module.filename));
10319
+ } else {
10320
+ return filePath;
10321
+ }
10322
+ };
10024
10323
 
10025
- var url = urlParse(aRoot);
10026
- if (aPath.charAt(0) == "/" && url && url.path == "/") {
10027
- return aPath.slice(1);
10028
- }
10324
+ return amdRequire;
10325
+ };
10029
10326
 
10030
- return aPath.indexOf(aRoot + '/') === 0
10031
- ? aPath.substr(aRoot.length + 1)
10032
- : aPath;
10033
- }
10034
- exports.relative = relative;
10327
+ //Favor explicit value, passed in if the module wants to support Node 0.4.
10328
+ requireFn = requireFn || function req() {
10329
+ return module.require.apply(module, arguments);
10330
+ };
10035
10331
 
10036
- function strcmp(aStr1, aStr2) {
10037
- var s1 = aStr1 || "";
10038
- var s2 = aStr2 || "";
10039
- return (s1 > s2) - (s1 < s2);
10040
- }
10332
+ function runFactory(id, deps, factory) {
10333
+ var r, e, m, result;
10041
10334
 
10042
- /**
10043
- * Comparator between two mappings where the original positions are compared.
10044
- *
10045
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
10046
- * mappings with the same original source/line/column, but different generated
10047
- * line and column the same. Useful when searching for a mapping with a
10048
- * stubbed out mapping.
10049
- */
10050
- function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
10051
- var cmp;
10335
+ if (id) {
10336
+ e = loaderCache[id] = {};
10337
+ m = {
10338
+ id: id,
10339
+ uri: __filename,
10340
+ exports: e
10341
+ };
10342
+ r = makeRequire(requireFn, e, m, id);
10343
+ } else {
10344
+ //Only support one define call per file
10345
+ if (alreadyCalled) {
10346
+ throw new Error('amdefine with no module ID cannot be called more than once per file.');
10347
+ }
10348
+ alreadyCalled = true;
10052
10349
 
10053
- cmp = strcmp(mappingA.source, mappingB.source);
10054
- if (cmp) {
10055
- return cmp;
10056
- }
10350
+ //Use the real variables from node
10351
+ //Use module.exports for exports, since
10352
+ //the exports in here is amdefine exports.
10353
+ e = module.exports;
10354
+ m = module;
10355
+ r = makeRequire(requireFn, e, m, module.id);
10356
+ }
10057
10357
 
10058
- cmp = mappingA.originalLine - mappingB.originalLine;
10059
- if (cmp) {
10060
- return cmp;
10358
+ //If there are dependencies, they are strings, so need
10359
+ //to convert them to dependency values.
10360
+ if (deps) {
10361
+ deps = deps.map(function (depName) {
10362
+ return r(depName);
10363
+ });
10364
+ }
10365
+
10366
+ //Call the factory with the right dependencies.
10367
+ if (typeof factory === 'function') {
10368
+ result = factory.apply(m.exports, deps);
10369
+ } else {
10370
+ result = factory;
10371
+ }
10372
+
10373
+ if (result !== undefined) {
10374
+ m.exports = result;
10375
+ if (id) {
10376
+ loaderCache[id] = m.exports;
10377
+ }
10378
+ }
10061
10379
  }
10062
10380
 
10063
- cmp = mappingA.originalColumn - mappingB.originalColumn;
10064
- if (cmp || onlyCompareOriginal) {
10065
- return cmp;
10066
- }
10381
+ stringRequire = function (systemRequire, exports, module, id, relId) {
10382
+ //Split the ID by a ! so that
10383
+ var index = id.indexOf('!'),
10384
+ originalId = id,
10385
+ prefix, plugin;
10386
+
10387
+ if (index === -1) {
10388
+ id = normalize(id, relId);
10389
+
10390
+ //Straight module lookup. If it is one of the special dependencies,
10391
+ //deal with it, otherwise, delegate to node.
10392
+ if (id === 'require') {
10393
+ return makeRequire(systemRequire, exports, module, relId);
10394
+ } else if (id === 'exports') {
10395
+ return exports;
10396
+ } else if (id === 'module') {
10397
+ return module;
10398
+ } else if (loaderCache.hasOwnProperty(id)) {
10399
+ return loaderCache[id];
10400
+ } else if (defineCache[id]) {
10401
+ runFactory.apply(null, defineCache[id]);
10402
+ return loaderCache[id];
10403
+ } else {
10404
+ if(systemRequire) {
10405
+ return systemRequire(originalId);
10406
+ } else {
10407
+ throw new Error('No module with ID: ' + id);
10408
+ }
10409
+ }
10410
+ } else {
10411
+ //There is a plugin in play.
10412
+ prefix = id.substring(0, index);
10413
+ id = id.substring(index + 1, id.length);
10414
+
10415
+ plugin = stringRequire(systemRequire, exports, module, prefix, relId);
10416
+
10417
+ if (plugin.normalize) {
10418
+ id = plugin.normalize(id, makeNormalize(relId));
10419
+ } else {
10420
+ //Normalize the ID normally.
10421
+ id = normalize(id, relId);
10422
+ }
10067
10423
 
10068
- cmp = strcmp(mappingA.name, mappingB.name);
10069
- if (cmp) {
10070
- return cmp;
10071
- }
10424
+ if (loaderCache[id]) {
10425
+ return loaderCache[id];
10426
+ } else {
10427
+ plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
10072
10428
 
10073
- cmp = mappingA.generatedLine - mappingB.generatedLine;
10074
- if (cmp) {
10075
- return cmp;
10076
- }
10429
+ return loaderCache[id];
10430
+ }
10431
+ }
10432
+ };
10077
10433
 
10078
- return mappingA.generatedColumn - mappingB.generatedColumn;
10079
- };
10080
- exports.compareByOriginalPositions = compareByOriginalPositions;
10434
+ //Create a define function specific to the module asking for amdefine.
10435
+ function define(id, deps, factory) {
10436
+ if (Array.isArray(id)) {
10437
+ factory = deps;
10438
+ deps = id;
10439
+ id = undefined;
10440
+ } else if (typeof id !== 'string') {
10441
+ factory = id;
10442
+ id = deps = undefined;
10443
+ }
10081
10444
 
10082
- /**
10083
- * Comparator between two mappings where the generated positions are
10084
- * compared.
10085
- *
10086
- * Optionally pass in `true` as `onlyCompareGenerated` to consider two
10087
- * mappings with the same generated line and column, but different
10088
- * source/name/original line and column the same. Useful when searching for a
10089
- * mapping with a stubbed out mapping.
10090
- */
10091
- function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
10092
- var cmp;
10445
+ if (deps && !Array.isArray(deps)) {
10446
+ factory = deps;
10447
+ deps = undefined;
10448
+ }
10093
10449
 
10094
- cmp = mappingA.generatedLine - mappingB.generatedLine;
10095
- if (cmp) {
10096
- return cmp;
10097
- }
10450
+ if (!deps) {
10451
+ deps = ['require', 'exports', 'module'];
10452
+ }
10098
10453
 
10099
- cmp = mappingA.generatedColumn - mappingB.generatedColumn;
10100
- if (cmp || onlyCompareGenerated) {
10101
- return cmp;
10454
+ //Set up properties for this module. If an ID, then use
10455
+ //internal cache. If no ID, then use the external variables
10456
+ //for this node module.
10457
+ if (id) {
10458
+ //Put the module in deep freeze until there is a
10459
+ //require call for it.
10460
+ defineCache[id] = [id, deps, factory];
10461
+ } else {
10462
+ runFactory(id, deps, factory);
10463
+ }
10102
10464
  }
10103
10465
 
10104
- cmp = strcmp(mappingA.source, mappingB.source);
10105
- if (cmp) {
10106
- return cmp;
10107
- }
10466
+ //define.require, which has access to all the values in the
10467
+ //cache. Useful for AMD modules that all have IDs in the file,
10468
+ //but need to finally export a value to node based on one of those
10469
+ //IDs.
10470
+ define.require = function (id) {
10471
+ if (loaderCache[id]) {
10472
+ return loaderCache[id];
10473
+ }
10108
10474
 
10109
- cmp = mappingA.originalLine - mappingB.originalLine;
10110
- if (cmp) {
10111
- return cmp;
10112
- }
10475
+ if (defineCache[id]) {
10476
+ runFactory.apply(null, defineCache[id]);
10477
+ return loaderCache[id];
10478
+ }
10479
+ };
10113
10480
 
10114
- cmp = mappingA.originalColumn - mappingB.originalColumn;
10115
- if (cmp) {
10116
- return cmp;
10117
- }
10481
+ define.amd = {};
10118
10482
 
10119
- return strcmp(mappingA.name, mappingB.name);
10120
- };
10121
- exports.compareByGeneratedPositions = compareByGeneratedPositions;
10483
+ return define;
10484
+ }
10122
10485
 
10123
- });
10486
+ module.exports = amdefine;
10124
10487
 
10125
- },{"amdefine":1}],18:[function(_dereq_,module,exports){
10488
+ }).call(this,_dereq_('_process'),"/node_modules/jstransform/node_modules/source-map/node_modules/amdefine/amdefine.js")
10489
+ },{"_process":7,"path":6}],20:[function(_dereq_,module,exports){
10126
10490
  /**
10127
10491
  * Copyright 2013 Facebook, Inc.
10128
10492
  *
@@ -10210,7 +10574,7 @@ exports.extract = extract;
10210
10574
  exports.parse = parse;
10211
10575
  exports.parseAsObject = parseAsObject;
10212
10576
 
10213
- },{}],19:[function(_dereq_,module,exports){
10577
+ },{}],21:[function(_dereq_,module,exports){
10214
10578
  /**
10215
10579
  * Copyright 2013 Facebook, Inc.
10216
10580
  *
@@ -10464,8 +10828,9 @@ function transform(visitors, source, options) {
10464
10828
  }
10465
10829
 
10466
10830
  exports.transform = transform;
10831
+ exports.Syntax = Syntax;
10467
10832
 
10468
- },{"./utils":20,"esprima-fb":7,"source-map":9}],20:[function(_dereq_,module,exports){
10833
+ },{"./utils":22,"esprima-fb":8,"source-map":10}],22:[function(_dereq_,module,exports){
10469
10834
  /**
10470
10835
  * Copyright 2013 Facebook, Inc.
10471
10836
  *
@@ -11072,7 +11437,7 @@ exports.analyzeAndTraverse = analyzeAndTraverse;
11072
11437
  exports.getOrderedChildren = getOrderedChildren;
11073
11438
  exports.getNodeSourceText = getNodeSourceText;
11074
11439
 
11075
- },{"./docblock":18,"esprima-fb":7}],21:[function(_dereq_,module,exports){
11440
+ },{"./docblock":20,"esprima-fb":8}],23:[function(_dereq_,module,exports){
11076
11441
  /**
11077
11442
  * Copyright 2013 Facebook, Inc.
11078
11443
  *
@@ -11225,7 +11590,7 @@ exports.visitorList = [
11225
11590
  ];
11226
11591
 
11227
11592
 
11228
- },{"../src/utils":20,"./es6-destructuring-visitors":23,"./es6-rest-param-visitors":26,"esprima-fb":7}],22:[function(_dereq_,module,exports){
11593
+ },{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":8}],24:[function(_dereq_,module,exports){
11229
11594
  /**
11230
11595
  * Copyright 2013 Facebook, Inc.
11231
11596
  *
@@ -11252,6 +11617,7 @@ exports.visitorList = [
11252
11617
  var base62 = _dereq_('base62');
11253
11618
  var Syntax = _dereq_('esprima-fb').Syntax;
11254
11619
  var utils = _dereq_('../src/utils');
11620
+ var reservedWordsHelper = _dereq_('./reserved-words-helper');
11255
11621
 
11256
11622
  var declareIdentInLocalScope = utils.declareIdentInLocalScope;
11257
11623
  var initScopeMetadata = utils.initScopeMetadata;
@@ -11370,7 +11736,7 @@ function _shouldMungeIdentifier(node, state) {
11370
11736
  * @param {object} state
11371
11737
  */
11372
11738
  function visitClassMethod(traverse, node, path, state) {
11373
- if (node.kind === 'get' || node.kind === 'set') {
11739
+ if (!state.g.opts.es5 && (node.kind === 'get' || node.kind === 'set')) {
11374
11740
  throw new Error(
11375
11741
  'This transform does not support ' + node.kind + 'ter methods for ES6 ' +
11376
11742
  'classes. (line: ' + node.loc.start.line + ', col: ' +
@@ -11398,6 +11764,8 @@ visitClassMethod.test = function(node, path, state) {
11398
11764
  */
11399
11765
  function visitClassFunctionExpression(traverse, node, path, state) {
11400
11766
  var methodNode = path[0];
11767
+ var isGetter = methodNode.kind === 'get';
11768
+ var isSetter = methodNode.kind === 'set';
11401
11769
 
11402
11770
  state = utils.updateState(state, {
11403
11771
  methodFuncNode: node
@@ -11408,6 +11776,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
11408
11776
  } else {
11409
11777
  var methodAccessor;
11410
11778
  var prototypeOrStatic = methodNode["static"] ? '' : '.prototype';
11779
+ var objectAccessor = state.className + prototypeOrStatic;
11411
11780
 
11412
11781
  if (methodNode.key.type === Syntax.Identifier) {
11413
11782
  // foo() {}
@@ -11415,17 +11784,37 @@ function visitClassFunctionExpression(traverse, node, path, state) {
11415
11784
  if (_shouldMungeIdentifier(methodNode.key, state)) {
11416
11785
  methodAccessor = _getMungedName(methodAccessor, state);
11417
11786
  }
11418
- methodAccessor = '.' + methodAccessor;
11787
+ if (isGetter || isSetter) {
11788
+ methodAccessor = JSON.stringify(methodAccessor);
11789
+ } else if (reservedWordsHelper.isReservedWord(methodAccessor)) {
11790
+ methodAccessor = '[' + JSON.stringify(methodAccessor) + ']';
11791
+ } else {
11792
+ methodAccessor = '.' + methodAccessor;
11793
+ }
11419
11794
  } else if (methodNode.key.type === Syntax.Literal) {
11420
- // 'foo bar'() {}
11421
- methodAccessor = '[' + JSON.stringify(methodNode.key.value) + ']';
11795
+ // 'foo bar'() {} | get 'foo bar'() {} | set 'foo bar'() {}
11796
+ methodAccessor = JSON.stringify(methodNode.key.value);
11797
+ if (!(isGetter || isSetter)) {
11798
+ methodAccessor = '[' + methodAccessor + ']';
11799
+ }
11422
11800
  }
11423
11801
 
11424
- utils.append(
11425
- state.className + prototypeOrStatic +
11426
- methodAccessor + '=function',
11427
- state
11428
- );
11802
+ if (isSetter || isGetter) {
11803
+ utils.append(
11804
+ 'Object.defineProperty(' +
11805
+ objectAccessor + ',' +
11806
+ methodAccessor + ',' +
11807
+ '{enumerable:true,configurable:true,' +
11808
+ methodNode.kind + ':function',
11809
+ state
11810
+ );
11811
+ } else {
11812
+ utils.append(
11813
+ objectAccessor +
11814
+ methodAccessor + '=function' + (node.generator ? '*' : ''),
11815
+ state
11816
+ );
11817
+ }
11429
11818
  }
11430
11819
  utils.move(methodNode.key.range[1], state);
11431
11820
  utils.append('(', state);
@@ -11457,6 +11846,9 @@ function visitClassFunctionExpression(traverse, node, path, state) {
11457
11846
  utils.catchup(node.body.range[1], state);
11458
11847
 
11459
11848
  if (methodNode.key.name !== 'constructor') {
11849
+ if (isGetter || isSetter) {
11850
+ utils.append('})', state);
11851
+ }
11460
11852
  utils.append(';', state);
11461
11853
  }
11462
11854
  return false;
@@ -11767,7 +12159,7 @@ exports.visitorList = [
11767
12159
  visitSuperMemberExpression
11768
12160
  ];
11769
12161
 
11770
- },{"../src/utils":20,"base62":8,"esprima-fb":7}],23:[function(_dereq_,module,exports){
12162
+ },{"../src/utils":22,"./reserved-words-helper":32,"base62":9,"esprima-fb":8}],25:[function(_dereq_,module,exports){
11771
12163
  /**
11772
12164
  * Copyright 2014 Facebook, Inc.
11773
12165
  *
@@ -11810,7 +12202,9 @@ exports.visitorList = [
11810
12202
  var Syntax = _dereq_('esprima-fb').Syntax;
11811
12203
  var utils = _dereq_('../src/utils');
11812
12204
 
12205
+ var reservedWordsHelper = _dereq_('./reserved-words-helper');
11813
12206
  var restParamVisitors = _dereq_('./es6-rest-param-visitors');
12207
+ var restPropertyHelpers = _dereq_('./es7-rest-property-helpers');
11814
12208
 
11815
12209
  // -------------------------------------------------------
11816
12210
  // 1. Structured variable declarations.
@@ -11855,6 +12249,26 @@ function getDestructuredComponents(node, state) {
11855
12249
  continue;
11856
12250
  }
11857
12251
 
12252
+ if (item.type === Syntax.SpreadElement) {
12253
+ // Spread/rest of an array.
12254
+ // TODO(dmitrys): support spread in the middle of a pattern
12255
+ // and also for function param patterns: [x, ...xs, y]
12256
+ components.push(item.argument.name +
12257
+ '=Array.prototype.slice.call(' +
12258
+ getTmpVar(tmpIndex) + ',' + idx + ')'
12259
+ );
12260
+ continue;
12261
+ }
12262
+
12263
+ if (item.type === Syntax.SpreadProperty) {
12264
+ var restExpression = restPropertyHelpers.renderRestExpression(
12265
+ getTmpVar(tmpIndex),
12266
+ patternItems
12267
+ );
12268
+ components.push(item.argument.name + '=' + restExpression);
12269
+ continue;
12270
+ }
12271
+
11858
12272
  // Depending on pattern type (Array or Object), we get
11859
12273
  // corresponding pattern item parts.
11860
12274
  var accessor = getPatternItemAccessor(node, item, tmpIndex, idx);
@@ -11864,14 +12278,6 @@ function getDestructuredComponents(node, state) {
11864
12278
  if (value.type === Syntax.Identifier) {
11865
12279
  // Simple pattern item.
11866
12280
  components.push(value.name + '=' + accessor);
11867
- } else if (value.type === Syntax.SpreadElement) {
11868
- // Spread/rest of an array.
11869
- // TODO(dmitrys): support spread in the middle of a pattern
11870
- // and also for function param patterns: [x, ...xs, y]
11871
- components.push(value.argument.name +
11872
- '=Array.prototype.slice.call(' +
11873
- getTmpVar(tmpIndex) + ',' + idx + ')'
11874
- );
11875
12281
  } else {
11876
12282
  // Complex sub-structure.
11877
12283
  components.push(
@@ -11890,9 +12296,15 @@ function getPatternItems(node) {
11890
12296
 
11891
12297
  function getPatternItemAccessor(node, patternItem, tmpIndex, idx) {
11892
12298
  var tmpName = getTmpVar(tmpIndex);
11893
- return node.type === Syntax.ObjectPattern
11894
- ? tmpName + '.' + patternItem.key.name
11895
- : tmpName + '[' + idx + ']';
12299
+ if (node.type === Syntax.ObjectPattern) {
12300
+ if (reservedWordsHelper.isReservedWord(patternItem.key.name)) {
12301
+ return tmpName + '["' + patternItem.key.name + '"]';
12302
+ } else {
12303
+ return tmpName + '.' + patternItem.key.name;
12304
+ }
12305
+ } else {
12306
+ return tmpName + '[' + idx + ']';
12307
+ }
11896
12308
  }
11897
12309
 
11898
12310
  function getPatternItemValue(node, patternItem) {
@@ -12035,7 +12447,7 @@ exports.visitorList = [
12035
12447
  exports.renderDestructuredComponents = renderDestructuredComponents;
12036
12448
 
12037
12449
 
12038
- },{"../src/utils":20,"./es6-rest-param-visitors":26,"esprima-fb":7}],24:[function(_dereq_,module,exports){
12450
+ },{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":8}],26:[function(_dereq_,module,exports){
12039
12451
  /**
12040
12452
  * Copyright 2013 Facebook, Inc.
12041
12453
  *
@@ -12055,7 +12467,7 @@ exports.renderDestructuredComponents = renderDestructuredComponents;
12055
12467
  /*jslint node:true*/
12056
12468
 
12057
12469
  /**
12058
- * Desugars concise methods of objects to ES3 function expressions.
12470
+ * Desugars concise methods of objects to function expressions.
12059
12471
  *
12060
12472
  * var foo = {
12061
12473
  * method(x, y) { ... }
@@ -12069,10 +12481,27 @@ exports.renderDestructuredComponents = renderDestructuredComponents;
12069
12481
 
12070
12482
  var Syntax = _dereq_('esprima-fb').Syntax;
12071
12483
  var utils = _dereq_('../src/utils');
12484
+ var reservedWordsHelper = _dereq_('./reserved-words-helper');
12072
12485
 
12073
12486
  function visitObjectConciseMethod(traverse, node, path, state) {
12487
+ var isGenerator = node.value.generator;
12488
+ if (isGenerator) {
12489
+ utils.catchupWhiteSpace(node.range[0] + 1, state);
12490
+ }
12491
+ if (node.computed) { // [<expr>]() { ...}
12492
+ utils.catchup(node.key.range[1] + 1, state);
12493
+ } else if (reservedWordsHelper.isReservedWord(node.key.name)) {
12494
+ utils.catchup(node.key.range[0], state);
12495
+ utils.append('"', state);
12496
+ utils.catchup(node.key.range[1], state);
12497
+ utils.append('"', state);
12498
+ }
12499
+
12074
12500
  utils.catchup(node.key.range[1], state);
12075
- utils.append(':function', state);
12501
+ utils.append(
12502
+ ':function' + (isGenerator ? '*' : ''),
12503
+ state
12504
+ );
12076
12505
  path.unshift(node);
12077
12506
  traverse(node.value, path, state);
12078
12507
  path.shift();
@@ -12089,7 +12518,7 @@ exports.visitorList = [
12089
12518
  visitObjectConciseMethod
12090
12519
  ];
12091
12520
 
12092
- },{"../src/utils":20,"esprima-fb":7}],25:[function(_dereq_,module,exports){
12521
+ },{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":8}],27:[function(_dereq_,module,exports){
12093
12522
  /**
12094
12523
  * Copyright 2013 Facebook, Inc.
12095
12524
  *
@@ -12144,7 +12573,7 @@ exports.visitorList = [
12144
12573
  ];
12145
12574
 
12146
12575
 
12147
- },{"../src/utils":20,"esprima-fb":7}],26:[function(_dereq_,module,exports){
12576
+ },{"../src/utils":22,"esprima-fb":8}],28:[function(_dereq_,module,exports){
12148
12577
  /**
12149
12578
  * Copyright 2013 Facebook, Inc.
12150
12579
  *
@@ -12243,7 +12672,7 @@ exports.visitorList = [
12243
12672
  visitFunctionBodyWithRestParam
12244
12673
  ];
12245
12674
 
12246
- },{"../src/utils":20,"esprima-fb":7}],27:[function(_dereq_,module,exports){
12675
+ },{"../src/utils":22,"esprima-fb":8}],29:[function(_dereq_,module,exports){
12247
12676
  /**
12248
12677
  * Copyright 2013 Facebook, Inc.
12249
12678
  *
@@ -12401,9 +12830,9 @@ exports.visitorList = [
12401
12830
  visitTaggedTemplateExpression
12402
12831
  ];
12403
12832
 
12404
- },{"../src/utils":20,"esprima-fb":7}],28:[function(_dereq_,module,exports){
12833
+ },{"../src/utils":22,"esprima-fb":8}],30:[function(_dereq_,module,exports){
12405
12834
  /**
12406
- * Copyright 2013-2014 Facebook, Inc.
12835
+ * Copyright 2013 Facebook, Inc.
12407
12836
  *
12408
12837
  * Licensed under the Apache License, Version 2.0 (the "License");
12409
12838
  * you may not use this file except in compliance with the License.
@@ -12417,321 +12846,182 @@ exports.visitorList = [
12417
12846
  * See the License for the specific language governing permissions and
12418
12847
  * limitations under the License.
12419
12848
  */
12420
- /* jshint browser: true */
12421
- /* jslint evil: true */
12422
-
12423
- 'use strict';
12424
-
12425
- var buffer = _dereq_('buffer');
12426
- var docblock = _dereq_('jstransform/src/docblock');
12427
- var transform = _dereq_('jstransform').transform;
12428
- var visitors = _dereq_('./fbtransform/visitors');
12429
-
12430
- var runScripts;
12431
- var loadScripts;
12432
- var headEl;
12433
- var dummyAnchor;
12434
- var inlineScriptCount = 0;
12435
-
12436
- // The source-map library relies on Object.defineProperty, but IE8 doesn't
12437
- // support it fully even with es5-sham. Indeed, es5-sham's defineProperty
12438
- // throws when Object.prototype.__defineGetter__ is missing, so we skip building
12439
- // the source map in that case.
12440
- var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
12441
-
12442
- /**
12443
- * Run provided code through jstransform.
12444
- *
12445
- * @param {string} source Original source code
12446
- * @param {object?} options Options to pass to jstransform
12447
- * @return {object} object as returned from jstransform
12448
- */
12449
- function transformReact(source, options) {
12450
- // TODO: just use react-tools
12451
- var visitorList;
12452
- if (options && options.harmony) {
12453
- visitorList = visitors.getAllVisitors();
12454
- } else {
12455
- visitorList = visitors.transformVisitors.react;
12456
- }
12457
-
12458
- return transform(visitorList, source, {
12459
- sourceMap: supportsAccessors
12460
- });
12461
- }
12462
12849
 
12463
- /**
12464
- * Eval provided source after transforming it.
12465
- *
12466
- * @param {string} source Original source code
12467
- * @param {object?} options Options to pass to jstransform
12468
- */
12469
- function exec(source, options) {
12470
- return eval(transformReact(source, options).code);
12471
- }
12850
+ /*jslint node:true*/
12472
12851
 
12473
12852
  /**
12474
- * This method returns a nicely formated line of code pointing to the exact
12475
- * location of the error `e`. The line is limited in size so big lines of code
12476
- * are also shown in a readable way.
12477
- *
12478
- * Example:
12479
- * ... x', overflow:'scroll'}} id={} onScroll={this.scroll} class=" ...
12480
- * ^
12481
- *
12482
- * @param {string} code The full string of code
12483
- * @param {Error} e The error being thrown
12484
- * @return {string} formatted message
12485
- * @internal
12853
+ * Desugars ES7 rest properties into ES5 object iteration.
12486
12854
  */
12487
- function createSourceCodeErrorMessage(code, e) {
12488
- var sourceLines = code.split('\n');
12489
- var erroneousLine = sourceLines[e.lineNumber - 1];
12490
-
12491
- // Removes any leading indenting spaces and gets the number of
12492
- // chars indenting the `erroneousLine`
12493
- var indentation = 0;
12494
- erroneousLine = erroneousLine.replace(/^\s+/, function(leadingSpaces) {
12495
- indentation = leadingSpaces.length;
12496
- return '';
12497
- });
12498
12855
 
12499
- // Defines the number of characters that are going to show
12500
- // before and after the erroneous code
12501
- var LIMIT = 30;
12502
- var errorColumn = e.column - indentation;
12856
+ var Syntax = _dereq_('esprima-fb').Syntax;
12857
+ var utils = _dereq_('../src/utils');
12503
12858
 
12504
- if (errorColumn > LIMIT) {
12505
- erroneousLine = '... ' + erroneousLine.slice(errorColumn - LIMIT);
12506
- errorColumn = 4 + LIMIT;
12507
- }
12508
- if (erroneousLine.length - errorColumn > LIMIT) {
12509
- erroneousLine = erroneousLine.slice(0, errorColumn + LIMIT) + ' ...';
12859
+ // TODO: This is a pretty massive helper, it should only be defined once, in the
12860
+ // transform's runtime environment. We don't currently have a runtime though.
12861
+ var restFunction =
12862
+ '(function(source, exclusion) {' +
12863
+ 'var rest = {};' +
12864
+ 'var hasOwn = Object.prototype.hasOwnProperty;' +
12865
+ 'if (source == null) {' +
12866
+ 'throw new TypeError();' +
12867
+ '}' +
12868
+ 'for (var key in source) {' +
12869
+ 'if (hasOwn.call(source, key) && !hasOwn.call(exclusion, key)) {' +
12870
+ 'rest[key] = source[key];' +
12871
+ '}' +
12872
+ '}' +
12873
+ 'return rest;' +
12874
+ '})';
12875
+
12876
+ function getPropertyNames(properties) {
12877
+ var names = [];
12878
+ for (var i = 0; i < properties.length; i++) {
12879
+ var property = properties[i];
12880
+ if (property.type === Syntax.SpreadProperty) {
12881
+ continue;
12882
+ }
12883
+ if (property.type === Syntax.Identifier) {
12884
+ names.push(property.name);
12885
+ } else {
12886
+ names.push(property.key.name);
12887
+ }
12510
12888
  }
12511
- var message = '\n\n' + erroneousLine + '\n';
12512
- message += new Array(errorColumn - 1).join(' ') + '^';
12513
- return message;
12889
+ return names;
12514
12890
  }
12515
12891
 
12516
- /**
12517
- * Actually transform the code.
12518
- *
12519
- * @param {string} code
12520
- * @param {string?} url
12521
- * @param {object?} options
12522
- * @return {string} The transformed code.
12523
- * @internal
12524
- */
12525
- function transformCode(code, url, options) {
12526
- var jsx = docblock.parseAsObject(docblock.extract(code)).jsx;
12527
-
12528
- if (jsx) {
12529
- try {
12530
- var transformed = transformReact(code, options);
12531
- } catch(e) {
12532
- e.message += '\n at ';
12533
- if (url) {
12534
- if ('fileName' in e) {
12535
- // We set `fileName` if it's supported by this error object and
12536
- // a `url` was provided.
12537
- // The error will correctly point to `url` in Firefox.
12538
- e.fileName = url;
12539
- }
12540
- e.message += url + ':' + e.lineNumber + ':' + e.column;
12541
- } else {
12542
- e.message += location.href;
12543
- }
12544
- e.message += createSourceCodeErrorMessage(code, e);
12545
- throw e;
12546
- }
12892
+ function getRestFunctionCall(source, exclusion) {
12893
+ return restFunction + '(' + source + ',' + exclusion + ')';
12894
+ }
12547
12895
 
12548
- if (!transformed.sourceMap) {
12549
- return transformed.code;
12550
- }
12896
+ function getSimpleShallowCopy(accessorExpression) {
12897
+ // This could be faster with 'Object.assign({}, ' + accessorExpression + ')'
12898
+ // but to unify code paths and avoid a ES6 dependency we use the same
12899
+ // helper as for the exclusion case.
12900
+ return getRestFunctionCall(accessorExpression, '{}');
12901
+ }
12551
12902
 
12552
- var map = transformed.sourceMap.toJSON();
12553
- var source;
12554
- if (url == null) {
12555
- source = "Inline JSX script";
12556
- inlineScriptCount++;
12557
- if (inlineScriptCount > 1) {
12558
- source += ' (' + inlineScriptCount + ')';
12559
- }
12560
- } else if (dummyAnchor) {
12561
- // Firefox has problems when the sourcemap source is a proper URL with a
12562
- // protocol and hostname, so use the pathname. We could use just the
12563
- // filename, but hopefully using the full path will prevent potential
12564
- // issues where the same filename exists in multiple directories.
12565
- dummyAnchor.href = url;
12566
- source = dummyAnchor.pathname.substr(1);
12567
- }
12568
- map.sources = [source];
12569
- map.sourcesContent = [code];
12570
-
12571
- return (
12572
- transformed.code +
12573
- '\n//# sourceMappingURL=data:application/json;base64,' +
12574
- buffer.Buffer(JSON.stringify(map)).toString('base64')
12575
- );
12576
- } else {
12577
- // TODO: warn that we found a script tag missing the docblock?
12578
- // or warn and proceed anyway?
12579
- // or warn, add it ourselves, and proceed anyway?
12580
- return code;
12903
+ function renderRestExpression(accessorExpression, excludedProperties) {
12904
+ var excludedNames = getPropertyNames(excludedProperties);
12905
+ if (!excludedNames.length) {
12906
+ return getSimpleShallowCopy(accessorExpression);
12581
12907
  }
12908
+ return getRestFunctionCall(
12909
+ accessorExpression,
12910
+ '{' + excludedNames.join(':1,') + ':1}'
12911
+ );
12582
12912
  }
12583
12913
 
12914
+ exports.renderRestExpression = renderRestExpression;
12584
12915
 
12916
+ },{"../src/utils":22,"esprima-fb":8}],31:[function(_dereq_,module,exports){
12585
12917
  /**
12586
- * Appends a script element at the end of the <head> with the content of code,
12587
- * after transforming it.
12588
- *
12589
- * @param {string} code The original source code
12590
- * @param {string?} url Where the code came from. null if inline
12591
- * @param {object?} options Options to pass to jstransform
12592
- * @internal
12918
+ * Copyright 2004-present Facebook. All Rights Reserved.
12593
12919
  */
12594
- function run(code, url, options) {
12595
- var scriptEl = document.createElement('script');
12596
- scriptEl.text = transformCode(code, url, options);
12597
- headEl.appendChild(scriptEl);
12598
- }
12920
+ /*global exports:true*/
12599
12921
 
12600
12922
  /**
12601
- * Load script from the provided url and pass the content to the callback.
12923
+ * Implements ES7 object spread property.
12924
+ * https://gist.github.com/sebmarkbage/aa849c7973cb4452c547
12925
+ *
12926
+ * { ...a, x: 1 }
12927
+ *
12928
+ * Object.assign({}, a, {x: 1 })
12602
12929
  *
12603
- * @param {string} url The location of the script src
12604
- * @param {function} callback Function to call with the content of url
12605
- * @internal
12606
12930
  */
12607
- function load(url, callback) {
12608
- var xhr;
12609
- xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP')
12610
- : new XMLHttpRequest();
12611
12931
 
12612
- // async, however scripts will be executed in the order they are in the
12613
- // DOM to mirror normal script loading.
12614
- xhr.open('GET', url, true);
12615
- if ('overrideMimeType' in xhr) {
12616
- xhr.overrideMimeType('text/plain');
12617
- }
12618
- xhr.onreadystatechange = function() {
12619
- if (xhr.readyState === 4) {
12620
- if (xhr.status === 0 || xhr.status === 200) {
12621
- callback(xhr.responseText, url);
12622
- } else {
12623
- throw new Error("Could not load " + url);
12624
- }
12625
- }
12626
- };
12627
- return xhr.send(null);
12628
- }
12932
+ var Syntax = _dereq_('esprima-fb').Syntax;
12933
+ var utils = _dereq_('../src/utils');
12629
12934
 
12630
- /**
12631
- * Loop over provided script tags and get the content, via innerHTML if an
12632
- * inline script, or by using XHR. Transforms are applied if needed. The scripts
12633
- * are executed in the order they are found on the page.
12634
- *
12635
- * @param {array} scripts The <script> elements to load and run.
12636
- * @internal
12637
- */
12638
- function loadScripts(scripts) {
12639
- var result = scripts.map(function() {
12640
- return false;
12641
- });
12642
- var count = result.length;
12935
+ function visitObjectLiteralSpread(traverse, node, path, state) {
12936
+ utils.catchup(node.range[0], state);
12643
12937
 
12644
- function check() {
12645
- var script, i;
12938
+ utils.append('Object.assign({', state);
12646
12939
 
12647
- for (i = 0; i < count; i++) {
12648
- script = result[i];
12940
+ // Skip the original {
12941
+ utils.move(node.range[0] + 1, state);
12649
12942
 
12650
- if (script && !script.executed) {
12651
- run(script.content, script.url, script.options);
12652
- script.executed = true;
12653
- } else if (!script) {
12654
- break;
12943
+ var previousWasSpread = false;
12944
+
12945
+ for (var i = 0; i < node.properties.length; i++) {
12946
+ var property = node.properties[i];
12947
+ if (property.type === Syntax.SpreadProperty) {
12948
+
12949
+ // Close the previous object or initial object
12950
+ if (!previousWasSpread) {
12951
+ utils.append('}', state);
12655
12952
  }
12656
- }
12657
- }
12658
12953
 
12659
- scripts.forEach(function(script, i) {
12660
- var options;
12661
- if (script.type.indexOf('harmony=true') !== -1) {
12662
- options = {
12663
- harmony: true
12664
- };
12665
- }
12954
+ if (i === 0) {
12955
+ // Normally there will be a comma when we catch up, but not before
12956
+ // the first property.
12957
+ utils.append(',', state);
12958
+ }
12959
+
12960
+ utils.catchup(property.range[0], state);
12961
+
12962
+ // skip ...
12963
+ utils.move(property.range[0] + 3, state);
12964
+
12965
+ traverse(property.argument, path, state);
12966
+
12967
+ utils.catchup(property.range[1], state);
12968
+
12969
+ previousWasSpread = true;
12666
12970
 
12667
- if (script.src) {
12668
- load(script.src, function(content, url) {
12669
- result[i] = {
12670
- executed: false,
12671
- content: content,
12672
- url: url,
12673
- options: options
12674
- };
12675
- check();
12676
- });
12677
12971
  } else {
12678
- result[i] = {
12679
- executed: false,
12680
- content: script.innerHTML,
12681
- url: null,
12682
- options: options
12683
- };
12684
- check();
12685
- }
12686
- });
12687
- }
12688
12972
 
12689
- /**
12690
- * Find and run all script tags with type="text/jsx".
12691
- *
12692
- * @internal
12693
- */
12694
- function runScripts() {
12695
- var scripts = document.getElementsByTagName('script');
12973
+ utils.catchup(property.range[0], state);
12974
+
12975
+ if (previousWasSpread) {
12976
+ utils.append('{', state);
12977
+ }
12978
+
12979
+ traverse(property, path, state);
12980
+
12981
+ utils.catchup(property.range[1], state);
12982
+
12983
+ previousWasSpread = false;
12696
12984
 
12697
- // Array.prototype.slice cannot be used on NodeList on IE8
12698
- var jsxScripts = [];
12699
- for (var i = 0; i < scripts.length; i++) {
12700
- if (scripts.item(i).type.indexOf('text/jsx') !== -1) {
12701
- jsxScripts.push(scripts.item(i));
12702
12985
  }
12703
12986
  }
12704
12987
 
12705
- console.warn(
12706
- 'You are using the in-browser JSX transformer. Be sure to precompile ' +
12707
- 'your JSX for production - ' +
12708
- 'http://facebook.github.io/react/docs/tooling-integration.html#jsx'
12709
- );
12710
-
12711
- loadScripts(jsxScripts);
12712
- }
12988
+ utils.catchup(node.range[1] - 1, state);
12713
12989
 
12714
- // Listen for load event if we're in a browser and then kick off finding and
12715
- // running of scripts.
12716
- if (typeof window !== "undefined" && window !== null) {
12717
- headEl = document.getElementsByTagName('head')[0];
12718
- dummyAnchor = document.createElement('a');
12990
+ // Skip the trailing }
12991
+ utils.move(node.range[1], state);
12719
12992
 
12720
- if (window.addEventListener) {
12721
- window.addEventListener('DOMContentLoaded', runScripts, false);
12722
- } else {
12723
- window.attachEvent('onload', runScripts);
12993
+ if (!previousWasSpread) {
12994
+ utils.append('}', state);
12724
12995
  }
12996
+
12997
+ utils.append(')', state);
12998
+ return false;
12725
12999
  }
12726
13000
 
12727
- module.exports = {
12728
- transform: transformReact,
12729
- exec: exec
13001
+ visitObjectLiteralSpread.test = function(node, path, state) {
13002
+ if (node.type !== Syntax.ObjectExpression) {
13003
+ return false;
13004
+ }
13005
+ // Tight loop optimization
13006
+ var hasAtLeastOneSpreadProperty = false;
13007
+ for (var i = 0; i < node.properties.length; i++) {
13008
+ var property = node.properties[i];
13009
+ if (property.type === Syntax.SpreadProperty) {
13010
+ hasAtLeastOneSpreadProperty = true;
13011
+ } else if (property.kind !== 'init') {
13012
+ return false;
13013
+ }
13014
+ }
13015
+ return hasAtLeastOneSpreadProperty;
12730
13016
  };
12731
13017
 
12732
- },{"./fbtransform/visitors":32,"buffer":2,"jstransform":19,"jstransform/src/docblock":18}],29:[function(_dereq_,module,exports){
13018
+ exports.visitorList = [
13019
+ visitObjectLiteralSpread
13020
+ ];
13021
+
13022
+ },{"../src/utils":22,"esprima-fb":8}],32:[function(_dereq_,module,exports){
12733
13023
  /**
12734
- * Copyright 2013-2014 Facebook, Inc.
13024
+ * Copyright 2014 Facebook, Inc.
12735
13025
  *
12736
13026
  * Licensed under the Apache License, Version 2.0 (the "License");
12737
13027
  * you may not use this file except in compliance with the License.
@@ -12745,6 +13035,121 @@ module.exports = {
12745
13035
  * See the License for the specific language governing permissions and
12746
13036
  * limitations under the License.
12747
13037
  */
13038
+
13039
+ var KEYWORDS = [
13040
+ 'break', 'do', 'in', 'typeof', 'case', 'else', 'instanceof', 'var', 'catch',
13041
+ 'export', 'new', 'void', 'class', 'extends', 'return', 'while', 'const',
13042
+ 'finally', 'super', 'with', 'continue', 'for', 'switch', 'yield', 'debugger',
13043
+ 'function', 'this', 'default', 'if', 'throw', 'delete', 'import', 'try'
13044
+ ];
13045
+
13046
+ var FUTURE_RESERVED_WORDS = [
13047
+ 'enum', 'await', 'implements', 'package', 'protected', 'static', 'interface',
13048
+ 'private', 'public'
13049
+ ];
13050
+
13051
+ var LITERALS = [
13052
+ 'null',
13053
+ 'true',
13054
+ 'false'
13055
+ ];
13056
+
13057
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words
13058
+ var RESERVED_WORDS = [].concat(
13059
+ KEYWORDS,
13060
+ FUTURE_RESERVED_WORDS,
13061
+ LITERALS
13062
+ );
13063
+
13064
+ var reservedWordsMap = {};
13065
+ RESERVED_WORDS.forEach(function(k) {
13066
+ reservedWordsMap[k] = true;
13067
+ });
13068
+
13069
+ exports.isReservedWord = function(word) {
13070
+ return !!reservedWordsMap[word];
13071
+ };
13072
+
13073
+ },{}],33:[function(_dereq_,module,exports){
13074
+ var esprima = _dereq_('esprima-fb');
13075
+ var utils = _dereq_('jstransform/src/utils');
13076
+
13077
+ var Syntax = esprima.Syntax;
13078
+
13079
+ function _isFunctionNode(node) {
13080
+ return node.type === Syntax.FunctionDeclaration
13081
+ || node.type === Syntax.FunctionExpression
13082
+ || node.type === Syntax.ArrowFunctionExpression;
13083
+ }
13084
+
13085
+ function visitClassProperty(traverse, node, path, state) {
13086
+ utils.catchupWhiteOut(node.range[1], state);
13087
+ return false;
13088
+ }
13089
+ visitClassProperty.test = function(node, path, state) {
13090
+ return node.type === Syntax.ClassProperty;
13091
+ };
13092
+
13093
+ function visitFunctionParametricAnnotation(traverse, node, path, state) {
13094
+ utils.catchupWhiteOut(node.range[1], state);
13095
+ return false;
13096
+ }
13097
+ visitFunctionParametricAnnotation.test = function(node, path, state) {
13098
+ return node.type === Syntax.ParametricTypeAnnotation
13099
+ && path[0]
13100
+ && _isFunctionNode(path[0])
13101
+ && node === path[0].parametricType;
13102
+ };
13103
+
13104
+ function visitFunctionReturnAnnotation(traverse, node, path, state) {
13105
+ utils.catchupWhiteOut(node.range[1], state);
13106
+ return false;
13107
+ }
13108
+ visitFunctionReturnAnnotation.test = function(node, path, state) {
13109
+ return path[0] && _isFunctionNode(path[0]) && node === path[0].returnType;
13110
+ };
13111
+
13112
+ function visitOptionalFunctionParameterAnnotation(traverse, node, path, state) {
13113
+ path.unshift(node);
13114
+ traverse(node.id, path, state);
13115
+ path.shift();
13116
+ utils.catchup(node.id.range[1], state);
13117
+ utils.catchupWhiteOut(node.range[1], state);
13118
+ return false;
13119
+ }
13120
+ visitOptionalFunctionParameterAnnotation.test = function(node, path, state) {
13121
+ return node.type === Syntax.OptionalParameter
13122
+ && path[0]
13123
+ && _isFunctionNode(path[0]);
13124
+ };
13125
+
13126
+ function visitTypeAnnotatedIdentifier(traverse, node, path, state) {
13127
+ traverse(node.id, path, state);
13128
+ utils.catchup(node.id.range[1], state);
13129
+ utils.catchupWhiteOut(node.range[1], state);
13130
+ return false;
13131
+ }
13132
+ visitTypeAnnotatedIdentifier.test = function(node, path, state) {
13133
+ return node.type === Syntax.TypeAnnotatedIdentifier;
13134
+ };
13135
+
13136
+ exports.visitorList = [
13137
+ visitClassProperty,
13138
+ visitFunctionParametricAnnotation,
13139
+ visitFunctionReturnAnnotation,
13140
+ visitOptionalFunctionParameterAnnotation,
13141
+ visitTypeAnnotatedIdentifier
13142
+ ];
13143
+
13144
+ },{"esprima-fb":8,"jstransform/src/utils":22}],34:[function(_dereq_,module,exports){
13145
+ /**
13146
+ * Copyright 2013-2014, Facebook, Inc.
13147
+ * All rights reserved.
13148
+ *
13149
+ * This source code is licensed under the BSD-style license found in the
13150
+ * LICENSE file in the root directory of this source tree. An additional grant
13151
+ * of patent rights can be found in the PATENTS file in the same directory.
13152
+ */
12748
13153
  /*global exports:true*/
12749
13154
  "use strict";
12750
13155
 
@@ -12760,27 +13165,16 @@ var quoteAttrName = _dereq_('./xjs').quoteAttrName;
12760
13165
  var trimLeft = _dereq_('./xjs').trimLeft;
12761
13166
 
12762
13167
  /**
12763
- * Customized desugar processor.
13168
+ * Customized desugar processor for React JSX. Currently:
12764
13169
  *
12765
- * Currently: (Somewhat tailored to React)
12766
- * <X> </X> => X(null, null)
12767
- * <X prop="1" /> => X({prop: '1'}, null)
12768
- * <X prop="2"><Y /></X> => X({prop:'2'}, Y(null, null))
12769
- * <X prop="2"><Y /><Z /></X> => X({prop:'2'}, [Y(null, null), Z(null, null)])
12770
- *
12771
- * Exceptions to the simple rules above:
12772
- * if a property is named "class" it will be changed to "className" in the
12773
- * javascript since "class" is not a valid object key in javascript.
13170
+ * <X> </X> => React.createElement(X, null)
13171
+ * <X prop="1" /> => React.createElement(X, {prop: '1'}, null)
13172
+ * <X prop="2"><Y /></X> => React.createElement(X, {prop:'2'},
13173
+ * React.createElement(Y, null)
13174
+ * )
13175
+ * <div /> => React.createElement("div", null)
12774
13176
  */
12775
13177
 
12776
- var JSX_ATTRIBUTE_TRANSFORMS = {
12777
- cxName: function(attr) {
12778
- throw new Error(
12779
- "cxName is no longer supported, use className={cx(...)} instead"
12780
- );
12781
- }
12782
- };
12783
-
12784
13178
  /**
12785
13179
  * Removes all non-whitespace/parenthesis characters
12786
13180
  */
@@ -12789,8 +13183,12 @@ function stripNonWhiteParen(value) {
12789
13183
  return value.replace(reNonWhiteParen, '');
12790
13184
  }
12791
13185
 
13186
+ var tagConvention = /^[a-z]|\-/;
13187
+ function isTagName(name) {
13188
+ return tagConvention.test(name);
13189
+ }
13190
+
12792
13191
  function visitReactTag(traverse, object, path, state) {
12793
- var jsxObjIdent = utils.getDocblock(state).jsx;
12794
13192
  var openingElement = object.openingElement;
12795
13193
  var nameObject = openingElement.name;
12796
13194
  var attributesObject = openingElement.attributes;
@@ -12801,44 +13199,31 @@ function visitReactTag(traverse, object, path, state) {
12801
13199
  throw new Error('Namespace tags are not supported. ReactJSX is not XML.');
12802
13200
  }
12803
13201
 
12804
- // Only identifiers can be fallback tags or need quoting. We don't need to
12805
- // handle quoting for other types.
12806
- var didAddTag = false;
12807
-
12808
- // Only identifiers can be fallback tags. XJSMemberExpressions are not.
12809
- if (nameObject.type === Syntax.XJSIdentifier) {
12810
- var tagName = nameObject.name;
12811
- var quotedTagName = quoteAttrName(tagName);
12812
-
12813
- if (FALLBACK_TAGS.hasOwnProperty(tagName)) {
12814
- // "Properly" handle invalid identifiers, like <font-face>, which needs to
12815
- // be enclosed in quotes.
12816
- var predicate =
12817
- tagName === quotedTagName ?
12818
- ('.' + tagName) :
12819
- ('[' + quotedTagName + ']');
12820
- utils.append(jsxObjIdent + predicate, state);
12821
- utils.move(nameObject.range[1], state);
12822
- didAddTag = true;
12823
- } else if (tagName !== quotedTagName) {
12824
- // If we're in the case where we need to quote and but don't recognize the
12825
- // tag, throw.
13202
+ // We assume that the React runtime is already in scope
13203
+ utils.append('React.createElement(', state);
13204
+
13205
+ // Identifiers with lower case or hypthens are fallback tags (strings).
13206
+ // XJSMemberExpressions are not.
13207
+ if (nameObject.type === Syntax.XJSIdentifier && isTagName(nameObject.name)) {
13208
+ // This is a temporary error message to assist upgrades
13209
+ if (!FALLBACK_TAGS.hasOwnProperty(nameObject.name)) {
12826
13210
  throw new Error(
12827
- 'Tags must be valid JS identifiers or a recognized special case. `<' +
12828
- tagName + '>` is not one of them.'
13211
+ 'Lower case component names (' + nameObject.name + ') are no longer ' +
13212
+ 'supported in JSX: See http://fb.me/react-jsx-lower-case'
12829
13213
  );
12830
13214
  }
12831
- }
12832
13215
 
12833
- // Use utils.catchup in this case so we can easily handle XJSMemberExpressions
12834
- // which look like Foo.Bar.Baz. This also handles unhyphenated XJSIdentifiers
12835
- // that aren't fallback tags.
12836
- if (!didAddTag) {
13216
+ utils.append('"' + nameObject.name + '"', state);
13217
+ utils.move(nameObject.range[1], state);
13218
+ } else {
13219
+ // Use utils.catchup in this case so we can easily handle
13220
+ // XJSMemberExpressions which look like Foo.Bar.Baz. This also handles
13221
+ // XJSIdentifiers that aren't fallback tags.
12837
13222
  utils.move(nameObject.range[0], state);
12838
13223
  utils.catchup(nameObject.range[1], state);
12839
13224
  }
12840
13225
 
12841
- utils.append('(', state);
13226
+ utils.append(', ', state);
12842
13227
 
12843
13228
  var hasAttributes = attributesObject.length;
12844
13229
 
@@ -12848,7 +13233,7 @@ function visitReactTag(traverse, object, path, state) {
12848
13233
 
12849
13234
  // if we don't have any attributes, pass in null
12850
13235
  if (hasAtLeastOneSpreadProperty) {
12851
- utils.append('Object.assign({', state);
13236
+ utils.append('React.__spread({', state);
12852
13237
  } else if (hasAttributes) {
12853
13238
  utils.append('{', state);
12854
13239
  } else {
@@ -12863,9 +13248,6 @@ function visitReactTag(traverse, object, path, state) {
12863
13248
  var isLast = index === attributesObject.length - 1;
12864
13249
 
12865
13250
  if (attr.type === Syntax.XJSSpreadAttribute) {
12866
- // Plus 1 to skip `{`.
12867
- utils.move(attr.range[0] + 1, state);
12868
-
12869
13251
  // Close the previous object or initial object
12870
13252
  if (!previousWasSpread) {
12871
13253
  utils.append('}, ', state);
@@ -12873,6 +13255,9 @@ function visitReactTag(traverse, object, path, state) {
12873
13255
 
12874
13256
  // Move to the expression start, ignoring everything except parenthesis
12875
13257
  // and whitespace.
13258
+ utils.catchup(attr.range[0], state, stripNonWhiteParen);
13259
+ // Plus 1 to skip `{`.
13260
+ utils.move(attr.range[0] + 1, state);
12876
13261
  utils.catchup(attr.argument.range[0], state, stripNonWhiteParen);
12877
13262
 
12878
13263
  traverse(attr.argument, path, state);
@@ -12923,13 +13308,7 @@ function visitReactTag(traverse, object, path, state) {
12923
13308
  utils.move(attr.name.range[1], state);
12924
13309
  // Use catchupNewlines to skip over the '=' in the attribute
12925
13310
  utils.catchupNewlines(attr.value.range[0], state);
12926
- if (JSX_ATTRIBUTE_TRANSFORMS.hasOwnProperty(attr.name.name)) {
12927
- utils.append(JSX_ATTRIBUTE_TRANSFORMS[attr.name.name](attr), state);
12928
- utils.move(attr.value.range[1], state);
12929
- if (!isLast) {
12930
- utils.append(', ', state);
12931
- }
12932
- } else if (attr.value.type === Syntax.Literal) {
13311
+ if (attr.value.type === Syntax.Literal) {
12933
13312
  renderXJSLiteral(attr.value, isLast, state);
12934
13313
  } else {
12935
13314
  renderXJSExpressionContainer(traverse, attr.value, isLast, path, state);
@@ -13010,30 +13389,21 @@ function visitReactTag(traverse, object, path, state) {
13010
13389
  }
13011
13390
 
13012
13391
  visitReactTag.test = function(object, path, state) {
13013
- // only run react when react @jsx namespace is specified in docblock
13014
- var jsx = utils.getDocblock(state).jsx;
13015
- return object.type === Syntax.XJSElement && jsx && jsx.length;
13392
+ return object.type === Syntax.XJSElement;
13016
13393
  };
13017
13394
 
13018
13395
  exports.visitorList = [
13019
13396
  visitReactTag
13020
13397
  ];
13021
13398
 
13022
- },{"./xjs":31,"esprima-fb":7,"jstransform/src/utils":20}],30:[function(_dereq_,module,exports){
13399
+ },{"./xjs":36,"esprima-fb":8,"jstransform/src/utils":22}],35:[function(_dereq_,module,exports){
13023
13400
  /**
13024
- * Copyright 2013-2014 Facebook, Inc.
13025
- *
13026
- * Licensed under the Apache License, Version 2.0 (the "License");
13027
- * you may not use this file except in compliance with the License.
13028
- * You may obtain a copy of the License at
13401
+ * Copyright 2013-2014, Facebook, Inc.
13402
+ * All rights reserved.
13029
13403
  *
13030
- * http://www.apache.org/licenses/LICENSE-2.0
13031
- *
13032
- * Unless required by applicable law or agreed to in writing, software
13033
- * distributed under the License is distributed on an "AS IS" BASIS,
13034
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13035
- * See the License for the specific language governing permissions and
13036
- * limitations under the License.
13404
+ * This source code is licensed under the BSD-style license found in the
13405
+ * LICENSE file in the root directory of this source tree. An additional grant
13406
+ * of patent rights can be found in the PATENTS file in the same directory.
13037
13407
  */
13038
13408
  /*global exports:true*/
13039
13409
  "use strict";
@@ -13109,40 +13479,26 @@ function visitReactDisplayName(traverse, object, path, state) {
13109
13479
  }
13110
13480
  }
13111
13481
 
13112
- /**
13113
- * Will only run on @jsx files for now.
13114
- */
13115
13482
  visitReactDisplayName.test = function(object, path, state) {
13116
- if (utils.getDocblock(state).jsx) {
13117
- return (
13118
- object.type === Syntax.AssignmentExpression ||
13119
- object.type === Syntax.Property ||
13120
- object.type === Syntax.VariableDeclarator
13121
- );
13122
- } else {
13123
- return false;
13124
- }
13483
+ return (
13484
+ object.type === Syntax.AssignmentExpression ||
13485
+ object.type === Syntax.Property ||
13486
+ object.type === Syntax.VariableDeclarator
13487
+ );
13125
13488
  };
13126
13489
 
13127
13490
  exports.visitorList = [
13128
13491
  visitReactDisplayName
13129
13492
  ];
13130
13493
 
13131
- },{"esprima-fb":7,"jstransform/src/utils":20}],31:[function(_dereq_,module,exports){
13494
+ },{"esprima-fb":8,"jstransform/src/utils":22}],36:[function(_dereq_,module,exports){
13132
13495
  /**
13133
- * Copyright 2013-2014 Facebook, Inc.
13134
- *
13135
- * Licensed under the Apache License, Version 2.0 (the "License");
13136
- * you may not use this file except in compliance with the License.
13137
- * You may obtain a copy of the License at
13138
- *
13139
- * http://www.apache.org/licenses/LICENSE-2.0
13496
+ * Copyright 2013-2014, Facebook, Inc.
13497
+ * All rights reserved.
13140
13498
  *
13141
- * Unless required by applicable law or agreed to in writing, software
13142
- * distributed under the License is distributed on an "AS IS" BASIS,
13143
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13144
- * See the License for the specific language governing permissions and
13145
- * limitations under the License.
13499
+ * This source code is licensed under the BSD-style license found in the
13500
+ * LICENSE file in the root directory of this source tree. An additional grant
13501
+ * of patent rights can be found in the PATENTS file in the same directory.
13146
13502
  */
13147
13503
  /*global exports:true*/
13148
13504
  "use strict";
@@ -13239,6 +13595,7 @@ var knownTags = {
13239
13595
  param: true,
13240
13596
  path: true,
13241
13597
  pattern: false,
13598
+ picture: true,
13242
13599
  polygon: true,
13243
13600
  polyline: true,
13244
13601
  pre: true,
@@ -13383,16 +13740,19 @@ exports.renderXJSLiteral = renderXJSLiteral;
13383
13740
  exports.quoteAttrName = quoteAttrName;
13384
13741
  exports.trimLeft = trimLeft;
13385
13742
 
13386
- },{"esprima-fb":7,"jstransform/src/utils":20}],32:[function(_dereq_,module,exports){
13743
+ },{"esprima-fb":8,"jstransform/src/utils":22}],37:[function(_dereq_,module,exports){
13387
13744
  /*global exports:true*/
13388
13745
  var es6ArrowFunctions = _dereq_('jstransform/visitors/es6-arrow-function-visitors');
13389
13746
  var es6Classes = _dereq_('jstransform/visitors/es6-class-visitors');
13747
+ var es6Destructuring = _dereq_('jstransform/visitors/es6-destructuring-visitors');
13390
13748
  var es6ObjectConciseMethod = _dereq_('jstransform/visitors/es6-object-concise-method-visitors');
13391
13749
  var es6ObjectShortNotation = _dereq_('jstransform/visitors/es6-object-short-notation-visitors');
13392
13750
  var es6RestParameters = _dereq_('jstransform/visitors/es6-rest-param-visitors');
13393
13751
  var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors');
13752
+ var es7SpreadProperty = _dereq_('jstransform/visitors/es7-spread-property-visitors');
13394
13753
  var react = _dereq_('./transforms/react');
13395
13754
  var reactDisplayName = _dereq_('./transforms/reactDisplayName');
13755
+ var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
13396
13756
 
13397
13757
  /**
13398
13758
  * Map from transformName => orderedListOfVisitors.
@@ -13400,23 +13760,48 @@ var reactDisplayName = _dereq_('./transforms/reactDisplayName');
13400
13760
  var transformVisitors = {
13401
13761
  'es6-arrow-functions': es6ArrowFunctions.visitorList,
13402
13762
  'es6-classes': es6Classes.visitorList,
13763
+ 'es6-destructuring': es6Destructuring.visitorList,
13403
13764
  'es6-object-concise-method': es6ObjectConciseMethod.visitorList,
13404
13765
  'es6-object-short-notation': es6ObjectShortNotation.visitorList,
13405
13766
  'es6-rest-params': es6RestParameters.visitorList,
13406
13767
  'es6-templates': es6Templates.visitorList,
13407
- 'react': react.visitorList.concat(reactDisplayName.visitorList)
13768
+ 'es7-spread-property': es7SpreadProperty.visitorList,
13769
+ 'react': react.visitorList.concat(reactDisplayName.visitorList),
13770
+ 'types': typesSyntax.visitorList
13771
+ };
13772
+
13773
+ var transformSets = {
13774
+ 'harmony': [
13775
+ 'es6-arrow-functions',
13776
+ 'es6-object-concise-method',
13777
+ 'es6-object-short-notation',
13778
+ 'es6-classes',
13779
+ 'es6-rest-params',
13780
+ 'es6-templates',
13781
+ 'es6-destructuring',
13782
+ 'es7-spread-property'
13783
+ ],
13784
+ 'react': [
13785
+ 'react'
13786
+ ],
13787
+ 'type-annotations': [
13788
+ 'types'
13789
+ ]
13408
13790
  };
13409
13791
 
13410
13792
  /**
13411
13793
  * Specifies the order in which each transform should run.
13412
13794
  */
13413
13795
  var transformRunOrder = [
13796
+ 'types',
13414
13797
  'es6-arrow-functions',
13415
13798
  'es6-object-concise-method',
13416
13799
  'es6-object-short-notation',
13417
13800
  'es6-classes',
13418
13801
  'es6-rest-params',
13419
13802
  'es6-templates',
13803
+ 'es6-destructuring',
13804
+ 'es7-spread-property',
13420
13805
  'react'
13421
13806
  ];
13422
13807
 
@@ -13437,9 +13822,37 @@ function getAllVisitors(excludes) {
13437
13822
  return ret;
13438
13823
  }
13439
13824
 
13825
+ /**
13826
+ * Given a list of visitor set names, return the ordered list of visitors to be
13827
+ * passed to jstransform.
13828
+ *
13829
+ * @param {array}
13830
+ * @return {array}
13831
+ */
13832
+ function getVisitorsBySet(sets) {
13833
+ var visitorsToInclude = sets.reduce(function(visitors, set) {
13834
+ if (!transformSets.hasOwnProperty(set)) {
13835
+ throw new Error('Unknown visitor set: ' + set);
13836
+ }
13837
+ transformSets[set].forEach(function(visitor) {
13838
+ visitors[visitor] = true;
13839
+ });
13840
+ return visitors;
13841
+ }, {});
13842
+
13843
+ var visitorList = [];
13844
+ for (var i = 0; i < transformRunOrder.length; i++) {
13845
+ if (visitorsToInclude.hasOwnProperty(transformRunOrder[i])) {
13846
+ visitorList = visitorList.concat(transformVisitors[transformRunOrder[i]]);
13847
+ }
13848
+ }
13849
+
13850
+ return visitorList;
13851
+ }
13852
+
13853
+ exports.getVisitorsBySet = getVisitorsBySet;
13440
13854
  exports.getAllVisitors = getAllVisitors;
13441
13855
  exports.transformVisitors = transformVisitors;
13442
13856
 
13443
- },{"./transforms/react":29,"./transforms/reactDisplayName":30,"jstransform/visitors/es6-arrow-function-visitors":21,"jstransform/visitors/es6-class-visitors":22,"jstransform/visitors/es6-object-concise-method-visitors":24,"jstransform/visitors/es6-object-short-notation-visitors":25,"jstransform/visitors/es6-rest-param-visitors":26,"jstransform/visitors/es6-template-visitors":27}]},{},[28])
13444
- (28)
13857
+ },{"./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,"jstransform/visitors/type-syntax":33}]},{},[1])(1)
13445
13858
  });