@hytopia.com/server-protocol 1.2.4 → 1.2.6

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.2.4",
3
+ "version": "1.2.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -26,12 +26,13 @@ export enum PacketId {
26
26
 
27
27
  // Standard Outbound Packet Types: 32 - 127 range
28
28
  SYNC_RESPONSE = 32,
29
- BLOCKS = 33,
30
- BLOCK_TYPES = 34,
31
- CHAT_MESSAGES = 35,
32
- CHUNKS = 36,
33
- ENTITIES = 37,
34
- WORLD = 38,
29
+ AUDIOS = 33,
30
+ BLOCKS = 34,
31
+ BLOCK_TYPES = 35,
32
+ CHAT_MESSAGES = 36,
33
+ CHUNKS = 37,
34
+ ENTITIES = 38,
35
+ WORLD = 39,
35
36
 
36
37
  // Debug Inbound Packet Types: 128 - 191 range
37
38
  DEBUG_CONFIG = 128,
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { audiosSchema } from '../../schemas/Audios';
4
+ import type { AudiosSchema } from '../../schemas/Audios';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type AudiosPacket = IPacket<typeof PacketId.AUDIOS, AudiosSchema> & [WorldTick];
8
+
9
+ export const audiosPacketDefinition = definePacket(
10
+ PacketId.AUDIOS,
11
+ audiosSchema,
12
+ );
@@ -1,3 +1,4 @@
1
+ export * from './Audios';
1
2
  export * from './Blocks';
2
3
  export * from './BlockTypes';
3
4
  export * from './ChatMessages';
@@ -0,0 +1,37 @@
1
+ import { vectorSchema } from './Vector';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { VectorSchema } from './Vector';
4
+
5
+ export type AudioSchema = {
6
+ a?: string; // audio uri
7
+ c?: VectorSchema; // coordinate of spatial audio origin
8
+ d?: number; // duration
9
+ de?: number; // detune
10
+ g?: number; // gain (0 to 1, or 1+ for distortion)
11
+ l?: boolean; // loop
12
+ o?: boolean; // one shot
13
+ of?: number; // offset
14
+ p?: number; // playback rate (0+)
15
+ r?: boolean; // restart
16
+ s?: boolean; // stop
17
+ v?: number; // volume (0 to 1)
18
+ }
19
+
20
+ export const audioSchema: JSONSchemaType<AudioSchema> = {
21
+ type: 'object',
22
+ properties: {
23
+ a: { type: 'string', nullable: true },
24
+ c: { ...vectorSchema, nullable: true },
25
+ d: { type: 'number', nullable: true },
26
+ de: { type: 'number', nullable: true },
27
+ g: { type: 'number', minimum: 0, nullable: true },
28
+ l: { type: 'boolean', nullable: true },
29
+ o: { type: 'boolean', nullable: true },
30
+ of: { type: 'number', nullable: true },
31
+ p: { type: 'number', minimum: 0, nullable: true },
32
+ r: { type: 'boolean', nullable: true },
33
+ s: { type: 'boolean', nullable: true },
34
+ v: { type: 'number', minimum: 0, maximum: 1, nullable: true },
35
+ },
36
+ additionalProperties: false,
37
+ }
@@ -0,0 +1,10 @@
1
+ import { audioSchema } from './Audio';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { AudioSchema } from './Audio';
4
+
5
+ export type AudiosSchema = AudioSchema[];
6
+
7
+ export const audiosSchema: JSONSchemaType<AudiosSchema> = {
8
+ type: 'array',
9
+ items: { ...audioSchema },
10
+ }
package/schemas/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './Audio';
2
+ export * from './Audios';
1
3
  export * from './Block';
2
4
  export * from './Blocks';
3
5
  export * from './BlockType';