@hytopia.com/server-protocol 1.3.19 → 1.3.20

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.19",
3
+ "version": "1.3.20",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -23,6 +23,7 @@ export enum PacketId {
23
23
  INPUT = 1,
24
24
  STATE_REQUEST = 2,
25
25
  CHAT_MESSAGE_SEND = 3,
26
+ UI_MESSAGE_SEND = 4,
26
27
 
27
28
  // Standard Outbound Packet Types: 32 - 127 range
28
29
  SYNC_RESPONSE = 32,
@@ -34,6 +35,8 @@ export enum PacketId {
34
35
  ENTITIES = 38,
35
36
  WORLD = 39,
36
37
  CAMERA = 40,
38
+ UI = 41,
39
+ UI_MESSAGES = 42,
37
40
 
38
41
  // Debug Inbound Packet Types: 128 - 191 range
39
42
  DEBUG_CONFIG = 128,
@@ -0,0 +1,11 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { uiMessageSchema } from '../../schemas/UIMessage';
4
+ import type { UIMessageSchema } from '../../schemas/UIMessage';
5
+
6
+ export type UIMessageSendPacket = IPacket<typeof PacketId.UI_MESSAGE_SEND, UIMessageSchema>;
7
+
8
+ export const uiMessageSendPacketDefinition = definePacket(
9
+ PacketId.UI_MESSAGE_SEND,
10
+ uiMessageSchema
11
+ );
@@ -3,3 +3,4 @@ export * from './DebugConfig';
3
3
  export * from './Input';
4
4
  export * from './StateRequest';
5
5
  export * from './SyncRequest';
6
+ export * from './UIMessageSend';
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { uiSchema } from '../../schemas/UI';
4
+ import type { UISchema } from '../../schemas/UI';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type UIPacket = IPacket<typeof PacketId.UI, UISchema> & [WorldTick];
8
+
9
+ export const uiPacketDefinition = definePacket(
10
+ PacketId.UI,
11
+ uiSchema,
12
+ );
@@ -0,0 +1,12 @@
1
+ import { definePacket, PacketId } from '../PacketCore';
2
+ import type { IPacket } from '../PacketCore';
3
+ import { uiMessagesSchema } from '../../schemas/UIMessages';
4
+ import type { UIMessagesSchema } from '../../schemas/UIMessages';
5
+ import type { WorldTick } from '../PacketCore';
6
+
7
+ export type UIMessagesPacket = IPacket<typeof PacketId.UI_MESSAGES, UIMessagesSchema> & [WorldTick];
8
+
9
+ export const uiMessagesPacketDefinition = definePacket(
10
+ PacketId.UI_MESSAGES,
11
+ uiMessagesSchema,
12
+ );
@@ -8,4 +8,6 @@ export * from './Entities';
8
8
  export * from './PhysicsDebugRender';
9
9
  export * from './PhysicsDebugRaycasts';
10
10
  export * from './SyncResponse';
11
+ export * from './UI';
12
+ export * from './UIMessages';
11
13
  export * from './World';
package/schemas/UI.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+
3
+ export type UISchema = {
4
+ c?: string[]; // css uris
5
+ h?: string[]; // html uris
6
+ j?: string[]; // js uris
7
+ };
8
+
9
+ export const uiSchema: JSONSchemaType<UISchema> = {
10
+ type: 'object',
11
+ properties: {
12
+ c: { type: 'array', items: { type: 'string' }, nullable: true },
13
+ h: { type: 'array', items: { type: 'string' }, nullable: true },
14
+ j: { type: 'array', items: { type: 'string' }, nullable: true },
15
+ },
16
+ additionalProperties: false,
17
+ }
@@ -0,0 +1,11 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+
3
+ export type UIMessageSchema = {
4
+ [key: string]: any;
5
+ }
6
+
7
+ export const uiMessageSchema: JSONSchemaType<UIMessageSchema> = {
8
+ type: 'object',
9
+ properties: {},
10
+ additionalProperties: true,
11
+ }
@@ -0,0 +1,10 @@
1
+ import { uiMessageSchema } from './UIMessage';
2
+ import type { JSONSchemaType } from 'ajv';
3
+ import type { UIMessageSchema } from './UIMessage';
4
+
5
+ export type UIMessagesSchema = UIMessageSchema[];
6
+
7
+ export const uiMessagesSchema: JSONSchemaType<UIMessagesSchema> = {
8
+ type: 'array',
9
+ items: { ...uiMessageSchema },
10
+ }
package/schemas/index.ts CHANGED
@@ -22,6 +22,9 @@ export * from './RgbColor';
22
22
  export * from './StateRequest';
23
23
  export * from './SyncRequest';
24
24
  export * from './SyncResponse';
25
+ export * from './UI';
26
+ export * from './UIMessage';
27
+ export * from './UIMessages';
25
28
  export * from './Vector';
26
29
  export * from './VectorBoolean';
27
30
  export * from './World';