From de98e0b232509d5f40c135d540a70e415272ff85 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 3 May 2017 15:35:00 +0200 Subject: node_modules --- node_modules/fbjs/lib/CSSCore.js | 121 +++++++ node_modules/fbjs/lib/CSSCore.js.flow | 118 +++++++ node_modules/fbjs/lib/DataTransfer.js | 221 ++++++++++++ node_modules/fbjs/lib/DataTransfer.js.flow | 196 +++++++++++ node_modules/fbjs/lib/Deferred.js | 81 +++++ node_modules/fbjs/lib/Deferred.js.flow | 75 ++++ node_modules/fbjs/lib/ErrorUtils.js | 28 ++ node_modules/fbjs/lib/ErrorUtils.js.flow | 27 ++ node_modules/fbjs/lib/EventListener.js | 83 +++++ node_modules/fbjs/lib/EventListener.js.flow | 82 +++++ node_modules/fbjs/lib/ExecutionEnvironment.js | 35 ++ node_modules/fbjs/lib/ExecutionEnvironment.js.flow | 36 ++ node_modules/fbjs/lib/Keys.js | 36 ++ node_modules/fbjs/lib/Keys.js.flow | 35 ++ node_modules/fbjs/lib/Map.js | 13 + node_modules/fbjs/lib/Map.js.flow | 12 + node_modules/fbjs/lib/PhotosMimeType.js | 28 ++ node_modules/fbjs/lib/PhotosMimeType.js.flow | 28 ++ node_modules/fbjs/lib/Promise.js | 13 + node_modules/fbjs/lib/Promise.js.flow | 12 + node_modules/fbjs/lib/Promise.native.js | 26 ++ node_modules/fbjs/lib/Promise.native.js.flow | 26 ++ node_modules/fbjs/lib/PromiseMap.js | 59 ++++ node_modules/fbjs/lib/PromiseMap.js.flow | 55 +++ node_modules/fbjs/lib/Scroll.js | 85 +++++ node_modules/fbjs/lib/Scroll.js.flow | 84 +++++ node_modules/fbjs/lib/Set.js | 13 + node_modules/fbjs/lib/Set.js.flow | 12 + node_modules/fbjs/lib/Style.js | 64 ++++ node_modules/fbjs/lib/Style.js.flow | 63 ++++ node_modules/fbjs/lib/TokenizeUtil.js | 37 ++ node_modules/fbjs/lib/TokenizeUtil.js.flow | 36 ++ node_modules/fbjs/lib/TouchEventUtils.js | 34 ++ node_modules/fbjs/lib/TouchEventUtils.js.flow | 33 ++ node_modules/fbjs/lib/URI.js | 30 ++ node_modules/fbjs/lib/URI.js.flow | 27 ++ node_modules/fbjs/lib/UnicodeBidi.js | 156 +++++++++ node_modules/fbjs/lib/UnicodeBidi.js.flow | 159 +++++++++ node_modules/fbjs/lib/UnicodeBidiDirection.js | 108 ++++++ node_modules/fbjs/lib/UnicodeBidiDirection.js.flow | 112 ++++++ node_modules/fbjs/lib/UnicodeBidiService.js | 100 ++++++ node_modules/fbjs/lib/UnicodeBidiService.js.flow | 97 ++++++ node_modules/fbjs/lib/UnicodeCJK.js | 174 ++++++++++ node_modules/fbjs/lib/UnicodeCJK.js.flow | 175 ++++++++++ node_modules/fbjs/lib/UnicodeHangulKorean.js | 137 ++++++++ node_modules/fbjs/lib/UnicodeHangulKorean.js.flow | 138 ++++++++ node_modules/fbjs/lib/UnicodeUtils.js | 214 ++++++++++++ node_modules/fbjs/lib/UnicodeUtils.js.flow | 215 ++++++++++++ node_modules/fbjs/lib/UnicodeUtilsExtra.js | 229 ++++++++++++ node_modules/fbjs/lib/UnicodeUtilsExtra.js.flow | 186 ++++++++++ node_modules/fbjs/lib/UserAgent.js | 241 +++++++++++++ node_modules/fbjs/lib/UserAgent.js.flow | 238 +++++++++++++ node_modules/fbjs/lib/UserAgentData.js | 82 +++++ node_modules/fbjs/lib/UserAgentData.js.flow | 83 +++++ node_modules/fbjs/lib/VersionRange.js | 382 +++++++++++++++++++++ node_modules/fbjs/lib/VersionRange.js.flow | 373 ++++++++++++++++++++ node_modules/fbjs/lib/__mocks__/ErrorUtils.js | 22 ++ node_modules/fbjs/lib/__mocks__/base62.js | 12 + node_modules/fbjs/lib/__mocks__/crc32.js | 12 + node_modules/fbjs/lib/__mocks__/fetch.js | 28 ++ .../fbjs/lib/__mocks__/fetchWithRetries.js | 33 ++ node_modules/fbjs/lib/__mocks__/nullthrows.js | 14 + .../fbjs/lib/_shouldPolyfillES6Collection.js | 41 +++ .../fbjs/lib/_shouldPolyfillES6Collection.js.flow | 40 +++ node_modules/fbjs/lib/areEqual.js | 108 ++++++ node_modules/fbjs/lib/areEqual.js.flow | 107 ++++++ node_modules/fbjs/lib/base62.js | 28 ++ node_modules/fbjs/lib/base62.js.flow | 29 ++ node_modules/fbjs/lib/camelize.js | 31 ++ node_modules/fbjs/lib/camelize.js.flow | 30 ++ node_modules/fbjs/lib/camelizeStyleName.js | 39 +++ node_modules/fbjs/lib/camelizeStyleName.js.flow | 40 +++ node_modules/fbjs/lib/compactArray.js | 27 ++ node_modules/fbjs/lib/compactArray.js.flow | 28 ++ node_modules/fbjs/lib/concatAllArray.js | 35 ++ node_modules/fbjs/lib/concatAllArray.js.flow | 34 ++ node_modules/fbjs/lib/containsNode.js | 39 +++ node_modules/fbjs/lib/containsNode.js.flow | 38 ++ node_modules/fbjs/lib/countDistinct.js | 53 +++ node_modules/fbjs/lib/countDistinct.js.flow | 33 ++ node_modules/fbjs/lib/crc32.js | 29 ++ node_modules/fbjs/lib/crc32.js.flow | 28 ++ node_modules/fbjs/lib/createArrayFromMixed.js | 126 +++++++ node_modules/fbjs/lib/createArrayFromMixed.js.flow | 125 +++++++ node_modules/fbjs/lib/createNodesFromMarkup.js | 83 +++++ .../fbjs/lib/createNodesFromMarkup.js.flow | 82 +++++ node_modules/fbjs/lib/cx.js | 41 +++ node_modules/fbjs/lib/cx.js.flow | 38 ++ node_modules/fbjs/lib/distinctArray.js | 24 ++ node_modules/fbjs/lib/distinctArray.js.flow | 23 ++ node_modules/fbjs/lib/emptyFunction.js | 38 ++ node_modules/fbjs/lib/emptyFunction.js.flow | 37 ++ node_modules/fbjs/lib/emptyObject.js | 19 + node_modules/fbjs/lib/emptyObject.js.flow | 20 ++ node_modules/fbjs/lib/enumerate.js | 307 +++++++++++++++++ node_modules/fbjs/lib/enumerate.js.flow | 265 ++++++++++++++ node_modules/fbjs/lib/equalsIterable.js | 66 ++++ node_modules/fbjs/lib/equalsIterable.js.flow | 67 ++++ node_modules/fbjs/lib/equalsSet.js | 29 ++ node_modules/fbjs/lib/equalsSet.js.flow | 30 ++ node_modules/fbjs/lib/everyObject.js | 46 +++ node_modules/fbjs/lib/everyObject.js.flow | 47 +++ node_modules/fbjs/lib/everySet.js | 32 ++ node_modules/fbjs/lib/everySet.js.flow | 35 ++ node_modules/fbjs/lib/fetch.js | 21 ++ node_modules/fbjs/lib/fetch.js.flow | 22 ++ node_modules/fbjs/lib/fetchWithRetries.js | 113 ++++++ node_modules/fbjs/lib/fetchWithRetries.js.flow | 117 +++++++ node_modules/fbjs/lib/filterObject.js | 51 +++ node_modules/fbjs/lib/filterObject.js.flow | 52 +++ node_modules/fbjs/lib/flatMapArray.js | 37 ++ node_modules/fbjs/lib/flatMapArray.js.flow | 36 ++ node_modules/fbjs/lib/flattenArray.js | 48 +++ node_modules/fbjs/lib/flattenArray.js.flow | 47 +++ node_modules/fbjs/lib/focusNode.js | 26 ++ node_modules/fbjs/lib/focusNode.js.flow | 27 ++ node_modules/fbjs/lib/forEachObject.js | 42 +++ node_modules/fbjs/lib/forEachObject.js.flow | 43 +++ node_modules/fbjs/lib/getActiveElement.js | 38 ++ node_modules/fbjs/lib/getActiveElement.js.flow | 37 ++ node_modules/fbjs/lib/getDocumentScrollElement.js | 30 ++ .../fbjs/lib/getDocumentScrollElement.js.flow | 31 ++ node_modules/fbjs/lib/getElementPosition.js | 33 ++ node_modules/fbjs/lib/getElementPosition.js.flow | 32 ++ node_modules/fbjs/lib/getElementRect.js | 50 +++ node_modules/fbjs/lib/getElementRect.js.flow | 49 +++ node_modules/fbjs/lib/getMarkupWrap.js | 94 +++++ node_modules/fbjs/lib/getMarkupWrap.js.flow | 93 +++++ node_modules/fbjs/lib/getScrollPosition.js | 47 +++ node_modules/fbjs/lib/getScrollPosition.js.flow | 48 +++ node_modules/fbjs/lib/getStyleProperty.js | 53 +++ node_modules/fbjs/lib/getStyleProperty.js.flow | 52 +++ .../fbjs/lib/getUnboundedScrollPosition.js | 38 ++ .../fbjs/lib/getUnboundedScrollPosition.js.flow | 39 +++ node_modules/fbjs/lib/getViewportDimensions.js | 59 ++++ .../fbjs/lib/getViewportDimensions.js.flow | 62 ++++ node_modules/fbjs/lib/groupArray.js | 36 ++ node_modules/fbjs/lib/groupArray.js.flow | 37 ++ node_modules/fbjs/lib/hyphenate.js | 32 ++ node_modules/fbjs/lib/hyphenate.js.flow | 31 ++ node_modules/fbjs/lib/hyphenateStyleName.js | 38 ++ node_modules/fbjs/lib/hyphenateStyleName.js.flow | 39 +++ node_modules/fbjs/lib/invariant.js | 55 +++ node_modules/fbjs/lib/invariant.js.flow | 56 +++ node_modules/fbjs/lib/isEmpty.js | 45 +++ node_modules/fbjs/lib/isEmpty.js.flow | 46 +++ node_modules/fbjs/lib/isNode.js | 24 ++ node_modules/fbjs/lib/isNode.js.flow | 23 ++ node_modules/fbjs/lib/isTextNode.js | 24 ++ node_modules/fbjs/lib/isTextNode.js.flow | 23 ++ node_modules/fbjs/lib/joinClasses.js | 39 +++ node_modules/fbjs/lib/joinClasses.js.flow | 40 +++ node_modules/fbjs/lib/keyMirror.js | 47 +++ node_modules/fbjs/lib/keyMirror.js.flow | 48 +++ node_modules/fbjs/lib/keyMirrorRecursive.js | 69 ++++ node_modules/fbjs/lib/keyMirrorRecursive.js.flow | 70 ++++ node_modules/fbjs/lib/keyOf.js | 34 ++ node_modules/fbjs/lib/keyOf.js.flow | 33 ++ node_modules/fbjs/lib/mapObject.js | 50 +++ node_modules/fbjs/lib/mapObject.js.flow | 51 +++ node_modules/fbjs/lib/maxBy.js | 32 ++ node_modules/fbjs/lib/maxBy.js.flow | 27 ++ node_modules/fbjs/lib/memoizeStringOnly.js | 29 ++ node_modules/fbjs/lib/memoizeStringOnly.js.flow | 30 ++ node_modules/fbjs/lib/minBy.js | 61 ++++ node_modules/fbjs/lib/minBy.js.flow | 37 ++ node_modules/fbjs/lib/monitorCodeUse.js | 26 ++ node_modules/fbjs/lib/monitorCodeUse.js.flow | 27 ++ .../fbjs/lib/nativeRequestAnimationFrame.js | 15 + .../fbjs/lib/nativeRequestAnimationFrame.js.flow | 14 + node_modules/fbjs/lib/nullthrows.js | 21 ++ node_modules/fbjs/lib/nullthrows.js.flow | 20 ++ node_modules/fbjs/lib/partitionArray.js | 33 ++ node_modules/fbjs/lib/partitionArray.js.flow | 32 ++ node_modules/fbjs/lib/partitionObject.js | 30 ++ node_modules/fbjs/lib/partitionObject.js.flow | 31 ++ node_modules/fbjs/lib/partitionObjectByKey.js | 24 ++ node_modules/fbjs/lib/partitionObjectByKey.js.flow | 23 ++ node_modules/fbjs/lib/performance.js | 22 ++ node_modules/fbjs/lib/performance.js.flow | 23 ++ node_modules/fbjs/lib/performanceNow.js | 33 ++ node_modules/fbjs/lib/performanceNow.js.flow | 28 ++ node_modules/fbjs/lib/removeFromArray.js | 25 ++ node_modules/fbjs/lib/removeFromArray.js.flow | 24 ++ node_modules/fbjs/lib/requestAnimationFrame.js | 30 ++ .../fbjs/lib/requestAnimationFrame.js.flow | 29 ++ node_modules/fbjs/lib/resolveImmediate.js | 31 ++ node_modules/fbjs/lib/resolveImmediate.js.flow | 28 ++ node_modules/fbjs/lib/setImmediate.js | 17 + node_modules/fbjs/lib/setImmediate.js.flow | 18 + node_modules/fbjs/lib/shallowEqual.js | 67 ++++ node_modules/fbjs/lib/shallowEqual.js.flow | 68 ++++ node_modules/fbjs/lib/someObject.js | 46 +++ node_modules/fbjs/lib/someObject.js.flow | 47 +++ node_modules/fbjs/lib/someSet.js | 32 ++ node_modules/fbjs/lib/someSet.js.flow | 35 ++ node_modules/fbjs/lib/sprintf.js | 34 ++ node_modules/fbjs/lib/sprintf.js.flow | 27 ++ node_modules/fbjs/lib/warning.js | 66 ++++ node_modules/fbjs/lib/warning.js.flow | 55 +++ node_modules/fbjs/lib/xhrSimpleDataSerializer.js | 22 ++ .../fbjs/lib/xhrSimpleDataSerializer.js.flow | 21 ++ 202 files changed, 11998 insertions(+) create mode 100644 node_modules/fbjs/lib/CSSCore.js create mode 100644 node_modules/fbjs/lib/CSSCore.js.flow create mode 100644 node_modules/fbjs/lib/DataTransfer.js create mode 100644 node_modules/fbjs/lib/DataTransfer.js.flow create mode 100644 node_modules/fbjs/lib/Deferred.js create mode 100644 node_modules/fbjs/lib/Deferred.js.flow create mode 100644 node_modules/fbjs/lib/ErrorUtils.js create mode 100644 node_modules/fbjs/lib/ErrorUtils.js.flow create mode 100644 node_modules/fbjs/lib/EventListener.js create mode 100644 node_modules/fbjs/lib/EventListener.js.flow create mode 100644 node_modules/fbjs/lib/ExecutionEnvironment.js create mode 100644 node_modules/fbjs/lib/ExecutionEnvironment.js.flow create mode 100644 node_modules/fbjs/lib/Keys.js create mode 100644 node_modules/fbjs/lib/Keys.js.flow create mode 100644 node_modules/fbjs/lib/Map.js create mode 100644 node_modules/fbjs/lib/Map.js.flow create mode 100644 node_modules/fbjs/lib/PhotosMimeType.js create mode 100644 node_modules/fbjs/lib/PhotosMimeType.js.flow create mode 100644 node_modules/fbjs/lib/Promise.js create mode 100644 node_modules/fbjs/lib/Promise.js.flow create mode 100644 node_modules/fbjs/lib/Promise.native.js create mode 100644 node_modules/fbjs/lib/Promise.native.js.flow create mode 100644 node_modules/fbjs/lib/PromiseMap.js create mode 100644 node_modules/fbjs/lib/PromiseMap.js.flow create mode 100644 node_modules/fbjs/lib/Scroll.js create mode 100644 node_modules/fbjs/lib/Scroll.js.flow create mode 100644 node_modules/fbjs/lib/Set.js create mode 100644 node_modules/fbjs/lib/Set.js.flow create mode 100644 node_modules/fbjs/lib/Style.js create mode 100644 node_modules/fbjs/lib/Style.js.flow create mode 100644 node_modules/fbjs/lib/TokenizeUtil.js create mode 100644 node_modules/fbjs/lib/TokenizeUtil.js.flow create mode 100644 node_modules/fbjs/lib/TouchEventUtils.js create mode 100644 node_modules/fbjs/lib/TouchEventUtils.js.flow create mode 100644 node_modules/fbjs/lib/URI.js create mode 100644 node_modules/fbjs/lib/URI.js.flow create mode 100644 node_modules/fbjs/lib/UnicodeBidi.js create mode 100644 node_modules/fbjs/lib/UnicodeBidi.js.flow create mode 100644 node_modules/fbjs/lib/UnicodeBidiDirection.js create mode 100644 node_modules/fbjs/lib/UnicodeBidiDirection.js.flow create mode 100644 node_modules/fbjs/lib/UnicodeBidiService.js create mode 100644 node_modules/fbjs/lib/UnicodeBidiService.js.flow create mode 100644 node_modules/fbjs/lib/UnicodeCJK.js create mode 100644 node_modules/fbjs/lib/UnicodeCJK.js.flow create mode 100644 node_modules/fbjs/lib/UnicodeHangulKorean.js create mode 100644 node_modules/fbjs/lib/UnicodeHangulKorean.js.flow create mode 100644 node_modules/fbjs/lib/UnicodeUtils.js create mode 100644 node_modules/fbjs/lib/UnicodeUtils.js.flow create mode 100644 node_modules/fbjs/lib/UnicodeUtilsExtra.js create mode 100644 node_modules/fbjs/lib/UnicodeUtilsExtra.js.flow create mode 100644 node_modules/fbjs/lib/UserAgent.js create mode 100644 node_modules/fbjs/lib/UserAgent.js.flow create mode 100644 node_modules/fbjs/lib/UserAgentData.js create mode 100644 node_modules/fbjs/lib/UserAgentData.js.flow create mode 100644 node_modules/fbjs/lib/VersionRange.js create mode 100644 node_modules/fbjs/lib/VersionRange.js.flow create mode 100644 node_modules/fbjs/lib/__mocks__/ErrorUtils.js create mode 100644 node_modules/fbjs/lib/__mocks__/base62.js create mode 100644 node_modules/fbjs/lib/__mocks__/crc32.js create mode 100644 node_modules/fbjs/lib/__mocks__/fetch.js create mode 100644 node_modules/fbjs/lib/__mocks__/fetchWithRetries.js create mode 100644 node_modules/fbjs/lib/__mocks__/nullthrows.js create mode 100644 node_modules/fbjs/lib/_shouldPolyfillES6Collection.js create mode 100644 node_modules/fbjs/lib/_shouldPolyfillES6Collection.js.flow create mode 100644 node_modules/fbjs/lib/areEqual.js create mode 100644 node_modules/fbjs/lib/areEqual.js.flow create mode 100644 node_modules/fbjs/lib/base62.js create mode 100644 node_modules/fbjs/lib/base62.js.flow create mode 100644 node_modules/fbjs/lib/camelize.js create mode 100644 node_modules/fbjs/lib/camelize.js.flow create mode 100644 node_modules/fbjs/lib/camelizeStyleName.js create mode 100644 node_modules/fbjs/lib/camelizeStyleName.js.flow create mode 100644 node_modules/fbjs/lib/compactArray.js create mode 100644 node_modules/fbjs/lib/compactArray.js.flow create mode 100644 node_modules/fbjs/lib/concatAllArray.js create mode 100644 node_modules/fbjs/lib/concatAllArray.js.flow create mode 100644 node_modules/fbjs/lib/containsNode.js create mode 100644 node_modules/fbjs/lib/containsNode.js.flow create mode 100644 node_modules/fbjs/lib/countDistinct.js create mode 100644 node_modules/fbjs/lib/countDistinct.js.flow create mode 100644 node_modules/fbjs/lib/crc32.js create mode 100644 node_modules/fbjs/lib/crc32.js.flow create mode 100644 node_modules/fbjs/lib/createArrayFromMixed.js create mode 100644 node_modules/fbjs/lib/createArrayFromMixed.js.flow create mode 100644 node_modules/fbjs/lib/createNodesFromMarkup.js create mode 100644 node_modules/fbjs/lib/createNodesFromMarkup.js.flow create mode 100644 node_modules/fbjs/lib/cx.js create mode 100644 node_modules/fbjs/lib/cx.js.flow create mode 100644 node_modules/fbjs/lib/distinctArray.js create mode 100644 node_modules/fbjs/lib/distinctArray.js.flow create mode 100644 node_modules/fbjs/lib/emptyFunction.js create mode 100644 node_modules/fbjs/lib/emptyFunction.js.flow create mode 100644 node_modules/fbjs/lib/emptyObject.js create mode 100644 node_modules/fbjs/lib/emptyObject.js.flow create mode 100644 node_modules/fbjs/lib/enumerate.js create mode 100644 node_modules/fbjs/lib/enumerate.js.flow create mode 100644 node_modules/fbjs/lib/equalsIterable.js create mode 100644 node_modules/fbjs/lib/equalsIterable.js.flow create mode 100644 node_modules/fbjs/lib/equalsSet.js create mode 100644 node_modules/fbjs/lib/equalsSet.js.flow create mode 100644 node_modules/fbjs/lib/everyObject.js create mode 100644 node_modules/fbjs/lib/everyObject.js.flow create mode 100644 node_modules/fbjs/lib/everySet.js create mode 100644 node_modules/fbjs/lib/everySet.js.flow create mode 100644 node_modules/fbjs/lib/fetch.js create mode 100644 node_modules/fbjs/lib/fetch.js.flow create mode 100644 node_modules/fbjs/lib/fetchWithRetries.js create mode 100644 node_modules/fbjs/lib/fetchWithRetries.js.flow create mode 100644 node_modules/fbjs/lib/filterObject.js create mode 100644 node_modules/fbjs/lib/filterObject.js.flow create mode 100644 node_modules/fbjs/lib/flatMapArray.js create mode 100644 node_modules/fbjs/lib/flatMapArray.js.flow create mode 100644 node_modules/fbjs/lib/flattenArray.js create mode 100644 node_modules/fbjs/lib/flattenArray.js.flow create mode 100644 node_modules/fbjs/lib/focusNode.js create mode 100644 node_modules/fbjs/lib/focusNode.js.flow create mode 100644 node_modules/fbjs/lib/forEachObject.js create mode 100644 node_modules/fbjs/lib/forEachObject.js.flow create mode 100644 node_modules/fbjs/lib/getActiveElement.js create mode 100644 node_modules/fbjs/lib/getActiveElement.js.flow create mode 100644 node_modules/fbjs/lib/getDocumentScrollElement.js create mode 100644 node_modules/fbjs/lib/getDocumentScrollElement.js.flow create mode 100644 node_modules/fbjs/lib/getElementPosition.js create mode 100644 node_modules/fbjs/lib/getElementPosition.js.flow create mode 100644 node_modules/fbjs/lib/getElementRect.js create mode 100644 node_modules/fbjs/lib/getElementRect.js.flow create mode 100644 node_modules/fbjs/lib/getMarkupWrap.js create mode 100644 node_modules/fbjs/lib/getMarkupWrap.js.flow create mode 100644 node_modules/fbjs/lib/getScrollPosition.js create mode 100644 node_modules/fbjs/lib/getScrollPosition.js.flow create mode 100644 node_modules/fbjs/lib/getStyleProperty.js create mode 100644 node_modules/fbjs/lib/getStyleProperty.js.flow create mode 100644 node_modules/fbjs/lib/getUnboundedScrollPosition.js create mode 100644 node_modules/fbjs/lib/getUnboundedScrollPosition.js.flow create mode 100644 node_modules/fbjs/lib/getViewportDimensions.js create mode 100644 node_modules/fbjs/lib/getViewportDimensions.js.flow create mode 100644 node_modules/fbjs/lib/groupArray.js create mode 100644 node_modules/fbjs/lib/groupArray.js.flow create mode 100644 node_modules/fbjs/lib/hyphenate.js create mode 100644 node_modules/fbjs/lib/hyphenate.js.flow create mode 100644 node_modules/fbjs/lib/hyphenateStyleName.js create mode 100644 node_modules/fbjs/lib/hyphenateStyleName.js.flow create mode 100644 node_modules/fbjs/lib/invariant.js create mode 100644 node_modules/fbjs/lib/invariant.js.flow create mode 100644 node_modules/fbjs/lib/isEmpty.js create mode 100644 node_modules/fbjs/lib/isEmpty.js.flow create mode 100644 node_modules/fbjs/lib/isNode.js create mode 100644 node_modules/fbjs/lib/isNode.js.flow create mode 100644 node_modules/fbjs/lib/isTextNode.js create mode 100644 node_modules/fbjs/lib/isTextNode.js.flow create mode 100644 node_modules/fbjs/lib/joinClasses.js create mode 100644 node_modules/fbjs/lib/joinClasses.js.flow create mode 100644 node_modules/fbjs/lib/keyMirror.js create mode 100644 node_modules/fbjs/lib/keyMirror.js.flow create mode 100644 node_modules/fbjs/lib/keyMirrorRecursive.js create mode 100644 node_modules/fbjs/lib/keyMirrorRecursive.js.flow create mode 100644 node_modules/fbjs/lib/keyOf.js create mode 100644 node_modules/fbjs/lib/keyOf.js.flow create mode 100644 node_modules/fbjs/lib/mapObject.js create mode 100644 node_modules/fbjs/lib/mapObject.js.flow create mode 100644 node_modules/fbjs/lib/maxBy.js create mode 100644 node_modules/fbjs/lib/maxBy.js.flow create mode 100644 node_modules/fbjs/lib/memoizeStringOnly.js create mode 100644 node_modules/fbjs/lib/memoizeStringOnly.js.flow create mode 100644 node_modules/fbjs/lib/minBy.js create mode 100644 node_modules/fbjs/lib/minBy.js.flow create mode 100644 node_modules/fbjs/lib/monitorCodeUse.js create mode 100644 node_modules/fbjs/lib/monitorCodeUse.js.flow create mode 100644 node_modules/fbjs/lib/nativeRequestAnimationFrame.js create mode 100644 node_modules/fbjs/lib/nativeRequestAnimationFrame.js.flow create mode 100644 node_modules/fbjs/lib/nullthrows.js create mode 100644 node_modules/fbjs/lib/nullthrows.js.flow create mode 100644 node_modules/fbjs/lib/partitionArray.js create mode 100644 node_modules/fbjs/lib/partitionArray.js.flow create mode 100644 node_modules/fbjs/lib/partitionObject.js create mode 100644 node_modules/fbjs/lib/partitionObject.js.flow create mode 100644 node_modules/fbjs/lib/partitionObjectByKey.js create mode 100644 node_modules/fbjs/lib/partitionObjectByKey.js.flow create mode 100644 node_modules/fbjs/lib/performance.js create mode 100644 node_modules/fbjs/lib/performance.js.flow create mode 100644 node_modules/fbjs/lib/performanceNow.js create mode 100644 node_modules/fbjs/lib/performanceNow.js.flow create mode 100644 node_modules/fbjs/lib/removeFromArray.js create mode 100644 node_modules/fbjs/lib/removeFromArray.js.flow create mode 100644 node_modules/fbjs/lib/requestAnimationFrame.js create mode 100644 node_modules/fbjs/lib/requestAnimationFrame.js.flow create mode 100644 node_modules/fbjs/lib/resolveImmediate.js create mode 100644 node_modules/fbjs/lib/resolveImmediate.js.flow create mode 100644 node_modules/fbjs/lib/setImmediate.js create mode 100644 node_modules/fbjs/lib/setImmediate.js.flow create mode 100644 node_modules/fbjs/lib/shallowEqual.js create mode 100644 node_modules/fbjs/lib/shallowEqual.js.flow create mode 100644 node_modules/fbjs/lib/someObject.js create mode 100644 node_modules/fbjs/lib/someObject.js.flow create mode 100644 node_modules/fbjs/lib/someSet.js create mode 100644 node_modules/fbjs/lib/someSet.js.flow create mode 100644 node_modules/fbjs/lib/sprintf.js create mode 100644 node_modules/fbjs/lib/sprintf.js.flow create mode 100644 node_modules/fbjs/lib/warning.js create mode 100644 node_modules/fbjs/lib/warning.js.flow create mode 100644 node_modules/fbjs/lib/xhrSimpleDataSerializer.js create mode 100644 node_modules/fbjs/lib/xhrSimpleDataSerializer.js.flow (limited to 'node_modules/fbjs/lib') 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 { + _settled: boolean; + _promise: Promise; + _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 { + 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 { + return Promise.prototype.catch.apply(this._promise, arguments); + } + + then(): Promise { + 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 { + _deferred: { [key: string]: Deferred }; + + constructor() { + this._deferred = {}; + } + + get(key: string): Promise { + 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 }, key: string): Deferred { + 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. + * + */ + +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. + * + */ + +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} 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} 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} 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} 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} a + * @param {array} b + * @returns {boolean} + */ +function checkLessThan(a, b) { + return compareComponents(a, b) === -1; +} + +/** + * Checks whether `a` is less than or equal to `b`. + * + * @param {array} a + * @param {array} 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} a + * @param {array} b + * @returns {boolean} + */ +function checkEqual(a, b) { + return compareComponents(a, b) === 0; +} + +/** + * Checks whether `a` is greater than or equal to `b`. + * + * @param {array} a + * @param {array} 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} a + * @param {array} 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} a + * @param {array} 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} a + * @param {array} b + * @returns {array>} + */ +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} a + * @param {array} 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 + * = 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} a + * @param {array} b + * @returns {boolean} + */ +function checkLessThan(a, b) { + return compareComponents(a, b) === -1; +} + +/** + * Checks whether `a` is less than or equal to `b`. + * + * @param {array} a + * @param {array} 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} a + * @param {array} b + * @returns {boolean} + */ +function checkEqual(a, b) { + return compareComponents(a, b) === 0; +} + +/** + * Checks whether `a` is greater than or equal to `b`. + * + * @param {array} a + * @param {array} 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} a + * @param {array} 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} a + * @param {array} 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} a + * @param {array} b + * @returns {array>} + */ +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} a + * @param {array} 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 + * = 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, bStack: Array): 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(array: Array): 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/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(iter: Iterable, 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 + *