diff --git a/.eslintignore b/.eslintignore index 2dfa9fb8..ff2e6526 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ flow-typed/** coverage/** -vendor/** +src/vendor/** fixtures/** diff --git a/fixtures/example-app/yarn.lock b/fixtures/example-app/yarn.lock index b6cb2d97..e94b79f2 100644 --- a/fixtures/example-app/yarn.lock +++ b/fixtures/example-app/yarn.lock @@ -2899,8 +2899,9 @@ haul@../..: node-emoji "^1.8.1" node-fetch "^2.0.0" open-in-editor "^2.2.0" - opn "^4.0.2" + opn "^5.3.0" ora "^1.2.0" + platform-select "^1.1.0" react "^16.2.0" react-deep-force-update "^2.0.1" react-hot-loader "3.0.0-beta.7" @@ -2912,9 +2913,8 @@ haul@../..: source-map "^0.5.6" strip-ansi "^3.0.1" thread-loader "^1.1.1" - webpack "^4.1.0" - webpack-dev-middleware "^1.12.0" - webpack-hot-middleware "^2.19.1" + webpack "^4.6.0" + webpack-hot-middleware "^2.22.1" ws "^2.2.2" xpipe "^1.0.5" @@ -3314,6 +3314,10 @@ is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" +is-wsl@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" + isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -4249,7 +4253,7 @@ mime@1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6" -mime@^1.3.4, mime@^1.4.1: +mime@^1.3.4: version "1.5.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.5.0.tgz#59c20e03ae116089edeb7d3b34a6788c5b3cccea" @@ -4641,12 +4645,11 @@ opn@^3.0.2: dependencies: object-assign "^4.0.1" -opn@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/opn/-/opn-4.0.2.tgz#7abc22e644dff63b0a96d5ab7f2790c0f01abc95" +opn@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/opn/-/opn-5.3.0.tgz#64871565c863875f052cfdf53d3e3cb5adb53b1c" dependencies: - object-assign "^4.0.1" - pinkie-promise "^2.0.0" + is-wsl "^1.1.0" optimist@^0.6.1: version "0.6.1" @@ -4874,6 +4877,10 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" +platform-select@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/platform-select/-/platform-select-1.1.2.tgz#d5b5d67f7b7a4d25f70c72ab77e21cfaa63f720c" + plist@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/plist/-/plist-2.0.1.tgz#0a32ca9481b1c364e92e18dc55c876de9d01da8b" @@ -5064,14 +5071,14 @@ randomfill@^1.0.3: randombytes "^2.0.5" safe-buffer "^5.1.0" -range-parser@^1.0.3, range-parser@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" - range-parser@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.0.3.tgz#6872823535c692e2c2a0103826afd82c2e0ff175" +range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + raw-body@2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" @@ -6205,10 +6212,6 @@ time-stamp@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" -time-stamp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-2.0.0.tgz#95c6a44530e15ba8d6f4a3ecb8c3a3fac46da357" - timers-browserify@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.4.tgz#96ca53f4b794a5e7c0e1bd7cc88a372298fa01e6" @@ -6338,8 +6341,8 @@ uglify-to-browserify@~1.0.0: resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" uglifyjs-webpack-plugin@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.4.tgz#5eec941b2e9b8538be0a20fc6eda25b14c7c1043" + version "1.2.5" + resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz#2ef8387c8f1a903ec5e44fa36f9f3cbdcea67641" dependencies: cacache "^10.0.4" find-cache-dir "^1.0.0" @@ -6538,19 +6541,9 @@ webidl-conversions@^4.0.1, webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" -webpack-dev-middleware@^1.12.0: - version "1.12.1" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.12.1.tgz#338be3ca930973be1c2ce07d84d275e997e1a25a" - dependencies: - memory-fs "~0.4.1" - mime "^1.4.1" - path-is-absolute "^1.0.0" - range-parser "^1.0.3" - time-stamp "^2.0.0" - -webpack-hot-middleware@^2.19.1: - version "2.20.0" - resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.20.0.tgz#cb896d837758b6408fe0afeeafdc0e5316b15319" +webpack-hot-middleware@^2.22.1: + version "2.22.1" + resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.22.1.tgz#2ff865bfebc8e9937bd1619f0f48d6ab601bfea0" dependencies: ansi-html "0.0.7" html-entities "^1.2.0" @@ -6571,7 +6564,7 @@ webpack-sources@^1.1.0: source-list-map "^2.0.0" source-map "~0.6.1" -webpack@^4.1.0: +webpack@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.6.0.tgz#363eafa733710eb0ed28c512b2b9b9f5fb01e69b" dependencies: diff --git a/package.json b/package.json index 654be4a6..5e62ac2d 100644 --- a/package.json +++ b/package.json @@ -77,9 +77,8 @@ "source-map": "^0.5.6", "strip-ansi": "^3.0.1", "thread-loader": "^1.1.5", - "webpack": "^4.1.0", - "webpack-dev-middleware": "^1.12.0", - "webpack-hot-middleware": "^2.19.1", + "webpack": "^4.6.0", + "webpack-hot-middleware": "^2.22.1", "ws": "^2.2.2", "xpipe": "^1.0.5" }, diff --git a/src/compiler/TaskQueue.js b/src/compiler/TaskQueue.js index 9bb00477..94a3ecee 100644 --- a/src/compiler/TaskQueue.js +++ b/src/compiler/TaskQueue.js @@ -1,7 +1,7 @@ /** * Copyright 2017-present, Callstack. * All rights reserved. - * + * * @flow */ diff --git a/src/utils/__tests__/__snapshots__/getConfig.test.js.snap b/src/utils/__tests__/__snapshots__/getConfig.test.js.snap index 31ea78af..be1a2930 100644 --- a/src/utils/__tests__/__snapshots__/getConfig.test.js.snap +++ b/src/utils/__tests__/__snapshots__/getConfig.test.js.snap @@ -5,7 +5,7 @@ exports[`creates config: diff ios/android config 1`] = ` - First value + Second value -@@ -34,25 +34,25 @@ +@@ -44,25 +44,25 @@ \\"test\\": /\\\\.(aac|aiff|bmp|caf|gif|html|jpeg|jpg|m4a|m4v|mov|mp3|mp4|mpeg|mpg|obj|otf|pdf|png|psd|svg|ttf|wav|webm|webp)$/, \\"use\\": Object { \\"loader\\": \\"<>/loaders/assetLoader.js\\", @@ -34,7 +34,7 @@ exports[`creates config: diff ios/android config 1`] = ` }, \\"plugins\\": Array [ CaseSensitivePathsPlugin { -@@ -311,11 +311,11 @@ +@@ -127,11 +127,11 @@ \\"resolve\\": Object { \\"alias\\": Object { \\"react-proxy\\": \\"@zamotany/react-proxy\\", @@ -53,6 +53,16 @@ exports[`creates config: ios config 1`] = ` Object { "context": "<>/utils/__tests__/fixtures", "entry": Array [ + "<>/vendor/polyfills/Object.es6.js", + "<>/vendor/polyfills/console.js", + "<>/vendor/polyfills/error-guard.js", + "<>/vendor/polyfills/Number.es6.js", + "<>/vendor/polyfills/String.prototype.es6.js", + "<>/vendor/polyfills/Array.prototype.es6.js", + "<>/vendor/polyfills/Array.es6.js", + "<>/vendor/polyfills/Object.es7.js", + "<>/vendor/polyfills/babelHelpers.js", + "<><>/react-native/Libraries/Core/InitializeCore.js", "<>/utils/polyfillEnvironment.js", "./index.js", ], @@ -157,205 +167,11 @@ Object { //# sourceMappingURL=[url]", }, BannerPlugin { - "banner": " - if (this && !this.self) { this.self = this; }; - /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @polyfill - */ - -/* eslint-disable */ - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex -function findIndex(predicate, context) { - if (this == null) { - throw new TypeError( - 'Array.prototype.findIndex called on null or undefined' - ); - } - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } - var list = Object(this); - var length = list.length >>> 0; - for (var i = 0; i < length; i++) { - if (predicate.call(context, list[i], i, list)) { - return i; - } - } - return -1; -} - -if (!Array.prototype.findIndex) { - Object.defineProperty(Array.prototype, 'findIndex', { - enumerable: false, - writable: true, - configurable: true, - value: findIndex - }); -} - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find -if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, 'find', { - enumerable: false, - writable: true, - configurable: true, - value: function(predicate, context) { - if (this == null) { - throw new TypeError( - 'Array.prototype.find called on null or undefined' - ); - } - var index = findIndex.call(this, predicate, context); - return index === -1 ? undefined : this[index]; - } - }); -} - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes -if (!Array.prototype.includes) { - Object.defineProperty(Array.prototype, 'includes', { - enumerable: false, - writable: true, - configurable: true, - value: function (searchElement) { - var O = Object(this); - var len = parseInt(O.length) || 0; - if (len === 0) { - return false; - } - var n = parseInt(arguments[1]) || 0; - var k; - if (n >= 0) { - k = n; - } else { - k = len + n; - if (k < 0) { - k = 0; - } - } - var currentElement; - while (k < len) { - currentElement = O[k]; - if (searchElement === currentElement || - (searchElement !== searchElement && currentElement !== currentElement)) { - return true; - } - k++; - } - return false; - } - }); -} - - ", + "banner": "if (this && !this.self) { this.self = this; }; +", "options": Object { - "banner": " - if (this && !this.self) { this.self = this; }; - /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @polyfill - */ - -/* eslint-disable */ - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex -function findIndex(predicate, context) { - if (this == null) { - throw new TypeError( - 'Array.prototype.findIndex called on null or undefined' - ); - } - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } - var list = Object(this); - var length = list.length >>> 0; - for (var i = 0; i < length; i++) { - if (predicate.call(context, list[i], i, list)) { - return i; - } - } - return -1; -} - -if (!Array.prototype.findIndex) { - Object.defineProperty(Array.prototype, 'findIndex', { - enumerable: false, - writable: true, - configurable: true, - value: findIndex - }); -} - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find -if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, 'find', { - enumerable: false, - writable: true, - configurable: true, - value: function(predicate, context) { - if (this == null) { - throw new TypeError( - 'Array.prototype.find called on null or undefined' - ); - } - var index = findIndex.call(this, predicate, context); - return index === -1 ? undefined : this[index]; - } - }); -} - -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes -if (!Array.prototype.includes) { - Object.defineProperty(Array.prototype, 'includes', { - enumerable: false, - writable: true, - configurable: true, - value: function (searchElement) { - var O = Object(this); - var len = parseInt(O.length) || 0; - if (len === 0) { - return false; - } - var n = parseInt(arguments[1]) || 0; - var k; - if (n >= 0) { - k = n; - } else { - k = len + n; - if (k < 0) { - k = 0; - } - } - var currentElement; - while (k < len) { - currentElement = O[k]; - if (searchElement === currentElement || - (searchElement !== searchElement && currentElement !== currentElement)) { - return true; - } - k++; - } - return false; - } - }); -} - - ", + "banner": "if (this && !this.self) { this.self = this; }; +", "raw": true, }, }, diff --git a/src/utils/__tests__/__snapshots__/makeReactNativeConfig.test.js.snap b/src/utils/__tests__/__snapshots__/makeReactNativeConfig.test.js.snap index d6dade06..9ac1c52b 100644 --- a/src/utils/__tests__/__snapshots__/makeReactNativeConfig.test.js.snap +++ b/src/utils/__tests__/__snapshots__/makeReactNativeConfig.test.js.snap @@ -5,7 +5,7 @@ exports[`makeReactNativeConfig creates config from defaults: diff ios/android co - First value + Second value -@@ -34,25 +34,25 @@ +@@ -44,25 +44,25 @@ \\"test\\": /\\\\.(aac|aiff|bmp|caf|gif|html|jpeg|jpg|m4a|m4v|mov|mp3|mp4|mpeg|mpg|obj|otf|pdf|png|psd|svg|ttf|wav|webm|webp)$/, \\"use\\": Object { \\"loader\\": \\"<>/loaders/assetLoader.js\\", @@ -34,7 +34,7 @@ exports[`makeReactNativeConfig creates config from defaults: diff ios/android co }, \\"plugins\\": Array [ CaseSensitivePathsPlugin { -@@ -311,11 +311,11 @@ +@@ -127,11 +127,11 @@ \\"resolve\\": Object { \\"alias\\": Object { \\"react-proxy\\": \\"@zamotany/react-proxy\\", diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/Array.es6.js b/src/utils/__tests__/fixtures/node_modules/react-native/Array.es6.js new file mode 100644 index 00000000..8337712e --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/Array.es6.js @@ -0,0 +1 @@ +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/Array.prototype.es6.js b/src/utils/__tests__/fixtures/node_modules/react-native/Array.prototype.es6.js new file mode 100644 index 00000000..8337712e --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/Array.prototype.es6.js @@ -0,0 +1 @@ +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/Libraries/Core/InitializeCore.js b/src/utils/__tests__/fixtures/node_modules/react-native/Libraries/Core/InitializeCore.js new file mode 100644 index 00000000..e69de29b diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/Number.es6.js b/src/utils/__tests__/fixtures/node_modules/react-native/Number.es6.js new file mode 100644 index 00000000..8337712e --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/Number.es6.js @@ -0,0 +1 @@ +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/Object.es6.js b/src/utils/__tests__/fixtures/node_modules/react-native/Object.es6.js new file mode 100644 index 00000000..8337712e --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/Object.es6.js @@ -0,0 +1 @@ +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/Object.es7.js b/src/utils/__tests__/fixtures/node_modules/react-native/Object.es7.js new file mode 100644 index 00000000..4b877637 --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/Object.es7.js @@ -0,0 +1,2 @@ +// +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/String.prototype.es6.js b/src/utils/__tests__/fixtures/node_modules/react-native/String.prototype.es6.js new file mode 100644 index 00000000..4b877637 --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/String.prototype.es6.js @@ -0,0 +1,2 @@ +// +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/babelHelpers.js b/src/utils/__tests__/fixtures/node_modules/react-native/babelHelpers.js new file mode 100644 index 00000000..4b877637 --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/babelHelpers.js @@ -0,0 +1,2 @@ +// +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/console.js b/src/utils/__tests__/fixtures/node_modules/react-native/console.js new file mode 100644 index 00000000..4b877637 --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/console.js @@ -0,0 +1,2 @@ +// +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/error-guard.js b/src/utils/__tests__/fixtures/node_modules/react-native/error-guard.js new file mode 100644 index 00000000..8337712e --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/error-guard.js @@ -0,0 +1 @@ +// diff --git a/src/utils/__tests__/fixtures/node_modules/react-native/rn-get-polyfills.js b/src/utils/__tests__/fixtures/node_modules/react-native/rn-get-polyfills.js new file mode 100644 index 00000000..1e58c708 --- /dev/null +++ b/src/utils/__tests__/fixtures/node_modules/react-native/rn-get-polyfills.js @@ -0,0 +1,11 @@ +module.exports = () => [ + 'node_modules/react-native/Object.es6.js', + 'node_modules/react-native/console.js', + 'node_modules/react-native/error-guard.js', + 'node_modules/react-native/Number.es6.js', + 'node_modules/react-native/String.prototype.es6.js', + 'node_modules/react-native/Array.prototype.es6.js', + 'node_modules/react-native/Array.es6.js', + 'node_modules/react-native/Object.es7.js', + 'node_modules/react-native/babelHelpers.js', +]; diff --git a/src/utils/__tests__/makeReactNativeConfig.test.js b/src/utils/__tests__/makeReactNativeConfig.test.js index de8ad684..3eee9e4f 100644 --- a/src/utils/__tests__/makeReactNativeConfig.test.js +++ b/src/utils/__tests__/makeReactNativeConfig.test.js @@ -62,22 +62,36 @@ describe('makeReactNativeConfig', () => { }); describe('injects polyfill into different entries', () => { - const fakePolyfillPath = 'path/to/polyfill.js'; - test('entry is a string', () => { const userEntry = './src/index.js'; - const generatedEntry = injectPolyfillIntoEntry(userEntry, fakePolyfillPath); + const generatedEntry = injectPolyfillIntoEntry({ + entry: userEntry, + root: path.resolve('src/utils/__tests__/fixtures'), + }); + + if (!Array.isArray(generatedEntry)) { + throw new Error('Entries should be an array'); + } - expect(generatedEntry.length).toBe(2); - expect(generatedEntry[0]).toBe(fakePolyfillPath); + generatedEntry.forEach(entry => { + expect(typeof entry).toBe('string'); + }); }); test('entry is an array', () => { const userEntry = ['./src/index.js', './src/module.js']; - const generatedEntry = injectPolyfillIntoEntry(userEntry, fakePolyfillPath); + const generatedEntry = injectPolyfillIntoEntry({ + entry: userEntry, + root: path.resolve('src/utils/__tests__/fixtures'), + }); - expect(generatedEntry[0]).toBe(fakePolyfillPath); - expect(generatedEntry.length).toBe(3); + if (!Array.isArray(generatedEntry)) { + throw new Error('Entries should be an array'); + } + + generatedEntry.forEach(entry => { + expect(typeof entry).toBe('string'); + }); }); test('entry is an object', () => { @@ -85,18 +99,16 @@ describe('injects polyfill into different entries', () => { entry1: './src/index.js', entry2: ['./src/module.js', './src/vendor.js'], }; - const expectedEntry1 = [fakePolyfillPath, './src/index.js']; - const expectedEntry2 = [ - fakePolyfillPath, - './src/module.js', - './src/vendor.js', - ]; - const generatedEntry = injectPolyfillIntoEntry(userEntry, fakePolyfillPath); + const generatedEntry = injectPolyfillIntoEntry({ + entry: userEntry, + root: path.resolve('src/utils/__tests__/fixtures'), + }); + + Object.entries(generatedEntry).forEach(([key, value]) => { + expect(Object.keys(userEntry).includes(key)).toBeTruthy(); - expect(generatedEntry).toMatchObject({ - entry1: expectedEntry1, - entry2: expectedEntry2, + expect(Array.isArray(value)).toBeTruthy(); }); }); }); diff --git a/src/utils/getPolyfills.js b/src/utils/getPolyfills.js new file mode 100644 index 00000000..468ff657 --- /dev/null +++ b/src/utils/getPolyfills.js @@ -0,0 +1,21 @@ +/** + * Copyright 2017-present, Callstack. + * All rights reserved. + * + * JS polyfills for JSC + * Temporary backport of https://github.com/facebook/react-native/blob/v0.55.3/rn-get-polyfills.js + * + * @flow + */ + +module.exports = () => [ + require.resolve('../vendor/polyfills/Object.es6.js'), + require.resolve('../vendor/polyfills/console.js'), + require.resolve('../vendor/polyfills/error-guard.js'), + require.resolve('../vendor/polyfills/Number.es6.js'), + require.resolve('../vendor/polyfills/String.prototype.es6.js'), + require.resolve('../vendor/polyfills/Array.prototype.es6.js'), + require.resolve('../vendor/polyfills/Array.es6.js'), + require.resolve('../vendor/polyfills/Object.es7.js'), + require.resolve('../vendor/polyfills/babelHelpers.js'), +]; diff --git a/src/utils/makeReactNativeConfig.js b/src/utils/makeReactNativeConfig.js index 9b9124c5..dc2df098 100644 --- a/src/utils/makeReactNativeConfig.js +++ b/src/utils/makeReactNativeConfig.js @@ -14,8 +14,9 @@ const fs = require('fs'); const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const AssetResolver = require('../resolvers/AssetResolver'); const HasteResolver = require('../resolvers/HasteResolver'); -const moduleResolve = require('../utils/resolveModule'); +const moduleResolve = require('./resolveModule'); const getBabelConfig = require('./getBabelConfig'); +const getPolyfills = require('./getPolyfills'); const loggerUtil = require('../logger'); const { DEFAULT_PORT } = require('../constants'); @@ -148,17 +149,7 @@ const getDefaultConfig = ({ filename: '[file].map', }), new webpack.BannerPlugin({ - banner: ` - if (this && !this.self) { this.self = this; }; - ${fs - .readFileSync( - path.join( - __dirname, - '../../vendor/polyfills/Array.prototype.es6.js' - ) - ) - .toString()} - `, + banner: 'if (this && !this.self) { this.self = this; };\n', raw: true, }), ] @@ -240,7 +231,6 @@ function DEPRECATEDMakeReactNativeConfig( }; const defaultWebpackConfig = getDefaultConfig(env); - const polyfillPath = require.resolve('./polyfillEnvironment.js'); const userConfig = typeof userWebpackConfig === 'function' @@ -248,7 +238,10 @@ function DEPRECATEDMakeReactNativeConfig( : userWebpackConfig; const config = Object.assign({}, defaultWebpackConfig, userConfig, { - entry: injectPolyfillIntoEntry(userConfig.entry, polyfillPath), + entry: injectPolyfillIntoEntry({ + root, + entry: userConfig.entry, + }), name: platform, }); @@ -349,20 +342,36 @@ function makeReactNativeConfig( return webpackConfig; } -/* - * Takes user entries from webpack.haul.js, - * change them to multi-point entries - * and injects polyfills - */ -function injectPolyfillIntoEntry( +function injectPolyfillIntoEntry({ + entry: userEntry, + root, +}: { + entry: WebpackEntry, + root: string, +}) { + const reactNativeHaulEntries = [ + ...getPolyfills(), + require.resolve( + path.join( + root, + 'node_modules/react-native/Libraries/Core/InitializeCore.js' + ) + ), + require.resolve('./polyfillEnvironment.js'), + ]; + + return makeWebpackEntry(userEntry, reactNativeHaulEntries); +} + +function makeWebpackEntry( userEntry: WebpackEntry, - polyfillPath: string + otherEntries: Array ): WebpackEntry { if (typeof userEntry === 'string') { - return [polyfillPath, userEntry]; + return [...otherEntries, userEntry]; } if (Array.isArray(userEntry)) { - return [polyfillPath, ...userEntry]; + return [...otherEntries, ...userEntry]; } if (typeof userEntry === 'object') { const chunkNames = Object.keys(userEntry); @@ -370,10 +379,10 @@ function injectPolyfillIntoEntry( // $FlowFixMe const chunk = userEntry[name]; if (typeof chunk === 'string') { - entryObj[name] = [polyfillPath, chunk]; + entryObj[name] = [...otherEntries, chunk]; return entryObj; } else if (Array.isArray(chunk)) { - entryObj[name] = [polyfillPath, ...chunk]; + entryObj[name] = [...otherEntries, ...chunk]; return entryObj; } return chunk; @@ -398,10 +407,10 @@ function createWebpackConfig(configBuilder: WebpackConfigFactory) { const config = { ...defaultWebpackConfig, - entry: injectPolyfillIntoEntry( + entry: injectPolyfillIntoEntry({ + root: options.root, entry, - require.resolve('./polyfillEnvironment.js') - ), + }), name: options.platform, }; diff --git a/src/utils/polyfillEnvironment.js b/src/utils/polyfillEnvironment.js index f8ea2250..4baaf261 100644 --- a/src/utils/polyfillEnvironment.js +++ b/src/utils/polyfillEnvironment.js @@ -2,39 +2,11 @@ * Copyright 2017-present, Callstack. * All rights reserved. * - * polyfillEnvironment.js - * * This file is loaded as a part of user bundle + * */ import { NativeModules } from 'react-native'; -/* eslint-disable import/no-extraneous-dependencies */ -require('../../vendor/polyfills/console.js')(global); -require('../../vendor/polyfills/error-guard.js'); -require('../../vendor/polyfills/Number.es6.js'); -require('../../vendor/polyfills/String.prototype.es6.js'); -require('../../vendor/polyfills/Array.prototype.es6.js'); -require('../../vendor/polyfills/Array.es6.js'); -require('../../vendor/polyfills/Object.es6.js'); -require('../../vendor/polyfills/Object.es7.js'); -require('../../vendor/polyfills/babelHelpers.js'); - -// HACK: -// This is horrible. I know. But this hack seems to be needed due to the way -// React Native lazy evaluates `fetch` within `InitializeCore`. This was fixed -// in 34-ish, but seems to be back again. I hope I'm wrong because I lost sleep -// on this one. -// -// Without this in place, global.fetch will be undefined and cause the symbolicate -// check to fail. This must be something that the packager is doing that haul isn't. -// I also so people complaining about this in Jest as well. -// -if (!global.self) { - global.self = global; /* eslint-disable-line */ -} - -require('react-native/Libraries/Core/InitializeCore'); - require('../hot/client/importScriptsPolyfill'); if (process.env.NODE_ENV !== 'production') { diff --git a/src/vendor/polyfills/Array.es6.js b/src/vendor/polyfills/Array.es6.js new file mode 100644 index 00000000..bf2a6e32 --- /dev/null +++ b/src/vendor/polyfills/Array.es6.js @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @providesModule Array.es6 + * @polyfill + * @nolint + */ + +/* eslint-disable consistent-this */ + +/** + * Creates an array from array like objects. + * + * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from + */ +if (!Array.from) { + Array.from = function(arrayLike /* , mapFn, thisArg */) { + if (arrayLike == null) { + throw new TypeError('Object is null or undefined'); + } + + // Optional args. + const mapFn = arguments[1]; + const thisArg = arguments[2]; + + const C = this; + const items = Object(arrayLike); + const symbolIterator = + typeof Symbol === 'function' ? Symbol.iterator : '@@iterator'; + const mapping = typeof mapFn === 'function'; + const usingIterator = typeof items[symbolIterator] === 'function'; + let key = 0; + let ret; + let value; + + if (usingIterator) { + ret = typeof C === 'function' ? new C() : []; + const it = items[symbolIterator](); + let next; + + while (!(next = it.next()).done) { + value = next.value; + + if (mapping) { + value = mapFn.call(thisArg, value, key); + } + + ret[key] = value; + key += 1; + } + + ret.length = key; + return ret; + } + + let len = items.length; + if (isNaN(len) || len < 0) { + len = 0; + } + + ret = typeof C === 'function' ? new C(len) : new Array(len); + + while (key < len) { + value = items[key]; + + if (mapping) { + value = mapFn.call(thisArg, value, key); + } + + ret[key] = value; + + key += 1; + } + + ret.length = key; + return ret; + }; +} diff --git a/vendor/polyfills/Array.prototype.es6.js b/src/vendor/polyfills/Array.prototype.es6.js similarity index 66% rename from vendor/polyfills/Array.prototype.es6.js rename to src/vendor/polyfills/Array.prototype.es6.js index 612d3c38..1973184a 100644 --- a/vendor/polyfills/Array.prototype.es6.js +++ b/src/vendor/polyfills/Array.prototype.es6.js @@ -1,15 +1,15 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in 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 source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * + * @providesModule Array.prototype.es6 * @polyfill + * @nolint */ -/* eslint-disable */ +/* eslint-disable no-bitwise, no-extend-native, radix, no-self-compare */ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex function findIndex(predicate, context) { @@ -21,9 +21,9 @@ function findIndex(predicate, context) { if (typeof predicate !== 'function') { throw new TypeError('predicate must be a function'); } - var list = Object(this); - var length = list.length >>> 0; - for (var i = 0; i < length; i++) { + const list = Object(this); + const length = list.length >>> 0; + for (let i = 0; i < length; i++) { if (predicate.call(context, list[i], i, list)) { return i; } @@ -36,7 +36,7 @@ if (!Array.prototype.findIndex) { enumerable: false, writable: true, configurable: true, - value: findIndex + value: findIndex, }); } @@ -46,15 +46,13 @@ if (!Array.prototype.find) { enumerable: false, writable: true, configurable: true, - value: function(predicate, context) { + value(predicate, context) { if (this == null) { - throw new TypeError( - 'Array.prototype.find called on null or undefined' - ); + throw new TypeError('Array.prototype.find called on null or undefined'); } - var index = findIndex.call(this, predicate, context); + const index = findIndex.call(this, predicate, context); return index === -1 ? undefined : this[index]; - } + }, }); } @@ -64,14 +62,14 @@ if (!Array.prototype.includes) { enumerable: false, writable: true, configurable: true, - value: function (searchElement) { - var O = Object(this); - var len = parseInt(O.length) || 0; + value(searchElement) { + const O = Object(this); + const len = parseInt(O.length) || 0; if (len === 0) { return false; } - var n = parseInt(arguments[1]) || 0; - var k; + const n = parseInt(arguments[1]) || 0; + let k; if (n >= 0) { k = n; } else { @@ -80,16 +78,18 @@ if (!Array.prototype.includes) { k = 0; } } - var currentElement; + let currentElement; while (k < len) { currentElement = O[k]; - if (searchElement === currentElement || - (searchElement !== searchElement && currentElement !== currentElement)) { + if ( + searchElement === currentElement || + (searchElement !== searchElement && currentElement !== currentElement) + ) { return true; } k++; } return false; - } + }, }); } diff --git a/vendor/polyfills/Number.es6.js b/src/vendor/polyfills/Number.es6.js similarity index 72% rename from vendor/polyfills/Number.es6.js rename to src/vendor/polyfills/Number.es6.js index bd669c3c..ef7d4ac8 100644 --- a/vendor/polyfills/Number.es6.js +++ b/src/vendor/polyfills/Number.es6.js @@ -1,16 +1,14 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in 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 source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * + * @providesModule Number.es6 * @polyfill + * @nolint */ -/* eslint-disable strict */ - if (Number.EPSILON === undefined) { Object.defineProperty(Number, 'EPSILON', { value: Math.pow(2, -52), @@ -27,7 +25,6 @@ if (Number.MIN_SAFE_INTEGER === undefined) { }); } if (!Number.isNaN) { - // eslint-disable-next-line max-len // https://github.com/dherman/tc39-codex-wiki/blob/master/data/es6/number/index.md#polyfill-for-numberisnan const globalIsNaN = global.isNaN; Object.defineProperty(Number, 'isNaN', { diff --git a/vendor/polyfills/Object.es6.js b/src/vendor/polyfills/Object.es6.js similarity index 63% rename from vendor/polyfills/Object.es6.js rename to src/vendor/polyfills/Object.es6.js index 64943664..4294ec0a 100644 --- a/vendor/polyfills/Object.es6.js +++ b/src/vendor/polyfills/Object.es6.js @@ -1,16 +1,14 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in 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 source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * + * @providesModule Object.es6 * @polyfill + * @nolint */ -/* eslint-disable strict */ - // WARNING: This is an optimized version that fails on hasOwnProperty checks // and non objects. It's not spec-compliant. It's a perf optimization. // This is only needed for iOS 8 and current Android JSC. @@ -22,24 +20,23 @@ Object.assign = function(target, sources) { } if (typeof target !== 'object' && typeof target !== 'function') { throw new TypeError( - 'In this environment the target of assign MUST be an object.' + - 'This error is a performance optimization and not spec compliant.' + 'In this environment the target of assign MUST be an object. ' + + 'This error is a performance optimization and not spec compliant.' ); } } - for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) { - var nextSource = arguments[nextIndex]; + for (let nextIndex = 1; nextIndex < arguments.length; nextIndex++) { + const nextSource = arguments[nextIndex]; if (nextSource == null) { continue; } if (__DEV__) { - if (typeof nextSource !== 'object' && - typeof nextSource !== 'function') { + if (typeof nextSource !== 'object' && typeof nextSource !== 'function') { throw new TypeError( - 'In this environment the sources for assign MUST be an object.' + - 'This error is a performance optimization and not spec compliant.' + 'In this environment the sources for assign MUST be an object. ' + + 'This error is a performance optimization and not spec compliant.' ); } } @@ -48,15 +45,15 @@ Object.assign = function(target, sources) { // copy cannot throw. If we ever supported this then we must handle // exceptions and side-effects. - for (var key in nextSource) { + for (const key in nextSource) { if (__DEV__) { - var hasOwnProperty = Object.prototype.hasOwnProperty; + const hasOwnProperty = Object.prototype.hasOwnProperty; if (!hasOwnProperty.call(nextSource, key)) { throw new TypeError( 'One of the sources for assign has an enumerable key on the ' + - 'prototype chain. Are you trying to assign a prototype property? ' + - 'We don\'t allow it, as this is an edge case that we do not support. ' + - 'This error is a performance optimization and not spec compliant.' + 'prototype chain. Are you trying to assign a prototype property? ' + + "We don't allow it, as this is an edge case that we do not support. " + + 'This error is a performance optimization and not spec compliant.' ); } } diff --git a/vendor/polyfills/Object.es7.js b/src/vendor/polyfills/Object.es7.js similarity index 84% rename from vendor/polyfills/Object.es7.js rename to src/vendor/polyfills/Object.es7.js index dc5dc893..bad28620 100644 --- a/vendor/polyfills/Object.es7.js +++ b/src/vendor/polyfills/Object.es7.js @@ -1,12 +1,12 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in 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 source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * + * @providesModule Object.es7 * @polyfill + * @nolint */ (function() { @@ -55,5 +55,4 @@ return values; }; } - })(); diff --git a/src/vendor/polyfills/String.prototype.es6.js b/src/vendor/polyfills/String.prototype.es6.js new file mode 100644 index 00000000..5d0deabe --- /dev/null +++ b/src/vendor/polyfills/String.prototype.es6.js @@ -0,0 +1,129 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @providesModule String.prototype.es6 + * @polyfill + * @nolint + */ + +/* eslint-disable no-extend-native, no-bitwise */ + +/* + * NOTE: We use (Number(x) || 0) to replace NaN values with zero. + */ + +if (!String.prototype.startsWith) { + String.prototype.startsWith = function(search) { + 'use strict'; + + if (this == null) { + throw TypeError(); + } + const string = String(this); + const pos = arguments.length > 1 ? Number(arguments[1]) || 0 : 0; + const start = Math.min(Math.max(pos, 0), string.length); + return string.indexOf(String(search), pos) === start; + }; +} + +if (!String.prototype.endsWith) { + String.prototype.endsWith = function(search) { + 'use strict'; + + if (this == null) { + throw TypeError(); + } + const string = String(this); + const stringLength = string.length; + const searchString = String(search); + const pos = arguments.length > 1 ? Number(arguments[1]) || 0 : stringLength; + const end = Math.min(Math.max(pos, 0), stringLength); + const start = end - searchString.length; + if (start < 0) { + return false; + } + return string.lastIndexOf(searchString, start) === start; + }; +} + +if (!String.prototype.repeat) { + String.prototype.repeat = function(count) { + 'use strict'; + + if (this == null) { + throw TypeError(); + } + let string = String(this); + count = Number(count) || 0; + if (count < 0 || count === Infinity) { + throw RangeError(); + } + if (count === 1) { + return string; + } + let result = ''; + while (count) { + if (count & 1) { + result += string; + } + if ((count >>= 1)) { + string += string; + } + } + return result; + }; +} + +if (!String.prototype.includes) { + String.prototype.includes = function(search, start) { + 'use strict'; + + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > this.length) { + return false; + } + return this.indexOf(search, start) !== -1; + }; +} + +if (!String.prototype.codePointAt) { + String.prototype.codePointAt = function(position) { + if (this == null) { + throw TypeError(); + } + const string = String(this); + const size = string.length; + // `ToInteger` + let index = position ? Number(position) : 0; + if (Number.isNaN(index)) { + index = 0; + } + // Account for out-of-bounds indices: + if (index < 0 || index >= size) { + return undefined; + } + // Get the first code unit + const first = string.charCodeAt(index); + let second; + if ( + // check if it’s the start of a surrogate pair + first >= 0xd800 && + first <= 0xdbff && // high surrogate + size > index + 1 // there is a next code unit + ) { + second = string.charCodeAt(index + 1); + if (second >= 0xdc00 && second <= 0xdfff) { + // low surrogate + // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xd800) * 0x400 + second - 0xdc00 + 0x10000; + } + } + return first; + }; +} diff --git a/src/vendor/polyfills/babelHelpers.js b/src/vendor/polyfills/babelHelpers.js new file mode 100644 index 00000000..a14ad021 --- /dev/null +++ b/src/vendor/polyfills/babelHelpers.js @@ -0,0 +1,342 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @providesModule babelHelpers + * @polyfill + * @nolint + */ + +/* eslint-disable quotes, curly, no-proto, no-undef-init, dot-notation */ + +// Created by running: +// require('fs').writeFileSync('babelExternalHelpers.js', require('@babel/core').buildExternalHelpers('_extends classCallCheck createClass createRawReactElement defineProperty get inherits interopRequireDefault interopRequireWildcard objectWithoutProperties possibleConstructorReturn slicedToArray taggedTemplateLiteral toArray toConsumableArray wrapNativeSuper assertThisInitialized taggedTemplateLiteralLoose'.split(' ')))// then replacing the `global` reference in the last line to also use `this`. +// +// Actually, that's a lie, because babel omits _extends and +// createRawReactElement. the file is also cleaned up a bit. +// You may need to clear wrapNativeSuper while the bug hasn't been fixed yet. +// Do try to keep diffs to a minimum. + +const babelHelpers = (global.babelHelpers = {}); + +babelHelpers.createRawReactElement = (function() { + const REACT_ELEMENT_TYPE = + (typeof Symbol === 'function' && + Symbol.for && + Symbol.for('react.element')) || + 0xeac7; + return function createRawReactElement(type, key, props) { + return { + $$typeof: REACT_ELEMENT_TYPE, + type, + key, + ref: null, + props, + _owner: null, + }; + }; +})(); + +babelHelpers.classCallCheck = function(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function'); + } +}; + +function _defineProperties(target, props) { + for (let i = 0; i < props.length; i++) { + const descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ('value' in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } +} + +babelHelpers.createClass = function(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; +}; + +babelHelpers.defineProperty = function(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value, + enumerable: true, + configurable: true, + writable: true, + }); + } else { + obj[key] = value; + } + + return obj; +}; + +babelHelpers._extends = babelHelpers.extends = + Object.assign || + function(target) { + for (let i = 1; i < arguments.length; i++) { + const source = arguments[i]; + + for (const key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + +babelHelpers.get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + const desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + const parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } + return get(parent, property, receiver); + } else if ('value' in desc) { + return desc.value; + } + const getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); +}; + +babelHelpers.inherits = function(subClass, superClass) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError('Super expression must either be null or a function'); + } + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true, + }, + }); + if (superClass) + Object.setPrototypeOf + ? Object.setPrototypeOf(subClass, superClass) + : (subClass.__proto__ = superClass); +}; + +const _gPO = + Object.getPrototypeOf || + function _gPO(o) { + return o.__proto__; + }; +const _sPO = + Object.setPrototypeOf || + function _sPO(o, p) { + o.__proto__ = p; + return o; + }; +const _construct = + // TODO: prepack does not like this line (and we can use the fallback just fine) + // (typeof Reflect === "object" && Reflect.construct) || + function _construct(Parent, args, Class) { + let Constructor, + a = [null]; + a.push(...args); + Constructor = Parent.bind(...a); + return _sPO(new Constructor(), Class.prototype); + }; +const _cache = typeof Map === 'function' && new Map(); +babelHelpers.wrapNativeSuper = function(Class) { + // FB: + // Note: while extending native classes is pretty meh we do have cases, for + // example; Error. There is also a false positive, for example; Blob. + + if (typeof Class !== 'function') { + throw new TypeError('Super expression must either be null or a function'); + } + if (typeof _cache !== 'undefined') { + if (_cache.has(Class)) return _cache.get(Class); + _cache.set(Class, Wrapper); + } + function Wrapper() { + // this is a temporary fix for a babel bug (it's invoking the wrong func + // when you do `super()`) + return _construct(Class, arguments, _gPO(this).constructor); + } + Wrapper.prototype = Object.create(Class.prototype, { + constructor: { + value: Wrapper, + enumerable: false, + writeable: true, + configurable: true, + }, + }); + return _sPO( + Wrapper, + _sPO(function Super() { + return _construct(Class, arguments, _gPO(this).constructor); + }, Class) + ); +}; + +babelHelpers.interopRequireDefault = function(obj) { + return obj && obj.__esModule + ? obj + : { + default: obj, + }; +}; + +babelHelpers.interopRequireWildcard = function(obj) { + if (obj && obj.__esModule) { + return obj; + } + const newObj = {}; + + if (obj != null) { + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + const desc = + Object.defineProperty && Object.getOwnPropertyDescriptor + ? Object.getOwnPropertyDescriptor(obj, key) + : {}; + + if (desc.get || desc.set) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; + } + } + } + } + + newObj.default = obj; + return newObj; +}; + +babelHelpers.objectWithoutProperties = function(source, excluded) { + if (source == null) return {}; + const target = {}; + const sourceKeys = Object.keys(source); + let key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + if (Object.getOwnPropertySymbols) { + const sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +}; + +babelHelpers.possibleConstructorReturn = function(self, call) { + if (call && (typeof call === 'object' || typeof call === 'function')) { + return call; + } + + if (self === void 0) { + throw new ReferenceError( + "this hasn't been initialised - super() hasn't been called" + ); + } + + return self; +}; + +function _sliceIterator(arr, i) { + const _arr = []; + let _n = true; + let _d = false; + let _e = undefined; + + try { + for ( + var _i = arr[Symbol.iterator](), _s; + !(_n = (_s = _i.next()).done); + _n = true + ) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i['return'] != null) _i['return'](); + } finally { + if (_d) throw _e; + } + } + + return _arr; +} + +babelHelpers.slicedToArray = function(arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + return _sliceIterator(arr, i); + } + throw new TypeError('Invalid attempt to destructure non-iterable instance'); +}; + +babelHelpers.taggedTemplateLiteral = function(strings, raw) { + return Object.freeze( + Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw), + }, + }) + ); +}; + +babelHelpers.toArray = function(arr) { + return Array.isArray(arr) ? arr : Array.from(arr); +}; + +babelHelpers.toConsumableArray = function(arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) + arr2[i] = arr[i]; + + return arr2; + } + return Array.from(arr); +}; + +babelHelpers.assertThisInitialized = function(self) { + if (self === void 0) { + throw new ReferenceError( + "this hasn't been initialised - super() hasn't been called" + ); + } + + return self; +}; + +babelHelpers.taggedTemplateLiteralLoose = function(strings, raw) { + strings.raw = raw; + return strings; +}; diff --git a/vendor/polyfills/console.js b/src/vendor/polyfills/console.js similarity index 53% rename from vendor/polyfills/console.js rename to src/vendor/polyfills/console.js index da979a2f..d2a441e2 100644 --- a/vendor/polyfills/console.js +++ b/src/vendor/polyfills/console.js @@ -1,16 +1,16 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in 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 source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * + * @providesModule console * @polyfill * @nolint + * @format */ -/* eslint-disable */ +/* eslint-disable no-shadow, eqeqeq, curly, no-unused-vars, no-void */ /** * This pipes all of our console logging functions to native logging so that @@ -41,9 +41,9 @@ const inspect = (function() { // https://github.com/joyent/node/blob/master/lib/util.js function inspect(obj, opts) { - var ctx = { + const ctx = { seen: [], - stylize: stylizeNoColor + stylize: stylizeNoColor, }; return formatValue(ctx, obj, opts.depth); } @@ -53,39 +53,40 @@ const inspect = (function() { } function arrayToHash(array) { - var hash = {}; + const hash = {}; - array.forEach(function(val, idx) { + array.forEach((val, idx) => { hash[val] = true; }); return hash; } - function formatValue(ctx, value, recurseTimes) { // Primitive types cannot have properties - var primitive = formatPrimitive(ctx, value); + const primitive = formatPrimitive(ctx, value); if (primitive) { return primitive; } // Look up the keys of the object. - var keys = Object.keys(value); - var visibleKeys = arrayToHash(keys); + const keys = Object.keys(value); + const visibleKeys = arrayToHash(keys); // IE doesn't make error fields non-enumerable // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx - if (isError(value) - && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + if ( + isError(value) && + (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0) + ) { return formatError(value); } // Some type of object without properties can be shortcutted. if (keys.length === 0) { if (isFunction(value)) { - var name = value.name ? ': ' + value.name : ''; - return ctx.stylize('[Function' + name + ']', 'special'); + const name = value.name ? `: ${value.name}` : ''; + return ctx.stylize(`[Function${name}]`, 'special'); } if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); @@ -98,7 +99,9 @@ const inspect = (function() { } } - var base = '', array = false, braces = ['{', '}']; + let base = '', + array = false, + braces = ['{', '}']; // Make Array say that they are Array if (isArray(value)) { @@ -108,23 +111,23 @@ const inspect = (function() { // Make functions say that they are functions if (isFunction(value)) { - var n = value.name ? ': ' + value.name : ''; - base = ' [Function' + n + ']'; + const n = value.name ? `: ${value.name}` : ''; + base = ` [Function${n}]`; } // Make RegExps say that they are RegExps if (isRegExp(value)) { - base = ' ' + RegExp.prototype.toString.call(value); + base = ` ${RegExp.prototype.toString.call(value)}`; } // Make dates with properties first say the date if (isDate(value)) { - base = ' ' + Date.prototype.toUTCString.call(value); + base = ` ${Date.prototype.toUTCString.call(value)}`; } // Make error with message first say the error if (isError(value)) { - base = ' ' + formatError(value); + base = ` ${formatError(value)}`; } if (keys.length === 0 && (!array || value.length == 0)) { @@ -134,19 +137,25 @@ const inspect = (function() { if (recurseTimes < 0) { if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); - } else { - return ctx.stylize('[Object]', 'special'); } + return ctx.stylize('[Object]', 'special'); } ctx.seen.push(value); - var output; + let output; if (array) { output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); } else { - output = keys.map(function(key) { - return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + output = keys.map(key => { + return formatProperty( + ctx, + value, + recurseTimes, + visibleKeys, + key, + array + ); }); } @@ -155,53 +164,48 @@ const inspect = (function() { return reduceToSingleString(output, base, braces); } - function formatPrimitive(ctx, value) { - if (isUndefined(value)) - return ctx.stylize('undefined', 'undefined'); + if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); if (isString(value)) { - var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; + const simple = `'${JSON.stringify(value) + .replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"')}'`; return ctx.stylize(simple, 'string'); } - if (isNumber(value)) - return ctx.stylize('' + value, 'number'); - if (isBoolean(value)) - return ctx.stylize('' + value, 'boolean'); + if (isNumber(value)) return ctx.stylize(`${value}`, 'number'); + if (isBoolean(value)) return ctx.stylize(`${value}`, 'boolean'); // For some reason typeof null is "object", so special case here. - if (isNull(value)) - return ctx.stylize('null', 'null'); + if (isNull(value)) return ctx.stylize('null', 'null'); } - function formatError(value) { - return '[' + Error.prototype.toString.call(value) + ']'; + return `[${Error.prototype.toString.call(value)}]`; } - function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { - var output = []; - for (var i = 0, l = value.length; i < l; ++i) { + const output = []; + for (let i = 0, l = value.length; i < l; ++i) { if (hasOwnProperty(value, String(i))) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); + output.push( + formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true) + ); } else { output.push(''); } } - keys.forEach(function(key) { + keys.forEach(key => { if (!key.match(/^\d+$/)) { - output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); + output.push( + formatProperty(ctx, value, recurseTimes, visibleKeys, key, true) + ); } }); return output; } - function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { - var name, str, desc; + let name, str, desc; desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; if (desc.get) { if (desc.set) { @@ -209,13 +213,11 @@ const inspect = (function() { } else { str = ctx.stylize('[Getter]', 'special'); } - } else { - if (desc.set) { - str = ctx.stylize('[Setter]', 'special'); - } + } else if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); } if (!hasOwnProperty(visibleKeys, key)) { - name = '[' + key + ']'; + name = `[${key}]`; } if (!str) { if (ctx.seen.indexOf(desc.value) < 0) { @@ -226,13 +228,20 @@ const inspect = (function() { } if (str.indexOf('\n') > -1) { if (array) { - str = str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n').substr(2); + str = str + .split('\n') + .map(line => { + return ` ${line}`; + }) + .join('\n') + .substr(2); } else { - str = '\n' + str.split('\n').map(function(line) { - return ' ' + line; - }).join('\n'); + str = `\n${str + .split('\n') + .map(line => { + return ` ${line}`; + }) + .join('\n')}`; } } } else { @@ -243,43 +252,39 @@ const inspect = (function() { if (array && key.match(/^\d+$/)) { return str; } - name = JSON.stringify('' + key); + name = JSON.stringify(`${key}`); if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { name = name.substr(1, name.length - 2); name = ctx.stylize(name, 'name'); } else { - name = name.replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'"); + name = name + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); name = ctx.stylize(name, 'string'); } } - return name + ': ' + str; + return `${name}: ${str}`; } - function reduceToSingleString(output, base, braces) { - var numLinesEst = 0; - var length = output.reduce(function(prev, cur) { + let numLinesEst = 0; + const length = output.reduce((prev, cur) => { numLinesEst++; if (cur.indexOf('\n') >= 0) numLinesEst++; return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; }, 0); if (length > 60) { - return braces[0] + - (base === '' ? '' : base + '\n ') + - ' ' + - output.join(',\n ') + - ' ' + - braces[1]; + return `${braces[0] + (base === '' ? '' : `${base}\n `)} ${output.join( + ',\n ' + )} ${braces[1]}`; } - return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; + return `${braces[0] + base} ${output.join(', ')} ${braces[1]}`; } - // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. function isArray(ar) { @@ -327,8 +332,10 @@ const inspect = (function() { } function isError(e) { - return isObject(e) && - (objectToString(e) === '[object Error]' || e instanceof Error); + return ( + isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error) + ); } function isFunction(arg) { @@ -336,12 +343,14 @@ const inspect = (function() { } function isPrimitive(arg) { - return arg === null || - typeof arg === 'boolean' || - typeof arg === 'number' || - typeof arg === 'string' || - typeof arg === 'symbol' || // ES6 symbol - typeof arg === 'undefined'; + return ( + arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined' + ); } function objectToString(o) { @@ -355,13 +364,12 @@ const inspect = (function() { return inspect; })(); - const OBJECT_COLUMN_NAME = '(index)'; const LOG_LEVELS = { trace: 0, info: 1, warn: 2, - error: 3 + error: 3, }; const INSPECTOR_LEVELS = []; INSPECTOR_LEVELS[LOG_LEVELS.trace] = 'debug'; @@ -373,114 +381,109 @@ INSPECTOR_LEVELS[LOG_LEVELS.error] = 'error'; // strip method printing to originalConsole. const INSPECTOR_FRAMES_TO_SKIP = __DEV__ ? 2 : 1; -function setupConsole(global) { - if (!global.nativeLoggingHook) { - return; - } - - function getNativeLogFunction(level) { - return function() { - let str; - if (arguments.length === 1 && typeof arguments[0] === 'string') { - str = arguments[0]; - } else { - str = Array.prototype.map.call(arguments, function(arg) { - return inspect(arg, {depth: 10}); - }).join(', '); - } - - let logLevel = level; - if (str.slice(0, 9) === 'Warning: ' && logLevel >= LOG_LEVELS.error) { - // React warnings use console.error so that a stack trace is shown, - // but we don't (currently) want these to show a redbox - // (Note: Logic duplicated in ExceptionsManager.js.) - logLevel = LOG_LEVELS.warn; - } - if (global.__inspectorLog) { - global.__inspectorLog( - INSPECTOR_LEVELS[logLevel], - str, - [].slice.call(arguments), - INSPECTOR_FRAMES_TO_SKIP); - } - global.nativeLoggingHook(str, logLevel); - }; - } - - function repeat(element, n) { - return Array.apply(null, Array(n)).map(function() { return element; }); - }; +function getNativeLogFunction(level) { + return function() { + let str; + if (arguments.length === 1 && typeof arguments[0] === 'string') { + str = arguments[0]; + } else { + str = Array.prototype.map + .call(arguments, arg => { + return inspect(arg, { depth: 10 }); + }) + .join(', '); + } - function consoleTablePolyfill(rows) { - // convert object -> array - if (!Array.isArray(rows)) { - var data = rows; - rows = []; - for (var key in data) { - if (data.hasOwnProperty(key)) { - var row = data[key]; - row[OBJECT_COLUMN_NAME] = key; - rows.push(row); - } - } + let logLevel = level; + if (str.slice(0, 9) === 'Warning: ' && logLevel >= LOG_LEVELS.error) { + // React warnings use console.error so that a stack trace is shown, + // but we don't (currently) want these to show a redbox + // (Note: Logic duplicated in ExceptionsManager.js.) + logLevel = LOG_LEVELS.warn; } - if (rows.length === 0) { - global.nativeLoggingHook('', LOG_LEVELS.info); - return; + if (global.__inspectorLog) { + global.__inspectorLog( + INSPECTOR_LEVELS[logLevel], + str, + [].slice.call(arguments), + INSPECTOR_FRAMES_TO_SKIP + ); } + global.nativeLoggingHook(str, logLevel); + }; +} - var columns = Object.keys(rows[0]).sort(); - var stringRows = []; - var columnWidths = []; - - // Convert each cell to a string. Also - // figure out max cell width for each column - columns.forEach(function(k, i) { - columnWidths[i] = k.length; - for (var j = 0; j < rows.length; j++) { - var cellStr = (rows[j][k] || '?').toString(); - stringRows[j] = stringRows[j] || []; - stringRows[j][i] = cellStr; - columnWidths[i] = Math.max(columnWidths[i], cellStr.length); - } - }); +function repeat(element, n) { + return Array(...Array(n)).map(() => { + return element; + }); +} - // Join all elements in the row into a single string with | separators - // (appends extra spaces to each cell to make separators | alligned) - function joinRow(row, space) { - var cells = row.map(function(cell, i) { - var extraSpaces = repeat(' ', columnWidths[i] - cell.length).join(''); - return cell + extraSpaces; - }); - space = space || ' '; - return cells.join(space + '|' + space); - }; +function consoleTablePolyfill(rows) { + // convert object -> array + if (!Array.isArray(rows)) { + const data = rows; + rows = []; + for (const key in data) { + if (data.hasOwnProperty(key)) { + const row = data[key]; + row[OBJECT_COLUMN_NAME] = key; + rows.push(row); + } + } + } + if (rows.length === 0) { + global.nativeLoggingHook('', LOG_LEVELS.info); + return; + } - var separators = columnWidths.map(function(columnWidth) { - return repeat('-', columnWidth).join(''); + const columns = Object.keys(rows[0]).sort(); + const stringRows = []; + const columnWidths = []; + + // Convert each cell to a string. Also + // figure out max cell width for each column + columns.forEach((k, i) => { + columnWidths[i] = k.length; + for (let j = 0; j < rows.length; j++) { + const cellStr = (rows[j][k] || '?').toString(); + stringRows[j] = stringRows[j] || []; + stringRows[j][i] = cellStr; + columnWidths[i] = Math.max(columnWidths[i], cellStr.length); + } + }); + + // Join all elements in the row into a single string with | separators + // (appends extra spaces to each cell to make separators | aligned) + function joinRow(row, space) { + const cells = row.map((cell, i) => { + const extraSpaces = repeat(' ', columnWidths[i] - cell.length).join(''); + return cell + extraSpaces; }); - var separatorRow = joinRow(separators, '-'); - var header = joinRow(columns); - var table = [header, separatorRow]; + space = space || ' '; + return cells.join(`${space}|${space}`); + } - for (var i = 0; i < rows.length; i++) { - table.push(joinRow(stringRows[i])); - } + const separators = columnWidths.map(columnWidth => { + return repeat('-', columnWidth).join(''); + }); + const separatorRow = joinRow(separators, '-'); + const header = joinRow(columns); + const table = [header, separatorRow]; - // Notice extra empty line at the beginning. - // Native logging hook adds "RCTLog >" at the front of every - // logged string, which would shift the header and screw up - // the table - global.nativeLoggingHook('\n' + table.join('\n'), LOG_LEVELS.info); + for (let i = 0; i < rows.length; i++) { + table.push(joinRow(stringRows[i])); } - // Preserve the original `console` as `originalConsole` - var originalConsole = global.console; - var descriptor = Object.getOwnPropertyDescriptor(global, 'console'); - if (descriptor) { - Object.defineProperty(global, 'originalConsole', descriptor); - } + // Notice extra empty line at the beginning. + // Native logging hook adds "RCTLog >" at the front of every + // logged string, which would shift the header and screw up + // the table + global.nativeLoggingHook(`\n${table.join('\n')}`, LOG_LEVELS.info); +} +if (global.nativeLoggingHook) { + const originalConsole = global.console; global.console = { error: getNativeLogFunction(LOG_LEVELS.error), info: getNativeLogFunction(LOG_LEVELS.info), @@ -488,15 +491,21 @@ function setupConsole(global) { warn: getNativeLogFunction(LOG_LEVELS.warn), trace: getNativeLogFunction(LOG_LEVELS.trace), debug: getNativeLogFunction(LOG_LEVELS.trace), - table: consoleTablePolyfill + table: consoleTablePolyfill, }; // If available, also call the original `console` method since that is // sometimes useful. Ex: on OS X, this will let you see rich output in // the Safari Web Inspector console. if (__DEV__ && originalConsole) { + // Preserve the original `console` as `originalConsole` + const descriptor = Object.getOwnPropertyDescriptor(global, 'console'); + if (descriptor) { + Object.defineProperty(global, 'originalConsole', descriptor); + } + Object.keys(console).forEach(methodName => { - var reactNativeMethod = console[methodName]; + const reactNativeMethod = console[methodName]; if (originalConsole[methodName]) { console[methodName] = function() { originalConsole[methodName](...arguments); @@ -505,10 +514,15 @@ function setupConsole(global) { } }); } -} - -if (typeof module !== 'undefined') { - module.exports = setupConsole; -} else { - setupConsole(global); +} else if (!global.console) { + const log = global.print || function consoleLoggingStub() {}; + global.console = { + error: log, + info: log, + log, + warn: log, + trace: log, + debug: log, + table: log, + }; } diff --git a/vendor/polyfills/error-guard.js b/src/vendor/polyfills/error-guard.js similarity index 78% rename from vendor/polyfills/error-guard.js rename to src/vendor/polyfills/error-guard.js index b9330506..33a4e4f3 100644 --- a/vendor/polyfills/error-guard.js +++ b/src/vendor/polyfills/error-guard.js @@ -1,16 +1,14 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in 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 source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. * + * @providesModule error-guard * @polyfill + * @nolint */ -/* eslint-disable strict */ - let _inGuard = 0; /** @@ -57,9 +55,9 @@ const ErrorUtils = { applyWithGuardIfNeeded(fun, context, args) { if (ErrorUtils.inGuard()) { return fun.apply(context, args); - } else { - ErrorUtils.applyWithGuard(fun, context, args); } + ErrorUtils.applyWithGuard(fun, context, args); + return null; }, inGuard() { @@ -72,14 +70,12 @@ const ErrorUtils = { } name = name || fun.name || ''; function guarded() { - return ( - ErrorUtils.applyWithGuard( - fun, - context || this, - arguments, - null, - name - ) + return ErrorUtils.applyWithGuard( + fun, + context || this, + arguments, + null, + name ); } diff --git a/vendor/polyfills/Array.es6.js b/vendor/polyfills/Array.es6.js deleted file mode 100644 index 87c83ed2..00000000 --- a/vendor/polyfills/Array.es6.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @polyfill - */ - -/* eslint-disable */ - -/** - * Creates an array from array like objects. - * - * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from - */ -if (!Array.from) { - Array.from = function(arrayLike /*, mapFn, thisArg */) { - if (arrayLike == null) { - throw new TypeError('Object is null or undefined'); - } - - // Optional args. - var mapFn = arguments[1]; - var thisArg = arguments[2]; - - var C = this; - var items = Object(arrayLike); - var symbolIterator = typeof Symbol === 'function' - ? Symbol.iterator - : '@@iterator'; - var mapping = typeof mapFn === 'function'; - var usingIterator = typeof items[symbolIterator] === 'function'; - var key = 0; - var ret; - var value; - - if (usingIterator) { - ret = typeof C === 'function' - ? new C() - : []; - var it = items[symbolIterator](); - var next; - - while (!(next = it.next()).done) { - value = next.value; - - if (mapping) { - value = mapFn.call(thisArg, value, key); - } - - ret[key] = value; - key += 1; - } - - ret.length = key; - return ret; - } - - var len = items.length; - if (isNaN(len) || len < 0) { - len = 0; - } - - ret = typeof C === 'function' - ? new C(len) - : new Array(len); - - while (key < len) { - value = items[key]; - - if (mapping) { - value = mapFn.call(thisArg, value, key); - } - - ret[key] = value; - - key += 1; - } - - ret.length = key; - return ret; - }; -} diff --git a/vendor/polyfills/String.prototype.es6.js b/vendor/polyfills/String.prototype.es6.js deleted file mode 100644 index a033f35e..00000000 --- a/vendor/polyfills/String.prototype.es6.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @polyfill - */ - -/* eslint-disable strict, no-extend-native, no-bitwise */ - -/* - * NOTE: We use (Number(x) || 0) to replace NaN values with zero. - */ - -if (!String.prototype.startsWith) { - String.prototype.startsWith = function(search) { - 'use strict'; - if (this == null) { - throw TypeError(); - } - var string = String(this); - var pos = arguments.length > 1 ? - (Number(arguments[1]) || 0) : 0; - var start = Math.min(Math.max(pos, 0), string.length); - return string.indexOf(String(search), pos) === start; - }; -} - -if (!String.prototype.endsWith) { - String.prototype.endsWith = function(search) { - 'use strict'; - if (this == null) { - throw TypeError(); - } - var string = String(this); - var stringLength = string.length; - var searchString = String(search); - var pos = arguments.length > 1 ? - (Number(arguments[1]) || 0) : stringLength; - var end = Math.min(Math.max(pos, 0), stringLength); - var start = end - searchString.length; - if (start < 0) { - return false; - } - return string.lastIndexOf(searchString, start) === start; - }; -} - -if (!String.prototype.repeat) { - String.prototype.repeat = function(count) { - 'use strict'; - if (this == null) { - throw TypeError(); - } - var string = String(this); - count = Number(count) || 0; - if (count < 0 || count === Infinity) { - throw RangeError(); - } - if (count === 1) { - return string; - } - var result = ''; - while (count) { - if (count & 1) { - result += string; - } - if ((count >>= 1)) { - string += string; - } - } - return result; - }; -} - -if (!String.prototype.includes) { - String.prototype.includes = function(search, start) { - 'use strict'; - if (typeof start !== 'number') { - start = 0; - } - - if (start + search.length > this.length) { - return false; - } else { - return this.indexOf(search, start) !== -1; - } - }; -} diff --git a/vendor/polyfills/babelHelpers.js b/vendor/polyfills/babelHelpers.js deleted file mode 100644 index 51cb4523..00000000 --- a/vendor/polyfills/babelHelpers.js +++ /dev/null @@ -1,247 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @polyfill - */ - -/* eslint-disable */ - -// Created by running: -// require('babel-core').buildExternalHelpers('_extends classCallCheck createClass createRawReactElement defineProperty get inherits interopRequireDefault interopRequireWildcard objectWithoutProperties possibleConstructorReturn slicedToArray taggedTemplateLiteral toArray toConsumableArray '.split(' ')) -// then replacing the `global` reference in the last line to also use `this`. -// -// actually, that's a lie, because babel6 omits _extends and createRawReactElement - -var babelHelpers = global.babelHelpers = {}; - -babelHelpers.typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; -} : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; -}; - -babelHelpers.createRawReactElement = (function () { - var REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7; - return function createRawReactElement(type, key, props) { - return { - $$typeof: REACT_ELEMENT_TYPE, - type: type, - key: key, - ref: null, - props: props, - _owner: null - }; - }; -})(); - -babelHelpers.classCallCheck = function (instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -}; - -babelHelpers.createClass = (function () { - function defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - return function (Constructor, protoProps, staticProps) { - if (protoProps) defineProperties(Constructor.prototype, protoProps); - if (staticProps) defineProperties(Constructor, staticProps); - return Constructor; - }; -})(); - -babelHelpers.defineEnumerableProperties = function(obj, descs) { - for (var key in descs) { - var desc = descs[key]; - desc.configurable = (desc.enumerable = true); - if ('value' in desc) desc.writable = true; - Object.defineProperty(obj, key, desc); - } - return obj; -}; - -babelHelpers.defineProperty = function (obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -}; - -babelHelpers._extends = babelHelpers.extends = Object.assign || function (target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i]; - - for (var key in source) { - if (Object.prototype.hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - } - - return target; -}; - -babelHelpers.get = function get(object, property, receiver) { - if (object === null) object = Function.prototype; - var desc = Object.getOwnPropertyDescriptor(object, property); - - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); - - if (parent === null) { - return undefined; - } else { - return get(parent, property, receiver); - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; - - if (getter === undefined) { - return undefined; - } - - return getter.call(receiver); - } -}; - -babelHelpers.inherits = function (subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - enumerable: false, - writable: true, - configurable: true - } - }); - if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; -}; - -babelHelpers.interopRequireDefault = function (obj) { - return obj && obj.__esModule ? obj : { - default: obj - }; -}; - -babelHelpers.interopRequireWildcard = function (obj) { - if (obj && obj.__esModule) { - return obj; - } else { - var newObj = {}; - - if (obj != null) { - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; - } - } - - newObj.default = obj; - return newObj; - } -}; - -babelHelpers.objectWithoutProperties = function (obj, keys) { - var target = {}; - - for (var i in obj) { - if (keys.indexOf(i) >= 0) continue; - if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; - target[i] = obj[i]; - } - - return target; -}; - -babelHelpers.possibleConstructorReturn = function (self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; -}; - -babelHelpers.slicedToArray = (function () { - function sliceIterator(arr, i) { - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"]) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; - } - - return function (arr, i) { - if (Array.isArray(arr)) { - return arr; - } else if (Symbol.iterator in Object(arr)) { - return sliceIterator(arr, i); - } else { - throw new TypeError("Invalid attempt to destructure non-iterable instance"); - } - }; -})(); - -babelHelpers.taggedTemplateLiteral = function (strings, raw) { - return Object.freeze(Object.defineProperties(strings, { - raw: { - value: Object.freeze(raw) - } - })); -}; - -babelHelpers.toArray = function (arr) { - return Array.isArray(arr) ? arr : Array.from(arr); -}; - -babelHelpers.toConsumableArray = function (arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - - return arr2; - } else { - return Array.from(arr); - } -}; diff --git a/yarn.lock b/yarn.lock index 43db8e15..f386f7e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -83,10 +83,6 @@ ajv-keywords@^1.0.0: version "1.5.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" -ajv-keywords@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" - ajv-keywords@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.1.0.tgz#ac2b27939c543e95d2c06e7f7f5c27be4aa543be" @@ -98,15 +94,6 @@ ajv@^4.7.0, ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.0.0: - version "5.5.2" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" - dependencies: - co "^4.6.0" - fast-deep-equal "^1.0.0" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.3.0" - ajv@^5.1.0: version "5.3.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.3.0.tgz#4414ff74a50879c208ee5fdc826e32c303549eda" @@ -1369,7 +1356,7 @@ block-stream@*: dependencies: inherits "~2.0.0" -bluebird@^3.5.0: +bluebird@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" @@ -1560,23 +1547,23 @@ bytes@2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.4.0.tgz#7d97196f9d5baf7f6935e25985549edd2a6c2339" -cacache@^10.0.1: - version "10.0.2" - resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.2.tgz#105a93a162bbedf3a25da42e1939ed99ffb145f8" +cacache@^10.0.4: + version "10.0.4" + resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.4.tgz#6452367999eff9d4188aefd9a14e9d7c6a263460" dependencies: - bluebird "^3.5.0" + bluebird "^3.5.1" chownr "^1.0.1" glob "^7.1.2" graceful-fs "^4.1.11" lru-cache "^4.1.1" - mississippi "^1.3.0" + mississippi "^2.0.0" mkdirp "^0.5.1" move-concurrently "^1.0.1" promise-inflight "^1.0.1" - rimraf "^2.6.1" - ssri "^5.0.0" + rimraf "^2.6.2" + ssri "^5.2.4" unique-filename "^1.1.0" - y18n "^3.2.1" + y18n "^4.0.0" cache-base@^1.0.1: version "1.0.1" @@ -4969,9 +4956,9 @@ minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -mississippi@^1.3.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-1.3.1.tgz#2a8bb465e86550ac8b36a7b6f45599171d78671e" +mississippi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-2.0.0.tgz#3442a508fafc28500486feea99409676e4ee5a6f" dependencies: concat-stream "^1.5.0" duplexify "^3.4.2" @@ -4979,7 +4966,7 @@ mississippi@^1.3.0: flush-write-stream "^1.0.0" from2 "^2.1.0" parallel-transform "^1.1.0" - pump "^1.0.0" + pump "^2.0.1" pumpify "^1.3.3" stream-each "^1.1.0" through2 "^2.0.0" @@ -5750,14 +5737,7 @@ public-encrypt@^4.0.0: parse-asn1 "^5.0.0" randombytes "^2.0.1" -pump@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" - dependencies: - end-of-stream "^1.1.0" - once "^1.3.1" - -pump@^2.0.0: +pump@^2.0.0, pump@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" dependencies: @@ -5829,14 +5809,14 @@ randombytes@^2.0.0, randombytes@^2.0.1: dependencies: safe-buffer "^5.1.0" -range-parser@^1.0.3, range-parser@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" - range-parser@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.0.3.tgz#6872823535c692e2c2a0103826afd82c2e0ff175" +range-parser@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + raw-body@~2.1.2: version "2.1.7" resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.1.7.tgz#adfeace2e4fb3098058014d08c072dcc59758774" @@ -6306,7 +6286,7 @@ rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.1: dependencies: glob "^7.0.5" -rimraf@^2.5.4: +rimraf@^2.5.4, rimraf@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: @@ -6391,12 +6371,12 @@ sax@~1.1.1: version "1.1.6" resolved "https://registry.yarnpkg.com/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240" -schema-utils@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.3.tgz#e2a594d3395834d5e15da22b48be13517859458e" +schema-utils@^0.4.4, schema-utils@^0.4.5: + version "0.4.5" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.5.tgz#21836f0608aac17b78f9e3e24daff14a5ca13a3e" dependencies: - ajv "^5.0.0" - ajv-keywords "^2.1.0" + ajv "^6.1.0" + ajv-keywords "^3.1.0" "semver@2 || 3 || 4 || 5", semver@5.x, semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0: version "5.4.1" @@ -6730,9 +6710,9 @@ sshpk@^1.7.0: jsbn "~0.1.0" tweetnacl "~0.14.0" -ssri@^5.0.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/ssri/-/ssri-5.2.1.tgz#8b6eb873688759bd3c75a88dee74593d179bb73c" +ssri@^5.2.4: + version "5.3.0" + resolved "https://registry.yarnpkg.com/ssri/-/ssri-5.3.0.tgz#ba3872c9c6d33a0704a7d71ff045e5ec48999d06" dependencies: safe-buffer "^5.1.1" @@ -7001,10 +6981,6 @@ time-stamp@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" -time-stamp@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-2.0.0.tgz#95c6a44530e15ba8d6f4a3ecb8c3a3fac46da357" - timers-browserify@^2.0.2: version "2.0.4" resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.4.tgz#96ca53f4b794a5e7c0e1bd7cc88a372298fa01e6" @@ -7147,13 +7123,13 @@ uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" -uglifyjs-webpack-plugin@^1.1.1: - version "1.1.8" - resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.1.8.tgz#1302fb9471a7daf3d0a5174da6d65f0f415e75ad" +uglifyjs-webpack-plugin@^1.2.4: + version "1.2.5" + resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz#2ef8387c8f1a903ec5e44fa36f9f3cbdcea67641" dependencies: - cacache "^10.0.1" + cacache "^10.0.4" find-cache-dir "^1.0.0" - schema-utils "^0.4.2" + schema-utils "^0.4.5" serialize-javascript "^1.4.0" source-map "^0.6.1" uglify-es "^3.3.4" @@ -7341,19 +7317,9 @@ webidl-conversions@^4.0.1, webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" -webpack-dev-middleware@^1.12.0: - version "1.12.0" - resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-1.12.0.tgz#d34efefb2edda7e1d3b5dbe07289513219651709" - dependencies: - memory-fs "~0.4.1" - mime "^1.3.4" - path-is-absolute "^1.0.0" - range-parser "^1.0.3" - time-stamp "^2.0.0" - -webpack-hot-middleware@^2.19.1: - version "2.19.1" - resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.19.1.tgz#5db32c31c955c1ead114d37c7519ea554da0d405" +webpack-hot-middleware@^2.22.1: + version "2.22.1" + resolved "https://registry.yarnpkg.com/webpack-hot-middleware/-/webpack-hot-middleware-2.22.1.tgz#2ff865bfebc8e9937bd1619f0f48d6ab601bfea0" dependencies: ansi-html "0.0.7" html-entities "^1.2.0" @@ -7374,9 +7340,9 @@ webpack-sources@^1.1.0: source-list-map "^2.0.0" source-map "~0.6.1" -webpack@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.1.0.tgz#91b6862e56eb3b18b79bb10b51866987ff10d2d6" +webpack@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.6.0.tgz#363eafa733710eb0ed28c512b2b9b9f5fb01e69b" dependencies: acorn "^5.0.0" acorn-dynamic-import "^3.0.0" @@ -7392,9 +7358,9 @@ webpack@^4.1.0: mkdirp "~0.5.0" neo-async "^2.5.0" node-libs-browser "^2.0.0" - schema-utils "^0.4.2" + schema-utils "^0.4.4" tapable "^1.0.0" - uglifyjs-webpack-plugin "^1.1.1" + uglifyjs-webpack-plugin "^1.2.4" watchpack "^1.5.0" webpack-sources "^1.0.1" @@ -7581,6 +7547,10 @@ y18n@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" +y18n@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" + yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"