From b4147390e0bf64bf1f4146d001865961b91b8a87 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Fri, 13 Jul 2018 08:09:30 +0200 Subject: [PATCH 1/9] Adds TS support --- .../{adblock_actions.js => adblock_actions.ts} | 0 .../{brave_adblock.js => brave_adblock.tsx} | 0 .../brave_adblock_ui/components/{app.js => app.tsx} | 0 .../constants/{adblock_types.js => adblock_types.ts} | 0 .../{adblock_reducer.js => adblock_reducer.ts} | 0 .../brave_adblock_ui/reducers/{index.js => index.ts} | 0 .../brave_adblock_ui/{storage.js => storage.ts} | 0 components/brave_adblock_ui/{store.js => store.ts} | 0 .../actions/{newTabActions.js => newTabActions.ts} | 0 components/brave_new_tab_ui/{api.js => api.ts} | 0 .../{backgrounds.js => backgrounds.ts} | 0 .../{brave_new_tab.js => brave_new_tab.tsx} | 0 .../brave_new_tab_ui/components/{app.js => app.tsx} | 0 .../components/{block.js => block.tsx} | 0 .../components/{footerInfo.js => footerInfo.tsx} | 0 .../{newPrivateTab.js => newPrivateTab.tsx} | 0 ...valNotification.js => siteRemovalNotification.tsx} | 0 .../components/{stats.js => stats.tsx} | 0 .../components/{theme.js => theme.tsx} | 0 .../constants/{newTabTypes.js => newTabTypes.ts} | 0 .../brave_new_tab_ui/reducers/{index.js => index.ts} | 0 .../reducers/{newTabReducer.js => newTabReducer.tsx} | 0 .../brave_new_tab_ui/{storage.js => storage.ts} | 0 components/brave_new_tab_ui/{store.js => store.ts} | 0 .../{rewards_actions.js => rewards_actions.ts} | 0 .../{brave_rewards.js => brave_rewards.tsx} | 0 .../brave_rewards_ui/components/{app.js => app.ts} | 0 .../constants/{rewards_types.js => rewards_types.ts} | 0 .../brave_rewards_ui/reducers/{index.js => index.ts} | 0 .../{rewards_reducer.js => rewards_reducer.ts} | 0 .../brave_rewards_ui/{storage.js => storage.ts} | 0 components/brave_rewards_ui/{store.js => store.ts} | 0 .../{welcome_actions.js => welcome_actions.ts} | 0 .../{brave_welcome.js => brave_welcome.tsx} | 0 .../brave_welcome_ui/components/{app.js => app.tsx} | 0 .../constants/{welcome_types.js => welcome_types.ts} | 0 .../brave_welcome_ui/reducers/{index.js => index.ts} | 0 .../{welcome_reducer.js => welcome_reducer.ts} | 0 .../brave_welcome_ui/{storage.js => storage.ts} | 0 components/brave_welcome_ui/{store.js => store.ts} | 0 components/common/{classSet.js => classSet.ts} | 1 + components/common/{debounce.js => debounce.ts} | 0 components/common/{locale.js => locale.ts} | 6 +++--- components/webpack/dev.config.js | 11 ++++------- components/webpack/prod.config.js | 6 +----- 45 files changed, 9 insertions(+), 15 deletions(-) rename components/brave_adblock_ui/actions/{adblock_actions.js => adblock_actions.ts} (100%) rename components/brave_adblock_ui/{brave_adblock.js => brave_adblock.tsx} (100%) rename components/brave_adblock_ui/components/{app.js => app.tsx} (100%) rename components/brave_adblock_ui/constants/{adblock_types.js => adblock_types.ts} (100%) rename components/brave_adblock_ui/reducers/{adblock_reducer.js => adblock_reducer.ts} (100%) rename components/brave_adblock_ui/reducers/{index.js => index.ts} (100%) rename components/brave_adblock_ui/{storage.js => storage.ts} (100%) rename components/brave_adblock_ui/{store.js => store.ts} (100%) rename components/brave_new_tab_ui/actions/{newTabActions.js => newTabActions.ts} (100%) rename components/brave_new_tab_ui/{api.js => api.ts} (100%) rename components/brave_new_tab_ui/{backgrounds.js => backgrounds.ts} (100%) rename components/brave_new_tab_ui/{brave_new_tab.js => brave_new_tab.tsx} (100%) rename components/brave_new_tab_ui/components/{app.js => app.tsx} (100%) rename components/brave_new_tab_ui/components/{block.js => block.tsx} (100%) rename components/brave_new_tab_ui/components/{footerInfo.js => footerInfo.tsx} (100%) rename components/brave_new_tab_ui/components/{newPrivateTab.js => newPrivateTab.tsx} (100%) rename components/brave_new_tab_ui/components/{siteRemovalNotification.js => siteRemovalNotification.tsx} (100%) rename components/brave_new_tab_ui/components/{stats.js => stats.tsx} (100%) rename components/brave_new_tab_ui/components/{theme.js => theme.tsx} (100%) rename components/brave_new_tab_ui/constants/{newTabTypes.js => newTabTypes.ts} (100%) rename components/brave_new_tab_ui/reducers/{index.js => index.ts} (100%) rename components/brave_new_tab_ui/reducers/{newTabReducer.js => newTabReducer.tsx} (100%) rename components/brave_new_tab_ui/{storage.js => storage.ts} (100%) rename components/brave_new_tab_ui/{store.js => store.ts} (100%) rename components/brave_rewards_ui/actions/{rewards_actions.js => rewards_actions.ts} (100%) rename components/brave_rewards_ui/{brave_rewards.js => brave_rewards.tsx} (100%) rename components/brave_rewards_ui/components/{app.js => app.ts} (100%) rename components/brave_rewards_ui/constants/{rewards_types.js => rewards_types.ts} (100%) rename components/brave_rewards_ui/reducers/{index.js => index.ts} (100%) rename components/brave_rewards_ui/reducers/{rewards_reducer.js => rewards_reducer.ts} (100%) rename components/brave_rewards_ui/{storage.js => storage.ts} (100%) rename components/brave_rewards_ui/{store.js => store.ts} (100%) rename components/brave_welcome_ui/actions/{welcome_actions.js => welcome_actions.ts} (100%) rename components/brave_welcome_ui/{brave_welcome.js => brave_welcome.tsx} (100%) rename components/brave_welcome_ui/components/{app.js => app.tsx} (100%) rename components/brave_welcome_ui/constants/{welcome_types.js => welcome_types.ts} (100%) rename components/brave_welcome_ui/reducers/{index.js => index.ts} (100%) rename components/brave_welcome_ui/reducers/{welcome_reducer.js => welcome_reducer.ts} (100%) rename components/brave_welcome_ui/{storage.js => storage.ts} (100%) rename components/brave_welcome_ui/{store.js => store.ts} (100%) rename components/common/{classSet.js => classSet.ts} (95%) rename components/common/{debounce.js => debounce.ts} (100%) rename components/common/{locale.js => locale.ts} (72%) diff --git a/components/brave_adblock_ui/actions/adblock_actions.js b/components/brave_adblock_ui/actions/adblock_actions.ts similarity index 100% rename from components/brave_adblock_ui/actions/adblock_actions.js rename to components/brave_adblock_ui/actions/adblock_actions.ts diff --git a/components/brave_adblock_ui/brave_adblock.js b/components/brave_adblock_ui/brave_adblock.tsx similarity index 100% rename from components/brave_adblock_ui/brave_adblock.js rename to components/brave_adblock_ui/brave_adblock.tsx diff --git a/components/brave_adblock_ui/components/app.js b/components/brave_adblock_ui/components/app.tsx similarity index 100% rename from components/brave_adblock_ui/components/app.js rename to components/brave_adblock_ui/components/app.tsx diff --git a/components/brave_adblock_ui/constants/adblock_types.js b/components/brave_adblock_ui/constants/adblock_types.ts similarity index 100% rename from components/brave_adblock_ui/constants/adblock_types.js rename to components/brave_adblock_ui/constants/adblock_types.ts diff --git a/components/brave_adblock_ui/reducers/adblock_reducer.js b/components/brave_adblock_ui/reducers/adblock_reducer.ts similarity index 100% rename from components/brave_adblock_ui/reducers/adblock_reducer.js rename to components/brave_adblock_ui/reducers/adblock_reducer.ts diff --git a/components/brave_adblock_ui/reducers/index.js b/components/brave_adblock_ui/reducers/index.ts similarity index 100% rename from components/brave_adblock_ui/reducers/index.js rename to components/brave_adblock_ui/reducers/index.ts diff --git a/components/brave_adblock_ui/storage.js b/components/brave_adblock_ui/storage.ts similarity index 100% rename from components/brave_adblock_ui/storage.js rename to components/brave_adblock_ui/storage.ts diff --git a/components/brave_adblock_ui/store.js b/components/brave_adblock_ui/store.ts similarity index 100% rename from components/brave_adblock_ui/store.js rename to components/brave_adblock_ui/store.ts diff --git a/components/brave_new_tab_ui/actions/newTabActions.js b/components/brave_new_tab_ui/actions/newTabActions.ts similarity index 100% rename from components/brave_new_tab_ui/actions/newTabActions.js rename to components/brave_new_tab_ui/actions/newTabActions.ts diff --git a/components/brave_new_tab_ui/api.js b/components/brave_new_tab_ui/api.ts similarity index 100% rename from components/brave_new_tab_ui/api.js rename to components/brave_new_tab_ui/api.ts diff --git a/components/brave_new_tab_ui/backgrounds.js b/components/brave_new_tab_ui/backgrounds.ts similarity index 100% rename from components/brave_new_tab_ui/backgrounds.js rename to components/brave_new_tab_ui/backgrounds.ts diff --git a/components/brave_new_tab_ui/brave_new_tab.js b/components/brave_new_tab_ui/brave_new_tab.tsx similarity index 100% rename from components/brave_new_tab_ui/brave_new_tab.js rename to components/brave_new_tab_ui/brave_new_tab.tsx diff --git a/components/brave_new_tab_ui/components/app.js b/components/brave_new_tab_ui/components/app.tsx similarity index 100% rename from components/brave_new_tab_ui/components/app.js rename to components/brave_new_tab_ui/components/app.tsx diff --git a/components/brave_new_tab_ui/components/block.js b/components/brave_new_tab_ui/components/block.tsx similarity index 100% rename from components/brave_new_tab_ui/components/block.js rename to components/brave_new_tab_ui/components/block.tsx diff --git a/components/brave_new_tab_ui/components/footerInfo.js b/components/brave_new_tab_ui/components/footerInfo.tsx similarity index 100% rename from components/brave_new_tab_ui/components/footerInfo.js rename to components/brave_new_tab_ui/components/footerInfo.tsx diff --git a/components/brave_new_tab_ui/components/newPrivateTab.js b/components/brave_new_tab_ui/components/newPrivateTab.tsx similarity index 100% rename from components/brave_new_tab_ui/components/newPrivateTab.js rename to components/brave_new_tab_ui/components/newPrivateTab.tsx diff --git a/components/brave_new_tab_ui/components/siteRemovalNotification.js b/components/brave_new_tab_ui/components/siteRemovalNotification.tsx similarity index 100% rename from components/brave_new_tab_ui/components/siteRemovalNotification.js rename to components/brave_new_tab_ui/components/siteRemovalNotification.tsx diff --git a/components/brave_new_tab_ui/components/stats.js b/components/brave_new_tab_ui/components/stats.tsx similarity index 100% rename from components/brave_new_tab_ui/components/stats.js rename to components/brave_new_tab_ui/components/stats.tsx diff --git a/components/brave_new_tab_ui/components/theme.js b/components/brave_new_tab_ui/components/theme.tsx similarity index 100% rename from components/brave_new_tab_ui/components/theme.js rename to components/brave_new_tab_ui/components/theme.tsx diff --git a/components/brave_new_tab_ui/constants/newTabTypes.js b/components/brave_new_tab_ui/constants/newTabTypes.ts similarity index 100% rename from components/brave_new_tab_ui/constants/newTabTypes.js rename to components/brave_new_tab_ui/constants/newTabTypes.ts diff --git a/components/brave_new_tab_ui/reducers/index.js b/components/brave_new_tab_ui/reducers/index.ts similarity index 100% rename from components/brave_new_tab_ui/reducers/index.js rename to components/brave_new_tab_ui/reducers/index.ts diff --git a/components/brave_new_tab_ui/reducers/newTabReducer.js b/components/brave_new_tab_ui/reducers/newTabReducer.tsx similarity index 100% rename from components/brave_new_tab_ui/reducers/newTabReducer.js rename to components/brave_new_tab_ui/reducers/newTabReducer.tsx diff --git a/components/brave_new_tab_ui/storage.js b/components/brave_new_tab_ui/storage.ts similarity index 100% rename from components/brave_new_tab_ui/storage.js rename to components/brave_new_tab_ui/storage.ts diff --git a/components/brave_new_tab_ui/store.js b/components/brave_new_tab_ui/store.ts similarity index 100% rename from components/brave_new_tab_ui/store.js rename to components/brave_new_tab_ui/store.ts diff --git a/components/brave_rewards_ui/actions/rewards_actions.js b/components/brave_rewards_ui/actions/rewards_actions.ts similarity index 100% rename from components/brave_rewards_ui/actions/rewards_actions.js rename to components/brave_rewards_ui/actions/rewards_actions.ts diff --git a/components/brave_rewards_ui/brave_rewards.js b/components/brave_rewards_ui/brave_rewards.tsx similarity index 100% rename from components/brave_rewards_ui/brave_rewards.js rename to components/brave_rewards_ui/brave_rewards.tsx diff --git a/components/brave_rewards_ui/components/app.js b/components/brave_rewards_ui/components/app.ts similarity index 100% rename from components/brave_rewards_ui/components/app.js rename to components/brave_rewards_ui/components/app.ts diff --git a/components/brave_rewards_ui/constants/rewards_types.js b/components/brave_rewards_ui/constants/rewards_types.ts similarity index 100% rename from components/brave_rewards_ui/constants/rewards_types.js rename to components/brave_rewards_ui/constants/rewards_types.ts diff --git a/components/brave_rewards_ui/reducers/index.js b/components/brave_rewards_ui/reducers/index.ts similarity index 100% rename from components/brave_rewards_ui/reducers/index.js rename to components/brave_rewards_ui/reducers/index.ts diff --git a/components/brave_rewards_ui/reducers/rewards_reducer.js b/components/brave_rewards_ui/reducers/rewards_reducer.ts similarity index 100% rename from components/brave_rewards_ui/reducers/rewards_reducer.js rename to components/brave_rewards_ui/reducers/rewards_reducer.ts diff --git a/components/brave_rewards_ui/storage.js b/components/brave_rewards_ui/storage.ts similarity index 100% rename from components/brave_rewards_ui/storage.js rename to components/brave_rewards_ui/storage.ts diff --git a/components/brave_rewards_ui/store.js b/components/brave_rewards_ui/store.ts similarity index 100% rename from components/brave_rewards_ui/store.js rename to components/brave_rewards_ui/store.ts diff --git a/components/brave_welcome_ui/actions/welcome_actions.js b/components/brave_welcome_ui/actions/welcome_actions.ts similarity index 100% rename from components/brave_welcome_ui/actions/welcome_actions.js rename to components/brave_welcome_ui/actions/welcome_actions.ts diff --git a/components/brave_welcome_ui/brave_welcome.js b/components/brave_welcome_ui/brave_welcome.tsx similarity index 100% rename from components/brave_welcome_ui/brave_welcome.js rename to components/brave_welcome_ui/brave_welcome.tsx diff --git a/components/brave_welcome_ui/components/app.js b/components/brave_welcome_ui/components/app.tsx similarity index 100% rename from components/brave_welcome_ui/components/app.js rename to components/brave_welcome_ui/components/app.tsx diff --git a/components/brave_welcome_ui/constants/welcome_types.js b/components/brave_welcome_ui/constants/welcome_types.ts similarity index 100% rename from components/brave_welcome_ui/constants/welcome_types.js rename to components/brave_welcome_ui/constants/welcome_types.ts diff --git a/components/brave_welcome_ui/reducers/index.js b/components/brave_welcome_ui/reducers/index.ts similarity index 100% rename from components/brave_welcome_ui/reducers/index.js rename to components/brave_welcome_ui/reducers/index.ts diff --git a/components/brave_welcome_ui/reducers/welcome_reducer.js b/components/brave_welcome_ui/reducers/welcome_reducer.ts similarity index 100% rename from components/brave_welcome_ui/reducers/welcome_reducer.js rename to components/brave_welcome_ui/reducers/welcome_reducer.ts diff --git a/components/brave_welcome_ui/storage.js b/components/brave_welcome_ui/storage.ts similarity index 100% rename from components/brave_welcome_ui/storage.js rename to components/brave_welcome_ui/storage.ts diff --git a/components/brave_welcome_ui/store.js b/components/brave_welcome_ui/store.ts similarity index 100% rename from components/brave_welcome_ui/store.js rename to components/brave_welcome_ui/store.ts diff --git a/components/common/classSet.js b/components/common/classSet.ts similarity index 95% rename from components/common/classSet.js rename to components/common/classSet.ts index 06d186d40d6b..24fc82503079 100644 --- a/components/common/classSet.js +++ b/components/common/classSet.ts @@ -6,4 +6,5 @@ * Converts an object with boolean properties to a CSS string. * Only the property names with truthy values are included. */ +// TODO remove NZ module.exports = (obj) => Object.keys(obj).filter((prop) => obj[prop]).join(' ') diff --git a/components/common/debounce.js b/components/common/debounce.ts similarity index 100% rename from components/common/debounce.js rename to components/common/debounce.ts diff --git a/components/common/locale.js b/components/common/locale.ts similarity index 72% rename from components/common/locale.js rename to components/common/locale.ts index 22f220f91dd9..41ad7b923d8e 100644 --- a/components/common/locale.js +++ b/components/common/locale.ts @@ -3,12 +3,12 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ 'use strict' +// TODO optimize NZ +declare let window: any; /** * Gets the localized string * @param {string} text - the locale string to translate * @returns {string} - the localized string */ -const getLocale = (text) => window.loadTimeData && window.loadTimeData.getString(text) - -module.exports = { getLocale } +export const getLocale = (text) => window.loadTimeData && window.loadTimeData.getString(text) diff --git a/components/webpack/dev.config.js b/components/webpack/dev.config.js index da03ba3768d6..4640bdebcf9c 100644 --- a/components/webpack/dev.config.js +++ b/components/webpack/dev.config.js @@ -2,6 +2,7 @@ const path = require('path') const webpack = require('webpack') module.exports = { + mode: 'development', devtool: '#inline-source-map', entry: { brave_adblock: path.join(__dirname, '../brave_adblock_ui/brave_adblock'), @@ -16,12 +17,7 @@ module.exports = { }, plugins: [ new webpack.optimize.OccurrenceOrderPlugin(), - new webpack.IgnorePlugin(/[^/]+\/[\S]+.dev$/), - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify('development') - } - }) + new webpack.IgnorePlugin(/[^/]+\/[\S]+.dev$/) ], resolve: { extensions: ['.ts', '.tsx', '.js'] @@ -30,7 +26,7 @@ module.exports = { rules: [ { test: /\.tsx?$/, - loader: 'awesome-typescript-loader' + loader: 'awesome-typescript-loader', }, { test: /\.js$/, @@ -59,3 +55,4 @@ module.exports = { }] } } + diff --git a/components/webpack/prod.config.js b/components/webpack/prod.config.js index c813b3e5c7aa..5107b115af09 100644 --- a/components/webpack/prod.config.js +++ b/components/webpack/prod.config.js @@ -3,6 +3,7 @@ const webpack = require('webpack') const UglifyJSPlugin = require('uglifyjs-webpack-plugin') module.exports = { + mode: 'production', entry: { brave_adblock: path.join(__dirname, '../brave_adblock_ui/brave_adblock'), brave_new_tab: path.join(__dirname, '../brave_new_tab_ui/brave_new_tab'), @@ -27,11 +28,6 @@ module.exports = { warnings: false } } - }), - new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify('production') - } }) ], resolve: { From a489016a2b80faaa6e8b3e06b55fc59229cc3097 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Sat, 14 Jul 2018 10:01:20 +0200 Subject: [PATCH 2/9] Adds tslint, travis Adds ts-loader; Removes standard --- .travis.yml | 47 +- components/definitions/chromel.d.ts | 11 + components/webpack/dev.config.js | 2 +- package-lock.json | 1964 ++++++--------------------- package.json | 16 +- tsconfig.json | 28 + tslint.json | 6 + 7 files changed, 479 insertions(+), 1595 deletions(-) create mode 100644 components/definitions/chromel.d.ts create mode 100644 tsconfig.json create mode 100644 tslint.json diff --git a/.travis.yml b/.travis.yml index 9c2776315f3a..a9c6ca372f75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,32 @@ -git: - depth: 10 -notifications: - email: false - language: node_js node_js: - - "4" -os: - - linux - - osx -env: - - TARGET_ARCH=x64 -osx_image: xcode7.3 - -matrix: - include: - - os: linux - env: TARGET_ARCH=arm - - os: linux - env: TARGET_ARCH=ia32 - allow_failures: - - os: osx + - "node" -script: './script/cibuild' +dist: trusty branches: only: - master + - /\d+\.\d+\.x/ + +cache: + directories: + - $HOME/.npm + - node_modules + +env: + - TEST_SUITE=lint + - TEST_SUITE=test-security + +before_install: + - npm i -g npm + - npm --version + +install: + - npm i + +script: + - npm run $TEST_SUITE + + + diff --git a/components/definitions/chromel.d.ts b/components/definitions/chromel.d.ts new file mode 100644 index 000000000000..b0b27b01008c --- /dev/null +++ b/components/definitions/chromel.d.ts @@ -0,0 +1,11 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +declare namespace chrome { + function getVariableValue(stat: string): string + + const extension: { + inIncognitoContext: boolean + } +} diff --git a/components/webpack/dev.config.js b/components/webpack/dev.config.js index 4640bdebcf9c..4234c71b6f78 100644 --- a/components/webpack/dev.config.js +++ b/components/webpack/dev.config.js @@ -26,7 +26,7 @@ module.exports = { rules: [ { test: /\.tsx?$/, - loader: 'awesome-typescript-loader', + loader: 'ts-loader' }, { test: /\.js$/, diff --git a/package-lock.json b/package-lock.json index 010eda834e0f..adad04f1139f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,50 +4,63 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "acorn": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", + "@types/node": { + "version": "10.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", + "integrity": "sha512-m9zXmifkZsMHZBOyxZWilMwmTlpC8x5Ty360JKTiXvlXZfBWYpsg9ZZvP/Ye+iZUh+Q+MxDLjItVTWIsfwz+8Q==", "dev": true }, - "acorn-jsx": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", - "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", + "@types/react": { + "version": "16.4.6", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.4.6.tgz", + "integrity": "sha512-9LDZdhsuKSc+DjY65SjBkA958oBWcTWSVWAd2cD9XqKBjhGw1KzAkRhWRw2eIsXvaIE/TOTjjKMFVC+JA1iU4g==", "dev": true, "requires": { - "acorn": "3.3.0" - }, - "dependencies": { - "acorn": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", - "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", - "dev": true - } + "csstype": "^2.2.0" } }, - "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", + "@types/react-dom": { + "version": "16.0.6", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.0.6.tgz", + "integrity": "sha512-M+1zmwa5KxUpkCuxA4whlDJKYTGNvNQW4pIoCLH16xGbClicD9CzPry4y94kTjCCk/bJZCZ/GVqUsP7eKcO/mQ==", "dev": true, "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" + "@types/node": "*", + "@types/react": "*" } }, - "ajv-keywords": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", - "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", - "dev": true + "@types/react-redux": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-6.0.4.tgz", + "integrity": "sha512-mM6nuIw4PhLciGliJfu/Bc7Knl1BVkoe/wPbtJYEeGaMG3k+LNAvEjEDFY0KSmKJz691hmzw2gO7VLXz7vN6gg==", + "dev": true, + "requires": { + "@types/react": "*", + "redux": "^4.0.0" + } }, - "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", - "dev": true + "@types/redux-logger": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/redux-logger/-/redux-logger-3.0.6.tgz", + "integrity": "sha512-HXVJnbyuTcVtQ+qiwDcbLEMoOgNjKnNYVKx29P4NhV+FIgVVRCFILEPzjgSxlmMLc6aBVaEew7PfE3421DZ6Jw==", + "dev": true, + "requires": { + "redux": "^3.6.0" + }, + "dependencies": { + "redux": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/redux/-/redux-3.7.2.tgz", + "integrity": "sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A==", + "dev": true, + "requires": { + "lodash": "^4.2.1", + "lodash-es": "^4.2.1", + "loose-envify": "^1.1.0", + "symbol-observable": "^1.0.3" + } + } + } }, "ansi-regex": { "version": "2.1.1", @@ -67,40 +80,9 @@ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "sprintf-js": "1.0.3" - } - }, - "array-union": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true, - "requires": { - "array-uniq": "1.0.3" - } - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, - "array.prototype.find": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/array.prototype.find/-/array.prototype.find-2.0.4.tgz", - "integrity": "sha1-VWpcU2LAhkgyPdrrnenRS8GGTJA=", - "dev": true, - "requires": { - "define-properties": "1.1.2", - "es-abstract": "1.12.0" + "sprintf-js": "~1.0.2" } }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, "asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -112,9 +94,36 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } } }, "balanced-match": { @@ -134,7 +143,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -143,8 +152,8 @@ "resolved": "https://registry.npmjs.org/brave-ui/-/brave-ui-0.12.2.tgz", "integrity": "sha512-/XD9k+3s7Z8L5BUqjmzQf42YfOoNodms07L8oygp2Et+s3PTxQQaHTHf82MABJDle9OlFzgG4h2X64O7f0OqTg==", "requires": { - "emptykit.css": "1.0.1", - "styled-components": "3.3.3" + "emptykit.css": "^1.0.1", + "styled-components": "^3.2.6" } }, "buffer": { @@ -152,89 +161,72 @@ "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.1.0.tgz", "integrity": "sha512-YkIRgwsZwJWTnyQrsBTWefizHh+8GYj3kbL1BTiAQ/9pwpino0G7B2gp5tx/FUBqUlvtxV85KNR3mwfAtv15Yw==", "requires": { - "base64-js": "1.3.0", - "ieee754": "1.1.12" + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" } }, - "buffer-from": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", - "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==", - "dev": true - }, "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "requires": { - "callsites": "0.2.0" - } - }, - "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", - "dev": true - }, "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" }, "dependencies": { - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } } } }, - "circular-json": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", - "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", - "dev": true - }, - "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "color-convert": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", + "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", "dev": true, "requires": { - "restore-cursor": "1.0.1" + "color-name": "1.1.1" } }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", - "dev": true - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", "dev": true }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "commander": { + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.16.0.tgz", + "integrity": "sha512-sVXqklSaotK9at437sFlFpyOcJonxe0yST/AG9DkQKUdIE6IqGIMv4SfAQSKaJbSdVEJYItASCrBiVQHq1HQew==", "dev": true }, "concat-map": { @@ -243,35 +235,11 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", - "dev": true, - "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "typedarray": "0.0.6" - } - }, - "contains-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", - "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", - "dev": true - }, "core-js": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, "css-color-keywords": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", @@ -282,87 +250,39 @@ "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-2.2.1.tgz", "integrity": "sha512-v++LRcf633phJiYZBDqtmGPj3+BVof0isd2jgwYLWZJ5YSuhCkrfYtDsNhM6oJthiEco0f9tDVJ1vUkDJNgGEA==", "requires": { - "css-color-keywords": "1.0.0", - "fbjs": "0.8.17", - "postcss-value-parser": "3.3.0" - } - }, - "d": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", - "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", - "dev": true, - "requires": { - "es5-ext": "0.10.45" - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" + "css-color-keywords": "^1.0.0", + "fbjs": "^0.8.5", + "postcss-value-parser": "^3.3.0" } }, - "debug-log": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/debug-log/-/debug-log-1.0.1.tgz", - "integrity": "sha1-IwdjLUwEOCuN+KMvcLiVBG1SdF8=", + "csstype": { + "version": "2.5.5", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.5.5.tgz", + "integrity": "sha512-EGMjeoiN3aqEX5u/cyH5mSdGBDGdLcCQvcEcBWNGFSPXKd9uOTIeVG91YQ22OxI44DKpvI+4C7VUSmEpsHWJaA==", "dev": true }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, - "define-properties": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", - "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", - "dev": true, - "requires": { - "foreach": "2.0.5", - "object-keys": "1.0.12" - } - }, - "deglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/deglob/-/deglob-2.1.1.tgz", - "integrity": "sha512-2kjwuGGonL7gWE1XU4Fv79+vVzpoQCl0V+boMwWtOQJV2AGDabCwez++nB1Nli/8BabAfZQ/UuHPlp6AymKdWw==", - "dev": true, - "requires": { - "find-root": "1.1.0", - "glob": "7.1.2", - "ignore": "3.3.10", - "pkg-config": "1.1.1", - "run-parallel": "1.1.9", - "uniq": "1.0.1" - } - }, - "del": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", - "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", - "dev": true, - "requires": { - "globby": "5.0.0", - "is-path-cwd": "1.0.0", - "is-path-in-cwd": "1.0.1", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "rimraf": "2.6.2" - } - }, "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", + "integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=", "dev": true, "requires": { - "esutils": "2.0.2" + "esutils": "^1.1.6", + "isarray": "0.0.1" + }, + "dependencies": { + "esutils": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", + "integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=", + "dev": true + } } }, "emptykit.css": { @@ -375,929 +295,199 @@ "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", "requires": { - "iconv-lite": "0.4.23" + "iconv-lite": "~0.4.13" } }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "requires": { - "is-arrayish": "0.2.1" - } + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true }, - "es-abstract": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz", - "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==", - "dev": true, - "requires": { - "es-to-primitive": "1.1.1", - "function-bind": "1.1.1", - "has": "1.0.3", - "is-callable": "1.1.4", - "is-regex": "1.0.4" - } + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true }, - "es-to-primitive": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz", - "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", - "dev": true, - "requires": { - "is-callable": "1.1.4", - "is-date-object": "1.0.1", - "is-symbol": "1.0.1" - } + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true }, - "es5-ext": { - "version": "0.10.45", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.45.tgz", - "integrity": "sha512-FkfM6Vxxfmztilbxxz5UKSD4ICMf5tSpRFtDNtkAhOxZ0EKtX6qwmXNyH/sFyIbX2P/nU5AMiA9jilWsUGJzCQ==", - "dev": true, + "fbjs": { + "version": "0.8.17", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", + "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", "requires": { - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1", - "next-tick": "1.0.0" + "core-js": "^1.0.0", + "isomorphic-fetch": "^2.1.1", + "loose-envify": "^1.0.0", + "object-assign": "^4.1.0", + "promise": "^7.1.1", + "setimmediate": "^1.0.5", + "ua-parser-js": "^0.7.18" } }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45", - "es6-symbol": "3.1.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, - "es6-map": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", - "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45", - "es6-iterator": "2.0.3", - "es6-set": "0.1.5", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" + "ansi-regex": "^2.0.0" } }, - "es6-set": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", - "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", - "dev": true, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=" + }, + "hoist-non-react-statics": { + "version": "2.5.5", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", + "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45", - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1", - "event-emitter": "0.3.5" + "safer-buffer": ">= 2.1.2 < 3" } }, - "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "ieee754": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", + "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45" + "once": "^1.3.0", + "wrappy": "1" } }, - "es6-weak-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", - "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", - "dev": true, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45", - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1" + "isobject": "^3.0.1" } }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, - "escope": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", - "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", - "dev": true, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" + }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", "requires": { - "es6-map": "0.1.5", - "es6-weak-map": "2.0.2", - "esrecurse": "4.2.1", - "estraverse": "4.2.0" + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" } }, - "eslint": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.19.0.tgz", - "integrity": "sha1-yPxiAcf0DdCJQbh8CFdnOGpnmsw=", + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "chalk": "1.1.3", - "concat-stream": "1.6.2", - "debug": "2.6.9", - "doctrine": "2.1.0", - "escope": "3.6.0", - "espree": "3.5.4", - "esquery": "1.0.1", - "estraverse": "4.2.0", - "esutils": "2.0.2", - "file-entry-cache": "2.0.0", - "glob": "7.1.2", - "globals": "9.18.0", - "ignore": "3.3.10", - "imurmurhash": "0.1.4", - "inquirer": "0.12.0", - "is-my-json-valid": "2.17.2", - "is-resolvable": "1.1.0", - "js-yaml": "3.12.0", - "json-stable-stringify": "1.0.1", - "levn": "0.3.0", - "lodash": "4.17.10", - "mkdirp": "0.5.1", - "natural-compare": "1.4.0", - "optionator": "0.8.2", - "path-is-inside": "1.0.2", - "pluralize": "1.2.1", - "progress": "1.1.8", - "require-uncached": "1.0.3", - "shelljs": "0.7.8", - "strip-bom": "3.0.0", - "strip-json-comments": "2.0.1", - "table": "3.8.3", - "text-table": "0.2.0", - "user-home": "2.0.0" + "argparse": "^1.0.7", + "esprima": "^4.0.0" } }, - "eslint-config-standard": { - "version": "10.2.1", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz", - "integrity": "sha1-wGHk0GbzedwXzVYsZOgZtN1FRZE=", + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", "dev": true }, - "eslint-config-standard-jsx": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/eslint-config-standard-jsx/-/eslint-config-standard-jsx-4.0.2.tgz", - "integrity": "sha512-F8fRh2WFnTek7dZH9ZaE0PCBwdVGkwVWZmizla/DDNOmg7Tx6B/IlK5+oYpiX29jpu73LszeJj5i1axEZv6VMw==", + "lodash-es": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.10.tgz", + "integrity": "sha512-iesFYPmxYYGTcmQK0sL8bX3TGHyM6b2qREaB4kamHfQyfPJP0xgoGxp19nsH16nsfquLdiyKyX3mQkfiSGV8Rg==", "dev": true }, - "eslint-import-resolver-node": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz", - "integrity": "sha1-Wt2BBujJKNssuiMrzZ76hG49oWw=", - "dev": true, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "requires": { - "debug": "2.6.9", - "object-assign": "4.1.1", - "resolve": "1.8.1" + "js-tokens": "^3.0.0 || ^4.0.0" } }, - "eslint-module-utils": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz", - "integrity": "sha1-snA2LNiLGkitMIl2zn+lTphBF0Y=", + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "debug": "2.6.9", - "pkg-dir": "1.0.0" + "brace-expansion": "^1.1.7" } }, - "eslint-plugin-import": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.2.0.tgz", - "integrity": "sha1-crowb60wXWfEgWNIpGmaQimsi04=", - "dev": true, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", "requires": { - "builtin-modules": "1.1.1", - "contains-path": "0.1.0", - "debug": "2.6.9", - "doctrine": "1.5.0", - "eslint-import-resolver-node": "0.2.3", - "eslint-module-utils": "2.2.0", - "has": "1.0.3", - "lodash.cond": "4.5.2", - "minimatch": "3.0.4", - "pkg-up": "1.0.0" - }, - "dependencies": { - "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", - "dev": true, - "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" - } - } + "encoding": "^0.1.11", + "is-stream": "^1.0.1" } }, - "eslint-plugin-node": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-4.2.3.tgz", - "integrity": "sha512-vIUQPuwbVYdz/CYnlTLsJrRy7iXHQjdEe5wz0XhhdTym3IInM/zZLlPf9nZ2mThsH0QcsieCOWs2vOeCy/22LQ==", - "dev": true, - "requires": { - "ignore": "3.3.10", - "minimatch": "3.0.4", - "object-assign": "4.1.1", - "resolve": "1.8.1", - "semver": "5.3.0" - } - }, - "eslint-plugin-promise": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz", - "integrity": "sha1-ePu2/+BHIBYnVp6FpsU3OvKmj8o=", - "dev": true - }, - "eslint-plugin-react": { - "version": "6.10.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-6.10.3.tgz", - "integrity": "sha1-xUNb6wZ3ThLH2y9qut3L+QDNP3g=", - "dev": true, - "requires": { - "array.prototype.find": "2.0.4", - "doctrine": "1.5.0", - "has": "1.0.3", - "jsx-ast-utils": "1.4.1", - "object.assign": "4.1.0" - }, - "dependencies": { - "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", - "dev": true, - "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" - } - } - } - }, - "eslint-plugin-standard": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz", - "integrity": "sha1-NNDJFbRe3G8BA5PH7vOCOwhWXPI=", - "dev": true - }, - "espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", - "dev": true, - "requires": { - "acorn": "5.7.1", - "acorn-jsx": "3.0.1" - } - }, - "esprima": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", - "dev": true - }, - "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", - "dev": true, - "requires": { - "estraverse": "4.2.0" - } - }, - "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", - "dev": true, - "requires": { - "estraverse": "4.2.0" - } - }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, - "event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.45" - } - }, - "exit-hook": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", - "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "fbjs": { - "version": "0.8.17", - "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", - "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", - "requires": { - "core-js": "1.2.7", - "isomorphic-fetch": "2.2.1", - "loose-envify": "1.3.1", - "object-assign": "4.1.1", - "promise": "7.3.1", - "setimmediate": "1.0.5", - "ua-parser-js": "0.7.18" - } - }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "1.0.5", - "object-assign": "4.1.1" - } - }, - "file-entry-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-2.0.0.tgz", - "integrity": "sha1-w5KZDD5oR4PYOLjISkXYoEhFg2E=", - "dev": true, - "requires": { - "flat-cache": "1.3.0", - "object-assign": "4.1.1" - } - }, - "find-root": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", - "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", - "dev": true - }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "2.0.1" - } - }, - "flat-cache": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", - "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", - "dev": true, - "requires": { - "circular-json": "0.3.3", - "del": "2.2.2", - "graceful-fs": "4.1.11", - "write": "0.2.1" - } - }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", - "dev": true - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true - }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", - "dev": true - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "requires": { - "is-property": "1.0.2" - } - }, - "get-stdin": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.1.tgz", - "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "globals": { - "version": "9.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", - "dev": true - }, - "globby": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", - "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", - "dev": true, - "requires": { - "array-union": "1.0.2", - "arrify": "1.0.1", - "glob": "7.1.2", - "object-assign": "4.1.1", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, - "requires": { - "function-bind": "1.1.1" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=" - }, - "has-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", - "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", - "dev": true - }, - "hoist-non-react-statics": { - "version": "2.5.5", - "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", - "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" - }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "requires": { - "safer-buffer": "2.1.2" - } - }, - "ieee754": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", - "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==" - }, - "ignore": { - "version": "3.3.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", - "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", - "dev": true - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "inquirer": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", - "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", - "dev": true, - "requires": { - "ansi-escapes": "1.4.0", - "ansi-regex": "2.1.1", - "chalk": "1.1.3", - "cli-cursor": "1.0.2", - "cli-width": "2.2.0", - "figures": "1.7.0", - "lodash": "4.17.10", - "readline2": "1.0.1", - "run-async": "0.1.0", - "rx-lite": "3.1.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "through": "2.3.8" - } - }, - "interpret": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", - "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", - "dev": true - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, - "is-callable": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", - "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", - "dev": true - }, - "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-my-ip-valid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", - "integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==", - "dev": true - }, - "is-my-json-valid": { - "version": "2.17.2", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz", - "integrity": "sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg==", - "dev": true, - "requires": { - "generate-function": "2.0.0", - "generate-object-property": "1.2.0", - "is-my-ip-valid": "1.0.0", - "jsonpointer": "4.0.1", - "xtend": "4.0.1" - } - }, - "is-path-cwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", - "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", - "dev": true - }, - "is-path-in-cwd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", - "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", - "dev": true, - "requires": { - "is-path-inside": "1.0.1" - } - }, - "is-path-inside": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", - "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", - "dev": true, - "requires": { - "path-is-inside": "1.0.2" - } - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "requires": { - "isobject": "3.0.1" - } - }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", - "dev": true - }, - "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", - "dev": true, - "requires": { - "has": "1.0.3" - } - }, - "is-resolvable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", - "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "is-symbol": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", - "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" - }, - "isomorphic-fetch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", - "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", - "requires": { - "node-fetch": "1.7.3", - "whatwg-fetch": "2.0.4" - } - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" - }, - "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", - "dev": true, - "requires": { - "argparse": "1.0.10", - "esprima": "4.0.0" - } - }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true - }, - "jsx-ast-utils": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", - "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=", - "dev": true - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "parse-json": "4.0.0", - "pify": "3.0.0", - "strip-bom": "3.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "2.0.0", - "path-exists": "3.0.0" - }, - "dependencies": { - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - } - } - }, - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true - }, - "lodash.cond": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/lodash.cond/-/lodash.cond-4.5.2.tgz", - "integrity": "sha1-9HGh2khr5g9quVXRcRVSPdHSVdU=", - "dev": true - }, - "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", - "requires": { - "js-tokens": "3.0.2" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.11" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", - "dev": true - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", - "dev": true - }, - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "requires": { - "encoding": "0.1.12", - "is-stream": "1.1.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" - }, - "object-keys": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", - "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", - "dev": true - }, - "object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "dev": true, - "requires": { - "define-properties": "1.1.2", - "function-bind": "1.1.1", - "has-symbols": "1.0.0", - "object-keys": "1.0.12" - } + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" }, "once": { "version": "1.4.0", @@ -1305,76 +495,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" - } - }, - "onetime": { - "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", - "dev": true, - "requires": { - "deep-is": "0.1.3", - "fast-levenshtein": "2.0.6", - "levn": "0.3.0", - "prelude-ls": "1.1.2", - "type-check": "0.3.2", - "wordwrap": "1.0.0" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "1.3.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "1.3.2", - "json-parse-better-errors": "1.0.2" - } - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "2.0.1" + "wrappy": "1" } }, "path-is-absolute": { @@ -1383,124 +504,23 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", "dev": true }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "2.0.4" - } - }, - "pkg-conf": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-2.1.0.tgz", - "integrity": "sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg=", - "dev": true, - "requires": { - "find-up": "2.1.0", - "load-json-file": "4.0.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "2.0.0" - } - } - } - }, - "pkg-config": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pkg-config/-/pkg-config-1.1.1.tgz", - "integrity": "sha1-VX7yLXPaPIg3EHdmxS6tq94pj+Q=", - "dev": true, - "requires": { - "debug-log": "1.0.1", - "find-root": "1.1.0", - "xtend": "4.0.1" - } - }, - "pkg-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", - "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", - "dev": true, - "requires": { - "find-up": "1.1.2" - } - }, - "pkg-up": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-1.0.0.tgz", - "integrity": "sha1-Pgj7RhUlxEIWJKM7n35tCvWwWiY=", - "dev": true, - "requires": { - "find-up": "1.1.2" - } - }, - "pluralize": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", - "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", - "dev": true - }, "postcss-value-parser": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.0.tgz", "integrity": "sha1-h/OPnxj3dKSrTIojL1xc6IcqnRU=" }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "dev": true - }, - "progress": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - }, "promise": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", "requires": { - "asap": "2.0.6" + "asap": "~2.0.3" } }, "prop-types": { @@ -1508,8 +528,8 @@ "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.2.tgz", "integrity": "sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==", "requires": { - "loose-envify": "1.3.1", - "object-assign": "4.1.1" + "loose-envify": "^1.3.1", + "object-assign": "^4.1.1" } }, "react-is": { @@ -1517,49 +537,14 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.4.1.tgz", "integrity": "sha512-xpb0PpALlFWNw/q13A+1aHeyJyLYCg0/cCHPUA43zYluZuIPHaHL3k8OBsTgQtxqW0FhyDEMvi8fZ/+7+r4OSQ==" }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.2", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" - } - }, - "readline2": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", - "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "mute-stream": "0.0.5" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "1.8.1" - } - }, - "require-uncached": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", - "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", + "redux": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/redux/-/redux-4.0.0.tgz", + "integrity": "sha512-NnnHF0h0WVE/hXyrB6OlX67LYRuaf/rJcbWvnHHEPCF/Xa/AZpwhs/20WyqzQae5x4SD2F9nPObgBh2rxAgLiA==", "dev": true, "requires": { - "caller-path": "0.1.0", - "resolve-from": "1.0.1" + "loose-envify": "^1.1.0", + "symbol-observable": "^1.2.0" } }, "resolve": { @@ -1568,70 +553,18 @@ "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { - "path-parse": "1.0.5" - } - }, - "resolve-from": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", - "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "1.1.1", - "onetime": "1.1.0" - } - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", - "dev": true, - "requires": { - "once": "1.4.0" + "path-parse": "^1.0.5" } }, - "run-parallel": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", - "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==", - "dev": true - }, - "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", - "dev": true - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "semver": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, "setimmediate": { @@ -1639,128 +572,42 @@ "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, - "shelljs": { - "version": "0.7.8", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.8.tgz", - "integrity": "sha1-3svPh0sNHl+3LhSxZKloMEjprLM=", - "dev": true, - "requires": { - "glob": "7.1.2", - "interpret": "1.1.0", - "rechoir": "0.6.2" - } - }, - "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", - "dev": true - }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "standard": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/standard/-/standard-10.0.3.tgz", - "integrity": "sha512-JURZ+85ExKLQULckDFijdX5WHzN6RC7fgiZNSV4jFQVo+3tPoQGHyBrGekye/yf0aOfb4210EM5qPNlc2cRh4w==", - "dev": true, - "requires": { - "eslint": "3.19.0", - "eslint-config-standard": "10.2.1", - "eslint-config-standard-jsx": "4.0.2", - "eslint-plugin-import": "2.2.0", - "eslint-plugin-node": "4.2.3", - "eslint-plugin-promise": "3.5.0", - "eslint-plugin-react": "6.10.3", - "eslint-plugin-standard": "3.0.1", - "standard-engine": "7.0.0" - } - }, - "standard-engine": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/standard-engine/-/standard-engine-7.0.0.tgz", - "integrity": "sha1-67d7nI/CyBZf+jU72Rug3/Qa9pA=", - "dev": true, - "requires": { - "deglob": "2.1.1", - "get-stdin": "5.0.1", - "minimist": "1.2.0", - "pkg-conf": "2.1.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, "styled-components": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-3.3.3.tgz", "integrity": "sha1-CecCBVqxH3qOq4IpscDQuFUJVoY=", "requires": { - "buffer": "5.1.0", - "css-to-react-native": "2.2.1", - "fbjs": "0.8.17", - "hoist-non-react-statics": "2.5.5", - "is-plain-object": "2.0.4", - "prop-types": "15.6.2", - "react-is": "16.4.1", - "stylis": "3.5.1", - "stylis-rule-sheet": "0.0.10", - "supports-color": "3.2.3" + "buffer": "^5.0.3", + "css-to-react-native": "^2.0.3", + "fbjs": "^0.8.16", + "hoist-non-react-statics": "^2.5.0", + "is-plain-object": "^2.0.1", + "prop-types": "^15.5.4", + "react-is": "^16.3.1", + "stylis": "^3.5.0", + "stylis-rule-sheet": "^0.0.10", + "supports-color": "^3.2.3" } }, "stylis": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-3.5.1.tgz", - "integrity": "sha512-yM4PyeHuwhIOUHNJxi1/Mbq8kVLv4AkyE7IYLP/LK0lIFcr3tRa2H1iZlBYKIxOlf+/jruBTe8DdKSyQX9w4OA==" + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-3.5.3.tgz", + "integrity": "sha512-TxU0aAscJghF9I3V9q601xcK3Uw1JbXvpsBGj/HULqexKOKlOEzzlIpLFRbKkCK990ccuxfXUqmPbIIo7Fq/cQ==" }, "stylis-rule-sheet": { "version": "0.0.10", @@ -1772,81 +619,100 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "requires": { - "has-flag": "1.0.0" + "has-flag": "^1.0.0" + } + }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "dev": true + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, + "tslint": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.10.0.tgz", + "integrity": "sha1-EeJrzLiK+gLdDZlWyuPUVAtfVMM=", + "dev": true, + "requires": { + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.12.1" } }, - "table": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", - "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", + "tslint-config-standard": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/tslint-config-standard/-/tslint-config-standard-7.1.0.tgz", + "integrity": "sha512-cETzxZcEQ1RKjwtEScGryAtqwiRFc55xBxhZP6bePyOfXmo6i1/QKQrTgFKBiM4FjCvcqTjJq20/KGrh+TzTfQ==", "dev": true, "requires": { - "ajv": "4.11.8", - "ajv-keywords": "1.5.1", - "chalk": "1.1.3", - "lodash": "4.17.10", - "slice-ansi": "0.0.4", - "string-width": "2.1.1" + "tslint-eslint-rules": "^5.3.1" + } + }, + "tslint-eslint-rules": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-5.3.1.tgz", + "integrity": "sha512-qq2H/AU/FlFbQJKXuxhtIk+ni/nQu9jHHhsFKa6hnA0/n3zl1/RWRc3TVFlL8HfWFMzkST350VeTrFpy1u4OUg==", + "dev": true, + "requires": { + "doctrine": "0.7.2", + "tslib": "1.9.0", + "tsutils": "2.8.0" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==", "dev": true }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "tsutils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.8.0.tgz", + "integrity": "sha1-AWAXNymzvxOGKN0UoVN+AIUdgUo=", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" + "tslib": "^1.7.1" } } } }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true + "tslint-react": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/tslint-react/-/tslint-react-3.6.0.tgz", + "integrity": "sha512-AIv1QcsSnj7e9pFir6cJ6vIncTqxfqeFF3Lzh8SuuBljueYzEAtByuB6zMaD27BL0xhMEqsZ9s5eHuCONydjBw==", + "dev": true, + "requires": { + "tsutils": "^2.13.1" + } }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "tsutils": { + "version": "2.27.2", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.27.2.tgz", + "integrity": "sha512-qf6rmT84TFMuxAKez2pIfR8UCai49iQsfB7YWVjV1bKpy/d0PWT5rEOSM6La9PiHZ0k1RRZQiwVdVJfQ3BPHgg==", "dev": true, "requires": { - "prelude-ls": "1.1.2" + "tslib": "^1.8.1" } }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "typescript": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", + "integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==", "dev": true }, "ua-parser-js": { @@ -1854,58 +720,16 @@ "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.18.tgz", "integrity": "sha512-LtzwHlVHwFGTptfNSgezHp7WUlwiqb0gA9AALRbKaERfxwJoiX0A73QbTToxteIAuIaFshhgIZfqK8s7clqgnA==" }, - "uniq": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", - "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", - "dev": true - }, - "user-home": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", - "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", - "dev": true, - "requires": { - "os-homedir": "1.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, "whatwg-fetch": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true - }, - "write": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", - "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", - "dev": true, - "requires": { - "mkdirp": "0.5.1" - } - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true } } } diff --git a/package.json b/package.json index 17451e663ba6..ec9ae9159a47 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "lint-js": "standard" + "lint": "tslint --project tsconfig.json 'components/**/*.{ts,tsx}'", + "test-security": "npm audit" }, "repository": { "type": "git", @@ -22,6 +23,10 @@ { "name": "Cezar Augusto", "email": "cezar@brave.com" + }, + { + "name": "Nejc Zdovc", + "email": "nejc@brave.com" } ], "license": "MPL-2.0", @@ -30,7 +35,14 @@ }, "homepage": "https:/github.com/brave/brave-core#readme", "devDependencies": { - "standard": "^10.0.3" + "@types/react": "^16.0.26", + "@types/react-dom": "^16.0.3", + "@types/react-redux": "^6.0.4", + "@types/redux-logger": "^3.0.5", + "tslint": "^5.8.0", + "tslint-config-standard": "^7.0.0", + "tslint-react": "^3.2.0", + "typescript": "^2.8.1" }, "dependencies": { "brave-ui": "^0.12.2", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000000..ded632132429 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "sourceMap": true, + "noImplicitAny": true, + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "target": "es5", + "allowJs": true, + "jsx": "react", + "moduleResolution": "node", + "typeRoots": [ + "./node_modules/@types", + "./components/definitions" + ], + // optional + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "strictNullChecks": true, + "suppressImplicitAnyIndexErrors": true, + "noUnusedLocals": true + }, + "include": [ + "./components/**/*" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 000000000000..30fad0f42b4b --- /dev/null +++ b/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": ["tslint-react", "tslint-config-standard"], + "rules": { + "jsx-no-multiline-js": false + } +} From a568b0521c7bc083d444602b3a5f44a390bdb387 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Sat, 14 Jul 2018 14:10:26 +0200 Subject: [PATCH 3/9] Converts ad block into TS --- .../actions/adblock_actions.ts | 5 +- components/brave_adblock_ui/brave_adblock.tsx | 4 +- .../brave_adblock_ui/components/app.tsx | 55 ++++++------------- .../components/numBlockedStat.tsx | 17 ++++++ .../components/regionalAdBlockEnabled.tsx | 29 ++++++++++ .../constants/adblock_types.ts | 4 +- .../reducers/adblock_reducer.ts | 13 ++--- components/brave_adblock_ui/reducers/index.ts | 6 +- components/brave_adblock_ui/storage.ts | 42 +++++++------- components/brave_adblock_ui/store.ts | 3 +- components/brave_new_tab_ui/api.ts | 2 +- components/brave_new_tab_ui/brave_new_tab.tsx | 2 +- .../brave_new_tab_ui/components/app.tsx | 7 +-- .../brave_new_tab_ui/components/block.tsx | 2 +- .../components/footerInfo.tsx | 2 +- .../components/newPrivateTab.tsx | 2 +- .../components/siteRemovalNotification.tsx | 2 +- .../brave_new_tab_ui/components/stats.tsx | 2 +- .../reducers/newTabReducer.tsx | 4 +- components/brave_new_tab_ui/storage.ts | 6 +- components/brave_rewards_ui/brave_rewards.tsx | 3 +- components/brave_rewards_ui/components/app.ts | 26 ++++----- .../reducers/rewards_reducer.ts | 10 ++-- components/brave_welcome_ui/brave_welcome.tsx | 2 +- .../brave_welcome_ui/components/app.tsx | 2 +- .../reducers/welcome_reducer.ts | 2 +- components/common/debounce.ts | 10 ++-- components/common/locale.ts | 2 +- components/definitions/adBlock.d.ts | 14 +++++ components/definitions/global.d.ts | 21 +++++++ package-lock.json | 5 ++ package.json | 3 +- 32 files changed, 187 insertions(+), 122 deletions(-) create mode 100644 components/brave_adblock_ui/components/numBlockedStat.tsx create mode 100644 components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx create mode 100644 components/definitions/adBlock.d.ts create mode 100644 components/definitions/global.d.ts diff --git a/components/brave_adblock_ui/actions/adblock_actions.ts b/components/brave_adblock_ui/actions/adblock_actions.ts index 8d1098517bd1..f5d62284784d 100644 --- a/components/brave_adblock_ui/actions/adblock_actions.ts +++ b/components/brave_adblock_ui/actions/adblock_actions.ts @@ -2,8 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { action } from 'typesafe-actions' const types = require('../constants/adblock_types') -export const statsUpdated = () => ({ - type: types.ADBLOCK_STATS_UPDATED -}) +export const statsUpdated = () => action(types.ADBLOCK_STATS_UPDATED) diff --git a/components/brave_adblock_ui/brave_adblock.tsx b/components/brave_adblock_ui/brave_adblock.tsx index d2f0253ab81a..ab54fd6c0b98 100644 --- a/components/brave_adblock_ui/brave_adblock.tsx +++ b/components/brave_adblock_ui/brave_adblock.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { render } = require('react-dom') const { Provider } = require('react-redux') const App = require('./components/app') @@ -24,7 +24,7 @@ window.cr.define('brave_adblock', function () { function statsUpdated () { const store = require('./store') const adblockActions = require('./actions/adblock_actions') - const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) + const actions = bindActionCreators(adblockActions, store.store.dispatch.bind(store)) actions.statsUpdated() } diff --git a/components/brave_adblock_ui/components/app.tsx b/components/brave_adblock_ui/components/app.tsx index 3001e5edc40b..dae882824dd5 100644 --- a/components/brave_adblock_ui/components/app.tsx +++ b/components/brave_adblock_ui/components/app.tsx @@ -2,41 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { bindActionCreators } = require('redux') -const { connect } = require('react-redux') -const adblockActions = require('../actions/adblock_actions') - -const NumBlockedStat = (props) => -
- - - { props.adsBlockedStat || 0 } -
- -const RegionalAdBlockEnabled = (props) => -
- - - { - props.regionalAdBlockEnabled - ? - : - } -
- { - props.regionalAdBlockEnabled - ? props.regionalAdBlockTitle - : null - } -
-
- -class AdblockPage extends React.Component { - constructor (props) { - super(props) - } +import * as React from 'react' +import { bindActionCreators, Dispatch } from 'redux' +import { connect } from 'react-redux' +import { RegionalAdBlockEnabled } from './regionalAdBlockEnabled' +import * as adblockActions from '../actions/adblock_actions' +import { NumBlockedStat } from './numBlockedStat' + +interface Props { + actions: AdBlock.Actions + adblockData: AdBlock.State +} +class AdblockPage extends React.Component { get actions () { return this.props.actions } @@ -45,19 +23,20 @@ class AdblockPage extends React.Component { const { adblockData } = this.props return (
- + + regionalAdBlockTitle={adblockData.stats.regionalAdBlockTitle || ''} + />
) } } -const mapStateToProps = (state) => ({ +const mapStateToProps = (state: {adblockData: AdBlock.State}) => ({ adblockData: state.adblockData }) -const mapDispatchToProps = (dispatch) => ({ +const mapDispatchToProps = (dispatch: Dispatch) => ({ actions: bindActionCreators(adblockActions, dispatch) }) diff --git a/components/brave_adblock_ui/components/numBlockedStat.tsx b/components/brave_adblock_ui/components/numBlockedStat.tsx new file mode 100644 index 000000000000..473cb8f4e4a4 --- /dev/null +++ b/components/brave_adblock_ui/components/numBlockedStat.tsx @@ -0,0 +1,17 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as React from 'react' + +interface Props { + adsBlockedStat: number +} + +export const NumBlockedStat = (props: Props) => ( +
+ +   + {props.adsBlockedStat || 0} +
+) diff --git a/components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx b/components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx new file mode 100644 index 000000000000..f1396b84de98 --- /dev/null +++ b/components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx @@ -0,0 +1,29 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as React from 'react' + +interface Props { + regionalAdBlockEnabled: boolean + regionalAdBlockTitle: string +} + +export const RegionalAdBlockEnabled = (props: Props) => ( +
+ +   + { + props.regionalAdBlockEnabled + ? + : + } +
+ { + props.regionalAdBlockEnabled + ? props.regionalAdBlockTitle + : null + } +
+
+) diff --git a/components/brave_adblock_ui/constants/adblock_types.ts b/components/brave_adblock_ui/constants/adblock_types.ts index 8faac4a76c46..5f035ec1a3a8 100644 --- a/components/brave_adblock_ui/constants/adblock_types.ts +++ b/components/brave_adblock_ui/constants/adblock_types.ts @@ -2,4 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -export const ADBLOCK_STATS_UPDATED = 'ADBLOCK_STATS_UPDATED' +export const enum types { + ADBLOCK_STATS_UPDATED = '@@adblock/ADBLOCK_STATS_UPDATED' +} diff --git a/components/brave_adblock_ui/reducers/adblock_reducer.ts b/components/brave_adblock_ui/reducers/adblock_reducer.ts index cf2285ffb9c3..aabf3c7878ad 100644 --- a/components/brave_adblock_ui/reducers/adblock_reducer.ts +++ b/components/brave_adblock_ui/reducers/adblock_reducer.ts @@ -1,16 +1,15 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global chrome */ -const types = require('../constants/adblock_types') +import { Reducer } from 'redux' + +const { types } = require('../constants/adblock_types') const storage = require('../storage') -let getGridSites_ -const adblockReducer = (state, action) => { - if (state === undefined) { - state = storage.load() || {} - state = Object.assign(storage.getInitialState(), state) +const adblockReducer: Reducer = (state: AdBlock.State, action) => { + if (state == null) { + state = storage.load() } const startingState = state diff --git a/components/brave_adblock_ui/reducers/index.ts b/components/brave_adblock_ui/reducers/index.ts index c547cb296825..c0fb9a0c20cb 100644 --- a/components/brave_adblock_ui/reducers/index.ts +++ b/components/brave_adblock_ui/reducers/index.ts @@ -5,7 +5,11 @@ import { combineReducers } from 'redux' import adblockReducer from './adblock_reducer' -const combinedReducer = combineReducers({ +interface State { + adblockData: AdBlock.State +} + +const combinedReducer = combineReducers({ adblockData: adblockReducer }) diff --git a/components/brave_adblock_ui/storage.ts b/components/brave_adblock_ui/storage.ts index 1905baa0e8a5..eee23f61017e 100644 --- a/components/brave_adblock_ui/storage.ts +++ b/components/brave_adblock_ui/storage.ts @@ -2,38 +2,42 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global chrome */ - const debounce = require('../common/debounce') const keyName = 'adblock-data' -const cleanData = (state) => { - return module.exports.getLoadTimeData(state) +const defaultState: AdBlock.State = { + stats: { + numBlocked: 0, + regionalAdBlockEnabled: false + } } -module.exports.getLoadTimeData = (state) => { +export const getLoadTimeData = (state: AdBlock.State): AdBlock.State => { state = { ...state } - state.stats = {} + state.stats = defaultState.stats + // Expected to be numbers - ;['adsBlockedStat', 'regionalAdBlockEnabled'].forEach( - (stat) => { state.stats[stat] = parseInt(chrome.getVariableValue(stat)) }) + ;['adsBlockedStat', 'regionalAdBlockEnabled'].forEach((stat) => { + state.stats[stat] = parseInt(chrome.getVariableValue(stat), 10) + }) // Expected to be Strings - ;['regionalAdBlockTitle'].forEach( - (stat) => { state.stats[stat] = chrome.getVariableValue(stat) }) + ;['regionalAdBlockTitle'].forEach((stat) => { + state.stats[stat] = chrome.getVariableValue(stat) + }) + return state } -module.exports.getInitialState = () => cleanData({ - stats: { - numBlocked: 0, - regionalAdBlockEnabled: false - } -}) +export const cleanData = (state: AdBlock.State): AdBlock.State => { + return getLoadTimeData(state) +} + +export const getInitialState = (): AdBlock.State => cleanData(defaultState) -module.exports.load = () => { +export const load = (): AdBlock.State => { const data = window.localStorage.getItem(keyName) - let state + let state: AdBlock.State = getInitialState() if (data) { try { state = JSON.parse(data) @@ -44,7 +48,7 @@ module.exports.load = () => { return cleanData(state) } -module.exports.debouncedSave = debounce((data) => { +export const debouncedSave = debounce((data: AdBlock.State) => { if (data) { window.localStorage.setItem(keyName, JSON.stringify(cleanData(data))) } diff --git a/components/brave_adblock_ui/store.ts b/components/brave_adblock_ui/store.ts index 426939fda2d6..4a2f7f5bcfa8 100644 --- a/components/brave_adblock_ui/store.ts +++ b/components/brave_adblock_ui/store.ts @@ -5,5 +5,4 @@ import { createStore } from 'redux' import reducers from './reducers' -const store = createStore(reducers) -module.exports = store +export const store = createStore(reducers) diff --git a/components/brave_new_tab_ui/api.ts b/components/brave_new_tab_ui/api.ts index c6ebf9b2a67c..2de6fd1687f0 100644 --- a/components/brave_new_tab_ui/api.ts +++ b/components/brave_new_tab_ui/api.ts @@ -50,7 +50,7 @@ export const fetchBookmarkInfo = (url) => { } export const getGridSites = (state, checkBookmarkInfo) => { - const sizeToCount = {large: 18, medium: 12, small: 6} + const sizeToCount = { large: 18, medium: 12, small: 6 } const count = sizeToCount[state.gridLayoutSize || 'small'] // Start with top sites with filtered out ignored sites and pinned sites diff --git a/components/brave_new_tab_ui/brave_new_tab.tsx b/components/brave_new_tab_ui/brave_new_tab.tsx index c16acfabb7fc..a5cb644e1c46 100644 --- a/components/brave_new_tab_ui/brave_new_tab.tsx +++ b/components/brave_new_tab_ui/brave_new_tab.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { render } = require('react-dom') const { Provider } = require('react-redux') const App = require('./components/app') diff --git a/components/brave_new_tab_ui/components/app.tsx b/components/brave_new_tab_ui/components/app.tsx index 04f97e5191a6..ab5b129884db 100644 --- a/components/brave_new_tab_ui/components/app.tsx +++ b/components/brave_new_tab_ui/components/app.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { DragDropContext } = require('react-dnd') const { bindActionCreators } = require('redux') const { connect } = require('react-redux') @@ -168,7 +168,7 @@ class NewTabPage extends React.Component { favicon={site.favicon} letter={site.letter} thumb={site.thumb} - style={{backgroundColor: site.themeColor || site.computedThemeColor}} + style={{ backgroundColor: site.themeColor || site.computedThemeColor }} onToggleBookmark={this.onToggleBookmark.bind(this, site)} onPinnedTopSite={this.onTogglePinnedTopSite.bind(this, site)} onIgnoredTopSite={this.onIgnoredTopSite.bind(this, site)} @@ -192,8 +192,7 @@ class NewTabPage extends React.Component { : null } { - - } + } } diff --git a/components/brave_new_tab_ui/components/block.tsx b/components/brave_new_tab_ui/components/block.tsx index 5a7c96661131..df59f3e2a5d2 100644 --- a/components/brave_new_tab_ui/components/block.tsx +++ b/components/brave_new_tab_ui/components/block.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const cx = require('../../common/classSet') const DragSource = require('react-dnd').DragSource const DropTarget = require('react-dnd').DropTarget diff --git a/components/brave_new_tab_ui/components/footerInfo.tsx b/components/brave_new_tab_ui/components/footerInfo.tsx index a52484df22e1..812d627ab0bf 100644 --- a/components/brave_new_tab_ui/components/footerInfo.tsx +++ b/components/brave_new_tab_ui/components/footerInfo.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' class FooterInfo extends React.Component { render () { diff --git a/components/brave_new_tab_ui/components/newPrivateTab.tsx b/components/brave_new_tab_ui/components/newPrivateTab.tsx index 0ed10312b2ef..6c0d899d0f40 100644 --- a/components/brave_new_tab_ui/components/newPrivateTab.tsx +++ b/components/brave_new_tab_ui/components/newPrivateTab.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { getLocale } = require('../../common/locale') // Components diff --git a/components/brave_new_tab_ui/components/siteRemovalNotification.tsx b/components/brave_new_tab_ui/components/siteRemovalNotification.tsx index 501e07febd1f..0774f01b8d18 100644 --- a/components/brave_new_tab_ui/components/siteRemovalNotification.tsx +++ b/components/brave_new_tab_ui/components/siteRemovalNotification.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const cx = require('../../common/classSet') class siteRemovalNotification extends React.Component { diff --git a/components/brave_new_tab_ui/components/stats.tsx b/components/brave_new_tab_ui/components/stats.tsx index c1e8dc0f4eb9..9e94d646e879 100644 --- a/components/brave_new_tab_ui/components/stats.tsx +++ b/components/brave_new_tab_ui/components/stats.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { DataBlock, DataItem } = require('brave-ui/dataBlock') const { getLocale } = require('../../common/locale') diff --git a/components/brave_new_tab_ui/reducers/newTabReducer.tsx b/components/brave_new_tab_ui/reducers/newTabReducer.tsx index 735623e57939..8f0f878aab47 100644 --- a/components/brave_new_tab_ui/reducers/newTabReducer.tsx +++ b/components/brave_new_tab_ui/reducers/newTabReducer.tsx @@ -104,7 +104,7 @@ const newTabReducer = (state, action) => { } break case types.NEW_TAB_TOP_SITES_DATA_UPDATED: - state = {...state, topSites: action.topSites} + state = { ...state, topSites: action.topSites } calculateGridSites(state) break case types.NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED: { @@ -112,7 +112,7 @@ const newTabReducer = (state, action) => { const fallbackImage = { name: 'Bay Bridge', source, - style: {backgroundImage: 'url(' + source + ')'}, + style: { backgroundImage: 'url(' + source + ')' }, author: 'Darrell Sano', link: 'https://dksfoto.smugmug.com' } diff --git a/components/brave_new_tab_ui/storage.ts b/components/brave_new_tab_ui/storage.ts index f2e94414905c..d4874be2fd5b 100644 --- a/components/brave_new_tab_ui/storage.ts +++ b/components/brave_new_tab_ui/storage.ts @@ -2,9 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global chrome */ - -const debounce = require('../common/debounce') +import {debounce} from '../common/debounce' const backgrounds = require('./backgrounds') const keyName = 'new-tab-data' @@ -12,7 +10,7 @@ const keyName = 'new-tab-data' const randomBackgroundImage = () => { const randomIndex = Math.floor(Math.random() * backgrounds.length) const image = Object.assign({}, backgrounds[randomIndex]) - image.style = {backgroundImage: 'url(' + image.source + ')'} + image.style = { backgroundImage: 'url(' + image.source + ')' } return image } diff --git a/components/brave_rewards_ui/brave_rewards.tsx b/components/brave_rewards_ui/brave_rewards.tsx index 331ebd645992..cf39e2800fae 100644 --- a/components/brave_rewards_ui/brave_rewards.tsx +++ b/components/brave_rewards_ui/brave_rewards.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { render } = require('react-dom') const { Provider } = require('react-redux') const App = require('./components/app') @@ -43,4 +43,3 @@ window.cr.define('brave_rewards', function () { }) document.addEventListener('DOMContentLoaded', window.brave_rewards.initialize) - diff --git a/components/brave_rewards_ui/components/app.ts b/components/brave_rewards_ui/components/app.ts index 72a0663743f5..893018fdce08 100644 --- a/components/brave_rewards_ui/components/app.ts +++ b/components/brave_rewards_ui/components/app.ts @@ -2,15 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { bindActionCreators } = require('redux') const { connect } = require('react-redux') const rewardsActions = require('../actions/rewards_actions') const CreateWalletLink = (props) => - + href = '#' onClick = { props.createWalletClicked } > Create Wallet< /a> + < /div> class RewardsPage extends React.Component { constructor (props) { @@ -18,7 +17,7 @@ class RewardsPage extends React.Component { this.onCreateWalletClicked = this.onCreateWalletClicked.bind(this) } - onCreateWalletClicked() { + onCreateWalletClicked () { this.actions.createWalletRequested() } @@ -29,19 +28,18 @@ class RewardsPage extends React.Component { render () { const { rewardsData } = this.props return ( -
- - { - rewardsData.walletCreated - ?
Wallet Created!
+ createWalletClicked = { this.onCreateWalletClicked } / > + { + rewardsData.walletCreated + ? Wallet Created!/div> as : null - } - { + } + { rewardsData.walletCreateFailed - ?
Wallet Create Failed!
+ ? Wallet Create Failed! < /div> : null } -
) + /div>) as } } diff --git a/components/brave_rewards_ui/reducers/rewards_reducer.ts b/components/brave_rewards_ui/reducers/rewards_reducer.ts index 53a3c01aad77..dc32f8402988 100644 --- a/components/brave_rewards_ui/reducers/rewards_reducer.ts +++ b/components/brave_rewards_ui/reducers/rewards_reducer.ts @@ -15,15 +15,15 @@ const rewardsReducer = (state, action) => { const startingState = state switch (action.type) { case types.CREATE_WALLET_REQUESTED: - chrome.send('createWalletRequested', []); + chrome.send('createWalletRequested', []) break case types.WALLET_CREATED: - state = {... state} - state.walletCreated = true + state = { ...state } + state.walletCreated = true break case types.WALLET_CREATE_FAILED: - state = {... state} - state.walletCreateFailed = true + state = { ...state } + state.walletCreateFailed = true break } diff --git a/components/brave_welcome_ui/brave_welcome.tsx b/components/brave_welcome_ui/brave_welcome.tsx index 800f046be368..b0373f4371df 100644 --- a/components/brave_welcome_ui/brave_welcome.tsx +++ b/components/brave_welcome_ui/brave_welcome.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { render } = require('react-dom') const { Provider } = require('react-redux') const App = require('./components/app') diff --git a/components/brave_welcome_ui/components/app.tsx b/components/brave_welcome_ui/components/app.tsx index a66b2bf76b1f..732507211313 100644 --- a/components/brave_welcome_ui/components/app.tsx +++ b/components/brave_welcome_ui/components/app.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') +import * as React from 'react' const { bindActionCreators } = require('redux') const { connect } = require('react-redux') const welcomeActions = require('../actions/welcome_actions') diff --git a/components/brave_welcome_ui/reducers/welcome_reducer.ts b/components/brave_welcome_ui/reducers/welcome_reducer.ts index e3ca7db355a2..8fcbdedb7bb5 100644 --- a/components/brave_welcome_ui/reducers/welcome_reducer.ts +++ b/components/brave_welcome_ui/reducers/welcome_reducer.ts @@ -18,7 +18,7 @@ const welcomeReducer = (state, action) => { chrome.send('importNowRequested', []) break case types.GO_TO_PAGE_REQUESTED: - state = {...state} + state = { ...state } state.pageIndex = action.pageIndex break } diff --git a/components/common/debounce.ts b/components/common/debounce.ts index 0e676f5414a9..1d38f02f399e 100644 --- a/components/common/debounce.ts +++ b/components/common/debounce.ts @@ -4,16 +4,14 @@ 'use strict' -function debounce (fn, bufferInterval, ...args) { - let timeout - return (...args2) => { +export const debounce = function(fn: (data: T) => void, bufferInterval: number, ...args: Array) { + let timeout: any + return (...args2: Array) => { clearTimeout(timeout) - let a = args || [] + let a: Array = args || [] if (args2 && args2.constructor === Array) { a = a.concat(args2) } timeout = setTimeout(fn.apply.bind(fn, this, a), bufferInterval) } } - -module.exports = debounce diff --git a/components/common/locale.ts b/components/common/locale.ts index 41ad7b923d8e..017ab8e716de 100644 --- a/components/common/locale.ts +++ b/components/common/locale.ts @@ -4,7 +4,7 @@ 'use strict' // TODO optimize NZ -declare let window: any; +declare let window: any /** * Gets the localized string diff --git a/components/definitions/adBlock.d.ts b/components/definitions/adBlock.d.ts new file mode 100644 index 000000000000..34c3aa3b76d4 --- /dev/null +++ b/components/definitions/adBlock.d.ts @@ -0,0 +1,14 @@ +declare namespace AdBlock { + export interface State { + stats: { + adsBlockedStat?: number + numBlocked: number + regionalAdBlockEnabled: boolean + regionalAdBlockTitle?: string + } + } + + export interface Actions { + statsUpdated: any + } +} diff --git a/components/definitions/global.d.ts b/components/definitions/global.d.ts new file mode 100644 index 000000000000..8f140c69367d --- /dev/null +++ b/components/definitions/global.d.ts @@ -0,0 +1,21 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ +export {} + +type Translations = {[key: string]: string}[] + +declare global { + interface Window { + loadTimeData: Translations + cr: { + define: (name: string, init: () => void) => void + } + i18nTemplate: { + process: (document: Document, translations: Translations) => void + } + brave_adblock: { + initialize: () => void + } + } +} diff --git a/package-lock.json b/package-lock.json index adad04f1139f..fd1cfcaa4fd3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -709,6 +709,11 @@ "tslib": "^1.8.1" } }, + "typesafe-actions": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/typesafe-actions/-/typesafe-actions-2.0.4.tgz", + "integrity": "sha512-3qnSDBNtH3mfekmM9w/IVlsqiUT4I5m+mpLp5tV2Ua/28BfaehqUg6eQNC8+cTk+oufbXcubLiWvKS/61qgleQ==" + }, "typescript": { "version": "2.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz", diff --git a/package.json b/package.json index ec9ae9159a47..bb9a0097f407 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ }, "dependencies": { "brave-ui": "^0.12.2", - "emptykit.css": "^1.0.1" + "emptykit.css": "^1.0.1", + "typesafe-actions": "^2.0.4" } } From eb0b298e23bb2aefef9eee5645c0f7c9d2f65248 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Sat, 14 Jul 2018 17:19:30 +0200 Subject: [PATCH 4/9] Convert new tab into TS --- components/brave_adblock_ui/brave_adblock.tsx | 2 +- components/brave_adblock_ui/reducers/index.ts | 6 +- .../brave_new_tab_ui/actions/newTabActions.ts | 59 ++---- components/brave_new_tab_ui/api.ts | 27 ++- components/brave_new_tab_ui/backgrounds.ts | 59 ++++-- .../brave_new_tab_ui/components/app.tsx | 178 +++++++++--------- .../brave_new_tab_ui/components/block.tsx | 82 +++++--- .../components/footerInfo.tsx | 51 ++--- .../components/newPrivateTab.tsx | 34 ++-- .../components/siteRemovalNotification.tsx | 35 ++-- .../brave_new_tab_ui/components/stats.tsx | 47 +++-- .../brave_new_tab_ui/components/theme.tsx | 4 +- .../brave_new_tab_ui/constants/newTabTypes.ts | 34 ++-- components/brave_new_tab_ui/reducers/index.ts | 2 +- .../reducers/newTabReducer.tsx | 74 ++++---- components/brave_new_tab_ui/storage.ts | 61 +++--- components/brave_new_tab_ui/store.ts | 3 +- components/brave_rewards_ui/components/app.ts | 23 ++- components/common/classSet.ts | 2 +- components/definitions/adBlock.d.ts | 4 + components/definitions/chromel.d.ts | 6 +- components/definitions/global.d.ts | 6 +- components/definitions/newTab.d.ts | 57 ++++++ package-lock.json | 139 +++++++++++++- package.json | 5 + 25 files changed, 634 insertions(+), 366 deletions(-) create mode 100644 components/definitions/newTab.d.ts diff --git a/components/brave_adblock_ui/brave_adblock.tsx b/components/brave_adblock_ui/brave_adblock.tsx index ab54fd6c0b98..3e5d58f9647a 100644 --- a/components/brave_adblock_ui/brave_adblock.tsx +++ b/components/brave_adblock_ui/brave_adblock.tsx @@ -24,7 +24,7 @@ window.cr.define('brave_adblock', function () { function statsUpdated () { const store = require('./store') const adblockActions = require('./actions/adblock_actions') - const actions = bindActionCreators(adblockActions, store.store.dispatch.bind(store)) + const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) actions.statsUpdated() } diff --git a/components/brave_adblock_ui/reducers/index.ts b/components/brave_adblock_ui/reducers/index.ts index c0fb9a0c20cb..3290ce15a89d 100644 --- a/components/brave_adblock_ui/reducers/index.ts +++ b/components/brave_adblock_ui/reducers/index.ts @@ -5,11 +5,7 @@ import { combineReducers } from 'redux' import adblockReducer from './adblock_reducer' -interface State { - adblockData: AdBlock.State -} - -const combinedReducer = combineReducers({ +const combinedReducer = combineReducers({ adblockData: adblockReducer }) diff --git a/components/brave_new_tab_ui/actions/newTabActions.ts b/components/brave_new_tab_ui/actions/newTabActions.ts index cf838873735d..9a6f091618a1 100644 --- a/components/brave_new_tab_ui/actions/newTabActions.ts +++ b/components/brave_new_tab_ui/actions/newTabActions.ts @@ -2,86 +2,67 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { action } from 'typesafe-actions' const types = require('../constants/newTabTypes') -export const topSitesDataUpdated = (topSites) => { - return { - type: types.NEW_TAB_TOP_SITES_DATA_UPDATED, - topSites - } -} - -export const backgroundImageLoadFailed = () => ({ - type: types.NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED + +export const topSitesDataUpdated = (topSites: NewTab.Site[]) => action(types.NEW_TAB_TOP_SITES_DATA_UPDATED, { + topSites }) -export const bookmarkAdded = (url) => ({ - type: types.BOOKMARK_ADDED, +export const backgroundImageLoadFailed = () => action(types.NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED) + +export const bookmarkAdded = (url: string) => action(types.BOOKMARK_ADDED, { url }) -export const bookmarkRemoved = (url) => ({ - type: types.BOOKMARK_REMOVED, +export const bookmarkRemoved = (url: string) => action(types.BOOKMARK_REMOVED, { url }) -export const sitePinned = (url) => ({ - type: types.NEW_TAB_SITE_PINNED, +export const sitePinned = (url: string) => action(types.NEW_TAB_SITE_PINNED, { url }) -export const siteUnpinned = (url) => ({ - type: types.NEW_TAB_SITE_UNPINNED, +export const siteUnpinned = (url: string) => action(types.NEW_TAB_SITE_UNPINNED, { url }) -export const siteIgnored = (url) => ({ - type: types.NEW_TAB_SITE_IGNORED, +export const siteIgnored = (url: string) => action(types.NEW_TAB_SITE_IGNORED, { url }) -export const undoSiteIgnored = (url) => ({ - type: types.NEW_TAB_UNDO_SITE_IGNORED, +export const undoSiteIgnored = (url: string) => action(types.NEW_TAB_UNDO_SITE_IGNORED, { url }) -export const undoAllSiteIgnored = (url) => ({ - type: types.NEW_TAB_UNDO_ALL_SITE_IGNORED, +export const undoAllSiteIgnored = (url: string) => action(types.NEW_TAB_UNDO_ALL_SITE_IGNORED, { url }) -export const siteDragged = (fromUrl, toUrl, dragRight) => ({ - type: types.NEW_TAB_SITE_DRAGGED, +export const siteDragged = (fromUrl: string, toUrl: string, dragRight: boolean) => action(types.NEW_TAB_SITE_DRAGGED, { fromUrl, toUrl, dragRight }) -export const siteDragEnd = (url, didDrop) => ({ - type: types.NEW_TAB_SITE_DRAG_END, +export const siteDragEnd = (url: string, didDrop: boolean) => action(types.NEW_TAB_SITE_DRAG_END, { url, didDrop }) -export const onHideSiteRemovalNotification = () => ({ - type: types.NEW_TAB_HIDE_SITE_REMOVAL_NOTIFICATION -}) +export const onHideSiteRemovalNotification = () => action(types.NEW_TAB_HIDE_SITE_REMOVAL_NOTIFICATION) -export const bookmarkInfoAvailable = (queryUrl, bookmarkTreeNode) => ({ - type: types.NEW_TAB_BOOKMARK_INFO_AVAILABLE, +export const bookmarkInfoAvailable = (queryUrl: string, bookmarkTreeNode: any) => action(types.NEW_TAB_BOOKMARK_INFO_AVAILABLE, { queryUrl, bookmarkTreeNode }) -export const gridSitesUpdated = (gridSites) => ({ - type: types.NEW_TAB_GRID_SITES_UPDATED, +export const gridSitesUpdated = (gridSites: NewTab.Site[]) => action(types.NEW_TAB_GRID_SITES_UPDATED, { gridSites }) -export const statsUpdated = () => ({ - type: types.NEW_TAB_STATS_UPDATED -}) +export const statsUpdated = () => action(types.NEW_TAB_STATS_UPDATED) -export const changePrivateSearchEngine = (shouldUse) => ({ - type: types.NEW_TAB_USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE, +export const changePrivateSearchEngine = (shouldUse: boolean) => action(types.NEW_TAB_USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE, { shouldUse }) diff --git a/components/brave_new_tab_ui/api.ts b/components/brave_new_tab_ui/api.ts index 2de6fd1687f0..214671d6f8d8 100644 --- a/components/brave_new_tab_ui/api.ts +++ b/components/brave_new_tab_ui/api.ts @@ -2,13 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global chrome */ - const { bindActionCreators } = require('redux') const newTabActions = require('./actions/newTabActions') const debounce = require('../common/debounce') -let actions +let actions: any + const getActions = () => { if (actions) { return actions @@ -21,35 +20,34 @@ const getActions = () => { /** * Obtains a letter / char that represents the current site */ -const getLetterFromSite = (site) => { +const getLetterFromSite = (site: NewTab.Site) => { let name try { name = new window.URL(site.url || '').hostname - } catch (e) {} + } catch (e) { + console.warn('getLetterFromSite', { url: site.url || '' }) + } name = site.title || name || '?' return name.charAt(0).toUpperCase() } /** * Obtains the top sites and submits an action with the results - * @param {Array} - An array of top site objects with title and url. */ -export const fetchTopSites = (topSites) => { - chrome.topSites.get( - (topSites) => getActions().topSitesDataUpdated(topSites || []) - ) +export const fetchTopSites = () => { + chrome.topSites.get((topSites: NewTab.Site[]) => getActions().topSitesDataUpdated(topSites || [])) } /** * Obtains the URL's bookmark info and calls an action with the result */ -export const fetchBookmarkInfo = (url) => { +export const fetchBookmarkInfo = (url: string) => { chrome.bookmarks.search(url.replace(/^https?:\/\//, ''), (bookmarkTreeNodes) => getActions().bookmarkInfoAvailable(url, bookmarkTreeNodes[0]) ) } -export const getGridSites = (state, checkBookmarkInfo) => { +export const getGridSites = (state: NewTab.State, checkBookmarkInfo: boolean) => { const sizeToCount = { large: 18, medium: 12, small: 6 } const count = sizeToCount[state.gridLayoutSize || 'small'] @@ -75,6 +73,7 @@ export const getGridSites = (state, checkBookmarkInfo) => { gridSite.thumb = `chrome://thumb/${gridSite.url}` gridSite.favicon = `chrome://favicon/size/48@1x/${gridSite.url}` gridSite.bookmarked = state.bookmarks[gridSite.url] + if (checkBookmarkInfo && gridSite.bookmarked === undefined) { fetchBookmarkInfo(gridSite.url) } @@ -85,6 +84,6 @@ export const getGridSites = (state, checkBookmarkInfo) => { /** * Calculates the top sites grid and calls an action with the results */ -export const calculateGridSites = debounce((state) => { - getActions().gridSitesUpdated(getGridSites(state, true, true)) +export const calculateGridSites = debounce((state: NewTab.State) => { + getActions().gridSitesUpdated(getGridSites(state, true)) }, 10) diff --git a/components/brave_new_tab_ui/backgrounds.ts b/components/brave_new_tab_ui/backgrounds.ts index 9bbc7bca5a17..8cac19464786 100644 --- a/components/brave_new_tab_ui/backgrounds.ts +++ b/components/brave_new_tab_ui/backgrounds.ts @@ -2,103 +2,122 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -module.exports = [ +export const images: NewTab.Image[] = [ { 'name': 'Tuolome Meadows', 'source': 'dksfoto1.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'South Tufa, Mono Lake', 'source': 'dksfoto2.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Little Lakes Valley', 'source': 'dksfoto3.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Bay Bridge', 'source': 'dksfoto4.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Yosemite', 'source': 'dksfoto5.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Beach Ice', 'source': 'dksfoto6.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Color and White Trunks', 'source': 'dksfoto7.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Golden Gate Bridge', 'source': 'dksfoto8.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Long Lake', 'source': 'dksfoto9.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'San Francisco Skyline', 'source': 'dksfoto10.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Across Mono Basin', 'source': 'dksfoto11.jpg', 'author': 'Darrell Sano', 'link': 'https://dksfoto.smugmug.com' - }, { + }, + { 'name': 'Corsica', 'source': 'Phoyoserge_Corsica.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Corsica', 'source': 'Phoyoserge_Corsica2.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Griffith Park Observatory (Downtown Los Angeles)', 'source': 'Phoyoserge_DowntownGriffith.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Elmatador Beach', 'source': 'Phoyoserge_ElmatadorBeach.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Paris:Conciergeri', 'source': 'Phoyoserge_ParisConciergeri.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Paris:The Roof', 'source': 'Phoyoserge_Theroofparis.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Paris:The Seant', 'source': 'Phoyoserge_TheSeantParis.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Venise Sunset', 'source': 'Phoyoserge_VeniseSunset.jpg', 'author': 'Serge Ramelli', 'link': 'https://www.photoserge.com/' - }, { + }, + { 'name': 'Yosemite', 'source': 'Phoyoserge_Yosemite.jpg', 'author': 'Serge Ramelli', diff --git a/components/brave_new_tab_ui/components/app.tsx b/components/brave_new_tab_ui/components/app.tsx index ab5b129884db..5a1fb1894813 100644 --- a/components/brave_new_tab_ui/components/app.tsx +++ b/components/brave_new_tab_ui/components/app.tsx @@ -3,38 +3,32 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { DragDropContext } = require('react-dnd') -const { bindActionCreators } = require('redux') -const { connect } = require('react-redux') -const HTML5Backend = require('react-dnd-html5-backend') -const newTabActions = require('../actions/newTabActions') +import { DragDropContext } from 'react-dnd' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import * as HTML5Backend from 'react-dnd-html5-backend' +import * as newTabActions from '../actions/newTabActions' // Components -const { Grid, Column, Clock } = require('brave-ui') -const Stats = require('./stats') -const Block = require('./block') -const FooterInfo = require('./footerInfo') -const SiteRemovalNotification = require('./siteRemovalNotification') -const NewPrivateTab = require('./newPrivateTab') +import { Grid, Column, Clock } from 'brave-ui' +import Stats from './stats' +import Block from './block' +import FooterInfo from './footerInfo' +import SiteRemovalNotification from './siteRemovalNotification' +import NewPrivateTab from './newPrivateTab' // Assets -const theme = require('./theme') +import { theme } from './theme' require('../../styles/newtab.less') require('font-awesome/css/font-awesome.css') require('../../fonts/poppins.css') -class NewTabPage extends React.Component { - constructor (props) { - super(props) - this.onBackgroundImageLoadFailed = this.onBackgroundImageLoadFailed.bind(this) - this.onUndoAllSiteIgnored = this.onUndoAllSiteIgnored.bind(this) - this.onUndoIgnoredTopSite = this.onUndoIgnoredTopSite.bind(this) - this.onHideSiteRemovalNotification = this.onHideSiteRemovalNotification.bind(this) - this.onDraggedSite = this.onDraggedSite.bind(this) - this.onDragEnd = this.onDragEnd.bind(this) - this.onChangePrivateSearchEngine = this.onChangePrivateSearchEngine.bind(this) - } +interface Props { + actions: any + newTabData: NewTab.State +} +class NewTabPage extends React.Component { get actions () { return this.props.actions } @@ -50,15 +44,15 @@ class NewTabPage extends React.Component { ) } - onDraggedSite (fromUrl, toUrl, dragRight) { + onDraggedSite = (fromUrl: string, toUrl: string, dragRight: boolean) => { this.actions.siteDragged(fromUrl, toUrl, dragRight) } - onDragEnd (url, didDrop) { + onDragEnd = (url: string, didDrop: boolean) => { this.actions.siteDragEnd(url, didDrop) } - onToggleBookmark (site) { + onToggleBookmark (site: NewTab.Site) { if (site.bookmarked) { this.actions.bookmarkAdded(site.url) } else { @@ -66,11 +60,11 @@ class NewTabPage extends React.Component { } } - onHideSiteRemovalNotification () { + onHideSiteRemovalNotification = () => { this.actions.onHideSiteRemovalNotification() } - onTogglePinnedTopSite (site) { + onTogglePinnedTopSite (site: NewTab.Site) { if (!site.pinned) { this.actions.sitePinned(site.url) } else { @@ -78,18 +72,18 @@ class NewTabPage extends React.Component { } } - onIgnoredTopSite (site) { + onIgnoredTopSite (site: NewTab.Site) { this.actions.siteIgnored(site.url) } - onUndoIgnoredTopSite () { + onUndoIgnoredTopSite = () => { this.actions.undoSiteIgnored() } /** * Clear ignoredTopSites and pinnedTopSites list */ - onUndoAllSiteIgnored () { + onUndoAllSiteIgnored = () => { this.actions.undoAllSiteIgnored() } @@ -97,11 +91,11 @@ class NewTabPage extends React.Component { * This handler only fires when the image fails to load. * If both the remote and local image fail, page defaults to gradients. */ - onBackgroundImageLoadFailed () { + onBackgroundImageLoadFailed = () => { this.actions.backgroundImageLoadFailed() } - onChangePrivateSearchEngine (e) { + onChangePrivateSearchEngine = (e: React.ChangeEvent) => { if (!e.target) { return } @@ -131,78 +125,78 @@ class NewTabPage extends React.Component { return null } - const backgroundProps = {} + const backgroundProps: Partial = {} + const bgImage: NewTab.Image | undefined = this.props.newTabData.backgroundImage let gradientClassName = 'gradient' - if (this.showImages) { - backgroundProps.style = this.props.newTabData.backgroundImage.style + if (this.showImages && bgImage) { + backgroundProps.style = bgImage.style gradientClassName = 'bgGradient' } - return
- { - this.showImages - ? - : null - } -
-
-
-
- - - - - - - - -
-
- -
-
+ return ( +
{ - this.props.newTabData.showSiteRemovalNotification - ? + this.showImages && bgImage + ? : null } - { - } +
+
+
+
+ + + + + + + + +
+
+ +
+
+ { + this.props.newTabData.showSiteRemovalNotification + ? + : null + } + +
-
+ ) } } -const mapStateToProps = (state) => ({ +const mapStateToProps = (state: NewTab.ApplicationState) => ({ newTabData: state.newTabData }) -const mapDispatchToProps = (dispatch) => ({ +const mapDispatchToProps = (dispatch: any) => ({ actions: bindActionCreators(newTabActions, dispatch) }) diff --git a/components/brave_new_tab_ui/components/block.tsx b/components/brave_new_tab_ui/components/block.tsx index df59f3e2a5d2..dbf39c5aba96 100644 --- a/components/brave_new_tab_ui/components/block.tsx +++ b/components/brave_new_tab_ui/components/block.tsx @@ -3,40 +3,48 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const cx = require('../../common/classSet') -const DragSource = require('react-dnd').DragSource -const DropTarget = require('react-dnd').DropTarget +import { cx } from '../../common/classSet' +import { + DragSource, DragSourceCollector, + DragSourceConnector, + DragSourceMonitor, DragSourceSpec, + DropTarget, DropTargetCollector, + DropTargetConnector, + DropTargetMonitor, DropTargetSpec +} from 'react-dnd' const Types = { BLOCK: 'block' } -const blockSource = { +const blockSource: DragSourceSpec = { /** * Required. Called when the dragging starts * It's the only data available to the drop targets about the drag source * @see http://gaearon.github.io/react-dnd/docs-drag-source.html#specification-methods */ - beginDrag (props) { + beginDrag (props: Props) { return { id: props.id } }, - endDrag (props, monitor, component) { - const dragId = monitor.getItem().id + endDrag (props: Props, monitor: DragSourceMonitor) { + const item: Props = monitor.getItem() as Props + const draggedId = item.id const didDrop = monitor.didDrop() - props.onDragEnd(dragId, didDrop) + props.onDragEnd(draggedId, didDrop) } } -const blockTarget = { +const blockTarget: DropTargetSpec = { /** * Optional. Called when an item is hovered over the component * @see http://gaearon.github.io/react-dnd/docs-drop-target.html#specification-methods */ - hover (props, monitor) { - const draggedId = monitor.getItem().id + hover (props: Props, monitor: DropTargetMonitor) { + const item: Props = monitor.getItem() as Props + const draggedId = item.id if (draggedId !== props.id) { const dragRight = monitor.getClientOffset().x - monitor.getInitialSourceClientOffset().x > 0 props.onDraggedSite(draggedId, props.id, dragRight) @@ -53,23 +61,54 @@ const blockTarget = { * @see http://gaearon.github.io/react-dnd/docs-drop-target.html#the-collecting-function */ -const sourceCollect = (connect, monitor) => { +const sourceCollect: DragSourceCollector = (connect: DragSourceConnector, monitor: DragSourceMonitor) => { return { connectDragSource: connect.dragSource(), isDragging: monitor.isDragging() } } -const targetCollect = (connect) => { +const targetCollect: DropTargetCollector = (connect: DropTargetConnector) => { return { connectDropTarget: connect.dropTarget() } } -class Block extends React.Component { +interface Props { + id: string + onDragEnd: (draggedId: string, didDrop: boolean) => void + onDraggedSite: (draggedId: string, id: string, dragRight: boolean) => void + connectDragSource?: any + connectDropTarget?: any + onToggleBookmark: () => void + isBookmarked?: boolean + onPinnedTopSite: () => void + isPinned: boolean + onIgnoredTopSite: () => void + title: string + href: string + style: { + backgroundColor: string + } + favicon: string +} + +// TODO remove so many props NZ +export default class Block extends React.Component { render () { - const { isDragging, connectDragSource, connectDropTarget, onToggleBookmark, isBookmarked, onPinnedTopSite, isPinned, onIgnoredTopSite, title, href, style, favicon } = this.props - const opacity = isDragging ? 0 : 1 + const { + connectDragSource, + connectDropTarget, + onToggleBookmark, + isBookmarked, + onPinnedTopSite, + isPinned, + onIgnoredTopSite, + title, + href, + style, + favicon + } = this.props const starIcon = isBookmarked ? 'fa-star' : 'fa-star-o' const pinIcon = isPinned ? 'fa-minus' : 'fa-thumb-tack' @@ -77,9 +116,6 @@ class Block extends React.Component {
+ + + ) } } - -module.exports = FooterInfo diff --git a/components/brave_new_tab_ui/components/newPrivateTab.tsx b/components/brave_new_tab_ui/components/newPrivateTab.tsx index 6c0d899d0f40..6c81c5d95669 100644 --- a/components/brave_new_tab_ui/components/newPrivateTab.tsx +++ b/components/brave_new_tab_ui/components/newPrivateTab.tsx @@ -3,10 +3,10 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { getLocale } = require('../../common/locale') +import { getLocale } from '../../common/locale' // Components -const { +import { Page, Grid, Column, @@ -16,18 +16,24 @@ const { Paragraph, SwitchButton, Clock -} = require('brave-ui') +} from 'brave-ui' -const Stats = require('./stats') +import Stats from './stats' // Theme -const theme = require('./theme') +import { theme } from './theme' require('emptykit.css') // Images const privateTabIcon = require('../../img/newtab/private_tab_pagearea_icon.svg') -class NewPrivateTab extends React.PureComponent { +interface Props { + stats: NewTab.Stats, + useAlternativePrivateSearchEngine: boolean, + onChangePrivateSearchEngine: (e: React.ChangeEvent) => void +} + +export default class NewPrivateTab extends React.PureComponent { render () { const { stats, @@ -44,7 +50,7 @@ class NewPrivateTab extends React.PureComponent { - + @@ -55,13 +61,16 @@ class NewPrivateTab extends React.PureComponent { + text={getLocale('privateNewTabTitle')} + /> + text={getLocale('privateNewTabDisclaimer1')} + /> + text={getLocale('privateNewTabDisclaimer2')} + /> + rightText={getLocale('privateNewTabSearchLabel')} + /> @@ -78,5 +88,3 @@ class NewPrivateTab extends React.PureComponent { ) } } - -module.exports = NewPrivateTab diff --git a/components/brave_new_tab_ui/components/siteRemovalNotification.tsx b/components/brave_new_tab_ui/components/siteRemovalNotification.tsx index 0774f01b8d18..2dbbd711aac0 100644 --- a/components/brave_new_tab_ui/components/siteRemovalNotification.tsx +++ b/components/brave_new_tab_ui/components/siteRemovalNotification.tsx @@ -3,25 +3,30 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const cx = require('../../common/classSet') -class siteRemovalNotification extends React.Component { +interface Props { + onUndoIgnoredTopSite: () => void + onRestoreAll: () => void + onCloseNotification: () => void +} + +export default class SiteRemovalNotification extends React.Component { componentDidMount () { window.i18nTemplate.process(window.document, window.loadTimeData) } render () { - const { onUndoIgnoredTopSite, onRestoreAll, onCloseNotification } = this.props - return
- - - -
+ const { + onUndoIgnoredTopSite, + onRestoreAll, + onCloseNotification + } = this.props + return ( +
+ + + +
+ ) } } - -module.exports = siteRemovalNotification diff --git a/components/brave_new_tab_ui/components/stats.tsx b/components/brave_new_tab_ui/components/stats.tsx index 9e94d646e879..88fda2ec54c5 100644 --- a/components/brave_new_tab_ui/components/stats.tsx +++ b/components/brave_new_tab_ui/components/stats.tsx @@ -3,25 +3,31 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { DataBlock, DataItem } = require('brave-ui/dataBlock') -const { getLocale } = require('../../common/locale') +import { DataBlock, DataItem } from 'brave-ui/dataBlock' +import { getLocale } from '../../common/locale' +import { theme } from './theme' -class Stats extends React.Component { +interface Props { + stats: NewTab.Stats +} + +export default class Stats extends React.Component { get millisecondsPerItem () { return 50 } - get theme () { - return this.props.theme || {} - } + get trackedBlockersCount () { return this.props.stats.trackersBlockedStat || 0 } + get adblockCount () { return this.props.stats.adsBlockedStat || 0 } + get httpsUpgradedCount () { return this.props.stats.httpsUpgradesStat || 0 } + get estimatedTimeSaved () { const estimatedMillisecondsSaved = (this.adblockCount + this.trackedBlockersCount) * this.millisecondsPerItem || 0 const hours = estimatedMillisecondsSaved < 1000 * 60 * 60 * 24 @@ -53,32 +59,37 @@ class Stats extends React.Component { args: JSON.stringify({ value: counter }) } } + render () { - const trackedBlockersCount = this.trackedBlockersCount - const adblockCount = this.adblockCount - const httpsUpgradedCount = this.httpsUpgradedCount + const trackedBlockersCount = this.trackedBlockersCount.toLocaleString() + const adblockCount = this.adblockCount.toLocaleString() + const httpsUpgradedCount = this.httpsUpgradedCount.toLocaleString() const timeSaved = this.estimatedTimeSaved + return ( + counter={trackedBlockersCount} + /> + counter={adblockCount} + /> + counter={httpsUpgradedCount} + /> + description={getLocale('estimatedTimeSaved')} + /> ) } } -module.exports = Stats diff --git a/components/brave_new_tab_ui/components/theme.tsx b/components/brave_new_tab_ui/components/theme.tsx index 1be8a37ddb53..84e89df0d93c 100644 --- a/components/brave_new_tab_ui/components/theme.tsx +++ b/components/brave_new_tab_ui/components/theme.tsx @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const theme = { +export const theme = { newTab: { fontFamily: '"Poppins", sans-serif' }, @@ -65,5 +65,3 @@ const theme = { labelColor: 'rgba(255,255,255,0.8)' } } - -module.exports = theme diff --git a/components/brave_new_tab_ui/constants/newTabTypes.ts b/components/brave_new_tab_ui/constants/newTabTypes.ts index 2f2df00ef3e7..613c07325f6b 100644 --- a/components/brave_new_tab_ui/constants/newTabTypes.ts +++ b/components/brave_new_tab_ui/constants/newTabTypes.ts @@ -2,19 +2,21 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -export const BOOKMARK_ADDED = 'BOOKMARK_ADDED' -export const BOOKMARK_REMOVED = 'BOOKMARK_REMOVED' -export const NEW_TAB_TOP_SITES_DATA_UPDATED = 'NEW_TAB_TOP_SITES_DATA_UPDATED' -export const NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED = 'NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED' -export const NEW_TAB_SITE_PINNED = 'NEW_TAB_SITE_PINNED' -export const NEW_TAB_SITE_UNPINNED = 'NEW_TAB_SITE_UNPINNED' -export const NEW_TAB_SITE_IGNORED = 'NEW_TAB_SITE_IGNORED' -export const NEW_TAB_UNDO_SITE_IGNORED = 'NEW_TAB_UNDO_SITE_IGNORED' -export const NEW_TAB_UNDO_ALL_SITE_IGNORED = 'NEW_TAB_UNDO_ALL_SITE_IGNORED' -export const NEW_TAB_SITE_DRAGGED = 'NEW_TAB_SITE_DRAGGED' -export const NEW_TAB_SITE_DRAG_END = 'NEW_TAB_SITE_DRAG_END' -export const NEW_TAB_HIDE_SITE_REMOVAL_NOTIFICATION = 'NEW_TAB_HIDE_SITE_REMOVAL_NOTIFICATION' -export const NEW_TAB_BOOKMARK_INFO_AVAILABLE = 'NEW_TAB_BOOKMARK_INFO_AVAILABLE' -export const NEW_TAB_GRID_SITES_UPDATED = 'NEW_TAB_GRID_SITES_UPDATED' -export const NEW_TAB_STATS_UPDATED = 'NEW_TAB_STATS_UPDATED' -export const NEW_TAB_USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE = 'NEW_TAB_USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE' +export const enum types { + BOOKMARK_ADDED = '@@newtab/BOOKMARK_ADDED', + BOOKMARK_REMOVED = '@@newtab/BOOKMARK_REMOVED', + NEW_TAB_TOP_SITES_DATA_UPDATED = '@@newtab/NEW_TAB_TOP_SITES_DATA_UPDATED', + NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED = '@@newtab/NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED', + NEW_TAB_SITE_PINNED = '@@newtab/NEW_TAB_SITE_PINNED', + NEW_TAB_SITE_UNPINNED = '@@newtab/NEW_TAB_SITE_UNPINNED', + NEW_TAB_SITE_IGNORED = '@@newtab/NEW_TAB_SITE_IGNORED', + NEW_TAB_UNDO_SITE_IGNORED = '@@newtab/NEW_TAB_UNDO_SITE_IGNORED', + NEW_TAB_UNDO_ALL_SITE_IGNORED = '@@newtab/NEW_TAB_UNDO_ALL_SITE_IGNORED', + NEW_TAB_SITE_DRAGGED = '@@newtab/NEW_TAB_SITE_DRAGGED', + NEW_TAB_SITE_DRAG_END = '@@newtab/NEW_TAB_SITE_DRAG_END', + NEW_TAB_HIDE_SITE_REMOVAL_NOTIFICATION = '@@newtab/NEW_TAB_HIDE_SITE_REMOVAL_NOTIFICATION', + NEW_TAB_BOOKMARK_INFO_AVAILABLE = '@@newtab/NEW_TAB_BOOKMARK_INFO_AVAILABLE', + NEW_TAB_GRID_SITES_UPDATED = '@@newtab/NEW_TAB_GRID_SITES_UPDATED', + NEW_TAB_STATS_UPDATED = '@@newtab/NEW_TAB_STATS_UPDATED', + NEW_TAB_USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE = '@@newtab/NEW_TAB_USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE' +} diff --git a/components/brave_new_tab_ui/reducers/index.ts b/components/brave_new_tab_ui/reducers/index.ts index aa4d45c650d9..c9ebb1f1ef81 100644 --- a/components/brave_new_tab_ui/reducers/index.ts +++ b/components/brave_new_tab_ui/reducers/index.ts @@ -5,7 +5,7 @@ import { combineReducers } from 'redux' import newTabReducer from './newTabReducer' -const combinedReducer = combineReducers({ +const combinedReducer = combineReducers({ newTabData: newTabReducer }) diff --git a/components/brave_new_tab_ui/reducers/newTabReducer.tsx b/components/brave_new_tab_ui/reducers/newTabReducer.tsx index 8f0f878aab47..f68e4929907c 100644 --- a/components/brave_new_tab_ui/reducers/newTabReducer.tsx +++ b/components/brave_new_tab_ui/reducers/newTabReducer.tsx @@ -3,26 +3,30 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ /* global chrome */ -const types = require('../constants/newTabTypes') -const storage = require('../storage') -let getGridSites_ +import { Reducer } from 'redux' -const getGridSites = (...args) => { - if (!getGridSites_) { - getGridSites_ = require('../api').getGridSites +import { types } from '../constants/newTabTypes' +import * as storage from '../storage' + +let getGridSitesCache: (state: NewTab.State, checkBookmarkInfo: boolean) => NewTab.Site[] + +const getGridSites = (state: NewTab.State, checkBookmarkInfo: boolean) => { + if (!getGridSitesCache) { + getGridSitesCache = require('../api').getGridSites } - return getGridSites_(...args) + + return getGridSitesCache(state, checkBookmarkInfo) } -const updateBookmarkInfo = (state, url, bookmarkTreeNode) => { +const updateBookmarkInfo = (state: NewTab.State, url: string, bookmarkTreeNode: any) => { const bookmarks = Object.assign({}, state.bookmarks) const gridSites = state.gridSites.slice() const topSites = state.topSites.slice() const pinnedTopSites = state.pinnedTopSites.slice() // The default empty object is just to avoid null checks below - const gridSite = gridSites.find((s) => s.url === url) || {} - const topSite = topSites.find((s) => s.url === url) || {} - const pinnedTopSite = pinnedTopSites.find((s) => s.url === url) || {} + const gridSite: Partial = gridSites.find((s) => s.url === url) || {} + const topSite: Partial = topSites.find((s) => s.url === url) || {} + const pinnedTopSite: Partial = pinnedTopSites.find((s) => s.url === url) || {} gridSite.bookmarked = topSite.bookmarked = pinnedTopSite.bookmarked = !!bookmarkTreeNode if (bookmarkTreeNode) { bookmarks[url] = bookmarkTreeNode @@ -34,7 +38,7 @@ const updateBookmarkInfo = (state, url, bookmarkTreeNode) => { return state } -const onDraggedSite = (state, url, destUrl, dragRight) => { +const onDraggedSite = (state: NewTab.State, url: string, destUrl: string) => { const gridSitesWithoutPreview = getGridSites(state, false) const currentPositionIndex = gridSitesWithoutPreview.findIndex(site => site.url === url) const finalPositionIndex = gridSitesWithoutPreview.findIndex(site => site.url === destUrl) @@ -66,13 +70,13 @@ const onDraggedSite = (state, url, destUrl, dragRight) => { return state } -const onDragEnd = (state) => { +const onDragEnd = (state: NewTab.State) => { state = { ...state, gridSites: getGridSites(state, false) } return state } -let calculateGridSites -const newTabReducer = (state, action) => { +let calculateGridSites: any +const newTabReducer: Reducer = (state: NewTab.State, action) => { if (state === undefined) { calculateGridSites = require('../api').calculateGridSites setImmediate(() => { @@ -87,15 +91,18 @@ const newTabReducer = (state, action) => { switch (action.type) { case types.BOOKMARK_ADDED: const { fetchBookmarkInfo } = require('../api') - const topSite = state.topSites.findIndex((site) => site.url === action.url) - chrome.bookmarks.create({ - title: topSite.title, - url: topSite.url - }, () => { - fetchBookmarkInfo(action.url) - }) + const topSite: NewTab.Site | undefined = state.topSites.find((site) => site.url === action.url) + if (topSite) { + chrome.bookmarks.create({ + title: topSite.title, + url: topSite.url + }, () => { + fetchBookmarkInfo(action.url) + }) + } break case types.BOOKMARK_REMOVED: + // TODO somewhere we are saying that bookmarks is Record of booleans, but here we are using id const bookmarkInfo = state.bookmarks[action.url] if (bookmarkInfo) { chrome.bookmarks.remove(bookmarkInfo.id, () => { @@ -109,7 +116,7 @@ const newTabReducer = (state, action) => { break case types.NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED: { const source = '/50cc52a4f1743ea74a21da996fe44272.jpg' - const fallbackImage = { + const fallbackImage: NewTab.Image = { name: 'Bay Bridge', source, style: { backgroundImage: 'url(' + source + ')' }, @@ -133,9 +140,10 @@ const newTabReducer = (state, action) => { } case types.NEW_TAB_SITE_PINNED: { - const topSiteIndex = state.topSites.findIndex((site) => site.url === action.url) - const pinnedTopSite = Object.assign({}, state.topSites[topSiteIndex], { pinned: true }) - const pinnedTopSites = state.pinnedTopSites.slice() + const topSiteIndex: number = state.topSites.findIndex((site) => site.url === action.url) + const pinnedTopSite: NewTab.Site = Object.assign({}, state.topSites[topSiteIndex], { pinned: true }) + const pinnedTopSites: NewTab.Site[] = state.pinnedTopSites.slice() + pinnedTopSite.index = topSiteIndex pinnedTopSites.push(pinnedTopSite) pinnedTopSites.sort((x, y) => x.index - y.index) @@ -148,9 +156,9 @@ const newTabReducer = (state, action) => { } case types.NEW_TAB_SITE_UNPINNED: - const currentPositionIndex = state.pinnedTopSites.findIndex((site) => site.url === action.url) + const currentPositionIndex: number = state.pinnedTopSites.findIndex((site) => site.url === action.url) if (currentPositionIndex !== -1) { - const pinnedTopSites = state.pinnedTopSites.slice() + const pinnedTopSites: NewTab.Site[] = state.pinnedTopSites.slice() pinnedTopSites.splice(currentPositionIndex, 1) state = { ...state, @@ -161,8 +169,8 @@ const newTabReducer = (state, action) => { break case types.NEW_TAB_SITE_IGNORED: { - const topSiteIndex = state.topSites.findIndex((site) => site.url === action.url) - const ignoredTopSites = state.ignoredTopSites.slice() + const topSiteIndex: number = state.topSites.findIndex((site) => site.url === action.url) + const ignoredTopSites: NewTab.Site[] = state.ignoredTopSites.slice() ignoredTopSites.splice(0, 1, state.topSites[topSiteIndex]) state = { ...state, @@ -174,7 +182,7 @@ const newTabReducer = (state, action) => { } case types.NEW_TAB_UNDO_SITE_IGNORED: { - const ignoredTopSites = state.ignoredTopSites.slice() + const ignoredTopSites: NewTab.Site[] = state.ignoredTopSites.slice() ignoredTopSites.pop() state = { ...state, @@ -202,11 +210,11 @@ const newTabReducer = (state, action) => { break case types.NEW_TAB_SITE_DRAGGED: - state = onDraggedSite(state, action.fromUrl, action.toUrl, action.dragRight) + state = onDraggedSite(state, action.fromUrl, action.toUrl) break case types.NEW_TAB_SITE_DRAG_END: - state = onDragEnd(state, action.url) + state = onDragEnd(state) break case types.NEW_TAB_BOOKMARK_INFO_AVAILABLE: diff --git a/components/brave_new_tab_ui/storage.ts b/components/brave_new_tab_ui/storage.ts index d4874be2fd5b..0d596b8fea44 100644 --- a/components/brave_new_tab_ui/storage.ts +++ b/components/brave_new_tab_ui/storage.ts @@ -2,19 +2,41 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -import {debounce} from '../common/debounce' +import { debounce } from '../common/debounce' const backgrounds = require('./backgrounds') const keyName = 'new-tab-data' -const randomBackgroundImage = () => { - const randomIndex = Math.floor(Math.random() * backgrounds.length) - const image = Object.assign({}, backgrounds[randomIndex]) - image.style = { backgroundImage: 'url(' + image.source + ')' } +const defaultState: NewTab.State = { + topSites: [], + ignoredTopSites: [], + pinnedTopSites: [], + gridSites: [], + showImages: true, + imageLoadFailed: false, + showEmptyPage: false, + isIncognito: chrome.extension.inIncognitoContext, + useAlternativePrivateSearchEngine: false, + bookmarks: {}, + stats: { + adsBlockedStat: 0, + trackersBlockedStat: 0, + javascriptBlockedStat: 0, + httpsUpgradesStat: 0, + fingerprintingBlockedStat: 0 + } +} + +const randomBackgroundImage = (): NewTab.Image => { + const randomIndex: number = Math.floor(Math.random() * backgrounds.length) + const image: NewTab.Image = Object.assign({}, backgrounds[randomIndex]) + image.style = { + backgroundImage: 'url(' + image.source + ')' + } return image } -const cleanData = (state) => { +const cleanData = (state: NewTab.State): NewTab.State => { state = { ...state } state.backgroundImage = randomBackgroundImage() delete state.imageLoadFailed @@ -22,30 +44,19 @@ const cleanData = (state) => { return state } -module.exports.getLoadTimeData = (state) => { +export const getLoadTimeData = (state: NewTab.State) => { state = { ...state } - state.stats = {} + state.stats = defaultState.stats ;['adsBlockedStat', 'trackersBlockedStat', 'javascriptBlockedStat', - 'httpsUpgradesStat', 'fingerprintingBlockedStat'].forEach( - (stat) => { state.stats[stat] = parseInt(chrome.getVariableValue(stat)) }) + 'httpsUpgradesStat', 'fingerprintingBlockedStat'].forEach((stat) => { + state.stats[stat] = parseInt(chrome.getVariableValue(stat), 10) || 0 + }) return state } -module.exports.getInitialState = () => cleanData({ - topSites: [], - ignoredTopSites: [], - pinnedTopSites: [], - gridSites: [], - showImages: true, - imageLoadFailed: false, - showEmptyPage: false, - isIncognito: chrome.extension.inIncognitoContext, - useAlternativePrivateSearchEngine: false, - bookmarks: {}, - stats: {} -}) +export const getInitialState = () => cleanData(defaultState) -module.exports.load = () => { +export const load = () => { const data = window.localStorage.getItem(keyName) let state if (data) { @@ -58,7 +69,7 @@ module.exports.load = () => { return cleanData(state) } -module.exports.debouncedSave = debounce((data) => { +export const debouncedSave = debounce((data: NewTab.State) => { if (data) { window.localStorage.setItem(keyName, JSON.stringify(cleanData(data))) } diff --git a/components/brave_new_tab_ui/store.ts b/components/brave_new_tab_ui/store.ts index 426939fda2d6..4a2f7f5bcfa8 100644 --- a/components/brave_new_tab_ui/store.ts +++ b/components/brave_new_tab_ui/store.ts @@ -5,5 +5,4 @@ import { createStore } from 'redux' import reducers from './reducers' -const store = createStore(reducers) -module.exports = store +export const store = createStore(reducers) diff --git a/components/brave_rewards_ui/components/app.ts b/components/brave_rewards_ui/components/app.ts index 893018fdce08..375b71e7079b 100644 --- a/components/brave_rewards_ui/components/app.ts +++ b/components/brave_rewards_ui/components/app.ts @@ -8,7 +8,7 @@ const { connect } = require('react-redux') const rewardsActions = require('../actions/rewards_actions') const CreateWalletLink = (props) => - href = '#' onClick = { props.createWalletClicked } > Create Wallet< /a> + href = '#' onClick = { props.createWalletClicked } > Create Wallet/a> as < /div> class RewardsPage extends React.Component { @@ -29,17 +29,16 @@ class RewardsPage extends React.Component { const { rewardsData } = this.props return ( createWalletClicked = { this.onCreateWalletClicked } / > - { - rewardsData.walletCreated - ? Wallet Created!/div> as + { + rewardsData.walletCreated + ? Wallet Created!/div> as : null - } - { - rewardsData.walletCreateFailed - ? Wallet Create Failed! < /div> - : null - } - /div>) as + { + rewardsData.walletCreateFailed + ? Wallet Create Failed! < /div> + : null + } + / div > ) as } } @@ -54,4 +53,4 @@ const mapDispatchToProps = (dispatch) => ({ export default connect( mapStateToProps, mapDispatchToProps -)(RewardsPage) +) (RewardsPage) diff --git a/components/common/classSet.ts b/components/common/classSet.ts index 24fc82503079..0ade1c8492c4 100644 --- a/components/common/classSet.ts +++ b/components/common/classSet.ts @@ -7,4 +7,4 @@ * Only the property names with truthy values are included. */ // TODO remove NZ -module.exports = (obj) => Object.keys(obj).filter((prop) => obj[prop]).join(' ') +export const cx = (obj: any) => Object.keys(obj).filter((prop) => obj[prop]).join(' ') diff --git a/components/definitions/adBlock.d.ts b/components/definitions/adBlock.d.ts index 34c3aa3b76d4..86af657766bc 100644 --- a/components/definitions/adBlock.d.ts +++ b/components/definitions/adBlock.d.ts @@ -1,4 +1,8 @@ declare namespace AdBlock { + export interface ApplicationState { + adblockData: State + } + export interface State { stats: { adsBlockedStat?: number diff --git a/components/definitions/chromel.d.ts b/components/definitions/chromel.d.ts index b0b27b01008c..cefe19012c2e 100644 --- a/components/definitions/chromel.d.ts +++ b/components/definitions/chromel.d.ts @@ -3,9 +3,5 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ declare namespace chrome { - function getVariableValue(stat: string): string - - const extension: { - inIncognitoContext: boolean - } + function getVariableValue (stat: string): string } diff --git a/components/definitions/global.d.ts b/components/definitions/global.d.ts index 8f140c69367d..c2dfe1fc69d3 100644 --- a/components/definitions/global.d.ts +++ b/components/definitions/global.d.ts @@ -3,7 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ export {} -type Translations = {[key: string]: string}[] +type Translations = Record[] declare global { interface Window { @@ -17,5 +17,9 @@ declare global { brave_adblock: { initialize: () => void } + brave_new_tab: { + initialize: () => void + statsUpdated: () => void + } } } diff --git a/components/definitions/newTab.d.ts b/components/definitions/newTab.d.ts new file mode 100644 index 000000000000..7c408365f639 --- /dev/null +++ b/components/definitions/newTab.d.ts @@ -0,0 +1,57 @@ +declare namespace NewTab { + export interface ApplicationState { + newTabData: State + } + + export interface Image { + name: string, + source: string, + author: string, + link: string, + style?: { + backgroundImage: string + } + } + + export interface Site { + index: number + url: string + title: string + favicon: string + letter: string + thumb: string + themeColor: string + computedThemeColor: string + pinned: boolean + bookmarked?: boolean + } + + export interface Stats { + adsBlockedStat: number + trackersBlockedStat: number + javascriptBlockedStat: number + httpsUpgradesStat: number + fingerprintingBlockedStat: number + } + + export interface State { + imageLoadFailed: boolean + topSites: Site[], + ignoredTopSites: Site[], + pinnedTopSites: Site[], + gridSites: Site[], + showImages: boolean, + showEmptyPage: boolean, + isIncognito: boolean, + useAlternativePrivateSearchEngine: boolean, + bookmarks: Record, + stats: Stats + backgroundImage?: Image + gridLayoutSize?: 'small' + showSiteRemovalNotification?: boolean + } + + export interface Actions { + statsUpdated: any + } +} diff --git a/package-lock.json b/package-lock.json index fd1cfcaa4fd3..dc43282eccd4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,30 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/chrome": { + "version": "0.0.69", + "resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.69.tgz", + "integrity": "sha512-esiuhfTrm0pVYuLpX5St2iv1AtLDZdM6Pvc2fIrtXNeJ1OJ6YRwLzz4LlgHiYkcXI6wUCYYmDMbIH6NnShBaPQ==", + "dev": true, + "requires": { + "@types/filesystem": "*" + } + }, + "@types/filesystem": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/@types/filesystem/-/filesystem-0.0.28.tgz", + "integrity": "sha1-P9dzWDDyx0E8taxFeAvEWQRpew4=", + "dev": true, + "requires": { + "@types/filewriter": "*" + } + }, + "@types/filewriter": { + "version": "0.0.28", + "resolved": "https://registry.npmjs.org/@types/filewriter/-/filewriter-0.0.28.tgz", + "integrity": "sha1-wFTor02d11205jq8dviFFocU1LM=", + "dev": true + }, "@types/node": { "version": "10.5.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.2.tgz", @@ -19,6 +43,15 @@ "csstype": "^2.2.0" } }, + "@types/react-dnd": { + "version": "2.0.36", + "resolved": "https://registry.npmjs.org/@types/react-dnd/-/react-dnd-2.0.36.tgz", + "integrity": "sha512-jA95HjQxuHNSnr0PstVBjRwVcFJZoinxbtsS4bpi5nwAL5GUOtjrLrq1bDi4WNYxW+77KHvqSAZ2EgA2q9evdA==", + "dev": true, + "requires": { + "@types/react": "*" + } + }, "@types/react-dom": { "version": "16.0.6", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.0.6.tgz", @@ -88,6 +121,12 @@ "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" }, + "autobind-decorator": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/autobind-decorator/-/autobind-decorator-2.1.0.tgz", + "integrity": "sha512-bgyxeRi1R2Q8kWpHsb1c+lXCulbIAHsyZRddaS+agAUX3hFUVZMociwvRgeZi1zWvfqEEjybSv4zxWvFV8ydQQ==", + "dev": true + }, "babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", @@ -126,6 +165,22 @@ } } }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "dependencies": { + "core-js": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" + } + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -208,6 +263,11 @@ } } }, + "change-emitter": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/change-emitter/-/change-emitter-0.1.6.tgz", + "integrity": "sha1-6LL+PX8at9aaMhma/5HqaTFAlRU=" + }, "color-convert": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", @@ -267,6 +327,17 @@ "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, + "dnd-core": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/dnd-core/-/dnd-core-4.0.5.tgz", + "integrity": "sha1-O4PRONDV4mXHPsl43sXh7UQdxmU=", + "requires": { + "asap": "^2.0.6", + "invariant": "^2.2.4", + "lodash": "^4.17.10", + "redux": "^4.0.0" + } + }, "doctrine": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", @@ -398,6 +469,14 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "requires": { + "loose-envify": "^1.0.0" + } + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -449,8 +528,7 @@ "lodash": { "version": "4.17.10", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, "lodash-es": { "version": "4.17.10", @@ -532,21 +610,68 @@ "object-assign": "^4.1.1" } }, + "react-dnd": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-5.0.0.tgz", + "integrity": "sha1-xKF8cBCeRW2tiQa+g45u6PMrBrU=", + "requires": { + "dnd-core": "^4.0.5", + "hoist-non-react-statics": "^2.5.0", + "invariant": "^2.1.0", + "lodash": "^4.17.10", + "recompose": "^0.27.1", + "shallowequal": "^1.0.2" + } + }, + "react-dnd-html5-backend": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/react-dnd-html5-backend/-/react-dnd-html5-backend-5.0.1.tgz", + "integrity": "sha1-C1eNecXAExfHBBTI1xf2MrkZ1PE=", + "dev": true, + "requires": { + "autobind-decorator": "^2.1.0", + "dnd-core": "^4.0.5", + "lodash": "^4.17.10", + "shallowequal": "^1.0.2" + } + }, "react-is": { "version": "16.4.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.4.1.tgz", "integrity": "sha512-xpb0PpALlFWNw/q13A+1aHeyJyLYCg0/cCHPUA43zYluZuIPHaHL3k8OBsTgQtxqW0FhyDEMvi8fZ/+7+r4OSQ==" }, + "react-lifecycles-compat": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", + "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" + }, + "recompose": { + "version": "0.27.1", + "resolved": "https://registry.npmjs.org/recompose/-/recompose-0.27.1.tgz", + "integrity": "sha512-p7xsyi/rfNjHfdP7vPU02uSFa+Q1eHhjKrvO+3+kRP4Ortj+MxEmpmd+UQtBGM2D2iNAjzNI5rCyBKp9Ob5McA==", + "requires": { + "babel-runtime": "^6.26.0", + "change-emitter": "^0.1.2", + "fbjs": "^0.8.1", + "hoist-non-react-statics": "^2.3.1", + "react-lifecycles-compat": "^3.0.2", + "symbol-observable": "^1.0.4" + } + }, "redux": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/redux/-/redux-4.0.0.tgz", "integrity": "sha512-NnnHF0h0WVE/hXyrB6OlX67LYRuaf/rJcbWvnHHEPCF/Xa/AZpwhs/20WyqzQae5x4SD2F9nPObgBh2rxAgLiA==", - "dev": true, "requires": { "loose-envify": "^1.1.0", "symbol-observable": "^1.2.0" } }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + }, "resolve": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", @@ -572,6 +697,11 @@ "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" }, + "shallowequal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", + "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -625,8 +755,7 @@ "symbol-observable": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", - "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", - "dev": true + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==" }, "tslib": { "version": "1.9.3", diff --git a/package.json b/package.json index bb9a0097f407..c8feb7b3d512 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "lint": "tslint --project tsconfig.json 'components/**/*.{ts,tsx}'", + "lint-fix": "tslint --project tsconfig.json 'components/**/*.{ts,tsx}' --fix", "test-security": "npm audit" }, "repository": { @@ -35,10 +36,13 @@ }, "homepage": "https:/github.com/brave/brave-core#readme", "devDependencies": { + "@types/chrome": "0.0.69", "@types/react": "^16.0.26", + "@types/react-dnd": "^2.0.36", "@types/react-dom": "^16.0.3", "@types/react-redux": "^6.0.4", "@types/redux-logger": "^3.0.5", + "react-dnd-html5-backend": "^5.0.1", "tslint": "^5.8.0", "tslint-config-standard": "^7.0.0", "tslint-react": "^3.2.0", @@ -47,6 +51,7 @@ "dependencies": { "brave-ui": "^0.12.2", "emptykit.css": "^1.0.1", + "react-dnd": "^5.0.0", "typesafe-actions": "^2.0.4" } } From d7d349689b2d7df8ff4178ce19dd7ffed9610c6b Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 16 Jul 2018 06:00:13 +0200 Subject: [PATCH 5/9] Converts rewards into TS --- .../reducers/newTabReducer.tsx | 1 - .../actions/rewards_actions.ts | 13 ++----- .../components/{app.ts => app.tsx} | 38 +++++++++---------- .../constants/rewards_types.ts | 8 ++-- components/brave_rewards_ui/reducers/index.ts | 2 +- .../reducers/rewards_reducer.ts | 8 ++-- components/brave_rewards_ui/storage.ts | 13 ++++--- .../{braveScreen.js => braveScreen.tsx} | 0 .../{featuresScreen.js => featuresScreen.tsx} | 0 .../components/{footer.js => footer.tsx} | 0 .../{importScreen.js => importScreen.tsx} | 0 .../{rewardsScreen.js => rewardsScreen.tsx} | 0 .../{shiedsScreen.js => shiedsScreen.tsx} | 0 .../brave_welcome_ui/{theme.js => theme.ts} | 0 components/definitions/chromel.d.ts | 1 + components/definitions/global.d.ts | 5 +++ components/definitions/rewards.d.ts | 10 +++++ 17 files changed, 55 insertions(+), 44 deletions(-) rename components/brave_rewards_ui/components/{app.ts => app.tsx} (56%) rename components/brave_welcome_ui/components/{braveScreen.js => braveScreen.tsx} (100%) rename components/brave_welcome_ui/components/{featuresScreen.js => featuresScreen.tsx} (100%) rename components/brave_welcome_ui/components/{footer.js => footer.tsx} (100%) rename components/brave_welcome_ui/components/{importScreen.js => importScreen.tsx} (100%) rename components/brave_welcome_ui/components/{rewardsScreen.js => rewardsScreen.tsx} (100%) rename components/brave_welcome_ui/components/{shiedsScreen.js => shiedsScreen.tsx} (100%) rename components/brave_welcome_ui/{theme.js => theme.ts} (100%) create mode 100644 components/definitions/rewards.d.ts diff --git a/components/brave_new_tab_ui/reducers/newTabReducer.tsx b/components/brave_new_tab_ui/reducers/newTabReducer.tsx index f68e4929907c..0bf0c9997239 100644 --- a/components/brave_new_tab_ui/reducers/newTabReducer.tsx +++ b/components/brave_new_tab_ui/reducers/newTabReducer.tsx @@ -1,7 +1,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global chrome */ import { Reducer } from 'redux' diff --git a/components/brave_rewards_ui/actions/rewards_actions.ts b/components/brave_rewards_ui/actions/rewards_actions.ts index e20d5314a9c2..52ac47753ba3 100644 --- a/components/brave_rewards_ui/actions/rewards_actions.ts +++ b/components/brave_rewards_ui/actions/rewards_actions.ts @@ -2,16 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { action } from 'typesafe-actions' const types = require('../constants/rewards_types') -export const createWalletRequested = () => ({ - type: types.CREATE_WALLET_REQUESTED -}) +export const createWalletRequested = () => action(types.CREATE_WALLET_REQUESTED) -export const walletCreated = () => ({ - type: types.WALLET_CREATED -}) +export const walletCreated = () => action(types.WALLET_CREATED) -export const walletCreateFailed = () => ({ - type: types.WALLET_CREATE_FAILED -}) +export const walletCreateFailed = () => action(types.WALLET_CREATE_FAILED) diff --git a/components/brave_rewards_ui/components/app.ts b/components/brave_rewards_ui/components/app.tsx similarity index 56% rename from components/brave_rewards_ui/components/app.ts rename to components/brave_rewards_ui/components/app.tsx index 375b71e7079b..62482f9a7860 100644 --- a/components/brave_rewards_ui/components/app.ts +++ b/components/brave_rewards_ui/components/app.tsx @@ -2,22 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -import * as React from 'react' +const React = require('react') const { bindActionCreators } = require('redux') const { connect } = require('react-redux') const rewardsActions = require('../actions/rewards_actions') -const CreateWalletLink = (props) => - href = '#' onClick = { props.createWalletClicked } > Create Wallet/a> as - < /div> - class RewardsPage extends React.Component { - constructor (props) { - super(props) - this.onCreateWalletClicked = this.onCreateWalletClicked.bind(this) - } - - onCreateWalletClicked () { + onCreateWalletClicked = () => { this.actions.createWalletRequested() } @@ -28,29 +19,34 @@ class RewardsPage extends React.Component { render () { const { rewardsData } = this.props return ( - createWalletClicked = { this.onCreateWalletClicked } / > +
+ { rewardsData.walletCreated - ? Wallet Created!/div> as + ?
Wallet Created!
: null + } { - rewardsData.walletCreateFailed - ? Wallet Create Failed! < /div> - : null - } - / div > ) as + rewardsData.walletCreateFailed + ?
Wallet Create Failed!
+ : null + } +
+ ) } } -const mapStateToProps = (state) => ({ +const mapStateToProps = (state: Rewards.ApplicationState) => ({ rewardsData: state.rewardsData }) -const mapDispatchToProps = (dispatch) => ({ +const mapDispatchToProps = (dispatch: any) => ({ actions: bindActionCreators(rewardsActions, dispatch) }) export default connect( mapStateToProps, mapDispatchToProps -) (RewardsPage) +)(RewardsPage) diff --git a/components/brave_rewards_ui/constants/rewards_types.ts b/components/brave_rewards_ui/constants/rewards_types.ts index 2c90b830451e..f4aeff498634 100644 --- a/components/brave_rewards_ui/constants/rewards_types.ts +++ b/components/brave_rewards_ui/constants/rewards_types.ts @@ -2,6 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -export const CREATE_WALLET_REQUESTED = 'CREATE_WALLET_REQUESTED' -export const WALLET_CREATED = 'WALLET_CREATED' -export const WALLET_CREATE_FAILED = 'WALLET_CREATE_FAILED' +export const enum types { + CREATE_WALLET_REQUESTED = '@@rewards/CREATE_WALLET_REQUESTED', + WALLET_CREATED = '@@rewards/WALLET_CREATED', + WALLET_CREATE_FAILED = '@@rewards/WALLET_CREATE_FAILED' +} diff --git a/components/brave_rewards_ui/reducers/index.ts b/components/brave_rewards_ui/reducers/index.ts index dd69ce98bcfb..2305e7e49e1e 100644 --- a/components/brave_rewards_ui/reducers/index.ts +++ b/components/brave_rewards_ui/reducers/index.ts @@ -5,7 +5,7 @@ import { combineReducers } from 'redux' import rewardsReducer from './rewards_reducer' -const combinedReducer = combineReducers({ +const combinedReducer = combineReducers({ rewardsData: rewardsReducer }) diff --git a/components/brave_rewards_ui/reducers/rewards_reducer.ts b/components/brave_rewards_ui/reducers/rewards_reducer.ts index dc32f8402988..1313782355aa 100644 --- a/components/brave_rewards_ui/reducers/rewards_reducer.ts +++ b/components/brave_rewards_ui/reducers/rewards_reducer.ts @@ -2,16 +2,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global chrome */ +import { Reducer } from 'redux' const types = require('../constants/rewards_types') const storage = require('../storage') -const rewardsReducer = (state, action) => { +const rewardsReducer: Reducer = (state: Rewards.State, action) => { if (state === undefined) { - state = storage.load() || {} - state = Object.assign(storage.getInitialState(), state) + state = storage.load() } + const startingState = state switch (action.type) { case types.CREATE_WALLET_REQUESTED: diff --git a/components/brave_rewards_ui/storage.ts b/components/brave_rewards_ui/storage.ts index ffed7631bbb8..9c8f8b05f7f8 100644 --- a/components/brave_rewards_ui/storage.ts +++ b/components/brave_rewards_ui/storage.ts @@ -6,13 +6,16 @@ const debounce = require('../common/debounce') const keyName = 'rewards-data' -const cleanData = (state) => ({}) +const defaultState: Rewards.State = { + walletCreated: false, + walletCreateFailed: false +} -module.exports.getInitialState = () => cleanData({}) +export const getInitialState = (): Rewards.State => cleanData(defaultState) -module.exports.load = () => { +export const load = () => { const data = window.localStorage.getItem(keyName) - let state + let state: Rewards.State = getInitialState() if (data) { try { state = JSON.parse(data) @@ -23,7 +26,7 @@ module.exports.load = () => { return cleanData(state) } -module.exports.debouncedSave = debounce((data) => { +export const debouncedSave = debounce((data: Rewards.State) => { if (data) { window.localStorage.setItem(keyName, JSON.stringify(cleanData(data))) } diff --git a/components/brave_welcome_ui/components/braveScreen.js b/components/brave_welcome_ui/components/braveScreen.tsx similarity index 100% rename from components/brave_welcome_ui/components/braveScreen.js rename to components/brave_welcome_ui/components/braveScreen.tsx diff --git a/components/brave_welcome_ui/components/featuresScreen.js b/components/brave_welcome_ui/components/featuresScreen.tsx similarity index 100% rename from components/brave_welcome_ui/components/featuresScreen.js rename to components/brave_welcome_ui/components/featuresScreen.tsx diff --git a/components/brave_welcome_ui/components/footer.js b/components/brave_welcome_ui/components/footer.tsx similarity index 100% rename from components/brave_welcome_ui/components/footer.js rename to components/brave_welcome_ui/components/footer.tsx diff --git a/components/brave_welcome_ui/components/importScreen.js b/components/brave_welcome_ui/components/importScreen.tsx similarity index 100% rename from components/brave_welcome_ui/components/importScreen.js rename to components/brave_welcome_ui/components/importScreen.tsx diff --git a/components/brave_welcome_ui/components/rewardsScreen.js b/components/brave_welcome_ui/components/rewardsScreen.tsx similarity index 100% rename from components/brave_welcome_ui/components/rewardsScreen.js rename to components/brave_welcome_ui/components/rewardsScreen.tsx diff --git a/components/brave_welcome_ui/components/shiedsScreen.js b/components/brave_welcome_ui/components/shiedsScreen.tsx similarity index 100% rename from components/brave_welcome_ui/components/shiedsScreen.js rename to components/brave_welcome_ui/components/shiedsScreen.tsx diff --git a/components/brave_welcome_ui/theme.js b/components/brave_welcome_ui/theme.ts similarity index 100% rename from components/brave_welcome_ui/theme.js rename to components/brave_welcome_ui/theme.ts diff --git a/components/definitions/chromel.d.ts b/components/definitions/chromel.d.ts index cefe19012c2e..57d49d479ef2 100644 --- a/components/definitions/chromel.d.ts +++ b/components/definitions/chromel.d.ts @@ -4,4 +4,5 @@ declare namespace chrome { function getVariableValue (stat: string): string + function send (stat: string, args?: any[]): void } diff --git a/components/definitions/global.d.ts b/components/definitions/global.d.ts index c2dfe1fc69d3..981609fea0c5 100644 --- a/components/definitions/global.d.ts +++ b/components/definitions/global.d.ts @@ -21,5 +21,10 @@ declare global { initialize: () => void statsUpdated: () => void } + brave_rewards: { + initialize: () => void + walletCreated: () => void + walletCreateFailed: () => void + } } } diff --git a/components/definitions/rewards.d.ts b/components/definitions/rewards.d.ts new file mode 100644 index 000000000000..9d1ef7836f33 --- /dev/null +++ b/components/definitions/rewards.d.ts @@ -0,0 +1,10 @@ +declare namespace Rewards { + export interface ApplicationState { + rewardsData: State + } + + export interface State { + walletCreated: boolean + walletCreateFailed: boolean + } +} From f46f99f9c50cff48b6aaab970f897ce88eb955d8 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 16 Jul 2018 06:35:34 +0200 Subject: [PATCH 6/9] Converts welcome into TS --- .../actions/welcome_actions.ts | 9 +-- .../brave_welcome_ui/components/app.tsx | 81 +++++++++---------- .../components/braveScreen.tsx | 26 +++--- .../components/featuresScreen.tsx | 17 ++-- .../brave_welcome_ui/components/footer.tsx | 65 ++++++++------- .../components/importScreen.tsx | 26 +++--- .../components/rewardsScreen.tsx | 19 ++--- .../components/shiedsScreen.tsx | 18 +++-- .../constants/welcome_types.ts | 6 +- .../reducers/welcome_reducer.ts | 11 +-- components/brave_welcome_ui/storage.ts | 10 +-- components/brave_welcome_ui/theme.ts | 4 +- components/definitions/global.d.ts | 3 + components/definitions/welcome.d.ts | 9 +++ package-lock.json | 8 +- 15 files changed, 160 insertions(+), 152 deletions(-) create mode 100644 components/definitions/welcome.d.ts diff --git a/components/brave_welcome_ui/actions/welcome_actions.ts b/components/brave_welcome_ui/actions/welcome_actions.ts index f91317bd9909..55dd49e5d205 100644 --- a/components/brave_welcome_ui/actions/welcome_actions.ts +++ b/components/brave_welcome_ui/actions/welcome_actions.ts @@ -2,13 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { action } from 'typesafe-actions' + const types = require('../constants/welcome_types') -export const importNowRequested = () => ({ - type: types.IMPORT_NOW_REQUESTED -}) +export const importNowRequested = () => action(types.IMPORT_NOW_REQUESTED) -export const goToPageRequested = (pageIndex) => ({ - type: types.GO_TO_PAGE_REQUESTED, +export const goToPageRequested = (pageIndex: number) => action(types.GO_TO_PAGE_REQUESTED, { pageIndex }) diff --git a/components/brave_welcome_ui/components/app.tsx b/components/brave_welcome_ui/components/app.tsx index 732507211313..2611b5274b52 100644 --- a/components/brave_welcome_ui/components/app.tsx +++ b/components/brave_welcome_ui/components/app.tsx @@ -3,40 +3,34 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { bindActionCreators } = require('redux') -const { connect } = require('react-redux') -const welcomeActions = require('../actions/welcome_actions') +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import { UnstyledButton } from 'brave-ui' +import Panel from 'brave-ui/v1/panel' // Components -const { UnstyledButton } = require('brave-ui') -const Panel = require('brave-ui/v1/panel').default - -// Theme -const theme = require('../theme') - -// Screens -const BraveScreen = require('./braveScreen') -const RewardsScreen = require('./rewardsScreen') -const ImportScreen = require('./importScreen') -const ShieldsScreen = require('./shiedsScreen') -const FeaturesScreen = require('./featuresScreen') -const Footer = require('./footer') - -// Images +import BraveScreen from './braveScreen' +import RewardsScreen from './rewardsScreen' +import ImportScreen from './importScreen' +import ShieldsScreen from './shiedsScreen' +import FeaturesScreen from './featuresScreen' +import Footer from './footer' + +// Utils +import * as welcomeActions from '../actions/welcome_actions' +import { theme } from '../theme' + +// Assets const background = require('../../img/welcome/welcomebg.svg') - -// Fonts require('../../fonts/muli.css') require('../../fonts/poppins.css') -class WelcomePage extends React.Component { - constructor (props) { - super(props) - this.onImportNowClicked = this.onImportNowClicked.bind(this) - this.onGoToFirstSlide = this.onGoToSlide.bind(this, 1) - this.onClickNext = this.onClickNext.bind(this) - } +interface Props { + welcomeData: Welcome.State + actions: any +} +class WelcomePage extends React.Component { get pageIndex () { return this.props.welcomeData.pageIndex } @@ -58,22 +52,22 @@ class WelcomePage extends React.Component { get activeScreen () { switch (this.pageIndex) { case 0: - return + return case 1: - return + return case 2: - return + return case 3: - return + return case 4: - return + return default: - return + return } } get slideBullets () { - return Array.from({length: this.totalSecondaryScreensSize}, (v, k) => { + return Array.from({ length: this.totalSecondaryScreensSize }, (v, k) => { return ( { + this.onGoToSlide(1) + } + + onGoToSlide = (nextPage: number) => { this.actions.goToPageRequested(nextPage) } - onClickNext () { + onClickNext = () => { this.actions.goToPageRequested(this.pageIndex + 1) } - onImportNowClicked () { + onImportNowClicked = () => { this.actions.importNowRequested() } @@ -138,14 +136,13 @@ class WelcomePage extends React.Component { return (
- { this.activeScreen } + {this.activeScreen}
- { this.slideBullets } + {this.slideBullets}
@@ -153,11 +150,11 @@ class WelcomePage extends React.Component { } } -const mapStateToProps = (state) => ({ +const mapStateToProps = (state: Welcome.ApplicationState) => ({ welcomeData: state.welcomeData }) -const mapDispatchToProps = (dispatch) => ({ +const mapDispatchToProps = (dispatch: any) => ({ actions: bindActionCreators(welcomeActions, dispatch) }) diff --git a/components/brave_welcome_ui/components/braveScreen.tsx b/components/brave_welcome_ui/components/braveScreen.tsx index 33ec44d021fe..ce2f2ec1d0f8 100644 --- a/components/brave_welcome_ui/components/braveScreen.tsx +++ b/components/brave_welcome_ui/components/braveScreen.tsx @@ -2,25 +2,25 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { getLocale } = require('../../common/locale') -const Image = require('brave-ui/v1/image').default -const PushButton = require('brave-ui/v1/pushButton').PushButton -const { Heading, Paragraph } = require('brave-ui') +import * as React from 'react' +import { getLocale } from '../../common/locale' +import Image from 'brave-ui/v1/image' +import { PushButton } from 'brave-ui/v1/pushButton' +import { Heading, Paragraph } from 'brave-ui' +import { theme } from '../theme' + const braveLogo = require('../../img/welcome/brave_logo.png') -class BraveScreen extends React.PureComponent { - constructor (props) { - super(props) - this.onClickLetsGo = this.onClickLetsGo.bind(this) - } +interface Props { + onGoToFirstSlide: () => void +} - onClickLetsGo () { +export default class BraveScreen extends React.PureComponent { + onClickLetsGo = () => { this.props.onGoToFirstSlide() } render () { - const { theme } = this.props return (
@@ -38,5 +38,3 @@ class BraveScreen extends React.PureComponent { ) } } - -module.exports = BraveScreen diff --git a/components/brave_welcome_ui/components/featuresScreen.tsx b/components/brave_welcome_ui/components/featuresScreen.tsx index 8af61496f9d2..089cd458f7d5 100644 --- a/components/brave_welcome_ui/components/featuresScreen.tsx +++ b/components/brave_welcome_ui/components/featuresScreen.tsx @@ -2,16 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { getLocale } = require('../../common/locale') +import * as React from 'react' +import { getLocale } from '../../common/locale' +import Image from 'brave-ui/v1/image' +import { PushButtonLink } from 'brave-ui/v1/pushButton' +import { Heading, Paragraph } from 'brave-ui' +import { theme } from '../theme' + const featuresImage = require('../../img/welcome/features.png') -const Image = require('brave-ui/v1/image').default -const PushButtonLink = require('brave-ui/v1/pushButton').PushButtonLink -const { Heading, Paragraph } = require('brave-ui') -class FeaturesScreen extends React.PureComponent { +export default class FeaturesScreen extends React.PureComponent<{}, {}> { render () { - const { theme } = this.props return (
@@ -29,5 +30,3 @@ class FeaturesScreen extends React.PureComponent { ) } } - -module.exports = FeaturesScreen diff --git a/components/brave_welcome_ui/components/footer.tsx b/components/brave_welcome_ui/components/footer.tsx index 9e2078f101b0..88d8e16d39fb 100644 --- a/components/brave_welcome_ui/components/footer.tsx +++ b/components/brave_welcome_ui/components/footer.tsx @@ -2,17 +2,22 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { getLocale } = require('../../common/locale') -const PushButton = require('brave-ui/v1/pushButton').PushButton -const PushButtonLink = require('brave-ui/v1/pushButton').PushButtonLink -const ArrowRight = require('brave-ui/v1/icons/arrowRight').default -const { Grid, Column, Anchor } = require('brave-ui') +import * as React from 'react' +import { getLocale } from '../../common/locale' +import { PushButton, PushButtonLink } from 'brave-ui/v1/pushButton' +import ArrowRight from 'brave-ui/v1/icons/arrowRight' +import { Grid, Column, Anchor } from 'brave-ui' +import { theme } from '../theme' -class Footer extends React.PureComponent { +interface Props { + pageIndex: number, + totalSecondaryScreensSize: number, + onClickNext: (e: any) => void +} + +export default class Footer extends React.PureComponent { render () { const { - theme, pageIndex, totalSecondaryScreensSize, onClickNext, @@ -35,30 +40,32 @@ class Footer extends React.PureComponent { { pageIndex < totalSecondaryScreensSize - 1 - ? ( - - + - {getLocale('next')} - - - ) - : ( - - {getLocale('done')} - - ) + {getLocale('next')} + + + ) + : ( + + {getLocale('done')} + + ) } @@ -66,5 +73,3 @@ class Footer extends React.PureComponent { ) } } - -module.exports = Footer diff --git a/components/brave_welcome_ui/components/importScreen.tsx b/components/brave_welcome_ui/components/importScreen.tsx index 1a3aa9381af2..7bcac597566d 100644 --- a/components/brave_welcome_ui/components/importScreen.tsx +++ b/components/brave_welcome_ui/components/importScreen.tsx @@ -2,25 +2,25 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { getLocale } = require('../../common/locale') +import * as React from 'react' +import { getLocale } from '../../common/locale' +import Image from 'brave-ui/v1/image' +import { PushButton } from 'brave-ui/v1/pushButton' +import { Heading, Paragraph } from 'brave-ui' +import { theme } from '../theme' + const importImage = require('../../img/welcome/import.png') -const Image = require('brave-ui/v1/image').default -const PushButton = require('brave-ui/v1/pushButton').PushButton -const { Heading, Paragraph } = require('brave-ui') -class ImportScreen extends React.PureComponent { - constructor (props) { - super(props) - this.onClickImportNow = this.onClickImportNow.bind(this) - } +interface Props { + onImportNowClicked: () => void +} - onClickImportNow () { +export default class ImportScreen extends React.PureComponent { + onClickImportNow = () => { this.props.onImportNowClicked() } render () { - const { theme } = this.props return (
@@ -38,5 +38,3 @@ class ImportScreen extends React.PureComponent { ) } } - -module.exports = ImportScreen diff --git a/components/brave_welcome_ui/components/rewardsScreen.tsx b/components/brave_welcome_ui/components/rewardsScreen.tsx index b1933f553baa..a59574515e19 100644 --- a/components/brave_welcome_ui/components/rewardsScreen.tsx +++ b/components/brave_welcome_ui/components/rewardsScreen.tsx @@ -2,16 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { getLocale } = require('../../common/locale') +import * as React from 'react' +import { Heading, Paragraph } from 'brave-ui' +import Image from 'brave-ui/v1/image' +import { PushButtonLink } from 'brave-ui/v1/pushButton' + +// Utils +import { theme } from '../theme' +import { getLocale } from '../../common/locale' + const rewardsImage = require('../../img/welcome/rewards.png') -const Image = require('brave-ui/v1/image').default -const PushButtonLink = require('brave-ui/v1/pushButton').PushButtonLink -const { Heading, Paragraph } = require('brave-ui') -class RewardsScreen extends React.PureComponent { +export default class RewardsScreen extends React.PureComponent { render () { - const { theme } = this.props return (
@@ -29,5 +32,3 @@ class RewardsScreen extends React.PureComponent { ) } } - -module.exports = RewardsScreen diff --git a/components/brave_welcome_ui/components/shiedsScreen.tsx b/components/brave_welcome_ui/components/shiedsScreen.tsx index 5fe0e82b303d..661e5d33d225 100644 --- a/components/brave_welcome_ui/components/shiedsScreen.tsx +++ b/components/brave_welcome_ui/components/shiedsScreen.tsx @@ -2,15 +2,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { getLocale } = require('../../common/locale') +import * as React from 'react' +import Image from 'brave-ui/v1/image' +import { Heading, Paragraph } from 'brave-ui' + +// Utils +import { getLocale } from '../../common/locale' +import { theme } from '../theme' + +// Assets const shieldsImage = require('../../img/welcome/shields.png') -const Image = require('brave-ui/v1/image').default -const { Heading, Paragraph } = require('brave-ui') -class ShieldsScreen extends React.PureComponent { +export default class ShieldsScreen extends React.PureComponent { render () { - const { theme } = this.props return (
@@ -20,5 +24,3 @@ class ShieldsScreen extends React.PureComponent { ) } } - -module.exports = ShieldsScreen diff --git a/components/brave_welcome_ui/constants/welcome_types.ts b/components/brave_welcome_ui/constants/welcome_types.ts index 6f33d8c617b0..b80814049302 100644 --- a/components/brave_welcome_ui/constants/welcome_types.ts +++ b/components/brave_welcome_ui/constants/welcome_types.ts @@ -2,5 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -export const IMPORT_NOW_REQUESTED = 'IMPORT_NOW_REQUESTED' -export const GO_TO_PAGE_REQUESTED = 'GO_TO_PAGE_REQUESTED' +export const enum types { + IMPORT_NOW_REQUESTED = '@@welcome/IMPORT_NOW_REQUESTED', + GO_TO_PAGE_REQUESTED = '@@welcome/GO_TO_PAGE_REQUESTED' +} diff --git a/components/brave_welcome_ui/reducers/welcome_reducer.ts b/components/brave_welcome_ui/reducers/welcome_reducer.ts index 8fcbdedb7bb5..79c4dfce20b7 100644 --- a/components/brave_welcome_ui/reducers/welcome_reducer.ts +++ b/components/brave_welcome_ui/reducers/welcome_reducer.ts @@ -2,15 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* global chrome */ +import { types } from '../constants/welcome_types' +import * as storage from '../storage' -const types = require('../constants/welcome_types') -const storage = require('../storage') - -const welcomeReducer = (state, action) => { +const welcomeReducer = (state: Welcome.State, action: any) => { if (state === undefined) { - state = storage.load() || {} - state = Object.assign(storage.getInitialState(), state) + state = storage.load() } const startingState = state switch (action.type) { diff --git a/components/brave_welcome_ui/storage.ts b/components/brave_welcome_ui/storage.ts index 3e9781a6f705..60486f669063 100644 --- a/components/brave_welcome_ui/storage.ts +++ b/components/brave_welcome_ui/storage.ts @@ -6,16 +6,16 @@ const debounce = require('../common/debounce') const keyName = 'welcome-data' -const cleanData = (state) => { +const cleanData = (state: Welcome.State) => { state = { ...state } return state } -module.exports.getInitialState = () => cleanData({ pageIndex: 0 }) +export const getInitialState = () => cleanData({ pageIndex: 0 }) -module.exports.load = () => { +export const load = () => { const data = window.localStorage.getItem(keyName) - let state + let state = getInitialState() if (data) { try { state = JSON.parse(data) @@ -26,7 +26,7 @@ module.exports.load = () => { return cleanData(state) } -module.exports.debouncedSave = debounce((data) => { +export const debouncedSave = debounce((data: Welcome.State) => { if (data) { window.localStorage.setItem(keyName, JSON.stringify(cleanData(data))) } diff --git a/components/brave_welcome_ui/theme.ts b/components/brave_welcome_ui/theme.ts index 18e0a3078252..85a7ff075055 100644 --- a/components/brave_welcome_ui/theme.ts +++ b/components/brave_welcome_ui/theme.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const theme = { +export const theme = { panel: { backgroundColor: 'rgba(255,255,255,0.95)', maxWidth: '600px', @@ -91,5 +91,3 @@ const theme = { fontSize: '40px' } } - -module.exports = theme diff --git a/components/definitions/global.d.ts b/components/definitions/global.d.ts index 981609fea0c5..064844fff8e4 100644 --- a/components/definitions/global.d.ts +++ b/components/definitions/global.d.ts @@ -26,5 +26,8 @@ declare global { walletCreated: () => void walletCreateFailed: () => void } + brave_welcome: { + initialize: () => void + } } } diff --git a/components/definitions/welcome.d.ts b/components/definitions/welcome.d.ts new file mode 100644 index 000000000000..b8467c317ec2 --- /dev/null +++ b/components/definitions/welcome.d.ts @@ -0,0 +1,9 @@ +declare namespace Welcome { + export interface ApplicationState { + welcomeData: State + } + + export interface State { + pageIndex: number + } +} diff --git a/package-lock.json b/package-lock.json index dc43282eccd4..c52961dd8a59 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "brave-core", - "version": "0.50.8", + "version": "0.50.10", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -203,9 +203,9 @@ } }, "brave-ui": { - "version": "0.12.2", - "resolved": "https://registry.npmjs.org/brave-ui/-/brave-ui-0.12.2.tgz", - "integrity": "sha512-/XD9k+3s7Z8L5BUqjmzQf42YfOoNodms07L8oygp2Et+s3PTxQQaHTHf82MABJDle9OlFzgG4h2X64O7f0OqTg==", + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/brave-ui/-/brave-ui-0.12.3.tgz", + "integrity": "sha512-zjUlOW2bR7ce4Fl36MysV1ynmckNC8pecniXmG+LgP7iOfK71l5UK93sUk0Wk4xYTJuA370tk61jMVCQZrleCg==", "requires": { "emptykit.css": "^1.0.1", "styled-components": "^3.2.6" From b1192dc6ecad15696c7a0d0a48b9cab4e76c0ecf Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 16 Jul 2018 07:43:39 +0200 Subject: [PATCH 7/9] Build successful --- .../actions/adblock_actions.ts | 2 +- components/brave_adblock_ui/brave_adblock.tsx | 13 +++-- .../components/numBlockedStat.tsx | 4 +- .../components/regionalAdBlockEnabled.tsx | 3 +- .../reducers/adblock_reducer.ts | 4 +- components/brave_adblock_ui/storage.ts | 2 +- components/brave_adblock_ui/store.ts | 2 +- .../brave_new_tab_ui/actions/newTabActions.ts | 2 +- components/brave_new_tab_ui/api.ts | 8 ++-- components/brave_new_tab_ui/brave_new_tab.tsx | 13 +++-- .../brave_new_tab_ui/components/app.tsx | 4 +- .../brave_new_tab_ui/components/block.tsx | 4 +- .../components/newPrivateTab.tsx | 2 +- .../brave_new_tab_ui/components/stats.tsx | 2 +- .../reducers/newTabReducer.tsx | 48 +++++++------------ components/brave_new_tab_ui/storage.ts | 20 ++++---- components/brave_new_tab_ui/store.ts | 2 +- .../{components/theme.tsx => theme.ts} | 0 .../actions/rewards_actions.ts | 2 +- components/brave_rewards_ui/brave_rewards.tsx | 13 +++-- .../brave_rewards_ui/components/app.tsx | 15 ++++-- .../reducers/rewards_reducer.ts | 5 +- components/brave_rewards_ui/storage.ts | 4 +- components/brave_rewards_ui/store.ts | 3 +- .../actions/welcome_actions.ts | 3 +- components/brave_welcome_ui/brave_welcome.tsx | 8 ++-- .../brave_welcome_ui/components/app.tsx | 2 +- .../{shiedsScreen.tsx => shieldsScreen.tsx} | 0 .../reducers/welcome_reducer.ts | 3 +- components/brave_welcome_ui/storage.ts | 2 +- components/brave_welcome_ui/store.ts | 3 +- components/brave_welcome_ui/theme.ts | 2 +- components/common/debounce.ts | 4 +- components/common/locale.ts | 6 +-- components/definitions/global.d.ts | 8 ++-- components/resources/BUILD.gn | 41 ++-------------- components/webpack/prod.config.js | 2 +- package-lock.json | 4 +- package.json | 3 +- 39 files changed, 109 insertions(+), 159 deletions(-) rename components/brave_new_tab_ui/{components/theme.tsx => theme.ts} (100%) rename components/brave_welcome_ui/components/{shiedsScreen.tsx => shieldsScreen.tsx} (100%) diff --git a/components/brave_adblock_ui/actions/adblock_actions.ts b/components/brave_adblock_ui/actions/adblock_actions.ts index f5d62284784d..1e67c96cd8c1 100644 --- a/components/brave_adblock_ui/actions/adblock_actions.ts +++ b/components/brave_adblock_ui/actions/adblock_actions.ts @@ -3,6 +3,6 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' -const types = require('../constants/adblock_types') +import { types } from '../constants/adblock_types' export const statsUpdated = () => action(types.ADBLOCK_STATS_UPDATED) diff --git a/components/brave_adblock_ui/brave_adblock.tsx b/components/brave_adblock_ui/brave_adblock.tsx index 3e5d58f9647a..879ee034832b 100644 --- a/components/brave_adblock_ui/brave_adblock.tsx +++ b/components/brave_adblock_ui/brave_adblock.tsx @@ -3,16 +3,17 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { render } = require('react-dom') -const { Provider } = require('react-redux') -const App = require('./components/app') -const { bindActionCreators } = require('redux') +import { render } from 'react-dom' +import { Provider } from 'react-redux' +import App from './components/app' +import { bindActionCreators } from 'redux' +import store from './store' +import * as adblockActions from './actions/adblock_actions' window.cr.define('brave_adblock', function () { 'use strict' function initialize () { - const store = require('./store') render( @@ -22,8 +23,6 @@ window.cr.define('brave_adblock', function () { } function statsUpdated () { - const store = require('./store') - const adblockActions = require('./actions/adblock_actions') const actions = bindActionCreators(adblockActions, store.dispatch.bind(store)) actions.statsUpdated() } diff --git a/components/brave_adblock_ui/components/numBlockedStat.tsx b/components/brave_adblock_ui/components/numBlockedStat.tsx index 473cb8f4e4a4..e8d7b54250a3 100644 --- a/components/brave_adblock_ui/components/numBlockedStat.tsx +++ b/components/brave_adblock_ui/components/numBlockedStat.tsx @@ -10,8 +10,6 @@ interface Props { export const NumBlockedStat = (props: Props) => (
- -   - {props.adsBlockedStat || 0} + {props.adsBlockedStat || 0}
) diff --git a/components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx b/components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx index f1396b84de98..ffa8f45f0f14 100644 --- a/components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx +++ b/components/brave_adblock_ui/components/regionalAdBlockEnabled.tsx @@ -11,8 +11,7 @@ interface Props { export const RegionalAdBlockEnabled = (props: Props) => (
- -   +   { props.regionalAdBlockEnabled ? diff --git a/components/brave_adblock_ui/reducers/adblock_reducer.ts b/components/brave_adblock_ui/reducers/adblock_reducer.ts index aabf3c7878ad..eb93993248be 100644 --- a/components/brave_adblock_ui/reducers/adblock_reducer.ts +++ b/components/brave_adblock_ui/reducers/adblock_reducer.ts @@ -4,8 +4,8 @@ import { Reducer } from 'redux' -const { types } = require('../constants/adblock_types') -const storage = require('../storage') +import { types } from '../constants/adblock_types' +import * as storage from '../storage' const adblockReducer: Reducer = (state: AdBlock.State, action) => { if (state == null) { diff --git a/components/brave_adblock_ui/storage.ts b/components/brave_adblock_ui/storage.ts index eee23f61017e..d48ca0e49002 100644 --- a/components/brave_adblock_ui/storage.ts +++ b/components/brave_adblock_ui/storage.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const debounce = require('../common/debounce') +import { debounce } from '../common/debounce' const keyName = 'adblock-data' diff --git a/components/brave_adblock_ui/store.ts b/components/brave_adblock_ui/store.ts index 4a2f7f5bcfa8..f661b99b374f 100644 --- a/components/brave_adblock_ui/store.ts +++ b/components/brave_adblock_ui/store.ts @@ -5,4 +5,4 @@ import { createStore } from 'redux' import reducers from './reducers' -export const store = createStore(reducers) +export default createStore(reducers) diff --git a/components/brave_new_tab_ui/actions/newTabActions.ts b/components/brave_new_tab_ui/actions/newTabActions.ts index 9a6f091618a1..ee35ff9f89bf 100644 --- a/components/brave_new_tab_ui/actions/newTabActions.ts +++ b/components/brave_new_tab_ui/actions/newTabActions.ts @@ -3,7 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' -const types = require('../constants/newTabTypes') +import { types } from '../constants/newTabTypes' export const topSitesDataUpdated = (topSites: NewTab.Site[]) => action(types.NEW_TAB_TOP_SITES_DATA_UPDATED, { topSites diff --git a/components/brave_new_tab_ui/api.ts b/components/brave_new_tab_ui/api.ts index 214671d6f8d8..eddafed665cf 100644 --- a/components/brave_new_tab_ui/api.ts +++ b/components/brave_new_tab_ui/api.ts @@ -2,9 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const { bindActionCreators } = require('redux') -const newTabActions = require('./actions/newTabActions') -const debounce = require('../common/debounce') +import { bindActionCreators } from 'redux' +import * as newTabActions from './actions/newTabActions' +import { debounce } from '../common/debounce' +import store from './store' let actions: any @@ -12,7 +13,6 @@ const getActions = () => { if (actions) { return actions } - const store = require('./store') actions = bindActionCreators(newTabActions, store.dispatch.bind(store)) return actions } diff --git a/components/brave_new_tab_ui/brave_new_tab.tsx b/components/brave_new_tab_ui/brave_new_tab.tsx index a5cb644e1c46..c5e6e3b8880c 100644 --- a/components/brave_new_tab_ui/brave_new_tab.tsx +++ b/components/brave_new_tab_ui/brave_new_tab.tsx @@ -3,16 +3,17 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { render } = require('react-dom') -const { Provider } = require('react-redux') -const App = require('./components/app') -const { bindActionCreators } = require('redux') +import { render } from 'react-dom' +import { Provider } from 'react-redux' +import App from './components/app' +import { bindActionCreators } from 'redux' +import store from './store' +import * as newTabActions from './actions/newTabActions' window.cr.define('brave_new_tab', function () { 'use strict' function initialize () { - const store = require('./store') render( @@ -22,8 +23,6 @@ window.cr.define('brave_new_tab', function () { } function statsUpdated () { - const store = require('./store') - const newTabActions = require('./actions/newTabActions') const actions = bindActionCreators(newTabActions, store.dispatch.bind(store)) actions.statsUpdated() } diff --git a/components/brave_new_tab_ui/components/app.tsx b/components/brave_new_tab_ui/components/app.tsx index 5a1fb1894813..43283df237ad 100644 --- a/components/brave_new_tab_ui/components/app.tsx +++ b/components/brave_new_tab_ui/components/app.tsx @@ -6,7 +6,7 @@ import * as React from 'react' import { DragDropContext } from 'react-dnd' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' -import * as HTML5Backend from 'react-dnd-html5-backend' +import HTML5Backend from 'react-dnd-html5-backend' import * as newTabActions from '../actions/newTabActions' // Components @@ -18,7 +18,7 @@ import SiteRemovalNotification from './siteRemovalNotification' import NewPrivateTab from './newPrivateTab' // Assets -import { theme } from './theme' +import { theme } from '../theme' require('../../styles/newtab.less') require('font-awesome/css/font-awesome.css') require('../../fonts/poppins.css') diff --git a/components/brave_new_tab_ui/components/block.tsx b/components/brave_new_tab_ui/components/block.tsx index dbf39c5aba96..7062c959c173 100644 --- a/components/brave_new_tab_ui/components/block.tsx +++ b/components/brave_new_tab_ui/components/block.tsx @@ -94,7 +94,7 @@ interface Props { } // TODO remove so many props NZ -export default class Block extends React.Component { +class Block extends React.Component { render () { const { connectDragSource, @@ -173,4 +173,4 @@ const source = DragSource(Types.BLOCK, blockSource, sourceCollect)(Block) * * @see http://gaearon.github.io/react-dnd/docs-drop-target.html */ -export const block = DropTarget(Types.BLOCK, blockTarget, targetCollect)(source) +export default DropTarget(Types.BLOCK, blockTarget, targetCollect)(source) diff --git a/components/brave_new_tab_ui/components/newPrivateTab.tsx b/components/brave_new_tab_ui/components/newPrivateTab.tsx index 6c81c5d95669..7edbb40fd11e 100644 --- a/components/brave_new_tab_ui/components/newPrivateTab.tsx +++ b/components/brave_new_tab_ui/components/newPrivateTab.tsx @@ -21,7 +21,7 @@ import { import Stats from './stats' // Theme -import { theme } from './theme' +import { theme } from '../theme' require('emptykit.css') // Images diff --git a/components/brave_new_tab_ui/components/stats.tsx b/components/brave_new_tab_ui/components/stats.tsx index 88fda2ec54c5..cb0b19e32cb9 100644 --- a/components/brave_new_tab_ui/components/stats.tsx +++ b/components/brave_new_tab_ui/components/stats.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import { DataBlock, DataItem } from 'brave-ui/dataBlock' import { getLocale } from '../../common/locale' -import { theme } from './theme' +import { theme } from '../theme' interface Props { stats: NewTab.Stats diff --git a/components/brave_new_tab_ui/reducers/newTabReducer.tsx b/components/brave_new_tab_ui/reducers/newTabReducer.tsx index 0bf0c9997239..0f1bea7fc4da 100644 --- a/components/brave_new_tab_ui/reducers/newTabReducer.tsx +++ b/components/brave_new_tab_ui/reducers/newTabReducer.tsx @@ -6,16 +6,7 @@ import { Reducer } from 'redux' import { types } from '../constants/newTabTypes' import * as storage from '../storage' - -let getGridSitesCache: (state: NewTab.State, checkBookmarkInfo: boolean) => NewTab.Site[] - -const getGridSites = (state: NewTab.State, checkBookmarkInfo: boolean) => { - if (!getGridSitesCache) { - getGridSitesCache = require('../api').getGridSites - } - - return getGridSitesCache(state, checkBookmarkInfo) -} +import { fetchBookmarkInfo, getGridSites, fetchTopSites, calculateGridSites } from '../api' const updateBookmarkInfo = (state: NewTab.State, url: string, bookmarkTreeNode: any) => { const bookmarks = Object.assign({}, state.bookmarks) @@ -74,43 +65,40 @@ const onDragEnd = (state: NewTab.State) => { return state } -let calculateGridSites: any -const newTabReducer: Reducer = (state: NewTab.State, action) => { +const newTabReducer: Reducer = (state: NewTab.State, action: any) => { if (state === undefined) { - calculateGridSites = require('../api').calculateGridSites setImmediate(() => { - const { fetchTopSites } = require('../api') fetchTopSites() }) - state = storage.load() || {} - state = Object.assign(storage.getInitialState(), state) + state = storage.load() } const startingState = state + const payload = action.payload switch (action.type) { case types.BOOKMARK_ADDED: - const { fetchBookmarkInfo } = require('../api') const topSite: NewTab.Site | undefined = state.topSites.find((site) => site.url === action.url) if (topSite) { chrome.bookmarks.create({ title: topSite.title, url: topSite.url }, () => { - fetchBookmarkInfo(action.url) + fetchBookmarkInfo(payload.url) }) } break case types.BOOKMARK_REMOVED: - // TODO somewhere we are saying that bookmarks is Record of booleans, but here we are using id - const bookmarkInfo = state.bookmarks[action.url] + // TODO somewhere we are saying that bookmarks is Record of booleans, but here we are using id NZ + const bookmarkInfo = state.bookmarks[payload.url] if (bookmarkInfo) { - chrome.bookmarks.remove(bookmarkInfo.id, () => { - fetchBookmarkInfo(action.url) + // TODO this is static now NZ + chrome.bookmarks.remove('1', () => { + fetchBookmarkInfo(payload.url) }) } break case types.NEW_TAB_TOP_SITES_DATA_UPDATED: - state = { ...state, topSites: action.topSites } + state = { ...state, topSites: payload.topSites } calculateGridSites(state) break case types.NEW_TAB_BACKGROUND_IMAGE_LOAD_FAILED: { @@ -139,7 +127,7 @@ const newTabReducer: Reducer = (state: NewTab.State, action) => { } case types.NEW_TAB_SITE_PINNED: { - const topSiteIndex: number = state.topSites.findIndex((site) => site.url === action.url) + const topSiteIndex: number = state.topSites.findIndex((site) => site.url === payload.url) const pinnedTopSite: NewTab.Site = Object.assign({}, state.topSites[topSiteIndex], { pinned: true }) const pinnedTopSites: NewTab.Site[] = state.pinnedTopSites.slice() @@ -155,7 +143,7 @@ const newTabReducer: Reducer = (state: NewTab.State, action) => { } case types.NEW_TAB_SITE_UNPINNED: - const currentPositionIndex: number = state.pinnedTopSites.findIndex((site) => site.url === action.url) + const currentPositionIndex: number = state.pinnedTopSites.findIndex((site) => site.url === payload.url) if (currentPositionIndex !== -1) { const pinnedTopSites: NewTab.Site[] = state.pinnedTopSites.slice() pinnedTopSites.splice(currentPositionIndex, 1) @@ -168,7 +156,7 @@ const newTabReducer: Reducer = (state: NewTab.State, action) => { break case types.NEW_TAB_SITE_IGNORED: { - const topSiteIndex: number = state.topSites.findIndex((site) => site.url === action.url) + const topSiteIndex: number = state.topSites.findIndex((site) => site.url === payload.url) const ignoredTopSites: NewTab.Site[] = state.ignoredTopSites.slice() ignoredTopSites.splice(0, 1, state.topSites[topSiteIndex]) state = { @@ -209,7 +197,7 @@ const newTabReducer: Reducer = (state: NewTab.State, action) => { break case types.NEW_TAB_SITE_DRAGGED: - state = onDraggedSite(state, action.fromUrl, action.toUrl) + state = onDraggedSite(state, payload.fromUrl, payload.toUrl) break case types.NEW_TAB_SITE_DRAG_END: @@ -217,11 +205,11 @@ const newTabReducer: Reducer = (state: NewTab.State, action) => { break case types.NEW_TAB_BOOKMARK_INFO_AVAILABLE: - state = updateBookmarkInfo(state, action.queryUrl, action.bookmarkTreeNode) + state = updateBookmarkInfo(state, payload.queryUrl, payload.bookmarkTreeNode) break case types.NEW_TAB_GRID_SITES_UPDATED: - state = { ...state, gridSites: action.gridSites } + state = { ...state, gridSites: payload.gridSites } break case types.NEW_TAB_STATS_UPDATED: @@ -229,7 +217,7 @@ const newTabReducer: Reducer = (state: NewTab.State, action) => { break case types.NEW_TAB_USE_ALTERNATIVE_PRIVATE_SEARCH_ENGINE: - state = { ...state, useAlternativePrivateSearchEngine: action.shouldUse } + state = { ...state, useAlternativePrivateSearchEngine: payload.shouldUse } break default: diff --git a/components/brave_new_tab_ui/storage.ts b/components/brave_new_tab_ui/storage.ts index 0d596b8fea44..c8c6f76c972f 100644 --- a/components/brave_new_tab_ui/storage.ts +++ b/components/brave_new_tab_ui/storage.ts @@ -3,7 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { debounce } from '../common/debounce' -const backgrounds = require('./backgrounds') +import { images as backgrounds } from './backgrounds' const keyName = 'new-tab-data' @@ -36,14 +36,6 @@ const randomBackgroundImage = (): NewTab.Image => { return image } -const cleanData = (state: NewTab.State): NewTab.State => { - state = { ...state } - state.backgroundImage = randomBackgroundImage() - delete state.imageLoadFailed - state = module.exports.getLoadTimeData(state) - return state -} - export const getLoadTimeData = (state: NewTab.State) => { state = { ...state } state.stats = defaultState.stats @@ -54,11 +46,19 @@ export const getLoadTimeData = (state: NewTab.State) => { return state } +const cleanData = (state: NewTab.State): NewTab.State => { + state = { ...state } + state.backgroundImage = randomBackgroundImage() + delete state.imageLoadFailed + state = getLoadTimeData(state) + return state +} + export const getInitialState = () => cleanData(defaultState) export const load = () => { const data = window.localStorage.getItem(keyName) - let state + let state = getInitialState() if (data) { try { state = JSON.parse(data) diff --git a/components/brave_new_tab_ui/store.ts b/components/brave_new_tab_ui/store.ts index 4a2f7f5bcfa8..f661b99b374f 100644 --- a/components/brave_new_tab_ui/store.ts +++ b/components/brave_new_tab_ui/store.ts @@ -5,4 +5,4 @@ import { createStore } from 'redux' import reducers from './reducers' -export const store = createStore(reducers) +export default createStore(reducers) diff --git a/components/brave_new_tab_ui/components/theme.tsx b/components/brave_new_tab_ui/theme.ts similarity index 100% rename from components/brave_new_tab_ui/components/theme.tsx rename to components/brave_new_tab_ui/theme.ts diff --git a/components/brave_rewards_ui/actions/rewards_actions.ts b/components/brave_rewards_ui/actions/rewards_actions.ts index 52ac47753ba3..59215de1a1d7 100644 --- a/components/brave_rewards_ui/actions/rewards_actions.ts +++ b/components/brave_rewards_ui/actions/rewards_actions.ts @@ -3,7 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' -const types = require('../constants/rewards_types') +import { types } from '../constants/rewards_types' export const createWalletRequested = () => action(types.CREATE_WALLET_REQUESTED) diff --git a/components/brave_rewards_ui/brave_rewards.tsx b/components/brave_rewards_ui/brave_rewards.tsx index cf39e2800fae..ffd45542f846 100644 --- a/components/brave_rewards_ui/brave_rewards.tsx +++ b/components/brave_rewards_ui/brave_rewards.tsx @@ -3,16 +3,17 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { render } = require('react-dom') -const { Provider } = require('react-redux') -const App = require('./components/app') -const { bindActionCreators } = require('redux') +import { render } from 'react-dom' +import { Provider } from 'react-redux' +import App from './components/app' +import { bindActionCreators } from 'redux' +import store from './store' +import * as rewardsActions from './actions/rewards_actions' window.cr.define('brave_rewards', function () { 'use strict' function initialize () { - const store = require('./store') render( @@ -22,8 +23,6 @@ window.cr.define('brave_rewards', function () { } function getActions () { - const store = require('./store') - const rewardsActions = require('./actions/rewards_actions') return bindActionCreators(rewardsActions, store.dispatch.bind(store)) } diff --git a/components/brave_rewards_ui/components/app.tsx b/components/brave_rewards_ui/components/app.tsx index 62482f9a7860..aa9939ad930d 100644 --- a/components/brave_rewards_ui/components/app.tsx +++ b/components/brave_rewards_ui/components/app.tsx @@ -2,12 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const React = require('react') -const { bindActionCreators } = require('redux') -const { connect } = require('react-redux') -const rewardsActions = require('../actions/rewards_actions') +import * as React from 'react' +import { bindActionCreators } from 'redux' +import { connect } from 'react-redux' +import * as rewardsActions from '../actions/rewards_actions' -class RewardsPage extends React.Component { +interface Props { + actions: any + rewardsData: Rewards.State +} + +class RewardsPage extends React.Component { onCreateWalletClicked = () => { this.actions.createWalletRequested() } diff --git a/components/brave_rewards_ui/reducers/rewards_reducer.ts b/components/brave_rewards_ui/reducers/rewards_reducer.ts index 1313782355aa..d1c01b84dbb1 100644 --- a/components/brave_rewards_ui/reducers/rewards_reducer.ts +++ b/components/brave_rewards_ui/reducers/rewards_reducer.ts @@ -3,9 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Reducer } from 'redux' - -const types = require('../constants/rewards_types') -const storage = require('../storage') +import { types } from '../constants/rewards_types' +import * as storage from '../storage' const rewardsReducer: Reducer = (state: Rewards.State, action) => { if (state === undefined) { diff --git a/components/brave_rewards_ui/storage.ts b/components/brave_rewards_ui/storage.ts index 9c8f8b05f7f8..3705c505bff1 100644 --- a/components/brave_rewards_ui/storage.ts +++ b/components/brave_rewards_ui/storage.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const debounce = require('../common/debounce') +import { debounce } from '../common/debounce' const keyName = 'rewards-data' @@ -11,6 +11,8 @@ const defaultState: Rewards.State = { walletCreateFailed: false } +const cleanData = (state: Rewards.State) => state + export const getInitialState = (): Rewards.State => cleanData(defaultState) export const load = () => { diff --git a/components/brave_rewards_ui/store.ts b/components/brave_rewards_ui/store.ts index 426939fda2d6..f661b99b374f 100644 --- a/components/brave_rewards_ui/store.ts +++ b/components/brave_rewards_ui/store.ts @@ -5,5 +5,4 @@ import { createStore } from 'redux' import reducers from './reducers' -const store = createStore(reducers) -module.exports = store +export default createStore(reducers) diff --git a/components/brave_welcome_ui/actions/welcome_actions.ts b/components/brave_welcome_ui/actions/welcome_actions.ts index 55dd49e5d205..c65515f41008 100644 --- a/components/brave_welcome_ui/actions/welcome_actions.ts +++ b/components/brave_welcome_ui/actions/welcome_actions.ts @@ -3,8 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' - -const types = require('../constants/welcome_types') +import { types } from '../constants/welcome_types' export const importNowRequested = () => action(types.IMPORT_NOW_REQUESTED) diff --git a/components/brave_welcome_ui/brave_welcome.tsx b/components/brave_welcome_ui/brave_welcome.tsx index b0373f4371df..ec2614d5deff 100644 --- a/components/brave_welcome_ui/brave_welcome.tsx +++ b/components/brave_welcome_ui/brave_welcome.tsx @@ -3,15 +3,15 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -const { render } = require('react-dom') -const { Provider } = require('react-redux') -const App = require('./components/app') +import { render } from 'react-dom' +import { Provider } from 'react-redux' +import App from './components/app' +import store from './store' window.cr.define('brave_welcome', function () { 'use strict' function initialize () { - const store = require('./store') render( diff --git a/components/brave_welcome_ui/components/app.tsx b/components/brave_welcome_ui/components/app.tsx index 2611b5274b52..5dee30aa5d7b 100644 --- a/components/brave_welcome_ui/components/app.tsx +++ b/components/brave_welcome_ui/components/app.tsx @@ -12,7 +12,7 @@ import Panel from 'brave-ui/v1/panel' import BraveScreen from './braveScreen' import RewardsScreen from './rewardsScreen' import ImportScreen from './importScreen' -import ShieldsScreen from './shiedsScreen' +import ShieldsScreen from './shieldsScreen' import FeaturesScreen from './featuresScreen' import Footer from './footer' diff --git a/components/brave_welcome_ui/components/shiedsScreen.tsx b/components/brave_welcome_ui/components/shieldsScreen.tsx similarity index 100% rename from components/brave_welcome_ui/components/shiedsScreen.tsx rename to components/brave_welcome_ui/components/shieldsScreen.tsx diff --git a/components/brave_welcome_ui/reducers/welcome_reducer.ts b/components/brave_welcome_ui/reducers/welcome_reducer.ts index 79c4dfce20b7..ff6e9b7a9cb7 100644 --- a/components/brave_welcome_ui/reducers/welcome_reducer.ts +++ b/components/brave_welcome_ui/reducers/welcome_reducer.ts @@ -9,6 +9,7 @@ const welcomeReducer = (state: Welcome.State, action: any) => { if (state === undefined) { state = storage.load() } + const payload = action.payload const startingState = state switch (action.type) { case types.IMPORT_NOW_REQUESTED: @@ -16,7 +17,7 @@ const welcomeReducer = (state: Welcome.State, action: any) => { break case types.GO_TO_PAGE_REQUESTED: state = { ...state } - state.pageIndex = action.pageIndex + state.pageIndex = payload.pageIndex break } diff --git a/components/brave_welcome_ui/storage.ts b/components/brave_welcome_ui/storage.ts index 60486f669063..33c930fb4fde 100644 --- a/components/brave_welcome_ui/storage.ts +++ b/components/brave_welcome_ui/storage.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -const debounce = require('../common/debounce') +import { debounce } from '../common/debounce' const keyName = 'welcome-data' diff --git a/components/brave_welcome_ui/store.ts b/components/brave_welcome_ui/store.ts index 426939fda2d6..f661b99b374f 100644 --- a/components/brave_welcome_ui/store.ts +++ b/components/brave_welcome_ui/store.ts @@ -5,5 +5,4 @@ import { createStore } from 'redux' import reducers from './reducers' -const store = createStore(reducers) -module.exports = store +export default createStore(reducers) diff --git a/components/brave_welcome_ui/theme.ts b/components/brave_welcome_ui/theme.ts index 85a7ff075055..5738cf5f8fc9 100644 --- a/components/brave_welcome_ui/theme.ts +++ b/components/brave_welcome_ui/theme.ts @@ -52,7 +52,7 @@ export const theme = { }, content: { display: 'flex', - flexDirection: 'column', + // flexDirection: 'column', TODO figure it out why it's failing https://github.com/Microsoft/TypeScript/issues/9489 justifyContent: 'center', alignItems: 'center', flex: '1', diff --git a/components/common/debounce.ts b/components/common/debounce.ts index 1d38f02f399e..210173fc5cd6 100644 --- a/components/common/debounce.ts +++ b/components/common/debounce.ts @@ -4,9 +4,9 @@ 'use strict' -export const debounce = function(fn: (data: T) => void, bufferInterval: number, ...args: Array) { +export const debounce = function(fn: (data: T) => void, bufferInterval: number, ...args: Array) { let timeout: any - return (...args2: Array) => { + return (...args2: any[]) => { clearTimeout(timeout) let a: Array = args || [] if (args2 && args2.constructor === Array) { diff --git a/components/common/locale.ts b/components/common/locale.ts index 017ab8e716de..5b9768d14b45 100644 --- a/components/common/locale.ts +++ b/components/common/locale.ts @@ -2,13 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -'use strict' -// TODO optimize NZ -declare let window: any - /** * Gets the localized string * @param {string} text - the locale string to translate * @returns {string} - the localized string */ -export const getLocale = (text) => window.loadTimeData && window.loadTimeData.getString(text) +export const getLocale = (text: string) => window.loadTimeData && window.loadTimeData.getString(text) diff --git a/components/definitions/global.d.ts b/components/definitions/global.d.ts index 064844fff8e4..bb568a97b67c 100644 --- a/components/definitions/global.d.ts +++ b/components/definitions/global.d.ts @@ -3,16 +3,18 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ export {} -type Translations = Record[] +type loadTimeData = { + getString: (key: string) => string +} declare global { interface Window { - loadTimeData: Translations + loadTimeData: loadTimeData cr: { define: (name: string, init: () => void) => void } i18nTemplate: { - process: (document: Document, translations: Translations) => void + process: (document: Document, translations: loadTimeData) => void } brave_adblock: { initialize: () => void diff --git a/components/resources/BUILD.gn b/components/resources/BUILD.gn index b32ce174caad..28cc1fd2659a 100644 --- a/components/resources/BUILD.gn +++ b/components/resources/BUILD.gn @@ -1,45 +1,14 @@ import("//tools/grit/grit_rule.gni") - transpile_includes = [ - # Brave new tab + # Brave Adblock Page + "../brave_adblock_ui/brave_adblock.html", + # Brave New Tab "../brave_new_tab_ui/brave_new_tab.html", - "../brave_new_tab_ui/brave_new_tab.js", - "../brave_new_tab_ui/components/app.js", - "../brave_new_tab_ui/components/block.js", - "../brave_new_tab_ui/components/newPrivateTab.js", - "../brave_new_tab_ui/components/footerInfo.js", - "../brave_new_tab_ui/components/siteRemovalNotification.js", - "../brave_new_tab_ui/components/stats.js", - "../brave_new_tab_ui/constants/newTabTypes.js", - "../brave_new_tab_ui/actions/newTabActions.js", - "../brave_new_tab_ui/api.js", - "../brave_new_tab_ui/backgrounds.js", - "../brave_new_tab_ui/storage.js", - "../brave_new_tab_ui/store.js", - "../brave_new_tab_ui/reducers/index.js", - "../brave_new_tab_ui/reducers/newTabReducer.js", # Brave Rewards "../brave_rewards_ui/brave_rewards.html", - "../brave_rewards_ui/components/app.js", - "../brave_rewards_ui/constants/rewards_types.js", - "../brave_rewards_ui/actions/rewards_actions.js", - "../brave_rewards_ui/storage.js", - "../brave_rewards_ui/store.js", - "../brave_rewards_ui/reducers/index.js", - "../brave_rewards_ui/reducers/rewards_reducer.js", - # Brave welcome page - "../brave_welcome_ui/brave_welcome.html", - # Brave adblock page - "../brave_adblock_ui/brave_adblock.html", - "../brave_adblock_ui/brave_adblock.js", - "../brave_adblock_ui/components/app.js", - "../brave_adblock_ui/constants/adblock_types.js", - "../brave_adblock_ui/actions/adblock_actions.js", - "../brave_adblock_ui/storage.js", - "../brave_adblock_ui/store.js", - "../brave_adblock_ui/reducers/index.js", - "../brave_adblock_ui/reducers/adblock_reducer.js", + # Brave Welcome Page + "../brave_welcome_ui/brave_welcome.html" ] action("transpile_web_uis") { diff --git a/components/webpack/prod.config.js b/components/webpack/prod.config.js index 5107b115af09..89fab3be8619 100644 --- a/components/webpack/prod.config.js +++ b/components/webpack/prod.config.js @@ -37,7 +37,7 @@ module.exports = { rules: [ { test: /\.tsx?$/, - loader: 'awesome-typescript-loader' + loader: 'ts-loader' }, { test: /\.js$/, diff --git a/package-lock.json b/package-lock.json index c52961dd8a59..df9d1133af9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -124,8 +124,7 @@ "autobind-decorator": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/autobind-decorator/-/autobind-decorator-2.1.0.tgz", - "integrity": "sha512-bgyxeRi1R2Q8kWpHsb1c+lXCulbIAHsyZRddaS+agAUX3hFUVZMociwvRgeZi1zWvfqEEjybSv4zxWvFV8ydQQ==", - "dev": true + "integrity": "sha512-bgyxeRi1R2Q8kWpHsb1c+lXCulbIAHsyZRddaS+agAUX3hFUVZMociwvRgeZi1zWvfqEEjybSv4zxWvFV8ydQQ==" }, "babel-code-frame": { "version": "6.26.0", @@ -627,7 +626,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-dnd-html5-backend/-/react-dnd-html5-backend-5.0.1.tgz", "integrity": "sha1-C1eNecXAExfHBBTI1xf2MrkZ1PE=", - "dev": true, "requires": { "autobind-decorator": "^2.1.0", "dnd-core": "^4.0.5", diff --git a/package.json b/package.json index c8feb7b3d512..4734666efbd2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "lint": "tslint --project tsconfig.json 'components/**/*.{ts,tsx}'", - "lint-fix": "tslint --project tsconfig.json 'components/**/*.{ts,tsx}' --fix", "test-security": "npm audit" }, "repository": { @@ -42,7 +41,6 @@ "@types/react-dom": "^16.0.3", "@types/react-redux": "^6.0.4", "@types/redux-logger": "^3.0.5", - "react-dnd-html5-backend": "^5.0.1", "tslint": "^5.8.0", "tslint-config-standard": "^7.0.0", "tslint-react": "^3.2.0", @@ -52,6 +50,7 @@ "brave-ui": "^0.12.2", "emptykit.css": "^1.0.1", "react-dnd": "^5.0.0", + "react-dnd-html5-backend": "^5.0.1", "typesafe-actions": "^2.0.4" } } From 3e34093a0416469d4c5a5d3e69f04abec5d375d1 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 16 Jul 2018 12:39:38 +0200 Subject: [PATCH 8/9] Implements undefined for State --- .../reducers/adblock_reducer.ts | 4 +-- components/brave_adblock_ui/reducers/index.ts | 4 +-- components/brave_adblock_ui/storage.ts | 4 +-- components/brave_new_tab_ui/api.ts | 6 ++--- .../brave_new_tab_ui/components/app.tsx | 2 +- components/brave_new_tab_ui/reducers/index.ts | 4 +-- .../reducers/newTabReducer.tsx | 25 +++++++++---------- components/brave_new_tab_ui/storage.ts | 6 ++--- components/brave_rewards_ui/reducers/index.ts | 4 +-- .../reducers/rewards_reducer.ts | 2 +- components/brave_rewards_ui/storage.ts | 6 ++--- components/brave_welcome_ui/reducers/index.ts | 4 +-- .../reducers/welcome_reducer.ts | 4 ++- components/brave_welcome_ui/storage.ts | 10 +++++--- components/definitions/adBlock.d.ts | 2 +- components/definitions/newTab.d.ts | 15 ++++++++--- components/definitions/rewards.d.ts | 2 +- components/definitions/welcome.d.ts | 2 +- 18 files changed, 52 insertions(+), 54 deletions(-) diff --git a/components/brave_adblock_ui/reducers/adblock_reducer.ts b/components/brave_adblock_ui/reducers/adblock_reducer.ts index eb93993248be..6b84e63f78c8 100644 --- a/components/brave_adblock_ui/reducers/adblock_reducer.ts +++ b/components/brave_adblock_ui/reducers/adblock_reducer.ts @@ -7,8 +7,8 @@ import { Reducer } from 'redux' import { types } from '../constants/adblock_types' import * as storage from '../storage' -const adblockReducer: Reducer = (state: AdBlock.State, action) => { - if (state == null) { +const adblockReducer: Reducer = (state: AdBlock.State | undefined, action) => { + if (state === undefined) { state = storage.load() } diff --git a/components/brave_adblock_ui/reducers/index.ts b/components/brave_adblock_ui/reducers/index.ts index 3290ce15a89d..2d0d9d45b3f1 100644 --- a/components/brave_adblock_ui/reducers/index.ts +++ b/components/brave_adblock_ui/reducers/index.ts @@ -5,8 +5,6 @@ import { combineReducers } from 'redux' import adblockReducer from './adblock_reducer' -const combinedReducer = combineReducers({ +export default combineReducers({ adblockData: adblockReducer }) - -export default combinedReducer diff --git a/components/brave_adblock_ui/storage.ts b/components/brave_adblock_ui/storage.ts index d48ca0e49002..66d0fa1b8684 100644 --- a/components/brave_adblock_ui/storage.ts +++ b/components/brave_adblock_ui/storage.ts @@ -33,11 +33,9 @@ export const cleanData = (state: AdBlock.State): AdBlock.State => { return getLoadTimeData(state) } -export const getInitialState = (): AdBlock.State => cleanData(defaultState) - export const load = (): AdBlock.State => { const data = window.localStorage.getItem(keyName) - let state: AdBlock.State = getInitialState() + let state: AdBlock.State = defaultState if (data) { try { state = JSON.parse(data) diff --git a/components/brave_new_tab_ui/api.ts b/components/brave_new_tab_ui/api.ts index eddafed665cf..4a52ee59dc51 100644 --- a/components/brave_new_tab_ui/api.ts +++ b/components/brave_new_tab_ui/api.ts @@ -47,7 +47,7 @@ export const fetchBookmarkInfo = (url: string) => { ) } -export const getGridSites = (state: NewTab.State, checkBookmarkInfo: boolean) => { +export const getGridSites = (state: NewTab.State, checkBookmarkInfo?: boolean) => { const sizeToCount = { large: 18, medium: 12, small: 6 } const count = sizeToCount[state.gridLayoutSize || 'small'] @@ -68,13 +68,13 @@ export const getGridSites = (state: NewTab.State, checkBookmarkInfo: boolean) => }) gridSites = gridSites.slice(0, count) - gridSites.forEach((gridSite) => { + gridSites.forEach((gridSite: NewTab.Site) => { gridSite.letter = getLetterFromSite(gridSite) gridSite.thumb = `chrome://thumb/${gridSite.url}` gridSite.favicon = `chrome://favicon/size/48@1x/${gridSite.url}` gridSite.bookmarked = state.bookmarks[gridSite.url] - if (checkBookmarkInfo && gridSite.bookmarked === undefined) { + if (checkBookmarkInfo && !gridSite.bookmarked) { fetchBookmarkInfo(gridSite.url) } }) diff --git a/components/brave_new_tab_ui/components/app.tsx b/components/brave_new_tab_ui/components/app.tsx index 43283df237ad..1d8b68321b88 100644 --- a/components/brave_new_tab_ui/components/app.tsx +++ b/components/brave_new_tab_ui/components/app.tsx @@ -169,7 +169,7 @@ class NewTabPage extends React.Component { onDraggedSite={this.onDraggedSite} onDragEnd={this.onDragEnd} isPinned={site.pinned} - isBookmarked={site.bookmarked} + isBookmarked={site.bookmarked !== undefined} /> ) } diff --git a/components/brave_new_tab_ui/reducers/index.ts b/components/brave_new_tab_ui/reducers/index.ts index c9ebb1f1ef81..c4ada0ec7bda 100644 --- a/components/brave_new_tab_ui/reducers/index.ts +++ b/components/brave_new_tab_ui/reducers/index.ts @@ -5,8 +5,6 @@ import { combineReducers } from 'redux' import newTabReducer from './newTabReducer' -const combinedReducer = combineReducers({ +export default combineReducers({ newTabData: newTabReducer }) - -export default combinedReducer diff --git a/components/brave_new_tab_ui/reducers/newTabReducer.tsx b/components/brave_new_tab_ui/reducers/newTabReducer.tsx index 0f1bea7fc4da..a3c9d6f466f1 100644 --- a/components/brave_new_tab_ui/reducers/newTabReducer.tsx +++ b/components/brave_new_tab_ui/reducers/newTabReducer.tsx @@ -3,13 +3,12 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Reducer } from 'redux' - import { types } from '../constants/newTabTypes' import * as storage from '../storage' -import { fetchBookmarkInfo, getGridSites, fetchTopSites, calculateGridSites } from '../api' +import { fetchBookmarkInfo, getGridSites, calculateGridSites, fetchTopSites } from '../api' -const updateBookmarkInfo = (state: NewTab.State, url: string, bookmarkTreeNode: any) => { - const bookmarks = Object.assign({}, state.bookmarks) +const updateBookmarkInfo = (state: NewTab.State, url: string, bookmarkTreeNode?: NewTab.Bookmark) => { + const bookmarks = state.bookmarks const gridSites = state.gridSites.slice() const topSites = state.topSites.slice() const pinnedTopSites = state.pinnedTopSites.slice() @@ -17,9 +16,10 @@ const updateBookmarkInfo = (state: NewTab.State, url: string, bookmarkTreeNode: const gridSite: Partial = gridSites.find((s) => s.url === url) || {} const topSite: Partial = topSites.find((s) => s.url === url) || {} const pinnedTopSite: Partial = pinnedTopSites.find((s) => s.url === url) || {} - gridSite.bookmarked = topSite.bookmarked = pinnedTopSite.bookmarked = !!bookmarkTreeNode + if (bookmarkTreeNode) { bookmarks[url] = bookmarkTreeNode + gridSite.bookmarked = topSite.bookmarked = pinnedTopSite.bookmarked = bookmarkTreeNode } else { delete bookmarks[url] } @@ -29,7 +29,7 @@ const updateBookmarkInfo = (state: NewTab.State, url: string, bookmarkTreeNode: } const onDraggedSite = (state: NewTab.State, url: string, destUrl: string) => { - const gridSitesWithoutPreview = getGridSites(state, false) + const gridSitesWithoutPreview = getGridSites(state) const currentPositionIndex = gridSitesWithoutPreview.findIndex(site => site.url === url) const finalPositionIndex = gridSitesWithoutPreview.findIndex(site => site.url === destUrl) let pinnedTopSites = state.pinnedTopSites.slice() @@ -56,21 +56,22 @@ const onDraggedSite = (state: NewTab.State, url: string, destUrl: string) => { return pinnedTopSite }) state = { ...state, pinnedTopSites } - state = { ...state, gridSites: getGridSites(state, false) } + state = { ...state, gridSites: getGridSites(state) } return state } const onDragEnd = (state: NewTab.State) => { - state = { ...state, gridSites: getGridSites(state, false) } + state = { ...state, gridSites: getGridSites(state) } return state } -const newTabReducer: Reducer = (state: NewTab.State, action: any) => { +export const newTabReducer: Reducer = (state: NewTab.State | undefined, action: any) => { if (state === undefined) { + state = storage.load() + setImmediate(() => { fetchTopSites() }) - state = storage.load() } const startingState = state @@ -88,11 +89,9 @@ const newTabReducer: Reducer = (state: NewTab.State, action: any) } break case types.BOOKMARK_REMOVED: - // TODO somewhere we are saying that bookmarks is Record of booleans, but here we are using id NZ const bookmarkInfo = state.bookmarks[payload.url] if (bookmarkInfo) { - // TODO this is static now NZ - chrome.bookmarks.remove('1', () => { + chrome.bookmarks.remove(bookmarkInfo.id, () => { fetchBookmarkInfo(payload.url) }) } diff --git a/components/brave_new_tab_ui/storage.ts b/components/brave_new_tab_ui/storage.ts index c8c6f76c972f..9a58878f65df 100644 --- a/components/brave_new_tab_ui/storage.ts +++ b/components/brave_new_tab_ui/storage.ts @@ -54,11 +54,9 @@ const cleanData = (state: NewTab.State): NewTab.State => { return state } -export const getInitialState = () => cleanData(defaultState) - -export const load = () => { +export const load = (): NewTab.State => { const data = window.localStorage.getItem(keyName) - let state = getInitialState() + let state = defaultState if (data) { try { state = JSON.parse(data) diff --git a/components/brave_rewards_ui/reducers/index.ts b/components/brave_rewards_ui/reducers/index.ts index 2305e7e49e1e..792ce9c9d0f5 100644 --- a/components/brave_rewards_ui/reducers/index.ts +++ b/components/brave_rewards_ui/reducers/index.ts @@ -5,8 +5,6 @@ import { combineReducers } from 'redux' import rewardsReducer from './rewards_reducer' -const combinedReducer = combineReducers({ +export default combineReducers({ rewardsData: rewardsReducer }) - -export default combinedReducer diff --git a/components/brave_rewards_ui/reducers/rewards_reducer.ts b/components/brave_rewards_ui/reducers/rewards_reducer.ts index d1c01b84dbb1..9207e003bf7a 100644 --- a/components/brave_rewards_ui/reducers/rewards_reducer.ts +++ b/components/brave_rewards_ui/reducers/rewards_reducer.ts @@ -6,7 +6,7 @@ import { Reducer } from 'redux' import { types } from '../constants/rewards_types' import * as storage from '../storage' -const rewardsReducer: Reducer = (state: Rewards.State, action) => { +const rewardsReducer: Reducer = (state: Rewards.State | undefined, action) => { if (state === undefined) { state = storage.load() } diff --git a/components/brave_rewards_ui/storage.ts b/components/brave_rewards_ui/storage.ts index 3705c505bff1..5b8c02d6fdb2 100644 --- a/components/brave_rewards_ui/storage.ts +++ b/components/brave_rewards_ui/storage.ts @@ -13,11 +13,9 @@ const defaultState: Rewards.State = { const cleanData = (state: Rewards.State) => state -export const getInitialState = (): Rewards.State => cleanData(defaultState) - -export const load = () => { +export const load = (): Rewards.State => { const data = window.localStorage.getItem(keyName) - let state: Rewards.State = getInitialState() + let state: Rewards.State = defaultState if (data) { try { state = JSON.parse(data) diff --git a/components/brave_welcome_ui/reducers/index.ts b/components/brave_welcome_ui/reducers/index.ts index 3f8ee06ce6fa..20b894217e3e 100644 --- a/components/brave_welcome_ui/reducers/index.ts +++ b/components/brave_welcome_ui/reducers/index.ts @@ -5,8 +5,6 @@ import { combineReducers } from 'redux' import welcomeReducer from './welcome_reducer' -const combinedReducer = combineReducers({ +export default combineReducers({ welcomeData: welcomeReducer }) - -export default combinedReducer diff --git a/components/brave_welcome_ui/reducers/welcome_reducer.ts b/components/brave_welcome_ui/reducers/welcome_reducer.ts index ff6e9b7a9cb7..bfb265853f4c 100644 --- a/components/brave_welcome_ui/reducers/welcome_reducer.ts +++ b/components/brave_welcome_ui/reducers/welcome_reducer.ts @@ -2,13 +2,15 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +import { Reducer } from 'redux' import { types } from '../constants/welcome_types' import * as storage from '../storage' -const welcomeReducer = (state: Welcome.State, action: any) => { +const welcomeReducer: Reducer = (state: Welcome.State | undefined, action: any) => { if (state === undefined) { state = storage.load() } + const payload = action.payload const startingState = state switch (action.type) { diff --git a/components/brave_welcome_ui/storage.ts b/components/brave_welcome_ui/storage.ts index 33c930fb4fde..c89f3bb9604d 100644 --- a/components/brave_welcome_ui/storage.ts +++ b/components/brave_welcome_ui/storage.ts @@ -6,16 +6,18 @@ import { debounce } from '../common/debounce' const keyName = 'welcome-data' +const defaultState = { + pageIndex: 0 +} + const cleanData = (state: Welcome.State) => { state = { ...state } return state } -export const getInitialState = () => cleanData({ pageIndex: 0 }) - -export const load = () => { +export const load = (): Welcome.State => { const data = window.localStorage.getItem(keyName) - let state = getInitialState() + let state = defaultState if (data) { try { state = JSON.parse(data) diff --git a/components/definitions/adBlock.d.ts b/components/definitions/adBlock.d.ts index 86af657766bc..5eed1099da7b 100644 --- a/components/definitions/adBlock.d.ts +++ b/components/definitions/adBlock.d.ts @@ -1,6 +1,6 @@ declare namespace AdBlock { export interface ApplicationState { - adblockData: State + adblockData: State | undefined } export interface State { diff --git a/components/definitions/newTab.d.ts b/components/definitions/newTab.d.ts index 7c408365f639..9830e42d421d 100644 --- a/components/definitions/newTab.d.ts +++ b/components/definitions/newTab.d.ts @@ -1,6 +1,6 @@ declare namespace NewTab { export interface ApplicationState { - newTabData: State + newTabData: State | undefined } export interface Image { @@ -23,7 +23,7 @@ declare namespace NewTab { themeColor: string computedThemeColor: string pinned: boolean - bookmarked?: boolean + bookmarked?: Bookmark } export interface Stats { @@ -34,6 +34,15 @@ declare namespace NewTab { fingerprintingBlockedStat: number } + export interface Bookmark { + dateAdded: number + id: string + index: number + parentId: string + title: string + url: string + } + export interface State { imageLoadFailed: boolean topSites: Site[], @@ -44,7 +53,7 @@ declare namespace NewTab { showEmptyPage: boolean, isIncognito: boolean, useAlternativePrivateSearchEngine: boolean, - bookmarks: Record, + bookmarks: Record, stats: Stats backgroundImage?: Image gridLayoutSize?: 'small' diff --git a/components/definitions/rewards.d.ts b/components/definitions/rewards.d.ts index 9d1ef7836f33..1d3137eefae9 100644 --- a/components/definitions/rewards.d.ts +++ b/components/definitions/rewards.d.ts @@ -1,6 +1,6 @@ declare namespace Rewards { export interface ApplicationState { - rewardsData: State + rewardsData: State | undefined } export interface State { diff --git a/components/definitions/welcome.d.ts b/components/definitions/welcome.d.ts index b8467c317ec2..7ccfbba4e421 100644 --- a/components/definitions/welcome.d.ts +++ b/components/definitions/welcome.d.ts @@ -1,6 +1,6 @@ declare namespace Welcome { export interface ApplicationState { - welcomeData: State + welcomeData: State | undefined } export interface State { From e842f2bf697505a03e39ebeb77f54c0650f94f2c Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 16 Jul 2018 12:52:37 +0200 Subject: [PATCH 9/9] Final changes to fix lint; Removes old dep; Header unification --- .../actions/adblock_actions.ts | 2 ++ components/brave_adblock_ui/brave_adblock.tsx | 6 +++- .../brave_adblock_ui/components/app.tsx | 8 +++-- .../reducers/adblock_reducer.ts | 3 ++ components/brave_adblock_ui/reducers/index.ts | 2 ++ components/brave_adblock_ui/store.ts | 2 ++ .../brave_new_tab_ui/actions/newTabActions.ts | 4 ++- components/brave_new_tab_ui/api.ts | 2 ++ components/brave_new_tab_ui/brave_new_tab.tsx | 6 +++- .../brave_new_tab_ui/components/app.tsx | 14 +++++--- .../brave_new_tab_ui/components/block.tsx | 4 ++- .../components/newPrivateTab.tsx | 11 +++---- .../brave_new_tab_ui/components/stats.tsx | 6 +++- .../{ => constants}/backgrounds.ts | 0 .../brave_new_tab_ui/{ => constants}/theme.ts | 0 components/brave_new_tab_ui/reducers/index.ts | 2 ++ .../reducers/newTabReducer.tsx | 4 +++ components/brave_new_tab_ui/storage.ts | 5 ++- components/brave_new_tab_ui/store.ts | 2 ++ .../actions/rewards_actions.ts | 2 ++ components/brave_rewards_ui/brave_rewards.tsx | 6 +++- .../brave_rewards_ui/components/app.tsx | 6 ++-- components/brave_rewards_ui/reducers/index.ts | 2 ++ .../reducers/rewards_reducer.ts | 4 +++ components/brave_rewards_ui/storage.ts | 1 + components/brave_rewards_ui/store.ts | 2 ++ .../actions/welcome_actions.ts | 2 ++ components/brave_welcome_ui/brave_welcome.tsx | 4 +++ .../brave_welcome_ui/components/app.tsx | 8 +++-- .../components/braveScreen.tsx | 9 ++++-- .../components/featuresScreen.tsx | 9 ++++-- .../brave_welcome_ui/components/footer.tsx | 8 +++-- .../components/importScreen.tsx | 9 ++++-- .../components/rewardsScreen.tsx | 5 ++- .../components/shieldsScreen.tsx | 4 ++- .../brave_welcome_ui/{ => constants}/theme.ts | 15 +++++++-- components/brave_welcome_ui/reducers/index.ts | 2 ++ .../reducers/welcome_reducer.ts | 4 +++ components/brave_welcome_ui/storage.ts | 1 + components/brave_welcome_ui/store.ts | 2 ++ components/common/classSet.ts | 2 +- components/definitions/adBlock.d.ts | 4 --- components/definitions/newTab.d.ts | 4 --- package-lock.json | 32 +------------------ package.json | 2 +- 45 files changed, 154 insertions(+), 78 deletions(-) rename components/brave_new_tab_ui/{ => constants}/backgrounds.ts (100%) rename components/brave_new_tab_ui/{ => constants}/theme.ts (100%) rename components/brave_welcome_ui/{ => constants}/theme.ts (84%) diff --git a/components/brave_adblock_ui/actions/adblock_actions.ts b/components/brave_adblock_ui/actions/adblock_actions.ts index 1e67c96cd8c1..ca4b394bc6a1 100644 --- a/components/brave_adblock_ui/actions/adblock_actions.ts +++ b/components/brave_adblock_ui/actions/adblock_actions.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' + +// Constants import { types } from '../constants/adblock_types' export const statsUpdated = () => action(types.ADBLOCK_STATS_UPDATED) diff --git a/components/brave_adblock_ui/brave_adblock.tsx b/components/brave_adblock_ui/brave_adblock.tsx index 879ee034832b..734cd944b73c 100644 --- a/components/brave_adblock_ui/brave_adblock.tsx +++ b/components/brave_adblock_ui/brave_adblock.tsx @@ -5,8 +5,12 @@ import * as React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' -import App from './components/app' import { bindActionCreators } from 'redux' + +// Components +import App from './components/app' + +// Utils import store from './store' import * as adblockActions from './actions/adblock_actions' diff --git a/components/brave_adblock_ui/components/app.tsx b/components/brave_adblock_ui/components/app.tsx index dae882824dd5..da6739fc948d 100644 --- a/components/brave_adblock_ui/components/app.tsx +++ b/components/brave_adblock_ui/components/app.tsx @@ -5,12 +5,16 @@ import * as React from 'react' import { bindActionCreators, Dispatch } from 'redux' import { connect } from 'react-redux' + +// Components import { RegionalAdBlockEnabled } from './regionalAdBlockEnabled' -import * as adblockActions from '../actions/adblock_actions' import { NumBlockedStat } from './numBlockedStat' +// Utils +import * as adblockActions from '../actions/adblock_actions' + interface Props { - actions: AdBlock.Actions + actions: any adblockData: AdBlock.State } diff --git a/components/brave_adblock_ui/reducers/adblock_reducer.ts b/components/brave_adblock_ui/reducers/adblock_reducer.ts index 6b84e63f78c8..4670199493e2 100644 --- a/components/brave_adblock_ui/reducers/adblock_reducer.ts +++ b/components/brave_adblock_ui/reducers/adblock_reducer.ts @@ -4,7 +4,10 @@ import { Reducer } from 'redux' +// Constants import { types } from '../constants/adblock_types' + +// Utils import * as storage from '../storage' const adblockReducer: Reducer = (state: AdBlock.State | undefined, action) => { diff --git a/components/brave_adblock_ui/reducers/index.ts b/components/brave_adblock_ui/reducers/index.ts index 2d0d9d45b3f1..6adc98c1a5f6 100644 --- a/components/brave_adblock_ui/reducers/index.ts +++ b/components/brave_adblock_ui/reducers/index.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { combineReducers } from 'redux' + +// Utils import adblockReducer from './adblock_reducer' export default combineReducers({ diff --git a/components/brave_adblock_ui/store.ts b/components/brave_adblock_ui/store.ts index f661b99b374f..ab32f65ee84e 100644 --- a/components/brave_adblock_ui/store.ts +++ b/components/brave_adblock_ui/store.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { createStore } from 'redux' + +// Utils import reducers from './reducers' export default createStore(reducers) diff --git a/components/brave_new_tab_ui/actions/newTabActions.ts b/components/brave_new_tab_ui/actions/newTabActions.ts index ee35ff9f89bf..d81f563edf83 100644 --- a/components/brave_new_tab_ui/actions/newTabActions.ts +++ b/components/brave_new_tab_ui/actions/newTabActions.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' + +// Constants import { types } from '../constants/newTabTypes' export const topSitesDataUpdated = (topSites: NewTab.Site[]) => action(types.NEW_TAB_TOP_SITES_DATA_UPDATED, { @@ -52,7 +54,7 @@ export const siteDragEnd = (url: string, didDrop: boolean) => action(types.NEW_T export const onHideSiteRemovalNotification = () => action(types.NEW_TAB_HIDE_SITE_REMOVAL_NOTIFICATION) -export const bookmarkInfoAvailable = (queryUrl: string, bookmarkTreeNode: any) => action(types.NEW_TAB_BOOKMARK_INFO_AVAILABLE, { +export const bookmarkInfoAvailable = (queryUrl: string, bookmarkTreeNode: NewTab.Bookmark) => action(types.NEW_TAB_BOOKMARK_INFO_AVAILABLE, { queryUrl, bookmarkTreeNode }) diff --git a/components/brave_new_tab_ui/api.ts b/components/brave_new_tab_ui/api.ts index 4a52ee59dc51..ebb045e81b13 100644 --- a/components/brave_new_tab_ui/api.ts +++ b/components/brave_new_tab_ui/api.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { bindActionCreators } from 'redux' + +// Utils import * as newTabActions from './actions/newTabActions' import { debounce } from '../common/debounce' import store from './store' diff --git a/components/brave_new_tab_ui/brave_new_tab.tsx b/components/brave_new_tab_ui/brave_new_tab.tsx index c5e6e3b8880c..ac036bfdad10 100644 --- a/components/brave_new_tab_ui/brave_new_tab.tsx +++ b/components/brave_new_tab_ui/brave_new_tab.tsx @@ -5,8 +5,12 @@ import * as React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' -import App from './components/app' import { bindActionCreators } from 'redux' + +// Components +import App from './components/app' + +// Utils import store from './store' import * as newTabActions from './actions/newTabActions' diff --git a/components/brave_new_tab_ui/components/app.tsx b/components/brave_new_tab_ui/components/app.tsx index 1d8b68321b88..1ad3ce214cce 100644 --- a/components/brave_new_tab_ui/components/app.tsx +++ b/components/brave_new_tab_ui/components/app.tsx @@ -4,21 +4,25 @@ import * as React from 'react' import { DragDropContext } from 'react-dnd' -import { bindActionCreators } from 'redux' +import { bindActionCreators, Dispatch } from 'redux' import { connect } from 'react-redux' import HTML5Backend from 'react-dnd-html5-backend' -import * as newTabActions from '../actions/newTabActions' +import { Grid, Column, Clock } from 'brave-ui' // Components -import { Grid, Column, Clock } from 'brave-ui' import Stats from './stats' import Block from './block' import FooterInfo from './footerInfo' import SiteRemovalNotification from './siteRemovalNotification' import NewPrivateTab from './newPrivateTab' +// Constants +import { theme } from '../constants/theme' + +// Utils +import * as newTabActions from '../actions/newTabActions' + // Assets -import { theme } from '../theme' require('../../styles/newtab.less') require('font-awesome/css/font-awesome.css') require('../../fonts/poppins.css') @@ -196,7 +200,7 @@ const mapStateToProps = (state: NewTab.ApplicationState) => ({ newTabData: state.newTabData }) -const mapDispatchToProps = (dispatch: any) => ({ +const mapDispatchToProps = (dispatch: Dispatch) => ({ actions: bindActionCreators(newTabActions, dispatch) }) diff --git a/components/brave_new_tab_ui/components/block.tsx b/components/brave_new_tab_ui/components/block.tsx index 7062c959c173..bc9b7ea77852 100644 --- a/components/brave_new_tab_ui/components/block.tsx +++ b/components/brave_new_tab_ui/components/block.tsx @@ -3,7 +3,6 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -import { cx } from '../../common/classSet' import { DragSource, DragSourceCollector, DragSourceConnector, @@ -13,6 +12,9 @@ import { DropTargetMonitor, DropTargetSpec } from 'react-dnd' +// Utils +import { cx } from '../../common/classSet' + const Types = { BLOCK: 'block' } diff --git a/components/brave_new_tab_ui/components/newPrivateTab.tsx b/components/brave_new_tab_ui/components/newPrivateTab.tsx index 7edbb40fd11e..f23ee4071bb4 100644 --- a/components/brave_new_tab_ui/components/newPrivateTab.tsx +++ b/components/brave_new_tab_ui/components/newPrivateTab.tsx @@ -4,8 +4,6 @@ import * as React from 'react' import { getLocale } from '../../common/locale' - -// Components import { Page, Grid, @@ -18,14 +16,15 @@ import { Clock } from 'brave-ui' +// Components import Stats from './stats' -// Theme -import { theme } from '../theme' -require('emptykit.css') +// Constant +import { theme } from '../constants/theme' -// Images +// Assets const privateTabIcon = require('../../img/newtab/private_tab_pagearea_icon.svg') +require('emptykit.css') interface Props { stats: NewTab.Stats, diff --git a/components/brave_new_tab_ui/components/stats.tsx b/components/brave_new_tab_ui/components/stats.tsx index cb0b19e32cb9..52a24b438cc4 100644 --- a/components/brave_new_tab_ui/components/stats.tsx +++ b/components/brave_new_tab_ui/components/stats.tsx @@ -4,8 +4,12 @@ import * as React from 'react' import { DataBlock, DataItem } from 'brave-ui/dataBlock' + +// Constants +import { theme } from '../constants/theme' + +// Utils import { getLocale } from '../../common/locale' -import { theme } from '../theme' interface Props { stats: NewTab.Stats diff --git a/components/brave_new_tab_ui/backgrounds.ts b/components/brave_new_tab_ui/constants/backgrounds.ts similarity index 100% rename from components/brave_new_tab_ui/backgrounds.ts rename to components/brave_new_tab_ui/constants/backgrounds.ts diff --git a/components/brave_new_tab_ui/theme.ts b/components/brave_new_tab_ui/constants/theme.ts similarity index 100% rename from components/brave_new_tab_ui/theme.ts rename to components/brave_new_tab_ui/constants/theme.ts diff --git a/components/brave_new_tab_ui/reducers/index.ts b/components/brave_new_tab_ui/reducers/index.ts index c4ada0ec7bda..2be00e9261fc 100644 --- a/components/brave_new_tab_ui/reducers/index.ts +++ b/components/brave_new_tab_ui/reducers/index.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { combineReducers } from 'redux' + +// Utils import newTabReducer from './newTabReducer' export default combineReducers({ diff --git a/components/brave_new_tab_ui/reducers/newTabReducer.tsx b/components/brave_new_tab_ui/reducers/newTabReducer.tsx index a3c9d6f466f1..506ea3fa1268 100644 --- a/components/brave_new_tab_ui/reducers/newTabReducer.tsx +++ b/components/brave_new_tab_ui/reducers/newTabReducer.tsx @@ -3,7 +3,11 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Reducer } from 'redux' + +// Constants import { types } from '../constants/newTabTypes' + +// Utils import * as storage from '../storage' import { fetchBookmarkInfo, getGridSites, calculateGridSites, fetchTopSites } from '../api' diff --git a/components/brave_new_tab_ui/storage.ts b/components/brave_new_tab_ui/storage.ts index 9a58878f65df..c1f3e8b6addd 100644 --- a/components/brave_new_tab_ui/storage.ts +++ b/components/brave_new_tab_ui/storage.ts @@ -2,8 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// Constants +import { images as backgrounds } from './constants/backgrounds' + +// Utils import { debounce } from '../common/debounce' -import { images as backgrounds } from './backgrounds' const keyName = 'new-tab-data' diff --git a/components/brave_new_tab_ui/store.ts b/components/brave_new_tab_ui/store.ts index f661b99b374f..ab32f65ee84e 100644 --- a/components/brave_new_tab_ui/store.ts +++ b/components/brave_new_tab_ui/store.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { createStore } from 'redux' + +// Utils import reducers from './reducers' export default createStore(reducers) diff --git a/components/brave_rewards_ui/actions/rewards_actions.ts b/components/brave_rewards_ui/actions/rewards_actions.ts index 59215de1a1d7..a4ce362dd76c 100644 --- a/components/brave_rewards_ui/actions/rewards_actions.ts +++ b/components/brave_rewards_ui/actions/rewards_actions.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' + +// Constant import { types } from '../constants/rewards_types' export const createWalletRequested = () => action(types.CREATE_WALLET_REQUESTED) diff --git a/components/brave_rewards_ui/brave_rewards.tsx b/components/brave_rewards_ui/brave_rewards.tsx index ffd45542f846..578f3107c3fa 100644 --- a/components/brave_rewards_ui/brave_rewards.tsx +++ b/components/brave_rewards_ui/brave_rewards.tsx @@ -5,8 +5,12 @@ import * as React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' -import App from './components/app' import { bindActionCreators } from 'redux' + +// Components +import App from './components/app' + +// Utils import store from './store' import * as rewardsActions from './actions/rewards_actions' diff --git a/components/brave_rewards_ui/components/app.tsx b/components/brave_rewards_ui/components/app.tsx index aa9939ad930d..0d5e6dd657c1 100644 --- a/components/brave_rewards_ui/components/app.tsx +++ b/components/brave_rewards_ui/components/app.tsx @@ -3,8 +3,10 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -import { bindActionCreators } from 'redux' +import { bindActionCreators, Dispatch } from 'redux' import { connect } from 'react-redux' + +// Utils import * as rewardsActions from '../actions/rewards_actions' interface Props { @@ -47,7 +49,7 @@ const mapStateToProps = (state: Rewards.ApplicationState) => ({ rewardsData: state.rewardsData }) -const mapDispatchToProps = (dispatch: any) => ({ +const mapDispatchToProps = (dispatch: Dispatch) => ({ actions: bindActionCreators(rewardsActions, dispatch) }) diff --git a/components/brave_rewards_ui/reducers/index.ts b/components/brave_rewards_ui/reducers/index.ts index 792ce9c9d0f5..ca68535c4b80 100644 --- a/components/brave_rewards_ui/reducers/index.ts +++ b/components/brave_rewards_ui/reducers/index.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { combineReducers } from 'redux' + +// Utils import rewardsReducer from './rewards_reducer' export default combineReducers({ diff --git a/components/brave_rewards_ui/reducers/rewards_reducer.ts b/components/brave_rewards_ui/reducers/rewards_reducer.ts index 9207e003bf7a..534b38fac398 100644 --- a/components/brave_rewards_ui/reducers/rewards_reducer.ts +++ b/components/brave_rewards_ui/reducers/rewards_reducer.ts @@ -3,7 +3,11 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Reducer } from 'redux' + +// Constant import { types } from '../constants/rewards_types' + +// Utils import * as storage from '../storage' const rewardsReducer: Reducer = (state: Rewards.State | undefined, action) => { diff --git a/components/brave_rewards_ui/storage.ts b/components/brave_rewards_ui/storage.ts index 5b8c02d6fdb2..aa3ef0c41f9b 100644 --- a/components/brave_rewards_ui/storage.ts +++ b/components/brave_rewards_ui/storage.ts @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// Utils import { debounce } from '../common/debounce' const keyName = 'rewards-data' diff --git a/components/brave_rewards_ui/store.ts b/components/brave_rewards_ui/store.ts index f661b99b374f..ab32f65ee84e 100644 --- a/components/brave_rewards_ui/store.ts +++ b/components/brave_rewards_ui/store.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { createStore } from 'redux' + +// Utils import reducers from './reducers' export default createStore(reducers) diff --git a/components/brave_welcome_ui/actions/welcome_actions.ts b/components/brave_welcome_ui/actions/welcome_actions.ts index c65515f41008..b05e9d808145 100644 --- a/components/brave_welcome_ui/actions/welcome_actions.ts +++ b/components/brave_welcome_ui/actions/welcome_actions.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { action } from 'typesafe-actions' + +// Constants import { types } from '../constants/welcome_types' export const importNowRequested = () => action(types.IMPORT_NOW_REQUESTED) diff --git a/components/brave_welcome_ui/brave_welcome.tsx b/components/brave_welcome_ui/brave_welcome.tsx index ec2614d5deff..f3482bb5bf2d 100644 --- a/components/brave_welcome_ui/brave_welcome.tsx +++ b/components/brave_welcome_ui/brave_welcome.tsx @@ -5,7 +5,11 @@ import * as React from 'react' import { render } from 'react-dom' import { Provider } from 'react-redux' + +// Components import App from './components/app' + +// Utils import store from './store' window.cr.define('brave_welcome', function () { diff --git a/components/brave_welcome_ui/components/app.tsx b/components/brave_welcome_ui/components/app.tsx index 5dee30aa5d7b..f864ebf941e9 100644 --- a/components/brave_welcome_ui/components/app.tsx +++ b/components/brave_welcome_ui/components/app.tsx @@ -3,7 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -import { bindActionCreators } from 'redux' +import { bindActionCreators, Dispatch } from 'redux' import { connect } from 'react-redux' import { UnstyledButton } from 'brave-ui' import Panel from 'brave-ui/v1/panel' @@ -16,9 +16,11 @@ import ShieldsScreen from './shieldsScreen' import FeaturesScreen from './featuresScreen' import Footer from './footer' +// Constants +import { theme } from '../constants/theme' + // Utils import * as welcomeActions from '../actions/welcome_actions' -import { theme } from '../theme' // Assets const background = require('../../img/welcome/welcomebg.svg') @@ -154,7 +156,7 @@ const mapStateToProps = (state: Welcome.ApplicationState) => ({ welcomeData: state.welcomeData }) -const mapDispatchToProps = (dispatch: any) => ({ +const mapDispatchToProps = (dispatch: Dispatch) => ({ actions: bindActionCreators(welcomeActions, dispatch) }) diff --git a/components/brave_welcome_ui/components/braveScreen.tsx b/components/brave_welcome_ui/components/braveScreen.tsx index ce2f2ec1d0f8..2005316e3c3d 100644 --- a/components/brave_welcome_ui/components/braveScreen.tsx +++ b/components/brave_welcome_ui/components/braveScreen.tsx @@ -3,12 +3,17 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -import { getLocale } from '../../common/locale' import Image from 'brave-ui/v1/image' import { PushButton } from 'brave-ui/v1/pushButton' import { Heading, Paragraph } from 'brave-ui' -import { theme } from '../theme' +// Constants +import { theme } from '../constants/theme' + +// Utils +import { getLocale } from '../../common/locale' + +// Assets const braveLogo = require('../../img/welcome/brave_logo.png') interface Props { diff --git a/components/brave_welcome_ui/components/featuresScreen.tsx b/components/brave_welcome_ui/components/featuresScreen.tsx index 089cd458f7d5..91ea0b870afe 100644 --- a/components/brave_welcome_ui/components/featuresScreen.tsx +++ b/components/brave_welcome_ui/components/featuresScreen.tsx @@ -3,12 +3,17 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -import { getLocale } from '../../common/locale' import Image from 'brave-ui/v1/image' import { PushButtonLink } from 'brave-ui/v1/pushButton' import { Heading, Paragraph } from 'brave-ui' -import { theme } from '../theme' +// Constants +import { theme } from '../constants/theme' + +// Utils +import { getLocale } from '../../common/locale' + +// Assets const featuresImage = require('../../img/welcome/features.png') export default class FeaturesScreen extends React.PureComponent<{}, {}> { diff --git a/components/brave_welcome_ui/components/footer.tsx b/components/brave_welcome_ui/components/footer.tsx index 88d8e16d39fb..49cc9030a6b1 100644 --- a/components/brave_welcome_ui/components/footer.tsx +++ b/components/brave_welcome_ui/components/footer.tsx @@ -3,11 +3,15 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -import { getLocale } from '../../common/locale' import { PushButton, PushButtonLink } from 'brave-ui/v1/pushButton' import ArrowRight from 'brave-ui/v1/icons/arrowRight' import { Grid, Column, Anchor } from 'brave-ui' -import { theme } from '../theme' + +// Constants +import { theme } from '../constants/theme' + +// Utils +import { getLocale } from '../../common/locale' interface Props { pageIndex: number, diff --git a/components/brave_welcome_ui/components/importScreen.tsx b/components/brave_welcome_ui/components/importScreen.tsx index 7bcac597566d..2fea7048300b 100644 --- a/components/brave_welcome_ui/components/importScreen.tsx +++ b/components/brave_welcome_ui/components/importScreen.tsx @@ -3,12 +3,17 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import * as React from 'react' -import { getLocale } from '../../common/locale' import Image from 'brave-ui/v1/image' import { PushButton } from 'brave-ui/v1/pushButton' import { Heading, Paragraph } from 'brave-ui' -import { theme } from '../theme' +// Constants +import { theme } from '../constants/theme' + +// Utils +import { getLocale } from '../../common/locale' + +// Assets const importImage = require('../../img/welcome/import.png') interface Props { diff --git a/components/brave_welcome_ui/components/rewardsScreen.tsx b/components/brave_welcome_ui/components/rewardsScreen.tsx index a59574515e19..aaa6734349e0 100644 --- a/components/brave_welcome_ui/components/rewardsScreen.tsx +++ b/components/brave_welcome_ui/components/rewardsScreen.tsx @@ -7,10 +7,13 @@ import { Heading, Paragraph } from 'brave-ui' import Image from 'brave-ui/v1/image' import { PushButtonLink } from 'brave-ui/v1/pushButton' +// Constants +import { theme } from '../constants/theme' + // Utils -import { theme } from '../theme' import { getLocale } from '../../common/locale' +// Assets const rewardsImage = require('../../img/welcome/rewards.png') export default class RewardsScreen extends React.PureComponent { diff --git a/components/brave_welcome_ui/components/shieldsScreen.tsx b/components/brave_welcome_ui/components/shieldsScreen.tsx index 661e5d33d225..6b9886d7f69b 100644 --- a/components/brave_welcome_ui/components/shieldsScreen.tsx +++ b/components/brave_welcome_ui/components/shieldsScreen.tsx @@ -6,9 +6,11 @@ import * as React from 'react' import Image from 'brave-ui/v1/image' import { Heading, Paragraph } from 'brave-ui' +// Constants +import { theme } from '../constants/theme' + // Utils import { getLocale } from '../../common/locale' -import { theme } from '../theme' // Assets const shieldsImage = require('../../img/welcome/shields.png') diff --git a/components/brave_welcome_ui/theme.ts b/components/brave_welcome_ui/constants/theme.ts similarity index 84% rename from components/brave_welcome_ui/theme.ts rename to components/brave_welcome_ui/constants/theme.ts index 5738cf5f8fc9..e211190b5422 100644 --- a/components/brave_welcome_ui/theme.ts +++ b/components/brave_welcome_ui/constants/theme.ts @@ -2,6 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +import * as CSS from 'csstype' + +interface Content { + display: CSS.DisplayProperty + flexDirection: CSS.FlexDirectionProperty + justifyContent: CSS.JustifyContentProperty + alignItems: CSS.AlignItemsProperty + flex: CSS.FlexProperty<1> + marginBottom: CSS.MarginBottomProperty<1> +} + export const theme = { panel: { backgroundColor: 'rgba(255,255,255,0.95)', @@ -52,12 +63,12 @@ export const theme = { }, content: { display: 'flex', - // flexDirection: 'column', TODO figure it out why it's failing https://github.com/Microsoft/TypeScript/issues/9489 + flexDirection: 'column', justifyContent: 'center', alignItems: 'center', flex: '1', marginBottom: '40px' - }, + } as Content, skip: { color: '#76777A', textDecoration: 'underline' diff --git a/components/brave_welcome_ui/reducers/index.ts b/components/brave_welcome_ui/reducers/index.ts index 20b894217e3e..ae0be51d761c 100644 --- a/components/brave_welcome_ui/reducers/index.ts +++ b/components/brave_welcome_ui/reducers/index.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { combineReducers } from 'redux' + +// Utils import welcomeReducer from './welcome_reducer' export default combineReducers({ diff --git a/components/brave_welcome_ui/reducers/welcome_reducer.ts b/components/brave_welcome_ui/reducers/welcome_reducer.ts index bfb265853f4c..9d5edfbb38f0 100644 --- a/components/brave_welcome_ui/reducers/welcome_reducer.ts +++ b/components/brave_welcome_ui/reducers/welcome_reducer.ts @@ -3,7 +3,11 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Reducer } from 'redux' + +// Constants import { types } from '../constants/welcome_types' + +// Utils import * as storage from '../storage' const welcomeReducer: Reducer = (state: Welcome.State | undefined, action: any) => { diff --git a/components/brave_welcome_ui/storage.ts b/components/brave_welcome_ui/storage.ts index c89f3bb9604d..dee9caafb275 100644 --- a/components/brave_welcome_ui/storage.ts +++ b/components/brave_welcome_ui/storage.ts @@ -2,6 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ +// Utils import { debounce } from '../common/debounce' const keyName = 'welcome-data' diff --git a/components/brave_welcome_ui/store.ts b/components/brave_welcome_ui/store.ts index f661b99b374f..ab32f65ee84e 100644 --- a/components/brave_welcome_ui/store.ts +++ b/components/brave_welcome_ui/store.ts @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ import { createStore } from 'redux' + +// Utils import reducers from './reducers' export default createStore(reducers) diff --git a/components/common/classSet.ts b/components/common/classSet.ts index 0ade1c8492c4..ad7a1c079d07 100644 --- a/components/common/classSet.ts +++ b/components/common/classSet.ts @@ -7,4 +7,4 @@ * Only the property names with truthy values are included. */ // TODO remove NZ -export const cx = (obj: any) => Object.keys(obj).filter((prop) => obj[prop]).join(' ') +export const cx = (obj: Record) => Object.keys(obj).filter((prop) => obj[prop]).join(' ') diff --git a/components/definitions/adBlock.d.ts b/components/definitions/adBlock.d.ts index 5eed1099da7b..df81457190f6 100644 --- a/components/definitions/adBlock.d.ts +++ b/components/definitions/adBlock.d.ts @@ -11,8 +11,4 @@ declare namespace AdBlock { regionalAdBlockTitle?: string } } - - export interface Actions { - statsUpdated: any - } } diff --git a/components/definitions/newTab.d.ts b/components/definitions/newTab.d.ts index 9830e42d421d..99fc30c9dfcf 100644 --- a/components/definitions/newTab.d.ts +++ b/components/definitions/newTab.d.ts @@ -59,8 +59,4 @@ declare namespace NewTab { gridLayoutSize?: 'small' showSiteRemovalNotification?: boolean } - - export interface Actions { - statsUpdated: any - } } diff --git a/package-lock.json b/package-lock.json index df9d1133af9f..df071ede2aa5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,29 +72,6 @@ "redux": "^4.0.0" } }, - "@types/redux-logger": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@types/redux-logger/-/redux-logger-3.0.6.tgz", - "integrity": "sha512-HXVJnbyuTcVtQ+qiwDcbLEMoOgNjKnNYVKx29P4NhV+FIgVVRCFILEPzjgSxlmMLc6aBVaEew7PfE3421DZ6Jw==", - "dev": true, - "requires": { - "redux": "^3.6.0" - }, - "dependencies": { - "redux": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/redux/-/redux-3.7.2.tgz", - "integrity": "sha512-pNqnf9q1hI5HHZRBkj3bAngGZW/JMCmexDlOxw4XagXY2o1327nHH54LoTjiPJ0gizoqPDRqWyX/00g0hD6w+A==", - "dev": true, - "requires": { - "lodash": "^4.2.1", - "lodash-es": "^4.2.1", - "loose-envify": "^1.1.0", - "symbol-observable": "^1.0.3" - } - } - } - }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -317,8 +294,7 @@ "csstype": { "version": "2.5.5", "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.5.5.tgz", - "integrity": "sha512-EGMjeoiN3aqEX5u/cyH5mSdGBDGdLcCQvcEcBWNGFSPXKd9uOTIeVG91YQ22OxI44DKpvI+4C7VUSmEpsHWJaA==", - "dev": true + "integrity": "sha512-EGMjeoiN3aqEX5u/cyH5mSdGBDGdLcCQvcEcBWNGFSPXKd9uOTIeVG91YQ22OxI44DKpvI+4C7VUSmEpsHWJaA==" }, "diff": { "version": "3.5.0", @@ -529,12 +505,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, - "lodash-es": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.10.tgz", - "integrity": "sha512-iesFYPmxYYGTcmQK0sL8bX3TGHyM6b2qREaB4kamHfQyfPJP0xgoGxp19nsH16nsfquLdiyKyX3mQkfiSGV8Rg==", - "dev": true - }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", diff --git a/package.json b/package.json index 4734666efbd2..7b8d893b6351 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@types/react-dnd": "^2.0.36", "@types/react-dom": "^16.0.3", "@types/react-redux": "^6.0.4", - "@types/redux-logger": "^3.0.5", + "csstype": "^2.5.5", "tslint": "^5.8.0", "tslint-config-standard": "^7.0.0", "tslint-react": "^3.2.0",