@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/agent/agent-contract-conformance.ts"],"sourcesContent":["import {\n describeAirJamAgentAction,\n resolveAirJamAgentActionPayload,\n type AnyAirJamAgentContract,\n} from \"./agent-contract.js\";\n\nexport type AirJamAgentContractConformanceIssue = {\n code:\n | \"store-domain-mismatch\"\n | \"missing-store-actions\"\n | \"missing-target-action\"\n | \"invalid-action-metadata\"\n | \"payload-parse-failed\"\n | \"snapshot-failed\"\n | \"snapshot-not-json\";\n path: string;\n message: string;\n};\n\nexport type AirJamAgentContractConformanceReport = {\n schemaVersion: 1;\n gameId: string;\n ok: boolean;\n storeDomains: string[];\n actionNames: string[];\n issues: AirJamAgentContractConformanceIssue[];\n};\n\ntype InspectAirJamAgentContractConformanceOptions = {\n gameId: string;\n contract: AnyAirJamAgentContract;\n stores: Record<string, object>;\n controllerId?: string | null;\n};\n\nconst representativePayload = (\n kind: ReturnType<typeof describeAirJamAgentAction>[\"payload\"][\"kind\"],\n allowedValues?: string[],\n): unknown => {\n switch (kind) {\n case \"none\":\n return undefined;\n case \"boolean\":\n return true;\n case \"number\":\n return 1;\n case \"string\":\n return \"conformance\";\n case \"enum\":\n return allowedValues?.[0];\n case \"json\":\n return {};\n }\n};\n\nconst inspectJsonValue = (\n value: unknown,\n path: string,\n seen: Set<object>,\n issues: AirJamAgentContractConformanceIssue[],\n): void => {\n if (\n value === null ||\n typeof value === \"string\" ||\n typeof value === \"boolean\"\n ) {\n return;\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n issues.push({\n code: \"snapshot-not-json\",\n path,\n message: \"Snapshot numbers must be finite.\",\n });\n }\n return;\n }\n if (typeof value !== \"object\") {\n issues.push({\n code: \"snapshot-not-json\",\n path,\n message: `Snapshot value has unsupported type ${typeof value}.`,\n });\n return;\n }\n if (seen.has(value)) {\n issues.push({\n code: \"snapshot-not-json\",\n path,\n message: \"Snapshot contains a circular reference.\",\n });\n return;\n }\n\n seen.add(value);\n if (Array.isArray(value)) {\n value.forEach((entry, index) =>\n inspectJsonValue(entry, `${path}[${index}]`, seen, issues),\n );\n } else {\n for (const [key, entry] of Object.entries(value)) {\n inspectJsonValue(entry, `${path}.${key}`, seen, issues);\n }\n }\n seen.delete(value);\n};\n\nexport const inspectAirJamAgentContractConformance = async ({\n gameId,\n contract,\n stores,\n controllerId = \"conformance-controller\",\n}: InspectAirJamAgentContractConformanceOptions): Promise<AirJamAgentContractConformanceReport> => {\n const issues: AirJamAgentContractConformanceIssue[] = [];\n const storeDomains = Object.keys(contract.stores).sort();\n const runtimeStoreDomains = Object.keys(stores).sort();\n const actionNames = Object.keys(contract.actions).sort();\n\n if (JSON.stringify(storeDomains) !== JSON.stringify(runtimeStoreDomains)) {\n issues.push({\n code: \"store-domain-mismatch\",\n path: \"stores\",\n message: `Declared domains [${storeDomains.join(\", \")}] do not match runtime domains [${runtimeStoreDomains.join(\", \")}].`,\n });\n }\n\n for (const [actionName, action] of Object.entries(contract.actions)) {\n const targetDomain = action.target.storeDomain ?? \"default\";\n const runtimeStore = stores[targetDomain] as\n | { actions?: Record<string, unknown> }\n | undefined;\n if (!runtimeStore?.actions || typeof runtimeStore.actions !== \"object\") {\n issues.push({\n code: \"missing-store-actions\",\n path: `actions.${actionName}.target`,\n message: `Runtime store \"${targetDomain}\" does not expose an actions object.`,\n });\n } else if (\n typeof runtimeStore.actions[action.target.actionName] !== \"function\"\n ) {\n issues.push({\n code: \"missing-target-action\",\n path: `actions.${actionName}.target`,\n message: `Runtime store \"${targetDomain}\" does not expose action \"${action.target.actionName}\".`,\n });\n }\n\n const metadata = describeAirJamAgentAction(action);\n if (\n !metadata.description?.trim() ||\n !metadata.resultDescription?.trim() ||\n (metadata.payload.kind === \"enum\" &&\n !metadata.payload.allowedValues?.length)\n ) {\n issues.push({\n code: \"invalid-action-metadata\",\n path: `actions.${actionName}`,\n message:\n \"Every semantic action must describe its intent, expected result, and enum values when applicable.\",\n });\n }\n\n try {\n resolveAirJamAgentActionPayload(\n action,\n representativePayload(\n metadata.payload.kind,\n metadata.payload.allowedValues,\n ),\n { gameId, actionName, contractKind: \"conformance\" },\n );\n } catch (error) {\n issues.push({\n code: \"payload-parse-failed\",\n path: `actions.${actionName}.input`,\n message: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n try {\n const snapshot = await contract.projectSnapshot({ controllerId, stores });\n inspectJsonValue(snapshot, \"snapshot\", new Set(), issues);\n } catch (error) {\n issues.push({\n code: \"snapshot-failed\",\n path: \"snapshot\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n\n return {\n schemaVersion: 1,\n gameId,\n ok: issues.length === 0,\n storeDomains,\n actionNames,\n issues,\n };\n};\n"],"mappings":";;;;;;;;;;AAmCA,IAAM,wBAAwB,CAC5B,MACA,kBACY;AACZ,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO;AAAA,IACT,KA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Q;AAAA,UACjB,SAAS,QAAQ;AAAA,QACnB;AAAA,QACA,EAAE,QAAQ,YAAY,cAAc,cAAc;AAAA,MACpD;AAAA,IACF,SAAS,OAAO;AACd,aAAO,KAAK;AAAA,QACV,MAAM;AAAA,QACN,MAAM,WAAW,UAAU;AAAA,QAC3B,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAChE,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI;AACF,UAAM,WAAW,MAAM,SAAS,gBAAgB,EAAE,cAAc,OAAO,CAAC;AACxE,qBAAiB,UAAU,YAAY,oBAAI,IAAI,GAAG,MAAM;AAAA,EAC1D,SAAS,OAAO;AACd,WAAO,KAAK;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IAChE,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,eAAe;AAAA,IACf;AAAA,IACA,IAAI,OAAO,WAAW;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { H as HostSessionKind } from './host-B9pRy0Aa.cjs';
|
|
4
|
+
import { RuntimeTopologyInput, ResolvedAirJamRuntimeTopology, SurfaceRole } from './runtime-topology.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module InputManager
|
|
8
|
+
* @description Internal input runtime used by host hooks.
|
|
9
|
+
*
|
|
10
|
+
* Public API terms:
|
|
11
|
+
* - `pulse`: consume-on-read, tap-safe behavior (default for booleans)
|
|
12
|
+
* - `hold`: keep last active vector until a new active value arrives
|
|
13
|
+
* - `latest`: read current value as-is (default for vectors and other fields)
|
|
14
|
+
*
|
|
15
|
+
* @internal This class is not exported publicly. Use hooks to access input.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for input handling with optional validation and per-field behavior.
|
|
20
|
+
*
|
|
21
|
+
* Provided to `HostSessionProvider` to enable typed and behavior-aware input reads.
|
|
22
|
+
*
|
|
23
|
+
* @template TSchema - Zod schema type for input validation
|
|
24
|
+
*
|
|
25
|
+
* @example Basic schema validation
|
|
26
|
+
* ```ts
|
|
27
|
+
* const config: InputConfig = {
|
|
28
|
+
* schema: z.object({
|
|
29
|
+
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
30
|
+
* action: z.boolean(),
|
|
31
|
+
* }),
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example With custom behavior overrides
|
|
36
|
+
* ```ts
|
|
37
|
+
* const config: InputConfig = {
|
|
38
|
+
* schema: gameInputSchema,
|
|
39
|
+
* behavior: {
|
|
40
|
+
* pulse: ["action", "ability"], // consume-on-read
|
|
41
|
+
* latest: ["aim"], // read latest value
|
|
42
|
+
* hold: ["menuVector"], // keep last non-zero vector
|
|
43
|
+
* },
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
48
|
+
/**
|
|
49
|
+
* Zod schema for input validation and type inference.
|
|
50
|
+
*
|
|
51
|
+
* When provided:
|
|
52
|
+
* - Incoming input is validated against the schema
|
|
53
|
+
* - Invalid input returns `undefined` (with console warning)
|
|
54
|
+
* - Return type is inferred from the schema
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* schema: z.object({
|
|
59
|
+
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
60
|
+
* action: z.boolean(),
|
|
61
|
+
* ability: z.boolean(),
|
|
62
|
+
* timestamp: z.number(),
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
schema?: TSchema;
|
|
67
|
+
behavior?: {
|
|
68
|
+
/**
|
|
69
|
+
* Consume-on-read behavior. Useful for tap-safe buttons and one-shot vectors.
|
|
70
|
+
*
|
|
71
|
+
* Defaults: booleans use `pulse` even without explicit config.
|
|
72
|
+
*/
|
|
73
|
+
pulse?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Sticky behavior. For vectors, keeps the last non-zero direction until
|
|
76
|
+
* another non-zero direction arrives.
|
|
77
|
+
*/
|
|
78
|
+
hold?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Stateless behavior. Returns the latest raw value.
|
|
81
|
+
*
|
|
82
|
+
* Defaults: vectors and non-boolean fields use `latest`.
|
|
83
|
+
*/
|
|
84
|
+
latest?: string[];
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Props for the AirJamProvider component.
|
|
90
|
+
*
|
|
91
|
+
* @template TSchema - Zod schema type for input validation (inferred from input.schema)
|
|
92
|
+
*
|
|
93
|
+
* @example Minimal configuration (uses environment variables)
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <HostSessionProvider>
|
|
96
|
+
* <App />
|
|
97
|
+
* </HostSessionProvider>
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example Full configuration
|
|
101
|
+
* ```tsx
|
|
102
|
+
* <HostSessionProvider
|
|
103
|
+
* topology={myTopology}
|
|
104
|
+
* appId="your-app-id"
|
|
105
|
+
* hostGrantEndpoint="/api/airjam/host-grant"
|
|
106
|
+
* maxPlayers={4}
|
|
107
|
+
* input={{
|
|
108
|
+
* schema: myInputSchema,
|
|
109
|
+
* behavior: { pulse: ["fire"], latest: ["move"] },
|
|
110
|
+
* }}
|
|
111
|
+
* >
|
|
112
|
+
* <App />
|
|
113
|
+
* </HostSessionProvider>
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
117
|
+
/** React children to render within the provider */
|
|
118
|
+
children: ReactNode;
|
|
119
|
+
/** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
|
|
120
|
+
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
121
|
+
/** Internal surface-role hint used while resolving topology. */
|
|
122
|
+
surfaceRole?: SurfaceRole;
|
|
123
|
+
/**
|
|
124
|
+
* App ID for production bootstrap identity.
|
|
125
|
+
* Falls back to VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID
|
|
126
|
+
* when not provided directly.
|
|
127
|
+
*/
|
|
128
|
+
appId?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Optional endpoint that returns a short-lived signed host grant for stronger production bootstrap.
|
|
131
|
+
* When provided, the host runtime fetches a grant automatically before `host:bootstrap`.
|
|
132
|
+
*/
|
|
133
|
+
hostGrantEndpoint?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Maximum number of players allowed in a room.
|
|
136
|
+
* @default 8
|
|
137
|
+
*/
|
|
138
|
+
maxPlayers?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Declares whether this host provider owns a standalone game room or a system shell room.
|
|
141
|
+
* Standalone games should use `"game"`; Arcade shell hosts should use `"system"`.
|
|
142
|
+
* @default "game"
|
|
143
|
+
*/
|
|
144
|
+
hostSessionKind?: HostSessionKind;
|
|
145
|
+
/**
|
|
146
|
+
* Enable environment-variable fallback resolution for config fields.
|
|
147
|
+
* Set to false to require explicit `topology` / `appId` / `hostGrantEndpoint`.
|
|
148
|
+
* @default true
|
|
149
|
+
*/
|
|
150
|
+
resolveEnv?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Input handling configuration including Zod schema validation and field behavior.
|
|
153
|
+
* When provided, enables typed input with tap-safe defaults:
|
|
154
|
+
* - booleans => `pulse`
|
|
155
|
+
* - vectors => `latest`
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* input={{
|
|
160
|
+
* schema: z.object({
|
|
161
|
+
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
162
|
+
* action: z.boolean(),
|
|
163
|
+
* ability: z.boolean(),
|
|
164
|
+
* }),
|
|
165
|
+
* behavior: {
|
|
166
|
+
* pulse: ["action", "ability"], // consume-on-read actions
|
|
167
|
+
* latest: ["vector"], // continuous movement
|
|
168
|
+
* },
|
|
169
|
+
* }}
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
input?: InputConfig<TSchema>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type { AirJamProviderProps as A };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { H as HostSessionKind } from './host-DylGsX7p.js';
|
|
4
|
+
import { RuntimeTopologyInput, ResolvedAirJamRuntimeTopology, SurfaceRole } from './runtime-topology.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module InputManager
|
|
8
|
+
* @description Internal input runtime used by host hooks.
|
|
9
|
+
*
|
|
10
|
+
* Public API terms:
|
|
11
|
+
* - `pulse`: consume-on-read, tap-safe behavior (default for booleans)
|
|
12
|
+
* - `hold`: keep last active vector until a new active value arrives
|
|
13
|
+
* - `latest`: read current value as-is (default for vectors and other fields)
|
|
14
|
+
*
|
|
15
|
+
* @internal This class is not exported publicly. Use hooks to access input.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for input handling with optional validation and per-field behavior.
|
|
20
|
+
*
|
|
21
|
+
* Provided to `HostSessionProvider` to enable typed and behavior-aware input reads.
|
|
22
|
+
*
|
|
23
|
+
* @template TSchema - Zod schema type for input validation
|
|
24
|
+
*
|
|
25
|
+
* @example Basic schema validation
|
|
26
|
+
* ```ts
|
|
27
|
+
* const config: InputConfig = {
|
|
28
|
+
* schema: z.object({
|
|
29
|
+
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
30
|
+
* action: z.boolean(),
|
|
31
|
+
* }),
|
|
32
|
+
* };
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example With custom behavior overrides
|
|
36
|
+
* ```ts
|
|
37
|
+
* const config: InputConfig = {
|
|
38
|
+
* schema: gameInputSchema,
|
|
39
|
+
* behavior: {
|
|
40
|
+
* pulse: ["action", "ability"], // consume-on-read
|
|
41
|
+
* latest: ["aim"], // read latest value
|
|
42
|
+
* hold: ["menuVector"], // keep last non-zero vector
|
|
43
|
+
* },
|
|
44
|
+
* };
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
interface InputConfig<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
48
|
+
/**
|
|
49
|
+
* Zod schema for input validation and type inference.
|
|
50
|
+
*
|
|
51
|
+
* When provided:
|
|
52
|
+
* - Incoming input is validated against the schema
|
|
53
|
+
* - Invalid input returns `undefined` (with console warning)
|
|
54
|
+
* - Return type is inferred from the schema
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* schema: z.object({
|
|
59
|
+
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
60
|
+
* action: z.boolean(),
|
|
61
|
+
* ability: z.boolean(),
|
|
62
|
+
* timestamp: z.number(),
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
schema?: TSchema;
|
|
67
|
+
behavior?: {
|
|
68
|
+
/**
|
|
69
|
+
* Consume-on-read behavior. Useful for tap-safe buttons and one-shot vectors.
|
|
70
|
+
*
|
|
71
|
+
* Defaults: booleans use `pulse` even without explicit config.
|
|
72
|
+
*/
|
|
73
|
+
pulse?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Sticky behavior. For vectors, keeps the last non-zero direction until
|
|
76
|
+
* another non-zero direction arrives.
|
|
77
|
+
*/
|
|
78
|
+
hold?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* Stateless behavior. Returns the latest raw value.
|
|
81
|
+
*
|
|
82
|
+
* Defaults: vectors and non-boolean fields use `latest`.
|
|
83
|
+
*/
|
|
84
|
+
latest?: string[];
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Props for the AirJamProvider component.
|
|
90
|
+
*
|
|
91
|
+
* @template TSchema - Zod schema type for input validation (inferred from input.schema)
|
|
92
|
+
*
|
|
93
|
+
* @example Minimal configuration (uses environment variables)
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <HostSessionProvider>
|
|
96
|
+
* <App />
|
|
97
|
+
* </HostSessionProvider>
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example Full configuration
|
|
101
|
+
* ```tsx
|
|
102
|
+
* <HostSessionProvider
|
|
103
|
+
* topology={myTopology}
|
|
104
|
+
* appId="your-app-id"
|
|
105
|
+
* hostGrantEndpoint="/api/airjam/host-grant"
|
|
106
|
+
* maxPlayers={4}
|
|
107
|
+
* input={{
|
|
108
|
+
* schema: myInputSchema,
|
|
109
|
+
* behavior: { pulse: ["fire"], latest: ["move"] },
|
|
110
|
+
* }}
|
|
111
|
+
* >
|
|
112
|
+
* <App />
|
|
113
|
+
* </HostSessionProvider>
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
interface AirJamProviderProps<TSchema extends z.ZodSchema = z.ZodSchema> {
|
|
117
|
+
/** React children to render within the provider */
|
|
118
|
+
children: ReactNode;
|
|
119
|
+
/** Explicit runtime topology for this surface. Prefer this over loose endpoint props. */
|
|
120
|
+
topology?: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology;
|
|
121
|
+
/** Internal surface-role hint used while resolving topology. */
|
|
122
|
+
surfaceRole?: SurfaceRole;
|
|
123
|
+
/**
|
|
124
|
+
* App ID for production bootstrap identity.
|
|
125
|
+
* Falls back to VITE_AIR_JAM_APP_ID or NEXT_PUBLIC_AIR_JAM_APP_ID
|
|
126
|
+
* when not provided directly.
|
|
127
|
+
*/
|
|
128
|
+
appId?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Optional endpoint that returns a short-lived signed host grant for stronger production bootstrap.
|
|
131
|
+
* When provided, the host runtime fetches a grant automatically before `host:bootstrap`.
|
|
132
|
+
*/
|
|
133
|
+
hostGrantEndpoint?: string;
|
|
134
|
+
/**
|
|
135
|
+
* Maximum number of players allowed in a room.
|
|
136
|
+
* @default 8
|
|
137
|
+
*/
|
|
138
|
+
maxPlayers?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Declares whether this host provider owns a standalone game room or a system shell room.
|
|
141
|
+
* Standalone games should use `"game"`; Arcade shell hosts should use `"system"`.
|
|
142
|
+
* @default "game"
|
|
143
|
+
*/
|
|
144
|
+
hostSessionKind?: HostSessionKind;
|
|
145
|
+
/**
|
|
146
|
+
* Enable environment-variable fallback resolution for config fields.
|
|
147
|
+
* Set to false to require explicit `topology` / `appId` / `hostGrantEndpoint`.
|
|
148
|
+
* @default true
|
|
149
|
+
*/
|
|
150
|
+
resolveEnv?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Input handling configuration including Zod schema validation and field behavior.
|
|
153
|
+
* When provided, enables typed input with tap-safe defaults:
|
|
154
|
+
* - booleans => `pulse`
|
|
155
|
+
* - vectors => `latest`
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* input={{
|
|
160
|
+
* schema: z.object({
|
|
161
|
+
* vector: z.object({ x: z.number(), y: z.number() }),
|
|
162
|
+
* action: z.boolean(),
|
|
163
|
+
* ability: z.boolean(),
|
|
164
|
+
* }),
|
|
165
|
+
* behavior: {
|
|
166
|
+
* pulse: ["action", "ability"], // consume-on-read actions
|
|
167
|
+
* latest: ["vector"], // continuous movement
|
|
168
|
+
* },
|
|
169
|
+
* }}
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
input?: InputConfig<TSchema>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type { AirJamProviderProps as A };
|