@microsoft/teams-js 2.42.0 → 2.44.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/public/index.d.ts +1 -0
- package/dist/esm/packages/teams-js/dts/public/interfaces.d.ts +27 -0
- 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/index.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 +271 -1
- 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
package/README.md
CHANGED
@@ -24,7 +24,7 @@ To install the stable [version](https://learn.microsoft.com/javascript/api/overv
|
|
24
24
|
|
25
25
|
### Production
|
26
26
|
|
27
|
-
You can reference these files directly [from here](https://res.cdn.office.net/teams-js/2.
|
27
|
+
You can reference these files directly [from here](https://res.cdn.office.net/teams-js/2.44.0/js/MicrosoftTeams.min.js) or point your package manager at them.
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
@@ -45,13 +45,13 @@ Reference the library inside of your `.html` page using:
|
|
45
45
|
```html
|
46
46
|
<!-- Microsoft Teams JavaScript API (via CDN) -->
|
47
47
|
<script
|
48
|
-
src="https://res.cdn.office.net/teams-js/2.
|
49
|
-
integrity="sha384-
|
48
|
+
src="https://res.cdn.office.net/teams-js/2.43.1/js/MicrosoftTeams.min.js"
|
49
|
+
integrity="sha384-7ORQy8xx1gKRnfigO9zP+eIdkANt5I5YKoTJh4P55DqdbkInsqjaevmrCNLwtkLb"
|
50
50
|
crossorigin="anonymous"
|
51
51
|
></script>
|
52
52
|
|
53
53
|
<!-- Microsoft Teams JavaScript API (via npm) -->
|
54
|
-
<script src="node_modules/@microsoft/teams-js@2.
|
54
|
+
<script src="node_modules/@microsoft/teams-js@2.43.1/dist/MicrosoftTeams.min.js"></script>
|
55
55
|
|
56
56
|
<!-- Microsoft Teams JavaScript API (via local) -->
|
57
57
|
<script src="MicrosoftTeams.min.js"></script>
|
@@ -307,6 +307,9 @@ export declare const enum ApiName {
|
|
307
307
|
Settings_SetValidityState = "settings.setValidityState",
|
308
308
|
Sharing_History_GetContent = "sharing.history.getContent",
|
309
309
|
Sharing_ShareWebContent = "sharing.shareWebContent",
|
310
|
+
ShortcutRelay_GetHostShortcuts = "shortcutRelay.getHostShortcuts",
|
311
|
+
ShortcutRelay_ForwardShortcutEvent = "shortcutRelay.forwardShortcutEvent",
|
312
|
+
ShortcutRelay_HostShortcutChanged = "shortcutRelay.hostShortcutChanged",
|
310
313
|
StageView_Open = "stageView.open",
|
311
314
|
StageView_Self_Close = "stageView.self.close",
|
312
315
|
Store_OpenFullStore = "store.openFullStore",
|
@@ -1050,6 +1050,11 @@ export interface AppEligibilityInformation {
|
|
1050
1050
|
* Education Eligibility Information for the app user
|
1051
1051
|
*/
|
1052
1052
|
userClassification: UserClassification | null;
|
1053
|
+
/**
|
1054
|
+
* Describes settings available to the user.
|
1055
|
+
* If this property is undefined, it indicates that the host is an older version that doesn't support this property.
|
1056
|
+
*/
|
1057
|
+
settings?: AppSettings | null;
|
1053
1058
|
}
|
1054
1059
|
/**
|
1055
1060
|
* @hidden
|
@@ -1081,6 +1086,28 @@ export interface UserClassificationWithEduType {
|
|
1081
1086
|
*/
|
1082
1087
|
persona: Persona.Faculty | Persona.Student;
|
1083
1088
|
}
|
1089
|
+
/**
|
1090
|
+
* @hidden
|
1091
|
+
* @beta
|
1092
|
+
* Represents the settings set available to the user.
|
1093
|
+
*/
|
1094
|
+
export interface AppSettings {
|
1095
|
+
/**
|
1096
|
+
* Describes conversation settings available to the user.
|
1097
|
+
*/
|
1098
|
+
conversationSettings?: AppConversationSettings | null;
|
1099
|
+
}
|
1100
|
+
/**
|
1101
|
+
* @hidden
|
1102
|
+
* @beta
|
1103
|
+
* Represents the conversation settings available to the user.
|
1104
|
+
*/
|
1105
|
+
export interface AppConversationSettings {
|
1106
|
+
/**
|
1107
|
+
* Indicates OCE admin toggle
|
1108
|
+
*/
|
1109
|
+
isOptionalConnectedExperiencesEnabled: boolean;
|
1110
|
+
}
|
1084
1111
|
/**
|
1085
1112
|
* @hidden
|
1086
1113
|
*
|
@@ -0,0 +1,60 @@
|
|
1
|
+
/**
|
2
|
+
* Allows host shortcuts to function in your application by forwarding keyboard shortcuts to the host.
|
3
|
+
*
|
4
|
+
* This functionality is in Beta.
|
5
|
+
* @beta
|
6
|
+
* @module
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* Data passed to the overridable shortcut handler.
|
10
|
+
*/
|
11
|
+
export type OverridableShortcutHandlerData = {
|
12
|
+
/**
|
13
|
+
* The matched shortcut that triggered the handler.
|
14
|
+
* This is a canonical form of the shortcut, e.g. "ctrl+shift+x".
|
15
|
+
*/
|
16
|
+
matchedShortcut: string;
|
17
|
+
};
|
18
|
+
/**
|
19
|
+
* A handler must return `true` when it wants to **consume** the shortcut
|
20
|
+
* (i.e. prevent forwarding to host). Any other return value forwards it.
|
21
|
+
*/
|
22
|
+
export type OverridableShortcutHandler = (event: KeyboardEvent, data: OverridableShortcutHandlerData) => boolean;
|
23
|
+
/**
|
24
|
+
* Replace the current overridable-shortcut handler.
|
25
|
+
*
|
26
|
+
* • Pass `undefined` to remove an existing handler.
|
27
|
+
* • Returns the previous handler so callers can restore it if needed.
|
28
|
+
*
|
29
|
+
* @beta
|
30
|
+
*/
|
31
|
+
export declare function setOverridableShortcutHandler(handler: OverridableShortcutHandler | undefined): OverridableShortcutHandler | undefined;
|
32
|
+
/**
|
33
|
+
* Reset the state of the shortcut relay capability.
|
34
|
+
* This is useful for tests to ensure a clean state.
|
35
|
+
*
|
36
|
+
* @beta
|
37
|
+
*/
|
38
|
+
export declare function resetIsShortcutRelayCapabilityEnabled(): void;
|
39
|
+
/**
|
40
|
+
* Enable capability to support host shortcuts.
|
41
|
+
*
|
42
|
+
* @beta
|
43
|
+
*/
|
44
|
+
export declare function enableShortcutRelayCapability(): Promise<void>;
|
45
|
+
/**
|
46
|
+
* Checks if shortcutRelay capability is supported by the host
|
47
|
+
* @returns boolean to represent whether the shortcutRelay capability is supported
|
48
|
+
*
|
49
|
+
* @throws Error if {@link app.initialize} has not successfully completed
|
50
|
+
*
|
51
|
+
* @beta
|
52
|
+
*/
|
53
|
+
export declare function isSupported(): boolean;
|
54
|
+
/**
|
55
|
+
* Allow apps to define zones where shortcuts should not be forwarded to the host.
|
56
|
+
* This is useful for input fields for password where shortcuts should not trigger host actions.
|
57
|
+
*
|
58
|
+
* @beta
|
59
|
+
*/
|
60
|
+
export declare const DISABLE_SHORTCUT_FORWARDING_ATTRIBUTE = "data-disable-shortcuts-forwarding";
|
@@ -1 +1 @@
|
|
1
|
-
export{NotificationTypes,UserSettingTypes,ViewerActionTypes}from"./private/interfaces.js";export{openFilePreview,registerCustomHandler,registerUserSettingsChangeHandler,sendCustomEvent,sendCustomMessage,uploadCustomApp}from"./private/privateAPIs.js";import*as e from"./private/logs.js";export{e as logs};import*as r from"./private/conversations.js";export{r as conversations};import*as t from"./private/copilot/copilot.js";export{t as copilot};import*as o from"./private/copilot/sidePanelInterfaces.js";export{o as sidePanelInterfaces};import*as p from"./private/externalAppAuthentication.js";export{p as externalAppAuthentication};import*as i from"./private/externalAppAuthenticationForCEA.js";export{i as externalAppAuthenticationForCEA};import*as a from"./private/externalAppCardActions.js";export{a as externalAppCardActions};import*as s from"./private/externalAppCardActionsForCEA.js";export{s as externalAppCardActionsForCEA};import*as m from"./private/externalAppCardActionsForDA.js";export{m as externalAppCardActionsForDA};import*as n from"./private/externalAppCommands.js";export{n as externalAppCommands};import*as l from"./private/files.js";export{l as files};import*as c from"./private/meetingRoom.js";export{c as meetingRoom};import*as f from"./private/messageChannels/messageChannels.js";export{f as messageChannels};import*as u from"./private/nestedAppAuth/nestedAppAuthBridge.js";export{u as nestedAppAuthBridge};import*as x from"./private/notifications.js";export{x as notifications};import*as j from"./private/otherAppStateChange.js";export{j as otherAppStateChange};import*as d from"./private/remoteCamera.js";export{d as remoteCamera};import*as g from"./private/appEntity.js";export{g as appEntity};import*as b from"./private/teams/teams.js";export{b as teams};import*as v from"./private/videoEffectsEx.js";export{v as videoEffectsEx};import*as C from"./private/hostEntity/hostEntity.js";export{C as hostEntity};import*as A from"./private/store.js";export{A as store};export{ChannelType,DialogDimension,FrameContexts,HostClientType,HostName,RenderingSurfaces,DialogDimension as TaskModuleDimension,TeamType,UserTeamRole}from"./public/constants.js";export{ActionObjectType,EduType,ErrorCode,FileOpenPreference,SecondaryM365ContentIdName}from"./public/interfaces.js";export{AppId}from"./public/appId.js";export{EmailAddress}from"./public/emailAddress.js";export{activateChildProxyingCommunication,getCurrentFeatureFlagsState,overwriteFeatureFlagsState,setFeatureFlagsState}from"./public/featureFlags.js";export{getAdaptiveCardSchemaVersion}from"./public/adaptiveCards.js";export{ChildAppWindow,ParentAppWindow}from"./public/appWindow.js";export{ValidatedSafeString}from"./public/validatedSafeString.js";export{version}from"./public/version.js";export{enablePrintCapability,executeDeepLink,getContext,getMruTabInstances,getTabInstances,initialize,initializeWithFrameContext,print,registerAppButtonClickHandler,registerAppButtonHoverEnterHandler,registerAppButtonHoverLeaveHandler,registerBackButtonHandler,registerBeforeUnloadHandler,registerChangeSettingsHandler,registerFocusEnterHandler,registerFullScreenHandler,registerOnLoadHandler,registerOnThemeChangeHandler,setFrameContext,shareDeepLink}from"./public/publicAPIs.js";export{navigateBack,navigateCrossDomain,navigateToTab,returnFocus}from"./public/navigation.js";export{UUID}from"./public/uuidObject.js";import*as h from"./public/liveShareHost.js";export{h as liveShare};export{LiveShareHost}from"./public/liveShareHost.js";import*as S from"./public/authentication.js";export{S as authentication};import*as H from"./public/app/app.js";export{H as app};import*as F from"./public/appInstallDialog.js";export{F as appInstallDialog};import*as y from"./public/barCode.js";export{y as barCode};import*as T from"./public/chat.js";export{T as chat};import*as E from"./public/clipboard.js";export{E as clipboard};import*as I from"./public/dialog/dialog.js";export{I as dialog};import*as D from"./public/nestedAppAuth.js";export{D as nestedAppAuth};import*as w from"./public/geoLocation/geoLocation.js";export{w as geoLocation};import*as P from"./public/pages/pages.js";export{P as pages};import*as B from"./public/menus.js";export{B as menus};import*as k from"./public/media.js";export{k as media};import*as L from"./public/secondaryBrowser.js";export{L as secondaryBrowser};import*as M from"./public/location.js";export{M as location};import*as U from"./public/meeting/meeting.js";export{U as meeting};import*as O from"./public/monetization.js";export{O as monetization};import*as V from"./public/calendar.js";export{V as calendar};import*as z from"./public/mail/mail.js";export{z as mail};import*as
|
1
|
+
export{NotificationTypes,UserSettingTypes,ViewerActionTypes}from"./private/interfaces.js";export{openFilePreview,registerCustomHandler,registerUserSettingsChangeHandler,sendCustomEvent,sendCustomMessage,uploadCustomApp}from"./private/privateAPIs.js";import*as e from"./private/logs.js";export{e as logs};import*as r from"./private/conversations.js";export{r as conversations};import*as t from"./private/copilot/copilot.js";export{t as copilot};import*as o from"./private/copilot/sidePanelInterfaces.js";export{o as sidePanelInterfaces};import*as p from"./private/externalAppAuthentication.js";export{p as externalAppAuthentication};import*as i from"./private/externalAppAuthenticationForCEA.js";export{i as externalAppAuthenticationForCEA};import*as a from"./private/externalAppCardActions.js";export{a as externalAppCardActions};import*as s from"./private/externalAppCardActionsForCEA.js";export{s as externalAppCardActionsForCEA};import*as m from"./private/externalAppCardActionsForDA.js";export{m as externalAppCardActionsForDA};import*as n from"./private/externalAppCommands.js";export{n as externalAppCommands};import*as l from"./private/files.js";export{l as files};import*as c from"./private/meetingRoom.js";export{c as meetingRoom};import*as f from"./private/messageChannels/messageChannels.js";export{f as messageChannels};import*as u from"./private/nestedAppAuth/nestedAppAuthBridge.js";export{u as nestedAppAuthBridge};import*as x from"./private/notifications.js";export{x as notifications};import*as j from"./private/otherAppStateChange.js";export{j as otherAppStateChange};import*as d from"./private/remoteCamera.js";export{d as remoteCamera};import*as g from"./private/appEntity.js";export{g as appEntity};import*as b from"./private/teams/teams.js";export{b as teams};import*as v from"./private/videoEffectsEx.js";export{v as videoEffectsEx};import*as C from"./private/hostEntity/hostEntity.js";export{C as hostEntity};import*as A from"./private/store.js";export{A as store};export{ChannelType,DialogDimension,FrameContexts,HostClientType,HostName,RenderingSurfaces,DialogDimension as TaskModuleDimension,TeamType,UserTeamRole}from"./public/constants.js";export{ActionObjectType,EduType,ErrorCode,FileOpenPreference,SecondaryM365ContentIdName}from"./public/interfaces.js";export{AppId}from"./public/appId.js";export{EmailAddress}from"./public/emailAddress.js";export{activateChildProxyingCommunication,getCurrentFeatureFlagsState,overwriteFeatureFlagsState,setFeatureFlagsState}from"./public/featureFlags.js";export{getAdaptiveCardSchemaVersion}from"./public/adaptiveCards.js";export{ChildAppWindow,ParentAppWindow}from"./public/appWindow.js";export{ValidatedSafeString}from"./public/validatedSafeString.js";export{version}from"./public/version.js";export{enablePrintCapability,executeDeepLink,getContext,getMruTabInstances,getTabInstances,initialize,initializeWithFrameContext,print,registerAppButtonClickHandler,registerAppButtonHoverEnterHandler,registerAppButtonHoverLeaveHandler,registerBackButtonHandler,registerBeforeUnloadHandler,registerChangeSettingsHandler,registerFocusEnterHandler,registerFullScreenHandler,registerOnLoadHandler,registerOnThemeChangeHandler,setFrameContext,shareDeepLink}from"./public/publicAPIs.js";export{navigateBack,navigateCrossDomain,navigateToTab,returnFocus}from"./public/navigation.js";export{UUID}from"./public/uuidObject.js";import*as h from"./public/liveShareHost.js";export{h as liveShare};export{LiveShareHost}from"./public/liveShareHost.js";import*as S from"./public/authentication.js";export{S as authentication};import*as H from"./public/app/app.js";export{H as app};import*as F from"./public/appInstallDialog.js";export{F as appInstallDialog};import*as y from"./public/barCode.js";export{y as barCode};import*as T from"./public/chat.js";export{T as chat};import*as E from"./public/clipboard.js";export{E as clipboard};import*as I from"./public/dialog/dialog.js";export{I as dialog};import*as D from"./public/nestedAppAuth.js";export{D as nestedAppAuth};import*as w from"./public/geoLocation/geoLocation.js";export{w as geoLocation};import*as P from"./public/pages/pages.js";export{P as pages};import*as B from"./public/menus.js";export{B as menus};import*as k from"./public/media.js";export{k as media};import*as L from"./public/secondaryBrowser.js";export{L as secondaryBrowser};import*as M from"./public/location.js";export{M as location};import*as U from"./public/meeting/meeting.js";export{U as meeting};import*as O from"./public/monetization.js";export{O as monetization};import*as V from"./public/calendar.js";export{V as calendar};import*as z from"./public/mail/mail.js";export{z as mail};import*as R from"./public/teamsAPIs.js";export{R as teamsCore};import*as W from"./public/people.js";export{W as people};import*as N from"./public/profile.js";export{N as profile};import*as q from"./public/videoEffects.js";export{q as videoEffects};import*as G from"./public/search.js";export{G as search};import*as J from"./public/sharing/sharing.js";export{J as sharing};import*as K from"./public/stageView/stageView.js";export{K as stageView};import*as Q from"./public/visualMedia/visualMedia.js";export{Q as visualMedia};import*as X from"./public/webStorage.js";export{X as webStorage};import*as Y from"./public/call.js";export{Y as call};import*as Z from"./public/appInitialization.js";export{Z as appInitialization};import*as $ from"./public/thirdPartyCloudStorage.js";export{$ as thirdPartyCloudStorage};import*as _ from"./public/settings.js";export{_ as settings};import*as ee from"./public/tasks.js";export{ee as tasks};import*as re from"./public/marketplace.js";export{re as marketplace};import*as te from"./public/shortcutRelay.js";export{te as shortcutRelay};
|
@@ -0,0 +1 @@
|
|
1
|
+
import{__awaiter as t}from"../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.24.4_tslib@2.6.3_typescript@4.9.5/node_modules/tslib/tslib.es6.js";import{callFunctionInHost as e,callFunctionInHostAndHandleResponse as r}from"../internal/communication.js";import{registerHandler as o}from"../internal/handlers.js";import{ensureInitialized as n}from"../internal/internalAPIs.js";import{ResponseHandler as s}from"../internal/responseHandler.js";import{getApiVersionTag as i}from"../internal/telemetry.js";import{errorNotSupportedOnPlatform as a}from"./constants.js";import{runtime as c}from"./runtime.js";class h{constructor(t){this.event=t}serialize(){return{altKey:this.event.altKey,bubbles:this.event.bubbles,cancelBubble:this.event.cancelBubble,charCode:this.event.charCode,code:this.event.code,composed:this.event.composed,ctrlKey:this.event.ctrlKey,defaultPrevented:this.event.defaultPrevented,detail:this.event.detail,eventPhase:this.event.eventPhase,isComposing:this.event.isComposing,isTrusted:this.event.isTrusted,key:this.event.key,keyCode:this.event.keyCode,location:this.event.location,metaKey:this.event.metaKey,repeat:this.event.repeat,returnValue:this.event.returnValue,shiftKey:this.event.shiftKey,timeStamp:this.event.timeStamp,type:this.event.type,which:this.event.which}}}function u(t){return t.toLowerCase().split("+").sort().join("+")}function l(t,e){if(function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey||!!t.key&&"escape"===t.key.toLowerCase()}(e)){const r=function(t){return[t.ctrlKey&&"ctrl",t.shiftKey&&"shift",t.altKey&&"alt",t.metaKey&&"meta",t.key.toLowerCase()].filter(Boolean).sort().join("+")}(e);if(t.has(r))return{matchedShortcut:r,isOverridable:f.has(r)}}return{matchedShortcut:void 0,isOverridable:!1}}function d(t){y.clear(),t.shortcuts.forEach((t=>{y.add(u(t))})),f.clear(),t.overridableShortcuts.forEach((t=>{f.add(u(t))}))}class v extends s{validate(t){return t&&Array.isArray(t.shortcuts)&&Array.isArray(t.overridableShortcuts)}deserialize(t){return t}}function m(t){if(t.target.closest(`[${g}]`))return;const{matchedShortcut:r,isOverridable:o}=l(y,t);if(!r)return;if(o&&p){if(p(t,{matchedShortcut:r}))return}const n=new h(t);e("shortcutRelay.forwardShortcutEvent",[n],i("v2","shortcutRelay.forwardShortcutEvent")),t.preventDefault(),t.stopImmediatePropagation()}const f=new Set,y=new Set;let p,b=!1;function w(t){if(!C())throw a;const e=p;return p=t,e}function K(){if(!C())throw a;b=!1,y.clear(),f.clear(),p=void 0,document.removeEventListener("keydown",m,{capture:!0})}function S(){return t(this,void 0,void 0,(function*(){if(!C())throw a;var t;d(yield r("shortcutRelay.getHostShortcuts",[],new v,i("v2","shortcutRelay.getHostShortcuts"))),b||document.addEventListener("keydown",m,{capture:!0}),b=!0,t=t=>{d(t)},o(i("v2","shortcutRelay.hostShortcutChanged"),"shortcutRelay.hostShortcutChanged",t)}))}function C(){return!(!n(c)||!c.supports.shortcutRelay)}const g="data-disable-shortcuts-forwarding";export{g as DISABLE_SHORTCUT_FORWARDING_ATTRIBUTE,S as enableShortcutRelayCapability,C as isSupported,K as resetIsShortcutRelayCapabilityEnabled,w as setOverridableShortcutHandler};
|
@@ -1 +1 @@
|
|
1
|
-
const o="2.
|
1
|
+
const o="2.44.0";export{o as version};
|
@@ -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
|
/**
|
@@ -4632,7 +4644,7 @@ function isSerializable(arg) {
|
|
4632
4644
|
* @hidden
|
4633
4645
|
* Package version.
|
4634
4646
|
*/
|
4635
|
-
const version = "2.
|
4647
|
+
const version = "2.44.0";
|
4636
4648
|
|
4637
4649
|
;// ./src/public/featureFlags.ts
|
4638
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.
|
@@ -19513,6 +19525,262 @@ function marketplace_isSupported() {
|
|
19513
19525
|
return ensureInitialized(runtime) && runtime.supports.marketplace ? true : false;
|
19514
19526
|
}
|
19515
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
|
+
|
19516
19784
|
;// ./src/public/index.ts
|
19517
19785
|
|
19518
19786
|
|
@@ -19597,6 +19865,8 @@ function marketplace_isSupported() {
|
|
19597
19865
|
|
19598
19866
|
|
19599
19867
|
|
19868
|
+
|
19869
|
+
|
19600
19870
|
|
19601
19871
|
;// ./src/index.ts
|
19602
19872
|
|