@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.
- package/README.md +1 -1
- package/package.json +34 -53
- package/packages/adobe-heartbeat/src/AdobeHeartbeat.ts +9 -9
- package/packages/async-image/src/AsyncImage.tsx +10 -15
- package/packages/developer-tools/PlayerDebugWindow/README.md +1 -1
- package/packages/developer-tools/src/DeveloperToolsService/DeveloperToolsList.tsx +0 -11
- package/packages/developer-tools/src/PlayerDebugWindow/PlayerDebugWindow.tsx +5 -5
- package/packages/developer-tools/src/PlayerDebugWindow/constants.ts +0 -15
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoDetail.tsx +1 -2
- package/packages/developer-tools/src/TechnicalInfo/TechnicalInfoProvider.ts +3 -34
- package/packages/developer-tools/src/TechnicalInfo/__mocks__/Device.ts +0 -4
- package/packages/developer-tools/src/TechnicalInfo/translations.ts +0 -4
- package/packages/device/src/getKeyDigit.ts +2 -2
- package/packages/device/src/resolver/resolver.ts +5 -18
- package/packages/digital-clock/src/DigitalClock.tsx +4 -15
- package/packages/driver-androidtv/src/DeviceAndroidTV.ts +9 -54
- package/packages/driver-androidtv/src/__mocks__/javaScriptBridge.ts +5 -29
- package/packages/driver-androidtv/src/keymap.ts +0 -18
- package/packages/driver-androidtv/src/types.ts +16 -102
- package/packages/driver-base/src/DeviceBase.ts +2 -61
- package/packages/driver-base/src/KeyMap/Key.ts +1 -8
- package/packages/driver-base/src/KeyMap/KeyMap.ts +0 -4
- package/packages/driver-base/src/KeyMap/interface.ts +0 -1
- package/packages/driver-base/src/KeyMap/overrideValues.ts +1 -2
- package/packages/driver-base/src/__mocks__/keyMap.ts +0 -1
- package/packages/driver-base/src/types/DeviceEvent.ts +0 -2
- package/packages/driver-base/src/types/KeycodeKeyMap.ts +0 -1
- package/packages/driver-browser/src/keymap.ts +0 -8
- package/packages/driver-entone/src/keymap.ts +0 -1
- package/packages/driver-tizen/src/TizenKeys.ts +0 -2
- package/packages/driver-vidaa/src/DeviceVidaa.ts +2 -3
- package/packages/driver-vidaa/src/__mocks__/vidaa.ts +1 -1
- package/packages/driver-vidaa/src/keymap.ts +0 -2
- package/packages/driver-webos/src/DeviceWebos.ts +0 -8
- package/packages/driver-webos/src/keymap.ts +1 -2
- package/packages/driver-xbox/src/keymap.ts +1 -1
- package/packages/epg/README.md +1 -3
- package/packages/epg/src/v2/Cell.tsx +2 -16
- package/packages/epg/src/v2/DataManager.ts +41 -112
- package/packages/epg/src/v2/DatePicker.tsx +3 -9
- package/packages/epg/src/v2/DateToast/DateToast.tsx +9 -12
- package/packages/epg/src/v2/Day.tsx +3 -6
- package/packages/epg/src/v2/Epg.tsx +5 -5
- package/packages/epg/src/v2/MockGenerator/generator.ts +2 -3
- package/packages/epg/src/v2/ProgramInfo/utils.ts +3 -4
- package/packages/epg/src/v2/Row.tsx +1 -3
- package/packages/epg/src/v2/TimelineSection.tsx +1 -4
- package/packages/epg/src/v2/basic/CellsManager.tsx +2 -7
- package/packages/epg/src/v2/basic/RowsManager.tsx +1 -3
- package/packages/epg/src/v2/interface.ts +0 -13
- package/packages/events-manager/src/EventsManager.ts +56 -1
- package/packages/focus/README.md +0 -33
- package/packages/focus/src/IFocusable.ts +0 -1
- package/packages/focus/src/Layout/Base.tsx +6 -41
- package/packages/focus/src/Layout/Matrix.tsx +19 -51
- package/packages/focus/src/Layout/__test__/Base.spec.ts +180 -0
- package/packages/focus/src/Layout/__test__/Horizontal.spec.ts +94 -0
- package/packages/focus/src/Layout/__test__/Matrix.spec.ts +261 -0
- package/packages/focus/src/Layout/__test__/Vertical.spec.ts +46 -0
- package/packages/focus/src/Layout/__test__/isRtl.spec.ts +23 -0
- package/packages/focus/src/Layout/__test__/shared.ts +19 -0
- package/packages/focus/src/focusFirstExisting.ts +1 -7
- package/packages/focus/src/index.ts +1 -2
- package/packages/gallup/src/Gallup.ts +3 -3
- package/packages/grid/src/Base/Base.tsx +10 -15
- package/packages/grid/src/FirstOnlyGrid/FirstOnlyGrid.tsx +2 -4
- package/packages/icon/src/Icon.tsx +5 -27
- package/packages/input/README.md +1 -4
- package/packages/input/src/Input.tsx +29 -65
- package/packages/input/src/handleOverflow.ts +29 -0
- package/packages/interactable/README.md +1 -2
- package/packages/interactable/src/Interactable.tsx +3 -9
- package/packages/interactable/src/interface.ts +0 -1
- package/packages/jsx/src/index.ts +1 -1
- package/packages/jsx/src/test-utils/index.ts +0 -1
- package/packages/keyboard/src/Backdrop/Backdrop.scss +0 -2
- package/packages/keyboard/src/KeyboardBase.tsx +4 -16
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.scss +0 -4
- package/packages/keyboard/src/WhitelabelKeyboard/Keyboard.tsx +20 -28
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.1080.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/_sizes.scss +0 -1
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/index.ts +0 -11
- package/packages/keyboard/src/WhitelabelKeyboard/types.ts +0 -1
- package/packages/l10n/README.md +0 -18
- package/packages/l10n/src/date/common.ts +6 -18
- package/packages/l10n/src/date/cs.ts +8 -2
- package/packages/l10n/src/date/en-001.ts +3 -3
- package/packages/l10n/src/date/en-common.ts +4 -5
- package/packages/l10n/src/date/en-us.ts +3 -3
- package/packages/l10n/src/date/iso.ts +13 -12
- package/packages/l10n/src/date/types.ts +0 -9
- package/packages/l10n/src/l10n.ts +3 -61
- package/packages/list/src/Base/Base.tsx +9 -19
- package/packages/list/src/Base/interface.ts +2 -2
- package/packages/list/src/CenteredList/controller.ts +1 -0
- package/packages/list/src/EdgeOffsetList/EdgeOffsetList.tsx +3 -3
- package/packages/list/src/UnifiedListController/UnifiedListController.ts +2 -6
- package/packages/logger/src/loggers/SentryLogger/Sentry.ts +0 -1
- package/packages/logger/src/loggers/SentryLogger/SentryLogger.ts +2 -2
- package/packages/menu/src/MenuAndContentContainer/MenuAndContentContainer.tsx +3 -31
- package/packages/menu/src/MenuAndContentContainer/interface.ts +0 -8
- package/packages/modal-service/README.md +1 -4
- package/packages/modal-service/src/ModalService.tsx +5 -29
- package/packages/perf-utils/README.md +120 -1
- package/packages/perf-utils/src/array/filter.ts +54 -1
- package/packages/perf-utils/src/array/find.ts +43 -1
- package/packages/perf-utils/src/array/findIndex.ts +43 -1
- package/packages/perf-utils/src/array/forEach.ts +48 -1
- package/packages/perf-utils/src/array/includes.ts +41 -1
- package/packages/perf-utils/src/array/includesNaN.ts +32 -1
- package/packages/perf-utils/src/array/index.ts +7 -1
- package/packages/perf-utils/src/array/map.ts +52 -1
- package/packages/player-ui/README.md +1 -1
- package/packages/player-ui/src/CurrentTime.tsx +2 -2
- package/packages/player-ui/src/Duration.tsx +2 -2
- package/packages/player-ui/src/PauseButton.tsx +0 -8
- package/packages/player-ui/src/PlayerInteractable.tsx +0 -1
- package/packages/player-ui/src/PlayerTime.tsx +1 -3
- package/packages/player-ui/src/PlayerUI.tsx +35 -68
- package/packages/player-ui/src/RemainingTime.tsx +2 -2
- package/packages/player-ui/src/Seekbar.tsx +18 -110
- package/packages/player-ui/src/Seeking.ts +16 -57
- package/packages/player-ui/src/Subtitles.tsx +2 -2
- package/packages/player-ui/src/index.ts +0 -1
- package/packages/player-ui/src/mocks.ts +8 -32
- package/packages/player-ui/src/timeUtils.ts +3 -3
- package/packages/player-ui/src/types.ts +3 -9
- package/packages/router/src/Route.tsx +27 -61
- package/packages/router/src/Router.tsx +13 -59
- package/packages/router/src/history.ts +1 -8
- package/packages/router/src/index.ts +1 -1
- package/packages/router/src/utils.ts +4 -9
- package/packages/sass-utils/src/linear-gradient.scss +4 -9
- package/packages/sass-utils/src/scale.1080.scss +1 -3
- package/packages/sass-utils/src/scale.720.scss +1 -1
- package/packages/time/README.md +1 -4
- package/packages/time/src/Time.ts +13 -35
- package/packages/time/src/constants.ts +0 -1
- package/packages/toast/src/ToastService.tsx +5 -16
- package/packages/types-bigscreen-jsx/README.md +4 -5
- package/packages/types-bigscreen-jsx/index.d.ts +67 -72
- package/packages/utils/README.md +0 -27
- package/packages/utils/src/elementUtils.ts +0 -25
- package/packages/utils/src/index.ts +0 -8
- package/packages/utils/src/scaledImage.ts +3 -6
- package/packages/utils/src/textUtils.ts +14 -46
- package/packages/utils/src/wait.ts +1 -3
- package/packages/utils/src/xhr/xhrSend.ts +1 -3
- package/packages/utils/src/xhr/xhrSendRetry.ts +1 -3
- package/packages/zapping/src/ChannelZapping.ts +0 -9
- package/packages/zapping/src/Zapping.tsx +0 -10
- package/.vscode/settings.json +0 -6
- package/packages/analytics/README.md +0 -8
- package/packages/analytics/src/A.ts +0 -1
- package/packages/analytics/src/Analytics.ts +0 -1
- package/packages/analytics/src/analyticsOnScroll.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/ConsoleAnalytics.ts +0 -1
- package/packages/analytics/src/clients/ConsoleAnalytics/index.ts +0 -1
- package/packages/analytics/src/clients/GoogleAnalytics/GoogleAnalytics.ts +0 -200
- package/packages/analytics/src/clients/GoogleAnalytics/constants.ts +0 -118
- package/packages/analytics/src/clients/GoogleAnalytics/getUrl.ts +0 -17
- package/packages/analytics/src/clients/GoogleAnalytics/index.ts +0 -2
- package/packages/analytics/src/clients/GoogleAnalytics/interface.ts +0 -77
- package/packages/analytics/src/clients/GoogleAnalytics/mapPayload.ts +0 -50
- package/packages/analytics/src/clients/GoogleAnalytics/prepareBody.ts +0 -14
- package/packages/analytics/src/clients/TealiumAnalytics/TealiumAnalytics.ts +0 -169
- package/packages/analytics/src/clients/TealiumAnalytics/constants.ts +0 -102
- package/packages/analytics/src/clients/TealiumAnalytics/findIdForLanguage.ts +0 -9
- package/packages/analytics/src/clients/TealiumAnalytics/index.ts +0 -4
- package/packages/analytics/src/clients/TealiumAnalytics/interface.ts +0 -33
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/__mocks__/mediaPayload.ts +0 -70
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/helper.ts +0 -36
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapAppError.ts +0 -13
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteAdd.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapFavoriteRemove.ts +0 -11
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerClose.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapPlayerOpen.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSceneView.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearch.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchFailed.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapSearchSuccess.ts +0 -8
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoPause.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoProgress.ts +0 -18
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoResume.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStart.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/mappers/mapVideoStop.ts +0 -15
- package/packages/analytics/src/clients/TealiumAnalytics/types.ts +0 -156
- package/packages/analytics/src/clients/TwentyFourIQ/TwentyFourIQClient.ts +0 -116
- package/packages/analytics/src/clients/TwentyFourIQ/constants.ts +0 -99
- package/packages/analytics/src/clients/TwentyFourIQ/helper.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/index.ts +0 -2
- package/packages/analytics/src/clients/TwentyFourIQ/interface.ts +0 -31
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdLoaded.ts +0 -13
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapAdSkipped.ts +0 -16
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBase.ts +0 -21
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapBuffering.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerClose.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapPlayerOpen.ts +0 -18
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapSceneView.ts +0 -15
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapScroll.ts +0 -17
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoComplete.ts +0 -21
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoPause.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoProgress.ts +0 -24
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStart.ts +0 -34
- package/packages/analytics/src/clients/TwentyFourIQ/mappers/mapVideoStop.ts +0 -32
- package/packages/analytics/src/clients/TwentyFourIQ/types.ts +0 -115
- package/packages/analytics/src/constants.ts +0 -1
- package/packages/analytics/src/index.ts +0 -3
- package/packages/analytics/src/interface.ts +0 -1
- package/packages/analytics/src/utils/generateSessionId.ts +0 -8
- package/packages/create-package/dist/createPackage.js +0 -66
- package/packages/create-package/dist/createPackage.js.map +0 -1
- package/packages/create-package/dist/index.js +0 -5
- package/packages/create-package/dist/index.js.map +0 -1
- package/packages/create-package/dist/questionnaire/questions.js +0 -35
- package/packages/create-package/dist/questionnaire/questions.js.map +0 -1
- package/packages/create-package/dist/settings/Settings.js +0 -10
- package/packages/create-package/dist/settings/Settings.js.map +0 -1
- package/packages/create-package/dist/types.js +0 -3
- package/packages/create-package/dist/types.js.map +0 -1
- package/packages/device/src/driver/index.firetv.ts +0 -1
- package/packages/device/src/driver/index.smartcast.tv.ts +0 -1
- package/packages/driver-firetv/src/DeviceFireTV.ts +0 -18
- package/packages/driver-firetv/src/__mocks__/javaScriptBridge.ts +0 -36
- package/packages/driver-firetv/src/index.ts +0 -1
- package/packages/driver-smartcast/src/DeviceSmartCast.ts +0 -317
- package/packages/driver-smartcast/src/__mocks__/api.ts +0 -49
- package/packages/driver-smartcast/src/index.ts +0 -1
- package/packages/driver-smartcast/src/keymap.ts +0 -9
- package/packages/driver-smartcast/src/types.ts +0 -65
- package/packages/focus/src/hasFocus.ts +0 -36
- package/packages/input/src/utils.ts +0 -71
- package/packages/jsx/src/test-utils/keyup.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/arabic.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/burmese.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/dari.ts +0 -28
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/korean.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/pashto.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/persian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/russian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/tibetan.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/turkish.ts +0 -26
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/ukrainian.ts +0 -27
- package/packages/keyboard/src/WhitelabelKeyboard/layouts/urdu.ts +0 -26
- package/packages/l10n/src/date/de.ts +0 -97
- package/packages/l10n/src/date/es.ts +0 -71
- package/packages/l10n/src/date/fr.ts +0 -94
- package/packages/l10n/src/date/he.ts +0 -101
- package/packages/time/src/adapters/24iMediaTimeApi.ts +0 -47
- package/packages/time/src/services/24iMediaTimeApi/24iMediaTimeApi.ts +0 -43
- package/packages/time/src/services/24iMediaTimeApi/index.ts +0 -6
- package/packages/utils/src/forceReflow.ts +0 -14
- package/packages/utils/src/keyPress/index.ts +0 -6
- package/packages/utils/src/keyPress/keyPressSimulator.ts +0 -74
- package/packages/utils/src/keyPress/simulateKeyPress.ts +0 -25
- 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,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,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
|
-
};
|
package/utils/release/release.ts
DELETED
|
@@ -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);
|