Prechádzať zdrojové kódy

[js] change Promise references in js.html to js.lib.Promise (#8282)

Aleksandr Kuzmenko 6 rokov pred
rodič
commit
c6943329b4

+ 6 - 4
std/js/html/Clients.hx

@@ -24,6 +24,8 @@
 
 package js.html;
 
+import js.lib.Promise;
+
 /**
 	The `Clients` interface provides access to `Client` objects. Access it via ``self`.clients` within a service worker.
 
@@ -33,22 +35,22 @@ package js.html;
 **/
 @:native("Clients")
 extern class Clients {
-	
+
 	/**
 		Returns a `Promise` for a `Client` matching a given `Client.id`.
 	**/
 	function get( id : String ) : Promise<Dynamic>;
-	
+
 	/**
 		Returns a `Promise` for an array of `Client` objects. An options argument allows you to control the types of clients returned. 
 	**/
 	function matchAll( ?options : ClientQueryOptions ) : Promise<Array<Client>>;
-	
+
 	/**
 		Opens a new browser window for a given url and returns a `Promise` for the new `WindowClient`.
 	**/
 	function openWindow( url : String ) : Promise<WindowClient>;
-	
+
 	/**
 		Allows an active service worker to set itself as the `ServiceWorkerContainer.controller` for all clients within its `ServiceWorkerRegistration.scope`. 
 	**/

+ 2 - 0
std/js/html/ExtendableEvent.hx

@@ -24,6 +24,8 @@
 
 package js.html;
 
+import js.lib.Promise;
+
 /**
 	The `ExtendableEvent` interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like `FetchEvent`) are not dispatched until it upgrades database schemas and deletes the outdated cache entries.
 

+ 6 - 4
std/js/html/FetchEvent.hx

@@ -24,6 +24,8 @@
 
 package js.html;
 
+import js.lib.Promise;
+
 /**
 	This is the event type for `fetch` events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the `event.respondWith()` method, which allows us to provide a response to this fetch.
 
@@ -33,21 +35,21 @@ package js.html;
 **/
 @:native("FetchEvent")
 extern class FetchEvent extends ExtendableEvent {
-	
+
 	/**
 		The `Request` the browser intends to make.
 	**/
 	var request(default,null) : Request;
-	
+
 	/**
 		The `Client.id` of the same-origin `Client` that initiated the fetch.
 	**/
 	var clientId(default,null) : String;
 	var isReload(default,null) : Bool;
-	
+
 	/** @throws DOMError */
 	function new( type : String, eventInitDict : FetchEventInit ) : Void;
-	
+
 	/**
 		Prevent the browser's default fetch handling, and provide (a promise for) a response yourself.
 		@throws DOMError

+ 14 - 12
std/js/html/ServiceWorkerGlobalScope.hx

@@ -24,6 +24,8 @@
 
 package js.html;
 
+import js.lib.Promise;
+
 /**
 	The `ServiceWorkerGlobalScope` interface of the ServiceWorker API represents the global execution context of a service worker.
 
@@ -33,58 +35,58 @@ package js.html;
 **/
 @:native("ServiceWorkerGlobalScope")
 extern class ServiceWorkerGlobalScope extends WorkerGlobalScope {
-	
+
 	/**
 		Contains the `Clients` object associated with the service worker.
 	**/
 	var clients(default,null) : Clients;
-	
+
 	/**
 		Contains the `ServiceWorkerRegistration` object that represents the service worker's registration.
 	**/
 	var registration(default,null) : ServiceWorkerRegistration;
-	
+
 	/**
 		An event handler fired whenever an `install` event occurs — when a `ServiceWorkerRegistration` acquires a new `ServiceWorkerRegistration.installing` worker.
 	**/
 	var oninstall : haxe.Constraints.Function;
-	
+
 	/**
 		An event handler fired whenever an `activate` event occurs — when a `ServiceWorkerRegistration` acquires a new `ServiceWorkerRegistration.active` worker.
 	**/
 	var onactivate : haxe.Constraints.Function;
-	
+
 	/**
 		An event handler fired whenever a `fetch` event occurs — when a `GlobalFetch.fetch` is called.
 	**/
 	var onfetch : haxe.Constraints.Function;
-	
+
 	/**
 		An event handler fired whenever a `message` event occurs — when incoming messages are received. Controlled pages can use the `MessagePort.postMessage()` method to send messages to service workers. The service worker can optionally send a response back via the `MessagePort` exposed in `event.data.port`, corresponding to the controlled page.
 	**/
 	var onmessage : haxe.Constraints.Function;
-	
+
 	/**
 		An event handler fired whenever a `push` event occurs — when a server push notification is received.
 	**/
 	var onpush : haxe.Constraints.Function;
-	
+
 	/**
 		An event handler fired whenever a `pushsubscriptionchange` event occurs — when a push subscription has been invalidated, or is about to be invalidated (e.g. when a push service sets an expiration time.)
 	**/
 	var onpushsubscriptionchange : haxe.Constraints.Function;
-	
+
 	/**
 		An event handler fired whenever a `notificationclick` event occurs — when a user clicks on a displayed notification.
 	**/
 	var onnotificationclick : haxe.Constraints.Function;
-	
+
 	/**
 		An event handler fired whenever a `notificationclose` event occurs — when a user closes a displayed notification.
 	**/
 	var onnotificationclose : haxe.Constraints.Function;
-	
-	
+
+
 	/**
 		Allows the current service worker registration to progress from waiting to active state while service worker clients are using it.
 		@throws DOMError

+ 7 - 5
std/js/html/WindowClient.hx

@@ -24,6 +24,8 @@
 
 package js.html;
 
+import js.lib.Promise;
+
 /**
 	The `WindowClient` interface of the ServiceWorker API represents the scope of a service worker client that is a document in a browser context, controlled by an active worker. The service worker client independently selects and uses a service worker for its own loading and sub-resources.
 
@@ -33,24 +35,24 @@ package js.html;
 **/
 @:native("WindowClient")
 extern class WindowClient extends Client {
-	
+
 	/**
 		Indicates the visibility of the current client. This value can be one of `hidden`, `visible`, `prerender`, or `unloaded`.
 	**/
 	var visibilityState(default,null) : VisibilityState;
-	
+
 	/**
 		A boolean that indicates whether the current client has focus.
 	**/
 	var focused(default,null) : Bool;
-	
-	
+
+
 	/**
 		Gives user input focus to the current client. 
 		@throws DOMError
 	**/
 	function focus() : Promise<WindowClient>;
-	
+
 	/**
 		Loads a specified URL into a controlled client page.
 		@throws DOMError

+ 11 - 9
std/js/html/WorkerGlobalScope.hx

@@ -24,6 +24,8 @@
 
 package js.html;
 
+import js.lib.Promise;
+
 /**
 	The `WorkerGlobalScope` interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by `Window` objects — in this case event handlers, the console or the associated `WorkerNavigator` object. Each `WorkerGlobalScope` has its own event loop.
 
@@ -33,33 +35,33 @@ package js.html;
 **/
 @:native("WorkerGlobalScope")
 extern class WorkerGlobalScope extends EventTarget {
-	
+
 	/**
 		Returns a reference to the `WorkerGlobalScope` itself. Most of the time it is a specific scope like `DedicatedWorkerGlobalScope`,  `SharedWorkerGlobalScope` or `ServiceWorkerGlobalScope`.
 	**/
 	var self(default,null) : WorkerGlobalScope;
-	
+
 	/**
 		Returns the `WorkerLocation` associated with the worker. It is a specific location object, mostly a subset of the `Location` for browsing scopes, but adapted to workers.
 	**/
 	var location(default,null) : WorkerLocation;
 	var navigator(default,null) : WorkerNavigator;
-	
+
 	/**
 		Is an `EventHandler` representing the code to be called when the `error` event is raised.
 	**/
 	var onerror : haxe.extern.EitherType<Event,String> -> String -> Int -> Int -> Dynamic -> Dynamic;
-	
+
 	/**
 		Is an `EventHandler` representing the code to be called when the `offline` event is raised.
 	**/
 	var onoffline : haxe.Constraints.Function;
-	
+
 	/**
 		Is an `EventHandler` representing the code to be called when the `online` event is raised.
 	**/
 	var ononline : haxe.Constraints.Function;
-	
+
 	/**
 		Returns the `Performance` associated with the worker. It is a regular performance object, except that only a subset of its property and methods are available to workers.
 	**/
@@ -69,14 +71,14 @@ extern class WorkerGlobalScope extends EventTarget {
 	var isSecureContext(default,null) : Bool;
 	var indexedDB(default,null) : js.html.idb.Factory;
 	var caches(default,null) : CacheStorage;
-	
-	
+
+
 	/**
 		Imports one or more scripts into the worker's scope. You can specify as many as you'd like, separated by commas. For example:` importScripts('foo.js', 'bar.js');`
 		@throws DOMError
 	**/
 	function importScripts( urls : haxe.extern.Rest<String> ) : Void;
-	
+
 	/**
 		Allows you to write a message to stdout — i.e. in your terminal. This is the same as Firefox's `window.dump`, but for workers.
 	**/

+ 7 - 5
std/js/html/audio/AudioContext.hx

@@ -24,6 +24,8 @@
 
 package js.html.audio;
 
+import js.lib.Promise;
+
 /**
 	The `AudioContext` interface represents an audio-processing graph built from audio modules linked together, each represented by an `AudioNode`.
 
@@ -35,31 +37,31 @@ package js.html.audio;
 extern class AudioContext extends BaseAudioContext {
 	/** @throws DOMError */
 	function new( ?contextOptions : AudioContextOptions ) : Void;
-	
+
 	/**
 		Suspends the progression of time in the audio context, temporarily halting audio hardware access and reducing CPU/battery usage in the process.
 		@throws DOMError
 	**/
 	function suspend() : Promise<Void>;
-	
+
 	/**
 		Closes the audio context, releasing any system audio resources that it uses.
 		@throws DOMError
 	**/
 	function close() : Promise<Void>;
-	
+
 	/**
 		Creates a `MediaElementAudioSourceNode` associated with an `HTMLMediaElement`. This can be used to play and manipulate audio from `video` or `audio` elements.
 		@throws DOMError
 	**/
 	function createMediaElementSource( mediaElement : js.html.MediaElement ) : MediaElementAudioSourceNode;
-	
+
 	/**
 		Creates a `MediaStreamAudioSourceNode` associated with a `MediaStream` representing an audio stream which may come from the local computer microphone or other sources.
 		@throws DOMError
 	**/
 	function createMediaStreamSource( mediaStream : js.html.MediaStream ) : MediaStreamAudioSourceNode;
-	
+
 	/**
 		Creates a `MediaStreamAudioDestinationNode` associated with a `MediaStream` representing an audio stream which may be stored in a local file or sent to another computer.
 		@throws DOMError

+ 29 - 27
std/js/html/audio/BaseAudioContext.hx

@@ -24,6 +24,8 @@
 
 package js.html.audio;
 
+import js.lib.Promise;
+
 /**
 	The `BaseAudioContext` interface acts as a base definition for online and offline audio-processing graphs, as represented by `AudioContext` and `OfflineAudioContext` respectively.
 
@@ -33,153 +35,153 @@ package js.html.audio;
 **/
 @:native("BaseAudioContext")
 extern class BaseAudioContext extends js.html.EventTarget {
-	
+
 	/**
 		Returns an `AudioDestinationNode` representing the final destination of all audio in the context. It can be thought of as the audio-rendering device.
 	**/
 	var destination(default,null) : AudioDestinationNode;
-	
+
 	/**
 		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.
 	**/
 	var sampleRate(default,null) : Float;
-	
+
 	/**
 		Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at `0`.
 	**/
 	var currentTime(default,null) : Float;
-	
+
 	/**
 		Returns the `AudioListener` object, used for 3D spatialization.
 	**/
 	var listener(default,null) : AudioListener;
-	
+
 	/**
 		Returns the current state of the `AudioContext`.
 	**/
 	var state(default,null) : AudioContextState;
-	
+
 	/**
 		An event handler that runs when an event of type `statechange` has fired. This occurs when the `AudioContext`'s state changes, due to the calling of one of the state change methods (`AudioContext.suspend`, `AudioContext.resume`, or `AudioContext.close`).
 	**/
 	var onstatechange : haxe.Constraints.Function;
-	
-	
+
+
 	/**
 		Resumes the progression of time in an audio context that has previously been suspended/paused.
 		@throws DOMError
 	**/
 	function resume() : Promise<Void>;
-	
+
 	/**
 		Creates a new, empty `AudioBuffer` object, which can then be populated by data and played via an `AudioBufferSourceNode`.
 		@throws DOMError
 	**/
 	function createBuffer( numberOfChannels : Int, length : Int, sampleRate : Float ) : AudioBuffer;
-	
+
 	/**
 		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.
 		@throws DOMError
 	**/
 	@:overload( function( audioData : js.lib.ArrayBuffer, ?successCallback : AudioBuffer -> Void, ?errorCallback : Void -> Void ) : Promise<AudioBuffer> {} )
 	function decodeAudioData( audioData : js.lib.ArrayBuffer, ?successCallback : AudioBuffer -> Void, ?errorCallback : js.html.DOMException -> Void ) : Promise<AudioBuffer>;
-	
+
 	/**
 		Creates an `AudioBufferSourceNode`, which can be used to play and manipulate audio data contained within an `AudioBuffer` object. `AudioBuffer`s are created using `AudioContext.createBuffer` or returned by `AudioContext.decodeAudioData` when it successfully decodes an audio track.
 		@throws DOMError
 	**/
 	function createBufferSource() : AudioBufferSourceNode;
-	
+
 	/**
 		Creates a `ConstantSourceNode` object, which is an audio source that continuously outputs a monaural (one-channel) sound signal whose samples all have the same value.
 		@throws DOMError
 	**/
 	function createConstantSource() : ConstantSourceNode;
-	
+
 	/**
 		Creates a `ScriptProcessorNode`, which can be used for direct audio processing via JavaScript.
 		@throws DOMError
 	**/
 	function createScriptProcessor( bufferSize : Int = 0, numberOfInputChannels : Int = 2, numberOfOutputChannels : Int = 2 ) : ScriptProcessorNode;
-	
+
 	/**
 		Creates an `AnalyserNode`, which can be used to expose audio time and frequency data and for example to create data visualisations.
 		@throws DOMError
 	**/
 	function createAnalyser() : AnalyserNode;
-	
+
 	/**
 		Creates a `GainNode`, which can be used to control the overall volume of the audio graph.
 		@throws DOMError
 	**/
 	function createGain() : GainNode;
-	
+
 	/**
 		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.
 		@throws DOMError
 	**/
 	function createDelay( maxDelayTime : Float = 1.0 ) : DelayNode;
-	
+
 	/**
 		Creates a `BiquadFilterNode`, which represents a second order filter configurable as several different common filter types: high-pass, low-pass, band-pass, etc
 		@throws DOMError
 	**/
 	function createBiquadFilter() : BiquadFilterNode;
-	
+
 	/**
 		Creates an `IIRFilterNode`, which represents a second order filter configurable as several different common filter types.
 		@throws DOMError
 	**/
 	function createIIRFilter( feedforward : Array<Float>, feedback : Array<Float> ) : IIRFilterNode;
-	
+
 	/**
 		Creates a `WaveShaperNode`, which is used to implement non-linear distortion effects.
 		@throws DOMError
 	**/
 	function createWaveShaper() : WaveShaperNode;
-	
+
 	/**
 		Creates a `PannerNode`, which is used to spatialise an incoming audio stream in 3D space.
 		@throws DOMError
 	**/
 	function createPanner() : PannerNode;
-	
+
 	/**
 		Creates a `StereoPannerNode`, which can be used to apply stereo panning to an audio source.
 		@throws DOMError
 	**/
 	function createStereoPanner() : StereoPannerNode;
-	
+
 	/**
 		Creates a `ConvolverNode`, which can be used to apply convolution effects to your audio graph, for example a reverberation effect.
 		@throws DOMError
 	**/
 	function createConvolver() : ConvolverNode;
-	
+
 	/**
 		Creates a `ChannelSplitterNode`, which is used to access the individual channels of an audio stream and process them separately.
 		@throws DOMError
 	**/
 	function createChannelSplitter( numberOfOutputs : Int = 6 ) : ChannelSplitterNode;
-	
+
 	/**
 		Creates a `ChannelMergerNode`, which is used to combine channels from multiple audio streams into a single audio stream.
 		@throws DOMError
 	**/
 	function createChannelMerger( numberOfInputs : Int = 6 ) : ChannelMergerNode;
-	
+
 	/**
 		Creates a `DynamicsCompressorNode`, which can be used to apply acoustic compression to an audio signal.
 		@throws DOMError
 	**/
 	function createDynamicsCompressor() : DynamicsCompressorNode;
-	
+
 	/**
 		Creates an `OscillatorNode`, a source representing a periodic waveform. It basically generates a tone.
 		@throws DOMError
 	**/
 	function createOscillator() : OscillatorNode;
-	
+
 	/**
 		Creates a `PeriodicWave`, used to define a periodic waveform that can be used to determine the output of an `OscillatorNode`.
 		@throws DOMError

+ 6 - 4
std/js/html/audio/OfflineAudioContext.hx

@@ -24,6 +24,8 @@
 
 package js.html.audio;
 
+import js.lib.Promise;
+
 /**
 	The `OfflineAudioContext` interface is an `AudioContext` interface representing an audio-processing graph built from linked together `AudioNode`s. 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`.
 
@@ -33,21 +35,21 @@ package js.html.audio;
 **/
 @:native("OfflineAudioContext")
 extern class OfflineAudioContext extends BaseAudioContext {
-	
+
 	/**
 		An integer representing the size of the buffer in sample-frames.
 	**/
 	var length(default,null) : Int;
-	
+
 	/**
 		Is an `EventHandler` called when processing is terminated, that is when the `complete` event (of type `OfflineAudioCompletionEvent`) is raised, after the event-based version of `OfflineAudioContext.startRendering()` is used.
 	**/
 	var oncomplete : haxe.Constraints.Function;
-	
+
 	/** @throws DOMError */
 	@:overload( function( contextOptions : OfflineAudioContextOptions ) : Void {} )
 	function new( numberOfChannels : Int, length : Int, sampleRate : Float ) : Void;
-	
+
 	/**
 		Starts rendering the audio, taking into account the current connections and the current scheduled changes. This page covers both the event-based version and the promise-based version.
 		@throws DOMError

+ 3 - 1
std/js/html/midi/MIDIPort.hx

@@ -24,6 +24,8 @@
 
 package js.html.midi;
 
+import js.lib.Promise;
+
 @:native("MIDIPort")
 extern class MIDIPort extends js.html.EventTarget {
 	var id(default,null) : String;
@@ -34,7 +36,7 @@ extern class MIDIPort extends js.html.EventTarget {
 	var state(default,null) : MIDIPortDeviceState;
 	var connection(default,null) : MIDIPortConnectionState;
 	var onstatechange : haxe.Constraints.Function;
-	
+
 	function open() : Promise<MIDIPort>;
 	function close() : Promise<MIDIPort>;
 }

+ 2 - 0
std/js/html/rtc/IdentityProvider.hx

@@ -24,6 +24,8 @@
 
 package js.html.rtc;
 
+import js.lib.Promise;
+
 typedef IdentityProvider = {
 	var generateAssertion : String -> String -> IdentityProviderOptions -> Promise<IdentityAssertionResult>;
 	var validateAssertion : String -> String -> Promise<IdentityValidationResult>;

+ 3 - 1
std/js/html/rtc/PeerConnection.hx

@@ -24,6 +24,8 @@
 
 package js.html.rtc;
 
+import js.lib.Promise;
+
 /**
 	The `RTCPeerConnection` interface represents a WebRTC connection between the local computer and a remote peer. It provides methods to connect to a remote peer, maintain and monitor the connection, and close the connection once it's no longer needed.
 
@@ -58,7 +60,7 @@ extern class PeerConnection extends js.html.EventTarget {
 	var oniceconnectionstatechange : haxe.Constraints.Function;
 	var onicegatheringstatechange : haxe.Constraints.Function;
 	var ondatachannel : haxe.Constraints.Function;
-	
+
 	/** @throws DOMError */
 	function new( ?configuration : Configuration, ?constraints : Dynamic ) : Void;
 	function setIdentityProvider( provider : String, ?options : IdentityProviderOptions ) : Void;

+ 7 - 5
std/js/html/rtc/RtpReceiver.hx

@@ -24,6 +24,8 @@
 
 package js.html.rtc;
 
+import js.lib.Promise;
+
 /**
 	The `RTCRtpReceiver` interface of the the WebRTC API manages the reception and decoding of data for a `MediaStreamTrack` on an `RTCPeerConnection`.
 
@@ -33,23 +35,23 @@ package js.html.rtc;
 **/
 @:native("RTCRtpReceiver")
 extern class RtpReceiver {
-	
+
 	/**
 		Returns the `MediaStreamTrack` associated with the current `RTCRtpReceiver` instance. 
 	**/
 	var track(default,null) : js.html.MediaStreamTrack;
-	
-	
+
+
 	/**
 		Returns a `Promise` whose fulfillment handler receives a `RTCStatsReport` which contains statistics about the incoming streams and their dependencies.
 	**/
 	function getStats() : Promise<StatsReport>;
-	
+
 	/**
 		Returns an array of `RTCRtpContributingSource` instances for each unique CSRC (contributing source) identifier received by the current `RTCRtpReceiver` in the last ten seconds.
 	**/
 	function getContributingSources() : Array<RtpContributingSource>;
-	
+
 	/**
 		Returns an array including one `RTCRtpSynchronizationSource` instance for each unique SSRC (synchronization source) identifier received by the current `RTCRtpReceiver` in the last ten seconds.
 	**/

+ 5 - 3
std/js/html/rtc/RtpSender.hx

@@ -24,6 +24,8 @@
 
 package js.html.rtc;
 
+import js.lib.Promise;
+
 /**
 	The `RTCRtpSender` interface provides the ability to control and obtain details about how a particular `MediaStreamTrack` is encoded and sent to a remote peer.
 
@@ -33,17 +35,17 @@ package js.html.rtc;
 **/
 @:native("RTCRtpSender")
 extern class RtpSender {
-	
+
 	/**
 		The `MediaStreamTrack` which is being handled by the `RTCRtpSender`. If `track` is `null`, the `RTCRtpSender` doesn't transmit anything.
 	**/
 	var track(default,null) : js.html.MediaStreamTrack;
-	
+
 	/**
 		An `RTCDTMFSender` which can be used to send `DTMF` tones using `"telephone-event"` payloads on the RTP session represented by the `RTCRtpSender` object. If `null`, the track and/or the connection doesn't support DTMF. Only audio tracks can support DTMF.
 	**/
 	var dtmf(default,null) : DTMFSender;
-	
+
 	function setParameters( ?parameters : RtpParameters ) : Promise<Void>;
 	function getParameters() : RtpParameters;
 	function replaceTrack( withTrack : js.html.MediaStreamTrack ) : Promise<Void>;