@air-jam/sdk 0.9.1 → 0.9.3
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 +25 -45
- package/dist/{agent-tooling-BSMGBix9.d.cts → agent-contract-CD2QnbBJ.d.cts} +1 -1
- package/dist/{agent-tooling-BSMGBix9.d.ts → agent-contract-CD2QnbBJ.d.ts} +1 -1
- package/dist/agent-tooling.cjs +139 -0
- package/dist/agent-tooling.cjs.map +1 -1
- package/dist/agent-tooling.d.cts +25 -1
- package/dist/agent-tooling.d.ts +25 -1
- package/dist/agent-tooling.js +138 -0
- package/dist/agent-tooling.js.map +1 -1
- package/dist/air-jam-context-BlLPvCup.d.cts +175 -0
- package/dist/air-jam-context-DTsxF-tP.d.ts +175 -0
- package/dist/arcade/bridge/controller.cjs +214 -194
- package/dist/arcade/bridge/controller.cjs.map +1 -1
- package/dist/arcade/bridge/controller.d.cts +2 -2
- package/dist/arcade/bridge/controller.d.ts +2 -2
- package/dist/arcade/bridge/controller.js +6 -4
- package/dist/arcade/bridge/host.cjs +1 -1
- package/dist/arcade/bridge/host.cjs.map +1 -1
- package/dist/arcade/bridge/host.d.cts +3 -3
- package/dist/arcade/bridge/host.d.ts +3 -3
- package/dist/arcade/bridge/host.js +4 -3
- package/dist/arcade/bridge/iframe.cjs +1 -1
- package/dist/arcade/bridge/iframe.cjs.map +1 -1
- package/dist/arcade/bridge/iframe.d.cts +2 -2
- package/dist/arcade/bridge/iframe.d.ts +2 -2
- package/dist/arcade/bridge/iframe.js +4 -4
- package/dist/arcade/bridge.cjs +251 -231
- package/dist/arcade/bridge.cjs.map +1 -1
- package/dist/arcade/bridge.d.cts +4 -4
- package/dist/arcade/bridge.d.ts +4 -4
- package/dist/arcade/bridge.js +9 -7
- package/dist/arcade/host.cjs +145 -122
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.d.cts +5 -4
- package/dist/arcade/host.d.ts +5 -4
- package/dist/arcade/host.js +6 -5
- package/dist/arcade/runtime.cjs +6499 -0
- package/dist/arcade/runtime.cjs.map +1 -0
- package/dist/arcade/runtime.d.cts +22 -0
- package/dist/arcade/runtime.d.ts +22 -0
- package/dist/arcade/runtime.js +32 -0
- package/dist/arcade/runtime.js.map +1 -0
- package/dist/arcade/surface.cjs +9 -0
- package/dist/arcade/surface.cjs.map +1 -1
- package/dist/arcade/surface.d.cts +6 -1
- package/dist/arcade/surface.d.ts +6 -1
- package/dist/arcade/surface.js +6 -2
- package/dist/arcade/url.d.cts +4 -4
- package/dist/arcade/url.d.ts +4 -4
- package/dist/arcade/url.js +5 -5
- package/dist/arcade.cjs +322 -292
- package/dist/arcade.cjs.map +1 -1
- package/dist/arcade.d.cts +6 -6
- package/dist/arcade.d.ts +6 -6
- package/dist/arcade.js +35 -29
- package/dist/{chunk-CEJ5RFSG.js → chunk-2SZ2YYGJ.js} +8 -16
- package/dist/chunk-2SZ2YYGJ.js.map +1 -0
- package/dist/{chunk-VKBMZHMQ.js → chunk-32RSSFSF.js} +10 -12
- package/dist/chunk-32RSSFSF.js.map +1 -0
- package/dist/chunk-3YMUAKPU.js +10 -0
- package/dist/chunk-3YMUAKPU.js.map +1 -0
- package/dist/chunk-56DM2KEW.js +14 -0
- package/dist/chunk-56DM2KEW.js.map +1 -0
- package/dist/chunk-CM53YLT5.js +59 -0
- package/dist/chunk-CM53YLT5.js.map +1 -0
- package/dist/{chunk-JEHV5C2X.js → chunk-CV3PBXPT.js} +3 -3
- package/dist/chunk-D4VDEVTZ.js +80 -0
- package/dist/chunk-D4VDEVTZ.js.map +1 -0
- package/dist/{chunk-W3YA5BWR.js → chunk-FUA6EMSJ.js} +24 -60
- package/dist/chunk-FUA6EMSJ.js.map +1 -0
- package/dist/chunk-GMLU7RI5.js +70 -0
- package/dist/chunk-GMLU7RI5.js.map +1 -0
- package/dist/{chunk-NCL6WJCL.js → chunk-IG6GZZSS.js} +32 -1
- package/dist/chunk-IG6GZZSS.js.map +1 -0
- package/dist/{chunk-EDRQIOCV.js → chunk-ITMQSBTH.js} +3 -2
- package/dist/chunk-ITMQSBTH.js.map +1 -0
- package/dist/{chunk-32NYL7XI.js → chunk-J5MCII33.js} +189 -108
- package/dist/chunk-J5MCII33.js.map +1 -0
- package/dist/{chunk-ZLPL2R3R.js → chunk-K4OZ54UD.js} +7 -34
- package/dist/chunk-K4OZ54UD.js.map +1 -0
- package/dist/{chunk-KXAFI5OP.js → chunk-LIHEEAVE.js} +9 -11
- package/dist/chunk-LIHEEAVE.js.map +1 -0
- package/dist/{chunk-FAT2KJ3K.js → chunk-MIMPMB7O.js} +2 -2
- package/dist/{chunk-NUJBMV3O.js → chunk-O6X7FJ6N.js} +29 -32
- package/dist/chunk-O6X7FJ6N.js.map +1 -0
- package/dist/chunk-PSUYTD2L.js +16 -0
- package/dist/chunk-PSUYTD2L.js.map +1 -0
- package/dist/{chunk-7UXSWCZZ.js → chunk-QO4KFUEI.js} +2 -2
- package/dist/chunk-QTLYZADF.js +125 -0
- package/dist/chunk-QTLYZADF.js.map +1 -0
- package/dist/chunk-TTQDHKXL.js +3017 -0
- package/dist/chunk-TTQDHKXL.js.map +1 -0
- package/dist/chunk-UCPY7UJC.js +8 -0
- package/dist/chunk-UCPY7UJC.js.map +1 -0
- package/dist/{chunk-JO2HR5PV.js → chunk-UPV6YWT5.js} +4 -4
- package/dist/chunk-X35LLCWV.js +65 -0
- package/dist/chunk-X35LLCWV.js.map +1 -0
- package/dist/{controller-DxVchfiA.d.ts → controller-PZEM_1cH.d.ts} +6 -2
- package/dist/{controller-Bod8YYr1.d.cts → controller-vj82tKm4.d.cts} +6 -2
- package/dist/{dev-log-events-CVAM29hx.d.cts → dev-log-events-BCJKmygo.d.cts} +0 -3
- package/dist/{dev-log-events-CVAM29hx.d.ts → dev-log-events-BCJKmygo.d.ts} +0 -3
- package/dist/{host-8hmq_Sgc.d.cts → host-B9pRy0Aa.d.cts} +20 -7
- package/dist/{host-Cw-N6e-5.d.ts → host-DylGsX7p.d.ts} +20 -7
- package/dist/index.cjs +4275 -3813
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +40 -642
- package/dist/index.d.ts +40 -642
- package/dist/index.js +1032 -3658
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +2 -3
- package/dist/metadata.d.ts +2 -3
- package/dist/metadata.js.map +1 -1
- package/dist/{notices-CnGaaS8B.d.ts → notices-C4bao3oi.d.ts} +1 -1
- package/dist/{notices-NyDM5Mtz.d.cts → notices-DNdOjwtj.d.cts} +1 -1
- package/dist/platform-machine.cjs +115 -15
- package/dist/platform-machine.cjs.map +1 -1
- package/dist/platform-machine.d.cts +1338 -65
- package/dist/platform-machine.d.ts +1338 -65
- package/dist/platform-machine.js +88 -15
- package/dist/platform-machine.js.map +1 -1
- package/dist/{platform-settings-cuor3i11.d.cts → platform-settings-DUWs4JTy.d.cts} +1 -1
- package/dist/{platform-settings-cuor3i11.d.ts → platform-settings-DUWs4JTy.d.ts} +1 -1
- package/dist/preview.cjs +301 -253
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +6 -4
- package/dist/preview.d.ts +6 -4
- package/dist/preview.js +31 -21
- package/dist/preview.js.map +1 -1
- package/dist/protocol.cjs +282 -167
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +74 -21
- package/dist/protocol.d.ts +74 -21
- package/dist/protocol.js +28 -10
- package/dist/release.cjs +37 -0
- package/dist/release.cjs.map +1 -1
- package/dist/release.d.cts +27 -1
- package/dist/release.d.ts +27 -1
- package/dist/release.js +13 -1
- package/dist/runtime-control.cjs +46 -0
- package/dist/runtime-control.cjs.map +1 -0
- package/dist/runtime-control.d.cts +17 -0
- package/dist/runtime-control.d.ts +17 -0
- package/dist/runtime-control.js +8 -0
- package/dist/runtime-control.js.map +1 -0
- package/dist/runtime-inspection.cjs +655 -0
- package/dist/runtime-inspection.cjs.map +1 -0
- package/dist/runtime-inspection.d.cts +47 -0
- package/dist/runtime-inspection.d.ts +47 -0
- package/dist/runtime-inspection.js +30 -0
- package/dist/runtime-inspection.js.map +1 -0
- package/dist/runtime-reporting-pe-eryVz.d.cts +27 -0
- package/dist/runtime-reporting-pe-eryVz.d.ts +27 -0
- package/dist/signals-ZHftIKuc.d.cts +33 -0
- package/dist/signals-ZHftIKuc.d.ts +33 -0
- package/dist/{standard-match-phase-BucA5dYo.d.ts → standard-match-phase-BzSgBYFg.d.ts} +2 -2
- package/dist/{standard-match-phase-U2ra8J-0.d.cts → standard-match-phase-CvJUW8Oe.d.cts} +2 -2
- package/dist/{sync-B6QsNrXz.d.cts → sync-xtPfWhif.d.cts} +1 -45
- package/dist/{sync-B6QsNrXz.d.ts → sync-xtPfWhif.d.ts} +1 -45
- package/dist/ui.cjs +689 -629
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.cts +14 -4
- package/dist/ui.d.ts +14 -4
- package/dist/ui.js +117 -35
- package/dist/ui.js.map +1 -1
- package/dist/use-air-jam-host-COLy8t4s.d.ts +403 -0
- package/dist/use-air-jam-host-DM-ybB3C.d.cts +403 -0
- package/package.json +55 -21
- package/src/agent/agent-contract-conformance.ts +201 -0
- package/src/agent-tooling.ts +5 -0
- package/src/arcade/runtime.ts +6 -0
- package/src/arcade/surface.ts +1 -0
- package/src/components/join-qr-overlay.tsx +115 -31
- package/src/context/air-jam-context.tsx +8 -8
- package/src/context/socket-manager.ts +0 -7
- package/src/dev/browser-log-sink.ts +12 -15
- package/src/events.ts +0 -5
- package/src/hooks/internal/use-controller-runtime-api.ts +110 -21
- package/src/hooks/internal/use-host-runtime-api.ts +306 -49
- package/src/hooks/use-air-jam-controller.ts +9 -9
- package/src/hooks/use-air-jam-host.ts +7 -7
- package/src/hooks/use-get-input.ts +1 -1
- package/src/hooks/use-host-arcade-restore.ts +6 -1
- package/src/hooks/use-host-audio-mute-preference.ts +99 -0
- package/src/index.ts +6 -21
- package/src/metadata/manifest.ts +2 -3
- package/src/platform-machine.ts +109 -12
- package/src/preview/workspace.tsx +48 -29
- package/src/protocol/arcade-platform-actions.ts +19 -1
- package/src/protocol/controller.ts +8 -2
- package/src/protocol/dev-log-events.ts +0 -3
- package/src/protocol/host-grant.ts +58 -140
- package/src/protocol/host.ts +21 -9
- package/src/protocol/runtime-reporting.ts +32 -0
- package/src/protocol/signed-envelope.ts +176 -0
- package/src/protocol/socket-events.ts +8 -10
- package/src/protocol/sync.ts +0 -16
- package/src/protocol.ts +2 -0
- package/src/release.ts +32 -0
- package/src/runtime/admission-retry.ts +62 -0
- package/src/runtime/air-jam-config.ts +6 -16
- package/src/runtime/air-jam-error-boundary.tsx +46 -2
- package/src/runtime/bridge-envelope-args.ts +21 -0
- package/src/runtime/connected-runtime-error-boundary.tsx +31 -0
- package/src/runtime/contracts/control.ts +107 -59
- package/src/runtime/controller-bridge.ts +12 -24
- package/src/runtime/controller-identity.ts +55 -27
- package/src/runtime/controller-realtime-client.ts +8 -47
- package/src/runtime/create-air-jam-app.tsx +21 -13
- package/src/runtime/host-bridge.ts +16 -24
- package/src/runtime/local-reference-game-identity.ts +13 -0
- package/src/runtime/runtime-session-params.ts +4 -64
- package/src/runtime-control.ts +3 -8
- package/src/settings/platform-settings-runtime.tsx +1 -6
- package/src/settings/platform-settings.ts +7 -38
- package/src/state/connection-store.ts +13 -6
- package/src/store/create-air-jam-store.ts +59 -7
- package/src/utils/ids.ts +32 -5
- package/dist/capabilities.cjs +0 -39
- package/dist/capabilities.cjs.map +0 -1
- package/dist/capabilities.d.cts +0 -31
- package/dist/capabilities.d.ts +0 -31
- package/dist/capabilities.js +0 -12
- package/dist/capabilities.js.map +0 -1
- package/dist/chunk-32NYL7XI.js.map +0 -1
- package/dist/chunk-CABEUV65.js +0 -184
- package/dist/chunk-CABEUV65.js.map +0 -1
- package/dist/chunk-CEJ5RFSG.js.map +0 -1
- package/dist/chunk-EDRQIOCV.js.map +0 -1
- package/dist/chunk-KXAFI5OP.js.map +0 -1
- package/dist/chunk-NCL6WJCL.js.map +0 -1
- package/dist/chunk-NUJBMV3O.js.map +0 -1
- package/dist/chunk-VKBMZHMQ.js.map +0 -1
- package/dist/chunk-W3YA5BWR.js.map +0 -1
- package/dist/chunk-ZLPL2R3R.js.map +0 -1
- package/dist/chunk-ZTQ5SP4H.js +0 -9
- package/dist/chunk-ZTQ5SP4H.js.map +0 -1
- package/src/capabilities/manifest.ts +0 -71
- package/src/capabilities.ts +0 -12
- package/src/hooks/internal/use-runtime-control-contract.ts +0 -15
- package/src/hooks/internal/use-runtime-observability-contract.ts +0 -24
- package/src/runtime/contracts/observability.ts +0 -94
- package/src/runtime-observability.ts +0 -9
- /package/dist/{chunk-JEHV5C2X.js.map → chunk-CV3PBXPT.js.map} +0 -0
- /package/dist/{chunk-FAT2KJ3K.js.map → chunk-MIMPMB7O.js.map} +0 -0
- /package/dist/{chunk-7UXSWCZZ.js.map → chunk-QO4KFUEI.js.map} +0 -0
- /package/dist/{chunk-JO2HR5PV.js.map → chunk-UPV6YWT5.js.map} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ErrorCode } from "../protocol/errors";
|
|
2
|
+
|
|
3
|
+
const MAX_ADMISSION_RETRIES = 3;
|
|
4
|
+
// Production lane controls intentionally support multi-minute pauses. Keep the
|
|
5
|
+
// automatic wait bounded, but do not turn an ordinary 60-300 second operator
|
|
6
|
+
// retry window into a reload-only state.
|
|
7
|
+
const MAX_RETRY_AFTER_SECONDS = 5 * 60;
|
|
8
|
+
const MIN_ADMISSION_RETRY_DELAY_MS = 250;
|
|
9
|
+
const MAX_RETRY_JITTER_MS = 1_000;
|
|
10
|
+
const RETRY_JITTER_RATIO = 0.2;
|
|
11
|
+
|
|
12
|
+
interface AdmissionDenial {
|
|
13
|
+
code?: ErrorCode | string;
|
|
14
|
+
retryAfterSeconds?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AdmissionRetryDecision {
|
|
18
|
+
code: ErrorCode.SERVICE_UNAVAILABLE;
|
|
19
|
+
retryAfterSeconds: number;
|
|
20
|
+
delayMs: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Converts an explicit admission denial into one bounded client retry.
|
|
25
|
+
* The server's delay is a floor; positive jitter spreads reconnecting clients
|
|
26
|
+
* without retrying earlier than the authoritative retry-after value.
|
|
27
|
+
*/
|
|
28
|
+
export const resolveAdmissionRetry = (
|
|
29
|
+
denial: AdmissionDenial,
|
|
30
|
+
completedRetries: number,
|
|
31
|
+
random: () => number = Math.random,
|
|
32
|
+
): AdmissionRetryDecision | null => {
|
|
33
|
+
if (
|
|
34
|
+
denial.code !== ErrorCode.SERVICE_UNAVAILABLE ||
|
|
35
|
+
completedRetries >= MAX_ADMISSION_RETRIES ||
|
|
36
|
+
denial.retryAfterSeconds === undefined ||
|
|
37
|
+
!Number.isFinite(denial.retryAfterSeconds) ||
|
|
38
|
+
denial.retryAfterSeconds <= 0 ||
|
|
39
|
+
denial.retryAfterSeconds > MAX_RETRY_AFTER_SECONDS
|
|
40
|
+
) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const retryAfterMs = Math.max(
|
|
45
|
+
Math.ceil(denial.retryAfterSeconds * 1_000),
|
|
46
|
+
MIN_ADMISSION_RETRY_DELAY_MS,
|
|
47
|
+
);
|
|
48
|
+
const jitterWindowMs = Math.min(
|
|
49
|
+
Math.ceil(retryAfterMs * RETRY_JITTER_RATIO),
|
|
50
|
+
MAX_RETRY_JITTER_MS,
|
|
51
|
+
);
|
|
52
|
+
const randomSample = random();
|
|
53
|
+
const boundedRandom = Number.isFinite(randomSample)
|
|
54
|
+
? Math.max(0, Math.min(1, randomSample))
|
|
55
|
+
: 0.5;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
code: ErrorCode.SERVICE_UNAVAILABLE,
|
|
59
|
+
retryAfterSeconds: denial.retryAfterSeconds,
|
|
60
|
+
delayMs: retryAfterMs + Math.floor(jitterWindowMs * boundedRandom),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { DEFAULT_MAX_PLAYERS } from "../constants";
|
|
2
|
+
import {
|
|
3
|
+
createAirJamDiagnosticError,
|
|
4
|
+
emitAirJamDiagnostic,
|
|
5
|
+
} from "../diagnostics";
|
|
6
|
+
import type { HostSessionKind } from "../protocol/host";
|
|
1
7
|
import {
|
|
2
8
|
parseRuntimeTopologyFromSearchParams,
|
|
3
9
|
readRuntimeTopologyFromEnv,
|
|
@@ -9,12 +15,6 @@ import {
|
|
|
9
15
|
type RuntimeTopologyInput,
|
|
10
16
|
type SurfaceRole,
|
|
11
17
|
} from "../runtime-topology";
|
|
12
|
-
import { DEFAULT_MAX_PLAYERS } from "../constants";
|
|
13
|
-
import {
|
|
14
|
-
createAirJamDiagnosticError,
|
|
15
|
-
emitAirJamDiagnostic,
|
|
16
|
-
} from "../diagnostics";
|
|
17
|
-
import type { HostSessionKind } from "../protocol/host";
|
|
18
18
|
|
|
19
19
|
export interface AirJamConfig {
|
|
20
20
|
topology: ResolvedAirJamRuntimeTopology;
|
|
@@ -22,14 +22,6 @@ export interface AirJamConfig {
|
|
|
22
22
|
hostGrantEndpoint?: string;
|
|
23
23
|
maxPlayers: number;
|
|
24
24
|
hostSessionKind: HostSessionKind;
|
|
25
|
-
/**
|
|
26
|
-
* Deprecated compatibility alias. Prefer `topology.backendOrigin`.
|
|
27
|
-
*/
|
|
28
|
-
serverUrl: string;
|
|
29
|
-
/**
|
|
30
|
-
* Deprecated compatibility alias. Prefer `topology.publicHost`.
|
|
31
|
-
*/
|
|
32
|
-
publicHost: string;
|
|
33
25
|
backendOrigin: string;
|
|
34
26
|
socketOrigin: string;
|
|
35
27
|
appOrigin: string;
|
|
@@ -277,8 +269,6 @@ export const resolveAirJamConfig = ({
|
|
|
277
269
|
hostGrantEndpoint: hostGrantEndpoint ?? getEnvHostGrantEndpoint(),
|
|
278
270
|
maxPlayers,
|
|
279
271
|
hostSessionKind,
|
|
280
|
-
serverUrl: resolvedTopology.backendOrigin,
|
|
281
|
-
publicHost: resolvedTopology.publicHost,
|
|
282
272
|
backendOrigin: resolvedTopology.backendOrigin,
|
|
283
273
|
socketOrigin: resolvedTopology.socketOrigin,
|
|
284
274
|
appOrigin: resolvedTopology.appOrigin,
|
|
@@ -9,7 +9,11 @@ import {
|
|
|
9
9
|
import type { CSSProperties, ErrorInfo, JSX, ReactNode } from "react";
|
|
10
10
|
import { Component, useCallback, useEffect, useRef, useState } from "react";
|
|
11
11
|
import { emitAirJamDiagnostic } from "../diagnostics";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
AIRJAM_DEV_LOG_EVENTS,
|
|
14
|
+
AIRJAM_RUNTIME_ERROR_REPORT_CONTRACT_VERSION,
|
|
15
|
+
type RuntimeErrorReport,
|
|
16
|
+
} from "../protocol";
|
|
13
17
|
import { emitAirJamDevRuntimeEvent } from "./dev-runtime-events";
|
|
14
18
|
|
|
15
19
|
export type AirJamRuntimeRole = "host" | "controller";
|
|
@@ -34,6 +38,7 @@ export type AirJamErrorFallbackRenderer = (
|
|
|
34
38
|
export interface AirJamErrorBoundaryProps extends AirJamRuntimeErrorContext {
|
|
35
39
|
children: ReactNode;
|
|
36
40
|
renderFallback?: AirJamErrorFallbackRenderer;
|
|
41
|
+
reportError?: (report: RuntimeErrorReport) => void;
|
|
37
42
|
onError?: (
|
|
38
43
|
error: Error,
|
|
39
44
|
errorInfo: ErrorInfo,
|
|
@@ -89,6 +94,26 @@ const createErrorDigest = (error: Error): string => {
|
|
|
89
94
|
return hash.toString(16).padStart(8, "0");
|
|
90
95
|
};
|
|
91
96
|
|
|
97
|
+
const createRuntimeReportId = (): string => {
|
|
98
|
+
const direct = globalThis.crypto?.randomUUID?.();
|
|
99
|
+
if (direct) return direct;
|
|
100
|
+
|
|
101
|
+
const bytes = new Uint8Array(16);
|
|
102
|
+
if (globalThis.crypto?.getRandomValues) {
|
|
103
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
104
|
+
} else {
|
|
105
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
106
|
+
bytes[index] = Math.floor(Math.random() * 256);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
bytes[6] = (bytes[6]! & 0x0f) | 0x40;
|
|
110
|
+
bytes[8] = (bytes[8]! & 0x3f) | 0x80;
|
|
111
|
+
const hex = Array.from(bytes, (value) =>
|
|
112
|
+
value.toString(16).padStart(2, "0"),
|
|
113
|
+
).join("");
|
|
114
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
115
|
+
};
|
|
116
|
+
|
|
92
117
|
const copyTextToClipboard = async (text: string): Promise<void> => {
|
|
93
118
|
if (
|
|
94
119
|
typeof navigator !== "undefined" &&
|
|
@@ -600,7 +625,7 @@ export class AirJamErrorBoundary extends Component<
|
|
|
600
625
|
}
|
|
601
626
|
|
|
602
627
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
|
603
|
-
const { role, roomId, appId, onError } = this.props;
|
|
628
|
+
const { role, roomId, appId, onError, reportError } = this.props;
|
|
604
629
|
const details = {
|
|
605
630
|
role,
|
|
606
631
|
roomId,
|
|
@@ -628,6 +653,25 @@ export class AirJamErrorBoundary extends Component<
|
|
|
628
653
|
data: details,
|
|
629
654
|
});
|
|
630
655
|
|
|
656
|
+
if (roomId && reportError) {
|
|
657
|
+
try {
|
|
658
|
+
reportError({
|
|
659
|
+
contractVersion: AIRJAM_RUNTIME_ERROR_REPORT_CONTRACT_VERSION,
|
|
660
|
+
reportId: createRuntimeReportId(),
|
|
661
|
+
roomId,
|
|
662
|
+
role,
|
|
663
|
+
code: "AJ_RUNTIME_RENDER_CRASH",
|
|
664
|
+
errorName: /^[A-Za-z][A-Za-z0-9._-]{0,79}$/u.test(error.name)
|
|
665
|
+
? error.name
|
|
666
|
+
: "Error",
|
|
667
|
+
digest: createErrorDigest(error),
|
|
668
|
+
occurredAt: new Date().toISOString(),
|
|
669
|
+
});
|
|
670
|
+
} catch {
|
|
671
|
+
// Operational reporting must never interfere with the recovery UI.
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
631
675
|
onError?.(error, errorInfo, {
|
|
632
676
|
role,
|
|
633
677
|
roomId,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Keep required event payloads separate from optional bridge correlation. */
|
|
2
|
+
export const splitBridgeEnvelopeArgs = (
|
|
3
|
+
args: unknown[],
|
|
4
|
+
requiredEventArgs: number,
|
|
5
|
+
): { eventArgs: unknown[]; requestId?: string } => {
|
|
6
|
+
const maybeOptions = args[args.length - 1] as
|
|
7
|
+
| { requestId?: string }
|
|
8
|
+
| undefined;
|
|
9
|
+
const hasOptions =
|
|
10
|
+
args.length > requiredEventArgs &&
|
|
11
|
+
typeof maybeOptions === "object" &&
|
|
12
|
+
maybeOptions !== null &&
|
|
13
|
+
"requestId" in maybeOptions;
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
eventArgs: hasOptions ? args.slice(0, -1) : args,
|
|
17
|
+
...(hasOptions && maybeOptions.requestId
|
|
18
|
+
? { requestId: maybeOptions.requestId }
|
|
19
|
+
: {}),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, type JSX } from "react";
|
|
2
|
+
import { useAirJamSocket } from "../context/air-jam-context";
|
|
3
|
+
import type { RuntimeErrorReport } from "../protocol";
|
|
4
|
+
import {
|
|
5
|
+
AirJamErrorBoundary,
|
|
6
|
+
type AirJamErrorBoundaryProps,
|
|
7
|
+
} from "./air-jam-error-boundary";
|
|
8
|
+
|
|
9
|
+
type ConnectedRuntimeErrorBoundaryProps = Omit<
|
|
10
|
+
AirJamErrorBoundaryProps,
|
|
11
|
+
"reportError"
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
export const ConnectedRuntimeErrorBoundary = ({
|
|
15
|
+
role,
|
|
16
|
+
...props
|
|
17
|
+
}: ConnectedRuntimeErrorBoundaryProps): JSX.Element => {
|
|
18
|
+
const socket = useAirJamSocket(role);
|
|
19
|
+
const reportError = useCallback(
|
|
20
|
+
(report: RuntimeErrorReport): void => {
|
|
21
|
+
socket.emit("runtime:error_report", report, () => {
|
|
22
|
+
// Reporting is best effort and must never disturb gameplay recovery.
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
[socket],
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<AirJamErrorBoundary {...props} role={role} reportError={reportError} />
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -1,68 +1,116 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { roomCodeSchema } from "../../protocol/core";
|
|
3
|
+
import type { AirJamActionInvocationResult } from "../../protocol/sync";
|
|
4
|
+
import { isRpcSerializable } from "../../utils/is-rpc-serializable";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
/** Callable only inside the owning browser realm; never a network endpoint. */
|
|
7
|
+
export const AIR_JAM_RUNTIME_CONTROL_KEY = "__AIR_JAM_RUNTIME_CONTROL__";
|
|
8
|
+
|
|
9
|
+
const hostRuntimeActionRequestSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
roomId: roomCodeSchema,
|
|
12
|
+
storeDomain: z.string().trim().min(1).max(128),
|
|
13
|
+
actionName: z.string().trim().min(1).max(128),
|
|
14
|
+
payload: z.record(z.string(), z.unknown()).optional(),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
15
17
|
|
|
16
|
-
type
|
|
17
|
-
|
|
18
|
-
| "runtimeState"
|
|
19
|
-
| "sendSystemCommand"
|
|
20
|
-
| "setNickname"
|
|
21
|
-
| "setAvatarId"
|
|
22
|
-
| "updatePlayerProfile"
|
|
23
|
-
| "reconnect"
|
|
18
|
+
export type HostRuntimeActionRequest = z.infer<
|
|
19
|
+
typeof hostRuntimeActionRequestSchema
|
|
24
20
|
>;
|
|
25
21
|
|
|
26
|
-
export interface
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
pauseRuntime: () => void;
|
|
31
|
-
resumeRuntime: () => void;
|
|
32
|
-
sendState: HostControlApi["sendState"];
|
|
33
|
-
sendSignal: HostControlApi["sendSignal"];
|
|
22
|
+
export interface HostRuntimeControl {
|
|
23
|
+
invoke(
|
|
24
|
+
request: HostRuntimeActionRequest,
|
|
25
|
+
): Promise<AirJamActionInvocationResult>;
|
|
34
26
|
}
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
setAvatarIdDraft: (value: string) => void;
|
|
42
|
-
updatePlayerProfile: (
|
|
43
|
-
patch: PlayerProfilePatch,
|
|
44
|
-
) => ReturnType<ControllerControlApi["updatePlayerProfile"]>;
|
|
45
|
-
}
|
|
28
|
+
type ActionStore = {
|
|
29
|
+
invoke: (
|
|
30
|
+
request: HostRuntimeActionRequest,
|
|
31
|
+
) => Promise<AirJamActionInvocationResult>;
|
|
32
|
+
};
|
|
46
33
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
resumeRuntime: api.resumeRuntime,
|
|
55
|
-
sendState: api.sendState,
|
|
56
|
-
sendSignal: api.sendSignal,
|
|
57
|
-
});
|
|
34
|
+
const controls = new WeakMap<
|
|
35
|
+
object,
|
|
36
|
+
{
|
|
37
|
+
stores: Map<string, Set<ActionStore>>;
|
|
38
|
+
control: HostRuntimeControl;
|
|
39
|
+
}
|
|
40
|
+
>();
|
|
58
41
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
const reject = (
|
|
43
|
+
reason: string,
|
|
44
|
+
message: string,
|
|
45
|
+
): AirJamActionInvocationResult => ({
|
|
46
|
+
ok: false,
|
|
47
|
+
status: "rejected",
|
|
48
|
+
source: "host",
|
|
49
|
+
reason,
|
|
50
|
+
message,
|
|
68
51
|
});
|
|
52
|
+
|
|
53
|
+
const storeKey = (roomId: string, storeDomain: string): string =>
|
|
54
|
+
JSON.stringify([roomId, storeDomain]);
|
|
55
|
+
|
|
56
|
+
/** Register one live host store; cleanup cannot remove another binding. */
|
|
57
|
+
export const registerHostRuntimeActionStore = (
|
|
58
|
+
target: object,
|
|
59
|
+
binding: ActionStore & { roomId: string; storeDomain: string },
|
|
60
|
+
): (() => void) => {
|
|
61
|
+
let entry = controls.get(target);
|
|
62
|
+
if (!entry) {
|
|
63
|
+
const stores = new Map<string, Set<ActionStore>>();
|
|
64
|
+
const control: HostRuntimeControl = {
|
|
65
|
+
async invoke(request) {
|
|
66
|
+
const parsed = hostRuntimeActionRequestSchema.safeParse(request);
|
|
67
|
+
if (
|
|
68
|
+
!parsed.success ||
|
|
69
|
+
!isRpcSerializable(request.payload) ||
|
|
70
|
+
parsed.data.actionName.startsWith("_")
|
|
71
|
+
) {
|
|
72
|
+
return reject(
|
|
73
|
+
"invalid_host_action",
|
|
74
|
+
"Host actions require a valid room, store, public action and serializable object payload.",
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const matches = stores.get(
|
|
78
|
+
storeKey(parsed.data.roomId, parsed.data.storeDomain),
|
|
79
|
+
);
|
|
80
|
+
if (!matches?.size)
|
|
81
|
+
return reject(
|
|
82
|
+
"host_store_unavailable",
|
|
83
|
+
"The requested host store is not active in this browser realm.",
|
|
84
|
+
);
|
|
85
|
+
if (matches.size !== 1)
|
|
86
|
+
return reject(
|
|
87
|
+
"host_store_ambiguous",
|
|
88
|
+
"More than one host store owns this room and domain.",
|
|
89
|
+
);
|
|
90
|
+
const [store] = matches;
|
|
91
|
+
return store.invoke(parsed.data);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
entry = { stores, control };
|
|
95
|
+
controls.set(target, entry);
|
|
96
|
+
Reflect.set(target, AIR_JAM_RUNTIME_CONTROL_KEY, control);
|
|
97
|
+
}
|
|
98
|
+
const key = storeKey(binding.roomId, binding.storeDomain);
|
|
99
|
+
const stores = entry.stores.get(key) ?? new Set<ActionStore>();
|
|
100
|
+
const registration = { invoke: binding.invoke };
|
|
101
|
+
stores.add(registration);
|
|
102
|
+
entry.stores.set(key, stores);
|
|
103
|
+
let registered = true;
|
|
104
|
+
return () => {
|
|
105
|
+
if (!registered) return;
|
|
106
|
+
registered = false;
|
|
107
|
+
stores.delete(registration);
|
|
108
|
+
if (!stores.size) entry.stores.delete(key);
|
|
109
|
+
if (!entry.stores.size) {
|
|
110
|
+
if (Reflect.get(target, AIR_JAM_RUNTIME_CONTROL_KEY) === entry.control) {
|
|
111
|
+
Reflect.deleteProperty(target, AIR_JAM_RUNTIME_CONTROL_KEY);
|
|
112
|
+
}
|
|
113
|
+
if (controls.get(target) === entry) controls.delete(target);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
arcadeSurfaceRuntimeIdentitySchema,
|
|
27
27
|
type ArcadeSurfaceRuntimeIdentity,
|
|
28
28
|
} from "./arcade-surface-identity";
|
|
29
|
+
import { splitBridgeEnvelopeArgs } from "./bridge-envelope-args";
|
|
29
30
|
import { createBridgeHandshake } from "./iframe-bridge";
|
|
30
31
|
import { AIR_JAM_SDK_VERSION } from "./sdk-version";
|
|
31
32
|
|
|
@@ -73,6 +74,9 @@ export type ControllerBridgeClientEventName =
|
|
|
73
74
|
export type ControllerBridgeServerEventName =
|
|
74
75
|
(typeof controllerBridgeServerEvents)[number];
|
|
75
76
|
|
|
77
|
+
const CONTROLLER_BRIDGE_ZERO_REQUIRED_ARGS_EVENTS =
|
|
78
|
+
new Set<ControllerBridgeServerEventName>(["connect", "disconnect"]);
|
|
79
|
+
|
|
76
80
|
export type ControllerBridgeClientEventArgs = {
|
|
77
81
|
"controller:input": [payload: ControllerInputEvent];
|
|
78
82
|
"controller:action_rpc": [payload: ControllerActionRpcPayload];
|
|
@@ -311,35 +315,16 @@ export const createControllerBridgeAttachMessage = (
|
|
|
311
315
|
},
|
|
312
316
|
});
|
|
313
317
|
|
|
314
|
-
const splitControllerBridgeArgs = (
|
|
315
|
-
args: unknown[],
|
|
316
|
-
): {
|
|
317
|
-
eventArgs: unknown[];
|
|
318
|
-
requestId?: string;
|
|
319
|
-
} => {
|
|
320
|
-
const maybeOptions = args[args.length - 1] as
|
|
321
|
-
| { requestId?: string }
|
|
322
|
-
| undefined;
|
|
323
|
-
const hasOptions =
|
|
324
|
-
typeof maybeOptions === "object" &&
|
|
325
|
-
maybeOptions !== null &&
|
|
326
|
-
"requestId" in maybeOptions;
|
|
327
|
-
|
|
328
|
-
return {
|
|
329
|
-
eventArgs: hasOptions ? args.slice(0, -1) : args,
|
|
330
|
-
...(hasOptions && maybeOptions.requestId
|
|
331
|
-
? { requestId: maybeOptions.requestId }
|
|
332
|
-
: {}),
|
|
333
|
-
};
|
|
334
|
-
};
|
|
335
|
-
|
|
336
318
|
export const createControllerBridgeEventMessage = <
|
|
337
319
|
TEvent extends ControllerBridgeServerEventName,
|
|
338
320
|
>(
|
|
339
321
|
event: TEvent,
|
|
340
322
|
...args: [...ControllerBridgeServerEventArgs[TEvent], { requestId?: string }?]
|
|
341
323
|
): ControllerBridgeEventMessage => {
|
|
342
|
-
const { eventArgs, requestId } =
|
|
324
|
+
const { eventArgs, requestId } = splitBridgeEnvelopeArgs(
|
|
325
|
+
args as unknown[],
|
|
326
|
+
CONTROLLER_BRIDGE_ZERO_REQUIRED_ARGS_EVENTS.has(event) ? 0 : 1,
|
|
327
|
+
);
|
|
343
328
|
return {
|
|
344
329
|
type: AIRJAM_CONTROLLER_BRIDGE_EVENT,
|
|
345
330
|
payload: {
|
|
@@ -356,7 +341,10 @@ export const createControllerBridgeEmitMessage = <
|
|
|
356
341
|
event: TEvent,
|
|
357
342
|
...args: [...ControllerBridgeClientEventArgs[TEvent], { requestId?: string }?]
|
|
358
343
|
): ControllerBridgeEmitMessage => {
|
|
359
|
-
const { eventArgs, requestId } =
|
|
344
|
+
const { eventArgs, requestId } = splitBridgeEnvelopeArgs(
|
|
345
|
+
args as unknown[],
|
|
346
|
+
1,
|
|
347
|
+
);
|
|
360
348
|
return {
|
|
361
349
|
type: AIRJAM_CONTROLLER_BRIDGE_EMIT,
|
|
362
350
|
payload: {
|
|
@@ -3,6 +3,11 @@ import { generateControllerId } from "../utils/ids";
|
|
|
3
3
|
const DEVICE_ID_STORAGE_KEY = "airjam_controller_device_id";
|
|
4
4
|
const ROOM_BINDINGS_STORAGE_KEY = "airjam_controller_room_bindings";
|
|
5
5
|
|
|
6
|
+
export interface ControllerRoomBinding {
|
|
7
|
+
controllerId: string;
|
|
8
|
+
resumeCapabilityToken: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
const getLocalStorage = (): Storage | null => {
|
|
7
12
|
if (typeof window === "undefined") {
|
|
8
13
|
return null;
|
|
@@ -35,32 +40,51 @@ export const getOrCreateControllerDeviceIdFromStorage = (
|
|
|
35
40
|
return generateControllerDeviceId();
|
|
36
41
|
}
|
|
37
42
|
|
|
38
|
-
const existing = storage.getItem(DEVICE_ID_STORAGE_KEY);
|
|
39
|
-
if (existing && existing.trim().length >= 8) {
|
|
40
|
-
return existing;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
43
|
const created = generateControllerDeviceId();
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
const existing = storage.getItem(DEVICE_ID_STORAGE_KEY);
|
|
46
|
+
if (existing && existing.trim().length >= 8) {
|
|
47
|
+
return existing;
|
|
48
|
+
}
|
|
49
|
+
storage.setItem(DEVICE_ID_STORAGE_KEY, created);
|
|
50
|
+
} catch {
|
|
51
|
+
// Device identity remains a usable in-memory hint when storage is denied.
|
|
52
|
+
}
|
|
45
53
|
return created;
|
|
46
54
|
};
|
|
47
55
|
|
|
48
|
-
const readRoomBindings = (
|
|
56
|
+
const readRoomBindings = (
|
|
57
|
+
storage: Storage | null,
|
|
58
|
+
): Record<string, ControllerRoomBinding> => {
|
|
49
59
|
if (!storage) {
|
|
50
60
|
return {};
|
|
51
61
|
}
|
|
52
62
|
|
|
53
|
-
const raw = storage.getItem(ROOM_BINDINGS_STORAGE_KEY);
|
|
54
|
-
if (!raw) {
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
63
|
try {
|
|
64
|
+
const raw = storage.getItem(ROOM_BINDINGS_STORAGE_KEY);
|
|
65
|
+
if (!raw) {
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
59
68
|
const parsed = JSON.parse(raw) as Record<string, unknown>;
|
|
60
|
-
const next: Record<string,
|
|
69
|
+
const next: Record<string, ControllerRoomBinding> = {};
|
|
61
70
|
for (const [key, value] of Object.entries(parsed)) {
|
|
62
|
-
if (
|
|
63
|
-
|
|
71
|
+
if (
|
|
72
|
+
key.trim().length > 0 &&
|
|
73
|
+
typeof value === "object" &&
|
|
74
|
+
value !== null
|
|
75
|
+
) {
|
|
76
|
+
const binding = value as Partial<ControllerRoomBinding>;
|
|
77
|
+
if (
|
|
78
|
+
typeof binding.controllerId === "string" &&
|
|
79
|
+
binding.controllerId.trim().length >= 3 &&
|
|
80
|
+
typeof binding.resumeCapabilityToken === "string" &&
|
|
81
|
+
binding.resumeCapabilityToken.length > 0
|
|
82
|
+
) {
|
|
83
|
+
next[key] = {
|
|
84
|
+
controllerId: binding.controllerId,
|
|
85
|
+
resumeCapabilityToken: binding.resumeCapabilityToken,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
64
88
|
}
|
|
65
89
|
}
|
|
66
90
|
return next;
|
|
@@ -71,46 +95,50 @@ const readRoomBindings = (storage: Storage | null): Record<string, string> => {
|
|
|
71
95
|
|
|
72
96
|
const writeRoomBindings = (
|
|
73
97
|
storage: Storage | null,
|
|
74
|
-
bindings: Record<string,
|
|
98
|
+
bindings: Record<string, ControllerRoomBinding>,
|
|
75
99
|
): void => {
|
|
76
100
|
if (!storage) {
|
|
77
101
|
return;
|
|
78
102
|
}
|
|
79
|
-
|
|
103
|
+
try {
|
|
104
|
+
storage.setItem(ROOM_BINDINGS_STORAGE_KEY, JSON.stringify(bindings));
|
|
105
|
+
} catch {
|
|
106
|
+
// The controller runtime retains its private binding in memory.
|
|
107
|
+
}
|
|
80
108
|
};
|
|
81
109
|
|
|
82
|
-
export const readControllerRoomBinding = (
|
|
110
|
+
export const readControllerRoomBinding = (
|
|
111
|
+
roomId: string,
|
|
112
|
+
): ControllerRoomBinding | null => {
|
|
83
113
|
return readControllerRoomBindingFromStorage(getLocalStorage(), roomId);
|
|
84
114
|
};
|
|
85
115
|
|
|
86
116
|
export const readControllerRoomBindingFromStorage = (
|
|
87
117
|
storage: Storage | null,
|
|
88
118
|
roomId: string,
|
|
89
|
-
):
|
|
119
|
+
): ControllerRoomBinding | null => {
|
|
90
120
|
const bindings = readRoomBindings(storage);
|
|
91
121
|
const binding = bindings[roomId.toUpperCase()];
|
|
92
|
-
return
|
|
93
|
-
? binding
|
|
94
|
-
: null;
|
|
122
|
+
return binding ?? null;
|
|
95
123
|
};
|
|
96
124
|
|
|
97
125
|
export const writeControllerRoomBinding = (
|
|
98
126
|
roomId: string,
|
|
99
|
-
|
|
127
|
+
binding: ControllerRoomBinding,
|
|
100
128
|
): void => {
|
|
101
|
-
writeControllerRoomBindingToStorage(getLocalStorage(), roomId,
|
|
129
|
+
writeControllerRoomBindingToStorage(getLocalStorage(), roomId, binding);
|
|
102
130
|
};
|
|
103
131
|
|
|
104
132
|
export const writeControllerRoomBindingToStorage = (
|
|
105
133
|
storage: Storage | null,
|
|
106
134
|
roomId: string,
|
|
107
|
-
|
|
135
|
+
binding: ControllerRoomBinding,
|
|
108
136
|
): void => {
|
|
109
|
-
if (!roomId || !controllerId) {
|
|
137
|
+
if (!roomId || !binding.controllerId || !binding.resumeCapabilityToken) {
|
|
110
138
|
return;
|
|
111
139
|
}
|
|
112
140
|
const bindings = readRoomBindings(storage);
|
|
113
|
-
bindings[roomId.toUpperCase()] =
|
|
141
|
+
bindings[roomId.toUpperCase()] = binding;
|
|
114
142
|
writeRoomBindings(storage, bindings);
|
|
115
143
|
};
|
|
116
144
|
|