From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- tools/ts/fixtures/intrinsics.d.ts | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tools/ts/fixtures/intrinsics.d.ts (limited to 'tools/ts/fixtures/intrinsics.d.ts') diff --git a/tools/ts/fixtures/intrinsics.d.ts b/tools/ts/fixtures/intrinsics.d.ts new file mode 100644 index 0000000000..7a0b45ee52 --- /dev/null +++ b/tools/ts/fixtures/intrinsics.d.ts @@ -0,0 +1,85 @@ +/** + * Gecko XPCOM builtins and utility types. + */ + +/** + * Generic IDs are created by most code which passes a nsID to js. + * https://searchfox.org/mozilla-central/source/js/xpconnect/src/XPCJSID.cpp#24 + */ +interface nsID { + readonly number: uuid; +} + +/** + * In addition to nsID, interface IIDs support instanceof type guards, + * and expose constants defined on the class, including variants from enums. + * https://searchfox.org/mozilla-central/source/js/xpconnect/src/XPCJSID.cpp#44 + */ +type nsJSIID = nsID & Constants & enums & { + new (_: never): void; + prototype: iface; +} + +/** A union of all known IIDs. */ +type nsIID = nsIXPCComponents_Interfaces[keyof nsIXPCComponents_Interfaces]; + +/** A generic to resolve QueryInterface return type from a nsID (or nsIID). */ +export type nsQIResult = iid extends { prototype: infer U } ? U : never; + +/** XPCOM inout param is passed in as a js object with a value property. */ +type InOutParam = { value: T }; + +/** XPCOM out param is written to the passed in object's value property. */ +type OutParam = { value?: T }; + +/** A named type for interfaces to inherit from enums. */ +type Enums = enums; + +/** Callable accepts either form of a [function] interface. */ +type Callable = iface | Extract + +/** Picks only const number properties from T. */ +type Constants = { [K in keyof T as IfConst]: T[K] }; + +/** Resolves only for keys K whose corresponding type T is a narrow number. */ +type IfConst = T extends number ? (number extends T ? never : K) : never; + +declare global { + // Until we have [ChromeOnly] webidl. + interface BrowsingContext {} + interface ContentFrameMessageManager {} + interface DOMRequest {} + interface FrameLoader {} + interface JSProcessActorChild {} + interface JSProcessActorParent {} + interface TreeColumn {} + interface WebExtensionContentScript {} + interface WebExtensionPolicy {} + interface WindowGlobalParent {} + interface WindowContext {} + interface XULTreeElement {} +} + +// Non-scriptable interfaces referenced from scriptable ones. +interface nsIAsyncVerifyRedirectReadyCallback {} +interface nsICRLiteTimestamp {} +interface nsIInputAvailableCallback {} +interface nsIScriptElement {} +interface nsIThreadObserver {} +interface nsIUDPSocketSyncListener {} +interface nsIWebAuthnRegisterArgs {} +interface nsIWebAuthnRegisterPromise {} +interface nsIWebAuthnSignArgs {} +interface nsIWebAuthnSignPromise {} +interface nsIXPCScriptable {} + +// Typedefs useful as a quick reference in method signatures. +type double = number; +type float = number; +type i16 = number; +type i32 = number; +type i64 = number; +type u16 = number; +type u32 = number; +type u64 = number; +type u8 = number; -- cgit v1.2.3