@logic-pad/core 0.12.5 → 0.12.6

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>>;
1428
+ grid: z.ZodCustom<GridData, GridData>;
1429
+ solution: z.ZodNullable<z.ZodCustom<GridData, GridData>>;
1451
1430
  },
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;
1461
- },
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
  /**
@@ -2191,7 +2153,7 @@ declare global {
2191
2153
  private solveOne;
2192
2154
  solve(
2193
2155
  grid: GridData,
2194
- abortSignal?: AbortSignal | undefined
2156
+ abortSignal?: AbortSignal
2195
2157
  ): AsyncGenerator<GridData | null>;
2196
2158
  }
2197
2159
  export declare abstract class EventIteratingSolver extends Solver {
@@ -2412,9 +2374,7 @@ declare global {
2412
2374
  checkGlobal(grid: BTGridData): CheckResult | false;
2413
2375
  private buildCheckAndRating;
2414
2376
  }
2415
- export type DirectionLinkerMap = {
2416
- [key in Direction]: Direction;
2417
- };
2377
+ export type DirectionLinkerMap = Record<Direction, Direction>;
2418
2378
  export declare class DirectionLinkerSymbol extends Symbol$1 {
2419
2379
  readonly x: number;
2420
2380
  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) {
@@ -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';
@@ -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
  }
@@ -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
  }
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logic-pad/core",
3
- "version": "0.12.5",
3
+ "version": "0.12.6",
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"