Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions editor/Change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ export class ChangeSequence extends UndoableChange {
this._didSomething();
}

protected _doForwards(): void {
protected override _doForwards(): void {
for (let i: number = 0; i < this._changes.length; i++) {
this._changes[i].redo();
}
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
for (let i: number = this._changes.length-1; i >= 0 ; i--) {
this._changes[i].undo();
}
Expand Down
12 changes: 6 additions & 6 deletions editor/EasyPointers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1485,13 +1485,13 @@ export function getElementDimensions(element: HTMLElement, elementBox: `${Elemen
switch (elementBox) {
case ElementBox.borderBox: {
return {width: element.offsetWidth, height: element.offsetHeight};
} break;
}
case ElementBox.insideBorder: {
return {
width: element.offsetWidth - parseFloat(styles.borderLeft) - parseFloat(styles.borderRight),
height: element.offsetHeight - parseFloat(styles.borderTop) - parseFloat(styles.borderBottom),
};
} break;
}
case ElementBox.paddingBox: {
if (styles.display == "inline") {
// For inline elements, the reported scrollWidth and scrollHeight are always zero even if there's a border.
Expand All @@ -1502,7 +1502,7 @@ export function getElementDimensions(element: HTMLElement, elementBox: `${Elemen
} else {
return {width: element.scrollWidth, height: element.scrollHeight};
}
} break;
}
case ElementBox.contentBox: {
if (styles.display == "inline") {
return {
Expand All @@ -1515,7 +1515,7 @@ export function getElementDimensions(element: HTMLElement, elementBox: `${Elemen
height: element.scrollHeight - parseFloat(styles.paddingTop) - parseFloat(styles.paddingBottom),
};
}
} break;
}
case ElementBox.imagePixels: {
if (element instanceof HTMLImageElement) {
return {width: element.naturalWidth, height: element.naturalHeight};
Expand All @@ -1524,10 +1524,10 @@ export function getElementDimensions(element: HTMLElement, elementBox: `${Elemen
} else {
throw new Error("EasyPointers: Unsupported element type for image box: " + element.tagName);
}
} break;
}
case ElementBox.svgTransform: {
throw new Error("EasyPointers: svgTransform unsupported for HTML elements.");
}// break; // unreachable code because of the throw.
}
default: throw new Error("EasyPointers: Unrecognized element box: " + elementBox);
}
}
Expand Down
10 changes: 5 additions & 5 deletions editor/MidiInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import {AnalogousDrum, analogousDrumMap, MidiEventType} from "./Midi.js";

declare global {
interface Navigator {
requestMIDIAccess?(): Promise<any>;
// Defined in latest TypeScript typings
// requestMIDIAccess?(): Promise<any>;
}
}

// Maybe these can be moved to standard lib typings as well, will have to look into it further.

interface MIDIInput extends EventTarget {
id: string;
type: "input" | "output";
state: "disconnected" | "connected";
}

interface MIDIConnectionEvent {
port: MIDIInput;
}

interface MIDIMessageEvent {
data: [type: number, key: number, velocity: number];
target: MIDIInput;
Expand Down Expand Up @@ -61,6 +60,7 @@ export class MidiInputHandler {
}

private _handleStateChange = (event: MIDIConnectionEvent) => {
if (!event.port) return;
if (event.port.type !== "input") return;

switch (event.port.state) {
Expand Down
2 changes: 1 addition & 1 deletion editor/PatternEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class PatternEditor {
/ minDivision) * minDivision;

if (this._pattern != null) {
const cursorPartForMatching: Number = Math.max(0, Math.min(partsPerPattern - 1, this._cursor.exactPart));
const cursorPartForMatching: number = Math.max(0, Math.min(partsPerPattern - 1, this._cursor.exactPart));
for (const note of this._pattern.notes) {
if (note.end <= cursorPartForMatching) {
this._cursor.prevNote = note;
Expand Down
42 changes: 21 additions & 21 deletions editor/changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class ChangePins extends UndoableChange {
this._didSomething();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._note.pins = this._newPins;
this._note.pitches = this._newPitches;
this._note.start = this._newStart;
Expand All @@ -361,7 +361,7 @@ class ChangePins extends UndoableChange {
if (this._doc != null) this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._note.pins = this._oldPins;
this._note.pitches = this._oldPitches;
this._note.start = this._oldStart;
Expand Down Expand Up @@ -1304,7 +1304,7 @@ class ChangeInstrumentSlider extends Change {
this._instrument = this._doc.song.channels[this._doc.channel].instruments[this._doc.getCurrentInstrument()];
}

public commit(): void {
public override commit(): void {
if (!this.isNoop()) {
this._instrument.preset = this._instrument.type;
this._doc.notifier.changed();
Expand Down Expand Up @@ -1470,7 +1470,7 @@ export class ChangeFilterAddPoint extends UndoableChange {
this.redo();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._filterSettings.controlPoints.splice(this._index, 0, this._point);
this._filterSettings.controlPointCount++;
this._filterSettings.controlPoints.length = this._filterSettings.controlPointCount;
Expand All @@ -1482,7 +1482,7 @@ export class ChangeFilterAddPoint extends UndoableChange {
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._filterSettings.controlPoints.splice(this._index, 1);
this._filterSettings.controlPointCount--;
this._filterSettings.controlPoints.length = this._filterSettings.controlPointCount;
Expand Down Expand Up @@ -1520,14 +1520,14 @@ export class ChangeFilterMovePoint extends UndoableChange {
this.redo();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._point.freq = this._newFreq;
this._point.gain = this._newGain;
this._instrument.preset = this._instrumentNextPreset;
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._point.freq = this._oldFreq;
this._point.gain = this._oldGain;
this._instrument.preset = this._instrumentPrevPreset;
Expand Down Expand Up @@ -1558,14 +1558,14 @@ export class ChangeFadeInOut extends UndoableChange {
this.redo();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._instrument.fadeIn = this._newFadeIn;
this._instrument.fadeOut = this._newFadeOut;
this._instrument.preset = this._instrumentNextPreset;
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._instrument.fadeIn = this._oldFadeIn;
this._instrument.fadeOut = this._oldFadeOut;
this._instrument.preset = this._instrumentPrevPreset;
Expand Down Expand Up @@ -1761,12 +1761,12 @@ export class ChangePitchAdded extends UndoableChange {
this.redo();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._note.pitches.splice(this._index, 0, this._pitch);
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._note.pitches.splice(this._index, 1);
this._doc.notifier.changed();
}
Expand Down Expand Up @@ -1946,7 +1946,7 @@ export class ChangeEnsurePatternExists extends UndoableChange {
this._doForwards();
}

protected _doForwards(): void {
protected override _doForwards(): void {
const song: Song = this._doc.song;
for (let j: number = song.patternsPerChannel; j < this._newPatternCount; j++) {
for (let i: number = 0; i < song.getChannelCount(); i++) {
Expand All @@ -1962,7 +1962,7 @@ export class ChangeEnsurePatternExists extends UndoableChange {
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
const song: Song = this._doc.song;
const pattern: Pattern = song.channels[this._channelIndex].patterns[this._patternIndex - 1];
if (this._patternOldNotes != null) pattern.notes = this._patternOldNotes;
Expand Down Expand Up @@ -2597,12 +2597,12 @@ export class ChangeNoteAdded extends UndoableChange {
this.redo();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._pattern.notes.splice(this._index, 0, this._note);
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._pattern.notes.splice(this._index, 1);
this._doc.notifier.changed();
}
Expand Down Expand Up @@ -2831,13 +2831,13 @@ class ChangeTransposeNote extends UndoableChange {
this._didSomething();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._note.pins = this._newPins;
this._note.pitches = this._newPitches;
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._note.pins = this._oldPins;
this._note.pitches = this._oldPitches;
this._doc.notifier.changed();
Expand Down Expand Up @@ -2893,14 +2893,14 @@ export class ChangePatternSelection extends UndoableChange {
this._didSomething();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._doc.selection.patternSelectionStart = this._newStart;
this._doc.selection.patternSelectionEnd = this._newEnd;
this._doc.selection.patternSelectionActive = this._newActive;
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._doc.selection.patternSelectionStart = this._oldStart;
this._doc.selection.patternSelectionEnd = this._oldEnd;
this._doc.selection.patternSelectionActive = this._oldActive;
Expand Down Expand Up @@ -3131,12 +3131,12 @@ export class ChangeSizeBend extends UndoableChange {
this._didSomething();
}

protected _doForwards(): void {
protected override _doForwards(): void {
this._note.pins = this._newPins;
this._doc.notifier.changed();
}

protected _doBackwards(): void {
protected override _doBackwards(): void {
this._note.pins = this._oldPins;
this._doc.notifier.changed();
}
Expand Down
4 changes: 2 additions & 2 deletions editor/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) John Nesky and contributing authors, distributed under the MIT license, see accompanying the LICENSE.md file.

export {Dictionary, DictionaryArray, EnvelopeType, InstrumentType, Transition, Chord, Envelope, Config} from "../synth/SynthConfig.js";
export {type Dictionary, type DictionaryArray, EnvelopeType, InstrumentType, type Transition, type Chord, type Envelope, Config} from "../synth/SynthConfig.js";
export {EditorConfig} from "./EditorConfig.js";
export {ColorConfig} from "./ColorConfig.js";
import "./style.js"; // Import for the side effects, there's no exports.
export {SongEditor} from "./SongEditor.js";
export {NotePin, Note, Pattern, Instrument, Channel, Song, Synth} from "../synth/synth.js";
export {type NotePin, Note, Pattern, Instrument, Channel, Song, Synth} from "../synth/synth.js";
export {SongDocument} from "./SongDocument.js";
export {ExportPrompt} from "./ExportPrompt.js";
export {ChangePreset} from "./changes.js";
Expand Down
2 changes: 1 addition & 1 deletion player/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,4 +588,4 @@ renderZoomIcon();
renderPlayButton();

// When compiling synth.ts as a standalone module named "beepbox", expose these classes as members to JavaScript:
export {Dictionary, DictionaryArray, EnvelopeType, InstrumentType, Transition, Chord, Envelope, Config, NotePin, Note, Pattern, Instrument, Channel, Synth};
export {type Dictionary, type DictionaryArray, EnvelopeType, InstrumentType, type Transition, type Chord, type Envelope, Config, type NotePin, Note, Pattern, Instrument, Channel, Synth};
12 changes: 6 additions & 6 deletions synth/synth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,7 @@ export class Song {
} break;
default: {
throw new Error("Unrecognized song tag code " + String.fromCharCode(command) + " at index " + (charIndex - 1));
} break;
}
}
}

Expand Down Expand Up @@ -7801,14 +7801,14 @@ export class Synth {

// When compiling synth.ts as a standalone module named "beepbox", expose these imported classes as members to JavaScript:
export {
Dictionary,
DictionaryArray,
type Dictionary,
type DictionaryArray,
FilterType,
EnvelopeType,
InstrumentType,
Transition,
Chord,
Envelope,
type Transition,
type Chord,
type Envelope,
Config,
fastFourierTransform,
forwardRealFourierTransform,
Expand Down
18 changes: 18 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "ESNext",
"isolatedModules": true,
"noEmit": true,
"skipLibCheck": true, // temp
"strict": true,
"strictPropertyInitialization": false, // temp
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
// "noUncheckedIndexedAccess": true, // needs oversight to enable
"allowUnreachableCode": false,
"noUnusedLocals": true,
"allowUnusedLabels": false,
// "noUnusedParameters": true // needs oversight to enable
}
}