@coorpacademy/components 10.26.1-alpha.1 → 10.27.1-alpha.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.
@@ -6,7 +6,7 @@ declare type Skin = {
6
6
  };
7
7
  declare type WebContextValues = {
8
8
  skin?: Skin;
9
- translate: (key: string) => string;
9
+ translate: (key: string, data: string) => string;
10
10
  };
11
11
  declare type Props = WebContextValues & {
12
12
  children: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"web-context.d.ts","sourceRoot":"","sources":["../../../src/atom/provider/web-context.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgB,SAAS,EAAa,MAAM,OAAO,CAAC;AAElE,aAAK,IAAI,GAAG;IACV,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,CAAC;AAMF,aAAK,KAAK,GAAG,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,UAAU,2BAA0B,KAAK,gBAE9C,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,gBAQhC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"web-context.d.ts","sourceRoot":"","sources":["../../../src/atom/provider/web-context.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgB,SAAS,EAAa,MAAM,OAAO,CAAC;AAElE,aAAK,IAAI,GAAG;IACV,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAClD,CAAC;AAMF,aAAK,KAAK,GAAG,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,UAAU,2BAA0B,KAAK,gBAE9C,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,gBAQhC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -4,7 +4,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
4
4
 
5
5
  import React, { createContext, useContext } from 'react';
6
6
  const Context = /*#__PURE__*/createContext({
7
- translate: key => key
7
+ translate: (key, data) => key
8
8
  });
9
9
 
10
10
  const WebContext = _ref => {
@@ -1 +1 @@
1
- {"version":3,"file":"web-context.js","names":["React","createContext","useContext","Context","translate","key","WebContext","children","value","useWebContext","context","Error"],"sources":["../../../src/atom/provider/web-context.tsx"],"sourcesContent":["import React, {createContext, ReactNode, useContext} from 'react';\n\ntype Skin = {\n common: {\n primary: string;\n };\n};\n\ntype WebContextValues = {\n skin?: Skin;\n translate: (key: string) => string;\n};\n\nconst Context = createContext({\n translate: (key: string) => key\n});\n\ntype Props = WebContextValues & {\n children: ReactNode;\n};\n\nconst WebContext = ({children, ...value}: Props) => {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useWebContext = (): WebContextValues => {\n const context = useContext(Context);\n\n if (!context) {\n throw new Error('❌ [WebContext] useWebContext must be used within a provider <WebContext>');\n }\n\n return context;\n};\n\nexport default WebContext;\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAeC,aAAf,EAAyCC,UAAzC,QAA0D,OAA1D;AAaA,MAAMC,OAAO,gBAAGF,aAAa,CAAC;EAC5BG,SAAS,EAAGC,GAAD,IAAiBA;AADA,CAAD,CAA7B;;AAQA,MAAMC,UAAU,GAAG,QAAiC;EAAA,IAAhC;IAACC;EAAD,CAAgC;EAAA,IAAlBC,KAAkB;;EAClD,oBAAO,oBAAC,OAAD,CAAS,QAAT;IAAkB,KAAK,EAAEA;EAAzB,GAAiCD,QAAjC,CAAP;AACD,CAFD;;AAIA,OAAO,MAAME,aAAa,GAAG,MAAwB;EACnD,MAAMC,OAAO,GAAGR,UAAU,CAACC,OAAD,CAA1B;;EAEA,IAAI,CAACO,OAAL,EAAc;IACZ,MAAM,IAAIC,KAAJ,CAAU,0EAAV,CAAN;EACD;;EAED,OAAOD,OAAP;AACD,CARM;AAUP,eAAeJ,UAAf"}
1
+ {"version":3,"file":"web-context.js","names":["React","createContext","useContext","Context","translate","key","data","WebContext","children","value","useWebContext","context","Error"],"sources":["../../../src/atom/provider/web-context.tsx"],"sourcesContent":["import React, {createContext, ReactNode, useContext} from 'react';\n\ntype Skin = {\n common: {\n primary: string;\n };\n};\n\ntype WebContextValues = {\n skin?: Skin;\n translate: (key: string, data: string) => string;\n};\n\nconst Context = createContext({\n translate: (key: string, data: string) => key\n});\n\ntype Props = WebContextValues & {\n children: ReactNode;\n};\n\nconst WebContext = ({children, ...value}: Props) => {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useWebContext = (): WebContextValues => {\n const context = useContext(Context);\n\n if (!context) {\n throw new Error('❌ [WebContext] useWebContext must be used within a provider <WebContext>');\n }\n\n return context;\n};\n\nexport default WebContext;\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAeC,aAAf,EAAyCC,UAAzC,QAA0D,OAA1D;AAaA,MAAMC,OAAO,gBAAGF,aAAa,CAAC;EAC5BG,SAAS,EAAE,CAACC,GAAD,EAAcC,IAAd,KAA+BD;AADd,CAAD,CAA7B;;AAQA,MAAME,UAAU,GAAG,QAAiC;EAAA,IAAhC;IAACC;EAAD,CAAgC;EAAA,IAAlBC,KAAkB;;EAClD,oBAAO,oBAAC,OAAD,CAAS,QAAT;IAAkB,KAAK,EAAEA;EAAzB,GAAiCD,QAAjC,CAAP;AACD,CAFD;;AAIA,OAAO,MAAME,aAAa,GAAG,MAAwB;EACnD,MAAMC,OAAO,GAAGT,UAAU,CAACC,OAAD,CAA1B;;EAEA,IAAI,CAACQ,OAAL,EAAc;IACZ,MAAM,IAAIC,KAAJ,CAAU,0EAAV,CAAN;EACD;;EAED,OAAOD,OAAP;AACD,CARM;AAUP,eAAeJ,UAAf"}
@@ -34,9 +34,9 @@ declare class JWPlayer extends React.Component<any, any, any> {
34
34
  onSetupError: import("prop-types").Requireable<(...args: any[]) => any>;
35
35
  onWarning: import("prop-types").Requireable<(...args: any[]) => any>;
36
36
  };
37
+ static getDerivedStateFromProps(props: any): any;
37
38
  constructor(props: any, context: any);
38
39
  state: {
39
- fileUrl: string;
40
40
  scriptFailedLoading: boolean;
41
41
  };
42
42
  handlePlay(e: any): void;
@@ -49,9 +49,7 @@ declare class JWPlayer extends React.Component<any, any, any> {
49
49
  handlePlayAttemptFailed(error: any): void;
50
50
  handleAutostartNotAllowed(error: any): void;
51
51
  handleWarning(error: any): void;
52
- componentDidMount(): void;
53
52
  componentDidUpdate(prevProps: any): void;
54
- setFileUrl(): void;
55
53
  render(): JSX.Element;
56
54
  }
57
55
  import React from "react";
@@ -1 +1 @@
1
- {"version":3,"file":"jwplayer.d.ts","sourceRoot":"","sources":["../../../src/molecule/video-player/jwplayer.js"],"names":[],"mappings":";AAMA;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAqC;IAErC,sCAiBC;IAfC;;;MAGC;IA6CH,yBAGC;IAED,2BAGC;IAED,0BAGC;IAED,0BAGC;IA6BD,8BAyBC;IA7CD,mCAGC;IAVD,qCAKC;IAOD,0CAGC;IAED,4CAGC;IAED,gCAGC;IA5ED,0BAIC;IAED,yCAgBC;IAED,mBAKC;IA4ED,sBA+BC;CACF"}
1
+ {"version":3,"file":"jwplayer.d.ts","sourceRoot":"","sources":["../../../src/molecule/video-player/jwplayer.js"],"names":[],"mappings":";AAoBA;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAqC;IAqBrC,iDAEC;IArBD,sCAiBC;IAdC;;MAEC;IAgCH,yBAGC;IAED,2BAGC;IAED,0BAGC;IAED,0BAGC;IA6BD,8BAyBC;IA7CD,mCAGC;IAVD,qCAKC;IAOD,0CAGC;IAED,4CAGC;IAED,gCAGC;IA3DD,yCAYC;IA4ED,sBAoCC;CACF"}
@@ -6,15 +6,30 @@ import _get from "lodash/fp/get";
6
6
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
7
7
 
8
8
  import React from 'react';
9
- import ReactJWPlayer from 'react-jw-player';
9
+ import Player from '@jwplayer/jwplayer-react';
10
10
  import style from './jwplayer.css';
11
11
  import { JWPlayerPropTypes } from './prop-types';
12
12
 
13
+ const fileAndTracks = ({
14
+ file,
15
+ customProps,
16
+ playlist
17
+ } = {}) => {
18
+ if (file) return {
19
+ file,
20
+ tracks: customProps ? customProps.tracks : null
21
+ };
22
+ if (playlist && playlist[0]) return playlist[0];
23
+ return {
24
+ file: null,
25
+ tracks: null
26
+ };
27
+ };
28
+
13
29
  class JWPlayer extends React.Component {
14
30
  constructor(props, context) {
15
31
  super(props, context);
16
32
  this.state = {
17
- fileUrl: '',
18
33
  scriptFailedLoading: false
19
34
  };
20
35
  this.handlePlay = this.handlePlay.bind(this);
@@ -29,12 +44,8 @@ class JWPlayer extends React.Component {
29
44
  this.handleWarning = this.handleWarning.bind(this);
30
45
  }
31
46
 
32
- componentDidMount() {
33
- const jwPlayerScript = document.getElementById('jw-player-script');
34
-
35
- jwPlayerScript.onerror = () => this.handleScriptError(jwPlayerScript);
36
-
37
- this.setFileUrl();
47
+ static getDerivedStateFromProps(props) {
48
+ return fileAndTracks(props.jwpOptions);
38
49
  }
39
50
 
40
51
  componentDidUpdate(prevProps) {
@@ -55,26 +66,6 @@ class JWPlayer extends React.Component {
55
66
  window.jwplayer(prevProps.jwpOptions.playerId).play();
56
67
  }
57
68
  }
58
-
59
- const {
60
- jwpOptions
61
- } = this.props;
62
-
63
- if (prevProps.jwpOptions.file !== jwpOptions.file) {
64
- this.setFileUrl();
65
- }
66
- }
67
-
68
- setFileUrl() {
69
- const {
70
- jwpOptions
71
- } = this.props;
72
- const {
73
- file
74
- } = jwpOptions;
75
- return this.setState({
76
- fileUrl: file
77
- });
78
69
  }
79
70
 
80
71
  handlePlay(e) {
@@ -171,7 +162,7 @@ class JWPlayer extends React.Component {
171
162
  if (matched) {
172
163
  const videoId = matched[1];
173
164
  return this.setState({
174
- fileUrl: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`
165
+ file: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`
175
166
  });
176
167
  }
177
168
  }
@@ -185,19 +176,27 @@ class JWPlayer extends React.Component {
185
176
  } = this.props;
186
177
  const {
187
178
  scriptFailedLoading,
188
- fileUrl
179
+ file,
180
+ tracks
189
181
  } = this.state;
190
182
 
191
183
  const _jwpOptions = _extends({}, jwpOptions, {
192
184
  customProps: _extends({}, _get('customProps', jwpOptions), {
185
+ key: jwpOptions.licenseKey,
193
186
  autostart: !disableAutostart && _get('customProps.autostart', jwpOptions)
194
187
  })
195
188
  });
196
189
 
197
190
  return /*#__PURE__*/React.createElement(React.Fragment, null, scriptFailedLoading ? /*#__PURE__*/React.createElement("p", {
198
191
  className: style.errorMessage
199
- }, scriptErrorMessage, " ") : null, /*#__PURE__*/React.createElement(ReactJWPlayer, _extends({}, _jwpOptions, {
192
+ }, scriptErrorMessage, " ") : null, /*#__PURE__*/React.createElement(Player, {
193
+ key: file,
200
194
  className: style.wrapper,
195
+ id: _jwpOptions.playerId,
196
+ file: file,
197
+ tracks: tracks,
198
+ library: _jwpOptions.playerScript,
199
+ config: _jwpOptions.customProps,
201
200
  onAutoStart: this.handlePlay,
202
201
  onPlay: this.handlePlay,
203
202
  onResume: this.handleResume,
@@ -207,9 +206,8 @@ class JWPlayer extends React.Component {
207
206
  onSetupError: this.handleSetupError,
208
207
  onPlayAttemptFailed: this.handlePlayAttemptFailed,
209
208
  onWarning: this.handleWarning,
210
- onAutostartNotAllowed: this.handleAutostartNotAllowed,
211
- file: fileUrl
212
- })));
209
+ onAutostartNotAllowed: this.handleAutostartNotAllowed
210
+ }));
213
211
  }
214
212
 
215
213
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jwplayer.js","names":["React","ReactJWPlayer","style","JWPlayerPropTypes","JWPlayer","Component","constructor","props","context","state","fileUrl","scriptFailedLoading","handlePlay","bind","handleResume","handlePause","handleEnded","handleError","handleSetupError","handleScriptError","handlePlayAttemptFailed","handleAutostartNotAllowed","handleWarning","componentDidMount","jwPlayerScript","document","getElementById","onerror","setFileUrl","componentDidUpdate","prevProps","changes","filter","key","current","prev","shouldStart","window","jwplayer","jwpOptions","playerId","play","file","setState","e","onPlay","onResume","onPause","onEnded","script","parentNode","removeChild","error","onSetupError","onPlayAttemptFailed","onAutostartNotAllowed","onWarning","onError","mimeType","code","videoUrl","regex","matched","match","videoId","render","disableAutostart","scriptErrorMessage","_jwpOptions","customProps","autostart","errorMessage","wrapper","propTypes"],"sources":["../../../src/molecule/video-player/jwplayer.js"],"sourcesContent":["import React from 'react';\nimport ReactJWPlayer from 'react-jw-player';\nimport {get, includes, isFunction, keys} from 'lodash/fp';\nimport style from './jwplayer.css';\nimport {JWPlayerPropTypes} from './prop-types';\n\nclass JWPlayer extends React.Component {\n static propTypes = JWPlayerPropTypes;\n\n constructor(props, context) {\n super(props, context);\n this.state = {\n fileUrl: '',\n scriptFailedLoading: false\n };\n\n this.handlePlay = this.handlePlay.bind(this);\n this.handleResume = this.handleResume.bind(this);\n this.handlePause = this.handlePause.bind(this);\n this.handleEnded = this.handleEnded.bind(this);\n this.handleError = this.handleError.bind(this);\n this.handleSetupError = this.handleSetupError.bind(this);\n this.handleScriptError = this.handleScriptError.bind(this);\n this.handlePlayAttemptFailed = this.handlePlayAttemptFailed.bind(this);\n this.handleAutostartNotAllowed = this.handleAutostartNotAllowed.bind(this);\n this.handleWarning = this.handleWarning.bind(this);\n }\n\n componentDidMount() {\n const jwPlayerScript = document.getElementById('jw-player-script');\n jwPlayerScript.onerror = () => this.handleScriptError(jwPlayerScript);\n this.setFileUrl();\n }\n\n componentDidUpdate(prevProps) {\n const changes = keys(this.props).filter(key => {\n const {[key]: current} = this.props;\n const {[key]: prev} = prevProps;\n return current !== prev;\n });\n const shouldStart = includes('autoplay', changes);\n if (shouldStart) {\n if (isFunction(window.jwplayer)) {\n window.jwplayer(prevProps.jwpOptions.playerId).play();\n }\n }\n const {jwpOptions} = this.props;\n if (prevProps.jwpOptions.file !== jwpOptions.file) {\n this.setFileUrl();\n }\n }\n\n setFileUrl() {\n const {jwpOptions} = this.props;\n const {file} = jwpOptions;\n\n return this.setState({fileUrl: file});\n }\n\n handlePlay(e) {\n const {onPlay} = this.props;\n if (onPlay) onPlay(e);\n }\n\n handleResume(e) {\n const {onResume} = this.props;\n if (onResume) onResume(e);\n }\n\n handlePause(e) {\n const {onPause} = this.props;\n if (onPause) onPause(e);\n }\n\n handleEnded(e) {\n const {onEnded} = this.props;\n if (onEnded) onEnded(e);\n }\n\n handleScriptError(script) {\n this.setState({scriptFailedLoading: true});\n if (script) {\n script.parentNode.removeChild();\n }\n }\n\n handleSetupError(error) {\n const {onSetupError} = this.props;\n if (onSetupError) onSetupError(error);\n }\n\n handlePlayAttemptFailed(error) {\n const {onPlayAttemptFailed} = this.props;\n if (onPlayAttemptFailed) onPlayAttemptFailed(error);\n }\n\n handleAutostartNotAllowed(error) {\n const {onAutostartNotAllowed} = this.props;\n if (onAutostartNotAllowed) onAutostartNotAllowed(error);\n }\n\n handleWarning(error) {\n const {onWarning} = this.props;\n if (onWarning) onWarning(error);\n }\n\n handleError(error) {\n const {onError, mimeType, jwpOptions} = this.props;\n const {code} = error;\n\n onError && onError(error);\n\n if (mimeType === 'application/kontiki') {\n return;\n }\n\n // This error mostly appears on IE11 on W7\n // Since IE11 dont kinda support M3U8 sometimes,\n // We've decided to switch from M3U8 to mp4 whenever it appears\n if (code === 214000) {\n const {file: videoUrl} = jwpOptions;\n const regex = /^https:\\/\\/content.jwplatform\\.com\\/manifests\\/(\\w+).m3u8/;\n const matched = videoUrl.match(regex);\n\n if (matched) {\n const videoId = matched[1];\n return this.setState({\n fileUrl: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`\n });\n }\n }\n }\n\n render() {\n const {jwpOptions, disableAutostart, scriptErrorMessage} = this.props;\n const {scriptFailedLoading, fileUrl} = this.state;\n const _jwpOptions = {\n ...jwpOptions,\n customProps: {\n ...get('customProps', jwpOptions),\n autostart: !disableAutostart && get('customProps.autostart', jwpOptions)\n }\n };\n\n return (\n <>\n {scriptFailedLoading ? <p className={style.errorMessage}>{scriptErrorMessage} </p> : null}\n <ReactJWPlayer\n {..._jwpOptions}\n className={style.wrapper}\n onAutoStart={this.handlePlay}\n onPlay={this.handlePlay}\n onResume={this.handleResume}\n onPause={this.handlePause}\n onOneHundredPercent={this.handleEnded}\n onError={this.handleError}\n onSetupError={this.handleSetupError}\n onPlayAttemptFailed={this.handlePlayAttemptFailed}\n onWarning={this.handleWarning}\n onAutostartNotAllowed={this.handleAutostartNotAllowed}\n file={fileUrl}\n />\n </>\n );\n }\n}\n\nexport default JWPlayer;\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AAEA,OAAOC,KAAP,MAAkB,gBAAlB;AACA,SAAQC,iBAAR,QAAgC,cAAhC;;AAEA,MAAMC,QAAN,SAAuBJ,KAAK,CAACK,SAA7B,CAAuC;EAGrCC,WAAW,CAACC,KAAD,EAAQC,OAAR,EAAiB;IAC1B,MAAMD,KAAN,EAAaC,OAAb;IACA,KAAKC,KAAL,GAAa;MACXC,OAAO,EAAE,EADE;MAEXC,mBAAmB,EAAE;IAFV,CAAb;IAKA,KAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAqB,IAArB,CAAlB;IACA,KAAK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DC,MAAM,GAAG;IACP,MAAM;MAAC1B,UAAD;MAAa2B,gBAAb;MAA+BC;IAA/B,IAAqD,KAAK5D,KAAhE;IACA,MAAM;MAACI,mBAAD;MAAsBD;IAAtB,IAAiC,KAAKD,KAA5C;;IACA,MAAM2D,WAAW,gBACZ7B,UADY;MAEf8B,WAAW,eACN,KAAI,aAAJ,EAAmB9B,UAAnB,CADM;QAET+B,SAAS,EAAE,CAACJ,gBAAD,IAAqB,KAAI,uBAAJ,EAA6B3B,UAA7B;MAFvB;IAFI,EAAjB;;IAQA,oBACE,0CACG5B,mBAAmB,gBAAG;MAAG,SAAS,EAAET,KAAK,CAACqE;IAApB,GAAmCJ,kBAAnC,MAAH,GAAiE,IADvF,eAEE,oBAAC,aAAD,eACMC,WADN;MAEE,SAAS,EAAElE,KAAK,CAACsE,OAFnB;MAGE,WAAW,EAAE,KAAK5D,UAHpB;MAIE,MAAM,EAAE,KAAKA,UAJf;MAKE,QAAQ,EAAE,KAAKE,YALjB;MAME,OAAO,EAAE,KAAKC,WANhB;MAOE,mBAAmB,EAAE,KAAKC,WAP5B;MAQE,OAAO,EAAE,KAAKC,WARhB;MASE,YAAY,EAAE,KAAKC,gBATrB;MAUE,mBAAmB,EAAE,KAAKE,uBAV5B;MAWE,SAAS,EAAE,KAAKE,aAXlB;MAYE,qBAAqB,EAAE,KAAKD,yBAZ9B;MAaE,IAAI,EAAEX;IAbR,GAFF,CADF;EAoBD;;AA9JoC;;AAAjCN,Q,CACGqE,S,2CAAYtE,iB;AAgKrB,eAAeC,QAAf"}
1
+ {"version":3,"file":"jwplayer.js","names":["React","Player","style","JWPlayerPropTypes","fileAndTracks","file","customProps","playlist","tracks","JWPlayer","Component","constructor","props","context","state","scriptFailedLoading","handlePlay","bind","handleResume","handlePause","handleEnded","handleError","handleSetupError","handleScriptError","handlePlayAttemptFailed","handleAutostartNotAllowed","handleWarning","getDerivedStateFromProps","jwpOptions","componentDidUpdate","prevProps","changes","filter","key","current","prev","shouldStart","window","jwplayer","playerId","play","e","onPlay","onResume","onPause","onEnded","script","setState","parentNode","removeChild","error","onSetupError","onPlayAttemptFailed","onAutostartNotAllowed","onWarning","onError","mimeType","code","videoUrl","regex","matched","match","videoId","render","disableAutostart","scriptErrorMessage","_jwpOptions","licenseKey","autostart","errorMessage","wrapper","playerScript","propTypes"],"sources":["../../../src/molecule/video-player/jwplayer.js"],"sourcesContent":["import React from 'react';\nimport Player from '@jwplayer/jwplayer-react';\nimport {get, includes, isFunction, keys} from 'lodash/fp';\nimport style from './jwplayer.css';\nimport {JWPlayerPropTypes} from './prop-types';\n\nconst fileAndTracks = ({file, customProps, playlist} = {}) => {\n if (file)\n return {\n file,\n tracks: customProps ? customProps.tracks : null\n };\n if (playlist && playlist[0]) return playlist[0];\n\n return {\n file: null,\n tracks: null\n };\n};\n\nclass JWPlayer extends React.Component {\n static propTypes = JWPlayerPropTypes;\n\n constructor(props, context) {\n super(props, context);\n\n this.state = {\n scriptFailedLoading: false\n };\n\n this.handlePlay = this.handlePlay.bind(this);\n this.handleResume = this.handleResume.bind(this);\n this.handlePause = this.handlePause.bind(this);\n this.handleEnded = this.handleEnded.bind(this);\n this.handleError = this.handleError.bind(this);\n this.handleSetupError = this.handleSetupError.bind(this);\n this.handleScriptError = this.handleScriptError.bind(this);\n this.handlePlayAttemptFailed = this.handlePlayAttemptFailed.bind(this);\n this.handleAutostartNotAllowed = this.handleAutostartNotAllowed.bind(this);\n this.handleWarning = this.handleWarning.bind(this);\n }\n\n static getDerivedStateFromProps(props) {\n return fileAndTracks(props.jwpOptions);\n }\n\n componentDidUpdate(prevProps) {\n const changes = keys(this.props).filter(key => {\n const {[key]: current} = this.props;\n const {[key]: prev} = prevProps;\n return current !== prev;\n });\n const shouldStart = includes('autoplay', changes);\n if (shouldStart) {\n if (isFunction(window.jwplayer)) {\n window.jwplayer(prevProps.jwpOptions.playerId).play();\n }\n }\n }\n\n handlePlay(e) {\n const {onPlay} = this.props;\n if (onPlay) onPlay(e);\n }\n\n handleResume(e) {\n const {onResume} = this.props;\n if (onResume) onResume(e);\n }\n\n handlePause(e) {\n const {onPause} = this.props;\n if (onPause) onPause(e);\n }\n\n handleEnded(e) {\n const {onEnded} = this.props;\n if (onEnded) onEnded(e);\n }\n\n handleScriptError(script) {\n this.setState({scriptFailedLoading: true});\n if (script) {\n script.parentNode.removeChild();\n }\n }\n\n handleSetupError(error) {\n const {onSetupError} = this.props;\n if (onSetupError) onSetupError(error);\n }\n\n handlePlayAttemptFailed(error) {\n const {onPlayAttemptFailed} = this.props;\n if (onPlayAttemptFailed) onPlayAttemptFailed(error);\n }\n\n handleAutostartNotAllowed(error) {\n const {onAutostartNotAllowed} = this.props;\n if (onAutostartNotAllowed) onAutostartNotAllowed(error);\n }\n\n handleWarning(error) {\n const {onWarning} = this.props;\n if (onWarning) onWarning(error);\n }\n\n handleError(error) {\n const {onError, mimeType, jwpOptions} = this.props;\n const {code} = error;\n\n onError && onError(error);\n\n if (mimeType === 'application/kontiki') {\n return;\n }\n\n // This error mostly appears on IE11 on W7\n // Since IE11 dont kinda support M3U8 sometimes,\n // We've decided to switch from M3U8 to mp4 whenever it appears\n if (code === 214000) {\n const {file: videoUrl} = jwpOptions;\n const regex = /^https:\\/\\/content.jwplatform\\.com\\/manifests\\/(\\w+).m3u8/;\n const matched = videoUrl.match(regex);\n\n if (matched) {\n const videoId = matched[1];\n return this.setState({\n file: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`\n });\n }\n }\n }\n\n render() {\n const {jwpOptions, disableAutostart, scriptErrorMessage} = this.props;\n const {scriptFailedLoading, file, tracks} = this.state;\n const _jwpOptions = {\n ...jwpOptions,\n customProps: {\n ...get('customProps', jwpOptions),\n key: jwpOptions.licenseKey,\n autostart: !disableAutostart && get('customProps.autostart', jwpOptions)\n }\n };\n\n return (\n <>\n {scriptFailedLoading ? <p className={style.errorMessage}>{scriptErrorMessage} </p> : null}\n <Player\n key={file}\n className={style.wrapper}\n id={_jwpOptions.playerId}\n file={file}\n tracks={tracks}\n library={_jwpOptions.playerScript}\n config={_jwpOptions.customProps}\n onAutoStart={this.handlePlay}\n onPlay={this.handlePlay}\n onResume={this.handleResume}\n onPause={this.handlePause}\n onOneHundredPercent={this.handleEnded}\n onError={this.handleError}\n onSetupError={this.handleSetupError}\n onPlayAttemptFailed={this.handlePlayAttemptFailed}\n onWarning={this.handleWarning}\n onAutostartNotAllowed={this.handleAutostartNotAllowed}\n />\n </>\n );\n }\n}\n\nexport default JWPlayer;\n"],"mappings":";;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,MAAP,MAAmB,0BAAnB;AAEA,OAAOC,KAAP,MAAkB,gBAAlB;AACA,SAAQC,iBAAR,QAAgC,cAAhC;;AAEA,MAAMC,aAAa,GAAG,CAAC;EAACC,IAAD;EAAOC,WAAP;EAAoBC;AAApB,IAAgC,EAAjC,KAAwC;EAC5D,IAAIF,IAAJ,EACE,OAAO;IACLA,IADK;IAELG,MAAM,EAAEF,WAAW,GAAGA,WAAW,CAACE,MAAf,GAAwB;EAFtC,CAAP;EAIF,IAAID,QAAQ,IAAIA,QAAQ,CAAC,CAAD,CAAxB,EAA6B,OAAOA,QAAQ,CAAC,CAAD,CAAf;EAE7B,OAAO;IACLF,IAAI,EAAE,IADD;IAELG,MAAM,EAAE;EAFH,CAAP;AAID,CAZD;;AAcA,MAAMC,QAAN,SAAuBT,KAAK,CAACU,SAA7B,CAAuC;EAGrCC,WAAW,CAACC,KAAD,EAAQC,OAAR,EAAiB;IAC1B,MAAMD,KAAN,EAAaC,OAAb;IAEA,KAAKC,KAAL,GAAa;MACXC,mBAAmB,EAAE;IADV,CAAb;IAIA,KAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAqB,IAArB,CAAlB;IACA,KAAKC,YAAL,GAAoB,KAAKA,YAAL,CAAkBD,IAAlB,CAAuB,IAAvB,CAApB;IACA,KAAKE,WAAL,GAAmB,KAAKA,WAAL,CAAiBF,IAAj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D,IADP;MAEE,SAAS,EAAEH,KAAK,CAACoE,OAFnB;MAGE,EAAE,EAAEJ,WAAW,CAAC3B,QAHlB;MAIE,IAAI,EAAElC,IAJR;MAKE,MAAM,EAAEG,MALV;MAME,OAAO,EAAE0D,WAAW,CAACK,YANvB;MAOE,MAAM,EAAEL,WAAW,CAAC5D,WAPtB;MAQE,WAAW,EAAE,KAAKU,UARpB;MASE,MAAM,EAAE,KAAKA,UATf;MAUE,QAAQ,EAAE,KAAKE,YAVjB;MAWE,OAAO,EAAE,KAAKC,WAXhB;MAYE,mBAAmB,EAAE,KAAKC,WAZ5B;MAaE,OAAO,EAAE,KAAKC,WAbhB;MAcE,YAAY,EAAE,KAAKC,gBAdrB;MAeE,mBAAmB,EAAE,KAAKE,uBAf5B;MAgBE,SAAS,EAAE,KAAKE,aAhBlB;MAiBE,qBAAqB,EAAE,KAAKD;IAjB9B,EAFF,CADF;EAwBD;;AAtJoC;;AAAjChB,Q,CACG+D,S,2CAAYrE,iB;AAwJrB,eAAeM,QAAf"}
@@ -6,7 +6,7 @@ declare type Skin = {
6
6
  };
7
7
  declare type WebContextValues = {
8
8
  skin?: Skin;
9
- translate: (key: string) => string;
9
+ translate: (key: string, data: string) => string;
10
10
  };
11
11
  declare type Props = WebContextValues & {
12
12
  children: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"web-context.d.ts","sourceRoot":"","sources":["../../../src/atom/provider/web-context.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgB,SAAS,EAAa,MAAM,OAAO,CAAC;AAElE,aAAK,IAAI,GAAG;IACV,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,CAAC;AAMF,aAAK,KAAK,GAAG,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,UAAU,2BAA0B,KAAK,gBAE9C,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,gBAQhC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"web-context.d.ts","sourceRoot":"","sources":["../../../src/atom/provider/web-context.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAgB,SAAS,EAAa,MAAM,OAAO,CAAC;AAElE,aAAK,IAAI,GAAG;IACV,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,aAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CAClD,CAAC;AAMF,aAAK,KAAK,GAAG,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,UAAU,2BAA0B,KAAK,gBAE9C,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,gBAQhC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -14,7 +14,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
14
14
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
15
15
 
16
16
  const Context = /*#__PURE__*/(0, _react.createContext)({
17
- translate: key => key
17
+ translate: (key, data) => key
18
18
  });
19
19
 
20
20
  const WebContext = _ref => {
@@ -1 +1 @@
1
- {"version":3,"file":"web-context.js","names":["Context","createContext","translate","key","WebContext","children","value","useWebContext","context","useContext","Error"],"sources":["../../../src/atom/provider/web-context.tsx"],"sourcesContent":["import React, {createContext, ReactNode, useContext} from 'react';\n\ntype Skin = {\n common: {\n primary: string;\n };\n};\n\ntype WebContextValues = {\n skin?: Skin;\n translate: (key: string) => string;\n};\n\nconst Context = createContext({\n translate: (key: string) => key\n});\n\ntype Props = WebContextValues & {\n children: ReactNode;\n};\n\nconst WebContext = ({children, ...value}: Props) => {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useWebContext = (): WebContextValues => {\n const context = useContext(Context);\n\n if (!context) {\n throw new Error('❌ [WebContext] useWebContext must be used within a provider <WebContext>');\n }\n\n return context;\n};\n\nexport default WebContext;\n"],"mappings":";;;;;AAAA;;;;;;;;;;AAaA,MAAMA,OAAO,gBAAG,IAAAC,oBAAA,EAAc;EAC5BC,SAAS,EAAGC,GAAD,IAAiBA;AADA,CAAd,CAAhB;;AAQA,MAAMC,UAAU,GAAG,QAAiC;EAAA,IAAhC;IAACC;EAAD,CAAgC;EAAA,IAAlBC,KAAkB;;EAClD,oBAAO,6BAAC,OAAD,CAAS,QAAT;IAAkB,KAAK,EAAEA;EAAzB,GAAiCD,QAAjC,CAAP;AACD,CAFD;;AAIO,MAAME,aAAa,GAAG,MAAwB;EACnD,MAAMC,OAAO,GAAG,IAAAC,iBAAA,EAAWT,OAAX,CAAhB;;EAEA,IAAI,CAACQ,OAAL,EAAc;IACZ,MAAM,IAAIE,KAAJ,CAAU,0EAAV,CAAN;EACD;;EAED,OAAOF,OAAP;AACD,CARM;;;eAUQJ,U"}
1
+ {"version":3,"file":"web-context.js","names":["Context","createContext","translate","key","data","WebContext","children","value","useWebContext","context","useContext","Error"],"sources":["../../../src/atom/provider/web-context.tsx"],"sourcesContent":["import React, {createContext, ReactNode, useContext} from 'react';\n\ntype Skin = {\n common: {\n primary: string;\n };\n};\n\ntype WebContextValues = {\n skin?: Skin;\n translate: (key: string, data: string) => string;\n};\n\nconst Context = createContext({\n translate: (key: string, data: string) => key\n});\n\ntype Props = WebContextValues & {\n children: ReactNode;\n};\n\nconst WebContext = ({children, ...value}: Props) => {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n};\n\nexport const useWebContext = (): WebContextValues => {\n const context = useContext(Context);\n\n if (!context) {\n throw new Error('❌ [WebContext] useWebContext must be used within a provider <WebContext>');\n }\n\n return context;\n};\n\nexport default WebContext;\n"],"mappings":";;;;;AAAA;;;;;;;;;;AAaA,MAAMA,OAAO,gBAAG,IAAAC,oBAAA,EAAc;EAC5BC,SAAS,EAAE,CAACC,GAAD,EAAcC,IAAd,KAA+BD;AADd,CAAd,CAAhB;;AAQA,MAAME,UAAU,GAAG,QAAiC;EAAA,IAAhC;IAACC;EAAD,CAAgC;EAAA,IAAlBC,KAAkB;;EAClD,oBAAO,6BAAC,OAAD,CAAS,QAAT;IAAkB,KAAK,EAAEA;EAAzB,GAAiCD,QAAjC,CAAP;AACD,CAFD;;AAIO,MAAME,aAAa,GAAG,MAAwB;EACnD,MAAMC,OAAO,GAAG,IAAAC,iBAAA,EAAWV,OAAX,CAAhB;;EAEA,IAAI,CAACS,OAAL,EAAc;IACZ,MAAM,IAAIE,KAAJ,CAAU,0EAAV,CAAN;EACD;;EAED,OAAOF,OAAP;AACD,CARM;;;eAUQJ,U"}
@@ -34,9 +34,9 @@ declare class JWPlayer extends React.Component<any, any, any> {
34
34
  onSetupError: import("prop-types").Requireable<(...args: any[]) => any>;
35
35
  onWarning: import("prop-types").Requireable<(...args: any[]) => any>;
36
36
  };
37
+ static getDerivedStateFromProps(props: any): any;
37
38
  constructor(props: any, context: any);
38
39
  state: {
39
- fileUrl: string;
40
40
  scriptFailedLoading: boolean;
41
41
  };
42
42
  handlePlay(e: any): void;
@@ -49,9 +49,7 @@ declare class JWPlayer extends React.Component<any, any, any> {
49
49
  handlePlayAttemptFailed(error: any): void;
50
50
  handleAutostartNotAllowed(error: any): void;
51
51
  handleWarning(error: any): void;
52
- componentDidMount(): void;
53
52
  componentDidUpdate(prevProps: any): void;
54
- setFileUrl(): void;
55
53
  render(): JSX.Element;
56
54
  }
57
55
  import React from "react";
@@ -1 +1 @@
1
- {"version":3,"file":"jwplayer.d.ts","sourceRoot":"","sources":["../../../src/molecule/video-player/jwplayer.js"],"names":[],"mappings":";AAMA;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAqC;IAErC,sCAiBC;IAfC;;;MAGC;IA6CH,yBAGC;IAED,2BAGC;IAED,0BAGC;IAED,0BAGC;IA6BD,8BAyBC;IA7CD,mCAGC;IAVD,qCAKC;IAOD,0CAGC;IAED,4CAGC;IAED,gCAGC;IA5ED,0BAIC;IAED,yCAgBC;IAED,mBAKC;IA4ED,sBA+BC;CACF"}
1
+ {"version":3,"file":"jwplayer.d.ts","sourceRoot":"","sources":["../../../src/molecule/video-player/jwplayer.js"],"names":[],"mappings":";AAoBA;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAqC;IAqBrC,iDAEC;IArBD,sCAiBC;IAdC;;MAEC;IAgCH,yBAGC;IAED,2BAGC;IAED,0BAGC;IAED,0BAGC;IA6BD,8BAyBC;IA7CD,mCAGC;IAVD,qCAKC;IAOD,0CAGC;IAED,4CAGC;IAED,gCAGC;IA3DD,yCAYC;IA4ED,sBAoCC;CACF"}
@@ -13,7 +13,7 @@ var _get2 = _interopRequireDefault(require("lodash/fp/get"));
13
13
 
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
 
16
- var _reactJwPlayer = _interopRequireDefault(require("react-jw-player"));
16
+ var _jwplayerReact = _interopRequireDefault(require("@jwplayer/jwplayer-react"));
17
17
 
18
18
  var _jwplayer = _interopRequireDefault(require("./jwplayer.css"));
19
19
 
@@ -23,11 +23,26 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
23
 
24
24
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
25
25
 
26
+ const fileAndTracks = ({
27
+ file,
28
+ customProps,
29
+ playlist
30
+ } = {}) => {
31
+ if (file) return {
32
+ file,
33
+ tracks: customProps ? customProps.tracks : null
34
+ };
35
+ if (playlist && playlist[0]) return playlist[0];
36
+ return {
37
+ file: null,
38
+ tracks: null
39
+ };
40
+ };
41
+
26
42
  class JWPlayer extends _react.default.Component {
27
43
  constructor(props, context) {
28
44
  super(props, context);
29
45
  this.state = {
30
- fileUrl: '',
31
46
  scriptFailedLoading: false
32
47
  };
33
48
  this.handlePlay = this.handlePlay.bind(this);
@@ -42,12 +57,8 @@ class JWPlayer extends _react.default.Component {
42
57
  this.handleWarning = this.handleWarning.bind(this);
43
58
  }
44
59
 
45
- componentDidMount() {
46
- const jwPlayerScript = document.getElementById('jw-player-script');
47
-
48
- jwPlayerScript.onerror = () => this.handleScriptError(jwPlayerScript);
49
-
50
- this.setFileUrl();
60
+ static getDerivedStateFromProps(props) {
61
+ return fileAndTracks(props.jwpOptions);
51
62
  }
52
63
 
53
64
  componentDidUpdate(prevProps) {
@@ -67,26 +78,6 @@ class JWPlayer extends _react.default.Component {
67
78
  window.jwplayer(prevProps.jwpOptions.playerId).play();
68
79
  }
69
80
  }
70
-
71
- const {
72
- jwpOptions
73
- } = this.props;
74
-
75
- if (prevProps.jwpOptions.file !== jwpOptions.file) {
76
- this.setFileUrl();
77
- }
78
- }
79
-
80
- setFileUrl() {
81
- const {
82
- jwpOptions
83
- } = this.props;
84
- const {
85
- file
86
- } = jwpOptions;
87
- return this.setState({
88
- fileUrl: file
89
- });
90
81
  }
91
82
 
92
83
  handlePlay(e) {
@@ -183,7 +174,7 @@ class JWPlayer extends _react.default.Component {
183
174
  if (matched) {
184
175
  const videoId = matched[1];
185
176
  return this.setState({
186
- fileUrl: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`
177
+ file: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`
187
178
  });
188
179
  }
189
180
  }
@@ -197,19 +188,27 @@ class JWPlayer extends _react.default.Component {
197
188
  } = this.props;
198
189
  const {
199
190
  scriptFailedLoading,
200
- fileUrl
191
+ file,
192
+ tracks
201
193
  } = this.state;
202
194
 
203
195
  const _jwpOptions = _extends({}, jwpOptions, {
204
196
  customProps: _extends({}, (0, _get2.default)('customProps', jwpOptions), {
197
+ key: jwpOptions.licenseKey,
205
198
  autostart: !disableAutostart && (0, _get2.default)('customProps.autostart', jwpOptions)
206
199
  })
207
200
  });
208
201
 
209
202
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, scriptFailedLoading ? /*#__PURE__*/_react.default.createElement("p", {
210
203
  className: _jwplayer.default.errorMessage
211
- }, scriptErrorMessage, " ") : null, /*#__PURE__*/_react.default.createElement(_reactJwPlayer.default, _extends({}, _jwpOptions, {
204
+ }, scriptErrorMessage, " ") : null, /*#__PURE__*/_react.default.createElement(_jwplayerReact.default, {
205
+ key: file,
212
206
  className: _jwplayer.default.wrapper,
207
+ id: _jwpOptions.playerId,
208
+ file: file,
209
+ tracks: tracks,
210
+ library: _jwpOptions.playerScript,
211
+ config: _jwpOptions.customProps,
213
212
  onAutoStart: this.handlePlay,
214
213
  onPlay: this.handlePlay,
215
214
  onResume: this.handleResume,
@@ -219,9 +218,8 @@ class JWPlayer extends _react.default.Component {
219
218
  onSetupError: this.handleSetupError,
220
219
  onPlayAttemptFailed: this.handlePlayAttemptFailed,
221
220
  onWarning: this.handleWarning,
222
- onAutostartNotAllowed: this.handleAutostartNotAllowed,
223
- file: fileUrl
224
- })));
221
+ onAutostartNotAllowed: this.handleAutostartNotAllowed
222
+ }));
225
223
  }
226
224
 
227
225
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jwplayer.js","names":["JWPlayer","React","Component","constructor","props","context","state","fileUrl","scriptFailedLoading","handlePlay","bind","handleResume","handlePause","handleEnded","handleError","handleSetupError","handleScriptError","handlePlayAttemptFailed","handleAutostartNotAllowed","handleWarning","componentDidMount","jwPlayerScript","document","getElementById","onerror","setFileUrl","componentDidUpdate","prevProps","changes","filter","key","current","prev","shouldStart","window","jwplayer","jwpOptions","playerId","play","file","setState","e","onPlay","onResume","onPause","onEnded","script","parentNode","removeChild","error","onSetupError","onPlayAttemptFailed","onAutostartNotAllowed","onWarning","onError","mimeType","code","videoUrl","regex","matched","match","videoId","render","disableAutostart","scriptErrorMessage","_jwpOptions","customProps","autostart","style","errorMessage","wrapper","propTypes","JWPlayerPropTypes"],"sources":["../../../src/molecule/video-player/jwplayer.js"],"sourcesContent":["import React from 'react';\nimport ReactJWPlayer from 'react-jw-player';\nimport {get, includes, isFunction, keys} from 'lodash/fp';\nimport style from './jwplayer.css';\nimport {JWPlayerPropTypes} from './prop-types';\n\nclass JWPlayer extends React.Component {\n static propTypes = JWPlayerPropTypes;\n\n constructor(props, context) {\n super(props, context);\n this.state = {\n fileUrl: '',\n scriptFailedLoading: false\n };\n\n this.handlePlay = this.handlePlay.bind(this);\n this.handleResume = this.handleResume.bind(this);\n this.handlePause = this.handlePause.bind(this);\n this.handleEnded = this.handleEnded.bind(this);\n this.handleError = this.handleError.bind(this);\n this.handleSetupError = this.handleSetupError.bind(this);\n this.handleScriptError = this.handleScriptError.bind(this);\n this.handlePlayAttemptFailed = this.handlePlayAttemptFailed.bind(this);\n this.handleAutostartNotAllowed = this.handleAutostartNotAllowed.bind(this);\n this.handleWarning = this.handleWarning.bind(this);\n }\n\n componentDidMount() {\n const jwPlayerScript = document.getElementById('jw-player-script');\n jwPlayerScript.onerror = () => this.handleScriptError(jwPlayerScript);\n this.setFileUrl();\n }\n\n componentDidUpdate(prevProps) {\n const changes = keys(this.props).filter(key => {\n const {[key]: current} = this.props;\n const {[key]: prev} = prevProps;\n return current !== prev;\n });\n const shouldStart = includes('autoplay', changes);\n if (shouldStart) {\n if (isFunction(window.jwplayer)) {\n window.jwplayer(prevProps.jwpOptions.playerId).play();\n }\n }\n const {jwpOptions} = this.props;\n if (prevProps.jwpOptions.file !== jwpOptions.file) {\n this.setFileUrl();\n }\n }\n\n setFileUrl() {\n const {jwpOptions} = this.props;\n const {file} = jwpOptions;\n\n return this.setState({fileUrl: file});\n }\n\n handlePlay(e) {\n const {onPlay} = this.props;\n if (onPlay) onPlay(e);\n }\n\n handleResume(e) {\n const {onResume} = this.props;\n if (onResume) onResume(e);\n }\n\n handlePause(e) {\n const {onPause} = this.props;\n if (onPause) onPause(e);\n }\n\n handleEnded(e) {\n const {onEnded} = this.props;\n if (onEnded) onEnded(e);\n }\n\n handleScriptError(script) {\n this.setState({scriptFailedLoading: true});\n if (script) {\n script.parentNode.removeChild();\n }\n }\n\n handleSetupError(error) {\n const {onSetupError} = this.props;\n if (onSetupError) onSetupError(error);\n }\n\n handlePlayAttemptFailed(error) {\n const {onPlayAttemptFailed} = this.props;\n if (onPlayAttemptFailed) onPlayAttemptFailed(error);\n }\n\n handleAutostartNotAllowed(error) {\n const {onAutostartNotAllowed} = this.props;\n if (onAutostartNotAllowed) onAutostartNotAllowed(error);\n }\n\n handleWarning(error) {\n const {onWarning} = this.props;\n if (onWarning) onWarning(error);\n }\n\n handleError(error) {\n const {onError, mimeType, jwpOptions} = this.props;\n const {code} = error;\n\n onError && onError(error);\n\n if (mimeType === 'application/kontiki') {\n return;\n }\n\n // This error mostly appears on IE11 on W7\n // Since IE11 dont kinda support M3U8 sometimes,\n // We've decided to switch from M3U8 to mp4 whenever it appears\n if (code === 214000) {\n const {file: videoUrl} = jwpOptions;\n const regex = /^https:\\/\\/content.jwplatform\\.com\\/manifests\\/(\\w+).m3u8/;\n const matched = videoUrl.match(regex);\n\n if (matched) {\n const videoId = matched[1];\n return this.setState({\n fileUrl: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`\n });\n }\n }\n }\n\n render() {\n const {jwpOptions, disableAutostart, scriptErrorMessage} = this.props;\n const {scriptFailedLoading, fileUrl} = this.state;\n const _jwpOptions = {\n ...jwpOptions,\n customProps: {\n ...get('customProps', jwpOptions),\n autostart: !disableAutostart && get('customProps.autostart', jwpOptions)\n }\n };\n\n return (\n <>\n {scriptFailedLoading ? <p className={style.errorMessage}>{scriptErrorMessage} </p> : null}\n <ReactJWPlayer\n {..._jwpOptions}\n className={style.wrapper}\n onAutoStart={this.handlePlay}\n onPlay={this.handlePlay}\n onResume={this.handleResume}\n onPause={this.handlePause}\n onOneHundredPercent={this.handleEnded}\n onError={this.handleError}\n onSetupError={this.handleSetupError}\n onPlayAttemptFailed={this.handlePlayAttemptFailed}\n onWarning={this.handleWarning}\n onAutostartNotAllowed={this.handleAutostartNotAllowed}\n file={fileUrl}\n />\n </>\n );\n }\n}\n\nexport default JWPlayer;\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAEA,MAAMA,QAAN,SAAuBC,cAAA,CAAMC,SAA7B,CAAuC;EAGrCC,WAAW,CAACC,KAAD,EAAQC,OAAR,EAAiB;IAC1B,MAAMD,KAAN,EAAaC,OAAb;IACA,KAAKC,KAAL,GAAa;MACXC,OAAO,EAAE,EADE;MAEXC,mBAAmB,EAAE;IAFV,CAAb;IAKA,KAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAqB,IAArB,CAAlB;IACA,KAAKC,YAAL,GAAoB,KAAKA,YAAL,CAAkBD,IAAlB,CAAuB,IAAvB,CAApB;IACA,KAAKE,WAAL,GAAmB,KAAKA,WAAL,CAAiBF,IAAjB,CAAsB,IAAtB,CAAnB;IACA,KAAKG,WAAL,GAAmB,KAAKA,WAAL,CAAiBH,IAAjB,CAAsB,IAAtB,CAAnB;IACA,KAAKI,WAAL,GAAmB,KAAKA,WAAL,CAAiBJ,IAAjB,CAAsB,IAAtB,CAAnB;IACA,KAAKK,gBAAL,GAAwB,KAAKA,gBAAL,CAAsBL,IAAtB,CAA2B,IAA3B,CAAxB;IACA,KAAKM,iBAAL,GAAyB,KAAKA,iBAAL,CAAuBN,IAAvB,CAA4B,IAA5B,CAAzB;IACA,KAAKO,uBAAL,GAA+B,KAAKA,uBAAL,CAA6BP,IAA7B,CAAkC,IAAlC,CAA/B;IACA,K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WAAW,EAAE,KAAK7D,UAHpB;MAIE,MAAM,EAAE,KAAKA,UAJf;MAKE,QAAQ,EAAE,KAAKE,YALjB;MAME,OAAO,EAAE,KAAKC,WANhB;MAOE,mBAAmB,EAAE,KAAKC,WAP5B;MAQE,OAAO,EAAE,KAAKC,WARhB;MASE,YAAY,EAAE,KAAKC,gBATrB;MAUE,mBAAmB,EAAE,KAAKE,uBAV5B;MAWE,SAAS,EAAE,KAAKE,aAXlB;MAYE,qBAAqB,EAAE,KAAKD,yBAZ9B;MAaE,IAAI,EAAEX;IAbR,GAFF,CADF;EAoBD;;AA9JoC;;AAAjCP,Q,CACGuE,S,2CAAYC,4B;eAgKNxE,Q"}
1
+ {"version":3,"file":"jwplayer.js","names":["fileAndTracks","file","customProps","playlist","tracks","JWPlayer","React","Component","constructor","props","context","state","scriptFailedLoading","handlePlay","bind","handleResume","handlePause","handleEnded","handleError","handleSetupError","handleScriptError","handlePlayAttemptFailed","handleAutostartNotAllowed","handleWarning","getDerivedStateFromProps","jwpOptions","componentDidUpdate","prevProps","changes","filter","key","current","prev","shouldStart","window","jwplayer","playerId","play","e","onPlay","onResume","onPause","onEnded","script","setState","parentNode","removeChild","error","onSetupError","onPlayAttemptFailed","onAutostartNotAllowed","onWarning","onError","mimeType","code","videoUrl","regex","matched","match","videoId","render","disableAutostart","scriptErrorMessage","_jwpOptions","licenseKey","autostart","style","errorMessage","wrapper","playerScript","propTypes","JWPlayerPropTypes"],"sources":["../../../src/molecule/video-player/jwplayer.js"],"sourcesContent":["import React from 'react';\nimport Player from '@jwplayer/jwplayer-react';\nimport {get, includes, isFunction, keys} from 'lodash/fp';\nimport style from './jwplayer.css';\nimport {JWPlayerPropTypes} from './prop-types';\n\nconst fileAndTracks = ({file, customProps, playlist} = {}) => {\n if (file)\n return {\n file,\n tracks: customProps ? customProps.tracks : null\n };\n if (playlist && playlist[0]) return playlist[0];\n\n return {\n file: null,\n tracks: null\n };\n};\n\nclass JWPlayer extends React.Component {\n static propTypes = JWPlayerPropTypes;\n\n constructor(props, context) {\n super(props, context);\n\n this.state = {\n scriptFailedLoading: false\n };\n\n this.handlePlay = this.handlePlay.bind(this);\n this.handleResume = this.handleResume.bind(this);\n this.handlePause = this.handlePause.bind(this);\n this.handleEnded = this.handleEnded.bind(this);\n this.handleError = this.handleError.bind(this);\n this.handleSetupError = this.handleSetupError.bind(this);\n this.handleScriptError = this.handleScriptError.bind(this);\n this.handlePlayAttemptFailed = this.handlePlayAttemptFailed.bind(this);\n this.handleAutostartNotAllowed = this.handleAutostartNotAllowed.bind(this);\n this.handleWarning = this.handleWarning.bind(this);\n }\n\n static getDerivedStateFromProps(props) {\n return fileAndTracks(props.jwpOptions);\n }\n\n componentDidUpdate(prevProps) {\n const changes = keys(this.props).filter(key => {\n const {[key]: current} = this.props;\n const {[key]: prev} = prevProps;\n return current !== prev;\n });\n const shouldStart = includes('autoplay', changes);\n if (shouldStart) {\n if (isFunction(window.jwplayer)) {\n window.jwplayer(prevProps.jwpOptions.playerId).play();\n }\n }\n }\n\n handlePlay(e) {\n const {onPlay} = this.props;\n if (onPlay) onPlay(e);\n }\n\n handleResume(e) {\n const {onResume} = this.props;\n if (onResume) onResume(e);\n }\n\n handlePause(e) {\n const {onPause} = this.props;\n if (onPause) onPause(e);\n }\n\n handleEnded(e) {\n const {onEnded} = this.props;\n if (onEnded) onEnded(e);\n }\n\n handleScriptError(script) {\n this.setState({scriptFailedLoading: true});\n if (script) {\n script.parentNode.removeChild();\n }\n }\n\n handleSetupError(error) {\n const {onSetupError} = this.props;\n if (onSetupError) onSetupError(error);\n }\n\n handlePlayAttemptFailed(error) {\n const {onPlayAttemptFailed} = this.props;\n if (onPlayAttemptFailed) onPlayAttemptFailed(error);\n }\n\n handleAutostartNotAllowed(error) {\n const {onAutostartNotAllowed} = this.props;\n if (onAutostartNotAllowed) onAutostartNotAllowed(error);\n }\n\n handleWarning(error) {\n const {onWarning} = this.props;\n if (onWarning) onWarning(error);\n }\n\n handleError(error) {\n const {onError, mimeType, jwpOptions} = this.props;\n const {code} = error;\n\n onError && onError(error);\n\n if (mimeType === 'application/kontiki') {\n return;\n }\n\n // This error mostly appears on IE11 on W7\n // Since IE11 dont kinda support M3U8 sometimes,\n // We've decided to switch from M3U8 to mp4 whenever it appears\n if (code === 214000) {\n const {file: videoUrl} = jwpOptions;\n const regex = /^https:\\/\\/content.jwplatform\\.com\\/manifests\\/(\\w+).m3u8/;\n const matched = videoUrl.match(regex);\n\n if (matched) {\n const videoId = matched[1];\n return this.setState({\n file: `https://content.jwplatform.com/videos/${videoId}-1080.mp4`\n });\n }\n }\n }\n\n render() {\n const {jwpOptions, disableAutostart, scriptErrorMessage} = this.props;\n const {scriptFailedLoading, file, tracks} = this.state;\n const _jwpOptions = {\n ...jwpOptions,\n customProps: {\n ...get('customProps', jwpOptions),\n key: jwpOptions.licenseKey,\n autostart: !disableAutostart && get('customProps.autostart', jwpOptions)\n }\n };\n\n return (\n <>\n {scriptFailedLoading ? <p className={style.errorMessage}>{scriptErrorMessage} </p> : null}\n <Player\n key={file}\n className={style.wrapper}\n id={_jwpOptions.playerId}\n file={file}\n tracks={tracks}\n library={_jwpOptions.playerScript}\n config={_jwpOptions.customProps}\n onAutoStart={this.handlePlay}\n onPlay={this.handlePlay}\n onResume={this.handleResume}\n onPause={this.handlePause}\n onOneHundredPercent={this.handleEnded}\n onError={this.handleError}\n onSetupError={this.handleSetupError}\n onPlayAttemptFailed={this.handlePlayAttemptFailed}\n onWarning={this.handleWarning}\n onAutostartNotAllowed={this.handleAutostartNotAllowed}\n />\n </>\n );\n }\n}\n\nexport default JWPlayer;\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAEA,MAAMA,aAAa,GAAG,CAAC;EAACC,IAAD;EAAOC,WAAP;EAAoBC;AAApB,IAAgC,EAAjC,KAAwC;EAC5D,IAAIF,IAAJ,EACE,OAAO;IACLA,IADK;IAELG,MAAM,EAAEF,WAAW,GAAGA,WAAW,CA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q"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coorpacademy/components",
3
- "version": "10.26.1-alpha.1+ba4ea48b8",
3
+ "version": "10.27.1-alpha.0+c67805b5f",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -57,6 +57,7 @@
57
57
  ],
58
58
  "dependencies": {
59
59
  "@coorpacademy/nova-icons": "3.11.12",
60
+ "@jwplayer/jwplayer-react": "^1.1.0",
60
61
  "@types/react": "^17.0.50",
61
62
  "@types/react-dom": "^17.0.17",
62
63
  "autoprefixer": "^10.4.12",
@@ -76,7 +77,6 @@
76
77
  "qs": "6.11.0",
77
78
  "react-autosuggest": "^10.0.2",
78
79
  "react-dropzone": "^9.0.0",
79
- "react-jw-player": "1.19.1",
80
80
  "react-tooltip": "^4.2.6"
81
81
  },
82
82
  "peerDependencies": {
@@ -157,5 +157,5 @@
157
157
  "last 2 versions",
158
158
  "IE 11"
159
159
  ],
160
- "gitHead": "ba4ea48b808cf8698b934e1d58eec6068152dd89"
160
+ "gitHead": "c67805b5f6cd6c8d74a4d9c3ead99fa8a0d5465d"
161
161
  }