@fraku/video 0.1.7 → 0.1.9
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/config/permissions.d.ts +5 -3
- package/dist/hooks/async.d.ts +64 -0
- package/dist/hooks/async.test.d.ts +1 -0
- package/dist/index.cjs +479 -344
- package/dist/index.css +1 -1
- package/dist/index.js +28549 -27649
- package/dist/libs/permissions.d.ts +3 -2
- package/dist/pages/MainSessionPage/Chat/ChatFooter.d.ts +11 -0
- package/dist/pages/MainSessionPage/Chat/MessageCard.d.ts +8 -0
- package/dist/pages/MainSessionPage/Chat/MessageHeader.d.ts +8 -0
- package/dist/pages/MainSessionPage/Chat/SenderInfo.d.ts +6 -0
- package/dist/pages/MainSessionPage/Chat/tests/ChatFooter.test.d.ts +1 -0
- package/dist/providers/DialogsProvider/DialogsProvider.d.ts +1 -1
- package/dist/providers/DialogsProvider/types.d.ts +0 -2
- package/dist/providers/MediaProvider/context.d.ts +1 -0
- package/dist/providers/MediaProvider/types.d.ts +12 -1
- package/dist/test/setup.d.ts +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/permissions.d.ts +0 -1
- package/package.json +13 -6
- package/dist/hooks/useAsyncHandler.d.ts +0 -5
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
declare const permissions: {
|
|
2
|
+
'init-pre-session': "admin"[];
|
|
3
|
+
'init-session': "admin"[];
|
|
4
|
+
'activate-chat': "admin"[];
|
|
5
|
+
};
|
|
4
6
|
export default permissions;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
type AsyncState<T> = {
|
|
2
|
+
loading: boolean;
|
|
3
|
+
value: T | undefined;
|
|
4
|
+
error: Error | undefined;
|
|
5
|
+
};
|
|
6
|
+
export type AsyncGroupRef = {
|
|
7
|
+
register: (id: string, state: AsyncState<any>) => void;
|
|
8
|
+
unregister: (id: string) => void;
|
|
9
|
+
updateState: (id: string, state: AsyncState<any>) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Hook to manage and aggregate the state of multiple async handlers.
|
|
13
|
+
* Provides loading state, error tracking, and reset functionality across all registered handlers.
|
|
14
|
+
*
|
|
15
|
+
* @returns An object containing:
|
|
16
|
+
* - `ref`: Reference to pass to useAsyncHandler hooks for registration
|
|
17
|
+
* - `loading`: True if any handler is loading
|
|
18
|
+
* - `error`: The first error from any handler
|
|
19
|
+
* - `errors`: Array of all errors from handlers
|
|
20
|
+
* - `hasError`: True if any handler has an error
|
|
21
|
+
* - `loadingCount`: Number of handlers currently loading
|
|
22
|
+
* - `reset()`: Clear all errors
|
|
23
|
+
* - `resetAll()`: Reset all states to initial values
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const asyncGroup = useAsyncGroup()
|
|
27
|
+
* const [handler] = useAsyncHandler(async () => {...}, [], asyncGroup.ref)
|
|
28
|
+
*
|
|
29
|
+
* return <Button disabled={asyncGroup.loading} onClick={handler} />
|
|
30
|
+
*/
|
|
31
|
+
export declare const useAsyncGroup: () => {
|
|
32
|
+
loading: boolean;
|
|
33
|
+
error: Error | undefined;
|
|
34
|
+
errors: Error[];
|
|
35
|
+
hasError: boolean;
|
|
36
|
+
loadingCount: number;
|
|
37
|
+
ref: AsyncGroupRef;
|
|
38
|
+
reset: () => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Hook to manage the execution of an async function with loading and error states.
|
|
42
|
+
* Can optionally register with an async group for coordinated state management.
|
|
43
|
+
*
|
|
44
|
+
* @template T - The async function type
|
|
45
|
+
* @param {T} callback - The async function to execute
|
|
46
|
+
* @param {React.DependencyList} deps - Dependency array for the callback (similar to useCallback)
|
|
47
|
+
* @param {AsyncGroupRef} [groupRef] - Optional group reference for coordinated state management
|
|
48
|
+
* @returns {[Function, {loading: boolean, value: Awaited<ReturnType<T>> | undefined, error: Error | undefined, reset: () => void}]}
|
|
49
|
+
* A tuple containing:
|
|
50
|
+
* - Handler function to execute the async operation
|
|
51
|
+
* - State object with loading, value, error, and reset function
|
|
52
|
+
* @example
|
|
53
|
+
* const [handleSubmit, { loading, error }] = useAsyncHandler(
|
|
54
|
+
* async (data) => await api.submit(data),
|
|
55
|
+
* [api]
|
|
56
|
+
* )
|
|
57
|
+
*/
|
|
58
|
+
export declare const useAsyncHandler: <T extends (...args: any[]) => Promise<any>>(callback: T, deps: React.DependencyList, groupRef?: AsyncGroupRef) => [(...args: Parameters<T>) => Promise<void>, {
|
|
59
|
+
loading: boolean;
|
|
60
|
+
value: Awaited<ReturnType<T>> | undefined;
|
|
61
|
+
error: Error | undefined;
|
|
62
|
+
reset: () => void;
|
|
63
|
+
}];
|
|
64
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|