@diffenderfer-games/hub 2.0.0-next.0 → 2.0.0-next.1
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/CHANGELOG.md +9 -0
- package/LICENSE +21 -21
- package/README.md +191 -139
- package/dist/doctor/cli.mjs +49 -19
- package/dist/doctor/cli.mjs.map +1 -1
- package/dist/shared/client-version.gen.js +1 -1
- package/dist/shared/daily.js +1 -1
- package/dist/shared/globals.js +8 -3
- package/dist/shared/globals.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/package.json +89 -89
- package/src/auto.ts +39 -39
- package/src/core/connection.ts +299 -299
- package/src/core/errors.ts +147 -147
- package/src/core/game-data.ts +38 -38
- package/src/core/hub-economy.ts +179 -179
- package/src/core/hub-progress.ts +205 -205
- package/src/core/hub.ts +131 -131
- package/src/core/menu-control.ts +61 -61
- package/src/core/offline/events.ts +50 -50
- package/src/core/offline/favorites.ts +21 -21
- package/src/core/offline/local-store.ts +261 -261
- package/src/core/offline/queue.ts +171 -171
- package/src/core/page.ts +74 -74
- package/src/core/rest/endpoint-types.ts +22 -22
- package/src/core/rest/rest-client.ts +152 -152
- package/src/core/storage/json-guards.ts +74 -74
- package/src/core/storage/key-value.ts +66 -66
- package/src/core/ticket.ts +43 -43
- package/src/core/types.ts +134 -134
- package/src/core/version/client-version.gen.ts +1 -1
- package/src/core/version/hub-version.ts +62 -62
- package/src/core/version/semver.ts +97 -97
- package/src/daily/daily-system.ts +161 -161
- package/src/daily/page-daily.ts +36 -36
- package/src/daily/types.ts +67 -67
- package/src/daily.ts +10 -10
- package/src/doctor/checks.ts +78 -76
- package/src/doctor/cli.ts +98 -106
- package/src/doctor/hub-version-fetch.ts +43 -0
- package/src/doctor/tsconfig.json +12 -12
- package/src/globals.ts +115 -110
- package/src/index.ts +50 -50
- package/src/input/device-state.ts +146 -146
- package/src/input/edges.ts +55 -55
- package/src/input/gamepad.ts +61 -61
- package/src/input/input-events.ts +32 -32
- package/src/input/input-registry.ts +164 -164
- package/src/input/input-system.ts +393 -393
- package/src/input/legacy-controls.ts +64 -64
- package/src/input/nav-state.ts +191 -191
- package/src/input/navigator.ts +171 -171
- package/src/input/on-screen-controls.ts +101 -101
- package/src/input/page-control.ts +43 -43
- package/src/input/page-input.ts +193 -193
- package/src/input/player-remaps.ts +77 -77
- package/src/input/source-values.ts +116 -116
- package/src/input/spatial.ts +47 -47
- package/src/input/types.ts +331 -331
- package/src/input/zero-config.ts +177 -177
- package/src/input.ts +22 -22
- package/src/mp.ts +10 -10
- package/src/overlay/controls-panel.ts +163 -163
- package/src/overlay/dom.ts +46 -46
- package/src/overlay/layout-clusters.ts +162 -162
- package/src/overlay/layout-geometry.ts +136 -136
- package/src/overlay/layout.ts +203 -203
- package/src/overlay/listener-scope.ts +23 -23
- package/src/overlay/on-screen-keyboard.ts +137 -137
- package/src/overlay/overlay.ts +208 -208
- package/src/overlay/styles.ts +9 -9
- package/src/overlay/virtual-controls.ts +262 -262
- package/src/race.ts +10 -10
- package/src/realtime/bridge.ts +121 -121
- package/src/realtime/cross-bundle.ts +29 -29
- package/src/realtime/fallback-notice.ts +48 -48
- package/src/realtime/hub-link.ts +65 -65
- package/src/realtime/latest-state.ts +33 -33
- package/src/realtime/multiplayer-forwarder.ts +28 -28
- package/src/realtime/multiplayer-types.ts +52 -52
- package/src/realtime/page-runtime.ts +60 -60
- package/src/realtime/race-forwarder.ts +59 -59
- package/src/realtime/race-types.ts +132 -132
- package/src/realtime/room-types.ts +125 -125
- package/src/realtime/rooms-forwarder.ts +79 -79
- package/src/realtime/runtime-api.ts +49 -49
- package/src/realtime/runtime-opener.ts +61 -61
- package/src/realtime/social-forwarder.ts +72 -72
- package/src/realtime/social-types.ts +78 -78
- package/src/realtime/types.ts +53 -53
- package/src/realtime/wire-types.ts +72 -72
- package/src/rooms.ts +10 -10
- package/src/social.ts +18 -18
- package/src/types.ts +13 -13
- package/src/uistack/page-stack.ts +45 -45
- package/src/uistack/play-suspension.ts +82 -82
- package/src/uistack/types.ts +76 -76
- package/src/uistack/ui-stack.ts +144 -144
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `hub.presence`, `hub.social` and `hub.notify`: thin forwarders to the
|
|
3
|
-
* social runtime. Presence and quiet mode are "latest state" calls,
|
|
4
|
-
* remembered and replayed when the runtime loads.
|
|
5
|
-
*/
|
|
6
|
-
import { pageBridge } from './bridge';
|
|
7
|
-
import { latestState } from './latest-state';
|
|
8
|
-
import { createRuntimeOpener } from './runtime-opener';
|
|
9
|
-
import type { HubNotifyApi, HubPresenceApi, HubSocialApi, SocialCounts } from './social-types';
|
|
10
|
-
|
|
11
|
-
const openWithRuntime = createRuntimeOpener(pageBridge);
|
|
12
|
-
|
|
13
|
-
/** Counts before the runtime is up. */
|
|
14
|
-
const NO_COUNTS: SocialCounts = { online: 0, inGame: 0, friendsOnline: 0 };
|
|
15
|
-
|
|
16
|
-
/** `hub.presence`: what you're doing, shown to friends. */
|
|
17
|
-
export const presenceForwarder: HubPresenceApi = {
|
|
18
|
-
set(presence) {
|
|
19
|
-
latestState.presence = { ...presence };
|
|
20
|
-
pageBridge.current()?.presence.set(latestState.presence);
|
|
21
|
-
},
|
|
22
|
-
clear() {
|
|
23
|
-
latestState.presence = { kind: 'menu' };
|
|
24
|
-
pageBridge.current()?.presence.clear();
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/** `hub.notify`: toast behaviour. */
|
|
29
|
-
export const notifyForwarder: HubNotifyApi = {
|
|
30
|
-
setQuiet(isQuiet) {
|
|
31
|
-
latestState.isQuiet = isQuiet;
|
|
32
|
-
pageBridge.current()?.notify.setQuiet(isQuiet);
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** `hub.social`: friends and the hub's social dialogs. */
|
|
37
|
-
export const socialForwarder: HubSocialApi = {
|
|
38
|
-
openPlayer: (ref) => {
|
|
39
|
-
openWithRuntime((realtime) => {
|
|
40
|
-
realtime.social.openPlayer(ref);
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
openFriends: () => {
|
|
44
|
-
openWithRuntime((realtime) => {
|
|
45
|
-
realtime.social.openFriends();
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
openChat: (userId) => {
|
|
49
|
-
openWithRuntime((realtime) => {
|
|
50
|
-
realtime.social.openChat(userId);
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
openInvite: (options) => {
|
|
54
|
-
openWithRuntime((realtime) => {
|
|
55
|
-
realtime.social.openInvite(options);
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
openSuggest: () => {
|
|
59
|
-
openWithRuntime((realtime) => {
|
|
60
|
-
realtime.social.openSuggest();
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
openNotify: (options) => {
|
|
64
|
-
openWithRuntime((realtime) => {
|
|
65
|
-
realtime.social.openNotify(options);
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
friends: () => pageBridge.call((realtime) => realtime.social.friends()),
|
|
69
|
-
counts: () => pageBridge.current()?.social.counts() ?? { ...NO_COUNTS },
|
|
70
|
-
chatMode: (userIds) => pageBridge.current()?.social.chatMode(userIds) ?? 'off',
|
|
71
|
-
on: (event, listener) => pageBridge.subscribe((realtime) => realtime.social.on(event, listener)),
|
|
72
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* `hub.presence`, `hub.social` and `hub.notify`: thin forwarders to the
|
|
3
|
+
* social runtime. Presence and quiet mode are "latest state" calls,
|
|
4
|
+
* remembered and replayed when the runtime loads.
|
|
5
|
+
*/
|
|
6
|
+
import { pageBridge } from './bridge';
|
|
7
|
+
import { latestState } from './latest-state';
|
|
8
|
+
import { createRuntimeOpener } from './runtime-opener';
|
|
9
|
+
import type { HubNotifyApi, HubPresenceApi, HubSocialApi, SocialCounts } from './social-types';
|
|
10
|
+
|
|
11
|
+
const openWithRuntime = createRuntimeOpener(pageBridge);
|
|
12
|
+
|
|
13
|
+
/** Counts before the runtime is up. */
|
|
14
|
+
const NO_COUNTS: SocialCounts = { online: 0, inGame: 0, friendsOnline: 0 };
|
|
15
|
+
|
|
16
|
+
/** `hub.presence`: what you're doing, shown to friends. */
|
|
17
|
+
export const presenceForwarder: HubPresenceApi = {
|
|
18
|
+
set(presence) {
|
|
19
|
+
latestState.presence = { ...presence };
|
|
20
|
+
pageBridge.current()?.presence.set(latestState.presence);
|
|
21
|
+
},
|
|
22
|
+
clear() {
|
|
23
|
+
latestState.presence = { kind: 'menu' };
|
|
24
|
+
pageBridge.current()?.presence.clear();
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** `hub.notify`: toast behaviour. */
|
|
29
|
+
export const notifyForwarder: HubNotifyApi = {
|
|
30
|
+
setQuiet(isQuiet) {
|
|
31
|
+
latestState.isQuiet = isQuiet;
|
|
32
|
+
pageBridge.current()?.notify.setQuiet(isQuiet);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** `hub.social`: friends and the hub's social dialogs. */
|
|
37
|
+
export const socialForwarder: HubSocialApi = {
|
|
38
|
+
openPlayer: (ref) => {
|
|
39
|
+
openWithRuntime((realtime) => {
|
|
40
|
+
realtime.social.openPlayer(ref);
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
openFriends: () => {
|
|
44
|
+
openWithRuntime((realtime) => {
|
|
45
|
+
realtime.social.openFriends();
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
openChat: (userId) => {
|
|
49
|
+
openWithRuntime((realtime) => {
|
|
50
|
+
realtime.social.openChat(userId);
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
openInvite: (options) => {
|
|
54
|
+
openWithRuntime((realtime) => {
|
|
55
|
+
realtime.social.openInvite(options);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
openSuggest: () => {
|
|
59
|
+
openWithRuntime((realtime) => {
|
|
60
|
+
realtime.social.openSuggest();
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
openNotify: (options) => {
|
|
64
|
+
openWithRuntime((realtime) => {
|
|
65
|
+
realtime.social.openNotify(options);
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
friends: () => pageBridge.call((realtime) => realtime.social.friends()),
|
|
69
|
+
counts: () => pageBridge.current()?.social.counts() ?? { ...NO_COUNTS },
|
|
70
|
+
chatMode: (userIds) => pageBridge.current()?.social.chatMode(userIds) ?? 'off',
|
|
71
|
+
on: (event, listener) => pageBridge.subscribe((realtime) => realtime.social.on(event, listener)),
|
|
72
|
+
};
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Friends, presence and notification shapes as games see them through
|
|
3
|
-
* `hub.social`, `hub.presence` and `hub.notify`.
|
|
4
|
-
*/
|
|
5
|
-
import type { ChatMode, FriendEntry, Invite, Party, Presence, PresenceInput } from '@diffenderfer-games/hub-contract';
|
|
6
|
-
|
|
7
|
-
/** Online counts as a game sees them. */
|
|
8
|
-
export interface SocialCounts {
|
|
9
|
-
/** Everyone online on the site. */
|
|
10
|
-
online: number;
|
|
11
|
-
/** Players in the current game (0 on the catalog page). */
|
|
12
|
-
inGame: number;
|
|
13
|
-
/** My friends currently online. */
|
|
14
|
-
friendsOnline: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Events `hub.social.on` delivers, name → payload. */
|
|
18
|
-
export interface SocialEvents {
|
|
19
|
-
/** The friends list changed. */
|
|
20
|
-
friends: FriendEntry[];
|
|
21
|
-
/** A friend's presence changed (`null` when they went offline). */
|
|
22
|
-
presence: { userId: number; p: Presence | null };
|
|
23
|
-
/** The online counts changed. */
|
|
24
|
-
counts: SocialCounts;
|
|
25
|
-
/** An invite arrived. */
|
|
26
|
-
invite: Invite;
|
|
27
|
-
/** My party changed (`null` when I left it). */
|
|
28
|
-
party: Party | null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Who to open a player card for. */
|
|
32
|
-
export type PlayerRef = { userId: number } | { username: string };
|
|
33
|
-
|
|
34
|
-
/** Options for the invite picker. */
|
|
35
|
-
export interface OpenInviteOptions {
|
|
36
|
-
/** Preselect this friend. */
|
|
37
|
-
userId?: number;
|
|
38
|
-
/** The game mode to invite to. */
|
|
39
|
-
mode?: string;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** `hub.presence`: what you're doing, shown to friends (privacy is automatic). */
|
|
43
|
-
export interface HubPresenceApi {
|
|
44
|
-
/** Report an activity, e.g. `{ kind: 'playing', detail: 'Level 3' }`. Coalesced; safe to call often. */
|
|
45
|
-
set(presence: PresenceInput): void;
|
|
46
|
-
/** Back to "in the menu". */
|
|
47
|
-
clear(): void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** `hub.social`: friends and the hub's social dialogs. */
|
|
51
|
-
export interface HubSocialApi {
|
|
52
|
-
/** Open a player card (add friend, message, invite, block, report). */
|
|
53
|
-
openPlayer(ref: PlayerRef): void;
|
|
54
|
-
/** Open the hub menu on the Friends section. */
|
|
55
|
-
openFriends(): void;
|
|
56
|
-
/** Open the chat with a friend. */
|
|
57
|
-
openChat(userId: number): void;
|
|
58
|
-
/** Open the invite picker (current game by default). */
|
|
59
|
-
openInvite(options?: OpenInviteOptions): void;
|
|
60
|
-
/** Open the game-suggestion form and board. */
|
|
61
|
-
openSuggest(): void;
|
|
62
|
-
/** Open notification settings, optionally focused on a game's lobby bell. */
|
|
63
|
-
openNotify(options?: { game?: string }): void;
|
|
64
|
-
/** Friends with live presence. Rejects with `OfflineError` without the runtime. */
|
|
65
|
-
friends(): Promise<FriendEntry[]>;
|
|
66
|
-
/** Live counts; all zero until the runtime is up. */
|
|
67
|
-
counts(): SocialCounts;
|
|
68
|
-
/** The effective chat mode (with these players); `'off'` until the runtime is up. */
|
|
69
|
-
chatMode(userIds?: number[]): ChatMode;
|
|
70
|
-
/** Subscribe to social events; works before the runtime loads. Returns the unsubscribe function. */
|
|
71
|
-
on<Name extends keyof SocialEvents>(event: Name, listener: (payload: SocialEvents[Name]) => void): () => void;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** `hub.notify`: toast behaviour during intense play. */
|
|
75
|
-
export interface HubNotifyApi {
|
|
76
|
-
/** Quiet: toasts collapse into the menu badge; invites still show as a small pill. */
|
|
77
|
-
setQuiet(isQuiet: boolean): void;
|
|
78
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Friends, presence and notification shapes as games see them through
|
|
3
|
+
* `hub.social`, `hub.presence` and `hub.notify`.
|
|
4
|
+
*/
|
|
5
|
+
import type { ChatMode, FriendEntry, Invite, Party, Presence, PresenceInput } from '@diffenderfer-games/hub-contract';
|
|
6
|
+
|
|
7
|
+
/** Online counts as a game sees them. */
|
|
8
|
+
export interface SocialCounts {
|
|
9
|
+
/** Everyone online on the site. */
|
|
10
|
+
online: number;
|
|
11
|
+
/** Players in the current game (0 on the catalog page). */
|
|
12
|
+
inGame: number;
|
|
13
|
+
/** My friends currently online. */
|
|
14
|
+
friendsOnline: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Events `hub.social.on` delivers, name → payload. */
|
|
18
|
+
export interface SocialEvents {
|
|
19
|
+
/** The friends list changed. */
|
|
20
|
+
friends: FriendEntry[];
|
|
21
|
+
/** A friend's presence changed (`null` when they went offline). */
|
|
22
|
+
presence: { userId: number; p: Presence | null };
|
|
23
|
+
/** The online counts changed. */
|
|
24
|
+
counts: SocialCounts;
|
|
25
|
+
/** An invite arrived. */
|
|
26
|
+
invite: Invite;
|
|
27
|
+
/** My party changed (`null` when I left it). */
|
|
28
|
+
party: Party | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Who to open a player card for. */
|
|
32
|
+
export type PlayerRef = { userId: number } | { username: string };
|
|
33
|
+
|
|
34
|
+
/** Options for the invite picker. */
|
|
35
|
+
export interface OpenInviteOptions {
|
|
36
|
+
/** Preselect this friend. */
|
|
37
|
+
userId?: number;
|
|
38
|
+
/** The game mode to invite to. */
|
|
39
|
+
mode?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** `hub.presence`: what you're doing, shown to friends (privacy is automatic). */
|
|
43
|
+
export interface HubPresenceApi {
|
|
44
|
+
/** Report an activity, e.g. `{ kind: 'playing', detail: 'Level 3' }`. Coalesced; safe to call often. */
|
|
45
|
+
set(presence: PresenceInput): void;
|
|
46
|
+
/** Back to "in the menu". */
|
|
47
|
+
clear(): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** `hub.social`: friends and the hub's social dialogs. */
|
|
51
|
+
export interface HubSocialApi {
|
|
52
|
+
/** Open a player card (add friend, message, invite, block, report). */
|
|
53
|
+
openPlayer(ref: PlayerRef): void;
|
|
54
|
+
/** Open the hub menu on the Friends section. */
|
|
55
|
+
openFriends(): void;
|
|
56
|
+
/** Open the chat with a friend. */
|
|
57
|
+
openChat(userId: number): void;
|
|
58
|
+
/** Open the invite picker (current game by default). */
|
|
59
|
+
openInvite(options?: OpenInviteOptions): void;
|
|
60
|
+
/** Open the game-suggestion form and board. */
|
|
61
|
+
openSuggest(): void;
|
|
62
|
+
/** Open notification settings, optionally focused on a game's lobby bell. */
|
|
63
|
+
openNotify(options?: { game?: string }): void;
|
|
64
|
+
/** Friends with live presence. Rejects with `OfflineError` without the runtime. */
|
|
65
|
+
friends(): Promise<FriendEntry[]>;
|
|
66
|
+
/** Live counts; all zero until the runtime is up. */
|
|
67
|
+
counts(): SocialCounts;
|
|
68
|
+
/** The effective chat mode (with these players); `'off'` until the runtime is up. */
|
|
69
|
+
chatMode(userIds?: number[]): ChatMode;
|
|
70
|
+
/** Subscribe to social events; works before the runtime loads. Returns the unsubscribe function. */
|
|
71
|
+
on<Name extends keyof SocialEvents>(event: Name, listener: (payload: SocialEvents[Name]) => void): () => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** `hub.notify`: toast behaviour during intense play. */
|
|
75
|
+
export interface HubNotifyApi {
|
|
76
|
+
/** Quiet: toasts collapse into the menu badge; invites still show as a small pill. */
|
|
77
|
+
setQuiet(isQuiet: boolean): void;
|
|
78
|
+
}
|
package/src/realtime/types.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Every public realtime type in one place: the realtime API the social
|
|
3
|
-
* runtime implements, the shapes `hub.social`, `hub.mp`, `hub.rooms` and
|
|
4
|
-
* `hub.race` use, and the contract entities they carry. Types only.
|
|
5
|
-
*/
|
|
6
|
-
export type {
|
|
7
|
-
Audience,
|
|
8
|
-
ChatMode,
|
|
9
|
-
Conversation,
|
|
10
|
-
Counts,
|
|
11
|
-
ErrorBody,
|
|
12
|
-
FriendEntry,
|
|
13
|
-
Invite,
|
|
14
|
-
JoinInfo,
|
|
15
|
-
Launch,
|
|
16
|
-
LaunchTicket,
|
|
17
|
-
Message,
|
|
18
|
-
MessagesPage,
|
|
19
|
-
NotifyChange,
|
|
20
|
-
NotifyPrefs,
|
|
21
|
-
Party,
|
|
22
|
-
PlayerCard,
|
|
23
|
-
PlayerLite,
|
|
24
|
-
Presence,
|
|
25
|
-
PresenceInput,
|
|
26
|
-
PresenceKind,
|
|
27
|
-
RaceOutcome,
|
|
28
|
-
RaceParams,
|
|
29
|
-
RaceRecord,
|
|
30
|
-
RaceResult,
|
|
31
|
-
RaceState,
|
|
32
|
-
RaceStats,
|
|
33
|
-
RaceStatValue,
|
|
34
|
-
Racer,
|
|
35
|
-
RacerResult,
|
|
36
|
-
RacerState,
|
|
37
|
-
RecentPlayer,
|
|
38
|
-
Relation,
|
|
39
|
-
ReportInput,
|
|
40
|
-
ReportKind,
|
|
41
|
-
ReportReason,
|
|
42
|
-
RoomInfo,
|
|
43
|
-
SocialConfig,
|
|
44
|
-
SocialMe,
|
|
45
|
-
Suggestion,
|
|
46
|
-
SuggestionStatus,
|
|
47
|
-
} from '@diffenderfer-games/hub-contract';
|
|
48
|
-
export type * from './wire-types';
|
|
49
|
-
export type * from './social-types';
|
|
50
|
-
export type * from './multiplayer-types';
|
|
51
|
-
export type * from './room-types';
|
|
52
|
-
export type * from './race-types';
|
|
53
|
-
export type { RealtimeApi } from './runtime-api';
|
|
1
|
+
/**
|
|
2
|
+
* Every public realtime type in one place: the realtime API the social
|
|
3
|
+
* runtime implements, the shapes `hub.social`, `hub.mp`, `hub.rooms` and
|
|
4
|
+
* `hub.race` use, and the contract entities they carry. Types only.
|
|
5
|
+
*/
|
|
6
|
+
export type {
|
|
7
|
+
Audience,
|
|
8
|
+
ChatMode,
|
|
9
|
+
Conversation,
|
|
10
|
+
Counts,
|
|
11
|
+
ErrorBody,
|
|
12
|
+
FriendEntry,
|
|
13
|
+
Invite,
|
|
14
|
+
JoinInfo,
|
|
15
|
+
Launch,
|
|
16
|
+
LaunchTicket,
|
|
17
|
+
Message,
|
|
18
|
+
MessagesPage,
|
|
19
|
+
NotifyChange,
|
|
20
|
+
NotifyPrefs,
|
|
21
|
+
Party,
|
|
22
|
+
PlayerCard,
|
|
23
|
+
PlayerLite,
|
|
24
|
+
Presence,
|
|
25
|
+
PresenceInput,
|
|
26
|
+
PresenceKind,
|
|
27
|
+
RaceOutcome,
|
|
28
|
+
RaceParams,
|
|
29
|
+
RaceRecord,
|
|
30
|
+
RaceResult,
|
|
31
|
+
RaceState,
|
|
32
|
+
RaceStats,
|
|
33
|
+
RaceStatValue,
|
|
34
|
+
Racer,
|
|
35
|
+
RacerResult,
|
|
36
|
+
RacerState,
|
|
37
|
+
RecentPlayer,
|
|
38
|
+
Relation,
|
|
39
|
+
ReportInput,
|
|
40
|
+
ReportKind,
|
|
41
|
+
ReportReason,
|
|
42
|
+
RoomInfo,
|
|
43
|
+
SocialConfig,
|
|
44
|
+
SocialMe,
|
|
45
|
+
Suggestion,
|
|
46
|
+
SuggestionStatus,
|
|
47
|
+
} from '@diffenderfer-games/hub-contract';
|
|
48
|
+
export type * from './wire-types';
|
|
49
|
+
export type * from './social-types';
|
|
50
|
+
export type * from './multiplayer-types';
|
|
51
|
+
export type * from './room-types';
|
|
52
|
+
export type * from './race-types';
|
|
53
|
+
export type { RealtimeApi } from './runtime-api';
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `/_ws` wire shapes the realtime runtime and the forwarders share,
|
|
3
|
-
* derived from the hub contract so they can never drift from what the server
|
|
4
|
-
* sends. Types only: nothing here costs a byte at runtime.
|
|
5
|
-
*/
|
|
6
|
-
import type {
|
|
7
|
-
EventData,
|
|
8
|
-
events,
|
|
9
|
-
OpAck,
|
|
10
|
-
ops,
|
|
11
|
-
InviteCreated as InviteCreatedSchema,
|
|
12
|
-
RaceHistory as RaceHistorySchema,
|
|
13
|
-
RaceResultPlayer as RaceResultPlayerSchema,
|
|
14
|
-
RaceRecordPlayer as RaceRecordPlayerSchema,
|
|
15
|
-
RoomSeat as RoomSeatSchema,
|
|
16
|
-
} from '@diffenderfer-games/hub-contract';
|
|
17
|
-
|
|
18
|
-
/** The parsed (output) type of a contract schema, without importing zod. */
|
|
19
|
-
export type SchemaOutput<Schema> = Schema extends { readonly _zod: { readonly output: infer Output } } ? Output : never;
|
|
20
|
-
|
|
21
|
-
/** Every server event, name → payload (the contract's `events`). */
|
|
22
|
-
export type ServerEvents = { [Name in keyof typeof events]: EventData<(typeof events)[Name]> };
|
|
23
|
-
|
|
24
|
-
/** The `hello` ack: everything the Friends drawer needs in one round-trip. */
|
|
25
|
-
export type Snapshot = OpAck<(typeof ops)['hello']>;
|
|
26
|
-
|
|
27
|
-
/** A generic server notice rendered as a toast (`ev:notice`). */
|
|
28
|
-
export type Notice = ServerEvents['notice'];
|
|
29
|
-
|
|
30
|
-
/** A seat in a hub room. */
|
|
31
|
-
export type RoomSeat = SchemaOutput<typeof RoomSeatSchema>;
|
|
32
|
-
|
|
33
|
-
/** One racer's line in a decided race. */
|
|
34
|
-
export type RaceResultPlayer = SchemaOutput<typeof RaceResultPlayerSchema>;
|
|
35
|
-
|
|
36
|
-
/** A racer in a history record. Suspended opponents are `hidden` (id 0, no name). */
|
|
37
|
-
export type RaceRecordPlayer = SchemaOutput<typeof RaceRecordPlayerSchema>;
|
|
38
|
-
|
|
39
|
-
/** A page of the player's races, newest first (`GET /race/history`). */
|
|
40
|
-
export type RaceHistory = SchemaOutput<typeof RaceHistorySchema>;
|
|
41
|
-
|
|
42
|
-
/** `POST /mp/invites`: the invite plus the inviter's own launch. */
|
|
43
|
-
export type InviteCreated = SchemaOutput<typeof InviteCreatedSchema>;
|
|
44
|
-
|
|
45
|
-
/** A live status line from another racer (`ev:race.status`); `at` is ms since the go on the server clock. */
|
|
46
|
-
export type RaceStatusEvent = ServerEvents['race.status'];
|
|
47
|
-
|
|
48
|
-
/** A relayed game message (`ev:room.msg`). */
|
|
49
|
-
export type RoomMessage = ServerEvents['room.msg'];
|
|
50
|
-
|
|
51
|
-
/** A shared-state change (`ev:room.state`); patches are shallow-merged unless `replace`. */
|
|
52
|
-
export type RoomStateChange = ServerEvents['room.state'];
|
|
53
|
-
|
|
54
|
-
/** A moderated room chat line (`ev:room.chat`). */
|
|
55
|
-
export type RoomChatLine = ServerEvents['room.chat'];
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* What a rejected realtime call throws. The runtime is another bundle, so its
|
|
59
|
-
* errors are re-created as the game's own `HubError` classes by the forwarders.
|
|
60
|
-
*/
|
|
61
|
-
export interface RealtimeErrorShape extends Error {
|
|
62
|
-
/** HTTP status (REST), absent for transport and socket errors. */
|
|
63
|
-
status?: number;
|
|
64
|
-
/** The machine-readable code from the error body. */
|
|
65
|
-
code?: string;
|
|
66
|
-
/** Why content was rejected. */
|
|
67
|
-
reason?: string;
|
|
68
|
-
/** A player-facing hint. */
|
|
69
|
-
hint?: string;
|
|
70
|
-
/** How long to wait before retrying, when rate limited. */
|
|
71
|
-
retryAfterMs?: number;
|
|
72
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* The `/_ws` wire shapes the realtime runtime and the forwarders share,
|
|
3
|
+
* derived from the hub contract so they can never drift from what the server
|
|
4
|
+
* sends. Types only: nothing here costs a byte at runtime.
|
|
5
|
+
*/
|
|
6
|
+
import type {
|
|
7
|
+
EventData,
|
|
8
|
+
events,
|
|
9
|
+
OpAck,
|
|
10
|
+
ops,
|
|
11
|
+
InviteCreated as InviteCreatedSchema,
|
|
12
|
+
RaceHistory as RaceHistorySchema,
|
|
13
|
+
RaceResultPlayer as RaceResultPlayerSchema,
|
|
14
|
+
RaceRecordPlayer as RaceRecordPlayerSchema,
|
|
15
|
+
RoomSeat as RoomSeatSchema,
|
|
16
|
+
} from '@diffenderfer-games/hub-contract';
|
|
17
|
+
|
|
18
|
+
/** The parsed (output) type of a contract schema, without importing zod. */
|
|
19
|
+
export type SchemaOutput<Schema> = Schema extends { readonly _zod: { readonly output: infer Output } } ? Output : never;
|
|
20
|
+
|
|
21
|
+
/** Every server event, name → payload (the contract's `events`). */
|
|
22
|
+
export type ServerEvents = { [Name in keyof typeof events]: EventData<(typeof events)[Name]> };
|
|
23
|
+
|
|
24
|
+
/** The `hello` ack: everything the Friends drawer needs in one round-trip. */
|
|
25
|
+
export type Snapshot = OpAck<(typeof ops)['hello']>;
|
|
26
|
+
|
|
27
|
+
/** A generic server notice rendered as a toast (`ev:notice`). */
|
|
28
|
+
export type Notice = ServerEvents['notice'];
|
|
29
|
+
|
|
30
|
+
/** A seat in a hub room. */
|
|
31
|
+
export type RoomSeat = SchemaOutput<typeof RoomSeatSchema>;
|
|
32
|
+
|
|
33
|
+
/** One racer's line in a decided race. */
|
|
34
|
+
export type RaceResultPlayer = SchemaOutput<typeof RaceResultPlayerSchema>;
|
|
35
|
+
|
|
36
|
+
/** A racer in a history record. Suspended opponents are `hidden` (id 0, no name). */
|
|
37
|
+
export type RaceRecordPlayer = SchemaOutput<typeof RaceRecordPlayerSchema>;
|
|
38
|
+
|
|
39
|
+
/** A page of the player's races, newest first (`GET /race/history`). */
|
|
40
|
+
export type RaceHistory = SchemaOutput<typeof RaceHistorySchema>;
|
|
41
|
+
|
|
42
|
+
/** `POST /mp/invites`: the invite plus the inviter's own launch. */
|
|
43
|
+
export type InviteCreated = SchemaOutput<typeof InviteCreatedSchema>;
|
|
44
|
+
|
|
45
|
+
/** A live status line from another racer (`ev:race.status`); `at` is ms since the go on the server clock. */
|
|
46
|
+
export type RaceStatusEvent = ServerEvents['race.status'];
|
|
47
|
+
|
|
48
|
+
/** A relayed game message (`ev:room.msg`). */
|
|
49
|
+
export type RoomMessage = ServerEvents['room.msg'];
|
|
50
|
+
|
|
51
|
+
/** A shared-state change (`ev:room.state`); patches are shallow-merged unless `replace`. */
|
|
52
|
+
export type RoomStateChange = ServerEvents['room.state'];
|
|
53
|
+
|
|
54
|
+
/** A moderated room chat line (`ev:room.chat`). */
|
|
55
|
+
export type RoomChatLine = ServerEvents['room.chat'];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* What a rejected realtime call throws. The runtime is another bundle, so its
|
|
59
|
+
* errors are re-created as the game's own `HubError` classes by the forwarders.
|
|
60
|
+
*/
|
|
61
|
+
export interface RealtimeErrorShape extends Error {
|
|
62
|
+
/** HTTP status (REST), absent for transport and socket errors. */
|
|
63
|
+
status?: number;
|
|
64
|
+
/** The machine-readable code from the error body. */
|
|
65
|
+
code?: string;
|
|
66
|
+
/** Why content was rejected. */
|
|
67
|
+
reason?: string;
|
|
68
|
+
/** A player-facing hint. */
|
|
69
|
+
hint?: string;
|
|
70
|
+
/** How long to wait before retrying, when rate limited. */
|
|
71
|
+
retryAfterMs?: number;
|
|
72
|
+
}
|
package/src/rooms.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@diffenderfer-games/hub/rooms`: the hub relay rooms forwarder (`hub.rooms`),
|
|
3
|
-
* for games that want only this namespace.
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
6
|
-
*/
|
|
7
|
-
export { roomsForwarder as rooms } from './realtime/rooms-forwarder';
|
|
8
|
-
export type * from './realtime/room-types';
|
|
9
|
-
export type { RoomChatLine, RoomMessage, RoomSeat, RoomStateChange } from './realtime/wire-types';
|
|
10
|
-
export type { RoomInfo } from '@diffenderfer-games/hub-contract';
|
|
1
|
+
/**
|
|
2
|
+
* `@diffenderfer-games/hub/rooms`: the hub relay rooms forwarder (`hub.rooms`),
|
|
3
|
+
* for games that want only this namespace.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { roomsForwarder as rooms } from './realtime/rooms-forwarder';
|
|
8
|
+
export type * from './realtime/room-types';
|
|
9
|
+
export type { RoomChatLine, RoomMessage, RoomSeat, RoomStateChange } from './realtime/wire-types';
|
|
10
|
+
export type { RoomInfo } from '@diffenderfer-games/hub-contract';
|
package/src/social.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@diffenderfer-games/hub/social`: the social forwarders (`hub.social`,
|
|
3
|
-
* `hub.presence`, `hub.notify`), and every realtime type: the API the hub's
|
|
4
|
-
* social runtime implements and the shapes it carries.
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
export { notifyForwarder as notify, presenceForwarder as presence, socialForwarder as social } from './realtime/social-forwarder';
|
|
9
|
-
export { linkRealtimeToHub } from './realtime/hub-link';
|
|
10
|
-
export type { RealtimeHubLink } from './realtime/hub-link';
|
|
11
|
-
export { findRealtimeApi, isRealtimeApi } from './realtime/page-runtime';
|
|
12
|
-
export {
|
|
13
|
-
REALTIME_FAILED_EVENT,
|
|
14
|
-
REALTIME_FEATURE_VERSION,
|
|
15
|
-
REALTIME_READY_EVENT,
|
|
16
|
-
REALTIME_SINGLETON_API,
|
|
17
|
-
} from './realtime/runtime-api';
|
|
18
|
-
export type * from './realtime/types';
|
|
1
|
+
/**
|
|
2
|
+
* `@diffenderfer-games/hub/social`: the social forwarders (`hub.social`,
|
|
3
|
+
* `hub.presence`, `hub.notify`), and every realtime type: the API the hub's
|
|
4
|
+
* social runtime implements and the shapes it carries.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { notifyForwarder as notify, presenceForwarder as presence, socialForwarder as social } from './realtime/social-forwarder';
|
|
9
|
+
export { linkRealtimeToHub } from './realtime/hub-link';
|
|
10
|
+
export type { RealtimeHubLink } from './realtime/hub-link';
|
|
11
|
+
export { findRealtimeApi, isRealtimeApi } from './realtime/page-runtime';
|
|
12
|
+
export {
|
|
13
|
+
REALTIME_FAILED_EVENT,
|
|
14
|
+
REALTIME_FEATURE_VERSION,
|
|
15
|
+
REALTIME_READY_EVENT,
|
|
16
|
+
REALTIME_SINGLETON_API,
|
|
17
|
+
} from './realtime/runtime-api';
|
|
18
|
+
export type * from './realtime/types';
|
package/src/types.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@diffenderfer-games/hub/types`: a type-only re-export of every contract
|
|
3
|
-
* type a game may use (request and reply shapes, entities, error bodies and
|
|
4
|
-
* codes, socket ops and events, the `game.*` manifest), so a game can name a
|
|
5
|
-
* hub type without depending on the contract package itself. Importing it
|
|
6
|
-
* adds nothing to a bundle.
|
|
7
|
-
*
|
|
8
|
-
* The client's own types (`User`, `Save<T>`, `HubStatus`, ...) come from the
|
|
9
|
-
* main entry.
|
|
10
|
-
*
|
|
11
|
-
* @packageDocumentation
|
|
12
|
-
*/
|
|
13
|
-
export type * from '@diffenderfer-games/hub-contract';
|
|
1
|
+
/**
|
|
2
|
+
* `@diffenderfer-games/hub/types`: a type-only re-export of every contract
|
|
3
|
+
* type a game may use (request and reply shapes, entities, error bodies and
|
|
4
|
+
* codes, socket ops and events, the `game.*` manifest), so a game can name a
|
|
5
|
+
* hub type without depending on the contract package itself. Importing it
|
|
6
|
+
* adds nothing to a bundle.
|
|
7
|
+
*
|
|
8
|
+
* The client's own types (`User`, `Save<T>`, `HubStatus`, ...) come from the
|
|
9
|
+
* main entry.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
export type * from '@diffenderfer-games/hub-contract';
|