feat: launch local-first Sudoku workbench
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import type { PuzzleDefinition } from "../domain";
|
||||
import type {
|
||||
ExactSolveOptions,
|
||||
ExactSolveResult,
|
||||
GenerateClassicOptions,
|
||||
KillerCombinationOptions,
|
||||
KillerCombinationResult,
|
||||
LogicalSolveOptions,
|
||||
LogicalSolveResult,
|
||||
MinimizeOptions,
|
||||
} from "../solver";
|
||||
import type { NormalizedPuzzle, ValidationIssue } from "../domain";
|
||||
|
||||
export type SolverWorkerOperation =
|
||||
| {
|
||||
readonly kind: "solve";
|
||||
readonly puzzle: PuzzleDefinition;
|
||||
readonly options?: ExactSolveOptions;
|
||||
}
|
||||
| {
|
||||
readonly kind: "logical";
|
||||
readonly puzzle: PuzzleDefinition;
|
||||
readonly options?: LogicalSolveOptions;
|
||||
}
|
||||
| { readonly kind: "generate"; readonly options?: GenerateClassicOptions }
|
||||
| {
|
||||
readonly kind: "minimize";
|
||||
readonly puzzle: PuzzleDefinition;
|
||||
readonly options?: MinimizeOptions;
|
||||
}
|
||||
| {
|
||||
readonly kind: "killer-combinations";
|
||||
readonly options: KillerCombinationOptions;
|
||||
};
|
||||
|
||||
export interface SolverWorkerRequest {
|
||||
readonly id: string;
|
||||
readonly operation: SolverWorkerOperation;
|
||||
}
|
||||
|
||||
export type SolverWorkerValue =
|
||||
| ExactSolveResult
|
||||
| LogicalSolveResult
|
||||
| NormalizedPuzzle
|
||||
| KillerCombinationResult;
|
||||
|
||||
export interface SolverWorkerError {
|
||||
readonly name: string;
|
||||
readonly message: string;
|
||||
readonly issues?: readonly ValidationIssue[];
|
||||
}
|
||||
|
||||
export type SolverWorkerResponse =
|
||||
| {
|
||||
readonly id: string;
|
||||
readonly ok: true;
|
||||
readonly value: SolverWorkerValue;
|
||||
}
|
||||
| {
|
||||
readonly id: string;
|
||||
readonly ok: false;
|
||||
readonly error: SolverWorkerError;
|
||||
};
|
||||
Reference in New Issue
Block a user