diff options
Diffstat (limited to 'node_modules/fbjs/lib')
202 files changed, 11998 insertions, 0 deletions
diff --git a/node_modules/fbjs/lib/CSSCore.js b/node_modules/fbjs/lib/CSSCore.js new file mode 100644 index 000000000..c8efce7dd --- /dev/null +++ b/node_modules/fbjs/lib/CSSCore.js @@ -0,0 +1,121 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var invariant = require('./invariant'); + +/** + * The CSSCore module specifies the API (and implements most of the methods) + * that should be used when dealing with the display of elements (via their + * CSS classes and visibility on screen. It is an API focused on mutating the + * display and not reading it as no logical state should be encoded in the + * display of elements. + */ + +/* Slow implementation for browsers that don't natively support .matches() */ +function matchesSelector_SLOW(element, selector) { + var root = element; + while (root.parentNode) { + root = root.parentNode; + } + + var all = root.querySelectorAll(selector); + return Array.prototype.indexOf.call(all, element) !== -1; +} + +var CSSCore = { + + /** + * Adds the class passed in to the element if it doesn't already have it. + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @return {DOMElement} the element passed in + */ + addClass: function addClass(element, className) { + !!/\s/.test(className) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'CSSCore.addClass takes only a single class name. "%s" contains ' + 'multiple classes.', className) : invariant(false) : void 0; + + if (className) { + if (element.classList) { + element.classList.add(className); + } else if (!CSSCore.hasClass(element, className)) { + element.className = element.className + ' ' + className; + } + } + return element; + }, + + /** + * Removes the class passed in from the element + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @return {DOMElement} the element passed in + */ + removeClass: function removeClass(element, className) { + !!/\s/.test(className) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'CSSCore.removeClass takes only a single class name. "%s" contains ' + 'multiple classes.', className) : invariant(false) : void 0; + + if (className) { + if (element.classList) { + element.classList.remove(className); + } else if (CSSCore.hasClass(element, className)) { + element.className = element.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ') // multiple spaces to one + .replace(/^\s*|\s*$/g, ''); // trim the ends + } + } + return element; + }, + + /** + * Helper to add or remove a class from an element based on a condition. + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @param {*} bool condition to whether to add or remove the class + * @return {DOMElement} the element passed in + */ + conditionClass: function conditionClass(element, className, bool) { + return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className); + }, + + /** + * Tests whether the element has the class specified. + * + * @param {DOMNode|DOMWindow} element the element to check the class on + * @param {string} className the CSS className + * @return {boolean} true if the element has the class, false if not + */ + hasClass: function hasClass(element, className) { + !!/\s/.test(className) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'CSS.hasClass takes only a single class name.') : invariant(false) : void 0; + if (element.classList) { + return !!className && element.classList.contains(className); + } + return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1; + }, + + /** + * Tests whether the element matches the selector specified + * + * @param {DOMNode|DOMWindow} element the element that we are querying + * @param {string} selector the CSS selector + * @return {boolean} true if the element matches the selector, false if not + */ + matchesSelector: function matchesSelector(element, selector) { + var matchesImpl = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || function (s) { + return matchesSelector_SLOW(element, s); + }; + return matchesImpl.call(element, selector); + } + +}; + +module.exports = CSSCore;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/CSSCore.js.flow b/node_modules/fbjs/lib/CSSCore.js.flow new file mode 100644 index 000000000..e7d8479af --- /dev/null +++ b/node_modules/fbjs/lib/CSSCore.js.flow @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule CSSCore + * @typechecks + */ + +const invariant = require('./invariant'); + +/** + * The CSSCore module specifies the API (and implements most of the methods) + * that should be used when dealing with the display of elements (via their + * CSS classes and visibility on screen. It is an API focused on mutating the + * display and not reading it as no logical state should be encoded in the + * display of elements. + */ + +/* Slow implementation for browsers that don't natively support .matches() */ +function matchesSelector_SLOW(element, selector) { + let root = element; + while (root.parentNode) { + root = root.parentNode; + } + + const all = root.querySelectorAll(selector); + return Array.prototype.indexOf.call(all, element) !== -1; +} + +const CSSCore = { + + /** + * Adds the class passed in to the element if it doesn't already have it. + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @return {DOMElement} the element passed in + */ + addClass: function (element, className) { + invariant(!/\s/.test(className), 'CSSCore.addClass takes only a single class name. "%s" contains ' + 'multiple classes.', className); + + if (className) { + if (element.classList) { + element.classList.add(className); + } else if (!CSSCore.hasClass(element, className)) { + element.className = element.className + ' ' + className; + } + } + return element; + }, + + /** + * Removes the class passed in from the element + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @return {DOMElement} the element passed in + */ + removeClass: function (element, className) { + invariant(!/\s/.test(className), 'CSSCore.removeClass takes only a single class name. "%s" contains ' + 'multiple classes.', className); + + if (className) { + if (element.classList) { + element.classList.remove(className); + } else if (CSSCore.hasClass(element, className)) { + element.className = element.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ') // multiple spaces to one + .replace(/^\s*|\s*$/g, ''); // trim the ends + } + } + return element; + }, + + /** + * Helper to add or remove a class from an element based on a condition. + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @param {*} bool condition to whether to add or remove the class + * @return {DOMElement} the element passed in + */ + conditionClass: function (element, className, bool) { + return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className); + }, + + /** + * Tests whether the element has the class specified. + * + * @param {DOMNode|DOMWindow} element the element to check the class on + * @param {string} className the CSS className + * @return {boolean} true if the element has the class, false if not + */ + hasClass: function (element, className) { + invariant(!/\s/.test(className), 'CSS.hasClass takes only a single class name.'); + if (element.classList) { + return !!className && element.classList.contains(className); + } + return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1; + }, + + /** + * Tests whether the element matches the selector specified + * + * @param {DOMNode|DOMWindow} element the element that we are querying + * @param {string} selector the CSS selector + * @return {boolean} true if the element matches the selector, false if not + */ + matchesSelector: function (element, selector) { + const matchesImpl = element.matches || element.webkitMatchesSelector || element.mozMatchesSelector || element.msMatchesSelector || (s => matchesSelector_SLOW(element, s)); + return matchesImpl.call(element, selector); + } + +}; + +module.exports = CSSCore;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/DataTransfer.js b/node_modules/fbjs/lib/DataTransfer.js new file mode 100644 index 000000000..d37882b80 --- /dev/null +++ b/node_modules/fbjs/lib/DataTransfer.js @@ -0,0 +1,221 @@ +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var PhotosMimeType = require('./PhotosMimeType'); + +var createArrayFromMixed = require('./createArrayFromMixed'); +var emptyFunction = require('./emptyFunction'); + +var CR_LF_REGEX = new RegExp('\r\n', 'g'); +var LF_ONLY = '\n'; + +var RICH_TEXT_TYPES = { + 'text/rtf': 1, + 'text/html': 1 +}; + +/** + * If DataTransferItem is a file then return the Blob of data. + * + * @param {object} item + * @return {?blob} + */ +function getFileFromDataTransfer(item) { + if (item.kind == 'file') { + return item.getAsFile(); + } +} + +var DataTransfer = function () { + /** + * @param {object} data + */ + function DataTransfer(data) { + _classCallCheck(this, DataTransfer); + + this.data = data; + + // Types could be DOMStringList or array + this.types = data.types ? createArrayFromMixed(data.types) : []; + } + + /** + * Is this likely to be a rich text data transfer? + * + * @return {boolean} + */ + + + DataTransfer.prototype.isRichText = function isRichText() { + // If HTML is available, treat this data as rich text. This way, we avoid + // using a pasted image if it is packaged with HTML -- this may occur with + // pastes from MS Word, for example. However this is only rich text if + // there's accompanying text. + if (this.getHTML() && this.getText()) { + return true; + } + + // When an image is copied from a preview window, you end up with two + // DataTransferItems one of which is a file's metadata as text. Skip those. + if (this.isImage()) { + return false; + } + + return this.types.some(function (type) { + return RICH_TEXT_TYPES[type]; + }); + }; + + /** + * Get raw text. + * + * @return {?string} + */ + + + DataTransfer.prototype.getText = function getText() { + var text; + if (this.data.getData) { + if (!this.types.length) { + text = this.data.getData('Text'); + } else if (this.types.indexOf('text/plain') != -1) { + text = this.data.getData('text/plain'); + } + } + return text ? text.replace(CR_LF_REGEX, LF_ONLY) : null; + }; + + /** + * Get HTML paste data + * + * @return {?string} + */ + + + DataTransfer.prototype.getHTML = function getHTML() { + if (this.data.getData) { + if (!this.types.length) { + return this.data.getData('Text'); + } else if (this.types.indexOf('text/html') != -1) { + return this.data.getData('text/html'); + } + } + }; + + /** + * Is this a link data transfer? + * + * @return {boolean} + */ + + + DataTransfer.prototype.isLink = function isLink() { + return this.types.some(function (type) { + return type.indexOf('Url') != -1 || type.indexOf('text/uri-list') != -1 || type.indexOf('text/x-moz-url'); + }); + }; + + /** + * Get a link url. + * + * @return {?string} + */ + + + DataTransfer.prototype.getLink = function getLink() { + if (this.data.getData) { + if (this.types.indexOf('text/x-moz-url') != -1) { + var url = this.data.getData('text/x-moz-url').split('\n'); + return url[0]; + } + return this.types.indexOf('text/uri-list') != -1 ? this.data.getData('text/uri-list') : this.data.getData('url'); + } + + return null; + }; + + /** + * Is this an image data transfer? + * + * @return {boolean} + */ + + + DataTransfer.prototype.isImage = function isImage() { + var isImage = this.types.some(function (type) { + // Firefox will have a type of application/x-moz-file for images during + // dragging + return type.indexOf('application/x-moz-file') != -1; + }); + + if (isImage) { + return true; + } + + var items = this.getFiles(); + for (var i = 0; i < items.length; i++) { + var type = items[i].type; + if (!PhotosMimeType.isImage(type)) { + return false; + } + } + + return true; + }; + + DataTransfer.prototype.getCount = function getCount() { + if (this.data.hasOwnProperty('items')) { + return this.data.items.length; + } else if (this.data.hasOwnProperty('mozItemCount')) { + return this.data.mozItemCount; + } else if (this.data.files) { + return this.data.files.length; + } + return null; + }; + + /** + * Get files. + * + * @return {array} + */ + + + DataTransfer.prototype.getFiles = function getFiles() { + if (this.data.items) { + // createArrayFromMixed doesn't properly handle DataTransferItemLists. + return Array.prototype.slice.call(this.data.items).map(getFileFromDataTransfer).filter(emptyFunction.thatReturnsArgument); + } else if (this.data.files) { + return Array.prototype.slice.call(this.data.files); + } else { + return []; + } + }; + + /** + * Are there any files to fetch? + * + * @return {boolean} + */ + + + DataTransfer.prototype.hasFiles = function hasFiles() { + return this.getFiles().length > 0; + }; + + return DataTransfer; +}(); + +module.exports = DataTransfer;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/DataTransfer.js.flow b/node_modules/fbjs/lib/DataTransfer.js.flow new file mode 100644 index 000000000..3d185fe2e --- /dev/null +++ b/node_modules/fbjs/lib/DataTransfer.js.flow @@ -0,0 +1,196 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule DataTransfer + * @typechecks + */ + +var PhotosMimeType = require('./PhotosMimeType'); + +var createArrayFromMixed = require('./createArrayFromMixed'); +var emptyFunction = require('./emptyFunction'); + +var CR_LF_REGEX = new RegExp('\u000D\u000A', 'g'); +var LF_ONLY = '\u000A'; + +var RICH_TEXT_TYPES = { + 'text/rtf': 1, + 'text/html': 1 +}; + +/** + * If DataTransferItem is a file then return the Blob of data. + * + * @param {object} item + * @return {?blob} + */ +function getFileFromDataTransfer(item) { + if (item.kind == 'file') { + return item.getAsFile(); + } +} + +class DataTransfer { + /** + * @param {object} data + */ + constructor(data) { + this.data = data; + + // Types could be DOMStringList or array + this.types = data.types ? createArrayFromMixed(data.types) : []; + } + + /** + * Is this likely to be a rich text data transfer? + * + * @return {boolean} + */ + isRichText() { + // If HTML is available, treat this data as rich text. This way, we avoid + // using a pasted image if it is packaged with HTML -- this may occur with + // pastes from MS Word, for example. However this is only rich text if + // there's accompanying text. + if (this.getHTML() && this.getText()) { + return true; + } + + // When an image is copied from a preview window, you end up with two + // DataTransferItems one of which is a file's metadata as text. Skip those. + if (this.isImage()) { + return false; + } + + return this.types.some(type => RICH_TEXT_TYPES[type]); + } + + /** + * Get raw text. + * + * @return {?string} + */ + getText() { + var text; + if (this.data.getData) { + if (!this.types.length) { + text = this.data.getData('Text'); + } else if (this.types.indexOf('text/plain') != -1) { + text = this.data.getData('text/plain'); + } + } + return text ? text.replace(CR_LF_REGEX, LF_ONLY) : null; + } + + /** + * Get HTML paste data + * + * @return {?string} + */ + getHTML() { + if (this.data.getData) { + if (!this.types.length) { + return this.data.getData('Text'); + } else if (this.types.indexOf('text/html') != -1) { + return this.data.getData('text/html'); + } + } + } + + /** + * Is this a link data transfer? + * + * @return {boolean} + */ + isLink() { + return this.types.some(type => { + return type.indexOf('Url') != -1 || type.indexOf('text/uri-list') != -1 || type.indexOf('text/x-moz-url'); + }); + } + + /** + * Get a link url. + * + * @return {?string} + */ + getLink() { + if (this.data.getData) { + if (this.types.indexOf('text/x-moz-url') != -1) { + let url = this.data.getData('text/x-moz-url').split('\n'); + return url[0]; + } + return this.types.indexOf('text/uri-list') != -1 ? this.data.getData('text/uri-list') : this.data.getData('url'); + } + + return null; + } + + /** + * Is this an image data transfer? + * + * @return {boolean} + */ + isImage() { + var isImage = this.types.some(type => { + // Firefox will have a type of application/x-moz-file for images during + // dragging + return type.indexOf('application/x-moz-file') != -1; + }); + + if (isImage) { + return true; + } + + var items = this.getFiles(); + for (var i = 0; i < items.length; i++) { + var type = items[i].type; + if (!PhotosMimeType.isImage(type)) { + return false; + } + } + + return true; + } + + getCount() { + if (this.data.hasOwnProperty('items')) { + return this.data.items.length; + } else if (this.data.hasOwnProperty('mozItemCount')) { + return this.data.mozItemCount; + } else if (this.data.files) { + return this.data.files.length; + } + return null; + } + + /** + * Get files. + * + * @return {array} + */ + getFiles() { + if (this.data.items) { + // createArrayFromMixed doesn't properly handle DataTransferItemLists. + return Array.prototype.slice.call(this.data.items).map(getFileFromDataTransfer).filter(emptyFunction.thatReturnsArgument); + } else if (this.data.files) { + return Array.prototype.slice.call(this.data.files); + } else { + return []; + } + } + + /** + * Are there any files to fetch? + * + * @return {boolean} + */ + hasFiles() { + return this.getFiles().length > 0; + } +} + +module.exports = DataTransfer;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Deferred.js b/node_modules/fbjs/lib/Deferred.js new file mode 100644 index 000000000..bfc358580 --- /dev/null +++ b/node_modules/fbjs/lib/Deferred.js @@ -0,0 +1,81 @@ +"use strict"; + +var Promise = require("./Promise"); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/** + * Deferred provides a Promise-like API that exposes methods to resolve and + * reject the Promise. It is most useful when converting non-Promise code to use + * Promises. + * + * If you want to export the Promise without exposing access to the resolve and + * reject methods, you should export `getPromise` which returns a Promise with + * the same semantics excluding those methods. + */ +var Deferred = function () { + function Deferred() { + var _this = this; + + _classCallCheck(this, Deferred); + + this._settled = false; + this._promise = new Promise(function (resolve, reject) { + _this._resolve = resolve; + _this._reject = reject; + }); + } + + Deferred.prototype.getPromise = function getPromise() { + return this._promise; + }; + + Deferred.prototype.resolve = function resolve(value) { + this._settled = true; + this._resolve(value); + }; + + Deferred.prototype.reject = function reject(reason) { + this._settled = true; + this._reject(reason); + }; + + Deferred.prototype["catch"] = function _catch() { + return Promise.prototype["catch"].apply(this._promise, arguments); + }; + + Deferred.prototype.then = function then() { + return Promise.prototype.then.apply(this._promise, arguments); + }; + + Deferred.prototype.done = function done() { + // Embed the polyfill for the non-standard Promise.prototype.done so that + // users of the open source fbjs don't need a custom lib for Promise + var promise = arguments.length ? this._promise.then.apply(this._promise, arguments) : this._promise; + promise.then(undefined, function (err) { + setTimeout(function () { + throw err; + }, 0); + }); + }; + + Deferred.prototype.isSettled = function isSettled() { + return this._settled; + }; + + return Deferred; +}(); + +module.exports = Deferred;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Deferred.js.flow b/node_modules/fbjs/lib/Deferred.js.flow new file mode 100644 index 000000000..aaad67b5c --- /dev/null +++ b/node_modules/fbjs/lib/Deferred.js.flow @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Deferred + * @typechecks + * @flow + */ + +/** + * Deferred provides a Promise-like API that exposes methods to resolve and + * reject the Promise. It is most useful when converting non-Promise code to use + * Promises. + * + * If you want to export the Promise without exposing access to the resolve and + * reject methods, you should export `getPromise` which returns a Promise with + * the same semantics excluding those methods. + */ +class Deferred<Tvalue, Treason> { + _settled: boolean; + _promise: Promise<any>; + _resolve: (value: Tvalue) => void; + _reject: (reason: Treason) => void; + + constructor() { + this._settled = false; + this._promise = new Promise((resolve, reject) => { + this._resolve = (resolve: any); + this._reject = (reject: any); + }); + } + + getPromise(): Promise<any> { + return this._promise; + } + + resolve(value: Tvalue): void { + this._settled = true; + this._resolve(value); + } + + reject(reason: Treason): void { + this._settled = true; + this._reject(reason); + } + + catch(): Promise<any> { + return Promise.prototype.catch.apply(this._promise, arguments); + } + + then(): Promise<any> { + return Promise.prototype.then.apply(this._promise, arguments); + } + + done(): void { + // Embed the polyfill for the non-standard Promise.prototype.done so that + // users of the open source fbjs don't need a custom lib for Promise + const promise = arguments.length ? this._promise.then.apply(this._promise, arguments) : this._promise; + promise.then(undefined, function (err) { + setTimeout(function () { + throw err; + }, 0); + }); + } + + isSettled(): boolean { + return this._settled; + } +} + +module.exports = Deferred;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/ErrorUtils.js b/node_modules/fbjs/lib/ErrorUtils.js new file mode 100644 index 000000000..c03245b39 --- /dev/null +++ b/node_modules/fbjs/lib/ErrorUtils.js @@ -0,0 +1,28 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +/* jslint unused:false */ + +if (global.ErrorUtils) { + module.exports = global.ErrorUtils; +} else { + var ErrorUtils = { + applyWithGuard: function applyWithGuard(callback, context, args, onError, name) { + return callback.apply(context, args); + }, + guard: function guard(callback, name) { + return callback; + } + }; + + module.exports = ErrorUtils; +}
\ No newline at end of file diff --git a/node_modules/fbjs/lib/ErrorUtils.js.flow b/node_modules/fbjs/lib/ErrorUtils.js.flow new file mode 100644 index 000000000..447bd87aa --- /dev/null +++ b/node_modules/fbjs/lib/ErrorUtils.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ErrorUtils + */ + +/* jslint unused:false */ + +if (global.ErrorUtils) { + module.exports = global.ErrorUtils; +} else { + var ErrorUtils = { + applyWithGuard(callback, context, args, onError, name) { + return callback.apply(context, args); + }, + guard(callback, name) { + return callback; + } + }; + + module.exports = ErrorUtils; +}
\ No newline at end of file diff --git a/node_modules/fbjs/lib/EventListener.js b/node_modules/fbjs/lib/EventListener.js new file mode 100644 index 000000000..c20a23a13 --- /dev/null +++ b/node_modules/fbjs/lib/EventListener.js @@ -0,0 +1,83 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @typechecks + */ + +var emptyFunction = require('./emptyFunction'); + +/** + * Upstream version of event listener. Does not take into account specific + * nature of platform. + */ +var EventListener = { + /** + * Listen to DOM events during the bubble phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + listen: function listen(target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, false); + return { + remove: function remove() { + target.removeEventListener(eventType, callback, false); + } + }; + } else if (target.attachEvent) { + target.attachEvent('on' + eventType, callback); + return { + remove: function remove() { + target.detachEvent('on' + eventType, callback); + } + }; + } + }, + + /** + * Listen to DOM events during the capture phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + capture: function capture(target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, true); + return { + remove: function remove() { + target.removeEventListener(eventType, callback, true); + } + }; + } else { + if (process.env.NODE_ENV !== 'production') { + console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.'); + } + return { + remove: emptyFunction + }; + } + }, + + registerDefault: function registerDefault() {} +}; + +module.exports = EventListener;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/EventListener.js.flow b/node_modules/fbjs/lib/EventListener.js.flow new file mode 100644 index 000000000..1f566665d --- /dev/null +++ b/node_modules/fbjs/lib/EventListener.js.flow @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @providesModule EventListener + * @typechecks + */ + +var emptyFunction = require('./emptyFunction'); + +/** + * Upstream version of event listener. Does not take into account specific + * nature of platform. + */ +var EventListener = { + /** + * Listen to DOM events during the bubble phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + listen: function (target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, false); + return { + remove: function () { + target.removeEventListener(eventType, callback, false); + } + }; + } else if (target.attachEvent) { + target.attachEvent('on' + eventType, callback); + return { + remove: function () { + target.detachEvent('on' + eventType, callback); + } + }; + } + }, + + /** + * Listen to DOM events during the capture phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + capture: function (target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, true); + return { + remove: function () { + target.removeEventListener(eventType, callback, true); + } + }; + } else { + if (__DEV__) { + console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.'); + } + return { + remove: emptyFunction + }; + } + }, + + registerDefault: function () {} +}; + +module.exports = EventListener;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/ExecutionEnvironment.js b/node_modules/fbjs/lib/ExecutionEnvironment.js new file mode 100644 index 000000000..ffd88af1f --- /dev/null +++ b/node_modules/fbjs/lib/ExecutionEnvironment.js @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + +/** + * Simple, lightweight module assisting with the detection and context of + * Worker. Helps avoid circular dependencies and allows code to reason about + * whether or not they are in a Worker, even if they never include the main + * `ReactWorker` dependency. + */ +var ExecutionEnvironment = { + + canUseDOM: canUseDOM, + + canUseWorkers: typeof Worker !== 'undefined', + + canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), + + canUseViewport: canUseDOM && !!window.screen, + + isInWorker: !canUseDOM // For now, this is true - might change in the future. + +}; + +module.exports = ExecutionEnvironment;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/ExecutionEnvironment.js.flow b/node_modules/fbjs/lib/ExecutionEnvironment.js.flow new file mode 100644 index 000000000..25e751959 --- /dev/null +++ b/node_modules/fbjs/lib/ExecutionEnvironment.js.flow @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ExecutionEnvironment + */ + +'use strict'; + +const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); + +/** + * Simple, lightweight module assisting with the detection and context of + * Worker. Helps avoid circular dependencies and allows code to reason about + * whether or not they are in a Worker, even if they never include the main + * `ReactWorker` dependency. + */ +const ExecutionEnvironment = { + + canUseDOM: canUseDOM, + + canUseWorkers: typeof Worker !== 'undefined', + + canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), + + canUseViewport: canUseDOM && !!window.screen, + + isInWorker: !canUseDOM // For now, this is true - might change in the future. + +}; + +module.exports = ExecutionEnvironment;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Keys.js b/node_modules/fbjs/lib/Keys.js new file mode 100644 index 000000000..4c344bdfe --- /dev/null +++ b/node_modules/fbjs/lib/Keys.js @@ -0,0 +1,36 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +module.exports = { + BACKSPACE: 8, + TAB: 9, + RETURN: 13, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46, + COMMA: 188, + PERIOD: 190, + A: 65, + Z: 90, + ZERO: 48, + NUMPAD_0: 96, + NUMPAD_9: 105 +};
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Keys.js.flow b/node_modules/fbjs/lib/Keys.js.flow new file mode 100644 index 000000000..8a35ea60a --- /dev/null +++ b/node_modules/fbjs/lib/Keys.js.flow @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Keys + */ + +module.exports = { + BACKSPACE: 8, + TAB: 9, + RETURN: 13, + ALT: 18, + ESC: 27, + SPACE: 32, + PAGE_UP: 33, + PAGE_DOWN: 34, + END: 35, + HOME: 36, + LEFT: 37, + UP: 38, + RIGHT: 39, + DOWN: 40, + DELETE: 46, + COMMA: 188, + PERIOD: 190, + A: 65, + Z: 90, + ZERO: 48, + NUMPAD_0: 96, + NUMPAD_9: 105 +};
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Map.js b/node_modules/fbjs/lib/Map.js new file mode 100644 index 000000000..d242802fd --- /dev/null +++ b/node_modules/fbjs/lib/Map.js @@ -0,0 +1,13 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +module.exports = require('core-js/library/es6/map');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Map.js.flow b/node_modules/fbjs/lib/Map.js.flow new file mode 100644 index 000000000..3879fbfc3 --- /dev/null +++ b/node_modules/fbjs/lib/Map.js.flow @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Map + */ + +module.exports = require('core-js/library/es6/map');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/PhotosMimeType.js b/node_modules/fbjs/lib/PhotosMimeType.js new file mode 100644 index 000000000..48fc3b5c2 --- /dev/null +++ b/node_modules/fbjs/lib/PhotosMimeType.js @@ -0,0 +1,28 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ +var PhotosMimeType = { + isImage: function isImage(mimeString) { + return getParts(mimeString)[0] === 'image'; + }, + isJpeg: function isJpeg(mimeString) { + var parts = getParts(mimeString); + return PhotosMimeType.isImage(mimeString) && ( + // see http://fburl.com/10972194 + parts[1] === 'jpeg' || parts[1] === 'pjpeg'); + } +}; + +function getParts(mimeString) { + return mimeString.split('/'); +} + +module.exports = PhotosMimeType;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/PhotosMimeType.js.flow b/node_modules/fbjs/lib/PhotosMimeType.js.flow new file mode 100644 index 000000000..ebd10a66b --- /dev/null +++ b/node_modules/fbjs/lib/PhotosMimeType.js.flow @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule PhotosMimeType + */ +const PhotosMimeType = { + isImage(mimeString) { + return getParts(mimeString)[0] === 'image'; + }, + + isJpeg(mimeString) { + const parts = getParts(mimeString); + return PhotosMimeType.isImage(mimeString) && ( + // see http://fburl.com/10972194 + parts[1] === 'jpeg' || parts[1] === 'pjpeg'); + } +}; + +function getParts(mimeString) { + return mimeString.split('/'); +} + +module.exports = PhotosMimeType;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Promise.js b/node_modules/fbjs/lib/Promise.js new file mode 100644 index 000000000..e92481a69 --- /dev/null +++ b/node_modules/fbjs/lib/Promise.js @@ -0,0 +1,13 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +module.exports = require('promise');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Promise.js.flow b/node_modules/fbjs/lib/Promise.js.flow new file mode 100644 index 000000000..d5932aaab --- /dev/null +++ b/node_modules/fbjs/lib/Promise.js.flow @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Promise + */ + +module.exports = require('promise');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Promise.native.js b/node_modules/fbjs/lib/Promise.native.js new file mode 100644 index 000000000..2a6a3b8aa --- /dev/null +++ b/node_modules/fbjs/lib/Promise.native.js @@ -0,0 +1,26 @@ +/** + * + * Copyright 2013-2016 Facebook, Inc. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * This module wraps and augments the minimally ES6-compliant Promise + * implementation provided by the promise npm package. + * + */ + +'use strict'; + +var Promise = require('promise/setimmediate/es6-extensions'); +require('promise/setimmediate/done'); + +/** + * Handle either fulfillment or rejection with the same callback. + */ +Promise.prototype['finally'] = function (onSettled) { + return this.then(onSettled, onSettled); +}; + +module.exports = Promise;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Promise.native.js.flow b/node_modules/fbjs/lib/Promise.native.js.flow new file mode 100644 index 000000000..ff8a91f21 --- /dev/null +++ b/node_modules/fbjs/lib/Promise.native.js.flow @@ -0,0 +1,26 @@ +/** + * + * Copyright 2013-2016 Facebook, Inc. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * This module wraps and augments the minimally ES6-compliant Promise + * implementation provided by the promise npm package. + * + */ + +'use strict'; + +var Promise = require('promise/setimmediate/es6-extensions'); +require('promise/setimmediate/done'); + +/** + * Handle either fulfillment or rejection with the same callback. + */ +Promise.prototype.finally = function (onSettled) { + return this.then(onSettled, onSettled); +}; + +module.exports = Promise;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/PromiseMap.js b/node_modules/fbjs/lib/PromiseMap.js new file mode 100644 index 000000000..63973c514 --- /dev/null +++ b/node_modules/fbjs/lib/PromiseMap.js @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Deferred = require('./Deferred'); + +var invariant = require('./invariant'); + +/** + * A map of asynchronous values that can be get or set in any order. Unlike a + * normal map, setting the value for a particular key more than once throws. + * Also unlike a normal map, a key can either be resolved or rejected. + */ + +var PromiseMap = function () { + function PromiseMap() { + _classCallCheck(this, PromiseMap); + + this._deferred = {}; + } + + PromiseMap.prototype.get = function get(key) { + return getDeferred(this._deferred, key).getPromise(); + }; + + PromiseMap.prototype.resolveKey = function resolveKey(key, value) { + var entry = getDeferred(this._deferred, key); + !!entry.isSettled() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'PromiseMap: Already settled `%s`.', key) : invariant(false) : void 0; + entry.resolve(value); + }; + + PromiseMap.prototype.rejectKey = function rejectKey(key, reason) { + var entry = getDeferred(this._deferred, key); + !!entry.isSettled() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'PromiseMap: Already settled `%s`.', key) : invariant(false) : void 0; + entry.reject(reason); + }; + + return PromiseMap; +}(); + +function getDeferred(entries, key) { + if (!entries.hasOwnProperty(key)) { + entries[key] = new Deferred(); + } + return entries[key]; +} + +module.exports = PromiseMap;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/PromiseMap.js.flow b/node_modules/fbjs/lib/PromiseMap.js.flow new file mode 100644 index 000000000..d87f1ceb9 --- /dev/null +++ b/node_modules/fbjs/lib/PromiseMap.js.flow @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule PromiseMap + * @flow + */ + +'use strict'; + +const Deferred = require('./Deferred'); + +const invariant = require('./invariant'); + +/** + * A map of asynchronous values that can be get or set in any order. Unlike a + * normal map, setting the value for a particular key more than once throws. + * Also unlike a normal map, a key can either be resolved or rejected. + */ +class PromiseMap<Tvalue, Treason> { + _deferred: { [key: string]: Deferred<any, any> }; + + constructor() { + this._deferred = {}; + } + + get(key: string): Promise<any> { + return getDeferred(this._deferred, key).getPromise(); + } + + resolveKey(key: string, value: Tvalue): void { + const entry = getDeferred(this._deferred, key); + invariant(!entry.isSettled(), 'PromiseMap: Already settled `%s`.', key); + entry.resolve(value); + } + + rejectKey(key: string, reason: Treason): void { + const entry = getDeferred(this._deferred, key); + invariant(!entry.isSettled(), 'PromiseMap: Already settled `%s`.', key); + entry.reject(reason); + } +} + +function getDeferred(entries: { [key: string]: Deferred<any, any> }, key: string): Deferred<any, any> { + if (!entries.hasOwnProperty(key)) { + entries[key] = new Deferred(); + } + return entries[key]; +} + +module.exports = PromiseMap;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Scroll.js b/node_modules/fbjs/lib/Scroll.js new file mode 100644 index 000000000..6159e2943 --- /dev/null +++ b/node_modules/fbjs/lib/Scroll.js @@ -0,0 +1,85 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +/** + * @param {DOMElement} element + * @param {DOMDocument} doc + * @return {boolean} + */ +function _isViewportScrollElement(element, doc) { + return !!doc && (element === doc.documentElement || element === doc.body); +} + +/** + * Scroll Module. This class contains 4 simple static functions + * to be used to access Element.scrollTop/scrollLeft properties. + * To solve the inconsistencies between browsers when either + * document.body or document.documentElement is supplied, + * below logic will be used to alleviate the issue: + * + * 1. If 'element' is either 'document.body' or 'document.documentElement, + * get whichever element's 'scroll{Top,Left}' is larger. + * 2. If 'element' is either 'document.body' or 'document.documentElement', + * set the 'scroll{Top,Left}' on both elements. + */ + +var Scroll = { + /** + * @param {DOMElement} element + * @return {number} + */ + getTop: function getTop(element) { + var doc = element.ownerDocument; + return _isViewportScrollElement(element, doc) ? + // In practice, they will either both have the same value, + // or one will be zero and the other will be the scroll position + // of the viewport. So we can use `X || Y` instead of `Math.max(X, Y)` + doc.body.scrollTop || doc.documentElement.scrollTop : element.scrollTop; + }, + + /** + * @param {DOMElement} element + * @param {number} newTop + */ + setTop: function setTop(element, newTop) { + var doc = element.ownerDocument; + if (_isViewportScrollElement(element, doc)) { + doc.body.scrollTop = doc.documentElement.scrollTop = newTop; + } else { + element.scrollTop = newTop; + } + }, + + /** + * @param {DOMElement} element + * @return {number} + */ + getLeft: function getLeft(element) { + var doc = element.ownerDocument; + return _isViewportScrollElement(element, doc) ? doc.body.scrollLeft || doc.documentElement.scrollLeft : element.scrollLeft; + }, + + /** + * @param {DOMElement} element + * @param {number} newLeft + */ + setLeft: function setLeft(element, newLeft) { + var doc = element.ownerDocument; + if (_isViewportScrollElement(element, doc)) { + doc.body.scrollLeft = doc.documentElement.scrollLeft = newLeft; + } else { + element.scrollLeft = newLeft; + } + } +}; + +module.exports = Scroll;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Scroll.js.flow b/node_modules/fbjs/lib/Scroll.js.flow new file mode 100644 index 000000000..e3588c393 --- /dev/null +++ b/node_modules/fbjs/lib/Scroll.js.flow @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Scroll + */ + +/** + * @param {DOMElement} element + * @param {DOMDocument} doc + * @return {boolean} + */ +function _isViewportScrollElement(element, doc) { + return !!doc && (element === doc.documentElement || element === doc.body); +} + +/** + * Scroll Module. This class contains 4 simple static functions + * to be used to access Element.scrollTop/scrollLeft properties. + * To solve the inconsistencies between browsers when either + * document.body or document.documentElement is supplied, + * below logic will be used to alleviate the issue: + * + * 1. If 'element' is either 'document.body' or 'document.documentElement, + * get whichever element's 'scroll{Top,Left}' is larger. + * 2. If 'element' is either 'document.body' or 'document.documentElement', + * set the 'scroll{Top,Left}' on both elements. + */ + +const Scroll = { + /** + * @param {DOMElement} element + * @return {number} + */ + getTop: function (element) { + const doc = element.ownerDocument; + return _isViewportScrollElement(element, doc) ? + // In practice, they will either both have the same value, + // or one will be zero and the other will be the scroll position + // of the viewport. So we can use `X || Y` instead of `Math.max(X, Y)` + doc.body.scrollTop || doc.documentElement.scrollTop : element.scrollTop; + }, + + /** + * @param {DOMElement} element + * @param {number} newTop + */ + setTop: function (element, newTop) { + const doc = element.ownerDocument; + if (_isViewportScrollElement(element, doc)) { + doc.body.scrollTop = doc.documentElement.scrollTop = newTop; + } else { + element.scrollTop = newTop; + } + }, + + /** + * @param {DOMElement} element + * @return {number} + */ + getLeft: function (element) { + const doc = element.ownerDocument; + return _isViewportScrollElement(element, doc) ? doc.body.scrollLeft || doc.documentElement.scrollLeft : element.scrollLeft; + }, + + /** + * @param {DOMElement} element + * @param {number} newLeft + */ + setLeft: function (element, newLeft) { + const doc = element.ownerDocument; + if (_isViewportScrollElement(element, doc)) { + doc.body.scrollLeft = doc.documentElement.scrollLeft = newLeft; + } else { + element.scrollLeft = newLeft; + } + } +}; + +module.exports = Scroll;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Set.js b/node_modules/fbjs/lib/Set.js new file mode 100644 index 000000000..c0ff64a87 --- /dev/null +++ b/node_modules/fbjs/lib/Set.js @@ -0,0 +1,13 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +module.exports = require('core-js/library/es6/set');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Set.js.flow b/node_modules/fbjs/lib/Set.js.flow new file mode 100644 index 000000000..f566f70fb --- /dev/null +++ b/node_modules/fbjs/lib/Set.js.flow @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Set + */ + +module.exports = require('core-js/library/es6/set');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Style.js b/node_modules/fbjs/lib/Style.js new file mode 100644 index 000000000..c4b412dbc --- /dev/null +++ b/node_modules/fbjs/lib/Style.js @@ -0,0 +1,64 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var getStyleProperty = require('./getStyleProperty'); + +/** + * @param {DOMNode} element [description] + * @param {string} name Overflow style property name. + * @return {boolean} True if the supplied ndoe is scrollable. + */ +function _isNodeScrollable(element, name) { + var overflow = Style.get(element, name); + return overflow === 'auto' || overflow === 'scroll'; +} + +/** + * Utilities for querying and mutating style properties. + */ +var Style = { + /** + * Gets the style property for the supplied node. This will return either the + * computed style, if available, or the declared style. + * + * @param {DOMNode} node + * @param {string} name Style property name. + * @return {?string} Style property value. + */ + get: getStyleProperty, + + /** + * Determines the nearest ancestor of a node that is scrollable. + * + * NOTE: This can be expensive if used repeatedly or on a node nested deeply. + * + * @param {?DOMNode} node Node from which to start searching. + * @return {?DOMWindow|DOMElement} Scroll parent of the supplied node. + */ + getScrollParent: function getScrollParent(node) { + if (!node) { + return null; + } + var ownerDocument = node.ownerDocument; + while (node && node !== ownerDocument.body) { + if (_isNodeScrollable(node, 'overflow') || _isNodeScrollable(node, 'overflowY') || _isNodeScrollable(node, 'overflowX')) { + return node; + } + node = node.parentNode; + } + return ownerDocument.defaultView || ownerDocument.parentWindow; + } + +}; + +module.exports = Style;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/Style.js.flow b/node_modules/fbjs/lib/Style.js.flow new file mode 100644 index 000000000..125c4effa --- /dev/null +++ b/node_modules/fbjs/lib/Style.js.flow @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Style + * @typechecks + */ + +var getStyleProperty = require('./getStyleProperty'); + +/** + * @param {DOMNode} element [description] + * @param {string} name Overflow style property name. + * @return {boolean} True if the supplied ndoe is scrollable. + */ +function _isNodeScrollable(element, name) { + var overflow = Style.get(element, name); + return overflow === 'auto' || overflow === 'scroll'; +} + +/** + * Utilities for querying and mutating style properties. + */ +var Style = { + /** + * Gets the style property for the supplied node. This will return either the + * computed style, if available, or the declared style. + * + * @param {DOMNode} node + * @param {string} name Style property name. + * @return {?string} Style property value. + */ + get: getStyleProperty, + + /** + * Determines the nearest ancestor of a node that is scrollable. + * + * NOTE: This can be expensive if used repeatedly or on a node nested deeply. + * + * @param {?DOMNode} node Node from which to start searching. + * @return {?DOMWindow|DOMElement} Scroll parent of the supplied node. + */ + getScrollParent: function (node) { + if (!node) { + return null; + } + var ownerDocument = node.ownerDocument; + while (node && node !== ownerDocument.body) { + if (_isNodeScrollable(node, 'overflow') || _isNodeScrollable(node, 'overflowY') || _isNodeScrollable(node, 'overflowX')) { + return node; + } + node = node.parentNode; + } + return ownerDocument.defaultView || ownerDocument.parentWindow; + } + +}; + +module.exports = Style;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/TokenizeUtil.js b/node_modules/fbjs/lib/TokenizeUtil.js new file mode 100644 index 000000000..046bde62a --- /dev/null +++ b/node_modules/fbjs/lib/TokenizeUtil.js @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * @stub + * + */ + +'use strict'; + +// \u00a1-\u00b1\u00b4-\u00b8\u00ba\u00bb\u00bf +// is latin supplement punctuation except fractions and superscript +// numbers +// \u2010-\u2027\u2030-\u205e +// is punctuation from the general punctuation block: +// weird quotes, commas, bullets, dashes, etc. +// \u30fb\u3001\u3002\u3008-\u3011\u3014-\u301f +// is CJK punctuation +// \uff1a-\uff1f\uff01-\uff0f\uff3b-\uff40\uff5b-\uff65 +// is some full-width/half-width punctuation +// \u2E2E\u061f\u066a-\u066c\u061b\u060c\u060d\uFD3e\uFD3F +// is some Arabic punctuation marks +// \u1801\u0964\u104a\u104b +// is misc. other language punctuation marks + +var PUNCTUATION = '[.,+*?$|#{}()\'\\^\\-\\[\\]\\\\\\/!@%"~=<>_:;' + '\u30FB\u3001\u3002\u3008-\u3011\u3014-\u301F\uFF1A-\uFF1F\uFF01-\uFF0F' + '\uFF3B-\uFF40\uFF5B-\uFF65\u2E2E\u061F\u066A-\u066C\u061B\u060C\u060D' + '\uFD3E\uFD3F\u1801\u0964\u104A\u104B\u2010-\u2027\u2030-\u205E' + '\xA1-\xB1\xB4-\xB8\xBA\xBB\xBF]'; + +module.exports = { + getPunctuation: function getPunctuation() { + return PUNCTUATION; + } +};
\ No newline at end of file diff --git a/node_modules/fbjs/lib/TokenizeUtil.js.flow b/node_modules/fbjs/lib/TokenizeUtil.js.flow new file mode 100644 index 000000000..90a055ce3 --- /dev/null +++ b/node_modules/fbjs/lib/TokenizeUtil.js.flow @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule TokenizeUtil + * @typechecks + * @stub + * @flow + */ + +'use strict'; + +// \u00a1-\u00b1\u00b4-\u00b8\u00ba\u00bb\u00bf +// is latin supplement punctuation except fractions and superscript +// numbers +// \u2010-\u2027\u2030-\u205e +// is punctuation from the general punctuation block: +// weird quotes, commas, bullets, dashes, etc. +// \u30fb\u3001\u3002\u3008-\u3011\u3014-\u301f +// is CJK punctuation +// \uff1a-\uff1f\uff01-\uff0f\uff3b-\uff40\uff5b-\uff65 +// is some full-width/half-width punctuation +// \u2E2E\u061f\u066a-\u066c\u061b\u060c\u060d\uFD3e\uFD3F +// is some Arabic punctuation marks +// \u1801\u0964\u104a\u104b +// is misc. other language punctuation marks + +var PUNCTUATION = '[.,+*?$|#{}()\'\\^\\-\\[\\]\\\\\\/!@%"~=<>_:;' + '\u30fb\u3001\u3002\u3008-\u3011\u3014-\u301f\uff1a-\uff1f\uff01-\uff0f' + '\uff3b-\uff40\uff5b-\uff65\u2E2E\u061f\u066a-\u066c\u061b\u060c\u060d' + '\uFD3e\uFD3F\u1801\u0964\u104a\u104b\u2010-\u2027\u2030-\u205e' + '\u00a1-\u00b1\u00b4-\u00b8\u00ba\u00bb\u00bf]'; + +module.exports = { + getPunctuation: (): string => PUNCTUATION +};
\ No newline at end of file diff --git a/node_modules/fbjs/lib/TouchEventUtils.js b/node_modules/fbjs/lib/TouchEventUtils.js new file mode 100644 index 000000000..77b28eacc --- /dev/null +++ b/node_modules/fbjs/lib/TouchEventUtils.js @@ -0,0 +1,34 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +var TouchEventUtils = { + /** + * Utility function for common case of extracting out the primary touch from a + * touch event. + * - `touchEnd` events usually do not have the `touches` property. + * http://stackoverflow.com/questions/3666929/ + * mobile-sarai-touchend-event-not-firing-when-last-touch-is-removed + * + * @param {Event} nativeEvent Native event that may or may not be a touch. + * @return {TouchesObject?} an object with pageX and pageY or null. + */ + extractSingleTouch: function extractSingleTouch(nativeEvent) { + var touches = nativeEvent.touches; + var changedTouches = nativeEvent.changedTouches; + var hasTouches = touches && touches.length > 0; + var hasChangedTouches = changedTouches && changedTouches.length > 0; + + return !hasTouches && hasChangedTouches ? changedTouches[0] : hasTouches ? touches[0] : nativeEvent; + } +}; + +module.exports = TouchEventUtils;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/TouchEventUtils.js.flow b/node_modules/fbjs/lib/TouchEventUtils.js.flow new file mode 100644 index 000000000..b5a73ba63 --- /dev/null +++ b/node_modules/fbjs/lib/TouchEventUtils.js.flow @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule TouchEventUtils + */ + +const TouchEventUtils = { + /** + * Utility function for common case of extracting out the primary touch from a + * touch event. + * - `touchEnd` events usually do not have the `touches` property. + * http://stackoverflow.com/questions/3666929/ + * mobile-sarai-touchend-event-not-firing-when-last-touch-is-removed + * + * @param {Event} nativeEvent Native event that may or may not be a touch. + * @return {TouchesObject?} an object with pageX and pageY or null. + */ + extractSingleTouch: function (nativeEvent) { + const touches = nativeEvent.touches; + const changedTouches = nativeEvent.changedTouches; + const hasTouches = touches && touches.length > 0; + const hasChangedTouches = changedTouches && changedTouches.length > 0; + + return !hasTouches && hasChangedTouches ? changedTouches[0] : hasTouches ? touches[0] : nativeEvent; + } +}; + +module.exports = TouchEventUtils;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/URI.js b/node_modules/fbjs/lib/URI.js new file mode 100644 index 000000000..bf1bd2080 --- /dev/null +++ b/node_modules/fbjs/lib/URI.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var URI = function () { + function URI(uri) { + _classCallCheck(this, URI); + + this._uri = uri; + } + + URI.prototype.toString = function toString() { + return this._uri; + }; + + return URI; +}(); + +module.exports = URI;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/URI.js.flow b/node_modules/fbjs/lib/URI.js.flow new file mode 100644 index 000000000..5a901f1ca --- /dev/null +++ b/node_modules/fbjs/lib/URI.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule URI + * @flow + */ + +'use strict'; + +class URI { + _uri: string; + + constructor(uri: string) { + this._uri = uri; + } + + toString(): string { + return this._uri; + } +} + +module.exports = URI;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeBidi.js b/node_modules/fbjs/lib/UnicodeBidi.js new file mode 100644 index 000000000..58565762c --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeBidi.js @@ -0,0 +1,156 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/** + * Basic (stateless) API for text direction detection + * + * Part of our implementation of Unicode Bidirectional Algorithm (UBA) + * Unicode Standard Annex #9 (UAX9) + * http://www.unicode.org/reports/tr9/ + */ + +'use strict'; + +var UnicodeBidiDirection = require('./UnicodeBidiDirection'); + +var invariant = require('./invariant'); + +/** + * RegExp ranges of characters with a *Strong* Bidi_Class value. + * + * Data is based on DerivedBidiClass.txt in UCD version 7.0.0. + * + * NOTE: For performance reasons, we only support Unicode's + * Basic Multilingual Plane (BMP) for now. + */ +var RANGE_BY_BIDI_TYPE = { + + L: 'A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u01BA\u01BB' + '\u01BC-\u01BF\u01C0-\u01C3\u01C4-\u0293\u0294\u0295-\u02AF\u02B0-\u02B8' + '\u02BB-\u02C1\u02D0-\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376-\u0377' + '\u037A\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1' + '\u03A3-\u03F5\u03F7-\u0481\u0482\u048A-\u052F\u0531-\u0556\u0559' + '\u055A-\u055F\u0561-\u0587\u0589\u0903\u0904-\u0939\u093B\u093D' + '\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0950\u0958-\u0961\u0964-\u0965' + '\u0966-\u096F\u0970\u0971\u0972-\u0980\u0982-\u0983\u0985-\u098C' + '\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD' + '\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09CE\u09D7\u09DC-\u09DD' + '\u09DF-\u09E1\u09E6-\u09EF\u09F0-\u09F1\u09F4-\u09F9\u09FA\u0A03' + '\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33' + '\u0A35-\u0A36\u0A38-\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F' + '\u0A72-\u0A74\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0' + '\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0AD0' + '\u0AE0-\u0AE1\u0AE6-\u0AEF\u0AF0\u0B02-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10' + '\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40' + '\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F' + '\u0B70\u0B71\u0B72-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95' + '\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9' + '\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7' + '\u0BE6-\u0BEF\u0BF0-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10' + '\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C59\u0C60-\u0C61' + '\u0C66-\u0C6F\u0C7F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8' + '\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CBE\u0CBF\u0CC0-\u0CC4\u0CC6' + '\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF' + '\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D' + '\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D57\u0D60-\u0D61' + '\u0D66-\u0D6F\u0D70-\u0D75\u0D79\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96' + '\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF' + '\u0DE6-\u0DEF\u0DF2-\u0DF3\u0DF4\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45' + '\u0E46\u0E4F\u0E50-\u0E59\u0E5A-\u0E5B\u0E81-\u0E82\u0E84\u0E87-\u0E88' + '\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7' + '\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6' + '\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F01-\u0F03\u0F04-\u0F12\u0F13\u0F14' + '\u0F15-\u0F17\u0F1A-\u0F1F\u0F20-\u0F29\u0F2A-\u0F33\u0F34\u0F36\u0F38' + '\u0F3E-\u0F3F\u0F40-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C' + '\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FCF\u0FD0-\u0FD4\u0FD5-\u0FD8' + '\u0FD9-\u0FDA\u1000-\u102A\u102B-\u102C\u1031\u1038\u103B-\u103C\u103F' + '\u1040-\u1049\u104A-\u104F\u1050-\u1055\u1056-\u1057\u105A-\u105D\u1061' + '\u1062-\u1064\u1065-\u1066\u1067-\u106D\u106E-\u1070\u1075-\u1081' + '\u1083-\u1084\u1087-\u108C\u108E\u108F\u1090-\u1099\u109A-\u109C' + '\u109E-\u109F\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FB\u10FC' + '\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288' + '\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5' + '\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u1368' + '\u1369-\u137C\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166D-\u166E' + '\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EB-\u16ED\u16EE-\u16F0' + '\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1735-\u1736' + '\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5' + '\u17C7-\u17C8\u17D4-\u17D6\u17D7\u17D8-\u17DA\u17DC\u17E0-\u17E9' + '\u1810-\u1819\u1820-\u1842\u1843\u1844-\u1877\u1880-\u18A8\u18AA' + '\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930-\u1931' + '\u1933-\u1938\u1946-\u194F\u1950-\u196D\u1970-\u1974\u1980-\u19AB' + '\u19B0-\u19C0\u19C1-\u19C7\u19C8-\u19C9\u19D0-\u19D9\u19DA\u1A00-\u1A16' + '\u1A19-\u1A1A\u1A1E-\u1A1F\u1A20-\u1A54\u1A55\u1A57\u1A61\u1A63-\u1A64' + '\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA7\u1AA8-\u1AAD' + '\u1B04\u1B05-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B45-\u1B4B' + '\u1B50-\u1B59\u1B5A-\u1B60\u1B61-\u1B6A\u1B74-\u1B7C\u1B82\u1B83-\u1BA0' + '\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAE-\u1BAF\u1BB0-\u1BB9\u1BBA-\u1BE5\u1BE7' + '\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1BFC-\u1BFF\u1C00-\u1C23\u1C24-\u1C2B' + '\u1C34-\u1C35\u1C3B-\u1C3F\u1C40-\u1C49\u1C4D-\u1C4F\u1C50-\u1C59' + '\u1C5A-\u1C77\u1C78-\u1C7D\u1C7E-\u1C7F\u1CC0-\u1CC7\u1CD3\u1CE1' + '\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF2-\u1CF3\u1CF5-\u1CF6\u1D00-\u1D2B' + '\u1D2C-\u1D6A\u1D6B-\u1D77\u1D78\u1D79-\u1D9A\u1D9B-\u1DBF\u1E00-\u1F15' + '\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D' + '\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC' + '\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E' + '\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D' + '\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2135-\u2138\u2139' + '\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2182\u2183-\u2184' + '\u2185-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF' + '\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C7B\u2C7C-\u2C7D\u2C7E-\u2CE4' + '\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F' + '\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE' + '\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005\u3006\u3007' + '\u3021-\u3029\u302E-\u302F\u3031-\u3035\u3038-\u303A\u303B\u303C' + '\u3041-\u3096\u309D-\u309E\u309F\u30A1-\u30FA\u30FC-\u30FE\u30FF' + '\u3105-\u312D\u3131-\u318E\u3190-\u3191\u3192-\u3195\u3196-\u319F' + '\u31A0-\u31BA\u31F0-\u31FF\u3200-\u321C\u3220-\u3229\u322A-\u3247' + '\u3248-\u324F\u3260-\u327B\u327F\u3280-\u3289\u328A-\u32B0\u32C0-\u32CB' + '\u32D0-\u32FE\u3300-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DB5' + '\u4E00-\u9FCC\uA000-\uA014\uA015\uA016-\uA48C\uA4D0-\uA4F7\uA4F8-\uA4FD' + '\uA4FE-\uA4FF\uA500-\uA60B\uA60C\uA610-\uA61F\uA620-\uA629\uA62A-\uA62B' + '\uA640-\uA66D\uA66E\uA680-\uA69B\uA69C-\uA69D\uA6A0-\uA6E5\uA6E6-\uA6EF' + '\uA6F2-\uA6F7\uA722-\uA76F\uA770\uA771-\uA787\uA789-\uA78A\uA78B-\uA78E' + '\uA790-\uA7AD\uA7B0-\uA7B1\uA7F7\uA7F8-\uA7F9\uA7FA\uA7FB-\uA801' + '\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA823-\uA824\uA827\uA830-\uA835' + '\uA836-\uA837\uA840-\uA873\uA880-\uA881\uA882-\uA8B3\uA8B4-\uA8C3' + '\uA8CE-\uA8CF\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8F8-\uA8FA\uA8FB\uA900-\uA909' + '\uA90A-\uA925\uA92E-\uA92F\uA930-\uA946\uA952-\uA953\uA95F\uA960-\uA97C' + '\uA983\uA984-\uA9B2\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uA9C1-\uA9CD' + '\uA9CF\uA9D0-\uA9D9\uA9DE-\uA9DF\uA9E0-\uA9E4\uA9E6\uA9E7-\uA9EF' + '\uA9F0-\uA9F9\uA9FA-\uA9FE\uAA00-\uAA28\uAA2F-\uAA30\uAA33-\uAA34' + '\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uAA60-\uAA6F' + '\uAA70\uAA71-\uAA76\uAA77-\uAA79\uAA7A\uAA7B\uAA7D\uAA7E-\uAAAF\uAAB1' + '\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAADD\uAADE-\uAADF' + '\uAAE0-\uAAEA\uAAEB\uAAEE-\uAAEF\uAAF0-\uAAF1\uAAF2\uAAF3-\uAAF4\uAAF5' + '\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E' + '\uAB30-\uAB5A\uAB5B\uAB5C-\uAB5F\uAB64-\uAB65\uABC0-\uABE2\uABE3-\uABE4' + '\uABE6-\uABE7\uABE9-\uABEA\uABEB\uABEC\uABF0-\uABF9\uAC00-\uD7A3' + '\uD7B0-\uD7C6\uD7CB-\uD7FB\uE000-\uF8FF\uF900-\uFA6D\uFA70-\uFAD9' + '\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFF6F\uFF70' + '\uFF71-\uFF9D\uFF9E-\uFF9F\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF' + '\uFFD2-\uFFD7\uFFDA-\uFFDC', + + R: '\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05D0-\u05EA\u05EB-\u05EF' + '\u05F0-\u05F2\u05F3-\u05F4\u05F5-\u05FF\u07C0-\u07C9\u07CA-\u07EA' + '\u07F4-\u07F5\u07FA\u07FB-\u07FF\u0800-\u0815\u081A\u0824\u0828' + '\u082E-\u082F\u0830-\u083E\u083F\u0840-\u0858\u085C-\u085D\u085E' + '\u085F-\u089F\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB37\uFB38-\uFB3C' + '\uFB3D\uFB3E\uFB3F\uFB40-\uFB41\uFB42\uFB43-\uFB44\uFB45\uFB46-\uFB4F', + + AL: '\u0608\u060B\u060D\u061B\u061C\u061D\u061E-\u061F\u0620-\u063F\u0640' + '\u0641-\u064A\u066D\u066E-\u066F\u0671-\u06D3\u06D4\u06D5\u06E5-\u06E6' + '\u06EE-\u06EF\u06FA-\u06FC\u06FD-\u06FE\u06FF\u0700-\u070D\u070E\u070F' + '\u0710\u0712-\u072F\u074B-\u074C\u074D-\u07A5\u07B1\u07B2-\u07BF' + '\u08A0-\u08B2\u08B3-\u08E3\uFB50-\uFBB1\uFBB2-\uFBC1\uFBC2-\uFBD2' + '\uFBD3-\uFD3D\uFD40-\uFD4F\uFD50-\uFD8F\uFD90-\uFD91\uFD92-\uFDC7' + '\uFDC8-\uFDCF\uFDF0-\uFDFB\uFDFC\uFDFE-\uFDFF\uFE70-\uFE74\uFE75' + '\uFE76-\uFEFC\uFEFD-\uFEFE' + +}; + +var REGEX_STRONG = new RegExp('[' + RANGE_BY_BIDI_TYPE.L + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']'); + +var REGEX_RTL = new RegExp('[' + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']'); + +/** + * Returns the first strong character (has Bidi_Class value of L, R, or AL). + * + * @param str A text block; e.g. paragraph, table cell, tag + * @return A character with strong bidi direction, or null if not found + */ +function firstStrongChar(str) { + var match = REGEX_STRONG.exec(str); + return match == null ? null : match[0]; +} + +/** + * Returns the direction of a block of text, based on the direction of its + * first strong character (has Bidi_Class value of L, R, or AL). + * + * @param str A text block; e.g. paragraph, table cell, tag + * @return The resolved direction + */ +function firstStrongCharDir(str) { + var strongChar = firstStrongChar(str); + if (strongChar == null) { + return UnicodeBidiDirection.NEUTRAL; + } + return REGEX_RTL.exec(strongChar) ? UnicodeBidiDirection.RTL : UnicodeBidiDirection.LTR; +} + +/** + * Returns the direction of a block of text, based on the direction of its + * first strong character (has Bidi_Class value of L, R, or AL), or a fallback + * direction, if no strong character is found. + * + * This function is supposed to be used in respect to Higher-Level Protocol + * rule HL1. (http://www.unicode.org/reports/tr9/#HL1) + * + * @param str A text block; e.g. paragraph, table cell, tag + * @param fallback Fallback direction, used if no strong direction detected + * for the block (default = NEUTRAL) + * @return The resolved direction + */ +function resolveBlockDir(str, fallback) { + fallback = fallback || UnicodeBidiDirection.NEUTRAL; + if (!str.length) { + return fallback; + } + var blockDir = firstStrongCharDir(str); + return blockDir === UnicodeBidiDirection.NEUTRAL ? fallback : blockDir; +} + +/** + * Returns the direction of a block of text, based on the direction of its + * first strong character (has Bidi_Class value of L, R, or AL), or a fallback + * direction, if no strong character is found. + * + * NOTE: This function is similar to resolveBlockDir(), but uses the global + * direction as the fallback, so it *always* returns a Strong direction, + * making it useful for integration in places that you need to make the final + * decision, like setting some CSS class. + * + * This function is supposed to be used in respect to Higher-Level Protocol + * rule HL1. (http://www.unicode.org/reports/tr9/#HL1) + * + * @param str A text block; e.g. paragraph, table cell + * @param strongFallback Fallback direction, used if no strong direction + * detected for the block (default = global direction) + * @return The resolved Strong direction + */ +function getDirection(str, strongFallback) { + if (!strongFallback) { + strongFallback = UnicodeBidiDirection.getGlobalDir(); + } + !UnicodeBidiDirection.isStrong(strongFallback) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Fallback direction must be a strong direction') : invariant(false) : void 0; + return resolveBlockDir(str, strongFallback); +} + +/** + * Returns true if getDirection(arguments...) returns LTR. + * + * @param str A text block; e.g. paragraph, table cell + * @param strongFallback Fallback direction, used if no strong direction + * detected for the block (default = global direction) + * @return True if the resolved direction is LTR + */ +function isDirectionLTR(str, strongFallback) { + return getDirection(str, strongFallback) === UnicodeBidiDirection.LTR; +} + +/** + * Returns true if getDirection(arguments...) returns RTL. + * + * @param str A text block; e.g. paragraph, table cell + * @param strongFallback Fallback direction, used if no strong direction + * detected for the block (default = global direction) + * @return True if the resolved direction is RTL + */ +function isDirectionRTL(str, strongFallback) { + return getDirection(str, strongFallback) === UnicodeBidiDirection.RTL; +} + +var UnicodeBidi = { + firstStrongChar: firstStrongChar, + firstStrongCharDir: firstStrongCharDir, + resolveBlockDir: resolveBlockDir, + getDirection: getDirection, + isDirectionLTR: isDirectionLTR, + isDirectionRTL: isDirectionRTL +}; + +module.exports = UnicodeBidi;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeBidi.js.flow b/node_modules/fbjs/lib/UnicodeBidi.js.flow new file mode 100644 index 000000000..42ac99587 --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeBidi.js.flow @@ -0,0 +1,159 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UnicodeBidi + * @typechecks + * @flow + */ + +/** + * Basic (stateless) API for text direction detection + * + * Part of our implementation of Unicode Bidirectional Algorithm (UBA) + * Unicode Standard Annex #9 (UAX9) + * http://www.unicode.org/reports/tr9/ + */ + +'use strict'; + +const UnicodeBidiDirection = require('./UnicodeBidiDirection'); + +const invariant = require('./invariant'); + +import type { BidiDirection } from './UnicodeBidiDirection'; + +/** + * RegExp ranges of characters with a *Strong* Bidi_Class value. + * + * Data is based on DerivedBidiClass.txt in UCD version 7.0.0. + * + * NOTE: For performance reasons, we only support Unicode's + * Basic Multilingual Plane (BMP) for now. + */ +const RANGE_BY_BIDI_TYPE = { + + L: 'A-Za-z\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u01BA\u01BB' + '\u01BC-\u01BF\u01C0-\u01C3\u01C4-\u0293\u0294\u0295-\u02AF\u02B0-\u02B8' + '\u02BB-\u02C1\u02D0-\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376-\u0377' + '\u037A\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1' + '\u03A3-\u03F5\u03F7-\u0481\u0482\u048A-\u052F\u0531-\u0556\u0559' + '\u055A-\u055F\u0561-\u0587\u0589\u0903\u0904-\u0939\u093B\u093D' + '\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0950\u0958-\u0961\u0964-\u0965' + '\u0966-\u096F\u0970\u0971\u0972-\u0980\u0982-\u0983\u0985-\u098C' + '\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD' + '\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09CE\u09D7\u09DC-\u09DD' + '\u09DF-\u09E1\u09E6-\u09EF\u09F0-\u09F1\u09F4-\u09F9\u09FA\u0A03' + '\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33' + '\u0A35-\u0A36\u0A38-\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F' + '\u0A72-\u0A74\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0' + '\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0AD0' + '\u0AE0-\u0AE1\u0AE6-\u0AEF\u0AF0\u0B02-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10' + '\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40' + '\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F' + '\u0B70\u0B71\u0B72-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95' + '\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9' + '\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7' + '\u0BE6-\u0BEF\u0BF0-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10' + '\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C59\u0C60-\u0C61' + '\u0C66-\u0C6F\u0C7F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8' + '\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CBE\u0CBF\u0CC0-\u0CC4\u0CC6' + '\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF' + '\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D' + '\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D57\u0D60-\u0D61' + '\u0D66-\u0D6F\u0D70-\u0D75\u0D79\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96' + '\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF' + '\u0DE6-\u0DEF\u0DF2-\u0DF3\u0DF4\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45' + '\u0E46\u0E4F\u0E50-\u0E59\u0E5A-\u0E5B\u0E81-\u0E82\u0E84\u0E87-\u0E88' + '\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7' + '\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6' + '\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F01-\u0F03\u0F04-\u0F12\u0F13\u0F14' + '\u0F15-\u0F17\u0F1A-\u0F1F\u0F20-\u0F29\u0F2A-\u0F33\u0F34\u0F36\u0F38' + '\u0F3E-\u0F3F\u0F40-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C' + '\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FCF\u0FD0-\u0FD4\u0FD5-\u0FD8' + '\u0FD9-\u0FDA\u1000-\u102A\u102B-\u102C\u1031\u1038\u103B-\u103C\u103F' + '\u1040-\u1049\u104A-\u104F\u1050-\u1055\u1056-\u1057\u105A-\u105D\u1061' + '\u1062-\u1064\u1065-\u1066\u1067-\u106D\u106E-\u1070\u1075-\u1081' + '\u1083-\u1084\u1087-\u108C\u108E\u108F\u1090-\u1099\u109A-\u109C' + '\u109E-\u109F\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FB\u10FC' + '\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288' + '\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5' + '\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u1368' + '\u1369-\u137C\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166D-\u166E' + '\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EB-\u16ED\u16EE-\u16F0' + '\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1735-\u1736' + '\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5' + '\u17C7-\u17C8\u17D4-\u17D6\u17D7\u17D8-\u17DA\u17DC\u17E0-\u17E9' + '\u1810-\u1819\u1820-\u1842\u1843\u1844-\u1877\u1880-\u18A8\u18AA' + '\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930-\u1931' + '\u1933-\u1938\u1946-\u194F\u1950-\u196D\u1970-\u1974\u1980-\u19AB' + '\u19B0-\u19C0\u19C1-\u19C7\u19C8-\u19C9\u19D0-\u19D9\u19DA\u1A00-\u1A16' + '\u1A19-\u1A1A\u1A1E-\u1A1F\u1A20-\u1A54\u1A55\u1A57\u1A61\u1A63-\u1A64' + '\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA7\u1AA8-\u1AAD' + '\u1B04\u1B05-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B45-\u1B4B' + '\u1B50-\u1B59\u1B5A-\u1B60\u1B61-\u1B6A\u1B74-\u1B7C\u1B82\u1B83-\u1BA0' + '\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAE-\u1BAF\u1BB0-\u1BB9\u1BBA-\u1BE5\u1BE7' + '\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1BFC-\u1BFF\u1C00-\u1C23\u1C24-\u1C2B' + '\u1C34-\u1C35\u1C3B-\u1C3F\u1C40-\u1C49\u1C4D-\u1C4F\u1C50-\u1C59' + '\u1C5A-\u1C77\u1C78-\u1C7D\u1C7E-\u1C7F\u1CC0-\u1CC7\u1CD3\u1CE1' + '\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF2-\u1CF3\u1CF5-\u1CF6\u1D00-\u1D2B' + '\u1D2C-\u1D6A\u1D6B-\u1D77\u1D78\u1D79-\u1D9A\u1D9B-\u1DBF\u1E00-\u1F15' + '\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D' + '\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC' + '\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E' + '\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D' + '\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2135-\u2138\u2139' + '\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2182\u2183-\u2184' + '\u2185-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF' + '\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C7B\u2C7C-\u2C7D\u2C7E-\u2CE4' + '\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F' + '\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE' + '\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005\u3006\u3007' + '\u3021-\u3029\u302E-\u302F\u3031-\u3035\u3038-\u303A\u303B\u303C' + '\u3041-\u3096\u309D-\u309E\u309F\u30A1-\u30FA\u30FC-\u30FE\u30FF' + '\u3105-\u312D\u3131-\u318E\u3190-\u3191\u3192-\u3195\u3196-\u319F' + '\u31A0-\u31BA\u31F0-\u31FF\u3200-\u321C\u3220-\u3229\u322A-\u3247' + '\u3248-\u324F\u3260-\u327B\u327F\u3280-\u3289\u328A-\u32B0\u32C0-\u32CB' + '\u32D0-\u32FE\u3300-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DB5' + '\u4E00-\u9FCC\uA000-\uA014\uA015\uA016-\uA48C\uA4D0-\uA4F7\uA4F8-\uA4FD' + '\uA4FE-\uA4FF\uA500-\uA60B\uA60C\uA610-\uA61F\uA620-\uA629\uA62A-\uA62B' + '\uA640-\uA66D\uA66E\uA680-\uA69B\uA69C-\uA69D\uA6A0-\uA6E5\uA6E6-\uA6EF' + '\uA6F2-\uA6F7\uA722-\uA76F\uA770\uA771-\uA787\uA789-\uA78A\uA78B-\uA78E' + '\uA790-\uA7AD\uA7B0-\uA7B1\uA7F7\uA7F8-\uA7F9\uA7FA\uA7FB-\uA801' + '\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA823-\uA824\uA827\uA830-\uA835' + '\uA836-\uA837\uA840-\uA873\uA880-\uA881\uA882-\uA8B3\uA8B4-\uA8C3' + '\uA8CE-\uA8CF\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8F8-\uA8FA\uA8FB\uA900-\uA909' + '\uA90A-\uA925\uA92E-\uA92F\uA930-\uA946\uA952-\uA953\uA95F\uA960-\uA97C' + '\uA983\uA984-\uA9B2\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uA9C1-\uA9CD' + '\uA9CF\uA9D0-\uA9D9\uA9DE-\uA9DF\uA9E0-\uA9E4\uA9E6\uA9E7-\uA9EF' + '\uA9F0-\uA9F9\uA9FA-\uA9FE\uAA00-\uAA28\uAA2F-\uAA30\uAA33-\uAA34' + '\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uAA60-\uAA6F' + '\uAA70\uAA71-\uAA76\uAA77-\uAA79\uAA7A\uAA7B\uAA7D\uAA7E-\uAAAF\uAAB1' + '\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAADD\uAADE-\uAADF' + '\uAAE0-\uAAEA\uAAEB\uAAEE-\uAAEF\uAAF0-\uAAF1\uAAF2\uAAF3-\uAAF4\uAAF5' + '\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E' + '\uAB30-\uAB5A\uAB5B\uAB5C-\uAB5F\uAB64-\uAB65\uABC0-\uABE2\uABE3-\uABE4' + '\uABE6-\uABE7\uABE9-\uABEA\uABEB\uABEC\uABF0-\uABF9\uAC00-\uD7A3' + '\uD7B0-\uD7C6\uD7CB-\uD7FB\uE000-\uF8FF\uF900-\uFA6D\uFA70-\uFAD9' + '\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFF6F\uFF70' + '\uFF71-\uFF9D\uFF9E-\uFF9F\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF' + '\uFFD2-\uFFD7\uFFDA-\uFFDC', + + R: '\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05D0-\u05EA\u05EB-\u05EF' + '\u05F0-\u05F2\u05F3-\u05F4\u05F5-\u05FF\u07C0-\u07C9\u07CA-\u07EA' + '\u07F4-\u07F5\u07FA\u07FB-\u07FF\u0800-\u0815\u081A\u0824\u0828' + '\u082E-\u082F\u0830-\u083E\u083F\u0840-\u0858\u085C-\u085D\u085E' + '\u085F-\u089F\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB37\uFB38-\uFB3C' + '\uFB3D\uFB3E\uFB3F\uFB40-\uFB41\uFB42\uFB43-\uFB44\uFB45\uFB46-\uFB4F', + + AL: '\u0608\u060B\u060D\u061B\u061C\u061D\u061E-\u061F\u0620-\u063F\u0640' + '\u0641-\u064A\u066D\u066E-\u066F\u0671-\u06D3\u06D4\u06D5\u06E5-\u06E6' + '\u06EE-\u06EF\u06FA-\u06FC\u06FD-\u06FE\u06FF\u0700-\u070D\u070E\u070F' + '\u0710\u0712-\u072F\u074B-\u074C\u074D-\u07A5\u07B1\u07B2-\u07BF' + '\u08A0-\u08B2\u08B3-\u08E3\uFB50-\uFBB1\uFBB2-\uFBC1\uFBC2-\uFBD2' + '\uFBD3-\uFD3D\uFD40-\uFD4F\uFD50-\uFD8F\uFD90-\uFD91\uFD92-\uFDC7' + '\uFDC8-\uFDCF\uFDF0-\uFDFB\uFDFC\uFDFE-\uFDFF\uFE70-\uFE74\uFE75' + '\uFE76-\uFEFC\uFEFD-\uFEFE' + +}; + +const REGEX_STRONG = new RegExp('[' + RANGE_BY_BIDI_TYPE.L + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']'); + +const REGEX_RTL = new RegExp('[' + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']'); + +/** + * Returns the first strong character (has Bidi_Class value of L, R, or AL). + * + * @param str A text block; e.g. paragraph, table cell, tag + * @return A character with strong bidi direction, or null if not found + */ +function firstStrongChar(str: string): ?string { + const match = REGEX_STRONG.exec(str); + return match == null ? null : match[0]; +} + +/** + * Returns the direction of a block of text, based on the direction of its + * first strong character (has Bidi_Class value of L, R, or AL). + * + * @param str A text block; e.g. paragraph, table cell, tag + * @return The resolved direction + */ +function firstStrongCharDir(str: string): BidiDirection { + const strongChar = firstStrongChar(str); + if (strongChar == null) { + return UnicodeBidiDirection.NEUTRAL; + } + return REGEX_RTL.exec(strongChar) ? UnicodeBidiDirection.RTL : UnicodeBidiDirection.LTR; +} + +/** + * Returns the direction of a block of text, based on the direction of its + * first strong character (has Bidi_Class value of L, R, or AL), or a fallback + * direction, if no strong character is found. + * + * This function is supposed to be used in respect to Higher-Level Protocol + * rule HL1. (http://www.unicode.org/reports/tr9/#HL1) + * + * @param str A text block; e.g. paragraph, table cell, tag + * @param fallback Fallback direction, used if no strong direction detected + * for the block (default = NEUTRAL) + * @return The resolved direction + */ +function resolveBlockDir(str: string, fallback: ?BidiDirection): BidiDirection { + fallback = fallback || UnicodeBidiDirection.NEUTRAL; + if (!str.length) { + return fallback; + } + const blockDir = firstStrongCharDir(str); + return blockDir === UnicodeBidiDirection.NEUTRAL ? fallback : blockDir; +} + +/** + * Returns the direction of a block of text, based on the direction of its + * first strong character (has Bidi_Class value of L, R, or AL), or a fallback + * direction, if no strong character is found. + * + * NOTE: This function is similar to resolveBlockDir(), but uses the global + * direction as the fallback, so it *always* returns a Strong direction, + * making it useful for integration in places that you need to make the final + * decision, like setting some CSS class. + * + * This function is supposed to be used in respect to Higher-Level Protocol + * rule HL1. (http://www.unicode.org/reports/tr9/#HL1) + * + * @param str A text block; e.g. paragraph, table cell + * @param strongFallback Fallback direction, used if no strong direction + * detected for the block (default = global direction) + * @return The resolved Strong direction + */ +function getDirection(str: string, strongFallback: ?BidiDirection): BidiDirection { + if (!strongFallback) { + strongFallback = UnicodeBidiDirection.getGlobalDir(); + } + invariant(UnicodeBidiDirection.isStrong(strongFallback), 'Fallback direction must be a strong direction'); + return resolveBlockDir(str, strongFallback); +} + +/** + * Returns true if getDirection(arguments...) returns LTR. + * + * @param str A text block; e.g. paragraph, table cell + * @param strongFallback Fallback direction, used if no strong direction + * detected for the block (default = global direction) + * @return True if the resolved direction is LTR + */ +function isDirectionLTR(str: string, strongFallback: ?BidiDirection): boolean { + return getDirection(str, strongFallback) === UnicodeBidiDirection.LTR; +} + +/** + * Returns true if getDirection(arguments...) returns RTL. + * + * @param str A text block; e.g. paragraph, table cell + * @param strongFallback Fallback direction, used if no strong direction + * detected for the block (default = global direction) + * @return True if the resolved direction is RTL + */ +function isDirectionRTL(str: string, strongFallback: ?BidiDirection): boolean { + return getDirection(str, strongFallback) === UnicodeBidiDirection.RTL; +} + +const UnicodeBidi = { + firstStrongChar: firstStrongChar, + firstStrongCharDir: firstStrongCharDir, + resolveBlockDir: resolveBlockDir, + getDirection: getDirection, + isDirectionLTR: isDirectionLTR, + isDirectionRTL: isDirectionRTL +}; + +module.exports = UnicodeBidi;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeBidiDirection.js b/node_modules/fbjs/lib/UnicodeBidiDirection.js new file mode 100644 index 000000000..c52c80732 --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeBidiDirection.js @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/** + * Constants to represent text directionality + * + * Also defines a *global* direciton, to be used in bidi algorithms as a + * default fallback direciton, when no better direction is found or provided. + * + * NOTE: Use `setGlobalDir()`, or update `initGlobalDir()`, to set the initial + * global direction value based on the application. + * + * Part of the implementation of Unicode Bidirectional Algorithm (UBA) + * Unicode Standard Annex #9 (UAX9) + * http://www.unicode.org/reports/tr9/ + */ + +'use strict'; + +var invariant = require('./invariant'); + +var NEUTRAL = 'NEUTRAL'; // No strong direction +var LTR = 'LTR'; // Left-to-Right direction +var RTL = 'RTL'; // Right-to-Left direction + +var globalDir = null; + +// == Helpers == + +/** + * Check if a directionality value is a Strong one + */ +function isStrong(dir) { + return dir === LTR || dir === RTL; +} + +/** + * Get string value to be used for `dir` HTML attribute or `direction` CSS + * property. + */ +function getHTMLDir(dir) { + !isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0; + return dir === LTR ? 'ltr' : 'rtl'; +} + +/** + * Get string value to be used for `dir` HTML attribute or `direction` CSS + * property, but returns null if `dir` has same value as `otherDir`. + * `null`. + */ +function getHTMLDirIfDifferent(dir, otherDir) { + !isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0; + !isStrong(otherDir) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`otherDir` must be a strong direction to be converted to HTML Direction') : invariant(false) : void 0; + return dir === otherDir ? null : getHTMLDir(dir); +} + +// == Global Direction == + +/** + * Set the global direction. + */ +function setGlobalDir(dir) { + globalDir = dir; +} + +/** + * Initialize the global direction + */ +function initGlobalDir() { + setGlobalDir(LTR); +} + +/** + * Get the global direction + */ +function getGlobalDir() { + if (!globalDir) { + this.initGlobalDir(); + } + !globalDir ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Global direction not set.') : invariant(false) : void 0; + return globalDir; +} + +var UnicodeBidiDirection = { + // Values + NEUTRAL: NEUTRAL, + LTR: LTR, + RTL: RTL, + // Helpers + isStrong: isStrong, + getHTMLDir: getHTMLDir, + getHTMLDirIfDifferent: getHTMLDirIfDifferent, + // Global Direction + setGlobalDir: setGlobalDir, + initGlobalDir: initGlobalDir, + getGlobalDir: getGlobalDir +}; + +module.exports = UnicodeBidiDirection;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeBidiDirection.js.flow b/node_modules/fbjs/lib/UnicodeBidiDirection.js.flow new file mode 100644 index 000000000..7d3964b95 --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeBidiDirection.js.flow @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UnicodeBidiDirection + * @typechecks + * @flow + */ + +/** + * Constants to represent text directionality + * + * Also defines a *global* direciton, to be used in bidi algorithms as a + * default fallback direciton, when no better direction is found or provided. + * + * NOTE: Use `setGlobalDir()`, or update `initGlobalDir()`, to set the initial + * global direction value based on the application. + * + * Part of the implementation of Unicode Bidirectional Algorithm (UBA) + * Unicode Standard Annex #9 (UAX9) + * http://www.unicode.org/reports/tr9/ + */ + +'use strict'; + +const invariant = require('./invariant'); + +export type BidiDirection = 'LTR' | 'RTL' | 'NEUTRAL'; +export type HTMLDir = 'ltr' | 'rtl'; + +const NEUTRAL = 'NEUTRAL'; // No strong direction +const LTR = 'LTR'; // Left-to-Right direction +const RTL = 'RTL'; // Right-to-Left direction + +let globalDir: ?BidiDirection = null; + +// == Helpers == + +/** + * Check if a directionality value is a Strong one + */ +function isStrong(dir: BidiDirection): boolean { + return dir === LTR || dir === RTL; +} + +/** + * Get string value to be used for `dir` HTML attribute or `direction` CSS + * property. + */ +function getHTMLDir(dir: BidiDirection): HTMLDir { + invariant(isStrong(dir), '`dir` must be a strong direction to be converted to HTML Direction'); + return dir === LTR ? 'ltr' : 'rtl'; +} + +/** + * Get string value to be used for `dir` HTML attribute or `direction` CSS + * property, but returns null if `dir` has same value as `otherDir`. + * `null`. + */ +function getHTMLDirIfDifferent(dir: BidiDirection, otherDir: BidiDirection): ?HTMLDir { + invariant(isStrong(dir), '`dir` must be a strong direction to be converted to HTML Direction'); + invariant(isStrong(otherDir), '`otherDir` must be a strong direction to be converted to HTML Direction'); + return dir === otherDir ? null : getHTMLDir(dir); +} + +// == Global Direction == + +/** + * Set the global direction. + */ +function setGlobalDir(dir: BidiDirection): void { + globalDir = dir; +} + +/** + * Initialize the global direction + */ +function initGlobalDir(): void { + setGlobalDir(LTR); +} + +/** + * Get the global direction + */ +function getGlobalDir(): BidiDirection { + if (!globalDir) { + this.initGlobalDir(); + } + invariant(globalDir, 'Global direction not set.'); + return globalDir; +} + +const UnicodeBidiDirection = { + // Values + NEUTRAL, + LTR, + RTL, + // Helpers + isStrong, + getHTMLDir, + getHTMLDirIfDifferent, + // Global Direction + setGlobalDir, + initGlobalDir, + getGlobalDir +}; + +module.exports = UnicodeBidiDirection;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeBidiService.js b/node_modules/fbjs/lib/UnicodeBidiService.js new file mode 100644 index 000000000..f7189d8ee --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeBidiService.js @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/** + * Stateful API for text direction detection + * + * This class can be used in applications where you need to detect the + * direction of a sequence of text blocks, where each direction shall be used + * as the fallback direction for the next one. + * + * NOTE: A default direction, if not provided, is set based on the global + * direction, as defined by `UnicodeBidiDirection`. + * + * == Example == + * ``` + * var UnicodeBidiService = require('UnicodeBidiService'); + * + * var bidiService = new UnicodeBidiService(); + * + * ... + * + * bidiService.reset(); + * for (var para in paragraphs) { + * var dir = bidiService.getDirection(para); + * ... + * } + * ``` + * + * Part of our implementation of Unicode Bidirectional Algorithm (UBA) + * Unicode Standard Annex #9 (UAX9) + * http://www.unicode.org/reports/tr9/ + */ + +'use strict'; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var UnicodeBidi = require('./UnicodeBidi'); +var UnicodeBidiDirection = require('./UnicodeBidiDirection'); + +var invariant = require('./invariant'); + +var UnicodeBidiService = function () { + + /** + * Stateful class for paragraph direction detection + * + * @param defaultDir Default direction of the service + */ + function UnicodeBidiService(defaultDir) { + _classCallCheck(this, UnicodeBidiService); + + if (!defaultDir) { + defaultDir = UnicodeBidiDirection.getGlobalDir(); + } else { + !UnicodeBidiDirection.isStrong(defaultDir) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Default direction must be a strong direction (LTR or RTL)') : invariant(false) : void 0; + } + this._defaultDir = defaultDir; + this.reset(); + } + + /** + * Reset the internal state + * + * Instead of creating a new instance, you can just reset() your instance + * everytime you start a new loop. + */ + + + UnicodeBidiService.prototype.reset = function reset() { + this._lastDir = this._defaultDir; + }; + + /** + * Returns the direction of a block of text, and remembers it as the + * fall-back direction for the next paragraph. + * + * @param str A text block, e.g. paragraph, table cell, tag + * @return The resolved direction + */ + + + UnicodeBidiService.prototype.getDirection = function getDirection(str) { + this._lastDir = UnicodeBidi.getDirection(str, this._lastDir); + return this._lastDir; + }; + + return UnicodeBidiService; +}(); + +module.exports = UnicodeBidiService;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeBidiService.js.flow b/node_modules/fbjs/lib/UnicodeBidiService.js.flow new file mode 100644 index 000000000..236a2f3dd --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeBidiService.js.flow @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UnicodeBidiService + * @typechecks + * @flow + */ + +/** + * Stateful API for text direction detection + * + * This class can be used in applications where you need to detect the + * direction of a sequence of text blocks, where each direction shall be used + * as the fallback direction for the next one. + * + * NOTE: A default direction, if not provided, is set based on the global + * direction, as defined by `UnicodeBidiDirection`. + * + * == Example == + * ``` + * var UnicodeBidiService = require('UnicodeBidiService'); + * + * var bidiService = new UnicodeBidiService(); + * + * ... + * + * bidiService.reset(); + * for (var para in paragraphs) { + * var dir = bidiService.getDirection(para); + * ... + * } + * ``` + * + * Part of our implementation of Unicode Bidirectional Algorithm (UBA) + * Unicode Standard Annex #9 (UAX9) + * http://www.unicode.org/reports/tr9/ + */ + +'use strict'; + +const UnicodeBidi = require('./UnicodeBidi'); +const UnicodeBidiDirection = require('./UnicodeBidiDirection'); + +const invariant = require('./invariant'); + +import type { BidiDirection } from './UnicodeBidiDirection'; + +class UnicodeBidiService { + + _defaultDir: BidiDirection; + _lastDir: BidiDirection; + + /** + * Stateful class for paragraph direction detection + * + * @param defaultDir Default direction of the service + */ + constructor(defaultDir: ?BidiDirection) { + if (!defaultDir) { + defaultDir = UnicodeBidiDirection.getGlobalDir(); + } else { + invariant(UnicodeBidiDirection.isStrong(defaultDir), 'Default direction must be a strong direction (LTR or RTL)'); + } + this._defaultDir = defaultDir; + this.reset(); + } + + /** + * Reset the internal state + * + * Instead of creating a new instance, you can just reset() your instance + * everytime you start a new loop. + */ + reset(): void { + this._lastDir = this._defaultDir; + } + + /** + * Returns the direction of a block of text, and remembers it as the + * fall-back direction for the next paragraph. + * + * @param str A text block, e.g. paragraph, table cell, tag + * @return The resolved direction + */ + getDirection(str: string): BidiDirection { + this._lastDir = UnicodeBidi.getDirection(str, this._lastDir); + return this._lastDir; + } + +} + +module.exports = UnicodeBidiService;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeCJK.js b/node_modules/fbjs/lib/UnicodeCJK.js new file mode 100644 index 000000000..762fa7ebe --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeCJK.js @@ -0,0 +1,174 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/** + * Unicode algorithms for CJK (Chinese, Japanese, Korean) writing systems. + * + * Utilities for Hanzi/Kanji/Hanja logographs and Kanas (Katakana and Hiragana) + * syllables. + * + * For Korean Hangul see module `UnicodeHangulKorean`. + */ + +'use strict'; + +/** + * Latin + * + * NOTE: The code assumes these sets include only BMP characters. + */ + +var R_LATIN_ASCII = 'a-zA-Z'; +var R_LATIN_FULLWIDTH = '\uFF21-\uFF3A\uFF41-\uFF5A'; +var R_LATIN = R_LATIN_ASCII + R_LATIN_FULLWIDTH; + +/** + * Hiragana & Katakana + * + * NOTE: Some ranges include non-BMP characters. We do not support those ranges + * for now. + */ +var R_HIRAGANA = '\u3040-\u309F'; +var R_KATAKANA = '\u30A0-\u30FF'; +var R_KATAKANA_PHONETIC = '\u31F0-\u31FF'; +var R_KATAKANA_HALFWIDTH = '\uFF65-\uFF9F'; +// var R_KANA_SUPPLEMENT = '\U0001B000-\U0001B0FF'; +var R_KATAKANA_ALL = R_KATAKANA + R_KATAKANA_PHONETIC + R_KATAKANA_HALFWIDTH; +var R_KANA = R_HIRAGANA + R_KATAKANA_ALL; + +var I_HIRAGANA = [0x3040, 0x309F]; +var I_KATAKANA = [0x30A0, 0x30FF]; +var I_HIRAGANA_TO_KATAKANA = I_KATAKANA[0] - I_HIRAGANA[0]; + +/** + * Hanzi/Kanji/Hanja + * + * NOTE: Some ranges include non-BMP characters. We do not support those ranges + * for now. + */ +var R_IDEO_MAIN = '\u4E00-\u9FCF'; +var R_IDEO_EXT_A = '\u3400-\u4DBF'; +// var R_IDEO_EXT_B = '\U00020000-\U0002A6DF'; +// var R_IDEO_EXT_C = '\U0002A700-\U0002B73F'; +// var R_IDEO_EXT_D = '\U0002B740-\U0002B81F'; +var R_IDEO = R_IDEO_MAIN + R_IDEO_EXT_A; + +/** + * Hangul + */ +// var R_HANGUL_JAMO = '\u1100-\u11FF'; +// var R_HANGUL_JAMO_EXT_A = '\uA960-\uA97F'; +// var R_HANGUL_JAMO_EXT_B = '\uD7B0-\uD7FF'; +// var R_HANGUL_COMPATIBILITY = '\u3130-\u318F'; +// var R_HANGUL_COMP_HALFWIDTH = '\uFFA0-\uFFDF'; +var R_HANGUL_SYLLABLES = '\uAC00-\uD7AF'; + +/** + * Globals + */ +var R_IDEO_OR_SYLL = R_IDEO + R_KANA + R_HANGUL_SYLLABLES; + +var REGEX_IDEO = null; +var REGEX_KANA = null; +var REGEX_IDEO_OR_SYLL = null; +var REGEX_IS_KANA_WITH_TRAILING_LATIN = null; + +/** + * Whether the string includes any Katakana or Hiragana characters. + * + * @param {string} str + * @return {boolean} + */ +function hasKana(str) { + REGEX_KANA = REGEX_KANA || new RegExp('[' + R_KANA + ']'); + return REGEX_KANA.test(str); +} + +/** + * Whether the string includes any CJK Ideograph characters. + * + * @param {string} str + * @return {boolean} + */ +function hasIdeograph(str) { + REGEX_IDEO = REGEX_IDEO || new RegExp('[' + R_IDEO + ']'); + return REGEX_IDEO.test(str); +} + +/** + * Whether the string includes any CJK Ideograph or Syllable characters. + * + * @param {string} str + * @return {boolean} + */ +function hasIdeoOrSyll(str) { + REGEX_IDEO_OR_SYLL = REGEX_IDEO_OR_SYLL || new RegExp('[' + R_IDEO_OR_SYLL + ']'); + return REGEX_IDEO_OR_SYLL.test(str); +} + +/** + * @param {string} chr + * @output {string} + */ +function charCodeToKatakana(chr) { + var charCode = chr.charCodeAt(0); + return String.fromCharCode(charCode < I_HIRAGANA[0] || charCode > I_HIRAGANA[1] ? charCode : charCode + I_HIRAGANA_TO_KATAKANA); +} + +/** + * Replace any Hiragana character with the matching Katakana + * + * @param {string} str + * @output {string} + */ +function hiraganaToKatakana(str) { + if (!hasKana(str)) { + return str; + } + return str.split('').map(charCodeToKatakana).join(''); +} + +/** + * Whether the string is exactly a sequence of Kana characters followed by one + * Latin character. + * + * @param {string} str + * @output {string} + */ +function isKanaWithTrailingLatin(str) { + REGEX_IS_KANA_WITH_TRAILING_LATIN = REGEX_IS_KANA_WITH_TRAILING_LATIN || new RegExp('^' + '[' + R_KANA + ']+' + '[' + R_LATIN + ']' + '$'); + return REGEX_IS_KANA_WITH_TRAILING_LATIN.test(str); +} + +/** + * Drops the trailing Latin character from a string that is exactly a sequence + * of Kana characters followed by one Latin character. + * + * @param {string} str + * @output {string} + */ +function kanaRemoveTrailingLatin(str) { + if (isKanaWithTrailingLatin(str)) { + return str.substr(0, str.length - 1); + } + return str; +} + +var UnicodeCJK = { + hasKana: hasKana, + hasIdeograph: hasIdeograph, + hasIdeoOrSyll: hasIdeoOrSyll, + hiraganaToKatakana: hiraganaToKatakana, + isKanaWithTrailingLatin: isKanaWithTrailingLatin, + kanaRemoveTrailingLatin: kanaRemoveTrailingLatin +}; + +module.exports = UnicodeCJK;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeCJK.js.flow b/node_modules/fbjs/lib/UnicodeCJK.js.flow new file mode 100644 index 000000000..549e57efa --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeCJK.js.flow @@ -0,0 +1,175 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UnicodeCJK + * @typechecks + */ + +/** + * Unicode algorithms for CJK (Chinese, Japanese, Korean) writing systems. + * + * Utilities for Hanzi/Kanji/Hanja logographs and Kanas (Katakana and Hiragana) + * syllables. + * + * For Korean Hangul see module `UnicodeHangulKorean`. + */ + +'use strict'; + +/** + * Latin + * + * NOTE: The code assumes these sets include only BMP characters. + */ + +const R_LATIN_ASCII = 'a-zA-Z'; +const R_LATIN_FULLWIDTH = '\uFF21-\uFF3A\uFF41-\uFF5A'; +const R_LATIN = R_LATIN_ASCII + R_LATIN_FULLWIDTH; + +/** + * Hiragana & Katakana + * + * NOTE: Some ranges include non-BMP characters. We do not support those ranges + * for now. + */ +const R_HIRAGANA = '\u3040-\u309F'; +const R_KATAKANA = '\u30A0-\u30FF'; +const R_KATAKANA_PHONETIC = '\u31F0-\u31FF'; +const R_KATAKANA_HALFWIDTH = '\uFF65-\uFF9F'; +// var R_KANA_SUPPLEMENT = '\U0001B000-\U0001B0FF'; +const R_KATAKANA_ALL = R_KATAKANA + R_KATAKANA_PHONETIC + R_KATAKANA_HALFWIDTH; +const R_KANA = R_HIRAGANA + R_KATAKANA_ALL; + +const I_HIRAGANA = [0x3040, 0x309F]; +const I_KATAKANA = [0x30A0, 0x30FF]; +const I_HIRAGANA_TO_KATAKANA = I_KATAKANA[0] - I_HIRAGANA[0]; + +/** + * Hanzi/Kanji/Hanja + * + * NOTE: Some ranges include non-BMP characters. We do not support those ranges + * for now. + */ +const R_IDEO_MAIN = '\u4E00-\u9FCF'; +const R_IDEO_EXT_A = '\u3400-\u4DBF'; +// var R_IDEO_EXT_B = '\U00020000-\U0002A6DF'; +// var R_IDEO_EXT_C = '\U0002A700-\U0002B73F'; +// var R_IDEO_EXT_D = '\U0002B740-\U0002B81F'; +const R_IDEO = R_IDEO_MAIN + R_IDEO_EXT_A; + +/** + * Hangul + */ +// var R_HANGUL_JAMO = '\u1100-\u11FF'; +// var R_HANGUL_JAMO_EXT_A = '\uA960-\uA97F'; +// var R_HANGUL_JAMO_EXT_B = '\uD7B0-\uD7FF'; +// var R_HANGUL_COMPATIBILITY = '\u3130-\u318F'; +// var R_HANGUL_COMP_HALFWIDTH = '\uFFA0-\uFFDF'; +const R_HANGUL_SYLLABLES = '\uAC00-\uD7AF'; + +/** + * Globals + */ +const R_IDEO_OR_SYLL = R_IDEO + R_KANA + R_HANGUL_SYLLABLES; + +let REGEX_IDEO = null; +let REGEX_KANA = null; +let REGEX_IDEO_OR_SYLL = null; +let REGEX_IS_KANA_WITH_TRAILING_LATIN = null; + +/** + * Whether the string includes any Katakana or Hiragana characters. + * + * @param {string} str + * @return {boolean} + */ +function hasKana(str) { + REGEX_KANA = REGEX_KANA || new RegExp('[' + R_KANA + ']'); + return REGEX_KANA.test(str); +} + +/** + * Whether the string includes any CJK Ideograph characters. + * + * @param {string} str + * @return {boolean} + */ +function hasIdeograph(str) { + REGEX_IDEO = REGEX_IDEO || new RegExp('[' + R_IDEO + ']'); + return REGEX_IDEO.test(str); +} + +/** + * Whether the string includes any CJK Ideograph or Syllable characters. + * + * @param {string} str + * @return {boolean} + */ +function hasIdeoOrSyll(str) { + REGEX_IDEO_OR_SYLL = REGEX_IDEO_OR_SYLL || new RegExp('[' + R_IDEO_OR_SYLL + ']'); + return REGEX_IDEO_OR_SYLL.test(str); +} + +/** + * @param {string} chr + * @output {string} + */ +function charCodeToKatakana(chr) { + const charCode = chr.charCodeAt(0); + return String.fromCharCode(charCode < I_HIRAGANA[0] || charCode > I_HIRAGANA[1] ? charCode : charCode + I_HIRAGANA_TO_KATAKANA); +} + +/** + * Replace any Hiragana character with the matching Katakana + * + * @param {string} str + * @output {string} + */ +function hiraganaToKatakana(str) { + if (!hasKana(str)) { + return str; + } + return str.split('').map(charCodeToKatakana).join(''); +} + +/** + * Whether the string is exactly a sequence of Kana characters followed by one + * Latin character. + * + * @param {string} str + * @output {string} + */ +function isKanaWithTrailingLatin(str) { + REGEX_IS_KANA_WITH_TRAILING_LATIN = REGEX_IS_KANA_WITH_TRAILING_LATIN || new RegExp('^' + '[' + R_KANA + ']+' + '[' + R_LATIN + ']' + '$'); + return REGEX_IS_KANA_WITH_TRAILING_LATIN.test(str); +} + +/** + * Drops the trailing Latin character from a string that is exactly a sequence + * of Kana characters followed by one Latin character. + * + * @param {string} str + * @output {string} + */ +function kanaRemoveTrailingLatin(str) { + if (isKanaWithTrailingLatin(str)) { + return str.substr(0, str.length - 1); + } + return str; +} + +const UnicodeCJK = { + hasKana: hasKana, + hasIdeograph: hasIdeograph, + hasIdeoOrSyll: hasIdeoOrSyll, + hiraganaToKatakana: hiraganaToKatakana, + isKanaWithTrailingLatin: isKanaWithTrailingLatin, + kanaRemoveTrailingLatin: kanaRemoveTrailingLatin +}; + +module.exports = UnicodeCJK;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeHangulKorean.js b/node_modules/fbjs/lib/UnicodeHangulKorean.js new file mode 100644 index 000000000..67252699d --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeHangulKorean.js @@ -0,0 +1,137 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/** + * Unicode algorithms for Hangul script, the Korean writing system + * + * Hangul script has three encoded models in Unicode: + * + * A) Conjoining Jamo (covers modern and historic elements) + * * U+1100..U+11FF ; Hangul Jamo + * * U+A960..U+A97F ; Hangul Jamo Extended-A + * * U+D7B0..U+D7FF ; Hangul Jamo Extended-B + * + * B) Conjoined Syllables (only covers modern Korean language) + * * U+AC00..U+D7AF ; Hangul Syllables + * + * C) Compatibility Jamo (one code-point for each "shape") + * * U+3130..U+318F ; Hangul Compatibility Jamo + * + * This modules helps you convert characters from one model to another. + * Primary functionalities are: + * + * 1) Convert from any encodings to Conjoining Jamo characters (A), + * e.g. for prefix matching + * + * 2) Convert from any encodings to Syllable characters, when possible (B), + * e.g. to reach the normal Unicode form (NFC) + */ + +'use strict'; + +var HANGUL_COMPATIBILITY_OR_SYLLABLE_REGEX = /[\u3130-\u318F\uAC00-\uD7AF]/; + +/** + * Returns true if the input includes any Hangul Compatibility Jamo or + * Hangul Conjoined Syllable. + * + * @param {string} str + */ +function hasCompatibilityOrSyllable(str) { + return HANGUL_COMPATIBILITY_OR_SYLLABLE_REGEX.test(str); +} + +/* Compatibility Jamo -> Conjoining Jamo + * + * Maps a compatibility character to the Conjoining Jamo character, + * positioned at (compatibilityCodePoint - 0x3131). + * + * Generated by: + * $ grep '^31[3-8].;' UnicodeData.txt |\ + * awk -F';' '{print $6}' | awk '{print " 0x"$2","}' + */ +var CMAP = [0x1100, 0x1101, 0x11AA, 0x1102, 0x11AC, 0x11AD, 0x1103, 0x1104, 0x1105, 0x11B0, 0x11B1, 0x11B2, 0x11B3, 0x11B4, 0x11B5, 0x111A, 0x1106, 0x1107, 0x1108, 0x1121, 0x1109, 0x110A, 0x110B, 0x110C, 0x110D, 0x110E, 0x110F, 0x1110, 0x1111, 0x1112, 0x1161, 0x1162, 0x1163, 0x1164, 0x1165, 0x1166, 0x1167, 0x1168, 0x1169, 0x116A, 0x116B, 0x116C, 0x116D, 0x116E, 0x116F, 0x1170, 0x1171, 0x1172, 0x1173, 0x1174, 0x1175, 0x1160, 0x1114, 0x1115, 0x11C7, 0x11C8, 0x11CC, 0x11CE, 0x11D3, 0x11D7, 0x11D9, 0x111C, 0x11DD, 0x11DF, 0x111D, 0x111E, 0x1120, 0x1122, 0x1123, 0x1127, 0x1129, 0x112B, 0x112C, 0x112D, 0x112E, 0x112F, 0x1132, 0x1136, 0x1140, 0x1147, 0x114C, 0x11F1, 0x11F2, 0x1157, 0x1158, 0x1159, 0x1184, 0x1185, 0x1188, 0x1191, 0x1192, 0x1194, 0x119E, 0x11A1]; + +var CBASE = 0x3131; +var CCOUNT = CMAP.length; +var CTOP = CBASE + CCOUNT; + +/** + * Maps one Hangul Compatibility Jamo code-point to the equivalent Hangul + * Conjoining Jamo characters, as defined in UnicodeData.txt. + * + * @param {number} codePoint One Unicode code-point + * @output {string} + */ +function fromCompatibility(codePoint) { + return String.fromCharCode(CMAP[codePoint - CBASE]); +} + +/** + * Conjoined Syllable -> Conjoining Jamo + * + * Based on the "Hangul Syllable Decomposition" algorithm provided in + * 3.12 Conjoining Jamo Behavior, The Unicode Standard, Version 6.3.0. + * <http://www.unicode.org/versions/Unicode6.2.0/ch03.pdf> + */ + +var LBASE = 0x1100; +var VBASE = 0x1161; +var TBASE = 0x11A7; +var SBASE = 0xAC00; +var LCOUNT = 19; +var VCOUNT = 21; +var TCOUNT = 28; +var NCOUNT = VCOUNT * TCOUNT; +var SCOUNT = LCOUNT * NCOUNT; +var STOP = SBASE + SCOUNT; + +/** + * Maps one Hangul Syllable code-point to the equivalent Hangul + * Conjoining Jamo characters, as defined in UnicodeData.txt. + * + * @param {number} codePoint One Unicode character + * @output {string} + */ +function decomposeSyllable(codePoint) { + var sylSIndex = codePoint - SBASE; + var sylTIndex = sylSIndex % TCOUNT; + return String.fromCharCode(LBASE + sylSIndex / NCOUNT) + String.fromCharCode(VBASE + sylSIndex % NCOUNT / TCOUNT) + (sylTIndex > 0 ? String.fromCharCode(TBASE + sylTIndex) : ''); +} + +/* To Conjoining Jamo */ + +/** + * Return Unicode characters as they are, except for Hangul characters, which + * will be converted to the Conjoining Jamo form. + * + * @param {string} string + * @output {string} + */ +function toConjoiningJamo(string) { + if (!hasCompatibilityOrSyllable(string)) { + return string; + } + + var result = []; + for (var i = 0; i < string.length; i++) { + var charStr = string.charAt(i); + var codeUnit = charStr.charCodeAt(0); + result.push(CBASE <= codeUnit && codeUnit < CTOP ? fromCompatibility(codeUnit) : SBASE <= codeUnit && codeUnit < STOP ? decomposeSyllable(codeUnit) : charStr); + } + return result.join(''); +} + +var UnicodeHangulKorean = { + toConjoiningJamo: toConjoiningJamo +}; + +module.exports = UnicodeHangulKorean;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeHangulKorean.js.flow b/node_modules/fbjs/lib/UnicodeHangulKorean.js.flow new file mode 100644 index 000000000..b278eb976 --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeHangulKorean.js.flow @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UnicodeHangulKorean + * @typechecks + */ + +/** + * Unicode algorithms for Hangul script, the Korean writing system + * + * Hangul script has three encoded models in Unicode: + * + * A) Conjoining Jamo (covers modern and historic elements) + * * U+1100..U+11FF ; Hangul Jamo + * * U+A960..U+A97F ; Hangul Jamo Extended-A + * * U+D7B0..U+D7FF ; Hangul Jamo Extended-B + * + * B) Conjoined Syllables (only covers modern Korean language) + * * U+AC00..U+D7AF ; Hangul Syllables + * + * C) Compatibility Jamo (one code-point for each "shape") + * * U+3130..U+318F ; Hangul Compatibility Jamo + * + * This modules helps you convert characters from one model to another. + * Primary functionalities are: + * + * 1) Convert from any encodings to Conjoining Jamo characters (A), + * e.g. for prefix matching + * + * 2) Convert from any encodings to Syllable characters, when possible (B), + * e.g. to reach the normal Unicode form (NFC) + */ + +'use strict'; + +const HANGUL_COMPATIBILITY_OR_SYLLABLE_REGEX = /[\u3130-\u318F\uAC00-\uD7AF]/; + +/** + * Returns true if the input includes any Hangul Compatibility Jamo or + * Hangul Conjoined Syllable. + * + * @param {string} str + */ +function hasCompatibilityOrSyllable(str) { + return HANGUL_COMPATIBILITY_OR_SYLLABLE_REGEX.test(str); +} + +/* Compatibility Jamo -> Conjoining Jamo + * + * Maps a compatibility character to the Conjoining Jamo character, + * positioned at (compatibilityCodePoint - 0x3131). + * + * Generated by: + * $ grep '^31[3-8].;' UnicodeData.txt |\ + * awk -F';' '{print $6}' | awk '{print " 0x"$2","}' + */ +const CMAP = [0x1100, 0x1101, 0x11AA, 0x1102, 0x11AC, 0x11AD, 0x1103, 0x1104, 0x1105, 0x11B0, 0x11B1, 0x11B2, 0x11B3, 0x11B4, 0x11B5, 0x111A, 0x1106, 0x1107, 0x1108, 0x1121, 0x1109, 0x110A, 0x110B, 0x110C, 0x110D, 0x110E, 0x110F, 0x1110, 0x1111, 0x1112, 0x1161, 0x1162, 0x1163, 0x1164, 0x1165, 0x1166, 0x1167, 0x1168, 0x1169, 0x116A, 0x116B, 0x116C, 0x116D, 0x116E, 0x116F, 0x1170, 0x1171, 0x1172, 0x1173, 0x1174, 0x1175, 0x1160, 0x1114, 0x1115, 0x11C7, 0x11C8, 0x11CC, 0x11CE, 0x11D3, 0x11D7, 0x11D9, 0x111C, 0x11DD, 0x11DF, 0x111D, 0x111E, 0x1120, 0x1122, 0x1123, 0x1127, 0x1129, 0x112B, 0x112C, 0x112D, 0x112E, 0x112F, 0x1132, 0x1136, 0x1140, 0x1147, 0x114C, 0x11F1, 0x11F2, 0x1157, 0x1158, 0x1159, 0x1184, 0x1185, 0x1188, 0x1191, 0x1192, 0x1194, 0x119E, 0x11A1]; + +const CBASE = 0x3131; +const CCOUNT = CMAP.length; +const CTOP = CBASE + CCOUNT; + +/** + * Maps one Hangul Compatibility Jamo code-point to the equivalent Hangul + * Conjoining Jamo characters, as defined in UnicodeData.txt. + * + * @param {number} codePoint One Unicode code-point + * @output {string} + */ +function fromCompatibility(codePoint) { + return String.fromCharCode(CMAP[codePoint - CBASE]); +} + +/** + * Conjoined Syllable -> Conjoining Jamo + * + * Based on the "Hangul Syllable Decomposition" algorithm provided in + * 3.12 Conjoining Jamo Behavior, The Unicode Standard, Version 6.3.0. + * <http://www.unicode.org/versions/Unicode6.2.0/ch03.pdf> + */ + +const LBASE = 0x1100; +const VBASE = 0x1161; +const TBASE = 0x11A7; +const SBASE = 0xAC00; +const LCOUNT = 19; +const VCOUNT = 21; +const TCOUNT = 28; +const NCOUNT = VCOUNT * TCOUNT; +const SCOUNT = LCOUNT * NCOUNT; +const STOP = SBASE + SCOUNT; + +/** + * Maps one Hangul Syllable code-point to the equivalent Hangul + * Conjoining Jamo characters, as defined in UnicodeData.txt. + * + * @param {number} codePoint One Unicode character + * @output {string} + */ +function decomposeSyllable(codePoint) { + const sylSIndex = codePoint - SBASE; + const sylTIndex = sylSIndex % TCOUNT; + return String.fromCharCode(LBASE + sylSIndex / NCOUNT) + String.fromCharCode(VBASE + sylSIndex % NCOUNT / TCOUNT) + (sylTIndex > 0 ? String.fromCharCode(TBASE + sylTIndex) : ''); +} + +/* To Conjoining Jamo */ + +/** + * Return Unicode characters as they are, except for Hangul characters, which + * will be converted to the Conjoining Jamo form. + * + * @param {string} string + * @output {string} + */ +function toConjoiningJamo(string) { + if (!hasCompatibilityOrSyllable(string)) { + return string; + } + + const result = []; + for (let i = 0; i < string.length; i++) { + const charStr = string.charAt(i); + const codeUnit = charStr.charCodeAt(0); + result.push(CBASE <= codeUnit && codeUnit < CTOP ? fromCompatibility(codeUnit) : SBASE <= codeUnit && codeUnit < STOP ? decomposeSyllable(codeUnit) : charStr); + } + return result.join(''); +} + +const UnicodeHangulKorean = { + toConjoiningJamo: toConjoiningJamo +}; + +module.exports = UnicodeHangulKorean;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeUtils.js b/node_modules/fbjs/lib/UnicodeUtils.js new file mode 100644 index 000000000..f192b5219 --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeUtils.js @@ -0,0 +1,214 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/** + * Unicode-enabled replacesments for basic String functions. + * + * All the functions in this module assume that the input string is a valid + * UTF-16 encoding of a Unicode sequence. If it's not the case, the behavior + * will be undefined. + * + * WARNING: Since this module is typechecks-enforced, you may find new bugs + * when replacing normal String functions with ones provided here. + */ + +'use strict'; + +var invariant = require('./invariant'); + +// These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a +// surrogate code unit. +var SURROGATE_HIGH_START = 0xD800; +var SURROGATE_HIGH_END = 0xDBFF; +var SURROGATE_LOW_START = 0xDC00; +var SURROGATE_LOW_END = 0xDFFF; +var SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/; + +/** + * @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF] + * @return {boolean} Whether code-unit is in a surrogate (hi/low) range + */ +function isCodeUnitInSurrogateRange(codeUnit) { + return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END; +} + +/** + * Returns whether the two characters starting at `index` form a surrogate pair. + * For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and + * (s, 1) returns false. + * + * @param {string} str + * @param {number} index + * @return {boolean} + */ +function isSurrogatePair(str, index) { + !(0 <= index && index < str.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isSurrogatePair: Invalid index %s for string length %s.', index, str.length) : invariant(false) : void 0; + if (index + 1 === str.length) { + return false; + } + var first = str.charCodeAt(index); + var second = str.charCodeAt(index + 1); + return SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END && SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END; +} + +/** + * @param {string} str Non-empty string + * @return {boolean} True if the input includes any surrogate code units + */ +function hasSurrogateUnit(str) { + return SURROGATE_UNITS_REGEX.test(str); +} + +/** + * Return the length of the original Unicode character at given position in the + * String by looking into the UTF-16 code unit; that is equal to 1 for any + * non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and + * returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact + * representing non-BMP characters ([U+10000..U+10FFFF]). + * + * Examples: + * - '\u0020' => 1 + * - '\u3020' => 1 + * - '\uD835' => 2 + * - '\uD835\uDDEF' => 2 + * - '\uDDEF' => 2 + * + * @param {string} str Non-empty string + * @param {number} pos Position in the string to look for one code unit + * @return {number} Number 1 or 2 + */ +function getUTF16Length(str, pos) { + return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos)); +} + +/** + * Fully Unicode-enabled replacement for String#length + * + * @param {string} str Valid Unicode string + * @return {number} The number of Unicode characters in the string + */ +function strlen(str) { + // Call the native functions if there's no surrogate char + if (!hasSurrogateUnit(str)) { + return str.length; + } + + var len = 0; + for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) { + len++; + } + return len; +} + +/** + * Fully Unicode-enabled replacement for String#substr() + * + * @param {string} str Valid Unicode string + * @param {number} start Location in Unicode sequence to begin extracting + * @param {?number} length The number of Unicode characters to extract + * (default: to the end of the string) + * @return {string} Extracted sub-string + */ +function substr(str, start, length) { + start = start || 0; + length = length === undefined ? Infinity : length || 0; + + // Call the native functions if there's no surrogate char + if (!hasSurrogateUnit(str)) { + return str.substr(start, length); + } + + // Obvious cases + var size = str.length; + if (size <= 0 || start > size || length <= 0) { + return ''; + } + + // Find the actual starting position + var posA = 0; + if (start > 0) { + for (; start > 0 && posA < size; start--) { + posA += getUTF16Length(str, posA); + } + if (posA >= size) { + return ''; + } + } else if (start < 0) { + for (posA = size; start < 0 && 0 < posA; start++) { + posA -= getUTF16Length(str, posA - 1); + } + if (posA < 0) { + posA = 0; + } + } + + // Find the actual ending position + var posB = size; + if (length < size) { + for (posB = posA; length > 0 && posB < size; length--) { + posB += getUTF16Length(str, posB); + } + } + + return str.substring(posA, posB); +} + +/** + * Fully Unicode-enabled replacement for String#substring() + * + * @param {string} str Valid Unicode string + * @param {number} start Location in Unicode sequence to begin extracting + * @param {?number} end Location in Unicode sequence to end extracting + * (default: end of the string) + * @return {string} Extracted sub-string + */ +function substring(str, start, end) { + start = start || 0; + end = end === undefined ? Infinity : end || 0; + + if (start < 0) { + start = 0; + } + if (end < 0) { + end = 0; + } + + var length = Math.abs(end - start); + start = start < end ? start : end; + return substr(str, start, length); +} + +/** + * Get a list of Unicode code-points from a String + * + * @param {string} str Valid Unicode string + * @return {array<number>} A list of code-points in [0..0x10FFFF] + */ +function getCodePoints(str) { + var codePoints = []; + for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) { + codePoints.push(str.codePointAt(pos)); + } + return codePoints; +} + +var UnicodeUtils = { + getCodePoints: getCodePoints, + getUTF16Length: getUTF16Length, + hasSurrogateUnit: hasSurrogateUnit, + isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange, + isSurrogatePair: isSurrogatePair, + strlen: strlen, + substring: substring, + substr: substr +}; + +module.exports = UnicodeUtils;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeUtils.js.flow b/node_modules/fbjs/lib/UnicodeUtils.js.flow new file mode 100644 index 000000000..2b34a0c25 --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeUtils.js.flow @@ -0,0 +1,215 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UnicodeUtils + * @typechecks + */ + +/** + * Unicode-enabled replacesments for basic String functions. + * + * All the functions in this module assume that the input string is a valid + * UTF-16 encoding of a Unicode sequence. If it's not the case, the behavior + * will be undefined. + * + * WARNING: Since this module is typechecks-enforced, you may find new bugs + * when replacing normal String functions with ones provided here. + */ + +'use strict'; + +const invariant = require('./invariant'); + +// These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a +// surrogate code unit. +const SURROGATE_HIGH_START = 0xD800; +const SURROGATE_HIGH_END = 0xDBFF; +const SURROGATE_LOW_START = 0xDC00; +const SURROGATE_LOW_END = 0xDFFF; +const SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/; + +/** + * @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF] + * @return {boolean} Whether code-unit is in a surrogate (hi/low) range + */ +function isCodeUnitInSurrogateRange(codeUnit) { + return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END; +} + +/** + * Returns whether the two characters starting at `index` form a surrogate pair. + * For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and + * (s, 1) returns false. + * + * @param {string} str + * @param {number} index + * @return {boolean} + */ +function isSurrogatePair(str, index) { + invariant(0 <= index && index < str.length, 'isSurrogatePair: Invalid index %s for string length %s.', index, str.length); + if (index + 1 === str.length) { + return false; + } + const first = str.charCodeAt(index); + const second = str.charCodeAt(index + 1); + return SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END && SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END; +} + +/** + * @param {string} str Non-empty string + * @return {boolean} True if the input includes any surrogate code units + */ +function hasSurrogateUnit(str) { + return SURROGATE_UNITS_REGEX.test(str); +} + +/** + * Return the length of the original Unicode character at given position in the + * String by looking into the UTF-16 code unit; that is equal to 1 for any + * non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and + * returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact + * representing non-BMP characters ([U+10000..U+10FFFF]). + * + * Examples: + * - '\u0020' => 1 + * - '\u3020' => 1 + * - '\uD835' => 2 + * - '\uD835\uDDEF' => 2 + * - '\uDDEF' => 2 + * + * @param {string} str Non-empty string + * @param {number} pos Position in the string to look for one code unit + * @return {number} Number 1 or 2 + */ +function getUTF16Length(str, pos) { + return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos)); +} + +/** + * Fully Unicode-enabled replacement for String#length + * + * @param {string} str Valid Unicode string + * @return {number} The number of Unicode characters in the string + */ +function strlen(str) { + // Call the native functions if there's no surrogate char + if (!hasSurrogateUnit(str)) { + return str.length; + } + + let len = 0; + for (let pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) { + len++; + } + return len; +} + +/** + * Fully Unicode-enabled replacement for String#substr() + * + * @param {string} str Valid Unicode string + * @param {number} start Location in Unicode sequence to begin extracting + * @param {?number} length The number of Unicode characters to extract + * (default: to the end of the string) + * @return {string} Extracted sub-string + */ +function substr(str, start, length) { + start = start || 0; + length = length === undefined ? Infinity : length || 0; + + // Call the native functions if there's no surrogate char + if (!hasSurrogateUnit(str)) { + return str.substr(start, length); + } + + // Obvious cases + const size = str.length; + if (size <= 0 || start > size || length <= 0) { + return ''; + } + + // Find the actual starting position + let posA = 0; + if (start > 0) { + for (; start > 0 && posA < size; start--) { + posA += getUTF16Length(str, posA); + } + if (posA >= size) { + return ''; + } + } else if (start < 0) { + for (posA = size; start < 0 && 0 < posA; start++) { + posA -= getUTF16Length(str, posA - 1); + } + if (posA < 0) { + posA = 0; + } + } + + // Find the actual ending position + let posB = size; + if (length < size) { + for (posB = posA; length > 0 && posB < size; length--) { + posB += getUTF16Length(str, posB); + } + } + + return str.substring(posA, posB); +} + +/** + * Fully Unicode-enabled replacement for String#substring() + * + * @param {string} str Valid Unicode string + * @param {number} start Location in Unicode sequence to begin extracting + * @param {?number} end Location in Unicode sequence to end extracting + * (default: end of the string) + * @return {string} Extracted sub-string + */ +function substring(str, start, end) { + start = start || 0; + end = end === undefined ? Infinity : end || 0; + + if (start < 0) { + start = 0; + } + if (end < 0) { + end = 0; + } + + const length = Math.abs(end - start); + start = start < end ? start : end; + return substr(str, start, length); +} + +/** + * Get a list of Unicode code-points from a String + * + * @param {string} str Valid Unicode string + * @return {array<number>} A list of code-points in [0..0x10FFFF] + */ +function getCodePoints(str) { + const codePoints = []; + for (let pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) { + codePoints.push(str.codePointAt(pos)); + } + return codePoints; +} + +const UnicodeUtils = { + getCodePoints: getCodePoints, + getUTF16Length: getUTF16Length, + hasSurrogateUnit: hasSurrogateUnit, + isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange, + isSurrogatePair: isSurrogatePair, + strlen: strlen, + substring: substring, + substr: substr +}; + +module.exports = UnicodeUtils;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeUtilsExtra.js b/node_modules/fbjs/lib/UnicodeUtilsExtra.js new file mode 100644 index 000000000..a7c9bf3e3 --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeUtilsExtra.js @@ -0,0 +1,229 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/** + * Unicode-enabled extra utility functions not always needed. + */ + +'use strict'; + +var UnicodeUtils = require('./UnicodeUtils'); + +/** + * @param {number} codePoint Valid Unicode code-point + * @param {number} len Zero-padded minimum width of result + * @return {string} A zero-padded hexadecimal string (00XXXX) + */ +function zeroPaddedHex(codePoint, len) { + var codePointHex = codePoint.toString(16).toUpperCase(); + var numZeros = Math.max(0, len - codePointHex.length); + var result = ''; + for (var i = 0; i < numZeros; i++) { + result += '0'; + } + result += codePointHex; + return result; +} + +/** + * @param {number} codePoint Valid Unicode code-point + * @return {string} A formatted Unicode code-point string + * of the format U+XXXX, U+XXXXX, or U+XXXXXX + */ +function formatCodePoint(codePoint) { + codePoint = codePoint || 0; // NaN --> 0 + var formatted = ''; + if (codePoint <= 0xFFFF) { + formatted = zeroPaddedHex(codePoint, 4); + } else { + formatted = codePoint.toString(16).toUpperCase(); + } + return 'U+' + formatted; +} + +/** + * Get a list of formatted (string) Unicode code-points from a String + * + * @param {string} str Valid Unicode string + * @return {array<string>} A list of formatted code-point strings + */ +function getCodePointsFormatted(str) { + var codePoints = UnicodeUtils.getCodePoints(str); + return codePoints.map(formatCodePoint); +} + +var specialEscape = { + 0x07: '\\a', + 0x08: '\\b', + 0x0C: '\\f', + 0x0A: '\\n', + 0x0D: '\\r', + 0x09: '\\t', + 0x0B: '\\v', + 0x22: '\\"', + 0x5c: '\\\\' +}; + +/** + * Returns a double-quoted PHP string with all non-printable and + * non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function phpEscape(s) { + var result = '"'; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = UnicodeUtils.getCodePoints(s)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var cp = _step.value; + + var special = specialEscape[cp]; + if (special !== undefined) { + result += special; + } else if (cp >= 0x20 && cp <= 0x7e) { + result += String.fromCodePoint(cp); + } else if (cp <= 0xFFFF) { + result += '\\u{' + zeroPaddedHex(cp, 4) + '}'; + } else { + result += '\\u{' + zeroPaddedHex(cp, 6) + '}'; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + result += '"'; + return result; +} + +/** + * Returns a double-quoted Java or JavaScript string with all + * non-printable and non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function jsEscape(s) { + var result = '"'; + for (var i = 0; i < s.length; i++) { + var cp = s.charCodeAt(i); + var special = specialEscape[cp]; + if (special !== undefined) { + result += special; + } else if (cp >= 0x20 && cp <= 0x7e) { + result += String.fromCodePoint(cp); + } else { + result += '\\u' + zeroPaddedHex(cp, 4); + } + } + result += '"'; + return result; +} + +function c11Escape(s) { + var result = ''; + var _iteratorNormalCompletion2 = true; + var _didIteratorError2 = false; + var _iteratorError2 = undefined; + + try { + for (var _iterator2 = UnicodeUtils.getCodePoints(s)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var cp = _step2.value; + + var special = specialEscape[cp]; + if (special !== undefined) { + result += special; + } else if (cp >= 0x20 && cp <= 0x7e) { + result += String.fromCodePoint(cp); + } else if (cp <= 0xFFFF) { + result += '\\u' + zeroPaddedHex(cp, 4); + } else { + result += '\\U' + zeroPaddedHex(cp, 8); + } + } + } catch (err) { + _didIteratorError2 = true; + _iteratorError2 = err; + } finally { + try { + if (!_iteratorNormalCompletion2 && _iterator2['return']) { + _iterator2['return'](); + } + } finally { + if (_didIteratorError2) { + throw _iteratorError2; + } + } + } + + return result; +} + +/** + * Returns a double-quoted C string with all non-printable and + * non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function cEscape(s) { + return 'u8"' + c11Escape(s) + '"'; +} + +/** + * Returns a double-quoted Objective-C string with all non-printable + * and non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function objcEscape(s) { + return '@"' + c11Escape(s) + '"'; +} + +/** + * Returns a double-quoted Python string with all non-printable + * and non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function pyEscape(s) { + return 'u"' + c11Escape(s) + '"'; +} + +var UnicodeUtilsExtra = { + formatCodePoint: formatCodePoint, + getCodePointsFormatted: getCodePointsFormatted, + zeroPaddedHex: zeroPaddedHex, + phpEscape: phpEscape, + jsEscape: jsEscape, + cEscape: cEscape, + objcEscape: objcEscape, + pyEscape: pyEscape +}; + +module.exports = UnicodeUtilsExtra;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UnicodeUtilsExtra.js.flow b/node_modules/fbjs/lib/UnicodeUtilsExtra.js.flow new file mode 100644 index 000000000..bb5f3404c --- /dev/null +++ b/node_modules/fbjs/lib/UnicodeUtilsExtra.js.flow @@ -0,0 +1,186 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UnicodeUtilsExtra + * @typechecks + */ + +/** + * Unicode-enabled extra utility functions not always needed. + */ + +'use strict'; + +const UnicodeUtils = require('./UnicodeUtils'); + +/** + * @param {number} codePoint Valid Unicode code-point + * @param {number} len Zero-padded minimum width of result + * @return {string} A zero-padded hexadecimal string (00XXXX) + */ +function zeroPaddedHex(codePoint, len) { + let codePointHex = codePoint.toString(16).toUpperCase(); + let numZeros = Math.max(0, len - codePointHex.length); + var result = ''; + for (var i = 0; i < numZeros; i++) { + result += '0'; + } + result += codePointHex; + return result; +} + +/** + * @param {number} codePoint Valid Unicode code-point + * @return {string} A formatted Unicode code-point string + * of the format U+XXXX, U+XXXXX, or U+XXXXXX + */ +function formatCodePoint(codePoint) { + codePoint = codePoint || 0; // NaN --> 0 + var formatted = ''; + if (codePoint <= 0xFFFF) { + formatted = zeroPaddedHex(codePoint, 4); + } else { + formatted = codePoint.toString(16).toUpperCase(); + } + return 'U+' + formatted; +} + +/** + * Get a list of formatted (string) Unicode code-points from a String + * + * @param {string} str Valid Unicode string + * @return {array<string>} A list of formatted code-point strings + */ +function getCodePointsFormatted(str) { + const codePoints = UnicodeUtils.getCodePoints(str); + return codePoints.map(formatCodePoint); +} + +const specialEscape = { + 0x07: '\\a', + 0x08: '\\b', + 0x0C: '\\f', + 0x0A: '\\n', + 0x0D: '\\r', + 0x09: '\\t', + 0x0B: '\\v', + 0x22: '\\"', + 0x5c: '\\\\' +}; + +/** + * Returns a double-quoted PHP string with all non-printable and + * non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function phpEscape(s) { + var result = '"'; + for (let cp of UnicodeUtils.getCodePoints(s)) { + let special = specialEscape[cp]; + if (special !== undefined) { + result += special; + } else if (cp >= 0x20 && cp <= 0x7e) { + result += String.fromCodePoint(cp); + } else if (cp <= 0xFFFF) { + result += '\\u{' + zeroPaddedHex(cp, 4) + '}'; + } else { + result += '\\u{' + zeroPaddedHex(cp, 6) + '}'; + } + } + result += '"'; + return result; +} + +/** + * Returns a double-quoted Java or JavaScript string with all + * non-printable and non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function jsEscape(s) { + var result = '"'; + for (var i = 0; i < s.length; i++) { + let cp = s.charCodeAt(i); + let special = specialEscape[cp]; + if (special !== undefined) { + result += special; + } else if (cp >= 0x20 && cp <= 0x7e) { + result += String.fromCodePoint(cp); + } else { + result += '\\u' + zeroPaddedHex(cp, 4); + } + } + result += '"'; + return result; +} + +function c11Escape(s) { + var result = ''; + for (let cp of UnicodeUtils.getCodePoints(s)) { + let special = specialEscape[cp]; + if (special !== undefined) { + result += special; + } else if (cp >= 0x20 && cp <= 0x7e) { + result += String.fromCodePoint(cp); + } else if (cp <= 0xFFFF) { + result += '\\u' + zeroPaddedHex(cp, 4); + } else { + result += '\\U' + zeroPaddedHex(cp, 8); + } + } + return result; +} + +/** + * Returns a double-quoted C string with all non-printable and + * non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function cEscape(s) { + return 'u8"' + c11Escape(s) + '"'; +} + +/** + * Returns a double-quoted Objective-C string with all non-printable + * and non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function objcEscape(s) { + return '@"' + c11Escape(s) + '"'; +} + +/** + * Returns a double-quoted Python string with all non-printable + * and non-US-ASCII sequences escaped. + * + * @param {string} str Valid Unicode string + * @return {string} Double-quoted string with Unicode sequences escaped + */ +function pyEscape(s) { + return 'u"' + c11Escape(s) + '"'; +} + +const UnicodeUtilsExtra = { + formatCodePoint: formatCodePoint, + getCodePointsFormatted: getCodePointsFormatted, + zeroPaddedHex: zeroPaddedHex, + phpEscape: phpEscape, + jsEscape: jsEscape, + cEscape: cEscape, + objcEscape: objcEscape, + pyEscape: pyEscape +}; + +module.exports = UnicodeUtilsExtra;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UserAgent.js b/node_modules/fbjs/lib/UserAgent.js new file mode 100644 index 000000000..c956d897e --- /dev/null +++ b/node_modules/fbjs/lib/UserAgent.js @@ -0,0 +1,241 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var UserAgentData = require('./UserAgentData'); +var VersionRange = require('./VersionRange'); + +var mapObject = require('./mapObject'); +var memoizeStringOnly = require('./memoizeStringOnly'); + +/** + * Checks to see whether `name` and `version` satisfy `query`. + * + * @param {string} name Name of the browser, device, engine or platform + * @param {?string} version Version of the browser, engine or platform + * @param {string} query Query of form "Name [range expression]" + * @param {?function} normalizer Optional pre-processor for range expression + * @return {boolean} + */ +function compare(name, version, query, normalizer) { + // check for exact match with no version + if (name === query) { + return true; + } + + // check for non-matching names + if (!query.startsWith(name)) { + return false; + } + + // full comparison with version + var range = query.slice(name.length); + if (version) { + range = normalizer ? normalizer(range) : range; + return VersionRange.contains(range, version); + } + + return false; +} + +/** + * Normalizes `version` by stripping any "NT" prefix, but only on the Windows + * platform. + * + * Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class. + * + * @param {string} version + * @return {string} + */ +function normalizePlatformVersion(version) { + if (UserAgentData.platformName === 'Windows') { + return version.replace(/^\s*NT/, ''); + } + + return version; +} + +/** + * Provides client-side access to the authoritative PHP-generated User Agent + * information supplied by the server. + */ +var UserAgent = { + /** + * Check if the User Agent browser matches `query`. + * + * `query` should be a string like "Chrome" or "Chrome > 33". + * + * Valid browser names include: + * + * - ACCESS NetFront + * - AOL + * - Amazon Silk + * - Android + * - BlackBerry + * - BlackBerry PlayBook + * - Chrome + * - Chrome for iOS + * - Chrome frame + * - Facebook PHP SDK + * - Facebook for iOS + * - Firefox + * - IE + * - IE Mobile + * - Mobile Safari + * - Motorola Internet Browser + * - Nokia + * - Openwave Mobile Browser + * - Opera + * - Opera Mini + * - Opera Mobile + * - Safari + * - UIWebView + * - Unknown + * - webOS + * - etc... + * + * An authoritative list can be found in the PHP `BrowserDetector` class and + * related classes in the same file (see calls to `new UserAgentBrowser` here: + * https://fburl.com/50728104). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name [range expression]" + * @return {boolean} + */ + isBrowser: function isBrowser(query) { + return compare(UserAgentData.browserName, UserAgentData.browserFullVersion, query); + }, + + + /** + * Check if the User Agent browser uses a 32 or 64 bit architecture. + * + * @note Function results are memoized + * + * @param {string} query Query of the form "32" or "64". + * @return {boolean} + */ + isBrowserArchitecture: function isBrowserArchitecture(query) { + return compare(UserAgentData.browserArchitecture, null, query); + }, + + + /** + * Check if the User Agent device matches `query`. + * + * `query` should be a string like "iPhone" or "iPad". + * + * Valid device names include: + * + * - Kindle + * - Kindle Fire + * - Unknown + * - iPad + * - iPhone + * - iPod + * - etc... + * + * An authoritative list can be found in the PHP `DeviceDetector` class and + * related classes in the same file (see calls to `new UserAgentDevice` here: + * https://fburl.com/50728332). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name" + * @return {boolean} + */ + isDevice: function isDevice(query) { + return compare(UserAgentData.deviceName, null, query); + }, + + + /** + * Check if the User Agent rendering engine matches `query`. + * + * `query` should be a string like "WebKit" or "WebKit >= 537". + * + * Valid engine names include: + * + * - Gecko + * - Presto + * - Trident + * - WebKit + * - etc... + * + * An authoritative list can be found in the PHP `RenderingEngineDetector` + * class related classes in the same file (see calls to `new + * UserAgentRenderingEngine` here: https://fburl.com/50728617). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name [range expression]" + * @return {boolean} + */ + isEngine: function isEngine(query) { + return compare(UserAgentData.engineName, UserAgentData.engineVersion, query); + }, + + + /** + * Check if the User Agent platform matches `query`. + * + * `query` should be a string like "Windows" or "iOS 5 - 6". + * + * Valid platform names include: + * + * - Android + * - BlackBerry OS + * - Java ME + * - Linux + * - Mac OS X + * - Mac OS X Calendar + * - Mac OS X Internet Account + * - Symbian + * - SymbianOS + * - Windows + * - Windows Mobile + * - Windows Phone + * - iOS + * - iOS Facebook Integration Account + * - iOS Facebook Social Sharing UI + * - webOS + * - Chrome OS + * - etc... + * + * An authoritative list can be found in the PHP `PlatformDetector` class and + * related classes in the same file (see calls to `new UserAgentPlatform` + * here: https://fburl.com/50729226). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name [range expression]" + * @return {boolean} + */ + isPlatform: function isPlatform(query) { + return compare(UserAgentData.platformName, UserAgentData.platformFullVersion, query, normalizePlatformVersion); + }, + + + /** + * Check if the User Agent platform is a 32 or 64 bit architecture. + * + * @note Function results are memoized + * + * @param {string} query Query of the form "32" or "64". + * @return {boolean} + */ + isPlatformArchitecture: function isPlatformArchitecture(query) { + return compare(UserAgentData.platformArchitecture, null, query); + } +}; + +module.exports = mapObject(UserAgent, memoizeStringOnly);
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UserAgent.js.flow b/node_modules/fbjs/lib/UserAgent.js.flow new file mode 100644 index 000000000..63d8b96e4 --- /dev/null +++ b/node_modules/fbjs/lib/UserAgent.js.flow @@ -0,0 +1,238 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UserAgent + */ + +'use strict'; + +const UserAgentData = require('./UserAgentData'); +const VersionRange = require('./VersionRange'); + +const mapObject = require('./mapObject'); +const memoizeStringOnly = require('./memoizeStringOnly'); + +/** + * Checks to see whether `name` and `version` satisfy `query`. + * + * @param {string} name Name of the browser, device, engine or platform + * @param {?string} version Version of the browser, engine or platform + * @param {string} query Query of form "Name [range expression]" + * @param {?function} normalizer Optional pre-processor for range expression + * @return {boolean} + */ +function compare(name, version, query, normalizer) { + // check for exact match with no version + if (name === query) { + return true; + } + + // check for non-matching names + if (!query.startsWith(name)) { + return false; + } + + // full comparison with version + let range = query.slice(name.length); + if (version) { + range = normalizer ? normalizer(range) : range; + return VersionRange.contains(range, version); + } + + return false; +} + +/** + * Normalizes `version` by stripping any "NT" prefix, but only on the Windows + * platform. + * + * Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class. + * + * @param {string} version + * @return {string} + */ +function normalizePlatformVersion(version) { + if (UserAgentData.platformName === 'Windows') { + return version.replace(/^\s*NT/, ''); + } + + return version; +} + +/** + * Provides client-side access to the authoritative PHP-generated User Agent + * information supplied by the server. + */ +const UserAgent = { + /** + * Check if the User Agent browser matches `query`. + * + * `query` should be a string like "Chrome" or "Chrome > 33". + * + * Valid browser names include: + * + * - ACCESS NetFront + * - AOL + * - Amazon Silk + * - Android + * - BlackBerry + * - BlackBerry PlayBook + * - Chrome + * - Chrome for iOS + * - Chrome frame + * - Facebook PHP SDK + * - Facebook for iOS + * - Firefox + * - IE + * - IE Mobile + * - Mobile Safari + * - Motorola Internet Browser + * - Nokia + * - Openwave Mobile Browser + * - Opera + * - Opera Mini + * - Opera Mobile + * - Safari + * - UIWebView + * - Unknown + * - webOS + * - etc... + * + * An authoritative list can be found in the PHP `BrowserDetector` class and + * related classes in the same file (see calls to `new UserAgentBrowser` here: + * https://fburl.com/50728104). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name [range expression]" + * @return {boolean} + */ + isBrowser(query) { + return compare(UserAgentData.browserName, UserAgentData.browserFullVersion, query); + }, + + /** + * Check if the User Agent browser uses a 32 or 64 bit architecture. + * + * @note Function results are memoized + * + * @param {string} query Query of the form "32" or "64". + * @return {boolean} + */ + isBrowserArchitecture(query) { + return compare(UserAgentData.browserArchitecture, null, query); + }, + + /** + * Check if the User Agent device matches `query`. + * + * `query` should be a string like "iPhone" or "iPad". + * + * Valid device names include: + * + * - Kindle + * - Kindle Fire + * - Unknown + * - iPad + * - iPhone + * - iPod + * - etc... + * + * An authoritative list can be found in the PHP `DeviceDetector` class and + * related classes in the same file (see calls to `new UserAgentDevice` here: + * https://fburl.com/50728332). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name" + * @return {boolean} + */ + isDevice(query) { + return compare(UserAgentData.deviceName, null, query); + }, + + /** + * Check if the User Agent rendering engine matches `query`. + * + * `query` should be a string like "WebKit" or "WebKit >= 537". + * + * Valid engine names include: + * + * - Gecko + * - Presto + * - Trident + * - WebKit + * - etc... + * + * An authoritative list can be found in the PHP `RenderingEngineDetector` + * class related classes in the same file (see calls to `new + * UserAgentRenderingEngine` here: https://fburl.com/50728617). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name [range expression]" + * @return {boolean} + */ + isEngine(query) { + return compare(UserAgentData.engineName, UserAgentData.engineVersion, query); + }, + + /** + * Check if the User Agent platform matches `query`. + * + * `query` should be a string like "Windows" or "iOS 5 - 6". + * + * Valid platform names include: + * + * - Android + * - BlackBerry OS + * - Java ME + * - Linux + * - Mac OS X + * - Mac OS X Calendar + * - Mac OS X Internet Account + * - Symbian + * - SymbianOS + * - Windows + * - Windows Mobile + * - Windows Phone + * - iOS + * - iOS Facebook Integration Account + * - iOS Facebook Social Sharing UI + * - webOS + * - Chrome OS + * - etc... + * + * An authoritative list can be found in the PHP `PlatformDetector` class and + * related classes in the same file (see calls to `new UserAgentPlatform` + * here: https://fburl.com/50729226). + * + * @note Function results are memoized + * + * @param {string} query Query of the form "Name [range expression]" + * @return {boolean} + */ + isPlatform(query) { + return compare(UserAgentData.platformName, UserAgentData.platformFullVersion, query, normalizePlatformVersion); + }, + + /** + * Check if the User Agent platform is a 32 or 64 bit architecture. + * + * @note Function results are memoized + * + * @param {string} query Query of the form "32" or "64". + * @return {boolean} + */ + isPlatformArchitecture(query) { + return compare(UserAgentData.platformArchitecture, null, query); + } + +}; + +module.exports = mapObject(UserAgent, memoizeStringOnly);
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UserAgentData.js b/node_modules/fbjs/lib/UserAgentData.js new file mode 100644 index 000000000..64dca7fbc --- /dev/null +++ b/node_modules/fbjs/lib/UserAgentData.js @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +/** + * Usage note: + * This module makes a best effort to export the same data we would internally. + * At Facebook we use a server-generated module that does the parsing and + * exports the data for the client to use. We can't rely on a server-side + * implementation in open source so instead we make use of an open source + * library to do the heavy lifting and then make some adjustments as necessary. + * It's likely there will be some differences. Some we can smooth over. + * Others are going to be harder. + */ + +'use strict'; + +var UAParser = require('ua-parser-js'); + +var UNKNOWN = 'Unknown'; + +var PLATFORM_MAP = { + 'Mac OS': 'Mac OS X' +}; + +/** + * Convert from UAParser platform name to what we expect. + */ +function convertPlatformName(name) { + return PLATFORM_MAP[name] || name; +} + +/** + * Get the version number in parts. This is very naive. We actually get major + * version as a part of UAParser already, which is generally good enough, but + * let's get the minor just in case. + */ +function getBrowserVersion(version) { + if (!version) { + return { + major: '', + minor: '' + }; + } + var parts = version.split('.'); + return { + major: parts[0], + minor: parts[1] + }; +} + +/** + * Get the UA data fom UAParser and then convert it to the format we're + * expecting for our APIS. + */ +var parser = new UAParser(); +var results = parser.getResult(); + +// Do some conversion first. +var browserVersionData = getBrowserVersion(results.browser.version); +var uaData = { + browserArchitecture: results.cpu.architecture || UNKNOWN, + browserFullVersion: results.browser.version || UNKNOWN, + browserMinorVersion: browserVersionData.minor || UNKNOWN, + browserName: results.browser.name || UNKNOWN, + browserVersion: results.browser.major || UNKNOWN, + deviceName: results.device.model || UNKNOWN, + engineName: results.engine.name || UNKNOWN, + engineVersion: results.engine.version || UNKNOWN, + platformArchitecture: results.cpu.architecture || UNKNOWN, + platformName: convertPlatformName(results.os.name) || UNKNOWN, + platformVersion: results.os.version || UNKNOWN, + platformFullVersion: results.os.version || UNKNOWN +}; + +module.exports = uaData;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/UserAgentData.js.flow b/node_modules/fbjs/lib/UserAgentData.js.flow new file mode 100644 index 000000000..e7f2ae008 --- /dev/null +++ b/node_modules/fbjs/lib/UserAgentData.js.flow @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule UserAgentData + */ + +/** + * Usage note: + * This module makes a best effort to export the same data we would internally. + * At Facebook we use a server-generated module that does the parsing and + * exports the data for the client to use. We can't rely on a server-side + * implementation in open source so instead we make use of an open source + * library to do the heavy lifting and then make some adjustments as necessary. + * It's likely there will be some differences. Some we can smooth over. + * Others are going to be harder. + */ + +'use strict'; + +var UAParser = require('ua-parser-js'); + +var UNKNOWN = 'Unknown'; + +var PLATFORM_MAP = { + 'Mac OS': 'Mac OS X' +}; + +/** + * Convert from UAParser platform name to what we expect. + */ +function convertPlatformName(name) { + return PLATFORM_MAP[name] || name; +} + +/** + * Get the version number in parts. This is very naive. We actually get major + * version as a part of UAParser already, which is generally good enough, but + * let's get the minor just in case. + */ +function getBrowserVersion(version) { + if (!version) { + return { + major: '', + minor: '' + }; + } + var parts = version.split('.'); + return { + major: parts[0], + minor: parts[1] + }; +} + +/** + * Get the UA data fom UAParser and then convert it to the format we're + * expecting for our APIS. + */ +var parser = new UAParser(); +var results = parser.getResult(); + +// Do some conversion first. +var browserVersionData = getBrowserVersion(results.browser.version); +var uaData = { + browserArchitecture: results.cpu.architecture || UNKNOWN, + browserFullVersion: results.browser.version || UNKNOWN, + browserMinorVersion: browserVersionData.minor || UNKNOWN, + browserName: results.browser.name || UNKNOWN, + browserVersion: results.browser.major || UNKNOWN, + deviceName: results.device.model || UNKNOWN, + engineName: results.engine.name || UNKNOWN, + engineVersion: results.engine.version || UNKNOWN, + platformArchitecture: results.cpu.architecture || UNKNOWN, + platformName: convertPlatformName(results.os.name) || UNKNOWN, + platformVersion: results.os.version || UNKNOWN, + platformFullVersion: results.os.version || UNKNOWN +}; + +module.exports = uaData;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/VersionRange.js b/node_modules/fbjs/lib/VersionRange.js new file mode 100644 index 000000000..5b068c686 --- /dev/null +++ b/node_modules/fbjs/lib/VersionRange.js @@ -0,0 +1,382 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var invariant = require('./invariant'); + +var componentRegex = /\./; +var orRegex = /\|\|/; +var rangeRegex = /\s+\-\s+/; +var modifierRegex = /^(<=|<|=|>=|~>|~|>|)?\s*(.+)/; +var numericRegex = /^(\d*)(.*)/; + +/** + * Splits input `range` on "||" and returns true if any subrange matches + * `version`. + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ +function checkOrExpression(range, version) { + var expressions = range.split(orRegex); + + if (expressions.length > 1) { + return expressions.some(function (range) { + return VersionRange.contains(range, version); + }); + } else { + range = expressions[0].trim(); + return checkRangeExpression(range, version); + } +} + +/** + * Splits input `range` on " - " (the surrounding whitespace is required) and + * returns true if version falls between the two operands. + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ +function checkRangeExpression(range, version) { + var expressions = range.split(rangeRegex); + + !(expressions.length > 0 && expressions.length <= 2) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'the "-" operator expects exactly 2 operands') : invariant(false) : void 0; + + if (expressions.length === 1) { + return checkSimpleExpression(expressions[0], version); + } else { + var startVersion = expressions[0], + endVersion = expressions[1]; + + !(isSimpleVersion(startVersion) && isSimpleVersion(endVersion)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'operands to the "-" operator must be simple (no modifiers)') : invariant(false) : void 0; + + return checkSimpleExpression('>=' + startVersion, version) && checkSimpleExpression('<=' + endVersion, version); + } +} + +/** + * Checks if `range` matches `version`. `range` should be a "simple" range (ie. + * not a compound range using the " - " or "||" operators). + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ +function checkSimpleExpression(range, version) { + range = range.trim(); + if (range === '') { + return true; + } + + var versionComponents = version.split(componentRegex); + + var _getModifierAndCompon = getModifierAndComponents(range), + modifier = _getModifierAndCompon.modifier, + rangeComponents = _getModifierAndCompon.rangeComponents; + + switch (modifier) { + case '<': + return checkLessThan(versionComponents, rangeComponents); + case '<=': + return checkLessThanOrEqual(versionComponents, rangeComponents); + case '>=': + return checkGreaterThanOrEqual(versionComponents, rangeComponents); + case '>': + return checkGreaterThan(versionComponents, rangeComponents); + case '~': + case '~>': + return checkApproximateVersion(versionComponents, rangeComponents); + default: + return checkEqual(versionComponents, rangeComponents); + } +} + +/** + * Checks whether `a` is less than `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkLessThan(a, b) { + return compareComponents(a, b) === -1; +} + +/** + * Checks whether `a` is less than or equal to `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkLessThanOrEqual(a, b) { + var result = compareComponents(a, b); + return result === -1 || result === 0; +} + +/** + * Checks whether `a` is equal to `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkEqual(a, b) { + return compareComponents(a, b) === 0; +} + +/** + * Checks whether `a` is greater than or equal to `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkGreaterThanOrEqual(a, b) { + var result = compareComponents(a, b); + return result === 1 || result === 0; +} + +/** + * Checks whether `a` is greater than `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkGreaterThan(a, b) { + return compareComponents(a, b) === 1; +} + +/** + * Checks whether `a` is "reasonably close" to `b` (as described in + * https://www.npmjs.org/doc/misc/semver.html). For example, if `b` is "1.3.1" + * then "reasonably close" is defined as ">= 1.3.1 and < 1.4". + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkApproximateVersion(a, b) { + var lowerBound = b.slice(); + var upperBound = b.slice(); + + if (upperBound.length > 1) { + upperBound.pop(); + } + var lastIndex = upperBound.length - 1; + var numeric = parseInt(upperBound[lastIndex], 10); + if (isNumber(numeric)) { + upperBound[lastIndex] = numeric + 1 + ''; + } + + return checkGreaterThanOrEqual(a, lowerBound) && checkLessThan(a, upperBound); +} + +/** + * Extracts the optional modifier (<, <=, =, >=, >, ~, ~>) and version + * components from `range`. + * + * For example, given `range` ">= 1.2.3" returns an object with a `modifier` of + * `">="` and `components` of `[1, 2, 3]`. + * + * @param {string} range + * @returns {object} + */ +function getModifierAndComponents(range) { + var rangeComponents = range.split(componentRegex); + var matches = rangeComponents[0].match(modifierRegex); + !matches ? process.env.NODE_ENV !== 'production' ? invariant(false, 'expected regex to match but it did not') : invariant(false) : void 0; + + return { + modifier: matches[1], + rangeComponents: [matches[2]].concat(rangeComponents.slice(1)) + }; +} + +/** + * Determines if `number` is a number. + * + * @param {mixed} number + * @returns {boolean} + */ +function isNumber(number) { + return !isNaN(number) && isFinite(number); +} + +/** + * Tests whether `range` is a "simple" version number without any modifiers + * (">", "~" etc). + * + * @param {string} range + * @returns {boolean} + */ +function isSimpleVersion(range) { + return !getModifierAndComponents(range).modifier; +} + +/** + * Zero-pads array `array` until it is at least `length` long. + * + * @param {array} array + * @param {number} length + */ +function zeroPad(array, length) { + for (var i = array.length; i < length; i++) { + array[i] = '0'; + } +} + +/** + * Normalizes `a` and `b` in preparation for comparison by doing the following: + * + * - zero-pads `a` and `b` + * - marks any "x", "X" or "*" component in `b` as equivalent by zero-ing it out + * in both `a` and `b` + * - marks any final "*" component in `b` as a greedy wildcard by zero-ing it + * and all of its successors in `a` + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {array<array<string>>} + */ +function normalizeVersions(a, b) { + a = a.slice(); + b = b.slice(); + + zeroPad(a, b.length); + + // mark "x" and "*" components as equal + for (var i = 0; i < b.length; i++) { + var matches = b[i].match(/^[x*]$/i); + if (matches) { + b[i] = a[i] = '0'; + + // final "*" greedily zeros all remaining components + if (matches[0] === '*' && i === b.length - 1) { + for (var j = i; j < a.length; j++) { + a[j] = '0'; + } + } + } + } + + zeroPad(b, a.length); + + return [a, b]; +} + +/** + * Returns the numerical -- not the lexicographical -- ordering of `a` and `b`. + * + * For example, `10-alpha` is greater than `2-beta`. + * + * @param {string} a + * @param {string} b + * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to, + * or greater than `b`, respectively + */ +function compareNumeric(a, b) { + var aPrefix = a.match(numericRegex)[1]; + var bPrefix = b.match(numericRegex)[1]; + var aNumeric = parseInt(aPrefix, 10); + var bNumeric = parseInt(bPrefix, 10); + + if (isNumber(aNumeric) && isNumber(bNumeric) && aNumeric !== bNumeric) { + return compare(aNumeric, bNumeric); + } else { + return compare(a, b); + } +} + +/** + * Returns the ordering of `a` and `b`. + * + * @param {string|number} a + * @param {string|number} b + * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to, + * or greater than `b`, respectively + */ +function compare(a, b) { + !(typeof a === typeof b) ? process.env.NODE_ENV !== 'production' ? invariant(false, '"a" and "b" must be of the same type') : invariant(false) : void 0; + + if (a > b) { + return 1; + } else if (a < b) { + return -1; + } else { + return 0; + } +} + +/** + * Compares arrays of version components. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to, + * or greater than `b`, respectively + */ +function compareComponents(a, b) { + var _normalizeVersions = normalizeVersions(a, b), + aNormalized = _normalizeVersions[0], + bNormalized = _normalizeVersions[1]; + + for (var i = 0; i < bNormalized.length; i++) { + var result = compareNumeric(aNormalized[i], bNormalized[i]); + if (result) { + return result; + } + } + + return 0; +} + +var VersionRange = { + /** + * Checks whether `version` satisfies the `range` specification. + * + * We support a subset of the expressions defined in + * https://www.npmjs.org/doc/misc/semver.html: + * + * version Must match version exactly + * =version Same as just version + * >version Must be greater than version + * >=version Must be greater than or equal to version + * <version Must be less than version + * <=version Must be less than or equal to version + * ~version Must be at least version, but less than the next significant + * revision above version: + * "~1.2.3" is equivalent to ">= 1.2.3 and < 1.3" + * ~>version Equivalent to ~version + * 1.2.x Must match "1.2.x", where "x" is a wildcard that matches + * anything + * 1.2.* Similar to "1.2.x", but "*" in the trailing position is a + * "greedy" wildcard, so will match any number of additional + * components: + * "1.2.*" will match "1.2.1", "1.2.1.1", "1.2.1.1.1" etc + * * Any version + * "" (Empty string) Same as * + * v1 - v2 Equivalent to ">= v1 and <= v2" + * r1 || r2 Passes if either r1 or r2 are satisfied + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ + contains: function contains(range, version) { + return checkOrExpression(range.trim(), version.trim()); + } +}; + +module.exports = VersionRange;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/VersionRange.js.flow b/node_modules/fbjs/lib/VersionRange.js.flow new file mode 100644 index 000000000..6aa27ed47 --- /dev/null +++ b/node_modules/fbjs/lib/VersionRange.js.flow @@ -0,0 +1,373 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule VersionRange + */ + +'use strict'; + +const invariant = require('./invariant'); + +const componentRegex = /\./; +const orRegex = /\|\|/; +const rangeRegex = /\s+\-\s+/; +const modifierRegex = /^(<=|<|=|>=|~>|~|>|)?\s*(.+)/; +const numericRegex = /^(\d*)(.*)/; + +/** + * Splits input `range` on "||" and returns true if any subrange matches + * `version`. + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ +function checkOrExpression(range, version) { + const expressions = range.split(orRegex); + + if (expressions.length > 1) { + return expressions.some(range => VersionRange.contains(range, version)); + } else { + range = expressions[0].trim(); + return checkRangeExpression(range, version); + } +} + +/** + * Splits input `range` on " - " (the surrounding whitespace is required) and + * returns true if version falls between the two operands. + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ +function checkRangeExpression(range, version) { + const expressions = range.split(rangeRegex); + + invariant(expressions.length > 0 && expressions.length <= 2, 'the "-" operator expects exactly 2 operands'); + + if (expressions.length === 1) { + return checkSimpleExpression(expressions[0], version); + } else { + const [startVersion, endVersion] = expressions; + invariant(isSimpleVersion(startVersion) && isSimpleVersion(endVersion), 'operands to the "-" operator must be simple (no modifiers)'); + + return checkSimpleExpression('>=' + startVersion, version) && checkSimpleExpression('<=' + endVersion, version); + } +} + +/** + * Checks if `range` matches `version`. `range` should be a "simple" range (ie. + * not a compound range using the " - " or "||" operators). + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ +function checkSimpleExpression(range, version) { + range = range.trim(); + if (range === '') { + return true; + } + + const versionComponents = version.split(componentRegex); + const { modifier, rangeComponents } = getModifierAndComponents(range); + switch (modifier) { + case '<': + return checkLessThan(versionComponents, rangeComponents); + case '<=': + return checkLessThanOrEqual(versionComponents, rangeComponents); + case '>=': + return checkGreaterThanOrEqual(versionComponents, rangeComponents); + case '>': + return checkGreaterThan(versionComponents, rangeComponents); + case '~': + case '~>': + return checkApproximateVersion(versionComponents, rangeComponents); + default: + return checkEqual(versionComponents, rangeComponents); + } +} + +/** + * Checks whether `a` is less than `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkLessThan(a, b) { + return compareComponents(a, b) === -1; +} + +/** + * Checks whether `a` is less than or equal to `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkLessThanOrEqual(a, b) { + const result = compareComponents(a, b); + return result === -1 || result === 0; +} + +/** + * Checks whether `a` is equal to `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkEqual(a, b) { + return compareComponents(a, b) === 0; +} + +/** + * Checks whether `a` is greater than or equal to `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkGreaterThanOrEqual(a, b) { + const result = compareComponents(a, b); + return result === 1 || result === 0; +} + +/** + * Checks whether `a` is greater than `b`. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkGreaterThan(a, b) { + return compareComponents(a, b) === 1; +} + +/** + * Checks whether `a` is "reasonably close" to `b` (as described in + * https://www.npmjs.org/doc/misc/semver.html). For example, if `b` is "1.3.1" + * then "reasonably close" is defined as ">= 1.3.1 and < 1.4". + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {boolean} + */ +function checkApproximateVersion(a, b) { + const lowerBound = b.slice(); + const upperBound = b.slice(); + + if (upperBound.length > 1) { + upperBound.pop(); + } + const lastIndex = upperBound.length - 1; + const numeric = parseInt(upperBound[lastIndex], 10); + if (isNumber(numeric)) { + upperBound[lastIndex] = numeric + 1 + ''; + } + + return checkGreaterThanOrEqual(a, lowerBound) && checkLessThan(a, upperBound); +} + +/** + * Extracts the optional modifier (<, <=, =, >=, >, ~, ~>) and version + * components from `range`. + * + * For example, given `range` ">= 1.2.3" returns an object with a `modifier` of + * `">="` and `components` of `[1, 2, 3]`. + * + * @param {string} range + * @returns {object} + */ +function getModifierAndComponents(range) { + const rangeComponents = range.split(componentRegex); + const matches = rangeComponents[0].match(modifierRegex); + invariant(matches, 'expected regex to match but it did not'); + + return { + modifier: matches[1], + rangeComponents: [matches[2]].concat(rangeComponents.slice(1)) + }; +} + +/** + * Determines if `number` is a number. + * + * @param {mixed} number + * @returns {boolean} + */ +function isNumber(number) { + return !isNaN(number) && isFinite(number); +} + +/** + * Tests whether `range` is a "simple" version number without any modifiers + * (">", "~" etc). + * + * @param {string} range + * @returns {boolean} + */ +function isSimpleVersion(range) { + return !getModifierAndComponents(range).modifier; +} + +/** + * Zero-pads array `array` until it is at least `length` long. + * + * @param {array} array + * @param {number} length + */ +function zeroPad(array, length) { + for (let i = array.length; i < length; i++) { + array[i] = '0'; + } +} + +/** + * Normalizes `a` and `b` in preparation for comparison by doing the following: + * + * - zero-pads `a` and `b` + * - marks any "x", "X" or "*" component in `b` as equivalent by zero-ing it out + * in both `a` and `b` + * - marks any final "*" component in `b` as a greedy wildcard by zero-ing it + * and all of its successors in `a` + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {array<array<string>>} + */ +function normalizeVersions(a, b) { + a = a.slice(); + b = b.slice(); + + zeroPad(a, b.length); + + // mark "x" and "*" components as equal + for (let i = 0; i < b.length; i++) { + const matches = b[i].match(/^[x*]$/i); + if (matches) { + b[i] = a[i] = '0'; + + // final "*" greedily zeros all remaining components + if (matches[0] === '*' && i === b.length - 1) { + for (let j = i; j < a.length; j++) { + a[j] = '0'; + } + } + } + } + + zeroPad(b, a.length); + + return [a, b]; +} + +/** + * Returns the numerical -- not the lexicographical -- ordering of `a` and `b`. + * + * For example, `10-alpha` is greater than `2-beta`. + * + * @param {string} a + * @param {string} b + * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to, + * or greater than `b`, respectively + */ +function compareNumeric(a, b) { + const aPrefix = a.match(numericRegex)[1]; + const bPrefix = b.match(numericRegex)[1]; + const aNumeric = parseInt(aPrefix, 10); + const bNumeric = parseInt(bPrefix, 10); + + if (isNumber(aNumeric) && isNumber(bNumeric) && aNumeric !== bNumeric) { + return compare(aNumeric, bNumeric); + } else { + return compare(a, b); + } +} + +/** + * Returns the ordering of `a` and `b`. + * + * @param {string|number} a + * @param {string|number} b + * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to, + * or greater than `b`, respectively + */ +function compare(a, b) { + invariant(typeof a === typeof b, '"a" and "b" must be of the same type'); + + if (a > b) { + return 1; + } else if (a < b) { + return -1; + } else { + return 0; + } +} + +/** + * Compares arrays of version components. + * + * @param {array<string>} a + * @param {array<string>} b + * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to, + * or greater than `b`, respectively + */ +function compareComponents(a, b) { + const [aNormalized, bNormalized] = normalizeVersions(a, b); + + for (let i = 0; i < bNormalized.length; i++) { + const result = compareNumeric(aNormalized[i], bNormalized[i]); + if (result) { + return result; + } + } + + return 0; +} + +var VersionRange = { + /** + * Checks whether `version` satisfies the `range` specification. + * + * We support a subset of the expressions defined in + * https://www.npmjs.org/doc/misc/semver.html: + * + * version Must match version exactly + * =version Same as just version + * >version Must be greater than version + * >=version Must be greater than or equal to version + * <version Must be less than version + * <=version Must be less than or equal to version + * ~version Must be at least version, but less than the next significant + * revision above version: + * "~1.2.3" is equivalent to ">= 1.2.3 and < 1.3" + * ~>version Equivalent to ~version + * 1.2.x Must match "1.2.x", where "x" is a wildcard that matches + * anything + * 1.2.* Similar to "1.2.x", but "*" in the trailing position is a + * "greedy" wildcard, so will match any number of additional + * components: + * "1.2.*" will match "1.2.1", "1.2.1.1", "1.2.1.1.1" etc + * * Any version + * "" (Empty string) Same as * + * v1 - v2 Equivalent to ">= v1 and <= v2" + * r1 || r2 Passes if either r1 or r2 are satisfied + * + * @param {string} range + * @param {string} version + * @returns {boolean} + */ + contains(range, version) { + return checkOrExpression(range.trim(), version.trim()); + } +}; + +module.exports = VersionRange;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/__mocks__/ErrorUtils.js b/node_modules/fbjs/lib/__mocks__/ErrorUtils.js new file mode 100644 index 000000000..f6a9944fa --- /dev/null +++ b/node_modules/fbjs/lib/__mocks__/ErrorUtils.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +var ErrorUtils = jest.genMockFromModule('../ErrorUtils'); + +ErrorUtils.applyWithGuard.mockImplementation(function (callback, context, args) { + return callback.apply(context, args); +}); + +ErrorUtils.guard.mockImplementation(function (callback) { + return callback; +}); + +module.exports = ErrorUtils;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/__mocks__/base62.js b/node_modules/fbjs/lib/__mocks__/base62.js new file mode 100644 index 000000000..560c0fdeb --- /dev/null +++ b/node_modules/fbjs/lib/__mocks__/base62.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +module.exports = require.requireActual('../base62');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/__mocks__/crc32.js b/node_modules/fbjs/lib/__mocks__/crc32.js new file mode 100644 index 000000000..9c4dfb3d6 --- /dev/null +++ b/node_modules/fbjs/lib/__mocks__/crc32.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +module.exports = require.requireActual('../crc32');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/__mocks__/fetch.js b/node_modules/fbjs/lib/__mocks__/fetch.js new file mode 100644 index 000000000..f91273729 --- /dev/null +++ b/node_modules/fbjs/lib/__mocks__/fetch.js @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @noflow + */ + +'use strict'; + +var Deferred = require.requireActual('../Deferred'); + +function fetch(uri, options) { + var deferred = new Deferred(); + fetch.mock.calls.push([uri, options]); + fetch.mock.deferreds.push(deferred); + return deferred.getPromise(); +} + +fetch.mock = { + calls: [], + deferreds: [] +}; + +module.exports = fetch;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/__mocks__/fetchWithRetries.js b/node_modules/fbjs/lib/__mocks__/fetchWithRetries.js new file mode 100644 index 000000000..a3309d209 --- /dev/null +++ b/node_modules/fbjs/lib/__mocks__/fetchWithRetries.js @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @noflow + */ + +'use strict'; + +var Deferred = require.requireActual('../Deferred'); + +function fetchWithRetries() { + var deferred = new Deferred(); + + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + fetchWithRetries.mock.calls.push(args); + fetchWithRetries.mock.deferreds.push(deferred); + return deferred.getPromise(); +} + +fetchWithRetries.mock = { + calls: [], + deferreds: [] +}; + +module.exports = fetchWithRetries;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/__mocks__/nullthrows.js b/node_modules/fbjs/lib/__mocks__/nullthrows.js new file mode 100644 index 000000000..fc07fa5b6 --- /dev/null +++ b/node_modules/fbjs/lib/__mocks__/nullthrows.js @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +jest.dontMock('../nullthrows'); + +module.exports = require('../nullthrows');
\ No newline at end of file diff --git a/node_modules/fbjs/lib/_shouldPolyfillES6Collection.js b/node_modules/fbjs/lib/_shouldPolyfillES6Collection.js new file mode 100644 index 000000000..f0d2d514e --- /dev/null +++ b/node_modules/fbjs/lib/_shouldPolyfillES6Collection.js @@ -0,0 +1,41 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @preventMunge + * + */ + +/** + * Checks whether a collection name (e.g. "Map" or "Set") has a native polyfill + * that is safe to be used. + */ +function shouldPolyfillES6Collection(collectionName) { + var Collection = global[collectionName]; + if (Collection == null) { + return true; + } + + // The iterator protocol depends on `Symbol.iterator`. If a collection is + // implemented, but `Symbol` is not, it's going to break iteration because + // we'll be using custom "@@iterator" instead, which is not implemented on + // native collections. + if (typeof global.Symbol !== 'function') { + return true; + } + + var proto = Collection.prototype; + + // These checks are adapted from es6-shim: https://fburl.com/34437854 + // NOTE: `isCallableWithoutNew` and `!supportsSubclassing` are not checked + // because they make debugging with "break on exceptions" difficult. + return Collection == null || typeof Collection !== 'function' || typeof proto.clear !== 'function' || new Collection().size !== 0 || typeof proto.keys !== 'function' || typeof proto.forEach !== 'function'; +} + +module.exports = shouldPolyfillES6Collection;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/_shouldPolyfillES6Collection.js.flow b/node_modules/fbjs/lib/_shouldPolyfillES6Collection.js.flow new file mode 100644 index 000000000..26298dbd4 --- /dev/null +++ b/node_modules/fbjs/lib/_shouldPolyfillES6Collection.js.flow @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule _shouldPolyfillES6Collection + * @preventMunge + * @flow + */ + +/** + * Checks whether a collection name (e.g. "Map" or "Set") has a native polyfill + * that is safe to be used. + */ +function shouldPolyfillES6Collection(collectionName: string): boolean { + const Collection = global[collectionName]; + if (Collection == null) { + return true; + } + + // The iterator protocol depends on `Symbol.iterator`. If a collection is + // implemented, but `Symbol` is not, it's going to break iteration because + // we'll be using custom "@@iterator" instead, which is not implemented on + // native collections. + if (typeof global.Symbol !== 'function') { + return true; + } + + const proto = Collection.prototype; + + // These checks are adapted from es6-shim: https://fburl.com/34437854 + // NOTE: `isCallableWithoutNew` and `!supportsSubclassing` are not checked + // because they make debugging with "break on exceptions" difficult. + return Collection == null || typeof Collection !== 'function' || typeof proto.clear !== 'function' || new Collection().size !== 0 || typeof proto.keys !== 'function' || typeof proto.forEach !== 'function'; +} + +module.exports = shouldPolyfillES6Collection;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/areEqual.js b/node_modules/fbjs/lib/areEqual.js new file mode 100644 index 000000000..ea8437aef --- /dev/null +++ b/node_modules/fbjs/lib/areEqual.js @@ -0,0 +1,108 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var aStackPool = []; +var bStackPool = []; + +/** + * Checks if two values are equal. Values may be primitives, arrays, or objects. + * Returns true if both arguments have the same keys and values. + * + * @see http://underscorejs.org + * @copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. + * @license MIT + */ +function areEqual(a, b) { + var aStack = aStackPool.length ? aStackPool.pop() : []; + var bStack = bStackPool.length ? bStackPool.pop() : []; + var result = eq(a, b, aStack, bStack); + aStack.length = 0; + bStack.length = 0; + aStackPool.push(aStack); + bStackPool.push(bStack); + return result; +} + +function eq(a, b, aStack, bStack) { + if (a === b) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + return a !== 0 || 1 / a == 1 / b; + } + if (a == null || b == null) { + // a or b can be `null` or `undefined` + return false; + } + if (typeof a != 'object' || typeof b != 'object') { + return false; + } + var objToStr = Object.prototype.toString; + var className = objToStr.call(a); + if (className != objToStr.call(b)) { + return false; + } + switch (className) { + case '[object String]': + return a == String(b); + case '[object Number]': + return isNaN(a) || isNaN(b) ? false : a == Number(b); + case '[object Date]': + case '[object Boolean]': + return +a == +b; + case '[object RegExp]': + return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; + } + // Assume equality for cyclic structures. + var length = aStack.length; + while (length--) { + if (aStack[length] == a) { + return bStack[length] == b; + } + } + aStack.push(a); + bStack.push(b); + var size = 0; + // Recursively compare objects and arrays. + if (className === '[object Array]') { + size = a.length; + if (size !== b.length) { + return false; + } + // Deep compare the contents, ignoring non-numeric properties. + while (size--) { + if (!eq(a[size], b[size], aStack, bStack)) { + return false; + } + } + } else { + if (a.constructor !== b.constructor) { + return false; + } + if (a.hasOwnProperty('valueOf') && b.hasOwnProperty('valueOf')) { + return a.valueOf() == b.valueOf(); + } + var keys = Object.keys(a); + if (keys.length != Object.keys(b).length) { + return false; + } + for (var i = 0; i < keys.length; i++) { + if (!eq(a[keys[i]], b[keys[i]], aStack, bStack)) { + return false; + } + } + } + aStack.pop(); + bStack.pop(); + return true; +} + +module.exports = areEqual;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/areEqual.js.flow b/node_modules/fbjs/lib/areEqual.js.flow new file mode 100644 index 000000000..67294f212 --- /dev/null +++ b/node_modules/fbjs/lib/areEqual.js.flow @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule areEqual + * @flow + */ + +const aStackPool = []; +const bStackPool = []; + +/** + * Checks if two values are equal. Values may be primitives, arrays, or objects. + * Returns true if both arguments have the same keys and values. + * + * @see http://underscorejs.org + * @copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. + * @license MIT + */ +function areEqual(a: any, b: any): boolean { + const aStack = aStackPool.length ? aStackPool.pop() : []; + const bStack = bStackPool.length ? bStackPool.pop() : []; + const result = eq(a, b, aStack, bStack); + aStack.length = 0; + bStack.length = 0; + aStackPool.push(aStack); + bStackPool.push(bStack); + return result; +} + +function eq(a: any, b: any, aStack: Array<any>, bStack: Array<any>): boolean { + if (a === b) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + return a !== 0 || 1 / a == 1 / b; + } + if (a == null || b == null) { + // a or b can be `null` or `undefined` + return false; + } + if (typeof a != 'object' || typeof b != 'object') { + return false; + } + const objToStr = Object.prototype.toString; + const className = objToStr.call(a); + if (className != objToStr.call(b)) { + return false; + } + switch (className) { + case '[object String]': + return a == String(b); + case '[object Number]': + return isNaN(a) || isNaN(b) ? false : a == Number(b); + case '[object Date]': + case '[object Boolean]': + return +a == +b; + case '[object RegExp]': + return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; + } + // Assume equality for cyclic structures. + let length = aStack.length; + while (length--) { + if (aStack[length] == a) { + return bStack[length] == b; + } + } + aStack.push(a); + bStack.push(b); + let size = 0; + // Recursively compare objects and arrays. + if (className === '[object Array]') { + size = a.length; + if (size !== b.length) { + return false; + } + // Deep compare the contents, ignoring non-numeric properties. + while (size--) { + if (!eq(a[size], b[size], aStack, bStack)) { + return false; + } + } + } else { + if (a.constructor !== b.constructor) { + return false; + } + if (a.hasOwnProperty('valueOf') && b.hasOwnProperty('valueOf')) { + return a.valueOf() == b.valueOf(); + } + const keys = Object.keys(a); + if (keys.length != Object.keys(b).length) { + return false; + } + for (let i = 0; i < keys.length; i++) { + if (!eq(a[keys[i]], b[keys[i]], aStack, bStack)) { + return false; + } + } + } + aStack.pop(); + bStack.pop(); + return true; +} + +module.exports = areEqual;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/base62.js b/node_modules/fbjs/lib/base62.js new file mode 100644 index 000000000..ec18ef998 --- /dev/null +++ b/node_modules/fbjs/lib/base62.js @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +'use strict'; + +var BASE62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +function base62(number) { + if (!number) { + return '0'; + } + var string = ''; + while (number > 0) { + string = BASE62[number % 62] + string; + number = Math.floor(number / 62); + } + return string; +} + +module.exports = base62;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/base62.js.flow b/node_modules/fbjs/lib/base62.js.flow new file mode 100644 index 000000000..a49d73b97 --- /dev/null +++ b/node_modules/fbjs/lib/base62.js.flow @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule base62 + * @flow + */ + +'use strict'; + +const BASE62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + +function base62(number: number): string { + if (!number) { + return '0'; + } + let string = ''; + while (number > 0) { + string = BASE62[number % 62] + string; + number = Math.floor(number / 62); + } + return string; +} + +module.exports = base62;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/camelize.js b/node_modules/fbjs/lib/camelize.js new file mode 100644 index 000000000..cf57a8dec --- /dev/null +++ b/node_modules/fbjs/lib/camelize.js @@ -0,0 +1,31 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var _hyphenPattern = /-(.)/g; + +/** + * Camelcases a hyphenated string, for example: + * + * > camelize('background-color') + * < "backgroundColor" + * + * @param {string} string + * @return {string} + */ +function camelize(string) { + return string.replace(_hyphenPattern, function (_, character) { + return character.toUpperCase(); + }); +} + +module.exports = camelize;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/camelize.js.flow b/node_modules/fbjs/lib/camelize.js.flow new file mode 100644 index 000000000..65972d7bb --- /dev/null +++ b/node_modules/fbjs/lib/camelize.js.flow @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule camelize + * @typechecks + */ + +const _hyphenPattern = /-(.)/g; + +/** + * Camelcases a hyphenated string, for example: + * + * > camelize('background-color') + * < "backgroundColor" + * + * @param {string} string + * @return {string} + */ +function camelize(string) { + return string.replace(_hyphenPattern, function (_, character) { + return character.toUpperCase(); + }); +} + +module.exports = camelize;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/camelizeStyleName.js b/node_modules/fbjs/lib/camelizeStyleName.js new file mode 100644 index 000000000..30a2d2197 --- /dev/null +++ b/node_modules/fbjs/lib/camelizeStyleName.js @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +var camelize = require('./camelize'); + +var msPattern = /^-ms-/; + +/** + * Camelcases a hyphenated CSS property name, for example: + * + * > camelizeStyleName('background-color') + * < "backgroundColor" + * > camelizeStyleName('-moz-transition') + * < "MozTransition" + * > camelizeStyleName('-ms-transition') + * < "msTransition" + * + * As Andi Smith suggests + * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix + * is converted to lowercase `ms`. + * + * @param {string} string + * @return {string} + */ +function camelizeStyleName(string) { + return camelize(string.replace(msPattern, 'ms-')); +} + +module.exports = camelizeStyleName;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/camelizeStyleName.js.flow b/node_modules/fbjs/lib/camelizeStyleName.js.flow new file mode 100644 index 000000000..c3a85d0f8 --- /dev/null +++ b/node_modules/fbjs/lib/camelizeStyleName.js.flow @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule camelizeStyleName + * @typechecks + */ + +'use strict'; + +const camelize = require('./camelize'); + +const msPattern = /^-ms-/; + +/** + * Camelcases a hyphenated CSS property name, for example: + * + * > camelizeStyleName('background-color') + * < "backgroundColor" + * > camelizeStyleName('-moz-transition') + * < "MozTransition" + * > camelizeStyleName('-ms-transition') + * < "msTransition" + * + * As Andi Smith suggests + * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix + * is converted to lowercase `ms`. + * + * @param {string} string + * @return {string} + */ +function camelizeStyleName(string) { + return camelize(string.replace(msPattern, 'ms-')); +} + +module.exports = camelizeStyleName;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/compactArray.js b/node_modules/fbjs/lib/compactArray.js new file mode 100644 index 000000000..5db775401 --- /dev/null +++ b/node_modules/fbjs/lib/compactArray.js @@ -0,0 +1,27 @@ +/** + * Copyright 2015-present Facebook. All Rights Reserved. + * + * @typechecks + * + */ + +'use strict'; + +/** + * Returns a new Array containing all the element of the source array except + * `null` and `undefined` ones. This brings the benefit of strong typing over + * `Array.prototype.filter`. + */ + +function compactArray(array) { + var result = []; + for (var i = 0; i < array.length; ++i) { + var elem = array[i]; + if (elem != null) { + result.push(elem); + } + } + return result; +} + +module.exports = compactArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/compactArray.js.flow b/node_modules/fbjs/lib/compactArray.js.flow new file mode 100644 index 000000000..5b8ccbecb --- /dev/null +++ b/node_modules/fbjs/lib/compactArray.js.flow @@ -0,0 +1,28 @@ +/** + * Copyright 2015-present Facebook. All Rights Reserved. + * + * @providesModule compactArray + * @typechecks + * @flow + */ + +'use strict'; + +/** + * Returns a new Array containing all the element of the source array except + * `null` and `undefined` ones. This brings the benefit of strong typing over + * `Array.prototype.filter`. + */ + +function compactArray<T>(array: Array<T | null | void>): Array<T> { + var result = []; + for (var i = 0; i < array.length; ++i) { + var elem = array[i]; + if (elem != null) { + result.push(elem); + } + } + return result; +} + +module.exports = compactArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/concatAllArray.js b/node_modules/fbjs/lib/concatAllArray.js new file mode 100644 index 000000000..00cbfb9ea --- /dev/null +++ b/node_modules/fbjs/lib/concatAllArray.js @@ -0,0 +1,35 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var push = Array.prototype.push; + +/** + * Concats an array of arrays into a single flat array. + * + * @param {array} array + * @return {array} + */ +function concatAllArray(array) { + var ret = []; + for (var ii = 0; ii < array.length; ii++) { + var value = array[ii]; + if (Array.isArray(value)) { + push.apply(ret, value); + } else if (value != null) { + throw new TypeError('concatAllArray: All items in the array must be an array or null, ' + 'got "' + value + '" at index "' + ii + '" instead'); + } + } + return ret; +} + +module.exports = concatAllArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/concatAllArray.js.flow b/node_modules/fbjs/lib/concatAllArray.js.flow new file mode 100644 index 000000000..c3327564a --- /dev/null +++ b/node_modules/fbjs/lib/concatAllArray.js.flow @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule concatAllArray + * @typechecks + */ + +var push = Array.prototype.push; + +/** + * Concats an array of arrays into a single flat array. + * + * @param {array} array + * @return {array} + */ +function concatAllArray(array) { + var ret = []; + for (var ii = 0; ii < array.length; ii++) { + var value = array[ii]; + if (Array.isArray(value)) { + push.apply(ret, value); + } else if (value != null) { + throw new TypeError('concatAllArray: All items in the array must be an array or null, ' + 'got "' + value + '" at index "' + ii + '" instead'); + } + } + return ret; +} + +module.exports = concatAllArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/containsNode.js b/node_modules/fbjs/lib/containsNode.js new file mode 100644 index 000000000..ba30d1a73 --- /dev/null +++ b/node_modules/fbjs/lib/containsNode.js @@ -0,0 +1,39 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var isTextNode = require('./isTextNode'); + +/*eslint-disable no-bitwise */ + +/** + * Checks if a given DOM node contains or is another DOM node. + */ +function containsNode(outerNode, innerNode) { + if (!outerNode || !innerNode) { + return false; + } else if (outerNode === innerNode) { + return true; + } else if (isTextNode(outerNode)) { + return false; + } else if (isTextNode(innerNode)) { + return containsNode(outerNode, innerNode.parentNode); + } else if ('contains' in outerNode) { + return outerNode.contains(innerNode); + } else if (outerNode.compareDocumentPosition) { + return !!(outerNode.compareDocumentPosition(innerNode) & 16); + } else { + return false; + } +} + +module.exports = containsNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/containsNode.js.flow b/node_modules/fbjs/lib/containsNode.js.flow new file mode 100644 index 000000000..b4d3ed851 --- /dev/null +++ b/node_modules/fbjs/lib/containsNode.js.flow @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule containsNode + * @flow + */ + +const isTextNode = require('./isTextNode'); + +/*eslint-disable no-bitwise */ + +/** + * Checks if a given DOM node contains or is another DOM node. + */ +function containsNode(outerNode: ?Node, innerNode: ?Node): boolean { + if (!outerNode || !innerNode) { + return false; + } else if (outerNode === innerNode) { + return true; + } else if (isTextNode(outerNode)) { + return false; + } else if (isTextNode(innerNode)) { + return containsNode(outerNode, innerNode.parentNode); + } else if ('contains' in outerNode) { + return outerNode.contains(innerNode); + } else if (outerNode.compareDocumentPosition) { + return !!(outerNode.compareDocumentPosition(innerNode) & 16); + } else { + return false; + } +} + +module.exports = containsNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/countDistinct.js b/node_modules/fbjs/lib/countDistinct.js new file mode 100644 index 000000000..1089d13b5 --- /dev/null +++ b/node_modules/fbjs/lib/countDistinct.js @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +'use strict'; + +var Set = require('./Set'); + +var emptyFunction = require('./emptyFunction'); + +/** + * Returns the count of distinct elements selected from an array. + */ +function countDistinct(iter, selector) { + selector = selector || emptyFunction.thatReturnsArgument; + + var set = new Set(); + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = iter[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var val = _step.value; + + set.add(selector(val)); + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator['return']) { + _iterator['return'](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return set.size; +} + +module.exports = countDistinct;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/countDistinct.js.flow b/node_modules/fbjs/lib/countDistinct.js.flow new file mode 100644 index 000000000..9fd9ca490 --- /dev/null +++ b/node_modules/fbjs/lib/countDistinct.js.flow @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule countDistinct + * @flow + */ + +'use strict'; + +var Set = require('./Set'); + +var emptyFunction = require('./emptyFunction'); + +/** + * Returns the count of distinct elements selected from an array. + */ +function countDistinct<T1, T2>(iter: Iterable<T1>, selector: (item: T1) => T2): number { + selector = selector || emptyFunction.thatReturnsArgument; + + var set = new Set(); + for (var val of iter) { + set.add(selector(val)); + } + + return set.size; +} + +module.exports = countDistinct;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/crc32.js b/node_modules/fbjs/lib/crc32.js new file mode 100644 index 000000000..657f4cc63 --- /dev/null +++ b/node_modules/fbjs/lib/crc32.js @@ -0,0 +1,29 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +function crc32(str) { + /* jslint bitwise: true */ + var crc = -1; + for (var i = 0, len = str.length; i < len; i++) { + crc = crc >>> 8 ^ table[(crc ^ str.charCodeAt(i)) & 0xFF]; + } + return ~crc; +} + +var table = [0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D]; + +if (global.Int32Array !== undefined) { + table = new Int32Array(table); +} + +module.exports = crc32;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/crc32.js.flow b/node_modules/fbjs/lib/crc32.js.flow new file mode 100644 index 000000000..2ab8c2e6c --- /dev/null +++ b/node_modules/fbjs/lib/crc32.js.flow @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule crc32 + * @flow + */ + +function crc32(str: string): number { + /* jslint bitwise: true */ + var crc = -1; + for (var i = 0, len = str.length; i < len; i++) { + crc = crc >>> 8 ^ table[(crc ^ str.charCodeAt(i)) & 0xFF]; + } + return ~crc; +} + +var table = [0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D]; + +if (global.Int32Array !== undefined) { + table = new Int32Array(table); +} + +module.exports = crc32;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/createArrayFromMixed.js b/node_modules/fbjs/lib/createArrayFromMixed.js new file mode 100644 index 000000000..ce027028c --- /dev/null +++ b/node_modules/fbjs/lib/createArrayFromMixed.js @@ -0,0 +1,126 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var invariant = require('./invariant'); + +/** + * Convert array-like objects to arrays. + * + * This API assumes the caller knows the contents of the data type. For less + * well defined inputs use createArrayFromMixed. + * + * @param {object|function|filelist} obj + * @return {array} + */ +function toArray(obj) { + var length = obj.length; + + // Some browsers builtin objects can report typeof 'function' (e.g. NodeList + // in old versions of Safari). + !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0; + + !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0; + + !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0; + + !(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0; + + // Old IE doesn't give collections access to hasOwnProperty. Assume inputs + // without method will throw during the slice call and skip straight to the + // fallback. + if (obj.hasOwnProperty) { + try { + return Array.prototype.slice.call(obj); + } catch (e) { + // IE < 9 does not support Array#slice on collections objects + } + } + + // Fall back to copying key by key. This assumes all keys have a value, + // so will not preserve sparsely populated inputs. + var ret = Array(length); + for (var ii = 0; ii < length; ii++) { + ret[ii] = obj[ii]; + } + return ret; +} + +/** + * Perform a heuristic test to determine if an object is "array-like". + * + * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" + * Joshu replied: "Mu." + * + * This function determines if its argument has "array nature": it returns + * true if the argument is an actual array, an `arguments' object, or an + * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). + * + * It will return false for other array-like objects like Filelist. + * + * @param {*} obj + * @return {boolean} + */ +function hasArrayNature(obj) { + return ( + // not null/false + !!obj && ( + // arrays are objects, NodeLists are functions in Safari + typeof obj == 'object' || typeof obj == 'function') && + // quacks like an array + 'length' in obj && + // not window + !('setInterval' in obj) && + // no DOM node should be considered an array-like + // a 'select' element has 'length' and 'item' properties on IE8 + typeof obj.nodeType != 'number' && ( + // a real array + Array.isArray(obj) || + // arguments + 'callee' in obj || + // HTMLCollection/NodeList + 'item' in obj) + ); +} + +/** + * Ensure that the argument is an array by wrapping it in an array if it is not. + * Creates a copy of the argument if it is already an array. + * + * This is mostly useful idiomatically: + * + * var createArrayFromMixed = require('createArrayFromMixed'); + * + * function takesOneOrMoreThings(things) { + * things = createArrayFromMixed(things); + * ... + * } + * + * This allows you to treat `things' as an array, but accept scalars in the API. + * + * If you need to convert an array-like object, like `arguments`, into an array + * use toArray instead. + * + * @param {*} obj + * @return {array} + */ +function createArrayFromMixed(obj) { + if (!hasArrayNature(obj)) { + return [obj]; + } else if (Array.isArray(obj)) { + return obj.slice(); + } else { + return toArray(obj); + } +} + +module.exports = createArrayFromMixed;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/createArrayFromMixed.js.flow b/node_modules/fbjs/lib/createArrayFromMixed.js.flow new file mode 100644 index 000000000..9bed48e0e --- /dev/null +++ b/node_modules/fbjs/lib/createArrayFromMixed.js.flow @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule createArrayFromMixed + * @typechecks + */ + +const invariant = require('./invariant'); + +/** + * Convert array-like objects to arrays. + * + * This API assumes the caller knows the contents of the data type. For less + * well defined inputs use createArrayFromMixed. + * + * @param {object|function|filelist} obj + * @return {array} + */ +function toArray(obj) { + const length = obj.length; + + // Some browsers builtin objects can report typeof 'function' (e.g. NodeList + // in old versions of Safari). + invariant(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function'), 'toArray: Array-like object expected'); + + invariant(typeof length === 'number', 'toArray: Object needs a length property'); + + invariant(length === 0 || length - 1 in obj, 'toArray: Object should have keys for indices'); + + invariant(typeof obj.callee !== 'function', 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.'); + + // Old IE doesn't give collections access to hasOwnProperty. Assume inputs + // without method will throw during the slice call and skip straight to the + // fallback. + if (obj.hasOwnProperty) { + try { + return Array.prototype.slice.call(obj); + } catch (e) { + // IE < 9 does not support Array#slice on collections objects + } + } + + // Fall back to copying key by key. This assumes all keys have a value, + // so will not preserve sparsely populated inputs. + const ret = Array(length); + for (let ii = 0; ii < length; ii++) { + ret[ii] = obj[ii]; + } + return ret; +} + +/** + * Perform a heuristic test to determine if an object is "array-like". + * + * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" + * Joshu replied: "Mu." + * + * This function determines if its argument has "array nature": it returns + * true if the argument is an actual array, an `arguments' object, or an + * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). + * + * It will return false for other array-like objects like Filelist. + * + * @param {*} obj + * @return {boolean} + */ +function hasArrayNature(obj) { + return ( + // not null/false + !!obj && ( + // arrays are objects, NodeLists are functions in Safari + typeof obj == 'object' || typeof obj == 'function') && + // quacks like an array + 'length' in obj && + // not window + !('setInterval' in obj) && + // no DOM node should be considered an array-like + // a 'select' element has 'length' and 'item' properties on IE8 + typeof obj.nodeType != 'number' && ( + // a real array + Array.isArray(obj) || + // arguments + 'callee' in obj || + // HTMLCollection/NodeList + 'item' in obj) + ); +} + +/** + * Ensure that the argument is an array by wrapping it in an array if it is not. + * Creates a copy of the argument if it is already an array. + * + * This is mostly useful idiomatically: + * + * var createArrayFromMixed = require('createArrayFromMixed'); + * + * function takesOneOrMoreThings(things) { + * things = createArrayFromMixed(things); + * ... + * } + * + * This allows you to treat `things' as an array, but accept scalars in the API. + * + * If you need to convert an array-like object, like `arguments`, into an array + * use toArray instead. + * + * @param {*} obj + * @return {array} + */ +function createArrayFromMixed(obj) { + if (!hasArrayNature(obj)) { + return [obj]; + } else if (Array.isArray(obj)) { + return obj.slice(); + } else { + return toArray(obj); + } +} + +module.exports = createArrayFromMixed;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/createNodesFromMarkup.js b/node_modules/fbjs/lib/createNodesFromMarkup.js new file mode 100644 index 000000000..6d226d929 --- /dev/null +++ b/node_modules/fbjs/lib/createNodesFromMarkup.js @@ -0,0 +1,83 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/*eslint-disable fb-www/unsafe-html*/ + +var ExecutionEnvironment = require('./ExecutionEnvironment'); + +var createArrayFromMixed = require('./createArrayFromMixed'); +var getMarkupWrap = require('./getMarkupWrap'); +var invariant = require('./invariant'); + +/** + * Dummy container used to render all markup. + */ +var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; + +/** + * Pattern used by `getNodeName`. + */ +var nodeNamePattern = /^\s*<(\w+)/; + +/** + * Extracts the `nodeName` of the first element in a string of markup. + * + * @param {string} markup String of markup. + * @return {?string} Node name of the supplied markup. + */ +function getNodeName(markup) { + var nodeNameMatch = markup.match(nodeNamePattern); + return nodeNameMatch && nodeNameMatch[1].toLowerCase(); +} + +/** + * Creates an array containing the nodes rendered from the supplied markup. The + * optionally supplied `handleScript` function will be invoked once for each + * <script> element that is rendered. If no `handleScript` function is supplied, + * an exception is thrown if any <script> elements are rendered. + * + * @param {string} markup A string of valid HTML markup. + * @param {?function} handleScript Invoked once for each rendered <script>. + * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes. + */ +function createNodesFromMarkup(markup, handleScript) { + var node = dummyNode; + !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : void 0; + var nodeName = getNodeName(markup); + + var wrap = nodeName && getMarkupWrap(nodeName); + if (wrap) { + node.innerHTML = wrap[1] + markup + wrap[2]; + + var wrapDepth = wrap[0]; + while (wrapDepth--) { + node = node.lastChild; + } + } else { + node.innerHTML = markup; + } + + var scripts = node.getElementsByTagName('script'); + if (scripts.length) { + !handleScript ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : void 0; + createArrayFromMixed(scripts).forEach(handleScript); + } + + var nodes = Array.from(node.childNodes); + while (node.lastChild) { + node.removeChild(node.lastChild); + } + return nodes; +} + +module.exports = createNodesFromMarkup;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/createNodesFromMarkup.js.flow b/node_modules/fbjs/lib/createNodesFromMarkup.js.flow new file mode 100644 index 000000000..5d85d9eb5 --- /dev/null +++ b/node_modules/fbjs/lib/createNodesFromMarkup.js.flow @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule createNodesFromMarkup + * @typechecks + */ + +/*eslint-disable fb-www/unsafe-html*/ + +const ExecutionEnvironment = require('./ExecutionEnvironment'); + +const createArrayFromMixed = require('./createArrayFromMixed'); +const getMarkupWrap = require('./getMarkupWrap'); +const invariant = require('./invariant'); + +/** + * Dummy container used to render all markup. + */ +const dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; + +/** + * Pattern used by `getNodeName`. + */ +const nodeNamePattern = /^\s*<(\w+)/; + +/** + * Extracts the `nodeName` of the first element in a string of markup. + * + * @param {string} markup String of markup. + * @return {?string} Node name of the supplied markup. + */ +function getNodeName(markup) { + const nodeNameMatch = markup.match(nodeNamePattern); + return nodeNameMatch && nodeNameMatch[1].toLowerCase(); +} + +/** + * Creates an array containing the nodes rendered from the supplied markup. The + * optionally supplied `handleScript` function will be invoked once for each + * <script> element that is rendered. If no `handleScript` function is supplied, + * an exception is thrown if any <script> elements are rendered. + * + * @param {string} markup A string of valid HTML markup. + * @param {?function} handleScript Invoked once for each rendered <script>. + * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes. + */ +function createNodesFromMarkup(markup, handleScript) { + let node = dummyNode; + invariant(!!dummyNode, 'createNodesFromMarkup dummy not initialized'); + const nodeName = getNodeName(markup); + + const wrap = nodeName && getMarkupWrap(nodeName); + if (wrap) { + node.innerHTML = wrap[1] + markup + wrap[2]; + + let wrapDepth = wrap[0]; + while (wrapDepth--) { + node = node.lastChild; + } + } else { + node.innerHTML = markup; + } + + const scripts = node.getElementsByTagName('script'); + if (scripts.length) { + invariant(handleScript, 'createNodesFromMarkup(...): Unexpected <script> element rendered.'); + createArrayFromMixed(scripts).forEach(handleScript); + } + + const nodes = Array.from(node.childNodes); + while (node.lastChild) { + node.removeChild(node.lastChild); + } + return nodes; +} + +module.exports = createNodesFromMarkup;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/cx.js b/node_modules/fbjs/lib/cx.js new file mode 100644 index 000000000..def43a695 --- /dev/null +++ b/node_modules/fbjs/lib/cx.js @@ -0,0 +1,41 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +/** + * This function is used to mark string literals representing CSS class names + * so that they can be transformed statically. This allows for modularization + * and minification of CSS class names. + * + * In static_upstream, this function is actually implemented, but it should + * eventually be replaced with something more descriptive, and the transform + * that is used in the main stack should be ported for use elsewhere. + * + * @param string|object className to modularize, or an object of key/values. + * In the object case, the values are conditions that + * determine if the className keys should be included. + * @param [string ...] Variable list of classNames in the string case. + * @return string Renderable space-separated CSS className. + */ +function cx(classNames) { + if (typeof classNames == 'object') { + return Object.keys(classNames).filter(function (className) { + return classNames[className]; + }).map(replace).join(' '); + } + return Array.prototype.map.call(arguments, replace).join(' '); +} + +function replace(str) { + return str.replace(/\//g, '-'); +} + +module.exports = cx;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/cx.js.flow b/node_modules/fbjs/lib/cx.js.flow new file mode 100644 index 000000000..99ba126f6 --- /dev/null +++ b/node_modules/fbjs/lib/cx.js.flow @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule cx + */ + +/** + * This function is used to mark string literals representing CSS class names + * so that they can be transformed statically. This allows for modularization + * and minification of CSS class names. + * + * In static_upstream, this function is actually implemented, but it should + * eventually be replaced with something more descriptive, and the transform + * that is used in the main stack should be ported for use elsewhere. + * + * @param string|object className to modularize, or an object of key/values. + * In the object case, the values are conditions that + * determine if the className keys should be included. + * @param [string ...] Variable list of classNames in the string case. + * @return string Renderable space-separated CSS className. + */ +function cx(classNames) { + if (typeof classNames == 'object') { + return Object.keys(classNames).filter(className => classNames[className]).map(replace).join(' '); + } + return Array.prototype.map.call(arguments, replace).join(' '); +} + +function replace(str) { + return str.replace(/\//g, '-'); +} + +module.exports = cx;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/distinctArray.js b/node_modules/fbjs/lib/distinctArray.js new file mode 100644 index 000000000..ce5192468 --- /dev/null +++ b/node_modules/fbjs/lib/distinctArray.js @@ -0,0 +1,24 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var Set = require('./Set'); + +/** + * Returns the distinct elements of an iterable. The result is an array whose + * elements are ordered by first occurrence. + */ +function distinctArray(xs) { + return Array.from(new Set(xs).values()); +} + +module.exports = distinctArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/distinctArray.js.flow b/node_modules/fbjs/lib/distinctArray.js.flow new file mode 100644 index 000000000..98479d664 --- /dev/null +++ b/node_modules/fbjs/lib/distinctArray.js.flow @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule distinctArray + * @flow + */ + +var Set = require('./Set'); + +/** + * Returns the distinct elements of an iterable. The result is an array whose + * elements are ordered by first occurrence. + */ +function distinctArray<T>(xs: Iterable<T>): Array<T> { + return Array.from(new Set(xs).values()); +} + +module.exports = distinctArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/emptyFunction.js b/node_modules/fbjs/lib/emptyFunction.js new file mode 100644 index 000000000..9f06dc060 --- /dev/null +++ b/node_modules/fbjs/lib/emptyFunction.js @@ -0,0 +1,38 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +function makeEmptyFunction(arg) { + return function () { + return arg; + }; +} + +/** + * This function accepts and discards inputs; it has no side effects. This is + * primarily useful idiomatically for overridable function endpoints which + * always need to be callable, since JS lacks a null-call idiom ala Cocoa. + */ +var emptyFunction = function emptyFunction() {}; + +emptyFunction.thatReturns = makeEmptyFunction; +emptyFunction.thatReturnsFalse = makeEmptyFunction(false); +emptyFunction.thatReturnsTrue = makeEmptyFunction(true); +emptyFunction.thatReturnsNull = makeEmptyFunction(null); +emptyFunction.thatReturnsThis = function () { + return this; +}; +emptyFunction.thatReturnsArgument = function (arg) { + return arg; +}; + +module.exports = emptyFunction;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/emptyFunction.js.flow b/node_modules/fbjs/lib/emptyFunction.js.flow new file mode 100644 index 000000000..26076b07c --- /dev/null +++ b/node_modules/fbjs/lib/emptyFunction.js.flow @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule emptyFunction + * @flow + */ + +function makeEmptyFunction<T>(arg: T): (...args: Array<any>) => T { + return function () { + return arg; + }; +} + +/** + * This function accepts and discards inputs; it has no side effects. This is + * primarily useful idiomatically for overridable function endpoints which + * always need to be callable, since JS lacks a null-call idiom ala Cocoa. + */ +const emptyFunction: (...args: Array<any>) => void = function () {}; + +emptyFunction.thatReturns = makeEmptyFunction; +emptyFunction.thatReturnsFalse = makeEmptyFunction(false); +emptyFunction.thatReturnsTrue = makeEmptyFunction(true); +emptyFunction.thatReturnsNull = makeEmptyFunction(null); +emptyFunction.thatReturnsThis = function () { + return this; +}; +emptyFunction.thatReturnsArgument = function (arg) { + return arg; +}; + +module.exports = emptyFunction;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/emptyObject.js b/node_modules/fbjs/lib/emptyObject.js new file mode 100644 index 000000000..c3373ff51 --- /dev/null +++ b/node_modules/fbjs/lib/emptyObject.js @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var emptyObject = {}; + +if (process.env.NODE_ENV !== 'production') { + Object.freeze(emptyObject); +} + +module.exports = emptyObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/emptyObject.js.flow b/node_modules/fbjs/lib/emptyObject.js.flow new file mode 100644 index 000000000..bf9cfd8d8 --- /dev/null +++ b/node_modules/fbjs/lib/emptyObject.js.flow @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule emptyObject + */ + +'use strict'; + +const emptyObject = {}; + +if (__DEV__) { + Object.freeze(emptyObject); +} + +module.exports = emptyObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/enumerate.js b/node_modules/fbjs/lib/enumerate.js new file mode 100644 index 000000000..3ca365056 --- /dev/null +++ b/node_modules/fbjs/lib/enumerate.js @@ -0,0 +1,307 @@ +'use strict'; + +var _assign = require('object-assign'); + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var KIND_KEYS = 'keys'; +var KIND_VALUES = 'values'; +var KIND_ENTRIES = 'entries'; + +/** + * Specific Array iterators. + */ +var ArrayIterators = function () { + + var hasNative = hasNativeIterator(Array); + var ArrayIterator = void 0; + + if (!hasNative) { + ArrayIterator = function () { + // 22.1.5.1 CreateArrayIterator Abstract Operation + function ArrayIterator(array, kind) { + _classCallCheck(this, ArrayIterator); + + this._iteratedObject = array; + this._kind = kind; + this._nextIndex = 0; + } + + // 22.1.5.2.1 %ArrayIteratorPrototype%.next() + + + ArrayIterator.prototype.next = function next() { + if (this._iteratedObject == null) { + return { value: undefined, done: true }; + } + + var array = this._iteratedObject; + var len = this._iteratedObject.length; + var index = this._nextIndex; + var kind = this._kind; + + if (index >= len) { + this._iteratedObject = undefined; + return { value: undefined, done: true }; + } + + this._nextIndex = index + 1; + + if (kind === KIND_KEYS) { + return { value: index, done: false }; + } else if (kind === KIND_VALUES) { + return { value: array[index], done: false }; + } else if (kind === KIND_ENTRIES) { + return { value: [index, array[index]], done: false }; + } + }; + + // 22.1.5.2.2 %ArrayIteratorPrototype%[@@iterator]() + + + ArrayIterator.prototype[Symbol.iterator] = function () { + return this; + }; + + return ArrayIterator; + }(); + } + + return { + keys: hasNative ? function (array) { + return array.keys(); + } : function (array) { + return new ArrayIterator(array, KIND_KEYS); + }, + + values: hasNative ? function (array) { + return array.values(); + } : function (array) { + return new ArrayIterator(array, KIND_VALUES); + }, + + entries: hasNative ? function (array) { + return array.entries(); + } : function (array) { + return new ArrayIterator(array, KIND_ENTRIES); + } + }; +}(); + +// ----------------------------------------------------------------- + +/** + * Specific String iterators. + */ +var StringIterators = function () { + + var hasNative = hasNativeIterator(String); + var StringIterator = void 0; + + if (!hasNative) { + StringIterator = function () { + // 21.1.5.1 CreateStringIterator Abstract Operation + function StringIterator(string) { + _classCallCheck(this, StringIterator); + + this._iteratedString = string; + this._nextIndex = 0; + } + + // 21.1.5.2.1 %StringIteratorPrototype%.next() + + + StringIterator.prototype.next = function next() { + if (this._iteratedString == null) { + return { value: undefined, done: true }; + } + + var index = this._nextIndex; + var s = this._iteratedString; + var len = s.length; + + if (index >= len) { + this._iteratedString = undefined; + return { value: undefined, done: true }; + } + + var ret = void 0; + var first = s.charCodeAt(index); + + if (first < 0xD800 || first > 0xDBFF || index + 1 === len) { + ret = s[index]; + } else { + var second = s.charCodeAt(index + 1); + if (second < 0xDC00 || second > 0xDFFF) { + ret = s[index]; + } else { + ret = s[index] + s[index + 1]; + } + } + + this._nextIndex = index + ret.length; + + return { value: ret, done: false }; + }; + + // 21.1.5.2.2 %StringIteratorPrototype%[@@iterator]() + + + StringIterator.prototype[Symbol.iterator] = function () { + return this; + }; + + return StringIterator; + }(); + } + + return { + keys: function keys() { + throw TypeError('Strings default iterator doesn\'t implement keys.'); + }, + + + values: hasNative ? function (string) { + return string[Symbol.iterator](); + } : function (string) { + return new StringIterator(string); + }, + + entries: function entries() { + throw TypeError('Strings default iterator doesn\'t implement entries.'); + } + }; +}(); + +function hasNativeIterator(classObject) { + return typeof classObject.prototype[Symbol.iterator] === 'function' && typeof classObject.prototype.values === 'function' && typeof classObject.prototype.keys === 'function' && typeof classObject.prototype.entries === 'function'; +} + +// ----------------------------------------------------------------- + +/** + * Generic object iterator. + */ + +var ObjectIterator = function () { + function ObjectIterator(object, kind) { + _classCallCheck(this, ObjectIterator); + + this._iteratedObject = object; + this._kind = kind; + this._keys = Object.keys(object); + this._nextIndex = 0; + } + + ObjectIterator.prototype.next = function next() { + var len = this._keys.length; + var index = this._nextIndex; + var kind = this._kind; + var key = this._keys[index]; + + if (index >= len) { + this._iteratedObject = undefined; + return { value: undefined, done: true }; + } + + this._nextIndex = index + 1; + + if (kind === KIND_KEYS) { + return { value: key, done: false }; + } else if (kind === KIND_VALUES) { + return { value: this._iteratedObject[key], done: false }; + } else if (kind === KIND_ENTRIES) { + return { value: [key, this._iteratedObject[key]], done: false }; + } + }; + + ObjectIterator.prototype[Symbol.iterator] = function () { + return this; + }; + + return ObjectIterator; +}(); + +/** + * Generic object iterator, iterates over all own enumerable + * properties. Used only if if no specific iterator is available, + * and object don't implement iterator protocol. + */ + + +var GenericIterators = { + keys: function keys(object) { + return new ObjectIterator(object, KIND_KEYS); + }, + values: function values(object) { + return new ObjectIterator(object, KIND_VALUES); + }, + entries: function entries(object) { + return new ObjectIterator(object, KIND_ENTRIES); + } +}; + +// ----------------------------------------------------------------- + +/** + * Main iterator function. Returns default iterator based + * on the class of an instance. + */ +function enumerate(object, kind) { + + // First check specific iterators. + if (typeof object === 'string') { + return StringIterators[kind || KIND_VALUES](object); + } else if (Array.isArray(object)) { + return ArrayIterators[kind || KIND_VALUES](object); + + // Then see if an object implements own. + } else if (object[Symbol.iterator]) { + return object[Symbol.iterator](); + + // And fallback to generic with entries. + } else { + return GenericIterators[kind || KIND_ENTRIES](object); + } +} + +_assign(enumerate, { + /** + * Export constants + */ + + KIND_KEYS: KIND_KEYS, + KIND_VALUES: KIND_VALUES, + KIND_ENTRIES: KIND_ENTRIES, + + /** + * Convenient explicit iterators for special kinds. + */ + + keys: function keys(object) { + return enumerate(object, KIND_KEYS); + }, + values: function values(object) { + return enumerate(object, KIND_VALUES); + }, + entries: function entries(object) { + return enumerate(object, KIND_ENTRIES); + }, + + + generic: GenericIterators.entries + +}); + +module.exports = enumerate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/enumerate.js.flow b/node_modules/fbjs/lib/enumerate.js.flow new file mode 100644 index 000000000..f4112803a --- /dev/null +++ b/node_modules/fbjs/lib/enumerate.js.flow @@ -0,0 +1,265 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule enumerate + * + */ + +const KIND_KEYS = 'keys'; +const KIND_VALUES = 'values'; +const KIND_ENTRIES = 'entries'; + +/** + * Specific Array iterators. + */ +const ArrayIterators = function () { + + let hasNative = hasNativeIterator(Array); + let ArrayIterator; + + if (!hasNative) { + ArrayIterator = class ArrayIterator { + // 22.1.5.1 CreateArrayIterator Abstract Operation + constructor(array, kind) { + this._iteratedObject = array; + this._kind = kind; + this._nextIndex = 0; + } + + // 22.1.5.2.1 %ArrayIteratorPrototype%.next() + next() { + if (this._iteratedObject == null) { + return { value: undefined, done: true }; + } + + let array = this._iteratedObject; + let len = this._iteratedObject.length; + let index = this._nextIndex; + let kind = this._kind; + + if (index >= len) { + this._iteratedObject = undefined; + return { value: undefined, done: true }; + } + + this._nextIndex = index + 1; + + if (kind === KIND_KEYS) { + return { value: index, done: false }; + } else if (kind === KIND_VALUES) { + return { value: array[index], done: false }; + } else if (kind === KIND_ENTRIES) { + return { value: [index, array[index]], done: false }; + } + } + + // 22.1.5.2.2 %ArrayIteratorPrototype%[@@iterator]() + [Symbol.iterator]() { + return this; + } + }; + } + + return { + keys: hasNative ? array => array.keys() : array => new ArrayIterator(array, KIND_KEYS), + + values: hasNative ? array => array.values() : array => new ArrayIterator(array, KIND_VALUES), + + entries: hasNative ? array => array.entries() : array => new ArrayIterator(array, KIND_ENTRIES) + }; +}(); + +// ----------------------------------------------------------------- + +/** + * Specific String iterators. + */ +const StringIterators = function () { + + let hasNative = hasNativeIterator(String); + let StringIterator; + + if (!hasNative) { + StringIterator = class StringIterator { + // 21.1.5.1 CreateStringIterator Abstract Operation + constructor(string) { + this._iteratedString = string; + this._nextIndex = 0; + } + + // 21.1.5.2.1 %StringIteratorPrototype%.next() + next() { + if (this._iteratedString == null) { + return { value: undefined, done: true }; + } + + let index = this._nextIndex; + let s = this._iteratedString; + let len = s.length; + + if (index >= len) { + this._iteratedString = undefined; + return { value: undefined, done: true }; + } + + let ret; + let first = s.charCodeAt(index); + + if (first < 0xD800 || first > 0xDBFF || index + 1 === len) { + ret = s[index]; + } else { + let second = s.charCodeAt(index + 1); + if (second < 0xDC00 || second > 0xDFFF) { + ret = s[index]; + } else { + ret = s[index] + s[index + 1]; + } + } + + this._nextIndex = index + ret.length; + + return { value: ret, done: false }; + } + + // 21.1.5.2.2 %StringIteratorPrototype%[@@iterator]() + [Symbol.iterator]() { + return this; + } + }; + } + + return { + keys() { + throw TypeError(`Strings default iterator doesn't implement keys.`); + }, + + values: hasNative ? string => string[Symbol.iterator]() : string => new StringIterator(string), + + entries() { + throw TypeError(`Strings default iterator doesn't implement entries.`); + } + }; +}(); + +function hasNativeIterator(classObject) { + return typeof classObject.prototype[Symbol.iterator] === 'function' && typeof classObject.prototype.values === 'function' && typeof classObject.prototype.keys === 'function' && typeof classObject.prototype.entries === 'function'; +} + +// ----------------------------------------------------------------- + +/** + * Generic object iterator. + */ +class ObjectIterator { + constructor(object, kind) { + this._iteratedObject = object; + this._kind = kind; + this._keys = Object.keys(object); + this._nextIndex = 0; + } + + next() { + let len = this._keys.length; + let index = this._nextIndex; + let kind = this._kind; + let key = this._keys[index]; + + if (index >= len) { + this._iteratedObject = undefined; + return { value: undefined, done: true }; + } + + this._nextIndex = index + 1; + + if (kind === KIND_KEYS) { + return { value: key, done: false }; + } else if (kind === KIND_VALUES) { + return { value: this._iteratedObject[key], done: false }; + } else if (kind === KIND_ENTRIES) { + return { value: [key, this._iteratedObject[key]], done: false }; + } + } + + [Symbol.iterator]() { + return this; + } +} + +/** + * Generic object iterator, iterates over all own enumerable + * properties. Used only if if no specific iterator is available, + * and object don't implement iterator protocol. + */ +const GenericIterators = { + keys(object) { + return new ObjectIterator(object, KIND_KEYS); + }, + + values(object) { + return new ObjectIterator(object, KIND_VALUES); + }, + + entries(object) { + return new ObjectIterator(object, KIND_ENTRIES); + } +}; + +// ----------------------------------------------------------------- + +/** + * Main iterator function. Returns default iterator based + * on the class of an instance. + */ +function enumerate(object, kind) { + + // First check specific iterators. + if (typeof object === 'string') { + return StringIterators[kind || KIND_VALUES](object); + } else if (Array.isArray(object)) { + return ArrayIterators[kind || KIND_VALUES](object); + + // Then see if an object implements own. + } else if (object[Symbol.iterator]) { + return object[Symbol.iterator](); + + // And fallback to generic with entries. + } else { + return GenericIterators[kind || KIND_ENTRIES](object); + } +} + +Object.assign(enumerate, { + /** + * Export constants + */ + + KIND_KEYS, + KIND_VALUES, + KIND_ENTRIES, + + /** + * Convenient explicit iterators for special kinds. + */ + + keys(object) { + return enumerate(object, KIND_KEYS); + }, + + values(object) { + return enumerate(object, KIND_VALUES); + }, + + entries(object) { + return enumerate(object, KIND_ENTRIES); + }, + + generic: GenericIterators.entries + +}); + +module.exports = enumerate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/equalsIterable.js b/node_modules/fbjs/lib/equalsIterable.js new file mode 100644 index 000000000..e17c85c97 --- /dev/null +++ b/node_modules/fbjs/lib/equalsIterable.js @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +'use strict'; + +var enumerate = require('./enumerate'); + +/** + * Checks if two iterables are equal. A custom areEqual function may be provided + * as an optional third argument. + */ +function equalsIterable(one, two, areEqual) { + if (one === two) { + return true; + } + + // We might be able to short circuit by using the size or length fields. + var oneSize = maybeGetSize(one); + var twoSize = maybeGetSize(two); + if (oneSize != null && twoSize != null && oneSize !== twoSize) { + return false; + } + + // Otherwise use the iterators to check equality. Here we cannot use for-of + // because we need to advance the iterators at the same time. + var oneIterator = enumerate(one); + var oneItem = oneIterator.next(); + var twoIterator = enumerate(two); + var twoItem = twoIterator.next(); + var safeAreEqual = areEqual || referenceEquality; + while (!(oneItem.done || twoItem.done)) { + if (!safeAreEqual(oneItem.value, twoItem.value)) { + return false; + } + oneItem = oneIterator.next(); + twoItem = twoIterator.next(); + } + return oneItem.done === twoItem.done; +} + +function maybeGetSize(o) { + if (o == null) { + return null; + } + if (typeof o.size === 'number') { + return o.size; + } + if (typeof o.length === 'number') { + return o.length; + } + return null; +} + +function referenceEquality(one, two) { + return one === two; +} + +module.exports = equalsIterable;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/equalsIterable.js.flow b/node_modules/fbjs/lib/equalsIterable.js.flow new file mode 100644 index 000000000..9051ce5ea --- /dev/null +++ b/node_modules/fbjs/lib/equalsIterable.js.flow @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule equalsIterable + * @flow + */ + +'use strict'; + +const enumerate = require('./enumerate'); + +/** + * Checks if two iterables are equal. A custom areEqual function may be provided + * as an optional third argument. + */ +function equalsIterable<T>(one: Iterable<T>, two: Iterable<T>, areEqual?: ?(one: T, two: T) => boolean): boolean { + if (one === two) { + return true; + } + + // We might be able to short circuit by using the size or length fields. + var oneSize = maybeGetSize(one); + var twoSize = maybeGetSize(two); + if (oneSize != null && twoSize != null && oneSize !== twoSize) { + return false; + } + + // Otherwise use the iterators to check equality. Here we cannot use for-of + // because we need to advance the iterators at the same time. + var oneIterator = enumerate(one); + var oneItem = oneIterator.next(); + var twoIterator = enumerate(two); + var twoItem = twoIterator.next(); + var safeAreEqual = areEqual || referenceEquality; + while (!(oneItem.done || twoItem.done)) { + if (!safeAreEqual(oneItem.value, twoItem.value)) { + return false; + } + oneItem = oneIterator.next(); + twoItem = twoIterator.next(); + } + return oneItem.done === twoItem.done; +} + +function maybeGetSize(o: any): ?number { + if (o == null) { + return null; + } + if (typeof o.size === 'number') { + return o.size; + } + if (typeof o.length === 'number') { + return o.length; + } + return null; +} + +function referenceEquality<T>(one: T, two: T): boolean { + return one === two; +} + +module.exports = equalsIterable;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/equalsSet.js b/node_modules/fbjs/lib/equalsSet.js new file mode 100644 index 000000000..d03022f9d --- /dev/null +++ b/node_modules/fbjs/lib/equalsSet.js @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + * @typechecks + */ + +'use strict'; + +var everySet = require('./everySet'); + +/** + * Checks if two sets are equal + */ +function equalsSet(one, two) { + if (one.size !== two.size) { + return false; + } + return everySet(one, function (value) { + return two.has(value); + }); +} + +module.exports = equalsSet;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/equalsSet.js.flow b/node_modules/fbjs/lib/equalsSet.js.flow new file mode 100644 index 000000000..5ef93fa66 --- /dev/null +++ b/node_modules/fbjs/lib/equalsSet.js.flow @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule equalsSet + * @flow + * @typechecks + */ + +'use strict'; + +import type Set from './Set'; + +var everySet = require('./everySet'); + +/** + * Checks if two sets are equal + */ +function equalsSet<T>(one: Set<T>, two: Set<T>): boolean { + if (one.size !== two.size) { + return false; + } + return everySet(one, value => two.has(value)); +} + +module.exports = equalsSet;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/everyObject.js b/node_modules/fbjs/lib/everyObject.js new file mode 100644 index 000000000..bfeb0bd95 --- /dev/null +++ b/node_modules/fbjs/lib/everyObject.js @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + * @typechecks + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object until it finds one where callback returns a falsy value. If such a + * property is found, `everyObject` immediately returns false. Otherwise, it + * returns true. + * + * The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `everyObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `everyObject` + * visits them. Properties that are deleted before being visited are not + * visited. + */ +function everyObject(object, callback, context) { + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + if (!callback.call(context, object[name], name, object)) { + return false; + } + } + } + return true; +} + +module.exports = everyObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/everyObject.js.flow b/node_modules/fbjs/lib/everyObject.js.flow new file mode 100644 index 000000000..7d172d4f7 --- /dev/null +++ b/node_modules/fbjs/lib/everyObject.js.flow @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule everyObject + * @flow + * @typechecks + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object until it finds one where callback returns a falsy value. If such a + * property is found, `everyObject` immediately returns false. Otherwise, it + * returns true. + * + * The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `everyObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `everyObject` + * visits them. Properties that are deleted before being visited are not + * visited. + */ +function everyObject(object: ?Object, callback: (value: any, name: string, object: Object) => any, context?: any): boolean { + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + if (!callback.call(context, object[name], name, object)) { + return false; + } + } + } + return true; +} + +module.exports = everyObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/everySet.js b/node_modules/fbjs/lib/everySet.js new file mode 100644 index 000000000..c45f6fa3c --- /dev/null +++ b/node_modules/fbjs/lib/everySet.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + * @typechecks + */ + +'use strict'; + +/** + * The everySet() method tests whether all elements in the given Set pass the + * test implemented by the provided function. + */ +function everySet(set, callback, context) { + var iterator = set.entries(); + var current = iterator.next(); + while (!current.done) { + var entry = current.value; + if (!callback.call(context, entry[1], entry[0], set)) { + return false; + } + current = iterator.next(); + } + return true; +} + +module.exports = everySet;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/everySet.js.flow b/node_modules/fbjs/lib/everySet.js.flow new file mode 100644 index 000000000..cb81fdbf3 --- /dev/null +++ b/node_modules/fbjs/lib/everySet.js.flow @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule everySet + * @flow + * @typechecks + */ + +'use strict'; + +import type Set from './Set'; + +/** + * The everySet() method tests whether all elements in the given Set pass the + * test implemented by the provided function. + */ +function everySet<T>(set: Set<T>, callback: (value: T, key: T, set: Set<T>) => boolean, context?: any): boolean { + var iterator = set.entries(); + var current = iterator.next(); + while (!current.done) { + var entry = current.value; + if (!callback.call(context, entry[1], entry[0], set)) { + return false; + } + current = iterator.next(); + } + return true; +} + +module.exports = everySet;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/fetch.js b/node_modules/fbjs/lib/fetch.js new file mode 100644 index 000000000..1d66d84d0 --- /dev/null +++ b/node_modules/fbjs/lib/fetch.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +// This hopefully supports the React Native case, which is already bringing along +// its own fetch polyfill. That should exist on `global`. If that doesn't exist +// then we'll try to polyfill, which might not work correctly in all environments. + +if (global.fetch) { + module.exports = global.fetch.bind(global); +} else { + module.exports = require('isomorphic-fetch'); +}
\ No newline at end of file diff --git a/node_modules/fbjs/lib/fetch.js.flow b/node_modules/fbjs/lib/fetch.js.flow new file mode 100644 index 000000000..e29e7b339 --- /dev/null +++ b/node_modules/fbjs/lib/fetch.js.flow @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule fetch + */ + +'use strict'; + +// This hopefully supports the React Native case, which is already bringing along +// its own fetch polyfill. That should exist on `global`. If that doesn't exist +// then we'll try to polyfill, which might not work correctly in all environments. + +if (global.fetch) { + module.exports = global.fetch.bind(global); +} else { + module.exports = require('isomorphic-fetch'); +}
\ No newline at end of file diff --git a/node_modules/fbjs/lib/fetchWithRetries.js b/node_modules/fbjs/lib/fetchWithRetries.js new file mode 100644 index 000000000..47722ea25 --- /dev/null +++ b/node_modules/fbjs/lib/fetchWithRetries.js @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +'use strict'; + +var Promise = require('./Promise'); + +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + +var ExecutionEnvironment = require('./ExecutionEnvironment'); + +var sprintf = require('./sprintf'); +var fetch = require('./fetch'); +var warning = require('./warning'); + +var DEFAULT_TIMEOUT = 15000; +var DEFAULT_RETRIES = [1000, 3000]; + +/** + * Makes a POST request to the server with the given data as the payload. + * Automatic retries are done based on the values in `retryDelays`. + */ +function fetchWithRetries(uri, initWithRetries) { + var _ref = initWithRetries || {}, + fetchTimeout = _ref.fetchTimeout, + retryDelays = _ref.retryDelays, + init = _objectWithoutProperties(_ref, ['fetchTimeout', 'retryDelays']); + + var _fetchTimeout = fetchTimeout != null ? fetchTimeout : DEFAULT_TIMEOUT; + var _retryDelays = retryDelays != null ? retryDelays : DEFAULT_RETRIES; + + var requestsAttempted = 0; + var requestStartTime = 0; + return new Promise(function (resolve, reject) { + /** + * Sends a request to the server that will timeout after `fetchTimeout`. + * If the request fails or times out a new request might be scheduled. + */ + function sendTimedRequest() { + requestsAttempted++; + requestStartTime = Date.now(); + var isRequestAlive = true; + var request = fetch(uri, init); + var requestTimeout = setTimeout(function () { + isRequestAlive = false; + if (shouldRetry(requestsAttempted)) { + process.env.NODE_ENV !== 'production' ? warning(false, 'fetchWithRetries: HTTP timeout, retrying.') : void 0; + retryRequest(); + } else { + reject(new Error(sprintf('fetchWithRetries(): Failed to get response from server, ' + 'tried %s times.', requestsAttempted))); + } + }, _fetchTimeout); + + request.then(function (response) { + clearTimeout(requestTimeout); + if (isRequestAlive) { + // We got a response, we can clear the timeout. + if (response.status >= 200 && response.status < 300) { + // Got a response code that indicates success, resolve the promise. + resolve(response); + } else if (shouldRetry(requestsAttempted)) { + // Fetch was not successful, retrying. + // TODO(#7595849): Only retry on transient HTTP errors. + process.env.NODE_ENV !== 'production' ? warning(false, 'fetchWithRetries: HTTP error, retrying.') : void 0, retryRequest(); + } else { + // Request was not successful, giving up. + var error = new Error(sprintf('fetchWithRetries(): Still no successful response after ' + '%s retries, giving up.', requestsAttempted)); + error.response = response; + reject(error); + } + } + })['catch'](function (error) { + clearTimeout(requestTimeout); + if (shouldRetry(requestsAttempted)) { + retryRequest(); + } else { + reject(error); + } + }); + } + + /** + * Schedules another run of sendTimedRequest based on how much time has + * passed between the time the last request was sent and now. + */ + function retryRequest() { + var retryDelay = _retryDelays[requestsAttempted - 1]; + var retryStartTime = requestStartTime + retryDelay; + // Schedule retry for a configured duration after last request started. + setTimeout(sendTimedRequest, retryStartTime - Date.now()); + } + + /** + * Checks if another attempt should be done to send a request to the server. + */ + function shouldRetry(attempt) { + return ExecutionEnvironment.canUseDOM && attempt <= _retryDelays.length; + } + + sendTimedRequest(); + }); +} + +module.exports = fetchWithRetries;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/fetchWithRetries.js.flow b/node_modules/fbjs/lib/fetchWithRetries.js.flow new file mode 100644 index 000000000..967f5c376 --- /dev/null +++ b/node_modules/fbjs/lib/fetchWithRetries.js.flow @@ -0,0 +1,117 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule fetchWithRetries + * @typechecks + * @flow + */ + +'use strict'; + +const ExecutionEnvironment = require('./ExecutionEnvironment'); + +const sprintf = require('./sprintf'); +const fetch = require('./fetch'); +const warning = require('./warning'); + +export type InitWithRetries = { + body?: mixed; + cache?: ?string; + credentials?: ?string; + fetchTimeout?: ?number; + headers?: mixed; + method?: ?string; + mode?: ?string; + retryDelays?: ?Array<number>; +}; + +const DEFAULT_TIMEOUT = 15000; +const DEFAULT_RETRIES = [1000, 3000]; + +/** + * Makes a POST request to the server with the given data as the payload. + * Automatic retries are done based on the values in `retryDelays`. + */ +function fetchWithRetries(uri: string, initWithRetries?: ?InitWithRetries): Promise<any> { + const { fetchTimeout, retryDelays, ...init } = initWithRetries || {}; + const _fetchTimeout = fetchTimeout != null ? fetchTimeout : DEFAULT_TIMEOUT; + const _retryDelays = retryDelays != null ? retryDelays : DEFAULT_RETRIES; + + let requestsAttempted = 0; + let requestStartTime = 0; + return new Promise((resolve, reject) => { + /** + * Sends a request to the server that will timeout after `fetchTimeout`. + * If the request fails or times out a new request might be scheduled. + */ + function sendTimedRequest(): void { + requestsAttempted++; + requestStartTime = Date.now(); + let isRequestAlive = true; + const request = fetch(uri, init); + const requestTimeout = setTimeout(() => { + isRequestAlive = false; + if (shouldRetry(requestsAttempted)) { + warning(false, 'fetchWithRetries: HTTP timeout, retrying.'); + retryRequest(); + } else { + reject(new Error(sprintf('fetchWithRetries(): Failed to get response from server, ' + 'tried %s times.', requestsAttempted))); + } + }, _fetchTimeout); + + request.then(response => { + clearTimeout(requestTimeout); + if (isRequestAlive) { + // We got a response, we can clear the timeout. + if (response.status >= 200 && response.status < 300) { + // Got a response code that indicates success, resolve the promise. + resolve(response); + } else if (shouldRetry(requestsAttempted)) { + // Fetch was not successful, retrying. + // TODO(#7595849): Only retry on transient HTTP errors. + warning(false, 'fetchWithRetries: HTTP error, retrying.'), retryRequest(); + } else { + // Request was not successful, giving up. + const error: any = new Error(sprintf('fetchWithRetries(): Still no successful response after ' + '%s retries, giving up.', requestsAttempted)); + error.response = response; + reject(error); + } + } + }).catch(error => { + clearTimeout(requestTimeout); + if (shouldRetry(requestsAttempted)) { + retryRequest(); + } else { + reject(error); + } + }); + } + + /** + * Schedules another run of sendTimedRequest based on how much time has + * passed between the time the last request was sent and now. + */ + function retryRequest(): void { + const retryDelay = _retryDelays[requestsAttempted - 1]; + const retryStartTime = requestStartTime + retryDelay; + // Schedule retry for a configured duration after last request started. + setTimeout(sendTimedRequest, retryStartTime - Date.now()); + } + + /** + * Checks if another attempt should be done to send a request to the server. + */ + function shouldRetry(attempt: number): boolean { + return ExecutionEnvironment.canUseDOM && attempt <= _retryDelays.length; + } + + sendTimedRequest(); + }); +} + +module.exports = fetchWithRetries;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/filterObject.js b/node_modules/fbjs/lib/filterObject.js new file mode 100644 index 000000000..891bc1625 --- /dev/null +++ b/node_modules/fbjs/lib/filterObject.js @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object and constructs a new object of all the values for which `callback` + * returns a true value. The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `filterObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `filterObject` + * visits them. Properties that are deleted before being visited are not + * visited. + * + * @grep function objectFilter() + * @grep function objFilter() + * + * @param {?object} object + * @param {function} callback + * @param {*} context + * @return {?object} + */ +function filterObject(object, callback, context) { + if (!object) { + return null; + } + var result = {}; + for (var name in object) { + if (hasOwnProperty.call(object, name) && callback.call(context, object[name], name, object)) { + result[name] = object[name]; + } + } + return result; +} + +module.exports = filterObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/filterObject.js.flow b/node_modules/fbjs/lib/filterObject.js.flow new file mode 100644 index 000000000..c5b6aa796 --- /dev/null +++ b/node_modules/fbjs/lib/filterObject.js.flow @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule filterObject + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object and constructs a new object of all the values for which `callback` + * returns a true value. The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `filterObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `filterObject` + * visits them. Properties that are deleted before being visited are not + * visited. + * + * @grep function objectFilter() + * @grep function objFilter() + * + * @param {?object} object + * @param {function} callback + * @param {*} context + * @return {?object} + */ +function filterObject(object, callback, context) { + if (!object) { + return null; + } + var result = {}; + for (var name in object) { + if (hasOwnProperty.call(object, name) && callback.call(context, object[name], name, object)) { + result[name] = object[name]; + } + } + return result; +} + +module.exports = filterObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/flatMapArray.js b/node_modules/fbjs/lib/flatMapArray.js new file mode 100644 index 000000000..90daacf60 --- /dev/null +++ b/node_modules/fbjs/lib/flatMapArray.js @@ -0,0 +1,37 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var push = Array.prototype.push; + +/** + * Applies a function to every item in an array and concatenates the resulting + * arrays into a single flat array. + * + * @param {array} array + * @param {function} fn + * @return {array} + */ +function flatMapArray(array, fn) { + var ret = []; + for (var ii = 0; ii < array.length; ii++) { + var result = fn.call(array, array[ii], ii); + if (Array.isArray(result)) { + push.apply(ret, result); + } else if (result != null) { + throw new TypeError('flatMapArray: Callback must return an array or null, ' + 'received "' + result + '" instead'); + } + } + return ret; +} + +module.exports = flatMapArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/flatMapArray.js.flow b/node_modules/fbjs/lib/flatMapArray.js.flow new file mode 100644 index 000000000..91f16fbcf --- /dev/null +++ b/node_modules/fbjs/lib/flatMapArray.js.flow @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule flatMapArray + * @typechecks + */ + +var push = Array.prototype.push; + +/** + * Applies a function to every item in an array and concatenates the resulting + * arrays into a single flat array. + * + * @param {array} array + * @param {function} fn + * @return {array} + */ +function flatMapArray(array, fn) { + var ret = []; + for (var ii = 0; ii < array.length; ii++) { + var result = fn.call(array, array[ii], ii); + if (Array.isArray(result)) { + push.apply(ret, result); + } else if (result != null) { + throw new TypeError('flatMapArray: Callback must return an array or null, ' + 'received "' + result + '" instead'); + } + } + return ret; +} + +module.exports = flatMapArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/flattenArray.js b/node_modules/fbjs/lib/flattenArray.js new file mode 100644 index 000000000..6824c5556 --- /dev/null +++ b/node_modules/fbjs/lib/flattenArray.js @@ -0,0 +1,48 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/** + * Returns a flattened array that represents the DFS traversal of the supplied + * input array. For example: + * + * var deep = ["a", ["b", "c"], "d", {"e": [1, 2]}, [["f"], "g"]]; + * var flat = flattenArray(deep); + * console.log(flat); + * > ["a", "b", "c", "d", {"e": [1, 2]}, "f", "g"]; + * + * @see https://github.com/jonschlinkert/arr-flatten + * @copyright 2014-2015 Jon Schlinkert + * @license MIT + */ +function flattenArray(array) { + var result = []; + flatten(array, result); + return result; +} + +function flatten(array, result) { + var length = array.length; + var ii = 0; + + while (length--) { + var current = array[ii++]; + if (Array.isArray(current)) { + flatten(current, result); + } else { + result.push(current); + } + } +} + +module.exports = flattenArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/flattenArray.js.flow b/node_modules/fbjs/lib/flattenArray.js.flow new file mode 100644 index 000000000..9c77af43f --- /dev/null +++ b/node_modules/fbjs/lib/flattenArray.js.flow @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule flattenArray + * @typechecks + * @flow + */ + +/** + * Returns a flattened array that represents the DFS traversal of the supplied + * input array. For example: + * + * var deep = ["a", ["b", "c"], "d", {"e": [1, 2]}, [["f"], "g"]]; + * var flat = flattenArray(deep); + * console.log(flat); + * > ["a", "b", "c", "d", {"e": [1, 2]}, "f", "g"]; + * + * @see https://github.com/jonschlinkert/arr-flatten + * @copyright 2014-2015 Jon Schlinkert + * @license MIT + */ +function flattenArray(array: Array<any>): Array<any> { + const result = []; + flatten(array, result); + return result; +} + +function flatten(array: Array<any>, result: Array<any>): void { + let length = array.length; + let ii = 0; + + while (length--) { + const current = array[ii++]; + if (Array.isArray(current)) { + flatten(current, result); + } else { + result.push(current); + } + } +} + +module.exports = flattenArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/focusNode.js b/node_modules/fbjs/lib/focusNode.js new file mode 100644 index 000000000..36a0e53ac --- /dev/null +++ b/node_modules/fbjs/lib/focusNode.js @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +/** + * @param {DOMElement} node input/textarea to focus + */ + +function focusNode(node) { + // IE8 can throw "Can't move focus to the control because it is invisible, + // not enabled, or of a type that does not accept the focus." for all kinds of + // reasons that are too expensive and fragile to test. + try { + node.focus(); + } catch (e) {} +} + +module.exports = focusNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/focusNode.js.flow b/node_modules/fbjs/lib/focusNode.js.flow new file mode 100644 index 000000000..61e42cf3d --- /dev/null +++ b/node_modules/fbjs/lib/focusNode.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule focusNode + */ + +'use strict'; + +/** + * @param {DOMElement} node input/textarea to focus + */ + +function focusNode(node) { + // IE8 can throw "Can't move focus to the control because it is invisible, + // not enabled, or of a type that does not accept the focus." for all kinds of + // reasons that are too expensive and fragile to test. + try { + node.focus(); + } catch (e) {} +} + +module.exports = focusNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/forEachObject.js b/node_modules/fbjs/lib/forEachObject.js new file mode 100644 index 000000000..43cb6c82b --- /dev/null +++ b/node_modules/fbjs/lib/forEachObject.js @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object. The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `forEachObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `forEachObject` + * visits them. Properties that are deleted before being visited are not + * visited. + * + * @param {?object} object + * @param {function} callback + * @param {*} context + */ +function forEachObject(object, callback, context) { + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + callback.call(context, object[name], name, object); + } + } +} + +module.exports = forEachObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/forEachObject.js.flow b/node_modules/fbjs/lib/forEachObject.js.flow new file mode 100644 index 000000000..b44c1297a --- /dev/null +++ b/node_modules/fbjs/lib/forEachObject.js.flow @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule forEachObject + * @typechecks + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object. The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `forEachObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `forEachObject` + * visits them. Properties that are deleted before being visited are not + * visited. + * + * @param {?object} object + * @param {function} callback + * @param {*} context + */ +function forEachObject(object, callback, context) { + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + callback.call(context, object[name], name, object); + } + } +} + +module.exports = forEachObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getActiveElement.js b/node_modules/fbjs/lib/getActiveElement.js new file mode 100644 index 000000000..a2715bcca --- /dev/null +++ b/node_modules/fbjs/lib/getActiveElement.js @@ -0,0 +1,38 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/* eslint-disable fb-www/typeof-undefined */ + +/** + * Same as document.activeElement but wraps in a try-catch block. In IE it is + * not safe to call document.activeElement if there is nothing focused. + * + * The activeElement will be null only if the document or document body is not + * yet defined. + * + * @param {?DOMDocument} doc Defaults to current document. + * @return {?DOMElement} + */ +function getActiveElement(doc) /*?DOMElement*/{ + doc = doc || (typeof document !== 'undefined' ? document : undefined); + if (typeof doc === 'undefined') { + return null; + } + try { + return doc.activeElement || doc.body; + } catch (e) { + return doc.body; + } +} + +module.exports = getActiveElement;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getActiveElement.js.flow b/node_modules/fbjs/lib/getActiveElement.js.flow new file mode 100644 index 000000000..f8348a1df --- /dev/null +++ b/node_modules/fbjs/lib/getActiveElement.js.flow @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getActiveElement + * @typechecks + */ + +/* eslint-disable fb-www/typeof-undefined */ + +/** + * Same as document.activeElement but wraps in a try-catch block. In IE it is + * not safe to call document.activeElement if there is nothing focused. + * + * The activeElement will be null only if the document or document body is not + * yet defined. + * + * @param {?DOMDocument} doc Defaults to current document. + * @return {?DOMElement} + */ +function getActiveElement(doc) /*?DOMElement*/{ + doc = doc || (typeof document !== 'undefined' ? document : undefined); + if (typeof doc === 'undefined') { + return null; + } + try { + return doc.activeElement || doc.body; + } catch (e) { + return doc.body; + } +} + +module.exports = getActiveElement;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getDocumentScrollElement.js b/node_modules/fbjs/lib/getDocumentScrollElement.js new file mode 100644 index 000000000..cf40511b0 --- /dev/null +++ b/node_modules/fbjs/lib/getDocumentScrollElement.js @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +var isWebkit = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('AppleWebKit') > -1; + +/** + * Gets the element with the document scroll properties such as `scrollLeft` and + * `scrollHeight`. This may differ across different browsers. + * + * NOTE: The return value can be null if the DOM is not yet ready. + * + * @param {?DOMDocument} doc Defaults to current document. + * @return {?DOMElement} + */ +function getDocumentScrollElement(doc) { + doc = doc || document; + return !isWebkit && doc.compatMode === 'CSS1Compat' ? doc.documentElement : doc.body; +} + +module.exports = getDocumentScrollElement;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getDocumentScrollElement.js.flow b/node_modules/fbjs/lib/getDocumentScrollElement.js.flow new file mode 100644 index 000000000..2711fb162 --- /dev/null +++ b/node_modules/fbjs/lib/getDocumentScrollElement.js.flow @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getDocumentScrollElement + * @typechecks + */ + +'use strict'; + +const isWebkit = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('AppleWebKit') > -1; + +/** + * Gets the element with the document scroll properties such as `scrollLeft` and + * `scrollHeight`. This may differ across different browsers. + * + * NOTE: The return value can be null if the DOM is not yet ready. + * + * @param {?DOMDocument} doc Defaults to current document. + * @return {?DOMElement} + */ +function getDocumentScrollElement(doc) { + doc = doc || document; + return !isWebkit && doc.compatMode === 'CSS1Compat' ? doc.documentElement : doc.body; +} + +module.exports = getDocumentScrollElement;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getElementPosition.js b/node_modules/fbjs/lib/getElementPosition.js new file mode 100644 index 000000000..714f9f3fe --- /dev/null +++ b/node_modules/fbjs/lib/getElementPosition.js @@ -0,0 +1,33 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var getElementRect = require('./getElementRect'); + +/** + * Gets an element's position in pixels relative to the viewport. The returned + * object represents the position of the element's top left corner. + * + * @param {DOMElement} element + * @return {object} + */ +function getElementPosition(element) { + var rect = getElementRect(element); + return { + x: rect.left, + y: rect.top, + width: rect.right - rect.left, + height: rect.bottom - rect.top + }; +} + +module.exports = getElementPosition;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getElementPosition.js.flow b/node_modules/fbjs/lib/getElementPosition.js.flow new file mode 100644 index 000000000..4ca58da1e --- /dev/null +++ b/node_modules/fbjs/lib/getElementPosition.js.flow @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getElementPosition + * @typechecks + */ + +const getElementRect = require('./getElementRect'); + +/** + * Gets an element's position in pixels relative to the viewport. The returned + * object represents the position of the element's top left corner. + * + * @param {DOMElement} element + * @return {object} + */ +function getElementPosition(element) { + const rect = getElementRect(element); + return { + x: rect.left, + y: rect.top, + width: rect.right - rect.left, + height: rect.bottom - rect.top + }; +} + +module.exports = getElementPosition;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getElementRect.js b/node_modules/fbjs/lib/getElementRect.js new file mode 100644 index 000000000..27f85b122 --- /dev/null +++ b/node_modules/fbjs/lib/getElementRect.js @@ -0,0 +1,50 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var containsNode = require('./containsNode'); + +/** + * Gets an element's bounding rect in pixels relative to the viewport. + * + * @param {DOMElement} elem + * @return {object} + */ +function getElementRect(elem) { + var docElem = elem.ownerDocument.documentElement; + + // FF 2, Safari 3 and Opera 9.5- do not support getBoundingClientRect(). + // IE9- will throw if the element is not in the document. + if (!('getBoundingClientRect' in elem) || !containsNode(docElem, elem)) { + return { + left: 0, + right: 0, + top: 0, + bottom: 0 + }; + } + + // Subtracts clientTop/Left because IE8- added a 2px border to the + // <html> element (see http://fburl.com/1493213). IE 7 in + // Quicksmode does not report clientLeft/clientTop so there + // will be an unaccounted offset of 2px when in quirksmode + var rect = elem.getBoundingClientRect(); + + return { + left: Math.round(rect.left) - docElem.clientLeft, + right: Math.round(rect.right) - docElem.clientLeft, + top: Math.round(rect.top) - docElem.clientTop, + bottom: Math.round(rect.bottom) - docElem.clientTop + }; +} + +module.exports = getElementRect;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getElementRect.js.flow b/node_modules/fbjs/lib/getElementRect.js.flow new file mode 100644 index 000000000..877a6b48e --- /dev/null +++ b/node_modules/fbjs/lib/getElementRect.js.flow @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getElementRect + * @typechecks + */ + +const containsNode = require('./containsNode'); + +/** + * Gets an element's bounding rect in pixels relative to the viewport. + * + * @param {DOMElement} elem + * @return {object} + */ +function getElementRect(elem) { + const docElem = elem.ownerDocument.documentElement; + + // FF 2, Safari 3 and Opera 9.5- do not support getBoundingClientRect(). + // IE9- will throw if the element is not in the document. + if (!('getBoundingClientRect' in elem) || !containsNode(docElem, elem)) { + return { + left: 0, + right: 0, + top: 0, + bottom: 0 + }; + } + + // Subtracts clientTop/Left because IE8- added a 2px border to the + // <html> element (see http://fburl.com/1493213). IE 7 in + // Quicksmode does not report clientLeft/clientTop so there + // will be an unaccounted offset of 2px when in quirksmode + const rect = elem.getBoundingClientRect(); + + return { + left: Math.round(rect.left) - docElem.clientLeft, + right: Math.round(rect.right) - docElem.clientLeft, + top: Math.round(rect.top) - docElem.clientTop, + bottom: Math.round(rect.bottom) - docElem.clientTop + }; +} + +module.exports = getElementRect;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getMarkupWrap.js b/node_modules/fbjs/lib/getMarkupWrap.js new file mode 100644 index 000000000..078c0a673 --- /dev/null +++ b/node_modules/fbjs/lib/getMarkupWrap.js @@ -0,0 +1,94 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +/*eslint-disable fb-www/unsafe-html */ + +var ExecutionEnvironment = require('./ExecutionEnvironment'); + +var invariant = require('./invariant'); + +/** + * Dummy container used to detect which wraps are necessary. + */ +var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; + +/** + * Some browsers cannot use `innerHTML` to render certain elements standalone, + * so we wrap them, render the wrapped nodes, then extract the desired node. + * + * In IE8, certain elements cannot render alone, so wrap all elements ('*'). + */ + +var shouldWrap = {}; + +var selectWrap = [1, '<select multiple="true">', '</select>']; +var tableWrap = [1, '<table>', '</table>']; +var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>']; + +var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>']; + +var markupWrap = { + '*': [1, '?<div>', '</div>'], + + 'area': [1, '<map>', '</map>'], + 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'], + 'legend': [1, '<fieldset>', '</fieldset>'], + 'param': [1, '<object>', '</object>'], + 'tr': [2, '<table><tbody>', '</tbody></table>'], + + 'optgroup': selectWrap, + 'option': selectWrap, + + 'caption': tableWrap, + 'colgroup': tableWrap, + 'tbody': tableWrap, + 'tfoot': tableWrap, + 'thead': tableWrap, + + 'td': trWrap, + 'th': trWrap +}; + +// Initialize the SVG elements since we know they'll always need to be wrapped +// consistently. If they are created inside a <div> they will be initialized in +// the wrong namespace (and will not display). +var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan']; +svgElements.forEach(function (nodeName) { + markupWrap[nodeName] = svgWrap; + shouldWrap[nodeName] = true; +}); + +/** + * Gets the markup wrap configuration for the supplied `nodeName`. + * + * NOTE: This lazily detects which wraps are necessary for the current browser. + * + * @param {string} nodeName Lowercase `nodeName`. + * @return {?array} Markup wrap configuration, if applicable. + */ +function getMarkupWrap(nodeName) { + !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : void 0; + if (!markupWrap.hasOwnProperty(nodeName)) { + nodeName = '*'; + } + if (!shouldWrap.hasOwnProperty(nodeName)) { + if (nodeName === '*') { + dummyNode.innerHTML = '<link />'; + } else { + dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>'; + } + shouldWrap[nodeName] = !dummyNode.firstChild; + } + return shouldWrap[nodeName] ? markupWrap[nodeName] : null; +} + +module.exports = getMarkupWrap;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getMarkupWrap.js.flow b/node_modules/fbjs/lib/getMarkupWrap.js.flow new file mode 100644 index 000000000..fb1510a8b --- /dev/null +++ b/node_modules/fbjs/lib/getMarkupWrap.js.flow @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getMarkupWrap + */ + +/*eslint-disable fb-www/unsafe-html */ + +const ExecutionEnvironment = require('./ExecutionEnvironment'); + +const invariant = require('./invariant'); + +/** + * Dummy container used to detect which wraps are necessary. + */ +const dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; + +/** + * Some browsers cannot use `innerHTML` to render certain elements standalone, + * so we wrap them, render the wrapped nodes, then extract the desired node. + * + * In IE8, certain elements cannot render alone, so wrap all elements ('*'). + */ + +const shouldWrap = {}; + +const selectWrap = [1, '<select multiple="true">', '</select>']; +const tableWrap = [1, '<table>', '</table>']; +const trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>']; + +const svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>']; + +const markupWrap = { + '*': [1, '?<div>', '</div>'], + + 'area': [1, '<map>', '</map>'], + 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'], + 'legend': [1, '<fieldset>', '</fieldset>'], + 'param': [1, '<object>', '</object>'], + 'tr': [2, '<table><tbody>', '</tbody></table>'], + + 'optgroup': selectWrap, + 'option': selectWrap, + + 'caption': tableWrap, + 'colgroup': tableWrap, + 'tbody': tableWrap, + 'tfoot': tableWrap, + 'thead': tableWrap, + + 'td': trWrap, + 'th': trWrap +}; + +// Initialize the SVG elements since we know they'll always need to be wrapped +// consistently. If they are created inside a <div> they will be initialized in +// the wrong namespace (and will not display). +const svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan']; +svgElements.forEach(nodeName => { + markupWrap[nodeName] = svgWrap; + shouldWrap[nodeName] = true; +}); + +/** + * Gets the markup wrap configuration for the supplied `nodeName`. + * + * NOTE: This lazily detects which wraps are necessary for the current browser. + * + * @param {string} nodeName Lowercase `nodeName`. + * @return {?array} Markup wrap configuration, if applicable. + */ +function getMarkupWrap(nodeName) { + invariant(!!dummyNode, 'Markup wrapping node not initialized'); + if (!markupWrap.hasOwnProperty(nodeName)) { + nodeName = '*'; + } + if (!shouldWrap.hasOwnProperty(nodeName)) { + if (nodeName === '*') { + dummyNode.innerHTML = '<link />'; + } else { + dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>'; + } + shouldWrap[nodeName] = !dummyNode.firstChild; + } + return shouldWrap[nodeName] ? markupWrap[nodeName] : null; +} + +module.exports = getMarkupWrap;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getScrollPosition.js b/node_modules/fbjs/lib/getScrollPosition.js new file mode 100644 index 000000000..d53d614c6 --- /dev/null +++ b/node_modules/fbjs/lib/getScrollPosition.js @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +var getDocumentScrollElement = require('./getDocumentScrollElement'); +var getUnboundedScrollPosition = require('./getUnboundedScrollPosition'); + +/** + * Gets the scroll position of the supplied element or window. + * + * The return values are bounded. This means that if the scroll position is + * negative or exceeds the element boundaries (which is possible using inertial + * scrolling), you will get zero or the maximum scroll position, respectively. + * + * If you need the unbound scroll position, use `getUnboundedScrollPosition`. + * + * @param {DOMWindow|DOMElement} scrollable + * @return {object} Map with `x` and `y` keys. + */ +function getScrollPosition(scrollable) { + var documentScrollElement = getDocumentScrollElement(scrollable.ownerDocument || scrollable.document); + if (scrollable.Window && scrollable instanceof scrollable.Window) { + scrollable = documentScrollElement; + } + var scrollPosition = getUnboundedScrollPosition(scrollable); + + var viewport = scrollable === documentScrollElement ? scrollable.ownerDocument.documentElement : scrollable; + + var xMax = scrollable.scrollWidth - viewport.clientWidth; + var yMax = scrollable.scrollHeight - viewport.clientHeight; + + scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax)); + scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax)); + + return scrollPosition; +} + +module.exports = getScrollPosition;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getScrollPosition.js.flow b/node_modules/fbjs/lib/getScrollPosition.js.flow new file mode 100644 index 000000000..d39f76bc7 --- /dev/null +++ b/node_modules/fbjs/lib/getScrollPosition.js.flow @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getScrollPosition + * @typechecks + */ + +'use strict'; + +const getDocumentScrollElement = require('./getDocumentScrollElement'); +const getUnboundedScrollPosition = require('./getUnboundedScrollPosition'); + +/** + * Gets the scroll position of the supplied element or window. + * + * The return values are bounded. This means that if the scroll position is + * negative or exceeds the element boundaries (which is possible using inertial + * scrolling), you will get zero or the maximum scroll position, respectively. + * + * If you need the unbound scroll position, use `getUnboundedScrollPosition`. + * + * @param {DOMWindow|DOMElement} scrollable + * @return {object} Map with `x` and `y` keys. + */ +function getScrollPosition(scrollable) { + const documentScrollElement = getDocumentScrollElement(scrollable.ownerDocument || scrollable.document); + if (scrollable.Window && scrollable instanceof scrollable.Window) { + scrollable = documentScrollElement; + } + const scrollPosition = getUnboundedScrollPosition(scrollable); + + const viewport = scrollable === documentScrollElement ? scrollable.ownerDocument.documentElement : scrollable; + + const xMax = scrollable.scrollWidth - viewport.clientWidth; + const yMax = scrollable.scrollHeight - viewport.clientHeight; + + scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax)); + scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax)); + + return scrollPosition; +} + +module.exports = getScrollPosition;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getStyleProperty.js b/node_modules/fbjs/lib/getStyleProperty.js new file mode 100644 index 000000000..e3ff91975 --- /dev/null +++ b/node_modules/fbjs/lib/getStyleProperty.js @@ -0,0 +1,53 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var camelize = require('./camelize'); +var hyphenate = require('./hyphenate'); + +function asString(value) /*?string*/{ + return value == null ? value : String(value); +} + +function getStyleProperty( /*DOMNode*/node, /*string*/name) /*?string*/{ + var computedStyle = void 0; + + // W3C Standard + if (window.getComputedStyle) { + // In certain cases such as within an iframe in FF3, this returns null. + computedStyle = window.getComputedStyle(node, null); + if (computedStyle) { + return asString(computedStyle.getPropertyValue(hyphenate(name))); + } + } + // Safari + if (document.defaultView && document.defaultView.getComputedStyle) { + computedStyle = document.defaultView.getComputedStyle(node, null); + // A Safari bug causes this to return null for `display: none` elements. + if (computedStyle) { + return asString(computedStyle.getPropertyValue(hyphenate(name))); + } + if (name === 'display') { + return 'none'; + } + } + // Internet Explorer + if (node.currentStyle) { + if (name === 'float') { + return asString(node.currentStyle.cssFloat || node.currentStyle.styleFloat); + } + return asString(node.currentStyle[camelize(name)]); + } + return asString(node.style && node.style[camelize(name)]); +} + +module.exports = getStyleProperty;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getStyleProperty.js.flow b/node_modules/fbjs/lib/getStyleProperty.js.flow new file mode 100644 index 000000000..265d15b81 --- /dev/null +++ b/node_modules/fbjs/lib/getStyleProperty.js.flow @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getStyleProperty + * @typechecks + */ + +const camelize = require('./camelize'); +const hyphenate = require('./hyphenate'); + +function asString(value) /*?string*/{ + return value == null ? value : String(value); +} + +function getStyleProperty( /*DOMNode*/node, /*string*/name) /*?string*/{ + let computedStyle; + + // W3C Standard + if (window.getComputedStyle) { + // In certain cases such as within an iframe in FF3, this returns null. + computedStyle = window.getComputedStyle(node, null); + if (computedStyle) { + return asString(computedStyle.getPropertyValue(hyphenate(name))); + } + } + // Safari + if (document.defaultView && document.defaultView.getComputedStyle) { + computedStyle = document.defaultView.getComputedStyle(node, null); + // A Safari bug causes this to return null for `display: none` elements. + if (computedStyle) { + return asString(computedStyle.getPropertyValue(hyphenate(name))); + } + if (name === 'display') { + return 'none'; + } + } + // Internet Explorer + if (node.currentStyle) { + if (name === 'float') { + return asString(node.currentStyle.cssFloat || node.currentStyle.styleFloat); + } + return asString(node.currentStyle[camelize(name)]); + } + return asString(node.style && node.style[camelize(name)]); +} + +module.exports = getStyleProperty;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getUnboundedScrollPosition.js b/node_modules/fbjs/lib/getUnboundedScrollPosition.js new file mode 100644 index 000000000..cec5fac91 --- /dev/null +++ b/node_modules/fbjs/lib/getUnboundedScrollPosition.js @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +/** + * Gets the scroll position of the supplied element or window. + * + * The return values are unbounded, unlike `getScrollPosition`. This means they + * may be negative or exceed the element boundaries (which is possible using + * inertial scrolling). + * + * @param {DOMWindow|DOMElement} scrollable + * @return {object} Map with `x` and `y` keys. + */ + +function getUnboundedScrollPosition(scrollable) { + if (scrollable.Window && scrollable instanceof scrollable.Window) { + return { + x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft, + y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop + }; + } + return { + x: scrollable.scrollLeft, + y: scrollable.scrollTop + }; +} + +module.exports = getUnboundedScrollPosition;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getUnboundedScrollPosition.js.flow b/node_modules/fbjs/lib/getUnboundedScrollPosition.js.flow new file mode 100644 index 000000000..b20be6c67 --- /dev/null +++ b/node_modules/fbjs/lib/getUnboundedScrollPosition.js.flow @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getUnboundedScrollPosition + * @typechecks + */ + +'use strict'; + +/** + * Gets the scroll position of the supplied element or window. + * + * The return values are unbounded, unlike `getScrollPosition`. This means they + * may be negative or exceed the element boundaries (which is possible using + * inertial scrolling). + * + * @param {DOMWindow|DOMElement} scrollable + * @return {object} Map with `x` and `y` keys. + */ + +function getUnboundedScrollPosition(scrollable) { + if (scrollable.Window && scrollable instanceof scrollable.Window) { + return { + x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft, + y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop + }; + } + return { + x: scrollable.scrollLeft, + y: scrollable.scrollTop + }; +} + +module.exports = getUnboundedScrollPosition;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getViewportDimensions.js b/node_modules/fbjs/lib/getViewportDimensions.js new file mode 100644 index 000000000..bb6839004 --- /dev/null +++ b/node_modules/fbjs/lib/getViewportDimensions.js @@ -0,0 +1,59 @@ +"use strict"; + +function getViewportWidth() { + var width = void 0; + if (document.documentElement) { + width = document.documentElement.clientWidth; + } + + if (!width && document.body) { + width = document.body.clientWidth; + } + + return width || 0; +} /** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + * @typechecks + */ + +function getViewportHeight() { + var height = void 0; + if (document.documentElement) { + height = document.documentElement.clientHeight; + } + + if (!height && document.body) { + height = document.body.clientHeight; + } + + return height || 0; +} + +/** + * Gets the viewport dimensions including any scrollbars. + */ +function getViewportDimensions() { + return { + width: window.innerWidth || getViewportWidth(), + height: window.innerHeight || getViewportHeight() + }; +} + +/** + * Gets the viewport dimensions excluding any scrollbars. + */ +getViewportDimensions.withoutScrollbars = function () { + return { + width: getViewportWidth(), + height: getViewportHeight() + }; +}; + +module.exports = getViewportDimensions;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/getViewportDimensions.js.flow b/node_modules/fbjs/lib/getViewportDimensions.js.flow new file mode 100644 index 000000000..4b03807ad --- /dev/null +++ b/node_modules/fbjs/lib/getViewportDimensions.js.flow @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule getViewportDimensions + * @flow + * @typechecks + */ + +type ViewportDimensions = { width: number; height: number; }; + +function getViewportWidth(): number { + let width; + if (document.documentElement) { + width = document.documentElement.clientWidth; + } + + if (!width && document.body) { + width = document.body.clientWidth; + } + + return width || 0; +} + +function getViewportHeight(): number { + let height; + if (document.documentElement) { + height = document.documentElement.clientHeight; + } + + if (!height && document.body) { + height = document.body.clientHeight; + } + + return height || 0; +} + +/** + * Gets the viewport dimensions including any scrollbars. + */ +function getViewportDimensions(): ViewportDimensions { + return { + width: window.innerWidth || getViewportWidth(), + height: window.innerHeight || getViewportHeight() + }; +} + +/** + * Gets the viewport dimensions excluding any scrollbars. + */ +getViewportDimensions.withoutScrollbars = function (): ViewportDimensions { + return { + width: getViewportWidth(), + height: getViewportHeight() + }; +}; + +module.exports = getViewportDimensions;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/groupArray.js b/node_modules/fbjs/lib/groupArray.js new file mode 100644 index 000000000..b62399360 --- /dev/null +++ b/node_modules/fbjs/lib/groupArray.js @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +/** + * Groups all items in the array using the specified function. An object will + * be returned where the keys are the group names, and the values are arrays of + * all the items in that group. + * + * @param {array} array + * @param {function} fn Should return a string with a group name + * @return {object} items grouped using fn + */ + +function groupArray(array, fn) { + var ret = {}; + for (var ii = 0; ii < array.length; ii++) { + var result = fn.call(array, array[ii], ii); + if (!ret[result]) { + ret[result] = []; + } + ret[result].push(array[ii]); + } + return ret; +} + +module.exports = groupArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/groupArray.js.flow b/node_modules/fbjs/lib/groupArray.js.flow new file mode 100644 index 000000000..de532f50d --- /dev/null +++ b/node_modules/fbjs/lib/groupArray.js.flow @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule groupArray + * @typechecks + */ + +'use strict'; + +/** + * Groups all items in the array using the specified function. An object will + * be returned where the keys are the group names, and the values are arrays of + * all the items in that group. + * + * @param {array} array + * @param {function} fn Should return a string with a group name + * @return {object} items grouped using fn + */ + +function groupArray(array, fn) { + var ret = {}; + for (var ii = 0; ii < array.length; ii++) { + var result = fn.call(array, array[ii], ii); + if (!ret[result]) { + ret[result] = []; + } + ret[result].push(array[ii]); + } + return ret; +} + +module.exports = groupArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/hyphenate.js b/node_modules/fbjs/lib/hyphenate.js new file mode 100644 index 000000000..8272a2864 --- /dev/null +++ b/node_modules/fbjs/lib/hyphenate.js @@ -0,0 +1,32 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var _uppercasePattern = /([A-Z])/g; + +/** + * Hyphenates a camelcased string, for example: + * + * > hyphenate('backgroundColor') + * < "background-color" + * + * For CSS style names, use `hyphenateStyleName` instead which works properly + * with all vendor prefixes, including `ms`. + * + * @param {string} string + * @return {string} + */ +function hyphenate(string) { + return string.replace(_uppercasePattern, '-$1').toLowerCase(); +} + +module.exports = hyphenate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/hyphenate.js.flow b/node_modules/fbjs/lib/hyphenate.js.flow new file mode 100644 index 000000000..36ad14e52 --- /dev/null +++ b/node_modules/fbjs/lib/hyphenate.js.flow @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule hyphenate + * @typechecks + */ + +const _uppercasePattern = /([A-Z])/g; + +/** + * Hyphenates a camelcased string, for example: + * + * > hyphenate('backgroundColor') + * < "background-color" + * + * For CSS style names, use `hyphenateStyleName` instead which works properly + * with all vendor prefixes, including `ms`. + * + * @param {string} string + * @return {string} + */ +function hyphenate(string) { + return string.replace(_uppercasePattern, '-$1').toLowerCase(); +} + +module.exports = hyphenate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/hyphenateStyleName.js b/node_modules/fbjs/lib/hyphenateStyleName.js new file mode 100644 index 000000000..c537b6d27 --- /dev/null +++ b/node_modules/fbjs/lib/hyphenateStyleName.js @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +var hyphenate = require('./hyphenate'); + +var msPattern = /^ms-/; + +/** + * Hyphenates a camelcased CSS property name, for example: + * + * > hyphenateStyleName('backgroundColor') + * < "background-color" + * > hyphenateStyleName('MozTransition') + * < "-moz-transition" + * > hyphenateStyleName('msTransition') + * < "-ms-transition" + * + * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix + * is converted to `-ms-`. + * + * @param {string} string + * @return {string} + */ +function hyphenateStyleName(string) { + return hyphenate(string).replace(msPattern, '-ms-'); +} + +module.exports = hyphenateStyleName;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/hyphenateStyleName.js.flow b/node_modules/fbjs/lib/hyphenateStyleName.js.flow new file mode 100644 index 000000000..aaf773539 --- /dev/null +++ b/node_modules/fbjs/lib/hyphenateStyleName.js.flow @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule hyphenateStyleName + * @typechecks + */ + +'use strict'; + +const hyphenate = require('./hyphenate'); + +const msPattern = /^ms-/; + +/** + * Hyphenates a camelcased CSS property name, for example: + * + * > hyphenateStyleName('backgroundColor') + * < "background-color" + * > hyphenateStyleName('MozTransition') + * < "-moz-transition" + * > hyphenateStyleName('msTransition') + * < "-ms-transition" + * + * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix + * is converted to `-ms-`. + * + * @param {string} string + * @return {string} + */ +function hyphenateStyleName(string) { + return hyphenate(string).replace(msPattern, '-ms-'); +} + +module.exports = hyphenateStyleName;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/invariant.js b/node_modules/fbjs/lib/invariant.js new file mode 100644 index 000000000..97b2e79c9 --- /dev/null +++ b/node_modules/fbjs/lib/invariant.js @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var validateFormat = function validateFormat(format) {}; + +if (process.env.NODE_ENV !== 'production') { + validateFormat = function validateFormat(format) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + }; +} + +function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); + + if (!condition) { + var error; + if (format === undefined) { + error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error(format.replace(/%s/g, function () { + return args[argIndex++]; + })); + error.name = 'Invariant Violation'; + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +} + +module.exports = invariant;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/invariant.js.flow b/node_modules/fbjs/lib/invariant.js.flow new file mode 100644 index 000000000..e2e64ebdf --- /dev/null +++ b/node_modules/fbjs/lib/invariant.js.flow @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule invariant + */ + +'use strict'; + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var validateFormat = function (format) {}; + +if (__DEV__) { + validateFormat = function (format) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + }; +} + +function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); + + if (!condition) { + var error; + if (format === undefined) { + error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error(format.replace(/%s/g, function () { + return args[argIndex++]; + })); + error.name = 'Invariant Violation'; + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +} + +module.exports = invariant;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/isEmpty.js b/node_modules/fbjs/lib/isEmpty.js new file mode 100644 index 000000000..1c7854c06 --- /dev/null +++ b/node_modules/fbjs/lib/isEmpty.js @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +'use strict'; + +/* eslint-disable fb-www/typeof-undefined */ +/* eslint-disable no-unused-vars */ + +var invariant = require('./invariant'); + +/** + * Checks if a value is empty. + */ +function isEmpty(value) { + if (Array.isArray(value)) { + return value.length === 0; + } else if (typeof value === 'object') { + if (value) { + !(!isIterable(value) || value.size === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isEmpty() does not support iterable collections.') : invariant(false) : void 0; + for (var _ in value) { + return false; + } + } + return true; + } else { + return !value; + } +} + +function isIterable(value) { + if (typeof Symbol === 'undefined') { + return false; + } + return value[Symbol.iterator]; +} + +module.exports = isEmpty;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/isEmpty.js.flow b/node_modules/fbjs/lib/isEmpty.js.flow new file mode 100644 index 000000000..d8a12ebd8 --- /dev/null +++ b/node_modules/fbjs/lib/isEmpty.js.flow @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule isEmpty + * @flow + */ + +'use strict'; + +/* eslint-disable fb-www/typeof-undefined */ +/* eslint-disable no-unused-vars */ + +const invariant = require('./invariant'); + +/** + * Checks if a value is empty. + */ +function isEmpty(value: mixed): boolean { + if (Array.isArray(value)) { + return value.length === 0; + } else if (typeof value === 'object') { + if (value) { + invariant(!isIterable(value) || value.size === undefined, 'isEmpty() does not support iterable collections.'); + for (const _ in value) { + return false; + } + } + return true; + } else { + return !value; + } +} + +function isIterable(value: any): boolean { + if (typeof Symbol === 'undefined') { + return false; + } + return value[Symbol.iterator]; +} + +module.exports = isEmpty;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/isNode.js b/node_modules/fbjs/lib/isNode.js new file mode 100644 index 000000000..0ec7b7ee8 --- /dev/null +++ b/node_modules/fbjs/lib/isNode.js @@ -0,0 +1,24 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/** + * @param {*} object The object to check. + * @return {boolean} Whether or not the object is a DOM node. + */ +function isNode(object) { + var doc = object ? object.ownerDocument || object : document; + var defaultView = doc.defaultView || window; + return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')); +} + +module.exports = isNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/isNode.js.flow b/node_modules/fbjs/lib/isNode.js.flow new file mode 100644 index 000000000..0b43a0871 --- /dev/null +++ b/node_modules/fbjs/lib/isNode.js.flow @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule isNode + * @typechecks + */ + +/** + * @param {*} object The object to check. + * @return {boolean} Whether or not the object is a DOM node. + */ +function isNode(object) { + var doc = object ? object.ownerDocument || object : document; + var defaultView = doc.defaultView || window; + return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')); +} + +module.exports = isNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/isTextNode.js b/node_modules/fbjs/lib/isTextNode.js new file mode 100644 index 000000000..5f63cbbcd --- /dev/null +++ b/node_modules/fbjs/lib/isTextNode.js @@ -0,0 +1,24 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var isNode = require('./isNode'); + +/** + * @param {*} object The object to check. + * @return {boolean} Whether or not the object is a DOM text node. + */ +function isTextNode(object) { + return isNode(object) && object.nodeType == 3; +} + +module.exports = isTextNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/isTextNode.js.flow b/node_modules/fbjs/lib/isTextNode.js.flow new file mode 100644 index 000000000..caa4ae4dc --- /dev/null +++ b/node_modules/fbjs/lib/isTextNode.js.flow @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule isTextNode + * @typechecks + */ + +const isNode = require('./isNode'); + +/** + * @param {*} object The object to check. + * @return {boolean} Whether or not the object is a DOM text node. + */ +function isTextNode(object) { + return isNode(object) && object.nodeType == 3; +} + +module.exports = isTextNode;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/joinClasses.js b/node_modules/fbjs/lib/joinClasses.js new file mode 100644 index 000000000..89d47abc8 --- /dev/null +++ b/node_modules/fbjs/lib/joinClasses.js @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks static-only + */ + +'use strict'; + +/** + * Combines multiple className strings into one. + * http://jsperf.com/joinclasses-args-vs-array + * + * @param {...?string} className + * @return {string} + */ + +function joinClasses(className /*, ... */) { + if (!className) { + className = ''; + } + var nextClass = void 0; + var argLength = arguments.length; + if (argLength > 1) { + for (var ii = 1; ii < argLength; ii++) { + nextClass = arguments[ii]; + if (nextClass) { + className = (className ? className + ' ' : '') + nextClass; + } + } + } + return className; +} + +module.exports = joinClasses;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/joinClasses.js.flow b/node_modules/fbjs/lib/joinClasses.js.flow new file mode 100644 index 000000000..e07f24180 --- /dev/null +++ b/node_modules/fbjs/lib/joinClasses.js.flow @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule joinClasses + * @typechecks static-only + */ + +'use strict'; + +/** + * Combines multiple className strings into one. + * http://jsperf.com/joinclasses-args-vs-array + * + * @param {...?string} className + * @return {string} + */ + +function joinClasses(className /*, ... */) { + if (!className) { + className = ''; + } + let nextClass; + const argLength = arguments.length; + if (argLength > 1) { + for (let ii = 1; ii < argLength; ii++) { + nextClass = arguments[ii]; + if (nextClass) { + className = (className ? className + ' ' : '') + nextClass; + } + } + } + return className; +} + +module.exports = joinClasses;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/keyMirror.js b/node_modules/fbjs/lib/keyMirror.js new file mode 100644 index 000000000..4e46b1f65 --- /dev/null +++ b/node_modules/fbjs/lib/keyMirror.js @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks static-only + */ + +'use strict'; + +var invariant = require('./invariant'); + +/** + * Constructs an enumeration with keys equal to their value. + * + * For example: + * + * var COLORS = keyMirror({blue: null, red: null}); + * var myColor = COLORS.blue; + * var isColorValid = !!COLORS[myColor]; + * + * The last line could not be performed if the values of the generated enum were + * not equal to their keys. + * + * Input: {key1: val1, key2: val2} + * Output: {key1: key1, key2: key2} + * + * @param {object} obj + * @return {object} + */ +var keyMirror = function keyMirror(obj) { + var ret = {}; + var key; + !(obj instanceof Object && !Array.isArray(obj)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'keyMirror(...): Argument must be an object.') : invariant(false) : void 0; + for (key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + ret[key] = key; + } + return ret; +}; + +module.exports = keyMirror;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/keyMirror.js.flow b/node_modules/fbjs/lib/keyMirror.js.flow new file mode 100644 index 000000000..3b09341a6 --- /dev/null +++ b/node_modules/fbjs/lib/keyMirror.js.flow @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule keyMirror + * @typechecks static-only + */ + +'use strict'; + +var invariant = require('./invariant'); + +/** + * Constructs an enumeration with keys equal to their value. + * + * For example: + * + * var COLORS = keyMirror({blue: null, red: null}); + * var myColor = COLORS.blue; + * var isColorValid = !!COLORS[myColor]; + * + * The last line could not be performed if the values of the generated enum were + * not equal to their keys. + * + * Input: {key1: val1, key2: val2} + * Output: {key1: key1, key2: key2} + * + * @param {object} obj + * @return {object} + */ +var keyMirror = function (obj) { + var ret = {}; + var key; + invariant(obj instanceof Object && !Array.isArray(obj), 'keyMirror(...): Argument must be an object.'); + for (key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + ret[key] = key; + } + return ret; +}; + +module.exports = keyMirror;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/keyMirrorRecursive.js b/node_modules/fbjs/lib/keyMirrorRecursive.js new file mode 100644 index 000000000..3abe772b8 --- /dev/null +++ b/node_modules/fbjs/lib/keyMirrorRecursive.js @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * weak + * @typechecks + */ + +'use strict'; + +var invariant = require('./invariant'); + +/** + * Constructs an enumeration with keys equal to their value. If the value is an + * object, the method is run recursively, including the parent key as a suffix. + * An optional prefix can be provided that will be prepended to each value. + * + * For example: + * + * var ACTIONS = keyMirror({FOO: null, BAR: { BAZ: null, BOZ: null }}}); + * ACTIONS.BAR.BAZ = 'BAR.BAZ'; + * + * Input: {key1: null, key2: { nested1: null, nested2: null }}} + * Output: {key1: key1, key2: { nested1: nested1, nested2: nested2 }}} + * + * var CONSTANTS = keyMirror({FOO: {BAR: null}}, 'NameSpace'); + * console.log(CONSTANTS.FOO.BAR); // NameSpace.FOO.BAR + */ +function keyMirrorRecursive(obj, prefix) { + return keyMirrorRecursiveInternal(obj, prefix); +} + +function keyMirrorRecursiveInternal( +/*object*/obj, +/*?string*/prefix) /*object*/{ + var ret = {}; + var key; + + !isObject(obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'keyMirrorRecursive(...): Argument must be an object.') : invariant(false) : void 0; + + for (key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + + var val = obj[key]; + + var newPrefix = prefix ? prefix + '.' + key : key; + + if (isObject(val)) { + val = keyMirrorRecursiveInternal(val, newPrefix); + } else { + val = newPrefix; + } + + ret[key] = val; + } + return ret; +} + +function isObject(obj) /*boolean*/{ + return obj instanceof Object && !Array.isArray(obj); +} + +module.exports = keyMirrorRecursive;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/keyMirrorRecursive.js.flow b/node_modules/fbjs/lib/keyMirrorRecursive.js.flow new file mode 100644 index 000000000..8a700b274 --- /dev/null +++ b/node_modules/fbjs/lib/keyMirrorRecursive.js.flow @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule keyMirrorRecursive + * @flow weak + * @typechecks + */ + +'use strict'; + +var invariant = require('./invariant'); + +/** + * Constructs an enumeration with keys equal to their value. If the value is an + * object, the method is run recursively, including the parent key as a suffix. + * An optional prefix can be provided that will be prepended to each value. + * + * For example: + * + * var ACTIONS = keyMirror({FOO: null, BAR: { BAZ: null, BOZ: null }}}); + * ACTIONS.BAR.BAZ = 'BAR.BAZ'; + * + * Input: {key1: null, key2: { nested1: null, nested2: null }}} + * Output: {key1: key1, key2: { nested1: nested1, nested2: nested2 }}} + * + * var CONSTANTS = keyMirror({FOO: {BAR: null}}, 'NameSpace'); + * console.log(CONSTANTS.FOO.BAR); // NameSpace.FOO.BAR + */ +function keyMirrorRecursive<T>(obj: T, prefix?: ?string): T { + return keyMirrorRecursiveInternal(obj, prefix); +} + +function keyMirrorRecursiveInternal( +/*object*/obj, +/*?string*/prefix) /*object*/{ + var ret = {}; + var key; + + invariant(isObject(obj), 'keyMirrorRecursive(...): Argument must be an object.'); + + for (key in obj) { + if (!obj.hasOwnProperty(key)) { + continue; + } + + var val = obj[key]; + + var newPrefix = prefix ? prefix + '.' + key : key; + + if (isObject(val)) { + val = keyMirrorRecursiveInternal(val, newPrefix); + } else { + val = newPrefix; + } + + ret[key] = val; + } + return ret; +} + +function isObject(obj) /*boolean*/{ + return obj instanceof Object && !Array.isArray(obj); +} + +module.exports = keyMirrorRecursive;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/keyOf.js b/node_modules/fbjs/lib/keyOf.js new file mode 100644 index 000000000..23c2881a6 --- /dev/null +++ b/node_modules/fbjs/lib/keyOf.js @@ -0,0 +1,34 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +/** + * Allows extraction of a minified key. Let's the build system minify keys + * without losing the ability to dynamically use key strings as values + * themselves. Pass in an object with a single key/val pair and it will return + * you the string key of that single record. Suppose you want to grab the + * value for a key 'className' inside of an object. Key/val minification may + * have aliased that key to be 'xa12'. keyOf({className: null}) will return + * 'xa12' in that case. Resolve keys you want to use once at startup time, then + * reuse those resolutions. + */ +var keyOf = function keyOf(oneKeyObj) { + var key; + for (key in oneKeyObj) { + if (!oneKeyObj.hasOwnProperty(key)) { + continue; + } + return key; + } + return null; +}; + +module.exports = keyOf;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/keyOf.js.flow b/node_modules/fbjs/lib/keyOf.js.flow new file mode 100644 index 000000000..2c4f8e5d7 --- /dev/null +++ b/node_modules/fbjs/lib/keyOf.js.flow @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule keyOf + */ + +/** + * Allows extraction of a minified key. Let's the build system minify keys + * without losing the ability to dynamically use key strings as values + * themselves. Pass in an object with a single key/val pair and it will return + * you the string key of that single record. Suppose you want to grab the + * value for a key 'className' inside of an object. Key/val minification may + * have aliased that key to be 'xa12'. keyOf({className: null}) will return + * 'xa12' in that case. Resolve keys you want to use once at startup time, then + * reuse those resolutions. + */ +var keyOf = function (oneKeyObj) { + var key; + for (key in oneKeyObj) { + if (!oneKeyObj.hasOwnProperty(key)) { + continue; + } + return key; + } + return null; +}; + +module.exports = keyOf;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/mapObject.js b/node_modules/fbjs/lib/mapObject.js new file mode 100644 index 000000000..16b7c5b9b --- /dev/null +++ b/node_modules/fbjs/lib/mapObject.js @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object and constructs a new object from the results. The `callback` is + * invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `mapObject` will not be visited + * by `callback`. If the values of existing properties are changed, the value + * passed to `callback` will be the value at the time `mapObject` visits them. + * Properties that are deleted before being visited are not visited. + * + * @grep function objectMap() + * @grep function objMap() + * + * @param {?object} object + * @param {function} callback + * @param {*} context + * @return {?object} + */ +function mapObject(object, callback, context) { + if (!object) { + return null; + } + var result = {}; + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + result[name] = callback.call(context, object[name], name, object); + } + } + return result; +} + +module.exports = mapObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/mapObject.js.flow b/node_modules/fbjs/lib/mapObject.js.flow new file mode 100644 index 000000000..c5ca4c083 --- /dev/null +++ b/node_modules/fbjs/lib/mapObject.js.flow @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule mapObject + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object and constructs a new object from the results. The `callback` is + * invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `mapObject` will not be visited + * by `callback`. If the values of existing properties are changed, the value + * passed to `callback` will be the value at the time `mapObject` visits them. + * Properties that are deleted before being visited are not visited. + * + * @grep function objectMap() + * @grep function objMap() + * + * @param {?object} object + * @param {function} callback + * @param {*} context + * @return {?object} + */ +function mapObject(object, callback, context) { + if (!object) { + return null; + } + var result = {}; + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + result[name] = callback.call(context, object[name], name, object); + } + } + return result; +} + +module.exports = mapObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/maxBy.js b/node_modules/fbjs/lib/maxBy.js new file mode 100644 index 000000000..dc6b3a624 --- /dev/null +++ b/node_modules/fbjs/lib/maxBy.js @@ -0,0 +1,32 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var minBy = require('./minBy'); + +var compareNumber = function compareNumber(a, b) { + return a - b; +}; + +/** + * Returns the maximum element as measured by a scoring function f. Returns the + * first such element if there are ties. + */ +function maxBy(as, f, compare) { + compare = compare || compareNumber; + + return minBy(as, f, function (u, v) { + return compare(v, u); + }); +} + +module.exports = maxBy;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/maxBy.js.flow b/node_modules/fbjs/lib/maxBy.js.flow new file mode 100644 index 000000000..38af0c706 --- /dev/null +++ b/node_modules/fbjs/lib/maxBy.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule maxBy + * @flow + */ + +var minBy = require('./minBy'); + +var compareNumber = (a, b) => a - b; + +/** + * Returns the maximum element as measured by a scoring function f. Returns the + * first such element if there are ties. + */ +function maxBy<A, B>(as: Iterable<A>, f: (a: A) => B, compare?: ?(u: B, v: B) => number): ?A { + compare = compare || (compareNumber: any); + + return minBy(as, f, (u, v) => (compare: any)(v, u)); +} + +module.exports = maxBy;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/memoizeStringOnly.js b/node_modules/fbjs/lib/memoizeStringOnly.js new file mode 100644 index 000000000..1431e27b5 --- /dev/null +++ b/node_modules/fbjs/lib/memoizeStringOnly.js @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + * @typechecks static-only + */ + +'use strict'; + +/** + * Memoizes the return value of a function that accepts one string argument. + */ + +function memoizeStringOnly(callback) { + var cache = {}; + return function (string) { + if (!cache.hasOwnProperty(string)) { + cache[string] = callback.call(this, string); + } + return cache[string]; + }; +} + +module.exports = memoizeStringOnly;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/memoizeStringOnly.js.flow b/node_modules/fbjs/lib/memoizeStringOnly.js.flow new file mode 100644 index 000000000..bceb694b3 --- /dev/null +++ b/node_modules/fbjs/lib/memoizeStringOnly.js.flow @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule memoizeStringOnly + * @flow + * @typechecks static-only + */ + +'use strict'; + +/** + * Memoizes the return value of a function that accepts one string argument. + */ + +function memoizeStringOnly<T>(callback: (s: string) => T): (s: string) => T { + const cache = {}; + return function (string) { + if (!cache.hasOwnProperty(string)) { + cache[string] = callback.call(this, string); + } + return cache[string]; + }; +} + +module.exports = memoizeStringOnly;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/minBy.js b/node_modules/fbjs/lib/minBy.js new file mode 100644 index 000000000..73091158b --- /dev/null +++ b/node_modules/fbjs/lib/minBy.js @@ -0,0 +1,61 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var compareNumber = function compareNumber(a, b) { + return a - b; +}; + +/** + * Returns the minimum element as measured by a scoring function f. Returns the + * first such element if there are ties. + */ +function minBy(as, f, compare) { + compare = compare || compareNumber; + + var minA = undefined; + var minB = undefined; + var seenFirst = false; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; + + try { + for (var _iterator = as[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var a = _step.value; + + var b = f(a); + if (!seenFirst || compare(b, minB) < 0) { + minA = a; + minB = b; + seenFirst = true; + } + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator["return"]) { + _iterator["return"](); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return minA; +} + +module.exports = minBy;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/minBy.js.flow b/node_modules/fbjs/lib/minBy.js.flow new file mode 100644 index 000000000..a76aec4fa --- /dev/null +++ b/node_modules/fbjs/lib/minBy.js.flow @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule minBy + * @flow + */ + +var compareNumber = (a, b) => a - b; + +/** + * Returns the minimum element as measured by a scoring function f. Returns the + * first such element if there are ties. + */ +function minBy<A, B>(as: Iterable<A>, f: (a: A) => B, compare?: ?(u: B, v: B) => number): ?A { + compare = compare || (compareNumber: any); + + var minA = undefined; + var minB = undefined; + var seenFirst = false; + for (var a of as) { + var b = f(a); + if (!seenFirst || compare(b, (minB: any)) < 0) { + minA = a; + minB = b; + seenFirst = true; + } + } + + return minA; +} + +module.exports = minBy;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/monitorCodeUse.js b/node_modules/fbjs/lib/monitorCodeUse.js new file mode 100644 index 000000000..d8682982f --- /dev/null +++ b/node_modules/fbjs/lib/monitorCodeUse.js @@ -0,0 +1,26 @@ +/** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var invariant = require('./invariant'); + +/** + * Provides open-source compatible instrumentation for monitoring certain API + * uses before we're ready to issue a warning or refactor. It accepts an event + * name which may only contain the characters [a-z0-9_] and an optional data + * object with further information. + */ + +function monitorCodeUse(eventName, data) { + !(eventName && !/[^a-z0-9_]/.test(eventName)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You must provide an eventName using only the characters [a-z0-9_]') : invariant(false) : void 0; +} + +module.exports = monitorCodeUse;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/monitorCodeUse.js.flow b/node_modules/fbjs/lib/monitorCodeUse.js.flow new file mode 100644 index 000000000..1eabaf63b --- /dev/null +++ b/node_modules/fbjs/lib/monitorCodeUse.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule monitorCodeUse + */ + +'use strict'; + +var invariant = require('./invariant'); + +/** + * Provides open-source compatible instrumentation for monitoring certain API + * uses before we're ready to issue a warning or refactor. It accepts an event + * name which may only contain the characters [a-z0-9_] and an optional data + * object with further information. + */ + +function monitorCodeUse(eventName, data) { + invariant(eventName && !/[^a-z0-9_]/.test(eventName), 'You must provide an eventName using only the characters [a-z0-9_]'); +} + +module.exports = monitorCodeUse;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/nativeRequestAnimationFrame.js b/node_modules/fbjs/lib/nativeRequestAnimationFrame.js new file mode 100644 index 000000000..ea9d61deb --- /dev/null +++ b/node_modules/fbjs/lib/nativeRequestAnimationFrame.js @@ -0,0 +1,15 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +var nativeRequestAnimationFrame = global.requestAnimationFrame || global.webkitRequestAnimationFrame || global.mozRequestAnimationFrame || global.oRequestAnimationFrame || global.msRequestAnimationFrame; + +module.exports = nativeRequestAnimationFrame;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/nativeRequestAnimationFrame.js.flow b/node_modules/fbjs/lib/nativeRequestAnimationFrame.js.flow new file mode 100644 index 000000000..869abda74 --- /dev/null +++ b/node_modules/fbjs/lib/nativeRequestAnimationFrame.js.flow @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule nativeRequestAnimationFrame + */ + +const nativeRequestAnimationFrame = global.requestAnimationFrame || global.webkitRequestAnimationFrame || global.mozRequestAnimationFrame || global.oRequestAnimationFrame || global.msRequestAnimationFrame; + +module.exports = nativeRequestAnimationFrame;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/nullthrows.js b/node_modules/fbjs/lib/nullthrows.js new file mode 100644 index 000000000..0901c27f2 --- /dev/null +++ b/node_modules/fbjs/lib/nullthrows.js @@ -0,0 +1,21 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var nullthrows = function nullthrows(x) { + if (x != null) { + return x; + } + throw new Error("Got unexpected null or undefined"); +}; + +module.exports = nullthrows;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/nullthrows.js.flow b/node_modules/fbjs/lib/nullthrows.js.flow new file mode 100644 index 000000000..13227b0f6 --- /dev/null +++ b/node_modules/fbjs/lib/nullthrows.js.flow @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule nullthrows + * @flow + */ + +var nullthrows = function <T>(x: ?T): T { + if (x != null) { + return x; + } + throw new Error("Got unexpected null or undefined"); +}; + +module.exports = nullthrows;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/partitionArray.js b/node_modules/fbjs/lib/partitionArray.js new file mode 100644 index 000000000..b8ed62da0 --- /dev/null +++ b/node_modules/fbjs/lib/partitionArray.js @@ -0,0 +1,33 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/** + * Partitions an array given a predicate. All elements satisfying the predicate + * are part of the first returned array, and all elements that don't are in the + * second. + */ +function partitionArray(array, predicate, context) { + var first = []; + var second = []; + array.forEach(function (element, index) { + if (predicate.call(context, element, index, array)) { + first.push(element); + } else { + second.push(element); + } + }); + return [first, second]; +} + +module.exports = partitionArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/partitionArray.js.flow b/node_modules/fbjs/lib/partitionArray.js.flow new file mode 100644 index 000000000..0b7d5fa03 --- /dev/null +++ b/node_modules/fbjs/lib/partitionArray.js.flow @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule partitionArray + * @typechecks + * @flow + */ + +/** + * Partitions an array given a predicate. All elements satisfying the predicate + * are part of the first returned array, and all elements that don't are in the + * second. + */ +function partitionArray<Tv>(array: Array<Tv>, predicate: (value: Tv, index: number, array: Array<Tv>) => boolean, context?: any): [Array<Tv>, Array<Tv>] { + var first = []; + var second = []; + array.forEach((element, index) => { + if (predicate.call(context, element, index, array)) { + first.push(element); + } else { + second.push(element); + } + }); + return [first, second]; +} + +module.exports = partitionArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/partitionObject.js b/node_modules/fbjs/lib/partitionObject.js new file mode 100644 index 000000000..f28ee6a53 --- /dev/null +++ b/node_modules/fbjs/lib/partitionObject.js @@ -0,0 +1,30 @@ +/** + * Copyright 2015-present Facebook. All Rights Reserved. + * + * @typechecks + * + */ + +'use strict'; + +var forEachObject = require('./forEachObject'); + +/** + * Partitions an object given a predicate. All elements satisfying the predicate + * are part of the first returned object, and all elements that don't are in the + * second. + */ +function partitionObject(object, callback, context) { + var first = {}; + var second = {}; + forEachObject(object, function (value, key) { + if (callback.call(context, value, key, object)) { + first[key] = value; + } else { + second[key] = value; + } + }); + return [first, second]; +} + +module.exports = partitionObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/partitionObject.js.flow b/node_modules/fbjs/lib/partitionObject.js.flow new file mode 100644 index 000000000..cc69cb604 --- /dev/null +++ b/node_modules/fbjs/lib/partitionObject.js.flow @@ -0,0 +1,31 @@ +/** + * Copyright 2015-present Facebook. All Rights Reserved. + * + * @providesModule partitionObject + * @typechecks + * @flow + */ + +'use strict'; + +var forEachObject = require('./forEachObject'); + +/** + * Partitions an object given a predicate. All elements satisfying the predicate + * are part of the first returned object, and all elements that don't are in the + * second. + */ +function partitionObject<Tv>(object: { [key: string]: Tv }, callback: (value: Tv, key: string, object: { [key: string]: Tv }) => boolean, context?: any): [{ [key: string]: Tv }, { [key: string]: Tv }] { + var first = {}; + var second = {}; + forEachObject(object, (value, key) => { + if (callback.call(context, value, key, object)) { + first[key] = value; + } else { + second[key] = value; + } + }); + return [first, second]; +} + +module.exports = partitionObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/partitionObjectByKey.js b/node_modules/fbjs/lib/partitionObjectByKey.js new file mode 100644 index 000000000..3bc292c3b --- /dev/null +++ b/node_modules/fbjs/lib/partitionObjectByKey.js @@ -0,0 +1,24 @@ +/** + * Copyright 2015-present Facebook. All Rights Reserved. + * + * @typechecks + * + */ + +'use strict'; + +var partitionObject = require('./partitionObject'); + +/** + * Partitions the enumerable properties of an object into two objects, given a + * whitelist `Set` for the first object. This is comparable to + * `whitelistObjectKeys`, but eventually keeping all the keys. Returns a tuple + * of objects `[first, second]`. + */ +function partitionObjectByKey(source, whitelist) { + return partitionObject(source, function (_, key) { + return whitelist.has(key); + }); +} + +module.exports = partitionObjectByKey;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/partitionObjectByKey.js.flow b/node_modules/fbjs/lib/partitionObjectByKey.js.flow new file mode 100644 index 000000000..120fb3b44 --- /dev/null +++ b/node_modules/fbjs/lib/partitionObjectByKey.js.flow @@ -0,0 +1,23 @@ +/** + * Copyright 2015-present Facebook. All Rights Reserved. + * + * @providesModule partitionObjectByKey + * @typechecks + * @flow + */ + +'use strict'; + +var partitionObject = require('./partitionObject'); + +/** + * Partitions the enumerable properties of an object into two objects, given a + * whitelist `Set` for the first object. This is comparable to + * `whitelistObjectKeys`, but eventually keeping all the keys. Returns a tuple + * of objects `[first, second]`. + */ +function partitionObjectByKey(source: Object, whitelist: Set<string>): [Object, Object] { + return partitionObject(source, (_, key) => whitelist.has(key)); +} + +module.exports = partitionObjectByKey;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/performance.js b/node_modules/fbjs/lib/performance.js new file mode 100644 index 000000000..a038a797f --- /dev/null +++ b/node_modules/fbjs/lib/performance.js @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +'use strict'; + +var ExecutionEnvironment = require('./ExecutionEnvironment'); + +var performance; + +if (ExecutionEnvironment.canUseDOM) { + performance = window.performance || window.msPerformance || window.webkitPerformance; +} + +module.exports = performance || {};
\ No newline at end of file diff --git a/node_modules/fbjs/lib/performance.js.flow b/node_modules/fbjs/lib/performance.js.flow new file mode 100644 index 000000000..0e67e7aea --- /dev/null +++ b/node_modules/fbjs/lib/performance.js.flow @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule performance + * @typechecks + */ + +'use strict'; + +var ExecutionEnvironment = require('./ExecutionEnvironment'); + +var performance; + +if (ExecutionEnvironment.canUseDOM) { + performance = window.performance || window.msPerformance || window.webkitPerformance; +} + +module.exports = performance || {};
\ No newline at end of file diff --git a/node_modules/fbjs/lib/performanceNow.js b/node_modules/fbjs/lib/performanceNow.js new file mode 100644 index 000000000..925df0680 --- /dev/null +++ b/node_modules/fbjs/lib/performanceNow.js @@ -0,0 +1,33 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +var performance = require('./performance'); + +var performanceNow; + +/** + * Detect if we can use `window.performance.now()` and gracefully fallback to + * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now + * because of Facebook's testing infrastructure. + */ +if (performance.now) { + performanceNow = function performanceNow() { + return performance.now(); + }; +} else { + performanceNow = function performanceNow() { + return Date.now(); + }; +} + +module.exports = performanceNow;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/performanceNow.js.flow b/node_modules/fbjs/lib/performanceNow.js.flow new file mode 100644 index 000000000..afa15974c --- /dev/null +++ b/node_modules/fbjs/lib/performanceNow.js.flow @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule performanceNow + * @typechecks + */ + +var performance = require('./performance'); + +var performanceNow; + +/** + * Detect if we can use `window.performance.now()` and gracefully fallback to + * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now + * because of Facebook's testing infrastructure. + */ +if (performance.now) { + performanceNow = () => performance.now(); +} else { + performanceNow = () => Date.now(); +} + +module.exports = performanceNow;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/removeFromArray.js b/node_modules/fbjs/lib/removeFromArray.js new file mode 100644 index 000000000..7693b9d0b --- /dev/null +++ b/node_modules/fbjs/lib/removeFromArray.js @@ -0,0 +1,25 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/** + * Removes an element from an array. + */ +function removeFromArray(array, element) { + var index = array.indexOf(element); + if (index !== -1) { + array.splice(index, 1); + } +} + +module.exports = removeFromArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/removeFromArray.js.flow b/node_modules/fbjs/lib/removeFromArray.js.flow new file mode 100644 index 000000000..9ac99b133 --- /dev/null +++ b/node_modules/fbjs/lib/removeFromArray.js.flow @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule removeFromArray + * @typechecks + * @flow + */ + +/** + * Removes an element from an array. + */ +function removeFromArray<T>(array: Array<T>, element: T): void { + var index = array.indexOf(element); + if (index !== -1) { + array.splice(index, 1); + } +} + +module.exports = removeFromArray;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/requestAnimationFrame.js b/node_modules/fbjs/lib/requestAnimationFrame.js new file mode 100644 index 000000000..68000b9ef --- /dev/null +++ b/node_modules/fbjs/lib/requestAnimationFrame.js @@ -0,0 +1,30 @@ +'use strict'; + +/** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +var emptyFunction = require('./emptyFunction'); +var nativeRequestAnimationFrame = require('./nativeRequestAnimationFrame'); + +var lastTime = 0; + +var requestAnimationFrame = nativeRequestAnimationFrame || function (callback) { + var currTime = Date.now(); + var timeDelay = Math.max(0, 16 - (currTime - lastTime)); + lastTime = currTime + timeDelay; + return global.setTimeout(function () { + callback(Date.now()); + }, timeDelay); +}; + +// Works around a rare bug in Safari 6 where the first request is never invoked. +requestAnimationFrame(emptyFunction); + +module.exports = requestAnimationFrame;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/requestAnimationFrame.js.flow b/node_modules/fbjs/lib/requestAnimationFrame.js.flow new file mode 100644 index 000000000..49ddb96e1 --- /dev/null +++ b/node_modules/fbjs/lib/requestAnimationFrame.js.flow @@ -0,0 +1,29 @@ +/** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule requestAnimationFrame + */ + +var emptyFunction = require('./emptyFunction'); +var nativeRequestAnimationFrame = require('./nativeRequestAnimationFrame'); + +var lastTime = 0; + +var requestAnimationFrame = nativeRequestAnimationFrame || function (callback) { + var currTime = Date.now(); + var timeDelay = Math.max(0, 16 - (currTime - lastTime)); + lastTime = currTime + timeDelay; + return global.setTimeout(function () { + callback(Date.now()); + }, timeDelay); +}; + +// Works around a rare bug in Safari 6 where the first request is never invoked. +requestAnimationFrame(emptyFunction); + +module.exports = requestAnimationFrame;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/resolveImmediate.js b/node_modules/fbjs/lib/resolveImmediate.js new file mode 100644 index 000000000..a502b72c5 --- /dev/null +++ b/node_modules/fbjs/lib/resolveImmediate.js @@ -0,0 +1,31 @@ +"use strict"; + +var Promise = require("./Promise"); + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + */ + +var resolvedPromise = Promise.resolve(); + +/** + * An alternative to setImmediate based on Promise. + */ +function resolveImmediate(callback) { + resolvedPromise.then(callback)["catch"](throwNext); +} + +function throwNext(error) { + setTimeout(function () { + throw error; + }, 0); +} + +module.exports = resolveImmediate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/resolveImmediate.js.flow b/node_modules/fbjs/lib/resolveImmediate.js.flow new file mode 100644 index 000000000..20668b225 --- /dev/null +++ b/node_modules/fbjs/lib/resolveImmediate.js.flow @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule resolveImmediate + * @flow + */ + +const resolvedPromise = Promise.resolve(); + +/** + * An alternative to setImmediate based on Promise. + */ +function resolveImmediate(callback: () => any): void { + resolvedPromise.then(callback).catch(throwNext); +} + +function throwNext(error) { + setTimeout(() => { + throw error; + }, 0); +} + +module.exports = resolveImmediate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/setImmediate.js b/node_modules/fbjs/lib/setImmediate.js new file mode 100644 index 000000000..5ed329790 --- /dev/null +++ b/node_modules/fbjs/lib/setImmediate.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +// setimmediate adds setImmediate to the global. We want to make sure we export +// the actual function. + +require('setimmediate'); +module.exports = global.setImmediate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/setImmediate.js.flow b/node_modules/fbjs/lib/setImmediate.js.flow new file mode 100644 index 000000000..6b8fcbab6 --- /dev/null +++ b/node_modules/fbjs/lib/setImmediate.js.flow @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule setImmediate + */ + +'use strict'; + +// setimmediate adds setImmediate to the global. We want to make sure we export +// the actual function. + +require('setimmediate'); +module.exports = global.setImmediate;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/shallowEqual.js b/node_modules/fbjs/lib/shallowEqual.js new file mode 100644 index 000000000..b7899474b --- /dev/null +++ b/node_modules/fbjs/lib/shallowEqual.js @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + * + */ + +/*eslint-disable no-self-compare */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + // SameValue algorithm + if (x === y) { + // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + // Added the nonzero y check to make Flow happy, but it is redundant + return x !== 0 || y !== 0 || 1 / x === 1 / y; + } else { + // Step 6.a: NaN == NaN + return x !== x && y !== y; + } +} + +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ +function shallowEqual(objA, objB) { + if (is(objA, objB)) { + return true; + } + + if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { + return false; + } + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } + + // Test for A's keys different from B. + for (var i = 0; i < keysA.length; i++) { + if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { + return false; + } + } + + return true; +} + +module.exports = shallowEqual;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/shallowEqual.js.flow b/node_modules/fbjs/lib/shallowEqual.js.flow new file mode 100644 index 000000000..8b4e3172a --- /dev/null +++ b/node_modules/fbjs/lib/shallowEqual.js.flow @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule shallowEqual + * @typechecks + * @flow + */ + +/*eslint-disable no-self-compare */ + +'use strict'; + +const hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x: mixed, y: mixed): boolean { + // SameValue algorithm + if (x === y) { + // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + // Added the nonzero y check to make Flow happy, but it is redundant + return x !== 0 || y !== 0 || 1 / x === 1 / y; + } else { + // Step 6.a: NaN == NaN + return x !== x && y !== y; + } +} + +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ +function shallowEqual(objA: mixed, objB: mixed): boolean { + if (is(objA, objB)) { + return true; + } + + if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { + return false; + } + + const keysA = Object.keys(objA); + const keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } + + // Test for A's keys different from B. + for (let i = 0; i < keysA.length; i++) { + if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { + return false; + } + } + + return true; +} + +module.exports = shallowEqual;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/someObject.js b/node_modules/fbjs/lib/someObject.js new file mode 100644 index 000000000..e939dc776 --- /dev/null +++ b/node_modules/fbjs/lib/someObject.js @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + * @typechecks + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object until it finds one where callback returns a truthy value. If such a + * property is found, `someObject` immediately returns true. Otherwise, it + * returns false. + * + * The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `someObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `someObject` + * visits them. Properties that are deleted before being visited are not + * visited. + */ +function someObject(object, callback, context) { + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + if (callback.call(context, object[name], name, object)) { + return true; + } + } + } + return false; +} + +module.exports = someObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/someObject.js.flow b/node_modules/fbjs/lib/someObject.js.flow new file mode 100644 index 000000000..44afe5a6a --- /dev/null +++ b/node_modules/fbjs/lib/someObject.js.flow @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule someObject + * @flow + * @typechecks + */ + +'use strict'; + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Executes the provided `callback` once for each enumerable own property in the + * object until it finds one where callback returns a truthy value. If such a + * property is found, `someObject` immediately returns true. Otherwise, it + * returns false. + * + * The `callback` is invoked with three arguments: + * + * - the property value + * - the property name + * - the object being traversed + * + * Properties that are added after the call to `someObject` will not be + * visited by `callback`. If the values of existing properties are changed, the + * value passed to `callback` will be the value at the time `someObject` + * visits them. Properties that are deleted before being visited are not + * visited. + */ +function someObject(object: ?Object, callback: (value: any, name: string, object: Object) => any, context?: any): boolean { + for (var name in object) { + if (hasOwnProperty.call(object, name)) { + if (callback.call(context, object[name], name, object)) { + return true; + } + } + } + return false; +} + +module.exports = someObject;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/someSet.js b/node_modules/fbjs/lib/someSet.js new file mode 100644 index 000000000..41393d279 --- /dev/null +++ b/node_modules/fbjs/lib/someSet.js @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * + * @typechecks + */ + +'use strict'; + +/** + * The someSet() method tests whether some elements in the given Set pass the + * test implemented by the provided function. + */ +function someSet(set, callback, context) { + var iterator = set.entries(); + var current = iterator.next(); + while (!current.done) { + var entry = current.value; + if (callback.call(context, entry[1], entry[0], set)) { + return true; + } + current = iterator.next(); + } + return false; +} + +module.exports = someSet;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/someSet.js.flow b/node_modules/fbjs/lib/someSet.js.flow new file mode 100644 index 000000000..74142b64c --- /dev/null +++ b/node_modules/fbjs/lib/someSet.js.flow @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule someSet + * @flow + * @typechecks + */ + +'use strict'; + +import type Set from './Set'; + +/** + * The someSet() method tests whether some elements in the given Set pass the + * test implemented by the provided function. + */ +function someSet<T>(set: Set<T>, callback: (value: T, key: T, set: Set<T>) => boolean, context?: any): boolean { + var iterator = set.entries(); + var current = iterator.next(); + while (!current.done) { + var entry = current.value; + if (callback.call(context, entry[1], entry[0], set)) { + return true; + } + current = iterator.next(); + } + return false; +} + +module.exports = someSet;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/sprintf.js b/node_modules/fbjs/lib/sprintf.js new file mode 100644 index 000000000..98a65c61a --- /dev/null +++ b/node_modules/fbjs/lib/sprintf.js @@ -0,0 +1,34 @@ +"use strict"; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @typechecks + */ + +/** + * Simple function for formatting strings. + * + * Replaces placeholders with values passed as extra arguments + * + * @param {string} format the base string + * @param ...args the values to insert + * @return {string} the replaced string + */ +function sprintf(format) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var index = 0; + return format.replace(/%s/g, function (match) { + return args[index++]; + }); +} + +module.exports = sprintf;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/sprintf.js.flow b/node_modules/fbjs/lib/sprintf.js.flow new file mode 100644 index 000000000..06d097c83 --- /dev/null +++ b/node_modules/fbjs/lib/sprintf.js.flow @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule sprintf + * @typechecks + */ + +/** + * Simple function for formatting strings. + * + * Replaces placeholders with values passed as extra arguments + * + * @param {string} format the base string + * @param ...args the values to insert + * @return {string} the replaced string + */ +function sprintf(format, ...args) { + let index = 0; + return format.replace(/%s/g, match => args[index++]); +} + +module.exports = sprintf;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/warning.js b/node_modules/fbjs/lib/warning.js new file mode 100644 index 000000000..502bb610d --- /dev/null +++ b/node_modules/fbjs/lib/warning.js @@ -0,0 +1,66 @@ +/** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +'use strict'; + +var emptyFunction = require('./emptyFunction'); + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = emptyFunction; + +if (process.env.NODE_ENV !== 'production') { + (function () { + var printWarning = function printWarning(format) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var argIndex = 0; + var message = 'Warning: ' + format.replace(/%s/g, function () { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; + + warning = function warning(condition, format) { + if (format === undefined) { + throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); + } + + if (format.indexOf('Failed Composite propType: ') === 0) { + return; // Ignore CompositeComponent proptype check. + } + + if (!condition) { + for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + args[_key2 - 2] = arguments[_key2]; + } + + printWarning.apply(undefined, [format].concat(args)); + } + }; + })(); +} + +module.exports = warning;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/warning.js.flow b/node_modules/fbjs/lib/warning.js.flow new file mode 100644 index 000000000..a42d54bf6 --- /dev/null +++ b/node_modules/fbjs/lib/warning.js.flow @@ -0,0 +1,55 @@ +/** + * Copyright 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule warning + */ + +'use strict'; + +var emptyFunction = require('./emptyFunction'); + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = emptyFunction; + +if (__DEV__) { + function printWarning(format, ...args) { + var argIndex = 0; + var message = 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + } + + warning = function (condition, format, ...args) { + if (format === undefined) { + throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); + } + + if (format.indexOf('Failed Composite propType: ') === 0) { + return; // Ignore CompositeComponent proptype check. + } + + if (!condition) { + printWarning(format, ...args); + } + }; +} + +module.exports = warning;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/xhrSimpleDataSerializer.js b/node_modules/fbjs/lib/xhrSimpleDataSerializer.js new file mode 100644 index 000000000..0ca8f578b --- /dev/null +++ b/node_modules/fbjs/lib/xhrSimpleDataSerializer.js @@ -0,0 +1,22 @@ +'use strict'; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + */ + +function xhrSimpleDataSerializer(data) { + var uri = []; + var key; + for (key in data) { + uri.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); + } + return uri.join('&'); +} + +module.exports = xhrSimpleDataSerializer;
\ No newline at end of file diff --git a/node_modules/fbjs/lib/xhrSimpleDataSerializer.js.flow b/node_modules/fbjs/lib/xhrSimpleDataSerializer.js.flow new file mode 100644 index 000000000..d4d381f2a --- /dev/null +++ b/node_modules/fbjs/lib/xhrSimpleDataSerializer.js.flow @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule xhrSimpleDataSerializer + */ + +function xhrSimpleDataSerializer(data) { + var uri = []; + var key; + for (key in data) { + uri.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); + } + return uri.join('&'); +} + +module.exports = xhrSimpleDataSerializer;
\ No newline at end of file |