From db9bc97e199e1a4b7380351da24cda3083d9acef Mon Sep 17 00:00:00 2001 From: Ralph Kuepper Date: Wed, 15 Jul 2026 18:33:32 +0200 Subject: [PATCH] =?UTF-8?q?fix(#53):=20stop=20exporting=20`Color`=20twice?= =?UTF-8?q?=20=E2=80=94=20it=20is=20a=20type,=20not=20a=20palette?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported in #53. `core/index.ts` exported the name `Color` twice: once as the RGBA TYPE (from ./types) and once as a palette MAP (from ./colors). Every consumer got both, and the map shadowed the thing people actually annotate with. The reporter asked whether dropping `Color` from ./colors and standardising on `Colors` would have side effects. It does not, and the palette loses nothing — it already had two other names: `Colors`, and `ColorConstants`, which is literally `= Color`. Three names for one map, one of them colliding with a type. Verified before removing, rather than assumed: - No code in engine, shooter, editor, garden or jump reads the palette through the name `Color` (i.e. `Color.Red`). The only `Color.*` hits are inside colors.ts itself, referring to its own local const. - `jump` DOES import `Color` from bloom/core — but only ever in TYPE position (`const WHITE: Color = { r, g, b, a }`), which the type re-export still serves. - The root index already re-exported the type separately (`export type { Vec2, Vec3, Vec4, Color }`), so `Color` stays available everywhere it was. - shooter compiles + runs; jump's TypeScript compiles (it now fails later, at link, on pre-existing engine drift — a different problem, see the jump commit). Claude-Session: https://claude.ai/code/session_01J1UWgMcrTNvwWeXcJ1T3Fp --- src/core/index.ts | 14 +++++++++++++- src/index.ts | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/core/index.ts b/src/core/index.ts index fca58d1..26e34e4 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,7 +1,19 @@ import { Color, Camera2D, Camera3D } from './types'; export type { Color, Vec2, Vec3, Vec4, Rect, Camera2D, Camera3D, Texture, Font, Sound, Music, Quat, Ray, BoundingBox, Model, Mat4, RayHit, FrustumPlanes } from './types'; -export { Color, ColorConstants, Colors } from './colors'; +// GH #53 — `Color` is deliberately NOT re-exported from './colors' any more. +// `Color` is the RGBA TYPE (`./types`, re-exported above); './colors' exports a +// palette MAP that also happened to be called `Color`, so the name arrived at +// every consumer as both a type and a value. It shadowed the thing people +// actually annotate with. The palette has always had two other names — +// `Colors` and `ColorConstants` (the latter is literally `= Color`) — so +// nothing is lost by dropping the third. +// +// Verified before removing: no code in engine, shooter, editor, garden or jump +// reads the palette through the name `Color` (i.e. `Color.Red`). `jump` imports +// `Color` from here, but only ever in TYPE position (`const WHITE: Color = {...}`), +// which the type re-export above still serves. +export { ColorConstants, Colors } from './colors'; export { Key, MouseButton } from './keys'; // FFI declarations diff --git a/src/index.ts b/src/index.ts index 822ec69..c9543d1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,9 @@ export { openFileDialog, saveFileDialog, writeFile, fileExists, readFile, getScreenToWorld2D, getWorldToScreen2D, - Color, ColorConstants, Colors, Key, MouseButton, + // `Color` is not here: it is the RGBA type, re-exported as a type below. + // The palette map is `Colors` / `ColorConstants` (GH #53). + ColorConstants, Colors, Key, MouseButton, injectKeyDown, injectKeyUp, isAnyInputPressed, getPlatform, isMobile, isTV, Platform, injectGamepadAxis, injectGamepadButtonDown, injectGamepadButtonUp, runGame,