This commit is contained in:
Dante
2026-05-21 23:40:20 -07:00
parent 3e2915dff7
commit 877a69d844
5737 changed files with 29796 additions and 1589684 deletions

View File

@ -0,0 +1,99 @@
package js.lib;
private typedef E<A, B> = haxe.extern.EitherType<A, B>;
private typedef IntTypedArray = E<Int8Array, E<Uint8Array, E<Int16Array, E<Uint16Array, E<Int32Array, Uint32Array>>>>>;
/**
The Atomics object provides atomic operations as static methods. They are used with SharedArrayBuffer and ArrayBuffer objects.
Documentation [Atomics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/contributors.txt), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
**/
@:native("Atomics")
extern class Atomics {
/**
Adds the provided value to the existing value at the specified index of the array.
Returns the old value at that index.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function add(typedArray:IntTypedArray, index:Int, value:Int):Int;
/**
Computes a bitwise AND on the value at the specified index of the array with the provided value.
Returns the old value at that index.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function and(typedArray:IntTypedArray, index:Int, value:Int):Int;
/**
Stores a value at the specified index of the array, if it equals a value.
Returns the old value.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function compareExchange(typedArray:IntTypedArray, index:Int, expectedValue:Int, replacementValue:Int):Int;
/**
Stores a value at the specified index of the array.
Returns the old value.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function exchange(typedArray:IntTypedArray, index:Int, value:Int):Int;
/**
An optimization primitive that can be used to determine whether to use locks or atomic operations.
Returns `true` if an atomic operation on arrays of the given element size will be implemented using a hardware atomic operation (as opposed to a lock). Experts only.
**/
static function isLockFree(size:Int):Bool;
/**
Returns the value at the specified index of the array.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function load(typedArray:IntTypedArray, index:Int):Int;
/**
Notifies agents that are waiting on the specified index of the array.
Returns the number of agents that were notified.
**/
static function notify(typedArray:IntTypedArray, index:Int, ?count:Int):Int;
/**
Computes a bitwise OR on the value at the specified index of the array with the provided value.
Returns the old value at that index.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function or(typedArray:IntTypedArray, index:Int, value:Int):Int;
/**
Stores a value at the specified index of the array.
Returns the value.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function store(typedArray:IntTypedArray, index:Int, value:Int):Int;
/**
Subtracts a value at the specified index of the array.
Returns the old value at that index.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function sub(typedArray:IntTypedArray, index:Int, value:Int):Int;
/**
Verifies that the specified index of the array still contains a value and sleeps awaiting or times out.
Returns either "ok", "not-equal", or "timed-out". If waiting is not allowed in the calling agent then it throws an Error exception.
Most browsers will not allow wait() on the browser's main thread.)
**/
static function wait(typedArray:Int32Array, index:Int, value:Int, ?timeout:Int):WaitValue;
/**
Computes a bitwise XOR on the value at the specified index of the array with the provided value.
Returns the old value at that index.
This atomic operation guarantees that no other write happens until the modified value is written back.
**/
static function xor(typedArray:IntTypedArray, index:Int, value:Int):Int;
}
enum abstract WaitValue(String) {
var OK = "ok";
var NotEqual = "not-equal";
var TimedOut = "timed-out";
}

View File

@ -34,9 +34,13 @@ import haxe.extern.EitherType;
@see <https://developer.mozilla.org/en-US/docs/Web/API/BufferSource>
*/
@:forward
abstract BufferSource(ArrayBuffer) to ArrayBuffer from ArrayBuffer {
@:from public static inline function fromBufferView(view:ArrayBufferView) {
return cast view.buffer;
abstract BufferSource(Dynamic) from ArrayBuffer from ArrayBufferView {
public var byteLength(get, never): Int;
@:pure
inline function get_byteLength(): Int {
return this.byteLength;
}
}

View File

@ -59,7 +59,8 @@ extern class Promise<T> {
the first promise in the iterable that rejected. This method can be
useful for aggregating results of multiple promises.
**/
static function all(iterable:Array<Dynamic>):Promise<Array<Dynamic>>;
@:overload(function(iterable:Array<Dynamic>):Promise<Array<Dynamic>> {})
static function all<T>(iterable:Array<Promise<T>>):Promise<Array<T>>;
/**
Returns a promise that resolves after all of the given promises have either fulfilled or rejected,
@ -71,14 +72,16 @@ extern class Promise<T> {
In comparison, the Promise returned by `Promise.all` may be more appropriate if the tasks are dependent
on each other / if you'd like to immediately reject upon any of them rejecting.
**/
static function allSettled(iterable:Array<Dynamic>):Promise<Array<PromiseSettleOutcome>>;
@:overload(function(iterable:Array<Dynamic>):Promise<Array<PromiseSettleOutcome<Dynamic>>> {})
static function allSettled<T>(iterable:Array<Promise<T>>):Promise<Array<PromiseSettleOutcome<T>>>;
/**
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<Dynamic>):Promise<Dynamic>;
@:overload(function(iterable:Array<Dynamic>):Promise<Dynamic> {})
static function race<T>(iterable:Array<Promise<T>>):Promise<T>;
/** @throws DOMError */
function new(init:(resolve:(value:T) -> Void, reject:(reason:Dynamic) -> Void) -> Void):Void;
@ -129,9 +132,9 @@ typedef ThenableStruct<T> = {
function then<TOut>(onFulfilled:Null<PromiseHandler<T, TOut>>, ?onRejected:PromiseHandler<Dynamic, TOut>):Thenable<TOut>;
}
typedef PromiseSettleOutcome = {
typedef PromiseSettleOutcome<T> = {
var status:PromiseSettleStatus;
var ?value:Dynamic;
var ?value:T;
var ?reason:Dynamic;
}

View File

@ -0,0 +1,16 @@
package js.lib;
/**
The SharedArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer, similar to the ArrayBuffer object, but in a way that they can be used to create views on shared memory.
A SharedArrayBuffer is not a Transferable Object, unlike an ArrayBuffer which is transferable.
Documentation [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/contributors.txt), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
**/
@:native("SharedArrayBuffer")
extern class SharedArrayBuffer {
final byteLength:Int;
function new(?length:Int):Void;
function slice(?begin:Int, ?end:Int):ArrayBuffer;
}

View File

@ -0,0 +1,38 @@
package js.lib;
/*
* Copyright (C)2005-2019 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.
*/
/**
The `WeakRef` object lets you hold a weak reference to another object, without preventing that object from getting garbage-collected.
Documentation [WeakRef](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
**/
@:native("WeakRef")
extern class WeakRef<T:{}> {
/**
Creates a new WeakRef object.
**/
@:pure function new(target:T);
/**
Returns the WeakRef object's target object, or null if the target object has been reclaimed.
**/
@:pure function deref():Null<T>;
}

View File

@ -0,0 +1,133 @@
/*
* Copyright (C)2005-2021 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.intl;
/**
The `Intl.DisplayNames` object enables the consistent translation of language,
region and script display names.
**/
@:native("Intl.DisplayNames")
extern class DisplayNames {
/**
Creates a new `Intl.DisplayNames` object.
**/
@:overload(function(?locales: Array<String>, ?options: DisplayNamesOptions): Void {})
function new(?locales: String, ?options: DisplayNamesOptions);
/**
Receives a code and returns a string based on the locale and options
provided when instantiating `Intl.DisplayNames`.
**/
function of(code: String): String;
/**
Returns a new object with properties reflecting the locale and formatting options
computed during initialization of the object.
**/
function resolvedOptions(): DisplayNamesResolvedOptions;
/**
Returns an array containing those of the provided locales that are supported
in display names without having to fall back to the runtime's default locale.
**/
@:overload(function(locales: Array<String>, ?options: DisplayNamesSupportedLocalesOfOptions): Array<String> {})
static function supportedLocalesOf(locales: String, ?options: DisplayNamesSupportedLocalesOfOptions): Array<String>;
}
enum abstract DisplayNamesFallback(String) {
var Code = "code";
var None = "none";
}
typedef DisplayNamesOptions = {
/**
The fallback to use.
The default is `Code`.
**/
var fallback: DisplayNamesFallback;
/**
The locale matching algorithm to use.
The default is `BestFit`.
**/
var ?localeMatcher: LocaleMatcher;
/**
The formatting style to use.
The default is `Long`.
**/
var ?style: DisplayNamesStyle;
/**
The type to use.
The default is `Language`.
**/
var ?type: DisplayNamesType;
}
typedef DisplayNamesResolvedOptions = {
/**
The value provided for this property in the `options` argument of the constructor
or the default value (`Code`).
**/
final fallback: DisplayNamesFallback;
/**
The BCP 47 language tag for the locale actually used.
**/
final locale: String;
/**
The value provided for this property in the `options` argument of the constructor
or the default value (`Long`).
**/
final style: DisplayNamesStyle;
/**
The value provided for this property in the `options` argument of the constructor
or the default value (`Language`).
**/
final type: DisplayNamesType;
}
enum abstract DisplayNamesStyle(String) {
var Long = "long";
var Narrow = "narrow";
var Short = "short";
}
typedef DisplayNamesSupportedLocalesOfOptions = {
/**
The locale matching algorithm to use.
The default is `BestFit`.
*/
var ?localeMatcher: LocaleMatcher;
}
enum abstract DisplayNamesType(String) {
var Currency = "currency";
var Language = "language";
var Region = "region";
var Script = "script";
}

View File

@ -0,0 +1,121 @@
/*
* Copyright (C)2005-2021 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.intl;
/**
The `Intl.ListFormat` object enables language-sensitive list formatting.
**/
@:native("Intl.ListFormat")
extern class ListFormat {
/**
Creates a new `Intl.ListFormat` object.
**/
@:overload(function(?locales: Array<String>, ?options: ListFormatOptions): Void {})
function new(?locales: String, ?options: ListFormatOptions);
/**
Returns a language-specific formatted string representing the elements of the list.
**/
function format(?list: Array<String>): String;
/**
Returns an array of objects representing the different components
that can be used to format a list of values in a locale-aware fashion.
**/
function formatToParts(?list: Array<String>): Array<ListFormatPart>;
/**
Returns an array containing those of the provided locales that are supported
without having to fall back to the runtime's default locale.
**/
@:overload(function(locales: Array<String>, ?options: ListFormatSupportedLocalesOfOptions): Array<String> {})
static function supportedLocalesOf(locales: String, ?options: ListFormatSupportedLocalesOfOptions): Array<String>;
}
typedef ListFormatOptions = {
/**
The locale matching algorithm to use.
The default is `BestFit`.
**/
var ?localeMatcher: LocaleMatcher;
/**
The length of the formatted message.
The default is `Long`.
**/
var ?style: ListFormatStyle;
/**
The format of output message.
**/
var ?type: ListFormatType;
}
typedef ListFormatPart = {
final type: ListFormatPartType;
final value: String;
}
enum abstract ListFormatPartType(String) {
/**
A value from the list.
**/
var Element = "element";
/**
A linguistic construct.
**/
var Literal = "literal";
}
enum abstract ListFormatStyle(String) {
var Long = "long";
var Narrow = "narrow";
var Short = "short";
}
typedef ListFormatSupportedLocalesOfOptions = {
/**
The locale matching algorithm to use.
The default is `BestFit`.
*/
var ?localeMatcher: LocaleMatcher;
}
enum abstract ListFormatType(String) {
/**
Stands for "and"-based lists.
**/
var Conjunction = "conjunction";
/**
Stands for "or"-based lists.
**/
var Disjunction = "disjunction";
/**
Stands for lists of values with units.
**/
var Unit = "unit";
}