@fgv/ts-sudoku-lib 5.0.1-9 → 5.0.2-0

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 (55) hide show
  1. package/dist/index.browser.js +37 -0
  2. package/dist/index.js +30 -0
  3. package/dist/packlets/collections/collections.js +136 -0
  4. package/dist/packlets/collections/data/puzzles.json +56 -0
  5. package/dist/packlets/collections/index.js +25 -0
  6. package/dist/packlets/common/cage.js +83 -0
  7. package/dist/packlets/common/cell.js +88 -0
  8. package/dist/packlets/common/common.js +70 -0
  9. package/dist/packlets/common/converters.js +65 -0
  10. package/dist/packlets/common/ids.js +152 -0
  11. package/dist/packlets/common/index.js +36 -0
  12. package/dist/packlets/common/logging.js +32 -0
  13. package/dist/packlets/common/public.js +25 -0
  14. package/dist/packlets/common/puzzle.js +411 -0
  15. package/dist/packlets/common/puzzleDefinitions.js +247 -0
  16. package/dist/packlets/common/puzzleSession.js +369 -0
  17. package/dist/packlets/common/puzzleState.js +99 -0
  18. package/dist/packlets/files/converters.js +67 -0
  19. package/dist/packlets/files/fileTreeHelpers.js +37 -0
  20. package/dist/packlets/files/filesystem.js +37 -0
  21. package/dist/packlets/files/index.browser.js +32 -0
  22. package/dist/packlets/files/index.js +30 -0
  23. package/dist/packlets/files/model.js +25 -0
  24. package/dist/packlets/hints/baseHintProvider.js +199 -0
  25. package/dist/packlets/hints/explanations.js +270 -0
  26. package/dist/packlets/hints/hiddenSingles.js +233 -0
  27. package/dist/packlets/hints/hintRegistry.js +222 -0
  28. package/dist/packlets/hints/hints.js +311 -0
  29. package/dist/packlets/hints/index.js +39 -0
  30. package/dist/packlets/hints/interfaces.js +25 -0
  31. package/dist/packlets/hints/nakedSingles.js +198 -0
  32. package/dist/packlets/hints/puzzleSessionHints.js +495 -0
  33. package/dist/packlets/hints/types.js +43 -0
  34. package/dist/packlets/puzzles/anyPuzzle.js +47 -0
  35. package/dist/packlets/puzzles/index.js +31 -0
  36. package/dist/packlets/puzzles/internal/combinationCache.js +75 -0
  37. package/dist/packlets/puzzles/internal/combinationGenerator.js +142 -0
  38. package/dist/packlets/puzzles/internal/possibilityAnalyzer.js +121 -0
  39. package/dist/packlets/puzzles/killerCombinations.js +222 -0
  40. package/dist/packlets/puzzles/killerCombinationsTypes.js +25 -0
  41. package/dist/packlets/puzzles/killerSudokuPuzzle.js +136 -0
  42. package/dist/packlets/puzzles/sudokuPuzzle.js +43 -0
  43. package/dist/packlets/puzzles/sudokuXPuzzle.js +65 -0
  44. package/dist/test/unit/helpers/puzzleBuilders.js +149 -0
  45. package/dist/ts-sudoku-lib.d.ts +12 -7
  46. package/dist/tsdoc-metadata.json +1 -1
  47. package/lib/index.browser.d.ts +7 -0
  48. package/lib/index.browser.js +78 -0
  49. package/lib/packlets/files/fileTreeHelpers.d.ts +13 -0
  50. package/lib/packlets/files/fileTreeHelpers.js +40 -0
  51. package/lib/packlets/files/index.browser.d.ts +5 -0
  52. package/lib/packlets/files/index.browser.js +70 -0
  53. package/lib/packlets/files/index.d.ts +3 -2
  54. package/lib/packlets/files/index.js +7 -4
  55. package/package.json +23 -5
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.53.3"
8
+ "packageVersion": "7.54.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,7 @@
1
+ import * as Files from './packlets/files/index.browser';
2
+ import * as Hints from './packlets/hints';
3
+ import * as Puzzles from './packlets/puzzles';
4
+ export * from './packlets/collections';
5
+ export * from './packlets/common';
6
+ export { Files, Hints, Puzzles };
7
+ //# sourceMappingURL=index.browser.d.ts.map
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ /*
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2025 Erik Fortune
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ var desc = Object.getOwnPropertyDescriptor(m, k);
28
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
29
+ desc = { enumerable: true, get: function() { return m[k]; } };
30
+ }
31
+ Object.defineProperty(o, k2, desc);
32
+ }) : (function(o, m, k, k2) {
33
+ if (k2 === undefined) k2 = k;
34
+ o[k2] = m[k];
35
+ }));
36
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
37
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
38
+ }) : function(o, v) {
39
+ o["default"] = v;
40
+ });
41
+ var __importStar = (this && this.__importStar) || (function () {
42
+ var ownKeys = function(o) {
43
+ ownKeys = Object.getOwnPropertyNames || function (o) {
44
+ var ar = [];
45
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
46
+ return ar;
47
+ };
48
+ return ownKeys(o);
49
+ };
50
+ return function (mod) {
51
+ if (mod && mod.__esModule) return mod;
52
+ var result = {};
53
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
54
+ __setModuleDefault(result, mod);
55
+ return result;
56
+ };
57
+ })();
58
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
59
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.Puzzles = exports.Hints = exports.Files = void 0;
63
+ // Browser entry point - excludes Node.js filesystem dependencies
64
+ // eslint-disable-next-line @rushstack/packlets/mechanics -- browser-specific entry point excludes Node.js fs dependencies
65
+ const Files = __importStar(require("./packlets/files/index.browser"));
66
+ exports.Files = Files;
67
+ const Hints = __importStar(require("./packlets/hints"));
68
+ exports.Hints = Hints;
69
+ const Puzzles = __importStar(require("./packlets/puzzles"));
70
+ exports.Puzzles = Puzzles;
71
+ __exportStar(require("./packlets/collections"), exports);
72
+ __exportStar(require("./packlets/common"), exports);
73
+ // Excluded from browser:
74
+ // - Files.loadJsonPuzzlesFileSync (requires Node.js fs via JsonFile.convertJsonFileSync)
75
+ //
76
+ // Included in browser (via FileTree):
77
+ // - Files.loadJsonPuzzlesFromTree (browser-compatible via FileTree)
78
+ //# sourceMappingURL=index.browser.js.map
@@ -0,0 +1,13 @@
1
+ import { Result } from '@fgv/ts-utils';
2
+ import { IPuzzlesFile } from './model';
3
+ import { FileTree } from '@fgv/ts-json-base';
4
+ /**
5
+ * Loads a puzzles file from a {@link FileTree.FileTree | FileTree}.
6
+ * @param fileTree - FileTree containing the file
7
+ * @param filePath - Path within the FileTree to the puzzles file
8
+ * @returns `Success` with the resulting file, or `Failure` with details if an
9
+ * error occurs.
10
+ * @public
11
+ */
12
+ export declare function loadJsonPuzzlesFromTree(fileTree: FileTree.FileTree, filePath: string): Result<IPuzzlesFile>;
13
+ //# sourceMappingURL=fileTreeHelpers.d.ts.map
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2025 Erik Fortune
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.loadJsonPuzzlesFromTree = loadJsonPuzzlesFromTree;
27
+ const converters_1 = require("./converters");
28
+ const ts_json_base_1 = require("@fgv/ts-json-base");
29
+ /**
30
+ * Loads a puzzles file from a {@link FileTree.FileTree | FileTree}.
31
+ * @param fileTree - FileTree containing the file
32
+ * @param filePath - Path within the FileTree to the puzzles file
33
+ * @returns `Success` with the resulting file, or `Failure` with details if an
34
+ * error occurs.
35
+ * @public
36
+ */
37
+ function loadJsonPuzzlesFromTree(fileTree, filePath) {
38
+ return ts_json_base_1.JsonFile.DefaultJsonTreeHelper.convertJsonFromTree(fileTree, filePath, converters_1.puzzlesFile);
39
+ }
40
+ //# sourceMappingURL=fileTreeHelpers.js.map
@@ -0,0 +1,5 @@
1
+ import * as Converters from './converters';
2
+ import * as Model from './model';
3
+ export { Converters, Model };
4
+ export { loadJsonPuzzlesFromTree } from './fileTreeHelpers';
5
+ //# sourceMappingURL=index.browser.d.ts.map
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /*
3
+ * MIT License
4
+ *
5
+ * Copyright (c) 2025 Erik Fortune
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ var desc = Object.getOwnPropertyDescriptor(m, k);
28
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
29
+ desc = { enumerable: true, get: function() { return m[k]; } };
30
+ }
31
+ Object.defineProperty(o, k2, desc);
32
+ }) : (function(o, m, k, k2) {
33
+ if (k2 === undefined) k2 = k;
34
+ o[k2] = m[k];
35
+ }));
36
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
37
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
38
+ }) : function(o, v) {
39
+ o["default"] = v;
40
+ });
41
+ var __importStar = (this && this.__importStar) || (function () {
42
+ var ownKeys = function(o) {
43
+ ownKeys = Object.getOwnPropertyNames || function (o) {
44
+ var ar = [];
45
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
46
+ return ar;
47
+ };
48
+ return ownKeys(o);
49
+ };
50
+ return function (mod) {
51
+ if (mod && mod.__esModule) return mod;
52
+ var result = {};
53
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
54
+ __setModuleDefault(result, mod);
55
+ return result;
56
+ };
57
+ })();
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.loadJsonPuzzlesFromTree = exports.Model = exports.Converters = void 0;
60
+ // Browser-safe files exports - includes FileTree functions, excludes Node.js filesystem functions
61
+ const Converters = __importStar(require("./converters"));
62
+ exports.Converters = Converters;
63
+ const Model = __importStar(require("./model"));
64
+ exports.Model = Model;
65
+ // Re-export browser-compatible FileTree helpers
66
+ var fileTreeHelpers_1 = require("./fileTreeHelpers");
67
+ Object.defineProperty(exports, "loadJsonPuzzlesFromTree", { enumerable: true, get: function () { return fileTreeHelpers_1.loadJsonPuzzlesFromTree; } });
68
+ // Excluded from browser:
69
+ // - loadJsonPuzzlesFileSync (requires Node.js fs via JsonFile.convertJsonFileSync)
70
+ //# sourceMappingURL=index.browser.js.map
@@ -1,5 +1,6 @@
1
1
  import * as Converters from './converters';
2
2
  import * as Model from './model';
3
- import * as FileSystem from './filesystem';
4
- export { Converters, Model, FileSystem };
3
+ export { Converters, Model };
4
+ export { loadJsonPuzzlesFileSync } from './filesystem';
5
+ export { loadJsonPuzzlesFromTree } from './fileTreeHelpers';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * MIT License
4
4
  *
5
- * Copyright (c) 2023 Erik Fortune
5
+ * Copyright (c) 2025 Erik Fortune
6
6
  *
7
7
  * Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  * of this software and associated documentation files (the "Software"), to deal
@@ -56,11 +56,14 @@ var __importStar = (this && this.__importStar) || (function () {
56
56
  };
57
57
  })();
58
58
  Object.defineProperty(exports, "__esModule", { value: true });
59
- exports.FileSystem = exports.Model = exports.Converters = void 0;
59
+ exports.loadJsonPuzzlesFromTree = exports.loadJsonPuzzlesFileSync = exports.Model = exports.Converters = void 0;
60
60
  const Converters = __importStar(require("./converters"));
61
61
  exports.Converters = Converters;
62
62
  const Model = __importStar(require("./model"));
63
63
  exports.Model = Model;
64
- const FileSystem = __importStar(require("./filesystem"));
65
- exports.FileSystem = FileSystem;
64
+ // Export both filesystem and FileTree helpers
65
+ var filesystem_1 = require("./filesystem");
66
+ Object.defineProperty(exports, "loadJsonPuzzlesFileSync", { enumerable: true, get: function () { return filesystem_1.loadJsonPuzzlesFileSync; } });
67
+ var fileTreeHelpers_1 = require("./fileTreeHelpers");
68
+ Object.defineProperty(exports, "loadJsonPuzzlesFromTree", { enumerable: true, get: function () { return fileTreeHelpers_1.loadJsonPuzzlesFromTree; } });
66
69
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-sudoku-lib",
3
- "version": "5.0.1-9",
3
+ "version": "5.0.2-0",
4
4
  "description": "Sudoku rules library",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-sudoku-lib.d.ts",
@@ -43,12 +43,30 @@
43
43
  "@rushstack/eslint-config": "4.5.3",
44
44
  "@rushstack/heft-jest-plugin": "1.1.3",
45
45
  "eslint-plugin-tsdoc": "~0.4.0",
46
- "@fgv/ts-utils": "5.0.1-9",
47
- "@fgv/ts-json-base": "5.0.1-9",
48
- "@fgv/ts-utils-jest": "5.0.1-9"
46
+ "@fgv/heft-dual-rig": "0.1.0",
47
+ "@fgv/ts-utils-jest": "5.0.2-0",
48
+ "@fgv/ts-utils": "5.0.2-0",
49
+ "@fgv/ts-json-base": "5.0.2-0"
49
50
  },
50
51
  "peerDependencies": {
51
- "@fgv/ts-utils": "5.0.1-9"
52
+ "@fgv/ts-utils": "5.0.2-0"
53
+ },
54
+ "exports": {
55
+ ".": {
56
+ "node": {
57
+ "import": "./lib/index.js",
58
+ "require": "./lib/index.js"
59
+ },
60
+ "default": {
61
+ "import": "./lib/index.browser.js",
62
+ "require": "./lib/index.browser.js"
63
+ },
64
+ "types": "dist/ts-sudoku-lib.d.ts"
65
+ }
66
+ },
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "https://github.com/ErikFortune/fgv.git"
52
70
  },
53
71
  "scripts": {
54
72
  "build": "heft build --clean",