@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.
Files changed (220) hide show
  1. package/README.md +99 -35
  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
@@ -1,82 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import React, { useEffect } from "react";
11
- import { TaskManager } from "@fluid-experimental/task-manager";
12
- import { useDynamicDDS } from "./useDynamicDDS";
13
- /**
14
- * 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.
15
- *
16
- * @param uniqueKey the unique key for the TaskManager DDS
17
- * @param taskId the task id to lock
18
- * @returns stateful data about the status of the task lock
19
- */
20
- export const useLockedTask = (uniqueKey, taskId) => {
21
- /**
22
- * TaskId currently in queue for
23
- */
24
- const currentTaskIdRef = React.useRef(undefined);
25
- /**
26
- * Stateful boolean that is true when the user is currently assigned the task
27
- */
28
- const [lockedTask, setLockedTask] = React.useState(false);
29
- /**
30
- * User facing: dynamically load the TaskManager DDS for the given unique key.
31
- */
32
- const { dds: taskManager } = useDynamicDDS(uniqueKey, TaskManager);
33
- /**
34
- * When the task id changes, lock the task. When the task id is undefined, abandon the task.
35
- */
36
- useEffect(() => {
37
- let mounted = true;
38
- if (taskManager) {
39
- if (taskId && currentTaskIdRef.current !== taskId) {
40
- if (currentTaskIdRef.current) {
41
- taskManager.abandon(currentTaskIdRef.current);
42
- setLockedTask(false);
43
- }
44
- currentTaskIdRef.current = taskId;
45
- const onLockTask = () => __awaiter(void 0, void 0, void 0, function* () {
46
- try {
47
- yield taskManager.lockTask(taskId);
48
- if (mounted) {
49
- setLockedTask(true);
50
- }
51
- }
52
- catch (_a) {
53
- if (mounted) {
54
- setLockedTask(false);
55
- currentTaskIdRef.current = undefined;
56
- }
57
- }
58
- });
59
- onLockTask();
60
- }
61
- else if (!taskId && currentTaskIdRef.current) {
62
- taskManager.abandon(currentTaskIdRef.current);
63
- setLockedTask(false);
64
- currentTaskIdRef.current = undefined;
65
- }
66
- }
67
- /**
68
- * When the component unmounts, abandon the task if it is still locked
69
- */
70
- return () => {
71
- mounted = false;
72
- if (currentTaskIdRef.current) {
73
- taskManager === null || taskManager === void 0 ? void 0 : taskManager.abandon(currentTaskIdRef.current);
74
- }
75
- currentTaskIdRef.current = undefined;
76
- };
77
- }, [taskManager, taskId]);
78
- return {
79
- lockedTask,
80
- };
81
- };
82
- //# sourceMappingURL=useLockedTask.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLockedTask.js","sourceRoot":"","sources":["../../src/shared-hooks/useLockedTask.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,MAAe,EAE9D,EAAE;IACA;;OAEG;IACH,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAqB,SAAS,CAAC,CAAC;IACrE;;OAEG;IACH,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,CAAC;IAEnE;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,aAAa,CAAc,SAAS,EAAE,WAAW,CAAC,CAAC;IAEhF;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,WAAW,EAAE;YACb,IAAI,MAAM,IAAI,gBAAgB,CAAC,OAAO,KAAK,MAAM,EAAE;gBAC/C,IAAI,gBAAgB,CAAC,OAAO,EAAE;oBAC1B,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;oBAC9C,aAAa,CAAC,KAAK,CAAC,CAAC;iBACxB;gBACD,gBAAgB,CAAC,OAAO,GAAG,MAAM,CAAC;gBAClC,MAAM,UAAU,GAAG,GAAS,EAAE;oBAC1B,IAAI;wBACA,MAAM,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;wBACnC,IAAI,OAAO,EAAE;4BACT,aAAa,CAAC,IAAI,CAAC,CAAC;yBACvB;qBACJ;oBAAC,WAAM;wBACJ,IAAI,OAAO,EAAE;4BACT,aAAa,CAAC,KAAK,CAAC,CAAC;4BACrB,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC;yBACxC;qBACJ;gBACL,CAAC,CAAA,CAAA;gBACD,UAAU,EAAE,CAAC;aAChB;iBAAM,IAAI,CAAC,MAAM,IAAI,gBAAgB,CAAC,OAAO,EAAE;gBAC5C,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;gBAC9C,aAAa,CAAC,KAAK,CAAC,CAAC;gBACrB,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC;aACxC;SACJ;QACD;;WAEG;QACH,OAAO,GAAG,EAAE;YACR,OAAO,GAAG,KAAK,CAAC;YAChB,IAAI,gBAAgB,CAAC,OAAO,EAAE;gBAC1B,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;aAClD;YACD,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC;QACzC,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAE1B,OAAO;QACH,UAAU;KACb,CAAC;AACN,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- import { TaskManager } from "@fluid-experimental/task-manager";
2
- /**
3
- * 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.
4
- *
5
- * @param uniqueKey the unique key for the TaskManager DDS
6
- * @param taskId the task id to lock
7
- * @returns stateful data about the status of the task lock
8
- */
9
- export declare const useTaskManager: (uniqueKey: string, taskId?: string) => {
10
- lockedTask: boolean;
11
- taskManager: TaskManager | undefined;
12
- };
13
- //# sourceMappingURL=useTaskManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTaskManager.d.ts","sourceRoot":"","sources":["../../src/shared-hooks/useTaskManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAG,MAAM,kCAAkC,CAAC;AAMhE;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,cAAe,MAAM,WAAW,MAAM;gBACjD,OAAO;iBACN,WAAW,GAAG,SAAS;CAgEvC,CAAC"}
@@ -1,86 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import React from "react";
11
- import { useDynamicDDS } from "./useDynamicDDS";
12
- import { TaskManager } from "@fluid-experimental/task-manager";
13
- import { DynamicObjectRegistry } from "@microsoft/live-share";
14
- // Register TaskManager as dynamic object
15
- DynamicObjectRegistry.registerObjectClass(TaskManager, TaskManager.getFactory().type);
16
- /**
17
- * 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.
18
- *
19
- * @param uniqueKey the unique key for the TaskManager DDS
20
- * @param taskId the task id to lock
21
- * @returns stateful data about the status of the task lock
22
- */
23
- export const useTaskManager = (uniqueKey, taskId) => {
24
- /**
25
- * TaskId currently in queue for
26
- */
27
- const currentTaskIdRef = React.useRef(undefined);
28
- /**
29
- * Stateful boolean that is true when the user is currently assigned the task
30
- */
31
- const [lockedTask, setLockedTask] = React.useState(false);
32
- /**
33
- * User facing: dynamically load the TaskManager DDS for the given unique key.
34
- */
35
- const { dds: taskManager } = useDynamicDDS(uniqueKey, TaskManager);
36
- /**
37
- * When the task id changes, lock the task. When the task id is undefined, abandon the task.
38
- */
39
- React.useEffect(() => {
40
- let mounted = true;
41
- if (taskManager) {
42
- if (taskId && currentTaskIdRef.current !== taskId) {
43
- if (currentTaskIdRef.current) {
44
- taskManager.abandon(currentTaskIdRef.current);
45
- setLockedTask(false);
46
- }
47
- currentTaskIdRef.current = taskId;
48
- const onLockTask = () => __awaiter(void 0, void 0, void 0, function* () {
49
- try {
50
- yield taskManager.lockTask(taskId);
51
- if (mounted) {
52
- setLockedTask(true);
53
- }
54
- }
55
- catch (_a) {
56
- if (mounted) {
57
- setLockedTask(false);
58
- currentTaskIdRef.current = undefined;
59
- }
60
- }
61
- });
62
- onLockTask();
63
- }
64
- else if (!taskId && currentTaskIdRef.current) {
65
- taskManager.abandon(currentTaskIdRef.current);
66
- setLockedTask(false);
67
- currentTaskIdRef.current = undefined;
68
- }
69
- }
70
- /**
71
- * When the component unmounts, abandon the task if it is still locked
72
- */
73
- return () => {
74
- mounted = false;
75
- if (currentTaskIdRef.current) {
76
- taskManager === null || taskManager === void 0 ? void 0 : taskManager.abandon(currentTaskIdRef.current);
77
- }
78
- currentTaskIdRef.current = undefined;
79
- };
80
- }, [taskManager, taskId]);
81
- return {
82
- lockedTask,
83
- taskManager,
84
- };
85
- };
86
- //# sourceMappingURL=useTaskManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useTaskManager.js","sourceRoot":"","sources":["../../src/shared-hooks/useTaskManager.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAG,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,yCAAyC;AACzC,qBAAqB,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAiB,EAAE,MAAe,EAG/D,EAAE;IACA;;OAEG;IACH,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAqB,SAAS,CAAC,CAAC;IACrE;;OAEG;IACH,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,CAAC;IAEnE;;OAEG;IACH,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,aAAa,CAAc,SAAS,EAAE,WAAW,CAAC,CAAC;IAEhF;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,OAAO,GAAG,IAAI,CAAC;QACnB,IAAI,WAAW,EAAE;YACb,IAAI,MAAM,IAAI,gBAAgB,CAAC,OAAO,KAAK,MAAM,EAAE;gBAC/C,IAAI,gBAAgB,CAAC,OAAO,EAAE;oBAC1B,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;oBAC9C,aAAa,CAAC,KAAK,CAAC,CAAC;iBACxB;gBACD,gBAAgB,CAAC,OAAO,GAAG,MAAM,CAAC;gBAClC,MAAM,UAAU,GAAG,GAAS,EAAE;oBAC1B,IAAI;wBACA,MAAM,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;wBACnC,IAAI,OAAO,EAAE;4BACT,aAAa,CAAC,IAAI,CAAC,CAAC;yBACvB;qBACJ;oBAAC,WAAM;wBACJ,IAAI,OAAO,EAAE;4BACT,aAAa,CAAC,KAAK,CAAC,CAAC;4BACrB,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC;yBACxC;qBACJ;gBACL,CAAC,CAAA,CAAA;gBACD,UAAU,EAAE,CAAC;aAChB;iBAAM,IAAI,CAAC,MAAM,IAAI,gBAAgB,CAAC,OAAO,EAAE;gBAC5C,WAAW,CAAC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;gBAC9C,aAAa,CAAC,KAAK,CAAC,CAAC;gBACrB,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC;aACxC;SACJ;QACD;;WAEG;QACH,OAAO,GAAG,EAAE;YACR,OAAO,GAAG,KAAK,CAAC;YAChB,IAAI,gBAAgB,CAAC,OAAO,EAAE;gBAC1B,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;aAClD;YACD,gBAAgB,CAAC,OAAO,GAAG,SAAS,CAAC;QACzC,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IAE1B,OAAO;QACH,UAAU;QACV,WAAW;KACd,CAAC;AACN,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- import { ContainerSchema, LoadableObjectClass } from "fluid-framework";
6
- export declare function getContainerSchema(additionalDynamicObjectTypes: LoadableObjectClass<any>[] | undefined): ContainerSchema;
7
- export declare function getLiveShareContainerSchema(additionalDynamicObjectTypes: LoadableObjectClass<any>[] | undefined): ContainerSchema;
8
- //# sourceMappingURL=getContainerSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getContainerSchema.d.ts","sourceRoot":"","sources":["../../src/utils/getContainerSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACH,eAAe,EACf,mBAAmB,EAItB,MAAM,iBAAiB,CAAC;AAUzB,wBAAgB,kBAAkB,CAC9B,4BAA4B,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,GACrE,eAAe,CAUjB;AAED,wBAAgB,2BAA2B,CACvC,4BAA4B,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAAE,GAAG,SAAS,mBAgBvE"}
@@ -1,41 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- import { LiveEvent, LivePresence, LiveState, LiveTimer, } from "@microsoft/live-share";
6
- import { LiveCanvas } from "@microsoft/live-share-canvas";
7
- import { LiveMediaSession } from "@microsoft/live-share-media";
8
- import { SharedDirectory, SharedMap, SharedString, } from "fluid-framework";
9
- const schema = {
10
- initialObjects: {
11
- stateMap: SharedMap,
12
- dynamicObjects: SharedMap,
13
- },
14
- dynamicObjectTypes: [SharedMap, SharedString, SharedDirectory],
15
- };
16
- export function getContainerSchema(additionalDynamicObjectTypes) {
17
- const _additionalDynamicObjectTypes = additionalDynamicObjectTypes !== null && additionalDynamicObjectTypes !== void 0 ? additionalDynamicObjectTypes : [];
18
- return {
19
- initialObjects: schema.initialObjects,
20
- dynamicObjectTypes: [
21
- ...schema.dynamicObjectTypes,
22
- ..._additionalDynamicObjectTypes,
23
- ],
24
- };
25
- }
26
- export function getLiveShareContainerSchema(additionalDynamicObjectTypes) {
27
- const liveShareDynamicObjects = [
28
- LiveEvent,
29
- LivePresence,
30
- LiveState,
31
- LiveMediaSession,
32
- LiveTimer,
33
- LiveCanvas,
34
- ];
35
- const _additionalDynamicObjectTypes = additionalDynamicObjectTypes !== null && additionalDynamicObjectTypes !== void 0 ? additionalDynamicObjectTypes : [];
36
- return getContainerSchema([
37
- ...liveShareDynamicObjects,
38
- ..._additionalDynamicObjectTypes,
39
- ]);
40
- }
41
- //# sourceMappingURL=getContainerSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getContainerSchema.js","sourceRoot":"","sources":["../../src/utils/getContainerSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,SAAS,EACT,YAAY,EACZ,SAAS,EACT,SAAS,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAGH,eAAe,EACf,SAAS,EACT,YAAY,GACf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,GAAoB;IAC5B,cAAc,EAAE;QACZ,QAAQ,EAAE,SAAS;QACnB,cAAc,EAAE,SAAS;KAC5B;IACD,kBAAkB,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,eAAe,CAAC;CACjE,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAC9B,4BAAoE;IAEpE,MAAM,6BAA6B,GAC/B,4BAA4B,aAA5B,4BAA4B,cAA5B,4BAA4B,GAAI,EAAE,CAAC;IACvC,OAAO;QACH,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,kBAAkB,EAAE;YAChB,GAAG,MAAM,CAAC,kBAAmB;YAC7B,GAAG,6BAA6B;SACnC;KACJ,CAAC;AACN,CAAC;AAED,MAAM,UAAU,2BAA2B,CACvC,4BAAoE;IAEpE,MAAM,uBAAuB,GAA+B;QACxD,SAAS;QACT,YAAY;QACZ,SAAS;QACT,gBAAgB;QAChB,SAAS;QACT,UAAU;KACb,CAAC;IACF,MAAM,6BAA6B,GAC/B,4BAA4B,aAA5B,4BAA4B,cAA5B,4BAA4B,GAAI,EAAE,CAAC;IACvC,OAAO,kBAAkB,CAAC;QACtB,GAAG,uBAAuB;QAC1B,GAAG,6BAA6B;KACnC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +0,0 @@
1
- export * from "./useSharedStateRegistry";
@@ -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
- info: Starting tinylicious@1.0.0-preview.4 {"label":"winston","timestamp":"2023-02-07T05:25:11.899Z"}
3
- info: Listening on port 7070 {"label":"winston","timestamp":"2023-02-07T05:25:11.921Z"}
4
- info: HEAD / 200 3.535 ms - 107 {"label":"winston","timestamp":"2023-02-07T05:25:13.499Z"}