scrabble-solver 2.9.1 → 2.9.3

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.
Files changed (119) hide show
  1. package/.eslintrc.js +8 -1
  2. package/LICENSE +1 -1
  3. package/README.md +82 -34
  4. package/lerna.json +1 -1
  5. package/package.json +4 -4
  6. package/packages/configs/package.json +5 -5
  7. package/packages/constants/package.json +3 -3
  8. package/packages/dictionaries/package-lock.json +2 -2
  9. package/packages/dictionaries/package.json +6 -6
  10. package/packages/logger/package-lock.json +2 -2
  11. package/packages/logger/package.json +3 -3
  12. package/packages/scrabble-solver/.next/BUILD_ID +1 -1
  13. package/packages/scrabble-solver/.next/build-manifest.json +9 -9
  14. package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
  15. package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
  16. package/packages/scrabble-solver/.next/cache/next-server.js.nft.json +1 -1
  17. package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
  18. package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
  19. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/0.pack +0 -0
  20. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack +0 -0
  21. package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
  22. package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
  23. package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
  24. package/packages/scrabble-solver/.next/prerender-manifest.json +1 -1
  25. package/packages/scrabble-solver/.next/required-server-files.json +1 -1
  26. package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
  27. package/packages/scrabble-solver/.next/server/chunks/413.js +6 -2
  28. package/packages/scrabble-solver/.next/server/chunks/44.js +894 -3
  29. package/packages/scrabble-solver/.next/server/chunks/515.js +119 -27
  30. package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
  31. package/packages/scrabble-solver/.next/server/pages/404.html +2 -2
  32. package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +1 -1
  33. package/packages/scrabble-solver/.next/server/pages/500.html +2 -2
  34. package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
  35. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +121 -65
  36. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
  37. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js +1 -1
  38. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
  39. package/packages/scrabble-solver/.next/server/pages/api/solve.js +1 -1
  40. package/packages/scrabble-solver/.next/server/pages/api/solve.js.nft.json +1 -1
  41. package/packages/scrabble-solver/.next/server/pages/api/verify.js +1 -1
  42. package/packages/scrabble-solver/.next/server/pages/api/verify.js.nft.json +1 -1
  43. package/packages/scrabble-solver/.next/server/pages/index.html +1 -13
  44. package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
  45. package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
  46. package/packages/scrabble-solver/.next/static/chunks/880-18e3aea6915aebe7.js +1 -0
  47. package/packages/scrabble-solver/.next/static/chunks/pages/{404-7082923654d5996f.js → 404-8650986dc56dab75.js} +1 -1
  48. package/packages/scrabble-solver/.next/static/chunks/pages/{_app-10893b318367f97c.js → _app-183f598b1d4d480b.js} +1 -1
  49. package/packages/scrabble-solver/.next/static/chunks/pages/index-f1cef1e67e14d022.js +1 -0
  50. package/packages/scrabble-solver/.next/static/css/e8de67ad5ea35427.css +1 -0
  51. package/packages/scrabble-solver/.next/static/s5pE_3C3ebZuSfaqE7xat/_buildManifest.js +1 -0
  52. package/packages/scrabble-solver/.next/static/{Oki2Ia4sgLw021iM7byAe → s5pE_3C3ebZuSfaqE7xat}/_ssgManifest.js +0 -0
  53. package/packages/scrabble-solver/.next/trace +52 -52
  54. package/packages/scrabble-solver/package-lock.json +2 -2
  55. package/packages/scrabble-solver/package.json +10 -10
  56. package/packages/scrabble-solver/src/components/Dictionary/Dictionary.module.scss +1 -0
  57. package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +7 -2
  58. package/packages/scrabble-solver/src/components/Logo/Logo.svg +62 -0
  59. package/packages/scrabble-solver/src/components/Logo/index.ts +1 -1
  60. package/packages/scrabble-solver/src/i18n/en.json +2 -2
  61. package/packages/scrabble-solver/src/pages/api/dictionary/[locale]/[word].ts +3 -1
  62. package/packages/solver/package-lock.json +2 -2
  63. package/packages/solver/package.json +7 -7
  64. package/packages/types/build/WordDefinition.d.ts +8 -5
  65. package/packages/types/build/WordDefinition.js +5 -1
  66. package/packages/types/build/WordDefinitionJson.d.ts +7 -0
  67. package/packages/types/package.json +4 -4
  68. package/packages/types/src/WordDefinition.ts +13 -1
  69. package/packages/types/src/WordDefinitionJson.ts +7 -0
  70. package/packages/word-definitions/build/getWordDefinition.d.ts +1 -1
  71. package/packages/word-definitions/build/getWordDefinition.js +3 -3
  72. package/packages/word-definitions/build/lib/normalizeDefinition.js +3 -1
  73. package/packages/word-definitions/build/parse/parse.js +2 -2
  74. package/packages/word-definitions/build/parse/parseEnglish.js +7 -7
  75. package/packages/word-definitions/build/parse/parseFrench.js +3 -6
  76. package/packages/word-definitions/build/parse/parseGerman.js +54 -16
  77. package/packages/word-definitions/build/parse/parsePolish.js +3 -6
  78. package/packages/word-definitions/build/parse/parseSpanish.js +3 -6
  79. package/packages/word-definitions/build/types.d.ts +1 -1
  80. package/packages/word-definitions/package-lock.json +8 -8
  81. package/packages/word-definitions/package.json +4 -4
  82. package/packages/word-definitions/src/getWordDefinition.ts +3 -3
  83. package/packages/word-definitions/src/lib/normalizeDefinition.ts +4 -1
  84. package/packages/word-definitions/src/parse/__tests__/expected/de-DE.hm.json +4 -0
  85. package/packages/word-definitions/src/parse/__tests__/expected/de-DE.ho.json +9 -0
  86. package/packages/word-definitions/src/parse/__tests__/expected/de-DE.kolla.json +4 -0
  87. package/packages/word-definitions/src/parse/__tests__/expected/de-DE.vom.json +16 -0
  88. package/packages/word-definitions/src/parse/__tests__/expected/en-US.awe.json +1 -1
  89. package/packages/word-definitions/src/parse/__tests__/expected/en-US.pawn.json +1 -1
  90. package/packages/word-definitions/src/parse/__tests__/expected/en-US.pawnee.json +1 -1
  91. package/packages/word-definitions/src/parse/__tests__/expected/en-US.pean.json +1 -1
  92. package/packages/word-definitions/src/parse/__tests__/expected/en-US.wiz.json +1 -1
  93. package/packages/word-definitions/src/parse/__tests__/expected/es-ES.corma.json +1 -1
  94. package/packages/word-definitions/src/parse/__tests__/expected/es-ES.portero.json +1 -1
  95. package/packages/word-definitions/src/parse/__tests__/input/de-DE.hm.html +873 -0
  96. package/packages/word-definitions/src/parse/__tests__/input/de-DE.ho.html +1144 -0
  97. package/packages/word-definitions/src/parse/__tests__/input/de-DE.kolla.html +980 -0
  98. package/packages/word-definitions/src/parse/__tests__/input/de-DE.vom.html +738 -0
  99. package/packages/word-definitions/src/parse/parse.test.ts +4 -0
  100. package/packages/word-definitions/src/parse/parse.ts +2 -2
  101. package/packages/word-definitions/src/parse/parseEnglish.ts +8 -4
  102. package/packages/word-definitions/src/parse/parseFrench.ts +3 -3
  103. package/packages/word-definitions/src/parse/parseGerman.ts +71 -12
  104. package/packages/word-definitions/src/parse/parsePolish.ts +3 -3
  105. package/packages/word-definitions/src/parse/parseSpanish.ts +3 -3
  106. package/packages/word-definitions/src/types.ts +1 -1
  107. package/packages/word-lists/build/getDeDeWordList.js +1 -1
  108. package/packages/word-lists/build/getPlPlWordList.js +2 -2
  109. package/packages/word-lists/package-lock.json +2 -2
  110. package/packages/word-lists/package.json +4 -4
  111. package/packages/word-lists/src/getDeDeWordList.ts +1 -1
  112. package/packages/word-lists/src/getPlPlWordList.ts +2 -2
  113. package/img/logo.png +0 -0
  114. package/packages/scrabble-solver/.next/server/chunks/452.js +0 -894
  115. package/packages/scrabble-solver/.next/static/Oki2Ia4sgLw021iM7byAe/_buildManifest.js +0 -1
  116. package/packages/scrabble-solver/.next/static/chunks/317-e7d5d859f1f95938.js +0 -1
  117. package/packages/scrabble-solver/.next/static/chunks/pages/index-b1ffeaddd9fb64b5.js +0 -1
  118. package/packages/scrabble-solver/.next/static/css/e3d218f4ea72c5fb.css +0 -1
  119. package/packages/scrabble-solver/public/robots.txt +0 -4
@@ -10,6 +10,10 @@ export const readTestFile = (filepath: string): string => {
10
10
  };
11
11
 
12
12
  const tests = [
13
+ { locale: Locale.DE_DE, word: 'hm' },
14
+ { locale: Locale.DE_DE, word: 'ho' },
15
+ { locale: Locale.DE_DE, word: 'kolla' },
16
+ { locale: Locale.DE_DE, word: 'vom' },
13
17
  { locale: Locale.EN_US, word: 'awe' },
14
18
  { locale: Locale.EN_US, word: 'pawn' },
15
19
  { locale: Locale.EN_US, word: 'pawnee' },
@@ -19,11 +19,11 @@ const parsePerLocale: Record<Locale, (html: string) => ParseResult> = {
19
19
  };
20
20
 
21
21
  const parse = (locale: Locale, html: string): ParseResult => {
22
- const { definitions, isAllowed } = parsePerLocale[locale](html);
22
+ const { definitions, exists } = parsePerLocale[locale](html);
23
23
 
24
24
  return {
25
25
  definitions: unique(definitions.map(normalizeDefinition).filter(Boolean)),
26
- isAllowed,
26
+ exists,
27
27
  };
28
28
  };
29
29
 
@@ -1,17 +1,21 @@
1
- import cheerio from 'cheerio';
1
+ import { load } from 'cheerio';
2
2
 
3
3
  import { ParseResult } from '../types';
4
4
 
5
+ const DOES_NOT_EXIST_MESSAGE =
6
+ // eslint-disable-next-line max-len
7
+ "The word you've entered isn't in the dictionary. Click on a spelling suggestion below or try again using the search bar above.";
8
+
5
9
  const parseEnglish = (html: string): ParseResult => {
6
- const $ = cheerio.load(html);
10
+ const $ = load(html);
7
11
  $('strong.mw_t_bc').replaceWith(', ');
8
12
  $('.text-lowercase').remove();
9
13
  $('[id^=dictionary-entry]').find('.dtText > *:not(a)').remove();
10
14
  const $definitions = $('[id^=dictionary-entry]').find('.dtText, .cxl-ref');
11
15
 
12
16
  return {
13
- definitions: Array.from($definitions).map((definition) => $(definition).text()),
14
- isAllowed: $definitions.length > 0,
17
+ definitions: Array.from($definitions).map((definition) => $(definition).text().replace(/\n/g, '')),
18
+ exists: $('.spelling-suggestion-text').text().trim() !== DOES_NOT_EXIST_MESSAGE,
15
19
  };
16
20
  };
17
21
 
@@ -1,14 +1,14 @@
1
- import cheerio from 'cheerio';
1
+ import { load } from 'cheerio';
2
2
 
3
3
  import { ParseResult } from '../types';
4
4
 
5
5
  const parseFrench = (html: string): ParseResult => {
6
- const $ = cheerio.load(html);
6
+ const $ = load(html);
7
7
  const $definitions = $('.tlf_cdefinition');
8
8
 
9
9
  return {
10
10
  definitions: Array.from($definitions).map((definition) => $(definition).text()),
11
- isAllowed: $('#vitemselected span').length > 0,
11
+ exists: $('#vitemselected span').length > 0,
12
12
  };
13
13
  };
14
14
 
@@ -1,21 +1,80 @@
1
- import cheerio from 'cheerio';
1
+ import { Cheerio, CheerioAPI, Element, load } from 'cheerio';
2
2
 
3
3
  import { ParseResult } from '../types';
4
4
 
5
5
  const parseGerman = (html: string): ParseResult => {
6
- const $ = cheerio.load(html);
7
- const $meaningOverview = $('.bedeutungsuebersicht');
8
- let $definitions;
9
- if ($meaningOverview.length > 0) {
10
- $definitions = $('.bedeutungsuebersicht > ol > li > a');
11
- } else {
12
- $definitions = $('.dwdswb-lesart .dwdswb-definition');
6
+ const $ = load(html);
7
+
8
+ const definitions = [parseBedeutungsubersicht, parseBedeutungen, parseBedeutung].reduce<string[]>(
9
+ (results, parse) => (results.length === 0 ? parse($) : results),
10
+ [],
11
+ );
12
+ const exists = Array.from($('.label-danger')).every((label) => $(label).text() !== 'Hinweis');
13
+
14
+ return { definitions, exists };
15
+ };
16
+
17
+ const parseBedeutungsubersicht = ($: CheerioAPI): string[] => {
18
+ Array.from($('.bedeutungsuebersicht ol > li > a')).forEach((item) => {
19
+ $(item).text($(item).text().replace(/\n/g, ''));
20
+ });
21
+
22
+ Array.from($('.bedeutungsuebersicht ol > li > ol > li')).forEach((item) => {
23
+ const text = `\n${$(item).text().replace(/\n/g, '')}`;
24
+ const $text = $(`<div>${text}</div>`);
25
+ $(item).replaceWith($text);
26
+ });
27
+
28
+ Array.from($('.bedeutungsuebersicht ol > li > ol')).forEach((list) => {
29
+ const $list = $(list);
30
+ const html = $list.html() || '';
31
+ const $html = $(`<div>${html}</div>`);
32
+ const $prev = $list.prev('a');
33
+
34
+ if ($prev) {
35
+ $prev.append($html);
36
+ $(list).remove();
37
+ } else {
38
+ $(list).replaceWith($html);
39
+ }
40
+ });
41
+
42
+ return parseDefinitions($, $('.bedeutungsuebersicht ol > li'));
43
+ };
44
+
45
+ const parseBedeutung = ($: CheerioAPI): string[] => {
46
+ return parseDefinitions($, $('.dwdswb-lesart .dwdswb-definition-spezifizierung'));
47
+ };
48
+
49
+ const parseBedeutungen = ($: CheerioAPI): string[] => {
50
+ const definitions = parseDefinitions($, $('.dwdswb-lesart .dwdswb-definition'));
51
+
52
+ if (definitions.length > 0) {
53
+ return definitions;
13
54
  }
14
55
 
15
- return {
16
- definitions: Array.from($definitions).map((definition) => $(definition).text().replace('/\n/', '')),
17
- isAllowed: $definitions.length > 0,
18
- };
56
+ const $references = $('.dwdswb-lesart .dwdswb-verweis');
57
+ const references = Array.from($references).reduce<string[]>((result, reference) => {
58
+ const html = reference.attribs['data-content'] || '<span />';
59
+ const values = $(html)
60
+ .text()
61
+ .split(';')
62
+ .map((value) => value.trim());
63
+
64
+ return result.concat(values);
65
+ }, []);
66
+
67
+ return references;
68
+ };
69
+
70
+ const parseDefinitions = ($: CheerioAPI, $definitions: Cheerio<Element>) => {
71
+ return Array.from($definitions).map((definition) =>
72
+ $(definition)
73
+ .text()
74
+ .replace(/[ ]+/g, ' ')
75
+ .replace(/[ ]\n/g, '\n')
76
+ .replace(/^[0-9]+\.\s/g, ''),
77
+ );
19
78
  };
20
79
 
21
80
  export default parseGerman;
@@ -1,16 +1,16 @@
1
- import cheerio from 'cheerio';
1
+ import { load } from 'cheerio';
2
2
 
3
3
  import { ParseResult } from '../types';
4
4
 
5
5
  const parsePolish = (html: string): ParseResult => {
6
- const $ = cheerio.load(html);
6
+ const $ = load(html);
7
7
  const $header = $($('h1')[0]);
8
8
  const $isAllowed = $header.next();
9
9
  const $definitions = $header.next().next().next().next();
10
10
 
11
11
  return {
12
12
  definitions: $definitions.text().trim().split(/\d+\./),
13
- isAllowed: $isAllowed.text().trim().indexOf('dopuszczalne w grach') >= 0,
13
+ exists: $isAllowed.text().trim().indexOf('dopuszczalne w grach') >= 0,
14
14
  };
15
15
  };
16
16
 
@@ -1,9 +1,9 @@
1
- import cheerio from 'cheerio';
1
+ import { load } from 'cheerio';
2
2
 
3
3
  import { ParseResult } from '../types';
4
4
 
5
5
  const parseSpanish = (html: string): ParseResult => {
6
- const $ = cheerio.load(html);
6
+ const $ = load(html);
7
7
  $('.verdBold14 + .gris11 + .gris13').remove();
8
8
  $('br + .gris13').remove();
9
9
  $('.grisItalic13 + .gris13').remove();
@@ -28,7 +28,7 @@ const parseSpanish = (html: string): ParseResult => {
28
28
  .filter(Boolean)
29
29
  .map((definition) => definition.replace(/\s+\.$/g, ''))
30
30
  .map((definition) => (definition.endsWith('.') ? definition : `${definition}.`)),
31
- isAllowed: definitions.length > 0,
31
+ exists: $('.wrapper > p > strong').text() !== 'No se ha encontrado la palabra exacta',
32
32
  };
33
33
  };
34
34
 
@@ -1,4 +1,4 @@
1
1
  export interface ParseResult {
2
2
  definitions: string[];
3
- isAllowed: boolean;
3
+ exists: boolean;
4
4
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const lib_1 = require("./lib");
4
- const FILE_URL = 'https://raw.githubusercontent.com/enz/german-wordlist/master/words';
4
+ const FILE_URL = 'https://raw.githubusercontent.com/hippler/german-wordlist/master/words.txt';
5
5
  const getDeDeWordList = async () => {
6
6
  return (0, lib_1.getTxtWordList)(FILE_URL);
7
7
  };
@@ -3,7 +3,7 @@ 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
- const cheerio_1 = __importDefault(require("cheerio"));
6
+ const cheerio_1 = require("cheerio");
7
7
  const memfs_1 = require("memfs");
8
8
  const unzipper_1 = __importDefault(require("unzipper"));
9
9
  const url_1 = require("url");
@@ -28,7 +28,7 @@ const fetchZipUrl = async (url) => {
28
28
  return href;
29
29
  };
30
30
  const parseZipContainingPage = (html) => {
31
- const $ = cheerio_1.default.load(html);
31
+ const $ = (0, cheerio_1.load)(html);
32
32
  const $links = $('a');
33
33
  const links = Array.from($links)
34
34
  .map((link) => $(link).attr('href'))
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@scrabble-solver/word-lists",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@scrabble-solver/word-lists",
9
- "version": "2.9.1",
9
+ "version": "2.9.3",
10
10
  "license": "CC-BY-NC-ND-4.0",
11
11
  "dependencies": {
12
12
  "cheerio": "^1.0.0-rc.12",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/word-lists",
3
- "version": "2.9.1",
3
+ "version": "2.9.3",
4
4
  "description": "Scrabble Solver 2 - Word lists",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "author": {
12
12
  "name": "Kamil Mielnik",
13
- "email": "kamil.adam.mielnik@gmail.com",
14
- "url": "https://kamilmielnik.com/"
13
+ "email": "kamil@kamilmielnik.com",
14
+ "url": "https://kamilmielnik.com"
15
15
  },
16
16
  "license": "CC-BY-NC-ND-4.0",
17
17
  "bugs": {
@@ -24,7 +24,7 @@
24
24
  "clean:force": "npm run clean && rimraf package-lock.json"
25
25
  },
26
26
  "dependencies": {
27
- "@scrabble-solver/types": "^2.9.1",
27
+ "@scrabble-solver/types": "^2.9.3",
28
28
  "cheerio": "^1.0.0-rc.12",
29
29
  "follow-redirects": "^1.15.2",
30
30
  "memfs": "^3.4.7",
@@ -1,6 +1,6 @@
1
1
  import { getTxtWordList } from './lib';
2
2
 
3
- const FILE_URL = 'https://raw.githubusercontent.com/enz/german-wordlist/master/words';
3
+ const FILE_URL = 'https://raw.githubusercontent.com/hippler/german-wordlist/master/words.txt';
4
4
 
5
5
  const getDeDeWordList = async (): Promise<string[]> => {
6
6
  return getTxtWordList(FILE_URL);
@@ -1,4 +1,4 @@
1
- import cheerio from 'cheerio';
1
+ import { load } from 'cheerio';
2
2
  import { fs } from 'memfs';
3
3
  import unzipper from 'unzipper';
4
4
  import { URL } from 'url';
@@ -28,7 +28,7 @@ const fetchZipUrl = async (url: string): Promise<string> => {
28
28
  };
29
29
 
30
30
  const parseZipContainingPage = (html: string): string => {
31
- const $ = cheerio.load(html);
31
+ const $ = load(html);
32
32
  const $links = $('a');
33
33
  const links = Array.from($links)
34
34
  .map((link) => $(link).attr('href'))
package/img/logo.png DELETED
Binary file