cacophony 0.1.0 → 0.1.1

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/README.md ADDED
@@ -0,0 +1,102 @@
1
+ Cacophony is a highly robust and versatile audio library for Typescript leveraging the WebAudio API, crafted to simplify audio management in complex applications. The core concept of Cacophony revolves around the creation and manipulation of three key elements: `Sound`, `Playback`, and `Group`.
2
+
3
+ - A `Sound` represents a distinct audio source, derived from an `AudioBuffer` or a URL string pointing to an audio file.
4
+ - A `Playback` refers to the act of playing a `Sound` and carries additional properties such as its position in a 3D audio scene, gain-node for volume control, and more.
5
+ - A `Group` encapsulates multiple `Sound` instances to handle them as one entity, permitting the grouped sounds to be played, paused, or stopped synchronously.
6
+
7
+ ## Features
8
+
9
+ - Multiple Audio Sources: Handle buffers, URLs, groups of sounds, and playbacks seamlessly.
10
+ - Comprehensive Audio Control: Play, stop, pause, resume, infinite or finite loops, and volume adjustments.
11
+ - 3D Audio Positioning: Precise control on 3D spatial positioning of the audio source.
12
+ - Audio Filtering: Elevate audio output with filters - adding, removing, or applying directly to an audio source.
13
+ - Volume Control: Mute, unmute, and volume adjustments on a global scale.
14
+
15
+ ## Quick Installation
16
+
17
+ Cacophony is provided as a regular NPM module. Install it using:
18
+
19
+ ```bash
20
+ $ npm install cacophony-ts
21
+ ```
22
+
23
+ ## Straightforward Usage
24
+
25
+ Utilizing Cacophony in the codebase is effortless, demonstrated below:
26
+
27
+ ```typescript
28
+ import { Cacophony } from 'cacophony-ts';
29
+
30
+ async function playSampleSound() {
31
+ const cacophony = new Cacophony();
32
+ const sound = await cacophony.createSound('path/to/your/audio/file.mp3');
33
+
34
+ sound.play();
35
+ sound.moveTo(1, 1, 1); // Position the sound in 3D space
36
+ }
37
+
38
+ playSampleSound();
39
+ ```
40
+
41
+ ## Comprehensive Documentation
42
+
43
+ ### Main Class: `Cacophony`
44
+
45
+ The centerpiece of the library delivers methods for creating sounds, managing global volumes, and more.
46
+
47
+ #### Method: `async createSound(bufferOrUrl: AudioBuffer | string): Promise<Sound>`
48
+
49
+ Crafts a `Sound` instance using either an `AudioBuffer` or a URL string leading to the desired audio file.
50
+
51
+ #### Method: `async createGroup(sounds: Sound[]): Promise<Group>`
52
+
53
+ Fabricates a `Group` entity from an array of `Sound` instances.
54
+
55
+ #### Method: `async createGroupFromUrls(urls: string[]): Promise<Group>`
56
+
57
+ Forms a `Group` instance from an array of URLs directing to the desired audio files.
58
+
59
+ #### Method: `createBiquadFilter(type: BiquadFilterType): BiquadFilterNode`
60
+
61
+ Generates a `BiquadFilterNode` ready to be applied to sounds.
62
+
63
+ #### Method: `pause()`
64
+
65
+ Halts all active audio.
66
+
67
+ #### Method: `resume()`
68
+
69
+ Resumes all paused audio.
70
+
71
+ #### Method: `stopAll()`
72
+
73
+ Complete cessation of all audio, irrespective of their current states.
74
+
75
+ #### Method: `setGlobalVolume(volume: number)`
76
+
77
+ Adjusts the global volume to the passed value.
78
+
79
+ #### Method: `mute()`
80
+
81
+ Silences all audio by setting the global volume to 0.
82
+
83
+ #### Method: `unmute()`
84
+
85
+ Resumes audio by restoring the global volume to its preceding value.
86
+
87
+ ### Shared Methods Across Sound Sources
88
+
89
+ All classes representing sound sources (`Sound`, `Playback`, `Group`) offer the following methods for a consistent interface and user-friendly experience:
90
+
91
+ - `play()`
92
+ - `stop()`
93
+ - `pause()`
94
+ - `resume()`
95
+ - `addFilter(filter: BiquadFilterNode)`
96
+ - `removeFilter(filter: BiquadFilterNode)`
97
+ - `moveTo(x: number, y: number, z: number)`
98
+ - `loop(loopCount?: LoopCount)`: `LoopCount` can be a finite number or 'infinite'.
99
+
100
+ ## License
101
+
102
+ Cacophony is freely available for incorporation into your projects under the [MIT License](LICENSE.txt).
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cacophony"), exports);
18
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,25 @@
1
1
  {
2
2
  "name": "cacophony",
3
- "version": "0.1.0",
4
- "main": "index.js",
5
- "author": "Wang Zuo <wangzuo@swiftcarrot.com> (https://swiftcarrot.com)",
6
- "license": "MIT"
7
- }
3
+ "version": "0.1.1",
4
+ "description": "Typescript audio library with caching",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "npm run clean && tsc --build",
9
+ "clean": "tsc --build --clean",
10
+ "prepublishOnly": "npm run build",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "keywords": [
14
+ "audio",
15
+ "webaudio"
16
+ ],
17
+ "author": "Christopher Toth",
18
+ "license": "ISC",
19
+ "devDependencies": {
20
+ "typescript": "^5.1.6"
21
+ },
22
+ "dependencies": {
23
+ "standardized-audio-context": "^25.3.55"
24
+ }
25
+ }
package/src/cache.ts ADDED
@@ -0,0 +1,63 @@
1
+ import { IAudioContext } from "standardized-audio-context";
2
+
3
+ export class CacheManager {
4
+ private static pendingRequests = new Map<string, Promise<AudioBuffer>>();
5
+
6
+ private static async openCache(): Promise<Cache> {
7
+ try {
8
+ return await caches.open('audio-cache');
9
+ } catch (error) {
10
+ console.error('Failed to open cache:', error);
11
+ throw error;
12
+ }
13
+ }
14
+
15
+ private static async getAudioBufferFromCache(url: string, cache: Cache, context: IAudioContext): Promise<AudioBuffer | null> {
16
+ try {
17
+ const response = await cache.match(url);
18
+ if (response) {
19
+ const arrayBuffer = await response.arrayBuffer();
20
+ return context.decodeAudioData(arrayBuffer);
21
+ }
22
+ return null;
23
+ } catch (error) {
24
+ console.error('Failed to get audio data from cache:', error);
25
+ throw error;
26
+ }
27
+ }
28
+
29
+ private static async fetchAndCacheAudioBuffer(url: string, cache: Cache, context: IAudioContext): Promise<AudioBuffer> {
30
+ try {
31
+ const fetchResponse = await fetch(url);
32
+ const responseClone = fetchResponse.clone();
33
+ cache.put(url, responseClone);
34
+ const arrayBuffer = await fetchResponse.arrayBuffer();
35
+ return context.decodeAudioData(arrayBuffer);
36
+ } catch (error) {
37
+ console.error('Failed to fetch and cache audio data:', error);
38
+ throw error;
39
+ }
40
+ }
41
+
42
+ public static async getAudioBuffer(url: string, context: IAudioContext): Promise<AudioBuffer> {
43
+ const cache = await this.openCache();
44
+
45
+ // First, check if there's a pending request.
46
+ let pendingRequest = this.pendingRequests.get(url);
47
+ if (pendingRequest) {
48
+ return pendingRequest;
49
+ }
50
+
51
+ // Try getting the buffer from cache.
52
+ const bufferFromCache = await this.getAudioBufferFromCache(url, cache, context);
53
+ if (bufferFromCache) {
54
+ return bufferFromCache;
55
+ }
56
+
57
+ // If it's not in the cache, fetch and cache it.
58
+ pendingRequest = this.fetchAndCacheAudioBuffer(url, cache, context);
59
+ this.pendingRequests.set(url, pendingRequest);
60
+
61
+ return pendingRequest;
62
+ }
63
+ }
@@ -0,0 +1,396 @@
1
+ import { AudioContext, IAudioBuffer, IAudioBufferSourceNode, IAudioListener, IBiquadFilterNode, IGainNode, IPannerNode } from 'standardized-audio-context';
2
+ import { CacheManager } from './cache';
3
+
4
+
5
+ type GainNode = IGainNode<AudioContext>;
6
+ type BiquadFilterNode = IBiquadFilterNode<AudioContext>;
7
+
8
+ type AudioBufferSourceNode = IAudioBufferSourceNode<AudioContext>;
9
+ type PannerNode = IPannerNode<AudioContext>;
10
+
11
+ type LoopCount = number | 'infinite';
12
+
13
+ export type FadeType = 'linear' | 'exponential'
14
+
15
+ export interface BaseSound {
16
+ // the stuff you should be able to do with anything that makes sound including groups, sounds, and playbacks.
17
+ play(): Playback[];
18
+ stop(): void;
19
+ pause(): void;
20
+ resume(): void;
21
+ addFilter(filter: BiquadFilterNode): void;
22
+ removeFilter(filter: BiquadFilterNode): void;
23
+ moveTo(x: number, y: number, z: number): void;
24
+ loop(loopCount?: LoopCount): LoopCount;
25
+ }
26
+
27
+ export class Cacophony {
28
+ context: AudioContext;
29
+ globalGainNode: GainNode;
30
+ listener: IAudioListener;
31
+ private prevVolume: number = 1;
32
+
33
+ constructor(context?: AudioContext) {
34
+ this.context = context || new AudioContext();
35
+ this.listener = this.context.listener;
36
+ this.globalGainNode = this.context.createGain();
37
+ this.globalGainNode.connect(this.context.destination);
38
+ }
39
+
40
+ async createSound(buffer: AudioBuffer): Promise<Sound>
41
+
42
+ async createSound(url: string): Promise<Sound>
43
+
44
+ async createSound(bufferOrUrl: AudioBuffer | string): Promise<Sound> {
45
+ if (bufferOrUrl instanceof AudioBuffer) {
46
+ return Promise.resolve(new Sound(bufferOrUrl, this.context, this.globalGainNode));
47
+ }
48
+ const url = bufferOrUrl;
49
+ return CacheManager.getAudioBuffer(url, this.context).then(buffer => new Sound(buffer, this.context, this.globalGainNode));
50
+ }
51
+
52
+ async createGroup(sounds: Sound[]): Promise<Group> {
53
+ const group = new Group();
54
+ sounds.forEach(sound => group.addSound(sound));
55
+ return group;
56
+ }
57
+
58
+ async createGroupFromUrls(urls: string[]): Promise<Group> {
59
+ const group = new Group();
60
+ const sounds = await Promise.all(urls.map(url => this.createSound(url)));
61
+ sounds.forEach(sound => group.addSound(sound));
62
+ return group;
63
+ }
64
+
65
+ createBiquadFilter(type: BiquadFilterType): BiquadFilterNode {
66
+ const filter = this.context.createBiquadFilter();
67
+ filter.type = type;
68
+ return filter;
69
+ }
70
+
71
+
72
+ pause() {
73
+ if ('suspend' in this.context) {
74
+ this.context.suspend();
75
+ }
76
+ }
77
+
78
+ resume() {
79
+ if ('resume' in this.context) {
80
+ this.context.resume();
81
+ }
82
+ }
83
+
84
+ stopAll() {
85
+ if ('close' in this.context) {
86
+ this.context.close();
87
+ }
88
+ }
89
+
90
+ setGlobalVolume(volume: number) {
91
+ this.globalGainNode.gain.value = volume;
92
+ }
93
+
94
+ mute() {
95
+ this.prevVolume = this.globalGainNode.gain.value;
96
+ this.setGlobalVolume(0);
97
+ }
98
+
99
+ unmute() {
100
+ this.setGlobalVolume(this.prevVolume);
101
+ }
102
+
103
+ }
104
+
105
+
106
+ class FilterManager {
107
+ protected filters: BiquadFilterNode[] = [];
108
+
109
+ addFilter(filter: BiquadFilterNode): void {
110
+ this.filters.push(filter);
111
+ }
112
+
113
+ removeFilter(filter: BiquadFilterNode): void {
114
+ this.filters = this.filters.filter(f => f !== filter);
115
+ }
116
+
117
+ applyFilters(connection: any): any {
118
+ this.filters.reduce((prevConnection, filter) => {
119
+ prevConnection.connect(filter);
120
+ return filter;
121
+ }, connection);
122
+ return this.filters.length > 0 ? this.filters[this.filters.length - 1] : connection;
123
+ }
124
+ }
125
+
126
+
127
+ export class Sound extends FilterManager implements BaseSound {
128
+ buffer: IAudioBuffer;
129
+ context: AudioContext;
130
+ playbacks: Playback[] = [];
131
+ globalGainNode: GainNode;
132
+ position: number[] = [0, 0, 0];
133
+ loopCount: LoopCount = 0;
134
+
135
+ constructor(buffer: AudioBuffer, context: AudioContext, globalGainNode: IGainNode<AudioContext>) {
136
+ super();
137
+ this.buffer = buffer;
138
+ this.context = context;
139
+ this.globalGainNode = globalGainNode;
140
+ }
141
+
142
+ preplay(): Playback[] {
143
+ const source = this.context.createBufferSource();
144
+ source.buffer = this.buffer;
145
+ const gainNode = this.context.createGain();
146
+ source.connect(gainNode);
147
+ gainNode.connect(this.globalGainNode);
148
+ const playback = new Playback(source, gainNode, this.context, this.loopCount);
149
+ this.filters.forEach(filter => playback.addFilter(filter));
150
+ playback.moveTo(this.position[0], this.position[1], this.position[2]);
151
+ this.playbacks.push(playback);
152
+ return [playback];
153
+ }
154
+
155
+ play(): Playback[] {
156
+ const playback = this.preplay();
157
+ playback.forEach(p => p.source.start());
158
+ return playback;
159
+ }
160
+
161
+ stop(): void {
162
+ this.playbacks.forEach(p => p.stop());
163
+ }
164
+
165
+ pause(): void {
166
+ if ('suspend' in this.context) {
167
+ this.context.suspend();
168
+ }
169
+ }
170
+
171
+ resume(): void {
172
+ if ('resume' in this.context) {
173
+ this.context.resume();
174
+ }
175
+ }
176
+
177
+ moveTo(x: number, y: number, z: number): void {
178
+ this.position = [x, y, z];
179
+ this.playbacks.forEach(p => p.moveTo(x, y, z));
180
+ }
181
+
182
+ loop(loopCount?: LoopCount): LoopCount {
183
+ if (loopCount === undefined) {
184
+ return this.loopCount;
185
+ }
186
+ this.loopCount = loopCount;
187
+ this.playbacks.forEach(p => p.source.loop = true);
188
+ return this.loopCount;
189
+ }
190
+
191
+ addFilter(filter: BiquadFilterNode): void {
192
+ super.addFilter(filter);
193
+ this.playbacks.forEach(p => p.addFilter(filter));
194
+ }
195
+
196
+ removeFilter(filter: BiquadFilterNode): void {
197
+ super.removeFilter(filter);
198
+ this.playbacks.forEach(p => p.removeFilter(filter));
199
+ }
200
+ }
201
+
202
+
203
+ class Playback extends FilterManager implements BaseSound {
204
+ context: AudioContext;
205
+ source: AudioBufferSourceNode;
206
+ gainNode: GainNode;
207
+ panner: PannerNode;
208
+ loopCount: LoopCount = 0;
209
+ currentLoop: number = 0;
210
+ buffer: IAudioBuffer | null = null;
211
+
212
+ constructor(source: AudioBufferSourceNode, gainNode: GainNode, context: AudioContext, loopCount: LoopCount = 0) {
213
+ super();
214
+ this.loopCount = loopCount;
215
+ this.source = source;
216
+ this.buffer = source.buffer;
217
+ this.source.onended = this.handleLoop.bind(this);
218
+ this.gainNode = gainNode;
219
+ this.context = context;
220
+ this.panner = context.createPanner();
221
+ source.connect(this.panner).connect(this.gainNode);
222
+ this.refreshFilters();
223
+ source.start();
224
+ }
225
+
226
+
227
+ handleLoop(): void {
228
+ if (this.loopCount === 'infinite' || this.currentLoop < this.loopCount) {
229
+ this.currentLoop++;
230
+ this.source = this.context.createBufferSource();
231
+ this.source.buffer = this.buffer;
232
+ this.play();
233
+ }
234
+ }
235
+
236
+ play() {
237
+ this.source.start();
238
+ return [this];
239
+ }
240
+
241
+ set volume(v: number) {
242
+ this.gainNode.gain.value = v;
243
+ }
244
+
245
+ fadeIn(time: number, FfadeType: FadeType = 'linear'): Promise<void> {
246
+ return new Promise(resolve => {
247
+ // Setting the initial gain value to 0
248
+ this.gainNode.gain.setValueAtTime(0, this.context.currentTime);
249
+ switch (FfadeType) {
250
+ case 'exponential':
251
+ // Scheduling an exponential fade up
252
+ this.gainNode.gain.exponentialRampToValueAtTime(1, this.context.currentTime + time);
253
+ break;
254
+ case 'linear':
255
+ // Scheduling a linear ramp to the target gain value over the given duration
256
+ this.gainNode.gain.linearRampToValueAtTime(1, this.context.currentTime + time);
257
+ }
258
+ // Resolving the Promise after the fade-in time
259
+ setTimeout(() => resolve(), time * 1000);
260
+ });
261
+ }
262
+
263
+ fadeOut(time: number, fadeType: FadeType = 'linear'): Promise<void> {
264
+ return new Promise(resolve => {
265
+ // Storing the current gain value
266
+ const initialVolume = this.gainNode.gain.value;
267
+ switch (fadeType) {
268
+ case 'exponential':
269
+ // Scheduling an exponential fade down
270
+ this.gainNode.gain.exponentialRampToValueAtTime(0.01, this.context.currentTime + time);
271
+ break;
272
+ case 'linear':
273
+
274
+ // Scheduling a linear ramp to 0 over the given duration
275
+ this.gainNode.gain.linearRampToValueAtTime(0, this.context.currentTime + time);
276
+ }
277
+ // Resolving the Promise after the fade-out time
278
+ setTimeout(() => resolve(), time * 1000);
279
+ });
280
+ }
281
+
282
+ loop(loopCount?: LoopCount): LoopCount {
283
+ if (loopCount === undefined) {
284
+ return this.source.loop === true ? 'infinite' : 0;
285
+ }
286
+ this.source.loop = true;
287
+ this.source.loopEnd = this.source.buffer?.duration || 0;
288
+ this.source.loopStart = 0;
289
+ return this.source.loop === true ? 'infinite' : 0;
290
+ }
291
+
292
+ stop(): void {
293
+ this.source.stop();
294
+ }
295
+
296
+ pause(): void {
297
+ if ('suspend' in this.source.context) {
298
+ this.source.context.suspend();
299
+ }
300
+
301
+ }
302
+ resume(): void {
303
+ if ('resume' in this.source.context) {
304
+ this.source.context.resume();
305
+ }
306
+ }
307
+
308
+ addFilter(filter: BiquadFilterNode): void {
309
+ super.addFilter(filter);
310
+ this.refreshFilters();
311
+ }
312
+
313
+ removeFilter(filter: BiquadFilterNode): void {
314
+ super.removeFilter(filter);
315
+ this.refreshFilters();
316
+ }
317
+
318
+ moveTo(x: number, y: number, z: number): void {
319
+ this.panner.positionX.value = x;
320
+ this.panner.positionY.value = y;
321
+ this.panner.positionZ.value = z;
322
+ }
323
+
324
+ private refreshFilters(): void {
325
+ let connection = this.source;
326
+ this.source.disconnect();
327
+ connection = this.applyFilters(connection);
328
+ connection.connect(this.gainNode);
329
+ }
330
+ }
331
+
332
+
333
+ export class Group implements BaseSound {
334
+ sounds: Sound[] = [];
335
+ position: number[] = [0, 0, 0];
336
+ loopCount: LoopCount = 0;
337
+
338
+ addSound(sound: Sound): void {
339
+ this.sounds.push(sound);
340
+ }
341
+
342
+ preplay(): Playback[] {
343
+ return this.sounds.reduce<Playback[]>((playbacks, sound) => {
344
+ sound.loop(this.loopCount);
345
+ return playbacks.concat(sound.preplay());
346
+ }, []);
347
+ }
348
+
349
+ play(): Playback[] {
350
+ return this.preplay().map(playback => {
351
+ playback.play();
352
+ return playback;
353
+ });
354
+ }
355
+
356
+ stop(): void {
357
+ this.sounds.forEach(sound => sound.stop());
358
+ }
359
+
360
+ pause(): void {
361
+ this.sounds.forEach(sound => sound.pause());
362
+ }
363
+
364
+ resume(): void {
365
+ this.sounds.forEach(sound => {
366
+ if ('resume' in sound.context) {
367
+ sound.context.resume();
368
+ }
369
+ });
370
+ }
371
+
372
+ loop(loopCount?: LoopCount): LoopCount {
373
+ if (loopCount === undefined) {
374
+ return this.loopCount;
375
+ }
376
+ this.loopCount = loopCount;
377
+ this.sounds.forEach(sound => sound.loop(loopCount));
378
+ return this.loopCount;
379
+ }
380
+
381
+ addFilter(filter: BiquadFilterNode): void {
382
+ this.sounds.forEach(sound => sound.addFilter(filter));
383
+ }
384
+
385
+ removeFilter(filter: BiquadFilterNode): void {
386
+ this.sounds.forEach(sound => sound.removeFilter(filter));
387
+ }
388
+
389
+ moveTo(x: number, y: number, z: number): void {
390
+ this.position = [x, y, z];
391
+ this.sounds.forEach(sound => sound.moveTo(x, y, z));
392
+ }
393
+
394
+
395
+ }
396
+
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './cacophony';
package/tsconfig.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+ /* Projects */
5
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
6
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
7
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
8
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
9
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
10
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
11
+ /* Language and Environment */
12
+ "target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13
+ "lib": [
14
+ "ES6",
15
+ "DOM"
16
+ ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
17
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
18
+ "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
19
+ "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
+ /* Modules */
28
+ "module": "commonjs", /* Specify what module code is generated. */
29
+ "rootDir": "./src", /* Specify the root folder within your source files. */
30
+ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
40
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
41
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
42
+ // "resolveJsonModule": true, /* Enable importing .json files. */
43
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
44
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
45
+ /* JavaScript Support */
46
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
47
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
48
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
49
+ /* Emit */
50
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
51
+ "declarationMap": true, /* Create sourcemaps for d.ts files. */
52
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
53
+ "sourceMap": true, /* Create source map files for emitted JavaScript files. */
54
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
55
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
56
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
57
+ // "removeComments": true, /* Disable emitting comments. */
58
+ // "noEmit": true, /* Disable emitting files from a compilation. */
59
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
60
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
61
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
62
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
63
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
64
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
65
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
66
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
67
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
68
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
69
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
70
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
71
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
72
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
73
+ /* Interop Constraints */
74
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
75
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
76
+ "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
77
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
78
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
79
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
80
+ /* Type Checking */
81
+ "strict": true, /* Enable all strict type-checking options. */
82
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
83
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
84
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
85
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
86
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
87
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
88
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
89
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
90
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
91
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
92
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
93
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
94
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
95
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
96
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
97
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
98
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
99
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
100
+ /* Completeness */
101
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
102
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
103
+ }
104
+ }