Skip to content

Commit

Permalink
Organize / clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
imericxu committed Jul 10, 2024
1 parent f521656 commit df9de74
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/app/components/OptionsForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { type FormActionType } from "@/app/page";
import { MazeController, type MazeSettings } from "@/lib/MazeController";
import { getFloatFromForm, getIntFromForm } from "@/lib/utils";
import { useCallback, useRef, type ReactElement } from "react";
Expand All @@ -11,7 +12,6 @@ import {
TextField,
} from "react-aria-components";
import { twMerge } from "tailwind-merge";
import { FormActionType } from "../page";

export interface OptionsFormProps {
onAction: (action: FormActionType, settings: MazeSettings) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Metadata } from "next";
import { Lato } from "next/font/google";
import { type ReactElement, type ReactNode } from "react";
import "./globals.scss";
import { twMerge } from "tailwind-merge";
import "./globals.scss";

const latoFont = Lato({
weight: ["300", "400", "700"],
Expand Down
8 changes: 4 additions & 4 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"use client";
import { MazeSettings, MazeController } from "@/lib/MazeController";
import { MazeController, type MazeSettings } from "@/lib/MazeController";
import { type RectSize } from "@/lib/twoDimens";
import {
useCallback,
useEffect,
useRef,
useState,
type ReactElement,
} from "react";
import OptionsForm from "./components/OptionsForm";
import { match } from "ts-pattern";
import { Label, Radio, RadioGroup } from "react-aria-components";
import { RectSize } from "@/lib/twoDimens";
import { match } from "ts-pattern";
import OptionsForm from "./components/OptionsForm";

export type FormActionType = "generate" | "solve" | "clear";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/MazeCell.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Idx2d } from "./twoDimens";
import { type Idx2d } from "./twoDimens";

export type CellState = "empty" | "partial" | "solid";

Expand Down
14 changes: 7 additions & 7 deletions src/lib/MazeController.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Mutex } from "async-mutex";
import { match } from "ts-pattern";
import {
type GenerationAlgorithm,
type SolveAlgorithm,
} from "./algorithms/algorithmTypes";
import { MazeGenerator } from "./algorithms/generating/MazeGenerator";
import { Wilsons } from "./algorithms/generating/Wilsons";
import { BFS } from "./algorithms/solving/BFS";
import { MazeSolver } from "./algorithms/solving/MazeSolver";
import { AnimationPromise } from "./AnimationPromise";
import { MazeCell } from "./MazeCell";
import { type MazeCell } from "./MazeCell";
import MazeDrawer from "./MazeDrawer";
import { RectSize } from "./twoDimens";
import { type RectSize } from "./twoDimens";
import { clamp, deepEqual } from "./utils";
import { BFS } from "./algorithms/solving/BFS";
import { match } from "ts-pattern";
import { MazeGenerator } from "./algorithms/generating/MazeGenerator";
import { MazeSolver } from "./algorithms/solving/MazeSolver";
import { Wilsons } from "./algorithms/generating/Wilsons";

export type MazeEvent = "generate" | "solve";

Expand Down
11 changes: 8 additions & 3 deletions src/lib/MazeDrawer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import colors from "tailwindcss/colors";
import { match } from "ts-pattern";
import { AnimationPromise } from "./AnimationPromise";
import { type MazeCell } from "./MazeCell";
import { RectSize, type Coord, type GridSize, type Idx2d } from "./twoDimens";
import { type MazeDimensions, type MazeEvent } from "./MazeController";
import {
type RectSize,
type Coord,
type GridSize,
type Idx2d,
} from "./twoDimens";
import { clamp, easeOutQuad, type Direction } from "./utils";
import { AnimationPromise } from "./AnimationPromise";
import { MazeDimensions, MazeEvent } from "./MazeController";

/** Colors used by the renderer. */
const COLOR = {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/algorithms/Algorithm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MazeCell } from "@/lib/MazeCell";
import { type MazeCell } from "@/lib/MazeCell";

export abstract class Algorithm {
private _finished: boolean = false;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/algorithms/generating/MazeGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MazeCell } from "@/lib/MazeCell";
import { GridSize } from "@/lib/twoDimens";
import { type GridSize } from "@/lib/twoDimens";
import { Algorithm } from "../Algorithm";

export abstract class MazeGenerator extends Algorithm {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/algorithms/generating/Wilsons.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MazeCell } from "@/lib/MazeCell";
import { type MazeCell } from "@/lib/MazeCell";
import { MazeGenerator } from "./MazeGenerator";
import { randomFromArray, randomFromSet } from "@/lib/utils";
import { match } from "ts-pattern";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/algorithms/solving/BFS.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MazeCell } from "@/lib/MazeCell";
import { type MazeCell } from "@/lib/MazeCell";
import { MazeSolver } from "./MazeSolver";
import { Deque } from "@datastructures-js/deque";
import { buildPath } from "./pathUtils";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/algorithms/solving/MazeSolver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MazeCell } from "@/lib/MazeCell";
import { type MazeCell } from "@/lib/MazeCell";
import { Algorithm } from "../Algorithm";

export abstract class MazeSolver extends Algorithm {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/algorithms/solving/Tremaux.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MazeCell } from "@/lib/MazeCell";
import { MazeSolver } from "./MazeSolver";
import { type MazeCell } from "@/lib/MazeCell";
import { randomFromArray } from "@/lib/utils";
import { MazeSolver } from "./MazeSolver";

export class Tremaux extends MazeSolver {
protected _step(): [boolean, Readonly<MazeCell>[]] {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/algorithms/solving/pathUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MazeCell } from "@/lib/MazeCell";
import { type MazeCell } from "@/lib/MazeCell";

export function buildPath(
cameFrom: Map<MazeCell, MazeCell>,
Expand Down

0 comments on commit df9de74

Please sign in to comment.