@hytopia.com/server-protocol 1.0.8 → 1.0.10

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 ADDED
@@ -0,0 +1,8 @@
1
+ import * as inboundPackets from './packets/inbound';
2
+ import * as outboundPackets from './packets/outbound';
3
+
4
+ export { inboundPackets, outboundPackets };
5
+ export * from './packets/inbound';
6
+ export * from './packets/outbound';
7
+ export * from './packets/PacketCore';
8
+ export * from './schemas';
package/index.ts CHANGED
@@ -1,16 +1,3 @@
1
- import * as inboundPackets from './packets/inbound';
2
- import * as outboundPackets from './packets/outbound';
3
- import * as PacketCore from './packets/PacketCore';
4
- import * as schemas from './schemas';
5
-
6
- export * from './packets/inbound';
7
- export * from './packets/outbound';
8
- export * from './packets/PacketCore';
9
- export * from './schemas';
10
-
11
- export default {
12
- inboundPackets,
13
- outboundPackets,
14
- ...PacketCore,
15
- ...schemas,
16
- };
1
+ import * as protocol from './exports';
2
+ export * from './exports';
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.8",
3
+ "version": "1.0.10",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -17,7 +17,7 @@ import type { JSONSchemaType, ValidateFunction } from 'ajv';
17
17
  * in encoded format.
18
18
  */
19
19
 
20
- export enum PacketIds {
20
+ export enum PacketId {
21
21
  // Standard Inbound Packet Types: 0 - 31 range
22
22
  HEARTBEAT = 0,
23
23
  INPUT = 1,
@@ -40,33 +40,33 @@ export enum PacketIds {
40
40
  * Generators for packet definitions and validators.
41
41
  */
42
42
 
43
- export interface IPacketDefinition<TId extends PacketIds, TSchema> {
43
+ export interface IPacketDefinition<TId extends PacketId, TSchema> {
44
44
  id: TId;
45
45
  schema: JSONSchemaType<TSchema>;
46
46
  validate: ValidateFunction<TSchema>;
47
47
  }
48
48
 
49
- export interface IPacket<TId extends PacketIds, TSchema> {
50
- id: TId;
51
- payload: TSchema;
49
+ export interface IPacket<TId extends PacketId, TSchema> {
50
+ i: TId; // packet id
51
+ d: TSchema; // packet data
52
52
  }
53
53
 
54
- export type AnyPacket = IPacket<PacketIds, unknown>;
54
+ export type AnyPacket = IPacket<PacketId, unknown>;
55
55
 
56
56
  export type AnyPacketDefinition = IPacketDefinition<number, unknown>;
57
57
 
58
58
  export const createPacket = <TId extends number, TSchema>(
59
59
  packetDef: IPacketDefinition<TId, TSchema>,
60
- payload: TSchema,
60
+ data: TSchema,
61
61
  ): IPacket<TId, TSchema> => {
62
- if (!packetDef.validate(payload)) {
62
+ if (!packetDef.validate(data)) {
63
63
  throw new Error(`createPacket(): Invalid payload for packet with id ${packetDef.id}, error: ${Ajv.instance.errorsText(packetDef.validate.errors)}`);
64
64
  }
65
65
 
66
- return { id: packetDef.id, payload };
66
+ return { i: packetDef.id, d: data };
67
67
  }
68
68
 
69
- export const definePacket = <TId extends PacketIds, TSchema>(
69
+ export const definePacket = <TId extends PacketId, TSchema>(
70
70
  id: TId,
71
71
  schema: JSONSchemaType<TSchema>,
72
72
  ): IPacketDefinition<TId, TSchema> => ({
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { heartbeatSchema } from '../../schemas/Heartbeat';
4
- import type { Heartbeat } from '../../schemas/Heartbeat';
4
+ import type { HeartbeatSchema } from '../../schemas/Heartbeat';
5
5
 
6
- export type HeartbeatPacket = IPacket<typeof PacketIds.HEARTBEAT, Heartbeat>;
6
+ export type HeartbeatPacket = IPacket<typeof PacketId.HEARTBEAT, HeartbeatSchema>;
7
7
 
8
8
  export const heartbeatPacketDefinition = definePacket(
9
- PacketIds.HEARTBEAT,
9
+ PacketId.HEARTBEAT,
10
10
  heartbeatSchema
11
11
  );
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { inputSchema } from '../../schemas/Input';
4
- import type { Input } from '../../schemas/Input';
4
+ import type { InputSchema } from '../../schemas/Input';
5
5
 
6
- export type InputPacket = IPacket<typeof PacketIds.INPUT, Input>;
6
+ export type InputPacket = IPacket<typeof PacketId.INPUT, InputSchema>;
7
7
 
8
8
  export const inputPacketDefinition = definePacket(
9
- PacketIds.INPUT,
9
+ PacketId.INPUT,
10
10
  inputSchema
11
11
  );
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { blockSchema } from '../../schemas/Block';
4
- import type { Block } from '../../schemas/Block';
4
+ import type { BlockSchema } from '../../schemas/Block';
5
5
 
6
- export type BlockPacket = IPacket<typeof PacketIds.BLOCK, Block>;
6
+ export type BlockPacket = IPacket<typeof PacketId.BLOCK, BlockSchema>;
7
7
 
8
8
  export const blockPacketDefinition = definePacket(
9
- PacketIds.BLOCK,
9
+ PacketId.BLOCK,
10
10
  blockSchema,
11
11
  );
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { blockRegistrySchema } from '../../schemas/BlockRegistry';
4
- import type { BlockRegistry } from '../../schemas/BlockRegistry';
4
+ import type { BlockRegistrySchema } from '../../schemas/BlockRegistry';
5
5
 
6
- export type BlockRegistryPacket = IPacket<typeof PacketIds.BLOCK_REGISTRY, BlockRegistry>;
6
+ export type BlockRegistryPacket = IPacket<typeof PacketId.BLOCK_REGISTRY, BlockRegistrySchema>;
7
7
 
8
8
  export const blockRegistryPacketDefinition = definePacket(
9
- PacketIds.BLOCK_REGISTRY,
9
+ PacketId.BLOCK_REGISTRY,
10
10
  blockRegistrySchema,
11
11
  );
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { blockTypeSchema } from '../../schemas/BlockType';
4
- import type { BlockType } from '../../schemas/BlockType';
4
+ import type { BlockTypeSchema } from '../../schemas/BlockType';
5
5
 
6
- export type BlockTypePacket = IPacket<typeof PacketIds.BLOCK_TYPE, BlockType>;
6
+ export type BlockTypePacket = IPacket<typeof PacketId.BLOCK_TYPE, BlockTypeSchema>;
7
7
 
8
8
  export const blockTypePacketDefinition = definePacket(
9
- PacketIds.BLOCK_TYPE,
9
+ PacketId.BLOCK_TYPE,
10
10
  blockTypeSchema,
11
11
  );
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { chunkSchema } from '../../schemas/Chunk';
4
- import type { Chunk } from '../../schemas/Chunk';
4
+ import type { ChunkSchema } from '../../schemas/Chunk';
5
5
 
6
- export type ChunkPacket = IPacket<typeof PacketIds.CHUNK, Chunk>;
6
+ export type ChunkPacket = IPacket<typeof PacketId.CHUNK, ChunkSchema>;
7
7
 
8
8
  export const chunkPacketDefinition = definePacket(
9
- PacketIds.CHUNK,
9
+ PacketId.CHUNK,
10
10
  chunkSchema,
11
11
  );
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { entitySchema } from '../../schemas/Entity';
4
- import type { Entity } from '../../schemas/Entity';
4
+ import type { EntitySchema } from '../../schemas/Entity';
5
5
 
6
- export type EntityPacket = IPacket<typeof PacketIds.ENTITY, Entity>;
6
+ export type EntityPacket = IPacket<typeof PacketId.ENTITY, EntitySchema>;
7
7
 
8
8
  export const entityPacketDefinition = definePacket(
9
- PacketIds.ENTITY,
9
+ PacketId.ENTITY,
10
10
  entitySchema,
11
11
  );
@@ -1,11 +1,11 @@
1
- import { definePacket, PacketIds } from '../PacketCore';
1
+ import { definePacket, PacketId } from '../PacketCore';
2
2
  import type { IPacket } from '../PacketCore';
3
3
  import { physicsDebugRenderSchema } from '../../schemas/PhysicsDebugRender';
4
- import type { PhysicsDebugRender } from '../../schemas/PhysicsDebugRender';
4
+ import type { PhysicsDebugRenderSchema } from '../../schemas/PhysicsDebugRender';
5
5
 
6
- export type PhysicsDebugRenderPacket = IPacket<typeof PacketIds.PHYSICS_DEBUG_RENDER, PhysicsDebugRender>;
6
+ export type PhysicsDebugRenderPacket = IPacket<typeof PacketId.PHYSICS_DEBUG_RENDER, PhysicsDebugRenderSchema>;
7
7
 
8
8
  export const physicsDebugRenderPacketDefinition = definePacket(
9
- PacketIds.PHYSICS_DEBUG_RENDER,
9
+ PacketId.PHYSICS_DEBUG_RENDER,
10
10
  physicsDebugRenderSchema,
11
11
  );
package/schemas/Block.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { vectorSchema } from './Vector';
2
2
  import type { JSONSchemaType } from 'ajv';
3
- import type { Vector } from './Vector';
3
+ import type { VectorSchema } from './Vector';
4
4
 
5
- export type Block = {
6
- wi: string; // world id
7
- i: number; // block id
8
- c: Vector; // coordinate
5
+ export type BlockSchema = {
6
+ wi: string; // world id
7
+ i: number; // block id
8
+ c: VectorSchema; // coordinate
9
9
  };
10
10
 
11
- export const blockSchema: JSONSchemaType<Block> = {
11
+ export const blockSchema: JSONSchemaType<BlockSchema> = {
12
12
  type: 'object',
13
13
  properties: {
14
14
  wi: { type: 'string' },
@@ -1,13 +1,13 @@
1
1
  import { blockTypeSchema } from './BlockType';
2
2
  import type { JSONSchemaType } from 'ajv';
3
- import type { BlockType } from './BlockType';
3
+ import type { BlockTypeSchema } from './BlockType';
4
4
 
5
- export type BlockRegistry = {
6
- wi: string; // world id
7
- b: BlockType[]; // block types
5
+ export type BlockRegistrySchema = {
6
+ wi: string; // world id
7
+ b: BlockTypeSchema[]; // block types
8
8
  }
9
9
 
10
- export const blockRegistrySchema: JSONSchemaType<BlockRegistry> = {
10
+ export const blockRegistrySchema: JSONSchemaType<BlockRegistrySchema> = {
11
11
  type: 'object',
12
12
  properties: {
13
13
  wi: { type: 'string' },
@@ -1,18 +1,18 @@
1
1
  import { colliderDescSchema } from './ColliderDesc';
2
2
  import type { JSONSchemaType } from 'ajv';
3
- import type { ColliderDesc } from './ColliderDesc';
3
+ import type { ColliderDescSchema } from './ColliderDesc';
4
4
 
5
- export type BlockType = {
6
- wi: string; // world id
7
- i: number; // block type id
8
- d: boolean; // delta
9
- t?: string; // textureUri
10
- n?: string; // name
11
- c?: ColliderDesc; // collider desc
12
- s?: boolean; // is solid
5
+ export type BlockTypeSchema = {
6
+ wi: string; // world id
7
+ i: number; // block type id
8
+ d: boolean; // delta
9
+ t?: string; // textureUri
10
+ n?: string; // name
11
+ c?: ColliderDescSchema; // collider desc
12
+ s?: boolean; // is solid
13
13
  }
14
14
 
15
- export const blockTypeSchema: JSONSchemaType<BlockType> = {
15
+ export const blockTypeSchema: JSONSchemaType<BlockTypeSchema> = {
16
16
  type: 'object',
17
17
  properties: {
18
18
  wi: { type: 'string' },
package/schemas/Chunk.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { vectorSchema } from './Vector';
2
2
  import type { JSONSchemaType } from 'ajv';
3
- import type { Vector } from './Vector';
3
+ import type { VectorSchema } from './Vector';
4
4
 
5
- export type Chunk = {
6
- wi: string; // world id
7
- c: Vector; // chunk coordinate [ 16n, 16n, 16n ]
5
+ export type ChunkSchema = {
6
+ wi: string; // world id
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
  };
10
10
 
11
- export const chunkSchema: JSONSchemaType<Chunk> = {
11
+ export const chunkSchema: JSONSchemaType<ChunkSchema> = {
12
12
  type: 'object',
13
13
  properties: {
14
14
  wi: { type: 'string' },
@@ -1,12 +1,12 @@
1
1
  import { colliderDescSchema } from './ColliderDesc';
2
2
  import type { JSONSchemaType } from 'ajv';
3
- import type { ColliderDesc } from './ColliderDesc';
3
+ import type { ColliderDescSchema } from './ColliderDesc';
4
4
 
5
- export type Collider = {
5
+ export type ColliderSchema = {
6
6
  h?: number; // collider handle for rapier
7
- } & ColliderDesc;
7
+ } & ColliderDescSchema;
8
8
 
9
- export const colliderSchema: JSONSchemaType<Collider> = {
9
+ export const colliderSchema: JSONSchemaType<ColliderSchema> = {
10
10
  type: 'object',
11
11
  properties: {
12
12
  h: { type: 'number', nullable: true },
@@ -2,29 +2,29 @@ import { shapeSchema } from './Shape';
2
2
  import { quaternionSchema } from './Quaternion';
3
3
  import { vectorSchema } from './Vector';
4
4
  import type { JSONSchemaType } from 'ajv';
5
- import type { Shape } from './Shape';
6
- import type { Quaternion } from './Quaternion';
7
- import type { Vector } from './Vector';
5
+ import type { ShapeSchema } from './Shape';
6
+ import type { QuaternionSchema } from './Quaternion';
7
+ import type { VectorSchema } from './Vector';
8
8
 
9
- export type ColliderDesc = {
10
- at?: number; // active collision types
11
- cg?: number; // collision groups
12
- cs?: number; // contact skin
13
- d?: number; // density
14
- f?: number; // friction
15
- fr?: number; // friction combine rule
16
- en?: boolean; // enabled
17
- sn?: boolean; // sensor
18
- m?: number; // mass
19
- re?: number; // restitution
20
- rer?: number; // restitution combine rule
21
- r?: Quaternion; // rotation
22
- s?: Shape; // shape
23
- sg?: number; // solver groups
24
- t?: Vector; // translation
9
+ export type ColliderDescSchema = {
10
+ at?: number; // active collision types
11
+ cg?: number; // collision groups
12
+ cs?: number; // contact skin
13
+ d?: number; // density
14
+ f?: number; // friction
15
+ fr?: number; // friction combine rule
16
+ en?: boolean; // enabled
17
+ sn?: boolean; // sensor
18
+ m?: number; // mass
19
+ re?: number; // restitution
20
+ rer?: number; // restitution combine rule
21
+ r?: QuaternionSchema; // rotation
22
+ s?: ShapeSchema; // shape
23
+ sg?: number; // solver groups
24
+ t?: VectorSchema; // translation
25
25
  }
26
26
 
27
- export const colliderDescSchema: JSONSchemaType<ColliderDesc> = {
27
+ export const colliderDescSchema: JSONSchemaType<ColliderDescSchema> = {
28
28
  type: 'object',
29
29
  properties: {
30
30
  at: { type: 'number', nullable: true },
package/schemas/Entity.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { rigidBodySchema } from './RigidBody';
2
2
  import type { JSONSchemaType } from 'ajv';
3
- import type { RigidBody } from './RigidBody';
3
+ import type { RigidBodySchema } from './RigidBody';
4
4
 
5
- export type Entity = {
6
- wi: string; // world id
7
- i: number; // entity id
8
- d: boolean; // delta
9
- f?: boolean; // focused
10
- n?: string; // name
11
- m?: string; // model uri
12
- t?: string; // texture uri
13
- r?: RigidBody; // rigid body
5
+ export type EntitySchema = {
6
+ wi: string; // world id
7
+ i: number; // entity id
8
+ d: boolean; // delta
9
+ f?: boolean; // focused
10
+ n?: string; // name
11
+ m?: string; // model uri
12
+ t?: string; // texture uri
13
+ r?: RigidBodySchema; // rigid body
14
14
  }
15
15
 
16
- export const entitySchema: JSONSchemaType<Entity> = {
16
+ export const entitySchema: JSONSchemaType<EntitySchema> = {
17
17
  type: 'object',
18
18
  properties: {
19
19
  wi: { type: 'string' },
@@ -1,8 +1,8 @@
1
1
  import type { JSONSchemaType } from 'ajv';
2
2
 
3
- export type Heartbeat = null;
3
+ export type HeartbeatSchema = null;
4
4
 
5
- export const heartbeatSchema: JSONSchemaType<Heartbeat> = {
5
+ export const heartbeatSchema: JSONSchemaType<HeartbeatSchema> = {
6
6
  type: 'null',
7
7
  nullable: true,
8
8
  }
package/schemas/Input.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
 
3
- export type Input = {
3
+ export type InputSchema = {
4
4
  w?: boolean; // w key pressed
5
5
  a?: boolean; // a key pressed
6
6
  s?: boolean; // s key pressed
@@ -15,7 +15,7 @@ export type Input = {
15
15
  cy?: number; // camera yaw radians
16
16
  }
17
17
 
18
- export const inputSchema: JSONSchemaType<Input> = {
18
+ export const inputSchema: JSONSchemaType<InputSchema> = {
19
19
  type: 'object',
20
20
  properties: {
21
21
  w: { type: 'boolean', nullable: true },
@@ -1,12 +1,12 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
 
3
- export type PhysicsDebugRender = {
3
+ export type PhysicsDebugRenderSchema = {
4
4
  wi: string; // world id
5
5
  v: number[]; // rapier debug render vertices
6
6
  c: number[]; // rapier debug render colors
7
7
  }
8
8
 
9
- export const physicsDebugRenderSchema: JSONSchemaType<PhysicsDebugRender> = {
9
+ export const physicsDebugRenderSchema: JSONSchemaType<PhysicsDebugRenderSchema> = {
10
10
  type: 'object',
11
11
  properties: {
12
12
  wi: { type: 'string' },
@@ -1,13 +1,13 @@
1
1
  import type { JSONSchemaType } from 'ajv';
2
2
 
3
- export type Quaternion = [
3
+ export type QuaternionSchema = [
4
4
  number, // x
5
5
  number, // y
6
6
  number, // z
7
7
  number, // w
8
8
  ];
9
9
 
10
- export const quaternionSchema: JSONSchemaType<Quaternion> = {
10
+ export const quaternionSchema: JSONSchemaType<QuaternionSchema> = {
11
11
  type: 'array',
12
12
  items: [
13
13
  { type: 'number' },
@@ -1,15 +1,15 @@
1
1
  import { rigidBodyDescSchema } from './RigidBodyDesc';
2
2
  import type { JSONSchemaType } from 'ajv';
3
- import { RigidBodyDesc } from './RigidBodyDesc';
3
+ import { RigidBodyDescSchema } from './RigidBodyDesc';
4
4
 
5
- export type RigidBody = {
5
+ export type RigidBodySchema = {
6
6
  h?: number; // rigid body handle for rapier
7
- } & RigidBodyDesc;
7
+ } & RigidBodyDescSchema;
8
8
 
9
- export const rigidBodySchema: JSONSchemaType<RigidBody> = {
9
+ export const rigidBodySchema: JSONSchemaType<RigidBodySchema> = {
10
10
  type: 'object',
11
11
  properties: {
12
- handle: { type: 'number', nullable: true },
12
+ h: { type: 'number', nullable: true },
13
13
  ...rigidBodyDescSchema.properties,
14
14
  },
15
15
  additionalProperties: false,
@@ -2,29 +2,29 @@ import { colliderSchema } from './Collider';
2
2
  import { vectorSchema } from './Vector';
3
3
  import { vectorBooleanSchema } from './VectorBoolean'
4
4
  import type { JSONSchemaType } from 'ajv';
5
- import type { Collider } from './Collider';
6
- import type { Vector } from './Vector';
7
- import type { VectorBoolean } from './VectorBoolean';
5
+ import type { ColliderSchema } from './Collider';
6
+ import type { VectorSchema } from './Vector';
7
+ import type { VectorBooleanSchema } from './VectorBoolean';
8
8
 
9
- export type RigidBodyDesc = {
10
- ad?: number; // angular dampening
11
- av?: Vector; // angular velocity
12
- b?: number; // body type
13
- c?: Collider[]; // colliders
14
- d?: number; // dominance group
15
- ce?: boolean; // ccd enabled
16
- en?: boolean; // enabled
17
- er?: VectorBoolean; // enabled rotations
18
- et?: VectorBoolean; // enabled translations
19
- g?: number; // gravity scaling
20
- ld?: number; // linear damping
21
- lv?: Vector; // linear velocity
22
- sl?: boolean; // sleeping
23
- scp?: number; // soft ccd prediction
24
- t?: Vector; // translation
9
+ export type RigidBodyDescSchema = {
10
+ ad?: number; // angular dampening
11
+ av?: VectorSchema; // angular velocity
12
+ b?: number; // body type
13
+ c?: ColliderSchema[]; // colliders
14
+ d?: number; // dominance group
15
+ ce?: boolean; // ccd enabled
16
+ en?: boolean; // enabled
17
+ er?: VectorBooleanSchema; // enabled rotations
18
+ et?: VectorBooleanSchema; // enabled translations
19
+ g?: number; // gravity scaling
20
+ ld?: number; // linear damping
21
+ lv?: VectorSchema; // linear velocity
22
+ sl?: boolean; // sleeping
23
+ scp?: number; // soft ccd prediction
24
+ t?: VectorSchema; // translation
25
25
  }
26
26
 
27
- export const rigidBodyDescSchema: JSONSchemaType<RigidBodyDesc> = {
27
+ export const rigidBodyDescSchema: JSONSchemaType<RigidBodyDescSchema> = {
28
28
  type: 'object',
29
29
  properties: {
30
30
  ad: { type: 'number', nullable: true },
package/schemas/Shape.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
  import { vectorSchema } from './Vector';
3
- import type { Vector } from './Vector';
3
+ import type { VectorSchema } from './Vector';
4
4
 
5
- export type Shape = {
6
- t?: number; // type
7
- b?: number; // border radius
8
- r?: number; // radius
9
- hx?: Vector; // half extends
10
- hh?: number; // half height
5
+ export type ShapeSchema = {
6
+ t?: number; // type
7
+ b?: number; // border radius
8
+ r?: number; // radius
9
+ hx?: VectorSchema; // half extends
10
+ hh?: number; // half height
11
11
  }
12
12
 
13
- export const shapeSchema: JSONSchemaType<Shape> = {
13
+ export const shapeSchema: JSONSchemaType<ShapeSchema> = {
14
14
  type: 'object',
15
15
  properties: {
16
16
  t: { type: 'number', nullable: true },
package/schemas/Vector.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { JSONSchemaType } from 'ajv';
2
2
 
3
- export type Vector = [
3
+ export type VectorSchema = [
4
4
  number, // x
5
5
  number, // y
6
6
  number, // z
7
7
  ];
8
8
 
9
- export const vectorSchema: JSONSchemaType<Vector> = {
9
+ export const vectorSchema: JSONSchemaType<VectorSchema> = {
10
10
  type: 'array',
11
11
  items: [
12
12
  { type: 'number' },
@@ -1,12 +1,12 @@
1
1
  import { JSONSchemaType } from 'ajv';
2
2
 
3
- export type VectorBoolean = [
3
+ export type VectorBooleanSchema = [
4
4
  boolean, // x
5
5
  boolean, // y
6
6
  boolean, // z
7
7
  ];
8
8
 
9
- export const vectorBooleanSchema: JSONSchemaType<VectorBoolean> = {
9
+ export const vectorBooleanSchema: JSONSchemaType<VectorBooleanSchema> = {
10
10
  type: 'array',
11
11
  items: [
12
12
  { type: 'boolean' },