@microsoft/live-share-react 1.0.0-preview.8 → 1.0.1-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.
Files changed (220) hide show
  1. package/README.md +99 -34
  2. package/bin/index.d.ts +6 -6
  3. package/bin/index.js +6 -6
  4. package/bin/interfaces/LiveInterfaceExtensions.d.ts +25 -8
  5. package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +1 -1
  6. package/bin/interfaces/LiveInterfaceExtensions.js +5 -5
  7. package/bin/interfaces/index.d.ts +1 -1
  8. package/bin/interfaces/index.js +1 -1
  9. package/bin/internal/errors.d.ts +26 -0
  10. package/bin/internal/errors.d.ts.map +1 -0
  11. package/bin/internal/errors.js +39 -0
  12. package/bin/internal/errors.js.map +1 -0
  13. package/bin/internal/index.d.ts +4 -0
  14. package/bin/internal/index.d.ts.map +1 -0
  15. package/bin/internal/index.js +4 -0
  16. package/bin/internal/index.js.map +1 -0
  17. package/bin/internal/type-guards.d.ts +6 -0
  18. package/bin/internal/type-guards.d.ts.map +1 -0
  19. package/bin/internal/type-guards.js +8 -0
  20. package/bin/internal/type-guards.js.map +1 -0
  21. package/bin/{internal-hooks → internal}/useSharedStateRegistry.d.ts +30 -30
  22. package/bin/internal/useSharedStateRegistry.d.ts.map +1 -0
  23. package/bin/{internal-hooks → internal}/useSharedStateRegistry.js +101 -99
  24. package/bin/internal/useSharedStateRegistry.js.map +1 -0
  25. package/bin/live-hooks/index.d.ts +6 -6
  26. package/bin/live-hooks/index.js +6 -6
  27. package/bin/live-hooks/useLiveCanvas.d.ts +27 -27
  28. package/bin/live-hooks/useLiveCanvas.d.ts.map +1 -1
  29. package/bin/live-hooks/useLiveCanvas.js +158 -166
  30. package/bin/live-hooks/useLiveCanvas.js.map +1 -1
  31. package/bin/live-hooks/useLiveEvent.d.ts +21 -21
  32. package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
  33. package/bin/live-hooks/useLiveEvent.js +100 -85
  34. package/bin/live-hooks/useLiveEvent.js.map +1 -1
  35. package/bin/live-hooks/useLivePresence.d.ts +25 -25
  36. package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
  37. package/bin/live-hooks/useLivePresence.js +106 -92
  38. package/bin/live-hooks/useLivePresence.js.map +1 -1
  39. package/bin/live-hooks/useLiveState.d.ts +19 -19
  40. package/bin/live-hooks/useLiveState.d.ts.map +1 -1
  41. package/bin/live-hooks/useLiveState.js +79 -70
  42. package/bin/live-hooks/useLiveState.js.map +1 -1
  43. package/bin/live-hooks/useLiveTimer.d.ts +7 -7
  44. package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
  45. package/bin/live-hooks/useLiveTimer.js +150 -131
  46. package/bin/live-hooks/useLiveTimer.js.map +1 -1
  47. package/bin/live-hooks/useMediaSynchronizer.d.ts +22 -22
  48. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -1
  49. package/bin/live-hooks/useMediaSynchronizer.js +206 -161
  50. package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
  51. package/bin/providers/AzureProvider.d.ts +33 -33
  52. package/bin/providers/AzureProvider.d.ts.map +1 -1
  53. package/bin/providers/AzureProvider.js +101 -101
  54. package/bin/providers/AzureProvider.js.map +1 -1
  55. package/bin/providers/LiveShareProvider.d.ts +62 -41
  56. package/bin/providers/LiveShareProvider.d.ts.map +1 -1
  57. package/bin/providers/LiveShareProvider.js +68 -65
  58. package/bin/providers/LiveShareProvider.js.map +1 -1
  59. package/bin/providers/index.d.ts +2 -2
  60. package/bin/providers/index.js +2 -2
  61. package/bin/shared-hooks/index.d.ts +3 -4
  62. package/bin/shared-hooks/index.d.ts.map +1 -1
  63. package/bin/shared-hooks/index.js +3 -4
  64. package/bin/shared-hooks/index.js.map +1 -1
  65. package/bin/shared-hooks/useDynamicDDS.d.ts +18 -18
  66. package/bin/shared-hooks/useDynamicDDS.d.ts.map +1 -1
  67. package/bin/shared-hooks/useDynamicDDS.js +67 -67
  68. package/bin/shared-hooks/useDynamicDDS.js.map +1 -1
  69. package/bin/shared-hooks/useSharedMap.d.ts +21 -21
  70. package/bin/shared-hooks/useSharedMap.d.ts.map +1 -1
  71. package/bin/shared-hooks/useSharedMap.js +112 -105
  72. package/bin/shared-hooks/useSharedMap.js.map +1 -1
  73. package/bin/shared-hooks/useSharedState.d.ts +20 -20
  74. package/bin/shared-hooks/useSharedState.d.ts.map +1 -1
  75. package/bin/shared-hooks/useSharedState.js +72 -62
  76. package/bin/shared-hooks/useSharedState.js.map +1 -1
  77. package/bin/types/ActionTypes.d.ts +111 -29
  78. package/bin/types/ActionTypes.d.ts.map +1 -1
  79. package/bin/types/ActionTypes.js +5 -5
  80. package/bin/types/PropTypes.d.ts +7 -7
  81. package/bin/types/PropTypes.d.ts.map +1 -1
  82. package/bin/types/PropTypes.js +5 -5
  83. package/bin/types/ResultTypes.d.ts +174 -162
  84. package/bin/types/ResultTypes.d.ts.map +1 -1
  85. package/bin/types/ResultTypes.js +5 -5
  86. package/bin/types/index.d.ts +3 -3
  87. package/bin/types/index.js +3 -3
  88. package/bin/utils/index.d.ts +1 -1
  89. package/bin/utils/index.js +1 -1
  90. package/bin/utils/type-check.d.ts +14 -14
  91. package/bin/utils/type-check.js +53 -53
  92. package/package.json +18 -14
  93. package/src/interfaces/LiveInterfaceExtensions.ts +19 -2
  94. package/src/internal/errors.ts +48 -0
  95. package/src/internal/index.ts +3 -0
  96. package/src/internal/type-guards.ts +9 -0
  97. package/src/{internal-hooks → internal}/useSharedStateRegistry.ts +6 -5
  98. package/src/live-hooks/useLiveCanvas.ts +12 -20
  99. package/src/live-hooks/useLiveEvent.ts +41 -22
  100. package/src/live-hooks/useLivePresence.ts +52 -33
  101. package/src/live-hooks/useLiveState.ts +48 -53
  102. package/src/live-hooks/useLiveTimer.ts +50 -41
  103. package/src/live-hooks/useMediaSynchronizer.ts +108 -41
  104. package/src/providers/AzureProvider.tsx +3 -8
  105. package/src/providers/LiveShareProvider.tsx +46 -16
  106. package/src/shared-hooks/index.ts +0 -1
  107. package/src/shared-hooks/useDynamicDDS.ts +15 -8
  108. package/src/shared-hooks/useSharedMap.ts +48 -22
  109. package/src/shared-hooks/useSharedState.ts +15 -5
  110. package/src/types/ActionTypes.ts +100 -15
  111. package/src/types/ResultTypes.ts +23 -9
  112. package/bin/internal-hooks/index.d.ts +0 -2
  113. package/bin/internal-hooks/index.d.ts.map +0 -1
  114. package/bin/internal-hooks/index.js +0 -2
  115. package/bin/internal-hooks/index.js.map +0 -1
  116. package/bin/internal-hooks/useDynamicDDSRegistry.d.ts +0 -14
  117. package/bin/internal-hooks/useDynamicDDSRegistry.d.ts.map +0 -1
  118. package/bin/internal-hooks/useDynamicDDSRegistry.js +0 -142
  119. package/bin/internal-hooks/useDynamicDDSRegistry.js.map +0 -1
  120. package/bin/internal-hooks/useSharedStateRegistry.d.ts.map +0 -1
  121. package/bin/internal-hooks/useSharedStateRegistry.js.map +0 -1
  122. package/bin/internal-hooks/useStateRef.d.ts +0 -7
  123. package/bin/internal-hooks/useStateRef.d.ts.map +0 -1
  124. package/bin/internal-hooks/useStateRef.js +0 -15
  125. package/bin/internal-hooks/useStateRef.js.map +0 -1
  126. package/bin/live-hooks/useLiveAICompletion.d.ts +0 -29
  127. package/bin/live-hooks/useLiveAICompletion.d.ts.map +0 -1
  128. package/bin/live-hooks/useLiveAICompletion.js +0 -186
  129. package/bin/live-hooks/useLiveAICompletion.js.map +0 -1
  130. package/bin/live-hooks/useLiveCoPilot.d.ts +0 -28
  131. package/bin/live-hooks/useLiveCoPilot.d.ts.map +0 -1
  132. package/bin/live-hooks/useLiveCoPilot.js +0 -178
  133. package/bin/live-hooks/useLiveCoPilot.js.map +0 -1
  134. package/bin/live-share-turbo/AzureTurboClient.d.ts +0 -39
  135. package/bin/live-share-turbo/AzureTurboClient.d.ts.map +0 -1
  136. package/bin/live-share-turbo/AzureTurboClient.js +0 -56
  137. package/bin/live-share-turbo/AzureTurboClient.js.map +0 -1
  138. package/bin/live-share-turbo/LiveShareTurboClient.d.ts +0 -53
  139. package/bin/live-share-turbo/LiveShareTurboClient.d.ts.map +0 -1
  140. package/bin/live-share-turbo/LiveShareTurboClient.js +0 -69
  141. package/bin/live-share-turbo/LiveShareTurboClient.js.map +0 -1
  142. package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts +0 -31
  143. package/bin/live-share-turbo/dds-objects/TurboDataObject.d.ts.map +0 -1
  144. package/bin/live-share-turbo/dds-objects/TurboDataObject.js +0 -75
  145. package/bin/live-share-turbo/dds-objects/TurboDataObject.js.map +0 -1
  146. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts +0 -48
  147. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.d.ts.map +0 -1
  148. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js +0 -104
  149. package/bin/live-share-turbo/dds-objects/TurboLiveCanvas.js.map +0 -1
  150. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts +0 -28
  151. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.d.ts.map +0 -1
  152. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js +0 -68
  153. package/bin/live-share-turbo/dds-objects/TurboLiveEvent.js.map +0 -1
  154. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts +0 -60
  155. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.d.ts.map +0 -1
  156. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js +0 -111
  157. package/bin/live-share-turbo/dds-objects/TurboLiveMediaSession.js.map +0 -1
  158. package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts +0 -77
  159. package/bin/live-share-turbo/dds-objects/TurboLivePresence.d.ts.map +0 -1
  160. package/bin/live-share-turbo/dds-objects/TurboLivePresence.js +0 -137
  161. package/bin/live-share-turbo/dds-objects/TurboLivePresence.js.map +0 -1
  162. package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts +0 -30
  163. package/bin/live-share-turbo/dds-objects/TurboLiveState.d.ts.map +0 -1
  164. package/bin/live-share-turbo/dds-objects/TurboLiveState.js +0 -74
  165. package/bin/live-share-turbo/dds-objects/TurboLiveState.js.map +0 -1
  166. package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts +0 -61
  167. package/bin/live-share-turbo/dds-objects/TurboSharedMap.d.ts.map +0 -1
  168. package/bin/live-share-turbo/dds-objects/TurboSharedMap.js +0 -108
  169. package/bin/live-share-turbo/dds-objects/TurboSharedMap.js.map +0 -1
  170. package/bin/live-share-turbo/dds-objects/index.d.ts +0 -8
  171. package/bin/live-share-turbo/dds-objects/index.d.ts.map +0 -1
  172. package/bin/live-share-turbo/dds-objects/index.js +0 -8
  173. package/bin/live-share-turbo/dds-objects/index.js.map +0 -1
  174. package/bin/live-share-turbo/index.d.ts +0 -5
  175. package/bin/live-share-turbo/index.d.ts.map +0 -1
  176. package/bin/live-share-turbo/index.js +0 -5
  177. package/bin/live-share-turbo/index.js.map +0 -1
  178. package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts +0 -15
  179. package/bin/live-share-turbo/interfaces/IFluidTurboClient.d.ts.map +0 -1
  180. package/bin/live-share-turbo/interfaces/IFluidTurboClient.js +0 -2
  181. package/bin/live-share-turbo/interfaces/IFluidTurboClient.js.map +0 -1
  182. package/bin/live-share-turbo/interfaces/index.d.ts +0 -3
  183. package/bin/live-share-turbo/interfaces/index.d.ts.map +0 -1
  184. package/bin/live-share-turbo/interfaces/index.js +0 -3
  185. package/bin/live-share-turbo/interfaces/index.js.map +0 -1
  186. package/bin/live-share-turbo/internals/FluidTurboClient.d.ts +0 -39
  187. package/bin/live-share-turbo/internals/FluidTurboClient.d.ts.map +0 -1
  188. package/bin/live-share-turbo/internals/FluidTurboClient.js +0 -121
  189. package/bin/live-share-turbo/internals/FluidTurboClient.js.map +0 -1
  190. package/bin/live-share-turbo/internals/index.d.ts +0 -2
  191. package/bin/live-share-turbo/internals/index.d.ts.map +0 -1
  192. package/bin/live-share-turbo/internals/index.js +0 -2
  193. package/bin/live-share-turbo/internals/index.js.map +0 -1
  194. package/bin/live-share-turbo/internals/types.d.ts +0 -4
  195. package/bin/live-share-turbo/internals/types.d.ts.map +0 -1
  196. package/bin/live-share-turbo/internals/types.js +0 -2
  197. package/bin/live-share-turbo/internals/types.js.map +0 -1
  198. package/bin/providers/FluidContextProvider.d.ts +0 -34
  199. package/bin/providers/FluidContextProvider.d.ts.map +0 -1
  200. package/bin/providers/FluidContextProvider.js +0 -99
  201. package/bin/providers/FluidContextProvider.js.map +0 -1
  202. package/bin/providers/LiveShareContextProvider.d.ts +0 -42
  203. package/bin/providers/LiveShareContextProvider.d.ts.map +0 -1
  204. package/bin/providers/LiveShareContextProvider.js +0 -63
  205. package/bin/providers/LiveShareContextProvider.js.map +0 -1
  206. package/bin/shared-hooks/useLockedTask.d.ts +0 -11
  207. package/bin/shared-hooks/useLockedTask.d.ts.map +0 -1
  208. package/bin/shared-hooks/useLockedTask.js +0 -82
  209. package/bin/shared-hooks/useLockedTask.js.map +0 -1
  210. package/bin/shared-hooks/useTaskManager.d.ts +0 -13
  211. package/bin/shared-hooks/useTaskManager.d.ts.map +0 -1
  212. package/bin/shared-hooks/useTaskManager.js +0 -86
  213. package/bin/shared-hooks/useTaskManager.js.map +0 -1
  214. package/bin/utils/getContainerSchema.d.ts +0 -8
  215. package/bin/utils/getContainerSchema.d.ts.map +0 -1
  216. package/bin/utils/getContainerSchema.js +0 -41
  217. package/bin/utils/getContainerSchema.js.map +0 -1
  218. package/src/internal-hooks/index.ts +0 -1
  219. package/src/shared-hooks/useTaskManager.ts +0 -82
  220. 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 lerna to hoist and build all dependencies.
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. Unlike other hooks, `useLivePresence` has a default ID set for you, but you can override it with your own if you'd like.
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
- "CUSTOM-USER-ID", // optional user id
184
- { name: "First Last" } // optional custom data object
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}>{user.name}</div>
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, data, setState] = useLiveState("CUSTOM-STATE-ID", ALLOWED_ROLES, ExampleAppState.WAITING);
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?.event.emoji}`}</div>
294
+ <div>{`Received: ${latestEvent?.value.emoji}`}</div>
291
295
  )}
292
296
  {latestEvent?.local === true && (
293
- <div>{`Sent: ${latestEvent?.event.emoji}`}</div>
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
- ```javascript
483
- import { DynamicObjectRegistry } from "@microsoft/live-share";
486
+ ```typescript
487
+ import React from "react";
484
488
  import { useDynamicDDS } from "@microsoft/live-share-react";
485
- import { SharedTree } from "@fluid-experimental/shared-tree";
486
- import { useCallback } from "react";
487
-
488
- // Register the experimental `SharedTree` DDS
489
- DynamicObjectRegistry.registerObjectClass(SharedTree, "SharedTree");
490
-
491
- // Custom useSharedTree hook
492
- export const useSharedTree = (uniqueKey) => {
493
- const onFirstInitialize = useCallback((dds) => {
494
- // Set initial values for the newly created SharedTree dds here
495
- }. []);
496
- const { dds: sharedTree } = useDynamicDDS(uniqueKey, SharedTree, onFirstInitialize);
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
- sharedTree,
565
+ lockedTask,
566
+ taskManager,
499
567
  };
500
- }
568
+ };
501
569
  ```
502
570
 
503
571
  ## Code samples
@@ -518,10 +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-preview.8 | ^2.5.0 | ~1.2.3 | 1.0.0-preview.8 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
522
- | 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) |
523
- | ~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) |
524
- | ~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 |
525
590
 
526
591
  ## Contributing
527
592
 
@@ -532,12 +597,12 @@ There are several ways you can [contribute](../../CONTRIBUTING.md) to this proje
532
597
  - Engage with other Live Share developers on [StackOverflow](https://stackoverflow.com/questions/tagged/live-share).
533
598
  - [Contribute bug fixes](../../CONTRIBUTING.md).
534
599
 
535
- 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.
536
601
 
537
602
  ## Reporting Security Issues
538
603
 
539
- 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/en-us/security/dn606155) key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default).
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).
540
605
 
541
606
  Copyright (c) Microsoft Corporation. All rights reserved.
542
607
 
543
- Licensed under a special [Microsoft](../../LICENSE) License.
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
- export interface IReceiveLiveEvent<TEvent extends object = object> {
6
- event: TEvent;
7
- local: boolean;
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,SAAS,MAAM,GAAG,MAAM;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAClB"}
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
@@ -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,4 @@
1
+ export * from "./useSharedStateRegistry";
2
+ export * from "./errors";
3
+ export * from "./type-guards";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -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,4 @@
1
+ export * from "./useSharedStateRegistry";
2
+ export * from "./errors";
3
+ export * from "./type-guards";
4
+ //# sourceMappingURL=index.js.map
@@ -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,6 @@
1
+ /**
2
+ * @hidden
3
+ * Used for useLiveState and useSharedState for checking if a value is a prevState callback
4
+ */
5
+ export declare function isPrevStateCallback<TState>(value: any): value is (value: TState) => TState;
6
+ //# sourceMappingURL=type-guards.d.ts.map
@@ -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,8 @@
1
+ /**
2
+ * @hidden
3
+ * Used for useLiveState and useSharedState for checking if a value is a prevState callback
4
+ */
5
+ export function isPrevStateCallback(value) {
6
+ return typeof value === "function";
7
+ }
8
+ //# sourceMappingURL=type-guards.js.map
@@ -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"}