Skip to content

DI Codebase Cruft

Quick wins (delete or one-liner)

NB: LEAVE THESE ALONE!

WhatWhereWhy
Unused sizeOf_svgPathcommon/Extensions.ts:151Never called anywhere
Commented-out boilerplatecommon/Extensions.ts:464-471Dead code
Inconsistent hash() descriptorExtensions.ts:146 — uses writable:true, enumerable:trueEvery other extension uses false/false/false
debug = false flagRender.ts:20Face debug colors never enabled, dead path
hid_unknown = 1000000000000Constants.ts:14Magic debug number, unused

Redundancy worth consolidating

WhatWhereSavings
Coordinate method explosionCoordinates.ts (468 lines) — offsetByXY, spreadByXY, multiply_xBy, multiply_yBy, extendedByX, extendedByY, etc.A single map(fn) or transform({x, y}) replaces 10+ methods
Verbose/description gettersPoint.verbose, Point.pixelVerbose, Size.verbose, Rect.verbose — near-identical formatting across 3 classesExtract one formatter, parameterize
Timer propertiesMouse_Timer.ts — 5 separate timer properties + 5 start/stop pairsReplace with Map<string, Timeout> + generic start(name, fn, ms) / stop(name)
Extension.ts (472 lines)Repetitive Object.defineProperty boilerplateA helper define(proto, name, fn) cuts this by 60%

Over-engineering

WhatWhereSimplification
S_Component debug loggingS_Component.ts — 70+ lines of debug methods, hardcoded type dictionariesRip out to a central Debug util with a global toggle
Components nested dictComponents.tsDictionary<Dictionary<S_Component>> with manual cacheMap<string, Map<number, S_Component>> + merge createUnique into lookup with optional factory
Custom color mathColors.ts (394 lines) — full RGB/HSB, srgb/linear defined inline in multiple methodsAlready imports color2k. Use it. Remove custom
S_Component classExtends S_Hit_Target, adds only hid + component_id getterCould be a factory or just fields on S_Hit_Target

Inconsistency

WhatDetails
Store scatteringw_ stores defined in Hits (4), Hits_3D (2), Events (5), Setup (6+). No single "state" module. Hard to trace reactive flow
Persistence patternSome stores subscribe and write to localStorage, others don't. No consistent "persistent store" abstraction
Setup.ts is a god moduleImports from 7+ modules, owns stores + init + scale + precision + solid + dimensionals. Split into Stores.ts+Startup.ts`

Structural

WhatRisk
Circular dep hackS_Hit_Target.ts:8-12 — forward-declares hits as any, runtime-injected via setHitsManager(). Fragile
Import chainsTypes -> Managers -> Render -> Signals -> Types. Not broken yet, but one wrong import away from a cycle
CSS constants in TSConstants.ts:17 has prevent_selection_style as a string. Styling should live in CSS

Not worth touching

  • Coordinates.ts core math — ugly but correct and heavily used
  • Extensions.ts prototype augmentation — disagreeable pattern but deep in the codebase, high-risk refactor for low reward
  • Angle.ts quadrant methods — readable as-is, consolidation would hurt clarity