From 4c4177c471aac494ba5a90ef524b395aca8a8ace Mon Sep 17 00:00:00 2001 From: June Kim Date: Mon, 11 May 2026 22:19:04 -0700 Subject: [PATCH 1/2] test: reproduce #73 (fails on main) TypeScript rejects core.on('metro', callback) because 'metro' is missing from the EventTypes type definition in Events.ts, even though the wasm runtime emits metro events at runtime. --- .../core/__tests__/metro-event-type.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 js/packages/core/__tests__/metro-event-type.test.ts diff --git a/js/packages/core/__tests__/metro-event-type.test.ts b/js/packages/core/__tests__/metro-event-type.test.ts new file mode 100644 index 00000000..2e5d2a13 --- /dev/null +++ b/js/packages/core/__tests__/metro-event-type.test.ts @@ -0,0 +1,18 @@ +/** + * Type-level test for metro event type. + * + * This test verifies that 'metro' is recognized as a valid event name + * in EventTypes, so that core.on('metro', callback) compiles without + * TypeScript errors. + * + * See: https://github.com/elemaudio/elementary/issues/73 + */ +import EventEmitter from '../src/Events'; + +// This should compile without errors: metro is a valid event type +const emitter = new EventEmitter(); + +emitter.on('metro', (data) => { + // The metro event payload should have an optional source field + const source: string | undefined = data.source; +}); From d68597cf22edf2117ab426a49935d31f91719e02 Mon Sep 17 00:00:00 2001 From: June Kim Date: Mon, 11 May 2026 22:28:44 -0700 Subject: [PATCH 2/2] fix: add metro to EventTypes interface Adds the metro event type signature to match the C++ MetronomeNode's processEvents output. The event payload contains an optional source field populated from the node's name property. Fixes #73 --- js/packages/core/src/Events.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/js/packages/core/src/Events.ts b/js/packages/core/src/Events.ts index 8a06949b..31046aca 100644 --- a/js/packages/core/src/Events.ts +++ b/js/packages/core/src/Events.ts @@ -7,6 +7,7 @@ type EventTypes = { fft: (data: { source?: string, data: { real: Float32Array, imag: Float32Array } }) => void; load: () => void; meter: (data: { source?: string, min: number; max: number, }) => void; + metro: (data: { source?: string }) => void; scope: (data: { source?: string, data: Float32Array[] }) => void; snapshot: (data: { source?: string, data: number }) => void; };