@mux/mux-audio-react 0.4.1 → 0.4.2-canary.0-9766f4c

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/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var k=Object.create;var c=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=e=>c(e,"__esModule",{value:!0});var V=(e,t)=>{M(e);for(var o in t)c(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"&&c(e,s,{get:()=>t[s],enumerable:!(o=j(t,s))||o.enumerable});return e},l=e=>N(M(c(e!=null?k(H(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);V(exports,{default:()=>_});var y=l(require("react")),U=(...e)=>{let t=(0,y.useRef)(null);return(0,y.useEffect)(()=>{e.forEach(o=>{!o||(typeof o=="function"?o(t.current):o.current=t.current)})},[e]),t},P=U;var r=l(require("react")),a=l(require("prop-types")),n=l(require("@mux/playback-core"));var h=()=>{try{return"0.4.1"}catch{}return"UNKNOWN"},D=h(),g=()=>D;var K=g(),W="mux-audio-react",x=r.default.forwardRef((e,t)=>{var R;let{envKey:o,debug:s,beaconCollectionDomain:z,playbackId:f,preferMse:B,type:Y,streamType:q,startTime:F,src:d,children:E,autoPlay:i,...A}=e,[O]=(0,r.useState)((0,n.generatePlayerInitTime)()),[T,S]=(0,r.useState)((R=(0,n.toMuxVideoURL)(f))!=null?R:d),m=(0,r.useRef)(void 0),v=(0,r.useRef)(null),b=P(v,t),G=(0,r.useRef)(void 0),[C,L]=(0,r.useState)(()=>u=>{});return(0,r.useEffect)(()=>{var p;let u=(p=(0,n.toMuxVideoURL)(f))!=null?p:d;S(u)},[d,f]),(0,r.useEffect)(()=>{let u={...e,src:T,playerInitTime:O,playerSoftwareName:W,playerSoftwareVersion:K,autoplay:i},p=(0,n.initialize)(u,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("audio",{ref:b,...A},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
+ var k=Object.create;var c=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var M=e=>c(e,"__esModule",{value:!0});var V=(e,t)=>{M(e);for(var o in t)c(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"&&c(e,s,{get:()=>t[s],enumerable:!(o=j(t,s))||o.enumerable});return e},l=e=>N(M(c(e!=null?k(H(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);V(exports,{default:()=>_});var y=l(require("react")),U=(...e)=>{let t=(0,y.useRef)(null);return(0,y.useEffect)(()=>{e.forEach(o=>{!o||(typeof o=="function"?o(t.current):o.current=t.current)})},[e]),t},P=U;var r=l(require("react")),a=l(require("prop-types")),n=l(require("@mux/playback-core"));var h=()=>{try{return"0.4.2-canary.0-9766f4c"}catch{}return"UNKNOWN"},D=h(),g=()=>D;var K=g(),W="mux-audio-react",x=r.default.forwardRef((e,t)=>{var R;let{envKey:o,debug:s,beaconCollectionDomain:z,playbackId:f,preferMse:B,type:Y,streamType:q,startTime:F,src:d,children:E,autoPlay:i,...A}=e,[O]=(0,r.useState)((0,n.generatePlayerInitTime)()),[T,S]=(0,r.useState)((R=(0,n.toMuxVideoURL)(f))!=null?R:d),m=(0,r.useRef)(void 0),v=(0,r.useRef)(null),b=P(v,t),G=(0,r.useRef)(void 0),[C,L]=(0,r.useState)(()=>u=>{});return(0,r.useEffect)(()=>{var p;let u=(p=(0,n.toMuxVideoURL)(f))!=null?p:d;S(u)},[d,f]),(0,r.useEffect)(()=>{let u={...e,src:T,playerInitTime:O,playerSoftwareName:W,playerSoftwareVersion:K,autoplay:i},p=(0,n.initialize)(u,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("audio",{ref:b,...A},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;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -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 type Autoplay,\n type UpdateAutoplay,\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.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>,\n 'autoPlay'\n> &\n MuxMediaProps;\n\nconst playerSoftwareVersion = getPlayerVersion();\nconst playerSoftwareName = 'mux-audio-react';\n\nconst MuxAudio = React.forwardRef<HTMLAudioElement | 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<HTMLAudioElement>(null);\n\n const mediaElRef = useCombinedRefs(innerMediaElRef, ref);\n const updateAutoplayRef = useRef<UpdateAutoplay | undefined>(undefined);\n const [updateAutoplay, setUpdateAutoplay] = useState(() => (x: any) => {});\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 <audio ref={mediaElRef} {...restProps}>\n {children}\n </audio>\n );\n});\n\nMuxAudio.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 MuxAudio;\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,EAWO,iCEVP,GAAM,GAAsB,IAAM,CAChC,GAAI,CAEF,MAAO,aACP,EACF,MAAO,WAGH,EAAyB,IAElB,EAAmB,IAAM,EFStC,GAAM,GAAwB,IACxB,EAAqB,kBAErB,EAAW,UAAM,WAAyD,CAAC,EAAO,IAAQ,CA1BhG,MA2BE,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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yD,CAAC,EAAO,IAAQ,CA1BhG,MA2BE,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,MAE3C,EAAa,EAAgB,EAAiB,GAC9C,EAAoB,aAAmC,QACvD,CAAC,EAAgB,GAAqB,eAAS,IAAM,AAAC,GAAW,IAEvE,sBAAU,IAAM,CArDlB,MAsDI,GAAM,GAAM,uBAAc,KAAd,OAA6B,EACzC,EAAO,IACN,CAAC,EAAU,IAEd,gBAAU,IAAM,CACd,GAAM,GAAiB,IAClB,EACH,MACA,iBACA,qBACA,wBACA,SAAU,GAEN,EAAwB,iBAAW,EAAgB,EAAW,QAAS,EAAkB,SAC/F,EAAkB,QAAU,EAC5B,EAAkB,IAAM,oBAAc,EAAW,QAAS,EAAU,EAAkB,WACrF,CAAC,IAEJ,gBAAU,IAAM,CACd,EAAe,IACd,CAAC,IAGF,wBAAC,QAAD,CAAO,IAAK,KAAgB,GACzB,KAKP,EAAS,UAAY,CACnB,OAAQ,UAAU,OAClB,MAAO,UAAU,KAGjB,SAAU,UAAU,IACpB,uBAAwB,UAAU,OAClC,WAAY,UAAU,OACtB,eAAgB,UAAU,OAC1B,UAAW,UAAU,KACrB,KAAM,UAAU,MAAM,iBACtB,WAAY,UAAU,MAAM,OAAO,OAAO,gBAC1C,UAAW,UAAU,QAGvB,GAAO,GAAQ",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mux/mux-audio-react",
3
- "version": "0.4.1",
3
+ "version": "0.4.2-canary.0-9766f4c",
4
4
  "description": "A custom mux audio element for React that Just Works™",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types-ts3.4/index.d.ts",
@@ -45,7 +45,7 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@mux/playback-core": "0.9.0",
48
+ "@mux/playback-core": "0.9.1-canary.0-9766f4c",
49
49
  "prop-types": "^15.7.2"
50
50
  },
51
51
  "devDependencies": {
@@ -59,6 +59,5 @@
59
59
  "react-dom": "^17.0.2",
60
60
  "shx": "^0.3.4",
61
61
  "typescript": "^4.5.2"
62
- },
63
- "gitHead": "2d61f80adc7037225c22e2ac87519881677702d3"
62
+ }
64
63
  }
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.