@microsoft/live-share-react 1.0.0-preview.9 → 1.0.2-preview.1
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 +99 -35
- package/bin/index.d.ts +6 -6
- package/bin/index.js +6 -6
- package/bin/interfaces/LiveInterfaceExtensions.d.ts +25 -8
- package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +1 -1
- package/bin/interfaces/LiveInterfaceExtensions.js +5 -5
- package/bin/interfaces/index.d.ts +1 -1
- package/bin/interfaces/index.js +1 -1
- package/bin/internal/errors.d.ts +26 -0
- package/bin/internal/errors.d.ts.map +1 -0
- package/bin/internal/errors.js +39 -0
- package/bin/internal/errors.js.map +1 -0
- package/bin/internal/index.d.ts +4 -0
- package/bin/internal/index.d.ts.map +1 -0
- package/bin/internal/index.js +4 -0
- package/bin/internal/index.js.map +1 -0
- package/bin/internal/type-guards.d.ts +6 -0
- package/bin/internal/type-guards.d.ts.map +1 -0
- package/bin/internal/type-guards.js +8 -0
- package/bin/internal/type-guards.js.map +1 -0
- package/bin/{internal-hooks → internal}/useSharedStateRegistry.d.ts +30 -30
- package/bin/internal/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/{internal-hooks → internal}/useSharedStateRegistry.js +101 -99
- package/bin/internal/useSharedStateRegistry.js.map +1 -0
- package/bin/live-hooks/index.d.ts +6 -6
- package/bin/live-hooks/index.js +6 -6
- package/bin/live-hooks/useLiveCanvas.d.ts +27 -27
- package/bin/live-hooks/useLiveCanvas.d.ts.map +1 -1
- package/bin/live-hooks/useLiveCanvas.js +158 -166
- package/bin/live-hooks/useLiveCanvas.js.map +1 -1
- package/bin/live-hooks/useLiveEvent.d.ts +21 -21
- package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
- package/bin/live-hooks/useLiveEvent.js +100 -85
- package/bin/live-hooks/useLiveEvent.js.map +1 -1
- package/bin/live-hooks/useLivePresence.d.ts +25 -25
- package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
- package/bin/live-hooks/useLivePresence.js +106 -92
- package/bin/live-hooks/useLivePresence.js.map +1 -1
- package/bin/live-hooks/useLiveState.d.ts +19 -19
- package/bin/live-hooks/useLiveState.d.ts.map +1 -1
- package/bin/live-hooks/useLiveState.js +79 -70
- package/bin/live-hooks/useLiveState.js.map +1 -1
- package/bin/live-hooks/useLiveTimer.d.ts +7 -7
- package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
- package/bin/live-hooks/useLiveTimer.js +150 -131
- package/bin/live-hooks/useLiveTimer.js.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.d.ts +22 -22
- package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.js +206 -161
- package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
- package/bin/providers/AzureProvider.d.ts +33 -33
- package/bin/providers/AzureProvider.d.ts.map +1 -1
- package/bin/providers/AzureProvider.js +101 -101
- package/bin/providers/AzureProvider.js.map +1 -1
- package/bin/providers/LiveShareProvider.d.ts +62 -41
- package/bin/providers/LiveShareProvider.d.ts.map +1 -1
- package/bin/providers/LiveShareProvider.js +68 -65
- package/bin/providers/LiveShareProvider.js.map +1 -1
- package/bin/providers/index.d.ts +2 -2
- package/bin/providers/index.js +2 -2
- package/bin/shared-hooks/index.d.ts +3 -4
- package/bin/shared-hooks/index.d.ts.map +1 -1
- package/bin/shared-hooks/index.js +3 -4
- package/bin/shared-hooks/index.js.map +1 -1
- package/bin/shared-hooks/useDynamicDDS.d.ts +18 -18
- package/bin/shared-hooks/useDynamicDDS.d.ts.map +1 -1
- package/bin/shared-hooks/useDynamicDDS.js +67 -67
- package/bin/shared-hooks/useDynamicDDS.js.map +1 -1
- package/bin/shared-hooks/useSharedMap.d.ts +21 -21
- package/bin/shared-hooks/useSharedMap.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedMap.js +112 -105
- package/bin/shared-hooks/useSharedMap.js.map +1 -1
- package/bin/shared-hooks/useSharedState.d.ts +20 -20
- package/bin/shared-hooks/useSharedState.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedState.js +72 -62
- package/bin/shared-hooks/useSharedState.js.map +1 -1
- package/bin/types/ActionTypes.d.ts +111 -29
- package/bin/types/ActionTypes.d.ts.map +1 -1
- package/bin/types/ActionTypes.js +5 -5
- package/bin/types/PropTypes.d.ts +7 -7
- package/bin/types/PropTypes.d.ts.map +1 -1
- package/bin/types/PropTypes.js +5 -5
- package/bin/types/ResultTypes.d.ts +174 -162
- package/bin/types/ResultTypes.d.ts.map +1 -1
- package/bin/types/ResultTypes.js +5 -5
- package/bin/types/index.d.ts +3 -3
- package/bin/types/index.js +3 -3
- package/bin/utils/index.d.ts +1 -1
- package/bin/utils/index.js +1 -1
- package/bin/utils/type-check.d.ts +14 -14
- package/bin/utils/type-check.js +53 -53
- package/package.json +18 -14
- package/src/interfaces/LiveInterfaceExtensions.ts +19 -2
- package/src/internal/errors.ts +48 -0
- package/src/internal/index.ts +3 -0
- package/src/internal/type-guards.ts +9 -0
- package/src/{internal-hooks → internal}/useSharedStateRegistry.ts +6 -5
- package/src/live-hooks/useLiveCanvas.ts +12 -20
- package/src/live-hooks/useLiveEvent.ts +41 -22
- package/src/live-hooks/useLivePresence.ts +52 -33
- package/src/live-hooks/useLiveState.ts +48 -53
- package/src/live-hooks/useLiveTimer.ts +50 -41
- package/src/live-hooks/useMediaSynchronizer.ts +108 -41
- package/src/providers/AzureProvider.tsx +3 -8
- package/src/providers/LiveShareProvider.tsx +46 -16
- package/src/shared-hooks/index.ts +0 -1
- package/src/shared-hooks/useDynamicDDS.ts +15 -8
- package/src/shared-hooks/useSharedMap.ts +48 -22
- package/src/shared-hooks/useSharedState.ts +15 -5
- package/src/types/ActionTypes.ts +100 -15
- package/src/types/ResultTypes.ts +23 -9
- package/bin/internal-hooks/index.d.ts +0 -2
- package/bin/internal-hooks/index.d.ts.map +0 -1
- package/bin/internal-hooks/index.js +0 -2
- package/bin/internal-hooks/index.js.map +0 -1
- package/bin/internal-hooks/useDynamicDDSRegistry.d.ts +0 -14
- package/bin/internal-hooks/useDynamicDDSRegistry.d.ts.map +0 -1
- package/bin/internal-hooks/useDynamicDDSRegistry.js +0 -142
- package/bin/internal-hooks/useDynamicDDSRegistry.js.map +0 -1
- package/bin/internal-hooks/useSharedStateRegistry.d.ts.map +0 -1
- package/bin/internal-hooks/useSharedStateRegistry.js.map +0 -1
- package/bin/internal-hooks/useStateRef.d.ts +0 -7
- package/bin/internal-hooks/useStateRef.d.ts.map +0 -1
- package/bin/internal-hooks/useStateRef.js +0 -15
- package/bin/internal-hooks/useStateRef.js.map +0 -1
- package/bin/live-hooks/useLiveAICompletion.d.ts +0 -29
- package/bin/live-hooks/useLiveAICompletion.d.ts.map +0 -1
- package/bin/live-hooks/useLiveAICompletion.js +0 -186
- package/bin/live-hooks/useLiveAICompletion.js.map +0 -1
- package/bin/live-hooks/useLiveCoPilot.d.ts +0 -28
- package/bin/live-hooks/useLiveCoPilot.d.ts.map +0 -1
- package/bin/live-hooks/useLiveCoPilot.js +0 -178
- package/bin/live-hooks/useLiveCoPilot.js.map +0 -1
- package/bin/live-share-turbo/AzureTurboClient.d.ts +0 -39
- package/bin/live-share-turbo/AzureTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/AzureTurboClient.js +0 -56
- package/bin/live-share-turbo/AzureTurboClient.js.map +0 -1
- package/bin/live-share-turbo/LiveShareTurboClient.d.ts +0 -53
- package/bin/live-share-turbo/LiveShareTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/LiveShareTurboClient.js +0 -69
- package/bin/live-share-turbo/LiveShareTurboClient.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts +0 -31
- package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboDataObject.js +0 -75
- package/bin/live-share-turbo/dds-objects/TurboDataObject.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts +0 -48
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js +0 -104
- package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts +0 -28
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js +0 -68
- package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts +0 -60
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js +0 -111
- package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts +0 -77
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.js +0 -137
- package/bin/live-share-turbo/dds-objects/TurboLivePresence.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts +0 -30
- package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboLiveState.js +0 -74
- package/bin/live-share-turbo/dds-objects/TurboLiveState.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts +0 -61
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.js +0 -108
- package/bin/live-share-turbo/dds-objects/TurboSharedMap.js.map +0 -1
- package/bin/live-share-turbo/dds-objects/index.d.ts +0 -8
- package/bin/live-share-turbo/dds-objects/index.d.ts.map +0 -1
- package/bin/live-share-turbo/dds-objects/index.js +0 -8
- package/bin/live-share-turbo/dds-objects/index.js.map +0 -1
- package/bin/live-share-turbo/index.d.ts +0 -5
- package/bin/live-share-turbo/index.d.ts.map +0 -1
- package/bin/live-share-turbo/index.js +0 -5
- package/bin/live-share-turbo/index.js.map +0 -1
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts +0 -15
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.js +0 -2
- package/bin/live-share-turbo/interfaces/IFluidTurboClient.js.map +0 -1
- package/bin/live-share-turbo/interfaces/index.d.ts +0 -3
- package/bin/live-share-turbo/interfaces/index.d.ts.map +0 -1
- package/bin/live-share-turbo/interfaces/index.js +0 -3
- package/bin/live-share-turbo/interfaces/index.js.map +0 -1
- package/bin/live-share-turbo/internals/FluidTurboClient.d.ts +0 -39
- package/bin/live-share-turbo/internals/FluidTurboClient.d.ts.map +0 -1
- package/bin/live-share-turbo/internals/FluidTurboClient.js +0 -121
- package/bin/live-share-turbo/internals/FluidTurboClient.js.map +0 -1
- package/bin/live-share-turbo/internals/index.d.ts +0 -2
- package/bin/live-share-turbo/internals/index.d.ts.map +0 -1
- package/bin/live-share-turbo/internals/index.js +0 -2
- package/bin/live-share-turbo/internals/index.js.map +0 -1
- package/bin/live-share-turbo/internals/types.d.ts +0 -4
- package/bin/live-share-turbo/internals/types.d.ts.map +0 -1
- package/bin/live-share-turbo/internals/types.js +0 -2
- package/bin/live-share-turbo/internals/types.js.map +0 -1
- package/bin/providers/FluidContextProvider.d.ts +0 -34
- package/bin/providers/FluidContextProvider.d.ts.map +0 -1
- package/bin/providers/FluidContextProvider.js +0 -99
- package/bin/providers/FluidContextProvider.js.map +0 -1
- package/bin/providers/LiveShareContextProvider.d.ts +0 -42
- package/bin/providers/LiveShareContextProvider.d.ts.map +0 -1
- package/bin/providers/LiveShareContextProvider.js +0 -63
- package/bin/providers/LiveShareContextProvider.js.map +0 -1
- package/bin/shared-hooks/useLockedTask.d.ts +0 -11
- package/bin/shared-hooks/useLockedTask.d.ts.map +0 -1
- package/bin/shared-hooks/useLockedTask.js +0 -82
- package/bin/shared-hooks/useLockedTask.js.map +0 -1
- package/bin/shared-hooks/useTaskManager.d.ts +0 -13
- package/bin/shared-hooks/useTaskManager.d.ts.map +0 -1
- package/bin/shared-hooks/useTaskManager.js +0 -86
- package/bin/shared-hooks/useTaskManager.js.map +0 -1
- package/bin/utils/getContainerSchema.d.ts +0 -8
- package/bin/utils/getContainerSchema.d.ts.map +0 -1
- package/bin/utils/getContainerSchema.js +0 -41
- package/bin/utils/getContainerSchema.js.map +0 -1
- package/src/internal-hooks/index.ts +0 -1
- package/src/shared-hooks/useTaskManager.ts +0 -82
- package/tinylicious.log +0 -4
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Live Share React
|
|
2
2
|
|
|
3
|
+
**DISCLAIMER:** This package is in preview and experimental. We are not yet committed to maintaining this package and may make breaking changes at any time. Read this package's [license](./LICENSE) for more information.
|
|
4
|
+
|
|
3
5
|
Live Share React is designed to make building collaborative apps in React simple and intuitive, all using familiar patterns from functional React.
|
|
4
6
|
|
|
5
7
|
Here is a simple example of how to get started:
|
|
@@ -48,13 +50,13 @@ export function SharedCheckbox() {
|
|
|
48
50
|
To add the latest version of the SDK to your application using NPM:
|
|
49
51
|
|
|
50
52
|
```bash
|
|
51
|
-
npm install @microsoft/live-share-react --save
|
|
53
|
+
npm install fluid-framework @fluidframework/azure-client @microsoft/live-share @microsoft/live-share-media @microsoft/live-share-canvas @microsoft/live-share-react --save
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
or using [Yarn](https://yarnpkg.com/):
|
|
55
57
|
|
|
56
58
|
```bash
|
|
57
|
-
yarn add @microsoft/live-share-react
|
|
59
|
+
yarn add fluid-framework @fluidframework/azure-client @microsoft/live-share @microsoft/live-share-media @microsoft/live-share-canvas @microsoft/live-share-react
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
### Building package
|
|
@@ -66,7 +68,7 @@ npm install
|
|
|
66
68
|
npm run build
|
|
67
69
|
```
|
|
68
70
|
|
|
69
|
-
This will use
|
|
71
|
+
This will use npm workspaces to hoist and build all dependencies.
|
|
70
72
|
|
|
71
73
|
### Sample app
|
|
72
74
|
|
|
@@ -172,7 +174,7 @@ export function CardList() {
|
|
|
172
174
|
|
|
173
175
|
### useLivePresence
|
|
174
176
|
|
|
175
|
-
Presence makes it easy to track which users are currently in the session and assign custom data to them.
|
|
177
|
+
Presence makes it easy to track which users are currently in the session and assign custom data to them.
|
|
176
178
|
|
|
177
179
|
```javascript
|
|
178
180
|
import { useLivePresence } from "@microsoft/live-share-react";
|
|
@@ -180,8 +182,8 @@ import { PresenceState } from "@microsoft/live-share";
|
|
|
180
182
|
|
|
181
183
|
export function OnlineUsers() {
|
|
182
184
|
const { localUser, allUsers, updatePresence } = useLivePresence(
|
|
183
|
-
"
|
|
184
|
-
{
|
|
185
|
+
"UNIQUE-PRESENCE-KEY", // required unique key for presence
|
|
186
|
+
{ favoriteColor: "red" } // optional custom data object
|
|
185
187
|
);
|
|
186
188
|
return (
|
|
187
189
|
<div>
|
|
@@ -190,16 +192,18 @@ export function OnlineUsers() {
|
|
|
190
192
|
{allUsers
|
|
191
193
|
.filter((user) => user.state === PresenceState.online)
|
|
192
194
|
.map((user) => (
|
|
193
|
-
<div key={user.userId}>
|
|
195
|
+
<div key={user.userId}>
|
|
196
|
+
{user.displayName + " " + user.data!.favoriteColor}
|
|
197
|
+
</div>
|
|
194
198
|
))}
|
|
195
199
|
</div>
|
|
196
200
|
<button
|
|
197
201
|
onClick={() => {
|
|
198
202
|
updatePresence(
|
|
203
|
+
localUser.data,
|
|
199
204
|
localUser?.state === PresenceState.offline
|
|
200
205
|
? PresenceState.online
|
|
201
206
|
: PresenceState.offline,
|
|
202
|
-
localUser.data
|
|
203
207
|
);
|
|
204
208
|
}}
|
|
205
209
|
>
|
|
@@ -223,7 +227,7 @@ import { UserMeetingRole } from "@microsoft/live-share";
|
|
|
223
227
|
const ALLOWED_ROLES = [UserMeetingRole.organizer, UserMeetingRole.presenter ];
|
|
224
228
|
|
|
225
229
|
export function AppState() {
|
|
226
|
-
const [state,
|
|
230
|
+
const [state, setState] = useLiveState("CUSTOM-STATE-ID", ExampleAppState.WAITING, ALLOWED_ROLES);
|
|
227
231
|
|
|
228
232
|
if (state === ExampleAppState.WAITING) {
|
|
229
233
|
return (
|
|
@@ -287,10 +291,10 @@ export function Reactions() {
|
|
|
287
291
|
</button>
|
|
288
292
|
{/* Show latest reaction */}
|
|
289
293
|
{latestEvent?.local === false && (
|
|
290
|
-
<div>{`Received: ${latestEvent?.
|
|
294
|
+
<div>{`Received: ${latestEvent?.value.emoji}`}</div>
|
|
291
295
|
)}
|
|
292
296
|
{latestEvent?.local === true && (
|
|
293
|
-
<div>{`Sent: ${latestEvent?.
|
|
297
|
+
<div>{`Sent: ${latestEvent?.value.emoji}`}</div>
|
|
294
298
|
)}
|
|
295
299
|
</div>
|
|
296
300
|
);
|
|
@@ -479,25 +483,89 @@ Implementations may vary for each dynamic object & hook. We will try and update
|
|
|
479
483
|
|
|
480
484
|
Example:
|
|
481
485
|
|
|
482
|
-
```
|
|
483
|
-
import
|
|
486
|
+
```typescript
|
|
487
|
+
import React from "react";
|
|
484
488
|
import { useDynamicDDS } from "@microsoft/live-share-react";
|
|
485
|
-
import {
|
|
486
|
-
import {
|
|
487
|
-
|
|
488
|
-
// Register
|
|
489
|
-
DynamicObjectRegistry.registerObjectClass(
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
489
|
+
import { DynamicObjectRegistry } from "@microsoft/live-share";
|
|
490
|
+
import { TaskManager } from "@fluid-experimental/task-manager";
|
|
491
|
+
|
|
492
|
+
// Register TaskManager as dynamic object
|
|
493
|
+
DynamicObjectRegistry.registerObjectClass(TaskManager, TaskManager.getFactory().type);
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* 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.
|
|
497
|
+
*
|
|
498
|
+
* @param uniqueKey the unique key for the TaskManager DDS
|
|
499
|
+
* @param taskId the task id to lock
|
|
500
|
+
* @returns stateful data about the status of the task lock
|
|
501
|
+
*/
|
|
502
|
+
export const useTaskManager = (uniqueKey: string, taskId?: string): {
|
|
503
|
+
lockedTask: boolean;
|
|
504
|
+
taskManager: TaskManager | undefined;
|
|
505
|
+
} => {
|
|
506
|
+
/**
|
|
507
|
+
* TaskId currently in queue for
|
|
508
|
+
*/
|
|
509
|
+
const currentTaskIdRef = React.useRef<string | undefined>(undefined);
|
|
510
|
+
/**
|
|
511
|
+
* Stateful boolean that is true when the user is currently assigned the task
|
|
512
|
+
*/
|
|
513
|
+
const [lockedTask, setLockedTask] = React.useState<boolean>(false);
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* User facing: dynamically load the TaskManager DDS for the given unique key.
|
|
517
|
+
*/
|
|
518
|
+
const { dds: taskManager } = useDynamicDDS<TaskManager>(uniqueKey, TaskManager);
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* When the task id changes, lock the task. When the task id is undefined, abandon the task.
|
|
522
|
+
*/
|
|
523
|
+
React.useEffect(() => {
|
|
524
|
+
let mounted = true;
|
|
525
|
+
if (taskManager) {
|
|
526
|
+
if (taskId && currentTaskIdRef.current !== taskId) {
|
|
527
|
+
if (currentTaskIdRef.current) {
|
|
528
|
+
taskManager.abandon(currentTaskIdRef.current);
|
|
529
|
+
setLockedTask(false);
|
|
530
|
+
}
|
|
531
|
+
currentTaskIdRef.current = taskId;
|
|
532
|
+
const onLockTask = async () => {
|
|
533
|
+
try {
|
|
534
|
+
await taskManager.lockTask(taskId);
|
|
535
|
+
if (mounted) {
|
|
536
|
+
setLockedTask(true);
|
|
537
|
+
}
|
|
538
|
+
} catch {
|
|
539
|
+
if (mounted) {
|
|
540
|
+
setLockedTask(false);
|
|
541
|
+
currentTaskIdRef.current = undefined;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
onLockTask();
|
|
546
|
+
} else if (!taskId && currentTaskIdRef.current) {
|
|
547
|
+
taskManager.abandon(currentTaskIdRef.current);
|
|
548
|
+
setLockedTask(false);
|
|
549
|
+
currentTaskIdRef.current = undefined;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* When the component unmounts, abandon the task if it is still locked
|
|
554
|
+
*/
|
|
555
|
+
return () => {
|
|
556
|
+
mounted = false;
|
|
557
|
+
if (currentTaskIdRef.current) {
|
|
558
|
+
taskManager?.abandon(currentTaskIdRef.current);
|
|
559
|
+
}
|
|
560
|
+
currentTaskIdRef.current = undefined;
|
|
561
|
+
}
|
|
562
|
+
}, [taskManager, taskId]);
|
|
563
|
+
|
|
497
564
|
return {
|
|
498
|
-
|
|
565
|
+
lockedTask,
|
|
566
|
+
taskManager,
|
|
499
567
|
};
|
|
500
|
-
}
|
|
568
|
+
};
|
|
501
569
|
```
|
|
502
570
|
|
|
503
571
|
## Code samples
|
|
@@ -518,11 +586,7 @@ The Live Share SDK contains dependencies for [@microsoft/teams-js](https://www.n
|
|
|
518
586
|
|
|
519
587
|
| @microsoft/live-share | @microsoft/teams-js | fluid-framework | @microsoft/live-share-\* | @fluidframework/azure-client | @microsoft/TeamsFx | @microsoft/TeamsFx-react |
|
|
520
588
|
| --------------------- | -------------------- | --------------- | -------------------------- | ---------------------------- | ------------------------------- | ------------------------------- |
|
|
521
|
-
| 1.0.0
|
|
522
|
-
| 1.0.0-preview.8 | ^2.5.0 | ~1.2.3 | 1.0.0-preview.9 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
|
|
523
|
-
| 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) |
|
|
524
|
-
| ~0.5.1 | 2.0.0-experimental.1 | ~1.2.3 | ~0.5.1 (optional) | ~1.0.2 (optional) | 2.0.0-experimental.0 (optional) | 2.0.0-experimental.0 (optional) |
|
|
525
|
-
| ~0.3.1 | 2.0.0-experimental.0 | ~0.59.0 | ~0.3.1 (optional) | ~0.59.0 (optional) | 2.0.0-experimental.0 (optional) | 2.0.0-experimental.0 (optional) |
|
|
589
|
+
| ^1.0.0 | ^2.11.0 | ^1.2.3 | ^1.0.0 | ^1.0.0 | ^2.5.0 | ^2.5.0 |
|
|
526
590
|
|
|
527
591
|
## Contributing
|
|
528
592
|
|
|
@@ -533,12 +597,12 @@ There are several ways you can [contribute](../../CONTRIBUTING.md) to this proje
|
|
|
533
597
|
- Engage with other Live Share developers on [StackOverflow](https://stackoverflow.com/questions/tagged/live-share).
|
|
534
598
|
- [Contribute bug fixes](../../CONTRIBUTING.md).
|
|
535
599
|
|
|
536
|
-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact opencode@microsoft.com with any additional questions or comments.
|
|
600
|
+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact <opencode@microsoft.com> with any additional questions or comments.
|
|
537
601
|
|
|
538
602
|
## Reporting Security Issues
|
|
539
603
|
|
|
540
|
-
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at secure@microsoft.com
|
|
604
|
+
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at <secure@microsoft.com>. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the [MSRC PGP](https://technet.microsoft.com/security/dn606155) key, can be found in the [Security TechCenter](https://technet.microsoft.com/security/default).
|
|
541
605
|
|
|
542
606
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
543
607
|
|
|
544
|
-
Licensed under a special [Microsoft](
|
|
608
|
+
Licensed under a special [Microsoft](./LICENSE) License.
|
package/bin/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./providers";
|
|
2
|
-
export * from "./shared-hooks";
|
|
3
|
-
export * from "./live-hooks";
|
|
4
|
-
export * from "./types";
|
|
5
|
-
export * from "./providers";
|
|
6
|
-
export * from "./interfaces";
|
|
1
|
+
export * from "./providers";
|
|
2
|
+
export * from "./shared-hooks";
|
|
3
|
+
export * from "./live-hooks";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./providers";
|
|
6
|
+
export * from "./interfaces";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/bin/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./providers";
|
|
2
|
-
export * from "./shared-hooks";
|
|
3
|
-
export * from "./live-hooks";
|
|
4
|
-
export * from "./types";
|
|
5
|
-
export * from "./providers";
|
|
6
|
-
export * from "./interfaces";
|
|
1
|
+
export * from "./providers";
|
|
2
|
+
export * from "./shared-hooks";
|
|
3
|
+
export * from "./live-hooks";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./providers";
|
|
6
|
+
export * from "./interfaces";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Object response for a received event
|
|
7
|
+
*/
|
|
8
|
+
export interface IReceiveLiveEvent<TEvent = any> {
|
|
9
|
+
/**
|
|
10
|
+
* The value of the event that was sent
|
|
11
|
+
*/
|
|
12
|
+
value: TEvent;
|
|
13
|
+
/**
|
|
14
|
+
* True if the local client was the one to send this event
|
|
15
|
+
*/
|
|
16
|
+
local: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Client ID of the user that sent the event
|
|
19
|
+
*/
|
|
20
|
+
clientId: string;
|
|
21
|
+
/**
|
|
22
|
+
* Server timestamp at which the event was sent
|
|
23
|
+
*/
|
|
24
|
+
timestamp: number;
|
|
25
|
+
}
|
|
9
26
|
//# sourceMappingURL=LiveInterfaceExtensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveInterfaceExtensions.d.ts","sourceRoot":"","sources":["../../src/interfaces/LiveInterfaceExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,iBAAiB,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"LiveInterfaceExtensions.d.ts","sourceRoot":"","sources":["../../src/interfaces/LiveInterfaceExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,GAAG;IAC3C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
export {};
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
export {};
|
|
6
6
|
//# sourceMappingURL=LiveInterfaceExtensions.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./LiveInterfaceExtensions";
|
|
1
|
+
export * from "./LiveInterfaceExtensions";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/bin/interfaces/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./LiveInterfaceExtensions";
|
|
1
|
+
export * from "./LiveInterfaceExtensions";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
declare class UseLiveDataObjectActionError extends Error {
|
|
5
|
+
constructor(ddsName: string, functionName: string, message: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export declare class ActionContainerNotJoinedError extends UseLiveDataObjectActionError {
|
|
11
|
+
constructor(ddsName: string, functionName: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @hidden
|
|
15
|
+
*/
|
|
16
|
+
export declare class ActionLiveDataObjectUndefinedError extends UseLiveDataObjectActionError {
|
|
17
|
+
constructor(ddsName: string, functionName: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @hidden
|
|
21
|
+
*/
|
|
22
|
+
export declare class ActionLiveDataObjectInitializedError extends UseLiveDataObjectActionError {
|
|
23
|
+
constructor(ddsName: string, functionName: string);
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/internal/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAM,4BAA6B,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAKrE;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,4BAA4B;gBAC/D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAGpD;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,4BAA4B;gBACpE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAOpD;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,4BAA4B;gBACtE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAGpD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
class UseLiveDataObjectActionError extends Error {
|
|
5
|
+
constructor(ddsName, functionName, message) {
|
|
6
|
+
super(`use${toFirstLetterUppercase(ddsName)} ${functionName}: ${message}`);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @hidden
|
|
11
|
+
*/
|
|
12
|
+
export class ActionContainerNotJoinedError extends UseLiveDataObjectActionError {
|
|
13
|
+
constructor(ddsName, functionName) {
|
|
14
|
+
super(ddsName, functionName, "container has not yet been joined");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @hidden
|
|
19
|
+
*/
|
|
20
|
+
export class ActionLiveDataObjectUndefinedError extends UseLiveDataObjectActionError {
|
|
21
|
+
constructor(ddsName, functionName) {
|
|
22
|
+
super(ddsName, functionName, `${ddsName} is undefined, which means it is still being dynamically created`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @hidden
|
|
27
|
+
*/
|
|
28
|
+
export class ActionLiveDataObjectInitializedError extends UseLiveDataObjectActionError {
|
|
29
|
+
constructor(ddsName, functionName) {
|
|
30
|
+
super(ddsName, functionName, `${ddsName} is not initialized`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @hidden
|
|
35
|
+
*/
|
|
36
|
+
function toFirstLetterUppercase(word) {
|
|
37
|
+
return word[0].toUpperCase() + word.substring(1);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/internal/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,4BAA6B,SAAQ,KAAK;IAC5C,YAAY,OAAe,EAAE,YAAoB,EAAE,OAAe;QAC9D,KAAK,CACD,MAAM,sBAAsB,CAAC,OAAO,CAAC,IAAI,YAAY,KAAK,OAAO,EAAE,CACtE,CAAC;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,4BAA4B;IAC3E,YAAY,OAAe,EAAE,YAAoB;QAC7C,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,mCAAmC,CAAC,CAAC;IACtE,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,4BAA4B;IAChF,YAAY,OAAe,EAAE,YAAoB;QAC7C,KAAK,CACD,OAAO,EACP,YAAY,EACZ,GAAG,OAAO,kEAAkE,CAC/E,CAAC;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,4BAA4B;IAClF,YAAY,OAAe,EAAE,YAAoB;QAC7C,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,qBAAqB,CAAC,CAAC;IAClE,CAAC;CACJ;AAED;;GAEG;AACH,SAAS,sBAAsB,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../../src/internal/type-guards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EACtC,KAAK,EAAE,GAAG,GACX,KAAK,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAEpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-guards.js","sourceRoot":"","sources":["../../src/internal/type-guards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAC/B,KAAU;IAEV,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
import { DeleteSharedStateAction, IAzureContainerResults, RegisterSharedSetStateAction, UnregisterSharedSetStateAction, UpdateSharedStateAction } from "../types";
|
|
6
|
-
export interface ISharedStateRegistryResponse {
|
|
7
|
-
/**
|
|
8
|
-
* Register a set state action callback
|
|
9
|
-
*/
|
|
10
|
-
registerSharedSetStateAction: RegisterSharedSetStateAction;
|
|
11
|
-
/**
|
|
12
|
-
* Unregister a set state action callback
|
|
13
|
-
*/
|
|
14
|
-
unregisterSharedSetStateAction: UnregisterSharedSetStateAction;
|
|
15
|
-
/**
|
|
16
|
-
* Setter callback to update the shared state
|
|
17
|
-
*/
|
|
18
|
-
updateSharedState: UpdateSharedStateAction;
|
|
19
|
-
/**
|
|
20
|
-
* Delete a shared state value
|
|
21
|
-
*/
|
|
22
|
-
deleteSharedState: DeleteSharedStateAction;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* 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.
|
|
26
|
-
*
|
|
27
|
-
* @param results IAzureContainerResults response or undefined
|
|
28
|
-
* @returns ISharedStateRegistryResponse object
|
|
29
|
-
*/
|
|
30
|
-
export declare const useSharedStateRegistry: (results: IAzureContainerResults | undefined) => ISharedStateRegistryResponse;
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import { DeleteSharedStateAction, IAzureContainerResults, RegisterSharedSetStateAction, UnregisterSharedSetStateAction, UpdateSharedStateAction } from "../types";
|
|
6
|
+
export interface ISharedStateRegistryResponse {
|
|
7
|
+
/**
|
|
8
|
+
* Register a set state action callback
|
|
9
|
+
*/
|
|
10
|
+
registerSharedSetStateAction: RegisterSharedSetStateAction;
|
|
11
|
+
/**
|
|
12
|
+
* Unregister a set state action callback
|
|
13
|
+
*/
|
|
14
|
+
unregisterSharedSetStateAction: UnregisterSharedSetStateAction;
|
|
15
|
+
/**
|
|
16
|
+
* Setter callback to update the shared state
|
|
17
|
+
*/
|
|
18
|
+
updateSharedState: UpdateSharedStateAction;
|
|
19
|
+
/**
|
|
20
|
+
* Delete a shared state value
|
|
21
|
+
*/
|
|
22
|
+
deleteSharedState: DeleteSharedStateAction;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 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.
|
|
26
|
+
*
|
|
27
|
+
* @param results IAzureContainerResults response or undefined
|
|
28
|
+
* @returns ISharedStateRegistryResponse object
|
|
29
|
+
*/
|
|
30
|
+
export declare const useSharedStateRegistry: (results: IAzureContainerResults | undefined) => ISharedStateRegistryResponse;
|
|
31
31
|
//# sourceMappingURL=useSharedStateRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharedStateRegistry.d.ts","sourceRoot":"","sources":["../../src/internal/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,EAE5B,8BAA8B,EAC9B,uBAAuB,EAC1B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,4BAA4B,EAAE,4BAA4B,CAAC;IAC3D;;OAEG;IACH,8BAA8B,EAAE,8BAA8B,CAAC;IAC/D;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;CAC9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,YACtB,sBAAsB,GAAG,SAAS,KAC5C,4BAwHF,CAAC"}
|