@microsoft/live-share-react 1.3.0-preview.0 → 1.4.0-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 (53) hide show
  1. package/.nycrc.json +9 -9
  2. package/LICENSE +86 -86
  3. package/README.md +608 -608
  4. package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
  5. package/bin/live-hooks/useLiveEvent.js +6 -0
  6. package/bin/live-hooks/useLiveEvent.js.map +1 -1
  7. package/bin/live-hooks/useLiveFollowMode.d.ts.map +1 -1
  8. package/bin/live-hooks/useLiveFollowMode.js +2 -4
  9. package/bin/live-hooks/useLiveFollowMode.js.map +1 -1
  10. package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
  11. package/bin/live-hooks/useLivePresence.js +1 -3
  12. package/bin/live-hooks/useLivePresence.js.map +1 -1
  13. package/bin/live-hooks/useLiveState.d.ts.map +1 -1
  14. package/bin/live-hooks/useLiveState.js +1 -3
  15. package/bin/live-hooks/useLiveState.js.map +1 -1
  16. package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
  17. package/bin/live-hooks/useLiveTimer.js +4 -0
  18. package/bin/live-hooks/useLiveTimer.js.map +1 -1
  19. package/package.json +50 -50
  20. package/src/index.ts +6 -6
  21. package/src/interfaces/LiveInterfaceExtensions.ts +26 -26
  22. package/src/interfaces/index.ts +1 -1
  23. package/src/internal/errors.ts +57 -57
  24. package/src/internal/index.ts +2 -2
  25. package/src/internal/type-guards.ts +9 -9
  26. package/src/live-hooks/index.ts +7 -7
  27. package/src/live-hooks/useLiveCanvas.ts +191 -191
  28. package/src/live-hooks/useLiveEvent.ts +146 -140
  29. package/src/live-hooks/useLiveFollowMode.ts +315 -316
  30. package/src/live-hooks/useLivePresence.ts +146 -147
  31. package/src/live-hooks/useLiveState.ts +108 -110
  32. package/src/live-hooks/useLiveTimer.ts +217 -213
  33. package/src/live-hooks/useMediaSynchronizer.ts +295 -295
  34. package/src/providers/AzureProvider.tsx +261 -261
  35. package/src/providers/LiveShareProvider.tsx +210 -210
  36. package/src/providers/index.ts +2 -2
  37. package/src/shared-hooks/index.ts +4 -4
  38. package/src/shared-hooks/useDynamicDDS.ts +82 -82
  39. package/src/shared-hooks/useSharedMap.ts +159 -159
  40. package/src/shared-hooks/useSharedState.ts +96 -96
  41. package/src/shared-hooks/useSharedStateRegistry.ts +170 -170
  42. package/src/types/ActionTypes.ts +161 -161
  43. package/src/types/PropTypes.ts +10 -10
  44. package/src/types/ResultTypes.ts +332 -332
  45. package/src/types/index.ts +3 -3
  46. package/src/utils/index.ts +1 -1
  47. package/src/utils/type-check.ts +69 -69
  48. package/tsconfig.build.json +5 -5
  49. package/tsconfig.json +72 -72
  50. package/bin/internal/useSharedStateRegistry.d.ts +0 -31
  51. package/bin/internal/useSharedStateRegistry.d.ts.map +0 -1
  52. package/bin/internal/useSharedStateRegistry.js +0 -102
  53. package/bin/internal/useSharedStateRegistry.js.map +0 -1
@@ -1,170 +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
- /**
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
+ /*!
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;