// Verify static/js/transport.js emits `song:seek` for every audio repositioning, // with `{ from, to, reason }` payload. Plugins (notedetect detection- // suppression during seek transients) consume this contract. // // Same isolation strategy as loop_restart.test.js — extract the relevant // functions from app.js by brace-matching and run them in a vm sandbox. const { test } = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const vm = require('node:vm'); const APP_JS = path.join(__dirname, '..', '..', 'static', 'js', 'transport.js'); function extractFunction(src, signature) { const start = src.indexOf(signature); if (start === -1) throw new Error(`extractFunction: '${signature}' not found in app.js`); const openBrace = src.indexOf('{', start); let depth = 1; let i = openBrace + 1; while (i < src.length && depth > 0) { const ch = src[i]; if (ch === '{') depth++; else if (ch === '}') depth--; i++; } if (depth !== 0) throw new Error(`extractFunction: unbalanced braces after '${signature}'`); return src.slice(start, i); } function buildSandbox({ juceMode = false, currentTime = 10, duration = Infinity } = {}) { const emitCalls = []; const audio = { duration, get currentTime() { return audio._t; }, // Clamp to [0, duration] like a real