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

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 +166 -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 +46 -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 +67 -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 +330 -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 +74 -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 +67 -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,80 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import React from "react";
6
+ import { IUseLiveCanvasOptionalProps, IUseLiveCanvasResults } from "../types/index.js";
7
+ /**
8
+ * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
9
+ *
10
+ * @remarks
11
+ * Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
12
+ * a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
13
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
14
+ *
15
+ * @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
16
+ * @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
17
+ * @param props Optional. Other optional props.
18
+ * @param props.active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
19
+ * @param props.tool Optional. Stateful enum for what tool to use in the `InkingManager`.
20
+ * @param props.lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
21
+ * @param props.offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
22
+ * @param props.scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
23
+ * @param props.referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
24
+ * @param props.isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
25
+ * @param props.localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
26
+ * @param props.node Optional. A Fluid `LiveCanvasTree` `TreeNode` instance to swap out the underlying storage solution for strokes.
27
+ * To learn more, look at Fluid's [SharedTree](https://fluidframework.com/docs/data-structures/tree/) documentation.
28
+ * @param allowedRoles Optional. The user roles that are allowed to start/stop/pause the timer.
29
+ *
30
+ * @returns `IUseLiveCanvasResults` object that contains the `liveCanvas` data object and `inkingManager`.
31
+ *
32
+ * @example
33
+ ```jsx
34
+ import { useLiveCanvas } from "@microsoft/live-share-react";
35
+ import { InkingTool } from "@microsoft/live-share-canvas";
36
+ import { useRef } from "react";
37
+
38
+ // Unique identifier that distinguishes this useLiveCanvas from others in your app
39
+ const UNIQUE_KEY = "CUSTOM-LIVE-CANVAS";
40
+
41
+ // Example component
42
+ export function ExampleLiveCanvas() {
43
+ const liveCanvasRef = useRef(null);
44
+ const { liveCanvas, inkingManager } = useLiveCanvas(
45
+ "CUSTOM-LIVE-CANVAS",
46
+ liveCanvasRef,
47
+ );
48
+
49
+ return (
50
+ <div style={{ position: "absolute"}}>
51
+ <div
52
+ ref={liveCanvasRef}
53
+ // Best practice is to not define inline styles
54
+ style={{ width: "556px", height: "224px" }}
55
+ />
56
+ {!!liveCanvas && (
57
+ <div>
58
+ <button
59
+ onClick={() => {
60
+ inkingManager.tool = InkingTool.pen;
61
+ }}
62
+ >
63
+ {"Pen"}
64
+ </button>
65
+ <button
66
+ onClick={() => {
67
+ inkingManager.tool = InkingTool.laserPointer;
68
+ }}
69
+ >
70
+ {"Laser pointer"}
71
+ </button>
72
+ </div>
73
+ )}
74
+ </div>
75
+ );
76
+ };
77
+ ```
78
+ */
79
+ export declare function useLiveCanvas(uniqueKey: string, canvasElementRef: React.RefObject<HTMLElement | null> | string, props: IUseLiveCanvasOptionalProps): IUseLiveCanvasResults;
80
+ //# sourceMappingURL=useLiveCanvas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveCanvas.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACH,2BAA2B,EAC3B,qBAAqB,EACxB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,MAAM,EAC9D,KAAK,EAAE,2BAA2B,GACnC,qBAAqB,CA0KvB"}
@@ -0,0 +1,238 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { InkingManager, LiveCanvas } from "@microsoft/live-share-canvas";
6
+ import React from "react";
7
+ import { useDynamicDDS } from "../shared-hooks/index.js";
8
+ import { isRefObject } from "../utils/index.js";
9
+ import { getRawNode } from "../shared-hooks/internals/tree-node-utils.js";
10
+ import { LiveDataObjectInitializeState } from "@microsoft/live-share";
11
+ /**
12
+ * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
13
+ *
14
+ * @remarks
15
+ * Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
16
+ * a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
17
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
18
+ *
19
+ * @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
20
+ * @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
21
+ * @param props Optional. Other optional props.
22
+ * @param props.active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
23
+ * @param props.tool Optional. Stateful enum for what tool to use in the `InkingManager`.
24
+ * @param props.lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
25
+ * @param props.offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
26
+ * @param props.scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
27
+ * @param props.referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
28
+ * @param props.isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
29
+ * @param props.localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
30
+ * @param props.node Optional. A Fluid `LiveCanvasTree` `TreeNode` instance to swap out the underlying storage solution for strokes.
31
+ * To learn more, look at Fluid's [SharedTree](https://fluidframework.com/docs/data-structures/tree/) documentation.
32
+ * @param allowedRoles Optional. The user roles that are allowed to start/stop/pause the timer.
33
+ *
34
+ * @returns `IUseLiveCanvasResults` object that contains the `liveCanvas` data object and `inkingManager`.
35
+ *
36
+ * @example
37
+ ```jsx
38
+ import { useLiveCanvas } from "@microsoft/live-share-react";
39
+ import { InkingTool } from "@microsoft/live-share-canvas";
40
+ import { useRef } from "react";
41
+
42
+ // Unique identifier that distinguishes this useLiveCanvas from others in your app
43
+ const UNIQUE_KEY = "CUSTOM-LIVE-CANVAS";
44
+
45
+ // Example component
46
+ export function ExampleLiveCanvas() {
47
+ const liveCanvasRef = useRef(null);
48
+ const { liveCanvas, inkingManager } = useLiveCanvas(
49
+ "CUSTOM-LIVE-CANVAS",
50
+ liveCanvasRef,
51
+ );
52
+
53
+ return (
54
+ <div style={{ position: "absolute"}}>
55
+ <div
56
+ ref={liveCanvasRef}
57
+ // Best practice is to not define inline styles
58
+ style={{ width: "556px", height: "224px" }}
59
+ />
60
+ {!!liveCanvas && (
61
+ <div>
62
+ <button
63
+ onClick={() => {
64
+ inkingManager.tool = InkingTool.pen;
65
+ }}
66
+ >
67
+ {"Pen"}
68
+ </button>
69
+ <button
70
+ onClick={() => {
71
+ inkingManager.tool = InkingTool.laserPointer;
72
+ }}
73
+ >
74
+ {"Laser pointer"}
75
+ </button>
76
+ </div>
77
+ )}
78
+ </div>
79
+ );
80
+ };
81
+ ```
82
+ */
83
+ export function useLiveCanvas(uniqueKey, canvasElementRef, props) {
84
+ var _a, _b, _c, _d, _e, _f, _g;
85
+ /**
86
+ * User facing: inking manager instance
87
+ */
88
+ const [inkingManager, setInkingManager] = React.useState();
89
+ /**
90
+ * User facing: dynamically load the DDS for the given unique key.
91
+ */
92
+ const { dds: liveCanvas } = useDynamicDDS(uniqueKey, LiveCanvas);
93
+ // This should change less frequently then node if they are using `useTreeNode`
94
+ // We need the raw node anyways to apply event listeners
95
+ const rawNode = getRawNode(props === null || props === void 0 ? void 0 : props.node);
96
+ /**
97
+ * Setup the InkingManager and LiveCanvas
98
+ */
99
+ React.useEffect(() => {
100
+ // if the component is already listening or liveCanvas is not yet initialized, return
101
+ if (!liveCanvas)
102
+ return;
103
+ // get the canvas element from the ref or document
104
+ let htmlElement;
105
+ if (isRefObject(canvasElementRef)) {
106
+ htmlElement = canvasElementRef.current;
107
+ }
108
+ else {
109
+ htmlElement = document.getElementById(canvasElementRef);
110
+ }
111
+ if (htmlElement === null)
112
+ return;
113
+ // Clear out existing nodes
114
+ function removeAllChildren(node) {
115
+ node.childNodes.forEach((childNode) => {
116
+ removeAllChildren(childNode);
117
+ childNode.remove();
118
+ });
119
+ }
120
+ removeAllChildren(htmlElement);
121
+ // Create the InkingManager and initialize the liveCanvas with it
122
+ const inkingManager = new InkingManager(htmlElement);
123
+ setInkingManager(inkingManager);
124
+ liveCanvas.initialize(inkingManager, props === null || props === void 0 ? void 0 : props.allowedRoles, rawNode);
125
+ // cleanup function to be called when the component is unmount
126
+ return () => {
127
+ inkingManager.removeAllListeners();
128
+ };
129
+ },
130
+ // Intentionally ommitting rawNode from deps because we only want to initialize once,
131
+ // whereas rawNode may change many times.
132
+ [liveCanvas, props === null || props === void 0 ? void 0 : props.allowedRoles]);
133
+ /**
134
+ * Set the node if it changes while LiveCanvas is initialized
135
+ */
136
+ React.useEffect(() => {
137
+ if (!rawNode ||
138
+ (liveCanvas === null || liveCanvas === void 0 ? void 0 : liveCanvas.initializeState) !==
139
+ LiveDataObjectInitializeState.succeeded)
140
+ return;
141
+ liveCanvas.setTreeNode(rawNode);
142
+ }, [liveCanvas, rawNode]);
143
+ /**
144
+ * Activate or deactivate the inkingManager based on the 'active' prop
145
+ */
146
+ React.useEffect(() => {
147
+ if (inkingManager && (props === null || props === void 0 ? void 0 : props.active) !== undefined) {
148
+ if (props === null || props === void 0 ? void 0 : props.active) {
149
+ inkingManager.activate();
150
+ }
151
+ else {
152
+ inkingManager.deactivate();
153
+ }
154
+ }
155
+ }, [props === null || props === void 0 ? void 0 : props.active, inkingManager]);
156
+ /**
157
+ * Sets the tool of the inkingManager based on the 'tool' prop
158
+ */
159
+ React.useEffect(() => {
160
+ if (inkingManager && (props === null || props === void 0 ? void 0 : props.tool) !== undefined) {
161
+ inkingManager.tool = props.tool;
162
+ }
163
+ }, [props === null || props === void 0 ? void 0 : props.tool, inkingManager]);
164
+ /**
165
+ * Sets the offset of the inkingManager based on the 'offset' prop
166
+ */
167
+ React.useEffect(() => {
168
+ if (inkingManager && (props === null || props === void 0 ? void 0 : props.offset) !== undefined) {
169
+ inkingManager.offset = {
170
+ x: props === null || props === void 0 ? void 0 : props.offset.x,
171
+ y: props === null || props === void 0 ? void 0 : props.offset.y,
172
+ };
173
+ }
174
+ }, [(_a = props === null || props === void 0 ? void 0 : props.offset) === null || _a === void 0 ? void 0 : _a.x, (_b = props === null || props === void 0 ? void 0 : props.offset) === null || _b === void 0 ? void 0 : _b.y, inkingManager]);
175
+ /**
176
+ * Sets the scale of the inkingManager based on the 'scale' prop
177
+ */
178
+ React.useEffect(() => {
179
+ if (inkingManager && (props === null || props === void 0 ? void 0 : props.scale) !== undefined) {
180
+ inkingManager.scale = props === null || props === void 0 ? void 0 : props.scale;
181
+ }
182
+ }, [props === null || props === void 0 ? void 0 : props.scale, inkingManager]);
183
+ /**
184
+ * Sets the referencePoint of the inkingManager based on the 'referencePoint' prop
185
+ */
186
+ React.useEffect(() => {
187
+ if (inkingManager && (props === null || props === void 0 ? void 0 : props.referencePoint) !== undefined) {
188
+ inkingManager.referencePoint = props === null || props === void 0 ? void 0 : props.referencePoint;
189
+ }
190
+ }, [props === null || props === void 0 ? void 0 : props.referencePoint, inkingManager]);
191
+ /**
192
+ * Sets the lineBrush of the inkingManager based on the 'lineBrush' prop
193
+ */
194
+ React.useEffect(() => {
195
+ if (inkingManager && (props === null || props === void 0 ? void 0 : props.lineBrush)) {
196
+ inkingManager.lineBrush = {
197
+ color: props.lineBrush.color,
198
+ tip: props.lineBrush.tip,
199
+ tipSize: props.lineBrush.tipSize,
200
+ type: props.lineBrush.type,
201
+ endArrow: props.lineBrush.endArrow,
202
+ };
203
+ }
204
+ }, [
205
+ (_c = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _c === void 0 ? void 0 : _c.color,
206
+ (_d = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _d === void 0 ? void 0 : _d.tip,
207
+ (_e = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _e === void 0 ? void 0 : _e.tipSize,
208
+ (_f = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _f === void 0 ? void 0 : _f.type,
209
+ (_g = props === null || props === void 0 ? void 0 : props.lineBrush) === null || _g === void 0 ? void 0 : _g.endArrow,
210
+ inkingManager,
211
+ ]);
212
+ /**
213
+ * Sets the isCursorShared of the liveCanvas based on the 'isCursorShared' prop
214
+ */
215
+ React.useEffect(() => {
216
+ if (liveCanvas && (props === null || props === void 0 ? void 0 : props.isCursorShared) !== undefined) {
217
+ liveCanvas.isCursorShared = props.isCursorShared;
218
+ }
219
+ }, [props === null || props === void 0 ? void 0 : props.isCursorShared, liveCanvas]);
220
+ /**
221
+ * Sets the onGetLocalUserInfo method of the liveCanvas based on the 'localUserCursor' prop
222
+ */
223
+ React.useEffect(() => {
224
+ if (liveCanvas && (props === null || props === void 0 ? void 0 : props.localUserPictureUrl)) {
225
+ liveCanvas.onGetLocalUserPictureUrl = () => {
226
+ return props.localUserPictureUrl;
227
+ };
228
+ }
229
+ }, [props === null || props === void 0 ? void 0 : props.localUserPictureUrl, liveCanvas]);
230
+ /**
231
+ * Return hook response
232
+ */
233
+ return {
234
+ inkingManager,
235
+ liveCanvas,
236
+ };
237
+ }
238
+ //# sourceMappingURL=useLiveCanvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveCanvas.js","sourceRoot":"","sources":["../../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EAAE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cAAc,MAAK,SAAS,EAAE,CAAC;YACpD,UAAU,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;QACrD,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IAExC;;OAEG;IACH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,UAAU,KAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,CAAA,EAAE,CAAC;YAC3C,UAAU,CAAC,wBAAwB,GAAG,GAAuB,EAAE;gBAC3D,OAAO,KAAK,CAAC,mBAAmB,CAAC;YACrC,CAAC,CAAC;QACN,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;IAE7C;;OAEG;IACH,OAAO;QACH,aAAa;QACb,UAAU;KACb,CAAC;AACN,CAAC"}
@@ -0,0 +1,59 @@
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 { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types/index.js";
7
+ /**
8
+ * React hook for using a Live Share `LiveEvent`.
9
+ *
10
+ * @remarks
11
+ * Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container,
12
+ * such as when sending push notifications or reactions.
13
+ * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
14
+ *
15
+ * @template TEvent Optional typing for events sent & received. Default is `object` type.
16
+ * @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one
17
+ * will be created, otherwise it will use the existing one.
18
+ * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
19
+ * @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
20
+ * @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
21
+ *
22
+ * @example
23
+ ```jsx
24
+ import { useLiveEvent } from "@microsoft/live-share-react";
25
+
26
+ const emojis = ["❤️", "😂", "👍", "👎"];
27
+
28
+ // Define a unique key that differentiates this usage of `useLiveEvent` from others in your app
29
+ const MY_UNIQUE_KEY = "event-key";
30
+
31
+ // Example component for using useLiveEvent
32
+ export const MyCustomEvent = () => {
33
+ const { latestEvent, liveEvent, sendEvent } = useLiveEvent(MY_UNIQUE_KEY);
34
+
35
+ // Render loading UI when creating LiveEvent instance for first time
36
+ if (!liveEvent) return <>Loading...</>;
37
+
38
+ // Render UI
39
+ return (
40
+ <div>
41
+ {`Latest event: ${latestEvent?.value}, from local user: ${latestEvent?.local}`}
42
+ {"Select a planet below:"}
43
+ {emojis.map((emoji) => (
44
+ <button
45
+ key={emoji}
46
+ onClick={() => {
47
+ sendEvent(emoji);
48
+ }}
49
+ >
50
+ {emoji}
51
+ </button>
52
+ ))}
53
+ </div>
54
+ );
55
+ };
56
+ ```
57
+ */
58
+ export declare function useLiveEvent<TEvent = any>(uniqueKey: string, allowedRoles?: UserMeetingRole[], onReceivedEvent?: OnReceivedLiveEventAction<TEvent>): IUseLiveEventResults<TEvent>;
59
+ //# sourceMappingURL=useLiveEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveEvent.d.ts","sourceRoot":"","sources":["../../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EAE5B,MAAM,mBAAmB,CAAC;AAU3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,eAAe,EAAE,EAChC,eAAe,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,GACpD,oBAAoB,CAAC,MAAM,CAAC,CAoG9B"}
@@ -13,9 +13,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  };
14
14
  import { LiveEventEvents, LiveEvent, LiveDataObjectInitializeState, } from "@microsoft/live-share";
15
15
  import React from "react";
16
- import { useDynamicDDS } from "../shared-hooks";
17
- import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
18
- import { useFluidObjectsContext } from "../providers";
16
+ import { useDynamicDDS } from "../shared-hooks/index.js";
17
+ import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal/index.js";
18
+ import { useFluidObjectsContext } from "../providers/index.js";
19
19
  /**
20
20
  * React hook for using a Live Share `LiveEvent`.
21
21
  *
@@ -30,6 +30,42 @@ import { useFluidObjectsContext } from "../providers";
30
30
  * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
31
31
  * @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
32
32
  * @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
33
+ *
34
+ * @example
35
+ ```jsx
36
+ import { useLiveEvent } from "@microsoft/live-share-react";
37
+
38
+ const emojis = ["❤️", "😂", "👍", "👎"];
39
+
40
+ // Define a unique key that differentiates this usage of `useLiveEvent` from others in your app
41
+ const MY_UNIQUE_KEY = "event-key";
42
+
43
+ // Example component for using useLiveEvent
44
+ export const MyCustomEvent = () => {
45
+ const { latestEvent, liveEvent, sendEvent } = useLiveEvent(MY_UNIQUE_KEY);
46
+
47
+ // Render loading UI when creating LiveEvent instance for first time
48
+ if (!liveEvent) return <>Loading...</>;
49
+
50
+ // Render UI
51
+ return (
52
+ <div>
53
+ {`Latest event: ${latestEvent?.value}, from local user: ${latestEvent?.local}`}
54
+ {"Select a planet below:"}
55
+ {emojis.map((emoji) => (
56
+ <button
57
+ key={emoji}
58
+ onClick={() => {
59
+ sendEvent(emoji);
60
+ }}
61
+ >
62
+ {emoji}
63
+ </button>
64
+ ))}
65
+ </div>
66
+ );
67
+ };
68
+ ```
33
69
  */
34
70
  export function useLiveEvent(uniqueKey, allowedRoles, onReceivedEvent) {
35
71
  /**
@@ -49,7 +85,7 @@ export function useLiveEvent(uniqueKey, allowedRoles, onReceivedEvent) {
49
85
  /**
50
86
  * User facing: callback to send event through `LiveEvent`
51
87
  */
52
- const sendEvent = React.useCallback((event) => __awaiter(this, void 0, void 0, function* () {
88
+ const sendEvent = React.useCallback((event, targetClientId) => __awaiter(this, void 0, void 0, function* () {
53
89
  if (!container) {
54
90
  throw new ActionContainerNotJoinedError("liveEvent", "sendEvent");
55
91
  }
@@ -59,7 +95,7 @@ export function useLiveEvent(uniqueKey, allowedRoles, onReceivedEvent) {
59
95
  if (!liveEvent.isInitialized) {
60
96
  throw new ActionLiveDataObjectInitializedError("liveEvent", "sendEvent");
61
97
  }
62
- return yield liveEvent.send(event);
98
+ return yield liveEvent.send(event, targetClientId);
63
99
  }), [container, liveEvent]);
64
100
  /**
65
101
  * Setup change listeners and start `LiveEvent` if needed
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveEvent.js","sourceRoot":"","sources":["../../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;AAEH,OAAO,EACH,eAAe,EAEf,SAAS,EACT,6BAA6B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EACH,6BAA6B,EAC7B,oCAAoC,EACpC,kCAAkC,GACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,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ChE,WAAW;YACX,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,KAAK,EAAE,KAAK,CAAC,CAAC;YAChC,4CAA4C;YAC5C,MAAM,QAAQ,GAA8B;gBACxC,KAAK,EAAE,KAAK;gBACZ,KAAK;gBACL,QAAQ;gBACR,SAAS;aACZ,CAAC;YACF,YAAY,CAAC,OAAO,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC3D,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC,CAAC;QACF,gEAAgE;QAChE,sEAAsE;QACtE,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClC,YAAY,CAAC,OAAO,GAAG,EAAE,CAAC;YAC1B,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;QACD,SAAS,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACxD,IACI,SAAS,CAAC,eAAe,KAAK,6BAA6B,CAAC,MAAM,EACpE,CAAC;YACC,mBAAmB;YACnB,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,GAAG,EAAE;YACR,qCAAqC;YACrC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC9D,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO;QACH,WAAW;QACX,SAAS,EAAE,YAAY,CAAC,OAAO;QAC/B,SAAS;QACT,SAAS;KACZ,CAAC;AACN,CAAC"}
@@ -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"}