@microsoft/live-share-react 2.0.0-internal.5 → 2.0.0-internal.7

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 (380) hide show
  1. package/.nycrc.json +9 -9
  2. package/LICENSE +64 -61
  3. package/README.md +173 -168
  4. package/bin/cjs/index.d.ts +7 -0
  5. package/bin/cjs/index.d.ts.map +1 -0
  6. package/bin/cjs/index.js +23 -0
  7. package/bin/cjs/index.js.map +1 -0
  8. package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  9. package/bin/cjs/interfaces/LiveInterfaceExtensions.js +7 -0
  10. package/bin/cjs/interfaces/LiveInterfaceExtensions.js.map +1 -0
  11. package/bin/cjs/interfaces/index.d.ts +2 -0
  12. package/bin/cjs/interfaces/index.d.ts.map +1 -0
  13. package/bin/cjs/interfaces/index.js +18 -0
  14. package/bin/cjs/interfaces/index.js.map +1 -0
  15. package/bin/cjs/internal/errors.d.ts.map +1 -0
  16. package/bin/cjs/internal/errors.js +48 -0
  17. package/bin/cjs/internal/errors.js.map +1 -0
  18. package/bin/cjs/internal/index.d.ts +3 -0
  19. package/bin/cjs/internal/index.d.ts.map +1 -0
  20. package/bin/cjs/internal/index.js +19 -0
  21. package/bin/cjs/internal/index.js.map +1 -0
  22. package/bin/{internal → cjs/internal}/type-guards.d.ts +1 -1
  23. package/bin/cjs/internal/type-guards.d.ts.map +1 -0
  24. package/bin/cjs/internal/type-guards.js +24 -0
  25. package/bin/cjs/internal/type-guards.js.map +1 -0
  26. package/bin/cjs/live-hooks/index.d.ts +8 -0
  27. package/bin/cjs/live-hooks/index.d.ts.map +1 -0
  28. package/bin/cjs/live-hooks/index.js +24 -0
  29. package/bin/cjs/live-hooks/index.js.map +1 -0
  30. package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
  31. package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
  32. package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
  33. package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
  34. package/bin/{live-hooks → cjs/live-hooks}/useLiveEvent.d.ts +37 -1
  35. package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
  36. package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
  37. package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
  38. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
  39. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  40. package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
  41. package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
  42. package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
  43. package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
  44. package/bin/cjs/live-hooks/useLivePresence.js +170 -0
  45. package/bin/cjs/live-hooks/useLivePresence.js.map +1 -0
  46. package/bin/{live-hooks → cjs/live-hooks}/useLiveState.d.ts +46 -1
  47. package/bin/cjs/live-hooks/useLiveState.d.ts.map +1 -0
  48. package/bin/cjs/live-hooks/useLiveState.js +130 -0
  49. package/bin/cjs/live-hooks/useLiveState.js.map +1 -0
  50. package/bin/{live-hooks → cjs/live-hooks}/useLiveTimer.d.ts +56 -1
  51. package/bin/cjs/live-hooks/useLiveTimer.d.ts.map +1 -0
  52. package/bin/cjs/live-hooks/useLiveTimer.js +233 -0
  53. package/bin/cjs/live-hooks/useLiveTimer.js.map +1 -0
  54. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts +86 -0
  55. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  56. package/bin/cjs/live-hooks/useMediaSynchronizer.js +301 -0
  57. package/bin/cjs/live-hooks/useMediaSynchronizer.js.map +1 -0
  58. package/bin/cjs/package.json +1 -0
  59. package/bin/{providers → cjs/providers}/AzureProvider.d.ts +9 -9
  60. package/bin/cjs/providers/AzureProvider.d.ts.map +1 -0
  61. package/bin/cjs/providers/AzureProvider.js +127 -0
  62. package/bin/cjs/providers/AzureProvider.js.map +1 -0
  63. package/bin/{providers → cjs/providers}/LiveShareProvider.d.ts +106 -4
  64. package/bin/cjs/providers/LiveShareProvider.d.ts.map +1 -0
  65. package/bin/cjs/providers/LiveShareProvider.js +205 -0
  66. package/bin/cjs/providers/LiveShareProvider.js.map +1 -0
  67. package/bin/cjs/providers/index.d.ts +3 -0
  68. package/bin/cjs/providers/index.d.ts.map +1 -0
  69. package/bin/cjs/providers/index.js +19 -0
  70. package/bin/cjs/providers/index.js.map +1 -0
  71. package/bin/cjs/shared-hooks/index.d.ts +7 -0
  72. package/bin/cjs/shared-hooks/index.d.ts.map +1 -0
  73. package/bin/cjs/shared-hooks/index.js +23 -0
  74. package/bin/cjs/shared-hooks/index.js.map +1 -0
  75. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  76. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  77. package/bin/cjs/shared-hooks/internals/tree-node-constants.js +6 -0
  78. package/bin/cjs/shared-hooks/internals/tree-node-constants.js.map +1 -0
  79. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts +10 -0
  80. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  81. package/bin/cjs/shared-hooks/internals/tree-node-types.js +23 -0
  82. package/bin/cjs/shared-hooks/internals/tree-node-types.js.map +1 -0
  83. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  84. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  85. package/bin/cjs/shared-hooks/internals/tree-node-utils.js +193 -0
  86. package/bin/cjs/shared-hooks/internals/tree-node-utils.js.map +1 -0
  87. package/bin/{shared-hooks → cjs/shared-hooks}/useDynamicDDS.d.ts +4 -4
  88. package/bin/cjs/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  89. package/bin/cjs/shared-hooks/useDynamicDDS.js +87 -0
  90. package/bin/cjs/shared-hooks/useDynamicDDS.js.map +1 -0
  91. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedMap.d.ts +4 -2
  92. package/bin/cjs/shared-hooks/useSharedMap.d.ts.map +1 -0
  93. package/bin/cjs/shared-hooks/useSharedMap.js +134 -0
  94. package/bin/cjs/shared-hooks/useSharedMap.js.map +1 -0
  95. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedState.d.ts +1 -1
  96. package/bin/cjs/shared-hooks/useSharedState.d.ts.map +1 -0
  97. package/bin/cjs/shared-hooks/useSharedState.js +80 -0
  98. package/bin/cjs/shared-hooks/useSharedState.js.map +1 -0
  99. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedStateRegistry.d.ts +1 -1
  100. package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  101. package/bin/cjs/shared-hooks/useSharedStateRegistry.js +120 -0
  102. package/bin/cjs/shared-hooks/useSharedStateRegistry.js.map +1 -0
  103. package/bin/cjs/shared-hooks/useSharedTree.d.ts +57 -0
  104. package/bin/cjs/shared-hooks/useSharedTree.d.ts.map +1 -0
  105. package/bin/cjs/shared-hooks/useSharedTree.js +123 -0
  106. package/bin/cjs/shared-hooks/useSharedTree.js.map +1 -0
  107. package/bin/cjs/shared-hooks/useTreeNode.d.ts +96 -0
  108. package/bin/cjs/shared-hooks/useTreeNode.d.ts.map +1 -0
  109. package/bin/cjs/shared-hooks/useTreeNode.js +135 -0
  110. package/bin/cjs/shared-hooks/useTreeNode.js.map +1 -0
  111. package/bin/{types → cjs/types}/ActionTypes.d.ts +7 -7
  112. package/bin/cjs/types/ActionTypes.d.ts.map +1 -0
  113. package/bin/cjs/types/ActionTypes.js +7 -0
  114. package/bin/cjs/types/ActionTypes.js.map +1 -0
  115. package/bin/cjs/types/PropTypes.d.ts +56 -0
  116. package/bin/cjs/types/PropTypes.d.ts.map +1 -0
  117. package/bin/cjs/types/PropTypes.js +7 -0
  118. package/bin/cjs/types/PropTypes.js.map +1 -0
  119. package/bin/{types → cjs/types}/ResultTypes.d.ts +50 -18
  120. package/bin/cjs/types/ResultTypes.d.ts.map +1 -0
  121. package/bin/cjs/types/ResultTypes.js +7 -0
  122. package/bin/cjs/types/ResultTypes.js.map +1 -0
  123. package/bin/cjs/types/index.d.ts +4 -0
  124. package/bin/cjs/types/index.d.ts.map +1 -0
  125. package/bin/cjs/types/index.js +20 -0
  126. package/bin/cjs/types/index.js.map +1 -0
  127. package/bin/cjs/utils/index.d.ts +2 -0
  128. package/bin/cjs/utils/index.d.ts.map +1 -0
  129. package/bin/cjs/utils/index.js +18 -0
  130. package/bin/cjs/utils/index.js.map +1 -0
  131. package/bin/cjs/utils/type-check.d.ts.map +1 -0
  132. package/bin/cjs/utils/type-check.js +62 -0
  133. package/bin/cjs/utils/type-check.js.map +1 -0
  134. package/bin/esm/index.d.ts +7 -0
  135. package/bin/esm/index.d.ts.map +1 -0
  136. package/bin/esm/index.js +7 -0
  137. package/bin/esm/index.js.map +1 -0
  138. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts +26 -0
  139. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  140. package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
  141. package/bin/esm/interfaces/index.d.ts +2 -0
  142. package/bin/esm/interfaces/index.d.ts.map +1 -0
  143. package/bin/esm/interfaces/index.js +2 -0
  144. package/bin/esm/interfaces/index.js.map +1 -0
  145. package/bin/esm/internal/errors.d.ts +41 -0
  146. package/bin/esm/internal/errors.d.ts.map +1 -0
  147. package/bin/esm/internal/errors.js.map +1 -0
  148. package/bin/esm/internal/index.d.ts +3 -0
  149. package/bin/esm/internal/index.d.ts.map +1 -0
  150. package/bin/esm/internal/index.js +3 -0
  151. package/bin/esm/internal/index.js.map +1 -0
  152. package/bin/esm/internal/type-guards.d.ts +11 -0
  153. package/bin/esm/internal/type-guards.d.ts.map +1 -0
  154. package/bin/esm/internal/type-guards.js.map +1 -0
  155. package/bin/esm/live-hooks/index.d.ts +8 -0
  156. package/bin/esm/live-hooks/index.d.ts.map +1 -0
  157. package/bin/esm/live-hooks/index.js +8 -0
  158. package/bin/esm/live-hooks/index.js.map +1 -0
  159. package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
  160. package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
  161. package/bin/esm/live-hooks/useLiveCanvas.js +238 -0
  162. package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
  163. package/bin/esm/live-hooks/useLiveEvent.d.ts +59 -0
  164. package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
  165. package/bin/{live-hooks → esm/live-hooks}/useLiveEvent.js +41 -5
  166. package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
  167. package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
  168. package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  169. package/bin/{live-hooks → esm/live-hooks}/useLiveFollowMode.js +148 -5
  170. package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
  171. package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
  172. package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
  173. package/bin/{live-hooks → esm/live-hooks}/useLivePresence.js +71 -13
  174. package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
  175. package/bin/esm/live-hooks/useLiveState.d.ts +66 -0
  176. package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
  177. package/bin/{live-hooks → esm/live-hooks}/useLiveState.js +48 -3
  178. package/bin/esm/live-hooks/useLiveState.js.map +1 -0
  179. package/bin/esm/live-hooks/useLiveTimer.d.ts +80 -0
  180. package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
  181. package/bin/{live-hooks → esm/live-hooks}/useLiveTimer.js +58 -3
  182. package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
  183. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
  184. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  185. package/bin/{live-hooks → esm/live-hooks}/useMediaSynchronizer.js +65 -4
  186. package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
  187. package/bin/esm/providers/AzureProvider.d.ts +113 -0
  188. package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
  189. package/bin/{providers → esm/providers}/AzureProvider.js +10 -10
  190. package/bin/esm/providers/AzureProvider.js.map +1 -0
  191. package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
  192. package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
  193. package/bin/{providers → esm/providers}/LiveShareProvider.js +111 -9
  194. package/bin/esm/providers/LiveShareProvider.js.map +1 -0
  195. package/bin/esm/providers/index.d.ts +3 -0
  196. package/bin/esm/providers/index.d.ts.map +1 -0
  197. package/bin/esm/providers/index.js +3 -0
  198. package/bin/esm/providers/index.js.map +1 -0
  199. package/bin/esm/shared-hooks/index.d.ts +7 -0
  200. package/bin/esm/shared-hooks/index.d.ts.map +1 -0
  201. package/bin/esm/shared-hooks/index.js +7 -0
  202. package/bin/esm/shared-hooks/index.js.map +1 -0
  203. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  204. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  205. package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
  206. package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
  207. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
  208. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  209. package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
  210. package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
  211. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  212. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  213. package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
  214. package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
  215. package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
  216. package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  217. package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.js +20 -11
  218. package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
  219. package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
  220. package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
  221. package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.js +27 -13
  222. package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
  223. package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
  224. package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
  225. package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.js +2 -2
  226. package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
  227. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
  228. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  229. package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.js +27 -19
  230. package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
  231. package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
  232. package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
  233. package/bin/esm/shared-hooks/useSharedTree.js +117 -0
  234. package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
  235. package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
  236. package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
  237. package/bin/esm/shared-hooks/useTreeNode.js +132 -0
  238. package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
  239. package/bin/esm/types/ActionTypes.d.ts +112 -0
  240. package/bin/esm/types/ActionTypes.d.ts.map +1 -0
  241. package/bin/esm/types/ActionTypes.js.map +1 -0
  242. package/bin/esm/types/PropTypes.d.ts +56 -0
  243. package/bin/esm/types/PropTypes.d.ts.map +1 -0
  244. package/bin/esm/types/PropTypes.js.map +1 -0
  245. package/bin/esm/types/ResultTypes.d.ts +334 -0
  246. package/bin/esm/types/ResultTypes.d.ts.map +1 -0
  247. package/bin/esm/types/ResultTypes.js.map +1 -0
  248. package/bin/esm/types/index.d.ts +4 -0
  249. package/bin/esm/types/index.d.ts.map +1 -0
  250. package/bin/esm/types/index.js +4 -0
  251. package/bin/esm/types/index.js.map +1 -0
  252. package/bin/esm/utils/index.d.ts +2 -0
  253. package/bin/esm/utils/index.d.ts.map +1 -0
  254. package/bin/esm/utils/index.js +2 -0
  255. package/bin/esm/utils/index.js.map +1 -0
  256. package/bin/esm/utils/type-check.d.ts +15 -0
  257. package/bin/esm/utils/type-check.d.ts.map +1 -0
  258. package/bin/esm/utils/type-check.js.map +1 -0
  259. package/package.json +61 -47
  260. package/src/index.ts +6 -6
  261. package/src/interfaces/index.ts +1 -1
  262. package/src/internal/index.ts +2 -2
  263. package/src/internal/type-guards.ts +1 -1
  264. package/src/live-hooks/index.ts +7 -7
  265. package/src/live-hooks/useLiveCanvas.ts +154 -82
  266. package/src/live-hooks/useLiveEvent.ts +43 -7
  267. package/src/live-hooks/useLiveFollowMode.ts +149 -6
  268. package/src/live-hooks/useLivePresence.ts +80 -17
  269. package/src/live-hooks/useLiveState.ts +49 -4
  270. package/src/live-hooks/useLiveTimer.ts +59 -4
  271. package/src/live-hooks/useMediaSynchronizer.ts +70 -5
  272. package/src/providers/AzureProvider.tsx +21 -21
  273. package/src/providers/LiveShareProvider.tsx +115 -13
  274. package/src/providers/index.ts +2 -2
  275. package/src/shared-hooks/index.ts +6 -4
  276. package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
  277. package/src/shared-hooks/internals/tree-node-types.ts +26 -0
  278. package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
  279. package/src/shared-hooks/useDynamicDDS.ts +28 -17
  280. package/src/shared-hooks/useSharedMap.ts +42 -17
  281. package/src/shared-hooks/useSharedState.ts +6 -3
  282. package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
  283. package/src/shared-hooks/useSharedTree.ts +144 -0
  284. package/src/shared-hooks/useTreeNode.ts +147 -0
  285. package/src/types/ActionTypes.ts +13 -9
  286. package/src/types/PropTypes.ts +57 -0
  287. package/src/types/ResultTypes.ts +71 -17
  288. package/src/types/index.ts +3 -3
  289. package/src/utils/index.ts +1 -1
  290. package/tsconfig.cjs.json +14 -0
  291. package/tsconfig.json +65 -70
  292. package/bin/index.d.ts +0 -7
  293. package/bin/index.d.ts.map +0 -1
  294. package/bin/index.js +0 -7
  295. package/bin/index.js.map +0 -1
  296. package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +0 -1
  297. package/bin/interfaces/LiveInterfaceExtensions.js.map +0 -1
  298. package/bin/interfaces/index.d.ts +0 -2
  299. package/bin/interfaces/index.d.ts.map +0 -1
  300. package/bin/interfaces/index.js +0 -2
  301. package/bin/interfaces/index.js.map +0 -1
  302. package/bin/internal/errors.d.ts.map +0 -1
  303. package/bin/internal/errors.js.map +0 -1
  304. package/bin/internal/index.d.ts +0 -3
  305. package/bin/internal/index.d.ts.map +0 -1
  306. package/bin/internal/index.js +0 -3
  307. package/bin/internal/index.js.map +0 -1
  308. package/bin/internal/type-guards.d.ts.map +0 -1
  309. package/bin/internal/type-guards.js.map +0 -1
  310. package/bin/live-hooks/index.d.ts +0 -8
  311. package/bin/live-hooks/index.d.ts.map +0 -1
  312. package/bin/live-hooks/index.js +0 -8
  313. package/bin/live-hooks/index.js.map +0 -1
  314. package/bin/live-hooks/useLiveCanvas.d.ts +0 -29
  315. package/bin/live-hooks/useLiveCanvas.d.ts.map +0 -1
  316. package/bin/live-hooks/useLiveCanvas.js +0 -160
  317. package/bin/live-hooks/useLiveCanvas.js.map +0 -1
  318. package/bin/live-hooks/useLiveEvent.d.ts.map +0 -1
  319. package/bin/live-hooks/useLiveEvent.js.map +0 -1
  320. package/bin/live-hooks/useLiveFollowMode.d.ts +0 -24
  321. package/bin/live-hooks/useLiveFollowMode.d.ts.map +0 -1
  322. package/bin/live-hooks/useLiveFollowMode.js.map +0 -1
  323. package/bin/live-hooks/useLivePresence.d.ts +0 -26
  324. package/bin/live-hooks/useLivePresence.d.ts.map +0 -1
  325. package/bin/live-hooks/useLivePresence.js.map +0 -1
  326. package/bin/live-hooks/useLiveState.d.ts.map +0 -1
  327. package/bin/live-hooks/useLiveState.js.map +0 -1
  328. package/bin/live-hooks/useLiveTimer.d.ts.map +0 -1
  329. package/bin/live-hooks/useLiveTimer.js.map +0 -1
  330. package/bin/live-hooks/useMediaSynchronizer.d.ts +0 -25
  331. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +0 -1
  332. package/bin/live-hooks/useMediaSynchronizer.js.map +0 -1
  333. package/bin/providers/AzureProvider.d.ts.map +0 -1
  334. package/bin/providers/AzureProvider.js.map +0 -1
  335. package/bin/providers/LiveShareProvider.d.ts.map +0 -1
  336. package/bin/providers/LiveShareProvider.js.map +0 -1
  337. package/bin/providers/index.d.ts +0 -3
  338. package/bin/providers/index.d.ts.map +0 -1
  339. package/bin/providers/index.js +0 -3
  340. package/bin/providers/index.js.map +0 -1
  341. package/bin/shared-hooks/index.d.ts +0 -5
  342. package/bin/shared-hooks/index.d.ts.map +0 -1
  343. package/bin/shared-hooks/index.js +0 -5
  344. package/bin/shared-hooks/index.js.map +0 -1
  345. package/bin/shared-hooks/useDynamicDDS.d.ts.map +0 -1
  346. package/bin/shared-hooks/useDynamicDDS.js.map +0 -1
  347. package/bin/shared-hooks/useSharedMap.d.ts.map +0 -1
  348. package/bin/shared-hooks/useSharedMap.js.map +0 -1
  349. package/bin/shared-hooks/useSharedState.d.ts.map +0 -1
  350. package/bin/shared-hooks/useSharedState.js.map +0 -1
  351. package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +0 -1
  352. package/bin/shared-hooks/useSharedStateRegistry.js.map +0 -1
  353. package/bin/types/ActionTypes.d.ts.map +0 -1
  354. package/bin/types/ActionTypes.js.map +0 -1
  355. package/bin/types/PropTypes.d.ts +0 -8
  356. package/bin/types/PropTypes.d.ts.map +0 -1
  357. package/bin/types/PropTypes.js.map +0 -1
  358. package/bin/types/ResultTypes.d.ts.map +0 -1
  359. package/bin/types/ResultTypes.js.map +0 -1
  360. package/bin/types/index.d.ts +0 -4
  361. package/bin/types/index.d.ts.map +0 -1
  362. package/bin/types/index.js +0 -4
  363. package/bin/types/index.js.map +0 -1
  364. package/bin/utils/index.d.ts +0 -2
  365. package/bin/utils/index.d.ts.map +0 -1
  366. package/bin/utils/index.js +0 -2
  367. package/bin/utils/index.js.map +0 -1
  368. package/bin/utils/type-check.d.ts.map +0 -1
  369. package/bin/utils/type-check.js.map +0 -1
  370. package/tsconfig.build.json +0 -6
  371. /package/bin/{interfaces → cjs/interfaces}/LiveInterfaceExtensions.d.ts +0 -0
  372. /package/bin/{internal → cjs/internal}/errors.d.ts +0 -0
  373. /package/bin/{utils → cjs/utils}/type-check.d.ts +0 -0
  374. /package/bin/{interfaces → esm/interfaces}/LiveInterfaceExtensions.js +0 -0
  375. /package/bin/{internal → esm/internal}/errors.js +0 -0
  376. /package/bin/{internal → esm/internal}/type-guards.js +0 -0
  377. /package/bin/{types → esm/types}/ActionTypes.js +0 -0
  378. /package/bin/{types → esm/types}/PropTypes.js +0 -0
  379. /package/bin/{types → esm/types}/ResultTypes.js +0 -0
  380. /package/bin/{utils → esm/utils}/type-check.js +0 -0
@@ -0,0 +1,163 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { UserMeetingRole } from "@microsoft/live-share";
6
+ import { IUseLiveFollowModeResults } from "../types/index.js";
7
+ /**
8
+ * React hook for using a Live Share `LiveFollowMode`.
9
+ *
10
+ * @remarks
11
+ * Use this hook if you want to add the ability to follow specific users or let a user present to everyone in the session.
12
+ * Each user has their own `stateValue`, which is the value other users will reference when that user is presenting or being followed.
13
+ * The `state` response includes the user's `value` that the local user is "following", whether it be their own or someone else's.
14
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
15
+ *
16
+ * @template TData Optional typing for the custom user presence data object. Default is `object` type.
17
+ *
18
+ * @param uniqueKey The unique key for `LiveFollowMode`. If one does not yet exist, a new one will be created.
19
+ * @param initialData The initial value for the local user's `stateValue`.
20
+ * @param allowedRoles Optional. The user roles that are allowed to present to use `startPresenting()` or `stopPresenting()`.
21
+ * @returns `IUseLiveFollowModeResults` results, which contains React stateful objects and callbacks.
22
+ *
23
+ * @example
24
+ ```jsx
25
+ import { FollowModeType } from "@microsoft/live-share";
26
+ import { useLiveFollowMode } from "@microsoft/live-share-react";
27
+ // As an example, we will use a fake component to denote what a 3D viewer might look like in an app
28
+ import { Example3DModelViewer } from "./components";
29
+
30
+ // Define a unique key that differentiates this usage of `useLiveFollowMode` from others in your app
31
+ const MY_UNIQUE_KEY = "follow-mode-key";
32
+
33
+ // Define the initial stateValue for the local user (optional).
34
+ const startingCameraPosition = {
35
+ x: 0,
36
+ y: 0,
37
+ z: 0,
38
+ };
39
+
40
+ // Example component for using useLiveFollowMode
41
+ export function MyLiveFollowMode() {
42
+ const {
43
+ state,
44
+ localUser,
45
+ otherUsers,
46
+ allUsers,
47
+ liveFollowMode,
48
+ update,
49
+ startPresenting,
50
+ stopPresenting,
51
+ beginSuspension,
52
+ endSuspension,
53
+ followUser,
54
+ stopFollowing,
55
+ } = useLiveFollowMode(MY_UNIQUE_KEY, startingCameraPosition);
56
+
57
+ // Example of an event listener for a camera position changed event.
58
+ // For something like a camera change event, you should use a debounce function.
59
+ function onCameraPositionChanged(position, isUserAction) {
60
+ // Broadcast change to other users so that they have their latest camera position
61
+ update(position);
62
+ // If the local user changed the position while following another user, we want to suspend.
63
+ // Note: helps to distinguish changes initiated by the local user (e.g., drag mouse) separately from other change events.
64
+ if (!isUserAction) return;
65
+ switch (state.type) {
66
+ case FollowModeType.followPresenter:
67
+ case FollowModeType.followUser: {
68
+ // This will trigger a "stateChanged" event update for the local user only.
69
+ followMode.beginSuspension();
70
+ break;
71
+ }
72
+ default: {
73
+ // No need to suspend for other types
74
+ break;
75
+ }
76
+ }
77
+ }
78
+
79
+ // Can optionally get the relevant user's presence object
80
+ const followingUser = liveFollowMode?.getUser(state.followingUserId);
81
+
82
+ // Render loading UI when creating LiveFollowMode instance for first time
83
+ if (!liveFollowMode) return <>Loading...</>;
84
+
85
+ // Render UI
86
+ return (
87
+ <div>
88
+ {state.type === FollowModeType.local && (
89
+ <div>
90
+ <p>{""}</p>
91
+ <button onClick={startPresenting}>
92
+ {"Start presenting"}
93
+ </button>
94
+ </div>
95
+ )}
96
+ {state.type === FollowModeType.activeFollowers && (
97
+ <div>
98
+ <p>{`${state.otherUsersCount} users are following you`}</p>
99
+ <button onClick={startPresenting}>
100
+ {"Present to all"}
101
+ </button>
102
+ </div>
103
+ )}
104
+ {state.type === FollowModeType.activePresenter && (
105
+ <div>
106
+ <p>{`You are actively presenting to everyone`}</p>
107
+ <button onClick={stopPresenting}>
108
+ {"Stop presenting"}
109
+ </button>
110
+ </div>
111
+ )}
112
+ {state.type === FollowModeType.followPresenter && (
113
+ <div>
114
+ <p>{`${followingUser?.displayName} is presenting to everyone`}</p>
115
+ <button onClick={startPresenting}>{"Take control"}</button>
116
+ </div>
117
+ )}
118
+ {state.type === FollowModeType.suspendFollowPresenter && (
119
+ <div>
120
+ <p>{`${followingUser?.displayName} is presenting to everyone`}</p>
121
+ <button onClick={endSuspension}>
122
+ {"Sync to presenter"}
123
+ </button>
124
+ </div>
125
+ )}
126
+ {state.type === FollowModeType.followUser && (
127
+ <div>
128
+ <p>{`You are following ${followingUser?.displayName}`}</p>
129
+ <button onClick={stopFollowing}>{"Stop following"}</button>
130
+ </div>
131
+ )}
132
+ {state.type === FollowModeType.suspendFollowUser && (
133
+ <div>
134
+ <p>{`You were following ${followingUser?.displayName}`}</p>
135
+ <button onClick={stopFollowing}>
136
+ {"Resume following"}
137
+ </button>
138
+ </div>
139
+ )}
140
+ <div>
141
+ <p>{"Follow a specific user:"}</p>
142
+ {otherUsers.map((user) => (
143
+ <button
144
+ onClick={() => {
145
+ followUser(user.userId);
146
+ }}
147
+ key={user.userId}
148
+ >
149
+ {user.displayName}
150
+ </button>
151
+ ))}
152
+ </div>
153
+ <Example3DModelViewer
154
+ cameraPosition={state.value}
155
+ onCameraPositionChanged={onCameraPositionChanged}
156
+ />
157
+ </div>
158
+ );
159
+ };
160
+ ```
161
+ */
162
+ export declare function useLiveFollowMode<TData = any>(uniqueKey: string, initialData: TData | (() => TData), allowedRoles?: UserMeetingRole[]): IUseLiveFollowModeResults<TData>;
163
+ //# sourceMappingURL=useLiveFollowMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveFollowMode.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveFollowMode.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAKlB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0JG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAG,GAAG,EACzC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EAClC,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,yBAAyB,CAAC,KAAK,CAAC,CA+QlC"}
@@ -0,0 +1,360 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the Microsoft Live Share SDK License.
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __importDefault = (this && this.__importDefault) || function (mod) {
16
+ return (mod && mod.__esModule) ? mod : { "default": mod };
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.useLiveFollowMode = useLiveFollowMode;
20
+ const live_share_1 = require("@microsoft/live-share");
21
+ const react_1 = __importDefault(require("react"));
22
+ const index_js_1 = require("../shared-hooks/index.js");
23
+ const index_js_2 = require("../providers/index.js");
24
+ const index_js_3 = require("../internal/index.js");
25
+ /**
26
+ * React hook for using a Live Share `LiveFollowMode`.
27
+ *
28
+ * @remarks
29
+ * Use this hook if you want to add the ability to follow specific users or let a user present to everyone in the session.
30
+ * Each user has their own `stateValue`, which is the value other users will reference when that user is presenting or being followed.
31
+ * The `state` response includes the user's `value` that the local user is "following", whether it be their own or someone else's.
32
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
33
+ *
34
+ * @template TData Optional typing for the custom user presence data object. Default is `object` type.
35
+ *
36
+ * @param uniqueKey The unique key for `LiveFollowMode`. If one does not yet exist, a new one will be created.
37
+ * @param initialData The initial value for the local user's `stateValue`.
38
+ * @param allowedRoles Optional. The user roles that are allowed to present to use `startPresenting()` or `stopPresenting()`.
39
+ * @returns `IUseLiveFollowModeResults` results, which contains React stateful objects and callbacks.
40
+ *
41
+ * @example
42
+ ```jsx
43
+ import { FollowModeType } from "@microsoft/live-share";
44
+ import { useLiveFollowMode } from "@microsoft/live-share-react";
45
+ // As an example, we will use a fake component to denote what a 3D viewer might look like in an app
46
+ import { Example3DModelViewer } from "./components";
47
+
48
+ // Define a unique key that differentiates this usage of `useLiveFollowMode` from others in your app
49
+ const MY_UNIQUE_KEY = "follow-mode-key";
50
+
51
+ // Define the initial stateValue for the local user (optional).
52
+ const startingCameraPosition = {
53
+ x: 0,
54
+ y: 0,
55
+ z: 0,
56
+ };
57
+
58
+ // Example component for using useLiveFollowMode
59
+ export function MyLiveFollowMode() {
60
+ const {
61
+ state,
62
+ localUser,
63
+ otherUsers,
64
+ allUsers,
65
+ liveFollowMode,
66
+ update,
67
+ startPresenting,
68
+ stopPresenting,
69
+ beginSuspension,
70
+ endSuspension,
71
+ followUser,
72
+ stopFollowing,
73
+ } = useLiveFollowMode(MY_UNIQUE_KEY, startingCameraPosition);
74
+
75
+ // Example of an event listener for a camera position changed event.
76
+ // For something like a camera change event, you should use a debounce function.
77
+ function onCameraPositionChanged(position, isUserAction) {
78
+ // Broadcast change to other users so that they have their latest camera position
79
+ update(position);
80
+ // If the local user changed the position while following another user, we want to suspend.
81
+ // Note: helps to distinguish changes initiated by the local user (e.g., drag mouse) separately from other change events.
82
+ if (!isUserAction) return;
83
+ switch (state.type) {
84
+ case FollowModeType.followPresenter:
85
+ case FollowModeType.followUser: {
86
+ // This will trigger a "stateChanged" event update for the local user only.
87
+ followMode.beginSuspension();
88
+ break;
89
+ }
90
+ default: {
91
+ // No need to suspend for other types
92
+ break;
93
+ }
94
+ }
95
+ }
96
+
97
+ // Can optionally get the relevant user's presence object
98
+ const followingUser = liveFollowMode?.getUser(state.followingUserId);
99
+
100
+ // Render loading UI when creating LiveFollowMode instance for first time
101
+ if (!liveFollowMode) return <>Loading...</>;
102
+
103
+ // Render UI
104
+ return (
105
+ <div>
106
+ {state.type === FollowModeType.local && (
107
+ <div>
108
+ <p>{""}</p>
109
+ <button onClick={startPresenting}>
110
+ {"Start presenting"}
111
+ </button>
112
+ </div>
113
+ )}
114
+ {state.type === FollowModeType.activeFollowers && (
115
+ <div>
116
+ <p>{`${state.otherUsersCount} users are following you`}</p>
117
+ <button onClick={startPresenting}>
118
+ {"Present to all"}
119
+ </button>
120
+ </div>
121
+ )}
122
+ {state.type === FollowModeType.activePresenter && (
123
+ <div>
124
+ <p>{`You are actively presenting to everyone`}</p>
125
+ <button onClick={stopPresenting}>
126
+ {"Stop presenting"}
127
+ </button>
128
+ </div>
129
+ )}
130
+ {state.type === FollowModeType.followPresenter && (
131
+ <div>
132
+ <p>{`${followingUser?.displayName} is presenting to everyone`}</p>
133
+ <button onClick={startPresenting}>{"Take control"}</button>
134
+ </div>
135
+ )}
136
+ {state.type === FollowModeType.suspendFollowPresenter && (
137
+ <div>
138
+ <p>{`${followingUser?.displayName} is presenting to everyone`}</p>
139
+ <button onClick={endSuspension}>
140
+ {"Sync to presenter"}
141
+ </button>
142
+ </div>
143
+ )}
144
+ {state.type === FollowModeType.followUser && (
145
+ <div>
146
+ <p>{`You are following ${followingUser?.displayName}`}</p>
147
+ <button onClick={stopFollowing}>{"Stop following"}</button>
148
+ </div>
149
+ )}
150
+ {state.type === FollowModeType.suspendFollowUser && (
151
+ <div>
152
+ <p>{`You were following ${followingUser?.displayName}`}</p>
153
+ <button onClick={stopFollowing}>
154
+ {"Resume following"}
155
+ </button>
156
+ </div>
157
+ )}
158
+ <div>
159
+ <p>{"Follow a specific user:"}</p>
160
+ {otherUsers.map((user) => (
161
+ <button
162
+ onClick={() => {
163
+ followUser(user.userId);
164
+ }}
165
+ key={user.userId}
166
+ >
167
+ {user.displayName}
168
+ </button>
169
+ ))}
170
+ </div>
171
+ <Example3DModelViewer
172
+ cameraPosition={state.value}
173
+ onCameraPositionChanged={onCameraPositionChanged}
174
+ />
175
+ </div>
176
+ );
177
+ };
178
+ ```
179
+ */
180
+ function useLiveFollowMode(uniqueKey, initialData, allowedRoles) {
181
+ /**
182
+ * Stateful follow state.
183
+ */
184
+ const [state, setState] = react_1.default.useState();
185
+ /**
186
+ * Stateful all user presence list and its non-user-facing setter method.
187
+ */
188
+ const [allUsers, setAllUsers] = react_1.default.useState([]);
189
+ /**
190
+ * User facing: dynamically load the DDS for the given unique key.
191
+ */
192
+ const { dds: liveFollowMode } = (0, index_js_1.useDynamicDDS)(uniqueKey, (live_share_1.LiveFollowMode));
193
+ /**
194
+ * User facing: list of non-local user's presence objects.
195
+ */
196
+ const otherUsers = react_1.default.useMemo(() => {
197
+ return allUsers.filter((user) => !user.isLocalUser);
198
+ }, [allUsers]);
199
+ /**
200
+ * User facing: local user's presence object.
201
+ */
202
+ const localUser = react_1.default.useMemo(() => {
203
+ return allUsers.find((user) => user.isLocalUser);
204
+ }, [allUsers]);
205
+ const { container } = (0, index_js_2.useFluidObjectsContext)();
206
+ /**
207
+ * User facing: callback to update the local user's custom data for their follow state.
208
+ */
209
+ const update = react_1.default.useCallback((stateValue) => __awaiter(this, void 0, void 0, function* () {
210
+ if (!container) {
211
+ throw new index_js_3.ActionContainerNotJoinedError("liveFollowMode", "update");
212
+ }
213
+ if (liveFollowMode === undefined) {
214
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveFollowMode", "update");
215
+ }
216
+ if (!liveFollowMode.isInitialized) {
217
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveFollowMode", "update");
218
+ }
219
+ return yield liveFollowMode.update(stateValue);
220
+ }), [container, liveFollowMode]);
221
+ /**
222
+ * User facing: callback to start presenting.
223
+ */
224
+ const startPresenting = react_1.default.useCallback(() => __awaiter(this, void 0, void 0, function* () {
225
+ if (!container) {
226
+ throw new index_js_3.ActionContainerNotJoinedError("liveFollowMode", "startPresenting");
227
+ }
228
+ if (liveFollowMode === undefined) {
229
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveFollowMode", "startPresenting");
230
+ }
231
+ if (!liveFollowMode.isInitialized) {
232
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveFollowMode", "startPresenting");
233
+ }
234
+ return yield liveFollowMode.startPresenting();
235
+ }), [container, liveFollowMode]);
236
+ /**
237
+ * User facing: callback to stop presenting.
238
+ */
239
+ const stopPresenting = react_1.default.useCallback(() => __awaiter(this, void 0, void 0, function* () {
240
+ if (!container) {
241
+ throw new index_js_3.ActionContainerNotJoinedError("liveFollowMode", "stopPresenting");
242
+ }
243
+ if (liveFollowMode === undefined) {
244
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveFollowMode", "stopPresenting");
245
+ }
246
+ if (!liveFollowMode.isInitialized) {
247
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveFollowMode", "stopPresenting");
248
+ }
249
+ return yield liveFollowMode.stopPresenting();
250
+ }), [container, liveFollowMode]);
251
+ /**
252
+ * User facing: callback to suspend sync.
253
+ */
254
+ const beginSuspension = react_1.default.useCallback(() => __awaiter(this, void 0, void 0, function* () {
255
+ if (!container) {
256
+ throw new index_js_3.ActionContainerNotJoinedError("liveFollowMode", "syncToPresenter");
257
+ }
258
+ if (liveFollowMode === undefined) {
259
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveFollowMode", "syncToPresenter");
260
+ }
261
+ if (!liveFollowMode.isInitialized) {
262
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveFollowMode", "syncToPresenter");
263
+ }
264
+ return yield liveFollowMode.beginSuspension();
265
+ }), [container, liveFollowMode]);
266
+ /**
267
+ * User facing: callback to end current suspension.
268
+ */
269
+ const endSuspension = react_1.default.useCallback(() => __awaiter(this, void 0, void 0, function* () {
270
+ if (!container) {
271
+ throw new index_js_3.ActionContainerNotJoinedError("liveFollowMode", "syncToPresenter");
272
+ }
273
+ if (liveFollowMode === undefined) {
274
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveFollowMode", "syncToPresenter");
275
+ }
276
+ if (!liveFollowMode.isInitialized) {
277
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveFollowMode", "syncToPresenter");
278
+ }
279
+ return yield liveFollowMode.endSuspension();
280
+ }), [container, liveFollowMode]);
281
+ /**
282
+ * User facing: callback to follow a specific user.
283
+ */
284
+ const followUser = react_1.default.useCallback((userId) => __awaiter(this, void 0, void 0, function* () {
285
+ if (!container) {
286
+ throw new index_js_3.ActionContainerNotJoinedError("liveFollowMode", "followUser");
287
+ }
288
+ if (liveFollowMode === undefined) {
289
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveFollowMode", "followUser");
290
+ }
291
+ if (!liveFollowMode.isInitialized) {
292
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveFollowMode", "followUser");
293
+ }
294
+ return yield liveFollowMode.followUser(userId);
295
+ }), [container, liveFollowMode]);
296
+ /**
297
+ * User facing: callback to stop following a user.
298
+ */
299
+ const stopFollowing = react_1.default.useCallback(() => __awaiter(this, void 0, void 0, function* () {
300
+ if (!container) {
301
+ throw new index_js_3.ActionContainerNotJoinedError("liveFollowMode", "stopFollowing");
302
+ }
303
+ if (liveFollowMode === undefined) {
304
+ throw new index_js_3.ActionLiveDataObjectUndefinedError("liveFollowMode", "stopFollowing");
305
+ }
306
+ if (!liveFollowMode.isInitialized) {
307
+ throw new index_js_3.ActionLiveDataObjectInitializedError("liveFollowMode", "stopFollowing");
308
+ }
309
+ return yield liveFollowMode.stopFollowing();
310
+ }), [container, liveFollowMode]);
311
+ /**
312
+ * Setup change listeners and start `LiveFollowMode` if needed
313
+ */
314
+ react_1.default.useEffect(() => {
315
+ if (liveFollowMode === undefined)
316
+ return;
317
+ const onPresenceChanged = () => {
318
+ const updatedLocalUsers = [];
319
+ liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.getUsers().forEach((user) => {
320
+ updatedLocalUsers.push(user);
321
+ });
322
+ setAllUsers(updatedLocalUsers);
323
+ };
324
+ liveFollowMode.on("presenceChanged", onPresenceChanged);
325
+ const onStateChanged = () => {
326
+ setState(liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.state);
327
+ };
328
+ liveFollowMode.on("stateChanged", onStateChanged);
329
+ if (liveFollowMode.initializeState ===
330
+ live_share_1.LiveDataObjectInitializeState.needed) {
331
+ liveFollowMode.initialize(isInitialDataCallback(initialData)
332
+ ? initialData()
333
+ : initialData, allowedRoles);
334
+ }
335
+ onPresenceChanged();
336
+ onStateChanged();
337
+ return () => {
338
+ liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.off("presenceChanged", onPresenceChanged);
339
+ liveFollowMode === null || liveFollowMode === void 0 ? void 0 : liveFollowMode.off("stateChanged", onStateChanged);
340
+ };
341
+ }, [liveFollowMode]);
342
+ return {
343
+ state,
344
+ localUser,
345
+ otherUsers,
346
+ allUsers,
347
+ liveFollowMode,
348
+ update,
349
+ startPresenting,
350
+ stopPresenting,
351
+ beginSuspension,
352
+ endSuspension,
353
+ followUser,
354
+ stopFollowing,
355
+ };
356
+ }
357
+ function isInitialDataCallback(value) {
358
+ return typeof value === "function";
359
+ }
360
+ //# sourceMappingURL=useLiveFollowMode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveFollowMode.js","sourceRoot":"","sources":["../../../src/live-hooks/useLiveFollowMode.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AA+KH,8CAmRC;AAhcD,sDAO+B;AAC/B,kDAA0B;AAC1B,uDAAyD;AACzD,oDAA+D;AAC/D,mDAI8B;AAG9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0JG;AACH,SAAgB,iBAAiB,CAC7B,SAAiB,EACjB,WAAkC,EAClC,YAAgC;IAEhC;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,eAAK,CAAC,QAAQ,EAA2B,CAAC;IACpE;;OAEG;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAK,CAAC,QAAQ,CAE5C,EAAE,CAAC,CAAC;IACN;;OAEG;IACH,MAAM,E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,cAAc,GAAG,GAAG,EAAE;YACxB,QAAQ,CAAC,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC;QACF,cAAc,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QAElD,IACI,cAAc,CAAC,eAAe;YAC9B,0CAA6B,CAAC,MAAM,EACtC,CAAC;YACC,cAAc,CAAC,UAAU,CACrB,qBAAqB,CAAQ,WAAW,CAAC;gBACrC,CAAC,CAAC,WAAW,EAAE;gBACf,CAAC,CAAC,WAAW,EACjB,YAAY,CACf,CAAC;QACN,CAAC;QACD,iBAAiB,EAAE,CAAC;QACpB,cAAc,EAAE,CAAC;QAEjB,OAAO,GAAG,EAAE;YACR,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;YAC1D,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACxD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO;QACH,KAAK;QACL,SAAS;QACT,UAAU;QACV,QAAQ;QACR,cAAc;QACd,MAAM;QACN,eAAe;QACf,cAAc;QACd,eAAe;QACf,aAAa;QACb,UAAU;QACV,aAAa;KAChB,CAAC;AACN,CAAC;AAED,SAAS,qBAAqB,CAAQ,KAAU;IAC5C,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC"}
@@ -0,0 +1,76 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { UserMeetingRole, LivePresenceData } from "@microsoft/live-share";
6
+ import { IUseLivePresenceResults } from "../types/index.js";
7
+ /**
8
+ * React hook for using a Live Share `LivePresence`.
9
+ *
10
+ * @remarks
11
+ * Use this hook if you want to track presence for who is currently using this component, such as
12
+ * who is online or who is viewing a specific document. With presence, you can sent along any custom
13
+ * user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
14
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
15
+ *
16
+ * @template TData Optional typing for the custom user presence data object. Default is `object` type.
17
+ * @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
18
+ * @param initialData Initial presence data object for the user. Can be value or a function to get the value.
19
+ * @param allowedRoles Optional. the user roles that are allowed to mutate the synchronized state
20
+ * will be created, otherwise it will use the existing one. Default value is ":<dds-default>"
21
+ * @returns stateful `localUser`, `otherUsers` list, and `allUsers` list. Also returns a callback method
22
+ * to update the local user's presence and the `LivePresence` Fluid object.
23
+ *
24
+ * @example
25
+ ```jsx
26
+ import { useLivePresence } from "@microsoft/live-share-react";
27
+
28
+ // Define a unique key that differentiates this usage of `useLivePresence` from others in your app
29
+ const MY_UNIQUE_KEY = "presence-key";
30
+
31
+ // Example component for using useLivePresence
32
+ export const MyCustomPresence = () => {
33
+ const {
34
+ allUsers,
35
+ localUser,
36
+ livePresence,
37
+ updatePresence,
38
+ } = useLivePresence(MY_UNIQUE_KEY, {
39
+ picture: "DEFAULT_PROFILE_PICTURE_URL",
40
+ readyToStart: false,
41
+ });
42
+
43
+ // Callback to update the user's presence
44
+ const onToggleReady = () => {
45
+ updatePresence({
46
+ ...localUser.data,
47
+ readyToStart: !localUser.data.readyToStart,
48
+ });
49
+ }
50
+
51
+ // Render loading UI while loading LivePresence for first time
52
+ if (!livePresence) return <>Loading...</>;
53
+
54
+ // Render presence UI
55
+ return (
56
+ {allUsers.map((user) => (
57
+ <div key={user.userId}>
58
+ <div>
59
+ {user.displayName}
60
+ </div>
61
+ <div>
62
+ {`Ready: ${user.data.readyToStart}`}
63
+ </div>
64
+ {user.isLocalUser && (
65
+ <button onClick={onToggleReady}>
66
+ {"Toggle ready"}
67
+ </button>
68
+ )}
69
+ </div>
70
+ ))}
71
+ );
72
+ }
73
+ ```
74
+ */
75
+ export declare function useLivePresence<TData extends LivePresenceData = any>(uniqueKey: string, initialData: TData | (() => TData), allowedRoles?: UserMeetingRole[]): IUseLivePresenceResults<TData>;
76
+ //# sourceMappingURL=useLivePresence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLivePresence.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLivePresence.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGH,eAAe,EAEf,gBAAgB,EAEnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,uBAAuB,EAE1B,MAAM,mBAAmB,CAAC;AAS3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,gBAAgB,GAAG,GAAG,EAChE,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EAClC,YAAY,CAAC,EAAE,eAAe,EAAE,GACjC,uBAAuB,CAAC,KAAK,CAAC,CAwGhC"}