@series-inc/rundot-syncplay 5.28.0-beta.4 → 6.0.0-rc.2

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 (146) hide show
  1. package/README.md +56 -13
  2. package/core/baker.d.ts +14 -0
  3. package/core/build-native.d.ts +3 -0
  4. package/core/build-wasm-physics.d.ts +6 -0
  5. package/core/compiler.d.ts +4 -0
  6. package/core/deterministic-math.d.ts +2 -0
  7. package/core/envelope.d.ts +8 -0
  8. package/core/f64-bits.d.ts +4 -0
  9. package/core/index.d.ts +1 -52
  10. package/core/native/kinetix-native-main.cpp +8 -11
  11. package/core/native/physics/abi.cpp +634 -2
  12. package/core/native/physics/abi.hpp +9 -0
  13. package/core/native/physics/constraint_rows.cpp +564 -0
  14. package/core/native/physics/constraint_rows.hpp +151 -0
  15. package/core/native/physics/physics.cpp +4415 -1222
  16. package/core/native/physics/physics.hpp +263 -5
  17. package/core/native/physics/topology.cpp +1107 -0
  18. package/core/native/physics/topology.hpp +237 -0
  19. package/core/native/physics/world.cpp +2722 -0
  20. package/core/native/physics/world.hpp +283 -0
  21. package/core/native/physics/world_abi.cpp +1354 -0
  22. package/core/native/physics/world_abi.hpp +252 -0
  23. package/core/native/physics2d/buoyancy.cpp +885 -0
  24. package/core/native/physics2d/buoyancy.hpp +119 -0
  25. package/core/native/physics2d/commands.cpp +1058 -0
  26. package/core/native/physics2d/commands.hpp +163 -0
  27. package/core/native/physics2d/fluid.cpp +878 -0
  28. package/core/native/physics2d/fluid.hpp +260 -0
  29. package/core/native/physics2d/joints.cpp +2534 -0
  30. package/core/native/physics2d/joints.hpp +669 -0
  31. package/core/native/physics2d/owned_abi.cpp +1327 -0
  32. package/core/native/physics2d/owned_abi.hpp +487 -0
  33. package/core/native/physics2d/physics2d.cpp +3046 -0
  34. package/core/native/physics2d/physics2d.hpp +489 -0
  35. package/core/native/physics2d/queries.cpp +2343 -0
  36. package/core/native/physics2d/queries.hpp +337 -0
  37. package/core/native/physics2d/world.cpp +2150 -0
  38. package/core/native/physics2d/world.hpp +230 -0
  39. package/core/native/wasm_runtime.cpp +4 -0
  40. package/core/native-product.d.ts +4 -0
  41. package/core/physics2d-owned.d.ts +417 -0
  42. package/core/render-projection.d.ts +3 -0
  43. package/core/render-records.d.ts +8 -0
  44. package/core/runtime.d.ts +39 -0
  45. package/core/scripts/build-native.mjs +40 -5
  46. package/core/scripts/build-wasm-physics.mjs +331 -104
  47. package/core/src/index.mjs +0 -32
  48. package/core/src/kinetix-product-contract.mjs +2 -0
  49. package/core/src/kinetix-runtime-adapter-utils.mjs +325 -47
  50. package/core/src/physics/abi-constants.mjs +10 -0
  51. package/core/src/physics/box3d-probe.mjs +41 -26
  52. package/core/src/physics/index.mjs +365 -532
  53. package/core/src/physics/mass-properties.mjs +18 -1
  54. package/core/src/physics/physics-wasm-module.generated.mjs +8 -6
  55. package/core/src/physics/wasm-instance.mjs +103 -0
  56. package/core/src/physics/world.d.mts +15 -0
  57. package/core/src/physics/world.mjs +1166 -0
  58. package/core/src/physics2d/body-state.mjs +249 -0
  59. package/core/src/physics2d/joint-output-state.mjs +295 -0
  60. package/core/src/physics2d/joint-state.mjs +1032 -0
  61. package/core/src/physics2d/owned-queries.mjs +54 -0
  62. package/core/src/physics2d/owned-transport.mjs +1338 -0
  63. package/core/src/physics2d/owned-world.d.mts +9 -0
  64. package/core/src/physics2d/owned-world.mjs +1047 -0
  65. package/core/src/physics2d/physics2d-wasm-module.generated.mjs +53 -0
  66. package/core/src/physics2d/query-codec.mjs +305 -0
  67. package/core/src/physics2d/wasm-instance.mjs +52 -0
  68. package/core/src/runtime.mjs +5 -1
  69. package/core/world-kernel.d.ts +3 -0
  70. package/core/world.d.ts +209 -0
  71. package/dist/api-deprecations.generated.d.ts +38 -0
  72. package/dist/api-deprecations.generated.js +39 -0
  73. package/dist/api-diagnostics.d.ts +11 -0
  74. package/dist/api-diagnostics.js +25 -0
  75. package/dist/browser.d.ts +2 -16
  76. package/dist/browser.js +0 -7
  77. package/dist/creator.d.ts +1 -10
  78. package/dist/creator.js +1 -9
  79. package/dist/errors.d.ts +7 -0
  80. package/dist/errors.js +4 -4
  81. package/dist/index.d.ts +3 -21
  82. package/dist/index.js +0 -9
  83. package/dist/lag-compensation3d.d.ts +22 -11
  84. package/dist/lag-compensation3d.js +70 -48
  85. package/dist/modules/combat.d.ts +7 -5
  86. package/dist/modules/combat.js +19 -12
  87. package/dist/modules/entity-registry.d.ts +1 -0
  88. package/dist/movement3d.d.ts +13 -13
  89. package/dist/movement3d.js +223 -221
  90. package/dist/networked-client.d.ts +13 -6
  91. package/dist/networked-client.js +228 -99
  92. package/dist/node.d.ts +0 -2
  93. package/dist/node.js +0 -1
  94. package/dist/physics/2d.d.ts +79 -0
  95. package/dist/physics/2d.js +219 -0
  96. package/dist/physics/3d.d.ts +282 -0
  97. package/dist/physics/3d.js +574 -0
  98. package/dist/runner.d.ts +41 -2
  99. package/dist/runner.js +341 -33
  100. package/dist/runtime-lease.d.ts +16 -0
  101. package/dist/runtime-lease.js +77 -0
  102. package/dist/state-digest.d.ts +28 -0
  103. package/dist/state-digest.js +83 -0
  104. package/package.json +89 -36
  105. package/core/native/mobile/syncplay_native_probe.cpp +0 -114
  106. package/core/native/mobile/syncplay_native_probe_abi.h +0 -46
  107. package/core/physics.d.ts +0 -422
  108. package/core/scripts/build-mobile-native.mjs +0 -101
  109. package/dist/collider-cooking.d.ts +0 -141
  110. package/dist/collider-cooking.js +0 -829
  111. package/dist/cosmetic-physics3d.d.ts +0 -41
  112. package/dist/cosmetic-physics3d.js +0 -196
  113. package/dist/debug-wireframe.d.ts +0 -22
  114. package/dist/debug-wireframe.js +0 -226
  115. package/dist/engine-core-proof.d.ts +0 -26
  116. package/dist/engine-core-proof.js +0 -66
  117. package/dist/physics-cert.d.ts +0 -40
  118. package/dist/physics-cert.js +0 -535
  119. package/dist/physics2d.d.ts +0 -142
  120. package/dist/physics2d.js +0 -747
  121. package/dist/physics3d-destruction-cert.d.ts +0 -35
  122. package/dist/physics3d-destruction-cert.js +0 -283
  123. package/dist/physics3d-heightfield.d.ts +0 -27
  124. package/dist/physics3d-heightfield.js +0 -80
  125. package/dist/physics3d-hull.d.ts +0 -67
  126. package/dist/physics3d-hull.js +0 -421
  127. package/dist/physics3d-joints.d.ts +0 -115
  128. package/dist/physics3d-joints.js +0 -1005
  129. package/dist/physics3d-mass.d.ts +0 -11
  130. package/dist/physics3d-mass.js +0 -126
  131. package/dist/physics3d-recipes.d.ts +0 -29
  132. package/dist/physics3d-recipes.js +0 -193
  133. package/dist/physics3d-solver.d.ts +0 -326
  134. package/dist/physics3d-solver.js +0 -2499
  135. package/dist/physics3d-stacking.d.ts +0 -26
  136. package/dist/physics3d-stacking.js +0 -147
  137. package/dist/physics3d-toi.d.ts +0 -79
  138. package/dist/physics3d-toi.js +0 -267
  139. package/dist/physics3d-vehicle.d.ts +0 -84
  140. package/dist/physics3d-vehicle.js +0 -488
  141. package/dist/physics3d-voxel.d.ts +0 -131
  142. package/dist/physics3d-voxel.js +0 -819
  143. package/dist/physics3d.d.ts +0 -544
  144. package/dist/physics3d.js +0 -4078
  145. package/dist/sample-scenes.d.ts +0 -86
  146. package/dist/sample-scenes.js +0 -732
package/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # RUN Syncplay
2
2
 
3
- Syncplay is the orchestration layer over a signed deterministic runtime. The
4
- deterministic core ships inside this package under the `/core` subpaths
5
- (`@series-inc/rundot-syncplay/core/...`): it owns deterministic state, RNG
6
- streams, stepping, opaque checkpoints, serialization, hydration, and checksums.
7
- Syncplay owns inputs, prediction, confirmation, rollback policy, replay logs,
8
- late join, secrets, and transport.
3
+ Syncplay is the orchestration layer over a signed deterministic runtime. Public
4
+ runtime utilities use the `/core` subpaths. Public physics uses `/physics/2d`
5
+ and `/physics/3d`. Both physics APIs use the canonical C++ core compiled to
6
+ WASM. Syncplay owns inputs, prediction, confirmation, rollback policy, replay
7
+ logs, late join, secrets, and transport.
9
8
 
10
9
  ## Installation
11
10
 
@@ -134,7 +133,8 @@ The published JavaScript graph has a committed exhaustive side-effect audit.
134
133
  effects and are preserved through the package's precise `sideEffects` allowlist.
135
134
 
136
135
  > **Upgrading an existing game?** See
137
- > [MIGRATING-SESSION-PRIMITIVES.md](./MIGRATING-SESSION-PRIMITIVES.md). Two
136
+ > [the RC1 migration guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-RC1-MIGRATION.md)
137
+ > and [the session primitive guide](https://github.com/series-ai/venus/blob/develop/packages/syncplay/MIGRATING-SESSION-PRIMITIVES.md). Two
138
138
  > changes are not additive: the runner now rejects an unsafe input codec at
139
139
  > construction, and the effects adapter now dedupes on your event `dedupeKey`.
140
140
 
@@ -158,8 +158,9 @@ dependency float cannot keep the same engine hash.
158
158
  | Subpath | Role |
159
159
  |---------|------|
160
160
  | `/core/runtime` | `createInstalledRuntimeAdapter`, identity helpers |
161
- | `/core/physics` | WASM physics (`initPhysics`, …) — reference solver |
162
- | `/` or `/browser` | KCC, runner, session, **TypeScript** physics — the solver `stepDeterministicKcc3D` collides against |
161
+ | `/physics/2d` | Canonical TypeScript 2D API over the C++/WASM core |
162
+ | `/physics/3d` | Canonical TypeScript 3D API over the C++/WASM core |
163
+ | `/` or `/browser` | Runner, session, and 3D character movement |
163
164
  | `/testing` | Simulated multi-peer / synctest |
164
165
  | `/node` | Authority room helpers (not for browser bundles) |
165
166
 
@@ -298,14 +299,22 @@ const runner = createSyncplayRunner({
298
299
  events: (frame) => frame.events,
299
300
  },
300
301
  })
301
- runner.startOffline({ identity, sessionConfigBytes, playerCount: 2, botInputForTick })
302
- await runner.startNetworked(() => createSyncplayRoom(api.realtime, roomOptions))
302
+ await runner.start({
303
+ mode: 'offline', identity, sessionConfigBytes, playerCount: 2, botInputForTick,
304
+ })
303
305
  runner.applyInput(readInput())
304
306
  runner.update(deltaMs)
305
307
  render(runner.getRenderState(), runner.renderAlpha)
308
+ runner.stop()
309
+ await runner.start({
310
+ mode: 'networked',
311
+ connect: (signal) => createSyncplayRoom(api.realtime, roomOptions, signal),
312
+ })
313
+ runner.dispose()
306
314
  ```
307
315
 
308
- **Status** is exactly `offline | connecting | syncing | live | stopped | error`:
316
+ `runner.lifecycle` reports `idle | starting | running | stopped | failed |
317
+ disposed`. The existing `status` field remains available for display state:
309
318
 
310
319
  - `connecting` covers the room-open promise.
311
320
  - `syncing` covers session-descriptor/asset preparation, reconnect, and catch-up.
@@ -314,7 +323,13 @@ render(runner.getRenderState(), runner.renderAlpha)
314
323
  - `error` carries connection, preparation, and offline-construction failures on
315
324
  the runner snapshot (and the throw is rethrown to the caller).
316
325
  - `stop` aborts preparation, closes the transport, and disposes the active
317
- client/session — idempotently.
326
+ client/session. `stop` and `dispose` are idempotent. `dispose` is terminal.
327
+
328
+ The runtime factory can return a runtime or a promise. A direct runtime is
329
+ borrowed. The runner does not dispose it. Return `{ runtime, dispose }` to give
330
+ the runner an owned lease. Cleanup releases session checkpoints before the
331
+ lease. Cancellation also cleans a late owned lease or transport. The old
332
+ `startOffline` and `startNetworked` methods remain as compatibility methods.
318
333
 
319
334
  Presentation stays **predicted** for render motion, while side-effect events are
320
335
  delivered only from authority-confirmed frames received after the first live
@@ -432,3 +447,31 @@ over a deterministic simulated network (`createSimulatedSyncplayMatch`,
432
447
  and `assertPresentationParity` cover the runner seam — a real runner driven on
433
448
  a fully controlled clock against the simulated match. Failures name the phase,
434
449
  frame, and disagreeing checksums.
450
+
451
+ ## Physics API v1
452
+
453
+ Syncplay RC1 has one public TypeScript API for each physics dimension. Import
454
+ 2D physics from `@series-inc/rundot-syncplay/physics/2d`. Import 3D physics from
455
+ `@series-inc/rundot-syncplay/physics/3d`. Do not import a raw physics adapter
456
+ from `/core`.
457
+
458
+ Call `initPhysics2D()` or `initPhysics3D()` before world creation. Create an
459
+ owned world with `createPhysicsWorld2D()` or `createPhysicsWorld3D()`. Each
460
+ world provides fixed stepping, atomic edits, retained queries, opaque native
461
+ checkpoints, portable checkpoint bytes, a state digest, and explicit disposal.
462
+
463
+ The TypeScript facade does not contain a second solver. Both dimensions run in
464
+ the canonical C++ core compiled to WASM. The internal solver algorithm, state
465
+ layout, WASM boundary, schedule, and checkpoint representation can change when
466
+ a complete benchmark proves a faster design. Each replacement must keep the
467
+ public contract, deterministic results, rollback controls, and bounded memory.
468
+
469
+ RC1 starts a new physics numeric epoch. Do not load a beta physics checkpoint
470
+ or replay into an RC1 world. Change the game deterministic version. Start new
471
+ rollback, replay, and late-join history.
472
+
473
+ Read the [2D guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-PHYSICS-2D.md),
474
+ the [3D guide](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-PHYSICS.md), and
475
+ the [RC1 migration helper](https://github.com/series-ai/venus/blob/develop/packages/sdk-docs/rundot-developer-platform/api/SYNCPLAY-RC1-MIGRATION.md).
476
+ Physical-phone performance remains a release gate. Do not infer phone results
477
+ from desktop measurements.
@@ -0,0 +1,14 @@
1
+ // Generated. Declares the runtime exports of ./core/baker.
2
+
3
+ export declare function assertKinetixProductContract(products: any): any;
4
+ export declare function assertKinetixRuntimeIdentityMatchesProducts(products: any, identity: any): any;
5
+ export declare function bakeKinetixEnvelope(envelope: any, installedProfiles: any): any;
6
+ export declare function deriveCustomRuntimeIdentity(options: any): any;
7
+ export declare function deriveKinetixRuntimeIdentity(products: any, runtimeContract?: any): any;
8
+ export declare const kinetixBakerVersion: "rundot.kinetix-baker.v1";
9
+ export declare const kinetixPhases: readonly ["initialization", "fixed-simulation", "post-simulation", "presentation-projection", "presentation"];
10
+ export declare function kinetixRuntimeModuleManifest(sourceRoot: any, relativePaths: any): any;
11
+ export declare function scanKinetixPayloadTree(value: any): any;
12
+ export declare function stableKinetixProductBytes(products: any): any;
13
+ export declare function stableKinetixSourceBytes(envelope: any): any;
14
+ export declare function validateInstalledKinetixProfile(profileId: any, profile: any): any;
@@ -0,0 +1,3 @@
1
+ // Generated. Declares the runtime exports of ./core/build-native.
2
+
3
+ export declare function buildNative(): any;
@@ -0,0 +1,6 @@
1
+ // Generated. Declares the runtime exports of ./core/build-wasm-physics.
2
+
3
+ export declare function buildWasmPhysics(options?: any): any;
4
+ export declare function buildWasmPhysics2D(options?: any): any;
5
+ export declare function getWasmNumericProfile(arg0?: any): any;
6
+ export declare function getWasmPhysicsSourceHashes(): any;
@@ -0,0 +1,4 @@
1
+ // Generated. Declares the runtime exports of ./core/compiler.
2
+
3
+ export declare function compileKinetixProject(arg0?: any): any;
4
+ export declare function compileTrustedKinetixSource(arg0: any): any;
@@ -0,0 +1,2 @@
1
+ export declare const DETERMINISTIC_MATH_SOURCE: string;
2
+ export declare function installDeterministicMath(): void;
@@ -0,0 +1,8 @@
1
+ // Generated. Declares the runtime exports of ./core/envelope.
2
+
3
+ export declare const kinetixDomains: readonly ["simulation", "presentation", "binding"];
4
+ export declare function kinetixEnvelopeDigest(envelope: any): any;
5
+ export declare const kinetixEnvelopeVersion: "rundot.kinetix-envelope.v1";
6
+ export declare const kinetixReferenceKinds: readonly ["entity", "component", "prefab", "prefab-local-entity", "prefab-local-component", "asset", "scene"];
7
+ export declare function stableKinetixEnvelopeBytes(envelope: any): any;
8
+ export declare function validateKinetixEnvelope(envelope: any): any;
@@ -0,0 +1,4 @@
1
+ // Generated. Declares the runtime exports of ./core/f64-bits.
2
+
3
+ export declare function f64FromHex(hex: any): any;
4
+ export declare function hexFromF64(value: any): any;
package/core/index.d.ts CHANGED
@@ -31,58 +31,6 @@ export {
31
31
  createDeterministicMath,
32
32
  DeterministicRandom,
33
33
  } from './deterministic-stdlib';
34
- export {
35
- applyDeterministicImpulse3D,
36
- applyDeterministicImpulses3D,
37
- applyDeterministicWorldEdit3D,
38
- applyPhysicsImpulse,
39
- applyPhysicsImpulses,
40
- applyPhysicsWorldEdit,
41
- createPhysicsWorld,
42
- createDeterministicPhysicsWorld3D,
43
- createTrustedDeterministicPhysicsWorld3D,
44
- cookPhysicsCollider,
45
- contactDetailsDeterministicPhysics3D,
46
- contactDetailsPhysics,
47
- initPhysics,
48
- initPhysics3D,
49
- overlapDeterministicPhysics3D,
50
- overlapPhysics,
51
- physicsReady,
52
- physics3DReady,
53
- physicsWasmMetadata,
54
- raycastDeterministicPhysics3D,
55
- raycastDeterministicPhysics3DDetailed,
56
- raycastPhysics,
57
- raycastPhysicsDetailed,
58
- resetPhysics3DCache,
59
- setDeterministicBodyVelocity3D,
60
- setPhysicsBodyVelocity,
61
- shapeCastDeterministicPhysics3D,
62
- shapeCastPhysics,
63
- stepPhysicsWorld,
64
- stepDeterministicPhysicsWorld3D,
65
- } from './physics';
66
- export type {
67
- KinetixPhysicsActivePair,
68
- KinetixPhysicsBody,
69
- KinetixPhysicsContactCacheEntry,
70
- KinetixPhysicsContactDetail,
71
- KinetixPhysicsContactEvent,
72
- KinetixPhysicsHit,
73
- KinetixPhysicsJointCacheEntry,
74
- KinetixPhysicsOverlapQuery,
75
- KinetixPhysicsQuaternion,
76
- KinetixPhysicsQueryOptions,
77
- KinetixPhysicsRaycastQuery,
78
- KinetixPhysicsScheduledQuery,
79
- KinetixPhysicsShape,
80
- KinetixPhysicsShapeCastQuery,
81
- KinetixPhysicsStepOptions,
82
- KinetixPhysicsStepResult,
83
- KinetixPhysicsVec3,
84
- KinetixPhysicsWorld,
85
- } from './physics';
86
34
  export type {
87
35
  DeterministicMathApi,
88
36
  DeterministicQuaternion,
@@ -277,6 +225,7 @@ export function deriveCustomRuntimeIdentity(
277
225
  ): import('./runtime').KinetixRuntimeIdentity;
278
226
  export const kinetixBakerVersion: string;
279
227
  export const kinetixPhases: readonly string[];
228
+ export const kinetixProductKinds: readonly ['simulation', 'presentation', 'binding'];
280
229
 
281
230
  export function createKinetixWorld(options: {
282
231
  worldId: string;
@@ -273,17 +273,14 @@ int runPhysicsSession() {
273
273
  << " status=" << status << '\n';
274
274
  return 2;
275
275
  }
276
- const std::uint32_t telemetryCount = rundot::kinetix::physics::contactTelemetryCount();
277
- const double* telemetry = rundot::kinetix::physics::contactTelemetryData();
278
- contactCache.resize(static_cast<std::size_t>(telemetryCount) * rundot::kinetix::physics::kContactCacheStride);
279
- for (std::uint32_t index = 0; index < telemetryCount; index += 1) {
280
- const double* source = telemetry + static_cast<std::size_t>(index)
281
- * rundot::kinetix::physics::kContactTelemetryStride;
282
- double* target = contactCache.data() + static_cast<std::size_t>(index)
283
- * rundot::kinetix::physics::kContactCacheStride;
284
- for (std::uint32_t field = 0; field < rundot::kinetix::physics::kContactCacheStride; field += 1) {
285
- target[field] = source[field];
286
- }
276
+ const std::uint32_t contactCount = rundot::kinetix::physics::contactCacheCount();
277
+ const double* cacheData = rundot::kinetix::physics::contactCacheData();
278
+ if (contactCount == 0) {
279
+ contactCache.clear();
280
+ } else {
281
+ contactCache.assign(cacheData, cacheData
282
+ + static_cast<std::size_t>(contactCount)
283
+ * rundot::kinetix::physics::kContactCacheStride);
287
284
  }
288
285
  for (std::uint32_t bodyIndex = 0; bodyIndex < bodyCount; bodyIndex += 1) {
289
286
  const std::size_t offset = static_cast<std::size_t>(bodyIndex) * stride;