react 0.11.0 → 0.12.0
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.
- package/dist/JSXTransformer.js +1373 -963
- package/dist/react-with-addons.js +3151 -3585
- package/dist/react-with-addons.min.js +11 -17
- package/dist/react.js +2960 -3308
- package/dist/react.min.js +11 -16
- package/lib/AutoFocusMixin.js +5 -12
- package/lib/BeforeInputEventPlugin.js +12 -14
- package/lib/CSSCore.js +6 -13
- package/lib/CSSProperty.js +5 -12
- package/lib/CSSPropertyOperations.js +46 -12
- package/lib/CallbackQueue.js +7 -14
- package/lib/ChangeEventPlugin.js +5 -12
- package/lib/ClientReactRootIndex.js +5 -12
- package/lib/CompositionEventPlugin.js +5 -12
- package/lib/DOMChildrenOperations.js +8 -15
- package/lib/DOMProperty.js +16 -19
- package/lib/DOMPropertyOperations.js +14 -14
- package/lib/Danger.js +12 -17
- package/lib/DefaultEventPluginOrder.js +5 -12
- package/lib/EnterLeaveEventPlugin.js +5 -12
- package/lib/EventConstants.js +5 -12
- package/lib/EventListener.js +14 -0
- package/lib/EventPluginHub.js +8 -26
- package/lib/EventPluginRegistry.js +5 -12
- package/lib/EventPluginUtils.js +5 -12
- package/lib/EventPropagators.js +12 -17
- package/lib/ExecutionEnvironment.js +5 -12
- package/lib/HTMLDOMPropertyConfig.js +14 -16
- package/lib/LinkedStateMixin.js +5 -12
- package/lib/LinkedValueUtils.js +5 -12
- package/lib/LocalEventTrapMixin.js +8 -14
- package/lib/MobileSafariClickEventPlugin.js +5 -12
- package/lib/Object.assign.js +45 -0
- package/lib/PooledClass.js +5 -12
- package/lib/React.js +91 -38
- package/lib/ReactBrowserComponentMixin.js +5 -12
- package/lib/ReactBrowserEventEmitter.js +7 -14
- package/lib/ReactCSSTransitionGroup.js +15 -17
- package/lib/ReactCSSTransitionGroupChild.js +9 -13
- package/lib/ReactChildren.js +5 -12
- package/lib/ReactComponent.js +61 -68
- package/lib/ReactComponentBrowserEnvironment.js +5 -12
- package/lib/ReactComponentWithPureRenderMixin.js +5 -12
- package/lib/ReactCompositeComponent.js +199 -180
- package/lib/ReactContext.js +8 -15
- package/lib/ReactCurrentOwner.js +5 -12
- package/lib/ReactDOM.js +145 -175
- package/lib/ReactDOMButton.js +8 -14
- package/lib/ReactDOMComponent.js +103 -38
- package/lib/ReactDOMForm.js +9 -15
- package/lib/ReactDOMIDOperations.js +5 -12
- package/lib/ReactDOMImg.js +8 -14
- package/lib/ReactDOMInput.js +30 -38
- package/lib/ReactDOMOption.js +8 -14
- package/lib/ReactDOMSelect.js +25 -24
- package/lib/ReactDOMSelection.js +11 -18
- package/lib/ReactDOMTextarea.js +19 -24
- package/lib/ReactDefaultBatchingStrategy.js +14 -18
- package/lib/ReactDefaultInjection.js +23 -26
- package/lib/ReactDefaultPerf.js +13 -16
- package/lib/ReactDefaultPerfAnalysis.js +18 -17
- package/lib/ReactElement.js +242 -0
- package/lib/{ReactDescriptorValidator.js → ReactElementValidator.js} +48 -65
- package/lib/ReactEmptyComponent.js +8 -13
- package/lib/ReactErrorUtils.js +5 -12
- package/lib/ReactEventEmitterMixin.js +5 -12
- package/lib/ReactEventListener.js +7 -14
- package/lib/ReactInjection.js +7 -14
- package/lib/ReactInputSelection.js +5 -12
- package/lib/ReactInstanceHandles.js +5 -12
- package/lib/ReactLegacyElement.js +243 -0
- package/lib/ReactLink.js +5 -12
- package/lib/ReactMarkupChecksum.js +5 -12
- package/lib/ReactMount.js +45 -32
- package/lib/ReactMultiChild.js +14 -18
- package/lib/ReactMultiChildUpdateTypes.js +5 -12
- package/lib/ReactNativeComponent.js +69 -0
- package/lib/ReactOwner.js +5 -12
- package/lib/ReactPerf.js +8 -13
- package/lib/ReactPropTransferer.js +34 -33
- package/lib/ReactPropTypeLocationNames.js +5 -12
- package/lib/ReactPropTypeLocations.js +5 -12
- package/lib/ReactPropTypes.js +38 -29
- package/lib/ReactPutListenerQueue.js +7 -14
- package/lib/ReactReconcileTransaction.js +7 -15
- package/lib/ReactRootIndex.js +5 -12
- package/lib/ReactServerRendering.js +21 -34
- package/lib/ReactServerRenderingTransaction.js +11 -15
- package/lib/ReactStateSetters.js +5 -12
- package/lib/ReactTestUtils.js +31 -33
- package/lib/ReactTextComponent.js +18 -21
- package/lib/ReactTransitionChildMapping.js +6 -13
- package/lib/ReactTransitionEvents.js +5 -12
- package/lib/ReactTransitionGroup.js +14 -17
- package/lib/ReactUpdates.js +43 -22
- package/lib/ReactWithAddons.js +7 -13
- package/lib/SVGDOMPropertyConfig.js +5 -12
- package/lib/SelectEventPlugin.js +13 -20
- package/lib/ServerReactRootIndex.js +5 -12
- package/lib/SimpleEventPlugin.js +20 -15
- package/lib/SyntheticClipboardEvent.js +5 -12
- package/lib/SyntheticCompositionEvent.js +5 -12
- package/lib/SyntheticDragEvent.js +5 -12
- package/lib/SyntheticEvent.js +9 -17
- package/lib/SyntheticFocusEvent.js +5 -12
- package/lib/SyntheticInputEvent.js +4 -11
- package/lib/SyntheticKeyboardEvent.js +17 -19
- package/lib/SyntheticMouseEvent.js +6 -13
- package/lib/SyntheticTouchEvent.js +5 -12
- package/lib/SyntheticUIEvent.js +5 -12
- package/lib/SyntheticWheelEvent.js +5 -12
- package/lib/Transaction.js +5 -12
- package/lib/ViewportMetrics.js +5 -12
- package/lib/accumulateInto.js +62 -0
- package/lib/adler32.js +6 -13
- package/lib/camelize.js +30 -0
- package/lib/camelizeStyleName.js +40 -0
- package/lib/cloneWithProps.js +9 -15
- package/lib/containsNode.js +5 -12
- package/lib/copyProperties.js +12 -12
- package/lib/createArrayFrom.js +5 -12
- package/lib/createFullPageComponent.js +12 -18
- package/lib/createNodesFromMarkup.js +5 -12
- package/lib/cx.js +5 -12
- package/lib/dangerousStyleValue.js +5 -12
- package/lib/deprecated.js +47 -0
- package/lib/emptyFunction.js +11 -22
- package/lib/emptyObject.js +5 -12
- package/lib/escapeTextForBrowser.js +5 -12
- package/lib/flattenChildren.js +19 -13
- package/lib/focusNode.js +10 -16
- package/lib/forEachAccumulated.js +5 -12
- package/lib/getActiveElement.js +5 -12
- package/lib/getEventCharCode.js +50 -0
- package/lib/getEventKey.js +9 -21
- package/lib/getEventModifierState.js +10 -17
- package/lib/getEventTarget.js +5 -12
- package/lib/getMarkupWrap.js +5 -12
- package/lib/getNodeForCharacterOffset.js +5 -12
- package/lib/getReactRootElementInContainer.js +5 -12
- package/lib/getTextContentAccessor.js +5 -12
- package/lib/getUnboundedScrollPosition.js +5 -12
- package/lib/hyphenate.js +5 -12
- package/lib/hyphenateStyleName.js +8 -15
- package/lib/instantiateReactComponent.js +90 -42
- package/lib/invariant.js +5 -12
- package/lib/isEventSupported.js +5 -12
- package/lib/isNode.js +5 -12
- package/lib/isTextInputElement.js +5 -12
- package/lib/isTextNode.js +5 -12
- package/lib/joinClasses.js +8 -13
- package/lib/keyMirror.js +5 -12
- package/lib/keyOf.js +5 -12
- package/lib/mapObject.js +35 -36
- package/lib/memoizeStringOnly.js +5 -12
- package/lib/merge.js +14 -17
- package/lib/mergeInto.js +13 -35
- package/lib/monitorCodeUse.js +5 -12
- package/lib/onlyChild.js +8 -15
- package/lib/performance.js +5 -12
- package/lib/performanceNow.js +5 -12
- package/lib/setInnerHTML.js +19 -20
- package/lib/shallowEqual.js +6 -13
- package/lib/shouldUpdateReactComponent.js +14 -22
- package/lib/toArray.js +5 -12
- package/lib/traverseAllChildren.js +34 -48
- package/lib/update.js +8 -15
- package/lib/warning.js +5 -12
- package/package.json +3 -8
- package/lib/ReactDescriptor.js +0 -251
- package/lib/accumulate.js +0 -54
- package/lib/mergeHelpers.js +0 -147
- package/lib/mixInto.js +0 -34
package/dist/JSXTransformer.js
CHANGED
|
@@ -1,7 +1,336 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* JSXTransformer v0.
|
|
2
|
+
* JSXTransformer v0.12.0
|
|
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);
|
|
4
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSXTransformer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
|
5
|
+
/**
|
|
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.
|
|
12
|
+
*/
|
|
13
|
+
/* jshint browser: true */
|
|
14
|
+
/* jslint evil: true */
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
var buffer = _dereq_('buffer');
|
|
19
|
+
var transform = _dereq_('jstransform').transform;
|
|
20
|
+
var visitors = _dereq_('./fbtransform/visitors');
|
|
21
|
+
|
|
22
|
+
var headEl;
|
|
23
|
+
var dummyAnchor;
|
|
24
|
+
var inlineScriptCount = 0;
|
|
25
|
+
|
|
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__');
|
|
31
|
+
|
|
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
|
+
}
|
|
48
|
+
|
|
49
|
+
return transform(visitorList, source, {
|
|
50
|
+
sourceMap: supportsAccessors && options.sourceMap
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
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
|
+
}
|
|
63
|
+
|
|
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];
|
|
81
|
+
|
|
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
|
+
});
|
|
89
|
+
|
|
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;
|
|
94
|
+
|
|
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
|
+
}
|
|
106
|
+
|
|
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
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!transformed.sourceMap) {
|
|
137
|
+
return transformed.code;
|
|
138
|
+
}
|
|
139
|
+
|
|
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];
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
transformed.code +
|
|
161
|
+
'\n//# sourceMappingURL=data:application/json;base64,' +
|
|
162
|
+
buffer.Buffer(JSON.stringify(map)).toString('base64')
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
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
|
+
}
|
|
181
|
+
|
|
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();
|
|
193
|
+
|
|
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
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
return xhr.send(null);
|
|
211
|
+
}
|
|
212
|
+
|
|
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;
|
|
224
|
+
|
|
225
|
+
function check() {
|
|
226
|
+
var script, i;
|
|
227
|
+
|
|
228
|
+
for (i = 0; i < count; i++) {
|
|
229
|
+
script = result[i];
|
|
230
|
+
|
|
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
|
+
}
|
|
239
|
+
|
|
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
|
+
}
|
|
247
|
+
|
|
248
|
+
// script.async is always true for non-javascript script tags
|
|
249
|
+
var async = script.hasAttribute('async');
|
|
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
|
+
};
|
|
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
|
+
});
|
|
282
|
+
|
|
283
|
+
check();
|
|
284
|
+
}
|
|
285
|
+
|
|
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');
|
|
293
|
+
|
|
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));
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (jsxScripts.length < 1) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
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
|
+
);
|
|
311
|
+
|
|
312
|
+
loadScripts(jsxScripts);
|
|
313
|
+
}
|
|
314
|
+
|
|
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
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
module.exports = {
|
|
329
|
+
transform: transformReact,
|
|
330
|
+
exec: exec
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
},{"./fbtransform/visitors":37,"buffer":2,"jstransform":21}],2:[function(_dereq_,module,exports){
|
|
5
334
|
/*!
|
|
6
335
|
* The buffer module from node.js, for the browser.
|
|
7
336
|
*
|
|
@@ -11,29 +340,45 @@
|
|
|
11
340
|
|
|
12
341
|
var base64 = _dereq_('base64-js')
|
|
13
342
|
var ieee754 = _dereq_('ieee754')
|
|
343
|
+
var isArray = _dereq_('is-array')
|
|
14
344
|
|
|
15
345
|
exports.Buffer = Buffer
|
|
16
346
|
exports.SlowBuffer = Buffer
|
|
17
347
|
exports.INSPECT_MAX_BYTES = 50
|
|
18
|
-
Buffer.poolSize = 8192
|
|
348
|
+
Buffer.poolSize = 8192 // not used by this implementation
|
|
349
|
+
|
|
350
|
+
var kMaxLength = 0x3fffffff
|
|
19
351
|
|
|
20
352
|
/**
|
|
21
|
-
* If `Buffer.
|
|
353
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
22
354
|
* === true Use Uint8Array implementation (fastest)
|
|
23
|
-
* === false Use Object implementation (compatible
|
|
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.
|
|
24
373
|
*/
|
|
25
|
-
Buffer.
|
|
26
|
-
// Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
|
|
27
|
-
// Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
|
|
28
|
-
// properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
|
|
29
|
-
// because we need to be able to add all the node Buffer API methods. This is an issue
|
|
30
|
-
// in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
|
|
374
|
+
Buffer.TYPED_ARRAY_SUPPORT = (function () {
|
|
31
375
|
try {
|
|
32
376
|
var buf = new ArrayBuffer(0)
|
|
33
377
|
var arr = new Uint8Array(buf)
|
|
34
378
|
arr.foo = function () { return 42 }
|
|
35
|
-
return 42 === arr.foo() &&
|
|
36
|
-
typeof arr.subarray === 'function' //
|
|
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`
|
|
37
382
|
} catch (e) {
|
|
38
383
|
return false
|
|
39
384
|
}
|
|
@@ -66,14 +411,18 @@ function Buffer (subject, encoding, noZero) {
|
|
|
66
411
|
subject = base64clean(subject)
|
|
67
412
|
length = Buffer.byteLength(subject, encoding)
|
|
68
413
|
} else if (type === 'object' && subject !== null) { // assume object is array-like
|
|
69
|
-
if (subject.type === 'Buffer' &&
|
|
414
|
+
if (subject.type === 'Buffer' && isArray(subject.data))
|
|
70
415
|
subject = subject.data
|
|
71
416
|
length = +subject.length > 0 ? Math.floor(+subject.length) : 0
|
|
72
417
|
} else
|
|
73
|
-
throw new
|
|
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')
|
|
74
423
|
|
|
75
424
|
var buf
|
|
76
|
-
if (Buffer.
|
|
425
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
77
426
|
// Preferred: Return an augmented `Uint8Array` instance for best performance
|
|
78
427
|
buf = Buffer._augment(new Uint8Array(length))
|
|
79
428
|
} else {
|
|
@@ -84,7 +433,7 @@ function Buffer (subject, encoding, noZero) {
|
|
|
84
433
|
}
|
|
85
434
|
|
|
86
435
|
var i
|
|
87
|
-
if (Buffer.
|
|
436
|
+
if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
|
|
88
437
|
// Speed optimization -- use set if we're copying from a typed array
|
|
89
438
|
buf._set(subject)
|
|
90
439
|
} else if (isArrayish(subject)) {
|
|
@@ -98,7 +447,7 @@ function Buffer (subject, encoding, noZero) {
|
|
|
98
447
|
}
|
|
99
448
|
} else if (type === 'string') {
|
|
100
449
|
buf.write(subject, 0, encoding)
|
|
101
|
-
} else if (type === 'number' && !Buffer.
|
|
450
|
+
} else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
|
|
102
451
|
for (i = 0; i < length; i++) {
|
|
103
452
|
buf[i] = 0
|
|
104
453
|
}
|
|
@@ -107,8 +456,25 @@ function Buffer (subject, encoding, noZero) {
|
|
|
107
456
|
return buf
|
|
108
457
|
}
|
|
109
458
|
|
|
110
|
-
|
|
111
|
-
|
|
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
|
+
}
|
|
112
478
|
|
|
113
479
|
Buffer.isEncoding = function (encoding) {
|
|
114
480
|
switch (String(encoding).toLowerCase()) {
|
|
@@ -129,88 +495,145 @@ Buffer.isEncoding = function (encoding) {
|
|
|
129
495
|
}
|
|
130
496
|
}
|
|
131
497
|
|
|
132
|
-
Buffer.
|
|
133
|
-
|
|
498
|
+
Buffer.concat = function (list, totalLength) {
|
|
499
|
+
if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')
|
|
500
|
+
|
|
501
|
+
if (list.length === 0) {
|
|
502
|
+
return new Buffer(0)
|
|
503
|
+
} else if (list.length === 1) {
|
|
504
|
+
return list[0]
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
var i
|
|
508
|
+
if (totalLength === undefined) {
|
|
509
|
+
totalLength = 0
|
|
510
|
+
for (i = 0; i < list.length; i++) {
|
|
511
|
+
totalLength += list[i].length
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
var buf = new Buffer(totalLength)
|
|
516
|
+
var pos = 0
|
|
517
|
+
for (i = 0; i < list.length; i++) {
|
|
518
|
+
var item = list[i]
|
|
519
|
+
item.copy(buf, pos)
|
|
520
|
+
pos += item.length
|
|
521
|
+
}
|
|
522
|
+
return buf
|
|
134
523
|
}
|
|
135
524
|
|
|
136
525
|
Buffer.byteLength = function (str, encoding) {
|
|
137
526
|
var ret
|
|
138
|
-
str = str
|
|
527
|
+
str = str + ''
|
|
139
528
|
switch (encoding || 'utf8') {
|
|
140
|
-
case 'hex':
|
|
141
|
-
ret = str.length / 2
|
|
142
|
-
break
|
|
143
|
-
case 'utf8':
|
|
144
|
-
case 'utf-8':
|
|
145
|
-
ret = utf8ToBytes(str).length
|
|
146
|
-
break
|
|
147
529
|
case 'ascii':
|
|
148
530
|
case 'binary':
|
|
149
531
|
case 'raw':
|
|
150
532
|
ret = str.length
|
|
151
533
|
break
|
|
152
|
-
case 'base64':
|
|
153
|
-
ret = base64ToBytes(str).length
|
|
154
|
-
break
|
|
155
534
|
case 'ucs2':
|
|
156
535
|
case 'ucs-2':
|
|
157
536
|
case 'utf16le':
|
|
158
537
|
case 'utf-16le':
|
|
159
538
|
ret = str.length * 2
|
|
160
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
|
|
161
550
|
default:
|
|
162
|
-
|
|
551
|
+
ret = str.length
|
|
163
552
|
}
|
|
164
553
|
return ret
|
|
165
554
|
}
|
|
166
555
|
|
|
167
|
-
|
|
168
|
-
|
|
556
|
+
// pre-set for values that may exist in the future
|
|
557
|
+
Buffer.prototype.length = undefined
|
|
558
|
+
Buffer.prototype.parent = undefined
|
|
169
559
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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)
|
|
175
583
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
|
181
601
|
}
|
|
182
602
|
}
|
|
603
|
+
}
|
|
183
604
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var item = list[i]
|
|
188
|
-
item.copy(buf, pos)
|
|
189
|
-
pos += item.length
|
|
190
|
-
}
|
|
191
|
-
return buf
|
|
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
|
|
192
608
|
}
|
|
193
609
|
|
|
194
|
-
Buffer.
|
|
195
|
-
|
|
196
|
-
var
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
y = b[i]
|
|
202
|
-
}
|
|
203
|
-
if (x < y) {
|
|
204
|
-
return -1
|
|
205
|
-
}
|
|
206
|
-
if (y < x) {
|
|
207
|
-
return 1
|
|
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 += ' ... '
|
|
208
617
|
}
|
|
209
|
-
return
|
|
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)
|
|
624
|
+
}
|
|
625
|
+
|
|
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)
|
|
210
630
|
}
|
|
211
631
|
|
|
212
|
-
//
|
|
213
|
-
|
|
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
|
+
}
|
|
214
637
|
|
|
215
638
|
function hexWrite (buf, string, offset, length) {
|
|
216
639
|
offset = Number(offset) || 0
|
|
@@ -226,14 +649,14 @@ function hexWrite (buf, string, offset, length) {
|
|
|
226
649
|
|
|
227
650
|
// must be an even number of digits
|
|
228
651
|
var strLen = string.length
|
|
229
|
-
|
|
652
|
+
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
|
230
653
|
|
|
231
654
|
if (length > strLen / 2) {
|
|
232
655
|
length = strLen / 2
|
|
233
656
|
}
|
|
234
657
|
for (var i = 0; i < length; i++) {
|
|
235
658
|
var byte = parseInt(string.substr(i * 2, 2), 16)
|
|
236
|
-
|
|
659
|
+
if (isNaN(byte)) throw new Error('Invalid hex string')
|
|
237
660
|
buf[offset + i] = byte
|
|
238
661
|
}
|
|
239
662
|
return i
|
|
@@ -315,48 +738,7 @@ Buffer.prototype.write = function (string, offset, length, encoding) {
|
|
|
315
738
|
ret = utf16leWrite(this, string, offset, length)
|
|
316
739
|
break
|
|
317
740
|
default:
|
|
318
|
-
throw new
|
|
319
|
-
}
|
|
320
|
-
return ret
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
Buffer.prototype.toString = function (encoding, start, end) {
|
|
324
|
-
var self = this
|
|
325
|
-
|
|
326
|
-
encoding = String(encoding || 'utf8').toLowerCase()
|
|
327
|
-
start = Number(start) || 0
|
|
328
|
-
end = (end === undefined) ? self.length : Number(end)
|
|
329
|
-
|
|
330
|
-
// Fastpath empty strings
|
|
331
|
-
if (end === start)
|
|
332
|
-
return ''
|
|
333
|
-
|
|
334
|
-
var ret
|
|
335
|
-
switch (encoding) {
|
|
336
|
-
case 'hex':
|
|
337
|
-
ret = hexSlice(self, start, end)
|
|
338
|
-
break
|
|
339
|
-
case 'utf8':
|
|
340
|
-
case 'utf-8':
|
|
341
|
-
ret = utf8Slice(self, start, end)
|
|
342
|
-
break
|
|
343
|
-
case 'ascii':
|
|
344
|
-
ret = asciiSlice(self, start, end)
|
|
345
|
-
break
|
|
346
|
-
case 'binary':
|
|
347
|
-
ret = binarySlice(self, start, end)
|
|
348
|
-
break
|
|
349
|
-
case 'base64':
|
|
350
|
-
ret = base64Slice(self, start, end)
|
|
351
|
-
break
|
|
352
|
-
case 'ucs2':
|
|
353
|
-
case 'ucs-2':
|
|
354
|
-
case 'utf16le':
|
|
355
|
-
case 'utf-16le':
|
|
356
|
-
ret = utf16leSlice(self, start, end)
|
|
357
|
-
break
|
|
358
|
-
default:
|
|
359
|
-
throw new Error('Unknown encoding')
|
|
741
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
|
360
742
|
}
|
|
361
743
|
return ret
|
|
362
744
|
}
|
|
@@ -368,52 +750,6 @@ Buffer.prototype.toJSON = function () {
|
|
|
368
750
|
}
|
|
369
751
|
}
|
|
370
752
|
|
|
371
|
-
Buffer.prototype.equals = function (b) {
|
|
372
|
-
assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
|
|
373
|
-
return Buffer.compare(this, b) === 0
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
Buffer.prototype.compare = function (b) {
|
|
377
|
-
assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
|
|
378
|
-
return Buffer.compare(this, b)
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
382
|
-
Buffer.prototype.copy = function (target, target_start, start, end) {
|
|
383
|
-
var source = this
|
|
384
|
-
|
|
385
|
-
if (!start) start = 0
|
|
386
|
-
if (!end && end !== 0) end = this.length
|
|
387
|
-
if (!target_start) target_start = 0
|
|
388
|
-
|
|
389
|
-
// Copy 0 bytes; we're done
|
|
390
|
-
if (end === start) return
|
|
391
|
-
if (target.length === 0 || source.length === 0) return
|
|
392
|
-
|
|
393
|
-
// Fatal error conditions
|
|
394
|
-
assert(end >= start, 'sourceEnd < sourceStart')
|
|
395
|
-
assert(target_start >= 0 && target_start < target.length,
|
|
396
|
-
'targetStart out of bounds')
|
|
397
|
-
assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
|
|
398
|
-
assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
|
|
399
|
-
|
|
400
|
-
// Are we oob?
|
|
401
|
-
if (end > this.length)
|
|
402
|
-
end = this.length
|
|
403
|
-
if (target.length - target_start < end - start)
|
|
404
|
-
end = target.length - target_start + start
|
|
405
|
-
|
|
406
|
-
var len = end - start
|
|
407
|
-
|
|
408
|
-
if (len < 100 || !Buffer._useTypedArrays) {
|
|
409
|
-
for (var i = 0; i < len; i++) {
|
|
410
|
-
target[i + target_start] = this[i + start]
|
|
411
|
-
}
|
|
412
|
-
} else {
|
|
413
|
-
target._set(this.subarray(start, start + len), target_start)
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
753
|
function base64Slice (buf, start, end) {
|
|
418
754
|
if (start === 0 && end === buf.length) {
|
|
419
755
|
return base64.fromByteArray(buf)
|
|
@@ -499,7 +835,7 @@ Buffer.prototype.slice = function (start, end) {
|
|
|
499
835
|
if (end < start)
|
|
500
836
|
end = start
|
|
501
837
|
|
|
502
|
-
if (Buffer.
|
|
838
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
503
839
|
return Buffer._augment(this.subarray(start, end))
|
|
504
840
|
} else {
|
|
505
841
|
var sliceLen = end - start
|
|
@@ -511,365 +847,275 @@ Buffer.prototype.slice = function (start, end) {
|
|
|
511
847
|
}
|
|
512
848
|
}
|
|
513
849
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
console.log('.set() is deprecated. Access using array indexes instead.')
|
|
523
|
-
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')
|
|
524
858
|
}
|
|
525
859
|
|
|
526
860
|
Buffer.prototype.readUInt8 = function (offset, noAssert) {
|
|
527
|
-
if (!noAssert)
|
|
528
|
-
|
|
529
|
-
assert(offset < this.length, 'Trying to read beyond buffer length')
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
if (offset >= this.length)
|
|
533
|
-
return
|
|
534
|
-
|
|
861
|
+
if (!noAssert)
|
|
862
|
+
checkOffset(offset, 1, this.length)
|
|
535
863
|
return this[offset]
|
|
536
864
|
}
|
|
537
865
|
|
|
538
|
-
function readUInt16 (buf, offset, littleEndian, noAssert) {
|
|
539
|
-
if (!noAssert) {
|
|
540
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
541
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
542
|
-
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
var len = buf.length
|
|
546
|
-
if (offset >= len)
|
|
547
|
-
return
|
|
548
|
-
|
|
549
|
-
var val
|
|
550
|
-
if (littleEndian) {
|
|
551
|
-
val = buf[offset]
|
|
552
|
-
if (offset + 1 < len)
|
|
553
|
-
val |= buf[offset + 1] << 8
|
|
554
|
-
} else {
|
|
555
|
-
val = buf[offset] << 8
|
|
556
|
-
if (offset + 1 < len)
|
|
557
|
-
val |= buf[offset + 1]
|
|
558
|
-
}
|
|
559
|
-
return val
|
|
560
|
-
}
|
|
561
|
-
|
|
562
866
|
Buffer.prototype.readUInt16LE = function (offset, noAssert) {
|
|
563
|
-
|
|
867
|
+
if (!noAssert)
|
|
868
|
+
checkOffset(offset, 2, this.length)
|
|
869
|
+
return this[offset] | (this[offset + 1] << 8)
|
|
564
870
|
}
|
|
565
871
|
|
|
566
872
|
Buffer.prototype.readUInt16BE = function (offset, noAssert) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
function readUInt32 (buf, offset, littleEndian, noAssert) {
|
|
571
|
-
if (!noAssert) {
|
|
572
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
573
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
574
|
-
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
var len = buf.length
|
|
578
|
-
if (offset >= len)
|
|
579
|
-
return
|
|
580
|
-
|
|
581
|
-
var val
|
|
582
|
-
if (littleEndian) {
|
|
583
|
-
if (offset + 2 < len)
|
|
584
|
-
val = buf[offset + 2] << 16
|
|
585
|
-
if (offset + 1 < len)
|
|
586
|
-
val |= buf[offset + 1] << 8
|
|
587
|
-
val |= buf[offset]
|
|
588
|
-
if (offset + 3 < len)
|
|
589
|
-
val = val + (buf[offset + 3] << 24 >>> 0)
|
|
590
|
-
} else {
|
|
591
|
-
if (offset + 1 < len)
|
|
592
|
-
val = buf[offset + 1] << 16
|
|
593
|
-
if (offset + 2 < len)
|
|
594
|
-
val |= buf[offset + 2] << 8
|
|
595
|
-
if (offset + 3 < len)
|
|
596
|
-
val |= buf[offset + 3]
|
|
597
|
-
val = val + (buf[offset] << 24 >>> 0)
|
|
598
|
-
}
|
|
599
|
-
return val
|
|
873
|
+
if (!noAssert)
|
|
874
|
+
checkOffset(offset, 2, this.length)
|
|
875
|
+
return (this[offset] << 8) | this[offset + 1]
|
|
600
876
|
}
|
|
601
877
|
|
|
602
878
|
Buffer.prototype.readUInt32LE = function (offset, noAssert) {
|
|
603
|
-
|
|
604
|
-
|
|
879
|
+
if (!noAssert)
|
|
880
|
+
checkOffset(offset, 4, this.length)
|
|
605
881
|
|
|
606
|
-
|
|
607
|
-
|
|
882
|
+
return ((this[offset]) |
|
|
883
|
+
(this[offset + 1] << 8) |
|
|
884
|
+
(this[offset + 2] << 16)) +
|
|
885
|
+
(this[offset + 3] * 0x1000000)
|
|
608
886
|
}
|
|
609
887
|
|
|
610
|
-
Buffer.prototype.
|
|
611
|
-
if (!noAssert)
|
|
612
|
-
|
|
613
|
-
'missing offset')
|
|
614
|
-
assert(offset < this.length, 'Trying to read beyond buffer length')
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (offset >= this.length)
|
|
618
|
-
return
|
|
888
|
+
Buffer.prototype.readUInt32BE = function (offset, noAssert) {
|
|
889
|
+
if (!noAssert)
|
|
890
|
+
checkOffset(offset, 4, this.length)
|
|
619
891
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
return this[offset]
|
|
892
|
+
return (this[offset] * 0x1000000) +
|
|
893
|
+
((this[offset + 1] << 16) |
|
|
894
|
+
(this[offset + 2] << 8) |
|
|
895
|
+
this[offset + 3])
|
|
625
896
|
}
|
|
626
897
|
|
|
627
|
-
function
|
|
628
|
-
if (!noAssert)
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
var len = buf.length
|
|
635
|
-
if (offset >= len)
|
|
636
|
-
return
|
|
637
|
-
|
|
638
|
-
var val = readUInt16(buf, offset, littleEndian, true)
|
|
639
|
-
var neg = val & 0x8000
|
|
640
|
-
if (neg)
|
|
641
|
-
return (0xffff - val + 1) * -1
|
|
642
|
-
else
|
|
643
|
-
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)
|
|
644
904
|
}
|
|
645
905
|
|
|
646
906
|
Buffer.prototype.readInt16LE = function (offset, noAssert) {
|
|
647
|
-
|
|
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
|
|
648
911
|
}
|
|
649
912
|
|
|
650
913
|
Buffer.prototype.readInt16BE = function (offset, noAssert) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
if (!noAssert) {
|
|
656
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
657
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
658
|
-
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
var len = buf.length
|
|
662
|
-
if (offset >= len)
|
|
663
|
-
return
|
|
664
|
-
|
|
665
|
-
var val = readUInt32(buf, offset, littleEndian, true)
|
|
666
|
-
var neg = val & 0x80000000
|
|
667
|
-
if (neg)
|
|
668
|
-
return (0xffffffff - val + 1) * -1
|
|
669
|
-
else
|
|
670
|
-
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
|
|
671
918
|
}
|
|
672
919
|
|
|
673
920
|
Buffer.prototype.readInt32LE = function (offset, noAssert) {
|
|
674
|
-
|
|
675
|
-
|
|
921
|
+
if (!noAssert)
|
|
922
|
+
checkOffset(offset, 4, this.length)
|
|
676
923
|
|
|
677
|
-
|
|
678
|
-
|
|
924
|
+
return (this[offset]) |
|
|
925
|
+
(this[offset + 1] << 8) |
|
|
926
|
+
(this[offset + 2] << 16) |
|
|
927
|
+
(this[offset + 3] << 24)
|
|
679
928
|
}
|
|
680
929
|
|
|
681
|
-
function
|
|
682
|
-
if (!noAssert)
|
|
683
|
-
|
|
684
|
-
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
685
|
-
}
|
|
930
|
+
Buffer.prototype.readInt32BE = function (offset, noAssert) {
|
|
931
|
+
if (!noAssert)
|
|
932
|
+
checkOffset(offset, 4, this.length)
|
|
686
933
|
|
|
687
|
-
return
|
|
934
|
+
return (this[offset] << 24) |
|
|
935
|
+
(this[offset + 1] << 16) |
|
|
936
|
+
(this[offset + 2] << 8) |
|
|
937
|
+
(this[offset + 3])
|
|
688
938
|
}
|
|
689
939
|
|
|
690
940
|
Buffer.prototype.readFloatLE = function (offset, noAssert) {
|
|
691
|
-
|
|
941
|
+
if (!noAssert)
|
|
942
|
+
checkOffset(offset, 4, this.length)
|
|
943
|
+
return ieee754.read(this, offset, true, 23, 4)
|
|
692
944
|
}
|
|
693
945
|
|
|
694
946
|
Buffer.prototype.readFloatBE = function (offset, noAssert) {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
function readDouble (buf, offset, littleEndian, noAssert) {
|
|
699
|
-
if (!noAssert) {
|
|
700
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
701
|
-
assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
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)
|
|
705
950
|
}
|
|
706
951
|
|
|
707
952
|
Buffer.prototype.readDoubleLE = function (offset, noAssert) {
|
|
708
|
-
|
|
953
|
+
if (!noAssert)
|
|
954
|
+
checkOffset(offset, 8, this.length)
|
|
955
|
+
return ieee754.read(this, offset, true, 52, 8)
|
|
709
956
|
}
|
|
710
957
|
|
|
711
958
|
Buffer.prototype.readDoubleBE = function (offset, noAssert) {
|
|
712
|
-
|
|
959
|
+
if (!noAssert)
|
|
960
|
+
checkOffset(offset, 8, this.length)
|
|
961
|
+
return ieee754.read(this, offset, false, 52, 8)
|
|
713
962
|
}
|
|
714
963
|
|
|
715
|
-
|
|
716
|
-
if (!
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
verifuint(value, 0xff)
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
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
|
+
}
|
|
724
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)
|
|
725
976
|
this[offset] = value
|
|
726
977
|
return offset + 1
|
|
727
978
|
}
|
|
728
979
|
|
|
729
|
-
function
|
|
730
|
-
if (
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
|
|
735
|
-
verifuint(value, 0xffff)
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
var len = buf.length
|
|
739
|
-
if (offset >= len)
|
|
740
|
-
return
|
|
741
|
-
|
|
742
|
-
for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
|
|
743
|
-
buf[offset + i] =
|
|
744
|
-
(value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
745
|
-
(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
|
|
746
985
|
}
|
|
747
|
-
return offset + 2
|
|
748
986
|
}
|
|
749
987
|
|
|
750
988
|
Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
|
|
751
|
-
|
|
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
|
|
752
998
|
}
|
|
753
999
|
|
|
754
1000
|
Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
|
|
755
|
-
|
|
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
|
|
756
1010
|
}
|
|
757
1011
|
|
|
758
|
-
function
|
|
759
|
-
if (
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
763
|
-
assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
|
|
764
|
-
verifuint(value, 0xffffffff)
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
var len = buf.length
|
|
768
|
-
if (offset >= len)
|
|
769
|
-
return
|
|
770
|
-
|
|
771
|
-
for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
|
|
772
|
-
buf[offset + i] =
|
|
773
|
-
(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
|
|
774
1016
|
}
|
|
775
|
-
return offset + 4
|
|
776
1017
|
}
|
|
777
1018
|
|
|
778
1019
|
Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
|
|
779
|
-
|
|
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
|
|
780
1031
|
}
|
|
781
1032
|
|
|
782
1033
|
Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
|
|
783
|
-
|
|
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
|
|
784
1045
|
}
|
|
785
1046
|
|
|
786
1047
|
Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
if (offset >= this.length)
|
|
795
|
-
return
|
|
796
|
-
|
|
797
|
-
if (value >= 0)
|
|
798
|
-
this.writeUInt8(value, offset, noAssert)
|
|
799
|
-
else
|
|
800
|
-
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
|
|
801
1055
|
return offset + 1
|
|
802
1056
|
}
|
|
803
1057
|
|
|
804
|
-
function writeInt16 (buf, value, offset, littleEndian, noAssert) {
|
|
805
|
-
if (!noAssert) {
|
|
806
|
-
assert(value !== undefined && value !== null, 'missing value')
|
|
807
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
808
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
809
|
-
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
|
|
810
|
-
verifsint(value, 0x7fff, -0x8000)
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
var len = buf.length
|
|
814
|
-
if (offset >= len)
|
|
815
|
-
return
|
|
816
|
-
|
|
817
|
-
if (value >= 0)
|
|
818
|
-
writeUInt16(buf, value, offset, littleEndian, noAssert)
|
|
819
|
-
else
|
|
820
|
-
writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
|
|
821
|
-
return offset + 2
|
|
822
|
-
}
|
|
823
|
-
|
|
824
1058
|
Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
|
|
825
|
-
|
|
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
|
|
826
1068
|
}
|
|
827
1069
|
|
|
828
1070
|
Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
|
|
829
|
-
|
|
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
|
|
830
1080
|
}
|
|
831
1081
|
|
|
832
|
-
function
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
return
|
|
844
|
-
|
|
845
|
-
if (value >= 0)
|
|
846
|
-
writeUInt32(buf, value, offset, littleEndian, noAssert)
|
|
847
|
-
else
|
|
848
|
-
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)
|
|
849
1093
|
return offset + 4
|
|
850
1094
|
}
|
|
851
1095
|
|
|
852
|
-
Buffer.prototype.
|
|
853
|
-
|
|
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
|
|
854
1109
|
}
|
|
855
1110
|
|
|
856
|
-
|
|
857
|
-
|
|
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')
|
|
858
1114
|
}
|
|
859
1115
|
|
|
860
1116
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
861
|
-
if (!noAssert)
|
|
862
|
-
|
|
863
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
864
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
865
|
-
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
|
866
|
-
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
var len = buf.length
|
|
870
|
-
if (offset >= len)
|
|
871
|
-
return
|
|
872
|
-
|
|
1117
|
+
if (!noAssert)
|
|
1118
|
+
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
873
1119
|
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
874
1120
|
return offset + 4
|
|
875
1121
|
}
|
|
@@ -883,19 +1129,8 @@ Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
|
|
|
883
1129
|
}
|
|
884
1130
|
|
|
885
1131
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
886
|
-
if (!noAssert)
|
|
887
|
-
|
|
888
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
889
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
890
|
-
assert(offset + 7 < buf.length,
|
|
891
|
-
'Trying to write beyond buffer length')
|
|
892
|
-
verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
var len = buf.length
|
|
896
|
-
if (offset >= len)
|
|
897
|
-
return
|
|
898
|
-
|
|
1132
|
+
if (!noAssert)
|
|
1133
|
+
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
899
1134
|
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
900
1135
|
return offset + 8
|
|
901
1136
|
}
|
|
@@ -908,20 +1143,56 @@ Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
|
|
|
908
1143
|
return writeDouble(this, value, offset, false, noAssert)
|
|
909
1144
|
}
|
|
910
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
|
+
|
|
911
1182
|
// fill(value, start=0, end=buffer.length)
|
|
912
1183
|
Buffer.prototype.fill = function (value, start, end) {
|
|
913
1184
|
if (!value) value = 0
|
|
914
1185
|
if (!start) start = 0
|
|
915
1186
|
if (!end) end = this.length
|
|
916
1187
|
|
|
917
|
-
|
|
1188
|
+
if (end < start) throw new TypeError('end < start')
|
|
918
1189
|
|
|
919
1190
|
// Fill 0 bytes; we're done
|
|
920
1191
|
if (end === start) return
|
|
921
1192
|
if (this.length === 0) return
|
|
922
1193
|
|
|
923
|
-
|
|
924
|
-
|
|
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')
|
|
925
1196
|
|
|
926
1197
|
var i
|
|
927
1198
|
if (typeof value === 'number') {
|
|
@@ -931,25 +1202,12 @@ Buffer.prototype.fill = function (value, start, end) {
|
|
|
931
1202
|
} else {
|
|
932
1203
|
var bytes = utf8ToBytes(value.toString())
|
|
933
1204
|
var len = bytes.length
|
|
934
|
-
for (i = start; i < end; i++) {
|
|
935
|
-
this[i] = bytes[i % len]
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
return this
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
Buffer.prototype.inspect = function () {
|
|
943
|
-
var out = []
|
|
944
|
-
var len = this.length
|
|
945
|
-
for (var i = 0; i < len; i++) {
|
|
946
|
-
out[i] = toHex(this[i])
|
|
947
|
-
if (i === exports.INSPECT_MAX_BYTES) {
|
|
948
|
-
out[i + 1] = '...'
|
|
949
|
-
break
|
|
1205
|
+
for (i = start; i < end; i++) {
|
|
1206
|
+
this[i] = bytes[i % len]
|
|
950
1207
|
}
|
|
951
1208
|
}
|
|
952
|
-
|
|
1209
|
+
|
|
1210
|
+
return this
|
|
953
1211
|
}
|
|
954
1212
|
|
|
955
1213
|
/**
|
|
@@ -958,7 +1216,7 @@ Buffer.prototype.inspect = function () {
|
|
|
958
1216
|
*/
|
|
959
1217
|
Buffer.prototype.toArrayBuffer = function () {
|
|
960
1218
|
if (typeof Uint8Array !== 'undefined') {
|
|
961
|
-
if (Buffer.
|
|
1219
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
962
1220
|
return (new Buffer(this)).buffer
|
|
963
1221
|
} else {
|
|
964
1222
|
var buf = new Uint8Array(this.length)
|
|
@@ -968,7 +1226,7 @@ Buffer.prototype.toArrayBuffer = function () {
|
|
|
968
1226
|
return buf.buffer
|
|
969
1227
|
}
|
|
970
1228
|
} else {
|
|
971
|
-
throw new
|
|
1229
|
+
throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
|
|
972
1230
|
}
|
|
973
1231
|
}
|
|
974
1232
|
|
|
@@ -1051,12 +1309,6 @@ function stringtrim (str) {
|
|
|
1051
1309
|
return str.replace(/^\s+|\s+$/g, '')
|
|
1052
1310
|
}
|
|
1053
1311
|
|
|
1054
|
-
function isArray (subject) {
|
|
1055
|
-
return (Array.isArray || function (subject) {
|
|
1056
|
-
return Object.prototype.toString.call(subject) === '[object Array]'
|
|
1057
|
-
})(subject)
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
1312
|
function isArrayish (subject) {
|
|
1061
1313
|
return isArray(subject) || Buffer.isBuffer(subject) ||
|
|
1062
1314
|
subject && typeof subject === 'object' &&
|
|
@@ -1130,36 +1382,7 @@ function decodeUtf8Char (str) {
|
|
|
1130
1382
|
}
|
|
1131
1383
|
}
|
|
1132
1384
|
|
|
1133
|
-
|
|
1134
|
-
* We have to make sure that the value is a valid integer. This means that it
|
|
1135
|
-
* is non-negative. It has no fractional component and that it does not
|
|
1136
|
-
* exceed the maximum allowed value.
|
|
1137
|
-
*/
|
|
1138
|
-
function verifuint (value, max) {
|
|
1139
|
-
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
1140
|
-
assert(value >= 0, 'specified a negative value for writing an unsigned value')
|
|
1141
|
-
assert(value <= max, 'value is larger than maximum value for type')
|
|
1142
|
-
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
function verifsint (value, max, min) {
|
|
1146
|
-
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
1147
|
-
assert(value <= max, 'value larger than maximum allowed value')
|
|
1148
|
-
assert(value >= min, 'value smaller than minimum allowed value')
|
|
1149
|
-
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
function verifIEEE754 (value, max, min) {
|
|
1153
|
-
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
1154
|
-
assert(value <= max, 'value larger than maximum allowed value')
|
|
1155
|
-
assert(value >= min, 'value smaller than minimum allowed value')
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
function assert (test, message) {
|
|
1159
|
-
if (!test) throw new Error(message || 'Failed assertion')
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
},{"base64-js":2,"ieee754":3}],2:[function(_dereq_,module,exports){
|
|
1385
|
+
},{"base64-js":3,"ieee754":4,"is-array":5}],3:[function(_dereq_,module,exports){
|
|
1163
1386
|
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
1164
1387
|
|
|
1165
1388
|
;(function (exports) {
|
|
@@ -1281,7 +1504,7 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
1281
1504
|
exports.fromByteArray = uint8ToBase64
|
|
1282
1505
|
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
|
1283
1506
|
|
|
1284
|
-
},{}],
|
|
1507
|
+
},{}],4:[function(_dereq_,module,exports){
|
|
1285
1508
|
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
1286
1509
|
var e, m,
|
|
1287
1510
|
eLen = nBytes * 8 - mLen - 1,
|
|
@@ -1367,7 +1590,42 @@ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
|
1367
1590
|
buffer[offset + i - d] |= s * 128;
|
|
1368
1591
|
};
|
|
1369
1592
|
|
|
1370
|
-
},{}],
|
|
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){
|
|
1371
1629
|
(function (process){
|
|
1372
1630
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
1373
1631
|
//
|
|
@@ -1594,8 +1852,8 @@ var substr = 'ab'.substr(-1) === 'b'
|
|
|
1594
1852
|
}
|
|
1595
1853
|
;
|
|
1596
1854
|
|
|
1597
|
-
}).call(this,_dereq_(
|
|
1598
|
-
},{"
|
|
1855
|
+
}).call(this,_dereq_('_process'))
|
|
1856
|
+
},{"_process":7}],7:[function(_dereq_,module,exports){
|
|
1599
1857
|
// shim for using process in browser
|
|
1600
1858
|
|
|
1601
1859
|
var process = module.exports = {};
|
|
@@ -1603,6 +1861,8 @@ var process = module.exports = {};
|
|
|
1603
1861
|
process.nextTick = (function () {
|
|
1604
1862
|
var canSetImmediate = typeof window !== 'undefined'
|
|
1605
1863
|
&& window.setImmediate;
|
|
1864
|
+
var canMutationObserver = typeof window !== 'undefined'
|
|
1865
|
+
&& window.MutationObserver;
|
|
1606
1866
|
var canPost = typeof window !== 'undefined'
|
|
1607
1867
|
&& window.postMessage && window.addEventListener
|
|
1608
1868
|
;
|
|
@@ -1611,8 +1871,29 @@ process.nextTick = (function () {
|
|
|
1611
1871
|
return function (f) { return window.setImmediate(f) };
|
|
1612
1872
|
}
|
|
1613
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
|
+
|
|
1614
1896
|
if (canPost) {
|
|
1615
|
-
var queue = [];
|
|
1616
1897
|
window.addEventListener('message', function (ev) {
|
|
1617
1898
|
var source = ev.source;
|
|
1618
1899
|
if ((source === window || source === null) && ev.data === 'process-tick') {
|
|
@@ -1652,7 +1933,7 @@ process.emit = noop;
|
|
|
1652
1933
|
|
|
1653
1934
|
process.binding = function (name) {
|
|
1654
1935
|
throw new Error('process.binding is not supported');
|
|
1655
|
-
}
|
|
1936
|
+
};
|
|
1656
1937
|
|
|
1657
1938
|
// TODO(shtylman)
|
|
1658
1939
|
process.cwd = function () { return '/' };
|
|
@@ -1660,7 +1941,7 @@ process.chdir = function (dir) {
|
|
|
1660
1941
|
throw new Error('process.chdir is not supported');
|
|
1661
1942
|
};
|
|
1662
1943
|
|
|
1663
|
-
},{}],
|
|
1944
|
+
},{}],8:[function(_dereq_,module,exports){
|
|
1664
1945
|
/*
|
|
1665
1946
|
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
|
1666
1947
|
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
|
|
@@ -2106,14 +2387,16 @@ parseYieldExpression: true
|
|
|
2106
2387
|
}
|
|
2107
2388
|
} else if (blockComment) {
|
|
2108
2389
|
if (isLineTerminator(ch)) {
|
|
2109
|
-
if (ch === 13
|
|
2390
|
+
if (ch === 13) {
|
|
2110
2391
|
++index;
|
|
2111
2392
|
}
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
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
|
+
}
|
|
2117
2400
|
}
|
|
2118
2401
|
} else {
|
|
2119
2402
|
ch = source.charCodeAt(index++);
|
|
@@ -2769,6 +3052,7 @@ parseYieldExpression: true
|
|
|
2769
3052
|
if (ch === '\r' && source[index] === '\n') {
|
|
2770
3053
|
++index;
|
|
2771
3054
|
}
|
|
3055
|
+
lineStart = index;
|
|
2772
3056
|
}
|
|
2773
3057
|
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
2774
3058
|
break;
|
|
@@ -2884,12 +3168,14 @@ parseYieldExpression: true
|
|
|
2884
3168
|
if (ch === '\r' && source[index] === '\n') {
|
|
2885
3169
|
++index;
|
|
2886
3170
|
}
|
|
3171
|
+
lineStart = index;
|
|
2887
3172
|
}
|
|
2888
3173
|
} else if (isLineTerminator(ch.charCodeAt(0))) {
|
|
2889
3174
|
++lineNumber;
|
|
2890
3175
|
if (ch === '\r' && source[index] === '\n') {
|
|
2891
3176
|
++index;
|
|
2892
3177
|
}
|
|
3178
|
+
lineStart = index;
|
|
2893
3179
|
cooked += '\n';
|
|
2894
3180
|
} else {
|
|
2895
3181
|
cooked += ch;
|
|
@@ -3240,6 +3526,57 @@ parseYieldExpression: true
|
|
|
3240
3526
|
return {offset: index, line: lineNumber, col: index - lineStart};
|
|
3241
3527
|
}
|
|
3242
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;
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
bottomRight.push(node);
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3243
3580
|
function markerApply(marker, node) {
|
|
3244
3581
|
if (extra.range) {
|
|
3245
3582
|
node.range = [marker.offset, index];
|
|
@@ -3257,6 +3594,9 @@ parseYieldExpression: true
|
|
|
3257
3594
|
};
|
|
3258
3595
|
node = delegate.postProcess(node);
|
|
3259
3596
|
}
|
|
3597
|
+
if (extra.attachComment) {
|
|
3598
|
+
processComment(node);
|
|
3599
|
+
}
|
|
3260
3600
|
return node;
|
|
3261
3601
|
}
|
|
3262
3602
|
|
|
@@ -3466,10 +3806,11 @@ parseYieldExpression: true
|
|
|
3466
3806
|
};
|
|
3467
3807
|
},
|
|
3468
3808
|
|
|
3469
|
-
createObjectTypeAnnotation: function (properties) {
|
|
3809
|
+
createObjectTypeAnnotation: function (properties, nullable) {
|
|
3470
3810
|
return {
|
|
3471
3811
|
type: Syntax.ObjectTypeAnnotation,
|
|
3472
|
-
properties: properties
|
|
3812
|
+
properties: properties,
|
|
3813
|
+
nullable: nullable
|
|
3473
3814
|
};
|
|
3474
3815
|
},
|
|
3475
3816
|
|
|
@@ -3492,7 +3833,7 @@ parseYieldExpression: true
|
|
|
3492
3833
|
return {
|
|
3493
3834
|
type: Syntax.XJSAttribute,
|
|
3494
3835
|
name: name,
|
|
3495
|
-
value: value
|
|
3836
|
+
value: value || null
|
|
3496
3837
|
};
|
|
3497
3838
|
},
|
|
3498
3839
|
|
|
@@ -4066,7 +4407,8 @@ parseYieldExpression: true
|
|
|
4066
4407
|
}
|
|
4067
4408
|
|
|
4068
4409
|
function consumeSemicolon() {
|
|
4069
|
-
var line
|
|
4410
|
+
var line, oldIndex = index, oldLineNumber = lineNumber,
|
|
4411
|
+
oldLineStart = lineStart, oldLookahead = lookahead;
|
|
4070
4412
|
|
|
4071
4413
|
// Catch the very common case first: immediately a semicolon (char #59).
|
|
4072
4414
|
if (source.charCodeAt(index) === 59) {
|
|
@@ -4077,6 +4419,10 @@ parseYieldExpression: true
|
|
|
4077
4419
|
line = lineNumber;
|
|
4078
4420
|
skipComment();
|
|
4079
4421
|
if (lineNumber !== line) {
|
|
4422
|
+
index = oldIndex;
|
|
4423
|
+
lineNumber = oldLineNumber;
|
|
4424
|
+
lineStart = oldLineStart;
|
|
4425
|
+
lookahead = oldLookahead;
|
|
4080
4426
|
return;
|
|
4081
4427
|
}
|
|
4082
4428
|
|
|
@@ -5172,7 +5518,7 @@ parseYieldExpression: true
|
|
|
5172
5518
|
|
|
5173
5519
|
// 12.2 Variable Statement
|
|
5174
5520
|
|
|
5175
|
-
function parseObjectTypeAnnotation() {
|
|
5521
|
+
function parseObjectTypeAnnotation(nullable) {
|
|
5176
5522
|
var isMethod, marker, properties = [], property, propertyKey,
|
|
5177
5523
|
propertyTypeAnnotation;
|
|
5178
5524
|
|
|
@@ -5202,7 +5548,7 @@ parseYieldExpression: true
|
|
|
5202
5548
|
|
|
5203
5549
|
expect('}');
|
|
5204
5550
|
|
|
5205
|
-
return delegate.createObjectTypeAnnotation(properties);
|
|
5551
|
+
return delegate.createObjectTypeAnnotation(properties, nullable);
|
|
5206
5552
|
}
|
|
5207
5553
|
|
|
5208
5554
|
function parseVoidTypeAnnotation() {
|
|
@@ -5237,15 +5583,15 @@ parseYieldExpression: true
|
|
|
5237
5583
|
expect(':');
|
|
5238
5584
|
}
|
|
5239
5585
|
|
|
5240
|
-
if (match('{')) {
|
|
5241
|
-
return markerApply(marker, parseObjectTypeAnnotation());
|
|
5242
|
-
}
|
|
5243
|
-
|
|
5244
5586
|
if (match('?')) {
|
|
5245
5587
|
lex();
|
|
5246
5588
|
nullable = true;
|
|
5247
5589
|
}
|
|
5248
5590
|
|
|
5591
|
+
if (match('{')) {
|
|
5592
|
+
return markerApply(marker, parseObjectTypeAnnotation(nullable));
|
|
5593
|
+
}
|
|
5594
|
+
|
|
5249
5595
|
if (lookahead.type === Token.Identifier) {
|
|
5250
5596
|
typeIdentifier = parseVariableIdentifier();
|
|
5251
5597
|
if (match('<')) {
|
|
@@ -5273,7 +5619,7 @@ parseYieldExpression: true
|
|
|
5273
5619
|
if (!matchKeyword('void')) {
|
|
5274
5620
|
throwUnexpected(lookahead);
|
|
5275
5621
|
} else {
|
|
5276
|
-
return parseVoidTypeAnnotation();
|
|
5622
|
+
return markerApply(marker, parseVoidTypeAnnotation());
|
|
5277
5623
|
}
|
|
5278
5624
|
}
|
|
5279
5625
|
|
|
@@ -6833,6 +7179,10 @@ parseYieldExpression: true
|
|
|
6833
7179
|
comment.loc = loc;
|
|
6834
7180
|
}
|
|
6835
7181
|
extra.comments.push(comment);
|
|
7182
|
+
if (extra.attachComment) {
|
|
7183
|
+
extra.leadingComments.push(comment);
|
|
7184
|
+
extra.trailingComments.push(comment);
|
|
7185
|
+
}
|
|
6836
7186
|
}
|
|
6837
7187
|
|
|
6838
7188
|
function scanComment() {
|
|
@@ -6873,17 +7223,18 @@ parseYieldExpression: true
|
|
|
6873
7223
|
}
|
|
6874
7224
|
} else if (blockComment) {
|
|
6875
7225
|
if (isLineTerminator(ch.charCodeAt(0))) {
|
|
6876
|
-
if (ch === '\r'
|
|
7226
|
+
if (ch === '\r') {
|
|
6877
7227
|
++index;
|
|
6878
|
-
comment += '\r
|
|
6879
|
-
} else {
|
|
6880
|
-
comment += ch;
|
|
7228
|
+
comment += '\r';
|
|
6881
7229
|
}
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
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
|
+
}
|
|
6887
7238
|
}
|
|
6888
7239
|
} else {
|
|
6889
7240
|
ch = source[index++];
|
|
@@ -7296,6 +7647,11 @@ parseYieldExpression: true
|
|
|
7296
7647
|
str += scanXJSEntity();
|
|
7297
7648
|
} else {
|
|
7298
7649
|
index++;
|
|
7650
|
+
if (ch === '\r' && source[index] === '\n') {
|
|
7651
|
+
str += ch;
|
|
7652
|
+
ch = source[index];
|
|
7653
|
+
index++;
|
|
7654
|
+
}
|
|
7299
7655
|
if (isLineTerminator(ch.charCodeAt(0))) {
|
|
7300
7656
|
++lineNumber;
|
|
7301
7657
|
lineStart = index;
|
|
@@ -7564,7 +7920,7 @@ parseYieldExpression: true
|
|
|
7564
7920
|
}
|
|
7565
7921
|
|
|
7566
7922
|
function parseXJSElement() {
|
|
7567
|
-
var openingElement, closingElement, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
|
|
7923
|
+
var openingElement, closingElement = null, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
|
|
7568
7924
|
|
|
7569
7925
|
origInXJSChild = state.inXJSChild;
|
|
7570
7926
|
origInXJSTag = state.inXJSTag;
|
|
@@ -7882,6 +8238,7 @@ parseYieldExpression: true
|
|
|
7882
8238
|
if (typeof options !== 'undefined') {
|
|
7883
8239
|
extra.range = (typeof options.range === 'boolean') && options.range;
|
|
7884
8240
|
extra.loc = (typeof options.loc === 'boolean') && options.loc;
|
|
8241
|
+
extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
|
|
7885
8242
|
|
|
7886
8243
|
if (extra.loc && options.source !== null && options.source !== undefined) {
|
|
7887
8244
|
delegate = extend(delegate, {
|
|
@@ -7901,6 +8258,13 @@ parseYieldExpression: true
|
|
|
7901
8258
|
if (typeof options.tolerant === 'boolean' && options.tolerant) {
|
|
7902
8259
|
extra.errors = [];
|
|
7903
8260
|
}
|
|
8261
|
+
if (extra.attachComment) {
|
|
8262
|
+
extra.range = true;
|
|
8263
|
+
extra.comments = [];
|
|
8264
|
+
extra.bottomRightStack = [];
|
|
8265
|
+
extra.trailingComments = [];
|
|
8266
|
+
extra.leadingComments = [];
|
|
8267
|
+
}
|
|
7904
8268
|
}
|
|
7905
8269
|
|
|
7906
8270
|
if (length > 0) {
|
|
@@ -7938,7 +8302,7 @@ parseYieldExpression: true
|
|
|
7938
8302
|
}
|
|
7939
8303
|
|
|
7940
8304
|
// Sync with *.json manifests.
|
|
7941
|
-
exports.version = '
|
|
8305
|
+
exports.version = '6001.0001.0000-dev-harmony-fb';
|
|
7942
8306
|
|
|
7943
8307
|
exports.tokenize = tokenize;
|
|
7944
8308
|
|
|
@@ -7968,7 +8332,7 @@ parseYieldExpression: true
|
|
|
7968
8332
|
}));
|
|
7969
8333
|
/* vim: set sw=4 ts=4 et tw=80 : */
|
|
7970
8334
|
|
|
7971
|
-
},{}],
|
|
8335
|
+
},{}],9:[function(_dereq_,module,exports){
|
|
7972
8336
|
var Base62 = (function (my) {
|
|
7973
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"]
|
|
7974
8338
|
|
|
@@ -7996,7 +8360,7 @@ var Base62 = (function (my) {
|
|
|
7996
8360
|
}({}));
|
|
7997
8361
|
|
|
7998
8362
|
module.exports = Base62
|
|
7999
|
-
},{}],
|
|
8363
|
+
},{}],10:[function(_dereq_,module,exports){
|
|
8000
8364
|
/*
|
|
8001
8365
|
* Copyright 2009-2011 Mozilla Foundation and contributors
|
|
8002
8366
|
* Licensed under the New BSD license. See LICENSE.txt or:
|
|
@@ -8006,7 +8370,7 @@ exports.SourceMapGenerator = _dereq_('./source-map/source-map-generator').Source
|
|
|
8006
8370
|
exports.SourceMapConsumer = _dereq_('./source-map/source-map-consumer').SourceMapConsumer;
|
|
8007
8371
|
exports.SourceNode = _dereq_('./source-map/source-node').SourceNode;
|
|
8008
8372
|
|
|
8009
|
-
},{"./source-map/source-map-consumer":
|
|
8373
|
+
},{"./source-map/source-map-consumer":15,"./source-map/source-map-generator":16,"./source-map/source-node":17}],11:[function(_dereq_,module,exports){
|
|
8010
8374
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
8011
8375
|
/*
|
|
8012
8376
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -8105,7 +8469,7 @@ define(function (_dereq_, exports, module) {
|
|
|
8105
8469
|
|
|
8106
8470
|
});
|
|
8107
8471
|
|
|
8108
|
-
},{"./util":
|
|
8472
|
+
},{"./util":18,"amdefine":19}],12:[function(_dereq_,module,exports){
|
|
8109
8473
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
8110
8474
|
/*
|
|
8111
8475
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -8251,7 +8615,7 @@ define(function (_dereq_, exports, module) {
|
|
|
8251
8615
|
|
|
8252
8616
|
});
|
|
8253
8617
|
|
|
8254
|
-
},{"./base64":
|
|
8618
|
+
},{"./base64":13,"amdefine":19}],13:[function(_dereq_,module,exports){
|
|
8255
8619
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
8256
8620
|
/*
|
|
8257
8621
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -8295,7 +8659,7 @@ define(function (_dereq_, exports, module) {
|
|
|
8295
8659
|
|
|
8296
8660
|
});
|
|
8297
8661
|
|
|
8298
|
-
},{"amdefine":
|
|
8662
|
+
},{"amdefine":19}],14:[function(_dereq_,module,exports){
|
|
8299
8663
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
8300
8664
|
/*
|
|
8301
8665
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -8378,7 +8742,7 @@ define(function (_dereq_, exports, module) {
|
|
|
8378
8742
|
|
|
8379
8743
|
});
|
|
8380
8744
|
|
|
8381
|
-
},{"amdefine":
|
|
8745
|
+
},{"amdefine":19}],15:[function(_dereq_,module,exports){
|
|
8382
8746
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
8383
8747
|
/*
|
|
8384
8748
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -8857,7 +9221,7 @@ define(function (_dereq_, exports, module) {
|
|
|
8857
9221
|
|
|
8858
9222
|
});
|
|
8859
9223
|
|
|
8860
|
-
},{"./array-set":
|
|
9224
|
+
},{"./array-set":11,"./base64-vlq":12,"./binary-search":14,"./util":18,"amdefine":19}],16:[function(_dereq_,module,exports){
|
|
8861
9225
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
8862
9226
|
/*
|
|
8863
9227
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -9239,7 +9603,7 @@ define(function (_dereq_, exports, module) {
|
|
|
9239
9603
|
|
|
9240
9604
|
});
|
|
9241
9605
|
|
|
9242
|
-
},{"./array-set":
|
|
9606
|
+
},{"./array-set":11,"./base64-vlq":12,"./util":18,"amdefine":19}],17:[function(_dereq_,module,exports){
|
|
9243
9607
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
9244
9608
|
/*
|
|
9245
9609
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -9612,7 +9976,7 @@ define(function (_dereq_, exports, module) {
|
|
|
9612
9976
|
|
|
9613
9977
|
});
|
|
9614
9978
|
|
|
9615
|
-
},{"./source-map-generator":
|
|
9979
|
+
},{"./source-map-generator":16,"./util":18,"amdefine":19}],18:[function(_dereq_,module,exports){
|
|
9616
9980
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
9617
9981
|
/*
|
|
9618
9982
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -9819,7 +10183,7 @@ define(function (_dereq_, exports, module) {
|
|
|
9819
10183
|
|
|
9820
10184
|
});
|
|
9821
10185
|
|
|
9822
|
-
},{"amdefine":
|
|
10186
|
+
},{"amdefine":19}],19:[function(_dereq_,module,exports){
|
|
9823
10187
|
(function (process,__filename){
|
|
9824
10188
|
/** vim: et:ts=4:sw=4:sts=4
|
|
9825
10189
|
* @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
|
|
@@ -10121,8 +10485,8 @@ function amdefine(module, requireFn) {
|
|
|
10121
10485
|
|
|
10122
10486
|
module.exports = amdefine;
|
|
10123
10487
|
|
|
10124
|
-
}).call(this,_dereq_(
|
|
10125
|
-
},{"
|
|
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
|
-
},{}],
|
|
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":
|
|
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":
|
|
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":
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
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":
|
|
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
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
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":
|
|
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
|
|
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(
|
|
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":
|
|
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":
|
|
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":
|
|
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":
|
|
12833
|
+
},{"../src/utils":22,"esprima-fb":8}],30:[function(_dereq_,module,exports){
|
|
12405
12834
|
/**
|
|
12406
|
-
* Copyright 2013
|
|
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
|
-
*
|
|
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
|
-
|
|
12500
|
-
|
|
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
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
|
|
12508
|
-
|
|
12509
|
-
|
|
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
|
-
|
|
12512
|
-
message += new Array(errorColumn - 1).join(' ') + '^';
|
|
12513
|
-
return message;
|
|
12889
|
+
return names;
|
|
12514
12890
|
}
|
|
12515
12891
|
|
|
12516
|
-
|
|
12517
|
-
|
|
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
|
-
|
|
12549
|
-
|
|
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
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12555
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
12613
|
-
|
|
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
|
-
|
|
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
|
-
|
|
12645
|
-
var script, i;
|
|
12938
|
+
utils.append('Object.assign({', state);
|
|
12646
12939
|
|
|
12647
|
-
|
|
12648
|
-
|
|
12940
|
+
// Skip the original {
|
|
12941
|
+
utils.move(node.range[0] + 1, state);
|
|
12649
12942
|
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
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
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
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
|
-
|
|
12691
|
-
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
|
|
12695
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
12715
|
-
|
|
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 (
|
|
12721
|
-
|
|
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
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
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
|
-
|
|
13018
|
+
exports.visitorList = [
|
|
13019
|
+
visitObjectLiteralSpread
|
|
13020
|
+
];
|
|
13021
|
+
|
|
13022
|
+
},{"../src/utils":22,"esprima-fb":8}],32:[function(_dereq_,module,exports){
|
|
12733
13023
|
/**
|
|
12734
|
-
* Copyright
|
|
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
|
-
*
|
|
12766
|
-
* <X
|
|
12767
|
-
* <X prop="
|
|
12768
|
-
*
|
|
12769
|
-
*
|
|
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
|
-
//
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
//
|
|
12809
|
-
if (nameObject.type === Syntax.XJSIdentifier) {
|
|
12810
|
-
|
|
12811
|
-
|
|
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
|
-
'
|
|
12828
|
-
|
|
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
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
|
|
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('
|
|
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('
|
|
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 (
|
|
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
|
-
|
|
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":
|
|
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
|
-
*
|
|
13031
|
-
*
|
|
13032
|
-
*
|
|
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
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
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":
|
|
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
|
-
*
|
|
13142
|
-
*
|
|
13143
|
-
*
|
|
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,7 +13740,7 @@ exports.renderXJSLiteral = renderXJSLiteral;
|
|
|
13383
13740
|
exports.quoteAttrName = quoteAttrName;
|
|
13384
13741
|
exports.trimLeft = trimLeft;
|
|
13385
13742
|
|
|
13386
|
-
},{"esprima-fb":
|
|
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');
|
|
@@ -13392,8 +13749,10 @@ var es6ObjectConciseMethod = _dereq_('jstransform/visitors/es6-object-concise-me
|
|
|
13392
13749
|
var es6ObjectShortNotation = _dereq_('jstransform/visitors/es6-object-short-notation-visitors');
|
|
13393
13750
|
var es6RestParameters = _dereq_('jstransform/visitors/es6-rest-param-visitors');
|
|
13394
13751
|
var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors');
|
|
13752
|
+
var es7SpreadProperty = _dereq_('jstransform/visitors/es7-spread-property-visitors');
|
|
13395
13753
|
var react = _dereq_('./transforms/react');
|
|
13396
13754
|
var reactDisplayName = _dereq_('./transforms/reactDisplayName');
|
|
13755
|
+
var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
|
|
13397
13756
|
|
|
13398
13757
|
/**
|
|
13399
13758
|
* Map from transformName => orderedListOfVisitors.
|
|
@@ -13406,13 +13765,35 @@ var transformVisitors = {
|
|
|
13406
13765
|
'es6-object-short-notation': es6ObjectShortNotation.visitorList,
|
|
13407
13766
|
'es6-rest-params': es6RestParameters.visitorList,
|
|
13408
13767
|
'es6-templates': es6Templates.visitorList,
|
|
13409
|
-
'
|
|
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
|
+
]
|
|
13410
13790
|
};
|
|
13411
13791
|
|
|
13412
13792
|
/**
|
|
13413
13793
|
* Specifies the order in which each transform should run.
|
|
13414
13794
|
*/
|
|
13415
13795
|
var transformRunOrder = [
|
|
13796
|
+
'types',
|
|
13416
13797
|
'es6-arrow-functions',
|
|
13417
13798
|
'es6-object-concise-method',
|
|
13418
13799
|
'es6-object-short-notation',
|
|
@@ -13420,6 +13801,7 @@ var transformRunOrder = [
|
|
|
13420
13801
|
'es6-rest-params',
|
|
13421
13802
|
'es6-templates',
|
|
13422
13803
|
'es6-destructuring',
|
|
13804
|
+
'es7-spread-property',
|
|
13423
13805
|
'react'
|
|
13424
13806
|
];
|
|
13425
13807
|
|
|
@@ -13440,9 +13822,37 @@ function getAllVisitors(excludes) {
|
|
|
13440
13822
|
return ret;
|
|
13441
13823
|
}
|
|
13442
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;
|
|
13443
13854
|
exports.getAllVisitors = getAllVisitors;
|
|
13444
13855
|
exports.transformVisitors = transformVisitors;
|
|
13445
13856
|
|
|
13446
|
-
},{"./transforms/react":
|
|
13447
|
-
(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)
|
|
13448
13858
|
});
|