@microsoft/teamsfx-react 1.0.4-rc.0 → 2.0.0-beta.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/CHANGELOG.md +4 -0
- package/LICENSE +21 -21
- package/NOTICE.txt +14833 -0
- package/build/index.d.ts +3 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +11 -11
- package/build/useData.d.ts +17 -33
- package/build/useData.d.ts.map +1 -1
- package/build/useData.js +47 -45
- package/build/useGraph.d.ts +19 -18
- package/build/useGraph.d.ts.map +1 -1
- package/build/useGraph.js +65 -57
- package/build/useTeamsFx.d.ts +10 -41
- package/build/useTeamsFx.d.ts.map +1 -1
- package/build/useTeamsFx.js +35 -30
- package/package.json +10 -11
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { useData } from "./useData";
|
|
2
|
-
export { useTeamsFx
|
|
3
|
-
export { useGraph } from "./useGraph";
|
|
1
|
+
export { useData } from "./useData";
|
|
2
|
+
export { useTeamsFx } from "./useTeamsFx";
|
|
3
|
+
export { useGraph } from "./useGraph";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useGraph = exports.useTeamsFx = exports.useData = void 0;
|
|
6
|
-
var useData_1 = require("./useData");
|
|
7
|
-
Object.defineProperty(exports, "useData", { enumerable: true, get: function () { return useData_1.useData; } });
|
|
8
|
-
var useTeamsFx_1 = require("./useTeamsFx");
|
|
9
|
-
Object.defineProperty(exports, "useTeamsFx", { enumerable: true, get: function () { return useTeamsFx_1.useTeamsFx; } });
|
|
10
|
-
var useGraph_1 = require("./useGraph");
|
|
11
|
-
Object.defineProperty(exports, "useGraph", { enumerable: true, get: function () { return useGraph_1.useGraph; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useGraph = exports.useTeamsFx = exports.useData = void 0;
|
|
6
|
+
var useData_1 = require("./useData");
|
|
7
|
+
Object.defineProperty(exports, "useData", { enumerable: true, get: function () { return useData_1.useData; } });
|
|
8
|
+
var useTeamsFx_1 = require("./useTeamsFx");
|
|
9
|
+
Object.defineProperty(exports, "useTeamsFx", { enumerable: true, get: function () { return useTeamsFx_1.useTeamsFx; } });
|
|
10
|
+
var useGraph_1 = require("./useGraph");
|
|
11
|
+
Object.defineProperty(exports, "useGraph", { enumerable: true, get: function () { return useGraph_1.useGraph; } });
|
package/build/useData.d.ts
CHANGED
|
@@ -1,34 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
reload: () => void;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Helper function to fetch data with status and error.
|
|
23
|
-
*
|
|
24
|
-
* @param fetchDataAsync - async function of how to fetch data
|
|
25
|
-
* @param options - if autoLoad is true, reload data immediately
|
|
26
|
-
* @returns data, loading status, error and reload function
|
|
27
|
-
*
|
|
28
|
-
* @beta
|
|
29
|
-
*/
|
|
30
|
-
export declare function useData<T>(fetchDataAsync: () => Promise<T>, options?: {
|
|
31
|
-
autoLoad: boolean;
|
|
32
|
-
}): Data<T>;
|
|
33
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Helper function to fetch data with status and error.
|
|
3
|
+
*
|
|
4
|
+
* @param asyncFn - async function of how to fetch data
|
|
5
|
+
* @param options - if autoLoad is true, reload data immediately
|
|
6
|
+
* @returns data, loading status, error and reload function
|
|
7
|
+
*
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export declare function useData<T>(asyncFn: () => Promise<T>, options?: {
|
|
11
|
+
auto: boolean;
|
|
12
|
+
}): {
|
|
13
|
+
data: T | undefined;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
error: any;
|
|
16
|
+
reload: () => void;
|
|
17
|
+
};
|
|
34
18
|
//# sourceMappingURL=useData.d.ts.map
|
package/build/useData.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useData.d.ts","sourceRoot":"","sources":["../src/useData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useData.d.ts","sourceRoot":"","sources":["../src/useData.ts"],"names":[],"mappings":"AAsCA;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE;;;;;EAkBhF"}
|
package/build/useData.js
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useData = void 0;
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const createReducer = () => (state, action) => {
|
|
8
|
-
switch (action.type) {
|
|
9
|
-
case "loading":
|
|
10
|
-
return { data: state.data, loading: true };
|
|
11
|
-
case "result":
|
|
12
|
-
return { data: action.result, loading: false };
|
|
13
|
-
case "error":
|
|
14
|
-
return { loading: false, error: action.error };
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Helper function to fetch data with status and error.
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param options - if autoLoad is true, reload data immediately
|
|
22
|
-
* @returns data, loading status, error and reload function
|
|
23
|
-
*
|
|
24
|
-
* @beta
|
|
25
|
-
*/
|
|
26
|
-
function useData(
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useData = void 0;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const createReducer = () => (state, action) => {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case "loading":
|
|
10
|
+
return { data: state.data, loading: true };
|
|
11
|
+
case "result":
|
|
12
|
+
return { data: action.result, loading: false };
|
|
13
|
+
case "error":
|
|
14
|
+
return { loading: false, error: action.error };
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to fetch data with status and error.
|
|
19
|
+
*
|
|
20
|
+
* @param asyncFn - async function of how to fetch data
|
|
21
|
+
* @param options - if autoLoad is true, reload data immediately
|
|
22
|
+
* @returns data, loading status, error and reload function
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
function useData(asyncFn, options) {
|
|
27
|
+
const { auto } = Object.assign({ auto: true }, options);
|
|
28
|
+
const [{ data, loading, error }, dispatch] = (0, react_1.useReducer)(createReducer(), {
|
|
29
|
+
loading: !!auto,
|
|
30
|
+
});
|
|
31
|
+
function reload() {
|
|
32
|
+
if (!loading)
|
|
33
|
+
dispatch({ type: "loading" });
|
|
34
|
+
if (typeof asyncFn != "function") {
|
|
35
|
+
throw new Error("invalid argument to useData, a function is required");
|
|
36
|
+
}
|
|
37
|
+
asyncFn()
|
|
38
|
+
.then((data) => dispatch({ type: "result", result: data }))
|
|
39
|
+
.catch((error) => dispatch({ type: "error", error }));
|
|
40
|
+
}
|
|
41
|
+
(0, react_1.useEffect)(() => {
|
|
42
|
+
if (auto)
|
|
43
|
+
reload();
|
|
44
|
+
}, []);
|
|
45
|
+
return { data, loading, error, reload };
|
|
46
|
+
}
|
|
47
|
+
exports.useData = useData;
|
package/build/useGraph.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { TeamsFx } from "@microsoft/teamsfx";
|
|
2
|
+
import { Client } from "@microsoft/microsoft-graph-client";
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
5
|
+
*
|
|
6
|
+
* @param asyncFunc - async function of how to call Graph API and fetch data.
|
|
7
|
+
* @param options - teamsfx instance and OAuth resource scope.
|
|
8
|
+
* @returns data, loading status, error and reload function
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export declare function useGraph<T>(asyncFunc: (graph: Client, teamsfx: TeamsFx, scope: string[]) => Promise<T>, options?: {
|
|
13
|
+
scope: string[];
|
|
14
|
+
}): {
|
|
15
|
+
data: T | undefined;
|
|
16
|
+
error: any;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
reload: () => void;
|
|
19
|
+
};
|
|
19
20
|
//# sourceMappingURL=useGraph.d.ts.map
|
package/build/useGraph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGraph.d.ts","sourceRoot":"","sources":["../src/useGraph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGraph.d.ts","sourceRoot":"","sources":["../src/useGraph.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAA6C,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,MAAM,EAAc,MAAM,mCAAmC,CAAC;AAEvE;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAC3E,OAAO,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE;;;;;EAgD9B"}
|
package/build/useGraph.js
CHANGED
|
@@ -1,57 +1,65 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useGraph = void 0;
|
|
6
|
-
const useData_1 = require("./useData");
|
|
7
|
-
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
-
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @param
|
|
14
|
-
* @
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
if (err instanceof
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useGraph = void 0;
|
|
6
|
+
const useData_1 = require("./useData");
|
|
7
|
+
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
+
const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to call Microsoft Graph API with authentication.
|
|
11
|
+
*
|
|
12
|
+
* @param asyncFunc - async function of how to call Graph API and fetch data.
|
|
13
|
+
* @param options - teamsfx instance and OAuth resource scope.
|
|
14
|
+
* @returns data, loading status, error and reload function
|
|
15
|
+
*
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
function useGraph(asyncFunc, options) {
|
|
19
|
+
const { scope } = Object.assign({ scope: ["User.Read"] }, options);
|
|
20
|
+
const initial = (0, useData_1.useData)(async () => {
|
|
21
|
+
var _a;
|
|
22
|
+
try {
|
|
23
|
+
const teamsfx = new teamsfx_1.TeamsFx();
|
|
24
|
+
const graph = (0, teamsfx_1.createMicrosoftGraphClient)(teamsfx, scope);
|
|
25
|
+
return await asyncFunc(graph, teamsfx, scope);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (err instanceof microsoft_graph_client_1.GraphError && ((_a = err.code) === null || _a === void 0 ? void 0 : _a.includes("UiRequiredError"))) {
|
|
29
|
+
// Silently fail for user didn't login error
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const { data, error, loading, reload } = (0, useData_1.useData)(async () => {
|
|
37
|
+
var _a;
|
|
38
|
+
try {
|
|
39
|
+
const teamsfx = new teamsfx_1.TeamsFx();
|
|
40
|
+
await teamsfx.login(scope);
|
|
41
|
+
// Important: tokens are stored in sessionStorage, read more here: https://aka.ms/teamsfx-session-storage-notice
|
|
42
|
+
const graph = (0, teamsfx_1.createMicrosoftGraphClient)(teamsfx, scope);
|
|
43
|
+
return await asyncFunc(graph, teamsfx, scope);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
if (err instanceof teamsfx_1.ErrorWithCode && ((_a = err.message) === null || _a === void 0 ? void 0 : _a.includes("CancelledByUser"))) {
|
|
47
|
+
const helpLink = "https://aka.ms/teamsfx-auth-code-flow";
|
|
48
|
+
err.message +=
|
|
49
|
+
'\nIf you see "AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application" ' +
|
|
50
|
+
"in the popup window, you may be using unmatched version for TeamsFx SDK (version >= 0.5.0) and Teams Toolkit (version < 3.3.0) or " +
|
|
51
|
+
`cli (version < 0.11.0). Please refer to the help link for how to fix the issue: ${helpLink}`;
|
|
52
|
+
}
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
}, { auto: false });
|
|
56
|
+
return data || error || loading
|
|
57
|
+
? { data, error, loading, reload }
|
|
58
|
+
: {
|
|
59
|
+
data: initial.data,
|
|
60
|
+
error: initial.error,
|
|
61
|
+
loading: initial.loading,
|
|
62
|
+
reload,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.useGraph = useGraph;
|
package/build/useTeamsFx.d.ts
CHANGED
|
@@ -1,42 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
loading: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Error information.
|
|
14
|
-
*/
|
|
15
|
-
error: unknown;
|
|
16
|
-
/**
|
|
17
|
-
* Indicates that current environment is in Teams
|
|
18
|
-
*/
|
|
19
|
-
inTeams?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Teams theme.
|
|
22
|
-
*/
|
|
23
|
-
theme: ThemePrepared;
|
|
24
|
-
/**
|
|
25
|
-
* Teams theme string.
|
|
26
|
-
*/
|
|
27
|
-
themeString: string;
|
|
28
|
-
/**
|
|
29
|
-
* Teams context object.
|
|
30
|
-
*/
|
|
31
|
-
context?: any;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
35
|
-
*
|
|
36
|
-
* @param teamsfxConfig - custom configuration to override default ones.
|
|
37
|
-
* @returns TeamsFxContext object
|
|
38
|
-
*
|
|
39
|
-
* @beta
|
|
40
|
-
*/
|
|
41
|
-
export declare function useTeamsFx(teamsfxConfig?: Record<string, string>): TeamsFxContext;
|
|
1
|
+
export declare function useTeamsFx(): {
|
|
2
|
+
inTeams?: boolean | undefined;
|
|
3
|
+
fullScreen?: boolean | undefined;
|
|
4
|
+
theme: import("@fluentui/styles").ThemePrepared<any>;
|
|
5
|
+
themeString: string;
|
|
6
|
+
context?: import("@microsoft/teams-js").app.Context | undefined;
|
|
7
|
+
error: any;
|
|
8
|
+
loading: boolean;
|
|
9
|
+
isInTeams: boolean;
|
|
10
|
+
};
|
|
42
11
|
//# sourceMappingURL=useTeamsFx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTeamsFx.d.ts","sourceRoot":"","sources":["../src/useTeamsFx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTeamsFx.d.ts","sourceRoot":"","sources":["../src/useTeamsFx.ts"],"names":[],"mappings":"AAmBA,wBAAgB,UAAU;;;;;;;;;EAezB"}
|
package/build/useTeamsFx.js
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useTeamsFx = void 0;
|
|
6
|
-
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
7
|
-
const msteams_react_base_component_1 = require("msteams-react-base-component");
|
|
8
|
-
const useData_1 = require("./useData");
|
|
9
|
-
/**
|
|
10
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
11
|
-
*
|
|
12
|
-
* @param teamsfxConfig - custom configuration to override default ones.
|
|
13
|
-
* @returns TeamsFxContext object
|
|
14
|
-
*
|
|
15
|
-
* @beta
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useTeamsFx = void 0;
|
|
6
|
+
const teamsfx_1 = require("@microsoft/teamsfx");
|
|
7
|
+
const msteams_react_base_component_1 = require("msteams-react-base-component");
|
|
8
|
+
const useData_1 = require("./useData");
|
|
9
|
+
/**
|
|
10
|
+
* Initialize TeamsFx SDK with customized configuration.
|
|
11
|
+
*
|
|
12
|
+
* @param teamsfxConfig - custom configuration to override default ones.
|
|
13
|
+
* @returns TeamsFxContext object
|
|
14
|
+
*
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
// TODO: fix this when the SDK stops hiding global state!
|
|
18
|
+
let initialized = false;
|
|
19
|
+
function useTeamsFx() {
|
|
20
|
+
const [result] = (0, msteams_react_base_component_1.useTeams)({});
|
|
21
|
+
const { error, loading } = (0, useData_1.useData)(async () => {
|
|
22
|
+
if (!initialized) {
|
|
23
|
+
if (process.env.NODE_ENV === "development") {
|
|
24
|
+
(0, teamsfx_1.setLogLevel)(teamsfx_1.LogLevel.Verbose);
|
|
25
|
+
(0, teamsfx_1.setLogFunction)((leve, message) => {
|
|
26
|
+
console.log(message);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
initialized = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const isInTeams = true;
|
|
33
|
+
return Object.assign({ error, loading, isInTeams }, result);
|
|
34
|
+
}
|
|
35
|
+
exports.useTeamsFx = useTeamsFx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/teamsfx-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "React helper functions for Microsoft TeamsFx",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"lint:staged": "lint-staged",
|
|
20
20
|
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
21
21
|
"test": "npm run test:unit",
|
|
22
|
-
"test:unit": "nyc mocha --no-timeouts --require init.js --require ts-node/register test/**/*.test.ts
|
|
22
|
+
"test:unit": "nyc mocha --no-timeouts --require init.js --require ts-node/register test/**/*.test.ts",
|
|
23
23
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
24
24
|
"format-check": "prettier --list-different \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
|
|
25
25
|
"check-sensitive": "npx eslint --plugin 'no-secrets' --cache --ignore-pattern 'package.json' --ignore-pattern 'package-lock.json'",
|
|
26
26
|
"precommit": "npm run check-sensitive && lint-staged"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@fluentui/react-northstar": "^0.
|
|
29
|
+
"@fluentui/react-northstar": "^0.62.0",
|
|
30
30
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
31
31
|
"@microsoft/microsoft-graph-client": "^3.0.1",
|
|
32
|
-
"@microsoft/teams-js": "^
|
|
33
|
-
"@microsoft/teamsfx": "
|
|
32
|
+
"@microsoft/teams-js": "^2.2.0",
|
|
33
|
+
"@microsoft/teamsfx": "2.0.0-beta.0",
|
|
34
34
|
"@testing-library/react-hooks": "^7.0.2",
|
|
35
35
|
"@types/chai": "^4.3.0",
|
|
36
36
|
"@types/mocha": "^9.1.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"isomorphic-fetch": "^3.0.0",
|
|
48
48
|
"lint-staged": "^12.3.4",
|
|
49
49
|
"mocha": "^9.2.1",
|
|
50
|
-
"msteams-react-base-component": "^
|
|
50
|
+
"msteams-react-base-component": "^4.0.1",
|
|
51
51
|
"nyc": "^15.1.0",
|
|
52
52
|
"prettier": "^2.5.1",
|
|
53
53
|
"react": "^16.9.0",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"sinon": "^13.0.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@fluentui/react-northstar": "^0.
|
|
60
|
+
"@fluentui/react-northstar": "^0.62.0",
|
|
61
61
|
"@microsoft/microsoft-graph-client": "^3.0.1",
|
|
62
|
-
"@microsoft/teamsfx": "
|
|
63
|
-
"msteams-react-base-component": "^
|
|
62
|
+
"@microsoft/teamsfx": "2.0.0-beta.0",
|
|
63
|
+
"msteams-react-base-component": "^4.0.1",
|
|
64
64
|
"react": "^16.8.6"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
@@ -70,6 +70,5 @@
|
|
|
70
70
|
"*.{js,jsx,css,ts,tsx}": [
|
|
71
71
|
"npx eslint --cache --fix --quiet"
|
|
72
72
|
]
|
|
73
|
-
}
|
|
74
|
-
"gitHead": "9c0b3bc030a4cbc070b45d4dae186c097bb9b98e"
|
|
73
|
+
}
|
|
75
74
|
}
|