@scrabble-solver/scrabble-solver 2.13.9 → 2.13.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +5 -5
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_8dgz12 +1 -1
  5. package/.next/cache/webpack/client-production/0.pack +0 -0
  6. package/.next/cache/webpack/client-production/index.pack +0 -0
  7. package/.next/cache/webpack/edge-server-production/0.pack +0 -0
  8. package/.next/cache/webpack/edge-server-production/index.pack +0 -0
  9. package/.next/cache/webpack/server-production/0.pack +0 -0
  10. package/.next/cache/webpack/server-production/index.pack +0 -0
  11. package/.next/prerender-manifest.js +1 -1
  12. package/.next/prerender-manifest.json +1 -1
  13. package/.next/routes-manifest.json +1 -1
  14. package/.next/server/chunks/807.js +1 -1
  15. package/.next/server/middleware-build-manifest.js +1 -1
  16. package/.next/server/pages/404.html +1 -1
  17. package/.next/server/pages/500.html +1 -1
  18. package/.next/server/pages/_app.js +1 -1
  19. package/.next/server/pages/_error.js +1 -1
  20. package/.next/server/pages/api/solve.js +1 -1
  21. package/.next/server/pages/index.html +1 -1
  22. package/.next/server/pages/index.js +1 -1
  23. package/.next/server/pages/index.json +1 -1
  24. package/.next/static/{eLvYNd4B2hzSgBZ_PuZcQ → 0kOqO_aASkcT2xjhiptyo}/_buildManifest.js +1 -1
  25. package/.next/static/chunks/pages/{404-01653a877b233143.js → 404-b447c5ca188dd7c1.js} +1 -1
  26. package/.next/static/chunks/pages/_app-0bbddaa93fde16ea.js +17 -0
  27. package/.next/static/chunks/pages/index-24b84719cf22731c.js +1 -0
  28. package/.next/trace +44 -44
  29. package/package.json +10 -9
  30. package/src/components/Results/Results.tsx +5 -1
  31. package/src/lib/groupResults.ts +4 -7
  32. package/src/lib/index.ts +1 -0
  33. package/src/lib/sortGroupedResults.ts +22 -0
  34. package/src/state/selectors.ts +8 -5
  35. package/src/types/index.ts +8 -0
  36. package/.next/static/chunks/pages/_app-735b5863675c1b5d.js +0 -17
  37. package/.next/static/chunks/pages/index-36c448d585a58425.js +0 -1
  38. /package/.next/static/{eLvYNd4B2hzSgBZ_PuZcQ → 0kOqO_aASkcT2xjhiptyo}/_ssgManifest.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/scrabble-solver",
3
- "version": "2.13.9",
3
+ "version": "2.13.10",
4
4
  "description": "Scrabble Solver 2 - App",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -30,13 +30,13 @@
30
30
  "@floating-ui/react": "^0.26.17",
31
31
  "@kamilmielnik/trie": "^3.0.0",
32
32
  "@reduxjs/toolkit": "^2.2.5",
33
- "@scrabble-solver/configs": "^2.13.9",
34
- "@scrabble-solver/constants": "^2.13.9",
35
- "@scrabble-solver/dictionaries": "^2.13.9",
36
- "@scrabble-solver/logger": "^2.13.9",
37
- "@scrabble-solver/solver": "^2.13.9",
38
- "@scrabble-solver/types": "^2.13.9",
39
- "@scrabble-solver/word-definitions": "^2.13.9",
33
+ "@scrabble-solver/configs": "^2.13.10",
34
+ "@scrabble-solver/constants": "^2.13.10",
35
+ "@scrabble-solver/dictionaries": "^2.13.10",
36
+ "@scrabble-solver/logger": "^2.13.10",
37
+ "@scrabble-solver/solver": "^2.13.10",
38
+ "@scrabble-solver/types": "^2.13.10",
39
+ "@scrabble-solver/word-definitions": "^2.13.10",
40
40
  "classnames": "^2.5.1",
41
41
  "env-cmd": "^10.1.0",
42
42
  "include-media": "^2.0.0",
@@ -52,6 +52,7 @@
52
52
  "react-window": "^1.8.10",
53
53
  "redux-saga": "^1.3.0",
54
54
  "store2": "^2.14.3",
55
+ "use-debounce": "^10.0.1",
55
56
  "workbox-expiration": "^7.1.0",
56
57
  "workbox-precaching": "^7.1.0",
57
58
  "workbox-routing": "^7.1.0",
@@ -72,5 +73,5 @@
72
73
  "@types/redux-saga": "^0.10.5",
73
74
  "sass": "^1.77.5"
74
75
  },
75
- "gitHead": "d09676296f8fafadb7da0cf1e11fb240aaf309ee"
76
+ "gitHead": "ebc7207c650ab1fdbb0bca3df53a445eaa6de268"
76
77
  }
@@ -1,6 +1,7 @@
1
1
  import classNames from 'classnames';
2
2
  import { FunctionComponent, useEffect, useMemo, useState } from 'react';
3
3
  import { FixedSizeList } from 'react-window';
4
+ import { useDebounce } from 'use-debounce';
4
5
 
5
6
  import { useAppLayout, useLatest } from 'hooks';
6
7
  import { LOCALE_FEATURES } from 'i18n';
@@ -32,6 +33,8 @@ interface Props {
32
33
  highlightedIndex?: number;
33
34
  }
34
35
 
36
+ const IS_LOADING_DEBOUNCE = 100;
37
+
35
38
  const Results: FunctionComponent<Props> = ({ callbacks, className, highlightedIndex }) => {
36
39
  const translate = useTranslate();
37
40
  const { resultsHeight, resultsWidth } = useAppLayout();
@@ -39,6 +42,7 @@ const Results: FunctionComponent<Props> = ({ callbacks, className, highlightedIn
39
42
  const { direction } = LOCALE_FEATURES[locale];
40
43
  const results = useTypedSelector(selectResults);
41
44
  const isLoading = useTypedSelector(selectIsLoading);
45
+ const [isLoadingDebounced] = useDebounce(isLoading, IS_LOADING_DEBOUNCE);
42
46
  const isOutdated = useTypedSelector(selectAreResultsOutdated);
43
47
  const error = useTypedSelector(selectSolveError);
44
48
  const itemData = useMemo(() => ({ ...callbacks, highlightedIndex, results }), [callbacks, highlightedIndex, results]);
@@ -128,7 +132,7 @@ const Results: FunctionComponent<Props> = ({ callbacks, className, highlightedIn
128
132
 
129
133
  {showInput && <ResultsInput className={styles.input} />}
130
134
 
131
- {isLoading && <Loading />}
135
+ {isLoadingDebounced && <Loading />}
132
136
  </div>
133
137
  );
134
138
  };
@@ -1,15 +1,10 @@
1
1
  import { Result } from '@scrabble-solver/types';
2
2
 
3
- import { CellFilterEntry } from 'types';
3
+ import { CellFilterEntry, GroupedResults } from 'types';
4
4
 
5
5
  import createRegExp from './createRegExp';
6
6
  import resultMatchesCellFilter from './resultMatchesCellFilter';
7
7
 
8
- interface GroupedResults {
9
- matching: Result[];
10
- other: Result[];
11
- }
12
-
13
8
  const groupResults = (
14
9
  results: Result[] | undefined,
15
10
  query: string,
@@ -21,7 +16,7 @@ const groupResults = (
21
16
 
22
17
  const regExp = createRegExp(query);
23
18
 
24
- return results.reduce<GroupedResults>(
19
+ const { matching, other } = results.reduce<GroupedResults>(
25
20
  (groupedResults, result) => {
26
21
  const matchesQuery = () => regExp.test(result.word);
27
22
 
@@ -35,6 +30,8 @@ const groupResults = (
35
30
  },
36
31
  { matching: [], other: [] },
37
32
  );
33
+
34
+ return { matching, other };
38
35
  };
39
36
 
40
37
  export default groupResults;
package/src/lib/index.ts CHANGED
@@ -34,6 +34,7 @@ export { default as noop } from './noop';
34
34
  export { default as numberComparator } from './numberComparator';
35
35
  export { default as resultMatchesCellFilter } from './resultMatchesCellFilter';
36
36
  export { default as reverseComparator } from './reverseComparator';
37
+ export { default as sortGroupedResults } from './sortGroupedResults';
37
38
  export { default as sortResults } from './sortResults';
38
39
  export { default as unorderedArraysEqual } from './unorderedArraysEqual';
39
40
  export { default as zipCharactersAndTiles } from './zipCharactersAndTiles';
@@ -0,0 +1,22 @@
1
+ import { Locale } from '@scrabble-solver/types';
2
+
3
+ import { GroupedResults, Sort } from 'types';
4
+
5
+ import sortResults from './sortResults';
6
+
7
+ const sortGroupedResults = (
8
+ results: GroupedResults | undefined,
9
+ sort: Sort,
10
+ locale: Locale,
11
+ ): GroupedResults | undefined => {
12
+ if (typeof results === 'undefined') {
13
+ return results;
14
+ }
15
+
16
+ return {
17
+ matching: sortResults(results.matching, sort, locale) ?? [],
18
+ other: sortResults(results.other, sort, locale) ?? [],
19
+ };
20
+ };
21
+
22
+ export default sortGroupedResults;
@@ -13,7 +13,7 @@ import {
13
13
  getRemainingTilesGroups,
14
14
  groupResults,
15
15
  resultMatchesCellFilter,
16
- sortResults,
16
+ sortGroupedResults,
17
17
  unorderedArraysEqual,
18
18
  } from 'lib';
19
19
  import { Point, Translations } from 'types';
@@ -94,14 +94,17 @@ export const selectResultsQuery = createSelector([selectResultsRoot], (results)
94
94
 
95
95
  export const selectResultsSort = createSelector([selectResultsRoot], (results) => results.sort);
96
96
 
97
- export const selectSortedResults = createSelector([selectResultsRaw, selectResultsSort, selectLocale], sortResults);
98
-
99
97
  export const selectGroupedResults = createSelector(
100
- [selectSortedResults, selectResultsQuery, selectFilteredCells],
98
+ [selectResultsRaw, selectResultsQuery, selectFilteredCells],
101
99
  groupResults,
102
100
  );
103
101
 
104
- export const selectResults = createSelector([selectGroupedResults], (groupedResults) => {
102
+ export const selectGroupedSortedResults = createSelector(
103
+ [selectGroupedResults, selectResultsSort, selectLocale],
104
+ sortGroupedResults,
105
+ );
106
+
107
+ export const selectResults = createSelector([selectGroupedSortedResults], (groupedResults) => {
105
108
  return groupedResults ? [...groupedResults.matching, ...groupedResults.other] : groupedResults;
106
109
  });
107
110
 
@@ -1,3 +1,5 @@
1
+ import { Result } from '@scrabble-solver/types';
2
+
1
3
  export type Comparator<T> = (a: T, B: T) => number;
2
4
 
3
5
  export type AutoGroupTiles = 'left' | 'right' | null;
@@ -55,6 +57,12 @@ export enum ResultColumn {
55
57
  Word = 'word',
56
58
  WordsCount = 'words-count',
57
59
  }
60
+
61
+ export interface GroupedResults {
62
+ matching: Result[];
63
+ other: Result[];
64
+ }
65
+
58
66
  export type TranslationKey =
59
67
  | 'cell.enter-word'
60
68
  | 'cell.filter-cell.exclude'