@hytopia.com/server-protocol 1.0.12 → 1.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/server-protocol",
3
- "version": "1.0.12",
3
+ "version": "1.0.15",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -20,11 +20,13 @@ import type { JSONSchemaType, ValidateFunction } from 'ajv';
20
20
  export enum PacketId {
21
21
  // Standard Inbound Packet Types: 0 - 31 range
22
22
  HEARTBEAT = 0,
23
- INPUT = 1,
23
+ DEBUG_CONFIG = 1,
24
+ INPUT = 2,
25
+ STATE_REQUEST = 3,
24
26
 
25
27
  // Standard Outbound Packet Types: 32 - 127 range
26
28
  BLOCK = 32,
27
- BLOCK_REGISTRY = 33,
29
+ BLOCK_TYPE_REGISTRY = 33,
28
30
  BLOCK_TYPE = 34,
29
31
  CHUNK = 35,
30
32
  ENTITY = 36,
@@ -0,0 +1,11 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { debugConfigSchema } from '../../schemas/DebugConfig';
4
+ import type { DebugConfigSchema } from '../../schemas/DebugConfig';
5
+
6
+ export type DebugConfigPacket = IPacket<typeof PacketId.DEBUG_CONFIG, DebugConfigSchema>;
7
+
8
+ export const debugConfigPacketDefinition = definePacket(
9
+ PacketId.DEBUG_CONFIG,
10
+ debugConfigSchema
11
+ );
@@ -0,0 +1,11 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { stateRequestSchema } from '../../schemas/StateRequest';
4
+ import type { StateRequestSchema } from '../../schemas/StateRequest';
5
+
6
+ export type StateRequestPacket = IPacket<typeof PacketId.STATE_REQUEST, StateRequestSchema>;
7
+
8
+ export const stateRequestPacketDefinition = definePacket(
9
+ PacketId.STATE_REQUEST,
10
+ stateRequestSchema
11
+ );
@@ -1,2 +1,3 @@
1
+ export * from './DebugConfig';
1
2
  export * from './Heartbeat';
2
3
  export * from './Input';
@@ -0,0 +1,11 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { blockTypeRegistrySchema } from '../../schemas/BlockTypeRegistry';
4
+ import type { BlockTypeRegistrySchema } from '../../schemas/BlockTypeRegistry';
5
+
6
+ export type BlockTypeRegistryPacket = IPacket<typeof PacketId.BLOCK_TYPE_REGISTRY, BlockTypeRegistrySchema>;
7
+
8
+ export const blockTypeRegistryPacketDefinition = definePacket(
9
+ PacketId.BLOCK_TYPE_REGISTRY,
10
+ blockTypeRegistrySchema,
11
+ );
@@ -1,5 +1,5 @@
1
1
  export * from './Block';
2
- export * from './BlockRegistry';
2
+ export * from './BlockTypeRegistry';
3
3
  export * from './BlockType';
4
4
  export * from './Chunk';
5
5
  export * from './Entity';
package/schemas/Block.ts CHANGED
@@ -3,7 +3,7 @@ import type { JSONSchemaType } from 'ajv';
3
3
  import type { VectorSchema } from './Vector';
4
4
 
5
5
  export type BlockSchema = {
6
- wi: string; // world id
6
+ wi: number; // world id
7
7
  i: number; // block id
8
8
  c: VectorSchema; // coordinate
9
9
  };
@@ -11,7 +11,7 @@ export type BlockSchema = {
11
11
  export const blockSchema: JSONSchemaType<BlockSchema> = {
12
12
  type: 'object',
13
13
  properties: {
14
- wi: { type: 'string' },
14
+ wi: { type: 'number' },
15
15
  i: { type: 'number' },
16
16
  c: vectorSchema,
17
17
  },
@@ -3,7 +3,7 @@ import type { JSONSchemaType } from 'ajv';
3
3
  import type { ColliderDescSchema } from './ColliderDesc';
4
4
 
5
5
  export type BlockTypeSchema = {
6
- wi: string; // world id
6
+ wi: number; // world id
7
7
  i: number; // block type id
8
8
  d: boolean; // delta
9
9
  t?: string; // textureUri
@@ -15,7 +15,7 @@ export type BlockTypeSchema = {
15
15
  export const blockTypeSchema: JSONSchemaType<BlockTypeSchema> = {
16
16
  type: 'object',
17
17
  properties: {
18
- wi: { type: 'string' },
18
+ wi: { type: 'number' },
19
19
  i: { type: 'number' },
20
20
  d: { type: 'boolean' },
21
21
  t: { type: 'string', nullable: true },
@@ -2,15 +2,15 @@ import { blockTypeSchema } from './BlockType';
2
2
  import type { JSONSchemaType } from 'ajv';
3
3
  import type { BlockTypeSchema } from './BlockType';
4
4
 
5
- export type BlockRegistrySchema = {
6
- wi: string; // world id
5
+ export type BlockTypeRegistrySchema = {
6
+ wi: number; // world id
7
7
  b: BlockTypeSchema[]; // block types
8
8
  }
9
9
 
10
- export const blockRegistrySchema: JSONSchemaType<BlockRegistrySchema> = {
10
+ export const blockTypeRegistrySchema: JSONSchemaType<BlockTypeRegistrySchema> = {
11
11
  type: 'object',
12
12
  properties: {
13
- wi: { type: 'string' },
13
+ wi: { type: 'number' },
14
14
  b: {
15
15
  type: 'array',
16
16
  items: blockTypeSchema,
package/schemas/Chunk.ts CHANGED
@@ -3,7 +3,7 @@ import type { JSONSchemaType } from 'ajv';
3
3
  import type { VectorSchema } from './Vector';
4
4
 
5
5
  export type ChunkSchema = {
6
- wi: string; // world id
6
+ wi: number; // world id
7
7
  c: VectorSchema; // chunk coordinate [ 16n, 16n, 16n ]
8
8
  b: Uint8Array | number[]; // block ids in chunk, 16^3 entries, registry block ids 1-255, 0 = none
9
9
  };
@@ -11,7 +11,7 @@ export type ChunkSchema = {
11
11
  export const chunkSchema: JSONSchemaType<ChunkSchema> = {
12
12
  type: 'object',
13
13
  properties: {
14
- wi: { type: 'string' },
14
+ wi: { type: 'number' },
15
15
  c: vectorSchema,
16
16
  b: {
17
17
  type: 'array',
@@ -4,12 +4,14 @@ import type { ColliderDescSchema } from './ColliderDesc';
4
4
 
5
5
  export type ColliderSchema = {
6
6
  h?: number; // collider handle for rapier
7
+ rm?: boolean; // removed
7
8
  } & ColliderDescSchema;
8
9
 
9
10
  export const colliderSchema: JSONSchemaType<ColliderSchema> = {
10
11
  type: 'object',
11
12
  properties: {
12
13
  h: { type: 'number', nullable: true },
14
+ rm: { type: 'boolean', nullable: true },
13
15
  ...colliderDescSchema.properties
14
16
  },
15
17
  additionalProperties: false,
@@ -0,0 +1,17 @@
1
+ import { JSONSchemaType } from 'ajv';
2
+
3
+ export type DebugConfigSchema = {
4
+ // physics debug render enabled,
5
+ // setting true will cause the
6
+ // server to send a PhysicsDebugRender
7
+ // packet per tick.
8
+ pdr?: boolean;
9
+ }
10
+
11
+ export const debugConfigSchema: JSONSchemaType<DebugConfigSchema> = {
12
+ type: 'object',
13
+ properties: {
14
+ pdr: { type: 'boolean', nullable: true },
15
+ },
16
+ additionalProperties: false,
17
+ }
package/schemas/Entity.ts CHANGED
@@ -3,10 +3,11 @@ import type { JSONSchemaType } from 'ajv';
3
3
  import type { RigidBodySchema } from './RigidBody';
4
4
 
5
5
  export type EntitySchema = {
6
- wi: string; // world id
6
+ wi: number; // world id
7
7
  i: number; // entity id
8
8
  d: boolean; // delta
9
9
  f?: boolean; // focused
10
+ rm?: boolean; // removed
10
11
  n?: string; // name
11
12
  m?: string; // model uri
12
13
  t?: string; // texture uri
@@ -16,10 +17,11 @@ export type EntitySchema = {
16
17
  export const entitySchema: JSONSchemaType<EntitySchema> = {
17
18
  type: 'object',
18
19
  properties: {
19
- wi: { type: 'string' },
20
+ wi: { type: 'number' },
20
21
  i: { type: 'number' },
21
22
  d: { type: 'boolean' },
22
23
  f: { type: 'boolean', nullable: true },
24
+ rm: { type: 'boolean', nullable: true },
23
25
  n: { type: 'string', nullable: true },
24
26
  m: { type: 'string', nullable: true },
25
27
  t: { type: 'string', nullable: true },
@@ -1,7 +1,7 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
 
3
3
  export type PhysicsDebugRenderSchema = {
4
- wi: string; // world id
4
+ wi: number; // world id
5
5
  v: number[]; // rapier debug render vertices
6
6
  c: number[]; // rapier debug render colors
7
7
  }
@@ -9,7 +9,7 @@ export type PhysicsDebugRenderSchema = {
9
9
  export const physicsDebugRenderSchema: JSONSchemaType<PhysicsDebugRenderSchema> = {
10
10
  type: 'object',
11
11
  properties: {
12
- wi: { type: 'string' },
12
+ wi: { type: 'number' },
13
13
  v: { type: 'array', items: { type: 'number' } },
14
14
  c: { type: 'array', items: { type: 'number' } },
15
15
  },
@@ -4,12 +4,14 @@ import { RigidBodyDescSchema } from './RigidBodyDesc';
4
4
 
5
5
  export type RigidBodySchema = {
6
6
  h?: number; // rigid body handle for rapier
7
+ rm?: boolean; // removed
7
8
  } & RigidBodyDescSchema;
8
9
 
9
10
  export const rigidBodySchema: JSONSchemaType<RigidBodySchema> = {
10
11
  type: 'object',
11
12
  properties: {
12
13
  h: { type: 'number', nullable: true },
14
+ rm: { type: 'boolean', nullable: true },
13
15
  ...rigidBodyDescSchema.properties,
14
16
  },
15
17
  additionalProperties: false,
@@ -0,0 +1,13 @@
1
+ import { JSONSchemaType } from 'ajv';
2
+
3
+ export type StateRequestSchema = {
4
+
5
+ }
6
+
7
+ export const stateRequestSchema: JSONSchemaType<StateRequestSchema> = {
8
+ type: 'object',
9
+ properties: {
10
+
11
+ },
12
+ additionalProperties: false,
13
+ }
package/schemas/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './Block';
2
- export * from './BlockRegistry';
2
+ export * from './BlockTypeRegistry';
3
3
  export * from './BlockType';
4
4
  export * from './Chunk';
5
5
  export * from './Collider';
@@ -1,11 +0,0 @@
1
- import { definePacket, PacketId } from '../PacketCore';
2
- import type { IPacket } from '../PacketCore';
3
- import { blockRegistrySchema } from '../../schemas/BlockRegistry';
4
- import type { BlockRegistrySchema } from '../../schemas/BlockRegistry';
5
-
6
- export type BlockRegistryPacket = IPacket<typeof PacketId.BLOCK_REGISTRY, BlockRegistrySchema>;
7
-
8
- export const blockRegistryPacketDefinition = definePacket(
9
- PacketId.BLOCK_REGISTRY,
10
- blockRegistrySchema,
11
- );