@microsoft/live-share-react 1.0.0-preview.12 → 1.0.0-preview.14

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 (90) hide show
  1. package/README.md +3 -3
  2. package/bin/index.d.ts +6 -6
  3. package/bin/index.js +6 -6
  4. package/bin/interfaces/LiveInterfaceExtensions.d.ts +8 -8
  5. package/bin/interfaces/LiveInterfaceExtensions.js +5 -5
  6. package/bin/interfaces/index.d.ts +1 -1
  7. package/bin/interfaces/index.js +1 -1
  8. package/bin/internal-hooks/index.d.ts +1 -1
  9. package/bin/internal-hooks/index.js +1 -1
  10. package/bin/internal-hooks/useSharedStateRegistry.d.ts +30 -30
  11. package/bin/internal-hooks/useSharedStateRegistry.d.ts.map +1 -1
  12. package/bin/internal-hooks/useSharedStateRegistry.js +101 -99
  13. package/bin/internal-hooks/useSharedStateRegistry.js.map +1 -1
  14. package/bin/live-hooks/index.d.ts +6 -6
  15. package/bin/live-hooks/index.js +6 -6
  16. package/bin/live-hooks/useLiveCanvas.d.ts +27 -27
  17. package/bin/live-hooks/useLiveCanvas.js +158 -158
  18. package/bin/live-hooks/useLiveEvent.d.ts +21 -21
  19. package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
  20. package/bin/live-hooks/useLiveEvent.js +92 -85
  21. package/bin/live-hooks/useLiveEvent.js.map +1 -1
  22. package/bin/live-hooks/useLivePresence.d.ts +25 -25
  23. package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
  24. package/bin/live-hooks/useLivePresence.js +101 -92
  25. package/bin/live-hooks/useLivePresence.js.map +1 -1
  26. package/bin/live-hooks/useLiveState.d.ts +19 -18
  27. package/bin/live-hooks/useLiveState.d.ts.map +1 -1
  28. package/bin/live-hooks/useLiveState.js +72 -60
  29. package/bin/live-hooks/useLiveState.js.map +1 -1
  30. package/bin/live-hooks/useLiveTimer.d.ts +7 -7
  31. package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
  32. package/bin/live-hooks/useLiveTimer.js +144 -131
  33. package/bin/live-hooks/useLiveTimer.js.map +1 -1
  34. package/bin/live-hooks/useMediaSynchronizer.d.ts +22 -22
  35. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -1
  36. package/bin/live-hooks/useMediaSynchronizer.js +184 -161
  37. package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
  38. package/bin/providers/AzureProvider.d.ts +33 -33
  39. package/bin/providers/AzureProvider.d.ts.map +1 -1
  40. package/bin/providers/AzureProvider.js +101 -101
  41. package/bin/providers/AzureProvider.js.map +1 -1
  42. package/bin/providers/LiveShareProvider.d.ts +62 -41
  43. package/bin/providers/LiveShareProvider.d.ts.map +1 -1
  44. package/bin/providers/LiveShareProvider.js +68 -65
  45. package/bin/providers/LiveShareProvider.js.map +1 -1
  46. package/bin/providers/index.d.ts +2 -2
  47. package/bin/providers/index.js +2 -2
  48. package/bin/shared-hooks/index.d.ts +3 -3
  49. package/bin/shared-hooks/index.js +3 -3
  50. package/bin/shared-hooks/useDynamicDDS.d.ts +18 -18
  51. package/bin/shared-hooks/useDynamicDDS.d.ts.map +1 -1
  52. package/bin/shared-hooks/useDynamicDDS.js +67 -67
  53. package/bin/shared-hooks/useDynamicDDS.js.map +1 -1
  54. package/bin/shared-hooks/useSharedMap.d.ts +21 -21
  55. package/bin/shared-hooks/useSharedMap.d.ts.map +1 -1
  56. package/bin/shared-hooks/useSharedMap.js +105 -105
  57. package/bin/shared-hooks/useSharedMap.js.map +1 -1
  58. package/bin/shared-hooks/useSharedState.d.ts +20 -20
  59. package/bin/shared-hooks/useSharedState.d.ts.map +1 -1
  60. package/bin/shared-hooks/useSharedState.js +66 -62
  61. package/bin/shared-hooks/useSharedState.js.map +1 -1
  62. package/bin/types/ActionTypes.d.ts +105 -29
  63. package/bin/types/ActionTypes.d.ts.map +1 -1
  64. package/bin/types/ActionTypes.js +5 -5
  65. package/bin/types/PropTypes.d.ts +7 -7
  66. package/bin/types/PropTypes.d.ts.map +1 -1
  67. package/bin/types/PropTypes.js +5 -5
  68. package/bin/types/ResultTypes.d.ts +174 -162
  69. package/bin/types/ResultTypes.d.ts.map +1 -1
  70. package/bin/types/ResultTypes.js +5 -5
  71. package/bin/types/index.d.ts +3 -3
  72. package/bin/types/index.js +3 -3
  73. package/bin/utils/index.d.ts +1 -1
  74. package/bin/utils/index.js +1 -1
  75. package/bin/utils/type-check.d.ts +14 -14
  76. package/bin/utils/type-check.js +53 -53
  77. package/package.json +13 -13
  78. package/src/internal-hooks/useSharedStateRegistry.ts +6 -5
  79. package/src/live-hooks/useLiveEvent.ts +14 -18
  80. package/src/live-hooks/useLivePresence.ts +13 -7
  81. package/src/live-hooks/useLiveState.ts +8 -6
  82. package/src/live-hooks/useLiveTimer.ts +21 -18
  83. package/src/live-hooks/useMediaSynchronizer.ts +37 -27
  84. package/src/providers/AzureProvider.tsx +2 -7
  85. package/src/providers/LiveShareProvider.tsx +45 -15
  86. package/src/shared-hooks/useDynamicDDS.ts +15 -8
  87. package/src/shared-hooks/useSharedMap.ts +17 -10
  88. package/src/shared-hooks/useSharedState.ts +5 -1
  89. package/src/types/ActionTypes.ts +89 -11
  90. package/src/types/ResultTypes.ts +22 -8
package/README.md CHANGED
@@ -172,7 +172,7 @@ export function CardList() {
172
172
 
173
173
  ### useLivePresence
174
174
 
175
- Presence makes it easy to track which users are currently in the session and assign custom data to them. Unlike other hooks, `useLivePresence` has a default ID set for you, but you can override it with your own if you'd like.
175
+ Presence makes it easy to track which users are currently in the session and assign custom data to them.
176
176
 
177
177
  ```javascript
178
178
  import { useLivePresence } from "@microsoft/live-share-react";
@@ -180,7 +180,7 @@ import { PresenceState } from "@microsoft/live-share";
180
180
 
181
181
  export function OnlineUsers() {
182
182
  const { localUser, allUsers, updatePresence } = useLivePresence(
183
- "CUSTOM-USER-ID", // optional user id
183
+ "UNIQUE-PRESENCE-KEY", // required unique key for presence
184
184
  { favoriteColor: "red" } // optional custom data object
185
185
  );
186
186
  return (
@@ -584,7 +584,7 @@ The Live Share SDK contains dependencies for [@microsoft/teams-js](https://www.n
584
584
 
585
585
  | @microsoft/live-share | @microsoft/teams-js | fluid-framework | @microsoft/live-share-\* | @fluidframework/azure-client | @microsoft/TeamsFx | @microsoft/TeamsFx-react |
586
586
  | --------------------- | -------------------- | --------------- | -------------------------- | ---------------------------- | ------------------------------- | ------------------------------- |
587
- | 1.0.0-preview.12 | ^2.11.0 | ^1.2.3 | 1.0.0-preview.12 (optional) | ^1.0.0 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
587
+ | 1.0.0-preview.14 | ^2.11.0 | ^1.2.3 | 1.0.0-preview.14 (optional) | ^1.0.0 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
588
588
  | 1.0.0-preview.10 | ^2.10.1 | ~1.2.3 | 1.0.0-preview.10 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
589
589
  | 1.0.0-preview.8 | ^2.5.0 | ~1.2.3 | 1.0.0-preview.10 (optional) | ~1.0.2 (optional) | ^2.5.0 (optional) | ^2.5.0 (optional) |
590
590
  | 1.0.0-preview.3 | 2.0.0-experimental.1 | ~1.2.3 | 1.0.0-preview.3 (optional) | ~1.0.2 (optional) | 2.0.0-experimental.0 (optional) | 2.0.0-experimental.0 (optional) |
package/bin/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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";
2
+ export * from "./shared-hooks";
3
+ export * from "./live-hooks";
4
+ export * from "./types";
5
+ export * from "./providers";
6
+ export * from "./interfaces";
7
7
  //# sourceMappingURL=index.d.ts.map
package/bin/index.js CHANGED
@@ -1,7 +1,7 @@
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";
2
+ export * from "./shared-hooks";
3
+ export * from "./live-hooks";
4
+ export * from "./types";
5
+ export * from "./providers";
6
+ export * from "./interfaces";
7
7
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,9 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- export interface IReceiveLiveEvent<TEvent extends object = object> {
6
- event: TEvent;
7
- local: boolean;
8
- }
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ export interface IReceiveLiveEvent<TEvent extends object = object> {
6
+ event: TEvent;
7
+ local: boolean;
8
+ }
9
9
  //# sourceMappingURL=LiveInterfaceExtensions.d.ts.map
@@ -1,6 +1,6 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- export {};
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ export {};
6
6
  //# sourceMappingURL=LiveInterfaceExtensions.js.map
@@ -1,2 +1,2 @@
1
- export * from "./LiveInterfaceExtensions";
1
+ export * from "./LiveInterfaceExtensions";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- export * from "./LiveInterfaceExtensions";
1
+ export * from "./LiveInterfaceExtensions";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- export * from "./useSharedStateRegistry";
1
+ export * from "./useSharedStateRegistry";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- export * from "./useSharedStateRegistry";
1
+ export * from "./useSharedStateRegistry";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,31 +1,31 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- import { DeleteSharedStateAction, IAzureContainerResults, RegisterSharedSetStateAction, UnregisterSharedSetStateAction, UpdateSharedStateAction } from "../types";
6
- export interface ISharedStateRegistryResponse {
7
- /**
8
- * Register a set state action callback
9
- */
10
- registerSharedSetStateAction: RegisterSharedSetStateAction;
11
- /**
12
- * Unregister a set state action callback
13
- */
14
- unregisterSharedSetStateAction: UnregisterSharedSetStateAction;
15
- /**
16
- * Setter callback to update the shared state
17
- */
18
- updateSharedState: UpdateSharedStateAction;
19
- /**
20
- * Delete a shared state value
21
- */
22
- deleteSharedState: DeleteSharedStateAction;
23
- }
24
- /**
25
- * Hook used internally to keep track of the SharedSetStateActionMap for each unique key. It sets state values for provided keys and updates components listening to the values.
26
- *
27
- * @param results IAzureContainerResults response or undefined
28
- * @returns ISharedStateRegistryResponse object
29
- */
30
- export declare const useSharedStateRegistry: (results: IAzureContainerResults | undefined) => ISharedStateRegistryResponse;
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { DeleteSharedStateAction, IAzureContainerResults, RegisterSharedSetStateAction, UnregisterSharedSetStateAction, UpdateSharedStateAction } from "../types";
6
+ export interface ISharedStateRegistryResponse {
7
+ /**
8
+ * Register a set state action callback
9
+ */
10
+ registerSharedSetStateAction: RegisterSharedSetStateAction;
11
+ /**
12
+ * Unregister a set state action callback
13
+ */
14
+ unregisterSharedSetStateAction: UnregisterSharedSetStateAction;
15
+ /**
16
+ * Setter callback to update the shared state
17
+ */
18
+ updateSharedState: UpdateSharedStateAction;
19
+ /**
20
+ * Delete a shared state value
21
+ */
22
+ deleteSharedState: DeleteSharedStateAction;
23
+ }
24
+ /**
25
+ * Hook used internally to keep track of the SharedSetStateActionMap for each unique key. It sets state values for provided keys and updates components listening to the values.
26
+ *
27
+ * @param results IAzureContainerResults response or undefined
28
+ * @returns ISharedStateRegistryResponse object
29
+ */
30
+ export declare const useSharedStateRegistry: (results: IAzureContainerResults | undefined) => ISharedStateRegistryResponse;
31
31
  //# sourceMappingURL=useSharedStateRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSharedStateRegistry.d.ts","sourceRoot":"","sources":["../../src/internal-hooks/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,EAE5B,8BAA8B,EAC9B,uBAAuB,EAC1B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,4BAA4B,EAAE,4BAA4B,CAAC;IAC3D;;OAEG;IACH,8BAA8B,EAAE,8BAA8B,CAAC;IAC/D;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;CAC9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,YACtB,sBAAsB,GAAG,SAAS,KAC5C,4BAuHF,CAAC"}
1
+ {"version":3,"file":"useSharedStateRegistry.d.ts","sourceRoot":"","sources":["../../src/internal-hooks/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,EAE5B,8BAA8B,EAC9B,uBAAuB,EAC1B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,4BAA4B;IACzC;;OAEG;IACH,4BAA4B,EAAE,4BAA4B,CAAC;IAC3D;;OAEG;IACH,8BAA8B,EAAE,8BAA8B,CAAC;IAC/D;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C;;OAEG;IACH,iBAAiB,EAAE,uBAAuB,CAAC;CAC9C;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,YACtB,sBAAsB,GAAG,SAAS,KAC5C,4BAwHF,CAAC"}
@@ -1,100 +1,102 @@
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
- /**
7
- * Hook used internally to keep track of the SharedSetStateActionMap for each unique key. It sets state values for provided keys and updates components listening to the values.
8
- *
9
- * @param results IAzureContainerResults response or undefined
10
- * @returns ISharedStateRegistryResponse object
11
- */
12
- export const useSharedStateRegistry = (results) => {
13
- const registeredSharedSetStateActionMapRef = React.useRef(new Map());
14
- /**
15
- * @see ISharedStateRegistryResponse.registerSharedSetStateAction
16
- */
17
- const registerSharedSetStateAction = React.useCallback((uniqueKey, componentId, setLocalStateAction) => {
18
- let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
19
- if (actionsMap) {
20
- if (!actionsMap.has(componentId)) {
21
- actionsMap.set(componentId, setLocalStateAction);
22
- }
23
- }
24
- else {
25
- actionsMap = new Map();
26
- actionsMap.set(componentId, setLocalStateAction);
27
- registeredSharedSetStateActionMapRef.current.set(uniqueKey, actionsMap);
28
- }
29
- // Set initial values, if known
30
- const stateMap = results === null || results === void 0 ? void 0 : results.container.initialObjects.TURBO_STATE_MAP;
31
- const initialValue = stateMap === null || stateMap === void 0 ? void 0 : stateMap.get(uniqueKey);
32
- if (initialValue) {
33
- setLocalStateAction(initialValue);
34
- }
35
- }, [results]);
36
- /**
37
- * @see ISharedStateRegistryResponse.unregisterSharedSetStateAction
38
- */
39
- const unregisterSharedSetStateAction = React.useCallback((uniqueKey, componentId) => {
40
- let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
41
- if (actionsMap === null || actionsMap === void 0 ? void 0 : actionsMap.has(componentId)) {
42
- actionsMap.delete(componentId);
43
- }
44
- }, []);
45
- /**
46
- * @see ISharedStateRegistryResponse.updateSharedState
47
- */
48
- const updateSharedState = React.useCallback((uniqueKey, value) => {
49
- if (!results)
50
- return;
51
- const { container } = results;
52
- const stateMap = container.initialObjects.TURBO_STATE_MAP;
53
- stateMap.set(uniqueKey, value);
54
- }, [results]);
55
- /**
56
- * @see ISharedStateRegistryResponse.deleteSharedState
57
- */
58
- const deleteSharedState = React.useCallback((uniqueKey) => {
59
- if (!results)
60
- return;
61
- const { container } = results;
62
- let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
63
- actionsMap === null || actionsMap === void 0 ? void 0 : actionsMap.clear();
64
- const stateMap = container.initialObjects.TURBO_STATE_MAP;
65
- stateMap.delete(uniqueKey);
66
- }, [results]);
67
- React.useEffect(() => {
68
- if (!results)
69
- return;
70
- const { container } = results;
71
- const stateMap = container.initialObjects.TURBO_STATE_MAP;
72
- const valueChangedListener = (changed) => {
73
- if (registeredSharedSetStateActionMapRef.current.has(changed.key)) {
74
- const value = stateMap.get(changed.key);
75
- const actionMap = registeredSharedSetStateActionMapRef.current.get(changed.key);
76
- actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
77
- setLocalStateHandler(value);
78
- });
79
- }
80
- };
81
- stateMap.on("valueChanged", valueChangedListener);
82
- // Set initial values
83
- stateMap.forEach((value, key) => {
84
- const actionMap = registeredSharedSetStateActionMapRef.current.get(key);
85
- actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
86
- setLocalStateHandler(value);
87
- });
88
- });
89
- return () => {
90
- stateMap.off("valueChanged", valueChangedListener);
91
- };
92
- }, [results]);
93
- return {
94
- registerSharedSetStateAction,
95
- unregisterSharedSetStateAction,
96
- updateSharedState,
97
- deleteSharedState,
98
- };
99
- };
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
+ /**
7
+ * Hook used internally to keep track of the SharedSetStateActionMap for each unique key. It sets state values for provided keys and updates components listening to the values.
8
+ *
9
+ * @param results IAzureContainerResults response or undefined
10
+ * @returns ISharedStateRegistryResponse object
11
+ */
12
+ export const useSharedStateRegistry = (results) => {
13
+ const registeredSharedSetStateActionMapRef = React.useRef(new Map());
14
+ /**
15
+ * @see ISharedStateRegistryResponse.registerSharedSetStateAction
16
+ */
17
+ const registerSharedSetStateAction = React.useCallback((uniqueKey, componentId, setLocalStateAction) => {
18
+ let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
19
+ if (actionsMap) {
20
+ if (!actionsMap.has(componentId)) {
21
+ actionsMap.set(componentId, setLocalStateAction);
22
+ }
23
+ }
24
+ else {
25
+ actionsMap = new Map();
26
+ actionsMap.set(componentId, setLocalStateAction);
27
+ registeredSharedSetStateActionMapRef.current.set(uniqueKey, actionsMap);
28
+ }
29
+ // Set initial values, if known
30
+ const stateMap = results === null || results === void 0 ? void 0 : results.container.initialObjects.TURBO_STATE_MAP;
31
+ const initialValue = stateMap === null || stateMap === void 0 ? void 0 : stateMap.get(uniqueKey);
32
+ if (initialValue) {
33
+ setLocalStateAction(initialValue);
34
+ }
35
+ }, [results]);
36
+ /**
37
+ * @see ISharedStateRegistryResponse.unregisterSharedSetStateAction
38
+ */
39
+ const unregisterSharedSetStateAction = React.useCallback((uniqueKey, componentId) => {
40
+ let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
41
+ if (actionsMap === null || actionsMap === void 0 ? void 0 : actionsMap.has(componentId)) {
42
+ actionsMap.delete(componentId);
43
+ }
44
+ }, []);
45
+ /**
46
+ * @see ISharedStateRegistryResponse.updateSharedState
47
+ */
48
+ const updateSharedState = React.useCallback((uniqueKey, value) => {
49
+ if (!results)
50
+ return;
51
+ const { container } = results;
52
+ const stateMap = container.initialObjects
53
+ .TURBO_STATE_MAP;
54
+ stateMap.set(uniqueKey, value);
55
+ }, [results]);
56
+ /**
57
+ * @see ISharedStateRegistryResponse.deleteSharedState
58
+ */
59
+ const deleteSharedState = React.useCallback((uniqueKey) => {
60
+ if (!results)
61
+ return;
62
+ const { container } = results;
63
+ let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
64
+ actionsMap === null || actionsMap === void 0 ? void 0 : actionsMap.clear();
65
+ const stateMap = container.initialObjects
66
+ .TURBO_STATE_MAP;
67
+ stateMap.delete(uniqueKey);
68
+ }, [results]);
69
+ React.useEffect(() => {
70
+ if (!results)
71
+ return;
72
+ const { container } = results;
73
+ const stateMap = container.initialObjects.TURBO_STATE_MAP;
74
+ const valueChangedListener = (changed) => {
75
+ if (registeredSharedSetStateActionMapRef.current.has(changed.key)) {
76
+ const value = stateMap.get(changed.key);
77
+ const actionMap = registeredSharedSetStateActionMapRef.current.get(changed.key);
78
+ actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
79
+ setLocalStateHandler(value);
80
+ });
81
+ }
82
+ };
83
+ stateMap.on("valueChanged", valueChangedListener);
84
+ // Set initial values
85
+ stateMap.forEach((value, key) => {
86
+ const actionMap = registeredSharedSetStateActionMapRef.current.get(key);
87
+ actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
88
+ setLocalStateHandler(value);
89
+ });
90
+ });
91
+ return () => {
92
+ stateMap.off("valueChanged", valueChangedListener);
93
+ };
94
+ }, [results]);
95
+ return {
96
+ registerSharedSetStateAction,
97
+ unregisterSharedSetStateAction,
98
+ updateSharedState,
99
+ deleteSharedState,
100
+ };
101
+ };
100
102
  //# sourceMappingURL=useSharedStateRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSharedStateRegistry.js","sourceRoot":"","sources":["../../src/internal-hooks/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AA6B1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,OAA2C,EACf,EAAE;IAC9B,MAAM,oCAAoC,GAAG,KAAK,CAAC,MAAM,CAEvD,IAAI,GAAG,EAAE,CAAC,CAAC;IAEb;;OAEG;IACH,MAAM,4BAA4B,GAAG,KAAK,CAAC,WAAW,CAClD,CACI,SAAiB,EACjB,WAAmB,EACnB,mBAAwC,EAC1C,EAAE;QACA,IAAI,UAAU,GACV,oCAAoC,CAAC,OAAO,CA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EAAE;oBACxC,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC;QACF,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;QAClD,qBAAqB;QACrB,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,GAAW,EAAE,EAAE;YACzC,MAAM,SAAS,GACX,oCAAoC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC1D,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAC,CAAC,oBAAoB,EAAE,EAAE;gBACxC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;QACvD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO;QACH,4BAA4B;QAC5B,8BAA8B;QAC9B,iBAAiB;QACjB,iBAAiB;KACpB,CAAC;AACN,CAAC,CAAC"}
1
+ {"version":3,"file":"useSharedStateRegistry.js","sourceRoot":"","sources":["../../src/internal-hooks/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AA6B1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,OAA2C,EACf,EAAE;IAC9B,MAAM,oCAAoC,GAAG,KAAK,CAAC,MAAM,CAEvD,IAAI,GAAG,EAAE,CAAC,CAAC;IAEb;;OAEG;IACH,MAAM,4BAA4B,GAAG,KAAK,CAAC,WAAW,CAClD,CACI,SAAiB,EACjB,WAAmB,EACnB,mBAAwC,EAC1C,EAAE;QACA,IAAI,UAAU,GACV,oCAAoC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC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AC,KAAK,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC;QACF,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;QAClD,qBAAqB;QACrB,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,GAAW,EAAE,EAAE;YACzC,MAAM,SAAS,GACX,oCAAoC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC1D,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,CAAC,CAAC,oBAAoB,EAAE,EAAE;gBACxC,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;QACvD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO;QACH,4BAA4B;QAC5B,8BAA8B;QAC9B,iBAAiB;QACjB,iBAAiB;KACpB,CAAC;AACN,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
- export * from "./useLivePresence";
2
- export * from "./useLiveState";
3
- export * from "./useMediaSynchronizer";
4
- export * from "./useLiveEvent";
5
- export * from "./useLiveCanvas";
6
- export * from "./useLiveTimer";
1
+ export * from "./useLivePresence";
2
+ export * from "./useLiveState";
3
+ export * from "./useMediaSynchronizer";
4
+ export * from "./useLiveEvent";
5
+ export * from "./useLiveCanvas";
6
+ export * from "./useLiveTimer";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,7 @@
1
- export * from "./useLivePresence";
2
- export * from "./useLiveState";
3
- export * from "./useMediaSynchronizer";
4
- export * from "./useLiveEvent";
5
- export * from "./useLiveCanvas";
6
- export * from "./useLiveTimer";
1
+ export * from "./useLivePresence";
2
+ export * from "./useLiveState";
3
+ export * from "./useMediaSynchronizer";
4
+ export * from "./useLiveEvent";
5
+ export * from "./useLiveCanvas";
6
+ export * from "./useLiveTimer";
7
7
  //# sourceMappingURL=index.js.map
@@ -1,28 +1,28 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- import { CanvasReferencePoint, IBrush, InkingTool, IPoint } from "@microsoft/live-share-canvas";
6
- import React from "react";
7
- import { IUseLiveCanvasResults } from "../types";
8
- /**
9
- * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
10
- *
11
- * @remarks
12
- * Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
13
- * a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
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 active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
18
- * @param tool Optional. Stateful enum for what tool to use in the `InkingManager`.
19
- * @param lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
20
- * @param offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
21
- * @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
22
- * @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
23
- * @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
24
- * @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
25
- * @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
26
- */
27
- export declare function useLiveCanvas(uniqueKey: string, canvasElementRef: React.RefObject<HTMLElement | null> | string, active?: boolean, tool?: InkingTool, lineBrush?: IBrush, offset?: IPoint, scale?: number, referencePoint?: CanvasReferencePoint, isCursorShared?: boolean, localUserPictureUrl?: string): IUseLiveCanvasResults;
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the Microsoft Live Share SDK License.
4
+ */
5
+ import { CanvasReferencePoint, IBrush, InkingTool, IPoint } from "@microsoft/live-share-canvas";
6
+ import React from "react";
7
+ import { IUseLiveCanvasResults } from "../types";
8
+ /**
9
+ * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
10
+ *
11
+ * @remarks
12
+ * Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
13
+ * a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
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 active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
18
+ * @param tool Optional. Stateful enum for what tool to use in the `InkingManager`.
19
+ * @param lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
20
+ * @param offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
21
+ * @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
22
+ * @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
23
+ * @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
24
+ * @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
25
+ * @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
26
+ */
27
+ export declare function useLiveCanvas(uniqueKey: string, canvasElementRef: React.RefObject<HTMLElement | null> | string, active?: boolean, tool?: InkingTool, lineBrush?: IBrush, offset?: IPoint, scale?: number, referencePoint?: CanvasReferencePoint, isCursorShared?: boolean, localUserPictureUrl?: string): IUseLiveCanvasResults;
28
28
  //# sourceMappingURL=useLiveCanvas.d.ts.map