@diffenderfer-games/hub 0.0.0-stage → 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 -0
- package/README.md +191 -3
- package/dist/auto.d.ts +36 -0
- package/dist/auto.d.ts.map +1 -0
- package/dist/auto.js +27 -0
- package/dist/auto.js.map +1 -0
- package/dist/daily.d.ts +2 -0
- package/dist/daily.js +1 -0
- package/dist/doctor/cli.mjs +268 -0
- package/dist/doctor/cli.mjs.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +6 -0
- package/dist/input.d.ts +2 -0
- package/dist/input.js +3 -0
- package/dist/mp.d.ts +4 -0
- package/dist/mp.js +1 -0
- package/dist/race.d.ts +4 -0
- package/dist/race.js +1 -0
- package/dist/rooms.d.ts +4 -0
- package/dist/rooms.js +1 -0
- package/dist/shared/bridge.js +209 -0
- package/dist/shared/bridge.js.map +1 -0
- package/dist/shared/client-version.gen.js +7 -0
- package/dist/shared/client-version.gen.js.map +1 -0
- package/dist/shared/daily.d.ts +123 -0
- package/dist/shared/daily.d.ts.map +1 -0
- package/dist/shared/daily.js +191 -0
- package/dist/shared/daily.js.map +1 -0
- package/dist/shared/dom.js +48 -0
- package/dist/shared/dom.js.map +1 -0
- package/dist/shared/globals.js +102 -0
- package/dist/shared/globals.js.map +1 -0
- package/dist/shared/index.d.ts +706 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/input.d.ts +730 -0
- package/dist/shared/input.d.ts.map +1 -0
- package/dist/shared/input.js +2718 -0
- package/dist/shared/input.js.map +1 -0
- package/dist/shared/latest-state.js +17 -0
- package/dist/shared/latest-state.js.map +1 -0
- package/dist/shared/mp.d.ts +9 -0
- package/dist/shared/mp.d.ts.map +1 -0
- package/dist/shared/mp.js +30 -0
- package/dist/shared/mp.js.map +1 -0
- package/dist/shared/multiplayer-types.d.ts +47 -0
- package/dist/shared/multiplayer-types.d.ts.map +1 -0
- package/dist/shared/page-stack.js +207 -0
- package/dist/shared/page-stack.js.map +1 -0
- package/dist/shared/race-types.d.ts +126 -0
- package/dist/shared/race-types.d.ts.map +1 -0
- package/dist/shared/race.d.ts +9 -0
- package/dist/shared/race.d.ts.map +1 -0
- package/dist/shared/race.js +53 -0
- package/dist/shared/race.js.map +1 -0
- package/dist/shared/room-types.d.ts +125 -0
- package/dist/shared/room-types.d.ts.map +1 -0
- package/dist/shared/rooms.d.ts +9 -0
- package/dist/shared/rooms.d.ts.map +1 -0
- package/dist/shared/rooms.js +62 -0
- package/dist/shared/rooms.js.map +1 -0
- package/dist/shared/runtime-opener.js +84 -0
- package/dist/shared/runtime-opener.js.map +1 -0
- package/dist/shared/social.d.ts +148 -0
- package/dist/shared/social.d.ts.map +1 -0
- package/dist/shared/social.js +73 -0
- package/dist/shared/social.js.map +1 -0
- package/dist/shared/src.js +2164 -0
- package/dist/shared/src.js.map +1 -0
- package/dist/shared/wire-types.d.ts +51 -0
- package/dist/shared/wire-types.d.ts.map +1 -0
- package/dist/social.d.ts +6 -0
- package/dist/social.js +3 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +0 -0
- package/package.json +89 -6
- package/src/auto.ts +39 -0
- package/src/core/connection.ts +299 -0
- package/src/core/errors.ts +147 -0
- package/src/core/game-data.ts +38 -0
- package/src/core/hub-economy.ts +179 -0
- package/src/core/hub-progress.ts +205 -0
- package/src/core/hub.ts +131 -0
- package/src/core/menu-control.ts +61 -0
- package/src/core/offline/events.ts +50 -0
- package/src/core/offline/favorites.ts +21 -0
- package/src/core/offline/local-store.ts +261 -0
- package/src/core/offline/queue.ts +171 -0
- package/src/core/page.ts +74 -0
- package/src/core/rest/endpoint-types.ts +22 -0
- package/src/core/rest/rest-client.ts +152 -0
- package/src/core/rest/routes.gen.ts +90 -0
- package/src/core/storage/json-guards.ts +74 -0
- package/src/core/storage/key-value.ts +66 -0
- package/src/core/ticket.ts +43 -0
- package/src/core/types.ts +134 -0
- package/src/core/version/client-version.gen.ts +3 -0
- package/src/core/version/hub-version.ts +62 -0
- package/src/core/version/semver.ts +97 -0
- package/src/daily/daily-system.ts +161 -0
- package/src/daily/page-daily.ts +36 -0
- package/src/daily/types.ts +67 -0
- package/src/daily.ts +10 -0
- package/src/doctor/checks.ts +78 -0
- package/src/doctor/cli.ts +98 -0
- package/src/doctor/hub-version-fetch.ts +43 -0
- package/src/doctor/tsconfig.json +12 -0
- package/src/globals.ts +115 -0
- package/src/index.ts +50 -0
- package/src/input/device-state.ts +146 -0
- package/src/input/edges.ts +55 -0
- package/src/input/gamepad.ts +61 -0
- package/src/input/input-events.ts +32 -0
- package/src/input/input-registry.ts +164 -0
- package/src/input/input-system.ts +393 -0
- package/src/input/legacy-controls.ts +64 -0
- package/src/input/nav-state.ts +191 -0
- package/src/input/navigator.ts +171 -0
- package/src/input/on-screen-controls.ts +101 -0
- package/src/input/page-control.ts +43 -0
- package/src/input/page-input.ts +193 -0
- package/src/input/player-remaps.ts +77 -0
- package/src/input/source-values.ts +116 -0
- package/src/input/spatial.ts +47 -0
- package/src/input/types.ts +331 -0
- package/src/input/zero-config.ts +177 -0
- package/src/input.ts +22 -0
- package/src/mp.ts +10 -0
- package/src/overlay/controls-panel.ts +163 -0
- package/src/overlay/dom.ts +46 -0
- package/src/overlay/layout-clusters.ts +162 -0
- package/src/overlay/layout-geometry.ts +136 -0
- package/src/overlay/layout.ts +203 -0
- package/src/overlay/listener-scope.ts +23 -0
- package/src/overlay/on-screen-keyboard.ts +137 -0
- package/src/overlay/overlay.ts +208 -0
- package/src/overlay/styles.ts +54 -0
- package/src/overlay/virtual-controls.ts +262 -0
- package/src/race.ts +10 -0
- package/src/realtime/bridge.ts +121 -0
- package/src/realtime/cross-bundle.ts +29 -0
- package/src/realtime/fallback-notice.ts +48 -0
- package/src/realtime/hub-link.ts +65 -0
- package/src/realtime/latest-state.ts +33 -0
- package/src/realtime/multiplayer-forwarder.ts +28 -0
- package/src/realtime/multiplayer-types.ts +52 -0
- package/src/realtime/page-runtime.ts +60 -0
- package/src/realtime/race-forwarder.ts +59 -0
- package/src/realtime/race-types.ts +132 -0
- package/src/realtime/room-types.ts +125 -0
- package/src/realtime/rooms-forwarder.ts +79 -0
- package/src/realtime/runtime-api.ts +49 -0
- package/src/realtime/runtime-opener.ts +61 -0
- package/src/realtime/social-forwarder.ts +72 -0
- package/src/realtime/social-types.ts +78 -0
- package/src/realtime/types.ts +53 -0
- package/src/realtime/wire-types.ts +72 -0
- package/src/rooms.ts +10 -0
- package/src/social.ts +18 -0
- package/src/types.ts +13 -0
- package/src/uistack/page-stack.ts +45 -0
- package/src/uistack/play-suspension.ts +82 -0
- package/src/uistack/types.ts +76 -0
- package/src/uistack/ui-stack.ts +144 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { t as pageBridge, u as hubLink } from "./bridge.js";
|
|
2
|
+
import { t as createRuntimeOpener } from "./runtime-opener.js";
|
|
3
|
+
//#region src/realtime/race-forwarder.ts
|
|
4
|
+
/**
|
|
5
|
+
* `hub.race`: races, forwarded to the social runtime. An old cached runtime
|
|
6
|
+
* (feature version 1) has no races, which reads as "not available" rather
|
|
7
|
+
* than a crash.
|
|
8
|
+
*/
|
|
9
|
+
const openWithRuntime = createRuntimeOpener(pageBridge);
|
|
10
|
+
let raceDefinition = null;
|
|
11
|
+
pageBridge.onReady((realtime) => {
|
|
12
|
+
if (raceDefinition !== null) realtime.race?.define(raceDefinition);
|
|
13
|
+
});
|
|
14
|
+
/** The runtime's race section, or an `OfflineError` for a runtime too old to race. */
|
|
15
|
+
function requireRaces(realtime) {
|
|
16
|
+
if (realtime.race === void 0) throw hubLink().createOfflineError("Races need the latest hub — reload the page.");
|
|
17
|
+
return realtime.race;
|
|
18
|
+
}
|
|
19
|
+
/** `hub.race`: races. */
|
|
20
|
+
const raceForwarder = {
|
|
21
|
+
define(definition) {
|
|
22
|
+
raceDefinition = definition;
|
|
23
|
+
pageBridge.current()?.race?.define(definition);
|
|
24
|
+
},
|
|
25
|
+
create: (options) => pageBridge.call((realtime) => requireRaces(realtime).create(options)),
|
|
26
|
+
join: (code, options) => pageBridge.call((realtime) => requireRaces(realtime).join(code, options)),
|
|
27
|
+
list: () => pageBridge.call((realtime) => requireRaces(realtime).list()),
|
|
28
|
+
browse: () => {
|
|
29
|
+
openWithRuntime((realtime) => {
|
|
30
|
+
realtime.race?.browse();
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
openHistory: (options) => {
|
|
34
|
+
openWithRuntime((realtime) => {
|
|
35
|
+
realtime.race?.openHistory(options);
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
history: (query) => pageBridge.call((realtime) => requireRaces(realtime).history(query)),
|
|
39
|
+
status: (stats, progress) => {
|
|
40
|
+
pageBridge.current()?.race?.status(stats, progress);
|
|
41
|
+
},
|
|
42
|
+
finish: (stats) => pageBridge.call((realtime) => requireRaces(realtime).finish(stats)),
|
|
43
|
+
lose: (stats) => pageBridge.call((realtime) => requireRaces(realtime).lose(stats)),
|
|
44
|
+
forfeit: () => pageBridge.call((realtime) => requireRaces(realtime).forfeit()),
|
|
45
|
+
leave: () => pageBridge.call((realtime) => requireRaces(realtime).leave()),
|
|
46
|
+
rematch: (params) => pageBridge.call((realtime) => requireRaces(realtime).rematch(params)),
|
|
47
|
+
current: () => pageBridge.current()?.race?.current() ?? null,
|
|
48
|
+
on: (event, listener) => pageBridge.subscribe((realtime) => realtime.race?.on(event, listener) ?? (() => void 0))
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { raceForwarder as t };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=race.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"race.js","names":[],"sources":["../../src/realtime/race-forwarder.ts"],"mappings":";;;;;;;;AAWA,MAAM,kBAAkB,oBAAoB,UAAU;AAEtD,IAAI,iBAAwC;AAC5C,WAAW,SAAS,aAAa;CAC/B,IAAI,mBAAmB,MACrB,SAAS,MAAM,OAAO,cAAc;AAExC,CAAC;;AAGD,SAAS,aAAa,UAAmC;CACvD,IAAI,SAAS,SAAS,KAAA,GACpB,MAAM,QAAQ,CAAC,CAAC,mBAAmB,8CAA8C;CAEnF,OAAO,SAAS;AAClB;;AAGA,MAAa,gBAA4B;CACvC,OAAO,YAAY;EACjB,iBAAiB;EACjB,WAAW,QAAQ,CAAC,EAAE,MAAM,OAAO,UAAU;CAC/C;CACA,SAAS,YAAY,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC;CACzF,OAAO,MAAM,YAAY,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,KAAK,MAAM,OAAO,CAAC;CACjG,YAAY,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,KAAK,CAAC;CACvE,cAAc;EACZ,iBAAiB,aAAa;GAC5B,SAAS,MAAM,OAAO;EACxB,CAAC;CACH;CACA,cAAc,YAAY;EACxB,iBAAiB,aAAa;GAC5B,SAAS,MAAM,YAAY,OAAO;EACpC,CAAC;CACH;CACA,UAAU,UAAU,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,QAAQ,KAAK,CAAC;CACvF,SAAS,OAAO,aAAa;EAC3B,WAAW,QAAQ,CAAC,EAAE,MAAM,OAAO,OAAO,QAAQ;CACpD;CACA,SAAS,UAAU,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC;CACrF,OAAO,UAAU,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,KAAK,KAAK,CAAC;CACjF,eAAe,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,QAAQ,CAAC;CAC7E,aAAa,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,MAAM,CAAC;CACzE,UAAU,WAAW,WAAW,MAAM,aAAa,aAAa,QAAQ,CAAC,CAAC,QAAQ,MAAM,CAAC;CACzF,eAAe,WAAW,QAAQ,CAAC,EAAE,MAAM,QAAQ,KAAK;CACxD,KAAK,OAAO,aAAa,WAAW,WAAW,aAAa,SAAS,MAAM,GAAG,OAAO,QAAQ,YAAY,KAAA,EAAU;AACrH"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { c as RoomChatLine, l as RoomMessage } from "./wire-types.js";
|
|
2
|
+
import { Json, RoomInfo } from "@diffenderfer-games/hub-contract";
|
|
3
|
+
//#region src/realtime/room-types.d.ts
|
|
4
|
+
/** The shared room state (a JSON object, at most 32 KB). */
|
|
5
|
+
type RoomState = Record<string, Json>;
|
|
6
|
+
/** Options for `hub.rooms.create`. `game` defaults to the current slug. */
|
|
7
|
+
interface RoomCreateOptions {
|
|
8
|
+
/** The game slug (default: this page's game). */
|
|
9
|
+
game?: string;
|
|
10
|
+
/** The game mode. */
|
|
11
|
+
mode?: string;
|
|
12
|
+
/** Listed in `hub.rooms.list` (default false). */
|
|
13
|
+
public?: boolean;
|
|
14
|
+
/** Seats. */
|
|
15
|
+
maxPlayers?: number;
|
|
16
|
+
/** `host` (default): guests' unaddressed sends reach the host only. `relay`: everyone hears every send. */
|
|
17
|
+
model?: 'host' | 'relay';
|
|
18
|
+
/** Seat this party in the room. */
|
|
19
|
+
partyId?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Options for joining a room or race. */
|
|
22
|
+
interface JoinOptions {
|
|
23
|
+
/** Watch instead of taking a seat (if the game allows spectators). */
|
|
24
|
+
spectate?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Events a {@link HubRoom} emits, name → payload. */
|
|
27
|
+
interface RoomEvents {
|
|
28
|
+
/** The room changed: roster, ready flags, phase, host. */
|
|
29
|
+
room: RoomInfo;
|
|
30
|
+
/** A relayed game message. */
|
|
31
|
+
msg: RoomMessage;
|
|
32
|
+
/** The shared state after a change. */
|
|
33
|
+
state: RoomState;
|
|
34
|
+
/** A moderated chat line. */
|
|
35
|
+
chat: RoomChatLine;
|
|
36
|
+
/** The host removed me. */
|
|
37
|
+
kicked: {
|
|
38
|
+
roomId: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The room is gone for this tab. `reason`: empty, ended, host_left,
|
|
42
|
+
* other_tab, moved, removed, or `gone` (client-side: the seat couldn't be
|
|
43
|
+
* reclaimed after a reconnect, e.g. the host restarted).
|
|
44
|
+
*/
|
|
45
|
+
closed: {
|
|
46
|
+
reason: string;
|
|
47
|
+
};
|
|
48
|
+
/** The host ended the match (phase → `ended`); `results` is what it passed to `end()`. Fires once. */
|
|
49
|
+
ended: {
|
|
50
|
+
room: RoomInfo;
|
|
51
|
+
results?: Json;
|
|
52
|
+
};
|
|
53
|
+
/** A player left mid-game (or their reconnect grace ran out). */
|
|
54
|
+
abandoned: {
|
|
55
|
+
userId: number;
|
|
56
|
+
reason?: string;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Who I am in a room. */
|
|
60
|
+
interface RoomSelf {
|
|
61
|
+
/** My user id. */
|
|
62
|
+
userId: number;
|
|
63
|
+
/** I host the room. */
|
|
64
|
+
host: boolean;
|
|
65
|
+
/** I'm watching, not seated. */
|
|
66
|
+
spectator: boolean;
|
|
67
|
+
}
|
|
68
|
+
/** Options for {@link HubRoom.send}. */
|
|
69
|
+
interface RoomSendOptions {
|
|
70
|
+
/** Send to this seat only. */
|
|
71
|
+
to?: number;
|
|
72
|
+
}
|
|
73
|
+
/** Options for {@link HubRoom.setState}. */
|
|
74
|
+
interface RoomStateOptions {
|
|
75
|
+
/** Replace the whole state instead of shallow-merging the patch. */
|
|
76
|
+
replace?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/** A live hub relay room, as games see it. */
|
|
79
|
+
interface HubRoom {
|
|
80
|
+
/** The room as last reported. */
|
|
81
|
+
readonly info: RoomInfo;
|
|
82
|
+
/** The shared room state (at most 32 KB). */
|
|
83
|
+
readonly state: RoomState;
|
|
84
|
+
/** Who I am in this room. */
|
|
85
|
+
readonly me: RoomSelf;
|
|
86
|
+
/** Subscribe to a room event. Returns the unsubscribe function. */
|
|
87
|
+
on<Name extends keyof RoomEvents>(event: Name, listener: (payload: RoomEvents[Name]) => void): () => void;
|
|
88
|
+
/** Mark my seat ready (or not). */
|
|
89
|
+
ready(isReady: boolean): Promise<void>;
|
|
90
|
+
/** Set my seat's small game data (team, colour…), at most 2 KB. */
|
|
91
|
+
seat(seatData: Json): Promise<void>;
|
|
92
|
+
/** Host: start the match. */
|
|
93
|
+
start(): Promise<void>;
|
|
94
|
+
/** Relay a game message. */
|
|
95
|
+
send(message: Json, options?: RoomSendOptions): Promise<void>;
|
|
96
|
+
/** Change the shared state. */
|
|
97
|
+
setState(patch: RoomState, options?: RoomStateOptions): Promise<void>;
|
|
98
|
+
/** Free-text chat; resolves with the delivered (maybe softened) text, rejects with a content rejection. */
|
|
99
|
+
chat(text: string): Promise<string>;
|
|
100
|
+
/** Send a quick-chat phrase. */
|
|
101
|
+
quick(phraseId: string): Promise<void>;
|
|
102
|
+
/** Host: remove a player. */
|
|
103
|
+
kick(userId: number): Promise<void>;
|
|
104
|
+
/** Leave the room. */
|
|
105
|
+
leave(): Promise<void>;
|
|
106
|
+
/** Host: end the match, with optional results for everyone. */
|
|
107
|
+
end(results?: Json): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
/** Options for `hub.rooms.list`. */
|
|
110
|
+
interface RoomListOptions {
|
|
111
|
+
/** Only rooms in this mode. */
|
|
112
|
+
mode?: string;
|
|
113
|
+
}
|
|
114
|
+
/** `hub.rooms`: hub relay rooms (static games, no server). */
|
|
115
|
+
interface HubRoomsApi {
|
|
116
|
+
/** Create a room and take its first seat. */
|
|
117
|
+
create(options?: RoomCreateOptions): Promise<HubRoom>;
|
|
118
|
+
/** Join a room by its 5-character code or its id. */
|
|
119
|
+
join(codeOrId: string, options?: JoinOptions): Promise<HubRoom>;
|
|
120
|
+
/** Public rooms in the lobby phase for this game. */
|
|
121
|
+
list(options?: RoomListOptions): Promise<RoomInfo[]>;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { RoomEvents as a, RoomSendOptions as c, RoomCreateOptions as i, RoomState as l, HubRoomsApi as n, RoomListOptions as o, JoinOptions as r, RoomSelf as s, HubRoom as t, RoomStateOptions as u };
|
|
125
|
+
//# sourceMappingURL=room-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-types.d.ts","names":[],"sources":["../../src/realtime/room-types.ts"],"mappings":";;;;KAQY,YAAY,eAAe;;UAGtB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;;UAIe;;EAEf,MAAM;;EAEN,KAAK;;EAEL,OAAO;;EAEP,MAAM;;EAEN;IAAU;;;;;;;EAMV;IAAU;;;EAEV;IAAS,MAAM;IAAU,UAAU;;;EAEnC;IAAa;IAAgB;;;;UAId;;EAEf;;EAEA;;EAEA;;;UAIe;;EAEf;;;UAIe;;EAEf;;;UAIe;;WAEN,MAAM;;WAEN,OAAO;;WAEP,IAAI;;EAEb,GAAG,mBAAmB,YAAY,OAAO,MAAM,WAAW,SAAS,WAAW;;EAE9E,MAAM,mBAAmB;;EAEzB,KAAK,UAAU,OAAO;;EAEtB,SAAS;;EAET,KAAK,SAAS,MAAM,UAAU,kBAAkB;;EAEhD,SAAS,OAAO,WAAW,UAAU,mBAAmB;;EAExD,KAAK,eAAe;;EAEpB,MAAM,mBAAmB;;EAEzB,KAAK,iBAAiB;;EAEtB,SAAS;;EAET,IAAI,UAAU,OAAO;;;UAIN;;EAEf;;;UAIe;;EAEf,OAAO,UAAU,oBAAoB,QAAQ;;EAE7C,KAAK,kBAAkB,UAAU,cAAc,QAAQ;;EAEvD,KAAK,UAAU,kBAAkB,QAAQ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "./wire-types.js";
|
|
2
|
+
import { n as HubRoomsApi } from "./room-types.js";
|
|
3
|
+
import { RoomInfo as RoomInfo$1 } from "@diffenderfer-games/hub-contract";
|
|
4
|
+
//#region src/realtime/rooms-forwarder.d.ts
|
|
5
|
+
/** `hub.rooms`: hub relay rooms. */
|
|
6
|
+
declare const roomsForwarder: HubRoomsApi;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { roomsForwarder as n, RoomInfo$1 as t };
|
|
9
|
+
//# sourceMappingURL=rooms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rooms.d.ts","names":[],"sources":["../../src/realtime/rooms-forwarder.ts"],"mappings":";;;;;cA0Ea,gBAAgB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { r as _defineProperty } from "./globals.js";
|
|
2
|
+
import { n as rethrowAsHubError, t as pageBridge } from "./bridge.js";
|
|
3
|
+
//#region src/realtime/rooms-forwarder.ts
|
|
4
|
+
/** A runtime room whose rejections are re-created as the core client's errors. */
|
|
5
|
+
var ForwardedRoom = class {
|
|
6
|
+
constructor(room) {
|
|
7
|
+
_defineProperty(this, "room", void 0);
|
|
8
|
+
this.room = room;
|
|
9
|
+
}
|
|
10
|
+
get info() {
|
|
11
|
+
return this.room.info;
|
|
12
|
+
}
|
|
13
|
+
get state() {
|
|
14
|
+
return this.room.state;
|
|
15
|
+
}
|
|
16
|
+
get me() {
|
|
17
|
+
return this.room.me;
|
|
18
|
+
}
|
|
19
|
+
on(event, listener) {
|
|
20
|
+
return this.room.on(event, listener);
|
|
21
|
+
}
|
|
22
|
+
ready(isReady) {
|
|
23
|
+
return rethrowAsHubError(this.room.ready(isReady));
|
|
24
|
+
}
|
|
25
|
+
seat(seatData) {
|
|
26
|
+
return rethrowAsHubError(this.room.seat(seatData));
|
|
27
|
+
}
|
|
28
|
+
start() {
|
|
29
|
+
return rethrowAsHubError(this.room.start());
|
|
30
|
+
}
|
|
31
|
+
send(message, options) {
|
|
32
|
+
return rethrowAsHubError(this.room.send(message, options));
|
|
33
|
+
}
|
|
34
|
+
setState(patch, options) {
|
|
35
|
+
return rethrowAsHubError(this.room.setState(patch, options));
|
|
36
|
+
}
|
|
37
|
+
chat(text) {
|
|
38
|
+
return rethrowAsHubError(this.room.chat(text));
|
|
39
|
+
}
|
|
40
|
+
quick(phraseId) {
|
|
41
|
+
return rethrowAsHubError(this.room.quick(phraseId));
|
|
42
|
+
}
|
|
43
|
+
kick(userId) {
|
|
44
|
+
return rethrowAsHubError(this.room.kick(userId));
|
|
45
|
+
}
|
|
46
|
+
leave() {
|
|
47
|
+
return rethrowAsHubError(this.room.leave());
|
|
48
|
+
}
|
|
49
|
+
end(results) {
|
|
50
|
+
return rethrowAsHubError(this.room.end(results));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/** `hub.rooms`: hub relay rooms. */
|
|
54
|
+
const roomsForwarder = {
|
|
55
|
+
create: (options) => pageBridge.call(async (realtime) => new ForwardedRoom(await realtime.rooms.create(options))),
|
|
56
|
+
join: (codeOrId, options) => pageBridge.call(async (realtime) => new ForwardedRoom(await realtime.rooms.join(codeOrId, options))),
|
|
57
|
+
list: (options) => pageBridge.call((realtime) => realtime.rooms.list(options))
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { roomsForwarder as t };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=rooms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rooms.js","names":[],"sources":["../../src/realtime/rooms-forwarder.ts"],"mappings":";;;;AASA,IAAM,gBAAN,MAAuC;CAGrC,YAAY,MAAe;EAFV,gBAAA,MAAA,QAAA,KAAA,CAAA;EAGf,KAAK,OAAO;CACd;CAEA,IAAI,OAAiB;EACnB,OAAO,KAAK,KAAK;CACnB;CAEA,IAAI,QAAmB;EACrB,OAAO,KAAK,KAAK;CACnB;CAEA,IAAI,KAAe;EACjB,OAAO,KAAK,KAAK;CACnB;CAEA,GAAkC,OAAa,UAA2D;EACxG,OAAO,KAAK,KAAK,GAAG,OAAO,QAAQ;CACrC;CAEA,MAAM,SAAiC;EACrC,OAAO,kBAAkB,KAAK,KAAK,MAAM,OAAO,CAAC;CACnD;CAEA,KAAK,UAA+B;EAClC,OAAO,kBAAkB,KAAK,KAAK,KAAK,QAAQ,CAAC;CACnD;CAEA,QAAuB;EACrB,OAAO,kBAAkB,KAAK,KAAK,MAAM,CAAC;CAC5C;CAEA,KAAK,SAAe,SAA0C;EAC5D,OAAO,kBAAkB,KAAK,KAAK,KAAK,SAAS,OAAO,CAAC;CAC3D;CAEA,SAAS,OAAkB,SAA2C;EACpE,OAAO,kBAAkB,KAAK,KAAK,SAAS,OAAO,OAAO,CAAC;CAC7D;CAEA,KAAK,MAA+B;EAClC,OAAO,kBAAkB,KAAK,KAAK,KAAK,IAAI,CAAC;CAC/C;CAEA,MAAM,UAAiC;EACrC,OAAO,kBAAkB,KAAK,KAAK,MAAM,QAAQ,CAAC;CACpD;CAEA,KAAK,QAA+B;EAClC,OAAO,kBAAkB,KAAK,KAAK,KAAK,MAAM,CAAC;CACjD;CAEA,QAAuB;EACrB,OAAO,kBAAkB,KAAK,KAAK,MAAM,CAAC;CAC5C;CAEA,IAAI,SAA+B;EACjC,OAAO,kBAAkB,KAAK,KAAK,IAAI,OAAO,CAAC;CACjD;AACF;;AAGA,MAAa,iBAA8B;CACzC,SAAS,YAAY,WAAW,KAAK,OAAO,aAAa,IAAI,cAAc,MAAM,SAAS,MAAM,OAAO,OAAO,CAAC,CAAC;CAChH,OAAO,UAAU,YAAY,WAAW,KAAK,OAAO,aAAa,IAAI,cAAc,MAAM,SAAS,MAAM,KAAK,UAAU,OAAO,CAAC,CAAC;CAChI,OAAO,YAAY,WAAW,MAAM,aAAa,SAAS,MAAM,KAAK,OAAO,CAAC;AAC/E"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { r as pageBody } from "./dom.js";
|
|
2
|
+
import { a as readRuntimeFailure, o as REALTIME_FAILED_EVENT } from "./bridge.js";
|
|
3
|
+
//#region src/realtime/fallback-notice.ts
|
|
4
|
+
/**
|
|
5
|
+
* A minimal top-centre notice for when the social runtime (which owns the
|
|
6
|
+
* real toasts) isn't available: plain DOM with inline styles in the hub
|
|
7
|
+
* palette, one at a time.
|
|
8
|
+
*/
|
|
9
|
+
const NOTICE_ELEMENT_ID = "hub-fallback-notice";
|
|
10
|
+
const NOTICE_STYLE = "position:fixed;top:12px;left:50%;transform:translateX(-50%);z-index:2147483647;max-width:min(92vw,420px);padding:10px 14px;border-radius:10px;font:13px/1.4 \"Space Mono\",ui-monospace,monospace;background:#11141c;color:#e8e6df;border:1px solid #2a3142;box-shadow:0 8px 24px rgba(0,0,0,.5);pointer-events:none;";
|
|
11
|
+
let hideTimer = null;
|
|
12
|
+
/** Show `text`; it hides itself after `visibleMs` (0 = until replaced or hidden). */
|
|
13
|
+
function showFallbackNotice(text, visibleMs = 0) {
|
|
14
|
+
if (typeof document === "undefined") return;
|
|
15
|
+
const body = pageBody();
|
|
16
|
+
if (body === null) return;
|
|
17
|
+
let notice = document.getElementById(NOTICE_ELEMENT_ID);
|
|
18
|
+
if (notice === null) {
|
|
19
|
+
notice = document.createElement("div");
|
|
20
|
+
notice.id = NOTICE_ELEMENT_ID;
|
|
21
|
+
notice.setAttribute("role", "status");
|
|
22
|
+
notice.style.cssText = NOTICE_STYLE;
|
|
23
|
+
body.appendChild(notice);
|
|
24
|
+
}
|
|
25
|
+
notice.textContent = text;
|
|
26
|
+
if (hideTimer !== null) clearTimeout(hideTimer);
|
|
27
|
+
hideTimer = visibleMs > 0 ? setTimeout(hideFallbackNotice, visibleMs) : null;
|
|
28
|
+
}
|
|
29
|
+
/** Remove the notice. */
|
|
30
|
+
function hideFallbackNotice() {
|
|
31
|
+
if (hideTimer !== null) {
|
|
32
|
+
clearTimeout(hideTimer);
|
|
33
|
+
hideTimer = null;
|
|
34
|
+
}
|
|
35
|
+
if (typeof document !== "undefined") document.getElementById(NOTICE_ELEMENT_ID)?.remove();
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/realtime/runtime-opener.ts
|
|
39
|
+
/** How long before "still loading" shows. */
|
|
40
|
+
const SLOW_NOTICE_MS = 1500;
|
|
41
|
+
/** How long the failure notice stays up. */
|
|
42
|
+
const FAILURE_NOTICE_MS = 8e3;
|
|
43
|
+
/** Tell the player the social runtime failed, with the reason the menu recorded. */
|
|
44
|
+
function showRuntimeFailure() {
|
|
45
|
+
const reason = readRuntimeFailure();
|
|
46
|
+
showFallbackNotice(`Friends couldn't load${reason === "" ? "" : ` (${reason})`}. Reload the page to try again.`, FAILURE_NOTICE_MS);
|
|
47
|
+
}
|
|
48
|
+
/** Make an opener: runs a UI call on the runtime once it is up, with the loading and failure notices. */
|
|
49
|
+
function createRuntimeOpener(bridge) {
|
|
50
|
+
return (openUi) => {
|
|
51
|
+
const loaded = bridge.current();
|
|
52
|
+
if (loaded !== null) {
|
|
53
|
+
openUi(loaded);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (readRuntimeFailure() !== "") {
|
|
57
|
+
showRuntimeFailure();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const slowTimer = setTimeout(() => {
|
|
61
|
+
showFallbackNotice("Friends are still loading…");
|
|
62
|
+
}, SLOW_NOTICE_MS);
|
|
63
|
+
let isSettled = false;
|
|
64
|
+
const onFailed = () => {
|
|
65
|
+
if (!isSettled) {
|
|
66
|
+
isSettled = true;
|
|
67
|
+
clearTimeout(slowTimer);
|
|
68
|
+
showRuntimeFailure();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
if (typeof window !== "undefined") window.addEventListener(REALTIME_FAILED_EVENT, onFailed, { once: true });
|
|
72
|
+
bridge.whenReady().then((realtime) => {
|
|
73
|
+
if (isSettled) return;
|
|
74
|
+
isSettled = true;
|
|
75
|
+
clearTimeout(slowTimer);
|
|
76
|
+
hideFallbackNotice();
|
|
77
|
+
openUi(realtime);
|
|
78
|
+
}, onFailed);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { createRuntimeOpener as t };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=runtime-opener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-opener.js","names":[],"sources":["../../src/realtime/fallback-notice.ts","../../src/realtime/runtime-opener.ts"],"mappings":";;;;;;;;AAOA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AAIrB,IAAI,YAAkD;;AAGtD,SAAgB,mBAAmB,MAAc,YAAY,GAAS;CACpE,IAAI,OAAO,aAAa,aACtB;CAEF,MAAM,OAAO,SAAS;CACtB,IAAI,SAAS,MACX;CAEF,IAAI,SAAS,SAAS,eAAe,iBAAiB;CACtD,IAAI,WAAW,MAAM;EACnB,SAAS,SAAS,cAAc,KAAK;EACrC,OAAO,KAAK;EACZ,OAAO,aAAa,QAAQ,QAAQ;EACpC,OAAO,MAAM,UAAU;EACvB,KAAK,YAAY,MAAM;CACzB;CACA,OAAO,cAAc;CACrB,IAAI,cAAc,MAChB,aAAa,SAAS;CAExB,YAAY,YAAY,IAAI,WAAW,oBAAoB,SAAS,IAAI;AAC1E;;AAGA,SAAgB,qBAA2B;CACzC,IAAI,cAAc,MAAM;EACtB,aAAa,SAAS;EACtB,YAAY;CACd;CACA,IAAI,OAAO,aAAa,aACtB,SAAS,eAAe,iBAAiB,CAAC,EAAE,OAAO;AAEvD;;;;AClCA,MAAM,iBAAiB;;AAEvB,MAAM,oBAAoB;;AAG1B,SAAS,qBAA2B;CAClC,MAAM,SAAS,mBAAmB;CAClC,mBAAmB,wBAAwB,WAAW,KAAK,KAAK,KAAK,OAAO,GAAG,kCAAkC,iBAAiB;AACpI;;AAGA,SAAgB,oBAAoB,QAA2E;CAC7G,QAAQ,WAAW;EACjB,MAAM,SAAS,OAAO,QAAQ;EAC9B,IAAI,WAAW,MAAM;GACnB,OAAO,MAAM;GACb;EACF;EAEA,IAAI,mBAAmB,MAAM,IAAI;GAC/B,mBAAmB;GACnB;EACF;EACA,MAAM,YAAY,iBAAiB;GACjC,mBAAmB,4BAA4B;EACjD,GAAG,cAAc;EACjB,IAAI,YAAY;EAChB,MAAM,iBAAuB;GAC3B,IAAI,CAAC,WAAW;IACd,YAAY;IACZ,aAAa,SAAS;IACtB,mBAAmB;GACrB;EACF;EACA,IAAI,OAAO,WAAW,aACpB,OAAO,iBAAiB,uBAAuB,UAAU,EAAE,MAAM,KAAK,CAAC;EAEzE,OAAO,UAAU,CAAC,CAAC,MAAM,aAAa;GACpC,IAAI,WACF;GAEF,YAAY;GACZ,aAAa,SAAS;GACtB,mBAAmB;GACnB,OAAO,QAAQ;EACjB,GAAG,QAAQ;CACb;AACF"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import "./wire-types.js";
|
|
2
|
+
import { n as HubMpApi } from "./multiplayer-types.js";
|
|
3
|
+
import { n as HubRoomsApi } from "./room-types.js";
|
|
4
|
+
import { t as HubRaceApi } from "./race-types.js";
|
|
5
|
+
import { Audience, ChatMode, ChatMode as ChatMode$1, Conversation, Counts, ErrorBody, FriendEntry, FriendEntry as FriendEntry$1, Invite, Invite as Invite$1, JoinInfo as JoinInfo$1, Launch as Launch$1, LaunchTicket, Message, MessagesPage, NotifyChange, NotifyPrefs, Party, Party as Party$1, PlayerCard, PlayerLite, Presence, Presence as Presence$1, PresenceInput, PresenceInput as PresenceInput$1, PresenceKind, RaceOutcome, RaceParams as RaceParams$1, RaceRecord, RaceResult as RaceResult$1, RaceStatValue, RaceState, RaceStats as RaceStats$1, Racer, RacerResult, RacerState, RecentPlayer, Relation, ReportInput, ReportKind, ReportReason, RoomInfo as RoomInfo$1, SocialConfig, SocialMe, Suggestion, SuggestionStatus } from "@diffenderfer-games/hub-contract";
|
|
6
|
+
//#region src/realtime/social-types.d.ts
|
|
7
|
+
/** Online counts as a game sees them. */
|
|
8
|
+
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
|
+
/** Events `hub.social.on` delivers, name → payload. */
|
|
17
|
+
interface SocialEvents {
|
|
18
|
+
/** The friends list changed. */
|
|
19
|
+
friends: FriendEntry[];
|
|
20
|
+
/** A friend's presence changed (`null` when they went offline). */
|
|
21
|
+
presence: {
|
|
22
|
+
userId: number;
|
|
23
|
+
p: Presence | null;
|
|
24
|
+
};
|
|
25
|
+
/** The online counts changed. */
|
|
26
|
+
counts: SocialCounts;
|
|
27
|
+
/** An invite arrived. */
|
|
28
|
+
invite: Invite;
|
|
29
|
+
/** My party changed (`null` when I left it). */
|
|
30
|
+
party: Party | null;
|
|
31
|
+
}
|
|
32
|
+
/** Who to open a player card for. */
|
|
33
|
+
type PlayerRef = {
|
|
34
|
+
userId: number;
|
|
35
|
+
} | {
|
|
36
|
+
username: string;
|
|
37
|
+
};
|
|
38
|
+
/** Options for the invite picker. */
|
|
39
|
+
interface OpenInviteOptions {
|
|
40
|
+
/** Preselect this friend. */
|
|
41
|
+
userId?: number;
|
|
42
|
+
/** The game mode to invite to. */
|
|
43
|
+
mode?: string;
|
|
44
|
+
}
|
|
45
|
+
/** `hub.presence`: what you're doing, shown to friends (privacy is automatic). */
|
|
46
|
+
interface HubPresenceApi {
|
|
47
|
+
/** Report an activity, e.g. `{ kind: 'playing', detail: 'Level 3' }`. Coalesced; safe to call often. */
|
|
48
|
+
set(presence: PresenceInput): void;
|
|
49
|
+
/** Back to "in the menu". */
|
|
50
|
+
clear(): void;
|
|
51
|
+
}
|
|
52
|
+
/** `hub.social`: friends and the hub's social dialogs. */
|
|
53
|
+
interface HubSocialApi {
|
|
54
|
+
/** Open a player card (add friend, message, invite, block, report). */
|
|
55
|
+
openPlayer(ref: PlayerRef): void;
|
|
56
|
+
/** Open the hub menu on the Friends section. */
|
|
57
|
+
openFriends(): void;
|
|
58
|
+
/** Open the chat with a friend. */
|
|
59
|
+
openChat(userId: number): void;
|
|
60
|
+
/** Open the invite picker (current game by default). */
|
|
61
|
+
openInvite(options?: OpenInviteOptions): void;
|
|
62
|
+
/** Open the game-suggestion form and board. */
|
|
63
|
+
openSuggest(): void;
|
|
64
|
+
/** Open notification settings, optionally focused on a game's lobby bell. */
|
|
65
|
+
openNotify(options?: {
|
|
66
|
+
game?: string;
|
|
67
|
+
}): void;
|
|
68
|
+
/** Friends with live presence. Rejects with `OfflineError` without the runtime. */
|
|
69
|
+
friends(): Promise<FriendEntry[]>;
|
|
70
|
+
/** Live counts; all zero until the runtime is up. */
|
|
71
|
+
counts(): SocialCounts;
|
|
72
|
+
/** The effective chat mode (with these players); `'off'` until the runtime is up. */
|
|
73
|
+
chatMode(userIds?: number[]): ChatMode;
|
|
74
|
+
/** Subscribe to social events; works before the runtime loads. Returns the unsubscribe function. */
|
|
75
|
+
on<Name extends keyof SocialEvents>(event: Name, listener: (payload: SocialEvents[Name]) => void): () => void;
|
|
76
|
+
}
|
|
77
|
+
/** `hub.notify`: toast behaviour during intense play. */
|
|
78
|
+
interface HubNotifyApi {
|
|
79
|
+
/** Quiet: toasts collapse into the menu badge; invites still show as a small pill. */
|
|
80
|
+
setQuiet(isQuiet: boolean): void;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/realtime/social-forwarder.d.ts
|
|
84
|
+
/** `hub.presence`: what you're doing, shown to friends. */
|
|
85
|
+
declare const presenceForwarder: HubPresenceApi;
|
|
86
|
+
/** `hub.notify`: toast behaviour. */
|
|
87
|
+
declare const notifyForwarder: HubNotifyApi;
|
|
88
|
+
/** `hub.social`: friends and the hub's social dialogs. */
|
|
89
|
+
declare const socialForwarder: HubSocialApi;
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/realtime/hub-link.d.ts
|
|
92
|
+
/** The core client's side of the link. */
|
|
93
|
+
interface RealtimeHubLink {
|
|
94
|
+
/** Re-create an error from the runtime (another bundle) as this client's `HubError` family. */
|
|
95
|
+
toHubError(error: unknown): Error;
|
|
96
|
+
/** This client's `OfflineError` with a message. */
|
|
97
|
+
createOfflineError(message: string): Error;
|
|
98
|
+
/** A 60-second identity ticket for this game's own server (`POST /mp/ticket`), straight from the hub. */
|
|
99
|
+
getGameServerTicket(): Promise<string>;
|
|
100
|
+
}
|
|
101
|
+
/** Called once by the core client so forwarder errors use its classes and tickets use its REST client. */
|
|
102
|
+
declare function linkRealtimeToHub(link: RealtimeHubLink): void;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/realtime/runtime-api.d.ts
|
|
105
|
+
/**
|
|
106
|
+
* The realtime feature version the runtime reports in {@link RealtimeApi.version}.
|
|
107
|
+
* 2 added races; a client feature-detects newer additions with it.
|
|
108
|
+
*/
|
|
109
|
+
declare const REALTIME_FEATURE_VERSION = 2;
|
|
110
|
+
/**
|
|
111
|
+
* The cross-bundle shape number of the `rt` page singleton (plan §4.4). The
|
|
112
|
+
* runtime registers with it through `claimSingleton`; bump it only when the
|
|
113
|
+
* shape of {@link RealtimeApi} changes incompatibly.
|
|
114
|
+
*/
|
|
115
|
+
declare const REALTIME_SINGLETON_API = 1;
|
|
116
|
+
/** The window event the runtime fires once it has installed itself. */
|
|
117
|
+
declare const REALTIME_READY_EVENT = "hub:rt-ready";
|
|
118
|
+
/** The window event the menu fires when the runtime failed to load (its reason is on `window.__HUB_RT_ERROR__`). */
|
|
119
|
+
declare const REALTIME_FAILED_EVENT = "hub:rt-failed";
|
|
120
|
+
/**
|
|
121
|
+
* Installed by the social runtime as the page's `rt` singleton (and the v1
|
|
122
|
+
* alias `window.__HUB_RT__`).
|
|
123
|
+
*/
|
|
124
|
+
interface RealtimeApi {
|
|
125
|
+
/** The runtime's feature version (see {@link REALTIME_FEATURE_VERSION}). */
|
|
126
|
+
readonly version: number;
|
|
127
|
+
/** Presence reporting. */
|
|
128
|
+
presence: HubPresenceApi;
|
|
129
|
+
/** Friends and the social dialogs. */
|
|
130
|
+
social: HubSocialApi;
|
|
131
|
+
/** Invites, launches, the leave guard and tickets. */
|
|
132
|
+
mp: HubMpApi;
|
|
133
|
+
/** Hub relay rooms. */
|
|
134
|
+
rooms: HubRoomsApi;
|
|
135
|
+
/** Toast behaviour. */
|
|
136
|
+
notify: HubNotifyApi;
|
|
137
|
+
/** Races (feature version 2 and later). */
|
|
138
|
+
race?: HubRaceApi;
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/realtime/page-runtime.d.ts
|
|
142
|
+
/** Whether `candidate` looks like a {@link RealtimeApi} (any bundle's). */
|
|
143
|
+
declare function isRealtimeApi(candidate: unknown): candidate is RealtimeApi;
|
|
144
|
+
/** The page's realtime API if the runtime has loaded, else `null`. */
|
|
145
|
+
declare function findRealtimeApi(): RealtimeApi | null;
|
|
146
|
+
//#endregion
|
|
147
|
+
export { HubNotifyApi as $, RacerState as A, SuggestionStatus as B, RaceRecord as C, RaceStats$1 as D, RaceState as E, ReportReason as F, REALTIME_READY_EVENT as G, isRealtimeApi as H, RoomInfo$1 as I, RealtimeHubLink as J, REALTIME_SINGLETON_API as K, SocialConfig as L, Relation as M, ReportInput as N, Racer as O, ReportKind as P, socialForwarder as Q, SocialMe as R, RaceParams$1 as S, RaceStatValue as T, REALTIME_FAILED_EVENT as U, findRealtimeApi as V, REALTIME_FEATURE_VERSION as W, notifyForwarder as X, linkRealtimeToHub as Y, presenceForwarder as Z, PlayerLite as _, ErrorBody as a, SocialEvents as at, PresenceKind as b, JoinInfo$1 as c, Message as d, HubPresenceApi as et, MessagesPage as f, PlayerCard as g, Party$1 as h, Counts as i, SocialCounts as it, RecentPlayer as j, RacerResult as k, Launch$1 as l, NotifyPrefs as m, ChatMode$1 as n, OpenInviteOptions as nt, FriendEntry$1 as o, NotifyChange as p, RealtimeApi as q, Conversation as r, PlayerRef as rt, Invite$1 as s, Audience as t, HubSocialApi as tt, LaunchTicket as u, Presence$1 as v, RaceResult$1 as w, RaceOutcome as x, PresenceInput$1 as y, Suggestion as z };
|
|
148
|
+
//# sourceMappingURL=social.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social.d.ts","names":[],"sources":["../../src/realtime/social-types.ts","../../src/realtime/social-forwarder.ts","../../src/realtime/hub-link.ts","../../src/realtime/runtime-api.ts","../../src/realtime/page-runtime.ts"],"mappings":";;;;;;;UAOiB;;EAEf;;EAEA;;EAEA;;;UAIe;;EAEf,SAAS;;EAET;IAAY;IAAgB,GAAG;;;EAE/B,QAAQ;;EAER,QAAQ;;EAER,OAAO;;;KAIG;EAAc;;EAAqB;;;UAG9B;;EAEf;;EAEA;;;UAIe;;EAEf,IAAI,UAAU;;EAEd;;;UAIe;;EAEf,WAAW,KAAK;;EAEhB;;EAEA,SAAS;;EAET,WAAW,UAAU;;EAErB;;EAEA,WAAW;IAAY;;;EAEvB,WAAW,QAAQ;;EAEnB,UAAU;;EAEV,SAAS,qBAAqB;;EAE9B,GAAG,mBAAmB,cAAc,OAAO,MAAM,WAAW,SAAS,aAAa;;;UAInE;;EAEf,SAAS;;;;;cC5DE,mBAAmB;;cAYnB,iBAAiB;;cAQjB,iBAAiB;;;;UCzBb;;EAGf,WAAW,iBAAiB;;EAE5B,mBAAmB,kBAAkB;;EAErC,uBAAuB;;;iBAuCT,kBAAkB,MAAM;;;;;;;cC3C3B;;;;;;cAOA;;cAGA;;cAGA;;;;;UAMI;;WAEN;;EAET,UAAU;;EAEV,QAAQ;;EAER,IAAI;;EAEJ,OAAO;;EAEP,QAAQ;;EAER,OAAO;;;;;iBCnCO,cAAc,qBAAqB,aAAa;;iBAsBhD,mBAAmB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { t as pageBridge } from "./bridge.js";
|
|
2
|
+
import { t as latestState } from "./latest-state.js";
|
|
3
|
+
import { t as createRuntimeOpener } from "./runtime-opener.js";
|
|
4
|
+
//#region src/realtime/social-forwarder.ts
|
|
5
|
+
/**
|
|
6
|
+
* `hub.presence`, `hub.social` and `hub.notify`: thin forwarders to the
|
|
7
|
+
* social runtime. Presence and quiet mode are "latest state" calls,
|
|
8
|
+
* remembered and replayed when the runtime loads.
|
|
9
|
+
*/
|
|
10
|
+
const openWithRuntime = createRuntimeOpener(pageBridge);
|
|
11
|
+
/** Counts before the runtime is up. */
|
|
12
|
+
const NO_COUNTS = {
|
|
13
|
+
online: 0,
|
|
14
|
+
inGame: 0,
|
|
15
|
+
friendsOnline: 0
|
|
16
|
+
};
|
|
17
|
+
/** `hub.presence`: what you're doing, shown to friends. */
|
|
18
|
+
const presenceForwarder = {
|
|
19
|
+
set(presence) {
|
|
20
|
+
latestState.presence = { ...presence };
|
|
21
|
+
pageBridge.current()?.presence.set(latestState.presence);
|
|
22
|
+
},
|
|
23
|
+
clear() {
|
|
24
|
+
latestState.presence = { kind: "menu" };
|
|
25
|
+
pageBridge.current()?.presence.clear();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/** `hub.notify`: toast behaviour. */
|
|
29
|
+
const notifyForwarder = { setQuiet(isQuiet) {
|
|
30
|
+
latestState.isQuiet = isQuiet;
|
|
31
|
+
pageBridge.current()?.notify.setQuiet(isQuiet);
|
|
32
|
+
} };
|
|
33
|
+
/** `hub.social`: friends and the hub's social dialogs. */
|
|
34
|
+
const socialForwarder = {
|
|
35
|
+
openPlayer: (ref) => {
|
|
36
|
+
openWithRuntime((realtime) => {
|
|
37
|
+
realtime.social.openPlayer(ref);
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
openFriends: () => {
|
|
41
|
+
openWithRuntime((realtime) => {
|
|
42
|
+
realtime.social.openFriends();
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
openChat: (userId) => {
|
|
46
|
+
openWithRuntime((realtime) => {
|
|
47
|
+
realtime.social.openChat(userId);
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
openInvite: (options) => {
|
|
51
|
+
openWithRuntime((realtime) => {
|
|
52
|
+
realtime.social.openInvite(options);
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
openSuggest: () => {
|
|
56
|
+
openWithRuntime((realtime) => {
|
|
57
|
+
realtime.social.openSuggest();
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
openNotify: (options) => {
|
|
61
|
+
openWithRuntime((realtime) => {
|
|
62
|
+
realtime.social.openNotify(options);
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
friends: () => pageBridge.call((realtime) => realtime.social.friends()),
|
|
66
|
+
counts: () => pageBridge.current()?.social.counts() ?? { ...NO_COUNTS },
|
|
67
|
+
chatMode: (userIds) => pageBridge.current()?.social.chatMode(userIds) ?? "off",
|
|
68
|
+
on: (event, listener) => pageBridge.subscribe((realtime) => realtime.social.on(event, listener))
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { presenceForwarder as n, socialForwarder as r, notifyForwarder as t };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=social.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social.js","names":[],"sources":["../../src/realtime/social-forwarder.ts"],"mappings":";;;;;;;;;AAUA,MAAM,kBAAkB,oBAAoB,UAAU;;AAGtD,MAAM,YAA0B;CAAE,QAAQ;CAAG,QAAQ;CAAG,eAAe;AAAE;;AAGzE,MAAa,oBAAoC;CAC/C,IAAI,UAAU;EACZ,YAAY,WAAW,EAAE,GAAG,SAAS;EACrC,WAAW,QAAQ,CAAC,EAAE,SAAS,IAAI,YAAY,QAAQ;CACzD;CACA,QAAQ;EACN,YAAY,WAAW,EAAE,MAAM,OAAO;EACtC,WAAW,QAAQ,CAAC,EAAE,SAAS,MAAM;CACvC;AACF;;AAGA,MAAa,kBAAgC,EAC3C,SAAS,SAAS;CAChB,YAAY,UAAU;CACtB,WAAW,QAAQ,CAAC,EAAE,OAAO,SAAS,OAAO;AAC/C,EACF;;AAGA,MAAa,kBAAgC;CAC3C,aAAa,QAAQ;EACnB,iBAAiB,aAAa;GAC5B,SAAS,OAAO,WAAW,GAAG;EAChC,CAAC;CACH;CACA,mBAAmB;EACjB,iBAAiB,aAAa;GAC5B,SAAS,OAAO,YAAY;EAC9B,CAAC;CACH;CACA,WAAW,WAAW;EACpB,iBAAiB,aAAa;GAC5B,SAAS,OAAO,SAAS,MAAM;EACjC,CAAC;CACH;CACA,aAAa,YAAY;EACvB,iBAAiB,aAAa;GAC5B,SAAS,OAAO,WAAW,OAAO;EACpC,CAAC;CACH;CACA,mBAAmB;EACjB,iBAAiB,aAAa;GAC5B,SAAS,OAAO,YAAY;EAC9B,CAAC;CACH;CACA,aAAa,YAAY;EACvB,iBAAiB,aAAa;GAC5B,SAAS,OAAO,WAAW,OAAO;EACpC,CAAC;CACH;CACA,eAAe,WAAW,MAAM,aAAa,SAAS,OAAO,QAAQ,CAAC;CACtE,cAAc,WAAW,QAAQ,CAAC,EAAE,OAAO,OAAO,KAAK,EAAE,GAAG,UAAU;CACtE,WAAW,YAAY,WAAW,QAAQ,CAAC,EAAE,OAAO,SAAS,OAAO,KAAK;CACzE,KAAK,OAAO,aAAa,WAAW,WAAW,aAAa,SAAS,OAAO,GAAG,OAAO,QAAQ,CAAC;AACjG"}
|