@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.
@@ -1,153 +1,151 @@
1
- declare namespace Framework {
2
- /** Activity verb shown before the app name. Name or the numeric Discord enum. */
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
- /** Party join privacy. Name or the numeric Discord enum. */
6
- type DiscordPartyPrivacy = "private" | "public" | number;
4
+ /** Party join privacy. Name or the numeric Discord enum. */
5
+ type DiscordPartyPrivacy = "private" | "public" | number;
7
6
 
8
- /** Options accepted by {@link Discord.setPresence}. Every field is optional. */
9
- interface DiscordPresenceOptions {
10
- /** Activity verb; defaults to `"playing"`. */
11
- type?: DiscordActivityType;
12
- /** Activity name. */
13
- name?: string;
14
- /** Top line of the presence. */
15
- details?: string;
16
- /** Bottom line of the presence. */
17
- state?: string;
18
- /** Elapsed-time anchor, unix seconds. `0` clears it. */
19
- startTimestamp?: number;
20
- /** Countdown anchor, unix seconds. `0` clears it. */
21
- endTimestamp?: number;
22
- /** Asset key of the large image. */
23
- largeImage?: string;
24
- /** Tooltip for the large image. */
25
- largeText?: string;
26
- /** Asset key of the small image (overlaps the large one). */
27
- smallImage?: string;
28
- /** Tooltip for the small image. */
29
- smallText?: string;
30
- /** Party grouping — enables Discord "X of Y" and, with a join secret, invites. */
31
- party?: {
32
- id?: string;
33
- /** `[current, max]` party size. */
34
- size?: [number, number];
35
- privacy?: DiscordPartyPrivacy;
36
- };
37
- /** Invite/spectate secrets (opaque strings your game round-trips). */
38
- secrets?: {
39
- match?: string;
40
- join?: string;
41
- spectate?: string;
42
- };
43
- /** Whether this is an instanced (session) activity. */
44
- instance?: boolean;
45
- /** Supported-platform bitmask (Desktop = 1, Android = 2, iOS = 4). */
46
- supportedPlatforms?: number;
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
- * Client-side Discord rich presence API. **Client only** — not available on
51
- * the server.
52
- *
53
- * Field setters *stage* changes onto a pending activity; nothing is shown
54
- * until {@link Discord.update} (or the batch {@link Discord.setPresence}) is
55
- * called. This mirrors Discord's model — an activity is published as one whole
56
- * object and updates are rate-limited — so compose, then commit once. All
57
- * calls no-op (setters silently, commits return `false`) when Discord presence
58
- * is disabled or unavailable.
59
- *
60
- * @example
61
- * // Batch form — apply several fields and publish in one call:
62
- * Framework.Discord.setPresence({
63
- * details: "In the city",
64
- * state: "Freeroam",
65
- * largeImage: "map-city",
66
- * startTimestamp: Math.floor(Date.now() / 1000),
67
- * party: { size: [4, 32] },
68
- * });
69
- *
70
- * @example
71
- * // Granular form — stage, then commit:
72
- * Framework.Discord.setDetails("Racing");
73
- * Framework.Discord.setPartySize(2, 8);
74
- * Framework.Discord.update();
75
- */
76
- const Discord: {
77
- /** Stage the activity {@link DiscordActivityType type}. */
78
- setType(type: DiscordActivityType): void;
79
- /** Stage the activity name. */
80
- setName(name: string): void;
81
- /** Stage the top line. */
82
- setDetails(details: string): void;
83
- /** Stage the bottom line. */
84
- setState(state: string): void;
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
- /** Stage the elapsed-time anchor (unix seconds; `0` clears). */
87
- setStartTimestamp(seconds: number): void;
88
- /** Stage the countdown anchor (unix seconds; `0` clears). */
89
- setEndTimestamp(seconds: number): void;
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
- /** Stage the large image asset key. */
92
- setLargeImage(assetKey: string): void;
93
- /** Stage the large image tooltip. */
94
- setLargeText(text: string): void;
95
- /** Stage the small image asset key. */
96
- setSmallImage(assetKey: string): void;
97
- /** Stage the small image tooltip. */
98
- setSmallText(text: string): void;
99
- /** Stage several asset fields at once. */
100
- setAssets(assets: { largeImage?: string; largeText?: string; smallImage?: string; smallText?: string }): void;
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
- /** Stage the party id. */
103
- setPartyId(id: string): void;
104
- /** Stage the party size (current of max). */
105
- setPartySize(current: number, max: number): void;
106
- /** Stage the party join privacy. */
107
- setPartyPrivacy(privacy: DiscordPartyPrivacy): void;
108
- /** Stage several party fields at once. */
109
- setParty(party: { id?: string; size?: [number, number]; privacy?: DiscordPartyPrivacy }): void;
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
- /** Stage the match secret. */
112
- setMatchSecret(secret: string): void;
113
- /** Stage the join secret (enables Ask to Join). */
114
- setJoinSecret(secret: string): void;
115
- /** Stage the spectate secret. */
116
- setSpectateSecret(secret: string): void;
117
- /** Stage several secret fields at once. */
118
- setSecrets(secrets: { match?: string; join?: string; spectate?: string }): void;
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
- /** Stage the instanced flag. */
121
- setInstance(instance: boolean): void;
122
- /** Stage the supported-platform bitmask (Desktop = 1, Android = 2, iOS = 4). */
123
- setSupportedPlatforms(flags: number): void;
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
- * Apply a batch of fields and publish immediately (a merge of the matching
127
- * setters followed by {@link Discord.update}).
128
- * @returns `true` if the update was dispatched, `false` if unavailable.
129
- */
130
- setPresence(options: DiscordPresenceOptions): boolean;
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
- * Publish the currently staged activity.
134
- * @returns `true` if dispatched, `false` if unavailable.
135
- */
136
- update(): boolean;
131
+ /**
132
+ * Publish the currently staged activity.
133
+ * @returns `true` if dispatched, `false` if unavailable.
134
+ */
135
+ update(): boolean;
137
136
 
138
- /**
139
- * Clear the activity on Discord and reset the staged state.
140
- * @returns `true` if dispatched, `false` if unavailable.
141
- */
142
- clear(): boolean;
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
- /** Reset the staged state without publishing. */
145
- reset(): void;
143
+ /** Reset the staged state without publishing. */
144
+ reset(): void;
146
145
 
147
- /** Snowflake of the signed-in Discord user, or `""` until known. */
148
- getUserId(): string;
146
+ /** Snowflake of the signed-in Discord user, or `""` until known. */
147
+ getUserId(): string;
149
148
 
150
- /** Whether the Discord client is connected and presence can be published. */
151
- isAvailable(): boolean;
152
- };
153
- }
149
+ /** Whether the Discord client is connected and presence can be published. */
150
+ isAvailable(): boolean;
151
+ };
@@ -1,21 +1,19 @@
1
- declare namespace Framework {
2
- const Exports: {
3
- /**
4
- * Register a value or function from the calling resource.
5
- * @param name Export name, preferably declared in the resource manifest.
6
- * @param value JavaScript value retained for dependent resources.
7
- * @returns `true` when registration succeeds.
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
- * Get a specific export from another resource.
13
- * Throws if the resource is not found, not running, or the export
14
- * does not exist.
15
- * @param resourceName Name of the running resource that owns the export.
16
- * @param exportName Registered export name.
17
- * @returns The exported value with its original JavaScript identity.
18
- */
19
- get(resourceName: string, exportName: string): any;
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
+ };
@@ -1,12 +1,10 @@
1
- declare namespace Framework {
2
- const imports: {
3
- /**
4
- * Get the exports object from another resource.
5
- * Throws if the resource is not found or not running.
6
- * Importing without a declared dependency produces a warning.
7
- * @param resourceName Name of the running resource whose exports should be read.
8
- * @returns An object keyed by export name, or an empty object when none are registered.
9
- */
10
- get(resourceName: string): Record<string, any>;
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
+ };
@@ -1,57 +1,55 @@
1
- declare namespace Framework {
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
- * Client-side keybinding API. **Client only** — not available on the server.
4
- *
5
- * Binds a physical key to a handler that fires on key-down, key-up, or both
6
- * edges. Binds are resource-owned: they are cleared automatically when the
7
- * resource stops. Handlers only fire while the game is in the foreground and
8
- * no UI (chat box, menu, focused web view) is capturing input.
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
- const Key: {
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
- * Remove binds for a key. With no filters, removes every handler on that key.
45
- * @param state Optional: only remove binds registered with this state.
46
- * @param handler Optional: only remove this exact handler function.
47
- * @returns `true` if at least one bind was removed.
48
- */
49
- unbind(key: string, state?: "down" | "up" | "both", handler?: (key: string, state: "down" | "up") => void): boolean;
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
- * Live physical state of a key. Returns `false` while UI owns input or the
53
- * game window is in the background (same gate as bind dispatch).
54
- */
55
- isDown(key: string): boolean;
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
+ };
@@ -1,32 +1,30 @@
1
- declare namespace Framework {
2
- const messages: {
3
- /**
4
- * Register or replace a handler owned by the calling resource.
5
- * @param messageType Message type unique within the receiving resource.
6
- * @param handler Receives `(payload, reply)`. Call `reply(value)`
7
- * once to resolve a request; replies are ignored for fire-and-forget messages.
8
- */
9
- handle(
10
- messageType: string,
11
- handler: (payload: any, reply: (value: any) => void) => void,
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
- * Send a request to another resource and await a reply.
16
- * Rejects if the target resource has no handler or the handler throws.
17
- * @param resourceName Destination running resource.
18
- * @param messageType Handler type registered by the destination.
19
- * @param payload Optional value delivered to the handler.
20
- * @returns A promise resolved with the value passed to `reply`.
21
- */
22
- request(resourceName: string, messageType: string, payload?: any): Promise<any>;
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
- * Send a fire-and-forget message to another local resource.
26
- * @param resourceName Destination running resource.
27
- * @param messageType Handler type registered by the destination.
28
- * @param payload Optional value delivered to the handler.
29
- */
30
- send(resourceName: string, messageType: string, payload?: any): void;
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mafiahub/types",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "TypeScript type definitions for the MafiaHub Framework scripting API",
5
5
  "types": "index.d.ts",
6
6
  "files": [