@multitapio/multitap 0.0.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/.stamp +0 -0
- package/dist/cache.d.ts +117 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/channel.d.ts +91 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.worker.d.ts +3 -0
- package/dist/channel.worker.d.ts.map +1 -0
- package/dist/codegen/config.d.ts +107 -0
- package/dist/codegen/config.d.ts.map +1 -0
- package/dist/codegen/generator.d.ts +78 -0
- package/dist/codegen/generator.d.ts.map +1 -0
- package/dist/codegen/index.d.ts +13 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/inject.d.ts +51 -0
- package/dist/codegen/inject.d.ts.map +1 -0
- package/dist/codegen/rust.d.ts +22 -0
- package/dist/codegen/rust.d.ts.map +1 -0
- package/dist/codegen/typescript.d.ts +22 -0
- package/dist/codegen/typescript.d.ts.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/crypto.d.ts +141 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/debug.d.ts +39 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/diagnostics/index.d.ts +12 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics.js +5502 -0
- package/dist/e2e/cli.d.ts +2 -0
- package/dist/e2e/cli.d.ts.map +1 -0
- package/dist/executor.d.ts +130 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/globals.d.ts +32 -0
- package/dist/helpers.d.ts +3 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/input-codec.d.ts +136 -0
- package/dist/input-codec.d.ts.map +1 -0
- package/dist/input-graph.d.ts +106 -0
- package/dist/input-graph.d.ts.map +1 -0
- package/dist/lib.d.ts +10 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +9409 -0
- package/dist/messages.d.ts +63 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/peer-mesh.d.ts +77 -0
- package/dist/peer-mesh.d.ts.map +1 -0
- package/dist/react/Crosshair.d.ts +17 -0
- package/dist/react/Crosshair.d.ts.map +1 -0
- package/dist/react/Player.d.ts +10 -0
- package/dist/react/Player.d.ts.map +1 -0
- package/dist/react/PlayerPoseContext.d.ts +31 -0
- package/dist/react/PlayerPoseContext.d.ts.map +1 -0
- package/dist/react/hooks/index.d.ts +7 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/useEvent.d.ts +46 -0
- package/dist/react/hooks/useEvent.d.ts.map +1 -0
- package/dist/react/hooks/useFrame.d.ts +23 -0
- package/dist/react/hooks/useFrame.d.ts.map +1 -0
- package/dist/react/hooks/usePlayers.d.ts +24 -0
- package/dist/react/hooks/usePlayers.d.ts.map +1 -0
- package/dist/react/hooks/useQuery.d.ts +41 -0
- package/dist/react/hooks/useQuery.d.ts.map +1 -0
- package/dist/react/hooks/useSession.d.ts +10 -0
- package/dist/react/hooks/useSession.d.ts.map +1 -0
- package/dist/react/index.d.ts +18 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/input/DesktopInputMapper.d.ts +38 -0
- package/dist/react/input/DesktopInputMapper.d.ts.map +1 -0
- package/dist/react/input/index.d.ts +4 -0
- package/dist/react/input/index.d.ts.map +1 -0
- package/dist/react/input/types.d.ts +46 -0
- package/dist/react/input/types.d.ts.map +1 -0
- package/dist/react/providers/SessionProvider.d.ts +17 -0
- package/dist/react/providers/SessionProvider.d.ts.map +1 -0
- package/dist/react/providers/index.d.ts +2 -0
- package/dist/react/providers/index.d.ts.map +1 -0
- package/dist/react/types/index.d.ts +2 -0
- package/dist/react/types/index.d.ts.map +1 -0
- package/dist/react/types/session.d.ts +88 -0
- package/dist/react/types/session.d.ts.map +1 -0
- package/dist/react/types.d.ts +134 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/utils/math.d.ts +19 -0
- package/dist/react/utils/math.d.ts.map +1 -0
- package/dist/react/views/AsteroidsView.d.ts +24 -0
- package/dist/react/views/AsteroidsView.d.ts.map +1 -0
- package/dist/react/views/FirstPersonView.d.ts +10 -0
- package/dist/react/views/FirstPersonView.d.ts.map +1 -0
- package/dist/react/views/IsometricView.d.ts +21 -0
- package/dist/react/views/IsometricView.d.ts.map +1 -0
- package/dist/react/views/MapView.d.ts +16 -0
- package/dist/react/views/MapView.d.ts.map +1 -0
- package/dist/react/views/MobaView.d.ts +17 -0
- package/dist/react/views/MobaView.d.ts.map +1 -0
- package/dist/react/views/SideOnView.d.ts +23 -0
- package/dist/react/views/SideOnView.d.ts.map +1 -0
- package/dist/react/views/ThirdPersonFixedView.d.ts +21 -0
- package/dist/react/views/ThirdPersonFixedView.d.ts.map +1 -0
- package/dist/react/views/ThirdPersonView.d.ts +12 -0
- package/dist/react/views/ThirdPersonView.d.ts.map +1 -0
- package/dist/react/views/TopDownFixedView.d.ts +20 -0
- package/dist/react/views/TopDownFixedView.d.ts.map +1 -0
- package/dist/react/views/TopDownView.d.ts +12 -0
- package/dist/react/views/TopDownView.d.ts.map +1 -0
- package/dist/react/views/TwinStickView.d.ts +13 -0
- package/dist/react/views/TwinStickView.d.ts.map +1 -0
- package/dist/react/views/VehicleFixedView.d.ts +16 -0
- package/dist/react/views/VehicleFixedView.d.ts.map +1 -0
- package/dist/react/views/VehicleView.d.ts +13 -0
- package/dist/react/views/VehicleView.d.ts.map +1 -0
- package/dist/react/views/index.d.ts +21 -0
- package/dist/react/views/index.d.ts.map +1 -0
- package/dist/react/views/types.d.ts +136 -0
- package/dist/react/views/types.d.ts.map +1 -0
- package/dist/rollback.d.ts +193 -0
- package/dist/rollback.d.ts.map +1 -0
- package/dist/rollback.worker.d.ts +3 -0
- package/dist/rollback.worker.d.ts.map +1 -0
- package/dist/schema.d.ts +309 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/session-config.d.ts +119 -0
- package/dist/session-config.d.ts.map +1 -0
- package/dist/session.d.ts +120 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/state.d.ts +400 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/stats.d.ts +21 -0
- package/dist/stats.d.ts.map +1 -0
- package/dist/test-session.d.ts +170 -0
- package/dist/test-session.d.ts.map +1 -0
- package/dist/types/cache.d.ts +117 -0
- package/dist/types/cache.d.ts.map +1 -0
- package/dist/types/channel.d.ts +91 -0
- package/dist/types/channel.d.ts.map +1 -0
- package/dist/types/channel.worker.d.ts +3 -0
- package/dist/types/channel.worker.d.ts.map +1 -0
- package/dist/types/codegen/config.d.ts +107 -0
- package/dist/types/codegen/config.d.ts.map +1 -0
- package/dist/types/codegen/generator.d.ts +78 -0
- package/dist/types/codegen/generator.d.ts.map +1 -0
- package/dist/types/codegen/index.d.ts +13 -0
- package/dist/types/codegen/index.d.ts.map +1 -0
- package/dist/types/codegen/inject.d.ts +51 -0
- package/dist/types/codegen/inject.d.ts.map +1 -0
- package/dist/types/codegen/rust.d.ts +22 -0
- package/dist/types/codegen/rust.d.ts.map +1 -0
- package/dist/types/codegen/typescript.d.ts +22 -0
- package/dist/types/codegen/typescript.d.ts.map +1 -0
- package/dist/types/constants.d.ts +5 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/crypto.d.ts +141 -0
- package/dist/types/crypto.d.ts.map +1 -0
- package/dist/types/debug.d.ts +39 -0
- package/dist/types/debug.d.ts.map +1 -0
- package/dist/types/diagnostics/index.d.ts +12 -0
- package/dist/types/diagnostics/index.d.ts.map +1 -0
- package/dist/types/e2e/cli.d.ts +2 -0
- package/dist/types/e2e/cli.d.ts.map +1 -0
- package/dist/types/executor.d.ts +130 -0
- package/dist/types/executor.d.ts.map +1 -0
- package/dist/types/helpers.d.ts +3 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/input-codec.d.ts +136 -0
- package/dist/types/input-codec.d.ts.map +1 -0
- package/dist/types/input-graph.d.ts +106 -0
- package/dist/types/input-graph.d.ts.map +1 -0
- package/dist/types/lib.d.ts +10 -0
- package/dist/types/lib.d.ts.map +1 -0
- package/dist/types/messages.d.ts +63 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/peer-mesh.d.ts +77 -0
- package/dist/types/peer-mesh.d.ts.map +1 -0
- package/dist/types/react/Crosshair.d.ts +17 -0
- package/dist/types/react/Crosshair.d.ts.map +1 -0
- package/dist/types/react/Player.d.ts +10 -0
- package/dist/types/react/Player.d.ts.map +1 -0
- package/dist/types/react/PlayerPoseContext.d.ts +31 -0
- package/dist/types/react/PlayerPoseContext.d.ts.map +1 -0
- package/dist/types/react/hooks/index.d.ts +7 -0
- package/dist/types/react/hooks/index.d.ts.map +1 -0
- package/dist/types/react/hooks/useEvent.d.ts +46 -0
- package/dist/types/react/hooks/useEvent.d.ts.map +1 -0
- package/dist/types/react/hooks/useFrame.d.ts +23 -0
- package/dist/types/react/hooks/useFrame.d.ts.map +1 -0
- package/dist/types/react/hooks/usePlayers.d.ts +24 -0
- package/dist/types/react/hooks/usePlayers.d.ts.map +1 -0
- package/dist/types/react/hooks/useQuery.d.ts +41 -0
- package/dist/types/react/hooks/useQuery.d.ts.map +1 -0
- package/dist/types/react/hooks/useSession.d.ts +10 -0
- package/dist/types/react/hooks/useSession.d.ts.map +1 -0
- package/dist/types/react/index.d.ts +18 -0
- package/dist/types/react/index.d.ts.map +1 -0
- package/dist/types/react/input/DesktopInputMapper.d.ts +38 -0
- package/dist/types/react/input/DesktopInputMapper.d.ts.map +1 -0
- package/dist/types/react/input/index.d.ts +4 -0
- package/dist/types/react/input/index.d.ts.map +1 -0
- package/dist/types/react/input/types.d.ts +46 -0
- package/dist/types/react/input/types.d.ts.map +1 -0
- package/dist/types/react/providers/SessionProvider.d.ts +17 -0
- package/dist/types/react/providers/SessionProvider.d.ts.map +1 -0
- package/dist/types/react/providers/index.d.ts +2 -0
- package/dist/types/react/providers/index.d.ts.map +1 -0
- package/dist/types/react/types/index.d.ts +2 -0
- package/dist/types/react/types/index.d.ts.map +1 -0
- package/dist/types/react/types/session.d.ts +88 -0
- package/dist/types/react/types/session.d.ts.map +1 -0
- package/dist/types/react/types.d.ts +134 -0
- package/dist/types/react/types.d.ts.map +1 -0
- package/dist/types/react/utils/math.d.ts +19 -0
- package/dist/types/react/utils/math.d.ts.map +1 -0
- package/dist/types/react/views/AsteroidsView.d.ts +24 -0
- package/dist/types/react/views/AsteroidsView.d.ts.map +1 -0
- package/dist/types/react/views/FirstPersonView.d.ts +10 -0
- package/dist/types/react/views/FirstPersonView.d.ts.map +1 -0
- package/dist/types/react/views/IsometricView.d.ts +21 -0
- package/dist/types/react/views/IsometricView.d.ts.map +1 -0
- package/dist/types/react/views/MapView.d.ts +16 -0
- package/dist/types/react/views/MapView.d.ts.map +1 -0
- package/dist/types/react/views/MobaView.d.ts +17 -0
- package/dist/types/react/views/MobaView.d.ts.map +1 -0
- package/dist/types/react/views/SideOnView.d.ts +23 -0
- package/dist/types/react/views/SideOnView.d.ts.map +1 -0
- package/dist/types/react/views/ThirdPersonFixedView.d.ts +21 -0
- package/dist/types/react/views/ThirdPersonFixedView.d.ts.map +1 -0
- package/dist/types/react/views/ThirdPersonView.d.ts +12 -0
- package/dist/types/react/views/ThirdPersonView.d.ts.map +1 -0
- package/dist/types/react/views/TopDownFixedView.d.ts +20 -0
- package/dist/types/react/views/TopDownFixedView.d.ts.map +1 -0
- package/dist/types/react/views/TopDownView.d.ts +12 -0
- package/dist/types/react/views/TopDownView.d.ts.map +1 -0
- package/dist/types/react/views/TwinStickView.d.ts +13 -0
- package/dist/types/react/views/TwinStickView.d.ts.map +1 -0
- package/dist/types/react/views/VehicleFixedView.d.ts +16 -0
- package/dist/types/react/views/VehicleFixedView.d.ts.map +1 -0
- package/dist/types/react/views/VehicleView.d.ts +13 -0
- package/dist/types/react/views/VehicleView.d.ts.map +1 -0
- package/dist/types/react/views/index.d.ts +21 -0
- package/dist/types/react/views/index.d.ts.map +1 -0
- package/dist/types/react/views/types.d.ts +136 -0
- package/dist/types/react/views/types.d.ts.map +1 -0
- package/dist/types/rollback.d.ts +193 -0
- package/dist/types/rollback.d.ts.map +1 -0
- package/dist/types/rollback.worker.d.ts +3 -0
- package/dist/types/rollback.worker.d.ts.map +1 -0
- package/dist/types/schema.d.ts +309 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/session-config.d.ts +119 -0
- package/dist/types/session-config.d.ts.map +1 -0
- package/dist/types/session.d.ts +120 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/state.d.ts +400 -0
- package/dist/types/state.d.ts.map +1 -0
- package/dist/types/stats.d.ts +21 -0
- package/dist/types/stats.d.ts.map +1 -0
- package/dist/types/test-session.d.ts +170 -0
- package/dist/types/test-session.d.ts.map +1 -0
- package/dist/types/utils.d.ts +26 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/vite/codegen-runner.d.ts +27 -0
- package/dist/types/vite/codegen-runner.d.ts.map +1 -0
- package/dist/types/vite/index.d.ts +20 -0
- package/dist/types/vite/index.d.ts.map +1 -0
- package/dist/types/vite/module-builder.d.ts +28 -0
- package/dist/types/vite/module-builder.d.ts.map +1 -0
- package/dist/types/vite/plugin.d.ts +27 -0
- package/dist/types/vite/plugin.d.ts.map +1 -0
- package/dist/types/vite/types.d.ts +37 -0
- package/dist/types/vite/types.d.ts.map +1 -0
- package/dist/types/vite/wasm-compiler.d.ts +32 -0
- package/dist/types/vite/wasm-compiler.d.ts.map +1 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/vite/codegen-runner.d.ts +27 -0
- package/dist/vite/codegen-runner.d.ts.map +1 -0
- package/dist/vite/index.d.ts +20 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +4202 -0
- package/dist/vite/module-builder.d.ts +28 -0
- package/dist/vite/module-builder.d.ts.map +1 -0
- package/dist/vite/plugin.d.ts +27 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/types.d.ts +37 -0
- package/dist/vite/types.d.ts.map +1 -0
- package/dist/vite/wasm-compiler.d.ts +32 -0
- package/dist/vite/wasm-compiler.d.ts.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;GAGG;AACH,eAAO,MAAM,KAAK,aAAa,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,SAAsB,CAAC;AAEjD,+CAA+C;AAC/C,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,gDAAgD;AAChD,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,8CAA8C;AAC9C,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,6CAA6C;AAC7C,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,mFAAmF;AACnF,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,iFAAiF;AACjF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAc7C,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAenD,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,eAAe,aAU1B,CAAC;AAEH,iFAAiF;AACjF,eAAO,MAAM,4BAA4B,aASvC,CAAC;AAMH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpC,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC5C,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAMpD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,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kB,CAAC,MAAM,EAAE,WAAW,GAAG,mBAAmB,CAqG3E"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the session start time for a rolling session.
|
|
3
|
+
* All clients with synchronized clocks will compute the same startTime
|
|
4
|
+
* for the current time window (session duration = maxTicks / tickRate seconds).
|
|
5
|
+
*
|
|
6
|
+
* The returned startTime should be passed to SessionConfig to ensure all players
|
|
7
|
+
* join the same session with proper timing coordination by the relay.
|
|
8
|
+
*
|
|
9
|
+
* @param timestamp - Unix timestamp in milliseconds (e.g., Date.now())
|
|
10
|
+
* @param tickRate - Ticks per second (Hz)
|
|
11
|
+
* @param maxTicks - Maximum ticks per session (determines session duration)
|
|
12
|
+
* @param cooldown - Optional seconds to add between sessions (default: 0)
|
|
13
|
+
* @returns Unix timestamp in seconds for the session start time
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* // Basic usage
|
|
18
|
+
* const startTime = computeRollingSessionStart(Date.now(), 20, 2000);
|
|
19
|
+
*
|
|
20
|
+
* // With 30 second cooldown between sessions
|
|
21
|
+
* const startTime = computeRollingSessionStart(Date.now(), 20, 2000, 30);
|
|
22
|
+
*
|
|
23
|
+
* const sessionConfig = new SessionConfig({
|
|
24
|
+
* authority: 'relay.example.com',
|
|
25
|
+
* appID: 'mygame',
|
|
26
|
+
* path: ['lobby'],
|
|
27
|
+
* tickRate: 20,
|
|
28
|
+
* maxParticipants: 8,
|
|
29
|
+
* maxTicks: 2000,
|
|
30
|
+
* startTime,
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function computeRollingSessionStart(timestamp: number, tickRate: number, maxTicks: number, cooldown?: number): number;
|
|
35
|
+
export type ConnectionURL = `multitap://${string}`;
|
|
36
|
+
/**
|
|
37
|
+
* SessionConfig holds all parameters that define a session's identity.
|
|
38
|
+
* Two clients must have matching configs to join the same session.
|
|
39
|
+
*/
|
|
40
|
+
export interface SessionConfigOptions {
|
|
41
|
+
/** Protocol version (must be "v1") */
|
|
42
|
+
version: string;
|
|
43
|
+
/** Relay server authority (host:port) - NOT included in genesis hash, only needed for toConnectionURL() */
|
|
44
|
+
authority?: string;
|
|
45
|
+
/** Application identifier (DNS-style, lowercase) */
|
|
46
|
+
appID: string;
|
|
47
|
+
/** Path segments for session routing (max 8 segments, 32 chars each) */
|
|
48
|
+
path: string[] | string;
|
|
49
|
+
/** Tick rate in Hz (1-60) */
|
|
50
|
+
tickRate: number;
|
|
51
|
+
/** Maximum participants (1-255) */
|
|
52
|
+
maxParticipants: number;
|
|
53
|
+
/** Maximum ticks before session ends (required, 1-864000) */
|
|
54
|
+
maxTicks: number;
|
|
55
|
+
/** Session start time in Unix seconds (required, must be > 0) */
|
|
56
|
+
startTime: number;
|
|
57
|
+
/** Join credentials - NOT included in hash or filepath */
|
|
58
|
+
credentials?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* SessionConfig manages session connection configuration.
|
|
62
|
+
* Provides methods to compute genesis hash, build connection URLs, and validate config.
|
|
63
|
+
*/
|
|
64
|
+
export declare class SessionConfig {
|
|
65
|
+
readonly version: string;
|
|
66
|
+
readonly authority: string;
|
|
67
|
+
readonly appID: string;
|
|
68
|
+
readonly path: string[];
|
|
69
|
+
readonly tickRate: number;
|
|
70
|
+
readonly maxParticipants: number;
|
|
71
|
+
readonly maxTicks: number;
|
|
72
|
+
readonly startTime: number;
|
|
73
|
+
credentials: string;
|
|
74
|
+
constructor(options: SessionConfigOptions);
|
|
75
|
+
/**
|
|
76
|
+
* Validate the session configuration identity fields.
|
|
77
|
+
* Authority is NOT validated here - it's only required for toConnectionURL().
|
|
78
|
+
* @throws Error if validation fails
|
|
79
|
+
*/
|
|
80
|
+
validate(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Compute the genesis hash - a deterministic 16-byte session identifier.
|
|
83
|
+
* Excludes Authority and Credentials from the hash.
|
|
84
|
+
*
|
|
85
|
+
* Format (must match Go protocol/session.go ToGenesisHash):
|
|
86
|
+
* SHA256("multitap:genesis:v1:" || AppID || \x00 || Path[0] || \x00 || ... || TickRate || MaxParticipants || MaxTicks || StartTime)[:16]
|
|
87
|
+
*
|
|
88
|
+
* @returns 16-byte genesis hash
|
|
89
|
+
*/
|
|
90
|
+
toGenesisHash(): Uint8Array;
|
|
91
|
+
/**
|
|
92
|
+
* Build a multitap:// connection URL from this config.
|
|
93
|
+
* @returns multitap:// URL string
|
|
94
|
+
*/
|
|
95
|
+
toConnectionURL(): ConnectionURL;
|
|
96
|
+
/**
|
|
97
|
+
* Build an HTTPS connection URL (for WebTransport).
|
|
98
|
+
* @returns HTTPS URL string
|
|
99
|
+
*/
|
|
100
|
+
toHTTPSURL(): string;
|
|
101
|
+
/**
|
|
102
|
+
* Encode the connection URL as base64url for transport through URL-unsafe systems.
|
|
103
|
+
* @returns base64url-encoded connection URL string
|
|
104
|
+
*/
|
|
105
|
+
toBase64EncodedConnectionURL(): string;
|
|
106
|
+
/**
|
|
107
|
+
* Create a SessionConfig from a base64url-encoded connection URL.
|
|
108
|
+
* @param encodedURL base64url-encoded connection URL
|
|
109
|
+
* @returns SessionConfig instance
|
|
110
|
+
*/
|
|
111
|
+
static fromBase64EncodedConnectionURL(encodedURL: string): SessionConfig;
|
|
112
|
+
/**
|
|
113
|
+
* Create a SessionConfig from a multitap:// URL.
|
|
114
|
+
* @param url multitap:// URL string
|
|
115
|
+
* @returns SessionConfig instance
|
|
116
|
+
*/
|
|
117
|
+
static fromConnectionURL(urlString: string): SessionConfig;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=session-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-config.d.ts","sourceRoot":"","sources":["../../src/session-config.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,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AU,IAAI,MAAM;IAKpB;;;OAGG;IACH,4BAA4B,IAAI,MAAM;IAKtC;;;;OAIG;IACH,MAAM,CAAC,8BAA8B,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa;IAKxE;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa;CAyD3D"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type InputCodec, type InputSchema } from './input-codec';
|
|
2
|
+
import { type CompiledSchema, type StateBuffer, type StateSchema, type StoreApi } from './state';
|
|
3
|
+
import { type Rollback as RollbackClass } from './rollback';
|
|
4
|
+
import { type Channel as ChannelClass } from './channel';
|
|
5
|
+
import { SessionConfig } from './session-config';
|
|
6
|
+
import type { Participant } from './input-graph';
|
|
7
|
+
export * from './input-graph';
|
|
8
|
+
export interface SessionStats {
|
|
9
|
+
inputs: Partial<Awaited<ReturnType<(typeof ChannelClass.prototype)['getStats']>>>;
|
|
10
|
+
simulation: Partial<Awaited<ReturnType<(typeof RollbackClass.prototype)['getStats']>>>;
|
|
11
|
+
renderer: Partial<{
|
|
12
|
+
fps: number;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export interface Renderer {
|
|
16
|
+
init(session: SessionInterface): void;
|
|
17
|
+
close(session: SessionInterface): void;
|
|
18
|
+
getStats?: () => SessionStats['renderer'];
|
|
19
|
+
}
|
|
20
|
+
export interface MultitapPlugin {
|
|
21
|
+
name: string;
|
|
22
|
+
wasmBytes: Uint8Array;
|
|
23
|
+
/** Reserved bytes in shared WASM memory for this plugin's data section and stack */
|
|
24
|
+
reservedBytes: number;
|
|
25
|
+
}
|
|
26
|
+
export interface MultitapConfig {
|
|
27
|
+
appID: string;
|
|
28
|
+
tickRate: number;
|
|
29
|
+
maxTicks: number;
|
|
30
|
+
maxParticipants: number;
|
|
31
|
+
plugins: MultitapPlugin[];
|
|
32
|
+
schema: {
|
|
33
|
+
state: CompiledSchema;
|
|
34
|
+
input: InputSchema;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface SessionOptions {
|
|
38
|
+
playerKey: Uint8Array;
|
|
39
|
+
authority?: string;
|
|
40
|
+
appID: string;
|
|
41
|
+
path: string[] | string;
|
|
42
|
+
tickRate: number;
|
|
43
|
+
maxParticipants: number;
|
|
44
|
+
maxTicks: number;
|
|
45
|
+
startTime: number;
|
|
46
|
+
debug?: boolean;
|
|
47
|
+
serverCertHash?: string;
|
|
48
|
+
validatorKeys?: Uint8Array[];
|
|
49
|
+
autoConnect?: boolean;
|
|
50
|
+
maxTicksPerBatch?: number;
|
|
51
|
+
tickLag?: number;
|
|
52
|
+
connectionTimeoutMs?: number;
|
|
53
|
+
plugins: MultitapPlugin[];
|
|
54
|
+
schema: {
|
|
55
|
+
state: StateSchema | CompiledSchema;
|
|
56
|
+
input: InputSchema;
|
|
57
|
+
};
|
|
58
|
+
renderer: Renderer;
|
|
59
|
+
dangerouslyDisableSessionCompatibilityHashCheck?: boolean;
|
|
60
|
+
logSyncTicks?: boolean;
|
|
61
|
+
enableStatsCollection?: boolean;
|
|
62
|
+
enableP2P?: boolean;
|
|
63
|
+
}
|
|
64
|
+
declare class Session {
|
|
65
|
+
private channel;
|
|
66
|
+
private rollback;
|
|
67
|
+
private config;
|
|
68
|
+
private initializing;
|
|
69
|
+
private initialized;
|
|
70
|
+
private playerKey;
|
|
71
|
+
private compiledStateSchema;
|
|
72
|
+
private channelWorkerUrl;
|
|
73
|
+
private rollbackWorkerUrl;
|
|
74
|
+
private rollbackWorker;
|
|
75
|
+
private channelWorker;
|
|
76
|
+
private maxTicksPerBatch;
|
|
77
|
+
private serverCertHash;
|
|
78
|
+
private validatorKeys;
|
|
79
|
+
readonly debug: boolean | undefined;
|
|
80
|
+
private autoConnect;
|
|
81
|
+
private connectionTimeoutMs;
|
|
82
|
+
private tickLag;
|
|
83
|
+
private logSyncTicks;
|
|
84
|
+
private schema;
|
|
85
|
+
private closed;
|
|
86
|
+
private latestState;
|
|
87
|
+
private loopTimer;
|
|
88
|
+
private renderer;
|
|
89
|
+
private plugins;
|
|
90
|
+
private inputCodec;
|
|
91
|
+
private stateBindings;
|
|
92
|
+
private statsTimer;
|
|
93
|
+
private enableStatsCollection;
|
|
94
|
+
private stats;
|
|
95
|
+
private participantsById;
|
|
96
|
+
private participantsSorted;
|
|
97
|
+
private peerMesh;
|
|
98
|
+
private enableP2P;
|
|
99
|
+
constructor(options: SessionOptions);
|
|
100
|
+
init(): Promise<void>;
|
|
101
|
+
getCurrentPlayerId(): string;
|
|
102
|
+
getParticipants(): readonly Participant[];
|
|
103
|
+
private onParticipantJoined;
|
|
104
|
+
getConfig(): SessionConfig;
|
|
105
|
+
getStateBindings(): StoreApi;
|
|
106
|
+
getInputBindings(): InputCodec;
|
|
107
|
+
sendInput(input: Uint8Array): void;
|
|
108
|
+
getState(): StateBuffer;
|
|
109
|
+
private onInputSendError;
|
|
110
|
+
private onStateUpdate;
|
|
111
|
+
getStats(): SessionStats;
|
|
112
|
+
close(): Promise<void>;
|
|
113
|
+
private _collectStats;
|
|
114
|
+
private collectStats;
|
|
115
|
+
private createRollbackWorker;
|
|
116
|
+
private createChannelWorker;
|
|
117
|
+
}
|
|
118
|
+
export declare function createSession(options: SessionOptions): Promise<Session>;
|
|
119
|
+
export type SessionInterface = Awaited<ReturnType<typeof createSession>>;
|
|
120
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACrF,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACd,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,KAAK,QAAQ,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D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B,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binary state format with Entity-Component-like access patterns and semantics
|
|
3
|
+
*
|
|
4
|
+
* A fixed-buffer database optimized for use with ECS and rollback networking:
|
|
5
|
+
* - O(1) state copying (memcpy semantics)
|
|
6
|
+
* - Bit-for-bit determinism across languages
|
|
7
|
+
* - Zero serialization overhead
|
|
8
|
+
* - Schema-first, cross-language compatible
|
|
9
|
+
*
|
|
10
|
+
* See ADR-014: Entity-Component State Format for specification details.
|
|
11
|
+
*
|
|
12
|
+
* @module state
|
|
13
|
+
*/
|
|
14
|
+
import { MAGIC, NULL_ENTITY, STATE_ID_OFFSET, STATE_ID_SIZE, TICK_OFFSET, TICK_RATE_OFFSET, type PrimitiveType, type CompoundType, type ArrayType, type EnumType, type FieldType, type EntityRef, type StateBuffer, type FieldDef, type ComponentDef, type EventDef, type StateSchema, type CompiledField, type CompiledComponent, type CompiledEvent, type CompiledStateSchema, type Vec2, type Vec3, type Quat } from './schema';
|
|
15
|
+
export { MAGIC, NULL_ENTITY, STATE_ID_OFFSET, STATE_ID_SIZE, TICK_OFFSET, TICK_RATE_OFFSET, type PrimitiveType, type CompoundType, type ArrayType, type EnumType, type FieldType, type EntityRef, type StateBuffer, type FieldDef, type ComponentDef, type EventDef, type StateSchema, type CompiledField, type CompiledComponent, type CompiledEvent, type Vec2, type Vec3, type Quat, };
|
|
16
|
+
type CompiledSchema = CompiledStateSchema;
|
|
17
|
+
export type { CompiledSchema };
|
|
18
|
+
/**
|
|
19
|
+
* Pack an entity index and generation into an EntityRef.
|
|
20
|
+
*
|
|
21
|
+
* @param index - Entity slot index (0 to maxEntities-1)
|
|
22
|
+
* @param generation - Generation counter
|
|
23
|
+
* @returns Packed EntityRef value
|
|
24
|
+
*/
|
|
25
|
+
export declare function packRef(index: number, generation: number): EntityRef;
|
|
26
|
+
/**
|
|
27
|
+
* Extract the entity index from an EntityRef.
|
|
28
|
+
*
|
|
29
|
+
* @param ref - Entity reference
|
|
30
|
+
* @returns Entity slot index
|
|
31
|
+
*/
|
|
32
|
+
export declare function unpackIndex(ref: EntityRef): number;
|
|
33
|
+
/**
|
|
34
|
+
* Extract the generation from an EntityRef.
|
|
35
|
+
*
|
|
36
|
+
* @param ref - Entity reference
|
|
37
|
+
* @returns Generation counter
|
|
38
|
+
*/
|
|
39
|
+
export declare function unpackGeneration(ref: EntityRef): number;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a schema is already compiled.
|
|
42
|
+
* @deprecated Use isCompiledStateSchema from schema.ts instead
|
|
43
|
+
*/
|
|
44
|
+
export declare function isCompiledSchema(schema: StateSchema | CompiledStateSchema): schema is CompiledStateSchema;
|
|
45
|
+
/**
|
|
46
|
+
* Compile a schema if needed, or return it if already compiled.
|
|
47
|
+
* @deprecated Use ensureCompiledStateSchema from schema.ts instead
|
|
48
|
+
*/
|
|
49
|
+
export declare function ensureCompiled(schema: StateSchema | CompiledStateSchema): CompiledStateSchema;
|
|
50
|
+
/**
|
|
51
|
+
* Compile a schema definition into a CompiledSchema with all layout offsets.
|
|
52
|
+
* @deprecated Use compileStateSchema from schema.ts instead
|
|
53
|
+
*/
|
|
54
|
+
export declare function compileSchema(schema: StateSchema): CompiledStateSchema;
|
|
55
|
+
/**
|
|
56
|
+
* Get the stateId from a state buffer.
|
|
57
|
+
* The stateId uniquely identifies a state based on its input history.
|
|
58
|
+
*
|
|
59
|
+
* @param state - State buffer
|
|
60
|
+
* @returns 32-byte stateId
|
|
61
|
+
*/
|
|
62
|
+
export declare function getStateId(state: Uint8Array): Uint8Array;
|
|
63
|
+
/**
|
|
64
|
+
* Set the stateId in a state buffer.
|
|
65
|
+
*
|
|
66
|
+
* @param state - State buffer to modify
|
|
67
|
+
* @param stateId - 32-byte stateId to set
|
|
68
|
+
*/
|
|
69
|
+
export declare function setStateId(state: Uint8Array, stateId: Uint8Array): void;
|
|
70
|
+
/**
|
|
71
|
+
* Get the current tick from a state buffer.
|
|
72
|
+
*
|
|
73
|
+
* @param state - State buffer to read from
|
|
74
|
+
* @returns Current tick number (uint32)
|
|
75
|
+
*/
|
|
76
|
+
export declare function getTick(state: Uint8Array): number;
|
|
77
|
+
/**
|
|
78
|
+
* Set the current tick in a state buffer.
|
|
79
|
+
*
|
|
80
|
+
* @param state - State buffer to modify
|
|
81
|
+
* @param tick - Tick number to set (uint32)
|
|
82
|
+
*/
|
|
83
|
+
export declare function setTick(state: Uint8Array, tick: number): void;
|
|
84
|
+
/**
|
|
85
|
+
* Get the tick rate from a state buffer.
|
|
86
|
+
*
|
|
87
|
+
* @param state - State buffer to read from
|
|
88
|
+
* @returns Tick rate (ticks per second, uint8)
|
|
89
|
+
*/
|
|
90
|
+
export declare function getTickRate(state: Uint8Array): number;
|
|
91
|
+
/**
|
|
92
|
+
* Set the tick rate in a state buffer.
|
|
93
|
+
*
|
|
94
|
+
* @param state - State buffer to modify
|
|
95
|
+
* @param tickRate - Tick rate to set (ticks per second, uint8)
|
|
96
|
+
*/
|
|
97
|
+
export declare function setTickRate(state: Uint8Array, tickRate: number): void;
|
|
98
|
+
/**
|
|
99
|
+
* Compute the stateId that would result from applying a state transition.
|
|
100
|
+
*
|
|
101
|
+
* Formula: SHA256(prevStateId || tick || orderedPayloadsHash)
|
|
102
|
+
*
|
|
103
|
+
* @param prevStateId - 32-byte stateId of the previous state
|
|
104
|
+
* @param tick - Tick number (will be encoded as little-endian uint32)
|
|
105
|
+
* @param orderedPayloadsHash - 32-byte hash of ordered payloads (one per participant at stable indices)
|
|
106
|
+
* @returns 32-byte stateId for the resulting state
|
|
107
|
+
*/
|
|
108
|
+
export declare function computeNextStateId(prevStateId: Uint8Array, tick: number, orderedPayloadsHash: Uint8Array): Uint8Array;
|
|
109
|
+
/**
|
|
110
|
+
* Convenience helper: compute stateId directly from ordered payloads.
|
|
111
|
+
* Uses hashPayloads to derive the orderedPayloadsHash.
|
|
112
|
+
*/
|
|
113
|
+
export declare function computeNextStateIdFromPayloads(prevStateId: Uint8Array, tick: number, orderedPayloads: Uint8Array[]): Uint8Array;
|
|
114
|
+
/**
|
|
115
|
+
* Compute the genesis stateId from a genesis hash.
|
|
116
|
+
* This seeds the stateId chain with global uniqueness.
|
|
117
|
+
*
|
|
118
|
+
* @param genesisHash - 16-byte genesis hash
|
|
119
|
+
* @returns 32-byte genesis stateId
|
|
120
|
+
*/
|
|
121
|
+
export declare function computeGenesisStateId(genesisHash: Uint8Array): Uint8Array;
|
|
122
|
+
/**
|
|
123
|
+
* Create a new state buffer initialized with the given schema.
|
|
124
|
+
*
|
|
125
|
+
* Initial state:
|
|
126
|
+
* - Header: magic number, alive count = 0, stateId = SHA256(genesisHash) or zeros
|
|
127
|
+
* - Entity table: all generations = 0, all bitmasks = 0
|
|
128
|
+
* - Free stack: populated with all indices (0 to maxEntities-1) in reverse order
|
|
129
|
+
* - Component storage: all zeros
|
|
130
|
+
* - Singleton storage: all zeros
|
|
131
|
+
*
|
|
132
|
+
* @param schema - Compiled schema
|
|
133
|
+
* @param genesisHash - Optional 16-byte genesis hash to seed the genesis stateId.
|
|
134
|
+
* If not provided, stateId will be all zeros.
|
|
135
|
+
* @param tickRate - Optional tick rate (ticks per second). Required for physics.
|
|
136
|
+
* @returns New Uint8Array state buffer
|
|
137
|
+
*/
|
|
138
|
+
export declare function createState(schema: CompiledSchema, genesisHash?: Uint8Array, tickRate?: number): StateBuffer;
|
|
139
|
+
/**
|
|
140
|
+
* Spawn a new entity.
|
|
141
|
+
*
|
|
142
|
+
* Allocation is deterministic - uses LIFO free stack, so spawn order
|
|
143
|
+
* depends only on previous despawn order.
|
|
144
|
+
*
|
|
145
|
+
* @param schema - Compiled schema
|
|
146
|
+
* @param state - State buffer
|
|
147
|
+
* @returns EntityRef for the new entity
|
|
148
|
+
* @throws Error if no free entity slots available
|
|
149
|
+
*/
|
|
150
|
+
export declare function spawn(schema: CompiledSchema, state: StateBuffer): EntityRef;
|
|
151
|
+
/**
|
|
152
|
+
* Check if an entity reference is still valid (alive).
|
|
153
|
+
*
|
|
154
|
+
* An entity is alive if its generation matches the stored generation.
|
|
155
|
+
* After despawn, the generation increments, invalidating old references.
|
|
156
|
+
*
|
|
157
|
+
* @param schema - Compiled schema
|
|
158
|
+
* @param state - State buffer
|
|
159
|
+
* @param entity - Entity reference to check
|
|
160
|
+
* @returns true if entity is alive, false otherwise
|
|
161
|
+
*/
|
|
162
|
+
export declare function isAlive(schema: CompiledSchema, state: StateBuffer, entity: EntityRef): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Despawn an entity.
|
|
165
|
+
*
|
|
166
|
+
* This operation:
|
|
167
|
+
* 1. Increments the generation counter (invalidates old references)
|
|
168
|
+
* 2. Clears the component bitmask
|
|
169
|
+
* 3. Zeros all component memory for this entity
|
|
170
|
+
* 4. Pushes the index back onto the free stack
|
|
171
|
+
* 5. Decrements the alive count
|
|
172
|
+
*
|
|
173
|
+
* @param schema - Compiled schema
|
|
174
|
+
* @param state - State buffer
|
|
175
|
+
* @param entity - Entity reference to despawn
|
|
176
|
+
* @throws Error if entity is not alive
|
|
177
|
+
*/
|
|
178
|
+
export declare function despawn(schema: CompiledSchema, state: StateBuffer, entity: EntityRef): void;
|
|
179
|
+
/**
|
|
180
|
+
* Check if an entity has a specific component.
|
|
181
|
+
*
|
|
182
|
+
* @param schema - Compiled schema
|
|
183
|
+
* @param state - State buffer
|
|
184
|
+
* @param entity - Entity reference
|
|
185
|
+
* @param componentName - Component name
|
|
186
|
+
* @returns true if entity has the component
|
|
187
|
+
* @throws Error if component is unknown
|
|
188
|
+
*/
|
|
189
|
+
export declare function hasComponent(schema: CompiledSchema, state: StateBuffer, entity: EntityRef, componentName: string): boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Add a component to an entity.
|
|
192
|
+
*
|
|
193
|
+
* Component memory is already zero from state initialization or prior despawn.
|
|
194
|
+
* This operation only sets the component's presence bit in the entity bitmask.
|
|
195
|
+
* Calling this when the component already exists is a no-op (idempotent).
|
|
196
|
+
*
|
|
197
|
+
* @param schema - Compiled schema
|
|
198
|
+
* @param state - State buffer
|
|
199
|
+
* @param entity - Entity reference
|
|
200
|
+
* @param componentName - Component name to add
|
|
201
|
+
* @throws Error if entity is not alive or component is unknown
|
|
202
|
+
*/
|
|
203
|
+
export declare function addComponent(schema: CompiledSchema, state: StateBuffer, entity: EntityRef, componentName: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* Remove a component from an entity.
|
|
206
|
+
*
|
|
207
|
+
* For non-tag components, the component's memory is zeroed.
|
|
208
|
+
* Calling this when the component doesn't exist is a no-op (idempotent).
|
|
209
|
+
*
|
|
210
|
+
* @param schema - Compiled schema
|
|
211
|
+
* @param state - State buffer
|
|
212
|
+
* @param entity - Entity reference
|
|
213
|
+
* @param componentName - Component name to remove
|
|
214
|
+
* @throws Error if entity is not alive or component is unknown
|
|
215
|
+
*/
|
|
216
|
+
export declare function removeComponent(schema: CompiledSchema, state: StateBuffer, entity: EntityRef, componentName: string): void;
|
|
217
|
+
/**
|
|
218
|
+
* Generic getter for a component field.
|
|
219
|
+
* Returns undefined if entity is dead or lacks the component.
|
|
220
|
+
*/
|
|
221
|
+
export declare function getField(schema: CompiledSchema, state: StateBuffer, entity: EntityRef, componentName: string, fieldName: string, arrayIndex?: number): number | boolean | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* Generic setter for a component field.
|
|
224
|
+
* Validates entity is alive and has the component.
|
|
225
|
+
*/
|
|
226
|
+
export declare function setField(schema: CompiledSchema, state: StateBuffer, entity: EntityRef, componentName: string, fieldName: string, value: number | boolean, arrayIndex?: number): void;
|
|
227
|
+
export declare function getSingletonField(schema: CompiledSchema, state: StateBuffer, componentName: string, fieldName: string, arrayIndex?: number): number | boolean;
|
|
228
|
+
export declare function setSingletonField(schema: CompiledSchema, state: StateBuffer, componentName: string, fieldName: string, value: number | boolean, arrayIndex?: number): void;
|
|
229
|
+
/**
|
|
230
|
+
* Generic getter for a compound (vec2/vec3/quat) component field.
|
|
231
|
+
* Returns undefined if entity is dead or lacks the component.
|
|
232
|
+
*/
|
|
233
|
+
export declare function getCompoundField(schema: CompiledSchema, state: StateBuffer, entity: EntityRef, componentName: string, fieldName: string): [number, number] | [number, number, number] | [number, number, number, number] | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* Generic setter for a compound (vec2/vec3/quat) component field.
|
|
236
|
+
* Accepts a tuple of values.
|
|
237
|
+
*/
|
|
238
|
+
export declare function setCompoundField(schema: CompiledSchema, state: StateBuffer, entity: EntityRef, componentName: string, fieldName: string, value: [number, number] | [number, number, number] | [number, number, number, number]): void;
|
|
239
|
+
export declare function getSingletonCompoundField(schema: CompiledSchema, state: StateBuffer, componentName: string, fieldName: string): [number, number] | [number, number, number] | [number, number, number, number];
|
|
240
|
+
export declare function setSingletonCompoundField(schema: CompiledSchema, state: StateBuffer, componentName: string, fieldName: string, value: [number, number] | [number, number, number] | [number, number, number, number]): void;
|
|
241
|
+
/**
|
|
242
|
+
* Query for entities with specific components.
|
|
243
|
+
*
|
|
244
|
+
* Iterates through all entity slots, yielding those that:
|
|
245
|
+
* - Are alive
|
|
246
|
+
* - Have all components in the `include` list
|
|
247
|
+
* - Have none of the components in the `exclude` list
|
|
248
|
+
*
|
|
249
|
+
* @param schema - Compiled schema
|
|
250
|
+
* @param state - State buffer
|
|
251
|
+
* @param include - Component names that must be present
|
|
252
|
+
* @param exclude - Component names that must NOT be present (optional)
|
|
253
|
+
* @yields EntityRef for each matching entity
|
|
254
|
+
*/
|
|
255
|
+
export declare function query(schema: CompiledSchema, state: StateBuffer, include: string[], exclude?: string[]): Generator<EntityRef>;
|
|
256
|
+
/**
|
|
257
|
+
* Query entities by pre-computed bigint bitmasks.
|
|
258
|
+
*
|
|
259
|
+
* This is more efficient than `query()` when using generated bindings,
|
|
260
|
+
* as the masks are computed at module load time rather than per-query.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* // With generated bindings (type-safe):
|
|
264
|
+
* import { Position, Ship, RespawnTimer, queryMask } from '../generated/state';
|
|
265
|
+
* const SHIPS_MASK = queryMask([Position, Ship]);
|
|
266
|
+
* const RESPAWN_MASK = queryMask([RespawnTimer]);
|
|
267
|
+
* const ships = queryByMask(schema, state, SHIPS_MASK, RESPAWN_MASK);
|
|
268
|
+
*
|
|
269
|
+
* @param schema - Compiled schema
|
|
270
|
+
* @param state - State buffer
|
|
271
|
+
* @param includeMask - Bigint bitmask of components that must be present
|
|
272
|
+
* @param excludeMask - Bigint bitmask of components that must NOT be present (optional, default 0n)
|
|
273
|
+
* @yields EntityRef for each matching entity
|
|
274
|
+
*/
|
|
275
|
+
export declare function queryByMask(schema: CompiledSchema, state: StateBuffer, includeMask: bigint, excludeMask?: bigint): Generator<EntityRef>;
|
|
276
|
+
/**
|
|
277
|
+
* Clear all events of a given type (call at tick start).
|
|
278
|
+
*
|
|
279
|
+
* @param schema - Compiled schema
|
|
280
|
+
* @param state - State buffer
|
|
281
|
+
* @param eventName - Event type name
|
|
282
|
+
*/
|
|
283
|
+
export declare function clearEvents(schema: CompiledSchema, state: StateBuffer, eventName: string): void;
|
|
284
|
+
/**
|
|
285
|
+
* Get the count of events for a given type this tick.
|
|
286
|
+
*
|
|
287
|
+
* @param schema - Compiled schema
|
|
288
|
+
* @param state - State buffer
|
|
289
|
+
* @param eventName - Event type name
|
|
290
|
+
* @returns Number of events
|
|
291
|
+
*/
|
|
292
|
+
export declare function getEventCount(schema: CompiledSchema, state: StateBuffer, eventName: string): number;
|
|
293
|
+
/**
|
|
294
|
+
* Push an event to the event buffer.
|
|
295
|
+
*
|
|
296
|
+
* @param schema - Compiled schema
|
|
297
|
+
* @param state - State buffer
|
|
298
|
+
* @param eventName - Event type name
|
|
299
|
+
* @param values - Field values as a record (e.g., { playerIndex: 0, targetX: 100.0, targetY: 200.0 })
|
|
300
|
+
* @returns true if event was pushed, false if buffer is full
|
|
301
|
+
*/
|
|
302
|
+
export declare function pushEvent(schema: CompiledSchema, state: StateBuffer, eventName: string, values: Record<string, number | boolean | Vec2 | Vec3 | Quat>): boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Get a field value from an event at a given index.
|
|
305
|
+
*
|
|
306
|
+
* @param schema - Compiled schema
|
|
307
|
+
* @param state - State buffer
|
|
308
|
+
* @param eventName - Event type name
|
|
309
|
+
* @param index - Event index (0 to getEventCount - 1)
|
|
310
|
+
* @param fieldName - Field name
|
|
311
|
+
* @returns Field value
|
|
312
|
+
*/
|
|
313
|
+
export declare function getEventField(schema: CompiledSchema, state: StateBuffer, eventName: string, index: number, fieldName: string): number | boolean | Vec2 | Vec3 | Quat;
|
|
314
|
+
/**
|
|
315
|
+
* Iterate over events of a given type.
|
|
316
|
+
*
|
|
317
|
+
* @param schema - Compiled schema
|
|
318
|
+
* @param state - State buffer
|
|
319
|
+
* @param eventName - Event type name
|
|
320
|
+
* @yields Record of field values for each event
|
|
321
|
+
*/
|
|
322
|
+
export declare function iterEvents(schema: CompiledSchema, state: StateBuffer, eventName: string): Generator<Record<string, number | boolean | Vec2 | Vec3 | Quat>>;
|
|
323
|
+
/**
|
|
324
|
+
* The StoreApi interface with dynamically generated accessors.
|
|
325
|
+
* Accessors like getPositionX(), setHealth() are generated at runtime.
|
|
326
|
+
*/
|
|
327
|
+
export interface StoreApi {
|
|
328
|
+
/** The compiled schema */
|
|
329
|
+
readonly schema: CompiledSchema;
|
|
330
|
+
/** Create a new state buffer */
|
|
331
|
+
createState(): StateBuffer;
|
|
332
|
+
/** Spawn a new entity */
|
|
333
|
+
spawn(state: StateBuffer): EntityRef;
|
|
334
|
+
/** Despawn an entity */
|
|
335
|
+
despawn(state: StateBuffer, entity: EntityRef): void;
|
|
336
|
+
/** Check if entity is alive */
|
|
337
|
+
isAlive(state: StateBuffer, entity: EntityRef): boolean;
|
|
338
|
+
/** Add a component to an entity */
|
|
339
|
+
addComponent(state: StateBuffer, entity: EntityRef, component: string): void;
|
|
340
|
+
/** Remove a component from an entity */
|
|
341
|
+
removeComponent(state: StateBuffer, entity: EntityRef, component: string): void;
|
|
342
|
+
/** Check if entity has a component */
|
|
343
|
+
hasComponent(state: StateBuffer, entity: EntityRef, component: string): boolean;
|
|
344
|
+
/** Query for entities with specific components */
|
|
345
|
+
query(state: StateBuffer, include: string[], exclude?: string[]): Generator<EntityRef>;
|
|
346
|
+
/** Index signature for dynamically generated accessors (getX, setX methods) */
|
|
347
|
+
[key: string]: any;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Define a state memory layout with the given schema.
|
|
351
|
+
*
|
|
352
|
+
* Returns a StoreApi object with:
|
|
353
|
+
* - Type-safe accessor methods for all component fields
|
|
354
|
+
* - Type-safe component name parameters
|
|
355
|
+
* - Core entity/component lifecycle methods
|
|
356
|
+
*
|
|
357
|
+
* @param schemaDef - State schema definition (use `as const` for full type inference)
|
|
358
|
+
* @returns StoreApi object with type-safe API
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```typescript
|
|
362
|
+
* const storeApi = createStoreApi({
|
|
363
|
+
* maxEntities: 1000,
|
|
364
|
+
* components: [
|
|
365
|
+
* { name: 'Position', type: 'vec2' },
|
|
366
|
+
* { name: 'Health', type: 'int16' },
|
|
367
|
+
* { name: 'IsPlayer', type: 'tag' },
|
|
368
|
+
* ],
|
|
369
|
+
* } as const);
|
|
370
|
+
*
|
|
371
|
+
* const state = storeApi.createState();
|
|
372
|
+
* const entity = storeApi.spawn(state);
|
|
373
|
+
* storeApi.addComponent(state, entity, 'Position');
|
|
374
|
+
* storeApi.setPositionX(state, entity, 100.5); // native f32 float
|
|
375
|
+
* storeApi.addComponent(state, entity, 'Health');
|
|
376
|
+
* storeApi.setHealth(state, entity, 100); // Scalar component accessor
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
export declare function createStoreApi(schemaDef: StateSchema | CompiledSchema): StoreApi;
|
|
380
|
+
/**
|
|
381
|
+
* Extract enum constants from a compiled schema.
|
|
382
|
+
*
|
|
383
|
+
* Returns a record mapping constant names to their numeric values.
|
|
384
|
+
* Naming convention matches the Rust codegen:
|
|
385
|
+
* - Standalone enum components: `COMPONENT_NAME_VARIANT`
|
|
386
|
+
* - Enum fields in compounds: `COMPONENT_NAME_FIELD_NAME_VARIANT`
|
|
387
|
+
*
|
|
388
|
+
* @param schema - Compiled schema (or raw schema that will be compiled)
|
|
389
|
+
* @returns Record of enum constant names to values
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```typescript
|
|
393
|
+
* const enums = getEnumConstants(schema);
|
|
394
|
+
* // enums.RIGID_BODY_TYPE_DYNAMIC === 0
|
|
395
|
+
* // enums.RIGID_BODY_TYPE_FIXED === 1
|
|
396
|
+
* // enums.COLLIDER_SHAPE_TYPE_BALL === 0
|
|
397
|
+
* ```
|
|
398
|
+
*/
|
|
399
|
+
export declare function getEnumConstants(schema: StateSchema | CompiledSchema): Record<string, number>;
|
|
400
|
+
//# sourceMappingURL=state.d.ts.map
|