@logic-pad/core 0.12.5 → 0.13.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.
@@ -106,9 +106,7 @@ declare global {
106
106
  Right = 'right',
107
107
  }
108
108
  export declare const DIRECTIONS: readonly Direction[];
109
- export type DirectionMap<T> = {
110
- [key in Direction]: T;
111
- };
109
+ export type DirectionMap<T> = Record<Direction, T>;
112
110
  export type DirectionToggle = Readonly<DirectionMap<boolean>>;
113
111
  export declare function directionToggle(
114
112
  ...directions: readonly Direction[]
@@ -129,9 +127,7 @@ declare global {
129
127
  UpLeft = 'up-left',
130
128
  }
131
129
  export declare const ORIENTATIONS: readonly Orientation[];
132
- export type OrientationMap<T> = {
133
- [key in Orientation]: T;
134
- };
130
+ export type OrientationMap<T> = Record<Orientation, T>;
135
131
  export type OrientationToggle = Readonly<OrientationMap<boolean>>;
136
132
  export declare function orientationToggle(
137
133
  ...orientations: readonly Orientation[]
@@ -1170,11 +1166,7 @@ declare global {
1170
1166
  * @param color The color of the tile. If undefined, all colors are included.
1171
1167
  * @returns The count of tiles that satisfy the given conditions.
1172
1168
  */
1173
- getTileCount(
1174
- exists: boolean,
1175
- fixed?: boolean | undefined,
1176
- color?: Color | undefined
1177
- ): number;
1169
+ getTileCount(exists: boolean, fixed?: boolean, color?: Color): number;
1178
1170
  /**
1179
1171
  * Get the count of tiles that satisfy the given conditions for each color.
1180
1172
  * @param color The color of the tiles.
@@ -1425,20 +1417,7 @@ declare global {
1425
1417
  description: z.ZodString;
1426
1418
  difficulty: z.ZodNumber;
1427
1419
  },
1428
- 'strict',
1429
- z.ZodTypeAny,
1430
- {
1431
- description: string;
1432
- title: string;
1433
- author: string;
1434
- difficulty: number;
1435
- },
1436
- {
1437
- description: string;
1438
- title: string;
1439
- author: string;
1440
- difficulty: number;
1441
- }
1420
+ z.core.$strict
1442
1421
  >;
1443
1422
  export declare const PuzzleSchema: z.ZodObject<
1444
1423
  {
@@ -1446,27 +1425,10 @@ declare global {
1446
1425
  author: z.ZodString;
1447
1426
  description: z.ZodString;
1448
1427
  difficulty: z.ZodNumber;
1449
- grid: z.ZodType<GridData, z.ZodTypeDef, GridData>;
1450
- solution: z.ZodNullable<z.ZodType<GridData, z.ZodTypeDef, GridData>>;
1451
- },
1452
- 'strict',
1453
- z.ZodTypeAny,
1454
- {
1455
- description: string;
1456
- grid: GridData;
1457
- title: string;
1458
- author: string;
1459
- difficulty: number;
1460
- solution: GridData | null;
1428
+ grid: z.ZodCustom<GridData, GridData>;
1429
+ solution: z.ZodNullable<z.ZodCustom<GridData, GridData>>;
1461
1430
  },
1462
- {
1463
- description: string;
1464
- grid: GridData;
1465
- title: string;
1466
- author: string;
1467
- difficulty: number;
1468
- solution: GridData | null;
1469
- }
1431
+ z.core.$strict
1470
1432
  >;
1471
1433
  export type PuzzleData = {
1472
1434
  /**
@@ -2025,6 +1987,11 @@ declare global {
2025
1987
  decompress(input: string): Promise<string>;
2026
1988
  }
2027
1989
  export declare const Compressor: MasterCompressor;
1990
+ export declare class ChecksumCompressor extends CompressorBase {
1991
+ get id(): string;
1992
+ compress(input: string): Promise<string>;
1993
+ decompress(_input: string): Promise<string>;
1994
+ }
2028
1995
  export declare abstract class StreamCompressor extends CompressorBase {
2029
1996
  protected abstract get algorithm(): CompressionFormat;
2030
1997
  compress(input: string): Promise<string>;
@@ -2067,8 +2034,22 @@ declare global {
2067
2034
  abstract stringifyPuzzle(puzzle: Puzzle): string;
2068
2035
  abstract parsePuzzle(input: string): Puzzle;
2069
2036
  }
2037
+ export declare const OFFSETS: {
2038
+ x: number;
2039
+ y: number;
2040
+ }[];
2041
+ export declare const orientationChars: {
2042
+ up: string;
2043
+ 'up-right': string;
2044
+ right: string;
2045
+ 'down-right': string;
2046
+ down: string;
2047
+ 'down-left': string;
2048
+ left: string;
2049
+ 'up-left': string;
2050
+ };
2070
2051
  export declare class SerializerV0 extends SerializerBase {
2071
- readonly version = 0;
2052
+ readonly version: number;
2072
2053
  stringifyTile(tile: TileData): string;
2073
2054
  parseTile(str: string): TileData;
2074
2055
  stringifyControlLine(line: ControlLine): string;
@@ -2100,6 +2081,29 @@ declare global {
2100
2081
  stringifyPuzzle(puzzle: Puzzle): string;
2101
2082
  parsePuzzle(input: string): Puzzle;
2102
2083
  }
2084
+ export declare class SerializerChecksum extends SerializerV0 {
2085
+ readonly version: number;
2086
+ parseTile(_str: string): TileData;
2087
+ stringifyControlLine(line: ControlLine): string;
2088
+ parseControlLine(_str: string): ControlLine;
2089
+ parseConfig(
2090
+ _configs: readonly AnyConfig[],
2091
+ _entry: string
2092
+ ): [string, unknown];
2093
+ parseRule(_str: string): Rule;
2094
+ parseSymbol(_str: string): Symbol$1;
2095
+ parseConnections(_input: string): GridConnections;
2096
+ stringifyZones(zones: GridZones): string;
2097
+ parseZones(_input: string): GridZones;
2098
+ parseTiles(_input: string): TileData[][];
2099
+ stringifyRules(rules: readonly Rule[]): string;
2100
+ parseRules(_input: string): Rule[];
2101
+ stringifySymbols(symbols: ReadonlyMap<string, readonly Symbol$1[]>): string;
2102
+ parseSymbols(_input: string): Map<string, Symbol$1[]>;
2103
+ parseGrid(_input: string): GridData;
2104
+ parseGridWithSolution(_input: string): PuzzleData;
2105
+ parsePuzzle(_input: string): Puzzle;
2106
+ }
2103
2107
  /**
2104
2108
  * Base class that all solvers must extend.
2105
2109
  */
@@ -2191,7 +2195,7 @@ declare global {
2191
2195
  private solveOne;
2192
2196
  solve(
2193
2197
  grid: GridData,
2194
- abortSignal?: AbortSignal | undefined
2198
+ abortSignal?: AbortSignal
2195
2199
  ): AsyncGenerator<GridData | null>;
2196
2200
  }
2197
2201
  export declare abstract class EventIteratingSolver extends Solver {
@@ -2412,9 +2416,7 @@ declare global {
2412
2416
  checkGlobal(grid: BTGridData): CheckResult | false;
2413
2417
  private buildCheckAndRating;
2414
2418
  }
2415
- export type DirectionLinkerMap = {
2416
- [key in Direction]: Direction;
2417
- };
2419
+ export type DirectionLinkerMap = Record<Direction, Direction>;
2418
2420
  export declare class DirectionLinkerSymbol extends Symbol$1 {
2419
2421
  readonly x: number;
2420
2422
  readonly y: number;
@@ -116,6 +116,7 @@ export function resize(array, newSize, defaultValue) {
116
116
  * @param values The values to compare.
117
117
  * @returns Whether all the values are equal.
118
118
  */
119
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
119
120
  export function allEqual(...values) {
120
121
  return values.every(value => value === values[0]);
121
122
  }
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
1
2
  export function isEventHandler(val, event) {
2
3
  if (typeof val !== 'object' || val === null || val === undefined)
3
4
  return false;
@@ -382,7 +382,7 @@ export default class GridData {
382
382
  * @param color The color of the tile. If undefined, all colors are included.
383
383
  * @returns The count of tiles that satisfy the given conditions.
384
384
  */
385
- getTileCount(exists: boolean, fixed?: boolean | undefined, color?: Color | undefined): number;
385
+ getTileCount(exists: boolean, fixed?: boolean, color?: Color): number;
386
386
  /**
387
387
  * Get the count of tiles that satisfy the given conditions for each color.
388
388
  * @param color The color of the tiles.
@@ -87,9 +87,7 @@ export declare enum Direction {
87
87
  Right = "right"
88
88
  }
89
89
  export declare const DIRECTIONS: readonly Direction[];
90
- export type DirectionMap<T> = {
91
- [key in Direction]: T;
92
- };
90
+ export type DirectionMap<T> = Record<Direction, T>;
93
91
  export type DirectionToggle = Readonly<DirectionMap<boolean>>;
94
92
  export declare function directionToggle(...directions: readonly Direction[]): {
95
93
  up: boolean;
@@ -108,9 +106,7 @@ export declare enum Orientation {
108
106
  UpLeft = "up-left"
109
107
  }
110
108
  export declare const ORIENTATIONS: readonly Orientation[];
111
- export type OrientationMap<T> = {
112
- [key in Orientation]: T;
113
- };
109
+ export type OrientationMap<T> = Record<Orientation, T>;
114
110
  export type OrientationToggle = Readonly<OrientationMap<boolean>>;
115
111
  export declare function orientationToggle(...orientations: readonly Orientation[]): {
116
112
  up: boolean;
@@ -26,39 +26,15 @@ export declare const MetadataSchema: z.ZodObject<{
26
26
  author: z.ZodString;
27
27
  description: z.ZodString;
28
28
  difficulty: z.ZodNumber;
29
- }, "strict", z.ZodTypeAny, {
30
- description: string;
31
- title: string;
32
- author: string;
33
- difficulty: number;
34
- }, {
35
- description: string;
36
- title: string;
37
- author: string;
38
- difficulty: number;
39
- }>;
29
+ }, z.core.$strict>;
40
30
  export declare const PuzzleSchema: z.ZodObject<{
41
31
  title: z.ZodString;
42
32
  author: z.ZodString;
43
33
  description: z.ZodString;
44
34
  difficulty: z.ZodNumber;
45
- grid: z.ZodType<GridData, z.ZodTypeDef, GridData>;
46
- solution: z.ZodNullable<z.ZodType<GridData, z.ZodTypeDef, GridData>>;
47
- }, "strict", z.ZodTypeAny, {
48
- description: string;
49
- grid: GridData;
50
- title: string;
51
- author: string;
52
- difficulty: number;
53
- solution: GridData | null;
54
- }, {
55
- description: string;
56
- grid: GridData;
57
- title: string;
58
- author: string;
59
- difficulty: number;
60
- solution: GridData | null;
61
- }>;
35
+ grid: z.ZodCustom<GridData, GridData>;
36
+ solution: z.ZodNullable<z.ZodCustom<GridData, GridData>>;
37
+ }, z.core.$strict>;
62
38
  export type PuzzleData = {
63
39
  /**
64
40
  * The grid of the puzzle. (required)
@@ -6,7 +6,7 @@ function register(prototype) {
6
6
  let defaultSerializer;
7
7
  register((defaultSerializer = new SerializerV0()));
8
8
  function selectSerializer(input) {
9
- const match = input.match(/^(\d+)_/);
9
+ const match = /^(\d+)_/.exec(input);
10
10
  const version = match ? parseInt(match[1]) : 0;
11
11
  const serializer = allSerializers.get(version);
12
12
  if (serializer) {
@@ -24,7 +24,7 @@ class MasterCompressor extends CompressorBase {
24
24
  return minBy(compressed, c => encodeURIComponent(c).length) ?? '';
25
25
  }
26
26
  async decompress(input) {
27
- const match = input.match(/^([^_]+?)_(.+)$/);
27
+ const match = /^([^_]+?)_(.+)$/.exec(input);
28
28
  let compressorId;
29
29
  let compressed;
30
30
  if (match) {
@@ -0,0 +1,6 @@
1
+ import CompressorBase from './compressorBase.js';
2
+ export default class ChecksumCompressor extends CompressorBase {
3
+ get id(): string;
4
+ compress(input: string): Promise<string>;
5
+ decompress(_input: string): Promise<string>;
6
+ }
@@ -0,0 +1,21 @@
1
+ import SerializerChecksum from '../serializer_checksum.js';
2
+ import CompressorBase from './compressorBase.js';
3
+ const checksumSerializer = new SerializerChecksum();
4
+ const encoder = new TextEncoder();
5
+ export default class ChecksumCompressor extends CompressorBase {
6
+ get id() {
7
+ return `cs${checksumSerializer.version}`;
8
+ }
9
+ async compress(input) {
10
+ const data = encoder.encode(input);
11
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
12
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
13
+ const hashHex = hashArray
14
+ .map(b => b.toString(16).padStart(2, '0'))
15
+ .join('');
16
+ return hashHex;
17
+ }
18
+ decompress(_input) {
19
+ throw new Error('Checksum decompression is not supported');
20
+ }
21
+ }
@@ -0,0 +1,30 @@
1
+ import GridData from '../grid.js';
2
+ import GridConnections from '../gridConnections.js';
3
+ import Rule from '../rules/rule.js';
4
+ import TileData from '../tile.js';
5
+ import Symbol from '../symbols/symbol.js';
6
+ import { AnyConfig } from '../config.js';
7
+ import { Puzzle, PuzzleData } from '../puzzle.js';
8
+ import { ControlLine } from '../rules/musicControlLine.js';
9
+ import GridZones from '../gridZones.js';
10
+ import SerializerV0 from './serializer_v0.js';
11
+ export default class SerializerChecksum extends SerializerV0 {
12
+ readonly version: number;
13
+ parseTile(_str: string): TileData;
14
+ stringifyControlLine(line: ControlLine): string;
15
+ parseControlLine(_str: string): ControlLine;
16
+ parseConfig(_configs: readonly AnyConfig[], _entry: string): [string, unknown];
17
+ parseRule(_str: string): Rule;
18
+ parseSymbol(_str: string): Symbol;
19
+ parseConnections(_input: string): GridConnections;
20
+ stringifyZones(zones: GridZones): string;
21
+ parseZones(_input: string): GridZones;
22
+ parseTiles(_input: string): TileData[][];
23
+ stringifyRules(rules: readonly Rule[]): string;
24
+ parseRules(_input: string): Rule[];
25
+ stringifySymbols(symbols: ReadonlyMap<string, readonly Symbol[]>): string;
26
+ parseSymbols(_input: string): Map<string, Symbol[]>;
27
+ parseGrid(_input: string): GridData;
28
+ parseGridWithSolution(_input: string): PuzzleData;
29
+ parsePuzzle(_input: string): Puzzle;
30
+ }
@@ -0,0 +1,76 @@
1
+ import SerializerV0 from './serializer_v0.js';
2
+ export default class SerializerChecksum extends SerializerV0 {
3
+ constructor() {
4
+ super(...arguments);
5
+ Object.defineProperty(this, "version", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: 1
10
+ });
11
+ }
12
+ parseTile(_str) {
13
+ throw new Error('Checksum serializer does not support parsing');
14
+ }
15
+ stringifyControlLine(line) {
16
+ const result = [];
17
+ result.push(`c${line.column}`);
18
+ result.push(`r${line.rows.map(row => `n${row.note ?? ''}`).join(',')}`);
19
+ return result.join('|');
20
+ }
21
+ parseControlLine(_str) {
22
+ throw new Error('Checksum serializer does not support parsing');
23
+ }
24
+ parseConfig(_configs, _entry) {
25
+ throw new Error('Checksum serializer does not support parsing');
26
+ }
27
+ parseRule(_str) {
28
+ throw new Error('Checksum serializer does not support parsing');
29
+ }
30
+ parseSymbol(_str) {
31
+ throw new Error('Checksum serializer does not support parsing');
32
+ }
33
+ parseConnections(_input) {
34
+ throw new Error('Checksum serializer does not support parsing');
35
+ }
36
+ stringifyZones(zones) {
37
+ return `Z${zones.edges
38
+ .map(edge => `${edge.x1}_${edge.y1}_${edge.x2 - edge.x1}_${edge.y2 - edge.y1}`)
39
+ .sort()
40
+ .join(':')}`;
41
+ }
42
+ parseZones(_input) {
43
+ throw new Error('Checksum serializer does not support parsing');
44
+ }
45
+ parseTiles(_input) {
46
+ throw new Error('Checksum serializer does not support parsing');
47
+ }
48
+ stringifyRules(rules) {
49
+ return `R${rules
50
+ .map(rule => this.stringifyRule(rule))
51
+ .sort()
52
+ .join(':')}`;
53
+ }
54
+ parseRules(_input) {
55
+ throw new Error('Checksum serializer does not support parsing');
56
+ }
57
+ stringifySymbols(symbols) {
58
+ return `S${Array.from(symbols.values())
59
+ .flat()
60
+ .map(symbol => this.stringifySymbol(symbol))
61
+ .sort()
62
+ .join(':')}`;
63
+ }
64
+ parseSymbols(_input) {
65
+ throw new Error('Checksum serializer does not support parsing');
66
+ }
67
+ parseGrid(_input) {
68
+ throw new Error('Checksum serializer does not support parsing');
69
+ }
70
+ parseGridWithSolution(_input) {
71
+ throw new Error('Checksum serializer does not support parsing');
72
+ }
73
+ parsePuzzle(_input) {
74
+ throw new Error('Checksum serializer does not support parsing');
75
+ }
76
+ }
@@ -9,8 +9,22 @@ import SerializerBase from './serializerBase.js';
9
9
  import { Puzzle, PuzzleData } from '../puzzle.js';
10
10
  import { ControlLine } from '../rules/musicControlLine.js';
11
11
  import GridZones from '../gridZones.js';
12
+ export declare const OFFSETS: {
13
+ x: number;
14
+ y: number;
15
+ }[];
16
+ export declare const orientationChars: {
17
+ up: string;
18
+ "up-right": string;
19
+ right: string;
20
+ "down-right": string;
21
+ down: string;
22
+ "down-left": string;
23
+ left: string;
24
+ "up-left": string;
25
+ };
12
26
  export default class SerializerV0 extends SerializerBase {
13
- readonly version = 0;
27
+ readonly version: number;
14
28
  stringifyTile(tile: TileData): string;
15
29
  parseTile(str: string): TileData;
16
30
  stringifyControlLine(line: ControlLine): string;
@@ -1,7 +1,7 @@
1
1
  import GridData from '../grid.js';
2
2
  import GridConnections from '../gridConnections.js';
3
3
  import TileData from '../tile.js';
4
- import { ConfigType } from '../config.js';
4
+ import { ConfigType, } from '../config.js';
5
5
  import { Color, DIRECTIONS, ORIENTATIONS, Orientation, directionToggle, orientationToggle, } from '../primitives.js';
6
6
  import { array, escape, unescape } from '../dataHelper.js';
7
7
  import { allRules } from '../rules/index.js';
@@ -9,13 +9,13 @@ import { allSymbols } from '../symbols/index.js';
9
9
  import SerializerBase from './serializerBase.js';
10
10
  import { ControlLine, Row } from '../rules/musicControlLine.js';
11
11
  import GridZones from '../gridZones.js';
12
- const OFFSETS = [
12
+ export const OFFSETS = [
13
13
  { x: 0, y: -1 },
14
14
  { x: -1, y: 0 },
15
15
  { x: 1, y: 0 },
16
16
  { x: 0, y: 1 },
17
17
  ];
18
- const orientationChars = {
18
+ export const orientationChars = {
19
19
  [Orientation.Up]: 'u',
20
20
  [Orientation.UpRight]: 'x',
21
21
  [Orientation.Right]: 'r',
@@ -83,7 +83,7 @@ export default class SerializerV0 extends SerializerBase {
83
83
  break;
84
84
  case 'r':
85
85
  rows.push(...value.split(',').map(row => {
86
- const match = row.match(/^v([\d.]*?)n(.*)$/);
86
+ const match = /^v([\d.]*?)n(.*)$/.exec(row);
87
87
  if (!match)
88
88
  return new Row(null, null);
89
89
  const [, velocity, note] = match;
@@ -108,7 +108,7 @@ export default class SerializerV0 extends SerializerBase {
108
108
  case ConfigType.Orientation:
109
109
  return (config.field +
110
110
  '=' +
111
- String(instruction[config.field]));
111
+ instruction[config.field]);
112
112
  case ConfigType.NullableBoolean:
113
113
  return (config.field +
114
114
  '=' +
@@ -139,7 +139,7 @@ export default class SerializerV0 extends SerializerBase {
139
139
  case ConfigType.Icon:
140
140
  return (config.field +
141
141
  '=' +
142
- escape(String(instruction[config.field])));
142
+ escape(instruction[config.field]));
143
143
  case ConfigType.NullableNote:
144
144
  return (config.field +
145
145
  '=' +
@@ -13,5 +13,5 @@ export default class AutoSolver extends Solver {
13
13
  private fixGrid;
14
14
  private solveWithProgress;
15
15
  private solveOne;
16
- solve(grid: GridData, abortSignal?: AbortSignal | undefined): AsyncGenerator<GridData | null>;
16
+ solve(grid: GridData, abortSignal?: AbortSignal): AsyncGenerator<GridData | null>;
17
17
  }
@@ -89,8 +89,10 @@ class AutoSolver extends Solver {
89
89
  for await (const updatedGrid of solver.solve(progress, abortSignal)) {
90
90
  if (abortSignal?.aborted)
91
91
  return;
92
- if (!updatedGrid)
93
- return updatedGrid;
92
+ if (!updatedGrid) {
93
+ yield updatedGrid;
94
+ return;
95
+ }
94
96
  yield this.fillSolution(grid, updatedGrid);
95
97
  }
96
98
  }
@@ -182,8 +182,7 @@ function getNextTile(grid, ratings) {
182
182
  highest = scores[y][x];
183
183
  pos = { x, y };
184
184
  }
185
- if (!fallback)
186
- fallback = { x, y };
185
+ fallback ?? (fallback = { x, y });
187
186
  }
188
187
  }
189
188
  return pos ?? fallback;
@@ -38,8 +38,7 @@ export default class DirectionLinkerBTModule extends BTModule {
38
38
  return [{ x: this.instr.x, y: this.instr.y }];
39
39
  }
40
40
  checkGlobal(grid) {
41
- if (this.initialPositions === null)
42
- this.initialPositions = this.getInitialPositions();
41
+ this.initialPositions ?? (this.initialPositions = this.getInitialPositions());
43
42
  const tilesNeedCheck = IntArray2D.create(grid.width, grid.height);
44
43
  const ratings = [];
45
44
  for (const pos of this.initialPositions) {
@@ -37,8 +37,7 @@ export default class FocusBTModule extends BTModule {
37
37
  }
38
38
  if (same > this.instr.number || same + gray < this.instr.number)
39
39
  return false;
40
- if (!this.cachedCheckResult)
41
- this.cachedCheckResult = this.buildCheckAndRating(grid);
40
+ this.cachedCheckResult ?? (this.cachedCheckResult = this.buildCheckAndRating(grid));
42
41
  return this.cachedCheckResult;
43
42
  }
44
43
  buildCheckAndRating(grid) {
@@ -35,8 +35,7 @@ export default class MinesweeperBTModule extends BTModule {
35
35
  }
36
36
  if (opposite > this.instr.number || opposite + gray < this.instr.number)
37
37
  return false;
38
- if (!this.cachedCheckResult)
39
- this.cachedCheckResult = this.buildCheckAndRating(grid);
38
+ this.cachedCheckResult ?? (this.cachedCheckResult = this.buildCheckAndRating(grid));
40
39
  return this.cachedCheckResult;
41
40
  }
42
41
  buildCheckAndRating(grid) {
@@ -82,7 +82,7 @@ class CspuzSolver extends EventIteratingSolver {
82
82
  }
83
83
  return true;
84
84
  }
85
- catch (ex) {
85
+ catch (_ex) {
86
86
  return false;
87
87
  }
88
88
  }
@@ -44,6 +44,10 @@ onmessage = e => {
44
44
  const puzzleData = gridToJson(grid);
45
45
  const solverResult = solveLogicPad(puzzleData, isUnderclued);
46
46
  postSolution(grid, solverResult);
47
+ if (isUnderclued) {
48
+ postMessage(null);
49
+ return;
50
+ }
47
51
  // Make use of the underclued mode to determine solution uniqueness
48
52
  if (solverResult !== null && !('error' in solverResult) && !isUnderclued) {
49
53
  const undercluedResult = solveLogicPad(puzzleData, true);
@@ -17,7 +17,7 @@ export default class EventIteratingSolver extends Solver {
17
17
  worker.terminate();
18
18
  return Promise.resolve(true);
19
19
  }
20
- catch (ex) {
20
+ catch (_ex) {
21
21
  return Promise.resolve(false);
22
22
  }
23
23
  }
@@ -38,7 +38,7 @@ export default class Z3Solver extends Solver {
38
38
  await init();
39
39
  return true;
40
40
  }
41
- catch (ex) {
41
+ catch (_ex) {
42
42
  return false;
43
43
  }
44
44
  }
@@ -2,9 +2,7 @@ import { AnyConfig } from '../config.js';
2
2
  import GridData from '../grid.js';
3
3
  import { Direction, State } from '../primitives.js';
4
4
  import Symbol from './symbol.js';
5
- export type DirectionLinkerMap = {
6
- [key in Direction]: Direction;
7
- };
5
+ export type DirectionLinkerMap = Record<Direction, Direction>;
8
6
  export default class DirectionLinkerSymbol extends Symbol {
9
7
  readonly x: number;
10
8
  readonly y: number;
package/dist/index.d.ts CHANGED
@@ -40,12 +40,14 @@ import UniqueShapeRule from './data/rules/uniqueShapeRule.js';
40
40
  import WrapAroundRule from './data/rules/wrapAroundRule.js';
41
41
  import { Serializer } from './data/serializer/allSerializers.js';
42
42
  import { Compressor } from './data/serializer/compressor/allCompressors.js';
43
+ import ChecksumCompressor from './data/serializer/compressor/checksumCompressor.js';
43
44
  import CompressorBase from './data/serializer/compressor/compressorBase.js';
44
45
  import DeflateCompressor from './data/serializer/compressor/deflateCompressor.js';
45
46
  import GzipCompressor from './data/serializer/compressor/gzipCompressor.js';
46
47
  import StreamCompressor from './data/serializer/compressor/streamCompressor.js';
47
48
  import SerializerBase from './data/serializer/serializerBase.js';
48
- import SerializerV0 from './data/serializer/serializer_v0.js';
49
+ import SerializerChecksum from './data/serializer/serializer_checksum.js';
50
+ import SerializerV0, { OFFSETS, orientationChars } from './data/serializer/serializer_v0.js';
49
51
  import { getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape } from './data/shapes.js';
50
52
  import { allSolvers } from './data/solver/allSolvers.js';
51
53
  import AutoSolver from './data/solver/auto/autoSolver.js';
@@ -108,4 +110,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
108
110
  import TileData from './data/tile.js';
109
111
  import TileConnections from './data/tileConnections.js';
110
112
  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, puzzleEquals, 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, };
113
+ 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, puzzleEquals, 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, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
package/dist/index.js CHANGED
@@ -43,12 +43,14 @@ import UniqueShapeRule from './data/rules/uniqueShapeRule.js';
43
43
  import WrapAroundRule from './data/rules/wrapAroundRule.js';
44
44
  import { Serializer } from './data/serializer/allSerializers.js';
45
45
  import { Compressor } from './data/serializer/compressor/allCompressors.js';
46
+ import ChecksumCompressor from './data/serializer/compressor/checksumCompressor.js';
46
47
  import CompressorBase from './data/serializer/compressor/compressorBase.js';
47
48
  import DeflateCompressor from './data/serializer/compressor/deflateCompressor.js';
48
49
  import GzipCompressor from './data/serializer/compressor/gzipCompressor.js';
49
50
  import StreamCompressor from './data/serializer/compressor/streamCompressor.js';
50
51
  import SerializerBase from './data/serializer/serializerBase.js';
51
- import SerializerV0 from './data/serializer/serializer_v0.js';
52
+ import SerializerChecksum from './data/serializer/serializer_checksum.js';
53
+ import SerializerV0, { OFFSETS, orientationChars } from './data/serializer/serializer_v0.js';
52
54
  import { getShapeVariants, normalizeShape, positionsToShape, sanitizePatternGrid, shapeEquals, tilesToShape } from './data/shapes.js';
53
55
  import { allSolvers } from './data/solver/allSolvers.js';
54
56
  import AutoSolver from './data/solver/auto/autoSolver.js';
@@ -111,4 +113,4 @@ import ViewpointSymbol from './data/symbols/viewpointSymbol.js';
111
113
  import TileData from './data/tile.js';
112
114
  import TileConnections from './data/tileConnections.js';
113
115
  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, puzzleEquals, 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, };
116
+ 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, puzzleEquals, 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, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logic-pad/core",
3
- "version": "0.12.5",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -51,38 +51,21 @@
51
51
  "bun": ">=1.1.0"
52
52
  },
53
53
  "dependencies": {
54
- "base64-arraybuffer": "^1.0.2",
55
54
  "compression-streams-polyfill": "^0.1.7",
56
- "dedent": "^1.5.3",
57
55
  "event-iterator": "^2.0.0",
58
- "events": "^3.3.0",
59
56
  "grilops": "^0.1.2",
60
- "lodash": "^4.17.21",
61
57
  "logic-pad-solver-core": "^0.1.2",
62
58
  "z3-solver": "^4.13.0",
63
- "zod": "^3.24.1"
59
+ "zod": "^4.0.17"
64
60
  },
65
61
  "devDependencies": {
66
- "@types/bun": "^1.0.12",
67
- "@types/dts-bundle": "^0.0.35",
68
- "@types/lodash": "^4.17.0",
69
- "@typescript-eslint/eslint-plugin": "^7.1.0",
70
- "@typescript-eslint/parser": "^7.1.0",
62
+ "@types/bun": "^1.2.20",
63
+ "@types/glob": "^9.0.0",
71
64
  "dts-bundle-generator": "^9.5.1",
72
- "eslint": "^8.57.0",
73
- "eslint-config-import": "^0.13.0",
74
- "eslint-config-prettier": "^9.1.0",
75
- "eslint-config-standard": "^17.1.0",
76
- "eslint-import-resolver-typescript": "^3.6.1",
77
- "eslint-plugin-import": "^2.29.1",
78
- "eslint-plugin-n": "^16.6.2",
79
- "eslint-plugin-prettier": "^5.1.3",
80
- "eslint-plugin-promise": "^6.1.1",
81
- "eslint-plugin-standard": "^5.0.0",
82
- "fast-glob": "^3.3.2",
83
- "prettier": "^3.2.5",
84
- "rimraf": "^5.0.5",
85
- "typescript": "^5.4.5"
65
+ "fast-glob": "^3.3.3",
66
+ "prettier": "^3.6.2",
67
+ "rimraf": "^6.0.1",
68
+ "typescript": "^5.9.2"
86
69
  },
87
70
  "trustedDependencies": [
88
71
  "esbuild"