@mafiahub/types 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/color.d.ts +22 -1
- package/core/events.d.ts +35 -7
- package/core/quaternion.d.ts +19 -0
- package/core/vector2.d.ts +19 -0
- package/core/vector3.d.ts +24 -0
- package/core/vector4.d.ts +21 -0
- package/framework/discord.d.ts +137 -139
- package/framework/exports.d.ts +18 -12
- package/framework/imports.d.ts +10 -9
- package/framework/key.d.ts +51 -53
- package/framework/messages.d.ts +28 -20
- package/package.json +1 -1
package/core/color.d.ts
CHANGED
|
@@ -4,31 +4,52 @@ declare namespace Core {
|
|
|
4
4
|
* Use `Color.fromRGB()` to construct from 0-255 values.
|
|
5
5
|
*/
|
|
6
6
|
class Color {
|
|
7
|
+
/** Create a color from normalized components; alpha defaults to 1. */
|
|
7
8
|
constructor(r: number, g: number, b: number, a?: number);
|
|
8
9
|
|
|
10
|
+
/** Mutable normalized red component. */
|
|
9
11
|
r: number;
|
|
12
|
+
/** Mutable normalized green component. */
|
|
10
13
|
g: number;
|
|
14
|
+
/** Mutable normalized blue component. */
|
|
11
15
|
b: number;
|
|
16
|
+
/** Mutable normalized alpha component. */
|
|
12
17
|
a: number;
|
|
13
18
|
|
|
19
|
+
/** Interpolate every component toward `target`, mutating this color. */
|
|
14
20
|
lerp(target: Color, t: number): this;
|
|
21
|
+
/** Replace normalized components; alpha defaults to 1 when omitted. */
|
|
15
22
|
set(r: number, g: number, b: number, a?: number): this;
|
|
23
|
+
/** Create an independent copy. */
|
|
16
24
|
clone(): Color;
|
|
25
|
+
/** Return uppercase `#RRGGBB`, or `#RRGGBBAA` when alpha is requested. */
|
|
17
26
|
toHex(includeAlpha?: boolean): string;
|
|
27
|
+
/** Format as `Color(r, g, b, a)` for logging. */
|
|
18
28
|
toString(): string;
|
|
29
|
+
/** Convert to a plain normalized component object for `JSON.stringify`. */
|
|
19
30
|
toJSON(): { r: number; g: number; b: number; a: number };
|
|
20
31
|
|
|
32
|
+
/** Parse `#RGB`, `#RGBA`, `#RRGGBB`, or `#RRGGBBAA`; invalid input returns opaque white. */
|
|
21
33
|
static fromHex(hex: string): Color;
|
|
22
|
-
/** Construct from 0-255 component values. */
|
|
34
|
+
/** Construct from 0-255 component values; alpha defaults to 255. */
|
|
23
35
|
static fromRGB(r: number, g: number, b: number, a?: number): Color;
|
|
36
|
+
/** Create opaque white. */
|
|
24
37
|
static white(): Color;
|
|
38
|
+
/** Create opaque black. */
|
|
25
39
|
static black(): Color;
|
|
40
|
+
/** Create opaque red. */
|
|
26
41
|
static red(): Color;
|
|
42
|
+
/** Create opaque green. */
|
|
27
43
|
static green(): Color;
|
|
44
|
+
/** Create opaque blue. */
|
|
28
45
|
static blue(): Color;
|
|
46
|
+
/** Create opaque yellow. */
|
|
29
47
|
static yellow(): Color;
|
|
48
|
+
/** Create opaque cyan. */
|
|
30
49
|
static cyan(): Color;
|
|
50
|
+
/** Create opaque magenta. */
|
|
31
51
|
static magenta(): Color;
|
|
52
|
+
/** Create fully transparent black. */
|
|
32
53
|
static transparent(): Color;
|
|
33
54
|
}
|
|
34
55
|
}
|
package/core/events.d.ts
CHANGED
|
@@ -9,34 +9,62 @@ declare namespace Core {
|
|
|
9
9
|
*/
|
|
10
10
|
const Events: {
|
|
11
11
|
/**
|
|
12
|
-
* Register a listener
|
|
12
|
+
* Register a persistent listener owned by the calling resource.
|
|
13
|
+
* @param eventName Case-sensitive shared event name.
|
|
14
|
+
* @param handler Callback invoked with the emitted arguments; asynchronous results are awaited by emitters.
|
|
13
15
|
* @returns An unsubscribe function.
|
|
14
16
|
*/
|
|
15
17
|
on(eventName: string, handler: (...args: any[]) => void): () => void;
|
|
16
18
|
|
|
17
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Register a listener removed before its first invocation.
|
|
21
|
+
* @param eventName Case-sensitive shared event name.
|
|
22
|
+
* @param handler Resource-owned callback invoked once.
|
|
23
|
+
*/
|
|
18
24
|
once(eventName: string, handler: (...args: any[]) => void): void;
|
|
19
25
|
|
|
20
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Remove a matching listener owned by the calling resource.
|
|
28
|
+
* @param eventName Case-sensitive shared event name.
|
|
29
|
+
* @param handler Exact function passed to `on` or `once`.
|
|
30
|
+
*/
|
|
21
31
|
off(eventName: string, handler: (...args: any[]) => void): void;
|
|
22
32
|
|
|
23
33
|
/**
|
|
24
34
|
* Emit an event globally. Reserved events cannot be emitted.
|
|
25
35
|
* Resolves when all handlers complete; rejects with
|
|
26
36
|
* `AggregateError` if any handler fails.
|
|
37
|
+
* @param eventName Shared event name; framework-reserved names cannot be emitted by scripts.
|
|
38
|
+
* @param args Arguments delivered to every matching handler.
|
|
27
39
|
*/
|
|
28
40
|
emit(eventName: string, ...args: any[]): Promise<void>;
|
|
29
41
|
|
|
30
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Emit an event targeting listeners owned by one resource.
|
|
44
|
+
* @param resourceName Destination running resource.
|
|
45
|
+
* @param eventName Shared event name.
|
|
46
|
+
* @param args Arguments delivered to matching destination handlers.
|
|
47
|
+
*/
|
|
31
48
|
emitTo(resourceName: string, eventName: string, ...args: any[]): Promise<void>;
|
|
32
49
|
|
|
33
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Register a listener in the calling resource's private event namespace.
|
|
52
|
+
* @param eventName Private event name.
|
|
53
|
+
* @param handler Callback invoked only by the same resource's `emitLocal` calls.
|
|
54
|
+
*/
|
|
34
55
|
onLocal(eventName: string, handler: (...args: any[]) => void): void;
|
|
35
56
|
|
|
36
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Emit within the calling resource's private event namespace.
|
|
59
|
+
* @param eventName Private event name.
|
|
60
|
+
* @param args Arguments delivered to local handlers.
|
|
61
|
+
*/
|
|
37
62
|
emitLocal(eventName: string, ...args: any[]): Promise<void>;
|
|
38
63
|
|
|
39
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Count persistent and one-shot listeners across resources.
|
|
66
|
+
* @param eventName Shared event name to inspect.
|
|
67
|
+
*/
|
|
40
68
|
listenerCount(eventName: string): number;
|
|
41
69
|
};
|
|
42
70
|
}
|
package/core/quaternion.d.ts
CHANGED
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
declare namespace Core {
|
|
2
|
+
/** Mutable quaternion used to compose and apply three-dimensional rotations. */
|
|
2
3
|
class Quaternion {
|
|
4
|
+
/** Create a quaternion in scalar-first `(w, x, y, z)` order. */
|
|
3
5
|
constructor(w: number, x: number, y: number, z: number);
|
|
4
6
|
|
|
7
|
+
/** Mutable scalar component. */
|
|
5
8
|
w: number;
|
|
9
|
+
/** Mutable X imaginary component. */
|
|
6
10
|
x: number;
|
|
11
|
+
/** Mutable Y imaginary component. */
|
|
7
12
|
y: number;
|
|
13
|
+
/** Mutable Z imaginary component. */
|
|
8
14
|
z: number;
|
|
9
15
|
|
|
16
|
+
/** Compose this rotation with `other`, mutating this quaternion. */
|
|
10
17
|
multiply(other: Quaternion): this;
|
|
18
|
+
/** Normalize this quaternion in place. */
|
|
11
19
|
normalize(): this;
|
|
20
|
+
/** Spherically interpolate toward `target`; `t=0` keeps this rotation and `t=1` reaches it. */
|
|
12
21
|
slerp(target: Quaternion, t: number): this;
|
|
22
|
+
/** Return a new conjugated quaternion without modifying this one. */
|
|
13
23
|
conjugate(): Quaternion;
|
|
24
|
+
/** Return a new inverse rotation without modifying this quaternion. */
|
|
14
25
|
inverse(): Quaternion;
|
|
26
|
+
/** Compute the scalar quaternion dot product. */
|
|
15
27
|
dot(other: Quaternion): number;
|
|
28
|
+
/** Apply this rotation and return a new rotated vector. */
|
|
16
29
|
rotateVector(v: Vector3): Vector3;
|
|
17
30
|
/** Euler angles in radians (x=pitch, y=yaw, z=roll). */
|
|
18
31
|
toEuler(): Vector3;
|
|
32
|
+
/** Replace every component and return this quaternion for chaining. */
|
|
19
33
|
set(w: number, x: number, y: number, z: number): this;
|
|
34
|
+
/** Create an independent copy. */
|
|
20
35
|
clone(): Quaternion;
|
|
36
|
+
/** Format as `Quaternion(w, x, y, z)` for logging. */
|
|
21
37
|
toString(): string;
|
|
38
|
+
/** Convert to a plain component object for `JSON.stringify`. */
|
|
22
39
|
toJSON(): { w: number; x: number; y: number; z: number };
|
|
23
40
|
|
|
41
|
+
/** Create the identity rotation `Quaternion(1, 0, 0, 0)`. */
|
|
24
42
|
static identity(): Quaternion;
|
|
25
43
|
/** From euler angles in radians. */
|
|
26
44
|
static fromEuler(pitch: number, yaw: number, roll: number): Quaternion;
|
|
45
|
+
/** Create a rotation of `angle` radians around an axis normalized internally. */
|
|
27
46
|
static fromAxisAngle(axis: Vector3, angle: number): Quaternion;
|
|
28
47
|
}
|
|
29
48
|
}
|
package/core/vector2.d.ts
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
declare namespace Core {
|
|
2
2
|
class Vector2 {
|
|
3
|
+
/** Create a vector from its X and Y components. */
|
|
3
4
|
constructor(x: number, y: number);
|
|
4
5
|
|
|
6
|
+
/** Mutable X component. */
|
|
5
7
|
x: number;
|
|
8
|
+
/** Mutable Y component. */
|
|
6
9
|
y: number;
|
|
10
|
+
/** Euclidean magnitude of this vector. */
|
|
7
11
|
readonly length: number;
|
|
12
|
+
/** Squared magnitude, avoiding a square-root calculation. */
|
|
8
13
|
readonly lengthSquared: number;
|
|
9
14
|
|
|
15
|
+
/** Add another vector component-wise, mutating this vector. */
|
|
10
16
|
add(other: Vector2): this;
|
|
17
|
+
/** Subtract another vector component-wise, mutating this vector. */
|
|
11
18
|
sub(other: Vector2): this;
|
|
19
|
+
/** Multiply both components by a scalar, mutating this vector. */
|
|
12
20
|
mul(scalar: number): this;
|
|
21
|
+
/** Divide both components by a non-zero scalar, mutating this vector. */
|
|
13
22
|
div(scalar: number): this;
|
|
23
|
+
/** Normalize this vector in place; a zero vector remains unchanged. */
|
|
14
24
|
normalize(): this;
|
|
25
|
+
/** Compute the scalar dot product without changing either vector. */
|
|
15
26
|
dot(other: Vector2): number;
|
|
27
|
+
/** Compute Euclidean distance to another vector. */
|
|
16
28
|
distance(other: Vector2): number;
|
|
29
|
+
/** Interpolate toward `target`; `t=0` keeps this value and `t=1` reaches the target. */
|
|
17
30
|
lerp(target: Vector2, t: number): this;
|
|
31
|
+
/** Replace both components and return this vector for chaining. */
|
|
18
32
|
set(x: number, y: number): this;
|
|
33
|
+
/** Create an independent copy. */
|
|
19
34
|
clone(): Vector2;
|
|
35
|
+
/** Format as `Vector2(x, y)` for logging. */
|
|
20
36
|
toString(): string;
|
|
37
|
+
/** Convert to a plain component object for `JSON.stringify`. */
|
|
21
38
|
toJSON(): { x: number; y: number };
|
|
22
39
|
|
|
40
|
+
/** Create `Vector2(0, 0)`. */
|
|
23
41
|
static zero(): Vector2;
|
|
42
|
+
/** Create `Vector2(1, 1)`. */
|
|
24
43
|
static one(): Vector2;
|
|
25
44
|
}
|
|
26
45
|
}
|
package/core/vector3.d.ts
CHANGED
|
@@ -1,31 +1,55 @@
|
|
|
1
1
|
declare namespace Core {
|
|
2
2
|
class Vector3 {
|
|
3
|
+
/** Create a vector from its X, Y, and Z components. */
|
|
3
4
|
constructor(x: number, y: number, z: number);
|
|
4
5
|
|
|
6
|
+
/** Mutable X component. */
|
|
5
7
|
x: number;
|
|
8
|
+
/** Mutable Y component. */
|
|
6
9
|
y: number;
|
|
10
|
+
/** Mutable Z component. */
|
|
7
11
|
z: number;
|
|
12
|
+
/** Euclidean magnitude of this vector. */
|
|
8
13
|
readonly length: number;
|
|
14
|
+
/** Squared magnitude, avoiding a square-root calculation. */
|
|
9
15
|
readonly lengthSquared: number;
|
|
10
16
|
|
|
17
|
+
/** Add another vector component-wise, mutating this vector. */
|
|
11
18
|
add(other: Vector3): this;
|
|
19
|
+
/** Subtract another vector component-wise, mutating this vector. */
|
|
12
20
|
sub(other: Vector3): this;
|
|
21
|
+
/** Multiply every component by a scalar, mutating this vector. */
|
|
13
22
|
mul(scalar: number): this;
|
|
23
|
+
/** Divide every component by a non-zero scalar, mutating this vector. */
|
|
14
24
|
div(scalar: number): this;
|
|
25
|
+
/** Normalize this vector in place; a zero vector remains unchanged. */
|
|
15
26
|
normalize(): this;
|
|
27
|
+
/** Compute the scalar dot product without changing either vector. */
|
|
16
28
|
dot(other: Vector3): number;
|
|
29
|
+
/** Replace this vector with its cross product against `other`. */
|
|
17
30
|
cross(other: Vector3): this;
|
|
31
|
+
/** Compute Euclidean distance to another vector. */
|
|
18
32
|
distance(other: Vector3): number;
|
|
33
|
+
/** Interpolate toward `target`; `t=0` keeps this value and `t=1` reaches the target. */
|
|
19
34
|
lerp(target: Vector3, t: number): this;
|
|
35
|
+
/** Replace all components and return this vector for chaining. */
|
|
20
36
|
set(x: number, y: number, z: number): this;
|
|
37
|
+
/** Create an independent copy. */
|
|
21
38
|
clone(): Vector3;
|
|
39
|
+
/** Format as `Vector3(x, y, z)` for logging. */
|
|
22
40
|
toString(): string;
|
|
41
|
+
/** Convert to a plain component object for `JSON.stringify`. */
|
|
23
42
|
toJSON(): { x: number; y: number; z: number };
|
|
24
43
|
|
|
44
|
+
/** Create `Vector3(0, 0, 0)`. */
|
|
25
45
|
static zero(): Vector3;
|
|
46
|
+
/** Create `Vector3(1, 1, 1)`. */
|
|
26
47
|
static one(): Vector3;
|
|
48
|
+
/** Create the framework's positive-Y unit direction. */
|
|
27
49
|
static up(): Vector3;
|
|
50
|
+
/** Create the framework's positive-Z unit direction. */
|
|
28
51
|
static forward(): Vector3;
|
|
52
|
+
/** Create the framework's positive-X unit direction. */
|
|
29
53
|
static right(): Vector3;
|
|
30
54
|
}
|
|
31
55
|
}
|
package/core/vector4.d.ts
CHANGED
|
@@ -1,28 +1,49 @@
|
|
|
1
1
|
declare namespace Core {
|
|
2
2
|
class Vector4 {
|
|
3
|
+
/** Create a vector from its X, Y, Z, and W components. */
|
|
3
4
|
constructor(x: number, y: number, z: number, w: number);
|
|
4
5
|
|
|
6
|
+
/** Mutable X component. */
|
|
5
7
|
x: number;
|
|
8
|
+
/** Mutable Y component. */
|
|
6
9
|
y: number;
|
|
10
|
+
/** Mutable Z component. */
|
|
7
11
|
z: number;
|
|
12
|
+
/** Mutable W component. */
|
|
8
13
|
w: number;
|
|
14
|
+
/** Euclidean magnitude of this vector. */
|
|
9
15
|
readonly length: number;
|
|
16
|
+
/** Squared magnitude, avoiding a square-root calculation. */
|
|
10
17
|
readonly lengthSquared: number;
|
|
11
18
|
|
|
19
|
+
/** Add another vector component-wise, mutating this vector. */
|
|
12
20
|
add(other: Vector4): this;
|
|
21
|
+
/** Subtract another vector component-wise, mutating this vector. */
|
|
13
22
|
sub(other: Vector4): this;
|
|
23
|
+
/** Multiply every component by a scalar, mutating this vector. */
|
|
14
24
|
mul(scalar: number): this;
|
|
25
|
+
/** Divide every component by a non-zero scalar, mutating this vector. */
|
|
15
26
|
div(scalar: number): this;
|
|
27
|
+
/** Normalize this vector in place; a zero vector remains unchanged. */
|
|
16
28
|
normalize(): this;
|
|
29
|
+
/** Compute the scalar dot product without changing either vector. */
|
|
17
30
|
dot(other: Vector4): number;
|
|
31
|
+
/** Compute Euclidean distance to another vector. */
|
|
18
32
|
distance(other: Vector4): number;
|
|
33
|
+
/** Interpolate toward `target`; `t=0` keeps this value and `t=1` reaches the target. */
|
|
19
34
|
lerp(target: Vector4, t: number): this;
|
|
35
|
+
/** Replace all components and return this vector for chaining. */
|
|
20
36
|
set(x: number, y: number, z: number, w: number): this;
|
|
37
|
+
/** Create an independent copy. */
|
|
21
38
|
clone(): Vector4;
|
|
39
|
+
/** Format as `Vector4(x, y, z, w)` for logging. */
|
|
22
40
|
toString(): string;
|
|
41
|
+
/** Convert to a plain component object for `JSON.stringify`. */
|
|
23
42
|
toJSON(): { x: number; y: number; z: number; w: number };
|
|
24
43
|
|
|
44
|
+
/** Create `Vector4(0, 0, 0, 0)`. */
|
|
25
45
|
static zero(): Vector4;
|
|
46
|
+
/** Create `Vector4(1, 1, 1, 1)`. */
|
|
26
47
|
static one(): Vector4;
|
|
27
48
|
}
|
|
28
49
|
}
|
package/framework/discord.d.ts
CHANGED
|
@@ -1,153 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type DiscordActivityType = "playing" | "streaming" | "listening" | "watching" | number;
|
|
1
|
+
/** Activity verb shown before the app name. Name or the numeric Discord enum. */
|
|
2
|
+
type DiscordActivityType = "playing" | "streaming" | "listening" | "watching" | number;
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/** Party join privacy. Name or the numeric Discord enum. */
|
|
5
|
+
type DiscordPartyPrivacy = "private" | "public" | number;
|
|
7
6
|
|
|
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
|
-
|
|
7
|
+
/** Options accepted by {@link Discord.setPresence}. Every field is optional. */
|
|
8
|
+
interface DiscordPresenceOptions {
|
|
9
|
+
/** Activity verb; defaults to `"playing"`. */
|
|
10
|
+
type?: DiscordActivityType;
|
|
11
|
+
/** Activity name. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Top line of the presence. */
|
|
14
|
+
details?: string;
|
|
15
|
+
/** Bottom line of the presence. */
|
|
16
|
+
state?: string;
|
|
17
|
+
/** Elapsed-time anchor, unix seconds. `0` clears it. */
|
|
18
|
+
startTimestamp?: number;
|
|
19
|
+
/** Countdown anchor, unix seconds. `0` clears it. */
|
|
20
|
+
endTimestamp?: number;
|
|
21
|
+
/** Asset key of the large image. */
|
|
22
|
+
largeImage?: string;
|
|
23
|
+
/** Tooltip for the large image. */
|
|
24
|
+
largeText?: string;
|
|
25
|
+
/** Asset key of the small image (overlaps the large one). */
|
|
26
|
+
smallImage?: string;
|
|
27
|
+
/** Tooltip for the small image. */
|
|
28
|
+
smallText?: string;
|
|
29
|
+
/** Party grouping — enables Discord "X of Y" and, with a join secret, invites. */
|
|
30
|
+
party?: {
|
|
31
|
+
id?: string;
|
|
32
|
+
/** `[current, max]` party size. */
|
|
33
|
+
size?: [number, number];
|
|
34
|
+
privacy?: DiscordPartyPrivacy;
|
|
35
|
+
};
|
|
36
|
+
/** Invite/spectate secrets (opaque strings your game round-trips). */
|
|
37
|
+
secrets?: {
|
|
38
|
+
match?: string;
|
|
39
|
+
join?: string;
|
|
40
|
+
spectate?: string;
|
|
41
|
+
};
|
|
42
|
+
/** Whether this is an instanced (session) activity. */
|
|
43
|
+
instance?: boolean;
|
|
44
|
+
/** Supported-platform bitmask (Desktop = 1, Android = 2, iOS = 4). */
|
|
45
|
+
supportedPlatforms?: number;
|
|
46
|
+
}
|
|
48
47
|
|
|
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
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Client-side Discord rich presence API. **Client only** — not available on
|
|
50
|
+
* the server.
|
|
51
|
+
*
|
|
52
|
+
* Field setters *stage* changes onto a pending activity; nothing is shown
|
|
53
|
+
* until {@link Discord.update} (or the batch {@link Discord.setPresence}) is
|
|
54
|
+
* called. This mirrors Discord's model — an activity is published as one whole
|
|
55
|
+
* object and updates are rate-limited — so compose, then commit once. All
|
|
56
|
+
* calls no-op (setters silently, commits return `false`) when Discord presence
|
|
57
|
+
* is disabled or unavailable.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Batch form — apply several fields and publish in one call:
|
|
61
|
+
* Discord.setPresence({
|
|
62
|
+
* details: "In the city",
|
|
63
|
+
* state: "Freeroam",
|
|
64
|
+
* largeImage: "map-city",
|
|
65
|
+
* startTimestamp: Math.floor(Date.now() / 1000),
|
|
66
|
+
* party: { size: [4, 32] },
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Granular form — stage, then commit:
|
|
71
|
+
* Discord.setDetails("Racing");
|
|
72
|
+
* Discord.setPartySize(2, 8);
|
|
73
|
+
* Discord.update();
|
|
74
|
+
*/
|
|
75
|
+
declare const Discord: {
|
|
76
|
+
/** Stage the activity {@link DiscordActivityType type}. */
|
|
77
|
+
setType(type: DiscordActivityType): void;
|
|
78
|
+
/** Stage the activity name. */
|
|
79
|
+
setName(name: string): void;
|
|
80
|
+
/** Stage the top line. */
|
|
81
|
+
setDetails(details: string): void;
|
|
82
|
+
/** Stage the bottom line. */
|
|
83
|
+
setState(state: string): void;
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
/** Stage the elapsed-time anchor (unix seconds; `0` clears). */
|
|
86
|
+
setStartTimestamp(seconds: number): void;
|
|
87
|
+
/** Stage the countdown anchor (unix seconds; `0` clears). */
|
|
88
|
+
setEndTimestamp(seconds: number): void;
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
90
|
+
/** Stage the large image asset key. */
|
|
91
|
+
setLargeImage(assetKey: string): void;
|
|
92
|
+
/** Stage the large image tooltip. */
|
|
93
|
+
setLargeText(text: string): void;
|
|
94
|
+
/** Stage the small image asset key. */
|
|
95
|
+
setSmallImage(assetKey: string): void;
|
|
96
|
+
/** Stage the small image tooltip. */
|
|
97
|
+
setSmallText(text: string): void;
|
|
98
|
+
/** Stage several asset fields at once. */
|
|
99
|
+
setAssets(assets: { largeImage?: string; largeText?: string; smallImage?: string; smallText?: string }): void;
|
|
101
100
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
/** Stage the party id. */
|
|
102
|
+
setPartyId(id: string): void;
|
|
103
|
+
/** Stage the party size (current of max). */
|
|
104
|
+
setPartySize(current: number, max: number): void;
|
|
105
|
+
/** Stage the party join privacy. */
|
|
106
|
+
setPartyPrivacy(privacy: DiscordPartyPrivacy): void;
|
|
107
|
+
/** Stage several party fields at once. */
|
|
108
|
+
setParty(party: { id?: string; size?: [number, number]; privacy?: DiscordPartyPrivacy }): void;
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
/** Stage the match secret. */
|
|
111
|
+
setMatchSecret(secret: string): void;
|
|
112
|
+
/** Stage the join secret (enables Ask to Join). */
|
|
113
|
+
setJoinSecret(secret: string): void;
|
|
114
|
+
/** Stage the spectate secret. */
|
|
115
|
+
setSpectateSecret(secret: string): void;
|
|
116
|
+
/** Stage several secret fields at once. */
|
|
117
|
+
setSecrets(secrets: { match?: string; join?: string; spectate?: string }): void;
|
|
119
118
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
/** Stage the instanced flag. */
|
|
120
|
+
setInstance(instance: boolean): void;
|
|
121
|
+
/** Stage the supported-platform bitmask (Desktop = 1, Android = 2, iOS = 4). */
|
|
122
|
+
setSupportedPlatforms(flags: number): void;
|
|
124
123
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Apply a batch of fields and publish immediately (a merge of the matching
|
|
126
|
+
* setters followed by {@link Discord.update}).
|
|
127
|
+
* @returns `true` if the update was dispatched, `false` if unavailable.
|
|
128
|
+
*/
|
|
129
|
+
setPresence(options: DiscordPresenceOptions): boolean;
|
|
131
130
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Publish the currently staged activity.
|
|
133
|
+
* @returns `true` if dispatched, `false` if unavailable.
|
|
134
|
+
*/
|
|
135
|
+
update(): boolean;
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Clear the activity on Discord and reset the staged state.
|
|
139
|
+
* @returns `true` if dispatched, `false` if unavailable.
|
|
140
|
+
*/
|
|
141
|
+
clear(): boolean;
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
/** Reset the staged state without publishing. */
|
|
144
|
+
reset(): void;
|
|
146
145
|
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
/** Snowflake of the signed-in Discord user, or `""` until known. */
|
|
147
|
+
getUserId(): string;
|
|
149
148
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
149
|
+
/** Whether the Discord client is connected and presence can be published. */
|
|
150
|
+
isAvailable(): boolean;
|
|
151
|
+
};
|
package/framework/exports.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
declare const Exports: {
|
|
2
|
+
/**
|
|
3
|
+
* Register a value or function from the calling resource.
|
|
4
|
+
* @param name Export name, preferably declared in the resource manifest.
|
|
5
|
+
* @param value JavaScript value retained for dependent resources.
|
|
6
|
+
* @returns `true` when registration succeeds.
|
|
7
|
+
*/
|
|
8
|
+
register(name: string, value: any): boolean;
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Get a specific export from another resource.
|
|
12
|
+
* Throws if the resource is not found, not running, or the export
|
|
13
|
+
* does not exist.
|
|
14
|
+
* @param resourceName Name of the running resource that owns the export.
|
|
15
|
+
* @param exportName Registered export name.
|
|
16
|
+
* @returns The exported value with its original JavaScript identity.
|
|
17
|
+
*/
|
|
18
|
+
get(resourceName: string, exportName: string): any;
|
|
19
|
+
};
|
package/framework/imports.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
declare const Imports: {
|
|
2
|
+
/**
|
|
3
|
+
* Get the exports object from another resource.
|
|
4
|
+
* Throws if the resource is not found or not running.
|
|
5
|
+
* Importing without a declared dependency produces a warning.
|
|
6
|
+
* @param resourceName Name of the running resource whose exports should be read.
|
|
7
|
+
* @returns An object keyed by export name, or an empty object when none are registered.
|
|
8
|
+
*/
|
|
9
|
+
get(resourceName: string): Record<string, any>;
|
|
10
|
+
};
|
package/framework/key.d.ts
CHANGED
|
@@ -1,57 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Client-side keybinding API. **Client only** — not available on the server.
|
|
3
|
+
*
|
|
4
|
+
* Binds a physical key to a handler that fires on key-down, key-up, or both
|
|
5
|
+
* edges. Binds are resource-owned: they are cleared automatically when the
|
|
6
|
+
* resource stops. Handlers only fire while the game is in the foreground and
|
|
7
|
+
* no UI (chat box, menu, focused web view) is capturing input.
|
|
8
|
+
*
|
|
9
|
+
* Key names are case-insensitive. Recognised names:
|
|
10
|
+
* - Letters `a`–`z`, digits `0`–`9`
|
|
11
|
+
* - Function keys `f1`–`f12`
|
|
12
|
+
* - Arrows `up` `down` `left` `right`
|
|
13
|
+
* - Modifiers `shift` `lshift` `rshift`, `ctrl`/`control` `lctrl` `rctrl`,
|
|
14
|
+
* `alt` `lalt` `ralt`
|
|
15
|
+
* - Editing `space` `enter`/`return` `escape`/`esc` `tab` `backspace`
|
|
16
|
+
* `insert` `delete` `home` `end` `pageup` `pagedown` `capslock`
|
|
17
|
+
* - Numpad `numpad0`–`numpad9` (aliases `num0`–`num9`)
|
|
18
|
+
* - Mouse `mouse1` (left) `mouse2` (right) `mouse3` (middle) `mouse4` `mouse5`
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Toggle a HUD on key-down:
|
|
22
|
+
* Key.bind("f6", "down", () => toggleHud());
|
|
23
|
+
*
|
|
24
|
+
* // Hold-to-act (fires on both edges); state is "down" then "up":
|
|
25
|
+
* Key.bind("b", "both", (key, state) => setAiming(state === "down"));
|
|
26
|
+
*
|
|
27
|
+
* // State omitted defaults to "down":
|
|
28
|
+
* Key.bind("h", () => honk());
|
|
29
|
+
*/
|
|
30
|
+
declare const Key: {
|
|
2
31
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Key names are case-insensitive. Recognised names:
|
|
11
|
-
* - Letters `a`–`z`, digits `0`–`9`
|
|
12
|
-
* - Function keys `f1`–`f12`
|
|
13
|
-
* - Arrows `up` `down` `left` `right`
|
|
14
|
-
* - Modifiers `shift` `lshift` `rshift`, `ctrl`/`control` `lctrl` `rctrl`,
|
|
15
|
-
* `alt` `lalt` `ralt`
|
|
16
|
-
* - Editing `space` `enter`/`return` `escape`/`esc` `tab` `backspace`
|
|
17
|
-
* `insert` `delete` `home` `end` `pageup` `pagedown` `capslock`
|
|
18
|
-
* - Numpad `numpad0`–`numpad9` (aliases `num0`–`num9`)
|
|
19
|
-
* - Mouse `mouse1` (left) `mouse2` (right) `mouse3` (middle) `mouse4` `mouse5`
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* // Toggle a HUD on key-down:
|
|
23
|
-
* Framework.Key.bind("f6", "down", () => toggleHud());
|
|
24
|
-
*
|
|
25
|
-
* // Hold-to-act (fires on both edges); state is "down" then "up":
|
|
26
|
-
* Framework.Key.bind("b", "both", (key, state) => setAiming(state === "down"));
|
|
27
|
-
*
|
|
28
|
-
* // State omitted defaults to "down":
|
|
29
|
-
* Framework.Key.bind("h", () => honk());
|
|
32
|
+
* Bind a handler to a key.
|
|
33
|
+
* @param key Case-insensitive key name (see the {@link Key} table).
|
|
34
|
+
* @param state `"down"`, `"up"`, or `"both"`. If omitted, defaults to `"down"`.
|
|
35
|
+
* @param handler Called as `handler(key, state)` where `state` is the actual
|
|
36
|
+
* edge that fired (`"down"` or `"up"`).
|
|
37
|
+
* @returns `true` once bound. Throws on an unknown key name or bad state.
|
|
30
38
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* Bind a handler to a key.
|
|
34
|
-
* @param key Case-insensitive key name (see the {@link Key} table).
|
|
35
|
-
* @param state `"down"`, `"up"`, or `"both"`. If omitted, defaults to `"down"`.
|
|
36
|
-
* @param handler Called as `handler(key, state)` where `state` is the actual
|
|
37
|
-
* edge that fired (`"down"` or `"up"`).
|
|
38
|
-
* @returns `true` once bound. Throws on an unknown key name or bad state.
|
|
39
|
-
*/
|
|
40
|
-
bind(key: string, state: "down" | "up" | "both", handler: (key: string, state: "down" | "up") => void): boolean;
|
|
41
|
-
bind(key: string, handler: (key: string, state: "down" | "up") => void): boolean;
|
|
39
|
+
bind(key: string, state: "down" | "up" | "both", handler: (key: string, state: "down" | "up") => void): boolean;
|
|
40
|
+
bind(key: string, handler: (key: string, state: "down" | "up") => void): boolean;
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Remove binds for a key. With no filters, removes every handler on that key.
|
|
44
|
+
* @param state Optional: only remove binds registered with this state.
|
|
45
|
+
* @param handler Optional: only remove this exact handler function.
|
|
46
|
+
* @returns `true` if at least one bind was removed.
|
|
47
|
+
*/
|
|
48
|
+
unbind(key: string, state?: "down" | "up" | "both", handler?: (key: string, state: "down" | "up") => void): boolean;
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
50
|
+
/**
|
|
51
|
+
* Live physical state of a key. Returns `false` while UI owns input or the
|
|
52
|
+
* game window is in the background (same gate as bind dispatch).
|
|
53
|
+
*/
|
|
54
|
+
isDown(key: string): boolean;
|
|
55
|
+
};
|
package/framework/messages.d.ts
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
declare const Messages: {
|
|
2
|
+
/**
|
|
3
|
+
* Register or replace a handler owned by the calling resource.
|
|
4
|
+
* @param messageType Message type unique within the receiving resource.
|
|
5
|
+
* @param handler Receives `(payload, reply)`. Call `reply(value)`
|
|
6
|
+
* once to resolve a request; replies are ignored for fire-and-forget messages.
|
|
7
|
+
*/
|
|
8
|
+
handle(
|
|
9
|
+
messageType: string,
|
|
10
|
+
handler: (payload: any, reply: (value: any) => void) => void,
|
|
11
|
+
): void;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Send a request to another resource and await a reply.
|
|
15
|
+
* Rejects if the target resource has no handler or the handler throws.
|
|
16
|
+
* @param resourceName Destination running resource.
|
|
17
|
+
* @param messageType Handler type registered by the destination.
|
|
18
|
+
* @param payload Optional value delivered to the handler.
|
|
19
|
+
* @returns A promise resolved with the value passed to `reply`.
|
|
20
|
+
*/
|
|
21
|
+
request(resourceName: string, messageType: string, payload?: any): Promise<any>;
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Send a fire-and-forget message to another local resource.
|
|
25
|
+
* @param resourceName Destination running resource.
|
|
26
|
+
* @param messageType Handler type registered by the destination.
|
|
27
|
+
* @param payload Optional value delivered to the handler.
|
|
28
|
+
*/
|
|
29
|
+
send(resourceName: string, messageType: string, payload?: any): void;
|
|
30
|
+
};
|