@microsoft/live-share-react 1.2.1-preview.0 → 1.3.0-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/internal/errors.d.ts.map +1 -1
- package/bin/internal/errors.js +7 -4
- package/bin/internal/errors.js.map +1 -1
- package/bin/internal/index.d.ts +0 -1
- package/bin/internal/index.d.ts.map +1 -1
- package/bin/internal/index.js +0 -1
- package/bin/internal/index.js.map +1 -1
- package/bin/live-hooks/useLiveCanvas.d.ts +1 -0
- package/bin/live-hooks/useLiveCanvas.d.ts.map +1 -1
- package/bin/live-hooks/useLiveCanvas.js +1 -0
- package/bin/live-hooks/useLiveCanvas.js.map +1 -1
- package/bin/live-hooks/useLiveEvent.d.ts +1 -0
- package/bin/live-hooks/useLiveEvent.d.ts.map +1 -1
- package/bin/live-hooks/useLiveEvent.js +1 -0
- package/bin/live-hooks/useLiveEvent.js.map +1 -1
- package/bin/live-hooks/useLiveFollowMode.d.ts +1 -0
- package/bin/live-hooks/useLiveFollowMode.d.ts.map +1 -1
- package/bin/live-hooks/useLiveFollowMode.js +7 -6
- package/bin/live-hooks/useLiveFollowMode.js.map +1 -1
- package/bin/live-hooks/useLivePresence.d.ts +1 -0
- package/bin/live-hooks/useLivePresence.d.ts.map +1 -1
- package/bin/live-hooks/useLivePresence.js +1 -0
- package/bin/live-hooks/useLivePresence.js.map +1 -1
- package/bin/live-hooks/useLiveState.d.ts +1 -0
- package/bin/live-hooks/useLiveState.d.ts.map +1 -1
- package/bin/live-hooks/useLiveState.js +1 -0
- package/bin/live-hooks/useLiveState.js.map +1 -1
- package/bin/live-hooks/useLiveTimer.d.ts +17 -0
- package/bin/live-hooks/useLiveTimer.d.ts.map +1 -1
- package/bin/live-hooks/useLiveTimer.js +17 -0
- package/bin/live-hooks/useLiveTimer.js.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.d.ts +1 -0
- package/bin/live-hooks/useMediaSynchronizer.d.ts.map +1 -1
- package/bin/live-hooks/useMediaSynchronizer.js +1 -0
- package/bin/live-hooks/useMediaSynchronizer.js.map +1 -1
- package/bin/providers/AzureProvider.d.ts +83 -4
- package/bin/providers/AzureProvider.d.ts.map +1 -1
- package/bin/providers/AzureProvider.js +18 -1
- package/bin/providers/AzureProvider.js.map +1 -1
- package/bin/providers/LiveShareProvider.d.ts +36 -8
- package/bin/providers/LiveShareProvider.d.ts.map +1 -1
- package/bin/providers/LiveShareProvider.js +19 -1
- package/bin/providers/LiveShareProvider.js.map +1 -1
- package/bin/shared-hooks/index.d.ts +1 -0
- package/bin/shared-hooks/index.d.ts.map +1 -1
- package/bin/shared-hooks/index.js +1 -0
- package/bin/shared-hooks/index.js.map +1 -1
- package/bin/shared-hooks/useDynamicDDS.d.ts +4 -0
- package/bin/shared-hooks/useDynamicDDS.d.ts.map +1 -1
- package/bin/shared-hooks/useDynamicDDS.js +4 -0
- package/bin/shared-hooks/useDynamicDDS.js.map +1 -1
- package/bin/shared-hooks/useSharedMap.d.ts +1 -0
- package/bin/shared-hooks/useSharedMap.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedMap.js +1 -0
- package/bin/shared-hooks/useSharedMap.js.map +1 -1
- package/bin/shared-hooks/useSharedState.d.ts +1 -0
- package/bin/shared-hooks/useSharedState.d.ts.map +1 -1
- package/bin/shared-hooks/useSharedState.js +1 -0
- package/bin/shared-hooks/useSharedState.js.map +1 -1
- package/bin/shared-hooks/useSharedStateRegistry.d.ts +37 -0
- package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +1 -0
- package/bin/shared-hooks/useSharedStateRegistry.js +105 -0
- package/bin/shared-hooks/useSharedStateRegistry.js.map +1 -0
- package/package.json +8 -8
- package/src/internal/errors.ts +15 -6
- package/src/internal/index.ts +0 -1
- package/src/live-hooks/useLiveCanvas.ts +1 -0
- package/src/live-hooks/useLiveEvent.ts +1 -0
- package/src/live-hooks/useLiveFollowMode.ts +7 -6
- package/src/live-hooks/useLivePresence.ts +1 -0
- package/src/live-hooks/useLiveState.ts +1 -0
- package/src/live-hooks/useLiveTimer.ts +17 -0
- package/src/live-hooks/useMediaSynchronizer.ts +1 -0
- package/src/providers/AzureProvider.tsx +92 -3
- package/src/providers/LiveShareProvider.tsx +49 -9
- package/src/shared-hooks/index.ts +1 -0
- package/src/shared-hooks/useDynamicDDS.ts +4 -0
- package/src/shared-hooks/useSharedMap.ts +1 -0
- package/src/shared-hooks/useSharedState.ts +1 -0
- package/src/{internal → shared-hooks}/useSharedStateRegistry.ts +6 -0
|
@@ -28,6 +28,7 @@ import { IUseLiveFollowModeResults } from "../types";
|
|
|
28
28
|
* Use this hook if you want to add the ability to follow specific users or let a user present to everyone in the session.
|
|
29
29
|
* Each user has their own `stateValue`, which is the value other users will reference when that user is presenting or being followed.
|
|
30
30
|
* The `state` response includes the user's `value` that the local user is "following", whether it be their own or someone else's.
|
|
31
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
31
32
|
*
|
|
32
33
|
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
33
34
|
*
|
|
@@ -79,19 +80,19 @@ export function useLiveFollowMode<TData = any>(
|
|
|
79
80
|
if (!container) {
|
|
80
81
|
throw new ActionContainerNotJoinedError(
|
|
81
82
|
"liveFollowMode",
|
|
82
|
-
"
|
|
83
|
+
"update"
|
|
83
84
|
);
|
|
84
85
|
}
|
|
85
86
|
if (liveFollowMode === undefined) {
|
|
86
87
|
throw new ActionLiveDataObjectUndefinedError(
|
|
87
88
|
"liveFollowMode",
|
|
88
|
-
"
|
|
89
|
+
"update"
|
|
89
90
|
);
|
|
90
91
|
}
|
|
91
92
|
if (!liveFollowMode.isInitialized) {
|
|
92
93
|
throw new ActionLiveDataObjectInitializedError(
|
|
93
94
|
"liveFollowMode",
|
|
94
|
-
"
|
|
95
|
+
"update"
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
return await liveFollowMode.update(stateValue);
|
|
@@ -106,19 +107,19 @@ export function useLiveFollowMode<TData = any>(
|
|
|
106
107
|
if (!container) {
|
|
107
108
|
throw new ActionContainerNotJoinedError(
|
|
108
109
|
"liveFollowMode",
|
|
109
|
-
"
|
|
110
|
+
"startPresenting"
|
|
110
111
|
);
|
|
111
112
|
}
|
|
112
113
|
if (liveFollowMode === undefined) {
|
|
113
114
|
throw new ActionLiveDataObjectUndefinedError(
|
|
114
115
|
"liveFollowMode",
|
|
115
|
-
"
|
|
116
|
+
"startPresenting"
|
|
116
117
|
);
|
|
117
118
|
}
|
|
118
119
|
if (!liveFollowMode.isInitialized) {
|
|
119
120
|
throw new ActionLiveDataObjectInitializedError(
|
|
120
121
|
"liveFollowMode",
|
|
121
|
-
"
|
|
122
|
+
"startPresenting"
|
|
122
123
|
);
|
|
123
124
|
}
|
|
124
125
|
return await liveFollowMode.startPresenting();
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
* Use this hook if you want to track presence for who is currently using this component, such as
|
|
28
28
|
* who is online or who is viewing a specific document. With presence, you can sent along any custom
|
|
29
29
|
* user data. This is useful for rendering a list of users, profile pictures, cursor positions, and more.
|
|
30
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
30
31
|
*
|
|
31
32
|
* @template TData Optional typing for the custom user presence data object. Default is `object` type.
|
|
32
33
|
* @param uniqueKey The unique key for `LivePresence`. If one does not yet exist, a new one will be created.
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
*
|
|
25
25
|
* @remarks
|
|
26
26
|
* Use this hook if you want to synchronize app state that will reset when all users leave the session.
|
|
27
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
27
28
|
*
|
|
28
29
|
* @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
|
|
29
30
|
* @param initialState Optional. the initial state value of type TState
|
|
@@ -30,6 +30,23 @@ import {
|
|
|
30
30
|
ActionLiveDataObjectUndefinedError,
|
|
31
31
|
} from "../internal";
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* React hook for using Live Share's `LiveTimer` DDS.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Use this hook to create a synchronized countdown timer in your app or to schedule synchronized tasks.
|
|
38
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
39
|
+
*
|
|
40
|
+
* @param uniqueKey the unique key for the `LiveTimer`. If one does not yet exist, a new one will be created, otherwise it will use the existing one.
|
|
41
|
+
* @param allowedRoles Optional. the user roles that are allowed to start/stop/pause the timer.
|
|
42
|
+
* @param tickRate Optional. the interval in which the `milliRemaining` state should be updated and the `onTick` callback will trigger.
|
|
43
|
+
* @param onTick Optional. event handler callback for when an active timer ticks.
|
|
44
|
+
* @param onStart Optional. event handler callback for when the timer is started.
|
|
45
|
+
* @param onPause Optional. event handler callback for when the timer is paused.
|
|
46
|
+
* @param onPlay Optional. event handler callback for when the timer is resumed.
|
|
47
|
+
* @param onFinish Optional. event handler callback for when the timer finishes.
|
|
48
|
+
* @returns results and callbacks exposed via the hook.
|
|
49
|
+
*/
|
|
33
50
|
export function useLiveTimer(
|
|
34
51
|
uniqueKey: string,
|
|
35
52
|
allowedRoles?: UserMeetingRole[],
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
*
|
|
31
31
|
* @remarks
|
|
32
32
|
* Use this hook if you want to synchronize the playback position of a video or audio element during a Live Share session.
|
|
33
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
33
34
|
*
|
|
34
35
|
* @param uniqueKey uniqueKey value for the `LiveMediaSession` DDS object used by `MediaPlayerSynchronizer`.
|
|
35
36
|
* @param mediaPlayerElement React RefObject containing object/element conforming to IMediaPlayer interface, `IMediaPlayer` object, or string id for <video> / <audio> element.
|
|
@@ -13,42 +13,127 @@ import { IAzureContainerResults } from "../types";
|
|
|
13
13
|
import {
|
|
14
14
|
ISharedStateRegistryResponse,
|
|
15
15
|
useSharedStateRegistry,
|
|
16
|
-
} from "../
|
|
16
|
+
} from "../shared-hooks";
|
|
17
17
|
import {
|
|
18
18
|
AzureTurboClient,
|
|
19
19
|
IFluidTurboClient,
|
|
20
20
|
} from "@microsoft/live-share-turbo";
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* React Context provider values for `<AzureProvider>` and `<LiveShareProvider>`.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* To get the latest values, use the {@link useFluidObjectsContext} hook.
|
|
27
|
+
*/
|
|
28
|
+
export interface IFluidContext extends ISharedStateRegistryResponse {
|
|
29
|
+
/**
|
|
30
|
+
* The Fluid Turbo client used for connecting to the Fluid container.
|
|
31
|
+
*/
|
|
23
32
|
clientRef: React.MutableRefObject<IFluidTurboClient>;
|
|
33
|
+
/**
|
|
34
|
+
* Stateful Fluid container.
|
|
35
|
+
*/
|
|
24
36
|
container: IFluidContainer | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The Azure container services (e.g., audience).
|
|
39
|
+
*/
|
|
25
40
|
services: AzureContainerServices | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* A stateful error object that is set if there was an error connecting to the Fluid container.
|
|
43
|
+
*/
|
|
26
44
|
joinError: Error | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* React callback function to connect to an existing Fluid container.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* The results will also be set to their stateful counterparts for `container` and `services`.
|
|
50
|
+
*
|
|
51
|
+
* @param containerId the containerId to connect to.
|
|
52
|
+
* @param initialObjects Optional. initial object schema, which should match that passed to `createContainer()`.
|
|
53
|
+
* @returns promise that returns a results object once complete (e.g., container, services, etc.)
|
|
54
|
+
*/
|
|
27
55
|
getContainer: (
|
|
28
56
|
containerId: string,
|
|
29
57
|
initialObjects?: LoadableObjectClassRecord
|
|
30
58
|
) => Promise<IAzureContainerResults>;
|
|
59
|
+
/**
|
|
60
|
+
* React callback function to create and connect to a new Fluid container.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* The results will also be set to their stateful counterparts for `container` and `services`.
|
|
64
|
+
*
|
|
65
|
+
* @param initialObjects Optional. The initial object schema to apply to the container.
|
|
66
|
+
* @param onInitializeContainer Optional. A callback for when the container is first initialized, which is useful for setting default values to objects in `initialObjects`.
|
|
67
|
+
* @returns promise that returns a results object once complete (e.g., container, services, etc.)
|
|
68
|
+
*/
|
|
31
69
|
createContainer: (
|
|
32
70
|
initialObjects?: LoadableObjectClassRecord,
|
|
33
71
|
onInitializeContainer?: (container: IFluidContainer) => void
|
|
34
72
|
) => Promise<IAzureContainerResults>;
|
|
35
73
|
}
|
|
36
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @hidden
|
|
77
|
+
*/
|
|
37
78
|
export const FluidContext = React.createContext<IFluidContext>(
|
|
38
79
|
{} as IFluidContext
|
|
39
80
|
);
|
|
40
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Hook to get the latest React context state for `FluidContext`.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
87
|
+
*
|
|
88
|
+
* @returns current state of `LiveShareContext`
|
|
89
|
+
*/
|
|
41
90
|
export const useFluidObjectsContext = (): IFluidContext => {
|
|
42
91
|
const context = React.useContext(FluidContext);
|
|
92
|
+
if (!isFluidObjectsContext(context)) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
"@microsoft/live-share-react: attempting to use `useFluidObjectsContext()` from a component that is not a child of `<LiveShareProvider>` or `<AzureProvider>`.\nTo fix this error, ensure that you are only using Live Share hooks (e.g., `useLiveState`) from a child component of `<LiveShareProvider>` or `<AzureProvider>`."
|
|
95
|
+
);
|
|
96
|
+
}
|
|
43
97
|
return context;
|
|
44
98
|
};
|
|
45
99
|
|
|
46
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Prop types for {@link AzureProvider} component.
|
|
102
|
+
*/
|
|
103
|
+
export interface IAzureProviderProps {
|
|
104
|
+
/**
|
|
105
|
+
* Optional. React children node for the React Context Provider.
|
|
106
|
+
*/
|
|
47
107
|
children?: React.ReactNode;
|
|
108
|
+
/**
|
|
109
|
+
* Props for initializing a new `AzureClient` instance.
|
|
110
|
+
*/
|
|
48
111
|
clientOptions: AzureClientProps;
|
|
112
|
+
/**
|
|
113
|
+
* The `containerId` to connect to when {@link joinOnLoad} is true.
|
|
114
|
+
*
|
|
115
|
+
* @remarks
|
|
116
|
+
* If you pass in an `undefined` value when {@link createOnLoad} is true, a new container will be created.
|
|
117
|
+
*/
|
|
49
118
|
containerId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Flag to control whether or not a new container should be created on first mount.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* If no {@link containerId} is set when the component first mounts, setting this to `true` will automatically create a new container.
|
|
124
|
+
* This prop does not do anything if you are using `<LiveShareProvider>` instead of `<AzureProvider>`.
|
|
125
|
+
*/
|
|
50
126
|
createOnLoad?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* The initial object schema to use when {@link joinOnLoad} or {@link createOnLoad} is true.
|
|
129
|
+
*/
|
|
51
130
|
initialObjects?: LoadableObjectClassRecord;
|
|
131
|
+
/**
|
|
132
|
+
* Flag to control whether or not to connect to an existing container on first mount.
|
|
133
|
+
*
|
|
134
|
+
* @remarks
|
|
135
|
+
* Setting this to true will connect to the container if {@link containerId} is provided as a prop.
|
|
136
|
+
*/
|
|
52
137
|
joinOnLoad?: boolean;
|
|
53
138
|
}
|
|
54
139
|
|
|
@@ -170,3 +255,7 @@ export const AzureProvider: React.FC<IAzureProviderProps> = (props) => {
|
|
|
170
255
|
</FluidContext.Provider>
|
|
171
256
|
);
|
|
172
257
|
};
|
|
258
|
+
|
|
259
|
+
function isFluidObjectsContext(value: any): value is IFluidContext {
|
|
260
|
+
return !!value?.clientRef;
|
|
261
|
+
}
|
|
@@ -5,16 +5,23 @@
|
|
|
5
5
|
|
|
6
6
|
import { IFluidContainer, LoadableObjectClassRecord } from "fluid-framework";
|
|
7
7
|
import React from "react";
|
|
8
|
-
import { useSharedStateRegistry } from "../
|
|
8
|
+
import { useSharedStateRegistry } from "../shared-hooks";
|
|
9
9
|
import {
|
|
10
10
|
ILiveShareClientOptions,
|
|
11
11
|
ILiveShareHost,
|
|
12
12
|
ILiveShareJoinResults,
|
|
13
13
|
ITimestampProvider,
|
|
14
14
|
} from "@microsoft/live-share";
|
|
15
|
-
import { FluidContext } from "./AzureProvider";
|
|
15
|
+
import { FluidContext, useFluidObjectsContext } from "./AzureProvider";
|
|
16
16
|
import { LiveShareTurboClient } from "@microsoft/live-share-turbo";
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* React Context provider values for `<LiveShareProvider>`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* To get the latest values, use the {@link useLiveShareContext} hook.
|
|
23
|
+
* Use the {@link useFluidObjectsContext} hook for other relevant context values.
|
|
24
|
+
*/
|
|
18
25
|
export interface ILiveShareContext {
|
|
19
26
|
/**
|
|
20
27
|
* True if the local user created the Fluid container
|
|
@@ -34,10 +41,14 @@ export interface ILiveShareContext {
|
|
|
34
41
|
*/
|
|
35
42
|
timestampProvider: ITimestampProvider | undefined;
|
|
36
43
|
/**
|
|
37
|
-
* Join callback method
|
|
44
|
+
* Join callback method for manually connecting to the Fluid container.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Use this callback if `joinOnLoad` is `false` or `undefined` in {@link ILiveShareProviderProps}.
|
|
48
|
+
*
|
|
38
49
|
* @param initialObjects Optional. The initial objects for the Fluid container schema.
|
|
39
50
|
* @param onInitializeContainer Optional. Callback for when the container is first created.
|
|
40
|
-
* @returns `ILiveShareJoinResults`, which includes the Fluid container
|
|
51
|
+
* @returns Promise with `ILiveShareJoinResults`, which includes the Fluid container
|
|
41
52
|
*/
|
|
42
53
|
join: (
|
|
43
54
|
initialObjects?: LoadableObjectClassRecord,
|
|
@@ -45,34 +56,57 @@ export interface ILiveShareContext {
|
|
|
45
56
|
) => Promise<ILiveShareJoinResults>;
|
|
46
57
|
}
|
|
47
58
|
|
|
59
|
+
/**
|
|
60
|
+
* @hidden
|
|
61
|
+
*/
|
|
48
62
|
export const LiveShareContext = React.createContext<ILiveShareContext>(
|
|
49
63
|
{} as ILiveShareContext
|
|
50
64
|
);
|
|
51
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Hook to get the latest React context state for `LiveShareContext`.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* This hook can only be used in a child component of `<LiveShareProvider>`.
|
|
71
|
+
* See `useFluidObjectsContext` for other information related to the Live Share session, such as the `container`.
|
|
72
|
+
*
|
|
73
|
+
* @returns current state of `LiveShareContext`
|
|
74
|
+
*/
|
|
52
75
|
export const useLiveShareContext = (): ILiveShareContext => {
|
|
53
76
|
const context = React.useContext(LiveShareContext);
|
|
77
|
+
if (!isLiveShareContext(context)) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"@microsoft/live-share-react: attempting to use `useLiveShareContext()` from a component that is not a child of `<LiveShareProvider>`.\nTo fix this error, ensure that you are only using Live Share hooks (e.g., `useLiveState`) from a child component of `<LiveShareProvider>`."
|
|
80
|
+
);
|
|
81
|
+
}
|
|
54
82
|
return context;
|
|
55
83
|
};
|
|
56
84
|
|
|
57
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Prop types for {@link LiveShareProvider} component.
|
|
87
|
+
*/
|
|
88
|
+
export interface ILiveShareProviderProps {
|
|
58
89
|
/**
|
|
59
90
|
* Optional. React children node for the React Context Provider
|
|
60
91
|
*/
|
|
61
92
|
children?: React.ReactNode;
|
|
62
93
|
/**
|
|
63
|
-
* Optional. Options
|
|
94
|
+
* Optional. Options for initializing `LiveShareClient`.
|
|
64
95
|
*/
|
|
65
96
|
clientOptions?: ILiveShareClientOptions;
|
|
66
97
|
/**
|
|
67
|
-
* Host to initialize LiveShareClient with
|
|
98
|
+
* Host to initialize `LiveShareClient` with.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* If using the `LiveShareClient` class from `@microsoft/teams-js`, you must ensure that you have first called `teamsJs.app.initialize()` before calling `LiveShareClient.create()`.
|
|
68
102
|
*/
|
|
69
103
|
host: ILiveShareHost;
|
|
70
104
|
/**
|
|
71
|
-
*
|
|
105
|
+
* The initial object schema to use when {@link joinOnLoad} is true.
|
|
72
106
|
*/
|
|
73
107
|
initialObjects?: LoadableObjectClassRecord;
|
|
74
108
|
/**
|
|
75
|
-
* Optional. Flag to determine whether to join Fluid container on load
|
|
109
|
+
* Optional. Flag to determine whether to join Fluid container on load.
|
|
76
110
|
*/
|
|
77
111
|
joinOnLoad?: boolean;
|
|
78
112
|
}
|
|
@@ -168,3 +202,9 @@ export const LiveShareProvider: React.FC<ILiveShareProviderProps> = (props) => {
|
|
|
168
202
|
</LiveShareContext.Provider>
|
|
169
203
|
);
|
|
170
204
|
};
|
|
205
|
+
|
|
206
|
+
function isLiveShareContext(value: any): value is ILiveShareContext {
|
|
207
|
+
return (
|
|
208
|
+
typeof value?.created === "boolean" && typeof value?.join === "function"
|
|
209
|
+
);
|
|
210
|
+
}
|
|
@@ -10,6 +10,10 @@ import { LoadableObjectClass } from "fluid-framework";
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Hook to gets or creates a DDS that corresponds to a given uniqueKey string.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
16
|
+
*
|
|
13
17
|
* @template T Type of Fluid LoadableObjectClass type to load. Must conform to IFluidLoadable interface.
|
|
14
18
|
* @param uniqueKey uniqueKey value for the data object
|
|
15
19
|
* @param loadableObjectClass Fluid LoadableObjectClass<T> to create/load.
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
* The primary benefit of using the `useSharedMap` hook rather than the Fluid `SharedMap`
|
|
22
22
|
* directly is that it integrates nicely with React state and automates repetitive tasks.
|
|
23
23
|
* If you want to use `SharedMap` this hook creates directly, you can do that as well.
|
|
24
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
24
25
|
*
|
|
25
26
|
* @template TData Optional typing for objects stored in the SharedMap. Default is `any` type.
|
|
26
27
|
* @param uniqueKey the unique key for the `SharedMap`. If one does not yet exist, a new `SharedMap`
|
|
@@ -16,6 +16,7 @@ import { isPrevStateCallback } from "../internal";
|
|
|
16
16
|
* Values set through this state is automatically attached to a `SharedMap` that the `AzureProvider`
|
|
17
17
|
* creates. If you are synchronizing complex data structures that multiple users will be setting simultaneously,
|
|
18
18
|
* consider using an optimized hook for your data structure (e.g., `useSharedMap`, `useSharedString`, etc.).
|
|
19
|
+
* This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
|
|
19
20
|
*
|
|
20
21
|
* @template S Typing for objects stored associated with the `uniqueKey`.
|
|
21
22
|
* @param uniqueKey the unique key for a `SharedMap`. If you use the same key for multiple components, those components will reference the same state.
|
|
@@ -14,6 +14,9 @@ import {
|
|
|
14
14
|
UpdateSharedStateAction,
|
|
15
15
|
} from "../types";
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Response for the {@link useSharedStateRegistry} hook.
|
|
19
|
+
*/
|
|
17
20
|
export interface ISharedStateRegistryResponse {
|
|
18
21
|
/**
|
|
19
22
|
* Register a set state action callback
|
|
@@ -36,6 +39,9 @@ export interface ISharedStateRegistryResponse {
|
|
|
36
39
|
/**
|
|
37
40
|
* 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.
|
|
38
41
|
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Use this if you are building a custom `LiveShareProvider` or `AzureProvider` implementation in your app.
|
|
44
|
+
*
|
|
39
45
|
* @param results IAzureContainerResults response or undefined
|
|
40
46
|
* @returns ISharedStateRegistryResponse object
|
|
41
47
|
*/
|