diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 67a0c942..00000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["env", "next/babel"] -} diff --git a/.eslintignore b/.eslintignore index c6417d93..99a9eb4c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,3 @@ flow-typed +web/.next +web/cosmos-export diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 7be404db..00000000 --- a/.eslintrc +++ /dev/null @@ -1,59 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": [ - "eslint:recommended", - "plugin:import/errors", - "plugin:import/warnings", - "plugin:flowtype/recommended" - ], - "plugins": ["react", "flowtype"], - "env": { - "es6": true, - "shared-node-browser": true - }, - "globals": { - "global": true, - "process": true - }, - "rules": { - "no-console": "off", - "flowtype/generic-spacing": "off" - }, - "overrides": [ - { - "files": [ - "jest.config.js", - "jest.framework-setup.js", - "cosmos.config.js", - "cosmos.test.js", - "next.config.js", - "server.js", - "server/**/*.js" - ], - "env": { - "node": true - } - }, - { - "files": ["**/*.test.js"], - "env": { - "jest": true - } - }, - { - "files": [ - "components/**/*.js", - "pages/**/*.js", - "utils/socket-connect.js", - "cosmos.proxies.js" - ], - "rules": { - "react/jsx-uses-react": "error", - "react/jsx-uses-vars": "error" - } - }, - { - "files": ["**/__fixtures__/**/*.js", "server.js"] - } - ] -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..5f4f97e2 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,64 @@ +module.exports = { + parser: 'babel-eslint', + extends: [ + 'eslint:recommended', + 'plugin:import/errors', + 'plugin:import/warnings', + 'plugin:flowtype/recommended' + ], + plugins: ['react', 'flowtype'], + env: { + es6: true, + 'shared-node-browser': true + }, + settings: { + 'import/resolver': { + 'babel-module': {} + } + }, + globals: { + global: true, + process: true + }, + rules: { + 'no-console': 'off', + 'flowtype/generic-spacing': 'off' + }, + overrides: [ + { + files: [ + '.eslintrc.js', + 'babel.config.js', + 'jest.config.js', + 'jest.framework-setup.js', + 'web/next.config.js', + 'web/cosmos.config.js', + 'web/cosmos.test.js', + 'server/**/*.js' + ], + env: { + node: true + } + }, + { + files: ['**/*.test.js'], + env: { + jest: true + } + }, + { + files: [ + 'web/components/**/*.js', + 'web/pages/**/*.js', + 'cosmos.proxies.js' + ], + rules: { + 'react/jsx-uses-react': 'error', + 'react/jsx-uses-vars': 'error' + } + }, + { + files: ['**/__fixtures__/**/*.js'] + } + ] +}; diff --git a/.flowconfig b/.flowconfig index 92ccf269..245df33e 100644 --- a/.flowconfig +++ b/.flowconfig @@ -12,5 +12,6 @@ flow-typed [lints] [options] +module.name_mapper='^shared' ->'/shared' [strict] diff --git a/.prettierignore b/.prettierignore index ec6d3cdd..b9cceed8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ package.json +flow-typed diff --git a/TODO.md b/TODO.md index f45fa6de..3669a170 100644 --- a/TODO.md +++ b/TODO.md @@ -1,193 +1,198 @@ -* [x] Extract Preloader component (get from public/index.html) -* [x] Remove dynamic layout -* [x] Create script for generating media queries for game page +- [x] Extract Preloader component (get from public/index.html) +- [x] Remove dynamic layout +- [x] Create script for generating media queries for game page Search: Does media query include scrollbar? Actually, the whole point is to avoid a scrollbar -* [x] Design game UI screens (new game, pausing) -* [x] Add user list to GamePanel -* [x] Design new game state (with Flow types) - * [x] Put `curUser` in Redux state - * [x] Derive playing state from `users(status=playing).len` -* [x] Add missing screens for multiplayer flows -* [x] PIVOT: Turn collaborative Flatris (2-8 players) into competitive 1vs1 Flatris - * [x] Redesign state and actions - * [x] Make MOVE, ROTATE, ENABLE_ACCELERATION, DISABLE_ACCELERATION userId based - * [x] Cancel ADVANCE loop on unmount - * [x] Disable acceleration on line drop - * [x] ADVANCE action for current user - * [x] Remove START/STOP actions - * [x] Clear onboarding screens (postpone UI this time until game mechanics are confirmed) - * [x] Update fixtures and tests - * [x] Add 2nd player - * [x] Start game when both players are ready - * [x] Render other player's grid in the background -* [x] Create server MVP database - * [x] Split client logic between starting or joining a game -* [x] Rename state.game to state.curGame -* [x] Add blocks to other player when clearing lines -* [x] Bring back "falling" block transition when lines are cleared -* [x] Transitions when clearing lines - * [x] Cleared lines should go down (not instantly disappear) - * [x] Lines from enemy should come up (not instantly appear) - * [x] getNextCellId(gameState) abstraction -* [x] Fix concomitant line clearing between players - * [x] Fix multiplayer test case: Clearing lines that aren't bottom ones -* [x] Expand memory db to multi games -* [x] Green/red wall flash when clearing lines (own vs enemy) -* [x] Earthquake effect when clearing lines -* [x] Make enemy grid visible on Firefox -* [x] Add hidden keyboard shortcut for stopping game -* [x] Clean up server scripts (Keep server with client together in prod, separate in dev) -* [x] [WORKING PROTOTYPE] -* [x] Handle wrong game ID with 404 -* [x] Create server-side user sessions -* [x] Read game (Redux) state from server side in Page.getInitialProps -* [x] Use HTTP request instead of socket event to create game -* [x] Load entire game state on load -* [x] Don't join game if 2 players are already in -* [x] Create join/:id route -* [x] Turn sessionId, userId & gameId numbers into hashes -* [x] Grayscale loading state until JS is loaded -* [x] Subscribe to game events on game page, once JS is loaded -* [x] Continue game after hard refresh -* [x] Add fixtures for all components -* [x] Add disabled state to buttons (get rid of early exists in handlers) -* [x] Create "Invite or play" screen -* [x] Create "Game full" screen -* [x] Create "Join game" screen -* [x] Create "Get ready" screen -* [x] Create "Waiting for other" screen -* [x] Create "Game over" screen - * [x] Allow players to restart once game is over -* [x] Different layouts per device type/orientation - * [x] No controls on desktop -* [x] Drop Tetromino on SPACE key -* [x] Style "Auth" screen - * [x] When joining - * [x] When creating - * [x] Restrict name length -* [x] Reuse old public assets - * [x] Add meta tags from old index.html -* [x] Style GamePanel - * [x] Show both players' score in game panel - * [x] Show player READY state - * [x] New Flatris logo - * [x] Humanize numbers over 1K - * [x] Show lines instead of "wins" for single player - * [x] Make "2P insert coin" clickable -* [x] Add global score (how many games each player won) -* [x] Add ability to PING other player -* [x] Allow users to just watch -* [x] Onboarding screen - * [x] Left, right, up, down & space keys for desktop - * [x] Point to controls - * [x] Explain Flatris invention: line transferring -* [x] [ALPHA TESTING] feedback - * [x] Disable in-game auth after entering 1st time - * [x] Fade in game screens - * [x] Generate new Tetromino random sequence per game turn - * [x] Improve ending UI: Add WON green badge under player name - * [x] Regression: Change "WON" badge to not block user score -* [x] Encourage players to play "best x out of y" -* [x] Disable controls when user isn't playing -* [x] Side controls on landscape mobile - * [x] Extract portrait controls out of FlatrisGame -* [x] Don't request user auth when game is full (allow guests to watch) -* [x] Add copy to clipboard btn to "Invite or play" screen - * [x] Show share button when clicking on "2P insert coin" -* [x] [BEAUTIFUL MVP] -* [x] Ensure action consistency - * [x] Create action backfill if user has old state and new actions - * [x] Create action.id, action.prevId and game.player.lastActionId - * [x] Store actions on the server - * [x] Create backfill operation -* [x] UX: Disable Auth buttons while performing IO -* [x] UX: Disable buttons while JS is loading - * [x] 2P Insert Coin in GamePanel - * [x] screens/Auth name field - * [x] screens/GameFull Watch - * [x] screens/GameOver Again - * [x] screens/GetReady Ready - * [x] screens/JoinGame Watch and Join - * [x] screens/NewGame Play and Copy - * [x] screens/WaitingForOther Ping -* [x] Add pause & end game state for solo players with invite screen -* [x] Index page - * [x] Create reduxState.games - * [x] List all games - * [x] Beautiful grid - * [x] Animating games - * [x] Strip game effects when going back to index page - * [x] Push new games to dashboard - * [x] Remove inactive games - * [x] Mark inactive after 30 seconds - * [x] Remove expired after 15 minutes - * [x] Redirect to dashboard from expired game page - * [x] Style - * [x] Style NEW GAME button - * [x] Add Flatris header - * [x] Show blank state when no active games exist - * [x] Fade in fade out transition game previews - * [x] Highlight already joined games -* [x] BUG: Broadcast new game to `global` (without requiring an action) -* [x] BUG: Reset losses when 2nd player joins -* [x] Minimize network communication: Don't send noop actions -* [x] Throttle key down events -* [x] Profile browser performance (detect unnecessary renders) -* [x] Redesign onboarding - * [x] Screen 1: Game intro - * [x] Screen 2: Multiplayer game - * [x] Screen 3: Line transferring - * [x] Screen 4: Controls -* [x] Custom 404 page -* [x] Error page (via componentDidCatch) -* [x] Add empty game shell to Dashboard blank state -* [x] Link to Github -* [x] Game footer -* [x] Disable active Tetromino movement when game over (via mobile buttons) -* [x] [1.0] - * [x] Merge to master - * [x] Rollbar server - * [x] Rollbar client - * [x] https://flatris.space -* [x] Embed Teko font in JS bundle -* [x] Record stats - * [x] Store in Firebase (users, games) - * [x] Count Turns and lines - * [x] Count actions (left, right, accelerate, rotate) - * [x] Count time -* [x] BUG: Gracefully invalidate session after re-deploy -* [x] Sync game after player disconnect -* [x] Real time stats page -* [x] [2.0] - * [x] Share on HN, PH, Reddit, etc -* [ ] Fix: Polyfill Set/Map https://reactjs.org/docs/javascript-environment-requirements.html -* [ ] Increase speed logarithmically (game currently ends too abruptly) -* [ ] "Paused" state for solo players (useful in dashboard to see if person paused or disappeared) - * [ ] How about "idle" state? -* [ ] Ask for permission to join game - * [ ] "Waiting for permission..." screen - * [ ] "Allow player to join?" screen - * [ ] "Denied" screen +- [x] Design game UI screens (new game, pausing) +- [x] Add user list to GamePanel +- [x] Design new game state (with Flow types) + - [x] Put `curUser` in Redux state + - [x] Derive playing state from `users(status=playing).len` +- [x] Add missing screens for multiplayer flows +- [x] PIVOT: Turn collaborative Flatris (2-8 players) into competitive 1vs1 Flatris + - [x] Redesign state and actions + - [x] Make MOVE, ROTATE, ENABLE_ACCELERATION, DISABLE_ACCELERATION userId based + - [x] Cancel ADVANCE loop on unmount + - [x] Disable acceleration on line drop + - [x] ADVANCE action for current user + - [x] Remove START/STOP actions + - [x] Clear onboarding screens (postpone UI this time until game mechanics are confirmed) + - [x] Update fixtures and tests + - [x] Add 2nd player + - [x] Start game when both players are ready + - [x] Render other player's grid in the background +- [x] Create server MVP database + - [x] Split client logic between starting or joining a game +- [x] Rename state.game to state.curGame +- [x] Add blocks to other player when clearing lines +- [x] Bring back "falling" block transition when lines are cleared +- [x] Transitions when clearing lines + - [x] Cleared lines should go down (not instantly disappear) + - [x] Lines from enemy should come up (not instantly appear) + - [x] getNextCellId(gameState) abstraction +- [x] Fix concomitant line clearing between players + - [x] Fix multiplayer test case: Clearing lines that aren't bottom ones +- [x] Expand memory db to multi games +- [x] Green/red wall flash when clearing lines (own vs enemy) +- [x] Earthquake effect when clearing lines +- [x] Make enemy grid visible on Firefox +- [x] Add hidden keyboard shortcut for stopping game +- [x] Clean up server scripts (Keep server with client together in prod, separate in dev) +- [x] [WORKING PROTOTYPE] +- [x] Handle wrong game ID with 404 +- [x] Create server-side user sessions +- [x] Read game (Redux) state from server side in Page.getInitialProps +- [x] Use HTTP request instead of socket event to create game +- [x] Load entire game state on load +- [x] Don't join game if 2 players are already in +- [x] Create join/:id route +- [x] Turn sessionId, userId & gameId numbers into hashes +- [x] Grayscale loading state until JS is loaded +- [x] Subscribe to game events on game page, once JS is loaded +- [x] Continue game after hard refresh +- [x] Add fixtures for all components +- [x] Add disabled state to buttons (get rid of early exists in handlers) +- [x] Create "Invite or play" screen +- [x] Create "Game full" screen +- [x] Create "Join game" screen +- [x] Create "Get ready" screen +- [x] Create "Waiting for other" screen +- [x] Create "Game over" screen + - [x] Allow players to restart once game is over +- [x] Different layouts per device type/orientation + - [x] No controls on desktop +- [x] Drop Tetromino on SPACE key +- [x] Style "Auth" screen + - [x] When joining + - [x] When creating + - [x] Restrict name length +- [x] Reuse old public assets + - [x] Add meta tags from old index.html +- [x] Style GamePanel + - [x] Show both players' score in game panel + - [x] Show player READY state + - [x] New Flatris logo + - [x] Humanize numbers over 1K + - [x] Show lines instead of "wins" for single player + - [x] Make "2P insert coin" clickable +- [x] Add global score (how many games each player won) +- [x] Add ability to PING other player +- [x] Allow users to just watch +- [x] Onboarding screen + - [x] Left, right, up, down & space keys for desktop + - [x] Point to controls + - [x] Explain Flatris invention: line transferring +- [x] [ALPHA TESTING] feedback + - [x] Disable in-game auth after entering 1st time + - [x] Fade in game screens + - [x] Generate new Tetromino random sequence per game turn + - [x] Improve ending UI: Add WON green badge under player name + - [x] Regression: Change "WON" badge to not block user score +- [x] Encourage players to play "best x out of y" +- [x] Disable controls when user isn't playing +- [x] Side controls on landscape mobile + - [x] Extract portrait controls out of FlatrisGame +- [x] Don't request user auth when game is full (allow guests to watch) +- [x] Add copy to clipboard btn to "Invite or play" screen + - [x] Show share button when clicking on "2P insert coin" +- [x] [BEAUTIFUL MVP] +- [x] Ensure action consistency + - [x] Create action backfill if user has old state and new actions + - [x] Create action.id, action.prevId and game.player.lastActionId + - [x] Store actions on the server + - [x] Create backfill operation +- [x] UX: Disable Auth buttons while performing IO +- [x] UX: Disable buttons while JS is loading + - [x] 2P Insert Coin in GamePanel + - [x] screens/Auth name field + - [x] screens/GameFull Watch + - [x] screens/GameOver Again + - [x] screens/GetReady Ready + - [x] screens/JoinGame Watch and Join + - [x] screens/NewGame Play and Copy + - [x] screens/WaitingForOther Ping +- [x] Add pause & end game state for solo players with invite screen +- [x] Index page + - [x] Create reduxState.games + - [x] List all games + - [x] Beautiful grid + - [x] Animating games + - [x] Strip game effects when going back to index page + - [x] Push new games to dashboard + - [x] Remove inactive games + - [x] Mark inactive after 30 seconds + - [x] Remove expired after 15 minutes + - [x] Redirect to dashboard from expired game page + - [x] Style + - [x] Style NEW GAME button + - [x] Add Flatris header + - [x] Show blank state when no active games exist + - [x] Fade in fade out transition game previews + - [x] Highlight already joined games +- [x] BUG: Broadcast new game to `global` (without requiring an action) +- [x] BUG: Reset losses when 2nd player joins +- [x] Minimize network communication: Don't send noop actions +- [x] Throttle key down events +- [x] Profile browser performance (detect unnecessary renders) +- [x] Redesign onboarding + - [x] Screen 1: Game intro + - [x] Screen 2: Multiplayer game + - [x] Screen 3: Line transferring + - [x] Screen 4: Controls +- [x] Custom 404 page +- [x] Error page (via componentDidCatch) +- [x] Add empty game shell to Dashboard blank state +- [x] Link to Github +- [x] Game footer +- [x] Disable active Tetromino movement when game over (via mobile buttons) +- [x] [1.0] + - [x] Merge to master + - [x] Rollbar server + - [x] Rollbar client + - [x] https://flatris.space +- [x] Embed Teko font in JS bundle +- [x] Record stats + - [x] Store in Firebase (users, games) + - [x] Count Turns and lines + - [x] Count actions (left, right, accelerate, rotate) + - [x] Count time +- [x] BUG: Gracefully invalidate session after re-deploy +- [x] Sync game after player disconnect +- [x] Real time stats page +- [x] [2.0] + - [x] Share on HN, PH, Reddit, etc +- [ ] Fix: Polyfill Set/Map https://reactjs.org/docs/javascript-environment-requirements.html +- [ ] Increase speed logarithmically (game currently ends too abruptly) +- [ ] "Paused" state for solo players (useful in dashboard to see if person paused or disappeared) + - [ ] How about "idle" state? +- [ ] Ask for permission to join game + - [ ] "Waiting for permission..." screen + - [ ] "Allow player to join?" screen + - [ ] "Denied" screen BACKLOG -* [ ] Back/home button in end game screen -* [ ] Allow watcher to select current player - * [ ] Show current player visually -* [ ] Don't show onboarding after every deploy -* [ ] Freeze game on player disconnect -* [ ] Create drop shadow from active Tetromino -* [ ] Draw game status -* [ ] Zoom in animation when opening game from dashboard -* [ ] Algorithm for dispatching bundled actions at time interval -* [ ] Sounds +- [ ] Back/home button in end game screen +- [ ] Allow watcher to select current player + - [ ] Show current player visually +- [ ] Don't show onboarding after every deploy +- [ ] Freeze game on player disconnect +- [ ] Create drop shadow from active Tetromino +- [ ] Draw game status +- [ ] Zoom in animation when opening game from dashboard +- [ ] Algorithm for dispatching bundled actions at time interval +- [ ] Sounds PERF -* [ ] Separate client from server (and run multiple instances of client) -* [ ] Minimize state footprint -* [ ] Batch dashboard actions +- [ ] Separate client from server (and run multiple instances of client) +- [ ] Minimize state footprint +- [ ] Batch dashboard actions CHORES -* [ ] Extract ReduxActions Cosmos proxy +- [ ] Extract ReduxActions Cosmos proxy +- [x] Upgrade to Babel7 + +Deployment + +- [ ] Change prod port to 80 diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..69a36d5e --- /dev/null +++ b/babel.config.js @@ -0,0 +1,11 @@ +const alias = { + shared: './shared' +}; + +module.exports = { + presets: [ + ['next/babel', { 'preset-env': { modules: 'commonjs' } }], + '@babel/preset-flow' + ], + plugins: [['module-resolver', { alias }]] +}; diff --git a/components/Logo.js b/components/Logo.js deleted file mode 100644 index ef5bc9df..00000000 --- a/components/Logo.js +++ /dev/null @@ -1,28 +0,0 @@ -// @flow - -import React from 'react'; -import Tetromino from './Tetromino'; -import { SHAPES } from '../constants/tetromino'; - -type Props = { - color?: string -}; - -export default ({ color = '#34495f' }: Props) => ( -
- - -
-); diff --git a/components/controls/Drop.js b/components/controls/Drop.js deleted file mode 100644 index 6333d8a1..00000000 --- a/components/controls/Drop.js +++ /dev/null @@ -1,25 +0,0 @@ -// @flow - -import React from 'react'; -import PointerButton from '../PointerButton'; - -type Props = { - onPress: Function -}; - -export default ({ onPress, ...rest }: Props) => ( - - - - - - -); diff --git a/components/controls/Left.js b/components/controls/Left.js deleted file mode 100644 index 2472d827..00000000 --- a/components/controls/Left.js +++ /dev/null @@ -1,25 +0,0 @@ -// @flow - -import React from 'react'; -import PointerButton from '../PointerButton'; - -type Props = { - onPress: Function -}; - -export default ({ onPress, ...rest }: Props) => ( - - - - - - -); diff --git a/components/controls/Right.js b/components/controls/Right.js deleted file mode 100644 index 62d4bb88..00000000 --- a/components/controls/Right.js +++ /dev/null @@ -1,25 +0,0 @@ -// @flow - -import React from 'react'; -import PointerButton from '../PointerButton'; - -type Props = { - onPress: Function -}; - -export default ({ onPress, ...rest }: Props) => ( - - - - - - -); diff --git a/components/controls/Rotate.js b/components/controls/Rotate.js deleted file mode 100644 index 89216eb2..00000000 --- a/components/controls/Rotate.js +++ /dev/null @@ -1,27 +0,0 @@ -// @flow - -import React from 'react'; -import PointerButton from '../PointerButton'; - -type Props = { - onPress: Function -}; - -export default ({ onPress, ...rest }: Props) => ( - - - - - - -); diff --git a/cosmos.test.js b/cosmos.test.js deleted file mode 100644 index 0074f980..00000000 --- a/cosmos.test.js +++ /dev/null @@ -1,3 +0,0 @@ -import runTelescope from 'react-cosmos-telescope'; - -runTelescope(); diff --git a/flow-typed/npm/express_v4.16.x.js b/flow-typed/npm/express_v4.16.x.js index fcdce777..a1e27372 100644 --- a/flow-typed/npm/express_v4.16.x.js +++ b/flow-typed/npm/express_v4.16.x.js @@ -1,7 +1,7 @@ -// flow-typed signature: aa48ae8a8a07518719f65b02f29c794b -// flow-typed version: 2846c4ef49/express_v4.16.x/flow_>=v0.32.x +// flow-typed signature: 207bac286d971cad7615b09aa20d4acf +// flow-typed version: bb849ae672/express_v4.16.x/flow_>=v0.32.x -import type { Server } from "http"; +import * as http from "http"; import type { Socket } from "net"; declare type express$RouterOptions = { @@ -21,7 +21,7 @@ declare type express$RequestParams = { declare class express$Request extends http$IncomingMessage mixins express$RequestResponseBase { baseUrl: string; - body: any; + body: mixed; cookies: { [cookie: string]: string }; connection: Socket; fresh: boolean; @@ -195,13 +195,11 @@ declare class express$Router extends express$Route { id: string ) => mixed ): void; - - // Can't use regular callable signature syntax due to https://github.com/facebook/flow/issues/3084 - $call: ( + ( req: http$IncomingMessage, res: http$ServerResponse, next?: ?express$NextFunction - ) => void; + ): void; } /* @@ -221,15 +219,15 @@ declare class express$Application extends express$Router mixins events$EventEmit hostname?: string, backlog?: number, callback?: (err?: ?Error) => mixed - ): ?Server; + ): ?http.Server; listen( port: number, hostname?: string, callback?: (err?: ?Error) => mixed - ): ?Server; - listen(port: number, callback?: (err?: ?Error) => mixed): ?Server; - listen(path: string, callback?: (err?: ?Error) => mixed): ?Server; - listen(handle: Object, callback?: (err?: ?Error) => mixed): ?Server; + ): ?http.Server; + listen(port: number, callback?: (err?: ?Error) => mixed): ?http.Server; + listen(path: string, callback?: (err?: ?Error) => mixed): ?http.Server; + listen(handle: Object, callback?: (err?: ?Error) => mixed): ?http.Server; disable(name: string): void; disabled(name: string): boolean; enable(name: string): express$Application; @@ -250,6 +248,12 @@ declare class express$Application extends express$Router mixins events$EventEmit res: http$ServerResponse, next?: ?express$NextFunction ): void; + // callable signature is not inherited + ( + req: http$IncomingMessage, + res: http$ServerResponse, + next?: ?express$NextFunction + ): void; } declare type JsonOptions = { @@ -266,6 +270,20 @@ declare type JsonOptions = { ) => mixed }; +declare type express$UrlEncodedOptions = { + extended?: boolean, + inflate?: boolean, + limit?: string | number, + parameterLimit?: number, + type?: string | Array | ((req: express$Request) => boolean), + verify?: ( + req: express$Request, + res: express$Response, + buf: Buffer, + encoding: string + ) => mixed, +} + declare module "express" { declare export type RouterOptions = express$RouterOptions; declare export type CookieOptions = express$CookieOptions; @@ -280,6 +298,7 @@ declare module "express" { (): express$Application, // If you try to call like a function, it will use this signature json: (opts: ?JsonOptions) => express$Middleware, static: (root: string, options?: Object) => express$Middleware, // `static` property on the function - Router: typeof express$Router // `Router` property on the function + Router: typeof express$Router, // `Router` property on the function + urlencoded: (opts: ?express$UrlEncodedOptions) => express$Middleware, }; } diff --git a/flow-typed/npm/jest_v22.x.x.js b/flow-typed/npm/jest_v22.x.x.js deleted file mode 100644 index 0b6d0fee..00000000 --- a/flow-typed/npm/jest_v22.x.x.js +++ /dev/null @@ -1,594 +0,0 @@ -// flow-typed signature: 18018da6c1a1d95b4ab1c64bb5fe86ca -// flow-typed version: c1ad61e7d4/jest_v22.x.x/flow_>=v0.39.x - -type JestMockFn, TReturn> = { - (...args: TArguments): TReturn, - /** - * An object for introspecting mock calls - */ - mock: { - /** - * An array that represents all calls that have been made into this mock - * function. Each call is represented by an array of arguments that were - * passed during the call. - */ - calls: Array, - /** - * An array that contains all the object instances that have been - * instantiated from this mock function. - */ - instances: Array - }, - /** - * Resets all information stored in the mockFn.mock.calls and - * mockFn.mock.instances arrays. Often this is useful when you want to clean - * up a mock's usage data between two assertions. - */ - mockClear(): void, - /** - * Resets all information stored in the mock. This is useful when you want to - * completely restore a mock back to its initial state. - */ - mockReset(): void, - /** - * Removes the mock and restores the initial implementation. This is useful - * when you want to mock functions in certain test cases and restore the - * original implementation in others. Beware that mockFn.mockRestore only - * works when mock was created with jest.spyOn. Thus you have to take care of - * restoration yourself when manually assigning jest.fn(). - */ - mockRestore(): void, - /** - * Accepts a function that should be used as the implementation of the mock. - * The mock itself will still record all calls that go into and instances - * that come from itself -- the only difference is that the implementation - * will also be executed when the mock is called. - */ - mockImplementation( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Accepts a function that will be used as an implementation of the mock for - * one call to the mocked function. Can be chained so that multiple function - * calls produce different results. - */ - mockImplementationOnce( - fn: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Just a simple sugar function for returning `this` - */ - mockReturnThis(): void, - /** - * Deprecated: use jest.fn(() => value) instead - */ - mockReturnValue(value: TReturn): JestMockFn, - /** - * Sugar for only returning a value once inside your mock - */ - mockReturnValueOnce(value: TReturn): JestMockFn -}; - -type JestAsymmetricEqualityType = { - /** - * A custom Jasmine equality tester - */ - asymmetricMatch(value: mixed): boolean -}; - -type JestCallsType = { - allArgs(): mixed, - all(): mixed, - any(): boolean, - count(): number, - first(): mixed, - mostRecent(): mixed, - reset(): void -}; - -type JestClockType = { - install(): void, - mockDate(date: Date): void, - tick(milliseconds?: number): void, - uninstall(): void -}; - -type JestMatcherResult = { - message?: string | (() => string), - pass: boolean -}; - -type JestMatcher = (actual: any, expected: any) => JestMatcherResult; - -type JestPromiseType = { - /** - * Use rejects to unwrap the reason of a rejected promise so any other - * matcher can be chained. If the promise is fulfilled the assertion fails. - */ - rejects: JestExpectType, - /** - * Use resolves to unwrap the value of a fulfilled promise so any other - * matcher can be chained. If the promise is rejected the assertion fails. - */ - resolves: JestExpectType -}; - -/** - * Jest allows functions and classes to be used as test names in test() and - * describe() - */ -type JestTestName = string | Function; - -/** - * Plugin: jest-enzyme - */ -type EnzymeMatchersType = { - toBeChecked(): void, - toBeDisabled(): void, - toBeEmpty(): void, - toBePresent(): void, - toContainReact(element: React$Element): void, - toHaveClassName(className: string): void, - toHaveHTML(html: string): void, - toHaveProp(propKey: string, propValue?: any): void, - toHaveRef(refName: string): void, - toHaveState(stateKey: string, stateValue?: any): void, - toHaveStyle(styleKey: string, styleValue?: any): void, - toHaveTagName(tagName: string): void, - toHaveText(text: string): void, - toIncludeText(text: string): void, - toHaveValue(value: any): void, - toMatchElement(element: React$Element): void, - toMatchSelector(selector: string): void -}; - -type JestExpectType = { - not: JestExpectType & EnzymeMatchersType, - /** - * If you have a mock function, you can use .lastCalledWith to test what - * arguments it was last called with. - */ - lastCalledWith(...args: Array): void, - /** - * toBe just checks that a value is what you expect. It uses === to check - * strict equality. - */ - toBe(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toBeCalled(): void, - /** - * Use .toBeCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toBeCalledWith(...args: Array): void, - /** - * Using exact equality with floating point numbers is a bad idea. Rounding - * means that intuitive things fail. - */ - toBeCloseTo(num: number, delta: any): void, - /** - * Use .toBeDefined to check that a variable is not undefined. - */ - toBeDefined(): void, - /** - * Use .toBeFalsy when you don't care what a value is, you just want to - * ensure a value is false in a boolean context. - */ - toBeFalsy(): void, - /** - * To compare floating point numbers, you can use toBeGreaterThan. - */ - toBeGreaterThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeGreaterThanOrEqual. - */ - toBeGreaterThanOrEqual(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThan. - */ - toBeLessThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThanOrEqual. - */ - toBeLessThanOrEqual(number: number): void, - /** - * Use .toBeInstanceOf(Class) to check that an object is an instance of a - * class. - */ - toBeInstanceOf(cls: Class<*>): void, - /** - * .toBeNull() is the same as .toBe(null) but the error messages are a bit - * nicer. - */ - toBeNull(): void, - /** - * Use .toBeTruthy when you don't care what a value is, you just want to - * ensure a value is true in a boolean context. - */ - toBeTruthy(): void, - /** - * Use .toBeUndefined to check that a variable is undefined. - */ - toBeUndefined(): void, - /** - * Use .toContain when you want to check that an item is in a list. For - * testing the items in the list, this uses ===, a strict equality check. - */ - toContain(item: any): void, - /** - * Use .toContainEqual when you want to check that an item is in a list. For - * testing the items in the list, this matcher recursively checks the - * equality of all fields, rather than checking for object identity. - */ - toContainEqual(item: any): void, - /** - * Use .toEqual when you want to check that two objects have the same value. - * This matcher recursively checks the equality of all fields, rather than - * checking for object identity. - */ - toEqual(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toHaveBeenCalled(): void, - /** - * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact - * number of times. - */ - toHaveBeenCalledTimes(number: number): void, - /** - * Use .toHaveBeenCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toHaveBeenCalledWith(...args: Array): void, - /** - * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called - * with specific arguments. - */ - toHaveBeenLastCalledWith(...args: Array): void, - /** - * Check that an object has a .length property and it is set to a certain - * numeric value. - */ - toHaveLength(number: number): void, - /** - * - */ - toHaveProperty(propPath: string, value?: any): void, - /** - * Use .toMatch to check that a string matches a regular expression or string. - */ - toMatch(regexpOrString: RegExp | string): void, - /** - * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. - */ - toMatchObject(object: Object | Array): void, - /** - * This ensures that a React component matches the most recent snapshot. - */ - toMatchSnapshot(name?: string): void, - /** - * Use .toThrow to test that a function throws when it is called. - * If you want to test that a specific error gets thrown, you can provide an - * argument to toThrow. The argument can be a string for the error message, - * a class for the error, or a regex that should match the error. - * - * Alias: .toThrowError - */ - toThrow(message?: string | Error | Class | RegExp): void, - toThrowError(message?: string | Error | Class | RegExp): void, - /** - * Use .toThrowErrorMatchingSnapshot to test that a function throws a error - * matching the most recent snapshot when it is called. - */ - toThrowErrorMatchingSnapshot(): void -}; - -type JestObjectType = { - /** - * Disables automatic mocking in the module loader. - * - * After this method is called, all `require()`s will return the real - * versions of each module (rather than a mocked version). - */ - disableAutomock(): JestObjectType, - /** - * An un-hoisted version of disableAutomock - */ - autoMockOff(): JestObjectType, - /** - * Enables automatic mocking in the module loader. - */ - enableAutomock(): JestObjectType, - /** - * An un-hoisted version of enableAutomock - */ - autoMockOn(): JestObjectType, - /** - * Clears the mock.calls and mock.instances properties of all mocks. - * Equivalent to calling .mockClear() on every mocked function. - */ - clearAllMocks(): JestObjectType, - /** - * Resets the state of all mocks. Equivalent to calling .mockReset() on every - * mocked function. - */ - resetAllMocks(): JestObjectType, - /** - * Restores all mocks back to their original value. - */ - restoreAllMocks(): JestObjectType, - /** - * Removes any pending timers from the timer system. - */ - clearAllTimers(): void, - /** - * The same as `mock` but not moved to the top of the expectation by - * babel-jest. - */ - doMock(moduleName: string, moduleFactory?: any): JestObjectType, - /** - * The same as `unmock` but not moved to the top of the expectation by - * babel-jest. - */ - dontMock(moduleName: string): JestObjectType, - /** - * Returns a new, unused mock function. Optionally takes a mock - * implementation. - */ - fn, TReturn>( - implementation?: (...args: TArguments) => TReturn - ): JestMockFn, - /** - * Determines if the given function is a mocked function. - */ - isMockFunction(fn: Function): boolean, - /** - * Given the name of a module, use the automatic mocking system to generate a - * mocked version of the module for you. - */ - genMockFromModule(moduleName: string): any, - /** - * Mocks a module with an auto-mocked version when it is being required. - * - * The second argument can be used to specify an explicit module factory that - * is being run instead of using Jest's automocking feature. - * - * The third argument can be used to create virtual mocks -- mocks of modules - * that don't exist anywhere in the system. - */ - mock( - moduleName: string, - moduleFactory?: any, - options?: Object - ): JestObjectType, - /** - * Returns the actual module instead of a mock, bypassing all checks on - * whether the module should receive a mock implementation or not. - */ - requireActual(moduleName: string): any, - /** - * Returns a mock module instead of the actual module, bypassing all checks - * on whether the module should be required normally or not. - */ - requireMock(moduleName: string): any, - /** - * Resets the module registry - the cache of all required modules. This is - * useful to isolate modules where local state might conflict between tests. - */ - resetModules(): JestObjectType, - /** - * Exhausts the micro-task queue (usually interfaced in node via - * process.nextTick). - */ - runAllTicks(): void, - /** - * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), - * setInterval(), and setImmediate()). - */ - runAllTimers(): void, - /** - * Exhausts all tasks queued by setImmediate(). - */ - runAllImmediates(): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - */ - runTimersToTime(msToRun: number): void, - /** - * Executes only the macro-tasks that are currently pending (i.e., only the - * tasks that have been queued by setTimeout() or setInterval() up to this - * point) - */ - runOnlyPendingTimers(): void, - /** - * Explicitly supplies the mock object that the module system should return - * for the specified module. Note: It is recommended to use jest.mock() - * instead. - */ - setMock(moduleName: string, moduleExports: any): JestObjectType, - /** - * Indicates that the module system should never return a mocked version of - * the specified module from require() (e.g. that it should always return the - * real module). - */ - unmock(moduleName: string): JestObjectType, - /** - * Instructs Jest to use fake versions of the standard timer functions - * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, - * setImmediate and clearImmediate). - */ - useFakeTimers(): JestObjectType, - /** - * Instructs Jest to use the real versions of the standard timer functions. - */ - useRealTimers(): JestObjectType, - /** - * Creates a mock function similar to jest.fn but also tracks calls to - * object[methodName]. - */ - spyOn(object: Object, methodName: string): JestMockFn, - /** - * Set the default timeout interval for tests and before/after hooks in milliseconds. - * Note: The default timeout interval is 5 seconds if this method is not called. - */ - setTimeout(timeout: number): JestObjectType -}; - -type JestSpyType = { - calls: JestCallsType -}; - -/** Runs this function after every test inside this context */ -declare function afterEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before every test inside this context */ -declare function beforeEach( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function after all tests have finished inside this context */ -declare function afterAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** Runs this function before any tests have started inside this context */ -declare function beforeAll( - fn: (done: () => void) => ?Promise, - timeout?: number -): void; - -/** A context for grouping tests together */ -declare var describe: { - /** - * Creates a block that groups together several related tests in one "test suite" - */ - (name: JestTestName, fn: () => void): void, - - /** - * Only run this describe block - */ - only(name: JestTestName, fn: () => void): void, - - /** - * Skip running this describe block - */ - skip(name: JestTestName, fn: () => void): void -}; - -/** An individual test unit */ -declare var it: { - /** - * An individual test unit - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - ( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * Only run this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - only( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * Skip running this test - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - skip( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void, - /** - * Run the test concurrently - * - * @param {JestTestName} Name of Test - * @param {Function} Test - * @param {number} Timeout for the test, in milliseconds. - */ - concurrent( - name: JestTestName, - fn?: (done: () => void) => ?Promise, - timeout?: number - ): void -}; -declare function fit( - name: JestTestName, - fn: (done: () => void) => ?Promise, - timeout?: number -): void; -/** An individual test unit */ -declare var test: typeof it; -/** A disabled group of tests */ -declare var xdescribe: typeof describe; -/** A focused group of tests */ -declare var fdescribe: typeof describe; -/** A disabled individual test */ -declare var xit: typeof it; -/** A disabled individual test */ -declare var xtest: typeof it; - -/** The expect function is used every time you want to test a value */ -declare var expect: { - /** The object that you want to make assertions against */ - (value: any): JestExpectType & JestPromiseType & EnzymeMatchersType, - /** Add additional Jasmine matchers to Jest's roster */ - extend(matchers: { [name: string]: JestMatcher }): void, - /** Add a module that formats application-specific data structures. */ - addSnapshotSerializer(serializer: (input: Object) => string): void, - assertions(expectedAssertions: number): void, - hasAssertions(): void, - any(value: mixed): JestAsymmetricEqualityType, - anything(): void, - arrayContaining(value: Array): void, - objectContaining(value: Object): void, - /** Matches any received string that contains the exact expected string. */ - stringContaining(value: string): void, - stringMatching(value: string | RegExp): void -}; - -// TODO handle return type -// http://jasmine.github.io/2.4/introduction.html#section-Spies -declare function spyOn(value: mixed, method: string): Object; - -/** Holds all functions related to manipulating test runner */ -declare var jest: JestObjectType; - -/** - * The global Jasmine object, this is generally not exposed as the public API, - * using features inside here could break in later versions of Jest. - */ -declare var jasmine: { - DEFAULT_TIMEOUT_INTERVAL: number, - any(value: mixed): JestAsymmetricEqualityType, - anything(): void, - arrayContaining(value: Array): void, - clock(): JestClockType, - createSpy(name: string): JestSpyType, - createSpyObj( - baseName: string, - methodNames: Array - ): { [methodName: string]: JestSpyType }, - objectContaining(value: Object): void, - stringMatching(value: string): void -}; diff --git a/flow-typed/npm/jest_v23.x.x.js b/flow-typed/npm/jest_v23.x.x.js new file mode 100644 index 00000000..95835f5f --- /dev/null +++ b/flow-typed/npm/jest_v23.x.x.js @@ -0,0 +1,1155 @@ +// flow-typed signature: 78c200acffbcc16bba9478f5396c3a00 +// flow-typed version: b2980740dd/jest_v23.x.x/flow_>=v0.39.x + +type JestMockFn, TReturn> = { + (...args: TArguments): TReturn, + /** + * An object for introspecting mock calls + */ + mock: { + /** + * An array that represents all calls that have been made into this mock + * function. Each call is represented by an array of arguments that were + * passed during the call. + */ + calls: Array, + /** + * An array that contains all the object instances that have been + * instantiated from this mock function. + */ + instances: Array, + /** + * An array that contains all the object results that have been + * returned by this mock function call + */ + results: Array<{ isThrow: boolean, value: TReturn }> + }, + /** + * Resets all information stored in the mockFn.mock.calls and + * mockFn.mock.instances arrays. Often this is useful when you want to clean + * up a mock's usage data between two assertions. + */ + mockClear(): void, + /** + * Resets all information stored in the mock. This is useful when you want to + * completely restore a mock back to its initial state. + */ + mockReset(): void, + /** + * Removes the mock and restores the initial implementation. This is useful + * when you want to mock functions in certain test cases and restore the + * original implementation in others. Beware that mockFn.mockRestore only + * works when mock was created with jest.spyOn. Thus you have to take care of + * restoration yourself when manually assigning jest.fn(). + */ + mockRestore(): void, + /** + * Accepts a function that should be used as the implementation of the mock. + * The mock itself will still record all calls that go into and instances + * that come from itself -- the only difference is that the implementation + * will also be executed when the mock is called. + */ + mockImplementation( + fn: (...args: TArguments) => TReturn + ): JestMockFn, + /** + * Accepts a function that will be used as an implementation of the mock for + * one call to the mocked function. Can be chained so that multiple function + * calls produce different results. + */ + mockImplementationOnce( + fn: (...args: TArguments) => TReturn + ): JestMockFn, + /** + * Accepts a string to use in test result output in place of "jest.fn()" to + * indicate which mock function is being referenced. + */ + mockName(name: string): JestMockFn, + /** + * Just a simple sugar function for returning `this` + */ + mockReturnThis(): void, + /** + * Accepts a value that will be returned whenever the mock function is called. + */ + mockReturnValue(value: TReturn): JestMockFn, + /** + * Sugar for only returning a value once inside your mock + */ + mockReturnValueOnce(value: TReturn): JestMockFn, + /** + * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) + */ + mockResolvedValue(value: TReturn): JestMockFn>, + /** + * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) + */ + mockResolvedValueOnce(value: TReturn): JestMockFn>, + /** + * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) + */ + mockRejectedValue(value: TReturn): JestMockFn>, + /** + * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) + */ + mockRejectedValueOnce(value: TReturn): JestMockFn> +}; + +type JestAsymmetricEqualityType = { + /** + * A custom Jasmine equality tester + */ + asymmetricMatch(value: mixed): boolean +}; + +type JestCallsType = { + allArgs(): mixed, + all(): mixed, + any(): boolean, + count(): number, + first(): mixed, + mostRecent(): mixed, + reset(): void +}; + +type JestClockType = { + install(): void, + mockDate(date: Date): void, + tick(milliseconds?: number): void, + uninstall(): void +}; + +type JestMatcherResult = { + message?: string | (() => string), + pass: boolean +}; + +type JestMatcher = (actual: any, expected: any) => + | JestMatcherResult + | Promise; + +type JestPromiseType = { + /** + * Use rejects to unwrap the reason of a rejected promise so any other + * matcher can be chained. If the promise is fulfilled the assertion fails. + */ + rejects: JestExpectType, + /** + * Use resolves to unwrap the value of a fulfilled promise so any other + * matcher can be chained. If the promise is rejected the assertion fails. + */ + resolves: JestExpectType +}; + +/** + * Jest allows functions and classes to be used as test names in test() and + * describe() + */ +type JestTestName = string | Function; + +/** + * Plugin: jest-styled-components + */ + +type JestStyledComponentsMatcherValue = + | string + | JestAsymmetricEqualityType + | RegExp + | typeof undefined; + +type JestStyledComponentsMatcherOptions = { + media?: string; + modifier?: string; + supports?: string; +} + +type JestStyledComponentsMatchersType = { + toHaveStyleRule( + property: string, + value: JestStyledComponentsMatcherValue, + options?: JestStyledComponentsMatcherOptions + ): void, +}; + +/** + * Plugin: jest-enzyme + */ +type EnzymeMatchersType = { + // 5.x + toBeEmpty(): void, + toBePresent(): void, + // 6.x + toBeChecked(): void, + toBeDisabled(): void, + toBeEmptyRender(): void, + toContainMatchingElement(selector: string): void; + toContainMatchingElements(n: number, selector: string): void; + toContainExactlyOneMatchingElement(selector: string): void; + toContainReact(element: React$Element): void, + toExist(): void, + toHaveClassName(className: string): void, + toHaveHTML(html: string): void, + toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), + toHaveRef(refName: string): void, + toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), + toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), + toHaveTagName(tagName: string): void, + toHaveText(text: string): void, + toHaveValue(value: any): void, + toIncludeText(text: string): void, + toMatchElement( + element: React$Element, + options?: {| ignoreProps?: boolean, verbose?: boolean |}, + ): void, + toMatchSelector(selector: string): void, + // 7.x + toHaveDisplayName(name: string): void, +}; + +// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers +type DomTestingLibraryType = { + toBeDisabled(): void, + toBeEmpty(): void, + toBeInTheDocument(): void, + toBeVisible(): void, + toContainElement(element: HTMLElement | null): void, + toContainHTML(htmlText: string): void, + toHaveAttribute(name: string, expectedValue?: string): void, + toHaveClass(...classNames: string[]): void, + toHaveFocus(): void, + toHaveFormValues(expectedValues: { [name: string]: any }): void, + toHaveStyle(css: string): void, + toHaveTextContent(content: string | RegExp, options?: { normalizeWhitespace: boolean }): void, + toBeInTheDOM(): void, +}; + +// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers +type JestJQueryMatchersType = { + toExist(): void, + toHaveLength(len: number): void, + toHaveId(id: string): void, + toHaveClass(className: string): void, + toHaveTag(tag: string): void, + toHaveAttr(key: string, val?: any): void, + toHaveProp(key: string, val?: any): void, + toHaveText(text: string | RegExp): void, + toHaveData(key: string, val?: any): void, + toHaveValue(val: any): void, + toHaveCss(css: {[key: string]: any}): void, + toBeChecked(): void, + toBeDisabled(): void, + toBeEmpty(): void, + toBeHidden(): void, + toBeSelected(): void, + toBeVisible(): void, + toBeFocused(): void, + toBeInDom(): void, + toBeMatchedBy(sel: string): void, + toHaveDescendant(sel: string): void, + toHaveDescendantWithText(sel: string, text: string | RegExp): void +}; + + +// Jest Extended Matchers: https://github.com/jest-community/jest-extended +type JestExtendedMatchersType = { + /** + * Note: Currently unimplemented + * Passing assertion + * + * @param {String} message + */ + // pass(message: string): void; + + /** + * Note: Currently unimplemented + * Failing assertion + * + * @param {String} message + */ + // fail(message: string): void; + + /** + * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. + */ + toBeEmpty(): void; + + /** + * Use .toBeOneOf when checking if a value is a member of a given Array. + * @param {Array.<*>} members + */ + toBeOneOf(members: any[]): void; + + /** + * Use `.toBeNil` when checking a value is `null` or `undefined`. + */ + toBeNil(): void; + + /** + * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. + * @param {Function} predicate + */ + toSatisfy(predicate: (n: any) => boolean): void; + + /** + * Use `.toBeArray` when checking if a value is an `Array`. + */ + toBeArray(): void; + + /** + * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. + * @param {Number} x + */ + toBeArrayOfSize(x: number): void; + + /** + * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. + * @param {Array.<*>} members + */ + toIncludeAllMembers(members: any[]): void; + + /** + * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. + * @param {Array.<*>} members + */ + toIncludeAnyMembers(members: any[]): void; + + /** + * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. + * @param {Function} predicate + */ + toSatisfyAll(predicate: (n: any) => boolean): void; + + /** + * Use `.toBeBoolean` when checking if a value is a `Boolean`. + */ + toBeBoolean(): void; + + /** + * Use `.toBeTrue` when checking a value is equal (===) to `true`. + */ + toBeTrue(): void; + + /** + * Use `.toBeFalse` when checking a value is equal (===) to `false`. + */ + toBeFalse(): void; + + /** + * Use .toBeDate when checking if a value is a Date. + */ + toBeDate(): void; + + /** + * Use `.toBeFunction` when checking if a value is a `Function`. + */ + toBeFunction(): void; + + /** + * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. + * + * Note: Required Jest version >22 + * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same + * + * @param {Mock} mock + */ + toHaveBeenCalledBefore(mock: JestMockFn): void; + + /** + * Use `.toBeNumber` when checking if a value is a `Number`. + */ + toBeNumber(): void; + + /** + * Use `.toBeNaN` when checking a value is `NaN`. + */ + toBeNaN(): void; + + /** + * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. + */ + toBeFinite(): void; + + /** + * Use `.toBePositive` when checking if a value is a positive `Number`. + */ + toBePositive(): void; + + /** + * Use `.toBeNegative` when checking if a value is a negative `Number`. + */ + toBeNegative(): void; + + /** + * Use `.toBeEven` when checking if a value is an even `Number`. + */ + toBeEven(): void; + + /** + * Use `.toBeOdd` when checking if a value is an odd `Number`. + */ + toBeOdd(): void; + + /** + * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). + * + * @param {Number} start + * @param {Number} end + */ + toBeWithin(start: number, end: number): void; + + /** + * Use `.toBeObject` when checking if a value is an `Object`. + */ + toBeObject(): void; + + /** + * Use `.toContainKey` when checking if an object contains the provided key. + * + * @param {String} key + */ + toContainKey(key: string): void; + + /** + * Use `.toContainKeys` when checking if an object has all of the provided keys. + * + * @param {Array.} keys + */ + toContainKeys(keys: string[]): void; + + /** + * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. + * + * @param {Array.} keys + */ + toContainAllKeys(keys: string[]): void; + + /** + * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. + * + * @param {Array.} keys + */ + toContainAnyKeys(keys: string[]): void; + + /** + * Use `.toContainValue` when checking if an object contains the provided value. + * + * @param {*} value + */ + toContainValue(value: any): void; + + /** + * Use `.toContainValues` when checking if an object contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainValues(values: any[]): void; + + /** + * Use `.toContainAllValues` when checking if an object only contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainAllValues(values: any[]): void; + + /** + * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. + * + * @param {Array.<*>} values + */ + toContainAnyValues(values: any[]): void; + + /** + * Use `.toContainEntry` when checking if an object contains the provided entry. + * + * @param {Array.} entry + */ + toContainEntry(entry: [string, string]): void; + + /** + * Use `.toContainEntries` when checking if an object contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainEntries(entries: [string, string][]): void; + + /** + * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainAllEntries(entries: [string, string][]): void; + + /** + * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. + * + * @param {Array.>} entries + */ + toContainAnyEntries(entries: [string, string][]): void; + + /** + * Use `.toBeExtensible` when checking if an object is extensible. + */ + toBeExtensible(): void; + + /** + * Use `.toBeFrozen` when checking if an object is frozen. + */ + toBeFrozen(): void; + + /** + * Use `.toBeSealed` when checking if an object is sealed. + */ + toBeSealed(): void; + + /** + * Use `.toBeString` when checking if a value is a `String`. + */ + toBeString(): void; + + /** + * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. + * + * @param {String} string + */ + toEqualCaseInsensitive(string: string): void; + + /** + * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. + * + * @param {String} prefix + */ + toStartWith(prefix: string): void; + + /** + * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. + * + * @param {String} suffix + */ + toEndWith(suffix: string): void; + + /** + * Use `.toInclude` when checking if a `String` includes the given `String` substring. + * + * @param {String} substring + */ + toInclude(substring: string): void; + + /** + * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. + * + * @param {String} substring + * @param {Number} times + */ + toIncludeRepeated(substring: string, times: number): void; + + /** + * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. + * + * @param {Array.} substring + */ + toIncludeMultiple(substring: string[]): void; +}; + +interface JestExpectType { + not: + & JestExpectType + & EnzymeMatchersType + & DomTestingLibraryType + & JestJQueryMatchersType + & JestStyledComponentsMatchersType + & JestExtendedMatchersType, + /** + * If you have a mock function, you can use .lastCalledWith to test what + * arguments it was last called with. + */ + lastCalledWith(...args: Array): void, + /** + * toBe just checks that a value is what you expect. It uses === to check + * strict equality. + */ + toBe(value: any): void, + /** + * Use .toBeCalledWith to ensure that a mock function was called with + * specific arguments. + */ + toBeCalledWith(...args: Array): void, + /** + * Using exact equality with floating point numbers is a bad idea. Rounding + * means that intuitive things fail. + */ + toBeCloseTo(num: number, delta: any): void, + /** + * Use .toBeDefined to check that a variable is not undefined. + */ + toBeDefined(): void, + /** + * Use .toBeFalsy when you don't care what a value is, you just want to + * ensure a value is false in a boolean context. + */ + toBeFalsy(): void, + /** + * To compare floating point numbers, you can use toBeGreaterThan. + */ + toBeGreaterThan(number: number): void, + /** + * To compare floating point numbers, you can use toBeGreaterThanOrEqual. + */ + toBeGreaterThanOrEqual(number: number): void, + /** + * To compare floating point numbers, you can use toBeLessThan. + */ + toBeLessThan(number: number): void, + /** + * To compare floating point numbers, you can use toBeLessThanOrEqual. + */ + toBeLessThanOrEqual(number: number): void, + /** + * Use .toBeInstanceOf(Class) to check that an object is an instance of a + * class. + */ + toBeInstanceOf(cls: Class<*>): void, + /** + * .toBeNull() is the same as .toBe(null) but the error messages are a bit + * nicer. + */ + toBeNull(): void, + /** + * Use .toBeTruthy when you don't care what a value is, you just want to + * ensure a value is true in a boolean context. + */ + toBeTruthy(): void, + /** + * Use .toBeUndefined to check that a variable is undefined. + */ + toBeUndefined(): void, + /** + * Use .toContain when you want to check that an item is in a list. For + * testing the items in the list, this uses ===, a strict equality check. + */ + toContain(item: any): void, + /** + * Use .toContainEqual when you want to check that an item is in a list. For + * testing the items in the list, this matcher recursively checks the + * equality of all fields, rather than checking for object identity. + */ + toContainEqual(item: any): void, + /** + * Use .toEqual when you want to check that two objects have the same value. + * This matcher recursively checks the equality of all fields, rather than + * checking for object identity. + */ + toEqual(value: any): void, + /** + * Use .toHaveBeenCalled to ensure that a mock function got called. + */ + toHaveBeenCalled(): void, + toBeCalled(): void; + /** + * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact + * number of times. + */ + toHaveBeenCalledTimes(number: number): void, + toBeCalledTimes(number: number): void; + /** + * + */ + toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; + nthCalledWith(nthCall: number, ...args: Array): void; + /** + * + */ + toHaveReturned(): void; + toReturn(): void; + /** + * + */ + toHaveReturnedTimes(number: number): void; + toReturnTimes(number: number): void; + /** + * + */ + toHaveReturnedWith(value: any): void; + toReturnWith(value: any): void; + /** + * + */ + toHaveLastReturnedWith(value: any): void; + lastReturnedWith(value: any): void; + /** + * + */ + toHaveNthReturnedWith(nthCall: number, value: any): void; + nthReturnedWith(nthCall: number, value: any): void; + /** + * Use .toHaveBeenCalledWith to ensure that a mock function was called with + * specific arguments. + */ + toHaveBeenCalledWith(...args: Array): void, + toBeCalledWith(...args: Array): void, + /** + * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called + * with specific arguments. + */ + toHaveBeenLastCalledWith(...args: Array): void, + lastCalledWith(...args: Array): void, + /** + * Check that an object has a .length property and it is set to a certain + * numeric value. + */ + toHaveLength(number: number): void, + /** + * + */ + toHaveProperty(propPath: string, value?: any): void, + /** + * Use .toMatch to check that a string matches a regular expression or string. + */ + toMatch(regexpOrString: RegExp | string): void, + /** + * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. + */ + toMatchObject(object: Object | Array): void, + /** + * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. + */ + toStrictEqual(value: any): void, + /** + * This ensures that an Object matches the most recent snapshot. + */ + toMatchSnapshot(propertyMatchers?: any, name?: string): void, + /** + * This ensures that an Object matches the most recent snapshot. + */ + toMatchSnapshot(name: string): void, + + toMatchInlineSnapshot(snapshot?: string): void, + toMatchInlineSnapshot(propertyMatchers?: any, snapshot?: string): void, + /** + * Use .toThrow to test that a function throws when it is called. + * If you want to test that a specific error gets thrown, you can provide an + * argument to toThrow. The argument can be a string for the error message, + * a class for the error, or a regex that should match the error. + * + * Alias: .toThrowError + */ + toThrow(message?: string | Error | Class | RegExp): void, + toThrowError(message?: string | Error | Class | RegExp): void, + /** + * Use .toThrowErrorMatchingSnapshot to test that a function throws a error + * matching the most recent snapshot when it is called. + */ + toThrowErrorMatchingSnapshot(): void, + toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, +} + +type JestObjectType = { + /** + * Disables automatic mocking in the module loader. + * + * After this method is called, all `require()`s will return the real + * versions of each module (rather than a mocked version). + */ + disableAutomock(): JestObjectType, + /** + * An un-hoisted version of disableAutomock + */ + autoMockOff(): JestObjectType, + /** + * Enables automatic mocking in the module loader. + */ + enableAutomock(): JestObjectType, + /** + * An un-hoisted version of enableAutomock + */ + autoMockOn(): JestObjectType, + /** + * Clears the mock.calls and mock.instances properties of all mocks. + * Equivalent to calling .mockClear() on every mocked function. + */ + clearAllMocks(): JestObjectType, + /** + * Resets the state of all mocks. Equivalent to calling .mockReset() on every + * mocked function. + */ + resetAllMocks(): JestObjectType, + /** + * Restores all mocks back to their original value. + */ + restoreAllMocks(): JestObjectType, + /** + * Removes any pending timers from the timer system. + */ + clearAllTimers(): void, + /** + * The same as `mock` but not moved to the top of the expectation by + * babel-jest. + */ + doMock(moduleName: string, moduleFactory?: any): JestObjectType, + /** + * The same as `unmock` but not moved to the top of the expectation by + * babel-jest. + */ + dontMock(moduleName: string): JestObjectType, + /** + * Returns a new, unused mock function. Optionally takes a mock + * implementation. + */ + fn, TReturn>( + implementation?: (...args: TArguments) => TReturn + ): JestMockFn, + /** + * Determines if the given function is a mocked function. + */ + isMockFunction(fn: Function): boolean, + /** + * Given the name of a module, use the automatic mocking system to generate a + * mocked version of the module for you. + */ + genMockFromModule(moduleName: string): any, + /** + * Mocks a module with an auto-mocked version when it is being required. + * + * The second argument can be used to specify an explicit module factory that + * is being run instead of using Jest's automocking feature. + * + * The third argument can be used to create virtual mocks -- mocks of modules + * that don't exist anywhere in the system. + */ + mock( + moduleName: string, + moduleFactory?: any, + options?: Object + ): JestObjectType, + /** + * Returns the actual module instead of a mock, bypassing all checks on + * whether the module should receive a mock implementation or not. + */ + requireActual(moduleName: string): any, + /** + * Returns a mock module instead of the actual module, bypassing all checks + * on whether the module should be required normally or not. + */ + requireMock(moduleName: string): any, + /** + * Resets the module registry - the cache of all required modules. This is + * useful to isolate modules where local state might conflict between tests. + */ + resetModules(): JestObjectType, + /** + * Exhausts the micro-task queue (usually interfaced in node via + * process.nextTick). + */ + runAllTicks(): void, + /** + * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), + * setInterval(), and setImmediate()). + */ + runAllTimers(): void, + /** + * Exhausts all tasks queued by setImmediate(). + */ + runAllImmediates(): void, + /** + * Executes only the macro task queue (i.e. all tasks queued by setTimeout() + * or setInterval() and setImmediate()). + */ + advanceTimersByTime(msToRun: number): void, + /** + * Executes only the macro task queue (i.e. all tasks queued by setTimeout() + * or setInterval() and setImmediate()). + * + * Renamed to `advanceTimersByTime`. + */ + runTimersToTime(msToRun: number): void, + /** + * Executes only the macro-tasks that are currently pending (i.e., only the + * tasks that have been queued by setTimeout() or setInterval() up to this + * point) + */ + runOnlyPendingTimers(): void, + /** + * Explicitly supplies the mock object that the module system should return + * for the specified module. Note: It is recommended to use jest.mock() + * instead. + */ + setMock(moduleName: string, moduleExports: any): JestObjectType, + /** + * Indicates that the module system should never return a mocked version of + * the specified module from require() (e.g. that it should always return the + * real module). + */ + unmock(moduleName: string): JestObjectType, + /** + * Instructs Jest to use fake versions of the standard timer functions + * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, + * setImmediate and clearImmediate). + */ + useFakeTimers(): JestObjectType, + /** + * Instructs Jest to use the real versions of the standard timer functions. + */ + useRealTimers(): JestObjectType, + /** + * Creates a mock function similar to jest.fn but also tracks calls to + * object[methodName]. + */ + spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, + /** + * Set the default timeout interval for tests and before/after hooks in milliseconds. + * Note: The default timeout interval is 5 seconds if this method is not called. + */ + setTimeout(timeout: number): JestObjectType +}; + +type JestSpyType = { + calls: JestCallsType +}; + +/** Runs this function after every test inside this context */ +declare function afterEach( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** Runs this function before every test inside this context */ +declare function beforeEach( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** Runs this function after all tests have finished inside this context */ +declare function afterAll( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** Runs this function before any tests have started inside this context */ +declare function beforeAll( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; + +/** A context for grouping tests together */ +declare var describe: { + /** + * Creates a block that groups together several related tests in one "test suite" + */ + (name: JestTestName, fn: () => void): void, + + /** + * Only run this describe block + */ + only(name: JestTestName, fn: () => void): void, + + /** + * Skip running this describe block + */ + skip(name: JestTestName, fn: () => void): void, + + /** + * each runs this test against array of argument arrays per each run + * + * @param {table} table of Test + */ + each( + ...table: Array | mixed> | [Array, string] + ): ( + name: JestTestName, + fn?: (...args: Array) => ?Promise, + timeout?: number + ) => void, +}; + +/** An individual test unit */ +declare var it: { + /** + * An individual test unit + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + ( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): void, + + /** + * Only run this test + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + only( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): { + each( + ...table: Array | mixed> | [Array, string] + ): ( + name: JestTestName, + fn?: (...args: Array) => ?Promise, + timeout?: number + ) => void, + }, + + /** + * Skip running this test + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + skip( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): void, + + /** + * Run the test concurrently + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + concurrent( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): void, + + /** + * each runs this test against array of argument arrays per each run + * + * @param {table} table of Test + */ + each( + ...table: Array | mixed> | [Array, string] + ): ( + name: JestTestName, + fn?: (...args: Array) => ?Promise, + timeout?: number + ) => void, +}; + +declare function fit( + name: JestTestName, + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** An individual test unit */ +declare var test: typeof it; +/** A disabled group of tests */ +declare var xdescribe: typeof describe; +/** A focused group of tests */ +declare var fdescribe: typeof describe; +/** A disabled individual test */ +declare var xit: typeof it; +/** A disabled individual test */ +declare var xtest: typeof it; + +type JestPrettyFormatColors = { + comment: { close: string, open: string }, + content: { close: string, open: string }, + prop: { close: string, open: string }, + tag: { close: string, open: string }, + value: { close: string, open: string }, +}; + +type JestPrettyFormatIndent = string => string; +type JestPrettyFormatRefs = Array; +type JestPrettyFormatPrint = any => string; +type JestPrettyFormatStringOrNull = string | null; + +type JestPrettyFormatOptions = {| + callToJSON: boolean, + edgeSpacing: string, + escapeRegex: boolean, + highlight: boolean, + indent: number, + maxDepth: number, + min: boolean, + plugins: JestPrettyFormatPlugins, + printFunctionName: boolean, + spacing: string, + theme: {| + comment: string, + content: string, + prop: string, + tag: string, + value: string, + |}, +|}; + +type JestPrettyFormatPlugin = { + print: ( + val: any, + serialize: JestPrettyFormatPrint, + indent: JestPrettyFormatIndent, + opts: JestPrettyFormatOptions, + colors: JestPrettyFormatColors, + ) => string, + test: any => boolean, +}; + +type JestPrettyFormatPlugins = Array; + +/** The expect function is used every time you want to test a value */ +declare var expect: { + /** The object that you want to make assertions against */ + (value: any): + & JestExpectType + & JestPromiseType + & EnzymeMatchersType + & DomTestingLibraryType + & JestJQueryMatchersType + & JestStyledComponentsMatchersType + & JestExtendedMatchersType, + + /** Add additional Jasmine matchers to Jest's roster */ + extend(matchers: { [name: string]: JestMatcher }): void, + /** Add a module that formats application-specific data structures. */ + addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, + assertions(expectedAssertions: number): void, + hasAssertions(): void, + any(value: mixed): JestAsymmetricEqualityType, + anything(): any, + arrayContaining(value: Array): Array, + objectContaining(value: Object): Object, + /** Matches any received string that contains the exact expected string. */ + stringContaining(value: string): string, + stringMatching(value: string | RegExp): string, + not: { + arrayContaining: (value: $ReadOnlyArray) => Array, + objectContaining: (value: {}) => Object, + stringContaining: (value: string) => string, + stringMatching: (value: string | RegExp) => string, + }, +}; + +// TODO handle return type +// http://jasmine.github.io/2.4/introduction.html#section-Spies +declare function spyOn(value: mixed, method: string): Object; + +/** Holds all functions related to manipulating test runner */ +declare var jest: JestObjectType; + +/** + * The global Jasmine object, this is generally not exposed as the public API, + * using features inside here could break in later versions of Jest. + */ +declare var jasmine: { + DEFAULT_TIMEOUT_INTERVAL: number, + any(value: mixed): JestAsymmetricEqualityType, + anything(): any, + arrayContaining(value: Array): Array, + clock(): JestClockType, + createSpy(name: string): JestSpyType, + createSpyObj( + baseName: string, + methodNames: Array + ): { [methodName: string]: JestSpyType }, + objectContaining(value: Object): Object, + stringMatching(value: string): string +}; diff --git a/flow-typed/npm/redux_v3.x.x.js b/flow-typed/npm/redux_v4.x.x.js similarity index 88% rename from flow-typed/npm/redux_v3.x.x.js rename to flow-typed/npm/redux_v4.x.x.js index 2ca868c0..d7a909d5 100644 --- a/flow-typed/npm/redux_v3.x.x.js +++ b/flow-typed/npm/redux_v4.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: ec7daead5cb4fec5ab25fedbedef29e8 -// flow-typed version: 2c04631d20/redux_v3.x.x/flow_>=v0.55.x +// flow-typed signature: df80bdd535bfed9cf3223e077f3b4543 +// flow-typed version: c4c8963c9c/redux_v4.x.x/flow_>=v0.55.x declare module 'redux' { @@ -27,7 +27,7 @@ declare module 'redux' { replaceReducer(nextReducer: Reducer): void }; - declare export type Reducer = (state: S, action: A) => S; + declare export type Reducer = (state: S | void, action: A) => S; declare export type CombinedReducer = (state: $Shape & {} | void, action: A) => S; @@ -43,7 +43,7 @@ declare module 'redux' { declare export type StoreEnhancer> = (next: StoreCreator) => StoreCreator; declare export function createStore(reducer: Reducer, enhancer?: StoreEnhancer): Store; - declare export function createStore(reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; + declare export function createStore(reducer: Reducer, preloadedState?: S, enhancer?: StoreEnhancer): Store; declare export function applyMiddleware(...middlewares: Array>): StoreEnhancer; diff --git a/package.json b/package.json index 6febe902..ff3faf17 100644 --- a/package.json +++ b/package.json @@ -1,74 +1,79 @@ { + "private": true, "name": "flatris", "license": "MIT", - "version": "1.0.0", "description": "A fast-paced two-player web game", "repository": { "type": "git", "url": "https://github.com/skidding/flatris.git" }, "scripts": { - "lint": "eslint '**/*.js' '!**/.next/**'", - "format": "prettier --write '**/*.{js,css}' '!**/.next/**'", + "lint": "eslint '**/*.js'", + "format": "prettier --write '**/*.{js,css}' '!**/{flow-typed,.next}/**'", "test": "flow && yarn lint && jest --maxWorkers=4", "test:watch": "jest --watch", - "cosmos": "cosmos", - "cosmos:export": "cosmos-export", + "cosmos": "cosmos --config web/cosmos.config.js", + "cosmos:export": "cosmos-export --config web/cosmos.config.js", "dev:client": "babel-node server/start-dev-client.js", "dev:server": "babel-node server/start-dev-server.js", "dev:server:watch": "nodemon server/start-dev-server.js --exec babel-node", - "build": "next build", + "build": "next build web", "start": "babel-node server/start-prod.js" }, "dependencies": { - "body-parser": "^1.18.2", - "classnames": "^2.2.5", - "clipboard": "^1.7.1", + "body-parser": "^1.18.3", + "classnames": "^2.2.6", + "clipboard": "^2.0.4", "cookie": "^0.3.1", "cookie-parser": "^1.4.3", "crc-32": "^1.2.0", - "express": "^4.16.2", - "firebase-admin": "^5.10.0", - "isomorphic-unfetch": "^2.0.0", - "lodash": "^4.17.4", - "next": "^5.0.1-canary.13", + "express": "^4.16.4", + "firebase-admin": "^6.4.0", + "isomorphic-unfetch": "^3.0.0", + "lodash": "^4.17.11", + "next": "^7.0.2", "next-redux-wrapper": "^1.3.5", - "prop-types": "^15.6.0", - "raf": "^3.4.0", - "react": "^16.2.0", - "react-dom": "^16.2.0", - "react-redux": "^5.0.6", - "redux": "^3.7.2", - "redux-thunk": "^2.2.0", - "rollbar": "^2.3.9", - "socket.io": "^2.0.4", - "socket.io-client": "^2.0.4" + "prop-types": "^15.6.2", + "raf": "^3.4.1", + "react": "^16.6.3", + "react-dom": "^16.6.3", + "react-redux": "^5.1.1", + "redux": "^4.0.1", + "redux-thunk": "^2.3.0", + "rollbar": "^2.5.1", + "socket.io": "^2.2.0", + "socket.io-client": "^2.2.0" }, "devDependencies": { - "babel-cli": "^6.26.0", - "babel-core": "^6.26.0", - "babel-eslint": "^8.2.1", - "babel-jest": "22.1.0", - "css-loader": "^0.28.9", - "eslint": "^4.16.0", - "eslint-plugin-babel": "^4.1.2", - "eslint-plugin-flowtype": "^2.42.0", - "eslint-plugin-import": "^2.8.0", - "eslint-plugin-jest": "^21.12.2", - "eslint-plugin-react": "^7.6.0", - "flow-bin": "^0.66.0", - "flow-typed": "^2.3.0", - "html-webpack-plugin": "^2.30.1", + "@babel/core": "^7.1.2", + "@babel/node": "^7.2.2", + "@babel/preset-flow": "^7.0.0", + "babel-core": "^7.0.0-bridge.0", + "babel-eslint": "^10.0.1", + "babel-jest": "23.6.0", + "babel-loader": "^8.0.4", + "babel-plugin-module-resolver": "^3.1.1", + "css-loader": "^2.0.1", + "eslint": "^5.10.0", + "eslint-import-resolver-babel-module": "^5.0.0-beta.1", + "eslint-plugin-babel": "^5.3.0", + "eslint-plugin-flowtype": "^3.2.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-jest": "^22.1.2", + "eslint-plugin-react": "^7.11.1", + "flow-bin": "^0.89.0", + "flow-typed": "^2.5.1", + "html-webpack-plugin": "^3.2.0", "identity-obj-proxy": "^3.0.0", - "jest": "22.1.4", - "nodemon": "^1.14.11", - "prettier": "^1.10.2", - "react-cosmos": "^4.2.0", - "react-cosmos-fetch-proxy": "^4.2.0", - "react-cosmos-redux-proxy": "^4.2.0", - "react-cosmos-telescope": "^4.2.0", - "react-test-renderer": "^16.2.0", - "redux-devtools-extension": "^2.13.2", - "style-loader": "^0.19.1" + "jest": "23.6.0", + "nodemon": "^1.18.9", + "prettier": "^1.15.3", + "react-cosmos": "^4.7.0-19", + "react-cosmos-fetch-proxy": "^4.6.1", + "react-cosmos-redux-proxy": "^4.6.1", + "react-cosmos-telescope": "^4.6.4", + "react-test-renderer": "^16.6.3", + "redux-devtools-extension": "^2.13.7", + "style-loader": "^0.23.1" } } diff --git a/scripts/generate-game-media-queries.js b/scripts/generate-game-media-queries.js index 95d0cb03..89324f4e 100644 --- a/scripts/generate-game-media-queries.js +++ b/scripts/generate-game-media-queries.js @@ -53,7 +53,7 @@ function getMediaQuery(cond, body) { function getPortraitRules({ width, height }) { const numBlocks = GAME_ROWS + CONTROL_BLOCKS; - const innerHeight = height / numBlocks * GAME_ROWS; + const innerHeight = (height / numBlocks) * GAME_ROWS; const topOffset = (height - innerHeight) / 2; return `.container { diff --git a/server/api.js b/server/api.js index dd189e92..1cd07712 100644 --- a/server/api.js +++ b/server/api.js @@ -14,8 +14,8 @@ import { import { rollbar } from './rollbar'; import { getStats, incrementUserCount, incrementGameCount } from './firebase'; -import type { User } from '../types/state'; -import type { BackfillRequest, BackfillResponse } from '../types/api'; +import type { User } from 'shared/types/state'; +import type { BackfillRequest, BackfillResponse } from 'shared/types/api'; import type { SessionId } from './db'; export function addRoutes(app: express$Application) { @@ -93,12 +93,11 @@ export function addRoutes(app: express$Application) { app.post('/auth', (req: express$Request, res: express$Response) => { try { - const { userName } = req.body; - if (!userName) { + if (!req.body || typeof req.body.userName !== 'string') { throw new Error('Empty user name'); } - const user = insertUser(userName); + const user = insertUser(req.body.userName); const session = insertSession(user.id); const numSessions = Object.keys(sessions).length; diff --git a/server/db.js b/server/db.js index d06e5f4c..cfe320c3 100644 --- a/server/db.js +++ b/server/db.js @@ -2,16 +2,16 @@ import crypto from 'crypto'; import { without } from 'lodash'; -import { getBlankGame } from '../reducers/game'; -import { MAX_NAME_LENGTH } from '../constants/user'; +import { getBlankGame } from 'shared/reducers/game'; +import { MAX_NAME_LENGTH } from 'shared/constants/user'; import { GAME_INACTIVE_TIMEOUT, GAME_EXPIRE_TIMEOUT -} from '../constants/timeouts'; -import { createTimeoutBumper } from '../utils/timeout-bumper'; +} from 'shared/constants/timeouts'; +import { createTimeoutBumper } from 'shared/utils/timeout-bumper'; -import type { GameId, Game, UserId, User } from '../types/state'; -import type { GameAction } from '../types/actions'; +import type { GameId, Game, UserId, User } from 'shared/types/state'; +import type { GameAction } from 'shared/types/actions'; export type SessionId = string; export type Session = { id: SessionId, userId: UserId }; diff --git a/server/firebase.js b/server/firebase.js index 03fa3a06..7d2c67a6 100644 --- a/server/firebase.js +++ b/server/firebase.js @@ -2,7 +2,7 @@ import admin from 'firebase-admin'; -import type { Stats } from '../types/state'; +import type { Stats } from 'shared/types/state'; export async function getStats(): Promise { const db = getDb(); diff --git a/server/next.js b/server/next.js index 17d001d7..3e8fa7d2 100644 --- a/server/next.js +++ b/server/next.js @@ -9,7 +9,7 @@ export async function startNextApp( server: net$Server ) { const dev = process.env.NODE_ENV !== 'production'; - const nextApp = next({ dev }); + const nextApp = next({ dev, dir: join(__dirname, '../web') }); const nextHandler = nextApp.getRequestHandler(); await nextApp.prepare(); diff --git a/server/socket.js b/server/socket.js index 93b8b84f..9e7b5b5f 100644 --- a/server/socket.js +++ b/server/socket.js @@ -2,11 +2,11 @@ import socketIo from 'socket.io'; import { omit, difference } from 'lodash'; -import { gameReducer, getPlayer } from '../reducers/game'; +import { gameReducer, getPlayer } from 'shared/reducers/game'; import { ACTION_STATS_FLUSH_INTERVAL, ACTION_STATS_FLUSH_DELAY -} from '../constants/timeouts'; +} from 'shared/constants/timeouts'; import { games, saveGameAction, bumpActiveGame } from './db'; import { onStatsChange, @@ -20,9 +20,9 @@ import { } from './firebase'; import { rollbar } from './rollbar'; -import type { GameId, Game } from '../types/state'; -import type { GameAction } from '../types/actions'; -import type { RoomId } from '../types/api'; +import type { GameId, Game } from 'shared/types/state'; +import type { GameAction } from 'shared/types/actions'; +import type { RoomId } from 'shared/types/api'; export function attachSocket(server: net$Server) { const io = socketIo(server); diff --git a/constants/grid.js b/shared/constants/grid.js similarity index 100% rename from constants/grid.js rename to shared/constants/grid.js diff --git a/constants/tetromino.js b/shared/constants/tetromino.js similarity index 100% rename from constants/tetromino.js rename to shared/constants/tetromino.js diff --git a/constants/timeouts.js b/shared/constants/timeouts.js similarity index 100% rename from constants/timeouts.js rename to shared/constants/timeouts.js diff --git a/constants/user.js b/shared/constants/user.js similarity index 97% rename from constants/user.js rename to shared/constants/user.js index f5487485..5948a5b5 100644 --- a/constants/user.js +++ b/shared/constants/user.js @@ -1,2 +1 @@ export const MAX_NAME_LENGTH = 14; - diff --git a/reducers/game.js b/shared/reducers/game.js similarity index 100% rename from reducers/game.js rename to shared/reducers/game.js diff --git a/types/actions.js b/shared/types/actions.js similarity index 100% rename from types/actions.js rename to shared/types/actions.js diff --git a/types/api.js b/shared/types/api.js similarity index 100% rename from types/api.js rename to shared/types/api.js diff --git a/types/error.js b/shared/types/error.js similarity index 100% rename from types/error.js rename to shared/types/error.js diff --git a/types/state.js b/shared/types/state.js similarity index 100% rename from types/state.js rename to shared/types/state.js diff --git a/utils/grid.js b/shared/utils/grid.js similarity index 100% rename from utils/grid.js rename to shared/utils/grid.js diff --git a/utils/tetromino.js b/shared/utils/tetromino.js similarity index 92% rename from utils/tetromino.js rename to shared/utils/tetromino.js index 07b5406a..4c2e035a 100644 --- a/utils/tetromino.js +++ b/shared/utils/tetromino.js @@ -6,7 +6,8 @@ import { SHAPES } from '../constants/tetromino'; import type { Tetromino, Position2d, GameId } from '../types/state'; export function getNextTetromino(gameId: GameId, nth: number): Tetromino { - const tetrominos = Object.keys(SHAPES); + // $FlowFixMe + const tetrominos: Tetromino[] = Object.keys(SHAPES); const randNum = crc32(gameId + nth); return tetrominos[Math.abs(randNum) % tetrominos.length]; diff --git a/utils/timeout-bumper.js b/shared/utils/timeout-bumper.js similarity index 100% rename from utils/timeout-bumper.js rename to shared/utils/timeout-bumper.js diff --git a/utils/timeout-bumper.test.js b/shared/utils/timeout-bumper.test.js similarity index 100% rename from utils/timeout-bumper.test.js rename to shared/utils/timeout-bumper.test.js diff --git a/utils/create-fixture.js b/utils/create-fixture.js deleted file mode 100644 index 2f456382..00000000 --- a/utils/create-fixture.js +++ /dev/null @@ -1,12 +0,0 @@ -// @flow - -import type { Node, ComponentType } from 'react'; - -export function createFixture>(fixture: { - component: C, - name?: string, - props?: P, - children?: Node -}) { - return fixture; -} diff --git a/__snapshots__/cosmos.test.js.snap b/web/__snapshots__/cosmos.test.js.snap similarity index 99% rename from __snapshots__/cosmos.test.js.snap rename to web/__snapshots__/cosmos.test.js.snap index bab69d8a..ae81c45a 100644 --- a/__snapshots__/cosmos.test.js.snap +++ b/web/__snapshots__/cosmos.test.js.snap @@ -399,7 +399,6 @@ exports[`Cosmos fixtures: Connect(NewGame):default 1`] = ` >
@@ -11998,11 +11959,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):double-hallelujah type="button" > @@ -12018,11 +11979,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):double-hallelujah type="button" > @@ -12039,11 +12000,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):double-hallelujah type="button" > @@ -13939,11 +13900,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):enemy-hallelujah 1 type="button" > @@ -13959,11 +13920,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):enemy-hallelujah 1 type="button" > @@ -13979,11 +13940,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):enemy-hallelujah 1 type="button" > @@ -14000,11 +13961,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):enemy-hallelujah 1 type="button" > @@ -16256,11 +16217,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah 1`] = ` type="button" > @@ -16276,11 +16237,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah 1`] = ` type="button" > @@ -16296,11 +16257,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah 1`] = ` type="button" > @@ -16317,11 +16278,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah 1`] = ` type="button" > @@ -18587,7 +18548,6 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah-guest 1 >
@@ -18653,11 +18613,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah-guest 1 type="button" > @@ -18672,11 +18632,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah-guest 1 type="button" > @@ -18691,11 +18651,11 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):hallelujah-guest 1 type="button" > @@ -21224,7 +21184,7 @@ exports[`Cosmos fixtures: Connect(SocketConnect(FlatrisGame)):mission-impossible className="jsx-1832570087 copy" >
); -}; +} diff --git a/components/CopyButton.js b/web/components/CopyButton.js similarity index 97% rename from components/CopyButton.js rename to web/components/CopyButton.js index de31c217..e6c1acef 100644 --- a/components/CopyButton.js +++ b/web/components/CopyButton.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import Clipboard from 'clipboard'; -import { COLORS } from '../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import Button from './Button'; type Props = { diff --git a/components/CopyGameLinkButton.js b/web/components/CopyGameLinkButton.js similarity index 91% rename from components/CopyGameLinkButton.js rename to web/components/CopyGameLinkButton.js index f828a31c..d58c093c 100644 --- a/components/CopyGameLinkButton.js +++ b/web/components/CopyGameLinkButton.js @@ -4,7 +4,7 @@ import React, { Component } from 'react'; import { getShareUrl } from '../utils/url'; import CopyButton from './CopyButton'; -import type { GameId } from '../types/state'; +import type { GameId } from 'shared/types/state'; type Props = { disabled: boolean, diff --git a/components/CurGameOfElse.js b/web/components/CurGameOfElse.js similarity index 95% rename from components/CurGameOfElse.js rename to web/components/CurGameOfElse.js index 64494028..8e6d96cd 100644 --- a/components/CurGameOfElse.js +++ b/web/components/CurGameOfElse.js @@ -4,7 +4,7 @@ import { Component } from 'react'; import { connect } from 'react-redux'; import type { Node } from 'react'; -import type { GameId, Games, State } from '../types/state'; +import type { GameId, Games, State } from 'shared/types/state'; type Props = { children: Node, diff --git a/components/FlatrisGame.js b/web/components/FlatrisGame.js similarity index 97% rename from components/FlatrisGame.js rename to web/components/FlatrisGame.js index fe0112a6..cab83dfa 100644 --- a/components/FlatrisGame.js +++ b/web/components/FlatrisGame.js @@ -5,14 +5,14 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { throttle } from 'lodash'; import { UP, DOWN, LEFT, RIGHT, SPACE, KEY_DELAY } from '../constants/keys'; -import { GAME_INACTIVE_TIMEOUT } from '../constants/timeouts'; +import { GAME_INACTIVE_TIMEOUT } from 'shared/constants/timeouts'; import { isPlayer, getPlayer, getCurPlayer, getOtherPlayer, allPlayersReady -} from '../reducers/game'; +} from 'shared/reducers/game'; import { getCurGame } from '../reducers/cur-game'; import { joinGame, @@ -46,8 +46,8 @@ import WaitingForOther from './screens/WaitingForOther'; import GameOver from './screens/GameOver'; import type { Node } from 'react'; -import type { User, GameId, Game, Backfills, State } from '../types/state'; -import type { RoomId } from '../types/api'; +import type { User, GameId, Game, Backfills, State } from 'shared/types/state'; +import type { RoomId } from 'shared/types/api'; type Props = { jsReady: boolean, @@ -487,6 +487,7 @@ const syncActions = { ping }; -export default connect(mapStateToProps, mapDispatchToProps)( - withSocket(FlatrisGame, syncActions) -); +export default connect( + mapStateToProps, + mapDispatchToProps +)(withSocket(FlatrisGame, syncActions)); diff --git a/components/GameContainer.js b/web/components/GameContainer.js similarity index 100% rename from components/GameContainer.js rename to web/components/GameContainer.js diff --git a/components/GamePanel.js b/web/components/GamePanel.js similarity index 96% rename from components/GamePanel.js rename to web/components/GamePanel.js index 93f2abe9..c9e07441 100644 --- a/components/GamePanel.js +++ b/web/components/GamePanel.js @@ -1,12 +1,12 @@ // @flow import React, { Component } from 'react'; -import { SHAPES, COLORS } from '../constants/tetromino'; -import { getCurPlayer, allPlayersReady } from '../reducers/game'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; +import { getCurPlayer, allPlayersReady } from 'shared/reducers/game'; import Tetromino from './Tetromino'; import PlayerInfo from './PlayerInfo'; -import type { User, Game } from '../types/state'; +import type { User, Game } from 'shared/types/state'; type Props = { curUser: ?User, diff --git a/components/GamePreview.js b/web/components/GamePreview.js similarity index 94% rename from components/GamePreview.js rename to web/components/GamePreview.js index b7cc441e..2e8ce22a 100644 --- a/components/GamePreview.js +++ b/web/components/GamePreview.js @@ -1,14 +1,14 @@ // @flow import React, { Component } from 'react'; -import { getCurPlayer, getOtherPlayer } from '../reducers/game'; +import { getCurPlayer, getOtherPlayer } from 'shared/reducers/game'; import Well from './Well'; import GamePanel from './GamePanel'; import Flash from './effects/Flash'; import Quake from './effects/Quake'; import type { Node } from 'react'; -import type { User, Player, Game } from '../types/state'; +import type { User, Player, Game } from 'shared/types/state'; type Props = { curUser: ?User, diff --git a/components/GamePreviewShell.js b/web/components/GamePreviewShell.js similarity index 100% rename from components/GamePreviewShell.js rename to web/components/GamePreviewShell.js diff --git a/components/Layout.js b/web/components/Layout.js similarity index 99% rename from components/Layout.js rename to web/components/Layout.js index 21f6be43..a6665ffe 100644 --- a/components/Layout.js +++ b/web/components/Layout.js @@ -8,9 +8,9 @@ import Error from './pages/Error'; import { logError } from '../utils/rollbar-client'; import type { Node } from 'react'; -import type { State } from '../types/state'; -import type { Action, Dispatch } from '../types/actions'; -import type { ComponentError } from '../types/error'; +import type { State } from 'shared/types/state'; +import type { Action, Dispatch } from 'shared/types/actions'; +import type { ComponentError } from 'shared/types/error'; type Props = { jsReady: boolean, @@ -150,4 +150,7 @@ function mapDispatchToProps(dispatch: Dispatch): $Shape { }; } -export default connect(mapStateToProps, mapDispatchToProps)(Layout); +export default connect( + mapStateToProps, + mapDispatchToProps +)(Layout); diff --git a/components/Loading.js b/web/components/Loading.js similarity index 100% rename from components/Loading.js rename to web/components/Loading.js diff --git a/web/components/Logo.js b/web/components/Logo.js new file mode 100644 index 00000000..b6fe6a0d --- /dev/null +++ b/web/components/Logo.js @@ -0,0 +1,30 @@ +// @flow + +import React from 'react'; +import Tetromino from './Tetromino'; +import { SHAPES } from 'shared/constants/tetromino'; + +type Props = { + color?: string +}; + +export default function Logo({ color = '#34495f' }: Props) { + return ( +
+ + +
+ ); +} diff --git a/components/PlayerInfo.js b/web/components/PlayerInfo.js similarity index 99% rename from components/PlayerInfo.js rename to web/components/PlayerInfo.js index f59c8122..e20f59d7 100644 --- a/components/PlayerInfo.js +++ b/web/components/PlayerInfo.js @@ -3,7 +3,7 @@ import classNames from 'classnames'; import React, { Component } from 'react'; -import type { Player } from '../types/state'; +import type { Player } from 'shared/types/state'; // NOTE: This component is a mess. Potential refactor: Send entire game state // and player index, and let it determine its various render paths internally. diff --git a/components/PointerButton.js b/web/components/PointerButton.js similarity index 87% rename from components/PointerButton.js rename to web/components/PointerButton.js index 1943688f..419c5905 100644 --- a/components/PointerButton.js +++ b/web/components/PointerButton.js @@ -13,7 +13,12 @@ type Props = { onRelease?: Function }; -export default ({ children, onPress, onRelease, ...rest }: Props) => { +export default function PointerButton({ + children, + onPress, + onRelease, + ...rest +}: Props) { const pointerDownEvent = getPointerDownEvent(); const pointerUpEvent = getPointerUpEvent(); let props = { @@ -30,4 +35,4 @@ export default ({ children, onPress, onRelease, ...rest }: Props) => { } return ; -}; +} diff --git a/components/SquareBlock.js b/web/components/SquareBlock.js similarity index 100% rename from components/SquareBlock.js rename to web/components/SquareBlock.js diff --git a/components/Stats.js b/web/components/Stats.js similarity index 95% rename from components/Stats.js rename to web/components/Stats.js index c8496d00..aa885abd 100644 --- a/components/Stats.js +++ b/web/components/Stats.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; -import type { Stats as StatsType } from '../types/state'; +import type { Stats as StatsType } from 'shared/types/state'; type Props = { stats: StatsType @@ -74,6 +74,8 @@ class Stats extends Component { } renderCount(stat: $Keys) { + // TODO: Add space between number digits + // Eg. 1445485 => 1 445 485 const { stats } = this.props; const { statsDiff } = this.state; const diff = statsDiff[stat]; diff --git a/components/Tetromino.js b/web/components/Tetromino.js similarity index 100% rename from components/Tetromino.js rename to web/components/Tetromino.js diff --git a/components/Title.js b/web/components/Title.js similarity index 100% rename from components/Title.js rename to web/components/Title.js diff --git a/components/Well.js b/web/components/Well.js similarity index 92% rename from components/Well.js rename to web/components/Well.js index b1f7ddfb..0d3c1c24 100644 --- a/components/Well.js +++ b/web/components/Well.js @@ -1,8 +1,8 @@ // @flow import React, { Component } from 'react'; -import { COLORS } from '../constants/tetromino'; -import { getExactPosition } from '../utils/grid'; +import { COLORS } from 'shared/constants/tetromino'; +import { getExactPosition } from 'shared/utils/grid'; import WellGridComponent from './WellGrid'; import TetrominoComponent from './Tetromino'; @@ -11,7 +11,7 @@ import type { Tetromino, TetrominoGrid, Position2d -} from '../types/state'; +} from 'shared/types/state'; type Props = { grid: WellGrid, @@ -56,8 +56,8 @@ class Well extends Component { const { x, y } = getExactPosition(this.props.activeTetrominoPosition); return { - top: `${100 / rows * y}%`, - left: `${100 / cols * x}%` + top: `${(100 / rows) * y}%`, + left: `${(100 / cols) * x}%` }; } diff --git a/components/WellGrid.js b/web/components/WellGrid.js similarity index 96% rename from components/WellGrid.js rename to web/components/WellGrid.js index 6f6f161a..5498a785 100644 --- a/components/WellGrid.js +++ b/web/components/WellGrid.js @@ -3,7 +3,10 @@ import React, { Component } from 'react'; import SquareBlock from './SquareBlock'; -import type { WellGrid as WellGridType, WellGridItem } from '../types/state'; +import type { + WellGrid as WellGridType, + WellGridItem +} from 'shared/types/state'; type Props = { grid: WellGridType, diff --git a/components/__fixtures__/Button/primary-disabled.js b/web/components/__fixtures__/Button/primary-disabled.js similarity index 78% rename from components/__fixtures__/Button/primary-disabled.js rename to web/components/__fixtures__/Button/primary-disabled.js index d67eea7c..b831ac14 100644 --- a/components/__fixtures__/Button/primary-disabled.js +++ b/web/components/__fixtures__/Button/primary-disabled.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Button from '../../Button'; export default createFixture({ diff --git a/components/__fixtures__/Button/primary.js b/web/components/__fixtures__/Button/primary.js similarity index 77% rename from components/__fixtures__/Button/primary.js rename to web/components/__fixtures__/Button/primary.js index 8ec48702..e99a6d04 100644 --- a/components/__fixtures__/Button/primary.js +++ b/web/components/__fixtures__/Button/primary.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Button from '../../Button'; export default createFixture({ diff --git a/components/__fixtures__/Button/secondary-disabled.js b/web/components/__fixtures__/Button/secondary-disabled.js similarity index 83% rename from components/__fixtures__/Button/secondary-disabled.js rename to web/components/__fixtures__/Button/secondary-disabled.js index 0eedb7b9..347bf159 100644 --- a/components/__fixtures__/Button/secondary-disabled.js +++ b/web/components/__fixtures__/Button/secondary-disabled.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Button from '../../Button'; export default createFixture({ diff --git a/components/__fixtures__/Button/secondary.js b/web/components/__fixtures__/Button/secondary.js similarity index 80% rename from components/__fixtures__/Button/secondary.js rename to web/components/__fixtures__/Button/secondary.js index f4644ae1..8c88ad86 100644 --- a/components/__fixtures__/Button/secondary.js +++ b/web/components/__fixtures__/Button/secondary.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Button from '../../Button'; export default createFixture({ diff --git a/components/__fixtures__/CopyButton/copy-error.js b/web/components/__fixtures__/CopyButton/copy-error.js similarity index 83% rename from components/__fixtures__/CopyButton/copy-error.js rename to web/components/__fixtures__/CopyButton/copy-error.js index e4450ac3..7bfb8d4e 100644 --- a/components/__fixtures__/CopyButton/copy-error.js +++ b/web/components/__fixtures__/CopyButton/copy-error.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import CopyButton from '../../CopyButton'; export default createFixture({ diff --git a/components/__fixtures__/CopyButton/copy-success.js b/web/components/__fixtures__/CopyButton/copy-success.js similarity index 83% rename from components/__fixtures__/CopyButton/copy-success.js rename to web/components/__fixtures__/CopyButton/copy-success.js index 59415000..cbee55fa 100644 --- a/components/__fixtures__/CopyButton/copy-success.js +++ b/web/components/__fixtures__/CopyButton/copy-success.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import CopyButton from '../../CopyButton'; export default createFixture({ diff --git a/components/__fixtures__/CopyButton/default.js b/web/components/__fixtures__/CopyButton/default.js similarity index 81% rename from components/__fixtures__/CopyButton/default.js rename to web/components/__fixtures__/CopyButton/default.js index 065f3800..51a8d585 100644 --- a/components/__fixtures__/CopyButton/default.js +++ b/web/components/__fixtures__/CopyButton/default.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import CopyButton from '../../CopyButton'; export default createFixture({ diff --git a/components/__fixtures__/CopyButton/disabled.js b/web/components/__fixtures__/CopyButton/disabled.js similarity index 81% rename from components/__fixtures__/CopyButton/disabled.js rename to web/components/__fixtures__/CopyButton/disabled.js index 8df11cc0..91ac7b61 100644 --- a/components/__fixtures__/CopyButton/disabled.js +++ b/web/components/__fixtures__/CopyButton/disabled.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import CopyButton from '../../CopyButton'; export default createFixture({ diff --git a/components/__fixtures__/CopyGameLinkButton/default.js b/web/components/__fixtures__/CopyGameLinkButton/default.js similarity index 75% rename from components/__fixtures__/CopyGameLinkButton/default.js rename to web/components/__fixtures__/CopyGameLinkButton/default.js index 6ae25d8d..7606ae2c 100644 --- a/components/__fixtures__/CopyGameLinkButton/default.js +++ b/web/components/__fixtures__/CopyGameLinkButton/default.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import CopyGameLinkButton from '../../CopyGameLinkButton'; export default createFixture({ diff --git a/components/__fixtures__/CopyGameLinkButton/disabled.js b/web/components/__fixtures__/CopyGameLinkButton/disabled.js similarity index 75% rename from components/__fixtures__/CopyGameLinkButton/disabled.js rename to web/components/__fixtures__/CopyGameLinkButton/disabled.js index 23ae42ff..e6d223a4 100644 --- a/components/__fixtures__/CopyGameLinkButton/disabled.js +++ b/web/components/__fixtures__/CopyGameLinkButton/disabled.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import CopyGameLinkButton from '../../CopyGameLinkButton'; export default createFixture({ diff --git a/components/__fixtures__/FlatrisGame/double-hallelujah.js b/web/components/__fixtures__/FlatrisGame/double-hallelujah.js similarity index 99% rename from components/__fixtures__/FlatrisGame/double-hallelujah.js rename to web/components/__fixtures__/FlatrisGame/double-hallelujah.js index cc735fff..116b1243 100644 --- a/components/__fixtures__/FlatrisGame/double-hallelujah.js +++ b/web/components/__fixtures__/FlatrisGame/double-hallelujah.js @@ -12,7 +12,7 @@ import { addUserToGame, updatePlayer, getPlayer -} from '../../../reducers/game'; +} from 'shared/reducers/game'; import { getCurGame } from '../../../reducers/cur-game'; import FlatrisGame from '../../FlatrisGame'; diff --git a/components/__fixtures__/FlatrisGame/enemy-hallelujah.js b/web/components/__fixtures__/FlatrisGame/enemy-hallelujah.js similarity index 99% rename from components/__fixtures__/FlatrisGame/enemy-hallelujah.js rename to web/components/__fixtures__/FlatrisGame/enemy-hallelujah.js index 3a727872..ccedd99a 100644 --- a/components/__fixtures__/FlatrisGame/enemy-hallelujah.js +++ b/web/components/__fixtures__/FlatrisGame/enemy-hallelujah.js @@ -7,7 +7,7 @@ import { addUserToGame, updatePlayer, getPlayer -} from '../../../reducers/game'; +} from 'shared/reducers/game'; import { getCurGame } from '../../../reducers/cur-game'; import FlatrisGame from '../../FlatrisGame'; diff --git a/components/__fixtures__/FlatrisGame/hallelujah-guest.js b/web/components/__fixtures__/FlatrisGame/hallelujah-guest.js similarity index 98% rename from components/__fixtures__/FlatrisGame/hallelujah-guest.js rename to web/components/__fixtures__/FlatrisGame/hallelujah-guest.js index 5addf7d1..0cc7f913 100644 --- a/components/__fixtures__/FlatrisGame/hallelujah-guest.js +++ b/web/components/__fixtures__/FlatrisGame/hallelujah-guest.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser, getSampleUser2 } from '../../../utils/test-helpers'; -import { getBlankGame, updatePlayer } from '../../../reducers/game'; +import { getBlankGame, updatePlayer } from 'shared/reducers/game'; import FlatrisGame from '../../FlatrisGame'; const user = getSampleUser(); diff --git a/components/__fixtures__/FlatrisGame/hallelujah.js b/web/components/__fixtures__/FlatrisGame/hallelujah.js similarity index 98% rename from components/__fixtures__/FlatrisGame/hallelujah.js rename to web/components/__fixtures__/FlatrisGame/hallelujah.js index fa47a2d3..abea351c 100644 --- a/components/__fixtures__/FlatrisGame/hallelujah.js +++ b/web/components/__fixtures__/FlatrisGame/hallelujah.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame, updatePlayer } from '../../../reducers/game'; +import { getBlankGame, updatePlayer } from 'shared/reducers/game'; import FlatrisGame from '../../FlatrisGame'; const user = getSampleUser(); diff --git a/components/__fixtures__/FlatrisGame/mission-impossible.js b/web/components/__fixtures__/FlatrisGame/mission-impossible.js similarity index 97% rename from components/__fixtures__/FlatrisGame/mission-impossible.js rename to web/components/__fixtures__/FlatrisGame/mission-impossible.js index ac04a168..e4938573 100644 --- a/components/__fixtures__/FlatrisGame/mission-impossible.js +++ b/web/components/__fixtures__/FlatrisGame/mission-impossible.js @@ -1,8 +1,8 @@ // @flow -import { SHAPES } from '../../../constants/tetromino'; +import { SHAPES } from 'shared/constants/tetromino'; import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame, updatePlayer } from '../../../reducers/game'; +import { getBlankGame, updatePlayer } from 'shared/reducers/game'; import FlatrisGame from '../../FlatrisGame'; const user = getSampleUser(); diff --git a/components/__fixtures__/FlatrisGame/new-game-running.js b/web/components/__fixtures__/FlatrisGame/new-game-running.js similarity index 94% rename from components/__fixtures__/FlatrisGame/new-game-running.js rename to web/components/__fixtures__/FlatrisGame/new-game-running.js index 101475c2..79d629b3 100644 --- a/components/__fixtures__/FlatrisGame/new-game-running.js +++ b/web/components/__fixtures__/FlatrisGame/new-game-running.js @@ -2,7 +2,7 @@ import { Component } from 'react'; import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame, getPlayer } from '../../../reducers/game'; +import { getBlankGame, getPlayer } from 'shared/reducers/game'; import { getCurGame } from '../../../reducers/cur-game'; import FlatrisGame from '../../FlatrisGame'; diff --git a/components/__fixtures__/FlatrisGame/new-game.js b/web/components/__fixtures__/FlatrisGame/new-game.js similarity index 87% rename from components/__fixtures__/FlatrisGame/new-game.js rename to web/components/__fixtures__/FlatrisGame/new-game.js index 0278cd31..9528a087 100644 --- a/components/__fixtures__/FlatrisGame/new-game.js +++ b/web/components/__fixtures__/FlatrisGame/new-game.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame } from '../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import FlatrisGame from '../../FlatrisGame'; const user = getSampleUser(); diff --git a/components/__fixtures__/GameContainer/default.js b/web/components/__fixtures__/GameContainer/default.js similarity index 71% rename from components/__fixtures__/GameContainer/default.js rename to web/components/__fixtures__/GameContainer/default.js index e4baf723..6acbd24e 100644 --- a/components/__fixtures__/GameContainer/default.js +++ b/web/components/__fixtures__/GameContainer/default.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import GameContainer from '../../GameContainer'; export default createFixture({ diff --git a/components/__fixtures__/GamePanel/default.js b/web/components/__fixtures__/GamePanel/default.js similarity index 76% rename from components/__fixtures__/GamePanel/default.js rename to web/components/__fixtures__/GamePanel/default.js index 80532260..417c6c30 100644 --- a/components/__fixtures__/GamePanel/default.js +++ b/web/components/__fixtures__/GamePanel/default.js @@ -1,8 +1,8 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame } from '../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import GamePanel from '../../GamePanel'; const user = getSampleUser(); diff --git a/components/__fixtures__/GamePanel/with-footer.js b/web/components/__fixtures__/GamePanel/with-footer.js similarity index 77% rename from components/__fixtures__/GamePanel/with-footer.js rename to web/components/__fixtures__/GamePanel/with-footer.js index f8bb0f74..56d8099b 100644 --- a/components/__fixtures__/GamePanel/with-footer.js +++ b/web/components/__fixtures__/GamePanel/with-footer.js @@ -1,8 +1,8 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame } from '../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import GamePanel from '../../GamePanel'; const user = getSampleUser(); diff --git a/components/__fixtures__/GamePreview/default.js b/web/components/__fixtures__/GamePreview/default.js similarity index 86% rename from components/__fixtures__/GamePreview/default.js rename to web/components/__fixtures__/GamePreview/default.js index c2e18e80..9915b3a7 100644 --- a/components/__fixtures__/GamePreview/default.js +++ b/web/components/__fixtures__/GamePreview/default.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame } from '../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import GamePreview from '../../GamePreview'; const user = getSampleUser(); diff --git a/components/__fixtures__/GamePreview/with-footer.js b/web/components/__fixtures__/GamePreview/with-footer.js similarity index 87% rename from components/__fixtures__/GamePreview/with-footer.js rename to web/components/__fixtures__/GamePreview/with-footer.js index 263383d7..6824b10b 100644 --- a/components/__fixtures__/GamePreview/with-footer.js +++ b/web/components/__fixtures__/GamePreview/with-footer.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../utils/test-helpers'; -import { getBlankGame } from '../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import GamePreview from '../../GamePreview'; const user = getSampleUser(); diff --git a/components/__fixtures__/GamePreviewShell/default.js b/web/components/__fixtures__/GamePreviewShell/default.js similarity index 72% rename from components/__fixtures__/GamePreviewShell/default.js rename to web/components/__fixtures__/GamePreviewShell/default.js index 8e81192a..f2169934 100644 --- a/components/__fixtures__/GamePreviewShell/default.js +++ b/web/components/__fixtures__/GamePreviewShell/default.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import GamePreviewShell from '../../GamePreviewShell'; export default createFixture({ diff --git a/components/__fixtures__/Loading/default.js b/web/components/__fixtures__/Loading/default.js similarity index 100% rename from components/__fixtures__/Loading/default.js rename to web/components/__fixtures__/Loading/default.js diff --git a/components/__fixtures__/Logo/default.js b/web/components/__fixtures__/Logo/default.js similarity index 100% rename from components/__fixtures__/Logo/default.js rename to web/components/__fixtures__/Logo/default.js diff --git a/components/__fixtures__/PlayerInfo/player-multi.js b/web/components/__fixtures__/PlayerInfo/player-multi.js similarity index 75% rename from components/__fixtures__/PlayerInfo/player-multi.js rename to web/components/__fixtures__/PlayerInfo/player-multi.js index 8e2267d0..389d59ee 100644 --- a/components/__fixtures__/PlayerInfo/player-multi.js +++ b/web/components/__fixtures__/PlayerInfo/player-multi.js @@ -1,7 +1,7 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; -import { getBlankPlayer } from '../../../reducers/game'; +import { createFixture } from 'react-cosmos'; +import { getBlankPlayer } from 'shared/reducers/game'; import PlayerInfo from '../../PlayerInfo'; const user = { id: 'mock', name: 'Treznik' }; diff --git a/components/__fixtures__/PlayerInfo/player-ready.js b/web/components/__fixtures__/PlayerInfo/player-ready.js similarity index 76% rename from components/__fixtures__/PlayerInfo/player-ready.js rename to web/components/__fixtures__/PlayerInfo/player-ready.js index a87f4221..8c2bacda 100644 --- a/components/__fixtures__/PlayerInfo/player-ready.js +++ b/web/components/__fixtures__/PlayerInfo/player-ready.js @@ -1,7 +1,7 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; -import { getBlankPlayer } from '../../../reducers/game'; +import { createFixture } from 'react-cosmos'; +import { getBlankPlayer } from 'shared/reducers/game'; import PlayerInfo from '../../PlayerInfo'; const user = { id: 'mock', name: 'Treznik' }; diff --git a/components/__fixtures__/PlayerInfo/player-solo-big-score.js b/web/components/__fixtures__/PlayerInfo/player-solo-big-score.js similarity index 76% rename from components/__fixtures__/PlayerInfo/player-solo-big-score.js rename to web/components/__fixtures__/PlayerInfo/player-solo-big-score.js index cd01a58b..a2638821 100644 --- a/components/__fixtures__/PlayerInfo/player-solo-big-score.js +++ b/web/components/__fixtures__/PlayerInfo/player-solo-big-score.js @@ -1,7 +1,7 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; -import { getBlankPlayer } from '../../../reducers/game'; +import { createFixture } from 'react-cosmos'; +import { getBlankPlayer } from 'shared/reducers/game'; import PlayerInfo from '../../PlayerInfo'; const user = { id: 'mock', name: 'Treznik' }; diff --git a/components/__fixtures__/PlayerInfo/player-solo-long-name.js b/web/components/__fixtures__/PlayerInfo/player-solo-long-name.js similarity index 76% rename from components/__fixtures__/PlayerInfo/player-solo-long-name.js rename to web/components/__fixtures__/PlayerInfo/player-solo-long-name.js index 30e384af..c033b7df 100644 --- a/components/__fixtures__/PlayerInfo/player-solo-long-name.js +++ b/web/components/__fixtures__/PlayerInfo/player-solo-long-name.js @@ -1,7 +1,7 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; -import { getBlankPlayer } from '../../../reducers/game'; +import { createFixture } from 'react-cosmos'; +import { getBlankPlayer } from 'shared/reducers/game'; import PlayerInfo from '../../PlayerInfo'; const user = { id: 'mock', name: 'Lorem ipsum' }; diff --git a/components/__fixtures__/PlayerInfo/player-solo.js b/web/components/__fixtures__/PlayerInfo/player-solo.js similarity index 76% rename from components/__fixtures__/PlayerInfo/player-solo.js rename to web/components/__fixtures__/PlayerInfo/player-solo.js index 37337aab..05246f90 100644 --- a/components/__fixtures__/PlayerInfo/player-solo.js +++ b/web/components/__fixtures__/PlayerInfo/player-solo.js @@ -1,7 +1,7 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; -import { getBlankPlayer } from '../../../reducers/game'; +import { createFixture } from 'react-cosmos'; +import { getBlankPlayer } from 'shared/reducers/game'; import PlayerInfo from '../../PlayerInfo'; const user = { id: 'mock', name: 'Treznik' }; diff --git a/components/__fixtures__/PlayerInfo/player1-missing.js b/web/components/__fixtures__/PlayerInfo/player1-missing.js similarity index 80% rename from components/__fixtures__/PlayerInfo/player1-missing.js rename to web/components/__fixtures__/PlayerInfo/player1-missing.js index 3dbcdbec..2961173c 100644 --- a/components/__fixtures__/PlayerInfo/player1-missing.js +++ b/web/components/__fixtures__/PlayerInfo/player1-missing.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import PlayerInfo from '../../PlayerInfo'; export default createFixture({ diff --git a/components/__fixtures__/PlayerInfo/player2-missing.js b/web/components/__fixtures__/PlayerInfo/player2-missing.js similarity index 82% rename from components/__fixtures__/PlayerInfo/player2-missing.js rename to web/components/__fixtures__/PlayerInfo/player2-missing.js index e830dbef..78242c48 100644 --- a/components/__fixtures__/PlayerInfo/player2-missing.js +++ b/web/components/__fixtures__/PlayerInfo/player2-missing.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import PlayerInfo from '../../PlayerInfo'; export default createFixture({ diff --git a/components/__fixtures__/PointerButton/primary.js b/web/components/__fixtures__/PointerButton/primary.js similarity index 100% rename from components/__fixtures__/PointerButton/primary.js rename to web/components/__fixtures__/PointerButton/primary.js diff --git a/components/__fixtures__/SquareBlock/color-of-the-I-tetromino.js b/web/components/__fixtures__/SquareBlock/color-of-the-I-tetromino.js similarity index 69% rename from components/__fixtures__/SquareBlock/color-of-the-I-tetromino.js rename to web/components/__fixtures__/SquareBlock/color-of-the-I-tetromino.js index 0e99037f..ae62735d 100644 --- a/components/__fixtures__/SquareBlock/color-of-the-I-tetromino.js +++ b/web/components/__fixtures__/SquareBlock/color-of-the-I-tetromino.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import SquareBlock from '../../SquareBlock'; export default { diff --git a/components/__fixtures__/SquareBlock/color-of-the-J-tetromino.js b/web/components/__fixtures__/SquareBlock/color-of-the-J-tetromino.js similarity index 69% rename from components/__fixtures__/SquareBlock/color-of-the-J-tetromino.js rename to web/components/__fixtures__/SquareBlock/color-of-the-J-tetromino.js index 13b809f5..6822c959 100644 --- a/components/__fixtures__/SquareBlock/color-of-the-J-tetromino.js +++ b/web/components/__fixtures__/SquareBlock/color-of-the-J-tetromino.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import SquareBlock from '../../SquareBlock'; export default { diff --git a/components/__fixtures__/SquareBlock/color-of-the-L-tetromino.js b/web/components/__fixtures__/SquareBlock/color-of-the-L-tetromino.js similarity index 69% rename from components/__fixtures__/SquareBlock/color-of-the-L-tetromino.js rename to web/components/__fixtures__/SquareBlock/color-of-the-L-tetromino.js index 8ab47e32..7561a998 100644 --- a/components/__fixtures__/SquareBlock/color-of-the-L-tetromino.js +++ b/web/components/__fixtures__/SquareBlock/color-of-the-L-tetromino.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import SquareBlock from '../../SquareBlock'; export default { diff --git a/components/__fixtures__/SquareBlock/color-of-the-O-tetromino.js b/web/components/__fixtures__/SquareBlock/color-of-the-O-tetromino.js similarity index 69% rename from components/__fixtures__/SquareBlock/color-of-the-O-tetromino.js rename to web/components/__fixtures__/SquareBlock/color-of-the-O-tetromino.js index 5bd7a5e7..898b502c 100644 --- a/components/__fixtures__/SquareBlock/color-of-the-O-tetromino.js +++ b/web/components/__fixtures__/SquareBlock/color-of-the-O-tetromino.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import SquareBlock from '../../SquareBlock'; export default { diff --git a/components/__fixtures__/SquareBlock/color-of-the-S-tetromino.js b/web/components/__fixtures__/SquareBlock/color-of-the-S-tetromino.js similarity index 69% rename from components/__fixtures__/SquareBlock/color-of-the-S-tetromino.js rename to web/components/__fixtures__/SquareBlock/color-of-the-S-tetromino.js index 2fb3cbee..89cde79a 100644 --- a/components/__fixtures__/SquareBlock/color-of-the-S-tetromino.js +++ b/web/components/__fixtures__/SquareBlock/color-of-the-S-tetromino.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import SquareBlock from '../../SquareBlock'; export default { diff --git a/components/__fixtures__/SquareBlock/color-of-the-T-tetromino.js b/web/components/__fixtures__/SquareBlock/color-of-the-T-tetromino.js similarity index 69% rename from components/__fixtures__/SquareBlock/color-of-the-T-tetromino.js rename to web/components/__fixtures__/SquareBlock/color-of-the-T-tetromino.js index e64ac9c7..3c275e52 100644 --- a/components/__fixtures__/SquareBlock/color-of-the-T-tetromino.js +++ b/web/components/__fixtures__/SquareBlock/color-of-the-T-tetromino.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import SquareBlock from '../../SquareBlock'; export default { diff --git a/components/__fixtures__/SquareBlock/color-of-the-Z-tetromino.js b/web/components/__fixtures__/SquareBlock/color-of-the-Z-tetromino.js similarity index 69% rename from components/__fixtures__/SquareBlock/color-of-the-Z-tetromino.js rename to web/components/__fixtures__/SquareBlock/color-of-the-Z-tetromino.js index 7be56eb1..93d4d5e8 100644 --- a/components/__fixtures__/SquareBlock/color-of-the-Z-tetromino.js +++ b/web/components/__fixtures__/SquareBlock/color-of-the-Z-tetromino.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import SquareBlock from '../../SquareBlock'; export default { diff --git a/components/__fixtures__/Stats/default.js b/web/components/__fixtures__/Stats/default.js similarity index 82% rename from components/__fixtures__/Stats/default.js rename to web/components/__fixtures__/Stats/default.js index e7a10e52..2f4f1bc4 100644 --- a/components/__fixtures__/Stats/default.js +++ b/web/components/__fixtures__/Stats/default.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Stats from '../../Stats'; export default createFixture({ diff --git a/components/__fixtures__/Stats/update.js b/web/components/__fixtures__/Stats/update.js similarity index 90% rename from components/__fixtures__/Stats/update.js rename to web/components/__fixtures__/Stats/update.js index 0355d013..d8edba21 100644 --- a/components/__fixtures__/Stats/update.js +++ b/web/components/__fixtures__/Stats/update.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Stats from '../../Stats'; export default createFixture({ diff --git a/components/__fixtures__/Tetromino/I-tetromino.js b/web/components/__fixtures__/Tetromino/I-tetromino.js similarity index 69% rename from components/__fixtures__/Tetromino/I-tetromino.js rename to web/components/__fixtures__/Tetromino/I-tetromino.js index 5278802b..f7a4b9a4 100644 --- a/components/__fixtures__/Tetromino/I-tetromino.js +++ b/web/components/__fixtures__/Tetromino/I-tetromino.js @@ -1,4 +1,4 @@ -import { SHAPES, COLORS } from '../../../constants/tetromino'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/J-tetromino.js b/web/components/__fixtures__/Tetromino/J-tetromino.js similarity index 69% rename from components/__fixtures__/Tetromino/J-tetromino.js rename to web/components/__fixtures__/Tetromino/J-tetromino.js index f2e054d9..9bcb0252 100644 --- a/components/__fixtures__/Tetromino/J-tetromino.js +++ b/web/components/__fixtures__/Tetromino/J-tetromino.js @@ -1,4 +1,4 @@ -import { SHAPES, COLORS } from '../../../constants/tetromino'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/L-tetromino.js b/web/components/__fixtures__/Tetromino/L-tetromino.js similarity index 69% rename from components/__fixtures__/Tetromino/L-tetromino.js rename to web/components/__fixtures__/Tetromino/L-tetromino.js index 69dd0ae7..2d2ebbb0 100644 --- a/components/__fixtures__/Tetromino/L-tetromino.js +++ b/web/components/__fixtures__/Tetromino/L-tetromino.js @@ -1,4 +1,4 @@ -import { SHAPES, COLORS } from '../../../constants/tetromino'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/O-tetromino.js b/web/components/__fixtures__/Tetromino/O-tetromino.js similarity index 69% rename from components/__fixtures__/Tetromino/O-tetromino.js rename to web/components/__fixtures__/Tetromino/O-tetromino.js index 025de823..a289ea67 100644 --- a/components/__fixtures__/Tetromino/O-tetromino.js +++ b/web/components/__fixtures__/Tetromino/O-tetromino.js @@ -1,4 +1,4 @@ -import { SHAPES, COLORS } from '../../../constants/tetromino'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/S-tetromino.js b/web/components/__fixtures__/Tetromino/S-tetromino.js similarity index 69% rename from components/__fixtures__/Tetromino/S-tetromino.js rename to web/components/__fixtures__/Tetromino/S-tetromino.js index e1c6a01a..11ef1142 100644 --- a/components/__fixtures__/Tetromino/S-tetromino.js +++ b/web/components/__fixtures__/Tetromino/S-tetromino.js @@ -1,4 +1,4 @@ -import { SHAPES, COLORS } from '../../../constants/tetromino'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/T-tetromino.js b/web/components/__fixtures__/Tetromino/T-tetromino.js similarity index 69% rename from components/__fixtures__/Tetromino/T-tetromino.js rename to web/components/__fixtures__/Tetromino/T-tetromino.js index d64c5fdf..2736e46e 100644 --- a/components/__fixtures__/Tetromino/T-tetromino.js +++ b/web/components/__fixtures__/Tetromino/T-tetromino.js @@ -1,4 +1,4 @@ -import { SHAPES, COLORS } from '../../../constants/tetromino'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/Z-tetromino.js b/web/components/__fixtures__/Tetromino/Z-tetromino.js similarity index 69% rename from components/__fixtures__/Tetromino/Z-tetromino.js rename to web/components/__fixtures__/Tetromino/Z-tetromino.js index b80fb8f1..fdfa0c8e 100644 --- a/components/__fixtures__/Tetromino/Z-tetromino.js +++ b/web/components/__fixtures__/Tetromino/Z-tetromino.js @@ -1,4 +1,4 @@ -import { SHAPES, COLORS } from '../../../constants/tetromino'; +import { SHAPES, COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/rotated-Z-tetromino-1.js b/web/components/__fixtures__/Tetromino/rotated-Z-tetromino-1.js similarity index 75% rename from components/__fixtures__/Tetromino/rotated-Z-tetromino-1.js rename to web/components/__fixtures__/Tetromino/rotated-Z-tetromino-1.js index 7df57dfa..cf42dedf 100644 --- a/components/__fixtures__/Tetromino/rotated-Z-tetromino-1.js +++ b/web/components/__fixtures__/Tetromino/rotated-Z-tetromino-1.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/rotated-Z-tetromino-2.js b/web/components/__fixtures__/Tetromino/rotated-Z-tetromino-2.js similarity index 75% rename from components/__fixtures__/Tetromino/rotated-Z-tetromino-2.js rename to web/components/__fixtures__/Tetromino/rotated-Z-tetromino-2.js index fc20367f..47d78ea5 100644 --- a/components/__fixtures__/Tetromino/rotated-Z-tetromino-2.js +++ b/web/components/__fixtures__/Tetromino/rotated-Z-tetromino-2.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Tetromino/rotated-Z-tetromino-3.js b/web/components/__fixtures__/Tetromino/rotated-Z-tetromino-3.js similarity index 75% rename from components/__fixtures__/Tetromino/rotated-Z-tetromino-3.js rename to web/components/__fixtures__/Tetromino/rotated-Z-tetromino-3.js index ef0c8e34..040d1883 100644 --- a/components/__fixtures__/Tetromino/rotated-Z-tetromino-3.js +++ b/web/components/__fixtures__/Tetromino/rotated-Z-tetromino-3.js @@ -1,4 +1,4 @@ -import { COLORS } from '../../../constants/tetromino'; +import { COLORS } from 'shared/constants/tetromino'; import Tetromino from '../..//Tetromino'; export default { diff --git a/components/__fixtures__/Well/s-coming-atcha.js b/web/components/__fixtures__/Well/s-coming-atcha.js similarity index 97% rename from components/__fixtures__/Well/s-coming-atcha.js rename to web/components/__fixtures__/Well/s-coming-atcha.js index df9dfd50..ba622f79 100644 --- a/components/__fixtures__/Well/s-coming-atcha.js +++ b/web/components/__fixtures__/Well/s-coming-atcha.js @@ -1,4 +1,4 @@ -import { SHAPES } from '../../../constants/tetromino'; +import { SHAPES } from 'shared/constants/tetromino'; import Well from '../../Well'; export default { diff --git a/components/__fixtures__/Well/t-bone.js b/web/components/__fixtures__/Well/t-bone.js similarity index 97% rename from components/__fixtures__/Well/t-bone.js rename to web/components/__fixtures__/Well/t-bone.js index 2a606571..b689ab20 100644 --- a/components/__fixtures__/Well/t-bone.js +++ b/web/components/__fixtures__/Well/t-bone.js @@ -1,4 +1,4 @@ -import { SHAPES } from '../../../constants/tetromino'; +import { SHAPES } from 'shared/constants/tetromino'; import Well from '../../Well'; export default { diff --git a/components/__fixtures__/WellGrid/3x3-grid.js b/web/components/__fixtures__/WellGrid/3x3-grid.js similarity index 100% rename from components/__fixtures__/WellGrid/3x3-grid.js rename to web/components/__fixtures__/WellGrid/3x3-grid.js diff --git a/components/__fixtures__/WellGrid/flatris.js b/web/components/__fixtures__/WellGrid/flatris.js similarity index 100% rename from components/__fixtures__/WellGrid/flatris.js rename to web/components/__fixtures__/WellGrid/flatris.js diff --git a/web/components/controls/Drop.js b/web/components/controls/Drop.js new file mode 100644 index 00000000..910c53f6 --- /dev/null +++ b/web/components/controls/Drop.js @@ -0,0 +1,32 @@ +// @flow + +import React from 'react'; +import PointerButton from '../PointerButton'; + +type Props = { + onPress: Function +}; + +export default function Drop({ onPress, ...rest }: Props) { + return ( + + + + + + + ); +} diff --git a/components/controls/LandscapeControls.js b/web/components/controls/LandscapeControls.js similarity index 95% rename from components/controls/LandscapeControls.js rename to web/components/controls/LandscapeControls.js index 15a00746..121f28c5 100644 --- a/components/controls/LandscapeControls.js +++ b/web/components/controls/LandscapeControls.js @@ -10,7 +10,7 @@ import { disableAcceleration } from '../../actions/game'; import { withSocket } from '../socket/SocketConnect'; -import { isPlayer, allPlayersReady } from '../../reducers/game'; +import { isPlayer, allPlayersReady } from 'shared/reducers/game'; import { getCurGame } from '../../reducers/cur-game'; import Left from './Left'; @@ -18,7 +18,7 @@ import Right from './Right'; import Rotate from './Rotate'; import Drop from './Drop'; -import type { User, Game, Backfills, State } from '../../types/state'; +import type { User, Game, Backfills, State } from 'shared/types/state'; type Props = { curUser: ?User, diff --git a/web/components/controls/Left.js b/web/components/controls/Left.js new file mode 100644 index 00000000..3f421b87 --- /dev/null +++ b/web/components/controls/Left.js @@ -0,0 +1,32 @@ +// @flow + +import React from 'react'; +import PointerButton from '../PointerButton'; + +type Props = { + onPress: Function +}; + +export default function Left({ onPress, ...rest }: Props) { + return ( + + + + + + + ); +} diff --git a/components/controls/PortraitControls.js b/web/components/controls/PortraitControls.js similarity index 95% rename from components/controls/PortraitControls.js rename to web/components/controls/PortraitControls.js index 8faf590a..aedc3054 100644 --- a/components/controls/PortraitControls.js +++ b/web/components/controls/PortraitControls.js @@ -10,7 +10,7 @@ import { disableAcceleration } from '../../actions/game'; import { withSocket } from '../socket/SocketConnect'; -import { isPlayer, allPlayersReady } from '../../reducers/game'; +import { isPlayer, allPlayersReady } from 'shared/reducers/game'; import { getCurGame } from '../../reducers/cur-game'; import Left from './Left'; @@ -18,7 +18,7 @@ import Right from './Right'; import Rotate from './Rotate'; import Drop from './Drop'; -import type { User, Game, Backfills, State } from '../../types/state'; +import type { User, Game, Backfills, State } from 'shared/types/state'; type Props = { curUser: ?User, diff --git a/web/components/controls/Right.js b/web/components/controls/Right.js new file mode 100644 index 00000000..f224edfa --- /dev/null +++ b/web/components/controls/Right.js @@ -0,0 +1,32 @@ +// @flow + +import React from 'react'; +import PointerButton from '../PointerButton'; + +type Props = { + onPress: Function +}; + +export default function Right({ onPress, ...rest }: Props) { + return ( + + + + + + + ); +} diff --git a/web/components/controls/Rotate.js b/web/components/controls/Rotate.js new file mode 100644 index 00000000..f034630d --- /dev/null +++ b/web/components/controls/Rotate.js @@ -0,0 +1,34 @@ +// @flow + +import React from 'react'; +import PointerButton from '../PointerButton'; + +type Props = { + onPress: Function +}; + +export default function Rotate({ onPress, ...rest }: Props) { + return ( + + + + + + + ); +} diff --git a/components/controls/__fixtures__/Drop/default.js b/web/components/controls/__fixtures__/Drop/default.js similarity index 100% rename from components/controls/__fixtures__/Drop/default.js rename to web/components/controls/__fixtures__/Drop/default.js diff --git a/components/controls/__fixtures__/LandscapeControls/active.js b/web/components/controls/__fixtures__/LandscapeControls/active.js similarity index 86% rename from components/controls/__fixtures__/LandscapeControls/active.js rename to web/components/controls/__fixtures__/LandscapeControls/active.js index 0625d725..f4498be6 100644 --- a/components/controls/__fixtures__/LandscapeControls/active.js +++ b/web/components/controls/__fixtures__/LandscapeControls/active.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankGame, updatePlayer } from '../../../../reducers/game'; +import { getBlankGame, updatePlayer } from 'shared/reducers/game'; import LandscapeControls from '../../LandscapeControls'; const user = getSampleUser(); diff --git a/components/controls/__fixtures__/LandscapeControls/disabled.js b/web/components/controls/__fixtures__/LandscapeControls/disabled.js similarity index 87% rename from components/controls/__fixtures__/LandscapeControls/disabled.js rename to web/components/controls/__fixtures__/LandscapeControls/disabled.js index cf152da3..23c1dd51 100644 --- a/components/controls/__fixtures__/LandscapeControls/disabled.js +++ b/web/components/controls/__fixtures__/LandscapeControls/disabled.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import LandscapeControls from '../../LandscapeControls'; const user = getSampleUser(); diff --git a/components/controls/__fixtures__/Left/default.js b/web/components/controls/__fixtures__/Left/default.js similarity index 100% rename from components/controls/__fixtures__/Left/default.js rename to web/components/controls/__fixtures__/Left/default.js diff --git a/components/controls/__fixtures__/PortraitControls/active.js b/web/components/controls/__fixtures__/PortraitControls/active.js similarity index 86% rename from components/controls/__fixtures__/PortraitControls/active.js rename to web/components/controls/__fixtures__/PortraitControls/active.js index 9402fd8e..81e53456 100644 --- a/components/controls/__fixtures__/PortraitControls/active.js +++ b/web/components/controls/__fixtures__/PortraitControls/active.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankGame, updatePlayer } from '../../../../reducers/game'; +import { getBlankGame, updatePlayer } from 'shared/reducers/game'; import PortraitControls from '../../PortraitControls'; const user = getSampleUser(); diff --git a/components/controls/__fixtures__/PortraitControls/disabled.js b/web/components/controls/__fixtures__/PortraitControls/disabled.js similarity index 87% rename from components/controls/__fixtures__/PortraitControls/disabled.js rename to web/components/controls/__fixtures__/PortraitControls/disabled.js index 439953c0..bff24159 100644 --- a/components/controls/__fixtures__/PortraitControls/disabled.js +++ b/web/components/controls/__fixtures__/PortraitControls/disabled.js @@ -1,7 +1,7 @@ // @flow import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import PortraitControls from '../../PortraitControls'; const user = getSampleUser(); diff --git a/components/controls/__fixtures__/Right/default.js b/web/components/controls/__fixtures__/Right/default.js similarity index 100% rename from components/controls/__fixtures__/Right/default.js rename to web/components/controls/__fixtures__/Right/default.js diff --git a/components/controls/__fixtures__/Rotate/default.js b/web/components/controls/__fixtures__/Rotate/default.js similarity index 100% rename from components/controls/__fixtures__/Rotate/default.js rename to web/components/controls/__fixtures__/Rotate/default.js diff --git a/components/effects/FadeIn.js b/web/components/effects/FadeIn.js similarity index 100% rename from components/effects/FadeIn.js rename to web/components/effects/FadeIn.js diff --git a/components/effects/Flash.js b/web/components/effects/Flash.js similarity index 97% rename from components/effects/Flash.js rename to web/components/effects/Flash.js index c7c67dd1..4e07eef2 100644 --- a/components/effects/Flash.js +++ b/web/components/effects/Flash.js @@ -3,7 +3,7 @@ import React, { Component } from 'react'; import type { Node } from 'react'; -import type { Player } from '../../types/state'; +import type { Player } from 'shared/types/state'; type Props = { player: ?Player, diff --git a/components/effects/Quake.js b/web/components/effects/Quake.js similarity index 99% rename from components/effects/Quake.js rename to web/components/effects/Quake.js index 23e54ec7..36fbdeef 100644 --- a/components/effects/Quake.js +++ b/web/components/effects/Quake.js @@ -3,7 +3,7 @@ import React, { Component } from 'react'; import type { Node } from 'react'; -import type { Player } from '../../types/state'; +import type { Player } from 'shared/types/state'; type Props = { player1: ?Player, diff --git a/components/effects/Shake.js b/web/components/effects/Shake.js similarity index 98% rename from components/effects/Shake.js rename to web/components/effects/Shake.js index 2b6d6459..1716d32d 100644 --- a/components/effects/Shake.js +++ b/web/components/effects/Shake.js @@ -6,7 +6,7 @@ import type { Node } from 'react'; type Props = { time: ?number, - children: ?Node + children: Node }; export default class Shake extends Component { diff --git a/components/effects/__fixtures__/FadeIn/default.js b/web/components/effects/__fixtures__/FadeIn/default.js similarity index 74% rename from components/effects/__fixtures__/FadeIn/default.js rename to web/components/effects/__fixtures__/FadeIn/default.js index 55b7e603..27819673 100644 --- a/components/effects/__fixtures__/FadeIn/default.js +++ b/web/components/effects/__fixtures__/FadeIn/default.js @@ -1,7 +1,7 @@ // @flow import React from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import FadeIn from '../../../effects/FadeIn'; export default createFixture({ diff --git a/components/effects/__fixtures__/Flash/nay.js b/web/components/effects/__fixtures__/Flash/nay.js similarity index 72% rename from components/effects/__fixtures__/Flash/nay.js rename to web/components/effects/__fixtures__/Flash/nay.js index 2d5ad44c..51cf827e 100644 --- a/components/effects/__fixtures__/Flash/nay.js +++ b/web/components/effects/__fixtures__/Flash/nay.js @@ -1,8 +1,8 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankPlayer } from '../../../../reducers/game'; +import { getBlankPlayer } from 'shared/reducers/game'; import Flash from '../../../effects/Flash'; const user = getSampleUser(); diff --git a/components/effects/__fixtures__/Flash/yay.js b/web/components/effects/__fixtures__/Flash/yay.js similarity index 72% rename from components/effects/__fixtures__/Flash/yay.js rename to web/components/effects/__fixtures__/Flash/yay.js index 7a729cb2..62db8c09 100644 --- a/components/effects/__fixtures__/Flash/yay.js +++ b/web/components/effects/__fixtures__/Flash/yay.js @@ -1,8 +1,8 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankPlayer } from '../../../../reducers/game'; +import { getBlankPlayer } from 'shared/reducers/game'; import Flash from '../../../effects/Flash'; const user = getSampleUser(); diff --git a/components/effects/__fixtures__/Quake/player1-four-lines.js b/web/components/effects/__fixtures__/Quake/player1-four-lines.js similarity index 66% rename from components/effects/__fixtures__/Quake/player1-four-lines.js rename to web/components/effects/__fixtures__/Quake/player1-four-lines.js index 6ff0e92c..78a2c09d 100644 --- a/components/effects/__fixtures__/Quake/player1-four-lines.js +++ b/web/components/effects/__fixtures__/Quake/player1-four-lines.js @@ -2,7 +2,7 @@ import React from 'react'; import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankPlayer } from '../../../../reducers/game'; +import { getBlankPlayer } from 'shared/reducers/game'; import Quake from '../../../effects/Quake'; const user = getSampleUser(); @@ -17,9 +17,12 @@ export default { player1, children: (
- I Like To Move It Move It
- I Like To Move It Move It
- I Like To Move It Move
+ I Like To Move It Move It +
+ I Like To Move It Move It +
+ I Like To Move It Move +
It Ya Like To (MOVE IT!)
) diff --git a/components/effects/__fixtures__/Quake/player1-one-line.js b/web/components/effects/__fixtures__/Quake/player1-one-line.js similarity index 66% rename from components/effects/__fixtures__/Quake/player1-one-line.js rename to web/components/effects/__fixtures__/Quake/player1-one-line.js index 8e98ecad..149bb319 100644 --- a/components/effects/__fixtures__/Quake/player1-one-line.js +++ b/web/components/effects/__fixtures__/Quake/player1-one-line.js @@ -2,7 +2,7 @@ import React from 'react'; import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankPlayer } from '../../../../reducers/game'; +import { getBlankPlayer } from 'shared/reducers/game'; import Quake from '../../../effects/Quake'; const user = getSampleUser(); @@ -17,9 +17,12 @@ export default { player1, children: (
- I Like To Move It Move It
- I Like To Move It Move It
- I Like To Move It Move
+ I Like To Move It Move It +
+ I Like To Move It Move It +
+ I Like To Move It Move +
It Ya Like To (MOVE IT!)
) diff --git a/components/effects/__fixtures__/Quake/player2-three-lines.js b/web/components/effects/__fixtures__/Quake/player2-three-lines.js similarity index 66% rename from components/effects/__fixtures__/Quake/player2-three-lines.js rename to web/components/effects/__fixtures__/Quake/player2-three-lines.js index 88c23794..a2a3e1c9 100644 --- a/components/effects/__fixtures__/Quake/player2-three-lines.js +++ b/web/components/effects/__fixtures__/Quake/player2-three-lines.js @@ -2,7 +2,7 @@ import React from 'react'; import { getSampleUser, getSampleUser2 } from '../../../../utils/test-helpers'; -import { getBlankPlayer } from '../../../../reducers/game'; +import { getBlankPlayer } from 'shared/reducers/game'; import Quake from '../../../effects/Quake'; const user1 = getSampleUser(); @@ -21,10 +21,14 @@ export default { player2, children: (
- Jump around, jump up and get down
- Jump around, jump around
- Jump up and get down
- Jump up, jump up and get down
+ Jump around, jump up and get down +
+ Jump around, jump around +
+ Jump up and get down +
+ Jump up, jump up and get down +
Jump, jump
) diff --git a/components/effects/__fixtures__/Quake/player2-two-lines.js b/web/components/effects/__fixtures__/Quake/player2-two-lines.js similarity index 66% rename from components/effects/__fixtures__/Quake/player2-two-lines.js rename to web/components/effects/__fixtures__/Quake/player2-two-lines.js index 3e3c8ca3..f74218cd 100644 --- a/components/effects/__fixtures__/Quake/player2-two-lines.js +++ b/web/components/effects/__fixtures__/Quake/player2-two-lines.js @@ -2,7 +2,7 @@ import React from 'react'; import { getSampleUser, getSampleUser2 } from '../../../../utils/test-helpers'; -import { getBlankPlayer } from '../../../../reducers/game'; +import { getBlankPlayer } from 'shared/reducers/game'; import Quake from '../../../effects/Quake'; const user1 = getSampleUser(); @@ -21,10 +21,14 @@ export default { player2, children: (
- Jump around, jump up and get down
- Jump around, jump around
- Jump up and get down
- Jump up, jump up and get down
+ Jump around, jump up and get down +
+ Jump around, jump around +
+ Jump up and get down +
+ Jump up, jump up and get down +
Jump, jump
) diff --git a/components/effects/__fixtures__/Shake/shake.js b/web/components/effects/__fixtures__/Shake/shake.js similarity index 76% rename from components/effects/__fixtures__/Shake/shake.js rename to web/components/effects/__fixtures__/Shake/shake.js index e58c3511..e99ab916 100644 --- a/components/effects/__fixtures__/Shake/shake.js +++ b/web/components/effects/__fixtures__/Shake/shake.js @@ -1,7 +1,7 @@ // @flow import React from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Shake from '../../../effects/Shake'; export default createFixture({ diff --git a/components/effects/__fixtures__/Shake/still.js b/web/components/effects/__fixtures__/Shake/still.js similarity index 75% rename from components/effects/__fixtures__/Shake/still.js rename to web/components/effects/__fixtures__/Shake/still.js index da04e3b1..316b9fd3 100644 --- a/components/effects/__fixtures__/Shake/still.js +++ b/web/components/effects/__fixtures__/Shake/still.js @@ -1,7 +1,7 @@ // @flow import React from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Shake from '../../../effects/Shake'; export default createFixture({ diff --git a/components/pages/Dashboard.js b/web/components/pages/Dashboard.js similarity index 97% rename from components/pages/Dashboard.js rename to web/components/pages/Dashboard.js index 78d08a16..2cf6c406 100644 --- a/components/pages/Dashboard.js +++ b/web/components/pages/Dashboard.js @@ -5,8 +5,8 @@ import classNames from 'classnames'; import React, { Fragment, Component } from 'react'; import Link from 'next/link'; import { connect } from 'react-redux'; -import { GAME_INACTIVE_TIMEOUT } from '../../constants/timeouts'; -import { createTimeoutBumper } from '../../utils/timeout-bumper'; +import { GAME_INACTIVE_TIMEOUT } from 'shared/constants/timeouts'; +import { createTimeoutBumper } from 'shared/utils/timeout-bumper'; import { closeGame, removeGame } from '../../actions/global'; import { withSocket } from '../socket/SocketConnect'; import Title from '../Title'; @@ -23,8 +23,8 @@ import type { Games, Stats as StatsType, State -} from '../../types/state'; -import type { RoomId } from '../../types/api'; +} from 'shared/types/state'; +import type { RoomId } from 'shared/types/api'; const TRANSITION_TIMEOUT = 550; // CSS transition takes 500ms (added 50ms buffer) @@ -376,6 +376,7 @@ function mapStateToProps({ const mapDispatchToProps = { closeGame, removeGame }; -export default connect(mapStateToProps, mapDispatchToProps)( - withSocket(Dashboard) -); +export default connect( + mapStateToProps, + mapDispatchToProps +)(withSocket(Dashboard)); diff --git a/components/pages/Error.js b/web/components/pages/Error.js similarity index 94% rename from components/pages/Error.js rename to web/components/pages/Error.js index ea33a63c..d1e73593 100644 --- a/components/pages/Error.js +++ b/web/components/pages/Error.js @@ -8,7 +8,7 @@ import CopyButton from '../CopyButton'; import Screen from '../screens/Screen'; import GameFrame from './GameFrame'; -import type { ComponentError } from '../../types/error'; +import type { ComponentError } from 'shared/types/error'; type Props = { statusCode?: number, @@ -35,7 +35,8 @@ export default class Error extends Component {

Hmm...

- It's either gone or
+ It's either gone or +
it never was ¯\_(ツ)_/¯

@@ -83,7 +84,8 @@ export default class Error extends Component {

- At least this page
+ At least this page +
works, right?

diff --git a/components/pages/GameFrame.js b/web/components/pages/GameFrame.js similarity index 100% rename from components/pages/GameFrame.js rename to web/components/pages/GameFrame.js diff --git a/components/pages/NewGame.js b/web/components/pages/NewGame.js similarity index 91% rename from components/pages/NewGame.js rename to web/components/pages/NewGame.js index 4af9d875..7c758c86 100644 --- a/components/pages/NewGame.js +++ b/web/components/pages/NewGame.js @@ -9,8 +9,8 @@ import Title from '../Title'; import Auth from '../screens/Auth'; import GameFrame from './GameFrame'; -import type { User, State } from '../../types/state'; -import type { UnauthAction } from '../../types/actions'; +import type { User, State } from 'shared/types/state'; +import type { UnauthAction } from 'shared/types/actions'; type Props = { curUser: ?User, @@ -96,4 +96,7 @@ const mapDispatchToProps = { unauth }; -export default connect(mapStateToProps, mapDispatchToProps)(NewGame); +export default connect( + mapStateToProps, + mapDispatchToProps +)(NewGame); diff --git a/components/pages/__fixtures__/Dashboard/game-added.js b/web/components/pages/__fixtures__/Dashboard/game-added.js similarity index 70% rename from components/pages/__fixtures__/Dashboard/game-added.js rename to web/components/pages/__fixtures__/Dashboard/game-added.js index b9b48596..4996e696 100644 --- a/components/pages/__fixtures__/Dashboard/game-added.js +++ b/web/components/pages/__fixtures__/Dashboard/game-added.js @@ -1,9 +1,8 @@ // @flow -import { Component } from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser, doAfter } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; import type { ElementRef } from 'react'; @@ -19,7 +18,7 @@ export default createFixture({ games: {} }, - async init({ compRef }: { compRef: ElementRef }) { + async init({ compRef }: { compRef: ElementRef }) { const { dispatch } = compRef.context.store; await doAfter(200, () => { diff --git a/components/pages/__fixtures__/Dashboard/game.js b/web/components/pages/__fixtures__/Dashboard/game.js similarity index 72% rename from components/pages/__fixtures__/Dashboard/game.js rename to web/components/pages/__fixtures__/Dashboard/game.js index f80dd9f5..78e1cd93 100644 --- a/components/pages/__fixtures__/Dashboard/game.js +++ b/web/components/pages/__fixtures__/Dashboard/game.js @@ -1,8 +1,8 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; const user = getSampleUser(); diff --git a/components/pages/__fixtures__/Dashboard/games-added.js b/web/components/pages/__fixtures__/Dashboard/games-added.js similarity index 78% rename from components/pages/__fixtures__/Dashboard/games-added.js rename to web/components/pages/__fixtures__/Dashboard/games-added.js index b5120c27..c43b7dfa 100644 --- a/components/pages/__fixtures__/Dashboard/games-added.js +++ b/web/components/pages/__fixtures__/Dashboard/games-added.js @@ -1,9 +1,8 @@ // @flow -import { Component } from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser, doAfter } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; import type { ElementRef } from 'react'; @@ -21,7 +20,7 @@ export default createFixture({ games: {} }, - async init({ compRef }: { compRef: ElementRef }) { + async init({ compRef }: { compRef: ElementRef }) { const { dispatch } = compRef.context.store; dispatch({ diff --git a/components/pages/__fixtures__/Dashboard/games-removed-and-added.js b/web/components/pages/__fixtures__/Dashboard/games-removed-and-added.js similarity index 80% rename from components/pages/__fixtures__/Dashboard/games-removed-and-added.js rename to web/components/pages/__fixtures__/Dashboard/games-removed-and-added.js index 018959de..cf5a442c 100644 --- a/components/pages/__fixtures__/Dashboard/games-removed-and-added.js +++ b/web/components/pages/__fixtures__/Dashboard/games-removed-and-added.js @@ -1,9 +1,8 @@ // @flow -import { Component } from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser, doAfter } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; import type { ElementRef } from 'react'; @@ -24,7 +23,7 @@ export default createFixture({ } }, - async init({ compRef }: { compRef: ElementRef }) { + async init({ compRef }: { compRef: ElementRef }) { const { dispatch } = compRef.context.store; dispatch({ diff --git a/components/pages/__fixtures__/Dashboard/games-removed.js b/web/components/pages/__fixtures__/Dashboard/games-removed.js similarity index 80% rename from components/pages/__fixtures__/Dashboard/games-removed.js rename to web/components/pages/__fixtures__/Dashboard/games-removed.js index 068dfb0c..700b86dc 100644 --- a/components/pages/__fixtures__/Dashboard/games-removed.js +++ b/web/components/pages/__fixtures__/Dashboard/games-removed.js @@ -1,9 +1,8 @@ // @flow -import { Component } from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser, doAfter } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; import type { ElementRef } from 'react'; @@ -25,7 +24,7 @@ export default createFixture({ } }, - async init({ compRef }: { compRef: ElementRef }) { + async init({ compRef }: { compRef: ElementRef }) { const { dispatch } = compRef.context.store; dispatch({ diff --git a/components/pages/__fixtures__/Dashboard/mixed-games-removed.js b/web/components/pages/__fixtures__/Dashboard/mixed-games-removed.js similarity index 79% rename from components/pages/__fixtures__/Dashboard/mixed-games-removed.js rename to web/components/pages/__fixtures__/Dashboard/mixed-games-removed.js index 93c42e07..15ae7e6c 100644 --- a/components/pages/__fixtures__/Dashboard/mixed-games-removed.js +++ b/web/components/pages/__fixtures__/Dashboard/mixed-games-removed.js @@ -1,13 +1,12 @@ // @flow -import { Component } from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser, getSampleUser2, doAfter } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; import type { ElementRef } from 'react'; @@ -29,7 +28,7 @@ export default createFixture({ } }, - async init({ compRef }: { compRef: ElementRef }) { + async init({ compRef }: { compRef: ElementRef }) { const { dispatch } = compRef.context.store; await doAfter(200, () => { diff --git a/components/pages/__fixtures__/Dashboard/mixed-games.js b/web/components/pages/__fixtures__/Dashboard/mixed-games.js similarity index 80% rename from components/pages/__fixtures__/Dashboard/mixed-games.js rename to web/components/pages/__fixtures__/Dashboard/mixed-games.js index 5aeaef29..622c30d9 100644 --- a/components/pages/__fixtures__/Dashboard/mixed-games.js +++ b/web/components/pages/__fixtures__/Dashboard/mixed-games.js @@ -1,8 +1,8 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser, getSampleUser2 } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; const user1 = getSampleUser(); diff --git a/components/pages/__fixtures__/Dashboard/no-games.js b/web/components/pages/__fixtures__/Dashboard/no-games.js similarity index 69% rename from components/pages/__fixtures__/Dashboard/no-games.js rename to web/components/pages/__fixtures__/Dashboard/no-games.js index 39919509..3a082b60 100644 --- a/components/pages/__fixtures__/Dashboard/no-games.js +++ b/web/components/pages/__fixtures__/Dashboard/no-games.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Dashboard from '../../Dashboard'; export default createFixture({ diff --git a/components/pages/__fixtures__/Dashboard/own-game-removed.js b/web/components/pages/__fixtures__/Dashboard/own-game-removed.js similarity index 72% rename from components/pages/__fixtures__/Dashboard/own-game-removed.js rename to web/components/pages/__fixtures__/Dashboard/own-game-removed.js index 6088e40b..70d2bf9d 100644 --- a/components/pages/__fixtures__/Dashboard/own-game-removed.js +++ b/web/components/pages/__fixtures__/Dashboard/own-game-removed.js @@ -1,9 +1,8 @@ // @flow -import { Component } from 'react'; -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser, doAfter } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; import type { ElementRef } from 'react'; @@ -22,7 +21,7 @@ export default createFixture({ } }, - async init({ compRef }: { compRef: ElementRef }) { + async init({ compRef }: { compRef: ElementRef }) { const { dispatch } = compRef.context.store; await doAfter(200, () => { diff --git a/components/pages/__fixtures__/Dashboard/own-game.js b/web/components/pages/__fixtures__/Dashboard/own-game.js similarity index 74% rename from components/pages/__fixtures__/Dashboard/own-game.js rename to web/components/pages/__fixtures__/Dashboard/own-game.js index 9f5eeff0..7eccf9a8 100644 --- a/components/pages/__fixtures__/Dashboard/own-game.js +++ b/web/components/pages/__fixtures__/Dashboard/own-game.js @@ -1,8 +1,8 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import { getSampleUser } from '../../../../utils/test-helpers'; -import { getBlankGame } from '../../../../reducers/game'; +import { getBlankGame } from 'shared/reducers/game'; import Dashboard from '../../Dashboard'; const user1 = getSampleUser(); diff --git a/components/pages/__fixtures__/Error/component-error.js b/web/components/pages/__fixtures__/Error/component-error.js similarity index 92% rename from components/pages/__fixtures__/Error/component-error.js rename to web/components/pages/__fixtures__/Error/component-error.js index e3461d03..088c502c 100644 --- a/components/pages/__fixtures__/Error/component-error.js +++ b/web/components/pages/__fixtures__/Error/component-error.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Error from '../../Error'; export default createFixture({ diff --git a/components/pages/__fixtures__/Error/not-found.js b/web/components/pages/__fixtures__/Error/not-found.js similarity index 67% rename from components/pages/__fixtures__/Error/not-found.js rename to web/components/pages/__fixtures__/Error/not-found.js index 3f514143..b1b6144d 100644 --- a/components/pages/__fixtures__/Error/not-found.js +++ b/web/components/pages/__fixtures__/Error/not-found.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Error from '../../Error'; export default createFixture({ diff --git a/components/pages/__fixtures__/Error/unknown.js b/web/components/pages/__fixtures__/Error/unknown.js similarity index 62% rename from components/pages/__fixtures__/Error/unknown.js rename to web/components/pages/__fixtures__/Error/unknown.js index 15640a92..4471786c 100644 --- a/components/pages/__fixtures__/Error/unknown.js +++ b/web/components/pages/__fixtures__/Error/unknown.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import Error from '../../Error'; export default createFixture({ diff --git a/components/pages/__fixtures__/NewGame/default.js b/web/components/pages/__fixtures__/NewGame/default.js similarity index 79% rename from components/pages/__fixtures__/NewGame/default.js rename to web/components/pages/__fixtures__/NewGame/default.js index 8ed60d33..fb941f4d 100644 --- a/components/pages/__fixtures__/NewGame/default.js +++ b/web/components/pages/__fixtures__/NewGame/default.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import NewGame from '../../NewGame'; // NOTE: A authenticated fixture for NewGame does not exist because it would diff --git a/components/pages/__fixtures__/NewGame/loading.js b/web/components/pages/__fixtures__/NewGame/loading.js similarity index 79% rename from components/pages/__fixtures__/NewGame/loading.js rename to web/components/pages/__fixtures__/NewGame/loading.js index 72974c8b..ac725471 100644 --- a/components/pages/__fixtures__/NewGame/loading.js +++ b/web/components/pages/__fixtures__/NewGame/loading.js @@ -1,6 +1,6 @@ // @flow -import { createFixture } from '../../../../utils/create-fixture'; +import { createFixture } from 'react-cosmos'; import NewGame from '../../NewGame'; // NOTE: A authenticated fixture for NewGame does not exist because it would diff --git a/components/screens/Auth.js b/web/components/screens/Auth.js similarity index 96% rename from components/screens/Auth.js rename to web/components/screens/Auth.js index 9cffc7aa..c79aca36 100644 --- a/components/screens/Auth.js +++ b/web/components/screens/Auth.js @@ -3,7 +3,7 @@ import React, { Fragment, Component } from 'react'; import { connect } from 'react-redux'; import { auth } from '../../actions/global'; -import { MAX_NAME_LENGTH } from '../../constants/user'; +import { MAX_NAME_LENGTH } from 'shared/constants/user'; import { createUserSession } from '../../utils/api'; import Button from '../Button'; import Screen from './Screen'; @@ -12,7 +12,7 @@ import Multiplayer from './onboarding/Multiplayer'; import ZeroSum from './onboarding/ZeroSum'; import HowToPlay from './onboarding/HowToPlay'; -import type { User, State } from '../../types/state'; +import type { User, State } from 'shared/types/state'; type Props = { jsReady: boolean, @@ -206,4 +206,7 @@ const mapDispatchToProps = { auth }; -export default connect(mapStateToProps, mapDispatchToProps)(Auth); +export default connect( + mapStateToProps, + mapDispatchToProps +)(Auth); diff --git a/components/screens/GameFull.js b/web/components/screens/GameFull.js similarity index 91% rename from components/screens/GameFull.js rename to web/components/screens/GameFull.js index 41ae9ddf..e25726e5 100644 --- a/components/screens/GameFull.js +++ b/web/components/screens/GameFull.js @@ -23,10 +23,12 @@ export default class GameFull extends Component { Game full.

- You can watch, or
+ You can watch, or +
join another game - . + + .

} diff --git a/components/screens/GameOver.js b/web/components/screens/GameOver.js similarity index 89% rename from components/screens/GameOver.js rename to web/components/screens/GameOver.js index 4317e616..4a5afaef 100644 --- a/components/screens/GameOver.js +++ b/web/components/screens/GameOver.js @@ -1,13 +1,13 @@ // @flow import React, { Fragment, Component } from 'react'; -import { getCurPlayer, getOtherPlayer } from '../../reducers/game'; +import { getCurPlayer, getOtherPlayer } from 'shared/reducers/game'; import Shake from '../effects/Shake'; import Button from '../Button'; import Invite from './Invite'; import Screen from './Screen'; -import type { User, Player, Game } from '../../types/state'; +import type { User, Player, Game } from 'shared/types/state'; type Props = { disabled: boolean, @@ -56,7 +56,9 @@ function getMultiMessage(curPlayer: Player, otherPlayer: Player) { return (

- Oh well... better luck
next time. + Oh well... better luck +
+ next time.

{bestOutOfMsg} diff --git a/components/screens/GetReady.js b/web/components/screens/GetReady.js similarity index 85% rename from components/screens/GetReady.js rename to web/components/screens/GetReady.js index 58032450..13f4e8d6 100644 --- a/components/screens/GetReady.js +++ b/web/components/screens/GetReady.js @@ -5,7 +5,7 @@ import Shake from '../effects/Shake'; import Button from '../Button'; import Screen from './Screen'; -import type { Player } from '../../types/state'; +import type { Player } from 'shared/types/state'; type Props = { disabled: boolean, @@ -23,7 +23,9 @@ export default class GetReady extends Component { message={

- Game starts when
you're both ready. + Game starts when +
+ you're both ready.

Good luck! diff --git a/components/screens/Invite.js b/web/components/screens/Invite.js similarity index 82% rename from components/screens/Invite.js rename to web/components/screens/Invite.js index 0e56b4db..9e88b290 100644 --- a/components/screens/Invite.js +++ b/web/components/screens/Invite.js @@ -5,7 +5,7 @@ import Button from '../Button'; import CopyGameLinkButton from '../CopyGameLinkButton'; import Screen from './Screen'; -import type { GameId } from '../../types/state'; +import type { GameId } from 'shared/types/state'; type Props = { disabled: boolean, @@ -25,15 +25,19 @@ export default class Invite extends Component {

Playing with a friend -
rival is more fun! +
+ rival is more fun!

- Send the link and
warm up until the
other person - arrives. + Send the link and +
+ warm up until the +
+ other person arrives.