@logic-pad/core 0.12.2 → 0.12.3
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 +14 -0
- package/dist/data/puzzle.d.ts +11 -1
- package/dist/data/puzzle.js +43 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1490,6 +1490,20 @@ declare global {
|
|
|
1490
1490
|
* The first type is the most important one.
|
|
1491
1491
|
*/
|
|
1492
1492
|
export declare function getPuzzleTypes(grid: GridData): PuzzleType[];
|
|
1493
|
+
export interface PuzzleChecklistItem {
|
|
1494
|
+
id: string;
|
|
1495
|
+
success: boolean;
|
|
1496
|
+
mandatory: boolean;
|
|
1497
|
+
}
|
|
1498
|
+
export interface PuzzleChecklist {
|
|
1499
|
+
items: PuzzleChecklistItem[];
|
|
1500
|
+
isValid: boolean;
|
|
1501
|
+
}
|
|
1502
|
+
export declare function validatePuzzleChecklist(
|
|
1503
|
+
metadata: PuzzleMetadata,
|
|
1504
|
+
gridWithSolution: GridData,
|
|
1505
|
+
state: GridState
|
|
1506
|
+
): PuzzleChecklist;
|
|
1493
1507
|
export interface ShapeElement {
|
|
1494
1508
|
x: number;
|
|
1495
1509
|
y: number;
|
package/dist/data/puzzle.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import GridData from './grid.js';
|
|
3
|
-
import { PuzzleType } from './primitives.js';
|
|
3
|
+
import { GridState, PuzzleType } from './primitives.js';
|
|
4
4
|
export type PuzzleMetadata = {
|
|
5
5
|
/**
|
|
6
6
|
* The title of the puzzle. (required)
|
|
@@ -81,3 +81,13 @@ export type Puzzle = PuzzleMetadata & PuzzleData;
|
|
|
81
81
|
* The first type is the most important one.
|
|
82
82
|
*/
|
|
83
83
|
export declare function getPuzzleTypes(grid: GridData): PuzzleType[];
|
|
84
|
+
export interface PuzzleChecklistItem {
|
|
85
|
+
id: string;
|
|
86
|
+
success: boolean;
|
|
87
|
+
mandatory: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface PuzzleChecklist {
|
|
90
|
+
items: PuzzleChecklistItem[];
|
|
91
|
+
isValid: boolean;
|
|
92
|
+
}
|
|
93
|
+
export declare function validatePuzzleChecklist(metadata: PuzzleMetadata, gridWithSolution: GridData, state: GridState): PuzzleChecklist;
|
package/dist/data/puzzle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import GridData from './grid.js';
|
|
3
|
-
import { PuzzleType } from './primitives.js';
|
|
3
|
+
import { Color, PuzzleType, State } from './primitives.js';
|
|
4
4
|
export const MetadataSchema = z
|
|
5
5
|
.object({
|
|
6
6
|
title: z.string().min(1),
|
|
@@ -42,3 +42,45 @@ export function getPuzzleTypes(grid) {
|
|
|
42
42
|
}
|
|
43
43
|
return types;
|
|
44
44
|
}
|
|
45
|
+
export function validatePuzzleChecklist(metadata, gridWithSolution, state) {
|
|
46
|
+
const checklist = {
|
|
47
|
+
items: [],
|
|
48
|
+
isValid: true,
|
|
49
|
+
};
|
|
50
|
+
checklist.items.push({
|
|
51
|
+
id: 'metadataValid',
|
|
52
|
+
success: MetadataSchema.safeParse(metadata).success,
|
|
53
|
+
mandatory: true,
|
|
54
|
+
});
|
|
55
|
+
if (gridWithSolution.requireSolution()) {
|
|
56
|
+
checklist.items.push({
|
|
57
|
+
id: 'autoValidation',
|
|
58
|
+
success: false,
|
|
59
|
+
mandatory: false,
|
|
60
|
+
});
|
|
61
|
+
checklist.items.push({
|
|
62
|
+
id: 'solutionIsNotEmpty',
|
|
63
|
+
success: gridWithSolution.tiles.some(row => row.some(tile => !tile.fixed && tile.color !== Color.Gray)),
|
|
64
|
+
mandatory: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
checklist.items.push({
|
|
69
|
+
id: 'autoValidation',
|
|
70
|
+
success: true,
|
|
71
|
+
mandatory: false,
|
|
72
|
+
});
|
|
73
|
+
checklist.items.push({
|
|
74
|
+
id: 'solutionIsComplete',
|
|
75
|
+
success: gridWithSolution.isComplete(),
|
|
76
|
+
mandatory: true,
|
|
77
|
+
});
|
|
78
|
+
checklist.items.push({
|
|
79
|
+
id: 'solutionIsValid',
|
|
80
|
+
success: state.final !== State.Error,
|
|
81
|
+
mandatory: true,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
checklist.isValid = !checklist.items.some(x => !x.success && x.mandatory);
|
|
85
|
+
return checklist;
|
|
86
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import GridConnections from './data/gridConnections.js';
|
|
|
14
14
|
import GridZones from './data/gridZones.js';
|
|
15
15
|
import Instruction from './data/instruction.js';
|
|
16
16
|
import { COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle } from './data/primitives.js';
|
|
17
|
-
import { MetadataSchema, PuzzleSchema, getPuzzleTypes } from './data/puzzle.js';
|
|
17
|
+
import { MetadataSchema, PuzzleSchema, getPuzzleTypes, validatePuzzleChecklist } from './data/puzzle.js';
|
|
18
18
|
import BanPatternRule from './data/rules/banPatternRule.js';
|
|
19
19
|
import CellCountPerZoneRule from './data/rules/cellCountPerZoneRule.js';
|
|
20
20
|
import CellCountRule from './data/rules/cellCountRule.js';
|
|
@@ -108,4 +108,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
|
|
|
108
108
|
import TileData from './data/tile.js';
|
|
109
109
|
import TileConnections from './data/tileConnections.js';
|
|
110
110
|
import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
|
|
111
|
-
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|
|
111
|
+
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import GridConnections from './data/gridConnections.js';
|
|
|
17
17
|
import GridZones from './data/gridZones.js';
|
|
18
18
|
import Instruction from './data/instruction.js';
|
|
19
19
|
import { COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle } from './data/primitives.js';
|
|
20
|
-
import { MetadataSchema, PuzzleSchema, getPuzzleTypes } from './data/puzzle.js';
|
|
20
|
+
import { MetadataSchema, PuzzleSchema, getPuzzleTypes, validatePuzzleChecklist } from './data/puzzle.js';
|
|
21
21
|
import BanPatternRule from './data/rules/banPatternRule.js';
|
|
22
22
|
import CellCountPerZoneRule from './data/rules/cellCountPerZoneRule.js';
|
|
23
23
|
import CellCountRule from './data/rules/cellCountRule.js';
|
|
@@ -111,4 +111,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
|
|
|
111
111
|
import TileData from './data/tile.js';
|
|
112
112
|
import TileConnections from './data/tileConnections.js';
|
|
113
113
|
import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
|
|
114
|
-
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|
|
114
|
+
export { ConfigType, configEquals, Configurable, CachedAccess, allEqual, array, directionToRotation, escape, isSameEdge, maxBy, minBy, move, orientationToRotation, resize, unescape, isEventHandler, handlesFinalValidation, handlesGetTile, handlesGridChange, handlesGridResize, handlesSetGrid, invokeSetGrid, handlesSymbolDisplay, handlesSymbolValidation, GridData, NEIGHBOR_OFFSETS, GridConnections, GridZones, Instruction, COMPARISONS, Color, Comparison, DIRECTIONS, Direction, MajorRule, Mode, ORIENTATIONS, Orientation, PuzzleType, State, WRAPPINGS, Wrapping, directionToggle, orientationToggle, MetadataSchema, PuzzleSchema, getPuzzleTypes, validatePuzzleChecklist, BanPatternRule, CellCountPerZoneRule, CellCountRule, CompletePatternRule, ConnectAllRule, ContainsShapeRule, CustomRule, ForesightRule, allRules, LyingSymbolRule, ControlLine, Row, MusicGridRule, MysteryRule, OffByXRule, PerfectionRule, RegionAreaRule, RegionShapeRule, Rule, SameShapeRule, SymbolsPerRegionRule, UndercluedRule, UniqueShapeRule, WrapAroundRule, Serializer, Compressor, CompressorBase, DeflateCompressor, GzipCompressor, StreamCompressor, SerializerBase, SerializerV0, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
|