@logic-pad/core 0.1.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.
- package/LICENSE +661 -0
- package/README.md +19 -0
- package/assets/logic-core.global.d.ts +5865 -0
- package/assets/z3-built.js +14723 -0
- package/assets/z3-built.wasm +0 -0
- package/assets/z3-built.worker.js +206 -0
- package/dist/data/config.d.ts +101 -0
- package/dist/data/config.js +55 -0
- package/dist/data/configurable.d.ts +12 -0
- package/dist/data/configurable.js +26 -0
- package/dist/data/dataHelper.d.ts +77 -0
- package/dist/data/dataHelper.js +190 -0
- package/dist/data/events/eventHelper.d.ts +1 -0
- package/dist/data/events/eventHelper.js +6 -0
- package/dist/data/events/onFinalValidation.d.ts +14 -0
- package/dist/data/events/onFinalValidation.js +4 -0
- package/dist/data/events/onGridChange.d.ts +6 -0
- package/dist/data/events/onGridChange.js +4 -0
- package/dist/data/events/onGridResize.d.ts +9 -0
- package/dist/data/events/onGridResize.js +4 -0
- package/dist/data/events/onSetGrid.d.ts +6 -0
- package/dist/data/events/onSetGrid.js +4 -0
- package/dist/data/events/onSymbolValidation.d.ts +18 -0
- package/dist/data/events/onSymbolValidation.js +4 -0
- package/dist/data/grid.d.ts +362 -0
- package/dist/data/grid.js +886 -0
- package/dist/data/gridConnections.d.ts +38 -0
- package/dist/data/gridConnections.js +328 -0
- package/dist/data/instruction.d.ts +19 -0
- package/dist/data/instruction.js +23 -0
- package/dist/data/primitives.d.ts +85 -0
- package/dist/data/primitives.js +90 -0
- package/dist/data/puzzle.d.ts +86 -0
- package/dist/data/puzzle.js +22 -0
- package/dist/data/rules/banPatternRule.d.ts +29 -0
- package/dist/data/rules/banPatternRule.js +133 -0
- package/dist/data/rules/cellCountRule.d.ts +32 -0
- package/dist/data/rules/cellCountRule.js +166 -0
- package/dist/data/rules/completePatternRule.d.ts +22 -0
- package/dist/data/rules/completePatternRule.js +53 -0
- package/dist/data/rules/connectAllRule.d.ts +28 -0
- package/dist/data/rules/connectAllRule.js +113 -0
- package/dist/data/rules/customRule.d.ts +32 -0
- package/dist/data/rules/customRule.js +92 -0
- package/dist/data/rules/foresightRule.d.ts +30 -0
- package/dist/data/rules/foresightRule.js +107 -0
- package/dist/data/rules/index.d.ts +3 -0
- package/dist/data/rules/index.js +10 -0
- package/dist/data/rules/musicControlLine.d.ts +64 -0
- package/dist/data/rules/musicControlLine.js +178 -0
- package/dist/data/rules/musicGridRule.d.ts +46 -0
- package/dist/data/rules/musicGridRule.js +211 -0
- package/dist/data/rules/mysteryRule.d.ts +37 -0
- package/dist/data/rules/mysteryRule.js +164 -0
- package/dist/data/rules/offByXRule.d.ts +30 -0
- package/dist/data/rules/offByXRule.js +134 -0
- package/dist/data/rules/regionAreaRule.d.ts +33 -0
- package/dist/data/rules/regionAreaRule.js +182 -0
- package/dist/data/rules/regionShapeRule.d.ts +22 -0
- package/dist/data/rules/regionShapeRule.js +58 -0
- package/dist/data/rules/rule.d.ts +18 -0
- package/dist/data/rules/rule.js +19 -0
- package/dist/data/rules/rules.gen.d.ts +14 -0
- package/dist/data/rules/rules.gen.js +18 -0
- package/dist/data/rules/sameShapeRule.d.ts +27 -0
- package/dist/data/rules/sameShapeRule.js +88 -0
- package/dist/data/rules/symbolsPerRegionRule.d.ts +37 -0
- package/dist/data/rules/symbolsPerRegionRule.js +211 -0
- package/dist/data/rules/undercluedRule.d.ts +22 -0
- package/dist/data/rules/undercluedRule.js +60 -0
- package/dist/data/rules/uniqueShapeRule.d.ts +27 -0
- package/dist/data/rules/uniqueShapeRule.js +85 -0
- package/dist/data/serializer/allSerializers.d.ts +30 -0
- package/dist/data/serializer/allSerializers.js +64 -0
- package/dist/data/serializer/compressor/allCompressors.d.ts +14 -0
- package/dist/data/serializer/compressor/allCompressors.js +43 -0
- package/dist/data/serializer/compressor/compressorBase.d.ts +16 -0
- package/dist/data/serializer/compressor/compressorBase.js +2 -0
- package/dist/data/serializer/compressor/deflateCompressor.d.ts +7 -0
- package/dist/data/serializer/compressor/deflateCompressor.js +17 -0
- package/dist/data/serializer/compressor/gzipCompressor.d.ts +5 -0
- package/dist/data/serializer/compressor/gzipCompressor.js +9 -0
- package/dist/data/serializer/compressor/streamCompressor.d.ts +6 -0
- package/dist/data/serializer/compressor/streamCompressor.js +36 -0
- package/dist/data/serializer/serializerBase.d.ts +27 -0
- package/dist/data/serializer/serializerBase.js +2 -0
- package/dist/data/serializer/serializer_v0.d.ts +36 -0
- package/dist/data/serializer/serializer_v0.js +426 -0
- package/dist/data/shapes.d.ts +17 -0
- package/dist/data/shapes.js +117 -0
- package/dist/data/solver/allSolvers.d.ts +3 -0
- package/dist/data/solver/allSolvers.js +11 -0
- package/dist/data/solver/backtrack/backtrackSolver.d.ts +9 -0
- package/dist/data/solver/backtrack/backtrackSolver.js +92 -0
- package/dist/data/solver/backtrack/backtrackWorker.d.ts +2 -0
- package/dist/data/solver/backtrack/backtrackWorker.js +295 -0
- package/dist/data/solver/backtrack/data.d.ts +46 -0
- package/dist/data/solver/backtrack/data.js +140 -0
- package/dist/data/solver/backtrack/rules/banPattern.d.ts +9 -0
- package/dist/data/solver/backtrack/rules/banPattern.js +66 -0
- package/dist/data/solver/backtrack/rules/cellCount.d.ts +7 -0
- package/dist/data/solver/backtrack/rules/cellCount.js +30 -0
- package/dist/data/solver/backtrack/rules/connectAll.d.ts +7 -0
- package/dist/data/solver/backtrack/rules/connectAll.js +49 -0
- package/dist/data/solver/backtrack/rules/regionArea.d.ts +8 -0
- package/dist/data/solver/backtrack/rules/regionArea.js +76 -0
- package/dist/data/solver/backtrack/rules/regionShape.d.ts +8 -0
- package/dist/data/solver/backtrack/rules/regionShape.js +62 -0
- package/dist/data/solver/backtrack/rules/sameShape.d.ts +8 -0
- package/dist/data/solver/backtrack/rules/sameShape.js +19 -0
- package/dist/data/solver/backtrack/rules/symbolsPerRegion.d.ts +10 -0
- package/dist/data/solver/backtrack/rules/symbolsPerRegion.js +92 -0
- package/dist/data/solver/backtrack/rules/uniqueShape.d.ts +8 -0
- package/dist/data/solver/backtrack/rules/uniqueShape.js +19 -0
- package/dist/data/solver/backtrack/symbols/areaNumber.d.ts +9 -0
- package/dist/data/solver/backtrack/symbols/areaNumber.js +77 -0
- package/dist/data/solver/backtrack/symbols/dart.d.ts +9 -0
- package/dist/data/solver/backtrack/symbols/dart.js +58 -0
- package/dist/data/solver/backtrack/symbols/directionLinker.d.ts +9 -0
- package/dist/data/solver/backtrack/symbols/directionLinker.js +50 -0
- package/dist/data/solver/backtrack/symbols/galaxy.d.ts +9 -0
- package/dist/data/solver/backtrack/symbols/galaxy.js +19 -0
- package/dist/data/solver/backtrack/symbols/letter.d.ts +9 -0
- package/dist/data/solver/backtrack/symbols/letter.js +100 -0
- package/dist/data/solver/backtrack/symbols/lotus.d.ts +9 -0
- package/dist/data/solver/backtrack/symbols/lotus.js +36 -0
- package/dist/data/solver/backtrack/symbols/minesweeper.d.ts +9 -0
- package/dist/data/solver/backtrack/symbols/minesweeper.js +55 -0
- package/dist/data/solver/backtrack/symbols/myopia.d.ts +7 -0
- package/dist/data/solver/backtrack/symbols/myopia.js +79 -0
- package/dist/data/solver/backtrack/symbols/viewpoint.d.ts +7 -0
- package/dist/data/solver/backtrack/symbols/viewpoint.js +56 -0
- package/dist/data/solver/solver.d.ts +61 -0
- package/dist/data/solver/solver.js +55 -0
- package/dist/data/solver/underclued/undercluedSolver.d.ts +8 -0
- package/dist/data/solver/underclued/undercluedSolver.js +55 -0
- package/dist/data/solver/underclued/undercluedWorker.d.ts +2 -0
- package/dist/data/solver/underclued/undercluedWorker.js +131 -0
- package/dist/data/solver/z3/modules/areaNumberModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/areaNumberModule.js +35 -0
- package/dist/data/solver/z3/modules/cellCountModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/cellCountModule.js +59 -0
- package/dist/data/solver/z3/modules/connectAllModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/connectAllModule.js +32 -0
- package/dist/data/solver/z3/modules/dartModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/dartModule.js +69 -0
- package/dist/data/solver/z3/modules/index.d.ts +3 -0
- package/dist/data/solver/z3/modules/index.js +10 -0
- package/dist/data/solver/z3/modules/letterModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/letterModule.js +41 -0
- package/dist/data/solver/z3/modules/modules.gen.d.ts +8 -0
- package/dist/data/solver/z3/modules/modules.gen.js +12 -0
- package/dist/data/solver/z3/modules/myopiaModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/myopiaModule.js +64 -0
- package/dist/data/solver/z3/modules/regionAreaModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/regionAreaModule.js +48 -0
- package/dist/data/solver/z3/modules/viewpointModule.d.ts +9 -0
- package/dist/data/solver/z3/modules/viewpointModule.js +37 -0
- package/dist/data/solver/z3/modules/z3Module.d.ts +7 -0
- package/dist/data/solver/z3/modules/z3Module.js +3 -0
- package/dist/data/solver/z3/utils.d.ts +2 -0
- package/dist/data/solver/z3/utils.js +26 -0
- package/dist/data/solver/z3/z3Solver.d.ts +10 -0
- package/dist/data/solver/z3/z3Solver.js +134 -0
- package/dist/data/solver/z3/z3SolverContext.d.ts +808 -0
- package/dist/data/solver/z3/z3SolverContext.js +49 -0
- package/dist/data/symbols/areaNumberSymbol.d.ts +30 -0
- package/dist/data/symbols/areaNumberSymbol.js +88 -0
- package/dist/data/symbols/customIconSymbol.d.ts +35 -0
- package/dist/data/symbols/customIconSymbol.js +105 -0
- package/dist/data/symbols/customSymbol.d.ts +23 -0
- package/dist/data/symbols/customSymbol.js +48 -0
- package/dist/data/symbols/customTextSymbol.d.ts +33 -0
- package/dist/data/symbols/customTextSymbol.js +106 -0
- package/dist/data/symbols/dartSymbol.d.ts +35 -0
- package/dist/data/symbols/dartSymbol.js +110 -0
- package/dist/data/symbols/directionLinkerSymbol.d.ts +36 -0
- package/dist/data/symbols/directionLinkerSymbol.js +259 -0
- package/dist/data/symbols/galaxySymbol.d.ts +26 -0
- package/dist/data/symbols/galaxySymbol.js +74 -0
- package/dist/data/symbols/index.d.ts +3 -0
- package/dist/data/symbols/index.js +10 -0
- package/dist/data/symbols/letterSymbol.d.ts +31 -0
- package/dist/data/symbols/letterSymbol.js +137 -0
- package/dist/data/symbols/lotusSymbol.d.ts +29 -0
- package/dist/data/symbols/lotusSymbol.js +132 -0
- package/dist/data/symbols/minesweeperSymbol.d.ts +31 -0
- package/dist/data/symbols/minesweeperSymbol.js +100 -0
- package/dist/data/symbols/multiEntrySymbol.d.ts +11 -0
- package/dist/data/symbols/multiEntrySymbol.js +14 -0
- package/dist/data/symbols/myopiaSymbol.d.ts +34 -0
- package/dist/data/symbols/myopiaSymbol.js +187 -0
- package/dist/data/symbols/numberSymbol.d.ts +19 -0
- package/dist/data/symbols/numberSymbol.js +41 -0
- package/dist/data/symbols/symbol.d.ts +16 -0
- package/dist/data/symbols/symbol.js +51 -0
- package/dist/data/symbols/symbols.gen.d.ts +10 -0
- package/dist/data/symbols/symbols.gen.js +14 -0
- package/dist/data/symbols/viewpointSymbol.d.ts +31 -0
- package/dist/data/symbols/viewpointSymbol.js +106 -0
- package/dist/data/tile.d.ts +26 -0
- package/dist/data/tile.js +68 -0
- package/dist/data/tileConnections.d.ts +25 -0
- package/dist/data/tileConnections.js +74 -0
- package/dist/data/validate.d.ts +5 -0
- package/dist/data/validate.js +131 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.js +100 -0
- package/dist/polyfill/streamPolyfill.d.ts +2 -0
- package/dist/polyfill/streamPolyfill.js +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
|
+
import GridData from '../grid';
|
|
3
|
+
import { State } from '../primitives';
|
|
4
|
+
import Rule from './rule';
|
|
5
|
+
class CustomRule extends Rule {
|
|
6
|
+
/**
|
|
7
|
+
* A custom rule with a description and thumbnail grid.
|
|
8
|
+
*
|
|
9
|
+
* This rule validates answers based on the provided solution.
|
|
10
|
+
*
|
|
11
|
+
* @param description - The description of the rule.
|
|
12
|
+
* @param grid - The thumbnail grid of the rule, preferably 5x4 in size.
|
|
13
|
+
*/
|
|
14
|
+
constructor(description, grid) {
|
|
15
|
+
super();
|
|
16
|
+
Object.defineProperty(this, "description", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: description
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "grid", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: grid
|
|
27
|
+
});
|
|
28
|
+
this.description = description;
|
|
29
|
+
this.grid = grid;
|
|
30
|
+
}
|
|
31
|
+
get id() {
|
|
32
|
+
return `custom`;
|
|
33
|
+
}
|
|
34
|
+
get explanation() {
|
|
35
|
+
return this.description;
|
|
36
|
+
}
|
|
37
|
+
get configs() {
|
|
38
|
+
return CustomRule.configs;
|
|
39
|
+
}
|
|
40
|
+
createExampleGrid() {
|
|
41
|
+
return this.grid;
|
|
42
|
+
}
|
|
43
|
+
get searchVariants() {
|
|
44
|
+
return CustomRule.SEARCH_VARIANTS;
|
|
45
|
+
}
|
|
46
|
+
validateGrid(_grid) {
|
|
47
|
+
return { state: State.Incomplete };
|
|
48
|
+
}
|
|
49
|
+
copyWith({ description, grid, }) {
|
|
50
|
+
return new CustomRule(description ?? this.description, grid ?? this.grid);
|
|
51
|
+
}
|
|
52
|
+
get validateWithSolution() {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(CustomRule, "EXAMPLE_GRID", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: Object.freeze(new GridData(5, 4))
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(CustomRule, "configs", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: Object.freeze([
|
|
67
|
+
{
|
|
68
|
+
type: ConfigType.String,
|
|
69
|
+
default: 'A *custom* rule',
|
|
70
|
+
field: 'description',
|
|
71
|
+
description: 'Description',
|
|
72
|
+
configurable: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: ConfigType.Grid,
|
|
76
|
+
default: CustomRule.EXAMPLE_GRID,
|
|
77
|
+
field: 'grid',
|
|
78
|
+
description: 'Thumbnail Grid',
|
|
79
|
+
configurable: true,
|
|
80
|
+
},
|
|
81
|
+
])
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(CustomRule, "SEARCH_VARIANTS", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
configurable: true,
|
|
86
|
+
writable: true,
|
|
87
|
+
value: [
|
|
88
|
+
new CustomRule('A *custom* rule', CustomRule.EXAMPLE_GRID).searchVariant(),
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
export default CustomRule;
|
|
92
|
+
export const instance = new CustomRule('', GridData.create([]));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AnyConfig } from '../config';
|
|
2
|
+
import GridData from '../grid';
|
|
3
|
+
import { RuleState } from '../primitives';
|
|
4
|
+
import Rule, { SearchVariant } from './rule';
|
|
5
|
+
export default class ForesightRule extends Rule {
|
|
6
|
+
readonly count: number;
|
|
7
|
+
readonly regenInterval: number;
|
|
8
|
+
readonly startFull: boolean;
|
|
9
|
+
private static readonly EXAMPLE_GRID;
|
|
10
|
+
private static readonly CONFIGS;
|
|
11
|
+
private static readonly SEARCH_VARIANTS;
|
|
12
|
+
/**
|
|
13
|
+
* **Foresight: Show hints**
|
|
14
|
+
*/
|
|
15
|
+
constructor(count: number, regenInterval: number, startFull: boolean);
|
|
16
|
+
get id(): string;
|
|
17
|
+
get explanation(): string;
|
|
18
|
+
get visibleWhenSolving(): boolean;
|
|
19
|
+
get configs(): readonly AnyConfig[] | null;
|
|
20
|
+
createExampleGrid(): GridData;
|
|
21
|
+
get searchVariants(): SearchVariant[];
|
|
22
|
+
validateGrid(_grid: GridData): RuleState;
|
|
23
|
+
get necessaryForCompletion(): boolean;
|
|
24
|
+
copyWith({ count, regenInterval, startFull, }: {
|
|
25
|
+
count?: number;
|
|
26
|
+
regenInterval?: number;
|
|
27
|
+
startFull?: boolean;
|
|
28
|
+
}): this;
|
|
29
|
+
}
|
|
30
|
+
export declare const instance: ForesightRule;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
|
+
import GridData from '../grid';
|
|
3
|
+
import { State } from '../primitives';
|
|
4
|
+
import CustomIconSymbol from '../symbols/customIconSymbol';
|
|
5
|
+
import Rule from './rule';
|
|
6
|
+
class ForesightRule extends Rule {
|
|
7
|
+
/**
|
|
8
|
+
* **Foresight: Show hints**
|
|
9
|
+
*/
|
|
10
|
+
constructor(count, regenInterval, startFull) {
|
|
11
|
+
super();
|
|
12
|
+
Object.defineProperty(this, "count", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: count
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(this, "regenInterval", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: regenInterval
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(this, "startFull", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: startFull
|
|
29
|
+
});
|
|
30
|
+
this.count = count;
|
|
31
|
+
this.regenInterval = regenInterval;
|
|
32
|
+
this.startFull = startFull;
|
|
33
|
+
}
|
|
34
|
+
get id() {
|
|
35
|
+
return `foresight`;
|
|
36
|
+
}
|
|
37
|
+
get explanation() {
|
|
38
|
+
return `*Foresight:* Show hints`;
|
|
39
|
+
}
|
|
40
|
+
get visibleWhenSolving() {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
get configs() {
|
|
44
|
+
return ForesightRule.CONFIGS;
|
|
45
|
+
}
|
|
46
|
+
createExampleGrid() {
|
|
47
|
+
return ForesightRule.EXAMPLE_GRID;
|
|
48
|
+
}
|
|
49
|
+
get searchVariants() {
|
|
50
|
+
return ForesightRule.SEARCH_VARIANTS;
|
|
51
|
+
}
|
|
52
|
+
validateGrid(_grid) {
|
|
53
|
+
return { state: State.Incomplete };
|
|
54
|
+
}
|
|
55
|
+
get necessaryForCompletion() {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
copyWith({ count, regenInterval, startFull, }) {
|
|
59
|
+
return new ForesightRule(count ?? this.count, regenInterval ?? this.regenInterval, startFull ?? this.startFull);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
Object.defineProperty(ForesightRule, "EXAMPLE_GRID", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: Object.freeze(GridData.create(['.']).addSymbol(new CustomIconSymbol('', GridData.create([]), 0, 0, 'MdRemoveRedEye')))
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(ForesightRule, "CONFIGS", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: Object.freeze([
|
|
73
|
+
{
|
|
74
|
+
type: ConfigType.Number,
|
|
75
|
+
default: 5,
|
|
76
|
+
min: 1,
|
|
77
|
+
field: 'count',
|
|
78
|
+
description: 'Foresight count',
|
|
79
|
+
configurable: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: ConfigType.Number,
|
|
83
|
+
default: 30,
|
|
84
|
+
min: 1,
|
|
85
|
+
field: 'regenInterval',
|
|
86
|
+
description: 'Regen Interval (seconds)',
|
|
87
|
+
configurable: true,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: ConfigType.Boolean,
|
|
91
|
+
default: false,
|
|
92
|
+
field: 'startFull',
|
|
93
|
+
description: 'Start with full foresight',
|
|
94
|
+
configurable: true,
|
|
95
|
+
},
|
|
96
|
+
])
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(ForesightRule, "SEARCH_VARIANTS", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: [
|
|
103
|
+
new ForesightRule(5, 30, false).searchVariant(),
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
export default ForesightRule;
|
|
107
|
+
export const instance = new ForesightRule(5, 30, false);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AnyConfig } from '../config';
|
|
2
|
+
import Configurable from '../configurable';
|
|
3
|
+
export declare class Row extends Configurable {
|
|
4
|
+
/**
|
|
5
|
+
* The note to play at this row, or null to keep the current note from the previous control line.
|
|
6
|
+
* If this is null from the first control line, the note will be silent.
|
|
7
|
+
*/
|
|
8
|
+
readonly note: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* The velocity to play the note at, or null to keep the current velocity from the previous control line.
|
|
11
|
+
* Ranges from 0 to 1
|
|
12
|
+
*/
|
|
13
|
+
readonly velocity: number | null;
|
|
14
|
+
private static readonly CONFIGS;
|
|
15
|
+
constructor(
|
|
16
|
+
/**
|
|
17
|
+
* The note to play at this row, or null to keep the current note from the previous control line.
|
|
18
|
+
* If this is null from the first control line, the note will be silent.
|
|
19
|
+
*/
|
|
20
|
+
note: string | null,
|
|
21
|
+
/**
|
|
22
|
+
* The velocity to play the note at, or null to keep the current velocity from the previous control line.
|
|
23
|
+
* Ranges from 0 to 1
|
|
24
|
+
*/
|
|
25
|
+
velocity: number | null);
|
|
26
|
+
get configs(): readonly AnyConfig[] | null;
|
|
27
|
+
copyWith({ note, velocity, }: {
|
|
28
|
+
note?: string | null;
|
|
29
|
+
velocity?: number | null;
|
|
30
|
+
}): this;
|
|
31
|
+
}
|
|
32
|
+
export declare class ControlLine extends Configurable {
|
|
33
|
+
readonly column: number;
|
|
34
|
+
readonly bpm: number | null;
|
|
35
|
+
readonly pedal: boolean | null;
|
|
36
|
+
readonly checkpoint: boolean;
|
|
37
|
+
readonly rows: readonly Row[];
|
|
38
|
+
private static readonly CONFIGS;
|
|
39
|
+
/**
|
|
40
|
+
* Configure playback settings, taking effect at the given column (inclusive)
|
|
41
|
+
* @param column The column at which the settings take effect
|
|
42
|
+
* @param bpm The new beats per minute, or null to keep the current value from the previous control line
|
|
43
|
+
* @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
|
|
44
|
+
* @param checkpoint Whether this control line is a checkpoint
|
|
45
|
+
* @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.
|
|
46
|
+
*/
|
|
47
|
+
constructor(column: number, bpm: number | null, pedal: boolean | null, checkpoint: boolean, rows: readonly Row[]);
|
|
48
|
+
get configs(): readonly AnyConfig[] | null;
|
|
49
|
+
copyWith({ column, bpm, pedal, checkpoint, rows, }: {
|
|
50
|
+
column?: number;
|
|
51
|
+
bpm?: number | null;
|
|
52
|
+
pedal?: boolean | null;
|
|
53
|
+
checkpoint?: boolean;
|
|
54
|
+
rows?: readonly Row[];
|
|
55
|
+
}): this;
|
|
56
|
+
withColumn(column: number): this;
|
|
57
|
+
withBpm(bpm: number | null): this;
|
|
58
|
+
withPedal(pedal: boolean | null): this;
|
|
59
|
+
withCheckpoint(checkpoint: boolean): this;
|
|
60
|
+
withRows(rows: readonly Row[]): this;
|
|
61
|
+
equals(other: ControlLine): boolean;
|
|
62
|
+
get isEmpty(): boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare const instance: undefined;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { ConfigType } from '../config';
|
|
2
|
+
import Configurable from '../configurable';
|
|
3
|
+
export class Row extends Configurable {
|
|
4
|
+
constructor(
|
|
5
|
+
/**
|
|
6
|
+
* The note to play at this row, or null to keep the current note from the previous control line.
|
|
7
|
+
* If this is null from the first control line, the note will be silent.
|
|
8
|
+
*/
|
|
9
|
+
note,
|
|
10
|
+
/**
|
|
11
|
+
* The velocity to play the note at, or null to keep the current velocity from the previous control line.
|
|
12
|
+
* Ranges from 0 to 1
|
|
13
|
+
*/
|
|
14
|
+
velocity) {
|
|
15
|
+
super();
|
|
16
|
+
Object.defineProperty(this, "note", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: note
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "velocity", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: velocity
|
|
27
|
+
});
|
|
28
|
+
this.note = note;
|
|
29
|
+
this.velocity = velocity;
|
|
30
|
+
}
|
|
31
|
+
get configs() {
|
|
32
|
+
return Row.CONFIGS;
|
|
33
|
+
}
|
|
34
|
+
copyWith({ note, velocity, }) {
|
|
35
|
+
return new Row(note !== undefined ? note : this.note, velocity !== undefined ? velocity : this.velocity);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
Object.defineProperty(Row, "CONFIGS", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: Object.freeze([
|
|
43
|
+
{
|
|
44
|
+
type: ConfigType.NullableNote,
|
|
45
|
+
default: 'C4',
|
|
46
|
+
field: 'note',
|
|
47
|
+
description: 'Note',
|
|
48
|
+
configurable: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: ConfigType.NullableNumber,
|
|
52
|
+
default: 0.6,
|
|
53
|
+
min: 0,
|
|
54
|
+
max: 1,
|
|
55
|
+
step: 0.2,
|
|
56
|
+
field: 'velocity',
|
|
57
|
+
description: 'Velocity',
|
|
58
|
+
configurable: true,
|
|
59
|
+
},
|
|
60
|
+
])
|
|
61
|
+
});
|
|
62
|
+
export class ControlLine extends Configurable {
|
|
63
|
+
/**
|
|
64
|
+
* Configure playback settings, taking effect at the given column (inclusive)
|
|
65
|
+
* @param column The column at which the settings take effect
|
|
66
|
+
* @param bpm The new beats per minute, or null to keep the current value from the previous control line
|
|
67
|
+
* @param pedal Whether the pedal is pressed, or null to keep the current value from the previous control line
|
|
68
|
+
* @param checkpoint Whether this control line is a checkpoint
|
|
69
|
+
* @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.
|
|
70
|
+
*/
|
|
71
|
+
constructor(column, bpm, pedal, checkpoint, rows) {
|
|
72
|
+
super();
|
|
73
|
+
Object.defineProperty(this, "column", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: column
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(this, "bpm", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: bpm
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(this, "pedal", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
value: pedal
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(this, "checkpoint", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
configurable: true,
|
|
94
|
+
writable: true,
|
|
95
|
+
value: checkpoint
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(this, "rows", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: rows
|
|
102
|
+
});
|
|
103
|
+
this.column = Math.floor(column);
|
|
104
|
+
this.bpm = bpm;
|
|
105
|
+
this.pedal = pedal;
|
|
106
|
+
this.checkpoint = checkpoint;
|
|
107
|
+
this.rows = rows;
|
|
108
|
+
}
|
|
109
|
+
get configs() {
|
|
110
|
+
return ControlLine.CONFIGS;
|
|
111
|
+
}
|
|
112
|
+
copyWith({ column, bpm, pedal, checkpoint, rows, }) {
|
|
113
|
+
return new ControlLine(column ?? this.column, bpm !== undefined ? bpm : this.bpm, pedal !== undefined ? pedal : this.pedal, checkpoint ?? this.checkpoint, rows ?? this.rows);
|
|
114
|
+
}
|
|
115
|
+
withColumn(column) {
|
|
116
|
+
return this.copyWith({ column });
|
|
117
|
+
}
|
|
118
|
+
withBpm(bpm) {
|
|
119
|
+
return this.copyWith({ bpm });
|
|
120
|
+
}
|
|
121
|
+
withPedal(pedal) {
|
|
122
|
+
return this.copyWith({ pedal });
|
|
123
|
+
}
|
|
124
|
+
withCheckpoint(checkpoint) {
|
|
125
|
+
return this.copyWith({ checkpoint });
|
|
126
|
+
}
|
|
127
|
+
withRows(rows) {
|
|
128
|
+
return this.copyWith({ rows });
|
|
129
|
+
}
|
|
130
|
+
equals(other) {
|
|
131
|
+
return (this.column === other.column &&
|
|
132
|
+
this.bpm === other.bpm &&
|
|
133
|
+
this.pedal === other.pedal &&
|
|
134
|
+
this.checkpoint === other.checkpoint &&
|
|
135
|
+
this.rows.length === other.rows.length &&
|
|
136
|
+
this.rows.every((row, i) => {
|
|
137
|
+
const otherRow = other.rows[i];
|
|
138
|
+
return row.note === otherRow.note && row.velocity === otherRow.velocity;
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
get isEmpty() {
|
|
142
|
+
return (this.bpm === null &&
|
|
143
|
+
this.pedal === null &&
|
|
144
|
+
!this.checkpoint &&
|
|
145
|
+
!this.rows.some(row => row.note !== null || row.velocity !== null));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
Object.defineProperty(ControlLine, "CONFIGS", {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
writable: true,
|
|
152
|
+
value: Object.freeze([
|
|
153
|
+
{
|
|
154
|
+
type: ConfigType.NullableNumber,
|
|
155
|
+
default: 120,
|
|
156
|
+
min: 20,
|
|
157
|
+
max: 1000,
|
|
158
|
+
field: 'bpm',
|
|
159
|
+
description: 'BPM',
|
|
160
|
+
configurable: true,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: ConfigType.NullableBoolean,
|
|
164
|
+
default: false,
|
|
165
|
+
field: 'pedal',
|
|
166
|
+
description: 'Pedal',
|
|
167
|
+
configurable: true,
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: ConfigType.Boolean,
|
|
171
|
+
default: false,
|
|
172
|
+
field: 'checkpoint',
|
|
173
|
+
description: 'Checkpoint',
|
|
174
|
+
configurable: true,
|
|
175
|
+
},
|
|
176
|
+
])
|
|
177
|
+
});
|
|
178
|
+
export const instance = undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AnyConfig } from '../config';
|
|
2
|
+
import { GridChangeHandler } from '../events/onGridChange';
|
|
3
|
+
import { GridResizeHandler } from '../events/onGridResize';
|
|
4
|
+
import { SetGridHandler } from '../events/onSetGrid';
|
|
5
|
+
import GridData from '../grid';
|
|
6
|
+
import { RuleState } from '../primitives';
|
|
7
|
+
import { ControlLine } from './musicControlLine';
|
|
8
|
+
import Rule, { SearchVariant } from './rule';
|
|
9
|
+
export default class MusicGridRule extends Rule implements GridChangeHandler, SetGridHandler, GridResizeHandler {
|
|
10
|
+
readonly controlLines: readonly ControlLine[];
|
|
11
|
+
readonly track: GridData | null;
|
|
12
|
+
private static readonly EXAMPLE_GRID;
|
|
13
|
+
private static readonly CONFIGS;
|
|
14
|
+
private static readonly SEARCH_VARIANTS;
|
|
15
|
+
/**
|
|
16
|
+
* **Music Grid: Listen to the solution**
|
|
17
|
+
* @param controlLines Denote changes in the playback settings. At least one control line at column 0 should be present to enable playback.
|
|
18
|
+
* @param track The grid to be played when "listen" is clicked. Set as null to play the solution.
|
|
19
|
+
*/
|
|
20
|
+
constructor(controlLines: readonly ControlLine[], track: GridData | null);
|
|
21
|
+
get id(): string;
|
|
22
|
+
get explanation(): string;
|
|
23
|
+
get configs(): readonly AnyConfig[] | null;
|
|
24
|
+
createExampleGrid(): GridData;
|
|
25
|
+
get searchVariants(): SearchVariant[];
|
|
26
|
+
validateGrid(_grid: GridData): RuleState;
|
|
27
|
+
onSetGrid(_oldGrid: GridData, newGrid: GridData): GridData;
|
|
28
|
+
onGridChange(newGrid: GridData): this;
|
|
29
|
+
onGridResize(_grid: GridData, mode: 'insert' | 'remove', direction: 'row' | 'column', index: number): this | null;
|
|
30
|
+
/**
|
|
31
|
+
* Add or replace a control line.
|
|
32
|
+
* @param controlLine The control line to set.
|
|
33
|
+
* @returns A new rule with the control line set.
|
|
34
|
+
*/
|
|
35
|
+
setControlLine(controlLine: ControlLine): this;
|
|
36
|
+
withTrack(track: GridData | null): this;
|
|
37
|
+
copyWith({ controlLines, track, }: {
|
|
38
|
+
controlLines?: readonly ControlLine[];
|
|
39
|
+
track?: GridData | null;
|
|
40
|
+
}): this;
|
|
41
|
+
get validateWithSolution(): boolean;
|
|
42
|
+
get isSingleton(): boolean;
|
|
43
|
+
static mergeControlLines(...lines: ControlLine[]): ControlLine;
|
|
44
|
+
static deduplicateControlLines(lines: readonly ControlLine[]): ControlLine[];
|
|
45
|
+
}
|
|
46
|
+
export declare const instance: MusicGridRule;
|