scrabble-solver 2.8.2 → 2.8.4
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/.eslintrc.js +1 -1
- package/.gitattributes +2 -0
- package/HISTORY.md +17 -0
- package/README.md +8 -26
- package/lerna.json +1 -1
- package/package.json +13 -13
- package/packages/configs/build/getConfig.js +6 -12
- package/packages/configs/build/getLocaleConfig.js +2 -2
- package/packages/configs/build/isConfigId.js +5 -8
- package/packages/configs/build/literaki/bonuses.js +2 -2
- package/packages/configs/build/literaki/literaki.js +14 -27
- package/packages/configs/build/literaki/tiles/tilesDe.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesEn.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesEs.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesFr.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesPl.js +1 -1
- package/packages/configs/build/scrabble/bonuses.js +2 -2
- package/packages/configs/build/scrabble/scrabble.js +14 -27
- package/packages/configs/build/scrabble/tiles/tilesDe.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesEn.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesEs.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesFr.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesPl.js +1 -1
- package/packages/configs/package.json +3 -3
- package/packages/constants/package.json +1 -1
- package/packages/dictionaries/build/Dictionaries.js +37 -110
- package/packages/dictionaries/build/constants/index.js +2 -2
- package/packages/dictionaries/build/index.js +1 -1
- package/packages/dictionaries/build/lib/DiskCache.js +29 -91
- package/packages/dictionaries/build/lib/LayeredCache.js +37 -101
- package/packages/dictionaries/build/lib/MemoryCache.js +16 -17
- package/packages/dictionaries/build/lib/createAsyncProxy.js +14 -58
- package/packages/dictionaries/build/lib/createCacheTimestampComparator.js +4 -4
- package/packages/dictionaries/build/lib/downloadDictionary.js +10 -54
- package/packages/dictionaries/build/lib/getDictionaryFilepath.js +4 -4
- package/packages/dictionaries/build/lib/index.d.ts +0 -2
- package/packages/dictionaries/build/lib/index.js +1 -5
- package/packages/dictionaries/package-lock.json +10 -10
- package/packages/dictionaries/package.json +5 -5
- package/packages/dictionaries/src/lib/DiskCache.ts +2 -4
- package/packages/dictionaries/src/lib/LayeredCache.ts +17 -8
- package/packages/dictionaries/src/lib/index.ts +0 -2
- package/packages/logger/build/constants.js +2 -2
- package/packages/logger/build/logger.js +4 -4
- package/packages/logger/package-lock.json +2 -2
- package/packages/logger/package.json +1 -1
- package/packages/scrabble-solver/.next/BUILD_ID +1 -1
- package/packages/scrabble-solver/.next/build-manifest.json +10 -10
- package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
- package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/packages/scrabble-solver/.next/cache/next-server.js.nft.json +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/server-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/prerender-manifest.json +1 -1
- package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/chunks/206.js +98 -97
- package/packages/scrabble-solver/.next/server/chunks/413.js +396 -677
- package/packages/scrabble-solver/.next/server/chunks/515.js +546 -550
- package/packages/scrabble-solver/.next/server/chunks/907.js +399 -681
- package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.html +5 -1
- package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/500.html +2 -2
- package/packages/scrabble-solver/.next/server/pages/_app.js +7 -10
- package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_document.js +0 -3
- 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 +114 -171
- package/packages/scrabble-solver/.next/server/pages/api/solve.js +426 -1206
- package/packages/scrabble-solver/.next/server/pages/index.html +17 -1
- package/packages/scrabble-solver/.next/server/pages/index.js +7 -14
- 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/static/-UOLkxdxU0PlKbXa09-xO/_buildManifest.js +1 -0
- package/packages/scrabble-solver/.next/static/{nXSSCVI5pGlS_NxEidxkS → -UOLkxdxU0PlKbXa09-xO}/_ssgManifest.js +0 -0
- package/packages/scrabble-solver/.next/static/chunks/56-2d34867599a0ac66.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/{404-02d949d2fe59e960.js → 404-30c06e61d256c5b2.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-6ffa2ab900772b67.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/{index-75517525489ab316.js → index-13ea7770a65c69ee.js} +1 -1
- package/packages/scrabble-solver/.next/static/css/{d676d43c6b9c9a57.css → 551d09cac435debb.css} +1 -1
- package/packages/scrabble-solver/.next/static/css/{6a9e5ba3f77c27f2.css → cdbc9e0afcff5473.css} +1 -1
- package/packages/scrabble-solver/.next/trace +42 -42
- package/packages/scrabble-solver/package-lock.json +85 -85
- package/packages/scrabble-solver/package.json +13 -13
- package/packages/scrabble-solver/src/components/Board/Board.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/Button.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/CellPure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/hooks/useGrid.ts +9 -0
- package/packages/scrabble-solver/src/components/Button/Button.tsx +1 -1
- package/packages/scrabble-solver/src/components/Checkbox/Checkbox.tsx +1 -1
- package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +1 -1
- package/packages/scrabble-solver/src/components/DictionaryInput/DictionaryInput.tsx +1 -1
- package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +1 -1
- package/packages/scrabble-solver/src/components/Key/Key.tsx +1 -1
- package/packages/scrabble-solver/src/components/KeyMap/KeyMap.tsx +2 -2
- package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.module.scss +4 -0
- package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.tsx +16 -12
- package/packages/scrabble-solver/src/components/Loading/Loading.tsx +1 -1
- package/packages/scrabble-solver/src/components/Logo/Logo.tsx +1 -1
- package/packages/scrabble-solver/src/components/NavButtons/NavButtons.tsx +1 -1
- package/packages/scrabble-solver/src/components/NotFound/NotFound.tsx +1 -1
- package/packages/scrabble-solver/src/components/PlainTiles/PlainTiles.tsx +5 -1
- package/packages/scrabble-solver/src/components/PlainTiles/Tile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Rack/Rack.tsx +1 -1
- package/packages/scrabble-solver/src/components/Rack/RackTile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Radio/Radio.tsx +1 -1
- package/packages/scrabble-solver/src/components/RemainingTiles/Character.tsx +1 -1
- package/packages/scrabble-solver/src/components/RemainingTiles/RemainingTiles.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Cell.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/HeaderButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Result.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Results.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/SolveButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.tsx +1 -1
- package/packages/scrabble-solver/src/components/Screen/Screen.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/Settings.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/ConfigSetting/ConfigSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/LocaleSetting/LocaleSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Sidebar/Sidebar.tsx +1 -1
- package/packages/scrabble-solver/src/components/Sidebar/components/Section/Section.tsx +1 -1
- package/packages/scrabble-solver/src/components/Splash/Splash.tsx +1 -1
- package/packages/scrabble-solver/src/components/SquareButton/Link.tsx +1 -1
- package/packages/scrabble-solver/src/components/SquareButton/SquareButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/SvgFontCss/SvgFontCss.tsx +12 -0
- package/packages/scrabble-solver/src/components/SvgFontCss/index.ts +1 -0
- package/packages/scrabble-solver/src/components/Tile/Tile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Tile/TilePure.tsx +2 -2
- package/packages/scrabble-solver/src/components/Tooltip/useTooltip.tsx +1 -1
- package/packages/scrabble-solver/src/components/Well/Well.tsx +1 -1
- package/packages/scrabble-solver/src/components/index.ts +1 -0
- package/packages/scrabble-solver/src/hooks/usePortal.tsx +19 -9
- package/packages/scrabble-solver/src/lib/createKeyboardNavigation.ts +3 -0
- package/packages/scrabble-solver/src/lib/memoize.ts +1 -1
- package/packages/scrabble-solver/src/pages/_app.tsx +1 -1
- package/packages/scrabble-solver/src/pages/_document.tsx +1 -1
- package/packages/scrabble-solver/src/pages/index.tsx +6 -15
- package/packages/scrabble-solver/src/styles/global.scss +3 -0
- package/packages/solver/build/PatternsFiller.js +38 -72
- package/packages/solver/build/PatternsGenerator.js +43 -72
- package/packages/solver/build/ScoresCalculator.js +20 -24
- package/packages/solver/build/Solver.js +19 -24
- package/packages/solver/package-lock.json +17 -17
- package/packages/solver/package.json +7 -7
- package/packages/solver/src/PatternsFiller.ts +5 -10
- package/packages/solver/src/PatternsGenerator.ts +17 -16
- package/packages/solver/src/Solver.ts +4 -8
- package/packages/types/build/Board.js +68 -85
- package/packages/types/build/Bonus.js +15 -21
- package/packages/types/build/Cell.js +31 -33
- package/packages/types/build/CharacterBonus.js +18 -40
- package/packages/types/build/Config.js +62 -117
- package/packages/types/build/HorizontalPattern.js +17 -63
- package/packages/types/build/Pattern.js +37 -41
- package/packages/types/build/Result.js +23 -46
- package/packages/types/build/Tile.js +22 -24
- package/packages/types/build/VerticalPattern.js +17 -63
- package/packages/types/build/WordBonus.js +13 -35
- package/packages/types/build/WordDefinition.js +13 -15
- package/packages/types/package.json +2 -2
- package/packages/types/src/Cell.ts +1 -1
- package/packages/types/src/Pattern.ts +1 -1
- package/packages/word-definitions/build/crawl/crawl.js +15 -16
- package/packages/word-definitions/build/crawl/crawlEnglish.js +3 -3
- package/packages/word-definitions/build/crawl/crawlFrench.js +3 -3
- package/packages/word-definitions/build/crawl/crawlGerman.js +3 -3
- package/packages/word-definitions/build/crawl/crawlPolish.js +3 -3
- package/packages/word-definitions/build/crawl/crawlSpanish.js +3 -3
- package/packages/word-definitions/build/getWordDefinition.js +9 -52
- package/packages/word-definitions/build/lib/normalizeDefinition.js +15 -15
- package/packages/word-definitions/build/lib/request.js +8 -20
- package/packages/word-definitions/build/lib/unique.js +1 -1
- package/packages/word-definitions/build/parse/parse.js +18 -19
- package/packages/word-definitions/build/parse/parseEnglish.js +5 -5
- package/packages/word-definitions/build/parse/parseFrench.js +5 -5
- package/packages/word-definitions/build/parse/parseGerman.js +6 -6
- package/packages/word-definitions/build/parse/parsePolish.js +6 -6
- package/packages/word-definitions/build/parse/parseSpanish.js +9 -9
- package/packages/word-definitions/package-lock.json +8 -8
- package/packages/word-definitions/package.json +2 -2
- package/packages/word-lists/build/getDeDeWordList.js +5 -43
- package/packages/word-lists/build/getEnGbWordList.js +5 -43
- package/packages/word-lists/build/getEnUsWordList.js +5 -43
- package/packages/word-lists/build/getEsEsWordList.js +7 -50
- package/packages/word-lists/build/getFrFrWordList.js +9 -50
- package/packages/word-lists/build/getPlPlWordList.js +33 -91
- package/packages/word-lists/build/getWordList.js +16 -17
- package/packages/word-lists/build/lib/downloadFile.d.ts +1 -2
- package/packages/word-lists/build/lib/downloadFile.js +28 -10
- package/packages/word-lists/build/lib/downloadHtml.js +8 -8
- package/packages/word-lists/build/lib/extractWords.js +5 -5
- package/packages/word-lists/build/lib/findFirstWordIndex.js +6 -6
- package/packages/word-lists/build/lib/getHash.js +2 -5
- package/packages/word-lists/build/lib/getTempFilename.js +3 -3
- package/packages/word-lists/build/lib/getTxtWordList.js +10 -56
- package/packages/word-lists/package-lock.json +2 -2
- package/packages/word-lists/package.json +2 -2
- package/packages/word-lists/src/getFrFrWordList.ts +1 -0
- package/packages/word-lists/src/getPlPlWordList.ts +2 -3
- package/packages/word-lists/src/lib/downloadFile.ts +25 -7
- package/packages/word-lists/src/lib/getTxtWordList.ts +2 -4
- package/tsconfig.json +1 -1
- package/packages/dictionaries/build/lib/readFile.d.ts +0 -2
- package/packages/dictionaries/build/lib/readFile.js +0 -57
- package/packages/dictionaries/build/lib/writeFile.d.ts +0 -2
- package/packages/dictionaries/build/lib/writeFile.js +0 -57
- package/packages/dictionaries/src/lib/readFile.ts +0 -15
- package/packages/dictionaries/src/lib/writeFile.ts +0 -15
- package/packages/scrabble-solver/.next/static/chunks/195-fcadef5c6eed8338.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-f4030148d742bcd2.js +0 -1
- package/packages/scrabble-solver/.next/static/nXSSCVI5pGlS_NxEidxkS/_buildManifest.js +0 -1
|
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var tiles = getTiles(cells);
|
|
6
|
+
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
+
const Cell_1 = __importDefault(require("./Cell"));
|
|
8
|
+
class Result {
|
|
9
|
+
constructor({ cells, id, numberOfCollisions, points, }) {
|
|
10
|
+
const tiles = getTiles(cells);
|
|
12
11
|
this.cells = cells;
|
|
13
12
|
this.id = id;
|
|
14
13
|
this.length = cells.length;
|
|
@@ -24,55 +23,33 @@ var Result = /** @class */ (function () {
|
|
|
24
23
|
this.tilesCharacters = getTilesCharacters(tiles);
|
|
25
24
|
this.word = getWord(cells);
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
static fromJson(json) {
|
|
28
27
|
return new Result({
|
|
29
28
|
cells: json.cells.map(Cell_1.default.fromJson),
|
|
30
29
|
id: json.id,
|
|
31
30
|
numberOfCollisions: json.numberOfCollisions,
|
|
32
31
|
points: json.points,
|
|
33
32
|
});
|
|
34
|
-
}
|
|
35
|
-
|
|
33
|
+
}
|
|
34
|
+
toJson() {
|
|
36
35
|
return {
|
|
37
|
-
cells: this.cells.map(
|
|
36
|
+
cells: this.cells.map((cell) => cell.toJson()),
|
|
38
37
|
id: this.id,
|
|
39
38
|
numberOfCollisions: this.numberOfCollisions,
|
|
40
39
|
points: this.points,
|
|
41
40
|
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
56
|
-
var getNonBlanks = function (tiles) { return tiles.filter(function (_a) {
|
|
57
|
-
var isBlank = _a.isBlank;
|
|
58
|
-
return !isBlank;
|
|
59
|
-
}); };
|
|
60
|
-
var getPointsRatio = function (tiles, points) { return points / tiles.length; };
|
|
61
|
-
var getTiles = function (cells) { return cells.filter(function (_a) {
|
|
62
|
-
var isEmpty = _a.isEmpty;
|
|
63
|
-
return isEmpty;
|
|
64
|
-
}).map(function (_a) {
|
|
65
|
-
var tile = _a.tile;
|
|
66
|
-
return tile;
|
|
67
|
-
}); };
|
|
68
|
-
var getTilesCharacters = function (tiles) { return getNonBlankCharacters(tiles).sort(charactersComparator).join(''); };
|
|
69
|
-
var getWord = function (cells) { return cells.map(String).join(''); };
|
|
70
|
-
var isConsonant = function (_a) {
|
|
71
|
-
var character = _a.character, isBlank = _a.isBlank;
|
|
72
|
-
return constants_1.CONSONANTS.includes(character) && !isBlank;
|
|
73
|
-
};
|
|
74
|
-
var isVowel = function (_a) {
|
|
75
|
-
var character = _a.character, isBlank = _a.isBlank;
|
|
76
|
-
return constants_1.VOWELS.includes(character) && !isBlank;
|
|
77
|
-
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const charactersComparator = (a, b) => a.localeCompare(b);
|
|
44
|
+
const getBlanks = (tiles) => tiles.filter(({ isBlank }) => isBlank);
|
|
45
|
+
const getConsonants = (tiles) => tiles.filter(isConsonant);
|
|
46
|
+
const getVowels = (tiles) => tiles.filter(isVowel);
|
|
47
|
+
const getNonBlankCharacters = (tiles) => getNonBlanks(tiles).map(({ character }) => character);
|
|
48
|
+
const getNonBlanks = (tiles) => tiles.filter(({ isBlank }) => !isBlank);
|
|
49
|
+
const getPointsRatio = (tiles, points) => points / tiles.length;
|
|
50
|
+
const getTiles = (cells) => cells.filter(({ isEmpty }) => isEmpty).map(({ tile }) => tile);
|
|
51
|
+
const getTilesCharacters = (tiles) => getNonBlankCharacters(tiles).sort(charactersComparator).join('');
|
|
52
|
+
const getWord = (cells) => cells.map(String).join('');
|
|
53
|
+
const isConsonant = ({ character, isBlank }) => constants_1.CONSONANTS.includes(character) && !isBlank;
|
|
54
|
+
const isVowel = ({ character, isBlank }) => constants_1.VOWELS.includes(character) && !isBlank;
|
|
78
55
|
exports.default = Result;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var character = _a.character, _b = _a.isBlank, isBlank = _b === void 0 ? false : _b;
|
|
3
|
+
const constants_1 = require("@scrabble-solver/constants");
|
|
4
|
+
class Tile {
|
|
5
|
+
constructor({ character, isBlank = false }) {
|
|
7
6
|
this.character = character;
|
|
8
7
|
this.isBlank = isBlank;
|
|
9
8
|
}
|
|
10
|
-
|
|
9
|
+
static fromJson(json) {
|
|
11
10
|
if (!json) {
|
|
12
11
|
return Tile.Null;
|
|
13
12
|
}
|
|
@@ -15,33 +14,32 @@ var Tile = /** @class */ (function () {
|
|
|
15
14
|
character: json.character,
|
|
16
15
|
isBlank: json.isBlank,
|
|
17
16
|
});
|
|
18
|
-
}
|
|
19
|
-
|
|
17
|
+
}
|
|
18
|
+
clone() {
|
|
20
19
|
return new Tile({
|
|
21
20
|
character: this.character,
|
|
22
21
|
isBlank: this.isBlank,
|
|
23
22
|
});
|
|
24
|
-
}
|
|
25
|
-
|
|
23
|
+
}
|
|
24
|
+
equals(other) {
|
|
26
25
|
return this.character === other.character && this.isBlank === other.isBlank;
|
|
27
|
-
}
|
|
28
|
-
|
|
26
|
+
}
|
|
27
|
+
toJson() {
|
|
29
28
|
return {
|
|
30
29
|
character: this.character,
|
|
31
30
|
isBlank: this.isBlank,
|
|
32
31
|
};
|
|
33
|
-
}
|
|
34
|
-
|
|
32
|
+
}
|
|
33
|
+
toString() {
|
|
35
34
|
return this.character;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
Tile.Null = Object.freeze({
|
|
38
|
+
character: constants_1.EMPTY_CELL,
|
|
39
|
+
isBlank: false,
|
|
40
|
+
clone: () => Tile.Null,
|
|
41
|
+
equals: (other) => other === Tile.Null,
|
|
42
|
+
toJson: () => null,
|
|
43
|
+
toString: () => constants_1.EMPTY_CELL,
|
|
44
|
+
});
|
|
47
45
|
exports.default = Tile;
|
|
@@ -1,85 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
18
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19
|
-
if (!m) return o;
|
|
20
|
-
var i = m.call(o), r, ar = [], e;
|
|
21
|
-
try {
|
|
22
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
23
|
-
}
|
|
24
|
-
catch (error) { e = { error: error }; }
|
|
25
|
-
finally {
|
|
26
|
-
try {
|
|
27
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
28
|
-
}
|
|
29
|
-
finally { if (e) throw e.error; }
|
|
30
|
-
}
|
|
31
|
-
return ar;
|
|
32
|
-
};
|
|
33
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
34
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
35
|
-
if (ar || !(i in from)) {
|
|
36
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
37
|
-
ar[i] = from[i];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
41
|
-
};
|
|
42
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
4
|
};
|
|
45
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function VerticalPattern() {
|
|
50
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
51
|
-
}
|
|
52
|
-
VerticalPattern.prototype.clone = function () {
|
|
6
|
+
const Pattern_1 = __importDefault(require("./Pattern"));
|
|
7
|
+
class VerticalPattern extends Pattern_1.default {
|
|
8
|
+
clone() {
|
|
53
9
|
return new VerticalPattern({
|
|
54
10
|
board: this.board,
|
|
55
|
-
cells: this.cells.map(
|
|
11
|
+
cells: this.cells.map((cell) => cell.clone()),
|
|
56
12
|
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var collisions = [];
|
|
13
|
+
}
|
|
14
|
+
getCollisions() {
|
|
15
|
+
const collisions = [];
|
|
61
16
|
this.cells
|
|
62
|
-
.filter(
|
|
63
|
-
.forEach(
|
|
64
|
-
|
|
65
|
-
|
|
17
|
+
.filter((cell) => cell.isEmpty && (this.board.collidesLeft(cell) || this.board.collidesRight(cell)))
|
|
18
|
+
.forEach((cell) => {
|
|
19
|
+
const row = this.board.getRow(cell.y);
|
|
20
|
+
let x = cell.x - 1;
|
|
66
21
|
while (x >= 0 && row[x].hasTile()) {
|
|
67
22
|
--x;
|
|
68
23
|
}
|
|
69
|
-
|
|
24
|
+
const previousCells = row.slice(x + 1, cell.x);
|
|
70
25
|
x = cell.x + 1;
|
|
71
26
|
while (x < row.length && row[x].hasTile()) {
|
|
72
27
|
++x;
|
|
73
28
|
}
|
|
74
|
-
|
|
75
|
-
|
|
29
|
+
const nextCells = row.slice(cell.x + 1, x);
|
|
30
|
+
const cells = [...previousCells, cell, ...nextCells];
|
|
76
31
|
if (cells.length > 1) {
|
|
77
|
-
|
|
32
|
+
const pattern = new Pattern_1.default({ board: this.board, cells });
|
|
78
33
|
collisions.push(pattern);
|
|
79
34
|
}
|
|
80
35
|
});
|
|
81
36
|
return collisions;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}(Pattern_1.default));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
85
39
|
exports.default = VerticalPattern;
|
|
@@ -1,42 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
4
|
};
|
|
20
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_this.type = constants_1.BONUS_WORD;
|
|
28
|
-
return _this;
|
|
6
|
+
const constants_1 = require("@scrabble-solver/constants");
|
|
7
|
+
const Bonus_1 = __importDefault(require("./Bonus"));
|
|
8
|
+
class WordBonus extends Bonus_1.default {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.type = constants_1.BONUS_WORD;
|
|
29
12
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
enumerable: false,
|
|
38
|
-
configurable: true
|
|
39
|
-
});
|
|
40
|
-
return WordBonus;
|
|
41
|
-
}(Bonus_1.default));
|
|
13
|
+
get value() {
|
|
14
|
+
return {
|
|
15
|
+
characterMultiplier: 1,
|
|
16
|
+
wordMultiplier: this.multiplier,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
42
20
|
exports.default = WordBonus;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var definitions = _a.definitions, isAllowed = _a.isAllowed, word = _a.word;
|
|
3
|
+
class WordDefinition {
|
|
4
|
+
constructor({ definitions, isAllowed, word }) {
|
|
6
5
|
this.definitions = definitions;
|
|
7
6
|
this.isAllowed = isAllowed;
|
|
8
7
|
this.word = word;
|
|
9
8
|
}
|
|
10
|
-
|
|
9
|
+
static fromJson(json) {
|
|
11
10
|
if (!json) {
|
|
12
11
|
return WordDefinition.Null;
|
|
13
12
|
}
|
|
@@ -16,20 +15,19 @@ var WordDefinition = /** @class */ (function () {
|
|
|
16
15
|
isAllowed: json.isAllowed,
|
|
17
16
|
word: json.word,
|
|
18
17
|
});
|
|
19
|
-
}
|
|
20
|
-
|
|
18
|
+
}
|
|
19
|
+
toJson() {
|
|
21
20
|
return {
|
|
22
21
|
definitions: this.definitions,
|
|
23
22
|
isAllowed: this.isAllowed,
|
|
24
23
|
word: this.word,
|
|
25
24
|
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}());
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
WordDefinition.Null = Object.freeze({
|
|
28
|
+
definitions: [],
|
|
29
|
+
isAllowed: false,
|
|
30
|
+
word: '',
|
|
31
|
+
toJson: () => null,
|
|
32
|
+
});
|
|
35
33
|
exports.default = WordDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/types",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.4",
|
|
4
4
|
"description": "Scrabble Solver 2 - Types",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"clean:force": "npm run clean && rimraf package-lock.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@scrabble-solver/constants": "^2.8.
|
|
27
|
+
"@scrabble-solver/constants": "^2.8.4"
|
|
28
28
|
},
|
|
29
29
|
"gitHead": "1e2d1ad49a288d4a44196d8e3336740da132c637"
|
|
30
30
|
}
|
|
@@ -2,23 +2,22 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
var _a;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
const types_1 = require("@scrabble-solver/types");
|
|
7
|
+
const crawlEnglish_1 = __importDefault(require("./crawlEnglish"));
|
|
8
|
+
const crawlFrench_1 = __importDefault(require("./crawlFrench"));
|
|
9
|
+
const crawlGerman_1 = __importDefault(require("./crawlGerman"));
|
|
10
|
+
const crawlPolish_1 = __importDefault(require("./crawlPolish"));
|
|
11
|
+
const crawlSpanish_1 = __importDefault(require("./crawlSpanish"));
|
|
12
|
+
const crawlPerLocale = {
|
|
13
|
+
[types_1.Locale.DE_DE]: crawlGerman_1.default,
|
|
14
|
+
[types_1.Locale.EN_GB]: crawlEnglish_1.default,
|
|
15
|
+
[types_1.Locale.EN_US]: crawlEnglish_1.default,
|
|
16
|
+
[types_1.Locale.ES_ES]: crawlSpanish_1.default,
|
|
17
|
+
[types_1.Locale.FR_FR]: crawlFrench_1.default,
|
|
18
|
+
[types_1.Locale.PL_PL]: crawlPolish_1.default,
|
|
19
|
+
};
|
|
20
|
+
const crawl = (locale, word) => {
|
|
22
21
|
return crawlPerLocale[locale](word);
|
|
23
22
|
};
|
|
24
23
|
exports.default = crawl;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlEnglish = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.merriam-webster.com',
|
|
8
|
-
path:
|
|
8
|
+
path: `/dictionary/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlEnglish;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlFrench = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.cnrtl.fr',
|
|
8
|
-
path:
|
|
8
|
+
path: `/definition/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlFrench;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlGerman = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.dwds.de',
|
|
8
|
-
path:
|
|
8
|
+
path: `?q=${encodeURIComponent(word)}&from=wb`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlGerman;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlPolish = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'sjp.pl',
|
|
8
|
-
path:
|
|
8
|
+
path: `/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlPolish;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const lib_1 = require("../lib");
|
|
4
|
+
const crawlSpanish = (word) => {
|
|
5
5
|
return (0, lib_1.request)({
|
|
6
6
|
protocol: 'https',
|
|
7
7
|
hostname: 'www.diccionarios.com',
|
|
8
|
-
path:
|
|
8
|
+
path: `/diccionario/espanol/${encodeURIComponent(word)}`,
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
exports.default = crawlSpanish;
|
|
@@ -1,55 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
html = _b.sent();
|
|
49
|
-
_a = (0, parse_1.parse)(locale, html), definitions = _a.definitions, isAllowed = _a.isAllowed;
|
|
50
|
-
wordDefinition = new types_1.WordDefinition({ definitions: definitions, isAllowed: isAllowed, word: word });
|
|
51
|
-
return [2 /*return*/, wordDefinition];
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}); };
|
|
3
|
+
const types_1 = require("@scrabble-solver/types");
|
|
4
|
+
const crawl_1 = require("./crawl");
|
|
5
|
+
const parse_1 = require("./parse");
|
|
6
|
+
const getWordDefinition = async (locale, word) => {
|
|
7
|
+
const html = await (0, crawl_1.crawl)(locale, word);
|
|
8
|
+
const { definitions, isAllowed } = (0, parse_1.parse)(locale, html);
|
|
9
|
+
const wordDefinition = new types_1.WordDefinition({ definitions, isAllowed, word });
|
|
10
|
+
return wordDefinition;
|
|
11
|
+
};
|
|
55
12
|
exports.default = getWordDefinition;
|