Port phase 1 to TypeScript
Move the standalone GameSense scale lighting to TypeScript ahead of the
Max for Live work, so step 3 gets type declarations at the seam.
Build emits CommonJS at ES2020 into dist/, because Node for Max loads CJS
on a Node version we do not control. bin/apex7-scale.js becomes a plain-JS
launcher so `node bin/apex7-scale.js` keeps working; the CLI itself moves
to src/cli.ts.
Two modules make previously implicit structure explicit:
- src/protocol.ts, the GameSense wire types, so the transport and the
payload construction agree on shapes neither of them owns
- src/errors.ts, since `catch (err)` binds `unknown` under strict
Typing surfaced a few real fixes:
- ScaleLighting.started was a public field the CLI set by hand to make
--off work without start(); that is now release(), with started
private behind isStarted
- readAddress() trusted JSON.parse output; the address is now checked
for being a non-empty string
- res.statusCode is number|undefined, so the old `>= 200` comparison
coerced silently; a missing status now rejects
- parseIntervals claimed to dedupe and sort, and never did (comment
corrected; pitchClassesFor is what dedupes)
Behavior is otherwise unchanged: all 18 tests pass and --once, --off,
--demo, --key-test, the resident stdin loop and the error paths were
verified against tools/fake-gamesense.ts.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
24
package.json
24
package.json
@@ -2,18 +2,30 @@
|
||||
"name": "steelseries-live-scale",
|
||||
"version": "0.1.0",
|
||||
"description": "Highlight the notes of the current Ableton Live scale on a SteelSeries Apex 7 via GameSense",
|
||||
"main": "src/index.js",
|
||||
"main": "dist/src/index.js",
|
||||
"types": "dist/src/index.d.ts",
|
||||
"bin": {
|
||||
"apex7-scale": "bin/apex7-scale.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist/src"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "node bin/apex7-scale.js",
|
||||
"stub": "node tools/fake-gamesense.js",
|
||||
"test": "node test/logic.test.js"
|
||||
"build": "tsc",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"prepare": "npm run build",
|
||||
"start": "npm run build && node bin/apex7-scale.js",
|
||||
"stub": "npm run build && node dist/tools/fake-gamesense.js",
|
||||
"test": "npm run build && node dist/test/logic.test.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
"node": ">=16"
|
||||
},
|
||||
"license": "MIT",
|
||||
"private": true
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@types/node": "^26.2.0",
|
||||
"typescript": "^7.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user