blob: 7a0b45ee52fb0555b9e0fb0c2857455e463cffe5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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<uuid = string> {
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<iface, enums = {}> = nsID & Constants<iface> & 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> = iid extends { prototype: infer U } ? U : never;
/** XPCOM inout param is passed in as a js object with a value property. */
type InOutParam<T> = { value: T };
/** XPCOM out param is written to the passed in object's value property. */
type OutParam<T> = { value?: T };
/** A named type for interfaces to inherit from enums. */
type Enums<enums> = enums;
/** Callable accepts either form of a [function] interface. */
type Callable<iface> = iface | Extract<iface[keyof iface], Function>
/** Picks only const number properties from T. */
type Constants<T> = { [K in keyof T as IfConst<K, T[K]>]: T[K] };
/** Resolves only for keys K whose corresponding type T is a narrow number. */
type IfConst<K, T> = 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;
|