diff --git a/.scalafix.conf b/.scalafix.conf index c243ef089..cac4f6d32 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -7,7 +7,7 @@ rules = [ ] RemoveUnused { - imports = false + imports = true privates = true locals = true } diff --git a/src/main/scala/org/scalajs/dom/AbortController.scala b/src/main/scala/org/scalajs/dom/AbortController.scala index 7f3f6ca66..bac2aed45 100644 --- a/src/main/scala/org/scalajs/dom/AbortController.scala +++ b/src/main/scala/org/scalajs/dom/AbortController.scala @@ -18,19 +18,3 @@ class AbortController() extends js.Object { */ def abort(): Unit = js.native } - -/** The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a - * Fetch) and abort it if required via an AbortController object. - */ -@js.native -trait AbortSignal extends EventTarget { - - /** A Boolean that indicates whether the request(s) the signal is communicating with is/are aborted (true) or not - * (false). - */ - def aborted: Boolean = js.native - - /** Invoked when an abort event fires, i.e. when the DOM request(s) the signal is communicating with is/are aborted. - */ - var onabort: js.Function0[Any] = js.native -} diff --git a/src/main/scala/org/scalajs/dom/AbortSignal.scala b/src/main/scala/org/scalajs/dom/AbortSignal.scala new file mode 100644 index 000000000..023b9c9c8 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AbortSignal.scala @@ -0,0 +1,19 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AbortSignal interface represents a signal object that allows you to communicate with a DOM request (such as a + * Fetch) and abort it if required via an AbortController object. + */ +@js.native +trait AbortSignal extends EventTarget { + + /** A Boolean that indicates whether the request(s) the signal is communicating with is/are aborted (true) or not + * (false). + */ + def aborted: Boolean = js.native + + /** Invoked when an abort event fires, i.e. when the DOM request(s) the signal is communicating with is/are aborted. + */ + var onabort: js.Function0[Any] = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AbstractWorker.scala b/src/main/scala/org/scalajs/dom/AbstractWorker.scala new file mode 100644 index 000000000..9402697e5 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AbstractWorker.scala @@ -0,0 +1,15 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AbstractWorker interface abstracts properties and methods common to all kind of workers, being Worker or + * SharedWorker. + */ +@js.native +trait AbstractWorker extends EventTarget { + + /** The AbstractWorker.onerror property represents an EventHandler, that is a function to be called when the error + * event occurs and bubbles through the Worker. + */ + var onerror: js.Function1[ErrorEvent, _] = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AnalyserNode.scala b/src/main/scala/org/scalajs/dom/AnalyserNode.scala new file mode 100644 index 000000000..d693bfce8 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AnalyserNode.scala @@ -0,0 +1,91 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AnalyserNode interface represents a node able to provide real-time frequency and time-domain analysis + * information. It is an AudioNode that passes the audio stream unchanged from the input to the output, but allows you + * to take the generated data,process it, and create audio visualizations. + * + * An AnalyzerNode has exactly one input and one output. The node works even if the output is not connected. + * + * - Number of inputs: 1 + * - Number of outputs: 1 (but may be left unconnected) + * - Channel count mode: "explicit" + * - Channel count: 1 + * - Channel interpretation: "speakers" + */ +@js.native +trait AnalyserNode extends AudioNode { + + /** Is an unsigned long value representing the size of the FFT (Fast Fourier Transform) to be used to determine the + * frequency domain. + */ + var fftSize: Int = js.native + + /** Is an unsigned long value half that of the FFT size. This generally equates to the number of data values you will + * have to play with for the visualization. + */ + val frequencyBinCount: Int = js.native + + /** Is a double value representing the minimum power value in the scaling range for the FFT analysis data, for + * conversion to unsigned byte values — basically, this specifies the minimum value for the range of results when + * using getByteFrequencyData(). + */ + var minDecibels: Double = js.native + + /** Is a double value representing the maximum power value in the scaling range for the FFT analysis data, for + * conversion to unsigned byte values — basically, this specifies the maximum value for the range of results when + * using getByteFrequencyData(). + */ + var maxDecibels: Double = js.native + + /** Is a double value representing the averaging constant with the last analysis frame — basically, it makes the + * transition between values over time smoother. + */ + var smoothingTimeConstant: Double = js.native + + /** Copies the current frequency data into a Float32Array array passed into it. + * + * If the array has fewer elements than the AnalyserNode.frequencyBinCount, excess elements are dropped. If it has + * more elements than needed, excess elements are ignored. + * + * @param array + * The Float32Array that the frequency domain data will be copied to. + */ + def getFloatFrequencyData(array: js.typedarray.Float32Array): Unit = js.native + + /** Copies the current frequency data into a Uint8Array (unsigned byte array) passed into it. + * + * If the array has fewer elements than the AnalyserNode.frequencyBinCount, excess elements are dropped. If it has + * more elements than needed, excess elements are ignored. + * + * @param array + * The Uint8Array that the frequency domain data will be copied to. + */ + def getByteFrequencyData(array: js.typedarray.Uint8Array): Unit = js.native + + /** Copies the current waveform, or time-domain, data into a Float32Array array passed into it. + * + * If the array has fewer elements than the AnalyserNode.fftSize, excess elements are dropped. If it has more + * elements than needed, excess elements are ignored. + * + * @param array + * The Float32Array that the time domain data will be copied to. + */ + def getFloatTimeDomainData(array: js.typedarray.Float32Array): Unit = js.native + + /** Copies the current waveform, or time-domain, data into a Uint8Array (unsigned byte array) passed into it. + * + * If the array has fewer elements than the AnalyserNode.fftSize, excess elements are dropped. If it has more + * elements than needed, excess elements are ignored. + * + * @param array + * The Uint8Array that the time domain data will be copied to. + */ + def getByteTimeDomainData(array: js.typedarray.Uint8Array): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AnimationEvent.scala b/src/main/scala/org/scalajs/dom/AnimationEvent.scala new file mode 100644 index 000000000..3ab8a4004 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AnimationEvent.scala @@ -0,0 +1,26 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AnimationEvent interface represents events providing information related to animations. */ +@js.native +trait AnimationEvent extends Event { + + /** The AnimationEvent.animationName read-only property is a DOMString containing the value of the animation-name CSS + * property associated with the transition. + */ + def animationName: String = js.native + + /** The AnimationEvent.elapsedTime read-only property is a float giving the amount of time the animation has been + * running, in seconds, when this event fired, excluding any time the animation was paused. For an "animationstart" + * event, elapsedTime is 0.0 unless there was a negative value for animation-delay, in which case the event will be + * fired with elapsedTime containing  (-1 * delay). + */ + def elapsedTime: Double = js.native +} diff --git a/src/main/scala/org/scalajs/dom/ApplicationCache.scala b/src/main/scala/org/scalajs/dom/ApplicationCache.scala new file mode 100644 index 000000000..f56c97184 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/ApplicationCache.scala @@ -0,0 +1,42 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +trait ApplicationCache extends EventTarget { + def status: Int = js.native + + var ondownloading: js.Function1[Event, _] = js.native + var onprogress: js.Function1[ProgressEvent, _] = js.native + var onupdateready: js.Function1[Event, _] = js.native + var oncached: js.Function1[Event, _] = js.native + var onobsolete: js.Function1[Event, _] = js.native + var onerror: js.Function1[ErrorEvent, _] = js.native + var onchecking: js.Function1[Event, _] = js.native + var onnoupdate: js.Function1[Event, _] = js.native + + def swapCache(): Unit = js.native + + def abort(): Unit = js.native + + def update(): Unit = js.native +} + +@js.native +@JSGlobal +object ApplicationCache extends js.Object { + /* ??? ConstructorMember(FunSignature(List(),List(),Some(TypeRef(TypeName(ApplicationCache),List())))) */ + val CHECKING: Int = js.native + val UNCACHED: Int = js.native + val UPDATEREADY: Int = js.native + val DOWNLOADING: Int = js.native + val IDLE: Int = js.native + val OBSOLETE: Int = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Attr.scala b/src/main/scala/org/scalajs/dom/Attr.scala new file mode 100644 index 000000000..e725928ea --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Attr.scala @@ -0,0 +1,41 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** This type represents a DOM element's attribute as an object. In most DOM methods, you will probably directly + * retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g., + * Element.getAttributeNode()) or means of iterating give Attr types. + */ +@js.native +@JSGlobal +class Attr extends Node { + + /** This property now always returns true. */ + def specified: Boolean = js.native + + /** The element holding the attribute. + * + * Note: DOM Level 4 removed this property. The assumption was that since you get an Attr object from an Element, you + * should already know the associated element. + * + * As that doesn't hold true in cases like Attr objects being returned by Document.evaluate, the DOM Living Standard + * reintroduced the property. + */ + def ownerElement: Element = js.native + + /** The attribute's value. */ + var value: String = js.native + + /** The attribute's name. */ + def name: String = js.native + + /** A DOMString representing the namespace prefix of the attribute, or null if no prefix is specified. */ + def prefix: String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Audio.scala b/src/main/scala/org/scalajs/dom/Audio.scala deleted file mode 100644 index d691021ac..000000000 --- a/src/main/scala/org/scalajs/dom/Audio.scala +++ /dev/null @@ -1,1143 +0,0 @@ -/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available - * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ - * - * Everything else is under the MIT License http://opensource.org/licenses/MIT - */ -package org.scalajs.dom - -import org.scalajs.dom.experimental.mediastream.MediaStream -import scala.scalajs.js -import scala.scalajs.js.annotation._ - -/** The AudioContext interface represents an audio-processing graph built from audio modules linked together, each - * represented by an AudioNode. An audio context controls both the creation of the nodes it contains and the execution - * of the audio processing, or decoding. You need to create an AudioContext before you do anything else, as everything - * happens inside a context. - * - * An AudioContext can be a target of events, therefore it implements the EventTarget interface. - */ -@js.native -@JSGlobal -class AudioContext extends EventTarget { - - /** Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at 0 and - * cannot be stopped, paused or reset. - */ - def currentTime: Double = js.native - - /** Returns an AudioDestinationNode representing the final destination of all audio in the context. It can be thought - * of as the audio-rendering device. - */ - val destination: AudioDestinationNode = js.native - - /** Returns the AudioListener object, used for 3D spatialization. */ - val listener: AudioListener = js.native - - /** Returns a float representing the sample rate (in samples per second) used by all nodes in this context. The - * sample-rate of an AudioContext cannot be changed. - */ - val sampleRate: Double = js.native - - /** Returns the current state of the AudioContext. */ - def state: String = js.native - - /** Closes the audio context, releasing any system audio resources that it uses. */ - def close(): js.Promise[Unit] = js.native - - /** Creates an AnalyserNode, which can be used to expose audio time and frequency data and for example to create data - * visualisations. - */ - def createAnalyser(): AnalyserNode = js.native - - /** Creates a BiquadFilterNode, which represents a second order filter configurable as several different common filter - * types: high-pass, low-pass, band-pass, etc. - */ - def createBiquadFilter(): BiquadFilterNode = js.native - - /** Creates a new, empty AudioBuffer object, which can then be populated by data and played via an - * AudioBufferSourceNode. - * - * @param numOfChannels - * An integer representing the number of channels this buffer should have. Implementations must support a minimum - * 32 channels. - * @param length - * An integer representing the size of the buffer in sample-frames. - * @param sampleRate - * The sample-rate of the linear audio data in sample-frames per second. An implementation must support - * sample-rates in at least the range 22050 to 96000. - */ - def createBuffer(numOfChannels: Int, length: Int, sampleRate: Int): AudioBuffer = js.native - - /** Creates an AudioBufferSourceNode, which can be used to play and manipulate audio data contained within an - * AudioBuffer object. AudioBuffers are created using AudioContext.createBuffer or returned by - * AudioContext.decodeAudioData when it successfully decodes an audio track. - */ - def createBufferSource(): AudioBufferSourceNode = js.native - - /** Creates a ChannelMergerNode, which is used to combine channels from multiple audio streams into a single audio - * stream. - * - * @param numberOfInputs - * The number of channels in the input audio streams, which the output stream will contain; the default is 6 is - * this parameter is not specified. - */ - def createChannelMerger(numberOfInputs: Int = js.native): ChannelMergerNode = js.native - - /** Creates a ChannelSplitterNode, which is used to access the individual channels of an audio stream and process them - * separately. - * - * @param numberOfOutputs - * The number of channels in the input audio stream that you want to output separately; the default is 6 is this - * parameter is not specified. - */ - def createChannelSplitter(numberOfOutputs: Int = js.native): ChannelSplitterNode = js.native - - /** Creates a ConvolverNode, which can be used to apply convolution effects to your audio graph, for example a - * reverberation effect. - */ - def createConvolver(): ConvolverNode = js.native - - /** Creates a DelayNode, which is used to delay the incoming audio signal by a certain amount. This node is also - * useful to create feedback loops in a Web Audio API graph. - * - * @param maxDelayTime - * The maximum amount of time, in seconds, that the audio signal can be delayed by. The default value is 0. - */ - def createDelay(maxDelayTime: Int): DelayNode = js.native - - /** Creates a DynamicsCompressorNode, which can be used to apply acoustic compression to an audio signal. */ - def createDynamicsCompressor(): DynamicsCompressorNode = js.native - - /** Creates a GainNode, which can be used to control the overall volume of the audio graph. */ - def createGain(): GainNode = js.native - - /** Creates a MediaElementAudioSourceNode associated with an HTMLMediaElement. This can be used to play and manipulate - * audio from <video> or <audio> elements. - * - * @param myMediaElement - * An HTMLMediaElement object that you want to feed into an audio processing graph to manipulate. - */ - def createMediaElementSource(myMediaElement: HTMLMediaElement): MediaElementAudioSourceNode = js.native - - /** Creates a MediaStreamAudioSourceNode associated with a MediaStream representing an audio stream which may come - * from the local computer microphone or other sources. - * - * @param stream - * A MediaStream object that you want to feed into an audio processing graph to manipulate. - */ - def createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode = js.native - - /** Creates a MediaStreamAudioDestinationNode associated with a MediaStream representing an audio stream which may be - * stored in a local file or sent to another computer. - */ - def createMediaStreamDestination(): MediaStreamAudioDestinationNode = js.native - - /** Creates an OscillatorNode, a source representing a periodic waveform. It basically generates a tone. */ - def createOscillator(): OscillatorNode = js.native - - /** Creates a PannerNode, which is used to spatialise an incoming audio stream in 3D space. */ - def createPanner(): PannerNode = js.native - - /** Creates a PeriodicWave, used to define a periodic waveform that can be used to determine the output of an - * OscillatorNode. - */ - def createPeriodicWave(real: js.typedarray.Float32Array, imag: js.typedarray.Float32Array): PeriodicWave = js.native - - /** Creates a StereoPannerNode, which can be used to apply stereo panning to an audio source. */ - def createStereoPanner(): StereoPannerNode = js.native - - /** Creates a WaveShaperNode, which is used to implement non-linear distortion effects. */ - def createWaveShaper(): WaveShaperNode = js.native - - /** Asynchronously decodes audio file data contained in an ArrayBuffer. In this case, the ArrayBuffer is usually - * loaded from an XMLHttpRequest's response attribute after setting the responseType to arraybuffer. This method only - * works on complete files, not fragments of audio files. - * - * @param audioData - * An ArrayBuffer containing the audio data to be decoded, usually grabbed from an XMLHttpRequest's response - * attribute after setting the responseType to arraybuffer. - * @param successCallback - * A callback function to be invoked when the decoding successfully finishes. The single argument to this callback - * is an AudioBuffer representing the decoded PCM audio data. Usually you'll want to put the decoded data into an - * AudioBufferSourceNode, from which it can be played and manipulated how you want. - * @param errorCallback - * An optional error callback, to be invoked if an error occurs when the audio data is being decoded. - */ - def decodeAudioData( - audioData: js.typedarray.ArrayBuffer, successCallback: js.Function1[AudioBuffer, _] = js.native, - errorCallback: js.Function0[_] = js.native - ): js.Promise[AudioBuffer] = js.native - - /** Resumes the progression of time in an audio context that has previously been suspended. */ - def resume(): js.Promise[Unit] = js.native - - /** Suspends the progression of time in the audio context, temporarily halting audio hardware access and reducing - * CPU/battery usage in the process. - */ - def suspend(): js.Promise[Unit] = js.native -} - -/** The OfflineAudioContext interface is an AudioContext interface representing an audio-processing graph built from - * linked together AudioNodes. In contrast with a standard AudioContext, an OfflineAudioContext doesn't render the - * audio to the device hardware; instead, it generates it, as fast as it can, and outputs the result to an AudioBuffer. - * - * It is important to note that, whereas you can create a new AudioContext using the new AudioContext() constructor - * with no arguments, the new OfflineAudioContext() constructor requires three arguments: - * - * @example - * {{{new OfflineAudioContext(numOfChannels, length, sampleRate)}}} - * - * This works in exactly the same way as when you create a new AudioBuffer with the AudioContext.createBuffer method. - * For more detail, read Audio buffers: frames, samples and channels from our Basic concepts guide. - * - * @param numOfChannels - * An integer representing the number of channels this buffer should have. Implementations must support a minimum 32 - * channels. - * @param length - * An integer representing the size of the buffer in sample-frames. - * @param sampleRate - * The sample-rate of the linear audio data in sample-frames per second. An implementation must support sample-rates - * in at least the range 22050 to 96000, with 44100 being the most commonly used. - */ -@js.native -@JSGlobal -class OfflineAudioContext(numOfChannels: Int, length: Int, sampleRate: Int) extends AudioContext { - - /** The promise-based startRendering() method of the OfflineAudioContext Interface starts rendering the audio graph, - * taking into account the current connections and the current scheduled changes. - * - * When the method is invoked, the rendering is started and a promise is raised. When the rendering is completed, the - * promise resolves with an AudioBuffer containing the rendered audio. - */ - def startRendering(): js.Promise[AudioBuffer] = js.native -} - -/** The AudioNode interface is a generic interface for representing an audio processing module like an audio source - * (e.g. an HTML <audio> or <video> element, an OscillatorNode, etc.), the audio destination, intermediate - * processing module (e.g. a filter like BiquadFilterNode or ConvolverNode), or volume control (like GainNode). - * - * An AudioNode has inputs and outputs, each with a given amount of channels. An AudioNode with zero inputs and one or - * multiple outputs is called a source node. The exact processing done varies from one AudioNode to another but, in - * general, a node reads its inputs, does some audio-related processing, and generates new values for its outputs, or - * simply lets the audio pass through (for example in the AnalyserNode, where the result of the processing is accessed - * separately). - * - * Different nodes can be linked together to build a processing graph. Such a graph is contained in an AudioContext. - * Each AudioNode participates in exactly one such context. In general, processing nodes inherit the properties and - * methods of AudioNode, but also define their own functionality on top. See the individual node pages for more - * details, as listed on the Web Audio API homepage. - */ -@js.native -trait AudioNode extends EventTarget { - - /** Returns the associated AudioContext, that is the object representing the processing graph the node is - * participating in. - */ - val context: AudioContext = js.native - - /** Returns the number of inputs feeding the node. Source nodes are defined as nodes having a numberOfInputs property - * with a value of 0. - */ - val numberOfInputs: Int = js.native - - /** Returns the number of outputs coming out of the node. Destination nodes — like AudioDestinationNode — have a value - * of 0 for this attribute. - */ - val numberOfOutputs: Int = js.native - - /** Represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to - * any inputs to the node. Its usage and precise definition depend on the value of AudioNode.channelCountMode. - */ - var channelCount: Int = js.native - - /** Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs. - */ - var channelCountMode: Int = js.native - - /** Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio - * up-mixing and down-mixing will happen. - * - * The possible values are "speakers" or "discrete". - */ - var channelInterpretation: String = js.native - - /** Allows us to connect one output of this node to one input of another node. */ - def connect(audioNode: AudioNode): Unit = js.native - - /** Allows us to connect one output of this node to one input of an audio parameter. */ - def connect(audioParam: AudioParam): Unit = js.native - - /** Allows us to disconnect the current node from another one it is already connected to. - * - * @param output - * The index describing which output of the AudioNode is going to be disconnected. - */ - def disconnect(output: AudioNode = js.native): Unit = js.native -} - -/** The AnalyserNode interface represents a node able to provide real-time frequency and time-domain analysis - * information. It is an AudioNode that passes the audio stream unchanged from the input to the output, but allows you - * to take the generated data,process it, and create audio visualizations. - * - * An AnalyzerNode has exactly one input and one output. The node works even if the output is not connected. - * - * - Number of inputs: 1 - * - Number of outputs: 1 (but may be left unconnected) - * - Channel count mode: "explicit" - * - Channel count: 1 - * - Channel interpretation: "speakers" - */ -@js.native -trait AnalyserNode extends AudioNode { - - /** Is an unsigned long value representing the size of the FFT (Fast Fourier Transform) to be used to determine the - * frequency domain. - */ - var fftSize: Int = js.native - - /** Is an unsigned long value half that of the FFT size. This generally equates to the number of data values you will - * have to play with for the visualization. - */ - val frequencyBinCount: Int = js.native - - /** Is a double value representing the minimum power value in the scaling range for the FFT analysis data, for - * conversion to unsigned byte values — basically, this specifies the minimum value for the range of results when - * using getByteFrequencyData(). - */ - var minDecibels: Double = js.native - - /** Is a double value representing the maximum power value in the scaling range for the FFT analysis data, for - * conversion to unsigned byte values — basically, this specifies the maximum value for the range of results when - * using getByteFrequencyData(). - */ - var maxDecibels: Double = js.native - - /** Is a double value representing the averaging constant with the last analysis frame — basically, it makes the - * transition between values over time smoother. - */ - var smoothingTimeConstant: Double = js.native - - /** Copies the current frequency data into a Float32Array array passed into it. - * - * If the array has fewer elements than the AnalyserNode.frequencyBinCount, excess elements are dropped. If it has - * more elements than needed, excess elements are ignored. - * - * @param array - * The Float32Array that the frequency domain data will be copied to. - */ - def getFloatFrequencyData(array: js.typedarray.Float32Array): Unit = js.native - - /** Copies the current frequency data into a Uint8Array (unsigned byte array) passed into it. - * - * If the array has fewer elements than the AnalyserNode.frequencyBinCount, excess elements are dropped. If it has - * more elements than needed, excess elements are ignored. - * - * @param array - * The Uint8Array that the frequency domain data will be copied to. - */ - def getByteFrequencyData(array: js.typedarray.Uint8Array): Unit = js.native - - /** Copies the current waveform, or time-domain, data into a Float32Array array passed into it. - * - * If the array has fewer elements than the AnalyserNode.fftSize, excess elements are dropped. If it has more - * elements than needed, excess elements are ignored. - * - * @param array - * The Float32Array that the time domain data will be copied to. - */ - def getFloatTimeDomainData(array: js.typedarray.Float32Array): Unit = js.native - - /** Copies the current waveform, or time-domain, data into a Uint8Array (unsigned byte array) passed into it. - * - * If the array has fewer elements than the AnalyserNode.fftSize, excess elements are dropped. If it has more - * elements than needed, excess elements are ignored. - * - * @param array - * The Uint8Array that the time domain data will be copied to. - */ - def getByteTimeDomainData(array: js.typedarray.Uint8Array): Unit = js.native -} - -/** AudioBufferSourceNode has no input and exactly one output. The number of channels in the output corresponds to the - * number of channels of the AudioBuffer that is set to the AudioBufferSourceNode.buffer property. If there is no - * buffer set—that is, if the attribute's value is NULL—the output contains one channel consisting of silence. An - * AudioBufferSourceNode can only be played once; that is, only one call to AudioBufferSourceNode.start() is allowed. - * If the sound needs to be played again, another AudioBufferSourceNode has to be created. Those nodes are cheap to - * create, and AudioBuffers can be reused across plays. It is often said that AudioBufferSourceNodes have to be used in - * a "fire and forget" fashion: once it has been started, all references to the node can be dropped, and it will be - * garbage-collected automatically. - * - * Multiple calls to AudioBufferSourceNode.stop() are allowed. The most recent call replaces the previous one, granted - * the AudioBufferSourceNode has not already reached the end of the buffer. - * - * - Number of inputs: 0 - * - Number of outputs: 1 - * - Channel count: defined by the associated AudioBuffer - */ -@js.native -trait AudioBufferSourceNode extends AudioNode { - - /** Is an AudioBuffer that defines the audio asset to be played, or when set to the value null, defines a single - * channel of silence. - */ - var buffer: AudioBuffer = js.native - - /** Is an a-rate AudioParam that defines the speed factor at which the audio asset will be played. Since no pitch - * correction is applied on the output, this can be used to change the pitch of the sample. - */ - val playbackRate: AudioParam = js.native - - /** Is a Boolean attribute indicating if the audio asset must be replayed when the end of the AudioBuffer is reached. - * Its default value is false. - */ - var loop: Boolean = js.native - - /** Is a double value indicating, in seconds, where in the AudioBuffer the restart of the play must happen. Its - * default value is 0. - */ - var loopStart: Double = js.native - - /** Is a double value indicating, in seconds, where in the AudioBuffer the replay of the play must stop (and - * eventually loop again). Its default value is 0. - */ - var loopEnd: Double = js.native - - /** Schedules the start of the playback of the audio asset. - * - * @param when - * The when parameter defines when the play will start. If when represents a time in the past, the play will start - * immediately. If the method is called more than one time, or after a call to AudioBufferSourceNode.stop(), an - * exception is raised. - * @param offset - * The offset parameter, which defaults to 0, defines where the playback will start. - * @param duration - * The duration parameter, which defaults to the length of the asset minus the value of offset, defines the length - * of the portion of the asset to be played. - */ - def start(when: Double = js.native, offset: Double = js.native, duration: Double = js.native): Unit = js.native - - /** Schedules the end of the playback of an audio asset. - * - * @param when - * The when parameter defines when the playback will stop. If it represents a time in the past, the playback will - * end immediately. If this method is called twice or more, an exception is raised. - */ - def stop(when: Double = js.native): Unit = js.native - - /** Is an EventHandler containing the callback associated with the ended event. */ - var onended: js.Function1[Event, _] = js.native -} - -/** The AudioDestinationNode interface represents the end destination of an audio graph in a given context — usually the - * speakers of your device. It can also be the node that will "record" the audio data when used with an - * OfflineAudioContext. - * - * AudioDestinationNode has no output (as it is the output, no more AudioNode can be linked after it in the audio - * graph) and one input. The amount of channels in the input must be between 0 and the maxChannelCount value or an - * exception is raised. - * - * The AudioDestinationNode of a given AudioContext can be retrieved using the AudioContext.destination property. - * - * - Number of inputs: 1 - * - Number of outputs: 0 - * - Channel count mode: "explicit" - * - Channel count: 2 - * - Channel interpretation: "speakers" - */ -@js.native -trait AudioDestinationNode extends AudioNode { - - /** Is an unsigned long defining the maximum amount of channels that the physical device can handle. */ - var maxChannelCount: Int = js.native -} - -/** The AudioListener interface represents the position and orientation of the unique person listening to the audio - * scene, and is used in audio spatialisation. All PannerNodes spatialise in relation to the AudioListener stored in - * the AudioContext.listener attribute. - * - * It is important to note that there is only one listener per context and that it isn't an AudioNode. - */ -@js.native -trait AudioListener extends AudioNode { - - /** Is a double value representing the amount of pitch shift to use when rendering a doppler effect. */ - var dopplerFactor: Double = js.native - - /** Is a double value representing the speed of sound, in meters per second. */ - var speedOfSound: Double = js.native - - /** Defines the position of the listener. - * - * The three parameters x, y and z are unitless and describe the listener's position in 3D space according to the - * right-hand Cartesian coordinate system. PannerNode objects use this position relative to individual audio sources - * for spatialisation. - * - * The default value of the position vector is (0, 0, 0). - * - * @param x - * The x position of the listener in 3D space. - * @param y - * The y position of the listener in 3D space. - * @param z - * The z position of the listener in 3D space. - */ - def setPosition(x: Double = js.native, y: Double = js.native, z: Double = js.native): Unit = js.native - - /** Defines the orientation of the listener. - * - * It consists of two direction vectors: - * - * - The front vector, defined by the three unitless parameters x, y and z, describes the direction of the face of - * the listener, that is the direction the nose of the person is pointing towards. The front vector's default - * value is (0, 0, -1). - * - The up vector, defined by three unitless parameters xUp, yUp and zUp, describes the direction of the top of - * the listener's head. The up vector's default value is (0, 1, 0). - * - * Both vectors must be separated by an angle of 90° — in linear analysis terms, they must be linearly independent. - * - * @param x - * The x value of the front vector of the listener. - * @param y - * The y value of the front vector of the listener. - * @param z - * The z value of the front vector of the listener. - * @param xUp - * The x value of the up vector of the listener. - * @param yUp - * The y value of the up vector of the listener. - * @param zUp - * The z value of the up vector of the listener. - */ - def setOrientation(x: Double = js.native, y: Double = js.native, z: Double = js.native, xUp: Double = js.native, - yUp: Double = js.native, zUp: Double = js.native): Unit = js.native -} - -/** The AudioParam interface represents an audio-related parameter, usually a parameter of an AudioNode (such as - * GainNode.gain). An AudioParam can be set to a specific value or a change in value, and can be scheduled to happen at - * a specific time and following a specific pattern. - * - * There are two kinds of AudioParam, a-rate and k-rate parameters: - * - * - An a-rate AudioParam takes the current audio parameter value for each sample frame of the audio signal. - * - A k-rate AudioParam uses the same initial audio parameter value for the whole block processed, that is 128 - * sample frames. - * - * Each AudioNode defines which of its parameters are a-rate or k-rate in the spec. - * - * Each AudioParam has a list of events, initially empty, that define when and how values change. When this list is not - * empty, changes using the AudioParam.value attributes are ignored. This list of events allows us to schedule changes - * that have to happen at very precise times, using arbitrary timelime-based automation curves. The time used is the - * one defined in AudioContext.currentTime. - */ -@js.native -trait AudioParam extends AudioNode { - - /** Represents the parameter's current floating point value; initially set to the value of AudioParam.defaultValue. - * Though it can be set, any modifications happening while there are automation events scheduled — that is events - * scheduled using the methods of the AudioParam — are ignored, without raising any exception. - */ - var value: Double = js.native - - /** Represents the initial value of the attributes as defined by the specific AudioNode creating the AudioParam. */ - val defaultValue: Double = js.native - - /** Schedules an instant change to the value of the AudioParam at a precise time, as measured against - * AudioContext.currentTime. The new value is given in the value parameter. - * - * @param value - * A floating point number representing the value the AudioParam will change to at the given time. - * @param startTime - * A double representing the exact time (in seconds) after the AudioContext was first created that the change in - * value will happen. - */ - def setValueAtTime(value: Double, startTime: Double): Unit = js.native - - /** Schedules a gradual linear change in the value of the AudioParam. The change starts at the time specified for the - * previous event, follows a linear ramp to the new value given in the value parameter, and reaches the new value at - * the time given in the endTime parameter. - * - * @param value - * A floating point number representing the value the AudioParam will ramp up to by the given time. - * @param endTime - * A double representing the exact time (in seconds) after the ramping starts that the changing of the value will - * stop. - */ - def linearRampToValueAtTime(value: Double, endTime: Double): Unit = js.native - - /** Schedules a gradual exponential change in the value of the AudioParam. The change starts at the time specified for - * the previous event, follows an exponential ramp to the new value given in the value parameter, and reaches the new - * value at the time given in the endTime parameter. - * - * @param value - * A floating point number representing the value the AudioParam will ramp up to by the given time. - * @param endTime - * A double representing the exact time (in seconds) after the ramping starts that the changing of the value will - * stop. - */ - def exponentialRampToValueAtTime(value: Double, endTime: Double): Unit = js.native - - /** Schedules the start of a change to the value of the AudioParam. The change starts at the time specified in - * startTime and exponentially moves towards the value given by the target parameter. The exponential decay rate is - * defined by the timeConstant parameter, which is a time measured in seconds. - * - * @param target - * The value the parameter will start to transition towards at the given start time. - * @param startTime - * The time that the exponential transition will begin, which will be relative to AudioContext.currentTime. - * @param timeConstant - * The time-constant value of first-order filter (exponential) approach to the target value. The larger this value - * is, the slower the transition will be. - */ - def setTargetAtTime(target: Double, startTime: Double, timeConstant: Double): Unit = js.native - - /** Schedules the values of the AudioParam to follow a set of values, defined by the values Float32Array scaled to fit - * into the given interval, starting at startTime, and having a specific duration. - * - * @param values - * A Float32Array representing the value curve the AudioParam will change through along the duration. - * @param startTime - * A double representing the exact time (in seconds) after the AudioContext was first created that the change in - * value will happen. - * @param duration - * A double representing the exact time (in seconds) during which the values will be changed between. The values - * are spaced equally along this duration. - */ - def setValueCurveAtTime(values: js.typedarray.Float32Array, startTime: Double, duration: Double): Unit = js.native - - /** Cancels all scheduled future changes to the AudioParam. - * - * @param startTime - * A double representing the exact time (in seconds) after the AudioContext was first created after which all - * scheduled changes will be cancelled. - */ - def cancelScheduledValues(startTime: Double): Unit = js.native -} - -/** The BiquadFilterNode interface represents a simple low-order filter, and is created using the - * AudioContext.createBiquadFilter() method. It is an AudioNode that can represent different kinds of filters, tone - * control devices, and graphic equalizers. A BiquadFilterNode always has exactly one input and one output. - * - * - Number of inputs: 1 - * - Number of outputs: 1 - * - Channel count mode: "max" - * - Channel count: 2 (not used in the default count mode) - * - Channel interpretation: "speakers" - */ -@js.native -trait BiquadFilterNode extends AudioNode { - - /** Is a k-rate AudioParam, a double representing a frequency in the current filtering algorithm measured in hertz - * (Hz). - */ - val frequency: AudioParam = js.native - - /** Is an a-rate AudioParam representing detuning of the frequency in cents. */ - val detune: AudioParam = js.native - - /** Is a k-rate AudioParam, a double representing a Q factor, or quality factor. */ - val Q: AudioParam = js.native - - /** Is a k-rate AudioParam, a double representing the gain used in the current filtering algorithm. */ - val gain: AudioParam = js.native - - /** Is a string value defining the kind of filtering algorithm the node is implementing. */ - var `type`: String = js.native - - /** From the current filter parameter settings this method calculates the frequency response for frequencies specified - * in the provided array of frequencies. - * - * @param frequencyHz - * A Float32Array containing hertz values that you want the frequency response for. - * @param magResponse - * A Float32Array that will contain the outputted magnitude of the frequency response for each inputted frequency - * (hertz) value. The magnitude values are unitless. - * @param phaseResponse - * A Float32Array that will contain the outputted phase of the frequency response for each inputted frequency - * (hertz) value, measured in radians. - */ - def getFrequencyResponse(frequencyHz: js.typedarray.Float32Array, magResponse: js.typedarray.Float32Array, - phaseResponse: js.typedarray.Float32Array): Unit = js.native -} - -/** The ChannelMergerNode interface, often used in conjunction with its opposite, ChannelSplitterNode, reunites - * different mono inputs into a single output. Each input is used to fill a channel of the output. This is useful for - * accessing each channels separately, e.g. for performing channel mixing where gain must be separately controlled on - * each channel. - * - * If ChannelMergerNode has one single output, but as many inputs as there are channels to merge; the amount of inputs - * is defined as a parameter of its constructor and the call to AudioContext.createChannelMerger. In the case that no - * value is given, it will default to 6. - * - * Using a ChannelMergerNode, it is possible to create outputs with more channels than the rendering hardware is able - * to process. In that case, when the signal is sent to the AudioContext.listener object, supernumerary channels will - * be ignored. - * - * - Number of inputs: variable; default to 6. - * - Number of outputs: 1 - * - Channel count mode: "max" - * - Channel count: 2 (not used in the default count mode) - * - Channel interpretation: "speakers" - */ -@js.native -trait ChannelMergerNode extends AudioNode - -/** The ChannelSplitterNode interface, often used in conjunction with its opposite, ChannelMergerNode, separates the - * different channels of an audio source into a set of mono outputs. This is useful for accessing each channel - * separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. - * - * If your ChannelSplitterNode always has one single input, the amount of outputs is defined by a parameter on its - * constructor and the call to AudioContext.createChannelSplitter(). In the case that no value is given, it will - * default to 6. If there are less channels in the input than there are outputs, supernumerary outputs are silent. - * - * - Number of inputs: 1 - * - Number of outputs: variable; default to 6. - * - Channel count mode: "max" - * - Channel count: 2 (not used in the default count mode) - * - Channel interpretation: "speakers" - */ -@js.native -trait ChannelSplitterNode extends AudioNode - -/** The ConvolverNode interface is an AudioNode that performs a Linear Convolution on a given AudioBuffer, often used to - * achieve a reverb effect. A ConvolverNode always has exactly one input and one output. - * - * Note: For more information on the theory behind Linear Convolution, see the W3C Web Audio API spec section, Linear - * Effects Using Convolution, or read the The Wikipedia Linear Convolution Article. - * - * - Number of inputs: 1 - * - Number of outputs: 1 - * - Channel count mode: "clamped-max" - * - Channel count: 2 - * - Channel interpretation: "speakers" - */ -@js.native -trait ConvolverNode extends AudioNode { - - /** A mono, stereo, or 4-channel AudioBuffer containing the (possibly multichannel) impulse response used by the - * ConvolverNode to create the reverb effect. - */ - var buffer: AudioBuffer = js.native - - /** A boolean that controls whether the impulse response from the buffer will be scaled by an equal-power - * normalization when the buffer attribute is set, or not. - */ - var normalize: Boolean = js.native -} - -/** The DelayNode interface represents a delay-line; an AudioNode audio-processing module that causes a delay between - * the arrival of an input data and its propagation to the output. A DelayNode always has exactly one input and one - * output, both with the same amount of channels. - * - * When creating a graph that has a cycle, it is mandatory to have at least one DelayNode in the cycle, or the nodes - * taking part in the cycle will be muted. - * - * - Number of inputs: 1 - * - Number of outputs: 1 - * - Channel count mode: "max" - * - Channel count: 2 (not used in the default count mode) - * - Channel interpretation: "speakers" - */ -@js.native -trait DelayNode extends AudioNode { - - /** Is an a-rate AudioParam representing the amount of delay to apply. */ - val delayTime: AudioParam = js.native -} - -/** The DynamicsCompressorNode interface provides a compression effect, which lowers the volume of the loudest parts of - * the signal in order to help prevent clipping and distortion that can occur when multiple sounds are played and - * multiplexed together at once. This is often used in musical production and game audio. DynamicsCompressorNode is an - * AudioNode that has exactly one input and one output; it is created using the AudioContext.createDynamicsCompressor - * method. - * - * - Number of inputs: 1 - * - Number of outputs: 1 - * - Channel count mode: "explicit" - * - Channel count: 2 - * - Channel interpretation: "speakers" - */ -@js.native -trait DynamicsCompressorNode extends AudioNode { - - /** Is a k-rate AudioParam representing the decibel value above which the compression will start taking effect. */ - val threshold: AudioParam = js.native - - /** Is a k-rate AudioParam containing a decibel value representing the range above the threshold where the curve - * smoothly transitions to the compressed portion. - */ - val knee: AudioParam = js.native - - /** Is a k-rate AudioParam representing the amount of change, in dB, needed in the input for a 1 dB change in the - * output. - */ - val ratio: AudioParam = js.native - - /** Is a k-rate AudioParam representing the amount of gain reduction currently applied by the compressor to the - * signal. - */ - val reduction: AudioParam = js.native - - /** Is a k-rate AudioParam representing the amount of time, in seconds, required to reduce the gain by 10 dB. */ - val attack: AudioParam = js.native - - /** Is a k-rate AudioParam representing the amount of time, in seconds, required to increase the gain by 10 dB. */ - val release: AudioParam = js.native -} - -/** The GainNode interface represents a change in volume. It is an AudioNode audio-processing module that causes a given - * gain to be applied to the input data before its propagation to the output. A GainNode always has exactly one input - * and one output, both with the same number of channels. - * - * The gain is a unitless value, changing with time, that is multiplied to each corresponding sample of all input - * channels. If modified, the new gain is applied using a de-zippering algorithm in order to prevent unaesthetic - * 'clicks' from appearing in the resulting audio. - * - * The GainNode is increasing the gain of the output. - * - * - Number of inputs: 1 - * - Number of outputs: 1 - * - Channel count mode: "max" - * - Channel count: 2 (not used in the default count mode) - * - Channel interpretation: "speakers" - */ -@js.native -trait GainNode extends AudioNode { - - /** Is an a-rate AudioParam representing the amount of gain to apply. */ - val gain: AudioParam = js.native -} - -/** The MediaElementAudioSourceNode interface represents an audio source consisting of an HTML5 <audio> or - * <video> element. It is an AudioNode that acts as an audio source. - * - * A MediaElementSourceNode has no inputs and exactly one output, and is created using the - * AudioContext.createMediaElementSource method. The amount of channels in the output equals the number of channels of - * the audio referenced by the HTMLMediaElement used in the creation of the node, or is 1 if the HTMLMediaElement has - * no audio. - * - * - Number of inputs: 0 - * - Number of outputs: 1 - * - Channel count: defined by the media in the HTMLMediaElement passed to the AudioContext.createMediaElementSource - * method that created it. - */ -@js.native -trait MediaElementAudioSourceNode extends AudioNode - -/** The MediaElementAudioSourceNode interface represents an audio destination consisting of a WebRTC MediaStream with a - * single AudioMediaStreamTrack, which can be used in a similar way to a MediaStream obtained from - * Navigator.getUserMedia. - * - * It is an AudioNode that acts as an audio destination, created using the AudioContext.createMediaStreamDestination - * method. - * - * - Number of inputs: 1 - * - Number of outputs: 0 - * - Channel count: 2 - * - Channel count mode: "explicit" - * - Channel count interpretation: "speakers" - */ -@js.native -trait MediaStreamAudioDestinationNode extends AudioNode { - - /** Is a MediaStream containing a single AudioMediaStreamTrack with the same number of channels as the node itself. - * You can use this property to get a stream out of the audio graph and feed it into another construct, such as a - * Media Recorder. - */ - var stream: MediaStream = js.native -} - -/** The MediaStreamAudioSourceNode interface represents an audio source consisting of a WebRTC MediaStream (such as a - * webcam or microphone). It is an AudioNode that acts as an audio source. - * - * A MediaElementSourceNode has no inputs and exactly one output, and is created using the - * AudioContext.createMediaStreamSource method. The amount of channels in the output equals the number of channels in - * AudioMediaStreamTrack. If there is no valid media stream, then the number of output channels will be one silent - * channel. - * - * - Number of inputs: 0 - * - Number of outputs: 1 - * - Channel count: defined by the AudioMediaStreamTrack passed to the AudioContext.createMediaStreamSource method - * that created it. - */ -@js.native -trait MediaStreamAudioSourceNode extends AudioNode - -/** The OscillatorNode interface represents a periodic waveform, like a sine wave. It is an AudioNode audio-processing - * module that causes a given frequency of sine wave to be created — in effect, a constant tone. - * - * An OscillatorNode is created using the AudioContext.createOscillator method. It always has exactly one output and no - * inputs, both with the same amount of channels. Its basic property defaults (see AudioNode for definitions) are: - * - * - Number of inputs: 0 - * - Number of outputs: 1 - * - Channel count mode: max - * - Channel count: 2 (not used in the default count mode) - * - Channel interpretation: speakers - */ -@js.native -trait OscillatorNode extends AudioNode { - - /** An a-rate AudioParam representing the frequency of oscillation in hertz (though the AudioParam returned is - * read-only, the value it represents is not.) - */ - var frequency: AudioParam = js.native - - /** An a-rate AudioParam representing detuning of oscillation in cents (though the AudioParam returned is read-only, - * the value it represents is not.) - */ - var detune: AudioParam = js.native - - /** Represents the shape of the oscillator wave generated. Different waves will produce different tones. */ - var `type`: String = js.native // Not sure if this is correct ... - - /** This method specifies the exact time to start playing the tone. */ - def start(when: Double = js.native): Unit = js.native - - /** This method specifies the exact time to stop playing the tone. */ - def stop(when: Double = js.native): Unit = js.native - - /** Used to point to a PeriodicWave defining a periodic waveform that can be used to shape the oscillator's output, - * when type = "custom" is used. - * - * This replaces the now-obsolete OscillatorNode.setWaveTable. - */ - def setPeriodicWave(wave: PeriodicWave): Unit = js.native - - /** Used to set the event handler for the ended event, which fires when the tone has stopped playing. */ - var onended: js.Function1[Event, _] = js.native -} - -/** The PannerNode interface represents the position and behavior of an audio source signal in space. It is an AudioNode - * audio-processing module describing its position with right-hand Cartesian coordinates, its movement using a velocity - * vector and its directionality using a directionality cone. - * - * A PannerNode always has exactly one input and one output: the input can be mono or stereo but the output is always - * stereo (2 channels) — you need stereo sound for panning effects! - * - * The PannerNode brings a spatial position and velocity and a directionality for a given signal. - * - * - Number of inputs: 1 - * - Number of outputs: 1 - * - Channel count mode: "clamped-max" - * - Channel count: 2 - * - Channel interpretation: "speakers" - */ -@js.native -trait PannerNode extends AudioNode { - - /** Is an enumerated value determining which spatialisation algorithm to use to position the audio in 3D space. */ - var panningModel: String = js.native - - /** Is an enumerated value determining which algorithm to use to reduce the volume of the audio source as it moves - * away from the listener. - */ - var distanceModel: String = js.native - - /** Is a double value representing the reference distance for reducing volume as the audio source moves further from - * the listener. - */ - var refDistance: Double = js.native - - /** Is a double value representing the maximum distance between the audio source and the listener, after which the - * volume is not reduced any further. - */ - var maxDistance: Double = js.native - - /** Is a double value describing how quickly the volume is reduced as the source moves away from the listener. This - * value is used by all distance models. - */ - var rolloffFactor: Double = js.native - - /** Is a double value describing the angle, in degrees, of a cone inside of which there will be no volume reduction. - */ - var coneInnerAngle: Double = js.native - - /** Is a double value describing the angle, in degrees, of a cone outside of which the volume will be reduced by a - * constant value, defined by the coneOuterGain attribute. - */ - var coneOuterAngle: Double = js.native - - /** Is a double value describing the amount of volume reduction outside the cone defined by the coneOuterAngle - * attribute. - * - * Its default value is 0, meaning that no sound can be heard. - */ - var coneOuterGain: Double = js.native - - /** Defines the position of the audio source relative to the listener (represented by an AudioListener object stored - * in the AudioContext.listener attribute.) The three parameters x, y and z are unitless and describe the source's - * position in 3D space using the right-hand Cartesian coordinate system. - * - * The setPosition() method's default value of the position is (0, 0, 0). - * - * @param x - * The x position of the panner in 3D space. - * @param y - * The y position of the panner in 3D space. - * @param z - * The z position of the panner in 3D space. - */ - def setPosition(x: Double = js.native, y: Double = js.native, z: Double = js.native): Unit = js.native - - /** Defines the direction the audio source is playing in. This can have a big effect if the sound is very directional - * — controlled by the three cone-related attributes PannerNode.coneInnerAngle, PannerNode.coneOuterAngle, and - * PannerNode.coneOuterGain. In such a case, a sound pointing away from the listener can be very quiet or even - * silent. - * - * The three parameters x, y and z are unitless and describe a direction vector in 3D space using the right-hand - * Cartesian coordinate system. - * - * The default value of the direction vector is (1, 0, 0). - * - * @param x - * The x value of the panner's direction vector in 3D space. - * @param y - * The y value of the panner's direction vector in 3D space. - * @param z - * The z value of the panner's direction vector in 3D space. - */ - def setOrientation(x: Double = js.native, y: Double = js.native, z: Double = js.native): Unit = js.native - - /** Defines the velocity vector of the audio source — how fast it is moving and in what direction. - * - * The velocity relative to the listener is used to control the pitch change needed to conform with the Doppler - * effect due to the relative speed. - * - * As the vector controls both the direction of travel and its velocity, the three parameters x, y and z are - * expressed in meters per second. - * - * The default value of the velocity vector is (0, 0, 0). - * - * @param x - * The x value of the panner's velocity vector. - * @param y - * The y value of the panner's velocity vector. - * @param z - * The z value of the panner's velocity vector. - */ - def setVelocity(x: Double = js.native, y: Double = js.native, z: Double = js.native): Unit = js.native -} - -/** The StereoPannerNode interface of the Web Audio API represents a simple stereo panner node that can be used to pan - * an audio stream left or right. It is an AudioNode audio-processing module that positions an incoming audio stream in - * a stereo image using a low-cost equal-power panning algorithm. - * - * The pan property takes a unitless value between -1 (full left pan) and 1 (full right pan). - * - * This interface was introduced as a much simpler way to apply a simple panning effect than having to use a full - * PannerNode. - */ -@js.native -trait StereoPannerNode extends AudioNode { - - /** Is an a-rate AudioParam representing the amount of panning to apply. */ - val pan: AudioParam = js.native -} - -/** The WaveShaperNode interface represents a non-linear distorter. It is an AudioNode that uses a curve to apply a wave - * shaping distortion to the signal. Beside obvious distortion effects, it is often used to add a warm feeling to the - * signal. - * - * A WaveShaperNode always has exactly one input and one output. - * - * - Number of inputs: 1 - * - Number of outputs: 1 - * - Channel count mode: "max" - * - Channel count: 2 (not used in the default count mode) - * - Channel interpretation: "speakers" - */ -@js.native -trait WaveShaperNode extends AudioNode { - - /** Is a Float32Array of numbers describing the distortion to apply. */ - var curve: js.typedarray.Float32Array = js.native - - /** Is an enumerated value indicating if oversampling must be used. Oversampling is a technique for creating more - * samples (up-sampling) before applying the distortion effect to the audio signal. - */ - var oversample: String = js.native -} - -/** The AudioBuffer interface represents a short audio asset residing in memory, created from an audio file using the - * AudioContext.decodeAudioData() method, or from raw data using AudioContext.createBuffer(). Once put into an - * AudioBuffer, the audio can then be played by being passed into an AudioBufferSourceNode. - * - * Objects of these types are designed to hold small audio snippets, typically less than 45 s. For longer sounds, - * objects implementing the MediaElementAudioSourceNode are more suitable. - * - * The buffer contains data in the following format: non-interleaved IEEE754 32-bit linear PCM with a nominal range - * between -1 and +1, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0. If the AudioBuffer - * has multiple channels, they are stored in separate buffer. - */ -@js.native -trait AudioBuffer extends js.Object { - - /** Returns a float representing the sample rate, in samples per second, of the PCM data stored in the buffer. */ - val sampleRate: Double = js.native - - /** Returns an integer representing the length, in sample-frames, of the PCM data stored in the buffer. */ - val length: Int = js.native - - /** Returns a double representing the duration, in seconds, of the PCM data stored in the buffer. */ - val duration: Double = js.native - - /** Returns an integer representing the number of discrete audio channels described by the PCM data stored in the - * buffer. - */ - val numberOfChannels: Int = js.native - - /** Returns a Float32Array containing the PCM data associated with the channel, defined by the channel parameter (with - * 0 representing the first channel). - * - * @param channel - * The channel property is an index representing the particular channel to get data for. An index value of 0 - * represents the first channel. If the channel index value is greater than of equal to - * AudioBuffer.numberOfChannels, an INDEX_SIZE_ERR exception will be thrown. - */ - def getChannelData(channel: Int): js.typedarray.Float32Array = js.native - - /** Copies the samples from the specified channel of the AudioBuffer to the destination array. - * - * @param destination - * A Float32Array to copy the channel data to. - * @param channelNumber - * The channel number of the current AudioBuffer to copy the channel data from. If channelNumber is greater than or - * equal to AudioBuffer.numberOfChannels, an INDEX_SIZE_ERR will be thrown. - * @param startInChannel - * An optional offset to copy the data from. If startInChannel is greater than AudioBuffer.length, an - * INDEX_SIZE_ERR will be thrown. - */ - def copyFromChannel(destination: js.typedarray.Float32Array, channelNumber: Int, - startInChannel: Int): Unit = js.native - - /** Copies the samples to the specified channel of the AudioBuffer, from the source array. - * - * @param source - * A Float32Array that the channel data will be copied from. - * @param channelNumber - * The channel number of the current AudioBuffer to copy the channel data to. If channelNumber is greater than or - * equal to AudioBuffer.numberOfChannels, an INDEX_SIZE_ERR will be thrown. - * @param startInChannel - * An optional offset to copy the data to. If startInChannel is greater than AudioBuffer.length, an INDEX_SIZE_ERR - * will be thrown. - */ - def copyToChannel(source: js.typedarray.Float32Array, channelNumber: Int, startInChannel: Int): Unit = js.native -} - -/** The Web Audio API OfflineAudioCompletionEvent interface represents events that occur when the processing of an - * OfflineAudioContext is terminated. The complete event implements this interface. - */ -@js.native -trait OfflineAudioCompletionEvent extends Event { - - /** The buffer containing the result of the processing of an OfflineAudioContext. */ - val renderedBuffer: AudioBuffer = js.native -} - -/** The PeriodicWave interface defines a periodic waveform that can be used to shape the output of an OscillatorNode. - * - * PeriodicWave has no inputs or outputs; it is used to create custom oscillators via OscillatorNode.setPeriodicWave. - * The PeriodicWave itself is created/returned by AudioContext.createPeriodicWave. - */ -@js.native -trait PeriodicWave extends js.Object diff --git a/src/main/scala/org/scalajs/dom/AudioBuffer.scala b/src/main/scala/org/scalajs/dom/AudioBuffer.scala new file mode 100644 index 000000000..e27d2c22f --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioBuffer.scala @@ -0,0 +1,74 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AudioBuffer interface represents a short audio asset residing in memory, created from an audio file using the + * AudioContext.decodeAudioData() method, or from raw data using AudioContext.createBuffer(). Once put into an + * AudioBuffer, the audio can then be played by being passed into an AudioBufferSourceNode. + * + * Objects of these types are designed to hold small audio snippets, typically less than 45 s. For longer sounds, + * objects implementing the MediaElementAudioSourceNode are more suitable. + * + * The buffer contains data in the following format: non-interleaved IEEE754 32-bit linear PCM with a nominal range + * between -1 and +1, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0. If the AudioBuffer + * has multiple channels, they are stored in separate buffer. + */ +@js.native +trait AudioBuffer extends js.Object { + + /** Returns a float representing the sample rate, in samples per second, of the PCM data stored in the buffer. */ + val sampleRate: Double = js.native + + /** Returns an integer representing the length, in sample-frames, of the PCM data stored in the buffer. */ + val length: Int = js.native + + /** Returns a double representing the duration, in seconds, of the PCM data stored in the buffer. */ + val duration: Double = js.native + + /** Returns an integer representing the number of discrete audio channels described by the PCM data stored in the + * buffer. + */ + val numberOfChannels: Int = js.native + + /** Returns a Float32Array containing the PCM data associated with the channel, defined by the channel parameter (with + * 0 representing the first channel). + * + * @param channel + * The channel property is an index representing the particular channel to get data for. An index value of 0 + * represents the first channel. If the channel index value is greater than of equal to + * AudioBuffer.numberOfChannels, an INDEX_SIZE_ERR exception will be thrown. + */ + def getChannelData(channel: Int): js.typedarray.Float32Array = js.native + + /** Copies the samples from the specified channel of the AudioBuffer to the destination array. + * + * @param destination + * A Float32Array to copy the channel data to. + * @param channelNumber + * The channel number of the current AudioBuffer to copy the channel data from. If channelNumber is greater than or + * equal to AudioBuffer.numberOfChannels, an INDEX_SIZE_ERR will be thrown. + * @param startInChannel + * An optional offset to copy the data from. If startInChannel is greater than AudioBuffer.length, an + * INDEX_SIZE_ERR will be thrown. + */ + def copyFromChannel(destination: js.typedarray.Float32Array, channelNumber: Int, + startInChannel: Int): Unit = js.native + + /** Copies the samples to the specified channel of the AudioBuffer, from the source array. + * + * @param source + * A Float32Array that the channel data will be copied from. + * @param channelNumber + * The channel number of the current AudioBuffer to copy the channel data to. If channelNumber is greater than or + * equal to AudioBuffer.numberOfChannels, an INDEX_SIZE_ERR will be thrown. + * @param startInChannel + * An optional offset to copy the data to. If startInChannel is greater than AudioBuffer.length, an INDEX_SIZE_ERR + * will be thrown. + */ + def copyToChannel(source: js.typedarray.Float32Array, channelNumber: Int, startInChannel: Int): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioBufferSourceNode.scala b/src/main/scala/org/scalajs/dom/AudioBufferSourceNode.scala new file mode 100644 index 000000000..1fc346b2b --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioBufferSourceNode.scala @@ -0,0 +1,78 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** AudioBufferSourceNode has no input and exactly one output. The number of channels in the output corresponds to the + * number of channels of the AudioBuffer that is set to the AudioBufferSourceNode.buffer property. If there is no + * buffer set—that is, if the attribute's value is NULL—the output contains one channel consisting of silence. An + * AudioBufferSourceNode can only be played once; that is, only one call to AudioBufferSourceNode.start() is allowed. + * If the sound needs to be played again, another AudioBufferSourceNode has to be created. Those nodes are cheap to + * create, and AudioBuffers can be reused across plays. It is often said that AudioBufferSourceNodes have to be used in + * a "fire and forget" fashion: once it has been started, all references to the node can be dropped, and it will be + * garbage-collected automatically. + * + * Multiple calls to AudioBufferSourceNode.stop() are allowed. The most recent call replaces the previous one, granted + * the AudioBufferSourceNode has not already reached the end of the buffer. + * + * - Number of inputs: 0 + * - Number of outputs: 1 + * - Channel count: defined by the associated AudioBuffer + */ +@js.native +trait AudioBufferSourceNode extends AudioNode { + + /** Is an AudioBuffer that defines the audio asset to be played, or when set to the value null, defines a single + * channel of silence. + */ + var buffer: AudioBuffer = js.native + + /** Is an a-rate AudioParam that defines the speed factor at which the audio asset will be played. Since no pitch + * correction is applied on the output, this can be used to change the pitch of the sample. + */ + val playbackRate: AudioParam = js.native + + /** Is a Boolean attribute indicating if the audio asset must be replayed when the end of the AudioBuffer is reached. + * Its default value is false. + */ + var loop: Boolean = js.native + + /** Is a double value indicating, in seconds, where in the AudioBuffer the restart of the play must happen. Its + * default value is 0. + */ + var loopStart: Double = js.native + + /** Is a double value indicating, in seconds, where in the AudioBuffer the replay of the play must stop (and + * eventually loop again). Its default value is 0. + */ + var loopEnd: Double = js.native + + /** Schedules the start of the playback of the audio asset. + * + * @param when + * The when parameter defines when the play will start. If when represents a time in the past, the play will start + * immediately. If the method is called more than one time, or after a call to AudioBufferSourceNode.stop(), an + * exception is raised. + * @param offset + * The offset parameter, which defaults to 0, defines where the playback will start. + * @param duration + * The duration parameter, which defaults to the length of the asset minus the value of offset, defines the length + * of the portion of the asset to be played. + */ + def start(when: Double = js.native, offset: Double = js.native, duration: Double = js.native): Unit = js.native + + /** Schedules the end of the playback of an audio asset. + * + * @param when + * The when parameter defines when the playback will stop. If it represents a time in the past, the playback will + * end immediately. If this method is called twice or more, an exception is raised. + */ + def stop(when: Double = js.native): Unit = js.native + + /** Is an EventHandler containing the callback associated with the ended event. */ + var onended: js.Function1[Event, _] = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioContext.scala b/src/main/scala/org/scalajs/dom/AudioContext.scala new file mode 100644 index 000000000..5ef7f3f2b --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioContext.scala @@ -0,0 +1,178 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import org.scalajs.dom.experimental.mediastream.MediaStream +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The AudioContext interface represents an audio-processing graph built from audio modules linked together, each + * represented by an AudioNode. An audio context controls both the creation of the nodes it contains and the execution + * of the audio processing, or decoding. You need to create an AudioContext before you do anything else, as everything + * happens inside a context. + * + * An AudioContext can be a target of events, therefore it implements the EventTarget interface. + */ +@js.native +@JSGlobal +class AudioContext extends EventTarget { + + /** Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at 0 and + * cannot be stopped, paused or reset. + */ + def currentTime: Double = js.native + + /** Returns an AudioDestinationNode representing the final destination of all audio in the context. It can be thought + * of as the audio-rendering device. + */ + val destination: AudioDestinationNode = js.native + + /** Returns the AudioListener object, used for 3D spatialization. */ + val listener: AudioListener = js.native + + /** Returns a float representing the sample rate (in samples per second) used by all nodes in this context. The + * sample-rate of an AudioContext cannot be changed. + */ + val sampleRate: Double = js.native + + /** Returns the current state of the AudioContext. */ + def state: String = js.native + + /** Closes the audio context, releasing any system audio resources that it uses. */ + def close(): js.Promise[Unit] = js.native + + /** Creates an AnalyserNode, which can be used to expose audio time and frequency data and for example to create data + * visualisations. + */ + def createAnalyser(): AnalyserNode = js.native + + /** Creates a BiquadFilterNode, which represents a second order filter configurable as several different common filter + * types: high-pass, low-pass, band-pass, etc. + */ + def createBiquadFilter(): BiquadFilterNode = js.native + + /** Creates a new, empty AudioBuffer object, which can then be populated by data and played via an + * AudioBufferSourceNode. + * + * @param numOfChannels + * An integer representing the number of channels this buffer should have. Implementations must support a minimum + * 32 channels. + * @param length + * An integer representing the size of the buffer in sample-frames. + * @param sampleRate + * The sample-rate of the linear audio data in sample-frames per second. An implementation must support + * sample-rates in at least the range 22050 to 96000. + */ + def createBuffer(numOfChannels: Int, length: Int, sampleRate: Int): AudioBuffer = js.native + + /** Creates an AudioBufferSourceNode, which can be used to play and manipulate audio data contained within an + * AudioBuffer object. AudioBuffers are created using AudioContext.createBuffer or returned by + * AudioContext.decodeAudioData when it successfully decodes an audio track. + */ + def createBufferSource(): AudioBufferSourceNode = js.native + + /** Creates a ChannelMergerNode, which is used to combine channels from multiple audio streams into a single audio + * stream. + * + * @param numberOfInputs + * The number of channels in the input audio streams, which the output stream will contain; the default is 6 is + * this parameter is not specified. + */ + def createChannelMerger(numberOfInputs: Int = js.native): ChannelMergerNode = js.native + + /** Creates a ChannelSplitterNode, which is used to access the individual channels of an audio stream and process them + * separately. + * + * @param numberOfOutputs + * The number of channels in the input audio stream that you want to output separately; the default is 6 is this + * parameter is not specified. + */ + def createChannelSplitter(numberOfOutputs: Int = js.native): ChannelSplitterNode = js.native + + /** Creates a ConvolverNode, which can be used to apply convolution effects to your audio graph, for example a + * reverberation effect. + */ + def createConvolver(): ConvolverNode = js.native + + /** Creates a DelayNode, which is used to delay the incoming audio signal by a certain amount. This node is also + * useful to create feedback loops in a Web Audio API graph. + * + * @param maxDelayTime + * The maximum amount of time, in seconds, that the audio signal can be delayed by. The default value is 0. + */ + def createDelay(maxDelayTime: Int): DelayNode = js.native + + /** Creates a DynamicsCompressorNode, which can be used to apply acoustic compression to an audio signal. */ + def createDynamicsCompressor(): DynamicsCompressorNode = js.native + + /** Creates a GainNode, which can be used to control the overall volume of the audio graph. */ + def createGain(): GainNode = js.native + + /** Creates a MediaElementAudioSourceNode associated with an HTMLMediaElement. This can be used to play and manipulate + * audio from <video> or <audio> elements. + * + * @param myMediaElement + * An HTMLMediaElement object that you want to feed into an audio processing graph to manipulate. + */ + def createMediaElementSource(myMediaElement: HTMLMediaElement): MediaElementAudioSourceNode = js.native + + /** Creates a MediaStreamAudioSourceNode associated with a MediaStream representing an audio stream which may come + * from the local computer microphone or other sources. + * + * @param stream + * A MediaStream object that you want to feed into an audio processing graph to manipulate. + */ + def createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode = js.native + + /** Creates a MediaStreamAudioDestinationNode associated with a MediaStream representing an audio stream which may be + * stored in a local file or sent to another computer. + */ + def createMediaStreamDestination(): MediaStreamAudioDestinationNode = js.native + + /** Creates an OscillatorNode, a source representing a periodic waveform. It basically generates a tone. */ + def createOscillator(): OscillatorNode = js.native + + /** Creates a PannerNode, which is used to spatialise an incoming audio stream in 3D space. */ + def createPanner(): PannerNode = js.native + + /** Creates a PeriodicWave, used to define a periodic waveform that can be used to determine the output of an + * OscillatorNode. + */ + def createPeriodicWave(real: js.typedarray.Float32Array, imag: js.typedarray.Float32Array): PeriodicWave = js.native + + /** Creates a StereoPannerNode, which can be used to apply stereo panning to an audio source. */ + def createStereoPanner(): StereoPannerNode = js.native + + /** Creates a WaveShaperNode, which is used to implement non-linear distortion effects. */ + def createWaveShaper(): WaveShaperNode = js.native + + /** Asynchronously decodes audio file data contained in an ArrayBuffer. In this case, the ArrayBuffer is usually + * loaded from an XMLHttpRequest's response attribute after setting the responseType to arraybuffer. This method only + * works on complete files, not fragments of audio files. + * + * @param audioData + * An ArrayBuffer containing the audio data to be decoded, usually grabbed from an XMLHttpRequest's response + * attribute after setting the responseType to arraybuffer. + * @param successCallback + * A callback function to be invoked when the decoding successfully finishes. The single argument to this callback + * is an AudioBuffer representing the decoded PCM audio data. Usually you'll want to put the decoded data into an + * AudioBufferSourceNode, from which it can be played and manipulated how you want. + * @param errorCallback + * An optional error callback, to be invoked if an error occurs when the audio data is being decoded. + */ + def decodeAudioData( + audioData: js.typedarray.ArrayBuffer, successCallback: js.Function1[AudioBuffer, _] = js.native, + errorCallback: js.Function0[_] = js.native + ): js.Promise[AudioBuffer] = js.native + + /** Resumes the progression of time in an audio context that has previously been suspended. */ + def resume(): js.Promise[Unit] = js.native + + /** Suspends the progression of time in the audio context, temporarily halting audio hardware access and reducing + * CPU/battery usage in the process. + */ + def suspend(): js.Promise[Unit] = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioDestinationNode.scala b/src/main/scala/org/scalajs/dom/AudioDestinationNode.scala new file mode 100644 index 000000000..e238f2cfe --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioDestinationNode.scala @@ -0,0 +1,31 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AudioDestinationNode interface represents the end destination of an audio graph in a given context — usually the + * speakers of your device. It can also be the node that will "record" the audio data when used with an + * OfflineAudioContext. + * + * AudioDestinationNode has no output (as it is the output, no more AudioNode can be linked after it in the audio + * graph) and one input. The amount of channels in the input must be between 0 and the maxChannelCount value or an + * exception is raised. + * + * The AudioDestinationNode of a given AudioContext can be retrieved using the AudioContext.destination property. + * + * - Number of inputs: 1 + * - Number of outputs: 0 + * - Channel count mode: "explicit" + * - Channel count: 2 + * - Channel interpretation: "speakers" + */ +@js.native +trait AudioDestinationNode extends AudioNode { + + /** Is an unsigned long defining the maximum amount of channels that the physical device can handle. */ + var maxChannelCount: Int = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioListener.scala b/src/main/scala/org/scalajs/dom/AudioListener.scala new file mode 100644 index 000000000..6a4ab956e --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioListener.scala @@ -0,0 +1,69 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AudioListener interface represents the position and orientation of the unique person listening to the audio + * scene, and is used in audio spatialisation. All PannerNodes spatialise in relation to the AudioListener stored in + * the AudioContext.listener attribute. + * + * It is important to note that there is only one listener per context and that it isn't an AudioNode. + */ +@js.native +trait AudioListener extends AudioNode { + + /** Is a double value representing the amount of pitch shift to use when rendering a doppler effect. */ + var dopplerFactor: Double = js.native + + /** Is a double value representing the speed of sound, in meters per second. */ + var speedOfSound: Double = js.native + + /** Defines the position of the listener. + * + * The three parameters x, y and z are unitless and describe the listener's position in 3D space according to the + * right-hand Cartesian coordinate system. PannerNode objects use this position relative to individual audio sources + * for spatialisation. + * + * The default value of the position vector is (0, 0, 0). + * + * @param x + * The x position of the listener in 3D space. + * @param y + * The y position of the listener in 3D space. + * @param z + * The z position of the listener in 3D space. + */ + def setPosition(x: Double = js.native, y: Double = js.native, z: Double = js.native): Unit = js.native + + /** Defines the orientation of the listener. + * + * It consists of two direction vectors: + * + * - The front vector, defined by the three unitless parameters x, y and z, describes the direction of the face of + * the listener, that is the direction the nose of the person is pointing towards. The front vector's default + * value is (0, 0, -1). + * - The up vector, defined by three unitless parameters xUp, yUp and zUp, describes the direction of the top of + * the listener's head. The up vector's default value is (0, 1, 0). + * + * Both vectors must be separated by an angle of 90° — in linear analysis terms, they must be linearly independent. + * + * @param x + * The x value of the front vector of the listener. + * @param y + * The y value of the front vector of the listener. + * @param z + * The z value of the front vector of the listener. + * @param xUp + * The x value of the up vector of the listener. + * @param yUp + * The y value of the up vector of the listener. + * @param zUp + * The z value of the up vector of the listener. + */ + def setOrientation(x: Double = js.native, y: Double = js.native, z: Double = js.native, xUp: Double = js.native, + yUp: Double = js.native, zUp: Double = js.native): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioNode.scala b/src/main/scala/org/scalajs/dom/AudioNode.scala new file mode 100644 index 000000000..283f604dc --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioNode.scala @@ -0,0 +1,71 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AudioNode interface is a generic interface for representing an audio processing module like an audio source + * (e.g. an HTML <audio> or <video> element, an OscillatorNode, etc.), the audio destination, intermediate + * processing module (e.g. a filter like BiquadFilterNode or ConvolverNode), or volume control (like GainNode). + * + * An AudioNode has inputs and outputs, each with a given amount of channels. An AudioNode with zero inputs and one or + * multiple outputs is called a source node. The exact processing done varies from one AudioNode to another but, in + * general, a node reads its inputs, does some audio-related processing, and generates new values for its outputs, or + * simply lets the audio pass through (for example in the AnalyserNode, where the result of the processing is accessed + * separately). + * + * Different nodes can be linked together to build a processing graph. Such a graph is contained in an AudioContext. + * Each AudioNode participates in exactly one such context. In general, processing nodes inherit the properties and + * methods of AudioNode, but also define their own functionality on top. See the individual node pages for more + * details, as listed on the Web Audio API homepage. + */ +@js.native +trait AudioNode extends EventTarget { + + /** Returns the associated AudioContext, that is the object representing the processing graph the node is + * participating in. + */ + val context: AudioContext = js.native + + /** Returns the number of inputs feeding the node. Source nodes are defined as nodes having a numberOfInputs property + * with a value of 0. + */ + val numberOfInputs: Int = js.native + + /** Returns the number of outputs coming out of the node. Destination nodes — like AudioDestinationNode — have a value + * of 0 for this attribute. + */ + val numberOfOutputs: Int = js.native + + /** Represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to + * any inputs to the node. Its usage and precise definition depend on the value of AudioNode.channelCountMode. + */ + var channelCount: Int = js.native + + /** Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs. + */ + var channelCountMode: Int = js.native + + /** Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio + * up-mixing and down-mixing will happen. + * + * The possible values are "speakers" or "discrete". + */ + var channelInterpretation: String = js.native + + /** Allows us to connect one output of this node to one input of another node. */ + def connect(audioNode: AudioNode): Unit = js.native + + /** Allows us to connect one output of this node to one input of an audio parameter. */ + def connect(audioParam: AudioParam): Unit = js.native + + /** Allows us to disconnect the current node from another one it is already connected to. + * + * @param output + * The index describing which output of the AudioNode is going to be disconnected. + */ + def disconnect(output: AudioNode = js.native): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioParam.scala b/src/main/scala/org/scalajs/dom/AudioParam.scala new file mode 100644 index 000000000..79b16030b --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioParam.scala @@ -0,0 +1,109 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The AudioParam interface represents an audio-related parameter, usually a parameter of an AudioNode (such as + * GainNode.gain). An AudioParam can be set to a specific value or a change in value, and can be scheduled to happen at + * a specific time and following a specific pattern. + * + * There are two kinds of AudioParam, a-rate and k-rate parameters: + * + * - An a-rate AudioParam takes the current audio parameter value for each sample frame of the audio signal. + * - A k-rate AudioParam uses the same initial audio parameter value for the whole block processed, that is 128 + * sample frames. + * + * Each AudioNode defines which of its parameters are a-rate or k-rate in the spec. + * + * Each AudioParam has a list of events, initially empty, that define when and how values change. When this list is not + * empty, changes using the AudioParam.value attributes are ignored. This list of events allows us to schedule changes + * that have to happen at very precise times, using arbitrary timelime-based automation curves. The time used is the + * one defined in AudioContext.currentTime. + */ +@js.native +trait AudioParam extends AudioNode { + + /** Represents the parameter's current floating point value; initially set to the value of AudioParam.defaultValue. + * Though it can be set, any modifications happening while there are automation events scheduled — that is events + * scheduled using the methods of the AudioParam — are ignored, without raising any exception. + */ + var value: Double = js.native + + /** Represents the initial value of the attributes as defined by the specific AudioNode creating the AudioParam. */ + val defaultValue: Double = js.native + + /** Schedules an instant change to the value of the AudioParam at a precise time, as measured against + * AudioContext.currentTime. The new value is given in the value parameter. + * + * @param value + * A floating point number representing the value the AudioParam will change to at the given time. + * @param startTime + * A double representing the exact time (in seconds) after the AudioContext was first created that the change in + * value will happen. + */ + def setValueAtTime(value: Double, startTime: Double): Unit = js.native + + /** Schedules a gradual linear change in the value of the AudioParam. The change starts at the time specified for the + * previous event, follows a linear ramp to the new value given in the value parameter, and reaches the new value at + * the time given in the endTime parameter. + * + * @param value + * A floating point number representing the value the AudioParam will ramp up to by the given time. + * @param endTime + * A double representing the exact time (in seconds) after the ramping starts that the changing of the value will + * stop. + */ + def linearRampToValueAtTime(value: Double, endTime: Double): Unit = js.native + + /** Schedules a gradual exponential change in the value of the AudioParam. The change starts at the time specified for + * the previous event, follows an exponential ramp to the new value given in the value parameter, and reaches the new + * value at the time given in the endTime parameter. + * + * @param value + * A floating point number representing the value the AudioParam will ramp up to by the given time. + * @param endTime + * A double representing the exact time (in seconds) after the ramping starts that the changing of the value will + * stop. + */ + def exponentialRampToValueAtTime(value: Double, endTime: Double): Unit = js.native + + /** Schedules the start of a change to the value of the AudioParam. The change starts at the time specified in + * startTime and exponentially moves towards the value given by the target parameter. The exponential decay rate is + * defined by the timeConstant parameter, which is a time measured in seconds. + * + * @param target + * The value the parameter will start to transition towards at the given start time. + * @param startTime + * The time that the exponential transition will begin, which will be relative to AudioContext.currentTime. + * @param timeConstant + * The time-constant value of first-order filter (exponential) approach to the target value. The larger this value + * is, the slower the transition will be. + */ + def setTargetAtTime(target: Double, startTime: Double, timeConstant: Double): Unit = js.native + + /** Schedules the values of the AudioParam to follow a set of values, defined by the values Float32Array scaled to fit + * into the given interval, starting at startTime, and having a specific duration. + * + * @param values + * A Float32Array representing the value curve the AudioParam will change through along the duration. + * @param startTime + * A double representing the exact time (in seconds) after the AudioContext was first created that the change in + * value will happen. + * @param duration + * A double representing the exact time (in seconds) during which the values will be changed between. The values + * are spaced equally along this duration. + */ + def setValueCurveAtTime(values: js.typedarray.Float32Array, startTime: Double, duration: Double): Unit = js.native + + /** Cancels all scheduled future changes to the AudioParam. + * + * @param startTime + * A double representing the exact time (in seconds) after the AudioContext was first created after which all + * scheduled changes will be cancelled. + */ + def cancelScheduledValues(startTime: Double): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioTrack.scala b/src/main/scala/org/scalajs/dom/AudioTrack.scala new file mode 100644 index 000000000..e72b6ecb8 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioTrack.scala @@ -0,0 +1,18 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +@js.native +trait AudioTrack extends js.Object { + val id: String = js.native + val kind: String = js.native + val label: String = js.native + val language: String = js.native + var enabled: Boolean = js.native +} diff --git a/src/main/scala/org/scalajs/dom/AudioTrackList.scala b/src/main/scala/org/scalajs/dom/AudioTrackList.scala new file mode 100644 index 000000000..14772a821 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/AudioTrackList.scala @@ -0,0 +1,18 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +@js.native +trait AudioTrackList extends EventTarget with DOMList[AudioTrack] { + + var onchange: js.Function1[js.Any, _] = js.native + var onaddtrack: js.Function1[TrackEvent, _] = js.native + + def getTrackById(id: String): AudioTrack = js.native +} diff --git a/src/main/scala/org/scalajs/dom/BeforeUnloadEvent.scala b/src/main/scala/org/scalajs/dom/BeforeUnloadEvent.scala new file mode 100644 index 000000000..44efceae2 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/BeforeUnloadEvent.scala @@ -0,0 +1,16 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +class BeforeUnloadEvent extends Event(js.native) { + var returnValue: String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/BiquadFilterNode.scala b/src/main/scala/org/scalajs/dom/BiquadFilterNode.scala new file mode 100644 index 000000000..abdb83a45 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/BiquadFilterNode.scala @@ -0,0 +1,54 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The BiquadFilterNode interface represents a simple low-order filter, and is created using the + * AudioContext.createBiquadFilter() method. It is an AudioNode that can represent different kinds of filters, tone + * control devices, and graphic equalizers. A BiquadFilterNode always has exactly one input and one output. + * + * - Number of inputs: 1 + * - Number of outputs: 1 + * - Channel count mode: "max" + * - Channel count: 2 (not used in the default count mode) + * - Channel interpretation: "speakers" + */ +@js.native +trait BiquadFilterNode extends AudioNode { + + /** Is a k-rate AudioParam, a double representing a frequency in the current filtering algorithm measured in hertz + * (Hz). + */ + val frequency: AudioParam = js.native + + /** Is an a-rate AudioParam representing detuning of the frequency in cents. */ + val detune: AudioParam = js.native + + /** Is a k-rate AudioParam, a double representing a Q factor, or quality factor. */ + val Q: AudioParam = js.native + + /** Is a k-rate AudioParam, a double representing the gain used in the current filtering algorithm. */ + val gain: AudioParam = js.native + + /** Is a string value defining the kind of filtering algorithm the node is implementing. */ + var `type`: String = js.native + + /** From the current filter parameter settings this method calculates the frequency response for frequencies specified + * in the provided array of frequencies. + * + * @param frequencyHz + * A Float32Array containing hertz values that you want the frequency response for. + * @param magResponse + * A Float32Array that will contain the outputted magnitude of the frequency response for each inputted frequency + * (hertz) value. The magnitude values are unitless. + * @param phaseResponse + * A Float32Array that will contain the outputted phase of the frequency response for each inputted frequency + * (hertz) value, measured in radians. + */ + def getFrequencyResponse(frequencyHz: js.typedarray.Float32Array, magResponse: js.typedarray.Float32Array, + phaseResponse: js.typedarray.Float32Array): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Blob.scala b/src/main/scala/org/scalajs/dom/Blob.scala new file mode 100644 index 000000000..5690e3836 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Blob.scala @@ -0,0 +1,59 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ +import scala.scalajs.js.typedarray.{ArrayBuffer, Uint8Array} + +/** A Blob object represents a file-like object of immutable, raw data; they can be read as text or binary data, or + * converted into a ReadableStream so its methods can be used for processing the data. Blobs can represent data that + * isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality + * and expanding it to support files on the user's system. + * + * To construct a Blob from other non-blob objects and data, use the Blob() constructor. To create a blob that contains + * a subset of another blob's data, use the slice() method. To obtain a Blob object for a file on the user's file + * system, see the File documentation. + * + * The APIs accepting Blob objects are also listed in the File documentation. + */ +@js.native +@JSGlobal +class Blob(blobParts: js.Array[js.Any] = js.native, options: BlobPropertyBag = js.native) extends js.Object { + + @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") + def close(): Unit = js.native + + /** The size, in bytes, of the data contained in the Blob object. */ + def size: Double = js.native + + /** A string indicating the MIME type of the data contained in the Blob. If the type is unknown, this string is empty. + */ + def `type`: String = js.native + + /** A string indicating the MIME type of the data contained in the Blob. If the type is unknown, this string is empty. + */ + def slice(start: Double = js.native, end: Double = js.native, contentType: String = js.native): Blob = js.native + + /** Returns a ReadableStream that can be used to read the contents of the blob. */ + def stream(): ReadableStream[Uint8Array] = js.native + + /** Returns a promise that resolves with a USVString containing the entire contents of the blob interpreted as UTF-8 + * text. + * + * @see + * https://developer.mozilla.org/en-US/docs/Web/API/USVString + */ + def text(): js.Promise[String] = js.native + + /** Returns a promise that resolves with an ArrayBuffer containing the entire contents of the blob as binary data. */ + def arrayBuffer(): js.Promise[ArrayBuffer] = js.native +} + +@js.native +@JSGlobal +object Blob extends js.Object diff --git a/src/main/scala/org/scalajs/dom/BlobPropertyBag.scala b/src/main/scala/org/scalajs/dom/BlobPropertyBag.scala new file mode 100644 index 000000000..f59526533 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/BlobPropertyBag.scala @@ -0,0 +1,27 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +trait BlobPropertyBag extends js.Object { + var `type`: js.UndefOr[String] = js.undefined + + var endings: js.UndefOr[String] = js.undefined +} + +@deprecated("all members of BlobPropertyBag are deprecated", "2.0.0") +object BlobPropertyBag { + + @deprecated("use `new BlobPropertyBag { ... }` instead", "2.0.0") + @inline + def apply(`type`: js.UndefOr[String] = js.undefined): BlobPropertyBag = { + val result = js.Dynamic.literal() + `type`.foreach(result.`type` = _) + result.asInstanceOf[BlobPropertyBag] + } +} diff --git a/src/main/scala/org/scalajs/dom/Body.scala b/src/main/scala/org/scalajs/dom/Body.scala new file mode 100644 index 000000000..0b9cf0453 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Body.scala @@ -0,0 +1,32 @@ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.typedarray.ArrayBuffer + +/** See [[https://fetch.spec.whatwg.org/#body body interface]] in whatwg Fetch spec. + * + * see also [[https://developer.mozilla.org/en-US/docs/Web/API/Body Body]] in MDN + */ +@js.native +trait Body extends js.Object { + + /** Contains a Boolean that indicates whether the body has been read. */ + def bodyUsed: Boolean = js.native + + /** Takes a Response stream and reads it to completion. It returns a promise that resolves with an ArrayBuffer. */ + def arrayBuffer(): js.Promise[ArrayBuffer] = js.native + + /** Takes a Response stream and reads it to completion. It returns a promise that resolves with a Blob. */ + def blob(): js.Promise[Blob] = js.native + + /** Takes a Response stream and reads it to completion. It returns a promise that resolves with a FormData object. */ + def formData(): js.Promise[FormData] = js.native + + /** Takes a Response stream and reads it to completion. It returns a promise that resolves with a JSON object. //todo: + * define the JSON type, and return a Promise[JSON] as per spec + */ + def json(): js.Promise[js.Any] = js.native + + /** Takes a Response stream and reads it to completion. It returns a promise that resolves with a USVString (text). */ + def text(): js.Promise[String] = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CDATASection.scala b/src/main/scala/org/scalajs/dom/CDATASection.scala new file mode 100644 index 000000000..7c6f501b9 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CDATASection.scala @@ -0,0 +1,20 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** A CDATA Section can be used within XML to include extended portions of unescaped text, such that the symbols < + * and & do not need escaping as they normally do within XML when used as text. + * + * As a CDATASection has no properties or methods unique to itself and only directly implements the Text interface, one + * can refer to Text to find its properties and methods. + */ +@js.native +@JSGlobal +abstract class CDATASection extends Text diff --git a/src/main/scala/org/scalajs/dom/CSS.scala b/src/main/scala/org/scalajs/dom/CSS.scala new file mode 100644 index 000000000..051477939 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSS.scala @@ -0,0 +1,26 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +object CSS extends js.Object { + + /** The CSS.supports() method returns a boolean value indicating if the browser supports a given CSS feature, or not. + * Allows to test the support of a pair property-value. + */ + def supports(propertyName: String, value: String): Boolean = js.native + + /** The CSS.supports() method returns a boolean value indicating if the browser supports a given CSS feature, or not. + * Takes one parameter matching the condition of @supports. + */ + def supports(supportCondition: String): Boolean = js.native + +} diff --git a/src/main/scala/org/scalajs/dom/CSSFontFaceRule.scala b/src/main/scala/org/scalajs/dom/CSSFontFaceRule.scala new file mode 100644 index 000000000..e8813af0f --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSFontFaceRule.scala @@ -0,0 +1,16 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +class CSSFontFaceRule extends CSSRule { + var style: CSSStyleDeclaration = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSImportRule.scala b/src/main/scala/org/scalajs/dom/CSSImportRule.scala new file mode 100644 index 000000000..84b3f3ea7 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSImportRule.scala @@ -0,0 +1,18 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +class CSSImportRule extends CSSRule { + var styleSheet: CSSStyleSheet = js.native + var href: String = js.native + var media: MediaList = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSKeyframeRule.scala b/src/main/scala/org/scalajs/dom/CSSKeyframeRule.scala new file mode 100644 index 000000000..04ed8b9c3 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSKeyframeRule.scala @@ -0,0 +1,27 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The CSSKeyframeRule interface describes an object representing a set of style for a given keyframe. It corresponds + * to the contains of a single keyframe of a `@@keyframes` at-rule. It implements the CSSRule interface with a type + * value of 8 (CSSRule.KEYFRAME_RULE). + */ +@js.native +@JSGlobal +class CSSKeyframeRule extends CSSRule { + + /** Represents the key of the keyframe, like '10%', '75%'. The from keyword maps to '0%' and the to keyword maps to + * '100%'. + */ + var keyText: String = js.native + + /** Returns a CSSStyleDeclaration of the CSS style associated with the keyfrom. */ + var style: CSSStyleDeclaration = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSKeyframesRule.scala b/src/main/scala/org/scalajs/dom/CSSKeyframesRule.scala new file mode 100644 index 000000000..c58b1dde1 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSKeyframesRule.scala @@ -0,0 +1,41 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The CSSKeyframesRule interface describes an object representing a complete set of keyframes for a CSS animation. It + * corresponds to the contains of a whole `@@keyframes` at-rule. It implements the CSSRule interface with a type value + * of 7 (CSSRule.KEYFRAMES_RULE). + */ +@js.native +@JSGlobal +class CSSKeyframesRule extends CSSRule { + + /** Represents the name of the animation, used by the animation-name property. */ + var name: String = js.native + + /** Returns a CSSRuleList of the CSS rules in the media rule. */ + var cssRules: CSSRuleList = js.native + + /** Returns a keyframe rule corresponding to the given key. The key is a DOMString containing an index of the keyframe + * o be returned, resolving to a number between 0 and 1. If no such keyframe exists, findRule returns null. + */ + def findRule(rule: String): CSSKeyframeRule = js.native + + /** Deletes a keyframe rule from the current CSSKeyframesRule. The parameter is the index of the keyframe to be + * deleted, expressed as a DOMString resolving as a number between 0 and 1. + */ + def deleteRule(rule: String): Unit = js.native + + /** Inserts a new keyframe rule into the current CSSKeyframesRule. The parameter is a DOMString containing a keyframe + * in the same format as an entry of a `@keyframes` at-rule. If it contains more than one keyframe rule, a + * DOMException with a SYNTAX_ERR is thrown. + */ + def appendRule(rule: String): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSMediaRule.scala b/src/main/scala/org/scalajs/dom/CSSMediaRule.scala new file mode 100644 index 000000000..41addb8d8 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSMediaRule.scala @@ -0,0 +1,26 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** CSSMediaRule is an object representing a single CSS `@media` rule. It implements the CSSConditionRule interface, and + * therefore the CSSGroupingRule and the CSSRule interface with a type value of 4 (CSSRule.MEDIA_RULE). + */ +@js.native +@JSGlobal +class CSSMediaRule extends CSSRule { + + /** Specifies a MediaList representing the intended destination medium for style information. */ + var media: MediaList = js.native + var cssRules: CSSRuleList = js.native + + def insertRule(rule: String, index: Int = js.native): Int = js.native + + def deleteRule(index: Int = js.native): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSNamespaceRule.scala b/src/main/scala/org/scalajs/dom/CSSNamespaceRule.scala new file mode 100644 index 000000000..ba7f367b6 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSNamespaceRule.scala @@ -0,0 +1,26 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The CSSNamespaceRule interface describes an object representing a single CSS `@@namespace` at-rule. It implements + * the CSSRule interface, with a type value of 10 (CSSRule.NAMESPACE_RULE). + */ +@js.native +@JSGlobal +class CSSNamespaceRule extends CSSRule { + + /** Returns a DOMString containing the text of the URI of the given namespace. */ + var namespaceURI: String = js.native + + /** Returns a DOMString with the name of the prefix associated to this namespace. If there is no such prefix, returns  + * null. + */ + var prefix: String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSPageRule.scala b/src/main/scala/org/scalajs/dom/CSSPageRule.scala new file mode 100644 index 000000000..7c6fdd391 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSPageRule.scala @@ -0,0 +1,26 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** CSSPageRule is an object representing a single CSS `@page` rule. It implements the CSSRule interface with a type + * value of 6 (CSSRule.PAGE_RULE). + */ +@js.native +@JSGlobal +class CSSPageRule extends CSSRule { + var pseudoClass: String = js.native + + /** Represents the text of the page selector associated with the at-rule. */ + var selectorText: String = js.native + var selector: String = js.native + + /** Returns the declaration block associated with the at-rule. */ + var style: CSSStyleDeclaration = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSRule.scala b/src/main/scala/org/scalajs/dom/CSSRule.scala new file mode 100644 index 000000000..857b6366b --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSRule.scala @@ -0,0 +1,56 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** An object implementing the CSSRule DOM interface represents a single CSS at-rule. References to a + * CSSRule-implementing object may be obtained by looking at a CSS style sheet's cssRules list. + */ +@js.native +@JSGlobal +class CSSRule extends js.Object { + + /** cssText returns the actual text of the style rule. To be able to set a stylesheet rule dynamically, see Using + * dynamic styling information. + */ + var cssText: String = js.native + + /** parentStyleSheet returns the stylesheet object in which the current rule is defined. */ + var parentStyleSheet: CSSStyleSheet = js.native + + /** Returns the containing rule, otherwise null. E.g. if this rule is a style rule inside an `@media` block, the + * parent rule would be that CSSMediaRule. + */ + var parentRule: CSSRule = js.native + var `type`: Int = js.native + var IMPORT_RULE: Int = js.native + var MEDIA_RULE: Int = js.native + var STYLE_RULE: Int = js.native + var NAMESPACE_RULE: Int = js.native + var PAGE_RULE: Int = js.native + var UNKNOWN_RULE: Int = js.native + var FONT_FACE_RULE: Int = js.native + var CHARSET_RULE: Int = js.native + var KEYFRAMES_RULE: Int = js.native + var KEYFRAME_RULE: Int = js.native + var VIEWPORT_RULE: Int = js.native +} + +@js.native +@JSGlobal +object CSSRule extends js.Object { + var IMPORT_RULE: Int = js.native + var MEDIA_RULE: Int = js.native + var STYLE_RULE: Int = js.native + var NAMESPACE_RULE: Int = js.native + var PAGE_RULE: Int = js.native + var UNKNOWN_RULE: Int = js.native + var FONT_FACE_RULE: Int = js.native + var CHARSET_RULE: Int = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSRuleList.scala b/src/main/scala/org/scalajs/dom/CSSRuleList.scala new file mode 100644 index 000000000..4d600e520 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSRuleList.scala @@ -0,0 +1,17 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** A CSSRuleList is an array-like object containing an ordered collection of CSSRule objects. */ +@js.native +@JSGlobal +class CSSRuleList private[this] () extends DOMList[CSSRule] { + def item(index: Int): CSSRule = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSTypes.scala b/src/main/scala/org/scalajs/dom/CSSStyleDeclaration.scala similarity index 50% rename from src/main/scala/org/scalajs/dom/CSSTypes.scala rename to src/main/scala/org/scalajs/dom/CSSStyleDeclaration.scala index 915d7b91f..a1426b650 100644 --- a/src/main/scala/org/scalajs/dom/CSSTypes.scala +++ b/src/main/scala/org/scalajs/dom/CSSStyleDeclaration.scala @@ -9,22 +9,6 @@ package org.scalajs.dom import scala.scalajs.js import scala.scalajs.js.annotation._ -@js.native -@JSGlobal -object CSS extends js.Object { - - /** The CSS.supports() method returns a boolean value indicating if the browser supports a given CSS feature, or not. - * Allows to test the support of a pair property-value. - */ - def supports(propertyName: String, value: String): Boolean = js.native - - /** The CSS.supports() method returns a boolean value indicating if the browser supports a given CSS feature, or not. - * Takes one parameter matching the condition of @supports. - */ - def supports(supportCondition: String): Boolean = js.native - -} - /** A CSSStyleDeclaration is an interface to the declaration block returned by the style property of a cssRule in a * stylesheet, when the rule is a CSSStyleRule. */ @@ -239,218 +223,3 @@ class CSSStyleDeclaration extends js.Object { var columnCount: js.Any = js.native var transformStyle: String = js.native } - -/** An object implementing the CSSStyleSheet interface represents a single CSS style sheet. */ -@js.native -@JSGlobal -class CSSStyleSheet extends StyleSheet { - var owningElement: Element = js.native - var imports: StyleSheetList = js.native - var isAlternate: Boolean = js.native - var isPrefAlternate: Boolean = js.native - var readOnly: Boolean = js.native - var cssText: String = js.native - - /** If this style sheet is imported into the document using an `@import` rule, the ownerRule property will return that - * CSSImportRule, otherwise it returns null. - */ - var ownerRule: CSSRule = js.native - - /** Returns a CSSRuleList of the CSS rules in the style sheet. */ - var cssRules: CSSRuleList = js.native - var id: String = js.native - - def addImport(bstrURL: String, lIndex: Int = js.native): Int = js.native - - def addPageRule(bstrSelector: String, bstrStyle: String, lIndex: Int = js.native): Int = js.native - - /** The CSSStyleSheet.insertRule() method inserts a new style rule into the current style sheet. */ - def insertRule(rule: String, index: Int = js.native): Int = js.native - - def removeRule(lIndex: Int): Unit = js.native - - /** Deletes a rule from the style sheet. */ - def deleteRule(index: Int = js.native): Unit = js.native - - def addRule(bstrSelector: String, bstrStyle: String = js.native, lIndex: Int = js.native): Int = js.native - - def removeImport(lIndex: Int): Unit = js.native -} - -/** CSSStyleRule represents a single CSS style rule. It implements the CSSRule interface with a type value of 1 - * (CSSRule.STYLE_RULE). - */ -@js.native -@JSGlobal -class CSSStyleRule extends CSSRule { - - /** Gets/sets the textual representation of the selector for this rule, e.g. "h1,h2". */ - var selectorText: String = js.native - var readOnly: Boolean = js.native - - /** Returns the CSSStyleDeclaration object for the rule. */ - val style: CSSStyleDeclaration = js.native -} - -/** CSSMediaRule is an object representing a single CSS `@media` rule. It implements the CSSConditionRule interface, and - * therefore the CSSGroupingRule and the CSSRule interface with a type value of 4 (CSSRule.MEDIA_RULE). - */ -@js.native -@JSGlobal -class CSSMediaRule extends CSSRule { - - /** Specifies a MediaList representing the intended destination medium for style information. */ - var media: MediaList = js.native - var cssRules: CSSRuleList = js.native - - def insertRule(rule: String, index: Int = js.native): Int = js.native - - def deleteRule(index: Int = js.native): Unit = js.native -} - -/** The CSSNamespaceRule interface describes an object representing a single CSS `@@namespace` at-rule. It implements - * the CSSRule interface, with a type value of 10 (CSSRule.NAMESPACE_RULE). - */ -@js.native -@JSGlobal -class CSSNamespaceRule extends CSSRule { - - /** Returns a DOMString containing the text of the URI of the given namespace. */ - var namespaceURI: String = js.native - - /** Returns a DOMString with the name of the prefix associated to this namespace. If there is no such prefix, returns  - * null. - */ - var prefix: String = js.native -} - -@js.native -@JSGlobal -class CSSImportRule extends CSSRule { - var styleSheet: CSSStyleSheet = js.native - var href: String = js.native - var media: MediaList = js.native -} - -/** An object implementing the CSSRule DOM interface represents a single CSS at-rule. References to a - * CSSRule-implementing object may be obtained by looking at a CSS style sheet's cssRules list. - */ -@js.native -@JSGlobal -class CSSRule extends js.Object { - - /** cssText returns the actual text of the style rule. To be able to set a stylesheet rule dynamically, see Using - * dynamic styling information. - */ - var cssText: String = js.native - - /** parentStyleSheet returns the stylesheet object in which the current rule is defined. */ - var parentStyleSheet: CSSStyleSheet = js.native - - /** Returns the containing rule, otherwise null. E.g. if this rule is a style rule inside an `@media` block, the - * parent rule would be that CSSMediaRule. - */ - var parentRule: CSSRule = js.native - var `type`: Int = js.native - var IMPORT_RULE: Int = js.native - var MEDIA_RULE: Int = js.native - var STYLE_RULE: Int = js.native - var NAMESPACE_RULE: Int = js.native - var PAGE_RULE: Int = js.native - var UNKNOWN_RULE: Int = js.native - var FONT_FACE_RULE: Int = js.native - var CHARSET_RULE: Int = js.native - var KEYFRAMES_RULE: Int = js.native - var KEYFRAME_RULE: Int = js.native - var VIEWPORT_RULE: Int = js.native -} - -@js.native -@JSGlobal -object CSSRule extends js.Object { - var IMPORT_RULE: Int = js.native - var MEDIA_RULE: Int = js.native - var STYLE_RULE: Int = js.native - var NAMESPACE_RULE: Int = js.native - var PAGE_RULE: Int = js.native - var UNKNOWN_RULE: Int = js.native - var FONT_FACE_RULE: Int = js.native - var CHARSET_RULE: Int = js.native -} - -@js.native -@JSGlobal -class CSSFontFaceRule extends CSSRule { - var style: CSSStyleDeclaration = js.native -} - -/** CSSPageRule is an object representing a single CSS `@page` rule. It implements the CSSRule interface with a type - * value of 6 (CSSRule.PAGE_RULE). - */ -@js.native -@JSGlobal -class CSSPageRule extends CSSRule { - var pseudoClass: String = js.native - - /** Represents the text of the page selector associated with the at-rule. */ - var selectorText: String = js.native - var selector: String = js.native - - /** Returns the declaration block associated with the at-rule. */ - var style: CSSStyleDeclaration = js.native -} - -/** A CSSRuleList is an array-like object containing an ordered collection of CSSRule objects. */ -@js.native -@JSGlobal -class CSSRuleList private[this] () extends DOMList[CSSRule] { - def item(index: Int): CSSRule = js.native -} - -/** The CSSKeyframesRule interface describes an object representing a complete set of keyframes for a CSS animation. It - * corresponds to the contains of a whole `@@keyframes` at-rule. It implements the CSSRule interface with a type value - * of 7 (CSSRule.KEYFRAMES_RULE). - */ -@js.native -@JSGlobal -class CSSKeyframesRule extends CSSRule { - - /** Represents the name of the animation, used by the animation-name property. */ - var name: String = js.native - - /** Returns a CSSRuleList of the CSS rules in the media rule. */ - var cssRules: CSSRuleList = js.native - - /** Returns a keyframe rule corresponding to the given key. The key is a DOMString containing an index of the keyframe - * o be returned, resolving to a number between 0 and 1. If no such keyframe exists, findRule returns null. - */ - def findRule(rule: String): CSSKeyframeRule = js.native - - /** Deletes a keyframe rule from the current CSSKeyframesRule. The parameter is the index of the keyframe to be - * deleted, expressed as a DOMString resolving as a number between 0 and 1. - */ - def deleteRule(rule: String): Unit = js.native - - /** Inserts a new keyframe rule into the current CSSKeyframesRule. The parameter is a DOMString containing a keyframe - * in the same format as an entry of a `@keyframes` at-rule. If it contains more than one keyframe rule, a - * DOMException with a SYNTAX_ERR is thrown. - */ - def appendRule(rule: String): Unit = js.native -} - -/** The CSSKeyframeRule interface describes an object representing a set of style for a given keyframe. It corresponds - * to the contains of a single keyframe of a `@@keyframes` at-rule. It implements the CSSRule interface with a type - * value of 8 (CSSRule.KEYFRAME_RULE). - */ -@js.native -@JSGlobal -class CSSKeyframeRule extends CSSRule { - - /** Represents the key of the keyframe, like '10%', '75%'. The from keyword maps to '0%' and the to keyword maps to - * '100%'. - */ - var keyText: String = js.native - - /** Returns a CSSStyleDeclaration of the CSS style associated with the keyfrom. */ - var style: CSSStyleDeclaration = js.native -} diff --git a/src/main/scala/org/scalajs/dom/CSSStyleRule.scala b/src/main/scala/org/scalajs/dom/CSSStyleRule.scala new file mode 100644 index 000000000..97a88fe19 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSStyleRule.scala @@ -0,0 +1,25 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** CSSStyleRule represents a single CSS style rule. It implements the CSSRule interface with a type value of 1 + * (CSSRule.STYLE_RULE). + */ +@js.native +@JSGlobal +class CSSStyleRule extends CSSRule { + + /** Gets/sets the textual representation of the selector for this rule, e.g. "h1,h2". */ + var selectorText: String = js.native + var readOnly: Boolean = js.native + + /** Returns the CSSStyleDeclaration object for the rule. */ + val style: CSSStyleDeclaration = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CSSStyleSheet.scala b/src/main/scala/org/scalajs/dom/CSSStyleSheet.scala new file mode 100644 index 000000000..19a3d01e2 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CSSStyleSheet.scala @@ -0,0 +1,47 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** An object implementing the CSSStyleSheet interface represents a single CSS style sheet. */ +@js.native +@JSGlobal +class CSSStyleSheet extends StyleSheet { + var owningElement: Element = js.native + var imports: StyleSheetList = js.native + var isAlternate: Boolean = js.native + var isPrefAlternate: Boolean = js.native + var readOnly: Boolean = js.native + var cssText: String = js.native + + /** If this style sheet is imported into the document using an `@import` rule, the ownerRule property will return that + * CSSImportRule, otherwise it returns null. + */ + var ownerRule: CSSRule = js.native + + /** Returns a CSSRuleList of the CSS rules in the style sheet. */ + var cssRules: CSSRuleList = js.native + var id: String = js.native + + def addImport(bstrURL: String, lIndex: Int = js.native): Int = js.native + + def addPageRule(bstrSelector: String, bstrStyle: String, lIndex: Int = js.native): Int = js.native + + /** The CSSStyleSheet.insertRule() method inserts a new style rule into the current style sheet. */ + def insertRule(rule: String, index: Int = js.native): Int = js.native + + def removeRule(lIndex: Int): Unit = js.native + + /** Deletes a rule from the style sheet. */ + def deleteRule(index: Int = js.native): Unit = js.native + + def addRule(bstrSelector: String, bstrStyle: String = js.native, lIndex: Int = js.native): Int = js.native + + def removeImport(lIndex: Int): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Cache.scala b/src/main/scala/org/scalajs/dom/Cache.scala new file mode 100644 index 000000000..72af5d8cd --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Cache.scala @@ -0,0 +1,29 @@ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** See [[https://slightlyoff.github.io/ServiceWorker/spec/service_worker_1/#cache ¶5.4 cache]] of ServiceWorker whatwg + * spec. + */ +@js.native +@JSGlobal +abstract class Cache extends js.Object { + + def `match`(request: RequestInfo, + options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[js.UndefOr[Response]] = js.native + + def matchAll(request: RequestInfo = js.native, + options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[js.Array[Response]] = js.native + + def add(request: RequestInfo): js.Promise[Unit] = js.native + + def addAll(requests: js.Array[RequestInfo]): js.Promise[Unit] = js.native + + def put(request: RequestInfo, response: Response): js.Promise[Unit] = js.native + + def delete(request: RequestInfo, options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[Boolean] = js.native + + def keys(request: js.UndefOr[RequestInfo] = js.native, + options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[js.Array[Request]] +} diff --git a/src/main/scala/org/scalajs/dom/CacheQueryOptions.scala b/src/main/scala/org/scalajs/dom/CacheQueryOptions.scala new file mode 100644 index 000000000..68f76b1e9 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CacheQueryOptions.scala @@ -0,0 +1,17 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** See [[https://slightlyoff.github.io/ServiceWorker/spec/service_worker_1/#cache ¶5.4 cache]] of ServiceWorker whatwg + * spec. + */ +@js.native +trait CacheQueryOptions extends js.Object { + var ignoreSearch: Boolean = js.native // false + + var ignoreMethod: Boolean = js.native // false + + var ignoreVary: Boolean = js.native //false + + var cacheName: String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CacheStorage.scala b/src/main/scala/org/scalajs/dom/CacheStorage.scala index 709850749..b963d20c9 100644 --- a/src/main/scala/org/scalajs/dom/CacheStorage.scala +++ b/src/main/scala/org/scalajs/dom/CacheStorage.scala @@ -1,21 +1,6 @@ package org.scalajs.dom import scala.scalajs.js -import scala.scalajs.js.annotation._ - -/** See [[https://slightlyoff.github.io/ServiceWorker/spec/service_worker_1/#cache ¶5.4 cache]] of ServiceWorker whatwg - * spec. - */ -@js.native -trait CacheQueryOptions extends js.Object { - var ignoreSearch: Boolean = js.native // false - - var ignoreMethod: Boolean = js.native // false - - var ignoreVary: Boolean = js.native //false - - var cacheName: String = js.native -} /** See [[https://slightlyoff.github.io/ServiceWorker/spec/service_worker_1/#cache-storage ¶5.5 cache]] of ServiceWorker * whatwg spec. @@ -32,28 +17,3 @@ trait CacheStorage extends js.Object { def keys(): js.Promise[js.Array[String]] = js.native } - -/** See [[https://slightlyoff.github.io/ServiceWorker/spec/service_worker_1/#cache ¶5.4 cache]] of ServiceWorker whatwg - * spec. - */ -@js.native -@JSGlobal -abstract class Cache extends js.Object { - - def `match`(request: RequestInfo, - options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[js.UndefOr[Response]] = js.native - - def matchAll(request: RequestInfo = js.native, - options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[js.Array[Response]] = js.native - - def add(request: RequestInfo): js.Promise[Unit] = js.native - - def addAll(requests: js.Array[RequestInfo]): js.Promise[Unit] = js.native - - def put(request: RequestInfo, response: Response): js.Promise[Unit] = js.native - - def delete(request: RequestInfo, options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[Boolean] = js.native - - def keys(request: js.UndefOr[RequestInfo] = js.native, - options: js.UndefOr[CacheQueryOptions] = js.native): js.Promise[js.Array[Request]] -} diff --git a/src/main/scala/org/scalajs/dom/CanvasGradient.scala b/src/main/scala/org/scalajs/dom/CanvasGradient.scala new file mode 100644 index 000000000..e07149d46 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CanvasGradient.scala @@ -0,0 +1,23 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The CanvasGradient interface represents an opaque object describing a gradient and returned by + * CanvasRenderingContext2D.createLinearGradient or CanvasRenderingContext2D.createRadialGradient methods. + */ +@js.native +@JSGlobal +class CanvasGradient extends js.Object { + + /** Add a new stop, defined by an offset and a color, to the gradient. If the offset is not between 0 and 1 an + * INDEX_SIZE_ERR is raised, if the color can't be parsed as a CSS <color>, a SYNTAX_ERR is raised. + */ + def addColorStop(offset: Double, color: String): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CanvasPattern.scala b/src/main/scala/org/scalajs/dom/CanvasPattern.scala new file mode 100644 index 000000000..b7f5d476b --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CanvasPattern.scala @@ -0,0 +1,17 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The CanvasPattern interface represents an opaque object describing a pattern, based on a image, a canvas or a video, + * created by the CanvasRenderingContext2D.createPattern() method. + */ +@js.native +@JSGlobal +class CanvasPattern extends js.Object diff --git a/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala b/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala new file mode 100644 index 000000000..db0207e84 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CanvasRenderingContext2D.scala @@ -0,0 +1,198 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The 2D rendering context for the drawing surface of a <canvas> element. To get this object, call getContext() + * on a <canvas>, supplying "2d" as the argument: + */ +@js.native +@JSGlobal +class CanvasRenderingContext2D extends js.Object { + + /** Default 10 */ + var miterLimit: Double = js.native + + /** Default value 10px sans-serif */ + var font: String = js.native + + /** With globalAlpha applied this sets how shapes and images are drawn onto the existing bitmap. Possible values: + * source-atop source-in source-out source-over (default) destination-atop destination-in destination-out + * destination-over lighter darker copy xor + */ + var globalCompositeOperation: String = js.native + + /** Type of endings on the end of lines. Possible values: butt (default), round, square */ + var lineCap: String = js.native + + /** Specifies where to start a dasharray on a line. */ + var lineDashOffset: Double = js.native + + /** Color of the shadow. Default fully-transparent black. */ + var shadowColor: String = js.native + + /** Defines the type of corners where two lines meet. Possible values: round, bevel, miter (default) */ + var lineJoin: String = js.native + + /** Horizontal distance the shadow will be offset. Default 0. */ + var shadowOffsetX: Double = js.native + + /** Width of lines. Default 1.0 */ + var lineWidth: Double = js.native + + /** Back-reference to the canvas element for which this context was created. Read only. */ + var canvas: HTMLCanvasElement = js.native + + /** A CSS color, a CanvasGradient or CanvasPattern, to use as a line around shapes. */ + var strokeStyle: js.Any = js.native + + /** Alpha value that is applied to shapes and images before they are composited onto the canvas. Default 1.0 (opaque). + */ + var globalAlpha: Double = js.native + + /** Vertical distance the shadow will be offset. Default 0. */ + var shadowOffsetY: Double = js.native + + /** A CSS color, a CanvasGradient or CanvasPattern, to use as a fill. */ + var fillStyle: js.Any = js.native + + /** Specifies the blurring effect. Default 0 */ + var shadowBlur: Double = js.native + + /** Possible values: start (default), end, left, right or center. */ + var textAlign: String = js.native + + /** Possible values: top, hanging, middle, alphabetic (default), ideographic, bottom */ + var textBaseline: String = js.native + + /** A boolean value indicating whether to smooth scaled images or not. The default value is true. */ + var imageSmoothingEnabled: Boolean = js.native + + /** Restores the drawing style state to the last element on the 'state stack' saved by save(). */ + def restore(): Unit = js.native + + def setTransform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit = js.native + + /** Saves the current drawing style state using a stack so you can revert any change you make to it using restore(). + */ + def save(): Unit = js.native + + def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double, + anticlockwise: Boolean): Unit = js.native + + /** Adds an arc to the path which is centered at (x, y) position with radius r starting at startAngle and ending at + * endAngle going in the given direction by anticlockwise (defaulting to clockwise). + */ + def arc(x: Double, y: Double, radius: Double, startAngle: Double, endAngle: Double): Unit = js.native + + def measureText(text: String): TextMetrics = js.native + + def isPointInPath(x: Double, y: Double, fillRule: String): Boolean = js.native + + /** Reports whether or not the specified point is contained in the current path. */ + def isPointInPath(x: Double, y: Double): Boolean = js.native + + def quadraticCurveTo(cpx: Double, cpy: Double, x: Double, y: Double): Unit = js.native + + def putImageData(imagedata: ImageData, dx: Double, dy: Double, dirtyX: Double = js.native, dirtyY: Double = js.native, + dirtyWidth: Double = js.native, dirtyHeight: Double = js.native): Unit = js.native + + def rotate(angle: Double): Unit = js.native + + def fillText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit = js.native + + /** Moves the origin point of the context to (x, y). */ + def translate(x: Double, y: Double): Unit = js.native + + def scale(x: Double, y: Double): Unit = js.native + + def createRadialGradient(x0: Double, y0: Double, r0: Double, x1: Double, y1: Double, + r1: Double): CanvasGradient = js.native + + /** Connects the last point in the subpath to the x, y coordinates with a straight line. */ + def lineTo(x: Double, y: Double): Unit = js.native + + /** Returns a dash list array containing an even number of non-negative numbers. */ + def getLineDash(): js.Array[Double] = js.native + + /** Fills the subpaths with the current fill style. */ + def fill(): Unit = js.native + + /** Creates a new, blank ImageData object with the specified dimensions. All of the pixels in the new object are + * transparent black. + */ + def createImageData(imageDataOrSw: js.Any, sh: Double = js.native): ImageData = js.native + + def createPattern(image: HTMLElement, repetition: String): CanvasPattern = js.native + + /** Tries to draw a straight line from the current point to the start. If the shape has already been closed or has + * only one point, this function does nothing. + */ + def closePath(): Unit = js.native + + def rect(x: Double, y: Double, w: Double, h: Double): Unit = js.native + + /** Creates a clipping path from the current sub-paths. Everything drawn after clip() is called appears inside the + * clipping path only. For an example, see Clipping paths in the Canvas tutorial. + */ + def clip(fillRule: String = js.native): Unit = js.native + + /** Sets all pixels in the rectangle defined by starting point (x, y) and size (width, height) to transparent black. + */ + def clearRect(x: Double, y: Double, w: Double, h: Double): Unit = js.native + + /** Moves the starting point of a new subpath to the (x, y) coordinates. */ + def moveTo(x: Double, y: Double): Unit = js.native + + /** Returns an ImageData object representing the underlying pixel data for the area of the canvas denoted by the + * rectangle which starts at (sx, sy) and has an sw width and sh height. + */ + def getImageData(sx: Double, sy: Double, sw: Double, sh: Double): ImageData = js.native + + /** Draws a filled rectangle at (x, y) position whose size is determined by width and height. */ + def fillRect(x: Double, y: Double, w: Double, h: Double): Unit = js.native + + def bezierCurveTo(cp1x: Double, cp1y: Double, cp2x: Double, cp2y: Double, x: Double, y: Double): Unit = js.native + + /** Draws the specified image. This method is available in multiple formats, providing a great deal of flexibility in + * its use. + */ + def drawImage(image: HTMLElement, offsetX: Double, offsetY: Double, width: Double = js.native, + height: Double = js.native, canvasOffsetX: Double = js.native, canvasOffsetY: Double = js.native, + canvasImageWidth: Double = js.native, canvasImageHeight: Double = js.native): Unit = js.native + + def transform(m11: Double, m12: Double, m21: Double, m22: Double, dx: Double, dy: Double): Unit = js.native + + /** Strokes the subpaths with the current stroke style. */ + def stroke(): Unit = js.native + + /** Paints a rectangle which has a starting point at (x, y) and has a w width and an h height onto the canvas, using + * the current stroke style. + */ + def strokeRect(x: Double, y: Double, w: Double, h: Double): Unit = js.native + + def setLineDash(segments: js.Array[Double]): Unit = js.native + + def strokeText(text: String, x: Double, y: Double, maxWidth: Double = js.native): Unit = js.native + + /** Starts a new path by resetting the list of sub-paths. Call this method when you want to create a new path. */ + def beginPath(): Unit = js.native + + /** Adds an arc with the given control points and radius, connected to the previous point by a straight line. */ + def arcTo(x1: Double, y1: Double, x2: Double, y2: Double, radius: Double): Unit = js.native + + def createLinearGradient(x0: Double, y0: Double, x1: Double, y1: Double): CanvasGradient = js.native + + /** The ellipse() method creates an elliptical arc centered at (x, y) with the radii radiusX and radiusY. The path + * starts at startAngle and ends at endAngle, and travels in the direction given by anticlockwise (defaulting to + * clockwise). + */ + def ellipse(x: Double, y: Double, radiusX: Double, radiusY: Double, rotation: Double, startAngle: Double, + endAngle: Double, anticlockwise: Boolean = js.native): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/ChannelMergerNode.scala b/src/main/scala/org/scalajs/dom/ChannelMergerNode.scala new file mode 100644 index 000000000..d1e0b1284 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/ChannelMergerNode.scala @@ -0,0 +1,30 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The ChannelMergerNode interface, often used in conjunction with its opposite, ChannelSplitterNode, reunites + * different mono inputs into a single output. Each input is used to fill a channel of the output. This is useful for + * accessing each channels separately, e.g. for performing channel mixing where gain must be separately controlled on + * each channel. + * + * If ChannelMergerNode has one single output, but as many inputs as there are channels to merge; the amount of inputs + * is defined as a parameter of its constructor and the call to AudioContext.createChannelMerger. In the case that no + * value is given, it will default to 6. + * + * Using a ChannelMergerNode, it is possible to create outputs with more channels than the rendering hardware is able + * to process. In that case, when the signal is sent to the AudioContext.listener object, supernumerary channels will + * be ignored. + * + * - Number of inputs: variable; default to 6. + * - Number of outputs: 1 + * - Channel count mode: "max" + * - Channel count: 2 (not used in the default count mode) + * - Channel interpretation: "speakers" + */ +@js.native +trait ChannelMergerNode extends AudioNode diff --git a/src/main/scala/org/scalajs/dom/ChannelSplitterNode.scala b/src/main/scala/org/scalajs/dom/ChannelSplitterNode.scala new file mode 100644 index 000000000..5437c54c5 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/ChannelSplitterNode.scala @@ -0,0 +1,25 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The ChannelSplitterNode interface, often used in conjunction with its opposite, ChannelMergerNode, separates the + * different channels of an audio source into a set of mono outputs. This is useful for accessing each channel + * separately, e.g. for performing channel mixing where gain must be separately controlled on each channel. + * + * If your ChannelSplitterNode always has one single input, the amount of outputs is defined by a parameter on its + * constructor and the call to AudioContext.createChannelSplitter(). In the case that no value is given, it will + * default to 6. If there are less channels in the input than there are outputs, supernumerary outputs are silent. + * + * - Number of inputs: 1 + * - Number of outputs: variable; default to 6. + * - Channel count mode: "max" + * - Channel count: 2 (not used in the default count mode) + * - Channel interpretation: "speakers" + */ +@js.native +trait ChannelSplitterNode extends AudioNode diff --git a/src/main/scala/org/scalajs/dom/CharacterData.scala b/src/main/scala/org/scalajs/dom/CharacterData.scala new file mode 100644 index 000000000..1310e3d0d --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CharacterData.scala @@ -0,0 +1,50 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The CharacterData abstract interface represents a Node object that contains characters. This is an abstract + * interface, meaning there aren't any object of type CharacterData: it is implemented by other interfaces, like Text, + * Comment, or ProcessingInstruction which aren't abstract. + */ +@js.native +@JSGlobal +abstract class CharacterData extends Node with NonDocumentTypeChildNode { + + /** Returns an unsigned long representing the size of the string contained in CharacterData.data. */ + def length: Int = js.native + + /** Is a DOMString representing the textual data contained in this object. */ + var data: String = js.native + + /** Removes the specified amount of characters, starting at the specified offset, from the CharacterData.data string; + * when this method returns, data contains the shortened DOMString. + */ + def deleteData(offset: Int, count: Int): Unit = js.native + + /** Replaces the specified amount of characters, starting at the specified offset, with the specified DOMString; when + * this method returns, data contains the modified DOMString. + */ + def replaceData(offset: Int, count: Int, arg: String): Unit = js.native + + /** Appends the given DOMString to the CharacterData.data string; when this method returns, data contains the + * concatenated DOMString. + */ + def appendData(arg: String): Unit = js.native + + /** Inserts the specified characters, at the specified offset, in the CharacterData.data string; when this method + * returns, data contains the modified DOMString. + */ + def insertData(offset: Int, arg: String): Unit = js.native + + /** Returns a DOMString containing the part of CharacterData.data of the specified length and starting at the + * specified offset. + */ + def substringData(offset: Int, count: Int): String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Chunk.scala b/src/main/scala/org/scalajs/dom/Chunk.scala new file mode 100644 index 000000000..a2d3417a1 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Chunk.scala @@ -0,0 +1,13 @@ +package org.scalajs.dom + +import scala.scalajs.js + +/** See [[https://streams.spec.whatwg.org/#chunk ¶2 Model]] but mostly the examples in the whatwg streams spec */ +@js.native +trait Chunk[+T] extends js.Object { + + /** The value of the chunk. */ + def value: T = js.native + + def done: Boolean = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Clipboard.scala b/src/main/scala/org/scalajs/dom/Clipboard.scala new file mode 100644 index 000000000..e07c4ed6d --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Clipboard.scala @@ -0,0 +1,45 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The Clipboard interface implements the Clipboard API, providing—if the user grants permission—both read and write + * access to the contents of the system clipboard. The Clipboard API can be used to implement cut, copy, and paste + * features within a web application. + * + * The system clipboard is exposed through the global Navigator.clipboard property + * + * Clipboard is based on the EventTarget interface, and includes its methods. + */ +@js.native +trait Clipboard extends EventTarget { + + /** The read() method of the Clipboard interface requests a copy of the clipboard's contents, delivering the data to + * the returned Promise when the promise is resolved. Unlike readText(), the read() method can return arbitrary data, + * such as images. + * + * To read from the clipboard, you must first have the "clipboard-read" permission. + */ + def read(): js.Promise[DataTransfer] = js.native + + /** The readText() method returns a Promise which resolves with a copy of the textual contents of the system + * clipboard. + */ + def readText(): js.Promise[String] = js.native + + /** The write() method writes arbitrary data, such as images, to the clipboard. This can be used to implement cut and + * copy functionality. + * + * Before you can write to the clipboard, you need to use the Permissions API to get the "clipboard-write" + * permission. + */ + def write(data: DataTransfer): js.Promise[Unit] = js.native + + /** The writeText() method writes the specified text string to the system clipboard. */ + def writeText(newClipText: String): js.Promise[Unit] = js.native +} diff --git a/src/main/scala/org/scalajs/dom/ClipboardEvent.scala b/src/main/scala/org/scalajs/dom/ClipboardEvent.scala new file mode 100644 index 000000000..f3722952f --- /dev/null +++ b/src/main/scala/org/scalajs/dom/ClipboardEvent.scala @@ -0,0 +1,24 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The ClipboardEvent interface represents events providing information related to modification of the clipboard, that + * is cut, copy, and paste events. + */ +@js.native +@JSGlobal +class ClipboardEvent(typeArg: String, init: js.UndefOr[ClipboardEventInit] = js.undefined) + extends Event(typeArg, init) { + + /** Is a DataTransfer object containing the data affected by the user-initialed cut, copy, or paste operation, along + * with its MIME type. + */ + def clipboardData: DataTransfer = js.native +} diff --git a/src/main/scala/org/scalajs/dom/ClipboardEventInit.scala b/src/main/scala/org/scalajs/dom/ClipboardEventInit.scala new file mode 100644 index 000000000..724c5b38f --- /dev/null +++ b/src/main/scala/org/scalajs/dom/ClipboardEventInit.scala @@ -0,0 +1,18 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +trait ClipboardEventInit extends EventInit { + + /** The data for this clipboard event. */ + var data: js.UndefOr[String] = js.undefined + + /** The MIME type of the data. */ + var dataType: js.UndefOr[String] = js.undefined +} diff --git a/src/main/scala/org/scalajs/dom/CloseEvent.scala b/src/main/scala/org/scalajs/dom/CloseEvent.scala new file mode 100644 index 000000000..5800fad25 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CloseEvent.scala @@ -0,0 +1,27 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** A CloseEvent is sent to clients using WebSockets when the connection is closed. This is delivered to the listener + * indicated by the WebSocket object's onclose attribute. + */ +@js.native +trait CloseEvent extends Event { + + /** Indicates whether or not the connection was cleanly closed. */ + def wasClean: Boolean = js.native + + /** A string indicating the reason the server closed the connection. This is specific to the particular server and + * sub-protocol. + */ + def reason: String = js.native + + /** The WebSocket connection close code provided by the server. See Close codes for possible values. */ + def code: Int = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Comment.scala b/src/main/scala/org/scalajs/dom/Comment.scala new file mode 100644 index 000000000..baee5def9 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Comment.scala @@ -0,0 +1,20 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The Comment interface represents textual notations within markup; although it is generally not visually shown, such + * comments are available to be read in the source view. Comments are represented in HTML and XML as content between + * '<!--' and '-->'. In XML, the character sequence '--' cannot be used within a comment. + */ +@js.native +@JSGlobal +class Comment extends CharacterData { + var text: String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CompositionEvent.scala b/src/main/scala/org/scalajs/dom/CompositionEvent.scala new file mode 100644 index 000000000..e2506e079 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CompositionEvent.scala @@ -0,0 +1,28 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The DOM CompositionEvent represents events that occur due to the user indirectly entering text. */ +@js.native +@JSGlobal +class CompositionEvent(typeArg: String, init: js.UndefOr[CompositionEventInit]) extends UIEvent(typeArg, init) { + + /** For compositionstart events, this is the currently selected text that will be replaced by the string being + * composed. This value doesn't change even if content changes the selection range; rather, it indicates the string + * that was selected when composition started. For compositionupdate, this is the string as it stands currently as + * editing is ongoing. For compositionend events, this is the string as committed to the editor. Read only. + */ + def data: String = js.native + + /** The locale of current input method (for example, the keyboard layout locale if the composition is associated with + * IME). Read only. + */ + def locale: String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CompositionEventInit.scala b/src/main/scala/org/scalajs/dom/CompositionEventInit.scala new file mode 100644 index 000000000..ce7427931 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CompositionEventInit.scala @@ -0,0 +1,14 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +trait CompositionEventInit extends UIEventInit { + var data: js.UndefOr[String] = js.undefined + var locale: js.UndefOr[String] = js.undefined +} diff --git a/src/main/scala/org/scalajs/dom/Console.scala b/src/main/scala/org/scalajs/dom/Console.scala new file mode 100644 index 000000000..2a40055db --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Console.scala @@ -0,0 +1,111 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.| + +/** The console object provides access to the browser's debugging console. The specifics of how it works vary from + * browser to browser, but there is a de facto set of features that are typically provided. + */ +@js.native +trait Console extends js.Object { + + /** Outputs an informational message to the Web Console. In Firefox, a small "i" icon is displayed next to these items + * in the Web Console's log. + */ + def info(message: Any, optionalParams: Any*): Unit = js.native + + def profile(reportName: String = js.native): Unit = js.native + + def assert(test: Boolean, message: String, optionalParams: Any*): Unit = js.native + + def clear(): Unit = js.native + + /** Displays an interactive list of the properties of the specified JavaScript object. The output is presented as a + * hierarchical listing with disclosure triangles that let you see the contents of child objects. + */ + def dir(value: Any, optionalParams: Any*): Unit = js.native + + /** Displays an interactive tree of the descendant elements of the specified XML/HTML element. If it is not possible + * to display as an element the JavaScript Object view is shown instead. The output is presented as a hierarchical + * listing of expandable nodes that let you see the contents of child nodes. + */ + def dirxml(value: Any): Unit = js.native + + /** Outputs a warning message. You may use string substitution and additional arguments with this method. See Using + * string substitutions. + */ + def warn(message: Any, optionalParams: Any*): Unit = js.native + + /** Outputs an error message. You may use string substitution and additional arguments with this method. See Using + * string substitutions. + */ + def error(message: Any, optionalParams: Any*): Unit = js.native + + /** For general output of logging information. You may use string substitution and additional arguments with this + * method. See Using string substitutions. + */ + def log(message: Any, optionalParams: Any*): Unit = js.native + + /** Outputs a debug message. You may use string substitution and additional arguments with this method. See Using + * string substitutions. + */ + def debug(message: Any, optionalParams: Any*): Unit = js.native + + /** Displays tabular data as a table. + * + * This function takes one mandatory argument data, which must be an array or an object, and one additional optional + * parameter columns. + * + * It logs data as a table. Each element in the array (or enumerable property if data is an object) will be a row in + * the table. + * + * The first column in the table will be labeled (index). If data is an array, then its values will be the array + * indices. If data is an object, then its values will be the property names. Note that (in Firefox) console.table is + * limited to displaying 1000 rows (first row is the labeled index). + */ + def table(data: js.Object | js.Array[_], columns: js.UndefOr[Int] = js.native): Unit = js.native + + /** Outputs a stack trace to the Web Console. */ + def trace(): Unit = js.native + + def profileEnd(): Unit = js.native + + /** Starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have + * up to 10,000 timers running on a given page. When you call console.timeEnd() with the same name, the browser will + * output the time, in milliseconds, that elapsed since the timer was started. + */ + def time(label: String): Unit = js.native + + /** Stops a timer that was previously started by calling console.time(). */ + def timeEnd(label: String): Unit = js.native + + /** Logs the number of times that this particular call to count() has been called. This function takes an optional + * argument label. + */ + def count(label: String = js.native): Unit = js.native + + /** Resets the counter. This function takes an optional argument label. */ + def countReset(label: String = js.native): Unit = js.native + + /** Creates a new inline group in the Web Console log. This indents following console messages by an additional level, + * until console.groupEnd() is called. + */ + def group(label: js.UndefOr[String] = js.native): Unit = js.native + + /** Creates a new inline group in the Web Console. Unlike console.group(), however, the new group is created + * collapsed. The user will need to use the disclosure button next to it to expand it, revealing the entries created + * in the group. + * + * Call console.groupEnd() to back out to the parent group. + */ + def groupCollapsed(label: js.UndefOr[String] = js.native): Unit = js.native + + /** Exits the current inline group in the Web Console. */ + def groupEnd(): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/ConvertToBlobOptions.scala b/src/main/scala/org/scalajs/dom/ConvertToBlobOptions.scala new file mode 100644 index 000000000..39e72f482 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/ConvertToBlobOptions.scala @@ -0,0 +1,9 @@ +package org.scalajs.dom + +import scala.scalajs.js + +trait ConvertToBlobOptions extends js.Object { + var `type`: js.UndefOr[String] = js.undefined + + var quality: js.UndefOr[Double] = js.undefined +} diff --git a/src/main/scala/org/scalajs/dom/ConvolverNode.scala b/src/main/scala/org/scalajs/dom/ConvolverNode.scala new file mode 100644 index 000000000..53a4073f4 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/ConvolverNode.scala @@ -0,0 +1,34 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The ConvolverNode interface is an AudioNode that performs a Linear Convolution on a given AudioBuffer, often used to + * achieve a reverb effect. A ConvolverNode always has exactly one input and one output. + * + * Note: For more information on the theory behind Linear Convolution, see the W3C Web Audio API spec section, Linear + * Effects Using Convolution, or read the The Wikipedia Linear Convolution Article. + * + * - Number of inputs: 1 + * - Number of outputs: 1 + * - Channel count mode: "clamped-max" + * - Channel count: 2 + * - Channel interpretation: "speakers" + */ +@js.native +trait ConvolverNode extends AudioNode { + + /** A mono, stereo, or 4-channel AudioBuffer containing the (possibly multichannel) impulse response used by the + * ConvolverNode to create the reverb effect. + */ + var buffer: AudioBuffer = js.native + + /** A boolean that controls whether the impulse response from the buffer will be scaled by an equal-power + * normalization when the buffer attribute is set, or not. + */ + var normalize: Boolean = js.native +} diff --git a/src/main/scala/org/scalajs/dom/Coordinates.scala b/src/main/scala/org/scalajs/dom/Coordinates.scala new file mode 100644 index 000000000..2ce99be80 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Coordinates.scala @@ -0,0 +1,55 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The Coordinates interface represents the position and attitude of the device on Earth, as well as the accuracy with + * which these data are computed. + */ +@js.native +trait Coordinates extends js.Object { + + /** The Coordinates.altitudeAccuracy read-only property is a strictly positive double representing the accuracy, with + * a 95% confidence level, of the altitude expressed in meters. This value is null if the implementation doesn't + * support measuring altitude. + */ + def altitudeAccuracy: Double = js.native + + /** The Coordinates.longitude read-only property is a double representing the longitude of the position in decimal + * degrees. + */ + def longitude: Double = js.native + + /** The Coordinates.latitude read-only property is a double representing the latitude of the position in decimal + * degrees. + */ + def latitude: Double = js.native + + /** The Coordinates.speed read-only property is a double representing the velocity of the device in meters per second. + * This value is null if the implementation is not able to measure it. + */ + def speed: Double = js.native + + /** The Coordinates.heading read-only property is a double representing the direction in which the device is + * traveling. This value, specified in degrees, indicates how far off from heading due north the device is. 0 degrees + * represents true true north, and the direction is determined clockwise (which means that east is 90 degrees and + * west is 270 degrees). If Coordinates.speed is 0, heading is NaN. If the device is not able to provide heading + * information, this value is null. + */ + def heading: Double = js.native + + /** The Coordinates.altitude read-only property is a double representing the altitude of the position in meters, + * relative to sea level. This value is null if the implementation cannot provide this data. + */ + def altitude: Double = js.native + + /** The Coordinates.accuracy read-only property is a strictly positive double representing the accuracy, with a 95% + * confidence level, of the Coordinates.latitude and Coordinates.longitude properties expressed in meters. + */ + def accuracy: Double = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CreateImageBitmapOptions.scala b/src/main/scala/org/scalajs/dom/CreateImageBitmapOptions.scala new file mode 100644 index 000000000..201bd91b8 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CreateImageBitmapOptions.scala @@ -0,0 +1,12 @@ +package org.scalajs.dom + +import scala.scalajs.js + +trait CreateImageBitmapOptions extends js.Object { + var imageOrientation: js.UndefOr[String] = js.undefined + var premultiplyAlpha: js.UndefOr[String] = js.undefined + var colorSpaceConversion: js.UndefOr[String] = js.undefined + var resizeWidth: js.UndefOr[Double] = js.undefined + var resizeHeight: js.UndefOr[Double] = js.undefined + var resizeQuality: js.UndefOr[String] = js.undefined +} diff --git a/src/main/scala/org/scalajs/dom/CustomEvent.scala b/src/main/scala/org/scalajs/dom/CustomEvent.scala new file mode 100644 index 000000000..0441a0d3f --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CustomEvent.scala @@ -0,0 +1,19 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The DOM CustomEvent are events initialized by an application for any purpose. */ +@js.native +@JSGlobal +class CustomEvent(typeArg: String, init: js.UndefOr[CustomEventInit]) extends Event(typeArg, init) { + + /** The data passed when initializing the event. */ + def detail: Any = js.native +} diff --git a/src/main/scala/org/scalajs/dom/CustomEventInit.scala b/src/main/scala/org/scalajs/dom/CustomEventInit.scala new file mode 100644 index 000000000..a66615ba2 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/CustomEventInit.scala @@ -0,0 +1,13 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +trait CustomEventInit extends EventInit { + var detail: js.UndefOr[Any] = js.undefined +} diff --git a/src/main/scala/org/scalajs/dom/DOMException.scala b/src/main/scala/org/scalajs/dom/DOMException.scala new file mode 100644 index 000000000..5b505226b --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMException.scala @@ -0,0 +1,53 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The DOMException interface represents an anormal event happening when a method or a property is used. */ +@js.native +@JSGlobal +class DOMException extends js.Object { + + /** Returns a DOMString representing a message or description associated with the given error name. */ + def message: String = js.native + + /** Returns a DOMString that contains one of the strings associated with an error name. */ + def name: String = js.native +} + +@js.native +@JSGlobal +object DOMException extends js.Object { + + val INDEX_SIZE_ERR: Int = js.native + val DOMSTRING_SIZE_ERR: Int = js.native + val HIERARCHY_REQUEST_ERR: Int = js.native + val WRONG_DOCUMENT_ERR: Int = js.native + val INVALID_CHARACTER_ERR: Int = js.native + val NO_DATA_ALLOWED_ERR: Int = js.native + val NO_MODIFICATION_ALLOWED_ERR: Int = js.native + val NOT_FOUND_ERR: Int = js.native + val NOT_SUPPORTED_ERR: Int = js.native + val INUSE_ATTRIBUTE_ERR: Int = js.native + val INVALID_STATE_ERR: Int = js.native + val SYNTAX_ERR: Int = js.native + val INVALID_MODIFICATION_ERR: Int = js.native + val NAMESPACE_ERR: Int = js.native + val INVALID_ACCESS_ERR: Int = js.native + val VALIDATION_ERR: Int = js.native + val TYPE_MISMATCH_ERR: Int = js.native + val SECURITY_ERR: Int = js.native + val NETWORK_ERR: Int = js.native + val ABORT_ERR: Int = js.native + val URL_MISMATCH_ERR: Int = js.native + val QUOTA_EXCEEDED_ERR: Int = js.native + val TIMEOUT_ERR: Int = js.native + val INVALID_NODE_TYPE_ERR: Int = js.native + val DATA_CLONE_ERR: Int = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DOMImplementation.scala b/src/main/scala/org/scalajs/dom/DOMImplementation.scala new file mode 100644 index 000000000..eb0a56d9d --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMImplementation.scala @@ -0,0 +1,35 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The DOMImplementation interface represent an object providing methods which are not dependent on any particular + * document. Such an object is returned by the Document.implementation property. + */ +@js.native +@JSGlobal +class DOMImplementation extends js.Object { + + /** « DOM Reference « DOMImplementation */ + def createDocumentType(qualifiedName: String, publicId: String, systemId: String): DocumentType = js.native + + /** « DOM Reference « DOMImplementation */ + def createDocument(namespaceURI: String, qualifiedName: String, doctype: DocumentType): Document = js.native + + def hasFeature(feature: String, version: String): Boolean = js.native + + /** Returns a Boolean indicating if a given feature is supported or not. This function is unreliable and kept for + * compatibility purpose alone: except for SVG-related queries, it always returns true. Old browsers are very + * inconsistent in their behavior. + */ + def hasFeature(feature: String): Boolean = js.native + + /** Creates and returns an HTML Document. */ + def createHTMLDocument(title: String): Document = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DOMList.scala b/src/main/scala/org/scalajs/dom/DOMList.scala new file mode 100644 index 000000000..2e0800ea3 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMList.scala @@ -0,0 +1,47 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.language.implicitConversions +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +trait DOMList[+T] extends js.Object { + def length: Int = js.native + + @JSBracketAccess + def apply(index: Int): T = js.native +} + +object DOMList { + + implicit def domListAsSeq[T](domList: DOMList[T]): scala.collection.Seq[T] = + new DOMListSeq(domList) + + private final class DOMListSeq[+T](domList: DOMList[T]) extends scala.collection.Seq[T] { + + def length: Int = domList.length + + def apply(x: Int): T = domList(x) + + def iterator: Iterator[T] = new DOMListIterator(domList) + } + + private final class DOMListIterator[+T](domList: DOMList[T]) extends Iterator[T] { + + private[this] var index = 0 + + def hasNext: Boolean = index < domList.length + + def next(): T = { + val res = domList(index) + index += 1 + res + } + } +} diff --git a/src/main/scala/org/scalajs/dom/DOMParser.scala b/src/main/scala/org/scalajs/dom/DOMParser.scala index 6265f015b..37bd8a225 100644 --- a/src/main/scala/org/scalajs/dom/DOMParser.scala +++ b/src/main/scala/org/scalajs/dom/DOMParser.scala @@ -26,16 +26,3 @@ class DOMParser extends js.Object { */ def parseFromString(string: String, mimeType: MIMEType): Document = js.native } - -@js.native -sealed trait MIMEType extends js.Any - -object MIMEType { - val `text/html` = "text/html".asInstanceOf[MIMEType] - val `text/xml` = "text/xml".asInstanceOf[MIMEType] - val `application/xml` = "application/xml".asInstanceOf[MIMEType] - - val `application/xhtml+xml` = - "application/xhtml+xml".asInstanceOf[MIMEType] - val `image/svg+xml` = "image/svg+xml".asInstanceOf[MIMEType] -} diff --git a/src/main/scala/org/scalajs/dom/DOMRect.scala b/src/main/scala/org/scalajs/dom/DOMRect.scala new file mode 100644 index 000000000..3ad89901d --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMRect.scala @@ -0,0 +1,21 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +class DOMRect extends js.Object { + var left: Double = js.native + var width: Double = js.native + var right: Double = js.native + var top: Double = js.native + var bottom: Double = js.native + var height: Double = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DOMRectList.scala b/src/main/scala/org/scalajs/dom/DOMRectList.scala new file mode 100644 index 000000000..ab24d3ea2 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMRectList.scala @@ -0,0 +1,14 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +class DOMRectList extends DOMList[DOMRect] diff --git a/src/main/scala/org/scalajs/dom/DOMSettableTokenList.scala b/src/main/scala/org/scalajs/dom/DOMSettableTokenList.scala new file mode 100644 index 000000000..f8acdf032 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMSettableTokenList.scala @@ -0,0 +1,14 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +@js.native +trait DOMSettableTokenList extends DOMTokenList { + def value: String = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DOMStringList.scala b/src/main/scala/org/scalajs/dom/DOMStringList.scala new file mode 100644 index 000000000..a233d5846 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMStringList.scala @@ -0,0 +1,19 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** A type returned by DOMConfiguration.parameterNames which contains a list of DOMString (strings). */ +@js.native +@JSGlobal +class DOMStringList private[this] () extends DOMList[String] { + def item(index: Int): String = js.native + + def contains(str: String): Boolean = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DOMTokenList.scala b/src/main/scala/org/scalajs/dom/DOMTokenList.scala new file mode 100644 index 000000000..ba72172e2 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DOMTokenList.scala @@ -0,0 +1,30 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** This type represents a set of space-separated tokens. Commonly returned by HTMLElement.classList, + * HTMLLinkElement.relList, HTMLAnchorElement.relList or HTMLAreaElement.relList. It is indexed beginning with 0 as + * with JavaScript arrays. DOMTokenList is always case-sensitive. + */ +@js.native +@JSGlobal +class DOMTokenList private[this] extends DOMList[String] { + def item(index: Int): String = js.native + + def contains(token: String): Boolean = js.native + + def remove(token: String): Unit = js.native + + def toggle(token: String): Boolean = js.native + + def toggle(token: String, force: Boolean): Boolean = js.native + + def add(token: String): Unit = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DataTransfer.scala b/src/main/scala/org/scalajs/dom/DataTransfer.scala new file mode 100644 index 000000000..e4971ece1 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DataTransfer.scala @@ -0,0 +1,83 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The DataTransfer object is used to hold the data that is being dragged during a drag and drop operation. It may hold + * one or more data items, each of one or more data types. For more information about drag and drop, see Drag and Drop. + * + * This object is available from the dataTransfer property of all drag events. It cannot be created separately. + */ +@js.native +trait DataTransfer extends js.Object { + + /** Specifies the effects that are allowed for this drag. You may set this in the dragstart event to set the desired + * effects for the source, and within the dragenter and dragover events to set the desired effects for the target. + * The value is not used for other events. + * + * See [[DragEffect]] for possible values. + */ + var effectAllowed: String = js.native + + /** The actual effect that will be used, and should always be one of the possible values of effectAllowed. + * + * See [[DragEffect]] for possible values. + */ + var dropEffect: String = js.native + + /** Remove the data associated with a given type. The type argument is optional. If the type is empty or not + * specified, the data associated with all types is removed. If data for the specified type does not exist, or the + * data transfer contains no data, this method will have no effect. + */ + def clearData(format: String = js.native): Unit = js.native + + /** Set the data for a given type. If data for the type does not exist, it is added at the end, such that the last + * item in the types list will be the new format. If data for the type already exists, the existing data is replaced + * in the same position. That is, the order of the types list is not changed when replacing data of the same type. + */ + def setData(format: String, data: String): Unit = js.native + + /** Set the image to be used for dragging if a custom one is desired. Most of the time, this would not be set, as a + * default image is created from the node that was dragged. + * + * If the node is an HTML img element, an HTML canvas element or a XUL image element, the image data is used. + * Otherwise, image should be a visible node and the drag image will be created from this. If image is null, any + * custom drag image is cleared and the default is used instead. + * + * The coordinates specify the offset into the image where the mouse cursor should be. To center the image, for + * instance, use values that are half the width and height of the image. + * + * @param image + * An element to use as the drag feedback image. + * @param x + * Horizontal offset within the image. + * @param y + * Vertical offset within the image. + */ + def setDragImage(image: Element, x: Double, y: Double): Unit = js.native + + /** Retrieves the data for a given type, or an empty string if data for that type does not exist or the data transfer + * contains no data. + * + * A security error will occur if you attempt to retrieve data during a drag that was set from a different domain, or + * the caller would otherwise not have access to. This data will only be available once a drop occurs during the drop + * event. + */ + def getData(format: String): String = js.native + + /** An array of the drag data formats (as strings) that were set in the dragstart event. + * + * The order of the formats is the same order as the data included in the drag operation. + * + * The formats are Unicode strings giving the type or format of the data, generally given by a MIME type. Some values + * that are not MIME types are special-cased for legacy reasons (for example "text"). + */ + def types: js.Array[String] = js.native + + def files: FileList = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DedicatedWorkerGlobalScope.scala b/src/main/scala/org/scalajs/dom/DedicatedWorkerGlobalScope.scala new file mode 100644 index 000000000..c6f680d42 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DedicatedWorkerGlobalScope.scala @@ -0,0 +1,46 @@ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** The DedicatedWorkerGlobalScope object (the Worker global scope) is accessible through the self keyword. Some + * additional global functions, namespaces objects, and constructors, not typically associated with the worker global + * scope, but available on it, are listed in the JavaScript Reference. See also: Functions available to workers. + */ +@js.native +trait DedicatedWorkerGlobalScope extends WorkerGlobalScope { + + /** The onmessage property of the DedicatedWorkerGlobalScope interface represents an EventHandler to be called when + * the message event occurs and bubbles through the Worker — i.e. when a message is sent to the worker using the + * Worker.postMessage method. + */ + var onmessage: js.Function1[MessageEvent, _] = js.native + + /** The postMessage() method of the DedicatedWorkerGlobalScope interface sends a message to the main thread that + * spawned it. This accepts a single parameter, which is the data to send to the worker. The data may be any value or + * JavaScript object handled by the structured clone algorithm, which includes cyclical references. + * + * The main scope that spawned the worker can send back information to the thread that spawned it using the + * Worker.postMessage method. + * + * @param message + * The object to deliver to the main thread; this will be in the data field in the event delivered to the + * Worker.onmessage handler. This may be any value or JavaScript object handled by the structured clone algorithm, + * which includes cyclical references. + * @param transferList + * An optional array of Transferable objects to transfer ownership of. If the ownership of an object is + * transferred, it becomes unusable in the context it was sent from and it becomes available only to the main + * thread it was sent to. + * + * Only MessagePort and ArrayBuffer objects can be transferred. + */ + def postMessage(message: js.Any, transferList: js.UndefOr[js.Array[Transferable]] = js.native): Unit = js.native +} + +@js.native +@JSGlobalScope +object DedicatedWorkerGlobalScope extends js.Object { + + /** Returns an object reference to the DedicatedWorkerGlobalScope object itself. */ + def self: DedicatedWorkerGlobalScope = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DelayNode.scala b/src/main/scala/org/scalajs/dom/DelayNode.scala new file mode 100644 index 000000000..a1b806bf9 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DelayNode.scala @@ -0,0 +1,28 @@ +/** Documentation is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API and available + * under the Creative Commons Attribution-ShareAlike v2.5 or later. http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js + +/** The DelayNode interface represents a delay-line; an AudioNode audio-processing module that causes a delay between + * the arrival of an input data and its propagation to the output. A DelayNode always has exactly one input and one + * output, both with the same amount of channels. + * + * When creating a graph that has a cycle, it is mandatory to have at least one DelayNode in the cycle, or the nodes + * taking part in the cycle will be muted. + * + * - Number of inputs: 1 + * - Number of outputs: 1 + * - Channel count mode: "max" + * - Channel count: 2 (not used in the default count mode) + * - Channel interpretation: "speakers" + */ +@js.native +trait DelayNode extends AudioNode { + + /** Is an a-rate AudioParam representing the amount of delay to apply. */ + val delayTime: AudioParam = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DeviceAcceleration.scala b/src/main/scala/org/scalajs/dom/DeviceAcceleration.scala new file mode 100644 index 000000000..fedef90e5 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DeviceAcceleration.scala @@ -0,0 +1,15 @@ +package org.scalajs.dom + +import scala.scalajs.js + +trait DeviceAcceleration extends js.Any { + + /** The acceleration in x. In m/s2. */ + val x: Double + + /** The acceleration in y. In m/s2. */ + val y: Double + + /** The acceleration in z. In m/s2. */ + val z: Double +} diff --git a/src/main/scala/org/scalajs/dom/DeviceMotionEvent.scala b/src/main/scala/org/scalajs/dom/DeviceMotionEvent.scala new file mode 100644 index 000000000..aac86d1ca --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DeviceMotionEvent.scala @@ -0,0 +1,22 @@ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +class DeviceMotionEvent(typeArg: String, init: js.UndefOr[DeviceMotionEventInit] = js.undefined) + extends Event(typeArg, init) { + + /** Device acceleration with gravity removed. */ + val acceleration: DeviceAcceleration = js.native + + /** Device acceleration including the force of gravity. */ + val accelerationIncludingGravity: DeviceAcceleration = js.native + + /** The rate of rotation. */ + val rotationRate: DeviceRotationRate = js.native + + /** The sampling rate in seconds that data is received from the hardware. */ + val interval: Double = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DeviceMotionEventInit.scala b/src/main/scala/org/scalajs/dom/DeviceMotionEventInit.scala new file mode 100644 index 000000000..a3e845f2e --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DeviceMotionEventInit.scala @@ -0,0 +1,19 @@ +package org.scalajs.dom + +import scala.scalajs.js + +trait DeviceMotionEventInit extends EventInit { + + /** Device acceleration with gravity removed. */ + val acceleration: js.UndefOr[DeviceAcceleration] = js.undefined + + /** Device acceleration including the force of gravity. */ + val accelerationIncludingGravity: js.UndefOr[DeviceAcceleration] = + js.undefined + + /** The rate of rotation. */ + val rotationRate: js.UndefOr[DeviceRotationRate] = js.undefined + + /** The sampling rate in seconds that data is received from the hardware. */ + val interval: js.UndefOr[Double] = js.undefined +} diff --git a/src/main/scala/org/scalajs/dom/DeviceOrientation.scala b/src/main/scala/org/scalajs/dom/DeviceOrientation.scala deleted file mode 100644 index 668235f16..000000000 --- a/src/main/scala/org/scalajs/dom/DeviceOrientation.scala +++ /dev/null @@ -1,99 +0,0 @@ -package org.scalajs.dom - -import scala.scalajs.js -import scala.scalajs.js.annotation._ - -@js.native -@JSGlobal -class DeviceOrientationEvent(typeArg: String, init: js.UndefOr[DeviceOrientationEventInit]) - extends Event(typeArg, init) { - - /** Z-Axis rotation in degrees. */ - val alpha: Double = js.native - - /** X-Axis rotation in degrees. */ - val beta: Double = js.native - - /** Y-Axis rotation in degrees. */ - val gamma: Double = js.native - - /** If true, this event data is has been produced using sensor fusion from the magnometer and other sensors. When - * false- only the gyroscope has been used. - */ - val absolute: Boolean = js.native -} - -trait DeviceOrientationEventInit extends EventInit { - - /** Z-Axis rotation in degrees. */ - var alpha: js.UndefOr[Double] = js.undefined - - /** X-Axis rotation in degrees. */ - var beta: js.UndefOr[Double] = js.undefined - - /** Y-Axis rotation in degrees. */ - var gamma: js.UndefOr[Double] = js.undefined - - /** If true, this event data is has been produced using sensor fusion from the magnometer and other sensors. When - * false- only the gyroscope has been used. - */ - var absolute: js.UndefOr[Boolean] = js.undefined -} - -trait DeviceAcceleration extends js.Any { - - /** The acceleration in x. In m/s2. */ - val x: Double - - /** The acceleration in y. In m/s2. */ - val y: Double - - /** The acceleration in z. In m/s2. */ - val z: Double -} - -trait DeviceRotationRate extends js.Any { - - /** The z axis rotation in degrees per second. */ - val alpha: Double - - /** The x axis rotation in degrees per second. */ - val beta: Double - - /** The y axis rotation in degrees per second. */ - val gamma: Double -} - -@js.native -@JSGlobal -class DeviceMotionEvent(typeArg: String, init: js.UndefOr[DeviceMotionEventInit] = js.undefined) - extends Event(typeArg, init) { - - /** Device acceleration with gravity removed. */ - val acceleration: DeviceAcceleration = js.native - - /** Device acceleration including the force of gravity. */ - val accelerationIncludingGravity: DeviceAcceleration = js.native - - /** The rate of rotation. */ - val rotationRate: DeviceRotationRate = js.native - - /** The sampling rate in seconds that data is received from the hardware. */ - val interval: Double = js.native -} - -trait DeviceMotionEventInit extends EventInit { - - /** Device acceleration with gravity removed. */ - val acceleration: js.UndefOr[DeviceAcceleration] = js.undefined - - /** Device acceleration including the force of gravity. */ - val accelerationIncludingGravity: js.UndefOr[DeviceAcceleration] = - js.undefined - - /** The rate of rotation. */ - val rotationRate: js.UndefOr[DeviceRotationRate] = js.undefined - - /** The sampling rate in seconds that data is received from the hardware. */ - val interval: js.UndefOr[Double] = js.undefined -} diff --git a/src/main/scala/org/scalajs/dom/DeviceOrientationEvent.scala b/src/main/scala/org/scalajs/dom/DeviceOrientationEvent.scala new file mode 100644 index 000000000..464aa16ee --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DeviceOrientationEvent.scala @@ -0,0 +1,24 @@ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +@js.native +@JSGlobal +class DeviceOrientationEvent(typeArg: String, init: js.UndefOr[DeviceOrientationEventInit]) + extends Event(typeArg, init) { + + /** Z-Axis rotation in degrees. */ + val alpha: Double = js.native + + /** X-Axis rotation in degrees. */ + val beta: Double = js.native + + /** Y-Axis rotation in degrees. */ + val gamma: Double = js.native + + /** If true, this event data is has been produced using sensor fusion from the magnometer and other sensors. When + * false- only the gyroscope has been used. + */ + val absolute: Boolean = js.native +} diff --git a/src/main/scala/org/scalajs/dom/DeviceOrientationEventInit.scala b/src/main/scala/org/scalajs/dom/DeviceOrientationEventInit.scala new file mode 100644 index 000000000..754f69132 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DeviceOrientationEventInit.scala @@ -0,0 +1,20 @@ +package org.scalajs.dom + +import scala.scalajs.js + +trait DeviceOrientationEventInit extends EventInit { + + /** Z-Axis rotation in degrees. */ + var alpha: js.UndefOr[Double] = js.undefined + + /** X-Axis rotation in degrees. */ + var beta: js.UndefOr[Double] = js.undefined + + /** Y-Axis rotation in degrees. */ + var gamma: js.UndefOr[Double] = js.undefined + + /** If true, this event data is has been produced using sensor fusion from the magnometer and other sensors. When + * false- only the gyroscope has been used. + */ + var absolute: js.UndefOr[Boolean] = js.undefined +} diff --git a/src/main/scala/org/scalajs/dom/DeviceRotationRate.scala b/src/main/scala/org/scalajs/dom/DeviceRotationRate.scala new file mode 100644 index 000000000..48e316bcc --- /dev/null +++ b/src/main/scala/org/scalajs/dom/DeviceRotationRate.scala @@ -0,0 +1,15 @@ +package org.scalajs.dom + +import scala.scalajs.js + +trait DeviceRotationRate extends js.Any { + + /** The z axis rotation in degrees per second. */ + val alpha: Double + + /** The x axis rotation in degrees per second. */ + val beta: Double + + /** The y axis rotation in degrees per second. */ + val gamma: Double +} diff --git a/src/main/scala/org/scalajs/dom/Document.scala b/src/main/scala/org/scalajs/dom/Document.scala new file mode 100644 index 000000000..8ffbd22f8 --- /dev/null +++ b/src/main/scala/org/scalajs/dom/Document.scala @@ -0,0 +1,222 @@ +/** All documentation for facades is thanks to Mozilla Contributors at https://developer.mozilla.org/en-US/docs/Web/API + * and available under the Creative Commons Attribution-ShareAlike v2.5 or later. + * http://creativecommons.org/licenses/by-sa/2.5/ + * + * Everything else is under the MIT License http://opensource.org/licenses/MIT + */ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation._ + +/** Each web page loaded in the browser has its own document object. The Document interface serves as an entry point to + * the web page's content (the DOM tree, including elements such as <body> and <table>) and provides + * functionality global to the document (such as obtaining the page's URL and creating new elements in the document). + */ +@js.native +@JSGlobal +abstract class Document extends Node with NodeSelector with DocumentEvent with ParentNode with PageVisibility { + + /** Returns a DOMImplementation object associated with the current document. */ + def implementation: DOMImplementation = js.native + + /** Returns the character encoding of the current document. */ + def characterSet: String = js.native + + /** Returns the Document Type Declaration (DTD) associated with current document. The returned object implements the + * DocumentType interface. Use DOMImplementation.createDocumentType() to create a DocumentType. + */ + def doctype: DocumentType = js.native + + /** Returns the Element that is the root element of the document (for example, the <html> element for HTML + * documents). + */ + def documentElement: Element = js.native + + def documentURI: String = js.native + + /** Returns a list of StyleSheet objects for stylesheets explicitly linked into or embedded in a document. */ + def styleSheets: StyleSheetList = js.native + + /** Returns a string containing the date and time on which the current document was last modified. */ + def lastModified: String = js.native + + /** Returns an object reference to the identified element. */ + def getElementById(elementId: String): Element = js.native + + /** Returns a list of elements with a given name in the (X)HTML document. */ + def getElementsByName(elementName: String): NodeList[Node] = js.native + + /** Returns a HTMLCollection of elements with the given tag name. The complete document is searched, including the + * root node. The returned HTMLCollection is live, meaning that it updates itself automatically to stay in sync with + * the DOM tree without having to call document.getElementsByTagName again. + */ + def getElementsByTagName(name: String): HTMLCollection = js.native + + /** Returns a list of elements with the given tag name belonging to the given namespace. The complete document is + * searched, including the root node. + */ + def getElementsByTagNameNS(namespaceURI: String, localName: String): HTMLCollection = js.native + + /** Returns a set of elements which have all the given class names. When called on the document object, the complete + * document is searched, including the root node. You may also call getElementsByClassName on any element; it will + * return only elements which are descendants of the specified root element with the given class names. + */ + def getElementsByClassName(classNames: String): HTMLCollection = js.native + + /** Returns the element from the document whose elementFromPoint method is being called which is the topmost element + * which lies under the given point.  To get an element, specify the point via coordinates, in CSS pixels, relative + * to the upper-left-most point in the window or frame containing the document. + */ + def elementFromPoint(x: Double, y: Double): Element = js.native + + /** Adopts a node from an external document. The node and its subtree is removed from the document it's in (if any), + * and its ownerDocument is changed to the current document. The node can then be inserted into the current document. + */ + def adoptNode(source: Node): Node = js.native + + /** Returns an XPathResult based on an XPath expression and other given parameters. + * + * @param xpathExpression + * is a string representing the XPath to be evaluated. + * @param contextNode + * specifies the context node for the query (see the http://www.w3.org/TR/xpath XPath specification). It's common + * to pass document as the context node. + * @param namespaceResolver + * an `XPathNSResolver` + * @param resultType + * is an integer that corresponds to the type of result XPathResult to return. Use named constant properties, such + * as XPathResult.ANY_TYPE, of the XPathResult constructor, which correspond to integers from 0 to 9. + * @param result + * is an existing XPathResult to use for the results. null is the most common and will create a new XPathResult + */ + def evaluate(xpathExpression: String, contextNode: Node, namespaceResolver: XPathNSResolver, resultType: Int, + result: XPathResult): XPathResult = js.native + + /** Returns an XPathResult based on an XPath expression and other given parameters. + * + * @param xpathExpression + * is a string representing the XPath to be evaluated. + * @param contextNode + * specifies the context node for the query (see the [http://www.w3.org/TR/xpath XPath specification). It's common + * to pass document as the context node. + * @param namespaceResolver + * is a function that will be passed any namespace prefixes and should return a string representing the namespace + * URI associated with that prefix. It will be used to resolve prefixes within the XPath itself, so that they can + * be matched with the document. null is common for HTML documents or when no namespace prefixes are used. + * @param resultType + * is an integer that corresponds to the type of result XPathResult to return. Use named constant properties, such + * as XPathResult.ANY_TYPE, of the XPathResult constructor, which correspond to integers from 0 to 9. + * @param result + * is an existing XPathResult to use for the results. null is the most common and will create a new XPathResult + */ + def evaluate(xpathExpression: String, contextNode: Node, namespaceResolver: js.Function1[String, String], + resultType: Int, result: XPathResult): XPathResult = js.native + + /** Creates an XPathNSResolver which resolves namespaces with respect to the definitions in scope for a specified + * node. + */ + def createNSResolver(node: Node): XPathNSResolver = js.native + + /** Creates a copy of a node from an external document that can be inserted into the current document. */ + def importNode(importedNode: Node, deep: Boolean): Node = js.native + + /** In an HTML document creates the specified HTML element or HTMLUnknownElement if the element is not known. In a XUL + * document creates the specified XUL element. In other documents creates an element with a null namespaceURI. + */ + def createElement(tagName: String): Element = js.native + + /** Creates an element with the specified namespace URI and qualified name. */ + def createElementNS(namespaceURI: String, qualifiedName: String): Element = js.native + + /** createAttribute creates a new attribute node, and returns it. */ + def createAttribute(name: String): Attr = js.native + + /** Creates a new attribute node in a given namespace and returns it. */ + def createAttributeNS(namespaceURI: String, qualifiedName: String): Attr = js.native + + /** createProcessingInstruction() creates a new processing instruction node, and returns it. */ + def createProcessingInstruction(target: String, data: String): ProcessingInstruction = js.native + + /** createCDATASection() creates a new CDATA section node, and returns it. */ + def createCDATASection(data: String): CDATASection = js.native + + /** Once a Range is created, you need to set its boundary points before you can make use of most of its methods. */ + def createRange(): Range = js.native + + /** createComment() creates a new comment node, and returns it. */ + def createComment(data: String): Comment = js.native + + /** Creates a new empty DocumentFragment. */ + def createDocumentFragment(): DocumentFragment = js.native + + def createStyleSheet(href: String = js.native, index: Int = js.native): CSSStyleSheet = js.native + + def createTextNode(data: String): Text = js.native + + /** Supported in FF 3.5+, Chrome 1+, Opera 9+, Safari 3+, IE9+ */ + def createNodeIterator(root: Node, whatToShow: Int, filter: NodeFilter, + entityReferenceExpansion: Boolean): NodeIterator = js.native + + /** The Document.createTreeWalker() creator method returns a newly created TreeWalker object. */ + def createTreeWalker(root: Node, whatToShow: Int, filter: NodeFilter, + entityReferenceExpansion: Boolean): TreeWalker = js.native + + /** The Document method exitFullscreen() requests that the element on this document which is currently being presented + * in full-screen mode be taken out of full-screen mode, restoring the previous state of the screen. This usually + * reverses the effects of a previous call to Element.requestFullscreen(). + * + * The exception is if another element was already in full-screen mode when the current element was placed into + * full-screen mode using requestFullscreen(). In that case, the previous full-screen element is restored to + * full-screen status instead. In essence, a stack of full-screen elements is maintained. + */ + def exitFullscreen(): js.Promise[Unit] = js.native + + /** The DocumentOrShadowRoot.fullscreenElement read-only property returns the Element that is currently being + * presented in full-screen mode in this document, or null if full-screen mode is not currently in use. + * + * Although this property is read-only, it will not throw if it is modified (even in strict mode); the setter is a + * no-operation and it will be ignored. + */ + def fullscreenElement: Element = js.native + + /** The read-only fullscreenEnabled property on the Document interface indicates whether or not full-screen mode is + * available. Full-screen mode is available only for a page that has no windowed plug-ins in any of its documents, + * and if all