@microsoft/live-share-react 1.0.0-preview.12 → 1.0.0-preview.13
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/README.md +3 -3
- package/bin/index.d.ts +6 -6
- package/bin/index.js +6 -6
- package/bin/interfaces/LiveInterfaceExtensions.d.ts +8 -8
- package/bin/interfaces/LiveInterfaceExtensions.js +5 -5
- package/bin/interfaces/index.d.ts +1 -1
- package/bin/interfaces/index.js +1 -1
- package/bin/internal-hooks/index.d.ts +1 -1
- package/bin/internal-hooks/index.js +1 -1
- package/bin/internal-hooks/useSharedStateRegistry.d.ts +30 -30
- package/bin/internal-hooks/useSharedStateRegistry.d.ts.map +1 -1
- package/bin/internal-hooks/useSharedStateRegistry.js +101 -99
- package/bin/internal-hooks/useSharedStateRegistry.js.map +1 -1
- package/bin/live-hooks/index.d.ts +6 -6
- package/bin/live-hooks/index.js +6 -6
- package/bin/live-hooks/useLiveCanvas.d.ts +27 -27
- package/bin/live-hooks/useLiveCanvas.js +158 -158
- package/bin/live-hooks/useLiveEvent.d.ts +21 -21
- package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
- package/bin/live-hooks/useLiveEvent.js +92 -85
- package/bin/live-hooks/useLiveEvent.js.map +1 -1
- package/bin/live-hooks/useLivePresence.d.ts +25 -25
- package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
- package/bin/live-hooks/useLivePresence.js +101 -92
- package/bin/live-hooks/useLivePresence.js.map +1 -1
- package/bin/live-hooks/useLiveState.d.ts +19 -18
- package/bin/live-hooks/useLiveState.d.ts.map +1 -1
- package/bin/live-hooks/useLiveState.js +72 -60
- package/bin/live-hooks/useLiveState.js.map +1 -1
- package/bin/live-hooks/useLiveTimer.d.ts +7 -7
- package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
- package/bin/live-hooks/useLiveTimer.js +144 -131
- package/bin/live-hooks/useLiveTimer.js.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.d.ts +22 -22
- package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.js +184 -161
- package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
- package/bin/providers/AzureProvider.d.ts +33 -33
- package/bin/providers/AzureProvider.d.ts.map +1 -1
- package/bin/providers/AzureProvider.js +101 -101
- package/bin/providers/AzureProvider.js.map +1 -1
- package/bin/providers/LiveShareProvider.d.ts +62 -41
- package/bin/providers/LiveShareProvider.d.ts.map +1 -1
- package/bin/providers/LiveShareProvider.js +68 -65
- package/bin/providers/LiveShareProvider.js.map +1 -1
- package/bin/providers/index.d.ts +2 -2
- package/bin/providers/index.js +2 -2
- package/bin/shared-hooks/index.d.ts +3 -3
- package/bin/shared-hooks/index.js +3 -3
- package/bin/shared-hooks/useDynamicDDS.d.ts +18 -18
- package/bin/shared-hooks/useDynamicDDS.d.ts.map +1 -1
- package/bin/shared-hooks/useDynamicDDS.js +67 -67
- package/bin/shared-hooks/useDynamicDDS.js.map +1 -1
- package/bin/shared-hooks/useSharedMap.d.ts +21 -21
- package/bin/shared-hooks/useSharedMap.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedMap.js +105 -105
- package/bin/shared-hooks/useSharedMap.js.map +1 -1
- package/bin/shared-hooks/useSharedState.d.ts +20 -20
- package/bin/shared-hooks/useSharedState.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedState.js +66 -62
- package/bin/shared-hooks/useSharedState.js.map +1 -1
- package/bin/types/ActionTypes.d.ts +105 -29
- package/bin/types/ActionTypes.d.ts.map +1 -1
- package/bin/types/ActionTypes.js +5 -5
- package/bin/types/PropTypes.d.ts +7 -7
- package/bin/types/PropTypes.d.ts.map +1 -1
- package/bin/types/PropTypes.js +5 -5
- package/bin/types/ResultTypes.d.ts +174 -162
- package/bin/types/ResultTypes.d.ts.map +1 -1
- package/bin/types/ResultTypes.js +5 -5
- package/bin/types/index.d.ts +3 -3
- package/bin/types/index.js +3 -3
- package/bin/utils/index.d.ts +1 -1
- package/bin/utils/index.js +1 -1
- package/bin/utils/type-check.d.ts +14 -14
- package/bin/utils/type-check.js +53 -53
- package/package.json +13 -13
- package/src/internal-hooks/useSharedStateRegistry.ts +6 -5
- package/src/live-hooks/useLiveEvent.ts +14 -18
- package/src/live-hooks/useLivePresence.ts +13 -7
- package/src/live-hooks/useLiveState.ts +8 -6
- package/src/live-hooks/useLiveTimer.ts +21 -18
- package/src/live-hooks/useMediaSynchronizer.ts +37 -27
- package/src/providers/AzureProvider.tsx +2 -7
- package/src/providers/LiveShareProvider.tsx +45 -15
- package/src/shared-hooks/useDynamicDDS.ts +15 -8
- package/src/shared-hooks/useSharedMap.ts +17 -10
- package/src/shared-hooks/useSharedState.ts +5 -1
- package/src/types/ActionTypes.ts +89 -11
- package/src/types/ResultTypes.ts +22 -8
|
@@ -5,18 +5,44 @@
|
|
|
5
5
|
|
|
6
6
|
import { IFluidContainer, LoadableObjectClassRecord } from "fluid-framework";
|
|
7
7
|
import React from "react";
|
|
8
|
-
import { ILiveShareContainerResults } from "../types";
|
|
9
8
|
import { useSharedStateRegistry } from "../internal-hooks";
|
|
10
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ILiveShareClientOptions,
|
|
11
|
+
ILiveShareHost,
|
|
12
|
+
ILiveShareJoinResults,
|
|
13
|
+
ITimestampProvider,
|
|
14
|
+
} from "@microsoft/live-share";
|
|
11
15
|
import { FluidContext } from "./AzureProvider";
|
|
12
16
|
import { LiveShareTurboClient } from "@microsoft/live-share-turbo";
|
|
13
17
|
|
|
14
|
-
interface ILiveShareContext {
|
|
15
|
-
|
|
18
|
+
export interface ILiveShareContext {
|
|
19
|
+
/**
|
|
20
|
+
* True if the local user created the Fluid container
|
|
21
|
+
*/
|
|
22
|
+
created: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* True if connected to the Live Share container
|
|
25
|
+
*/
|
|
26
|
+
joined: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* An error that will be defined if there was a problem joining the container, or undefined if not.
|
|
29
|
+
*/
|
|
30
|
+
joinError: Error | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Live Share timestamp provider. Can be used to `.getTimestamp()` for a global clock value.
|
|
33
|
+
* This reference timestamp value should be fairly consistent for all users in the session.
|
|
34
|
+
*/
|
|
35
|
+
timestampProvider: ITimestampProvider | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Join callback method
|
|
38
|
+
* @param initialObjects Optional. The initial objects for the Fluid container schema.
|
|
39
|
+
* @param onInitializeContainer Optional. Callback for when the container is first created.
|
|
40
|
+
* @returns `ILiveShareJoinResults`, which includes the Fluid container
|
|
41
|
+
*/
|
|
16
42
|
join: (
|
|
17
43
|
initialObjects?: LoadableObjectClassRecord,
|
|
18
44
|
onInitializeContainer?: (container: IFluidContainer) => void
|
|
19
|
-
) => Promise<
|
|
45
|
+
) => Promise<ILiveShareJoinResults>;
|
|
20
46
|
}
|
|
21
47
|
|
|
22
48
|
export const LiveShareContext = React.createContext<ILiveShareContext>(
|
|
@@ -54,15 +80,13 @@ interface ILiveShareProviderProps {
|
|
|
54
80
|
/**
|
|
55
81
|
* React Context provider component for using Live Share data objects & joining a Live Share session using `LiveShareClient`.
|
|
56
82
|
*/
|
|
57
|
-
export const LiveShareProvider: React.FC<
|
|
58
|
-
ILiveShareProviderProps
|
|
59
|
-
> = (props) => {
|
|
83
|
+
export const LiveShareProvider: React.FC<ILiveShareProviderProps> = (props) => {
|
|
60
84
|
const startedRef = React.useRef(false);
|
|
61
85
|
const clientRef = React.useRef(
|
|
62
86
|
new LiveShareTurboClient(props.host, props.clientOptions)
|
|
63
87
|
);
|
|
64
88
|
const [results, setResults] = React.useState<
|
|
65
|
-
|
|
89
|
+
ILiveShareJoinResults | undefined
|
|
66
90
|
>();
|
|
67
91
|
const [joinError, setJoinError] = React.useState<Error | undefined>();
|
|
68
92
|
|
|
@@ -75,10 +99,12 @@ export const LiveShareProvider: React.FC<
|
|
|
75
99
|
async (
|
|
76
100
|
initialObjects?: LoadableObjectClassRecord,
|
|
77
101
|
onInitializeContainer?: (container: IFluidContainer) => void
|
|
78
|
-
): Promise<
|
|
102
|
+
): Promise<ILiveShareJoinResults> => {
|
|
79
103
|
startedRef.current = true;
|
|
80
|
-
const results
|
|
81
|
-
|
|
104
|
+
const results = await clientRef.current.join(
|
|
105
|
+
initialObjects,
|
|
106
|
+
onInitializeContainer
|
|
107
|
+
);
|
|
82
108
|
setResults(results);
|
|
83
109
|
return results;
|
|
84
110
|
},
|
|
@@ -92,9 +118,10 @@ export const LiveShareProvider: React.FC<
|
|
|
92
118
|
// This hook should only be called once, so we use a ref to track if it has been called.
|
|
93
119
|
// This is a workaround for the fact that useEffect is called twice on initial render in React V18.
|
|
94
120
|
// We are not doing this here for backwards compatibility. View the README for more information.
|
|
95
|
-
if (results !== undefined || startedRef.current || !props.joinOnLoad)
|
|
121
|
+
if (results !== undefined || startedRef.current || !props.joinOnLoad)
|
|
122
|
+
return;
|
|
96
123
|
join(props.initialObjects).catch((error) => {
|
|
97
|
-
console.
|
|
124
|
+
console.error(error);
|
|
98
125
|
if (error instanceof Error) {
|
|
99
126
|
setJoinError(error);
|
|
100
127
|
} else {
|
|
@@ -110,7 +137,10 @@ export const LiveShareProvider: React.FC<
|
|
|
110
137
|
return (
|
|
111
138
|
<LiveShareContext.Provider
|
|
112
139
|
value={{
|
|
113
|
-
created: results?.created,
|
|
140
|
+
created: !!results?.created,
|
|
141
|
+
timestampProvider: results?.timestampProvider,
|
|
142
|
+
joined: !!results?.container,
|
|
143
|
+
joinError,
|
|
114
144
|
join,
|
|
115
145
|
}}
|
|
116
146
|
>
|
|
@@ -16,10 +16,12 @@ import { LoadableObjectClass } from "fluid-framework";
|
|
|
16
16
|
* @param onFirstInitialize Optional. Callback function for when the DDS is first loaded
|
|
17
17
|
* @returns the DDS object, which is of type T when loaded and undefined while loading
|
|
18
18
|
*/
|
|
19
|
-
export function useDynamicDDS<
|
|
19
|
+
export function useDynamicDDS<
|
|
20
|
+
T extends IFluidLoadable = FluidObject<any> & IFluidLoadable
|
|
21
|
+
>(
|
|
20
22
|
uniqueKey: string,
|
|
21
23
|
loadableObjectClass: LoadableObjectClass<T>,
|
|
22
|
-
onFirstInitialize?: (dds: T) => void
|
|
24
|
+
onFirstInitialize?: (dds: T) => void
|
|
23
25
|
): {
|
|
24
26
|
dds: T | undefined;
|
|
25
27
|
error: Error | undefined;
|
|
@@ -29,10 +31,7 @@ export function useDynamicDDS<T extends IFluidLoadable = FluidObject<any> & IFlu
|
|
|
29
31
|
/**
|
|
30
32
|
* Import container and DDS object register callbacks from AzureProvider.
|
|
31
33
|
*/
|
|
32
|
-
const {
|
|
33
|
-
container,
|
|
34
|
-
clientRef,
|
|
35
|
-
} = useFluidObjectsContext();
|
|
34
|
+
const { container, clientRef } = useFluidObjectsContext();
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* Once container is available, this effect will register the setter method so that the DDS loaded
|
|
@@ -46,7 +45,11 @@ export function useDynamicDDS<T extends IFluidLoadable = FluidObject<any> & IFlu
|
|
|
46
45
|
// Callback method to set the `initialData` into the map when the DDS is first created.
|
|
47
46
|
const onGetDDS = async () => {
|
|
48
47
|
try {
|
|
49
|
-
const dds = await clientRef.current.getDDS<T>(
|
|
48
|
+
const dds = await clientRef.current.getDDS<T>(
|
|
49
|
+
uniqueKey,
|
|
50
|
+
loadableObjectClass,
|
|
51
|
+
onFirstInitialize
|
|
52
|
+
);
|
|
50
53
|
if (mounted) {
|
|
51
54
|
setDDS(dds);
|
|
52
55
|
}
|
|
@@ -54,7 +57,11 @@ export function useDynamicDDS<T extends IFluidLoadable = FluidObject<any> & IFlu
|
|
|
54
57
|
if (error instanceof Error) {
|
|
55
58
|
setError(error);
|
|
56
59
|
} else {
|
|
57
|
-
setError(
|
|
60
|
+
setError(
|
|
61
|
+
new Error(
|
|
62
|
+
"useDynamicDDS: an unknown error occurred while getting the DDS"
|
|
63
|
+
)
|
|
64
|
+
);
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
};
|
|
@@ -35,19 +35,26 @@ export function useSharedMap<TData extends object = object>(
|
|
|
35
35
|
getInitialData<TData>(initialData)
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
const onFirstInitialize = React.useCallback(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
const onFirstInitialize = React.useCallback(
|
|
39
|
+
(newDDS: SharedMap): void => {
|
|
40
|
+
/**
|
|
41
|
+
* Callback method to set the `initialData` into the map when the `SharedMap` is first created.
|
|
42
|
+
* Only should be used as a prop to useDynamicDDS.
|
|
43
|
+
*/
|
|
44
|
+
getInitialData(initialData).forEach((value, key) => {
|
|
45
|
+
newDDS.set(key, value);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
[initialData]
|
|
49
|
+
);
|
|
47
50
|
/**
|
|
48
51
|
* User facing: dynamically load the SharedMap DDS for the given unique key.
|
|
49
52
|
*/
|
|
50
|
-
const { dds: sharedMap } = useDynamicDDS<SharedMap>(
|
|
53
|
+
const { dds: sharedMap } = useDynamicDDS<SharedMap>(
|
|
54
|
+
uniqueKey,
|
|
55
|
+
SharedMap,
|
|
56
|
+
onFirstInitialize
|
|
57
|
+
);
|
|
51
58
|
|
|
52
59
|
/**
|
|
53
60
|
* User facing: set a value to the Fluid `SharedMap`.
|
|
@@ -79,7 +79,11 @@ export function useSharedState<S>(
|
|
|
79
79
|
return () => {
|
|
80
80
|
unregisterSharedSetStateAction(uniqueKey, componentIdRef.current);
|
|
81
81
|
};
|
|
82
|
-
}, [
|
|
82
|
+
}, [
|
|
83
|
+
uniqueKey,
|
|
84
|
+
registerSharedSetStateAction,
|
|
85
|
+
unregisterSharedSetStateAction,
|
|
86
|
+
]);
|
|
83
87
|
|
|
84
88
|
return [localState, setSharedState, disposeSharedState];
|
|
85
89
|
}
|
package/src/types/ActionTypes.ts
CHANGED
|
@@ -6,13 +6,19 @@
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
8
|
import { LoadableObjectClass } from "fluid-framework";
|
|
9
|
-
import { ITimerConfig, PresenceState } from "@microsoft/live-share";
|
|
9
|
+
import { ITimerConfig, ILiveEvent, PresenceState } from "@microsoft/live-share";
|
|
10
10
|
|
|
11
11
|
// React actions
|
|
12
|
+
|
|
12
13
|
export type SetSharedStateAction<T> = (state: T) => void;
|
|
13
14
|
export type SetLocalStateAction = React.Dispatch<React.SetStateAction<any>>;
|
|
14
15
|
|
|
15
16
|
// Fluid actions
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Callback for UnregisterDDSSetStateAction.
|
|
20
|
+
* <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: LoadableObjectClass<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void
|
|
21
|
+
*/
|
|
16
22
|
export type RegisterDDSSetStateAction = <T extends IFluidLoadable>(
|
|
17
23
|
uniqueKey: string,
|
|
18
24
|
componentId: string,
|
|
@@ -21,55 +27,127 @@ export type RegisterDDSSetStateAction = <T extends IFluidLoadable>(
|
|
|
21
27
|
onDidFirstInitialize?: (dds: T) => void
|
|
22
28
|
) => void;
|
|
23
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Callback for UnregisterDDSSetStateAction.
|
|
32
|
+
* (uniqueKey: string, componentId: string) => void
|
|
33
|
+
*/
|
|
24
34
|
export type UnregisterDDSSetStateAction = (
|
|
25
35
|
uniqueKey: string,
|
|
26
36
|
componentId: string
|
|
27
37
|
) => void;
|
|
28
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Callback for RegisterSharedSetStateAction.
|
|
41
|
+
* (uniqueKey: string, componentId: string, setLocalStateAction: SetLocalStateAction) => void
|
|
42
|
+
*/
|
|
29
43
|
export type RegisterSharedSetStateAction = (
|
|
30
44
|
uniqueKey: string,
|
|
31
45
|
componentId: string,
|
|
32
46
|
setLocalStateAction: SetLocalStateAction
|
|
33
47
|
) => void;
|
|
34
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Callback for UnregisterSharedSetStateAction.
|
|
51
|
+
* (uniqueKey: string, componentId: string) => void
|
|
52
|
+
*/
|
|
35
53
|
export type UnregisterSharedSetStateAction = (
|
|
36
54
|
uniqueKey: string,
|
|
37
55
|
componentId: string
|
|
38
56
|
) => void;
|
|
39
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Callback for UpdateSharedStateAction.
|
|
60
|
+
* (uniqueKey: string, value: any) => void
|
|
61
|
+
*/
|
|
40
62
|
export type UpdateSharedStateAction = (uniqueKey: string, value: any) => void;
|
|
41
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Callback for DeleteSharedStateAction.
|
|
66
|
+
* (uniqueKey: string) => void
|
|
67
|
+
*/
|
|
42
68
|
export type DeleteSharedStateAction = (uniqueKey: string) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Callback for DisposeSharedStateAction.
|
|
71
|
+
* () => void
|
|
72
|
+
*/
|
|
43
73
|
export type DisposeSharedStateAction = () => void;
|
|
44
74
|
|
|
45
75
|
// Live Share actions
|
|
46
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Callback for SetLiveStateAction<TState = undefined>.
|
|
79
|
+
* (state: TState) => Promise<void>
|
|
80
|
+
*/
|
|
47
81
|
export type SetLiveStateAction<TState = undefined> = (
|
|
48
|
-
state: TState
|
|
49
|
-
) => void
|
|
82
|
+
state: TState
|
|
83
|
+
) => Promise<void>;
|
|
50
84
|
|
|
51
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Callback for SendLiveEventAction<TEvent>.
|
|
87
|
+
* (event: TEvent) => Promise<void>
|
|
88
|
+
*/
|
|
89
|
+
export type SendLiveEventAction<TEvent> = (
|
|
90
|
+
event: TEvent
|
|
91
|
+
) => Promise<ILiveEvent<TEvent>>;
|
|
52
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Callback for OnReceivedLiveEventAction<TEvent>.
|
|
95
|
+
* (event: TEvent, local: boolean) => void
|
|
96
|
+
*/
|
|
53
97
|
export type OnReceivedLiveEventAction<TEvent> = (
|
|
54
98
|
event: TEvent,
|
|
55
99
|
local: boolean
|
|
56
100
|
) => void;
|
|
57
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Callback for OnUpdateLivePresenceAction<TData extends object = object>.
|
|
104
|
+
* (data?: TData | undefined, state?: PresenceState | undefined) => Promise<void>
|
|
105
|
+
*/
|
|
58
106
|
export type OnUpdateLivePresenceAction<TData extends object = object> = (
|
|
59
107
|
data?: TData | undefined,
|
|
60
|
-
state?: PresenceState | undefined
|
|
61
|
-
) => void
|
|
108
|
+
state?: PresenceState | undefined
|
|
109
|
+
) => Promise<void>;
|
|
62
110
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
) => void
|
|
111
|
+
/**
|
|
112
|
+
* Callback for OnStartTimerAction.
|
|
113
|
+
* (duration: number) => Promise<void>
|
|
114
|
+
*/
|
|
115
|
+
export type OnStartTimerAction = (duration: number) => Promise<void>;
|
|
66
116
|
|
|
67
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Callback for OnPlayTimerAction.
|
|
119
|
+
* () => Promise<void>
|
|
120
|
+
*/
|
|
121
|
+
export type OnPlayTimerAction = () => Promise<void>;
|
|
68
122
|
|
|
69
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Callback for OnPauseTimerAction.
|
|
125
|
+
* () => Promise<void>
|
|
126
|
+
*/
|
|
127
|
+
export type OnPauseTimerAction = () => Promise<void>;
|
|
70
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Callback for OnTimerTickAction.
|
|
131
|
+
* (milliRemaining: number) => void
|
|
132
|
+
*/
|
|
71
133
|
export type OnTimerTickAction = (milliRemaining: number) => void;
|
|
134
|
+
/**
|
|
135
|
+
* Callback for OnTimerDidStartAction.
|
|
136
|
+
* (timerConfig: ITimerConfig) => void
|
|
137
|
+
*/
|
|
72
138
|
export type OnTimerDidStartAction = (timerConfig: ITimerConfig) => void;
|
|
139
|
+
/**
|
|
140
|
+
* Callback for OnTimerDidPauseAction.
|
|
141
|
+
* (timerConfig: ITimerConfig) => void
|
|
142
|
+
*/
|
|
73
143
|
export type OnTimerDidPauseAction = (timerConfig: ITimerConfig) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Callback for OnTimerDidPlayAction.
|
|
146
|
+
* (timerConfig: ITimerConfig) => void
|
|
147
|
+
*/
|
|
74
148
|
export type OnTimerDidPlayAction = (timerConfig: ITimerConfig) => void;
|
|
149
|
+
/**
|
|
150
|
+
* Callback for OnTimerDidFinishAction.
|
|
151
|
+
* (timerConfig: ITimerConfig) => void
|
|
152
|
+
*/
|
|
75
153
|
export type OnTimerDidFinishAction = (timerConfig: ITimerConfig) => void;
|
package/src/types/ResultTypes.ts
CHANGED
|
@@ -75,6 +75,8 @@ export interface IUseLiveEventResults<TEvent extends object = object> {
|
|
|
75
75
|
allEvents: IReceiveLiveEvent<TEvent>[];
|
|
76
76
|
/**
|
|
77
77
|
* Callback method to send a new event to users in the session.
|
|
78
|
+
* @param TEvent to send.
|
|
79
|
+
* @returns void promise that will throw when user does not have required roles
|
|
78
80
|
*/
|
|
79
81
|
sendEvent: SendLiveEventAction<TEvent>;
|
|
80
82
|
/**
|
|
@@ -97,15 +99,19 @@ export interface IUseLiveTimerResults {
|
|
|
97
99
|
*/
|
|
98
100
|
liveTimer: LiveTimer | undefined;
|
|
99
101
|
/**
|
|
100
|
-
*
|
|
102
|
+
* Callback to send event through `LiveTimer`
|
|
103
|
+
* @param duration the duration for the timer in milliseconds
|
|
104
|
+
* @returns void promise that will throw when user does not have required roles
|
|
101
105
|
*/
|
|
102
106
|
start: OnStartTimerAction;
|
|
103
107
|
/**
|
|
104
|
-
*
|
|
108
|
+
* Callback to send event through `LiveTimer`
|
|
109
|
+
* @returns void promise that will throw when user does not have required roles
|
|
105
110
|
*/
|
|
106
111
|
play: OnPlayTimerAction;
|
|
107
112
|
/**
|
|
108
|
-
*
|
|
113
|
+
* Callback to send event through `LiveTimer`
|
|
114
|
+
* @returns void promise that will throw when user does not have required roles
|
|
109
115
|
*/
|
|
110
116
|
pause: OnPauseTimerAction;
|
|
111
117
|
}
|
|
@@ -129,6 +135,9 @@ export interface IUseLivePresenceResults<TData extends object = object> {
|
|
|
129
135
|
livePresence: LivePresence<TData> | undefined;
|
|
130
136
|
/**
|
|
131
137
|
* Callback method to update the local user's presence.
|
|
138
|
+
* @param data Optional. TData to set for user.
|
|
139
|
+
* @param state Optional. PresenceState to set for user.
|
|
140
|
+
* @returns void promise that will throw when user does not have required roles
|
|
132
141
|
*/
|
|
133
142
|
updatePresence: OnUpdateLivePresenceAction<TData>;
|
|
134
143
|
}
|
|
@@ -140,23 +149,28 @@ export interface IUseMediaSynchronizerResults {
|
|
|
140
149
|
suspended: boolean;
|
|
141
150
|
/**
|
|
142
151
|
* Callback to initiate a play action for the group media session.
|
|
152
|
+
* @returns void promise that will throw when user does not have required roles
|
|
143
153
|
*/
|
|
144
|
-
play: () => void
|
|
154
|
+
play: () => Promise<void>;
|
|
145
155
|
/**
|
|
146
156
|
* Callback to initiate a pause action for the group media session.
|
|
157
|
+
* @returns void promise that will throw when user does not have required roles
|
|
147
158
|
*/
|
|
148
|
-
pause: () => void
|
|
159
|
+
pause: () => Promise<void>;
|
|
149
160
|
/**
|
|
150
161
|
* Callback to initiate a seek action for the group media session.
|
|
151
|
-
*
|
|
152
162
|
* @param time timestamp of the video in seconds to seek to
|
|
163
|
+
* @returns void promise that will throw when user does not have required roles
|
|
153
164
|
*/
|
|
154
|
-
seekTo: (time: number) => void
|
|
165
|
+
seekTo: (time: number) => Promise<void>;
|
|
155
166
|
/**
|
|
156
167
|
* Callback to change the track for the group media session.
|
|
157
168
|
* @param track media metadata object, track src string, or null
|
|
169
|
+
* @returns void promise that will throw when user does not have required roles
|
|
158
170
|
*/
|
|
159
|
-
setTrack: (
|
|
171
|
+
setTrack: (
|
|
172
|
+
track: Partial<ExtendedMediaMetadata> | string | null
|
|
173
|
+
) => Promise<void>;
|
|
160
174
|
/**
|
|
161
175
|
* Begin a new suspension. If a wait point is not set, the suspension will only impact the
|
|
162
176
|
* local user.
|