@microsoft/teams-js 2.41.0 → 2.43.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/README.md +4 -4
- package/dist/esm/packages/teams-js/dts/internal/telemetry.d.ts +3 -0
- package/dist/esm/packages/teams-js/dts/internal/utils.d.ts +7 -0
- package/dist/esm/packages/teams-js/dts/public/app/app.d.ts +5 -0
- package/dist/esm/packages/teams-js/dts/public/index.d.ts +1 -0
- package/dist/esm/packages/teams-js/dts/public/interfaces.d.ts +13 -1
- package/dist/esm/packages/teams-js/dts/public/runtime.d.ts +1 -0
- package/dist/esm/packages/teams-js/dts/public/shortcutRelay.d.ts +60 -0
- package/dist/esm/packages/teams-js/src/artifactsForCDN/validDomains.json.js +1 -1
- package/dist/esm/packages/teams-js/src/index.js +1 -1
- package/dist/esm/packages/teams-js/src/internal/appHelpers.js +1 -1
- package/dist/esm/packages/teams-js/src/internal/utils.js +1 -1
- package/dist/esm/packages/teams-js/src/private/copilot/eligibility.js +1 -1
- package/dist/esm/packages/teams-js/src/public/app/app.js +1 -1
- package/dist/esm/packages/teams-js/src/public/interfaces.js +1 -1
- package/dist/esm/packages/teams-js/src/public/shortcutRelay.js +1 -0
- package/dist/esm/packages/teams-js/src/public/version.js +1 -1
- package/dist/umd/MicrosoftTeams.js +309 -6
- package/dist/umd/MicrosoftTeams.js.map +1 -1
- package/dist/umd/MicrosoftTeams.min.js +1 -1
- package/dist/umd/MicrosoftTeams.min.js.map +1 -1
- package/package.json +1 -1
@@ -1093,6 +1093,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
1093
1093
|
settings: () => (/* reexport */ settings_namespaceObject),
|
1094
1094
|
shareDeepLink: () => (/* reexport */ publicAPIs_shareDeepLink),
|
1095
1095
|
sharing: () => (/* reexport */ sharing_namespaceObject),
|
1096
|
+
shortcutRelay: () => (/* reexport */ shortcutRelay_namespaceObject),
|
1096
1097
|
sidePanelInterfaces: () => (/* reexport */ sidePanelInterfaces_namespaceObject),
|
1097
1098
|
stageView: () => (/* reexport */ stageView_namespaceObject),
|
1098
1099
|
store: () => (/* reexport */ store_namespaceObject),
|
@@ -2037,6 +2038,17 @@ __webpack_require__.d(marketplace_namespaceObject, {
|
|
2037
2038
|
updateCartStatus: () => (updateCartStatus)
|
2038
2039
|
});
|
2039
2040
|
|
2041
|
+
// NAMESPACE OBJECT: ./src/public/shortcutRelay.ts
|
2042
|
+
var shortcutRelay_namespaceObject = {};
|
2043
|
+
__webpack_require__.r(shortcutRelay_namespaceObject);
|
2044
|
+
__webpack_require__.d(shortcutRelay_namespaceObject, {
|
2045
|
+
DISABLE_SHORTCUT_FORWARDING_ATTRIBUTE: () => (DISABLE_SHORTCUT_FORWARDING_ATTRIBUTE),
|
2046
|
+
enableShortcutRelayCapability: () => (enableShortcutRelayCapability),
|
2047
|
+
isSupported: () => (shortcutRelay_isSupported),
|
2048
|
+
resetIsShortcutRelayCapabilityEnabled: () => (resetIsShortcutRelayCapabilityEnabled),
|
2049
|
+
setOverridableShortcutHandler: () => (setOverridableShortcutHandler)
|
2050
|
+
});
|
2051
|
+
|
2040
2052
|
;// ./src/public/interfaces.ts
|
2041
2053
|
/* eslint-disable @typescript-eslint/no-explicit-any*/
|
2042
2054
|
/**
|
@@ -2211,7 +2223,12 @@ var LegalAgeGroupClassification;
|
|
2211
2223
|
* United Kingdom, European Union, or South Korea, and the user's age is between a minor and an adult age
|
2212
2224
|
* (as stipulated based on country or region). Generally, this means that teenagers are considered as notAdult in regulated countries.
|
2213
2225
|
*/
|
2214
|
-
LegalAgeGroupClassification["
|
2226
|
+
LegalAgeGroupClassification["NotAdult"] = "notAdult";
|
2227
|
+
/**
|
2228
|
+
* @deprecated To provide back compatibility for the NonAdult enum value coming from the hubs
|
2229
|
+
*/
|
2230
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
2231
|
+
LegalAgeGroupClassification["NonAdult"] = "notAdult";
|
2215
2232
|
})(LegalAgeGroupClassification || (LegalAgeGroupClassification = {}));
|
2216
2233
|
/**
|
2217
2234
|
* @hidden
|
@@ -2245,7 +2262,7 @@ var ClipboardSupportedMimeType;
|
|
2245
2262
|
})(ClipboardSupportedMimeType || (ClipboardSupportedMimeType = {}));
|
2246
2263
|
|
2247
2264
|
;// ./src/artifactsForCDN/validDomains.json
|
2248
|
-
const validDomains_namespaceObject = /*#__PURE__*/JSON.parse('{"validOrigins":["teams.microsoft.com","teams.microsoft.us","gov.teams.microsoft.us","dod.teams.microsoft.us","int.teams.microsoft.com","outlook.office.com","outlook-sdf.office.com","outlook.office365.com","outlook-sdf.office365.com","outlook.live.com","outlook-sdf.live.com","teams.live.com","local.teams.live.com","local.teams.live.com:8080","local.teams.office.com","local.teams.office.com:8080","devspaces.skype.com","*.www.office.com","www.office.com","word.office.com","excel.office.com","powerpoint.office.com","www.officeppe.com","*.www.microsoft365.com","www.microsoft365.com","bing.com","edgeservices.bing.com","work.bing.com","www.bing.com","www.staging-bing-int.com","*.cloud.microsoft","*.m365.cloud.microsoft","*.outlook.cloud.microsoft","chatuxmanager.svc.cloud.microsoft","copilot.microsoft.com","windows.msn.com","fa000000125.resources.office.net","fa000000129.resources.office.net","fa000000124.resources.office.net","fa000000128.resources.office.net","fa000000136.resources.office.net"]}');
|
2265
|
+
const validDomains_namespaceObject = /*#__PURE__*/JSON.parse('{"validOrigins":["teams.microsoft.com","teams.microsoft.us","gov.teams.microsoft.us","dod.teams.microsoft.us","int.teams.microsoft.com","outlook.office.com","outlook-sdf.office.com","outlook.office365.com","outlook-sdf.office365.com","outlook.office365.us","outlook-dod.office365.us","webmail.apps.mil","outlook.live.com","outlook-sdf.live.com","teams.live.com","local.teams.live.com","local.teams.live.com:8080","local.teams.office.com","local.teams.office.com:8080","devspaces.skype.com","*.www.office.com","www.office.com","word.office.com","excel.office.com","powerpoint.office.com","www.officeppe.com","*.www.microsoft365.com","www.microsoft365.com","bing.com","edgeservices.bing.com","work.bing.com","www.bing.com","www.staging-bing-int.com","*.cloud.microsoft","*.m365.cloud.microsoft","*.outlook.cloud.microsoft","chatuxmanager.svc.cloud.microsoft","copilot.microsoft.com","windows.msn.com","fa000000125.resources.office.net","fa000000129.resources.office.net","fa000000124.resources.office.net","fa000000128.resources.office.net","fa000000136.resources.office.net","fa000000125.officeapps.live.com","fa000000129.officeapps.live.com","fa000000124.officeapps.live.com","fa000000128.officeapps.live.com"]}');
|
2249
2266
|
var artifactsForCDN_validDomains_namespaceObject = /*#__PURE__*/__webpack_require__.t(validDomains_namespaceObject, 2);
|
2250
2267
|
;// ./src/internal/constants.ts
|
2251
2268
|
|
@@ -3597,6 +3614,7 @@ const errorInvalidResponse = new Error('Invalid response: Received more images t
|
|
3597
3614
|
|
3598
3615
|
|
3599
3616
|
|
3617
|
+
|
3600
3618
|
/**
|
3601
3619
|
* @internal
|
3602
3620
|
* Limited to Microsoft-internal use
|
@@ -4074,6 +4092,25 @@ function isPrimitiveOrPlainObject(value, depth = 0) {
|
|
4074
4092
|
// Check all properties of the object recursively
|
4075
4093
|
return Object.keys(value).every((key) => isPrimitiveOrPlainObject(value[key], depth + 1));
|
4076
4094
|
}
|
4095
|
+
/**
|
4096
|
+
* Normalizes legacy ageGroup values for backward compatibility
|
4097
|
+
* @param runtimeConfig - The runtime configuration object to normalize
|
4098
|
+
* @returns A new IBaseRuntime object with normalized ageGroup values
|
4099
|
+
*/
|
4100
|
+
function normalizeAgeGroupValue(runtimeConfig) {
|
4101
|
+
var _a, _b;
|
4102
|
+
// If no ageGroup exists, return the original config
|
4103
|
+
if (!((_b = (_a = runtimeConfig.hostVersionsInfo) === null || _a === void 0 ? void 0 : _a.appEligibilityInformation) === null || _b === void 0 ? void 0 : _b.ageGroup)) {
|
4104
|
+
return runtimeConfig;
|
4105
|
+
}
|
4106
|
+
const ageGroup = runtimeConfig.hostVersionsInfo.appEligibilityInformation.ageGroup;
|
4107
|
+
// If the ageGroup doesn't need normalization, return the original config
|
4108
|
+
if ((ageGroup === null || ageGroup === void 0 ? void 0 : ageGroup.toLowerCase()) !== 'nonadult') {
|
4109
|
+
return runtimeConfig;
|
4110
|
+
}
|
4111
|
+
// Create a new config with the normalized ageGroup value
|
4112
|
+
return Object.assign(Object.assign({}, runtimeConfig), { hostVersionsInfo: Object.assign(Object.assign({}, runtimeConfig.hostVersionsInfo), { appEligibilityInformation: Object.assign(Object.assign({}, runtimeConfig.hostVersionsInfo.appEligibilityInformation), { ageGroup: LegalAgeGroupClassification.NotAdult }) }) });
|
4113
|
+
}
|
4077
4114
|
|
4078
4115
|
;// ./src/public/uuidObject.ts
|
4079
4116
|
|
@@ -4607,7 +4644,7 @@ function isSerializable(arg) {
|
|
4607
4644
|
* @hidden
|
4608
4645
|
* Package version.
|
4609
4646
|
*/
|
4610
|
-
const version = "2.
|
4647
|
+
const version = "2.43.0";
|
4611
4648
|
|
4612
4649
|
;// ./src/public/featureFlags.ts
|
4613
4650
|
// All build feature flags are defined inside this object. Any build feature flag must have its own unique getter and setter function. This pattern allows for client apps to treeshake unused code and avoid including code guarded by this feature flags in the final bundle. If this property isn't desired, use the below runtime feature flags object.
|
@@ -5489,6 +5526,7 @@ function transformLegacyContextToAppContext(legacyContext) {
|
|
5489
5526
|
theme: legacyContext.theme ? legacyContext.theme : 'default',
|
5490
5527
|
iconPositionVertical: legacyContext.appIconPosition,
|
5491
5528
|
osLocaleInfo: legacyContext.osLocaleInfo,
|
5529
|
+
messageId: legacyContext.messageId,
|
5492
5530
|
parentMessageId: legacyContext.parentMessageId,
|
5493
5531
|
userClickTime: legacyContext.userClickTime,
|
5494
5532
|
userClickTimeV2: legacyContext.userClickTimeV2,
|
@@ -6575,12 +6613,14 @@ function initializeHelper(apiVersionTag, validMessageOrigins) {
|
|
6575
6613
|
// After Teams updates its client code, we can remove this default code.
|
6576
6614
|
try {
|
6577
6615
|
initializeHelperLogger('Parsing %s', runtimeConfig);
|
6578
|
-
|
6616
|
+
let givenRuntimeConfig = JSON.parse(runtimeConfig);
|
6579
6617
|
initializeHelperLogger('Checking if %o is a valid runtime object', givenRuntimeConfig !== null && givenRuntimeConfig !== void 0 ? givenRuntimeConfig : 'null');
|
6580
6618
|
// Check that givenRuntimeConfig is a valid instance of IBaseRuntime
|
6581
6619
|
if (!givenRuntimeConfig || !givenRuntimeConfig.apiVersion) {
|
6582
6620
|
throw new Error('Received runtime config is invalid');
|
6583
6621
|
}
|
6622
|
+
// Normalize ageGroup value for backward compatibility
|
6623
|
+
givenRuntimeConfig = normalizeAgeGroupValue(givenRuntimeConfig);
|
6584
6624
|
runtimeConfig && applyRuntimeConfig(givenRuntimeConfig);
|
6585
6625
|
}
|
6586
6626
|
catch (e) {
|
@@ -6594,12 +6634,13 @@ function initializeHelper(apiVersionTag, validMessageOrigins) {
|
|
6594
6634
|
if (!isNaN(compareSDKVersions(runtimeConfig, defaultSDKVersionForCompatCheck))) {
|
6595
6635
|
GlobalVars.clientSupportedSDKVersion = runtimeConfig;
|
6596
6636
|
}
|
6597
|
-
|
6637
|
+
let givenRuntimeConfig = JSON.parse(clientSupportedSDKVersion);
|
6598
6638
|
initializeHelperLogger('givenRuntimeConfig parsed to %o', givenRuntimeConfig !== null && givenRuntimeConfig !== void 0 ? givenRuntimeConfig : 'null');
|
6599
6639
|
if (!givenRuntimeConfig) {
|
6600
6640
|
throw new Error('givenRuntimeConfig string was successfully parsed. However, it parsed to value of null');
|
6601
6641
|
}
|
6602
6642
|
else {
|
6643
|
+
givenRuntimeConfig = normalizeAgeGroupValue(givenRuntimeConfig);
|
6603
6644
|
applyRuntimeConfig(givenRuntimeConfig);
|
6604
6645
|
}
|
6605
6646
|
}
|
@@ -9431,7 +9472,7 @@ function eligibility_isSupported() {
|
|
9431
9472
|
* @beta
|
9432
9473
|
*/
|
9433
9474
|
function getEligibilityInfo(forceRefresh) {
|
9434
|
-
var _a, _b;
|
9475
|
+
var _a, _b, _c;
|
9435
9476
|
return eligibility_awaiter(this, void 0, void 0, function* () {
|
9436
9477
|
ensureInitialized(runtime);
|
9437
9478
|
if (!eligibility_isSupported()) {
|
@@ -9452,6 +9493,10 @@ function getEligibilityInfo(forceRefresh) {
|
|
9452
9493
|
if (!isEligibilityInfoValid(response)) {
|
9453
9494
|
throw new Error('Error deserializing eligibility information');
|
9454
9495
|
}
|
9496
|
+
// convert nonAdult age group to NotAdult
|
9497
|
+
if (((_c = response.ageGroup) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'nonadult') {
|
9498
|
+
response.ageGroup = LegalAgeGroupClassification.NotAdult;
|
9499
|
+
}
|
9455
9500
|
return response;
|
9456
9501
|
});
|
9457
9502
|
}
|
@@ -19480,6 +19525,262 @@ function marketplace_isSupported() {
|
|
19480
19525
|
return ensureInitialized(runtime) && runtime.supports.marketplace ? true : false;
|
19481
19526
|
}
|
19482
19527
|
|
19528
|
+
;// ./src/public/shortcutRelay.ts
|
19529
|
+
/**
|
19530
|
+
* Allows host shortcuts to function in your application by forwarding keyboard shortcuts to the host.
|
19531
|
+
*
|
19532
|
+
* This functionality is in Beta.
|
19533
|
+
* @beta
|
19534
|
+
* @module
|
19535
|
+
*/
|
19536
|
+
var shortcutRelay_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
19537
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
19538
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
19539
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
19540
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
19541
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
19542
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
19543
|
+
});
|
19544
|
+
};
|
19545
|
+
|
19546
|
+
|
19547
|
+
|
19548
|
+
|
19549
|
+
|
19550
|
+
|
19551
|
+
|
19552
|
+
/* ------------------------------------------------------------------ */
|
19553
|
+
/* Utils */
|
19554
|
+
/* ------------------------------------------------------------------ */
|
19555
|
+
class SerializableKeyboardEvent {
|
19556
|
+
constructor(event) {
|
19557
|
+
this.event = event;
|
19558
|
+
}
|
19559
|
+
serialize() {
|
19560
|
+
return {
|
19561
|
+
altKey: this.event.altKey,
|
19562
|
+
bubbles: this.event.bubbles,
|
19563
|
+
cancelBubble: this.event.cancelBubble,
|
19564
|
+
charCode: this.event.charCode,
|
19565
|
+
code: this.event.code,
|
19566
|
+
composed: this.event.composed,
|
19567
|
+
ctrlKey: this.event.ctrlKey,
|
19568
|
+
// currentTarget: skipped
|
19569
|
+
defaultPrevented: this.event.defaultPrevented,
|
19570
|
+
detail: this.event.detail,
|
19571
|
+
eventPhase: this.event.eventPhase,
|
19572
|
+
isComposing: this.event.isComposing,
|
19573
|
+
isTrusted: this.event.isTrusted,
|
19574
|
+
key: this.event.key,
|
19575
|
+
keyCode: this.event.keyCode,
|
19576
|
+
location: this.event.location,
|
19577
|
+
metaKey: this.event.metaKey,
|
19578
|
+
// path - skipped,
|
19579
|
+
repeat: this.event.repeat,
|
19580
|
+
returnValue: this.event.returnValue,
|
19581
|
+
shiftKey: this.event.shiftKey,
|
19582
|
+
// sourceCapabilities - skipped,
|
19583
|
+
// srcElement - slipped.
|
19584
|
+
// target - skipped.
|
19585
|
+
timeStamp: this.event.timeStamp,
|
19586
|
+
type: this.event.type,
|
19587
|
+
// view - skipped
|
19588
|
+
which: this.event.which,
|
19589
|
+
};
|
19590
|
+
}
|
19591
|
+
}
|
19592
|
+
/**
|
19593
|
+
* Normalizes a shortcut string to a canonical form.
|
19594
|
+
*/
|
19595
|
+
function normalizeShortcut(shortcut) {
|
19596
|
+
return shortcut.toLowerCase().split('+').sort().join('+');
|
19597
|
+
}
|
19598
|
+
/**
|
19599
|
+
* Build a canonical, lower-case “ctrl+shift+x” representation of the
|
19600
|
+
* currently pressed keys. The array is sorted so the order in which
|
19601
|
+
* modifiers are pressed does not matter.
|
19602
|
+
*/
|
19603
|
+
function eventToCanonicalShortcut(e) {
|
19604
|
+
return [e.ctrlKey && 'ctrl', e.shiftKey && 'shift', e.altKey && 'alt', e.metaKey && 'meta', e.key.toLowerCase()]
|
19605
|
+
.filter(Boolean)
|
19606
|
+
.sort()
|
19607
|
+
.join('+');
|
19608
|
+
}
|
19609
|
+
/**
|
19610
|
+
* Checks if the event is a valid shortcut event.
|
19611
|
+
* A valid shortcut event is one that has at least one modifier key pressed
|
19612
|
+
* (ctrl, shift, alt, meta) or the Escape key.
|
19613
|
+
*/
|
19614
|
+
function isValidShortcutEvent(e) {
|
19615
|
+
return e.ctrlKey || e.shiftKey || e.altKey || e.metaKey || (!!e.key && e.key.toLowerCase() === 'escape');
|
19616
|
+
}
|
19617
|
+
function isMatchingShortcut(shortcuts, e) {
|
19618
|
+
if (isValidShortcutEvent(e)) {
|
19619
|
+
const pressedShortcut = eventToCanonicalShortcut(e);
|
19620
|
+
const isMatching = shortcuts.has(pressedShortcut);
|
19621
|
+
if (isMatching) {
|
19622
|
+
return {
|
19623
|
+
matchedShortcut: pressedShortcut,
|
19624
|
+
isOverridable: overridableShortcuts.has(pressedShortcut),
|
19625
|
+
};
|
19626
|
+
}
|
19627
|
+
}
|
19628
|
+
return {
|
19629
|
+
matchedShortcut: undefined,
|
19630
|
+
isOverridable: false,
|
19631
|
+
};
|
19632
|
+
}
|
19633
|
+
function updateHostShortcuts(data) {
|
19634
|
+
hostShortcuts.clear();
|
19635
|
+
data.shortcuts.forEach((shortcut) => {
|
19636
|
+
hostShortcuts.add(normalizeShortcut(shortcut));
|
19637
|
+
});
|
19638
|
+
overridableShortcuts.clear();
|
19639
|
+
data.overridableShortcuts.forEach((shortcut) => {
|
19640
|
+
overridableShortcuts.add(normalizeShortcut(shortcut));
|
19641
|
+
});
|
19642
|
+
}
|
19643
|
+
class HostShortcutsResponseHandler extends ResponseHandler {
|
19644
|
+
validate(response) {
|
19645
|
+
return response && Array.isArray(response.shortcuts) && Array.isArray(response.overridableShortcuts);
|
19646
|
+
}
|
19647
|
+
deserialize(response) {
|
19648
|
+
return response;
|
19649
|
+
}
|
19650
|
+
}
|
19651
|
+
/**
|
19652
|
+
* register a handler to be called when shortcuts are updated in the host.
|
19653
|
+
*/
|
19654
|
+
function registerOnHostShortcutChangedHandler(handler) {
|
19655
|
+
registerHandler(getApiVersionTag("v2" /* ApiVersionNumber.V_2 */, "shortcutRelay.hostShortcutChanged" /* ApiName.ShortcutRelay_HostShortcutChanged */), "shortcutRelay.hostShortcutChanged" /* ApiName.ShortcutRelay_HostShortcutChanged */, handler);
|
19656
|
+
}
|
19657
|
+
function keydownHandler(event) {
|
19658
|
+
// Skip if the event target is within an element that has the `data-disable-shortcuts-forwarding` attribute
|
19659
|
+
if (event.target.closest(`[${DISABLE_SHORTCUT_FORWARDING_ATTRIBUTE}]`)) {
|
19660
|
+
return;
|
19661
|
+
}
|
19662
|
+
const { matchedShortcut, isOverridable } = isMatchingShortcut(hostShortcuts, event);
|
19663
|
+
if (!matchedShortcut) {
|
19664
|
+
return; // ignore unrelated events
|
19665
|
+
}
|
19666
|
+
if (isOverridable && overridableShortcutHandler) {
|
19667
|
+
const shouldOverride = overridableShortcutHandler(event, { matchedShortcut });
|
19668
|
+
if (shouldOverride) {
|
19669
|
+
return; // Do not forward shortcut to host
|
19670
|
+
}
|
19671
|
+
}
|
19672
|
+
/* Forward shortcut to host */
|
19673
|
+
const payload = new SerializableKeyboardEvent(event);
|
19674
|
+
callFunctionInHost("shortcutRelay.forwardShortcutEvent" /* ApiName.ShortcutRelay_ForwardShortcutEvent */, [payload], getApiVersionTag("v2" /* ApiVersionNumber.V_2 */, "shortcutRelay.forwardShortcutEvent" /* ApiName.ShortcutRelay_ForwardShortcutEvent */));
|
19675
|
+
event.preventDefault();
|
19676
|
+
event.stopImmediatePropagation();
|
19677
|
+
}
|
19678
|
+
/* ------------------------------------------------------------------ */
|
19679
|
+
/* In-memory */
|
19680
|
+
/* ------------------------------------------------------------------ */
|
19681
|
+
/**
|
19682
|
+
* @hidden
|
19683
|
+
* @internal
|
19684
|
+
* Stores the shortcuts that can be overridden by the app.
|
19685
|
+
*/
|
19686
|
+
const overridableShortcuts = new Set();
|
19687
|
+
/**
|
19688
|
+
* @hidden
|
19689
|
+
* @internal
|
19690
|
+
* Stores the shortcuts that are enabled in host.
|
19691
|
+
* This set is populated when the host sends the list of enabled shortcuts.
|
19692
|
+
*/
|
19693
|
+
const hostShortcuts = new Set();
|
19694
|
+
/**
|
19695
|
+
* @hidden
|
19696
|
+
* @internal
|
19697
|
+
* Stores the handler for overridable shortcuts.
|
19698
|
+
*/
|
19699
|
+
let overridableShortcutHandler = undefined;
|
19700
|
+
/**
|
19701
|
+
* @hidden
|
19702
|
+
* @internal
|
19703
|
+
* Flag to indicate if the shortcut relay capability has been enabled, so that we do not register the event listener multiple times.
|
19704
|
+
*/
|
19705
|
+
let isShortcutRelayCapabilityEnabled = false;
|
19706
|
+
/* ------------------------------------------------------------------ */
|
19707
|
+
/* API */
|
19708
|
+
/* ------------------------------------------------------------------ */
|
19709
|
+
/**
|
19710
|
+
* Replace the current overridable-shortcut handler.
|
19711
|
+
*
|
19712
|
+
* • Pass `undefined` to remove an existing handler.
|
19713
|
+
* • Returns the previous handler so callers can restore it if needed.
|
19714
|
+
*
|
19715
|
+
* @beta
|
19716
|
+
*/
|
19717
|
+
function setOverridableShortcutHandler(handler) {
|
19718
|
+
if (!shortcutRelay_isSupported()) {
|
19719
|
+
throw errorNotSupportedOnPlatform;
|
19720
|
+
}
|
19721
|
+
const previous = overridableShortcutHandler;
|
19722
|
+
overridableShortcutHandler = handler;
|
19723
|
+
return previous;
|
19724
|
+
}
|
19725
|
+
/**
|
19726
|
+
* Reset the state of the shortcut relay capability.
|
19727
|
+
* This is useful for tests to ensure a clean state.
|
19728
|
+
*
|
19729
|
+
* @beta
|
19730
|
+
*/
|
19731
|
+
function resetIsShortcutRelayCapabilityEnabled() {
|
19732
|
+
if (!shortcutRelay_isSupported()) {
|
19733
|
+
throw errorNotSupportedOnPlatform;
|
19734
|
+
}
|
19735
|
+
isShortcutRelayCapabilityEnabled = false;
|
19736
|
+
hostShortcuts.clear();
|
19737
|
+
overridableShortcuts.clear();
|
19738
|
+
overridableShortcutHandler = undefined;
|
19739
|
+
document.removeEventListener('keydown', keydownHandler, { capture: true });
|
19740
|
+
}
|
19741
|
+
/**
|
19742
|
+
* Enable capability to support host shortcuts.
|
19743
|
+
*
|
19744
|
+
* @beta
|
19745
|
+
*/
|
19746
|
+
function enableShortcutRelayCapability() {
|
19747
|
+
return shortcutRelay_awaiter(this, void 0, void 0, function* () {
|
19748
|
+
if (!shortcutRelay_isSupported()) {
|
19749
|
+
throw errorNotSupportedOnPlatform;
|
19750
|
+
}
|
19751
|
+
/* 1. Ask host for the list of enabled shortcuts */
|
19752
|
+
const response = yield callFunctionInHostAndHandleResponse("shortcutRelay.getHostShortcuts" /* ApiName.ShortcutRelay_GetHostShortcuts */, [], new HostShortcutsResponseHandler(), getApiVersionTag("v2" /* ApiVersionNumber.V_2 */, "shortcutRelay.getHostShortcuts" /* ApiName.ShortcutRelay_GetHostShortcuts */));
|
19753
|
+
updateHostShortcuts(response);
|
19754
|
+
/* 2. Global key-down handler */
|
19755
|
+
if (!isShortcutRelayCapabilityEnabled) {
|
19756
|
+
document.addEventListener('keydown', keydownHandler, { capture: true });
|
19757
|
+
}
|
19758
|
+
isShortcutRelayCapabilityEnabled = true;
|
19759
|
+
/* 3. Register handler for host shortcut updates */
|
19760
|
+
registerOnHostShortcutChangedHandler((hostShortcuts) => {
|
19761
|
+
updateHostShortcuts(hostShortcuts);
|
19762
|
+
});
|
19763
|
+
});
|
19764
|
+
}
|
19765
|
+
/**
|
19766
|
+
* Checks if shortcutRelay capability is supported by the host
|
19767
|
+
* @returns boolean to represent whether the shortcutRelay capability is supported
|
19768
|
+
*
|
19769
|
+
* @throws Error if {@link app.initialize} has not successfully completed
|
19770
|
+
*
|
19771
|
+
* @beta
|
19772
|
+
*/
|
19773
|
+
function shortcutRelay_isSupported() {
|
19774
|
+
return ensureInitialized(runtime) && runtime.supports.shortcutRelay ? true : false;
|
19775
|
+
}
|
19776
|
+
/**
|
19777
|
+
* Allow apps to define zones where shortcuts should not be forwarded to the host.
|
19778
|
+
* This is useful for input fields for password where shortcuts should not trigger host actions.
|
19779
|
+
*
|
19780
|
+
* @beta
|
19781
|
+
*/
|
19782
|
+
const DISABLE_SHORTCUT_FORWARDING_ATTRIBUTE = 'data-disable-shortcuts-forwarding';
|
19783
|
+
|
19483
19784
|
;// ./src/public/index.ts
|
19484
19785
|
|
19485
19786
|
|
@@ -19564,6 +19865,8 @@ function marketplace_isSupported() {
|
|
19564
19865
|
|
19565
19866
|
|
19566
19867
|
|
19868
|
+
|
19869
|
+
|
19567
19870
|
|
19568
19871
|
;// ./src/index.ts
|
19569
19872
|
|