diff --git a/src/filters/jsExceptions.ml b/src/filters/jsExceptions.ml index 4e9c05a5206..c7f537d6360 100644 --- a/src/filters/jsExceptions.ml +++ b/src/filters/jsExceptions.ml @@ -58,7 +58,7 @@ let follow = Abstract.follow_with_abstracts let rec is_js_error c = match c with - | { cl_path = ["js"],"Error" } -> true + | { cl_path = ["js";"lib"],"Error" } -> true | { cl_super = Some (csup,_) } -> is_js_error csup | _ -> false @@ -69,7 +69,7 @@ let find_cl com path = ) com.types let init ctx = - let cJsError = find_cl ctx.com (["js"],"Error") in + let cJsError = find_cl ctx.com (["js";"lib"],"Error") in let cHaxeError = find_cl ctx.com (["js";"_Boot"],"HaxeError") in let cStd = find_cl ctx.com ([],"Std") in let cBoot = find_cl ctx.com (["js"],"Boot") in diff --git a/std/haxe/CallStack.hx b/std/haxe/CallStack.hx index 7b799fee5fb..4b2053cdd02 100644 --- a/std/haxe/CallStack.hx +++ b/std/haxe/CallStack.hx @@ -37,9 +37,9 @@ enum StackItem { **/ class CallStack { #if js - static var lastException:js.Error; + static var lastException:js.lib.Error; - static function getStack(e:js.Error):Array { + static function getStack(e:js.lib.Error):Array { if (e == null) return []; // https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi var oldValue = (untyped Error).prepareStackTrace; @@ -97,7 +97,7 @@ class CallStack { return makeStack(s); #elseif js try { - throw new js.Error(); + throw new js.lib.Error(); } catch( e : Dynamic ) { var a = getStack(js.Lib.getOriginalException()); a.shift(); // remove Stack.callStack() diff --git a/std/haxe/Timer.hx b/std/haxe/Timer.hx index 7de7669cc06..3e79febe531 100644 --- a/std/haxe/Timer.hx +++ b/std/haxe/Timer.hx @@ -172,7 +172,7 @@ class Timer { #elseif (neko || php) return Sys.time(); #elseif js - return js.Date.now() / 1000; + return js.lib.Date.now() / 1000; #elseif cpp return untyped __global__.__time_stamp(); #elseif python diff --git a/std/js/Boot.hx b/std/js/Boot.hx index 5eac6ed20fa..9946b174eb8 100644 --- a/std/js/Boot.hx +++ b/std/js/Boot.hx @@ -23,22 +23,22 @@ package js; import js.Syntax; // import it here so it's always available in the compiler -private class HaxeError extends js.Error { +private class HaxeError extends js.lib.Error { var val:Dynamic; @:pure public function new(val:Dynamic) { super(); this.val = val; - if ((cast js.Error).captureStackTrace) (cast js.Error).captureStackTrace(this, HaxeError); + if ((cast js.lib.Error).captureStackTrace) (cast js.lib.Error).captureStackTrace(this, HaxeError); } - public static function wrap(val:Dynamic):js.Error { - return if (js.Syntax.instanceof(val, js.Error)) val else new HaxeError(val); + public static function wrap(val:Dynamic):js.lib.Error { + return if (js.Syntax.instanceof(val, js.lib.Error)) val else new HaxeError(val); } static function __init__() { - js.Object.defineProperty((cast HaxeError).prototype, "message", {get: () -> (cast String)(js.Lib.nativeThis.val)}); + js.lib.Object.defineProperty((cast HaxeError).prototype, "message", {get: () -> (cast String)(js.Lib.nativeThis.val)}); } } @@ -161,7 +161,7 @@ class Boot { return false; if( cc == cl ) return true; - if( js.Object.prototype.hasOwnProperty.call(cc, "__interfaces__") ) { + if( js.lib.Object.prototype.hasOwnProperty.call(cc, "__interfaces__") ) { var intf : Dynamic = cc.__interfaces__; for( i in 0...intf.length ) { var i : Dynamic = intf[i]; @@ -220,7 +220,7 @@ class Boot { else throw "Cannot cast " +Std.string(o) + " to " +Std.string(t); } - static var __toStr:js.Function; + static var __toStr:js.lib.Function; static function __init__() { Boot.__toStr = (cast {}).toString; } diff --git a/std/js/Error.hx b/std/js/Error.hx index a5a7ccc5c32..8c1b3f86142 100644 --- a/std/js/Error.hx +++ b/std/js/Error.hx @@ -21,48 +21,10 @@ */ package js; -@:native("Error") -extern class Error -{ - var message : String; - var name : String; - var stack(default,null) : String; - - function new(?message : String) : Void; -} - -@:native("EvalError") -extern class EvalError extends Error -{ - function new(?message : String) : Void; -} - -@:native("RangeError") -extern class RangeError extends Error -{ - function new(?message : String) : Void; -} - -@:native("ReferenceError") -extern class ReferenceError extends Error -{ - function new(?message : String) : Void; -} - -@:native("SyntaxError") -extern class SyntaxError extends Error -{ - function new(?message : String) : Void; -} - -@:native("TypeError") -extern class TypeError extends Error -{ - function new(?message : String) : Void; -} - -@:native("URIError") -extern class URIError extends Error -{ - function new(?message : String) : Void; -} +@:deprecated typedef Error = js.lib.Error; +@:deprecated typedef EvalError = js.lib.Error.EvalError; +@:deprecated typedef RangeError = js.lib.Error.RangeError; +@:deprecated typedef ReferenceError = js.lib.Error.ReferenceError; +@:deprecated typedef SyntaxError = js.lib.Error.SyntaxError; +@:deprecated typedef TypeError = js.lib.Error.TypeError; +@:deprecated typedef URIError = js.lib.Error.URIError; diff --git a/std/js/Function.hx b/std/js/Function.hx index 8286beeedcf..4d233394350 100644 --- a/std/js/Function.hx +++ b/std/js/Function.hx @@ -21,31 +21,4 @@ */ package js; -import haxe.extern.Rest; - -@:native("Function") -extern class Function { - /** Specifies the number of arguments expected by the function. **/ - var length(default,never):Int; - - /** The name of the function. **/ - var name:String; - - /** Creates a new Function object. **/ - function new(arg:String, rest:Rest); - - /** Calls a function and sets its this to the provided value, arguments can be passed as an Array object. **/ - function apply(thisArg:Dynamic, argsArray:Array):Dynamic; - - /** Calls (executes) a function and sets its this to the provided value, arguments can be passed as they are. **/ - function call(thisArg:Dynamic, args:Rest):Dynamic; - - /** - Creates a new function which, when called, has its this set to the provided value, - with a given sequence of arguments preceding any provided when the new function was called. - **/ - @:pure function bind(thisArg:Dynamic, args:Rest):Function; - - /** Returns a string representing the source code of the function. **/ - @:pure function toString():String; -} +@:deprecated typedef Function = js.lib.Function; diff --git a/std/js/JsIterator.hx b/std/js/JsIterator.hx index 419dbdfb49a..8c7b0e4a97e 100644 --- a/std/js/JsIterator.hx +++ b/std/js/JsIterator.hx @@ -1,17 +1,4 @@ package js; -/** - JsIterator is prefixed with Js to avoid name clashes with standard - Iterator structure. -**/ -typedef JsIterator = { - function next():JsIteratorStep; -} - -/** - Object returned by `JsIterator.next`. -**/ -typedef JsIteratorStep = { - done:Bool, - ?value:T -} +@:deprecated typedef JsIterator = js.lib.Iterator; +@:deprecated typedef JsIteratorStep = js.lib.Iterator.JsIteratorStep; diff --git a/std/js/Object.hx b/std/js/Object.hx index 76dcf789d7c..6e78d73a498 100644 --- a/std/js/Object.hx +++ b/std/js/Object.hx @@ -21,205 +21,6 @@ */ package js; -import haxe.extern.Rest; -import haxe.DynamicAccess; - -/** - The `js.Object` constructor creates an object wrapper. - - Documentation [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). -**/ -@:native("Object") -extern class Object { - /** - Copies the values of all enumerable own properties from one or more - source objects to a target object. - **/ - static function assign(target:T, sources:Rest<{}>):T; - - /** - Creates a new object with the specified prototype object and properties. - **/ - @:pure static function create(proto:{}, ?propertiesObject:DynamicAccess):T; - - /** - Adds the named properties described by the given descriptors to an object. - **/ - static function defineProperties(obj:T, props:DynamicAccess):T; - - /** - Adds the named property described by a given descriptor to an object. - **/ - static function defineProperty(obj:T, prop:String, descriptor:ObjectPropertyDescriptor):T; - - /** - Freezes an object: other code can't delete or change any properties. - **/ - static function freeze(obj:T):T; - - /** - Returns a property descriptor for a named property on an object. - **/ - @:pure static function getOwnPropertyDescriptor(obj:{}, prop:String):Null; - - /** - Returns an array containing the names of all of the given object's own - enumerable and non-enumerable properties. - **/ - @:pure static function getOwnPropertyNames(obj:{}):Array; - - /** - Returns an array of all symbol properties found directly upon a given object. - **/ - @:pure static function getOwnPropertySymbols(obj:{}):Array; - - /** - Returns the prototype of the specified object. - **/ - @:pure static function getPrototypeOf(obj:{}):Null; - - /** - Compares if two values are the same value. Equates all NaN values - (which differs from both Abstract Equality Comparison and - Strict Equality Comparison). - **/ - @:pure static function is(value1:T, value2:T):Bool; - - /** - Determines if extending of an object is allowed. - **/ - @:pure static function isExtensible(obj:{}):Bool; - - /** - Determines if an object was frozen. - **/ - @:pure static function isFrozen(obj:{}):Bool; - - /** - Determines if an object is sealed. - **/ - @:pure static function isSealed(obj:{}):Bool; - - /** - Returns an array containing the names of all of the given object's own - enumerable string properties. - **/ - @:pure static function keys(obj:{}):Array; - - /** - Prevents any extensions of an object. - **/ - static function preventExtensions(obj:T):T; - - /** - Prevents other code from deleting properties of an object. - **/ - static function seal(obj:T):T; - - /** - Sets the prototype (i.e., the internal Prototype property). - **/ - static function setPrototypeOf(obj:T, prototype:Null<{}>):T; - - /** - Allows the addition of properties to all objects of type Object. - **/ - static var prototype(default,never):ObjectPrototype; - - /** - The Object constructor creates an object wrapper. - **/ - @:pure function new(?value:Any); -} - -/** - Type for - @see -**/ -typedef ObjectPrototype = { - /** - Returns a boolean indicating whether an object contains the specified - property as a direct property of that object and not inherited through - the prototype chain. - **/ - var hasOwnProperty(default,never):Function; - - /** - Returns a boolean indicating whether the object this method is called - upon is in the prototype chain of the specified object. - **/ - var isPrototypeOf(default,never):Function; - - /** - Returns a boolean indicating if the internal enumerable attribute is set. - **/ - var propertyIsEnumerable(default,never):Function; - - /** - Calls `toString()`. - **/ - var toLocaleString(default,never):Function; - - /** - Returns a string representation of the object. - **/ - var toString(default,never):Function; - - /** - Returns the primitive value of the specified object. - **/ - var valueOf(default,never):Function; -} - -/** - @see -**/ -typedef ObjectPropertyDescriptor = { - /** - `true` if and only if the type of this property descriptor may be - changed and if the property may be deleted from the corresponding object. - - Defaults to `false`. - **/ - var ?configurable:Bool; - - /** - `true` if and only if this property shows up during enumeration of the - properties on the corresponding object. - - Defaults to `false`. - **/ - var ?enumerable:Bool; - - /** - The value associated with the property. - Can be any valid JavaScript value (number, object, function, etc). - **/ - var ?value:Any; - - /** - `true` if and only if the value associated with the property may be - changed with an assignment operator. - - Defaults to `false`. - **/ - var ?writable:Bool; - - /** - A function which serves as a getter for the property, or `undefined` if - there is no getter. When the property is accessed, this function is - called without arguments and with `this` set to the object through which - the property is accessed (this may not be the object on which the - property is defined due to inheritance). - The return value will be used as the value of the property. - **/ - var ?get:Void->Any; - - /** - A function which serves as a setter for the property, or undefined if - there is no setter. When the property is assigned to, this function - is called with one argument (the value being assigned to the property) - and with `this` set to the object through which the property is assigned. - **/ - var ?set:Any->Void; -} +@:deprecated typedef Object = js.lib.Object; +@:deprecated typedef ObjectPrototype = js.lib.Object.ObjectPrototype; +@:deprecated typedef ObjectPropertyDescriptor = js.lib.Object.ObjectPropertyDescriptor; diff --git a/std/js/Promise.hx b/std/js/Promise.hx index d4a3f6dce43..5de240ba9de 100644 --- a/std/js/Promise.hx +++ b/std/js/Promise.hx @@ -22,88 +22,7 @@ package js; -import haxe.extern.EitherType; - -/** - The Promise object represents the eventual completion (or failure) of an - asynchronous operation and its resulting value. - - Documentation [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). -**/ -@:native("Promise") -extern class Promise -{ - /** - Returns a Promise object that is resolved with the given value. If the - value is Thenable, the returned promise will "follow" that - thenable, adopting its eventual state; - otherwise the returned promise will be fulfilled with the value. - Generally, when it's unknown when value is a promise or not, - use `Promise.resolve(value)` instead and work with the return value as - a promise. - **/ - @:overload(function(?value : T) : Promise {}) - static function resolve( thenable : Thenable ) : Promise; - - /** - Returns a Promise object that is rejected with the given reason. - **/ - static function reject( ?reason : Dynamic ) : Promise; - - /** - Returns a promise that either fulfills when all of the promises in the - iterable argument have fulfilled or rejects as soon as one of the - promises in the iterable argument rejects. If the returned promise - fulfills, it is fulfilled with an array of the values from the - fulfilled promises in the same order as defined in the iterable. - If the returned promise rejects, it is rejected with the reason from - the first promise in the iterable that rejected. This method can be - useful for aggregating results of multiple promises. - **/ - static function all( iterable : Array ) : Promise>; - - /** - Returns a promise that fulfills or rejects as soon as one of the - promises in the iterable fulfills or rejects, with the value or reason - from that promise. - **/ - static function race( iterable : Array ) : Promise; - - /** @throws DOMError */ - function new( init : (resolve : (value : T) -> Void, reject: (reason : Dynamic) -> Void) -> Void ) : Void; - - /** - Appends fulfillment and rejection handlers to the promise and returns a - new promise resolving to the return value of the called handler, or to - its original settled value if the promise was not handled - (i.e. if the relevant handler onFulfilled or onRejected is not a function). - **/ - function then( onFulfilled : Null>, ?onRejected : PromiseHandler ) : Promise; - - /** - Appends a rejection handler callback to the promise, and returns a new - promise resolving to the return value of the callback if it is called, - or to its original fulfillment value if the promise is instead fulfilled. - **/ - @:native("catch") - function catchError( onRejected : PromiseHandler ) : Promise; -} - -/** - Handler type for the Promise object. -**/ -abstract PromiseHandler(T->Dynamic) // T->Dynamic, so the compiler always knows the type of the argument and can infer it for then/catch callbacks - from T->TOut // order is important, because Promise return must have priority - from T->Thenable // although the checking order seems to be reversed at the moment, see https://github.com/HaxeFoundation/haxe/issues/7656 - from T->Promise // support Promise explicitly as it doesn't work transitively through Thenable at the moment -{} - -/** - A value with a `then` method. -**/ -@:forward -abstract Thenable(ThenableStruct) from ThenableStruct {} // abstract wrapping prevents compiler hanging, see https://github.com/HaxeFoundation/haxe/issues/5785 - -typedef ThenableStruct = { - function then( onFulfilled : Null>, ?onRejected : PromiseHandler ) : Thenable; -} +@:deprecated typedef Promise = js.lib.Promise; +@:deprecated typedef PromiseHandler = js.lib.Promise.PromiseHandler; +@:deprecated typedef Thenable = js.lib.Promise.Thenable; +@:deprecated typedef ThenableStruct = js.lib.Promise.ThenableStruct; diff --git a/std/js/RegExp.hx b/std/js/RegExp.hx index 282294f99aa..e246ea2baa2 100644 --- a/std/js/RegExp.hx +++ b/std/js/RegExp.hx @@ -21,26 +21,5 @@ */ package js; -/** - Native JavaScript regular expressions. - - For cross-platform regular expressions, use Haxe `EReg` class or - [regexp literals](https://haxe.org/manual/std-regex.html). -**/ -@:native("RegExp") -extern class RegExp { - var global(default,null):Bool; - var ignoreCase(default,null):Bool; - var multiline(default,null):Bool; - var source(default,null):String; - var lastIndex:Int; - function new(pattern:String, ?flags:String); - function exec(str:String):Null; - function test(str:String):Bool; - function toString():String; -} - -extern class RegExpMatch extends Array { - var index:Int; - var input:String; -} +@:deprecated typedef RegExp = js.lib.RegExp; +@:deprecated typedef RegExpMatch = js.lib.RegExp.RegExpMatch; diff --git a/std/js/Set.hx b/std/js/Set.hx index 1012eccbe51..b0998ba0848 100644 --- a/std/js/Set.hx +++ b/std/js/Set.hx @@ -21,78 +21,4 @@ */ package js; -import js.Map.MapEntry; - -/** - The `js.Set` object lets you store unique values of any type, whether - primitive values or object references. - - Documentation [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). -**/ -@:native("Set") -extern class Set { - /** - The number of values in the `js.Set` object. - **/ - var size(default,null):Int; - - /** - If an iterable object is passed, all of its elements will be added to - the new `js.Set`. - **/ - @:pure function new(?iterable:Any); - - /** - Returns a boolean asserting whether an element is present with the given - value in the `js.Set` object or not. - **/ - @:pure function has(value:T):Bool; - - /** - Appends a new element with the given value to the `js.Set` object. - Returns the `js.Set` object. - **/ - function add(value:T):Set; - - /** - Removes the element associated to the value and returns the value that - `has(value)` would have previously returned. - `has(value)` will return `false` afterwards. - **/ - function delete(value:T):Bool; - - /** - Removes all elements from the `js.Set` object. - **/ - function clear():Void; - - /** - Calls `callback` once for each key-value pair present in the `js.Set` - object, in insertion order. - - If a `thisArg` parameter is provided to forEach, it will be used as the - `this` value for each callback. - **/ - function forEach(callback:(value:T, key:T, set:Set)->Void, ?thisArg:Any):Void; - - /** - Returns a new `JsIterator` object that contains the keys for each element - in the `js.Set` object in insertion order. - **/ - function keys():JsIterator; - - /** - Returns a new `JsIterator` object that contains the values for each - element in the `js.Set` object in insertion order. - **/ - function values():JsIterator; - - /** - Returns a new `JsIterator` object that contains an array of - `[value, value]` for each element in the `js.Set` object, in insertion - order. - This is kept similar to the `js.Map` object, so that each entry has the - same value for its key and value here. - **/ - function entries():JsIterator>; -} +@:deprecated typedef Set = js.lib.Set; diff --git a/std/js/Symbol.hx b/std/js/Symbol.hx index 1beb48f531a..9ffa2fa281d 100644 --- a/std/js/Symbol.hx +++ b/std/js/Symbol.hx @@ -21,41 +21,4 @@ */ package js; -@:native("Symbol") -extern class Symbol { - /** - To create a new primitive symbol, you write `new Symbol()` with an optional string as its `description`. - - NOTE: Unlike plain JavaScript, in Haxe `new Symbol()` syntax is used, however `Symbol(...)` expression - will be generated as required by JavaScript specification. - **/ - @:pure @:selfCall function new(?description:String); - - /** - Searches for existing symbols with the given key and returns it if found. - Otherwise a new symbol gets created in the global symbol registry with this key. - **/ - @:native("for") static function for_(key:String):Symbol; - - /** - Retrieves a shared symbol key from the global symbol registry for the given symbol. - **/ - @:pure static function keyFor(sym:Symbol):Null; - - /** - Returns a string containing the description of the Symbol. - **/ - @:pure function toString():String; - - /** - A method returning the default iterator for an object. - **/ - static var iterator(default,null):Symbol; - - /** - Retrieve symbol from a given `object`. - - NOTE: This is a Haxe-specific method that generates `object[symbol]` expression. - **/ - inline function ofObject(object:{}):Null return (cast object)[cast this]; -} +@:deprecated typedef Symbol = js.lib.Symbol; \ No newline at end of file diff --git a/std/js/_std/EReg.hx b/std/js/_std/EReg.hx index bd2a74567c8..f8556ffb723 100644 --- a/std/js/_std/EReg.hx +++ b/std/js/_std/EReg.hx @@ -112,11 +112,11 @@ public static inline function escape( s : String ) : String { return (cast s).replace(escapeRe, "\\$&"); } - static var escapeRe = new js.RegExp("[.*+?^${}()|[\\]\\\\]", "g"); + static var escapeRe = new js.lib.RegExp("[.*+?^${}()|[\\]\\\\]", "g"); } @:native("RegExp") -private extern class HaxeRegExp extends js.RegExp { - var m:js.RegExp.RegExpMatch; +private extern class HaxeRegExp extends js.lib.RegExp { + var m:js.lib.RegExp.RegExpMatch; var s:String; } diff --git a/std/js/_std/Reflect.hx b/std/js/_std/Reflect.hx index 5d3033ead47..9d7d313a0d6 100644 --- a/std/js/_std/Reflect.hx +++ b/std/js/_std/Reflect.hx @@ -23,7 +23,7 @@ @:pure public inline static function hasField( o : Dynamic, field : String ) : Bool { - return js.Object.prototype.hasOwnProperty.call(o, field); + return js.lib.Object.prototype.hasOwnProperty.call(o, field); } @:pure @@ -46,13 +46,13 @@ } public inline static function callMethod( o : Dynamic, func : haxe.Constraints.Function, args : Array ) : Dynamic { - return (cast func : js.Function).apply(o,args); + return (cast func : js.lib.Function).apply(o,args); } public static function fields( o : Dynamic ) : Array { var a = []; if (o != null) untyped { - var hasOwnProperty = js.Object.prototype.hasOwnProperty; + var hasOwnProperty = js.lib.Object.prototype.hasOwnProperty; __js__("for( var f in o ) {"); if( f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o, f) ) a.push(f); __js__("}"); diff --git a/std/js/_std/Type.hx b/std/js/_std/Type.hx index 6027d04d637..ab1df228034 100644 --- a/std/js/_std/Type.hx +++ b/std/js/_std/Type.hx @@ -138,7 +138,7 @@ enum ValueType { } public static inline function createEmptyInstance(cl:Class):T { - return js.Object.create((cast cl).prototype); + return js.lib.Object.create((cast cl).prototype); } #end public static function createEnum(e:Enum, constr:String, ?params:Array):T { @@ -166,7 +166,7 @@ enum ValueType { public static function getInstanceFields(c:Class):Array { var result = []; while (c != null) { - for (name in js.Object.getOwnPropertyNames((cast c).prototype)) { + for (name in js.lib.Object.getOwnPropertyNames((cast c).prototype)) { switch name { case "constructor" | "__class__" | "__properties__": // skip special names @@ -181,7 +181,7 @@ enum ValueType { } public static function getClassFields(c:Class):Array { - var a = js.Object.getOwnPropertyNames(cast c); + var a = js.lib.Object.getOwnPropertyNames(cast c); a.remove("__id__"); a.remove("hx__closures__"); a.remove("__name__"); diff --git a/std/js/html/Animation.hx b/std/js/html/Animation.hx index 2f50062ffd9..fbaab563fb4 100644 --- a/std/js/html/Animation.hx +++ b/std/js/html/Animation.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `Animation` interface of the Web Animations API represents a single animation player and provides playback controls and a timeline for an animation node or source. @@ -33,98 +35,98 @@ package js.html; **/ @:native("Animation") extern class Animation extends EventTarget { - + /** Gets and sets the `String` used to identify the animation. **/ var id : String; - + /** Gets and sets the `AnimationEffectReadOnly` associated with this animation. This will usually be a `KeyframeEffect` object. **/ var effect : AnimationEffect; - + /** Gets or sets the `AnimationTimeline` associated with this animation. **/ var timeline : AnimationTimeline; - + /** Gets or sets the scheduled time when an animation's playback should begin. **/ var startTime : Float; - + /** The current time value of the animation in milliseconds, whether running or paused. If the animation lacks a `AnimationTimeline`, is inactive or hasn't been played yet, its value is `null`. **/ var currentTime : Float; - + /** Gets or sets the playback rate of the animation. **/ var playbackRate : Float; - + /** Returns an enumerated value describing the playback state of an animation. **/ var playState(default,null) : AnimationPlayState; - + /** Indicates whether the animation is currently waiting for an asynchronous operation such as initiating playback or pausing a running animation. **/ var pending(default,null) : Bool; - + /** Returns the current ready Promise for this animation. **/ var ready(default,null) : Promise; - + /** Returns the current finished Promise for this animation. **/ var finished(default,null) : Promise; - + /** Gets and sets the event handler for the `finish` event. **/ var onfinish : haxe.Constraints.Function; - + /** Gets and sets the event handler for the `cancel` event. **/ var oncancel : haxe.Constraints.Function; - + /** @throws DOMError */ function new( ?effect : AnimationEffect, ?timeline : AnimationTimeline ) : Void; - + /** Clears all `KeyframeEffect` caused by this animation and aborts its playback. **/ function cancel() : Void; - + /** Seeks either end of an animation, depending on whether the animation is playing or reversing. @throws DOMError **/ function finish() : Void; - + /** Starts or resumes playing of an animation, or begins the animation again if it previously finished. @throws DOMError **/ function play() : Void; - + /** Suspends playing of an animation. @throws DOMError **/ function pause() : Void; - + /** Sets the speed of an animation after first synchronizing its playback position. **/ function updatePlaybackRate( playbackRate : Float ) : Void; - + /** Reverses playback direction, stopping at the start of the animation. If the animation is finished or unplayed, it will play from end to beginning. @throws DOMError diff --git a/std/js/html/Cache.hx b/std/js/html/Cache.hx index d525245685b..93b9bd6d39d 100644 --- a/std/js/html/Cache.hx +++ b/std/js/html/Cache.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `Cache` interface provides a storage mechanism for `Request` / `Response` object pairs that are cached, for example as part of the `ServiceWorker` life cycle. Note that the `Cache` interface is exposed to windowed scopes as well as workers. You don't have to use it in conjunction with service workers, even though it is defined in the service worker spec. diff --git a/std/js/html/CacheStorage.hx b/std/js/html/CacheStorage.hx index 28429e75806..8a7546b07f0 100644 --- a/std/js/html/CacheStorage.hx +++ b/std/js/html/CacheStorage.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `CacheStorage` interface represents the storage for `Cache` objects. @@ -35,28 +37,28 @@ package js.html; extern class CacheStorage { /** @throws DOMError */ function new( namespace : CacheStorageNamespace, principal : Dynamic/*MISSING Principal*/ ) : Void; - + /** Checks if a given `Request` is a key in any of the `Cache` objects that the `CacheStorage` object tracks, and returns a `Promise` that resolves to that match. **/ @:overload( function( request : String, ?options : CacheQueryOptions) : Promise {} ) function match( request : Request, ?options : CacheQueryOptions ) : Promise; - + /** Returns a `Promise` that resolves to `true` if a `Cache` object matching the `cacheName` exists. **/ function has( cacheName : String ) : Promise; - + /** Returns a `Promise` that resolves to the `Cache` object matching the `cacheName` (a new cache is created if it doesn't already exist.) **/ function open( cacheName : String ) : Promise; - + /** Finds the `Cache` object matching the `cacheName`, and if found, deletes the `Cache` object and returns a `Promise` that resolves to `true`. If no `Cache` object is found, it returns `false`. **/ function delete( cacheName : String ) : Promise; - + /** Returns a `Promise` that will resolve with an array containing strings corresponding to all of the named `Cache` objects tracked by the `CacheStorage`. Use this method to iterate over a list of all the `Cache` objects. **/ diff --git a/std/js/html/Directory.hx b/std/js/html/Directory.hx index 271c061e7c0..719d3559727 100644 --- a/std/js/html/Directory.hx +++ b/std/js/html/Directory.hx @@ -24,11 +24,13 @@ package js.html; +import js.lib.Promise; + @:native("Directory") extern class Directory { var name(default,null) : String; var path(default,null) : String; - + /** @throws DOMError */ function new( path : String ) : Void; /** @throws DOMError */ diff --git a/std/js/html/FontFace.hx b/std/js/html/FontFace.hx index ab4c77b975a..7110e6a3845 100644 --- a/std/js/html/FontFace.hx +++ b/std/js/html/FontFace.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `FontFace` interface represents a single usable font face. It allows control of the source of the font face, being a URL to an external resource, or a buffer; it also allows control of when the font face is loaded and its current status. @@ -33,57 +35,57 @@ package js.html; **/ @:native("FontFace") extern class FontFace { - + /** Is a `CSSOMString` that contains the family of the font. It is equivalent to the `@font-face/font-family` descriptor. **/ var family : String; - + /** Is a `CSSOMString` that contains the style of the font. It is equivalent to the `@font-face/font-style` descriptor. **/ var style : String; - + /** Is a `CSSOMString` that contains the weight of the font. It is equivalent to the `@font-face/font-weight` descriptor. **/ var weight : String; - + /** Is a `CSSOMString` that contains how the font stretches. It is equivalent to the `@font-face/font-stretch` descriptor. **/ var stretch : String; - + /** Is a `CSSOMString` that contains the range of code encompassed the font. It is equivalent to the `@font-face/unicode-range` descriptor. **/ var unicodeRange : String; - + /** Is a `CSSOMString` that contains the variant of the font. It is equivalent to the `@font-face/font-variant` descriptor. **/ var variant : String; - + /** Is a `CSSOMString` that contains the features of the font. It is equivalent to the `@font-face/font-feature-settings`descriptor. **/ var featureSettings : String; - + /** Returns an enumerated value indicating the status of the font. It can be one of the following: `"unloaded"`, `"loading"`, `"loaded"`, or `"error"`. **/ var status(default,null) : FontFaceLoadStatus; - + /** Returns a `Promise` to a `FontFace` that fulfills when the font is completely loaded and rejects when an error happens. **/ var loaded(default,null) : Promise; - + /** @throws DOMError */ @:overload( function( family : String, source : js.lib.ArrayBuffer, ?descriptors : FontFaceDescriptors) : FontFace {} ) @:overload( function( family : String, source : js.lib.ArrayBufferView, ?descriptors : FontFaceDescriptors) : FontFace {} ) function new( family : String, source : String, ?descriptors : FontFaceDescriptors ) : Void; - + /** Loads the font, returning a `Promise` to a `FontFace` that fulfills when the font is completely loaded and rejects when an error happens. @throws DOMError diff --git a/std/js/html/FontFaceSet.hx b/std/js/html/FontFaceSet.hx index 16b038048c6..85f5de51690 100644 --- a/std/js/html/FontFaceSet.hx +++ b/std/js/html/FontFaceSet.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `FontFaceSet` interface of the CSS Font Loading API manages the loading of font-faces and querying of their download status. @@ -34,28 +36,28 @@ package js.html; @:native("FontFaceSet") extern class FontFaceSet extends EventTarget { var size(default,null) : Int; - + /** An `EventListener` called whenever an event of type `loading` is fired, indicating a font-face set has started loading. **/ var onloading : haxe.Constraints.Function; - + /** An `EventListener` called whenever an event of type `loadingdone` is fired, indicating that a font face set has finished loading. **/ var onloadingdone : haxe.Constraints.Function; - + /** An `EventListener` called whenever an event of type `loadingerror` is fired, indicating that an error occurred whilst loading a font-face set. **/ var onloadingerror : haxe.Constraints.Function; var ready(default,null) : Promise; - + /** Indicates the font-face's loading status. It will be one of `'loading'` or `'loaded'`. **/ var status(default,null) : FontFaceSetLoadStatus; - + /** @throws DOMError */ function add( font : FontFace ) : Void; function has( font : FontFace ) : Bool; diff --git a/std/js/html/MediaDevices.hx b/std/js/html/MediaDevices.hx index 851c992d311..2bdef74379a 100644 --- a/std/js/html/MediaDevices.hx +++ b/std/js/html/MediaDevices.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `MediaDevices` interface provides access to connected media input devices like cameras and microphones, as well as screen sharing. In essence, it lets you obtain access to any hardware source of media data. @@ -33,12 +35,12 @@ package js.html; **/ @:native("MediaDevices") extern class MediaDevices extends EventTarget { - + /** The event handler for the `devicechange` event. This event is delivered to the `MediaDevices` object when a media input or output device is attached to or removed from the user's computer. **/ var ondevicechange : haxe.Constraints.Function; - + function getSupportedConstraints() : MediaTrackSupportedConstraints; /** @throws DOMError */ function enumerateDevices() : Promise>; diff --git a/std/js/html/MediaElement.hx b/std/js/html/MediaElement.hx index ac5f485f6f8..9ef5ac73957 100644 --- a/std/js/html/MediaElement.hx +++ b/std/js/html/MediaElement.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `HTMLMediaElement` interface adds to `HTMLElement` the properties and methods needed to support basic media-related capabilities that are common to audio and video. @@ -42,198 +44,198 @@ extern class MediaElement extends Element { static inline var HAVE_CURRENT_DATA : Int = 2; static inline var HAVE_FUTURE_DATA : Int = 3; static inline var HAVE_ENOUGH_DATA : Int = 4; - - + + /** Returns a `MediaError` object for the most recent error, or `null` if there has not been an error. **/ var error(default,null) : MediaError; - + /** Is a `DOMString` that reflects the `src` HTML attribute, which contains the URL of a media resource to use. **/ var src : String; - + /** Returns a `DOMString` with the absolute URL of the chosen media resource. **/ var currentSrc(default,null) : String; - + /** Is a `DOMString` indicating the CORS setting for this media element. **/ var crossOrigin : String; - + /** Returns a `unsigned short` (enumeration) indicating the current state of fetching the media over the network. **/ var networkState(default,null) : Int; - + /** Is a `DOMString` that reflects the `preload` HTML attribute, indicating what data should be preloaded, if any. Possible values are: `none`, `metadata`, `auto`. **/ var preload : String; - + /** Returns a `TimeRanges` object that indicates the ranges of the media source that the browser has buffered (if any) at the moment the `buffered` property is accessed. **/ var buffered(default,null) : TimeRanges; - + /** Returns a `unsigned short` (enumeration) indicating the readiness state of the media. **/ var readyState(default,null) : Int; - + /** Returns a `Boolean` that indicates whether the media is in the process of seeking to a new position. **/ var seeking(default,null) : Bool; - + /** Is a `double` indicating the current playback time in seconds. Setting this value seeks the media to the new time. **/ var currentTime : Float; - + /** Returns a `double` indicating the length of the media in seconds, or 0 if no media data is available. **/ var duration(default,null) : Float; - + /** Returns a `Boolean` that indicates whether the media element is paused. **/ var paused(default,null) : Bool; - + /** Is a `double` indicating the default playback rate for the media. **/ var defaultPlaybackRate : Float; - + /** Is a `double` that indicates the rate at which the media is being played back.  **/ var playbackRate : Float; - + /** Returns a `TimeRanges` object that contains the ranges of the media source that the browser has played, if any. **/ var played(default,null) : TimeRanges; - + /** Returns a `TimeRanges` object that contains the time ranges that the user is able to seek to, if any. **/ var seekable(default,null) : TimeRanges; - + /** Returns a `Boolean` that indicates whether the media element has finished playing. **/ var ended(default,null) : Bool; - + /** A `Boolean` that reflects the `autoplay` HTML attribute, indicating whether playback should automatically begin as soon as enough media is available to do so without interruption. Sites which automatically play audio (or videos with an audio track) can be an unpleasant experience for users, so it should be avoided when possible. If you must offer autoplay functionality, you should make it opt-in (requiring a user to specifically enable it). However, this can be useful when creating media elements whose source will be set at a later time, under user control. - + **/ var autoplay : Bool; - + /** Is a `Boolean` that reflects the `loop` HTML attribute, which indicates whether the media element should start over when it reaches the end. **/ var loop : Bool; - + /** Is a `Boolean` that reflects the `controls` HTML attribute, indicating whether user interface items for controlling the resource should be displayed. **/ var controls : Bool; - + /** Is a `double` indicating the audio volume, from 0.0 (silent) to 1.0 (loudest). **/ var volume : Float; - + /** Is a `Boolean` that determines whether audio is muted. `true` if the audio is muted and `false` otherwise. **/ var muted : Bool; - + /** Is a `Boolean` that reflects the `muted` HTML attribute, which indicates whether the media element's audio output should be muted by default. **/ var defaultMuted : Bool; - + /** A `AudioTrackList` that lists the `AudioTrack` objects contained in the element. **/ var audioTracks(default,null) : AudioTrackList; - + /** Returns the list of `VideoTrack` objects contained in the element. - + Gecko supports only single track playback, and the parsing of tracks' metadata is only available for media with the Ogg container format. - - + + **/ var videoTracks(default,null) : VideoTrackList; - + /** Returns the list of `TextTrack` objects contained in the element. **/ var textTracks(default,null) : TextTrackList; - + /** Is a `MediaStream` representing the media to play or that has played in the current `HTMLMediaElement`, or `null` if not assigned. **/ var srcObject : MediaStream; - + /** Returns a `MediaKeys` object or `null`. MediaKeys is a set of keys that an associated HTMLMediaElement can use for decryption of media data during playback. **/ var mediaKeys(default,null) : js.html.eme.MediaKeys; - + /** Sets the `EventHandler` called when the media is encrypted. **/ var onencrypted : haxe.Constraints.Function; - + /** Sets the `EventHandler` called when playback is blocked while waiting for an encryption key. **/ var onwaitingforkey : haxe.Constraints.Function; - - + + /** Resets the media element and restarts the media resource. Any pending events are discarded. How much media data is fetched is still affected by the `preload` attribute. This method can be useful for releasing resources after any `src` attribute and `source` element descendants have been removed. Otherwise, it is usually unnecessary to use this method, unless required to rescan `source` element children after dynamic changes. **/ function load() : Void; - + /** Determines whether the specified media type can be played back. **/ function canPlayType( type : String ) : String; - + /** Directly seeks to the given time. @throws DOMError **/ function fastSeek( time : Float ) : Void; - + /** Begins playback of the media. @throws DOMError **/ function play() : Promise; - + /** Pauses the media playback. @throws DOMError **/ function pause() : Void; - + /** Adds a text track (such as a track for subtitles) to a media element. **/ function addTextTrack( kind : TextTrackKind, label : String = "", language : String = "" ) : TextTrack; - + /** Returns `Promise`. Sets the `MediaKeys` keys to use when decrypting media during playback. **/ diff --git a/std/js/html/MediaStreamTrack.hx b/std/js/html/MediaStreamTrack.hx index e686256b036..255bfc10fec 100644 --- a/std/js/html/MediaStreamTrack.hx +++ b/std/js/html/MediaStreamTrack.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `MediaStreamTrack` interface represents a single media track within a stream; typically, these are audio or video tracks, but other track types may exist as well. @@ -33,82 +35,82 @@ package js.html; **/ @:native("MediaStreamTrack") extern class MediaStreamTrack extends EventTarget { - + /** Returns a `DOMString` set to `"audio"` if the track is an audio track and to `"video"`, if it is a video track. It doesn't change if the track is deassociated from its source. **/ var kind(default,null) : String; - + /** Returns a `DOMString` containing a unique identifier (GUID) for the track; it is generated by the browser. **/ var id(default,null) : String; - + /** Returns a `DOMString` containing a user agent-assigned label that identifies the track source, as in `"internal microphone"`. The string may be left empty and is empty as long as no source has been connected. When the track is deassociated from its source, the label is not changed. **/ var label(default,null) : String; - + /** A Boolean whose value of `true` if the track is enabled, that is allowed to render the media source stream; or `false` if it is disabled, that is not rendering the media source stream but silence and blackness. If the track has been disconnected, this value can be changed but has no more effect. Note: You can implement standard "mute" functionality by setting `enabled` to `false`. The `muted` property refers to a condition in which there's no media because of a technical issue. - + **/ var enabled : Bool; - + /** Returns a Boolean value indicating whether the track is unable to provide media data due to a technical issue. Note: You can implement standard "mute" functionality by setting `enabled` to `false`, and unmute the media by setting it back to `true` again. - + **/ var muted(default,null) : Bool; - + /** An `EventHandler` containing the action to perform when an `mute` event is fired on the object, that is when the streaming is terminating. **/ var onmute : haxe.Constraints.Function; - + /** An `EventHandler` containing the action to perform when an `unmute` event is fired on the object, that is when a  `MediaStreamTrack` object is removed from it. **/ var onunmute : haxe.Constraints.Function; - + /** Returns an enumerated value giving the status of the track. This will be one of the following values: - + `"live"` which indicates that an input is connected and does its best-effort in providing real-time data. In that case, the output of data can be switched on or off using the `MediaStreamTrack.enabled` attribute. `"ended"` which indicates that the input is not giving any more data and will never provide new data. - - + + **/ var readyState(default,null) : MediaStreamTrackState; - + /** An `EventHandler` containing the action to perform when an `ended_(MediaStream)` event is fired on the object, that is when a  `MediaStreamTrack` object is removed from it. **/ var onended : haxe.Constraints.Function; - - + + /** Returns a duplicate of the `MediaStreamTrack`. **/ function clone() : MediaStreamTrack; - + /** Stops playing the source associated to the track, both the source and the track are deassociated. The track state is set to `ended`. **/ function stop() : Void; - + /** Returns a `MediaTrackConstraints` object containing the currently set constraints for the track; the returned value matches the constraints last set using `MediaStreamTrack.applyConstraints`. **/ function getConstraints() : MediaTrackConstraints; - + /** Returns a `MediaTrackSettings` object containing the current values of each of the `MediaStreamTrack`'s constrainable properties. **/ function getSettings() : MediaTrackSettings; - + /** Lets the application specify the ideal and/or ranges of acceptable values for any number of the available constrainable properties of the `MediaStreamTrack`. @throws DOMError diff --git a/std/js/html/Navigator.hx b/std/js/html/Navigator.hx index b7c44026001..5f2701dab12 100644 --- a/std/js/html/Navigator.hx +++ b/std/js/html/Navigator.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `Navigator` interface represents the state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities. @@ -33,61 +35,61 @@ package js.html; **/ @:native("Navigator") extern class Navigator { - + /** Returns a `Permissions` object that can be used to query and update permission status of APIs covered by the Permissions API. **/ var permissions(default,null) : Permissions; var mimeTypes(default,null) : MimeTypeArray; var plugins(default,null) : PluginArray; - + /** Reports the value of the user's do-not-track preference. When this value is "yes", your web site or application should not track the user. **/ var doNotTrack(default,null) : String; var maxTouchPoints(default,null) : Int; - + /** Returns a string that represents the current operating system. **/ var oscpu(default,null) : String; - + /** Returns the vendor name of the current browser (e.g., "Netscape6"). **/ var vendor(default,null) : String; - + /** Returns the vendor version number (e.g. "6.1"). **/ var vendorSub(default,null) : String; - + /** Returns the build number of the current browser (e.g., "20060909"). **/ var productSub(default,null) : String; - + /** Returns false if setting a cookie will be ignored and true otherwise. **/ var cookieEnabled(default,null) : Bool; - + /** Returns the build identifier of the browser (e.g., "2006090803"). **/ var buildID(default,null) : String; - + /** Returns a reference to a `MediaDevices` object which can then be used to get information about available media devices (`MediaDevices.enumerateDevices()`), find out what constrainable properties are supported for media on the user's computer and user agent (`MediaDevices.getSupportedConstraints()`), and to request access to media using `MediaDevices.getUserMedia()`. **/ var mediaDevices(default,null) : MediaDevices; - + /** Returns a `ServiceWorkerContainer` object, which provides access to registration, removal, upgrade, and communication with the `ServiceWorker` objects for the associated document. **/ var serviceWorker(default,null) : ServiceWorkerContainer; var hardwareConcurrency(default,null) : Int; - + /** Returns a `Geolocation` object allowing accessing the location of the device. **/ @@ -102,7 +104,7 @@ extern class Navigator { var languages(default,null) : Array; var onLine(default,null) : Bool; var storage(default,null) : StorageManager; - + @:overload( function( duration : Int ) : Bool {} ) function vibrate( pattern : Array ) : Bool; function javaEnabled() : Bool; diff --git a/std/js/html/Permissions.hx b/std/js/html/Permissions.hx index 5dfcd66e07e..52a61226fb3 100644 --- a/std/js/html/Permissions.hx +++ b/std/js/html/Permissions.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** Documentation [Permissions](https://developer.mozilla.org/en-US/docs/Web/API/Permissions) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/API/Permissions$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). @@ -31,7 +33,7 @@ package js.html; **/ @:native("Permissions") extern class Permissions { - + /** Returns the user permission status for a given API. @throws DOMError diff --git a/std/js/html/Request.hx b/std/js/html/Request.hx index d69f93036c8..3c0f7abf921 100644 --- a/std/js/html/Request.hx +++ b/std/js/html/Request.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `Request` interface of the Fetch API represents a resource request. @@ -33,68 +35,68 @@ package js.html; **/ @:native("Request") extern class Request { - + /** Contains the request's method (`GET`, `POST`, etc.) **/ var method(default,null) : String; - + /** Contains the URL of the request. **/ var url(default,null) : String; - + /** Contains the associated `Headers` object of the request. **/ var headers(default,null) : Headers; - + /** Returns a string from the `RequestDestination` enum describing the request's destination. This is a string indicating the type of content being requested. **/ var destination(default,null) : RequestDestination; - + /** Contains the referrer of the request (e.g., `client`). **/ var referrer(default,null) : String; - + /** Contains the referrer policy of the request (e.g., `no-referrer`). **/ var referrerPolicy(default,null) : ReferrerPolicy; - + /** Contains the mode of the request (e.g., `cors`, `no-cors`, `same-origin`, `navigate`.) **/ var mode(default,null) : RequestMode; - + /** Contains the credentials of the request (e.g., `"omit"`, `"same-origin"`, `"include"`). The default is `"same-origin"`. **/ var credentials(default,null) : RequestCredentials; - + /** Contains the cache mode of the request (e.g., `default`, `reload`, `no-cache`). **/ var cache(default,null) : RequestCache; - + /** Contains the mode for how redirects are handled. It may be one of `follow`, `error`, or `manual`. **/ var redirect(default,null) : RequestRedirect; - + /** Contains the subresource integrity value of the request (e.g., `sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=`). **/ var integrity(default,null) : String; var signal(default,null) : AbortSignal; var bodyUsed(default,null) : Bool; - + /** @throws DOMError */ @:overload( function( input : String, ?init : RequestInit) : Request {} ) function new( input : Request, ?init : RequestInit ) : Void; - + /** Creates a copy of the current `Request` object. @throws DOMError diff --git a/std/js/html/Response.hx b/std/js/html/Response.hx index ae82e48c94c..006bf5fdd06 100644 --- a/std/js/html/Response.hx +++ b/std/js/html/Response.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `Response` interface of the Fetch API represents the response to a request. @@ -33,54 +35,54 @@ package js.html; **/ @:native("Response") extern class Response { - + /** Returns a new `Response` object associated with a network error. **/ static function error() : Response; - + /** Creates a new response with a different URL. @throws DOMError **/ static function redirect( url : String, status : Int = 302 ) : Response; - + /** Contains the type of the response (e.g., `basic`, `cors`). **/ var type(default,null) : ResponseType; - + /** Contains the URL of the response. **/ var url(default,null) : String; - + /** Indicates whether or not the response is the result of a redirect; that is, its URL list has more than one entry. **/ var redirected(default,null) : Bool; - + /** Contains the status code of the response (e.g., `200` for a success). **/ var status(default,null) : Int; - + /** Contains a boolean stating whether the response was successful (status in the range 200-299) or not. **/ var ok(default,null) : Bool; - + /** Contains the status message corresponding to the status code (e.g., `OK` for `200`). **/ var statusText(default,null) : String; - + /** Contains the `Headers` object associated with the response. **/ var headers(default,null) : Headers; var bodyUsed(default,null) : Bool; - + /** @throws DOMError */ @:overload( function( ?body : js.lib.ArrayBufferView, ?init : ResponseInit) : Response {} ) @:overload( function( ?body : js.lib.ArrayBuffer, ?init : ResponseInit) : Response {} ) @@ -89,7 +91,7 @@ extern class Response { @:overload( function( ?body : Dynamic/*MISSING ReadableStream*/, ?init : ResponseInit) : Response {} ) @:overload( function( ?body : String, ?init : ResponseInit) : Response {} ) function new( ?body : Blob, ?init : ResponseInit ) : Void; - + /** Creates a clone of a `Response` object. @throws DOMError diff --git a/std/js/html/ScreenOrientation.hx b/std/js/html/ScreenOrientation.hx index 9dc4daf9fff..10a580e511d 100644 --- a/std/js/html/ScreenOrientation.hx +++ b/std/js/html/ScreenOrientation.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `ScreenOrientation` interface of the the Screen Orientation API provides information about the current orientation of the document. @@ -33,29 +35,29 @@ package js.html; **/ @:native("ScreenOrientation") extern class ScreenOrientation extends EventTarget { - + /** Returns the document's current orientation type, one of "portrait-primary", "portrait-secondary", "landscape-primary", or "landscape-secondary". **/ var type(default,null) : OrientationType; - + /** Returns the document's current orientation angle. **/ var angle(default,null) : Int; - + /** Fired whenever is the `EventHandler` called when the screen changes orientation. **/ var onchange : haxe.Constraints.Function; - - + + /** Locks the orientation of the containing document to its default orientation and returns a `Promise`.  @throws DOMError **/ function lock( orientation : OrientationLockType ) : Promise; - + /** Unlocks the orientation of the containing document from its default orientation. @throws DOMError diff --git a/std/js/html/ServiceWorkerContainer.hx b/std/js/html/ServiceWorkerContainer.hx index 7b04948d492..af1cdde5f4d 100644 --- a/std/js/html/ServiceWorkerContainer.hx +++ b/std/js/html/ServiceWorkerContainer.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `ServiceWorkerContainer` interface of the ServiceWorker API provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister and update service workers, and access the state of service workers and their registrations. @@ -33,39 +35,39 @@ package js.html; **/ @:native("ServiceWorkerContainer") extern class ServiceWorkerContainer extends EventTarget { - + /** Returns a `ServiceWorker` object if its state is `activated` (the same object returned by `ServiceWorkerRegistration.active`). This property returns `null` during a force-refresh request (Shift + refresh) or if there is no active worker. **/ var controller(default,null) : ServiceWorker; - + /** Provides a way of delaying code execution until a service worker is active. It returns a `Promise` that will never reject, and which waits indefinitely until the `ServiceWorkerRegistration` associated with the current page has an `ServiceWorkerRegistration.active` worker. Once that condition is met, it resolves with the `ServiceWorkerRegistration`. **/ var ready(default,null) : Promise; - + /** Fired whenever a `controllerchange` event occurs — when the document's associated `ServiceWorkerRegistration` acquires a new `ServiceWorkerRegistration.active` worker. **/ var oncontrollerchange : haxe.Constraints.Function; - + /** Fired whenever an `error` event occurs in the associated service workers. **/ var onerror : haxe.Constraints.Function; - + /** Fired whenever a `message` event occurs — when incoming messages are received to the `ServiceWorkerContainer` object (e.g. via a `MessagePort.postMessage()` call.) **/ var onmessage : haxe.Constraints.Function; - + function register( scriptURL : String, ?options : RegistrationOptions ) : Promise; - + /** Gets a `ServiceWorkerRegistration` object whose scope matches the provided document URL.  If the method can't return a `ServiceWorkerRegistration`, it returns a `Promise`.  **/ function getRegistration( documentURL : String = "" ) : Promise; - + /** Returns all `ServiceWorkerRegistration` objects associated with a `ServiceWorkerContainer` in an array.  If the method can't return `ServiceWorkerRegistration` objects, it returns a `Promise`.  **/ diff --git a/std/js/html/ServiceWorkerRegistration.hx b/std/js/html/ServiceWorkerRegistration.hx index a5b958b599d..f431d128afd 100644 --- a/std/js/html/ServiceWorkerRegistration.hx +++ b/std/js/html/ServiceWorkerRegistration.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `ServiceWorkerRegistration` interface of the ServiceWorker API represents the service worker registration. You register a service worker to control one or more pages that share the same origin. @@ -33,57 +35,57 @@ package js.html; **/ @:native("ServiceWorkerRegistration") extern class ServiceWorkerRegistration extends EventTarget { - + /** Returns a service worker whose state is `installing`. This is initially set to `null`. **/ var installing(default,null) : ServiceWorker; - + /** Returns a service worker whose state is `waiting`. This is initially set to `null`. **/ var waiting(default,null) : ServiceWorker; - + /** Returns a service worker whose state is either `activating` or `activated`. This is initially set to `null`. An active worker will control a `ServiceWorkerClient` if the client's URL falls within the scope of the registration (the `scope` option set when `ServiceWorkerContainer.register` is first called.) **/ var active(default,null) : ServiceWorker; - + /** Returns a unique identifier for a service worker registration. This must be on the same origin as the document that registers the `ServiceWorker`. **/ var scope(default,null) : String; var updateViaCache(default,null) : ServiceWorkerUpdateViaCache; - + /** An `EventListener` property called whenever an event of type `updatefound` is fired; it is fired any time the `ServiceWorkerRegistration.installing` property acquires a new service worker. **/ var onupdatefound : haxe.Constraints.Function; - + /** Returns a reference to the `PushManager` interface for managing push subscriptions including subscribing, getting an active subscription, and accessing push permission status. **/ var pushManager(default,null) : js.html.push.PushManager; - - + + /** Checks the server for an updated version of the service worker without consulting caches. @throws DOMError **/ function update() : Promise; - + /** Unregisters the service worker registration and returns a `Promise`. The service worker will finish any ongoing operations before it is unregistered. @throws DOMError **/ function unregister() : Promise; - + /** Displays the notification with the requested title. @throws DOMError **/ function showNotification( title : String, ?options : NotificationOptions ) : Promise; - + /** Returns a `Promise` that resolves to an array of `Notification` objects. @throws DOMError diff --git a/std/js/html/StorageManager.hx b/std/js/html/StorageManager.hx index 083dd73eb50..27fc26ec4b7 100644 --- a/std/js/html/StorageManager.hx +++ b/std/js/html/StorageManager.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `StorageManager` interface of the the Storage API provides an interface for managing persistance permissions and estimating available storage. You can get a reference to this interface using either `navigator.storage` or `WorkerNavigator.storage`. @@ -33,19 +35,19 @@ package js.html; **/ @:native("StorageManager") extern class StorageManager { - + /** Returns a `Promise` that resolves to `true` if persistence has already been granted for your site's storage. @throws DOMError **/ function persisted() : Promise; - + /** Returns a `Promise` that resolves to `true` if the user agent is able to persist your site's storage. @throws DOMError **/ function persist() : Promise; - + /** Returns a `StorageEstimate` object containing usage and quota numbers for your origin. @throws DOMError diff --git a/std/js/html/SubtleCrypto.hx b/std/js/html/SubtleCrypto.hx index ae75e95ed98..0771ca6e060 100644 --- a/std/js/html/SubtleCrypto.hx +++ b/std/js/html/SubtleCrypto.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `SubtleCrypto` interface represents a set of cryptographic primitives. It is available via the `Crypto.subtle` properties available in a window context (via `Window.crypto`). @@ -33,77 +35,77 @@ package js.html; **/ @:native("SubtleCrypto") extern class SubtleCrypto { - + /** Returns a `Promise` of the encrypted data corresponding to the clear text, algorithm and key given as parameters. @throws DOMError **/ function encrypt( algorithm : haxe.extern.EitherType, key : CryptoKey, data : haxe.extern.EitherType ) : Promise; - + /** Returns a `Promise` of the clear data corresponding to the encrypted text, algorithm and key given as parameters. @throws DOMError **/ function decrypt( algorithm : haxe.extern.EitherType, key : CryptoKey, data : haxe.extern.EitherType ) : Promise; - + /** Returns a `Promise` of the signature corresponding to the text, algorithm and key given as parameters. @throws DOMError **/ function sign( algorithm : haxe.extern.EitherType, key : CryptoKey, data : haxe.extern.EitherType ) : Promise; - + /** Returns a `Promise` of a `Boolean` value indicating if the signature given as parameter matches the text, algorithm and key also given as parameters. @throws DOMError **/ function verify( algorithm : haxe.extern.EitherType, key : CryptoKey, signature : haxe.extern.EitherType, data : haxe.extern.EitherType ) : Promise; - + /** Returns a `Promise` of a digest generated from the algorithm and text given as parameters. @throws DOMError **/ function digest( algorithm : haxe.extern.EitherType, data : haxe.extern.EitherType ) : Promise; - + /** Returns a `Promise` of a newly generated `CryptoKey`, for symmetrical algorithms, or a `CryptoKeyPair`, containing two newly generated keys, for asymmetrical algorithm, that matches the algorithm, the usages and the extractability given as parameters. @throws DOMError **/ @:overload( function( algorithm : String, extractable : Bool, keyUsages : Array) : Promise {} ) function generateKey( algorithm : Dynamic, extractable : Bool, keyUsages : Array ) : Promise; - + /** Returns a `Promise` of a newly generated `CryptoKey` derived from a master key and a specific algorithm given as parameters. @throws DOMError **/ function deriveKey( algorithm : haxe.extern.EitherType, baseKey : CryptoKey, derivedKeyType : haxe.extern.EitherType, extractable : Bool, keyUsages : Array ) : Promise; - + /** Returns a `Promise` of a newly generated buffer of pseudo-random bits derived from a master key and a specific algorithm given as parameters. @throws DOMError **/ @:overload( function( algorithm : String, baseKey : CryptoKey, length : Int) : Promise {} ) function deriveBits( algorithm : Dynamic, baseKey : CryptoKey, length : Int ) : Promise; - + /** Returns a `Promise` of a `CryptoKey` corresponding to the format, the algorithm, the raw key data, the usages and the extractability given as parameters. @throws DOMError **/ @:overload( function( format : String, keyData : Dynamic, algorithm : String, extractable : Bool, keyUsages : Array) : Promise {} ) function importKey( format : String, keyData : Dynamic, algorithm : Dynamic, extractable : Bool, keyUsages : Array ) : Promise; - + /** Returns a `Promise` of a buffer containing the key in the format requested. @throws DOMError **/ function exportKey( format : String, key : CryptoKey ) : Promise; - + /** Returns a `Promise` of a wrapped symmetric key for usage (transfer, storage) in insecure environments. The wrapped buffer returned is in the format given in parameters, and contains the key wrapped by the given wrapping key with the given algorithm. @throws DOMError **/ @:overload( function( format : String, key : CryptoKey, wrappingKey : CryptoKey, wrapAlgorithm : String) : Promise {} ) function wrapKey( format : String, key : CryptoKey, wrappingKey : CryptoKey, wrapAlgorithm : Dynamic ) : Promise; - + /** Returns a `Promise` of a `CryptoKey` corresponding to the wrapped key given in parameter. @throws DOMError diff --git a/std/js/html/Window.hx b/std/js/html/Window.hx index 4b8a6c37513..ded540ed9aa 100644 --- a/std/js/html/Window.hx +++ b/std/js/html/Window.hx @@ -24,6 +24,8 @@ package js.html; +import js.lib.Promise; + /** The `Window` interface represents a window containing a DOM document; the `document` property points to the DOM document loaded in that window. @@ -33,197 +35,197 @@ package js.html; **/ @:native("Window") extern class Window extends EventTarget { - + /** Returns a reference to the current window. **/ var window(default,null) : Window; - + /** Returns an object reference to the window object itself. **/ var self(default,null) : Window; - + /** Returns a reference to the document that the window contains. **/ var document(default,null) : HTMLDocument; - + /** Gets/sets the name of the window. **/ var name : String; - + /** Gets/sets the location, or current URL, of the window object. **/ var location(default,null) : Location; - + /** Returns a reference to the history object. **/ var history(default,null) : History; - + /** Returns the locationbar object, whose visibility can be toggled in the window. **/ var locationbar(default,null) : BarProp; - + /** Returns the menubar object, whose visibility can be toggled in the window. **/ var menubar(default,null) : BarProp; - + /** Returns the personalbar object, whose visibility can be toggled in the window. **/ var personalbar(default,null) : BarProp; - + /** Returns the scrollbars object, whose visibility can be toggled in the window. **/ var scrollbars(default,null) : BarProp; - + /** Returns the statusbar object, whose visibility can be toggled in the window. **/ var statusbar(default,null) : BarProp; - + /** Returns the toolbar object, whose visibility can be toggled in the window. **/ var toolbar(default,null) : BarProp; - + /** Gets/sets the text in the statusbar at the bottom of the browser. **/ var status : String; - + /** This property indicates whether the current window is closed or not. **/ var closed(default,null) : Bool; - + /** Returns the current event, which is the event currently being handled by the JavaScript code's context, or `undefined` if no event is currently being handled. The `Event` object passed directly to event handlers should be used instead whenever possible. **/ var event(default,null) : Dynamic; - + /** Returns an array of the subframes in the current window. **/ var frames(default,null) : Window; - + /** Returns the number of frames in the window. See also `window.frames`. **/ var length(default,null) : Int; - + /** Returns a reference to the topmost window in the window hierarchy. This property is read only. **/ var top(default,null) : Window; - + /** Returns a reference to the window that opened this current window. **/ var opener : Dynamic; - + /** Returns a reference to the parent of the current window or subframe. **/ var parent(default,null) : Window; - + /** Returns the element in which the window is embedded, or null if the window is not embedded. **/ var frameElement(default,null) : Element; - + /** Returns a reference to the navigator object. **/ var navigator(default,null) : Navigator; - + /** Returns a reference to the console object which provides access to the browser's debugging console. **/ var console(default,null) : ConsoleInstance; - + /** Returns a reference to the screen object associated with the window. **/ var screen(default,null) : Screen; - + /** Gets the width of the content area of the browser window including, if rendered, the vertical scrollbar. **/ var innerWidth : Dynamic; - + /** Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar. **/ var innerHeight : Dynamic; - + /** Returns the number of pixels that the document has already been scrolled horizontally. **/ var scrollX(default,null) : Float; - + /** An alias for `window.scrollX`. **/ var pageXOffset(default,null) : Float; - + /** Returns the number of pixels that the document has already been scrolled vertically. **/ var scrollY(default,null) : Float; - + /** An alias for `window.scrollY` **/ var pageYOffset(default,null) : Float; - + /** Returns the horizontal distance of the left border of the user's browser from the left side of the screen. **/ var screenX : Dynamic; - + /** Returns the vertical distance of the top border of the user's browser from the top side of the screen. **/ var screenY : Dynamic; - + /** Gets the width of the outside of the browser window. **/ var outerWidth : Dynamic; - + /** Gets the height of the outside of the browser window. **/ var outerHeight : Dynamic; - + /** Returns a `Performance` object, which includes the `Performance.timing` and `Performance.navigation` attributes, each of which is an object providing performance-related data. See also Using Navigation Timing for additional information and examples. **/ var performance(default,null) : Performance; - + /** Returns the ratio between physical pixels and device independent pixels in the current display. **/ var devicePixelRatio(default,null) : Float; - + /** The maximum offset that the window can be scrolled to horizontally, that is the document width minus the viewport width. **/ var scrollMaxX(default,null) : Int; - + /** The maximum offset that the window can be scrolled to vertically (i.e., the document height minus the viewport height). **/ var scrollMaxY(default,null) : Int; - + /** This property indicates whether the window is displayed in full screen or not. **/ @@ -234,18 +236,18 @@ extern class Window extends EventTarget { var ondeviceproximity : haxe.Constraints.Function; var onuserproximity : haxe.Constraints.Function; var ondevicelight : haxe.Constraints.Function; - + /** Returns a reference to the content element in the current window. Since Firefox 57 (initially Nightly-only), both versions are only available from chrome (privileged) code, and not available to the web anymore. **/ var content(default,null) : Dynamic; - + /** Returns the orientation in degrees (in 90 degree increments) of the viewport relative to the device's natural orientation. **/ var orientation(default,null) : Int; var onorientationchange : haxe.Constraints.Function; - + /** Returns the browser crypto object. **/ @@ -333,7 +335,7 @@ extern class Window extends EventTarget { var onwebkitanimationstart : haxe.Constraints.Function; var onwebkittransitionend : haxe.Constraints.Function; var onerror : haxe.extern.EitherType -> String -> Int -> Int -> Dynamic -> Dynamic; - + /** Returns a `SpeechSynthesis` object, which is the entry point into using Web Speech API speech synthesis functionality. **/ @@ -356,207 +358,207 @@ extern class Window extends EventTarget { var onpopstate : haxe.Constraints.Function; var onstorage : haxe.Constraints.Function; var onunload : haxe.Constraints.Function; - + /** Returns a reference to the local storage object used to store data that may only be accessed by the origin that created it. **/ var localStorage(default,null) : Storage; var origin(default,null) : String; - + /** Indicates whether a context is capable of using features that require secure contexts. **/ var isSecureContext(default,null) : Bool; var indexedDB(default,null) : js.html.idb.Factory; var caches(default,null) : CacheStorage; - + /** Returns a reference to the session storage object used to store data that may only be accessed by the origin that created it. **/ var sessionStorage(default,null) : Storage; - - + + /** Closes the current window. @throws DOMError **/ function close() : Void; - + /** This method stops window loading. @throws DOMError **/ function stop() : Void; - + /** Sets focus on the current window. @throws DOMError **/ function focus() : Void; - + /** Sets focus away from the window. @throws DOMError **/ function blur() : Void; - + /** Opens a new window. @throws DOMError **/ function open( url : String = "", target : String = "", features : String = "" ) : Window; - + /** Displays an alert dialog. @throws DOMError **/ @:overload( function() : Void {} ) function alert( message : String ) : Void; - + /** Displays a dialog with a message that the user needs to respond to. @throws DOMError **/ function confirm( message : String = "" ) : Bool; - + /** Returns the text entered by the user in a prompt dialog. @throws DOMError **/ function prompt( message : String = "", default_ : String = "" ) : String; - + /** Opens the Print Dialog to print the current document. @throws DOMError **/ function print() : Void; - + /** Provides a secure means for one window to send a string of data to another window, which need not be within the same domain as the first. @throws DOMError **/ function postMessage( message : Dynamic, targetOrigin : String, ?transfer : Array ) : Void; - + /** Registers the window to capture all events of the specified type. **/ function captureEvents() : Void; - + /** Releases the window from trapping events of a specific type. **/ function releaseEvents() : Void; - + /** Returns the selection object representing the selected item(s). @throws DOMError **/ function getSelection() : Selection; - + /** Gets computed style for the specified element. Computed style indicates the computed values of all CSS properties of the element. @throws DOMError **/ function getComputedStyle( elt : Element, pseudoElt : String = "" ) : CSSStyleDeclaration; - + /** Returns a `MediaQueryList` object representing the specified media query string. @throws DOMError **/ function matchMedia( query : String ) : MediaQueryList; - + /** Moves the window to the specified coordinates. @throws DOMError **/ function moveTo( x : Int, y : Int ) : Void; - + /** Moves the current window by a specified amount. @throws DOMError **/ function moveBy( x : Int, y : Int ) : Void; - + /** Dynamically resizes window. @throws DOMError **/ function resizeTo( x : Int, y : Int ) : Void; - + /** Resizes the current window by a certain amount. @throws DOMError **/ function resizeBy( x : Int, y : Int ) : Void; - + /** Scrolls the window to a particular place in the document. **/ @:overload( function( x : Float, y : Float ) : Void {} ) function scroll( ?options : ScrollToOptions ) : Void; - + /** Scrolls to a particular set of coordinates in the document. **/ @:overload( function( x : Float, y : Float ) : Void {} ) function scrollTo( ?options : ScrollToOptions ) : Void; - + /** Scrolls the document in the window by the given amount. **/ @:overload( function( x : Float, y : Float ) : Void {} ) function scrollBy( ?options : ScrollToOptions ) : Void; - + /** Tells the browser that an animation is in progress, requesting that the browser schedule a repaint of the window for the next animation frame. @throws DOMError **/ function requestAnimationFrame( callback : Float -> Void ) : Int; - + /** Enables you to cancel a callback previously scheduled with `Window.requestAnimationFrame`. @throws DOMError **/ function cancelAnimationFrame( handle : Int ) : Void; - + /** Gets default computed style for the specified element, ignoring author stylesheets. @throws DOMError **/ function getDefaultComputedStyle( elt : Element, pseudoElt : String = "" ) : CSSStyleDeclaration; - + /** Scrolls the document by the given number of lines. **/ function scrollByLines( numLines : Int, ?options : ScrollOptions ) : Void; - + /** Scrolls the current document by the specified number of pages. **/ function scrollByPages( numPages : Int, ?options : ScrollOptions ) : Void; - + /** Sizes the window according to its content. @throws DOMError **/ function sizeToContent() : Void; - + /** Updates the state of commands of the current chrome window (UI). **/ function updateCommands( action : String, ?sel : Selection, reason : Int = 0 ) : Void; - + /** Searches for a given string in a window. @throws DOMError **/ function find( str : String = "", caseSensitive : Bool = false, backwards : Bool = false, wrapAround : Bool = false, wholeWord : Bool = false, searchInFrames : Bool = false, showDialog : Bool = false ) : Bool; - + /** Writes a message to the console. **/ function dump( str : String ) : Void; - + /** Toggles a user's ability to resize a window. **/ diff --git a/std/js/html/eme/MediaKeySession.hx b/std/js/html/eme/MediaKeySession.hx index bcd3c612c06..ce8c74db453 100644 --- a/std/js/html/eme/MediaKeySession.hx +++ b/std/js/html/eme/MediaKeySession.hx @@ -24,6 +24,8 @@ package js.html.eme; +import js.lib.Promise; + /** The `MediaKeySession` interface of the EncryptedMediaExtensions API represents a context for message exchange with a content decryption module (CDM). @@ -34,62 +36,62 @@ package js.html.eme; @:native("MediaKeySession") extern class MediaKeySession extends js.html.EventTarget { var error(default,null) : MediaKeyError; - + /** Contains a unique string generated by the CDM for the current media object and its associated keys or licenses. **/ var sessionId(default,null) : String; - + /** The time after which the keys in the current session can no longer be used to decrypt media data, or `NaN` if no such time exists. This value is determined by the CDM and measured in milliseconds since January 1, 1970, UTC. This value may change during a session lifetime, such as when an action triggers the start of a window. **/ var expiration(default,null) : Float; - + /** Returns a `Promise` signaling when a `MediaKeySession` closes. This promise can only be fulfilled and is never rejected. Closing a session means that licenses and keys associated with it are no longer valid for decrypting media data.  **/ var closed(default,null) : Promise; - + /** Contains a reference to a read-only `MediaKeyStatusMap` of the current session's keys and their statuses. **/ var keyStatuses(default,null) : MediaKeyStatusMap; - + /** Sets the `EventHandler` called when there has been a change in the keys in a session or their statuses. **/ var onkeystatuseschange : haxe.Constraints.Function; - + /** Sets the `EventHandler` called when the content decryption module has generated a message for the session. **/ var onmessage : haxe.Constraints.Function; - - + + /** Returns a `Promise` after generating a media request based on initialization data. **/ @:overload( function( initDataType : String, initData : js.lib.ArrayBuffer) : Promise {} ) function generateRequest( initDataType : String, initData : js.lib.ArrayBufferView ) : Promise; - + /** Returns a `Promise` that resolves to a boolean value after loading data for a specified session object.  **/ function load( sessionId : String ) : Promise; - + /** Returns a `Promise` after loading messages and licenses to the CDM. **/ @:overload( function( response : js.lib.ArrayBuffer) : Promise {} ) function update( response : js.lib.ArrayBufferView ) : Promise; - + /** - + Returns a `Promise` after notifying the current media session is no longer needed and that the CDM should release any resources associated with this object and close it. - + **/ function close() : Promise; - + /** Returns a `Promise` after removing any session data associated with the current object. **/ diff --git a/std/js/html/eme/MediaKeySystemAccess.hx b/std/js/html/eme/MediaKeySystemAccess.hx index b81ee77f724..54b4910fbb9 100644 --- a/std/js/html/eme/MediaKeySystemAccess.hx +++ b/std/js/html/eme/MediaKeySystemAccess.hx @@ -24,6 +24,8 @@ package js.html.eme; +import js.lib.Promise; + /** The `MediaKeySystemAccess` interface of the EncryptedMediaExtensions API provides access to a Key System for decryption and/or a content protection provider. You can request an instance of this object using the `Navigator.requestMediaKeySystemAccess` method. @@ -33,18 +35,18 @@ package js.html.eme; **/ @:native("MediaKeySystemAccess") extern class MediaKeySystemAccess { - + /** Returns a `DOMString` identifying the key system being used. **/ var keySystem(default,null) : String; - - + + /** Returns a `MediaKeySystemConfiguration` object with the supported combination of configuration options. **/ function getConfiguration() : MediaKeySystemConfiguration; - + /** Returns a `Promise` that resolves to a new `MediaKeys` object. **/ diff --git a/std/js/html/eme/MediaKeys.hx b/std/js/html/eme/MediaKeys.hx index 6ad3546aec8..b6811483fc3 100644 --- a/std/js/html/eme/MediaKeys.hx +++ b/std/js/html/eme/MediaKeys.hx @@ -24,6 +24,8 @@ package js.html.eme; +import js.lib.Promise; + /** The `MediaKeys` interface of EncryptedMediaExtensions API the represents a set of keys that an associated `HTMLMediaElement` can use for decryption of media data during playback. @@ -34,14 +36,14 @@ package js.html.eme; @:native("MediaKeys") extern class MediaKeys { var keySystem(default,null) : String; - - + + /** Returns a new `MediaKeySession` object, which represents a context for message exchange with a content decryption module (CDM). @throws DOMError **/ function createSession( sessionType : MediaKeySessionType = TEMPORARY ) : MediaKeySession; - + /** Returns a `Promise` to a server certificate to be used to encrypt messages to the license server. **/ diff --git a/std/js/html/push/PushManager.hx b/std/js/html/push/PushManager.hx index c98a87faa3f..3a13e17c5cf 100644 --- a/std/js/html/push/PushManager.hx +++ b/std/js/html/push/PushManager.hx @@ -24,6 +24,8 @@ package js.html.push; +import js.lib.Promise; + /** The `PushManager` interface of the Push API provides a way to receive notifications from third-party servers as well as request URLs for push notifications. @@ -35,19 +37,19 @@ package js.html.push; extern class PushManager { /** @throws DOMError */ function new( scope : String ) : Void; - + /** Subscribes to a push service. It returns a `Promise` that resolves to a `PushSubscription` object containing details of a push subscription. A new push subscription is created if the current service worker does not have an existing subscription. @throws DOMError **/ function subscribe( ?options : PushSubscriptionOptionsInit ) : Promise; - + /** Retrieves an existing push subscription. It returns a `Promise` that resolves to a `PushSubscription` object containing details of an existing subscription. If no existing subscription exists, this resolves to a `null` value. @throws DOMError **/ function getSubscription() : Promise; - + /** Returns a `Promise` that resolves to the permission state of the current `PushManager`, which will be one of `'granted'`, `'denied'`, or `'prompt'`. @throws DOMError diff --git a/std/js/html/push/PushSubscription.hx b/std/js/html/push/PushSubscription.hx index b2e44bd768d..4893d414913 100644 --- a/std/js/html/push/PushSubscription.hx +++ b/std/js/html/push/PushSubscription.hx @@ -24,6 +24,8 @@ package js.html.push; +import js.lib.Promise; + /** The `PushSubscription` interface of the Push API provides a subcription's URL endpoint and allows unsubscription from a push service. @@ -33,32 +35,32 @@ package js.html.push; **/ @:native("PushSubscription") extern class PushSubscription { - + /** A `USVString` containing the endpoint associated with the push subscription. **/ var endpoint(default,null) : String; - + /** An object containing the options used to create the subscription. **/ var options(default,null) : PushSubscriptionOptions; - + /** @throws DOMError */ function new( initDict : PushSubscriptionInit ) : Void; - + /** Returns an `ArrayBuffer` which contains the client's public key, which can then be sent to a server and used in encrypting push message data. @throws DOMError **/ function getKey( name : PushEncryptionKeyName ) : js.lib.ArrayBuffer; - + /** Starts the asynchronous process of unsubscribing from the push service, returning a `Promise` that resolves to a `Boolean` when the current subscription is successfully unregistered. @throws DOMError **/ function unsubscribe() : Promise; - + /** Standard serializer — returns a JSON representation of the subscription properties. @throws DOMError diff --git a/std/js/Date.hx b/std/js/lib/Date.hx similarity index 97% rename from std/js/Date.hx rename to std/js/lib/Date.hx index 8a4b2ed5089..0a4f0fefd33 100644 --- a/std/js/Date.hx +++ b/std/js/lib/Date.hx @@ -1,5 +1,5 @@ /* - * Copyright (C)2005-2019 Haxe Foundation + * Copyright (C)2005-2018 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -19,7 +19,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -package js; +package js.lib; import Date in HaxeDate; @@ -35,14 +35,14 @@ extern class Date function new() : Void; /** - Cast Haxe's Date to js.Date. + Cast Haxe's Date to js.lib.Date. **/ - static public inline function fromHaxeDate(date:HaxeDate):js.Date { + static public inline function fromHaxeDate(date:HaxeDate):js.lib.Date { return cast date; } /** - Cast js.Date to Haxe's Date. + Cast js.lib.Date to Haxe's Date. **/ static public inline function toHaxeDate(date:Date):HaxeDate { return cast date; @@ -282,4 +282,4 @@ extern class Date Converts a date to a string using the UTC timezone. **/ function toUTCString() : String; -} \ No newline at end of file +} diff --git a/std/js/lib/Error.hx b/std/js/lib/Error.hx new file mode 100644 index 00000000000..7fbfd4c3439 --- /dev/null +++ b/std/js/lib/Error.hx @@ -0,0 +1,68 @@ +/* + * Copyright (C)2005-2018 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +package js.lib; + +@:native("Error") +extern class Error +{ + var message : String; + var name : String; + var stack(default,null) : String; + + function new(?message : String) : Void; +} + +@:native("EvalError") +extern class EvalError extends Error +{ + function new(?message : String) : Void; +} + +@:native("RangeError") +extern class RangeError extends Error +{ + function new(?message : String) : Void; +} + +@:native("ReferenceError") +extern class ReferenceError extends Error +{ + function new(?message : String) : Void; +} + +@:native("SyntaxError") +extern class SyntaxError extends Error +{ + function new(?message : String) : Void; +} + +@:native("TypeError") +extern class TypeError extends Error +{ + function new(?message : String) : Void; +} + +@:native("URIError") +extern class URIError extends Error +{ + function new(?message : String) : Void; +} diff --git a/std/js/lib/Function.hx b/std/js/lib/Function.hx new file mode 100644 index 00000000000..62924e0aebc --- /dev/null +++ b/std/js/lib/Function.hx @@ -0,0 +1,51 @@ +/* + * Copyright (C)2005-2018 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +package js.lib; + +import haxe.extern.Rest; + +@:native("Function") +extern class Function { + /** Specifies the number of arguments expected by the function. **/ + var length(default,never):Int; + + /** The name of the function. **/ + var name:String; + + /** Creates a new Function object. **/ + function new(arg:String, rest:Rest); + + /** Calls a function and sets its this to the provided value, arguments can be passed as an Array object. **/ + function apply(thisArg:Dynamic, argsArray:Array):Dynamic; + + /** Calls (executes) a function and sets its this to the provided value, arguments can be passed as they are. **/ + function call(thisArg:Dynamic, args:Rest):Dynamic; + + /** + Creates a new function which, when called, has its this set to the provided value, + with a given sequence of arguments preceding any provided when the new function was called. + **/ + @:pure function bind(thisArg:Dynamic, args:Rest):Function; + + /** Returns a string representing the source code of the function. **/ + @:pure function toString():String; +} diff --git a/std/js/lib/Iterator.hx b/std/js/lib/Iterator.hx new file mode 100644 index 00000000000..c361acd4fbf --- /dev/null +++ b/std/js/lib/Iterator.hx @@ -0,0 +1,10 @@ +package js.lib; + +typedef Iterator = { + function next():IteratorStep; +} + +typedef IteratorStep = { + done:Bool, + ?value:T +} diff --git a/std/js/Map.hx b/std/js/lib/Map.hx similarity index 80% rename from std/js/Map.hx rename to std/js/lib/Map.hx index 25ef38f244a..7e29b61b169 100644 --- a/std/js/Map.hx +++ b/std/js/lib/Map.hx @@ -1,5 +1,5 @@ /* - * Copyright (C)2005-2019 Haxe Foundation + * Copyright (C)2005-2018 Haxe Foundation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -19,32 +19,34 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ -package js; +package js.lib; + +import js.lib.Iterator; /** - The (native) JavaScript Map object holds key-value pairs. + The (native) JavaScript Map object holds key-value pairs. Any value (both objects and primitive values) may be used as either a key or a value. - + Documentation [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). **/ @:native("Map") extern class Map { - /** - The number of key/value pairs in the `js.Map` object. + /** + The number of key/value pairs in the `js.Map` object. **/ var size(default,null):Int; /** - An Array or other iterable object whose elements are key-value pairs + An Array or other iterable object whose elements are key-value pairs (arrays with two elements, e.g. `[[ 1, 'one' ],[ 2, 'two' ]]`). - Each key-value pair is added to the new `js.Map`; + Each key-value pair is added to the new `js.Map`; null values are treated as undefined. **/ @:pure function new(?iterable:Any); - /** - A boolean asserting whether a value has been associated to the key in + /** + A boolean asserting whether a value has been associated to the key in the `js.Map` object or not. **/ @:pure function has(key:K):Bool; @@ -55,14 +57,14 @@ extern class Map { @:pure function get(key:K):Null; /** - Sets the value for the key in the Map object. + Sets the value for the key in the Map object. Returns the `js.Map` object. **/ function set(key:K, value:V):Map; /** Returns `true` if an element in the `js.Map` object existed and has been - removed, or `false` if the element does not exist. + removed, or `false` if the element does not exist. `has(key)` will return `false` afterwards. **/ function delete(key:K):Bool; @@ -73,31 +75,31 @@ extern class Map { function clear():Void; /** - Calls `callback` once for each key-value pair present in the `js.Map` - object, in insertion order. - + Calls `callback` once for each key-value pair present in the `js.Map` + object, in insertion order. + If a `thisArg` parameter is provided to forEach, it will be used as the `this` value for each callback. **/ function forEach(callback:(value:V, key:K, map:Map)->Void, ?thisArg:Any):Void; /** - Returns a new `JsIterator` object that contains the keys for each element + Returns a new `Iterator` object that contains the keys for each element in the `js.Map` object in insertion order. **/ - function keys():JsIterator; + function keys():Iterator; /** - Returns a new `JsIterator` object that contains the values for each + Returns a new `Iterator` object that contains the values for each element in the `js.Map` object in insertion order. **/ - function values():JsIterator; + function values():Iterator; /** - Returns a new `JsIterator` object that contains an array of `MapEntry` + Returns a new `Iterator` object that contains an array of `MapEntry` for each element in the `js.Map` object in insertion order. **/ - function entries():JsIterator>; + function entries():Iterator>; } /** @@ -108,4 +110,4 @@ abstract MapEntry(Array) { public var value(get,never):V; inline function get_key():K return this[0]; inline function get_value():V return this[1]; -} +} \ No newline at end of file diff --git a/std/js/lib/Object.hx b/std/js/lib/Object.hx new file mode 100644 index 00000000000..60b1a5fc8b9 --- /dev/null +++ b/std/js/lib/Object.hx @@ -0,0 +1,224 @@ +/* + * Copyright (C)2005-2018 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +package js.lib; + +import haxe.extern.Rest; +import haxe.DynamicAccess; +/** + The `js.lib.Object` constructor creates an object wrapper. + + Documentation [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). +**/ +@:native("Object") +extern class Object { + /** + Copies the values of all enumerable own properties from one or more + source objects to a target object. + **/ + static function assign(target:T, sources:Rest<{}>):T; + + /** + Creates a new object with the specified prototype object and properties. + **/ + @:pure static function create(proto:{}, ?propertiesObject:DynamicAccess):T; + + /** + Adds the named properties described by the given descriptors to an object. + **/ + static function defineProperties(obj:T, props:DynamicAccess):T; + + /** + Adds the named property described by a given descriptor to an object. + **/ + static function defineProperty(obj:T, prop:String, descriptor:ObjectPropertyDescriptor):T; + + /** + Freezes an object: other code can't delete or change any properties. + **/ + static function freeze(obj:T):T; + + /** + Returns a property descriptor for a named property on an object. + **/ + @:pure static function getOwnPropertyDescriptor(obj:{}, prop:String):Null; + + /** + Returns an array containing the names of all of the given object's own + enumerable and non-enumerable properties. + **/ + @:pure static function getOwnPropertyNames(obj:{}):Array; + + /** + Returns an array of all symbol properties found directly upon a given object. + **/ + @:pure static function getOwnPropertySymbols(obj:{}):Array; + + /** + Returns the prototype of the specified object. + **/ + @:pure static function getPrototypeOf(obj:{}):Null; + + /** + Compares if two values are the same value. Equates all NaN values + (which differs from both Abstract Equality Comparison and + Strict Equality Comparison). + **/ + @:pure static function is(value1:T, value2:T):Bool; + + /** + Determines if extending of an object is allowed. + **/ + @:pure static function isExtensible(obj:{}):Bool; + + /** + Determines if an object was frozen. + **/ + @:pure static function isFrozen(obj:{}):Bool; + + /** + Determines if an object is sealed. + **/ + @:pure static function isSealed(obj:{}):Bool; + + /** + Returns an array containing the names of all of the given object's own + enumerable string properties. + **/ + @:pure static function keys(obj:{}):Array; + + /** + Prevents any extensions of an object. + **/ + static function preventExtensions(obj:T):T; + + /** + Prevents other code from deleting properties of an object. + **/ + static function seal(obj:T):T; + + /** + Sets the prototype (i.e., the internal Prototype property). + **/ + static function setPrototypeOf(obj:T, prototype:Null<{}>):T; + + /** + Allows the addition of properties to all objects of type Object. + **/ + static var prototype(default,never):ObjectPrototype; + + /** + The Object constructor creates an object wrapper. + **/ + @:pure function new(?value:Any); +} + +/** + Type for + @see +**/ +typedef ObjectPrototype = { + /** + Returns a boolean indicating whether an object contains the specified + property as a direct property of that object and not inherited through + the prototype chain. + **/ + var hasOwnProperty(default,never):Function; + + /** + Returns a boolean indicating whether the object this method is called + upon is in the prototype chain of the specified object. + **/ + var isPrototypeOf(default,never):Function; + + /** + Returns a boolean indicating if the internal enumerable attribute is set. + **/ + var propertyIsEnumerable(default,never):Function; + + /** + Calls `toString()`. + **/ + var toLocaleString(default,never):Function; + + /** + Returns a string representation of the object. + **/ + var toString(default,never):Function; + + /** + Returns the primitive value of the specified object. + **/ + var valueOf(default,never):Function; +} + +/** + @see +**/ +typedef ObjectPropertyDescriptor = { + /** + `true` if and only if the type of this property descriptor may be + changed and if the property may be deleted from the corresponding object. + + Defaults to `false`. + **/ + var ?configurable:Bool; + + /** + `true` if and only if this property shows up during enumeration of the + properties on the corresponding object. + + Defaults to `false`. + **/ + var ?enumerable:Bool; + + /** + The value associated with the property. + Can be any valid JavaScript value (number, object, function, etc). + **/ + var ?value:Any; + + /** + `true` if and only if the value associated with the property may be + changed with an assignment operator. + + Defaults to `false`. + **/ + var ?writable:Bool; + + /** + A function which serves as a getter for the property, or `undefined` if + there is no getter. When the property is accessed, this function is + called without arguments and with `this` set to the object through which + the property is accessed (this may not be the object on which the + property is defined due to inheritance). + The return value will be used as the value of the property. + **/ + var ?get:Void->Any; + + /** + A function which serves as a setter for the property, or undefined if + there is no setter. When the property is assigned to, this function + is called with one argument (the value being assigned to the property) + and with `this` set to the object through which the property is assigned. + **/ + var ?set:Any->Void; +} \ No newline at end of file diff --git a/std/js/lib/Promise.hx b/std/js/lib/Promise.hx new file mode 100644 index 00000000000..54685caa8c6 --- /dev/null +++ b/std/js/lib/Promise.hx @@ -0,0 +1,109 @@ +/* + * Copyright (C)2005-2018 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +package js.lib; + +import haxe.extern.EitherType; + +/** + The Promise object represents the eventual completion (or failure) of an + asynchronous operation and its resulting value. + + Documentation [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). +**/ +@:native("Promise") +extern class Promise +{ + /** + Returns a Promise object that is resolved with the given value. If the + value is Thenable, the returned promise will "follow" that + thenable, adopting its eventual state; + otherwise the returned promise will be fulfilled with the value. + Generally, when it's unknown when value is a promise or not, + use `Promise.resolve(value)` instead and work with the return value as + a promise. + **/ + @:overload(function(?value : T) : Promise {}) + static function resolve( thenable : Thenable ) : Promise; + + /** + Returns a Promise object that is rejected with the given reason. + **/ + static function reject( ?reason : Dynamic ) : Promise; + + /** + Returns a promise that either fulfills when all of the promises in the + iterable argument have fulfilled or rejects as soon as one of the + promises in the iterable argument rejects. If the returned promise + fulfills, it is fulfilled with an array of the values from the + fulfilled promises in the same order as defined in the iterable. + If the returned promise rejects, it is rejected with the reason from + the first promise in the iterable that rejected. This method can be + useful for aggregating results of multiple promises. + **/ + static function all( iterable : Array ) : Promise>; + + /** + Returns a promise that fulfills or rejects as soon as one of the + promises in the iterable fulfills or rejects, with the value or reason + from that promise. + **/ + static function race( iterable : Array ) : Promise; + + /** @throws DOMError */ + function new( init : (resolve : (value : T) -> Void, reject: (reason : Dynamic) -> Void) -> Void ) : Void; + + /** + Appends fulfillment and rejection handlers to the promise and returns a + new promise resolving to the return value of the called handler, or to + its original settled value if the promise was not handled + (i.e. if the relevant handler onFulfilled or onRejected is not a function). + **/ + function then( onFulfilled : Null>, ?onRejected : PromiseHandler ) : Promise; + + /** + Appends a rejection handler callback to the promise, and returns a new + promise resolving to the return value of the callback if it is called, + or to its original fulfillment value if the promise is instead fulfilled. + **/ + @:native("catch") + function catchError( onRejected : PromiseHandler ) : Promise; +} + +/** + Handler type for the Promise object. +**/ +abstract PromiseHandler(T->Dynamic) // T->Dynamic, so the compiler always knows the type of the argument and can infer it for then/catch callbacks + from T->TOut // order is important, because Promise return must have priority + from T->Thenable // although the checking order seems to be reversed at the moment, see https://github.com/HaxeFoundation/haxe/issues/7656 + from T->Promise // support Promise explicitly as it doesn't work transitively through Thenable at the moment +{} + +/** + A value with a `then` method. +**/ +@:forward +abstract Thenable(ThenableStruct) from ThenableStruct {} // abstract wrapping prevents compiler hanging, see https://github.com/HaxeFoundation/haxe/issues/5785 + +typedef ThenableStruct = { + function then( onFulfilled : Null>, ?onRejected : PromiseHandler ) : Thenable; +} \ No newline at end of file diff --git a/std/js/lib/RegExp.hx b/std/js/lib/RegExp.hx new file mode 100644 index 00000000000..10010258daf --- /dev/null +++ b/std/js/lib/RegExp.hx @@ -0,0 +1,46 @@ +/* + * Copyright (C)2005-2018 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + package js.lib; + +/** + Native JavaScript regular expressions. + + For cross-platform regular expressions, use Haxe `EReg` class or + [regexp literals](https://haxe.org/manual/std-regex.html). +**/ +@:native("RegExp") +extern class RegExp { + var global(default,null):Bool; + var ignoreCase(default,null):Bool; + var multiline(default,null):Bool; + var source(default,null):String; + var lastIndex:Int; + function new(pattern:String, ?flags:String); + function exec(str:String):Null; + function test(str:String):Bool; + function toString():String; +} + +extern class RegExpMatch extends Array { + var index:Int; + var input:String; +} diff --git a/std/js/lib/Set.hx b/std/js/lib/Set.hx new file mode 100644 index 00000000000..634dee50f67 --- /dev/null +++ b/std/js/lib/Set.hx @@ -0,0 +1,99 @@ +/* + * Copyright (C)2005-2018 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +package js.lib; + +import js.lib.Map.MapEntry; +import js.lib.Iterator; + +/** + The `js.Set` object lets you store unique values of any type, whether + primitive values or object references. + + Documentation [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/). +**/ +@:native("Set") +extern class Set { + /** + The number of values in the `js.Set` object. + **/ + var size(default,null):Int; + + /** + If an iterable object is passed, all of its elements will be added to + the new `js.Set`. + **/ + @:pure function new(?iterable:Any); + + /** + Returns a boolean asserting whether an element is present with the given + value in the `js.Set` object or not. + **/ + @:pure function has(value:T):Bool; + + /** + Appends a new element with the given value to the `js.Set` object. + Returns the `js.Set` object. + **/ + function add(value:T):Set; + + /** + Removes the element associated to the value and returns the value that + `has(value)` would have previously returned. + `has(value)` will return `false` afterwards. + **/ + function delete(value:T):Bool; + + /** + Removes all elements from the `js.Set` object. + **/ + function clear():Void; + + /** + Calls `callback` once for each key-value pair present in the `js.Set` + object, in insertion order. + + If a `thisArg` parameter is provided to forEach, it will be used as the + `this` value for each callback. + **/ + function forEach(callback:(value:T, key:T, set:Set)->Void, ?thisArg:Any):Void; + + /** + Returns a new `js.lib.Iterator` object that contains the keys for each element + in the `js.Set` object in insertion order. + **/ + function keys():Iterator; + + /** + Returns a new `js.lib.Iterator` object that contains the values for each + element in the `js.Set` object in insertion order. + **/ + function values():Iterator; + + /** + Returns a new `js.lib.Iterator` object that contains an array of + `[value, value]` for each element in the `js.Set` object, in insertion + order. + This is kept similar to the `js.Map` object, so that each entry has the + same value for its key and value here. + **/ + function entries():Iterator>; +} diff --git a/std/js/lib/Symbol.hx b/std/js/lib/Symbol.hx new file mode 100644 index 00000000000..75a84de97c1 --- /dev/null +++ b/std/js/lib/Symbol.hx @@ -0,0 +1,61 @@ +/* + * Copyright (C)2005-2018 Haxe Foundation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +package js.lib; + +@:native("Symbol") +extern class Symbol { + /** + To create a new primitive symbol, you write `new Symbol()` with an optional string as its `description`. + + NOTE: Unlike plain JavaScript, in Haxe `new Symbol()` syntax is used, however `Symbol(...)` expression + will be generated as required by JavaScript specification. + **/ + @:pure @:selfCall function new(?description:String); + + /** + Searches for existing symbols with the given key and returns it if found. + Otherwise a new symbol gets created in the global symbol registry with this key. + **/ + @:native("for") static function for_(key:String):Symbol; + + /** + Retrieves a shared symbol key from the global symbol registry for the given symbol. + **/ + @:pure static function keyFor(sym:Symbol):Null; + + /** + Returns a string containing the description of the Symbol. + **/ + @:pure function toString():String; + + /** + A method returning the default iterator for an object. + **/ + static var iterator(default,null):Symbol; + + /** + Retrieve symbol from a given `object`. + + NOTE: This is a Haxe-specific method that generates `object[symbol]` expression. + **/ + inline function ofObject(object:{}):Null return (cast object)[cast this]; +} diff --git a/tests/server/src/Vfs.hx b/tests/server/src/Vfs.hx index ec9ff1c2756..5a83ee8f860 100644 --- a/tests/server/src/Vfs.hx +++ b/tests/server/src/Vfs.hx @@ -2,6 +2,8 @@ import js.node.Fs; import sys.FileSystem; import haxe.io.Path; +using DateTools; + class Vfs { var physicalPath:String; @@ -17,8 +19,8 @@ class Vfs { var path = getPhysicalPath(path); FileSystem.createDirectory(path.dir); var file = Fs.openSync(path.dir + "/" + path.file + "." + path.ext, 'a'); - var last = Date.fromString(Fs.fstatSync(file).mtime.toTimeString().substr(0, 8)); - var notNow = js.Date.fromHaxeDate(DateTools.delta(last, 1000)); + var last = Date.fromString(Fs.fstatSync(file).mtime.format("%T")); + var notNow = last.delta(1000); Fs.futimesSync(file, notNow, notNow); Fs.closeSync(file); } diff --git a/tests/unit/src/unit/issues/Issue3499.hx b/tests/unit/src/unit/issues/Issue3499.hx index 90e7e9a13f8..9e2078205e9 100644 --- a/tests/unit/src/unit/issues/Issue3499.hx +++ b/tests/unit/src/unit/issues/Issue3499.hx @@ -2,7 +2,7 @@ package unit.issues; #if js -private typedef PathSimple = haxe.extern.EitherType; +private typedef PathSimple = haxe.extern.EitherType; private typedef Path = haxe.extern.EitherType>; #end @@ -10,7 +10,7 @@ private typedef Path = haxe.extern.EitherType>; class Issue3499 extends Test { #if js function test() { - var a:Path = ["", new js.RegExp("")]; + var a:Path = ["", new js.lib.RegExp("")]; eq("", a[0]); } #end diff --git a/tests/unit/src/unit/issues/Issue4644.hx b/tests/unit/src/unit/issues/Issue4644.hx index f7efa705303..7f707640e75 100644 --- a/tests/unit/src/unit/issues/Issue4644.hx +++ b/tests/unit/src/unit/issues/Issue4644.hx @@ -10,7 +10,7 @@ class Issue4644 extends Test { }} catch (e) {{ {1} = (e instanceof {2}); }}", - throw (new js.Error() : Dynamic), + throw (new js.lib.Error() : Dynamic), isHaxeError, #if js_unflatten __js__("js._Boot.HaxeError")