@dreamboard-games/cli 0.1.30-alpha.0
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/README.md +50 -0
- package/dist/agent-verifier/agent-workspace-verifier.mjs +227 -0
- package/dist/agent-verifier/chunk-2E5P5NWG.mjs +835 -0
- package/dist/agent-verifier/chunk-2GBBP27W.mjs +301 -0
- package/dist/agent-verifier/chunk-2NZNKIND.mjs +166 -0
- package/dist/agent-verifier/chunk-2QMNAVV4.mjs +14522 -0
- package/dist/agent-verifier/chunk-2SZHMP6F.mjs +264 -0
- package/dist/agent-verifier/chunk-54TAYXUD.mjs +12 -0
- package/dist/agent-verifier/chunk-6A5HRJMQ.mjs +3174 -0
- package/dist/agent-verifier/chunk-6UUJEYDV.mjs +213 -0
- package/dist/agent-verifier/chunk-7653FPGJ.mjs +381 -0
- package/dist/agent-verifier/chunk-BVVNBJM4.mjs +221 -0
- package/dist/agent-verifier/chunk-CEDUHGNH.mjs +74 -0
- package/dist/agent-verifier/chunk-CEQ2VJWN.mjs +149 -0
- package/dist/agent-verifier/chunk-CFU5EWIC.mjs +69 -0
- package/dist/agent-verifier/chunk-DTMJCPS4.mjs +730 -0
- package/dist/agent-verifier/chunk-EIQWDQWJ.mjs +186 -0
- package/dist/agent-verifier/chunk-EOQIV6PS.mjs +649 -0
- package/dist/agent-verifier/chunk-HBNDKQT5.mjs +8381 -0
- package/dist/agent-verifier/chunk-HJFQDSTU.mjs +225 -0
- package/dist/agent-verifier/chunk-LI3ZR3BI.mjs +41 -0
- package/dist/agent-verifier/chunk-LM3OZLZG.mjs +48 -0
- package/dist/agent-verifier/chunk-MINCYHXN.mjs +106 -0
- package/dist/agent-verifier/chunk-MRCUP5SW.mjs +128 -0
- package/dist/agent-verifier/chunk-PM3SVG6R.mjs +38 -0
- package/dist/agent-verifier/chunk-RBDDIIPM.mjs +19 -0
- package/dist/agent-verifier/chunk-RJBLBYHX.mjs +1681 -0
- package/dist/agent-verifier/chunk-SHUMAVAP.mjs +59 -0
- package/dist/agent-verifier/chunk-SYPLYRGB.mjs +2812 -0
- package/dist/agent-verifier/chunk-U6OJN7XS.mjs +8092 -0
- package/dist/agent-verifier/chunk-VYJTHSYR.mjs +44 -0
- package/dist/agent-verifier/chunk-XYDL7GY6.mjs +10 -0
- package/dist/agent-verifier/compile-WNCQQVOF.mjs +313 -0
- package/dist/agent-verifier/global-config-WX3ZZIVU.mjs +17 -0
- package/dist/agent-verifier/keychain-backend-TNOPQV3Z.mjs +134 -0
- package/dist/agent-verifier/local-files-MTPLP62S.mjs +46 -0
- package/dist/agent-verifier/local-typecheck-QFYYAZOK.mjs +9 -0
- package/dist/agent-verifier/materialize-workspace-EWGZIVOY.mjs +90 -0
- package/dist/agent-verifier/project-state-7GR6BQTQ.mjs +32 -0
- package/dist/agent-verifier/prompt-3BAINGAQ.mjs +755 -0
- package/dist/agent-verifier/reducer-bundle-preflight-C73LEXI2.mjs +23 -0
- package/dist/agent-verifier/reducer-contract-preflight-22X7DSZW.mjs +10 -0
- package/dist/agent-verifier/reducer-native-test-harness-GMWBUISX.mjs +53 -0
- package/dist/agent-verifier/static-scaffold-4YEQME5N.mjs +28 -0
- package/dist/agent-verifier/sync-LOQAH4RC.mjs +594 -0
- package/dist/agent-verifier/test-YOJERVHN.mjs +356 -0
- package/dist/agent-verifier/testing-5K2BJYF2.mjs +674 -0
- package/dist/agent-verifier/workspace-codegen-JDZJRSDV.mjs +11 -0
- package/dist/agent-verifier/workspace-dependencies-HZ6VVS4G.mjs +14 -0
- package/dist/chunk-2H7UOFLK.js +11 -0
- package/dist/chunk-2H7UOFLK.js.map +1 -0
- package/dist/chunk-3XNJT3RK.js +39809 -0
- package/dist/chunk-3XNJT3RK.js.map +1 -0
- package/dist/chunk-7FOO4AJI.js +50 -0
- package/dist/chunk-7FOO4AJI.js.map +1 -0
- package/dist/chunk-TSJVWTJO.js +430 -0
- package/dist/chunk-TSJVWTJO.js.map +1 -0
- package/dist/dev-host/components/drawer.tsx +132 -0
- package/dist/dev-host/components/input.tsx +21 -0
- package/dist/dev-host/dev-api-proxy-plugin.ts +328 -0
- package/dist/dev-host/dev-author-dom-warnings.ts +100 -0
- package/dist/dev-host/dev-diagnostics.ts +62 -0
- package/dist/dev-host/dev-fallback-stylesheet.ts +53 -0
- package/dist/dev-host/dev-hmr-guard-plugin.ts +47 -0
- package/dist/dev-host/dev-host-controller.ts +674 -0
- package/dist/dev-host/dev-host-player-query.ts +17 -0
- package/dist/dev-host/dev-host-session-transport.ts +52 -0
- package/dist/dev-host/dev-host-storage.ts +56 -0
- package/dist/dev-host/dev-log-relay-plugin.ts +510 -0
- package/dist/dev-host/dev-runtime-config.ts +14 -0
- package/dist/dev-host/dev-runtime-platform.ts +335 -0
- package/dist/dev-host/dev-virtual-modules-plugin.ts +64 -0
- package/dist/dev-host/host-main.css +224 -0
- package/dist/dev-host/host-main.tsx +948 -0
- package/dist/dev-host/index.html +56 -0
- package/dist/dev-host/lib/utils.ts +6 -0
- package/dist/dev-host/plugin-main.ts +61 -0
- package/dist/dev-host/plugin.html +24 -0
- package/dist/dev-host/shared-styles.css +144 -0
- package/dist/dev-host/start-dev-server.ts +140 -0
- package/dist/dev-host/virtual-modules.d.ts +27 -0
- package/dist/global-config-UKSWNDTX.js +15 -0
- package/dist/global-config-UKSWNDTX.js.map +1 -0
- package/dist/index.js +8473 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +311 -0
- package/dist/internal.js +52 -0
- package/dist/internal.js.map +1 -0
- package/dist/keychain-backend-JHTXAKWC.js +135 -0
- package/dist/keychain-backend-JHTXAKWC.js.map +1 -0
- package/dist/prompt-GMZABCJC.js +756 -0
- package/dist/prompt-GMZABCJC.js.map +1 -0
- package/dist/runtime-packages/ui-host-runtime/src/actor-principal.ts +71 -0
- package/dist/runtime-packages/ui-host-runtime/src/browser-interaction.ts +139 -0
- package/dist/runtime-packages/ui-host-runtime/src/components/host-controls.tsx +374 -0
- package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback-toaster.tsx +266 -0
- package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback.tsx +212 -0
- package/dist/runtime-packages/ui-host-runtime/src/components/host-primitives.tsx +271 -0
- package/dist/runtime-packages/ui-host-runtime/src/components/host-session-metadata.tsx +135 -0
- package/dist/runtime-packages/ui-host-runtime/src/components/index.ts +5 -0
- package/dist/runtime-packages/ui-host-runtime/src/components/perf-overlay.tsx +194 -0
- package/dist/runtime-packages/ui-host-runtime/src/gameplay-authority-transport.ts +626 -0
- package/dist/runtime-packages/ui-host-runtime/src/host-controls.tsx +1 -0
- package/dist/runtime-packages/ui-host-runtime/src/host-feedback.tsx +1 -0
- package/dist/runtime-packages/ui-host-runtime/src/host-session-transport.ts +294 -0
- package/dist/runtime-packages/ui-host-runtime/src/index.ts +3 -0
- package/dist/runtime-packages/ui-host-runtime/src/logger.ts +11 -0
- package/dist/runtime-packages/ui-host-runtime/src/perf.ts +324 -0
- package/dist/runtime-packages/ui-host-runtime/src/plugin-bridge.ts +195 -0
- package/dist/runtime-packages/ui-host-runtime/src/plugin-health-check.ts +138 -0
- package/dist/runtime-packages/ui-host-runtime/src/plugin-messages.ts +159 -0
- package/dist/runtime-packages/ui-host-runtime/src/plugin-session-gateway.ts +551 -0
- package/dist/runtime-packages/ui-host-runtime/src/runtime/index.ts +13 -0
- package/dist/runtime-packages/ui-host-runtime/src/screenshot/projection-to-snapshot.ts +122 -0
- package/dist/runtime-packages/ui-host-runtime/src/screenshot/static-store-api.ts +26 -0
- package/dist/runtime-packages/ui-host-runtime/src/session-ingress-controller.ts +583 -0
- package/dist/runtime-packages/ui-host-runtime/src/session-ingress.ts +219 -0
- package/dist/runtime-packages/ui-host-runtime/src/session-live-runtime.ts +117 -0
- package/dist/runtime-packages/ui-host-runtime/src/session-model.ts +431 -0
- package/dist/runtime-packages/ui-host-runtime/src/session-projection.ts +211 -0
- package/dist/runtime-packages/ui-host-runtime/src/session-recovery.ts +80 -0
- package/dist/runtime-packages/ui-host-runtime/src/session-state-reducer.ts +1034 -0
- package/dist/runtime-packages/ui-host-runtime/src/sse-manager.ts +416 -0
- package/dist/runtime-packages/ui-host-runtime/src/unified-session-store.ts +184 -0
- package/dist/scaffold/assets/static/app/tsconfig.framework.json +26 -0
- package/dist/scaffold/assets/static/app/tsconfig.json +3 -0
- package/dist/scaffold/assets/static/ui/index.tsx +13 -0
- package/dist/scaffold/assets/static/ui/style.css +4 -0
- package/dist/scaffold/assets/static/ui/tsconfig.framework.json +19 -0
- package/dist/scaffold/assets/static/ui/tsconfig.json +5 -0
- package/dist/testing-KLSV6CPJ.js +674 -0
- package/dist/testing-KLSV6CPJ.js.map +1 -0
- package/package.json +72 -0
- package/skills/dreamboard/SKILL.md +130 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HostSessionEvent,
|
|
3
|
+
HostSessionSnapshot,
|
|
4
|
+
} from "@dreamboard-games/api-client";
|
|
5
|
+
import type {
|
|
6
|
+
GameplayPerspective,
|
|
7
|
+
GameplayViewport,
|
|
8
|
+
SessionContext,
|
|
9
|
+
} from "./session-model.js";
|
|
10
|
+
import {
|
|
11
|
+
contextFromHostEventContext,
|
|
12
|
+
contextFromHostSnapshot,
|
|
13
|
+
gameplayViewportFromSnapshot,
|
|
14
|
+
} from "./session-model.js";
|
|
15
|
+
|
|
16
|
+
type WireSessionIngressSnapshot = HostSessionSnapshot;
|
|
17
|
+
type WireSessionIngressEvent = HostSessionEvent;
|
|
18
|
+
interface WireSessionIngressActionSubmitResponse {
|
|
19
|
+
success: boolean;
|
|
20
|
+
version: number;
|
|
21
|
+
actionSetVersion: string;
|
|
22
|
+
accepted?: boolean | null;
|
|
23
|
+
durabilityStatus?: "COMMITTED" | null;
|
|
24
|
+
update?: WireSessionIngressEvent | null;
|
|
25
|
+
errorCode?: string | null;
|
|
26
|
+
message?: string | null;
|
|
27
|
+
clientActionId?: string | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type HostSessionWireSnapshot = WireSessionIngressSnapshot;
|
|
31
|
+
export type HostSessionWireEvent = WireSessionIngressEvent;
|
|
32
|
+
export type HostActionSubmitWireResponse =
|
|
33
|
+
WireSessionIngressActionSubmitResponse;
|
|
34
|
+
|
|
35
|
+
export type NormalizedSessionSnapshot =
|
|
36
|
+
| {
|
|
37
|
+
type: "lobby";
|
|
38
|
+
context: SessionContext;
|
|
39
|
+
gameplay: null;
|
|
40
|
+
preferredPlayerId: string | null;
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
type: "gameplay";
|
|
44
|
+
context: SessionContext;
|
|
45
|
+
perspective: GameplayPerspective;
|
|
46
|
+
gameplay: GameplayViewport;
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
type: "ended";
|
|
50
|
+
context: SessionContext;
|
|
51
|
+
gameplay: null;
|
|
52
|
+
preferredPlayerId: string | null;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export type NormalizedSessionEvent =
|
|
56
|
+
| {
|
|
57
|
+
type: "session.snapshot";
|
|
58
|
+
snapshot: NormalizedSessionSnapshot;
|
|
59
|
+
context: SessionContext;
|
|
60
|
+
gameplay: GameplayViewport | null;
|
|
61
|
+
}
|
|
62
|
+
| {
|
|
63
|
+
type: "session.lobbyUpdated";
|
|
64
|
+
context: SessionContext | null;
|
|
65
|
+
gameplay: GameplayViewport | null;
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
type: "session.gameplayUpdated";
|
|
69
|
+
context: SessionContext | null;
|
|
70
|
+
gameplay: GameplayViewport;
|
|
71
|
+
perspective: GameplayPerspective;
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
type: "session.historyUpdated";
|
|
75
|
+
context: SessionContext | null;
|
|
76
|
+
gameplay: GameplayViewport | null;
|
|
77
|
+
}
|
|
78
|
+
| {
|
|
79
|
+
type: "session.ended";
|
|
80
|
+
context: SessionContext | null;
|
|
81
|
+
gameplay: GameplayViewport | null;
|
|
82
|
+
}
|
|
83
|
+
| {
|
|
84
|
+
type: "session.error";
|
|
85
|
+
message: string;
|
|
86
|
+
code?: string;
|
|
87
|
+
context: SessionContext | null;
|
|
88
|
+
gameplay: GameplayViewport | null;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type NormalizedSubmitResponse = NormalizedSessionEvent | null;
|
|
92
|
+
|
|
93
|
+
export function normalizeSnapshot(
|
|
94
|
+
snapshot: HostSessionWireSnapshot,
|
|
95
|
+
options: {
|
|
96
|
+
userId: string | null;
|
|
97
|
+
previousGameplay?: GameplayViewport | null;
|
|
98
|
+
},
|
|
99
|
+
): NormalizedSessionSnapshot {
|
|
100
|
+
const context = contextFromHostSnapshot(snapshot, options.userId);
|
|
101
|
+
if (snapshot.type !== "gameplay") {
|
|
102
|
+
return {
|
|
103
|
+
type: snapshot.type,
|
|
104
|
+
context,
|
|
105
|
+
gameplay: null,
|
|
106
|
+
preferredPlayerId: null,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
type: "gameplay",
|
|
111
|
+
context,
|
|
112
|
+
perspective: { playerId: snapshot.gameplay.perspectivePlayerId },
|
|
113
|
+
gameplay: gameplayViewportFromSnapshot(
|
|
114
|
+
snapshot.gameplay,
|
|
115
|
+
options.previousGameplay,
|
|
116
|
+
),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function normalizeEvent(
|
|
121
|
+
event: HostSessionWireEvent,
|
|
122
|
+
options: {
|
|
123
|
+
currentContext: SessionContext | null;
|
|
124
|
+
currentGameplay: GameplayViewport | null;
|
|
125
|
+
userId: string | null;
|
|
126
|
+
},
|
|
127
|
+
): NormalizedSessionEvent {
|
|
128
|
+
const context = options.currentContext;
|
|
129
|
+
switch (event.type) {
|
|
130
|
+
case "session.snapshot": {
|
|
131
|
+
const normalized = normalizeSnapshot(event.snapshot, {
|
|
132
|
+
userId: options.userId,
|
|
133
|
+
previousGameplay: options.currentGameplay,
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
type: "session.snapshot",
|
|
137
|
+
snapshot: normalized,
|
|
138
|
+
context: normalized.context,
|
|
139
|
+
gameplay: normalized.gameplay,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
case "session.lobbyUpdated":
|
|
143
|
+
return {
|
|
144
|
+
type: "session.lobbyUpdated",
|
|
145
|
+
context: context
|
|
146
|
+
? contextFromHostEventContext(
|
|
147
|
+
{ ...context, userId: options.userId },
|
|
148
|
+
event.context,
|
|
149
|
+
event.lobby,
|
|
150
|
+
)
|
|
151
|
+
: null,
|
|
152
|
+
gameplay: options.currentGameplay,
|
|
153
|
+
};
|
|
154
|
+
case "session.gameplayUpdated":
|
|
155
|
+
return {
|
|
156
|
+
type: "session.gameplayUpdated",
|
|
157
|
+
context: context
|
|
158
|
+
? contextFromHostEventContext(
|
|
159
|
+
{ ...context, userId: options.userId },
|
|
160
|
+
event.context,
|
|
161
|
+
)
|
|
162
|
+
: null,
|
|
163
|
+
gameplay: gameplayViewportFromSnapshot(
|
|
164
|
+
event.gameplay,
|
|
165
|
+
options.currentGameplay,
|
|
166
|
+
),
|
|
167
|
+
perspective: { playerId: event.gameplay.perspectivePlayerId },
|
|
168
|
+
};
|
|
169
|
+
case "session.historyUpdated":
|
|
170
|
+
return {
|
|
171
|
+
type: "session.historyUpdated",
|
|
172
|
+
context: context
|
|
173
|
+
? contextFromHostEventContext(
|
|
174
|
+
{ ...context, userId: options.userId },
|
|
175
|
+
event.context,
|
|
176
|
+
)
|
|
177
|
+
: null,
|
|
178
|
+
gameplay: options.currentGameplay,
|
|
179
|
+
};
|
|
180
|
+
case "session.ended":
|
|
181
|
+
return {
|
|
182
|
+
type: "session.ended",
|
|
183
|
+
context: context
|
|
184
|
+
? contextFromHostEventContext(
|
|
185
|
+
{ ...context, userId: options.userId },
|
|
186
|
+
event.context,
|
|
187
|
+
event.lobby,
|
|
188
|
+
)
|
|
189
|
+
: null,
|
|
190
|
+
gameplay: options.currentGameplay,
|
|
191
|
+
};
|
|
192
|
+
case "session.error":
|
|
193
|
+
return {
|
|
194
|
+
type: "session.error",
|
|
195
|
+
message: event.message,
|
|
196
|
+
code: event.code,
|
|
197
|
+
context,
|
|
198
|
+
gameplay: options.currentGameplay,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function normalizeSubmitResponse(
|
|
204
|
+
response: HostActionSubmitWireResponse,
|
|
205
|
+
options: {
|
|
206
|
+
currentContext: SessionContext | null;
|
|
207
|
+
currentGameplay: GameplayViewport | null;
|
|
208
|
+
userId: string | null;
|
|
209
|
+
},
|
|
210
|
+
): NormalizedSubmitResponse {
|
|
211
|
+
if (!response.accepted || !response.update) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
return normalizeEvent(response.update, {
|
|
215
|
+
currentContext: options.currentContext,
|
|
216
|
+
currentGameplay: options.currentGameplay,
|
|
217
|
+
userId: options.userId,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { HostSessionWireEvent } from "./session-ingress.js";
|
|
2
|
+
import type { SSEManager, SSERecoveryEvent } from "./sse-manager.js";
|
|
3
|
+
|
|
4
|
+
export interface SSEManagerLike {
|
|
5
|
+
connect: (
|
|
6
|
+
sessionId: string,
|
|
7
|
+
options: {
|
|
8
|
+
source?: string;
|
|
9
|
+
playerId?: string;
|
|
10
|
+
},
|
|
11
|
+
) => Promise<void> | void;
|
|
12
|
+
disconnect: () => void;
|
|
13
|
+
on: SSEManager["on"];
|
|
14
|
+
onAnyMessage: SSEManager["onAnyMessage"];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SessionLiveRuntime {
|
|
18
|
+
connectSession: (
|
|
19
|
+
sessionId: string,
|
|
20
|
+
options: { source?: string; playerId?: string },
|
|
21
|
+
) => void;
|
|
22
|
+
reconnectGameplay: (
|
|
23
|
+
sessionId: string,
|
|
24
|
+
playerId: string,
|
|
25
|
+
source: string,
|
|
26
|
+
) => void;
|
|
27
|
+
requestGameplayResync: (
|
|
28
|
+
sessionId: string,
|
|
29
|
+
playerId: string,
|
|
30
|
+
source: string,
|
|
31
|
+
) => void;
|
|
32
|
+
closeStreams: () => void;
|
|
33
|
+
getConnectedSessionId: () => string | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function createSessionLiveRuntime(options: {
|
|
37
|
+
createSseManager: () => SSEManagerLike;
|
|
38
|
+
onConnectionChange: (
|
|
39
|
+
channel: "lobby" | "gameplay",
|
|
40
|
+
connected: boolean,
|
|
41
|
+
) => void;
|
|
42
|
+
onConnectionError: (error: unknown) => void;
|
|
43
|
+
onConnectionRecovering: (details: SSERecoveryEvent) => void;
|
|
44
|
+
onLiveMessage: (message: HostSessionWireEvent) => void;
|
|
45
|
+
}): SessionLiveRuntime {
|
|
46
|
+
let connectedSessionId: string | null = null;
|
|
47
|
+
let sessionManager: SSEManagerLike | null = null;
|
|
48
|
+
let unsubscribeSession: (() => void) | null = null;
|
|
49
|
+
|
|
50
|
+
const attachConnectionHandlers = (
|
|
51
|
+
manager: SSEManagerLike,
|
|
52
|
+
channel: "lobby" | "gameplay",
|
|
53
|
+
) => {
|
|
54
|
+
manager.on("connected", () => options.onConnectionChange(channel, true));
|
|
55
|
+
manager.on("disconnected", () =>
|
|
56
|
+
options.onConnectionChange(channel, false),
|
|
57
|
+
);
|
|
58
|
+
manager.on("error", (error) => {
|
|
59
|
+
options.onConnectionChange(channel, false);
|
|
60
|
+
options.onConnectionError(error);
|
|
61
|
+
});
|
|
62
|
+
manager.on("recovering", (details) => {
|
|
63
|
+
options.onConnectionChange(channel, false);
|
|
64
|
+
options.onConnectionRecovering(details);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const closeStreams = () => {
|
|
69
|
+
unsubscribeSession?.();
|
|
70
|
+
unsubscribeSession = null;
|
|
71
|
+
sessionManager?.disconnect();
|
|
72
|
+
sessionManager = null;
|
|
73
|
+
connectedSessionId = null;
|
|
74
|
+
options.onConnectionChange("lobby", false);
|
|
75
|
+
options.onConnectionChange("gameplay", false);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const openSession = (
|
|
79
|
+
sessionId: string,
|
|
80
|
+
playerId: string | undefined,
|
|
81
|
+
source: string,
|
|
82
|
+
) => {
|
|
83
|
+
closeStreams();
|
|
84
|
+
connectedSessionId = sessionId;
|
|
85
|
+
sessionManager = options.createSseManager();
|
|
86
|
+
attachConnectionHandlers(sessionManager, playerId ? "gameplay" : "lobby");
|
|
87
|
+
unsubscribeSession = sessionManager.onAnyMessage(options.onLiveMessage);
|
|
88
|
+
void sessionManager.connect(sessionId, {
|
|
89
|
+
source,
|
|
90
|
+
playerId,
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
connectSession: (sessionId, connectOptions) => {
|
|
96
|
+
openSession(
|
|
97
|
+
sessionId,
|
|
98
|
+
connectOptions.playerId,
|
|
99
|
+
connectOptions.source ?? "connect-session",
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
reconnectGameplay: (sessionId, playerId, source) => {
|
|
103
|
+
openSession(sessionId, playerId, source);
|
|
104
|
+
},
|
|
105
|
+
requestGameplayResync: (sessionId, playerId, source) => {
|
|
106
|
+
if (!sessionManager) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
void sessionManager.connect(sessionId, {
|
|
110
|
+
source,
|
|
111
|
+
playerId,
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
closeStreams,
|
|
115
|
+
getConnectedSessionId: () => connectedSessionId,
|
|
116
|
+
};
|
|
117
|
+
}
|