@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
|
@@ -8,18 +8,17 @@ exports.modules = {
|
|
|
8
8
|
"use strict";
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11
|
-
|
|
11
|
+
const lib_1 = __webpack_require__(19336);
|
|
12
12
|
/**
|
|
13
13
|
* A class representing the {@link https://en.wikipedia.org/wiki/Trie | Trie data structure}.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
class Trie {
|
|
16
16
|
/**
|
|
17
17
|
* Creates a new {@link Trie} with optionally given root {@link Node}.
|
|
18
18
|
*
|
|
19
19
|
* @param root - Root {@link Node} of the {@link Trie} to be created.
|
|
20
20
|
*/
|
|
21
|
-
|
|
22
|
-
if (root === void 0) { root = {}; }
|
|
21
|
+
constructor(root = {}) {
|
|
23
22
|
this.root = root;
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
@@ -30,45 +29,45 @@ var Trie = /** @class */ (function () {
|
|
|
30
29
|
* @param serialized - String with serialized data.
|
|
31
30
|
* @returns {@link Trie} representing deserialized data.
|
|
32
31
|
*/
|
|
33
|
-
|
|
34
|
-
return new Trie(lib_1.deserialize(serialized));
|
|
35
|
-
}
|
|
32
|
+
static deserialize(serialized) {
|
|
33
|
+
return new Trie((0, lib_1.deserialize)(serialized));
|
|
34
|
+
}
|
|
36
35
|
/**
|
|
37
36
|
* Creates a new {@link Trie} based on array of words.
|
|
38
37
|
*
|
|
39
38
|
* @params words - array of words to put in the {@link Trie}.
|
|
40
39
|
* @returns New {@link Trie} containing all given words.
|
|
41
40
|
*/
|
|
42
|
-
|
|
43
|
-
return new Trie(lib_1.fromArray(words));
|
|
44
|
-
}
|
|
41
|
+
static fromArray(words) {
|
|
42
|
+
return new Trie((0, lib_1.fromArray)(words));
|
|
43
|
+
}
|
|
45
44
|
/**
|
|
46
45
|
* Inserts given word into the {@link Trie}.
|
|
47
46
|
*
|
|
48
47
|
* @param word - Word to be inserted into the {@link Trie}.
|
|
49
48
|
* @returns {@link Node} representing the end of the added word.
|
|
50
49
|
*/
|
|
51
|
-
|
|
52
|
-
return lib_1.add(this.root, word);
|
|
53
|
-
}
|
|
50
|
+
add(word) {
|
|
51
|
+
return (0, lib_1.add)(this.root, word);
|
|
52
|
+
}
|
|
54
53
|
/**
|
|
55
54
|
* Finds {@link Node} representing given prefix in the {@link Trie}.
|
|
56
55
|
*
|
|
57
56
|
* @param prefix - Prefix to be found.
|
|
58
57
|
* @returns {@link Node} representing a given prefix, undefined if there is no such node.
|
|
59
58
|
*/
|
|
60
|
-
|
|
61
|
-
return lib_1.find(this.root, prefix);
|
|
62
|
-
}
|
|
59
|
+
find(prefix) {
|
|
60
|
+
return (0, lib_1.find)(this.root, prefix);
|
|
61
|
+
}
|
|
63
62
|
/**
|
|
64
63
|
* Tells you whether given word is in the {@link Trie}.
|
|
65
64
|
*
|
|
66
65
|
* @param word - Word to be found.
|
|
67
66
|
* @returns true if given word is in the {@link Trie}, false otherwise.
|
|
68
67
|
*/
|
|
69
|
-
|
|
70
|
-
return lib_1.has(this.root, word);
|
|
71
|
-
}
|
|
68
|
+
has(word) {
|
|
69
|
+
return (0, lib_1.has)(this.root, word);
|
|
70
|
+
}
|
|
72
71
|
/**
|
|
73
72
|
* Tells you whether there are any words with given prefix in the {@link Trie}.
|
|
74
73
|
*
|
|
@@ -77,18 +76,18 @@ var Trie = /** @class */ (function () {
|
|
|
77
76
|
* @param prefix - Prefix to be found.
|
|
78
77
|
* @returns true if there are any words with given prefix in the {@link Trie}, false otherwise.
|
|
79
78
|
*/
|
|
80
|
-
|
|
81
|
-
return lib_1.hasPrefix(this.root, prefix);
|
|
82
|
-
}
|
|
79
|
+
hasPrefix(prefix) {
|
|
80
|
+
return (0, lib_1.hasPrefix)(this.root, prefix);
|
|
81
|
+
}
|
|
83
82
|
/**
|
|
84
83
|
* Removes given word from the {@link Trie} if it exists.
|
|
85
84
|
*
|
|
86
85
|
* @param word - Word to be removed.
|
|
87
86
|
* @returns true if the word was removed, false otherwise.
|
|
88
87
|
*/
|
|
89
|
-
|
|
90
|
-
return lib_1.remove(this.root, word);
|
|
91
|
-
}
|
|
88
|
+
remove(word) {
|
|
89
|
+
return (0, lib_1.remove)(this.root, word);
|
|
90
|
+
}
|
|
92
91
|
/**
|
|
93
92
|
* Converts the {@link Trie} into a string.
|
|
94
93
|
*
|
|
@@ -102,29 +101,28 @@ var Trie = /** @class */ (function () {
|
|
|
102
101
|
*
|
|
103
102
|
* @returns String with serialized data.
|
|
104
103
|
*/
|
|
105
|
-
|
|
106
|
-
return lib_1.serialize(this.root);
|
|
107
|
-
}
|
|
104
|
+
serialize() {
|
|
105
|
+
return (0, lib_1.serialize)(this.root);
|
|
106
|
+
}
|
|
108
107
|
/**
|
|
109
108
|
* Finds all {@link Descendant | descendants} of the {@link Trie | Trie's} root and returns them as an array.
|
|
110
109
|
*
|
|
111
110
|
* @param options - See {@link TraverseOptions}.
|
|
112
111
|
* @returns An array of {@link Descendant | descendants}.
|
|
113
112
|
*/
|
|
114
|
-
|
|
115
|
-
return lib_1.toArray(this.root, options);
|
|
116
|
-
}
|
|
113
|
+
toArray(options) {
|
|
114
|
+
return (0, lib_1.toArray)(this.root, options);
|
|
115
|
+
}
|
|
117
116
|
/**
|
|
118
117
|
* Visits every descendant {@link Node} of the {@link Trie} and calls a callback.
|
|
119
118
|
*
|
|
120
119
|
* @param callback - Callback that will be called for each visited {@link Node}. Return true from callback to stop traversing.
|
|
121
120
|
* @param options - See {@link TraverseOptions}.
|
|
122
121
|
*/
|
|
123
|
-
|
|
124
|
-
return lib_1.traverse(this.root, callback, options);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
}());
|
|
122
|
+
traverse(callback, options) {
|
|
123
|
+
return (0, lib_1.traverse)(this.root, callback, options);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
128
126
|
exports["default"] = Trie;
|
|
129
127
|
|
|
130
128
|
|
|
@@ -156,7 +154,11 @@ exports.OPEN_PARENS = '(';
|
|
|
156
154
|
|
|
157
155
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
158
156
|
if (k2 === undefined) k2 = k;
|
|
159
|
-
Object.
|
|
157
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
158
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
159
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
160
|
+
}
|
|
161
|
+
Object.defineProperty(o, k2, desc);
|
|
160
162
|
}) : (function(o, m, k, k2) {
|
|
161
163
|
if (k2 === undefined) k2 = k;
|
|
162
164
|
o[k2] = m[k];
|
|
@@ -169,7 +171,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
169
171
|
};
|
|
170
172
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
171
173
|
exports.Trie = void 0;
|
|
172
|
-
|
|
174
|
+
const Trie_1 = __importDefault(__webpack_require__(43210));
|
|
173
175
|
Object.defineProperty(exports, "Trie", ({ enumerable: true, get: function () { return Trie_1.default; } }));
|
|
174
176
|
__exportStar(__webpack_require__(31430), exports);
|
|
175
177
|
__exportStar(__webpack_require__(19336), exports);
|
|
@@ -191,10 +193,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
191
193
|
* @param word - Word to be inserted into `node`.
|
|
192
194
|
* @returns {@link Node} representing the end of the added word.
|
|
193
195
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
for (
|
|
197
|
-
|
|
196
|
+
const add = (node, word) => {
|
|
197
|
+
let currentNode = node;
|
|
198
|
+
for (let index = 0; index < word.length; ++index) {
|
|
199
|
+
const character = word[index];
|
|
198
200
|
if (!currentNode[character]) {
|
|
199
201
|
currentNode[character] = {};
|
|
200
202
|
}
|
|
@@ -214,7 +216,7 @@ exports["default"] = add;
|
|
|
214
216
|
"use strict";
|
|
215
217
|
|
|
216
218
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
217
|
-
|
|
219
|
+
const constants_1 = __webpack_require__(31430);
|
|
218
220
|
/**
|
|
219
221
|
* Creates a new {@link Node} by deserializing given string.
|
|
220
222
|
*
|
|
@@ -223,33 +225,33 @@ var constants_1 = __webpack_require__(31430);
|
|
|
223
225
|
* @param serialized - String with value returned by {@link serialize}.
|
|
224
226
|
* @returns Instance of a root {@link Node} of deserialized string.
|
|
225
227
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
const deserialize = (serialized) => {
|
|
229
|
+
const stack = [];
|
|
230
|
+
let node = {};
|
|
231
|
+
let i = 1;
|
|
230
232
|
while (i < serialized.length - 1) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
+
const character = serialized[i];
|
|
234
|
+
const nextCharacter = serialized[i + 1];
|
|
233
235
|
++i;
|
|
234
236
|
if (character === constants_1.CLOSE_PARENS) {
|
|
235
|
-
|
|
237
|
+
const nextNode = stack.pop();
|
|
236
238
|
if (!nextNode) {
|
|
237
|
-
throw new Error(
|
|
239
|
+
throw new Error(`Syntax error: misplaced "${constants_1.CLOSE_PARENS}"`);
|
|
238
240
|
}
|
|
239
241
|
node = nextNode;
|
|
240
242
|
}
|
|
241
243
|
else if (nextCharacter === constants_1.CLOSE_PARENS) {
|
|
242
244
|
node[character] = { wordEnd: true };
|
|
243
|
-
|
|
245
|
+
const nextNode = stack.pop();
|
|
244
246
|
if (!nextNode) {
|
|
245
|
-
throw new Error(
|
|
247
|
+
throw new Error(`Syntax error: misplaced "${constants_1.CLOSE_PARENS}"`);
|
|
246
248
|
}
|
|
247
249
|
node = nextNode;
|
|
248
250
|
++i;
|
|
249
251
|
}
|
|
250
252
|
else if (nextCharacter === constants_1.OPEN_PARENS) {
|
|
251
253
|
stack.push(node);
|
|
252
|
-
|
|
254
|
+
const newNode = node[character] || {};
|
|
253
255
|
node[character] = newNode;
|
|
254
256
|
node = newNode;
|
|
255
257
|
++i;
|
|
@@ -278,10 +280,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
278
280
|
* @param prefix - Prefix to be found.
|
|
279
281
|
* @returns {@link Node} representing a given prefix, undefined if there is no such node.
|
|
280
282
|
*/
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
for (
|
|
284
|
-
|
|
283
|
+
const find = (node, prefix) => {
|
|
284
|
+
let currentNode = node;
|
|
285
|
+
for (let index = 0; index < prefix.length; ++index) {
|
|
286
|
+
const character = prefix[index];
|
|
285
287
|
if (!currentNode[character]) {
|
|
286
288
|
return undefined;
|
|
287
289
|
}
|
|
@@ -303,16 +305,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
303
305
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
304
306
|
};
|
|
305
307
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
306
|
-
|
|
308
|
+
const add_1 = __importDefault(__webpack_require__(3661));
|
|
307
309
|
/**
|
|
308
310
|
* Creates a new {@link Node} based on array of words.
|
|
309
311
|
*
|
|
310
312
|
* @params words - array of words to put in the {@link Node}.
|
|
311
313
|
* @returns New {@link Node} containing all given words.
|
|
312
314
|
*/
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
words.forEach(
|
|
315
|
+
const fromArray = (words) => {
|
|
316
|
+
const node = {};
|
|
317
|
+
words.forEach((word) => (0, add_1.default)(node, word));
|
|
316
318
|
return node;
|
|
317
319
|
};
|
|
318
320
|
exports["default"] = fromArray;
|
|
@@ -329,7 +331,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
329
331
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
330
332
|
};
|
|
331
333
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
332
|
-
|
|
334
|
+
const find_1 = __importDefault(__webpack_require__(89129));
|
|
333
335
|
/**
|
|
334
336
|
* Tells you whether given word is in the {@link Node}.
|
|
335
337
|
*
|
|
@@ -337,8 +339,8 @@ var find_1 = __importDefault(__webpack_require__(89129));
|
|
|
337
339
|
* @param word - Word to be found.
|
|
338
340
|
* @returns true if given word is in the {@link Node}, false otherwise.
|
|
339
341
|
*/
|
|
340
|
-
|
|
341
|
-
|
|
342
|
+
const has = (node, word) => {
|
|
343
|
+
const foundNode = (0, find_1.default)(node, word);
|
|
342
344
|
return Boolean(foundNode && foundNode.wordEnd);
|
|
343
345
|
};
|
|
344
346
|
exports["default"] = has;
|
|
@@ -355,7 +357,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
355
357
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
356
358
|
};
|
|
357
359
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
358
|
-
|
|
360
|
+
const find_1 = __importDefault(__webpack_require__(89129));
|
|
359
361
|
/**
|
|
360
362
|
* Tells you whether there are any words with given prefix in the {@link Node}.
|
|
361
363
|
*
|
|
@@ -365,8 +367,8 @@ var find_1 = __importDefault(__webpack_require__(89129));
|
|
|
365
367
|
* @param prefix - Prefix to be found.
|
|
366
368
|
* @returns true if there are any words with given prefix in the {@link Node}, false otherwise.
|
|
367
369
|
*/
|
|
368
|
-
|
|
369
|
-
|
|
370
|
+
const hasPrefix = (node, prefix) => {
|
|
371
|
+
const foundNode = (0, find_1.default)(node, prefix);
|
|
370
372
|
return foundNode ? Object.keys(foundNode).length > 0 : false;
|
|
371
373
|
};
|
|
372
374
|
exports["default"] = hasPrefix;
|
|
@@ -424,7 +426,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
424
426
|
* @param key2 - Second key to compare.
|
|
425
427
|
* @returns -1 if key1 should precede key2, 0 if they're the same, 1 if key2 should precede key1.
|
|
426
428
|
*/
|
|
427
|
-
|
|
429
|
+
const nodeKeyComparator = (key1, key2) => {
|
|
428
430
|
if (key1 === 'wordEnd') {
|
|
429
431
|
return -1;
|
|
430
432
|
}
|
|
@@ -451,7 +453,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
451
453
|
* @param word - Word to be removed.
|
|
452
454
|
* @returns true if the word was removed, false otherwise.
|
|
453
455
|
*/
|
|
454
|
-
|
|
456
|
+
const remove = (node, word) => {
|
|
455
457
|
if (word.length === 0) {
|
|
456
458
|
if (node.wordEnd) {
|
|
457
459
|
delete node.wordEnd;
|
|
@@ -459,12 +461,12 @@ var remove = function (node, word) {
|
|
|
459
461
|
}
|
|
460
462
|
return false;
|
|
461
463
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
+
const letter = word[0];
|
|
465
|
+
const nextNode = node[letter];
|
|
464
466
|
if (!nextNode) {
|
|
465
467
|
return false;
|
|
466
468
|
}
|
|
467
|
-
|
|
469
|
+
const removed = remove(nextNode, word.substring(1));
|
|
468
470
|
if (!removed) {
|
|
469
471
|
return false;
|
|
470
472
|
}
|
|
@@ -484,18 +486,18 @@ exports["default"] = remove;
|
|
|
484
486
|
"use strict";
|
|
485
487
|
|
|
486
488
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
489
|
+
const constants_1 = __webpack_require__(31430);
|
|
490
|
+
const serializeNode = (node, character) => {
|
|
491
|
+
const letters = Object.keys(node).filter((key) => key.length === 1);
|
|
492
|
+
const hasPrefix = letters.length > 0;
|
|
493
|
+
let serialized = '';
|
|
492
494
|
if (node.wordEnd) {
|
|
493
495
|
serialized += character;
|
|
494
496
|
}
|
|
495
497
|
if (hasPrefix) {
|
|
496
498
|
serialized += character;
|
|
497
499
|
serialized += constants_1.OPEN_PARENS;
|
|
498
|
-
serialized += letters.map(
|
|
500
|
+
serialized += letters.map((letter) => serializeNode(node[letter], letter)).join('');
|
|
499
501
|
serialized += constants_1.CLOSE_PARENS;
|
|
500
502
|
}
|
|
501
503
|
return serialized;
|
|
@@ -514,7 +516,7 @@ var serializeNode = function (node, character) {
|
|
|
514
516
|
* @param node - {@link Node} to serialize.
|
|
515
517
|
* @returns String with serialized data.
|
|
516
518
|
*/
|
|
517
|
-
|
|
519
|
+
const serialize = (node) => serializeNode(node, '');
|
|
518
520
|
exports["default"] = serialize;
|
|
519
521
|
|
|
520
522
|
|
|
@@ -529,7 +531,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
529
531
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
530
532
|
};
|
|
531
533
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
532
|
-
|
|
534
|
+
const traverse_1 = __importDefault(__webpack_require__(6026));
|
|
533
535
|
/**
|
|
534
536
|
* Finds all {@link Descendant | descendants} of given {@link Node} and returns them as an array.
|
|
535
537
|
*
|
|
@@ -537,12 +539,12 @@ var traverse_1 = __importDefault(__webpack_require__(6026));
|
|
|
537
539
|
* @param options - See {@link TraverseOptions}.
|
|
538
540
|
* @returns An array of {@link Descendant | descendants}.
|
|
539
541
|
*/
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
542
|
+
const toArray = (node, options) => {
|
|
543
|
+
const descendants = [];
|
|
544
|
+
const callback = (parameters) => {
|
|
543
545
|
descendants.push(parameters);
|
|
544
546
|
};
|
|
545
|
-
traverse_1.default(node, callback, options);
|
|
547
|
+
(0, traverse_1.default)(node, callback, options);
|
|
546
548
|
return descendants;
|
|
547
549
|
};
|
|
548
550
|
exports["default"] = toArray;
|
|
@@ -559,7 +561,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
559
561
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
560
562
|
};
|
|
561
563
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
562
|
-
|
|
564
|
+
const nodeKeyComparator_1 = __importDefault(__webpack_require__(68693));
|
|
563
565
|
/**
|
|
564
566
|
* Visits every descendant {@link Node} of given {@link Node} and calls a callback.
|
|
565
567
|
*
|
|
@@ -567,21 +569,20 @@ var nodeKeyComparator_1 = __importDefault(__webpack_require__(68693));
|
|
|
567
569
|
* @param callback - Callback that will be called for each visited {@link Node}. Return true from callback to stop traversing.
|
|
568
570
|
* @param options - See {@link TraverseOptions}.
|
|
569
571
|
*/
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
var currentPrefix = options.prefix || '';
|
|
572
|
+
const traverse = (node, callback, options = {}) => {
|
|
573
|
+
const stack = [];
|
|
574
|
+
let currentKeyIndex = 0;
|
|
575
|
+
let currentNode = node;
|
|
576
|
+
let currentPrefix = options.prefix || '';
|
|
576
577
|
while (stack.length > 0 || currentNode) {
|
|
577
578
|
while (currentNode) {
|
|
578
|
-
|
|
579
|
+
const keys = Object.keys(currentNode);
|
|
579
580
|
if (currentKeyIndex >= keys.length) {
|
|
580
581
|
currentNode = undefined;
|
|
581
582
|
}
|
|
582
583
|
else {
|
|
583
|
-
|
|
584
|
-
|
|
584
|
+
const sortedKeys = options.sort ? keys.sort(nodeKeyComparator_1.default) : keys;
|
|
585
|
+
const key = sortedKeys[currentKeyIndex];
|
|
585
586
|
if (key === 'wordEnd') {
|
|
586
587
|
++currentKeyIndex;
|
|
587
588
|
}
|
|
@@ -591,7 +592,7 @@ var traverse = function (node, callback, options) {
|
|
|
591
592
|
currentNode = currentNode[key];
|
|
592
593
|
currentPrefix += key;
|
|
593
594
|
if (!options.wordsOnly || currentNode.wordEnd) {
|
|
594
|
-
|
|
595
|
+
const shouldStop = callback({ node: currentNode, prefix: currentPrefix });
|
|
595
596
|
if (shouldStop) {
|
|
596
597
|
return;
|
|
597
598
|
}
|
|
@@ -600,7 +601,7 @@ var traverse = function (node, callback, options) {
|
|
|
600
601
|
}
|
|
601
602
|
}
|
|
602
603
|
if (stack.length > 0) {
|
|
603
|
-
|
|
604
|
+
const state = stack.pop();
|
|
604
605
|
currentKeyIndex = state.keyIndex + 1;
|
|
605
606
|
currentNode = state.node;
|
|
606
607
|
currentPrefix = currentPrefix.slice(0, -1);
|