@microsoft/teams-js 2.0.0-beta.3-dev.10 → 2.0.0-beta.3-dev.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.
- package/README.md +3 -3
- package/dist/MicrosoftTeams.d.ts +52 -2
- package/dist/MicrosoftTeams.js +118 -63
- package/dist/MicrosoftTeams.js.map +1 -1
- package/dist/MicrosoftTeams.min.js +1 -1
- package/dist/MicrosoftTeams.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Microsoft Teams JavaScript client SDK
|
|
2
2
|
|
|
3
|
-
Welcome to the Teams client SDK monorepo! For breaking changes, please refer to our changelog in the monorepo root.
|
|
3
|
+
Welcome to the Teams client SDK monorepo! For breaking changes, please refer to our changelog in the monorepo root of the `2.0-preview` branch.
|
|
4
4
|
|
|
5
5
|
This JavaScript library is part of the [Microsoft Teams developer platform](https://developer.microsoft.com/microsoft-teams/). See full [SDK reference documentation](https://docs.microsoft.com/en-us/javascript/api/overview/msteams-client).
|
|
6
6
|
|
|
@@ -11,8 +11,8 @@ This JavaScript library is part of the [Microsoft Teams developer platform](http
|
|
|
11
11
|
|
|
12
12
|
1. Clone the repo
|
|
13
13
|
2. Navigate to the repo root and run `yarn install`
|
|
14
|
-
3. `yarn build` from repo root
|
|
15
|
-
4.
|
|
14
|
+
3. Run `yarn build` from repo root
|
|
15
|
+
4. To run Unit tests, run `yarn test`
|
|
16
16
|
|
|
17
17
|
TIP: whenever building or testing the Teams client SDK, you can run `yarn build` or `yarn test` from the packages/teams-js directory.
|
|
18
18
|
|
package/dist/MicrosoftTeams.d.ts
CHANGED
|
@@ -2717,7 +2717,7 @@ export namespace app {
|
|
|
2717
2717
|
*
|
|
2718
2718
|
* @param validMessageOrigins - Optionally specify a list of cross frame message origins. They must have
|
|
2719
2719
|
* https: protocol otherwise they will be ignored. Example: https:www.example.com
|
|
2720
|
-
* @returns Promise that will be fulfilled when initialization has completed
|
|
2720
|
+
* @returns Promise that will be fulfilled when initialization has completed, or rejected if the initialization fails or times out
|
|
2721
2721
|
*/
|
|
2722
2722
|
function initialize(validMessageOrigins?: string[]): Promise<void>;
|
|
2723
2723
|
/**
|
|
@@ -2853,6 +2853,16 @@ export namespace pages {
|
|
|
2853
2853
|
* @returns Promise that resolves when the navigation has completed.
|
|
2854
2854
|
*/
|
|
2855
2855
|
function navigateCrossDomain(url: string): Promise<void>;
|
|
2856
|
+
/**
|
|
2857
|
+
* Navigate to the given App ID and Page ID, with optional parameters for a WebURL (if the app cannot
|
|
2858
|
+
* be navigated to, such as if it is not installed), Channel ID (for apps installed as a channel tab), and
|
|
2859
|
+
* Sub-page ID (for navigating to specific content within the page). This is equivalent to navigating to
|
|
2860
|
+
* a deep link with the above data, but does not require the app to build a URL or worry about different
|
|
2861
|
+
* deep link formats for different hosts.
|
|
2862
|
+
* @param params Parameters for the navigation
|
|
2863
|
+
* @returns a promise that will resolve if the navigation was successful
|
|
2864
|
+
*/
|
|
2865
|
+
function navigateToApp(params: NavigateToAppParams): Promise<void>;
|
|
2856
2866
|
/**
|
|
2857
2867
|
* Registers a handler for changes from or to full-screen view for a tab.
|
|
2858
2868
|
* Only one handler can be registered at a time. A subsequent registration replaces an existing registration.
|
|
@@ -2863,6 +2873,32 @@ export namespace pages {
|
|
|
2863
2873
|
* Checks if page capability is supported currently
|
|
2864
2874
|
*/
|
|
2865
2875
|
function isSupported(): boolean;
|
|
2876
|
+
/**
|
|
2877
|
+
* Parameters for the NavigateToApp API
|
|
2878
|
+
*/
|
|
2879
|
+
interface NavigateToAppParams {
|
|
2880
|
+
/**
|
|
2881
|
+
* ID of the App to navigate to
|
|
2882
|
+
*/
|
|
2883
|
+
appId: string;
|
|
2884
|
+
/**
|
|
2885
|
+
* Developer-defined ID of the Page to navigate to within the app (Formerly EntityID)
|
|
2886
|
+
*/
|
|
2887
|
+
pageId: string;
|
|
2888
|
+
/**
|
|
2889
|
+
* Optional URL to open if the navigation cannot be completed within the host
|
|
2890
|
+
*/
|
|
2891
|
+
webUrl?: string;
|
|
2892
|
+
/**
|
|
2893
|
+
* Optional developer-defined ID describing the content to navigate to within the Page. This will be passed
|
|
2894
|
+
* back to the App via the Context object.
|
|
2895
|
+
*/
|
|
2896
|
+
subPageId?: string;
|
|
2897
|
+
/**
|
|
2898
|
+
* Optional ID of the Teams Channel where the app should be opened
|
|
2899
|
+
*/
|
|
2900
|
+
channelId?: string;
|
|
2901
|
+
}
|
|
2866
2902
|
/**
|
|
2867
2903
|
* Namespace to interact with the teams specific part of the SDK.
|
|
2868
2904
|
*/
|
|
@@ -4244,6 +4280,20 @@ export namespace sharing {
|
|
|
4244
4280
|
preview?: boolean;
|
|
4245
4281
|
}
|
|
4246
4282
|
/**
|
|
4283
|
+
* @hidden
|
|
4284
|
+
* Feature is under development
|
|
4285
|
+
* Opens a share dialog for web content
|
|
4286
|
+
*
|
|
4287
|
+
* @param shareWebContentRequest - web content info
|
|
4288
|
+
* @returns Promise that will be fulfilled when the operation has completed
|
|
4289
|
+
*
|
|
4290
|
+
* @internal
|
|
4291
|
+
*/
|
|
4292
|
+
export function shareWebContent(shareWebContentRequest: IShareRequest<IShareRequestContentType>): Promise<void>;
|
|
4293
|
+
/**
|
|
4294
|
+
* @deprecated
|
|
4295
|
+
* As of 2.0.0-beta.3, please use {@link sharing.shareWebContent sharing.shareWebContent(shareWebContentRequest: IShareRequest\<IShareRequestContentType\>): Promise\<void\>} instead.
|
|
4296
|
+
*
|
|
4247
4297
|
* @hidden
|
|
4248
4298
|
* Feature is under development
|
|
4249
4299
|
* Opens a share dialog for web content
|
|
@@ -4253,7 +4303,7 @@ export namespace sharing {
|
|
|
4253
4303
|
*
|
|
4254
4304
|
* @internal
|
|
4255
4305
|
*/
|
|
4256
|
-
export function shareWebContent(shareWebContentRequest: IShareRequest<IShareRequestContentType>, callback
|
|
4306
|
+
export function shareWebContent(shareWebContentRequest: IShareRequest<IShareRequestContentType>, callback: (err?: SdkError) => void): void;
|
|
4257
4307
|
export function isSupported(): boolean;
|
|
4258
4308
|
export {};
|
|
4259
4309
|
}
|
package/dist/MicrosoftTeams.js
CHANGED
|
@@ -395,7 +395,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
395
395
|
});
|
|
396
396
|
|
|
397
397
|
;// CONCATENATED MODULE: ./src/internal/constants.ts
|
|
398
|
-
var version = '2.0.0-beta.3-dev.
|
|
398
|
+
var version = '2.0.0-beta.3-dev.14';
|
|
399
399
|
/**
|
|
400
400
|
* @hidden
|
|
401
401
|
* The SDK version when all SDK APIs started to check platform compatibility for the APIs was 1.6.0.
|
|
@@ -780,6 +780,44 @@ function callCallbackWithErrorOrResultOrNullFromPromiseAndReturnPromise(funcHelp
|
|
|
780
780
|
});
|
|
781
781
|
return p;
|
|
782
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* A helper function to add a timeout to an asynchronous operation.
|
|
785
|
+
*
|
|
786
|
+
* @param action Action to wrap the timeout around
|
|
787
|
+
* @param timeoutInMs Timeout period in milliseconds
|
|
788
|
+
* @param timeoutError Error to reject the promise with if timeout elapses before the action completed
|
|
789
|
+
* @returns A promise which resolves to the result of provided action or rejects with a provided timeout error
|
|
790
|
+
* if the initial action didn't complete within provided timeout.
|
|
791
|
+
*
|
|
792
|
+
* @internal
|
|
793
|
+
*/
|
|
794
|
+
function runWithTimeout(action, timeoutInMs, timeoutError) {
|
|
795
|
+
return new Promise(function (resolve, reject) {
|
|
796
|
+
var timeoutHandle = setTimeout(reject, timeoutInMs, timeoutError);
|
|
797
|
+
action()
|
|
798
|
+
.then(function (result) {
|
|
799
|
+
clearTimeout(timeoutHandle);
|
|
800
|
+
resolve(result);
|
|
801
|
+
})
|
|
802
|
+
.catch(function (error) {
|
|
803
|
+
clearTimeout(timeoutHandle);
|
|
804
|
+
reject(error);
|
|
805
|
+
});
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
function createTeamsAppLink(params) {
|
|
809
|
+
var url = new URL('https://teams.microsoft.com/l/entity/' +
|
|
810
|
+
encodeURIComponent(params.appId) +
|
|
811
|
+
'/' +
|
|
812
|
+
encodeURIComponent(params.pageId));
|
|
813
|
+
if (params.webUrl) {
|
|
814
|
+
url.searchParams.append('webUrl', params.webUrl);
|
|
815
|
+
}
|
|
816
|
+
if (params.channelId || params.subPageId) {
|
|
817
|
+
url.searchParams.append('context', JSON.stringify({ channelId: params.channelId, subEntityId: params.subPageId }));
|
|
818
|
+
}
|
|
819
|
+
return url.toString();
|
|
820
|
+
}
|
|
783
821
|
|
|
784
822
|
;// CONCATENATED MODULE: ./src/internal/internalAPIs.ts
|
|
785
823
|
|
|
@@ -887,6 +925,7 @@ var runtime = {
|
|
|
887
925
|
};
|
|
888
926
|
var teamsRuntimeConfig = {
|
|
889
927
|
apiVersion: 1,
|
|
928
|
+
isLegacyTeams: true,
|
|
890
929
|
supports: {
|
|
891
930
|
appInstallDialog: {},
|
|
892
931
|
appEntity: {},
|
|
@@ -1794,6 +1833,10 @@ var app_app;
|
|
|
1794
1833
|
return GlobalVars.frameContext;
|
|
1795
1834
|
}
|
|
1796
1835
|
app.getFrameContext = getFrameContext;
|
|
1836
|
+
/**
|
|
1837
|
+
* Number of milliseconds we'll give the initialization call to return before timing it out
|
|
1838
|
+
*/
|
|
1839
|
+
var initializationTimeoutInMs = 5000;
|
|
1797
1840
|
/**
|
|
1798
1841
|
* Initializes the library.
|
|
1799
1842
|
*
|
|
@@ -1803,9 +1846,13 @@ var app_app;
|
|
|
1803
1846
|
*
|
|
1804
1847
|
* @param validMessageOrigins - Optionally specify a list of cross frame message origins. They must have
|
|
1805
1848
|
* https: protocol otherwise they will be ignored. Example: https:www.example.com
|
|
1806
|
-
* @returns Promise that will be fulfilled when initialization has completed
|
|
1849
|
+
* @returns Promise that will be fulfilled when initialization has completed, or rejected if the initialization fails or times out
|
|
1807
1850
|
*/
|
|
1808
1851
|
function initialize(validMessageOrigins) {
|
|
1852
|
+
return runWithTimeout(function () { return initializeHelper(validMessageOrigins); }, initializationTimeoutInMs, new Error('SDK initialization timed out.'));
|
|
1853
|
+
}
|
|
1854
|
+
app.initialize = initialize;
|
|
1855
|
+
function initializeHelper(validMessageOrigins) {
|
|
1809
1856
|
return new Promise(function (resolve) {
|
|
1810
1857
|
// Independent components might not know whether the SDK is initialized so might call it to be safe.
|
|
1811
1858
|
// Just no-op if that happens to make it easier to use.
|
|
@@ -1870,7 +1917,6 @@ var app_app;
|
|
|
1870
1917
|
resolve(GlobalVars.initializePromise);
|
|
1871
1918
|
});
|
|
1872
1919
|
}
|
|
1873
|
-
app.initialize = initialize;
|
|
1874
1920
|
/**
|
|
1875
1921
|
* @hidden
|
|
1876
1922
|
* Hide from docs.
|
|
@@ -2110,6 +2156,7 @@ function transformLegacyContextToAppContext(legacyContext) {
|
|
|
2110
2156
|
|
|
2111
2157
|
|
|
2112
2158
|
|
|
2159
|
+
|
|
2113
2160
|
/**
|
|
2114
2161
|
* Navigation specific part of the SDK.
|
|
2115
2162
|
*
|
|
@@ -2154,6 +2201,27 @@ var pages;
|
|
|
2154
2201
|
});
|
|
2155
2202
|
}
|
|
2156
2203
|
pages.navigateCrossDomain = navigateCrossDomain;
|
|
2204
|
+
/**
|
|
2205
|
+
* Navigate to the given App ID and Page ID, with optional parameters for a WebURL (if the app cannot
|
|
2206
|
+
* be navigated to, such as if it is not installed), Channel ID (for apps installed as a channel tab), and
|
|
2207
|
+
* Sub-page ID (for navigating to specific content within the page). This is equivalent to navigating to
|
|
2208
|
+
* a deep link with the above data, but does not require the app to build a URL or worry about different
|
|
2209
|
+
* deep link formats for different hosts.
|
|
2210
|
+
* @param params Parameters for the navigation
|
|
2211
|
+
* @returns a promise that will resolve if the navigation was successful
|
|
2212
|
+
*/
|
|
2213
|
+
function navigateToApp(params) {
|
|
2214
|
+
return new Promise(function (resolve) {
|
|
2215
|
+
ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.settings, FrameContexts.task, FrameContexts.stage, FrameContexts.meetingStage);
|
|
2216
|
+
if (runtime.isLegacyTeams) {
|
|
2217
|
+
resolve(sendAndHandleStatusAndReason('executeDeepLink', createTeamsAppLink(params)));
|
|
2218
|
+
}
|
|
2219
|
+
else {
|
|
2220
|
+
resolve(sendAndHandleStatusAndReason('pages.navigateToApp', params));
|
|
2221
|
+
}
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
pages.navigateToApp = navigateToApp;
|
|
2157
2225
|
/**
|
|
2158
2226
|
* Registers a handler for changes from or to full-screen view for a tab.
|
|
2159
2227
|
* Only one handler can be registered at a time. A subsequent registration replaces an existing registration.
|
|
@@ -4482,6 +4550,7 @@ var video;
|
|
|
4482
4550
|
|
|
4483
4551
|
|
|
4484
4552
|
|
|
4553
|
+
|
|
4485
4554
|
/**
|
|
4486
4555
|
* @alpha
|
|
4487
4556
|
*/
|
|
@@ -4490,88 +4559,74 @@ var sharing;
|
|
|
4490
4559
|
sharing.SharingAPIMessages = {
|
|
4491
4560
|
shareWebContent: 'sharing.shareWebContent',
|
|
4492
4561
|
};
|
|
4493
|
-
/**
|
|
4494
|
-
* @hidden
|
|
4495
|
-
* Feature is under development
|
|
4496
|
-
* Opens a share dialog for web content
|
|
4497
|
-
*
|
|
4498
|
-
* @param shareWebContentRequest - web content info
|
|
4499
|
-
* @param callback - optional callback
|
|
4500
|
-
*
|
|
4501
|
-
* @internal
|
|
4502
|
-
*/
|
|
4503
4562
|
function shareWebContent(shareWebContentRequest, callback) {
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4563
|
+
// validate the given input (synchronous check)
|
|
4564
|
+
try {
|
|
4565
|
+
validateNonEmptyContent(shareWebContentRequest);
|
|
4566
|
+
validateTypeConsistency(shareWebContentRequest);
|
|
4567
|
+
validateContentForSupportedTypes(shareWebContentRequest);
|
|
4509
4568
|
}
|
|
4510
|
-
|
|
4511
|
-
return
|
|
4569
|
+
catch (err) {
|
|
4570
|
+
//return the error via callback(v1) or rejected promise(v2)
|
|
4571
|
+
var wrappedFunction = function () { return Promise.reject(err); };
|
|
4572
|
+
return callCallbackWithSdkErrorFromPromiseAndReturnPromise(wrappedFunction, callback);
|
|
4512
4573
|
}
|
|
4513
4574
|
ensureInitialized(FrameContexts.content, FrameContexts.sidePanel, FrameContexts.task, FrameContexts.stage, FrameContexts.meetingStage);
|
|
4514
|
-
|
|
4575
|
+
return callCallbackWithSdkErrorFromPromiseAndReturnPromise(shareWebContentHelper, callback, shareWebContentRequest);
|
|
4515
4576
|
}
|
|
4516
4577
|
sharing.shareWebContent = shareWebContent;
|
|
4578
|
+
function shareWebContentHelper(shareWebContentRequest) {
|
|
4579
|
+
return new Promise(function (resolve) {
|
|
4580
|
+
resolve(sendAndHandleSdkError(sharing.SharingAPIMessages.shareWebContent, shareWebContentRequest));
|
|
4581
|
+
});
|
|
4582
|
+
}
|
|
4517
4583
|
/**
|
|
4518
|
-
*
|
|
4584
|
+
* Functions for validating the shareRequest input parameter
|
|
4519
4585
|
*/
|
|
4520
|
-
function validateNonEmptyContent(shareRequest
|
|
4586
|
+
function validateNonEmptyContent(shareRequest) {
|
|
4521
4587
|
if (!(shareRequest && shareRequest.content && shareRequest.content.length)) {
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
}
|
|
4528
|
-
return false;
|
|
4588
|
+
var err = {
|
|
4589
|
+
errorCode: ErrorCode.INVALID_ARGUMENTS,
|
|
4590
|
+
message: 'Shared content is missing',
|
|
4591
|
+
};
|
|
4592
|
+
throw err;
|
|
4529
4593
|
}
|
|
4530
|
-
return true;
|
|
4531
4594
|
}
|
|
4532
|
-
function validateTypeConsistency(shareRequest
|
|
4595
|
+
function validateTypeConsistency(shareRequest) {
|
|
4596
|
+
var err;
|
|
4533
4597
|
if (shareRequest.content.some(function (item) { return !item.type; })) {
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
}
|
|
4540
|
-
return false;
|
|
4598
|
+
err = {
|
|
4599
|
+
errorCode: ErrorCode.INVALID_ARGUMENTS,
|
|
4600
|
+
message: 'Shared content type cannot be undefined',
|
|
4601
|
+
};
|
|
4602
|
+
throw err;
|
|
4541
4603
|
}
|
|
4542
4604
|
if (shareRequest.content.some(function (item) { return item.type !== shareRequest.content[0].type; })) {
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
}
|
|
4549
|
-
return false;
|
|
4605
|
+
err = {
|
|
4606
|
+
errorCode: ErrorCode.INVALID_ARGUMENTS,
|
|
4607
|
+
message: 'Shared content must be of the same type',
|
|
4608
|
+
};
|
|
4609
|
+
throw err;
|
|
4550
4610
|
}
|
|
4551
|
-
return true;
|
|
4552
4611
|
}
|
|
4553
|
-
function validateContentForSupportedTypes(shareRequest
|
|
4612
|
+
function validateContentForSupportedTypes(shareRequest) {
|
|
4613
|
+
var err;
|
|
4554
4614
|
if (shareRequest.content[0].type === 'URL') {
|
|
4555
4615
|
if (shareRequest.content.some(function (item) { return !item.url; })) {
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
}
|
|
4562
|
-
return false;
|
|
4616
|
+
err = {
|
|
4617
|
+
errorCode: ErrorCode.INVALID_ARGUMENTS,
|
|
4618
|
+
message: 'URLs are required for URL content types',
|
|
4619
|
+
};
|
|
4620
|
+
throw err;
|
|
4563
4621
|
}
|
|
4564
4622
|
}
|
|
4565
4623
|
else {
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
}
|
|
4572
|
-
return false;
|
|
4624
|
+
err = {
|
|
4625
|
+
errorCode: ErrorCode.INVALID_ARGUMENTS,
|
|
4626
|
+
message: 'Content type is unsupported',
|
|
4627
|
+
};
|
|
4628
|
+
throw err;
|
|
4573
4629
|
}
|
|
4574
|
-
return true;
|
|
4575
4630
|
}
|
|
4576
4631
|
function isSupported() {
|
|
4577
4632
|
return runtime.supports.sharing ? true : false;
|