Skip to content

Commit

Permalink
main: organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeHats committed Feb 3, 2024
1 parent ddea532 commit 20d083e
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 61 deletions.
11 changes: 6 additions & 5 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"printWidth": 80,
"tabWidth": 4,
"trailingComma": "all",
"proseWrap": "always",
"experimentalTernaries": true
"printWidth": 80,
"tabWidth": 4,
"trailingComma": "all",
"proseWrap": "always",
"experimentalTernaries": true,
"plugins": ["prettier-plugin-organize-imports"]
}
9 changes: 3 additions & 6 deletions src/emoji/PostDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { Post } from "@/emoji/Post";
import { EventIterator } from "@/lib/EventIterator";
import PointerDragCover from "@/lib/PointerDragCover";
import { Spring } from "@/lib/Spring";
import { Ticker } from "@/lib/Ticker";
import { assertExists } from "@/lib/assert";
import { inOutSin, outExpo } from "@/lib/easings";
import { inOutSin } from "@/lib/easings";
import AABB from "@/lib/geom/AABB";
import Circle from "@/lib/geom/Circle";
import { Vector2 } from "@/lib/geom/Vector2";
import { reactive, memo } from "@/lib/signia";
import { memo, reactive } from "@/lib/signia";
import { SvgPathBuilder } from "@/lib/svgPathBuilder";
import { tailwindColors } from "@/lib/theme";
import { clamp, exhaustiveSwitchError, invLerp, lerp } from "@/lib/utils";
import { computed, track } from "@tldraw/state";
import classNames from "classnames";
import { useState, PointerEvent, useLayoutEffect } from "react";
import { PointerEvent, useLayoutEffect, useState } from "react";
import { FiPlus } from "react-icons/fi";

const TRIGGER_SIZE = 32;
Expand Down
1 change: 0 additions & 1 deletion src/geometry/GeometryExperiment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
useGestureDetector,
} from "@/lib/hooks/useGestureDetector";
import { reactive } from "@/lib/signia";
import { SvgPathBuilder } from "@/lib/svgPathBuilder";
import { tailwindColors } from "@/lib/theme";
import { track } from "@tldraw/state";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/geometry/paths.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SvgPathBuilder } from "@/lib/svgPathBuilder";
import { Vector2 } from "@/lib/geom/Vector2";
import { SvgPathBuilder } from "@/lib/svgPathBuilder";

export const paths = {
x(position: Vector2, size = 5) {
Expand Down
1 change: 0 additions & 1 deletion src/lib/DebugSvg.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { scale } from "@/blob-tree/canvas";
import {
DebugDraw,
FillOptions,
Expand Down
1 change: 0 additions & 1 deletion src/lib/EventEmitter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { promiseWithResolve } from "@/lib/utils";
import { unstable_batchedUpdates } from "react-dom";
import { s } from "vitest/dist/reporters-OH1c16Kq";

export type Unsubscribe = () => void;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/Spring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
atom as createAtom,
useValue,
} from "@tldraw/state";
import { useEffect, useLayoutEffect, useMemo, useState } from "react";
import { useEffect, useState } from "react";

function asSignal(signal: number | Signal<number>): Atom<number> {
const writeTarget = createAtom(
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Ticker.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import EventEmitter, { Unsubscribe } from "@/lib/EventEmitter";
import { reactive } from "@/lib/signia";
import { frameLoop } from "@/lib/utils";
import { useEffect, useState, createContext, useContext } from "react";
import { createContext, useContext, useEffect, useState } from "react";
import { generateUUID } from "three/src/math/MathUtils";

export class Ticker {
Expand Down
1 change: 0 additions & 1 deletion src/lib/geom/AABB.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Vector2 } from "@/lib/geom/Vector2";
import { mapRange } from "@/lib/utils";

export default class AABB {
static ZERO = new AABB(Vector2.ZERO, Vector2.ZERO);
Expand Down
10 changes: 5 additions & 5 deletions src/lib/gl/GlProgram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ export class GlProgram {
}
private addUniform<T, Uniform extends GlUniform<T>>(
GlUniformType: new (
gl: Gl,
name: string,
location: WebGLUniformLocation,
initialValue: GlUniformInitialValue<T>,
) => Uniform,
gl: Gl,
name: string,
location: WebGLUniformLocation,
initialValue: GlUniformInitialValue<T>,
) => Uniform,
name: string,
initialValue: GlUniformInitialValue<T>,
): Uniform {
Expand Down
6 changes: 4 additions & 2 deletions src/lib/hooks/useGestureDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export type TapGestureHandler<Args extends readonly unknown[] = []> = (
event: PointerEvent,
...args: Args
) => void;
export type DragStartGestureHandler<Args extends readonly unknown[] = []> =
(event: PointerEvent, ...args: Args) => DragGestureHandler | null;
export type DragStartGestureHandler<Args extends readonly unknown[] = []> = (
event: PointerEvent,
...args: Args
) => DragGestureHandler | null;
export interface DragGestureHandler {
couldBeTap: boolean;
pointerCapture: boolean;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/hooks/useStoredState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
import { Initializer, UpdateAction, applyUpdate } from "@/lib/utils";
import { useCallback, useEffect, useState } from "react";

interface Opts { delayMs?: number | null }
interface Opts {
delayMs?: number | null;
}

export function useStorageState<T>(
storage: Storage | WatchableStorage,
Expand Down
4 changes: 1 addition & 3 deletions src/lib/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ export class Schema<Parsed> {
return new Schema<V[number]>(validate, validate, identity);
}

static arrayOf<Item>(
itemSchema: Schema<Item>,
): Schema<readonly Item[]> {
static arrayOf<Item>(itemSchema: Schema<Item>): Schema<readonly Item[]> {
return new Schema<readonly Item[]>(
(input) => {
if (!Array.isArray(input)) {
Expand Down
20 changes: 16 additions & 4 deletions src/lib/shader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ export interface ScalarGlslType {
readonly name: ScalarGlslTypeName;
}

export interface BoolGlslType { readonly type: "scalar"; readonly name: "bool" }
export interface IntGlslType { readonly type: "scalar"; readonly name: "int" }
export interface UintGlslType { readonly type: "scalar"; readonly name: "uint" }
export interface FloatGlslType { readonly type: "scalar"; readonly name: "float" }
export interface BoolGlslType {
readonly type: "scalar";
readonly name: "bool";
}
export interface IntGlslType {
readonly type: "scalar";
readonly name: "int";
}
export interface UintGlslType {
readonly type: "scalar";
readonly name: "uint";
}
export interface FloatGlslType {
readonly type: "scalar";
readonly name: "float";
}
export interface DoubleGlslType {
readonly type: "scalar";
readonly name: "double";
Expand Down
2 changes: 1 addition & 1 deletion src/lib/signia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function memo<This extends object, Value>(
);
});
return function (this: This) {
return assertExists(computeds.get(this )).value;
return assertExists(computeds.get(this)).value;
};
}

Expand Down
12 changes: 7 additions & 5 deletions src/splatapus/model/InterpolationCache.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import { StrokeCenterPoint } from "@/splatapus/model/perfectFreehand";
interface CachedValues {
keyPoints: ReadonlySet<SplatKeyPoint>;
versions: ReadonlySet<SplatShapeVersion>;
interpolators: readonly {
x: Interpolator;
y: Interpolator;
r: Interpolator;
}[] | null;
interpolators:
| readonly {
x: Interpolator;
y: Interpolator;
r: Interpolator;
}[]
| null;
}

class InterpolationCache {
Expand Down
10 changes: 2 additions & 8 deletions src/splatapus/model/Interpolator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ class TwoInterpolator implements Interpolator {
}

class TpsInterpolator extends Tps implements Interpolator {
constructor(
centers: readonly Vector2[],
values: readonly number[],
) {
constructor(centers: readonly Vector2[], values: readonly number[]) {
super(
centers.map(({ x, y }) => [x, y]),
values,
Expand All @@ -56,10 +53,7 @@ class TpsInterpolator extends Tps implements Interpolator {
export class AutoInterpolator implements Interpolator {
private readonly interpolator: Interpolator;

constructor(
centers: readonly Vector2[],
values: readonly number[],
) {
constructor(centers: readonly Vector2[], values: readonly number[]) {
assert(centers.length === values.length);
switch (centers.length) {
case 0:
Expand Down
4 changes: 3 additions & 1 deletion src/splatapus/model/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
keys,
} from "@/lib/utils";

export interface UnknownTableEntry { readonly id: string }
export interface UnknownTableEntry {
readonly id: string;
}
export type TableData<T extends UnknownTableEntry> = ReadonlyObjectMap<
T["id"],
T
Expand Down
2 changes: 1 addition & 1 deletion src/splatapus3/model/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const KeyPoint = createRecordType("keyPoint", {
validator: KeyPointSchema.asValidator(),
});

export type Shape = BaseRecord<"shape", RecordId<Shape>>
export type Shape = BaseRecord<"shape", RecordId<Shape>>;
export const ShapeSchema = Schema.object<Shape>({
typeName: Schema.value("shape"),
id: idSchema<ShapeId>("shape"),
Expand Down
4 changes: 1 addition & 3 deletions src/terrain/Terrain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import { Quadtree, quadtree } from "d3-quadtree";
function assignPlates(plateCount: number, terrain: Terrain) {
const remainingCellIds = new Set(terrain.activeCellIds);
const queue = new RandomQueue(terrain.activeCellIds);
const plateIdByCellId = new Array<number>(
terrain.activeCellIds.length,
);
const plateIdByCellId = new Array<number>(terrain.activeCellIds.length);

const plates = times(plateCount, (id) => {
const initialCellId = queue.pop();
Expand Down
5 changes: 4 additions & 1 deletion src/terrain/TerrainCell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export class TerrainCell {
public readonly position: Vector2;
public readonly neighbourCellIds: readonly number[];
public readonly neighbourCellIdsByEdgeIndex: readonly (number | null)[];
public readonly edgeIndexByNeighbourCellId: Record<number, number | undefined>;
public readonly edgeIndexByNeighbourCellId: Record<
number,
number | undefined
>;
public readonly polygon: readonly Vector2[];
private readonly noiseHeight: number;
private heightAdjustment = 0;
Expand Down
14 changes: 7 additions & 7 deletions src/trees/LeafPattern.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { DebugArrow, DebugPointX } from "@/lib/DebugSvg";
import { DebugPointX } from "@/lib/DebugSvg";
import { Ticker } from "@/lib/Ticker";
import { assert } from "@/lib/assert";
import * as easings from "@/lib/easings";
import AABB from "@/lib/geom/AABB";
import { Vector2 } from "@/lib/geom/Vector2";
import { SvgApp } from "@/lib/react/Svg";
import { clamp, mapRange } from "@/lib/utils";
import { useEffect, useState } from "react";
import * as easings from "@/lib/easings";
import { assert } from "@/lib/assert";
import { SvgPathBuilder } from "@/lib/svgPathBuilder";
import { degToRad } from "three/src/math/MathUtils";
import { clamp, mapRange } from "@/lib/utils";
import { useNoise4d } from "@/trees/TreesApp";
import { Ticker } from "@/lib/Ticker";
import { track } from "@tldraw/state";
import { useEffect, useState } from "react";
import { degToRad } from "three/src/math/MathUtils";

const viewbox = AABB.fromLeftTopWidthHeight(0, 0, 100, 100);
const unitRange = AABB.fromLeftTopRightBottom(-1, -1, 1, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/wires/Model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function memo<This extends object, Value>(
);
});
return function (this: This) {
return assertExists(computeds.get(this )).value;
return assertExists(computeds.get(this)).value;
};
}

Expand Down

0 comments on commit 20d083e

Please sign in to comment.