@microsoft/live-share-react 2.0.0-internal.1 → 2.0.0-internal.10

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/LICENSE +64 -61
  2. package/README.md +173 -168
  3. package/bin/cjs/index.d.ts +7 -0
  4. package/bin/cjs/index.d.ts.map +1 -0
  5. package/bin/cjs/index.js +23 -0
  6. package/bin/cjs/index.js.map +1 -0
  7. package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  8. package/bin/cjs/interfaces/LiveInterfaceExtensions.js +7 -0
  9. package/bin/cjs/interfaces/LiveInterfaceExtensions.js.map +1 -0
  10. package/bin/cjs/interfaces/index.d.ts +2 -0
  11. package/bin/cjs/interfaces/index.d.ts.map +1 -0
  12. package/bin/cjs/interfaces/index.js +18 -0
  13. package/bin/cjs/interfaces/index.js.map +1 -0
  14. package/bin/cjs/internal/errors.d.ts.map +1 -0
  15. package/bin/cjs/internal/errors.js +48 -0
  16. package/bin/cjs/internal/errors.js.map +1 -0
  17. package/bin/cjs/internal/index.d.ts +3 -0
  18. package/bin/cjs/internal/index.d.ts.map +1 -0
  19. package/bin/cjs/internal/index.js +19 -0
  20. package/bin/cjs/internal/index.js.map +1 -0
  21. package/bin/{internal → cjs/internal}/type-guards.d.ts +1 -1
  22. package/bin/cjs/internal/type-guards.d.ts.map +1 -0
  23. package/bin/cjs/internal/type-guards.js +24 -0
  24. package/bin/cjs/internal/type-guards.js.map +1 -0
  25. package/bin/cjs/live-hooks/index.d.ts +8 -0
  26. package/bin/cjs/live-hooks/index.d.ts.map +1 -0
  27. package/bin/cjs/live-hooks/index.js +24 -0
  28. package/bin/cjs/live-hooks/index.js.map +1 -0
  29. package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
  30. package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
  31. package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
  32. package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
  33. package/bin/{live-hooks → cjs/live-hooks}/useLiveEvent.d.ts +37 -1
  34. package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
  35. package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
  36. package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
  37. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
  38. package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  39. package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
  40. package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
  41. package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
  42. package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
  43. package/bin/cjs/live-hooks/useLivePresence.js +170 -0
  44. package/bin/cjs/live-hooks/useLivePresence.js.map +1 -0
  45. package/bin/{live-hooks → cjs/live-hooks}/useLiveState.d.ts +46 -1
  46. package/bin/cjs/live-hooks/useLiveState.d.ts.map +1 -0
  47. package/bin/cjs/live-hooks/useLiveState.js +134 -0
  48. package/bin/cjs/live-hooks/useLiveState.js.map +1 -0
  49. package/bin/{live-hooks → cjs/live-hooks}/useLiveTimer.d.ts +56 -1
  50. package/bin/cjs/live-hooks/useLiveTimer.d.ts.map +1 -0
  51. package/bin/cjs/live-hooks/useLiveTimer.js +233 -0
  52. package/bin/cjs/live-hooks/useLiveTimer.js.map +1 -0
  53. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts +86 -0
  54. package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  55. package/bin/cjs/live-hooks/useMediaSynchronizer.js +301 -0
  56. package/bin/cjs/live-hooks/useMediaSynchronizer.js.map +1 -0
  57. package/bin/cjs/package.json +1 -0
  58. package/bin/{providers → cjs/providers}/AzureProvider.d.ts +9 -9
  59. package/bin/cjs/providers/AzureProvider.d.ts.map +1 -0
  60. package/bin/cjs/providers/AzureProvider.js +127 -0
  61. package/bin/cjs/providers/AzureProvider.js.map +1 -0
  62. package/bin/{providers → cjs/providers}/LiveShareProvider.d.ts +106 -4
  63. package/bin/cjs/providers/LiveShareProvider.d.ts.map +1 -0
  64. package/bin/cjs/providers/LiveShareProvider.js +205 -0
  65. package/bin/cjs/providers/LiveShareProvider.js.map +1 -0
  66. package/bin/cjs/providers/index.d.ts +3 -0
  67. package/bin/cjs/providers/index.d.ts.map +1 -0
  68. package/bin/cjs/providers/index.js +19 -0
  69. package/bin/cjs/providers/index.js.map +1 -0
  70. package/bin/cjs/shared-hooks/index.d.ts +7 -0
  71. package/bin/cjs/shared-hooks/index.d.ts.map +1 -0
  72. package/bin/cjs/shared-hooks/index.js +23 -0
  73. package/bin/cjs/shared-hooks/index.js.map +1 -0
  74. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  75. package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  76. package/bin/cjs/shared-hooks/internals/tree-node-constants.js +6 -0
  77. package/bin/cjs/shared-hooks/internals/tree-node-constants.js.map +1 -0
  78. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts +10 -0
  79. package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  80. package/bin/cjs/shared-hooks/internals/tree-node-types.js +23 -0
  81. package/bin/cjs/shared-hooks/internals/tree-node-types.js.map +1 -0
  82. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  83. package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  84. package/bin/cjs/shared-hooks/internals/tree-node-utils.js +193 -0
  85. package/bin/cjs/shared-hooks/internals/tree-node-utils.js.map +1 -0
  86. package/bin/{shared-hooks → cjs/shared-hooks}/useDynamicDDS.d.ts +4 -4
  87. package/bin/cjs/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  88. package/bin/cjs/shared-hooks/useDynamicDDS.js +87 -0
  89. package/bin/cjs/shared-hooks/useDynamicDDS.js.map +1 -0
  90. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedMap.d.ts +4 -2
  91. package/bin/cjs/shared-hooks/useSharedMap.d.ts.map +1 -0
  92. package/bin/cjs/shared-hooks/useSharedMap.js +134 -0
  93. package/bin/cjs/shared-hooks/useSharedMap.js.map +1 -0
  94. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedState.d.ts +1 -1
  95. package/bin/cjs/shared-hooks/useSharedState.d.ts.map +1 -0
  96. package/bin/cjs/shared-hooks/useSharedState.js +80 -0
  97. package/bin/cjs/shared-hooks/useSharedState.js.map +1 -0
  98. package/bin/{shared-hooks → cjs/shared-hooks}/useSharedStateRegistry.d.ts +1 -1
  99. package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  100. package/bin/cjs/shared-hooks/useSharedStateRegistry.js +120 -0
  101. package/bin/cjs/shared-hooks/useSharedStateRegistry.js.map +1 -0
  102. package/bin/cjs/shared-hooks/useSharedTree.d.ts +57 -0
  103. package/bin/cjs/shared-hooks/useSharedTree.d.ts.map +1 -0
  104. package/bin/cjs/shared-hooks/useSharedTree.js +123 -0
  105. package/bin/cjs/shared-hooks/useSharedTree.js.map +1 -0
  106. package/bin/cjs/shared-hooks/useTreeNode.d.ts +96 -0
  107. package/bin/cjs/shared-hooks/useTreeNode.d.ts.map +1 -0
  108. package/bin/cjs/shared-hooks/useTreeNode.js +135 -0
  109. package/bin/cjs/shared-hooks/useTreeNode.js.map +1 -0
  110. package/bin/{types → cjs/types}/ActionTypes.d.ts +7 -7
  111. package/bin/cjs/types/ActionTypes.d.ts.map +1 -0
  112. package/bin/cjs/types/ActionTypes.js +7 -0
  113. package/bin/cjs/types/ActionTypes.js.map +1 -0
  114. package/bin/cjs/types/PropTypes.d.ts +56 -0
  115. package/bin/cjs/types/PropTypes.d.ts.map +1 -0
  116. package/bin/cjs/types/PropTypes.js +7 -0
  117. package/bin/cjs/types/PropTypes.js.map +1 -0
  118. package/bin/{types → cjs/types}/ResultTypes.d.ts +50 -18
  119. package/bin/cjs/types/ResultTypes.d.ts.map +1 -0
  120. package/bin/cjs/types/ResultTypes.js +7 -0
  121. package/bin/cjs/types/ResultTypes.js.map +1 -0
  122. package/bin/cjs/types/index.d.ts +4 -0
  123. package/bin/cjs/types/index.d.ts.map +1 -0
  124. package/bin/cjs/types/index.js +20 -0
  125. package/bin/cjs/types/index.js.map +1 -0
  126. package/bin/cjs/utils/index.d.ts +2 -0
  127. package/bin/cjs/utils/index.d.ts.map +1 -0
  128. package/bin/cjs/utils/index.js +18 -0
  129. package/bin/cjs/utils/index.js.map +1 -0
  130. package/bin/cjs/utils/type-check.d.ts.map +1 -0
  131. package/bin/cjs/utils/type-check.js +62 -0
  132. package/bin/cjs/utils/type-check.js.map +1 -0
  133. package/bin/esm/index.d.ts +7 -0
  134. package/bin/esm/index.d.ts.map +1 -0
  135. package/bin/esm/index.js +7 -0
  136. package/bin/esm/index.js.map +1 -0
  137. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts +26 -0
  138. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  139. package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
  140. package/bin/esm/interfaces/index.d.ts +2 -0
  141. package/bin/esm/interfaces/index.d.ts.map +1 -0
  142. package/bin/esm/interfaces/index.js +2 -0
  143. package/bin/esm/interfaces/index.js.map +1 -0
  144. package/bin/esm/internal/errors.d.ts +41 -0
  145. package/bin/esm/internal/errors.d.ts.map +1 -0
  146. package/bin/esm/internal/errors.js.map +1 -0
  147. package/bin/esm/internal/index.d.ts +3 -0
  148. package/bin/esm/internal/index.d.ts.map +1 -0
  149. package/bin/esm/internal/index.js +3 -0
  150. package/bin/esm/internal/index.js.map +1 -0
  151. package/bin/esm/internal/type-guards.d.ts +11 -0
  152. package/bin/esm/internal/type-guards.d.ts.map +1 -0
  153. package/bin/esm/internal/type-guards.js.map +1 -0
  154. package/bin/esm/live-hooks/index.d.ts +8 -0
  155. package/bin/esm/live-hooks/index.d.ts.map +1 -0
  156. package/bin/esm/live-hooks/index.js +8 -0
  157. package/bin/esm/live-hooks/index.js.map +1 -0
  158. package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
  159. package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
  160. package/bin/esm/live-hooks/useLiveCanvas.js +238 -0
  161. package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
  162. package/bin/esm/live-hooks/useLiveEvent.d.ts +59 -0
  163. package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
  164. package/bin/{live-hooks → esm/live-hooks}/useLiveEvent.js +41 -5
  165. package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
  166. package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
  167. package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  168. package/bin/{live-hooks → esm/live-hooks}/useLiveFollowMode.js +148 -5
  169. package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
  170. package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
  171. package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
  172. package/bin/{live-hooks → esm/live-hooks}/useLivePresence.js +71 -13
  173. package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
  174. package/bin/esm/live-hooks/useLiveState.d.ts +66 -0
  175. package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
  176. package/bin/{live-hooks → esm/live-hooks}/useLiveState.js +54 -5
  177. package/bin/esm/live-hooks/useLiveState.js.map +1 -0
  178. package/bin/esm/live-hooks/useLiveTimer.d.ts +80 -0
  179. package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
  180. package/bin/{live-hooks → esm/live-hooks}/useLiveTimer.js +58 -3
  181. package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
  182. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
  183. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  184. package/bin/{live-hooks → esm/live-hooks}/useMediaSynchronizer.js +66 -5
  185. package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
  186. package/bin/esm/providers/AzureProvider.d.ts +113 -0
  187. package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
  188. package/bin/{providers → esm/providers}/AzureProvider.js +10 -10
  189. package/bin/esm/providers/AzureProvider.js.map +1 -0
  190. package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
  191. package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
  192. package/bin/{providers → esm/providers}/LiveShareProvider.js +111 -9
  193. package/bin/esm/providers/LiveShareProvider.js.map +1 -0
  194. package/bin/esm/providers/index.d.ts +3 -0
  195. package/bin/esm/providers/index.d.ts.map +1 -0
  196. package/bin/esm/providers/index.js +3 -0
  197. package/bin/esm/providers/index.js.map +1 -0
  198. package/bin/esm/shared-hooks/index.d.ts +7 -0
  199. package/bin/esm/shared-hooks/index.d.ts.map +1 -0
  200. package/bin/esm/shared-hooks/index.js +7 -0
  201. package/bin/esm/shared-hooks/index.js.map +1 -0
  202. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  203. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  204. package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
  205. package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
  206. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
  207. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  208. package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
  209. package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
  210. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  211. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  212. package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
  213. package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
  214. package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
  215. package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  216. package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.js +20 -11
  217. package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
  218. package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
  219. package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
  220. package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.js +27 -13
  221. package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
  222. package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
  223. package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
  224. package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.js +2 -2
  225. package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
  226. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
  227. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  228. package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.js +27 -19
  229. package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
  230. package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
  231. package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
  232. package/bin/esm/shared-hooks/useSharedTree.js +117 -0
  233. package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
  234. package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
  235. package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
  236. package/bin/esm/shared-hooks/useTreeNode.js +132 -0
  237. package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
  238. package/bin/esm/types/ActionTypes.d.ts +112 -0
  239. package/bin/esm/types/ActionTypes.d.ts.map +1 -0
  240. package/bin/esm/types/ActionTypes.js.map +1 -0
  241. package/bin/esm/types/PropTypes.d.ts +56 -0
  242. package/bin/esm/types/PropTypes.d.ts.map +1 -0
  243. package/bin/esm/types/PropTypes.js.map +1 -0
  244. package/bin/esm/types/ResultTypes.d.ts +334 -0
  245. package/bin/esm/types/ResultTypes.d.ts.map +1 -0
  246. package/bin/esm/types/ResultTypes.js.map +1 -0
  247. package/bin/esm/types/index.d.ts +4 -0
  248. package/bin/esm/types/index.d.ts.map +1 -0
  249. package/bin/esm/types/index.js +4 -0
  250. package/bin/esm/types/index.js.map +1 -0
  251. package/bin/esm/utils/index.d.ts +2 -0
  252. package/bin/esm/utils/index.d.ts.map +1 -0
  253. package/bin/esm/utils/index.js +2 -0
  254. package/bin/esm/utils/index.js.map +1 -0
  255. package/bin/esm/utils/type-check.d.ts +15 -0
  256. package/bin/esm/utils/type-check.d.ts.map +1 -0
  257. package/bin/esm/utils/type-check.js.map +1 -0
  258. package/package.json +61 -47
  259. package/src/index.ts +6 -6
  260. package/src/interfaces/index.ts +1 -1
  261. package/src/internal/index.ts +2 -2
  262. package/src/internal/type-guards.ts +1 -1
  263. package/src/live-hooks/index.ts +7 -7
  264. package/src/live-hooks/useLiveCanvas.ts +154 -82
  265. package/src/live-hooks/useLiveEvent.ts +43 -7
  266. package/src/live-hooks/useLiveFollowMode.ts +149 -6
  267. package/src/live-hooks/useLivePresence.ts +80 -17
  268. package/src/live-hooks/useLiveState.ts +54 -6
  269. package/src/live-hooks/useLiveTimer.ts +59 -4
  270. package/src/live-hooks/useMediaSynchronizer.ts +71 -6
  271. package/src/providers/AzureProvider.tsx +21 -21
  272. package/src/providers/LiveShareProvider.tsx +115 -13
  273. package/src/providers/index.ts +2 -2
  274. package/src/shared-hooks/index.ts +6 -4
  275. package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
  276. package/src/shared-hooks/internals/tree-node-types.ts +26 -0
  277. package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
  278. package/src/shared-hooks/useDynamicDDS.ts +28 -17
  279. package/src/shared-hooks/useSharedMap.ts +42 -17
  280. package/src/shared-hooks/useSharedState.ts +6 -3
  281. package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
  282. package/src/shared-hooks/useSharedTree.ts +144 -0
  283. package/src/shared-hooks/useTreeNode.ts +147 -0
  284. package/src/types/ActionTypes.ts +13 -9
  285. package/src/types/PropTypes.ts +57 -0
  286. package/src/types/ResultTypes.ts +71 -17
  287. package/src/types/index.ts +3 -3
  288. package/src/utils/index.ts +1 -1
  289. package/tsconfig.cjs.json +14 -0
  290. package/tsconfig.json +65 -70
  291. package/.nycrc.json +0 -10
  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 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./ActionTypes.js";
2
+ export * from "./ResultTypes.js";
3
+ export * from "./PropTypes.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./type-check.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./type-check.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { ExtendedMediaMetadata, IMediaPlayer } from "@microsoft/live-share-media";
6
+ import React from "react";
7
+ export declare function isRefObject<T>(value: any): value is React.RefObject<T>;
8
+ export declare function isMediaElement(value: any): value is IMediaPlayer;
9
+ export declare function isExtendedMediaMetadata(value: any): value is ExtendedMediaMetadata;
10
+ export declare function isMap(value: any): value is Map<string, any>;
11
+ export declare function isEntries(value: any): value is readonly (readonly [string, any])[];
12
+ export declare function isJSON(value: any): value is {
13
+ [key: string]: any;
14
+ };
15
+ //# sourceMappingURL=type-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-check.d.ts","sourceRoot":"","sources":["../../../src/utils/type-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,qBAAqB,EACrB,YAAY,EACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAEtE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,YAAY,CAoBhE;AAED,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,GAAG,GACX,KAAK,IAAI,qBAAqB,CAEhC;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAE3D;AAED,wBAAgB,SAAS,CACrB,KAAK,EAAE,GAAG,GACX,KAAK,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAU9C;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAOlE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-check.js","sourceRoot":"","sources":["../../../src/utils/type-check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,UAAU,WAAW,CAAI,KAAU;IACrC,OAAO,KAAK,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAU;IACrC,IAAI,KAAK,EAAE,CAAC;QACR,OAAO,CACH,KAAK,CAAC,UAAU,KAAK,SAAS;YAC9B,KAAK,CAAC,WAAW,KAAK,SAAS;YAC/B,KAAK,CAAC,QAAQ,KAAK,SAAS;YAC5B,KAAK,CAAC,KAAK,KAAK,SAAS;YACzB,KAAK,CAAC,KAAK,KAAK,SAAS;YACzB,KAAK,CAAC,MAAM,KAAK,SAAS;YAC1B,KAAK,CAAC,YAAY,KAAK,SAAS;YAChC,KAAK,CAAC,GAAG,KAAK,SAAS;YACvB,KAAK,CAAC,MAAM,KAAK,SAAS;YAC1B,KAAK,CAAC,IAAI,KAAK,SAAS;YACxB,KAAK,CAAC,KAAK,KAAK,SAAS;YACzB,KAAK,CAAC,IAAI,KAAK,SAAS;YACxB,KAAK,CAAC,gBAAgB,KAAK,SAAS;YACpC,KAAK,CAAC,mBAAmB,KAAK,SAAS,CAC1C,CAAC;IACN,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,uBAAuB,CACnC,KAAU;IAEV,OAAO,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAA,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,KAAU;IAC5B,OAAO,KAAK,YAAY,GAAG,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,SAAS,CACrB,KAAU;IAEV,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,KAAyC,CAAC;QAC3D,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAU;IAC7B,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,KAA+B,CAAC;QACjD,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,48 +1,62 @@
1
1
  {
2
- "name": "@microsoft/live-share-react",
3
- "version": "2.0.0-internal.1",
4
- "description": "Build collaborative React apps using Microsoft's Fluid & Live Share frameworks with ease.",
5
- "author": "Microsoft",
6
- "license": "SEE LICENSE IN LICENSE",
7
- "main": "./bin/index.js",
8
- "types": "./bin/index.d.ts",
9
- "scripts": {
10
- "clean": "npx shx rm -rf bin",
11
- "build": "tsc -p tsconfig.build.json",
12
- "typecheck": "tsc"
13
- },
14
- "dependencies": {
15
- "@microsoft/live-share-turbo": "2.0.0-internal.1",
16
- "url": "^0.11.0",
17
- "uuid": "^9.0.0"
18
- },
19
- "devDependencies": {
20
- "@babel/core": "^7.21.8",
21
- "@microsoft/live-share": "2.0.0-internal.1",
22
- "@microsoft/live-share-canvas": "2.0.0-internal.1",
23
- "@microsoft/live-share-media": "2.0.0-internal.1",
24
- "@types/react": "^18.0.0",
25
- "@types/react-dom": "^18.0.0",
26
- "@types/uuid": "^9.0.1",
27
- "babel-loader": "^9.1.2",
28
- "fluid-framework": "^2.0.0-rc.1",
29
- "typescript": "^5.0.4"
30
- },
31
- "peerDependencies": {
32
- "@microsoft/live-share": "2.0.0-internal.1",
33
- "@microsoft/live-share-canvas": "2.0.0-internal.1",
34
- "@microsoft/live-share-media": "2.0.0-internal.1",
35
- "fluid-framework": "^2.0.0-rc || ^2.0.0-internal",
36
- "react": "^16.8.0 || ^17 || ^18",
37
- "react-dom": "^16.8.0 || ^17 || ^18"
38
- },
39
- "repository": {
40
- "directory": "packages/live-share-react",
41
- "type": "git",
42
- "url": "https://github.com/microsoft/live-share-sdk"
43
- },
44
- "homepage": "https://aka.ms/teamsliveshare",
45
- "bugs": {
46
- "url": "https://github.com/microsoft/live-share-sdk/issues"
47
- }
48
- }
2
+ "name": "@microsoft/live-share-react",
3
+ "version": "2.0.0-internal.10",
4
+ "description": "Build collaborative React apps using Microsoft's Fluid & Live Share frameworks with ease.",
5
+ "author": "Microsoft",
6
+ "license": "SEE LICENSE IN LICENSE",
7
+ "main": "./bin/cjs/index.js",
8
+ "module": "./bin/esm/index.js",
9
+ "types": "./bin/esm/index.d.ts",
10
+ "type": "module",
11
+ "scripts": {
12
+ "clean": "npx shx rm -rf bin",
13
+ "build": "node ../../internal/build-tools/build-package.js --cjs --esm",
14
+ "typecheck": "tsc"
15
+ },
16
+ "exports": {
17
+ "./package.json": "./package.json",
18
+ ".": {
19
+ "require": {
20
+ "types": "./bin/cjs/index.d.ts",
21
+ "default": "./bin/cjs/index.js"
22
+ },
23
+ "import": {
24
+ "types": "./bin/esm/index.d.ts",
25
+ "default": "./bin/esm/index.js"
26
+ }
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "url": "^0.11.0",
31
+ "uuid": "^9.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@babel/core": "^7.21.8",
35
+ "@microsoft/live-share": "2.0.0-internal.10",
36
+ "@microsoft/live-share-canvas": "2.0.0-internal.10",
37
+ "@microsoft/live-share-media": "2.0.0-internal.10",
38
+ "@types/react": "^18.0.0",
39
+ "@types/react-dom": "^18.0.0",
40
+ "@types/uuid": "^9.0.1",
41
+ "babel-loader": "^9.1.2",
42
+ "fluid-framework": ">=2.40 <2.50",
43
+ "typescript": "~5.5.3"
44
+ },
45
+ "peerDependencies": {
46
+ "@microsoft/live-share": "2.0.0-internal.10",
47
+ "@microsoft/live-share-canvas": "2.0.0-internal.10",
48
+ "@microsoft/live-share-media": "2.0.0-internal.10",
49
+ "fluid-framework": ">=2.40 <2.50",
50
+ "react": "^16.8.0 || ^17 || ^18",
51
+ "react-dom": "^16.8.0 || ^17 || ^18"
52
+ },
53
+ "repository": {
54
+ "directory": "packages/live-share-react",
55
+ "type": "git",
56
+ "url": "https://github.com/microsoft/live-share-sdk"
57
+ },
58
+ "homepage": "https://aka.ms/teamsliveshare",
59
+ "bugs": {
60
+ "url": "https://github.com/microsoft/live-share-sdk/issues"
61
+ }
62
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from "./providers";
2
- export * from "./shared-hooks";
3
- export * from "./live-hooks";
4
- export * from "./types";
5
- export * from "./providers";
6
- export * from "./interfaces";
1
+ export * from "./providers/index.js";
2
+ export * from "./shared-hooks/index.js";
3
+ export * from "./live-hooks/index.js";
4
+ export * from "./types/index.js";
5
+ export * from "./providers/index.js";
6
+ export * from "./interfaces/index.js";
@@ -1 +1 @@
1
- export * from "./LiveInterfaceExtensions";
1
+ export * from "./LiveInterfaceExtensions.js";
@@ -1,2 +1,2 @@
1
- export * from "./errors";
2
- export * from "./type-guards";
1
+ export * from "./errors.js";
2
+ export * from "./type-guards.js";
@@ -1,4 +1,4 @@
1
- import { ITeamsJsSdkError } from "./errors";
1
+ import { ITeamsJsSdkError } from "./errors.js";
2
2
 
3
3
  /**
4
4
  * @hidden
@@ -1,7 +1,7 @@
1
- export * from "./useLivePresence";
2
- export * from "./useLiveFollowMode";
3
- export * from "./useLiveState";
4
- export * from "./useMediaSynchronizer";
5
- export * from "./useLiveEvent";
6
- export * from "./useLiveCanvas";
7
- export * from "./useLiveTimer";
1
+ export * from "./useLivePresence.js";
2
+ export * from "./useLiveFollowMode.js";
3
+ export * from "./useLiveState.js";
4
+ export * from "./useMediaSynchronizer.js";
5
+ export * from "./useLiveEvent.js";
6
+ export * from "./useLiveCanvas.js";
7
+ export * from "./useLiveTimer.js";
@@ -3,18 +3,16 @@
3
3
  * Licensed under the Microsoft Live Share SDK License.
4
4
  */
5
5
 
6
- import {
7
- CanvasReferencePoint,
8
- IBrush,
9
- InkingManager,
10
- InkingTool,
11
- IPoint,
12
- LiveCanvas,
13
- } from "@microsoft/live-share-canvas";
6
+ import { InkingManager, LiveCanvas } from "@microsoft/live-share-canvas";
14
7
  import React from "react";
15
- import { useDynamicDDS } from "../shared-hooks";
16
- import { IUseLiveCanvasResults } from "../types";
17
- import { isRefObject } from "../utils";
8
+ import { useDynamicDDS } from "../shared-hooks/index.js";
9
+ import {
10
+ IUseLiveCanvasOptionalProps,
11
+ IUseLiveCanvasResults,
12
+ } from "../types/index.js";
13
+ import { isRefObject } from "../utils/index.js";
14
+ import { getRawNode } from "../shared-hooks/internals/tree-node-utils.js";
15
+ import { LiveDataObjectInitializeState } from "@microsoft/live-share";
18
16
 
19
17
  /**
20
18
  * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
@@ -26,27 +24,72 @@ import { isRefObject } from "../utils";
26
24
  *
27
25
  * @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
28
26
  * @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
29
- * @param active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
30
- * @param tool Optional. Stateful enum for what tool to use in the `InkingManager`.
31
- * @param lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
32
- * @param offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
33
- * @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
34
- * @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
35
- * @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
36
- * @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
37
- * @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
27
+ * @param props Optional. Other optional props.
28
+ * @param props.active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
29
+ * @param props.tool Optional. Stateful enum for what tool to use in the `InkingManager`.
30
+ * @param props.lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
31
+ * @param props.offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
32
+ * @param props.scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
33
+ * @param props.referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
34
+ * @param props.isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
35
+ * @param props.localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
36
+ * @param props.node Optional. A Fluid `LiveCanvasTree` `TreeNode` instance to swap out the underlying storage solution for strokes.
37
+ * To learn more, look at Fluid's [SharedTree](https://fluidframework.com/docs/data-structures/tree/) documentation.
38
+ * @param allowedRoles Optional. The user roles that are allowed to start/stop/pause the timer.
39
+ *
40
+ * @returns `IUseLiveCanvasResults` object that contains the `liveCanvas` data object and `inkingManager`.
41
+ *
42
+ * @example
43
+ ```jsx
44
+ import { useLiveCanvas } from "@microsoft/live-share-react";
45
+ import { InkingTool } from "@microsoft/live-share-canvas";
46
+ import { useRef } from "react";
47
+
48
+ // Unique identifier that distinguishes this useLiveCanvas from others in your app
49
+ const UNIQUE_KEY = "CUSTOM-LIVE-CANVAS";
50
+
51
+ // Example component
52
+ export function ExampleLiveCanvas() {
53
+ const liveCanvasRef = useRef(null);
54
+ const { liveCanvas, inkingManager } = useLiveCanvas(
55
+ "CUSTOM-LIVE-CANVAS",
56
+ liveCanvasRef,
57
+ );
58
+
59
+ return (
60
+ <div style={{ position: "absolute"}}>
61
+ <div
62
+ ref={liveCanvasRef}
63
+ // Best practice is to not define inline styles
64
+ style={{ width: "556px", height: "224px" }}
65
+ />
66
+ {!!liveCanvas && (
67
+ <div>
68
+ <button
69
+ onClick={() => {
70
+ inkingManager.tool = InkingTool.pen;
71
+ }}
72
+ >
73
+ {"Pen"}
74
+ </button>
75
+ <button
76
+ onClick={() => {
77
+ inkingManager.tool = InkingTool.laserPointer;
78
+ }}
79
+ >
80
+ {"Laser pointer"}
81
+ </button>
82
+ </div>
83
+ )}
84
+ </div>
85
+ );
86
+ };
87
+ ```
38
88
  */
39
89
  export function useLiveCanvas(
40
90
  uniqueKey: string,
41
91
  canvasElementRef: React.RefObject<HTMLElement | null> | string,
42
- active?: boolean,
43
- tool?: InkingTool,
44
- lineBrush?: IBrush,
45
- offset?: IPoint,
46
- scale?: number,
47
- referencePoint?: CanvasReferencePoint,
48
- isCursorShared?: boolean,
49
- localUserPictureUrl?: string
92
+ props?: IUseLiveCanvasOptionalProps
50
93
  ): IUseLiveCanvasResults {
51
94
  /**
52
95
  * User facing: inking manager instance
@@ -61,103 +104,132 @@ export function useLiveCanvas(
61
104
  LiveCanvas
62
105
  );
63
106
 
107
+ // This should change less frequently then node if they are using `useTreeNode`
108
+ // We need the raw node anyways to apply event listeners
109
+ const rawNode = getRawNode(props?.node);
110
+
64
111
  /**
65
112
  * Setup the InkingManager and LiveCanvas
66
113
  */
114
+ React.useEffect(
115
+ () => {
116
+ // if the component is already listening or liveCanvas is not yet initialized, return
117
+ if (!liveCanvas) return;
118
+ // get the canvas element from the ref or document
119
+ let htmlElement: HTMLElement | null;
120
+ if (isRefObject(canvasElementRef)) {
121
+ htmlElement = canvasElementRef.current;
122
+ } else {
123
+ htmlElement = document.getElementById(canvasElementRef);
124
+ }
125
+ if (htmlElement === null) return;
126
+ // Clear out existing nodes
127
+ function removeAllChildren(node: HTMLElement | ChildNode) {
128
+ node.childNodes.forEach((childNode) => {
129
+ removeAllChildren(childNode);
130
+ childNode.remove();
131
+ });
132
+ }
133
+ removeAllChildren(htmlElement);
134
+ // Create the InkingManager and initialize the liveCanvas with it
135
+ const inkingManager = new InkingManager(htmlElement);
136
+ setInkingManager(inkingManager);
137
+ liveCanvas.initialize(inkingManager, props?.allowedRoles, rawNode);
138
+
139
+ // cleanup function to be called when the component is unmount
140
+ return () => {
141
+ inkingManager.removeAllListeners();
142
+ };
143
+ },
144
+ // Intentionally ommitting rawNode from deps because we only want to initialize once,
145
+ // whereas rawNode may change many times.
146
+ [liveCanvas, props?.allowedRoles]
147
+ );
148
+
149
+ /**
150
+ * Set the node if it changes while LiveCanvas is initialized
151
+ */
67
152
  React.useEffect(() => {
68
- // if the component is already listening or liveCanvas is not yet initialized, return
69
- if (!liveCanvas) return;
70
- // get the canvas element from the ref or document
71
- let htmlElement: HTMLElement | null;
72
- if (isRefObject(canvasElementRef)) {
73
- htmlElement = canvasElementRef.current;
74
- } else {
75
- htmlElement = document.getElementById(canvasElementRef);
76
- }
77
- if (htmlElement === null) return;
78
- // Create the InkingManager and initialize the liveCanvas with it
79
- const inkingManager = new InkingManager(htmlElement);
80
- setInkingManager(inkingManager);
81
- liveCanvas.initialize(inkingManager);
82
-
83
- // cleanup function to be called when the component is unmount
84
- return () => {
85
- // liveCanvas.dispose();
86
- inkingManager.removeAllListeners();
87
- };
88
- }, [liveCanvas]);
153
+ if (
154
+ !rawNode ||
155
+ liveCanvas?.initializeState !==
156
+ LiveDataObjectInitializeState.succeeded
157
+ )
158
+ return;
159
+ liveCanvas.setTreeNode(rawNode);
160
+ }, [liveCanvas, rawNode]);
89
161
 
90
162
  /**
91
163
  * Activate or deactivate the inkingManager based on the 'active' prop
92
164
  */
93
165
  React.useEffect(() => {
94
- if (inkingManager && active !== undefined) {
95
- if (active) {
166
+ if (inkingManager && props?.active !== undefined) {
167
+ if (props?.active) {
96
168
  inkingManager.activate();
97
169
  } else {
98
170
  inkingManager.deactivate();
99
171
  }
100
172
  }
101
- }, [active, inkingManager]);
173
+ }, [props?.active, inkingManager]);
102
174
 
103
175
  /**
104
176
  * Sets the tool of the inkingManager based on the 'tool' prop
105
177
  */
106
178
  React.useEffect(() => {
107
- if (inkingManager && tool !== undefined) {
108
- inkingManager.tool = tool;
179
+ if (inkingManager && props?.tool !== undefined) {
180
+ inkingManager.tool = props.tool;
109
181
  }
110
- }, [tool, inkingManager]);
182
+ }, [props?.tool, inkingManager]);
111
183
 
112
184
  /**
113
185
  * Sets the offset of the inkingManager based on the 'offset' prop
114
186
  */
115
187
  React.useEffect(() => {
116
- if (inkingManager && offset !== undefined) {
188
+ if (inkingManager && props?.offset !== undefined) {
117
189
  inkingManager.offset = {
118
- x: offset.x,
119
- y: offset.y,
190
+ x: props?.offset.x,
191
+ y: props?.offset.y,
120
192
  };
121
193
  }
122
- }, [offset?.x, offset?.y, inkingManager]);
194
+ }, [props?.offset?.x, props?.offset?.y, inkingManager]);
123
195
 
124
196
  /**
125
197
  * Sets the scale of the inkingManager based on the 'scale' prop
126
198
  */
127
199
  React.useEffect(() => {
128
- if (inkingManager && scale !== undefined) {
129
- inkingManager.scale = scale;
200
+ if (inkingManager && props?.scale !== undefined) {
201
+ inkingManager.scale = props?.scale;
130
202
  }
131
- }, [scale, inkingManager]);
203
+ }, [props?.scale, inkingManager]);
132
204
 
133
205
  /**
134
206
  * Sets the referencePoint of the inkingManager based on the 'referencePoint' prop
135
207
  */
136
208
  React.useEffect(() => {
137
- if (inkingManager && referencePoint !== undefined) {
138
- inkingManager.referencePoint = referencePoint;
209
+ if (inkingManager && props?.referencePoint !== undefined) {
210
+ inkingManager.referencePoint = props?.referencePoint;
139
211
  }
140
- }, [referencePoint, inkingManager]);
212
+ }, [props?.referencePoint, inkingManager]);
141
213
 
142
214
  /**
143
215
  * Sets the lineBrush of the inkingManager based on the 'lineBrush' prop
144
216
  */
145
217
  React.useEffect(() => {
146
- if (inkingManager && lineBrush) {
218
+ if (inkingManager && props?.lineBrush) {
147
219
  inkingManager.lineBrush = {
148
- color: lineBrush.color,
149
- tip: lineBrush.tip,
150
- tipSize: lineBrush.tipSize,
151
- type: lineBrush.type,
152
- endArrow: lineBrush.endArrow,
220
+ color: props.lineBrush.color,
221
+ tip: props.lineBrush.tip,
222
+ tipSize: props.lineBrush.tipSize,
223
+ type: props.lineBrush.type,
224
+ endArrow: props.lineBrush.endArrow,
153
225
  };
154
226
  }
155
227
  }, [
156
- lineBrush?.color,
157
- lineBrush?.tip,
158
- lineBrush?.tipSize,
159
- lineBrush?.type,
160
- lineBrush?.endArrow,
228
+ props?.lineBrush?.color,
229
+ props?.lineBrush?.tip,
230
+ props?.lineBrush?.tipSize,
231
+ props?.lineBrush?.type,
232
+ props?.lineBrush?.endArrow,
161
233
  inkingManager,
162
234
  ]);
163
235
 
@@ -165,21 +237,21 @@ export function useLiveCanvas(
165
237
  * Sets the isCursorShared of the liveCanvas based on the 'isCursorShared' prop
166
238
  */
167
239
  React.useEffect(() => {
168
- if (liveCanvas && isCursorShared !== undefined) {
169
- liveCanvas.isCursorShared = isCursorShared;
240
+ if (liveCanvas && props?.isCursorShared !== undefined) {
241
+ liveCanvas.isCursorShared = props.isCursorShared;
170
242
  }
171
- }, [isCursorShared, liveCanvas]);
243
+ }, [props?.isCursorShared, liveCanvas]);
172
244
 
173
245
  /**
174
246
  * Sets the onGetLocalUserInfo method of the liveCanvas based on the 'localUserCursor' prop
175
247
  */
176
248
  React.useEffect(() => {
177
- if (liveCanvas && localUserPictureUrl) {
249
+ if (liveCanvas && props?.localUserPictureUrl) {
178
250
  liveCanvas.onGetLocalUserPictureUrl = (): string | undefined => {
179
- return localUserPictureUrl;
251
+ return props.localUserPictureUrl;
180
252
  };
181
253
  }
182
- }, [localUserPictureUrl, liveCanvas]);
254
+ }, [props?.localUserPictureUrl, liveCanvas]);
183
255
 
184
256
  /**
185
257
  * Return hook response
@@ -14,15 +14,15 @@ import {
14
14
  IUseLiveEventResults,
15
15
  OnReceivedLiveEventAction,
16
16
  SendLiveEventAction,
17
- } from "../types";
18
- import { IReceiveLiveEvent } from "../interfaces";
19
- import { useDynamicDDS } from "../shared-hooks";
17
+ } from "../types/index.js";
18
+ import { IReceiveLiveEvent } from "../interfaces/index.js";
19
+ import { useDynamicDDS } from "../shared-hooks/index.js";
20
20
  import {
21
21
  ActionContainerNotJoinedError,
22
22
  ActionLiveDataObjectInitializedError,
23
23
  ActionLiveDataObjectUndefinedError,
24
- } from "../internal";
25
- import { useFluidObjectsContext } from "../providers";
24
+ } from "../internal/index.js";
25
+ import { useFluidObjectsContext } from "../providers/index.js";
26
26
 
27
27
  /**
28
28
  * React hook for using a Live Share `LiveEvent`.
@@ -38,6 +38,42 @@ import { useFluidObjectsContext } from "../providers";
38
38
  * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
39
39
  * @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
40
40
  * @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
41
+ *
42
+ * @example
43
+ ```jsx
44
+ import { useLiveEvent } from "@microsoft/live-share-react";
45
+
46
+ const emojis = ["❤️", "😂", "👍", "👎"];
47
+
48
+ // Define a unique key that differentiates this usage of `useLiveEvent` from others in your app
49
+ const MY_UNIQUE_KEY = "event-key";
50
+
51
+ // Example component for using useLiveEvent
52
+ export const MyCustomEvent = () => {
53
+ const { latestEvent, liveEvent, sendEvent } = useLiveEvent(MY_UNIQUE_KEY);
54
+
55
+ // Render loading UI when creating LiveEvent instance for first time
56
+ if (!liveEvent) return <>Loading...</>;
57
+
58
+ // Render UI
59
+ return (
60
+ <div>
61
+ {`Latest event: ${latestEvent?.value}, from local user: ${latestEvent?.local}`}
62
+ {"Select a planet below:"}
63
+ {emojis.map((emoji) => (
64
+ <button
65
+ key={emoji}
66
+ onClick={() => {
67
+ sendEvent(emoji);
68
+ }}
69
+ >
70
+ {emoji}
71
+ </button>
72
+ ))}
73
+ </div>
74
+ );
75
+ };
76
+ ```
41
77
  */
42
78
  export function useLiveEvent<TEvent = any>(
43
79
  uniqueKey: string,
@@ -68,7 +104,7 @@ export function useLiveEvent<TEvent = any>(
68
104
  * User facing: callback to send event through `LiveEvent`
69
105
  */
70
106
  const sendEvent: SendLiveEventAction<TEvent> = React.useCallback(
71
- async (event: TEvent) => {
107
+ async (event: TEvent, targetClientId?: string) => {
72
108
  if (!container) {
73
109
  throw new ActionContainerNotJoinedError(
74
110
  "liveEvent",
@@ -87,7 +123,7 @@ export function useLiveEvent<TEvent = any>(
87
123
  "sendEvent"
88
124
  );
89
125
  }
90
- return await liveEvent.send(event);
126
+ return await liveEvent.send(event, targetClientId);
91
127
  },
92
128
  [container, liveEvent]
93
129
  );