From b7d38af0d3e17b3b0ab6c0a602ebcf691f713233 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sun, 6 Aug 2023 10:31:47 +0200 Subject: [PATCH] less warnings when building --- src/Clock.ts | 4 +++- src/Evaluator.ts | 2 +- src/TransportNode.ts | 12 ++++-------- src/main.ts | 1 + 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Clock.ts b/src/Clock.ts index 2a688ef..c1384e2 100644 --- a/src/Clock.ts +++ b/src/Clock.ts @@ -33,7 +33,7 @@ export class Clock { */ ctx: AudioContext - transportNode: TransportNode + transportNode: TransportNode | null bpm: number time_signature: number[] time_position: TimePosition @@ -41,6 +41,7 @@ export class Clock { tick: number constructor(public app: Editor, ctx: AudioContext) { + this.transportNode = null; this.ctx = ctx; this.tick = 0; this.time_position = { bar: 0, beat: 0, pulse: 0 } @@ -83,6 +84,7 @@ export class Clock { /** * Starts the TransportNode (starts the clock). */ + // @ts-ignore if (this.transportNode?.state === 'running') { console.log('Already started') } else { diff --git a/src/Evaluator.ts b/src/Evaluator.ts index dacf6e7..d43dfbc 100644 --- a/src/Evaluator.ts +++ b/src/Evaluator.ts @@ -41,7 +41,7 @@ export const tryEvaluate = async ( timeout = 5000 ): Promise => { try { - code.evaluations++; + code.evaluations!++; const isCodeValid = await Promise.race([tryCatchWrapper( application, `let i = ${code.evaluations};` + code.candidate, diff --git a/src/TransportNode.ts b/src/TransportNode.ts index 511454a..3aea5de 100644 --- a/src/TransportNode.ts +++ b/src/TransportNode.ts @@ -1,6 +1,6 @@ -import { evaluate, tryEvaluate, evaluateCommand } from "./Evaluator"; +import { tryEvaluate } from "./Evaluator"; import { Editor } from './main'; -const zeroPad = (num, places) => String(num).padStart(places, '0') +const zeroPad = (num: number, places: any) => String(num).padStart(places, '0') export class TransportNode extends AudioWorkletNode { @@ -16,7 +16,6 @@ export class TransportNode extends AudioWorkletNode { elapsedTime: number|undefined prevCurrentTime: number - constructor(context: BaseAudioContext, options: AudioWorkletNodeOptions, application: Editor) { super(context, "transport", options); this.app = application @@ -42,14 +41,11 @@ export class TransportNode extends AudioWorkletNode { /** @type {(this: MessagePort, ev: MessageEvent) => any} */ handleMessage = (message: MessageEvent) => { - if (message.data && message.data.type === "ping") { - const delay = performance.now() - message.data.t; - // console.log(delay); - } else if (message.data && message.data.type === "bang") { + if (message.data && message.data.type === "bang") { if (this.startTime === undefined) { this.startTime = message.data.currentTime; } - this.elapsedTime = message.data.currentTime - this.startTime; + this.elapsedTime = message.data.currentTime - this.startTime!; this.prevCurrentTime = message.data.currentTime; let { futureTimeStamp, timeToNextPulse, nextPulsePosition } = this.convertTimeToNextBarsBeats(this.elapsedTime); diff --git a/src/main.ts b/src/main.ts index a6dc478..95c1fbb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -726,6 +726,7 @@ window.addEventListener('mousemove', reportMouseCoordinates); // When the user leaves the page, all the universes should be saved in the localStorage window.addEventListener("beforeunload", () => { + // @ts-ignore event.preventDefault(); // Iterate over all local files and set the candidate to the committed app.currentFile().candidate = app.view.state.doc.toString();