Skip to content

Commit

Permalink
FIX EbayVideo: [#259] Fix shaka-player types (#262)
Browse files Browse the repository at this point in the history
* [#259] Export Player type

* [#259] Ignore broken player definitions

* [#259] Update export
  • Loading branch information
darkwebdev authored Oct 18, 2023
1 parent a2b1845 commit 0e949e2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"args": "none"
}
],
// need that for shaka-player workaround
"@typescript-eslint/ban-ts-comment": "off",
// works incorrectly with type imports
"no-import-assign": "off",
"react/prop-types": "off",
Expand Down
5 changes: 4 additions & 1 deletion src/ebay-video/controls.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React, { ReactElement } from 'react'
import ReactDOM from 'react-dom'
// need that for broken definitions workaround
// @ts-ignore
import { ui } from 'shaka-player/dist/shaka-player.ui'
import { ReportButton } from './reportButton'

export function customControls(onReport = () => {}): { Report } {
// Have to contain in order to not execute until shaka is downloaded
const Report = class extends ui.Element {
// eslint-disable-next-line no-extra-parens
const Report = class extends (ui.Element as any) {
constructor(parent, controls, text) {
super(parent, controls)

Expand Down
2 changes: 0 additions & 2 deletions src/ebay-video/shaka-player.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
declare module 'shaka-player'
declare module 'shaka-player/dist/shaka-player.ui'
declare module 'shaka-player/dist/shaka-player.ui.debug'

type Player = Record<string, any>
2 changes: 2 additions & 0 deletions src/ebay-video/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export type VideoSource = {
src: string;
type?: VideoSourceType
}

export type Player = Record<string, any>
4 changes: 3 additions & 1 deletion src/ebay-video/video.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { ComponentProps, FC, SyntheticEvent, MouseEvent, useEffect, useRef, useState } from 'react'
import classNames from 'classnames'
// need that for broken definitions workaround
// @ts-ignore
import shaka from 'shaka-player/dist/shaka-player.ui'

import { filterByType } from '../common/component-utils'
import { EbayIcon } from '../ebay-icon'
import { EbayProgressSpinner } from '../ebay-progress-spinner'
import { VideoAction, VideoPlayView } from './types'
import { Player, VideoAction, VideoPlayView } from './types'
import EbayVideoSource from './source'
import { defaultVideoConfig, ERROR_ANOTHER_LOAD, ERROR_NO_PLAYER } from './const'
import { customControls } from './controls'
Expand Down

0 comments on commit 0e949e2

Please sign in to comment.