Skip to content
Merged
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
24 changes: 21 additions & 3 deletions src/NotificationAPI/Notification.res
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
open NotificationTypes

type t = notification = {...notification}

type notificationDirection = NotificationTypes.notificationDirection
type notificationPermission = NotificationTypes.notificationPermission
type notificationAction = NotificationTypes.notificationAction = {
...NotificationTypes.notificationAction,
}
type notificationOptions = NotificationTypes.notificationOptions = {
...NotificationTypes.notificationOptions,
}
type getNotificationOptions = NotificationTypes.getNotificationOptions = {
...NotificationTypes.getNotificationOptions,
}
type notificationPermissionCallback = NotificationTypes.notificationPermissionCallback
type notificationEvent = NotificationTypes.notificationEvent = {
...NotificationTypes.notificationEvent,
}

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Notification)
*/
@new
external make: (~title: string, ~options: notificationOptions=?) => notification = "Notification"
external make: (~title: string, ~options: notificationOptions=?) => t = "Notification"

include EventTarget.Impl({type t = notification})
include EventTarget.Impl({type t = t})

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Notification/requestPermission_static)
Expand All @@ -20,7 +38,7 @@ external requestPermission: (
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Notification/close)
*/
@send
external close: notification => unit = "close"
external close: t => unit = "close"

/**
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission_static)
Expand Down
5 changes: 5 additions & 0 deletions src/PictureInPicture.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
open PictureInPictureTypes

type t = pictureInPictureWindow = {...pictureInPictureWindow}

include EventTarget.Impl({type t = t})
25 changes: 16 additions & 9 deletions src/WebAudioAPI/AudioContext.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,62 @@ open WebAudioTypes
open DOMTypes
open MediaCaptureAndStreamsTypes

include BaseAudioContext.Impl({type t = audioContext})
type t = audioContext = {...audioContext}
type baseAudioContext = WebAudioTypes.baseAudioContext = {...WebAudioTypes.baseAudioContext}
type audioContextOptions = WebAudioTypes.audioContextOptions = {
...WebAudioTypes.audioContextOptions,
}
type audioTimestamp = WebAudioTypes.audioTimestamp = {...WebAudioTypes.audioTimestamp}

include BaseAudioContext.Impl({type t = t})

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext)
*/
@new
external make: (~contextOptions: audioContextOptions=?) => audioContext = "AudioContext"
external make: (~contextOptions: audioContextOptions=?) => t = "AudioContext"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext/getOutputTimestamp)
*/
@send
external getOutputTimestamp: audioContext => audioTimestamp = "getOutputTimestamp"
external getOutputTimestamp: t => audioTimestamp = "getOutputTimestamp"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext/resume)
*/
@send
external resume: audioContext => promise<unit> = "resume"
external resume: t => promise<unit> = "resume"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext/suspend)
*/
@send
external suspend: audioContext => promise<unit> = "suspend"
external suspend: t => promise<unit> = "suspend"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext/close)
*/
@send
external close: audioContext => promise<unit> = "close"
external close: t => promise<unit> = "close"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext/createMediaElementSource)
*/
@send
external createMediaElementSource: (audioContext, htmlMediaElement) => mediaElementAudioSourceNode =
external createMediaElementSource: (t, htmlMediaElement) => mediaElementAudioSourceNode =
"createMediaElementSource"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext/createMediaStreamSource)
*/
@send
external createMediaStreamSource: (audioContext, mediaStream) => mediaStreamAudioSourceNode =
external createMediaStreamSource: (t, mediaStream) => mediaStreamAudioSourceNode =
"createMediaStreamSource"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/AudioContext/createMediaStreamDestination)
*/
@send
external createMediaStreamDestination: audioContext => mediaStreamAudioDestinationNode =
external createMediaStreamDestination: t => mediaStreamAudioDestinationNode =
"createMediaStreamDestination"
4 changes: 3 additions & 1 deletion src/WebAudioAPI/AudioDestinationNode.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open WebAudioTypes

include AudioNode.Impl({type t = audioDestinationNode})
type t = audioDestinationNode = {...audioDestinationNode}

include AudioNode.Impl({type t = t})
4 changes: 4 additions & 0 deletions src/WebAudioAPI/AudioNode.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open WebAudioTypes

type t = audioNode = {...audioNode}

module Impl = (
T: {
type t
Expand Down Expand Up @@ -65,3 +67,5 @@ module Impl = (
@send
external disconnect7: (T.t, ~destinationParam: audioParam, ~output: int) => unit = "disconnect"
}

include Impl({type t = t})
4 changes: 3 additions & 1 deletion src/WebAudioAPI/AudioScheduledSourceNode.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
open WebAudioTypes

type t = audioScheduledSourceNode = {...audioScheduledSourceNode}

module Impl = (
T: {
type t
Expand All @@ -22,4 +24,4 @@ module Impl = (
external stop: (T.t, ~when_: float=?) => unit = "stop"
}

include Impl({type t = audioScheduledSourceNode})
include Impl({type t = t})
7 changes: 5 additions & 2 deletions src/WebAudioAPI/GainNode.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
open WebAudioTypes

include AudioNode.Impl({type t = gainNode})
type t = gainNode = {...gainNode}
type gainOptions = WebAudioTypes.gainOptions = {...WebAudioTypes.gainOptions}

include AudioNode.Impl({type t = t})

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/GainNode)
*/
@new
external make: (~context: baseAudioContext, ~options: gainOptions=?) => gainNode = "GainNode"
external make: (~context: baseAudioContext, ~options: gainOptions=?) => t = "GainNode"
12 changes: 8 additions & 4 deletions src/WebAudioAPI/OscillatorNode.res
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
open WebAudioTypes

include AudioScheduledSourceNode.Impl({type t = oscillatorNode})
type t = oscillatorNode = {...oscillatorNode}
type oscillatorOptions = WebAudioTypes.oscillatorOptions = {...WebAudioTypes.oscillatorOptions}
type oscillatorType = WebAudioTypes.oscillatorType
type periodicWave = WebAudioTypes.periodicWave = {...WebAudioTypes.periodicWave}

include AudioScheduledSourceNode.Impl({type t = t})

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/OscillatorNode)
*/
@new
external make: (~context: baseAudioContext, ~options: oscillatorOptions=?) => oscillatorNode =
"OscillatorNode"
external make: (~context: baseAudioContext, ~options: oscillatorOptions=?) => t = "OscillatorNode"

/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/OscillatorNode/setPeriodicWave)
*/
@send
external setPeriodicWave: (oscillatorNode, periodicWave) => unit = "setPeriodicWave"
external setPeriodicWave: (t, periodicWave) => unit = "setPeriodicWave"
4 changes: 4 additions & 0 deletions src/WebMIDI.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
open WebMIDITypes

type t = midiAccess = {...midiAccess}
type midiOptions = WebMIDITypes.midiOptions = {...WebMIDITypes.midiOptions}
6 changes: 3 additions & 3 deletions tests/NotificationsAPI/Notification__test.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
open WebAPI.NotificationTypes
let current: Notification.notificationPermission = Notification.permission

let current = Notification.permission
let _notification: Notification.t = Notification.make(~title="Testing notifications")

Notification.requestPermission()
->Promise.thenResolve(notificationPermission => {
->Promise.thenResolve((notificationPermission: Notification.notificationPermission) => {
switch notificationPermission {
| Granted => Console.log("Permission granted")
| Denied => Console.log("Permission denied")
Expand Down
35 changes: 15 additions & 20 deletions tests/WebAudioAPI/AudioDestinationNode__.test.res
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
open WebAudioTypes
let ctx: AudioContext.t = AudioContext.make()

let ctx = AudioContext.make()
let destinationNode: AudioNode.t = ctx.destination->AudioDestinationNode.asAudioNode
let context: AudioContext.baseAudioContext = AudioContext.asBaseAudioContext(ctx)

let destinationNode = ctx.destination->AudioDestinationNode.asAudioNode
let context = AudioContext.asBaseAudioContext(ctx)
let oscillatorOptions: OscillatorNode.oscillatorOptions = {
type_: Sine,
frequency: 440.0,
}
let osc: OscillatorNode.t = OscillatorNode.make(~context, ~options=oscillatorOptions)

let gainOptions: GainNode.gainOptions = {
gain: 0.3,
}
let gain: GainNode.t = GainNode.make(~context, ~options=gainOptions)

let osc = OscillatorNode.make(
~context,
~options={
type_: Sine,
frequency: 440.0,
},
)
let gain = GainNode.make(
~context,
~options={
gain: 0.3,
},
)
let _ = gain->GainNode.connect(~destinationNode)
let _scheduledSource: AudioScheduledSourceNode.t = osc->OscillatorNode.asAudioScheduledSourceNode
let _ =
osc
->OscillatorNode.asAudioScheduledSourceNode
->AudioScheduledSourceNode.connect(~destinationNode=gain->GainNode.asAudioNode)
_scheduledSource->AudioScheduledSourceNode.connect(~destinationNode=gain->GainNode.asAudioNode)

osc->OscillatorNode.start