@microsoft/live-share-react 2.0.0-internal.2 → 2.0.0-internal.20

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 (252) hide show
  1. package/LICENSE +64 -61
  2. package/README.md +175 -164
  3. package/bin/esm/index.d.ts +7 -0
  4. package/bin/esm/index.d.ts.map +1 -0
  5. package/bin/esm/index.js +7 -0
  6. package/bin/esm/index.js.map +1 -0
  7. package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
  8. package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
  9. package/bin/esm/interfaces/index.d.ts +2 -0
  10. package/bin/esm/interfaces/index.d.ts.map +1 -0
  11. package/bin/esm/interfaces/index.js +2 -0
  12. package/bin/esm/interfaces/index.js.map +1 -0
  13. package/bin/esm/internal/errors.d.ts.map +1 -0
  14. package/bin/esm/internal/errors.js.map +1 -0
  15. package/bin/esm/internal/index.d.ts +3 -0
  16. package/bin/esm/internal/index.d.ts.map +1 -0
  17. package/bin/esm/internal/index.js +3 -0
  18. package/bin/esm/internal/index.js.map +1 -0
  19. package/bin/{internal → esm/internal}/type-guards.d.ts +1 -1
  20. package/bin/esm/internal/type-guards.d.ts.map +1 -0
  21. package/bin/esm/internal/type-guards.js.map +1 -0
  22. package/bin/esm/live-hooks/index.d.ts +8 -0
  23. package/bin/esm/live-hooks/index.d.ts.map +1 -0
  24. package/bin/esm/live-hooks/index.js +8 -0
  25. package/bin/esm/live-hooks/index.js.map +1 -0
  26. package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
  27. package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
  28. package/bin/esm/live-hooks/useLiveCanvas.js +237 -0
  29. package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
  30. package/bin/{live-hooks → esm/live-hooks}/useLiveEvent.d.ts +37 -1
  31. package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
  32. package/bin/{live-hooks → esm/live-hooks}/useLiveEvent.js +45 -18
  33. package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
  34. package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
  35. package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
  36. package/bin/{live-hooks → esm/live-hooks}/useLiveFollowMode.js +173 -39
  37. package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
  38. package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
  39. package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
  40. package/bin/{live-hooks → esm/live-hooks}/useLivePresence.js +74 -25
  41. package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
  42. package/bin/{live-hooks → esm/live-hooks}/useLiveState.d.ts +46 -1
  43. package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
  44. package/bin/{live-hooks → esm/live-hooks}/useLiveState.js +58 -18
  45. package/bin/esm/live-hooks/useLiveState.js.map +1 -0
  46. package/bin/{live-hooks → esm/live-hooks}/useLiveTimer.d.ts +56 -1
  47. package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
  48. package/bin/{live-hooks → esm/live-hooks}/useLiveTimer.js +80 -34
  49. package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
  50. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
  51. package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
  52. package/bin/{live-hooks → esm/live-hooks}/useMediaSynchronizer.js +89 -37
  53. package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
  54. package/bin/{providers → esm/providers}/AzureProvider.d.ts +9 -9
  55. package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
  56. package/bin/{providers → esm/providers}/AzureProvider.js +28 -33
  57. package/bin/esm/providers/AzureProvider.js.map +1 -0
  58. package/bin/{providers → esm/providers}/LiveShareProvider.d.ts +106 -4
  59. package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
  60. package/bin/esm/providers/LiveShareProvider.js +196 -0
  61. package/bin/esm/providers/LiveShareProvider.js.map +1 -0
  62. package/bin/esm/providers/index.d.ts +3 -0
  63. package/bin/esm/providers/index.d.ts.map +1 -0
  64. package/bin/esm/providers/index.js +3 -0
  65. package/bin/esm/providers/index.js.map +1 -0
  66. package/bin/esm/shared-hooks/index.d.ts +7 -0
  67. package/bin/esm/shared-hooks/index.d.ts.map +1 -0
  68. package/bin/esm/shared-hooks/index.js +7 -0
  69. package/bin/esm/shared-hooks/index.js.map +1 -0
  70. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
  71. package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
  72. package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
  73. package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
  74. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
  75. package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
  76. package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
  77. package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
  78. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
  79. package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
  80. package/bin/esm/shared-hooks/internals/tree-node-utils.js +186 -0
  81. package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
  82. package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.d.ts +4 -4
  83. package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
  84. package/bin/{shared-hooks → esm/shared-hooks}/useDynamicDDS.js +22 -22
  85. package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
  86. package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.d.ts +4 -2
  87. package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
  88. package/bin/{shared-hooks → esm/shared-hooks}/useSharedMap.js +28 -14
  89. package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
  90. package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.d.ts +1 -1
  91. package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
  92. package/bin/{shared-hooks → esm/shared-hooks}/useSharedState.js +2 -2
  93. package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
  94. package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.d.ts +1 -1
  95. package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
  96. package/bin/{shared-hooks → esm/shared-hooks}/useSharedStateRegistry.js +35 -24
  97. package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
  98. package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
  99. package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
  100. package/bin/esm/shared-hooks/useSharedTree.js +117 -0
  101. package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
  102. package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
  103. package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
  104. package/bin/esm/shared-hooks/useTreeNode.js +132 -0
  105. package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
  106. package/bin/{types → esm/types}/ActionTypes.d.ts +7 -7
  107. package/bin/esm/types/ActionTypes.d.ts.map +1 -0
  108. package/bin/esm/types/ActionTypes.js.map +1 -0
  109. package/bin/esm/types/FluidMap.d.ts +151 -0
  110. package/bin/esm/types/FluidMap.d.ts.map +1 -0
  111. package/bin/esm/types/FluidMap.js +24 -0
  112. package/bin/esm/types/FluidMap.js.map +1 -0
  113. package/bin/esm/types/PropTypes.d.ts +56 -0
  114. package/bin/esm/types/PropTypes.d.ts.map +1 -0
  115. package/bin/esm/types/PropTypes.js.map +1 -0
  116. package/bin/{types → esm/types}/ResultTypes.d.ts +62 -18
  117. package/bin/esm/types/ResultTypes.d.ts.map +1 -0
  118. package/bin/esm/types/ResultTypes.js.map +1 -0
  119. package/bin/esm/types/index.d.ts +4 -0
  120. package/bin/esm/types/index.d.ts.map +1 -0
  121. package/bin/esm/types/index.js +4 -0
  122. package/bin/esm/types/index.js.map +1 -0
  123. package/bin/esm/utils/index.d.ts +2 -0
  124. package/bin/esm/utils/index.d.ts.map +1 -0
  125. package/bin/esm/utils/index.js +2 -0
  126. package/bin/esm/utils/index.js.map +1 -0
  127. package/bin/esm/utils/type-check.d.ts.map +1 -0
  128. package/bin/{utils → esm/utils}/type-check.js +1 -1
  129. package/bin/esm/utils/type-check.js.map +1 -0
  130. package/package.json +51 -47
  131. package/src/index.ts +6 -6
  132. package/src/interfaces/index.ts +1 -1
  133. package/src/internal/index.ts +2 -2
  134. package/src/internal/type-guards.ts +1 -1
  135. package/src/live-hooks/index.ts +7 -7
  136. package/src/live-hooks/useLiveCanvas.ts +154 -82
  137. package/src/live-hooks/useLiveEvent.ts +43 -7
  138. package/src/live-hooks/useLiveFollowMode.ts +149 -6
  139. package/src/live-hooks/useLivePresence.ts +80 -17
  140. package/src/live-hooks/useLiveState.ts +54 -6
  141. package/src/live-hooks/useLiveTimer.ts +59 -4
  142. package/src/live-hooks/useMediaSynchronizer.ts +71 -6
  143. package/src/providers/AzureProvider.tsx +21 -21
  144. package/src/providers/LiveShareProvider.tsx +115 -13
  145. package/src/providers/index.ts +2 -2
  146. package/src/shared-hooks/index.ts +6 -4
  147. package/src/shared-hooks/internals/tree-node-constants.ts +2 -0
  148. package/src/shared-hooks/internals/tree-node-types.ts +26 -0
  149. package/src/shared-hooks/internals/tree-node-utils.ts +269 -0
  150. package/src/shared-hooks/useDynamicDDS.ts +28 -17
  151. package/src/shared-hooks/useSharedMap.ts +42 -17
  152. package/src/shared-hooks/useSharedState.ts +6 -3
  153. package/src/shared-hooks/useSharedStateRegistry.ts +44 -22
  154. package/src/shared-hooks/useSharedTree.ts +144 -0
  155. package/src/shared-hooks/useTreeNode.ts +147 -0
  156. package/src/types/ActionTypes.ts +13 -9
  157. package/src/types/FluidMap.ts +169 -0
  158. package/src/types/PropTypes.ts +57 -0
  159. package/src/types/ResultTypes.ts +88 -17
  160. package/src/types/index.ts +3 -3
  161. package/src/utils/index.ts +1 -1
  162. package/tsconfig.json +64 -70
  163. package/.nycrc.json +0 -10
  164. package/bin/index.d.ts +0 -7
  165. package/bin/index.d.ts.map +0 -1
  166. package/bin/index.js +0 -7
  167. package/bin/index.js.map +0 -1
  168. package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +0 -1
  169. package/bin/interfaces/LiveInterfaceExtensions.js.map +0 -1
  170. package/bin/interfaces/index.d.ts +0 -2
  171. package/bin/interfaces/index.d.ts.map +0 -1
  172. package/bin/interfaces/index.js +0 -2
  173. package/bin/interfaces/index.js.map +0 -1
  174. package/bin/internal/errors.d.ts.map +0 -1
  175. package/bin/internal/errors.js.map +0 -1
  176. package/bin/internal/index.d.ts +0 -3
  177. package/bin/internal/index.d.ts.map +0 -1
  178. package/bin/internal/index.js +0 -3
  179. package/bin/internal/index.js.map +0 -1
  180. package/bin/internal/type-guards.d.ts.map +0 -1
  181. package/bin/internal/type-guards.js.map +0 -1
  182. package/bin/live-hooks/index.d.ts +0 -8
  183. package/bin/live-hooks/index.d.ts.map +0 -1
  184. package/bin/live-hooks/index.js +0 -8
  185. package/bin/live-hooks/index.js.map +0 -1
  186. package/bin/live-hooks/useLiveCanvas.d.ts +0 -29
  187. package/bin/live-hooks/useLiveCanvas.d.ts.map +0 -1
  188. package/bin/live-hooks/useLiveCanvas.js +0 -160
  189. package/bin/live-hooks/useLiveCanvas.js.map +0 -1
  190. package/bin/live-hooks/useLiveEvent.d.ts.map +0 -1
  191. package/bin/live-hooks/useLiveEvent.js.map +0 -1
  192. package/bin/live-hooks/useLiveFollowMode.d.ts +0 -24
  193. package/bin/live-hooks/useLiveFollowMode.d.ts.map +0 -1
  194. package/bin/live-hooks/useLiveFollowMode.js.map +0 -1
  195. package/bin/live-hooks/useLivePresence.d.ts +0 -26
  196. package/bin/live-hooks/useLivePresence.d.ts.map +0 -1
  197. package/bin/live-hooks/useLivePresence.js.map +0 -1
  198. package/bin/live-hooks/useLiveState.d.ts.map +0 -1
  199. package/bin/live-hooks/useLiveState.js.map +0 -1
  200. package/bin/live-hooks/useLiveTimer.d.ts.map +0 -1
  201. package/bin/live-hooks/useLiveTimer.js.map +0 -1
  202. package/bin/live-hooks/useMediaSynchronizer.d.ts +0 -25
  203. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +0 -1
  204. package/bin/live-hooks/useMediaSynchronizer.js.map +0 -1
  205. package/bin/providers/AzureProvider.d.ts.map +0 -1
  206. package/bin/providers/AzureProvider.js.map +0 -1
  207. package/bin/providers/LiveShareProvider.d.ts.map +0 -1
  208. package/bin/providers/LiveShareProvider.js +0 -95
  209. package/bin/providers/LiveShareProvider.js.map +0 -1
  210. package/bin/providers/index.d.ts +0 -3
  211. package/bin/providers/index.d.ts.map +0 -1
  212. package/bin/providers/index.js +0 -3
  213. package/bin/providers/index.js.map +0 -1
  214. package/bin/shared-hooks/index.d.ts +0 -5
  215. package/bin/shared-hooks/index.d.ts.map +0 -1
  216. package/bin/shared-hooks/index.js +0 -5
  217. package/bin/shared-hooks/index.js.map +0 -1
  218. package/bin/shared-hooks/useDynamicDDS.d.ts.map +0 -1
  219. package/bin/shared-hooks/useDynamicDDS.js.map +0 -1
  220. package/bin/shared-hooks/useSharedMap.d.ts.map +0 -1
  221. package/bin/shared-hooks/useSharedMap.js.map +0 -1
  222. package/bin/shared-hooks/useSharedState.d.ts.map +0 -1
  223. package/bin/shared-hooks/useSharedState.js.map +0 -1
  224. package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +0 -1
  225. package/bin/shared-hooks/useSharedStateRegistry.js.map +0 -1
  226. package/bin/types/ActionTypes.d.ts.map +0 -1
  227. package/bin/types/ActionTypes.js.map +0 -1
  228. package/bin/types/PropTypes.d.ts +0 -8
  229. package/bin/types/PropTypes.d.ts.map +0 -1
  230. package/bin/types/PropTypes.js.map +0 -1
  231. package/bin/types/ResultTypes.d.ts.map +0 -1
  232. package/bin/types/ResultTypes.js.map +0 -1
  233. package/bin/types/index.d.ts +0 -4
  234. package/bin/types/index.d.ts.map +0 -1
  235. package/bin/types/index.js +0 -4
  236. package/bin/types/index.js.map +0 -1
  237. package/bin/utils/index.d.ts +0 -2
  238. package/bin/utils/index.d.ts.map +0 -1
  239. package/bin/utils/index.js +0 -2
  240. package/bin/utils/index.js.map +0 -1
  241. package/bin/utils/type-check.d.ts.map +0 -1
  242. package/bin/utils/type-check.js.map +0 -1
  243. package/tsconfig.build.json +0 -6
  244. /package/bin/{interfaces → esm/interfaces}/LiveInterfaceExtensions.d.ts +0 -0
  245. /package/bin/{interfaces → esm/interfaces}/LiveInterfaceExtensions.js +0 -0
  246. /package/bin/{internal → esm/internal}/errors.d.ts +0 -0
  247. /package/bin/{internal → esm/internal}/errors.js +0 -0
  248. /package/bin/{internal → esm/internal}/type-guards.js +0 -0
  249. /package/bin/{types → esm/types}/ActionTypes.js +0 -0
  250. /package/bin/{types → esm/types}/PropTypes.js +0 -0
  251. /package/bin/{types → esm/types}/ResultTypes.js +0 -0
  252. /package/bin/{utils → esm/utils}/type-check.d.ts +0 -0
@@ -0,0 +1,96 @@
1
+ import { TreeChangeEvents, TreeNode } from "fluid-framework";
2
+ import { IUseTreeNodeResults } from "../types/index.js";
3
+ /**
4
+ * Makes a provided Fluid `TreeNode` stateful in React.
5
+ *
6
+ * @param node the Fluid `SharedTree` `TreeNode` instance to make stateful.
7
+ * @param stateChangeType listener type to apply changes for. Default value is "nodeChanged", which has the most optimal performance.
8
+ * Provide "treeChanged" to make all children nodes stateful as well when those child nodes change.
9
+ * When using the default, you must pass all child `TreeNode` values into `useTreeNode` for them to be stateful as well.
10
+ * @returns a stateful version `node`
11
+ *
12
+ * @example
13
+ * Example using default `"nodeChanged"` `stateChangeType`
14
+ * ```tsx
15
+ * import { SchemaFactory, TreeViewConfiguration } from "fluid-framework";
16
+ * import { useSharedTree, useTreeNode } from "@microsoft/live-share-react";
17
+ * // Declare a schema factory with your unique uuid
18
+ * const sf = new SchemaFactory("fc1db2e8-0000-11ee-be57-0242ac120002");
19
+ * class YourObject extends sf.object("YourObject", {
20
+ * listChangedCount: sf.number,
21
+ * list: sf.array(sf.string),
22
+ * }) {
23
+ * // You can add your own utility functions
24
+ * insert() {
25
+ * this.list.insertAtEnd("some text");
26
+ * this.listChangedCount += 1;
27
+ * }
28
+ * }
29
+ * const config = new TreeViewConfiguration({ schema: YourObject });
30
+ * const initialData = new YourObject({
31
+ * number: 0,
32
+ * list: [],
33
+ * });
34
+ *
35
+ * // Must be child component of <LiveShareProvider> or <AzureProvider>
36
+ * export const YourComponent = () => {
37
+ * // Get the root node of the `SharedTree` mapped to "some-unique-key"
38
+ * const { root } = useSharedTree("some-unique-key", config, initialData);
39
+ * // Makes root stateful / automatically update when the node changes (e.g., node.count)
40
+ * const { node } = useTreeNode(root);
41
+ * // node.list is its own TreeNode, so we make it stateful as well
42
+ * const { node: list } = useTreeNode(node?.list);
43
+ * if (!node || !list) return (<>"Loading"</>);
44
+ * return (
45
+ * <div>
46
+ * <div>Changed: {node.listChangedCount}</div>
47
+ * <button onClick={() => node.insert()}>Insert</button>
48
+ * { list.map((item) => <div key={item}>{item}</div>) }
49
+ * </div>
50
+ * );
51
+ * }
52
+ * ```
53
+ *
54
+ * @example
55
+ * Example using `"treeChanged"` `stateChangeType`
56
+ * ```tsx
57
+ * import { SchemaFactory, TreeViewConfiguration } from "fluid-framework";
58
+ * import { useSharedTree, useTreeNode } from "@microsoft/live-share-react";
59
+ * // Declare a schema factory with your unique uuid
60
+ * const sf = new SchemaFactory("fc1db2e8-0000-11ee-be57-0242ac120002");
61
+ *
62
+ * class ChildObject extends sf.object("ChildObject", {
63
+ * count: sf.number,
64
+ * }) {
65
+ * increment() {
66
+ * this.count += 1;
67
+ * }
68
+ * }
69
+ *
70
+ * class YourObject extends sf.object("YourObject", {
71
+ * child: ChildObject,
72
+ * }) {}
73
+ * const config = new TreeViewConfiguration({ schema: YourObject });
74
+ * const initialData = new YourObject({
75
+ * child: new ChildObject({ count: 0 }),
76
+ * });
77
+ *
78
+ * // Must be child component of <LiveShareProvider> or <AzureProvider>
79
+ * export const YourComponent = () => {
80
+ * // Get the root node of the `SharedTree` mapped to "some-unique-key"
81
+ * const { root } = useSharedTree("some-unique-key", config, initialData);
82
+ * // Using "treeChanged" prop makes all children nodes stateful as well.
83
+ * // Use with caution / measure render performance with React dev tools.
84
+ * const { node } = useTreeNode(root, "treeChanged");
85
+ * if (!node) return (<>"Loading"</>);
86
+ * return (
87
+ * <div>
88
+ * <div>Changed: {node.child.count}</div>
89
+ * <button onClick={() => node.increment()}>Insert</button>
90
+ * </div>
91
+ * );
92
+ * }
93
+ * ```
94
+ */
95
+ export declare function useTreeNode<TNode extends TreeNode | undefined = TreeNode>(node: TNode, stateChangeType?: keyof TreeChangeEvents): IUseTreeNodeResults<TNode>;
96
+ //# sourceMappingURL=useTreeNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTreeNode.d.ts","sourceRoot":"","sources":["../../../src/shared-hooks/useTreeNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,wBAAgB,WAAW,CAAC,KAAK,SAAS,QAAQ,GAAG,SAAS,GAAG,QAAQ,EACrE,IAAI,EAAE,KAAK,EACX,eAAe,GAAE,MAAM,gBAAgC,GACxD,mBAAmB,CAAC,KAAK,CAAC,CA0C5B"}
@@ -0,0 +1,132 @@
1
+ import { Tree } from "fluid-framework";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { getRawNode, buildProxy, setUpListenersForNodeChildren, } from "./internals/tree-node-utils.js";
4
+ /**
5
+ * Makes a provided Fluid `TreeNode` stateful in React.
6
+ *
7
+ * @param node the Fluid `SharedTree` `TreeNode` instance to make stateful.
8
+ * @param stateChangeType listener type to apply changes for. Default value is "nodeChanged", which has the most optimal performance.
9
+ * Provide "treeChanged" to make all children nodes stateful as well when those child nodes change.
10
+ * When using the default, you must pass all child `TreeNode` values into `useTreeNode` for them to be stateful as well.
11
+ * @returns a stateful version `node`
12
+ *
13
+ * @example
14
+ * Example using default `"nodeChanged"` `stateChangeType`
15
+ * ```tsx
16
+ * import { SchemaFactory, TreeViewConfiguration } from "fluid-framework";
17
+ * import { useSharedTree, useTreeNode } from "@microsoft/live-share-react";
18
+ * // Declare a schema factory with your unique uuid
19
+ * const sf = new SchemaFactory("fc1db2e8-0000-11ee-be57-0242ac120002");
20
+ * class YourObject extends sf.object("YourObject", {
21
+ * listChangedCount: sf.number,
22
+ * list: sf.array(sf.string),
23
+ * }) {
24
+ * // You can add your own utility functions
25
+ * insert() {
26
+ * this.list.insertAtEnd("some text");
27
+ * this.listChangedCount += 1;
28
+ * }
29
+ * }
30
+ * const config = new TreeViewConfiguration({ schema: YourObject });
31
+ * const initialData = new YourObject({
32
+ * number: 0,
33
+ * list: [],
34
+ * });
35
+ *
36
+ * // Must be child component of <LiveShareProvider> or <AzureProvider>
37
+ * export const YourComponent = () => {
38
+ * // Get the root node of the `SharedTree` mapped to "some-unique-key"
39
+ * const { root } = useSharedTree("some-unique-key", config, initialData);
40
+ * // Makes root stateful / automatically update when the node changes (e.g., node.count)
41
+ * const { node } = useTreeNode(root);
42
+ * // node.list is its own TreeNode, so we make it stateful as well
43
+ * const { node: list } = useTreeNode(node?.list);
44
+ * if (!node || !list) return (<>"Loading"</>);
45
+ * return (
46
+ * <div>
47
+ * <div>Changed: {node.listChangedCount}</div>
48
+ * <button onClick={() => node.insert()}>Insert</button>
49
+ * { list.map((item) => <div key={item}>{item}</div>) }
50
+ * </div>
51
+ * );
52
+ * }
53
+ * ```
54
+ *
55
+ * @example
56
+ * Example using `"treeChanged"` `stateChangeType`
57
+ * ```tsx
58
+ * import { SchemaFactory, TreeViewConfiguration } from "fluid-framework";
59
+ * import { useSharedTree, useTreeNode } from "@microsoft/live-share-react";
60
+ * // Declare a schema factory with your unique uuid
61
+ * const sf = new SchemaFactory("fc1db2e8-0000-11ee-be57-0242ac120002");
62
+ *
63
+ * class ChildObject extends sf.object("ChildObject", {
64
+ * count: sf.number,
65
+ * }) {
66
+ * increment() {
67
+ * this.count += 1;
68
+ * }
69
+ * }
70
+ *
71
+ * class YourObject extends sf.object("YourObject", {
72
+ * child: ChildObject,
73
+ * }) {}
74
+ * const config = new TreeViewConfiguration({ schema: YourObject });
75
+ * const initialData = new YourObject({
76
+ * child: new ChildObject({ count: 0 }),
77
+ * });
78
+ *
79
+ * // Must be child component of <LiveShareProvider> or <AzureProvider>
80
+ * export const YourComponent = () => {
81
+ * // Get the root node of the `SharedTree` mapped to "some-unique-key"
82
+ * const { root } = useSharedTree("some-unique-key", config, initialData);
83
+ * // Using "treeChanged" prop makes all children nodes stateful as well.
84
+ * // Use with caution / measure render performance with React dev tools.
85
+ * const { node } = useTreeNode(root, "treeChanged");
86
+ * if (!node) return (<>"Loading"</>);
87
+ * return (
88
+ * <div>
89
+ * <div>Changed: {node.child.count}</div>
90
+ * <button onClick={() => node.increment()}>Insert</button>
91
+ * </div>
92
+ * );
93
+ * }
94
+ * ```
95
+ */
96
+ export function useTreeNode(node, stateChangeType = "nodeChanged") {
97
+ // When we return a proxied node to a developer, it's possible they will pass it back to us in this hook.
98
+ // We can't listen using Tree.on using a proxy node though...
99
+ // Thus, if we are already listening to a node from another instance of this hook, we look for the unproxied node.
100
+ const rawNode = getRawNode(node);
101
+ const [proxyNode, setProxyNode] = useState(rawNode);
102
+ const treeProxyMapRef = useRef(new WeakMap());
103
+ useEffect(() => {
104
+ if (!rawNode)
105
+ return;
106
+ // Set default value
107
+ setProxyNode(rawNode);
108
+ function onNodeChanged() {
109
+ if (!rawNode)
110
+ return;
111
+ const proxyNode = buildProxy(rawNode, treeProxyMapRef.current);
112
+ setProxyNode(proxyNode);
113
+ }
114
+ // Listen to Fluid's base node from their TreeView so Fluid flex nodes continue to work
115
+ const unsubscribeListeners = [
116
+ Tree.on(rawNode, "nodeChanged", onNodeChanged),
117
+ ];
118
+ if (stateChangeType === "treeChanged") {
119
+ // Recursively for all child nodes of this node in the tree
120
+ setUpListenersForNodeChildren(rawNode, rawNode, treeProxyMapRef.current, unsubscribeListeners,
121
+ // TODO: fix typing so casting isn't necessary
122
+ setProxyNode);
123
+ }
124
+ return () => {
125
+ unsubscribeListeners.forEach((unsubscribe) => unsubscribe());
126
+ };
127
+ }, [rawNode, stateChangeType]);
128
+ return {
129
+ node: proxyNode,
130
+ };
131
+ }
132
+ //# sourceMappingURL=useTreeNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTreeNode.js","sourceRoot":"","sources":["../../../src/shared-hooks/useTreeNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA8B,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EACH,UAAU,EACV,UAAU,EACV,6BAA6B,GAChC,MAAM,gCAAgC,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,MAAM,UAAU,WAAW,CACvB,IAAW,EACX,kBAA0C,aAAa;IAEvD,yGAAyG;IACzG,6DAA6D;IAC7D,kHAAkH;IAClH,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAQ,OAAO,CAAC,CAAC;IAC3D,MAAM,eAAe,GAAG,MAAM,CAA8B,IAAI,OAAO,EAAE,CAAC,CAAC;IAE3E,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,oBAAoB;QACpB,YAAY,CAAC,OAAO,CAAC,CAAC;QACtB,SAAS,aAAa;YAClB,IAAI,CAAC,OAAO;gBAAE,OAAO;YAErB,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;YAC/D,YAAY,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QACD,uFAAuF;QACvF,MAAM,oBAAoB,GAAmB;YACzC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,aAAa,CAAC;SACjD,CAAC;QACF,IAAI,eAAe,KAAK,aAAa,EAAE,CAAC;YACpC,2DAA2D;YAC3D,6BAA6B,CACzB,OAAO,EACP,OAAO,EACP,eAAe,CAAC,OAAO,EACvB,oBAAoB;YACpB,8CAA8C;YAC9C,YAAmB,CACtB,CAAC;QACN,CAAC;QACD,OAAO,GAAG,EAAE;YACR,oBAAoB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACjE,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IAE/B,OAAO;QACH,IAAI,EAAE,SAAS;KAClB,CAAC;AACN,CAAC"}
@@ -4,8 +4,8 @@
4
4
  */
5
5
  import React from "react";
6
6
  import { IFluidLoadable } from "@fluidframework/core-interfaces";
7
- import { LoadableObjectClass } from "fluid-framework";
8
- import { ITimerConfig, ILiveEvent, PresenceState } from "@microsoft/live-share";
7
+ import { ITimerConfig, ILiveEvent, LivePresenceData } from "@microsoft/live-share";
8
+ import { SharedObjectKind } from "fluid-framework";
9
9
  /**
10
10
  * Callback to set shared state
11
11
  */
@@ -16,9 +16,9 @@ export type SetSharedStateAction<TState> = (state: TState | ((prevState: TState)
16
16
  export type SetLocalStateAction = React.Dispatch<React.SetStateAction<any>>;
17
17
  /**
18
18
  * Callback for UnregisterDDSSetStateAction.
19
- * <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: LoadableObjectClass<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void
19
+ * <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: SharedObjectKind<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void
20
20
  */
21
- export type RegisterDDSSetStateAction = <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: LoadableObjectClass<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void;
21
+ export type RegisterDDSSetStateAction = <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: SharedObjectKind<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void;
22
22
  /**
23
23
  * Callback for UnregisterDDSSetStateAction.
24
24
  * (uniqueKey: string, componentId: string) => void
@@ -56,9 +56,9 @@ export type DisposeSharedStateAction = () => void;
56
56
  export type SetLiveStateAction<TState = undefined> = (state: TState | ((prevState: TState) => TState)) => Promise<void>;
57
57
  /**
58
58
  * Callback for SendLiveEventAction<TEvent>.
59
- * (event: TEvent) => Promise<void>
59
+ * (event: TEvent, targetClientId?: string) => Promise<void>
60
60
  */
61
- export type SendLiveEventAction<TEvent> = (event: TEvent) => Promise<ILiveEvent<TEvent>>;
61
+ export type SendLiveEventAction<TEvent> = (event: TEvent, targetClientId?: string) => Promise<ILiveEvent<TEvent>>;
62
62
  /**
63
63
  * Callback for OnReceivedLiveEventAction<TEvent>.
64
64
  * (event: TEvent, local: boolean) => void
@@ -68,7 +68,7 @@ export type OnReceivedLiveEventAction<TEvent> = (event: TEvent, local: boolean)
68
68
  * Callback for OnUpdateLivePresenceAction<TData extends object = object>.
69
69
  * (data?: TData | undefined, state?: PresenceState | undefined) => Promise<void>
70
70
  */
71
- export type OnUpdateLivePresenceAction<TData extends object = object> = (data?: TData | undefined, state?: PresenceState | undefined) => Promise<void>;
71
+ export type OnUpdateLivePresenceAction<TData extends LivePresenceData = any> = (data: TData) => Promise<void>;
72
72
  /**
73
73
  * Callback for OnStartTimerAction.
74
74
  * (duration: number) => Promise<void>
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionTypes.d.ts","sourceRoot":"","sources":["../../../src/types/ActionTypes.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionTypes.js","sourceRoot":"","sources":["../../../src/types/ActionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,151 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ /**
24
+ * Like TypeScript's built-in `Iterable` type.
25
+ *
26
+ * @privateRemarks
27
+ * This exists to be unaffected by TypeScript's version and configuration options.
28
+ *
29
+ * @sealed @public
30
+ */
31
+ export interface FluidIterable<T> {
32
+ /**
33
+ * Returns an iterator over the elements in this iterable.
34
+ *
35
+ * @remarks Works like the built-in {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator | \[Symbol.iterator\]} protocol.
36
+ */
37
+ [Symbol.iterator](): FluidIterableIterator<T>;
38
+ }
39
+ /**
40
+ * Like TypeScript's built-in iterable iterator type.
41
+ *
42
+ * @privateRemarks
43
+ * The done branch uses `any` rather than `undefined` to match TypeScript's built-in IteratorReturnResult, which defaults to any for the same reason.
44
+ * Using `undefined` causes TypeScript to include it in type inference at call sites like `Array.from` which would infer `T | undefined` instead of `T`.
45
+ * The done value is rarely meaningful to callers since values are mainly consumed when done is false.
46
+ * Thus `any` is not particularly harmful here, and the unsafety is worth it as
47
+ * it interacts better with the existing TypeScript `IteratorResult` interfaces where `TReturn` defaults to any.
48
+ *
49
+ * @sealed @public
50
+ */
51
+ export interface FluidIterableIterator<T> extends FluidIterable<T> {
52
+ /**
53
+ * Returns the next element in the iteration sequence.
54
+ *
55
+ * @remarks Works like the built-in {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol | Iterator.next} method.
56
+ * When there are remaining elements, returns `\{ value: T; done?: false \}`.
57
+ * When the iteration is complete, returns `\{ value: any; done: true \}`.
58
+ */
59
+ next(): {
60
+ value: T;
61
+ done?: false;
62
+ } | {
63
+ value: any;
64
+ done: true;
65
+ };
66
+ }
67
+ /**
68
+ * Like TypeScript's built in `ReadonlyMap` type.
69
+ * Unlike the built in `ReadonlyMap`, this interface includes Symbol.toStringTag.
70
+ *
71
+ * @privateRemarks
72
+ * This exists so that Fluid has a `ReadonlyMap` type which is unaffected by TypeScript's version and configuration options,
73
+ * and safe to implement without being broken by changes to TypeScript's default ReadonlyMap type.
74
+ * All behavior exposed through this interface should be compatible with the corresponding behavior of built in ReadonlyMaps,
75
+ * but it may lack some of the newer APIs,
76
+ * and might express the type slightly different from how TypeScript does in its `ReadonlyMap` type.
77
+ *
78
+ * @sealed @public
79
+ */
80
+ export interface FluidReadonlyMap<K, V> {
81
+ /**
82
+ * Returns an iterable of entries in the map.
83
+ */
84
+ [Symbol.iterator](): FluidIterableIterator<[K, V]>;
85
+ /**
86
+ * The number of entries in the map.
87
+ */
88
+ readonly size: number;
89
+ /**
90
+ * Returns an iterable of key, value pairs for every entry in the map.
91
+ */
92
+ entries(): FluidIterableIterator<[K, V]>;
93
+ /**
94
+ * Executes the provided function once per each key/value pair in the map.
95
+ */
96
+ forEach(callbackfn: (value: V, key: K, map: FluidReadonlyMap<K, V>) => void, thisArg?: any): void;
97
+ /**
98
+ * Returns the value associated to the specified key, or undefined if there is none.
99
+ */
100
+ get(key: K): V | undefined;
101
+ /**
102
+ * Returns a boolean indicating whether an element with the specified key exists or not.
103
+ */
104
+ has(key: K): boolean;
105
+ /**
106
+ * Returns an iterable of keys in the map.
107
+ */
108
+ keys(): FluidIterableIterator<K>;
109
+ /**
110
+ * Returns an iterable of values in the map.
111
+ */
112
+ values(): FluidIterableIterator<V>;
113
+ /**
114
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag | Symbol.toStringTag}
115
+ */
116
+ readonly [Symbol.toStringTag]: string;
117
+ }
118
+ /**
119
+ * Like TypeScript's built in `Map` type.
120
+ *
121
+ * @privateRemarks
122
+ * This exists so that Fluid has a `Map` type which is unaffected by TypeScript's version and configuration options,
123
+ * and safe to implement without being broken by changes to TypeScript's default Map type.
124
+ * All behavior exposed through this interface should be compatible with the corresponding behavior of JavaScript Maps,
125
+ * but it may lack some of the newer APIs,
126
+ * and might express the type slightly different from how TypeScript does in its `Map` type.
127
+ *
128
+ * @sealed @public
129
+ */
130
+ export interface FluidMap<K, V> extends FluidReadonlyMap<K, V> {
131
+ /**
132
+ * Removes the specified element from the map by its key.
133
+ *
134
+ * @remarks
135
+ * Unlike the built-in `Map.delete`, this returns `void` instead of a boolean.
136
+ * This is intentional: in a distributed system, the caller often cannot reliably know
137
+ * whether the element existed at the time of deletion.
138
+ * Subtypes may override this to return a boolean if appropriate.
139
+ */
140
+ delete(key: K): void;
141
+ /**
142
+ * Executes the provided function once per each key/value pair in the map.
143
+ */
144
+ forEach(callbackfn: (value: V, key: K, map: FluidMap<K, V>) => void, thisArg?: any): void;
145
+ /**
146
+ * Adds a new element with a specified key and value to the map.
147
+ * If an element with the same key already exists, the element will be updated.
148
+ */
149
+ set(key: K, value: V): void;
150
+ }
151
+ //# sourceMappingURL=FluidMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FluidMap.d.ts","sourceRoot":"","sources":["../../../src/types/FluidMap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC5B;;;;OAIG;IACH,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAC9D;;;;;;OAMG;IACH,IAAI,IAAI;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,IAAI,CAAC,EAAE,KAAK,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC;CACnE;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IAClC;;OAEG;IACH,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEnD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,IAAI,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEzC;;OAEG;IACH,OAAO,CACH,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAEnE,OAAO,CAAC,EAAE,GAAG,GACd,IAAI,CAAC;IAER;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAE3B;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IAErB;;OAEG;IACH,IAAI,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAEjC;;OAEG;IACH,MAAM,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CACzC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1D;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;IAErB;;OAEG;IACH,OAAO,CACH,UAAU,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,EAE3D,OAAO,CAAC,EAAE,GAAG,GACd,IAAI,CAAC;IAER;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CAC/B"}
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ export {};
24
+ //# sourceMappingURL=FluidMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FluidMap.js","sourceRoot":"","sources":["../../../src/types/FluidMap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG"}
@@ -0,0 +1,56 @@
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 { CanvasReferencePoint, IBrush, IPoint, InkingTool, LiveCanvasTreeNode } from "@microsoft/live-share-canvas";
7
+ export type SharedMapInitialData<T> = Map<string, T> | readonly (readonly [string, T])[] | {
8
+ [key: string]: T;
9
+ } | undefined;
10
+ /**
11
+ * Optional props for {@link useLiveCanvas}
12
+ */
13
+ export interface IUseLiveCanvasOptionalProps {
14
+ /**
15
+ * Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
16
+ */
17
+ active?: boolean;
18
+ /**
19
+ * Optional. Stateful enum for what tool to use in the `InkingManager`.
20
+ */
21
+ tool?: InkingTool;
22
+ /**
23
+ * Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
24
+ */
25
+ lineBrush?: IBrush;
26
+ /**
27
+ * Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
28
+ */
29
+ offset?: IPoint;
30
+ /**
31
+ * Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
32
+ */
33
+ scale?: number;
34
+ /**
35
+ * Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
36
+ */
37
+ referencePoint?: CanvasReferencePoint;
38
+ /**
39
+ * Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
40
+ */
41
+ isCursorShared?: boolean;
42
+ /**
43
+ * Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
44
+ */
45
+ localUserPictureUrl?: string;
46
+ /**
47
+ * Optional. A Fluid `LiveCanvasTree` `TreeNode` instance to swap out the underlying storage solution for strokes.
48
+ * To learn more, look at Fluid's [SharedTree](https://fluidframework.com/docs/data-structures/tree/) documentation.
49
+ */
50
+ node?: LiveCanvasTreeNode;
51
+ /**
52
+ * Optional. The user roles that are allowed to start/stop/pause the timer.
53
+ */
54
+ allowedRoles?: UserMeetingRole[];
55
+ }
56
+ //# sourceMappingURL=PropTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropTypes.d.ts","sourceRoot":"","sources":["../../../src/types/PropTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACH,oBAAoB,EACpB,MAAM,EACN,MAAM,EACN,UAAU,EACV,kBAAkB,EACrB,MAAM,8BAA8B,CAAC;AAGtC,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAC5B,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GACd,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,GACjC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;CAAE,GACpB,SAAS,CAAC;AAEhB;;GAEG;AACH,MAAM,WAAW,2BAA2B;IACxC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;CACpC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropTypes.js","sourceRoot":"","sources":["../../../src/types/PropTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG"}