@scrabble-solver/scrabble-solver 2.8.2 → 2.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +10 -10
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/.next/cache/next-server.js.nft.json +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/206.js +98 -97
- package/.next/server/chunks/413.js +396 -677
- package/.next/server/chunks/515.js +546 -550
- package/.next/server/chunks/907.js +399 -681
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +5 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/server/pages/_app.js +7 -10
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js +0 -3
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/dictionary/[locale]/[word].js +114 -171
- package/.next/server/pages/api/solve.js +426 -1206
- package/.next/server/pages/index.html +17 -1
- package/.next/server/pages/index.js +7 -14
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/index.json +1 -1
- package/.next/static/-UOLkxdxU0PlKbXa09-xO/_buildManifest.js +1 -0
- package/.next/static/{nXSSCVI5pGlS_NxEidxkS → -UOLkxdxU0PlKbXa09-xO}/_ssgManifest.js +0 -0
- package/.next/static/chunks/56-2d34867599a0ac66.js +1 -0
- package/.next/static/chunks/pages/{404-02d949d2fe59e960.js → 404-30c06e61d256c5b2.js} +1 -1
- package/.next/static/chunks/pages/_app-6ffa2ab900772b67.js +1 -0
- package/.next/static/chunks/pages/{index-75517525489ab316.js → index-13ea7770a65c69ee.js} +1 -1
- package/.next/static/css/{d676d43c6b9c9a57.css → 551d09cac435debb.css} +1 -1
- package/.next/static/css/{6a9e5ba3f77c27f2.css → cdbc9e0afcff5473.css} +1 -1
- package/.next/trace +42 -42
- package/package.json +14 -14
- package/src/components/Board/Board.tsx +1 -1
- package/src/components/Board/BoardPure.tsx +1 -1
- package/src/components/Board/components/Cell/Button.tsx +1 -1
- package/src/components/Board/components/Cell/Cell.tsx +1 -1
- package/src/components/Board/components/Cell/CellPure.tsx +1 -1
- package/src/components/Board/hooks/useGrid.ts +9 -0
- package/src/components/Button/Button.tsx +1 -1
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Dictionary/Dictionary.tsx +1 -1
- package/src/components/DictionaryInput/DictionaryInput.tsx +1 -1
- package/src/components/EmptyState/EmptyState.tsx +1 -1
- package/src/components/Key/Key.tsx +1 -1
- package/src/components/KeyMap/KeyMap.tsx +2 -2
- package/src/components/KeyMap/components/Mapping/Mapping.module.scss +4 -0
- package/src/components/KeyMap/components/Mapping/Mapping.tsx +16 -12
- package/src/components/Loading/Loading.tsx +1 -1
- package/src/components/Logo/Logo.tsx +1 -1
- package/src/components/NavButtons/NavButtons.tsx +1 -1
- package/src/components/NotFound/NotFound.tsx +1 -1
- package/src/components/PlainTiles/PlainTiles.tsx +5 -1
- package/src/components/PlainTiles/Tile.tsx +1 -1
- package/src/components/Rack/Rack.tsx +1 -1
- package/src/components/Rack/RackTile.tsx +1 -1
- package/src/components/Radio/Radio.tsx +1 -1
- package/src/components/RemainingTiles/Character.tsx +1 -1
- package/src/components/RemainingTiles/RemainingTiles.tsx +1 -1
- package/src/components/Results/Cell.tsx +1 -1
- package/src/components/Results/HeaderButton.tsx +1 -1
- package/src/components/Results/Result.tsx +1 -1
- package/src/components/Results/Results.tsx +1 -1
- package/src/components/Results/SolveButton.tsx +1 -1
- package/src/components/ResultsInput/ResultsInput.tsx +1 -1
- package/src/components/Screen/Screen.tsx +1 -1
- package/src/components/Settings/Settings.tsx +1 -1
- package/src/components/Settings/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -1
- package/src/components/Settings/components/ConfigSetting/ConfigSetting.tsx +1 -1
- package/src/components/Settings/components/LocaleSetting/LocaleSetting.tsx +1 -1
- package/src/components/Sidebar/Sidebar.tsx +1 -1
- package/src/components/Sidebar/components/Section/Section.tsx +1 -1
- package/src/components/Splash/Splash.tsx +1 -1
- package/src/components/SquareButton/Link.tsx +1 -1
- package/src/components/SquareButton/SquareButton.tsx +1 -1
- package/src/components/SvgFontCss/SvgFontCss.tsx +12 -0
- package/src/components/SvgFontCss/index.ts +1 -0
- package/src/components/Tile/Tile.tsx +1 -1
- package/src/components/Tile/TilePure.tsx +2 -2
- package/src/components/Tooltip/useTooltip.tsx +1 -1
- package/src/components/Well/Well.tsx +1 -1
- package/src/components/index.ts +1 -0
- package/src/hooks/usePortal.tsx +19 -9
- package/src/lib/createKeyboardNavigation.ts +3 -0
- package/src/lib/memoize.ts +1 -1
- package/src/pages/_app.tsx +1 -1
- package/src/pages/_document.tsx +1 -1
- package/src/pages/index.tsx +6 -15
- package/src/styles/global.scss +3 -0
- package/.next/static/chunks/195-fcadef5c6eed8338.js +0 -1
- package/.next/static/chunks/pages/_app-f4030148d742bcd2.js +0 -1
- package/.next/static/nXSSCVI5pGlS_NxEidxkS/_buildManifest.js +0 -1
|
@@ -128,123 +128,50 @@ module.exports = require("zlib");
|
|
|
128
128
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
132
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
133
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
134
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
135
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
136
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
137
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
141
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
142
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
143
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
144
|
-
function step(op) {
|
|
145
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
146
|
-
while (_) try {
|
|
147
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
148
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
149
|
-
switch (op[0]) {
|
|
150
|
-
case 0: case 1: t = op; break;
|
|
151
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
152
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
153
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
154
|
-
default:
|
|
155
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
156
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
157
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
158
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
159
|
-
if (t[2]) _.ops.pop();
|
|
160
|
-
_.trys.pop(); continue;
|
|
161
|
-
}
|
|
162
|
-
op = body.call(thisArg, _);
|
|
163
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
164
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
131
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
168
132
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
169
133
|
};
|
|
170
134
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
135
|
+
const logger_1 = __importDefault(__webpack_require__(52954));
|
|
136
|
+
const types_1 = __webpack_require__(46452);
|
|
137
|
+
const fs_1 = __importDefault(__webpack_require__(57147));
|
|
138
|
+
const constants_1 = __webpack_require__(75823);
|
|
139
|
+
const lib_1 = __webpack_require__(26137);
|
|
140
|
+
class Dictionaries {
|
|
141
|
+
constructor() {
|
|
178
142
|
this.cache = new lib_1.LayeredCache();
|
|
179
|
-
this.downloadDictionaryProxies = Object.fromEntries(Object.values(types_1.Locale).map(
|
|
143
|
+
this.downloadDictionaryProxies = Object.fromEntries(Object.values(types_1.Locale).map((locale) => [locale, (0, lib_1.createAsyncProxy)(() => (0, lib_1.downloadDictionary)(locale))]));
|
|
180
144
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return [2 /*return*/, trie];
|
|
193
|
-
}
|
|
194
|
-
_a.label = 2;
|
|
195
|
-
case 2:
|
|
196
|
-
logger_1.default.info('Dictionaries - cache miss', { locale: locale });
|
|
197
|
-
return [2 /*return*/, this.updateDictionary(locale)];
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
|
-
Dictionaries.prototype.remove = function () {
|
|
145
|
+
async get(locale) {
|
|
146
|
+
if (this.cache.has(locale)) {
|
|
147
|
+
const trie = await this.cache.get(locale);
|
|
148
|
+
if (trie) {
|
|
149
|
+
return trie;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
logger_1.default.info('Dictionaries - cache miss', { locale });
|
|
153
|
+
return this.updateDictionary(locale);
|
|
154
|
+
}
|
|
155
|
+
remove() {
|
|
203
156
|
fs_1.default.rmdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
Dictionaries.prototype.getLocalesToUpdate = function () {
|
|
223
|
-
var _this = this;
|
|
224
|
-
return Object.values(types_1.Locale).filter(function (locale) { return _this.cache.isStale(locale) !== false; });
|
|
225
|
-
};
|
|
226
|
-
Dictionaries.prototype.updateDictionary = function (locale) {
|
|
227
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
228
|
-
var downloadDictionaryProxy, trie;
|
|
229
|
-
return __generator(this, function (_a) {
|
|
230
|
-
switch (_a.label) {
|
|
231
|
-
case 0:
|
|
232
|
-
logger_1.default.info('Dictionaries - updateDictionary', { locale: locale });
|
|
233
|
-
fs_1.default.mkdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
|
|
234
|
-
downloadDictionaryProxy = this.downloadDictionaryProxies[locale];
|
|
235
|
-
return [4 /*yield*/, downloadDictionaryProxy()];
|
|
236
|
-
case 1:
|
|
237
|
-
trie = _a.sent();
|
|
238
|
-
return [4 /*yield*/, this.cache.set(locale, trie)];
|
|
239
|
-
case 2:
|
|
240
|
-
_a.sent();
|
|
241
|
-
return [2 /*return*/, trie];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
return Dictionaries;
|
|
247
|
-
}());
|
|
157
|
+
}
|
|
158
|
+
async update(force) {
|
|
159
|
+
const locales = force ? Object.values(types_1.Locale) : this.getLocalesToUpdate();
|
|
160
|
+
logger_1.default.info('Dictionaries - update', { force, locales });
|
|
161
|
+
await Promise.all(locales.map((locale) => this.updateDictionary(locale)));
|
|
162
|
+
}
|
|
163
|
+
getLocalesToUpdate() {
|
|
164
|
+
return Object.values(types_1.Locale).filter((locale) => this.cache.isStale(locale) !== false);
|
|
165
|
+
}
|
|
166
|
+
async updateDictionary(locale) {
|
|
167
|
+
logger_1.default.info('Dictionaries - updateDictionary', { locale });
|
|
168
|
+
fs_1.default.mkdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
|
|
169
|
+
const downloadDictionaryProxy = this.downloadDictionaryProxies[locale];
|
|
170
|
+
const trie = await downloadDictionaryProxy();
|
|
171
|
+
await this.cache.set(locale, trie);
|
|
172
|
+
return trie;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
248
175
|
exports["default"] = Dictionaries;
|
|
249
176
|
|
|
250
177
|
|
|
@@ -259,8 +186,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
259
186
|
};
|
|
260
187
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
261
188
|
exports.OUTPUT_DIRECTORY = exports.CACHE_STALE_THRESHOLD = exports.DAY = void 0;
|
|
262
|
-
|
|
263
|
-
|
|
189
|
+
const os_1 = __importDefault(__webpack_require__(22037));
|
|
190
|
+
const path_1 = __importDefault(__webpack_require__(71017));
|
|
264
191
|
exports.DAY = 24 * 60 * 60 * 1000;
|
|
265
192
|
exports.CACHE_STALE_THRESHOLD = 30 * exports.DAY;
|
|
266
193
|
exports.OUTPUT_DIRECTORY = path_1.default.resolve(os_1.default.homedir(), '.scrabble-solver', 'dictionaries');
|
|
@@ -291,7 +218,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
291
218
|
};
|
|
292
219
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
293
220
|
exports.dictionaries = void 0;
|
|
294
|
-
|
|
221
|
+
const Dictionaries_1 = __importDefault(__webpack_require__(21285));
|
|
295
222
|
__exportStar(__webpack_require__(26137), exports);
|
|
296
223
|
exports.dictionaries = new Dictionaries_1.default();
|
|
297
224
|
|
|
@@ -302,114 +229,52 @@ exports.dictionaries = new Dictionaries_1.default();
|
|
|
302
229
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
303
230
|
|
|
304
231
|
|
|
305
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
306
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
307
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
308
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
309
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
310
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
311
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
315
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
316
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
317
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
318
|
-
function step(op) {
|
|
319
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
320
|
-
while (_) try {
|
|
321
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
322
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
323
|
-
switch (op[0]) {
|
|
324
|
-
case 0: case 1: t = op; break;
|
|
325
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
326
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
327
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
328
|
-
default:
|
|
329
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
330
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
331
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
332
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
333
|
-
if (t[2]) _.ops.pop();
|
|
334
|
-
_.trys.pop(); continue;
|
|
335
|
-
}
|
|
336
|
-
op = body.call(thisArg, _);
|
|
337
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
338
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
232
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
342
233
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
343
234
|
};
|
|
344
235
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
236
|
+
const trie_1 = __webpack_require__(83140);
|
|
237
|
+
const fs_1 = __importDefault(__webpack_require__(57147));
|
|
238
|
+
const constants_1 = __webpack_require__(75823);
|
|
239
|
+
const getDictionaryFilepath_1 = __importDefault(__webpack_require__(68638));
|
|
240
|
+
class DiskCache {
|
|
241
|
+
async get(locale) {
|
|
242
|
+
if (!this.has(locale)) {
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
const filepath = (0, getDictionaryFilepath_1.default)(locale);
|
|
246
|
+
const serialized = await fs_1.default.promises.readFile(filepath, 'utf-8');
|
|
247
|
+
const trie = trie_1.Trie.deserialize(serialized);
|
|
248
|
+
return trie;
|
|
353
249
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
var filepath, serialized, trie;
|
|
357
|
-
return __generator(this, function (_a) {
|
|
358
|
-
switch (_a.label) {
|
|
359
|
-
case 0:
|
|
360
|
-
if (!this.has(locale)) {
|
|
361
|
-
return [2 /*return*/, undefined];
|
|
362
|
-
}
|
|
363
|
-
filepath = (0, getDictionaryFilepath_1.default)(locale);
|
|
364
|
-
return [4 /*yield*/, (0, readFile_1.default)(filepath)];
|
|
365
|
-
case 1:
|
|
366
|
-
serialized = _a.sent();
|
|
367
|
-
trie = trie_1.Trie.deserialize(serialized);
|
|
368
|
-
return [2 /*return*/, trie];
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
};
|
|
373
|
-
DiskCache.prototype.getLastModifiedTimestamp = function (locale) {
|
|
374
|
-
var filepath = (0, getDictionaryFilepath_1.default)(locale);
|
|
250
|
+
getLastModifiedTimestamp(locale) {
|
|
251
|
+
const filepath = (0, getDictionaryFilepath_1.default)(locale);
|
|
375
252
|
if (!fs_1.default.existsSync(filepath)) {
|
|
376
253
|
return undefined;
|
|
377
254
|
}
|
|
378
|
-
|
|
255
|
+
const stats = fs_1.default.statSync(filepath);
|
|
379
256
|
return stats.mtimeMs;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
257
|
+
}
|
|
258
|
+
has(locale) {
|
|
259
|
+
const filepath = (0, getDictionaryFilepath_1.default)(locale);
|
|
383
260
|
return fs_1.default.existsSync(filepath);
|
|
384
|
-
}
|
|
385
|
-
|
|
261
|
+
}
|
|
262
|
+
isStale(locale) {
|
|
386
263
|
if (!this.has(locale)) {
|
|
387
264
|
return undefined;
|
|
388
265
|
}
|
|
389
|
-
|
|
266
|
+
const lastModifiedTimestamp = this.getLastModifiedTimestamp(locale);
|
|
390
267
|
if (typeof lastModifiedTimestamp === 'undefined') {
|
|
391
268
|
return undefined;
|
|
392
269
|
}
|
|
393
|
-
|
|
270
|
+
const timeSinceModification = Math.abs(lastModifiedTimestamp - Date.now());
|
|
394
271
|
return timeSinceModification > constants_1.CACHE_STALE_THRESHOLD;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
case 0:
|
|
402
|
-
filepath = (0, getDictionaryFilepath_1.default)(locale);
|
|
403
|
-
return [4 /*yield*/, (0, writeFile_1.default)(filepath, trie.serialize())];
|
|
404
|
-
case 1:
|
|
405
|
-
_a.sent();
|
|
406
|
-
return [2 /*return*/];
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
};
|
|
411
|
-
return DiskCache;
|
|
412
|
-
}());
|
|
272
|
+
}
|
|
273
|
+
async set(locale, trie) {
|
|
274
|
+
const filepath = (0, getDictionaryFilepath_1.default)(locale);
|
|
275
|
+
await fs_1.default.promises.writeFile(filepath, trie.serialize());
|
|
276
|
+
}
|
|
277
|
+
}
|
|
413
278
|
exports["default"] = DiskCache;
|
|
414
279
|
|
|
415
280
|
|
|
@@ -419,123 +284,59 @@ exports["default"] = DiskCache;
|
|
|
419
284
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
420
285
|
|
|
421
286
|
|
|
422
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
423
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
424
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
425
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
426
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
427
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
428
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
429
|
-
});
|
|
430
|
-
};
|
|
431
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
432
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
433
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
434
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
435
|
-
function step(op) {
|
|
436
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
437
|
-
while (_) try {
|
|
438
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
439
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
440
|
-
switch (op[0]) {
|
|
441
|
-
case 0: case 1: t = op; break;
|
|
442
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
443
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
444
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
445
|
-
default:
|
|
446
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
447
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
448
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
449
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
450
|
-
if (t[2]) _.ops.pop();
|
|
451
|
-
_.trys.pop(); continue;
|
|
452
|
-
}
|
|
453
|
-
op = body.call(thisArg, _);
|
|
454
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
455
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
459
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
460
|
-
if (!m) return o;
|
|
461
|
-
var i = m.call(o), r, ar = [], e;
|
|
462
|
-
try {
|
|
463
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
464
|
-
}
|
|
465
|
-
catch (error) { e = { error: error }; }
|
|
466
|
-
finally {
|
|
467
|
-
try {
|
|
468
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
469
|
-
}
|
|
470
|
-
finally { if (e) throw e.error; }
|
|
471
|
-
}
|
|
472
|
-
return ar;
|
|
473
|
-
};
|
|
474
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
475
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
476
|
-
if (ar || !(i in from)) {
|
|
477
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
478
|
-
ar[i] = from[i];
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
482
|
-
};
|
|
483
287
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
484
288
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
485
289
|
};
|
|
486
290
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
291
|
+
const createCacheTimestampComparator_1 = __importDefault(__webpack_require__(20494));
|
|
292
|
+
const DiskCache_1 = __importDefault(__webpack_require__(2812));
|
|
293
|
+
const MemoryCache_1 = __importDefault(__webpack_require__(50192));
|
|
294
|
+
class LayeredCache {
|
|
295
|
+
constructor() {
|
|
492
296
|
this.layers = [new MemoryCache_1.default(), new DiskCache_1.default()];
|
|
493
297
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
if (!
|
|
298
|
+
async get(locale) {
|
|
299
|
+
const cache = this.getLastModifiedLayer(locale);
|
|
300
|
+
if (!cache) {
|
|
497
301
|
return Promise.resolve(undefined);
|
|
498
302
|
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
303
|
+
const [memoryCache, diskCache] = this.layers;
|
|
304
|
+
const value = await cache.get(locale);
|
|
305
|
+
if (cache === diskCache && typeof value !== 'undefined') {
|
|
306
|
+
await memoryCache.set(locale, value);
|
|
307
|
+
}
|
|
308
|
+
return value;
|
|
309
|
+
}
|
|
310
|
+
getLastModifiedTimestamp(locale) {
|
|
311
|
+
const cache = this.getLastModifiedLayer(locale);
|
|
312
|
+
if (!cache) {
|
|
504
313
|
return undefined;
|
|
505
314
|
}
|
|
506
|
-
return
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return this.layers.some(
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
if (this.layers.some(
|
|
315
|
+
return cache.getLastModifiedTimestamp(locale);
|
|
316
|
+
}
|
|
317
|
+
has(locale) {
|
|
318
|
+
return this.layers.some((cache) => cache.has(locale));
|
|
319
|
+
}
|
|
320
|
+
isStale(locale) {
|
|
321
|
+
if (this.layers.some((cache) => cache.isStale(locale))) {
|
|
513
322
|
return true;
|
|
514
323
|
}
|
|
515
|
-
if (this.layers.every(
|
|
324
|
+
if (this.layers.every((cache) => typeof cache.isStale(locale) === 'undefined')) {
|
|
516
325
|
return undefined;
|
|
517
326
|
}
|
|
518
327
|
return false;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
});
|
|
531
|
-
};
|
|
532
|
-
LayeredCache.prototype.getLastModifiedLayer = function (locale) {
|
|
533
|
-
var layers = this.layers.filter(function (cache) { return cache.has(locale); });
|
|
534
|
-
var _a = __read(__spreadArray([], __read(layers), false).sort((0, createCacheTimestampComparator_1.default)(locale)), 1), cached = _a[0];
|
|
328
|
+
}
|
|
329
|
+
async set(locale, trie) {
|
|
330
|
+
const [memoryCache, diskCache] = this.layers;
|
|
331
|
+
await diskCache.set(locale, trie);
|
|
332
|
+
await memoryCache.set(locale, trie);
|
|
333
|
+
}
|
|
334
|
+
getLastModifiedLayer(locale) {
|
|
335
|
+
const layers = this.layers.filter((cache) => cache.has(locale));
|
|
336
|
+
const [cached] = [...layers].sort((0, createCacheTimestampComparator_1.default)(locale));
|
|
535
337
|
return cached;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
}());
|
|
338
|
+
}
|
|
339
|
+
}
|
|
539
340
|
exports["default"] = LayeredCache;
|
|
540
341
|
|
|
541
342
|
|
|
@@ -546,104 +347,59 @@ exports["default"] = LayeredCache;
|
|
|
546
347
|
|
|
547
348
|
|
|
548
349
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
350
|
+
const constants_1 = __webpack_require__(75823);
|
|
351
|
+
class MemoryCache {
|
|
352
|
+
constructor() {
|
|
552
353
|
this.cache = {};
|
|
553
354
|
this.cacheTimestamps = {};
|
|
554
355
|
}
|
|
555
|
-
|
|
356
|
+
get(locale) {
|
|
556
357
|
return Promise.resolve(this.cache[locale]);
|
|
557
|
-
}
|
|
558
|
-
|
|
358
|
+
}
|
|
359
|
+
getLastModifiedTimestamp(locale) {
|
|
559
360
|
return this.cacheTimestamps[locale];
|
|
560
|
-
}
|
|
561
|
-
|
|
361
|
+
}
|
|
362
|
+
has(locale) {
|
|
562
363
|
return typeof this.cache[locale] !== 'undefined';
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
|
|
364
|
+
}
|
|
365
|
+
isStale(locale) {
|
|
366
|
+
const timestamp = this.getLastModifiedTimestamp(locale);
|
|
566
367
|
if (!this.has(locale) || typeof timestamp === 'undefined') {
|
|
567
368
|
return undefined;
|
|
568
369
|
}
|
|
569
|
-
|
|
370
|
+
const timeSinceModification = Math.abs(timestamp - Date.now());
|
|
570
371
|
return timeSinceModification > constants_1.CACHE_STALE_THRESHOLD;
|
|
571
|
-
}
|
|
572
|
-
|
|
372
|
+
}
|
|
373
|
+
set(locale, trie) {
|
|
573
374
|
this.cacheTimestamps[locale] = Date.now();
|
|
574
375
|
this.cache[locale] = trie;
|
|
575
376
|
return Promise.resolve();
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
}());
|
|
377
|
+
}
|
|
378
|
+
}
|
|
579
379
|
exports["default"] = MemoryCache;
|
|
580
380
|
|
|
581
381
|
|
|
582
382
|
/***/ }),
|
|
583
383
|
|
|
584
384
|
/***/ 26554:
|
|
585
|
-
/***/ (
|
|
385
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
586
386
|
|
|
587
387
|
|
|
588
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
589
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
590
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
591
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
592
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
593
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
594
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
595
|
-
});
|
|
596
|
-
};
|
|
597
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
598
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
599
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
600
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
601
|
-
function step(op) {
|
|
602
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
603
|
-
while (_) try {
|
|
604
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
605
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
606
|
-
switch (op[0]) {
|
|
607
|
-
case 0: case 1: t = op; break;
|
|
608
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
609
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
610
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
611
|
-
default:
|
|
612
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
613
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
614
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
615
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
616
|
-
if (t[2]) _.ops.pop();
|
|
617
|
-
_.trys.pop(); continue;
|
|
618
|
-
}
|
|
619
|
-
op = body.call(thisArg, _);
|
|
620
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
621
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
622
|
-
}
|
|
623
|
-
};
|
|
624
388
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
return
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
case 2: return [2 /*return*/, _a.sent()];
|
|
640
|
-
case 3:
|
|
641
|
-
promise = null;
|
|
642
|
-
return [7 /*endfinally*/];
|
|
643
|
-
case 4: return [2 /*return*/];
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
}); };
|
|
389
|
+
const createAsyncProxy = (asyncCallback) => {
|
|
390
|
+
let promise = null;
|
|
391
|
+
return async () => {
|
|
392
|
+
if (promise) {
|
|
393
|
+
return promise;
|
|
394
|
+
}
|
|
395
|
+
try {
|
|
396
|
+
promise = asyncCallback();
|
|
397
|
+
return await promise;
|
|
398
|
+
}
|
|
399
|
+
finally {
|
|
400
|
+
promise = null;
|
|
401
|
+
}
|
|
402
|
+
};
|
|
647
403
|
};
|
|
648
404
|
exports["default"] = createAsyncProxy;
|
|
649
405
|
|
|
@@ -655,10 +411,10 @@ exports["default"] = createAsyncProxy;
|
|
|
655
411
|
|
|
656
412
|
|
|
657
413
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
658
|
-
|
|
659
|
-
return
|
|
660
|
-
|
|
661
|
-
|
|
414
|
+
const createCacheTimestampComparator = (locale) => {
|
|
415
|
+
return (a, b) => {
|
|
416
|
+
const aTimestamp = a.getLastModifiedTimestamp(locale);
|
|
417
|
+
const bTimestamp = b.getLastModifiedTimestamp(locale);
|
|
662
418
|
if (aTimestamp === bTimestamp) {
|
|
663
419
|
return 0;
|
|
664
420
|
}
|
|
@@ -680,64 +436,20 @@ exports["default"] = createCacheTimestampComparator;
|
|
|
680
436
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
681
437
|
|
|
682
438
|
|
|
683
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
684
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
685
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
686
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
687
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
688
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
689
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
690
|
-
});
|
|
691
|
-
};
|
|
692
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
693
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
694
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
695
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
696
|
-
function step(op) {
|
|
697
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
698
|
-
while (_) try {
|
|
699
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
700
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
701
|
-
switch (op[0]) {
|
|
702
|
-
case 0: case 1: t = op; break;
|
|
703
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
704
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
705
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
706
|
-
default:
|
|
707
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
708
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
709
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
710
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
711
|
-
if (t[2]) _.ops.pop();
|
|
712
|
-
_.trys.pop(); continue;
|
|
713
|
-
}
|
|
714
|
-
op = body.call(thisArg, _);
|
|
715
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
716
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
717
|
-
}
|
|
718
|
-
};
|
|
719
439
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
720
440
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
721
441
|
};
|
|
722
442
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
case 1:
|
|
734
|
-
words = _a.sent();
|
|
735
|
-
logger_1.default.info('downloadDictionary - success', { locale: locale });
|
|
736
|
-
trie = trie_1.Trie.fromArray(words);
|
|
737
|
-
return [2 /*return*/, trie];
|
|
738
|
-
}
|
|
739
|
-
});
|
|
740
|
-
}); };
|
|
443
|
+
const trie_1 = __webpack_require__(83140);
|
|
444
|
+
const logger_1 = __importDefault(__webpack_require__(52954));
|
|
445
|
+
const word_lists_1 = __webpack_require__(51585);
|
|
446
|
+
const downloadDictionary = async (locale) => {
|
|
447
|
+
logger_1.default.info('downloadDictionary', { locale });
|
|
448
|
+
const words = await (0, word_lists_1.getWordList)(locale);
|
|
449
|
+
logger_1.default.info('downloadDictionary - success', { locale });
|
|
450
|
+
const trie = trie_1.Trie.fromArray(words);
|
|
451
|
+
return trie;
|
|
452
|
+
};
|
|
741
453
|
exports["default"] = downloadDictionary;
|
|
742
454
|
|
|
743
455
|
|
|
@@ -751,10 +463,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
751
463
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
752
464
|
};
|
|
753
465
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
return path_1.default.resolve(constants_1.OUTPUT_DIRECTORY,
|
|
466
|
+
const path_1 = __importDefault(__webpack_require__(71017));
|
|
467
|
+
const constants_1 = __webpack_require__(75823);
|
|
468
|
+
const getDictionaryFilepath = (locale) => {
|
|
469
|
+
return path_1.default.resolve(constants_1.OUTPUT_DIRECTORY, `${locale}.txt`);
|
|
758
470
|
};
|
|
759
471
|
exports["default"] = getDictionaryFilepath;
|
|
760
472
|
|
|
@@ -769,7 +481,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
769
481
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
770
482
|
};
|
|
771
483
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
772
|
-
exports.
|
|
484
|
+
exports.MemoryCache = exports.LayeredCache = exports.getDictionaryFilepath = exports.downloadDictionary = exports.DiskCache = exports.createCacheTimestampComparator = exports.createAsyncProxy = void 0;
|
|
773
485
|
var createAsyncProxy_1 = __webpack_require__(26554);
|
|
774
486
|
Object.defineProperty(exports, "createAsyncProxy", ({ enumerable: true, get: function () { return __importDefault(createAsyncProxy_1).default; } }));
|
|
775
487
|
var createCacheTimestampComparator_1 = __webpack_require__(20494);
|
|
@@ -784,138 +496,6 @@ var LayeredCache_1 = __webpack_require__(70287);
|
|
|
784
496
|
Object.defineProperty(exports, "LayeredCache", ({ enumerable: true, get: function () { return __importDefault(LayeredCache_1).default; } }));
|
|
785
497
|
var MemoryCache_1 = __webpack_require__(50192);
|
|
786
498
|
Object.defineProperty(exports, "MemoryCache", ({ enumerable: true, get: function () { return __importDefault(MemoryCache_1).default; } }));
|
|
787
|
-
var readFile_1 = __webpack_require__(61908);
|
|
788
|
-
Object.defineProperty(exports, "readFile", ({ enumerable: true, get: function () { return __importDefault(readFile_1).default; } }));
|
|
789
|
-
var writeFile_1 = __webpack_require__(42213);
|
|
790
|
-
Object.defineProperty(exports, "writeFile", ({ enumerable: true, get: function () { return __importDefault(writeFile_1).default; } }));
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
/***/ }),
|
|
794
|
-
|
|
795
|
-
/***/ 61908:
|
|
796
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
800
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
801
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
802
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
803
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
804
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
805
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
806
|
-
});
|
|
807
|
-
};
|
|
808
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
809
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
810
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
811
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
812
|
-
function step(op) {
|
|
813
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
814
|
-
while (_) try {
|
|
815
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
816
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
817
|
-
switch (op[0]) {
|
|
818
|
-
case 0: case 1: t = op; break;
|
|
819
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
820
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
821
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
822
|
-
default:
|
|
823
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
824
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
825
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
826
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
827
|
-
if (t[2]) _.ops.pop();
|
|
828
|
-
_.trys.pop(); continue;
|
|
829
|
-
}
|
|
830
|
-
op = body.call(thisArg, _);
|
|
831
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
832
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
833
|
-
}
|
|
834
|
-
};
|
|
835
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
836
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
837
|
-
};
|
|
838
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
839
|
-
var fs_1 = __importDefault(__webpack_require__(57147));
|
|
840
|
-
var readFile = function (filepath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
841
|
-
return __generator(this, function (_a) {
|
|
842
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
843
|
-
fs_1.default.readFile(filepath, { encoding: 'utf-8' }, function (error, data) {
|
|
844
|
-
if (error) {
|
|
845
|
-
reject();
|
|
846
|
-
}
|
|
847
|
-
else {
|
|
848
|
-
resolve(data.toString());
|
|
849
|
-
}
|
|
850
|
-
});
|
|
851
|
-
})];
|
|
852
|
-
});
|
|
853
|
-
}); };
|
|
854
|
-
exports["default"] = readFile;
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
/***/ }),
|
|
858
|
-
|
|
859
|
-
/***/ 42213:
|
|
860
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
864
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
865
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
866
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
867
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
868
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
869
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
870
|
-
});
|
|
871
|
-
};
|
|
872
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
873
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
874
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
875
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
876
|
-
function step(op) {
|
|
877
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
878
|
-
while (_) try {
|
|
879
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
880
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
881
|
-
switch (op[0]) {
|
|
882
|
-
case 0: case 1: t = op; break;
|
|
883
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
884
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
885
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
886
|
-
default:
|
|
887
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
888
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
889
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
890
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
891
|
-
if (t[2]) _.ops.pop();
|
|
892
|
-
_.trys.pop(); continue;
|
|
893
|
-
}
|
|
894
|
-
op = body.call(thisArg, _);
|
|
895
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
896
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
900
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
901
|
-
};
|
|
902
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
903
|
-
var fs_1 = __importDefault(__webpack_require__(57147));
|
|
904
|
-
var writeFile = function (filepath, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
905
|
-
return __generator(this, function (_a) {
|
|
906
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
907
|
-
fs_1.default.writeFile(filepath, data, function (error) {
|
|
908
|
-
if (error) {
|
|
909
|
-
reject();
|
|
910
|
-
}
|
|
911
|
-
else {
|
|
912
|
-
resolve();
|
|
913
|
-
}
|
|
914
|
-
});
|
|
915
|
-
})];
|
|
916
|
-
});
|
|
917
|
-
}); };
|
|
918
|
-
exports["default"] = writeFile;
|
|
919
499
|
|
|
920
500
|
|
|
921
501
|
/***/ }),
|
|
@@ -1014,213 +594,150 @@ const validateRequest = ({ board , characters , config })=>{
|
|
|
1014
594
|
/***/ }),
|
|
1015
595
|
|
|
1016
596
|
/***/ 6700:
|
|
1017
|
-
/***/ (
|
|
597
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1018
598
|
|
|
1019
599
|
|
|
1020
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
1021
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1022
|
-
if (!m) return o;
|
|
1023
|
-
var i = m.call(o), r, ar = [], e;
|
|
1024
|
-
try {
|
|
1025
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1026
|
-
}
|
|
1027
|
-
catch (error) { e = { error: error }; }
|
|
1028
|
-
finally {
|
|
1029
|
-
try {
|
|
1030
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1031
|
-
}
|
|
1032
|
-
finally { if (e) throw e.error; }
|
|
1033
|
-
}
|
|
1034
|
-
return ar;
|
|
1035
|
-
};
|
|
1036
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
1037
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1038
|
-
if (ar || !(i in from)) {
|
|
1039
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1040
|
-
ar[i] = from[i];
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1044
|
-
};
|
|
1045
600
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
601
|
+
const constants_1 = __webpack_require__(38436);
|
|
602
|
+
const types_1 = __webpack_require__(46452);
|
|
603
|
+
class PatternsFiller {
|
|
604
|
+
constructor(config, trie) {
|
|
1050
605
|
this.config = config;
|
|
1051
606
|
this.trie = trie;
|
|
1052
607
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
608
|
+
fill(pattern, tiles) {
|
|
609
|
+
const patterns = [];
|
|
1055
610
|
if (pattern.getNumberOfEmptyCells() > tiles.length) {
|
|
1056
611
|
return [];
|
|
1057
612
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
for (
|
|
1061
|
-
|
|
1062
|
-
this.fillPattern(pattern,
|
|
613
|
+
const onPatternFound = (newPattern) => patterns.push(newPattern);
|
|
614
|
+
const tilesPermutations = this.generateBlankTilesPermutations(tiles);
|
|
615
|
+
for (let index = 0; index < tilesPermutations.length; ++index) {
|
|
616
|
+
const tilesPermutation = tilesPermutations[index];
|
|
617
|
+
this.fillPattern(pattern, pattern.toString(), tilesPermutation, onPatternFound);
|
|
1063
618
|
}
|
|
1064
619
|
return patterns;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
|
|
620
|
+
}
|
|
621
|
+
fillPattern(pattern, word, tiles, onPatternFound) {
|
|
622
|
+
const indexOfFirstCellWithoutTile = pattern.getIndexOfFirstCellWithoutTile();
|
|
1068
623
|
if (indexOfFirstCellWithoutTile === -1) {
|
|
1069
624
|
if (this.canAddPattern(pattern, word)) {
|
|
1070
625
|
onPatternFound(pattern.clone());
|
|
1071
626
|
}
|
|
1072
627
|
}
|
|
1073
628
|
else {
|
|
1074
|
-
for (
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
var previousTile = pattern.cells[indexOfFirstCellWithoutTile].tile;
|
|
629
|
+
for (let index = 0; index < tiles.length; ++index) {
|
|
630
|
+
const tile = tiles[index];
|
|
631
|
+
const previousTile = pattern.cells[indexOfFirstCellWithoutTile].tile;
|
|
1078
632
|
pattern.cells[indexOfFirstCellWithoutTile].tile = tile;
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
633
|
+
const indexOfNextCellWithoutTile = pattern.getIndexOfFirstCellWithoutTile();
|
|
634
|
+
const indexOfFirstEmptyLetter = word.indexOf(constants_1.EMPTY_CELL);
|
|
635
|
+
const newWordPrefix = word.substring(0, indexOfFirstEmptyLetter) + tile.character;
|
|
636
|
+
const newWord = newWordPrefix + word.substring(indexOfFirstEmptyLetter + 1);
|
|
1083
637
|
if (indexOfNextCellWithoutTile === -1) {
|
|
1084
638
|
if (this.canAddPattern(pattern, newWord)) {
|
|
1085
639
|
onPatternFound(pattern.clone());
|
|
1086
640
|
}
|
|
1087
641
|
}
|
|
1088
642
|
else if (this.trie.hasPrefix(newWordPrefix)) {
|
|
1089
|
-
|
|
643
|
+
tiles.splice(index, 1);
|
|
644
|
+
this.fillPattern(pattern, newWord, tiles, onPatternFound);
|
|
645
|
+
tiles.splice(index, 0, tile);
|
|
1090
646
|
}
|
|
1091
647
|
pattern.cells[indexOfFirstCellWithoutTile].tile = previousTile;
|
|
1092
648
|
}
|
|
1093
649
|
}
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
.every(function (collision) { return _this.trie.has(collision); }));
|
|
1102
|
-
};
|
|
1103
|
-
PatternsFiller.prototype.generateBlankTilesPermutations = function (tiles) {
|
|
1104
|
-
var _this = this;
|
|
1105
|
-
var alphabet = this.config.alphabet;
|
|
1106
|
-
var firstBlankIndex = tiles.findIndex(function (_a) {
|
|
1107
|
-
var character = _a.character, isBlank = _a.isBlank;
|
|
1108
|
-
return isBlank && !alphabet.includes(character);
|
|
1109
|
-
});
|
|
650
|
+
}
|
|
651
|
+
canAddPattern(pattern, word) {
|
|
652
|
+
return this.trie.has(word) && pattern.getCollisions().every((collision) => this.trie.has(collision.toString()));
|
|
653
|
+
}
|
|
654
|
+
generateBlankTilesPermutations(tiles) {
|
|
655
|
+
const { alphabet } = this.config;
|
|
656
|
+
const firstBlankIndex = tiles.findIndex(({ character, isBlank }) => isBlank && !alphabet.includes(character));
|
|
1110
657
|
if (firstBlankIndex === -1) {
|
|
1111
658
|
return [tiles];
|
|
1112
659
|
}
|
|
1113
|
-
|
|
1114
|
-
return this.config.alphabet.reduce(
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
return permutations.concat(
|
|
660
|
+
const remainingTiles = tiles.slice(0, firstBlankIndex).concat(tiles.slice(firstBlankIndex + 1));
|
|
661
|
+
return this.config.alphabet.reduce((permutations, character) => {
|
|
662
|
+
const newTile = new types_1.Tile({ character, isBlank: true });
|
|
663
|
+
const newTiles = [...remainingTiles, newTile];
|
|
664
|
+
return permutations.concat(this.generateBlankTilesPermutations(newTiles));
|
|
1118
665
|
}, []);
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
}());
|
|
666
|
+
}
|
|
667
|
+
}
|
|
1122
668
|
exports["default"] = PatternsFiller;
|
|
1123
669
|
|
|
1124
670
|
|
|
1125
671
|
/***/ }),
|
|
1126
672
|
|
|
1127
673
|
/***/ 34196:
|
|
1128
|
-
/***/ (
|
|
674
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1129
675
|
|
|
1130
676
|
|
|
1131
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
1132
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
1133
|
-
if (!m) return o;
|
|
1134
|
-
var i = m.call(o), r, ar = [], e;
|
|
1135
|
-
try {
|
|
1136
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
1137
|
-
}
|
|
1138
|
-
catch (error) { e = { error: error }; }
|
|
1139
|
-
finally {
|
|
1140
|
-
try {
|
|
1141
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
1142
|
-
}
|
|
1143
|
-
finally { if (e) throw e.error; }
|
|
1144
|
-
}
|
|
1145
|
-
return ar;
|
|
1146
|
-
};
|
|
1147
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
1148
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
1149
|
-
if (ar || !(i in from)) {
|
|
1150
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
1151
|
-
ar[i] = from[i];
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
1155
|
-
};
|
|
1156
677
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
678
|
+
const types_1 = __webpack_require__(46452);
|
|
679
|
+
class PatternsGenerator {
|
|
680
|
+
constructor(config) {
|
|
1160
681
|
this.config = config;
|
|
1161
682
|
}
|
|
1162
|
-
|
|
1163
|
-
return
|
|
1164
|
-
}
|
|
1165
|
-
|
|
683
|
+
generate(board) {
|
|
684
|
+
return [...this.generateHorizontal(board), ...this.generateVertical(board)];
|
|
685
|
+
}
|
|
686
|
+
generateHorizontal(board) {
|
|
1166
687
|
return this.generatePatterns({
|
|
1167
|
-
board
|
|
1168
|
-
getNthVector:
|
|
688
|
+
board,
|
|
689
|
+
getNthVector: (index) => board.getRow(index),
|
|
1169
690
|
numberOfVectors: this.config.boardHeight,
|
|
1170
691
|
PatternModel: types_1.HorizontalPattern,
|
|
1171
692
|
});
|
|
1172
|
-
}
|
|
1173
|
-
|
|
693
|
+
}
|
|
694
|
+
generateVertical(board) {
|
|
1174
695
|
return this.generatePatterns({
|
|
1175
|
-
board
|
|
1176
|
-
getNthVector:
|
|
696
|
+
board,
|
|
697
|
+
getNthVector: (index) => board.getColumn(index),
|
|
1177
698
|
numberOfVectors: this.config.boardWidth,
|
|
1178
699
|
PatternModel: types_1.VerticalPattern,
|
|
1179
700
|
});
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
return this.generateVectors({ getNthVector: getNthVector, numberOfVectors: numberOfVectors }).reduce(function (patterns, cells) {
|
|
1185
|
-
return patterns.concat(_this.generateCellsPatterns({ board: board, PatternModel: PatternModel, cells: cells }));
|
|
701
|
+
}
|
|
702
|
+
generatePatterns({ board, getNthVector, numberOfVectors, PatternModel, }) {
|
|
703
|
+
return this.generateVectors({ getNthVector, numberOfVectors }).reduce((patterns, cells) => {
|
|
704
|
+
return patterns.concat(this.generateCellsPatterns({ board, PatternModel, cells }));
|
|
1186
705
|
}, []);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
var getNthVector = _a.getNthVector, numberOfVectors = _a.numberOfVectors;
|
|
706
|
+
}
|
|
707
|
+
generateVectors({ getNthVector, numberOfVectors, }) {
|
|
1190
708
|
return Array(numberOfVectors)
|
|
1191
709
|
.fill(0)
|
|
1192
|
-
.map(
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
board
|
|
710
|
+
.map((_, index) => getNthVector(index));
|
|
711
|
+
}
|
|
712
|
+
generateCellsPatterns({ board, cells, PatternModel, }) {
|
|
713
|
+
return this.generateStartIndices(cells).flatMap((startIndex) => {
|
|
714
|
+
const endIndices = this.generateEndIndices(cells, startIndex);
|
|
715
|
+
const patterns = [];
|
|
716
|
+
for (const endIndex of endIndices) {
|
|
717
|
+
const pattern = new PatternModel({
|
|
718
|
+
board,
|
|
1201
719
|
cells: cells.slice(startIndex, endIndex + 1),
|
|
1202
720
|
});
|
|
1203
|
-
if (pattern.canBePlaced(
|
|
1204
|
-
|
|
721
|
+
if (pattern.canBePlaced(this.config)) {
|
|
722
|
+
patterns.push(pattern);
|
|
1205
723
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
724
|
+
}
|
|
725
|
+
return patterns;
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
generateStartIndices(cells) {
|
|
1211
729
|
return Array(cells.length - 1)
|
|
1212
730
|
.fill(0)
|
|
1213
|
-
.map(
|
|
1214
|
-
.filter(
|
|
1215
|
-
}
|
|
1216
|
-
|
|
731
|
+
.map((_, startIndex) => startIndex)
|
|
732
|
+
.filter((startIndex) => startIndex === 0 || !cells[startIndex - 1].hasTile());
|
|
733
|
+
}
|
|
734
|
+
generateEndIndices(cells, startIndex) {
|
|
1217
735
|
return Array(cells.length - startIndex - 1)
|
|
1218
736
|
.fill(0)
|
|
1219
|
-
.map(
|
|
1220
|
-
.filter(
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
}());
|
|
737
|
+
.map((_, endIndex) => endIndex + startIndex + 1)
|
|
738
|
+
.filter((endIndex) => endIndex >= cells.length - 1 || !cells[endIndex + 1].hasTile());
|
|
739
|
+
}
|
|
740
|
+
}
|
|
1224
741
|
exports["default"] = PatternsGenerator;
|
|
1225
742
|
|
|
1226
743
|
|
|
@@ -1231,15 +748,13 @@ exports["default"] = PatternsGenerator;
|
|
|
1231
748
|
|
|
1232
749
|
|
|
1233
750
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
var _b = bonus && bonus.canApply(_this.config, cell) ? bonus.value : constants_1.NO_BONUS, characterMultiplier = _b.characterMultiplier, wordMultiplier = _b.wordMultiplier;
|
|
1242
|
-
var characterScore = cell.tile.isBlank ? _this.config.blankScore : _this.config.pointsMap[cell.tile.character];
|
|
751
|
+
const constants_1 = __webpack_require__(38436);
|
|
752
|
+
class ScoresCalculator {
|
|
753
|
+
constructor(config) {
|
|
754
|
+
this.reduceCellScore = ({ multiplier, score }, cell) => {
|
|
755
|
+
const bonus = this.config.getCellBonus(cell);
|
|
756
|
+
const { characterMultiplier, wordMultiplier } = bonus && bonus.canApply(this.config, cell) ? bonus.value : constants_1.NO_BONUS;
|
|
757
|
+
const characterScore = cell.tile.isBlank ? this.config.blankScore : this.config.pointsMap[cell.tile.character];
|
|
1243
758
|
return {
|
|
1244
759
|
multiplier: multiplier * wordMultiplier,
|
|
1245
760
|
score: score + characterScore * characterMultiplier,
|
|
@@ -1247,28 +762,26 @@ var ScoresCalculator = /** @class */ (function () {
|
|
|
1247
762
|
};
|
|
1248
763
|
this.config = config;
|
|
1249
764
|
}
|
|
1250
|
-
|
|
765
|
+
calculate(pattern) {
|
|
1251
766
|
return this.calculatePatternScoreWithCollisions(pattern) + this.calculateBonusScore(pattern);
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
|
|
767
|
+
}
|
|
768
|
+
calculateBonusScore(pattern) {
|
|
769
|
+
const areAllTilesUsed = pattern.getNumberOfEmptyCells() === this.config.maximumNumberOfCharacters;
|
|
1255
770
|
return areAllTilesUsed ? this.config.allTilesBonusScore : 0;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
var _this = this;
|
|
771
|
+
}
|
|
772
|
+
calculatePatternScoreWithCollisions(pattern) {
|
|
1259
773
|
return pattern
|
|
1260
774
|
.getCollisions()
|
|
1261
|
-
.reduce(
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
|
|
775
|
+
.reduce((patternsScore, collisionPattern) => patternsScore + this.calculatePatternScore(collisionPattern), this.calculatePatternScore(pattern));
|
|
776
|
+
}
|
|
777
|
+
calculatePatternScore(pattern) {
|
|
778
|
+
const { multiplier, score } = pattern.cells.reduce(this.reduceCellScore, {
|
|
1265
779
|
multiplier: 1,
|
|
1266
780
|
score: 0,
|
|
1267
|
-
})
|
|
781
|
+
});
|
|
1268
782
|
return score * multiplier;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
}());
|
|
783
|
+
}
|
|
784
|
+
}
|
|
1272
785
|
exports["default"] = ScoresCalculator;
|
|
1273
786
|
|
|
1274
787
|
|
|
@@ -1282,35 +795,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1282
795
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1283
796
|
};
|
|
1284
797
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
798
|
+
const types_1 = __webpack_require__(46452);
|
|
799
|
+
const uniqBy_1 = __importDefault(__webpack_require__(50285));
|
|
800
|
+
const PatternsFiller_1 = __importDefault(__webpack_require__(6700));
|
|
801
|
+
const PatternsGenerator_1 = __importDefault(__webpack_require__(34196));
|
|
802
|
+
const ScoresCalculator_1 = __importDefault(__webpack_require__(19368));
|
|
803
|
+
class Solver {
|
|
804
|
+
constructor(config, trie) {
|
|
1292
805
|
this.patternsFiller = new PatternsFiller_1.default(config, trie);
|
|
1293
806
|
this.patternsGenerator = new PatternsGenerator_1.default(config);
|
|
1294
807
|
this.scoresCalculator = new ScoresCalculator_1.default(config);
|
|
1295
808
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
numberOfCollisions: pattern.getCollisions().length,
|
|
1307
|
-
points: _this.scoresCalculator.calculate(pattern),
|
|
1308
|
-
});
|
|
1309
|
-
});
|
|
809
|
+
solve(board, tiles) {
|
|
810
|
+
const patterns = this.patternsGenerator.generate(board);
|
|
811
|
+
const filledPatterns = patterns.flatMap((pattern) => this.patternsFiller.fill(pattern, tiles));
|
|
812
|
+
const uniquePatterns = (0, uniqBy_1.default)(filledPatterns, (pattern) => JSON.stringify(pattern.toJson()));
|
|
813
|
+
const results = uniquePatterns.map((pattern, index) => new types_1.Result({
|
|
814
|
+
cells: pattern.cells,
|
|
815
|
+
id: index,
|
|
816
|
+
numberOfCollisions: pattern.getCollisions().length,
|
|
817
|
+
points: this.scoresCalculator.calculate(pattern),
|
|
818
|
+
}));
|
|
1310
819
|
return results;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
}());
|
|
820
|
+
}
|
|
821
|
+
}
|
|
1314
822
|
exports["default"] = Solver;
|
|
1315
823
|
|
|
1316
824
|
|
|
@@ -1332,219 +840,62 @@ Object.defineProperty(exports, "default", ({ enumerable: true, get: function ()
|
|
|
1332
840
|
/***/ }),
|
|
1333
841
|
|
|
1334
842
|
/***/ 61704:
|
|
1335
|
-
/***/ (
|
|
843
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1336
844
|
|
|
1337
845
|
|
|
1338
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1339
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1340
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1341
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1342
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1343
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1344
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1345
|
-
});
|
|
1346
|
-
};
|
|
1347
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
1348
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1349
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1350
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1351
|
-
function step(op) {
|
|
1352
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1353
|
-
while (_) try {
|
|
1354
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1355
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1356
|
-
switch (op[0]) {
|
|
1357
|
-
case 0: case 1: t = op; break;
|
|
1358
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1359
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1360
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1361
|
-
default:
|
|
1362
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1363
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1364
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1365
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1366
|
-
if (t[2]) _.ops.pop();
|
|
1367
|
-
_.trys.pop(); continue;
|
|
1368
|
-
}
|
|
1369
|
-
op = body.call(thisArg, _);
|
|
1370
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1371
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1372
|
-
}
|
|
1373
|
-
};
|
|
1374
846
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
return
|
|
1379
|
-
|
|
1380
|
-
});
|
|
1381
|
-
}); };
|
|
847
|
+
const lib_1 = __webpack_require__(60337);
|
|
848
|
+
const FILE_URL = 'https://raw.githubusercontent.com/HanSolo80/German-Dictionary/master/dictionary.txt';
|
|
849
|
+
const getDeDeWordList = async () => {
|
|
850
|
+
return (0, lib_1.getTxtWordList)(FILE_URL);
|
|
851
|
+
};
|
|
1382
852
|
exports["default"] = getDeDeWordList;
|
|
1383
853
|
|
|
1384
854
|
|
|
1385
855
|
/***/ }),
|
|
1386
856
|
|
|
1387
857
|
/***/ 3284:
|
|
1388
|
-
/***/ (
|
|
858
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1389
859
|
|
|
1390
860
|
|
|
1391
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1392
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1393
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1394
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1395
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1396
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1397
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1398
|
-
});
|
|
1399
|
-
};
|
|
1400
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
1401
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1402
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1403
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1404
|
-
function step(op) {
|
|
1405
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1406
|
-
while (_) try {
|
|
1407
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1408
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1409
|
-
switch (op[0]) {
|
|
1410
|
-
case 0: case 1: t = op; break;
|
|
1411
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1412
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1413
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1414
|
-
default:
|
|
1415
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1416
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1417
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1418
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1419
|
-
if (t[2]) _.ops.pop();
|
|
1420
|
-
_.trys.pop(); continue;
|
|
1421
|
-
}
|
|
1422
|
-
op = body.call(thisArg, _);
|
|
1423
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1424
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1425
|
-
}
|
|
1426
|
-
};
|
|
1427
861
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
return
|
|
1432
|
-
|
|
1433
|
-
});
|
|
1434
|
-
}); };
|
|
862
|
+
const lib_1 = __webpack_require__(60337);
|
|
863
|
+
const FILE_URL = 'https://www.wordgamedictionary.com/sowpods/download/sowpods.txt';
|
|
864
|
+
const getEnGbWordList = async () => {
|
|
865
|
+
return (0, lib_1.getTxtWordList)(FILE_URL);
|
|
866
|
+
};
|
|
1435
867
|
exports["default"] = getEnGbWordList;
|
|
1436
868
|
|
|
1437
869
|
|
|
1438
870
|
/***/ }),
|
|
1439
871
|
|
|
1440
872
|
/***/ 163:
|
|
1441
|
-
/***/ (
|
|
873
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1442
874
|
|
|
1443
875
|
|
|
1444
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1445
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1446
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1447
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1448
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1449
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1450
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1451
|
-
});
|
|
1452
|
-
};
|
|
1453
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
1454
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1455
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1456
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1457
|
-
function step(op) {
|
|
1458
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1459
|
-
while (_) try {
|
|
1460
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1461
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1462
|
-
switch (op[0]) {
|
|
1463
|
-
case 0: case 1: t = op; break;
|
|
1464
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1465
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1466
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1467
|
-
default:
|
|
1468
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1469
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1470
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1471
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1472
|
-
if (t[2]) _.ops.pop();
|
|
1473
|
-
_.trys.pop(); continue;
|
|
1474
|
-
}
|
|
1475
|
-
op = body.call(thisArg, _);
|
|
1476
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1477
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1478
|
-
}
|
|
1479
|
-
};
|
|
1480
876
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
return
|
|
1485
|
-
|
|
1486
|
-
});
|
|
1487
|
-
}); };
|
|
877
|
+
const lib_1 = __webpack_require__(60337);
|
|
878
|
+
const FILE_URL = 'https://www.wordgamedictionary.com/twl06/download/twl06.txt';
|
|
879
|
+
const getEnUsWordList = async () => {
|
|
880
|
+
return (0, lib_1.getTxtWordList)(FILE_URL);
|
|
881
|
+
};
|
|
1488
882
|
exports["default"] = getEnUsWordList;
|
|
1489
883
|
|
|
1490
884
|
|
|
1491
885
|
/***/ }),
|
|
1492
886
|
|
|
1493
887
|
/***/ 87537:
|
|
1494
|
-
/***/ (
|
|
888
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1495
889
|
|
|
1496
890
|
|
|
1497
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1498
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1499
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1500
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1501
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1502
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1503
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1504
|
-
});
|
|
1505
|
-
};
|
|
1506
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
1507
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1508
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1509
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1510
|
-
function step(op) {
|
|
1511
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1512
|
-
while (_) try {
|
|
1513
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1514
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1515
|
-
switch (op[0]) {
|
|
1516
|
-
case 0: case 1: t = op; break;
|
|
1517
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1518
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1519
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1520
|
-
default:
|
|
1521
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1522
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1523
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1524
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1525
|
-
if (t[2]) _.ops.pop();
|
|
1526
|
-
_.trys.pop(); continue;
|
|
1527
|
-
}
|
|
1528
|
-
op = body.call(thisArg, _);
|
|
1529
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1530
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1531
|
-
}
|
|
1532
|
-
};
|
|
1533
891
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
return
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
case 1:
|
|
1542
|
-
words = _a.sent();
|
|
1543
|
-
return [2 /*return*/, words.map(normalizeWord)];
|
|
1544
|
-
}
|
|
1545
|
-
});
|
|
1546
|
-
}); };
|
|
1547
|
-
var normalizeWord = function (word) {
|
|
892
|
+
const lib_1 = __webpack_require__(60337);
|
|
893
|
+
const FILE_URL = 'https://raw.githubusercontent.com/kamilmielnik/fise-2/master/fise-2.txt';
|
|
894
|
+
const getEsEsWordList = async () => {
|
|
895
|
+
const words = await (0, lib_1.getTxtWordList)(FILE_URL);
|
|
896
|
+
return words.map(normalizeWord);
|
|
897
|
+
};
|
|
898
|
+
const normalizeWord = (word) => {
|
|
1548
899
|
// normalization from https://stackoverflow.com/a/37511463
|
|
1549
900
|
return word.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
1550
901
|
};
|
|
@@ -1554,60 +905,19 @@ exports["default"] = getEsEsWordList;
|
|
|
1554
905
|
/***/ }),
|
|
1555
906
|
|
|
1556
907
|
/***/ 27098:
|
|
1557
|
-
/***/ (
|
|
908
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1558
909
|
|
|
1559
910
|
|
|
1560
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1561
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1562
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1563
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1564
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1565
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1566
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1567
|
-
});
|
|
1568
|
-
};
|
|
1569
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
1570
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1571
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1572
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1573
|
-
function step(op) {
|
|
1574
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1575
|
-
while (_) try {
|
|
1576
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1577
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1578
|
-
switch (op[0]) {
|
|
1579
|
-
case 0: case 1: t = op; break;
|
|
1580
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1581
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1582
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1583
|
-
default:
|
|
1584
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1585
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1586
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1587
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1588
|
-
if (t[2]) _.ops.pop();
|
|
1589
|
-
_.trys.pop(); continue;
|
|
1590
|
-
}
|
|
1591
|
-
op = body.call(thisArg, _);
|
|
1592
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1593
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
911
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
return [2 /*return*/, words.map(normalizeWord)];
|
|
1607
|
-
}
|
|
1608
|
-
});
|
|
1609
|
-
}); };
|
|
1610
|
-
var normalizeWord = function (word) {
|
|
912
|
+
const lib_1 = __webpack_require__(60337);
|
|
913
|
+
const FILE_URL =
|
|
914
|
+
// eslint-disable-next-line max-len
|
|
915
|
+
'https://raw.githubusercontent.com/hbenbel/French-Dictionary/a573eab10cc798d7d5da7daab4d2ac0259bb46a3/dictionary/dictionary.txt';
|
|
916
|
+
const getFrFrWordList = async () => {
|
|
917
|
+
const words = await (0, lib_1.getTxtWordList)(FILE_URL);
|
|
918
|
+
return words.map(normalizeWord);
|
|
919
|
+
};
|
|
920
|
+
const normalizeWord = (word) => {
|
|
1611
921
|
// normalization from https://stackoverflow.com/a/37511463
|
|
1612
922
|
return word.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
1613
923
|
};
|
|
@@ -1620,110 +930,52 @@ exports["default"] = getFrFrWordList;
|
|
|
1620
930
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1621
931
|
|
|
1622
932
|
|
|
1623
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1624
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1625
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1626
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1627
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1628
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1629
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1630
|
-
});
|
|
1631
|
-
};
|
|
1632
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
1633
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1634
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1635
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1636
|
-
function step(op) {
|
|
1637
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1638
|
-
while (_) try {
|
|
1639
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1640
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1641
|
-
switch (op[0]) {
|
|
1642
|
-
case 0: case 1: t = op; break;
|
|
1643
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1644
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1645
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1646
|
-
default:
|
|
1647
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1648
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1649
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1650
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1651
|
-
if (t[2]) _.ops.pop();
|
|
1652
|
-
_.trys.pop(); continue;
|
|
1653
|
-
}
|
|
1654
|
-
op = body.call(thisArg, _);
|
|
1655
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1656
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1657
|
-
}
|
|
1658
|
-
};
|
|
1659
933
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1660
934
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1661
935
|
};
|
|
1662
936
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
});
|
|
1693
|
-
}); };
|
|
1694
|
-
var fetchZipUrl = function (url) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1695
|
-
var html, filename, href;
|
|
1696
|
-
return __generator(this, function (_a) {
|
|
1697
|
-
switch (_a.label) {
|
|
1698
|
-
case 0: return [4 /*yield*/, (0, lib_1.downloadHtml)(url)];
|
|
1699
|
-
case 1:
|
|
1700
|
-
html = _a.sent();
|
|
1701
|
-
return [4 /*yield*/, parseZipContainingPage(html)];
|
|
1702
|
-
case 2:
|
|
1703
|
-
filename = _a.sent();
|
|
1704
|
-
href = new url_1.URL(filename, url).href;
|
|
1705
|
-
return [2 /*return*/, href];
|
|
1706
|
-
}
|
|
1707
|
-
});
|
|
1708
|
-
}); };
|
|
1709
|
-
var parseZipContainingPage = function (html) {
|
|
1710
|
-
var $ = cheerio_1.default.load(html);
|
|
1711
|
-
var $links = $('a');
|
|
1712
|
-
var links = Array.from($links)
|
|
1713
|
-
.map(function (link) { return $(link).attr('href'); })
|
|
937
|
+
const cheerio_1 = __importDefault(__webpack_require__(55473));
|
|
938
|
+
const memfs_1 = __webpack_require__(28098);
|
|
939
|
+
const unzipper_1 = __importDefault(__webpack_require__(23428));
|
|
940
|
+
const url_1 = __webpack_require__(57310);
|
|
941
|
+
const lib_1 = __webpack_require__(60337);
|
|
942
|
+
const PAGE_URL = 'https://sjp.pl/sl/growy/';
|
|
943
|
+
const FILE_TO_EXTRACT_FROM_ZIP = 'slowa.txt';
|
|
944
|
+
const getPlPlWordList = async () => {
|
|
945
|
+
const tempFilename = (0, lib_1.getTempFilename)();
|
|
946
|
+
const zipUrl = await fetchZipUrl(PAGE_URL);
|
|
947
|
+
const zipTempFilename = await (0, lib_1.downloadFile)(zipUrl);
|
|
948
|
+
await unzip(zipTempFilename, tempFilename);
|
|
949
|
+
memfs_1.fs.unlinkSync(zipTempFilename);
|
|
950
|
+
const file = memfs_1.fs.readFileSync(tempFilename, 'utf-8');
|
|
951
|
+
memfs_1.fs.unlinkSync(tempFilename);
|
|
952
|
+
const words = (0, lib_1.extractWords)(file.toLocaleString());
|
|
953
|
+
return words;
|
|
954
|
+
};
|
|
955
|
+
const fetchZipUrl = async (url) => {
|
|
956
|
+
const html = await (0, lib_1.downloadHtml)(url);
|
|
957
|
+
const filename = await parseZipContainingPage(html);
|
|
958
|
+
const { href } = new url_1.URL(filename, url);
|
|
959
|
+
return href;
|
|
960
|
+
};
|
|
961
|
+
const parseZipContainingPage = (html) => {
|
|
962
|
+
const $ = cheerio_1.default.load(html);
|
|
963
|
+
const $links = $('a');
|
|
964
|
+
const links = Array.from($links)
|
|
965
|
+
.map((link) => $(link).attr('href'))
|
|
1714
966
|
.filter(Boolean);
|
|
1715
|
-
|
|
967
|
+
const zipFilename = links.find((link) => link.endsWith('.zip'));
|
|
1716
968
|
if (typeof zipFilename === 'undefined') {
|
|
1717
969
|
throw new Error('Cannot find link to zip file on the page');
|
|
1718
970
|
}
|
|
1719
971
|
return zipFilename;
|
|
1720
972
|
};
|
|
1721
|
-
|
|
973
|
+
const unzip = (zipFilename, outputFilename) => {
|
|
1722
974
|
return memfs_1.fs
|
|
1723
975
|
.createReadStream(zipFilename)
|
|
1724
976
|
.pipe(unzipper_1.default.Parse())
|
|
1725
|
-
.on('entry',
|
|
1726
|
-
|
|
977
|
+
.on('entry', (entry) => {
|
|
978
|
+
const fileName = entry.path;
|
|
1727
979
|
if (fileName === FILE_TO_EXTRACT_FROM_ZIP) {
|
|
1728
980
|
entry.pipe(memfs_1.fs.createWriteStream(outputFilename));
|
|
1729
981
|
}
|
|
@@ -1745,24 +997,23 @@ exports["default"] = getPlPlWordList;
|
|
|
1745
997
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1746
998
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1747
999
|
};
|
|
1748
|
-
var _a;
|
|
1749
1000
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1001
|
+
const types_1 = __webpack_require__(46452);
|
|
1002
|
+
const getDeDeWordList_1 = __importDefault(__webpack_require__(61704));
|
|
1003
|
+
const getEnGbWordList_1 = __importDefault(__webpack_require__(3284));
|
|
1004
|
+
const getEnUsWordList_1 = __importDefault(__webpack_require__(163));
|
|
1005
|
+
const getEsEsWordList_1 = __importDefault(__webpack_require__(87537));
|
|
1006
|
+
const getFrFrWordList_1 = __importDefault(__webpack_require__(27098));
|
|
1007
|
+
const getPlPlWordList_1 = __importDefault(__webpack_require__(81848));
|
|
1008
|
+
const localeMap = {
|
|
1009
|
+
[types_1.Locale.DE_DE]: getDeDeWordList_1.default,
|
|
1010
|
+
[types_1.Locale.EN_GB]: getEnGbWordList_1.default,
|
|
1011
|
+
[types_1.Locale.EN_US]: getEnUsWordList_1.default,
|
|
1012
|
+
[types_1.Locale.ES_ES]: getEsEsWordList_1.default,
|
|
1013
|
+
[types_1.Locale.FR_FR]: getFrFrWordList_1.default,
|
|
1014
|
+
[types_1.Locale.PL_PL]: getPlPlWordList_1.default,
|
|
1015
|
+
};
|
|
1016
|
+
const getWordList = (locale) => localeMap[locale]();
|
|
1766
1017
|
exports["default"] = getWordList;
|
|
1767
1018
|
|
|
1768
1019
|
|
|
@@ -1809,24 +1060,42 @@ __exportStar(__webpack_require__(60337), exports);
|
|
|
1809
1060
|
/***/ }),
|
|
1810
1061
|
|
|
1811
1062
|
/***/ 920:
|
|
1812
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
1063
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1813
1064
|
|
|
1814
1065
|
|
|
1066
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1067
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1068
|
+
};
|
|
1815
1069
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1070
|
+
const follow_redirects_1 = __webpack_require__(24396);
|
|
1071
|
+
const memfs_1 = __webpack_require__(28098);
|
|
1072
|
+
const getTempFilename_1 = __importDefault(__webpack_require__(52688));
|
|
1073
|
+
const downloadFile = (url) => {
|
|
1074
|
+
return new Promise((resolve, reject) => {
|
|
1075
|
+
const tempFilename = (0, getTempFilename_1.default)();
|
|
1076
|
+
const protocol = url.startsWith('https') ? follow_redirects_1.https : follow_redirects_1.http;
|
|
1077
|
+
const writeStream = memfs_1.fs.createWriteStream(tempFilename);
|
|
1078
|
+
const request = protocol.get(url, (response) => {
|
|
1821
1079
|
if (typeof response.statusCode === 'undefined' || response.statusCode >= 400) {
|
|
1822
|
-
reject();
|
|
1080
|
+
reject(new Error(`Cannot download file: ${url}`));
|
|
1823
1081
|
return;
|
|
1824
1082
|
}
|
|
1825
|
-
response.
|
|
1826
|
-
|
|
1827
|
-
|
|
1083
|
+
response.on('error', (error) => {
|
|
1084
|
+
writeStream.close();
|
|
1085
|
+
reject(error);
|
|
1086
|
+
});
|
|
1087
|
+
response.on('end', () => {
|
|
1088
|
+
writeStream.on('finish', () => {
|
|
1089
|
+
writeStream.close();
|
|
1090
|
+
resolve(tempFilename);
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
response.pipe(writeStream);
|
|
1094
|
+
});
|
|
1095
|
+
request.on('error', (error) => {
|
|
1096
|
+
writeStream.close();
|
|
1097
|
+
reject(error);
|
|
1828
1098
|
});
|
|
1829
|
-
request.on('error', reject);
|
|
1830
1099
|
});
|
|
1831
1100
|
};
|
|
1832
1101
|
exports["default"] = downloadFile;
|
|
@@ -1839,17 +1108,17 @@ exports["default"] = downloadFile;
|
|
|
1839
1108
|
|
|
1840
1109
|
|
|
1841
1110
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
return new Promise(
|
|
1845
|
-
|
|
1846
|
-
protocol.get(url,
|
|
1847
|
-
|
|
1111
|
+
const follow_redirects_1 = __webpack_require__(24396);
|
|
1112
|
+
const downloadHtml = (url) => {
|
|
1113
|
+
return new Promise((resolve, reject) => {
|
|
1114
|
+
const protocol = url.startsWith('https') ? follow_redirects_1.https : follow_redirects_1.http;
|
|
1115
|
+
protocol.get(url, (response) => {
|
|
1116
|
+
let data = '';
|
|
1848
1117
|
response.setEncoding('utf8');
|
|
1849
|
-
response.on('data',
|
|
1118
|
+
response.on('data', (chunk) => {
|
|
1850
1119
|
data += chunk;
|
|
1851
1120
|
});
|
|
1852
|
-
response.on('end',
|
|
1121
|
+
response.on('end', () => {
|
|
1853
1122
|
resolve(data);
|
|
1854
1123
|
});
|
|
1855
1124
|
response.on('error', reject);
|
|
@@ -1869,11 +1138,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1869
1138
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1870
1139
|
};
|
|
1871
1140
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1141
|
+
const findFirstWordIndex_1 = __importDefault(__webpack_require__(47669));
|
|
1142
|
+
const extractWords = (file) => {
|
|
1143
|
+
const lines = file.replace(/\r/g, '').split('\n');
|
|
1144
|
+
const firstWordIndex = (0, findFirstWordIndex_1.default)(lines);
|
|
1145
|
+
const words = lines.slice(firstWordIndex).filter(Boolean);
|
|
1877
1146
|
return words;
|
|
1878
1147
|
};
|
|
1879
1148
|
exports["default"] = extractWords;
|
|
@@ -1886,12 +1155,12 @@ exports["default"] = extractWords;
|
|
|
1886
1155
|
|
|
1887
1156
|
|
|
1888
1157
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1158
|
+
const findFirstWordIndex = (lines) => {
|
|
1159
|
+
const firstWordIndex = lines.findIndex((line, index) => {
|
|
1160
|
+
const nextLine = line[index + 1] || '';
|
|
1161
|
+
const isNextLineInOrder = line.localeCompare(nextLine) === 1;
|
|
1162
|
+
const hasWhitespace = Boolean(line.match(/\s/));
|
|
1163
|
+
const isEmpty = line.trim().length === 0;
|
|
1895
1164
|
return !isEmpty && !hasWhitespace && isNextLineInOrder;
|
|
1896
1165
|
});
|
|
1897
1166
|
if (typeof firstWordIndex === 'undefined') {
|
|
@@ -1912,11 +1181,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1912
1181
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1913
1182
|
};
|
|
1914
1183
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
if (bytes === void 0) { bytes = 8; }
|
|
1918
|
-
return crypto_1.default.randomBytes(bytes).toString('hex');
|
|
1919
|
-
};
|
|
1184
|
+
const crypto_1 = __importDefault(__webpack_require__(6113));
|
|
1185
|
+
const getHash = (bytes = 8) => crypto_1.default.randomBytes(bytes).toString('hex');
|
|
1920
1186
|
exports["default"] = getHash;
|
|
1921
1187
|
|
|
1922
1188
|
|
|
@@ -1930,9 +1196,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
1930
1196
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1931
1197
|
};
|
|
1932
1198
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
return
|
|
1199
|
+
const getHash_1 = __importDefault(__webpack_require__(93938));
|
|
1200
|
+
const getTempFilename = () => {
|
|
1201
|
+
return `/${(0, getHash_1.default)()}.txt`;
|
|
1936
1202
|
};
|
|
1937
1203
|
exports["default"] = getTempFilename;
|
|
1938
1204
|
|
|
@@ -1943,66 +1209,20 @@ exports["default"] = getTempFilename;
|
|
|
1943
1209
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1944
1210
|
|
|
1945
1211
|
|
|
1946
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
1947
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1948
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1949
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1950
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1951
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1952
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1953
|
-
});
|
|
1954
|
-
};
|
|
1955
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
1956
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1957
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1958
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1959
|
-
function step(op) {
|
|
1960
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1961
|
-
while (_) try {
|
|
1962
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1963
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1964
|
-
switch (op[0]) {
|
|
1965
|
-
case 0: case 1: t = op; break;
|
|
1966
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1967
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1968
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1969
|
-
default:
|
|
1970
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1971
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1972
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1973
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1974
|
-
if (t[2]) _.ops.pop();
|
|
1975
|
-
_.trys.pop(); continue;
|
|
1976
|
-
}
|
|
1977
|
-
op = body.call(thisArg, _);
|
|
1978
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1979
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1980
|
-
}
|
|
1981
|
-
};
|
|
1982
1212
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
1983
1213
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1984
1214
|
};
|
|
1985
1215
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
return [4 /*yield*/, (0, downloadFile_1.default)(url, memfs_1.fs.createWriteStream(tempFilename))];
|
|
1997
|
-
case 1:
|
|
1998
|
-
_a.sent();
|
|
1999
|
-
file = memfs_1.fs.readFileSync(tempFilename, 'utf-8');
|
|
2000
|
-
words = (0, extractWords_1.default)(file.toString());
|
|
2001
|
-
memfs_1.fs.unlinkSync(tempFilename);
|
|
2002
|
-
return [2 /*return*/, words];
|
|
2003
|
-
}
|
|
2004
|
-
});
|
|
2005
|
-
}); };
|
|
1216
|
+
const memfs_1 = __webpack_require__(28098);
|
|
1217
|
+
const downloadFile_1 = __importDefault(__webpack_require__(920));
|
|
1218
|
+
const extractWords_1 = __importDefault(__webpack_require__(39759));
|
|
1219
|
+
const getTxtWordList = async (url) => {
|
|
1220
|
+
const tempFilename = await (0, downloadFile_1.default)(url);
|
|
1221
|
+
const file = memfs_1.fs.readFileSync(tempFilename, 'utf-8');
|
|
1222
|
+
const words = (0, extractWords_1.default)(file.toLocaleString());
|
|
1223
|
+
memfs_1.fs.unlinkSync(tempFilename);
|
|
1224
|
+
return words;
|
|
1225
|
+
};
|
|
2006
1226
|
exports["default"] = getTxtWordList;
|
|
2007
1227
|
|
|
2008
1228
|
|