@microsoft/live-share-react 1.2.2-preview.0 → 1.3.1-preview.0

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.
Files changed (54) hide show
  1. package/.nycrc.json +9 -9
  2. package/LICENSE +86 -86
  3. package/README.md +608 -608
  4. package/bin/internal/index.d.ts +0 -1
  5. package/bin/internal/index.d.ts.map +1 -1
  6. package/bin/internal/index.js +0 -1
  7. package/bin/internal/index.js.map +1 -1
  8. package/bin/providers/AzureProvider.d.ts +1 -1
  9. package/bin/providers/AzureProvider.d.ts.map +1 -1
  10. package/bin/providers/AzureProvider.js +1 -1
  11. package/bin/providers/AzureProvider.js.map +1 -1
  12. package/bin/providers/LiveShareProvider.js +1 -1
  13. package/bin/providers/LiveShareProvider.js.map +1 -1
  14. package/bin/shared-hooks/index.d.ts +1 -0
  15. package/bin/shared-hooks/index.d.ts.map +1 -1
  16. package/bin/shared-hooks/index.js +1 -0
  17. package/bin/shared-hooks/index.js.map +1 -1
  18. package/bin/{internal → shared-hooks}/useSharedStateRegistry.d.ts +6 -0
  19. package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  20. package/bin/{internal → shared-hooks}/useSharedStateRegistry.js +3 -0
  21. package/bin/shared-hooks/useSharedStateRegistry.js.map +1 -0
  22. package/package.json +50 -50
  23. package/src/index.ts +6 -6
  24. package/src/interfaces/LiveInterfaceExtensions.ts +26 -26
  25. package/src/interfaces/index.ts +1 -1
  26. package/src/internal/errors.ts +57 -57
  27. package/src/internal/index.ts +2 -3
  28. package/src/internal/type-guards.ts +9 -9
  29. package/src/live-hooks/index.ts +7 -7
  30. package/src/live-hooks/useLiveCanvas.ts +191 -191
  31. package/src/live-hooks/useLiveEvent.ts +140 -140
  32. package/src/live-hooks/useLiveFollowMode.ts +316 -316
  33. package/src/live-hooks/useLivePresence.ts +147 -147
  34. package/src/live-hooks/useLiveState.ts +110 -110
  35. package/src/live-hooks/useLiveTimer.ts +213 -213
  36. package/src/live-hooks/useMediaSynchronizer.ts +295 -295
  37. package/src/providers/AzureProvider.tsx +261 -261
  38. package/src/providers/LiveShareProvider.tsx +210 -210
  39. package/src/providers/index.ts +2 -2
  40. package/src/shared-hooks/index.ts +4 -3
  41. package/src/shared-hooks/useDynamicDDS.ts +82 -82
  42. package/src/shared-hooks/useSharedMap.ts +159 -159
  43. package/src/shared-hooks/useSharedState.ts +96 -96
  44. package/src/{internal → shared-hooks}/useSharedStateRegistry.ts +170 -164
  45. package/src/types/ActionTypes.ts +161 -161
  46. package/src/types/PropTypes.ts +10 -10
  47. package/src/types/ResultTypes.ts +332 -332
  48. package/src/types/index.ts +3 -3
  49. package/src/utils/index.ts +1 -1
  50. package/src/utils/type-check.ts +69 -69
  51. package/tsconfig.build.json +5 -5
  52. package/tsconfig.json +72 -72
  53. package/bin/internal/useSharedStateRegistry.d.ts.map +0 -1
  54. package/bin/internal/useSharedStateRegistry.js.map +0 -1
@@ -1,164 +1,170 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
-
6
- import { IValueChanged, SharedMap } from "fluid-framework";
7
- import React from "react";
8
- import {
9
- DeleteSharedStateAction,
10
- IAzureContainerResults,
11
- RegisterSharedSetStateAction,
12
- SetLocalStateAction,
13
- UnregisterSharedSetStateAction,
14
- UpdateSharedStateAction,
15
- } from "../types";
16
-
17
- export interface ISharedStateRegistryResponse {
18
- /**
19
- * Register a set state action callback
20
- */
21
- registerSharedSetStateAction: RegisterSharedSetStateAction;
22
- /**
23
- * Unregister a set state action callback
24
- */
25
- unregisterSharedSetStateAction: UnregisterSharedSetStateAction;
26
- /**
27
- * Setter callback to update the shared state
28
- */
29
- updateSharedState: UpdateSharedStateAction;
30
- /**
31
- * Delete a shared state value
32
- */
33
- deleteSharedState: DeleteSharedStateAction;
34
- }
35
-
36
- /**
37
- * Hook used internally to keep track of the SharedSetStateActionMap for each unique key. It sets state values for provided keys and updates components listening to the values.
38
- *
39
- * @param results IAzureContainerResults response or undefined
40
- * @returns ISharedStateRegistryResponse object
41
- */
42
- export const useSharedStateRegistry = (
43
- results: IAzureContainerResults | undefined
44
- ): ISharedStateRegistryResponse => {
45
- const registeredSharedSetStateActionMapRef = React.useRef<
46
- Map<string, Map<string, SetLocalStateAction>>
47
- >(new Map());
48
-
49
- /**
50
- * @see ISharedStateRegistryResponse.registerSharedSetStateAction
51
- */
52
- const registerSharedSetStateAction = React.useCallback(
53
- (
54
- uniqueKey: string,
55
- componentId: string,
56
- setLocalStateAction: SetLocalStateAction
57
- ) => {
58
- let actionsMap =
59
- registeredSharedSetStateActionMapRef.current.get(uniqueKey);
60
- if (actionsMap) {
61
- if (!actionsMap.has(componentId)) {
62
- actionsMap.set(componentId, setLocalStateAction);
63
- }
64
- } else {
65
- actionsMap = new Map<string, SetLocalStateAction>();
66
- actionsMap.set(componentId, setLocalStateAction);
67
- registeredSharedSetStateActionMapRef.current.set(
68
- uniqueKey,
69
- actionsMap
70
- );
71
- }
72
- // Set initial values, if known
73
- const stateMap = results?.container.initialObjects
74
- .TURBO_STATE_MAP as SharedMap | undefined;
75
- const initialValue = stateMap?.get(uniqueKey);
76
- if (initialValue) {
77
- setLocalStateAction(initialValue);
78
- }
79
- },
80
- [results]
81
- );
82
-
83
- /**
84
- * @see ISharedStateRegistryResponse.unregisterSharedSetStateAction
85
- */
86
- const unregisterSharedSetStateAction = React.useCallback(
87
- (uniqueKey: string, componentId: string) => {
88
- let actionsMap =
89
- registeredSharedSetStateActionMapRef.current.get(uniqueKey);
90
- if (actionsMap?.has(componentId)) {
91
- actionsMap.delete(componentId);
92
- }
93
- },
94
- []
95
- );
96
-
97
- /**
98
- * @see ISharedStateRegistryResponse.updateSharedState
99
- */
100
- const updateSharedState: UpdateSharedStateAction = React.useCallback(
101
- (uniqueKey: string, value: any) => {
102
- if (!results) return;
103
- const { container } = results;
104
- const stateMap = container.initialObjects
105
- .TURBO_STATE_MAP as SharedMap;
106
- stateMap.set(uniqueKey, value);
107
- },
108
- [results]
109
- );
110
-
111
- /**
112
- * @see ISharedStateRegistryResponse.deleteSharedState
113
- */
114
- const deleteSharedState: DeleteSharedStateAction = React.useCallback(
115
- (uniqueKey: string) => {
116
- if (!results) return;
117
- const { container } = results;
118
- let actionsMap =
119
- registeredSharedSetStateActionMapRef.current.get(uniqueKey);
120
- actionsMap?.clear();
121
- const stateMap = container.initialObjects
122
- .TURBO_STATE_MAP as SharedMap;
123
- stateMap.delete(uniqueKey);
124
- },
125
- [results]
126
- );
127
-
128
- React.useEffect(() => {
129
- if (!results) return;
130
- const { container } = results;
131
- const stateMap = container.initialObjects.TURBO_STATE_MAP as SharedMap;
132
- const valueChangedListener = (changed: IValueChanged): void => {
133
- if (registeredSharedSetStateActionMapRef.current.has(changed.key)) {
134
- const value = stateMap.get(changed.key);
135
- const actionMap =
136
- registeredSharedSetStateActionMapRef.current.get(
137
- changed.key
138
- );
139
- actionMap?.forEach((setLocalStateHandler) => {
140
- setLocalStateHandler(value);
141
- });
142
- }
143
- };
144
- stateMap.on("valueChanged", valueChangedListener);
145
- // Set initial values
146
- stateMap.forEach((value: any, key: string) => {
147
- const actionMap =
148
- registeredSharedSetStateActionMapRef.current.get(key);
149
- actionMap?.forEach((setLocalStateHandler) => {
150
- setLocalStateHandler(value);
151
- });
152
- });
153
- return () => {
154
- stateMap.off("valueChanged", valueChangedListener);
155
- };
156
- }, [results]);
157
-
158
- return {
159
- registerSharedSetStateAction,
160
- unregisterSharedSetStateAction,
161
- updateSharedState,
162
- deleteSharedState,
163
- };
164
- };
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+
6
+ import { IValueChanged, SharedMap } from "fluid-framework";
7
+ import React from "react";
8
+ import {
9
+ DeleteSharedStateAction,
10
+ IAzureContainerResults,
11
+ RegisterSharedSetStateAction,
12
+ SetLocalStateAction,
13
+ UnregisterSharedSetStateAction,
14
+ UpdateSharedStateAction,
15
+ } from "../types";
16
+
17
+ /**
18
+ * Response for the {@link useSharedStateRegistry} hook.
19
+ */
20
+ export interface ISharedStateRegistryResponse {
21
+ /**
22
+ * Register a set state action callback
23
+ */
24
+ registerSharedSetStateAction: RegisterSharedSetStateAction;
25
+ /**
26
+ * Unregister a set state action callback
27
+ */
28
+ unregisterSharedSetStateAction: UnregisterSharedSetStateAction;
29
+ /**
30
+ * Setter callback to update the shared state
31
+ */
32
+ updateSharedState: UpdateSharedStateAction;
33
+ /**
34
+ * Delete a shared state value
35
+ */
36
+ deleteSharedState: DeleteSharedStateAction;
37
+ }
38
+
39
+ /**
40
+ * Hook used internally to keep track of the SharedSetStateActionMap for each unique key. It sets state values for provided keys and updates components listening to the values.
41
+ *
42
+ * @remarks
43
+ * Use this if you are building a custom `LiveShareProvider` or `AzureProvider` implementation in your app.
44
+ *
45
+ * @param results IAzureContainerResults response or undefined
46
+ * @returns ISharedStateRegistryResponse object
47
+ */
48
+ export const useSharedStateRegistry = (
49
+ results: IAzureContainerResults | undefined
50
+ ): ISharedStateRegistryResponse => {
51
+ const registeredSharedSetStateActionMapRef = React.useRef<
52
+ Map<string, Map<string, SetLocalStateAction>>
53
+ >(new Map());
54
+
55
+ /**
56
+ * @see ISharedStateRegistryResponse.registerSharedSetStateAction
57
+ */
58
+ const registerSharedSetStateAction = React.useCallback(
59
+ (
60
+ uniqueKey: string,
61
+ componentId: string,
62
+ setLocalStateAction: SetLocalStateAction
63
+ ) => {
64
+ let actionsMap =
65
+ registeredSharedSetStateActionMapRef.current.get(uniqueKey);
66
+ if (actionsMap) {
67
+ if (!actionsMap.has(componentId)) {
68
+ actionsMap.set(componentId, setLocalStateAction);
69
+ }
70
+ } else {
71
+ actionsMap = new Map<string, SetLocalStateAction>();
72
+ actionsMap.set(componentId, setLocalStateAction);
73
+ registeredSharedSetStateActionMapRef.current.set(
74
+ uniqueKey,
75
+ actionsMap
76
+ );
77
+ }
78
+ // Set initial values, if known
79
+ const stateMap = results?.container.initialObjects
80
+ .TURBO_STATE_MAP as SharedMap | undefined;
81
+ const initialValue = stateMap?.get(uniqueKey);
82
+ if (initialValue) {
83
+ setLocalStateAction(initialValue);
84
+ }
85
+ },
86
+ [results]
87
+ );
88
+
89
+ /**
90
+ * @see ISharedStateRegistryResponse.unregisterSharedSetStateAction
91
+ */
92
+ const unregisterSharedSetStateAction = React.useCallback(
93
+ (uniqueKey: string, componentId: string) => {
94
+ let actionsMap =
95
+ registeredSharedSetStateActionMapRef.current.get(uniqueKey);
96
+ if (actionsMap?.has(componentId)) {
97
+ actionsMap.delete(componentId);
98
+ }
99
+ },
100
+ []
101
+ );
102
+
103
+ /**
104
+ * @see ISharedStateRegistryResponse.updateSharedState
105
+ */
106
+ const updateSharedState: UpdateSharedStateAction = React.useCallback(
107
+ (uniqueKey: string, value: any) => {
108
+ if (!results) return;
109
+ const { container } = results;
110
+ const stateMap = container.initialObjects
111
+ .TURBO_STATE_MAP as SharedMap;
112
+ stateMap.set(uniqueKey, value);
113
+ },
114
+ [results]
115
+ );
116
+
117
+ /**
118
+ * @see ISharedStateRegistryResponse.deleteSharedState
119
+ */
120
+ const deleteSharedState: DeleteSharedStateAction = React.useCallback(
121
+ (uniqueKey: string) => {
122
+ if (!results) return;
123
+ const { container } = results;
124
+ let actionsMap =
125
+ registeredSharedSetStateActionMapRef.current.get(uniqueKey);
126
+ actionsMap?.clear();
127
+ const stateMap = container.initialObjects
128
+ .TURBO_STATE_MAP as SharedMap;
129
+ stateMap.delete(uniqueKey);
130
+ },
131
+ [results]
132
+ );
133
+
134
+ React.useEffect(() => {
135
+ if (!results) return;
136
+ const { container } = results;
137
+ const stateMap = container.initialObjects.TURBO_STATE_MAP as SharedMap;
138
+ const valueChangedListener = (changed: IValueChanged): void => {
139
+ if (registeredSharedSetStateActionMapRef.current.has(changed.key)) {
140
+ const value = stateMap.get(changed.key);
141
+ const actionMap =
142
+ registeredSharedSetStateActionMapRef.current.get(
143
+ changed.key
144
+ );
145
+ actionMap?.forEach((setLocalStateHandler) => {
146
+ setLocalStateHandler(value);
147
+ });
148
+ }
149
+ };
150
+ stateMap.on("valueChanged", valueChangedListener);
151
+ // Set initial values
152
+ stateMap.forEach((value: any, key: string) => {
153
+ const actionMap =
154
+ registeredSharedSetStateActionMapRef.current.get(key);
155
+ actionMap?.forEach((setLocalStateHandler) => {
156
+ setLocalStateHandler(value);
157
+ });
158
+ });
159
+ return () => {
160
+ stateMap.off("valueChanged", valueChangedListener);
161
+ };
162
+ }, [results]);
163
+
164
+ return {
165
+ registerSharedSetStateAction,
166
+ unregisterSharedSetStateAction,
167
+ updateSharedState,
168
+ deleteSharedState,
169
+ };
170
+ };
@@ -1,161 +1,161 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
-
6
- import React from "react";
7
- import { IFluidLoadable } from "@fluidframework/core-interfaces";
8
- import { LoadableObjectClass } from "fluid-framework";
9
- import { ITimerConfig, ILiveEvent, PresenceState } from "@microsoft/live-share";
10
-
11
- // React actions
12
-
13
- /**
14
- * Callback to set shared state
15
- */
16
- export type SetSharedStateAction<TState> = (
17
- state: TState | ((prevState: TState) => TState)
18
- ) => void;
19
- /**
20
- * Callback to set local state
21
- */
22
- export type SetLocalStateAction = React.Dispatch<React.SetStateAction<any>>;
23
-
24
- // Fluid actions
25
-
26
- /**
27
- * Callback for UnregisterDDSSetStateAction.
28
- * <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: LoadableObjectClass<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void
29
- */
30
- export type RegisterDDSSetStateAction = <T extends IFluidLoadable>(
31
- uniqueKey: string,
32
- componentId: string,
33
- objectClass: LoadableObjectClass<T>,
34
- setLocalStateAction: SetLocalStateAction,
35
- onDidFirstInitialize?: (dds: T) => void
36
- ) => void;
37
-
38
- /**
39
- * Callback for UnregisterDDSSetStateAction.
40
- * (uniqueKey: string, componentId: string) => void
41
- */
42
- export type UnregisterDDSSetStateAction = (
43
- uniqueKey: string,
44
- componentId: string
45
- ) => void;
46
-
47
- /**
48
- * Callback for RegisterSharedSetStateAction.
49
- * (uniqueKey: string, componentId: string, setLocalStateAction: SetLocalStateAction) => void
50
- */
51
- export type RegisterSharedSetStateAction = (
52
- uniqueKey: string,
53
- componentId: string,
54
- setLocalStateAction: SetLocalStateAction
55
- ) => void;
56
-
57
- /**
58
- * Callback for UnregisterSharedSetStateAction.
59
- * (uniqueKey: string, componentId: string) => void
60
- */
61
- export type UnregisterSharedSetStateAction = (
62
- uniqueKey: string,
63
- componentId: string
64
- ) => void;
65
-
66
- /**
67
- * Callback for UpdateSharedStateAction.
68
- * (uniqueKey: string, value: any) => void
69
- */
70
- export type UpdateSharedStateAction = (uniqueKey: string, value: any) => void;
71
-
72
- /**
73
- * Callback for DeleteSharedStateAction.
74
- * (uniqueKey: string) => void
75
- */
76
- export type DeleteSharedStateAction = (uniqueKey: string) => void;
77
- /**
78
- * Callback for DisposeSharedStateAction.
79
- * () => void
80
- */
81
- export type DisposeSharedStateAction = () => void;
82
-
83
- // Live Share actions
84
-
85
- /**
86
- * Callback for SetLiveStateAction<TState = undefined>.
87
- * (state: TState) => Promise<void>
88
- */
89
- export type SetLiveStateAction<TState = undefined> = (
90
- state: TState | ((prevState: TState) => TState)
91
- ) => Promise<void>;
92
-
93
- /**
94
- * Callback for SendLiveEventAction<TEvent>.
95
- * (event: TEvent) => Promise<void>
96
- */
97
- export type SendLiveEventAction<TEvent> = (
98
- event: TEvent
99
- ) => Promise<ILiveEvent<TEvent>>;
100
-
101
- /**
102
- * Callback for OnReceivedLiveEventAction<TEvent>.
103
- * (event: TEvent, local: boolean) => void
104
- */
105
- export type OnReceivedLiveEventAction<TEvent> = (
106
- event: TEvent,
107
- local: boolean
108
- ) => void;
109
-
110
- /**
111
- * Callback for OnUpdateLivePresenceAction<TData extends object = object>.
112
- * (data?: TData | undefined, state?: PresenceState | undefined) => Promise<void>
113
- */
114
- export type OnUpdateLivePresenceAction<TData extends object = object> = (
115
- data?: TData | undefined,
116
- state?: PresenceState | undefined
117
- ) => Promise<void>;
118
-
119
- /**
120
- * Callback for OnStartTimerAction.
121
- * (duration: number) => Promise<void>
122
- */
123
- export type OnStartTimerAction = (duration: number) => Promise<void>;
124
-
125
- /**
126
- * Callback for OnPlayTimerAction.
127
- * () => Promise<void>
128
- */
129
- export type OnPlayTimerAction = () => Promise<void>;
130
-
131
- /**
132
- * Callback for OnPauseTimerAction.
133
- * () => Promise<void>
134
- */
135
- export type OnPauseTimerAction = () => Promise<void>;
136
-
137
- /**
138
- * Callback for OnTimerTickAction.
139
- * (milliRemaining: number) => void
140
- */
141
- export type OnTimerTickAction = (milliRemaining: number) => void;
142
- /**
143
- * Callback for OnTimerDidStartAction.
144
- * (timerConfig: ITimerConfig) => void
145
- */
146
- export type OnTimerDidStartAction = (timerConfig: ITimerConfig) => void;
147
- /**
148
- * Callback for OnTimerDidPauseAction.
149
- * (timerConfig: ITimerConfig) => void
150
- */
151
- export type OnTimerDidPauseAction = (timerConfig: ITimerConfig) => void;
152
- /**
153
- * Callback for OnTimerDidPlayAction.
154
- * (timerConfig: ITimerConfig) => void
155
- */
156
- export type OnTimerDidPlayAction = (timerConfig: ITimerConfig) => void;
157
- /**
158
- * Callback for OnTimerDidFinishAction.
159
- * (timerConfig: ITimerConfig) => void
160
- */
161
- export type OnTimerDidFinishAction = (timerConfig: ITimerConfig) => void;
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+
6
+ import React from "react";
7
+ import { IFluidLoadable } from "@fluidframework/core-interfaces";
8
+ import { LoadableObjectClass } from "fluid-framework";
9
+ import { ITimerConfig, ILiveEvent, PresenceState } from "@microsoft/live-share";
10
+
11
+ // React actions
12
+
13
+ /**
14
+ * Callback to set shared state
15
+ */
16
+ export type SetSharedStateAction<TState> = (
17
+ state: TState | ((prevState: TState) => TState)
18
+ ) => void;
19
+ /**
20
+ * Callback to set local state
21
+ */
22
+ export type SetLocalStateAction = React.Dispatch<React.SetStateAction<any>>;
23
+
24
+ // Fluid actions
25
+
26
+ /**
27
+ * Callback for UnregisterDDSSetStateAction.
28
+ * <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: LoadableObjectClass<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void
29
+ */
30
+ export type RegisterDDSSetStateAction = <T extends IFluidLoadable>(
31
+ uniqueKey: string,
32
+ componentId: string,
33
+ objectClass: LoadableObjectClass<T>,
34
+ setLocalStateAction: SetLocalStateAction,
35
+ onDidFirstInitialize?: (dds: T) => void
36
+ ) => void;
37
+
38
+ /**
39
+ * Callback for UnregisterDDSSetStateAction.
40
+ * (uniqueKey: string, componentId: string) => void
41
+ */
42
+ export type UnregisterDDSSetStateAction = (
43
+ uniqueKey: string,
44
+ componentId: string
45
+ ) => void;
46
+
47
+ /**
48
+ * Callback for RegisterSharedSetStateAction.
49
+ * (uniqueKey: string, componentId: string, setLocalStateAction: SetLocalStateAction) => void
50
+ */
51
+ export type RegisterSharedSetStateAction = (
52
+ uniqueKey: string,
53
+ componentId: string,
54
+ setLocalStateAction: SetLocalStateAction
55
+ ) => void;
56
+
57
+ /**
58
+ * Callback for UnregisterSharedSetStateAction.
59
+ * (uniqueKey: string, componentId: string) => void
60
+ */
61
+ export type UnregisterSharedSetStateAction = (
62
+ uniqueKey: string,
63
+ componentId: string
64
+ ) => void;
65
+
66
+ /**
67
+ * Callback for UpdateSharedStateAction.
68
+ * (uniqueKey: string, value: any) => void
69
+ */
70
+ export type UpdateSharedStateAction = (uniqueKey: string, value: any) => void;
71
+
72
+ /**
73
+ * Callback for DeleteSharedStateAction.
74
+ * (uniqueKey: string) => void
75
+ */
76
+ export type DeleteSharedStateAction = (uniqueKey: string) => void;
77
+ /**
78
+ * Callback for DisposeSharedStateAction.
79
+ * () => void
80
+ */
81
+ export type DisposeSharedStateAction = () => void;
82
+
83
+ // Live Share actions
84
+
85
+ /**
86
+ * Callback for SetLiveStateAction<TState = undefined>.
87
+ * (state: TState) => Promise<void>
88
+ */
89
+ export type SetLiveStateAction<TState = undefined> = (
90
+ state: TState | ((prevState: TState) => TState)
91
+ ) => Promise<void>;
92
+
93
+ /**
94
+ * Callback for SendLiveEventAction<TEvent>.
95
+ * (event: TEvent) => Promise<void>
96
+ */
97
+ export type SendLiveEventAction<TEvent> = (
98
+ event: TEvent
99
+ ) => Promise<ILiveEvent<TEvent>>;
100
+
101
+ /**
102
+ * Callback for OnReceivedLiveEventAction<TEvent>.
103
+ * (event: TEvent, local: boolean) => void
104
+ */
105
+ export type OnReceivedLiveEventAction<TEvent> = (
106
+ event: TEvent,
107
+ local: boolean
108
+ ) => void;
109
+
110
+ /**
111
+ * Callback for OnUpdateLivePresenceAction<TData extends object = object>.
112
+ * (data?: TData | undefined, state?: PresenceState | undefined) => Promise<void>
113
+ */
114
+ export type OnUpdateLivePresenceAction<TData extends object = object> = (
115
+ data?: TData | undefined,
116
+ state?: PresenceState | undefined
117
+ ) => Promise<void>;
118
+
119
+ /**
120
+ * Callback for OnStartTimerAction.
121
+ * (duration: number) => Promise<void>
122
+ */
123
+ export type OnStartTimerAction = (duration: number) => Promise<void>;
124
+
125
+ /**
126
+ * Callback for OnPlayTimerAction.
127
+ * () => Promise<void>
128
+ */
129
+ export type OnPlayTimerAction = () => Promise<void>;
130
+
131
+ /**
132
+ * Callback for OnPauseTimerAction.
133
+ * () => Promise<void>
134
+ */
135
+ export type OnPauseTimerAction = () => Promise<void>;
136
+
137
+ /**
138
+ * Callback for OnTimerTickAction.
139
+ * (milliRemaining: number) => void
140
+ */
141
+ export type OnTimerTickAction = (milliRemaining: number) => void;
142
+ /**
143
+ * Callback for OnTimerDidStartAction.
144
+ * (timerConfig: ITimerConfig) => void
145
+ */
146
+ export type OnTimerDidStartAction = (timerConfig: ITimerConfig) => void;
147
+ /**
148
+ * Callback for OnTimerDidPauseAction.
149
+ * (timerConfig: ITimerConfig) => void
150
+ */
151
+ export type OnTimerDidPauseAction = (timerConfig: ITimerConfig) => void;
152
+ /**
153
+ * Callback for OnTimerDidPlayAction.
154
+ * (timerConfig: ITimerConfig) => void
155
+ */
156
+ export type OnTimerDidPlayAction = (timerConfig: ITimerConfig) => void;
157
+ /**
158
+ * Callback for OnTimerDidFinishAction.
159
+ * (timerConfig: ITimerConfig) => void
160
+ */
161
+ export type OnTimerDidFinishAction = (timerConfig: ITimerConfig) => void;