Skip to content

Commit

Permalink
clear out some annotations by not confusing our old ts compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
jwunderl committed Jun 30, 2023
1 parent a0bcbbe commit 751f2f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
24 changes: 16 additions & 8 deletions libs/mixer/sim/music.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,29 @@ namespace pxsim.music {
}

export function _sequencerState(id: number): string {
return lookupSequencer(id)?.state();
const seq = lookupSequencer(id);
return seq && seq.state();
}

export function _sequencerCurrentTick(id: number): number {
return lookupSequencer(id)?.currentTick();
const seq = lookupSequencer(id);
return seq && seq.currentTick();
}

export function _sequencerPlaySong(id: number, song: RefBuffer, loop: boolean): void {
const decoded = decodeSong(song.data);
lookupSequencer(id)?.start(decoded, loop);
const seq = lookupSequencer(id);
seq && seq.start(decoded, loop);
}

export function _sequencerStop(id: number): void {
lookupSequencer(id)?.stop();
const seq = lookupSequencer(id);
seq && seq.stop();
}

export function _sequencerSetVolume(id: number, volume: number): void {
lookupSequencer(id)?.setVolume(volume);
const seq = lookupSequencer(id);
seq && seq.setVolume(volume);
}

export function _sequencerSetVolumeForAll(volume: number): void {
Expand All @@ -98,15 +103,18 @@ namespace pxsim.music {
}

export function _sequencerSetTrackVolume(id: number, trackIndex: number, volume: number): void {
lookupSequencer(id)?.setTrackVolume(trackIndex, volume);
const seq = lookupSequencer(id);
seq && seq.setTrackVolume(trackIndex, volume);
}

export function _sequencerSetDrumTrackVolume(id: number, trackIndex: number, drumIndex: number, volume: number): void {
lookupSequencer(id)?.setDrumTrackVolume(trackIndex, drumIndex, volume);
const seq = lookupSequencer(id);
seq && seq.setDrumTrackVolume(trackIndex, drumIndex, volume);
}

export function _sequencerDispose(id: number) {
lookupSequencer(id)?.dispose();
const seq = lookupSequencer(id);
seq.dispose();
sequencers = sequencers.filter(s => s.id !== id);
}

Expand Down
11 changes: 9 additions & 2 deletions libs/wifi---esp32/sim/wifisockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ namespace pxsim._wifi {
const WIFI_ID = 1234

export function _allowed() {
const bid = board()?.runOptions?.boardDefinition?.id
const b = board();
const bid = b
&& b.runOptions
&& b.runOptions.boardDefinition
&& b.runOptions.boardDefinition.id;
return /esp32|-s2/.test(bid)
}

Expand Down Expand Up @@ -295,7 +299,10 @@ namespace pxsim.crypto {
concat.set(b, len)
len += b.length
}
const r = window?.crypto?.subtle?.digest("SHA-256", concat)
const r = window
&& window.crypto
&& window.crypto.subtle
&& window.crypto.subtle.digest("SHA-256", concat);
if (r)
return r.then(buf => new RefBuffer(new Uint8Array(buf)))
else
Expand Down

0 comments on commit 751f2f1

Please sign in to comment.