@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,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Player component and command event injection for codegen.
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to automatically generate:
|
|
5
|
+
* - Player component from input schema controls
|
|
6
|
+
* - Command events from input schema commands
|
|
7
|
+
*
|
|
8
|
+
* @module codegen/inject
|
|
9
|
+
*/
|
|
10
|
+
import type { StateSchema, ComponentDef, EventDef, CompiledInputSchema } from '../schema';
|
|
11
|
+
/**
|
|
12
|
+
* Build a Player component definition from compiled input schema controls.
|
|
13
|
+
*
|
|
14
|
+
* The Player component contains:
|
|
15
|
+
* - `index` field (uint8) - identifies which player owns this entity
|
|
16
|
+
* - One field per control, with vec2/vec3/quat flattened to x/y/z/w components
|
|
17
|
+
* - Flag types (flags8/16/32) map to uint8/16/32
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildPlayerComponent(inputSchema: CompiledInputSchema): ComponentDef;
|
|
20
|
+
/**
|
|
21
|
+
* Inject the Player component into a state schema.
|
|
22
|
+
* Mutates the schema in place.
|
|
23
|
+
*
|
|
24
|
+
* @throws Error if schema already contains a 'Player' component
|
|
25
|
+
*/
|
|
26
|
+
export declare function injectPlayerComponent(schema: {
|
|
27
|
+
components: ComponentDef[];
|
|
28
|
+
}, inputSchema: CompiledInputSchema): void;
|
|
29
|
+
/**
|
|
30
|
+
* Build event definitions from compiled input schema commands.
|
|
31
|
+
*
|
|
32
|
+
* Each command becomes a `{Name}Command` event with:
|
|
33
|
+
* - `player_index` field (uint8) - identifies which player issued the command
|
|
34
|
+
* - One field per command argument, with vec2/vec3/quat flattened to x/y/z/w components
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildCommandEvents(inputSchema: CompiledInputSchema): EventDef[];
|
|
37
|
+
/**
|
|
38
|
+
* Inject command-derived events into a state schema.
|
|
39
|
+
* Mutates the schema in place.
|
|
40
|
+
*
|
|
41
|
+
* @throws Error if schema already contains an event with a conflicting name
|
|
42
|
+
*/
|
|
43
|
+
export declare function injectCommandEvents(schema: {
|
|
44
|
+
events?: EventDef[];
|
|
45
|
+
}, inputSchema: CompiledInputSchema): void;
|
|
46
|
+
/**
|
|
47
|
+
* Prepare a state schema for codegen by injecting Player component and command events.
|
|
48
|
+
* Returns a new schema object (does not mutate the original).
|
|
49
|
+
*/
|
|
50
|
+
export declare function prepareStateSchema(stateSchema: StateSchema, inputSchema: CompiledInputSchema): StateSchema;
|
|
51
|
+
//# sourceMappingURL=inject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../../src/codegen/inject.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,QAAQ,EAER,mBAAmB,EACpB,MAAM,WAAW,CAAC;AAMnB;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,mBAAmB,GAAG,YAAY,CAgDnF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE;IAAE,UAAU,EAAE,YAAY,EAAE,CAAA;CAAE,EACtC,WAAW,EAAE,mBAAmB,GAC/B,IAAI,CAWN;AAMD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,mBAAmB,GAAG,QAAQ,EAAE,CAyD/E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,EAC/B,WAAW,EAAE,mBAAmB,GAC/B,IAAI,CAsBN;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,mBAAmB,GAC/B,WAAW,CAeb"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rust code generator for state and input bindings.
|
|
3
|
+
*
|
|
4
|
+
* Generates Rust code from compiled schemas using template literals.
|
|
5
|
+
*
|
|
6
|
+
* @module codegen/rust
|
|
7
|
+
*/
|
|
8
|
+
import type { CompiledStateSchema, CompiledInputSchema } from '../schema';
|
|
9
|
+
import type { Generator, GeneratorOptions } from './generator';
|
|
10
|
+
/**
|
|
11
|
+
* Rust code generator.
|
|
12
|
+
* Generates Rust accessors for state and input schemas.
|
|
13
|
+
*/
|
|
14
|
+
export declare class RustGenerator implements Generator {
|
|
15
|
+
readonly language: "rust";
|
|
16
|
+
private opts;
|
|
17
|
+
constructor(opts?: GeneratorOptions);
|
|
18
|
+
generateState(schema: CompiledStateSchema): string;
|
|
19
|
+
generateInput(schema: CompiledInputSchema): string;
|
|
20
|
+
generateGame(state: CompiledStateSchema, input: CompiledInputSchema): string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=rust.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust.d.ts","sourceRoot":"","sources":["../../../src/codegen/rust.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EAKpB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAy5C/D;;;GAGG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC7C,QAAQ,CAAC,QAAQ,EAAG,MAAM,CAAU;IACpC,OAAO,CAAC,IAAI,CAAmB;gBAEnB,IAAI,GAAE,gBAAqB;IAIvC,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM;IA2ClD,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM;IA2BlD,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,GAAG,MAAM;CAe7E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript code generator for state and input bindings.
|
|
3
|
+
*
|
|
4
|
+
* Generates TypeScript code from compiled schemas using template literals.
|
|
5
|
+
*
|
|
6
|
+
* @module codegen/typescript
|
|
7
|
+
*/
|
|
8
|
+
import type { CompiledStateSchema, CompiledInputSchema } from '../schema';
|
|
9
|
+
import type { Generator, GeneratorOptions } from './generator';
|
|
10
|
+
/**
|
|
11
|
+
* TypeScript code generator.
|
|
12
|
+
* Generates TypeScript accessors for state and input schemas.
|
|
13
|
+
*/
|
|
14
|
+
export declare class TypeScriptGenerator implements Generator {
|
|
15
|
+
readonly language: "typescript";
|
|
16
|
+
private opts;
|
|
17
|
+
constructor(opts?: GeneratorOptions);
|
|
18
|
+
generateState(schema: CompiledStateSchema): string;
|
|
19
|
+
generateInput(schema: CompiledInputSchema): string;
|
|
20
|
+
generateGame(state: CompiledStateSchema, input: CompiledInputSchema): string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=typescript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../../src/codegen/typescript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EAMpB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAklD/D;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,SAAS;IACnD,QAAQ,CAAC,QAAQ,EAAG,YAAY,CAAU;IAC1C,OAAO,CAAC,IAAI,CAAmB;gBAEnB,IAAI,GAAE,gBAAqB;IAIvC,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM;IA0ClD,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM;IAyClD,YAAY,CAAC,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,mBAAmB,GAAG,MAAM;CAG7E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Maximum ticks the predicted head can run ahead of sync head before stalling */
|
|
2
|
+
export declare const ROLLBACK_WINDOW = 20;
|
|
3
|
+
/** Range around current tick where inputs are valid (±10 ticks) */
|
|
4
|
+
export declare const INPUT_VALIDITY_WINDOW = 10;
|
|
5
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA,kFAAkF;AAClF,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,KAAK,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { InputData } from './messages';
|
|
2
|
+
export declare const SIGNATURE_SIZE = 65;
|
|
3
|
+
export declare const COMPRESSED_PUBKEY_SIZE = 33;
|
|
4
|
+
export declare const COMPRESSED_PUB_KEY_SIZE = 33;
|
|
5
|
+
export declare const PRIVATE_KEY_SIZE = 32;
|
|
6
|
+
export declare const HASH_SIZE = 32;
|
|
7
|
+
export declare const INPUT_HEADER_SIZE = 5;
|
|
8
|
+
export declare const GENESIS_HASH_SIZE = 16;
|
|
9
|
+
/**
|
|
10
|
+
* Generate a new secp256k1 private key.
|
|
11
|
+
* @returns 32-byte private key
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateKeyPair(): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* Derive the compressed public key from a private key.
|
|
16
|
+
* @param privateKey 32-byte private key
|
|
17
|
+
* @returns 33-byte compressed public key
|
|
18
|
+
*/
|
|
19
|
+
export declare function pubKeyFromPrivate(privateKey: Uint8Array): Uint8Array;
|
|
20
|
+
/**
|
|
21
|
+
* Sign a 32-byte message hash with a private key.
|
|
22
|
+
* Returns a 65-byte recoverable signature in format [r:32][s:32][v:1].
|
|
23
|
+
* @param privateKey 32-byte private key
|
|
24
|
+
* @param messageHash 32-byte message hash
|
|
25
|
+
* @returns 65-byte signature
|
|
26
|
+
*/
|
|
27
|
+
export declare function sign(privateKey: Uint8Array, messageHash: Uint8Array): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Recover the compressed public key from a message hash and signature.
|
|
30
|
+
* @param messageHash 32-byte message hash
|
|
31
|
+
* @param signature 65-byte signature in format [r:32][s:32][v:1]
|
|
32
|
+
* @returns 33-byte compressed public key
|
|
33
|
+
*/
|
|
34
|
+
export declare function recoverPubKey(messageHash: Uint8Array, signature: Uint8Array): Uint8Array;
|
|
35
|
+
/**
|
|
36
|
+
* Verify that a signature was created by the owner of the given public key.
|
|
37
|
+
* @param pubKey 33-byte compressed public key
|
|
38
|
+
* @param messageHash 32-byte message hash
|
|
39
|
+
* @param signature 65-byte signature
|
|
40
|
+
* @returns true if valid
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifySignature(pubKey: Uint8Array, messageHash: Uint8Array, signature: Uint8Array): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Compute SHA-256 hash of arbitrary data.
|
|
45
|
+
* @param data Data to hash
|
|
46
|
+
* @returns 32-byte hash
|
|
47
|
+
*/
|
|
48
|
+
export declare function hashMessage(data: Uint8Array): Uint8Array;
|
|
49
|
+
/**
|
|
50
|
+
* Compute a short truncated SHA256 hash used to shard sessions based on simulation/schema/input compatibility.
|
|
51
|
+
* Returns the first 8 bytes of SHA256(data).
|
|
52
|
+
* @param data Data to hash
|
|
53
|
+
* @returns 8-byte truncated hash
|
|
54
|
+
*/
|
|
55
|
+
export declare function sessionCompatibilityHash(data: Uint8Array): Uint8Array;
|
|
56
|
+
/**
|
|
57
|
+
* Compute a truncated SHA256 hash of a JavaScript object using deterministic CBOR encoding.
|
|
58
|
+
* This ensures cross-platform compatibility - the same object will produce the same hash
|
|
59
|
+
* in both Go and JavaScript implementations.
|
|
60
|
+
*
|
|
61
|
+
* CBOR encoding rules (RFC 8949 §4.2 Core Deterministic Encoding):
|
|
62
|
+
* - Map keys sorted by byte string length, then lexicographically
|
|
63
|
+
* - Smallest possible integer encodings
|
|
64
|
+
* - No indefinite-length encodings
|
|
65
|
+
*
|
|
66
|
+
* @param obj JavaScript object to hash (must be CBOR-serializable)
|
|
67
|
+
* @returns 8-byte truncated hash
|
|
68
|
+
*/
|
|
69
|
+
export declare function hashContent(obj: unknown): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* Compute the hash for signing an input message.
|
|
72
|
+
* Format: SHA256(genesisHash || targetTick || payload)
|
|
73
|
+
* @param genesisHash 16-byte genesis hash (from SessionConfig.toGenesisHash())
|
|
74
|
+
* @param targetTick Target tick number (uint32)
|
|
75
|
+
* @param payload Variable-length input payload (0-255 bytes)
|
|
76
|
+
* @returns 32-byte hash
|
|
77
|
+
*/
|
|
78
|
+
export declare function hashInputMessage(genesisHash: Uint8Array, targetTick: number, payload: Uint8Array): Uint8Array;
|
|
79
|
+
/**
|
|
80
|
+
* Compute the hash for signing a tick message.
|
|
81
|
+
* Format: SHA256(genesisHash || tickNum || inputsHash || prevTickSig)
|
|
82
|
+
* @param genesisHash 16-byte genesis hash (from SessionConfig.toGenesisHash())
|
|
83
|
+
* @param tickNum Tick number (uint32)
|
|
84
|
+
* @param inputsHash 32-byte hash of concatenated inputs
|
|
85
|
+
* @param prevTickSig 65-byte previous tick's signature
|
|
86
|
+
* @returns 32-byte hash
|
|
87
|
+
*/
|
|
88
|
+
export declare function hashTickMessage(genesisHash: Uint8Array, tickNum: number, inputsHash: Uint8Array, prevTickSig: Uint8Array): Uint8Array;
|
|
89
|
+
/**
|
|
90
|
+
* Compute a hash over all inputs in a tick.
|
|
91
|
+
* Format: SHA256(input1 || input2 || ... || inputN)
|
|
92
|
+
* where each input is: [targetTick:4][payloadLen:1][payload:0-255][signature:65]
|
|
93
|
+
* Returns zero hash if there are no inputs.
|
|
94
|
+
* @param inputs Array of input messages
|
|
95
|
+
* @returns 32-byte hash
|
|
96
|
+
*/
|
|
97
|
+
export declare function hashInputs(inputs: InputData[]): Uint8Array;
|
|
98
|
+
/**
|
|
99
|
+
* Compute a hash over ordered payloads for stateId computation.
|
|
100
|
+
* Format: SHA256(payload1 || payload2 || ... || payloadN)
|
|
101
|
+
* Returns zero hash if there are no payloads.
|
|
102
|
+
*
|
|
103
|
+
* NOTE: This is distinct from hashInputs() which hashes full input messages
|
|
104
|
+
* (including signatures) for the tick signature chain. hashPayloads() hashes
|
|
105
|
+
* only the raw payloads in participant order, for state identity caching.
|
|
106
|
+
*
|
|
107
|
+
* @param payloads Array of payload bytes, ordered by participant index
|
|
108
|
+
* @returns 32-byte hash
|
|
109
|
+
*/
|
|
110
|
+
export declare function hashPayloads(payloads: Uint8Array[]): Uint8Array;
|
|
111
|
+
/**
|
|
112
|
+
* Compute the hash for connection authentication.
|
|
113
|
+
* Format: SHA256("multitap:session:" || genesisHash || ":" || timestamp)
|
|
114
|
+
* @param genesisHash 16-byte genesis hash (from SessionConfig.toGenesisHash())
|
|
115
|
+
* @param timestampMs Timestamp in milliseconds
|
|
116
|
+
* @returns 32-byte hash
|
|
117
|
+
*/
|
|
118
|
+
export declare function hashAuthMessage(genesisHash: Uint8Array, timestampMs: number): Uint8Array;
|
|
119
|
+
/**
|
|
120
|
+
* Encode a 16-byte genesis hash to base64url (no padding).
|
|
121
|
+
* A genesis hash is the deterministic session identity from SessionConfig.toGenesisHash().
|
|
122
|
+
* @param bytes 16-byte genesis hash
|
|
123
|
+
* @returns base64url string (22 chars)
|
|
124
|
+
*/
|
|
125
|
+
export declare function genesisHashToString(bytes: Uint8Array): string;
|
|
126
|
+
/**
|
|
127
|
+
* Decode a base64url (no padding) string to a 16-byte genesis hash.
|
|
128
|
+
* Throws if the string is invalid or decodes to all zeros.
|
|
129
|
+
* @param str base64url string (22 chars)
|
|
130
|
+
* @returns 16-byte genesis hash
|
|
131
|
+
*/
|
|
132
|
+
export declare function genesisHashFromString(str: string): Uint8Array;
|
|
133
|
+
/**
|
|
134
|
+
* Convert signature to hex string for URL encoding.
|
|
135
|
+
*/
|
|
136
|
+
export declare function signatureToHex(signature: Uint8Array): string;
|
|
137
|
+
/**
|
|
138
|
+
* Parse hex string to signature bytes.
|
|
139
|
+
*/
|
|
140
|
+
export declare function hexToSignature(hex: string): Uint8Array;
|
|
141
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAE5C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAEpE;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,GAAG,UAAU,CAehF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,UAAU,CAkBxF;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAO3G;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAGrE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,UAAU,CAIpD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,UAAU,CAc7G;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,UAAU,GACtB,UAAU,CAiBZ;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAkC1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,UAAU,CAkC/D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CAkBxF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAU7D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,CAI5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAMtD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug logging utility for the multitap SDK.
|
|
3
|
+
*
|
|
4
|
+
* Wraps console.* methods with an enable/disable toggle.
|
|
5
|
+
* Disabled by default so library consumers don't see logs unless they opt-in.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { debug } from './debug';
|
|
9
|
+
* debug.warn('something happened');
|
|
10
|
+
*
|
|
11
|
+
* To enable logging (e.g., for debugging):
|
|
12
|
+
* import { setDebugEnabled } from './debug';
|
|
13
|
+
* setDebugEnabled(true);
|
|
14
|
+
*/
|
|
15
|
+
/** Enable or disable debug logging globally */
|
|
16
|
+
export declare function setDebugEnabled(value: boolean): void;
|
|
17
|
+
/** Check if debug logging is currently enabled */
|
|
18
|
+
export declare function isDebugEnabled(): boolean;
|
|
19
|
+
export declare const debug: {
|
|
20
|
+
log: (...args: unknown[]) => void;
|
|
21
|
+
warn: (...args: unknown[]) => void;
|
|
22
|
+
error: (...args: unknown[]) => void;
|
|
23
|
+
info: (...args: unknown[]) => void;
|
|
24
|
+
debug: (...args: unknown[]) => void;
|
|
25
|
+
/** Returns a group function; if disabled, returns noop */
|
|
26
|
+
group: (label?: string) => void;
|
|
27
|
+
groupEnd: () => void;
|
|
28
|
+
/** Table output for structured data */
|
|
29
|
+
table: (data: unknown) => void;
|
|
30
|
+
/** Get the underlying console method (for advanced use) */
|
|
31
|
+
readonly raw: Console | {
|
|
32
|
+
log: () => void;
|
|
33
|
+
warn: () => void;
|
|
34
|
+
error: () => void;
|
|
35
|
+
info: () => void;
|
|
36
|
+
debug: () => void;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAEpD;AAED,kDAAkD;AAClD,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAID,eAAO,MAAM,KAAK;mBACD,OAAO,EAAE,KAAG,IAAI;oBAGf,OAAO,EAAE,KAAG,IAAI;qBAGf,OAAO,EAAE,KAAG,IAAI;oBAGjB,OAAO,EAAE,KAAG,IAAI;qBAGf,OAAO,EAAE,KAAG,IAAI;IAGjC,0DAA0D;oBAC1C,MAAM,KAAG,IAAI;oBAGf,IAAI;IAGlB,uCAAuC;kBACzB,OAAO,KAAG,IAAI;IAG5B,2DAA2D;;;;;;;;CAI5D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostics client for e2e testing.
|
|
3
|
+
*
|
|
4
|
+
* Minimal browser client that:
|
|
5
|
+
* - Parses URL params (connectionURL, serverCertHash, relayPubKey)
|
|
6
|
+
* - Creates a Session with zero plugins (channel-only mode)
|
|
7
|
+
* - Generates random inputs on 50ms interval
|
|
8
|
+
* - Logs SYNC ticks to console for conformance testing
|
|
9
|
+
* - Exits when session duration elapses
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/e2e/cli.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WASM Executor - Manages state transition via WASM modules
|
|
3
|
+
*
|
|
4
|
+
* Supports multiple plugins executing serially on shared state.
|
|
5
|
+
*
|
|
6
|
+
* @module wasm-host
|
|
7
|
+
*/
|
|
8
|
+
import { type InputSchema } from './input-codec';
|
|
9
|
+
import type { TickPrimitive } from './input-graph';
|
|
10
|
+
import { type CompiledSchema, type StateBuffer } from './state';
|
|
11
|
+
/**
|
|
12
|
+
* Batch transition execution interface.
|
|
13
|
+
*
|
|
14
|
+
* Takes input state and a batch of ticks, returns new state.
|
|
15
|
+
* Note: The function should NOT modify stateId - StateManager handles that.
|
|
16
|
+
*/
|
|
17
|
+
export interface BatchTransitionExecutor {
|
|
18
|
+
transition: (state: StateBuffer, ticks: TickPrimitive[]) => StateBuffer;
|
|
19
|
+
close: () => void;
|
|
20
|
+
}
|
|
21
|
+
export interface TransitionExports {
|
|
22
|
+
/** Per-tick transition function - mutates state in-place */
|
|
23
|
+
apply: (statePtr: number) => void;
|
|
24
|
+
/** WASM memory */
|
|
25
|
+
memory: WebAssembly.Memory;
|
|
26
|
+
}
|
|
27
|
+
/** Plugin definition for multi-plugin executor */
|
|
28
|
+
export interface PluginDef {
|
|
29
|
+
name: string;
|
|
30
|
+
wasmBytes: Uint8Array;
|
|
31
|
+
/** Reserved bytes in shared WASM memory for this plugin's data section and stack */
|
|
32
|
+
reservedBytes: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ExecutorOptions {
|
|
35
|
+
/** Be noisy in the console */
|
|
36
|
+
debug?: boolean | undefined;
|
|
37
|
+
/** The WASM module bytes (single plugin - deprecated, use plugins) */
|
|
38
|
+
moduleBytes?: Uint8Array;
|
|
39
|
+
/** Array of plugins in execution order */
|
|
40
|
+
plugins?: PluginDef[];
|
|
41
|
+
/** The state schema */
|
|
42
|
+
stateSchema: CompiledSchema;
|
|
43
|
+
/** The input schema */
|
|
44
|
+
inputSchema: InputSchema;
|
|
45
|
+
/** Maximum number of ticks per batch (for buffer sizing and yielding execution) */
|
|
46
|
+
maxTicksPerBatch: number;
|
|
47
|
+
}
|
|
48
|
+
export declare class Executor implements BatchTransitionExecutor {
|
|
49
|
+
private memory;
|
|
50
|
+
private plugins;
|
|
51
|
+
private options;
|
|
52
|
+
private stateSize;
|
|
53
|
+
private statePtr;
|
|
54
|
+
private heapPos;
|
|
55
|
+
private arenaResetMark;
|
|
56
|
+
private inputCodec;
|
|
57
|
+
private playerEntities;
|
|
58
|
+
constructor(options: ExecutorOptions);
|
|
59
|
+
/**
|
|
60
|
+
* Host-provided allocator for WASM modules.
|
|
61
|
+
* This enables shared memory across multiple plugins.
|
|
62
|
+
* Returns zeroed memory.
|
|
63
|
+
*/
|
|
64
|
+
private hostAlloc;
|
|
65
|
+
/**
|
|
66
|
+
* Mark current heap position as the arena reset point.
|
|
67
|
+
* Called after init allocations (state buffers) but before game logic.
|
|
68
|
+
*/
|
|
69
|
+
markArenaReset(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Reset heap to the marked position, reclaiming temporary allocations.
|
|
72
|
+
* Called between tick batches.
|
|
73
|
+
*/
|
|
74
|
+
resetArena(): void;
|
|
75
|
+
init(): Promise<Executor>;
|
|
76
|
+
/**
|
|
77
|
+
* Find an existing player entity by player index.
|
|
78
|
+
* Returns undefined if no entity exists for this player.
|
|
79
|
+
*/
|
|
80
|
+
private findPlayerEntity;
|
|
81
|
+
/**
|
|
82
|
+
* Spawn a new player entity and set its Player.index field.
|
|
83
|
+
*/
|
|
84
|
+
private spawnPlayerEntity;
|
|
85
|
+
/**
|
|
86
|
+
* Find or spawn a player entity for the given player index.
|
|
87
|
+
*/
|
|
88
|
+
private findOrSpawnPlayerEntity;
|
|
89
|
+
/**
|
|
90
|
+
* Reset control fields in a Player component to zero/default.
|
|
91
|
+
* Called at tick start before writing new inputs.
|
|
92
|
+
* Skips controls with retain="always" (they persist until explicitly changed).
|
|
93
|
+
*/
|
|
94
|
+
private resetPlayerControls;
|
|
95
|
+
/**
|
|
96
|
+
* Write decoded controls from an InputInstance to the Player component.
|
|
97
|
+
* Maps each control field to the corresponding Player component field.
|
|
98
|
+
*
|
|
99
|
+
* Note: vec2/vec3/quat controls are flattened to individual X/Y/Z/W fields
|
|
100
|
+
* by the Go codegen (e.g., "movement" becomes "movement_x", "movement_y").
|
|
101
|
+
*/
|
|
102
|
+
private writeControlsToPlayer;
|
|
103
|
+
/**
|
|
104
|
+
* Push decoded commands to the generated command events.
|
|
105
|
+
* Each command becomes a {Name}Command event with playerIndex prepended.
|
|
106
|
+
*/
|
|
107
|
+
private pushCommands;
|
|
108
|
+
/**
|
|
109
|
+
* Clear all command events at tick start.
|
|
110
|
+
*/
|
|
111
|
+
private clearCommandEvents;
|
|
112
|
+
/**
|
|
113
|
+
* Decode all payloads for a tick and write to state.
|
|
114
|
+
* - Finds or spawns player entities
|
|
115
|
+
* - Writes controls to Player components
|
|
116
|
+
* - Pushes commands to command events
|
|
117
|
+
*/
|
|
118
|
+
private decodePayloadsToState;
|
|
119
|
+
/**
|
|
120
|
+
* Execute state transition for a batch of ticks.
|
|
121
|
+
*
|
|
122
|
+
* @param state - Current state buffer
|
|
123
|
+
* @param ticks - Array of tick nodes to process
|
|
124
|
+
* @returns New state buffer after applying all ticks
|
|
125
|
+
*/
|
|
126
|
+
transition(state: Uint8Array, ticks: TickPrimitive[]): Uint8Array;
|
|
127
|
+
close(): void;
|
|
128
|
+
getStateSize(): number;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAsC,KAAK,WAAW,EAAsB,MAAM,eAAe,CAAC;AACzG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAWjB,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,WAAW,CAAC;IACxE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,kBAAkB;IAClB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;CAC5B;AAED,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;I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;;;;OAKG;IACH,OAAO,CAAC,qBAAqB;IA+B7B;;;;;;OAMG;IACH,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,UAAU;IAuDjE,KAAK,IAAI,IAAI;IAKb,YAAY,IAAI,MAAM;CAOvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAMlD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema-driven input codec for variable-length game inputs.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a TLV (type-length-value) encoding for game inputs that
|
|
5
|
+
* supports both real-time controls (buttons, axes) and discrete commands (RPC-style).
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Variable-length encoding: Only set fields are transmitted
|
|
9
|
+
* - Semantic hints: Controls declare meaning (momentary, toggle, axis) for prediction
|
|
10
|
+
* - Command support: RTS-style commands with typed arguments
|
|
11
|
+
* - Cross-language: Same wire format for TypeScript and Go
|
|
12
|
+
*
|
|
13
|
+
* See ADR-017: Input Encoding for specification details.
|
|
14
|
+
*
|
|
15
|
+
* @module input-codec
|
|
16
|
+
*/
|
|
17
|
+
import { type InputSchema, type ControlDef, type CommandDef, type CommandArgDef, type FlagType, type InputFieldType } from './schema';
|
|
18
|
+
export type { InputSchema, ControlDef, CommandDef, CommandArgDef, FlagType, };
|
|
19
|
+
export type { InputFieldType as FieldType };
|
|
20
|
+
export type { PrimitiveType, CompoundType, ArrayType } from './schema';
|
|
21
|
+
interface InternalCompiledField {
|
|
22
|
+
name: string;
|
|
23
|
+
type: string;
|
|
24
|
+
size: number;
|
|
25
|
+
offset: number;
|
|
26
|
+
options?: readonly string[] | undefined;
|
|
27
|
+
arrayLength?: number | undefined;
|
|
28
|
+
arrayElementType?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
interface InternalCompiledControl {
|
|
31
|
+
name: string;
|
|
32
|
+
index: number;
|
|
33
|
+
field: InternalCompiledField;
|
|
34
|
+
hint?: string | undefined;
|
|
35
|
+
retain: 'tick' | 'always';
|
|
36
|
+
}
|
|
37
|
+
interface InternalCompiledCommand {
|
|
38
|
+
name: string;
|
|
39
|
+
index: number;
|
|
40
|
+
args: InternalCompiledField[];
|
|
41
|
+
totalSize: number;
|
|
42
|
+
}
|
|
43
|
+
interface InternalCompiledInputSchema {
|
|
44
|
+
controls: InternalCompiledControl[];
|
|
45
|
+
commands: InternalCompiledCommand[];
|
|
46
|
+
controlByName: Map<string, InternalCompiledControl>;
|
|
47
|
+
commandByName: Map<string, InternalCompiledCommand>;
|
|
48
|
+
}
|
|
49
|
+
/** Decoded command with name and arguments */
|
|
50
|
+
export interface DecodedCommand {
|
|
51
|
+
name: string;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
/** Input instance that can be encoded/decoded */
|
|
55
|
+
export declare class InputInstance {
|
|
56
|
+
private schema;
|
|
57
|
+
private fields;
|
|
58
|
+
private commandList;
|
|
59
|
+
constructor(schema: InternalCompiledInputSchema);
|
|
60
|
+
/** Set a control value by name */
|
|
61
|
+
setControl(name: string, value: unknown): void;
|
|
62
|
+
/** Set a flags control from an object of boolean options */
|
|
63
|
+
setFlags(name: string, flags: Record<string, boolean>): void;
|
|
64
|
+
/** Set a vec2 control (f32 components) */
|
|
65
|
+
setVec2(name: string, value: [number, number]): void;
|
|
66
|
+
/** Set a vec3 control (f32 components) */
|
|
67
|
+
setVec3(name: string, value: [number, number, number]): void;
|
|
68
|
+
/** Set a quat control (f32 components: x, y, z, w) */
|
|
69
|
+
setQuat(name: string, value: [number, number, number, number]): void;
|
|
70
|
+
/** Get a control value by name */
|
|
71
|
+
getControl(name: string): unknown;
|
|
72
|
+
/** Get a flags control as an object of boolean options */
|
|
73
|
+
getFlags(name: string): Record<string, boolean>;
|
|
74
|
+
/** Get a vec2 control (f32 components) */
|
|
75
|
+
getVec2(name: string): [number, number];
|
|
76
|
+
/** Get a vec3 control (f32 components) */
|
|
77
|
+
getVec3(name: string): [number, number, number];
|
|
78
|
+
/** Get a quat control (f32 components: x, y, z, w) */
|
|
79
|
+
getQuat(name: string): [number, number, number, number];
|
|
80
|
+
/** Check if a control is set */
|
|
81
|
+
hasControl(name: string): boolean;
|
|
82
|
+
/** Add a command */
|
|
83
|
+
addCommand(name: string, args: Record<string, unknown>): void;
|
|
84
|
+
/** Get all commands */
|
|
85
|
+
getCommands(): DecodedCommand[];
|
|
86
|
+
/** Encode to TLV wire format */
|
|
87
|
+
encode(): Uint8Array;
|
|
88
|
+
/** Decode from TLV wire format */
|
|
89
|
+
static decode(schema: InternalCompiledInputSchema, bytes: Uint8Array): InputInstance;
|
|
90
|
+
/** Clear all set controls and commands */
|
|
91
|
+
clear(): void;
|
|
92
|
+
private encodeValue;
|
|
93
|
+
private decodeValue;
|
|
94
|
+
private getDefaultValue;
|
|
95
|
+
}
|
|
96
|
+
/** Compiled input codec with create/decode methods */
|
|
97
|
+
export interface InputCodec {
|
|
98
|
+
/** Create a new empty input instance */
|
|
99
|
+
create(): InputInstance;
|
|
100
|
+
/** Decode bytes to an input instance */
|
|
101
|
+
decode(bytes: Uint8Array): InputInstance;
|
|
102
|
+
/** Get the compiled schema (internal format) */
|
|
103
|
+
readonly schema: InternalCompiledInputSchema;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compile an input schema into a codec.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const codec = compileInputCodec({
|
|
111
|
+
* controls: [
|
|
112
|
+
* { name: "buttons", type: "flags8", options: ["w", "a", "s", "d", "jump", "fire"], hint: "momentary" },
|
|
113
|
+
* { name: "aim", type: "vec2", hint: "axis" },
|
|
114
|
+
* ],
|
|
115
|
+
* commands: [
|
|
116
|
+
* { name: "move", args: [{ name: "unitId", type: "uint16" }, { name: "pos", type: "vec2" }] },
|
|
117
|
+
* ],
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* const input = codec.create();
|
|
121
|
+
* input.setFlags("buttons", { w: true, jump: true });
|
|
122
|
+
* input.setVec2("aim", [0.5, -0.25]); // native f32 floats
|
|
123
|
+
* input.addCommand("move", { unitId: 12, pos: [100.0, 200.0] });
|
|
124
|
+
*
|
|
125
|
+
* const bytes = input.encode();
|
|
126
|
+
* const decoded = codec.decode(bytes);
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* Also works with JSON-imported schemas:
|
|
130
|
+
* ```typescript
|
|
131
|
+
* import config from './game.config.json';
|
|
132
|
+
* const codec = compileInputCodec(config.input);
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare function compileInputCodec(schema: InputSchema): InputCodec;
|
|
136
|
+
//# sourceMappingURL=input-codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-codec.d.ts","sourceRoot":"","sources":["../../src/input-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,EACb,QAAQ,GACT,CAAC;AAGF,YAAY,EAAE,cAAc,IAAI,SAAS,EAAE,CAAC;AAG5C,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAUvE,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,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