@scrabble-solver/scrabble-solver 2.13.1 → 2.13.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 (88) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +16 -16
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_8dgz12 +1 -1
  5. package/.next/cache/webpack/client-production/0.pack +0 -0
  6. package/.next/cache/webpack/client-production/index.pack +0 -0
  7. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  8. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  9. package/.next/cache/webpack/server-production/0.pack +0 -0
  10. package/.next/cache/webpack/server-production/index.pack +0 -0
  11. package/.next/next-minimal-server.js.nft.json +1 -0
  12. package/.next/next-server.js.nft.json +1 -1
  13. package/.next/prerender-manifest.js +1 -0
  14. package/.next/prerender-manifest.json +1 -1
  15. package/.next/required-server-files.json +1 -1
  16. package/.next/routes-manifest.json +1 -1
  17. package/.next/server/InjectManifest.js.nft.json +1 -1
  18. package/.next/server/chunks/28.js +1 -0
  19. package/.next/server/chunks/331.js +6 -0
  20. package/.next/server/chunks/577.js +1 -0
  21. package/.next/server/chunks/911.js +1 -1083
  22. package/.next/server/chunks/977.js +1 -0
  23. package/.next/server/functions-config-manifest.json +1 -0
  24. package/.next/server/middleware-build-manifest.js +1 -1
  25. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  26. package/.next/server/next-font-manifest.js +1 -1
  27. package/.next/server/next-font-manifest.json +1 -6
  28. package/.next/server/pages/404.html +1 -1
  29. package/.next/server/pages/404.js.nft.json +1 -1
  30. package/.next/server/pages/500.html +1 -1
  31. package/.next/server/pages/_app.js +1 -380
  32. package/.next/server/pages/_app.js.nft.json +1 -1
  33. package/.next/server/pages/_document.js +1 -212
  34. package/.next/server/pages/_document.js.nft.json +1 -1
  35. package/.next/server/pages/_error.js +1 -166
  36. package/.next/server/pages/_error.js.nft.json +1 -1
  37. package/.next/server/pages/api/dictionary/[locale]/[word].js +2 -836
  38. package/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
  39. package/.next/server/pages/api/dictionary/[locale].js +1 -192
  40. package/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
  41. package/.next/server/pages/api/solve.js +1 -1121
  42. package/.next/server/pages/api/solve.js.nft.json +1 -1
  43. package/.next/server/pages/api/verify.js +1 -213
  44. package/.next/server/pages/api/verify.js.nft.json +1 -1
  45. package/.next/server/pages/api/visit.js +1 -131
  46. package/.next/server/pages/api/visit.js.nft.json +1 -1
  47. package/.next/server/pages/index.html +1 -1
  48. package/.next/server/pages/index.js +1 -2088
  49. package/.next/server/pages/index.js.nft.json +1 -1
  50. package/.next/server/pages/index.json +1 -1
  51. package/.next/server/pages-manifest.json +1 -12
  52. package/.next/server/webpack-api-runtime.js +1 -172
  53. package/.next/server/webpack-runtime.js +1 -229
  54. package/.next/static/chunks/framework-1728d40275bc359a.js +49 -0
  55. package/.next/static/chunks/main-5fb7abbfc135de15.js +1 -0
  56. package/.next/static/chunks/pages/404-b6e238bb4117d451.js +1 -0
  57. package/.next/static/chunks/pages/_app-b95404c40a0092e6.js +17 -0
  58. package/.next/static/chunks/pages/_error-db043fa3544f8809.js +1 -0
  59. package/.next/static/chunks/pages/index-59d569ef79bc2580.js +1 -0
  60. package/.next/static/css/8fa2fb99b90e109e.css +1 -0
  61. package/.next/static/css/c80ebc6fd13311f1.css +2 -0
  62. package/.next/static/r00VHxlMI-jbGWpg3nm2M/_buildManifest.js +1 -0
  63. package/.next/trace +44 -51
  64. package/package.json +31 -32
  65. package/src/i18n/ro.json +5 -5
  66. package/src/state/slices/boardSlice.ts +4 -4
  67. package/src/state/store.ts +1 -1
  68. package/.next/cache/next-server.js.nft.json +0 -1
  69. package/.next/server/chunks/210.js +0 -109
  70. package/.next/server/chunks/277.js +0 -11942
  71. package/.next/server/chunks/44.js +0 -1813
  72. package/.next/server/chunks/50.js +0 -12119
  73. package/.next/server/chunks/636.js +0 -286
  74. package/.next/server/chunks/675.js +0 -572
  75. package/.next/server/chunks/859.js +0 -835
  76. package/.next/server/chunks/865.js +0 -20424
  77. package/.next/server/chunks/907.js +0 -42530
  78. package/.next/server/chunks/987.js +0 -91
  79. package/.next/static/RJ5_dKU0dHcryeTVO6SSX/_buildManifest.js +0 -1
  80. package/.next/static/chunks/framework-2c29dc3cd933590b.js +0 -49
  81. package/.next/static/chunks/main-4dcb7f9b52833aba.js +0 -1
  82. package/.next/static/chunks/pages/404-b4b5ce15153d4825.js +0 -1
  83. package/.next/static/chunks/pages/_app-b92880dde164b954.js +0 -32
  84. package/.next/static/chunks/pages/_error-54de1933a164a1ff.js +0 -1
  85. package/.next/static/chunks/pages/index-f56eaa969a831c70.js +0 -1
  86. package/.next/static/css/4e8b47fe382a8a8f.css +0 -2
  87. package/.next/static/css/cfae5256f1689f57.css +0 -1
  88. /package/.next/static/{RJ5_dKU0dHcryeTVO6SSX → r00VHxlMI-jbGWpg3nm2M}/_ssgManifest.js +0 -0
@@ -1,1813 +0,0 @@
1
- "use strict";
2
- exports.id = 44;
3
- exports.ids = [44];
4
- exports.modules = {
5
-
6
- /***/ 38436:
7
- /***/ ((__unused_webpack_module, exports) => {
8
-
9
-
10
- Object.defineProperty(exports, "__esModule", ({ value: true }));
11
- exports.VOWELS = exports.CONSONANTS = exports.NO_BONUS = exports.EMPTY_CELL = exports.BONUS_WORD = exports.BONUS_CHARACTER = exports.BLANK = exports.COMMA_LATIN = exports.COMMA_ARABIC = void 0;
12
- exports.COMMA_ARABIC = '،';
13
- exports.COMMA_LATIN = ',';
14
- exports.BLANK = ' ';
15
- exports.BONUS_CHARACTER = 'BONUS_CHARACTER';
16
- exports.BONUS_WORD = 'BONUS_WORD';
17
- exports.EMPTY_CELL = ' ';
18
- exports.NO_BONUS = { characterMultiplier: 1, wordMultiplier: 1 };
19
- exports.CONSONANTS = 'bcćdfghjklłmnńñpqrsśtvwxzźż'.split('');
20
- exports.VOWELS = 'aąäeęioóöuüy'.split('');
21
-
22
-
23
- /***/ }),
24
-
25
- /***/ 21285:
26
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
27
-
28
-
29
- var __importDefault = (this && this.__importDefault) || function (mod) {
30
- return (mod && mod.__esModule) ? mod : { "default": mod };
31
- };
32
- Object.defineProperty(exports, "__esModule", ({ value: true }));
33
- const logger_1 = __importDefault(__webpack_require__(52954));
34
- const types_1 = __webpack_require__(46452);
35
- const fs_1 = __importDefault(__webpack_require__(57147));
36
- const constants_1 = __webpack_require__(75823);
37
- const lib_1 = __webpack_require__(26137);
38
- class Dictionaries {
39
- constructor() {
40
- this.cache = new lib_1.LayeredCache();
41
- this.downloadDictionaryProxies = Object.fromEntries(Object.values(types_1.Locale).map((locale) => [locale, (0, lib_1.createAsyncProxy)(() => (0, lib_1.downloadDictionary)(locale))]));
42
- }
43
- async get(locale) {
44
- if (this.cache.has(locale)) {
45
- const trie = await this.cache.get(locale);
46
- if (trie) {
47
- return trie;
48
- }
49
- }
50
- logger_1.default.info('Dictionaries - cache miss', { locale });
51
- return this.updateDictionary(locale);
52
- }
53
- remove() {
54
- fs_1.default.rmdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
55
- }
56
- async update(force) {
57
- const locales = force ? Object.values(types_1.Locale) : this.getLocalesToUpdate();
58
- logger_1.default.info('Dictionaries - update', { force, locales });
59
- await Promise.all(locales.map((locale) => this.updateDictionary(locale)));
60
- }
61
- getLocalesToUpdate() {
62
- return Object.values(types_1.Locale).filter((locale) => this.cache.isStale(locale) !== false);
63
- }
64
- async updateDictionary(locale) {
65
- logger_1.default.info('Dictionaries - updateDictionary', { locale });
66
- fs_1.default.mkdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
67
- const downloadDictionaryProxy = this.downloadDictionaryProxies[locale];
68
- const trie = await downloadDictionaryProxy();
69
- await this.cache.set(locale, trie);
70
- return trie;
71
- }
72
- }
73
- exports["default"] = Dictionaries;
74
-
75
-
76
- /***/ }),
77
-
78
- /***/ 75823:
79
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
80
-
81
-
82
- var __importDefault = (this && this.__importDefault) || function (mod) {
83
- return (mod && mod.__esModule) ? mod : { "default": mod };
84
- };
85
- Object.defineProperty(exports, "__esModule", ({ value: true }));
86
- exports.OUTPUT_DIRECTORY = exports.CACHE_STALE_THRESHOLD = exports.DAY = void 0;
87
- const os_1 = __importDefault(__webpack_require__(22037));
88
- const path_1 = __importDefault(__webpack_require__(71017));
89
- exports.DAY = 24 * 60 * 60 * 1000;
90
- exports.CACHE_STALE_THRESHOLD = 1 * exports.DAY; // eslint-disable-line no-implicit-coercion
91
- exports.OUTPUT_DIRECTORY = path_1.default.resolve(os_1.default.homedir(), '.scrabble-solver', 'dictionaries');
92
-
93
-
94
- /***/ }),
95
-
96
- /***/ 89044:
97
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
98
-
99
-
100
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
101
- if (k2 === undefined) k2 = k;
102
- var desc = Object.getOwnPropertyDescriptor(m, k);
103
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
104
- desc = { enumerable: true, get: function() { return m[k]; } };
105
- }
106
- Object.defineProperty(o, k2, desc);
107
- }) : (function(o, m, k, k2) {
108
- if (k2 === undefined) k2 = k;
109
- o[k2] = m[k];
110
- }));
111
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
112
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
113
- };
114
- var __importDefault = (this && this.__importDefault) || function (mod) {
115
- return (mod && mod.__esModule) ? mod : { "default": mod };
116
- };
117
- Object.defineProperty(exports, "__esModule", ({ value: true }));
118
- exports.dictionaries = void 0;
119
- const Dictionaries_1 = __importDefault(__webpack_require__(21285));
120
- __exportStar(__webpack_require__(26137), exports);
121
- exports.dictionaries = new Dictionaries_1.default();
122
-
123
-
124
- /***/ }),
125
-
126
- /***/ 2812:
127
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
128
-
129
-
130
- var __importDefault = (this && this.__importDefault) || function (mod) {
131
- return (mod && mod.__esModule) ? mod : { "default": mod };
132
- };
133
- Object.defineProperty(exports, "__esModule", ({ value: true }));
134
- const trie_1 = __webpack_require__(83140);
135
- const fs_1 = __importDefault(__webpack_require__(57147));
136
- const constants_1 = __webpack_require__(75823);
137
- const getDictionaryFilepath_1 = __importDefault(__webpack_require__(68638));
138
- class DiskCache {
139
- async get(locale) {
140
- if (!this.has(locale)) {
141
- return undefined;
142
- }
143
- const filepath = (0, getDictionaryFilepath_1.default)(locale);
144
- const serialized = await fs_1.default.promises.readFile(filepath, 'utf-8');
145
- const trie = trie_1.Trie.deserialize(serialized);
146
- return trie;
147
- }
148
- getLastModifiedTimestamp(locale) {
149
- const filepath = (0, getDictionaryFilepath_1.default)(locale);
150
- if (!fs_1.default.existsSync(filepath)) {
151
- return undefined;
152
- }
153
- const stats = fs_1.default.statSync(filepath);
154
- return stats.mtimeMs;
155
- }
156
- has(locale) {
157
- const filepath = (0, getDictionaryFilepath_1.default)(locale);
158
- return fs_1.default.existsSync(filepath);
159
- }
160
- isStale(locale) {
161
- if (!this.has(locale)) {
162
- return undefined;
163
- }
164
- const lastModifiedTimestamp = this.getLastModifiedTimestamp(locale);
165
- if (typeof lastModifiedTimestamp === 'undefined') {
166
- return undefined;
167
- }
168
- const timeSinceModification = Math.abs(lastModifiedTimestamp - Date.now());
169
- return timeSinceModification > constants_1.CACHE_STALE_THRESHOLD;
170
- }
171
- async set(locale, trie) {
172
- const filepath = (0, getDictionaryFilepath_1.default)(locale);
173
- await fs_1.default.promises.writeFile(filepath, trie.serialize());
174
- }
175
- }
176
- exports["default"] = DiskCache;
177
-
178
-
179
- /***/ }),
180
-
181
- /***/ 70287:
182
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
183
-
184
-
185
- var __importDefault = (this && this.__importDefault) || function (mod) {
186
- return (mod && mod.__esModule) ? mod : { "default": mod };
187
- };
188
- Object.defineProperty(exports, "__esModule", ({ value: true }));
189
- const createCacheTimestampComparator_1 = __importDefault(__webpack_require__(20494));
190
- const DiskCache_1 = __importDefault(__webpack_require__(2812));
191
- const MemoryCache_1 = __importDefault(__webpack_require__(50192));
192
- class LayeredCache {
193
- constructor() {
194
- this.layers = [new MemoryCache_1.default(), new DiskCache_1.default()];
195
- }
196
- async get(locale) {
197
- const cache = this.getLastModifiedLayer(locale);
198
- if (!cache) {
199
- return Promise.resolve(undefined);
200
- }
201
- const [memoryCache, diskCache] = this.layers;
202
- const value = await cache.get(locale);
203
- if (cache === diskCache && typeof value !== 'undefined') {
204
- await memoryCache.set(locale, value);
205
- }
206
- return value;
207
- }
208
- getLastModifiedTimestamp(locale) {
209
- const cache = this.getLastModifiedLayer(locale);
210
- if (!cache) {
211
- return undefined;
212
- }
213
- return cache.getLastModifiedTimestamp(locale);
214
- }
215
- has(locale) {
216
- return this.layers.some((cache) => cache.has(locale));
217
- }
218
- isStale(locale) {
219
- if (this.layers.some((cache) => cache.isStale(locale))) {
220
- return true;
221
- }
222
- if (this.layers.every((cache) => typeof cache.isStale(locale) === 'undefined')) {
223
- return undefined;
224
- }
225
- return false;
226
- }
227
- async set(locale, trie) {
228
- const [memoryCache, diskCache] = this.layers;
229
- await diskCache.set(locale, trie);
230
- await memoryCache.set(locale, trie);
231
- }
232
- getLastModifiedLayer(locale) {
233
- const layers = this.layers.filter((cache) => cache.has(locale));
234
- const [cached] = [...layers].sort((0, createCacheTimestampComparator_1.default)(locale));
235
- return cached;
236
- }
237
- }
238
- exports["default"] = LayeredCache;
239
-
240
-
241
- /***/ }),
242
-
243
- /***/ 50192:
244
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
245
-
246
-
247
- Object.defineProperty(exports, "__esModule", ({ value: true }));
248
- const constants_1 = __webpack_require__(75823);
249
- class MemoryCache {
250
- constructor() {
251
- this.cache = {};
252
- this.cacheTimestamps = {};
253
- }
254
- get(locale) {
255
- return Promise.resolve(this.cache[locale]);
256
- }
257
- getLastModifiedTimestamp(locale) {
258
- return this.cacheTimestamps[locale];
259
- }
260
- has(locale) {
261
- return typeof this.cache[locale] !== 'undefined';
262
- }
263
- isStale(locale) {
264
- const timestamp = this.getLastModifiedTimestamp(locale);
265
- if (!this.has(locale) || typeof timestamp === 'undefined') {
266
- return undefined;
267
- }
268
- const timeSinceModification = Math.abs(timestamp - Date.now());
269
- return timeSinceModification > constants_1.CACHE_STALE_THRESHOLD;
270
- }
271
- set(locale, trie) {
272
- this.cacheTimestamps[locale] = Date.now();
273
- this.cache[locale] = trie;
274
- return Promise.resolve();
275
- }
276
- }
277
- exports["default"] = MemoryCache;
278
-
279
-
280
- /***/ }),
281
-
282
- /***/ 26554:
283
- /***/ ((__unused_webpack_module, exports) => {
284
-
285
-
286
- Object.defineProperty(exports, "__esModule", ({ value: true }));
287
- const createAsyncProxy = (asyncCallback) => {
288
- let promise = null;
289
- return async () => {
290
- if (promise) {
291
- return promise;
292
- }
293
- try {
294
- promise = asyncCallback();
295
- return await promise;
296
- }
297
- finally {
298
- promise = null;
299
- }
300
- };
301
- };
302
- exports["default"] = createAsyncProxy;
303
-
304
-
305
- /***/ }),
306
-
307
- /***/ 20494:
308
- /***/ ((__unused_webpack_module, exports) => {
309
-
310
-
311
- Object.defineProperty(exports, "__esModule", ({ value: true }));
312
- const createCacheTimestampComparator = (locale) => {
313
- return (a, b) => {
314
- const aTimestamp = a.getLastModifiedTimestamp(locale);
315
- const bTimestamp = b.getLastModifiedTimestamp(locale);
316
- if (aTimestamp === bTimestamp) {
317
- return 0;
318
- }
319
- if (typeof aTimestamp === 'undefined') {
320
- return 1;
321
- }
322
- if (typeof bTimestamp === 'undefined') {
323
- return -1;
324
- }
325
- return bTimestamp - aTimestamp;
326
- };
327
- };
328
- exports["default"] = createCacheTimestampComparator;
329
-
330
-
331
- /***/ }),
332
-
333
- /***/ 41281:
334
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
335
-
336
-
337
- var __importDefault = (this && this.__importDefault) || function (mod) {
338
- return (mod && mod.__esModule) ? mod : { "default": mod };
339
- };
340
- Object.defineProperty(exports, "__esModule", ({ value: true }));
341
- const trie_1 = __webpack_require__(83140);
342
- const logger_1 = __importDefault(__webpack_require__(52954));
343
- const word_lists_1 = __webpack_require__(51585);
344
- const downloadDictionary = async (locale) => {
345
- logger_1.default.info('downloadDictionary', { locale });
346
- const words = await (0, word_lists_1.getWordList)(locale);
347
- logger_1.default.info('downloadDictionary - success', { locale });
348
- const trie = trie_1.Trie.fromArray(words);
349
- return trie;
350
- };
351
- exports["default"] = downloadDictionary;
352
-
353
-
354
- /***/ }),
355
-
356
- /***/ 68638:
357
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
358
-
359
-
360
- var __importDefault = (this && this.__importDefault) || function (mod) {
361
- return (mod && mod.__esModule) ? mod : { "default": mod };
362
- };
363
- Object.defineProperty(exports, "__esModule", ({ value: true }));
364
- const path_1 = __importDefault(__webpack_require__(71017));
365
- const constants_1 = __webpack_require__(75823);
366
- const getDictionaryFilepath = (locale) => {
367
- return path_1.default.resolve(constants_1.OUTPUT_DIRECTORY, `${locale}.txt`);
368
- };
369
- exports["default"] = getDictionaryFilepath;
370
-
371
-
372
- /***/ }),
373
-
374
- /***/ 26137:
375
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
376
-
377
-
378
- var __importDefault = (this && this.__importDefault) || function (mod) {
379
- return (mod && mod.__esModule) ? mod : { "default": mod };
380
- };
381
- Object.defineProperty(exports, "__esModule", ({ value: true }));
382
- exports.MemoryCache = exports.LayeredCache = exports.getDictionaryFilepath = exports.downloadDictionary = exports.DiskCache = exports.createCacheTimestampComparator = exports.createAsyncProxy = void 0;
383
- var createAsyncProxy_1 = __webpack_require__(26554);
384
- Object.defineProperty(exports, "createAsyncProxy", ({ enumerable: true, get: function () { return __importDefault(createAsyncProxy_1).default; } }));
385
- var createCacheTimestampComparator_1 = __webpack_require__(20494);
386
- Object.defineProperty(exports, "createCacheTimestampComparator", ({ enumerable: true, get: function () { return __importDefault(createCacheTimestampComparator_1).default; } }));
387
- var DiskCache_1 = __webpack_require__(2812);
388
- Object.defineProperty(exports, "DiskCache", ({ enumerable: true, get: function () { return __importDefault(DiskCache_1).default; } }));
389
- var downloadDictionary_1 = __webpack_require__(41281);
390
- Object.defineProperty(exports, "downloadDictionary", ({ enumerable: true, get: function () { return __importDefault(downloadDictionary_1).default; } }));
391
- var getDictionaryFilepath_1 = __webpack_require__(68638);
392
- Object.defineProperty(exports, "getDictionaryFilepath", ({ enumerable: true, get: function () { return __importDefault(getDictionaryFilepath_1).default; } }));
393
- var LayeredCache_1 = __webpack_require__(70287);
394
- Object.defineProperty(exports, "LayeredCache", ({ enumerable: true, get: function () { return __importDefault(LayeredCache_1).default; } }));
395
- var MemoryCache_1 = __webpack_require__(50192);
396
- Object.defineProperty(exports, "MemoryCache", ({ enumerable: true, get: function () { return __importDefault(MemoryCache_1).default; } }));
397
-
398
-
399
- /***/ }),
400
-
401
- /***/ 83017:
402
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
403
-
404
-
405
- var __importDefault = (this && this.__importDefault) || function (mod) {
406
- return (mod && mod.__esModule) ? mod : { "default": mod };
407
- };
408
- Object.defineProperty(exports, "__esModule", ({ value: true }));
409
- const constants_1 = __webpack_require__(38436);
410
- const Cell_1 = __importDefault(__webpack_require__(70902));
411
- const Tile_1 = __importDefault(__webpack_require__(580));
412
- class Board {
413
- static create(width, height) {
414
- return Board.fromStringArray(Array(height).fill(Array(width).fill(' ').join('')));
415
- }
416
- static fromJson(json) {
417
- return new Board({
418
- rows: json.map((row) => row.map(Cell_1.default.fromJson)),
419
- });
420
- }
421
- static fromStringArray(stringArray) {
422
- return new Board({
423
- rows: stringArray.map((row, y) => row.split('').map((character, x) => new Cell_1.default({
424
- isEmpty: !character || character === constants_1.EMPTY_CELL,
425
- tile: character === constants_1.EMPTY_CELL ? Tile_1.default.Null : new Tile_1.default({ character }),
426
- x,
427
- y,
428
- }))),
429
- });
430
- }
431
- constructor({ rows }) {
432
- this.rows = rows;
433
- this.columnsCount = rows[0].length;
434
- this.rowsCount = rows.length;
435
- }
436
- get center() {
437
- const x = Math.floor(this.columnsCount / 2);
438
- const y = Math.floor(this.rowsCount / 2);
439
- return this.rows[y][x];
440
- }
441
- clone() {
442
- const rows = this.rows.map((row) => row.map((cell) => cell.clone()));
443
- return new Board({ rows });
444
- }
445
- collides(cell) {
446
- return this.collidesUp(cell) || this.collidesDown(cell) || this.collidesLeft(cell) || this.collidesRight(cell);
447
- }
448
- collidesDown({ x, y }) {
449
- return y < this.rowsCount - 1 && !this.rows[y + 1][x].isEmpty;
450
- }
451
- collidesLeft({ x, y }) {
452
- return x > 0 && !this.rows[y][x - 1].isEmpty;
453
- }
454
- collidesRight({ x, y }) {
455
- return x < this.columnsCount - 1 && !this.rows[y][x + 1].isEmpty;
456
- }
457
- collidesUp({ x, y }) {
458
- return y > 0 && !this.rows[y - 1][x].isEmpty;
459
- }
460
- equals(other) {
461
- return (this.columnsCount === other.columnsCount &&
462
- this.rowsCount === other.rowsCount &&
463
- this.rows.every((row, rowIndex) => {
464
- return row.every((cell, cellIndex) => {
465
- return cell.equals(other.rows[rowIndex][cellIndex]);
466
- });
467
- }));
468
- }
469
- getBlanksCount() {
470
- return this.rows.reduce((count, row) => {
471
- return count + row.reduce((rowCount, cell) => rowCount + (cell.tile.isBlank ? 1 : 0), 0);
472
- }, 0);
473
- }
474
- getColumn(index) {
475
- return this.rows.map((row) => row[index]);
476
- }
477
- getRow(index) {
478
- return this.rows[index];
479
- }
480
- getTilesCount() {
481
- return this.rows.reduce((count, row) => {
482
- return count + row.reduce((rowCount, cell) => rowCount + (cell.hasTile() ? 1 : 0), 0);
483
- }, 0);
484
- }
485
- getWords() {
486
- const columns = [];
487
- for (let x = 0; x < this.columnsCount; ++x) {
488
- const column = [];
489
- for (let y = 0; y < this.rowsCount; ++y) {
490
- column.push(this.rows[y][x]);
491
- }
492
- columns.push(column);
493
- }
494
- const columnsBoard = new Board({ rows: columns });
495
- const lines = this.toString().split('\n').concat(columnsBoard.toString().split('\n'));
496
- const words = lines
497
- .flatMap((line) => line.replaceAll(/\s+/g, constants_1.EMPTY_CELL).split(' '))
498
- .filter((word) => word.length > 1);
499
- return words;
500
- }
501
- isEmpty() {
502
- return this.rows.every((row) => row.every(({ isEmpty }) => isEmpty));
503
- }
504
- toJson() {
505
- return this.rows.map((row) => row.map((cell) => cell.toJson()));
506
- }
507
- toString() {
508
- return this.rows.map((row) => row.map(String).join('')).join('\n');
509
- }
510
- updateCell(x, y, updateCell) {
511
- this.rows[y][x] = updateCell(this.rows[y][x]);
512
- }
513
- updateRow(y, updateRow) {
514
- this.rows[y] = updateRow(this.rows[y]);
515
- }
516
- }
517
- exports["default"] = Board;
518
-
519
-
520
- /***/ }),
521
-
522
- /***/ 28508:
523
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
524
-
525
-
526
- Object.defineProperty(exports, "__esModule", ({ value: true }));
527
- exports.isBoardJson = void 0;
528
- const CellJson_1 = __webpack_require__(56508);
529
- const isBoardJson = (value) => {
530
- if (!Array.isArray(value)) {
531
- return false;
532
- }
533
- for (const row of value) {
534
- if (!Array.isArray(value)) {
535
- return false;
536
- }
537
- for (const cell of row) {
538
- if (!(0, CellJson_1.isCellJson)(cell)) {
539
- return false;
540
- }
541
- }
542
- }
543
- return true;
544
- };
545
- exports.isBoardJson = isBoardJson;
546
-
547
-
548
- /***/ }),
549
-
550
- /***/ 80769:
551
- /***/ ((__unused_webpack_module, exports) => {
552
-
553
-
554
- Object.defineProperty(exports, "__esModule", ({ value: true }));
555
- class Bonus {
556
- constructor({ multiplier, score, x, y }) {
557
- this.multiplier = multiplier;
558
- this.score = score;
559
- this.x = x;
560
- this.y = y;
561
- }
562
- canApply(_config, cell) {
563
- return cell.isEmpty && this.matchesCellCoordinates(cell);
564
- }
565
- matchesCellCoordinates(cell) {
566
- return this.x === cell.x && this.y === cell.y;
567
- }
568
- toJson() {
569
- return {
570
- multiplier: this.multiplier,
571
- score: this.score,
572
- type: this.type,
573
- x: this.x,
574
- y: this.y,
575
- };
576
- }
577
- get value() {
578
- return {
579
- characterMultiplier: 1,
580
- wordMultiplier: 1,
581
- };
582
- }
583
- }
584
- exports["default"] = Bonus;
585
-
586
-
587
- /***/ }),
588
-
589
- /***/ 70902:
590
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
591
-
592
-
593
- var __importDefault = (this && this.__importDefault) || function (mod) {
594
- return (mod && mod.__esModule) ? mod : { "default": mod };
595
- };
596
- Object.defineProperty(exports, "__esModule", ({ value: true }));
597
- const Tile_1 = __importDefault(__webpack_require__(580));
598
- class Cell {
599
- static fromJson(json) {
600
- return new Cell({
601
- isEmpty: json.isEmpty,
602
- tile: Tile_1.default.fromJson(json.tile),
603
- x: json.x,
604
- y: json.y,
605
- });
606
- }
607
- // eslint-disable-next-line no-undef
608
- constructor({ isEmpty = true, tile = Tile_1.default.Null, x, y }) {
609
- this.isEmpty = isEmpty;
610
- this.tile = tile;
611
- this.x = x;
612
- this.y = y;
613
- }
614
- clone() {
615
- return new Cell({
616
- isEmpty: this.isEmpty,
617
- tile: this.tile.clone(),
618
- x: this.x,
619
- y: this.y,
620
- });
621
- }
622
- equals(other) {
623
- return this.x === other.x && this.y === other.y && this.isEmpty === other.isEmpty && this.tile.equals(other.tile);
624
- }
625
- hasTile() {
626
- return this.tile !== Tile_1.default.Null;
627
- }
628
- isCandidate() {
629
- return this.isEmpty && this.hasTile();
630
- }
631
- toJson() {
632
- return {
633
- isEmpty: this.isEmpty,
634
- tile: this.tile.toJson(),
635
- x: this.x,
636
- y: this.y,
637
- };
638
- }
639
- toString() {
640
- return this.tile.toString();
641
- }
642
- }
643
- exports["default"] = Cell;
644
-
645
-
646
- /***/ }),
647
-
648
- /***/ 56508:
649
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
650
-
651
-
652
- var __importDefault = (this && this.__importDefault) || function (mod) {
653
- return (mod && mod.__esModule) ? mod : { "default": mod };
654
- };
655
- Object.defineProperty(exports, "__esModule", ({ value: true }));
656
- exports.isCellJson = void 0;
657
- const isObject_1 = __importDefault(__webpack_require__(93518));
658
- const TileJson_1 = __webpack_require__(92298);
659
- const isCellJson = (value) => {
660
- return ((0, isObject_1.default)(value) &&
661
- typeof value.isEmpty === 'boolean' &&
662
- ((0, TileJson_1.isTileJson)(value.tile) || value.tile === null) &&
663
- typeof value.x === 'number' &&
664
- typeof value.y === 'number');
665
- };
666
- exports.isCellJson = isCellJson;
667
-
668
-
669
- /***/ }),
670
-
671
- /***/ 95699:
672
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
673
-
674
-
675
- var __importDefault = (this && this.__importDefault) || function (mod) {
676
- return (mod && mod.__esModule) ? mod : { "default": mod };
677
- };
678
- Object.defineProperty(exports, "__esModule", ({ value: true }));
679
- const constants_1 = __webpack_require__(38436);
680
- const Bonus_1 = __importDefault(__webpack_require__(80769));
681
- class CharacterBonus extends Bonus_1.default {
682
- constructor() {
683
- super(...arguments);
684
- this.type = constants_1.BONUS_CHARACTER;
685
- }
686
- canApply(config, cell) {
687
- return super.canApply(config, cell) && this.matchesCellTileScore(config, cell);
688
- }
689
- matchesCellTileScore(config, cell) {
690
- if (typeof this.score === 'undefined') {
691
- return true;
692
- }
693
- return this.score === config.pointsMap[cell.tile.character];
694
- }
695
- get value() {
696
- return {
697
- characterMultiplier: this.multiplier,
698
- wordMultiplier: 1,
699
- };
700
- }
701
- }
702
- exports["default"] = CharacterBonus;
703
-
704
-
705
- /***/ }),
706
-
707
- /***/ 68725:
708
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
709
-
710
-
711
- var __importDefault = (this && this.__importDefault) || function (mod) {
712
- return (mod && mod.__esModule) ? mod : { "default": mod };
713
- };
714
- Object.defineProperty(exports, "__esModule", ({ value: true }));
715
- const constants_1 = __webpack_require__(38436);
716
- const CharacterBonus_1 = __importDefault(__webpack_require__(95699));
717
- const WordBonus_1 = __importDefault(__webpack_require__(39667));
718
- class Config {
719
- static fromJson(json) {
720
- return new Config(json);
721
- }
722
- constructor(config) {
723
- this.bonuses = getBonuses(config);
724
- this.config = config;
725
- this.pointsMap = getPointsMap(this.config);
726
- }
727
- get allTilesBonusScore() {
728
- return this.config.allTilesBonusScore;
729
- }
730
- get alphabet() {
731
- return getAlphabet(this.config);
732
- }
733
- get blankScore() {
734
- return this.config.blankScore;
735
- }
736
- get blanksCount() {
737
- return this.config.blanksCount;
738
- }
739
- get boardHeight() {
740
- return this.config.boardHeight;
741
- }
742
- get boardWidth() {
743
- return this.config.boardWidth;
744
- }
745
- get game() {
746
- return this.config.game;
747
- }
748
- get locale() {
749
- return this.config.locale;
750
- }
751
- get twoCharacterTiles() {
752
- return this.config.tiles.filter((tile) => tile.character.length === 2).map((tile) => tile.character);
753
- }
754
- getCellBonus(cell) {
755
- return this.bonuses.find((bonus) => bonus.matchesCellCoordinates(cell));
756
- }
757
- getCellBonusValue(cell) {
758
- return this.getCellBonus(cell)?.value || constants_1.NO_BONUS;
759
- }
760
- getCharacterPoints(character) {
761
- if (character === null) {
762
- return undefined;
763
- }
764
- if (character === constants_1.BLANK) {
765
- return this.blankScore;
766
- }
767
- return this.pointsMap[character];
768
- }
769
- getTwoCharacterTileByPrefix(character) {
770
- if (character.length !== 1) {
771
- return undefined;
772
- }
773
- return this.twoCharacterTiles.find((characters) => characters.startsWith(character));
774
- }
775
- getTilePoints(tile) {
776
- if (tile === null) {
777
- return undefined;
778
- }
779
- return tile.isBlank ? this.blankScore : this.getCharacterPoints(tile.character);
780
- }
781
- hasCharacter(character) {
782
- return character in this.pointsMap;
783
- }
784
- isTwoCharacterTilePrefix(character) {
785
- return typeof this.getTwoCharacterTileByPrefix(character) !== 'undefined';
786
- }
787
- get maximumCharactersCount() {
788
- return this.config.maximumCharactersCount;
789
- }
790
- get tiles() {
791
- return this.config.tiles;
792
- }
793
- toJson() {
794
- return this.config;
795
- }
796
- }
797
- const getBonuses = (config) => {
798
- return config.bonuses.map((bonus) => {
799
- if (bonus.type === constants_1.BONUS_CHARACTER) {
800
- return new CharacterBonus_1.default(bonus);
801
- }
802
- if (bonus.type === constants_1.BONUS_WORD) {
803
- return new WordBonus_1.default(bonus);
804
- }
805
- throw new Error(`Unsupported Bonus type: "${bonus.type}"`);
806
- });
807
- };
808
- const getAlphabet = (config) => config.tiles.map(({ character }) => character);
809
- const getPointsMap = (config) => config.tiles.reduce((pointsMap, { character, score }) => ({
810
- ...pointsMap,
811
- [character]: score,
812
- }), {});
813
- exports["default"] = Config;
814
-
815
-
816
- /***/ }),
817
-
818
- /***/ 79238:
819
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
820
-
821
-
822
- var __importDefault = (this && this.__importDefault) || function (mod) {
823
- return (mod && mod.__esModule) ? mod : { "default": mod };
824
- };
825
- Object.defineProperty(exports, "__esModule", ({ value: true }));
826
- const Pattern_1 = __importDefault(__webpack_require__(43600));
827
- class FinalPattern extends Pattern_1.default {
828
- constructor(pattern) {
829
- super(pattern.board, pattern.cells);
830
- this.collisions = pattern.getCollisions();
831
- }
832
- getCollisions() {
833
- return this.collisions;
834
- }
835
- }
836
- exports["default"] = FinalPattern;
837
-
838
-
839
- /***/ }),
840
-
841
- /***/ 47659:
842
- /***/ ((__unused_webpack_module, exports) => {
843
-
844
-
845
- Object.defineProperty(exports, "__esModule", ({ value: true }));
846
- exports.isGame = void 0;
847
- var Game;
848
- (function (Game) {
849
- Game["Literaki"] = "literaki";
850
- Game["Scrabble"] = "scrabble";
851
- Game["SuperScrabble"] = "super-scrabble";
852
- })(Game || (Game = {}));
853
- const games = Object.values(Game);
854
- const isGame = (locale) => games.includes(locale);
855
- exports.isGame = isGame;
856
- exports["default"] = Game;
857
-
858
-
859
- /***/ }),
860
-
861
- /***/ 44405:
862
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
863
-
864
-
865
- var __importDefault = (this && this.__importDefault) || function (mod) {
866
- return (mod && mod.__esModule) ? mod : { "default": mod };
867
- };
868
- Object.defineProperty(exports, "__esModule", ({ value: true }));
869
- const Pattern_1 = __importDefault(__webpack_require__(43600));
870
- class HorizontalPattern extends Pattern_1.default {
871
- clone() {
872
- return new HorizontalPattern(this.board, this.cells.map((cell) => cell.clone()));
873
- }
874
- getCollisions() {
875
- const collisions = [];
876
- this.cells
877
- .filter((cell) => cell.isEmpty && (this.board.collidesUp(cell) || this.board.collidesDown(cell)))
878
- .forEach((cell) => {
879
- const column = this.board.getColumn(cell.x);
880
- let y = cell.y - 1;
881
- while (y >= 0 && column[y].hasTile()) {
882
- --y;
883
- }
884
- const previousCells = column.slice(y + 1, cell.y);
885
- y = cell.y + 1;
886
- while (y < column.length && column[y].hasTile()) {
887
- ++y;
888
- }
889
- const nextCells = column.slice(cell.y + 1, y);
890
- const cells = [...previousCells, cell, ...nextCells];
891
- if (cells.length > 1) {
892
- const pattern = new Pattern_1.default(this.board, cells);
893
- collisions.push(pattern);
894
- }
895
- });
896
- return collisions;
897
- }
898
- }
899
- exports["default"] = HorizontalPattern;
900
-
901
-
902
- /***/ }),
903
-
904
- /***/ 28044:
905
- /***/ ((__unused_webpack_module, exports) => {
906
-
907
-
908
- Object.defineProperty(exports, "__esModule", ({ value: true }));
909
- exports.isLocale = void 0;
910
- /**
911
- * Locales are defined using IETF language tags
912
- * @see https://en.wikipedia.org/wiki/IETF_language_tag
913
- * @see https://en.wikipedia.org/wiki/ISO_3166-1
914
- */
915
- var Locale;
916
- (function (Locale) {
917
- Locale["DE_DE"] = "de-DE";
918
- Locale["EN_GB"] = "en-GB";
919
- Locale["EN_US"] = "en-US";
920
- Locale["ES_ES"] = "es-ES";
921
- Locale["FA_IR"] = "fa-IR";
922
- Locale["FR_FR"] = "fr-FR";
923
- Locale["PL_PL"] = "pl-PL";
924
- Locale["RO_RO"] = "ro-RO";
925
- })(Locale || (Locale = {}));
926
- const locales = Object.values(Locale);
927
- const isLocale = (locale) => locales.includes(locale);
928
- exports.isLocale = isLocale;
929
- exports["default"] = Locale;
930
-
931
-
932
- /***/ }),
933
-
934
- /***/ 43600:
935
- /***/ ((__unused_webpack_module, exports) => {
936
-
937
-
938
- Object.defineProperty(exports, "__esModule", ({ value: true }));
939
- class Pattern {
940
- constructor(board, cells) {
941
- this.board = board;
942
- this.cells = cells;
943
- }
944
- canBePlaced(config) {
945
- const emptyCellsCount = this.getEmptyCellsCount();
946
- const isUsedCellsCountInRange = emptyCellsCount >= 1 && emptyCellsCount <= config.maximumCharactersCount;
947
- return (isUsedCellsCountInRange &&
948
- (this.hasAtLeast1NonEmptyCell() || this.collides() || (this.goesThroughBoardCenter() && this.board.isEmpty())));
949
- }
950
- clone() {
951
- return new Pattern(this.board, this.cells.map((cell) => cell.clone()));
952
- }
953
- collides() {
954
- return this.cells.some((cell) => cell.isEmpty && this.board.collides(cell));
955
- }
956
- getIndexOfFirstCellWithoutTile() {
957
- return this.cells.findIndex((cell) => !cell.hasTile());
958
- }
959
- getEmptyCellsCount() {
960
- return this.cells.filter((cell) => cell.isEmpty).length;
961
- }
962
- goesThroughBoardCenter() {
963
- return this.cells.some((cell) => cell.x === this.board.center.x && cell.y === this.board.center.y && cell.isEmpty);
964
- }
965
- hasAtLeast1EmptyCell() {
966
- return this.cells.some((cell) => cell.isEmpty);
967
- }
968
- hasAtLeast1NonEmptyCell() {
969
- return this.cells.some((cell) => !cell.isEmpty);
970
- }
971
- getCollisions() {
972
- return [];
973
- }
974
- toJson() {
975
- return {
976
- cells: this.cells.map((cell) => cell.toJson()),
977
- collisions: this.getCollisions().map((collision) => collision.toJson()),
978
- word: this.toString(),
979
- };
980
- }
981
- toString() {
982
- return this.cells.reduce((result, cell) => result + cell.toString(), '');
983
- }
984
- }
985
- exports["default"] = Pattern;
986
-
987
-
988
- /***/ }),
989
-
990
- /***/ 28211:
991
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
992
-
993
-
994
- var __importDefault = (this && this.__importDefault) || function (mod) {
995
- return (mod && mod.__esModule) ? mod : { "default": mod };
996
- };
997
- Object.defineProperty(exports, "__esModule", ({ value: true }));
998
- const constants_1 = __webpack_require__(38436);
999
- const Cell_1 = __importDefault(__webpack_require__(70902));
1000
- class Result {
1001
- static fromJson(json) {
1002
- return new Result({
1003
- id: json.id,
1004
- cells: json.cells.map(Cell_1.default.fromJson),
1005
- collisions: json.collisions.map((collision) => collision.map(Cell_1.default.fromJson)),
1006
- points: json.points,
1007
- });
1008
- }
1009
- constructor({ cells, id, collisions, points, }) {
1010
- const tiles = getTiles(cells);
1011
- this.blanksCount = getBlanks(tiles).length;
1012
- this.cells = cells;
1013
- this.collisions = collisions;
1014
- this.consonantsCount = getConsonants(tiles).length;
1015
- this.id = id;
1016
- this.length = cells.length;
1017
- this.points = points;
1018
- this.pointsRatio = getPointsRatio(tiles, points);
1019
- this.tiles = tiles;
1020
- this.tilesCount = tiles.length;
1021
- this.vowelsCount = getVowels(tiles).length;
1022
- this.word = getWord(cells);
1023
- this.words = getWords(cells, collisions);
1024
- this.wordsCount = 1 + this.collisions.length;
1025
- }
1026
- toJson() {
1027
- return {
1028
- cells: this.cells.map((cell) => cell.toJson()),
1029
- id: this.id,
1030
- collisions: this.collisions.map((collision) => collision.map((cell) => cell.toJson())),
1031
- points: this.points,
1032
- };
1033
- }
1034
- }
1035
- const getBlanks = (tiles) => tiles.filter(({ isBlank }) => isBlank);
1036
- const getConsonants = (tiles) => tiles.filter(isConsonant);
1037
- const getVowels = (tiles) => tiles.filter(isVowel);
1038
- const getPointsRatio = (tiles, points) => points / tiles.length;
1039
- const getTiles = (cells) => cells.filter(({ isEmpty }) => isEmpty).map(({ tile }) => tile);
1040
- // eslint-disable-next-line prefer-template
1041
- const getWord = (cells) => cells.reduce((word, cell) => word + cell.toString(), '');
1042
- const getWords = (cells, collisions) => [cells, ...collisions].map(getWord);
1043
- const isConsonant = ({ character, isBlank }) => constants_1.CONSONANTS.includes(character) && !isBlank;
1044
- const isVowel = ({ character, isBlank }) => constants_1.VOWELS.includes(character) && !isBlank;
1045
- exports["default"] = Result;
1046
-
1047
-
1048
- /***/ }),
1049
-
1050
- /***/ 580:
1051
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1052
-
1053
-
1054
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1055
- const constants_1 = __webpack_require__(38436);
1056
- class Tile {
1057
- static fromJson(json) {
1058
- if (!json) {
1059
- return Tile.Null;
1060
- }
1061
- return new Tile({
1062
- character: json.character,
1063
- isBlank: json.isBlank,
1064
- });
1065
- }
1066
- constructor({ character, isBlank = false }) {
1067
- this.character = character;
1068
- this.isBlank = isBlank;
1069
- }
1070
- clone() {
1071
- return new Tile({
1072
- character: this.character,
1073
- isBlank: this.isBlank,
1074
- });
1075
- }
1076
- equals(other) {
1077
- return this.character === other.character && this.isBlank === other.isBlank;
1078
- }
1079
- toJson() {
1080
- return {
1081
- character: this.character,
1082
- isBlank: this.isBlank,
1083
- };
1084
- }
1085
- toString() {
1086
- return this.character;
1087
- }
1088
- }
1089
- Tile.Null = Object.freeze({
1090
- character: constants_1.EMPTY_CELL,
1091
- isBlank: false,
1092
- clone: () => Tile.Null,
1093
- equals: (other) => other === Tile.Null,
1094
- toJson: () => null,
1095
- toString: () => constants_1.EMPTY_CELL,
1096
- });
1097
- exports["default"] = Tile;
1098
-
1099
-
1100
- /***/ }),
1101
-
1102
- /***/ 92298:
1103
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1104
-
1105
-
1106
- var __importDefault = (this && this.__importDefault) || function (mod) {
1107
- return (mod && mod.__esModule) ? mod : { "default": mod };
1108
- };
1109
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1110
- exports.isTileJson = void 0;
1111
- const isObject_1 = __importDefault(__webpack_require__(93518));
1112
- const isTileJson = (value) => {
1113
- return (0, isObject_1.default)(value) && typeof value.character === 'string' && typeof value.isBlank === 'boolean';
1114
- };
1115
- exports.isTileJson = isTileJson;
1116
-
1117
-
1118
- /***/ }),
1119
-
1120
- /***/ 36161:
1121
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1122
-
1123
-
1124
- var __importDefault = (this && this.__importDefault) || function (mod) {
1125
- return (mod && mod.__esModule) ? mod : { "default": mod };
1126
- };
1127
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1128
- const Pattern_1 = __importDefault(__webpack_require__(43600));
1129
- class VerticalPattern extends Pattern_1.default {
1130
- clone() {
1131
- return new VerticalPattern(this.board, this.cells.map((cell) => cell.clone()));
1132
- }
1133
- getCollisions() {
1134
- const collisions = [];
1135
- this.cells
1136
- .filter((cell) => cell.isEmpty && (this.board.collidesLeft(cell) || this.board.collidesRight(cell)))
1137
- .forEach((cell) => {
1138
- const row = this.board.getRow(cell.y);
1139
- let x = cell.x - 1;
1140
- while (x >= 0 && row[x].hasTile()) {
1141
- --x;
1142
- }
1143
- const previousCells = row.slice(x + 1, cell.x);
1144
- x = cell.x + 1;
1145
- while (x < row.length && row[x].hasTile()) {
1146
- ++x;
1147
- }
1148
- const nextCells = row.slice(cell.x + 1, x);
1149
- const cells = [...previousCells, cell, ...nextCells];
1150
- if (cells.length > 1) {
1151
- const pattern = new Pattern_1.default(this.board, cells);
1152
- collisions.push(pattern);
1153
- }
1154
- });
1155
- return collisions;
1156
- }
1157
- }
1158
- exports["default"] = VerticalPattern;
1159
-
1160
-
1161
- /***/ }),
1162
-
1163
- /***/ 39667:
1164
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1165
-
1166
-
1167
- var __importDefault = (this && this.__importDefault) || function (mod) {
1168
- return (mod && mod.__esModule) ? mod : { "default": mod };
1169
- };
1170
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1171
- const constants_1 = __webpack_require__(38436);
1172
- const Bonus_1 = __importDefault(__webpack_require__(80769));
1173
- class WordBonus extends Bonus_1.default {
1174
- constructor() {
1175
- super(...arguments);
1176
- this.type = constants_1.BONUS_WORD;
1177
- }
1178
- get value() {
1179
- return {
1180
- characterMultiplier: 1,
1181
- wordMultiplier: this.multiplier,
1182
- };
1183
- }
1184
- }
1185
- exports["default"] = WordBonus;
1186
-
1187
-
1188
- /***/ }),
1189
-
1190
- /***/ 43184:
1191
- /***/ ((__unused_webpack_module, exports) => {
1192
-
1193
-
1194
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1195
- class WordDefinition {
1196
- static fromJson(json) {
1197
- if (!json) {
1198
- return WordDefinition.Null;
1199
- }
1200
- return new WordDefinition({
1201
- definitions: json.definitions,
1202
- exists: json.exists,
1203
- isAllowed: json.isAllowed,
1204
- word: json.word,
1205
- });
1206
- }
1207
- constructor({ definitions, exists, isAllowed, word }) {
1208
- this.definitions = definitions;
1209
- this.exists = exists;
1210
- this.isAllowed = isAllowed;
1211
- this.word = word;
1212
- }
1213
- toJson() {
1214
- return {
1215
- definitions: this.definitions,
1216
- exists: this.exists,
1217
- isAllowed: this.isAllowed,
1218
- word: this.word,
1219
- };
1220
- }
1221
- }
1222
- WordDefinition.Null = Object.freeze({
1223
- definitions: [],
1224
- exists: false,
1225
- isAllowed: false,
1226
- word: '',
1227
- toJson: () => null,
1228
- });
1229
- exports["default"] = WordDefinition;
1230
-
1231
-
1232
- /***/ }),
1233
-
1234
- /***/ 46452:
1235
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1236
-
1237
-
1238
- var __importDefault = (this && this.__importDefault) || function (mod) {
1239
- return (mod && mod.__esModule) ? mod : { "default": mod };
1240
- };
1241
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1242
- exports.isObject = exports.isError = exports.WordDefinition = exports.WordBonus = exports.VerticalPattern = exports.isTileJson = exports.Tile = exports.Result = exports.Pattern = exports.isLocale = exports.Locale = exports.HorizontalPattern = exports.isGame = exports.Game = exports.FinalPattern = exports.Config = exports.CharacterBonus = exports.isCellJson = exports.Cell = exports.Bonus = exports.isBoardJson = exports.Board = void 0;
1243
- var Board_1 = __webpack_require__(83017);
1244
- Object.defineProperty(exports, "Board", ({ enumerable: true, get: function () { return __importDefault(Board_1).default; } }));
1245
- var BoardJson_1 = __webpack_require__(28508);
1246
- Object.defineProperty(exports, "isBoardJson", ({ enumerable: true, get: function () { return BoardJson_1.isBoardJson; } }));
1247
- var Bonus_1 = __webpack_require__(80769);
1248
- Object.defineProperty(exports, "Bonus", ({ enumerable: true, get: function () { return __importDefault(Bonus_1).default; } }));
1249
- var Cell_1 = __webpack_require__(70902);
1250
- Object.defineProperty(exports, "Cell", ({ enumerable: true, get: function () { return __importDefault(Cell_1).default; } }));
1251
- var CellJson_1 = __webpack_require__(56508);
1252
- Object.defineProperty(exports, "isCellJson", ({ enumerable: true, get: function () { return CellJson_1.isCellJson; } }));
1253
- var CharacterBonus_1 = __webpack_require__(95699);
1254
- Object.defineProperty(exports, "CharacterBonus", ({ enumerable: true, get: function () { return __importDefault(CharacterBonus_1).default; } }));
1255
- var Config_1 = __webpack_require__(68725);
1256
- Object.defineProperty(exports, "Config", ({ enumerable: true, get: function () { return __importDefault(Config_1).default; } }));
1257
- var FinalPattern_1 = __webpack_require__(79238);
1258
- Object.defineProperty(exports, "FinalPattern", ({ enumerable: true, get: function () { return __importDefault(FinalPattern_1).default; } }));
1259
- var Game_1 = __webpack_require__(47659);
1260
- Object.defineProperty(exports, "Game", ({ enumerable: true, get: function () { return __importDefault(Game_1).default; } }));
1261
- Object.defineProperty(exports, "isGame", ({ enumerable: true, get: function () { return Game_1.isGame; } }));
1262
- var HorizontalPattern_1 = __webpack_require__(44405);
1263
- Object.defineProperty(exports, "HorizontalPattern", ({ enumerable: true, get: function () { return __importDefault(HorizontalPattern_1).default; } }));
1264
- var Locale_1 = __webpack_require__(28044);
1265
- Object.defineProperty(exports, "Locale", ({ enumerable: true, get: function () { return __importDefault(Locale_1).default; } }));
1266
- Object.defineProperty(exports, "isLocale", ({ enumerable: true, get: function () { return Locale_1.isLocale; } }));
1267
- var Pattern_1 = __webpack_require__(43600);
1268
- Object.defineProperty(exports, "Pattern", ({ enumerable: true, get: function () { return __importDefault(Pattern_1).default; } }));
1269
- var Result_1 = __webpack_require__(28211);
1270
- Object.defineProperty(exports, "Result", ({ enumerable: true, get: function () { return __importDefault(Result_1).default; } }));
1271
- var Tile_1 = __webpack_require__(580);
1272
- Object.defineProperty(exports, "Tile", ({ enumerable: true, get: function () { return __importDefault(Tile_1).default; } }));
1273
- var TileJson_1 = __webpack_require__(92298);
1274
- Object.defineProperty(exports, "isTileJson", ({ enumerable: true, get: function () { return TileJson_1.isTileJson; } }));
1275
- var VerticalPattern_1 = __webpack_require__(36161);
1276
- Object.defineProperty(exports, "VerticalPattern", ({ enumerable: true, get: function () { return __importDefault(VerticalPattern_1).default; } }));
1277
- var WordBonus_1 = __webpack_require__(39667);
1278
- Object.defineProperty(exports, "WordBonus", ({ enumerable: true, get: function () { return __importDefault(WordBonus_1).default; } }));
1279
- var WordDefinition_1 = __webpack_require__(43184);
1280
- Object.defineProperty(exports, "WordDefinition", ({ enumerable: true, get: function () { return __importDefault(WordDefinition_1).default; } }));
1281
- var isError_1 = __webpack_require__(24075);
1282
- Object.defineProperty(exports, "isError", ({ enumerable: true, get: function () { return __importDefault(isError_1).default; } }));
1283
- var isObject_1 = __webpack_require__(93518);
1284
- Object.defineProperty(exports, "isObject", ({ enumerable: true, get: function () { return __importDefault(isObject_1).default; } }));
1285
-
1286
-
1287
- /***/ }),
1288
-
1289
- /***/ 24075:
1290
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1291
-
1292
-
1293
- var __importDefault = (this && this.__importDefault) || function (mod) {
1294
- return (mod && mod.__esModule) ? mod : { "default": mod };
1295
- };
1296
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1297
- const isObject_1 = __importDefault(__webpack_require__(93518));
1298
- const isError = (value) => {
1299
- if (!(0, isObject_1.default)(value)) {
1300
- return false;
1301
- }
1302
- return typeof value.message === 'string';
1303
- };
1304
- exports["default"] = isError;
1305
-
1306
-
1307
- /***/ }),
1308
-
1309
- /***/ 93518:
1310
- /***/ ((__unused_webpack_module, exports) => {
1311
-
1312
-
1313
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1314
- const isObject = (value) => {
1315
- return typeof value === 'object' && value !== null;
1316
- };
1317
- exports["default"] = isObject;
1318
-
1319
-
1320
- /***/ }),
1321
-
1322
- /***/ 61704:
1323
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1324
-
1325
-
1326
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1327
- const types_1 = __webpack_require__(46452);
1328
- const lib_1 = __webpack_require__(60337);
1329
- const FILE_URL = 'https://raw.githubusercontent.com/hippler/german-wordlist/master/words.txt';
1330
- const getDeDeWordList = async () => {
1331
- return (0, lib_1.getTxtWordList)(FILE_URL, types_1.Locale.DE_DE);
1332
- };
1333
- exports["default"] = getDeDeWordList;
1334
-
1335
-
1336
- /***/ }),
1337
-
1338
- /***/ 3284:
1339
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1340
-
1341
-
1342
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1343
- const types_1 = __webpack_require__(46452);
1344
- const lib_1 = __webpack_require__(60337);
1345
- const FILE_URL = 'https://www.wordgamedictionary.com/sowpods/download/sowpods.txt';
1346
- const getEnGbWordList = async () => {
1347
- return (0, lib_1.getTxtWordList)(FILE_URL, types_1.Locale.EN_GB);
1348
- };
1349
- exports["default"] = getEnGbWordList;
1350
-
1351
-
1352
- /***/ }),
1353
-
1354
- /***/ 163:
1355
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1356
-
1357
-
1358
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1359
- const types_1 = __webpack_require__(46452);
1360
- const lib_1 = __webpack_require__(60337);
1361
- const FILE_URL = 'https://www.wordgamedictionary.com/twl06/download/twl06.txt';
1362
- const getEnUsWordList = async () => {
1363
- return (0, lib_1.getTxtWordList)(FILE_URL, types_1.Locale.EN_US);
1364
- };
1365
- exports["default"] = getEnUsWordList;
1366
-
1367
-
1368
- /***/ }),
1369
-
1370
- /***/ 87537:
1371
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1372
-
1373
-
1374
- var __importDefault = (this && this.__importDefault) || function (mod) {
1375
- return (mod && mod.__esModule) ? mod : { "default": mod };
1376
- };
1377
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1378
- const types_1 = __webpack_require__(46452);
1379
- const latinize_1 = __importDefault(__webpack_require__(66761));
1380
- const lib_1 = __webpack_require__(60337);
1381
- const FILE_URL = 'https://raw.githubusercontent.com/kamilmielnik/scrabble-dictionaries/master/spanish/fise-2.txt';
1382
- const N_PLACEHOLDER = '---n---';
1383
- const getEsEsWordList = async () => {
1384
- const words = await (0, lib_1.getTxtWordList)(FILE_URL, types_1.Locale.ES_ES);
1385
- return words
1386
- .map((word) => word.replaceAll('ñ', N_PLACEHOLDER))
1387
- .map(latinize_1.default)
1388
- .map((word) => word.replaceAll(N_PLACEHOLDER, 'ñ'));
1389
- };
1390
- exports["default"] = getEsEsWordList;
1391
-
1392
-
1393
- /***/ }),
1394
-
1395
- /***/ 29596:
1396
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1397
-
1398
-
1399
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1400
- const types_1 = __webpack_require__(46452);
1401
- const lib_1 = __webpack_require__(60337);
1402
- const FILE_URL = 'https://raw.githubusercontent.com/MansourM/persian-to-persian-dictionary/main/moein/words.txt';
1403
- const getFaIrWordList = async () => {
1404
- return (0, lib_1.getTxtWordList)(FILE_URL, types_1.Locale.FA_IR);
1405
- };
1406
- exports["default"] = getFaIrWordList;
1407
-
1408
-
1409
- /***/ }),
1410
-
1411
- /***/ 27098:
1412
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1413
-
1414
-
1415
- var __importDefault = (this && this.__importDefault) || function (mod) {
1416
- return (mod && mod.__esModule) ? mod : { "default": mod };
1417
- };
1418
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1419
- const types_1 = __webpack_require__(46452);
1420
- const latinize_1 = __importDefault(__webpack_require__(66761));
1421
- const lib_1 = __webpack_require__(60337);
1422
- const FILE_URL = 'https://raw.githubusercontent.com/Thecoolsim/French-Scrabble-ODS8/main/French%20ODS%20dictionary.txt';
1423
- const getFrFrWordList = async () => {
1424
- const words = await (0, lib_1.getTxtWordList)(FILE_URL, types_1.Locale.FR_FR);
1425
- return words.map(latinize_1.default);
1426
- };
1427
- exports["default"] = getFrFrWordList;
1428
-
1429
-
1430
- /***/ }),
1431
-
1432
- /***/ 9385:
1433
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1434
-
1435
-
1436
- var __importDefault = (this && this.__importDefault) || function (mod) {
1437
- return (mod && mod.__esModule) ? mod : { "default": mod };
1438
- };
1439
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1440
- const cheerio_1 = __webpack_require__(55473);
1441
- const fs_1 = __importDefault(__webpack_require__(57147));
1442
- const url_1 = __webpack_require__(57310);
1443
- const lib_1 = __webpack_require__(60337);
1444
- const PAGE_URL = 'https://sjp.pl/sl/growy/';
1445
- const FILE_TO_EXTRACT_FROM_ZIP = 'slowa.txt';
1446
- const getPlPlWordList = async () => {
1447
- const tempFilepath = (0, lib_1.getTempFilepath)();
1448
- const zipUrl = await fetchZipUrl(PAGE_URL);
1449
- const zipTempFilename = await (0, lib_1.downloadFile)(zipUrl);
1450
- await (0, lib_1.unzip)(zipTempFilename, FILE_TO_EXTRACT_FROM_ZIP, tempFilepath);
1451
- fs_1.default.unlinkSync(zipTempFilename);
1452
- const file = fs_1.default.readFileSync(tempFilepath, 'utf-8');
1453
- fs_1.default.unlinkSync(tempFilepath);
1454
- const words = (0, lib_1.extractWords)(file.toLocaleString(), 'pl-PL');
1455
- return words;
1456
- };
1457
- const fetchZipUrl = async (url) => {
1458
- const html = await (0, lib_1.downloadHtml)(url);
1459
- const filename = await parseZipContainingPage(html);
1460
- const { href } = new url_1.URL(filename, url);
1461
- return href;
1462
- };
1463
- const parseZipContainingPage = (html) => {
1464
- const $ = (0, cheerio_1.load)(html);
1465
- const $links = $('a');
1466
- const links = Array.from($links)
1467
- .map((link) => $(link).attr('href'))
1468
- .filter(Boolean);
1469
- const zipFilename = links.find((link) => link.endsWith('.zip'));
1470
- if (typeof zipFilename === 'undefined') {
1471
- throw new Error('Cannot find link to zip file on the page');
1472
- }
1473
- return zipFilename;
1474
- };
1475
- exports["default"] = getPlPlWordList;
1476
-
1477
-
1478
- /***/ }),
1479
-
1480
- /***/ 73691:
1481
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1482
-
1483
-
1484
- var __importDefault = (this && this.__importDefault) || function (mod) {
1485
- return (mod && mod.__esModule) ? mod : { "default": mod };
1486
- };
1487
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1488
- const types_1 = __webpack_require__(46452);
1489
- const latinize_1 = __importDefault(__webpack_require__(66761));
1490
- const lib_1 = __webpack_require__(60337);
1491
- const FILE_URL = 'https://raw.githubusercontent.com/kamilmielnik/scrabble-dictionaries/master/romanian/loc-5.0.txt';
1492
- const getRoRoWordList = async () => {
1493
- const words = await (0, lib_1.getTxtWordList)(FILE_URL, types_1.Locale.RO_RO);
1494
- return words.map(latinize_1.default);
1495
- };
1496
- exports["default"] = getRoRoWordList;
1497
-
1498
-
1499
- /***/ }),
1500
-
1501
- /***/ 8769:
1502
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1503
-
1504
-
1505
- var __importDefault = (this && this.__importDefault) || function (mod) {
1506
- return (mod && mod.__esModule) ? mod : { "default": mod };
1507
- };
1508
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1509
- const types_1 = __webpack_require__(46452);
1510
- const getDeDeWordList_1 = __importDefault(__webpack_require__(61704));
1511
- const getEnGbWordList_1 = __importDefault(__webpack_require__(3284));
1512
- const getEnUsWordList_1 = __importDefault(__webpack_require__(163));
1513
- const getEsEsWordList_1 = __importDefault(__webpack_require__(87537));
1514
- const getFaIrWordList_1 = __importDefault(__webpack_require__(29596));
1515
- const getFrFrWordList_1 = __importDefault(__webpack_require__(27098));
1516
- const getPlPlWordList_1 = __importDefault(__webpack_require__(9385));
1517
- const getRoRoWordList_1 = __importDefault(__webpack_require__(73691));
1518
- const localeMap = {
1519
- [types_1.Locale.DE_DE]: getDeDeWordList_1.default,
1520
- [types_1.Locale.EN_GB]: getEnGbWordList_1.default,
1521
- [types_1.Locale.EN_US]: getEnUsWordList_1.default,
1522
- [types_1.Locale.ES_ES]: getEsEsWordList_1.default,
1523
- [types_1.Locale.FA_IR]: getFaIrWordList_1.default,
1524
- [types_1.Locale.FR_FR]: getFrFrWordList_1.default,
1525
- [types_1.Locale.PL_PL]: getPlPlWordList_1.default,
1526
- [types_1.Locale.RO_RO]: getRoRoWordList_1.default,
1527
- };
1528
- const getWordList = (locale) => localeMap[locale]();
1529
- exports["default"] = getWordList;
1530
-
1531
-
1532
- /***/ }),
1533
-
1534
- /***/ 51585:
1535
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1536
-
1537
-
1538
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1539
- if (k2 === undefined) k2 = k;
1540
- var desc = Object.getOwnPropertyDescriptor(m, k);
1541
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1542
- desc = { enumerable: true, get: function() { return m[k]; } };
1543
- }
1544
- Object.defineProperty(o, k2, desc);
1545
- }) : (function(o, m, k, k2) {
1546
- if (k2 === undefined) k2 = k;
1547
- o[k2] = m[k];
1548
- }));
1549
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
1550
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1551
- };
1552
- var __importDefault = (this && this.__importDefault) || function (mod) {
1553
- return (mod && mod.__esModule) ? mod : { "default": mod };
1554
- };
1555
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1556
- exports.getWordList = exports.getDeDeWordList = exports.getPlPlWordList = exports.getFrFrWordList = exports.getEnGbWordList = exports.getEnUsWordList = void 0;
1557
- var getEnUsWordList_1 = __webpack_require__(163);
1558
- Object.defineProperty(exports, "getEnUsWordList", ({ enumerable: true, get: function () { return __importDefault(getEnUsWordList_1).default; } }));
1559
- var getEnGbWordList_1 = __webpack_require__(3284);
1560
- Object.defineProperty(exports, "getEnGbWordList", ({ enumerable: true, get: function () { return __importDefault(getEnGbWordList_1).default; } }));
1561
- var getFrFrWordList_1 = __webpack_require__(27098);
1562
- Object.defineProperty(exports, "getFrFrWordList", ({ enumerable: true, get: function () { return __importDefault(getFrFrWordList_1).default; } }));
1563
- var getPlPlWordList_1 = __webpack_require__(9385);
1564
- Object.defineProperty(exports, "getPlPlWordList", ({ enumerable: true, get: function () { return __importDefault(getPlPlWordList_1).default; } }));
1565
- var getDeDeWordList_1 = __webpack_require__(61704);
1566
- Object.defineProperty(exports, "getDeDeWordList", ({ enumerable: true, get: function () { return __importDefault(getDeDeWordList_1).default; } }));
1567
- var getWordList_1 = __webpack_require__(8769);
1568
- Object.defineProperty(exports, "getWordList", ({ enumerable: true, get: function () { return __importDefault(getWordList_1).default; } }));
1569
- __exportStar(__webpack_require__(60337), exports);
1570
-
1571
-
1572
- /***/ }),
1573
-
1574
- /***/ 920:
1575
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1576
-
1577
-
1578
- var __importDefault = (this && this.__importDefault) || function (mod) {
1579
- return (mod && mod.__esModule) ? mod : { "default": mod };
1580
- };
1581
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1582
- const follow_redirects_1 = __webpack_require__(24396);
1583
- const fs_1 = __importDefault(__webpack_require__(57147));
1584
- const getTempFilepath_1 = __importDefault(__webpack_require__(5026));
1585
- const downloadFile = (url) => {
1586
- return new Promise((resolve, reject) => {
1587
- const tempFilepath = (0, getTempFilepath_1.default)();
1588
- const protocol = url.startsWith('https') ? follow_redirects_1.https : follow_redirects_1.http;
1589
- const writeStream = fs_1.default.createWriteStream(tempFilepath);
1590
- const request = protocol.get(url, (response) => {
1591
- if (typeof response.statusCode === 'undefined' || response.statusCode >= 400) {
1592
- reject(new Error(`Cannot download file: ${url}`));
1593
- return;
1594
- }
1595
- response.on('error', (error) => {
1596
- writeStream.close();
1597
- reject(error);
1598
- });
1599
- response.on('end', () => {
1600
- writeStream.on('finish', () => {
1601
- writeStream.close();
1602
- resolve(tempFilepath);
1603
- });
1604
- });
1605
- response.pipe(writeStream);
1606
- });
1607
- request.on('error', (error) => {
1608
- writeStream.close();
1609
- reject(error);
1610
- });
1611
- });
1612
- };
1613
- exports["default"] = downloadFile;
1614
-
1615
-
1616
- /***/ }),
1617
-
1618
- /***/ 78015:
1619
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
1620
-
1621
-
1622
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1623
- const follow_redirects_1 = __webpack_require__(24396);
1624
- const downloadHtml = (url) => {
1625
- return new Promise((resolve, reject) => {
1626
- const protocol = url.startsWith('https') ? follow_redirects_1.https : follow_redirects_1.http;
1627
- protocol.get(url, (response) => {
1628
- let data = '';
1629
- response.setEncoding('utf8');
1630
- response.on('data', (chunk) => {
1631
- data += chunk;
1632
- });
1633
- response.on('end', () => {
1634
- resolve(data);
1635
- });
1636
- response.on('error', reject);
1637
- });
1638
- });
1639
- };
1640
- exports["default"] = downloadHtml;
1641
-
1642
-
1643
- /***/ }),
1644
-
1645
- /***/ 39759:
1646
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1647
-
1648
-
1649
- var __importDefault = (this && this.__importDefault) || function (mod) {
1650
- return (mod && mod.__esModule) ? mod : { "default": mod };
1651
- };
1652
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1653
- const findFirstWordIndex_1 = __importDefault(__webpack_require__(47669));
1654
- const extractWords = (file, locale) => {
1655
- const lines = file.split(/\r?\n/g);
1656
- const firstWordIndex = (0, findFirstWordIndex_1.default)(lines, locale);
1657
- const words = [];
1658
- for (let i = firstWordIndex; i < lines.length; ++i) {
1659
- const trimmed = lines[i].trim();
1660
- if (trimmed.length > 0) {
1661
- words.push(trimmed.toLocaleLowerCase());
1662
- }
1663
- }
1664
- return words;
1665
- };
1666
- exports["default"] = extractWords;
1667
-
1668
-
1669
- /***/ }),
1670
-
1671
- /***/ 47669:
1672
- /***/ ((__unused_webpack_module, exports) => {
1673
-
1674
-
1675
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1676
- const findFirstWordIndex = (lines, locale) => {
1677
- const firstWordIndex = lines.findIndex((line, index) => {
1678
- const nextLine = line[index + 1] || '';
1679
- const isNextLineInOrder = line.localeCompare(nextLine, locale) > 0;
1680
- const hasWhitespace = Boolean(line.match(/\s/));
1681
- const isEmpty = line.trim().length === 0;
1682
- return !isEmpty && !hasWhitespace && isNextLineInOrder;
1683
- });
1684
- if (typeof firstWordIndex === 'undefined') {
1685
- throw new Error('Cannot find index of the first word in the file');
1686
- }
1687
- return firstWordIndex;
1688
- };
1689
- exports["default"] = findFirstWordIndex;
1690
-
1691
-
1692
- /***/ }),
1693
-
1694
- /***/ 93938:
1695
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1696
-
1697
-
1698
- var __importDefault = (this && this.__importDefault) || function (mod) {
1699
- return (mod && mod.__esModule) ? mod : { "default": mod };
1700
- };
1701
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1702
- const crypto_1 = __importDefault(__webpack_require__(6113));
1703
- const getHash = (bytes = 8) => crypto_1.default.randomBytes(bytes).toString('hex');
1704
- exports["default"] = getHash;
1705
-
1706
-
1707
- /***/ }),
1708
-
1709
- /***/ 5026:
1710
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1711
-
1712
-
1713
- var __importDefault = (this && this.__importDefault) || function (mod) {
1714
- return (mod && mod.__esModule) ? mod : { "default": mod };
1715
- };
1716
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1717
- const os_1 = __importDefault(__webpack_require__(22037));
1718
- const path_1 = __importDefault(__webpack_require__(71017));
1719
- const getHash_1 = __importDefault(__webpack_require__(93938));
1720
- const OUTPUT_DIRECTORY = path_1.default.resolve(os_1.default.homedir(), '.scrabble-solver');
1721
- const getTempFilepath = () => {
1722
- const filename = `${(0, getHash_1.default)()}.txt`;
1723
- return path_1.default.join(OUTPUT_DIRECTORY, filename);
1724
- };
1725
- exports["default"] = getTempFilepath;
1726
-
1727
-
1728
- /***/ }),
1729
-
1730
- /***/ 78029:
1731
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1732
-
1733
-
1734
- var __importDefault = (this && this.__importDefault) || function (mod) {
1735
- return (mod && mod.__esModule) ? mod : { "default": mod };
1736
- };
1737
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1738
- const fs_1 = __importDefault(__webpack_require__(57147));
1739
- const downloadFile_1 = __importDefault(__webpack_require__(920));
1740
- const extractWords_1 = __importDefault(__webpack_require__(39759));
1741
- const getTxtWordList = async (url, locale) => {
1742
- const tempFilename = await (0, downloadFile_1.default)(url);
1743
- const file = fs_1.default.readFileSync(tempFilename, 'utf-8');
1744
- const words = (0, extractWords_1.default)(file.toLocaleString(), locale);
1745
- fs_1.default.unlinkSync(tempFilename);
1746
- return words;
1747
- };
1748
- exports["default"] = getTxtWordList;
1749
-
1750
-
1751
- /***/ }),
1752
-
1753
- /***/ 60337:
1754
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1755
-
1756
-
1757
- var __importDefault = (this && this.__importDefault) || function (mod) {
1758
- return (mod && mod.__esModule) ? mod : { "default": mod };
1759
- };
1760
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1761
- exports.unzip = exports.getTxtWordList = exports.getTempFilepath = exports.getHash = exports.findFirstWordIndex = exports.extractWords = exports.downloadHtml = exports.downloadFile = void 0;
1762
- var downloadFile_1 = __webpack_require__(920);
1763
- Object.defineProperty(exports, "downloadFile", ({ enumerable: true, get: function () { return __importDefault(downloadFile_1).default; } }));
1764
- var downloadHtml_1 = __webpack_require__(78015);
1765
- Object.defineProperty(exports, "downloadHtml", ({ enumerable: true, get: function () { return __importDefault(downloadHtml_1).default; } }));
1766
- var extractWords_1 = __webpack_require__(39759);
1767
- Object.defineProperty(exports, "extractWords", ({ enumerable: true, get: function () { return __importDefault(extractWords_1).default; } }));
1768
- var findFirstWordIndex_1 = __webpack_require__(47669);
1769
- Object.defineProperty(exports, "findFirstWordIndex", ({ enumerable: true, get: function () { return __importDefault(findFirstWordIndex_1).default; } }));
1770
- var getHash_1 = __webpack_require__(93938);
1771
- Object.defineProperty(exports, "getHash", ({ enumerable: true, get: function () { return __importDefault(getHash_1).default; } }));
1772
- var getTempFilepath_1 = __webpack_require__(5026);
1773
- Object.defineProperty(exports, "getTempFilepath", ({ enumerable: true, get: function () { return __importDefault(getTempFilepath_1).default; } }));
1774
- var getTxtWordList_1 = __webpack_require__(78029);
1775
- Object.defineProperty(exports, "getTxtWordList", ({ enumerable: true, get: function () { return __importDefault(getTxtWordList_1).default; } }));
1776
- var unzip_1 = __webpack_require__(76987);
1777
- Object.defineProperty(exports, "unzip", ({ enumerable: true, get: function () { return __importDefault(unzip_1).default; } }));
1778
-
1779
-
1780
- /***/ }),
1781
-
1782
- /***/ 76987:
1783
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1784
-
1785
-
1786
- var __importDefault = (this && this.__importDefault) || function (mod) {
1787
- return (mod && mod.__esModule) ? mod : { "default": mod };
1788
- };
1789
- Object.defineProperty(exports, "__esModule", ({ value: true }));
1790
- const fs_1 = __importDefault(__webpack_require__(57147));
1791
- const unzipper_1 = __importDefault(__webpack_require__(23428));
1792
- const unzip = (zipFilename, extractFilename, outputFilename) => {
1793
- return fs_1.default
1794
- .createReadStream(zipFilename)
1795
- .pipe(unzipper_1.default.Parse())
1796
- .on('entry', (entry) => {
1797
- const fileName = entry.path;
1798
- if (fileName === extractFilename) {
1799
- entry.pipe(fs_1.default.createWriteStream(outputFilename));
1800
- }
1801
- else {
1802
- entry.autodrain();
1803
- }
1804
- })
1805
- .promise();
1806
- };
1807
- exports["default"] = unzip;
1808
-
1809
-
1810
- /***/ })
1811
-
1812
- };
1813
- ;