@hytopia.com/server-protocol 1.0.11 → 1.0.14

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/exports.ts CHANGED
@@ -1,7 +1,7 @@
1
- import * as inboundPackets from './packets/inbound';
2
- import * as outboundPackets from './packets/outbound';
3
-
4
- export { inboundPackets, outboundPackets };
1
+ export * from './packets/inbound';
2
+ export * from './packets/outbound';
5
3
  export * from './packets/PacketCore';
6
4
  export * from './packets/PacketDefinitions';
7
5
  export * from './schemas';
6
+
7
+
package/index.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import * as protocol from './exports';
2
2
  export * from './exports';
3
- export default protocol;
3
+ export default protocol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hytopia.com/server-protocol",
3
- "version": "1.0.11",
3
+ "version": "1.0.14",
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,
@@ -2,6 +2,8 @@ import * as inboundPackets from './inbound';
2
2
  import * as outboundPackets from './outbound';
3
3
  import type { PacketId, AnyPacket, AnyPacketDefinition } from './PacketCore';
4
4
 
5
+ export { inboundPackets, outboundPackets };
6
+
5
7
  export const registeredPackets = new Map<PacketId, AnyPacketDefinition>();
6
8
 
7
9
  const allPackets = { ...inboundPackets, ...outboundPackets };
@@ -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';
@@ -2,12 +2,12 @@ import { blockTypeSchema } from './BlockType';
2
2
  import type { JSONSchemaType } from 'ajv';
3
3
  import type { BlockTypeSchema } from './BlockType';
4
4
 
5
- export type BlockRegistrySchema = {
5
+ export type BlockTypeRegistrySchema = {
6
6
  wi: string; // 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
13
  wi: { type: 'string' },
@@ -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
@@ -7,6 +7,7 @@ export type EntitySchema = {
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
@@ -20,6 +21,7 @@ export const entitySchema: JSONSchemaType<EntitySchema> = {
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 },
@@ -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
- );