@24i/bigscreen-sdk 1.0.32 → 1.0.33-alpha.2548

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1055) hide show
  1. package/README.md +47 -47
  2. package/__mocks__/@24i/bigscreen-sdk/animations.ts +2 -2
  3. package/package.json +1 -1
  4. package/packages/adobe-heartbeat/README.md +46 -46
  5. package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +244 -244
  6. package/packages/adobe-heartbeat/src/__external__/Adobe/Adobe.d.ts +24 -24
  7. package/packages/adobe-heartbeat/src/__external__/Adobe/MediaSDK.min.d.ts +126 -126
  8. package/packages/adobe-heartbeat/src/__external__/Adobe/MediaSDK.min.js +76 -76
  9. package/packages/adobe-heartbeat/src/index.ts +5 -5
  10. package/packages/adobe-heartbeat/src/types.ts +67 -67
  11. package/packages/analytics/README.md +7 -7
  12. package/packages/analytics/src/A.ts +1 -1
  13. package/packages/analytics/src/Analytics.ts +1 -1
  14. package/packages/analytics/src/analyticsOnScroll.ts +1 -1
  15. package/packages/analytics/src/clients/ConsoleAnalytics/ConsoleAnalytics.ts +1 -1
  16. package/packages/analytics/src/clients/ConsoleAnalytics/index.ts +1 -1
  17. package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +200 -200
  18. package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +118 -118
  19. package/packages/analytics/src/clients/GoogleAnalytics/generateSessionId.ts +8 -8
  20. package/packages/analytics/src/clients/GoogleAnalytics/getUrl.ts +17 -17
  21. package/packages/analytics/src/clients/GoogleAnalytics/index.ts +2 -2
  22. package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +77 -77
  23. package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +50 -50
  24. package/packages/analytics/src/clients/GoogleAnalytics/prepareBody.ts +14 -14
  25. package/packages/analytics/src/clients/TwentyFourIQ/TwentyFourIQClient.ts +116 -116
  26. package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +99 -99
  27. package/packages/analytics/src/clients/TwentyFourIQ/generateSessionId.ts +8 -8
  28. package/packages/analytics/src/clients/TwentyFourIQ/helper.ts +34 -34
  29. package/packages/analytics/src/clients/TwentyFourIQ/index.ts +2 -2
  30. package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +31 -31
  31. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdLoaded.ts +13 -13
  32. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdSkipped.ts +16 -16
  33. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBase.ts +21 -21
  34. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBuffering.ts +15 -15
  35. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerClose.ts +24 -24
  36. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerOpen.ts +18 -18
  37. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapSceneView.ts +15 -15
  38. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapScroll.ts +17 -17
  39. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoComplete.ts +21 -21
  40. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoPause.ts +24 -24
  41. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoProgress.ts +24 -24
  42. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStart.ts +34 -34
  43. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStop.ts +32 -32
  44. package/packages/analytics/src/clients/TwentyFourIQ/types.ts +115 -115
  45. package/packages/analytics/src/constants.ts +1 -1
  46. package/packages/analytics/src/index.ts +3 -3
  47. package/packages/analytics/src/interface.ts +1 -1
  48. package/packages/animations/README.md +85 -85
  49. package/packages/animations/src/AnimationUtils.ts +238 -238
  50. package/packages/animations/src/JSAnimations.ts +144 -144
  51. package/packages/animations/src/__mocks__/JSAnimations.ts +30 -30
  52. package/packages/animations/src/index.ts +3 -3
  53. package/packages/announcement-banner/README.md +49 -49
  54. package/packages/announcement-banner/src/AnnouncementBanner.scss +8 -8
  55. package/packages/announcement-banner/src/AnnouncementBanner.tsx +136 -136
  56. package/packages/announcement-banner/src/index.ts +1 -1
  57. package/packages/async-image/README.md +47 -47
  58. package/packages/async-image/src/AsyncImage.tsx +101 -101
  59. package/packages/async-image/src/index.ts +2 -2
  60. package/packages/conviva/README.md +47 -47
  61. package/packages/conviva/src/ConvivaSDK.ts +38 -38
  62. package/packages/conviva/src/__mocks__/ConvivaMock.ts +36 -36
  63. package/packages/conviva/src/index.ts +1 -1
  64. package/packages/conviva/src/theoPlugin/ConvivaConviguration.ts +19 -19
  65. package/packages/conviva/src/theoPlugin/__external__/Conviva_4.0.15.js +698 -698
  66. package/packages/conviva/src/theoPlugin/__external__/convivaTheoPlugin.d.ts +7 -7
  67. package/packages/conviva/src/theoPlugin/__external__/convivaTheoPlugin.js +635 -635
  68. package/packages/conviva/src/theoPlugin/convivaTheoPluginWrapper.ts +61 -61
  69. package/packages/conviva/src/theoPlugin/index.ts +2 -2
  70. package/packages/developer-tools/DeveloperConsole/README.md +114 -114
  71. package/packages/developer-tools/DeveloperConsole/index.ts +3 -3
  72. package/packages/developer-tools/DeveloperConsole/unstyled.ts +1 -1
  73. package/packages/developer-tools/DeveloperToolsService/README.md +54 -54
  74. package/packages/developer-tools/DeveloperToolsService/index.ts +3 -3
  75. package/packages/developer-tools/DeveloperToolsService/unstyled.ts +1 -1
  76. package/packages/developer-tools/EnvironmentSelection/README.md +77 -77
  77. package/packages/developer-tools/EnvironmentSelection/index.ts +3 -3
  78. package/packages/developer-tools/EnvironmentSelection/unstyled.ts +1 -1
  79. package/packages/developer-tools/PlayerDebugWindow/README.md +65 -65
  80. package/packages/developer-tools/PlayerDebugWindow/index.ts +3 -3
  81. package/packages/developer-tools/PlayerDebugWindow/unstyled.ts +1 -1
  82. package/packages/developer-tools/README.md +24 -24
  83. package/packages/developer-tools/TechnicalInfo/README.md +90 -90
  84. package/packages/developer-tools/TechnicalInfo/index.ts +9 -9
  85. package/packages/developer-tools/TechnicalInfo/unstyled.ts +6 -6
  86. package/packages/developer-tools/src/DeveloperConsole/ControlButton.tsx +16 -16
  87. package/packages/developer-tools/src/DeveloperConsole/DeveloperConsole.tsx +389 -389
  88. package/packages/developer-tools/src/DeveloperConsole/Panel.tsx +108 -108
  89. package/packages/developer-tools/src/DeveloperConsole/PanelMessage.tsx +33 -33
  90. package/packages/developer-tools/src/DeveloperConsole/helpers/Queue.ts +38 -38
  91. package/packages/developer-tools/src/DeveloperConsole/helpers/index.ts +2 -2
  92. package/packages/developer-tools/src/DeveloperConsole/helpers/instrumentHandler.ts +165 -165
  93. package/packages/developer-tools/src/DeveloperConsole/index.ts +2 -2
  94. package/packages/developer-tools/src/DeveloperConsole/initDeveloperConsole.tsx +8 -8
  95. package/packages/developer-tools/src/DeveloperConsole/styles/DeveloperConsole/DeveloperConsole.scss +91 -91
  96. package/packages/developer-tools/src/DeveloperConsole/styles/DeveloperConsole/DeveloperConsole.styles.1080.scss +2 -2
  97. package/packages/developer-tools/src/DeveloperConsole/styles/DeveloperConsole/DeveloperConsole.styles.scss +2 -2
  98. package/packages/developer-tools/src/DeveloperConsole/styles/DeveloperConsole/_sizes.1080.scss +16 -16
  99. package/packages/developer-tools/src/DeveloperConsole/styles/DeveloperConsole/_sizes.scss +16 -16
  100. package/packages/developer-tools/src/DeveloperConsole/styles/Panel/Panel.scss +87 -87
  101. package/packages/developer-tools/src/DeveloperConsole/styles/Panel/Panel.styles.1080.scss +2 -2
  102. package/packages/developer-tools/src/DeveloperConsole/styles/Panel/Panel.styles.scss +2 -2
  103. package/packages/developer-tools/src/DeveloperConsole/styles/Panel/_sizes.1080.scss +9 -9
  104. package/packages/developer-tools/src/DeveloperConsole/styles/Panel/_sizes.scss +9 -9
  105. package/packages/developer-tools/src/DeveloperConsole/styles.ts +2 -2
  106. package/packages/developer-tools/src/DeveloperConsole/types.ts +49 -49
  107. package/packages/developer-tools/src/DeveloperConsole/utils/formatTime.ts +13 -13
  108. package/packages/developer-tools/src/DeveloperConsole/utils/index.ts +3 -3
  109. package/packages/developer-tools/src/DeveloperConsole/utils/stringify.ts +10 -10
  110. package/packages/developer-tools/src/DeveloperConsole/utils/styles.ts +24 -24
  111. package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolItem.tsx +21 -21
  112. package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsList.tsx +125 -125
  113. package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsService.tsx +122 -122
  114. package/packages/developer-tools/src/DeveloperToolsService/index.ts +1 -1
  115. package/packages/developer-tools/src/DeveloperToolsService/styles/DeveloperToolsService.scss +64 -64
  116. package/packages/developer-tools/src/DeveloperToolsService/styles/DeveloperToolsService.styles.1080.scss +2 -2
  117. package/packages/developer-tools/src/DeveloperToolsService/styles/DeveloperToolsService.styles.animated.1080.scss +3 -3
  118. package/packages/developer-tools/src/DeveloperToolsService/styles/DeveloperToolsService.styles.animated.scss +4 -4
  119. package/packages/developer-tools/src/DeveloperToolsService/styles/DeveloperToolsService.styles.scss +2 -2
  120. package/packages/developer-tools/src/DeveloperToolsService/styles/_animated.scss +5 -5
  121. package/packages/developer-tools/src/DeveloperToolsService/styles/_sizes.1080.scss +16 -16
  122. package/packages/developer-tools/src/DeveloperToolsService/styles/_sizes.scss +16 -16
  123. package/packages/developer-tools/src/DeveloperToolsService/styles.ts +1 -1
  124. package/packages/developer-tools/src/EnvironmentSelection/EnvironmentList.tsx +90 -90
  125. package/packages/developer-tools/src/EnvironmentSelection/EnvironmentListItem.tsx +106 -106
  126. package/packages/developer-tools/src/EnvironmentSelection/EnvironmentSelection.tsx +102 -102
  127. package/packages/developer-tools/src/EnvironmentSelection/assets/checkmark.svg +18 -18
  128. package/packages/developer-tools/src/EnvironmentSelection/config.ts +43 -43
  129. package/packages/developer-tools/src/EnvironmentSelection/constants.ts +1 -1
  130. package/packages/developer-tools/src/EnvironmentSelection/index.ts +2 -2
  131. package/packages/developer-tools/src/EnvironmentSelection/sizes.1080.ts +5 -5
  132. package/packages/developer-tools/src/EnvironmentSelection/sizes.ts +5 -5
  133. package/packages/developer-tools/src/EnvironmentSelection/styles/EnvironmentSelection.scss +141 -141
  134. package/packages/developer-tools/src/EnvironmentSelection/styles/EnvironmentSelection.styles.1080.scss +2 -2
  135. package/packages/developer-tools/src/EnvironmentSelection/styles/EnvironmentSelection.styles.animated.1080.scss +3 -3
  136. package/packages/developer-tools/src/EnvironmentSelection/styles/EnvironmentSelection.styles.animated.scss +3 -3
  137. package/packages/developer-tools/src/EnvironmentSelection/styles/EnvironmentSelection.styles.scss +2 -2
  138. package/packages/developer-tools/src/EnvironmentSelection/styles/_animated.scss +9 -9
  139. package/packages/developer-tools/src/EnvironmentSelection/styles/_sizes.1080.scss +26 -26
  140. package/packages/developer-tools/src/EnvironmentSelection/styles/_sizes.scss +26 -26
  141. package/packages/developer-tools/src/EnvironmentSelection/styles.ts +1 -1
  142. package/packages/developer-tools/src/EnvironmentSelection/types.ts +10 -10
  143. package/packages/developer-tools/src/EnvironmentSelection/utils/format.ts +4 -4
  144. package/packages/developer-tools/src/IDeveloperTool.ts +14 -14
  145. package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +115 -115
  146. package/packages/developer-tools/src/PlayerDebugWindow/constants.ts +128 -128
  147. package/packages/developer-tools/src/PlayerDebugWindow/index.ts +1 -1
  148. package/packages/developer-tools/src/PlayerDebugWindow/styles/PlayerDebugWindow.scss +29 -29
  149. package/packages/developer-tools/src/PlayerDebugWindow/styles/PlayerDebugWindow.styles.1080.scss +2 -2
  150. package/packages/developer-tools/src/PlayerDebugWindow/styles/PlayerDebugWindow.styles.scss +2 -2
  151. package/packages/developer-tools/src/PlayerDebugWindow/styles/_sizes.1080.scss +11 -11
  152. package/packages/developer-tools/src/PlayerDebugWindow/styles/_sizes.scss +11 -11
  153. package/packages/developer-tools/src/PlayerDebugWindow/styles.ts +1 -1
  154. package/packages/developer-tools/src/TechnicalInfo/ITechnicalInfoProvider.ts +5 -5
  155. package/packages/developer-tools/src/TechnicalInfo/TechnicalInfo.tsx +125 -125
  156. package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +77 -77
  157. package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +349 -349
  158. package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +55 -55
  159. package/packages/developer-tools/src/TechnicalInfo/__mocks__/Player.ts +7 -7
  160. package/packages/developer-tools/src/TechnicalInfo/__mocks__/Storage.ts +9 -9
  161. package/packages/developer-tools/src/TechnicalInfo/icons/arrow-down.svg +18 -18
  162. package/packages/developer-tools/src/TechnicalInfo/icons/arrow-up.svg +18 -18
  163. package/packages/developer-tools/src/TechnicalInfo/index.ts +5 -5
  164. package/packages/developer-tools/src/TechnicalInfo/sizes.1080.ts +1 -1
  165. package/packages/developer-tools/src/TechnicalInfo/sizes.ts +1 -1
  166. package/packages/developer-tools/src/TechnicalInfo/styles/TechnicalInfo.scss +187 -187
  167. package/packages/developer-tools/src/TechnicalInfo/styles/TechnicalInfo.styles.1080.scss +2 -2
  168. package/packages/developer-tools/src/TechnicalInfo/styles/TechnicalInfo.styles.animated.1080.scss +3 -3
  169. package/packages/developer-tools/src/TechnicalInfo/styles/TechnicalInfo.styles.animated.scss +3 -3
  170. package/packages/developer-tools/src/TechnicalInfo/styles/TechnicalInfo.styles.scss +2 -2
  171. package/packages/developer-tools/src/TechnicalInfo/styles/_animated.scss +16 -16
  172. package/packages/developer-tools/src/TechnicalInfo/styles/_sizes.1080.scss +50 -50
  173. package/packages/developer-tools/src/TechnicalInfo/styles/_sizes.scss +50 -50
  174. package/packages/developer-tools/src/TechnicalInfo/styles.ts +1 -1
  175. package/packages/developer-tools/src/TechnicalInfo/translations.ts +79 -79
  176. package/packages/developer-tools/src/TechnicalInfo/utils/eme01bSupport.ts +58 -58
  177. package/packages/developer-tools/src/TechnicalInfo/utils/emeSupport.ts +84 -84
  178. package/packages/developer-tools/src/TechnicalInfo/utils/formatTimezone.ts +15 -15
  179. package/packages/developer-tools/src/TechnicalInfo/utils/mseSupport.ts +14 -14
  180. package/packages/developer-tools/src/utils/reload.ts +6 -6
  181. package/packages/device/README.md +219 -219
  182. package/packages/device/keymap.ts +1 -1
  183. package/packages/device/resolver/index.ts +2 -2
  184. package/packages/device/resolver/keymap.ts +1 -1
  185. package/packages/device/src/DeviceEventMap.ts +1 -1
  186. package/packages/device/src/device.ts +6 -6
  187. package/packages/device/src/driver/index.android.tv.ts +1 -1
  188. package/packages/device/src/driver/index.entone.ts +1 -1
  189. package/packages/device/src/driver/index.firetv.ts +1 -1
  190. package/packages/device/src/driver/index.hbbtv.tv.ts +1 -1
  191. package/packages/device/src/driver/index.kreatv.ts +1 -1
  192. package/packages/device/src/driver/index.saphi.tv.ts +1 -1
  193. package/packages/device/src/driver/index.smartcast.tv.ts +1 -1
  194. package/packages/device/src/driver/index.tizen.tv.ts +1 -1
  195. package/packages/device/src/driver/index.ts +1 -1
  196. package/packages/device/src/driver/index.vidaa.tv.ts +1 -1
  197. package/packages/device/src/driver/index.webos.tv.ts +1 -1
  198. package/packages/device/src/getKeyDigit.ts +35 -35
  199. package/packages/device/src/getKeyMap.ts +4 -4
  200. package/packages/device/src/index.ts +8 -8
  201. package/packages/device/src/isClickOrEnter.ts +3 -3
  202. package/packages/device/src/resolver/index.ts +2 -2
  203. package/packages/device/src/resolver/resolver.ts +84 -84
  204. package/packages/digital-clock/README.md +26 -26
  205. package/packages/digital-clock/src/DigitalClock.tsx +78 -78
  206. package/packages/digital-clock/src/index.ts +1 -1
  207. package/packages/driver-androidtv/src/DeviceAndroidTV.ts +224 -224
  208. package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +36 -36
  209. package/packages/driver-androidtv/src/formatUserAgent.ts +11 -11
  210. package/packages/driver-androidtv/src/index.ts +1 -1
  211. package/packages/driver-androidtv/src/keymap.ts +27 -27
  212. package/packages/driver-androidtv/src/types.ts +113 -113
  213. package/packages/driver-base/DeviceBase.md +139 -139
  214. package/packages/driver-base/README.md +44 -44
  215. package/packages/driver-base/src/ConnectionType.ts +1 -1
  216. package/packages/driver-base/src/DeviceBase.ts +224 -224
  217. package/packages/driver-base/src/KeyMap/Key.ts +48 -48
  218. package/packages/driver-base/src/KeyMap/KeyMap.ts +390 -390
  219. package/packages/driver-base/src/KeyMap/generateKeyCodeKeyMap.ts +11 -11
  220. package/packages/driver-base/src/KeyMap/index.ts +5 -5
  221. package/packages/driver-base/src/KeyMap/interface.ts +8 -8
  222. package/packages/driver-base/src/KeyMap/overrideValues.ts +17 -17
  223. package/packages/driver-base/src/KeyMap/switchByKey.ts +18 -18
  224. package/packages/driver-base/src/ScreenSize.ts +1 -1
  225. package/packages/driver-base/src/VolumeRange.ts +5 -5
  226. package/packages/driver-base/src/__mocks__/DeviceBase.ts +100 -100
  227. package/packages/driver-base/src/__mocks__/keyMap.ts +42 -42
  228. package/packages/driver-base/src/bindPreventDefaultEvent.ts +5 -5
  229. package/packages/driver-base/src/errors.ts +32 -32
  230. package/packages/driver-base/src/index.ts +10 -10
  231. package/packages/driver-base/src/loadObject.ts +30 -30
  232. package/packages/driver-base/src/types/DeviceEvent.ts +11 -11
  233. package/packages/driver-base/src/types/ExitOptions.ts +1 -1
  234. package/packages/driver-base/src/types/KeycodeKeyMap.ts +86 -86
  235. package/packages/driver-base/src/types/ScreenSaverStatus.ts +3 -3
  236. package/packages/driver-base/src/utils.ts +10 -10
  237. package/packages/driver-browser/src/DeviceBrowser.ts +170 -170
  238. package/packages/driver-browser/src/getBrowser.ts +51 -51
  239. package/packages/driver-browser/src/getOsName.ts +30 -30
  240. package/packages/driver-browser/src/index.ts +1 -1
  241. package/packages/driver-browser/src/keymap.ts +22 -22
  242. package/packages/driver-browser/src/patchSuitestKeys.ts +27 -27
  243. package/packages/driver-entone/README.md +9 -9
  244. package/packages/driver-entone/src/DeviceEntone.ts +232 -232
  245. package/packages/driver-entone/src/IEntone.ts +460 -460
  246. package/packages/driver-entone/src/__mocks__/entone.ts +177 -177
  247. package/packages/driver-entone/src/constants.ts +73 -73
  248. package/packages/driver-entone/src/index.ts +1 -1
  249. package/packages/driver-entone/src/keymap.ts +57 -57
  250. package/packages/driver-firetv/src/DeviceFireTV.ts +18 -18
  251. package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +36 -36
  252. package/packages/driver-firetv/src/index.ts +1 -1
  253. package/packages/driver-hbbtv/src/DeviceHbbTV.ts +313 -313
  254. package/packages/driver-hbbtv/src/__mocks__/hbbtv.ts +17 -17
  255. package/packages/driver-hbbtv/src/constants.ts +28 -28
  256. package/packages/driver-hbbtv/src/deviceInfo.ts +23 -23
  257. package/packages/driver-hbbtv/src/getVersion.ts +16 -16
  258. package/packages/driver-hbbtv/src/index.ts +1 -1
  259. package/packages/driver-hbbtv/src/keymap.ts +45 -45
  260. package/packages/driver-hbbtv/src/types.ts +366 -366
  261. package/packages/driver-kreatv/src/DeviceKreaTV.ts +271 -271
  262. package/packages/driver-kreatv/src/IToi.ts +379 -379
  263. package/packages/driver-kreatv/src/__mocks__/toi2.ts +76 -76
  264. package/packages/driver-kreatv/src/__mocks__/toi3.ts +43 -43
  265. package/packages/driver-kreatv/src/index.ts +1 -1
  266. package/packages/driver-kreatv/src/keymap.ts +31 -31
  267. package/packages/driver-kreatv/src/toi2.ts +107 -107
  268. package/packages/driver-kreatv/src/toi3.ts +102 -102
  269. package/packages/driver-kreatv/src/types.ts +35 -35
  270. package/packages/driver-saphi/src/DeviceSaphi.ts +144 -144
  271. package/packages/driver-saphi/src/__mocks__/SmartTvA_API.ts +11 -11
  272. package/packages/driver-saphi/src/__mocks__/userAgent.ts +4 -4
  273. package/packages/driver-saphi/src/constants.ts +1 -1
  274. package/packages/driver-saphi/src/formatUserAgent.ts +19 -19
  275. package/packages/driver-saphi/src/index.ts +1 -1
  276. package/packages/driver-saphi/src/keymap.ts +64 -64
  277. package/packages/driver-saphi/src/types.ts +75 -75
  278. package/packages/driver-smartcast/src/DeviceSmartCast.ts +310 -310
  279. package/packages/driver-smartcast/src/__mocks__/api.ts +49 -49
  280. package/packages/driver-smartcast/src/index.ts +1 -1
  281. package/packages/driver-smartcast/src/keymap.ts +9 -9
  282. package/packages/driver-smartcast/src/types.ts +65 -65
  283. package/packages/driver-tizen/src/DeviceTizen.ts +298 -298
  284. package/packages/driver-tizen/src/ITizen.ts +212 -212
  285. package/packages/driver-tizen/src/IWebapis.ts +95 -95
  286. package/packages/driver-tizen/src/TizenKeys.ts +96 -96
  287. package/packages/driver-tizen/src/__mocks__/tizen.ts +35 -35
  288. package/packages/driver-tizen/src/constants.ts +197 -197
  289. package/packages/driver-tizen/src/index.ts +1 -1
  290. package/packages/driver-tizen/src/types.ts +14 -14
  291. package/packages/driver-vidaa/src/DeviceVidaa.ts +141 -141
  292. package/packages/driver-vidaa/src/__mocks__/vidaa.ts +21 -21
  293. package/packages/driver-vidaa/src/constants.ts +8 -8
  294. package/packages/driver-vidaa/src/formatUserAgent.ts +16 -16
  295. package/packages/driver-vidaa/src/index.ts +1 -1
  296. package/packages/driver-vidaa/src/keymap.ts +56 -56
  297. package/packages/driver-vidaa/src/types.ts +90 -90
  298. package/packages/driver-webos/src/DeviceWebos.ts +313 -313
  299. package/packages/driver-webos/src/__mocks__/webos.ts +172 -172
  300. package/packages/driver-webos/src/constants.ts +20 -20
  301. package/packages/driver-webos/src/index.ts +1 -1
  302. package/packages/driver-webos/src/keymap.ts +10 -10
  303. package/packages/driver-webos/src/types.ts +344 -344
  304. package/packages/driver-webos/src/utils.ts +60 -60
  305. package/packages/driver-webos/src/webOSTVjs/webOSTVjs.js +12 -12
  306. package/packages/driver-xbox/__external__/winjs/directionalnavigation-1.0.0.0.js +1015 -1015
  307. package/packages/driver-xbox/src/DeviceXbox.ts +231 -231
  308. package/packages/driver-xbox/src/__mocks__/Windows.ts +94 -94
  309. package/packages/driver-xbox/src/index.ts +1 -1
  310. package/packages/driver-xbox/src/interfaces.ts +138 -138
  311. package/packages/driver-xbox/src/keymap.ts +96 -96
  312. package/packages/driver-xbox/src/utils.ts +23 -23
  313. package/packages/epg/IMPLEMENTATION.md +228 -228
  314. package/packages/epg/MockGenerator.md +102 -102
  315. package/packages/epg/README.md +585 -585
  316. package/packages/epg/src/v2/Cell.tsx +222 -222
  317. package/packages/epg/src/v2/CellsManager.ts +1 -1
  318. package/packages/epg/src/v2/DataManager.ts +372 -372
  319. package/packages/epg/src/v2/DatePicker.tsx +110 -110
  320. package/packages/epg/src/v2/DateToast/DateToast.scss +28 -28
  321. package/packages/epg/src/v2/DateToast/DateToast.styles.1080.scss +2 -2
  322. package/packages/epg/src/v2/DateToast/DateToast.styles.scss +2 -2
  323. package/packages/epg/src/v2/DateToast/DateToast.tsx +90 -90
  324. package/packages/epg/src/v2/DateToast/_sizes.1080.scss +7 -7
  325. package/packages/epg/src/v2/DateToast/_sizes.scss +7 -7
  326. package/packages/epg/src/v2/DateToast/index.tsx +1 -1
  327. package/packages/epg/src/v2/DateToast/styles.ts +1 -1
  328. package/packages/epg/src/v2/Day.tsx +33 -33
  329. package/packages/epg/src/v2/Epg.tsx +462 -462
  330. package/packages/epg/src/v2/Header.tsx +41 -41
  331. package/packages/epg/src/v2/IdleController.ts +25 -25
  332. package/packages/epg/src/v2/InputEvents.ts +301 -301
  333. package/packages/epg/src/v2/MockGenerator/config.1080.ts +2 -2
  334. package/packages/epg/src/v2/MockGenerator/config.ts +2 -2
  335. package/packages/epg/src/v2/MockGenerator/generator.ts +174 -174
  336. package/packages/epg/src/v2/MockGenerator/index.ts +2 -2
  337. package/packages/epg/src/v2/MockGenerator/mocks/data.ts +102 -102
  338. package/packages/epg/src/v2/MockGenerator/types.ts +25 -25
  339. package/packages/epg/src/v2/MockGenerator/utils.ts +28 -28
  340. package/packages/epg/src/v2/MouseNavigation/MouseNavigation.tsx +88 -88
  341. package/packages/epg/src/v2/MouseNavigation/MouseNavigationFallback.ts +4 -4
  342. package/packages/epg/src/v2/MouseNavigation/index.tizen.tv.ts +1 -1
  343. package/packages/epg/src/v2/MouseNavigation/index.ts +1 -1
  344. package/packages/epg/src/v2/MouseNavigation/index.web.ts +1 -1
  345. package/packages/epg/src/v2/MouseNavigation/index.webos.tv.ts +1 -1
  346. package/packages/epg/src/v2/NowLine.tsx +66 -66
  347. package/packages/epg/src/v2/Program.tsx +58 -58
  348. package/packages/epg/src/v2/ProgramInfo/ProgramInfo.scss +67 -67
  349. package/packages/epg/src/v2/ProgramInfo/ProgramInfo.styles.1080.scss +3 -3
  350. package/packages/epg/src/v2/ProgramInfo/ProgramInfo.styles.animated.1080.scss +2 -2
  351. package/packages/epg/src/v2/ProgramInfo/ProgramInfo.styles.animated.scss +2 -2
  352. package/packages/epg/src/v2/ProgramInfo/ProgramInfo.styles.scss +3 -3
  353. package/packages/epg/src/v2/ProgramInfo/ProgramInfo.tsx +149 -149
  354. package/packages/epg/src/v2/ProgramInfo/_animated.scss +8 -8
  355. package/packages/epg/src/v2/ProgramInfo/_mixins.scss +5 -5
  356. package/packages/epg/src/v2/ProgramInfo/_sizes.1080.scss +21 -21
  357. package/packages/epg/src/v2/ProgramInfo/_sizes.scss +21 -21
  358. package/packages/epg/src/v2/ProgramInfo/index.ts +1 -1
  359. package/packages/epg/src/v2/ProgramInfo/rtl.scss +7 -7
  360. package/packages/epg/src/v2/ProgramInfo/sizes.1080.ts +3 -3
  361. package/packages/epg/src/v2/ProgramInfo/sizes.ts +3 -3
  362. package/packages/epg/src/v2/ProgramInfo/styles.ts +1 -1
  363. package/packages/epg/src/v2/ProgramInfo/utils.ts +28 -28
  364. package/packages/epg/src/v2/Row.tsx +134 -134
  365. package/packages/epg/src/v2/RowsManager.ts +1 -1
  366. package/packages/epg/src/v2/TimeManager.ts +58 -58
  367. package/packages/epg/src/v2/Timeline.ts +1 -1
  368. package/packages/epg/src/v2/TimelineSection.tsx +50 -50
  369. package/packages/epg/src/v2/basic/CellsManager.tsx +300 -300
  370. package/packages/epg/src/v2/basic/RowsManager.tsx +503 -503
  371. package/packages/epg/src/v2/basic/Timeline.tsx +88 -88
  372. package/packages/epg/src/v2/index.ts +1 -1
  373. package/packages/epg/src/v2/interface.ts +1519 -1519
  374. package/packages/epg/src/v2/sizes.1080.ts +2 -2
  375. package/packages/epg/src/v2/sizes.ts +2 -2
  376. package/packages/epg/src/v2/styles/Basic/Basic.scss +116 -116
  377. package/packages/epg/src/v2/styles/Basic/index.ts +1 -1
  378. package/packages/epg/src/v2/styles/Whitelabel/index.ts +1 -1
  379. package/packages/epg/src/v2/utils.ts +40 -40
  380. package/packages/events-manager/src/EventsManager.ts +1 -1
  381. package/packages/events-manager/src/index.ts +2 -2
  382. package/packages/floating-focus/README.md +64 -64
  383. package/packages/floating-focus/src/FloatingFocus.ts +106 -106
  384. package/packages/floating-focus/src/Horizontal.tsx +20 -20
  385. package/packages/floating-focus/src/Vertical.tsx +20 -20
  386. package/packages/floating-focus/src/index.ts +4 -4
  387. package/packages/floating-focus/src/types.ts +20 -20
  388. package/packages/floating-focus/src/utils.ts +43 -43
  389. package/packages/focus/README.md +348 -348
  390. package/packages/focus/src/IFocusable.ts +5 -5
  391. package/packages/focus/src/Layout/Base.tsx +166 -166
  392. package/packages/focus/src/Layout/Horizontal.ts +15 -15
  393. package/packages/focus/src/Layout/Matrix.tsx +357 -357
  394. package/packages/focus/src/Layout/Vertical.ts +12 -12
  395. package/packages/focus/src/Layout/constants.ts +10 -10
  396. package/packages/focus/src/Layout/isRtl.ts +12 -12
  397. package/packages/focus/src/Layout/types.ts +7 -7
  398. package/packages/focus/src/candidate.ts +106 -106
  399. package/packages/focus/src/focusFirstExisting.ts +19 -19
  400. package/packages/focus/src/hasFocus.ts +36 -36
  401. package/packages/focus/src/index.ts +16 -16
  402. package/packages/focus/src/refocusAfterHashChange.ts +19 -19
  403. package/packages/focus/src/safeFocus.ts +15 -15
  404. package/packages/gallup/README.md +27 -27
  405. package/packages/gallup/src/Gallup.ts +80 -80
  406. package/packages/gallup/src/GallupMock.ts +7 -7
  407. package/packages/gallup/src/__external__/SpringStreams.d.ts +39 -39
  408. package/packages/gallup/src/__mocks__/SpringStreams.js +18 -18
  409. package/packages/gallup/src/index.ts +1 -1
  410. package/packages/grid/BasicGrid/README.md +78 -78
  411. package/packages/grid/BasicGrid/index.ts +1 -1
  412. package/packages/grid/FirstOnlyGrid/README.md +43 -43
  413. package/packages/grid/FirstOnlyGrid/index.ts +1 -1
  414. package/packages/grid/FixedToEndGrid/README.md +45 -45
  415. package/packages/grid/FixedToEndGrid/index.ts +1 -1
  416. package/packages/grid/Item/index.ts +1 -1
  417. package/packages/grid/README.md +169 -169
  418. package/packages/grid/src/Base/Base.tsx +492 -492
  419. package/packages/grid/src/Base/MouseNavigation/MouseNavigation.tsx +82 -82
  420. package/packages/grid/src/Base/MouseNavigation/MouseNavigationFallback.ts +4 -4
  421. package/packages/grid/src/Base/MouseNavigation/index.tizen.tv.ts +1 -1
  422. package/packages/grid/src/Base/MouseNavigation/index.ts +1 -1
  423. package/packages/grid/src/Base/MouseNavigation/index.webos.tv.ts +1 -1
  424. package/packages/grid/src/Base/MouseNavigation/index.webtv.ts +1 -1
  425. package/packages/grid/src/Base/index.ts +1 -1
  426. package/packages/grid/src/Base/interface.ts +47 -47
  427. package/packages/grid/src/BasicGrid/BasicGrid.tsx +137 -137
  428. package/packages/grid/src/BasicGrid/config.ts +13 -13
  429. package/packages/grid/src/FastFocusingOptimizer/FastFocusingOptimizer.ts +54 -54
  430. package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +112 -112
  431. package/packages/grid/src/FirstOnlyGrid/config.ts +13 -13
  432. package/packages/grid/src/FirstOnlyGrid/controller.ts +10 -10
  433. package/packages/grid/src/FixedToEndGrid/FixedToEndGrid.tsx +112 -112
  434. package/packages/grid/src/FixedToEndGrid/config.ts +13 -13
  435. package/packages/grid/src/FixedToEndGrid/controller.ts +36 -36
  436. package/packages/grid/src/UnifiedGridController/UnifiedGridController.ts +555 -555
  437. package/packages/grid/src/UnifiedGridController/index.ts +2 -2
  438. package/packages/grid/src/UnifiedGridController/interface.ts +92 -92
  439. package/packages/grid/src/animate.animated.ts +1 -1
  440. package/packages/grid/src/animate.ts +1 -1
  441. package/packages/grid/src/interface.ts +30 -30
  442. package/packages/grid/src/mocks/index.tsx +41 -41
  443. package/packages/grid/src/types.ts +69 -69
  444. package/packages/grid/src/utils.ts +69 -69
  445. package/packages/i18n/README.md +460 -460
  446. package/packages/i18n/src/I18n.ts +246 -246
  447. package/packages/i18n/src/Translation.tsx +36 -36
  448. package/packages/i18n/src/addResourceBundle.ts +73 -73
  449. package/packages/i18n/src/direction.ts +33 -33
  450. package/packages/i18n/src/index.ts +4 -4
  451. package/packages/i18n/src/isRtl.ts +3 -3
  452. package/packages/i18n/src/middlewares/i18next/Context/Context.ts +25 -25
  453. package/packages/i18n/src/middlewares/i18next/Context/index.ts +1 -1
  454. package/packages/i18n/src/middlewares/i18next/Interpolation/Interpolation.ts +95 -95
  455. package/packages/i18n/src/middlewares/i18next/Interpolation/index.ts +1 -1
  456. package/packages/i18n/src/middlewares/i18next/Nesting/Nesting.ts +38 -38
  457. package/packages/i18n/src/middlewares/i18next/Nesting/index.ts +1 -1
  458. package/packages/i18n/src/middlewares/i18next/Plurals/Plurals.ts +123 -123
  459. package/packages/i18n/src/middlewares/i18next/Plurals/Resolvers.ts +124 -124
  460. package/packages/i18n/src/middlewares/i18next/Plurals/index.ts +1 -1
  461. package/packages/i18n/src/middlewares/i18next/Plurals/types.ts +6 -6
  462. package/packages/i18n/src/middlewares/icu/DateInterpolation/DateInterpolation.ts +64 -64
  463. package/packages/i18n/src/middlewares/icu/DateInterpolation/index.ts +1 -1
  464. package/packages/i18n/src/middlewares/icu/Interpolation/Interpolation.ts +39 -39
  465. package/packages/i18n/src/middlewares/icu/Interpolation/index.ts +1 -1
  466. package/packages/i18n/src/middlewares/icu/NumberInterpolation/NumberInterpolation.ts +41 -41
  467. package/packages/i18n/src/middlewares/icu/NumberInterpolation/index.ts +1 -1
  468. package/packages/i18n/src/middlewares/icu/Plurals/Plurals.ts +65 -65
  469. package/packages/i18n/src/middlewares/icu/Plurals/Resolvers.ts +130 -130
  470. package/packages/i18n/src/middlewares/icu/Plurals/index.ts +1 -1
  471. package/packages/i18n/src/middlewares/icu/Plurals/types.ts +15 -15
  472. package/packages/i18n/src/middlewares/icu/Select/Select.ts +36 -36
  473. package/packages/i18n/src/middlewares/icu/Select/index.ts +1 -1
  474. package/packages/i18n/src/middlewares/icu/TimeInterpolation/TimeInterpolation.ts +65 -65
  475. package/packages/i18n/src/middlewares/icu/TimeInterpolation/index.ts +1 -1
  476. package/packages/i18n/src/middlewares/icu/shared/hasVariable.ts +5 -5
  477. package/packages/i18n/src/middlewares/icu/shared/matchSwitchCase.ts +80 -80
  478. package/packages/i18n/src/middlewares/icu/shared/unwrap.ts +1 -1
  479. package/packages/i18n/src/pluralsCommon/PluralsHelper.ts +54 -54
  480. package/packages/i18n/src/pluralsCommon/ResolverByLanguage.ts +129 -129
  481. package/packages/i18n/src/t.tsx +6 -6
  482. package/packages/i18n/src/typedTranslate.ts +31 -31
  483. package/packages/i18n/src/types.ts +66 -66
  484. package/packages/i18n/src/utils.ts +76 -76
  485. package/packages/icon/README.md +107 -107
  486. package/packages/icon/src/Icon.tsx +71 -71
  487. package/packages/icon/src/index.ts +1 -1
  488. package/packages/ime/README.md +72 -72
  489. package/packages/ime/src/IKeyboard.ts +6 -6
  490. package/packages/ime/src/IKeyboardEvent.ts +7 -7
  491. package/packages/ime/src/ImeManager.ts +33 -33
  492. package/packages/ime/src/SystemKeyboard/SystemKeyboard.ts +33 -33
  493. package/packages/ime/src/SystemKeyboard/SystemKeyboardBase.ts +98 -98
  494. package/packages/ime/src/SystemKeyboard/TizenSystemKeyboard.ts +66 -66
  495. package/packages/ime/src/SystemKeyboard/WebosSystemKeyboard.ts +74 -74
  496. package/packages/ime/src/SystemKeyboard/index.tizen.tv.ts +1 -1
  497. package/packages/ime/src/SystemKeyboard/index.ts +1 -1
  498. package/packages/ime/src/SystemKeyboard/index.webos.tv.ts +1 -1
  499. package/packages/ime/src/index.ts +3 -3
  500. package/packages/input/README.md +65 -65
  501. package/packages/input/__mocks__/MockKeyboard.ts +40 -40
  502. package/packages/input/src/Input.scss +9 -9
  503. package/packages/input/src/Input.tsx +267 -267
  504. package/packages/input/src/index.ts +1 -1
  505. package/packages/input/src/utils.ts +71 -71
  506. package/packages/interactable/README.md +38 -38
  507. package/packages/interactable/src/Interactable.tsx +33 -33
  508. package/packages/interactable/src/index.ts +1 -1
  509. package/packages/interactable/src/interface.ts +7 -7
  510. package/packages/ipify/README.md +30 -30
  511. package/packages/ipify/src/index.ts +1 -1
  512. package/packages/ipify/src/ipify.ts +41 -41
  513. package/packages/jsx/README.md +388 -388
  514. package/packages/jsx/src/Component.ts +68 -68
  515. package/packages/jsx/src/createRef.ts +5 -5
  516. package/packages/jsx/src/forwardRef.ts +8 -8
  517. package/packages/jsx/src/index.ts +31 -31
  518. package/packages/jsx/src/jsx-runtime.ts +5 -5
  519. package/packages/jsx/src/manipulation/attachNode.ts +30 -30
  520. package/packages/jsx/src/manipulation/attachNodeBefore.ts +44 -44
  521. package/packages/jsx/src/manipulation/clearNode.ts +14 -14
  522. package/packages/jsx/src/manipulation/detachNode.ts +26 -26
  523. package/packages/jsx/src/manipulation/index.ts +7 -7
  524. package/packages/jsx/src/manipulation/removeNode.ts +18 -18
  525. package/packages/jsx/src/manipulation/replaceNode.ts +42 -42
  526. package/packages/jsx/src/manipulation/swapNodes.ts +53 -53
  527. package/packages/jsx/src/mount/guards.ts +26 -26
  528. package/packages/jsx/src/mount/handleLifecycle.ts +71 -71
  529. package/packages/jsx/src/mount/index.ts +1 -1
  530. package/packages/jsx/src/mount/lifecycle.ts +38 -38
  531. package/packages/jsx/src/mount/lifecycleHelpers.ts +29 -29
  532. package/packages/jsx/src/mount/mount.ts +141 -141
  533. package/packages/jsx/src/mount/namespaces.ts +7 -7
  534. package/packages/jsx/src/mount/props.ts +121 -121
  535. package/packages/jsx/src/nodeUtils.ts +69 -69
  536. package/packages/jsx/src/setText.ts +15 -15
  537. package/packages/jsx/src/test-utils/MountedComponent.ts +50 -50
  538. package/packages/jsx/src/test-utils/README.md +72 -72
  539. package/packages/jsx/src/test-utils/click.ts +7 -7
  540. package/packages/jsx/src/test-utils/enter.ts +4 -4
  541. package/packages/jsx/src/test-utils/index.ts +6 -6
  542. package/packages/jsx/src/test-utils/keydown.ts +27 -27
  543. package/packages/jsx/src/test-utils/keyup.ts +27 -27
  544. package/packages/jsx/src/test-utils/shallow.ts +33 -33
  545. package/packages/jsx/src/test-utils/spec-utils.ts +6 -6
  546. package/packages/jsx/src/textNode.ts +9 -9
  547. package/packages/jsx/src/types.ts +128 -128
  548. package/packages/jsx/src/utils.ts +35 -35
  549. package/packages/jsx/src/virtualDOM.ts +121 -121
  550. package/packages/key-sequence/README.md +44 -44
  551. package/packages/key-sequence/src/KeySequence.ts +56 -56
  552. package/packages/key-sequence/src/arrayEndsWithKeyCombo.ts +22 -22
  553. package/packages/key-sequence/src/index.ts +1 -1
  554. package/packages/key-sequence/src/types.ts +13 -13
  555. package/packages/keyboard/README.md +237 -237
  556. package/packages/keyboard/src/AndroidKeyboard/Keyboard.scss +140 -140
  557. package/packages/keyboard/src/AndroidKeyboard/Keyboard.styles.1080.scss +2 -2
  558. package/packages/keyboard/src/AndroidKeyboard/Keyboard.styles.animated.1080.scss +3 -3
  559. package/packages/keyboard/src/AndroidKeyboard/Keyboard.styles.animated.scss +3 -3
  560. package/packages/keyboard/src/AndroidKeyboard/Keyboard.styles.scss +2 -2
  561. package/packages/keyboard/src/AndroidKeyboard/Keyboard.tsx +235 -235
  562. package/packages/keyboard/src/AndroidKeyboard/_animated.scss +7 -7
  563. package/packages/keyboard/src/AndroidKeyboard/_sizes.1080.scss +15 -15
  564. package/packages/keyboard/src/AndroidKeyboard/_sizes.scss +15 -15
  565. package/packages/keyboard/src/AndroidKeyboard/icons/arrow_left.svg +6 -6
  566. package/packages/keyboard/src/AndroidKeyboard/icons/arrow_right.svg +6 -6
  567. package/packages/keyboard/src/AndroidKeyboard/icons/key_backspace.svg +12 -12
  568. package/packages/keyboard/src/AndroidKeyboard/index.ts +1 -1
  569. package/packages/keyboard/src/AndroidKeyboard/makeLayout.ts +19 -19
  570. package/packages/keyboard/src/Backdrop/Backdrop.scss +17 -17
  571. package/packages/keyboard/src/Backdrop/Backdrop.styles.1080.scss +2 -2
  572. package/packages/keyboard/src/Backdrop/Backdrop.styles.scss +2 -2
  573. package/packages/keyboard/src/Backdrop/Backdrop.tsx +31 -31
  574. package/packages/keyboard/src/Backdrop/_sizes.1080.scss +2 -2
  575. package/packages/keyboard/src/Backdrop/_sizes.scss +2 -2
  576. package/packages/keyboard/src/DefaultKeyboard/Keyboard.scss +73 -73
  577. package/packages/keyboard/src/DefaultKeyboard/Keyboard.styles.1080.scss +2 -2
  578. package/packages/keyboard/src/DefaultKeyboard/Keyboard.styles.scss +2 -2
  579. package/packages/keyboard/src/DefaultKeyboard/Keyboard.tsx +155 -155
  580. package/packages/keyboard/src/DefaultKeyboard/_sizes.1080.scss +12 -12
  581. package/packages/keyboard/src/DefaultKeyboard/_sizes.scss +12 -12
  582. package/packages/keyboard/src/DefaultKeyboard/index.ts +1 -1
  583. package/packages/keyboard/src/KeyboardBase.tsx +344 -344
  584. package/packages/keyboard/src/MobiKeyboard/Keyboard.scss +180 -180
  585. package/packages/keyboard/src/MobiKeyboard/Keyboard.styles.1080.scss +2 -2
  586. package/packages/keyboard/src/MobiKeyboard/Keyboard.styles.animated.1080.scss +3 -3
  587. package/packages/keyboard/src/MobiKeyboard/Keyboard.styles.animated.scss +3 -3
  588. package/packages/keyboard/src/MobiKeyboard/Keyboard.styles.scss +2 -2
  589. package/packages/keyboard/src/MobiKeyboard/Keyboard.tsx +278 -278
  590. package/packages/keyboard/src/MobiKeyboard/_animated.scss +7 -7
  591. package/packages/keyboard/src/MobiKeyboard/_sizes.1080.scss +10 -10
  592. package/packages/keyboard/src/MobiKeyboard/_sizes.scss +10 -10
  593. package/packages/keyboard/src/MobiKeyboard/icons/arrow_left.svg +6 -6
  594. package/packages/keyboard/src/MobiKeyboard/icons/arrow_right.svg +6 -6
  595. package/packages/keyboard/src/MobiKeyboard/icons/key_backspace.svg +12 -12
  596. package/packages/keyboard/src/MobiKeyboard/icons/key_space.svg +6 -6
  597. package/packages/keyboard/src/MobiKeyboard/index.ts +1 -1
  598. package/packages/keyboard/src/MobiKeyboard/utils.ts +19 -19
  599. package/packages/keyboard/src/QwertyKeyboardBase/QwertyKeyboardBase.tsx +54 -54
  600. package/packages/keyboard/src/ShiftMode.ts +25 -25
  601. package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +168 -168
  602. package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.styles.1080.scss +2 -2
  603. package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.styles.scss +2 -2
  604. package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +353 -353
  605. package/packages/keyboard/src/WhitelabelKeyboard/WhitelabelStyles/_sizes.1080.scss +7 -7
  606. package/packages/keyboard/src/WhitelabelKeyboard/WhitelabelStyles/_sizes.scss +7 -7
  607. package/packages/keyboard/src/WhitelabelKeyboard/WhitelabelStyles/index.ts +1 -1
  608. package/packages/keyboard/src/WhitelabelKeyboard/WhitelabelStyles/whitelabel.scss +81 -81
  609. package/packages/keyboard/src/WhitelabelKeyboard/WhitelabelStyles/whitelabel.styles.1080.scss +2 -2
  610. package/packages/keyboard/src/WhitelabelKeyboard/WhitelabelStyles/whitelabel.styles.scss +2 -2
  611. package/packages/keyboard/src/WhitelabelKeyboard/_sizes.1080.scss +32 -32
  612. package/packages/keyboard/src/WhitelabelKeyboard/_sizes.scss +32 -32
  613. package/packages/keyboard/src/WhitelabelKeyboard/icons/arrow_left.svg +9 -9
  614. package/packages/keyboard/src/WhitelabelKeyboard/icons/arrow_right.svg +9 -9
  615. package/packages/keyboard/src/WhitelabelKeyboard/icons/key_backspace.svg +9 -9
  616. package/packages/keyboard/src/WhitelabelKeyboard/icons/key_language.svg +20 -20
  617. package/packages/keyboard/src/WhitelabelKeyboard/icons/key_shift.svg +9 -9
  618. package/packages/keyboard/src/WhitelabelKeyboard/icons/key_shift_active.svg +9 -9
  619. package/packages/keyboard/src/WhitelabelKeyboard/index.ts +2 -2
  620. package/packages/keyboard/src/WhitelabelKeyboard/layouts/hebrew.ts +28 -28
  621. package/packages/keyboard/src/WhitelabelKeyboard/layouts/index.ts +8 -8
  622. package/packages/keyboard/src/WhitelabelKeyboard/layouts/korean.ts +26 -26
  623. package/packages/keyboard/src/WhitelabelKeyboard/layouts/latin.ts +26 -26
  624. package/packages/keyboard/src/WhitelabelKeyboard/layouts/russian.ts +27 -27
  625. package/packages/keyboard/src/WhitelabelKeyboard/layouts/special.ts +28 -28
  626. package/packages/keyboard/src/WhitelabelKeyboard/layouts/tibetan.ts +26 -26
  627. package/packages/keyboard/src/WhitelabelKeyboard/layouts/turkish.ts +26 -26
  628. package/packages/keyboard/src/WhitelabelKeyboard/layouts/urdu.ts +26 -26
  629. package/packages/keyboard/src/WhitelabelKeyboard/types.ts +28 -28
  630. package/packages/keyboard/src/WhitelabelNumericKeyboard/NumericKeyboard.scss +105 -105
  631. package/packages/keyboard/src/WhitelabelNumericKeyboard/NumericKeyboard.styles.1080.scss +2 -2
  632. package/packages/keyboard/src/WhitelabelNumericKeyboard/NumericKeyboard.styles.scss +2 -2
  633. package/packages/keyboard/src/WhitelabelNumericKeyboard/NumericKeyboard.tsx +161 -161
  634. package/packages/keyboard/src/WhitelabelNumericKeyboard/WhitelabelStyles/_sizes.1080.scss +7 -7
  635. package/packages/keyboard/src/WhitelabelNumericKeyboard/WhitelabelStyles/_sizes.scss +7 -7
  636. package/packages/keyboard/src/WhitelabelNumericKeyboard/WhitelabelStyles/index.ts +1 -1
  637. package/packages/keyboard/src/WhitelabelNumericKeyboard/WhitelabelStyles/whitelabel.scss +62 -62
  638. package/packages/keyboard/src/WhitelabelNumericKeyboard/WhitelabelStyles/whitelabel.styles.1080.scss +2 -2
  639. package/packages/keyboard/src/WhitelabelNumericKeyboard/WhitelabelStyles/whitelabel.styles.scss +2 -2
  640. package/packages/keyboard/src/WhitelabelNumericKeyboard/_sizes.1080.scss +29 -29
  641. package/packages/keyboard/src/WhitelabelNumericKeyboard/_sizes.scss +29 -29
  642. package/packages/keyboard/src/WhitelabelNumericKeyboard/icons/key_backspace.svg +9 -9
  643. package/packages/keyboard/src/WhitelabelNumericKeyboard/index.ts +2 -2
  644. package/packages/keyboard/src/WhitelabelNumericKeyboard/layout.ts +14 -14
  645. package/packages/keyboard/src/hwKeyboardEventToChar.ts +11 -11
  646. package/packages/keyboard/src/types/index.ts +11 -11
  647. package/packages/keyboard/src/utils/caret.ts +48 -48
  648. package/packages/keyboard/src/utils/generateFocusMatrixFromStringMatrix.ts +12 -12
  649. package/packages/keyboard/src/utils/input.ts +40 -40
  650. package/packages/l10n/README.md +120 -120
  651. package/packages/l10n/interface.ts +1 -1
  652. package/packages/l10n/locales/cs.ts +4 -4
  653. package/packages/l10n/locales/en-001.ts +4 -4
  654. package/packages/l10n/locales/en-us.ts +4 -4
  655. package/packages/l10n/src/Locale.tsx +44 -44
  656. package/packages/l10n/src/date/common.ts +165 -165
  657. package/packages/l10n/src/date/cs.ts +89 -89
  658. package/packages/l10n/src/date/de.ts +97 -97
  659. package/packages/l10n/src/date/en-001.ts +76 -76
  660. package/packages/l10n/src/date/en-common.ts +55 -55
  661. package/packages/l10n/src/date/en-us.ts +83 -83
  662. package/packages/l10n/src/date/es.ts +71 -71
  663. package/packages/l10n/src/date/fr.ts +94 -94
  664. package/packages/l10n/src/date/he.ts +101 -101
  665. package/packages/l10n/src/date/iso.ts +63 -63
  666. package/packages/l10n/src/date/types.ts +56 -56
  667. package/packages/l10n/src/index.ts +2 -2
  668. package/packages/l10n/src/l10n.ts +112 -112
  669. package/packages/l10n/src/types.ts +22 -22
  670. package/packages/list/AttachDetachItem/README.md +128 -128
  671. package/packages/list/AttachDetachItem/index.ts +3 -3
  672. package/packages/list/BasicList/README.md +71 -71
  673. package/packages/list/BasicList/index.ts +1 -1
  674. package/packages/list/CenteredList/README.md +42 -42
  675. package/packages/list/CenteredList/index.ts +1 -1
  676. package/packages/list/EdgeOffsetList/README.md +58 -58
  677. package/packages/list/EdgeOffsetList/index.ts +1 -1
  678. package/packages/list/FirstOnlyList/README.md +39 -39
  679. package/packages/list/FirstOnlyList/index.ts +1 -1
  680. package/packages/list/FirstOnlyVariedList/README.md +105 -105
  681. package/packages/list/FirstOnlyVariedList/index.ts +1 -1
  682. package/packages/list/FixedToEndList/README.md +42 -42
  683. package/packages/list/FixedToEndList/index.ts +1 -1
  684. package/packages/list/Item/index.ts +1 -1
  685. package/packages/list/README.md +193 -193
  686. package/packages/list/src/AttachDetachItem/AttachDetachItem.tsx +96 -96
  687. package/packages/list/src/AttachDetachItem/prepareAttachDetachItemData.ts +13 -13
  688. package/packages/list/src/Base/Base.tsx +392 -392
  689. package/packages/list/src/Base/MouseNavigation/MouseNavigation.tsx +82 -82
  690. package/packages/list/src/Base/MouseNavigation/MouseNavigationFallback.ts +4 -4
  691. package/packages/list/src/Base/MouseNavigation/index.tizen.tv.ts +1 -1
  692. package/packages/list/src/Base/MouseNavigation/index.ts +1 -1
  693. package/packages/list/src/Base/MouseNavigation/index.webos.tv.ts +1 -1
  694. package/packages/list/src/Base/MouseNavigation/index.webtv.ts +1 -1
  695. package/packages/list/src/Base/index.ts +1 -1
  696. package/packages/list/src/Base/interface.ts +39 -39
  697. package/packages/list/src/BasicList/BasicList.tsx +178 -178
  698. package/packages/list/src/BasicList/config.ts +13 -13
  699. package/packages/list/src/CenteredList/CenteredList.tsx +116 -116
  700. package/packages/list/src/CenteredList/config.ts +13 -13
  701. package/packages/list/src/CenteredList/controller.ts +46 -46
  702. package/packages/list/src/CenteredList/interface.ts +10 -10
  703. package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +173 -173
  704. package/packages/list/src/EdgeOffsetList/config.ts +13 -13
  705. package/packages/list/src/FastFocusingOptimizer/FastFocusingOptimizer.ts +54 -54
  706. package/packages/list/src/FirstOnlyList/FirstOnlyList.tsx +122 -122
  707. package/packages/list/src/FirstOnlyList/config.ts +13 -13
  708. package/packages/list/src/FirstOnlyList/controller.ts +11 -11
  709. package/packages/list/src/FirstOnlyVariedList/FirstOnlyVariedList.tsx +132 -132
  710. package/packages/list/src/FirstOnlyVariedList/config.ts +13 -13
  711. package/packages/list/src/FixedToEndList/FixedToEndList.tsx +125 -125
  712. package/packages/list/src/FixedToEndList/config.ts +13 -13
  713. package/packages/list/src/FixedToEndList/controller.ts +44 -44
  714. package/packages/list/src/UnifiedListController/UnifiedListController.ts +258 -258
  715. package/packages/list/src/UnifiedListController/UnifiedListControllerBase.ts +241 -241
  716. package/packages/list/src/UnifiedListController/UnifiedVariedListController.ts +241 -241
  717. package/packages/list/src/UnifiedListController/interface.ts +81 -81
  718. package/packages/list/src/__test__/utils.spec.ts +59 -59
  719. package/packages/list/src/animate.animated.ts +1 -1
  720. package/packages/list/src/animate.ts +1 -1
  721. package/packages/list/src/index.ts +1 -1
  722. package/packages/list/src/interface.ts +48 -48
  723. package/packages/list/src/mocks/index.tsx +55 -55
  724. package/packages/list/src/types.ts +132 -132
  725. package/packages/list/src/utils.ts +142 -142
  726. package/packages/list/utils/index.ts +1 -1
  727. package/packages/logger/README.md +117 -117
  728. package/packages/logger/src/LoggerManager.ts +60 -60
  729. package/packages/logger/src/LoggerService.ts +43 -43
  730. package/packages/logger/src/__mocks__/LoggerBase.ts +13 -13
  731. package/packages/logger/src/index.ts +3 -3
  732. package/packages/logger/src/loggers/ConsoleLogger/ConsoleLogger.ts +51 -51
  733. package/packages/logger/src/loggers/ConsoleLogger/README.md +39 -39
  734. package/packages/logger/src/loggers/ConsoleLogger/index.ts +1 -1
  735. package/packages/logger/src/loggers/LoggerBase/LoggerBase.ts +67 -67
  736. package/packages/logger/src/loggers/LoggerBase/README.md +69 -69
  737. package/packages/logger/src/loggers/LoggerBase/index.ts +1 -1
  738. package/packages/logger/src/loggers/SentryLogger/README.md +98 -98
  739. package/packages/logger/src/loggers/SentryLogger/Sentry.ts +2 -2
  740. package/packages/logger/src/loggers/SentryLogger/SentryLogger.ts +179 -179
  741. package/packages/logger/src/loggers/SentryLogger/index.ts +2 -2
  742. package/packages/logger/src/loggers/SentryLogger/mock.ts +6 -6
  743. package/packages/logger/src/loggers/index.ts +2 -2
  744. package/packages/logger/src/types.ts +46 -46
  745. package/packages/logger/src/utils/deviceInfo.ts +25 -25
  746. package/packages/logger/src/utils/index.ts +1 -1
  747. package/packages/lottie-animations/README.md +217 -217
  748. package/packages/lottie-animations/src/LottieAnimation.tsx +125 -125
  749. package/packages/lottie-animations/src/index.ts +7 -7
  750. package/packages/menu/README.md +90 -90
  751. package/packages/menu/WhitelabelMenu/index.ts +1 -1
  752. package/packages/menu/WhitelabelMenu/interface.ts +2 -2
  753. package/packages/menu/WhitelabelMenu/styles.ts +2 -2
  754. package/packages/menu/interface.ts +3 -3
  755. package/packages/menu/src/MenuAndContentContainer/MenuAndContentContainer.tsx +211 -211
  756. package/packages/menu/src/MenuAndContentContainer/index.ts +1 -1
  757. package/packages/menu/src/MenuAndContentContainer/interface.ts +164 -164
  758. package/packages/menu/src/MenuAndContentContainer/service.ts +5 -5
  759. package/packages/menu/src/WhitelabelMenu/SideMenu.scss +41 -41
  760. package/packages/menu/src/WhitelabelMenu/SideMenu.styles.1080.scss +2 -2
  761. package/packages/menu/src/WhitelabelMenu/SideMenu.styles.animated.1080.scss +3 -3
  762. package/packages/menu/src/WhitelabelMenu/SideMenu.styles.animated.scss +3 -3
  763. package/packages/menu/src/WhitelabelMenu/SideMenu.styles.scss +2 -2
  764. package/packages/menu/src/WhitelabelMenu/SideMenu.tsx +248 -248
  765. package/packages/menu/src/WhitelabelMenu/SideMenuItem/SideMenuItem.scss +56 -56
  766. package/packages/menu/src/WhitelabelMenu/SideMenuItem/SideMenuItem.styles.1080.scss +2 -2
  767. package/packages/menu/src/WhitelabelMenu/SideMenuItem/SideMenuItem.styles.animated.1080.scss +3 -3
  768. package/packages/menu/src/WhitelabelMenu/SideMenuItem/SideMenuItem.styles.animated.scss +3 -3
  769. package/packages/menu/src/WhitelabelMenu/SideMenuItem/SideMenuItem.styles.scss +2 -2
  770. package/packages/menu/src/WhitelabelMenu/SideMenuItem/SideMenuItem.tsx +78 -78
  771. package/packages/menu/src/WhitelabelMenu/SideMenuItem/_animated.scss +12 -12
  772. package/packages/menu/src/WhitelabelMenu/SideMenuItem/_sizes.1080.scss +17 -17
  773. package/packages/menu/src/WhitelabelMenu/SideMenuItem/_sizes.scss +17 -17
  774. package/packages/menu/src/WhitelabelMenu/SideMenuItem/index.ts +1 -1
  775. package/packages/menu/src/WhitelabelMenu/SideMenuItem/interface.ts +49 -49
  776. package/packages/menu/src/WhitelabelMenu/SideMenuItem/rtl.scss +12 -12
  777. package/packages/menu/src/WhitelabelMenu/SideMenuItem/sizes.1080.ts +2 -2
  778. package/packages/menu/src/WhitelabelMenu/SideMenuItem/sizes.ts +2 -2
  779. package/packages/menu/src/WhitelabelMenu/SideMenuItem/styles.ts +1 -1
  780. package/packages/menu/src/WhitelabelMenu/VisualController.animated.ts +48 -48
  781. package/packages/menu/src/WhitelabelMenu/VisualController.ts +20 -20
  782. package/packages/menu/src/WhitelabelMenu/VisualControllerBase.ts +71 -71
  783. package/packages/menu/src/WhitelabelMenu/_animated.scss +39 -39
  784. package/packages/menu/src/WhitelabelMenu/_sizes.1080.scss +14 -14
  785. package/packages/menu/src/WhitelabelMenu/_sizes.scss +14 -14
  786. package/packages/menu/src/WhitelabelMenu/constants.animated.ts +1 -1
  787. package/packages/menu/src/WhitelabelMenu/constants.ts +1 -1
  788. package/packages/menu/src/WhitelabelMenu/index.ts +1 -1
  789. package/packages/menu/src/WhitelabelMenu/interface.ts +14 -14
  790. package/packages/menu/src/WhitelabelMenu/rtl.scss +22 -22
  791. package/packages/menu/src/WhitelabelMenu/sizes.1080.ts +1 -1
  792. package/packages/menu/src/WhitelabelMenu/sizes.ts +1 -1
  793. package/packages/menu/src/WhitelabelMenu/styles.ts +1 -1
  794. package/packages/menu/src/WhitelabelMenu/utils.ts +34 -34
  795. package/packages/menu/src/index.ts +2 -2
  796. package/packages/modal-service/README.md +50 -50
  797. package/packages/modal-service/src/IModal.ts +3 -3
  798. package/packages/modal-service/src/ModalService.scss +7 -7
  799. package/packages/modal-service/src/ModalService.styles.1080.scss +2 -2
  800. package/packages/modal-service/src/ModalService.styles.scss +2 -2
  801. package/packages/modal-service/src/ModalService.tsx +102 -102
  802. package/packages/modal-service/src/_sizes.1080.scss +2 -2
  803. package/packages/modal-service/src/_sizes.scss +2 -2
  804. package/packages/modal-service/src/index.ts +2 -2
  805. package/packages/mouse-navigation/README.md +105 -105
  806. package/packages/mouse-navigation/src/ArrowNavigation/Arrow.tsx +58 -58
  807. package/packages/mouse-navigation/src/ArrowNavigation/ArrowNavigation.tsx +95 -95
  808. package/packages/mouse-navigation/src/ArrowNavigation/__test__/Arrow.spec.tsx +35 -35
  809. package/packages/mouse-navigation/src/ArrowNavigation/__test__/ArrowNavigation.spec.tsx +45 -45
  810. package/packages/mouse-navigation/src/ArrowNavigation/index.tsx +1 -1
  811. package/packages/mouse-navigation/src/MouseElementWrapper.tsx +70 -70
  812. package/packages/mouse-navigation/src/MouseNavigation.tsx +157 -157
  813. package/packages/mouse-navigation/src/MouseNavigationInterface.ts +8 -8
  814. package/packages/mouse-navigation/src/index.ts +3 -3
  815. package/packages/numeric-zapper/README.md +153 -153
  816. package/packages/numeric-zapper/src/NumericZapper.scss +20 -20
  817. package/packages/numeric-zapper/src/NumericZapper.styles.1080.scss +2 -2
  818. package/packages/numeric-zapper/src/NumericZapper.styles.scss +2 -2
  819. package/packages/numeric-zapper/src/NumericZapper.tsx +257 -257
  820. package/packages/numeric-zapper/src/ZapperAllower.ts +15 -15
  821. package/packages/numeric-zapper/src/ZapperService.tsx +8 -8
  822. package/packages/numeric-zapper/src/_sizes.1080.scss +7 -7
  823. package/packages/numeric-zapper/src/_sizes.scss +7 -7
  824. package/packages/numeric-zapper/src/index.ts +4 -4
  825. package/packages/numeric-zapper/src/interface.ts +1 -1
  826. package/packages/numeric-zapper/src/styles.ts +1 -1
  827. package/packages/perf-utils/README.md +7 -7
  828. package/packages/perf-utils/src/array/filter.ts +1 -1
  829. package/packages/perf-utils/src/array/find.ts +1 -1
  830. package/packages/perf-utils/src/array/findIndex.ts +1 -1
  831. package/packages/perf-utils/src/array/forEach.ts +1 -1
  832. package/packages/perf-utils/src/array/includes.ts +1 -1
  833. package/packages/perf-utils/src/array/includesNaN.ts +1 -1
  834. package/packages/perf-utils/src/array/index.ts +1 -1
  835. package/packages/perf-utils/src/array/map.ts +1 -1
  836. package/packages/picker/README.md +70 -70
  837. package/packages/picker/src/DatePicker.tsx +55 -55
  838. package/packages/picker/src/ModalPicker/Checkbox.tsx +38 -38
  839. package/packages/picker/src/ModalPicker/PickerItem.tsx +86 -86
  840. package/packages/picker/src/ModalPicker/PickerModal.tsx +98 -98
  841. package/packages/picker/src/ModalPicker/index.ts +1 -1
  842. package/packages/picker/src/ModalPicker/modalPicker.tsx +48 -48
  843. package/packages/picker/src/Picker.tsx +127 -127
  844. package/packages/picker/src/index.ts +3 -3
  845. package/packages/picker/src/types.ts +25 -25
  846. package/packages/pin-input/README.md +55 -55
  847. package/packages/pin-input/src/PinInput.scss +5 -5
  848. package/packages/pin-input/src/PinInput.tsx +169 -169
  849. package/packages/pin-input/src/index.ts +1 -1
  850. package/packages/player-ui/README.md +207 -207
  851. package/packages/player-ui/src/BackwardButton.tsx +41 -41
  852. package/packages/player-ui/src/CurrentTime.tsx +56 -56
  853. package/packages/player-ui/src/Duration.tsx +60 -60
  854. package/packages/player-ui/src/ForwardButton.tsx +41 -41
  855. package/packages/player-ui/src/PauseButton.tsx +57 -57
  856. package/packages/player-ui/src/PlayButton.tsx +57 -57
  857. package/packages/player-ui/src/PlayPauseButton.tsx +63 -63
  858. package/packages/player-ui/src/PlayerInteractable.tsx +67 -67
  859. package/packages/player-ui/src/PlayerTime.tsx +57 -57
  860. package/packages/player-ui/src/PlayerUI.tsx +267 -267
  861. package/packages/player-ui/src/RemainingTime.tsx +74 -74
  862. package/packages/player-ui/src/Seekbar.tsx +274 -274
  863. package/packages/player-ui/src/Seeking.ts +163 -163
  864. package/packages/player-ui/src/StopButton.tsx +35 -35
  865. package/packages/player-ui/src/Subtitles.tsx +151 -151
  866. package/packages/player-ui/src/index.ts +15 -15
  867. package/packages/player-ui/src/mocks.ts +65 -65
  868. package/packages/player-ui/src/timeUtils.ts +142 -142
  869. package/packages/player-ui/src/types.ts +48 -48
  870. package/packages/progress-bar/README.md +31 -31
  871. package/packages/progress-bar/src/ProgressBar.tsx +41 -41
  872. package/packages/progress-bar/src/index.ts +1 -1
  873. package/packages/progress-bar/src/interface.ts +14 -14
  874. package/packages/qr-code/README.md +79 -79
  875. package/packages/qr-code/src/QRCode.tsx +39 -39
  876. package/packages/qr-code/src/index.ts +2 -2
  877. package/packages/qr-code/src/qrGenerator/__external__/constants.ts +23 -23
  878. package/packages/qr-code/src/qrGenerator/__external__/qrcode.d.ts +31 -31
  879. package/packages/qr-code/src/qrGenerator/__external__/qrcode.js +618 -618
  880. package/packages/qr-code/src/qrGenerator/generateQr.ts +7 -7
  881. package/packages/qr-code/src/qrGenerator/index.ts +3 -3
  882. package/packages/router/README.md +163 -163
  883. package/packages/router/src/Route.tsx +166 -166
  884. package/packages/router/src/Router.tsx +220 -220
  885. package/packages/router/src/focusActiveRoute.ts +5 -5
  886. package/packages/router/src/history.ts +31 -31
  887. package/packages/router/src/index.ts +6 -6
  888. package/packages/router/src/types.ts +13 -13
  889. package/packages/router/src/utils.ts +35 -32
  890. package/packages/runtime-config/README.md +37 -37
  891. package/packages/runtime-config/src/Config.ts +44 -44
  892. package/packages/runtime-config/src/index.ts +1 -1
  893. package/packages/sass-utils/README.md +197 -197
  894. package/packages/sass-utils/src/box-shadow.scss +5 -5
  895. package/packages/sass-utils/src/ellipsis.scss +15 -15
  896. package/packages/sass-utils/src/linear-gradient.scss +43 -43
  897. package/packages/sass-utils/src/prefix-property.scss +7 -7
  898. package/packages/sass-utils/src/prefix-value.scss +6 -6
  899. package/packages/sass-utils/src/prefix.scss +6 -6
  900. package/packages/sass-utils/src/scale.1080.scss +3 -3
  901. package/packages/sass-utils/src/scale.720.scss +5 -5
  902. package/packages/sass-utils/src/transform.scss +5 -5
  903. package/packages/sass-utils/src/transition.scss +6 -6
  904. package/packages/scheduler/README.md +55 -55
  905. package/packages/scheduler/src/Scheduler.ts +43 -43
  906. package/packages/scheduler/src/Task.ts +72 -72
  907. package/packages/scheduler/src/index.ts +4 -4
  908. package/packages/scheduler/src/timeProvider.ts +3 -3
  909. package/packages/scroll-text/README.md +77 -77
  910. package/packages/scroll-text/src/Base.tsx +146 -146
  911. package/packages/scroll-text/src/ScrollText.animated.tsx +80 -80
  912. package/packages/scroll-text/src/ScrollText.tsx +53 -53
  913. package/packages/scroll-text/src/ScrollTextBaseClass.tsx +86 -86
  914. package/packages/scroll-text/src/index.ts +1 -1
  915. package/packages/scroller/README.md +77 -77
  916. package/packages/scroller/src/Scroller.tsx +51 -51
  917. package/packages/scroller/src/index.ts +1 -1
  918. package/packages/splash/AnimatedSplash.ts +1 -1
  919. package/packages/splash/AnimatedSplashAnimated.ts +1 -1
  920. package/packages/splash/AnimatedSplashBasic.ts +1 -1
  921. package/packages/splash/AutomaticSplashAnimated.ts +1 -1
  922. package/packages/splash/AutomaticSplashBasic.ts +1 -1
  923. package/packages/splash/README.md +93 -93
  924. package/packages/splash/StaticSplash.ts +1 -1
  925. package/packages/splash/StaticSplashAnimated.ts +1 -1
  926. package/packages/splash/StaticSplashBasic.ts +1 -1
  927. package/packages/splash/src/AnimatedSplash.animated.tsx +78 -78
  928. package/packages/splash/src/AnimatedSplash.basic.tsx +37 -37
  929. package/packages/splash/src/AutomaticSplash.animated.tsx +20 -20
  930. package/packages/splash/src/AutomaticSplash.basic.tsx +20 -20
  931. package/packages/splash/src/Splash.scss +8 -8
  932. package/packages/splash/src/StaticSplash.animated.tsx +48 -48
  933. package/packages/splash/src/StaticSplash.basic.tsx +26 -26
  934. package/packages/splash/src/index.animated.ts +1 -1
  935. package/packages/splash/src/index.ts +1 -1
  936. package/packages/splash/src/styles.ts +1 -1
  937. package/packages/splash/src/types.ts +20 -20
  938. package/packages/storage/README.md +61 -61
  939. package/packages/storage/src/CookieStorage/CookieStorage.ts +57 -57
  940. package/packages/storage/src/CookieStorage/index.ts +1 -1
  941. package/packages/storage/src/LocalStorage/LocalStorage.ts +58 -58
  942. package/packages/storage/src/LocalStorage/index.ts +1 -1
  943. package/packages/storage/src/index.ts +2 -2
  944. package/packages/storage/src/shared.ts +41 -41
  945. package/packages/storage/src/types.ts +33 -33
  946. package/packages/throbber/README.md +53 -53
  947. package/packages/throbber/src/Throbber.scss +52 -52
  948. package/packages/throbber/src/Throbber.tsx +19 -19
  949. package/packages/throbber/src/ThrobberService.tsx +55 -55
  950. package/packages/throbber/src/controlsHandling.ts +14 -14
  951. package/packages/throbber/src/index.ts +2 -2
  952. package/packages/time/README.md +116 -116
  953. package/packages/time/src/Time.ts +257 -257
  954. package/packages/time/src/adapters/24iMediaTimeApi.ts +47 -47
  955. package/packages/time/src/adapters/worldTimeApi.ts +74 -74
  956. package/packages/time/src/constants.ts +14 -14
  957. package/packages/time/src/index.ts +1 -1
  958. package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +43 -43
  959. package/packages/time/src/services/24iMediaTimeApi/index.ts +6 -6
  960. package/packages/time/src/services/worldTimeApi/index.ts +7 -7
  961. package/packages/time/src/services/worldTimeApi/types.ts +75 -75
  962. package/packages/time/src/services/worldTimeApi/worldTimeApi.ts +77 -77
  963. package/packages/time/src/types.ts +39 -39
  964. package/packages/time/src/utils.ts +79 -79
  965. package/packages/toast/README.md +116 -116
  966. package/packages/toast/src/Toast/IVisualController.ts +7 -7
  967. package/packages/toast/src/Toast/Toast.scss +22 -22
  968. package/packages/toast/src/Toast/Toast.styles.1080.scss +2 -2
  969. package/packages/toast/src/Toast/Toast.styles.scss +2 -2
  970. package/packages/toast/src/Toast/Toast.tsx +83 -83
  971. package/packages/toast/src/Toast/VisualController.animated.ts +20 -20
  972. package/packages/toast/src/Toast/VisualController.ts +9 -9
  973. package/packages/toast/src/Toast/_sizes.1080.scss +8 -8
  974. package/packages/toast/src/Toast/_sizes.scss +8 -8
  975. package/packages/toast/src/Toast/index.ts +2 -2
  976. package/packages/toast/src/Toast/styles.ts +1 -1
  977. package/packages/toast/src/ToastService.scss +8 -8
  978. package/packages/toast/src/ToastService.styles.1080.scss +2 -2
  979. package/packages/toast/src/ToastService.styles.scss +2 -2
  980. package/packages/toast/src/ToastService.tsx +59 -59
  981. package/packages/toast/src/_sizes.1080.scss +2 -2
  982. package/packages/toast/src/_sizes.scss +2 -2
  983. package/packages/toast/src/index.ts +4 -4
  984. package/packages/toast/src/types.ts +4 -4
  985. package/packages/types-bigscreen-jsx/README.md +12 -12
  986. package/packages/types-bigscreen-jsx/global.d.ts +0 -0
  987. package/packages/types-bigscreen-jsx/index.d.ts +32 -32
  988. package/packages/types-bigscreen-jsx/src/copyTypes.js +14 -14
  989. package/packages/utils/README.md +363 -363
  990. package/packages/utils/src/addClass.ts +9 -9
  991. package/packages/utils/src/counter.ts +49 -49
  992. package/packages/utils/src/debounce.ts +54 -54
  993. package/packages/utils/src/displayToggler.scss +3 -3
  994. package/packages/utils/src/displayToggler.ts +38 -38
  995. package/packages/utils/src/elementUtils.ts +105 -105
  996. package/packages/utils/src/forceReflow.ts +14 -14
  997. package/packages/utils/src/generateUuid.ts +19 -19
  998. package/packages/utils/src/index.ts +43 -43
  999. package/packages/utils/src/keyPress/index.ts +6 -6
  1000. package/packages/utils/src/keyPress/keyPressSimulator.ts +74 -74
  1001. package/packages/utils/src/keyPress/simulateKeyPress.ts +25 -25
  1002. package/packages/utils/src/memoryInfo.ts +21 -21
  1003. package/packages/utils/src/nTimes.ts +9 -9
  1004. package/packages/utils/src/noop.ts +1 -1
  1005. package/packages/utils/src/offsetPosition.ts +56 -56
  1006. package/packages/utils/src/removeClass.ts +9 -9
  1007. package/packages/utils/src/scaledImage.ts +24 -24
  1008. package/packages/utils/src/sizes.1080.ts +1 -1
  1009. package/packages/utils/src/sizes.ts +1 -1
  1010. package/packages/utils/src/stopEvent.ts +10 -10
  1011. package/packages/utils/src/textUtils.ts +57 -57
  1012. package/packages/utils/src/timeConstants.ts +11 -11
  1013. package/packages/utils/src/timers/createInterval.ts +19 -19
  1014. package/packages/utils/src/timers/createTimeout.ts +22 -22
  1015. package/packages/utils/src/timers/index.ts +4 -4
  1016. package/packages/utils/src/timers/runAsync.ts +3 -3
  1017. package/packages/utils/src/timers/types.ts +9 -9
  1018. package/packages/utils/src/wait.ts +3 -3
  1019. package/packages/utils/src/xhr/__mocks__/xhr.ts +29 -29
  1020. package/packages/utils/src/xhr/index.ts +11 -11
  1021. package/packages/utils/src/xhr/xhrSend.ts +141 -141
  1022. package/packages/utils/src/xhr/xhrSendRetry.ts +79 -79
  1023. package/packages/volume-control/README.md +79 -79
  1024. package/packages/volume-control/src/IVolumeControlUI.ts +26 -26
  1025. package/packages/volume-control/src/VolumeControlService.tsx +110 -110
  1026. package/packages/volume-control/src/VolumeControlUI/VisualController.animated.ts +28 -28
  1027. package/packages/volume-control/src/VolumeControlUI/VisualController.ts +3 -3
  1028. package/packages/volume-control/src/VolumeControlUI/VisualControllerBase.ts +26 -26
  1029. package/packages/volume-control/src/VolumeControlUI/VolumeControl.scss +18 -18
  1030. package/packages/volume-control/src/VolumeControlUI/VolumeControl.styles.animated.scss +2 -2
  1031. package/packages/volume-control/src/VolumeControlUI/VolumeControl.styles.scss +1 -1
  1032. package/packages/volume-control/src/VolumeControlUI/VolumeControlUI.tsx +80 -80
  1033. package/packages/volume-control/src/VolumeControlUI/_animated.scss +8 -8
  1034. package/packages/volume-control/src/VolumeControlUI/index.ts +1 -1
  1035. package/packages/volume-control/src/__mocks__/VolumeControlUIMock.tsx +22 -22
  1036. package/packages/volume-control/src/index.ts +2 -2
  1037. package/packages/zapping/README.md +87 -87
  1038. package/packages/zapping/src/ChannelZapping.ts +143 -143
  1039. package/packages/zapping/src/Zapping.tsx +115 -115
  1040. package/packages/zapping/src/index.ts +1 -1
  1041. package/packages/zapping/src/interface.ts +1 -1
  1042. package/utils/create-export-maps/index.ts +3 -3
  1043. package/utils/create-export-maps/src/__tests__/createExportMaps.spec.ts +50 -50
  1044. package/utils/create-export-maps/src/createExportMaps.ts +61 -61
  1045. package/utils/create-package/README.md +39 -39
  1046. package/utils/create-package/src/createPackage.ts +72 -72
  1047. package/utils/create-package/src/index.ts +3 -3
  1048. package/utils/create-package/src/questionnaire/questions.ts +19 -19
  1049. package/utils/create-package/src/settings/Settings.ts +5 -5
  1050. package/utils/create-package/src/types.ts +4 -4
  1051. package/utils/create-package/templates/typescript/README.md +8 -8
  1052. package/utils/create-package/templates/typescript/exports.json +6 -6
  1053. package/utils/run-scripts/index.ts +3 -3
  1054. package/utils/run-scripts/src/__tests__/runScripts.spec.ts +45 -45
  1055. package/utils/run-scripts/src/runScripts.ts +20 -20
@@ -1,1015 +1,1015 @@
1
- // # The MIT License (MIT)
2
- // #
3
- // # Copyright (c) 2016 Microsoft. All rights reserved.
4
- // #
5
- // # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // # of this software and associated documentation files (the "Software"), to deal
7
- // # in the Software without restriction, including without limitation the rights
8
- // # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // # copies of the Software, and to permit persons to whom the Software is
10
- // # furnished to do so, subject to the following conditions:
11
- // #
12
- // # The above copyright notice and this permission notice shall be included in
13
- // # all copies or substantial portions of the Software.
14
- // #
15
- // # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- // # THE SOFTWARE.
22
-
23
- //High Level
24
- // -Provides direct APIs to navigate focus to each cardinal direction relative
25
- // to the current focused element within a specified container
26
- // -Directly listens to configurable key inputs and invokes navigation
27
- // automatically
28
- // -Coordinates with XYFocus implementations within iframes for seamless focus
29
- // navigation into and out of an iframe
30
-
31
- //Navigation Algorithm
32
- // -Navigation API is called with a given direction
33
- // -Source element is established, usually the current focused element
34
- // -All elements within the focus root (document.body by default) are gathered
35
- // -Each element's distance from the source element is measured
36
- // -Each element is assigned a score value which takes the following into
37
- // account, in order of importance:
38
- // -The relative size and alignment difference between the element
39
- // and history rectangle
40
- // -The distance between the element and source element along the
41
- // main axis
42
- // -The relative size and alignment difference between the element
43
- // and source element
44
- // -The distance the element and source element along the co- axis
45
- // -The highest scoring element is resolved which is the candidate for navigation
46
- // -NOTE: a more in -depth summary of this algorithm can be found in the actual
47
- // source code which has been well- maintained as the code evolved
48
-
49
- //Customizations
50
- // The focus request can be customized by the following:
51
- // -Specific source rectangle/ element, algorithm calculates from this
52
- // rectangle instead of the current focused element
53
- // -A focus root, only elements within the focus root are considered as
54
- // potential targets
55
- // -A history rectangle, which heavily favors potential target elements that
56
- // are aligned and of similar size to the history rectangle
57
- // -Any focusable element can be also annotated with a
58
- // "data-tv-focus='{ left: "#myDiv" }'" attribute.This attribute is referred
59
- // to as an XYFocus override.This allows you to directly control where focus
60
- // should move from this element, given the requested direction.
61
-
62
- //Automatic Focus
63
- // The XYFocus module can be configured to listen to specific hotkeys via
64
- // XYFocus.keyCodeMap.When a mapped key input is detected, it will automatically
65
- // invoke the above navigation algorithm.By default, the Xbox DPad and left thumbstick
66
- // keys are mapped.These can be cleared and new keys(e.g.arrow keys, WASD) can be added.
67
-
68
- //Considerations when authoring new controls
69
- // When authoring a new control, you may just let XYFocus handle all your focus navigation if the
70
- // focus navigation story is trivial.
71
-
72
- //Dealing with edge cases
73
- // Rule of thumb: Ignore it! One important thing to accept is that XYFocus is a heuristic-it is
74
- // not a general focus management solution.It works very well in orthogonal, grid - like layouts
75
- // and will fail utterly outside of them.
76
- // -There are numerous layouts that can break the XYFocus' heuristic for determining the next
77
- // focusable element.Most of these are unnatural and contrived layouts where buttons are
78
- // purposely misaligned and overlapping.Historically, we have ignored these issues.
79
- // -If a valid edge case is found, we handle it on a case-by -case basis.In most cases,
80
- // leveraging the XYFocus override is good enough.
81
- // -If anything more fundamental with the heuristics are found (which has not happened since
82
- // XYFocus was handed to WinJS by Xbox), consider tweaking the scoring constants - this is the
83
- // most EXTREME case.
84
- // -Another category of edge cases revolves around history focus.These have also been historically
85
- // ignored as no real app has produced any valid layout that triggers these issues.
86
- // One common example here is that you could have a list of buttons so long that the score from
87
- // the primary axis trumps the history score, however, you'd need 10,000s of pixels of consecutive
88
- // buttons which is unrealistic as a focus movement likely will trigger a scroll which invalidates history.
89
-
90
- (function () {
91
- "use strict";
92
-
93
- var CrossDomainMessageConstants = {
94
- messageDataProperty: "msWinJSXYFocusControlMessage",
95
- register: "register",
96
- unregister: "unregister",
97
- dFocusEnter: "dFocusEnter",
98
- dFocusExit: "dFocusExit"
99
- };
100
- var DirectionNames = {
101
- left: "left",
102
- right: "right",
103
- up: "up",
104
- down: "down"
105
- };
106
- var EventNames = {
107
- focusChanging: "focuschanging",
108
- focusChanged: "focuschanged"
109
- };
110
- var FocusableTagNames = [
111
- "A",
112
- "BUTTON",
113
- "IFRAME",
114
- "INPUT",
115
- "SELECT",
116
- "TEXTAREA",
117
- "X-MS-WEBVIEW"
118
- ];
119
- var FocusableSelectors = [];
120
-
121
- // These factors can be tweaked to adjust which elements are favored by the focus algorithm
122
- var ScoringConstants = {
123
- primaryAxisDistanceWeight: 30,
124
- secondaryAxisDistanceWeight: 20,
125
- percentInHistoryShadowWeight: 100000
126
- };
127
-
128
- /**
129
- * Gets the mapping object that maps keycodes to XYFocus actions.
130
- **/
131
- var _keyCodeMap = {
132
- left: [],
133
- right: [],
134
- up: [],
135
- down: [],
136
- accept: []
137
- };
138
-
139
- var _enabled = true;
140
- /**
141
- * Gets or sets the focus root when invoking XYFocus APIs.
142
- **/
143
- var _focusRoot;
144
-
145
- function _findNextFocusElement(direction, options) {
146
- var result = _findNextFocusElementInternal(direction, options);
147
- return result ? result.target : null;
148
- }
149
- function _moveFocus(direction, options) {
150
- var result = _findNextFocusElement(direction, options);
151
- if (result) {
152
- var previousFocusElement = document.activeElement;
153
- if (_trySetFocus(result, -1)) {
154
- eventSrc.dispatchEvent(EventNames.focusChanged, { previousFocusElement: previousFocusElement, keyCode: -1 });
155
- return result;
156
- }
157
- }
158
- return null;
159
- }
160
- function _mergeAll(list) {
161
- // Merge a list of objects together
162
- var o = {};
163
- list.forEach(function (part) {
164
- Object.keys(part).forEach(function (k) {
165
- o[k] = part[k];
166
- });
167
- });
168
- return o;
169
- };
170
- function _createEventProperty(name) {
171
- var eventPropStateName = "_on" + name + "state";
172
-
173
- return {
174
- get: function () {
175
- var state = this[eventPropStateName];
176
- return state && state.userHandler;
177
- },
178
- set: function (handler) {
179
- var state = this[eventPropStateName];
180
- if (handler) {
181
- if (!state) {
182
- state = { wrapper: function (evt) { return state.userHandler(evt); }, userHandler: handler };
183
- Object.defineProperty(this, eventPropStateName, { value: state, enumerable: false, writable: true, configurable: true });
184
- this.addEventListener(name, state.wrapper, false);
185
- }
186
- state.userHandler = handler;
187
- } else if (state) {
188
- this.removeEventListener(name, state.wrapper, false);
189
- this[eventPropStateName] = null;
190
- }
191
- },
192
- enumerable: true
193
- };
194
- };
195
- // Privates
196
- var _lastTarget;
197
- var _cachedLastTargetRect;
198
- var _historyRect;
199
- /**
200
- * Executes XYFocus algorithm with the given parameters. Returns true if focus was moved, false otherwise.
201
- * @param direction The direction to move focus.
202
- * @param keyCode The key code of the pressed key.
203
- * @param referenceRect (optional) A rectangle to use as the source coordinates for finding the next focusable element.
204
- * @param dontExit (optional) Indicates whether this focus request is allowed to propagate to its parent if we are in iframe.
205
- **/
206
- function _xyFocus(direction, keyCode, referenceRect, dontExit) {
207
- // If focus has moved since the last XYFocus movement, scrolling occured, or an explicit
208
- // reference rectangle was given to us, then we invalidate the history rectangle.
209
- if (referenceRect || document.activeElement !== _lastTarget) {
210
- _historyRect = null;
211
- _lastTarget = null;
212
- _cachedLastTargetRect = null;
213
- }
214
- else if (_lastTarget && _cachedLastTargetRect) {
215
- var lastTargetRect = _toIRect(_lastTarget.getBoundingClientRect());
216
- // Sometimes the bounds calculation for top is off by 1 even though the element has not moved.
217
- if (lastTargetRect.left !== _cachedLastTargetRect.left || Math.abs(lastTargetRect.top - _cachedLastTargetRect.top) > 1) {
218
- _cachedLastTargetRect = lastTargetRect;
219
- }
220
- }
221
- var activeElement = document.activeElement;
222
- var lastTarget = _lastTarget;
223
- var result = _findNextFocusElementInternal(direction, {
224
- focusRoot: _focusRoot,
225
- historyRect: _historyRect,
226
- referenceElement: _lastTarget,
227
- referenceRect: referenceRect
228
- });
229
- if (result && _trySetFocus(result.target, keyCode)) {
230
- // A focus target was found
231
- updateHistoryRect(direction, result);
232
- _lastTarget = result.target;
233
- _cachedLastTargetRect = result.targetRect;
234
- if (result.target.tagName === "IFRAME") {
235
- var targetIframe = result.target;
236
- if (IFrameHelper.isXYFocusEnabled(targetIframe)) {
237
- // If we successfully moved focus and the new focused item is an IFRAME, then we need to notify it
238
- // Note on coordinates: When signaling enter, DO transform the coordinates into the child frame's coordinate system.
239
- var refRect = _toIRect({
240
- left: result.referenceRect.left - result.targetRect.left,
241
- top: result.referenceRect.top - result.targetRect.top,
242
- width: result.referenceRect.width,
243
- height: result.referenceRect.height
244
- });
245
- var message = {};
246
- message[CrossDomainMessageConstants.messageDataProperty] = {
247
- type: CrossDomainMessageConstants.dFocusEnter,
248
- direction: direction,
249
- referenceRect: refRect
250
- };
251
- // postMessage API is safe even in cross-domain scenarios.
252
- targetIframe.contentWindow.postMessage(message, "*");
253
- }
254
- }
255
- else if (typeof result.target.navigateFocus === "function") {
256
- // No need to adjust coordinate space of result.referenceRect. navigateFocus/departFocus and corresponding
257
- // events handle the coordinate space translation.
258
- result.target.navigateFocus(direction, WebViewHelper.refRectToNavigateFocusRect(result.referenceRect));
259
- }
260
- eventSrc.dispatchEvent(EventNames.focusChanged, { previousFocusElement: activeElement, keyCode: keyCode });
261
- return true;
262
- }
263
- else {
264
- // No focus target was found; if we are inside an IFRAME or webview and focus is allowed to propagate out, notify the parent that focus is exiting
265
- // Note on coordinates: When signaling exit, do NOT transform the coordinates into the parent's coordinate system.
266
- if ((!dontExit && top !== window) || typeof window.departFocus === "function") {
267
- var refRect = referenceRect;
268
- if (!refRect) {
269
- refRect = document.activeElement ? _toIRect(document.activeElement.getBoundingClientRect()) : _defaultRect();
270
- }
271
- if (top === window && typeof window.departFocus === "function") {
272
- document.activeElement.blur();
273
- departFocus(direction, WebViewHelper.refRectToNavigateFocusRect(refRect));
274
- }
275
- else {
276
- var message = {};
277
- message[CrossDomainMessageConstants.messageDataProperty] = {
278
- type: CrossDomainMessageConstants.dFocusExit,
279
- direction: direction,
280
- referenceRect: refRect
281
- };
282
- // postMessage API is safe even in cross-domain scenarios.
283
- parent.postMessage(message, "*");
284
- }
285
- return true;
286
- }
287
- }
288
- return false;
289
- // Nested Helpers
290
- function updateHistoryRect(direction, result) {
291
- var newHistoryRect = _defaultRect();
292
- // It's possible to get into a situation where the target element has no overlap with the reference edge.
293
- //
294
- //..╔══════════════╗..........................
295
- //..║ reference ║..........................
296
- //..╚══════════════╝..........................
297
- //.....................╔═══════════════════╗..
298
- //.....................║ ║..
299
- //.....................║ target ║..
300
- //.....................║ ║..
301
- //.....................╚═══════════════════╝..
302
- //
303
- // If that is the case, we need to reset the coordinates to the edge of the target element.
304
- if (direction === DirectionNames.left || direction === DirectionNames.right) {
305
- newHistoryRect.top = Math.max(result.targetRect.top, result.referenceRect.top, _historyRect ? _historyRect.top : Number.MIN_VALUE);
306
- newHistoryRect.bottom = Math.min(result.targetRect.bottom, result.referenceRect.bottom, _historyRect ? _historyRect.bottom : Number.MAX_VALUE);
307
- if (newHistoryRect.bottom <= newHistoryRect.top) {
308
- newHistoryRect.top = result.targetRect.top;
309
- newHistoryRect.bottom = result.targetRect.bottom;
310
- }
311
- newHistoryRect.height = newHistoryRect.bottom - newHistoryRect.top;
312
- newHistoryRect.width = Number.MAX_VALUE;
313
- newHistoryRect.left = Number.MIN_VALUE;
314
- newHistoryRect.right = Number.MAX_VALUE;
315
- }
316
- else {
317
- newHistoryRect.left = Math.max(result.targetRect.left, result.referenceRect.left, _historyRect ? _historyRect.left : Number.MIN_VALUE);
318
- newHistoryRect.right = Math.min(result.targetRect.right, result.referenceRect.right, _historyRect ? _historyRect.right : Number.MAX_VALUE);
319
- if (newHistoryRect.right <= newHistoryRect.left) {
320
- newHistoryRect.left = result.targetRect.left;
321
- newHistoryRect.right = result.targetRect.right;
322
- }
323
- newHistoryRect.width = newHistoryRect.right - newHistoryRect.left;
324
- newHistoryRect.height = Number.MAX_VALUE;
325
- newHistoryRect.top = Number.MIN_VALUE;
326
- newHistoryRect.bottom = Number.MAX_VALUE;
327
- }
328
- _historyRect = newHistoryRect;
329
- }
330
- }
331
- function _findNextFocusElementInternal(direction, options) {
332
- options = options || {};
333
- options.focusRoot = options.focusRoot || _focusRoot || document.body;
334
- options.historyRect = options.historyRect || _defaultRect();
335
- var maxDistance = Math.max(window.screen.availHeight, window.screen.availWidth);
336
- var refObj = getReferenceObject(options.referenceElement, options.referenceRect);
337
- // Handle override
338
- var refElement = refObj.element;
339
- if (refElement) {
340
- var overrideSelector = refElement.getAttribute("data-tv-focus-" + direction);
341
- if (overrideSelector) {
342
- if (overrideSelector) {
343
- var target;
344
- var element = refObj.element;
345
- while (!target && element) {
346
- target = element.querySelector(overrideSelector);
347
- element = element.parentElement;
348
- }
349
- if (target) {
350
- if (target === document.activeElement) {
351
- return null;
352
- }
353
- return { target: target, targetRect: _toIRect(target.getBoundingClientRect()), referenceRect: refObj.rect, usedOverride: true };
354
- }
355
- }
356
- }
357
- }
358
- // Calculate scores for each element in the root
359
- var bestPotential = {
360
- element: null,
361
- rect: null,
362
- score: 0
363
- };
364
- var allElements = options.focusRoot.querySelectorAll("*");
365
- for (var i = 0, length = allElements.length; i < length; i++) {
366
- var potentialElement = allElements[i];
367
- if (refObj.element === potentialElement || !_isFocusable(potentialElement)) {
368
- continue;
369
- }
370
- var potentialRect = _toIRect(potentialElement.getBoundingClientRect());
371
- // Skip elements that have either a width of zero or a height of zero
372
- if (potentialRect.width === 0 || potentialRect.height === 0) {
373
- continue;
374
- }
375
- var score = calculateScore(direction, maxDistance, options.historyRect, refObj.rect, potentialRect);
376
- if (score > bestPotential.score) {
377
- bestPotential.element = potentialElement;
378
- bestPotential.rect = potentialRect;
379
- bestPotential.score = score;
380
- }
381
- }
382
- return bestPotential.element ? { target: bestPotential.element, targetRect: bestPotential.rect, referenceRect: refObj.rect, usedOverride: false } : null;
383
- // Nested Helpers
384
- function calculatePercentInShadow(minReferenceCoord, maxReferenceCoord, minPotentialCoord, maxPotentialCoord) {
385
- /// Calculates the percentage of the potential element that is in the shadow of the reference element.
386
- if ((minReferenceCoord >= maxPotentialCoord) || (maxReferenceCoord <= minPotentialCoord)) {
387
- // Potential is not in the reference's shadow.
388
- return 0;
389
- }
390
- var pixelOverlap = Math.min(maxReferenceCoord, maxPotentialCoord) - Math.max(minReferenceCoord, minPotentialCoord);
391
- var shortEdge = Math.min(maxPotentialCoord - minPotentialCoord, maxReferenceCoord - minReferenceCoord);
392
- return shortEdge === 0 ? 0 : (pixelOverlap / shortEdge);
393
- }
394
- function calculateScore(direction, maxDistance, historyRect, referenceRect, potentialRect) {
395
- var score = 0;
396
- var percentInShadow;
397
- var primaryAxisDistance;
398
- var secondaryAxisDistance = 0;
399
- var percentInHistoryShadow = 0;
400
- switch (direction) {
401
- case DirectionNames.left:
402
- // Make sure we don't evaluate any potential elements to the right of the reference element
403
- if (potentialRect.left >= referenceRect.left) {
404
- break;
405
- }
406
- percentInShadow = calculatePercentInShadow(referenceRect.top, referenceRect.bottom, potentialRect.top, potentialRect.bottom);
407
- primaryAxisDistance = referenceRect.left - potentialRect.right;
408
- if (percentInShadow > 0) {
409
- percentInHistoryShadow = calculatePercentInShadow(historyRect.top, historyRect.bottom, potentialRect.top, potentialRect.bottom);
410
- }
411
- else {
412
- // If the potential element is not in the shadow, then we calculate secondary axis distance
413
- secondaryAxisDistance = (referenceRect.bottom <= potentialRect.top) ? (potentialRect.top - referenceRect.bottom) : referenceRect.top - potentialRect.bottom;
414
- }
415
- break;
416
- case DirectionNames.right:
417
- // Make sure we don't evaluate any potential elements to the left of the reference element
418
- if (potentialRect.right <= referenceRect.right) {
419
- break;
420
- }
421
- percentInShadow = calculatePercentInShadow(referenceRect.top, referenceRect.bottom, potentialRect.top, potentialRect.bottom);
422
- primaryAxisDistance = potentialRect.left - referenceRect.right;
423
- if (percentInShadow > 0) {
424
- percentInHistoryShadow = calculatePercentInShadow(historyRect.top, historyRect.bottom, potentialRect.top, potentialRect.bottom);
425
- }
426
- else {
427
- // If the potential element is not in the shadow, then we calculate secondary axis distance
428
- secondaryAxisDistance = (referenceRect.bottom <= potentialRect.top) ? (potentialRect.top - referenceRect.bottom) : referenceRect.top - potentialRect.bottom;
429
- }
430
- break;
431
- case DirectionNames.up:
432
- // Make sure we don't evaluate any potential elements below the reference element
433
- if (potentialRect.top >= referenceRect.top) {
434
- break;
435
- }
436
- percentInShadow = calculatePercentInShadow(referenceRect.left, referenceRect.right, potentialRect.left, potentialRect.right);
437
- primaryAxisDistance = referenceRect.top - potentialRect.bottom;
438
- if (percentInShadow > 0) {
439
- percentInHistoryShadow = calculatePercentInShadow(historyRect.left, historyRect.right, potentialRect.left, potentialRect.right);
440
- }
441
- else {
442
- // If the potential element is not in the shadow, then we calculate secondary axis distance
443
- secondaryAxisDistance = (referenceRect.right <= potentialRect.left) ? (potentialRect.left - referenceRect.right) : referenceRect.left - potentialRect.right;
444
- }
445
- break;
446
- case DirectionNames.down:
447
- // Make sure we don't evaluate any potential elements above the reference element
448
- if (potentialRect.bottom <= referenceRect.bottom) {
449
- break;
450
- }
451
- percentInShadow = calculatePercentInShadow(referenceRect.left, referenceRect.right, potentialRect.left, potentialRect.right);
452
- primaryAxisDistance = potentialRect.top - referenceRect.bottom;
453
- if (percentInShadow > 0) {
454
- percentInHistoryShadow = calculatePercentInShadow(historyRect.left, historyRect.right, potentialRect.left, potentialRect.right);
455
- }
456
- else {
457
- // If the potential element is not in the shadow, then we calculate secondary axis distance
458
- secondaryAxisDistance = (referenceRect.right <= potentialRect.left) ? (potentialRect.left - referenceRect.right) : referenceRect.left - potentialRect.right;
459
- }
460
- break;
461
- }
462
- if (primaryAxisDistance >= 0) {
463
- // The score needs to be a positive number so we make these distances positive numbers
464
- primaryAxisDistance = maxDistance - primaryAxisDistance;
465
- secondaryAxisDistance = maxDistance - secondaryAxisDistance;
466
- if (primaryAxisDistance >= 0 && secondaryAxisDistance >= 0) {
467
- // Potential elements in the shadow get a multiplier to their final score
468
- primaryAxisDistance += primaryAxisDistance * percentInShadow;
469
- score = primaryAxisDistance * ScoringConstants.primaryAxisDistanceWeight + secondaryAxisDistance * ScoringConstants.secondaryAxisDistanceWeight + percentInHistoryShadow * ScoringConstants.percentInHistoryShadowWeight;
470
- }
471
- }
472
- return score;
473
- }
474
- function getReferenceObject(referenceElement, referenceRect) {
475
- var refElement;
476
- var refRect;
477
- if ((!referenceElement && !referenceRect) || (referenceElement && !referenceElement.parentNode)) {
478
- // Note: We need to check to make sure 'parentNode' is not null otherwise there is a case
479
- // where _lastTarget is defined, but calling getBoundingClientRect will throw a native exception.
480
- // This case happens if the innerHTML of the parent of the _lastTarget is set to "".
481
- // If no valid reference is supplied, we'll use document.activeElement unless it's the body
482
- if (document.activeElement !== document.body) {
483
- referenceElement = document.activeElement;
484
- }
485
- }
486
- if (referenceElement) {
487
- refElement = referenceElement;
488
- refRect = _toIRect(refElement.getBoundingClientRect());
489
- }
490
- else if (referenceRect) {
491
- refRect = _toIRect(referenceRect);
492
- }
493
- else {
494
- refRect = _defaultRect();
495
- }
496
- return {
497
- element: refElement,
498
- rect: refRect
499
- };
500
- }
501
- }
502
- function _defaultRect() {
503
- // We set the top, left, bottom and right properties of the referenceBoundingRectangle to '-1'
504
- // (as opposed to '0') because we want to make sure that even elements that are up to the edge
505
- // of the screen can receive focus.
506
- return {
507
- top: -1,
508
- bottom: -1,
509
- right: -1,
510
- left: -1,
511
- height: 0,
512
- width: 0
513
- };
514
- }
515
- function _toIRect(rect) {
516
- return {
517
- top: Math.floor(rect.top),
518
- bottom: Math.floor(rect.top + rect.height),
519
- right: Math.floor(rect.left + rect.width),
520
- left: Math.floor(rect.left),
521
- height: Math.floor(rect.height),
522
- width: Math.floor(rect.width),
523
- };
524
- }
525
- function _trySetFocus(element, keyCode) {
526
- // We raise an event on the focusRoot before focus changes to give listeners
527
- // a chance to prevent the next focus target from receiving focus if they want.
528
- var canceled = eventSrc.dispatchEvent(EventNames.focusChanging, { nextFocusElement: element, keyCode: keyCode });
529
- if (!canceled) {
530
- element.focus();
531
- }
532
- return document.activeElement === element;
533
- }
534
- function _isFocusable(element) {
535
- var elementTagName = element.tagName;
536
- var tabIndex = parseInt(element.getAttribute("tabIndex"));
537
- if (FocusableTagNames.indexOf(elementTagName) === -1 && isNaN(tabIndex)) {
538
- // Loop through the selectors
539
- var matchesSelector = false;
540
- for (var i = 0, len = FocusableSelectors.length; i < len; i++) {
541
- if (_matchesSelector(element, FocusableSelectors[i])) {
542
- if (isNaN(tabIndex)) {
543
- element.setAttribute("tabIndex", 0);
544
- }
545
- matchesSelector = true;
546
- break;
547
- }
548
- }
549
- // If the current potential element is not one of the tags we consider to be focusable, then exit
550
- if (!matchesSelector) {
551
- return false;
552
- }
553
- }
554
- if (elementTagName === "IFRAME" && !IFrameHelper.isXYFocusEnabled(element)) {
555
- // Skip IFRAMEs without compatible XYFocus implementation
556
- return false;
557
- }
558
- if (elementTagName === "DIV" && element["winControl"] && element["winControl"].disabled) {
559
- // Skip disabled WinJS controls
560
- return false;
561
- }
562
-
563
- var style = window.getComputedStyle(element);
564
- if (style && tabIndex === -1 || style.display === "none" || style.visibility === "hidden" || element.disabled) {
565
- // Skip elements that are hidden
566
- // Note: We don't check for opacity === 0, because the browser cannot tell us this value accurately.
567
- return false;
568
- }
569
- return true;
570
- };
571
- function _matchesSelector(element, selectorString) {
572
- var matchesSelector = element.matches
573
- || element.msMatchesSelector
574
- || element.mozMatchesSelector
575
- || element.webkitMatchesSelector;
576
- return matchesSelector.call(element, selectorString);
577
- };
578
- function _handleKeyDownEvent(e) {
579
- if (e.defaultPrevented) {
580
- return;
581
- }
582
- var direction = "";
583
- var keyCode = e.keyCode;
584
- if (_keyCodeMap.up.indexOf(keyCode) !== -1) {
585
- direction = "up";
586
- }
587
- else if (_keyCodeMap.down.indexOf(keyCode) !== -1) {
588
- direction = "down";
589
- }
590
- else if (_keyCodeMap.left.indexOf(keyCode) !== -1) {
591
- direction = "left";
592
- }
593
- else if (_keyCodeMap.right.indexOf(keyCode) !== -1) {
594
- direction = "right";
595
- }
596
- if (direction && _enabled) {
597
- var shouldPreventDefault = _xyFocus(direction, keyCode);
598
- if (shouldPreventDefault) {
599
- e.preventDefault();
600
- }
601
- }
602
- };
603
- function _handleKeyUpEvent(e) {
604
- if (e.defaultPrevented) {
605
- return;
606
- }
607
- if (_keyCodeMap.accept.indexOf(e.keyCode) !== -1) {
608
- e.srcElement.click();
609
- }
610
- };
611
-
612
- var WebViewHelper;
613
- (function (WebViewHelper) {
614
- function refRectToNavigateFocusRect(refRect) {
615
- return {
616
- originLeft: refRect.left,
617
- originTop: refRect.top,
618
- originWidth: refRect.width,
619
- originHeight: refRect.height
620
- };
621
- }
622
- WebViewHelper.refRectToNavigateFocusRect = refRectToNavigateFocusRect;
623
-
624
- function navigateFocusRectToRefRect(navigateFocusRect) {
625
- return _toIRect({
626
- left: navigateFocusRect.originLeft,
627
- top: navigateFocusRect.originTop,
628
- width: navigateFocusRect.originWidth,
629
- height: navigateFocusRect.originHeight
630
- });
631
- }
632
- WebViewHelper.navigateFocusRectToRefRect = navigateFocusRectToRefRect;
633
- })(WebViewHelper || (WebViewHelper = {}));
634
-
635
- var IFrameHelper;
636
- (function (IFrameHelper) {
637
- // XYFocus caches registered iframes and iterates over the cache for its focus navigation implementation.
638
- // However, since there is no reliable way for an iframe to unregister with its parent as it can be
639
- // spontaneously taken out of the DOM, the cache can go stale. This helper module makes sure that on
640
- // every query to the iframe cache, stale iframes are removed.
641
- // Furthermore, merely accessing an iframe that has been garbage collected by the platform will cause an
642
- // exception so each iteration during a query must be in a try/catch block.
643
- var iframes = [];
644
- function count() {
645
- // Iterating over it causes stale iframes to be cleared from the cache.
646
- _safeForEach(function () { return false; });
647
- return iframes.length;
648
- }
649
- IFrameHelper.count = count;
650
- function getIFrameFromWindow(win) {
651
- var iframes = document.querySelectorAll("IFRAME");
652
- var found = Array.prototype.filter.call(iframes, function (x) { return x.contentWindow === win; });
653
- return found.length ? found[0] : null;
654
- }
655
- IFrameHelper.getIFrameFromWindow = getIFrameFromWindow;
656
- function isXYFocusEnabled(iframe) {
657
- var found = false;
658
- _safeForEach(function (ifr) {
659
- if (ifr === iframe) {
660
- found = true;
661
- }
662
- });
663
- return found;
664
- }
665
- IFrameHelper.isXYFocusEnabled = isXYFocusEnabled;
666
- function registerIFrame(iframe) {
667
- iframes.push(iframe);
668
- };
669
- IFrameHelper.registerIFrame = registerIFrame;
670
- function unregisterIFrame(iframe) {
671
- var index = -1;
672
- _safeForEach(function (ifr, i) {
673
- if (ifr === iframe) {
674
- index = i;
675
- }
676
- });
677
- if (index !== -1) {
678
- iframes.splice(index, 1);
679
- }
680
- };
681
- IFrameHelper.unregisterIFrame = unregisterIFrame;
682
- function _safeForEach(callback) {
683
- for (var i = iframes.length - 1; i >= 0; i--) {
684
- try {
685
- var iframe = iframes[i];
686
- if (!iframe.contentWindow) {
687
- iframes.splice(i, 1);
688
- }
689
- else {
690
- callback(iframe, i);
691
- }
692
- }
693
- catch (e) {
694
- // Iframe has been GC'd
695
- iframes.splice(i, 1);
696
- }
697
- }
698
- };
699
- })(IFrameHelper || (IFrameHelper = {}));
700
-
701
- // Default mappings
702
- _keyCodeMap.left.push(
703
- 37, // LeftArrow
704
- 214, // GamepadLeftThumbstickLeft
705
- 205, // GamepadDPadLeft
706
- 140); // NavigationLeft
707
- _keyCodeMap.right.push(
708
- 39, // RightArrow
709
- 213, // GamepadLeftThumbstickRight
710
- 206, // GamepadDPadRight
711
- 141); // NavigationRight
712
- _keyCodeMap.up.push(
713
- 38, // UpArrow
714
- 211, // GamepadLeftThumbstickUp
715
- 203, // GamepadDPadUp
716
- 138); // NavigationUp
717
- _keyCodeMap.down.push(
718
- 40, // UpArrow
719
- 212, // GamepadLeftThumbstickDown
720
- 204, // GamepadDPadDown
721
- 139); // NavigationDown
722
- _keyCodeMap.accept.push(
723
- 142, // NavigationAccept
724
- 195); // GamepadA
725
- window.addEventListener("message", function (e) {
726
- // Note: e.source is the Window object of an iframe which could be hosting content
727
- // from a different domain. No properties on e.source should be accessed or we may
728
- // run into a cross-domain access violation exception.
729
- var sourceWindow = null;
730
- try {
731
- // Since messages are async, by the time we get this message, the iframe could've
732
- // been removed from the DOM and e.source is null or throws an exception on access.
733
- sourceWindow = e.source;
734
- if (!sourceWindow) {
735
- return;
736
- }
737
- }
738
- catch (e) {
739
- return;
740
- }
741
- if (!e.data || !e.data[CrossDomainMessageConstants.messageDataProperty]) {
742
- return;
743
- }
744
- var data = e.data[CrossDomainMessageConstants.messageDataProperty];
745
- switch (data.type) {
746
- case CrossDomainMessageConstants.register:
747
- var iframe = IFrameHelper.getIFrameFromWindow(sourceWindow);
748
- iframe && IFrameHelper.registerIFrame(iframe);
749
- break;
750
- case CrossDomainMessageConstants.unregister:
751
- var iframe = IFrameHelper.getIFrameFromWindow(sourceWindow);
752
- iframe && IFrameHelper.unregisterIFrame(iframe);
753
- break;
754
- case CrossDomainMessageConstants.dFocusEnter:
755
- // The coordinates stored in data.refRect are already in this frame's coordinate system.
756
- // First try to focus anything within this iframe without leaving the current frame.
757
- var focused = _xyFocus(data.direction, -1, data.referenceRect, true);
758
- if (!focused) {
759
- // No focusable element was found, we'll focus document.body if it is focusable.
760
- if (_isFocusable(document.body)) {
761
- document.body.focus();
762
- }
763
- else {
764
- // Nothing within this iframe is focusable, we call _xyFocus again without a refRect
765
- // and allow the request to propagate to the parent.
766
- _xyFocus(data.direction, -1);
767
- }
768
- }
769
- break;
770
- case CrossDomainMessageConstants.dFocusExit:
771
- var iframe = IFrameHelper.getIFrameFromWindow(sourceWindow);
772
- if (document.activeElement !== iframe) {
773
- break;
774
- }
775
- // The coordinates stored in data.refRect are in the IFRAME's coordinate system,
776
- // so we must first transform them into this frame's coordinate system.
777
- var refRect = data.referenceRect;
778
- var iframeRect = iframe.getBoundingClientRect();
779
- refRect.left += iframeRect.left;
780
- refRect.top += iframeRect.top;
781
- if (typeof refRect.right === "number") {
782
- refRect.right += iframeRect.left;
783
- }
784
- if (typeof refRect.bottom === "number") {
785
- refRect.bottom += iframeRect.top;
786
- }
787
- _xyFocus(data.direction, -1, refRect);
788
- break;
789
- }
790
- });
791
-
792
- // Receiving departingFocus event in the app as a result of any child webview calling
793
- // window.departFocus from within the webview. Indicates focus transitioning into the app
794
- // from the webview. The navigatingfocus event handles transforming the
795
- // coordinate space so we just pass the values along.
796
- document.addEventListener("departingfocus", function (eventArg) {
797
- var focusChanged = _xyFocus(
798
- eventArg.navigationReason,
799
- -1,
800
- WebViewHelper.navigateFocusRectToRefRect(eventArg));
801
-
802
- if (focusChanged && eventArg && (typeof eventArg.focus === "function")) {
803
- eventArg.focus();
804
- }
805
- });
806
-
807
- // Receiving a navigatingfocus event in the webview as a result of the host app calling
808
- // webview.navigateFocus on our containing webview element indicating focus transitioning
809
- // into the webview from the app. The navigatingfocus event handles transforming the
810
- // coordinate space so we just pass the values along.
811
- window.addEventListener("navigatingfocus", function (eventArg) {
812
- var focusChanged = _xyFocus(
813
- eventArg.navigationReason,
814
- -1,
815
- WebViewHelper.navigateFocusRectToRefRect(eventArg));
816
-
817
- if (focusChanged && eventArg && (typeof eventArg.focus === "function")) {
818
- eventArg.focus();
819
- }
820
- });
821
-
822
- var _initRun = false;
823
- var _init = function () {
824
- if (_initRun) {
825
- return;
826
- }
827
- _initRun = true;
828
- // Subscribe on bubble phase to allow developers to override XYFocus behaviors for directional keys.
829
- document.addEventListener("keydown", _handleKeyDownEvent);
830
- document.addEventListener("keyup", _handleKeyUpEvent);
831
- // If we are running within an iframe, we send a registration message to the parent window
832
- if (window.top !== window.window) {
833
- var message = {};
834
- message[CrossDomainMessageConstants.messageDataProperty] = {
835
- type: CrossDomainMessageConstants.register,
836
- version: 1.0
837
- };
838
- window.parent.postMessage(message, "*");
839
- }
840
- }
841
-
842
- document.addEventListener("DOMContentLoaded", function () {
843
- _init();
844
- });
845
-
846
- var EventMixinEvent = (function () {
847
- function EventMixinEvent(type, detail, target) {
848
- this.detail = detail;
849
- this.target = target;
850
- this.timeStamp = Date.now();
851
- this.type = type;
852
- this.bubbles = { value: false, writable: false };
853
- this.cancelable = { value: false, writable: false };
854
- this.trusted = { value: false, writable: false };
855
- this.eventPhase = { value: 0, writable: false };
856
- this.supportedForProcessing = true;
857
- };
858
- Object.defineProperty(EventMixinEvent.prototype, "currentTarget", {
859
- get: function () { return this.target; },
860
- enumerable: true,
861
- configurable: true
862
- });
863
- Object.defineProperty(EventMixinEvent.prototype, "defaultPrevented", {
864
- get: function () { return this._preventDefaultCalled; },
865
- enumerable: true,
866
- configurable: true
867
- });
868
- EventMixinEvent.prototype.preventDefault = function () {
869
- this._preventDefaultCalled = true;
870
- };
871
- EventMixinEvent.prototype.stopImmediatePropagation = function () {
872
- this._stopImmediatePropagationCalled = true;
873
- };
874
- EventMixinEvent.prototype.stopPropagation = function () {
875
- };
876
- return EventMixinEvent;
877
- })();
878
-
879
- var eventMixin = {
880
- _listeners: null,
881
-
882
- addEventListener: function (type, listener, useCapture) {
883
- /// <signature helpKeyword="WinJS.Utilities.eventMixin.addEventListener">
884
- /// <summary locid="WinJS.Utilities.eventMixin.addEventListener">
885
- /// Adds an event listener to the control.
886
- /// </summary>
887
- /// <param name="type" locid="WinJS.Utilities.eventMixin.addEventListener_p:type">
888
- /// The type (name) of the event.
889
- /// </param>
890
- /// <param name="listener" locid="WinJS.Utilities.eventMixin.addEventListener_p:listener">
891
- /// The listener to invoke when the event is raised.
892
- /// </param>
893
- /// <param name="useCapture" locid="WinJS.Utilities.eventMixin.addEventListener_p:useCapture">
894
- /// if true initiates capture, otherwise false.
895
- /// </param>
896
- /// </signature>
897
- useCapture = useCapture || false;
898
- this._listeners = this._listeners || {};
899
- var eventListeners = (this._listeners[type] = this._listeners[type] || []);
900
- for (var i = 0, len = eventListeners.length; i < len; i++) {
901
- var l = eventListeners[i];
902
- if (l.useCapture === useCapture && l.listener === listener) {
903
- return;
904
- }
905
- }
906
- eventListeners.push({ listener: listener, useCapture: useCapture });
907
- },
908
- dispatchEvent: function (type, details) {
909
- /// <signature helpKeyword="WinJS.Utilities.eventMixin.dispatchEvent">
910
- /// <summary locid="WinJS.Utilities.eventMixin.dispatchEvent">
911
- /// Raises an event of the specified type and with the specified additional properties.
912
- /// </summary>
913
- /// <param name="type" locid="WinJS.Utilities.eventMixin.dispatchEvent_p:type">
914
- /// The type (name) of the event.
915
- /// </param>
916
- /// <param name="details" locid="WinJS.Utilities.eventMixin.dispatchEvent_p:details">
917
- /// The set of additional properties to be attached to the event object when the event is raised.
918
- /// </param>
919
- /// <returns type="Boolean" locid="WinJS.Utilities.eventMixin.dispatchEvent_returnValue">
920
- /// true if preventDefault was called on the event.
921
- /// </returns>
922
- /// </signature>
923
- var listeners = this._listeners && this._listeners[type];
924
- if (listeners) {
925
- var eventValue = new EventMixinEvent(type, details, this);
926
- // Need to copy the array to protect against people unregistering while we are dispatching
927
- listeners = listeners.slice(0, listeners.length);
928
- for (var i = 0, len = listeners.length; i < len && !eventValue._stopImmediatePropagationCalled; i++) {
929
- listeners[i].listener(eventValue);
930
- }
931
- return eventValue.defaultPrevented || false;
932
- }
933
- return false;
934
- },
935
- removeEventListener: function (type, listener, useCapture) {
936
- /// <signature helpKeyword="WinJS.Utilities.eventMixin.removeEventListener">
937
- /// <summary locid="WinJS.Utilities.eventMixin.removeEventListener">
938
- /// Removes an event listener from the control.
939
- /// </summary>
940
- /// <param name="type" locid="WinJS.Utilities.eventMixin.removeEventListener_p:type">
941
- /// The type (name) of the event.
942
- /// </param>
943
- /// <param name="listener" locid="WinJS.Utilities.eventMixin.removeEventListener_p:listener">
944
- /// The listener to remove.
945
- /// </param>
946
- /// <param name="useCapture" locid="WinJS.Utilities.eventMixin.removeEventListener_p:useCapture">
947
- /// Specifies whether to initiate capture.
948
- /// </param>
949
- /// </signature>
950
- useCapture = useCapture || false;
951
- var listeners = this._listeners && this._listeners[type];
952
- if (listeners) {
953
- for (var i = 0, len = listeners.length; i < len; i++) {
954
- var l = listeners[i];
955
- if (l.listener === listener && l.useCapture === useCapture) {
956
- listeners.splice(i, 1);
957
- if (listeners.length === 0) {
958
- delete this._listeners[type];
959
- }
960
- // Only want to remove one element for each call to removeEventListener
961
- break;
962
- }
963
- }
964
- }
965
- }
966
- };
967
- // Publish to WinJS namespace
968
- var toPublish = {
969
- init: _init,
970
- findNextFocusElement: _findNextFocusElement,
971
- keyCodeMap: _keyCodeMap,
972
- focusableSelectors: FocusableSelectors,
973
- moveFocus: _moveFocus,
974
- onfocuschanged: _createEventProperty(EventNames.focusChanged),
975
- onfocuschanging: _createEventProperty(EventNames.focusChanging),
976
- _xyFocus: _xyFocus,
977
- _handleKeyDownEvent: _handleKeyDownEvent,
978
- _handleKeyUpEvent: _handleKeyUpEvent,
979
- _iframeHelper: IFrameHelper
980
- };
981
- toPublish = _mergeAll([toPublish, eventMixin]);
982
- toPublish["_listeners"] = {};
983
- var eventSrc = toPublish;
984
- window.TVJS = window.TVJS || {};
985
- TVJS.DirectionalNavigation = toPublish;
986
- Object.defineProperty(window.TVJS.DirectionalNavigation, "enabled", {
987
- get: function () {
988
- return _enabled;
989
- },
990
- set: function (value) {
991
- _enabled = value;
992
- },
993
- enumerable: true,
994
- configurable: true
995
- });
996
- Object.defineProperty(window.TVJS.DirectionalNavigation, "focusRoot", {
997
- get: function () {
998
- return _focusRoot;
999
- },
1000
- set: function (value) {
1001
- _focusRoot = value;
1002
- },
1003
- enumerable: true,
1004
- configurable: true
1005
- });
1006
-
1007
- // The gamepadInputEmulation is a string property that exists in JavaScript UWAs and in WebViews in UWAs.
1008
- // It won't exist in Win8.1 style apps or browsers.
1009
- if (window.navigator && typeof window.navigator.gamepadInputEmulation === "string") {
1010
- // We want the gamepad to provide gamepad VK keyboard events rather than moving a
1011
- // mouse like cursor. Set to "keyboard", the gamepad will provide such keyboard events
1012
- // and provide input to the DOM navigator.getGamepads API.
1013
- window.navigator.gamepadInputEmulation = "keyboard";
1014
- }
1015
- })();
1
+ // # The MIT License (MIT)
2
+ // #
3
+ // # Copyright (c) 2016 Microsoft. All rights reserved.
4
+ // #
5
+ // # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ // # of this software and associated documentation files (the "Software"), to deal
7
+ // # in the Software without restriction, including without limitation the rights
8
+ // # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ // # copies of the Software, and to permit persons to whom the Software is
10
+ // # furnished to do so, subject to the following conditions:
11
+ // #
12
+ // # The above copyright notice and this permission notice shall be included in
13
+ // # all copies or substantial portions of the Software.
14
+ // #
15
+ // # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ // # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ // # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ // # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ // # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ // # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ // # THE SOFTWARE.
22
+
23
+ //High Level
24
+ // -Provides direct APIs to navigate focus to each cardinal direction relative
25
+ // to the current focused element within a specified container
26
+ // -Directly listens to configurable key inputs and invokes navigation
27
+ // automatically
28
+ // -Coordinates with XYFocus implementations within iframes for seamless focus
29
+ // navigation into and out of an iframe
30
+
31
+ //Navigation Algorithm
32
+ // -Navigation API is called with a given direction
33
+ // -Source element is established, usually the current focused element
34
+ // -All elements within the focus root (document.body by default) are gathered
35
+ // -Each element's distance from the source element is measured
36
+ // -Each element is assigned a score value which takes the following into
37
+ // account, in order of importance:
38
+ // -The relative size and alignment difference between the element
39
+ // and history rectangle
40
+ // -The distance between the element and source element along the
41
+ // main axis
42
+ // -The relative size and alignment difference between the element
43
+ // and source element
44
+ // -The distance the element and source element along the co- axis
45
+ // -The highest scoring element is resolved which is the candidate for navigation
46
+ // -NOTE: a more in -depth summary of this algorithm can be found in the actual
47
+ // source code which has been well- maintained as the code evolved
48
+
49
+ //Customizations
50
+ // The focus request can be customized by the following:
51
+ // -Specific source rectangle/ element, algorithm calculates from this
52
+ // rectangle instead of the current focused element
53
+ // -A focus root, only elements within the focus root are considered as
54
+ // potential targets
55
+ // -A history rectangle, which heavily favors potential target elements that
56
+ // are aligned and of similar size to the history rectangle
57
+ // -Any focusable element can be also annotated with a
58
+ // "data-tv-focus='{ left: "#myDiv" }'" attribute.This attribute is referred
59
+ // to as an XYFocus override.This allows you to directly control where focus
60
+ // should move from this element, given the requested direction.
61
+
62
+ //Automatic Focus
63
+ // The XYFocus module can be configured to listen to specific hotkeys via
64
+ // XYFocus.keyCodeMap.When a mapped key input is detected, it will automatically
65
+ // invoke the above navigation algorithm.By default, the Xbox DPad and left thumbstick
66
+ // keys are mapped.These can be cleared and new keys(e.g.arrow keys, WASD) can be added.
67
+
68
+ //Considerations when authoring new controls
69
+ // When authoring a new control, you may just let XYFocus handle all your focus navigation if the
70
+ // focus navigation story is trivial.
71
+
72
+ //Dealing with edge cases
73
+ // Rule of thumb: Ignore it! One important thing to accept is that XYFocus is a heuristic-it is
74
+ // not a general focus management solution.It works very well in orthogonal, grid - like layouts
75
+ // and will fail utterly outside of them.
76
+ // -There are numerous layouts that can break the XYFocus' heuristic for determining the next
77
+ // focusable element.Most of these are unnatural and contrived layouts where buttons are
78
+ // purposely misaligned and overlapping.Historically, we have ignored these issues.
79
+ // -If a valid edge case is found, we handle it on a case-by -case basis.In most cases,
80
+ // leveraging the XYFocus override is good enough.
81
+ // -If anything more fundamental with the heuristics are found (which has not happened since
82
+ // XYFocus was handed to WinJS by Xbox), consider tweaking the scoring constants - this is the
83
+ // most EXTREME case.
84
+ // -Another category of edge cases revolves around history focus.These have also been historically
85
+ // ignored as no real app has produced any valid layout that triggers these issues.
86
+ // One common example here is that you could have a list of buttons so long that the score from
87
+ // the primary axis trumps the history score, however, you'd need 10,000s of pixels of consecutive
88
+ // buttons which is unrealistic as a focus movement likely will trigger a scroll which invalidates history.
89
+
90
+ (function () {
91
+ "use strict";
92
+
93
+ var CrossDomainMessageConstants = {
94
+ messageDataProperty: "msWinJSXYFocusControlMessage",
95
+ register: "register",
96
+ unregister: "unregister",
97
+ dFocusEnter: "dFocusEnter",
98
+ dFocusExit: "dFocusExit"
99
+ };
100
+ var DirectionNames = {
101
+ left: "left",
102
+ right: "right",
103
+ up: "up",
104
+ down: "down"
105
+ };
106
+ var EventNames = {
107
+ focusChanging: "focuschanging",
108
+ focusChanged: "focuschanged"
109
+ };
110
+ var FocusableTagNames = [
111
+ "A",
112
+ "BUTTON",
113
+ "IFRAME",
114
+ "INPUT",
115
+ "SELECT",
116
+ "TEXTAREA",
117
+ "X-MS-WEBVIEW"
118
+ ];
119
+ var FocusableSelectors = [];
120
+
121
+ // These factors can be tweaked to adjust which elements are favored by the focus algorithm
122
+ var ScoringConstants = {
123
+ primaryAxisDistanceWeight: 30,
124
+ secondaryAxisDistanceWeight: 20,
125
+ percentInHistoryShadowWeight: 100000
126
+ };
127
+
128
+ /**
129
+ * Gets the mapping object that maps keycodes to XYFocus actions.
130
+ **/
131
+ var _keyCodeMap = {
132
+ left: [],
133
+ right: [],
134
+ up: [],
135
+ down: [],
136
+ accept: []
137
+ };
138
+
139
+ var _enabled = true;
140
+ /**
141
+ * Gets or sets the focus root when invoking XYFocus APIs.
142
+ **/
143
+ var _focusRoot;
144
+
145
+ function _findNextFocusElement(direction, options) {
146
+ var result = _findNextFocusElementInternal(direction, options);
147
+ return result ? result.target : null;
148
+ }
149
+ function _moveFocus(direction, options) {
150
+ var result = _findNextFocusElement(direction, options);
151
+ if (result) {
152
+ var previousFocusElement = document.activeElement;
153
+ if (_trySetFocus(result, -1)) {
154
+ eventSrc.dispatchEvent(EventNames.focusChanged, { previousFocusElement: previousFocusElement, keyCode: -1 });
155
+ return result;
156
+ }
157
+ }
158
+ return null;
159
+ }
160
+ function _mergeAll(list) {
161
+ // Merge a list of objects together
162
+ var o = {};
163
+ list.forEach(function (part) {
164
+ Object.keys(part).forEach(function (k) {
165
+ o[k] = part[k];
166
+ });
167
+ });
168
+ return o;
169
+ };
170
+ function _createEventProperty(name) {
171
+ var eventPropStateName = "_on" + name + "state";
172
+
173
+ return {
174
+ get: function () {
175
+ var state = this[eventPropStateName];
176
+ return state && state.userHandler;
177
+ },
178
+ set: function (handler) {
179
+ var state = this[eventPropStateName];
180
+ if (handler) {
181
+ if (!state) {
182
+ state = { wrapper: function (evt) { return state.userHandler(evt); }, userHandler: handler };
183
+ Object.defineProperty(this, eventPropStateName, { value: state, enumerable: false, writable: true, configurable: true });
184
+ this.addEventListener(name, state.wrapper, false);
185
+ }
186
+ state.userHandler = handler;
187
+ } else if (state) {
188
+ this.removeEventListener(name, state.wrapper, false);
189
+ this[eventPropStateName] = null;
190
+ }
191
+ },
192
+ enumerable: true
193
+ };
194
+ };
195
+ // Privates
196
+ var _lastTarget;
197
+ var _cachedLastTargetRect;
198
+ var _historyRect;
199
+ /**
200
+ * Executes XYFocus algorithm with the given parameters. Returns true if focus was moved, false otherwise.
201
+ * @param direction The direction to move focus.
202
+ * @param keyCode The key code of the pressed key.
203
+ * @param referenceRect (optional) A rectangle to use as the source coordinates for finding the next focusable element.
204
+ * @param dontExit (optional) Indicates whether this focus request is allowed to propagate to its parent if we are in iframe.
205
+ **/
206
+ function _xyFocus(direction, keyCode, referenceRect, dontExit) {
207
+ // If focus has moved since the last XYFocus movement, scrolling occured, or an explicit
208
+ // reference rectangle was given to us, then we invalidate the history rectangle.
209
+ if (referenceRect || document.activeElement !== _lastTarget) {
210
+ _historyRect = null;
211
+ _lastTarget = null;
212
+ _cachedLastTargetRect = null;
213
+ }
214
+ else if (_lastTarget && _cachedLastTargetRect) {
215
+ var lastTargetRect = _toIRect(_lastTarget.getBoundingClientRect());
216
+ // Sometimes the bounds calculation for top is off by 1 even though the element has not moved.
217
+ if (lastTargetRect.left !== _cachedLastTargetRect.left || Math.abs(lastTargetRect.top - _cachedLastTargetRect.top) > 1) {
218
+ _cachedLastTargetRect = lastTargetRect;
219
+ }
220
+ }
221
+ var activeElement = document.activeElement;
222
+ var lastTarget = _lastTarget;
223
+ var result = _findNextFocusElementInternal(direction, {
224
+ focusRoot: _focusRoot,
225
+ historyRect: _historyRect,
226
+ referenceElement: _lastTarget,
227
+ referenceRect: referenceRect
228
+ });
229
+ if (result && _trySetFocus(result.target, keyCode)) {
230
+ // A focus target was found
231
+ updateHistoryRect(direction, result);
232
+ _lastTarget = result.target;
233
+ _cachedLastTargetRect = result.targetRect;
234
+ if (result.target.tagName === "IFRAME") {
235
+ var targetIframe = result.target;
236
+ if (IFrameHelper.isXYFocusEnabled(targetIframe)) {
237
+ // If we successfully moved focus and the new focused item is an IFRAME, then we need to notify it
238
+ // Note on coordinates: When signaling enter, DO transform the coordinates into the child frame's coordinate system.
239
+ var refRect = _toIRect({
240
+ left: result.referenceRect.left - result.targetRect.left,
241
+ top: result.referenceRect.top - result.targetRect.top,
242
+ width: result.referenceRect.width,
243
+ height: result.referenceRect.height
244
+ });
245
+ var message = {};
246
+ message[CrossDomainMessageConstants.messageDataProperty] = {
247
+ type: CrossDomainMessageConstants.dFocusEnter,
248
+ direction: direction,
249
+ referenceRect: refRect
250
+ };
251
+ // postMessage API is safe even in cross-domain scenarios.
252
+ targetIframe.contentWindow.postMessage(message, "*");
253
+ }
254
+ }
255
+ else if (typeof result.target.navigateFocus === "function") {
256
+ // No need to adjust coordinate space of result.referenceRect. navigateFocus/departFocus and corresponding
257
+ // events handle the coordinate space translation.
258
+ result.target.navigateFocus(direction, WebViewHelper.refRectToNavigateFocusRect(result.referenceRect));
259
+ }
260
+ eventSrc.dispatchEvent(EventNames.focusChanged, { previousFocusElement: activeElement, keyCode: keyCode });
261
+ return true;
262
+ }
263
+ else {
264
+ // No focus target was found; if we are inside an IFRAME or webview and focus is allowed to propagate out, notify the parent that focus is exiting
265
+ // Note on coordinates: When signaling exit, do NOT transform the coordinates into the parent's coordinate system.
266
+ if ((!dontExit && top !== window) || typeof window.departFocus === "function") {
267
+ var refRect = referenceRect;
268
+ if (!refRect) {
269
+ refRect = document.activeElement ? _toIRect(document.activeElement.getBoundingClientRect()) : _defaultRect();
270
+ }
271
+ if (top === window && typeof window.departFocus === "function") {
272
+ document.activeElement.blur();
273
+ departFocus(direction, WebViewHelper.refRectToNavigateFocusRect(refRect));
274
+ }
275
+ else {
276
+ var message = {};
277
+ message[CrossDomainMessageConstants.messageDataProperty] = {
278
+ type: CrossDomainMessageConstants.dFocusExit,
279
+ direction: direction,
280
+ referenceRect: refRect
281
+ };
282
+ // postMessage API is safe even in cross-domain scenarios.
283
+ parent.postMessage(message, "*");
284
+ }
285
+ return true;
286
+ }
287
+ }
288
+ return false;
289
+ // Nested Helpers
290
+ function updateHistoryRect(direction, result) {
291
+ var newHistoryRect = _defaultRect();
292
+ // It's possible to get into a situation where the target element has no overlap with the reference edge.
293
+ //
294
+ //..╔══════════════╗..........................
295
+ //..║ reference ║..........................
296
+ //..╚══════════════╝..........................
297
+ //.....................╔═══════════════════╗..
298
+ //.....................║ ║..
299
+ //.....................║ target ║..
300
+ //.....................║ ║..
301
+ //.....................╚═══════════════════╝..
302
+ //
303
+ // If that is the case, we need to reset the coordinates to the edge of the target element.
304
+ if (direction === DirectionNames.left || direction === DirectionNames.right) {
305
+ newHistoryRect.top = Math.max(result.targetRect.top, result.referenceRect.top, _historyRect ? _historyRect.top : Number.MIN_VALUE);
306
+ newHistoryRect.bottom = Math.min(result.targetRect.bottom, result.referenceRect.bottom, _historyRect ? _historyRect.bottom : Number.MAX_VALUE);
307
+ if (newHistoryRect.bottom <= newHistoryRect.top) {
308
+ newHistoryRect.top = result.targetRect.top;
309
+ newHistoryRect.bottom = result.targetRect.bottom;
310
+ }
311
+ newHistoryRect.height = newHistoryRect.bottom - newHistoryRect.top;
312
+ newHistoryRect.width = Number.MAX_VALUE;
313
+ newHistoryRect.left = Number.MIN_VALUE;
314
+ newHistoryRect.right = Number.MAX_VALUE;
315
+ }
316
+ else {
317
+ newHistoryRect.left = Math.max(result.targetRect.left, result.referenceRect.left, _historyRect ? _historyRect.left : Number.MIN_VALUE);
318
+ newHistoryRect.right = Math.min(result.targetRect.right, result.referenceRect.right, _historyRect ? _historyRect.right : Number.MAX_VALUE);
319
+ if (newHistoryRect.right <= newHistoryRect.left) {
320
+ newHistoryRect.left = result.targetRect.left;
321
+ newHistoryRect.right = result.targetRect.right;
322
+ }
323
+ newHistoryRect.width = newHistoryRect.right - newHistoryRect.left;
324
+ newHistoryRect.height = Number.MAX_VALUE;
325
+ newHistoryRect.top = Number.MIN_VALUE;
326
+ newHistoryRect.bottom = Number.MAX_VALUE;
327
+ }
328
+ _historyRect = newHistoryRect;
329
+ }
330
+ }
331
+ function _findNextFocusElementInternal(direction, options) {
332
+ options = options || {};
333
+ options.focusRoot = options.focusRoot || _focusRoot || document.body;
334
+ options.historyRect = options.historyRect || _defaultRect();
335
+ var maxDistance = Math.max(window.screen.availHeight, window.screen.availWidth);
336
+ var refObj = getReferenceObject(options.referenceElement, options.referenceRect);
337
+ // Handle override
338
+ var refElement = refObj.element;
339
+ if (refElement) {
340
+ var overrideSelector = refElement.getAttribute("data-tv-focus-" + direction);
341
+ if (overrideSelector) {
342
+ if (overrideSelector) {
343
+ var target;
344
+ var element = refObj.element;
345
+ while (!target && element) {
346
+ target = element.querySelector(overrideSelector);
347
+ element = element.parentElement;
348
+ }
349
+ if (target) {
350
+ if (target === document.activeElement) {
351
+ return null;
352
+ }
353
+ return { target: target, targetRect: _toIRect(target.getBoundingClientRect()), referenceRect: refObj.rect, usedOverride: true };
354
+ }
355
+ }
356
+ }
357
+ }
358
+ // Calculate scores for each element in the root
359
+ var bestPotential = {
360
+ element: null,
361
+ rect: null,
362
+ score: 0
363
+ };
364
+ var allElements = options.focusRoot.querySelectorAll("*");
365
+ for (var i = 0, length = allElements.length; i < length; i++) {
366
+ var potentialElement = allElements[i];
367
+ if (refObj.element === potentialElement || !_isFocusable(potentialElement)) {
368
+ continue;
369
+ }
370
+ var potentialRect = _toIRect(potentialElement.getBoundingClientRect());
371
+ // Skip elements that have either a width of zero or a height of zero
372
+ if (potentialRect.width === 0 || potentialRect.height === 0) {
373
+ continue;
374
+ }
375
+ var score = calculateScore(direction, maxDistance, options.historyRect, refObj.rect, potentialRect);
376
+ if (score > bestPotential.score) {
377
+ bestPotential.element = potentialElement;
378
+ bestPotential.rect = potentialRect;
379
+ bestPotential.score = score;
380
+ }
381
+ }
382
+ return bestPotential.element ? { target: bestPotential.element, targetRect: bestPotential.rect, referenceRect: refObj.rect, usedOverride: false } : null;
383
+ // Nested Helpers
384
+ function calculatePercentInShadow(minReferenceCoord, maxReferenceCoord, minPotentialCoord, maxPotentialCoord) {
385
+ /// Calculates the percentage of the potential element that is in the shadow of the reference element.
386
+ if ((minReferenceCoord >= maxPotentialCoord) || (maxReferenceCoord <= minPotentialCoord)) {
387
+ // Potential is not in the reference's shadow.
388
+ return 0;
389
+ }
390
+ var pixelOverlap = Math.min(maxReferenceCoord, maxPotentialCoord) - Math.max(minReferenceCoord, minPotentialCoord);
391
+ var shortEdge = Math.min(maxPotentialCoord - minPotentialCoord, maxReferenceCoord - minReferenceCoord);
392
+ return shortEdge === 0 ? 0 : (pixelOverlap / shortEdge);
393
+ }
394
+ function calculateScore(direction, maxDistance, historyRect, referenceRect, potentialRect) {
395
+ var score = 0;
396
+ var percentInShadow;
397
+ var primaryAxisDistance;
398
+ var secondaryAxisDistance = 0;
399
+ var percentInHistoryShadow = 0;
400
+ switch (direction) {
401
+ case DirectionNames.left:
402
+ // Make sure we don't evaluate any potential elements to the right of the reference element
403
+ if (potentialRect.left >= referenceRect.left) {
404
+ break;
405
+ }
406
+ percentInShadow = calculatePercentInShadow(referenceRect.top, referenceRect.bottom, potentialRect.top, potentialRect.bottom);
407
+ primaryAxisDistance = referenceRect.left - potentialRect.right;
408
+ if (percentInShadow > 0) {
409
+ percentInHistoryShadow = calculatePercentInShadow(historyRect.top, historyRect.bottom, potentialRect.top, potentialRect.bottom);
410
+ }
411
+ else {
412
+ // If the potential element is not in the shadow, then we calculate secondary axis distance
413
+ secondaryAxisDistance = (referenceRect.bottom <= potentialRect.top) ? (potentialRect.top - referenceRect.bottom) : referenceRect.top - potentialRect.bottom;
414
+ }
415
+ break;
416
+ case DirectionNames.right:
417
+ // Make sure we don't evaluate any potential elements to the left of the reference element
418
+ if (potentialRect.right <= referenceRect.right) {
419
+ break;
420
+ }
421
+ percentInShadow = calculatePercentInShadow(referenceRect.top, referenceRect.bottom, potentialRect.top, potentialRect.bottom);
422
+ primaryAxisDistance = potentialRect.left - referenceRect.right;
423
+ if (percentInShadow > 0) {
424
+ percentInHistoryShadow = calculatePercentInShadow(historyRect.top, historyRect.bottom, potentialRect.top, potentialRect.bottom);
425
+ }
426
+ else {
427
+ // If the potential element is not in the shadow, then we calculate secondary axis distance
428
+ secondaryAxisDistance = (referenceRect.bottom <= potentialRect.top) ? (potentialRect.top - referenceRect.bottom) : referenceRect.top - potentialRect.bottom;
429
+ }
430
+ break;
431
+ case DirectionNames.up:
432
+ // Make sure we don't evaluate any potential elements below the reference element
433
+ if (potentialRect.top >= referenceRect.top) {
434
+ break;
435
+ }
436
+ percentInShadow = calculatePercentInShadow(referenceRect.left, referenceRect.right, potentialRect.left, potentialRect.right);
437
+ primaryAxisDistance = referenceRect.top - potentialRect.bottom;
438
+ if (percentInShadow > 0) {
439
+ percentInHistoryShadow = calculatePercentInShadow(historyRect.left, historyRect.right, potentialRect.left, potentialRect.right);
440
+ }
441
+ else {
442
+ // If the potential element is not in the shadow, then we calculate secondary axis distance
443
+ secondaryAxisDistance = (referenceRect.right <= potentialRect.left) ? (potentialRect.left - referenceRect.right) : referenceRect.left - potentialRect.right;
444
+ }
445
+ break;
446
+ case DirectionNames.down:
447
+ // Make sure we don't evaluate any potential elements above the reference element
448
+ if (potentialRect.bottom <= referenceRect.bottom) {
449
+ break;
450
+ }
451
+ percentInShadow = calculatePercentInShadow(referenceRect.left, referenceRect.right, potentialRect.left, potentialRect.right);
452
+ primaryAxisDistance = potentialRect.top - referenceRect.bottom;
453
+ if (percentInShadow > 0) {
454
+ percentInHistoryShadow = calculatePercentInShadow(historyRect.left, historyRect.right, potentialRect.left, potentialRect.right);
455
+ }
456
+ else {
457
+ // If the potential element is not in the shadow, then we calculate secondary axis distance
458
+ secondaryAxisDistance = (referenceRect.right <= potentialRect.left) ? (potentialRect.left - referenceRect.right) : referenceRect.left - potentialRect.right;
459
+ }
460
+ break;
461
+ }
462
+ if (primaryAxisDistance >= 0) {
463
+ // The score needs to be a positive number so we make these distances positive numbers
464
+ primaryAxisDistance = maxDistance - primaryAxisDistance;
465
+ secondaryAxisDistance = maxDistance - secondaryAxisDistance;
466
+ if (primaryAxisDistance >= 0 && secondaryAxisDistance >= 0) {
467
+ // Potential elements in the shadow get a multiplier to their final score
468
+ primaryAxisDistance += primaryAxisDistance * percentInShadow;
469
+ score = primaryAxisDistance * ScoringConstants.primaryAxisDistanceWeight + secondaryAxisDistance * ScoringConstants.secondaryAxisDistanceWeight + percentInHistoryShadow * ScoringConstants.percentInHistoryShadowWeight;
470
+ }
471
+ }
472
+ return score;
473
+ }
474
+ function getReferenceObject(referenceElement, referenceRect) {
475
+ var refElement;
476
+ var refRect;
477
+ if ((!referenceElement && !referenceRect) || (referenceElement && !referenceElement.parentNode)) {
478
+ // Note: We need to check to make sure 'parentNode' is not null otherwise there is a case
479
+ // where _lastTarget is defined, but calling getBoundingClientRect will throw a native exception.
480
+ // This case happens if the innerHTML of the parent of the _lastTarget is set to "".
481
+ // If no valid reference is supplied, we'll use document.activeElement unless it's the body
482
+ if (document.activeElement !== document.body) {
483
+ referenceElement = document.activeElement;
484
+ }
485
+ }
486
+ if (referenceElement) {
487
+ refElement = referenceElement;
488
+ refRect = _toIRect(refElement.getBoundingClientRect());
489
+ }
490
+ else if (referenceRect) {
491
+ refRect = _toIRect(referenceRect);
492
+ }
493
+ else {
494
+ refRect = _defaultRect();
495
+ }
496
+ return {
497
+ element: refElement,
498
+ rect: refRect
499
+ };
500
+ }
501
+ }
502
+ function _defaultRect() {
503
+ // We set the top, left, bottom and right properties of the referenceBoundingRectangle to '-1'
504
+ // (as opposed to '0') because we want to make sure that even elements that are up to the edge
505
+ // of the screen can receive focus.
506
+ return {
507
+ top: -1,
508
+ bottom: -1,
509
+ right: -1,
510
+ left: -1,
511
+ height: 0,
512
+ width: 0
513
+ };
514
+ }
515
+ function _toIRect(rect) {
516
+ return {
517
+ top: Math.floor(rect.top),
518
+ bottom: Math.floor(rect.top + rect.height),
519
+ right: Math.floor(rect.left + rect.width),
520
+ left: Math.floor(rect.left),
521
+ height: Math.floor(rect.height),
522
+ width: Math.floor(rect.width),
523
+ };
524
+ }
525
+ function _trySetFocus(element, keyCode) {
526
+ // We raise an event on the focusRoot before focus changes to give listeners
527
+ // a chance to prevent the next focus target from receiving focus if they want.
528
+ var canceled = eventSrc.dispatchEvent(EventNames.focusChanging, { nextFocusElement: element, keyCode: keyCode });
529
+ if (!canceled) {
530
+ element.focus();
531
+ }
532
+ return document.activeElement === element;
533
+ }
534
+ function _isFocusable(element) {
535
+ var elementTagName = element.tagName;
536
+ var tabIndex = parseInt(element.getAttribute("tabIndex"));
537
+ if (FocusableTagNames.indexOf(elementTagName) === -1 && isNaN(tabIndex)) {
538
+ // Loop through the selectors
539
+ var matchesSelector = false;
540
+ for (var i = 0, len = FocusableSelectors.length; i < len; i++) {
541
+ if (_matchesSelector(element, FocusableSelectors[i])) {
542
+ if (isNaN(tabIndex)) {
543
+ element.setAttribute("tabIndex", 0);
544
+ }
545
+ matchesSelector = true;
546
+ break;
547
+ }
548
+ }
549
+ // If the current potential element is not one of the tags we consider to be focusable, then exit
550
+ if (!matchesSelector) {
551
+ return false;
552
+ }
553
+ }
554
+ if (elementTagName === "IFRAME" && !IFrameHelper.isXYFocusEnabled(element)) {
555
+ // Skip IFRAMEs without compatible XYFocus implementation
556
+ return false;
557
+ }
558
+ if (elementTagName === "DIV" && element["winControl"] && element["winControl"].disabled) {
559
+ // Skip disabled WinJS controls
560
+ return false;
561
+ }
562
+
563
+ var style = window.getComputedStyle(element);
564
+ if (style && tabIndex === -1 || style.display === "none" || style.visibility === "hidden" || element.disabled) {
565
+ // Skip elements that are hidden
566
+ // Note: We don't check for opacity === 0, because the browser cannot tell us this value accurately.
567
+ return false;
568
+ }
569
+ return true;
570
+ };
571
+ function _matchesSelector(element, selectorString) {
572
+ var matchesSelector = element.matches
573
+ || element.msMatchesSelector
574
+ || element.mozMatchesSelector
575
+ || element.webkitMatchesSelector;
576
+ return matchesSelector.call(element, selectorString);
577
+ };
578
+ function _handleKeyDownEvent(e) {
579
+ if (e.defaultPrevented) {
580
+ return;
581
+ }
582
+ var direction = "";
583
+ var keyCode = e.keyCode;
584
+ if (_keyCodeMap.up.indexOf(keyCode) !== -1) {
585
+ direction = "up";
586
+ }
587
+ else if (_keyCodeMap.down.indexOf(keyCode) !== -1) {
588
+ direction = "down";
589
+ }
590
+ else if (_keyCodeMap.left.indexOf(keyCode) !== -1) {
591
+ direction = "left";
592
+ }
593
+ else if (_keyCodeMap.right.indexOf(keyCode) !== -1) {
594
+ direction = "right";
595
+ }
596
+ if (direction && _enabled) {
597
+ var shouldPreventDefault = _xyFocus(direction, keyCode);
598
+ if (shouldPreventDefault) {
599
+ e.preventDefault();
600
+ }
601
+ }
602
+ };
603
+ function _handleKeyUpEvent(e) {
604
+ if (e.defaultPrevented) {
605
+ return;
606
+ }
607
+ if (_keyCodeMap.accept.indexOf(e.keyCode) !== -1) {
608
+ e.srcElement.click();
609
+ }
610
+ };
611
+
612
+ var WebViewHelper;
613
+ (function (WebViewHelper) {
614
+ function refRectToNavigateFocusRect(refRect) {
615
+ return {
616
+ originLeft: refRect.left,
617
+ originTop: refRect.top,
618
+ originWidth: refRect.width,
619
+ originHeight: refRect.height
620
+ };
621
+ }
622
+ WebViewHelper.refRectToNavigateFocusRect = refRectToNavigateFocusRect;
623
+
624
+ function navigateFocusRectToRefRect(navigateFocusRect) {
625
+ return _toIRect({
626
+ left: navigateFocusRect.originLeft,
627
+ top: navigateFocusRect.originTop,
628
+ width: navigateFocusRect.originWidth,
629
+ height: navigateFocusRect.originHeight
630
+ });
631
+ }
632
+ WebViewHelper.navigateFocusRectToRefRect = navigateFocusRectToRefRect;
633
+ })(WebViewHelper || (WebViewHelper = {}));
634
+
635
+ var IFrameHelper;
636
+ (function (IFrameHelper) {
637
+ // XYFocus caches registered iframes and iterates over the cache for its focus navigation implementation.
638
+ // However, since there is no reliable way for an iframe to unregister with its parent as it can be
639
+ // spontaneously taken out of the DOM, the cache can go stale. This helper module makes sure that on
640
+ // every query to the iframe cache, stale iframes are removed.
641
+ // Furthermore, merely accessing an iframe that has been garbage collected by the platform will cause an
642
+ // exception so each iteration during a query must be in a try/catch block.
643
+ var iframes = [];
644
+ function count() {
645
+ // Iterating over it causes stale iframes to be cleared from the cache.
646
+ _safeForEach(function () { return false; });
647
+ return iframes.length;
648
+ }
649
+ IFrameHelper.count = count;
650
+ function getIFrameFromWindow(win) {
651
+ var iframes = document.querySelectorAll("IFRAME");
652
+ var found = Array.prototype.filter.call(iframes, function (x) { return x.contentWindow === win; });
653
+ return found.length ? found[0] : null;
654
+ }
655
+ IFrameHelper.getIFrameFromWindow = getIFrameFromWindow;
656
+ function isXYFocusEnabled(iframe) {
657
+ var found = false;
658
+ _safeForEach(function (ifr) {
659
+ if (ifr === iframe) {
660
+ found = true;
661
+ }
662
+ });
663
+ return found;
664
+ }
665
+ IFrameHelper.isXYFocusEnabled = isXYFocusEnabled;
666
+ function registerIFrame(iframe) {
667
+ iframes.push(iframe);
668
+ };
669
+ IFrameHelper.registerIFrame = registerIFrame;
670
+ function unregisterIFrame(iframe) {
671
+ var index = -1;
672
+ _safeForEach(function (ifr, i) {
673
+ if (ifr === iframe) {
674
+ index = i;
675
+ }
676
+ });
677
+ if (index !== -1) {
678
+ iframes.splice(index, 1);
679
+ }
680
+ };
681
+ IFrameHelper.unregisterIFrame = unregisterIFrame;
682
+ function _safeForEach(callback) {
683
+ for (var i = iframes.length - 1; i >= 0; i--) {
684
+ try {
685
+ var iframe = iframes[i];
686
+ if (!iframe.contentWindow) {
687
+ iframes.splice(i, 1);
688
+ }
689
+ else {
690
+ callback(iframe, i);
691
+ }
692
+ }
693
+ catch (e) {
694
+ // Iframe has been GC'd
695
+ iframes.splice(i, 1);
696
+ }
697
+ }
698
+ };
699
+ })(IFrameHelper || (IFrameHelper = {}));
700
+
701
+ // Default mappings
702
+ _keyCodeMap.left.push(
703
+ 37, // LeftArrow
704
+ 214, // GamepadLeftThumbstickLeft
705
+ 205, // GamepadDPadLeft
706
+ 140); // NavigationLeft
707
+ _keyCodeMap.right.push(
708
+ 39, // RightArrow
709
+ 213, // GamepadLeftThumbstickRight
710
+ 206, // GamepadDPadRight
711
+ 141); // NavigationRight
712
+ _keyCodeMap.up.push(
713
+ 38, // UpArrow
714
+ 211, // GamepadLeftThumbstickUp
715
+ 203, // GamepadDPadUp
716
+ 138); // NavigationUp
717
+ _keyCodeMap.down.push(
718
+ 40, // UpArrow
719
+ 212, // GamepadLeftThumbstickDown
720
+ 204, // GamepadDPadDown
721
+ 139); // NavigationDown
722
+ _keyCodeMap.accept.push(
723
+ 142, // NavigationAccept
724
+ 195); // GamepadA
725
+ window.addEventListener("message", function (e) {
726
+ // Note: e.source is the Window object of an iframe which could be hosting content
727
+ // from a different domain. No properties on e.source should be accessed or we may
728
+ // run into a cross-domain access violation exception.
729
+ var sourceWindow = null;
730
+ try {
731
+ // Since messages are async, by the time we get this message, the iframe could've
732
+ // been removed from the DOM and e.source is null or throws an exception on access.
733
+ sourceWindow = e.source;
734
+ if (!sourceWindow) {
735
+ return;
736
+ }
737
+ }
738
+ catch (e) {
739
+ return;
740
+ }
741
+ if (!e.data || !e.data[CrossDomainMessageConstants.messageDataProperty]) {
742
+ return;
743
+ }
744
+ var data = e.data[CrossDomainMessageConstants.messageDataProperty];
745
+ switch (data.type) {
746
+ case CrossDomainMessageConstants.register:
747
+ var iframe = IFrameHelper.getIFrameFromWindow(sourceWindow);
748
+ iframe && IFrameHelper.registerIFrame(iframe);
749
+ break;
750
+ case CrossDomainMessageConstants.unregister:
751
+ var iframe = IFrameHelper.getIFrameFromWindow(sourceWindow);
752
+ iframe && IFrameHelper.unregisterIFrame(iframe);
753
+ break;
754
+ case CrossDomainMessageConstants.dFocusEnter:
755
+ // The coordinates stored in data.refRect are already in this frame's coordinate system.
756
+ // First try to focus anything within this iframe without leaving the current frame.
757
+ var focused = _xyFocus(data.direction, -1, data.referenceRect, true);
758
+ if (!focused) {
759
+ // No focusable element was found, we'll focus document.body if it is focusable.
760
+ if (_isFocusable(document.body)) {
761
+ document.body.focus();
762
+ }
763
+ else {
764
+ // Nothing within this iframe is focusable, we call _xyFocus again without a refRect
765
+ // and allow the request to propagate to the parent.
766
+ _xyFocus(data.direction, -1);
767
+ }
768
+ }
769
+ break;
770
+ case CrossDomainMessageConstants.dFocusExit:
771
+ var iframe = IFrameHelper.getIFrameFromWindow(sourceWindow);
772
+ if (document.activeElement !== iframe) {
773
+ break;
774
+ }
775
+ // The coordinates stored in data.refRect are in the IFRAME's coordinate system,
776
+ // so we must first transform them into this frame's coordinate system.
777
+ var refRect = data.referenceRect;
778
+ var iframeRect = iframe.getBoundingClientRect();
779
+ refRect.left += iframeRect.left;
780
+ refRect.top += iframeRect.top;
781
+ if (typeof refRect.right === "number") {
782
+ refRect.right += iframeRect.left;
783
+ }
784
+ if (typeof refRect.bottom === "number") {
785
+ refRect.bottom += iframeRect.top;
786
+ }
787
+ _xyFocus(data.direction, -1, refRect);
788
+ break;
789
+ }
790
+ });
791
+
792
+ // Receiving departingFocus event in the app as a result of any child webview calling
793
+ // window.departFocus from within the webview. Indicates focus transitioning into the app
794
+ // from the webview. The navigatingfocus event handles transforming the
795
+ // coordinate space so we just pass the values along.
796
+ document.addEventListener("departingfocus", function (eventArg) {
797
+ var focusChanged = _xyFocus(
798
+ eventArg.navigationReason,
799
+ -1,
800
+ WebViewHelper.navigateFocusRectToRefRect(eventArg));
801
+
802
+ if (focusChanged && eventArg && (typeof eventArg.focus === "function")) {
803
+ eventArg.focus();
804
+ }
805
+ });
806
+
807
+ // Receiving a navigatingfocus event in the webview as a result of the host app calling
808
+ // webview.navigateFocus on our containing webview element indicating focus transitioning
809
+ // into the webview from the app. The navigatingfocus event handles transforming the
810
+ // coordinate space so we just pass the values along.
811
+ window.addEventListener("navigatingfocus", function (eventArg) {
812
+ var focusChanged = _xyFocus(
813
+ eventArg.navigationReason,
814
+ -1,
815
+ WebViewHelper.navigateFocusRectToRefRect(eventArg));
816
+
817
+ if (focusChanged && eventArg && (typeof eventArg.focus === "function")) {
818
+ eventArg.focus();
819
+ }
820
+ });
821
+
822
+ var _initRun = false;
823
+ var _init = function () {
824
+ if (_initRun) {
825
+ return;
826
+ }
827
+ _initRun = true;
828
+ // Subscribe on bubble phase to allow developers to override XYFocus behaviors for directional keys.
829
+ document.addEventListener("keydown", _handleKeyDownEvent);
830
+ document.addEventListener("keyup", _handleKeyUpEvent);
831
+ // If we are running within an iframe, we send a registration message to the parent window
832
+ if (window.top !== window.window) {
833
+ var message = {};
834
+ message[CrossDomainMessageConstants.messageDataProperty] = {
835
+ type: CrossDomainMessageConstants.register,
836
+ version: 1.0
837
+ };
838
+ window.parent.postMessage(message, "*");
839
+ }
840
+ }
841
+
842
+ document.addEventListener("DOMContentLoaded", function () {
843
+ _init();
844
+ });
845
+
846
+ var EventMixinEvent = (function () {
847
+ function EventMixinEvent(type, detail, target) {
848
+ this.detail = detail;
849
+ this.target = target;
850
+ this.timeStamp = Date.now();
851
+ this.type = type;
852
+ this.bubbles = { value: false, writable: false };
853
+ this.cancelable = { value: false, writable: false };
854
+ this.trusted = { value: false, writable: false };
855
+ this.eventPhase = { value: 0, writable: false };
856
+ this.supportedForProcessing = true;
857
+ };
858
+ Object.defineProperty(EventMixinEvent.prototype, "currentTarget", {
859
+ get: function () { return this.target; },
860
+ enumerable: true,
861
+ configurable: true
862
+ });
863
+ Object.defineProperty(EventMixinEvent.prototype, "defaultPrevented", {
864
+ get: function () { return this._preventDefaultCalled; },
865
+ enumerable: true,
866
+ configurable: true
867
+ });
868
+ EventMixinEvent.prototype.preventDefault = function () {
869
+ this._preventDefaultCalled = true;
870
+ };
871
+ EventMixinEvent.prototype.stopImmediatePropagation = function () {
872
+ this._stopImmediatePropagationCalled = true;
873
+ };
874
+ EventMixinEvent.prototype.stopPropagation = function () {
875
+ };
876
+ return EventMixinEvent;
877
+ })();
878
+
879
+ var eventMixin = {
880
+ _listeners: null,
881
+
882
+ addEventListener: function (type, listener, useCapture) {
883
+ /// <signature helpKeyword="WinJS.Utilities.eventMixin.addEventListener">
884
+ /// <summary locid="WinJS.Utilities.eventMixin.addEventListener">
885
+ /// Adds an event listener to the control.
886
+ /// </summary>
887
+ /// <param name="type" locid="WinJS.Utilities.eventMixin.addEventListener_p:type">
888
+ /// The type (name) of the event.
889
+ /// </param>
890
+ /// <param name="listener" locid="WinJS.Utilities.eventMixin.addEventListener_p:listener">
891
+ /// The listener to invoke when the event is raised.
892
+ /// </param>
893
+ /// <param name="useCapture" locid="WinJS.Utilities.eventMixin.addEventListener_p:useCapture">
894
+ /// if true initiates capture, otherwise false.
895
+ /// </param>
896
+ /// </signature>
897
+ useCapture = useCapture || false;
898
+ this._listeners = this._listeners || {};
899
+ var eventListeners = (this._listeners[type] = this._listeners[type] || []);
900
+ for (var i = 0, len = eventListeners.length; i < len; i++) {
901
+ var l = eventListeners[i];
902
+ if (l.useCapture === useCapture && l.listener === listener) {
903
+ return;
904
+ }
905
+ }
906
+ eventListeners.push({ listener: listener, useCapture: useCapture });
907
+ },
908
+ dispatchEvent: function (type, details) {
909
+ /// <signature helpKeyword="WinJS.Utilities.eventMixin.dispatchEvent">
910
+ /// <summary locid="WinJS.Utilities.eventMixin.dispatchEvent">
911
+ /// Raises an event of the specified type and with the specified additional properties.
912
+ /// </summary>
913
+ /// <param name="type" locid="WinJS.Utilities.eventMixin.dispatchEvent_p:type">
914
+ /// The type (name) of the event.
915
+ /// </param>
916
+ /// <param name="details" locid="WinJS.Utilities.eventMixin.dispatchEvent_p:details">
917
+ /// The set of additional properties to be attached to the event object when the event is raised.
918
+ /// </param>
919
+ /// <returns type="Boolean" locid="WinJS.Utilities.eventMixin.dispatchEvent_returnValue">
920
+ /// true if preventDefault was called on the event.
921
+ /// </returns>
922
+ /// </signature>
923
+ var listeners = this._listeners && this._listeners[type];
924
+ if (listeners) {
925
+ var eventValue = new EventMixinEvent(type, details, this);
926
+ // Need to copy the array to protect against people unregistering while we are dispatching
927
+ listeners = listeners.slice(0, listeners.length);
928
+ for (var i = 0, len = listeners.length; i < len && !eventValue._stopImmediatePropagationCalled; i++) {
929
+ listeners[i].listener(eventValue);
930
+ }
931
+ return eventValue.defaultPrevented || false;
932
+ }
933
+ return false;
934
+ },
935
+ removeEventListener: function (type, listener, useCapture) {
936
+ /// <signature helpKeyword="WinJS.Utilities.eventMixin.removeEventListener">
937
+ /// <summary locid="WinJS.Utilities.eventMixin.removeEventListener">
938
+ /// Removes an event listener from the control.
939
+ /// </summary>
940
+ /// <param name="type" locid="WinJS.Utilities.eventMixin.removeEventListener_p:type">
941
+ /// The type (name) of the event.
942
+ /// </param>
943
+ /// <param name="listener" locid="WinJS.Utilities.eventMixin.removeEventListener_p:listener">
944
+ /// The listener to remove.
945
+ /// </param>
946
+ /// <param name="useCapture" locid="WinJS.Utilities.eventMixin.removeEventListener_p:useCapture">
947
+ /// Specifies whether to initiate capture.
948
+ /// </param>
949
+ /// </signature>
950
+ useCapture = useCapture || false;
951
+ var listeners = this._listeners && this._listeners[type];
952
+ if (listeners) {
953
+ for (var i = 0, len = listeners.length; i < len; i++) {
954
+ var l = listeners[i];
955
+ if (l.listener === listener && l.useCapture === useCapture) {
956
+ listeners.splice(i, 1);
957
+ if (listeners.length === 0) {
958
+ delete this._listeners[type];
959
+ }
960
+ // Only want to remove one element for each call to removeEventListener
961
+ break;
962
+ }
963
+ }
964
+ }
965
+ }
966
+ };
967
+ // Publish to WinJS namespace
968
+ var toPublish = {
969
+ init: _init,
970
+ findNextFocusElement: _findNextFocusElement,
971
+ keyCodeMap: _keyCodeMap,
972
+ focusableSelectors: FocusableSelectors,
973
+ moveFocus: _moveFocus,
974
+ onfocuschanged: _createEventProperty(EventNames.focusChanged),
975
+ onfocuschanging: _createEventProperty(EventNames.focusChanging),
976
+ _xyFocus: _xyFocus,
977
+ _handleKeyDownEvent: _handleKeyDownEvent,
978
+ _handleKeyUpEvent: _handleKeyUpEvent,
979
+ _iframeHelper: IFrameHelper
980
+ };
981
+ toPublish = _mergeAll([toPublish, eventMixin]);
982
+ toPublish["_listeners"] = {};
983
+ var eventSrc = toPublish;
984
+ window.TVJS = window.TVJS || {};
985
+ TVJS.DirectionalNavigation = toPublish;
986
+ Object.defineProperty(window.TVJS.DirectionalNavigation, "enabled", {
987
+ get: function () {
988
+ return _enabled;
989
+ },
990
+ set: function (value) {
991
+ _enabled = value;
992
+ },
993
+ enumerable: true,
994
+ configurable: true
995
+ });
996
+ Object.defineProperty(window.TVJS.DirectionalNavigation, "focusRoot", {
997
+ get: function () {
998
+ return _focusRoot;
999
+ },
1000
+ set: function (value) {
1001
+ _focusRoot = value;
1002
+ },
1003
+ enumerable: true,
1004
+ configurable: true
1005
+ });
1006
+
1007
+ // The gamepadInputEmulation is a string property that exists in JavaScript UWAs and in WebViews in UWAs.
1008
+ // It won't exist in Win8.1 style apps or browsers.
1009
+ if (window.navigator && typeof window.navigator.gamepadInputEmulation === "string") {
1010
+ // We want the gamepad to provide gamepad VK keyboard events rather than moving a
1011
+ // mouse like cursor. Set to "keyboard", the gamepad will provide such keyboard events
1012
+ // and provide input to the DOM navigator.getGamepads API.
1013
+ window.navigator.gamepadInputEmulation = "keyboard";
1014
+ }
1015
+ })();