@logic-pad/core 0.1.4 → 0.2.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.
Files changed (37) hide show
  1. package/assets/logic-core.global.d.ts +383 -305
  2. package/dist/data/dataHelper.d.ts +8 -0
  3. package/dist/data/dataHelper.js +31 -0
  4. package/dist/data/events/onSymbolDisplay.d.ts +15 -0
  5. package/dist/data/events/onSymbolDisplay.js +4 -0
  6. package/dist/data/grid.d.ts +7 -0
  7. package/dist/data/grid.js +23 -2
  8. package/dist/data/instruction.d.ts +1 -0
  9. package/dist/data/instruction.js +3 -0
  10. package/dist/data/primitives.d.ts +8 -0
  11. package/dist/data/primitives.js +9 -0
  12. package/dist/data/rules/completePatternRule.js +2 -2
  13. package/dist/data/rules/foresightRule.d.ts +1 -0
  14. package/dist/data/rules/foresightRule.js +3 -0
  15. package/dist/data/rules/musicGridRule.js +2 -2
  16. package/dist/data/rules/offByXRule.d.ts +1 -0
  17. package/dist/data/rules/offByXRule.js +3 -0
  18. package/dist/data/rules/rule.d.ts +0 -1
  19. package/dist/data/rules/rule.js +0 -3
  20. package/dist/data/rules/symbolsPerRegionRule.js +3 -1
  21. package/dist/data/rules/undercluedRule.js +2 -2
  22. package/dist/data/solver/backtrack/backtrackWorker.js +6 -7
  23. package/dist/data/solver/backtrack/rules/banPattern.d.ts +1 -1
  24. package/dist/data/solver/backtrack/rules/banPattern.js +18 -2
  25. package/dist/data/solver/backtrack/symbols/dart.d.ts +0 -1
  26. package/dist/data/solver/backtrack/symbols/dart.js +1 -9
  27. package/dist/data/solver/underclued/undercluedSolver.js +2 -2
  28. package/dist/data/solver/underclued/undercluedWorker.js +28 -24
  29. package/dist/data/symbols/hiddenSymbol.d.ts +36 -0
  30. package/dist/data/symbols/hiddenSymbol.js +119 -0
  31. package/dist/data/symbols/symbol.d.ts +7 -0
  32. package/dist/data/symbols/symbol.js +9 -0
  33. package/dist/data/symbols/symbols.gen.d.ts +1 -0
  34. package/dist/data/symbols/symbols.gen.js +1 -0
  35. package/dist/index.d.ts +5 -3
  36. package/dist/index.js +5 -3
  37. package/package.json +1 -1
@@ -22,6 +22,14 @@ declare global {
22
22
  readonly x2: number;
23
23
  readonly y2: number;
24
24
  }
25
+ /**
26
+ * Major rules are frequently referenced in grids to provide additional UI.
27
+ */
28
+ export declare enum MajorRule {
29
+ MusicGrid = 'music',
30
+ CompletePattern = 'complete_pattern',
31
+ Underclued = 'underclued',
32
+ }
25
33
  export declare enum State {
26
34
  Error = 'error',
27
35
  Satisfied = 'satisfied',
@@ -165,6 +173,116 @@ declare global {
165
173
  removeColumn(index: number): GridConnections;
166
174
  removeRow(index: number): GridConnections;
167
175
  }
176
+ /**
177
+ * Offset the given position by a given step in the given direction.
178
+ * @param position The position to offset.
179
+ * @param direction The direction to offset in.
180
+ * @param step The distance to offset by.
181
+ * @returns The offset position.
182
+ */
183
+ export declare function move(
184
+ position: Position$1,
185
+ direction: Direction | Orientation,
186
+ step?: number
187
+ ): {
188
+ x: number;
189
+ y: number;
190
+ };
191
+ /**
192
+ * Convert the given direction to a rotation in degrees.
193
+ * @param direction The direction to convert.
194
+ * @returns The rotation in degrees.
195
+ */
196
+ export declare function directionToRotation(
197
+ direction: Direction
198
+ ): 0 | 270 | 90 | 180;
199
+ /**
200
+ * Convert the given orientation to a rotation in degrees.
201
+ * @param orientation The orientation to convert.
202
+ * @returns The rotation in degrees.
203
+ */
204
+ export declare function orientationToRotation(
205
+ orientation: Orientation
206
+ ): 0 | 270 | 90 | 180 | 225 | 125 | 315 | 45;
207
+ /**
208
+ * Create a new 2D array with the given dimensions and values.
209
+ * @param width The width of the array.
210
+ * @param height The height of the array.
211
+ * @param value A function that returns the value for each x,y coordinate.
212
+ * @returns The 2D array.
213
+ */
214
+ export declare function array<T>(
215
+ width: number,
216
+ height: number,
217
+ value: (x: number, y: number) => T
218
+ ): T[][];
219
+ /**
220
+ * Resize the given array to the new size, cutting off or padding with the default value.
221
+ * @param array The array to resize.
222
+ * @param newSize The new size of the array.
223
+ * @param defaultValue A function that returns the default value for each new element.
224
+ * @returns The resized array.
225
+ */
226
+ export declare function resize<T>(
227
+ array: T[],
228
+ newSize: number,
229
+ defaultValue: () => T
230
+ ): T[];
231
+ export declare function resize<T>(
232
+ array: readonly T[],
233
+ newSize: number,
234
+ defaultValue: () => T
235
+ ): readonly T[];
236
+ /**
237
+ * Check if all the given values are equal.
238
+ * @param values The values to compare.
239
+ * @returns Whether all the values are equal.
240
+ */
241
+ export declare function allEqual<T>(...values: T[]): boolean;
242
+ /**
243
+ * Return the first element of the array which has the minimum mapped value.
244
+ *
245
+ * @param values The array of values.
246
+ * @param mapper The function to map each value to a number.
247
+ * @returns The first element with the minimum mapped value.
248
+ */
249
+ export declare function minBy<T>(
250
+ values: readonly T[],
251
+ mapper: (element: T) => number
252
+ ): T | undefined;
253
+ /**
254
+ * Return the first element of the array which has the maximum mapped value.
255
+ *
256
+ * @param values The array of values.
257
+ * @param mapper The function to map each value to a number.
258
+ * @returns The first element with the maximum mapped value.
259
+ */
260
+ export declare function maxBy<T>(
261
+ values: readonly T[],
262
+ mapper: (element: T) => number
263
+ ): T | undefined;
264
+ /**
265
+ * Escape the given text by replacing the specified characters with HTML escape sequences.
266
+ * @param text The text to escape.
267
+ * @param escapeCharacters The characters to escape.
268
+ * @returns The escaped text.
269
+ */
270
+ declare function escape$1(text: string, escapeCharacters?: string): string;
271
+ /**
272
+ * Unescape the given text by replacing HTML escape sequences with the corresponding characters.
273
+ * @param text The text to unescape.
274
+ * @param escapeCharacters The characters to unescape. This should match the characters escaped by the `escape` function.
275
+ * @returns The unescaped text.
276
+ */
277
+ declare function unescape$1(text: string, escapeCharacters?: string): string;
278
+ export declare class CachedAccess<T> {
279
+ private readonly getter;
280
+ private static readonly UNCACHED;
281
+ private cache;
282
+ private constructor();
283
+ static of<T>(getter: () => T): CachedAccess<T>;
284
+ get value(): T;
285
+ }
168
286
  export declare abstract class Configurable {
169
287
  get configs(): readonly AnyConfig[] | null;
170
288
  abstract copyWith(props: Record<string, unknown>): this;
@@ -185,6 +303,7 @@ declare global {
185
303
  */
186
304
  get validateWithSolution(): boolean;
187
305
  get necessaryForCompletion(): boolean;
306
+ get visibleWhenSolving(): boolean;
188
307
  /**
189
308
  * Check if this instruction is equal to another instruction by comparing their IDs and configs.
190
309
  *
@@ -201,7 +320,6 @@ declare global {
201
320
  abstract validateGrid(grid: GridData): RuleState;
202
321
  abstract get searchVariants(): SearchVariant[];
203
322
  searchVariant(): SearchVariant;
204
- get visibleWhenSolving(): boolean;
205
323
  /**
206
324
  * Whether only one instance of this rule is allowed in a grid.
207
325
  */
@@ -235,7 +353,14 @@ declare global {
235
353
  direction: 'row' | 'column',
236
354
  index: number
237
355
  ): this | null;
356
+ /**
357
+ * The step size for the x and y coordinates of the symbol.
358
+ */
238
359
  get placementStep(): number;
360
+ /**
361
+ * The order in which symbols are displayed on the instruction list. Lower values are displayed first.
362
+ */
363
+ get sortOrder(): number;
239
364
  withX(x: number): this;
240
365
  withY(y: number): this;
241
366
  withPosition(x: number, y: number): this;
@@ -269,6 +394,181 @@ declare global {
269
394
  equals(other: TileData): boolean;
270
395
  static create(char: string): TileData;
271
396
  }
397
+ export interface GridChangeHandler {
398
+ onGridChange(newGrid: GridData): this;
399
+ }
400
+ export declare function handlesGridChange<T extends Instruction>(
401
+ val: T
402
+ ): val is T & GridChangeHandler;
403
+ export interface SetGridHandler {
404
+ onSetGrid(oldGrid: GridData, newGrid: GridData): GridData;
405
+ }
406
+ export declare function handlesSetGrid<T extends Instruction>(
407
+ val: T
408
+ ): val is T & SetGridHandler;
409
+ export declare class Row extends Configurable {
410
+ /**
411
+ * The note to play at this row, or null to keep the current note from the previous control line.
412
+ * If this is null from the first control line, the note will be silent.
413
+ */
414
+ readonly note: string | null;
415
+ /**
416
+ * The velocity to play the note at, or null to keep the current velocity from the previous control line.
417
+ * Ranges from 0 to 1
418
+ */
419
+ readonly velocity: number | null;
420
+ private static readonly CONFIGS;
421
+ constructor(
422
+ /**
423
+ * The note to play at this row, or null to keep the current note from the previous control line.
424
+ * If this is null from the first control line, the note will be silent.
425
+ */
426
+ note: string | null,
427
+ /**
428
+ * The velocity to play the note at, or null to keep the current velocity from the previous control line.
429
+ * Ranges from 0 to 1
430
+ */
431
+ velocity: number | null
432
+ );
433
+ get configs(): readonly AnyConfig[] | null;
434
+ copyWith({
435
+ note,
436
+ velocity,
437
+ }: {
438
+ note?: string | null;
439
+ velocity?: number | null;
440
+ }): this;
441
+ }
442
+ export declare class ControlLine extends Configurable {
443
+ readonly column: number;
444
+ readonly bpm: number | null;
445
+ readonly pedal: boolean | null;
446
+ readonly checkpoint: boolean;
447
+ readonly rows: readonly Row[];
448
+ private static readonly CONFIGS;
449
+ /**
450
+ * Configure playback settings, taking effect at the given column (inclusive)
451
+ * @param column The column at which the settings take effect
452
+ * @param bpm The new beats per minute, or null to keep the current value from the previous control line
453
+ * @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
454
+ * @param checkpoint Whether this control line is a checkpoint
455
+ * @param rows The notes to play at each row. This list is automatically resized to match the height of the grid. You may pass in an empty list if none of the rows need to be changed.
456
+ */
457
+ constructor(
458
+ column: number,
459
+ bpm: number | null,
460
+ pedal: boolean | null,
461
+ checkpoint: boolean,
462
+ rows: readonly Row[]
463
+ );
464
+ get configs(): readonly AnyConfig[] | null;
465
+ copyWith({
466
+ column,
467
+ bpm,
468
+ pedal,
469
+ checkpoint,
470
+ rows,
471
+ }: {
472
+ column?: number;
473
+ bpm?: number | null;
474
+ pedal?: boolean | null;
475
+ checkpoint?: boolean;
476
+ rows?: readonly Row[];
477
+ }): this;
478
+ withColumn(column: number): this;
479
+ withBpm(bpm: number | null): this;
480
+ withPedal(pedal: boolean | null): this;
481
+ withCheckpoint(checkpoint: boolean): this;
482
+ withRows(rows: readonly Row[]): this;
483
+ equals(other: ControlLine): boolean;
484
+ get isEmpty(): boolean;
485
+ }
486
+ export declare class MusicGridRule
487
+ extends Rule
488
+ implements GridChangeHandler, SetGridHandler, GridResizeHandler
489
+ {
490
+ readonly controlLines: readonly ControlLine[];
491
+ readonly track: GridData | null;
492
+ private static readonly EXAMPLE_GRID;
493
+ private static readonly CONFIGS;
494
+ private static readonly SEARCH_VARIANTS;
495
+ /**
496
+ * **Music Grid: Listen to the solution**
497
+ * @param controlLines Denote changes in the playback settings. At least one control line at column 0 should be present to enable playback.
498
+ * @param track The grid to be played when "listen" is clicked. Set as null to play the solution.
499
+ */
500
+ constructor(controlLines: readonly ControlLine[], track: GridData | null);
501
+ get id(): string;
502
+ get explanation(): string;
503
+ get configs(): readonly AnyConfig[] | null;
504
+ createExampleGrid(): GridData;
505
+ get searchVariants(): SearchVariant[];
506
+ validateGrid(_grid: GridData): RuleState;
507
+ onSetGrid(_oldGrid: GridData, newGrid: GridData): GridData;
508
+ onGridChange(newGrid: GridData): this;
509
+ onGridResize(
510
+ _grid: GridData,
511
+ mode: 'insert' | 'remove',
512
+ direction: 'row' | 'column',
513
+ index: number
514
+ ): this | null;
515
+ /**
516
+ * Add or replace a control line.
517
+ * @param controlLine The control line to set.
518
+ * @returns A new rule with the control line set.
519
+ */
520
+ setControlLine(controlLine: ControlLine): this;
521
+ withTrack(track: GridData | null): this;
522
+ copyWith({
523
+ controlLines,
524
+ track,
525
+ }: {
526
+ controlLines?: readonly ControlLine[];
527
+ track?: GridData | null;
528
+ }): this;
529
+ get validateWithSolution(): boolean;
530
+ get isSingleton(): boolean;
531
+ static mergeControlLines(...lines: ControlLine[]): ControlLine;
532
+ static deduplicateControlLines(
533
+ lines: readonly ControlLine[]
534
+ ): ControlLine[];
535
+ }
536
+ export declare class CompletePatternRule extends Rule {
537
+ private static readonly EXAMPLE_GRID;
538
+ private static readonly SEARCH_VARIANTS;
539
+ /**
540
+ * **Complete the pattern**
541
+ *
542
+ * This rule validates answers based on the provided solution.
543
+ */
544
+ constructor();
545
+ get id(): string;
546
+ get explanation(): string;
547
+ createExampleGrid(): GridData;
548
+ get searchVariants(): SearchVariant[];
549
+ validateGrid(_grid: GridData): RuleState;
550
+ copyWith(_: object): this;
551
+ get validateWithSolution(): boolean;
552
+ get isSingleton(): boolean;
553
+ }
554
+ export declare class UndercluedRule extends Rule {
555
+ private static readonly EXAMPLE_GRID;
556
+ private static readonly SEARCH_VARIANTS;
557
+ /**
558
+ * **Underclued Grid: Mark only what is definitely true**
559
+ *
560
+ * This rule validates answers based on the provided solution.
561
+ */
562
+ constructor();
563
+ get id(): string;
564
+ get explanation(): string;
565
+ createExampleGrid(): GridData;
566
+ get searchVariants(): SearchVariant[];
567
+ validateGrid(_grid: GridData): RuleState;
568
+ copyWith(_: object): this;
569
+ get validateWithSolution(): boolean;
570
+ get isSingleton(): boolean;
571
+ }
272
572
  export declare class GridData {
273
573
  readonly width: number;
274
574
  readonly height: number;
@@ -276,6 +576,9 @@ declare global {
276
576
  readonly connections: GridConnections;
277
577
  readonly symbols: ReadonlyMap<string, readonly Symbol$1[]>;
278
578
  readonly rules: readonly Rule[];
579
+ readonly musicGrid: CachedAccess<MusicGridRule | undefined>;
580
+ readonly completePattern: CachedAccess<CompletePatternRule | undefined>;
581
+ readonly underclued: CachedAccess<UndercluedRule | undefined>;
279
582
  /**
280
583
  * Create a new grid with tiles, connections, symbols and rules.
281
584
  * @param width The width of the grid.
@@ -665,110 +968,33 @@ declare global {
665
968
  * @param color The color of the tiles.
666
969
  * @returns The count of tiles that satisfy the given conditions for each color.
667
970
  */
668
- getColorCount(color: Color): {
669
- min: number;
670
- max: number;
671
- };
672
- /**
673
- * Deduplicate the rules in the given list.
674
- *
675
- * @param rules The list of rules to deduplicate.
676
- * @returns The deduplicated list of rules.
677
- */
678
- static deduplicateRules(rules: readonly Rule[]): Rule[];
679
- /**
680
- * Deduplicate the singleton rules in the given list.
681
- *
682
- * @param rules The list of rules to deduplicate.
683
- * @returns The deduplicated list of rules.
684
- */
685
- static deduplicateSingletonRules(rules: readonly Rule[]): Rule[];
686
- /**
687
- * Deduplicate the symbols in the given map.
688
- *
689
- * @param symbols The map of symbols to deduplicate.
690
- * @returns The deduplicated map of symbols.
691
- */
692
- static deduplicateSymbols(
693
- symbols: ReadonlyMap<string, readonly Symbol$1[]>
694
- ): Map<string, Symbol$1[]>;
695
- }
696
- export declare class Row extends Configurable {
697
- /**
698
- * The note to play at this row, or null to keep the current note from the previous control line.
699
- * If this is null from the first control line, the note will be silent.
700
- */
701
- readonly note: string | null;
702
- /**
703
- * The velocity to play the note at, or null to keep the current velocity from the previous control line.
704
- * Ranges from 0 to 1
705
- */
706
- readonly velocity: number | null;
707
- private static readonly CONFIGS;
708
- constructor(
709
- /**
710
- * The note to play at this row, or null to keep the current note from the previous control line.
711
- * If this is null from the first control line, the note will be silent.
712
- */
713
- note: string | null,
714
- /**
715
- * The velocity to play the note at, or null to keep the current velocity from the previous control line.
716
- * Ranges from 0 to 1
717
- */
718
- velocity: number | null
719
- );
720
- get configs(): readonly AnyConfig[] | null;
721
- copyWith({
722
- note,
723
- velocity,
724
- }: {
725
- note?: string | null;
726
- velocity?: number | null;
727
- }): this;
728
- }
729
- export declare class ControlLine extends Configurable {
730
- readonly column: number;
731
- readonly bpm: number | null;
732
- readonly pedal: boolean | null;
733
- readonly checkpoint: boolean;
734
- readonly rows: readonly Row[];
735
- private static readonly CONFIGS;
736
- /**
737
- * Configure playback settings, taking effect at the given column (inclusive)
738
- * @param column The column at which the settings take effect
739
- * @param bpm The new beats per minute, or null to keep the current value from the previous control line
740
- * @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
741
- * @param checkpoint Whether this control line is a checkpoint
742
- * @param rows The notes to play at each row. This list is automatically resized to match the height of the grid. You may pass in an empty list if none of the rows need to be changed.
743
- */
744
- constructor(
745
- column: number,
746
- bpm: number | null,
747
- pedal: boolean | null,
748
- checkpoint: boolean,
749
- rows: readonly Row[]
750
- );
751
- get configs(): readonly AnyConfig[] | null;
752
- copyWith({
753
- column,
754
- bpm,
755
- pedal,
756
- checkpoint,
757
- rows,
758
- }: {
759
- column?: number;
760
- bpm?: number | null;
761
- pedal?: boolean | null;
762
- checkpoint?: boolean;
763
- rows?: readonly Row[];
764
- }): this;
765
- withColumn(column: number): this;
766
- withBpm(bpm: number | null): this;
767
- withPedal(pedal: boolean | null): this;
768
- withCheckpoint(checkpoint: boolean): this;
769
- withRows(rows: readonly Row[]): this;
770
- equals(other: ControlLine): boolean;
771
- get isEmpty(): boolean;
971
+ getColorCount(color: Color): {
972
+ min: number;
973
+ max: number;
974
+ };
975
+ /**
976
+ * Deduplicate the rules in the given list.
977
+ *
978
+ * @param rules The list of rules to deduplicate.
979
+ * @returns The deduplicated list of rules.
980
+ */
981
+ static deduplicateRules(rules: readonly Rule[]): Rule[];
982
+ /**
983
+ * Deduplicate the singleton rules in the given list.
984
+ *
985
+ * @param rules The list of rules to deduplicate.
986
+ * @returns The deduplicated list of rules.
987
+ */
988
+ static deduplicateSingletonRules(rules: readonly Rule[]): Rule[];
989
+ /**
990
+ * Deduplicate the symbols in the given map.
991
+ *
992
+ * @param symbols The map of symbols to deduplicate.
993
+ * @returns The deduplicated map of symbols.
994
+ */
995
+ static deduplicateSymbols(
996
+ symbols: ReadonlyMap<string, readonly Symbol$1[]>
997
+ ): Map<string, Symbol$1[]>;
772
998
  }
773
999
  export declare enum ConfigType {
774
1000
  Boolean = 'boolean',
@@ -889,108 +1115,6 @@ declare global {
889
1115
  a: C['default'],
890
1116
  b: C['default']
891
1117
  ): boolean;
892
- /**
893
- * Offset the given position by a given step in the given direction.
894
- * @param position The position to offset.
895
- * @param direction The direction to offset in.
896
- * @param step The distance to offset by.
897
- * @returns The offset position.
898
- */
899
- export declare function move(
900
- position: Position$1,
901
- direction: Direction | Orientation,
902
- step?: number
903
- ): {
904
- x: number;
905
- y: number;
906
- };
907
- /**
908
- * Convert the given direction to a rotation in degrees.
909
- * @param direction The direction to convert.
910
- * @returns The rotation in degrees.
911
- */
912
- export declare function directionToRotation(
913
- direction: Direction
914
- ): 0 | 270 | 90 | 180;
915
- /**
916
- * Convert the given orientation to a rotation in degrees.
917
- * @param orientation The orientation to convert.
918
- * @returns The rotation in degrees.
919
- */
920
- export declare function orientationToRotation(
921
- orientation: Orientation
922
- ): 0 | 270 | 90 | 180 | 225 | 125 | 315 | 45;
923
- /**
924
- * Create a new 2D array with the given dimensions and values.
925
- * @param width The width of the array.
926
- * @param height The height of the array.
927
- * @param value A function that returns the value for each x,y coordinate.
928
- * @returns The 2D array.
929
- */
930
- export declare function array<T>(
931
- width: number,
932
- height: number,
933
- value: (x: number, y: number) => T
934
- ): T[][];
935
- /**
936
- * Resize the given array to the new size, cutting off or padding with the default value.
937
- * @param array The array to resize.
938
- * @param newSize The new size of the array.
939
- * @param defaultValue A function that returns the default value for each new element.
940
- * @returns The resized array.
941
- */
942
- export declare function resize<T>(
943
- array: T[],
944
- newSize: number,
945
- defaultValue: () => T
946
- ): T[];
947
- export declare function resize<T>(
948
- array: readonly T[],
949
- newSize: number,
950
- defaultValue: () => T
951
- ): readonly T[];
952
- /**
953
- * Check if all the given values are equal.
954
- * @param values The values to compare.
955
- * @returns Whether all the values are equal.
956
- */
957
- export declare function allEqual<T>(...values: T[]): boolean;
958
- /**
959
- * Return the first element of the array which has the minimum mapped value.
960
- *
961
- * @param values The array of values.
962
- * @param mapper The function to map each value to a number.
963
- * @returns The first element with the minimum mapped value.
964
- */
965
- export declare function minBy<T>(
966
- values: readonly T[],
967
- mapper: (element: T) => number
968
- ): T | undefined;
969
- /**
970
- * Return the first element of the array which has the maximum mapped value.
971
- *
972
- * @param values The array of values.
973
- * @param mapper The function to map each value to a number.
974
- * @returns The first element with the maximum mapped value.
975
- */
976
- export declare function maxBy<T>(
977
- values: readonly T[],
978
- mapper: (element: T) => number
979
- ): T | undefined;
980
- /**
981
- * Escape the given text by replacing the specified characters with HTML escape sequences.
982
- * @param text The text to escape.
983
- * @param escapeCharacters The characters to escape.
984
- * @returns The escaped text.
985
- */
986
- declare function escape$1(text: string, escapeCharacters?: string): string;
987
- /**
988
- * Unescape the given text by replacing HTML escape sequences with the corresponding characters.
989
- * @param text The text to unescape.
990
- * @param escapeCharacters The characters to unescape. This should match the characters escaped by the `escape` function.
991
- * @returns The unescaped text.
992
- */
993
- declare function unescape$1(text: string, escapeCharacters?: string): string;
994
1118
  export declare function isEventHandler<T>(
995
1119
  val: unknown,
996
1120
  event: string
@@ -1012,18 +1136,24 @@ declare global {
1012
1136
  export declare function handlesFinalValidation<T extends Instruction>(
1013
1137
  val: T
1014
1138
  ): val is T & FinalValidationHandler;
1015
- export interface GridChangeHandler {
1016
- onGridChange(newGrid: GridData): this;
1017
- }
1018
- export declare function handlesGridChange<T extends Instruction>(
1019
- val: T
1020
- ): val is T & GridChangeHandler;
1021
- export interface SetGridHandler {
1022
- onSetGrid(oldGrid: GridData, newGrid: GridData): GridData;
1139
+ export interface SymbolDisplayHandler {
1140
+ /**
1141
+ * Controls whether a symbol should be visible in the grid.
1142
+ *
1143
+ * @param grid The grid that is being displayed.
1144
+ * @param symbol The symbol that is being displayed.
1145
+ * @param editing Whether the grid is being edited.
1146
+ * @returns True if the symbol should be displayed, false otherwise. The symbol will not be displayed if any handler returns false.
1147
+ */
1148
+ onSymbolDisplay(
1149
+ grid: GridData,
1150
+ symbol: Symbol$1,
1151
+ editing: boolean
1152
+ ): boolean;
1023
1153
  }
1024
- export declare function handlesSetGrid<T extends Instruction>(
1154
+ export declare function handlesSymbolDisplay<T extends Instruction>(
1025
1155
  val: T
1026
- ): val is T & SetGridHandler;
1156
+ ): val is T & SymbolDisplayHandler;
1027
1157
  export interface SymbolValidationHandler {
1028
1158
  /**
1029
1159
  * Overrides the validation of symbols.
@@ -1205,24 +1335,6 @@ declare global {
1205
1335
  withColor(color: Color): this;
1206
1336
  withCount(count: number): this;
1207
1337
  }
1208
- export declare class CompletePatternRule extends Rule {
1209
- private static readonly EXAMPLE_GRID;
1210
- private static readonly SEARCH_VARIANTS;
1211
- /**
1212
- * **Complete the pattern**
1213
- *
1214
- * This rule validates answers based on the provided solution.
1215
- */
1216
- constructor();
1217
- get id(): string;
1218
- get explanation(): string;
1219
- createExampleGrid(): GridData;
1220
- get searchVariants(): SearchVariant[];
1221
- validateGrid(_grid: GridData): RuleState;
1222
- copyWith(_: object): this;
1223
- get validateWithSolution(): boolean;
1224
- get isSingleton(): boolean;
1225
- }
1226
1338
  export declare class ConnectAllRule extends Rule {
1227
1339
  readonly color: Color;
1228
1340
  private static readonly CONFIGS;
@@ -1293,6 +1405,7 @@ declare global {
1293
1405
  get searchVariants(): SearchVariant[];
1294
1406
  validateGrid(_grid: GridData): RuleState;
1295
1407
  get necessaryForCompletion(): boolean;
1408
+ get isSingleton(): boolean;
1296
1409
  copyWith({
1297
1410
  count,
1298
1411
  regenInterval,
@@ -1304,56 +1417,6 @@ declare global {
1304
1417
  }): this;
1305
1418
  }
1306
1419
  export declare const allRules: Map<string, Rule>;
1307
- export declare class MusicGridRule
1308
- extends Rule
1309
- implements GridChangeHandler, SetGridHandler, GridResizeHandler
1310
- {
1311
- readonly controlLines: readonly ControlLine[];
1312
- readonly track: GridData | null;
1313
- private static readonly EXAMPLE_GRID;
1314
- private static readonly CONFIGS;
1315
- private static readonly SEARCH_VARIANTS;
1316
- /**
1317
- * **Music Grid: Listen to the solution**
1318
- * @param controlLines Denote changes in the playback settings. At least one control line at column 0 should be present to enable playback.
1319
- * @param track The grid to be played when "listen" is clicked. Set as null to play the solution.
1320
- */
1321
- constructor(controlLines: readonly ControlLine[], track: GridData | null);
1322
- get id(): string;
1323
- get explanation(): string;
1324
- get configs(): readonly AnyConfig[] | null;
1325
- createExampleGrid(): GridData;
1326
- get searchVariants(): SearchVariant[];
1327
- validateGrid(_grid: GridData): RuleState;
1328
- onSetGrid(_oldGrid: GridData, newGrid: GridData): GridData;
1329
- onGridChange(newGrid: GridData): this;
1330
- onGridResize(
1331
- _grid: GridData,
1332
- mode: 'insert' | 'remove',
1333
- direction: 'row' | 'column',
1334
- index: number
1335
- ): this | null;
1336
- /**
1337
- * Add or replace a control line.
1338
- * @param controlLine The control line to set.
1339
- * @returns A new rule with the control line set.
1340
- */
1341
- setControlLine(controlLine: ControlLine): this;
1342
- withTrack(track: GridData | null): this;
1343
- copyWith({
1344
- controlLines,
1345
- track,
1346
- }: {
1347
- controlLines?: readonly ControlLine[];
1348
- track?: GridData | null;
1349
- }): this;
1350
- get validateWithSolution(): boolean;
1351
- get isSingleton(): boolean;
1352
- static mergeControlLines(...lines: ControlLine[]): ControlLine;
1353
- static deduplicateControlLines(
1354
- lines: readonly ControlLine[]
1355
- ): ControlLine[];
1356
- }
1357
1420
  export declare class MysteryRule
1358
1421
  extends Rule
1359
1422
  implements FinalValidationHandler, GridChangeHandler, GridResizeHandler
@@ -1423,6 +1486,7 @@ declare global {
1423
1486
  symbol: Symbol$1,
1424
1487
  _validator: (grid: GridData) => State
1425
1488
  ): State | undefined;
1489
+ get isSingleton(): boolean;
1426
1490
  copyWith({ number }: { number?: number }): this;
1427
1491
  withNumber(number: number): this;
1428
1492
  }
@@ -1523,24 +1587,6 @@ declare global {
1523
1587
  withComparison(comparison: Comparison): this;
1524
1588
  private static countAllSymbolsOfPosition;
1525
1589
  }
1526
- export declare class UndercluedRule extends Rule {
1527
- private static readonly EXAMPLE_GRID;
1528
- private static readonly SEARCH_VARIANTS;
1529
- /**
1530
- * **Underclued Grid: Mark only what is definitely true**
1531
- *
1532
- * This rule validates answers based on the provided solution.
1533
- */
1534
- constructor();
1535
- get id(): string;
1536
- get explanation(): string;
1537
- createExampleGrid(): GridData;
1538
- get searchVariants(): SearchVariant[];
1539
- validateGrid(_grid: GridData): RuleState;
1540
- copyWith(_: object): this;
1541
- get validateWithSolution(): boolean;
1542
- get isSingleton(): boolean;
1543
- }
1544
1590
  export declare class UniqueShapeRule extends RegionShapeRule {
1545
1591
  private static readonly CONFIGS;
1546
1592
  private static readonly EXAMPLE_GRID_LIGHT;
@@ -1801,7 +1847,7 @@ declare global {
1801
1847
  export declare class BanPatternBTModule extends BTModule {
1802
1848
  instr: BanPatternRule;
1803
1849
  constructor(instr: BanPatternRule);
1804
- checkGlobal(_: BTGridData): CheckResult | false;
1850
+ checkGlobal(grid: BTGridData): CheckResult | false;
1805
1851
  checkLocal(grid: BTGridData, positions: Position$1[]): CheckResult | false;
1806
1852
  }
1807
1853
  export declare class CellCountBTModule extends BTModule {
@@ -1939,7 +1985,6 @@ declare global {
1939
1985
  }
1940
1986
  export declare class DartBTModule extends BTModule {
1941
1987
  instr: DartSymbol;
1942
- private cachedCheckResult?;
1943
1988
  constructor(instr: DartSymbol);
1944
1989
  checkGlobal(grid: BTGridData): CheckResult | false;
1945
1990
  private buildCheckAndRating;
@@ -5841,6 +5886,39 @@ declare global {
5841
5886
  withText(text: string): this;
5842
5887
  withRotation(rotation: number): this;
5843
5888
  }
5889
+ export declare class HiddenSymbol
5890
+ extends Symbol$1
5891
+ implements SymbolDisplayHandler
5892
+ {
5893
+ readonly x: number;
5894
+ readonly y: number;
5895
+ readonly color: Color;
5896
+ private static readonly CONFIGS;
5897
+ private static readonly EXAMPLE_GRID;
5898
+ /**
5899
+ * **Hidden Symbols: color cells correctly to reveal more clues**
5900
+ *
5901
+ * @param x - The x-coordinate of the symbol.
5902
+ * @param y - The y-coordinate of the symbol.
5903
+ * @param color - The target color of the cell.
5904
+ */
5905
+ constructor(x: number, y: number, color: Color);
5906
+ get id(): string;
5907
+ get explanation(): string;
5908
+ get configs(): readonly AnyConfig[] | null;
5909
+ createExampleGrid(): GridData;
5910
+ get necessaryForCompletion(): boolean;
5911
+ get visibleWhenSolving(): boolean;
5912
+ get sortOrder(): number;
5913
+ validateSymbol(grid: GridData): State;
5914
+ onSymbolDisplay(
5915
+ grid: GridData,
5916
+ symbol: Symbol$1,
5917
+ editing: boolean
5918
+ ): boolean;
5919
+ copyWith({ x, y, color }: { x?: number; y?: number; color?: Color }): this;
5920
+ withColor(color: Color): this;
5921
+ }
5844
5922
  export declare const allSymbols: Map<string, Symbol$1>;
5845
5923
  export declare function aggregateState(
5846
5924
  rules: RuleState[],