@microsoft/live-share-react 2.0.0-internal.12 → 2.0.0-internal.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 (113) hide show
  1. package/package.json +9 -9
  2. package/bin/index.d.ts +0 -7
  3. package/bin/index.d.ts.map +0 -1
  4. package/bin/index.js +0 -7
  5. package/bin/index.js.map +0 -1
  6. package/bin/interfaces/LiveInterfaceExtensions.d.ts +0 -26
  7. package/bin/interfaces/LiveInterfaceExtensions.d.ts.map +0 -1
  8. package/bin/interfaces/LiveInterfaceExtensions.js +0 -6
  9. package/bin/interfaces/LiveInterfaceExtensions.js.map +0 -1
  10. package/bin/interfaces/index.d.ts +0 -2
  11. package/bin/interfaces/index.d.ts.map +0 -1
  12. package/bin/interfaces/index.js +0 -2
  13. package/bin/interfaces/index.js.map +0 -1
  14. package/bin/internal/errors.d.ts +0 -41
  15. package/bin/internal/errors.d.ts.map +0 -1
  16. package/bin/internal/errors.js +0 -42
  17. package/bin/internal/errors.js.map +0 -1
  18. package/bin/internal/index.d.ts +0 -3
  19. package/bin/internal/index.d.ts.map +0 -1
  20. package/bin/internal/index.js +0 -3
  21. package/bin/internal/index.js.map +0 -1
  22. package/bin/internal/type-guards.d.ts +0 -11
  23. package/bin/internal/type-guards.d.ts.map +0 -1
  24. package/bin/internal/type-guards.js +0 -20
  25. package/bin/internal/type-guards.js.map +0 -1
  26. package/bin/live-hooks/index.d.ts +0 -8
  27. package/bin/live-hooks/index.d.ts.map +0 -1
  28. package/bin/live-hooks/index.js +0 -8
  29. package/bin/live-hooks/index.js.map +0 -1
  30. package/bin/live-hooks/useLiveCanvas.d.ts +0 -29
  31. package/bin/live-hooks/useLiveCanvas.d.ts.map +0 -1
  32. package/bin/live-hooks/useLiveCanvas.js +0 -160
  33. package/bin/live-hooks/useLiveCanvas.js.map +0 -1
  34. package/bin/live-hooks/useLiveEvent.d.ts +0 -23
  35. package/bin/live-hooks/useLiveEvent.d.ts.map +0 -1
  36. package/bin/live-hooks/useLiveEvent.js +0 -108
  37. package/bin/live-hooks/useLiveEvent.js.map +0 -1
  38. package/bin/live-hooks/useLiveFollowMode.d.ts +0 -24
  39. package/bin/live-hooks/useLiveFollowMode.d.ts.map +0 -1
  40. package/bin/live-hooks/useLiveFollowMode.js +0 -211
  41. package/bin/live-hooks/useLiveFollowMode.js.map +0 -1
  42. package/bin/live-hooks/useLivePresence.d.ts +0 -26
  43. package/bin/live-hooks/useLivePresence.d.ts.map +0 -1
  44. package/bin/live-hooks/useLivePresence.js +0 -106
  45. package/bin/live-hooks/useLivePresence.js.map +0 -1
  46. package/bin/live-hooks/useLiveState.d.ts +0 -21
  47. package/bin/live-hooks/useLiveState.d.ts.map +0 -1
  48. package/bin/live-hooks/useLiveState.js +0 -83
  49. package/bin/live-hooks/useLiveState.js.map +0 -1
  50. package/bin/live-hooks/useLiveTimer.d.ts +0 -25
  51. package/bin/live-hooks/useLiveTimer.d.ts.map +0 -1
  52. package/bin/live-hooks/useLiveTimer.js +0 -172
  53. package/bin/live-hooks/useLiveTimer.js.map +0 -1
  54. package/bin/live-hooks/useMediaSynchronizer.d.ts +0 -25
  55. package/bin/live-hooks/useMediaSynchronizer.d.ts.map +0 -1
  56. package/bin/live-hooks/useMediaSynchronizer.js +0 -234
  57. package/bin/live-hooks/useMediaSynchronizer.js.map +0 -1
  58. package/bin/providers/AzureProvider.d.ts +0 -113
  59. package/bin/providers/AzureProvider.d.ts.map +0 -1
  60. package/bin/providers/AzureProvider.js +0 -119
  61. package/bin/providers/AzureProvider.js.map +0 -1
  62. package/bin/providers/LiveShareProvider.d.ts +0 -91
  63. package/bin/providers/LiveShareProvider.d.ts.map +0 -1
  64. package/bin/providers/LiveShareProvider.js +0 -95
  65. package/bin/providers/LiveShareProvider.js.map +0 -1
  66. package/bin/providers/index.d.ts +0 -3
  67. package/bin/providers/index.d.ts.map +0 -1
  68. package/bin/providers/index.js +0 -3
  69. package/bin/providers/index.js.map +0 -1
  70. package/bin/shared-hooks/index.d.ts +0 -5
  71. package/bin/shared-hooks/index.d.ts.map +0 -1
  72. package/bin/shared-hooks/index.js +0 -5
  73. package/bin/shared-hooks/index.js.map +0 -1
  74. package/bin/shared-hooks/useDynamicDDS.d.ts +0 -23
  75. package/bin/shared-hooks/useDynamicDDS.d.ts.map +0 -1
  76. package/bin/shared-hooks/useDynamicDDS.js +0 -72
  77. package/bin/shared-hooks/useDynamicDDS.js.map +0 -1
  78. package/bin/shared-hooks/useSharedMap.d.ts +0 -23
  79. package/bin/shared-hooks/useSharedMap.d.ts.map +0 -1
  80. package/bin/shared-hooks/useSharedMap.js +0 -114
  81. package/bin/shared-hooks/useSharedMap.js.map +0 -1
  82. package/bin/shared-hooks/useSharedState.d.ts +0 -22
  83. package/bin/shared-hooks/useSharedState.d.ts.map +0 -1
  84. package/bin/shared-hooks/useSharedState.js +0 -74
  85. package/bin/shared-hooks/useSharedState.js.map +0 -1
  86. package/bin/shared-hooks/useSharedStateRegistry.d.ts +0 -37
  87. package/bin/shared-hooks/useSharedStateRegistry.d.ts.map +0 -1
  88. package/bin/shared-hooks/useSharedStateRegistry.js +0 -105
  89. package/bin/shared-hooks/useSharedStateRegistry.js.map +0 -1
  90. package/bin/types/ActionTypes.d.ts +0 -112
  91. package/bin/types/ActionTypes.d.ts.map +0 -1
  92. package/bin/types/ActionTypes.js +0 -6
  93. package/bin/types/ActionTypes.js.map +0 -1
  94. package/bin/types/PropTypes.d.ts +0 -8
  95. package/bin/types/PropTypes.d.ts.map +0 -1
  96. package/bin/types/PropTypes.js +0 -6
  97. package/bin/types/PropTypes.js.map +0 -1
  98. package/bin/types/ResultTypes.d.ts +0 -302
  99. package/bin/types/ResultTypes.d.ts.map +0 -1
  100. package/bin/types/ResultTypes.js +0 -6
  101. package/bin/types/ResultTypes.js.map +0 -1
  102. package/bin/types/index.d.ts +0 -4
  103. package/bin/types/index.d.ts.map +0 -1
  104. package/bin/types/index.js +0 -4
  105. package/bin/types/index.js.map +0 -1
  106. package/bin/utils/index.d.ts +0 -2
  107. package/bin/utils/index.d.ts.map +0 -1
  108. package/bin/utils/index.js +0 -2
  109. package/bin/utils/index.js.map +0 -1
  110. package/bin/utils/type-check.d.ts +0 -15
  111. package/bin/utils/type-check.d.ts.map +0 -1
  112. package/bin/utils/type-check.js +0 -54
  113. package/bin/utils/type-check.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/live-share-react",
3
- "version": "2.0.0-internal.12",
3
+ "version": "2.0.0-internal.14",
4
4
  "description": "Build collaborative React apps using Microsoft's Fluid & Live Share frameworks with ease.",
5
5
  "author": "Microsoft",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -32,21 +32,21 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@babel/core": "^7.21.8",
35
- "@microsoft/live-share": "2.0.0-internal.12",
36
- "@microsoft/live-share-canvas": "2.0.0-internal.12",
37
- "@microsoft/live-share-media": "2.0.0-internal.12",
35
+ "@microsoft/live-share": "2.0.0-internal.14",
36
+ "@microsoft/live-share-canvas": "2.0.0-internal.14",
37
+ "@microsoft/live-share-media": "2.0.0-internal.14",
38
38
  "@types/react": "^18.0.0",
39
39
  "@types/react-dom": "^18.0.0",
40
40
  "@types/uuid": "^9.0.1",
41
41
  "babel-loader": "^9.1.2",
42
- "fluid-framework": ">=2.40 <2.70",
42
+ "fluid-framework": ">=2.40 <2.90",
43
43
  "typescript": "~5.5.3"
44
44
  },
45
45
  "peerDependencies": {
46
- "@microsoft/live-share": "2.0.0-internal.12",
47
- "@microsoft/live-share-canvas": "2.0.0-internal.12",
48
- "@microsoft/live-share-media": "2.0.0-internal.12",
49
- "fluid-framework": ">=2.40 <2.70",
46
+ "@microsoft/live-share": "2.0.0-internal.14",
47
+ "@microsoft/live-share-canvas": "2.0.0-internal.14",
48
+ "@microsoft/live-share-media": "2.0.0-internal.14",
49
+ "fluid-framework": ">=2.40 <2.90",
50
50
  "react": "^16.8.0 || ^17 || ^18",
51
51
  "react-dom": "^16.8.0 || ^17 || ^18"
52
52
  },
package/bin/index.d.ts DELETED
@@ -1,7 +0,0 @@
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
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
package/bin/index.js DELETED
@@ -1,7 +0,0 @@
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
- //# sourceMappingURL=index.js.map
package/bin/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
@@ -1,26 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- /**
6
- * Object response for a received event
7
- */
8
- export interface IReceiveLiveEvent<TEvent = any> {
9
- /**
10
- * The value of the event that was sent
11
- */
12
- value: TEvent;
13
- /**
14
- * True if the local client was the one to send this event
15
- */
16
- local: boolean;
17
- /**
18
- * Client ID of the user that sent the event
19
- */
20
- clientId: string;
21
- /**
22
- * Server timestamp at which the event was sent
23
- */
24
- timestamp: number;
25
- }
26
- //# sourceMappingURL=LiveInterfaceExtensions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LiveInterfaceExtensions.d.ts","sourceRoot":"","sources":["../../src/interfaces/LiveInterfaceExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,GAAG;IAC3C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACrB"}
@@ -1,6 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- export {};
6
- //# sourceMappingURL=LiveInterfaceExtensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LiveInterfaceExtensions.js","sourceRoot":"","sources":["../../src/interfaces/LiveInterfaceExtensions.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -1,2 +0,0 @@
1
- export * from "./LiveInterfaceExtensions";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from "./LiveInterfaceExtensions";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -1,41 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- declare class UseLiveDataObjectActionError extends Error {
5
- constructor(ddsName: string, functionName: string, message: string);
6
- }
7
- /**
8
- * @hidden
9
- */
10
- export declare class ActionContainerNotJoinedError extends UseLiveDataObjectActionError {
11
- constructor(ddsName: string, functionName: string);
12
- }
13
- /**
14
- * @hidden
15
- */
16
- export declare class ActionLiveDataObjectUndefinedError extends UseLiveDataObjectActionError {
17
- constructor(ddsName: string, functionName: string);
18
- }
19
- /**
20
- * @hidden
21
- */
22
- export declare class ActionLiveDataObjectInitializedError extends UseLiveDataObjectActionError {
23
- constructor(ddsName: string, functionName: string);
24
- }
25
- /**
26
- * @hidden
27
- */
28
- export interface ITeamsJsSdkError {
29
- /**
30
- * error code
31
- */
32
- errorCode: number;
33
- /**
34
- * Optional description for the error. This may contain useful information for web-app developers.
35
- * This string will not be localized and is not for end-user consumption.
36
- * App should not depend on the string content. The exact value may change. This is only for debugging purposes.
37
- */
38
- message?: string;
39
- }
40
- export {};
41
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/internal/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAM,4BAA6B,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAIrE;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,4BAA4B;gBAC/D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAOpD;AAED;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,4BAA4B;gBACpE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAQpD;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,4BAA4B;gBACtE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAQpD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -1,42 +0,0 @@
1
- /**
2
- * @hidden
3
- */
4
- class UseLiveDataObjectActionError extends Error {
5
- constructor(ddsName, functionName, message) {
6
- const hookName = `use${toFirstLetterUppercase(ddsName)}`;
7
- super(`${hookName} ${functionName}: ${message}`);
8
- }
9
- }
10
- /**
11
- * @hidden
12
- */
13
- export class ActionContainerNotJoinedError extends UseLiveDataObjectActionError {
14
- constructor(ddsName, functionName) {
15
- super(ddsName, functionName, "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.");
16
- }
17
- }
18
- /**
19
- * @hidden
20
- */
21
- export class ActionLiveDataObjectUndefinedError extends UseLiveDataObjectActionError {
22
- constructor(ddsName, functionName) {
23
- const hookName = `use${toFirstLetterUppercase(ddsName)}`;
24
- super(ddsName, functionName, `${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.`);
25
- }
26
- }
27
- /**
28
- * @hidden
29
- */
30
- export class ActionLiveDataObjectInitializedError extends UseLiveDataObjectActionError {
31
- constructor(ddsName, functionName) {
32
- const hookName = `use${toFirstLetterUppercase(ddsName)}`;
33
- super(ddsName, functionName, `${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.`);
34
- }
35
- }
36
- /**
37
- * @hidden
38
- */
39
- function toFirstLetterUppercase(word) {
40
- return word[0].toUpperCase() + word.substring(1);
41
- }
42
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/internal/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,4BAA6B,SAAQ,KAAK;IAC5C,YAAY,OAAe,EAAE,YAAoB,EAAE,OAAe;QAC9D,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,KAAK,CAAC,GAAG,QAAQ,IAAI,YAAY,KAAK,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,4BAA4B;IAC3E,YAAY,OAAe,EAAE,YAAoB;QAC7C,KAAK,CACD,OAAO,EACP,YAAY,EACZ,oSAAoS,CACvS,CAAC;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,4BAA4B;IAChF,YAAY,OAAe,EAAE,YAAoB;QAC7C,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,KAAK,CACD,OAAO,EACP,YAAY,EACZ,GAAG,OAAO,uGAAuG,OAAO,kCAAkC,QAAQ,8CAA8C,CACnN,CAAC;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,4BAA4B;IAClF,YAAY,OAAe,EAAE,YAAoB;QAC7C,MAAM,QAAQ,GAAG,MAAM,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,KAAK,CACD,OAAO,EACP,YAAY,EACZ,GAAG,OAAO,8DAA8D,OAAO,yDAAyD,QAAQ,mCAAmC,CACtL,CAAC;IACN,CAAC;CACJ;AAkBD;;GAEG;AACH,SAAS,sBAAsB,CAAC,IAAY;IACxC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from "./errors";
2
- export * from "./type-guards";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from "./errors";
2
- export * from "./type-guards";
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
@@ -1,11 +0,0 @@
1
- import { ITeamsJsSdkError } from "./errors";
2
- /**
3
- * @hidden
4
- * Used for useLiveState and useSharedState for checking if a value is a prevState callback
5
- */
6
- export declare function isPrevStateCallback<TState>(value: any): value is (value: TState) => TState;
7
- /**
8
- * @hidden
9
- */
10
- export declare function isITeamsJsSdkError(value: any): value is ITeamsJsSdkError;
11
- //# sourceMappingURL=type-guards.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../../src/internal/type-guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EACtC,KAAK,EAAE,GAAG,GACX,KAAK,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAEpC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,gBAAgB,CAKxE"}
@@ -1,20 +0,0 @@
1
- /**
2
- * @hidden
3
- * Used for useLiveState and useSharedState for checking if a value is a prevState callback
4
- */
5
- export function isPrevStateCallback(value) {
6
- return typeof value === "function";
7
- }
8
- /**
9
- * @hidden
10
- */
11
- export function isITeamsJsSdkError(value) {
12
- if (!value)
13
- return false;
14
- if (typeof value.errorCode !== "number")
15
- return false;
16
- if (value.message === undefined)
17
- return true;
18
- return typeof value.message === "string";
19
- }
20
- //# sourceMappingURL=type-guards.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-guards.js","sourceRoot":"","sources":["../../src/internal/type-guards.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAC/B,KAAU;IAEV,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAU;IACzC,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACzB,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC7C,OAAO,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AAC7C,CAAC"}
@@ -1,8 +0,0 @@
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";
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/live-hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
@@ -1,8 +0,0 @@
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";
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/live-hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
@@ -1,29 +0,0 @@
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
- * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
15
- *
16
- * @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
17
- * @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
18
- * @param active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
19
- * @param tool Optional. Stateful enum for what tool to use in the `InkingManager`.
20
- * @param lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
21
- * @param offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
22
- * @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
23
- * @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
24
- * @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
25
- * @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
26
- * @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
27
- */
28
- 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;
29
- //# sourceMappingURL=useLiveCanvas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLiveCanvas.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,oBAAoB,EACpB,MAAM,EAEN,UAAU,EACV,MAAM,EAET,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,MAAM,EAC9D,MAAM,CAAC,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,oBAAoB,EACrC,cAAc,CAAC,EAAE,OAAO,EACxB,mBAAmB,CAAC,EAAE,MAAM,GAC7B,qBAAqB,CA6IvB"}
@@ -1,160 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- import { InkingManager, LiveCanvas, } from "@microsoft/live-share-canvas";
6
- import React from "react";
7
- import { useDynamicDDS } from "../shared-hooks";
8
- import { isRefObject } from "../utils";
9
- /**
10
- * React hook for using a Live Share Canvas `LiveCanvas` and `InkingManager`.
11
- *
12
- * @remarks
13
- * Use this hook to set up an `LiveCanvas` object, which is used for collaborative inking. It takes several input parameters, including a unique key,
14
- * a reference to a canvas element, and various settings for the inking tool, brush, and canvas offset and scale.
15
- * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
16
- *
17
- * @param uniqueKey the unique key for the `LiveCanvas`. If one does not yet exist, a new one.
18
- * @param canvasElementRef the HTML div element ref or document ID that `InkingManager` will use for canvas-based collaboration.
19
- * @param active Optional. Stateful boolean that will activate/de-activate `InkingManager` accordingly.
20
- * @param tool Optional. Stateful enum for what tool to use in the `InkingManager`.
21
- * @param lineBrush Optional. Stateful lineBrush object for the selected lineBrush options to use in `InkingManager`.
22
- * @param offset Optional. Stateful offset point to use in the `InkingManager`. Gets the viewport offset. Defaults to 0,0.
23
- * @param scale Optional. Stateful scale number to use in the `InkingManager`. Defaults to 1 and must be greater than 0.
24
- * @param referencePoint Optional. Stateful reference point enum to use in the `InkingManger`. Defaults to "center".
25
- * @param isCursorShared Optional. Stateful boolean flag for whether cursor should be shared in `LiveCanvas`. Defaults to false.
26
- * @param localUserPictureUrl Optional. url string for the local user to display alongside their cursor. Defaults to undefined.
27
- * @returns IUseLiveCanvasResults object that contains the `liveCanvas` data object and `inkingManager`.
28
- */
29
- export function useLiveCanvas(uniqueKey, canvasElementRef, active, tool, lineBrush, offset, scale, referencePoint, isCursorShared, localUserPictureUrl) {
30
- /**
31
- * User facing: inking manager instance
32
- */
33
- const [inkingManager, setInkingManager] = React.useState();
34
- /**
35
- * User facing: dynamically load the DDS for the given unique key.
36
- */
37
- const { dds: liveCanvas } = useDynamicDDS(uniqueKey, LiveCanvas);
38
- /**
39
- * Setup the InkingManager and LiveCanvas
40
- */
41
- React.useEffect(() => {
42
- // if the component is already listening or liveCanvas is not yet initialized, return
43
- if (!liveCanvas)
44
- return;
45
- // get the canvas element from the ref or document
46
- let htmlElement;
47
- if (isRefObject(canvasElementRef)) {
48
- htmlElement = canvasElementRef.current;
49
- }
50
- else {
51
- htmlElement = document.getElementById(canvasElementRef);
52
- }
53
- if (htmlElement === null)
54
- return;
55
- // Create the InkingManager and initialize the liveCanvas with it
56
- const inkingManager = new InkingManager(htmlElement);
57
- setInkingManager(inkingManager);
58
- liveCanvas.initialize(inkingManager);
59
- // cleanup function to be called when the component is unmount
60
- return () => {
61
- liveCanvas.dispose();
62
- inkingManager.removeAllListeners();
63
- };
64
- }, [liveCanvas]);
65
- /**
66
- * Activate or deactivate the inkingManager based on the 'active' prop
67
- */
68
- React.useEffect(() => {
69
- if (inkingManager && active !== undefined) {
70
- if (active) {
71
- inkingManager.activate();
72
- }
73
- else {
74
- inkingManager.deactivate();
75
- }
76
- }
77
- }, [active, inkingManager]);
78
- /**
79
- * Sets the tool of the inkingManager based on the 'tool' prop
80
- */
81
- React.useEffect(() => {
82
- if (inkingManager && tool !== undefined) {
83
- inkingManager.tool = tool;
84
- }
85
- }, [tool, inkingManager]);
86
- /**
87
- * Sets the offset of the inkingManager based on the 'offset' prop
88
- */
89
- React.useEffect(() => {
90
- if (inkingManager && offset !== undefined) {
91
- inkingManager.offset = {
92
- x: offset.x,
93
- y: offset.y,
94
- };
95
- }
96
- }, [offset === null || offset === void 0 ? void 0 : offset.x, offset === null || offset === void 0 ? void 0 : offset.y, inkingManager]);
97
- /**
98
- * Sets the scale of the inkingManager based on the 'scale' prop
99
- */
100
- React.useEffect(() => {
101
- if (inkingManager && scale !== undefined) {
102
- inkingManager.scale = scale;
103
- }
104
- }, [scale, inkingManager]);
105
- /**
106
- * Sets the referencePoint of the inkingManager based on the 'referencePoint' prop
107
- */
108
- React.useEffect(() => {
109
- if (inkingManager && referencePoint !== undefined) {
110
- inkingManager.referencePoint = referencePoint;
111
- }
112
- }, [referencePoint, inkingManager]);
113
- /**
114
- * Sets the lineBrush of the inkingManager based on the 'lineBrush' prop
115
- */
116
- React.useEffect(() => {
117
- if (inkingManager && lineBrush) {
118
- inkingManager.lineBrush = {
119
- color: lineBrush.color,
120
- tip: lineBrush.tip,
121
- tipSize: lineBrush.tipSize,
122
- type: lineBrush.type,
123
- endArrow: lineBrush.endArrow,
124
- };
125
- }
126
- }, [
127
- lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.color,
128
- lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.tip,
129
- lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.tipSize,
130
- lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.type,
131
- lineBrush === null || lineBrush === void 0 ? void 0 : lineBrush.endArrow,
132
- inkingManager,
133
- ]);
134
- /**
135
- * Sets the isCursorShared of the liveCanvas based on the 'isCursorShared' prop
136
- */
137
- React.useEffect(() => {
138
- if (liveCanvas && isCursorShared !== undefined) {
139
- liveCanvas.isCursorShared = isCursorShared;
140
- }
141
- }, [isCursorShared, liveCanvas]);
142
- /**
143
- * Sets the onGetLocalUserInfo method of the liveCanvas based on the 'localUserCursor' prop
144
- */
145
- React.useEffect(() => {
146
- if (liveCanvas && localUserPictureUrl) {
147
- liveCanvas.onGetLocalUserPictureUrl = () => {
148
- return localUserPictureUrl;
149
- };
150
- }
151
- }, [localUserPictureUrl, liveCanvas]);
152
- /**
153
- * Return hook response
154
- */
155
- return {
156
- inkingManager,
157
- liveCanvas,
158
- };
159
- }
160
- //# sourceMappingURL=useLiveCanvas.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLiveCanvas.js","sourceRoot":"","sources":["../../src/live-hooks/useLiveCanvas.ts"],"names":[],"mappings":"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"}
@@ -1,23 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- import { UserMeetingRole } from "@microsoft/live-share";
6
- import { IUseLiveEventResults, OnReceivedLiveEventAction } from "../types";
7
- /**
8
- * React hook for using a Live Share `LiveEvent`.
9
- *
10
- * @remarks
11
- * Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container,
12
- * such as when sending push notifications or reactions.
13
- * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
14
- *
15
- * @template TEvent Optional typing for events sent & received. Default is `object` type.
16
- * @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one
17
- * will be created, otherwise it will use the existing one.
18
- * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
19
- * @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
20
- * @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
21
- */
22
- export declare function useLiveEvent<TEvent = any>(uniqueKey: string, allowedRoles?: UserMeetingRole[], onReceivedEvent?: OnReceivedLiveEventAction<TEvent>): IUseLiveEventResults<TEvent>;
23
- //# sourceMappingURL=useLiveEvent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLiveEvent.d.ts","sourceRoot":"","sources":["../../src/live-hooks/useLiveEvent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEH,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACH,oBAAoB,EACpB,yBAAyB,EAE5B,MAAM,UAAU,CAAC;AAUlB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,GAAG,EACrC,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,eAAe,EAAE,EAChC,eAAe,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,GACpD,oBAAoB,CAAC,MAAM,CAAC,CAoG9B"}
@@ -1,108 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the Microsoft Live Share SDK License.
4
- */
5
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
6
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
7
- return new (P || (P = Promise))(function (resolve, reject) {
8
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11
- step((generator = generator.apply(thisArg, _arguments || [])).next());
12
- });
13
- };
14
- import { LiveEventEvents, LiveEvent, LiveDataObjectInitializeState, } from "@microsoft/live-share";
15
- import React from "react";
16
- import { useDynamicDDS } from "../shared-hooks";
17
- import { ActionContainerNotJoinedError, ActionLiveDataObjectInitializedError, ActionLiveDataObjectUndefinedError, } from "../internal";
18
- import { useFluidObjectsContext } from "../providers";
19
- /**
20
- * React hook for using a Live Share `LiveEvent`.
21
- *
22
- * @remarks
23
- * Use this hook if you want to send transient JSON objects to everyone connected to the Fluid container,
24
- * such as when sending push notifications or reactions.
25
- * This hook can only be used in a child component of `<LiveShareProvider>` or `<AzureProvider>`.
26
- *
27
- * @template TEvent Optional typing for events sent & received. Default is `object` type.
28
- * @param uniqueKey the unique key for the `LiveEvent`. If one does not yet exist, a new one
29
- * will be created, otherwise it will use the existing one.
30
- * @param allowedRoles Optional. The meeting roles eligible to send events through this object.
31
- * @param onReceivedEvent Optional. Callback method to be called when a new notification is received.
32
- * @returns stateful `latestEvent` & `allEvents` list, `sendEvent` callback, and the `liveEvent` object.
33
- */
34
- export function useLiveEvent(uniqueKey, allowedRoles, onReceivedEvent) {
35
- /**
36
- * Stateful latest event (user facing) and its non-user-facing setter method.
37
- */
38
- const [latestEvent, setLatestReceived] = React.useState();
39
- /**
40
- * Reference for all received/sent events. The current value of this is user-facing. Because
41
- * this is always set at the same time as latestEvent, it is effectively a stateful value.
42
- */
43
- const allEventsRef = React.useRef([]);
44
- /**
45
- * User facing: dynamically load the DDS for the given unique key.
46
- */
47
- const { dds: liveEvent } = useDynamicDDS(uniqueKey, (LiveEvent));
48
- const { container } = useFluidObjectsContext();
49
- /**
50
- * User facing: callback to send event through `LiveEvent`
51
- */
52
- const sendEvent = React.useCallback((event) => __awaiter(this, void 0, void 0, function* () {
53
- if (!container) {
54
- throw new ActionContainerNotJoinedError("liveEvent", "sendEvent");
55
- }
56
- if (liveEvent === undefined) {
57
- throw new ActionLiveDataObjectUndefinedError("liveEvent", "sendEvent");
58
- }
59
- if (!liveEvent.isInitialized) {
60
- throw new ActionLiveDataObjectInitializedError("liveEvent", "sendEvent");
61
- }
62
- return yield liveEvent.send(event);
63
- }), [container, liveEvent]);
64
- /**
65
- * Setup change listeners and start `LiveEvent` if needed
66
- */
67
- React.useEffect(() => {
68
- if ((liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.isInitialized) === undefined)
69
- return;
70
- // Register event listener
71
- const onEventReceived = (event, local, clientId, timestamp) => {
72
- // If developer passed the optional onReceivedEvent callback, we
73
- // call it.
74
- onReceivedEvent === null || onReceivedEvent === void 0 ? void 0 : onReceivedEvent(event, local);
75
- // Set the received event to our local state
76
- const received = {
77
- value: event,
78
- local,
79
- clientId,
80
- timestamp,
81
- };
82
- allEventsRef.current = [...allEventsRef.current, received];
83
- setLatestReceived(received);
84
- };
85
- // Reset the events list if it allEventRef.current is non-empty.
86
- // This happens when the `id` a developer provides changes on the fly.
87
- if (allEventsRef.current.length > 0) {
88
- allEventsRef.current = [];
89
- setLatestReceived(undefined);
90
- }
91
- liveEvent.on(LiveEventEvents.received, onEventReceived);
92
- if (liveEvent.initializeState === LiveDataObjectInitializeState.needed) {
93
- // Start live event
94
- liveEvent.initialize(allowedRoles);
95
- }
96
- return () => {
97
- // on unmount, remove event listeners
98
- liveEvent === null || liveEvent === void 0 ? void 0 : liveEvent.off(LiveEventEvents.received, onEventReceived);
99
- };
100
- }, [liveEvent]);
101
- return {
102
- latestEvent,
103
- allEvents: allEventsRef.current,
104
- sendEvent,
105
- liveEvent,
106
- };
107
- }
108
- //# sourceMappingURL=useLiveEvent.js.map