@logic-pad/core 0.24.0 → 0.25.1
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/assets/logic-core.global.d.ts +22 -0
- package/dist/benchmark/helper.d.ts +21 -0
- package/dist/benchmark/helper.js +34 -0
- package/dist/benchmark/prepareBench.js +140 -0
- package/dist/benchmark/runBench.js +206 -0
- package/dist/{data → src/data}/dataHelper.js +4 -18
- package/dist/{data → src/data}/grid.js +15 -68
- package/dist/{data → src/data}/gridZones.js +1 -6
- package/dist/{data → src/data}/rules/banPatternRule.js +19 -50
- package/dist/{data → src/data}/rules/cellCountPerZoneRule.js +2 -6
- package/dist/{data → src/data}/rules/cellCountRule.js +62 -96
- package/dist/{data → src/data}/rules/completePatternRule.js +6 -22
- package/dist/{data → src/data}/rules/connectAllRule.js +20 -50
- package/dist/{data → src/data}/rules/connectZonesRule.js +28 -58
- package/dist/{data → src/data}/rules/containsShapeRule.js +29 -65
- package/dist/{data → src/data}/rules/customRule.js +28 -57
- package/dist/{data → src/data}/rules/differentCountPerZoneRule.js +33 -68
- package/dist/{data → src/data}/rules/exactCountPerZoneRule.js +43 -82
- package/dist/{data → src/data}/rules/foresightRule.js +50 -87
- package/dist/{data → src/data}/rules/lyingSymbolRule.js +37 -88
- package/dist/{data → src/data}/rules/musicControlLine.js +69 -131
- package/dist/{data → src/data}/rules/musicGridRule.js +43 -76
- package/dist/{data → src/data}/rules/mysteryRule.js +29 -58
- package/dist/src/data/rules/noLoopsRule.d.ts +29 -0
- package/dist/src/data/rules/noLoopsRule.js +111 -0
- package/dist/{data → src/data}/rules/offByXRule.js +49 -74
- package/dist/{data → src/data}/rules/perfectionRule.js +8 -28
- package/dist/{data → src/data}/rules/regionAreaRule.js +47 -86
- package/dist/{data → src/data}/rules/regionShapeRule.js +2 -6
- package/dist/{data → src/data}/rules/rules.gen.d.ts +1 -0
- package/dist/{data → src/data}/rules/rules.gen.js +1 -0
- package/dist/{data → src/data}/rules/sameCountPerZoneRule.js +33 -68
- package/dist/{data → src/data}/rules/sameShapeRule.js +18 -44
- package/dist/{data → src/data}/rules/symbolsPerRegionRule.js +52 -90
- package/dist/{data → src/data}/rules/undercluedRule.js +11 -27
- package/dist/{data → src/data}/rules/uniqueShapeRule.js +18 -44
- package/dist/{data → src/data}/rules/wrapAroundRule.js +99 -138
- package/dist/{data → src/data}/serializer/serializer_checksum.js +1 -9
- package/dist/{data → src/data}/serializer/serializer_v0.js +1 -9
- package/dist/{data → src/data}/solver/auto/autoSolver.js +11 -40
- package/dist/{data → src/data}/solver/backtrack/backtrackSolver.js +15 -39
- package/dist/{data → src/data}/solver/backtrack/backtrackWorker.js +1 -1
- package/dist/{data → src/data}/solver/backtrack/data.js +16 -48
- package/dist/{data → src/data}/solver/backtrack/rules/banPattern.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/rules/cellCount.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/rules/connectAll.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/rules/regionArea.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/rules/regionShape.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/rules/sameShape.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/rules/symbolsPerRegion.js +2 -12
- package/dist/{data → src/data}/solver/backtrack/rules/uniqueShape.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/symbols/areaNumber.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/symbols/dart.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/symbols/directionLinker.js +3 -13
- package/dist/{data → src/data}/solver/backtrack/symbols/focus.js +3 -13
- package/dist/{data → src/data}/solver/backtrack/symbols/galaxy.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/symbols/letter.js +2 -12
- package/dist/{data → src/data}/solver/backtrack/symbols/lotus.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/symbols/minesweeper.js +3 -13
- package/dist/{data → src/data}/solver/backtrack/symbols/myopia.js +1 -6
- package/dist/{data → src/data}/solver/backtrack/symbols/viewpoint.js +1 -6
- package/dist/{data → src/data}/solver/cspuz/cspuzSolver.js +22 -46
- package/dist/{data → src/data}/solver/eventIteratingSolver.js +9 -12
- package/dist/{data → src/data}/solver/solver.js +1 -8
- package/dist/src/data/solver/universal/universalSolver.js +20 -0
- package/dist/src/data/solver/universal/universalWorker.d.ts +1 -0
- package/dist/{data → src/data}/solver/z3/modules/areaNumberModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/modules/cellCountModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/modules/connectAllModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/modules/dartModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/modules/letterModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/modules/myopiaModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/modules/regionAreaModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/modules/viewpointModule.js +1 -9
- package/dist/{data → src/data}/solver/z3/z3Solver.js +4 -27
- package/dist/{data → src/data}/solver/z3/z3SolverContext.js +3 -12
- package/dist/{data → src/data}/symbols/areaNumberSymbol.js +28 -44
- package/dist/{data → src/data}/symbols/customIconSymbol.js +40 -64
- package/dist/{data → src/data}/symbols/customSymbol.js +4 -12
- package/dist/{data → src/data}/symbols/customTextSymbol.js +40 -64
- package/dist/{data → src/data}/symbols/dartSymbol.js +39 -59
- package/dist/{data → src/data}/symbols/directionLinkerSymbol.js +34 -63
- package/dist/{data → src/data}/symbols/everyLetterSymbol.js +37 -65
- package/dist/{data → src/data}/symbols/focusSymbol.js +49 -69
- package/dist/{data → src/data}/symbols/galaxySymbol.js +12 -31
- package/dist/{data → src/data}/symbols/hiddenSymbol.js +34 -62
- package/dist/{data → src/data}/symbols/houseSymbol.js +39 -67
- package/dist/{data → src/data}/symbols/letterSymbol.js +40 -68
- package/dist/{data → src/data}/symbols/lotusSymbol.js +58 -81
- package/dist/{data → src/data}/symbols/minesweeperSymbol.js +30 -46
- package/dist/{data → src/data}/symbols/myopiaSymbol.js +45 -69
- package/dist/{data → src/data}/symbols/numberSymbol.js +6 -18
- package/dist/{data → src/data}/symbols/symbol.js +4 -12
- package/dist/{data → src/data}/symbols/viewpointSymbol.js +26 -42
- package/dist/{data → src/data}/tile.js +6 -18
- package/dist/src/data/validateAsync.js +71 -0
- package/dist/src/data/validateAsyncWorker.d.ts +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +2 -1
- package/dist/{index.js → src/index.js} +2 -1
- package/package.json +13 -10
- package/dist/data/solver/universal/universalSolver.js +0 -38
- package/dist/data/validateAsync.js +0 -128
- /package/dist/{data/solver/backtrack/backtrackWorker.d.ts → benchmark/prepareBench.d.ts} +0 -0
- /package/dist/{data/solver/cspuz/cspuzWorker.d.ts → benchmark/runBench.d.ts} +0 -0
- /package/dist/{data → src/data}/config.d.ts +0 -0
- /package/dist/{data → src/data}/config.js +0 -0
- /package/dist/{data → src/data}/configurable.d.ts +0 -0
- /package/dist/{data → src/data}/configurable.js +0 -0
- /package/dist/{data → src/data}/dataHelper.d.ts +0 -0
- /package/dist/{data → src/data}/events/eventHelper.d.ts +0 -0
- /package/dist/{data → src/data}/events/eventHelper.js +0 -0
- /package/dist/{data → src/data}/events/onFinalValidation.d.ts +0 -0
- /package/dist/{data → src/data}/events/onFinalValidation.js +0 -0
- /package/dist/{data → src/data}/events/onGetTile.d.ts +0 -0
- /package/dist/{data → src/data}/events/onGetTile.js +0 -0
- /package/dist/{data → src/data}/events/onGridChange.d.ts +0 -0
- /package/dist/{data → src/data}/events/onGridChange.js +0 -0
- /package/dist/{data → src/data}/events/onGridResize.d.ts +0 -0
- /package/dist/{data → src/data}/events/onGridResize.js +0 -0
- /package/dist/{data → src/data}/events/onSetGrid.d.ts +0 -0
- /package/dist/{data → src/data}/events/onSetGrid.js +0 -0
- /package/dist/{data → src/data}/events/onSymbolDisplay.d.ts +0 -0
- /package/dist/{data → src/data}/events/onSymbolDisplay.js +0 -0
- /package/dist/{data → src/data}/events/onSymbolMerge.d.ts +0 -0
- /package/dist/{data → src/data}/events/onSymbolMerge.js +0 -0
- /package/dist/{data → src/data}/events/onSymbolValidation.d.ts +0 -0
- /package/dist/{data → src/data}/events/onSymbolValidation.js +0 -0
- /package/dist/{data → src/data}/grid.d.ts +0 -0
- /package/dist/{data → src/data}/gridConnections.d.ts +0 -0
- /package/dist/{data → src/data}/gridConnections.js +0 -0
- /package/dist/{data → src/data}/gridZones.d.ts +0 -0
- /package/dist/{data → src/data}/instruction.d.ts +0 -0
- /package/dist/{data → src/data}/instruction.js +0 -0
- /package/dist/{data → src/data}/primitives.d.ts +0 -0
- /package/dist/{data → src/data}/primitives.js +0 -0
- /package/dist/{data → src/data}/puzzle.d.ts +0 -0
- /package/dist/{data → src/data}/puzzle.js +0 -0
- /package/dist/{data → src/data}/rules/banPatternRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/cellCountPerZoneRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/cellCountRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/completePatternRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/connectAllRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/connectZonesRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/containsShapeRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/customRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/differentCountPerZoneRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/exactCountPerZoneRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/foresightRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/index.d.ts +0 -0
- /package/dist/{data → src/data}/rules/index.js +0 -0
- /package/dist/{data → src/data}/rules/lyingSymbolRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/musicControlLine.d.ts +0 -0
- /package/dist/{data → src/data}/rules/musicGridRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/mysteryRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/offByXRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/perfectionRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/regionAreaRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/regionShapeRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/rule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/rule.js +0 -0
- /package/dist/{data → src/data}/rules/sameCountPerZoneRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/sameShapeRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/symbolsPerRegionRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/undercluedRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/uniqueShapeRule.d.ts +0 -0
- /package/dist/{data → src/data}/rules/wrapAroundRule.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/allSerializers.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/allSerializers.js +0 -0
- /package/dist/{data → src/data}/serializer/compressor/allCompressors.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/compressor/allCompressors.js +0 -0
- /package/dist/{data → src/data}/serializer/compressor/checksumCompressor.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/compressor/checksumCompressor.js +0 -0
- /package/dist/{data → src/data}/serializer/compressor/compressorBase.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/compressor/compressorBase.js +0 -0
- /package/dist/{data → src/data}/serializer/compressor/deflateCompressor.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/compressor/deflateCompressor.js +0 -0
- /package/dist/{data → src/data}/serializer/compressor/gzipCompressor.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/compressor/gzipCompressor.js +0 -0
- /package/dist/{data → src/data}/serializer/compressor/streamCompressor.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/compressor/streamCompressor.js +0 -0
- /package/dist/{data → src/data}/serializer/serializerBase.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/serializerBase.js +0 -0
- /package/dist/{data → src/data}/serializer/serializer_checksum.d.ts +0 -0
- /package/dist/{data → src/data}/serializer/serializer_v0.d.ts +0 -0
- /package/dist/{data → src/data}/shapes.d.ts +0 -0
- /package/dist/{data → src/data}/shapes.js +0 -0
- /package/dist/{data → src/data}/solver/allSolvers.d.ts +0 -0
- /package/dist/{data → src/data}/solver/allSolvers.js +0 -0
- /package/dist/{data → src/data}/solver/auto/autoSolver.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/backtrackSolver.d.ts +0 -0
- /package/dist/{data/solver/universal/universalWorker.d.ts → src/data/solver/backtrack/backtrackWorker.d.ts} +0 -0
- /package/dist/{data → src/data}/solver/backtrack/data.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/banPattern.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/cellCount.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/connectAll.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/regionArea.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/regionShape.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/sameShape.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/symbolsPerRegion.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/rules/uniqueShape.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/areaNumber.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/dart.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/directionLinker.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/focus.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/galaxy.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/letter.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/lotus.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/minesweeper.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/myopia.d.ts +0 -0
- /package/dist/{data → src/data}/solver/backtrack/symbols/viewpoint.d.ts +0 -0
- /package/dist/{data → src/data}/solver/cspuz/cspuzSolver.d.ts +0 -0
- /package/dist/{data/validateAsyncWorker.d.ts → src/data/solver/cspuz/cspuzWorker.d.ts} +0 -0
- /package/dist/{data → src/data}/solver/cspuz/cspuzWorker.js +0 -0
- /package/dist/{data → src/data}/solver/cspuz/jsonify.d.ts +0 -0
- /package/dist/{data → src/data}/solver/cspuz/jsonify.js +0 -0
- /package/dist/{data → src/data}/solver/eventIteratingSolver.d.ts +0 -0
- /package/dist/{data → src/data}/solver/solver.d.ts +0 -0
- /package/dist/{data → src/data}/solver/universal/universalSolver.d.ts +0 -0
- /package/dist/{data → src/data}/solver/universal/universalWorker.js +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/areaNumberModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/cellCountModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/connectAllModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/dartModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/index.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/index.js +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/letterModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/modules.gen.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/modules.gen.js +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/myopiaModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/regionAreaModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/viewpointModule.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/z3Module.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/modules/z3Module.js +0 -0
- /package/dist/{data → src/data}/solver/z3/utils.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/utils.js +0 -0
- /package/dist/{data → src/data}/solver/z3/z3Solver.d.ts +0 -0
- /package/dist/{data → src/data}/solver/z3/z3SolverContext.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/areaNumberSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/customIconSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/customSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/customTextSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/dartSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/directionLinkerSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/everyLetterSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/focusSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/galaxySymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/hiddenSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/houseSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/index.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/index.js +0 -0
- /package/dist/{data → src/data}/symbols/letterSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/lotusSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/minesweeperSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/myopiaSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/numberSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/symbol.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/symbols.gen.d.ts +0 -0
- /package/dist/{data → src/data}/symbols/symbols.gen.js +0 -0
- /package/dist/{data → src/data}/symbols/viewpointSymbol.d.ts +0 -0
- /package/dist/{data → src/data}/tile.d.ts +0 -0
- /package/dist/{data → src/data}/tileConnections.d.ts +0 -0
- /package/dist/{data → src/data}/tileConnections.js +0 -0
- /package/dist/{data → src/data}/validate.d.ts +0 -0
- /package/dist/{data → src/data}/validate.js +0 -0
- /package/dist/{data → src/data}/validateAsync.d.ts +0 -0
- /package/dist/{data → src/data}/validateAsyncWorker.js +0 -0
- /package/dist/{polyfill → src/polyfill}/streamPolyfill.d.ts +0 -0
- /package/dist/{polyfill → src/polyfill}/streamPolyfill.js +0 -0
|
@@ -3,7 +3,32 @@ import GridData from '../grid.js';
|
|
|
3
3
|
import { array, move } from '../dataHelper.js';
|
|
4
4
|
import { Color, DIRECTIONS } from '../primitives.js';
|
|
5
5
|
import NumberSymbol from './numberSymbol.js';
|
|
6
|
-
class ViewpointSymbol extends NumberSymbol {
|
|
6
|
+
export default class ViewpointSymbol extends NumberSymbol {
|
|
7
|
+
title = 'Viewpoint Number';
|
|
8
|
+
static CONFIGS = Object.freeze([
|
|
9
|
+
{
|
|
10
|
+
type: ConfigType.Number,
|
|
11
|
+
default: 0,
|
|
12
|
+
field: 'x',
|
|
13
|
+
description: 'X',
|
|
14
|
+
configurable: false,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: ConfigType.Number,
|
|
18
|
+
default: 0,
|
|
19
|
+
field: 'y',
|
|
20
|
+
description: 'Y',
|
|
21
|
+
configurable: false,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: ConfigType.Number,
|
|
25
|
+
default: 1,
|
|
26
|
+
field: 'number',
|
|
27
|
+
description: 'Number',
|
|
28
|
+
configurable: true,
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
static EXAMPLE_GRID = Object.freeze(GridData.create(['bbbbb', 'wwwwb', 'bwwbb', 'bbwww']).addSymbol(new ViewpointSymbol(1, 1, 5)));
|
|
7
32
|
/**
|
|
8
33
|
* **Viewpoint Numbers count visible cells in the four directions**
|
|
9
34
|
* @param x - The x-coordinate of the symbol.
|
|
@@ -12,12 +37,6 @@ class ViewpointSymbol extends NumberSymbol {
|
|
|
12
37
|
*/
|
|
13
38
|
constructor(x, y, number) {
|
|
14
39
|
super(x, y, number);
|
|
15
|
-
Object.defineProperty(this, "title", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: 'Viewpoint Number'
|
|
20
|
-
});
|
|
21
40
|
}
|
|
22
41
|
get id() {
|
|
23
42
|
return `viewpoint`;
|
|
@@ -73,39 +92,4 @@ class ViewpointSymbol extends NumberSymbol {
|
|
|
73
92
|
return this.copyWith({ number });
|
|
74
93
|
}
|
|
75
94
|
}
|
|
76
|
-
Object.defineProperty(ViewpointSymbol, "CONFIGS", {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
configurable: true,
|
|
79
|
-
writable: true,
|
|
80
|
-
value: Object.freeze([
|
|
81
|
-
{
|
|
82
|
-
type: ConfigType.Number,
|
|
83
|
-
default: 0,
|
|
84
|
-
field: 'x',
|
|
85
|
-
description: 'X',
|
|
86
|
-
configurable: false,
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
type: ConfigType.Number,
|
|
90
|
-
default: 0,
|
|
91
|
-
field: 'y',
|
|
92
|
-
description: 'Y',
|
|
93
|
-
configurable: false,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
type: ConfigType.Number,
|
|
97
|
-
default: 1,
|
|
98
|
-
field: 'number',
|
|
99
|
-
description: 'Number',
|
|
100
|
-
configurable: true,
|
|
101
|
-
},
|
|
102
|
-
])
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(ViewpointSymbol, "EXAMPLE_GRID", {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
configurable: true,
|
|
107
|
-
writable: true,
|
|
108
|
-
value: Object.freeze(GridData.create(['bbbbb', 'wwwwb', 'bwwbb', 'bbwww']).addSymbol(new ViewpointSymbol(1, 1, 5)))
|
|
109
|
-
});
|
|
110
|
-
export default ViewpointSymbol;
|
|
111
95
|
export const instance = new ViewpointSymbol(0, 0, 1);
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import { Color } from './primitives.js';
|
|
2
2
|
export default class TileData {
|
|
3
|
+
exists;
|
|
4
|
+
fixed;
|
|
5
|
+
color;
|
|
3
6
|
constructor(exists, fixed, color) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
writable: true,
|
|
8
|
-
value: exists
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(this, "fixed", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
value: fixed
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(this, "color", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: color
|
|
21
|
-
});
|
|
7
|
+
this.exists = exists;
|
|
8
|
+
this.fixed = fixed;
|
|
9
|
+
this.color = color;
|
|
22
10
|
this.exists = exists;
|
|
23
11
|
this.fixed = fixed;
|
|
24
12
|
this.color = color;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import debounce from 'lodash/debounce.js';
|
|
2
|
+
import { Serializer } from './serializer/allSerializers.js';
|
|
3
|
+
import validateGrid from './validate.js';
|
|
4
|
+
const SYNC_VALIDATION_THRESHOLD = 10000;
|
|
5
|
+
export class GridValidator {
|
|
6
|
+
worker = null;
|
|
7
|
+
stateListeners = new Set();
|
|
8
|
+
loadListeners = new Set();
|
|
9
|
+
validateGridDebounced = debounce((grid, solution) => {
|
|
10
|
+
this.worker?.terminate();
|
|
11
|
+
this.worker = new Worker(new URL('./validateAsyncWorker.js', import.meta.url), { type: 'module' });
|
|
12
|
+
this.worker.onmessage = (event) => {
|
|
13
|
+
if (event.data) {
|
|
14
|
+
this.notifyState(event.data);
|
|
15
|
+
}
|
|
16
|
+
this.worker?.terminate();
|
|
17
|
+
this.worker = null;
|
|
18
|
+
this.notifyLoad();
|
|
19
|
+
};
|
|
20
|
+
this.worker.onmessageerror = (error) => {
|
|
21
|
+
console.error('Validation worker error:', error);
|
|
22
|
+
this.worker?.terminate();
|
|
23
|
+
this.worker = null;
|
|
24
|
+
this.notifyLoad();
|
|
25
|
+
};
|
|
26
|
+
this.worker.postMessage({
|
|
27
|
+
grid: Serializer.stringifyGrid(grid),
|
|
28
|
+
solution: solution ? Serializer.stringifyGrid(solution) : null,
|
|
29
|
+
});
|
|
30
|
+
this.notifyLoad();
|
|
31
|
+
}, 300, { leading: true, trailing: true });
|
|
32
|
+
validateGrid = (grid, solution) => {
|
|
33
|
+
if (grid.width * grid.height <= SYNC_VALIDATION_THRESHOLD) {
|
|
34
|
+
// Synchronous validation for small grids
|
|
35
|
+
// to avoid the overhead of worker communication.
|
|
36
|
+
const state = validateGrid(grid, solution);
|
|
37
|
+
this.notifyState(state);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.validateGridDebounced(grid, solution);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
notifyState = (state) => {
|
|
44
|
+
this.stateListeners.forEach(listener => listener(state));
|
|
45
|
+
};
|
|
46
|
+
subscribeToState = (listener) => {
|
|
47
|
+
this.stateListeners.add(listener);
|
|
48
|
+
return () => {
|
|
49
|
+
this.stateListeners.delete(listener);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
notifyLoad = () => {
|
|
53
|
+
this.loadListeners.forEach(listener => listener());
|
|
54
|
+
};
|
|
55
|
+
subscribeToLoad = (listener) => {
|
|
56
|
+
this.loadListeners.add(listener);
|
|
57
|
+
return () => {
|
|
58
|
+
this.loadListeners.delete(listener);
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
isLoading = () => {
|
|
62
|
+
return this.worker !== null;
|
|
63
|
+
};
|
|
64
|
+
delete = () => {
|
|
65
|
+
if (this.worker) {
|
|
66
|
+
this.worker.terminate();
|
|
67
|
+
this.worker = null;
|
|
68
|
+
}
|
|
69
|
+
this.stateListeners.clear();
|
|
70
|
+
};
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -32,6 +32,7 @@ import LyingSymbolRule from './data/rules/lyingSymbolRule.js';
|
|
|
32
32
|
import { ControlLine, Row } from './data/rules/musicControlLine.js';
|
|
33
33
|
import MusicGridRule from './data/rules/musicGridRule.js';
|
|
34
34
|
import MysteryRule from './data/rules/mysteryRule.js';
|
|
35
|
+
import NoLoopsRule from './data/rules/noLoopsRule.js';
|
|
35
36
|
import OffByXRule from './data/rules/offByXRule.js';
|
|
36
37
|
import PerfectionRule from './data/rules/perfectionRule.js';
|
|
37
38
|
import RegionAreaRule from './data/rules/regionAreaRule.js';
|
|
@@ -117,4 +118,4 @@ import TileData from './data/tile.js';
|
|
|
117
118
|
import TileConnections from './data/tileConnections.js';
|
|
118
119
|
import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
|
|
119
120
|
import { GridValidator } from './data/validateAsync.js';
|
|
120
|
-
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolMerge, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, DRUM_SAMPLES, Direction, INSTRUMENTS, Instrument, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, isDrumSample, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ConnectZonesRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ExactCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, EveryLetterSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, GridValidator, };
|
|
121
|
+
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolMerge, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, DRUM_SAMPLES, Direction, INSTRUMENTS, Instrument, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, isDrumSample, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ConnectZonesRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ExactCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, NoLoopsRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, EveryLetterSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, GridValidator, };
|
|
@@ -35,6 +35,7 @@ import LyingSymbolRule from './data/rules/lyingSymbolRule.js';
|
|
|
35
35
|
import { ControlLine, Row } from './data/rules/musicControlLine.js';
|
|
36
36
|
import MusicGridRule from './data/rules/musicGridRule.js';
|
|
37
37
|
import MysteryRule from './data/rules/mysteryRule.js';
|
|
38
|
+
import NoLoopsRule from './data/rules/noLoopsRule.js';
|
|
38
39
|
import OffByXRule from './data/rules/offByXRule.js';
|
|
39
40
|
import PerfectionRule from './data/rules/perfectionRule.js';
|
|
40
41
|
import RegionAreaRule from './data/rules/regionAreaRule.js';
|
|
@@ -120,4 +121,4 @@ import TileData from './data/tile.js';
|
|
|
120
121
|
import TileConnections from './data/tileConnections.js';
|
|
121
122
|
import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
|
|
122
123
|
import { GridValidator } from './data/validateAsync.js';
|
|
123
|
-
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolMerge, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, DRUM_SAMPLES, Direction, INSTRUMENTS, Instrument, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, isDrumSample, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ConnectZonesRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ExactCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, EveryLetterSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, GridValidator, };
|
|
124
|
+
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolMerge, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, DRUM_SAMPLES, Direction, INSTRUMENTS, Instrument, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, isDrumSample, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, puzzleEquals, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ConnectZonesRule, ContainsShapeRule, CustomRule, DifferentCountPerZoneRule, ExactCountPerZoneRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, NoLoopsRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameCountPerZoneRule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, ChecksumCompressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerChecksum, SerializerV0, OFFSETS, orientationChars, getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape, allSolvers, AutoSolver, BacktrackSolver, BTModule, BTGridData, BTTile, IntArray2D, colorToBTTile, createOneTileResult, getOppositeColor, BanPatternBTModule, CellCountBTModule, ConnectAllBTModule, RegionAreaBTModule, RegionShapeBTModule, SameShapeBTModule, SymbolsPerRegionBTModule, UniqueShapeBTModule, AreaNumberBTModule, DartBTModule, DirectionLinkerBTModule, FocusBTModule, GalaxyBTModule, LetterBTModule, LotusBTModule, MinesweeperBTModule, MyopiaBTModule, ViewpointBTModule, CspuzSolver, gridToJson, EventIteratingSolver, Solver, UniversalSolver, AreaNumberModule, CellCountModule, ConnectAllModule, DartModule, allZ3Modules, LetterModule, MyopiaModule, RegionAreaModule, ViewpointModule, Z3Module, convertDirection, Z3Solver, Z3SolverContext, AreaNumberSymbol, CustomIconSymbol, CustomSymbol, CustomTextSymbol, DartSymbol, DirectionLinkerSymbol, EveryLetterSymbol, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, GridValidator, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logic-pad/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -20,20 +20,19 @@
|
|
|
20
20
|
"grid"
|
|
21
21
|
],
|
|
22
22
|
"license": "AGPL-3.0-only",
|
|
23
|
-
"
|
|
24
|
-
"module": "./dist/logic-core.js",
|
|
23
|
+
"module": "./dist/src/index.js",
|
|
25
24
|
"exports": {
|
|
26
25
|
".": {
|
|
27
|
-
"import": "./dist/index.js",
|
|
28
|
-
"require": "./dist/index.js"
|
|
26
|
+
"import": "./dist/src/index.js",
|
|
27
|
+
"require": "./dist/src/index.js"
|
|
29
28
|
},
|
|
30
29
|
"./data/*": {
|
|
31
|
-
"import": "./dist/data/*",
|
|
32
|
-
"require": "./dist/data/*"
|
|
30
|
+
"import": "./dist/src/data/*",
|
|
31
|
+
"require": "./dist/src/data/*"
|
|
33
32
|
},
|
|
34
33
|
"./polyfill/*": {
|
|
35
|
-
"import": "./dist/polyfill/*",
|
|
36
|
-
"require": "./dist/polyfill/*"
|
|
34
|
+
"import": "./dist/src/polyfill/*",
|
|
35
|
+
"require": "./dist/src/polyfill/*"
|
|
37
36
|
},
|
|
38
37
|
"./assets/*": {
|
|
39
38
|
"import": "./assets/*",
|
|
@@ -44,6 +43,8 @@
|
|
|
44
43
|
"build": "rimraf dist/ && bun run codegen && bunx --bun tsc && bun run typegen",
|
|
45
44
|
"codegen": "bun ./scripts/genImports.ts && bun ./scripts/genEntry.ts",
|
|
46
45
|
"typegen": "bun ./scripts/genTypes.ts",
|
|
46
|
+
"bench:prepare": "bun ./benchmark/prepareBench.ts",
|
|
47
|
+
"bench:run": "bun ./benchmark/runBench.ts",
|
|
47
48
|
"prepublishOnly": "bun run build"
|
|
48
49
|
},
|
|
49
50
|
"engines": {
|
|
@@ -65,9 +66,11 @@
|
|
|
65
66
|
"@types/lodash": "^4.17.20",
|
|
66
67
|
"dts-bundle-generator": "^9.5.1",
|
|
67
68
|
"fast-glob": "^3.3.3",
|
|
69
|
+
"p-queue": "^9.0.1",
|
|
68
70
|
"prettier": "^3.6.2",
|
|
69
71
|
"rimraf": "^6.0.1",
|
|
70
|
-
"typescript": "^5.9.2"
|
|
72
|
+
"typescript": "^5.9.2",
|
|
73
|
+
"uint8-to-base64": "^0.2.1"
|
|
71
74
|
},
|
|
72
75
|
"trustedDependencies": [
|
|
73
76
|
"esbuild"
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { instance as undercluedInstance } from '../../rules/undercluedRule.js';
|
|
2
|
-
import EventIteratingSolver from '../eventIteratingSolver.js';
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
4
|
-
('vite-apply-code-mod');
|
|
5
|
-
export default class UniversalSolver extends EventIteratingSolver {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
Object.defineProperty(this, "id", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: 'universal'
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "author", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: 'romain22222, Lysine'
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "description", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: 'A backtracking solver that supports all rules and symbols (including underclued) but is less optimized.'
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
createWorker() {
|
|
28
|
-
return new Worker(new URL('./universalWorker.js', import.meta.url), {
|
|
29
|
-
type: 'module',
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
isInstructionSupported(instructionId) {
|
|
33
|
-
if (super.isInstructionSupported(instructionId)) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
return instructionId === undercluedInstance.id;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import debounce from 'lodash/debounce.js';
|
|
2
|
-
import { Serializer } from './serializer/allSerializers.js';
|
|
3
|
-
import validateGrid from './validate.js';
|
|
4
|
-
const SYNC_VALIDATION_THRESHOLD = 10000;
|
|
5
|
-
export class GridValidator {
|
|
6
|
-
constructor() {
|
|
7
|
-
Object.defineProperty(this, "worker", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
configurable: true,
|
|
10
|
-
writable: true,
|
|
11
|
-
value: null
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "stateListeners", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: new Set()
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(this, "loadListeners", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: true,
|
|
23
|
-
value: new Set()
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(this, "validateGridDebounced", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: debounce((grid, solution) => {
|
|
30
|
-
this.worker?.terminate();
|
|
31
|
-
this.worker = new Worker(new URL('./validateAsyncWorker.js', import.meta.url), { type: 'module' });
|
|
32
|
-
this.worker.onmessage = (event) => {
|
|
33
|
-
if (event.data) {
|
|
34
|
-
this.notifyState(event.data);
|
|
35
|
-
}
|
|
36
|
-
this.worker?.terminate();
|
|
37
|
-
this.worker = null;
|
|
38
|
-
this.notifyLoad();
|
|
39
|
-
};
|
|
40
|
-
this.worker.onmessageerror = (error) => {
|
|
41
|
-
console.error('Validation worker error:', error);
|
|
42
|
-
this.worker?.terminate();
|
|
43
|
-
this.worker = null;
|
|
44
|
-
this.notifyLoad();
|
|
45
|
-
};
|
|
46
|
-
this.worker.postMessage({
|
|
47
|
-
grid: Serializer.stringifyGrid(grid),
|
|
48
|
-
solution: solution ? Serializer.stringifyGrid(solution) : null,
|
|
49
|
-
});
|
|
50
|
-
this.notifyLoad();
|
|
51
|
-
}, 300, { leading: true, trailing: true })
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "validateGrid", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: (grid, solution) => {
|
|
58
|
-
if (grid.width * grid.height <= SYNC_VALIDATION_THRESHOLD) {
|
|
59
|
-
// Synchronous validation for small grids
|
|
60
|
-
// to avoid the overhead of worker communication.
|
|
61
|
-
const state = validateGrid(grid, solution);
|
|
62
|
-
this.notifyState(state);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
this.validateGridDebounced(grid, solution);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
Object.defineProperty(this, "notifyState", {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
configurable: true,
|
|
72
|
-
writable: true,
|
|
73
|
-
value: (state) => {
|
|
74
|
-
this.stateListeners.forEach(listener => listener(state));
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(this, "subscribeToState", {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
configurable: true,
|
|
80
|
-
writable: true,
|
|
81
|
-
value: (listener) => {
|
|
82
|
-
this.stateListeners.add(listener);
|
|
83
|
-
return () => {
|
|
84
|
-
this.stateListeners.delete(listener);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
Object.defineProperty(this, "notifyLoad", {
|
|
89
|
-
enumerable: true,
|
|
90
|
-
configurable: true,
|
|
91
|
-
writable: true,
|
|
92
|
-
value: () => {
|
|
93
|
-
this.loadListeners.forEach(listener => listener());
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(this, "subscribeToLoad", {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
configurable: true,
|
|
99
|
-
writable: true,
|
|
100
|
-
value: (listener) => {
|
|
101
|
-
this.loadListeners.add(listener);
|
|
102
|
-
return () => {
|
|
103
|
-
this.loadListeners.delete(listener);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
Object.defineProperty(this, "isLoading", {
|
|
108
|
-
enumerable: true,
|
|
109
|
-
configurable: true,
|
|
110
|
-
writable: true,
|
|
111
|
-
value: () => {
|
|
112
|
-
return this.worker !== null;
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
Object.defineProperty(this, "delete", {
|
|
116
|
-
enumerable: true,
|
|
117
|
-
configurable: true,
|
|
118
|
-
writable: true,
|
|
119
|
-
value: () => {
|
|
120
|
-
if (this.worker) {
|
|
121
|
-
this.worker.terminate();
|
|
122
|
-
this.worker = null;
|
|
123
|
-
}
|
|
124
|
-
this.stateListeners.clear();
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|