@4players/odin-common 2.19.1 → 3.0.0
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/lib/cjs/index.js +1 -0
- package/lib/cjs/rpc/commands.js +1 -1
- package/lib/cjs/rpc/notifications.js +4 -4
- package/lib/cjs/schema/channels.js +44 -0
- package/lib/cjs/schema/room.js +130 -40
- package/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/cjs/utility/msgpack.js +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/rpc/commands.js +2 -2
- package/lib/esm/rpc/notifications.js +5 -5
- package/lib/esm/schema/channels.js +40 -0
- package/lib/esm/schema/room.js +130 -40
- package/lib/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/esm/utility/msgpack.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/plugin/api.d.ts +3 -2
- package/lib/rpc/commands.d.ts +6 -6
- package/lib/schema/channels.d.ts +11 -0
- package/lib/schema/room.d.ts +1108 -488
- package/package.json +3 -3
package/lib/cjs/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __exportStar(require("./schema/peer"), exports);
|
|
|
23
23
|
__exportStar(require("./schema/media"), exports);
|
|
24
24
|
__exportStar(require("./schema/message"), exports);
|
|
25
25
|
__exportStar(require("./schema/webrtc"), exports);
|
|
26
|
+
__exportStar(require("./schema/channels"), exports);
|
|
26
27
|
__exportStar(require("./rpc/commands"), exports);
|
|
27
28
|
__exportStar(require("./rpc/notifications"), exports);
|
|
28
29
|
__exportStar(require("./utility/base64"), exports);
|
package/lib/cjs/rpc/commands.js
CHANGED
|
@@ -17,7 +17,7 @@ exports.MainCommandsRpc = {
|
|
|
17
17
|
JoinRoom: {
|
|
18
18
|
request: zod_1.z.object({
|
|
19
19
|
token: zod_1.z.string(),
|
|
20
|
-
room_id: room_1.RoomIdSchema,
|
|
20
|
+
room_id: room_1.RoomV1.RoomIdSchema,
|
|
21
21
|
user_data: serialization_1.ByteArraySchema,
|
|
22
22
|
position: peer_1.PeerPositionSchema,
|
|
23
23
|
}),
|
|
@@ -16,11 +16,11 @@ exports.MainNotificationsRpc = {
|
|
|
16
16
|
exports.RoomNotificationSchema = z.union([
|
|
17
17
|
z.object({
|
|
18
18
|
name: z.literal('RoomStatusChanged'),
|
|
19
|
-
properties: room_1.RoomStatusChangedSchema,
|
|
19
|
+
properties: room_1.RoomV1.RoomStatusChangedSchema,
|
|
20
20
|
}),
|
|
21
21
|
z.object({
|
|
22
22
|
name: z.literal('RoomUpdated'),
|
|
23
|
-
properties: room_1.RoomUpdatesSchema,
|
|
23
|
+
properties: room_1.RoomV1.RoomUpdatesSchema,
|
|
24
24
|
}),
|
|
25
25
|
z.object({
|
|
26
26
|
name: z.literal('PeerUpdated'),
|
|
@@ -32,8 +32,8 @@ exports.RoomNotificationSchema = z.union([
|
|
|
32
32
|
}),
|
|
33
33
|
]);
|
|
34
34
|
exports.RoomNotificationsRpc = {
|
|
35
|
-
RoomStatusChanged: room_1.RoomStatusChangedSchema,
|
|
36
|
-
RoomUpdated: room_1.RoomUpdatesSchema,
|
|
35
|
+
RoomStatusChanged: room_1.RoomV1.RoomStatusChangedSchema,
|
|
36
|
+
RoomUpdated: room_1.RoomV1.RoomUpdatesSchema,
|
|
37
37
|
PeerUpdated: peer_1.PeerUpdateSchema,
|
|
38
38
|
MessageReceived: message_1.MessageReceivedSchema,
|
|
39
39
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChannelSetSchema = exports.ChannelSet = void 0;
|
|
4
|
+
const z = require("zod");
|
|
5
|
+
class ChannelSet {
|
|
6
|
+
constructor(value = BigInt(0)) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
}
|
|
9
|
+
from(...channels) {
|
|
10
|
+
const value = channels.reduce((value, channel) => value | channel_mask(channel), BigInt(0));
|
|
11
|
+
return new ChannelSet(value);
|
|
12
|
+
}
|
|
13
|
+
contains(channel) {
|
|
14
|
+
return (this.value & channel_mask(channel)) !== BigInt(0);
|
|
15
|
+
}
|
|
16
|
+
insert(channel) {
|
|
17
|
+
this.value |= channel_mask(channel);
|
|
18
|
+
}
|
|
19
|
+
remove(channel) {
|
|
20
|
+
this.value &= ~channel_mask(channel);
|
|
21
|
+
}
|
|
22
|
+
[Symbol.iterator]() {
|
|
23
|
+
let channel = -1;
|
|
24
|
+
const self = new ChannelSet(this.value);
|
|
25
|
+
return {
|
|
26
|
+
next() {
|
|
27
|
+
while (channel < 63) {
|
|
28
|
+
channel += 1;
|
|
29
|
+
if (self.contains(channel)) {
|
|
30
|
+
return { value: channel, done: false };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { value: undefined, done: true };
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ChannelSet = ChannelSet;
|
|
39
|
+
exports.ChannelSetSchema = z
|
|
40
|
+
.bigint()
|
|
41
|
+
.transform((number) => new ChannelSet(number));
|
|
42
|
+
function channel_mask(channel) {
|
|
43
|
+
return BigInt(1) << BigInt(channel);
|
|
44
|
+
}
|
package/lib/cjs/schema/room.js
CHANGED
|
@@ -1,46 +1,136 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RoomV2 = exports.RoomV1 = void 0;
|
|
4
4
|
const z = require("zod");
|
|
5
5
|
const media_1 = require("./media");
|
|
6
6
|
const peer_1 = require("./peer");
|
|
7
7
|
const serialization_1 = require("./serialization");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
8
|
+
const channels_1 = require("./channels");
|
|
9
|
+
var RoomV1;
|
|
10
|
+
(function (RoomV1) {
|
|
11
|
+
RoomV1.RoomIdSchema = z.string();
|
|
12
|
+
RoomV1.RoomSchema = z.object({
|
|
13
|
+
id: RoomV1.RoomIdSchema,
|
|
14
|
+
customer: z.string(),
|
|
15
|
+
user_data: serialization_1.ByteArraySchema,
|
|
16
|
+
peers: z.array(peer_1.PeerSchema),
|
|
17
|
+
});
|
|
18
|
+
RoomV1.RoomUpdateSchema = z.discriminatedUnion('kind', [
|
|
19
|
+
z.object({
|
|
20
|
+
kind: z.literal('Joined'),
|
|
21
|
+
room: RoomV1.RoomSchema,
|
|
22
|
+
media_ids: z.array(media_1.MediaIdSchema),
|
|
23
|
+
own_peer_id: peer_1.PeerIdSchema,
|
|
24
|
+
}),
|
|
25
|
+
z.object({
|
|
26
|
+
kind: z.literal('Left'),
|
|
27
|
+
reason: z.enum(['RoomClosing', 'ServerClosing', 'PeerKicked']),
|
|
28
|
+
}),
|
|
29
|
+
z.object({
|
|
30
|
+
kind: z.literal('UserDataChanged'),
|
|
31
|
+
user_data: z.optional(serialization_1.ByteArraySchema),
|
|
32
|
+
}),
|
|
33
|
+
z.object({
|
|
34
|
+
kind: z.literal('PeerJoined'),
|
|
35
|
+
peer: peer_1.PeerSchema,
|
|
36
|
+
}),
|
|
37
|
+
z.object({
|
|
38
|
+
kind: z.literal('PeerLeft'),
|
|
39
|
+
peer_id: peer_1.PeerIdSchema,
|
|
40
|
+
}),
|
|
41
|
+
]);
|
|
42
|
+
RoomV1.RoomUpdatesSchema = z.object({
|
|
43
|
+
updates: z.array(RoomV1.RoomUpdateSchema),
|
|
44
|
+
});
|
|
45
|
+
RoomV1.RoomStatusSchema = z.enum(['Joining', 'Joined', 'Closed']);
|
|
46
|
+
RoomV1.RoomStatusChangedSchema = z.object({
|
|
47
|
+
status: RoomV1.RoomStatusSchema,
|
|
48
|
+
message: z.optional(z.string()),
|
|
49
|
+
});
|
|
50
|
+
})(RoomV1 || (exports.RoomV1 = RoomV1 = {}));
|
|
51
|
+
var RoomV2;
|
|
52
|
+
(function (RoomV2) {
|
|
53
|
+
RoomV2.ParametersSchema = z.record(serialization_1.JsonSchema);
|
|
54
|
+
RoomV2.PeerProperties = z.object({
|
|
55
|
+
user_data: serialization_1.ByteArraySchema.optional(),
|
|
56
|
+
tags: z.array(z.string()).optional(),
|
|
57
|
+
audio_parameters: RoomV2.ParametersSchema.optional(),
|
|
58
|
+
video_parameters: RoomV2.ParametersSchema.optional(),
|
|
59
|
+
});
|
|
60
|
+
RoomV2.PingSchema = z.object({
|
|
61
|
+
Ping: z.object({ id: z.number() }),
|
|
62
|
+
});
|
|
63
|
+
RoomV2.ChangeSelfSchema = z.object({
|
|
64
|
+
ChangeSelf: RoomV2.PeerProperties.omit({ tags: true }),
|
|
65
|
+
});
|
|
66
|
+
RoomV2.SetAudioMaskSchema = z.object({
|
|
67
|
+
SetAudioMask: z.object({
|
|
68
|
+
peer_id: z.number(),
|
|
69
|
+
mask: channels_1.ChannelSetSchema,
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
RoomV2.SendMessageSchema = z.object({
|
|
73
|
+
SendMessage: z.object({
|
|
74
|
+
peer_ids: z.number().array().default([]),
|
|
75
|
+
message: serialization_1.ByteArraySchema,
|
|
76
|
+
}),
|
|
77
|
+
});
|
|
78
|
+
RoomV2.CallSchema = RoomV2.PingSchema.or(RoomV2.ChangeSelfSchema)
|
|
79
|
+
.or(RoomV2.SetAudioMaskSchema)
|
|
80
|
+
.or(RoomV2.SendMessageSchema);
|
|
81
|
+
RoomV2.PongSchema = z.object({
|
|
82
|
+
Pong: z.object({ id: z.number() }),
|
|
83
|
+
});
|
|
84
|
+
RoomV2.JoinedSchema = z.object({
|
|
85
|
+
Joined: z.object({
|
|
86
|
+
own_peer_id: z.number(),
|
|
87
|
+
room_id: z.string(),
|
|
88
|
+
customer: z.string(),
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
RoomV2.LeftSchema = z.object({
|
|
92
|
+
Left: z.object({
|
|
93
|
+
reason: z.enum(['room_closing', 'server_closing', 'peer_kicked']),
|
|
94
|
+
}),
|
|
95
|
+
});
|
|
96
|
+
RoomV2.PeerJoinedSchema = z.object({
|
|
97
|
+
PeerJoined: RoomV2.PeerProperties.extend({
|
|
98
|
+
peer_id: z.number(),
|
|
99
|
+
user_id: z.string(),
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
RoomV2.PeerLeftSchema = z.object({
|
|
103
|
+
PeerLeft: z.object({
|
|
104
|
+
peer_id: z.number(),
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
RoomV2.PeerChangedSchema = z.object({
|
|
108
|
+
PeerChanged: RoomV2.PeerProperties.extend({
|
|
109
|
+
peer_id: z.number(),
|
|
110
|
+
}),
|
|
111
|
+
});
|
|
112
|
+
RoomV2.NewReconnectTokenSchema = z.object({
|
|
113
|
+
NewReconnectToken: z.object({
|
|
114
|
+
token: z.string(),
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
RoomV2.MessageReceivedSchema = z.object({
|
|
118
|
+
MessageReceived: z.object({
|
|
119
|
+
sender_peer_id: z.number(),
|
|
120
|
+
message: serialization_1.ByteArraySchema,
|
|
121
|
+
}),
|
|
122
|
+
});
|
|
123
|
+
RoomV2.ErrorSchema = z.object({
|
|
124
|
+
Error: z.object({
|
|
125
|
+
message: serialization_1.ByteArraySchema,
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
RoomV2.EventSchema = RoomV2.PongSchema.or(RoomV2.JoinedSchema)
|
|
129
|
+
.or(RoomV2.LeftSchema)
|
|
130
|
+
.or(RoomV2.PeerJoinedSchema)
|
|
131
|
+
.or(RoomV2.PeerLeftSchema)
|
|
132
|
+
.or(RoomV2.PeerChangedSchema)
|
|
133
|
+
.or(RoomV2.NewReconnectTokenSchema)
|
|
134
|
+
.or(RoomV2.MessageReceivedSchema)
|
|
135
|
+
.or(RoomV2.ErrorSchema);
|
|
136
|
+
})(RoomV2 || (exports.RoomV2 = RoomV2 = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/codec.spec.ts","../../src/utility/codec.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.6.3"}
|
|
1
|
+
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/channels.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/codec.spec.ts","../../src/utility/codec.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.6.3"}
|
|
@@ -4,7 +4,7 @@ exports.msgpackEncode = msgpackEncode;
|
|
|
4
4
|
exports.msgpackDecode = msgpackDecode;
|
|
5
5
|
const msgpack_1 = require("@msgpack/msgpack");
|
|
6
6
|
function msgpackEncode(value) {
|
|
7
|
-
return (0, msgpack_1.encode)(value);
|
|
7
|
+
return (0, msgpack_1.encode)(value, { forceFloat32: true, ignoreUndefined: true });
|
|
8
8
|
}
|
|
9
9
|
function msgpackDecode(buffer) {
|
|
10
10
|
return (0, msgpack_1.decode)(buffer);
|
package/lib/esm/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from './schema/peer';
|
|
|
6
6
|
export * from './schema/media';
|
|
7
7
|
export * from './schema/message';
|
|
8
8
|
export * from './schema/webrtc';
|
|
9
|
+
export * from './schema/channels';
|
|
9
10
|
export * from './rpc/commands';
|
|
10
11
|
export * from './rpc/notifications';
|
|
11
12
|
export * from './utility/base64';
|
package/lib/esm/rpc/commands.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ByteArraySchema } from '../schema/serialization';
|
|
3
|
-
import {
|
|
3
|
+
import { RoomV1 } from '../schema/room';
|
|
4
4
|
import { PeerIdSchema, PeerPositionSchema } from '../schema/peer';
|
|
5
5
|
import { MediaIdSchema, MediaPropertiesSchema } from '../schema/media';
|
|
6
6
|
import { WebRtcUpdateSchema } from '../schema/webrtc';
|
|
@@ -14,7 +14,7 @@ export const MainCommandsRpc = {
|
|
|
14
14
|
JoinRoom: {
|
|
15
15
|
request: z.object({
|
|
16
16
|
token: z.string(),
|
|
17
|
-
room_id: RoomIdSchema,
|
|
17
|
+
room_id: RoomV1.RoomIdSchema,
|
|
18
18
|
user_data: ByteArraySchema,
|
|
19
19
|
position: PeerPositionSchema,
|
|
20
20
|
}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
-
import {
|
|
2
|
+
import { RoomV1 } from '../schema/room';
|
|
3
3
|
import { PeerUpdateSchema } from '../schema/peer';
|
|
4
4
|
import { MessageReceivedSchema } from '../schema/message';
|
|
5
5
|
import { WebRtcUpdateSchema } from '../schema/webrtc';
|
|
@@ -13,11 +13,11 @@ export const MainNotificationsRpc = {
|
|
|
13
13
|
export const RoomNotificationSchema = z.union([
|
|
14
14
|
z.object({
|
|
15
15
|
name: z.literal('RoomStatusChanged'),
|
|
16
|
-
properties: RoomStatusChangedSchema,
|
|
16
|
+
properties: RoomV1.RoomStatusChangedSchema,
|
|
17
17
|
}),
|
|
18
18
|
z.object({
|
|
19
19
|
name: z.literal('RoomUpdated'),
|
|
20
|
-
properties: RoomUpdatesSchema,
|
|
20
|
+
properties: RoomV1.RoomUpdatesSchema,
|
|
21
21
|
}),
|
|
22
22
|
z.object({
|
|
23
23
|
name: z.literal('PeerUpdated'),
|
|
@@ -29,8 +29,8 @@ export const RoomNotificationSchema = z.union([
|
|
|
29
29
|
}),
|
|
30
30
|
]);
|
|
31
31
|
export const RoomNotificationsRpc = {
|
|
32
|
-
RoomStatusChanged: RoomStatusChangedSchema,
|
|
33
|
-
RoomUpdated: RoomUpdatesSchema,
|
|
32
|
+
RoomStatusChanged: RoomV1.RoomStatusChangedSchema,
|
|
33
|
+
RoomUpdated: RoomV1.RoomUpdatesSchema,
|
|
34
34
|
PeerUpdated: PeerUpdateSchema,
|
|
35
35
|
MessageReceived: MessageReceivedSchema,
|
|
36
36
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export class ChannelSet {
|
|
3
|
+
constructor(value = BigInt(0)) {
|
|
4
|
+
this.value = value;
|
|
5
|
+
}
|
|
6
|
+
from(...channels) {
|
|
7
|
+
const value = channels.reduce((value, channel) => value | channel_mask(channel), BigInt(0));
|
|
8
|
+
return new ChannelSet(value);
|
|
9
|
+
}
|
|
10
|
+
contains(channel) {
|
|
11
|
+
return (this.value & channel_mask(channel)) !== BigInt(0);
|
|
12
|
+
}
|
|
13
|
+
insert(channel) {
|
|
14
|
+
this.value |= channel_mask(channel);
|
|
15
|
+
}
|
|
16
|
+
remove(channel) {
|
|
17
|
+
this.value &= ~channel_mask(channel);
|
|
18
|
+
}
|
|
19
|
+
[Symbol.iterator]() {
|
|
20
|
+
let channel = -1;
|
|
21
|
+
const self = new ChannelSet(this.value);
|
|
22
|
+
return {
|
|
23
|
+
next() {
|
|
24
|
+
while (channel < 63) {
|
|
25
|
+
channel += 1;
|
|
26
|
+
if (self.contains(channel)) {
|
|
27
|
+
return { value: channel, done: false };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return { value: undefined, done: true };
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const ChannelSetSchema = z
|
|
36
|
+
.bigint()
|
|
37
|
+
.transform((number) => new ChannelSet(number));
|
|
38
|
+
function channel_mask(channel) {
|
|
39
|
+
return BigInt(1) << BigInt(channel);
|
|
40
|
+
}
|
package/lib/esm/schema/room.js
CHANGED
|
@@ -1,43 +1,133 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { MediaIdSchema } from './media';
|
|
3
3
|
import { PeerIdSchema, PeerSchema } from './peer';
|
|
4
|
-
import { ByteArraySchema } from './serialization';
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
4
|
+
import { ByteArraySchema, JsonSchema } from './serialization';
|
|
5
|
+
import { ChannelSetSchema } from './channels';
|
|
6
|
+
export var RoomV1;
|
|
7
|
+
(function (RoomV1) {
|
|
8
|
+
RoomV1.RoomIdSchema = z.string();
|
|
9
|
+
RoomV1.RoomSchema = z.object({
|
|
10
|
+
id: RoomV1.RoomIdSchema,
|
|
11
|
+
customer: z.string(),
|
|
12
|
+
user_data: ByteArraySchema,
|
|
13
|
+
peers: z.array(PeerSchema),
|
|
14
|
+
});
|
|
15
|
+
RoomV1.RoomUpdateSchema = z.discriminatedUnion('kind', [
|
|
16
|
+
z.object({
|
|
17
|
+
kind: z.literal('Joined'),
|
|
18
|
+
room: RoomV1.RoomSchema,
|
|
19
|
+
media_ids: z.array(MediaIdSchema),
|
|
20
|
+
own_peer_id: PeerIdSchema,
|
|
21
|
+
}),
|
|
22
|
+
z.object({
|
|
23
|
+
kind: z.literal('Left'),
|
|
24
|
+
reason: z.enum(['RoomClosing', 'ServerClosing', 'PeerKicked']),
|
|
25
|
+
}),
|
|
26
|
+
z.object({
|
|
27
|
+
kind: z.literal('UserDataChanged'),
|
|
28
|
+
user_data: z.optional(ByteArraySchema),
|
|
29
|
+
}),
|
|
30
|
+
z.object({
|
|
31
|
+
kind: z.literal('PeerJoined'),
|
|
32
|
+
peer: PeerSchema,
|
|
33
|
+
}),
|
|
34
|
+
z.object({
|
|
35
|
+
kind: z.literal('PeerLeft'),
|
|
36
|
+
peer_id: PeerIdSchema,
|
|
37
|
+
}),
|
|
38
|
+
]);
|
|
39
|
+
RoomV1.RoomUpdatesSchema = z.object({
|
|
40
|
+
updates: z.array(RoomV1.RoomUpdateSchema),
|
|
41
|
+
});
|
|
42
|
+
RoomV1.RoomStatusSchema = z.enum(['Joining', 'Joined', 'Closed']);
|
|
43
|
+
RoomV1.RoomStatusChangedSchema = z.object({
|
|
44
|
+
status: RoomV1.RoomStatusSchema,
|
|
45
|
+
message: z.optional(z.string()),
|
|
46
|
+
});
|
|
47
|
+
})(RoomV1 || (RoomV1 = {}));
|
|
48
|
+
export var RoomV2;
|
|
49
|
+
(function (RoomV2) {
|
|
50
|
+
RoomV2.ParametersSchema = z.record(JsonSchema);
|
|
51
|
+
RoomV2.PeerProperties = z.object({
|
|
52
|
+
user_data: ByteArraySchema.optional(),
|
|
53
|
+
tags: z.array(z.string()).optional(),
|
|
54
|
+
audio_parameters: RoomV2.ParametersSchema.optional(),
|
|
55
|
+
video_parameters: RoomV2.ParametersSchema.optional(),
|
|
56
|
+
});
|
|
57
|
+
RoomV2.PingSchema = z.object({
|
|
58
|
+
Ping: z.object({ id: z.number() }),
|
|
59
|
+
});
|
|
60
|
+
RoomV2.ChangeSelfSchema = z.object({
|
|
61
|
+
ChangeSelf: RoomV2.PeerProperties.omit({ tags: true }),
|
|
62
|
+
});
|
|
63
|
+
RoomV2.SetAudioMaskSchema = z.object({
|
|
64
|
+
SetAudioMask: z.object({
|
|
65
|
+
peer_id: z.number(),
|
|
66
|
+
mask: ChannelSetSchema,
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
RoomV2.SendMessageSchema = z.object({
|
|
70
|
+
SendMessage: z.object({
|
|
71
|
+
peer_ids: z.number().array().default([]),
|
|
72
|
+
message: ByteArraySchema,
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
RoomV2.CallSchema = RoomV2.PingSchema.or(RoomV2.ChangeSelfSchema)
|
|
76
|
+
.or(RoomV2.SetAudioMaskSchema)
|
|
77
|
+
.or(RoomV2.SendMessageSchema);
|
|
78
|
+
RoomV2.PongSchema = z.object({
|
|
79
|
+
Pong: z.object({ id: z.number() }),
|
|
80
|
+
});
|
|
81
|
+
RoomV2.JoinedSchema = z.object({
|
|
82
|
+
Joined: z.object({
|
|
83
|
+
own_peer_id: z.number(),
|
|
84
|
+
room_id: z.string(),
|
|
85
|
+
customer: z.string(),
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
RoomV2.LeftSchema = z.object({
|
|
89
|
+
Left: z.object({
|
|
90
|
+
reason: z.enum(['room_closing', 'server_closing', 'peer_kicked']),
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
RoomV2.PeerJoinedSchema = z.object({
|
|
94
|
+
PeerJoined: RoomV2.PeerProperties.extend({
|
|
95
|
+
peer_id: z.number(),
|
|
96
|
+
user_id: z.string(),
|
|
97
|
+
}),
|
|
98
|
+
});
|
|
99
|
+
RoomV2.PeerLeftSchema = z.object({
|
|
100
|
+
PeerLeft: z.object({
|
|
101
|
+
peer_id: z.number(),
|
|
102
|
+
}),
|
|
103
|
+
});
|
|
104
|
+
RoomV2.PeerChangedSchema = z.object({
|
|
105
|
+
PeerChanged: RoomV2.PeerProperties.extend({
|
|
106
|
+
peer_id: z.number(),
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
RoomV2.NewReconnectTokenSchema = z.object({
|
|
110
|
+
NewReconnectToken: z.object({
|
|
111
|
+
token: z.string(),
|
|
112
|
+
}),
|
|
113
|
+
});
|
|
114
|
+
RoomV2.MessageReceivedSchema = z.object({
|
|
115
|
+
MessageReceived: z.object({
|
|
116
|
+
sender_peer_id: z.number(),
|
|
117
|
+
message: ByteArraySchema,
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
RoomV2.ErrorSchema = z.object({
|
|
121
|
+
Error: z.object({
|
|
122
|
+
message: ByteArraySchema,
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
RoomV2.EventSchema = RoomV2.PongSchema.or(RoomV2.JoinedSchema)
|
|
126
|
+
.or(RoomV2.LeftSchema)
|
|
127
|
+
.or(RoomV2.PeerJoinedSchema)
|
|
128
|
+
.or(RoomV2.PeerLeftSchema)
|
|
129
|
+
.or(RoomV2.PeerChangedSchema)
|
|
130
|
+
.or(RoomV2.NewReconnectTokenSchema)
|
|
131
|
+
.or(RoomV2.MessageReceivedSchema)
|
|
132
|
+
.or(RoomV2.ErrorSchema);
|
|
133
|
+
})(RoomV2 || (RoomV2 = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/codec.spec.ts","../../src/utility/codec.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.6.3"}
|
|
1
|
+
{"root":["../../src/index.ts","../../src/plugin/api.ts","../../src/rpc/commands.ts","../../src/rpc/notifications.ts","../../src/schema/channels.ts","../../src/schema/media.ts","../../src/schema/message.ts","../../src/schema/peer.ts","../../src/schema/room.ts","../../src/schema/serialization.ts","../../src/schema/token.ts","../../src/schema/webrtc.ts","../../src/utility/base64.spec.ts","../../src/utility/base64.ts","../../src/utility/bytearray.spec.ts","../../src/utility/bytearray.ts","../../src/utility/codec.spec.ts","../../src/utility/codec.ts","../../src/utility/environment.spec.ts","../../src/utility/environment.ts","../../src/utility/iterable.spec.ts","../../src/utility/iterable.ts","../../src/utility/json.spec.ts","../../src/utility/json.ts","../../src/utility/log.spec.ts","../../src/utility/log.ts","../../src/utility/msgpack.spec.ts","../../src/utility/msgpack.ts","../../src/utility/result.spec.ts","../../src/utility/result.ts","../../src/utility/selector.spec.ts","../../src/utility/selector.ts","../../src/utility/sleep.spec.ts","../../src/utility/sleep.ts","../../src/utility/strand.spec.ts","../../src/utility/strand.ts","../../src/utility/url.spec.ts","../../src/utility/url.ts","../../src/utility/uuid.spec.ts","../../src/utility/uuid.ts","../../src/utility/validation.spec.ts","../../src/utility/validation.ts"],"version":"5.6.3"}
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './schema/peer';
|
|
|
6
6
|
export * from './schema/media';
|
|
7
7
|
export * from './schema/message';
|
|
8
8
|
export * from './schema/webrtc';
|
|
9
|
+
export * from './schema/channels';
|
|
9
10
|
export * from './rpc/commands';
|
|
10
11
|
export * from './rpc/notifications';
|
|
11
12
|
export * from './utility/base64';
|
package/lib/plugin/api.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare namespace Backend {
|
|
|
3
3
|
type UID = string;
|
|
4
4
|
type OnStatusChanged = (status: 'started' | 'stopped') => void;
|
|
5
5
|
type OnEvent = (method: string, properties: unknown) => void;
|
|
6
|
-
type Version = '
|
|
6
|
+
type Version = '5';
|
|
7
7
|
enum Transport {
|
|
8
8
|
H3 = "h3",
|
|
9
9
|
WebRTC = "webrtc"
|
|
@@ -25,6 +25,7 @@ export declare namespace Backend {
|
|
|
25
25
|
interface Device {
|
|
26
26
|
readonly type: 'AudioPlayback' | 'AudioCapture';
|
|
27
27
|
readonly name: string;
|
|
28
|
+
readonly id: string;
|
|
28
29
|
readonly isDefault: boolean;
|
|
29
30
|
}
|
|
30
31
|
interface DeviceParameters {
|
|
@@ -113,7 +114,7 @@ export declare namespace Backend {
|
|
|
113
114
|
readonly mediaStream?: MediaStream;
|
|
114
115
|
readonly uid: UID;
|
|
115
116
|
}
|
|
116
|
-
type Volume =
|
|
117
|
+
type Volume = 'muted' | [number, number];
|
|
117
118
|
interface VadConfig {
|
|
118
119
|
voiceActivity?: SensitivityRange;
|
|
119
120
|
volumeGate?: SensitivityRange;
|
package/lib/rpc/commands.d.ts
CHANGED
|
@@ -23,13 +23,13 @@ export declare const MainCommandsRpc: {
|
|
|
23
23
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
25
|
user_data: Uint8Array;
|
|
26
|
-
token: string;
|
|
27
26
|
room_id: string;
|
|
27
|
+
token: string;
|
|
28
28
|
position: [number, number, number] | [number, number];
|
|
29
29
|
}, {
|
|
30
30
|
user_data: Uint8Array;
|
|
31
|
-
token: string;
|
|
32
31
|
room_id: string;
|
|
32
|
+
token: string;
|
|
33
33
|
position: [number, number, number] | [number, number];
|
|
34
34
|
}>;
|
|
35
35
|
response: z.ZodObject<{
|
|
@@ -115,15 +115,15 @@ export declare const RoomCommandsRpc: {
|
|
|
115
115
|
position: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
116
116
|
}, "strip", z.ZodTypeAny, {
|
|
117
117
|
user_data: Uint8Array;
|
|
118
|
-
stream: "room";
|
|
119
|
-
token: string;
|
|
120
118
|
room_id: string;
|
|
119
|
+
token: string;
|
|
120
|
+
stream: "room";
|
|
121
121
|
position: [number, number, number] | [number, number];
|
|
122
122
|
}, {
|
|
123
123
|
user_data: Uint8Array;
|
|
124
|
-
stream: "room";
|
|
125
|
-
token: string;
|
|
126
124
|
room_id: string;
|
|
125
|
+
token: string;
|
|
126
|
+
stream: "room";
|
|
127
127
|
position: [number, number, number] | [number, number];
|
|
128
128
|
}>;
|
|
129
129
|
response: z.ZodNull;
|