@hytopia.com/server-protocol 1.3.4 → 1.3.7

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.3.4",
3
+ "version": "1.3.7",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -33,6 +33,7 @@ export enum PacketId {
33
33
  CHUNKS = 37,
34
34
  ENTITIES = 38,
35
35
  WORLD = 39,
36
+ CAMERA = 40,
36
37
 
37
38
  // Debug Inbound Packet Types: 128 - 191 range
38
39
  DEBUG_CONFIG = 128,
@@ -1,6 +1,6 @@
1
1
  import * as inboundPackets from './inbound';
2
2
  import * as outboundPackets from './outbound';
3
- import type { PacketId, AnyPacket, AnyPacketDefinition } from './PacketCore';
3
+ import type { PacketId, AnyPacket, AnyPacketDefinition, IPacket } from './PacketCore';
4
4
 
5
5
  export { inboundPackets, outboundPackets };
6
6
 
@@ -20,7 +20,7 @@ for (const packet of Object.values(allPackets)) {
20
20
  }
21
21
  }
22
22
 
23
- export function isValidPacket(packet: unknown): packet is AnyPacket {
23
+ export function isValidPacket(packet: IPacket<PacketId, unknown>): packet is AnyPacket {
24
24
  if (
25
25
  typeof packet !== 'object' ||
26
26
  packet === null ||
File without changes
@@ -1,6 +1,7 @@
1
1
  export * from './Audios';
2
2
  export * from './Blocks';
3
3
  export * from './BlockTypes';
4
+ export * from './Camera';
4
5
  export * from './ChatMessages';
5
6
  export * from './Chunks';
6
7
  export * from './Entities';
@@ -0,0 +1,37 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ import { vectorSchema } from './Vector';
3
+ import type { VectorSchema } from './Vector';
4
+
5
+ export type CameraSchema = {
6
+ f?: boolean // first person mode
7
+ t?: boolean // third person mode
8
+ e?: number // entity id to fix camera to
9
+ el?: number // entity id to look at
10
+ fo?: number // film offset, + value shifts right, - shifts left
11
+ ffo?: number // first person forward offset, moves camera in (+) or out (-) relative to camera position
12
+ fv?: number // field of view
13
+ p?: VectorSchema // position to fix camera at
14
+ pl?: VectorSchema // position to look at
15
+ h?: string[] // player model parts to hide by partial case insensitive match of gltf children names
16
+ o?: VectorSchema // offset - positional relative to target
17
+ z?: number // zoom
18
+ }
19
+
20
+ export const cameraSchema: JSONSchemaType<CameraSchema> = {
21
+ type: 'object',
22
+ properties: {
23
+ f: { type: 'boolean', nullable: true },
24
+ t: { type: 'boolean', nullable: true },
25
+ e: { type: 'number', nullable: true },
26
+ el: { type: 'number', nullable: true },
27
+ fo: { type: 'number', nullable: true },
28
+ ffo: { type: 'number', nullable: true },
29
+ fv: { type: 'number', nullable: true },
30
+ p: { ...vectorSchema, nullable: true },
31
+ pl: { ...vectorSchema, nullable: true },
32
+ h: { type: 'array', items: { type: 'string' }, nullable: true },
33
+ o: { ...vectorSchema, nullable: true },
34
+ z: { type: 'number', nullable: true },
35
+ },
36
+ additionalProperties: false,
37
+ }
package/schemas/index.ts CHANGED
@@ -4,6 +4,7 @@ export * from './Block';
4
4
  export * from './Blocks';
5
5
  export * from './BlockType';
6
6
  export * from './BlockTypes';
7
+ export * from './Camera';
7
8
  export * from './ChatMessage';
8
9
  export * from './ChatMessages';
9
10
  export * from './Chunk';
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "target": "ESNext",
5
+ "module": "ESNext",
6
+ "moduleResolution": "node",
7
+ "strict": true,
8
+ "noImplicitReturns": true,
9
+ "noImplicitAny": true,
10
+ "noImplicitThis": true,
11
+ "strictNullChecks": true,
12
+ },
13
+ "include": ["packets/**/*.ts", "schemas/**/*.json", "shared/**/*.ts"]
14
+ }
package/bun.lockb DELETED
Binary file