From 35fab919228648899e554d5c0a6d4c9088246abc Mon Sep 17 00:00:00 2001 From: Jahed Ahmed Date: Sat, 23 Jan 2021 21:41:57 +0000 Subject: [PATCH] fix: ensure lazy typedefs mirror defaults Fixes #1146 --- package.json | 4 ++-- types/base.d.ts | 30 +++++++++++++++++++++++++++++- types/index.d.ts | 31 ------------------------------- types/lib/index.d.ts | 1 + 4 files changed, 32 insertions(+), 34 deletions(-) delete mode 100644 types/index.d.ts create mode 100644 types/lib/index.d.ts diff --git a/package.json b/package.json index 4df97ed5..6a729399 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.8.1", "description": "A React component for playing a variety of URLs, including file paths, YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia and DailyMotion", "main": "lib/index.js", - "typings": "index.d.ts", + "typings": "lib/index.d.ts", "scripts": { "clean": "rimraf lib lazy demo coverage *.d.ts", "start": "webpack-dev-server --config webpack/config.babel.js", @@ -21,7 +21,7 @@ "build:standalone": "cross-env NODE_ENV=production webpack --config webpack/standalone.babel.js", "preversion": "npm run lint && npm run test", "version": "auto-changelog -p && npm run build:dist && npm run build:standalone && git add CHANGELOG.md dist", - "prepublishOnly": "npm run build:lib && npm run build:lazy && npm run build:dist && node scripts/pre-publish.js && cp types/*.d.ts . && cp types/index.d.ts lazy", + "prepublishOnly": "npm run build:lib && npm run build:lazy && npm run build:dist && node scripts/pre-publish.js && cp types/*.d.ts . && cp types/lib/index.d.ts lib && cp types/lib/index.d.ts lazy", "postpublish": "node scripts/post-publish.js && npm run clean" }, "repository": { diff --git a/types/base.d.ts b/types/base.d.ts index e798e2c0..6a554e52 100644 --- a/types/base.d.ts +++ b/types/base.d.ts @@ -1,5 +1,14 @@ import { Component, ReactElement, CSSProperties } from 'react' -import ReactPlayer from './index' +import { DailyMotionConfig } from './dailymotion' +import { FacebookConfig } from './facebook' +import { FileConfig } from './file' +import { MixcloudConfig } from './mixcloud' +import { SoundCloudConfig } from './soundcloud' +import { TwitchConfig } from './twitch' +import { VidyardConfig } from './vidyard' +import { VimeoConfig } from './vimeo' +import { WistiaConfig } from './wistia' +import { YouTubeConfig } from './youtube' interface SourceProps { src: string @@ -59,3 +68,22 @@ export default class BaseReactPlayer extends Com getInternalPlayer (key?: string): Record; showPreview (): void; } + +export interface Config { + soundcloud?: SoundCloudConfig + youtube?: YouTubeConfig + facebook?: FacebookConfig + dailymotion?: DailyMotionConfig + vimeo?: VimeoConfig + file?: FileConfig + wistia?: WistiaConfig + mixcloud?: MixcloudConfig + vidyard?: VidyardConfig + twitch?: TwitchConfig +} + +export interface ReactPlayerProps extends BaseReactPlayerProps { + config?: Config +} + +export class ReactPlayer extends BaseReactPlayer {} diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index 39af0726..00000000 --- a/types/index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import BaseReactPlayer, { BaseReactPlayerProps } from './base' - -import { DailyMotionConfig } from './dailymotion' -import { FacebookConfig } from './facebook' -import { FileConfig } from './file' -import { MixcloudConfig } from './mixcloud' -import { SoundCloudConfig } from './soundcloud' -import { TwitchConfig } from './twitch' -import { VidyardConfig } from './vidyard' -import { VimeoConfig } from './vimeo' -import { WistiaConfig } from './wistia' -import { YouTubeConfig } from './youtube' - -export interface Config { - soundcloud?: SoundCloudConfig - youtube?: YouTubeConfig - facebook?: FacebookConfig - dailymotion?: DailyMotionConfig - vimeo?: VimeoConfig - file?: FileConfig - wistia?: WistiaConfig - mixcloud?: MixcloudConfig - vidyard?: VidyardConfig - twitch?: TwitchConfig -} - -export interface ReactPlayerProps extends BaseReactPlayerProps { - config?: Config -} - -export default class ReactPlayer extends BaseReactPlayer {} diff --git a/types/lib/index.d.ts b/types/lib/index.d.ts new file mode 100644 index 00000000..f066ae32 --- /dev/null +++ b/types/lib/index.d.ts @@ -0,0 +1 @@ +export { Config, ReactPlayerProps, ReactPlayer as default } from '../base'