Skip to content

Commit fdaf8c1

Browse files
authored
docs: Export Transport, Destination, Listener and Draw (#1371)
* docs: Exporting hidden classes certain classes were hidden from docs, exporting them now to show up in * chore(packages): Updating typedoc * refactor: rename ListenerClass to ListenerInstance * refactor: rename TransportClass to TransportInstance * refactor: rename DrawClass to DrawInstance * refactor: rename DestinationClass to DestinationInstance
1 parent e8ca4c2 commit fdaf8c1

24 files changed

+327
-221
lines changed

Tone/core/clock/Transport.test.ts

Lines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.

Tone/core/clock/Transport.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ type TransportCallback = (time: Seconds) => void;
8787
* Tone.getTransport().start();
8888
* @category Core
8989
*/
90-
export class TransportClass
90+
export class TransportInstance
9191
extends ToneWithContext<TransportOptions>
9292
implements Emitter<TransportEventNames>
9393
{
@@ -189,7 +189,7 @@ export class TransportClass
189189
constructor(options?: Partial<TransportOptions>);
190190
constructor() {
191191
const options = optionsFromArguments(
192-
TransportClass.getDefaults(),
192+
TransportInstance.getDefaults(),
193193
arguments
194194
);
195195
super(options);
@@ -808,14 +808,14 @@ export class TransportClass
808808
emit!: (event: any, ...args: any[]) => this;
809809
}
810810

811-
Emitter.mixin(TransportClass);
811+
Emitter.mixin(TransportInstance);
812812

813813
//-------------------------------------
814814
// INITIALIZATION
815815
//-------------------------------------
816816

817817
onContextInit((context) => {
818-
context.transport = new TransportClass({ context });
818+
context.transport = new TransportInstance({ context });
819819
});
820820

821821
onContextClose((context) => {

Tone/core/clock/TransportEvent.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect } from "chai";
22

33
import { Offline } from "../../../test/helper/Offline.js";
4-
import { TransportClass } from "./Transport.js";
4+
import { TransportInstance } from "./Transport.js";
55
import { TransportEvent } from "./TransportEvent.js";
66

77
describe("TransportEvent", () => {
88
it("can be created and disposed", () => {
99
return Offline((context) => {
10-
const transport = new TransportClass({ context });
10+
const transport = new TransportInstance({ context });
1111
const event = new TransportEvent(transport, {
1212
time: 0,
1313
});
@@ -17,7 +17,7 @@ describe("TransportEvent", () => {
1717

1818
it("has a unique id", () => {
1919
return Offline((context) => {
20-
const transport = new TransportClass({ context });
20+
const transport = new TransportInstance({ context });
2121
const event = new TransportEvent(transport, {
2222
time: 0,
2323
});
@@ -29,7 +29,7 @@ describe("TransportEvent", () => {
2929
it("can invoke the callback", async () => {
3030
let wasInvoked = false;
3131
await Offline((context) => {
32-
const transport = new TransportClass({ context });
32+
const transport = new TransportInstance({ context });
3333
const event = new TransportEvent(transport, {
3434
callback: (time) => {
3535
expect(time).to.equal(100);

Tone/core/clock/TransportEvent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Seconds, Ticks } from "../type/Units.js";
22
import { noOp } from "../util/Interface.js";
3-
import type { TransportClass as Transport } from "./Transport.js";
3+
import type { TransportInstance as Transport } from "./Transport.js";
44

55
export interface TransportEventOptions {
66
callback: (time: number) => void;
@@ -9,7 +9,7 @@ export interface TransportEventOptions {
99
}
1010

1111
/**
12-
* TransportEvent is an internal class used by {@link TransportClass}
12+
* TransportEvent is an internal class used by {@link TransportInstance}
1313
* to schedule events. Do no invoke this class directly, it is
1414
* handled from within Tone.Transport.
1515
*/

Tone/core/clock/TransportRepeatEvent.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { expect } from "chai";
22

33
import { Offline } from "../../../test/helper/Offline.js";
4-
import { TransportClass } from "./Transport.js";
4+
import { TransportInstance } from "./Transport.js";
55
import { TransportRepeatEvent } from "./TransportRepeatEvent.js";
66

77
describe("TransportRepeatEvent", () => {
88
it("can be created and disposed", async () => {
99
await Offline((context) => {
10-
const transport = new TransportClass({ context });
10+
const transport = new TransportInstance({ context });
1111
const event = new TransportRepeatEvent(transport, {
1212
duration: 100,
1313
interval: 4,
@@ -19,7 +19,7 @@ describe("TransportRepeatEvent", () => {
1919

2020
it("generates a unique event ID", async () => {
2121
await Offline((context) => {
22-
const transport = new TransportClass({ context });
22+
const transport = new TransportInstance({ context });
2323
const event = new TransportRepeatEvent(transport, {
2424
time: 0,
2525
});
@@ -30,7 +30,7 @@ describe("TransportRepeatEvent", () => {
3030

3131
it("is removed from the Transport when disposed", async () => {
3232
await Offline((context) => {
33-
const transport = new TransportClass({ context });
33+
const transport = new TransportInstance({ context });
3434
const event = new TransportRepeatEvent(transport, {
3535
time: 0,
3636
});

Tone/core/clock/TransportRepeatEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BaseContext } from "../context/BaseContext.js";
22
import { TicksClass } from "../type/Ticks.js";
33
import { Seconds, Ticks, Time } from "../type/Units.js";
44
import { GT, LT } from "../util/Math.js";
5-
import type { TransportClass as Transport } from "./Transport.js";
5+
import type { TransportInstance as Transport } from "./Transport.js";
66
import { TransportEvent, TransportEventOptions } from "./TransportEvent.js";
77

88
interface TransportRepeatEventOptions extends TransportEventOptions {

Tone/core/context/BaseContext.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { TransportClass as Transport } from "../clock/Transport.js";
1+
import type { TransportInstance as Transport } from "../clock/Transport.js";
22
import { Seconds } from "../type/Units.js";
3-
import type { DrawClass as Draw } from "../util/Draw.js";
3+
import type { DrawInstance as Draw } from "../util/Draw.js";
44
import { Emitter } from "../util/Emitter.js";
55
import { AnyAudioContext } from "./AudioContext.js";
6-
import type { DestinationClass as Destination } from "./Destination.js";
7-
import type { ListenerClass as Listener } from "./Listener.js";
6+
import type { DestinationInstance as Destination } from "./Destination.js";
7+
import type { ListenerInstance as Listener } from "./Listener.js";
88

99
// these are either not used in Tone.js or deprecated and not implemented.
1010
export type ExcludedFromBaseAudioContext =

Tone/core/context/Context.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { expect } from "chai";
22

33
import { ConstantOutput } from "../../../test/helper/ConstantOutput.js";
44
import { Offline } from "../../../test/helper/Offline.js";
5-
import { TransportClass } from "../clock/Transport.js";
5+
import { TransportInstance } from "../clock/Transport.js";
66
import { getContext } from "../Global.js";
7-
import { DrawClass } from "../util/Draw.js";
7+
import { DrawInstance } from "../util/Draw.js";
88
import { createAudioContext } from "./AudioContext.js";
99
import { Context } from "./Context.js";
10-
import { DestinationClass } from "./Destination.js";
11-
import { ListenerClass } from "./Listener.js";
10+
import { DestinationInstance } from "./Destination.js";
11+
import { ListenerInstance } from "./Listener.js";
1212
import { connect } from "./ToneAudioNode.js";
1313

1414
describe("Context", () => {
@@ -19,9 +19,9 @@ describe("Context", () => {
1919
const ctxDraw = context.draw;
2020
const ctxTransport = context.transport;
2121
const ctxListener = context.listener;
22-
expect(context.destination).is.instanceOf(DestinationClass);
23-
expect(context.draw).is.instanceOf(DrawClass);
24-
expect(context.listener).is.instanceOf(ListenerClass);
22+
expect(context.destination).is.instanceOf(DestinationInstance);
23+
expect(context.draw).is.instanceOf(DrawInstance);
24+
expect(context.listener).is.instanceOf(ListenerInstance);
2525
await context.close();
2626
expect(ctxDest.disposed).to.be.true;
2727
expect(ctxDraw.disposed).to.be.true;
@@ -214,7 +214,7 @@ describe("Context", () => {
214214

215215
it("is invoked in the offline context", () => {
216216
return Offline((context) => {
217-
const transport = new TransportClass({ context });
217+
const transport = new TransportInstance({ context });
218218
transport.context.setTimeout(() => {
219219
expect(transport.now()).to.be.closeTo(0.01, 0.005);
220220
}, 0.01);

Tone/core/context/Context.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Ticker, TickerClockSource } from "../clock/Ticker.js";
2-
import type { TransportClass as Transport } from "../clock/Transport.js";
2+
import type { TransportInstance as Transport } from "../clock/Transport.js";
33
import { Seconds } from "../type/Units.js";
44
import { isAudioContext } from "../util/AdvancedTypeCheck.js";
55
import { assert } from "../util/Debug.js";
66
import { optionsFromArguments } from "../util/Defaults.js";
7-
import type { DrawClass as Draw } from "../util/Draw.js";
7+
import type { DrawInstance as Draw } from "../util/Draw.js";
88
import { Timeline } from "../util/Timeline.js";
99
import { isDefined } from "../util/TypeCheck.js";
1010
import {
@@ -14,8 +14,8 @@ import {
1414
} from "./AudioContext.js";
1515
import { BaseContext, ContextLatencyHint } from "./BaseContext.js";
1616
import { closeContext, initializeContext } from "./ContextInitialization.js";
17-
import type { DestinationClass as Destination } from "./Destination.js";
18-
import type { ListenerClass as Listener } from "./Listener.js";
17+
import type { DestinationInstance as Destination } from "./Destination.js";
18+
import type { ListenerInstance as Listener } from "./Listener.js";
1919

2020
export interface ContextOptions {
2121
clockSource: TickerClockSource;
@@ -117,12 +117,16 @@ export class Context extends BaseContext {
117117
// custom context provided, latencyHint unknown (unless explicitly provided in options)
118118
this._latencyHint = arguments[0]?.latencyHint || "";
119119
} else {
120-
this._context = createAudioContext(options.sampleRate ? {
121-
latencyHint: options.latencyHint,
122-
sampleRate: options.sampleRate,
123-
} : {
124-
latencyHint: options.latencyHint,
125-
});
120+
this._context = createAudioContext(
121+
options.sampleRate
122+
? {
123+
latencyHint: options.latencyHint,
124+
sampleRate: options.sampleRate,
125+
}
126+
: {
127+
latencyHint: options.latencyHint,
128+
}
129+
);
126130
this._latencyHint = options.latencyHint;
127131
}
128132

Tone/core/context/Destination.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { Offline } from "../../../test/helper/Offline.js";
55
import { PassAudio } from "../../../test/helper/PassAudio.js";
66
import { Oscillator } from "../../source/oscillator/Oscillator.js";
77
import { getContext } from "../Global.js";
8-
import { DestinationClass } from "./Destination.js";
8+
import { DestinationInstance } from "./Destination.js";
99

1010
describe("Destination", () => {
1111
it("creates itself on the context", () => {
12-
expect(getContext().destination).instanceOf(DestinationClass);
12+
expect(getContext().destination).instanceOf(DestinationInstance);
1313
});
1414

1515
it("can be muted and unmuted", () => {

0 commit comments

Comments
 (0)