diff --git a/src/API/API.ts b/src/API/API.ts index 960cc7a..4cd761b 100644 --- a/src/API/API.ts +++ b/src/API/API.ts @@ -395,7 +395,7 @@ export class UserAPI { this.almostAlways = Probability.almostAlways(this); this.always = Probability.always(); this.dice = Probability.dice(this); - this.osc = OSC.osc(this.app); + this.osc = OSC.osc(); this.getOSC = OSC.getOSC(); this.gif = Canvas.gif(this.app); this.scope = Canvas.scope(this.app); diff --git a/src/API/Script.ts b/src/API/Script.ts index d332d7d..c1d2dee 100644 --- a/src/API/Script.ts +++ b/src/API/Script.ts @@ -26,15 +26,15 @@ export const delete_script = (app: Editor) => (script: number): void => { }; export const copy_script = (app: Editor) => (from: number, to: number): void => { + //@ts-ignore app.universes[app.selected_universe].locals[to] = { ...app.universes[app.selected_universe]!.locals[from], }; }; export const copy_universe = (app: Editor) => (from: string, to: string): void => { - app.universes[to] = { - ...app.universes[from], - }; + //@ts-ignore + app.universes[to] = { ...app.universes[from], }; }; export const delete_universe = (app: Editor) => (universe: string): void => { diff --git a/src/Editor/EditorSetup.ts b/src/Editor/EditorSetup.ts index 4078203..c6d706a 100644 --- a/src/Editor/EditorSetup.ts +++ b/src/Editor/EditorSetup.ts @@ -65,29 +65,29 @@ export const getCodeMirrorTheme = (theme: { [key: string]: string }): Extension selection_background = theme["selection_background"]; const toposTheme = EditorView.theme({ "&": { - color: background, + color: background || "", backgroundColor: "transparent", fontSize: "24px", fontFamily: "IBM Plex Mono", }, ".cm-content": { - caretColor: cursor, + caretColor: cursor || '', fontFamily: "IBM Plex Mono", }, ".cm-line": { color: `${brightwhite}`, }, ".cm-cursor, .cm-dropCursor": { - borderLeftColor: cursor, + borderLeftColor: cursor || 'white', }, "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { - backgroundColor: brightwhite, + backgroundColor: brightwhite || 'black', border: `1px solid ${brightwhite}`, }, ".cm-panels": { - backgroundColor: selection_background, - color: red, + backgroundColor: selection_background || 'gray', + color: red || '', }, ".cm-panels.cm-panels-top": { borderBottom: "2px solid black" }, ".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" }, @@ -96,30 +96,30 @@ export const getCodeMirrorTheme = (theme: { [key: string]: string }): Extension outline: `1px solid ${magenta}`, }, ".cm-searchMatch.cm-searchMatch-selected": { - backgroundColor: red, + backgroundColor: red || '', }, ".cm-activeLine": { - backgroundColor: `rgba(${(parseInt(selection_background.slice(1, 3), 16))}, ${(parseInt(selection_background.slice(3, 5), 16))}, ${(parseInt(selection_background.slice(5, 7), 16))}, 0.25)`, + backgroundColor: `rgba(${(parseInt(selection_background!.slice(1, 3), 16))}, ${(parseInt(selection_background!.slice(3, 5), 16))}, ${(parseInt(selection_background!.slice(5, 7), 16))}, 0.25)`, }, ".cm-selectionMatch": { - backgroundColor: `rgba(${(parseInt(selection_background.slice(1, 3), 16))}, ${(parseInt(selection_background.slice(3, 5), 16))}, ${(parseInt(selection_background.slice(5, 7), 16))}, 0.25)`, + backgroundColor: `rgba(${(parseInt(selection_background!.slice(1, 3), 16))}, ${(parseInt(selection_background!.slice(3, 5), 16))}, ${(parseInt(selection_background!.slice(5, 7), 16))}, 0.25)`, outline: `1px solid ${brightwhite}`, }, "&.cm-focused .cm-matchingBracket": { - color: `rgba(${(parseInt(selection_background.slice(1, 3), 16))}, ${(parseInt(selection_background.slice(3, 5), 16))}, ${(parseInt(selection_background.slice(5, 7), 16))}, 0.25)`, + color: `rgba(${(parseInt(selection_background!.slice(1, 3), 16))}, ${(parseInt(selection_background!.slice(3, 5), 16))}, ${(parseInt(selection_background!.slice(5, 7), 16))}, 0.25)`, }, "&.cm-focused .cm-nonmatchingBracket": { - color: yellow, + color: yellow || '', }, ".cm-gutters": { //backgroundColor: base00, backgroundColor: "transparent", - color: foreground, + color: foreground || '', }, ".cm-activeLineGutter": { - backgroundColor: selection_background, - color: selection_foreground, + backgroundColor: selection_background || '', + color: selection_foreground || '', }, ".cm-foldPlaceholder": { @@ -128,17 +128,17 @@ export const getCodeMirrorTheme = (theme: { [key: string]: string }): Extension }, ".cm-tooltip": { border: "none", - backgroundColor: background, + backgroundColor: background || '', }, ".cm-tooltip .cm-tooltip-arrow:before": {}, ".cm-tooltip .cm-tooltip-arrow:after": { - borderTopColor: background, - borderBottomColor: background, + borderTopColor: background || '', + borderBottomColor: background || '', }, ".cm-tooltip-autocomplete": { "& > ul > li[aria-selected]": { - backgroundColor: background, - color: brightwhite, + backgroundColor: background || '', + color: brightwhite || '', }, }, }, @@ -343,7 +343,7 @@ export const installEditor = (app: Editor) => { ), keymap.of([indentWithTab]), ], - doc: app.universes[app.selected_universe].global.candidate, + doc: app.universes[app.selected_universe]!.global.candidate, }); app.view = new EditorView({ parent: document.getElementById("editor") as HTMLElement, diff --git a/src/IO/MidiConnection.ts b/src/IO/MidiConnection.ts index 3b06bea..827ef87 100644 --- a/src/IO/MidiConnection.ts +++ b/src/IO/MidiConnection.ts @@ -1,4 +1,5 @@ import { UserAPI } from "../API/API"; +import { MidiEvent } from "../Classes/MidiEvent"; import { AppSettings } from "../Editor/FileManagement"; export type MidiNoteEvent = { @@ -297,36 +298,37 @@ export class MidiConnection { const input = this.midiInputs[inputIndex]; if (input && !input.onmidimessage) { input.onmidimessage = (event: Event) => { - const message = event as MIDIMessageEvent; + // @ts-ignore + const message: MidiEvent = event as MIDIMessageEvent; /* MIDI CLOCK */ if (input.name === this.settings.midi_clock_input) { - if (message.data![0] === 0xf8) { + if (message['data'][0] === 0xf8) { if (this.skipOnError > 0) { this.skipOnError -= 1; } else { this.onMidiClock(event.timeStamp); } - } else if (message.data![0] === 0xfa) { + } else if (message["data"]![0] === 0xfa) { console.log("MIDI start received"); this.api.stop(); this.api.play(); - } else if (message.data![0] === 0xfc) { + } else if (message["data"]![0] === 0xfc) { console.log("MIDI stop received"); this.api.pause(); - } else if (message.data![0] === 0xfb) { + } else if (message["data"]![0] === 0xfb) { console.log("MIDI continue received"); this.api.play(); - } else if (message.data![0] === 0xfe) { + } else if (message["data"]![0] === 0xfe) { console.log("MIDI active sensing received"); } } /* DEFAULT MIDI INPUT */ if (input.name === this.settings.default_midi_input) { // If message is one of note ons - if (message.data![0] >= 0x90 && message.data![0] <= 0x9f) { - const channel = message.data![0] - 0x90 + 1; - const note = message.data![1]; - const velocity = message.data![2]; + if (message["data"][0] >= 0x90 && message["data"]![0] <= 0x9f) { + const channel = message["data"]![0] - 0x90 + 1; + const note = message["data"]![1]; + const velocity = message["data"]![2]; this.lastNote = { note, @@ -367,24 +369,24 @@ export class MidiConnection { } // If note off - if (message.data![0] >= 0x80 && message.data![0] <= 0x8f) { - const channel = message.data![0] - 0x80 + 1; - const note = message.data![1]; + if (message["data"]![0] >= 0x80 && message["data"]![0] <= 0x8f) { + const channel = message["data"]![0] - 0x80 + 1; + const note = message["data"]![1]; this.removeFromActiveNotes(note, channel); } // If message is one of CCs - if (message.data![0] >= 0xb0 && message.data![0] <= 0xbf) { - const channel = message.data![0] - 0xb0 + 1; - const control = message.data![1]; - const value = message.data![2]; + if (message["data"]![0] >= 0xb0 && message["data"]![0] <= 0xbf) { + const channel = message["data"]![0] - 0xb0 + 1; + const control = message["data"]![1]; + const value = message["data"]![2]; this.lastCC[control] = value; if (this.lastCCInChannel[channel]) { - this.lastCCInChannel[channel][control] = value; + this.lastCCInChannel[channel]![control] = value; } else { this.lastCCInChannel[channel] = {}; - this.lastCCInChannel[channel][control] = value; + this.lastCCInChannel[channel]![control] = value; } //console.log(`CC: ${control} VALUE: ${value} CHANNEL: ${channel}`); diff --git a/src/classes/AbstractEvents.ts b/src/classes/AbstractEvents.ts index 438672d..706c669 100644 --- a/src/classes/AbstractEvents.ts +++ b/src/classes/AbstractEvents.ts @@ -211,12 +211,12 @@ export class AbstractEvent { * @param func - The function to be applied to the Event * @returns The transformed Event */ - return this.modify(func).update(); + return this.modify(func)["update"](); }; mod = (value: number): AbstractEvent => { - this.values.originalPitch = safeMod(this.values.originalPitch, value); - return this.update(); + this.values["originalPitch"] = safeMod(this.values["originalPitch"], value); + return this["update"](); } noteLength = ( @@ -230,17 +230,18 @@ export class AbstractEvent { value = Array.isArray(value) ? value.concat(kwargs) : [value, ...kwargs]; } if (Array.isArray(value)) { - this.values.dur = value.map((v) => + this.values["dur"] = value.map((v) => this.app.clock.convertPulseToSecond(v * 4 * this.app.clock.ppqn), ); } else { - this.values.dur = this.app.clock.convertPulseToSecond( + this.values["dur"] = this.app.clock.convertPulseToSecond( value * 4 * this.app.clock.ppqn, ); } - if(this.current) { - value = Array.isArray(value) ? value[this.index%value.length] : value; - this.current.duration = value; + if(this["current"]) { + // @ts-ignore + value = Array.isArray(value) ? value[this["index"]%value.length] : value; + this["current"].duration = value; } return this; }; @@ -253,7 +254,9 @@ export class AbstractEvent { const n: number[] = []; sound.forEach((str) => { const parts = (str as string).split(":"); - s.push(parts[0]); + if (parts[0] !== undefined) { + s.push(parts[0]); + } if (parts[1]) { n.push(parseInt(parts[1])); } @@ -273,7 +276,7 @@ export class AbstractEvent { if (sound.includes(":")) { const vals = sound.split(":"); const s = vals[0]; - const n = parseInt(vals[1]); + const n = parseInt(vals[1] ?? ''); return { s, n, @@ -472,7 +475,7 @@ export abstract class AudibleEvent extends AbstractEvent { return this; } - public clear = () => { + public override clear = () => { this.app.api.clear(); return this; } @@ -524,8 +527,8 @@ export abstract class AudibleEvent extends AbstractEvent { runChain = (): this => { // chainAll is defined using all() in the API - if("chainAll" in this && typeof this.chainAll === "function") { - this.values = this.chainAll().values; + if("chainAll" in this && typeof this["chainAll"] === "function") { + this.values = this["chainAll"]().values; } return this; } diff --git a/src/clock/Clock.ts b/src/clock/Clock.ts index c25572e..51367e6 100644 --- a/src/clock/Clock.ts +++ b/src/clock/Clock.ts @@ -1,3 +1,4 @@ +// @ts-ignore import { ClockNode } from "./ClockNode"; import TransportProcessor from "./ClockProcessor?worker&url"; import { Editor } from "../main"; diff --git a/tsconfig.json b/tsconfig.json index f23b67b..b184812 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,6 @@ "DOM.Iterable" ], "skipLibCheck": true, - // Strict mode (9) "strict": true, "alwaysStrict": true, "noImplicitAny": true, @@ -32,16 +31,19 @@ "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, + "maxNodeModuleJsDepth": 0, "noEmit": true, - // Others (5) + // Others "noUncheckedIndexedAccess": true, "noPropertyAccessFromIndexSignature": true, "noFallthroughCasesInSwitch": true, - "exactOptionalPropertyTypes": true, "forceConsistentCasingInFileNames": true }, "include": [ - "src", + "src/**/*", "../definitions/" + ], + "exclude": [ + "node_modules/**/*", ] }