scrabble-solver 2.18.0 → 2.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nx/workspace-data/d/server-process.json +2 -2
- package/.nx/workspace-data/file-map.json +1652 -1412
- package/.nx/workspace-data/lockfile-dependencies.hash +1 -1
- package/.nx/workspace-data/lockfile-nodes.hash +1 -1
- package/.nx/workspace-data/nx_files.nxt +0 -0
- package/.nx/workspace-data/parsed-lock-file.dependencies.json +184 -209
- package/.nx/workspace-data/parsed-lock-file.nodes.json +374 -419
- package/.nx/workspace-data/project-graph.json +669 -670
- package/.nx/workspace-data/source-maps.json +236 -0
- package/CLAUDE.md +13 -11
- package/README.md +2 -2
- package/bun.lock +115 -130
- package/e2e/app.spec.ts +1 -1
- package/e2e/bugs/398-digraphs-in-created-words.spec.ts +2 -2
- package/e2e/bugs/445-tile-text-selection.spec.ts +38 -0
- package/e2e/bugs/451-results-list-gap-hover.spec.ts +35 -0
- package/e2e/bugs/452-stale-translations-cache.spec.ts +32 -0
- package/e2e/features/427-highlight-created-words.spec.ts +86 -0
- package/e2e/features/430-highlight-unreachable-cells-results.spec.ts +75 -0
- package/e2e/features/91-hover-remaining-tile-highlights.spec.ts +22 -0
- package/e2e/features/result-candidate-picker.spec.ts +21 -0
- package/e2e/features/results-interactions.spec.ts +170 -0
- package/e2e/features/solver-paths.spec.ts +2 -2
- package/e2e/features/words-dictionary-search.spec.ts +36 -0
- package/e2e/features/words-empty-state.spec.ts +42 -0
- package/e2e/features/words-interactions.spec.ts +179 -0
- package/e2e/features/words-preview.spec.ts +140 -0
- package/e2e/features/words-table-filtering.spec.ts +22 -0
- package/e2e/features/words-table-sorting.spec.ts +33 -0
- package/e2e/lib/actions.ts +76 -6
- package/e2e/lib/selectors.ts +40 -3
- package/lerna.json +1 -1
- package/package.json +24 -44
- package/packages/configs/package.json +13 -4
- package/packages/constants/package.json +6 -2
- package/packages/dictionaries/package.json +12 -5
- package/packages/logger/package.json +7 -2
- package/packages/scrabble-solver/.next/BUILD_ID +1 -1
- package/packages/scrabble-solver/.next/build-manifest.json +15 -15
- package/packages/scrabble-solver/.next/cache/.previewinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.rscinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
- package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/diagnostics/framework.json +1 -1
- package/packages/scrabble-solver/.next/dynamic-css-manifest.json +2 -2
- package/packages/scrabble-solver/.next/prerender-manifest.json +4 -4
- package/packages/scrabble-solver/.next/react-loadable-manifest.json +37 -37
- package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/chunks/309.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/344.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/371.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/392.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/465.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/546.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/641.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/67.js +1 -0
- package/packages/scrabble-solver/.next/server/chunks/712.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/846.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/886.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/942.js +1 -0
- package/packages/scrabble-solver/.next/server/chunks/953.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/961.js +1 -1
- package/packages/scrabble-solver/.next/server/dynamic-css-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/500.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/_app.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_document.js +2 -2
- package/packages/scrabble-solver/.next/server/pages/_document.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_error.js +2 -2
- package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/solve.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/solve.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/verify.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/verify.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/index.js +4 -4
- package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/not-found.html +3 -2
- package/packages/scrabble-solver/.next/server/pages/not-found.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/static/chunks/100.305bdf9c75b1758f.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/256.66ff9fb6d7db9ec7.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{307.67f52f13e3d60d4e.js → 307.89e6100f58443679.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{363.01eed3233f92b6a4.js → 363.cec65b1f9668a75e.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{422.1559ae6756912ca5.js → 422.3e55b4c94e328701.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{663.d2c9ca36b26695b8.js → 663.bd2c45413fbca518.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/693.677c88e0eb1340b5.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{820.97b82f751ca49579.js → 820.823e9e885ebb66af.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/827.c81b92b383a748c9.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{865.a9b563a45848a83c.js → 865.59baba8296c9b116.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/912.077603e4f0bc6cca.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{939.19b33a3d3c351d73.js → 939.2ad86b50405c7897.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/980.7ce17464fc56648a.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/{main-b92e08f3fc96dd8d.js → main-7e52da35a4beea0b.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-f9ec81278ffa7b1a.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/index-b5bf018100015277.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/not-found-a59f9deeeff63d17.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/webpack-9f5c9d275348829b.js +1 -0
- package/packages/scrabble-solver/.next/static/css/65bcc9440e067113.css +1 -0
- package/packages/scrabble-solver/.next/static/css/{abc2425d3ba607bc.css → 92f85ce358a0a468.css} +2 -1
- package/packages/scrabble-solver/.next/static/css/a691348b788f8bc0.css +1 -0
- package/packages/scrabble-solver/.next/static/css/cd4d7f2458487399.css +1 -0
- package/packages/scrabble-solver/.next/static/{FL82obwzFHRzvV6z76I-U → nvGZh1gPuX98L07YmxlYD}/_buildManifest.js +1 -1
- package/packages/scrabble-solver/.next/trace +21 -21
- package/packages/scrabble-solver/.next/trace-build +1 -1
- package/packages/scrabble-solver/AGENTS.md +9 -0
- package/packages/scrabble-solver/CLAUDE.md +1 -0
- package/packages/scrabble-solver/package.json +22 -13
- package/packages/scrabble-solver/public/robots.txt +1 -0
- package/packages/scrabble-solver/public/service-worker.js +1 -1
- package/packages/scrabble-solver/public/site.webmanifest +14 -0
- package/packages/scrabble-solver/src/components/Board/Board.tsx +3 -1
- package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +26 -20
- package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +4 -4
- package/packages/scrabble-solver/src/components/Board/lib.test.ts +106 -0
- package/packages/scrabble-solver/src/components/Board/lib.ts +34 -3
- package/packages/scrabble-solver/src/components/Board/selectors.ts +17 -5
- package/packages/scrabble-solver/src/components/Button/Button.module.scss +1 -1
- package/packages/scrabble-solver/src/components/Modal/Modal.module.scss +0 -4
- package/packages/scrabble-solver/src/components/Results/Header.tsx +30 -5
- package/packages/scrabble-solver/src/components/Results/Result.tsx +45 -55
- package/packages/scrabble-solver/src/components/Results/Results.module.scss +0 -126
- package/packages/scrabble-solver/src/components/Results/Results.module.scss.d.ts +0 -10
- package/packages/scrabble-solver/src/components/Results/Results.tsx +25 -5
- package/packages/scrabble-solver/src/components/Solver/Solver.module.scss +4 -4
- package/packages/scrabble-solver/src/components/Solver/Solver.tsx +5 -3
- package/packages/scrabble-solver/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.module.scss +5 -1
- package/packages/scrabble-solver/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.module.scss.d.ts +1 -0
- package/packages/scrabble-solver/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.tsx +5 -2
- package/packages/scrabble-solver/src/components/Table/Cell.tsx +42 -0
- package/packages/scrabble-solver/src/components/Table/Header.tsx +11 -0
- package/packages/scrabble-solver/src/components/{Results → Table}/HeaderButton.tsx +22 -14
- package/packages/scrabble-solver/src/components/Table/Row.tsx +59 -0
- package/packages/scrabble-solver/src/components/{ResultsInput/ResultsInput.tsx → Table/Search.tsx} +9 -11
- package/packages/scrabble-solver/src/components/Table/Table.module.scss +147 -0
- package/packages/scrabble-solver/src/components/Table/Table.module.scss.d.ts +19 -0
- package/packages/scrabble-solver/src/components/Table/index.ts +5 -0
- package/packages/scrabble-solver/src/components/Tile/Tile.module.scss +2 -1
- package/packages/scrabble-solver/src/hooks/useColumns.ts +7 -5
- package/packages/scrabble-solver/src/hooks/useIsCompactLayout.ts +14 -0
- package/packages/scrabble-solver/src/i18n/languages/english.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/french.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/german.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/persian.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/polish.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/romanian.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/spanish.json +6 -1
- package/packages/scrabble-solver/src/i18n/languages/turkish.json +6 -1
- package/packages/scrabble-solver/src/icons/QuestionSquare.svg +5 -0
- package/packages/scrabble-solver/src/lib/createCoordinatesComparator.ts +23 -0
- package/packages/scrabble-solver/src/lib/createKeyComparator.ts +1 -4
- package/packages/scrabble-solver/src/lib/createSortComparator.ts +22 -0
- package/packages/scrabble-solver/src/lib/getCoordinates.test.ts +21 -0
- package/packages/scrabble-solver/src/lib/getCoordinates.ts +16 -0
- package/packages/scrabble-solver/src/lib/getNextSort.ts +12 -0
- package/packages/scrabble-solver/src/lib/waitForIdleOrFirstIntent.ts +19 -8
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/RemainingTilesModal.tsx +3 -1
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/components/Character/Character.tsx +8 -9
- package/packages/scrabble-solver/src/modals/ResultsModal/ResultsModal.tsx +14 -10
- package/packages/scrabble-solver/src/modals/WordsModal/WordsModal.module.scss +16 -27
- package/packages/scrabble-solver/src/modals/WordsModal/WordsModal.module.scss.d.ts +3 -6
- package/packages/scrabble-solver/src/modals/WordsModal/WordsModal.tsx +56 -42
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordRow.tsx +92 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordsTable.module.scss +69 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordsTable.module.scss.d.ts +16 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/WordsTable.tsx +137 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/WordsTable/index.ts +1 -0
- package/packages/scrabble-solver/src/modals/WordsModal/components/index.ts +1 -0
- package/packages/scrabble-solver/src/pages/_app.tsx +40 -76
- package/packages/scrabble-solver/src/pages/_document.tsx +21 -19
- package/packages/scrabble-solver/src/pages/api/verify.ts +7 -6
- package/packages/scrabble-solver/src/pages/index.tsx +58 -6
- package/packages/scrabble-solver/src/pages/not-found.tsx +13 -2
- package/packages/scrabble-solver/src/parameters/index.ts +9 -0
- package/packages/scrabble-solver/src/sdk/verify.ts +3 -2
- package/packages/scrabble-solver/src/solver-worker/client.test.ts +10 -3
- package/packages/scrabble-solver/src/solver-worker/index.worker.ts +7 -7
- package/packages/scrabble-solver/src/solver-worker/messages.ts +3 -3
- package/packages/scrabble-solver/src/state/hoveredWord/index.ts +4 -0
- package/packages/scrabble-solver/src/state/hoveredWord/initialState.ts +5 -0
- package/packages/scrabble-solver/src/state/hoveredWord/selectors.ts +5 -0
- package/packages/scrabble-solver/src/state/hoveredWord/slice.ts +18 -0
- package/packages/scrabble-solver/src/state/hoveredWord/types.ts +5 -0
- package/packages/scrabble-solver/src/state/index.ts +1 -0
- package/packages/scrabble-solver/src/state/localStorage.ts +13 -2
- package/packages/scrabble-solver/src/state/results/lib.ts +9 -26
- package/packages/scrabble-solver/src/state/results/selectors.ts +9 -1
- package/packages/scrabble-solver/src/state/results/slice.ts +4 -16
- package/packages/scrabble-solver/src/state/sagas.ts +30 -5
- package/packages/scrabble-solver/src/state/selectors.ts +18 -1
- package/packages/scrabble-solver/src/state/store.ts +2 -0
- package/packages/scrabble-solver/src/state/types.ts +2 -0
- package/packages/scrabble-solver/src/state/verify/initialState.ts +7 -0
- package/packages/scrabble-solver/src/state/verify/lib.test.ts +55 -0
- package/packages/scrabble-solver/src/state/verify/lib.ts +49 -0
- package/packages/scrabble-solver/src/state/verify/selectors.ts +37 -0
- package/packages/scrabble-solver/src/state/verify/slice.ts +13 -2
- package/packages/scrabble-solver/src/state/verify/types.ts +6 -2
- package/packages/scrabble-solver/src/styles/_tokens.scss +2 -0
- package/packages/scrabble-solver/src/styles/mixins.scss +5 -0
- package/packages/scrabble-solver/src/styles/variables.module.scss +1 -0
- package/packages/scrabble-solver/src/styles/variables.module.scss.d.ts +1 -0
- package/packages/scrabble-solver/src/styles/variables.scss +1 -1
- package/packages/scrabble-solver/src/types/index.ts +24 -11
- package/packages/scrabble-solver/tsconfig.tsbuildinfo +1 -1
- package/packages/solver/package.json +14 -6
- package/packages/types/build/Bingo.d.ts +0 -3
- package/packages/types/build/Bingo.js +0 -14
- package/packages/types/build/Board.d.ts +3 -1
- package/packages/types/build/Board.js +5 -40
- package/packages/types/build/BoardJson.d.ts +0 -1
- package/packages/types/build/BoardJson.js +0 -19
- package/packages/types/build/BoardWord.d.ts +7 -0
- package/packages/types/build/BoardWord.js +2 -0
- package/packages/types/build/CellJson.d.ts +0 -1
- package/packages/types/build/CellJson.js +0 -11
- package/packages/types/build/Game.d.ts +0 -1
- package/packages/types/build/Game.js +1 -4
- package/packages/types/build/Locale.d.ts +0 -1
- package/packages/types/build/Locale.js +1 -4
- package/packages/types/build/Result.js +3 -3
- package/packages/types/build/TileJson.d.ts +0 -1
- package/packages/types/build/TileJson.js +0 -6
- package/packages/types/build/index.d.ts +9 -8
- package/packages/types/build/index.js +14 -17
- package/packages/types/build/lib/getBoardWords.d.ts +3 -0
- package/packages/types/build/lib/getBoardWords.js +10 -0
- package/packages/types/build/lib/getCells.d.ts +4 -0
- package/packages/types/build/lib/getCells.js +27 -0
- package/packages/types/build/lib/getCollidingWords.d.ts +3 -0
- package/packages/types/build/lib/getCollidingWords.js +19 -0
- package/packages/types/build/lib/getCollision.d.ts +3 -0
- package/packages/types/build/lib/getCollision.js +31 -0
- package/packages/types/build/lib/getCollisions.d.ts +3 -0
- package/packages/types/build/lib/getCollisions.js +17 -0
- package/packages/types/build/lib/getPlacedCell.d.ts +3 -0
- package/packages/types/build/lib/getPlacedCell.js +10 -0
- package/packages/types/build/lib/getWordThrough.d.ts +4 -0
- package/packages/types/build/lib/getWordThrough.js +23 -0
- package/packages/types/build/lib/getWordsInRows.d.ts +8 -0
- package/packages/types/build/lib/getWordsInRows.js +29 -0
- package/packages/types/build/lib/index.d.ts +5 -0
- package/packages/types/build/lib/index.js +21 -0
- package/packages/types/build/lib/isSameBoardWord.d.ts +2 -0
- package/packages/types/build/lib/isSameBoardWord.js +6 -0
- package/packages/types/build/lib/toBoardWord.d.ts +4 -0
- package/packages/types/build/lib/toBoardWord.js +11 -0
- package/packages/types/build/lib/transpose.d.ts +1 -0
- package/packages/types/build/lib/transpose.js +16 -0
- package/packages/types/build/type-guards/index.d.ts +10 -0
- package/packages/types/build/type-guards/index.js +23 -0
- package/packages/types/build/type-guards/isBingo.d.ts +2 -0
- package/packages/types/build/type-guards/isBingo.js +9 -0
- package/packages/types/build/type-guards/isBoardJson.d.ts +2 -0
- package/packages/types/build/type-guards/isBoardJson.js +21 -0
- package/packages/types/build/type-guards/isCellJson.d.ts +2 -0
- package/packages/types/build/type-guards/isCellJson.js +13 -0
- package/packages/types/build/type-guards/isGame.d.ts +2 -0
- package/packages/types/build/type-guards/isGame.js +7 -0
- package/packages/types/build/type-guards/isLocale.d.ts +2 -0
- package/packages/types/build/type-guards/isLocale.js +7 -0
- package/packages/types/build/type-guards/isMultiplierBingo.d.ts +2 -0
- package/packages/types/build/type-guards/isMultiplierBingo.js +8 -0
- package/packages/types/build/type-guards/isScoreBingo.d.ts +2 -0
- package/packages/types/build/type-guards/isScoreBingo.js +8 -0
- package/packages/types/build/type-guards/isTileJson.d.ts +2 -0
- package/packages/types/build/type-guards/isTileJson.js +8 -0
- package/packages/types/package.json +10 -3
- package/packages/types/src/Bingo.ts +0 -14
- package/packages/types/src/Board.test.ts +85 -0
- package/packages/types/src/Board.ts +8 -49
- package/packages/types/src/BoardJson.ts +1 -21
- package/packages/types/src/BoardWord.ts +8 -0
- package/packages/types/src/CellJson.ts +1 -12
- package/packages/types/src/Game.ts +0 -4
- package/packages/types/src/Locale.ts +0 -4
- package/packages/types/src/Result.ts +3 -3
- package/packages/types/src/TileJson.ts +0 -6
- package/packages/types/src/index.ts +20 -8
- package/packages/types/src/lib/getBoardWords.ts +11 -0
- package/packages/types/src/lib/getCells.test.ts +127 -0
- package/packages/types/src/lib/getCells.ts +31 -0
- package/packages/types/src/lib/getCollidingWords.ts +25 -0
- package/packages/types/src/lib/getCollision.ts +38 -0
- package/packages/types/src/lib/getCollisions.test.ts +82 -0
- package/packages/types/src/lib/getCollisions.ts +22 -0
- package/packages/types/src/lib/getPlacedCell.ts +9 -0
- package/packages/types/src/lib/getWordThrough.ts +30 -0
- package/packages/types/src/lib/getWordsInRows.ts +34 -0
- package/packages/types/src/lib/index.ts +5 -0
- package/packages/types/src/lib/isSameBoardWord.ts +5 -0
- package/packages/types/src/lib/toBoardWord.ts +12 -0
- package/packages/types/src/lib/transpose.ts +15 -0
- package/packages/types/src/type-guards/index.ts +10 -0
- package/packages/types/src/type-guards/isBingo.ts +8 -0
- package/packages/types/src/type-guards/isBoardJson.test.ts +33 -0
- package/packages/types/src/type-guards/isBoardJson.ts +23 -0
- package/packages/types/src/type-guards/isCellJson.ts +14 -0
- package/packages/types/src/type-guards/isGame.ts +5 -0
- package/packages/types/src/type-guards/isLocale.ts +5 -0
- package/packages/types/src/type-guards/isMultiplierBingo.ts +7 -0
- package/packages/types/src/type-guards/isScoreBingo.ts +7 -0
- package/packages/types/src/type-guards/isTileJson.ts +7 -0
- package/packages/word-definitions/package.json +9 -3
- package/packages/word-lists/package.json +11 -3
- package/playwright-report/index.html +1 -1
- package/screencast.gif +0 -0
- package/packages/scrabble-solver/.next/server/chunks/316.js +0 -1
- package/packages/scrabble-solver/.next/server/chunks/916.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/106.e414e88694add27f.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/127.125d896a19061d71.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/18.8b91e137d239e15c.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/583.7a46807be14c377e.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/711.ba7b8f900dfd40d0.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/912.ff8037ba9d4db5c8.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-ba5d628e81a15461.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/index-5f9fa6ac3cd3d97b.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/not-found-23d61fd3ed791cad.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/webpack-e34c3ae12275e978.js +0 -1
- package/packages/scrabble-solver/.next/static/css/b74cd7de82dabcdd.css +0 -1
- package/packages/scrabble-solver/.next/static/css/c403ce739a9c0d83.css +0 -1
- package/packages/scrabble-solver/.next/static/css/fbfdce70731d0d2b.css +0 -1
- package/packages/scrabble-solver/src/components/Results/Cell.tsx +0 -32
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.module.scss +0 -12
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.module.scss.d.ts +0 -7
- package/packages/scrabble-solver/src/components/ResultsInput/index.ts +0 -1
- package/packages/scrabble-solver/src/components/SeoMessage/SeoMessage.tsx +0 -18
- package/packages/scrabble-solver/src/components/SeoMessage/index.ts +0 -1
- package/packages/types/build/readResultCells.d.ts +0 -5
- package/packages/types/build/readResultCells.js +0 -75
- package/packages/types/src/readResultCells.test.ts +0 -140
- package/packages/types/src/readResultCells.ts +0 -90
- /package/packages/scrabble-solver/.next/static/{FL82obwzFHRzvV6z76I-U → nvGZh1gPuX98L07YmxlYD}/_ssgManifest.js +0 -0
- /package/packages/types/build/{isError.d.ts → type-guards/isError.d.ts} +0 -0
- /package/packages/types/build/{isError.js → type-guards/isError.js} +0 -0
- /package/packages/types/build/{isObject.d.ts → type-guards/isObject.d.ts} +0 -0
- /package/packages/types/build/{isObject.js → type-guards/isObject.js} +0 -0
- /package/packages/types/src/{isError.ts → type-guards/isError.ts} +0 -0
- /package/packages/types/src/{isObject.ts → type-guards/isObject.ts} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { Board } from '../Board';
|
|
4
|
+
import { Cell } from '../Cell';
|
|
5
|
+
import { Tile } from '../Tile';
|
|
6
|
+
|
|
7
|
+
import { getCells } from './getCells';
|
|
8
|
+
|
|
9
|
+
describe('getCells', () => {
|
|
10
|
+
it('reads a word placed on an empty board', () => {
|
|
11
|
+
const board = Board.fromStringArray([' ', ' ', ' ', ' ', ' ']);
|
|
12
|
+
const cells = getCells(board, {
|
|
13
|
+
blankIndices: [],
|
|
14
|
+
id: 0,
|
|
15
|
+
isHorizontal: true,
|
|
16
|
+
points: 0,
|
|
17
|
+
tiles: ['a', 'b', 'c'],
|
|
18
|
+
x: 1,
|
|
19
|
+
y: 2,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(cells.map(String).join('')).toBe('abc');
|
|
23
|
+
expect(cells.map(({ x, y }) => `${x},${y}`).join(' ')).toBe('1,2 2,2 3,2');
|
|
24
|
+
expect(cells.every((cell) => cell.isEmpty)).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('reads a word played through existing board tiles', () => {
|
|
28
|
+
const board = Board.fromStringArray([' ', ' ', ' a c ', ' ', ' ']);
|
|
29
|
+
const cells = getCells(board, { blankIndices: [], id: 0, isHorizontal: true, points: 0, tiles: ['b'], x: 1, y: 2 });
|
|
30
|
+
|
|
31
|
+
expect(cells.map(String).join('')).toBe('abc');
|
|
32
|
+
expect(cells.map((cell) => cell.isEmpty)).toEqual([false, true, false]);
|
|
33
|
+
expect(
|
|
34
|
+
cells
|
|
35
|
+
.filter((cell) => cell.isEmpty)
|
|
36
|
+
.map(String)
|
|
37
|
+
.join(''),
|
|
38
|
+
).toBe('b');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('reads a vertical word', () => {
|
|
42
|
+
const board = Board.fromStringArray([' ', ' a ', ' ', ' ', ' ']);
|
|
43
|
+
const cells = getCells(board, {
|
|
44
|
+
blankIndices: [],
|
|
45
|
+
id: 0,
|
|
46
|
+
isHorizontal: false,
|
|
47
|
+
points: 0,
|
|
48
|
+
tiles: ['b', 'c'],
|
|
49
|
+
x: 2,
|
|
50
|
+
y: 1,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
expect(cells.map(String).join('')).toBe('abc');
|
|
54
|
+
expect(cells.map(({ x, y }) => `${x},${y}`).join(' ')).toBe('2,1 2,2 2,3');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('marks placed blanks by their index among placed tiles', () => {
|
|
58
|
+
const board = Board.fromStringArray([' ', ' ', ' a ', ' ', ' ']);
|
|
59
|
+
const cells = getCells(board, {
|
|
60
|
+
blankIndices: [1],
|
|
61
|
+
id: 0,
|
|
62
|
+
isHorizontal: true,
|
|
63
|
+
points: 0,
|
|
64
|
+
tiles: ['b', 'c'],
|
|
65
|
+
x: 1,
|
|
66
|
+
y: 2,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(cells.map(String).join('')).toBe('abc');
|
|
70
|
+
expect(cells.map((cell) => cell.tile.isBlank)).toEqual([false, false, true]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('stops at the board edge', () => {
|
|
74
|
+
const board = Board.fromStringArray([' ', ' ', ' ', ' ', ' ']);
|
|
75
|
+
const cells = getCells(board, {
|
|
76
|
+
blankIndices: [],
|
|
77
|
+
id: 0,
|
|
78
|
+
isHorizontal: true,
|
|
79
|
+
points: 0,
|
|
80
|
+
tiles: ['a', 'b', 'c'],
|
|
81
|
+
x: 3,
|
|
82
|
+
y: 2,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(cells.map(String).join('')).toBe('ab');
|
|
86
|
+
expect(cells.map(({ x, y }) => `${x},${y}`).join(' ')).toBe('3,2 4,2');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('treats a candidate cell as empty', () => {
|
|
90
|
+
const board = Board.fromStringArray([' ', ' ', ' ', ' ', ' ']);
|
|
91
|
+
board.updateCell(2, 2, () => new Cell({ isEmpty: true, tile: new Tile({ character: 'z' }), x: 2, y: 2 }));
|
|
92
|
+
const cells = getCells(board, {
|
|
93
|
+
blankIndices: [],
|
|
94
|
+
id: 0,
|
|
95
|
+
isHorizontal: true,
|
|
96
|
+
points: 0,
|
|
97
|
+
tiles: ['a', 'b', 'c'],
|
|
98
|
+
x: 1,
|
|
99
|
+
y: 2,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(cells.map(String).join('')).toBe('abc');
|
|
103
|
+
expect(cells.every((cell) => cell.isEmpty)).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('treats a cell without a tile as empty, matching the solver', () => {
|
|
107
|
+
const board = Board.fromStringArray([' ', ' ', ' ', ' ', ' ']);
|
|
108
|
+
board.updateCell(2, 2, () => new Cell({ isEmpty: false, tile: Tile.Null, x: 2, y: 2 }));
|
|
109
|
+
const cells = getCells(board, {
|
|
110
|
+
blankIndices: [],
|
|
111
|
+
id: 0,
|
|
112
|
+
isHorizontal: true,
|
|
113
|
+
points: 0,
|
|
114
|
+
tiles: ['a', 'b', 'c'],
|
|
115
|
+
x: 1,
|
|
116
|
+
y: 2,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(cells.map(String).join('')).toBe('abc');
|
|
120
|
+
expect(
|
|
121
|
+
cells
|
|
122
|
+
.filter((cell) => cell.isEmpty)
|
|
123
|
+
.map(String)
|
|
124
|
+
.join(''),
|
|
125
|
+
).toBe('abc');
|
|
126
|
+
});
|
|
127
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Board } from '../Board';
|
|
2
|
+
import { type Cell } from '../Cell';
|
|
3
|
+
import { type ResultJson } from '../ResultJson';
|
|
4
|
+
|
|
5
|
+
import { getPlacedCell } from './getPlacedCell';
|
|
6
|
+
|
|
7
|
+
export function getCells(board: Board, json: ResultJson): Cell[] {
|
|
8
|
+
const stepX = json.isHorizontal ? 1 : 0;
|
|
9
|
+
const stepY = json.isHorizontal ? 0 : 1;
|
|
10
|
+
const cells: Cell[] = [];
|
|
11
|
+
let placedIndex = 0;
|
|
12
|
+
let { x, y } = json;
|
|
13
|
+
|
|
14
|
+
while (y < board.rowsCount && x < board.columnsCount) {
|
|
15
|
+
const boardCell = board.rows[y][x];
|
|
16
|
+
|
|
17
|
+
if (boardCell.isFilled()) {
|
|
18
|
+
cells.push(boardCell.clone());
|
|
19
|
+
} else if (placedIndex < json.tiles.length) {
|
|
20
|
+
cells.push(getPlacedCell(json, placedIndex, x, y));
|
|
21
|
+
placedIndex += 1;
|
|
22
|
+
} else {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
x += stepX;
|
|
27
|
+
y += stepY;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return cells;
|
|
31
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Board } from '../Board';
|
|
2
|
+
import { type BoardWord } from '../BoardWord';
|
|
3
|
+
import { type Direction } from '../Direction';
|
|
4
|
+
|
|
5
|
+
import { getWordThrough } from './getWordThrough';
|
|
6
|
+
|
|
7
|
+
export function getCollidingWords(board: Board, word: BoardWord): BoardWord[] {
|
|
8
|
+
const isHorizontal = word.direction === 'horizontal';
|
|
9
|
+
const collidingDirection: Direction = isHorizontal ? 'vertical' : 'horizontal';
|
|
10
|
+
const collidingWords: BoardWord[] = [];
|
|
11
|
+
let { x, y } = word;
|
|
12
|
+
|
|
13
|
+
while (x < board.columnsCount && y < board.rowsCount && !board.rows[y][x].isEmpty) {
|
|
14
|
+
const collidingWord = getWordThrough(board, x, y, collidingDirection);
|
|
15
|
+
|
|
16
|
+
if (collidingWord) {
|
|
17
|
+
collidingWords.push(collidingWord);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
x += isHorizontal ? 1 : 0;
|
|
21
|
+
y += isHorizontal ? 0 : 1;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return collidingWords;
|
|
25
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Board } from '../Board';
|
|
2
|
+
import { type Cell } from '../Cell';
|
|
3
|
+
|
|
4
|
+
export function getCollision(placed: Cell, board: Board, isHorizontal: boolean): Cell[] {
|
|
5
|
+
const stepX = isHorizontal ? 0 : 1;
|
|
6
|
+
const stepY = isHorizontal ? 1 : 0;
|
|
7
|
+
let x = placed.x - stepX;
|
|
8
|
+
let y = placed.y - stepY;
|
|
9
|
+
|
|
10
|
+
while (x >= 0 && y >= 0 && board.rows[y][x].isFilled()) {
|
|
11
|
+
x -= stepX;
|
|
12
|
+
y -= stepY;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
x += stepX;
|
|
16
|
+
y += stepY;
|
|
17
|
+
|
|
18
|
+
const collision: Cell[] = [];
|
|
19
|
+
|
|
20
|
+
while (y < board.rowsCount && x < board.columnsCount) {
|
|
21
|
+
if (x === placed.x && y === placed.y) {
|
|
22
|
+
collision.push(placed);
|
|
23
|
+
} else {
|
|
24
|
+
const boardCell = board.rows[y][x];
|
|
25
|
+
|
|
26
|
+
if (!boardCell.isFilled()) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
collision.push(boardCell.clone());
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
x += stepX;
|
|
34
|
+
y += stepY;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return collision;
|
|
38
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { Board } from '../Board';
|
|
4
|
+
import { Cell } from '../Cell';
|
|
5
|
+
import { Tile } from '../Tile';
|
|
6
|
+
|
|
7
|
+
import { getCells } from './getCells';
|
|
8
|
+
import { getCollisions } from './getCollisions';
|
|
9
|
+
|
|
10
|
+
describe('getCollisions', () => {
|
|
11
|
+
it('reads the perpendicular word crossing a placed tile', () => {
|
|
12
|
+
const board = Board.fromStringArray([' ', ' a ', ' d ', ' c ', ' ']);
|
|
13
|
+
const cells = getCells(board, { blankIndices: [], id: 0, isHorizontal: true, points: 0, tiles: ['b'], x: 2, y: 2 });
|
|
14
|
+
const collisions = getCollisions(board, cells, true);
|
|
15
|
+
|
|
16
|
+
expect(collisions.map((collision) => collision.map(String).join(''))).toEqual(['abc']);
|
|
17
|
+
expect(collisions[0].map(({ x, y }) => `${x},${y}`).join(' ')).toBe('2,1 2,2 2,3');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('reads a horizontal collision crossing a vertical word', () => {
|
|
21
|
+
const board = Board.fromStringArray([' ', ' a c ', ' ', ' ', ' ']);
|
|
22
|
+
const cells = getCells(board, {
|
|
23
|
+
blankIndices: [],
|
|
24
|
+
id: 0,
|
|
25
|
+
isHorizontal: false,
|
|
26
|
+
points: 0,
|
|
27
|
+
tiles: ['b', 'd'],
|
|
28
|
+
x: 2,
|
|
29
|
+
y: 1,
|
|
30
|
+
});
|
|
31
|
+
const collisions = getCollisions(board, cells, false);
|
|
32
|
+
|
|
33
|
+
expect(cells.map(String).join('')).toBe('bd');
|
|
34
|
+
expect(collisions.map((collision) => collision.map(String).join(''))).toEqual(['abc']);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('reads one collision per placed tile', () => {
|
|
38
|
+
const board = Board.fromStringArray([' a a', ' ', ' ', ' ', ' ']);
|
|
39
|
+
const cells = getCells(board, {
|
|
40
|
+
blankIndices: [],
|
|
41
|
+
id: 0,
|
|
42
|
+
isHorizontal: true,
|
|
43
|
+
points: 0,
|
|
44
|
+
tiles: ['b', 'c', 'b'],
|
|
45
|
+
x: 2,
|
|
46
|
+
y: 1,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(getCollisions(board, cells, true).map((collision) => collision.map(String).join(''))).toEqual(['ab', 'ab']);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('ignores placed tiles without a perpendicular neighbour', () => {
|
|
53
|
+
const board = Board.fromStringArray([' ', ' ', ' ', ' ', ' ']);
|
|
54
|
+
const cells = getCells(board, {
|
|
55
|
+
blankIndices: [],
|
|
56
|
+
id: 0,
|
|
57
|
+
isHorizontal: true,
|
|
58
|
+
points: 0,
|
|
59
|
+
tiles: ['a', 'b'],
|
|
60
|
+
x: 1,
|
|
61
|
+
y: 2,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
expect(getCollisions(board, cells, true)).toEqual([]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('does not cross a candidate cell', () => {
|
|
68
|
+
const board = Board.fromStringArray([' ', ' ', ' ', ' ', ' ']);
|
|
69
|
+
board.updateCell(2, 1, () => new Cell({ isEmpty: true, tile: new Tile({ character: 'z' }), x: 2, y: 1 }));
|
|
70
|
+
const cells = getCells(board, {
|
|
71
|
+
blankIndices: [],
|
|
72
|
+
id: 0,
|
|
73
|
+
isHorizontal: true,
|
|
74
|
+
points: 0,
|
|
75
|
+
tiles: ['a', 'b', 'c'],
|
|
76
|
+
x: 1,
|
|
77
|
+
y: 2,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
expect(getCollisions(board, cells, true)).toEqual([]);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Board } from '../Board';
|
|
2
|
+
import { type Cell } from '../Cell';
|
|
3
|
+
|
|
4
|
+
import { getCollision } from './getCollision';
|
|
5
|
+
|
|
6
|
+
export function getCollisions(board: Board, cells: Cell[], isHorizontal: boolean): Cell[][] {
|
|
7
|
+
const collisions: Cell[][] = [];
|
|
8
|
+
|
|
9
|
+
for (const cell of cells) {
|
|
10
|
+
if (cell.isFilled()) {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const collision = getCollision(cell, board, isHorizontal);
|
|
15
|
+
|
|
16
|
+
if (collision.length > 1) {
|
|
17
|
+
collisions.push(collision);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return collisions;
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Cell } from '../Cell';
|
|
2
|
+
import { type ResultJson } from '../ResultJson';
|
|
3
|
+
import { Tile } from '../Tile';
|
|
4
|
+
|
|
5
|
+
export function getPlacedCell(json: ResultJson, placedIndex: number, x: number, y: number): Cell {
|
|
6
|
+
const character = json.tiles[placedIndex];
|
|
7
|
+
const isBlank = json.blankIndices.includes(placedIndex);
|
|
8
|
+
return new Cell({ isEmpty: true, tile: new Tile({ character, isBlank }), x, y });
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Board } from '../Board';
|
|
2
|
+
import { type BoardWord } from '../BoardWord';
|
|
3
|
+
import { type Cell } from '../Cell';
|
|
4
|
+
import { type Direction } from '../Direction';
|
|
5
|
+
|
|
6
|
+
import { toBoardWord } from './toBoardWord';
|
|
7
|
+
|
|
8
|
+
export function getWordThrough(board: Board, x: number, y: number, direction: Direction): BoardWord | undefined {
|
|
9
|
+
const stepX = direction === 'horizontal' ? 1 : 0;
|
|
10
|
+
const stepY = direction === 'horizontal' ? 0 : 1;
|
|
11
|
+
let startX = x;
|
|
12
|
+
let startY = y;
|
|
13
|
+
|
|
14
|
+
while (startX - stepX >= 0 && startY - stepY >= 0 && !board.rows[startY - stepY][startX - stepX].isEmpty) {
|
|
15
|
+
startX -= stepX;
|
|
16
|
+
startY -= stepY;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const cells: Cell[] = [];
|
|
20
|
+
let cellX = startX;
|
|
21
|
+
let cellY = startY;
|
|
22
|
+
|
|
23
|
+
while (cellX < board.columnsCount && cellY < board.rowsCount && !board.rows[cellY][cellX].isEmpty) {
|
|
24
|
+
cells.push(board.rows[cellY][cellX]);
|
|
25
|
+
cellX += stepX;
|
|
26
|
+
cellY += stepY;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return cells.length > 1 ? toBoardWord(cells, direction) : undefined;
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type BoardWord } from '../BoardWord';
|
|
2
|
+
import { type Cell } from '../Cell';
|
|
3
|
+
import { type Direction } from '../Direction';
|
|
4
|
+
|
|
5
|
+
import { toBoardWord } from './toBoardWord';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Cells in transposed rows keep their original coordinates,
|
|
9
|
+
* so the first cell of a run is the word's start in both directions.
|
|
10
|
+
*/
|
|
11
|
+
export function getWordsInRows(cells: Cell[][], direction: Direction): BoardWord[] {
|
|
12
|
+
const words: BoardWord[] = [];
|
|
13
|
+
|
|
14
|
+
for (const row of cells) {
|
|
15
|
+
let currentWord: Cell[] = [];
|
|
16
|
+
|
|
17
|
+
for (const cell of row) {
|
|
18
|
+
if (!cell.isEmpty) {
|
|
19
|
+
currentWord.push(cell);
|
|
20
|
+
} else if (currentWord.length > 0) {
|
|
21
|
+
if (currentWord.length > 1) {
|
|
22
|
+
words.push(toBoardWord(currentWord, direction));
|
|
23
|
+
}
|
|
24
|
+
currentWord = [];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (currentWord.length > 1) {
|
|
29
|
+
words.push(toBoardWord(currentWord, direction));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return words;
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type BoardWord } from '../BoardWord';
|
|
2
|
+
import { type Cell } from '../Cell';
|
|
3
|
+
import { type Direction } from '../Direction';
|
|
4
|
+
|
|
5
|
+
export function toBoardWord(cells: Cell[], direction: Direction): BoardWord {
|
|
6
|
+
return {
|
|
7
|
+
direction,
|
|
8
|
+
word: cells.map((cell) => cell.tile.character).join(''),
|
|
9
|
+
x: cells[0].x,
|
|
10
|
+
y: cells[0].y,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function transpose<T>(array: T[][]): T[][] {
|
|
2
|
+
const rows = array.length;
|
|
3
|
+
const cols = array[0].length;
|
|
4
|
+
const transposed: T[][] = Array(cols)
|
|
5
|
+
.fill(null)
|
|
6
|
+
.map(() => Array(rows));
|
|
7
|
+
|
|
8
|
+
for (let y = 0; y < rows; ++y) {
|
|
9
|
+
for (let x = 0; x < cols; ++x) {
|
|
10
|
+
transposed[x][y] = array[y][x];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return transposed;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { isBingo } from './isBingo';
|
|
2
|
+
export { isBoardJson } from './isBoardJson';
|
|
3
|
+
export { isCellJson } from './isCellJson';
|
|
4
|
+
export { isError } from './isError';
|
|
5
|
+
export { isGame } from './isGame';
|
|
6
|
+
export { isLocale } from './isLocale';
|
|
7
|
+
export { isMultiplierBingo } from './isMultiplierBingo';
|
|
8
|
+
export { isObject } from './isObject';
|
|
9
|
+
export { isScoreBingo } from './isScoreBingo';
|
|
10
|
+
export { isTileJson } from './isTileJson';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Bingo } from '../Bingo';
|
|
2
|
+
|
|
3
|
+
import { isMultiplierBingo } from './isMultiplierBingo';
|
|
4
|
+
import { isScoreBingo } from './isScoreBingo';
|
|
5
|
+
|
|
6
|
+
export const isBingo = (value: unknown): value is Bingo => {
|
|
7
|
+
return isScoreBingo(value) || isMultiplierBingo(value);
|
|
8
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { isBoardJson } from './isBoardJson';
|
|
4
|
+
|
|
5
|
+
describe('isBoardJson', () => {
|
|
6
|
+
const cell = { isEmpty: true, tile: null, x: 0, y: 0 };
|
|
7
|
+
|
|
8
|
+
it('accepts a board of cells', () => {
|
|
9
|
+
expect(
|
|
10
|
+
isBoardJson([
|
|
11
|
+
[cell, cell],
|
|
12
|
+
[cell, cell],
|
|
13
|
+
]),
|
|
14
|
+
).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('accepts an empty board', () => {
|
|
18
|
+
expect(isBoardJson([])).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('rejects a non-array', () => {
|
|
22
|
+
expect(isBoardJson({ rows: [] })).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('rejects rows that are not arrays', () => {
|
|
26
|
+
expect(isBoardJson([1, 2, 3])).toBe(false);
|
|
27
|
+
expect(isBoardJson([[cell], 'row'])).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('rejects rows holding something other than cells', () => {
|
|
31
|
+
expect(isBoardJson([[cell, { x: 1, y: 0 }]])).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type BoardJson } from '../BoardJson';
|
|
2
|
+
|
|
3
|
+
import { isCellJson } from './isCellJson';
|
|
4
|
+
|
|
5
|
+
export const isBoardJson = (value: unknown): value is BoardJson => {
|
|
6
|
+
if (!Array.isArray(value)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
for (const row of value) {
|
|
11
|
+
if (!Array.isArray(row)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (const cell of row) {
|
|
16
|
+
if (!isCellJson(cell)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CellJson } from '../CellJson';
|
|
2
|
+
|
|
3
|
+
import { isObject } from './isObject';
|
|
4
|
+
import { isTileJson } from './isTileJson';
|
|
5
|
+
|
|
6
|
+
export const isCellJson = (value: unknown): value is CellJson => {
|
|
7
|
+
return (
|
|
8
|
+
isObject(value) &&
|
|
9
|
+
typeof value.isEmpty === 'boolean' &&
|
|
10
|
+
(isTileJson(value.tile) || value.tile === null) &&
|
|
11
|
+
typeof value.x === 'number' &&
|
|
12
|
+
typeof value.y === 'number'
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type MultiplierBingo } from '../Bingo';
|
|
2
|
+
|
|
3
|
+
import { isObject } from './isObject';
|
|
4
|
+
|
|
5
|
+
export const isMultiplierBingo = (value: unknown): value is MultiplierBingo => {
|
|
6
|
+
return isObject(value) && 'multiplier' in value && typeof value.multiplier === 'number';
|
|
7
|
+
};
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/word-definitions",
|
|
3
|
-
"version": "2.18.
|
|
4
|
-
"description": "Scrabble Solver
|
|
3
|
+
"version": "2.18.2",
|
|
4
|
+
"description": "Word definition crawlers and parsers for Scrabble Solver (Wiktionary, CNRTL, DWDS, SJP, dexonline, and more).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"word-definitions",
|
|
7
|
+
"dictionary",
|
|
8
|
+
"wiktionary",
|
|
9
|
+
"scrabble"
|
|
10
|
+
],
|
|
5
11
|
"main": "build/index.js",
|
|
6
12
|
"types": "build/index.d.ts",
|
|
7
13
|
"repository": {
|
|
@@ -24,7 +30,7 @@
|
|
|
24
30
|
"test": "bun test --timeout 180000 src"
|
|
25
31
|
},
|
|
26
32
|
"dependencies": {
|
|
27
|
-
"@scrabble-solver/types": "^2.18.
|
|
33
|
+
"@scrabble-solver/types": "^2.18.2",
|
|
28
34
|
"cheerio": "^1.2.0",
|
|
29
35
|
"follow-redirects": "^1.16.0",
|
|
30
36
|
"striptags": "^3.2.0"
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/word-lists",
|
|
3
|
-
"version": "2.18.
|
|
4
|
-
"description": "Scrabble Solver
|
|
3
|
+
"version": "2.18.2",
|
|
4
|
+
"description": "Per-locale word list downloaders for Scrabble Solver (SOWPODS, TWL06, SJP, and more).",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"word-list",
|
|
7
|
+
"scrabble",
|
|
8
|
+
"dictionary",
|
|
9
|
+
"sowpods",
|
|
10
|
+
"twl06",
|
|
11
|
+
"sjp"
|
|
12
|
+
],
|
|
5
13
|
"main": "build/index.js",
|
|
6
14
|
"types": "build/index.d.ts",
|
|
7
15
|
"repository": {
|
|
@@ -23,7 +31,7 @@
|
|
|
23
31
|
"clean": "rimraf build/"
|
|
24
32
|
},
|
|
25
33
|
"dependencies": {
|
|
26
|
-
"@scrabble-solver/types": "^2.18.
|
|
34
|
+
"@scrabble-solver/types": "^2.18.2",
|
|
27
35
|
"cheerio": "^1.2.0",
|
|
28
36
|
"follow-redirects": "^1.16.0",
|
|
29
37
|
"transliteration": "^2.6.1",
|