@logic-pad/core 0.22.0 → 0.23.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.
@@ -1448,6 +1448,16 @@ declare global {
1448
1448
  export declare function handlesSymbolDisplay<T extends Instruction>(
1449
1449
  val: T
1450
1450
  ): val is T & SymbolDisplayHandler;
1451
+ export interface SymbolMergeHandler {
1452
+ /**
1453
+ * Determines if the description of two symbols can be merged when displayed in the UI.
1454
+ * @param other The other symbol to compare against.
1455
+ */
1456
+ descriptionEquals(other: Symbol$1): boolean;
1457
+ }
1458
+ export declare function handlesSymbolMerge<T extends Instruction>(
1459
+ val: T
1460
+ ): val is T & SymbolMergeHandler;
1451
1461
  export interface SymbolValidationHandler {
1452
1462
  /**
1453
1463
  * Overrides the validation of symbols.
@@ -1660,7 +1670,7 @@ declare global {
1660
1670
  copyWith({ color }: { color?: Color }): this;
1661
1671
  withColor(color: Color): this;
1662
1672
  }
1663
- export declare class CollectZonesRule extends Rule {
1673
+ export declare class ConnectZonesRule extends Rule {
1664
1674
  readonly color: Color;
1665
1675
  readonly title = 'Connect Zones';
1666
1676
  private static readonly CONFIGS;
@@ -2641,17 +2651,23 @@ declare global {
2641
2651
  y: number
2642
2652
  ): Position$1 | null;
2643
2653
  }
2644
- export declare class FocusSymbol extends NumberSymbol {
2645
- readonly title = 'Focus Number';
2654
+ export declare class FocusSymbol
2655
+ extends NumberSymbol
2656
+ implements SymbolMergeHandler
2657
+ {
2658
+ readonly deadEnd: boolean;
2659
+ get title(): string;
2646
2660
  private static readonly CONFIGS;
2647
2661
  private static readonly EXAMPLE_GRID;
2662
+ private static readonly EXAMPLE_GRID_DEAD_END;
2648
2663
  /**
2649
2664
  * **Focus Numbers count directly adjacent cells of the same color**
2650
2665
  * @param x - The x-coordinate of the symbol.
2651
2666
  * @param y - The y-coordinate of the symbol.
2667
+ * @param deadEnd - Whether this Focus Number is a Dead End.
2652
2668
  * @param number - The focus number.
2653
2669
  */
2654
- constructor(x: number, y: number, number: number);
2670
+ constructor(x: number, y: number, deadEnd: boolean, number: number);
2655
2671
  get id(): string;
2656
2672
  get placementStep(): number;
2657
2673
  get explanation(): string;
@@ -2662,16 +2678,20 @@ declare global {
2662
2678
  completed: number;
2663
2679
  possible: number;
2664
2680
  };
2681
+ descriptionEquals(other: Symbol$1): boolean;
2665
2682
  copyWith({
2666
2683
  x,
2667
2684
  y,
2685
+ deadEnd,
2668
2686
  number,
2669
2687
  }: {
2670
2688
  x?: number;
2671
2689
  y?: number;
2690
+ deadEnd?: boolean;
2672
2691
  number?: number;
2673
2692
  }): this;
2674
2693
  withNumber(number: number): this;
2694
+ withDeadEnd(deadEnd: boolean): this;
2675
2695
  }
2676
2696
  export declare class FocusBTModule extends BTModule {
2677
2697
  instr: FocusSymbol;
@@ -2826,15 +2846,10 @@ declare global {
2826
2846
  checkGlobal(grid: BTGridData): CheckResult | false;
2827
2847
  private buildCheckAndRating;
2828
2848
  }
2829
- export declare abstract class MultiEntrySymbol extends Symbol$1 {
2830
- /**
2831
- * Determines if the description of two MultiEntrySymbols can be merged when displayed in the UI.
2832
- * @param other - The other MultiEntrySymbol to compare to.
2833
- * @returns Whether the two MultiEntrySymbols have the same description.
2834
- */
2835
- descriptionEquals(other: Instruction): boolean;
2836
- }
2837
- export declare class MyopiaSymbol extends MultiEntrySymbol {
2849
+ export declare class MyopiaSymbol
2850
+ extends Symbol$1
2851
+ implements SymbolMergeHandler
2852
+ {
2838
2853
  readonly diagonals: boolean;
2839
2854
  readonly directions: OrientationToggle;
2840
2855
  get title(): 'Framed Myopia Arrow' | 'Myopia Arrow';
@@ -2860,6 +2875,7 @@ declare global {
2860
2875
  get configs(): readonly AnyConfig[] | null;
2861
2876
  createExampleGrid(): GridData;
2862
2877
  validateSymbol(grid: GridData): State;
2878
+ descriptionEquals(other: Symbol$1): boolean;
2863
2879
  copyWith({
2864
2880
  x,
2865
2881
  y,
@@ -3030,7 +3046,10 @@ declare global {
3030
3046
  isInstructionSupported(instructionId: string): boolean;
3031
3047
  isGridSupported(grid: GridData): boolean;
3032
3048
  }
3033
- export declare abstract class CustomSymbol extends MultiEntrySymbol {
3049
+ export declare abstract class CustomSymbol
3050
+ extends Symbol$1
3051
+ implements SymbolMergeHandler
3052
+ {
3034
3053
  readonly description: string;
3035
3054
  readonly grid: GridData;
3036
3055
  /**
@@ -3046,6 +3065,7 @@ declare global {
3046
3065
  createExampleGrid(): GridData;
3047
3066
  validateSymbol(_grid: GridData): State;
3048
3067
  get validateWithSolution(): boolean;
3068
+ descriptionEquals(other: Symbol$1): boolean;
3049
3069
  withDescription(description: string): this;
3050
3070
  withGrid(grid: GridData): this;
3051
3071
  }
@@ -0,0 +1,10 @@
1
+ import Instruction from '../instruction.js';
2
+ import Symbol from '../symbols/symbol.js';
3
+ export interface SymbolMergeHandler {
4
+ /**
5
+ * Determines if the description of two symbols can be merged when displayed in the UI.
6
+ * @param other The other symbol to compare against.
7
+ */
8
+ descriptionEquals(other: Symbol): boolean;
9
+ }
10
+ export declare function handlesSymbolMerge<T extends Instruction>(val: T): val is T & SymbolMergeHandler;
@@ -0,0 +1,4 @@
1
+ import { isEventHandler } from './eventHelper.js';
2
+ export function handlesSymbolMerge(val) {
3
+ return isEventHandler(val, 'descriptionEquals');
4
+ }
@@ -2,7 +2,7 @@ import { AnyConfig } from '../config.js';
2
2
  import GridData from '../grid.js';
3
3
  import { Color, RuleState } from '../primitives.js';
4
4
  import Rule, { SearchVariant } from './rule.js';
5
- export default class CollectZonesRule extends Rule {
5
+ export default class ConnectZonesRule extends Rule {
6
6
  readonly color: Color;
7
7
  readonly title = "Connect Zones";
8
8
  private static readonly CONFIGS;
@@ -26,4 +26,4 @@ export default class CollectZonesRule extends Rule {
26
26
  }): this;
27
27
  withColor(color: Color): this;
28
28
  }
29
- export declare const instance: CollectZonesRule;
29
+ export declare const instance: ConnectZonesRule;
@@ -3,7 +3,8 @@ import GridData from '../grid.js';
3
3
  import { array, minBy } from '../dataHelper.js';
4
4
  import { Color, State } from '../primitives.js';
5
5
  import Rule from './rule.js';
6
- class CollectZonesRule extends Rule {
6
+ import GridZones from '../gridZones.js';
7
+ class ConnectZonesRule extends Rule {
7
8
  /**
8
9
  * **Connect all &lt;color&gt; cells in each zone**
9
10
  *
@@ -32,15 +33,15 @@ class CollectZonesRule extends Rule {
32
33
  return `Connect all ${this.color} cells in each zone`;
33
34
  }
34
35
  get configs() {
35
- return CollectZonesRule.CONFIGS;
36
+ return ConnectZonesRule.CONFIGS;
36
37
  }
37
38
  createExampleGrid() {
38
39
  return this.color === Color.Light
39
- ? CollectZonesRule.EXAMPLE_GRID_LIGHT
40
- : CollectZonesRule.EXAMPLE_GRID_DARK;
40
+ ? ConnectZonesRule.EXAMPLE_GRID_LIGHT
41
+ : ConnectZonesRule.EXAMPLE_GRID_DARK;
41
42
  }
42
43
  get searchVariants() {
43
- return CollectZonesRule.SEARCH_VARIANTS;
44
+ return ConnectZonesRule.SEARCH_VARIANTS;
44
45
  }
45
46
  validateGrid(grid) {
46
47
  let complete = true;
@@ -86,13 +87,13 @@ class CollectZonesRule extends Rule {
86
87
  return { state: complete ? State.Satisfied : State.Incomplete };
87
88
  }
88
89
  copyWith({ color }) {
89
- return new CollectZonesRule(color ?? this.color);
90
+ return new ConnectZonesRule(color ?? this.color);
90
91
  }
91
92
  withColor(color) {
92
93
  return this.copyWith({ color });
93
94
  }
94
95
  }
95
- Object.defineProperty(CollectZonesRule, "CONFIGS", {
96
+ Object.defineProperty(ConnectZonesRule, "CONFIGS", {
96
97
  enumerable: true,
97
98
  configurable: true,
98
99
  writable: true,
@@ -107,26 +108,34 @@ Object.defineProperty(CollectZonesRule, "CONFIGS", {
107
108
  },
108
109
  ])
109
110
  });
110
- Object.defineProperty(CollectZonesRule, "EXAMPLE_GRID_LIGHT", {
111
+ Object.defineProperty(ConnectZonesRule, "EXAMPLE_GRID_LIGHT", {
111
112
  enumerable: true,
112
113
  configurable: true,
113
114
  writable: true,
114
- value: Object.freeze(GridData.create(['bwwwb', 'bwbww', 'wwwbb', 'wbwww']))
115
+ value: Object.freeze(GridData.create(['wbbwb', 'wbbwb', 'wbbww', 'wwbbb'])
116
+ .withZones(new GridZones([
117
+ { x1: 2, y1: 1, x2: 2, y2: 2 },
118
+ { x1: 1, y1: 0, x2: 2, y2: 0 },
119
+ { x1: 1, y1: 1, x2: 2, y2: 1 },
120
+ { x1: 2, y1: 2, x2: 3, y2: 2 },
121
+ { x1: 2, y1: 3, x2: 3, y2: 3 },
122
+ ]))
123
+ .addRule(new ConnectZonesRule(Color.Light)))
115
124
  });
116
- Object.defineProperty(CollectZonesRule, "EXAMPLE_GRID_DARK", {
125
+ Object.defineProperty(ConnectZonesRule, "EXAMPLE_GRID_DARK", {
117
126
  enumerable: true,
118
127
  configurable: true,
119
128
  writable: true,
120
- value: Object.freeze(GridData.create(['wbbbw', 'wbwbb', 'bbbww', 'bwbbb']))
129
+ value: Object.freeze(ConnectZonesRule.EXAMPLE_GRID_LIGHT.withTiles(tiles => tiles.map(row => row.map(tile => tile.withColor(tile.color === Color.Dark ? Color.Light : Color.Dark)))))
121
130
  });
122
- Object.defineProperty(CollectZonesRule, "SEARCH_VARIANTS", {
131
+ Object.defineProperty(ConnectZonesRule, "SEARCH_VARIANTS", {
123
132
  enumerable: true,
124
133
  configurable: true,
125
134
  writable: true,
126
135
  value: [
127
- new CollectZonesRule(Color.Light).searchVariant(),
128
- new CollectZonesRule(Color.Dark).searchVariant(),
136
+ new ConnectZonesRule(Color.Light).searchVariant(),
137
+ new ConnectZonesRule(Color.Dark).searchVariant(),
129
138
  ]
130
139
  });
131
- export default CollectZonesRule;
132
- export const instance = new CollectZonesRule(Color.Dark);
140
+ export default ConnectZonesRule;
141
+ export const instance = new ConnectZonesRule(Color.Dark);
@@ -2,7 +2,7 @@ export { instance as BanPatternRule } from './banPatternRule.js';
2
2
  export { instance as CellCountRule } from './cellCountRule.js';
3
3
  export { instance as CompletePatternRule } from './completePatternRule.js';
4
4
  export { instance as ConnectAllRule } from './connectAllRule.js';
5
- export { instance as CollectZonesRule } from './connectZonesRule.js';
5
+ export { instance as ConnectZonesRule } from './connectZonesRule.js';
6
6
  export { instance as ContainsShapeRule } from './containsShapeRule.js';
7
7
  export { instance as CustomRule } from './customRule.js';
8
8
  export { instance as DifferentCountPerZoneRule } from './differentCountPerZoneRule.js';
@@ -6,7 +6,7 @@ export { instance as BanPatternRule } from './banPatternRule.js';
6
6
  export { instance as CellCountRule } from './cellCountRule.js';
7
7
  export { instance as CompletePatternRule } from './completePatternRule.js';
8
8
  export { instance as ConnectAllRule } from './connectAllRule.js';
9
- export { instance as CollectZonesRule } from './connectZonesRule.js';
9
+ export { instance as ConnectZonesRule } from './connectZonesRule.js';
10
10
  export { instance as ContainsShapeRule } from './containsShapeRule.js';
11
11
  export { instance as CustomRule } from './customRule.js';
12
12
  export { instance as DifferentCountPerZoneRule } from './differentCountPerZoneRule.js';
@@ -1,7 +1,8 @@
1
+ import { SymbolMergeHandler } from '../events/onSymbolMerge.js';
1
2
  import GridData from '../grid.js';
2
3
  import { State } from '../primitives.js';
3
- import MultiEntrySymbol from './multiEntrySymbol.js';
4
- export default abstract class CustomSymbol extends MultiEntrySymbol {
4
+ import Symbol from './symbol.js';
5
+ export default abstract class CustomSymbol extends Symbol implements SymbolMergeHandler {
5
6
  readonly description: string;
6
7
  readonly grid: GridData;
7
8
  /**
@@ -17,6 +18,7 @@ export default abstract class CustomSymbol extends MultiEntrySymbol {
17
18
  createExampleGrid(): GridData;
18
19
  validateSymbol(_grid: GridData): State;
19
20
  get validateWithSolution(): boolean;
21
+ descriptionEquals(other: Symbol): boolean;
20
22
  withDescription(description: string): this;
21
23
  withGrid(grid: GridData): this;
22
24
  }
@@ -1,6 +1,6 @@
1
1
  import { State } from '../primitives.js';
2
- import MultiEntrySymbol from './multiEntrySymbol.js';
3
- export default class CustomSymbol extends MultiEntrySymbol {
2
+ import Symbol from './symbol.js';
3
+ export default class CustomSymbol extends Symbol {
4
4
  /**
5
5
  * **A custom symbol**
6
6
  *
@@ -38,6 +38,11 @@ export default class CustomSymbol extends MultiEntrySymbol {
38
38
  get validateWithSolution() {
39
39
  return true;
40
40
  }
41
+ descriptionEquals(other) {
42
+ return (this.id === other.id &&
43
+ this.explanation === other.explanation &&
44
+ this.createExampleGrid().equals(other.createExampleGrid()));
45
+ }
41
46
  withDescription(description) {
42
47
  return this.copyWith({ description });
43
48
  }
@@ -1,17 +1,22 @@
1
1
  import { AnyConfig } from '../config.js';
2
+ import { SymbolMergeHandler } from '../events/onSymbolMerge.js';
2
3
  import GridData from '../grid.js';
3
4
  import NumberSymbol from './numberSymbol.js';
4
- export default class FocusSymbol extends NumberSymbol {
5
- readonly title = "Focus Number";
5
+ import Symbol from './symbol.js';
6
+ export default class FocusSymbol extends NumberSymbol implements SymbolMergeHandler {
7
+ readonly deadEnd: boolean;
8
+ get title(): string;
6
9
  private static readonly CONFIGS;
7
10
  private static readonly EXAMPLE_GRID;
11
+ private static readonly EXAMPLE_GRID_DEAD_END;
8
12
  /**
9
13
  * **Focus Numbers count directly adjacent cells of the same color**
10
14
  * @param x - The x-coordinate of the symbol.
11
15
  * @param y - The y-coordinate of the symbol.
16
+ * @param deadEnd - Whether this Focus Number is a Dead End.
12
17
  * @param number - The focus number.
13
18
  */
14
- constructor(x: number, y: number, number: number);
19
+ constructor(x: number, y: number, deadEnd: boolean, number: number);
15
20
  get id(): string;
16
21
  get placementStep(): number;
17
22
  get explanation(): string;
@@ -22,11 +27,14 @@ export default class FocusSymbol extends NumberSymbol {
22
27
  completed: number;
23
28
  possible: number;
24
29
  };
25
- copyWith({ x, y, number, }: {
30
+ descriptionEquals(other: Symbol): boolean;
31
+ copyWith({ x, y, deadEnd, number, }: {
26
32
  x?: number;
27
33
  y?: number;
34
+ deadEnd?: boolean;
28
35
  number?: number;
29
36
  }): this;
30
37
  withNumber(number: number): this;
38
+ withDeadEnd(deadEnd: boolean): this;
31
39
  }
32
40
  export declare const instance: FocusSymbol;
@@ -1,6 +1,8 @@
1
1
  import { ConfigType } from '../config.js';
2
2
  import GridData from '../grid.js';
3
3
  import { Color } from '../primitives.js';
4
+ import AreaNumberSymbol from './areaNumberSymbol.js';
5
+ import LetterSymbol from './letterSymbol.js';
4
6
  import NumberSymbol from './numberSymbol.js';
5
7
  const OFFSETS = [
6
8
  [0, -1],
@@ -9,20 +11,33 @@ const OFFSETS = [
9
11
  [-1, 0],
10
12
  ];
11
13
  class FocusSymbol extends NumberSymbol {
14
+ get title() {
15
+ if (this.deadEnd) {
16
+ return 'Dead End';
17
+ }
18
+ else {
19
+ return 'Focus Number';
20
+ }
21
+ }
12
22
  /**
13
23
  * **Focus Numbers count directly adjacent cells of the same color**
14
24
  * @param x - The x-coordinate of the symbol.
15
25
  * @param y - The y-coordinate of the symbol.
26
+ * @param deadEnd - Whether this Focus Number is a Dead End.
16
27
  * @param number - The focus number.
17
28
  */
18
- constructor(x, y, number) {
29
+ constructor(x, y, deadEnd, number) {
30
+ if (deadEnd) {
31
+ number = 1;
32
+ }
19
33
  super(x, y, number);
20
- Object.defineProperty(this, "title", {
34
+ Object.defineProperty(this, "deadEnd", {
21
35
  enumerable: true,
22
36
  configurable: true,
23
37
  writable: true,
24
- value: 'Focus Number'
38
+ value: deadEnd
25
39
  });
40
+ this.deadEnd = deadEnd;
26
41
  }
27
42
  get id() {
28
43
  return `focus`;
@@ -31,13 +46,23 @@ class FocusSymbol extends NumberSymbol {
31
46
  return 1;
32
47
  }
33
48
  get explanation() {
34
- return '*Focus Numbers* count directly adjacent cells of the same color';
49
+ if (this.deadEnd) {
50
+ return `*Dead Ends* connect to one adjacent cell of the same color`;
51
+ }
52
+ else {
53
+ return '*Focus Numbers* count directly adjacent cells of the same color';
54
+ }
35
55
  }
36
56
  get configs() {
37
57
  return FocusSymbol.CONFIGS;
38
58
  }
39
59
  createExampleGrid() {
40
- return FocusSymbol.EXAMPLE_GRID;
60
+ if (this.deadEnd) {
61
+ return FocusSymbol.EXAMPLE_GRID_DEAD_END;
62
+ }
63
+ else {
64
+ return FocusSymbol.EXAMPLE_GRID;
65
+ }
41
66
  }
42
67
  countForColor(grid, color) {
43
68
  let gray = 0;
@@ -76,12 +101,18 @@ class FocusSymbol extends NumberSymbol {
76
101
  }
77
102
  return this.countForColor(grid, color);
78
103
  }
79
- copyWith({ x, y, number, }) {
80
- return new FocusSymbol(x ?? this.x, y ?? this.y, number ?? this.number);
104
+ descriptionEquals(other) {
105
+ return this.id === other.id && this.explanation === other.explanation;
106
+ }
107
+ copyWith({ x, y, deadEnd, number, }) {
108
+ return new FocusSymbol(x ?? this.x, y ?? this.y, deadEnd ?? this.deadEnd, number ?? this.number);
81
109
  }
82
110
  withNumber(number) {
83
111
  return this.copyWith({ number });
84
112
  }
113
+ withDeadEnd(deadEnd) {
114
+ return this.copyWith({ deadEnd });
115
+ }
85
116
  }
86
117
  Object.defineProperty(FocusSymbol, "CONFIGS", {
87
118
  enumerable: true,
@@ -102,11 +133,20 @@ Object.defineProperty(FocusSymbol, "CONFIGS", {
102
133
  description: 'Y',
103
134
  configurable: false,
104
135
  },
136
+ {
137
+ type: ConfigType.Boolean,
138
+ default: false,
139
+ field: 'deadEnd',
140
+ description: 'Dead End',
141
+ explanation: 'A Dead End is a Focus Number of 1 that can be stacked with other symbols.',
142
+ configurable: true,
143
+ },
105
144
  {
106
145
  type: ConfigType.Number,
107
146
  default: 1,
108
147
  field: 'number',
109
148
  description: 'Number',
149
+ explanation: 'Must be 1 for Dead Ends. Between 0 and 4 for Focus Numbers.',
110
150
  configurable: true,
111
151
  },
112
152
  ])
@@ -116,10 +156,24 @@ Object.defineProperty(FocusSymbol, "EXAMPLE_GRID", {
116
156
  configurable: true,
117
157
  writable: true,
118
158
  value: Object.freeze(GridData.create(['wwwww', 'bbbbw', 'wwbbw', 'wwwww']).withSymbols([
119
- new FocusSymbol(0, 0, 1),
120
- new FocusSymbol(4, 1, 2),
121
- new FocusSymbol(1, 3, 3),
159
+ new FocusSymbol(0, 0, false, 1),
160
+ new FocusSymbol(4, 1, false, 2),
161
+ new FocusSymbol(1, 3, false, 3),
162
+ ]))
163
+ });
164
+ Object.defineProperty(FocusSymbol, "EXAMPLE_GRID_DEAD_END", {
165
+ enumerable: true,
166
+ configurable: true,
167
+ writable: true,
168
+ value: Object.freeze(GridData.create(['wwwww', 'bbbbw', 'wwwbw', 'bbbbw']).withSymbols([
169
+ new FocusSymbol(0, 0, true, 1),
170
+ new FocusSymbol(4, 3, true, 1),
171
+ new FocusSymbol(0, 2, true, 1),
172
+ new FocusSymbol(2, 2, true, 1),
173
+ new AreaNumberSymbol(0, 2, 3),
174
+ new LetterSymbol(0, 0, 'A'),
175
+ new LetterSymbol(4, 3, 'A'),
122
176
  ]))
123
177
  });
124
178
  export default FocusSymbol;
125
- export const instance = new FocusSymbol(0, 0, 1);
179
+ export const instance = new FocusSymbol(0, 0, false, 1);
@@ -1,8 +1,9 @@
1
1
  import { AnyConfig } from '../config.js';
2
+ import { SymbolMergeHandler } from '../events/onSymbolMerge.js';
2
3
  import GridData from '../grid.js';
3
4
  import { OrientationToggle, State } from '../primitives.js';
4
- import MultiEntrySymbol from './multiEntrySymbol.js';
5
- export default class MyopiaSymbol extends MultiEntrySymbol {
5
+ import Symbol from './symbol.js';
6
+ export default class MyopiaSymbol extends Symbol implements SymbolMergeHandler {
6
7
  readonly diagonals: boolean;
7
8
  readonly directions: OrientationToggle;
8
9
  get title(): "Framed Myopia Arrow" | "Myopia Arrow";
@@ -23,6 +24,7 @@ export default class MyopiaSymbol extends MultiEntrySymbol {
23
24
  get configs(): readonly AnyConfig[] | null;
24
25
  createExampleGrid(): GridData;
25
26
  validateSymbol(grid: GridData): State;
27
+ descriptionEquals(other: Symbol): boolean;
26
28
  copyWith({ x, y, diagonals, directions, }: {
27
29
  x?: number;
28
30
  y?: number;
@@ -2,8 +2,8 @@ import { ConfigType } from '../config.js';
2
2
  import { move } from '../dataHelper.js';
3
3
  import GridData from '../grid.js';
4
4
  import { Color, ORIENTATIONS, Orientation, State, orientationToggle, } from '../primitives.js';
5
- import MultiEntrySymbol from './multiEntrySymbol.js';
6
- class MyopiaSymbol extends MultiEntrySymbol {
5
+ import Symbol from './symbol.js';
6
+ class MyopiaSymbol extends Symbol {
7
7
  get title() {
8
8
  return this.diagonals ? 'Framed Myopia Arrow' : 'Myopia Arrow';
9
9
  }
@@ -134,6 +134,9 @@ class MyopiaSymbol extends MultiEntrySymbol {
134
134
  return State.Satisfied;
135
135
  return State.Incomplete;
136
136
  }
137
+ descriptionEquals(other) {
138
+ return this.id === other.id && this.explanation === other.explanation;
139
+ }
137
140
  copyWith({ x, y, diagonals, directions, }) {
138
141
  return new MyopiaSymbol(x ?? this.x, y ?? this.y, diagonals ?? this.diagonals, directions ?? this.directions);
139
142
  }
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import { handlesGridChange } from './data/events/onGridChange.js';
8
8
  import { handlesGridResize } from './data/events/onGridResize.js';
9
9
  import { handlesSetGrid, invokeSetGrid } from './data/events/onSetGrid.js';
10
10
  import { handlesSymbolDisplay } from './data/events/onSymbolDisplay.js';
11
+ import { handlesSymbolMerge } from './data/events/onSymbolMerge.js';
11
12
  import { handlesSymbolValidation } from './data/events/onSymbolValidation.js';
12
13
  import GridData, { NEIGHBOR_OFFSETS } from './data/grid.js';
13
14
  import GridConnections from './data/gridConnections.js';
@@ -20,7 +21,7 @@ import CellCountPerZoneRule from './data/rules/cellCountPerZoneRule.js';
20
21
  import CellCountRule from './data/rules/cellCountRule.js';
21
22
  import CompletePatternRule from './data/rules/completePatternRule.js';
22
23
  import ConnectAllRule from './data/rules/connectAllRule.js';
23
- import CollectZonesRule from './data/rules/connectZonesRule.js';
24
+ import ConnectZonesRule from './data/rules/connectZonesRule.js';
24
25
  import ContainsShapeRule from './data/rules/containsShapeRule.js';
25
26
  import CustomRule from './data/rules/customRule.js';
26
27
  import DifferentCountPerZoneRule from './data/rules/differentCountPerZoneRule.js';
@@ -107,7 +108,6 @@ import { allSymbols } from './data/symbols/index.js';
107
108
  import LetterSymbol from './data/symbols/letterSymbol.js';
108
109
  import LotusSymbol from './data/symbols/lotusSymbol.js';
109
110
  import MinesweeperSymbol from './data/symbols/minesweeperSymbol.js';
110
- import MultiEntrySymbol from './data/symbols/multiEntrySymbol.js';
111
111
  import MyopiaSymbol from './data/symbols/myopiaSymbol.js';
112
112
  import NumberSymbol from './data/symbols/numberSymbol.js';
113
113
  import Symbol from './data/symbols/symbol.js';
@@ -116,4 +116,4 @@ import TileData from './data/tile.js';
116
116
  import TileConnections from './data/tileConnections.js';
117
117
  import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
118
118
  import { GridValidator } from './data/validateAsync.js';
119
- 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, 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, CollectZonesRule, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, GridValidator, };
119
+ 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, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, GridValidator, };
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { handlesGridChange } from './data/events/onGridChange.js';
11
11
  import { handlesGridResize } from './data/events/onGridResize.js';
12
12
  import { handlesSetGrid, invokeSetGrid } from './data/events/onSetGrid.js';
13
13
  import { handlesSymbolDisplay } from './data/events/onSymbolDisplay.js';
14
+ import { handlesSymbolMerge } from './data/events/onSymbolMerge.js';
14
15
  import { handlesSymbolValidation } from './data/events/onSymbolValidation.js';
15
16
  import GridData, { NEIGHBOR_OFFSETS } from './data/grid.js';
16
17
  import GridConnections from './data/gridConnections.js';
@@ -23,7 +24,7 @@ import CellCountPerZoneRule from './data/rules/cellCountPerZoneRule.js';
23
24
  import CellCountRule from './data/rules/cellCountRule.js';
24
25
  import CompletePatternRule from './data/rules/completePatternRule.js';
25
26
  import ConnectAllRule from './data/rules/connectAllRule.js';
26
- import CollectZonesRule from './data/rules/connectZonesRule.js';
27
+ import ConnectZonesRule from './data/rules/connectZonesRule.js';
27
28
  import ContainsShapeRule from './data/rules/containsShapeRule.js';
28
29
  import CustomRule from './data/rules/customRule.js';
29
30
  import DifferentCountPerZoneRule from './data/rules/differentCountPerZoneRule.js';
@@ -110,7 +111,6 @@ import { allSymbols } from './data/symbols/index.js';
110
111
  import LetterSymbol from './data/symbols/letterSymbol.js';
111
112
  import LotusSymbol from './data/symbols/lotusSymbol.js';
112
113
  import MinesweeperSymbol from './data/symbols/minesweeperSymbol.js';
113
- import MultiEntrySymbol from './data/symbols/multiEntrySymbol.js';
114
114
  import MyopiaSymbol from './data/symbols/myopiaSymbol.js';
115
115
  import NumberSymbol from './data/symbols/numberSymbol.js';
116
116
  import Symbol from './data/symbols/symbol.js';
@@ -119,4 +119,4 @@ import TileData from './data/tile.js';
119
119
  import TileConnections from './data/tileConnections.js';
120
120
  import validateGrid, { aggregateState, applyFinalOverrides } from './data/validate.js';
121
121
  import { GridValidator } from './data/validateAsync.js';
122
- 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, 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, CollectZonesRule, 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, FocusSymbol, GalaxySymbol, HiddenSymbol, HouseSymbol, allSymbols, LetterSymbol, LotusSymbol, MinesweeperSymbol, MultiEntrySymbol, MyopiaSymbol, NumberSymbol, Symbol, ViewpointSymbol, TileData, TileConnections, validateGrid, aggregateState, applyFinalOverrides, GridValidator, };
122
+ 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, 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.22.0",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -1,11 +0,0 @@
1
- import Instruction from '../instruction.js';
2
- import Symbol from './symbol.js';
3
- export default abstract class MultiEntrySymbol extends Symbol {
4
- /**
5
- * Determines if the description of two MultiEntrySymbols can be merged when displayed in the UI.
6
- * @param other - The other MultiEntrySymbol to compare to.
7
- * @returns Whether the two MultiEntrySymbols have the same description.
8
- */
9
- descriptionEquals(other: Instruction): boolean;
10
- }
11
- export declare const instance: undefined;
@@ -1,14 +0,0 @@
1
- import Symbol from './symbol.js';
2
- export default class MultiEntrySymbol extends Symbol {
3
- /**
4
- * Determines if the description of two MultiEntrySymbols can be merged when displayed in the UI.
5
- * @param other - The other MultiEntrySymbol to compare to.
6
- * @returns Whether the two MultiEntrySymbols have the same description.
7
- */
8
- descriptionEquals(other) {
9
- return (this.id === other.id &&
10
- this.explanation === other.explanation &&
11
- this.createExampleGrid().equals(other.createExampleGrid()));
12
- }
13
- }
14
- export const instance = undefined;