@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.
@@ -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 {};
@@ -0,0 +1,2 @@
1
+ export declare const isAndroidOrIOSBrowser: () => boolean;
2
+ export declare const isSupportWebCodecs: () => boolean;
@@ -14,6 +14,7 @@ export type NotifyProps = {
14
14
  header?: string;
15
15
  message: string;
16
16
  severity?: NotifySeverity;
17
+ clear?: boolean;
17
18
  };
18
19
  export type DialogsContextType = {
19
20
  configDialogVisible: {
@@ -1,5 +1,5 @@
1
- import { SharedState } from './types';
2
1
  import { Participant } from '@zoom/videosdk';
2
+ import { SharedState } from '../../shared';
3
3
 
4
4
  export declare const CHAT_STATE_DEFAULT: {
5
5
  active: boolean;
@@ -1,4 +1,4 @@
1
- import { SharedAction } from './types';
1
+ import { SharedAction } from '../../shared';
2
2
 
3
3
  export declare const useActionSender: () => (action: SharedAction, options?: {
4
4
  maxAttempts?: number;
@@ -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>;
@@ -4,4 +4,5 @@ export declare const useLocalVideo: () => {
4
4
  start: (cameraId: string) => Promise<void>;
5
5
  stop: () => Promise<void>;
6
6
  switch: (cameraId: string) => Promise<void>;
7
+ updateVirtualBackground: (blurred: boolean) => Promise<void>;
7
8
  };
@@ -0,0 +1,2 @@
1
+ export { default } from './reducer';
2
+ export type { ChatState, ChatAction } from './types';
@@ -0,0 +1,4 @@
1
+ import { ChatAction, ChatState } from './types';
2
+
3
+ declare const chatReducer: (state: ChatState, action: ChatAction) => ChatState;
4
+ export default chatReducer;
@@ -0,0 +1,10 @@
1
+ export type ChatState = {
2
+ active: boolean;
3
+ timestamp: number;
4
+ };
5
+ export type ToggleChatAction = {
6
+ type: 'TOGGLE-CHAT';
7
+ active: boolean;
8
+ timestamp: number;
9
+ };
10
+ export type ChatAction = ToggleChatAction;
@@ -0,0 +1,2 @@
1
+ export { default } from './reducer';
2
+ export type { SharedState, SharedAction } from './types';
@@ -0,0 +1,4 @@
1
+ import { SharedState, SharedAction } from './types';
2
+
3
+ declare const reducer: (state: SharedState, action: SharedAction) => SharedState;
4
+ export default reducer;
@@ -0,0 +1,2 @@
1
+ export { default } from './reducer';
2
+ export type { SpeakerTurnState, SpeakerTurnAction, ToggleHandAction, LowerUserHandAction, ToggleTurnQueueAction } from './types';
@@ -0,0 +1,4 @@
1
+ import { SpeakerTurnAction, SpeakerTurnState } from './types';
2
+
3
+ declare const speakerTurnReducer: (state: SpeakerTurnState, action: SpeakerTurnAction) => SpeakerTurnState;
4
+ export default speakerTurnReducer;
@@ -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.29",
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.5",
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.0",
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.15",
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.15"
94
+ "vitest": "^4.0.16"
94
95
  },
95
96
  "keywords": [
96
97
  "react",
@@ -1 +0,0 @@
1
- export { sharedStateReducer } from './reducer';
@@ -1,3 +0,0 @@
1
- import { LowerUserHandAction, SharedState } from '../types';
2
-
3
- export declare const lowerUserHandReducer: (state: SharedState, action: LowerUserHandAction) => SharedState;
@@ -1,3 +0,0 @@
1
- import { SharedState, SharedAction } from '../types';
2
-
3
- export declare const sharedStateReducer: (state: SharedState, action: SharedAction) => SharedState;
@@ -1,3 +0,0 @@
1
- import { SendStateAction, SharedState } from '../types';
2
-
3
- export declare const sendSharedStateReducer: (_state: SharedState, action: SendStateAction) => SharedState;
@@ -1,4 +0,0 @@
1
- import { SharedState, ToggleChatAction } from '../types';
2
-
3
- declare const toggleChatReducer: (state: SharedState, action: ToggleChatAction) => SharedState;
4
- export default toggleChatReducer;
@@ -1,3 +0,0 @@
1
- import { SharedState, ToggleHandAction } from '../types';
2
-
3
- export declare const toggleHandReducer: (state: SharedState, action: ToggleHandAction) => SharedState;
@@ -1,4 +0,0 @@
1
- import { SharedState, ToggleTurnQueueAction } from '../types';
2
-
3
- declare const toggleTurnQueueReducer: (state: SharedState, action: ToggleTurnQueueAction) => SharedState;
4
- export default toggleTurnQueueReducer;
@@ -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;