@mux/mux-video-react 0.5.2 → 0.5.3-canary.0-c569328

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/CHANGELOG.md ADDED
@@ -0,0 +1,93 @@
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.5.3](https://github.com/muxinc/elements/compare/@mux/mux-video-react@0.5.2...@mux/mux-video-react@0.5.3) (2022-09-01)
7
+
8
+ ### Bug Fixes
9
+
10
+ - cjs main entrypoint for React pkgs ([#360](https://github.com/muxinc/elements/issues/360)) ([473875f](https://github.com/muxinc/elements/commit/473875f4869a6ab9b04b44a90cc52b620a15ac83))
11
+
12
+ ## [0.5.2](https://github.com/muxinc/elements/compare/@mux/mux-video-react@0.5.1...@mux/mux-video-react@0.5.2) (2022-08-31)
13
+
14
+ **Note:** Version bump only for package @mux/mux-video-react
15
+
16
+ ## [0.5.1](https://github.com/muxinc/elements/compare/@mux/mux-video-react@0.5.0...@mux/mux-video-react@0.5.1) (2022-07-21)
17
+
18
+ **Note:** Version bump only for package @mux/mux-video-react
19
+
20
+ # 0.5.0 (2022-07-05)
21
+
22
+ ### Bug Fixes
23
+
24
+ - **mux-video-react:** use generateInitTime() instead of Date.now. ([0f159c2](https://github.com/muxinc/elements/commit/0f159c233244404faec13e61f1dbbd8b7c4adc81))
25
+ - prettier format all elements files ([741d607](https://github.com/muxinc/elements/commit/741d607521ca9578cfad9f0a9216a6565b4c56a1))
26
+ - switch cjs extension to .cjs.js ([30e83c3](https://github.com/muxinc/elements/commit/30e83c3ce0bd9bfda4817c30ffe0921e425619e4))
27
+ - update react peerDependencies to allow ^18 ([1cfb019](https://github.com/muxinc/elements/commit/1cfb019b71cf9aa280abccaf4a7818d585b56d86))
28
+
29
+ ### Features
30
+
31
+ - add beaconCollectionDomain option to replace beaconDomain ([a44b699](https://github.com/muxinc/elements/commit/a44b699ae3138590b9d953f693f95971694658df))
32
+ - Extended autoplay options ([#116](https://github.com/muxinc/elements/issues/116)) ([475e838](https://github.com/muxinc/elements/commit/475e83884f641c578fa601c9501147d485fc1831))
33
+
34
+ ## [0.4.12](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.11...@mux-elements/mux-video-react@0.4.12) (2022-06-23)
35
+
36
+ **Note:** Version bump only for package @mux-elements/mux-video-react
37
+
38
+ ## [0.4.11](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.10...@mux-elements/mux-video-react@0.4.11) (2022-06-06)
39
+
40
+ **Note:** Version bump only for package @mux-elements/mux-video-react
41
+
42
+ ## [0.4.10](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.9...@mux-elements/mux-video-react@0.4.10) (2022-05-26)
43
+
44
+ **Note:** Version bump only for package @mux-elements/mux-video-react
45
+
46
+ ## [0.4.9](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.8...@mux-elements/mux-video-react@0.4.9) (2022-05-23)
47
+
48
+ **Note:** Version bump only for package @mux-elements/mux-video-react
49
+
50
+ ## [0.4.8](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.7...@mux-elements/mux-video-react@0.4.8) (2022-05-20)
51
+
52
+ ### Bug Fixes
53
+
54
+ - switch cjs extension to .cjs.js ([30e83c3](https://github.com/muxinc/elements/commit/30e83c3ce0bd9bfda4817c30ffe0921e425619e4))
55
+
56
+ ## [0.4.7](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.6...@mux-elements/mux-video-react@0.4.7) (2022-05-10)
57
+
58
+ **Note:** Version bump only for package @mux-elements/mux-video-react
59
+
60
+ ## [0.4.6](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.5...@mux-elements/mux-video-react@0.4.6) (2022-05-03)
61
+
62
+ **Note:** Version bump only for package @mux-elements/mux-video-react
63
+
64
+ ## [0.4.5](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.4...@mux-elements/mux-video-react@0.4.5) (2022-04-22)
65
+
66
+ **Note:** Version bump only for package @mux-elements/mux-video-react
67
+
68
+ ## [0.4.4](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.3...@mux-elements/mux-video-react@0.4.4) (2022-04-18)
69
+
70
+ **Note:** Version bump only for package @mux-elements/mux-video-react
71
+
72
+ ## [0.4.3](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.2...@mux-elements/mux-video-react@0.4.3) (2022-04-12)
73
+
74
+ **Note:** Version bump only for package @mux-elements/mux-video-react
75
+
76
+ ## [0.4.2](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.1...@mux-elements/mux-video-react@0.4.2) (2022-04-01)
77
+
78
+ **Note:** Version bump only for package @mux-elements/mux-video-react
79
+
80
+ ## [0.4.1](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.4.0...@mux-elements/mux-video-react@0.4.1) (2022-03-29)
81
+
82
+ **Note:** Version bump only for package @mux-elements/mux-video-react
83
+
84
+ # [0.4.0](https://github.com/muxinc/elements/compare/@mux-elements/mux-video-react@0.3.0...@mux-elements/mux-video-react@0.4.0) (2022-03-28)
85
+
86
+ ### Bug Fixes
87
+
88
+ - **mux-video-react:** use generateInitTime() instead of Date.now. ([0f159c2](https://github.com/muxinc/elements/commit/0f159c233244404faec13e61f1dbbd8b7c4adc81))
89
+ - prettier format all elements files ([741d607](https://github.com/muxinc/elements/commit/741d607521ca9578cfad9f0a9216a6565b4c56a1))
90
+
91
+ ### Features
92
+
93
+ - add beaconCollectionDomain option to replace beaconDomain ([a44b699](https://github.com/muxinc/elements/commit/a44b699ae3138590b9d953f693f95971694658df))
package/dist/cjs.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "inputs": {
3
+ "src/use-combined-refs.ts": {
4
+ "bytes": 697,
5
+ "imports": []
6
+ },
7
+ "src/env.ts": {
8
+ "bytes": 391,
9
+ "imports": []
10
+ },
11
+ "src/index.tsx": {
12
+ "bytes": 2627,
13
+ "imports": [
14
+ {
15
+ "path": "src/use-combined-refs.ts",
16
+ "kind": "import-statement"
17
+ },
18
+ {
19
+ "path": "src/env.ts",
20
+ "kind": "import-statement"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ "outputs": {
26
+ "dist/index.cjs.js.map": {
27
+ "imports": [],
28
+ "exports": [],
29
+ "inputs": {},
30
+ "bytes": 6569
31
+ },
32
+ "dist/index.cjs.js": {
33
+ "imports": [],
34
+ "exports": [],
35
+ "entryPoint": "src/index.tsx",
36
+ "inputs": {
37
+ "src/index.tsx": {
38
+ "bytesInOutput": 1267
39
+ },
40
+ "src/use-combined-refs.ts": {
41
+ "bytesInOutput": 175
42
+ },
43
+ "src/env.ts": {
44
+ "bytesInOutput": 67
45
+ }
46
+ },
47
+ "bytes": 2118
48
+ }
49
+ }
50
+ }
package/dist/esm.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "inputs": {
3
+ "src/use-combined-refs.ts": {
4
+ "bytes": 697,
5
+ "imports": []
6
+ },
7
+ "src/env.ts": {
8
+ "bytes": 391,
9
+ "imports": []
10
+ },
11
+ "src/index.tsx": {
12
+ "bytes": 2627,
13
+ "imports": [
14
+ {
15
+ "path": "src/use-combined-refs.ts",
16
+ "kind": "import-statement"
17
+ },
18
+ {
19
+ "path": "src/env.ts",
20
+ "kind": "import-statement"
21
+ }
22
+ ]
23
+ }
24
+ },
25
+ "outputs": {
26
+ "dist/index.mjs.map": {
27
+ "imports": [],
28
+ "exports": [],
29
+ "inputs": {},
30
+ "bytes": 6795
31
+ },
32
+ "dist/index.mjs": {
33
+ "imports": [],
34
+ "exports": [
35
+ "default"
36
+ ],
37
+ "entryPoint": "src/index.tsx",
38
+ "inputs": {
39
+ "src/use-combined-refs.ts": {
40
+ "bytesInOutput": 178
41
+ },
42
+ "src/index.tsx": {
43
+ "bytesInOutput": 1052
44
+ },
45
+ "src/env.ts": {
46
+ "bytesInOutput": 67
47
+ }
48
+ },
49
+ "bytes": 1355
50
+ }
51
+ }
52
+ }
package/dist/index.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- var k=Object.create;var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var R=e=>u(e,"__esModule",{value:!0});var A=(e,t)=>{R(e);for(var o in t)u(e,o,{get:t[o],enumerable:!0})},N=(e,t,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of w(t))!I.call(e,s)&&s!=="default"&&u(e,s,{get:()=>t[s],enumerable:!(o=j(t,s))||o.enumerable});return e},l=e=>N(R(u(e!=null?k(H(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);A(exports,{default:()=>_});var f=l(require("react")),h=(...e)=>{let t=(0,f.useRef)(null);return(0,f.useEffect)(()=>{e.forEach(o=>{!o||(typeof o=="function"?o(t.current):o.current=t.current)})},[e]),t},P=h;var r=l(require("react")),a=l(require("prop-types")),n=l(require("@mux/playback-core"));var D=()=>{try{return"0.5.2"}catch{}return"UNKNOWN"},K=D(),g=()=>K;var U=g(),W="mux-video-react",x=r.default.forwardRef((e,t)=>{var M;let{envKey:o,debug:s,beaconCollectionDomain:z,playbackId:y,preferMse:B,type:Y,streamType:q,startTime:F,src:d,children:E,autoPlay:i,...V}=e,[v]=(0,r.useState)((0,n.generatePlayerInitTime)()),[T,O]=(0,r.useState)((M=(0,n.toMuxVideoURL)(y))!=null?M:d),m=(0,r.useRef)(void 0),S=(0,r.useRef)(null),[C,L]=(0,r.useState)(()=>c=>{}),b=P(S,t);return(0,r.useEffect)(()=>{var p;let c=(p=(0,n.toMuxVideoURL)(y))!=null?p:d;O(c)},[d,y]),(0,r.useEffect)(()=>{let c={...e,src:T,playerInitTime:v,playerSoftwareName:W,playerSoftwareVersion:U,autoplay:i},p=(0,n.initialize)(c,b.current,m.current);m.current=p,L(()=>(0,n.setupAutoplay)(b.current,i,m.current))},[T]),(0,r.useEffect)(()=>{C(i)},[i]),r.default.createElement("video",{ref:b,...V},E)});x.propTypes={envKey:a.default.string,debug:a.default.bool,metadata:a.default.any,beaconCollectionDomain:a.default.string,playbackId:a.default.string,playerInitTime:a.default.number,preferMse:a.default.bool,type:a.default.oneOf(n.allMediaTypes),streamType:a.default.oneOf(Object.values(n.StreamTypes)),startTime:a.default.number};var _=x;
1
+ "use strict";var k=Object.create;var u=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var N=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},R=(e,t,r,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of H(t))!A.call(e,i)&&i!==r&&u(e,i,{get:()=>t[i],enumerable:!(f=w(t,i))||f.enumerable});return e};var P=(e,t,r)=>(r=e!=null?k(I(e)):{},R(t||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)),h=e=>R(u({},"__esModule",{value:!0}),e);var B={};N(B,{default:()=>z});module.exports=h(B);var l=require("react"),D=(...e)=>{let t=(0,l.useRef)(null);return(0,l.useEffect)(()=>{e.forEach(r=>{!r||(typeof r=="function"?r(t.current):r.current=t.current)})},[e]),t},g=D;var n=P(require("react")),a=P(require("prop-types")),o=require("@mux/playback-core");var K=()=>{try{return"0.5.3"}catch{}return"UNKNOWN"},U=K(),E=()=>U;var W=E(),_="mux-video-react",x=n.default.forwardRef((e,t)=>{var M;let{envKey:r,debug:f,beaconCollectionDomain:i,playbackId:y,preferMse:Y,type:q,streamType:F,startTime:G,src:d,children:V,autoPlay:s,...O}=e,[v]=(0,n.useState)((0,o.generatePlayerInitTime)()),[T,S]=(0,n.useState)((M=(0,o.toMuxVideoURL)(y))!=null?M:d),m=(0,n.useRef)(void 0),C=(0,n.useRef)(null),[L,j]=(0,n.useState)(()=>c=>{}),b=g(C,t);return(0,n.useEffect)(()=>{var p;let c=(p=(0,o.toMuxVideoURL)(y))!=null?p:d;S(c)},[d,y]),(0,n.useEffect)(()=>{let c={...e,src:T,playerInitTime:v,playerSoftwareName:_,playerSoftwareVersion:W,autoplay:s},p=(0,o.initialize)(c,b.current,m.current);m.current=p,j(()=>(0,o.setupAutoplay)(b.current,s,m.current))},[T]),(0,n.useEffect)(()=>{L(s)},[s]),n.default.createElement("video",{ref:b,...O},V)});x.propTypes={envKey:a.default.string,debug:a.default.bool,metadata:a.default.any,beaconCollectionDomain:a.default.string,playbackId:a.default.string,playerInitTime:a.default.number,preferMse:a.default.bool,type:a.default.oneOf(o.allMediaTypes),streamType:a.default.oneOf(Object.values(o.StreamTypes)),startTime:a.default.number};var z=x;
2
2
  //# sourceMappingURL=index.cjs.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/index.tsx", "../src/use-combined-refs.ts", "../src/env.ts"],
4
4
  "sourcesContent": ["import useCombinedRefs from './use-combined-refs';\nimport React, { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n allMediaTypes,\n initialize,\n setupAutoplay,\n MuxMediaProps,\n StreamTypes,\n toMuxVideoURL,\n PlaybackEngine,\n generatePlayerInitTime,\n} from '@mux/playback-core';\nimport { getPlayerVersion } from './env';\n\nexport type Props = Omit<\n React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>,\n 'autoPlay'\n> &\n MuxMediaProps;\n\nconst playerSoftwareVersion = getPlayerVersion();\nconst playerSoftwareName = 'mux-video-react';\n\nconst MuxVideo = React.forwardRef<HTMLVideoElement | undefined, Partial<Props>>((props, ref) => {\n const {\n envKey,\n debug,\n beaconCollectionDomain,\n playbackId,\n preferMse,\n type,\n streamType,\n startTime,\n src: outerSrc,\n children,\n autoPlay,\n ...restProps\n } = props;\n\n const [playerInitTime] = useState(generatePlayerInitTime());\n\n const [src, setSrc] = useState<MuxMediaProps['src']>(toMuxVideoURL(playbackId) ?? outerSrc);\n\n const playbackEngineRef = useRef<PlaybackEngine | undefined>(undefined);\n const innerMediaElRef = useRef<HTMLVideoElement>(null);\n const [updateAutoplay, setUpdateAutoplay] = useState(() => (x: any) => {});\n\n const mediaElRef = useCombinedRefs(innerMediaElRef, ref);\n\n useEffect(() => {\n const src = toMuxVideoURL(playbackId) ?? outerSrc;\n setSrc(src);\n }, [outerSrc, playbackId]);\n\n useEffect(() => {\n const propsWithState = {\n ...props,\n src,\n playerInitTime,\n playerSoftwareName,\n playerSoftwareVersion,\n autoplay: autoPlay,\n };\n const nextPlaybackEngineRef = initialize(propsWithState, mediaElRef.current, playbackEngineRef.current);\n playbackEngineRef.current = nextPlaybackEngineRef;\n setUpdateAutoplay(() => setupAutoplay(mediaElRef.current, autoPlay, playbackEngineRef.current));\n }, [src]);\n\n useEffect(() => {\n updateAutoplay(autoPlay);\n }, [autoPlay]);\n\n return (\n <video ref={mediaElRef} {...restProps}>\n {children}\n </video>\n );\n});\n\nMuxVideo.propTypes = {\n envKey: PropTypes.string,\n debug: PropTypes.bool,\n // Improve this by adding a full shape() definition for all metadata props\n // metadata: PropTypes.shape({}),\n metadata: PropTypes.any,\n beaconCollectionDomain: PropTypes.string,\n playbackId: PropTypes.string,\n playerInitTime: PropTypes.number,\n preferMse: PropTypes.bool,\n type: PropTypes.oneOf(allMediaTypes),\n streamType: PropTypes.oneOf(Object.values(StreamTypes)),\n startTime: PropTypes.number,\n};\n\nexport default MuxVideo;\n", "import { useEffect, useRef, MutableRefObject } 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>;\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", "export const isMaybeBrowser = () => typeof window != 'undefined';\n// @ts-ignore\nexport const isMaybeServer = () => typeof global != 'undefined';\n\nconst 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": "mlBAAA,2BCAA,MAAoD,oBAUvC,EAAmC,IAAI,IAAS,CAC3D,GAAM,GAAY,aAAO,MAEzB,sBAAU,IAAM,CACd,EAAK,QAAQ,AAAC,GAAQ,CACpB,AAAI,CAAC,GAEL,CAAI,MAAO,IAAQ,WACjB,EAAI,EAAU,SAEd,EAAI,QAAU,EAAU,YAG3B,CAAC,IAEG,GAGF,EAAQ,ED3Bf,MAAmD,oBACnD,EAAsB,yBACtB,EASO,iCERP,GAAM,GAAsB,IAAM,CAChC,GAAI,CAEF,MAAO,aACP,EACF,MAAO,WAGH,EAAyB,IAElB,EAAmB,IAAM,EFOtC,GAAM,GAAwB,IACxB,EAAqB,kBAErB,EAAW,UAAM,WAAyD,CAAC,EAAO,IAAQ,CAxBhG,MAyBE,GAAM,CACJ,SACA,QACA,yBACA,aACA,YACA,OACA,aACA,YACA,IAAK,EACL,WACA,cACG,GACD,EAEE,CAAC,GAAkB,eAAS,gCAE5B,CAAC,EAAK,GAAU,eAA+B,uBAAc,KAAd,OAA6B,GAE5E,EAAoB,aAAmC,QACvD,EAAkB,aAAyB,MAC3C,CAAC,EAAgB,GAAqB,eAAS,IAAM,AAAC,GAAW,IAEjE,EAAa,EAAgB,EAAiB,GAEpD,sBAAU,IAAM,CAlDlB,MAmDI,GAAM,GAAM,uBAAc,KAAd,OAA6B,EACzC,EAAO,IACN,CAAC,EAAU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A,QAAU,OAC1B,UAAW,EAAAA,QAAU,KACrB,KAAM,EAAAA,QAAU,MAAM,eAAa,EACnC,WAAY,EAAAA,QAAU,MAAM,OAAO,OAAO,aAAW,CAAC,EACtD,UAAW,EAAAA,QAAU,MACvB,EAEA,IAAOC,EAAQ9B",
6
+ "names": ["src_exports", "__export", "src_default", "__toCommonJS", "import_react", "useCombinedRefs", "refs", "targetRef", "ref", "use_combined_refs_default", "import_react", "import_prop_types", "import_playback_core", "getEnvPlayerVersion", "player_version", "getPlayerVersion", "playerSoftwareVersion", "getPlayerVersion", "playerSoftwareName", "MuxVideo", "React", "props", "ref", "_a", "envKey", "debug", "beaconCollectionDomain", "playbackId", "preferMse", "type", "streamType", "startTime", "outerSrc", "children", "autoPlay", "restProps", "playerInitTime", "src", "setSrc", "playbackEngineRef", "innerMediaElRef", "updateAutoplay", "setUpdateAutoplay", "x", "mediaElRef", "use_combined_refs_default", "propsWithState", "nextPlaybackEngineRef", "PropTypes", "src_default"]
7
7
  }
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{useEffect as C,useRef as L}from"react";var k=(...t)=>{let r=L(null);return C(()=>{t.forEach(n=>{!n||(typeof n=="function"?n(r.current):n.current=r.current)})},[t]),r},m=k;import T,{useEffect as l,useRef as M,useState as f}from"react";import e from"prop-types";import{allMediaTypes as H,initialize as I,setupAutoplay as A,StreamTypes as N,toMuxVideoURL as R,generatePlayerInitTime as h}from"@mux/playback-core";var j=()=>{try{return"0.5.2"}catch{}return"UNKNOWN"},w=j(),b=()=>w;var D=b(),K="mux-video-react",P=T.forwardRef((t,r)=>{var d;let{envKey:n,debug:U,beaconCollectionDomain:W,playbackId:i,preferMse:_,type:z,streamType:B,startTime:Y,src:c,children:g,autoPlay:o,...x}=t,[E]=f(h()),[y,V]=f((d=R(i))!=null?d:c),p=M(void 0),v=M(null),[O,S]=f(()=>a=>{}),u=m(v,r);return l(()=>{var s;let a=(s=R(i))!=null?s:c;V(a)},[c,i]),l(()=>{let a={...t,src:y,playerInitTime:E,playerSoftwareName:K,playerSoftwareVersion:D,autoplay:o},s=I(a,u.current,p.current);p.current=s,S(()=>A(u.current,o,p.current))},[y]),l(()=>{O(o)},[o]),T.createElement("video",{ref:u,...x},g)});P.propTypes={envKey:e.string,debug:e.bool,metadata:e.any,beaconCollectionDomain:e.string,playbackId:e.string,playerInitTime:e.number,preferMse:e.bool,type:e.oneOf(H),streamType:e.oneOf(Object.values(N)),startTime:e.number};var ne=P;export{ne as default};
1
+ import{useEffect as C,useRef as L}from"react";var j=(...t)=>{let r=L(null);return C(()=>{t.forEach(n=>{!n||(typeof n=="function"?n(r.current):n.current=r.current)})},[t]),r},m=j;import T,{useEffect as l,useRef as M,useState as f}from"react";import e from"prop-types";import{allMediaTypes as H,initialize as I,setupAutoplay as A,StreamTypes as N,toMuxVideoURL as R,generatePlayerInitTime as h}from"@mux/playback-core";var k=()=>{try{return"0.5.3"}catch{}return"UNKNOWN"},w=k(),b=()=>w;var D=b(),K="mux-video-react",P=T.forwardRef((t,r)=>{var d;let{envKey:n,debug:U,beaconCollectionDomain:W,playbackId:s,preferMse:_,type:z,streamType:B,startTime:Y,src:c,children:g,autoPlay:o,...E}=t,[x]=f(h()),[y,V]=f((d=R(s))!=null?d:c),p=M(void 0),O=M(null),[v,S]=f(()=>a=>{}),u=m(O,r);return l(()=>{var i;let a=(i=R(s))!=null?i:c;V(a)},[c,s]),l(()=>{let a={...t,src:y,playerInitTime:x,playerSoftwareName:K,playerSoftwareVersion:D,autoplay:o},i=I(a,u.current,p.current);p.current=i,S(()=>A(u.current,o,p.current))},[y]),l(()=>{v(o)},[o]),T.createElement("video",{ref:u,...E},g)});P.propTypes={envKey:e.string,debug:e.bool,metadata:e.any,beaconCollectionDomain:e.string,playbackId:e.string,playerInitTime:e.number,preferMse:e.bool,type:e.oneOf(H),streamType:e.oneOf(Object.values(N)),startTime:e.number};var ne=P;export{ne as default};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/use-combined-refs.ts", "../src/index.tsx", "../src/env.ts"],
4
4
  "sourcesContent": ["import { useEffect, useRef, MutableRefObject } 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>;\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 useCombinedRefs from './use-combined-refs';\nimport React, { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n allMediaTypes,\n initialize,\n setupAutoplay,\n MuxMediaProps,\n StreamTypes,\n toMuxVideoURL,\n PlaybackEngine,\n generatePlayerInitTime,\n} from '@mux/playback-core';\nimport { getPlayerVersion } from './env';\n\nexport type Props = Omit<\n React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>,\n 'autoPlay'\n> &\n MuxMediaProps;\n\nconst playerSoftwareVersion = getPlayerVersion();\nconst playerSoftwareName = 'mux-video-react';\n\nconst MuxVideo = React.forwardRef<HTMLVideoElement | undefined, Partial<Props>>((props, ref) => {\n const {\n envKey,\n debug,\n beaconCollectionDomain,\n playbackId,\n preferMse,\n type,\n streamType,\n startTime,\n src: outerSrc,\n children,\n autoPlay,\n ...restProps\n } = props;\n\n const [playerInitTime] = useState(generatePlayerInitTime());\n\n const [src, setSrc] = useState<MuxMediaProps['src']>(toMuxVideoURL(playbackId) ?? outerSrc);\n\n const playbackEngineRef = useRef<PlaybackEngine | undefined>(undefined);\n const innerMediaElRef = useRef<HTMLVideoElement>(null);\n const [updateAutoplay, setUpdateAutoplay] = useState(() => (x: any) => {});\n\n const mediaElRef = useCombinedRefs(innerMediaElRef, ref);\n\n useEffect(() => {\n const src = toMuxVideoURL(playbackId) ?? outerSrc;\n setSrc(src);\n }, [outerSrc, playbackId]);\n\n useEffect(() => {\n const propsWithState = {\n ...props,\n src,\n playerInitTime,\n playerSoftwareName,\n playerSoftwareVersion,\n autoplay: autoPlay,\n };\n const nextPlaybackEngineRef = initialize(propsWithState, mediaElRef.current, playbackEngineRef.current);\n playbackEngineRef.current = nextPlaybackEngineRef;\n setUpdateAutoplay(() => setupAutoplay(mediaElRef.current, autoPlay, playbackEngineRef.current));\n }, [src]);\n\n useEffect(() => {\n updateAutoplay(autoPlay);\n }, [autoPlay]);\n\n return (\n <video ref={mediaElRef} {...restProps}>\n {children}\n </video>\n );\n});\n\nMuxVideo.propTypes = {\n envKey: PropTypes.string,\n debug: PropTypes.bool,\n // Improve this by adding a full shape() definition for all metadata props\n // metadata: PropTypes.shape({}),\n metadata: PropTypes.any,\n beaconCollectionDomain: PropTypes.string,\n playbackId: PropTypes.string,\n playerInitTime: PropTypes.number,\n preferMse: PropTypes.bool,\n type: PropTypes.oneOf(allMediaTypes),\n streamType: PropTypes.oneOf(Object.values(StreamTypes)),\n startTime: PropTypes.number,\n};\n\nexport default MuxVideo;\n", "export const isMaybeBrowser = () => typeof window != 'undefined';\n// @ts-ignore\nexport const isMaybeServer = () => typeof global != 'undefined';\n\nconst 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": "AAAA,8CAUO,GAAM,GAAmC,IAAI,IAAS,CAC3D,GAAM,GAAY,EAAO,MAEzB,SAAU,IAAM,CACd,EAAK,QAAQ,AAAC,GAAQ,CACpB,AAAI,CAAC,GAEL,CAA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CAlDlB,IAAA3B,EAmDI,IAAMgB,GAAMhB,EAAAkB,EAAcd,CAAU,IAAxB,KAAAJ,EAA6BS,EACzCQ,EAAOD,CAAG,CACZ,EAAG,CAACP,EAAUL,CAAU,CAAC,EAEzBuB,EAAU,IAAM,CACd,IAAMC,EAAiB,CACrB,GAAG9B,EACH,IAAAkB,EACA,eAAAH,EACA,mBAAAlB,EACA,sBAAAF,EACA,SAAUkB,CACZ,EACMkB,EAAwBC,EAAWF,EAAgBH,EAAW,QAASN,EAAkB,OAAO,EACtGA,EAAkB,QAAUU,EAC5BN,EAAkB,IAAMQ,EAAcN,EAAW,QAASd,EAAUQ,EAAkB,OAAO,CAAC,CAChG,EAAG,CAACH,CAAG,CAAC,EAERW,EAAU,IAAM,CACdL,EAAeX,CAAQ,CACzB,EAAG,CAACA,CAAQ,CAAC,EAGXd,EAAA,cAAC,SAAM,IAAK4B,EAAa,GAAGb,GACzBF,CACH,CAEJ,CAAC,EAEDd,EAAS,UAAY,CACnB,OAAQoC,EAAU,OAClB,MAAOA,EAAU,KAGjB,SAAUA,EAAU,IACpB,uBAAwBA,EAAU,OAClC,WAAYA,EAAU,OACtB,eAAgBA,EAAU,OAC1B,UAAWA,EAAU,KACrB,KAAMA,EAAU,MAAMC,CAAa,EACnC,WAAYD,EAAU,MAAM,OAAO,OAAOE,CAAW,CAAC,EACtD,UAAWF,EAAU,MACvB,EAEA,IAAOG,GAAQvC",
6
+ "names": ["useEffect", "useRef", "useCombinedRefs", "refs", "targetRef", "ref", "use_combined_refs_default", "React", "useEffect", "useRef", "useState", "PropTypes", "allMediaTypes", "initialize", "setupAutoplay", "StreamTypes", "toMuxVideoURL", "generatePlayerInitTime", "getEnvPlayerVersion", "player_version", "getPlayerVersion", "playerSoftwareVersion", "getPlayerVersion", "playerSoftwareName", "MuxVideo", "React", "props", "ref", "_a", "envKey", "debug", "beaconCollectionDomain", "playbackId", "preferMse", "type", "streamType", "startTime", "outerSrc", "children", "autoPlay", "restProps", "playerInitTime", "useState", "generatePlayerInitTime", "src", "setSrc", "toMuxVideoURL", "playbackEngineRef", "useRef", "innerMediaElRef", "updateAutoplay", "setUpdateAutoplay", "x", "mediaElRef", "use_combined_refs_default", "useEffect", "propsWithState", "nextPlaybackEngineRef", "initialize", "setupAutoplay", "PropTypes", "allMediaTypes", "StreamTypes", "src_default"]
7
7
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@mux/mux-video-react",
3
- "version": "0.5.2",
3
+ "version": "0.5.3-canary.0-c569328",
4
4
  "description": "A custom mux video element for React that Just Works™",
5
- "main": "dist/index.js",
5
+ "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "exports": {
8
8
  "import": "./dist/index.mjs",
@@ -26,8 +26,8 @@
26
26
  "license": "MIT",
27
27
  "scripts": {
28
28
  "clean": "shx rm -rf dist/",
29
- "dev:cjs": "open-process | yarn build:cjs --watch",
30
- "dev:esm": "open-process | yarn build:esm --watch",
29
+ "dev:cjs": "yarn build:cjs --watch=forever",
30
+ "dev:esm": "yarn build:esm --watch=forever",
31
31
  "dev:types": "yarn build:types -w",
32
32
  "dev": "npm-run-all --parallel dev:types dev:cjs dev:esm",
33
33
  "build:cjs": "esbuild src/index.tsx --target=es2019 --bundle --sourcemap --metafile=./dist/cjs.json --format=cjs --outdir=dist --out-extension:.js=.cjs.js --external:react --external:prop-types --external:@mux/* --define:PLAYER_VERSION=\"'$npm_package_version'\"",
@@ -53,20 +53,21 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@mux/playback-core": "0.10.0",
56
+ "@mux/mux-audio-react": "0.4.2-canary.35-c569328",
57
+ "@mux/mux-elements-codemod": "1.1.2-canary.35-c569328",
58
+ "@mux/mux-uploader-react": "0.1.0-canary.34-c569328",
59
+ "@mux/playback-core": "0.9.1-canary.34-c569328",
57
60
  "prop-types": "^15.7.2"
58
61
  },
59
62
  "devDependencies": {
60
- "@mux/open-process": "0.1.0",
61
63
  "@types/react": "^17.0.37",
62
64
  "@types/react-dom": "^17.0.11",
63
65
  "downlevel-dts": "^0.9.0",
64
- "esbuild": "^0.13.13",
66
+ "esbuild": "^0.15.7",
65
67
  "npm-run-all": "^4.1.5",
66
68
  "react": "^17.0.2",
67
69
  "react-dom": "^17.0.2",
68
70
  "shx": "^0.3.4",
69
71
  "typescript": "^4.5.2"
70
- },
71
- "gitHead": "505f1e6e74b2caed83d2a54ec9f3660573e4d6e9"
72
+ }
72
73
  }
package/LICENSE DELETED
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Mux, Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.