@24i/bigscreen-sdk 1.1.0 → 2.1.1-alpha.2133

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 (256) hide show
  1. package/README.md +1 -1
  2. package/package.json +34 -53
  3. package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +9 -9
  4. package/packages/async-image/src/AsyncImage.tsx +10 -15
  5. package/packages/developer-tools/PlayerDebugWindow/README.md +1 -1
  6. package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsList.tsx +0 -11
  7. package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +5 -5
  8. package/packages/developer-tools/src/PlayerDebugWindow/constants.ts +0 -15
  9. package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +1 -2
  10. package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +3 -34
  11. package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +0 -4
  12. package/packages/developer-tools/src/TechnicalInfo/translations.ts +0 -4
  13. package/packages/device/src/getKeyDigit.ts +2 -2
  14. package/packages/device/src/resolver/resolver.ts +5 -18
  15. package/packages/digital-clock/src/DigitalClock.tsx +4 -15
  16. package/packages/driver-androidtv/src/DeviceAndroidTV.ts +9 -54
  17. package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +5 -29
  18. package/packages/driver-androidtv/src/keymap.ts +0 -18
  19. package/packages/driver-androidtv/src/types.ts +16 -102
  20. package/packages/driver-base/src/DeviceBase.ts +2 -61
  21. package/packages/driver-base/src/KeyMap/Key.ts +1 -8
  22. package/packages/driver-base/src/KeyMap/KeyMap.ts +0 -4
  23. package/packages/driver-base/src/KeyMap/interface.ts +0 -1
  24. package/packages/driver-base/src/KeyMap/overrideValues.ts +1 -2
  25. package/packages/driver-base/src/__mocks__/keyMap.ts +0 -1
  26. package/packages/driver-base/src/types/DeviceEvent.ts +0 -2
  27. package/packages/driver-base/src/types/KeycodeKeyMap.ts +0 -1
  28. package/packages/driver-browser/src/keymap.ts +0 -8
  29. package/packages/driver-entone/src/keymap.ts +0 -1
  30. package/packages/driver-tizen/src/TizenKeys.ts +0 -2
  31. package/packages/driver-vidaa/src/DeviceVidaa.ts +2 -3
  32. package/packages/driver-vidaa/src/__mocks__/vidaa.ts +1 -1
  33. package/packages/driver-vidaa/src/keymap.ts +0 -2
  34. package/packages/driver-webos/src/DeviceWebos.ts +0 -8
  35. package/packages/driver-webos/src/keymap.ts +1 -2
  36. package/packages/driver-xbox/src/keymap.ts +1 -1
  37. package/packages/epg/README.md +1 -3
  38. package/packages/epg/src/v2/Cell.tsx +2 -16
  39. package/packages/epg/src/v2/DataManager.ts +41 -112
  40. package/packages/epg/src/v2/DatePicker.tsx +3 -9
  41. package/packages/epg/src/v2/DateToast/DateToast.tsx +9 -12
  42. package/packages/epg/src/v2/Day.tsx +3 -6
  43. package/packages/epg/src/v2/Epg.tsx +5 -5
  44. package/packages/epg/src/v2/MockGenerator/generator.ts +2 -3
  45. package/packages/epg/src/v2/ProgramInfo/utils.ts +3 -4
  46. package/packages/epg/src/v2/Row.tsx +1 -3
  47. package/packages/epg/src/v2/TimelineSection.tsx +1 -4
  48. package/packages/epg/src/v2/basic/CellsManager.tsx +2 -7
  49. package/packages/epg/src/v2/basic/RowsManager.tsx +1 -3
  50. package/packages/epg/src/v2/interface.ts +0 -13
  51. package/packages/events-manager/src/EventsManager.ts +56 -1
  52. package/packages/focus/README.md +0 -33
  53. package/packages/focus/src/IFocusable.ts +0 -1
  54. package/packages/focus/src/Layout/Base.tsx +6 -41
  55. package/packages/focus/src/Layout/Matrix.tsx +19 -51
  56. package/packages/focus/src/Layout/__test__/Base.spec.ts +180 -0
  57. package/packages/focus/src/Layout/__test__/Horizontal.spec.ts +94 -0
  58. package/packages/focus/src/Layout/__test__/Matrix.spec.ts +261 -0
  59. package/packages/focus/src/Layout/__test__/Vertical.spec.ts +46 -0
  60. package/packages/focus/src/Layout/__test__/isRtl.spec.ts +23 -0
  61. package/packages/focus/src/Layout/__test__/shared.ts +19 -0
  62. package/packages/focus/src/focusFirstExisting.ts +1 -7
  63. package/packages/focus/src/index.ts +1 -2
  64. package/packages/gallup/src/Gallup.ts +3 -3
  65. package/packages/grid/src/Base/Base.tsx +10 -15
  66. package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +2 -4
  67. package/packages/icon/src/Icon.tsx +5 -27
  68. package/packages/input/README.md +1 -4
  69. package/packages/input/src/Input.tsx +29 -65
  70. package/packages/input/src/handleOverflow.ts +29 -0
  71. package/packages/interactable/README.md +1 -2
  72. package/packages/interactable/src/Interactable.tsx +3 -9
  73. package/packages/interactable/src/interface.ts +0 -1
  74. package/packages/jsx/src/index.ts +1 -1
  75. package/packages/jsx/src/test-utils/index.ts +0 -1
  76. package/packages/keyboard/src/Backdrop/Backdrop.scss +0 -2
  77. package/packages/keyboard/src/KeyboardBase.tsx +4 -16
  78. package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +0 -4
  79. package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +20 -28
  80. package/packages/keyboard/src/WhitelabelKeyboard/_sizes.1080.scss +0 -1
  81. package/packages/keyboard/src/WhitelabelKeyboard/_sizes.scss +0 -1
  82. package/packages/keyboard/src/WhitelabelKeyboard/layouts/index.ts +0 -11
  83. package/packages/keyboard/src/WhitelabelKeyboard/types.ts +0 -1
  84. package/packages/l10n/README.md +0 -18
  85. package/packages/l10n/src/date/common.ts +6 -18
  86. package/packages/l10n/src/date/cs.ts +8 -2
  87. package/packages/l10n/src/date/en-001.ts +3 -3
  88. package/packages/l10n/src/date/en-common.ts +4 -5
  89. package/packages/l10n/src/date/en-us.ts +3 -3
  90. package/packages/l10n/src/date/iso.ts +13 -12
  91. package/packages/l10n/src/date/types.ts +0 -9
  92. package/packages/l10n/src/l10n.ts +3 -61
  93. package/packages/list/src/Base/Base.tsx +9 -19
  94. package/packages/list/src/Base/interface.ts +2 -2
  95. package/packages/list/src/CenteredList/controller.ts +1 -0
  96. package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +3 -3
  97. package/packages/list/src/UnifiedListController/UnifiedListController.ts +2 -6
  98. package/packages/logger/src/loggers/SentryLogger/Sentry.ts +0 -1
  99. package/packages/logger/src/loggers/SentryLogger/SentryLogger.ts +2 -2
  100. package/packages/menu/src/MenuAndContentContainer/MenuAndContentContainer.tsx +3 -31
  101. package/packages/menu/src/MenuAndContentContainer/interface.ts +0 -8
  102. package/packages/modal-service/README.md +1 -4
  103. package/packages/modal-service/src/ModalService.tsx +5 -29
  104. package/packages/perf-utils/README.md +120 -1
  105. package/packages/perf-utils/src/array/filter.ts +54 -1
  106. package/packages/perf-utils/src/array/find.ts +43 -1
  107. package/packages/perf-utils/src/array/findIndex.ts +43 -1
  108. package/packages/perf-utils/src/array/forEach.ts +48 -1
  109. package/packages/perf-utils/src/array/includes.ts +41 -1
  110. package/packages/perf-utils/src/array/includesNaN.ts +32 -1
  111. package/packages/perf-utils/src/array/index.ts +7 -1
  112. package/packages/perf-utils/src/array/map.ts +52 -1
  113. package/packages/player-ui/README.md +1 -1
  114. package/packages/player-ui/src/CurrentTime.tsx +2 -2
  115. package/packages/player-ui/src/Duration.tsx +2 -2
  116. package/packages/player-ui/src/PauseButton.tsx +0 -8
  117. package/packages/player-ui/src/PlayerInteractable.tsx +0 -1
  118. package/packages/player-ui/src/PlayerTime.tsx +1 -3
  119. package/packages/player-ui/src/PlayerUI.tsx +35 -68
  120. package/packages/player-ui/src/RemainingTime.tsx +2 -2
  121. package/packages/player-ui/src/Seekbar.tsx +18 -110
  122. package/packages/player-ui/src/Seeking.ts +16 -57
  123. package/packages/player-ui/src/Subtitles.tsx +2 -2
  124. package/packages/player-ui/src/index.ts +0 -1
  125. package/packages/player-ui/src/mocks.ts +8 -32
  126. package/packages/player-ui/src/timeUtils.ts +3 -3
  127. package/packages/player-ui/src/types.ts +3 -9
  128. package/packages/router/src/Route.tsx +27 -61
  129. package/packages/router/src/Router.tsx +13 -59
  130. package/packages/router/src/history.ts +1 -8
  131. package/packages/router/src/index.ts +1 -1
  132. package/packages/router/src/utils.ts +4 -9
  133. package/packages/sass-utils/src/linear-gradient.scss +4 -9
  134. package/packages/sass-utils/src/scale.1080.scss +1 -3
  135. package/packages/sass-utils/src/scale.720.scss +1 -1
  136. package/packages/time/README.md +1 -4
  137. package/packages/time/src/Time.ts +13 -35
  138. package/packages/time/src/constants.ts +0 -1
  139. package/packages/toast/src/ToastService.tsx +5 -16
  140. package/packages/types-bigscreen-jsx/README.md +4 -5
  141. package/packages/types-bigscreen-jsx/index.d.ts +67 -72
  142. package/packages/utils/README.md +0 -27
  143. package/packages/utils/src/elementUtils.ts +0 -25
  144. package/packages/utils/src/index.ts +0 -8
  145. package/packages/utils/src/scaledImage.ts +3 -6
  146. package/packages/utils/src/textUtils.ts +14 -46
  147. package/packages/utils/src/wait.ts +1 -3
  148. package/packages/utils/src/xhr/xhrSend.ts +1 -3
  149. package/packages/utils/src/xhr/xhrSendRetry.ts +1 -3
  150. package/packages/zapping/src/ChannelZapping.ts +0 -9
  151. package/packages/zapping/src/Zapping.tsx +0 -10
  152. package/.vscode/settings.json +0 -6
  153. package/packages/analytics/README.md +0 -8
  154. package/packages/analytics/src/A.ts +0 -1
  155. package/packages/analytics/src/Analytics.ts +0 -1
  156. package/packages/analytics/src/analyticsOnScroll.ts +0 -1
  157. package/packages/analytics/src/clients/ConsoleAnalytics/ConsoleAnalytics.ts +0 -1
  158. package/packages/analytics/src/clients/ConsoleAnalytics/index.ts +0 -1
  159. package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +0 -200
  160. package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +0 -118
  161. package/packages/analytics/src/clients/GoogleAnalytics/getUrl.ts +0 -17
  162. package/packages/analytics/src/clients/GoogleAnalytics/index.ts +0 -2
  163. package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +0 -77
  164. package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +0 -50
  165. package/packages/analytics/src/clients/GoogleAnalytics/prepareBody.ts +0 -14
  166. package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +0 -169
  167. package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +0 -102
  168. package/packages/analytics/src/clients/TealiumAnalytics/findIdForLanguage.ts +0 -9
  169. package/packages/analytics/src/clients/TealiumAnalytics/index.ts +0 -4
  170. package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +0 -33
  171. package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +0 -70
  172. package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +0 -36
  173. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +0 -13
  174. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteAdd.ts +0 -11
  175. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteRemove.ts +0 -11
  176. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +0 -15
  177. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +0 -15
  178. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSceneView.ts +0 -18
  179. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +0 -18
  180. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +0 -8
  181. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +0 -8
  182. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +0 -15
  183. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +0 -18
  184. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +0 -15
  185. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +0 -15
  186. package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +0 -15
  187. package/packages/analytics/src/clients/TealiumAnalytics/types.ts +0 -156
  188. package/packages/analytics/src/clients/TwentyFourIQ/TwentyFourIQClient.ts +0 -116
  189. package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +0 -99
  190. package/packages/analytics/src/clients/TwentyFourIQ/helper.ts +0 -34
  191. package/packages/analytics/src/clients/TwentyFourIQ/index.ts +0 -2
  192. package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +0 -31
  193. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdLoaded.ts +0 -13
  194. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdSkipped.ts +0 -16
  195. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBase.ts +0 -21
  196. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBuffering.ts +0 -15
  197. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerClose.ts +0 -24
  198. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerOpen.ts +0 -18
  199. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapSceneView.ts +0 -15
  200. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapScroll.ts +0 -17
  201. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoComplete.ts +0 -21
  202. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoPause.ts +0 -24
  203. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoProgress.ts +0 -24
  204. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStart.ts +0 -34
  205. package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStop.ts +0 -32
  206. package/packages/analytics/src/clients/TwentyFourIQ/types.ts +0 -115
  207. package/packages/analytics/src/constants.ts +0 -1
  208. package/packages/analytics/src/index.ts +0 -3
  209. package/packages/analytics/src/interface.ts +0 -1
  210. package/packages/analytics/src/utils/generateSessionId.ts +0 -8
  211. package/packages/create-package/dist/createPackage.js +0 -66
  212. package/packages/create-package/dist/createPackage.js.map +0 -1
  213. package/packages/create-package/dist/index.js +0 -5
  214. package/packages/create-package/dist/index.js.map +0 -1
  215. package/packages/create-package/dist/questionnaire/questions.js +0 -35
  216. package/packages/create-package/dist/questionnaire/questions.js.map +0 -1
  217. package/packages/create-package/dist/settings/Settings.js +0 -10
  218. package/packages/create-package/dist/settings/Settings.js.map +0 -1
  219. package/packages/create-package/dist/types.js +0 -3
  220. package/packages/create-package/dist/types.js.map +0 -1
  221. package/packages/device/src/driver/index.firetv.ts +0 -1
  222. package/packages/device/src/driver/index.smartcast.tv.ts +0 -1
  223. package/packages/driver-firetv/src/DeviceFireTV.ts +0 -18
  224. package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +0 -36
  225. package/packages/driver-firetv/src/index.ts +0 -1
  226. package/packages/driver-smartcast/src/DeviceSmartCast.ts +0 -317
  227. package/packages/driver-smartcast/src/__mocks__/api.ts +0 -49
  228. package/packages/driver-smartcast/src/index.ts +0 -1
  229. package/packages/driver-smartcast/src/keymap.ts +0 -9
  230. package/packages/driver-smartcast/src/types.ts +0 -65
  231. package/packages/focus/src/hasFocus.ts +0 -36
  232. package/packages/input/src/utils.ts +0 -71
  233. package/packages/jsx/src/test-utils/keyup.ts +0 -27
  234. package/packages/keyboard/src/WhitelabelKeyboard/layouts/arabic.ts +0 -27
  235. package/packages/keyboard/src/WhitelabelKeyboard/layouts/burmese.ts +0 -27
  236. package/packages/keyboard/src/WhitelabelKeyboard/layouts/dari.ts +0 -28
  237. package/packages/keyboard/src/WhitelabelKeyboard/layouts/korean.ts +0 -26
  238. package/packages/keyboard/src/WhitelabelKeyboard/layouts/pashto.ts +0 -27
  239. package/packages/keyboard/src/WhitelabelKeyboard/layouts/persian.ts +0 -27
  240. package/packages/keyboard/src/WhitelabelKeyboard/layouts/russian.ts +0 -27
  241. package/packages/keyboard/src/WhitelabelKeyboard/layouts/tibetan.ts +0 -26
  242. package/packages/keyboard/src/WhitelabelKeyboard/layouts/turkish.ts +0 -26
  243. package/packages/keyboard/src/WhitelabelKeyboard/layouts/ukrainian.ts +0 -27
  244. package/packages/keyboard/src/WhitelabelKeyboard/layouts/urdu.ts +0 -26
  245. package/packages/l10n/src/date/de.ts +0 -97
  246. package/packages/l10n/src/date/es.ts +0 -71
  247. package/packages/l10n/src/date/fr.ts +0 -94
  248. package/packages/l10n/src/date/he.ts +0 -101
  249. package/packages/time/src/adapters/24iMediaTimeApi.ts +0 -47
  250. package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +0 -43
  251. package/packages/time/src/services/24iMediaTimeApi/index.ts +0 -6
  252. package/packages/utils/src/forceReflow.ts +0 -14
  253. package/packages/utils/src/keyPress/index.ts +0 -6
  254. package/packages/utils/src/keyPress/keyPressSimulator.ts +0 -74
  255. package/packages/utils/src/keyPress/simulateKeyPress.ts +0 -25
  256. package/utils/release/release.ts +0 -154
@@ -1,43 +0,0 @@
1
- /**
2
- * Package "24iMediaTimeApi" provides a single function to obtain the current time
3
- * adjusted by local timezone and daylight savings time for use in time package,
4
- * from 24i time API at https://time.24imedia.tv/
5
- */
6
- import {
7
- xhrSendRetry, type RetryConfig, type XhrResponse,
8
- } from '@24i/bigscreen-sdk/utils/xhr';
9
-
10
- const API_URL = 'https://time.24imedia.tv/';
11
-
12
- export type Options = {
13
- /** The request timeout in milliseconds. The value 0 for no timeout */
14
- timeoutInMs: number,
15
- /** Retry configuration */
16
- retryConfig: RetryConfig,
17
- };
18
- export type ParamOptions = Partial<Options>;
19
-
20
- export type ServiceDataResponse = {
21
- /** Is dailight savings time */
22
- in_dst: boolean,
23
- /** Current time in GMT, in milliseconds */
24
- timestamp: number,
25
- /** Timezeone offset in milliseconds */
26
- timezone_offset: number,
27
- };
28
-
29
- /**
30
- * Request the current time based on public IP of request.
31
- *
32
- * @param options Options object
33
- */
34
- export async function getTime(options?: ParamOptions): Promise<ServiceDataResponse> {
35
- try {
36
- const resp = (await xhrSendRetry(API_URL, options)) as XhrResponse;
37
- const data: any = resp.dataJson || {};
38
- return data as ServiceDataResponse;
39
- } catch (e) {
40
- console.error('[24iMediaTimeApi] Failed to get time', e);
41
- throw e;
42
- }
43
- }
@@ -1,6 +0,0 @@
1
- export {
2
- Options,
3
- ParamOptions,
4
- ServiceDataResponse,
5
- getTime,
6
- } from './24iMediaTimeApi';
@@ -1,14 +0,0 @@
1
- import { Reference, unwrapReference } from '@24i/bigscreen-sdk/jsx';
2
-
3
- /**
4
- * To force a DOM reflow on given DOM element. It can be needed for transitions
5
- * or other purposes.
6
- * @param elementOrReference DOM element or reference to element on which reflow is called.
7
- */
8
- export const forceReflow = (
9
- elementOrReference: HTMLElement | Reference<HTMLElement>,
10
- ) => {
11
- const element = unwrapReference(elementOrReference);
12
- if (!element) return;
13
- void element.offsetHeight; // eslint-disable-line no-void
14
- };
@@ -1,6 +0,0 @@
1
- export {
2
- registerKeyPressSimulator,
3
- unregisterKeyPressSimulator,
4
- dispatchKeyboardEvent,
5
- } from './keyPressSimulator';
6
- export { simulateKeyPress } from './simulateKeyPress';
@@ -1,74 +0,0 @@
1
- import { Key } from '@24i/bigscreen-sdk/driver-base/keymap';
2
- import { stopEvent } from '@24i/bigscreen-sdk/utils';
3
-
4
- let keysPressed: Record<number, boolean>;
5
-
6
- interface CustomKeyboardEvent extends KeyboardEvent {
7
- skipKeyPressSimulation: boolean;
8
- }
9
-
10
- const shouldSkipEvent = (e: KeyboardEvent) => (
11
- Boolean((e as CustomKeyboardEvent).skipKeyPressSimulation)
12
- );
13
-
14
- const onKeyDown = (e: KeyboardEvent) => {
15
- if (shouldSkipEvent(e)) return;
16
- const { keyCode } = e;
17
- if (keysPressed[keyCode] === true) {
18
- console.warn(`Key ${e.code} (${e.keyCode}) is skipped by the key press simulator`);
19
- stopEvent(e);
20
- } else if (typeof keysPressed[keyCode] !== 'undefined') {
21
- keysPressed[keyCode] = true;
22
- }
23
- };
24
-
25
- const onKeyUp = (e: KeyboardEvent) => {
26
- const { keyCode } = e;
27
- if (keysPressed[keyCode] === true) keysPressed[keyCode] = false;
28
- };
29
-
30
- /**
31
- * Modifies `keydown` event behavior to similar to `keypress` and causes
32
- * triggering `keydown` event only once before the key is released. This is
33
- * because `keypress` event is deprecated and it is not implemented with the same
34
- * behavior on all platforms. This functionality is applied across the board for
35
- * all provided keys globally. To use in one specific handler only
36
- * use `simulateKeyPress` util.
37
- * @param keys array with keys to behave as keypress
38
- */
39
- export const registerKeyPressSimulator = (keys: Key[]) => {
40
- keysPressed = {};
41
- keys.forEach((key) => {
42
- keysPressed[key.keyCode] = false;
43
- });
44
- window.document.addEventListener('keydown', onKeyDown, true);
45
- window.document.addEventListener('keyup', onKeyUp, true);
46
- };
47
-
48
- /**
49
- * Unregister key press simulator events, turn off the functionality.
50
- */
51
- export const unregisterKeyPressSimulator = () => {
52
- window.document.removeEventListener('keydown', onKeyDown, true);
53
- window.document.removeEventListener('keyup', onKeyUp, true);
54
- };
55
-
56
- /**
57
- * This should be the main method for manually dispatching keyboard events when the
58
- * key press simulator is registered in the app. When parameter `skipKeyPressSimulation`
59
- * is `true`, those event's won't be caught by the key press simulator and
60
- * are no longer under it's influence. Key press simulator should work only with events
61
- * generated from input device.
62
- * @param target element target to dispatch event
63
- * @param event dispatching event
64
- * @param skipKeyPressSimulation default value is `true`, when false, the event
65
- * will be caught by the simulator and other dispatched events will be stopped.
66
- */
67
- export const dispatchKeyboardEvent = (
68
- target: HTMLElement,
69
- event: KeyboardEvent,
70
- skipKeyPressSimulation = true,
71
- ) => {
72
- (event as CustomKeyboardEvent).skipKeyPressSimulation = skipKeyPressSimulation;
73
- target.dispatchEvent(event);
74
- };
@@ -1,25 +0,0 @@
1
- const NO_KEY = -1;
2
-
3
- /**
4
- * Returns a new `keydown` handler wrapped with the simulated key press functionality.
5
- * Modifies `keydown` event behavior to similar to `keypress` and causes triggering keydown
6
- * event only once before the key is released. This is because `keypress` event is deprecated
7
- * and it is not implemented with the same behavior on all platforms. Apply this globally for
8
- * the specific keys by using `keyPressSimulator` util.
9
- * @param onKeyDown original handler for keydown event
10
- * @returns decorated handler with key press functionality
11
- */
12
- export const simulateKeyPress = (onKeyDown: (e: KeyboardEvent) => void) => {
13
- let keyPressed = NO_KEY;
14
- const onKeyUp = (e: KeyboardEvent) => {
15
- if (e.keyCode !== keyPressed) return;
16
- window.document.removeEventListener('keyup', onKeyUp);
17
- keyPressed = NO_KEY;
18
- };
19
- return (e: KeyboardEvent) => {
20
- if (keyPressed !== NO_KEY) return;
21
- keyPressed = e.keyCode;
22
- window.document.addEventListener('keyup', onKeyUp);
23
- onKeyDown(e);
24
- };
25
- };
@@ -1,154 +0,0 @@
1
- import { ok } from 'assert';
2
- import { execSync, ExecSyncOptions } from 'child_process';
3
-
4
- const branchNames = {
5
- dev: 'development',
6
- main: 'master',
7
- release: 'release',
8
- };
9
-
10
- const cmdSync = (command: string, options?: ExecSyncOptions) => execSync(command, options);
11
- const cmdSyncInheritOut = (command: string) => cmdSync(command, { stdio: 'inherit' });
12
- const cmdSyncPipeOut = (command: string) => cmdSync(command, { stdio: 'pipe' });
13
- const cmdSyncTrimOut = (command: string) => cmdSync(command).toString().trim();
14
-
15
- const splitByNewLine = (string = '') => string.split(/\r?\n/);
16
-
17
- const statusList = () => {
18
- const gitCmd = 'git status --porcelain';
19
- const outputString = cmdSyncTrimOut(gitCmd);
20
-
21
- if (!outputString) return [];
22
- const handleMultipleWhitespaces = (rowString: string) => {
23
- const spaceChar = ' ';
24
- const parts = rowString.split(spaceChar);
25
- return parts.filter(Boolean).join(spaceChar);
26
- };
27
-
28
- return splitByNewLine(outputString).map(handleMultipleWhitespaces);
29
- };
30
- const createBranch = (branchName: string) => cmdSyncPipeOut(`git branch ${branchName}`);
31
- const checkout = (branchName: string) => cmdSyncPipeOut(`git checkout ${branchName}`);
32
- const addAll = () => cmdSyncPipeOut('git add --all');
33
-
34
- const commit = (commitMessage: string, noVerify = false) => {
35
- const maybeNoVerifyParam = noVerify ? '--no-verify' : '';
36
- return cmdSyncPipeOut(`git commit -m "${commitMessage}" ${maybeNoVerifyParam}`.trimEnd());
37
- };
38
-
39
- const push = (branchName: string, noVerify = false) => {
40
- const maybeNoVerifyParam = noVerify ? '--no-verify' : '';
41
- const cmd = `git push --set-upstream origin ${branchName} ${maybeNoVerifyParam}`.trimEnd();
42
- return cmdSyncPipeOut(cmd);
43
- };
44
-
45
- const pushTag = (version: string) => {
46
- const cmd = `git push origin v${version}`;
47
- return cmdSyncPipeOut(cmd);
48
- };
49
-
50
- const assertEmptyStatusList = () => {
51
- ok(statusList().length === 0, 'An empty GIT stage is expected!');
52
- };
53
-
54
- const getCurrentBranchName = () => cmdSyncTrimOut('git branch --show-current');
55
-
56
- const remoteBranchExists = (expectedBranchName: string) => {
57
- const gitCmd = `git ls-remote --heads origin ${expectedBranchName}`;
58
- const output = cmdSyncTrimOut(gitCmd);
59
- return Boolean(output);
60
- };
61
-
62
- // only for GitHub
63
- const pullRequest = (fromBranch: string, toBranch: string, prTitle: string) => {
64
- const cmdTool = 'hub';
65
- const installDocUrl = 'https://github.com/github/hub#installation';
66
- const errorMsg = `${cmdTool} is not installed! See ${installDocUrl}\n`;
67
-
68
- try {
69
- const toolPath = cmdSyncTrimOut(`${cmdTool} --version`);
70
- ok(toolPath, errorMsg);
71
- } catch (error) {
72
- throw new Error(errorMsg);
73
- }
74
-
75
- const cmd = `${cmdTool} pull-request -m "${prTitle}" --head ${fromBranch} --base ${toBranch}`;
76
- cmdSyncInheritOut(cmd);
77
- };
78
-
79
- const assertCurrentBranch = (expectedBranchName: string) => {
80
- const currentGitBranchName = getCurrentBranchName();
81
- // eslint-disable-next-line max-len
82
- const errorMsg = `The ${expectedBranchName} branch is expected to be active, not "${currentGitBranchName}"`;
83
- ok(currentGitBranchName === expectedBranchName, errorMsg);
84
- };
85
-
86
- const bumpVersion = (version: string | 'major' | 'minor' | 'patch') => {
87
- // it bumps version, creates commit and GIT tag
88
- execSync(`npm version ${version}`, { stdio: 'inherit' });
89
- };
90
-
91
- const getNewReleaseBranchName = () => {
92
- const date = new Date();
93
- const yyyy = date.getFullYear();
94
- const mm = String(date.getMonth() + 1).padStart(2, '0');
95
- const dd = String(date.getDate()).padStart(2, '0');
96
- let bod = 0;
97
- const dateString = `${yyyy}-${mm}-${dd}`;
98
- while (true) {
99
- bod += 1;
100
- const bodString = String(bod).padStart(2, '0');
101
- const branchName = `${branchNames.release}/${dateString}-${bodString}`;
102
- if (!remoteBranchExists(branchName)) {
103
- return branchName;
104
- }
105
- }
106
- };
107
-
108
- /**
109
- * Release process.
110
- * @param versionType Version type one of 'major', 'minor', 'patch' or specific
111
- * version like '0.0.2'.
112
- */
113
- const release = (versionType: string | 'major' | 'minor' | 'patch') => {
114
- console.log(`Start release with version: ${versionType}`);
115
- assertCurrentBranch(branchNames.dev);
116
- assertEmptyStatusList();
117
- const newReleaseBranchName = getNewReleaseBranchName();
118
-
119
- console.log(`Creating "${newReleaseBranchName}" branch ...`);
120
- createBranch(newReleaseBranchName);
121
- checkout(newReleaseBranchName);
122
-
123
- console.log(`Bumping version with "${versionType}" ...`);
124
- bumpVersion(versionType);
125
- const version = cmdSyncTrimOut('npm pkg get version').replace(/"/g, '');
126
- ok(version, 'Oops, cannot get current version from package.json');
127
-
128
- console.log(`Publishing package version: ${version} ...`);
129
- cmdSyncInheritOut('npm publish');
130
-
131
- console.log(`Generating changelog: ${version} ...`);
132
- cmdSyncInheritOut('npm run generate-changelog');
133
- addAll(); // add version changes (changelog) into a git stage
134
-
135
- console.log('Creating commit with changed version and changelog ...');
136
- commit('chore(CHANGELOG): generated changelog', true);
137
-
138
- console.log(`Pushing ${newReleaseBranchName} branch ...`);
139
- push(newReleaseBranchName, true);
140
-
141
- console.log(`Pushing ${version} tag ...`);
142
- pushTag(version);
143
-
144
- const prTitle = `Release: ${newReleaseBranchName.split('/')[1]}`;
145
- // eslint-disable-next-line max-len
146
- console.log(`Creating Pull Request from ${newReleaseBranchName} branch to ${branchNames.main} branch...`);
147
- console.log(`Applied PR title: "${prTitle}"`);
148
- pullRequest(newReleaseBranchName, branchNames.main, prTitle);
149
-
150
- console.log('Done!');
151
- };
152
-
153
- const version = process.argv[2] || 'patch'; // 'major' | 'minor' | 'patch'
154
- release(version);