@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,201 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describeAirJamAgentAction,
|
|
3
|
+
resolveAirJamAgentActionPayload,
|
|
4
|
+
type AnyAirJamAgentContract,
|
|
5
|
+
} from "./agent-contract.js";
|
|
6
|
+
|
|
7
|
+
export type AirJamAgentContractConformanceIssue = {
|
|
8
|
+
code:
|
|
9
|
+
| "store-domain-mismatch"
|
|
10
|
+
| "missing-store-actions"
|
|
11
|
+
| "missing-target-action"
|
|
12
|
+
| "invalid-action-metadata"
|
|
13
|
+
| "payload-parse-failed"
|
|
14
|
+
| "snapshot-failed"
|
|
15
|
+
| "snapshot-not-json";
|
|
16
|
+
path: string;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type AirJamAgentContractConformanceReport = {
|
|
21
|
+
schemaVersion: 1;
|
|
22
|
+
gameId: string;
|
|
23
|
+
ok: boolean;
|
|
24
|
+
storeDomains: string[];
|
|
25
|
+
actionNames: string[];
|
|
26
|
+
issues: AirJamAgentContractConformanceIssue[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type InspectAirJamAgentContractConformanceOptions = {
|
|
30
|
+
gameId: string;
|
|
31
|
+
contract: AnyAirJamAgentContract;
|
|
32
|
+
stores: Record<string, object>;
|
|
33
|
+
controllerId?: string | null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const representativePayload = (
|
|
37
|
+
kind: ReturnType<typeof describeAirJamAgentAction>["payload"]["kind"],
|
|
38
|
+
allowedValues?: string[],
|
|
39
|
+
): unknown => {
|
|
40
|
+
switch (kind) {
|
|
41
|
+
case "none":
|
|
42
|
+
return undefined;
|
|
43
|
+
case "boolean":
|
|
44
|
+
return true;
|
|
45
|
+
case "number":
|
|
46
|
+
return 1;
|
|
47
|
+
case "string":
|
|
48
|
+
return "conformance";
|
|
49
|
+
case "enum":
|
|
50
|
+
return allowedValues?.[0];
|
|
51
|
+
case "json":
|
|
52
|
+
return {};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const inspectJsonValue = (
|
|
57
|
+
value: unknown,
|
|
58
|
+
path: string,
|
|
59
|
+
seen: Set<object>,
|
|
60
|
+
issues: AirJamAgentContractConformanceIssue[],
|
|
61
|
+
): void => {
|
|
62
|
+
if (
|
|
63
|
+
value === null ||
|
|
64
|
+
typeof value === "string" ||
|
|
65
|
+
typeof value === "boolean"
|
|
66
|
+
) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (typeof value === "number") {
|
|
70
|
+
if (!Number.isFinite(value)) {
|
|
71
|
+
issues.push({
|
|
72
|
+
code: "snapshot-not-json",
|
|
73
|
+
path,
|
|
74
|
+
message: "Snapshot numbers must be finite.",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (typeof value !== "object") {
|
|
80
|
+
issues.push({
|
|
81
|
+
code: "snapshot-not-json",
|
|
82
|
+
path,
|
|
83
|
+
message: `Snapshot value has unsupported type ${typeof value}.`,
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (seen.has(value)) {
|
|
88
|
+
issues.push({
|
|
89
|
+
code: "snapshot-not-json",
|
|
90
|
+
path,
|
|
91
|
+
message: "Snapshot contains a circular reference.",
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
seen.add(value);
|
|
97
|
+
if (Array.isArray(value)) {
|
|
98
|
+
value.forEach((entry, index) =>
|
|
99
|
+
inspectJsonValue(entry, `${path}[${index}]`, seen, issues),
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
103
|
+
inspectJsonValue(entry, `${path}.${key}`, seen, issues);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
seen.delete(value);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const inspectAirJamAgentContractConformance = async ({
|
|
110
|
+
gameId,
|
|
111
|
+
contract,
|
|
112
|
+
stores,
|
|
113
|
+
controllerId = "conformance-controller",
|
|
114
|
+
}: InspectAirJamAgentContractConformanceOptions): Promise<AirJamAgentContractConformanceReport> => {
|
|
115
|
+
const issues: AirJamAgentContractConformanceIssue[] = [];
|
|
116
|
+
const storeDomains = Object.keys(contract.stores).sort();
|
|
117
|
+
const runtimeStoreDomains = Object.keys(stores).sort();
|
|
118
|
+
const actionNames = Object.keys(contract.actions).sort();
|
|
119
|
+
|
|
120
|
+
if (JSON.stringify(storeDomains) !== JSON.stringify(runtimeStoreDomains)) {
|
|
121
|
+
issues.push({
|
|
122
|
+
code: "store-domain-mismatch",
|
|
123
|
+
path: "stores",
|
|
124
|
+
message: `Declared domains [${storeDomains.join(", ")}] do not match runtime domains [${runtimeStoreDomains.join(", ")}].`,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const [actionName, action] of Object.entries(contract.actions)) {
|
|
129
|
+
const targetDomain = action.target.storeDomain ?? "default";
|
|
130
|
+
const runtimeStore = stores[targetDomain] as
|
|
131
|
+
| { actions?: Record<string, unknown> }
|
|
132
|
+
| undefined;
|
|
133
|
+
if (!runtimeStore?.actions || typeof runtimeStore.actions !== "object") {
|
|
134
|
+
issues.push({
|
|
135
|
+
code: "missing-store-actions",
|
|
136
|
+
path: `actions.${actionName}.target`,
|
|
137
|
+
message: `Runtime store "${targetDomain}" does not expose an actions object.`,
|
|
138
|
+
});
|
|
139
|
+
} else if (
|
|
140
|
+
typeof runtimeStore.actions[action.target.actionName] !== "function"
|
|
141
|
+
) {
|
|
142
|
+
issues.push({
|
|
143
|
+
code: "missing-target-action",
|
|
144
|
+
path: `actions.${actionName}.target`,
|
|
145
|
+
message: `Runtime store "${targetDomain}" does not expose action "${action.target.actionName}".`,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const metadata = describeAirJamAgentAction(action);
|
|
150
|
+
if (
|
|
151
|
+
!metadata.description?.trim() ||
|
|
152
|
+
!metadata.resultDescription?.trim() ||
|
|
153
|
+
(metadata.payload.kind === "enum" &&
|
|
154
|
+
!metadata.payload.allowedValues?.length)
|
|
155
|
+
) {
|
|
156
|
+
issues.push({
|
|
157
|
+
code: "invalid-action-metadata",
|
|
158
|
+
path: `actions.${actionName}`,
|
|
159
|
+
message:
|
|
160
|
+
"Every semantic action must describe its intent, expected result, and enum values when applicable.",
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
resolveAirJamAgentActionPayload(
|
|
166
|
+
action,
|
|
167
|
+
representativePayload(
|
|
168
|
+
metadata.payload.kind,
|
|
169
|
+
metadata.payload.allowedValues,
|
|
170
|
+
),
|
|
171
|
+
{ gameId, actionName, contractKind: "conformance" },
|
|
172
|
+
);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
issues.push({
|
|
175
|
+
code: "payload-parse-failed",
|
|
176
|
+
path: `actions.${actionName}.input`,
|
|
177
|
+
message: error instanceof Error ? error.message : String(error),
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
try {
|
|
183
|
+
const snapshot = await contract.projectSnapshot({ controllerId, stores });
|
|
184
|
+
inspectJsonValue(snapshot, "snapshot", new Set(), issues);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
issues.push({
|
|
187
|
+
code: "snapshot-failed",
|
|
188
|
+
path: "snapshot",
|
|
189
|
+
message: error instanceof Error ? error.message : String(error),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
schemaVersion: 1,
|
|
195
|
+
gameId,
|
|
196
|
+
ok: issues.length === 0,
|
|
197
|
+
storeDomains,
|
|
198
|
+
actionNames,
|
|
199
|
+
issues,
|
|
200
|
+
};
|
|
201
|
+
};
|
package/src/agent-tooling.ts
CHANGED
|
@@ -18,3 +18,8 @@ export {
|
|
|
18
18
|
type AirJamAgentActionContract,
|
|
19
19
|
type AirJamAgentContract,
|
|
20
20
|
} from "./agent/agent-contract";
|
|
21
|
+
export {
|
|
22
|
+
inspectAirJamAgentContractConformance,
|
|
23
|
+
type AirJamAgentContractConformanceIssue,
|
|
24
|
+
type AirJamAgentContractConformanceReport,
|
|
25
|
+
} from "./agent/agent-contract-conformance";
|
package/src/arcade/surface.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "../runtime/arcade-bridge-request-surface";
|
|
2
2
|
export * from "../runtime/arcade-runtime-url";
|
|
3
3
|
export * from "../runtime/arcade-surface-identity";
|
|
4
|
+
export * from "../runtime/local-reference-game-identity";
|
|
4
5
|
export { AIR_JAM_ARCADE_SURFACE_STORE_DOMAIN } from "../store/air-jam-store-domain-constants";
|
|
@@ -1,39 +1,60 @@
|
|
|
1
|
-
import { useEffect, type JSX, type MouseEvent } from "react";
|
|
1
|
+
import { useEffect, useState, type JSX, type MouseEvent } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
2
3
|
import { cn } from "../utils/cn";
|
|
3
4
|
import { RoomQrCode } from "./room-qr-code";
|
|
4
|
-
import {
|
|
5
|
-
shellPanelClassName,
|
|
6
|
-
shellUtilityButtonClassName,
|
|
7
|
-
} from "./shell-classes";
|
|
5
|
+
import { shellUtilityButtonClassName } from "./shell-classes";
|
|
8
6
|
import { Button } from "./ui/button";
|
|
9
7
|
|
|
10
8
|
export interface JoinQrOverlayProps {
|
|
11
9
|
open: boolean;
|
|
12
10
|
value: string | null | undefined;
|
|
11
|
+
status?: "ready" | "loading" | "unavailable";
|
|
13
12
|
roomId?: string | null;
|
|
14
13
|
onClose?: () => void;
|
|
15
14
|
title?: string;
|
|
15
|
+
roomLabel?: string;
|
|
16
16
|
description?: string;
|
|
17
|
+
unavailableLabel?: string;
|
|
18
|
+
loadingLabel?: string;
|
|
19
|
+
qrAlt?: string;
|
|
20
|
+
showCloseButton?: boolean;
|
|
17
21
|
className?: string;
|
|
18
22
|
panelClassName?: string;
|
|
19
23
|
qrClassName?: string;
|
|
24
|
+
bodyClassName?: string;
|
|
25
|
+
messageClassName?: string;
|
|
26
|
+
descriptionClassName?: string;
|
|
27
|
+
closeButtonClassName?: string;
|
|
20
28
|
size?: number;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
export const JoinQrOverlay = ({
|
|
24
32
|
open,
|
|
25
33
|
value,
|
|
34
|
+
status = "ready",
|
|
26
35
|
roomId,
|
|
27
36
|
onClose,
|
|
28
|
-
title = "Scan to join",
|
|
37
|
+
title = "Scan QR code to join as a controller",
|
|
38
|
+
roomLabel = "Join room",
|
|
29
39
|
description = "Scan with your phone to connect as a controller.",
|
|
40
|
+
unavailableLabel = "Join URL unavailable right now.",
|
|
41
|
+
loadingLabel = "Preparing join QR…",
|
|
42
|
+
qrAlt,
|
|
43
|
+
showCloseButton = false,
|
|
30
44
|
className,
|
|
31
45
|
panelClassName,
|
|
32
46
|
qrClassName,
|
|
33
|
-
|
|
47
|
+
bodyClassName,
|
|
48
|
+
messageClassName,
|
|
49
|
+
descriptionClassName,
|
|
50
|
+
closeButtonClassName,
|
|
51
|
+
size = 260,
|
|
34
52
|
}: JoinQrOverlayProps): JSX.Element | null => {
|
|
35
53
|
const joinUrlValue = value?.trim() ?? "";
|
|
36
|
-
const
|
|
54
|
+
const effectiveStatus =
|
|
55
|
+
status === "ready" && joinUrlValue.length === 0 ? "unavailable" : status;
|
|
56
|
+
const overlaySize = `min(72vw, ${size}px)`;
|
|
57
|
+
const [entered, setEntered] = useState(false);
|
|
37
58
|
|
|
38
59
|
useEffect(() => {
|
|
39
60
|
if (!open || typeof window === "undefined") {
|
|
@@ -52,6 +73,22 @@ export const JoinQrOverlay = ({
|
|
|
52
73
|
};
|
|
53
74
|
}, [onClose, open]);
|
|
54
75
|
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!open || typeof window === "undefined") {
|
|
78
|
+
setEntered(false);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setEntered(false);
|
|
83
|
+
const frame = window.requestAnimationFrame(() => {
|
|
84
|
+
setEntered(true);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return () => {
|
|
88
|
+
window.cancelAnimationFrame(frame);
|
|
89
|
+
};
|
|
90
|
+
}, [open]);
|
|
91
|
+
|
|
55
92
|
if (!open) {
|
|
56
93
|
return null;
|
|
57
94
|
}
|
|
@@ -60,74 +97,121 @@ export const JoinQrOverlay = ({
|
|
|
60
97
|
event.stopPropagation();
|
|
61
98
|
};
|
|
62
99
|
|
|
63
|
-
|
|
100
|
+
const dialog = (
|
|
64
101
|
<div
|
|
65
102
|
role="dialog"
|
|
66
103
|
aria-modal="true"
|
|
67
104
|
aria-label={roomId ? `Join room ${roomId}` : title}
|
|
68
105
|
className={cn(
|
|
69
|
-
"
|
|
106
|
+
"pointer-events-auto fixed inset-0 z-[120] flex cursor-pointer flex-col items-center justify-center bg-black/85 px-6 backdrop-blur-md transition-opacity duration-200 ease-out",
|
|
107
|
+
entered ? "opacity-100" : "opacity-0",
|
|
70
108
|
className,
|
|
71
109
|
)}
|
|
72
110
|
onClick={onClose}
|
|
73
111
|
>
|
|
74
112
|
<div
|
|
75
113
|
className={cn(
|
|
76
|
-
"flex
|
|
77
|
-
|
|
114
|
+
"flex cursor-default flex-col items-center gap-6 text-center transition-transform duration-200 ease-out",
|
|
115
|
+
entered ? "translate-y-0" : "-translate-y-4",
|
|
78
116
|
panelClassName,
|
|
79
117
|
)}
|
|
80
118
|
onClick={handlePanelClick}
|
|
81
119
|
>
|
|
82
120
|
<div className="space-y-1">
|
|
83
|
-
<p className="text-[
|
|
84
|
-
{
|
|
121
|
+
<p className="text-[11px] tracking-[0.18em] text-slate-400 uppercase">
|
|
122
|
+
{roomLabel}
|
|
85
123
|
</p>
|
|
86
124
|
{roomId ? (
|
|
87
|
-
<p className="text-
|
|
125
|
+
<p className="text-2xl font-semibold tracking-tight text-white tabular-nums">
|
|
88
126
|
{roomId}
|
|
89
127
|
</p>
|
|
90
128
|
) : null}
|
|
91
129
|
</div>
|
|
92
130
|
|
|
93
|
-
{
|
|
131
|
+
{effectiveStatus === "loading" ? (
|
|
132
|
+
<div
|
|
133
|
+
className={cn(
|
|
134
|
+
"flex flex-col items-center justify-center gap-3 rounded-lg border border-white/25 bg-white/6 px-5 py-10 text-sm text-white/70 shadow-sm",
|
|
135
|
+
bodyClassName,
|
|
136
|
+
)}
|
|
137
|
+
style={{
|
|
138
|
+
width: overlaySize,
|
|
139
|
+
height: "auto",
|
|
140
|
+
aspectRatio: "1 / 1",
|
|
141
|
+
}}
|
|
142
|
+
>
|
|
143
|
+
<span className="h-8 w-8 animate-spin rounded-full border-2 border-white/15 border-t-white/85" />
|
|
144
|
+
<span>{loadingLabel}</span>
|
|
145
|
+
</div>
|
|
146
|
+
) : effectiveStatus === "ready" ? (
|
|
94
147
|
<RoomQrCode
|
|
95
148
|
value={joinUrlValue}
|
|
96
149
|
size={size}
|
|
97
150
|
padding={2}
|
|
98
151
|
foregroundColor="#111827"
|
|
99
152
|
backgroundColor="#ffffff"
|
|
100
|
-
className={cn(
|
|
153
|
+
className={cn(
|
|
154
|
+
"rounded-lg border border-white/25 bg-white/6 shadow-sm",
|
|
155
|
+
qrClassName,
|
|
156
|
+
)}
|
|
101
157
|
style={{
|
|
102
|
-
width:
|
|
158
|
+
width: overlaySize,
|
|
103
159
|
height: "auto",
|
|
104
160
|
aspectRatio: "1 / 1",
|
|
105
161
|
}}
|
|
106
162
|
alt={
|
|
107
|
-
|
|
163
|
+
qrAlt ??
|
|
164
|
+
(roomId
|
|
108
165
|
? `QR code to join room ${roomId}`
|
|
109
|
-
: "QR code to join as a controller"
|
|
166
|
+
: "QR code to join as a controller")
|
|
110
167
|
}
|
|
111
168
|
/>
|
|
112
169
|
) : (
|
|
113
|
-
<div
|
|
114
|
-
|
|
170
|
+
<div
|
|
171
|
+
className={cn(
|
|
172
|
+
"flex items-center justify-center rounded-lg border border-white/25 bg-white/6 px-5 py-10 text-sm text-white/70 shadow-sm",
|
|
173
|
+
messageClassName,
|
|
174
|
+
)}
|
|
175
|
+
style={{
|
|
176
|
+
width: overlaySize,
|
|
177
|
+
height: "auto",
|
|
178
|
+
aspectRatio: "1 / 1",
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
{unavailableLabel}
|
|
115
182
|
</div>
|
|
116
183
|
)}
|
|
117
184
|
|
|
118
|
-
<p
|
|
185
|
+
<p
|
|
186
|
+
className={cn(
|
|
187
|
+
"max-w-xs text-center text-sm text-slate-400",
|
|
188
|
+
descriptionClassName,
|
|
189
|
+
)}
|
|
190
|
+
>
|
|
119
191
|
{description}
|
|
120
192
|
</p>
|
|
121
193
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
194
|
+
{showCloseButton ? (
|
|
195
|
+
<Button
|
|
196
|
+
type="button"
|
|
197
|
+
variant="outline"
|
|
198
|
+
onClick={onClose}
|
|
199
|
+
className={cn(
|
|
200
|
+
"rounded-2xl px-5",
|
|
201
|
+
shellUtilityButtonClassName,
|
|
202
|
+
closeButtonClassName,
|
|
203
|
+
)}
|
|
204
|
+
>
|
|
205
|
+
Close
|
|
206
|
+
</Button>
|
|
207
|
+
) : null}
|
|
130
208
|
</div>
|
|
131
209
|
</div>
|
|
132
210
|
);
|
|
211
|
+
|
|
212
|
+
if (typeof document === "undefined") {
|
|
213
|
+
return dialog;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return createPortal(dialog, document.body);
|
|
133
217
|
};
|
|
@@ -42,12 +42,6 @@
|
|
|
42
42
|
* );
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
import type {
|
|
46
|
-
ResolvedAirJamRuntimeTopology,
|
|
47
|
-
RuntimeTopologyInput,
|
|
48
|
-
SurfaceRole,
|
|
49
|
-
} from "../runtime-topology";
|
|
50
|
-
import { isLocalDevControlSurfaceTopology } from "../runtime-topology";
|
|
51
45
|
import {
|
|
52
46
|
createContext,
|
|
53
47
|
useCallback,
|
|
@@ -65,6 +59,12 @@ import { InputManager, type InputConfig } from "../internal/input-manager";
|
|
|
65
59
|
import type { ConnectionRole } from "../protocol";
|
|
66
60
|
import { AIRJAM_DEV_LOG_EVENTS } from "../protocol";
|
|
67
61
|
import type { HostSessionKind } from "../protocol/host";
|
|
62
|
+
import type {
|
|
63
|
+
ResolvedAirJamRuntimeTopology,
|
|
64
|
+
RuntimeTopologyInput,
|
|
65
|
+
SurfaceRole,
|
|
66
|
+
} from "../runtime-topology";
|
|
67
|
+
import { isLocalDevControlSurfaceTopology } from "../runtime-topology";
|
|
68
68
|
import type { AirJamConfig } from "../runtime/air-jam-config";
|
|
69
69
|
import { resolveAirJamConfig } from "../runtime/air-jam-config";
|
|
70
70
|
import {
|
|
@@ -113,7 +113,7 @@ export interface AirJamProviderProps<
|
|
|
113
113
|
children: ReactNode;
|
|
114
114
|
/** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
|
|
115
115
|
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
116
|
-
/** Internal surface-role hint
|
|
116
|
+
/** Internal surface-role hint used while resolving topology. */
|
|
117
117
|
surfaceRole?: SurfaceRole;
|
|
118
118
|
/**
|
|
119
119
|
* App ID for production bootstrap identity.
|
|
@@ -478,7 +478,7 @@ export const useAirJamContext = (): AirJamContextValue => {
|
|
|
478
478
|
* @example
|
|
479
479
|
* ```tsx
|
|
480
480
|
* const config = useAirJamConfig();
|
|
481
|
-
* console.log(config.
|
|
481
|
+
* console.log(config.topology.backendOrigin, config.maxPlayers);
|
|
482
482
|
* ```
|
|
483
483
|
*/
|
|
484
484
|
export const useAirJamConfig = (): AirJamConfig => {
|
|
@@ -63,13 +63,6 @@ export class SocketManager {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* Deprecated compatibility alias. Returns the resolved socket origin.
|
|
68
|
-
*/
|
|
69
|
-
getServerUrl(): string {
|
|
70
|
-
return this.socketOrigin;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
66
|
private normalizeOrigin(origin: string): string {
|
|
74
67
|
if (!origin.includes("://")) {
|
|
75
68
|
return `http://${origin}`;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isLocalDevControlSurfaceTopology,
|
|
3
|
-
type ProxyStrategy,
|
|
4
|
-
type ResolvedAirJamRuntimeTopology,
|
|
5
|
-
} from "../runtime-topology";
|
|
6
1
|
import {
|
|
7
2
|
onAirJamDiagnostic,
|
|
8
3
|
type AirJamDiagnostic,
|
|
@@ -17,6 +12,11 @@ import {
|
|
|
17
12
|
AIRJAM_DEV_LOG_EVENTS,
|
|
18
13
|
resolveAirJamBrowserConsoleCategory,
|
|
19
14
|
} from "../protocol";
|
|
15
|
+
import {
|
|
16
|
+
isLocalDevControlSurfaceTopology,
|
|
17
|
+
type ProxyStrategy,
|
|
18
|
+
type ResolvedAirJamRuntimeTopology,
|
|
19
|
+
} from "../runtime-topology";
|
|
20
20
|
import {
|
|
21
21
|
AIRJAM_DEV_LOG_SINK_FAILURE,
|
|
22
22
|
AIRJAM_DEV_RUNTIME_EVENT,
|
|
@@ -74,7 +74,6 @@ type ConsoleMethodName = "debug" | "info" | "log" | "warn" | "error";
|
|
|
74
74
|
|
|
75
75
|
interface BrowserLogSinkOptions {
|
|
76
76
|
backendOrigin?: string;
|
|
77
|
-
serverUrl?: string;
|
|
78
77
|
appOrigin?: string;
|
|
79
78
|
proxyStrategy?: ProxyStrategy;
|
|
80
79
|
appId?: string;
|
|
@@ -134,30 +133,28 @@ const isDevelopmentRuntime = (): boolean => {
|
|
|
134
133
|
|
|
135
134
|
const resolveEndpointBase = ({
|
|
136
135
|
backendOrigin,
|
|
137
|
-
serverUrl,
|
|
138
136
|
appOrigin,
|
|
139
137
|
proxyStrategy,
|
|
140
138
|
}: Pick<
|
|
141
139
|
BrowserLogSinkOptions,
|
|
142
|
-
"backendOrigin" | "
|
|
140
|
+
"backendOrigin" | "appOrigin" | "proxyStrategy"
|
|
143
141
|
>): string | null => {
|
|
144
142
|
if (proxyStrategy && proxyStrategy !== "none") {
|
|
145
143
|
return (appOrigin ?? resolveDevProxyBaseUrl())?.replace(/\/$/, "") ?? null;
|
|
146
144
|
}
|
|
147
145
|
|
|
148
|
-
|
|
149
|
-
if (!explicitOrigin) {
|
|
146
|
+
if (!backendOrigin) {
|
|
150
147
|
return resolveDevProxyBaseUrl();
|
|
151
148
|
}
|
|
152
149
|
|
|
153
|
-
if (
|
|
154
|
-
return `http://${
|
|
150
|
+
if (backendOrigin.startsWith("ws://")) {
|
|
151
|
+
return `http://${backendOrigin.slice(5)}`.replace(/\/$/, "");
|
|
155
152
|
}
|
|
156
|
-
if (
|
|
157
|
-
return `https://${
|
|
153
|
+
if (backendOrigin.startsWith("wss://")) {
|
|
154
|
+
return `https://${backendOrigin.slice(6)}`.replace(/\/$/, "");
|
|
158
155
|
}
|
|
159
156
|
|
|
160
|
-
return
|
|
157
|
+
return backendOrigin.replace(/\/$/, "");
|
|
161
158
|
};
|
|
162
159
|
|
|
163
160
|
const resolveDevProxyBaseUrl = (): string | null => {
|
package/src/events.ts
CHANGED