@microsoft/live-share-react 2.0.0-internal.13 → 2.0.0-internal.15
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/package.json +9 -9
- package/bin/index.d.ts +0 -7
- package/bin/index.d.ts.map +0 -1
- package/bin/index.js +0 -7
- package/bin/index.js.map +0 -1
- package/bin/interfaces/LiveInterfaceExtensions.d.ts +0 -26
- package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +0 -1
- package/bin/interfaces/LiveInterfaceExtensions.js +0 -6
- package/bin/interfaces/LiveInterfaceExtensions.js.map +0 -1
- package/bin/interfaces/index.d.ts +0 -2
- package/bin/interfaces/index.d.ts.map +0 -1
- package/bin/interfaces/index.js +0 -2
- package/bin/interfaces/index.js.map +0 -1
- package/bin/internal/errors.d.ts +0 -41
- package/bin/internal/errors.d.ts.map +0 -1
- package/bin/internal/errors.js +0 -42
- package/bin/internal/errors.js.map +0 -1
- package/bin/internal/index.d.ts +0 -3
- package/bin/internal/index.d.ts.map +0 -1
- package/bin/internal/index.js +0 -3
- package/bin/internal/index.js.map +0 -1
- package/bin/internal/type-guards.d.ts +0 -11
- package/bin/internal/type-guards.d.ts.map +0 -1
- package/bin/internal/type-guards.js +0 -20
- package/bin/internal/type-guards.js.map +0 -1
- package/bin/live-hooks/index.d.ts +0 -8
- package/bin/live-hooks/index.d.ts.map +0 -1
- package/bin/live-hooks/index.js +0 -8
- package/bin/live-hooks/index.js.map +0 -1
- package/bin/live-hooks/useLiveCanvas.d.ts +0 -29
- package/bin/live-hooks/useLiveCanvas.d.ts.map +0 -1
- package/bin/live-hooks/useLiveCanvas.js +0 -160
- package/bin/live-hooks/useLiveCanvas.js.map +0 -1
- package/bin/live-hooks/useLiveEvent.d.ts +0 -23
- package/bin/live-hooks/useLiveEvent.d.ts.map +0 -1
- package/bin/live-hooks/useLiveEvent.js +0 -108
- package/bin/live-hooks/useLiveEvent.js.map +0 -1
- package/bin/live-hooks/useLiveFollowMode.d.ts +0 -24
- package/bin/live-hooks/useLiveFollowMode.d.ts.map +0 -1
- package/bin/live-hooks/useLiveFollowMode.js +0 -211
- package/bin/live-hooks/useLiveFollowMode.js.map +0 -1
- package/bin/live-hooks/useLivePresence.d.ts +0 -26
- package/bin/live-hooks/useLivePresence.d.ts.map +0 -1
- package/bin/live-hooks/useLivePresence.js +0 -106
- package/bin/live-hooks/useLivePresence.js.map +0 -1
- package/bin/live-hooks/useLiveState.d.ts +0 -21
- package/bin/live-hooks/useLiveState.d.ts.map +0 -1
- package/bin/live-hooks/useLiveState.js +0 -83
- package/bin/live-hooks/useLiveState.js.map +0 -1
- package/bin/live-hooks/useLiveTimer.d.ts +0 -25
- package/bin/live-hooks/useLiveTimer.d.ts.map +0 -1
- package/bin/live-hooks/useLiveTimer.js +0 -172
- package/bin/live-hooks/useLiveTimer.js.map +0 -1
- package/bin/live-hooks/useMediaSynchronizer.d.ts +0 -25
- package/bin/live-hooks/useMediaSynchronizer.d.ts.map +0 -1
- package/bin/live-hooks/useMediaSynchronizer.js +0 -234
- package/bin/live-hooks/useMediaSynchronizer.js.map +0 -1
- package/bin/providers/AzureProvider.d.ts +0 -113
- package/bin/providers/AzureProvider.d.ts.map +0 -1
- package/bin/providers/AzureProvider.js +0 -119
- package/bin/providers/AzureProvider.js.map +0 -1
- package/bin/providers/LiveShareProvider.d.ts +0 -91
- package/bin/providers/LiveShareProvider.d.ts.map +0 -1
- package/bin/providers/LiveShareProvider.js +0 -95
- package/bin/providers/LiveShareProvider.js.map +0 -1
- package/bin/providers/index.d.ts +0 -3
- package/bin/providers/index.d.ts.map +0 -1
- package/bin/providers/index.js +0 -3
- package/bin/providers/index.js.map +0 -1
- package/bin/shared-hooks/index.d.ts +0 -5
- package/bin/shared-hooks/index.d.ts.map +0 -1
- package/bin/shared-hooks/index.js +0 -5
- package/bin/shared-hooks/index.js.map +0 -1
- package/bin/shared-hooks/useDynamicDDS.d.ts +0 -23
- package/bin/shared-hooks/useDynamicDDS.d.ts.map +0 -1
- package/bin/shared-hooks/useDynamicDDS.js +0 -72
- package/bin/shared-hooks/useDynamicDDS.js.map +0 -1
- package/bin/shared-hooks/useSharedMap.d.ts +0 -23
- package/bin/shared-hooks/useSharedMap.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedMap.js +0 -114
- package/bin/shared-hooks/useSharedMap.js.map +0 -1
- package/bin/shared-hooks/useSharedState.d.ts +0 -22
- package/bin/shared-hooks/useSharedState.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedState.js +0 -74
- package/bin/shared-hooks/useSharedState.js.map +0 -1
- package/bin/shared-hooks/useSharedStateRegistry.d.ts +0 -37
- package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +0 -1
- package/bin/shared-hooks/useSharedStateRegistry.js +0 -105
- package/bin/shared-hooks/useSharedStateRegistry.js.map +0 -1
- package/bin/types/ActionTypes.d.ts +0 -112
- package/bin/types/ActionTypes.d.ts.map +0 -1
- package/bin/types/ActionTypes.js +0 -6
- package/bin/types/ActionTypes.js.map +0 -1
- package/bin/types/PropTypes.d.ts +0 -8
- package/bin/types/PropTypes.d.ts.map +0 -1
- package/bin/types/PropTypes.js +0 -6
- package/bin/types/PropTypes.js.map +0 -1
- package/bin/types/ResultTypes.d.ts +0 -302
- package/bin/types/ResultTypes.d.ts.map +0 -1
- package/bin/types/ResultTypes.js +0 -6
- package/bin/types/ResultTypes.js.map +0 -1
- package/bin/types/index.d.ts +0 -4
- package/bin/types/index.d.ts.map +0 -1
- package/bin/types/index.js +0 -4
- package/bin/types/index.js.map +0 -1
- package/bin/utils/index.d.ts +0 -2
- package/bin/utils/index.d.ts.map +0 -1
- package/bin/utils/index.js +0 -2
- package/bin/utils/index.js.map +0 -1
- package/bin/utils/type-check.d.ts +0 -15
- package/bin/utils/type-check.d.ts.map +0 -1
- package/bin/utils/type-check.js +0 -54
- package/bin/utils/type-check.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveE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ACN,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO;QACH,WAAW;QACX,SAAS,EAAE,YAAY,CAAC,OAAO;QAC/B,SAAS;QACT,SAAS;KACZ,CAAC;AACN,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
-
import { IUseLiveFollowModeResults } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* React hook for using a Live Share `LiveFollowMode`.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Use this hook if you want to add the ability to follow specific users or let a user present to everyone in the session.
|
|
12
|
-
* Each user has their own `stateValue`, which is the value other users will reference when that user is presenting or being followed.
|
|
13
|
-
* The `state` response includes the user's `value` that the local user is "following", whether it be their own or someone else's.
|
|
14
|
-
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
15
|
-
*
|
|
16
|
-
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
17
|
-
*
|
|
18
|
-
* @param uniqueKey The unique key for `LiveFollowMode`. If one does not yet exist, a new one will be created.
|
|
19
|
-
* @param initialData The initial value for the local user's `stateValue`.
|
|
20
|
-
* @param allowedRoles Optional. The user roles that are allowed to present to use `startPresenting()` or `stopPresenting()`.
|
|
21
|
-
* @returns `IUseLiveFollowModeResults` results, which contains React stateful objects and callbacks.
|
|
22
|
-
*/
|
|
23
|
-
export declare function useLiveFollowMode<TData = any>(uniqueKey: string, initialData: TData | (() => TData), allowedRoles?: UserMeetingRole[]): IUseLiveFollowModeResults<TData>;
|
|
24
|
-
//# sourceMappingURL=useLiveFollowMode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveFollowMode.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveFollowMode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAKlB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAG,GAAG,EACzC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EAClC,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,yBAAyB,CAAC,KAAK,CAAC,CA2QlC"}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
import { LiveDataObjectInitializeState, LiveFollowMode, } from "@microsoft/live-share";
|
|
15
|
-
import React from "react";
|
|
16
|
-
import { useDynamicDDS } from "../shared-hooks";
|
|
17
|
-
import { useFluidObjectsContext } from "../providers";
|
|
18
|
-
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
|
|
19
|
-
/**
|
|
20
|
-
* React hook for using a Live Share `LiveFollowMode`.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* Use this hook if you want to add the ability to follow specific users or let a user present to everyone in the session.
|
|
24
|
-
* Each user has their own `stateValue`, which is the value other users will reference when that user is presenting or being followed.
|
|
25
|
-
* The `state` response includes the user's `value` that the local user is "following", whether it be their own or someone else's.
|
|
26
|
-
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
27
|
-
*
|
|
28
|
-
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
29
|
-
*
|
|
30
|
-
* @param uniqueKey The unique key for `LiveFollowMode`. If one does not yet exist, a new one will be created.
|
|
31
|
-
* @param initialData The initial value for the local user's `stateValue`.
|
|
32
|
-
* @param allowedRoles Optional. The user roles that are allowed to present to use `startPresenting()` or `stopPresenting()`.
|
|
33
|
-
* @returns `IUseLiveFollowModeResults` results, which contains React stateful objects and callbacks.
|
|
34
|
-
*/
|
|
35
|
-
export function useLiveFollowMode(uniqueKey, initialData, allowedRoles) {
|
|
36
|
-
/**
|
|
37
|
-
* Stateful follow state.
|
|
38
|
-
*/
|
|
39
|
-
const [state, setState] = React.useState();
|
|
40
|
-
/**
|
|
41
|
-
* Stateful all user presence list and its non-user-facing setter method.
|
|
42
|
-
*/
|
|
43
|
-
const [allUsers, setAllUsers] = React.useState([]);
|
|
44
|
-
/**
|
|
45
|
-
* User facing: dynamically load the DDS for the given unique key.
|
|
46
|
-
*/
|
|
47
|
-
const { dds: liveFollowMode } = useDynamicDDS(uniqueKey, (LiveFollowMode));
|
|
48
|
-
/**
|
|
49
|
-
* User facing: list of non-local user's presence objects.
|
|
50
|
-
*/
|
|
51
|
-
const otherUsers = allUsers.filter((user) => !user.isLocalUser);
|
|
52
|
-
/**
|
|
53
|
-
* User facing: local user's presence object.
|
|
54
|
-
*/
|
|
55
|
-
const localUser = allUsers.find((user) => user.isLocalUser);
|
|
56
|
-
const { container } = useFluidObjectsContext();
|
|
57
|
-
/**
|
|
58
|
-
* User facing: callback to update the local user's custom data for their follow state.
|
|
59
|
-
*/
|
|
60
|
-
const update = React.useCallback((stateValue) => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
if (!container) {
|
|
62
|
-
throw new ActionContainerNotJoinedError("liveFollowMode", "update");
|
|
63
|
-
}
|
|
64
|
-
if (liveFollowMode === undefined) {
|
|
65
|
-
throw new ActionLiveDataObjectUndefinedError("liveFollowMode", "update");
|
|
66
|
-
}
|
|
67
|
-
if (!liveFollowMode.isInitialized) {
|
|
68
|
-
throw new ActionLiveDataObjectInitializedError("liveFollowMode", "update");
|
|
69
|
-
}
|
|
70
|
-
return yield liveFollowMode.update(stateValue);
|
|
71
|
-
}), [container, liveFollowMode]);
|
|
72
|
-
/**
|
|
73
|
-
* User facing: callback to start presenting.
|
|
74
|
-
*/
|
|
75
|
-
const startPresenting = React.useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
if (!container) {
|
|
77
|
-
throw new ActionContainerNotJoinedError("liveFollowMode", "startPresenting");
|
|
78
|
-
}
|
|
79
|
-
if (liveFollowMode === undefined) {
|
|
80
|
-
throw new ActionLiveDataObjectUndefinedError("liveFollowMode", "startPresenting");
|
|
81
|
-
}
|
|
82
|
-
if (!liveFollowMode.isInitialized) {
|
|
83
|
-
throw new ActionLiveDataObjectInitializedError("liveFollowMode", "startPresenting");
|
|
84
|
-
}
|
|
85
|
-
return yield liveFollowMode.startPresenting();
|
|
86
|
-
}), [container, liveFollowMode]);
|
|
87
|
-
/**
|
|
88
|
-
* User facing: callback to stop presenting.
|
|
89
|
-
*/
|
|
90
|
-
const stopPresenting = React.useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
if (!container) {
|
|
92
|
-
throw new ActionContainerNotJoinedError("liveFollowMode", "stopPresenting");
|
|
93
|
-
}
|
|
94
|
-
if (liveFollowMode === undefined) {
|
|
95
|
-
throw new ActionLiveDataObjectUndefinedError("liveFollowMode", "stopPresenting");
|
|
96
|
-
}
|
|
97
|
-
if (!liveFollowMode.isInitialized) {
|
|
98
|
-
throw new ActionLiveDataObjectInitializedError("liveFollowMode", "stopPresenting");
|
|
99
|
-
}
|
|
100
|
-
return yield liveFollowMode.stopPresenting();
|
|
101
|
-
}), [container, liveFollowMode]);
|
|
102
|
-
/**
|
|
103
|
-
* User facing: callback to suspend sync.
|
|
104
|
-
*/
|
|
105
|
-
const beginSuspension = React.useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
if (!container) {
|
|
107
|
-
throw new ActionContainerNotJoinedError("liveFollowMode", "syncToPresenter");
|
|
108
|
-
}
|
|
109
|
-
if (liveFollowMode === undefined) {
|
|
110
|
-
throw new ActionLiveDataObjectUndefinedError("liveFollowMode", "syncToPresenter");
|
|
111
|
-
}
|
|
112
|
-
if (!liveFollowMode.isInitialized) {
|
|
113
|
-
throw new ActionLiveDataObjectInitializedError("liveFollowMode", "syncToPresenter");
|
|
114
|
-
}
|
|
115
|
-
return yield liveFollowMode.beginSuspension();
|
|
116
|
-
}), [container, liveFollowMode]);
|
|
117
|
-
/**
|
|
118
|
-
* User facing: callback to end current suspension.
|
|
119
|
-
*/
|
|
120
|
-
const endSuspension = React.useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
if (!container) {
|
|
122
|
-
throw new ActionContainerNotJoinedError("liveFollowMode", "syncToPresenter");
|
|
123
|
-
}
|
|
124
|
-
if (liveFollowMode === undefined) {
|
|
125
|
-
throw new ActionLiveDataObjectUndefinedError("liveFollowMode", "syncToPresenter");
|
|
126
|
-
}
|
|
127
|
-
if (!liveFollowMode.isInitialized) {
|
|
128
|
-
throw new ActionLiveDataObjectInitializedError("liveFollowMode", "syncToPresenter");
|
|
129
|
-
}
|
|
130
|
-
return yield liveFollowMode.endSuspension();
|
|
131
|
-
}), [container, liveFollowMode]);
|
|
132
|
-
/**
|
|
133
|
-
* User facing: callback to follow a specific user.
|
|
134
|
-
*/
|
|
135
|
-
const followUser = React.useCallback((userId) => __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
if (!container) {
|
|
137
|
-
throw new ActionContainerNotJoinedError("liveFollowMode", "followUser");
|
|
138
|
-
}
|
|
139
|
-
if (liveFollowMode === undefined) {
|
|
140
|
-
throw new ActionLiveDataObjectUndefinedError("liveFollowMode", "followUser");
|
|
141
|
-
}
|
|
142
|
-
if (!liveFollowMode.isInitialized) {
|
|
143
|
-
throw new ActionLiveDataObjectInitializedError("liveFollowMode", "followUser");
|
|
144
|
-
}
|
|
145
|
-
return yield liveFollowMode.followUser(userId);
|
|
146
|
-
}), [container, liveFollowMode]);
|
|
147
|
-
/**
|
|
148
|
-
* User facing: callback to stop following a user.
|
|
149
|
-
*/
|
|
150
|
-
const stopFollowing = React.useCallback(() => __awaiter(this, void 0, void 0, function* () {
|
|
151
|
-
if (!container) {
|
|
152
|
-
throw new ActionContainerNotJoinedError("liveFollowMode", "stopFollowing");
|
|
153
|
-
}
|
|
154
|
-
if (liveFollowMode === undefined) {
|
|
155
|
-
throw new ActionLiveDataObjectUndefinedError("liveFollowMode", "stopFollowing");
|
|
156
|
-
}
|
|
157
|
-
if (!liveFollowMode.isInitialized) {
|
|
158
|
-
throw new ActionLiveDataObjectInitializedError("liveFollowMode", "stopFollowing");
|
|
159
|
-
}
|
|
160
|
-
return yield liveFollowMode.stopFollowing();
|
|
161
|
-
}), [container, liveFollowMode]);
|
|
162
|
-
/**
|
|
163
|
-
* Setup change listeners and start `LiveFollowMode` if needed
|
|
164
|
-
*/
|
|
165
|
-
React.useEffect(() => {
|
|
166
|
-
if (liveFollowMode === undefined)
|
|
167
|
-
return;
|
|
168
|
-
const onPresenceChanged = () => {
|
|
169
|
-
const updatedLocalUsers = [];
|
|
170
|
-
liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.getUsers().forEach((user) => {
|
|
171
|
-
updatedLocalUsers.push(user);
|
|
172
|
-
});
|
|
173
|
-
setAllUsers(updatedLocalUsers);
|
|
174
|
-
};
|
|
175
|
-
liveFollowMode.on("presenceChanged", onPresenceChanged);
|
|
176
|
-
const onStateChanged = () => {
|
|
177
|
-
setState(liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.state);
|
|
178
|
-
};
|
|
179
|
-
liveFollowMode.on("stateChanged", onStateChanged);
|
|
180
|
-
if (liveFollowMode.initializeState ===
|
|
181
|
-
LiveDataObjectInitializeState.needed) {
|
|
182
|
-
liveFollowMode.initialize(isInitialDataCallback(initialData)
|
|
183
|
-
? initialData()
|
|
184
|
-
: initialData, allowedRoles);
|
|
185
|
-
}
|
|
186
|
-
onPresenceChanged();
|
|
187
|
-
onStateChanged();
|
|
188
|
-
return () => {
|
|
189
|
-
liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.off("presenceChanged", onPresenceChanged);
|
|
190
|
-
liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.off("stateChanged", onStateChanged);
|
|
191
|
-
};
|
|
192
|
-
}, [liveFollowMode]);
|
|
193
|
-
return {
|
|
194
|
-
state,
|
|
195
|
-
localUser,
|
|
196
|
-
otherUsers,
|
|
197
|
-
allUsers,
|
|
198
|
-
liveFollowMode,
|
|
199
|
-
update,
|
|
200
|
-
startPresenting,
|
|
201
|
-
stopPresenting,
|
|
202
|
-
beginSuspension,
|
|
203
|
-
endSuspension,
|
|
204
|
-
followUser,
|
|
205
|
-
stopFollowing,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function isInitialDataCallback(value) {
|
|
209
|
-
return typeof value === "function";
|
|
210
|
-
}
|
|
211
|
-
//# sourceMappingURL=useLiveFollowMode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveFollowMode.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveFollowMode.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EAGH,6BAA6B,EAC7B,cAAc,GAGjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,M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C;QACF,cAAc,CAAC,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QACxD,MAAM,cAAc,GAAG,GAAG,EAAE;YACxB,QAAQ,CAAC,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC;QACF,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAElD,IACI,cAAc,CAAC,eAAe;YAC9B,6BAA6B,CAAC,MAAM,EACtC;YACE,cAAc,CAAC,UAAU,CACrB,qBAAqB,CAAQ,WAAW,CAAC;gBACrC,CAAC,CAAC,WAAW,EAAE;gBACf,CAAC,CAAC,WAAW,EACjB,YAAY,CACf,CAAC;SACL;QACD,iBAAiB,EAAE,CAAC;QACpB,cAAc,EAAE,CAAC;QAEjB,OAAO,GAAG,EAAE;YACR,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;YAC1D,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACxD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO;QACH,KAAK;QACL,SAAS;QACT,UAAU;QACV,QAAQ;QACR,cAAc;QACd,MAAM;QACN,eAAe;QACf,cAAc;QACd,eAAe;QACf,aAAa;QACb,UAAU;QACV,aAAa;KAChB,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAQ,KAAU;IAC5C,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { PresenceState, UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
-
import { IUseLivePresenceResults } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* React hook for using a Live Share `LivePresence`.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Use this hook if you want to track presence for who is currently using this component, such as
|
|
12
|
-
* who is online or who is viewing a specific document. With presence, you can sent along any custom
|
|
13
|
-
* user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
|
|
14
|
-
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
15
|
-
*
|
|
16
|
-
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
17
|
-
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
|
|
18
|
-
* @param initialData Optional. Initial presence data object for the user. Can be value or a function to get the value.
|
|
19
|
-
* @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
|
|
20
|
-
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
21
|
-
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
22
|
-
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
23
|
-
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
24
|
-
*/
|
|
25
|
-
export declare function useLivePresence<TData extends object = object>(uniqueKey: string, initialData?: TData | (() => TData) | undefined, initialPresenceState?: PresenceState, allowedRoles?: UserMeetingRole[]): IUseLivePresenceResults<TData>;
|
|
26
|
-
//# sourceMappingURL=useLivePresence.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLivePresence.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,aAAa,EAEb,eAAe,EAElB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAA8B,MAAM,UAAU,CAAC;AAS/E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACzD,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,SAAS,EAC/C,oBAAoB,GAAE,aAAoC,EAC1D,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,uBAAuB,CAAC,KAAK,CAAC,CAgGhC"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
import { PresenceState, LivePresence, LiveDataObjectInitializeState, } from "@microsoft/live-share";
|
|
15
|
-
import React from "react";
|
|
16
|
-
import { useDynamicDDS } from "../shared-hooks";
|
|
17
|
-
import { useFluidObjectsContext } from "../providers";
|
|
18
|
-
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
|
|
19
|
-
/**
|
|
20
|
-
* React hook for using a Live Share `LivePresence`.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* Use this hook if you want to track presence for who is currently using this component, such as
|
|
24
|
-
* who is online or who is viewing a specific document. With presence, you can sent along any custom
|
|
25
|
-
* user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
|
|
26
|
-
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
27
|
-
*
|
|
28
|
-
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
29
|
-
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
|
|
30
|
-
* @param initialData Optional. Initial presence data object for the user. Can be value or a function to get the value.
|
|
31
|
-
* @param initialPresenceState Optional. Initial status of the user's presence. Default is online.
|
|
32
|
-
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
33
|
-
* will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
|
|
34
|
-
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
35
|
-
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
36
|
-
*/
|
|
37
|
-
export function useLivePresence(uniqueKey, initialData, initialPresenceState = PresenceState.online, allowedRoles) {
|
|
38
|
-
/**
|
|
39
|
-
* Stateful all user presence list and its non-user-facing setter method.
|
|
40
|
-
*/
|
|
41
|
-
const [allUsers, setAllUsers] = React.useState([]);
|
|
42
|
-
/**
|
|
43
|
-
* User facing: dynamically load the DDS for the given unique key.
|
|
44
|
-
*/
|
|
45
|
-
const { dds: livePresence } = useDynamicDDS(uniqueKey, (LivePresence));
|
|
46
|
-
/**
|
|
47
|
-
* User facing: list of non-local user's presence objects.
|
|
48
|
-
*/
|
|
49
|
-
const otherUsers = allUsers.filter((user) => !user.isLocalUser);
|
|
50
|
-
/**
|
|
51
|
-
* User facing: local user's presence object.
|
|
52
|
-
*/
|
|
53
|
-
const localUser = allUsers.find((user) => user.isLocalUser);
|
|
54
|
-
const { container } = useFluidObjectsContext();
|
|
55
|
-
/**
|
|
56
|
-
* User facing: callback to update the local user's presence.
|
|
57
|
-
*/
|
|
58
|
-
const updatePresence = React.useCallback((data, state) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
if (!container) {
|
|
60
|
-
throw new ActionContainerNotJoinedError("livePresence", "updatePresence");
|
|
61
|
-
}
|
|
62
|
-
if (livePresence === undefined) {
|
|
63
|
-
throw new ActionLiveDataObjectUndefinedError("livePresence", "updatePresence");
|
|
64
|
-
}
|
|
65
|
-
if (!livePresence.isInitialized) {
|
|
66
|
-
throw new ActionLiveDataObjectInitializedError("livePresence", "updatePresence");
|
|
67
|
-
}
|
|
68
|
-
return yield livePresence.update(data, state);
|
|
69
|
-
}), [container, livePresence]);
|
|
70
|
-
/**
|
|
71
|
-
* Setup change listeners and start `LivePresence` if needed
|
|
72
|
-
*/
|
|
73
|
-
React.useEffect(() => {
|
|
74
|
-
if (livePresence === undefined)
|
|
75
|
-
return;
|
|
76
|
-
const onPresenceChanged = () => {
|
|
77
|
-
const updatedLocalUsers = [];
|
|
78
|
-
livePresence === null || livePresence === void 0 ? void 0 : livePresence.getUsers().forEach((user) => {
|
|
79
|
-
updatedLocalUsers.push(user);
|
|
80
|
-
});
|
|
81
|
-
setAllUsers(updatedLocalUsers);
|
|
82
|
-
};
|
|
83
|
-
livePresence.on("presenceChanged", onPresenceChanged);
|
|
84
|
-
if (livePresence.initializeState ===
|
|
85
|
-
LiveDataObjectInitializeState.needed) {
|
|
86
|
-
livePresence.initialize(isInitialDataCallback(initialData)
|
|
87
|
-
? initialData()
|
|
88
|
-
: initialData, initialPresenceState, allowedRoles);
|
|
89
|
-
}
|
|
90
|
-
onPresenceChanged();
|
|
91
|
-
return () => {
|
|
92
|
-
livePresence === null || livePresence === void 0 ? void 0 : livePresence.off("presenceChanged", onPresenceChanged);
|
|
93
|
-
};
|
|
94
|
-
}, [livePresence]);
|
|
95
|
-
return {
|
|
96
|
-
localUser,
|
|
97
|
-
otherUsers,
|
|
98
|
-
allUsers,
|
|
99
|
-
livePresence,
|
|
100
|
-
updatePresence,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function isInitialDataCallback(value) {
|
|
104
|
-
return typeof value === "function";
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=useLiv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AAiB,CAAC,CAAC;QAC5D,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO;QACH,SAAS;QACT,UAAU;QACV,QAAQ;QACR,YAAY;QACZ,cAAc;KACjB,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAQ,KAAU;IAC5C,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { LiveState, UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
-
import { SetLiveStateAction } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* React hook for using a Live Share `LiveState`.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Use this hook if you want to synchronize app state that will reset when all users leave the session.
|
|
12
|
-
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
13
|
-
*
|
|
14
|
-
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
|
|
15
|
-
* @param initialState Optional. the initial state value of type TState
|
|
16
|
-
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
17
|
-
* @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
|
|
18
|
-
* The setter returns a void promise, which will throw if the user does not have the required roles to set.
|
|
19
|
-
*/
|
|
20
|
-
export declare function useLiveState<TState = any>(uniqueKey: string, initialState: TState, allowedRoles?: UserMeetingRole[]): [TState, SetLiveStateAction<TState>, LiveState<TState> | undefined];
|
|
21
|
-
//# sourceMappingURL=useLiveState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveState.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,SAAS,EACT,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAU9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,CAAC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAwErE"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
import { LiveDataObjectInitializeState, LiveState, } from "@microsoft/live-share";
|
|
15
|
-
import React from "react";
|
|
16
|
-
import { useDynamicDDS } from "../shared-hooks";
|
|
17
|
-
import { useFluidObjectsContext } from "../providers";
|
|
18
|
-
import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, isPrevStateCallback, } from "../internal";
|
|
19
|
-
/**
|
|
20
|
-
* React hook for using a Live Share `LiveState`.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* Use this hook if you want to synchronize app state that will reset when all users leave the session.
|
|
24
|
-
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
25
|
-
*
|
|
26
|
-
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
|
|
27
|
-
* @param initialState Optional. the initial state value of type TState
|
|
28
|
-
* @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
|
|
29
|
-
* @returns ordered values: first value is the synchronized state value and the second is a setter to change the state value.
|
|
30
|
-
* The setter returns a void promise, which will throw if the user does not have the required roles to set.
|
|
31
|
-
*/
|
|
32
|
-
export function useLiveState(uniqueKey, initialState, allowedRoles) {
|
|
33
|
-
const [currentState, setCurrentState] = React.useState(initialState);
|
|
34
|
-
/**
|
|
35
|
-
* User facing: dynamically load the DDS for the given unique key.
|
|
36
|
-
*/
|
|
37
|
-
const { dds: liveState } = useDynamicDDS(uniqueKey, (LiveState));
|
|
38
|
-
const { container } = useFluidObjectsContext();
|
|
39
|
-
/**
|
|
40
|
-
* Change state callback that is user facing
|
|
41
|
-
* @param state TState to set
|
|
42
|
-
* @returns void promise, which will throw if the user does not have the required roles
|
|
43
|
-
*/
|
|
44
|
-
const setState = React.useCallback((state) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (!container) {
|
|
46
|
-
throw new ActionContainerNotJoinedError("liveState", "setState");
|
|
47
|
-
}
|
|
48
|
-
if (liveState === undefined) {
|
|
49
|
-
throw new ActionLiveDataObjectUndefinedError("liveState", "setState");
|
|
50
|
-
}
|
|
51
|
-
if (!liveState.isInitialized) {
|
|
52
|
-
throw new ActionLiveDataObjectInitializedError("liveState", "setState");
|
|
53
|
-
}
|
|
54
|
-
const valueToSet = isPrevStateCallback(state)
|
|
55
|
-
? state(liveState.state)
|
|
56
|
-
: state;
|
|
57
|
-
return yield liveState.set(valueToSet);
|
|
58
|
-
}), [container, liveState]);
|
|
59
|
-
/**
|
|
60
|
-
* Setup change listeners and start `LiveState` if needed
|
|
61
|
-
*/
|
|
62
|
-
React.useEffect(() => {
|
|
63
|
-
if (liveState === undefined)
|
|
64
|
-
return;
|
|
65
|
-
const onStateChanged = (state) => {
|
|
66
|
-
setCurrentState(state);
|
|
67
|
-
};
|
|
68
|
-
liveState.on("stateChanged", onStateChanged);
|
|
69
|
-
if (liveState.initializeState === LiveDataObjectInitializeState.needed) {
|
|
70
|
-
liveState
|
|
71
|
-
.initialize(initialState, allowedRoles)
|
|
72
|
-
.then(() => onStateChanged(liveState.state));
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
onStateChanged(liveState.state);
|
|
76
|
-
}
|
|
77
|
-
return () => {
|
|
78
|
-
liveState === null || liveState === void 0 ? void 0 : liveState.off("stateChanged", onStateChanged);
|
|
79
|
-
};
|
|
80
|
-
}, [liveState]);
|
|
81
|
-
return [currentState, setState, liveState];
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=useLiveState.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveState.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveState.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EACH,6BAA6B,EAC7B,SAAS,GAEZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACH,6BAA6B,EAC7B,oCAAoC,EACpC,kCAAkC,EAClC,mBAAmB,GACtB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CACxB,SAAiB,EACjB,YAAoB,EACpB,YAAgC;IAEhC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GACjC,KAAK,CA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AAC;iBACtC,IAAI,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;SACpD;aAAM;YACH,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SACnC;QAED,OAAO,GAAG,EAAE;YACR,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACnD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { UserMeetingRole } from "@microsoft/live-share";
|
|
6
|
-
import { IUseLiveTimerResults, OnTimerDidFinishAction, OnTimerDidPauseAction, OnTimerDidPlayAction, OnTimerDidStartAction, OnTimerTickAction } from "../types";
|
|
7
|
-
/**
|
|
8
|
-
* React hook for using Live Share's `LiveTimer` DDS.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Use this hook to create a synchronized countdown timer in your app or to schedule synchronized tasks.
|
|
12
|
-
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
13
|
-
*
|
|
14
|
-
* @param uniqueKey the unique key for the `LiveTimer`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
|
|
15
|
-
* @param allowedRoles Optional. the user roles that are allowed to start/stop/pause the timer.
|
|
16
|
-
* @param tickRate Optional. the interval in which the `milliRemaining` state should be updated and the `onTick` callback will trigger.
|
|
17
|
-
* @param onTick Optional. event handler callback for when an active timer ticks.
|
|
18
|
-
* @param onStart Optional. event handler callback for when the timer is started.
|
|
19
|
-
* @param onPause Optional. event handler callback for when the timer is paused.
|
|
20
|
-
* @param onPlay Optional. event handler callback for when the timer is resumed.
|
|
21
|
-
* @param onFinish Optional. event handler callback for when the timer finishes.
|
|
22
|
-
* @returns results and callbacks exposed via the hook.
|
|
23
|
-
*/
|
|
24
|
-
export declare function useLiveTimer(uniqueKey: string, allowedRoles?: UserMeetingRole[], tickRate?: number, onTick?: OnTimerTickAction, onStart?: OnTimerDidStartAction, onPause?: OnTimerDidPauseAction, onPlay?: OnTimerDidPlayAction, onFinish?: OnTimerDidFinishAction): IUseLiveTimerResults;
|
|
25
|
-
//# sourceMappingURL=useLiveTimer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveTimer.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveTimer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EAIpB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,UAAU,CAAC;AASlB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CACxB,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,eAAe,EAAE,EAChC,QAAQ,CAAC,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE,qBAAqB,EAC/B,MAAM,CAAC,EAAE,oBAAoB,EAC7B,QAAQ,CAAC,EAAE,sBAAsB,GAClC,oBAAoB,CA8JtB"}
|