@microsoft/live-share-react 1.0.0-preview.10 → 1.0.0-preview.12
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 +88 -21
- package/bin/live-hooks/useLiveCanvas.d.ts +3 -3
- package/bin/live-hooks/useLiveCanvas.d.ts.map +1 -1
- package/bin/live-hooks/useLiveCanvas.js +7 -15
- package/bin/live-hooks/useLiveCanvas.js.map +1 -1
- package/bin/live-hooks/useLiveEvent.js +1 -1
- package/bin/live-hooks/useLiveEvent.js.map +1 -1
- package/bin/live-hooks/useLivePresence.d.ts +1 -1
- package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
- package/bin/live-hooks/useLivePresence.js +4 -4
- package/bin/live-hooks/useLivePresence.js.map +1 -1
- package/bin/shared-hooks/index.d.ts +0 -1
- package/bin/shared-hooks/index.d.ts.map +1 -1
- package/bin/shared-hooks/index.js +0 -1
- package/bin/shared-hooks/index.js.map +1 -1
- package/bin/types/ActionTypes.d.ts +1 -1
- package/bin/types/ActionTypes.d.ts.map +1 -1
- package/package.json +13 -9
- package/src/live-hooks/useLiveCanvas.ts +11 -19
- package/src/live-hooks/useLiveEvent.ts +1 -1
- package/src/live-hooks/useLivePresence.ts +10 -9
- package/src/shared-hooks/index.ts +0 -1
- package/src/types/ActionTypes.ts +1 -1
- package/src/shared-hooks/useTaskManager.ts +0 -82
- package/tinylicious.log +0 -4
package/README.md
CHANGED
|
@@ -48,13 +48,13 @@ export function SharedCheckbox() {
|
|
|
48
48
|
To add the latest version of the SDK to your application using NPM:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
-
npm install @microsoft/live-share-react --save
|
|
51
|
+
npm install fluid-framework @fluidframework/azure-client @microsoft/live-share @microsoft/live-share-media @microsoft/live-share-canvas @microsoft/live-share-react --save
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
or using [Yarn](https://yarnpkg.com/):
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
yarn add @microsoft/live-share-react
|
|
57
|
+
yarn add fluid-framework @fluidframework/azure-client @microsoft/live-share @microsoft/live-share-media @microsoft/live-share-canvas @microsoft/live-share-react
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
### Building package
|
|
@@ -181,7 +181,7 @@ import { PresenceState } from "@microsoft/live-share";
|
|
|
181
181
|
export function OnlineUsers() {
|
|
182
182
|
const { localUser, allUsers, updatePresence } = useLivePresence(
|
|
183
183
|
"CUSTOM-USER-ID", // optional user id
|
|
184
|
-
{
|
|
184
|
+
{ favoriteColor: "red" } // optional custom data object
|
|
185
185
|
);
|
|
186
186
|
return (
|
|
187
187
|
<div>
|
|
@@ -190,16 +190,18 @@ export function OnlineUsers() {
|
|
|
190
190
|
{allUsers
|
|
191
191
|
.filter((user) => user.state === PresenceState.online)
|
|
192
192
|
.map((user) => (
|
|
193
|
-
<div key={user.userId}>
|
|
193
|
+
<div key={user.userId}>
|
|
194
|
+
{user.displayName + " " + user.data!.favoriteColor}
|
|
195
|
+
</div>
|
|
194
196
|
))}
|
|
195
197
|
</div>
|
|
196
198
|
<button
|
|
197
199
|
onClick={() => {
|
|
198
200
|
updatePresence(
|
|
201
|
+
localUser.data,
|
|
199
202
|
localUser?.state === PresenceState.offline
|
|
200
203
|
? PresenceState.online
|
|
201
204
|
: PresenceState.offline,
|
|
202
|
-
localUser.data
|
|
203
205
|
);
|
|
204
206
|
}}
|
|
205
207
|
>
|
|
@@ -479,25 +481,89 @@ Implementations may vary for each dynamic object & hook. We will try and update
|
|
|
479
481
|
|
|
480
482
|
Example:
|
|
481
483
|
|
|
482
|
-
```
|
|
483
|
-
import
|
|
484
|
+
```typescript
|
|
485
|
+
import React from "react";
|
|
484
486
|
import { useDynamicDDS } from "@microsoft/live-share-react";
|
|
485
|
-
import {
|
|
486
|
-
import {
|
|
487
|
-
|
|
488
|
-
// Register
|
|
489
|
-
DynamicObjectRegistry.registerObjectClass(
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
487
|
+
import { DynamicObjectRegistry } from "@microsoft/live-share";
|
|
488
|
+
import { TaskManager } from "@fluid-experimental/task-manager";
|
|
489
|
+
|
|
490
|
+
// Register TaskManager as dynamic object
|
|
491
|
+
DynamicObjectRegistry.registerObjectClass(TaskManager, TaskManager.getFactory().type);
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* A hook for joining a queue to lock tasks for a given id. Guaranteed to have only one user assigned to a task at a time.
|
|
495
|
+
*
|
|
496
|
+
* @param uniqueKey the unique key for the TaskManager DDS
|
|
497
|
+
* @param taskId the task id to lock
|
|
498
|
+
* @returns stateful data about the status of the task lock
|
|
499
|
+
*/
|
|
500
|
+
export const useTaskManager = (uniqueKey: string, taskId?: string): {
|
|
501
|
+
lockedTask: boolean;
|
|
502
|
+
taskManager: TaskManager | undefined;
|
|
503
|
+
} => {
|
|
504
|
+
/**
|
|
505
|
+
* TaskId currently in queue for
|
|
506
|
+
*/
|
|
507
|
+
const currentTaskIdRef = React.useRef<string | undefined>(undefined);
|
|
508
|
+
/**
|
|
509
|
+
* Stateful boolean that is true when the user is currently assigned the task
|
|
510
|
+
*/
|
|
511
|
+
const [lockedTask, setLockedTask] = React.useState<boolean>(false);
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* User facing: dynamically load the TaskManager DDS for the given unique key.
|
|
515
|
+
*/
|
|
516
|
+
const { dds: taskManager } = useDynamicDDS<TaskManager>(uniqueKey, TaskManager);
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* When the task id changes, lock the task. When the task id is undefined, abandon the task.
|
|
520
|
+
*/
|
|
521
|
+
React.useEffect(() => {
|
|
522
|
+
let mounted = true;
|
|
523
|
+
if (taskManager) {
|
|
524
|
+
if (taskId && currentTaskIdRef.current !== taskId) {
|
|
525
|
+
if (currentTaskIdRef.current) {
|
|
526
|
+
taskManager.abandon(currentTaskIdRef.current);
|
|
527
|
+
setLockedTask(false);
|
|
528
|
+
}
|
|
529
|
+
currentTaskIdRef.current = taskId;
|
|
530
|
+
const onLockTask = async () => {
|
|
531
|
+
try {
|
|
532
|
+
await taskManager.lockTask(taskId);
|
|
533
|
+
if (mounted) {
|
|
534
|
+
setLockedTask(true);
|
|
535
|
+
}
|
|
536
|
+
} catch {
|
|
537
|
+
if (mounted) {
|
|
538
|
+
setLockedTask(false);
|
|
539
|
+
currentTaskIdRef.current = undefined;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
onLockTask();
|
|
544
|
+
} else if (!taskId && currentTaskIdRef.current) {
|
|
545
|
+
taskManager.abandon(currentTaskIdRef.current);
|
|
546
|
+
setLockedTask(false);
|
|
547
|
+
currentTaskIdRef.current = undefined;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* When the component unmounts, abandon the task if it is still locked
|
|
552
|
+
*/
|
|
553
|
+
return () => {
|
|
554
|
+
mounted = false;
|
|
555
|
+
if (currentTaskIdRef.current) {
|
|
556
|
+
taskManager?.abandon(currentTaskIdRef.current);
|
|
557
|
+
}
|
|
558
|
+
currentTaskIdRef.current = undefined;
|
|
559
|
+
}
|
|
560
|
+
}, [taskManager, taskId]);
|
|
561
|
+
|
|
497
562
|
return {
|
|
498
|
-
|
|
563
|
+
lockedTask,
|
|
564
|
+
taskManager,
|
|
499
565
|
};
|
|
500
|
-
}
|
|
566
|
+
};
|
|
501
567
|
```
|
|
502
568
|
|
|
503
569
|
## Code samples
|
|
@@ -518,6 +584,7 @@ The Live Share SDK contains dependencies for [@microsoft/teams-js](https://www.n
|
|
|
518
584
|
|
|
519
585
|
| @microsoft/live-share | @microsoft/teams-js | fluid-framework | @microsoft/live-share-\* | @fluidframework/azure-client | @microsoft/TeamsFx | @microsoft/TeamsFx-react |
|
|
520
586
|
| --------------------- | -------------------- | --------------- | -------------------------- | ---------------------------- | ------------------------------- | ------------------------------- |
|
|
587
|
+
| 1.0.0-preview.12 | ^2.11.0 | ^1.2.3 | 1.0.0-preview.12 (optional) | ^1.0.0 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
|
|
521
588
|
| 1.0.0-preview.10 | ^2.10.1 | ~1.2.3 | 1.0.0-preview.10 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
|
|
522
589
|
| 1.0.0-preview.8 | ^2.5.0 | ~1.2.3 | 1.0.0-preview.10 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
|
|
523
590
|
| 1.0.0-preview.3 | 2.0.0-experimental.1 | ~1.2.3 | 1.0.0-preview.3 (optional) | ~1.0.2 (optional) | 2.0.0-experimental.0 (optional) | 2.0.0-experimental.0 (optional) |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Licensed under the Microsoft Live Share SDK License.
|
|
4
4
|
*/
|
|
5
|
-
import { CanvasReferencePoint, IBrush, InkingTool, IPoint
|
|
5
|
+
import { CanvasReferencePoint, IBrush, InkingTool, IPoint } from "@microsoft/live-share-canvas";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { IUseLiveCanvasResults } from "../types";
|
|
8
8
|
/**
|
|
@@ -21,8 +21,8 @@ import { IUseLiveCanvasResults } from "../types";
|
|
|
21
21
|
* @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
|
|
22
22
|
* @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
|
|
23
23
|
* @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
|
|
24
|
-
* @param
|
|
24
|
+
* @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
|
|
25
25
|
* @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
|
|
26
26
|
*/
|
|
27
|
-
export declare function useLiveCanvas(uniqueKey: string, canvasElementRef: React.RefObject<HTMLElement | null> | string, active?: boolean, tool?: InkingTool, lineBrush?: IBrush, offset?: IPoint, scale?: number, referencePoint?: CanvasReferencePoint, isCursorShared?: boolean,
|
|
27
|
+
export declare function useLiveCanvas(uniqueKey: string, canvasElementRef: React.RefObject<HTMLElement | null> | string, active?: boolean, tool?: InkingTool, lineBrush?: IBrush, offset?: IPoint, scale?: number, referencePoint?: CanvasReferencePoint, isCursorShared?: boolean, localUserPictureUrl?: string): IUseLiveCanvasResults;
|
|
28
28
|
//# sourceMappingURL=useLiveCanvas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveCanvas.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,oBAAoB,EACpB,MAAM,EAEN,UAAU,EACV,MAAM,
|
|
1
|
+
{"version":3,"file":"useLiveCanvas.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,oBAAoB,EACpB,MAAM,EAEN,UAAU,EACV,MAAM,EAET,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,MAAM,EAC9D,MAAM,CAAC,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,oBAAoB,EACrC,cAAc,CAAC,EAAE,OAAO,EACxB,mBAAmB,CAAC,EAAE,MAAM,GAC7B,qBAAqB,CA6IvB"}
|
|
@@ -22,10 +22,10 @@ import { isRefObject } from "../utils";
|
|
|
22
22
|
* @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
|
|
23
23
|
* @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
|
|
24
24
|
* @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
|
|
25
|
-
* @param
|
|
25
|
+
* @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
|
|
26
26
|
* @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
|
|
27
27
|
*/
|
|
28
|
-
export function useLiveCanvas(uniqueKey, canvasElementRef, active, tool, lineBrush, offset, scale, referencePoint, isCursorShared,
|
|
28
|
+
export function useLiveCanvas(uniqueKey, canvasElementRef, active, tool, lineBrush, offset, scale, referencePoint, isCursorShared, localUserPictureUrl) {
|
|
29
29
|
/**
|
|
30
30
|
* User facing: inking manager instance
|
|
31
31
|
*/
|
|
@@ -134,8 +134,7 @@ export function useLiveCanvas(uniqueKey, canvasElementRef, active, tool, lineBru
|
|
|
134
134
|
* Sets the isCursorShared of the liveCanvas based on the 'isCursorShared' prop
|
|
135
135
|
*/
|
|
136
136
|
React.useEffect(() => {
|
|
137
|
-
if (liveCanvas &&
|
|
138
|
-
isCursorShared !== undefined) {
|
|
137
|
+
if (liveCanvas && isCursorShared !== undefined) {
|
|
139
138
|
liveCanvas.isCursorShared = isCursorShared;
|
|
140
139
|
}
|
|
141
140
|
}, [isCursorShared, liveCanvas]);
|
|
@@ -143,19 +142,12 @@ export function useLiveCanvas(uniqueKey, canvasElementRef, active, tool, lineBru
|
|
|
143
142
|
* Sets the onGetLocalUserInfo method of the liveCanvas based on the 'localUserCursor' prop
|
|
144
143
|
*/
|
|
145
144
|
React.useEffect(() => {
|
|
146
|
-
if (liveCanvas &&
|
|
147
|
-
liveCanvas.
|
|
148
|
-
return
|
|
149
|
-
displayName: localUserCursor.displayName,
|
|
150
|
-
pictureUri: localUserCursor.pictureUri,
|
|
151
|
-
};
|
|
145
|
+
if (liveCanvas && localUserPictureUrl) {
|
|
146
|
+
liveCanvas.onGetLocalUserPictureUrl = () => {
|
|
147
|
+
return localUserPictureUrl;
|
|
152
148
|
};
|
|
153
149
|
}
|
|
154
|
-
}, [
|
|
155
|
-
localUserCursor === null || localUserCursor === void 0 ? void 0 : localUserCursor.displayName,
|
|
156
|
-
localUserCursor === null || localUserCursor === void 0 ? void 0 : localUserCursor.pictureUri,
|
|
157
|
-
liveCanvas,
|
|
158
|
-
]);
|
|
150
|
+
}, [localUserPictureUrl, liveCanvas]);
|
|
159
151
|
/**
|
|
160
152
|
* Return hook response
|
|
161
153
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveCanvas.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,aAAa,
|
|
1
|
+
{"version":3,"file":"useLiveCanvas.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,aAAa,EAGb,UAAU,GACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,aAAa,CACzB,SAAiB,EACjB,gBAA8D,EAC9D,MAAgB,EAChB,IAAiB,EACjB,SAAkB,EAClB,MAAe,EACf,KAAc,EACd,cAAqC,EACrC,cAAwB,EACxB,mBAA4B;IAE5B;;OAEG;IACH,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,K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AAE;QACC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,KAAK;QAChB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG;QACd,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO;QAClB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI;QACf,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ;QACnB,aAAa;KAChB,CAAC,CAAC;IAEH;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,UAAU,IAAI,cAAc,KAAK,SAAS,EAAE;YAC5C,UAAU,CAAC,cAAc,GAAG,cAAc,CAAC;SAC9C;IACL,CAAC,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IAEjC;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,UAAU,IAAI,mBAAmB,EAAE;YACnC,UAAU,CAAC,wBAAwB,GAAG,GAAuB,EAAE;gBAC3D,OAAO,mBAAmB,CAAC;YAC/B,CAAC,CAAC;SACL;IACL,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEtC;;OAEG;IACH,OAAO;QACH,aAAa;QACb,UAAU;KACb,CAAC;AACN,CAAC"}
|
|
@@ -45,7 +45,7 @@ export function useLiveEvent(uniqueKey, allowedRoles, onReceivedEvent) {
|
|
|
45
45
|
console.error(new Error("Cannot call emitEvent while liveEvent is not started"));
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.
|
|
48
|
+
liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.send(event);
|
|
49
49
|
}, [liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.isInitialized]);
|
|
50
50
|
/**
|
|
51
51
|
* Setup change listeners and start `LiveEvent` if needed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveEvent.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,eAAe,EAEf,SAAS,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CACxB,SAAiB,EACjB,YAAgC,EAChC,eAAmD;IAEnD;;OAEG;IACH,MAAM,CAAC,WAAW,EAAE,iBAAiB,CAAC,GAClC,KAAK,CAAC,QAAQ,EAA6B,CAAC;IAChD;;;OAGG;IACH,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAA8B,EAAE,CAAC,CAAC;IACnE;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,aAAa,CAAY,SAAS,EAAE,SAAS,CAAC,CAAC;IAE1E;;OAEG;IACH,MAAM,SAAS,GAAgC,KAAK,CAAC,WAAW,CAC5D,CAAC,KAAa,EAAE,EAAE;QACd,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,aAAa,MAAK,SAAS,EAAE;YACxC,OAAO,CAAC,KAAK,CACT,IAAI,KAAK,CACL,mDAAmD,CACtD,CACJ,CAAC;YACF,OAAO;SACV;QACD,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;YAC1B,OAAO,CAAC,KAAK,CACT,IAAI,KAAK,CACL,sDAAsD,CACzD,CACJ,CAAC;YACF,OAAO;SACV;QACD,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,
|
|
1
|
+
{"version":3,"file":"useLiveEvent.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,eAAe,EAEf,SAAS,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;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f,eAAe,CAAG,KAAe,EAAE,KAAK,CAAC,CAAC;YAC1C,4CAA4C;YAC5C,MAAM,QAAQ,GAA8B;gBACxC,KAAK,EAAE,KAAe;gBACtB,KAAK;aACR,CAAC;YACF,YAAY,CAAC,OAAO,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC3D,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC,CAAC;QACF,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACxD,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;YAC1B,mBAAmB;YACnB,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;SACtC;QAED,OAAO,GAAG,EAAE;YACR,qCAAqC;YACrC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC9D,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,aAAa,CAAC,CAAC,CAAC;IAE/B,OAAO;QACH,WAAW;QACX,SAAS,EAAE,YAAY,CAAC,OAAO;QAC/B,SAAS;QACT,SAAS;KACZ,CAAC;AACN,CAAC"}
|
|
@@ -22,5 +22,5 @@ import { IUseLivePresenceResults } from "../types";
|
|
|
22
22
|
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
23
23
|
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
24
24
|
*/
|
|
25
|
-
export declare function useLivePresence<TData extends object = object>(
|
|
25
|
+
export declare function useLivePresence<TData extends object = object>(initialData?: TData | undefined, initialPresenceState?: PresenceState, uniqueKey?: string): IUseLivePresenceResults<TData>;
|
|
26
26
|
//# sourceMappingURL=useLivePresence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLivePresence.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,aAAa,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"useLivePresence.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,aAAa,EAEhB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAA8B,MAAM,UAAU,CAAC;AAG/E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EACzD,WAAW,CAAC,EAAE,KAAK,GAAG,SAAS,EAC/B,oBAAoB,GAAE,aAAoC,EAC1D,SAAS,GAAE,MAAyB,GACrC,uBAAuB,CAAC,KAAK,CAAC,CAwFhC"}
|
|
@@ -23,7 +23,7 @@ import { useDynamicDDS } from "../shared-hooks";
|
|
|
23
23
|
* @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
|
|
24
24
|
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
25
25
|
*/
|
|
26
|
-
export function useLivePresence(
|
|
26
|
+
export function useLivePresence(initialData, initialPresenceState = PresenceState.online, uniqueKey = ":<dds-default>") {
|
|
27
27
|
/**
|
|
28
28
|
* Stateful all user presence list and its non-user-facing setter method.
|
|
29
29
|
*/
|
|
@@ -47,7 +47,7 @@ export function useLivePresence(userId, initialData, initialPresenceState = Pres
|
|
|
47
47
|
/**
|
|
48
48
|
* User facing: callback to update the local user's presence.
|
|
49
49
|
*/
|
|
50
|
-
const updatePresence = React.useCallback((
|
|
50
|
+
const updatePresence = React.useCallback((data, state) => {
|
|
51
51
|
if (!livePresence) {
|
|
52
52
|
console.error(new Error("Cannot call updatePresence when presence is undefined"));
|
|
53
53
|
return;
|
|
@@ -56,7 +56,7 @@ export function useLivePresence(userId, initialData, initialPresenceState = Pres
|
|
|
56
56
|
console.error(new Error("Cannot call updatePresence while presence is not started"));
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
livePresence.
|
|
59
|
+
livePresence.update(data, state);
|
|
60
60
|
}, [livePresence]);
|
|
61
61
|
/**
|
|
62
62
|
* Setup change listeners and start `LivePresence` if needed
|
|
@@ -73,7 +73,7 @@ export function useLivePresence(userId, initialData, initialPresenceState = Pres
|
|
|
73
73
|
};
|
|
74
74
|
livePresence.on("presenceChanged", onPresenceChanged);
|
|
75
75
|
if (!livePresence.isInitialized) {
|
|
76
|
-
livePresence.initialize(
|
|
76
|
+
livePresence.initialize(initialData, initialPresenceState);
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
79
|
onPresenceChanged();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLivePresence.js","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,aAAa,EACb,YAAY,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC3B,
|
|
1
|
+
{"version":3,"file":"useLivePresence.js","sourceRoot":"","sources":["../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,aAAa,EACb,YAAY,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC3B,WAA+B,EAC/B,uBAAsC,aAAa,CAAC,MAAM,EAC1D,YAAoB,gBAAgB;IAEpC;;OAEG;IACH,MAAM,CAAC,QA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GAAG,EAAE;YAC3B,MAAM,iBAAiB,GAA8B,EAAE,CAAC;YACxD,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC3B,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,WAAW,CAAC,iBAAiB,CAAC,CAAC;QACnC,CAAC,CAAC;QACF,YAAY,CAAC,EAAE,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;QAEtD,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE;YAC7B,YAAY,CAAC,UAAU,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;SAC9D;aAAM;YACH,iBAAiB,EAAE,CAAC;SACvB;QAED,OAAO,GAAG,EAAE;YACR,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared-hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shared-hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare type DisposeSharedStateAction = () => void;
|
|
|
18
18
|
export declare type SetLiveStateAction<TState = undefined> = (state: TState) => void;
|
|
19
19
|
export declare type SendLiveEventAction<TEvent> = (event: TEvent) => void;
|
|
20
20
|
export declare type OnReceivedLiveEventAction<TEvent> = (event: TEvent, local: boolean) => void;
|
|
21
|
-
export declare type OnUpdateLivePresenceAction<TData extends object = object> = (
|
|
21
|
+
export declare type OnUpdateLivePresenceAction<TData extends object = object> = (data?: TData | undefined, state?: PresenceState | undefined) => void;
|
|
22
22
|
export declare type OnStartTimerAction = (duration: number) => void;
|
|
23
23
|
export declare type OnPlayTimerAction = () => void;
|
|
24
24
|
export declare type OnPauseTimerAction = () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionTypes.d.ts","sourceRoot":"","sources":["../../src/types/ActionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGpE,oBAAY,oBAAoB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AACzD,oBAAY,mBAAmB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AAG5E,oBAAY,yBAAyB,GAAG,CAAC,CAAC,SAAS,c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,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAElE,oBAAY,yBAAyB,CAAC,MAAM,IAAI,CAC5C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,OAAO,KACb,IAAI,CAAC;AAEV,oBAAY,0BAA0B,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,IAAI,CACpE,IAAI,CAAC,EAAE,KAAK,GAAG,SAAS,EACxB,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,KAChC,IAAI,CAAC;AAEV,oBAAY,kBAAkB,GAAG,CAC7B,QAAQ,EAAE,MAAM,KACf,IAAI,CAAC;AAEV,oBAAY,iBAAiB,GAAG,MAAM,IAAI,CAAC;AAE3C,oBAAY,kBAAkB,GAAG,MAAM,IAAI,CAAC;AAE5C,oBAAY,iBAAiB,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;AACjE,oBAAY,qBAAqB,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC;AACxE,oBAAY,qBAAqB,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC;AACxE,oBAAY,oBAAoB,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC;AACvE,oBAAY,sBAAsB,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/live-share-react",
|
|
3
|
-
"version": "1.0.0-preview.
|
|
3
|
+
"version": "1.0.0-preview.12",
|
|
4
4
|
"description": "Build collaborative React apps using Microsoft's Fluid & Live Share frameworks with ease.",
|
|
5
5
|
"author": "Microsoft",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -12,26 +12,30 @@
|
|
|
12
12
|
"typecheck": "tsc"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"@fluid-experimental/task-manager": "~1.2.3",
|
|
17
|
-
"@microsoft/live-share": "1.0.0-preview.10",
|
|
18
|
-
"@microsoft/live-share-canvas": "1.0.0-preview.10",
|
|
19
|
-
"@microsoft/live-share-media": "1.0.0-preview.10",
|
|
20
|
-
"@microsoft/live-share-turbo": "1.0.0-preview.10",
|
|
21
|
-
"fluid-framework": "~1.2.3",
|
|
15
|
+
"@microsoft/live-share-turbo": "1.0.0-preview.12",
|
|
22
16
|
"url": "^0.11.0",
|
|
23
17
|
"uuid": "^8.3.2"
|
|
24
18
|
},
|
|
25
19
|
"devDependencies": {
|
|
26
20
|
"@babel/core": "^7.12.3",
|
|
27
|
-
"@fluidframework/
|
|
21
|
+
"@fluidframework/azure-client": "~1.0.3",
|
|
22
|
+
"@fluidframework/test-client-utils": "^1.3.6",
|
|
23
|
+
"@microsoft/live-share": "1.0.0-preview.12",
|
|
24
|
+
"@microsoft/live-share-canvas": "1.0.0-preview.12",
|
|
25
|
+
"@microsoft/live-share-media": "1.0.0-preview.12",
|
|
28
26
|
"@types/react": "^18.0.0",
|
|
29
27
|
"@types/react-dom": "^18.0.0",
|
|
30
28
|
"@types/uuid": "^8.3.4",
|
|
31
29
|
"babel-loader": "^7.1.5",
|
|
30
|
+
"fluid-framework": "^1.3.6",
|
|
32
31
|
"typescript": "^4.6.4"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
34
|
+
"@fluidframework/azure-client": "^1.0.0",
|
|
35
|
+
"@microsoft/live-share": "1.0.0-preview.12",
|
|
36
|
+
"@microsoft/live-share-canvas": "1.0.0-preview.12",
|
|
37
|
+
"@microsoft/live-share-media": "1.0.0-preview.12",
|
|
38
|
+
"fluid-framework": "^1.2.3",
|
|
35
39
|
"react": "^16.8.0 || ^17 || ^18",
|
|
36
40
|
"react-dom": "^16.8.0 || ^17 || ^18"
|
|
37
41
|
},
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
InkingManager,
|
|
10
10
|
InkingTool,
|
|
11
11
|
IPoint,
|
|
12
|
-
IUserInfo,
|
|
13
12
|
LiveCanvas,
|
|
14
13
|
} from "@microsoft/live-share-canvas";
|
|
15
14
|
import React from "react";
|
|
@@ -33,7 +32,7 @@ import { isRefObject } from "../utils";
|
|
|
33
32
|
* @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
|
|
34
33
|
* @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
|
|
35
34
|
* @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
|
|
36
|
-
* @param
|
|
35
|
+
* @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
|
|
37
36
|
* @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
|
|
38
37
|
*/
|
|
39
38
|
export function useLiveCanvas(
|
|
@@ -46,7 +45,7 @@ export function useLiveCanvas(
|
|
|
46
45
|
scale?: number,
|
|
47
46
|
referencePoint?: CanvasReferencePoint,
|
|
48
47
|
isCursorShared?: boolean,
|
|
49
|
-
|
|
48
|
+
localUserPictureUrl?: string
|
|
50
49
|
): IUseLiveCanvasResults {
|
|
51
50
|
/**
|
|
52
51
|
* User facing: inking manager instance
|
|
@@ -56,7 +55,10 @@ export function useLiveCanvas(
|
|
|
56
55
|
/**
|
|
57
56
|
* User facing: dynamically load the DDS for the given unique key.
|
|
58
57
|
*/
|
|
59
|
-
const { dds: liveCanvas } = useDynamicDDS<LiveCanvas>(
|
|
58
|
+
const { dds: liveCanvas } = useDynamicDDS<LiveCanvas>(
|
|
59
|
+
uniqueKey,
|
|
60
|
+
LiveCanvas
|
|
61
|
+
);
|
|
60
62
|
|
|
61
63
|
/**
|
|
62
64
|
* Setup the InkingManager and LiveCanvas
|
|
@@ -162,10 +164,7 @@ export function useLiveCanvas(
|
|
|
162
164
|
* Sets the isCursorShared of the liveCanvas based on the 'isCursorShared' prop
|
|
163
165
|
*/
|
|
164
166
|
React.useEffect(() => {
|
|
165
|
-
if (
|
|
166
|
-
liveCanvas &&
|
|
167
|
-
isCursorShared !== undefined
|
|
168
|
-
) {
|
|
167
|
+
if (liveCanvas && isCursorShared !== undefined) {
|
|
169
168
|
liveCanvas.isCursorShared = isCursorShared;
|
|
170
169
|
}
|
|
171
170
|
}, [isCursorShared, liveCanvas]);
|
|
@@ -174,19 +173,12 @@ export function useLiveCanvas(
|
|
|
174
173
|
* Sets the onGetLocalUserInfo method of the liveCanvas based on the 'localUserCursor' prop
|
|
175
174
|
*/
|
|
176
175
|
React.useEffect(() => {
|
|
177
|
-
if (liveCanvas &&
|
|
178
|
-
liveCanvas.
|
|
179
|
-
return
|
|
180
|
-
displayName: localUserCursor.displayName,
|
|
181
|
-
pictureUri: localUserCursor.pictureUri,
|
|
182
|
-
};
|
|
176
|
+
if (liveCanvas && localUserPictureUrl) {
|
|
177
|
+
liveCanvas.onGetLocalUserPictureUrl = (): string | undefined => {
|
|
178
|
+
return localUserPictureUrl;
|
|
183
179
|
};
|
|
184
180
|
}
|
|
185
|
-
}, [
|
|
186
|
-
localUserCursor?.displayName,
|
|
187
|
-
localUserCursor?.pictureUri,
|
|
188
|
-
liveCanvas,
|
|
189
|
-
]);
|
|
181
|
+
}, [localUserPictureUrl, liveCanvas]);
|
|
190
182
|
|
|
191
183
|
/**
|
|
192
184
|
* Return hook response
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
LivePresence,
|
|
10
10
|
} from "@microsoft/live-share";
|
|
11
11
|
import React from "react";
|
|
12
|
-
import { IUseLivePresenceResults } from "../types";
|
|
12
|
+
import { IUseLivePresenceResults, OnUpdateLivePresenceAction } from "../types";
|
|
13
13
|
import { useDynamicDDS } from "../shared-hooks";
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -31,7 +31,6 @@ import { useDynamicDDS } from "../shared-hooks";
|
|
|
31
31
|
* to update the local user's presence and the `LivePresence` Fluid object.
|
|
32
32
|
*/
|
|
33
33
|
export function useLivePresence<TData extends object = object>(
|
|
34
|
-
userId?: string | undefined,
|
|
35
34
|
initialData?: TData | undefined,
|
|
36
35
|
initialPresenceState: PresenceState = PresenceState.online,
|
|
37
36
|
uniqueKey: string = ":<dds-default>"
|
|
@@ -45,7 +44,10 @@ export function useLivePresence<TData extends object = object>(
|
|
|
45
44
|
/**
|
|
46
45
|
* User facing: dynamically load the DDS for the given unique key.
|
|
47
46
|
*/
|
|
48
|
-
const { dds: livePresence } = useDynamicDDS<LivePresence<TData>>(
|
|
47
|
+
const { dds: livePresence } = useDynamicDDS<LivePresence<TData>>(
|
|
48
|
+
uniqueKey,
|
|
49
|
+
LivePresence<TData>
|
|
50
|
+
);
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* User facing: list of non-local user's presence objects.
|
|
@@ -64,8 +66,8 @@ export function useLivePresence<TData extends object = object>(
|
|
|
64
66
|
/**
|
|
65
67
|
* User facing: callback to update the local user's presence.
|
|
66
68
|
*/
|
|
67
|
-
const updatePresence = React.useCallback(
|
|
68
|
-
(
|
|
69
|
+
const updatePresence: OnUpdateLivePresenceAction<TData> = React.useCallback(
|
|
70
|
+
(data?: TData | undefined, state?: PresenceState | undefined) => {
|
|
69
71
|
if (!livePresence) {
|
|
70
72
|
console.error(
|
|
71
73
|
new Error(
|
|
@@ -82,7 +84,7 @@ export function useLivePresence<TData extends object = object>(
|
|
|
82
84
|
);
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
|
-
livePresence.
|
|
87
|
+
livePresence.update(data, state);
|
|
86
88
|
},
|
|
87
89
|
[livePresence]
|
|
88
90
|
);
|
|
@@ -91,8 +93,7 @@ export function useLivePresence<TData extends object = object>(
|
|
|
91
93
|
* Setup change listeners and start `LivePresence` if needed
|
|
92
94
|
*/
|
|
93
95
|
React.useEffect(() => {
|
|
94
|
-
if (livePresence === undefined)
|
|
95
|
-
return;
|
|
96
|
+
if (livePresence === undefined) return;
|
|
96
97
|
|
|
97
98
|
const onPresenceChanged = () => {
|
|
98
99
|
const updatedLocalUsers: LivePresenceUser<TData>[] = [];
|
|
@@ -104,7 +105,7 @@ export function useLivePresence<TData extends object = object>(
|
|
|
104
105
|
livePresence.on("presenceChanged", onPresenceChanged);
|
|
105
106
|
|
|
106
107
|
if (!livePresence.isInitialized) {
|
|
107
|
-
livePresence.initialize(
|
|
108
|
+
livePresence.initialize(initialData, initialPresenceState);
|
|
108
109
|
} else {
|
|
109
110
|
onPresenceChanged();
|
|
110
111
|
}
|
package/src/types/ActionTypes.ts
CHANGED
|
@@ -56,8 +56,8 @@ export type OnReceivedLiveEventAction<TEvent> = (
|
|
|
56
56
|
) => void;
|
|
57
57
|
|
|
58
58
|
export type OnUpdateLivePresenceAction<TData extends object = object> = (
|
|
59
|
+
data?: TData | undefined,
|
|
59
60
|
state?: PresenceState | undefined,
|
|
60
|
-
data?: TData | undefined
|
|
61
61
|
) => void;
|
|
62
62
|
|
|
63
63
|
export type OnStartTimerAction = (
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useDynamicDDS } from "./useDynamicDDS";
|
|
3
|
-
import { TaskManager } from "@fluid-experimental/task-manager";
|
|
4
|
-
import { DynamicObjectRegistry } from "@microsoft/live-share";
|
|
5
|
-
|
|
6
|
-
// Register TaskManager as dynamic object
|
|
7
|
-
DynamicObjectRegistry.registerObjectClass(TaskManager, TaskManager.getFactory().type);
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* A hook for joining a queue to lock tasks for a given id. Guaranteed to have only one user assigned to a task at a time.
|
|
11
|
-
*
|
|
12
|
-
* @param uniqueKey the unique key for the TaskManager DDS
|
|
13
|
-
* @param taskId the task id to lock
|
|
14
|
-
* @returns stateful data about the status of the task lock
|
|
15
|
-
*/
|
|
16
|
-
export const useTaskManager = (uniqueKey: string, taskId?: string): {
|
|
17
|
-
lockedTask: boolean;
|
|
18
|
-
taskManager: TaskManager | undefined;
|
|
19
|
-
} => {
|
|
20
|
-
/**
|
|
21
|
-
* TaskId currently in queue for
|
|
22
|
-
*/
|
|
23
|
-
const currentTaskIdRef = React.useRef<string | undefined>(undefined);
|
|
24
|
-
/**
|
|
25
|
-
* Stateful boolean that is true when the user is currently assigned the task
|
|
26
|
-
*/
|
|
27
|
-
const [lockedTask, setLockedTask] = React.useState<boolean>(false);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* User facing: dynamically load the TaskManager DDS for the given unique key.
|
|
31
|
-
*/
|
|
32
|
-
const { dds: taskManager } = useDynamicDDS<TaskManager>(uniqueKey, TaskManager);
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* When the task id changes, lock the task. When the task id is undefined, abandon the task.
|
|
36
|
-
*/
|
|
37
|
-
React.useEffect(() => {
|
|
38
|
-
let mounted = true;
|
|
39
|
-
if (taskManager) {
|
|
40
|
-
if (taskId && currentTaskIdRef.current !== taskId) {
|
|
41
|
-
if (currentTaskIdRef.current) {
|
|
42
|
-
taskManager.abandon(currentTaskIdRef.current);
|
|
43
|
-
setLockedTask(false);
|
|
44
|
-
}
|
|
45
|
-
currentTaskIdRef.current = taskId;
|
|
46
|
-
const onLockTask = async () => {
|
|
47
|
-
try {
|
|
48
|
-
await taskManager.lockTask(taskId);
|
|
49
|
-
if (mounted) {
|
|
50
|
-
setLockedTask(true);
|
|
51
|
-
}
|
|
52
|
-
} catch {
|
|
53
|
-
if (mounted) {
|
|
54
|
-
setLockedTask(false);
|
|
55
|
-
currentTaskIdRef.current = undefined;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
onLockTask();
|
|
60
|
-
} else if (!taskId && currentTaskIdRef.current) {
|
|
61
|
-
taskManager.abandon(currentTaskIdRef.current);
|
|
62
|
-
setLockedTask(false);
|
|
63
|
-
currentTaskIdRef.current = undefined;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* When the component unmounts, abandon the task if it is still locked
|
|
68
|
-
*/
|
|
69
|
-
return () => {
|
|
70
|
-
mounted = false;
|
|
71
|
-
if (currentTaskIdRef.current) {
|
|
72
|
-
taskManager?.abandon(currentTaskIdRef.current);
|
|
73
|
-
}
|
|
74
|
-
currentTaskIdRef.current = undefined;
|
|
75
|
-
}
|
|
76
|
-
}, [taskManager, taskId]);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
lockedTask,
|
|
80
|
-
taskManager,
|
|
81
|
-
};
|
|
82
|
-
};
|
package/tinylicious.log
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
|
|
2
|
-
[32minfo[39m: Starting tinylicious@1.0.0-preview.4 {"label":"winston","timestamp":"2023-02-07T05:25:11.899Z"}
|
|
3
|
-
[32minfo[39m: Listening on port 7070 {"label":"winston","timestamp":"2023-02-07T05:25:11.921Z"}
|
|
4
|
-
[32minfo[39m: [0mHEAD / [32m200[0m 3.535 ms - 107[0m {"label":"winston","timestamp":"2023-02-07T05:25:13.499Z"}
|