@microsoft/live-share-react 1.3.0-preview.0 → 1.3.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/.nycrc.json +9 -9
- package/LICENSE +86 -86
- package/README.md +608 -608
- package/package.json +50 -50
- package/src/index.ts +6 -6
- package/src/interfaces/LiveInterfaceExtensions.ts +26 -26
- package/src/interfaces/index.ts +1 -1
- package/src/internal/errors.ts +57 -57
- package/src/internal/index.ts +2 -2
- package/src/internal/type-guards.ts +9 -9
- package/src/live-hooks/index.ts +7 -7
- package/src/live-hooks/useLiveCanvas.ts +191 -191
- package/src/live-hooks/useLiveEvent.ts +140 -140
- package/src/live-hooks/useLiveFollowMode.ts +316 -316
- package/src/live-hooks/useLivePresence.ts +147 -147
- package/src/live-hooks/useLiveState.ts +110 -110
- package/src/live-hooks/useLiveTimer.ts +213 -213
- package/src/live-hooks/useMediaSynchronizer.ts +295 -295
- package/src/providers/AzureProvider.tsx +261 -261
- package/src/providers/LiveShareProvider.tsx +210 -210
- package/src/providers/index.ts +2 -2
- package/src/shared-hooks/index.ts +4 -4
- package/src/shared-hooks/useDynamicDDS.ts +82 -82
- package/src/shared-hooks/useSharedMap.ts +159 -159
- package/src/shared-hooks/useSharedState.ts +96 -96
- package/src/shared-hooks/useSharedStateRegistry.ts +170 -170
- package/src/types/ActionTypes.ts +161 -161
- package/src/types/PropTypes.ts +10 -10
- package/src/types/ResultTypes.ts +332 -332
- package/src/types/index.ts +3 -3
- package/src/utils/index.ts +1 -1
- package/src/utils/type-check.ts +69 -69
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +72 -72
- package/bin/internal/useSharedStateRegistry.d.ts +0 -31
- package/bin/internal/useSharedStateRegistry.d.ts.map +0 -1
- package/bin/internal/useSharedStateRegistry.js +0 -102
- package/bin/internal/useSharedStateRegistry.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@microsoft/live-share-react",
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"description": "Build collaborative React apps using Microsoft's Fluid & Live Share frameworks with ease.",
|
|
5
|
-
"author": "Microsoft",
|
|
6
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
-
"main": "./bin/index.js",
|
|
8
|
-
"types": "./bin/index.d.ts",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"clean": "npx shx rm -rf bin",
|
|
11
|
-
"build": "tsc -p tsconfig.build.json",
|
|
12
|
-
"typecheck": "tsc"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"@microsoft/live-share-turbo": "1.3.
|
|
16
|
-
"url": "^0.11.0",
|
|
17
|
-
"uuid": "^9.0.0"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@babel/core": "^7.21.8",
|
|
21
|
-
"@fluidframework/azure-client": "^1.1.1",
|
|
22
|
-
"@fluidframework/test-client-utils": "^1.3.6",
|
|
23
|
-
"@microsoft/live-share": "1.3.
|
|
24
|
-
"@microsoft/live-share-canvas": "1.3.
|
|
25
|
-
"@microsoft/live-share-media": "1.3.
|
|
26
|
-
"@types/react": "^18.0.0",
|
|
27
|
-
"@types/react-dom": "^18.0.0",
|
|
28
|
-
"@types/uuid": "^9.0.1",
|
|
29
|
-
"babel-loader": "^9.1.2",
|
|
30
|
-
"fluid-framework": "^1.3.6",
|
|
31
|
-
"typescript": "^5.0.4"
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"@fluidframework/azure-client": "^1.0.0",
|
|
35
|
-
"@microsoft/live-share": "1.3.
|
|
36
|
-
"@microsoft/live-share-canvas": "1.3.
|
|
37
|
-
"@microsoft/live-share-media": "1.3.
|
|
38
|
-
"fluid-framework": "^1.2.3",
|
|
39
|
-
"react": "^16.8.0 || ^17 || ^18",
|
|
40
|
-
"react-dom": "^16.8.0 || ^17 || ^18"
|
|
41
|
-
},
|
|
42
|
-
"repository": {
|
|
43
|
-
"directory": "packages/live-share-react",
|
|
44
|
-
"type": "git",
|
|
45
|
-
"url": "https://github.com/microsoft/live-share-sdk"
|
|
46
|
-
},
|
|
47
|
-
"homepage": "https://aka.ms/teamsliveshare",
|
|
48
|
-
"bugs": {
|
|
49
|
-
"url": "https://github.com/microsoft/live-share-sdk/issues"
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/live-share-react",
|
|
3
|
+
"version": "1.3.1-preview.0",
|
|
4
|
+
"description": "Build collaborative React apps using Microsoft's Fluid & Live Share frameworks with ease.",
|
|
5
|
+
"author": "Microsoft",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"main": "./bin/index.js",
|
|
8
|
+
"types": "./bin/index.d.ts",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "npx shx rm -rf bin",
|
|
11
|
+
"build": "tsc -p tsconfig.build.json",
|
|
12
|
+
"typecheck": "tsc"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@microsoft/live-share-turbo": "1.3.1-preview.0",
|
|
16
|
+
"url": "^0.11.0",
|
|
17
|
+
"uuid": "^9.0.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@babel/core": "^7.21.8",
|
|
21
|
+
"@fluidframework/azure-client": "^1.1.1",
|
|
22
|
+
"@fluidframework/test-client-utils": "^1.3.6",
|
|
23
|
+
"@microsoft/live-share": "1.3.1",
|
|
24
|
+
"@microsoft/live-share-canvas": "1.3.1",
|
|
25
|
+
"@microsoft/live-share-media": "1.3.1",
|
|
26
|
+
"@types/react": "^18.0.0",
|
|
27
|
+
"@types/react-dom": "^18.0.0",
|
|
28
|
+
"@types/uuid": "^9.0.1",
|
|
29
|
+
"babel-loader": "^9.1.2",
|
|
30
|
+
"fluid-framework": "^1.3.6",
|
|
31
|
+
"typescript": "^5.0.4"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@fluidframework/azure-client": "^1.0.0",
|
|
35
|
+
"@microsoft/live-share": "1.3.1",
|
|
36
|
+
"@microsoft/live-share-canvas": "1.3.1",
|
|
37
|
+
"@microsoft/live-share-media": "1.3.1",
|
|
38
|
+
"fluid-framework": "^1.2.3",
|
|
39
|
+
"react": "^16.8.0 || ^17 || ^18",
|
|
40
|
+
"react-dom": "^16.8.0 || ^17 || ^18"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"directory": "packages/live-share-react",
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/microsoft/live-share-sdk"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://aka.ms/teamsliveshare",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/microsoft/live-share-sdk/issues"
|
|
50
|
+
}
|
|
51
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./providers";
|
|
2
|
-
export * from "./shared-hooks";
|
|
3
|
-
export * from "./live-hooks";
|
|
4
|
-
export * from "./types";
|
|
5
|
-
export * from "./providers";
|
|
6
|
-
export * from "./interfaces";
|
|
1
|
+
export * from "./providers";
|
|
2
|
+
export * from "./shared-hooks";
|
|
3
|
+
export * from "./live-hooks";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./providers";
|
|
6
|
+
export * from "./interfaces";
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Object response for a received event
|
|
8
|
-
*/
|
|
9
|
-
export interface IReceiveLiveEvent<TEvent = any> {
|
|
10
|
-
/**
|
|
11
|
-
* The value of the event that was sent
|
|
12
|
-
*/
|
|
13
|
-
value: TEvent;
|
|
14
|
-
/**
|
|
15
|
-
* True if the local client was the one to send this event
|
|
16
|
-
*/
|
|
17
|
-
local: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Client ID of the user that sent the event
|
|
20
|
-
*/
|
|
21
|
-
clientId: string;
|
|
22
|
-
/**
|
|
23
|
-
* Server timestamp at which the event was sent
|
|
24
|
-
*/
|
|
25
|
-
timestamp: number;
|
|
26
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the Microsoft Live Share SDK License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Object response for a received event
|
|
8
|
+
*/
|
|
9
|
+
export interface IReceiveLiveEvent<TEvent = any> {
|
|
10
|
+
/**
|
|
11
|
+
* The value of the event that was sent
|
|
12
|
+
*/
|
|
13
|
+
value: TEvent;
|
|
14
|
+
/**
|
|
15
|
+
* True if the local client was the one to send this event
|
|
16
|
+
*/
|
|
17
|
+
local: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Client ID of the user that sent the event
|
|
20
|
+
*/
|
|
21
|
+
clientId: string;
|
|
22
|
+
/**
|
|
23
|
+
* Server timestamp at which the event was sent
|
|
24
|
+
*/
|
|
25
|
+
timestamp: number;
|
|
26
|
+
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./LiveInterfaceExtensions";
|
|
1
|
+
export * from "./LiveInterfaceExtensions";
|
package/src/internal/errors.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @hidden
|
|
3
|
-
*/
|
|
4
|
-
class UseLiveDataObjectActionError extends Error {
|
|
5
|
-
constructor(ddsName: string, functionName: string, message: string) {
|
|
6
|
-
const hookName = `use${toFirstLetterUppercase(ddsName)}`;
|
|
7
|
-
super(`${hookName} ${functionName}: ${message}`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @hidden
|
|
13
|
-
*/
|
|
14
|
-
export class ActionContainerNotJoinedError extends UseLiveDataObjectActionError {
|
|
15
|
-
constructor(ddsName: string, functionName: string) {
|
|
16
|
-
super(
|
|
17
|
-
ddsName,
|
|
18
|
-
functionName,
|
|
19
|
-
"container has not yet been joined.\nTo fix this error, ensure `container` from `useFluidObjectsContext()` is defined before calling this function.\nIf using `<LiveShareProvider>`, you can instead check the `joined` response is true from `useLiveShareContext()` before calling this function."
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @hidden
|
|
26
|
-
*/
|
|
27
|
-
export class ActionLiveDataObjectUndefinedError extends UseLiveDataObjectActionError {
|
|
28
|
-
constructor(ddsName: string, functionName: string) {
|
|
29
|
-
const hookName = `use${toFirstLetterUppercase(ddsName)}`;
|
|
30
|
-
super(
|
|
31
|
-
ddsName,
|
|
32
|
-
functionName,
|
|
33
|
-
`${ddsName} is undefined, which means it is still being dynamically created.\nTo fix this error, ensure that \`${ddsName}\` (found in the response of \`${hookName}\`) is defined before calling this function.`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @hidden
|
|
40
|
-
*/
|
|
41
|
-
export class ActionLiveDataObjectInitializedError extends UseLiveDataObjectActionError {
|
|
42
|
-
constructor(ddsName: string, functionName: string) {
|
|
43
|
-
const hookName = `use${toFirstLetterUppercase(ddsName)}`;
|
|
44
|
-
super(
|
|
45
|
-
ddsName,
|
|
46
|
-
functionName,
|
|
47
|
-
`${ddsName} is not yet initialized.\nTo fix this error, ensure that \`${ddsName}?.isInitialized\` is true (found in the response of \`${hookName}\`) before calling this function.`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @hidden
|
|
54
|
-
*/
|
|
55
|
-
function toFirstLetterUppercase(word: string) {
|
|
56
|
-
return word[0].toUpperCase() + word.substring(1);
|
|
57
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
*/
|
|
4
|
+
class UseLiveDataObjectActionError extends Error {
|
|
5
|
+
constructor(ddsName: string, functionName: string, message: string) {
|
|
6
|
+
const hookName = `use${toFirstLetterUppercase(ddsName)}`;
|
|
7
|
+
super(`${hookName} ${functionName}: ${message}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @hidden
|
|
13
|
+
*/
|
|
14
|
+
export class ActionContainerNotJoinedError extends UseLiveDataObjectActionError {
|
|
15
|
+
constructor(ddsName: string, functionName: string) {
|
|
16
|
+
super(
|
|
17
|
+
ddsName,
|
|
18
|
+
functionName,
|
|
19
|
+
"container has not yet been joined.\nTo fix this error, ensure `container` from `useFluidObjectsContext()` is defined before calling this function.\nIf using `<LiveShareProvider>`, you can instead check the `joined` response is true from `useLiveShareContext()` before calling this function."
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @hidden
|
|
26
|
+
*/
|
|
27
|
+
export class ActionLiveDataObjectUndefinedError extends UseLiveDataObjectActionError {
|
|
28
|
+
constructor(ddsName: string, functionName: string) {
|
|
29
|
+
const hookName = `use${toFirstLetterUppercase(ddsName)}`;
|
|
30
|
+
super(
|
|
31
|
+
ddsName,
|
|
32
|
+
functionName,
|
|
33
|
+
`${ddsName} is undefined, which means it is still being dynamically created.\nTo fix this error, ensure that \`${ddsName}\` (found in the response of \`${hookName}\`) is defined before calling this function.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
export class ActionLiveDataObjectInitializedError extends UseLiveDataObjectActionError {
|
|
42
|
+
constructor(ddsName: string, functionName: string) {
|
|
43
|
+
const hookName = `use${toFirstLetterUppercase(ddsName)}`;
|
|
44
|
+
super(
|
|
45
|
+
ddsName,
|
|
46
|
+
functionName,
|
|
47
|
+
`${ddsName} is not yet initialized.\nTo fix this error, ensure that \`${ddsName}?.isInitialized\` is true (found in the response of \`${hookName}\`) before calling this function.`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
function toFirstLetterUppercase(word: string) {
|
|
56
|
+
return word[0].toUpperCase() + word.substring(1);
|
|
57
|
+
}
|
package/src/internal/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./errors";
|
|
2
|
-
export * from "./type-guards";
|
|
1
|
+
export * from "./errors";
|
|
2
|
+
export * from "./type-guards";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @hidden
|
|
3
|
-
* Used for useLiveState and useSharedState for checking if a value is a prevState callback
|
|
4
|
-
*/
|
|
5
|
-
export function isPrevStateCallback<TState>(
|
|
6
|
-
value: any
|
|
7
|
-
): value is (value: TState) => TState {
|
|
8
|
-
return typeof value === "function";
|
|
9
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
* Used for useLiveState and useSharedState for checking if a value is a prevState callback
|
|
4
|
+
*/
|
|
5
|
+
export function isPrevStateCallback<TState>(
|
|
6
|
+
value: any
|
|
7
|
+
): value is (value: TState) => TState {
|
|
8
|
+
return typeof value === "function";
|
|
9
|
+
}
|
package/src/live-hooks/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./useLivePresence";
|
|
2
|
-
export * from "./useLiveFollowMode";
|
|
3
|
-
export * from "./useLiveState";
|
|
4
|
-
export * from "./useMediaSynchronizer";
|
|
5
|
-
export * from "./useLiveEvent";
|
|
6
|
-
export * from "./useLiveCanvas";
|
|
7
|
-
export * from "./useLiveTimer";
|
|
1
|
+
export * from "./useLivePresence";
|
|
2
|
+
export * from "./useLiveFollowMode";
|
|
3
|
+
export * from "./useLiveState";
|
|
4
|
+
export * from "./useMediaSynchronizer";
|
|
5
|
+
export * from "./useLiveEvent";
|
|
6
|
+
export * from "./useLiveCanvas";
|
|
7
|
+
export * from "./useLiveTimer";
|