@air-jam/sdk 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arcade/bridge/controller.cjs +1 -1
- package/dist/arcade/bridge/controller.js +2 -2
- package/dist/arcade/bridge/host.cjs +1 -1
- package/dist/arcade/bridge/host.js +2 -2
- package/dist/arcade/bridge/iframe.cjs +1 -1
- package/dist/arcade/bridge/iframe.js +5 -5
- package/dist/arcade/bridge.cjs +1 -1
- package/dist/arcade/bridge.js +8 -8
- package/dist/arcade/host.cjs +0 -7
- package/dist/arcade/host.cjs.map +1 -1
- package/dist/arcade/host.js +4 -3
- package/dist/arcade/url.cjs +183 -2
- package/dist/arcade/url.cjs.map +1 -1
- package/dist/arcade/url.d.cts +1 -1
- package/dist/arcade/url.d.ts +1 -1
- package/dist/arcade/url.js +5 -4
- package/dist/arcade.cjs +184 -12
- package/dist/arcade.cjs.map +1 -1
- package/dist/arcade.d.cts +1 -1
- package/dist/arcade.d.ts +1 -1
- package/dist/arcade.js +22 -21
- package/dist/{chunk-VN5LDWVN.js → chunk-7UXSWCZZ.js} +2 -2
- package/dist/{chunk-VDRNNGHX.js → chunk-CABEUV65.js} +9 -9
- package/dist/{chunk-VDRNNGHX.js.map → chunk-CABEUV65.js.map} +1 -1
- package/dist/{chunk-D3X4MN4U.js → chunk-CEJ5RFSG.js} +2 -2
- package/dist/{chunk-XLUWV45V.js → chunk-EDRQIOCV.js} +2 -2
- package/dist/{chunk-Y4RAPKKB.js → chunk-FAT2KJ3K.js} +2 -2
- package/dist/{chunk-CQUG24WX.js → chunk-JEHV5C2X.js} +2 -2
- package/dist/{chunk-2J65FXEP.js → chunk-JO2HR5PV.js} +6 -4
- package/dist/chunk-JO2HR5PV.js.map +1 -0
- package/dist/{chunk-2432OL7L.js → chunk-KXAFI5OP.js} +2 -2
- package/dist/{chunk-HFWRZVZ3.js → chunk-NUJBMV3O.js} +13 -16
- package/dist/chunk-NUJBMV3O.js.map +1 -0
- package/dist/chunk-UWJOIVON.js +369 -0
- package/dist/chunk-UWJOIVON.js.map +1 -0
- package/dist/{chunk-MKBASO6X.js → chunk-VKBMZHMQ.js} +2 -2
- package/dist/{chunk-NU5W6VAV.js → chunk-W3YA5BWR.js} +3 -3
- package/dist/index.cjs +344 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -20
- package/dist/index.js.map +1 -1
- package/dist/preview.cjs +22 -11
- package/dist/preview.cjs.map +1 -1
- package/dist/preview.d.cts +1 -1
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +12 -12
- package/dist/preview.js.map +1 -1
- package/dist/runtime-topology.cjs +405 -0
- package/dist/runtime-topology.cjs.map +1 -0
- package/dist/runtime-topology.d.cts +59 -0
- package/dist/runtime-topology.d.ts +59 -0
- package/dist/runtime-topology.js +31 -0
- package/dist/runtime-topology.js.map +1 -0
- package/dist/ui.cjs +246 -12
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.js +9 -8
- package/dist/ui.js.map +1 -1
- package/package.json +10 -3
- package/src/arcade/url.ts +2 -2
- package/src/context/air-jam-context.tsx +2 -2
- package/src/dev/browser-log-sink.ts +1 -1
- package/src/preview/ownership.ts +1 -1
- package/src/runtime/air-jam-config.ts +1 -1
- package/src/runtime/create-air-jam-app.tsx +2 -2
- package/src/runtime/embedded-runtime-adapters.ts +1 -1
- package/src/runtime/runtime-session-params.ts +2 -2
- package/src/runtime-topology.ts +569 -0
- package/dist/chunk-2J65FXEP.js.map +0 -1
- package/dist/chunk-HFWRZVZ3.js.map +0 -1
- /package/dist/{chunk-VN5LDWVN.js.map → chunk-7UXSWCZZ.js.map} +0 -0
- /package/dist/{chunk-D3X4MN4U.js.map → chunk-CEJ5RFSG.js.map} +0 -0
- /package/dist/{chunk-XLUWV45V.js.map → chunk-EDRQIOCV.js.map} +0 -0
- /package/dist/{chunk-Y4RAPKKB.js.map → chunk-FAT2KJ3K.js.map} +0 -0
- /package/dist/{chunk-CQUG24WX.js.map → chunk-JEHV5C2X.js.map} +0 -0
- /package/dist/{chunk-2432OL7L.js.map → chunk-KXAFI5OP.js.map} +0 -0
- /package/dist/{chunk-MKBASO6X.js.map → chunk-VKBMZHMQ.js.map} +0 -0
- /package/dist/{chunk-NU5W6VAV.js.map → chunk-W3YA5BWR.js.map} +0 -0
package/dist/arcade/url.cjs
CHANGED
|
@@ -29,7 +29,188 @@ __export(url_exports, {
|
|
|
29
29
|
urlBuilder: () => urlBuilder
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(url_exports);
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
// src/runtime-topology.ts
|
|
34
|
+
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
35
|
+
"standalone-dev",
|
|
36
|
+
"standalone-secure",
|
|
37
|
+
"arcade-live",
|
|
38
|
+
"arcade-built",
|
|
39
|
+
"self-hosted-production",
|
|
40
|
+
"hosted-release"
|
|
41
|
+
]);
|
|
42
|
+
var SURFACE_ROLES = /* @__PURE__ */ new Set([
|
|
43
|
+
"host",
|
|
44
|
+
"controller",
|
|
45
|
+
"platform-host",
|
|
46
|
+
"platform-controller"
|
|
47
|
+
]);
|
|
48
|
+
var PROXY_STRATEGIES = /* @__PURE__ */ new Set([
|
|
49
|
+
"none",
|
|
50
|
+
"platform-proxy",
|
|
51
|
+
"dev-proxy"
|
|
52
|
+
]);
|
|
53
|
+
var AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX = "aj_topology_";
|
|
54
|
+
var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
55
|
+
var assertString = (value, fieldName) => {
|
|
56
|
+
if (typeof value !== "string") {
|
|
57
|
+
throw new Error(`Runtime topology field "${fieldName}" must be a string.`);
|
|
58
|
+
}
|
|
59
|
+
const normalized = value.trim();
|
|
60
|
+
if (!normalized) {
|
|
61
|
+
throw new Error(`Runtime topology field "${fieldName}" cannot be empty.`);
|
|
62
|
+
}
|
|
63
|
+
return normalized;
|
|
64
|
+
};
|
|
65
|
+
var assertBoolean = (value, fieldName) => {
|
|
66
|
+
if (typeof value !== "boolean") {
|
|
67
|
+
throw new Error(`Runtime topology field "${fieldName}" must be a boolean.`);
|
|
68
|
+
}
|
|
69
|
+
return value;
|
|
70
|
+
};
|
|
71
|
+
var assertUrl = (value, fieldName) => {
|
|
72
|
+
const normalized = assertString(value, fieldName);
|
|
73
|
+
const withScheme = normalized.includes("://") ? normalized : `http://${normalized}`;
|
|
74
|
+
let parsed;
|
|
75
|
+
try {
|
|
76
|
+
parsed = new URL(withScheme);
|
|
77
|
+
} catch {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Runtime topology field "${fieldName}" must be a valid absolute URL.`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Runtime topology field "${fieldName}" must use http or https.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
parsed.pathname = "";
|
|
88
|
+
parsed.search = "";
|
|
89
|
+
parsed.hash = "";
|
|
90
|
+
return parsed.origin;
|
|
91
|
+
};
|
|
92
|
+
var normalizeAssetBasePath = (value) => {
|
|
93
|
+
if (value == null) {
|
|
94
|
+
return "/";
|
|
95
|
+
}
|
|
96
|
+
const normalized = assertString(value, "assetBasePath");
|
|
97
|
+
if (normalized === "/") {
|
|
98
|
+
return normalized;
|
|
99
|
+
}
|
|
100
|
+
const withLeadingSlash = normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
101
|
+
return withLeadingSlash.endsWith("/") && withLeadingSlash.length > 1 ? withLeadingSlash.slice(0, -1) : withLeadingSlash;
|
|
102
|
+
};
|
|
103
|
+
var toBooleanParam = (value) => value ? "true" : "false";
|
|
104
|
+
var resolveDefaultSocketOrigin = ({
|
|
105
|
+
proxyStrategy,
|
|
106
|
+
appOrigin,
|
|
107
|
+
backendOrigin
|
|
108
|
+
}) => {
|
|
109
|
+
if (proxyStrategy === "none") {
|
|
110
|
+
return backendOrigin;
|
|
111
|
+
}
|
|
112
|
+
return appOrigin;
|
|
113
|
+
};
|
|
114
|
+
var inferSecureTransport = ({
|
|
115
|
+
runtimeMode,
|
|
116
|
+
appOrigin,
|
|
117
|
+
backendOrigin,
|
|
118
|
+
socketOrigin,
|
|
119
|
+
publicHost
|
|
120
|
+
}) => {
|
|
121
|
+
if (runtimeMode === "standalone-secure") {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
return [appOrigin, backendOrigin, socketOrigin, publicHost].every(
|
|
125
|
+
(origin) => origin.startsWith("https://")
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
var resolveRuntimeTopology = (input) => {
|
|
129
|
+
if (!isObject(input)) {
|
|
130
|
+
throw new Error("Runtime topology input must be an object.");
|
|
131
|
+
}
|
|
132
|
+
const runtimeMode = assertString(
|
|
133
|
+
input.runtimeMode,
|
|
134
|
+
"runtimeMode"
|
|
135
|
+
);
|
|
136
|
+
if (!RUNTIME_MODES.has(runtimeMode)) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`Unsupported runtime mode "${runtimeMode}". Use one of: ${Array.from(RUNTIME_MODES).join(", ")}.`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
const surfaceRole = assertString(
|
|
142
|
+
input.surfaceRole,
|
|
143
|
+
"surfaceRole"
|
|
144
|
+
);
|
|
145
|
+
if (!SURFACE_ROLES.has(surfaceRole)) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
`Unsupported surface role "${surfaceRole}". Use one of: ${Array.from(SURFACE_ROLES).join(", ")}.`
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
const appOrigin = assertUrl(input.appOrigin, "appOrigin");
|
|
151
|
+
const backendOrigin = assertUrl(input.backendOrigin, "backendOrigin");
|
|
152
|
+
const proxyStrategy = input.proxyStrategy == null ? "none" : assertString(input.proxyStrategy, "proxyStrategy");
|
|
153
|
+
if (!PROXY_STRATEGIES.has(proxyStrategy)) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
`Unsupported proxy strategy "${proxyStrategy}". Use one of: ${Array.from(PROXY_STRATEGIES).join(", ")}.`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
const socketOrigin = input.socketOrigin != null ? assertUrl(input.socketOrigin, "socketOrigin") : resolveDefaultSocketOrigin({ proxyStrategy, appOrigin, backendOrigin });
|
|
159
|
+
const publicHost = input.publicHost != null ? assertUrl(input.publicHost, "publicHost") : appOrigin;
|
|
160
|
+
const assetBasePath = normalizeAssetBasePath(input.assetBasePath);
|
|
161
|
+
const embedded = input.embedded == null ? false : assertBoolean(input.embedded, "embedded");
|
|
162
|
+
const embedParentOrigin = input.embedParentOrigin == null ? void 0 : assertUrl(input.embedParentOrigin, "embedParentOrigin");
|
|
163
|
+
if (embedded && !embedParentOrigin) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
'Embedded runtimes must provide "embedParentOrigin" in their topology.'
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
if (!embedded && embedParentOrigin) {
|
|
169
|
+
throw new Error(
|
|
170
|
+
'Non-embedded runtimes cannot provide "embedParentOrigin" in their topology.'
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
const secureTransport = input.secureTransport == null ? inferSecureTransport({
|
|
174
|
+
runtimeMode,
|
|
175
|
+
appOrigin,
|
|
176
|
+
backendOrigin,
|
|
177
|
+
socketOrigin,
|
|
178
|
+
publicHost
|
|
179
|
+
}) : assertBoolean(input.secureTransport, "secureTransport");
|
|
180
|
+
return {
|
|
181
|
+
runtimeMode,
|
|
182
|
+
surfaceRole,
|
|
183
|
+
appOrigin,
|
|
184
|
+
backendOrigin,
|
|
185
|
+
socketOrigin,
|
|
186
|
+
publicHost,
|
|
187
|
+
assetBasePath,
|
|
188
|
+
secureTransport,
|
|
189
|
+
embedded,
|
|
190
|
+
...embedParentOrigin ? { embedParentOrigin } : {},
|
|
191
|
+
proxyStrategy
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
var runtimeTopologyToQueryParams = (topology) => {
|
|
195
|
+
const resolved = resolveRuntimeTopology(topology);
|
|
196
|
+
return {
|
|
197
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}runtime_mode`]: resolved.runtimeMode,
|
|
198
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}surface_role`]: resolved.surfaceRole,
|
|
199
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}app_origin`]: resolved.appOrigin,
|
|
200
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}backend_origin`]: resolved.backendOrigin,
|
|
201
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}socket_origin`]: resolved.socketOrigin,
|
|
202
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}public_host`]: resolved.publicHost,
|
|
203
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}asset_base_path`]: resolved.assetBasePath,
|
|
204
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}secure_transport`]: toBooleanParam(resolved.secureTransport),
|
|
205
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embedded`]: toBooleanParam(
|
|
206
|
+
resolved.embedded
|
|
207
|
+
),
|
|
208
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}proxy_strategy`]: resolved.proxyStrategy,
|
|
209
|
+
...resolved.embedParentOrigin ? {
|
|
210
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embed_parent_origin`]: resolved.embedParentOrigin
|
|
211
|
+
} : {}
|
|
212
|
+
};
|
|
213
|
+
};
|
|
33
214
|
|
|
34
215
|
// src/protocol/url-policy.ts
|
|
35
216
|
var import_zod = require("zod");
|
|
@@ -336,7 +517,7 @@ var buildArcadeGameIframeSrc = ({
|
|
|
336
517
|
aj_cap: launchCapability.token,
|
|
337
518
|
aj_cap_exp: String(launchCapability.expiresAt),
|
|
338
519
|
aj_join_url: joinUrl,
|
|
339
|
-
...
|
|
520
|
+
...runtimeTopologyToQueryParams(topology),
|
|
340
521
|
...arcadeSurfaceRuntimeUrlParams(arcadeSurface)
|
|
341
522
|
});
|
|
342
523
|
var buildArcadeControllerRuntimeUrl = (normalizedUrl) => {
|
package/dist/arcade/url.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/arcade/url.ts","../../src/protocol/url-policy.ts","../../src/runtime/arcade-runtime-url.ts","../../src/runtime/arcade-surface-identity.ts","../../src/constants.ts","../../src/utils/network-ip.ts","../../src/utils/url-builder.ts"],"sourcesContent":["import type { ResolvedAirJamRuntimeTopology } from \"@air-jam/runtime-topology\";\nimport { runtimeTopologyToQueryParams } from \"@air-jam/runtime-topology\";\nimport type { ChildHostCapability } from \"../protocol\";\nimport {\n appendRuntimeQueryParams,\n getRuntimeUrlOrigin,\n normalizeRuntimeUrl,\n} from \"../protocol/url-policy\";\nimport {\n arcadeSurfaceRuntimeUrlParams,\n type ArcadeSurfaceRuntimeIdentity,\n} from \"./surface\";\nexport { urlBuilder } from \"../utils/url-builder\";\nexport { arcadeSurfaceRuntimeUrlParams } from \"./surface\";\nexport { appendRuntimeQueryParams, getRuntimeUrlOrigin, normalizeRuntimeUrl };\n\nexport const buildArcadeGameIframeSrc = ({\n normalizedUrl,\n roomId,\n launchCapability,\n joinUrl,\n topology,\n arcadeSurface,\n}: {\n normalizedUrl: string;\n roomId: string;\n launchCapability: ChildHostCapability;\n joinUrl?: string | null;\n topology: ResolvedAirJamRuntimeTopology;\n arcadeSurface: ArcadeSurfaceRuntimeIdentity;\n}): string | null =>\n appendRuntimeQueryParams(normalizedUrl, {\n aj_room: roomId,\n aj_cap: launchCapability.token,\n aj_cap_exp: String(launchCapability.expiresAt),\n aj_join_url: joinUrl,\n ...runtimeTopologyToQueryParams(topology),\n ...arcadeSurfaceRuntimeUrlParams(arcadeSurface),\n });\n\nexport const buildArcadeControllerRuntimeUrl = (\n normalizedUrl: string,\n): string | null => {\n try {\n const runtimeUrl = new URL(normalizedUrl);\n const trimmedPath =\n runtimeUrl.pathname !== \"/\" && runtimeUrl.pathname.endsWith(\"/\")\n ? runtimeUrl.pathname.slice(0, -1)\n : runtimeUrl.pathname;\n const pathSegments = trimmedPath.split(\"/\").filter(Boolean);\n const controllerPath =\n trimmedPath === \"/\" || pathSegments.length <= 1\n ? \"/controller\"\n : `${trimmedPath}/controller`;\n\n return new URL(controllerPath, runtimeUrl.origin).toString();\n } catch {\n return null;\n }\n};\n","import { z } from \"zod\";\n\nconst ALLOWED_RUNTIME_PROTOCOLS = new Set([\"http:\", \"https:\"]);\n\nconst parseRuntimeUrl = (value: string): URL | null => {\n try {\n const parsed = new URL(value);\n if (!ALLOWED_RUNTIME_PROTOCOLS.has(parsed.protocol)) {\n return null;\n }\n if (parsed.username || parsed.password) {\n return null;\n }\n return parsed;\n } catch {\n return null;\n }\n};\n\nexport const normalizeRuntimeUrl = (value: string): string | null => {\n const parsed = parseRuntimeUrl(value);\n return parsed ? parsed.toString() : null;\n};\n\nexport const getRuntimeUrlOrigin = (value: string): string | null => {\n const parsed = parseRuntimeUrl(value);\n return parsed ? parsed.origin : null;\n};\n\nexport const runtimeUrlSchema = z\n .string()\n .trim()\n .min(1)\n .refine((value) => parseRuntimeUrl(value) !== null, {\n message: \"URL must be a valid http(s) URL without embedded credentials.\",\n });\n\nexport const appendRuntimeQueryParams = (\n baseUrl: string,\n params: Record<string, string | null | undefined>,\n): string | null => {\n const parsed = parseRuntimeUrl(baseUrl);\n if (!parsed) {\n return null;\n }\n\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null || value === \"\") {\n continue;\n }\n parsed.searchParams.set(key, value);\n }\n\n return parsed.toString();\n};\n\nexport const isTrustedRuntimeMessageOrigin = (\n runtimeUrl: string,\n messageOrigin: string,\n): boolean => {\n const runtimeOrigin = getRuntimeUrlOrigin(runtimeUrl);\n return runtimeOrigin !== null && runtimeOrigin === messageOrigin;\n};\n","import { AIR_JAM_DEFAULT_STORE_DOMAIN } from \"../store/air-jam-store-domain-constants\";\nimport type { ArcadeSurfaceRuntimeIdentity } from \"./arcade-surface-identity\";\n\n/**\n * Query param for the canonical replicated store domain in embedded runtimes.\n * When set, {@link resolveImplicitReplicatedStoreDomainFromSearchParams} prefers it over derivation from `aj_arcade_*`.\n */\nexport const AIRJAM_STORE_DOMAIN_URL_PARAM = \"aj_store_domain\";\n\nconst clampStoreDomain = (value: string): string =>\n value.length > 128 ? value.slice(0, 128) : value;\n\n/**\n * Stable replicated store domain for an embedded Arcade surface identity (epoch-bound).\n * Used for host/controller `createAirJamStore` in iframes so shell `default` and prior runs do not collide.\n */\nexport const embeddedReplicatedStoreDomainFromArcadeIdentity = (\n identity: ArcadeSurfaceRuntimeIdentity,\n): string => {\n if (identity.kind === \"game\") {\n const gameKey = identity.gameId ?? \"_\";\n return clampStoreDomain(`aj.embedded.game:${identity.epoch}:${gameKey}`);\n }\n return clampStoreDomain(`aj.embedded.browser:${identity.epoch}`);\n};\n\n/**\n * Query params used to pass {@link ArcadeSurfaceRuntimeIdentity} and replicated store domain into embedded iframes.\n */\nexport const arcadeSurfaceRuntimeUrlParams = (\n identity: ArcadeSurfaceRuntimeIdentity,\n): Record<string, string> => ({\n aj_arcade_epoch: String(identity.epoch),\n aj_arcade_kind: identity.kind,\n ...(identity.gameId != null ? { aj_arcade_game_id: identity.gameId } : {}),\n [AIRJAM_STORE_DOMAIN_URL_PARAM]:\n embeddedReplicatedStoreDomainFromArcadeIdentity(identity),\n});\n\nexport const parseOptionalArcadeSurfaceFromSearchParams = (\n params: URLSearchParams,\n): ArcadeSurfaceRuntimeIdentity | undefined => {\n const epochStr = params.get(\"aj_arcade_epoch\");\n const kind = params.get(\"aj_arcade_kind\");\n if (epochStr === null || (kind !== \"browser\" && kind !== \"game\")) {\n return undefined;\n }\n\n const epoch = Number(epochStr);\n if (!Number.isFinite(epoch) || epoch < 0 || !Number.isInteger(epoch)) {\n return undefined;\n }\n\n const gameIdRaw = params.get(\"aj_arcade_game_id\");\n const gameId =\n kind === \"browser\"\n ? null\n : gameIdRaw && gameIdRaw.length > 0\n ? gameIdRaw\n : null;\n\n return { epoch, kind, gameId };\n};\n\n/**\n * Resolves the implicit networked store domain from the current URL (embedded) or {@link AIR_JAM_DEFAULT_STORE_DOMAIN}.\n * Prefer {@link AIRJAM_STORE_DOMAIN_URL_PARAM} when present; otherwise derive from `aj_arcade_*` when valid.\n */\nexport const resolveImplicitReplicatedStoreDomainFromSearchParams = (\n params: URLSearchParams,\n): string => {\n const explicit = params.get(AIRJAM_STORE_DOMAIN_URL_PARAM)?.trim();\n if (explicit && explicit.length > 0) {\n return clampStoreDomain(explicit);\n }\n\n const surface = parseOptionalArcadeSurfaceFromSearchParams(params);\n if (surface) {\n return embeddedReplicatedStoreDomainFromArcadeIdentity(surface);\n }\n\n return AIR_JAM_DEFAULT_STORE_DOMAIN;\n};\n\n/**\n * Browser-only resolver for implicit store domain (SSR-safe: returns default without `window`).\n */\nexport const resolveImplicitReplicatedStoreDomainFromWindow = (): string => {\n if (typeof window === \"undefined\") {\n return AIR_JAM_DEFAULT_STORE_DOMAIN;\n }\n return resolveImplicitReplicatedStoreDomainFromSearchParams(\n new URLSearchParams(window.location.search),\n );\n};\n","import { z } from \"zod\";\n\n/**\n * Minimum Arcade surface identity for embedded runtime bridge attach (see docs/systems/arcade-surface-contract.md).\n */\nexport const arcadeSurfaceRuntimeIdentitySchema = z\n .object({\n epoch: z.number().int().nonnegative(),\n kind: z.enum([\"browser\", \"game\"]),\n gameId: z.string().nullable(),\n })\n .strict();\n\nexport type ArcadeSurfaceRuntimeIdentity = z.infer<\n typeof arcadeSurfaceRuntimeIdentitySchema\n>;\n","/**\n * Core Air Jam constants used across the SDK\n */\n\n/**\n * Default server port for Air Jam server\n */\nexport const DEFAULT_SERVER_PORT = 4000;\n\n/**\n * Standard path for controller endpoints.\n * All Air Jam games use this convention - controller is always at {baseUrl}/controller\n */\nexport const CONTROLLER_PATH = \"/controller\";\n\n/**\n * Input debounce time in milliseconds\n * Used to prevent rapid input events from overwhelming the system\n */\nexport const INPUT_DEBOUNCE_MS = 200;\n\n/**\n * Toggle debounce time in milliseconds\n * Used for game state toggles to prevent accidental double-toggles\n */\nexport const TOGGLE_DEBOUNCE_MS = 300;\n\n/**\n * Socket.IO configuration\n */\nexport const SOCKET_CONFIG = {\n /**\n * Ping interval in milliseconds\n */\n PING_INTERVAL: 2000,\n\n /**\n * Ping timeout in milliseconds\n */\n PING_TIMEOUT: 5000,\n} as const;\n\n/**\n * Maximum players allowed in a room by default\n */\nexport const DEFAULT_MAX_PLAYERS = 8;\n","/**\n * Checks if an IP is from a virtual network interface (Docker, VMs, etc.)\n */\nconst isVirtualNetwork = (ip: string): boolean => {\n // Docker Desktop on Mac uses 192.168.64.x and 192.168.65.x\n if (ip.startsWith(\"192.168.64.\") || ip.startsWith(\"192.168.65.\")) {\n return true;\n }\n // Docker default bridge network\n if (ip.startsWith(\"172.17.\")) {\n return true;\n }\n // Other common virtual network ranges\n if (ip.startsWith(\"172.18.\") || ip.startsWith(\"172.19.\")) {\n return true;\n }\n // Link-local addresses\n if (ip.startsWith(\"169.254.\")) {\n return true;\n }\n return false;\n};\n\n/**\n * Scores an IP address to determine preference.\n * Higher score = more preferred.\n */\nconst scoreIp = (ip: string): number => {\n // Prefer 192.168.0.x - 192.168.63.x (common home network ranges, excluding virtual networks)\n if (ip.startsWith(\"192.168.\")) {\n const parts = ip.split(\".\");\n const thirdOctet = parseInt(parts[2] || \"0\", 10);\n // Prefer lower third octets (0-63) as they're more likely to be real networks\n if (thirdOctet < 64) {\n return 100 - thirdOctet; // Higher score for lower numbers\n }\n // 64+ are often virtual, but we'll still consider them if nothing else\n return 10;\n }\n // Prefer 10.x.x.x networks\n if (ip.startsWith(\"10.\")) {\n return 50;\n }\n // 172.16-31.x.x networks (but not 172.17.x.x which is Docker)\n if (/^172\\.(1[6-9]|2[0-9]|3[01])\\./.test(ip)) {\n return 30;\n }\n return 0;\n};\n\n/**\n * Gets the local network IP address using WebRTC.\n * Filters out virtual network interfaces and prefers real network IPs.\n * Returns null if unable to determine the IP.\n */\nexport const getLocalNetworkIp = (): Promise<string | null> => {\n return new Promise((resolve) => {\n // If not in browser, return null\n if (\n typeof window === \"undefined\" ||\n typeof RTCPeerConnection === \"undefined\"\n ) {\n resolve(null);\n return;\n }\n\n const pc = new RTCPeerConnection({\n iceServers: [{ urls: \"stun:stun.l.google.com:19302\" }],\n });\n\n const candidates: Array<{ ip: string; score: number }> = [];\n let candidateGatheringComplete = false;\n\n const resolveOnce = (ip: string | null) => {\n pc.close();\n resolve(ip);\n };\n\n // Timeout after 3 seconds\n const timeout = setTimeout(() => {\n if (candidateGatheringComplete) {\n pickBestCandidate();\n } else {\n // Wait a bit more for candidates to arrive\n setTimeout(() => {\n pickBestCandidate();\n }, 500);\n }\n }, 3000);\n\n const pickBestCandidate = () => {\n if (candidates.length === 0) {\n resolveOnce(null);\n return;\n }\n\n // Sort by score (highest first), then pick the best one\n candidates.sort((a, b) => b.score - a.score);\n const best = candidates[0];\n clearTimeout(timeout);\n resolveOnce(best.ip);\n };\n\n pc.onicecandidate = (event) => {\n if (event.candidate) {\n const candidate = event.candidate.candidate;\n const match = candidate.match(/([0-9]{1,3}(\\.[0-9]{1,3}){3})/);\n if (match) {\n const ip = match[1];\n // Filter out localhost\n if (ip === \"127.0.0.1\") {\n return;\n }\n\n // Check if it's a private network IP\n const isPrivate =\n ip.startsWith(\"192.168.\") ||\n ip.startsWith(\"10.\") ||\n /^172\\.(1[6-9]|2[0-9]|3[01])\\./.test(ip);\n\n if (isPrivate && !isVirtualNetwork(ip)) {\n const score = scoreIp(ip);\n candidates.push({ ip, score });\n }\n }\n } else {\n // No more candidates - gathering is complete\n candidateGatheringComplete = true;\n // Give it a moment for any last candidates to arrive, then pick the best\n setTimeout(() => {\n pickBestCandidate();\n }, 200);\n }\n };\n\n // Create a data channel to trigger candidate gathering\n pc.createDataChannel(\"\");\n pc.createOffer()\n .then((offer) => pc.setLocalDescription(offer))\n .catch(() => {\n clearTimeout(timeout);\n resolveOnce(null);\n });\n });\n};\n","import { CONTROLLER_PATH, DEFAULT_SERVER_PORT } from \"../constants\";\nimport type { RoomCode } from \"../protocol\";\nimport { getLocalNetworkIp } from \"./network-ip\";\n\n/**\n * Centralized URL builder service for Air Jam.\n * Handles IP detection, URL normalization, and construction of all URL types.\n */\nclass UrlBuilder {\n private cachedLocalIp: string | null = null;\n private ipDetectionPromise: Promise<string | null> | null = null;\n\n /**\n * Get the local network IP address with caching.\n * First call triggers detection, subsequent calls return cached value.\n */\n async getLocalIp(): Promise<string | null> {\n // Return cached value if available\n if (this.cachedLocalIp !== null) {\n return this.cachedLocalIp;\n }\n\n // If detection is already in progress, wait for it\n if (this.ipDetectionPromise !== null) {\n return this.ipDetectionPromise;\n }\n\n // Start IP detection\n this.ipDetectionPromise = getLocalNetworkIp().then((ip) => {\n this.cachedLocalIp = ip;\n this.ipDetectionPromise = null;\n return ip;\n });\n\n return this.ipDetectionPromise;\n }\n\n /**\n * Clear the cached IP address.\n * Useful for testing or when network changes are detected.\n */\n clearCache(): void {\n this.cachedLocalIp = null;\n this.ipDetectionPromise = null;\n }\n\n /**\n * Normalize a URL for mobile access.\n * Replaces localhost with the local network IP.\n */\n async normalizeForMobile(url: string): Promise<string> {\n if (typeof window === \"undefined\") return url;\n\n try {\n const urlObj = new URL(url);\n\n // If URL uses localhost, replace with local network IP\n if (urlObj.hostname === \"localhost\" || urlObj.hostname === \"127.0.0.1\") {\n const localIp = await this.getLocalIp();\n\n if (localIp) {\n urlObj.hostname = localIp;\n return urlObj.toString();\n }\n\n // Fallback to current hostname if IP detection fails\n urlObj.hostname = window.location.hostname;\n return urlObj.toString();\n }\n\n return url;\n } catch {\n return url;\n }\n }\n\n /**\n * Build a controller URL with room code.\n * Controller is always at {baseUrl}/controller (standardized convention).\n * Automatically uses local IP when running on localhost.\n */\n async buildControllerUrl(\n roomId: RoomCode,\n options?: {\n host?: string;\n capabilityToken?: string;\n },\n ): Promise<string> {\n const path = CONTROLLER_PATH;\n\n // If explicit host is provided, use it\n if (options?.host) {\n const url = new URL(path, this.normalizeOrigin(options.host));\n url.searchParams.set(\"room\", roomId);\n if (options.capabilityToken) {\n url.searchParams.set(\"aj_controller_cap\", options.capabilityToken);\n }\n return url.toString();\n }\n\n // Determine base URL\n let base: string;\n if (typeof window === \"undefined\") {\n base = `http://localhost:${DEFAULT_SERVER_PORT}`;\n } else {\n const currentUrl = new URL(window.location.href);\n\n // If not localhost, use the current origin\n if (!this.isLocalhost(currentUrl.hostname)) {\n base = currentUrl.origin;\n } else {\n // If localhost, try to get the local network IP\n const localIp = await this.getLocalIp();\n if (localIp) {\n // Preserve the port from the current URL\n const port = currentUrl.port;\n base = port ? `http://${localIp}:${port}` : `http://${localIp}`;\n } else {\n // Fallback to localhost if we can't determine the IP\n base = currentUrl.origin;\n }\n }\n }\n\n const url = new URL(path, base);\n url.searchParams.set(\"room\", roomId);\n if (options?.capabilityToken) {\n url.searchParams.set(\"aj_controller_cap\", options.capabilityToken);\n }\n return url.toString();\n }\n\n /**\n * Resolve the server URL.\n * Uses explicit URL if provided, otherwise infers from window location.\n */\n resolveServerUrl(explicit?: string): string {\n if (explicit) {\n return this.normalizeOrigin(explicit);\n }\n\n if (typeof window !== \"undefined\") {\n const url = new URL(window.location.href);\n url.port = String(DEFAULT_SERVER_PORT);\n return url.origin;\n }\n\n return `http://localhost:${DEFAULT_SERVER_PORT}`;\n }\n\n /**\n * Check if a hostname is localhost.\n */\n private isLocalhost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n }\n\n /**\n * Normalize an origin string to ensure it has a protocol.\n */\n private normalizeOrigin(origin: string): string {\n if (!origin.includes(\"://\")) {\n return `http://${origin}`;\n }\n return origin;\n }\n}\n\n// Export singleton instance\nexport const urlBuilder = new UrlBuilder();\n\n// Export class for testing/advanced usage\nexport { UrlBuilder };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA6C;;;ACD7C,iBAAkB;AAElB,IAAM,4BAA4B,oBAAI,IAAI,CAAC,SAAS,QAAQ,CAAC;AAE7D,IAAM,kBAAkB,CAAC,UAA8B;AACrD,MAAI;AACF,UAAM,SAAS,IAAI,IAAI,KAAK;AAC5B,QAAI,CAAC,0BAA0B,IAAI,OAAO,QAAQ,GAAG;AACnD,aAAO;AAAA,IACT;AACA,QAAI,OAAO,YAAY,OAAO,UAAU;AACtC,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,IAAM,sBAAsB,CAAC,UAAiC;AACnE,QAAM,SAAS,gBAAgB,KAAK;AACpC,SAAO,SAAS,OAAO,SAAS,IAAI;AACtC;AAEO,IAAM,sBAAsB,CAAC,UAAiC;AACnE,QAAM,SAAS,gBAAgB,KAAK;AACpC,SAAO,SAAS,OAAO,SAAS;AAClC;AAEO,IAAM,mBAAmB,aAC7B,OAAO,EACP,KAAK,EACL,IAAI,CAAC,EACL,OAAO,CAAC,UAAU,gBAAgB,KAAK,MAAM,MAAM;AAAA,EAClD,SAAS;AACX,CAAC;AAEI,IAAM,2BAA2B,CACtC,SACA,WACkB;AAClB,QAAM,SAAS,gBAAgB,OAAO;AACtC,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,KAAK,KAAK,K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;AACxC,UAAM,cACJ,WAAW,aAAa,OAAO,WAAW,SAAS,SAAS,GAAG,IAC3D,WAAW,SAAS,MAAM,GAAG,EAAE,IAC/B,WAAW;AACjB,UAAM,eAAe,YAAY,MAAM,GAAG,EAAE,OAAO,OAAO;AAC1D,UAAM,iBACJ,gBAAgB,OAAO,aAAa,UAAU,IAC1C,gBACA,GAAG,WAAW;AAEpB,WAAO,IAAI,IAAI,gBAAgB,WAAW,MAAM,EAAE,SAAS;AAAA,EAC7D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":["import_zod","url"]}
|
|
1
|
+
{"version":3,"sources":["../../src/arcade/url.ts","../../src/runtime-topology.ts","../../src/protocol/url-policy.ts","../../src/runtime/arcade-runtime-url.ts","../../src/runtime/arcade-surface-identity.ts","../../src/constants.ts","../../src/utils/network-ip.ts","../../src/utils/url-builder.ts"],"sourcesContent":["import type { ResolvedAirJamRuntimeTopology } from \"../runtime-topology\";\nimport { runtimeTopologyToQueryParams } from \"../runtime-topology\";\nimport type { ChildHostCapability } from \"../protocol\";\nimport {\n appendRuntimeQueryParams,\n getRuntimeUrlOrigin,\n normalizeRuntimeUrl,\n} from \"../protocol/url-policy\";\nimport {\n arcadeSurfaceRuntimeUrlParams,\n type ArcadeSurfaceRuntimeIdentity,\n} from \"./surface\";\nexport { urlBuilder } from \"../utils/url-builder\";\nexport { arcadeSurfaceRuntimeUrlParams } from \"./surface\";\nexport { appendRuntimeQueryParams, getRuntimeUrlOrigin, normalizeRuntimeUrl };\n\nexport const buildArcadeGameIframeSrc = ({\n normalizedUrl,\n roomId,\n launchCapability,\n joinUrl,\n topology,\n arcadeSurface,\n}: {\n normalizedUrl: string;\n roomId: string;\n launchCapability: ChildHostCapability;\n joinUrl?: string | null;\n topology: ResolvedAirJamRuntimeTopology;\n arcadeSurface: ArcadeSurfaceRuntimeIdentity;\n}): string | null =>\n appendRuntimeQueryParams(normalizedUrl, {\n aj_room: roomId,\n aj_cap: launchCapability.token,\n aj_cap_exp: String(launchCapability.expiresAt),\n aj_join_url: joinUrl,\n ...runtimeTopologyToQueryParams(topology),\n ...arcadeSurfaceRuntimeUrlParams(arcadeSurface),\n });\n\nexport const buildArcadeControllerRuntimeUrl = (\n normalizedUrl: string,\n): string | null => {\n try {\n const runtimeUrl = new URL(normalizedUrl);\n const trimmedPath =\n runtimeUrl.pathname !== \"/\" && runtimeUrl.pathname.endsWith(\"/\")\n ? runtimeUrl.pathname.slice(0, -1)\n : runtimeUrl.pathname;\n const pathSegments = trimmedPath.split(\"/\").filter(Boolean);\n const controllerPath =\n trimmedPath === \"/\" || pathSegments.length <= 1\n ? \"/controller\"\n : `${trimmedPath}/controller`;\n\n return new URL(controllerPath, runtimeUrl.origin).toString();\n } catch {\n return null;\n }\n};\n","export type RuntimeMode =\n | \"standalone-dev\"\n | \"standalone-secure\"\n | \"arcade-live\"\n | \"arcade-built\"\n | \"self-hosted-production\"\n | \"hosted-release\";\n\nexport type SurfaceRole =\n | \"host\"\n | \"controller\"\n | \"platform-host\"\n | \"platform-controller\";\n\nexport type ProxyStrategy = \"none\" | \"platform-proxy\" | \"dev-proxy\";\n\nexport interface RuntimeTopologyInput {\n runtimeMode: RuntimeMode;\n surfaceRole: SurfaceRole;\n appOrigin: string;\n backendOrigin: string;\n socketOrigin?: string;\n publicHost?: string;\n assetBasePath?: string;\n secureTransport?: boolean;\n embedded?: boolean;\n embedParentOrigin?: string;\n proxyStrategy?: ProxyStrategy;\n}\n\nexport interface ProjectRuntimeTopologyInput {\n runtimeMode?:\n | \"standalone-dev\"\n | \"standalone-secure\"\n | \"self-hosted-production\"\n | \"hosted-release\";\n surfaceRole: Extract<SurfaceRole, \"host\" | \"controller\">;\n appOrigin: string;\n backendOrigin?: string;\n socketOrigin?: string;\n publicHost?: string;\n assetBasePath?: string;\n secureTransport?: boolean;\n embedded?: boolean;\n embedParentOrigin?: string;\n proxyStrategy?: Extract<ProxyStrategy, \"none\" | \"dev-proxy\">;\n}\n\nexport interface ResolvedAirJamRuntimeTopology {\n runtimeMode: RuntimeMode;\n surfaceRole: SurfaceRole;\n appOrigin: string;\n backendOrigin: string;\n socketOrigin: string;\n publicHost: string;\n assetBasePath: string;\n secureTransport: boolean;\n embedded: boolean;\n embedParentOrigin?: string;\n proxyStrategy: ProxyStrategy;\n}\n\nconst RUNTIME_MODES = new Set<RuntimeMode>([\n \"standalone-dev\",\n \"standalone-secure\",\n \"arcade-live\",\n \"arcade-built\",\n \"self-hosted-production\",\n \"hosted-release\",\n]);\n\nconst SURFACE_ROLES = new Set<SurfaceRole>([\n \"host\",\n \"controller\",\n \"platform-host\",\n \"platform-controller\",\n]);\n\nconst PROXY_STRATEGIES = new Set<ProxyStrategy>([\n \"none\",\n \"platform-proxy\",\n \"dev-proxy\",\n]);\n\nconst PROJECT_RUNTIME_MODES = new Set<\n NonNullable<ProjectRuntimeTopologyInput[\"runtimeMode\"]>\n>([\n \"standalone-dev\",\n \"standalone-secure\",\n \"self-hosted-production\",\n \"hosted-release\",\n]);\n\nconst LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES = new Set<RuntimeMode>([\n \"standalone-dev\",\n \"standalone-secure\",\n \"arcade-live\",\n \"arcade-built\",\n]);\n\nexport const AIR_JAM_RUNTIME_TOPOLOGY_ENV_KEYS = [\n \"VITE_AIR_JAM_RUNTIME_TOPOLOGY\",\n \"NEXT_PUBLIC_AIR_JAM_RUNTIME_TOPOLOGY\",\n \"AIR_JAM_RUNTIME_TOPOLOGY\",\n];\n\nexport const AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX = \"aj_topology_\";\nexport const AIR_JAM_RUNTIME_TOPOLOGY_WINDOW_KEY =\n \"__AIR_JAM_RUNTIME_TOPOLOGY__\";\n\nconst REQUIRED_QUERY_KEYS = [\n \"runtime_mode\",\n \"surface_role\",\n \"app_origin\",\n \"backend_origin\",\n \"public_host\",\n \"asset_base_path\",\n \"secure_transport\",\n \"embedded\",\n \"proxy_strategy\",\n] as const;\n\nconst isObject = (value: unknown): value is Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value);\n\nconst assertString = (value: unknown, fieldName: string): string => {\n if (typeof value !== \"string\") {\n throw new Error(`Runtime topology field \"${fieldName}\" must be a string.`);\n }\n\n const normalized = value.trim();\n if (!normalized) {\n throw new Error(`Runtime topology field \"${fieldName}\" cannot be empty.`);\n }\n\n return normalized;\n};\n\nconst assertBoolean = (value: unknown, fieldName: string): boolean => {\n if (typeof value !== \"boolean\") {\n throw new Error(`Runtime topology field \"${fieldName}\" must be a boolean.`);\n }\n\n return value;\n};\n\nconst assertUrl = (value: unknown, fieldName: string): string => {\n const normalized = assertString(value, fieldName);\n const withScheme = normalized.includes(\"://\")\n ? normalized\n : `http://${normalized}`;\n\n let parsed: URL;\n try {\n parsed = new URL(withScheme);\n } catch {\n throw new Error(\n `Runtime topology field \"${fieldName}\" must be a valid absolute URL.`,\n );\n }\n\n if (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") {\n throw new Error(\n `Runtime topology field \"${fieldName}\" must use http or https.`,\n );\n }\n\n parsed.pathname = \"\";\n parsed.search = \"\";\n parsed.hash = \"\";\n return parsed.origin;\n};\n\nconst normalizeAssetBasePath = (value: unknown): string => {\n if (value == null) {\n return \"/\";\n }\n\n const normalized = assertString(value, \"assetBasePath\");\n if (normalized === \"/\") {\n return normalized;\n }\n\n const withLeadingSlash = normalized.startsWith(\"/\")\n ? normalized\n : `/${normalized}`;\n\n return withLeadingSlash.endsWith(\"/\") && withLeadingSlash.length > 1\n ? withLeadingSlash.slice(0, -1)\n : withLeadingSlash;\n};\n\nconst toBooleanParam = (value: boolean): string => (value ? \"true\" : \"false\");\n\nconst fromBooleanParam = (value: string | null, fieldName: string): boolean => {\n if (value === \"true\") {\n return true;\n }\n\n if (value === \"false\") {\n return false;\n }\n\n throw new Error(\n `Runtime topology query field \"${fieldName}\" must be \"true\" or \"false\".`,\n );\n};\n\nconst resolveDefaultSocketOrigin = ({\n proxyStrategy,\n appOrigin,\n backendOrigin,\n}: {\n proxyStrategy: ProxyStrategy;\n appOrigin: string;\n backendOrigin: string;\n}): string => {\n if (proxyStrategy === \"none\") {\n return backendOrigin;\n }\n\n return appOrigin;\n};\n\nconst inferSecureTransport = ({\n runtimeMode,\n appOrigin,\n backendOrigin,\n socketOrigin,\n publicHost,\n}: {\n runtimeMode: RuntimeMode;\n appOrigin: string;\n backendOrigin: string;\n socketOrigin: string;\n publicHost: string;\n}): boolean => {\n if (runtimeMode === \"standalone-secure\") {\n return true;\n }\n\n return [appOrigin, backendOrigin, socketOrigin, publicHost].every((origin) =>\n origin.startsWith(\"https://\"),\n );\n};\n\nexport const resolveRuntimeTopology = (\n input: RuntimeTopologyInput,\n): ResolvedAirJamRuntimeTopology => {\n if (!isObject(input)) {\n throw new Error(\"Runtime topology input must be an object.\");\n }\n\n const runtimeMode = assertString(\n input.runtimeMode,\n \"runtimeMode\",\n ) as RuntimeMode;\n if (!RUNTIME_MODES.has(runtimeMode)) {\n throw new Error(\n `Unsupported runtime mode \"${runtimeMode}\". Use one of: ${Array.from(RUNTIME_MODES).join(\", \")}.`,\n );\n }\n\n const surfaceRole = assertString(\n input.surfaceRole,\n \"surfaceRole\",\n ) as SurfaceRole;\n if (!SURFACE_ROLES.has(surfaceRole)) {\n throw new Error(\n `Unsupported surface role \"${surfaceRole}\". Use one of: ${Array.from(SURFACE_ROLES).join(\", \")}.`,\n );\n }\n\n const appOrigin = assertUrl(input.appOrigin, \"appOrigin\");\n const backendOrigin = assertUrl(input.backendOrigin, \"backendOrigin\");\n\n const proxyStrategy =\n input.proxyStrategy == null\n ? \"none\"\n : (assertString(input.proxyStrategy, \"proxyStrategy\") as ProxyStrategy);\n if (!PROXY_STRATEGIES.has(proxyStrategy)) {\n throw new Error(\n `Unsupported proxy strategy \"${proxyStrategy}\". Use one of: ${Array.from(PROXY_STRATEGIES).join(\", \")}.`,\n );\n }\n\n const socketOrigin =\n input.socketOrigin != null\n ? assertUrl(input.socketOrigin, \"socketOrigin\")\n : resolveDefaultSocketOrigin({ proxyStrategy, appOrigin, backendOrigin });\n const publicHost =\n input.publicHost != null\n ? assertUrl(input.publicHost, \"publicHost\")\n : appOrigin;\n const assetBasePath = normalizeAssetBasePath(input.assetBasePath);\n const embedded =\n input.embedded == null ? false : assertBoolean(input.embedded, \"embedded\");\n const embedParentOrigin =\n input.embedParentOrigin == null\n ? undefined\n : assertUrl(input.embedParentOrigin, \"embedParentOrigin\");\n\n if (embedded && !embedParentOrigin) {\n throw new Error(\n 'Embedded runtimes must provide \"embedParentOrigin\" in their topology.',\n );\n }\n\n if (!embedded && embedParentOrigin) {\n throw new Error(\n 'Non-embedded runtimes cannot provide \"embedParentOrigin\" in their topology.',\n );\n }\n\n const secureTransport =\n input.secureTransport == null\n ? inferSecureTransport({\n runtimeMode,\n appOrigin,\n backendOrigin,\n socketOrigin,\n publicHost,\n })\n : assertBoolean(input.secureTransport, \"secureTransport\");\n\n return {\n runtimeMode,\n surfaceRole,\n appOrigin,\n backendOrigin,\n socketOrigin,\n publicHost,\n assetBasePath,\n secureTransport,\n embedded,\n ...(embedParentOrigin ? { embedParentOrigin } : {}),\n proxyStrategy,\n };\n};\n\nexport const resolveProjectRuntimeTopology = (\n input: ProjectRuntimeTopologyInput,\n): ResolvedAirJamRuntimeTopology => {\n if (!isObject(input)) {\n throw new Error(\"Project runtime topology input must be an object.\");\n }\n\n const requestedRuntimeMode =\n input.runtimeMode == null\n ? input.secureTransport\n ? \"standalone-secure\"\n : \"standalone-dev\"\n : (assertString(input.runtimeMode, \"runtimeMode\") as NonNullable<\n ProjectRuntimeTopologyInput[\"runtimeMode\"]\n >);\n\n if (!PROJECT_RUNTIME_MODES.has(requestedRuntimeMode)) {\n throw new Error(\n `Unsupported project runtime mode \"${requestedRuntimeMode}\". Use one of: ${Array.from(PROJECT_RUNTIME_MODES).join(\", \")}.`,\n );\n }\n\n const proxyStrategy =\n input.proxyStrategy ??\n (requestedRuntimeMode === \"standalone-dev\" ||\n requestedRuntimeMode === \"standalone-secure\"\n ? \"dev-proxy\"\n : \"none\");\n\n const appOrigin = assertUrl(input.appOrigin, \"appOrigin\");\n const backendOrigin =\n input.backendOrigin != null\n ? assertUrl(input.backendOrigin, \"backendOrigin\")\n : appOrigin;\n const publicHost =\n input.publicHost != null\n ? assertUrl(input.publicHost, \"publicHost\")\n : appOrigin;\n\n return resolveRuntimeTopology({\n runtimeMode: requestedRuntimeMode,\n surfaceRole: input.surfaceRole,\n appOrigin,\n backendOrigin,\n publicHost,\n assetBasePath: input.assetBasePath,\n secureTransport: input.secureTransport,\n embedded: input.embedded,\n embedParentOrigin: input.embedParentOrigin,\n proxyStrategy,\n ...(input.socketOrigin ? { socketOrigin: input.socketOrigin } : {}),\n });\n};\n\nexport const isLocalDevControlSurfaceRuntimeMode = (\n runtimeMode: RuntimeMode,\n): boolean =>\n LOCAL_DEV_CONTROL_SURFACE_RUNTIME_MODES.has(\n assertString(runtimeMode, \"runtimeMode\") as RuntimeMode,\n );\n\nexport const isLocalDevControlSurfaceTopology = ({\n runtimeMode,\n}: Pick<ResolvedAirJamRuntimeTopology, \"runtimeMode\">): boolean =>\n isLocalDevControlSurfaceRuntimeMode(runtimeMode);\n\nexport const serializeRuntimeTopology = (\n topology: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology,\n): string => JSON.stringify(resolveRuntimeTopology(topology));\n\nexport const parseRuntimeTopology = (\n serialized: string,\n): ResolvedAirJamRuntimeTopology => {\n const normalized = assertString(\n serialized,\n \"serialized runtime topology\",\n );\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(normalized);\n } catch {\n throw new Error(\"Runtime topology must be valid JSON.\");\n }\n\n return resolveRuntimeTopology(parsed as RuntimeTopologyInput);\n};\n\nexport const readRuntimeTopologyFromEnv = (\n env: Record<string, string | undefined> = process.env,\n): ResolvedAirJamRuntimeTopology | null => {\n for (const key of AIR_JAM_RUNTIME_TOPOLOGY_ENV_KEYS) {\n const candidate = env?.[key];\n if (typeof candidate === \"string\" && candidate.trim().length > 0) {\n return parseRuntimeTopology(candidate);\n }\n }\n\n return null;\n};\n\nexport const readRuntimeTopologyFromWindow = (\n target:\n | Record<string, unknown>\n | { [AIR_JAM_RUNTIME_TOPOLOGY_WINDOW_KEY]?: unknown }\n | undefined = (globalThis as typeof globalThis & {\n window?: { [AIR_JAM_RUNTIME_TOPOLOGY_WINDOW_KEY]?: unknown };\n }).window,\n): ResolvedAirJamRuntimeTopology | null => {\n if (!target || typeof target !== \"object\") {\n return null;\n }\n\n const candidate = target[AIR_JAM_RUNTIME_TOPOLOGY_WINDOW_KEY];\n if (typeof candidate === \"string\" && candidate.trim().length > 0) {\n return parseRuntimeTopology(candidate);\n }\n\n if (isObject(candidate)) {\n return resolveRuntimeTopology(candidate as unknown as RuntimeTopologyInput);\n }\n\n return null;\n};\n\nexport const runtimeTopologyToQueryParams = (\n topology: RuntimeTopologyInput | ResolvedAirJamRuntimeTopology,\n): Record<string, string> => {\n const resolved = resolveRuntimeTopology(topology);\n\n return {\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}runtime_mode`]:\n resolved.runtimeMode,\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}surface_role`]:\n resolved.surfaceRole,\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}app_origin`]:\n resolved.appOrigin,\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}backend_origin`]:\n resolved.backendOrigin,\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}socket_origin`]:\n resolved.socketOrigin,\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}public_host`]:\n resolved.publicHost,\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}asset_base_path`]:\n resolved.assetBasePath,\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}secure_transport`]:\n toBooleanParam(resolved.secureTransport),\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embedded`]: toBooleanParam(\n resolved.embedded,\n ),\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}proxy_strategy`]:\n resolved.proxyStrategy,\n ...(resolved.embedParentOrigin\n ? {\n [`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embed_parent_origin`]:\n resolved.embedParentOrigin,\n }\n : {}),\n };\n};\n\nexport const parseRuntimeTopologyFromSearchParams = (\n params: URLSearchParams,\n): ResolvedAirJamRuntimeTopology | null => {\n if (!(params instanceof URLSearchParams)) {\n throw new Error(\n \"Runtime topology search param reader expects URLSearchParams.\",\n );\n }\n\n const hasAnyTopologyParam = REQUIRED_QUERY_KEYS.some((key) =>\n params.has(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}${key}`),\n );\n if (!hasAnyTopologyParam) {\n return null;\n }\n\n const missing = REQUIRED_QUERY_KEYS.filter(\n (key) =>\n !params.has(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}${key}`),\n );\n if (missing.length > 0) {\n throw new Error(\n `Runtime topology search params are incomplete. Missing: ${missing.join(\", \")}.`,\n );\n }\n\n const embedParentOrigin = params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embed_parent_origin`,\n );\n\n return resolveRuntimeTopology({\n runtimeMode: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}runtime_mode`,\n ) as RuntimeMode,\n surfaceRole: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}surface_role`,\n ) as SurfaceRole,\n appOrigin: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}app_origin`,\n ) as string,\n backendOrigin: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}backend_origin`,\n ) as string,\n socketOrigin: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}socket_origin`,\n ) as string,\n publicHost: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}public_host`,\n ) as string,\n assetBasePath: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}asset_base_path`,\n ) as string,\n secureTransport: fromBooleanParam(\n params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}secure_transport`,\n ),\n \"secure_transport\",\n ),\n embedded: fromBooleanParam(\n params.get(`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embedded`),\n \"embedded\",\n ),\n proxyStrategy: params.get(\n `${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}proxy_strategy`,\n ) as ProxyStrategy,\n ...(embedParentOrigin ? { embedParentOrigin } : {}),\n });\n};\n","import { z } from \"zod\";\n\nconst ALLOWED_RUNTIME_PROTOCOLS = new Set([\"http:\", \"https:\"]);\n\nconst parseRuntimeUrl = (value: string): URL | null => {\n try {\n const parsed = new URL(value);\n if (!ALLOWED_RUNTIME_PROTOCOLS.has(parsed.protocol)) {\n return null;\n }\n if (parsed.username || parsed.password) {\n return null;\n }\n return parsed;\n } catch {\n return null;\n }\n};\n\nexport const normalizeRuntimeUrl = (value: string): string | null => {\n const parsed = parseRuntimeUrl(value);\n return parsed ? parsed.toString() : null;\n};\n\nexport const getRuntimeUrlOrigin = (value: string): string | null => {\n const parsed = parseRuntimeUrl(value);\n return parsed ? parsed.origin : null;\n};\n\nexport const runtimeUrlSchema = z\n .string()\n .trim()\n .min(1)\n .refine((value) => parseRuntimeUrl(value) !== null, {\n message: \"URL must be a valid http(s) URL without embedded credentials.\",\n });\n\nexport const appendRuntimeQueryParams = (\n baseUrl: string,\n params: Record<string, string | null | undefined>,\n): string | null => {\n const parsed = parseRuntimeUrl(baseUrl);\n if (!parsed) {\n return null;\n }\n\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null || value === \"\") {\n continue;\n }\n parsed.searchParams.set(key, value);\n }\n\n return parsed.toString();\n};\n\nexport const isTrustedRuntimeMessageOrigin = (\n runtimeUrl: string,\n messageOrigin: string,\n): boolean => {\n const runtimeOrigin = getRuntimeUrlOrigin(runtimeUrl);\n return runtimeOrigin !== null && runtimeOrigin === messageOrigin;\n};\n","import { AIR_JAM_DEFAULT_STORE_DOMAIN } from \"../store/air-jam-store-domain-constants\";\nimport type { ArcadeSurfaceRuntimeIdentity } from \"./arcade-surface-identity\";\n\n/**\n * Query param for the canonical replicated store domain in embedded runtimes.\n * When set, {@link resolveImplicitReplicatedStoreDomainFromSearchParams} prefers it over derivation from `aj_arcade_*`.\n */\nexport const AIRJAM_STORE_DOMAIN_URL_PARAM = \"aj_store_domain\";\n\nconst clampStoreDomain = (value: string): string =>\n value.length > 128 ? value.slice(0, 128) : value;\n\n/**\n * Stable replicated store domain for an embedded Arcade surface identity (epoch-bound).\n * Used for host/controller `createAirJamStore` in iframes so shell `default` and prior runs do not collide.\n */\nexport const embeddedReplicatedStoreDomainFromArcadeIdentity = (\n identity: ArcadeSurfaceRuntimeIdentity,\n): string => {\n if (identity.kind === \"game\") {\n const gameKey = identity.gameId ?? \"_\";\n return clampStoreDomain(`aj.embedded.game:${identity.epoch}:${gameKey}`);\n }\n return clampStoreDomain(`aj.embedded.browser:${identity.epoch}`);\n};\n\n/**\n * Query params used to pass {@link ArcadeSurfaceRuntimeIdentity} and replicated store domain into embedded iframes.\n */\nexport const arcadeSurfaceRuntimeUrlParams = (\n identity: ArcadeSurfaceRuntimeIdentity,\n): Record<string, string> => ({\n aj_arcade_epoch: String(identity.epoch),\n aj_arcade_kind: identity.kind,\n ...(identity.gameId != null ? { aj_arcade_game_id: identity.gameId } : {}),\n [AIRJAM_STORE_DOMAIN_URL_PARAM]:\n embeddedReplicatedStoreDomainFromArcadeIdentity(identity),\n});\n\nexport const parseOptionalArcadeSurfaceFromSearchParams = (\n params: URLSearchParams,\n): ArcadeSurfaceRuntimeIdentity | undefined => {\n const epochStr = params.get(\"aj_arcade_epoch\");\n const kind = params.get(\"aj_arcade_kind\");\n if (epochStr === null || (kind !== \"browser\" && kind !== \"game\")) {\n return undefined;\n }\n\n const epoch = Number(epochStr);\n if (!Number.isFinite(epoch) || epoch < 0 || !Number.isInteger(epoch)) {\n return undefined;\n }\n\n const gameIdRaw = params.get(\"aj_arcade_game_id\");\n const gameId =\n kind === \"browser\"\n ? null\n : gameIdRaw && gameIdRaw.length > 0\n ? gameIdRaw\n : null;\n\n return { epoch, kind, gameId };\n};\n\n/**\n * Resolves the implicit networked store domain from the current URL (embedded) or {@link AIR_JAM_DEFAULT_STORE_DOMAIN}.\n * Prefer {@link AIRJAM_STORE_DOMAIN_URL_PARAM} when present; otherwise derive from `aj_arcade_*` when valid.\n */\nexport const resolveImplicitReplicatedStoreDomainFromSearchParams = (\n params: URLSearchParams,\n): string => {\n const explicit = params.get(AIRJAM_STORE_DOMAIN_URL_PARAM)?.trim();\n if (explicit && explicit.length > 0) {\n return clampStoreDomain(explicit);\n }\n\n const surface = parseOptionalArcadeSurfaceFromSearchParams(params);\n if (surface) {\n return embeddedReplicatedStoreDomainFromArcadeIdentity(surface);\n }\n\n return AIR_JAM_DEFAULT_STORE_DOMAIN;\n};\n\n/**\n * Browser-only resolver for implicit store domain (SSR-safe: returns default without `window`).\n */\nexport const resolveImplicitReplicatedStoreDomainFromWindow = (): string => {\n if (typeof window === \"undefined\") {\n return AIR_JAM_DEFAULT_STORE_DOMAIN;\n }\n return resolveImplicitReplicatedStoreDomainFromSearchParams(\n new URLSearchParams(window.location.search),\n );\n};\n","import { z } from \"zod\";\n\n/**\n * Minimum Arcade surface identity for embedded runtime bridge attach (see docs/systems/arcade-surface-contract.md).\n */\nexport const arcadeSurfaceRuntimeIdentitySchema = z\n .object({\n epoch: z.number().int().nonnegative(),\n kind: z.enum([\"browser\", \"game\"]),\n gameId: z.string().nullable(),\n })\n .strict();\n\nexport type ArcadeSurfaceRuntimeIdentity = z.infer<\n typeof arcadeSurfaceRuntimeIdentitySchema\n>;\n","/**\n * Core Air Jam constants used across the SDK\n */\n\n/**\n * Default server port for Air Jam server\n */\nexport const DEFAULT_SERVER_PORT = 4000;\n\n/**\n * Standard path for controller endpoints.\n * All Air Jam games use this convention - controller is always at {baseUrl}/controller\n */\nexport const CONTROLLER_PATH = \"/controller\";\n\n/**\n * Input debounce time in milliseconds\n * Used to prevent rapid input events from overwhelming the system\n */\nexport const INPUT_DEBOUNCE_MS = 200;\n\n/**\n * Toggle debounce time in milliseconds\n * Used for game state toggles to prevent accidental double-toggles\n */\nexport const TOGGLE_DEBOUNCE_MS = 300;\n\n/**\n * Socket.IO configuration\n */\nexport const SOCKET_CONFIG = {\n /**\n * Ping interval in milliseconds\n */\n PING_INTERVAL: 2000,\n\n /**\n * Ping timeout in milliseconds\n */\n PING_TIMEOUT: 5000,\n} as const;\n\n/**\n * Maximum players allowed in a room by default\n */\nexport const DEFAULT_MAX_PLAYERS = 8;\n","/**\n * Checks if an IP is from a virtual network interface (Docker, VMs, etc.)\n */\nconst isVirtualNetwork = (ip: string): boolean => {\n // Docker Desktop on Mac uses 192.168.64.x and 192.168.65.x\n if (ip.startsWith(\"192.168.64.\") || ip.startsWith(\"192.168.65.\")) {\n return true;\n }\n // Docker default bridge network\n if (ip.startsWith(\"172.17.\")) {\n return true;\n }\n // Other common virtual network ranges\n if (ip.startsWith(\"172.18.\") || ip.startsWith(\"172.19.\")) {\n return true;\n }\n // Link-local addresses\n if (ip.startsWith(\"169.254.\")) {\n return true;\n }\n return false;\n};\n\n/**\n * Scores an IP address to determine preference.\n * Higher score = more preferred.\n */\nconst scoreIp = (ip: string): number => {\n // Prefer 192.168.0.x - 192.168.63.x (common home network ranges, excluding virtual networks)\n if (ip.startsWith(\"192.168.\")) {\n const parts = ip.split(\".\");\n const thirdOctet = parseInt(parts[2] || \"0\", 10);\n // Prefer lower third octets (0-63) as they're more likely to be real networks\n if (thirdOctet < 64) {\n return 100 - thirdOctet; // Higher score for lower numbers\n }\n // 64+ are often virtual, but we'll still consider them if nothing else\n return 10;\n }\n // Prefer 10.x.x.x networks\n if (ip.startsWith(\"10.\")) {\n return 50;\n }\n // 172.16-31.x.x networks (but not 172.17.x.x which is Docker)\n if (/^172\\.(1[6-9]|2[0-9]|3[01])\\./.test(ip)) {\n return 30;\n }\n return 0;\n};\n\n/**\n * Gets the local network IP address using WebRTC.\n * Filters out virtual network interfaces and prefers real network IPs.\n * Returns null if unable to determine the IP.\n */\nexport const getLocalNetworkIp = (): Promise<string | null> => {\n return new Promise((resolve) => {\n // If not in browser, return null\n if (\n typeof window === \"undefined\" ||\n typeof RTCPeerConnection === \"undefined\"\n ) {\n resolve(null);\n return;\n }\n\n const pc = new RTCPeerConnection({\n iceServers: [{ urls: \"stun:stun.l.google.com:19302\" }],\n });\n\n const candidates: Array<{ ip: string; score: number }> = [];\n let candidateGatheringComplete = false;\n\n const resolveOnce = (ip: string | null) => {\n pc.close();\n resolve(ip);\n };\n\n // Timeout after 3 seconds\n const timeout = setTimeout(() => {\n if (candidateGatheringComplete) {\n pickBestCandidate();\n } else {\n // Wait a bit more for candidates to arrive\n setTimeout(() => {\n pickBestCandidate();\n }, 500);\n }\n }, 3000);\n\n const pickBestCandidate = () => {\n if (candidates.length === 0) {\n resolveOnce(null);\n return;\n }\n\n // Sort by score (highest first), then pick the best one\n candidates.sort((a, b) => b.score - a.score);\n const best = candidates[0];\n clearTimeout(timeout);\n resolveOnce(best.ip);\n };\n\n pc.onicecandidate = (event) => {\n if (event.candidate) {\n const candidate = event.candidate.candidate;\n const match = candidate.match(/([0-9]{1,3}(\\.[0-9]{1,3}){3})/);\n if (match) {\n const ip = match[1];\n // Filter out localhost\n if (ip === \"127.0.0.1\") {\n return;\n }\n\n // Check if it's a private network IP\n const isPrivate =\n ip.startsWith(\"192.168.\") ||\n ip.startsWith(\"10.\") ||\n /^172\\.(1[6-9]|2[0-9]|3[01])\\./.test(ip);\n\n if (isPrivate && !isVirtualNetwork(ip)) {\n const score = scoreIp(ip);\n candidates.push({ ip, score });\n }\n }\n } else {\n // No more candidates - gathering is complete\n candidateGatheringComplete = true;\n // Give it a moment for any last candidates to arrive, then pick the best\n setTimeout(() => {\n pickBestCandidate();\n }, 200);\n }\n };\n\n // Create a data channel to trigger candidate gathering\n pc.createDataChannel(\"\");\n pc.createOffer()\n .then((offer) => pc.setLocalDescription(offer))\n .catch(() => {\n clearTimeout(timeout);\n resolveOnce(null);\n });\n });\n};\n","import { CONTROLLER_PATH, DEFAULT_SERVER_PORT } from \"../constants\";\nimport type { RoomCode } from \"../protocol\";\nimport { getLocalNetworkIp } from \"./network-ip\";\n\n/**\n * Centralized URL builder service for Air Jam.\n * Handles IP detection, URL normalization, and construction of all URL types.\n */\nclass UrlBuilder {\n private cachedLocalIp: string | null = null;\n private ipDetectionPromise: Promise<string | null> | null = null;\n\n /**\n * Get the local network IP address with caching.\n * First call triggers detection, subsequent calls return cached value.\n */\n async getLocalIp(): Promise<string | null> {\n // Return cached value if available\n if (this.cachedLocalIp !== null) {\n return this.cachedLocalIp;\n }\n\n // If detection is already in progress, wait for it\n if (this.ipDetectionPromise !== null) {\n return this.ipDetectionPromise;\n }\n\n // Start IP detection\n this.ipDetectionPromise = getLocalNetworkIp().then((ip) => {\n this.cachedLocalIp = ip;\n this.ipDetectionPromise = null;\n return ip;\n });\n\n return this.ipDetectionPromise;\n }\n\n /**\n * Clear the cached IP address.\n * Useful for testing or when network changes are detected.\n */\n clearCache(): void {\n this.cachedLocalIp = null;\n this.ipDetectionPromise = null;\n }\n\n /**\n * Normalize a URL for mobile access.\n * Replaces localhost with the local network IP.\n */\n async normalizeForMobile(url: string): Promise<string> {\n if (typeof window === \"undefined\") return url;\n\n try {\n const urlObj = new URL(url);\n\n // If URL uses localhost, replace with local network IP\n if (urlObj.hostname === \"localhost\" || urlObj.hostname === \"127.0.0.1\") {\n const localIp = await this.getLocalIp();\n\n if (localIp) {\n urlObj.hostname = localIp;\n return urlObj.toString();\n }\n\n // Fallback to current hostname if IP detection fails\n urlObj.hostname = window.location.hostname;\n return urlObj.toString();\n }\n\n return url;\n } catch {\n return url;\n }\n }\n\n /**\n * Build a controller URL with room code.\n * Controller is always at {baseUrl}/controller (standardized convention).\n * Automatically uses local IP when running on localhost.\n */\n async buildControllerUrl(\n roomId: RoomCode,\n options?: {\n host?: string;\n capabilityToken?: string;\n },\n ): Promise<string> {\n const path = CONTROLLER_PATH;\n\n // If explicit host is provided, use it\n if (options?.host) {\n const url = new URL(path, this.normalizeOrigin(options.host));\n url.searchParams.set(\"room\", roomId);\n if (options.capabilityToken) {\n url.searchParams.set(\"aj_controller_cap\", options.capabilityToken);\n }\n return url.toString();\n }\n\n // Determine base URL\n let base: string;\n if (typeof window === \"undefined\") {\n base = `http://localhost:${DEFAULT_SERVER_PORT}`;\n } else {\n const currentUrl = new URL(window.location.href);\n\n // If not localhost, use the current origin\n if (!this.isLocalhost(currentUrl.hostname)) {\n base = currentUrl.origin;\n } else {\n // If localhost, try to get the local network IP\n const localIp = await this.getLocalIp();\n if (localIp) {\n // Preserve the port from the current URL\n const port = currentUrl.port;\n base = port ? `http://${localIp}:${port}` : `http://${localIp}`;\n } else {\n // Fallback to localhost if we can't determine the IP\n base = currentUrl.origin;\n }\n }\n }\n\n const url = new URL(path, base);\n url.searchParams.set(\"room\", roomId);\n if (options?.capabilityToken) {\n url.searchParams.set(\"aj_controller_cap\", options.capabilityToken);\n }\n return url.toString();\n }\n\n /**\n * Resolve the server URL.\n * Uses explicit URL if provided, otherwise infers from window location.\n */\n resolveServerUrl(explicit?: string): string {\n if (explicit) {\n return this.normalizeOrigin(explicit);\n }\n\n if (typeof window !== \"undefined\") {\n const url = new URL(window.location.href);\n url.port = String(DEFAULT_SERVER_PORT);\n return url.origin;\n }\n\n return `http://localhost:${DEFAULT_SERVER_PORT}`;\n }\n\n /**\n * Check if a hostname is localhost.\n */\n private isLocalhost(hostname: string): boolean {\n return (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname === \"[::1]\"\n );\n }\n\n /**\n * Normalize an origin string to ensure it has a protocol.\n */\n private normalizeOrigin(origin: string): string {\n if (!origin.includes(\"://\")) {\n return `http://${origin}`;\n }\n return origin;\n }\n}\n\n// Export singleton instance\nexport const urlBuilder = new UrlBuilder();\n\n// Export class for testing/advanced usage\nexport { UrlBuilder };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC8DA,IAAM,gBAAgB,oBAAI,IAAiB;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,gBAAgB,oBAAI,IAAiB;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,mBAAmB,oBAAI,IAAmB;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAwBM,IAAM,8CAA8C;AAgB3D,IAAM,WAAW,CAAC,UAChB,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAErE,IAAM,eAAe,CAAC,OAAgB,cAA8B;AAClE,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,IAAI,MAAM,2BAA2B,SAAS,qBAAqB;AAAA,EAC3E;AAEA,QAAM,aAAa,MAAM,KAAK;AAC9B,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,2BAA2B,SAAS,oBAAoB;AAAA,EAC1E;AAEA,SAAO;AACT;AAEA,IAAM,gBAAgB,CAAC,OAAgB,cAA+B;AACpE,MAAI,OAAO,UAAU,WAAW;AAC9B,UAAM,IAAI,MAAM,2BAA2B,SAAS,sBAAsB;A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T;AACF;","names":["import_zod","url"]}
|
package/dist/arcade/url.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedAirJamRuntimeTopology } from '
|
|
1
|
+
import { ResolvedAirJamRuntimeTopology } from '../runtime-topology.cjs';
|
|
2
2
|
import { C as ChildHostCapability } from '../host-8hmq_Sgc.cjs';
|
|
3
3
|
export { a as appendRuntimeQueryParams, g as getRuntimeUrlOrigin, n as normalizeRuntimeUrl } from '../url-policy-C89zxgw9.cjs';
|
|
4
4
|
import { A as ArcadeSurfaceRuntimeIdentity } from '../arcade-surface-identity-CQxDpn_w.cjs';
|
package/dist/arcade/url.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedAirJamRuntimeTopology } from '
|
|
1
|
+
import { ResolvedAirJamRuntimeTopology } from '../runtime-topology.js';
|
|
2
2
|
import { C as ChildHostCapability } from '../host-Cw-N6e-5.js';
|
|
3
3
|
export { a as appendRuntimeQueryParams, g as getRuntimeUrlOrigin, n as normalizeRuntimeUrl } from '../url-policy-C89zxgw9.js';
|
|
4
4
|
import { A as ArcadeSurfaceRuntimeIdentity } from '../arcade-surface-identity-CQxDpn_w.js';
|
package/dist/arcade/url.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildArcadeControllerRuntimeUrl,
|
|
3
3
|
buildArcadeGameIframeSrc
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-JO2HR5PV.js";
|
|
5
5
|
import "../chunk-ZTQ5SP4H.js";
|
|
6
6
|
import {
|
|
7
7
|
urlBuilder
|
|
8
8
|
} from "../chunk-YXHH3MQT.js";
|
|
9
9
|
import "../chunk-X24K52DG.js";
|
|
10
10
|
import "../chunk-W2VK36RO.js";
|
|
11
|
-
import
|
|
12
|
-
arcadeSurfaceRuntimeUrlParams
|
|
13
|
-
} from "../chunk-BE6Z4SIT.js";
|
|
11
|
+
import "../chunk-UWJOIVON.js";
|
|
14
12
|
import {
|
|
15
13
|
appendRuntimeQueryParams,
|
|
16
14
|
getRuntimeUrlOrigin,
|
|
17
15
|
normalizeRuntimeUrl
|
|
18
16
|
} from "../chunk-3USU7GY2.js";
|
|
17
|
+
import {
|
|
18
|
+
arcadeSurfaceRuntimeUrlParams
|
|
19
|
+
} from "../chunk-BE6Z4SIT.js";
|
|
19
20
|
export {
|
|
20
21
|
appendRuntimeQueryParams,
|
|
21
22
|
arcadeSurfaceRuntimeUrlParams,
|
package/dist/arcade.cjs
CHANGED
|
@@ -649,7 +649,7 @@ var isAirJamSettingsReadyMessage = (value) => {
|
|
|
649
649
|
};
|
|
650
650
|
|
|
651
651
|
// src/runtime/sdk-version.ts
|
|
652
|
-
var AIR_JAM_SDK_VERSION = true ? "0.9.
|
|
652
|
+
var AIR_JAM_SDK_VERSION = true ? "0.9.1" : "0.0.0";
|
|
653
653
|
|
|
654
654
|
// src/runtime/controller-bridge.ts
|
|
655
655
|
var AIRJAM_CONTROLLER_BRIDGE_REQUEST = "AIRJAM_CONTROLLER_BRIDGE_REQUEST";
|
|
@@ -1076,15 +1076,193 @@ var createArcadeSettingsSyncMessage = (settings) => ({
|
|
|
1076
1076
|
var import_zustand3 = require("zustand");
|
|
1077
1077
|
var import_shallow2 = require("zustand/react/shallow");
|
|
1078
1078
|
|
|
1079
|
+
// src/runtime-topology.ts
|
|
1080
|
+
var RUNTIME_MODES = /* @__PURE__ */ new Set([
|
|
1081
|
+
"standalone-dev",
|
|
1082
|
+
"standalone-secure",
|
|
1083
|
+
"arcade-live",
|
|
1084
|
+
"arcade-built",
|
|
1085
|
+
"self-hosted-production",
|
|
1086
|
+
"hosted-release"
|
|
1087
|
+
]);
|
|
1088
|
+
var SURFACE_ROLES = /* @__PURE__ */ new Set([
|
|
1089
|
+
"host",
|
|
1090
|
+
"controller",
|
|
1091
|
+
"platform-host",
|
|
1092
|
+
"platform-controller"
|
|
1093
|
+
]);
|
|
1094
|
+
var PROXY_STRATEGIES = /* @__PURE__ */ new Set([
|
|
1095
|
+
"none",
|
|
1096
|
+
"platform-proxy",
|
|
1097
|
+
"dev-proxy"
|
|
1098
|
+
]);
|
|
1099
|
+
var AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX = "aj_topology_";
|
|
1100
|
+
var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1101
|
+
var assertString = (value, fieldName) => {
|
|
1102
|
+
if (typeof value !== "string") {
|
|
1103
|
+
throw new Error(`Runtime topology field "${fieldName}" must be a string.`);
|
|
1104
|
+
}
|
|
1105
|
+
const normalized = value.trim();
|
|
1106
|
+
if (!normalized) {
|
|
1107
|
+
throw new Error(`Runtime topology field "${fieldName}" cannot be empty.`);
|
|
1108
|
+
}
|
|
1109
|
+
return normalized;
|
|
1110
|
+
};
|
|
1111
|
+
var assertBoolean = (value, fieldName) => {
|
|
1112
|
+
if (typeof value !== "boolean") {
|
|
1113
|
+
throw new Error(`Runtime topology field "${fieldName}" must be a boolean.`);
|
|
1114
|
+
}
|
|
1115
|
+
return value;
|
|
1116
|
+
};
|
|
1117
|
+
var assertUrl = (value, fieldName) => {
|
|
1118
|
+
const normalized = assertString(value, fieldName);
|
|
1119
|
+
const withScheme = normalized.includes("://") ? normalized : `http://${normalized}`;
|
|
1120
|
+
let parsed;
|
|
1121
|
+
try {
|
|
1122
|
+
parsed = new URL(withScheme);
|
|
1123
|
+
} catch {
|
|
1124
|
+
throw new Error(
|
|
1125
|
+
`Runtime topology field "${fieldName}" must be a valid absolute URL.`
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
1129
|
+
throw new Error(
|
|
1130
|
+
`Runtime topology field "${fieldName}" must use http or https.`
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
parsed.pathname = "";
|
|
1134
|
+
parsed.search = "";
|
|
1135
|
+
parsed.hash = "";
|
|
1136
|
+
return parsed.origin;
|
|
1137
|
+
};
|
|
1138
|
+
var normalizeAssetBasePath = (value) => {
|
|
1139
|
+
if (value == null) {
|
|
1140
|
+
return "/";
|
|
1141
|
+
}
|
|
1142
|
+
const normalized = assertString(value, "assetBasePath");
|
|
1143
|
+
if (normalized === "/") {
|
|
1144
|
+
return normalized;
|
|
1145
|
+
}
|
|
1146
|
+
const withLeadingSlash = normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
1147
|
+
return withLeadingSlash.endsWith("/") && withLeadingSlash.length > 1 ? withLeadingSlash.slice(0, -1) : withLeadingSlash;
|
|
1148
|
+
};
|
|
1149
|
+
var toBooleanParam = (value) => value ? "true" : "false";
|
|
1150
|
+
var resolveDefaultSocketOrigin = ({
|
|
1151
|
+
proxyStrategy,
|
|
1152
|
+
appOrigin,
|
|
1153
|
+
backendOrigin
|
|
1154
|
+
}) => {
|
|
1155
|
+
if (proxyStrategy === "none") {
|
|
1156
|
+
return backendOrigin;
|
|
1157
|
+
}
|
|
1158
|
+
return appOrigin;
|
|
1159
|
+
};
|
|
1160
|
+
var inferSecureTransport = ({
|
|
1161
|
+
runtimeMode,
|
|
1162
|
+
appOrigin,
|
|
1163
|
+
backendOrigin,
|
|
1164
|
+
socketOrigin,
|
|
1165
|
+
publicHost
|
|
1166
|
+
}) => {
|
|
1167
|
+
if (runtimeMode === "standalone-secure") {
|
|
1168
|
+
return true;
|
|
1169
|
+
}
|
|
1170
|
+
return [appOrigin, backendOrigin, socketOrigin, publicHost].every(
|
|
1171
|
+
(origin) => origin.startsWith("https://")
|
|
1172
|
+
);
|
|
1173
|
+
};
|
|
1174
|
+
var resolveRuntimeTopology = (input) => {
|
|
1175
|
+
if (!isObject(input)) {
|
|
1176
|
+
throw new Error("Runtime topology input must be an object.");
|
|
1177
|
+
}
|
|
1178
|
+
const runtimeMode = assertString(
|
|
1179
|
+
input.runtimeMode,
|
|
1180
|
+
"runtimeMode"
|
|
1181
|
+
);
|
|
1182
|
+
if (!RUNTIME_MODES.has(runtimeMode)) {
|
|
1183
|
+
throw new Error(
|
|
1184
|
+
`Unsupported runtime mode "${runtimeMode}". Use one of: ${Array.from(RUNTIME_MODES).join(", ")}.`
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
const surfaceRole = assertString(
|
|
1188
|
+
input.surfaceRole,
|
|
1189
|
+
"surfaceRole"
|
|
1190
|
+
);
|
|
1191
|
+
if (!SURFACE_ROLES.has(surfaceRole)) {
|
|
1192
|
+
throw new Error(
|
|
1193
|
+
`Unsupported surface role "${surfaceRole}". Use one of: ${Array.from(SURFACE_ROLES).join(", ")}.`
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
const appOrigin = assertUrl(input.appOrigin, "appOrigin");
|
|
1197
|
+
const backendOrigin = assertUrl(input.backendOrigin, "backendOrigin");
|
|
1198
|
+
const proxyStrategy = input.proxyStrategy == null ? "none" : assertString(input.proxyStrategy, "proxyStrategy");
|
|
1199
|
+
if (!PROXY_STRATEGIES.has(proxyStrategy)) {
|
|
1200
|
+
throw new Error(
|
|
1201
|
+
`Unsupported proxy strategy "${proxyStrategy}". Use one of: ${Array.from(PROXY_STRATEGIES).join(", ")}.`
|
|
1202
|
+
);
|
|
1203
|
+
}
|
|
1204
|
+
const socketOrigin = input.socketOrigin != null ? assertUrl(input.socketOrigin, "socketOrigin") : resolveDefaultSocketOrigin({ proxyStrategy, appOrigin, backendOrigin });
|
|
1205
|
+
const publicHost = input.publicHost != null ? assertUrl(input.publicHost, "publicHost") : appOrigin;
|
|
1206
|
+
const assetBasePath = normalizeAssetBasePath(input.assetBasePath);
|
|
1207
|
+
const embedded = input.embedded == null ? false : assertBoolean(input.embedded, "embedded");
|
|
1208
|
+
const embedParentOrigin = input.embedParentOrigin == null ? void 0 : assertUrl(input.embedParentOrigin, "embedParentOrigin");
|
|
1209
|
+
if (embedded && !embedParentOrigin) {
|
|
1210
|
+
throw new Error(
|
|
1211
|
+
'Embedded runtimes must provide "embedParentOrigin" in their topology.'
|
|
1212
|
+
);
|
|
1213
|
+
}
|
|
1214
|
+
if (!embedded && embedParentOrigin) {
|
|
1215
|
+
throw new Error(
|
|
1216
|
+
'Non-embedded runtimes cannot provide "embedParentOrigin" in their topology.'
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
const secureTransport = input.secureTransport == null ? inferSecureTransport({
|
|
1220
|
+
runtimeMode,
|
|
1221
|
+
appOrigin,
|
|
1222
|
+
backendOrigin,
|
|
1223
|
+
socketOrigin,
|
|
1224
|
+
publicHost
|
|
1225
|
+
}) : assertBoolean(input.secureTransport, "secureTransport");
|
|
1226
|
+
return {
|
|
1227
|
+
runtimeMode,
|
|
1228
|
+
surfaceRole,
|
|
1229
|
+
appOrigin,
|
|
1230
|
+
backendOrigin,
|
|
1231
|
+
socketOrigin,
|
|
1232
|
+
publicHost,
|
|
1233
|
+
assetBasePath,
|
|
1234
|
+
secureTransport,
|
|
1235
|
+
embedded,
|
|
1236
|
+
...embedParentOrigin ? { embedParentOrigin } : {},
|
|
1237
|
+
proxyStrategy
|
|
1238
|
+
};
|
|
1239
|
+
};
|
|
1240
|
+
var runtimeTopologyToQueryParams = (topology) => {
|
|
1241
|
+
const resolved = resolveRuntimeTopology(topology);
|
|
1242
|
+
return {
|
|
1243
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}runtime_mode`]: resolved.runtimeMode,
|
|
1244
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}surface_role`]: resolved.surfaceRole,
|
|
1245
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}app_origin`]: resolved.appOrigin,
|
|
1246
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}backend_origin`]: resolved.backendOrigin,
|
|
1247
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}socket_origin`]: resolved.socketOrigin,
|
|
1248
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}public_host`]: resolved.publicHost,
|
|
1249
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}asset_base_path`]: resolved.assetBasePath,
|
|
1250
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}secure_transport`]: toBooleanParam(resolved.secureTransport),
|
|
1251
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embedded`]: toBooleanParam(
|
|
1252
|
+
resolved.embedded
|
|
1253
|
+
),
|
|
1254
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}proxy_strategy`]: resolved.proxyStrategy,
|
|
1255
|
+
...resolved.embedParentOrigin ? {
|
|
1256
|
+
[`${AIR_JAM_RUNTIME_TOPOLOGY_QUERY_PARAM_PREFIX}embed_parent_origin`]: resolved.embedParentOrigin
|
|
1257
|
+
} : {}
|
|
1258
|
+
};
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1079
1261
|
// src/context/air-jam-context.tsx
|
|
1080
|
-
var import_runtime_topology3 = require("@air-jam/runtime-topology");
|
|
1081
1262
|
var import_react = require("react");
|
|
1082
1263
|
var import_zustand2 = require("zustand");
|
|
1083
1264
|
var import_shallow = require("zustand/react/shallow");
|
|
1084
1265
|
|
|
1085
|
-
// src/dev/browser-log-sink.ts
|
|
1086
|
-
var import_runtime_topology = require("@air-jam/runtime-topology");
|
|
1087
|
-
|
|
1088
1266
|
// src/diagnostics.ts
|
|
1089
1267
|
var listeners = /* @__PURE__ */ new Set();
|
|
1090
1268
|
var lastEmissionByKey = /* @__PURE__ */ new Map();
|
|
@@ -1141,9 +1319,6 @@ var createAirJamDiagnosticError = (code, message, details) => {
|
|
|
1141
1319
|
return error;
|
|
1142
1320
|
};
|
|
1143
1321
|
|
|
1144
|
-
// src/runtime/air-jam-config.ts
|
|
1145
|
-
var import_runtime_topology2 = require("@air-jam/runtime-topology");
|
|
1146
|
-
|
|
1147
1322
|
// src/constants.ts
|
|
1148
1323
|
var DEFAULT_SERVER_PORT = 4e3;
|
|
1149
1324
|
var CONTROLLER_PATH = "/controller";
|
|
@@ -1265,9 +1440,6 @@ var resolveImplicitReplicatedStoreDomainFromWindow = () => {
|
|
|
1265
1440
|
);
|
|
1266
1441
|
};
|
|
1267
1442
|
|
|
1268
|
-
// src/arcade/url.ts
|
|
1269
|
-
var import_runtime_topology4 = require("@air-jam/runtime-topology");
|
|
1270
|
-
|
|
1271
1443
|
// src/utils/network-ip.ts
|
|
1272
1444
|
var isVirtualNetwork = (ip) => {
|
|
1273
1445
|
if (ip.startsWith("192.168.64.") || ip.startsWith("192.168.65.")) {
|
|
@@ -1502,7 +1674,7 @@ var buildArcadeGameIframeSrc = ({
|
|
|
1502
1674
|
aj_cap: launchCapability.token,
|
|
1503
1675
|
aj_cap_exp: String(launchCapability.expiresAt),
|
|
1504
1676
|
aj_join_url: joinUrl,
|
|
1505
|
-
...
|
|
1677
|
+
...runtimeTopologyToQueryParams(topology),
|
|
1506
1678
|
...arcadeSurfaceRuntimeUrlParams(arcadeSurface)
|
|
1507
1679
|
});
|
|
1508
1680
|
var buildArcadeControllerRuntimeUrl = (normalizedUrl) => {
|