@microsoft/live-share-react 1.4.0-preview.0 → 1.4.1-preview.0
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.
- package/bin/cjs/index.d.ts +7 -0
- package/bin/cjs/index.d.ts.map +1 -0
- package/bin/cjs/index.js +23 -0
- package/bin/cjs/index.js.map +1 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts +26 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.js +7 -0
- package/bin/cjs/interfaces/LiveInterfaceExtensions.js.map +1 -0
- package/bin/cjs/interfaces/index.d.ts +2 -0
- package/bin/cjs/interfaces/index.d.ts.map +1 -0
- package/bin/cjs/interfaces/index.js +18 -0
- package/bin/cjs/interfaces/index.js.map +1 -0
- package/bin/cjs/internal/errors.d.ts +41 -0
- package/bin/cjs/internal/errors.d.ts.map +1 -0
- package/bin/cjs/internal/errors.js +48 -0
- package/bin/cjs/internal/errors.js.map +1 -0
- package/bin/cjs/internal/index.d.ts +3 -0
- package/bin/cjs/internal/index.d.ts.map +1 -0
- package/bin/cjs/internal/index.js +19 -0
- package/bin/cjs/internal/index.js.map +1 -0
- package/bin/cjs/internal/type-guards.d.ts +11 -0
- package/bin/cjs/internal/type-guards.d.ts.map +1 -0
- package/bin/cjs/internal/type-guards.js +24 -0
- package/bin/cjs/internal/type-guards.js.map +1 -0
- package/bin/cjs/live-hooks/index.d.ts +8 -0
- package/bin/cjs/live-hooks/index.d.ts.map +1 -0
- package/bin/cjs/live-hooks/index.js +24 -0
- package/bin/cjs/live-hooks/index.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveCanvas.d.ts +80 -0
- package/bin/cjs/live-hooks/useLiveCanvas.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveCanvas.js +244 -0
- package/bin/cjs/live-hooks/useLiveCanvas.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveEvent.d.ts +59 -0
- package/bin/cjs/live-hooks/useLiveEvent.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveEvent.js +150 -0
- package/bin/cjs/live-hooks/useLiveEvent.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.d.ts +163 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.js +360 -0
- package/bin/cjs/live-hooks/useLiveFollowMode.js.map +1 -0
- package/bin/cjs/live-hooks/useLivePresence.d.ts +76 -0
- package/bin/cjs/live-hooks/useLivePresence.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLivePresence.js +170 -0
- package/bin/cjs/live-hooks/useLivePresence.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveState.d.ts +66 -0
- package/bin/cjs/live-hooks/useLiveState.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveState.js +134 -0
- package/bin/cjs/live-hooks/useLiveState.js.map +1 -0
- package/bin/cjs/live-hooks/useLiveTimer.d.ts +80 -0
- package/bin/cjs/live-hooks/useLiveTimer.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useLiveTimer.js +233 -0
- package/bin/cjs/live-hooks/useLiveTimer.js.map +1 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts +86 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.js +301 -0
- package/bin/cjs/live-hooks/useMediaSynchronizer.js.map +1 -0
- package/bin/cjs/package.json +1 -0
- package/bin/cjs/providers/AzureProvider.d.ts +113 -0
- package/bin/cjs/providers/AzureProvider.d.ts.map +1 -0
- package/bin/cjs/providers/AzureProvider.js +127 -0
- package/bin/cjs/providers/AzureProvider.js.map +1 -0
- package/bin/cjs/providers/LiveShareProvider.d.ts +193 -0
- package/bin/cjs/providers/LiveShareProvider.d.ts.map +1 -0
- package/bin/cjs/providers/LiveShareProvider.js +205 -0
- package/bin/cjs/providers/LiveShareProvider.js.map +1 -0
- package/bin/cjs/providers/index.d.ts +3 -0
- package/bin/cjs/providers/index.d.ts.map +1 -0
- package/bin/cjs/providers/index.js +19 -0
- package/bin/cjs/providers/index.js.map +1 -0
- package/bin/cjs/shared-hooks/index.d.ts +7 -0
- package/bin/cjs/shared-hooks/index.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/index.js +23 -0
- package/bin/cjs/shared-hooks/index.js.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts +3 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.js +6 -0
- package/bin/cjs/shared-hooks/internals/tree-node-constants.js.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts +10 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.js +23 -0
- package/bin/cjs/shared-hooks/internals/tree-node-types.js.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts +33 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.js +193 -0
- package/bin/cjs/shared-hooks/internals/tree-node-utils.js.map +1 -0
- package/bin/cjs/shared-hooks/useDynamicDDS.d.ts +23 -0
- package/bin/cjs/shared-hooks/useDynamicDDS.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useDynamicDDS.js +87 -0
- package/bin/cjs/shared-hooks/useDynamicDDS.js.map +1 -0
- package/bin/cjs/shared-hooks/useSharedMap.d.ts +25 -0
- package/bin/cjs/shared-hooks/useSharedMap.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedMap.js +134 -0
- package/bin/cjs/shared-hooks/useSharedMap.js.map +1 -0
- package/bin/cjs/shared-hooks/useSharedState.d.ts +22 -0
- package/bin/cjs/shared-hooks/useSharedState.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedState.js +80 -0
- package/bin/cjs/shared-hooks/useSharedState.js.map +1 -0
- package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts +37 -0
- package/bin/cjs/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedStateRegistry.js +120 -0
- package/bin/cjs/shared-hooks/useSharedStateRegistry.js.map +1 -0
- package/bin/cjs/shared-hooks/useSharedTree.d.ts +57 -0
- package/bin/cjs/shared-hooks/useSharedTree.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useSharedTree.js +123 -0
- package/bin/cjs/shared-hooks/useSharedTree.js.map +1 -0
- package/bin/cjs/shared-hooks/useTreeNode.d.ts +96 -0
- package/bin/cjs/shared-hooks/useTreeNode.d.ts.map +1 -0
- package/bin/cjs/shared-hooks/useTreeNode.js +135 -0
- package/bin/cjs/shared-hooks/useTreeNode.js.map +1 -0
- package/bin/cjs/types/ActionTypes.d.ts +112 -0
- package/bin/cjs/types/ActionTypes.d.ts.map +1 -0
- package/bin/cjs/types/ActionTypes.js +7 -0
- package/bin/cjs/types/ActionTypes.js.map +1 -0
- package/bin/cjs/types/PropTypes.d.ts +56 -0
- package/bin/cjs/types/PropTypes.d.ts.map +1 -0
- package/bin/cjs/types/PropTypes.js +7 -0
- package/bin/cjs/types/PropTypes.js.map +1 -0
- package/bin/cjs/types/ResultTypes.d.ts +334 -0
- package/bin/cjs/types/ResultTypes.d.ts.map +1 -0
- package/bin/cjs/types/ResultTypes.js +7 -0
- package/bin/cjs/types/ResultTypes.js.map +1 -0
- package/bin/cjs/types/index.d.ts +4 -0
- package/bin/cjs/types/index.d.ts.map +1 -0
- package/bin/cjs/types/index.js +20 -0
- package/bin/cjs/types/index.js.map +1 -0
- package/bin/cjs/utils/index.d.ts +2 -0
- package/bin/cjs/utils/index.d.ts.map +1 -0
- package/bin/cjs/utils/index.js +18 -0
- package/bin/cjs/utils/index.js.map +1 -0
- package/bin/cjs/utils/type-check.d.ts +15 -0
- package/bin/cjs/utils/type-check.d.ts.map +1 -0
- package/bin/cjs/utils/type-check.js +62 -0
- package/bin/cjs/utils/type-check.js.map +1 -0
- package/bin/esm/index.d.ts +7 -0
- package/bin/esm/index.d.ts.map +1 -0
- package/bin/esm/index.js +7 -0
- package/bin/esm/index.js.map +1 -0
- package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts +26 -0
- package/bin/esm/interfaces/LiveInterfaceExtensions.d.ts.map +1 -0
- package/bin/esm/interfaces/LiveInterfaceExtensions.js +6 -0
- package/bin/esm/interfaces/LiveInterfaceExtensions.js.map +1 -0
- package/bin/esm/interfaces/index.d.ts +2 -0
- package/bin/esm/interfaces/index.d.ts.map +1 -0
- package/bin/esm/interfaces/index.js +2 -0
- package/bin/esm/interfaces/index.js.map +1 -0
- package/bin/esm/internal/errors.d.ts +41 -0
- package/bin/esm/internal/errors.d.ts.map +1 -0
- package/bin/esm/internal/errors.js +42 -0
- package/bin/esm/internal/errors.js.map +1 -0
- package/bin/esm/internal/index.d.ts +3 -0
- package/bin/esm/internal/index.d.ts.map +1 -0
- package/bin/esm/internal/index.js +3 -0
- package/bin/esm/internal/index.js.map +1 -0
- package/bin/esm/internal/type-guards.d.ts +11 -0
- package/bin/esm/internal/type-guards.d.ts.map +1 -0
- package/bin/esm/internal/type-guards.js +20 -0
- package/bin/esm/internal/type-guards.js.map +1 -0
- package/bin/esm/live-hooks/index.d.ts +8 -0
- package/bin/esm/live-hooks/index.d.ts.map +1 -0
- package/bin/esm/live-hooks/index.js +8 -0
- package/bin/esm/live-hooks/index.js.map +1 -0
- package/bin/esm/live-hooks/useLiveCanvas.d.ts +80 -0
- package/bin/esm/live-hooks/useLiveCanvas.d.ts.map +1 -0
- package/bin/esm/live-hooks/useLiveCanvas.js +238 -0
- package/bin/esm/live-hooks/useLiveCanvas.js.map +1 -0
- package/bin/esm/live-hooks/useLiveEvent.d.ts +59 -0
- package/bin/esm/live-hooks/useLiveEvent.d.ts.map +1 -0
- package/bin/esm/live-hooks/useLiveEvent.js +144 -0
- package/bin/esm/live-hooks/useLiveEvent.js.map +1 -0
- package/bin/esm/live-hooks/useLiveFollowMode.d.ts +163 -0
- package/bin/esm/live-hooks/useLiveFollowMode.d.ts.map +1 -0
- package/bin/esm/live-hooks/useLiveFollowMode.js +354 -0
- package/bin/esm/live-hooks/useLiveFollowMode.js.map +1 -0
- package/bin/esm/live-hooks/useLivePresence.d.ts +76 -0
- package/bin/esm/live-hooks/useLivePresence.d.ts.map +1 -0
- package/bin/esm/live-hooks/useLivePresence.js +164 -0
- package/bin/esm/live-hooks/useLivePresence.js.map +1 -0
- package/bin/esm/live-hooks/useLiveState.d.ts +66 -0
- package/bin/esm/live-hooks/useLiveState.d.ts.map +1 -0
- package/bin/esm/live-hooks/useLiveState.js +128 -0
- package/bin/esm/live-hooks/useLiveState.js.map +1 -0
- package/bin/esm/live-hooks/useLiveTimer.d.ts +80 -0
- package/bin/esm/live-hooks/useLiveTimer.d.ts.map +1 -0
- package/bin/esm/live-hooks/useLiveTimer.js +227 -0
- package/bin/esm/live-hooks/useLiveTimer.js.map +1 -0
- package/bin/esm/live-hooks/useMediaSynchronizer.d.ts +86 -0
- package/bin/esm/live-hooks/useMediaSynchronizer.d.ts.map +1 -0
- package/bin/esm/live-hooks/useMediaSynchronizer.js +295 -0
- package/bin/esm/live-hooks/useMediaSynchronizer.js.map +1 -0
- package/bin/esm/providers/AzureProvider.d.ts +113 -0
- package/bin/esm/providers/AzureProvider.d.ts.map +1 -0
- package/bin/esm/providers/AzureProvider.js +119 -0
- package/bin/esm/providers/AzureProvider.js.map +1 -0
- package/bin/esm/providers/LiveShareProvider.d.ts +193 -0
- package/bin/esm/providers/LiveShareProvider.d.ts.map +1 -0
- package/bin/esm/providers/LiveShareProvider.js +197 -0
- package/bin/esm/providers/LiveShareProvider.js.map +1 -0
- package/bin/esm/providers/index.d.ts +3 -0
- package/bin/esm/providers/index.d.ts.map +1 -0
- package/bin/esm/providers/index.js +3 -0
- package/bin/esm/providers/index.js.map +1 -0
- package/bin/esm/shared-hooks/index.d.ts +7 -0
- package/bin/esm/shared-hooks/index.d.ts.map +1 -0
- package/bin/esm/shared-hooks/index.js +7 -0
- package/bin/esm/shared-hooks/index.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts +3 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.js +3 -0
- package/bin/esm/shared-hooks/internals/tree-node-constants.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.d.ts +10 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.js +18 -0
- package/bin/esm/shared-hooks/internals/tree-node-types.js.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts +33 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.d.ts.map +1 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.js +188 -0
- package/bin/esm/shared-hooks/internals/tree-node-utils.js.map +1 -0
- package/bin/esm/shared-hooks/useDynamicDDS.d.ts +23 -0
- package/bin/esm/shared-hooks/useDynamicDDS.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useDynamicDDS.js +81 -0
- package/bin/esm/shared-hooks/useDynamicDDS.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedMap.d.ts +25 -0
- package/bin/esm/shared-hooks/useSharedMap.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useSharedMap.js +128 -0
- package/bin/esm/shared-hooks/useSharedMap.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedState.d.ts +22 -0
- package/bin/esm/shared-hooks/useSharedState.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useSharedState.js +74 -0
- package/bin/esm/shared-hooks/useSharedState.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts +37 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.js +113 -0
- package/bin/esm/shared-hooks/useSharedStateRegistry.js.map +1 -0
- package/bin/esm/shared-hooks/useSharedTree.d.ts +57 -0
- package/bin/esm/shared-hooks/useSharedTree.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useSharedTree.js +117 -0
- package/bin/esm/shared-hooks/useSharedTree.js.map +1 -0
- package/bin/esm/shared-hooks/useTreeNode.d.ts +96 -0
- package/bin/esm/shared-hooks/useTreeNode.d.ts.map +1 -0
- package/bin/esm/shared-hooks/useTreeNode.js +132 -0
- package/bin/esm/shared-hooks/useTreeNode.js.map +1 -0
- package/bin/esm/types/ActionTypes.d.ts +112 -0
- package/bin/esm/types/ActionTypes.d.ts.map +1 -0
- package/bin/esm/types/ActionTypes.js +6 -0
- package/bin/esm/types/ActionTypes.js.map +1 -0
- package/bin/esm/types/PropTypes.d.ts +56 -0
- package/bin/esm/types/PropTypes.d.ts.map +1 -0
- package/bin/esm/types/PropTypes.js +6 -0
- package/bin/esm/types/PropTypes.js.map +1 -0
- package/bin/esm/types/ResultTypes.d.ts +334 -0
- package/bin/esm/types/ResultTypes.d.ts.map +1 -0
- package/bin/esm/types/ResultTypes.js +6 -0
- package/bin/esm/types/ResultTypes.js.map +1 -0
- package/bin/esm/types/index.d.ts +4 -0
- package/bin/esm/types/index.d.ts.map +1 -0
- package/bin/esm/types/index.js +4 -0
- package/bin/esm/types/index.js.map +1 -0
- package/bin/esm/utils/index.d.ts +2 -0
- package/bin/esm/utils/index.d.ts.map +1 -0
- package/bin/esm/utils/index.js +2 -0
- package/bin/esm/utils/index.js.map +1 -0
- package/bin/esm/utils/type-check.d.ts +15 -0
- package/bin/esm/utils/type-check.d.ts.map +1 -0
- package/bin/esm/utils/type-check.js +54 -0
- package/bin/esm/utils/type-check.js.map +1 -0
- package/bin/internal/errors.d.ts +15 -0
- package/bin/internal/errors.d.ts.map +1 -1
- package/bin/internal/errors.js.map +1 -1
- package/bin/internal/type-guards.d.ts +5 -0
- package/bin/internal/type-guards.d.ts.map +1 -1
- package/bin/internal/type-guards.js +12 -0
- package/bin/internal/type-guards.js.map +1 -1
- package/bin/live-hooks/useLiveState.d.ts.map +1 -1
- package/bin/live-hooks/useLiveState.js +6 -2
- package/bin/live-hooks/useLiveState.js.map +1 -1
- package/bin/providers/LiveShareProvider.d.ts.map +1 -1
- package/bin/providers/LiveShareProvider.js +8 -0
- package/bin/providers/LiveShareProvider.js.map +1 -1
- package/package.json +8 -8
- package/src/internal/errors.ts +16 -0
- package/src/internal/type-guards.ts +12 -0
- package/src/live-hooks/useLiveState.ts +5 -2
- package/src/providers/LiveShareProvider.tsx +12 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { getRootDataObject, getRootDirectory, TurboDirectory, TurboStateMap, } from "@microsoft/live-share/internal";
|
|
7
|
+
/**
|
|
8
|
+
* 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.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Use this if you are building a custom `LiveShareProvider` or `AzureProvider` implementation in your app.
|
|
12
|
+
*
|
|
13
|
+
* @param results IAzureContainerResults response or undefined
|
|
14
|
+
* @returns ISharedStateRegistryResponse object
|
|
15
|
+
*/
|
|
16
|
+
export const useSharedStateRegistry = (results) => {
|
|
17
|
+
const registeredSharedSetStateActionMapRef = React.useRef(new Map());
|
|
18
|
+
const stateMap = useStateMap(results === null || results === void 0 ? void 0 : results.container);
|
|
19
|
+
/**
|
|
20
|
+
* @see ISharedStateRegistryResponse.registerSharedSetStateAction
|
|
21
|
+
*/
|
|
22
|
+
const registerSharedSetStateAction = React.useCallback((uniqueKey, componentId, setLocalStateAction) => {
|
|
23
|
+
let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
|
|
24
|
+
if (actionsMap) {
|
|
25
|
+
if (!actionsMap.has(componentId)) {
|
|
26
|
+
actionsMap.set(componentId, setLocalStateAction);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
actionsMap = new Map();
|
|
31
|
+
actionsMap.set(componentId, setLocalStateAction);
|
|
32
|
+
registeredSharedSetStateActionMapRef.current.set(uniqueKey, actionsMap);
|
|
33
|
+
}
|
|
34
|
+
// Set initial values, if known
|
|
35
|
+
const initialValue = stateMap === null || stateMap === void 0 ? void 0 : stateMap.get(uniqueKey);
|
|
36
|
+
if (initialValue) {
|
|
37
|
+
setLocalStateAction(initialValue);
|
|
38
|
+
}
|
|
39
|
+
}, [stateMap]);
|
|
40
|
+
/**
|
|
41
|
+
* @see ISharedStateRegistryResponse.unregisterSharedSetStateAction
|
|
42
|
+
*/
|
|
43
|
+
const unregisterSharedSetStateAction = React.useCallback((uniqueKey, componentId) => {
|
|
44
|
+
let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
|
|
45
|
+
if (actionsMap === null || actionsMap === void 0 ? void 0 : actionsMap.has(componentId)) {
|
|
46
|
+
actionsMap.delete(componentId);
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
/**
|
|
50
|
+
* @see ISharedStateRegistryResponse.updateSharedState
|
|
51
|
+
*/
|
|
52
|
+
const updateSharedState = React.useCallback((uniqueKey, value) => {
|
|
53
|
+
if (!stateMap)
|
|
54
|
+
return;
|
|
55
|
+
stateMap === null || stateMap === void 0 ? void 0 : stateMap.set(uniqueKey, value);
|
|
56
|
+
}, [stateMap]);
|
|
57
|
+
/**
|
|
58
|
+
* @see ISharedStateRegistryResponse.deleteSharedState
|
|
59
|
+
*/
|
|
60
|
+
const deleteSharedState = React.useCallback((uniqueKey) => {
|
|
61
|
+
if (!stateMap)
|
|
62
|
+
return;
|
|
63
|
+
let actionsMap = registeredSharedSetStateActionMapRef.current.get(uniqueKey);
|
|
64
|
+
actionsMap === null || actionsMap === void 0 ? void 0 : actionsMap.clear();
|
|
65
|
+
stateMap.delete(uniqueKey);
|
|
66
|
+
}, [stateMap]);
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (!stateMap)
|
|
69
|
+
return;
|
|
70
|
+
const valueChangedListener = (changed) => {
|
|
71
|
+
if (registeredSharedSetStateActionMapRef.current.has(changed.key)) {
|
|
72
|
+
const value = stateMap === null || stateMap === void 0 ? void 0 : stateMap.get(changed.key);
|
|
73
|
+
const actionMap = registeredSharedSetStateActionMapRef.current.get(changed.key);
|
|
74
|
+
actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
|
|
75
|
+
setLocalStateHandler(value);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
stateMap.on("valueChanged", valueChangedListener);
|
|
80
|
+
// Set initial values
|
|
81
|
+
stateMap.forEach((value, key) => {
|
|
82
|
+
const actionMap = registeredSharedSetStateActionMapRef.current.get(key);
|
|
83
|
+
actionMap === null || actionMap === void 0 ? void 0 : actionMap.forEach((setLocalStateHandler) => {
|
|
84
|
+
setLocalStateHandler(value);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
return () => {
|
|
88
|
+
stateMap === null || stateMap === void 0 ? void 0 : stateMap.off("valueChanged", valueChangedListener);
|
|
89
|
+
};
|
|
90
|
+
}, [stateMap]);
|
|
91
|
+
return {
|
|
92
|
+
registerSharedSetStateAction,
|
|
93
|
+
unregisterSharedSetStateAction,
|
|
94
|
+
updateSharedState,
|
|
95
|
+
deleteSharedState,
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const useStateMap = (container) => {
|
|
99
|
+
const [stateMap, setStateMap] = React.useState();
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
if (!container) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const rootDataObject = getRootDataObject(container);
|
|
105
|
+
const rootDirectory = getRootDirectory(rootDataObject);
|
|
106
|
+
const turboDir = rootDirectory.getSubDirectory(TurboDirectory);
|
|
107
|
+
turboDir === null || turboDir === void 0 ? void 0 : turboDir.get(TurboStateMap).get().then((state) => {
|
|
108
|
+
setStateMap(state);
|
|
109
|
+
});
|
|
110
|
+
}, [container]);
|
|
111
|
+
return stateMap;
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=useSharedStateRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharedStateRegistry.js","sourceRoot":"","sources":["../../../src/shared-hooks/useSharedStateRegistry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EACH,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,aAAa,GAChB,MAAM,gCAAgC,CAAC;AAwBxC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,OAA2C,EACf,EAAE;IAC9B,MAAM,oCAAoC,GAAG,KAAK,CAAC,MAAM,CAEvD,IAAI,GAAG,EAAE,CAAC,CAAC;IAEb,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC,CAAC;IAEjD;;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,CAAC;QAChE,IAAI,UAAU,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/B,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;YACrD,CAAC;QACL,CAAC;aAAM,CA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,uBAAR,QAAQ,CAAE,GAAG,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO;QACH,4BAA4B;QAC5B,8BAA8B;QAC9B,iBAAiB;QACjB,iBAAiB;KACpB,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,SAAsC,EAAE,EAAE;IAC3D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAyB,CAAC;IACxE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO;QACX,CAAC;QACD,MAAM,cAAc,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACpD,MAAM,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,aAAa,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QAC/D,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CACF,GAAG,CAAC,aAAa,EAClB,GAAG,GACH,IAAI,CAAC,CAAC,KAAgB,EAAE,EAAE;YACvB,WAAW,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACX,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ImplicitFieldSchema, TreeViewConfiguration, InsertableTreeFieldFromImplicitField } from "fluid-framework";
|
|
2
|
+
import { IUseSharedTreeResults } from "../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new Fluid `SharedTree` instance if one doesn't already exist.
|
|
5
|
+
* @remarks
|
|
6
|
+
* Use the `root` variable from the {@link IUseSharedTreeResults} response from this hook with {@link useTreeNode}.
|
|
7
|
+
* This makes `root` stateful with React whenever a leaf of `root` changes.
|
|
8
|
+
*
|
|
9
|
+
* @param uniqueKey the unique key for the `SharedTree`. If one does not yet exist, a new `SharedTree` will be created.
|
|
10
|
+
* Otherwise it will use the existing one.
|
|
11
|
+
* @param treeViewConfiguration the tree view configuration that contains the `SharedTree` field schema.
|
|
12
|
+
* @param initialData the initial data to load into the `SharedTree` when it is first created.
|
|
13
|
+
* @returns the {@link IUseSharedTreeResults} with the `root` node.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { SchemaFactory, TreeViewConfiguration } from "fluid-framework";
|
|
18
|
+
* import { useSharedTree, useTreeNode } from "@microsoft/live-share-react";
|
|
19
|
+
* // Declare a schema factory with your unique uuid
|
|
20
|
+
* const sf = new SchemaFactory("fc1db2e8-0000-11ee-be57-0242ac120002");
|
|
21
|
+
* class YourObject extends sf.object("YourObject", {
|
|
22
|
+
* listChangedCount: sf.number,
|
|
23
|
+
* list: sf.array(sf.string),
|
|
24
|
+
* }) {
|
|
25
|
+
* // You can add your own utility functions
|
|
26
|
+
* insert() {
|
|
27
|
+
* this.list.insertAtEnd("some text");
|
|
28
|
+
* this.listChangedCount += 1;
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* const config = new TreeViewConfiguration({ schema: YourObject });
|
|
32
|
+
* const initialData = new YourObject({
|
|
33
|
+
* number: 0,
|
|
34
|
+
* list: [],
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Must be child component of <LiveShareProvider> or <AzureProvider>
|
|
38
|
+
* export const YourComponent = () => {
|
|
39
|
+
* // Get the root node of the `SharedTree` mapped to "some-unique-key"
|
|
40
|
+
* const { root } = useSharedTree("some-unique-key", config, initialData);
|
|
41
|
+
* // Makes root stateful / automatically update when the node changes (e.g., node.count)
|
|
42
|
+
* const { node } = useTreeNode(root);
|
|
43
|
+
* // node.list is its own TreeNode, so we make it stateful as well
|
|
44
|
+
* const { node: list } = useTreeNode(node?.list);
|
|
45
|
+
* if (!node || !list) return (<>"Loading"</>);
|
|
46
|
+
* return (
|
|
47
|
+
* <div>
|
|
48
|
+
* <div>Changed: {node.listChangedCount}</div>
|
|
49
|
+
* <button onClick={() => node.insert()}>Insert</button>
|
|
50
|
+
* { list.map((item) => <div key={item}>{item}</div>) }
|
|
51
|
+
* </div>
|
|
52
|
+
* );
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function useSharedTree<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema>(uniqueKey: string, treeViewConfiguration: TreeViewConfiguration<TSchema>, initialData: InsertableTreeFieldFromImplicitField<TSchema>): IUseSharedTreeResults<TSchema>;
|
|
57
|
+
//# sourceMappingURL=useSharedTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharedTree.d.ts","sourceRoot":"","sources":["../../../src/shared-hooks/useSharedTree.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EAIrB,oCAAoC,EAEvC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,aAAa,CACzB,OAAO,SAAS,mBAAmB,GAAG,mBAAmB,EAEzD,SAAS,EAAE,MAAM,EACjB,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,CAAC,EACrD,WAAW,EAAE,oCAAoC,CAAC,OAAO,CAAC,GAC3D,qBAAqB,CAAC,OAAO,CAAC,CAuEhC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { SharedTree, } from "fluid-framework";
|
|
2
|
+
import { useDynamicDDS } from "../shared-hooks/index.js";
|
|
3
|
+
import React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new Fluid `SharedTree` instance if one doesn't already exist.
|
|
6
|
+
* @remarks
|
|
7
|
+
* Use the `root` variable from the {@link IUseSharedTreeResults} response from this hook with {@link useTreeNode}.
|
|
8
|
+
* This makes `root` stateful with React whenever a leaf of `root` changes.
|
|
9
|
+
*
|
|
10
|
+
* @param uniqueKey the unique key for the `SharedTree`. If one does not yet exist, a new `SharedTree` will be created.
|
|
11
|
+
* Otherwise it will use the existing one.
|
|
12
|
+
* @param treeViewConfiguration the tree view configuration that contains the `SharedTree` field schema.
|
|
13
|
+
* @param initialData the initial data to load into the `SharedTree` when it is first created.
|
|
14
|
+
* @returns the {@link IUseSharedTreeResults} with the `root` node.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { SchemaFactory, TreeViewConfiguration } from "fluid-framework";
|
|
19
|
+
* import { useSharedTree, useTreeNode } from "@microsoft/live-share-react";
|
|
20
|
+
* // Declare a schema factory with your unique uuid
|
|
21
|
+
* const sf = new SchemaFactory("fc1db2e8-0000-11ee-be57-0242ac120002");
|
|
22
|
+
* class YourObject extends sf.object("YourObject", {
|
|
23
|
+
* listChangedCount: sf.number,
|
|
24
|
+
* list: sf.array(sf.string),
|
|
25
|
+
* }) {
|
|
26
|
+
* // You can add your own utility functions
|
|
27
|
+
* insert() {
|
|
28
|
+
* this.list.insertAtEnd("some text");
|
|
29
|
+
* this.listChangedCount += 1;
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* const config = new TreeViewConfiguration({ schema: YourObject });
|
|
33
|
+
* const initialData = new YourObject({
|
|
34
|
+
* number: 0,
|
|
35
|
+
* list: [],
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Must be child component of <LiveShareProvider> or <AzureProvider>
|
|
39
|
+
* export const YourComponent = () => {
|
|
40
|
+
* // Get the root node of the `SharedTree` mapped to "some-unique-key"
|
|
41
|
+
* const { root } = useSharedTree("some-unique-key", config, initialData);
|
|
42
|
+
* // Makes root stateful / automatically update when the node changes (e.g., node.count)
|
|
43
|
+
* const { node } = useTreeNode(root);
|
|
44
|
+
* // node.list is its own TreeNode, so we make it stateful as well
|
|
45
|
+
* const { node: list } = useTreeNode(node?.list);
|
|
46
|
+
* if (!node || !list) return (<>"Loading"</>);
|
|
47
|
+
* return (
|
|
48
|
+
* <div>
|
|
49
|
+
* <div>Changed: {node.listChangedCount}</div>
|
|
50
|
+
* <button onClick={() => node.insert()}>Insert</button>
|
|
51
|
+
* { list.map((item) => <div key={item}>{item}</div>) }
|
|
52
|
+
* </div>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function useSharedTree(uniqueKey, treeViewConfiguration, initialData) {
|
|
58
|
+
const [treeView, setTreeView] = React.useState();
|
|
59
|
+
const [root, setRoot] = React.useState();
|
|
60
|
+
const onFirstInitialize = React.useCallback((newDDS) => {
|
|
61
|
+
try {
|
|
62
|
+
// Create a `treeView` with the provided `treeViewConfiguration`
|
|
63
|
+
const _treeView = newDDS.viewWith(treeViewConfiguration);
|
|
64
|
+
if (_treeView.compatibility.canInitialize) {
|
|
65
|
+
// Set initial data
|
|
66
|
+
_treeView.initialize(initialData);
|
|
67
|
+
}
|
|
68
|
+
// `onFirstInitialize` is only called for the user that created the tree, but we need this object for all clients.
|
|
69
|
+
// Dispose, since we will call `sharedTree.viewWith` in a `useEffect` down below and set it to state.
|
|
70
|
+
_treeView.dispose();
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
console.error(err);
|
|
74
|
+
}
|
|
75
|
+
}, [treeViewConfiguration, initialData]);
|
|
76
|
+
/**
|
|
77
|
+
* User facing: dynamically load the `SharedTree` DDS for the given unique key.
|
|
78
|
+
*/
|
|
79
|
+
const { dds: sharedTree } = useDynamicDDS(uniqueKey, SharedTree, onFirstInitialize);
|
|
80
|
+
/**
|
|
81
|
+
* Sets the tree view and root view
|
|
82
|
+
*/
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
if (!sharedTree)
|
|
85
|
+
return;
|
|
86
|
+
let _treeView = undefined;
|
|
87
|
+
try {
|
|
88
|
+
// Create a `treeView` with the provided `treeViewConfiguration`
|
|
89
|
+
_treeView = sharedTree.viewWith(treeViewConfiguration);
|
|
90
|
+
setTreeView(_treeView);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
console.error(err);
|
|
94
|
+
}
|
|
95
|
+
// Listen for changes to root view
|
|
96
|
+
const updateRoot = () => {
|
|
97
|
+
if (_treeView === null || _treeView === void 0 ? void 0 : _treeView.compatibility.canView) {
|
|
98
|
+
setRoot(_treeView.root);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
setRoot(undefined);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
updateRoot();
|
|
105
|
+
const unsubscribeToRoot = _treeView === null || _treeView === void 0 ? void 0 : _treeView.events.on("rootChanged", updateRoot);
|
|
106
|
+
return () => {
|
|
107
|
+
_treeView === null || _treeView === void 0 ? void 0 : _treeView.dispose();
|
|
108
|
+
unsubscribeToRoot === null || unsubscribeToRoot === void 0 ? void 0 : unsubscribeToRoot();
|
|
109
|
+
};
|
|
110
|
+
}, [sharedTree, treeViewConfiguration]);
|
|
111
|
+
return {
|
|
112
|
+
treeView,
|
|
113
|
+
sharedTree,
|
|
114
|
+
root,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=useSharedTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSharedTree.js","sourceRoot":"","sources":["../../../src/shared-hooks/useSharedTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,UAAU,GAKb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAe,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,MAAM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kCAAkC;QAClC,MAAM,UAAU,GAAG,GAAS,EAAE;YAC1B,IAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,aAAa,CAAC,OAAO,EAAE,CAAC;gBACnC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,SAAS,CAAC,CAAC;YACvB,CAAC;QACL,CAAC,CAAC;QAEF,UAAU,EAAE,CAAC;QACb,MAAM,iBAAiB,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC,EAAE,CAC1C,aAAa,EACb,UAAU,CACb,CAAC;QACF,OAAO,GAAG,EAAE;YACR,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,EAAE,CAAC;YACrB,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,EAAI,CAAC;QAC1B,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAExC,OAAO;QACH,QAAQ;QACR,UAAU;QACV,IAAI;KACP,CAAC;AACN,CAAC"}
|
|
@@ -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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C,CAAC;IAE/B,OAAO;QACH,IAAI,EAAE,SAAS;KAClB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { ITimerConfig, ILiveEvent, LivePresenceData } from "@microsoft/live-share";
|
|
8
|
+
import { SharedObjectKind } from "fluid-framework";
|
|
9
|
+
/**
|
|
10
|
+
* Callback to set shared state
|
|
11
|
+
*/
|
|
12
|
+
export type SetSharedStateAction<TState> = (state: TState | ((prevState: TState) => TState)) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Callback to set local state
|
|
15
|
+
*/
|
|
16
|
+
export type SetLocalStateAction = React.Dispatch<React.SetStateAction<any>>;
|
|
17
|
+
/**
|
|
18
|
+
* Callback for UnregisterDDSSetStateAction.
|
|
19
|
+
* <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: SharedObjectKind<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void
|
|
20
|
+
*/
|
|
21
|
+
export type RegisterDDSSetStateAction = <T extends IFluidLoadable>(uniqueKey: string, componentId: string, objectClass: SharedObjectKind<T>, setLocalStateAction: SetLocalStateAction, onDidFirstInitialize?: (dds: T) => void) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Callback for UnregisterDDSSetStateAction.
|
|
24
|
+
* (uniqueKey: string, componentId: string) => void
|
|
25
|
+
*/
|
|
26
|
+
export type UnregisterDDSSetStateAction = (uniqueKey: string, componentId: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Callback for RegisterSharedSetStateAction.
|
|
29
|
+
* (uniqueKey: string, componentId: string, setLocalStateAction: SetLocalStateAction) => void
|
|
30
|
+
*/
|
|
31
|
+
export type RegisterSharedSetStateAction = (uniqueKey: string, componentId: string, setLocalStateAction: SetLocalStateAction) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback for UnregisterSharedSetStateAction.
|
|
34
|
+
* (uniqueKey: string, componentId: string) => void
|
|
35
|
+
*/
|
|
36
|
+
export type UnregisterSharedSetStateAction = (uniqueKey: string, componentId: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Callback for UpdateSharedStateAction.
|
|
39
|
+
* (uniqueKey: string, value: any) => void
|
|
40
|
+
*/
|
|
41
|
+
export type UpdateSharedStateAction = (uniqueKey: string, value: any) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Callback for DeleteSharedStateAction.
|
|
44
|
+
* (uniqueKey: string) => void
|
|
45
|
+
*/
|
|
46
|
+
export type DeleteSharedStateAction = (uniqueKey: string) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Callback for DisposeSharedStateAction.
|
|
49
|
+
* () => void
|
|
50
|
+
*/
|
|
51
|
+
export type DisposeSharedStateAction = () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Callback for SetLiveStateAction<TState = undefined>.
|
|
54
|
+
* (state: TState) => Promise<void>
|
|
55
|
+
*/
|
|
56
|
+
export type SetLiveStateAction<TState = undefined> = (state: TState | ((prevState: TState) => TState)) => Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Callback for SendLiveEventAction<TEvent>.
|
|
59
|
+
* (event: TEvent, targetClientId?: string) => Promise<void>
|
|
60
|
+
*/
|
|
61
|
+
export type SendLiveEventAction<TEvent> = (event: TEvent, targetClientId?: string) => Promise<ILiveEvent<TEvent>>;
|
|
62
|
+
/**
|
|
63
|
+
* Callback for OnReceivedLiveEventAction<TEvent>.
|
|
64
|
+
* (event: TEvent, local: boolean) => void
|
|
65
|
+
*/
|
|
66
|
+
export type OnReceivedLiveEventAction<TEvent> = (event: TEvent, local: boolean) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Callback for OnUpdateLivePresenceAction<TData extends object = object>.
|
|
69
|
+
* (data?: TData | undefined, state?: PresenceState | undefined) => Promise<void>
|
|
70
|
+
*/
|
|
71
|
+
export type OnUpdateLivePresenceAction<TData extends LivePresenceData = any> = (data: TData) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Callback for OnStartTimerAction.
|
|
74
|
+
* (duration: number) => Promise<void>
|
|
75
|
+
*/
|
|
76
|
+
export type OnStartTimerAction = (duration: number) => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Callback for OnPlayTimerAction.
|
|
79
|
+
* () => Promise<void>
|
|
80
|
+
*/
|
|
81
|
+
export type OnPlayTimerAction = () => Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Callback for OnPauseTimerAction.
|
|
84
|
+
* () => Promise<void>
|
|
85
|
+
*/
|
|
86
|
+
export type OnPauseTimerAction = () => Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Callback for OnTimerTickAction.
|
|
89
|
+
* (milliRemaining: number) => void
|
|
90
|
+
*/
|
|
91
|
+
export type OnTimerTickAction = (milliRemaining: number) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Callback for OnTimerDidStartAction.
|
|
94
|
+
* (timerConfig: ITimerConfig) => void
|
|
95
|
+
*/
|
|
96
|
+
export type OnTimerDidStartAction = (timerConfig: ITimerConfig) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Callback for OnTimerDidPauseAction.
|
|
99
|
+
* (timerConfig: ITimerConfig) => void
|
|
100
|
+
*/
|
|
101
|
+
export type OnTimerDidPauseAction = (timerConfig: ITimerConfig) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Callback for OnTimerDidPlayAction.
|
|
104
|
+
* (timerConfig: ITimerConfig) => void
|
|
105
|
+
*/
|
|
106
|
+
export type OnTimerDidPlayAction = (timerConfig: ITimerConfig) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Callback for OnTimerDidFinishAction.
|
|
109
|
+
* (timerConfig: ITimerConfig) => void
|
|
110
|
+
*/
|
|
111
|
+
export type OnTimerDidFinishAction = (timerConfig: ITimerConfig) => void;
|
|
112
|
+
//# sourceMappingURL=ActionTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionTypes.d.ts","sourceRoot":"","sources":["../../../src/types/ActionTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EACH,YAAY,EACZ,UAAU,EACV,gBAAgB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInD;;GAEG;AACH,MAAM,MAAM,oBAAoB,CAAC,MAAM,IAAI,CACvC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,KAC9C,IAAI,CAAC;AACV;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AAI5E;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,SAAS,cAAc,EAC7D,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,oBAAoB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,KACtC,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACtC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,KAClB,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,CACvC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,mBAAmB,KACvC,IAAI,CAAC;AAEV;;;GAG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