@series-inc/rundot-syncplay 6.0.0-rc.2 → 6.0.0-rc.21

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.
Files changed (329) hide show
  1. package/README.md +133 -0
  2. package/core/deterministic-math.d.ts +75 -1
  3. package/core/native/instance_ledger.hpp +1095 -0
  4. package/core/native/legacy_checkpoint_ids.hpp +107 -0
  5. package/core/native/physics/abi.cpp +39 -211
  6. package/core/native/physics/abi.hpp +2 -6
  7. package/core/native/physics/articulation.cpp +1434 -0
  8. package/core/native/physics/articulation.hpp +279 -0
  9. package/core/native/physics/buoyancy.cpp +1588 -0
  10. package/core/native/physics/buoyancy.hpp +254 -0
  11. package/core/native/physics/capsule_triangle.cpp +168 -0
  12. package/core/native/physics/capsule_triangle.hpp +40 -0
  13. package/core/native/physics/capsule_triangle_native.inc +291 -0
  14. package/core/native/physics/certified_sum.hpp +218 -0
  15. package/core/native/physics/character.cpp +638 -0
  16. package/core/native/physics/character.hpp +169 -0
  17. package/core/native/physics/checkpoint_schema.hpp +379 -0
  18. package/core/native/physics/cloth.cpp +1401 -0
  19. package/core/native/physics/cloth.hpp +357 -0
  20. package/core/native/physics/constraint_rows.cpp +363 -2
  21. package/core/native/physics/constraint_rows.hpp +72 -1
  22. package/core/native/physics/deformable_query.cpp +1630 -0
  23. package/core/native/physics/deformable_query.hpp +578 -0
  24. package/core/native/physics/distance.cpp +1166 -0
  25. package/core/native/physics/distance.hpp +151 -0
  26. package/core/native/physics/exact/exact-applied.cpp +101 -0
  27. package/core/native/physics/exact/exact-applied.hpp +112 -0
  28. package/core/native/physics/exact/exact-dyadic.cpp +691 -0
  29. package/core/native/physics/exact/exact-dyadic.hpp +58 -0
  30. package/core/native/physics/exact/exact-operation.hpp +51 -0
  31. package/core/native/physics/exact/word-core.hpp +262 -0
  32. package/core/native/physics/extended_abi.cpp +1242 -0
  33. package/core/native/physics/extended_abi.hpp +355 -0
  34. package/core/native/physics/extended_abi_characters.cpp +261 -0
  35. package/core/native/physics/extended_abi_characters.hpp +434 -0
  36. package/core/native/physics/extended_abi_core_features.cpp +713 -0
  37. package/core/native/physics/extended_abi_core_features.hpp +226 -0
  38. package/core/native/physics/extended_abi_deformables.cpp +448 -0
  39. package/core/native/physics/extended_abi_deformables.hpp +867 -0
  40. package/core/native/physics/extended_abi_vehicles.cpp +411 -0
  41. package/core/native/physics/extended_abi_vehicles.hpp +222 -0
  42. package/core/native/physics/fracture.cpp +1981 -0
  43. package/core/native/physics/fracture.hpp +460 -0
  44. package/core/native/physics/gear.cpp +563 -0
  45. package/core/native/physics/gear.hpp +158 -0
  46. package/core/native/physics/geometry_memory.hpp +476 -0
  47. package/core/native/physics/geometry_store.cpp +547 -0
  48. package/core/native/physics/geometry_store.hpp +134 -0
  49. package/core/native/physics/lag_compensation.cpp +1626 -0
  50. package/core/native/physics/lag_compensation.hpp +405 -0
  51. package/core/native/physics/mass_properties.cpp +449 -0
  52. package/core/native/physics/mass_properties.hpp +23 -0
  53. package/core/native/physics/material_pose.hpp +988 -0
  54. package/core/native/physics/particles.cpp +1065 -0
  55. package/core/native/physics/particles.hpp +261 -0
  56. package/core/native/physics/path_joint.cpp +781 -0
  57. package/core/native/physics/path_joint.hpp +154 -0
  58. package/core/native/physics/physics.cpp +13043 -1065
  59. package/core/native/physics/physics.hpp +184 -8
  60. package/core/native/physics/planar_deformable.cpp +2433 -0
  61. package/core/native/physics/planar_deformable.hpp +889 -0
  62. package/core/native/physics/platformer_2d.cpp +1353 -0
  63. package/core/native/physics/platformer_2d.hpp +340 -0
  64. package/core/native/physics/powered_ragdoll.cpp +1100 -0
  65. package/core/native/physics/powered_ragdoll.hpp +279 -0
  66. package/core/native/physics/powertrain.cpp +586 -0
  67. package/core/native/physics/powertrain.hpp +180 -0
  68. package/core/native/physics/pulley.cpp +311 -0
  69. package/core/native/physics/pulley.hpp +121 -0
  70. package/core/native/physics/ragdoll.cpp +586 -0
  71. package/core/native/physics/ragdoll.hpp +221 -0
  72. package/core/native/physics/rope.cpp +692 -0
  73. package/core/native/physics/rope.hpp +215 -0
  74. package/core/native/physics/rounded_convex.cpp +1229 -0
  75. package/core/native/physics/rounded_convex.hpp +287 -0
  76. package/core/native/physics/sdf_geometry.cpp +1821 -0
  77. package/core/native/physics/sdf_geometry.hpp +474 -0
  78. package/core/native/physics/soft_body.cpp +1449 -0
  79. package/core/native/physics/soft_body.hpp +328 -0
  80. package/core/native/physics/soft_collision.cpp +1862 -0
  81. package/core/native/physics/soft_collision.hpp +561 -0
  82. package/core/native/physics/surface_velocity.cpp +366 -0
  83. package/core/native/physics/surface_velocity.hpp +243 -0
  84. package/core/native/physics/topology.cpp +357 -39
  85. package/core/native/physics/topology.hpp +97 -6
  86. package/core/native/physics/tracks.cpp +1179 -0
  87. package/core/native/physics/tracks.hpp +404 -0
  88. package/core/native/physics/vehicle.cpp +629 -0
  89. package/core/native/physics/vehicle.hpp +191 -0
  90. package/core/native/physics/voxel_cooking.cpp +1929 -0
  91. package/core/native/physics/voxel_cooking.hpp +395 -0
  92. package/core/native/physics/world.cpp +5290 -854
  93. package/core/native/physics/world.hpp +796 -24
  94. package/core/native/physics/world_abi.cpp +3840 -306
  95. package/core/native/physics/world_abi.hpp +530 -10
  96. package/core/native/physics/world_digest_visitor.hpp +277 -0
  97. package/core/native/physics/world_strong_digest.hpp +557 -0
  98. package/core/native/physics2d/ccd.cpp +1302 -0
  99. package/core/native/physics2d/ccd.hpp +141 -0
  100. package/core/native/physics2d/checkpoint_memory.hpp +349 -0
  101. package/core/native/physics2d/clock_primitives.hpp +138 -0
  102. package/core/native/physics2d/commands.cpp +174 -28
  103. package/core/native/physics2d/commands.hpp +3 -1
  104. package/core/native/physics2d/compound.cpp +581 -0
  105. package/core/native/physics2d/compound.hpp +248 -0
  106. package/core/native/physics2d/contour.cpp +325 -0
  107. package/core/native/physics2d/contour.hpp +143 -0
  108. package/core/native/physics2d/frame_scope.hpp +124 -0
  109. package/core/native/physics2d/joint_phases.hpp +93 -0
  110. package/core/native/physics2d/joints.cpp +587 -150
  111. package/core/native/physics2d/joints.hpp +5 -0
  112. package/core/native/physics2d/memory_private.hpp +125 -0
  113. package/core/native/physics2d/owned_abi.cpp +1354 -879
  114. package/core/native/physics2d/owned_abi.hpp +190 -52
  115. package/core/native/physics2d/phase_test_hooks.hpp +17 -0
  116. package/core/native/physics2d/physics2d.cpp +2073 -120
  117. package/core/native/physics2d/physics2d.hpp +154 -2
  118. package/core/native/physics2d/queries.cpp +1055 -79
  119. package/core/native/physics2d/queries.hpp +71 -5
  120. package/core/native/physics2d/world.cpp +1313 -353
  121. package/core/native/physics2d/world.hpp +124 -13
  122. package/core/native/sha256/sha256_compress_unsigned.hpp +68 -0
  123. package/core/native/sha256/sha256_fips_constants.hpp +24 -0
  124. package/core/native/sha256/sha256_length.hpp +56 -0
  125. package/core/native/sha256/sha256_memo.hpp +48 -0
  126. package/core/native/sha256/sha256_sink.hpp +234 -0
  127. package/core/physics2d-owned.d.ts +466 -126
  128. package/core/runtime.d.ts +192 -19
  129. package/core/scripts/build-native.mjs +34 -0
  130. package/core/scripts/build-wasm-physics.mjs +272 -23
  131. package/core/scripts/extended-physics-profile.mjs +634 -0
  132. package/core/scripts/generate-physics2d-vectors.mjs +59 -0
  133. package/core/src/kinetix-deterministic-math.d.ts +2 -0
  134. package/core/src/kinetix-deterministic-math.mjs +513 -27
  135. package/core/src/kinetix-owned-runtime-adapter.mjs +788 -0
  136. package/core/src/kinetix-runtime-adapter-utils.mjs +54 -6
  137. package/core/src/kinetix-runtime-contract.mjs +55 -9
  138. package/core/src/kinetix-runtime-identity.mjs +12 -1
  139. package/core/src/kinetix-session-config.mjs +7 -2
  140. package/core/src/kinetix-state-report.mjs +36 -0
  141. package/core/src/physics/abi-constants.mjs +5 -4
  142. package/core/src/physics/articulation.d.mts +194 -0
  143. package/core/src/physics/articulation.mjs +1141 -0
  144. package/core/src/physics/buoyancy.d.mts +143 -0
  145. package/core/src/physics/buoyancy.mjs +268 -0
  146. package/core/src/physics/cloth.d.mts +314 -0
  147. package/core/src/physics/cloth.mjs +1156 -0
  148. package/core/src/physics/deformable-query.d.mts +217 -0
  149. package/core/src/physics/deformable-query.mjs +1412 -0
  150. package/core/src/physics/distance.d.mts +160 -0
  151. package/core/src/physics/distance.mjs +175 -0
  152. package/core/src/physics/extended-wasm-instance.d.mts +5 -0
  153. package/core/src/physics/extended-wasm-instance.mjs +48 -0
  154. package/core/src/physics/feature-api.d.mts +74 -0
  155. package/core/src/physics/feature-api.mjs +98 -0
  156. package/core/src/physics/fracture.d.mts +133 -0
  157. package/core/src/physics/fracture.mjs +1324 -0
  158. package/core/src/physics/gear.d.mts +585 -0
  159. package/core/src/physics/gear.mjs +955 -0
  160. package/core/src/physics/lag-compensation.d.mts +101 -0
  161. package/core/src/physics/lag-compensation.mjs +1100 -0
  162. package/core/src/physics/mass-properties.d.mts +114 -0
  163. package/core/src/physics/mass-properties.mjs +137 -468
  164. package/core/src/physics/particles.d.mts +177 -0
  165. package/core/src/physics/particles.mjs +758 -0
  166. package/core/src/physics/path-joint.d.mts +171 -0
  167. package/core/src/physics/path-joint.mjs +1231 -0
  168. package/core/src/physics/physics-extended-wasm-module.generated.mjs +13 -0
  169. package/core/src/physics/physics-profile-wasm-module.generated.mjs +48 -0
  170. package/core/src/physics/physics-wasm-module.generated.mjs +34 -5
  171. package/core/src/physics/powered-ragdoll.d.mts +188 -0
  172. package/core/src/physics/powered-ragdoll.mjs +1043 -0
  173. package/core/src/physics/powertrain.d.mts +260 -0
  174. package/core/src/physics/powertrain.mjs +621 -0
  175. package/core/src/physics/pulley.d.mts +98 -0
  176. package/core/src/physics/pulley.mjs +686 -0
  177. package/core/src/physics/ragdoll.d.mts +289 -0
  178. package/core/src/physics/ragdoll.mjs +1323 -0
  179. package/core/src/physics/rope.d.mts +241 -0
  180. package/core/src/physics/rope.mjs +319 -0
  181. package/core/src/physics/rounded-convex.d.mts +328 -0
  182. package/core/src/physics/rounded-convex.mjs +1404 -0
  183. package/core/src/physics/sdf-geometry.d.mts +117 -0
  184. package/core/src/physics/sdf-geometry.mjs +1204 -0
  185. package/core/src/physics/soft-body.d.mts +144 -0
  186. package/core/src/physics/soft-body.mjs +1285 -0
  187. package/core/src/physics/soft-collision.d.mts +651 -0
  188. package/core/src/physics/soft-collision.mjs +1883 -0
  189. package/core/src/physics/surface-velocity.d.mts +156 -0
  190. package/core/src/physics/surface-velocity.mjs +722 -0
  191. package/core/src/physics/tracks.d.mts +411 -0
  192. package/core/src/physics/tracks.mjs +1074 -0
  193. package/core/src/physics/vehicle.d.mts +3 -0
  194. package/core/src/physics/vehicle.mjs +172 -0
  195. package/core/src/physics/voxel-cooking.d.mts +219 -0
  196. package/core/src/physics/voxel-cooking.mjs +1499 -0
  197. package/core/src/physics/voxel-swept-quad.mjs +110 -0
  198. package/core/src/physics/wasm-instance.mjs +160 -23
  199. package/core/src/physics/world.d.mts +62 -0
  200. package/core/src/physics/world.mjs +1947 -152
  201. package/core/src/physics2d/body-state.mjs +218 -15
  202. package/core/src/physics2d/collision.d.mts +52 -0
  203. package/core/src/physics2d/collision.mjs +234 -0
  204. package/core/src/physics2d/compound.mjs +454 -0
  205. package/core/src/physics2d/contour-state.mjs +771 -0
  206. package/core/src/physics2d/feature-api.d.mts +211 -0
  207. package/core/src/physics2d/feature-api.mjs +3 -0
  208. package/core/src/physics2d/fluid-state.mjs +145 -0
  209. package/core/src/physics2d/joint-state.mjs +1 -1
  210. package/core/src/physics2d/owned-queries.mjs +3 -1
  211. package/core/src/physics2d/owned-transport.mjs +268 -122
  212. package/core/src/physics2d/owned-world.mjs +353 -230
  213. package/core/src/physics2d/particle-fluid.d.mts +152 -0
  214. package/core/src/physics2d/particle-fluid.mjs +233 -0
  215. package/core/src/physics2d/physics2d-wasm-module.generated.mjs +27 -10
  216. package/core/src/physics2d/query-codec.mjs +61 -13
  217. package/core/src/physics2d/submerged-geometry.d.mts +51 -0
  218. package/core/src/physics2d/submerged-geometry.mjs +186 -0
  219. package/core/src/runtime.mjs +23 -0
  220. package/core/src/shared/bytes.d.mts +2 -0
  221. package/core/src/shared/bytes.mjs +33 -0
  222. package/core/src/shared/sha256.d.mts +3 -0
  223. package/core/src/shared/sha256.mjs +72 -22
  224. package/core/units.d.ts +50 -0
  225. package/core/world.d.ts +253 -5
  226. package/dist/authority-room.d.ts +9 -0
  227. package/dist/authority-room.js +45 -16
  228. package/dist/browser.d.ts +6 -5
  229. package/dist/browser.js +4 -3
  230. package/dist/cadence.d.ts +7 -0
  231. package/dist/cadence.js +19 -0
  232. package/dist/canonical.d.ts +1 -0
  233. package/dist/canonical.js +3 -0
  234. package/dist/checksum-policy.d.ts +10 -0
  235. package/dist/checksum-policy.js +14 -0
  236. package/dist/collider-cooking-hull.d.ts +18 -0
  237. package/dist/collider-cooking-hull.js +248 -0
  238. package/dist/collider-cooking.d.ts +140 -0
  239. package/dist/collider-cooking.js +794 -0
  240. package/dist/compat/v5.d.ts +121 -0
  241. package/dist/compat/v5.js +479 -0
  242. package/dist/creator.d.ts +7 -6
  243. package/dist/creator.js +4 -3
  244. package/dist/game-byte-section.d.ts +36 -0
  245. package/dist/game-byte-section.js +350 -0
  246. package/dist/index.d.ts +13 -6
  247. package/dist/index.js +9 -4
  248. package/dist/instant-replay.d.ts +27 -2
  249. package/dist/instant-replay.js +91 -16
  250. package/dist/lag-compensation3d.js +11 -10
  251. package/dist/match-log.d.ts +21 -4
  252. package/dist/match-log.js +92 -9
  253. package/dist/math.d.ts +2 -0
  254. package/dist/math.js +1 -0
  255. package/dist/modules/character-3d.d.ts +16 -1
  256. package/dist/modules/character-3d.js +42 -5
  257. package/dist/modules/combat.js +6 -5
  258. package/dist/movement3d-revision1.d.ts +2 -0
  259. package/dist/movement3d-revision1.js +973 -0
  260. package/dist/movement3d.d.ts +53 -3
  261. package/dist/movement3d.js +917 -247
  262. package/dist/networked-client.d.ts +15 -0
  263. package/dist/networked-client.js +378 -105
  264. package/dist/node.d.ts +3 -2
  265. package/dist/node.js +2 -1
  266. package/dist/physics/2d.d.ts +38 -4
  267. package/dist/physics/2d.js +57 -36
  268. package/dist/physics/3d.d.ts +755 -111
  269. package/dist/physics/3d.js +2355 -158
  270. package/dist/physics/edit-result-graph.d.ts +36 -0
  271. package/dist/physics/edit-result-graph.js +141 -0
  272. package/dist/physics/game-codec3d.d.ts +41 -0
  273. package/dist/physics/game-codec3d.js +544 -0
  274. package/dist/physics/installed-checkpoint3d.d.ts +13 -0
  275. package/dist/physics/installed-checkpoint3d.js +120 -0
  276. package/dist/physics/installed-runtime3d.d.ts +51 -0
  277. package/dist/physics/installed-runtime3d.js +372 -0
  278. package/dist/physics/installed-state-commitment3d.d.ts +2 -0
  279. package/dist/physics/installed-state-commitment3d.js +24 -0
  280. package/dist/physics/units.d.ts +38 -0
  281. package/dist/physics/units.js +56 -0
  282. package/dist/physics/vehicle-state3d.d.ts +93 -0
  283. package/dist/physics/vehicle-state3d.js +1191 -0
  284. package/dist/physics/voxel-body-state.d.ts +61 -0
  285. package/dist/physics/voxel-body-state.js +410 -0
  286. package/dist/r3f-render-adapter.d.ts +59 -1
  287. package/dist/r3f-render-adapter.js +137 -2
  288. package/dist/replay.d.ts +13 -0
  289. package/dist/replay.js +95 -70
  290. package/dist/run-room-transport.js +5 -1
  291. package/dist/runner.d.ts +17 -2
  292. package/dist/runner.js +472 -84
  293. package/dist/runtime-cleanup.d.ts +54 -0
  294. package/dist/runtime-cleanup.js +266 -0
  295. package/dist/runtime-lease.d.ts +11 -1
  296. package/dist/runtime-lease.js +23 -10
  297. package/dist/runtime-room-metadata.d.ts +2 -8
  298. package/dist/runtime-room-metadata.js +11 -14
  299. package/dist/runtime-session.d.ts +8 -0
  300. package/dist/runtime-session.js +222 -58
  301. package/dist/schema-codegen.js +3 -0
  302. package/dist/schema-dsl-binary.d.ts +10 -4
  303. package/dist/schema-dsl-binary.js +375 -76
  304. package/dist/scratch-pool.d.ts +32 -0
  305. package/dist/scratch-pool.js +60 -0
  306. package/dist/sdk-session.d.ts +1 -0
  307. package/dist/sdk-session.js +4 -0
  308. package/dist/secret-config.js +2 -60
  309. package/dist/secret-crypto.js +70 -36
  310. package/dist/session-snapshot.d.ts +15 -4
  311. package/dist/session-snapshot.js +35 -33
  312. package/dist/session-wire.js +14 -22
  313. package/dist/sparse-set.d.ts +1 -0
  314. package/dist/sparse-set.js +22 -0
  315. package/dist/spatial/spatial-grid-3d.d.ts +41 -0
  316. package/dist/spatial/spatial-grid-3d.js +115 -0
  317. package/dist/synctest.d.ts +9 -0
  318. package/dist/synctest.js +106 -17
  319. package/dist/testing-network.d.ts +2 -0
  320. package/dist/testing-network.js +122 -18
  321. package/dist/testing.d.ts +27 -6
  322. package/dist/testing.js +297 -56
  323. package/dist/tools/index.d.ts +3 -2
  324. package/dist/tools/index.js +3 -2
  325. package/dist/tools/module-certification.d.ts +6 -0
  326. package/dist/tools/module-certification.js +26 -2
  327. package/package.json +18 -5
  328. package/core/scripts/run-box3d-benchmark.mjs +0 -350
  329. package/core/src/physics/index.mjs +0 -3169
@@ -0,0 +1,115 @@
1
+ import { SyncplayError } from '../errors.js';
2
+ export class DeterministicSpatialGrid3D {
3
+ cellSize;
4
+ capacity;
5
+ invCellSize;
6
+ // Spatial hash map: key -> array of entity IDs
7
+ cells = new Map();
8
+ // Set to avoid duplicate entries when an entity spans or when checking candidate buckets
9
+ candidateSet = new Set();
10
+ entityCount = 0;
11
+ constructor(cellSize, capacity = 4096) {
12
+ this.cellSize = cellSize;
13
+ this.capacity = capacity;
14
+ if (!Number.isFinite(cellSize) || cellSize <= 0) {
15
+ throw new RangeError(`cellSize must be a positive finite number, got ${cellSize}`);
16
+ }
17
+ this.invCellSize = 1 / cellSize;
18
+ }
19
+ /**
20
+ * Clears all cells in the spatial grid.
21
+ */
22
+ clear() {
23
+ this.cells.clear();
24
+ this.candidateSet.clear();
25
+ this.entityCount = 0;
26
+ }
27
+ hashCoords(cx, cy, cz) {
28
+ return `${cx},${cy},${cz}`;
29
+ }
30
+ /**
31
+ * Inserts an entity into the grid.
32
+ */
33
+ insert(entityId, x, y, z) {
34
+ if (!Number.isSafeInteger(entityId) || entityId < 0) {
35
+ throw new RangeError(`entityId must be a non-negative safe integer, got ${entityId}`);
36
+ }
37
+ if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) {
38
+ throw new RangeError(`Coordinates must be finite numbers, got (${x}, ${y}, ${z})`);
39
+ }
40
+ if (this.entityCount >= this.capacity) {
41
+ throw new SyncplayError(`DeterministicSpatialGrid3D capacity overflow: grid holds ${this.entityCount} entities, maximum capacity is ${this.capacity}`, { code: 'BUFFER_OVERFLOW', operation: 'insert' });
42
+ }
43
+ const cx = Math.floor(x * this.invCellSize);
44
+ const cy = Math.floor(y * this.invCellSize);
45
+ const cz = Math.floor(z * this.invCellSize);
46
+ const key = this.hashCoords(cx, cy, cz);
47
+ let cell = this.cells.get(key);
48
+ if (!cell) {
49
+ cell = [];
50
+ this.cells.set(key, cell);
51
+ }
52
+ cell.push(entityId);
53
+ this.entityCount += 1;
54
+ }
55
+ /**
56
+ * Queries entities within radius, writing ascending-sorted entity IDs into outEntityIds.
57
+ * Throws SyncplayError if outEntityIds capacity is insufficient.
58
+ */
59
+ queryRadius(centerX, centerY, centerZ, radius, outEntityIds) {
60
+ if (!Number.isFinite(centerX) || !Number.isFinite(centerY) || !Number.isFinite(centerZ)) {
61
+ throw new RangeError(`Query center must be finite numbers, got (${centerX}, ${centerY}, ${centerZ})`);
62
+ }
63
+ if (!Number.isFinite(radius) || radius < 0) {
64
+ throw new RangeError(`Query radius must be a non-negative finite number, got ${radius}`);
65
+ }
66
+ const minX = centerX - radius;
67
+ const maxX = centerX + radius;
68
+ const minY = centerY - radius;
69
+ const maxY = centerY + radius;
70
+ const minZ = centerZ - radius;
71
+ const maxZ = centerZ + radius;
72
+ return this.queryAABB(minX, minY, minZ, maxX, maxY, maxZ, outEntityIds);
73
+ }
74
+ /**
75
+ * Queries entities within an Axis-Aligned Bounding Box, writing ascending-sorted entity IDs into outEntityIds.
76
+ * Throws SyncplayError if outEntityIds capacity is insufficient.
77
+ */
78
+ queryAABB(minX, minY, minZ, maxX, maxY, maxZ, outEntityIds) {
79
+ if (!Number.isFinite(minX) || !Number.isFinite(minY) || !Number.isFinite(minZ) ||
80
+ !Number.isFinite(maxX) || !Number.isFinite(maxY) || !Number.isFinite(maxZ)) {
81
+ throw new RangeError('AABB coordinates must be finite numbers');
82
+ }
83
+ const startCX = Math.floor(minX * this.invCellSize);
84
+ const endCX = Math.floor(maxX * this.invCellSize);
85
+ const startCY = Math.floor(minY * this.invCellSize);
86
+ const endCY = Math.floor(maxY * this.invCellSize);
87
+ const startCZ = Math.floor(minZ * this.invCellSize);
88
+ const endCZ = Math.floor(maxZ * this.invCellSize);
89
+ this.candidateSet.clear();
90
+ // Canonical cell traversal order
91
+ for (let cx = startCX; cx <= endCX; cx += 1) {
92
+ for (let cy = startCY; cy <= endCY; cy += 1) {
93
+ for (let cz = startCZ; cz <= endCZ; cz += 1) {
94
+ const key = this.hashCoords(cx, cy, cz);
95
+ const cell = this.cells.get(key);
96
+ if (cell) {
97
+ for (let i = 0; i < cell.length; i += 1) {
98
+ this.candidateSet.add(cell[i]);
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ const count = this.candidateSet.size;
105
+ if (count > outEntityIds.length) {
106
+ throw new SyncplayError(`DeterministicSpatialGrid3D query overflow: found ${count} entities, buffer capacity is ${outEntityIds.length}`, { code: 'BUFFER_OVERFLOW', operation: 'queryAABB' });
107
+ }
108
+ // Collect into array for deterministic sorting
109
+ const sorted = Array.from(this.candidateSet).sort((a, b) => a - b);
110
+ for (let i = 0; i < sorted.length; i += 1) {
111
+ outEntityIds[i] = sorted[i];
112
+ }
113
+ return count;
114
+ }
115
+ }
@@ -1,6 +1,7 @@
1
1
  import { DeterministicRandom } from './random.js';
2
2
  import { type SyncplaySessionPolicy } from './sdk-session.js';
3
3
  import type { ProjectionCapableRuntime } from './runtime-session.js';
4
+ import type { RuntimeFactoryResult } from './runtime-lease.js';
4
5
  export type SyncplaySynctestPhase = 'straight' | 'rollback' | 'replay' | 'hydration';
5
6
  export type SyncplaySynctestInputFuzz<Input> = (random: DeterministicRandom, slot: number, frame: number) => Input;
6
7
  export interface SyncplaySynctestConfig<State, Input, Checkpoint = unknown, Projection = State> {
@@ -10,6 +11,13 @@ export interface SyncplaySynctestConfig<State, Input, Checkpoint = unknown, Proj
10
11
  readonly seeds?: readonly number[];
11
12
  readonly inputFuzz?: SyncplaySynctestInputFuzz<Input>;
12
13
  }
14
+ export interface SyncplaySynctestConfigAsync<State, Input, Checkpoint = unknown, Projection = State> {
15
+ readonly runtimeFactory: (seed: number) => RuntimeFactoryResult<ProjectionCapableRuntime<State, Input, Checkpoint, Projection>> | PromiseLike<RuntimeFactoryResult<ProjectionCapableRuntime<State, Input, Checkpoint, Projection>>>;
16
+ readonly policy: SyncplaySessionPolicy<State, Input, Checkpoint, Projection>;
17
+ readonly frames?: number;
18
+ readonly seeds?: readonly number[];
19
+ readonly inputFuzz?: SyncplaySynctestInputFuzz<Input>;
20
+ }
13
21
  export interface SyncplaySynctestDivergence {
14
22
  readonly seed: number;
15
23
  readonly frame: number;
@@ -24,3 +32,4 @@ export interface SyncplaySynctestResult {
24
32
  readonly firstDivergence?: SyncplaySynctestDivergence;
25
33
  }
26
34
  export declare function runSyncplaySynctest<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplaySynctestConfig<State, Input, Checkpoint, Projection>): SyncplaySynctestResult;
35
+ export declare function runSyncplaySynctestAsync<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplaySynctestConfigAsync<State, Input, Checkpoint, Projection>): Promise<SyncplaySynctestResult>;
package/dist/synctest.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import { stableSortedKeys } from './collections.js';
2
2
  import { invariant } from './errors.js';
3
+ import { ensureDeterministicMathInstalled } from './math.js';
3
4
  import { DeterministicRandom } from './random.js';
4
- import { verifyReplay } from './replay.js';
5
+ import { verifyReplay, verifyReplayAsync } from './replay.js';
5
6
  import { createSyncplaySession } from './sdk-session.js';
7
+ import { assertNotOwnedLease, runWithSessionAndLease, runWithSessionCleanup } from './runtime-cleanup.js';
6
8
  export function runSyncplaySynctest(config) {
7
9
  const frames = config.frames ?? 300;
8
10
  const seeds = config.seeds ?? [1, 2, 3];
@@ -14,13 +16,19 @@ export function runSyncplaySynctest(config) {
14
16
  for (const seed of seeds) {
15
17
  seedsRun += 1;
16
18
  const schedule = buildInputSchedule(config.policy.playerCount, frames, seed, inputFuzz);
17
- const straight = createSyncplaySession(config.runtimeFactory(seed), { ...config.policy, checksumIntervalFrames: 1 });
19
+ ensureDeterministicMathInstalled();
20
+ const straightRuntime = config.runtimeFactory(seed);
21
+ assertNotOwnedLease(straightRuntime, 'runSyncplaySynctest', 'runSyncplaySynctestAsync');
22
+ const straight = createSyncplaySession(straightRuntime, { ...config.policy, checksumIntervalFrames: 1 });
18
23
  const straightChecksums = [];
19
- try {
24
+ const seedResult = runWithSessionCleanup(straight, () => {
20
25
  for (let index = 0; index < frames; index += 1) {
21
26
  const external = straight.exportExternalSnapshot(straight.currentFrame);
22
- const hydrated = createSyncplaySession(config.runtimeFactory(seed), { ...config.policy, checksumIntervalFrames: 1 });
23
- try {
27
+ ensureDeterministicMathInstalled();
28
+ const hydratedRuntime = config.runtimeFactory(seed);
29
+ assertNotOwnedLease(hydratedRuntime, 'runSyncplaySynctest', 'runSyncplaySynctestAsync');
30
+ const hydrated = createSyncplaySession(hydratedRuntime, { ...config.policy, checksumIntervalFrames: 1 });
31
+ const hydrationResult = runWithSessionCleanup(hydrated, () => {
24
32
  hydrated.restoreSnapshot(external);
25
33
  applyInputs(straight, schedule[index]);
26
34
  straight.stepFrames(1);
@@ -32,13 +40,15 @@ export function runSyncplaySynctest(config) {
32
40
  if (straightChecksum !== hydratedChecksum) {
33
41
  return diverged(seedsRun, framesChecked, seed, straight.currentFrame, 'hydration', straightChecksum, hydratedChecksum);
34
42
  }
35
- }
36
- finally {
37
- hydrated.dispose();
38
- }
43
+ });
44
+ if (hydrationResult !== undefined)
45
+ return hydrationResult;
39
46
  }
40
- const rollback = createSyncplaySession(config.runtimeFactory(seed), { ...config.policy, checksumIntervalFrames: 1 });
41
- try {
47
+ ensureDeterministicMathInstalled();
48
+ const rollbackRuntime = config.runtimeFactory(seed);
49
+ assertNotOwnedLease(rollbackRuntime, 'runSyncplaySynctest', 'runSyncplaySynctestAsync');
50
+ const rollback = createSyncplaySession(rollbackRuntime, { ...config.policy, checksumIntervalFrames: 1 });
51
+ const rollbackResult = runWithSessionCleanup(rollback, () => {
42
52
  for (let index = 0; index < frames; index += 1) {
43
53
  applyInputs(rollback, schedule[index]);
44
54
  rollback.stepFrames(1);
@@ -54,10 +64,9 @@ export function runSyncplaySynctest(config) {
54
64
  if (second !== expected)
55
65
  return diverged(seedsRun, framesChecked, seed, index + 1, 'rollback', expected, second);
56
66
  }
57
- }
58
- finally {
59
- rollback.dispose();
60
- }
67
+ });
68
+ if (rollbackResult !== undefined)
69
+ return rollbackResult;
61
70
  const replay = straight.exportReplay();
62
71
  const replayResult = verifyReplay({
63
72
  replay,
@@ -68,9 +77,89 @@ export function runSyncplaySynctest(config) {
68
77
  if (replayResult.firstMismatch !== undefined) {
69
78
  return diverged(seedsRun, framesChecked, seed, replayResult.firstMismatch.frame, 'replay', replayResult.firstMismatch.expectedChecksum, replayResult.firstMismatch.actualChecksum);
70
79
  }
80
+ });
81
+ if (seedResult !== undefined)
82
+ return seedResult;
83
+ }
84
+ return { ok: true, seedsRun, framesChecked };
85
+ }
86
+ export async function runSyncplaySynctestAsync(config) {
87
+ const frames = config.frames ?? 300;
88
+ const seeds = config.seeds ?? [1, 2, 3];
89
+ invariant(Number.isSafeInteger(frames) && frames >= 1, 'synctest frames must be a positive integer', 'synctest.frames');
90
+ invariant(seeds.length > 0 && seeds.every(Number.isSafeInteger), 'synctest seeds must be integers', 'synctest.seeds');
91
+ const inputFuzz = config.inputFuzz ?? createDefaultInputFuzz(config.policy.defaultInput);
92
+ let framesChecked = 0;
93
+ let seedsRun = 0;
94
+ for (const seed of seeds) {
95
+ seedsRun += 1;
96
+ const schedule = buildInputSchedule(config.policy.playerCount, frames, seed, inputFuzz);
97
+ const straightChecksums = [];
98
+ let exportedReplay;
99
+ const straightDivergence = await runWithSessionAndLease(() => config.runtimeFactory(seed), async (straightRuntime, registerStraightSession) => {
100
+ const straight = createSyncplaySession(straightRuntime, { ...config.policy, checksumIntervalFrames: 1 });
101
+ registerStraightSession(straight);
102
+ for (let index = 0; index < frames; index += 1) {
103
+ const external = straight.exportExternalSnapshot(straight.currentFrame);
104
+ const hydrationDivergence = await runWithSessionAndLease(() => config.runtimeFactory(seed), async (hydratedRuntime, registerHydratedSession) => {
105
+ const hydrated = createSyncplaySession(hydratedRuntime, { ...config.policy, checksumIntervalFrames: 1 });
106
+ registerHydratedSession(hydrated);
107
+ hydrated.restoreSnapshot(external);
108
+ applyInputs(straight, schedule[index]);
109
+ straight.stepFrames(1);
110
+ applyInputs(hydrated, schedule[index]);
111
+ hydrated.stepFrames(1);
112
+ const straightChecksum = straight.computeRecordedChecksum(straight.currentFrame);
113
+ const hydratedChecksum = hydrated.computeRecordedChecksum(hydrated.currentFrame);
114
+ straightChecksums.push(straightChecksum);
115
+ if (straightChecksum !== hydratedChecksum) {
116
+ return diverged(seedsRun, framesChecked, seed, straight.currentFrame, 'hydration', straightChecksum, hydratedChecksum);
117
+ }
118
+ return undefined;
119
+ });
120
+ if (hydrationDivergence !== undefined) {
121
+ return hydrationDivergence;
122
+ }
123
+ }
124
+ exportedReplay = straight.exportReplay();
125
+ return undefined;
126
+ });
127
+ if (straightDivergence !== undefined) {
128
+ return straightDivergence;
129
+ }
130
+ const rollbackDivergence = await runWithSessionAndLease(() => config.runtimeFactory(seed), async (rollbackRuntime, registerRollbackSession) => {
131
+ const rollback = createSyncplaySession(rollbackRuntime, { ...config.policy, checksumIntervalFrames: 1 });
132
+ registerRollbackSession(rollback);
133
+ for (let index = 0; index < frames; index += 1) {
134
+ applyInputs(rollback, schedule[index]);
135
+ rollback.stepFrames(1);
136
+ const first = rollback.computeRecordedChecksum(rollback.currentFrame);
137
+ rollback.restoreToFrame(index);
138
+ applyInputs(rollback, schedule[index]);
139
+ rollback.stepFrames(1);
140
+ const second = rollback.computeRecordedChecksum(rollback.currentFrame);
141
+ framesChecked += 1;
142
+ const expected = straightChecksums[index];
143
+ if (first !== expected)
144
+ return diverged(seedsRun, framesChecked, seed, index + 1, 'straight', expected, first);
145
+ if (second !== expected)
146
+ return diverged(seedsRun, framesChecked, seed, index + 1, 'rollback', expected, second);
147
+ }
148
+ return undefined;
149
+ });
150
+ if (rollbackDivergence !== undefined) {
151
+ return rollbackDivergence;
71
152
  }
72
- finally {
73
- straight.dispose();
153
+ if (exportedReplay !== undefined) {
154
+ const replayResult = await verifyReplayAsync({
155
+ replay: exportedReplay,
156
+ runtimeFactory: () => config.runtimeFactory(seed),
157
+ policy: { ...config.policy, checksumIntervalFrames: 1 },
158
+ throwOnMismatch: false,
159
+ });
160
+ if (replayResult.firstMismatch !== undefined) {
161
+ return diverged(seedsRun, framesChecked, seed, replayResult.firstMismatch.frame, 'replay', replayResult.firstMismatch.expectedChecksum, replayResult.firstMismatch.actualChecksum);
162
+ }
74
163
  }
75
164
  }
76
165
  return { ok: true, seedsRun, framesChecked };
@@ -29,6 +29,8 @@ export interface SimulatedSyncplayMatch {
29
29
  openTransport(playerId: string, link?: Partial<SimulatedSyncplayLink>): SimulatedSyncplayTransport;
30
30
  advance(steps: number): void;
31
31
  settle(maxSteps?: number): void;
32
+ advanceAsync(steps: number): Promise<void>;
33
+ settleAsync(maxSteps?: number): Promise<void>;
32
34
  }
33
35
  export declare function createSimulatedSyncplayMatch(options: {
34
36
  readonly roomConfig: DeterministicAuthorityRoomConfig;
@@ -1,6 +1,7 @@
1
1
  import { createDeterministicAuthorityRoom, } from './authority-room.js';
2
2
  import { DeterministicRandom } from './random.js';
3
3
  import { createNetworkedSyncplayClient, } from './networked-client.js';
4
+ import { SyncplayAggregateCleanupError, SyncplayRuntimeLeaseRequiredError, } from './runtime-cleanup.js';
4
5
  const DEFAULT_SECRET_MSG_TYPE = 'rdm-secret';
5
6
  export function createSimulatedSyncplayMatch(options) {
6
7
  const rng = new DeterministicRandom(options.networkSeed ?? options.roomConfig.seed);
@@ -36,6 +37,33 @@ export function createSimulatedSyncplayMatch(options) {
36
37
  while (queue.length > 0 && queue[0].deliverAt <= step)
37
38
  queue.shift()?.deliver();
38
39
  }
40
+ async function awaitActiveGeneration() {
41
+ for (const endpoint of [...endpoints]) {
42
+ if (endpoint.greetingDelivered !== true || endpoint.whenReady === undefined)
43
+ continue;
44
+ endpoint.greetingDelivered = false;
45
+ await endpoint.whenReady();
46
+ if (endpoint.isReady !== undefined && endpoint.isReady() !== true) {
47
+ throw new Error('SYNCPLAY_TEST_GENERATION_INACTIVE');
48
+ }
49
+ }
50
+ }
51
+ function rethrowConnectFailure(error, disposal, disposeError) {
52
+ const jobs = [];
53
+ if (disposal !== undefined)
54
+ jobs.push(() => disposal);
55
+ if (disposeError !== undefined)
56
+ jobs.push(async () => { throw disposeError; });
57
+ if (error instanceof SyncplayRuntimeLeaseRequiredError) {
58
+ for (const job of jobs)
59
+ error.addJob(job);
60
+ throw error;
61
+ }
62
+ if (jobs.length === 0)
63
+ throw error;
64
+ const carrier = new SyncplayRuntimeLeaseRequiredError('createSimulatedSyncplayMatch.connect', 'assertTwoClientConvergenceAsync', { jobs, cause: error });
65
+ throw new SyncplayAggregateCleanupError([error, carrier], 'SYNCPLAY_CLEANUP_FAILED', { cause: error });
66
+ }
39
67
  const room = createDeterministicAuthorityRoom({
40
68
  broadcast: (_msgType, payload) => {
41
69
  for (const endpoint of endpoints) {
@@ -47,7 +75,11 @@ export function createSimulatedSyncplayMatch(options) {
47
75
  if (endpoint === undefined)
48
76
  return;
49
77
  const handlers = msgType === secretMsgType ? secretHandlers : clientHandlers;
50
- schedule(endpoint.downlink, () => handlers.get(playerId)?.(payload));
78
+ schedule(endpoint.downlink, () => {
79
+ if (msgType !== secretMsgType)
80
+ endpoint.greetingDelivered = true;
81
+ handlers.get(playerId)?.(payload);
82
+ });
51
83
  },
52
84
  }, options.roomConfig);
53
85
  return {
@@ -57,24 +89,71 @@ export function createSimulatedSyncplayMatch(options) {
57
89
  const configuredLink = normalizedLink(link);
58
90
  const uplink = { latencyMin: 0, latencyMax: 0, lossRate: 0 };
59
91
  const downlink = { latencyMin: 0, latencyMax: 0, lossRate: 0 };
60
- const client = createNetworkedSyncplayClient({
61
- ...clientOptions,
62
- transport: {
92
+ let client;
93
+ let endpoint;
94
+ let seated = false;
95
+ try {
96
+ client = createNetworkedSyncplayClient({
97
+ ...clientOptions,
98
+ transport: {
99
+ playerId,
100
+ send: (text) => schedule(uplink, () => room.onPlayerMessage(playerId, text)),
101
+ onMessage: (handler) => { clientHandlers.set(playerId, handler); },
102
+ sendSecret: (text) => schedule(uplink, () => room.onPlayerSecretMessage(playerId, text)),
103
+ onSecretMessage: (handler) => { secretHandlers.set(playerId, handler); },
104
+ },
105
+ });
106
+ endpoint = {
63
107
  playerId,
64
- send: (text) => schedule(uplink, () => room.onPlayerMessage(playerId, text)),
65
- onMessage: (handler) => { clientHandlers.set(playerId, handler); },
66
- sendSecret: (text) => schedule(uplink, () => room.onPlayerSecretMessage(playerId, text)),
67
- onSecretMessage: (handler) => { secretHandlers.set(playerId, handler); },
68
- },
69
- });
70
- const peer = { playerId, client, uplink, downlink };
71
- endpoints.push({ playerId, uplink, downlink, pump: () => client.pump() });
72
- const joined = room.onPlayerJoin(playerId);
73
- if (!joined.accepted)
74
- throw new Error(`simulated join rejected for ${playerId}: ${joined.reason}`);
75
- Object.assign(uplink, configuredLink);
76
- Object.assign(downlink, configuredLink);
77
- return peer;
108
+ uplink,
109
+ downlink,
110
+ pump: () => client?.pump(),
111
+ whenReady: () => {
112
+ if (client === undefined)
113
+ return Promise.resolve();
114
+ return client.whenReady();
115
+ },
116
+ isReady: () => client?.ready === true,
117
+ greetingDelivered: false,
118
+ };
119
+ endpoints.push(endpoint);
120
+ const joined = room.onPlayerJoin(playerId);
121
+ if (!joined.accepted)
122
+ throw new Error(`simulated join rejected for ${playerId}: ${joined.reason}`);
123
+ seated = true;
124
+ deliverDue();
125
+ Object.assign(uplink, configuredLink);
126
+ Object.assign(downlink, configuredLink);
127
+ return { playerId, client, uplink, downlink };
128
+ }
129
+ catch (error) {
130
+ if (endpoint !== undefined) {
131
+ const index = endpoints.indexOf(endpoint);
132
+ if (index >= 0)
133
+ endpoints.splice(index, 1);
134
+ }
135
+ clientHandlers.delete(playerId);
136
+ secretHandlers.delete(playerId);
137
+ let disposal;
138
+ let disposeError;
139
+ if (client !== undefined) {
140
+ try {
141
+ disposal = client.dispose();
142
+ }
143
+ catch (caught) {
144
+ disposeError = caught;
145
+ }
146
+ }
147
+ if (seated) {
148
+ try {
149
+ room.onPlayerLeave(playerId);
150
+ }
151
+ catch (caught) {
152
+ disposeError = disposeError ?? caught;
153
+ }
154
+ }
155
+ rethrowConnectFailure(error, disposal, disposeError);
156
+ }
78
157
  },
79
158
  openTransport(playerId, link = {}) {
80
159
  const configuredLink = normalizedLink(link);
@@ -137,5 +216,30 @@ export function createSimulatedSyncplayMatch(options) {
137
216
  endpoint.pump?.();
138
217
  }
139
218
  },
219
+ async advanceAsync(steps) {
220
+ await awaitActiveGeneration();
221
+ for (let index = 0; index < steps; index += 1) {
222
+ step += 1;
223
+ deliverDue();
224
+ await awaitActiveGeneration();
225
+ room.onTick();
226
+ for (const endpoint of [...endpoints])
227
+ endpoint.pump?.();
228
+ }
229
+ },
230
+ async settleAsync(maxSteps = 64) {
231
+ for (const endpoint of endpoints) {
232
+ Object.assign(endpoint.uplink, { latencyMin: 0, latencyMax: 0, lossRate: 0 });
233
+ Object.assign(endpoint.downlink, { latencyMin: 0, latencyMax: 0, lossRate: 0 });
234
+ }
235
+ await awaitActiveGeneration();
236
+ for (let index = 0; index < maxSteps; index += 1) {
237
+ step += 1;
238
+ deliverDue();
239
+ await awaitActiveGeneration();
240
+ for (const endpoint of [...endpoints])
241
+ endpoint.pump?.();
242
+ }
243
+ },
140
244
  };
141
245
  }
package/dist/testing.d.ts CHANGED
@@ -1,18 +1,29 @@
1
- export { runSyncplaySynctest } from './synctest.js';
1
+ export { runSyncplaySynctest, runSyncplaySynctestAsync } from './synctest.js';
2
2
  export { createSimulatedSyncplayMatch } from './testing-network.js';
3
- export type { SyncplaySynctestConfig, SyncplaySynctestDivergence, SyncplaySynctestResult, } from './synctest.js';
3
+ export type { SyncplaySynctestConfig, SyncplaySynctestConfigAsync, SyncplaySynctestDivergence, SyncplaySynctestInputFuzz, SyncplaySynctestPhase, SyncplaySynctestResult, } from './synctest.js';
4
4
  export type { SimulatedSyncplayLink, SimulatedSyncplayMatch, SimulatedSyncplayPeer, SimulatedSyncplayTransport, } from './testing-network.js';
5
5
  export { assertPresentationParity, assertRunnerLifecycle, createSyncplayRunnerHarness, } from './runner-harness.js';
6
6
  export type { SyncplayPresentationParityConfig, SyncplayPresentationParityProof, SyncplayRunnerHarness, SyncplayRunnerHarnessConfig, SyncplayRunnerLifecycleProof, SyncplayRunnerStatusTransition, } from './runner-harness.js';
7
7
  import type { DeterministicAuthorityRoomConfig } from './authority-room.js';
8
- import type { NetworkedSyncplayClientOptions } from './networked-client.js';
9
- import { type ReplayVerificationConfig } from './replay.js';
10
- import { type SyncplaySynctestConfig, type SyncplaySynctestResult } from './synctest.js';
8
+ import { type KinetixRuntimeFactory, type NetworkedSyncplayClientOptions } from './networked-client.js';
9
+ import { type ReplayVerificationConfig, type ReplayVerificationConfigAsync } from './replay.js';
10
+ import { type SyncplaySynctestConfig, type SyncplaySynctestConfigAsync, type SyncplaySynctestResult } from './synctest.js';
11
11
  import { type SimulatedSyncplayLink } from './testing-network.js';
12
12
  import type { ReplayVerificationResult } from './types.js';
13
+ export type SyncplaySyncClientOptions<State, Input, Checkpoint = unknown, Projection = State> = Omit<NetworkedSyncplayClientOptions<State, Input, Checkpoint, Projection>, 'transport' | 'runtimeFactory'> & {
14
+ readonly runtimeFactory: KinetixRuntimeFactory<State, Input, Checkpoint, Projection>;
15
+ };
16
+ export type SyncplayAsyncClientOptions<State, Input, Checkpoint = unknown, Projection = State> = Omit<NetworkedSyncplayClientOptions<State, Input, Checkpoint, Projection>, 'transport'>;
13
17
  export interface SyncplayNetworkAssertionConfig<State, Input, Checkpoint = unknown, Projection = State> {
14
18
  readonly roomConfig: DeterministicAuthorityRoomConfig;
15
- readonly clientOptions: (index: number) => Omit<NetworkedSyncplayClientOptions<State, Input, Checkpoint, Projection>, 'transport'>;
19
+ readonly clientOptions: (index: number) => SyncplaySyncClientOptions<State, Input, Checkpoint, Projection>;
20
+ readonly steps?: number;
21
+ readonly link?: Partial<SimulatedSyncplayLink>;
22
+ readonly networkSeed?: number;
23
+ }
24
+ export interface SyncplayNetworkAssertionConfigAsync<State, Input, Checkpoint = unknown, Projection = State> {
25
+ readonly roomConfig: DeterministicAuthorityRoomConfig;
26
+ readonly clientOptions: (index: number) => SyncplayAsyncClientOptions<State, Input, Checkpoint, Projection>;
16
27
  readonly steps?: number;
17
28
  readonly link?: Partial<SimulatedSyncplayLink>;
18
29
  readonly networkSeed?: number;
@@ -27,10 +38,20 @@ export interface SyncplayLateJoinAssertionConfig<State, Input, Checkpoint = unkn
27
38
  readonly beforeJoinSteps?: number;
28
39
  readonly afterJoinSteps?: number;
29
40
  }
41
+ export interface SyncplayLateJoinAssertionConfigAsync<State, Input, Checkpoint = unknown, Projection = State> extends SyncplayNetworkAssertionConfigAsync<State, Input, Checkpoint, Projection> {
42
+ readonly initialClientCount?: number;
43
+ readonly beforeJoinSteps?: number;
44
+ readonly afterJoinSteps?: number;
45
+ }
30
46
  export interface SyncplayLateJoinProof extends SyncplayConvergenceProof {
31
47
  readonly hydratedThrough: number;
32
48
  }
33
49
  export declare function assertDeterministic<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplaySynctestConfig<State, Input, Checkpoint, Projection>): SyncplaySynctestResult;
50
+ export declare function assertDeterministicAsync<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplaySynctestConfigAsync<State, Input, Checkpoint, Projection>): Promise<SyncplaySynctestResult>;
34
51
  export declare function assertReplayVerifies<State, Input, Checkpoint = unknown, Projection = State>(config: ReplayVerificationConfig<State, Input, Checkpoint, Projection>): ReplayVerificationResult;
52
+ export declare function assertReplayVerifiesAsync<State, Input, Checkpoint = unknown, Projection = State>(config: ReplayVerificationConfigAsync<State, Input, Checkpoint, Projection>): Promise<ReplayVerificationResult>;
35
53
  export declare function assertTwoClientConvergence<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplayNetworkAssertionConfig<State, Input, Checkpoint, Projection>): SyncplayConvergenceProof;
54
+ export declare function assertTwoClientConvergenceAsync<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplayNetworkAssertionConfigAsync<State, Input, Checkpoint, Projection>): Promise<SyncplayConvergenceProof>;
36
55
  export declare function assertLateJoinHydration<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplayLateJoinAssertionConfig<State, Input, Checkpoint, Projection>): SyncplayLateJoinProof;
56
+ export declare function assertLateJoinHydrationAsync<State, Input, Checkpoint = unknown, Projection = State>(config: SyncplayLateJoinAssertionConfigAsync<State, Input, Checkpoint, Projection>): Promise<SyncplayLateJoinProof>;
57
+ export { SyncplayRuntimeLeaseRequiredError } from './runtime-cleanup.js';