Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FEC-13371): Refactor: Migration to TypeScript (from Flow) #837

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
499376f
upgrade webpack deps and the coorsponding conf
Nov 13, 2023
bede944
all dirs exept componebts
Nov 14, 2023
66f131c
add scss suppurt and some components
Nov 15, 2023
3eebe4b
40% fix event classes dups
Nov 16, 2023
320bc54
icon
Nov 16, 2023
7c052bf
live tag and ineractive
Nov 16, 2023
ce21961
more comps
Nov 19, 2023
603052a
seekbar comps
Nov 20, 2023
ce54073
coms complete
Nov 20, 2023
c8e0619
index to ts
Nov 20, 2023
2736a8c
complete
Nov 21, 2023
cd8010b
remove redundent alias webpack
Nov 21, 2023
5a6dab4
state types
Nov 22, 2023
5e32b45
fix webpakc - react settings
Nov 22, 2023
12a7965
fix tests
Nov 26, 2023
52f7a4c
lint + types generate + ci cd
Nov 27, 2023
4f0ea77
reomve api extractor files
Nov 27, 2023
80923c9
add them to gitignore
Nov 27, 2023
bb00741
Merge remote-tracking branch 'origin/master' into FEC-13371
Nov 27, 2023
bd858b3
fix lint
Nov 27, 2023
526f824
ci cd concurrency improvement
Nov 27, 2023
fdef0da
fix invalid yaml
Nov 27, 2023
d0f2309
fix
Dec 11, 2023
9631096
webpack preact
Dec 11, 2023
96248ed
fix jsx error - missing config & and fix style broken error - missing…
Dec 12, 2023
5df9bac
fix
Dec 19, 2023
8434acd
update yarn and set webpack
Dec 19, 2023
96f1e56
Merge branch 'master' into FEC-13371
Dec 19, 2023
00c3cb3
fix merge master
Dec 19, 2023
cff480e
fix css sourc map
Dec 20, 2023
5439799
Review
Dec 21, 2023
fa5f236
fix types
Dec 24, 2023
c4e8cf0
Addressing Sivan comments & add browserlist
Dec 26, 2023
67ec818
upgrade playkit to the latest canary, and use temp local .tgz file fo…
Dec 27, 2023
6e771d1
fix
Dec 27, 2023
8d56eb8
fix
Dec 27, 2023
5afd46b
fix
Dec 27, 2023
476e3a1
fix
Dec 27, 2023
f04965e
fix
Dec 27, 2023
0e46c5f
fix
Dec 27, 2023
1949281
feat(FEC-13371): Refactor: Migrate to TypeScript (from Flow) (#815)
JonathanTGold Dec 27, 2023
e20dcd3
fix(FEC-13371): fix TS types CSS export issue
Dec 28, 2023
50ba8a8
Merge remote-tracking branch 'origin/master' into FEC-13371
Dec 28, 2023
baef7a9
fix template
Dec 28, 2023
d8497ca
fix temlate
Dec 28, 2023
a2e9935
fix(FEC-13371): fix TS types CSS export issue (#829)
JonathanTGold Dec 28, 2023
3011d8c
Merge remote-tracking branch 'origin/master' into FEC-13371
Dec 28, 2023
d82abb9
fix
Dec 28, 2023
262640d
fix(FEC-13361): Export typings on package.json (#830)
JonathanTGold Dec 28, 2023
b70d97c
Merge remote-tracking branch 'origin/master' into FEC-13371
Dec 28, 2023
853ae41
fix(FEC-13371): Update browser-list dep
Dec 28, 2023
9b27090
fix
Dec 28, 2023
f9ad890
fix
Dec 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Addressing Sivan comments & add browserlist
  • Loading branch information
JonathanTGold committed Dec 26, 2023
commit c4e8cf0a7b8f793f3f59658f65fb886e9e57c68c
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@
"typescript-plugin-css-modules": "^5.0.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
"webpack-dev-server": "^4.15.1",
"@playkit-js/browserslist-config": "^1.0.5"
},
"browserslist": [
"extends @playkit-js/browserslist-config"
],
"publishConfig": {
"cache": "~/.npm",
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {KeyMap} from '../../utils/key-map';
import {KeyMap} from "../../utils";
import style from '../../styles/style.scss';
import {Icon, IconType} from '../icon';
import {h} from 'preact';
Expand Down
8 changes: 3 additions & 5 deletions src/components/expandable-text/expandable-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { h, ComponentChildren } from "preact";
import {withText} from 'preact-i18n';

import {useState, useRef, useLayoutEffect} from 'preact/hooks';
import {KeyMap} from '../../utils/key-map';
import {KeyMap} from "../../utils";

import styles from '../../styles/style.scss';

Expand Down Expand Up @@ -101,10 +101,8 @@ const ExpandableText: new(props?: any, context?: any) => any = withText({
</div>
);
});
/*@ts-expect-error - Property 'defaultProps' does not exist on type 'new (props?: any, context?: any) => any */
ExpandableText.defaultProps = {
ExpandableText['defaultProps'] = {
buttonProps: {}
};
/*@ts-expect-error - Property 'displayName' does not exist on type 'new (props?: any, context?: any) => any'. */
ExpandableText.displayName = COMPONENT_NAME;
ExpandableText['displayName'] = COMPONENT_NAME;
export {ExpandableText};
6 changes: 2 additions & 4 deletions src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import {withEventManager} from '../../event';
import {WithEventManagerProps} from '../../event/with-event-manager';

type OptionType = {
value: any; // Replace 'any' with a more specific type if possible
value: any;
label: string;
active: boolean;
// Add other properties of options here if they exist
};

type MenuProps = {
Expand All @@ -21,11 +20,10 @@ type MenuProps = {
options: OptionType[];
labelledby?: string;
pushRef?: (HTMLElement) => void;
onMenuChosen: (value: any) => void; // Replace 'any' with the specific type of option value
onMenuChosen: (value: any) => void;
onClose: () => void;
hideSelect?: boolean;
parentEl?: HTMLDivElement;
// Add any other props that Menu might use
};

/**
Expand Down
10 changes: 5 additions & 5 deletions src/components/player-area/player-area-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class PlayerAreaProvider extends Component<WithLoggerProps & PlayerAreaProviderP
* @private
* @return {void}
*/
_initializePlayerComponents() {
_initializePlayerComponents(): void {
if (this.props.uiComponents && this.props.uiComponents.length > 0) {
// @ts-ignore
this.props.uiComponents.forEach(this._addNewComponent);
// @ts-ignore - TODO
this.props.uiComponents.forEach((c)=> this._addNewComponent(c));
this._emitAllListeners();
}
}
Expand All @@ -66,7 +66,7 @@ class PlayerAreaProvider extends Component<WithLoggerProps & PlayerAreaProviderP
* @returns {void}
* @private
*/
_emitListeners(listeners: ComponentListener[]) {
_emitListeners(listeners: ComponentListener[]): void {
const {activePresetName} = this.props;

(listeners || []).forEach(listener => {
Expand All @@ -84,7 +84,7 @@ class PlayerAreaProvider extends Component<WithLoggerProps & PlayerAreaProviderP
* @returns {void}
* @private
*/
_emitAllListeners() {
_emitAllListeners(): void {
this._emitListeners(this._listeners);
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/shell/shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,13 @@ class Shell extends Component<any, any> {
);
}
playerClasses.push('notranslate');
const JoinedPlayerClasses = playerClasses.join(' ');
const joinedPlayerClasses = playerClasses.join(' ');

return (
<div
tabIndex={-1}
ref={node => (this._playerRef = node)}
className={JoinedPlayerClasses}
className={joinedPlayerClasses}
onTouchEnd={this.onTouchEnd}
onMouseUp={this.onMouseUp}
onMouseOver={this.onMouseOver}
Expand Down
3 changes: 0 additions & 3 deletions src/components/smart-container/smart-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ const COMPONENT_NAME = 'SmartContainer';
@withKeyboardA11y
@withText({settingsText: 'settings.title'})
class SmartContainer extends Component<any, any> {
// ie11 fix (FEC-7312) - don't remove
_portal: any;

/**
* before component mounted, add player css class
*
Expand Down
2 changes: 1 addition & 1 deletion src/components/unmute-indication/unmute-indication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class UnmuteIndication extends Component<any, any> {
* @returns {void}
*/
_iconOnlyTimeout(): void {
// @ts-ignore
// @ts-expect-error - Type 'Timeout' is not assignable to type 'number'.
this._iconTimeout = setTimeout(() => {
this.setState({iconOnly: true});
}, MUTED_AUTOPLAY_ICON_ONLY_DEFAULT_TIMEOUT);
Expand Down
5 changes: 0 additions & 5 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
declare var __CSS_MODULE_PREFIX__: string;
declare var __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: string;

declare module '*.css' {
const classes: { [key: string]: string };
export default classes;
}

declare module '*.scss' {
const classes: { [key: string]: string };
export default classes;
Expand Down
2 changes: 1 addition & 1 deletion src/types/reducers/engine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AudioTrack, PKTextTrack, VideoTrack } from "@playkit-js/playkit-js";
import { AudioTrack, PKTextTrack, VideoTrack } from '@playkit-js/playkit-js';

export interface EngineState {
isIdle: boolean;
Expand Down
12 changes: 7 additions & 5 deletions src/ui-manager.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {h, render} from 'preact';
import {Provider} from 'react-redux';
import {IntlProvider} from 'preact-i18n';
import {createStore, compose, Store} from 'redux'; // the former is deprecated, react docs recommends using import {cconfigureStore} from '@reduxjs/toolkit';
// TODO the 'redux' lib is deprecated, react docs recommends using import {cconfigureStore} from '@reduxjs/toolkit';
import {createStore, compose, Store} from 'redux';
import {copyDeep} from './utils/copy-deep';
import {mergeDeep} from './utils/merge-deep';
import {getLogLevel, setLogLevel, setLogger, LogLevelType, LogLevel} from './utils/logger';
Expand All @@ -28,7 +29,7 @@ import {EventDispatcherProvider} from './components';
import {KeyboardEventProvider} from './components';
import {ThemesManager} from './utils/themes-manager';
import {UIOptionsObject, UIPreset} from './types';
import {KalturaPlayer, KPUIAddComponent, KPUIComponent} from '@playkit-js/kaltura-player-js';
import {KalturaPlayer, KPUIComponent} from '@playkit-js/kaltura-player-js';
import {RootState} from './types';

/**
Expand Down Expand Up @@ -162,9 +163,10 @@ class UIManager {
* @returns {void}
*/
_createStore(config: UIOptionsObject): void {
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
// @ts-ignore
this.store = createStore<RootState, any>(reducer, composeEnhancers(middleware(this.player, config)));
// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
// TODO - fix the window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
// TODO - Deprecated symbol used, consult docs for better alternative, React recommend using the configureStore method of the @reduxjs/toolkit packag
this.store = createStore<RootState, any, any, any>(reducer, compose(middleware(this.player, config)));
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ function setLogger(logger?: LoggerType): void {
* @returns {Object} - the logger class
*/
function getLogger(name?: string): any {
//$FlowFixMe
return JsLogger.get(name);
}

Expand Down
24 changes: 13 additions & 11 deletions src/utils/time-format.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
/**
* Formatting seconds input into time format
*
* @param {number} input number of seconds
* @returns {string} formatted time string
*/
function toHHMMSS(input: number): string {
const secNum = parseInt(input, 10);
let hours = Math.floor(secNum / 3600);
let minutes = Math.floor((secNum - hours * 3600) / 60);
let seconds = secNum - hours * 3600 - minutes * 60;
function toHHMMSS(input: string | number): string {
const secNum = parseInt(input as string, 10);
const hours: number = Math.floor(secNum / 3600);
const minutes: number = Math.floor((secNum - hours * 3600) / 60);
const seconds: number = secNum - hours * 3600 - minutes * 60;

let hoursFormat = hours as unknown as string;
let minutesFormat = minutes as unknown as string;
let secondsFormat = seconds as unknown as string;

if (hours < 10) {
hours = '0' + hours;
hoursFormat = '0' + hours;
}
if (minutes < 10) {
minutes = '0' + minutes;
minutesFormat = '0' + minutes;
}
if (seconds < 10) {
seconds = '0' + seconds;
secondsFormat = '0' + seconds;
}

return `${hours !== '00' ? hours + ':' : ''}${minutes}:${seconds}`;
return `${hoursFormat !== '00' ? hoursFormat + ':' : ''}${minutesFormat}:${secondsFormat}`;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,11 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@playkit-js/browserslist-config@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@playkit-js/browserslist-config/-/browserslist-config-1.0.5.tgz#7d4a7f7b087caa2620d9f89263a05bd4a0af99a4"
integrity sha512-aEx7S4nW1XakhTtx01Use7viuuZ61ho6FeL6iHtZMpclsjEPYf0N8jQt9e3aDBKhaZZ8pKl5250hI4pjWWBfAA==

"@playkit-js/kaltura-player-js@canary":
version "3.17.5-canary.0-50b07bd"
resolved "https://registry.yarnpkg.com/@playkit-js/kaltura-player-js/-/kaltura-player-js-3.17.5-canary.0-50b07bd.tgz#1bdc2b7b0dfa2fb4a8ea7d72716b74df9dc5810f"
Expand Down
Loading