@logic-pad/core 0.12.0 → 0.12.2

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.
@@ -1489,7 +1489,7 @@ declare global {
1489
1489
  * Get the types of a puzzle based on its grid properties. The returned types are ordered by their priority.
1490
1490
  * The first type is the most important one.
1491
1491
  */
1492
- export declare function getPuzzleTypes(puzzle: Puzzle): PuzzleType[];
1492
+ export declare function getPuzzleTypes(grid: GridData): PuzzleType[];
1493
1493
  export interface ShapeElement {
1494
1494
  x: number;
1495
1495
  y: number;
@@ -1970,6 +1970,8 @@ declare global {
1970
1970
  parseSymbol(input: string): Symbol$1;
1971
1971
  stringifyGrid(grid: GridData): string;
1972
1972
  parseGrid(input: string): GridData;
1973
+ stringifyGridWithSolution(puzzle: PuzzleData): string;
1974
+ parseGridWithSolution(input: string): PuzzleData;
1973
1975
  /**
1974
1976
  * Convert a puzzle to a string.
1975
1977
  * @param puzzle The puzzle to convert.
@@ -80,4 +80,4 @@ export type Puzzle = PuzzleMetadata & PuzzleData;
80
80
  * Get the types of a puzzle based on its grid properties. The returned types are ordered by their priority.
81
81
  * The first type is the most important one.
82
82
  */
83
- export declare function getPuzzleTypes(puzzle: Puzzle): PuzzleType[];
83
+ export declare function getPuzzleTypes(grid: GridData): PuzzleType[];
@@ -23,18 +23,18 @@ export const PuzzleSchema = z
23
23
  * Get the types of a puzzle based on its grid properties. The returned types are ordered by their priority.
24
24
  * The first type is the most important one.
25
25
  */
26
- export function getPuzzleTypes(puzzle) {
26
+ export function getPuzzleTypes(grid) {
27
27
  const types = [];
28
28
  let logic = true;
29
- if (puzzle.grid.musicGrid.value) {
29
+ if (grid.musicGrid.value) {
30
30
  types.push(PuzzleType.Music);
31
31
  logic = false;
32
32
  }
33
- if (puzzle.grid.completePattern.value) {
33
+ if (grid.completePattern.value) {
34
34
  types.push(PuzzleType.Pattern);
35
35
  logic = false;
36
36
  }
37
- if (puzzle.grid.underclued.value) {
37
+ if (grid.underclued.value) {
38
38
  types.push(PuzzleType.Underclued);
39
39
  }
40
40
  if (logic) {
@@ -1,5 +1,5 @@
1
1
  import GridData from '../grid.js';
2
- import { Puzzle } from '../puzzle.js';
2
+ import { Puzzle, PuzzleData } from '../puzzle.js';
3
3
  import Rule from '../rules/rule.js';
4
4
  import Symbol from '../symbols/symbol.js';
5
5
  /**
@@ -14,6 +14,8 @@ declare const Serializer: {
14
14
  parseSymbol(input: string): Symbol;
15
15
  stringifyGrid(grid: GridData): string;
16
16
  parseGrid(input: string): GridData;
17
+ stringifyGridWithSolution(puzzle: PuzzleData): string;
18
+ parseGridWithSolution(input: string): PuzzleData;
17
19
  /**
18
20
  * Convert a puzzle to a string.
19
21
  * @param puzzle The puzzle to convert.
@@ -43,6 +43,13 @@ const Serializer = {
43
43
  const { serializer, data } = selectSerializer(input);
44
44
  return serializer.parseGrid(data);
45
45
  },
46
+ stringifyGridWithSolution(puzzle) {
47
+ return `${defaultSerializer.version}_${defaultSerializer.stringifyGridWithSolution(puzzle)}`;
48
+ },
49
+ parseGridWithSolution(input) {
50
+ const { serializer, data } = selectSerializer(input);
51
+ return serializer.parseGridWithSolution(data);
52
+ },
46
53
  /**
47
54
  * Convert a puzzle to a string.
48
55
  * @param puzzle The puzzle to convert.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logic-pad/core",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",