@elice/material-video-file 1.230328.0 → 1.230418.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.
Files changed (22) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +60 -0
  2. package/cjs/components/material-video-file/MaterialVideoFile.d.ts +2 -1
  3. package/cjs/components/material-video-file/MaterialVideoFile.js +33 -24
  4. package/cjs/components/material-video-file/MaterialVideoFile.styled.js +1 -1
  5. package/cjs/components/material-video-file/MaterialVideoFilePlayer.d.ts +2 -1
  6. package/cjs/components/material-video-file/MaterialVideoFilePlayer.js +108 -97
  7. package/cjs/components/material-video-file/MaterialVideoFilePlayer.styled.js +2 -2
  8. package/cjs/components/material-video-file/locales.js +2 -2
  9. package/cjs/components/material-video-file/useMaterialVideoFileApi.d.ts +12 -0
  10. package/cjs/components/material-video-file/useMaterialVideoFileApi.js +44 -0
  11. package/cjs/index.js +1 -1
  12. package/es/_virtual/_rollupPluginBabelHelpers.js +51 -0
  13. package/es/components/material-video-file/MaterialVideoFile.d.ts +2 -1
  14. package/es/components/material-video-file/MaterialVideoFile.js +29 -22
  15. package/es/components/material-video-file/MaterialVideoFile.styled.js +1 -1
  16. package/es/components/material-video-file/MaterialVideoFilePlayer.d.ts +2 -1
  17. package/es/components/material-video-file/MaterialVideoFilePlayer.js +105 -96
  18. package/es/components/material-video-file/MaterialVideoFilePlayer.styled.js +2 -2
  19. package/es/components/material-video-file/locales.js +2 -2
  20. package/es/components/material-video-file/useMaterialVideoFileApi.d.ts +12 -0
  21. package/es/components/material-video-file/useMaterialVideoFileApi.js +40 -0
  22. package/package.json +10 -8
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _iterableToArrayLimit(arr, i) {
6
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
7
+ if (null != _i) {
8
+ var _s,
9
+ _e,
10
+ _x,
11
+ _r,
12
+ _arr = [],
13
+ _n = !0,
14
+ _d = !1;
15
+ try {
16
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
17
+ if (Object(_i) !== _i) return;
18
+ _n = !1;
19
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
20
+ } catch (err) {
21
+ _d = !0, _e = err;
22
+ } finally {
23
+ try {
24
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
25
+ } finally {
26
+ if (_d) throw _e;
27
+ }
28
+ }
29
+ return _arr;
30
+ }
31
+ }
32
+ function _slicedToArray(arr, i) {
33
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
34
+ }
35
+ function _arrayWithHoles(arr) {
36
+ if (Array.isArray(arr)) return arr;
37
+ }
38
+ function _unsupportedIterableToArray(o, minLen) {
39
+ if (!o) return;
40
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
41
+ var n = Object.prototype.toString.call(o).slice(8, -1);
42
+ if (n === "Object" && o.constructor) n = o.constructor.name;
43
+ if (n === "Map" || n === "Set") return Array.from(o);
44
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
45
+ }
46
+ function _arrayLikeToArray(arr, len) {
47
+ if (len == null || len > arr.length) len = arr.length;
48
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
49
+ return arr2;
50
+ }
51
+ function _nonIterableRest() {
52
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53
+ }
54
+
55
+ exports.arrayLikeToArray = _arrayLikeToArray;
56
+ exports.arrayWithHoles = _arrayWithHoles;
57
+ exports.iterableToArrayLimit = _iterableToArrayLimit;
58
+ exports.nonIterableRest = _nonIterableRest;
59
+ exports.slicedToArray = _slicedToArray;
60
+ exports.unsupportedIterableToArray = _unsupportedIterableToArray;
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { MaterialVideoFilePlayerProps } from './MaterialVideoFilePlayer';
3
+ import type { UseMaterialVideoFileApiProps } from './useMaterialVideoFileApi';
3
4
  declare type PickedVideoPlayerProps = Pick<MaterialVideoFilePlayerProps, 'materialVideoFileTrackerDisabled' | 'mainLecturePageId' | 'lms' | 'lmsOrganizationBusinessType' | 'emptyComponent' | 'autoPlay' | 'autoPlayNext' | 'endControl' | 'eliceVideoPlayerUrl' | 'onNavigatePreviousLecturePage' | 'onNavigateNextLecturePage'>;
4
- export interface MaterialVideoFileProps extends PickedVideoPlayerProps {
5
+ export interface MaterialVideoFileProps extends PickedVideoPlayerProps, UseMaterialVideoFileApiProps {
5
6
  materialVideoFileId: number;
6
7
  className?: string;
7
8
  locale?: string;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var tslib = require('tslib');
4
6
  var React = require('react');
5
7
  var reactIntl = require('react-intl');
@@ -9,6 +11,7 @@ var types = require('@elice/types');
9
11
  var classnames = require('classnames');
10
12
  var locales = require('./locales.js');
11
13
  var MaterialVideoFilePlayer = require('./MaterialVideoFilePlayer.js');
14
+ var useMaterialVideoFileApi = require('./useMaterialVideoFileApi.js');
12
15
  var MaterialVideoFile_styled = require('./MaterialVideoFile.styled.js');
13
16
 
14
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -16,43 +19,49 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
16
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
20
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
18
21
 
19
- const MaterialVideoFile = _a => {
22
+ //
23
+ //
24
+ //
25
+ var MaterialVideoFile = function MaterialVideoFile(_a) {
20
26
  var _b, _c;
21
-
22
- var {
23
- materialVideoFileId,
24
- className,
25
- locale = 'en'
26
- } = _a,
27
- playerProps = tslib.__rest(_a, ["materialVideoFileId", "className", "locale"]);
28
-
29
- const prefixCls = 'em-material-video-file';
30
- const {
31
- orgNameShort
32
- } = materialSharedUtils.useMaterialConfig();
33
- const {
34
- materialVideoFile,
35
- status: materialVideoFileStatus
36
- } = materialSharedUtils.useMaterialFetch(types.enums.LectureMaterialType.VideoFile, React__default["default"].useCallback(signal => apiClient.getOrgMaterialVideoFileGet({
37
- materialVideoFileId
38
- }, {
39
- signal
40
- }), [materialVideoFileId]), apiClient.config.init); //
27
+ var materialVideoFileId = _a.materialVideoFileId,
28
+ className = _a.className,
29
+ _a$locale = _a.locale,
30
+ locale = _a$locale === void 0 ? 'en' : _a$locale,
31
+ eliceAccountApiConfiguration = _a.eliceAccountApiConfiguration,
32
+ playerProps = tslib.__rest(_a, ["materialVideoFileId", "className", "locale", "eliceAccountApiConfiguration"]);
33
+ var prefixCls = 'em-material-video-file';
34
+ var _useMaterialConfig = materialSharedUtils.useMaterialConfig(),
35
+ orgNameShort = _useMaterialConfig.orgNameShort;
36
+ var _useMaterialVideoFile = useMaterialVideoFileApi.useMaterialVideoFileApi({
37
+ eliceAccountApiConfiguration: eliceAccountApiConfiguration
38
+ }),
39
+ accountApi = _useMaterialVideoFile.accountApi;
40
+ var _useMaterialFetch = materialSharedUtils.useMaterialFetch(types.enums.LectureMaterialType.VideoFile, React__default["default"].useCallback(function (signal) {
41
+ return apiClient.getOrgMaterialVideoFileGet({
42
+ materialVideoFileId: materialVideoFileId
43
+ }, {
44
+ signal: signal
45
+ });
46
+ }, [materialVideoFileId]), apiClient.config.init),
47
+ materialVideoFile = _useMaterialFetch.materialVideoFile,
48
+ materialVideoFileStatus = _useMaterialFetch.status;
49
+ //
41
50
  //
42
51
  //
43
-
44
52
  return React__default["default"].createElement(MaterialVideoFile_styled.StyledMaterialVideoFileWrap, {
45
53
  className: classnames__default["default"](prefixCls, className)
46
54
  }, React__default["default"].createElement(reactIntl.IntlProvider, {
47
55
  locale: locale,
48
56
  defaultLocale: "en",
49
57
  messages: locale in locales ? locales[locale] : locales.en
50
- }, React__default["default"].createElement(MaterialVideoFilePlayer, Object.assign({}, playerProps, {
58
+ }, React__default["default"].createElement(MaterialVideoFilePlayer["default"], Object.assign({}, playerProps, {
51
59
  orgNameShort: orgNameShort,
52
60
  materialVideoFile: materialVideoFile !== null && materialVideoFile !== void 0 ? materialVideoFile : null,
53
61
  materialVideoFileStatus: materialVideoFileStatus,
62
+ accountApi: accountApi,
54
63
  title: (_c = (_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.videoAssetName) !== null && _c !== void 0 ? _c : undefined
55
64
  }))));
56
65
  };
57
66
 
58
- module.exports = MaterialVideoFile;
67
+ exports["default"] = MaterialVideoFile;
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
 
10
10
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
11
11
 
12
- const StyledMaterialVideoFileWrap = styled__default["default"].div.withConfig({
12
+ var StyledMaterialVideoFileWrap = styled__default["default"].div.withConfig({
13
13
  componentId: "sc-1a1otok-0"
14
14
  })(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;background:", ";"], designTokens.base.color.gray9);
15
15
 
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { APIStatus } from '@elice/material-shared-types';
3
3
  import type { EliceVideoPlayerSearchParams, GetOrgMaterialVideoFileGetResponses } from '@elice/types';
4
- export interface MaterialVideoFilePlayerProps {
4
+ import type { UseMaterialVideoFileApiReturn } from './useMaterialVideoFileApi';
5
+ export interface MaterialVideoFilePlayerProps extends UseMaterialVideoFileApiReturn {
5
6
  /** Classname for the element. */
6
7
  className?: string;
7
8
  /** Material video file. */
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
3
6
  var React = require('react');
4
7
  var reactIntl = require('react-intl');
5
- var apiClient = require('@elice/api-client');
6
8
  var blocks = require('@elice/blocks');
7
9
  var types = require('@elice/types');
8
10
  var classnames = require('classnames');
@@ -13,176 +15,188 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
13
15
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
16
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
15
17
 
18
+ //
19
+ //
20
+ //
16
21
  var VideoUploadStatus;
17
-
18
22
  (function (VideoUploadStatus) {
19
23
  VideoUploadStatus[VideoUploadStatus["Empty"] = 0] = "Empty";
20
24
  VideoUploadStatus[VideoUploadStatus["Encoding"] = 1] = "Encoding";
21
25
  VideoUploadStatus[VideoUploadStatus["EncodingFailed"] = 2] = "EncodingFailed";
22
26
  VideoUploadStatus[VideoUploadStatus["Ready"] = 3] = "Ready";
23
27
  })(VideoUploadStatus || (VideoUploadStatus = {}));
24
-
25
28
  var VideoMimeType;
26
-
27
29
  (function (VideoMimeType) {
28
30
  /** `application/vnd.ms-sstr+xml` */
29
31
  VideoMimeType["Smooth"] = "application/vnd.ms-sstr+xml";
30
32
  /** `application/vnd.apple.mpegurl` */
31
-
32
33
  VideoMimeType["Hls"] = "application/vnd.apple.mpegurl";
33
34
  /** `application/dash+xml` */
34
-
35
35
  VideoMimeType["Mpeg"] = "application/dash+xml";
36
36
  })(VideoMimeType || (VideoMimeType = {}));
37
-
38
- const ELICE_VIDEO_PLAYER_MESSAGE_EVENT = 'elice-videoplayer';
39
- const ELICE_VIDEO_PLAYER_MESSAGE_TYPE = 'navigate';
40
-
41
- const MaterialVideoFilePlayer = ({
42
- className,
43
- materialVideoFile,
44
- materialVideoFileStatus = 'idle',
45
- materialVideoFileTrackerDisabled = false,
46
- mainLecturePageId,
47
- orgNameShort,
48
- lms = false,
49
- lmsOrganizationBusinessType = null,
50
- autoPlay = false,
51
- autoPlayNext = false,
52
- endControl = false,
53
- locale,
54
- eliceVideoPlayerUrl,
55
- emptyComponent = null,
56
- title = 'elice-videoplayer',
57
- onNavigatePreviousLecturePage,
58
- onNavigateNextLecturePage
59
- }) => {
60
- const prefixCls = 'em-video-player';
61
- const [playerFrameSrc, setPlayerFrameSrc] = React__default["default"].useState(null);
37
+ //
38
+ //
39
+ //
40
+ var ELICE_VIDEO_PLAYER_MESSAGE_EVENT = 'elice-videoplayer';
41
+ var ELICE_VIDEO_PLAYER_MESSAGE_TYPE = 'navigate';
42
+ //
43
+ //
44
+ //
45
+ var MaterialVideoFilePlayer = function MaterialVideoFilePlayer(_ref) {
46
+ var className = _ref.className,
47
+ materialVideoFile = _ref.materialVideoFile,
48
+ _ref$materialVideoFil = _ref.materialVideoFileStatus,
49
+ materialVideoFileStatus = _ref$materialVideoFil === void 0 ? 'idle' : _ref$materialVideoFil,
50
+ _ref$materialVideoFil2 = _ref.materialVideoFileTrackerDisabled,
51
+ materialVideoFileTrackerDisabled = _ref$materialVideoFil2 === void 0 ? false : _ref$materialVideoFil2,
52
+ mainLecturePageId = _ref.mainLecturePageId,
53
+ orgNameShort = _ref.orgNameShort,
54
+ _ref$lms = _ref.lms,
55
+ lms = _ref$lms === void 0 ? false : _ref$lms,
56
+ _ref$lmsOrganizationB = _ref.lmsOrganizationBusinessType,
57
+ lmsOrganizationBusinessType = _ref$lmsOrganizationB === void 0 ? null : _ref$lmsOrganizationB,
58
+ _ref$autoPlay = _ref.autoPlay,
59
+ autoPlay = _ref$autoPlay === void 0 ? false : _ref$autoPlay,
60
+ _ref$autoPlayNext = _ref.autoPlayNext,
61
+ autoPlayNext = _ref$autoPlayNext === void 0 ? false : _ref$autoPlayNext,
62
+ _ref$endControl = _ref.endControl,
63
+ endControl = _ref$endControl === void 0 ? false : _ref$endControl,
64
+ locale = _ref.locale,
65
+ eliceVideoPlayerUrl = _ref.eliceVideoPlayerUrl,
66
+ _ref$emptyComponent = _ref.emptyComponent,
67
+ emptyComponent = _ref$emptyComponent === void 0 ? null : _ref$emptyComponent,
68
+ _ref$title = _ref.title,
69
+ title = _ref$title === void 0 ? 'elice-videoplayer' : _ref$title,
70
+ onNavigatePreviousLecturePage = _ref.onNavigatePreviousLecturePage,
71
+ onNavigateNextLecturePage = _ref.onNavigateNextLecturePage,
72
+ accountApi = _ref.accountApi;
73
+ var prefixCls = 'em-video-player';
74
+ var _React$useState = React__default["default"].useState(null),
75
+ _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
76
+ playerFrameSrc = _React$useState2[0],
77
+ setPlayerFrameSrc = _React$useState2[1];
62
78
  /**
63
79
  * Current video status.
64
80
  */
65
-
66
- const materialVideoFileUploadStatus = React__default["default"].useMemo(() => {
81
+ var materialVideoFileUploadStatus = React__default["default"].useMemo(function () {
67
82
  var _a, _b, _c, _d;
68
-
69
83
  switch (true) {
70
84
  case typeof ((_a = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.status) === 'undefined':
71
85
  return VideoUploadStatus.Empty;
72
-
73
86
  case ((_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.status) === types.enums.AzureMediaVideoStatus.Encoding:
74
87
  return VideoUploadStatus.Encoding;
75
-
76
88
  case ((_c = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _c === void 0 ? void 0 : _c.status) === types.enums.AzureMediaVideoStatus.Error:
77
89
  return VideoUploadStatus.EncodingFailed;
78
-
79
90
  case ((_d = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _d === void 0 ? void 0 : _d.status) === types.enums.AzureMediaVideoStatus.Done && typeof materialVideoFile.azureMediaVideo.videoStreamingUrl === 'string':
80
91
  return VideoUploadStatus.Ready;
81
-
82
92
  default:
83
93
  return VideoUploadStatus.Empty;
84
94
  }
85
- }, [materialVideoFile]); //
95
+ }, [materialVideoFile]);
96
+ //
86
97
  // Get video iframe src.
87
98
  //
88
-
89
- React__default["default"].useEffect(() => {
99
+ React__default["default"].useEffect(function () {
90
100
  if (!eliceVideoPlayerUrl || !materialVideoFile) {
91
101
  return;
92
102
  }
93
-
94
- const abortCtrl = new AbortController();
95
- apiClient.postGlobalAuthOtpKeyMake({
103
+ var abortCtrl = new AbortController();
104
+ accountApi.auth.authOtpPost({
96
105
  signal: abortCtrl.signal
97
- }) // issue otp key
98
- .then(res => res.otpKey) // create search params
99
- .then(otp => ({
100
- org: orgNameShort,
101
- mid: materialVideoFile.id,
102
- lmid: mainLecturePageId,
103
- lms,
104
- lmstype: lms ? lmsOrganizationBusinessType !== null && lmsOrganizationBusinessType !== void 0 ? lmsOrganizationBusinessType : undefined : undefined,
105
- codec: VideoMimeType.Smooth,
106
- autoplay: autoPlay,
107
- autoplaynext: autoPlayNext,
108
- endctrl: endControl,
109
- notrack: materialVideoFileTrackerDisabled,
110
- origin: window.location.origin,
111
- locale,
112
- otp
113
- })) // create url from search params
114
- .then(params => {
115
- const url = new URL(eliceVideoPlayerUrl);
116
- Object.entries(params).forEach(([key, value]) => {
106
+ })
107
+ // issue otp key
108
+ .then(function (res) {
109
+ return res.otp;
110
+ })
111
+ // create search params
112
+ .then(function (otp) {
113
+ return {
114
+ org: orgNameShort,
115
+ mid: materialVideoFile.id,
116
+ lmid: mainLecturePageId,
117
+ lms: lms,
118
+ lmstype: lms ? lmsOrganizationBusinessType !== null && lmsOrganizationBusinessType !== void 0 ? lmsOrganizationBusinessType : undefined : undefined,
119
+ codec: VideoMimeType.Smooth,
120
+ autoplay: autoPlay,
121
+ autoplaynext: autoPlayNext,
122
+ endctrl: endControl,
123
+ notrack: materialVideoFileTrackerDisabled,
124
+ origin: window.location.origin,
125
+ locale: locale,
126
+ otp: otp
127
+ };
128
+ })
129
+ // create url from search params
130
+ .then(function (params) {
131
+ var url = new URL(eliceVideoPlayerUrl);
132
+ Object.entries(params).forEach(function (_ref2) {
133
+ var _ref3 = _rollupPluginBabelHelpers.slicedToArray(_ref2, 2),
134
+ key = _ref3[0],
135
+ value = _ref3[1];
117
136
  if (value) {
118
137
  url.searchParams.set(key, value);
119
138
  }
120
139
  });
121
140
  return url;
122
- }).then(url => url.href).then(setPlayerFrameSrc).catch(err => {
141
+ }).then(function (url) {
142
+ return url.href;
143
+ }).then(setPlayerFrameSrc).catch(function (err) {
123
144
  if (err.name !== 'AbortError') {
124
145
  setPlayerFrameSrc(null);
125
146
  }
126
147
  });
127
- return () => {
148
+ return function () {
128
149
  abortCtrl.abort();
129
150
  };
130
- }, [orgNameShort, materialVideoFile, materialVideoFileTrackerDisabled, mainLecturePageId, lms, lmsOrganizationBusinessType, eliceVideoPlayerUrl, autoPlay, autoPlayNext, endControl, locale]); //
151
+ }, [orgNameShort, materialVideoFile, materialVideoFileTrackerDisabled, mainLecturePageId, lms, lmsOrganizationBusinessType, eliceVideoPlayerUrl, autoPlay, autoPlayNext, endControl, locale, accountApi]);
152
+ //
131
153
  // Add event listener for navigating prev and next lecture page.
132
154
  //
133
-
134
- React__default["default"].useEffect(() => {
135
- const _handle = event => {
155
+ React__default["default"].useEffect(function () {
156
+ var _handle = function _handle(event) {
136
157
  var _a, _b, _c;
137
-
138
158
  try {
139
- const edata = JSON.parse(event.data);
140
-
159
+ var edata = JSON.parse(event.data);
141
160
  if (edata.key !== ELICE_VIDEO_PLAYER_MESSAGE_EVENT || ((_a = edata.event) === null || _a === void 0 ? void 0 : _a.type) !== ELICE_VIDEO_PLAYER_MESSAGE_TYPE) {
142
161
  return;
143
162
  }
144
-
145
163
  switch ((_c = (_b = edata.event) === null || _b === void 0 ? void 0 : _b.args) === null || _c === void 0 ? void 0 : _c.direction) {
146
164
  case 'previous':
147
165
  if (typeof onNavigatePreviousLecturePage === 'function') {
148
166
  onNavigatePreviousLecturePage();
149
167
  }
150
-
151
168
  break;
152
-
153
169
  case 'next':
154
170
  if (typeof onNavigateNextLecturePage === 'function') {
155
171
  onNavigateNextLecturePage === null || onNavigateNextLecturePage === void 0 ? void 0 : onNavigateNextLecturePage();
156
172
  }
157
-
158
173
  break;
159
174
  }
160
- } catch (_) {//
175
+ } catch (_) {
176
+ //
161
177
  }
162
178
  };
163
-
164
179
  window.addEventListener('message', _handle);
165
- return () => {
180
+ return function () {
166
181
  window.removeEventListener('message', _handle);
167
182
  };
168
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
169
- []); //
183
+ },
184
+ // eslint-disable-next-line react-hooks/exhaustive-deps
185
+ []);
186
+ //
170
187
  //
171
188
  //
172
189
  // pending
173
-
174
190
  if (materialVideoFileStatus === 'idle' || materialVideoFileStatus === 'pending' || materialVideoFileStatus === 'resolved' && !playerFrameSrc) {
175
191
  return React__default["default"].createElement(MaterialVideoFilePlayer_styled.StyledVideoPlayerLoading, null, React__default["default"].createElement(blocks.Spinner, null));
176
- } // rejected / empty video
177
-
178
-
192
+ }
193
+ // rejected / empty video
179
194
  if (materialVideoFileStatus === 'rejected' || materialVideoFileUploadStatus === VideoUploadStatus.Empty) {
180
195
  return React__default["default"].createElement(React__default["default"].Fragment, {
181
196
  children: emptyComponent
182
197
  });
183
- } // encoding
184
-
185
-
198
+ }
199
+ // encoding
186
200
  if (materialVideoFileUploadStatus === VideoUploadStatus.Encoding) {
187
201
  return React__default["default"].createElement(MaterialVideoFilePlayer_styled.StyledVideoPlayerLoading, null, React__default["default"].createElement(blocks.Spinner, null), React__default["default"].createElement(blocks.Text, {
188
202
  role: "gray3",
@@ -192,9 +206,8 @@ const MaterialVideoFilePlayer = ({
192
206
  }, React__default["default"].createElement(reactIntl.FormattedMessage, {
193
207
  id: "videoFile.player.encoding"
194
208
  })));
195
- } // encoding failed
196
-
197
-
209
+ }
210
+ // encoding failed
198
211
  if (materialVideoFileUploadStatus === VideoUploadStatus.EncodingFailed) {
199
212
  return React__default["default"].createElement(MaterialVideoFilePlayer_styled.StyledVideoPlayerLoading, null, React__default["default"].createElement(blocks.Text, {
200
213
  role: "gray3",
@@ -204,9 +217,8 @@ const MaterialVideoFilePlayer = ({
204
217
  }, React__default["default"].createElement(reactIntl.FormattedMessage, {
205
218
  id: "videoFile.player.encodingFailed"
206
219
  })));
207
- } // resolved
208
-
209
-
220
+ }
221
+ // resolved
210
222
  return React__default["default"].createElement(MaterialVideoFilePlayer_styled.StyledVideoPlayerWrap, {
211
223
  className: classnames__default["default"](prefixCls, className),
212
224
  src: playerFrameSrc,
@@ -215,9 +227,8 @@ const MaterialVideoFilePlayer = ({
215
227
  allowFullScreen: true
216
228
  });
217
229
  };
218
-
219
230
  var MaterialVideoFilePlayer$1 = Object.assign(MaterialVideoFilePlayer, {
220
231
  MimeType: VideoMimeType
221
232
  });
222
233
 
223
- module.exports = MaterialVideoFilePlayer$1;
234
+ exports["default"] = MaterialVideoFilePlayer$1;
@@ -8,10 +8,10 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
10
10
 
11
- const StyledVideoPlayerWrap = styled__default["default"].iframe.withConfig({
11
+ var StyledVideoPlayerWrap = styled__default["default"].iframe.withConfig({
12
12
  componentId: "sc-1ocq3lp-0"
13
13
  })(["width:100%;height:100%;border:0;"]);
14
- const StyledVideoPlayerLoading = styled__default["default"].div.withConfig({
14
+ var StyledVideoPlayerLoading = styled__default["default"].div.withConfig({
15
15
  componentId: "sc-1ocq3lp-1"
16
16
  })(["display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;"]);
17
17
 
@@ -2,14 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const en = {
5
+ var en = {
6
6
  'videoFile.player.preparing': 'Material on preparing.',
7
7
  'videoFile.player.uploadVideoBtn': 'Upload File',
8
8
  'videoFile.player.encoding': 'A video is being prepared.\nPlease check back later.',
9
9
  'videoFile.player.encodingFailed': 'There was a problem processing the video.\nIf the problem persists, please contact customer service.',
10
10
  'videoFile.player.noVideo': 'This file does not exist.'
11
11
  };
12
- const ko = {
12
+ var ko = {
13
13
  'videoFile.player.preparing': '자료를 준비 중입니다.',
14
14
  'videoFile.player.uploadVideoBtn': '파일 업로드',
15
15
  'videoFile.player.encoding': '동영상을 준비 중 입니다.\n잠시 후 다시 확인해주세요.',
@@ -0,0 +1,12 @@
1
+ import { AuthApi as EliceAccountAuthApi } from '@elice/openapi-client-account';
2
+ import type { Configuration as EliceAccountApiConfiguration } from '@elice/openapi-client-account';
3
+ export interface UseMaterialVideoFileApiProps {
4
+ eliceAccountApiConfiguration: EliceAccountApiConfiguration;
5
+ }
6
+ export interface UseMaterialVideoFileApiReturnMaterialRunbox {
7
+ auth: EliceAccountAuthApi;
8
+ }
9
+ export interface UseMaterialVideoFileApiReturn {
10
+ accountApi: UseMaterialVideoFileApiReturnMaterialRunbox;
11
+ }
12
+ export declare const useMaterialVideoFileApi: (props: UseMaterialVideoFileApiProps) => UseMaterialVideoFileApiReturn;
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var React = require('react');
7
+ var openapiClientAccount = require('@elice/openapi-client-account');
8
+
9
+ //
10
+ //
11
+ //
12
+ var useMaterialVideoFileApi = function useMaterialVideoFileApi(props) {
13
+ var _return = React.useRef({});
14
+ //
15
+ //
16
+ //
17
+ var createAccountApi = function createAccountApi() {
18
+ return Object.freeze({
19
+ auth: new openapiClientAccount.AuthApi(props.eliceAccountApiConfiguration)
20
+ });
21
+ };
22
+ //
23
+ //
24
+ //
25
+ var _useState = React.useState(createAccountApi),
26
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
27
+ accountApi = _useState2[0],
28
+ setAccountApi = _useState2[1];
29
+ //
30
+ //
31
+ //
32
+ React.useEffect(function () {
33
+ return setAccountApi(createAccountApi);
34
+ },
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ [props.eliceAccountApiConfiguration]);
37
+ //
38
+ //
39
+ //
40
+ _return.current.accountApi = accountApi;
41
+ return _return.current;
42
+ };
43
+
44
+ exports.useMaterialVideoFileApi = useMaterialVideoFileApi;
package/cjs/index.js CHANGED
@@ -6,4 +6,4 @@ var MaterialVideoFile = require('./components/material-video-file/MaterialVideoF
6
6
 
7
7
 
8
8
 
9
- exports.MaterialVideoFile = MaterialVideoFile;
9
+ exports.MaterialVideoFile = MaterialVideoFile["default"];
@@ -0,0 +1,51 @@
1
+ function _iterableToArrayLimit(arr, i) {
2
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
3
+ if (null != _i) {
4
+ var _s,
5
+ _e,
6
+ _x,
7
+ _r,
8
+ _arr = [],
9
+ _n = !0,
10
+ _d = !1;
11
+ try {
12
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
13
+ if (Object(_i) !== _i) return;
14
+ _n = !1;
15
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
16
+ } catch (err) {
17
+ _d = !0, _e = err;
18
+ } finally {
19
+ try {
20
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
21
+ } finally {
22
+ if (_d) throw _e;
23
+ }
24
+ }
25
+ return _arr;
26
+ }
27
+ }
28
+ function _slicedToArray(arr, i) {
29
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
30
+ }
31
+ function _arrayWithHoles(arr) {
32
+ if (Array.isArray(arr)) return arr;
33
+ }
34
+ function _unsupportedIterableToArray(o, minLen) {
35
+ if (!o) return;
36
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
37
+ var n = Object.prototype.toString.call(o).slice(8, -1);
38
+ if (n === "Object" && o.constructor) n = o.constructor.name;
39
+ if (n === "Map" || n === "Set") return Array.from(o);
40
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
41
+ }
42
+ function _arrayLikeToArray(arr, len) {
43
+ if (len == null || len > arr.length) len = arr.length;
44
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
45
+ return arr2;
46
+ }
47
+ function _nonIterableRest() {
48
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
49
+ }
50
+
51
+ export { _arrayLikeToArray as arrayLikeToArray, _arrayWithHoles as arrayWithHoles, _iterableToArrayLimit as iterableToArrayLimit, _nonIterableRest as nonIterableRest, _slicedToArray as slicedToArray, _unsupportedIterableToArray as unsupportedIterableToArray };
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { MaterialVideoFilePlayerProps } from './MaterialVideoFilePlayer';
3
+ import type { UseMaterialVideoFileApiProps } from './useMaterialVideoFileApi';
3
4
  declare type PickedVideoPlayerProps = Pick<MaterialVideoFilePlayerProps, 'materialVideoFileTrackerDisabled' | 'mainLecturePageId' | 'lms' | 'lmsOrganizationBusinessType' | 'emptyComponent' | 'autoPlay' | 'autoPlayNext' | 'endControl' | 'eliceVideoPlayerUrl' | 'onNavigatePreviousLecturePage' | 'onNavigateNextLecturePage'>;
4
- export interface MaterialVideoFileProps extends PickedVideoPlayerProps {
5
+ export interface MaterialVideoFileProps extends PickedVideoPlayerProps, UseMaterialVideoFileApiProps {
5
6
  materialVideoFileId: number;
6
7
  className?: string;
7
8
  locale?: string;
@@ -8,33 +8,39 @@ import classnames from 'classnames';
8
8
  import * as locales from './locales.js';
9
9
  import { en } from './locales.js';
10
10
  import MaterialVideoFilePlayer from './MaterialVideoFilePlayer.js';
11
+ import { useMaterialVideoFileApi } from './useMaterialVideoFileApi.js';
11
12
  import { StyledMaterialVideoFileWrap } from './MaterialVideoFile.styled.js';
12
13
 
13
- const MaterialVideoFile = _a => {
14
+ //
15
+ //
16
+ //
17
+ var MaterialVideoFile = function MaterialVideoFile(_a) {
14
18
  var _b, _c;
15
-
16
- var {
17
- materialVideoFileId,
18
- className,
19
- locale = 'en'
20
- } = _a,
21
- playerProps = __rest(_a, ["materialVideoFileId", "className", "locale"]);
22
-
23
- const prefixCls = 'em-material-video-file';
24
- const {
25
- orgNameShort
26
- } = useMaterialConfig();
27
- const {
28
- materialVideoFile,
29
- status: materialVideoFileStatus
30
- } = useMaterialFetch(enums.LectureMaterialType.VideoFile, React.useCallback(signal => getOrgMaterialVideoFileGet({
31
- materialVideoFileId
32
- }, {
33
- signal
34
- }), [materialVideoFileId]), config.init); //
19
+ var materialVideoFileId = _a.materialVideoFileId,
20
+ className = _a.className,
21
+ _a$locale = _a.locale,
22
+ locale = _a$locale === void 0 ? 'en' : _a$locale,
23
+ eliceAccountApiConfiguration = _a.eliceAccountApiConfiguration,
24
+ playerProps = __rest(_a, ["materialVideoFileId", "className", "locale", "eliceAccountApiConfiguration"]);
25
+ var prefixCls = 'em-material-video-file';
26
+ var _useMaterialConfig = useMaterialConfig(),
27
+ orgNameShort = _useMaterialConfig.orgNameShort;
28
+ var _useMaterialVideoFile = useMaterialVideoFileApi({
29
+ eliceAccountApiConfiguration: eliceAccountApiConfiguration
30
+ }),
31
+ accountApi = _useMaterialVideoFile.accountApi;
32
+ var _useMaterialFetch = useMaterialFetch(enums.LectureMaterialType.VideoFile, React.useCallback(function (signal) {
33
+ return getOrgMaterialVideoFileGet({
34
+ materialVideoFileId: materialVideoFileId
35
+ }, {
36
+ signal: signal
37
+ });
38
+ }, [materialVideoFileId]), config.init),
39
+ materialVideoFile = _useMaterialFetch.materialVideoFile,
40
+ materialVideoFileStatus = _useMaterialFetch.status;
41
+ //
35
42
  //
36
43
  //
37
-
38
44
  return React.createElement(StyledMaterialVideoFileWrap, {
39
45
  className: classnames(prefixCls, className)
40
46
  }, React.createElement(IntlProvider, {
@@ -45,6 +51,7 @@ const MaterialVideoFile = _a => {
45
51
  orgNameShort: orgNameShort,
46
52
  materialVideoFile: materialVideoFile !== null && materialVideoFile !== void 0 ? materialVideoFile : null,
47
53
  materialVideoFileStatus: materialVideoFileStatus,
54
+ accountApi: accountApi,
48
55
  title: (_c = (_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.videoAssetName) !== null && _c !== void 0 ? _c : undefined
49
56
  }))));
50
57
  };
@@ -1,7 +1,7 @@
1
1
  import { base } from '@elice/design-tokens';
2
2
  import styled from 'styled-components';
3
3
 
4
- const StyledMaterialVideoFileWrap = styled.div.withConfig({
4
+ var StyledMaterialVideoFileWrap = styled.div.withConfig({
5
5
  componentId: "sc-1a1otok-0"
6
6
  })(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;background:", ";"], base.color.gray9);
7
7
 
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { APIStatus } from '@elice/material-shared-types';
3
3
  import type { EliceVideoPlayerSearchParams, GetOrgMaterialVideoFileGetResponses } from '@elice/types';
4
- export interface MaterialVideoFilePlayerProps {
4
+ import type { UseMaterialVideoFileApiReturn } from './useMaterialVideoFileApi';
5
+ export interface MaterialVideoFilePlayerProps extends UseMaterialVideoFileApiReturn {
5
6
  /** Classname for the element. */
6
7
  className?: string;
7
8
  /** Material video file. */
@@ -1,181 +1,193 @@
1
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import React from 'react';
2
3
  import { FormattedMessage } from 'react-intl';
3
- import { postGlobalAuthOtpKeyMake } from '@elice/api-client';
4
4
  import { Spinner, Text } from '@elice/blocks';
5
5
  import { enums } from '@elice/types';
6
6
  import classnames from 'classnames';
7
7
  import { StyledVideoPlayerLoading, StyledVideoPlayerWrap } from './MaterialVideoFilePlayer.styled.js';
8
8
 
9
+ //
10
+ //
11
+ //
9
12
  var VideoUploadStatus;
10
-
11
13
  (function (VideoUploadStatus) {
12
14
  VideoUploadStatus[VideoUploadStatus["Empty"] = 0] = "Empty";
13
15
  VideoUploadStatus[VideoUploadStatus["Encoding"] = 1] = "Encoding";
14
16
  VideoUploadStatus[VideoUploadStatus["EncodingFailed"] = 2] = "EncodingFailed";
15
17
  VideoUploadStatus[VideoUploadStatus["Ready"] = 3] = "Ready";
16
18
  })(VideoUploadStatus || (VideoUploadStatus = {}));
17
-
18
19
  var VideoMimeType;
19
-
20
20
  (function (VideoMimeType) {
21
21
  /** `application/vnd.ms-sstr+xml` */
22
22
  VideoMimeType["Smooth"] = "application/vnd.ms-sstr+xml";
23
23
  /** `application/vnd.apple.mpegurl` */
24
-
25
24
  VideoMimeType["Hls"] = "application/vnd.apple.mpegurl";
26
25
  /** `application/dash+xml` */
27
-
28
26
  VideoMimeType["Mpeg"] = "application/dash+xml";
29
27
  })(VideoMimeType || (VideoMimeType = {}));
30
-
31
- const ELICE_VIDEO_PLAYER_MESSAGE_EVENT = 'elice-videoplayer';
32
- const ELICE_VIDEO_PLAYER_MESSAGE_TYPE = 'navigate';
33
-
34
- const MaterialVideoFilePlayer = ({
35
- className,
36
- materialVideoFile,
37
- materialVideoFileStatus = 'idle',
38
- materialVideoFileTrackerDisabled = false,
39
- mainLecturePageId,
40
- orgNameShort,
41
- lms = false,
42
- lmsOrganizationBusinessType = null,
43
- autoPlay = false,
44
- autoPlayNext = false,
45
- endControl = false,
46
- locale,
47
- eliceVideoPlayerUrl,
48
- emptyComponent = null,
49
- title = 'elice-videoplayer',
50
- onNavigatePreviousLecturePage,
51
- onNavigateNextLecturePage
52
- }) => {
53
- const prefixCls = 'em-video-player';
54
- const [playerFrameSrc, setPlayerFrameSrc] = React.useState(null);
28
+ //
29
+ //
30
+ //
31
+ var ELICE_VIDEO_PLAYER_MESSAGE_EVENT = 'elice-videoplayer';
32
+ var ELICE_VIDEO_PLAYER_MESSAGE_TYPE = 'navigate';
33
+ //
34
+ //
35
+ //
36
+ var MaterialVideoFilePlayer = function MaterialVideoFilePlayer(_ref) {
37
+ var className = _ref.className,
38
+ materialVideoFile = _ref.materialVideoFile,
39
+ _ref$materialVideoFil = _ref.materialVideoFileStatus,
40
+ materialVideoFileStatus = _ref$materialVideoFil === void 0 ? 'idle' : _ref$materialVideoFil,
41
+ _ref$materialVideoFil2 = _ref.materialVideoFileTrackerDisabled,
42
+ materialVideoFileTrackerDisabled = _ref$materialVideoFil2 === void 0 ? false : _ref$materialVideoFil2,
43
+ mainLecturePageId = _ref.mainLecturePageId,
44
+ orgNameShort = _ref.orgNameShort,
45
+ _ref$lms = _ref.lms,
46
+ lms = _ref$lms === void 0 ? false : _ref$lms,
47
+ _ref$lmsOrganizationB = _ref.lmsOrganizationBusinessType,
48
+ lmsOrganizationBusinessType = _ref$lmsOrganizationB === void 0 ? null : _ref$lmsOrganizationB,
49
+ _ref$autoPlay = _ref.autoPlay,
50
+ autoPlay = _ref$autoPlay === void 0 ? false : _ref$autoPlay,
51
+ _ref$autoPlayNext = _ref.autoPlayNext,
52
+ autoPlayNext = _ref$autoPlayNext === void 0 ? false : _ref$autoPlayNext,
53
+ _ref$endControl = _ref.endControl,
54
+ endControl = _ref$endControl === void 0 ? false : _ref$endControl,
55
+ locale = _ref.locale,
56
+ eliceVideoPlayerUrl = _ref.eliceVideoPlayerUrl,
57
+ _ref$emptyComponent = _ref.emptyComponent,
58
+ emptyComponent = _ref$emptyComponent === void 0 ? null : _ref$emptyComponent,
59
+ _ref$title = _ref.title,
60
+ title = _ref$title === void 0 ? 'elice-videoplayer' : _ref$title,
61
+ onNavigatePreviousLecturePage = _ref.onNavigatePreviousLecturePage,
62
+ onNavigateNextLecturePage = _ref.onNavigateNextLecturePage,
63
+ accountApi = _ref.accountApi;
64
+ var prefixCls = 'em-video-player';
65
+ var _React$useState = React.useState(null),
66
+ _React$useState2 = _slicedToArray(_React$useState, 2),
67
+ playerFrameSrc = _React$useState2[0],
68
+ setPlayerFrameSrc = _React$useState2[1];
55
69
  /**
56
70
  * Current video status.
57
71
  */
58
-
59
- const materialVideoFileUploadStatus = React.useMemo(() => {
72
+ var materialVideoFileUploadStatus = React.useMemo(function () {
60
73
  var _a, _b, _c, _d;
61
-
62
74
  switch (true) {
63
75
  case typeof ((_a = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _a === void 0 ? void 0 : _a.status) === 'undefined':
64
76
  return VideoUploadStatus.Empty;
65
-
66
77
  case ((_b = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _b === void 0 ? void 0 : _b.status) === enums.AzureMediaVideoStatus.Encoding:
67
78
  return VideoUploadStatus.Encoding;
68
-
69
79
  case ((_c = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _c === void 0 ? void 0 : _c.status) === enums.AzureMediaVideoStatus.Error:
70
80
  return VideoUploadStatus.EncodingFailed;
71
-
72
81
  case ((_d = materialVideoFile === null || materialVideoFile === void 0 ? void 0 : materialVideoFile.azureMediaVideo) === null || _d === void 0 ? void 0 : _d.status) === enums.AzureMediaVideoStatus.Done && typeof materialVideoFile.azureMediaVideo.videoStreamingUrl === 'string':
73
82
  return VideoUploadStatus.Ready;
74
-
75
83
  default:
76
84
  return VideoUploadStatus.Empty;
77
85
  }
78
- }, [materialVideoFile]); //
86
+ }, [materialVideoFile]);
87
+ //
79
88
  // Get video iframe src.
80
89
  //
81
-
82
- React.useEffect(() => {
90
+ React.useEffect(function () {
83
91
  if (!eliceVideoPlayerUrl || !materialVideoFile) {
84
92
  return;
85
93
  }
86
-
87
- const abortCtrl = new AbortController();
88
- postGlobalAuthOtpKeyMake({
94
+ var abortCtrl = new AbortController();
95
+ accountApi.auth.authOtpPost({
89
96
  signal: abortCtrl.signal
90
- }) // issue otp key
91
- .then(res => res.otpKey) // create search params
92
- .then(otp => ({
93
- org: orgNameShort,
94
- mid: materialVideoFile.id,
95
- lmid: mainLecturePageId,
96
- lms,
97
- lmstype: lms ? lmsOrganizationBusinessType !== null && lmsOrganizationBusinessType !== void 0 ? lmsOrganizationBusinessType : undefined : undefined,
98
- codec: VideoMimeType.Smooth,
99
- autoplay: autoPlay,
100
- autoplaynext: autoPlayNext,
101
- endctrl: endControl,
102
- notrack: materialVideoFileTrackerDisabled,
103
- origin: window.location.origin,
104
- locale,
105
- otp
106
- })) // create url from search params
107
- .then(params => {
108
- const url = new URL(eliceVideoPlayerUrl);
109
- Object.entries(params).forEach(([key, value]) => {
97
+ })
98
+ // issue otp key
99
+ .then(function (res) {
100
+ return res.otp;
101
+ })
102
+ // create search params
103
+ .then(function (otp) {
104
+ return {
105
+ org: orgNameShort,
106
+ mid: materialVideoFile.id,
107
+ lmid: mainLecturePageId,
108
+ lms: lms,
109
+ lmstype: lms ? lmsOrganizationBusinessType !== null && lmsOrganizationBusinessType !== void 0 ? lmsOrganizationBusinessType : undefined : undefined,
110
+ codec: VideoMimeType.Smooth,
111
+ autoplay: autoPlay,
112
+ autoplaynext: autoPlayNext,
113
+ endctrl: endControl,
114
+ notrack: materialVideoFileTrackerDisabled,
115
+ origin: window.location.origin,
116
+ locale: locale,
117
+ otp: otp
118
+ };
119
+ })
120
+ // create url from search params
121
+ .then(function (params) {
122
+ var url = new URL(eliceVideoPlayerUrl);
123
+ Object.entries(params).forEach(function (_ref2) {
124
+ var _ref3 = _slicedToArray(_ref2, 2),
125
+ key = _ref3[0],
126
+ value = _ref3[1];
110
127
  if (value) {
111
128
  url.searchParams.set(key, value);
112
129
  }
113
130
  });
114
131
  return url;
115
- }).then(url => url.href).then(setPlayerFrameSrc).catch(err => {
132
+ }).then(function (url) {
133
+ return url.href;
134
+ }).then(setPlayerFrameSrc).catch(function (err) {
116
135
  if (err.name !== 'AbortError') {
117
136
  setPlayerFrameSrc(null);
118
137
  }
119
138
  });
120
- return () => {
139
+ return function () {
121
140
  abortCtrl.abort();
122
141
  };
123
- }, [orgNameShort, materialVideoFile, materialVideoFileTrackerDisabled, mainLecturePageId, lms, lmsOrganizationBusinessType, eliceVideoPlayerUrl, autoPlay, autoPlayNext, endControl, locale]); //
142
+ }, [orgNameShort, materialVideoFile, materialVideoFileTrackerDisabled, mainLecturePageId, lms, lmsOrganizationBusinessType, eliceVideoPlayerUrl, autoPlay, autoPlayNext, endControl, locale, accountApi]);
143
+ //
124
144
  // Add event listener for navigating prev and next lecture page.
125
145
  //
126
-
127
- React.useEffect(() => {
128
- const _handle = event => {
146
+ React.useEffect(function () {
147
+ var _handle = function _handle(event) {
129
148
  var _a, _b, _c;
130
-
131
149
  try {
132
- const edata = JSON.parse(event.data);
133
-
150
+ var edata = JSON.parse(event.data);
134
151
  if (edata.key !== ELICE_VIDEO_PLAYER_MESSAGE_EVENT || ((_a = edata.event) === null || _a === void 0 ? void 0 : _a.type) !== ELICE_VIDEO_PLAYER_MESSAGE_TYPE) {
135
152
  return;
136
153
  }
137
-
138
154
  switch ((_c = (_b = edata.event) === null || _b === void 0 ? void 0 : _b.args) === null || _c === void 0 ? void 0 : _c.direction) {
139
155
  case 'previous':
140
156
  if (typeof onNavigatePreviousLecturePage === 'function') {
141
157
  onNavigatePreviousLecturePage();
142
158
  }
143
-
144
159
  break;
145
-
146
160
  case 'next':
147
161
  if (typeof onNavigateNextLecturePage === 'function') {
148
162
  onNavigateNextLecturePage === null || onNavigateNextLecturePage === void 0 ? void 0 : onNavigateNextLecturePage();
149
163
  }
150
-
151
164
  break;
152
165
  }
153
- } catch (_) {//
166
+ } catch (_) {
167
+ //
154
168
  }
155
169
  };
156
-
157
170
  window.addEventListener('message', _handle);
158
- return () => {
171
+ return function () {
159
172
  window.removeEventListener('message', _handle);
160
173
  };
161
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
162
- []); //
174
+ },
175
+ // eslint-disable-next-line react-hooks/exhaustive-deps
176
+ []);
177
+ //
163
178
  //
164
179
  //
165
180
  // pending
166
-
167
181
  if (materialVideoFileStatus === 'idle' || materialVideoFileStatus === 'pending' || materialVideoFileStatus === 'resolved' && !playerFrameSrc) {
168
182
  return React.createElement(StyledVideoPlayerLoading, null, React.createElement(Spinner, null));
169
- } // rejected / empty video
170
-
171
-
183
+ }
184
+ // rejected / empty video
172
185
  if (materialVideoFileStatus === 'rejected' || materialVideoFileUploadStatus === VideoUploadStatus.Empty) {
173
186
  return React.createElement(React.Fragment, {
174
187
  children: emptyComponent
175
188
  });
176
- } // encoding
177
-
178
-
189
+ }
190
+ // encoding
179
191
  if (materialVideoFileUploadStatus === VideoUploadStatus.Encoding) {
180
192
  return React.createElement(StyledVideoPlayerLoading, null, React.createElement(Spinner, null), React.createElement(Text, {
181
193
  role: "gray3",
@@ -185,9 +197,8 @@ const MaterialVideoFilePlayer = ({
185
197
  }, React.createElement(FormattedMessage, {
186
198
  id: "videoFile.player.encoding"
187
199
  })));
188
- } // encoding failed
189
-
190
-
200
+ }
201
+ // encoding failed
191
202
  if (materialVideoFileUploadStatus === VideoUploadStatus.EncodingFailed) {
192
203
  return React.createElement(StyledVideoPlayerLoading, null, React.createElement(Text, {
193
204
  role: "gray3",
@@ -197,9 +208,8 @@ const MaterialVideoFilePlayer = ({
197
208
  }, React.createElement(FormattedMessage, {
198
209
  id: "videoFile.player.encodingFailed"
199
210
  })));
200
- } // resolved
201
-
202
-
211
+ }
212
+ // resolved
203
213
  return React.createElement(StyledVideoPlayerWrap, {
204
214
  className: classnames(prefixCls, className),
205
215
  src: playerFrameSrc,
@@ -208,7 +218,6 @@ const MaterialVideoFilePlayer = ({
208
218
  allowFullScreen: true
209
219
  });
210
220
  };
211
-
212
221
  var MaterialVideoFilePlayer$1 = Object.assign(MaterialVideoFilePlayer, {
213
222
  MimeType: VideoMimeType
214
223
  });
@@ -1,9 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
 
3
- const StyledVideoPlayerWrap = styled.iframe.withConfig({
3
+ var StyledVideoPlayerWrap = styled.iframe.withConfig({
4
4
  componentId: "sc-1ocq3lp-0"
5
5
  })(["width:100%;height:100%;border:0;"]);
6
- const StyledVideoPlayerLoading = styled.div.withConfig({
6
+ var StyledVideoPlayerLoading = styled.div.withConfig({
7
7
  componentId: "sc-1ocq3lp-1"
8
8
  })(["display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;"]);
9
9
 
@@ -1,11 +1,11 @@
1
- const en = {
1
+ var en = {
2
2
  'videoFile.player.preparing': 'Material on preparing.',
3
3
  'videoFile.player.uploadVideoBtn': 'Upload File',
4
4
  'videoFile.player.encoding': 'A video is being prepared.\nPlease check back later.',
5
5
  'videoFile.player.encodingFailed': 'There was a problem processing the video.\nIf the problem persists, please contact customer service.',
6
6
  'videoFile.player.noVideo': 'This file does not exist.'
7
7
  };
8
- const ko = {
8
+ var ko = {
9
9
  'videoFile.player.preparing': '자료를 준비 중입니다.',
10
10
  'videoFile.player.uploadVideoBtn': '파일 업로드',
11
11
  'videoFile.player.encoding': '동영상을 준비 중 입니다.\n잠시 후 다시 확인해주세요.',
@@ -0,0 +1,12 @@
1
+ import { AuthApi as EliceAccountAuthApi } from '@elice/openapi-client-account';
2
+ import type { Configuration as EliceAccountApiConfiguration } from '@elice/openapi-client-account';
3
+ export interface UseMaterialVideoFileApiProps {
4
+ eliceAccountApiConfiguration: EliceAccountApiConfiguration;
5
+ }
6
+ export interface UseMaterialVideoFileApiReturnMaterialRunbox {
7
+ auth: EliceAccountAuthApi;
8
+ }
9
+ export interface UseMaterialVideoFileApiReturn {
10
+ accountApi: UseMaterialVideoFileApiReturnMaterialRunbox;
11
+ }
12
+ export declare const useMaterialVideoFileApi: (props: UseMaterialVideoFileApiProps) => UseMaterialVideoFileApiReturn;
@@ -0,0 +1,40 @@
1
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { useRef, useState, useEffect } from 'react';
3
+ import { AuthApi } from '@elice/openapi-client-account';
4
+
5
+ //
6
+ //
7
+ //
8
+ var useMaterialVideoFileApi = function useMaterialVideoFileApi(props) {
9
+ var _return = useRef({});
10
+ //
11
+ //
12
+ //
13
+ var createAccountApi = function createAccountApi() {
14
+ return Object.freeze({
15
+ auth: new AuthApi(props.eliceAccountApiConfiguration)
16
+ });
17
+ };
18
+ //
19
+ //
20
+ //
21
+ var _useState = useState(createAccountApi),
22
+ _useState2 = _slicedToArray(_useState, 2),
23
+ accountApi = _useState2[0],
24
+ setAccountApi = _useState2[1];
25
+ //
26
+ //
27
+ //
28
+ useEffect(function () {
29
+ return setAccountApi(createAccountApi);
30
+ },
31
+ // eslint-disable-next-line react-hooks/exhaustive-deps
32
+ [props.eliceAccountApiConfiguration]);
33
+ //
34
+ //
35
+ //
36
+ _return.current.accountApi = accountApi;
37
+ return _return.current;
38
+ };
39
+
40
+ export { useMaterialVideoFileApi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-video-file",
3
- "version": "1.230328.0",
3
+ "version": "1.230418.0",
4
4
  "description": "User view and editing components of Elice material video file",
5
5
  "repository": "https://git.elicer.io/elice/frontend/library/elice-material",
6
6
  "license": "UNLICENSED",
@@ -29,13 +29,14 @@
29
29
  "clean": "del-cli \"es/*\" \"cjs/*\" \"dist/*\""
30
30
  },
31
31
  "peerDependencies": {
32
- "@elice/api-client": "1.230306.1",
32
+ "@elice/api-client": "^1.230413.0",
33
33
  "@elice/blocks": "^1.220803.0",
34
34
  "@elice/design-tokens": "^1.220803.0",
35
35
  "@elice/icons": "^1.220803.0",
36
36
  "@elice/material-shared-types": "*",
37
37
  "@elice/material-shared-utils": "*",
38
- "@elice/types": "^1.230306.0",
38
+ "@elice/openapi-client-account": "^1.230302.0",
39
+ "@elice/types": "^1.230417.0",
39
40
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
40
41
  "react-intl": "^5.0.0",
41
42
  "react-use": "^17.0.0",
@@ -47,14 +48,15 @@
47
48
  "tslib": "^2.3.1"
48
49
  },
49
50
  "devDependencies": {
50
- "@elice/api-client": "1.230306.1",
51
+ "@elice/api-client": "^1.230413.0",
51
52
  "@elice/blocks": "^1.220803.0",
52
53
  "@elice/design-tokens": "^1.220803.0",
53
54
  "@elice/icons": "^1.220803.0",
54
55
  "@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
55
- "@elice/material-shared-types": "1.230328.0",
56
- "@elice/material-shared-utils": "1.230328.0",
57
- "@elice/types": "^1.230306.0",
56
+ "@elice/material-shared-types": "1.230418.0",
57
+ "@elice/material-shared-utils": "1.230418.0",
58
+ "@elice/openapi-client-account": "^1.230302.0",
59
+ "@elice/types": "^1.230417.0",
58
60
  "@types/classnames": "^2.3.1",
59
61
  "@types/query-string": "^6.3.0",
60
62
  "@types/react": "~17.0.9",
@@ -64,5 +66,5 @@
64
66
  "react-use": "^17.2.4",
65
67
  "styled-components": "^5.3.0"
66
68
  },
67
- "gitHead": "c24abeffe609385031a77c725bf6e92e47e94b56"
69
+ "gitHead": "06d5f856939bdbb6bffa9eba30f2fab56d66129b"
68
70
  }