@yrzhao/aves-core 0.1.0 → 0.2.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.
@@ -7,4 +7,4 @@ export { AvesClient } from "./core/AvesClient";
7
7
  export { EventEmitter } from "./core/EventEmitter";
8
8
  export { WebRTCManager } from "./core/WebRTCManager";
9
9
  export { SignalingClient } from "./core/SignalingClient";
10
- export type { Participant, AvesClientConfig, SignalingMessage, ReconnectConfig, } from "./types/types";
10
+ export type { Participant, AvesClientConfig, FileTransferOptions, FileTransferInfo, FileTransferProgress, FileTransferResult, LocalAudioState, SignalingMessage, SignalingErrorCode, SignalingErrorStage, SignalingErrorPayload, JoinRoomResult, LeaveRoomResult, ReconnectConfig, } from "./types/types";
@@ -2,28 +2,88 @@ export interface Participant {
2
2
  id: string;
3
3
  name: string;
4
4
  }
5
+ export type SignalingErrorCode = "INVALID_MESSAGE_FORMAT" | "INVALID_MESSAGE" | "ROOM_NOT_FOUND" | "ROOM_CREATE_FAILED" | "ROOM_JOIN_FAILED" | "JOIN_ROOM_MISSING_FIELDS" | "ALREADY_JOINED" | "LEAVE_NOT_JOINED" | "LEAVE_USER_MISMATCH" | "SIGNALING_NOT_AUTHENTICATED" | "SIGNALING_FORBIDDEN" | "SIGNALING_TARGET_NOT_FOUND" | "SIGNALING_TARGET_ROOM_MISMATCH" | "SERVER_ERROR" | (string & {});
6
+ export type SignalingErrorStage = "protocol" | "room" | "signaling" | "transport" | "server" | (string & {});
7
+ export interface SignalingErrorPayload {
8
+ message: string;
9
+ code: SignalingErrorCode;
10
+ stage: SignalingErrorStage;
11
+ retryable: boolean;
12
+ requestId?: string;
13
+ }
14
+ export interface JoinRoomResult {
15
+ participants: Participant[];
16
+ userId: string;
17
+ }
18
+ export interface LeaveRoomResult {
19
+ roomId: string;
20
+ userId: string;
21
+ }
5
22
  export interface AvesClientConfig {
6
23
  signalingUrl: string;
7
24
  iceServers?: RTCIceServer[];
25
+ fileChunkSize?: number;
8
26
  reconnect?: {
9
27
  maxAttempts?: number;
10
28
  delay?: number;
11
29
  };
12
30
  debug?: boolean;
13
31
  }
32
+ export interface FileTransferOptions {
33
+ peerId?: string;
34
+ fileName?: string;
35
+ mimeType?: string;
36
+ lastModified?: number;
37
+ chunkSize?: number;
38
+ }
39
+ export type FileTransferDirection = "send" | "receive";
40
+ export interface FileTransferInfo {
41
+ transferId: string;
42
+ peerId: string;
43
+ direction: FileTransferDirection;
44
+ name: string;
45
+ size: number;
46
+ mimeType: string;
47
+ lastModified: number;
48
+ }
49
+ export interface FileTransferProgress extends FileTransferInfo {
50
+ bytesTransferred: number;
51
+ progress: number;
52
+ }
53
+ export interface FileTransferResult extends FileTransferInfo {
54
+ blob?: Blob;
55
+ }
56
+ export interface LocalAudioState {
57
+ active: boolean;
58
+ muted: boolean;
59
+ }
14
60
  export type SignalingMessage = {
15
61
  type: "create-room";
62
+ requestId?: string;
16
63
  } | {
17
64
  type: "room-created";
18
65
  roomId: string;
66
+ requestId?: string;
19
67
  } | {
20
68
  type: "join-room";
21
69
  roomId: string;
22
- userId: string;
70
+ userId?: string;
23
71
  userName: string;
72
+ requestId?: string;
24
73
  } | {
25
74
  type: "room-joined";
26
75
  participants: Participant[];
76
+ userId: string;
77
+ requestId?: string;
78
+ } | {
79
+ type: "leave-room";
80
+ userId: string;
81
+ requestId?: string;
82
+ } | {
83
+ type: "room-left";
84
+ roomId: string;
85
+ userId: string;
86
+ requestId?: string;
27
87
  } | {
28
88
  type: "user-joined";
29
89
  user: Participant;
@@ -45,10 +105,9 @@ export type SignalingMessage = {
45
105
  fromId: string;
46
106
  targetId: string;
47
107
  candidate: RTCIceCandidateInit;
48
- } | {
108
+ } | ({
49
109
  type: "error";
50
- message: string;
51
- };
110
+ } & SignalingErrorPayload);
52
111
  export interface ReconnectConfig {
53
112
  maxAttempts: number;
54
113
  delay: number;
package/dist/index.d.ts CHANGED
@@ -7,4 +7,4 @@ export { AvesClient } from "./core/AvesClient";
7
7
  export { EventEmitter } from "./core/EventEmitter";
8
8
  export { WebRTCManager } from "./core/WebRTCManager";
9
9
  export { SignalingClient } from "./core/SignalingClient";
10
- export type { Participant, AvesClientConfig, SignalingMessage, ReconnectConfig, } from "./types/types";
10
+ export type { Participant, AvesClientConfig, FileTransferOptions, FileTransferInfo, FileTransferProgress, FileTransferResult, LocalAudioState, SignalingMessage, SignalingErrorCode, SignalingErrorStage, SignalingErrorPayload, JoinRoomResult, LeaveRoomResult, ReconnectConfig, } from "./types/types";
@@ -2,28 +2,88 @@ export interface Participant {
2
2
  id: string;
3
3
  name: string;
4
4
  }
5
+ export type SignalingErrorCode = "INVALID_MESSAGE_FORMAT" | "INVALID_MESSAGE" | "ROOM_NOT_FOUND" | "ROOM_CREATE_FAILED" | "ROOM_JOIN_FAILED" | "JOIN_ROOM_MISSING_FIELDS" | "ALREADY_JOINED" | "LEAVE_NOT_JOINED" | "LEAVE_USER_MISMATCH" | "SIGNALING_NOT_AUTHENTICATED" | "SIGNALING_FORBIDDEN" | "SIGNALING_TARGET_NOT_FOUND" | "SIGNALING_TARGET_ROOM_MISMATCH" | "SERVER_ERROR" | (string & {});
6
+ export type SignalingErrorStage = "protocol" | "room" | "signaling" | "transport" | "server" | (string & {});
7
+ export interface SignalingErrorPayload {
8
+ message: string;
9
+ code: SignalingErrorCode;
10
+ stage: SignalingErrorStage;
11
+ retryable: boolean;
12
+ requestId?: string;
13
+ }
14
+ export interface JoinRoomResult {
15
+ participants: Participant[];
16
+ userId: string;
17
+ }
18
+ export interface LeaveRoomResult {
19
+ roomId: string;
20
+ userId: string;
21
+ }
5
22
  export interface AvesClientConfig {
6
23
  signalingUrl: string;
7
24
  iceServers?: RTCIceServer[];
25
+ fileChunkSize?: number;
8
26
  reconnect?: {
9
27
  maxAttempts?: number;
10
28
  delay?: number;
11
29
  };
12
30
  debug?: boolean;
13
31
  }
32
+ export interface FileTransferOptions {
33
+ peerId?: string;
34
+ fileName?: string;
35
+ mimeType?: string;
36
+ lastModified?: number;
37
+ chunkSize?: number;
38
+ }
39
+ export type FileTransferDirection = "send" | "receive";
40
+ export interface FileTransferInfo {
41
+ transferId: string;
42
+ peerId: string;
43
+ direction: FileTransferDirection;
44
+ name: string;
45
+ size: number;
46
+ mimeType: string;
47
+ lastModified: number;
48
+ }
49
+ export interface FileTransferProgress extends FileTransferInfo {
50
+ bytesTransferred: number;
51
+ progress: number;
52
+ }
53
+ export interface FileTransferResult extends FileTransferInfo {
54
+ blob?: Blob;
55
+ }
56
+ export interface LocalAudioState {
57
+ active: boolean;
58
+ muted: boolean;
59
+ }
14
60
  export type SignalingMessage = {
15
61
  type: "create-room";
62
+ requestId?: string;
16
63
  } | {
17
64
  type: "room-created";
18
65
  roomId: string;
66
+ requestId?: string;
19
67
  } | {
20
68
  type: "join-room";
21
69
  roomId: string;
22
- userId: string;
70
+ userId?: string;
23
71
  userName: string;
72
+ requestId?: string;
24
73
  } | {
25
74
  type: "room-joined";
26
75
  participants: Participant[];
76
+ userId: string;
77
+ requestId?: string;
78
+ } | {
79
+ type: "leave-room";
80
+ userId: string;
81
+ requestId?: string;
82
+ } | {
83
+ type: "room-left";
84
+ roomId: string;
85
+ userId: string;
86
+ requestId?: string;
27
87
  } | {
28
88
  type: "user-joined";
29
89
  user: Participant;
@@ -45,10 +105,9 @@ export type SignalingMessage = {
45
105
  fromId: string;
46
106
  targetId: string;
47
107
  candidate: RTCIceCandidateInit;
48
- } | {
108
+ } | ({
49
109
  type: "error";
50
- message: string;
51
- };
110
+ } & SignalingErrorPayload);
52
111
  export interface ReconnectConfig {
53
112
  maxAttempts: number;
54
113
  delay: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yrzhao/aves-core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "WebRTC client library for real-time communication",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",