Skip to content

Commit

Permalink
Compat for iOS <13
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed Dec 9, 2024
1 parent 97d7b3f commit b066c12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/glkote/web/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ export function is_input_focused() {

/** Try to detect iOS */
// From https://stackoverflow.com/a/58065241/2854284
export const is_iOS = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
export const is_iOS = /iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && (navigator.maxTouchPoints ?? 0) > 1)
15 changes: 10 additions & 5 deletions src/glkote/web/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
windowport_id: 'windowport',
})
metrics_calculator: Metrics
private schannels: SoundChannelManager
private schannels?: SoundChannelManager
private showing_error = false
private showing_loading = true
private transcript_recorder?: TranscriptRecorder
Expand All @@ -57,7 +57,9 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
super()

this.metrics_calculator = new Metrics(this)
this.schannels = new SoundChannelManager(this)
if (typeof AudioContext !== 'undefined') {
this.schannels = new SoundChannelManager(this)
}
this.windows = new Windows(this)
}

Expand Down Expand Up @@ -178,14 +180,17 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
}

protected capabilities(): string[] {
return [
const capabilities = [
'garglktext',
'graphics',
'graphicswin',
'hyperlinks',
'sounds',
'timer',
]
if (this.schannels) {
capabilities.push('sounds')
}
return capabilities
}

protected disable(disable: boolean) {
Expand Down Expand Up @@ -363,7 +368,7 @@ export default class WebGlkOte extends GlkOte.GlkOteBase implements GlkOte.GlkOt
}

protected update_schannels(schannels: protocol.SoundChannelUpdate[]) {
this.schannels.update(schannels)
this.schannels?.update(schannels)
}

protected update_windows(windows: protocol.WindowUpdate[]) {
Expand Down

0 comments on commit b066c12

Please sign in to comment.