From 8415dde838701483212c4af440f28455b468373b Mon Sep 17 00:00:00 2001 From: Amo Wu Date: Mon, 25 Mar 2024 16:06:43 +0800 Subject: [PATCH 1/2] build: fix could not find a declaration file for module '@jwplayer/jwplayer-react' --- package-lock.json | 12 ++++++++++++ package.json | 6 ++++++ {src => types}/jwplayer-react.d.ts | 5 ++--- 3 files changed, 20 insertions(+), 3 deletions(-) rename {src => types}/jwplayer-react.d.ts (94%) diff --git a/package-lock.json b/package-lock.json index fe362b1..d1a2c93 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2955,6 +2955,12 @@ "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "node_modules/@types/jwplayer": { + "version": "8.28.4", + "resolved": "https://registry.npmjs.org/@types/jwplayer/-/jwplayer-8.28.4.tgz", + "integrity": "sha512-do47k7UASeDSnaZRZU71OmVv6KZ4F1mgkXOmljbu2uiT38jeE+ecxaL7ZkWggYg6xGqqSYmkLrjl4E6aOBqoHA==", + "dev": true + }, "node_modules/@types/node": { "version": "17.0.23", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.23.tgz", @@ -13429,6 +13435,12 @@ "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "@types/jwplayer": { + "version": "8.28.4", + "resolved": "https://registry.npmjs.org/@types/jwplayer/-/jwplayer-8.28.4.tgz", + "integrity": "sha512-do47k7UASeDSnaZRZU71OmVv6KZ4F1mgkXOmljbu2uiT38jeE+ecxaL7ZkWggYg6xGqqSYmkLrjl4E6aOBqoHA==", + "dev": true + }, "@types/node": { "version": "17.0.23", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.23.tgz", diff --git a/package.json b/package.json index ccc6eed..78a7886 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,11 @@ "url": "https://github.com/jwplayer/jwplayer-react/issues" }, "main": "./lib/jwplayer-react.js", + "types": "types/jwplayer-react.d.ts", + "files": [ + "lib", + "types" + ], "scripts": { "build": "webpack && npm run badges:build:passing || npm run badges:build:failing", "ci": "npm ci; npm run build; npm run test; npm run lint; npm run badges:license", @@ -34,6 +39,7 @@ "@babel/preset-env": "7.16.11", "@babel/preset-react": "7.16.7", "@testing-library/react": "12.1.4", + "@types/jwplayer": "^8.28.4", "@typescript-eslint/eslint-plugin": "5.59.6", "@typescript-eslint/parser": "5.59.6", "@wojtekmaj/enzyme-adapter-react-17": "0.6.6", diff --git a/src/jwplayer-react.d.ts b/types/jwplayer-react.d.ts similarity index 94% rename from src/jwplayer-react.d.ts rename to types/jwplayer-react.d.ts index c4c3348..29e6552 100644 --- a/src/jwplayer-react.d.ts +++ b/types/jwplayer-react.d.ts @@ -1,6 +1,5 @@ declare module '@jwplayer/jwplayer-react' { - import React from 'react'; - import jwplayer from './jwplayer'; + import type { ComponentType, HTMLProps } from 'react'; /** * Example: {"2500":"High","1000":"Medium"} @@ -99,7 +98,7 @@ declare module '@jwplayer/jwplayer-react' { config?: JWPlayerConfig; } - const JWPlayerComponent = React.Component>; + const JWPlayerComponent: ComponentType>; export default JWPlayerComponent; } From e3dc6a684c5674b04f6cff2cc12d9795e641abee Mon Sep 17 00:00:00 2001 From: Amo Wu Date: Tue, 28 May 2024 17:22:56 +0800 Subject: [PATCH 2/2] refactor: use HTMLVideoElement instead of 'video' --- types/jwplayer-react.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jwplayer-react.d.ts b/types/jwplayer-react.d.ts index 29e6552..5b40c8d 100644 --- a/types/jwplayer-react.d.ts +++ b/types/jwplayer-react.d.ts @@ -98,7 +98,7 @@ declare module '@jwplayer/jwplayer-react' { config?: JWPlayerConfig; } - const JWPlayerComponent: ComponentType>; + const JWPlayerComponent: ComponentType>; export default JWPlayerComponent; }