@mafiahub/types 0.1.6 → 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/framework/discord.d.ts +137 -139
- package/framework/exports.d.ts +18 -20
- package/framework/imports.d.ts +10 -12
- package/framework/key.d.ts +51 -53
- package/framework/messages.d.ts +28 -30
- package/package.json +1 -1
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,21 +1,19 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
register(name: string, value: any): boolean;
|
|
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;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
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,12 +1,10 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
}
|
|
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,32 +1,30 @@
|
|
|
1
|
-
declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
): void;
|
|
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;
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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>;
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
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
|
+
};
|