@fraku/video 0.1.8 → 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.
@@ -1,5 +1,6 @@
1
1
  declare const permissions: {
2
2
  'init-pre-session': "admin"[];
3
3
  'init-session': "admin"[];
4
+ 'activate-chat': "admin"[];
4
5
  };
5
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 {};