@ac-kit/browser 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +258 -4
- package/dist/_race-abort.d.ts +2 -0
- package/dist/_race-abort.d.ts.map +1 -0
- package/dist/_race-abort.js +20 -0
- package/dist/_race-abort.js.map +1 -0
- package/dist/canvas/image-data-pixels.d.ts +61 -0
- package/dist/canvas/image-data-pixels.d.ts.map +1 -0
- package/dist/canvas/image-data-pixels.js +74 -0
- package/dist/canvas/image-data-pixels.js.map +1 -0
- package/dist/canvas/read-image-data.d.ts +120 -0
- package/dist/canvas/read-image-data.d.ts.map +1 -0
- package/dist/canvas/read-image-data.js +147 -0
- package/dist/canvas/read-image-data.js.map +1 -0
- package/dist/dom/index.d.ts +2 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +2 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/web-animations/wait-for-transitions.d.ts +59 -0
- package/dist/dom/web-animations/wait-for-transitions.d.ts.map +1 -0
- package/dist/dom/web-animations/wait-for-transitions.js +44 -0
- package/dist/dom/web-animations/wait-for-transitions.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/media-capture/microphone-access.d.ts +116 -0
- package/dist/media-capture/microphone-access.d.ts.map +1 -0
- package/dist/media-capture/microphone-access.js +224 -0
- package/dist/media-capture/microphone-access.js.map +1 -0
- package/dist/testing/fake-audio-context.d.ts +174 -0
- package/dist/testing/fake-audio-context.d.ts.map +1 -0
- package/dist/testing/fake-audio-context.js +314 -0
- package/dist/testing/fake-audio-context.js.map +1 -0
- package/dist/testing/fake-media-devices.d.ts +90 -0
- package/dist/testing/fake-media-devices.d.ts.map +1 -0
- package/dist/testing/fake-media-devices.js +147 -0
- package/dist/testing/fake-media-devices.js.map +1 -0
- package/dist/testing/fake-web-midi.d.ts +25 -0
- package/dist/testing/fake-web-midi.d.ts.map +1 -0
- package/dist/testing/fake-web-midi.js +52 -0
- package/dist/testing/fake-web-midi.js.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/web-audio/audio-clock-mapping.d.ts +124 -0
- package/dist/web-audio/audio-clock-mapping.d.ts.map +1 -0
- package/dist/web-audio/audio-clock-mapping.js +245 -0
- package/dist/web-audio/audio-clock-mapping.js.map +1 -0
- package/package.json +20 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"microphone-access.js","sourceRoot":"","sources":["../../src/media-capture/microphone-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA2D/C,qEAAqE;AACrE,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACpD,YAAY,OAAsB;QACjC,KAAK,CAAC,0CAA0C,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC1C,CAAC;CACD;AAED,mEAAmE;AACnE,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC/C,YAAY,OAAsB;QACjC,KAAK,CAAC,sCAAsC,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACrC,CAAC;CACD;AAED,sCAAsC;AACtC,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACjD,YAAY,OAAsB;QACjC,KAAK,CAAC,yBAAyB,EAAE,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD;AAED,gFAAgF;AAChF,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC9C,YAAY,OAAsB;QACjC,KAAK,CAAC,kDAAkD,EAAE,OAAO,CAAC,CAAC;QACnE,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AAK,SAAS,IAAI,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,UAAU,CAC1E,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAChC,QAAQ,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,KAAK,iBAAiB,CAAC;QACvB,KAAK,eAAe,CAAC;QACrB,KAAK,uBAAuB;YAC3B,OAAO,IAAI,qBAAqB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACpD,KAAK,eAAe,CAAC;QACrB,KAAK,sBAAsB;YAC1B,OAAO,IAAI,uBAAuB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACtD,KAAK,kBAAkB,CAAC;QACxB,KAAK,YAAY,CAAC;QAClB,KAAK,iBAAiB;YACrB,OAAO,IAAI,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD;YACC,OAAO,KAAK,CAAC;IACf,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/** An audio node that records what it was connected to, and its disconnections. */
|
|
2
|
+
export declare class FakeAudioNode {
|
|
3
|
+
/** The nodes it was connected to, in order. */
|
|
4
|
+
readonly connections: unknown[];
|
|
5
|
+
/** How many times the page called {@link disconnect}. */
|
|
6
|
+
disconnectCount: number;
|
|
7
|
+
connect(destination: unknown): void;
|
|
8
|
+
disconnect(): void;
|
|
9
|
+
}
|
|
10
|
+
/** The node a microphone stream enters the graph by. */
|
|
11
|
+
export declare class FakeMediaStreamSource extends FakeAudioNode {
|
|
12
|
+
readonly stream: MediaStream;
|
|
13
|
+
constructor(stream: MediaStream);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A message port the page posts to and listens on. What arrives before there is
|
|
17
|
+
* a listener waits for it, and is handed over after the current task, as a real
|
|
18
|
+
* port does.
|
|
19
|
+
*/
|
|
20
|
+
export declare class FakeMessagePort {
|
|
21
|
+
/** What the page posted, in order. */
|
|
22
|
+
readonly posted: unknown[];
|
|
23
|
+
/**
|
|
24
|
+
* The other end, given each message the page posts once it is recorded: set
|
|
25
|
+
* it to feed a real processor's logic, rather than replacing
|
|
26
|
+
* {@link postMessage}, whose replacement would leave {@link posted} empty.
|
|
27
|
+
*/
|
|
28
|
+
onPostMessage: ((message: unknown) => void) | undefined;
|
|
29
|
+
private handler;
|
|
30
|
+
private readonly pending;
|
|
31
|
+
postMessage(message: unknown): void;
|
|
32
|
+
get onmessage(): ((event: MessageEvent) => void) | null;
|
|
33
|
+
set onmessage(handler: ((event: MessageEvent) => void) | null);
|
|
34
|
+
/** `data` arrives from the other end. */
|
|
35
|
+
receive(data: unknown): void;
|
|
36
|
+
private flush;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* An `AudioWorkletNode` whose processor is the test: what the page posts is in
|
|
40
|
+
* {@link posted}, and {@link emit} posts to the page. The processor options it
|
|
41
|
+
* was made with are in {@link configuration}.
|
|
42
|
+
*/
|
|
43
|
+
export declare class FakeAudioWorkletNode extends FakeAudioNode {
|
|
44
|
+
readonly configuration?: unknown;
|
|
45
|
+
onprocessorerror: ((event: Event) => void) | null;
|
|
46
|
+
readonly port: FakeMessagePort;
|
|
47
|
+
constructor(configuration?: unknown);
|
|
48
|
+
/** What the page posted to the processor, in order. */
|
|
49
|
+
get posted(): unknown[];
|
|
50
|
+
/** The messages of `type` the page posted. */
|
|
51
|
+
postedOf(type: string): Record<string, unknown>[];
|
|
52
|
+
/** The processor posts `data` to the page. */
|
|
53
|
+
emit(data: unknown): void;
|
|
54
|
+
/** The processor threw. */
|
|
55
|
+
fail(): void;
|
|
56
|
+
}
|
|
57
|
+
/** An audio buffer holding the samples copied into it. */
|
|
58
|
+
export declare class FakeAudioBuffer {
|
|
59
|
+
readonly length: number;
|
|
60
|
+
readonly sampleRate: number;
|
|
61
|
+
readonly data: Float32Array;
|
|
62
|
+
constructor(length: number, sampleRate: number);
|
|
63
|
+
copyToChannel(samples: Float32Array, _channel: number): void;
|
|
64
|
+
}
|
|
65
|
+
/** A gain node: its value is what a test reads. */
|
|
66
|
+
export declare class FakeGainNode extends FakeAudioNode {
|
|
67
|
+
readonly gain: {
|
|
68
|
+
value: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A buffer source: {@link start} records when it was asked to start, and
|
|
73
|
+
* {@link stop} ends it, as a real one does.
|
|
74
|
+
*/
|
|
75
|
+
export declare class FakeBufferSource extends FakeAudioNode {
|
|
76
|
+
buffer: FakeAudioBuffer | null;
|
|
77
|
+
onended: (() => void) | null;
|
|
78
|
+
/** The node it was connected to. */
|
|
79
|
+
output: FakeGainNode | undefined;
|
|
80
|
+
/** The times it was asked to start at, in order; `undefined` for now. */
|
|
81
|
+
readonly starts: (number | undefined)[];
|
|
82
|
+
/** How many times the page called {@link stop}. */
|
|
83
|
+
stopCount: number;
|
|
84
|
+
connect(node: FakeGainNode): void;
|
|
85
|
+
start(when?: number): void;
|
|
86
|
+
stop(): void;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* An `AudioContext` that starts suspended, as before a gesture, and answers
|
|
90
|
+
* `resume`, `suspend` and `close` by its state and a `statechange` event.
|
|
91
|
+
*/
|
|
92
|
+
export declare class FakeAudioContext extends EventTarget {
|
|
93
|
+
readonly sampleRate: number;
|
|
94
|
+
state: AudioContextState;
|
|
95
|
+
/** Whether the page's `resume()` is allowed: false before a gesture. */
|
|
96
|
+
isResumeAllowed: boolean;
|
|
97
|
+
/** What the next `addModule` and `resume` calls wait for, in turn. */
|
|
98
|
+
moduleGates: Promise<void>[];
|
|
99
|
+
resumeGates: Promise<void>[];
|
|
100
|
+
/** The URLs of every `addModule` call, in order. */
|
|
101
|
+
readonly modules: string[];
|
|
102
|
+
readonly audioWorklet: {
|
|
103
|
+
addModule: (url: string) => Promise<void>;
|
|
104
|
+
};
|
|
105
|
+
isModuleFailing: boolean;
|
|
106
|
+
/** Whether a stream whose rate is not the context's is refused, as Firefox. */
|
|
107
|
+
isRateMatchRequired: boolean;
|
|
108
|
+
/** The name of the exception `createMediaStreamSource` throws, if any. */
|
|
109
|
+
sourceErrorName: string | undefined;
|
|
110
|
+
readonly sources: FakeMediaStreamSource[];
|
|
111
|
+
/** The context's clock, seconds: tests set it. */
|
|
112
|
+
currentTime: number;
|
|
113
|
+
baseLatency: number;
|
|
114
|
+
/** What the browser reports of the output; `undefined` when it does not. */
|
|
115
|
+
outputLatency: number | undefined;
|
|
116
|
+
readonly destination: {};
|
|
117
|
+
/** The sounds played, in order. */
|
|
118
|
+
readonly bufferSources: FakeBufferSource[];
|
|
119
|
+
/** How many times the page called {@link resume}. */
|
|
120
|
+
resumeCount: number;
|
|
121
|
+
/** How many times the page called {@link suspend}. */
|
|
122
|
+
suspendCount: number;
|
|
123
|
+
/** How many times the page called {@link close}. */
|
|
124
|
+
closeCount: number;
|
|
125
|
+
constructor(sampleRate: number);
|
|
126
|
+
createBuffer(_channels: number, length: number, sampleRate: number): FakeAudioBuffer;
|
|
127
|
+
createBufferSource(): FakeBufferSource;
|
|
128
|
+
createGain(): FakeGainNode;
|
|
129
|
+
createMediaStreamSource(stream: MediaStream): FakeMediaStreamSource;
|
|
130
|
+
resume(): Promise<void>;
|
|
131
|
+
suspend(): Promise<void>;
|
|
132
|
+
close(): Promise<void>;
|
|
133
|
+
/** The browser changes the context's state: another tab, a phone call. */
|
|
134
|
+
setState(state: string): void;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* What a browser makes audio contexts and worklet nodes of: records every one,
|
|
138
|
+
* and refuses the sampling rates it is told to, as Firefox does.
|
|
139
|
+
*/
|
|
140
|
+
export declare class FakeAudioEnvironment {
|
|
141
|
+
readonly contexts: FakeAudioContext[];
|
|
142
|
+
readonly nodes: FakeAudioWorkletNode[];
|
|
143
|
+
/** The rates `createContext` refuses with a `NotSupportedError`. */
|
|
144
|
+
readonly unsupportedRates: Set<number>;
|
|
145
|
+
/** The rate of a context made with none. */
|
|
146
|
+
defaultRate: number;
|
|
147
|
+
/** Whether the contexts made from now on are Firefox's about rates. */
|
|
148
|
+
isRateMatchRequired: boolean;
|
|
149
|
+
/** Whether the contexts made from now on fail to load the module. */
|
|
150
|
+
isModuleFailing: boolean;
|
|
151
|
+
/** The exception the contexts made from now on throw making a source. */
|
|
152
|
+
sourceErrorName: string | undefined;
|
|
153
|
+
/** Whether the contexts made from now on may run: false before a gesture. */
|
|
154
|
+
isResumeAllowed: boolean;
|
|
155
|
+
private readonly moduleGates;
|
|
156
|
+
private readonly resumeGates;
|
|
157
|
+
/**
|
|
158
|
+
* Makes the next `addModule` of any context wait.
|
|
159
|
+
*
|
|
160
|
+
* @returns What lets it go on.
|
|
161
|
+
*/
|
|
162
|
+
holdNextModule(): () => void;
|
|
163
|
+
/**
|
|
164
|
+
* Makes the next `resume` of any context wait, as before a gesture.
|
|
165
|
+
*
|
|
166
|
+
* @returns What lets it go on.
|
|
167
|
+
*/
|
|
168
|
+
holdNextResume(): () => void;
|
|
169
|
+
readonly createContext: (sampleRate?: number) => AudioContext;
|
|
170
|
+
readonly createWorkletNode: (_context: AudioContext, configuration?: unknown) => AudioWorkletNode;
|
|
171
|
+
get context(): FakeAudioContext;
|
|
172
|
+
get node(): FakeAudioWorkletNode;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=fake-audio-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-audio-context.d.ts","sourceRoot":"","sources":["../../src/testing/fake-audio-context.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,qBAAa,aAAa;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,CAAM;IACrC,yDAAyD;IACzD,eAAe,SAAK;IAEpB,OAAO,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAElC;IAED,UAAU,IAAI,IAAI,CAEjB;CACD;AAED,wDAAwD;AACxD,qBAAa,qBAAs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C,gBAAgB,cAAqB;IAC9C,4CAA4C;IAC5C,WAAW,SAAU;IACrB,uEAAuE;IACvE,mBAAmB,UAAS;IAC5B,qEAAqE;IACrE,eAAe,UAAS;IACxB,yEAAyE;IACzE,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,6EAA6E;IAC7E,eAAe,UAAQ;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IAEnD;;;;OAIG;IACH,cAAc,IAAI,MAAM,IAAI,CAK3B;IAED;;;;OAIG;IACH,cAAc,IAAI,MAAM,IAAI,CAK3B;IAED,QAAQ,CAAC,aAAa,gBAAiB,MAAM,KAAG,YAAY,CAe1D;IAEF,QAAQ,CAAC,iBAAiB,aACf,YAAY,kBACN,OAAO,KACrB,gBAAgB,CAKjB;IAEF,IAAI,OAAO,IAAI,gBAAgB,CAO9B;IAED,IAAI,IAAI,IAAI,oBAAoB,CAO/B;CACD"}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/** An audio node that records what it was connected to, and its disconnections. */
|
|
2
|
+
export class FakeAudioNode {
|
|
3
|
+
/** The nodes it was connected to, in order. */
|
|
4
|
+
connections = [];
|
|
5
|
+
/** How many times the page called {@link disconnect}. */
|
|
6
|
+
disconnectCount = 0;
|
|
7
|
+
connect(destination) {
|
|
8
|
+
this.connections.push(destination);
|
|
9
|
+
}
|
|
10
|
+
disconnect() {
|
|
11
|
+
this.disconnectCount += 1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** The node a microphone stream enters the graph by. */
|
|
15
|
+
export class FakeMediaStreamSource extends FakeAudioNode {
|
|
16
|
+
stream;
|
|
17
|
+
constructor(stream) {
|
|
18
|
+
super();
|
|
19
|
+
this.stream = stream;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A message port the page posts to and listens on. What arrives before there is
|
|
24
|
+
* a listener waits for it, and is handed over after the current task, as a real
|
|
25
|
+
* port does.
|
|
26
|
+
*/
|
|
27
|
+
export class FakeMessagePort {
|
|
28
|
+
/** What the page posted, in order. */
|
|
29
|
+
posted = [];
|
|
30
|
+
/**
|
|
31
|
+
* The other end, given each message the page posts once it is recorded: set
|
|
32
|
+
* it to feed a real processor's logic, rather than replacing
|
|
33
|
+
* {@link postMessage}, whose replacement would leave {@link posted} empty.
|
|
34
|
+
*/
|
|
35
|
+
onPostMessage;
|
|
36
|
+
handler = null;
|
|
37
|
+
pending = [];
|
|
38
|
+
postMessage(message) {
|
|
39
|
+
this.posted.push(message);
|
|
40
|
+
this.onPostMessage?.(message);
|
|
41
|
+
}
|
|
42
|
+
get onmessage() {
|
|
43
|
+
return this.handler;
|
|
44
|
+
}
|
|
45
|
+
set onmessage(handler) {
|
|
46
|
+
this.handler = handler;
|
|
47
|
+
if (handler !== null && this.pending.length > 0) {
|
|
48
|
+
queueMicrotask(() => this.flush());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** `data` arrives from the other end. */
|
|
52
|
+
receive(data) {
|
|
53
|
+
if (this.handler === null) {
|
|
54
|
+
this.pending.push(data);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.handler(new MessageEvent("message", { data }));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
flush() {
|
|
61
|
+
for (const data of this.pending.splice(0)) {
|
|
62
|
+
this.handler?.(new MessageEvent("message", { data }));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* An `AudioWorkletNode` whose processor is the test: what the page posts is in
|
|
68
|
+
* {@link posted}, and {@link emit} posts to the page. The processor options it
|
|
69
|
+
* was made with are in {@link configuration}.
|
|
70
|
+
*/
|
|
71
|
+
export class FakeAudioWorkletNode extends FakeAudioNode {
|
|
72
|
+
configuration;
|
|
73
|
+
onprocessorerror = null;
|
|
74
|
+
port = new FakeMessagePort();
|
|
75
|
+
constructor(configuration) {
|
|
76
|
+
super();
|
|
77
|
+
this.configuration = configuration;
|
|
78
|
+
}
|
|
79
|
+
/** What the page posted to the processor, in order. */
|
|
80
|
+
get posted() {
|
|
81
|
+
return this.port.posted;
|
|
82
|
+
}
|
|
83
|
+
/** The messages of `type` the page posted. */
|
|
84
|
+
postedOf(type) {
|
|
85
|
+
return this.posted.filter((message) => typeof message === "object" &&
|
|
86
|
+
message !== null &&
|
|
87
|
+
"type" in message &&
|
|
88
|
+
message.type === type);
|
|
89
|
+
}
|
|
90
|
+
/** The processor posts `data` to the page. */
|
|
91
|
+
emit(data) {
|
|
92
|
+
this.port.receive(data);
|
|
93
|
+
}
|
|
94
|
+
/** The processor threw. */
|
|
95
|
+
fail() {
|
|
96
|
+
this.onprocessorerror?.(new Event("processorerror"));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** An audio buffer holding the samples copied into it. */
|
|
100
|
+
export class FakeAudioBuffer {
|
|
101
|
+
length;
|
|
102
|
+
sampleRate;
|
|
103
|
+
data;
|
|
104
|
+
constructor(length, sampleRate) {
|
|
105
|
+
this.length = length;
|
|
106
|
+
this.sampleRate = sampleRate;
|
|
107
|
+
this.data = new Float32Array(length);
|
|
108
|
+
}
|
|
109
|
+
copyToChannel(samples, _channel) {
|
|
110
|
+
this.data.set(samples);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** A gain node: its value is what a test reads. */
|
|
114
|
+
export class FakeGainNode extends FakeAudioNode {
|
|
115
|
+
gain = { value: 1 };
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A buffer source: {@link start} records when it was asked to start, and
|
|
119
|
+
* {@link stop} ends it, as a real one does.
|
|
120
|
+
*/
|
|
121
|
+
export class FakeBufferSource extends FakeAudioNode {
|
|
122
|
+
buffer = null;
|
|
123
|
+
onended = null;
|
|
124
|
+
/** The node it was connected to. */
|
|
125
|
+
output;
|
|
126
|
+
/** The times it was asked to start at, in order; `undefined` for now. */
|
|
127
|
+
starts = [];
|
|
128
|
+
/** How many times the page called {@link stop}. */
|
|
129
|
+
stopCount = 0;
|
|
130
|
+
connect(node) {
|
|
131
|
+
super.connect(node);
|
|
132
|
+
this.output = node;
|
|
133
|
+
}
|
|
134
|
+
start(when) {
|
|
135
|
+
this.starts.push(when);
|
|
136
|
+
}
|
|
137
|
+
stop() {
|
|
138
|
+
this.stopCount += 1;
|
|
139
|
+
this.onended?.();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* An `AudioContext` that starts suspended, as before a gesture, and answers
|
|
144
|
+
* `resume`, `suspend` and `close` by its state and a `statechange` event.
|
|
145
|
+
*/
|
|
146
|
+
export class FakeAudioContext extends EventTarget {
|
|
147
|
+
sampleRate;
|
|
148
|
+
state = "suspended";
|
|
149
|
+
/** Whether the page's `resume()` is allowed: false before a gesture. */
|
|
150
|
+
isResumeAllowed = true;
|
|
151
|
+
/** What the next `addModule` and `resume` calls wait for, in turn. */
|
|
152
|
+
moduleGates = [];
|
|
153
|
+
resumeGates = [];
|
|
154
|
+
/** The URLs of every `addModule` call, in order. */
|
|
155
|
+
modules = [];
|
|
156
|
+
audioWorklet = {
|
|
157
|
+
addModule: async (url) => {
|
|
158
|
+
this.modules.push(url);
|
|
159
|
+
await this.moduleGates.shift();
|
|
160
|
+
if (this.isModuleFailing) {
|
|
161
|
+
throw new DOMException("fake module failure", "AbortError");
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
isModuleFailing = false;
|
|
166
|
+
/** Whether a stream whose rate is not the context's is refused, as Firefox. */
|
|
167
|
+
isRateMatchRequired = false;
|
|
168
|
+
/** The name of the exception `createMediaStreamSource` throws, if any. */
|
|
169
|
+
sourceErrorName;
|
|
170
|
+
sources = [];
|
|
171
|
+
/** The context's clock, seconds: tests set it. */
|
|
172
|
+
currentTime = 0;
|
|
173
|
+
baseLatency = 0.01;
|
|
174
|
+
/** What the browser reports of the output; `undefined` when it does not. */
|
|
175
|
+
outputLatency = 0.02;
|
|
176
|
+
destination = {};
|
|
177
|
+
/** The sounds played, in order. */
|
|
178
|
+
bufferSources = [];
|
|
179
|
+
/** How many times the page called {@link resume}. */
|
|
180
|
+
resumeCount = 0;
|
|
181
|
+
/** How many times the page called {@link suspend}. */
|
|
182
|
+
suspendCount = 0;
|
|
183
|
+
/** How many times the page called {@link close}. */
|
|
184
|
+
closeCount = 0;
|
|
185
|
+
constructor(sampleRate) {
|
|
186
|
+
super();
|
|
187
|
+
this.sampleRate = sampleRate;
|
|
188
|
+
}
|
|
189
|
+
createBuffer(_channels, length, sampleRate) {
|
|
190
|
+
return new FakeAudioBuffer(length, sampleRate);
|
|
191
|
+
}
|
|
192
|
+
createBufferSource() {
|
|
193
|
+
const source = new FakeBufferSource();
|
|
194
|
+
this.bufferSources.push(source);
|
|
195
|
+
return source;
|
|
196
|
+
}
|
|
197
|
+
createGain() {
|
|
198
|
+
return new FakeGainNode();
|
|
199
|
+
}
|
|
200
|
+
createMediaStreamSource(stream) {
|
|
201
|
+
if (this.sourceErrorName !== undefined) {
|
|
202
|
+
throw new DOMException("fake source failure", this.sourceErrorName);
|
|
203
|
+
}
|
|
204
|
+
const [track] = stream.getAudioTracks();
|
|
205
|
+
const rate = track?.getSettings().sampleRate;
|
|
206
|
+
if (this.isRateMatchRequired &&
|
|
207
|
+
rate !== undefined &&
|
|
208
|
+
rate !== this.sampleRate) {
|
|
209
|
+
throw new DOMException("sample rates differ", "NotSupportedError");
|
|
210
|
+
}
|
|
211
|
+
const source = new FakeMediaStreamSource(stream);
|
|
212
|
+
this.sources.push(source);
|
|
213
|
+
return source;
|
|
214
|
+
}
|
|
215
|
+
async resume() {
|
|
216
|
+
this.resumeCount += 1;
|
|
217
|
+
await this.resumeGates.shift();
|
|
218
|
+
if (this.isResumeAllowed) {
|
|
219
|
+
this.setState("running");
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async suspend() {
|
|
223
|
+
this.suspendCount += 1;
|
|
224
|
+
this.setState("suspended");
|
|
225
|
+
}
|
|
226
|
+
async close() {
|
|
227
|
+
this.closeCount += 1;
|
|
228
|
+
this.setState("closed");
|
|
229
|
+
}
|
|
230
|
+
/** The browser changes the context's state: another tab, a phone call. */
|
|
231
|
+
setState(state) {
|
|
232
|
+
if (state !== this.state) {
|
|
233
|
+
this.state = state;
|
|
234
|
+
this.dispatchEvent(new Event("statechange"));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* What a browser makes audio contexts and worklet nodes of: records every one,
|
|
240
|
+
* and refuses the sampling rates it is told to, as Firefox does.
|
|
241
|
+
*/
|
|
242
|
+
export class FakeAudioEnvironment {
|
|
243
|
+
contexts = [];
|
|
244
|
+
nodes = [];
|
|
245
|
+
/** The rates `createContext` refuses with a `NotSupportedError`. */
|
|
246
|
+
unsupportedRates = new Set();
|
|
247
|
+
/** The rate of a context made with none. */
|
|
248
|
+
defaultRate = 48000;
|
|
249
|
+
/** Whether the contexts made from now on are Firefox's about rates. */
|
|
250
|
+
isRateMatchRequired = false;
|
|
251
|
+
/** Whether the contexts made from now on fail to load the module. */
|
|
252
|
+
isModuleFailing = false;
|
|
253
|
+
/** The exception the contexts made from now on throw making a source. */
|
|
254
|
+
sourceErrorName;
|
|
255
|
+
/** Whether the contexts made from now on may run: false before a gesture. */
|
|
256
|
+
isResumeAllowed = true;
|
|
257
|
+
moduleGates = [];
|
|
258
|
+
resumeGates = [];
|
|
259
|
+
/**
|
|
260
|
+
* Makes the next `addModule` of any context wait.
|
|
261
|
+
*
|
|
262
|
+
* @returns What lets it go on.
|
|
263
|
+
*/
|
|
264
|
+
holdNextModule() {
|
|
265
|
+
const gate = Promise.withResolvers();
|
|
266
|
+
this.moduleGates.push(gate.promise);
|
|
267
|
+
return gate.resolve;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Makes the next `resume` of any context wait, as before a gesture.
|
|
271
|
+
*
|
|
272
|
+
* @returns What lets it go on.
|
|
273
|
+
*/
|
|
274
|
+
holdNextResume() {
|
|
275
|
+
const gate = Promise.withResolvers();
|
|
276
|
+
this.resumeGates.push(gate.promise);
|
|
277
|
+
return gate.resolve;
|
|
278
|
+
}
|
|
279
|
+
createContext = (sampleRate) => {
|
|
280
|
+
const rate = sampleRate ?? this.defaultRate;
|
|
281
|
+
if (this.unsupportedRates.has(rate)) {
|
|
282
|
+
throw new DOMException(`rate ${rate} refused`, "NotSupportedError");
|
|
283
|
+
}
|
|
284
|
+
const context = new FakeAudioContext(rate);
|
|
285
|
+
context.isRateMatchRequired = this.isRateMatchRequired;
|
|
286
|
+
context.isModuleFailing = this.isModuleFailing;
|
|
287
|
+
context.sourceErrorName = this.sourceErrorName;
|
|
288
|
+
context.isResumeAllowed = this.isResumeAllowed;
|
|
289
|
+
context.moduleGates = this.moduleGates;
|
|
290
|
+
context.resumeGates = this.resumeGates;
|
|
291
|
+
this.contexts.push(context);
|
|
292
|
+
return context;
|
|
293
|
+
};
|
|
294
|
+
createWorkletNode = (_context, configuration) => {
|
|
295
|
+
const node = new FakeAudioWorkletNode(configuration);
|
|
296
|
+
this.nodes.push(node);
|
|
297
|
+
return node;
|
|
298
|
+
};
|
|
299
|
+
get context() {
|
|
300
|
+
const context = this.contexts.at(-1);
|
|
301
|
+
if (context === undefined) {
|
|
302
|
+
throw new Error("no context was made");
|
|
303
|
+
}
|
|
304
|
+
return context;
|
|
305
|
+
}
|
|
306
|
+
get node() {
|
|
307
|
+
const node = this.nodes.at(-1);
|
|
308
|
+
if (node === undefined) {
|
|
309
|
+
throw new Error("no worklet node was made");
|
|
310
|
+
}
|
|
311
|
+
return node;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
//# sourceMappingURL=fake-audio-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-audio-context.js","sourceRoot":"","sources":["../../src/testing/fake-audio-context.ts"],"names":[],"mappings":"AAAA,mFAA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-0,0 +1,90 @@
|
|
|
1
|
+
/** What a fake track reports of itself, as `getSettings()` does. */
|
|
2
|
+
export type FakeTrackSettings = {
|
|
3
|
+
sampleRate?: number;
|
|
4
|
+
echoCancellation?: boolean;
|
|
5
|
+
noiseSuppression?: boolean;
|
|
6
|
+
autoGainControl?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A microphone's audio track: live until stopped or until its device is lost
|
|
10
|
+
* ({@link end}), which a real track reports by an `ended` event, and not by
|
|
11
|
+
* `stop()`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class FakeMediaStreamTrack extends EventTarget {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
private readonly settings_;
|
|
16
|
+
readyState: MediaStreamTrackState;
|
|
17
|
+
muted: boolean;
|
|
18
|
+
/** How many times the page called {@link stop}. */
|
|
19
|
+
stopCount: number;
|
|
20
|
+
private readonly listeners_;
|
|
21
|
+
constructor(label?: string, settings_?: FakeTrackSettings);
|
|
22
|
+
/** How many listeners of `type` are registered, those removed by a signal not. */
|
|
23
|
+
listenerCount(type: string): number;
|
|
24
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
|
|
25
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: EventListenerOptions | boolean): void;
|
|
26
|
+
getSettings(): FakeTrackSettings;
|
|
27
|
+
stop(): void;
|
|
28
|
+
/** The device went away. */
|
|
29
|
+
end(): void;
|
|
30
|
+
/** Another application took the microphone. */
|
|
31
|
+
mute(): void;
|
|
32
|
+
unmute(): void;
|
|
33
|
+
}
|
|
34
|
+
/** A media stream that stands for the microphone's: one live track by default. */
|
|
35
|
+
export declare class FakeMediaStream {
|
|
36
|
+
private readonly tracks_;
|
|
37
|
+
constructor(tracks_?: FakeMediaStreamTrack[]);
|
|
38
|
+
getTracks(): MediaStreamTrack[];
|
|
39
|
+
getAudioTracks(): MediaStreamTrack[];
|
|
40
|
+
}
|
|
41
|
+
/** One device `enumerateDevices` lists. */
|
|
42
|
+
export type FakeMediaDeviceInfo = {
|
|
43
|
+
kind: MediaDeviceKind;
|
|
44
|
+
deviceId: string;
|
|
45
|
+
label: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* What a `getUserMedia` call answers: `"ok"` opens a stream, another string
|
|
49
|
+
* rejects with a `DOMException` of that name, and any other value is thrown as
|
|
50
|
+
* it is (an `OverconstrainedError` carrying its `constraint`, say).
|
|
51
|
+
*/
|
|
52
|
+
export type FakeUserMediaOutcome = string | {
|
|
53
|
+
readonly thrown: unknown;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* A `MediaDevices` whose `getUserMedia` answers with the given outcomes in
|
|
57
|
+
* turn, then opens streams, and which lists the given devices. It opens a
|
|
58
|
+
* stream of one track with {@link trackSettings}, keeps every request and every
|
|
59
|
+
* track it opened, and tells when the devices change.
|
|
60
|
+
*
|
|
61
|
+
* Its methods are plain: spy on them with the test runner's own spies
|
|
62
|
+
* (`vi.spyOn(mediaDevices, "getUserMedia")`) to assert on the calls.
|
|
63
|
+
*/
|
|
64
|
+
export declare class FakeMediaDevices extends EventTarget {
|
|
65
|
+
private readonly outcomes_;
|
|
66
|
+
devices: FakeMediaDeviceInfo[];
|
|
67
|
+
/** What the tracks opened from now on report of themselves. */
|
|
68
|
+
trackSettings: FakeTrackSettings;
|
|
69
|
+
/** The label of the tracks opened from now on. */
|
|
70
|
+
trackLabel: string;
|
|
71
|
+
/** The constraints of every `getUserMedia` call, in order. */
|
|
72
|
+
readonly requests: (MediaStreamConstraints | undefined)[];
|
|
73
|
+
/** Every track opened, in order. */
|
|
74
|
+
readonly tracks: FakeMediaStreamTrack[];
|
|
75
|
+
private readonly gates_;
|
|
76
|
+
constructor(outcomes_?: FakeUserMediaOutcome[], devices?: FakeMediaDeviceInfo[]);
|
|
77
|
+
/** The tracks opened and neither stopped nor ended. */
|
|
78
|
+
get liveTracks(): FakeMediaStreamTrack[];
|
|
79
|
+
getUserMedia(constraints?: MediaStreamConstraints): Promise<MediaStream>;
|
|
80
|
+
enumerateDevices(): Promise<MediaDeviceInfo[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Makes the next `getUserMedia` wait, as for a permission prompt.
|
|
83
|
+
*
|
|
84
|
+
* @returns What lets it go on.
|
|
85
|
+
*/
|
|
86
|
+
holdNext(): () => void;
|
|
87
|
+
/** Plugs `devices` in and out: the browser tells so. */
|
|
88
|
+
changeDevices(devices: FakeMediaDeviceInfo[]): void;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=fake-media-devices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-media-devices.d.ts","sourceRoot":"","sources":["../../src/testing/fake-media-devices.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;IASnD,QAAQ,CAAC,KAAK;IACd,OAAO,CAAC,QAAQ,CAAC,SAAS;IAT3B,UAAU,EAAE,qBAAqB,CAAU;IAC3C,KAAK,UAAS;IACd,mDAAmD;IACnD,SAAS,SAAK;IAEd,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAE9D,YACU,KAAK,SAAoB,EACjB,SAAS,GAAE,iBAAsB,EAGlD;IAED,kFAAkF;IAClF,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElC;IAEQ,gBAAgB,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,kCAAkC,GAAG,IAAI,EACnD,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,GACzC,IAAI,CAUN;IAEQ,mBA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