@fraku/video 0.1.29 → 0.1.30
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/dist/index.cjs +154 -154
- package/dist/index.js +9995 -9897
- package/dist/libs/errors.d.ts +28 -0
- package/dist/libs/errors.test.d.ts +1 -0
- package/dist/libs/platform.d.ts +2 -0
- package/dist/providers/DialogsProvider/context.d.ts +1 -0
- package/dist/providers/SharedProvider/context.d.ts +1 -1
- package/dist/providers/SharedProvider/hooks.d.ts +1 -1
- package/dist/providers/VideoProvider/context.d.ts +2 -0
- package/dist/providers/VideoProvider/hooks.d.ts +1 -0
- package/dist/shared/chat/index.d.ts +2 -0
- package/dist/shared/chat/reducer.d.ts +4 -0
- package/dist/shared/chat/types.d.ts +10 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/reducer.d.ts +4 -0
- package/dist/shared/speaker-turn/index.d.ts +2 -0
- package/dist/shared/speaker-turn/reducer.d.ts +4 -0
- package/dist/shared/speaker-turn/types.d.ts +21 -0
- package/dist/shared/types.d.ts +21 -0
- package/package.json +9 -8
- package/dist/providers/SharedProvider/reducer/index.d.ts +0 -1
- package/dist/providers/SharedProvider/reducer/lowerUserHandReducer.d.ts +0 -3
- package/dist/providers/SharedProvider/reducer/reducer.d.ts +0 -3
- package/dist/providers/SharedProvider/reducer/sendSharedStateReducer.d.ts +0 -3
- package/dist/providers/SharedProvider/reducer/toggleChatReducer.d.ts +0 -4
- package/dist/providers/SharedProvider/reducer/toggleHandReducer.d.ts +0 -3
- package/dist/providers/SharedProvider/reducer/toggleTurnQueueReducer.d.ts +0 -4
- package/dist/providers/SharedProvider/types.d.ts +0 -43
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type SafeFunction = {
|
|
2
|
+
<TResult>(fn: () => Promise<TResult>): Promise<TResult>;
|
|
3
|
+
<TResult>(fn: () => TResult): TResult;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* React hook that wraps unstable or error-prone functions to provide consistent error handling.
|
|
7
|
+
*
|
|
8
|
+
* Instead of allowing functions to fail silently (e.g., when a user doesn't have a camera or microphone),
|
|
9
|
+
* this hook catches errors and displays a user-friendly notification using the DialogsProvider.
|
|
10
|
+
*
|
|
11
|
+
* @returns A callback function that accepts either a sync or async function, executes it safely,
|
|
12
|
+
* and handles both synchronous and asynchronous errors by:
|
|
13
|
+
* - Displaying a notification to the user with the error details
|
|
14
|
+
* - Re-throwing the error for additional handling if needed
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const safe = useSafeCall()
|
|
19
|
+
*
|
|
20
|
+
* // Async function:
|
|
21
|
+
* await safe(() => localVideo.start(activeCameraId))
|
|
22
|
+
*
|
|
23
|
+
* // Sync function:
|
|
24
|
+
* const x = safe(() => unsafeOperation())
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const useSafeCall: () => SafeFunction;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,11 +5,13 @@ export type VideoContextType = {
|
|
|
5
5
|
cameraList: MediaDevice[];
|
|
6
6
|
activeCameraId: string;
|
|
7
7
|
videoStarted: boolean;
|
|
8
|
+
localVideoStarted: boolean;
|
|
8
9
|
isBlurred: boolean;
|
|
9
10
|
localVideoRef: MutableRefObject<HTMLVideoElement | null>;
|
|
10
11
|
switchBlurred: (blurred: boolean) => Promise<void>;
|
|
11
12
|
startVideo: () => Promise<void>;
|
|
12
13
|
stopVideo: () => Promise<void>;
|
|
14
|
+
stopLocalVideo: () => Promise<void>;
|
|
13
15
|
switchCamera: (deviceId: string) => Promise<void>;
|
|
14
16
|
attachUserVideo: (userId: number, videoElement: VideoPlayer) => Promise<void>;
|
|
15
17
|
detachUserVideo: (userId: number) => Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type SpeakerTurnState = {
|
|
2
|
+
turnQueueState: {
|
|
3
|
+
active: boolean;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
};
|
|
6
|
+
speakerQueueIds: number[];
|
|
7
|
+
};
|
|
8
|
+
export type ToggleHandAction = {
|
|
9
|
+
type: 'TOGGLE-HAND';
|
|
10
|
+
senderId: number;
|
|
11
|
+
};
|
|
12
|
+
export type LowerUserHandAction = {
|
|
13
|
+
type: 'LOWER-USER-HAND';
|
|
14
|
+
userId: number;
|
|
15
|
+
};
|
|
16
|
+
export type ToggleTurnQueueAction = {
|
|
17
|
+
type: 'TOGGLE-TURN-QUEUE';
|
|
18
|
+
active: boolean;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
};
|
|
21
|
+
export type SpeakerTurnAction = ToggleHandAction | LowerUserHandAction | ToggleTurnQueueAction;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ChatAction, ChatState } from './chat';
|
|
2
|
+
import { SpeakerTurnAction, SpeakerTurnState } from './speaker-turn';
|
|
3
|
+
|
|
4
|
+
export type SharedState = {
|
|
5
|
+
chatState: ChatState;
|
|
6
|
+
speakerTurnState: SpeakerTurnState;
|
|
7
|
+
};
|
|
8
|
+
export type AlertUserAction = {
|
|
9
|
+
type: 'ALERT-USER';
|
|
10
|
+
message: string;
|
|
11
|
+
userId: number;
|
|
12
|
+
};
|
|
13
|
+
export type RequestStateAction = {
|
|
14
|
+
type: 'REQUEST-SHARED-STATE';
|
|
15
|
+
userId: number;
|
|
16
|
+
};
|
|
17
|
+
export type SendStateAction = {
|
|
18
|
+
type: 'SEND-SHARED-STATE';
|
|
19
|
+
state: SharedState;
|
|
20
|
+
};
|
|
21
|
+
export type SharedAction = AlertUserAction | RequestStateAction | SendStateAction | SpeakerTurnAction | ChatAction;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fraku/video",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.30",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"test": "vitest",
|
|
35
35
|
"test:ui": "vitest --ui",
|
|
36
36
|
"test:coverage": "vitest --coverage",
|
|
37
|
-
"test:e2e": "playwright test",
|
|
38
|
-
"test:e2e:ui": "playwright test --ui",
|
|
39
|
-
"test:e2e:headed": "playwright test --headed",
|
|
37
|
+
"test:e2e": "playwright test --project=chromium",
|
|
38
|
+
"test:e2e:ui": "playwright test --ui --project=chromium",
|
|
39
|
+
"test:e2e:headed": "playwright test --headed --project=chromium",
|
|
40
40
|
"test:storybook": "test-storybook",
|
|
41
41
|
"build:ci": "tsc && vite build",
|
|
42
42
|
"build:css:ci": "tailwindcss -c ./tailwind.config.js -i ./src/index.css -o ./dist/index.css --minify",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@playwright/test": "^1.57.0",
|
|
62
|
-
"@storybook/react-vite": "^10.1.
|
|
62
|
+
"@storybook/react-vite": "^10.1.11",
|
|
63
63
|
"@storybook/test-runner": "^0.24.2",
|
|
64
64
|
"@tailwindcss/container-queries": "^0.1.1",
|
|
65
65
|
"@testing-library/jest-dom": "^6.9.1",
|
|
66
|
-
"@testing-library/react": "^16.3.
|
|
66
|
+
"@testing-library/react": "^16.3.1",
|
|
67
67
|
"@types/jsrsasign": "^10.5.15",
|
|
68
68
|
"@types/node": "^24.10.2",
|
|
69
69
|
"@types/react": "^18.2.43",
|
|
@@ -72,8 +72,9 @@
|
|
|
72
72
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
73
73
|
"@typescript-eslint/parser": "^6.14.0",
|
|
74
74
|
"@vitejs/plugin-react": "^4.3.4",
|
|
75
|
-
"@vitest/ui": "^4.0.
|
|
75
|
+
"@vitest/ui": "^4.0.16",
|
|
76
76
|
"autoprefixer": "^10.4.22",
|
|
77
|
+
"baseline-browser-mapping": "^2.9.13",
|
|
77
78
|
"eslint": "^8.55.0",
|
|
78
79
|
"eslint-plugin-react": "^7.37.5",
|
|
79
80
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
"vite": "^6.0.7",
|
|
91
92
|
"vite-plugin-dts": "^3.6.4",
|
|
92
93
|
"vite-plugin-static-copy": "^3.1.4",
|
|
93
|
-
"vitest": "^4.0.
|
|
94
|
+
"vitest": "^4.0.16"
|
|
94
95
|
},
|
|
95
96
|
"keywords": [
|
|
96
97
|
"react",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { sharedStateReducer } from './reducer';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export type SharedState = {
|
|
2
|
-
chatState: {
|
|
3
|
-
active: boolean;
|
|
4
|
-
timestamp: number;
|
|
5
|
-
};
|
|
6
|
-
turnQueueState: {
|
|
7
|
-
active: boolean;
|
|
8
|
-
timestamp: number;
|
|
9
|
-
};
|
|
10
|
-
speakerQueueIds: number[];
|
|
11
|
-
};
|
|
12
|
-
export type RequestStateAction = {
|
|
13
|
-
type: 'REQUEST-SHARED-STATE';
|
|
14
|
-
userId: number;
|
|
15
|
-
};
|
|
16
|
-
export type SendStateAction = {
|
|
17
|
-
type: 'SEND-SHARED-STATE';
|
|
18
|
-
state: SharedState;
|
|
19
|
-
};
|
|
20
|
-
export type ToggleHandAction = {
|
|
21
|
-
type: 'TOGGLE-HAND';
|
|
22
|
-
senderId: number;
|
|
23
|
-
};
|
|
24
|
-
export type LowerUserHandAction = {
|
|
25
|
-
type: 'LOWER-USER-HAND';
|
|
26
|
-
userId: number;
|
|
27
|
-
};
|
|
28
|
-
export type AlertUserAction = {
|
|
29
|
-
type: 'ALERT-USER';
|
|
30
|
-
message: string;
|
|
31
|
-
userId: number;
|
|
32
|
-
};
|
|
33
|
-
export type ToggleChatAction = {
|
|
34
|
-
type: 'TOGGLE-CHAT';
|
|
35
|
-
active: boolean;
|
|
36
|
-
timestamp: number;
|
|
37
|
-
};
|
|
38
|
-
export type ToggleTurnQueueAction = {
|
|
39
|
-
type: 'TOGGLE-TURN-QUEUE';
|
|
40
|
-
active: boolean;
|
|
41
|
-
timestamp: number;
|
|
42
|
-
};
|
|
43
|
-
export type SharedAction = RequestStateAction | SendStateAction | ToggleHandAction | LowerUserHandAction | ToggleTurnQueueAction | AlertUserAction | ToggleChatAction;
|