@mux/mux-player-react 0.1.0-canary.9-cbb4bc0 → 1.0.0-beta.0
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/LICENSE +9 -0
- package/README.md +128 -48
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +7 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +36 -18
- package/dist/types/useCombinedRefs.d.ts +2 -1
- package/dist/types-ts3.4/index.d.ts +36 -18
- package/dist/types-ts3.4/useCombinedRefs.d.ts +2 -1
- package/package.json +21 -13
- package/CHANGELOG.md +0 -131
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -7
- package/src/common/utils.ts +0 -54
- package/src/env.ts +0 -11
- package/src/index.tsx +0 -204
- package/src/useCombinedRefs.ts +0 -30
- package/src/useObjectPropEffect.ts +0 -66
- package/tsconfig.json +0 -22
- package/types/index.d.ts +0 -0
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
3
|
import { StreamTypes } from '@mux/playback-core';
|
|
4
|
-
import '@mux/mux-player';
|
|
4
|
+
import { MediaError } from '@mux/mux-player';
|
|
5
5
|
import MuxPlayerElement from '@mux/mux-player';
|
|
6
6
|
import { Tokens } from '@mux/mux-player';
|
|
7
|
+
export { MediaError };
|
|
7
8
|
declare type ValueOf<T> = T[keyof T];
|
|
9
|
+
interface GenericEventListener<T extends Event = CustomEvent> {
|
|
10
|
+
(evt: T): void;
|
|
11
|
+
}
|
|
8
12
|
export declare type MuxPlayerRefAttributes = MuxPlayerElement;
|
|
9
13
|
declare type VideoApiAttributes = {
|
|
10
14
|
currentTime: number;
|
|
@@ -36,7 +40,12 @@ declare type MuxMediaPropTypes = {
|
|
|
36
40
|
startTime: number;
|
|
37
41
|
children: never[];
|
|
38
42
|
};
|
|
43
|
+
interface MuxPlayerElementEventMap extends HTMLVideoElementEventMap {
|
|
44
|
+
}
|
|
39
45
|
export declare type MuxPlayerProps = {
|
|
46
|
+
className?: string;
|
|
47
|
+
hotkeys?: string;
|
|
48
|
+
nohotkeys?: boolean;
|
|
40
49
|
defaultHiddenCaptions?: boolean;
|
|
41
50
|
playerSoftwareVersion?: string;
|
|
42
51
|
playerSoftwareName?: string;
|
|
@@ -48,25 +57,34 @@ export declare type MuxPlayerProps = {
|
|
|
48
57
|
primaryColor?: string;
|
|
49
58
|
secondaryColor?: string;
|
|
50
59
|
tertiaryColor?: string;
|
|
60
|
+
playbackRates?: number[];
|
|
61
|
+
defaultShowRemainingTime?: boolean;
|
|
51
62
|
thumbnailTime?: number;
|
|
63
|
+
title?: string;
|
|
52
64
|
tokens?: Tokens;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
onAbort?: GenericEventListener<MuxPlayerElementEventMap['abort']>;
|
|
66
|
+
onCanPlay?: GenericEventListener<MuxPlayerElementEventMap['canplay']>;
|
|
67
|
+
onCanPlayThrough?: GenericEventListener<MuxPlayerElementEventMap['canplaythrough']>;
|
|
68
|
+
onEmptied?: GenericEventListener<MuxPlayerElementEventMap['emptied']>;
|
|
69
|
+
onLoadStart?: GenericEventListener<MuxPlayerElementEventMap['loadstart']>;
|
|
70
|
+
onLoadedData?: GenericEventListener<MuxPlayerElementEventMap['loadeddata']>;
|
|
71
|
+
onLoadedMetadata?: GenericEventListener<MuxPlayerElementEventMap['loadedmetadata']>;
|
|
72
|
+
onProgress?: GenericEventListener<MuxPlayerElementEventMap['progress']>;
|
|
73
|
+
onDurationChange?: GenericEventListener<MuxPlayerElementEventMap['durationchange']>;
|
|
74
|
+
onVolumeChange?: GenericEventListener<MuxPlayerElementEventMap['volumechange']>;
|
|
75
|
+
onRateChange?: GenericEventListener<MuxPlayerElementEventMap['ratechange']>;
|
|
76
|
+
onResize?: GenericEventListener<MuxPlayerElementEventMap['resize']>;
|
|
77
|
+
onWaiting?: GenericEventListener<MuxPlayerElementEventMap['waiting']>;
|
|
78
|
+
onPlay?: GenericEventListener<MuxPlayerElementEventMap['play']>;
|
|
79
|
+
onPlaying?: GenericEventListener<MuxPlayerElementEventMap['playing']>;
|
|
80
|
+
onTimeUpdate?: GenericEventListener<MuxPlayerElementEventMap['timeupdate']>;
|
|
81
|
+
onPause?: GenericEventListener<MuxPlayerElementEventMap['pause']>;
|
|
82
|
+
onSeeking?: GenericEventListener<MuxPlayerElementEventMap['seeking']>;
|
|
83
|
+
onSeeked?: GenericEventListener<MuxPlayerElementEventMap['seeked']>;
|
|
84
|
+
onStalled?: GenericEventListener<MuxPlayerElementEventMap['stalled']>;
|
|
85
|
+
onSuspend?: GenericEventListener<MuxPlayerElementEventMap['suspend']>;
|
|
86
|
+
onEnded?: GenericEventListener<MuxPlayerElementEventMap['ended']>;
|
|
87
|
+
onError?: GenericEventListener<MuxPlayerElementEventMap['error']>;
|
|
70
88
|
} & Partial<MuxMediaPropTypes> & Partial<VideoApiAttributes>;
|
|
71
89
|
declare const MuxPlayer: React.ForwardRefExoticComponent<Pick<MuxPlayerProps, Exclude<keyof MuxPlayerProps, "playerSoftwareVersion" | "playerSoftwareName">> & React.RefAttributes<MuxPlayerElement>>;
|
|
72
90
|
export default MuxPlayer;
|
|
@@ -7,4 +7,5 @@ interface useCombinedRefs {
|
|
|
7
7
|
<T>(...refs: Maybe<RefTypes<T>>[]): RefObj<T>;
|
|
8
8
|
}
|
|
9
9
|
export declare const useCombinedRefs: useCombinedRefs;
|
|
10
|
-
|
|
10
|
+
declare const defaultUseCombinedRefs: useCombinedRefs;
|
|
11
|
+
export default defaultUseCombinedRefs;
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mux/mux-player-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"description": "An open source Mux player for React that Just Works™",
|
|
5
|
-
"main": "dist/index.js",
|
|
5
|
+
"main": "./dist/index.cjs.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"require": "./dist/index.cjs.js",
|
|
10
|
+
"default": "./dist/index.cjs.js"
|
|
11
|
+
},
|
|
6
12
|
"types": "dist/types-ts3.4/index.d.ts",
|
|
7
13
|
"typesVersions": {
|
|
8
14
|
">=4.3.5": {
|
|
@@ -20,14 +26,16 @@
|
|
|
20
26
|
"license": "MIT",
|
|
21
27
|
"scripts": {
|
|
22
28
|
"clean": "shx rm -rf dist/",
|
|
23
|
-
"dev:cjs": "
|
|
29
|
+
"dev:cjs": "yarn build:cjs --watch=forever",
|
|
30
|
+
"dev:esm": "yarn build:esm --watch=forever",
|
|
24
31
|
"dev:types": "yarn build:types -w",
|
|
25
|
-
"dev": "npm-run-all --parallel dev:types dev:cjs",
|
|
26
|
-
"build:cjs": "esbuild src/index.tsx --target=es2019 --bundle --sourcemap --metafile=./dist/cjs.json --format=cjs --loader:.css=text --outdir=dist --external:react --external:@mux/* --external:prop-types --define:PLAYER_VERSION=\"'$npm_package_version'\"",
|
|
27
|
-
"build:
|
|
28
|
-
"build": "
|
|
32
|
+
"dev": "npm-run-all --parallel dev:types dev:cjs dev:esm",
|
|
33
|
+
"build:cjs": "esbuild src/index.tsx --target=es2019 --bundle --sourcemap --metafile=./dist/cjs.json --format=cjs --loader:.css=text --outdir=dist --out-extension:.js=.cjs.js --external:react --external:@mux/* --external:prop-types --define:PLAYER_VERSION=\"'$npm_package_version'\"",
|
|
34
|
+
"build:esm": "esbuild src/index.tsx --target=es2019 --bundle --sourcemap --metafile=./dist/esm.json --format=esm --loader:.css=text --outdir=dist --out-extension:.js=.mjs --external:react --external:@mux/* --external:prop-types --define:PLAYER_VERSION=\"'$npm_package_version'\"",
|
|
35
|
+
"build:types": "tsc --declaration --emitDeclarationOnly --outDir './dist/types'",
|
|
36
|
+
"postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4",
|
|
37
|
+
"build": "npm-run-all --parallel build:types 'build:cjs -- --minify' 'build:esm -- --minify'",
|
|
29
38
|
"prebuild": "yarn clean",
|
|
30
|
-
"prepublishOnly": "yarn build",
|
|
31
39
|
"create-release-notes": "create-release-notes ./CHANGELOG.md",
|
|
32
40
|
"publish-release": "../../scripts/publish.sh"
|
|
33
41
|
},
|
|
@@ -45,20 +53,20 @@
|
|
|
45
53
|
}
|
|
46
54
|
},
|
|
47
55
|
"dependencies": {
|
|
48
|
-
"@mux/mux-player": "
|
|
49
|
-
"@mux/playback-core": "0.
|
|
56
|
+
"@mux/mux-player": "1.0.0-beta.0",
|
|
57
|
+
"@mux/playback-core": "0.11.0",
|
|
50
58
|
"prop-types": "^15.7.2"
|
|
51
59
|
},
|
|
52
60
|
"devDependencies": {
|
|
53
|
-
"@mux/open-process": "0.1.0",
|
|
54
61
|
"@types/react": "^17.0.37",
|
|
55
62
|
"@types/react-dom": "^17.0.11",
|
|
56
63
|
"downlevel-dts": "^0.9.0",
|
|
57
|
-
"esbuild": "^0.
|
|
64
|
+
"esbuild": "^0.15.7",
|
|
58
65
|
"npm-run-all": "^4.1.5",
|
|
59
66
|
"react": "^17.0.2",
|
|
60
67
|
"react-dom": "^17.0.2",
|
|
61
68
|
"shx": "^0.3.4",
|
|
62
69
|
"typescript": "^4.5.2"
|
|
63
|
-
}
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "807de779d0c22eec622957f02362d122e1dcd686"
|
|
64
72
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# 0.1.0-beta.21 (2022-07-05)
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
- enable cast docs + cast fix ([#253](https://github.com/muxinc/elements/issues/253)) ([421d515](https://github.com/muxinc/elements/commit/421d515cc4700cf9d7ca4f0d09aa600ec4adac7b))
|
|
11
|
-
- **mux-player-react:** Missing preload prop type def. ([19b2e15](https://github.com/muxinc/elements/commit/19b2e15dc844e6fb0f90e9ad62a436587260094a))
|
|
12
|
-
- prettier format all elements files ([741d607](https://github.com/muxinc/elements/commit/741d607521ca9578cfad9f0a9216a6565b4c56a1))
|
|
13
|
-
- switch cjs extension to .cjs.js ([30e83c3](https://github.com/muxinc/elements/commit/30e83c3ce0bd9bfda4817c30ffe0921e425619e4))
|
|
14
|
-
- update react peerDependencies to allow ^18 ([1cfb019](https://github.com/muxinc/elements/commit/1cfb019b71cf9aa280abccaf4a7818d585b56d86))
|
|
15
|
-
|
|
16
|
-
### Features
|
|
17
|
-
|
|
18
|
-
- add beaconCollectionDomain option to replace beaconDomain ([a44b699](https://github.com/muxinc/elements/commit/a44b699ae3138590b9d953f693f95971694658df))
|
|
19
|
-
- default-hidden-captions to turn off showing captions by default ([#98](https://github.com/muxinc/elements/issues/98)) ([9edc3cd](https://github.com/muxinc/elements/commit/9edc3cd008e47234472b14784ea89493736599cb))
|
|
20
|
-
- Extended autoplay options ([#116](https://github.com/muxinc/elements/issues/116)) ([475e838](https://github.com/muxinc/elements/commit/475e83884f641c578fa601c9501147d485fc1831))
|
|
21
|
-
- **mux-player-react:** Add audio only. Cleanup StreamTypes source of truth. ([4f37d7f](https://github.com/muxinc/elements/commit/4f37d7f10ef66eef48af0dd9cf1efc79322b660d))
|
|
22
|
-
- **mux-player-react:** Add basic support for custom video domains. ([ac61aff](https://github.com/muxinc/elements/commit/ac61affffdd38ef0df3151d2f75023f7d2772688))
|
|
23
|
-
- **mux-player-react:** Add thumbnail-time support to mux-player-react. Document prop. ([d1c1a4c](https://github.com/muxinc/elements/commit/d1c1a4c65b200c59bab7cc68453c0e307eb75ae4))
|
|
24
|
-
|
|
25
|
-
### Reverts
|
|
26
|
-
|
|
27
|
-
- Revert "Publish" ([42fc528](https://github.com/muxinc/elements/commit/42fc528216346ff52d967cec5392a1191f74a1c0))
|
|
28
|
-
|
|
29
|
-
# [0.1.0-beta.20](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.19...@mux-elements/mux-player-react@0.1.0-beta.20) (2022-06-23)
|
|
30
|
-
|
|
31
|
-
### Bug Fixes
|
|
32
|
-
|
|
33
|
-
- enable cast docs + cast fix ([#253](https://github.com/muxinc/elements/issues/253)) ([421d515](https://github.com/muxinc/elements/commit/421d515cc4700cf9d7ca4f0d09aa600ec4adac7b))
|
|
34
|
-
|
|
35
|
-
### Features
|
|
36
|
-
|
|
37
|
-
- **mux-player-react:** Add basic support for custom video domains. ([ac61aff](https://github.com/muxinc/elements/commit/ac61affffdd38ef0df3151d2f75023f7d2772688))
|
|
38
|
-
|
|
39
|
-
# [0.1.0-beta.19](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.18...@mux-elements/mux-player-react@0.1.0-beta.19) (2022-06-07)
|
|
40
|
-
|
|
41
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
42
|
-
|
|
43
|
-
# [0.1.0-beta.18](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.17...@mux-elements/mux-player-react@0.1.0-beta.18) (2022-06-06)
|
|
44
|
-
|
|
45
|
-
### Features
|
|
46
|
-
|
|
47
|
-
- **mux-player-react:** Add audio only. Cleanup StreamTypes source of truth. ([4f37d7f](https://github.com/muxinc/elements/commit/4f37d7f10ef66eef48af0dd9cf1efc79322b660d))
|
|
48
|
-
|
|
49
|
-
# [0.1.0-beta.17](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.16...@mux-elements/mux-player-react@0.1.0-beta.17) (2022-05-26)
|
|
50
|
-
|
|
51
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
52
|
-
|
|
53
|
-
# [0.1.0-beta.16](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.15...@mux-elements/mux-player-react@0.1.0-beta.16) (2022-05-23)
|
|
54
|
-
|
|
55
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
56
|
-
|
|
57
|
-
# [0.1.0-beta.15](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.14...@mux-elements/mux-player-react@0.1.0-beta.15) (2022-05-23)
|
|
58
|
-
|
|
59
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
60
|
-
|
|
61
|
-
# [0.1.0-beta.14](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.13...@mux-elements/mux-player-react@0.1.0-beta.14) (2022-05-20)
|
|
62
|
-
|
|
63
|
-
### Bug Fixes
|
|
64
|
-
|
|
65
|
-
- switch cjs extension to .cjs.js ([30e83c3](https://github.com/muxinc/elements/commit/30e83c3ce0bd9bfda4817c30ffe0921e425619e4))
|
|
66
|
-
|
|
67
|
-
# [0.1.0-beta.13](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.12...@mux-elements/mux-player-react@0.1.0-beta.13) (2022-05-19)
|
|
68
|
-
|
|
69
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
70
|
-
|
|
71
|
-
# [0.1.0-beta.12](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.11...@mux-elements/mux-player-react@0.1.0-beta.12) (2022-05-12)
|
|
72
|
-
|
|
73
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
74
|
-
|
|
75
|
-
# [0.1.0-beta.11](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.10...@mux-elements/mux-player-react@0.1.0-beta.11) (2022-05-11)
|
|
76
|
-
|
|
77
|
-
### Bug Fixes
|
|
78
|
-
|
|
79
|
-
- **mux-player-react:** Missing preload prop type def. ([19b2e15](https://github.com/muxinc/elements/commit/19b2e15dc844e6fb0f90e9ad62a436587260094a))
|
|
80
|
-
|
|
81
|
-
### Features
|
|
82
|
-
|
|
83
|
-
- **mux-player-react:** Add thumbnail-time support to mux-player-react. Document prop. ([d1c1a4c](https://github.com/muxinc/elements/commit/d1c1a4c65b200c59bab7cc68453c0e307eb75ae4))
|
|
84
|
-
|
|
85
|
-
# [0.1.0-beta.10](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.9...@mux-elements/mux-player-react@0.1.0-beta.10) (2022-05-10)
|
|
86
|
-
|
|
87
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
88
|
-
|
|
89
|
-
# [0.1.0-beta.9](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.8...@mux-elements/mux-player-react@0.1.0-beta.9) (2022-05-03)
|
|
90
|
-
|
|
91
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
92
|
-
|
|
93
|
-
# [0.1.0-beta.8](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.7...@mux-elements/mux-player-react@0.1.0-beta.8) (2022-04-22)
|
|
94
|
-
|
|
95
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
96
|
-
|
|
97
|
-
# [0.1.0-beta.7](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.6...@mux-elements/mux-player-react@0.1.0-beta.7) (2022-04-18)
|
|
98
|
-
|
|
99
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
100
|
-
|
|
101
|
-
# [0.1.0-beta.6](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.5...@mux-elements/mux-player-react@0.1.0-beta.6) (2022-04-13)
|
|
102
|
-
|
|
103
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
104
|
-
|
|
105
|
-
# [0.1.0-beta.5](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.4...@mux-elements/mux-player-react@0.1.0-beta.5) (2022-04-12)
|
|
106
|
-
|
|
107
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
108
|
-
|
|
109
|
-
# [0.1.0-beta.4](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.3...@mux-elements/mux-player-react@0.1.0-beta.4) (2022-04-08)
|
|
110
|
-
|
|
111
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
112
|
-
|
|
113
|
-
# [0.1.0-beta.3](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.2...@mux-elements/mux-player-react@0.1.0-beta.3) (2022-04-01)
|
|
114
|
-
|
|
115
|
-
**Note:** Version bump only for package @mux-elements/mux-player-react
|
|
116
|
-
|
|
117
|
-
# [0.1.0-beta.2](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.1...@mux-elements/mux-player-react@0.1.0-beta.2) (2022-04-01)
|
|
118
|
-
|
|
119
|
-
### Reverts
|
|
120
|
-
|
|
121
|
-
- Revert "Publish" ([42fc528](https://github.com/muxinc/elements/commit/42fc528216346ff52d967cec5392a1191f74a1c0))
|
|
122
|
-
|
|
123
|
-
# [0.1.0-beta.1](https://github.com/muxinc/elements/compare/@mux-elements/mux-player-react@0.1.0-beta.0...@mux-elements/mux-player-react@0.1.0-beta.1) (2022-03-28)
|
|
124
|
-
|
|
125
|
-
### Bug Fixes
|
|
126
|
-
|
|
127
|
-
- prettier format all elements files ([741d607](https://github.com/muxinc/elements/commit/741d607521ca9578cfad9f0a9216a6565b4c56a1))
|
|
128
|
-
|
|
129
|
-
### Features
|
|
130
|
-
|
|
131
|
-
- add beaconCollectionDomain option to replace beaconDomain ([a44b699](https://github.com/muxinc/elements/commit/a44b699ae3138590b9d953f693f95971694658df))
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var H=Object.create;var c=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var g=e=>c(e,"__esModule",{value:!0});var q=(e,t)=>{g(e);for(var n in t)c(e,n,{get:t[n],enumerable:!0})},J=(e,t,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of W(t))!_.call(e,r)&&r!=="default"&&c(e,r,{get:()=>t[r],enumerable:!(n=z(t,r))||n.enumerable});return e},l=e=>J(g(c(e!=null?H(Z(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);q(exports,{default:()=>ye});var i=l(require("react")),ge=l(require("@mux/mux-player"));var b={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay"},Y=e=>e==null,$=(e,t)=>Y(t)?!1:e in t,G=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`),Q=(e,t)=>{if(!(typeof t=="boolean"&&!t)){if($(e,b))return b[e];if(typeof t!=null)return/[A-Z]/.test(e)?G(e):e}};var X=(e,t)=>typeof e=="boolean"?"":e,P=(e={})=>Object.entries(e).reduce((t,[n,r])=>{let a=Q(n,r);if(!a)return t;let s=X(r,n);return t[a]=s,t},{});var E=l(require("react"));var f=l(require("react")),T=(...e)=>{let t=(0,f.useRef)(null);return(0,f.useEffect)(()=>{e.forEach(n=>{!n||(typeof n=="function"?n(t.current):n.current=t.current)})},[e]),t};var x=l(require("react")),B=Object.prototype.hasOwnProperty,ee=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.some((a,s)=>t[s]===a);let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let a=0;a<n.length;a++)if(!B.call(t,n[a])||!Object.is(e[n[a]],t[n[a]]))return!1;return!0},m=(e,t,n)=>!ee(t,e[n]),te=(e,t,n)=>{e[n]=t},ne=(e,t,n,r=te,a=m)=>(0,x.useEffect)(()=>{let s=n==null?void 0:n.current;!s||!a(s,t,e)||r(s,t,e)},[n==null?void 0:n.current,t]),y=ne;var re=()=>{try{return"0.1.0-canary.9-cbb4bc0"}catch{}return"UNKNOWN"},ae=re(),R=()=>ae;var oe=i.default.forwardRef(({children:e,...t},n)=>i.default.createElement("mux-player",P({...t,ref:n}),e)),o=(e,t,n)=>(0,i.useEffect)(()=>{let r=t==null?void 0:t.current;if(!(!r||!n))return r.addEventListener(e,n),()=>{r.removeEventListener(e,n)}},[t==null?void 0:t.current,n]),se=(e,t)=>{let{onLoadStart:n,onLoadedMetadata:r,onProgress:a,onDurationChange:s,onVolumeChange:p,onRateChange:v,onResize:k,onWaiting:O,onPlay:M,onPlaying:w,onTimeUpdate:S,onPause:h,onSeeking:L,onSeeked:C,onEnded:V,onError:A,onPlayerReady:N,metadata:I,tokens:K,paused:j,playbackId:D,...U}=t;return y("metadata",I,e),y("tokens",K,e),y("playbackId",D,e),y("paused",j,e,(u,d)=>{d!=null&&(d?u.pause():u.play())},(u,d,F)=>u.hasAttribute("autoplay")&&!u.hasPlayed?!1:m(u,d,F)),o("loadstart",e,n),o("loadedmetadata",e,r),o("progress",e,a),o("durationchange",e,s),o("volumechange",e,p),o("ratechange",e,v),o("resize",e,k),o("waiting",e,O),o("play",e,M),o("playing",e,w),o("timeupdate",e,S),o("pause",e,h),o("seeking",e,L),o("seeked",e,C),o("ended",e,V),o("error",e,A),o("playerready",e,N),[U]},ie=R(),ue="mux-player-react",le=i.default.forwardRef((e,t)=>{let{forwardSeekOffset:n=10,backwardSeekOffset:r=10}=e,a=(0,E.useRef)(null),s=T(a,t),[p]=se(a,e);return i.default.createElement(oe,{ref:s,playerSoftwareName:ue,playerSoftwareVersion:ie,forwardSeekOffset:n,backwardSeekOffset:r,...p})}),ye=le;
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.tsx", "../src/common/utils.ts", "../src/useCombinedRefs.ts", "../src/useObjectPropEffect.ts", "../src/env.ts"],
|
|
4
|
-
"sourcesContent": ["import React, { useEffect } from 'react';\nimport type { CSSProperties } from 'react';\nimport type { StreamTypes } from '@mux/playback-core';\nimport '@mux/mux-player';\nimport type MuxPlayerElement from '@mux/mux-player';\nimport type { Tokens } from '@mux/mux-player';\nimport { toNativeProps } from './common/utils';\nimport { useRef } from 'react';\nimport { useCombinedRefs } from './useCombinedRefs';\nimport useObjectPropEffect, { defaultHasChanged } from './useObjectPropEffect';\nimport { getPlayerVersion } from './env';\n\ntype ValueOf<T> = T[keyof T];\n\nexport type MuxPlayerRefAttributes = MuxPlayerElement;\ntype VideoApiAttributes = {\n currentTime: number;\n volume: number;\n paused: boolean;\n src: string | null;\n poster: string;\n playbackRate: number;\n playsInline: boolean;\n preload: string;\n crossOrigin: string;\n autoPlay: boolean | string;\n loop: boolean;\n muted: boolean;\n style: CSSProperties;\n};\n\ntype MuxMediaPropTypes = {\n audio: boolean;\n // envKey: Options[\"data\"][\"env_key\"];\n envKey: string;\n // debug: Options[\"debug\"] & Hls[\"config\"][\"debug\"];\n debug: boolean;\n // metadata: Partial<Options[\"data\"]>;\n metadata: { [k: string]: any };\n beaconCollectionDomain: string;\n customDomain: string;\n playbackId: string;\n preferMse: boolean;\n streamType: ValueOf<StreamTypes> | 'vod';\n startTime: number;\n children: never[];\n};\n\nexport type MuxPlayerProps = {\n defaultHiddenCaptions?: boolean;\n playerSoftwareVersion?: string;\n playerSoftwareName?: string;\n forwardSeekOffset?: number;\n backwardSeekOffset?: number;\n metadataVideoId?: string;\n metadataVideoTitle?: string;\n metadataViewerUserId?: string;\n primaryColor?: string;\n secondaryColor?: string;\n tertiaryColor?: string;\n thumbnailTime?: number;\n tokens?: Tokens;\n onLoadStart?: EventListener;\n onLoadedMetadata?: EventListener;\n onProgress?: EventListener;\n onDurationChange?: EventListener;\n onVolumeChange?: EventListener;\n onRateChange?: EventListener;\n onResize?: EventListener;\n onWaiting?: EventListener;\n onPlay?: EventListener;\n onPlaying?: EventListener;\n onTimeUpdate?: EventListener;\n onPause?: EventListener;\n onSeeking?: EventListener;\n onSeeked?: EventListener;\n onEnded?: EventListener;\n onError?: EventListener;\n onPlayerReady?: EventListener;\n} & Partial<MuxMediaPropTypes> &\n Partial<VideoApiAttributes>;\n\nconst MuxPlayerInternal = React.forwardRef<MuxPlayerRefAttributes, MuxPlayerProps>(({ children, ...props }, ref) => {\n return React.createElement('mux-player', toNativeProps({ ...props, ref }), children);\n});\n\nconst useEventCallbackEffect = (\n type: string,\n ref: // | ((instance: EventTarget | null) => void)\n React.MutableRefObject<EventTarget | null> | null | undefined,\n callback: EventListener | undefined\n) => {\n return useEffect(() => {\n const eventTarget = ref?.current;\n if (!eventTarget || !callback) return;\n eventTarget.addEventListener(type, callback);\n return () => {\n eventTarget.removeEventListener(type, callback);\n };\n }, [ref?.current, callback]);\n};\n\nconst usePlayer = (\n ref: // | ((instance: EventTarget | null) => void)\n React.MutableRefObject<MuxPlayerElement | null> | null | undefined,\n props: MuxPlayerProps\n) => {\n const {\n onLoadStart,\n onLoadedMetadata,\n onProgress,\n onDurationChange,\n onVolumeChange,\n onRateChange,\n onResize,\n onWaiting,\n onPlay,\n onPlaying,\n onTimeUpdate,\n onPause,\n onSeeking,\n onSeeked,\n onEnded,\n onError,\n onPlayerReady,\n metadata,\n tokens,\n paused,\n playbackId,\n ...remainingProps\n } = props;\n useObjectPropEffect('metadata', metadata, ref);\n useObjectPropEffect('tokens', tokens, ref);\n useObjectPropEffect('playbackId', playbackId, ref);\n useObjectPropEffect(\n 'paused',\n paused,\n ref,\n (playerEl: HTMLMediaElement, pausedVal?: boolean) => {\n if (pausedVal == null) return;\n if (pausedVal) {\n playerEl.pause();\n } else {\n playerEl.play();\n }\n },\n (playerEl, value, propName) => {\n if (playerEl.hasAttribute('autoplay') && !playerEl.hasPlayed) {\n return false;\n }\n return defaultHasChanged(playerEl, value, propName);\n }\n );\n useEventCallbackEffect('loadstart', ref, onLoadStart);\n useEventCallbackEffect('loadedmetadata', ref, onLoadedMetadata);\n useEventCallbackEffect('progress', ref, onProgress);\n useEventCallbackEffect('durationchange', ref, onDurationChange);\n useEventCallbackEffect('volumechange', ref, onVolumeChange);\n useEventCallbackEffect('ratechange', ref, onRateChange);\n useEventCallbackEffect('resize', ref, onResize);\n useEventCallbackEffect('waiting', ref, onWaiting);\n useEventCallbackEffect('play', ref, onPlay);\n useEventCallbackEffect('playing', ref, onPlaying);\n useEventCallbackEffect('timeupdate', ref, onTimeUpdate);\n useEventCallbackEffect('pause', ref, onPause);\n useEventCallbackEffect('seeking', ref, onSeeking);\n useEventCallbackEffect('seeked', ref, onSeeked);\n useEventCallbackEffect('ended', ref, onEnded);\n useEventCallbackEffect('error', ref, onError);\n useEventCallbackEffect('playerready', ref, onPlayerReady);\n return [remainingProps];\n};\n\nconst playerSoftwareVersion = getPlayerVersion();\nconst playerSoftwareName = 'mux-player-react';\n\nconst MuxPlayer = React.forwardRef<\n MuxPlayerRefAttributes,\n Omit<MuxPlayerProps, 'playerSoftwareVersion' | 'playerSoftwareName'>\n>((props, ref) => {\n const {\n /** @TODO Remove these once defaults are added to mux-player (CJP) */\n forwardSeekOffset = 10,\n backwardSeekOffset = 10,\n } = props;\n\n const innerPlayerRef = useRef<MuxPlayerElement>(null);\n const playerRef = useCombinedRefs(innerPlayerRef, ref);\n const [remainingProps] = usePlayer(innerPlayerRef, props);\n\n return (\n <MuxPlayerInternal\n /** @TODO Fix types relationships (CJP) */\n ref={playerRef as typeof innerPlayerRef}\n playerSoftwareName={playerSoftwareName}\n playerSoftwareVersion={playerSoftwareVersion}\n forwardSeekOffset={forwardSeekOffset}\n backwardSeekOffset={backwardSeekOffset}\n {...remainingProps}\n />\n );\n});\n\nexport default MuxPlayer;\n", "// NOTE: As a forward-looking implementation, we may want to assume\n// prop names -> attribute names is always a simple name.toLowerCase()\n// and provide a mechanism for passing in per-component overrides for\n// e.g. kebab cases, as that's the way React/Preact handles these. (CJP)\nconst ReactPropToAttrNameMap = {\n className: 'class',\n classname: 'class',\n htmlFor: 'for',\n crossOrigin: 'crossorigin',\n viewBox: 'viewBox',\n playsInline: 'playsinline',\n autoPlay: 'autoplay',\n};\n\ntype KeyTypes = string | number | symbol;\n\nexport const isNil = (x: unknown): x is null | undefined => x == undefined;\n\n// Type Guard to determine if a given key is actually a key of some object of type T\nexport const isKeyOf = <T = unknown>(k: KeyTypes, o: T): k is keyof T => {\n if (isNil(o)) return false;\n return k in o;\n};\n\nconst toKebabCase = (string: string) => string.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\n\nexport const toNativeAttrName = (propName: string, propValue: any): string | undefined => {\n if (typeof propValue === 'boolean' && !propValue) return undefined;\n if (isKeyOf(propName, ReactPropToAttrNameMap)) return ReactPropToAttrNameMap[propName];\n if (typeof propValue == undefined) return undefined;\n if (/[A-Z]/.test(propName)) return toKebabCase(propName);\n return propName;\n};\nexport const toStyleAttr = <T>(x: T) => x;\n\nexport const toNativeAttrValue = (propValue: any, propName: string) => {\n if (typeof propValue === 'boolean') return '';\n return propValue;\n};\n\nexport const toNativeProps = (props = {}) => {\n return Object.entries(props).reduce<{ [k: string]: string }>((transformedProps, [propName, propValue]) => {\n const attrName = toNativeAttrName(propName, propValue);\n\n // prop was stripped. Don't add.\n if (!attrName) {\n return transformedProps;\n }\n\n const attrValue = toNativeAttrValue(propValue, propName);\n transformedProps[attrName] = attrValue;\n return transformedProps;\n }, {});\n};\n", "import { useEffect, useRef } from 'react';\nimport type { MutableRefObject, ForwardedRef } from 'react';\n\ntype Maybe<T> = T | null | undefined;\ntype RefCb<T> = (instance: Maybe<T>) => void;\ntype RefObj<T> = MutableRefObject<Maybe<T>>;\ntype RefTypes<T> = RefObj<T> | RefCb<T> | ForwardedRef<T>;\ninterface useCombinedRefs {\n <T>(...refs: Maybe<RefTypes<T>>[]): RefObj<T>;\n}\n\nexport const useCombinedRefs: useCombinedRefs = (...refs) => {\n const targetRef = useRef(null);\n\n useEffect(() => {\n refs.forEach((ref) => {\n if (!ref) return;\n\n if (typeof ref === 'function') {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n });\n }, [refs]);\n\n return targetRef;\n};\n\nexport default useCombinedRefs;\n", "import { useEffect } from 'react';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * Slightly modified version of React's shallowEqual, with optimizations for Arrays\n * so we may treat them specifically as unequal if they are not a) both arrays\n * or b) don't contain the same (shallowly compared) elements.\n */\nconst shallowEqual = (objA: any, objB: any): boolean => {\n if (Object.is(objA, objB)) {\n return true;\n }\n\n if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {\n return false;\n }\n\n if (Array.isArray(objA)) {\n // Early \"cheap\" array compares\n if (!Array.isArray(objB) || objA.length !== objB.length) return false;\n // Shallow compare for arrays\n return objA.some((vVal, i) => objB[i] === vVal);\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n for (let i = 0; i < keysA.length; i++) {\n if (!hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {\n return false;\n }\n }\n\n return true;\n};\n\nexport const defaultHasChanged = (obj: any, v: any, k: string) => {\n return !shallowEqual(v, obj[k]);\n};\n\nconst defaultUpdateValue = (obj: any, v: any, k: string) => {\n obj[k] = v;\n};\n\nexport const useObjectPropEffect = <T extends { [k: string]: any }, V>(\n propName: string,\n propValue: V | null | undefined,\n ref: React.MutableRefObject<T | null> | null | undefined,\n updateValue = defaultUpdateValue,\n hasChanged = defaultHasChanged\n) => {\n return useEffect(() => {\n const obj = ref?.current;\n if (!obj) return;\n if (!hasChanged(obj, propValue, propName)) return;\n updateValue(obj, propValue, propName);\n }, [ref?.current, propValue]);\n};\n\nexport default useObjectPropEffect;\n", "const getEnvPlayerVersion = () => {\n try {\n // @ts-ignore\n return PLAYER_VERSION as string;\n } catch {}\n return 'UNKNOWN';\n};\n\nconst player_version: string = getEnvPlayerVersion();\n\nexport const getPlayerVersion = () => player_version;\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/src/common/utils.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// NOTE: As a forward-looking implementation, we may want to assume
|
|
2
|
-
// prop names -> attribute names is always a simple name.toLowerCase()
|
|
3
|
-
// and provide a mechanism for passing in per-component overrides for
|
|
4
|
-
// e.g. kebab cases, as that's the way React/Preact handles these. (CJP)
|
|
5
|
-
const ReactPropToAttrNameMap = {
|
|
6
|
-
className: 'class',
|
|
7
|
-
classname: 'class',
|
|
8
|
-
htmlFor: 'for',
|
|
9
|
-
crossOrigin: 'crossorigin',
|
|
10
|
-
viewBox: 'viewBox',
|
|
11
|
-
playsInline: 'playsinline',
|
|
12
|
-
autoPlay: 'autoplay',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type KeyTypes = string | number | symbol;
|
|
16
|
-
|
|
17
|
-
export const isNil = (x: unknown): x is null | undefined => x == undefined;
|
|
18
|
-
|
|
19
|
-
// Type Guard to determine if a given key is actually a key of some object of type T
|
|
20
|
-
export const isKeyOf = <T = unknown>(k: KeyTypes, o: T): k is keyof T => {
|
|
21
|
-
if (isNil(o)) return false;
|
|
22
|
-
return k in o;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const toKebabCase = (string: string) => string.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
26
|
-
|
|
27
|
-
export const toNativeAttrName = (propName: string, propValue: any): string | undefined => {
|
|
28
|
-
if (typeof propValue === 'boolean' && !propValue) return undefined;
|
|
29
|
-
if (isKeyOf(propName, ReactPropToAttrNameMap)) return ReactPropToAttrNameMap[propName];
|
|
30
|
-
if (typeof propValue == undefined) return undefined;
|
|
31
|
-
if (/[A-Z]/.test(propName)) return toKebabCase(propName);
|
|
32
|
-
return propName;
|
|
33
|
-
};
|
|
34
|
-
export const toStyleAttr = <T>(x: T) => x;
|
|
35
|
-
|
|
36
|
-
export const toNativeAttrValue = (propValue: any, propName: string) => {
|
|
37
|
-
if (typeof propValue === 'boolean') return '';
|
|
38
|
-
return propValue;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const toNativeProps = (props = {}) => {
|
|
42
|
-
return Object.entries(props).reduce<{ [k: string]: string }>((transformedProps, [propName, propValue]) => {
|
|
43
|
-
const attrName = toNativeAttrName(propName, propValue);
|
|
44
|
-
|
|
45
|
-
// prop was stripped. Don't add.
|
|
46
|
-
if (!attrName) {
|
|
47
|
-
return transformedProps;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const attrValue = toNativeAttrValue(propValue, propName);
|
|
51
|
-
transformedProps[attrName] = attrValue;
|
|
52
|
-
return transformedProps;
|
|
53
|
-
}, {});
|
|
54
|
-
};
|
package/src/env.ts
DELETED
package/src/index.tsx
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import type { CSSProperties } from 'react';
|
|
3
|
-
import type { StreamTypes } from '@mux/playback-core';
|
|
4
|
-
import '@mux/mux-player';
|
|
5
|
-
import type MuxPlayerElement from '@mux/mux-player';
|
|
6
|
-
import type { Tokens } from '@mux/mux-player';
|
|
7
|
-
import { toNativeProps } from './common/utils';
|
|
8
|
-
import { useRef } from 'react';
|
|
9
|
-
import { useCombinedRefs } from './useCombinedRefs';
|
|
10
|
-
import useObjectPropEffect, { defaultHasChanged } from './useObjectPropEffect';
|
|
11
|
-
import { getPlayerVersion } from './env';
|
|
12
|
-
|
|
13
|
-
type ValueOf<T> = T[keyof T];
|
|
14
|
-
|
|
15
|
-
export type MuxPlayerRefAttributes = MuxPlayerElement;
|
|
16
|
-
type VideoApiAttributes = {
|
|
17
|
-
currentTime: number;
|
|
18
|
-
volume: number;
|
|
19
|
-
paused: boolean;
|
|
20
|
-
src: string | null;
|
|
21
|
-
poster: string;
|
|
22
|
-
playbackRate: number;
|
|
23
|
-
playsInline: boolean;
|
|
24
|
-
preload: string;
|
|
25
|
-
crossOrigin: string;
|
|
26
|
-
autoPlay: boolean | string;
|
|
27
|
-
loop: boolean;
|
|
28
|
-
muted: boolean;
|
|
29
|
-
style: CSSProperties;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type MuxMediaPropTypes = {
|
|
33
|
-
audio: boolean;
|
|
34
|
-
// envKey: Options["data"]["env_key"];
|
|
35
|
-
envKey: string;
|
|
36
|
-
// debug: Options["debug"] & Hls["config"]["debug"];
|
|
37
|
-
debug: boolean;
|
|
38
|
-
// metadata: Partial<Options["data"]>;
|
|
39
|
-
metadata: { [k: string]: any };
|
|
40
|
-
beaconCollectionDomain: string;
|
|
41
|
-
customDomain: string;
|
|
42
|
-
playbackId: string;
|
|
43
|
-
preferMse: boolean;
|
|
44
|
-
streamType: ValueOf<StreamTypes> | 'vod';
|
|
45
|
-
startTime: number;
|
|
46
|
-
children: never[];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type MuxPlayerProps = {
|
|
50
|
-
defaultHiddenCaptions?: boolean;
|
|
51
|
-
playerSoftwareVersion?: string;
|
|
52
|
-
playerSoftwareName?: string;
|
|
53
|
-
forwardSeekOffset?: number;
|
|
54
|
-
backwardSeekOffset?: number;
|
|
55
|
-
metadataVideoId?: string;
|
|
56
|
-
metadataVideoTitle?: string;
|
|
57
|
-
metadataViewerUserId?: string;
|
|
58
|
-
primaryColor?: string;
|
|
59
|
-
secondaryColor?: string;
|
|
60
|
-
tertiaryColor?: string;
|
|
61
|
-
thumbnailTime?: number;
|
|
62
|
-
tokens?: Tokens;
|
|
63
|
-
onLoadStart?: EventListener;
|
|
64
|
-
onLoadedMetadata?: EventListener;
|
|
65
|
-
onProgress?: EventListener;
|
|
66
|
-
onDurationChange?: EventListener;
|
|
67
|
-
onVolumeChange?: EventListener;
|
|
68
|
-
onRateChange?: EventListener;
|
|
69
|
-
onResize?: EventListener;
|
|
70
|
-
onWaiting?: EventListener;
|
|
71
|
-
onPlay?: EventListener;
|
|
72
|
-
onPlaying?: EventListener;
|
|
73
|
-
onTimeUpdate?: EventListener;
|
|
74
|
-
onPause?: EventListener;
|
|
75
|
-
onSeeking?: EventListener;
|
|
76
|
-
onSeeked?: EventListener;
|
|
77
|
-
onEnded?: EventListener;
|
|
78
|
-
onError?: EventListener;
|
|
79
|
-
onPlayerReady?: EventListener;
|
|
80
|
-
} & Partial<MuxMediaPropTypes> &
|
|
81
|
-
Partial<VideoApiAttributes>;
|
|
82
|
-
|
|
83
|
-
const MuxPlayerInternal = React.forwardRef<MuxPlayerRefAttributes, MuxPlayerProps>(({ children, ...props }, ref) => {
|
|
84
|
-
return React.createElement('mux-player', toNativeProps({ ...props, ref }), children);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const useEventCallbackEffect = (
|
|
88
|
-
type: string,
|
|
89
|
-
ref: // | ((instance: EventTarget | null) => void)
|
|
90
|
-
React.MutableRefObject<EventTarget | null> | null | undefined,
|
|
91
|
-
callback: EventListener | undefined
|
|
92
|
-
) => {
|
|
93
|
-
return useEffect(() => {
|
|
94
|
-
const eventTarget = ref?.current;
|
|
95
|
-
if (!eventTarget || !callback) return;
|
|
96
|
-
eventTarget.addEventListener(type, callback);
|
|
97
|
-
return () => {
|
|
98
|
-
eventTarget.removeEventListener(type, callback);
|
|
99
|
-
};
|
|
100
|
-
}, [ref?.current, callback]);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const usePlayer = (
|
|
104
|
-
ref: // | ((instance: EventTarget | null) => void)
|
|
105
|
-
React.MutableRefObject<MuxPlayerElement | null> | null | undefined,
|
|
106
|
-
props: MuxPlayerProps
|
|
107
|
-
) => {
|
|
108
|
-
const {
|
|
109
|
-
onLoadStart,
|
|
110
|
-
onLoadedMetadata,
|
|
111
|
-
onProgress,
|
|
112
|
-
onDurationChange,
|
|
113
|
-
onVolumeChange,
|
|
114
|
-
onRateChange,
|
|
115
|
-
onResize,
|
|
116
|
-
onWaiting,
|
|
117
|
-
onPlay,
|
|
118
|
-
onPlaying,
|
|
119
|
-
onTimeUpdate,
|
|
120
|
-
onPause,
|
|
121
|
-
onSeeking,
|
|
122
|
-
onSeeked,
|
|
123
|
-
onEnded,
|
|
124
|
-
onError,
|
|
125
|
-
onPlayerReady,
|
|
126
|
-
metadata,
|
|
127
|
-
tokens,
|
|
128
|
-
paused,
|
|
129
|
-
playbackId,
|
|
130
|
-
...remainingProps
|
|
131
|
-
} = props;
|
|
132
|
-
useObjectPropEffect('metadata', metadata, ref);
|
|
133
|
-
useObjectPropEffect('tokens', tokens, ref);
|
|
134
|
-
useObjectPropEffect('playbackId', playbackId, ref);
|
|
135
|
-
useObjectPropEffect(
|
|
136
|
-
'paused',
|
|
137
|
-
paused,
|
|
138
|
-
ref,
|
|
139
|
-
(playerEl: HTMLMediaElement, pausedVal?: boolean) => {
|
|
140
|
-
if (pausedVal == null) return;
|
|
141
|
-
if (pausedVal) {
|
|
142
|
-
playerEl.pause();
|
|
143
|
-
} else {
|
|
144
|
-
playerEl.play();
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
(playerEl, value, propName) => {
|
|
148
|
-
if (playerEl.hasAttribute('autoplay') && !playerEl.hasPlayed) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
return defaultHasChanged(playerEl, value, propName);
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
useEventCallbackEffect('loadstart', ref, onLoadStart);
|
|
155
|
-
useEventCallbackEffect('loadedmetadata', ref, onLoadedMetadata);
|
|
156
|
-
useEventCallbackEffect('progress', ref, onProgress);
|
|
157
|
-
useEventCallbackEffect('durationchange', ref, onDurationChange);
|
|
158
|
-
useEventCallbackEffect('volumechange', ref, onVolumeChange);
|
|
159
|
-
useEventCallbackEffect('ratechange', ref, onRateChange);
|
|
160
|
-
useEventCallbackEffect('resize', ref, onResize);
|
|
161
|
-
useEventCallbackEffect('waiting', ref, onWaiting);
|
|
162
|
-
useEventCallbackEffect('play', ref, onPlay);
|
|
163
|
-
useEventCallbackEffect('playing', ref, onPlaying);
|
|
164
|
-
useEventCallbackEffect('timeupdate', ref, onTimeUpdate);
|
|
165
|
-
useEventCallbackEffect('pause', ref, onPause);
|
|
166
|
-
useEventCallbackEffect('seeking', ref, onSeeking);
|
|
167
|
-
useEventCallbackEffect('seeked', ref, onSeeked);
|
|
168
|
-
useEventCallbackEffect('ended', ref, onEnded);
|
|
169
|
-
useEventCallbackEffect('error', ref, onError);
|
|
170
|
-
useEventCallbackEffect('playerready', ref, onPlayerReady);
|
|
171
|
-
return [remainingProps];
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const playerSoftwareVersion = getPlayerVersion();
|
|
175
|
-
const playerSoftwareName = 'mux-player-react';
|
|
176
|
-
|
|
177
|
-
const MuxPlayer = React.forwardRef<
|
|
178
|
-
MuxPlayerRefAttributes,
|
|
179
|
-
Omit<MuxPlayerProps, 'playerSoftwareVersion' | 'playerSoftwareName'>
|
|
180
|
-
>((props, ref) => {
|
|
181
|
-
const {
|
|
182
|
-
/** @TODO Remove these once defaults are added to mux-player (CJP) */
|
|
183
|
-
forwardSeekOffset = 10,
|
|
184
|
-
backwardSeekOffset = 10,
|
|
185
|
-
} = props;
|
|
186
|
-
|
|
187
|
-
const innerPlayerRef = useRef<MuxPlayerElement>(null);
|
|
188
|
-
const playerRef = useCombinedRefs(innerPlayerRef, ref);
|
|
189
|
-
const [remainingProps] = usePlayer(innerPlayerRef, props);
|
|
190
|
-
|
|
191
|
-
return (
|
|
192
|
-
<MuxPlayerInternal
|
|
193
|
-
/** @TODO Fix types relationships (CJP) */
|
|
194
|
-
ref={playerRef as typeof innerPlayerRef}
|
|
195
|
-
playerSoftwareName={playerSoftwareName}
|
|
196
|
-
playerSoftwareVersion={playerSoftwareVersion}
|
|
197
|
-
forwardSeekOffset={forwardSeekOffset}
|
|
198
|
-
backwardSeekOffset={backwardSeekOffset}
|
|
199
|
-
{...remainingProps}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
export default MuxPlayer;
|
package/src/useCombinedRefs.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import type { MutableRefObject, ForwardedRef } from 'react';
|
|
3
|
-
|
|
4
|
-
type Maybe<T> = T | null | undefined;
|
|
5
|
-
type RefCb<T> = (instance: Maybe<T>) => void;
|
|
6
|
-
type RefObj<T> = MutableRefObject<Maybe<T>>;
|
|
7
|
-
type RefTypes<T> = RefObj<T> | RefCb<T> | ForwardedRef<T>;
|
|
8
|
-
interface useCombinedRefs {
|
|
9
|
-
<T>(...refs: Maybe<RefTypes<T>>[]): RefObj<T>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const useCombinedRefs: useCombinedRefs = (...refs) => {
|
|
13
|
-
const targetRef = useRef(null);
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
refs.forEach((ref) => {
|
|
17
|
-
if (!ref) return;
|
|
18
|
-
|
|
19
|
-
if (typeof ref === 'function') {
|
|
20
|
-
ref(targetRef.current);
|
|
21
|
-
} else {
|
|
22
|
-
ref.current = targetRef.current;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}, [refs]);
|
|
26
|
-
|
|
27
|
-
return targetRef;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default useCombinedRefs;
|