From 5d910ca0844e1096bd28fb4ca4d98c3d79001583 Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Thu, 25 Apr 2024 10:13:07 -0400 Subject: [PATCH] working on getting actions to run --- .github/workflows/test.yml | 28 ++++++++ Tone/component/channel/Channel.ts | 2 +- Tone/core/context/Context.ts | 2 +- Tone/core/context/ToneAudioNode.ts | 2 +- Tone/core/context/ToneWithContext.ts | 2 +- Tone/instrument/DuoSynth.ts | 2 +- Tone/instrument/PolySynth.ts | 1 - Tone/source/buffer/Player.test.ts | 3 + Tone/source/buffer/Players.ts | 2 +- Tone/source/oscillator/OmniOscillator.ts | 2 +- examples/meter.html | 2 +- examples/mixer.html | 2 +- examples/pingPongDelay.html | 2 +- package-lock.json | 92 ++++++++++++------------ package.json | 4 +- scripts/typedoc.json | 6 +- test/scripts/test_examples.cjs | 52 +++++++------- 17 files changed, 118 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..96d6b7740 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Run tests + +on: + pull_request: + types: [opened, reopened, synchronize] + branches: + - dev + push: + branches: + - dev +jobs: + all-tests: + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + - name: Setup Nodejs + uses: actions/setup-node@v4 + with: + node-version: 18.12.0 + cache: 'npm' + - name: Install dependencies + run: npm install + - name: Build + run: npm run build \ No newline at end of file diff --git a/Tone/component/channel/Channel.ts b/Tone/component/channel/Channel.ts index faa32cf94..b7741bf5d 100644 --- a/Tone/component/channel/Channel.ts +++ b/Tone/component/channel/Channel.ts @@ -91,7 +91,7 @@ export class Channel extends ToneAudioNode { } /** - * Solo/unsolo the channel. Soloing is only relative to other [[Channels]] and [[Solo]] instances + * Solo/unsolo the channel. Soloing is only relative to other [[Channel]]s and [[Solo]] instances */ get solo(): boolean { return this._solo.solo; diff --git a/Tone/core/context/Context.ts b/Tone/core/context/Context.ts index 08311730e..dc3ecd017 100644 --- a/Tone/core/context/Context.ts +++ b/Tone/core/context/Context.ts @@ -475,7 +475,7 @@ export class Context extends BaseContext { /** * Starts the audio context from a suspended state. This is required - * to initially start the AudioContext. See [[Tone.start]] + * to initially start the AudioContext. See [[start]] */ resume(): Promise { if (isAudioContext(this._context)) { diff --git a/Tone/core/context/ToneAudioNode.ts b/Tone/core/context/ToneAudioNode.ts index c34c19438..6276dedd1 100644 --- a/Tone/core/context/ToneAudioNode.ts +++ b/Tone/core/context/ToneAudioNode.ts @@ -385,7 +385,7 @@ export function disconnect( * const player1 = new Tone.Player("https://tonejs.github.io/audio/drum-samples/conga-rhythm.mp3"); * const filter = new Tone.Filter("G5").toDestination(); * // connect nodes to a common destination - * fanIn(player, player1, filter); + * Tone.fanIn(player, player1, filter); */ export function fanIn(...nodes: OutputNode[]): void { const dstNode = nodes.pop(); diff --git a/Tone/core/context/ToneWithContext.ts b/Tone/core/context/ToneWithContext.ts index 4bbcfad2d..c58e50f88 100644 --- a/Tone/core/context/ToneWithContext.ts +++ b/Tone/core/context/ToneWithContext.ts @@ -97,7 +97,7 @@ export abstract class ToneWithContext ex /** * Convert the incoming time to seconds. - * This is calculated against the current [[Tone.Transport]] bpm + * This is calculated against the current [[Transport]] bpm * @example * const gain = new Tone.Gain(); * setInterval(() => console.log(gain.toSeconds("4n")), 100); diff --git a/Tone/instrument/DuoSynth.ts b/Tone/instrument/DuoSynth.ts index 47d4f0d74..09284b515 100644 --- a/Tone/instrument/DuoSynth.ts +++ b/Tone/instrument/DuoSynth.ts @@ -18,7 +18,7 @@ export interface DuoSynthOptions extends MonophonicOptions { } /** - * DuoSynth is a monophonic synth composed of two [[MonoSynths]] run in parallel with control over the + * DuoSynth is a monophonic synth composed of two [[MonoSynth]]s run in parallel with control over the * frequency ratio between the two voices and vibrato effect. * @example * const duoSynth = new Tone.DuoSynth().toDestination(); diff --git a/Tone/instrument/PolySynth.ts b/Tone/instrument/PolySynth.ts index 026bfa854..07cdfa58b 100644 --- a/Tone/instrument/PolySynth.ts +++ b/Tone/instrument/PolySynth.ts @@ -285,7 +285,6 @@ export class PolySynth = Synth> extends Instrument * @param notes The notes to play. Accepts a single Frequency or an array of frequencies. * @param time When the release will be triggered. * @example - * @example * const poly = new Tone.PolySynth(Tone.AMSynth).toDestination(); * poly.triggerAttack(["Ab3", "C4", "F5"]); * // trigger the release of the given notes. diff --git a/Tone/source/buffer/Player.test.ts b/Tone/source/buffer/Player.test.ts index d23a8c8a1..ee167cde9 100644 --- a/Tone/source/buffer/Player.test.ts +++ b/Tone/source/buffer/Player.test.ts @@ -709,11 +709,14 @@ describe("Player", () => { setTimeout(() => { player.restart(undefined, undefined, 1); const checkStopTimes = new Set(); + // @ts-ignore player._activeSources.forEach(source => { + // @ts-ignore checkStopTimes.add(source._stopTime); }); getContext().lookAhead = originalLookAhead; // ensure each source has a different stopTime + // @ts-ignore expect(checkStopTimes.size).to.equal(player._activeSources.size); done(); }, 250); diff --git a/Tone/source/buffer/Players.ts b/Tone/source/buffer/Players.ts index 4a5ac9caa..c75b45a9e 100644 --- a/Tone/source/buffer/Players.ts +++ b/Tone/source/buffer/Players.ts @@ -206,7 +206,7 @@ export class Players extends ToneAudioNode { * const players = new Tone.Players(); * players.add("gong", "https://tonejs.github.io/audio/berklee/gong_1.mp3", () => { * console.log("gong loaded"); - * players.get("gong").start(); + * players.player("gong").start(); * }); */ add(name: string, url: string | ToneAudioBuffer | AudioBuffer, callback?: () => void): this { diff --git a/Tone/source/oscillator/OmniOscillator.ts b/Tone/source/oscillator/OmniOscillator.ts index a21f6f9f0..562d2ee2a 100644 --- a/Tone/source/oscillator/OmniOscillator.ts +++ b/Tone/source/oscillator/OmniOscillator.ts @@ -315,7 +315,7 @@ export class OmniOscillator /** * The width of the oscillator when sourceType === "pulse". - * See [[PWMOscillator.width]] + * See [[PWMOscillator]] */ get width(): IsPulseOscillator> { if (this._getOscType(this._oscillator, "pulse")) { diff --git a/examples/meter.html b/examples/meter.html index f890359d4..b3a11c53a 100644 --- a/examples/meter.html +++ b/examples/meter.html @@ -33,7 +33,7 @@ }).toDestination(); const toneMeter = new Tone.Meter({ - channels: 2, + channelCount: 2, }); player.connect(toneMeter); diff --git a/examples/mixer.html b/examples/mixer.html index 6de258bfc..8c2a7325c 100644 --- a/examples/mixer.html +++ b/examples/mixer.html @@ -55,7 +55,7 @@ } // create a meter on the destination node - const toneMeter = new Tone.Meter({ channels: 2 }); + const toneMeter = new Tone.Meter({ channelCount: 2 }); Tone.Destination.chain(toneMeter); meter({ tone: toneMeter, diff --git a/examples/pingPongDelay.html b/examples/pingPongDelay.html index 9d8aba9be..a68133cd0 100644 --- a/examples/pingPongDelay.html +++ b/examples/pingPongDelay.html @@ -39,7 +39,7 @@ // play a snare sound through it const player = new Tone.Player("https://tonejs.github.io/audio/drum-samples/CR78/snare.mp3").connect(feedbackDelay); - const toneMeter = new Tone.Meter({ channels: 2 }); + const toneMeter = new Tone.Meter({ channelCount: 2 }); feedbackDelay.connect(toneMeter); meter({ diff --git a/package-lock.json b/package-lock.json index 538280d8e..665bb53ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "tone", - "version": "14.8.0", + "version": "14.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tone", - "version": "14.8.0", + "version": "14.9.0", "license": "MIT", "dependencies": { - "standardized-audio-context": "^25.3.37", + "standardized-audio-context": "^25.3.70", "tslib": "^2.3.1" }, "devDependencies": { @@ -417,20 +417,20 @@ } }, "node_modules/@babel/runtime": { - "version": "7.20.13", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.13.tgz", - "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.4.tgz", + "integrity": "sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==", "dependencies": { - "regenerator-runtime": "^0.13.11" + "regenerator-runtime": "^0.14.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/runtime/node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" }, "node_modules/@babel/template": { "version": "7.18.10", @@ -1544,15 +1544,15 @@ "dev": true }, "node_modules/automation-events": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/automation-events/-/automation-events-5.0.0.tgz", - "integrity": "sha512-SkYa2YBwgRUJNsR5v6GxeJwP5IGnYtOMW37coplTOWMUpDYYrk5j8gGOhYa765rchRln/HssFzMAck/2P6zTFw==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/automation-events/-/automation-events-7.0.4.tgz", + "integrity": "sha512-uM5VFyhksP/GzzOuGi/ygeI16ked+IA5enGLH9b+BvxUSDnfAWC54RZnnem/iprEKtuWV29FX5gvYcesPAgPAw==", "dependencies": { - "@babel/runtime": "^7.20.7", - "tslib": "^2.4.1" + "@babel/runtime": "^7.24.4", + "tslib": "^2.6.2" }, "engines": { - "node": ">=14.15.4" + "node": ">=18.2.0" } }, "node_modules/available-typed-arrays": { @@ -8720,13 +8720,13 @@ "dev": true }, "node_modules/standardized-audio-context": { - "version": "25.3.37", - "resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.37.tgz", - "integrity": "sha512-lr0+RH/IJXYMts95oYKIJ+orTmstOZN3GXWVGmlkbMj8OLahREkRh7DhNGLYgBGDkBkhhc4ev5pYGSFN3gltHw==", + "version": "25.3.70", + "resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.70.tgz", + "integrity": "sha512-v07apb+yDztoTrYu6aU4DZGbbO/gkcyC/P+u+SCalDFq+eUp5kbQYnxS8Z/6tA2Vnm/YslhVaR5VzsCYafg3BQ==", "dependencies": { - "@babel/runtime": "^7.20.7", - "automation-events": "^5.0.0", - "tslib": "^2.4.1" + "@babel/runtime": "^7.24.4", + "automation-events": "^7.0.4", + "tslib": "^2.6.2" } }, "node_modules/statuses": { @@ -9367,9 +9367,9 @@ } }, "node_modules/tslib": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", - "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/tsutils": { "version": "3.21.0", @@ -10586,17 +10586,17 @@ "dev": true }, "@babel/runtime": { - "version": "7.20.13", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.13.tgz", - "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==", + "version": "7.24.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.4.tgz", + "integrity": "sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==", "requires": { - "regenerator-runtime": "^0.13.11" + "regenerator-runtime": "^0.14.0" }, "dependencies": { "regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" } } }, @@ -11488,12 +11488,12 @@ "dev": true }, "automation-events": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/automation-events/-/automation-events-5.0.0.tgz", - "integrity": "sha512-SkYa2YBwgRUJNsR5v6GxeJwP5IGnYtOMW37coplTOWMUpDYYrk5j8gGOhYa765rchRln/HssFzMAck/2P6zTFw==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/automation-events/-/automation-events-7.0.4.tgz", + "integrity": "sha512-uM5VFyhksP/GzzOuGi/ygeI16ked+IA5enGLH9b+BvxUSDnfAWC54RZnnem/iprEKtuWV29FX5gvYcesPAgPAw==", "requires": { - "@babel/runtime": "^7.20.7", - "tslib": "^2.4.1" + "@babel/runtime": "^7.24.4", + "tslib": "^2.6.2" } }, "available-typed-arrays": { @@ -17192,13 +17192,13 @@ "dev": true }, "standardized-audio-context": { - "version": "25.3.37", - "resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.37.tgz", - "integrity": "sha512-lr0+RH/IJXYMts95oYKIJ+orTmstOZN3GXWVGmlkbMj8OLahREkRh7DhNGLYgBGDkBkhhc4ev5pYGSFN3gltHw==", + "version": "25.3.70", + "resolved": "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.70.tgz", + "integrity": "sha512-v07apb+yDztoTrYu6aU4DZGbbO/gkcyC/P+u+SCalDFq+eUp5kbQYnxS8Z/6tA2Vnm/YslhVaR5VzsCYafg3BQ==", "requires": { - "@babel/runtime": "^7.20.7", - "automation-events": "^5.0.0", - "tslib": "^2.4.1" + "@babel/runtime": "^7.24.4", + "automation-events": "^7.0.4", + "tslib": "^2.6.2" } }, "statuses": { @@ -17681,9 +17681,9 @@ } }, "tslib": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", - "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==" + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "tsutils": { "version": "3.21.0", diff --git a/package.json b/package.json index 24682eca4..a077f577a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tone", - "version": "14.8.0", + "version": "14.9.0", "description": "A Web Audio framework for making interactive music in the browser.", "browser": "build/Tone.js", "main": "build/esm/index.js", @@ -103,7 +103,7 @@ "yargs": "^17.3.0" }, "dependencies": { - "standardized-audio-context": "^25.3.37", + "standardized-audio-context": "^25.3.70", "tslib": "^2.3.1" }, "prettier": { diff --git a/scripts/typedoc.json b/scripts/typedoc.json index b7725d900..7f842cb37 100644 --- a/scripts/typedoc.json +++ b/scripts/typedoc.json @@ -1,12 +1,12 @@ { "name" : "Tone.js", - "mode": "file", + "entryPoints": ["../Tone"], + "out":"../docs", "defaultCategory" : "Global", "categorizeByGroup" : true, "categoryOrder" : ["Core", "Source", "Instrument", "Effect", "Component", "Signal"], "exclude" : ["./Tone/**/*.test.ts", "./test/**/*.ts"], "excludeProtected" : true, "excludePrivate" : true, - "listInvalidSymbolLinks" : true, - "excludeNotExported" : false + "hideGenerator": true, } \ No newline at end of file diff --git a/test/scripts/test_examples.cjs b/test/scripts/test_examples.cjs index 52eceef38..1aa1817a5 100644 --- a/test/scripts/test_examples.cjs +++ b/test/scripts/test_examples.cjs @@ -6,31 +6,39 @@ const { file } = require("tmp-promise"); const { writeFile } = require("fs-extra"); const toneJson = require("../../docs/tone.json"); -const testSplit = parseInt(process.env.TEST_EXAMPLES || "0"); - /** * Get all of the examples */ function findExamples(obj) { let examples = []; - for (const prop in obj) { - if (Array.isArray(obj[prop])) { - obj[prop].forEach((child) => { - examples = [...examples, ...findExamples(child)]; + + function traverse(node) { + if (node.comment && node.comment.blockTags) { + node.comment.blockTags.forEach((tag) => { + if (tag.tag === "@example") { + tag.content.forEach((example) => { + examples.push( + example.text.trim().replace(/^```ts\n|```$/g, "") + ); + }); + } }); - } else if (prop === "comment" && obj[prop].tags) { - examples = [ - ...examples, - ...obj[prop].tags - .filter((tag) => tag.tag === "example") - .map((tag) => tag.text), - ]; - } else if (typeof obj[prop] === "object") { - examples = [...examples, ...findExamples(obj[prop])]; - } else { - // console.log(prop); } + + ["children", "getSignature", "setSignature", "signatures"].forEach( + (prop) => { + if (prop in node) { + if (Array.isArray(node[prop])) { + node[prop].forEach((child) => traverse(child)); + } else { + traverse(node[prop]); + } + } + } + ); } + + traverse(obj); // filter any repeats return [...new Set(examples)]; } @@ -75,15 +83,7 @@ async function testExampleString(str) { } async function main() { - let examples = findExamples(toneJson); - if (testSplit > 0) { - // split it in half and choose either the first or second half - const halfLength = Math.ceil(examples.length / 2); - const splitStart = (testSplit - 1) * halfLength; - const splitEnd = testSplit * halfLength; - examples = examples.slice(splitStart, splitEnd); - console.log(`testing examples ${splitStart} - ${splitEnd}`); - } + const examples = findExamples(toneJson); let passed = 0; for (let i = 0; i < examples.length; i++) { const example = examples[i];