@micromag/screen-audio 0.3.541 → 0.3.547

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 (3) hide show
  1. package/es/index.js +2 -3
  2. package/package.json +12 -13
  3. package/lib/index.js +0 -394
package/es/index.js CHANGED
@@ -294,7 +294,6 @@ var AudioScreen = function AudioScreen(_ref) {
294
294
  };
295
295
  AudioScreen.propTypes = propTypes;
296
296
  AudioScreen.defaultProps = defaultProps;
297
- var AudioScreen$1 = AudioScreen;
298
297
 
299
298
  // import * as transforms from './transforms/index';
300
299
 
@@ -318,7 +317,7 @@ var definition = {
318
317
  "value": "Audio"
319
318
  }]
320
319
  }),
321
- component: AudioScreen$1,
320
+ component: AudioScreen,
322
321
  layouts: ['middle'],
323
322
  // transforms,
324
323
  fields: [{
@@ -386,4 +385,4 @@ var definition = {
386
385
  }]
387
386
  };
388
387
 
389
- export { AudioScreen$1 as AudioScreen, definition as default };
388
+ export { AudioScreen, definition as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-audio",
3
- "version": "0.3.541",
3
+ "version": "0.3.547",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -30,12 +30,11 @@
30
30
  }
31
31
  ],
32
32
  "license": "ISC",
33
- "main": "lib/index.js",
33
+ "type": "module",
34
34
  "module": "es/index.js",
35
35
  "style": "assets/css/styles.css",
36
36
  "exports": {
37
37
  ".": {
38
- "require": "./lib/index.js",
39
38
  "import": "./es/index.js"
40
39
  },
41
40
  "./assets/css/styles": "./assets/css/styles.css",
@@ -61,15 +60,15 @@
61
60
  },
62
61
  "dependencies": {
63
62
  "@babel/runtime": "^7.13.10",
64
- "@micromag/core": "^0.3.541",
65
- "@micromag/element-audio": "^0.3.541",
66
- "@micromag/element-background": "^0.3.541",
67
- "@micromag/element-closed-captions": "^0.3.541",
68
- "@micromag/element-container": "^0.3.541",
69
- "@micromag/element-footer": "^0.3.541",
70
- "@micromag/element-header": "^0.3.541",
71
- "@micromag/element-layout": "^0.3.541",
72
- "@micromag/transforms": "^0.3.541",
63
+ "@micromag/core": "^0.3.547",
64
+ "@micromag/element-audio": "^0.3.547",
65
+ "@micromag/element-background": "^0.3.547",
66
+ "@micromag/element-closed-captions": "^0.3.547",
67
+ "@micromag/element-container": "^0.3.547",
68
+ "@micromag/element-footer": "^0.3.547",
69
+ "@micromag/element-header": "^0.3.547",
70
+ "@micromag/element-layout": "^0.3.547",
71
+ "@micromag/transforms": "^0.3.547",
73
72
  "classnames": "^2.2.6",
74
73
  "lodash": "^4.17.21",
75
74
  "prop-types": "^15.7.2",
@@ -80,5 +79,5 @@
80
79
  "access": "public",
81
80
  "registry": "https://registry.npmjs.org/"
82
81
  },
83
- "gitHead": "6c04a7e327b5fbc096785c11320b3fbd3c5751c8"
82
+ "gitHead": "3c2f5904ce61fcfa61f673c38c2a5ec56e9e2b07"
84
83
  }
package/lib/index.js DELETED
@@ -1,394 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactIntl = require('react-intl');
6
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
8
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
9
- var classNames = require('classnames');
10
- var PropTypes = require('prop-types');
11
- var React = require('react');
12
- var core = require('@micromag/core');
13
- var components = require('@micromag/core/components');
14
- var contexts = require('@micromag/core/contexts');
15
- var hooks = require('@micromag/core/hooks');
16
- var utils = require('@micromag/core/utils');
17
- var Audio = require('@micromag/element-audio');
18
- var Background = require('@micromag/element-background');
19
- var ClosedCaptions = require('@micromag/element-closed-captions');
20
- var Container = require('@micromag/element-container');
21
- var Footer = require('@micromag/element-footer');
22
- var Header = require('@micromag/element-header');
23
- var Layout = require('@micromag/element-layout');
24
-
25
- var styles = {"container":"micromag-screen-audio-container","background":"micromag-screen-audio-background","disabled":"micromag-screen-audio-disabled","hidden":"micromag-screen-audio-hidden","placeholder":"micromag-screen-audio-placeholder","content":"micromag-screen-audio-content","empty":"micromag-screen-audio-empty","audio":"micromag-screen-audio-audio","bottom":"micromag-screen-audio-bottom","isPreview":"micromag-screen-audio-isPreview"};
26
-
27
- var propTypes = {
28
- layout: PropTypes.oneOf(['middle']),
29
- audio: core.PropTypes.audioElement,
30
- spacing: PropTypes.number,
31
- background: core.PropTypes.backgroundElement,
32
- header: core.PropTypes.header,
33
- footer: core.PropTypes.footer,
34
- current: PropTypes.bool,
35
- active: PropTypes.bool,
36
- mediaRef: PropTypes.func,
37
- showWave: PropTypes.bool,
38
- className: PropTypes.string
39
- };
40
- var defaultProps = {
41
- layout: 'middle',
42
- audio: null,
43
- spacing: 20,
44
- background: null,
45
- header: null,
46
- footer: null,
47
- current: true,
48
- active: true,
49
- mediaRef: null,
50
- showWave: true,
51
- className: null
52
- };
53
- var AudioScreen = function AudioScreen(_ref) {
54
- _ref.layout;
55
- var audio = _ref.audio,
56
- spacing = _ref.spacing,
57
- background = _ref.background,
58
- header = _ref.header,
59
- footer = _ref.footer,
60
- current = _ref.current,
61
- active = _ref.active,
62
- customMediaRef = _ref.mediaRef,
63
- showWave = _ref.showWave,
64
- className = _ref.className;
65
- var _useScreenSize = contexts.useScreenSize(),
66
- width = _useScreenSize.width,
67
- height = _useScreenSize.height,
68
- resolution = _useScreenSize.resolution;
69
- var _useScreenRenderConte = contexts.useScreenRenderContext(),
70
- isPlaceholder = _useScreenRenderConte.isPlaceholder,
71
- isPreview = _useScreenRenderConte.isPreview,
72
- isView = _useScreenRenderConte.isView,
73
- isEdit = _useScreenRenderConte.isEdit,
74
- isStatic = _useScreenRenderConte.isStatic,
75
- isCapture = _useScreenRenderConte.isCapture;
76
- var _useViewerContext = contexts.useViewerContext(),
77
- viewerTopHeight = _useViewerContext.topHeight,
78
- viewerBottomHeight = _useViewerContext.bottomHeight,
79
- viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
80
- var _useViewerWebView = contexts.useViewerWebView(),
81
- openWebView = _useViewerWebView.open;
82
- var trackScreenMedia = hooks.useTrackScreenMedia('audio');
83
- var _useState = React.useState(isStatic || isPlaceholder),
84
- _useState2 = _slicedToArray(_useState, 2),
85
- ready = _useState2[0],
86
- setReady = _useState2[1];
87
- var backgroundPlaying = current && (isView || isEdit);
88
- var mediaShouldLoad = current || active;
89
- // const transitionPlaying = current && ready;
90
- // const transitionDisabled = isStatic || isCapture || isPlaceholder || isPreview || isEdit;
91
-
92
- var hasHeader = utils.isHeaderFilled(header);
93
- var hasFooter = utils.isFooterFilled(footer);
94
- var footerProps = utils.getFooterProps(footer, {
95
- isView: isView,
96
- current: current,
97
- openWebView: openWebView,
98
- isPreview: isPreview
99
- });
100
- var hasAudio = audio !== null;
101
- var _ref2 = audio || {},
102
- _ref2$media = _ref2.media,
103
- audioMedia = _ref2$media === void 0 ? null : _ref2$media,
104
- _ref2$autoPlay = _ref2.autoPlay,
105
- autoPlay = _ref2$autoPlay === void 0 ? true : _ref2$autoPlay,
106
- _ref2$closedCaptions = _ref2.closedCaptions,
107
- closedCaptions = _ref2$closedCaptions === void 0 ? null : _ref2$closedCaptions,
108
- _ref2$captions = _ref2.captions,
109
- captions = _ref2$captions === void 0 ? null : _ref2$captions,
110
- _ref2$withWave = _ref2.withWave,
111
- withWave = _ref2$withWave === void 0 ? false : _ref2$withWave,
112
- _ref2$withControls = _ref2.withControls,
113
- withControls = _ref2$withControls === void 0 ? false : _ref2$withControls,
114
- _ref2$withSeekBar = _ref2.withSeekBar,
115
- withSeekBar = _ref2$withSeekBar === void 0 ? false : _ref2$withSeekBar,
116
- _ref2$color = _ref2.color,
117
- color = _ref2$color === void 0 ? null : _ref2$color,
118
- _ref2$progressColor = _ref2.progressColor,
119
- progressColor = _ref2$progressColor === void 0 ? null : _ref2$progressColor;
120
- var _ref3 = audioMedia || {},
121
- _ref3$url = _ref3.url,
122
- audioUrl = _ref3$url === void 0 ? null : _ref3$url;
123
- var hasAudioUrl = audioUrl !== null;
124
- var finalAudio = hasAudio ? _objectSpread(_objectSpread({}, audio), {}, {
125
- autoPlay: !isPreview && !isStatic && !isCapture && autoPlay && current
126
- }) : null;
127
- var hasClosedCaptions = closedCaptions !== null || captions !== null;
128
- var _usePlaybackContext = contexts.usePlaybackContext(),
129
- playing = _usePlaybackContext.playing,
130
- muted = _usePlaybackContext.muted,
131
- setControls = _usePlaybackContext.setControls,
132
- setControlsSuggestPlay = _usePlaybackContext.setControlsSuggestPlay,
133
- setControlsTheme = _usePlaybackContext.setControlsTheme,
134
- setPlaying = _usePlaybackContext.setPlaying;
135
- var mediaRef = contexts.usePlaybackMediaRef(current);
136
- React.useEffect(function () {
137
- if (!current) {
138
- return function () {};
139
- }
140
- if (withControls || withSeekBar) {
141
- setControls(true);
142
- setControlsTheme({
143
- seekBarOnly: withSeekBar,
144
- color: color,
145
- progressColor: progressColor
146
- });
147
- } else {
148
- setControls(false);
149
- }
150
- return function () {
151
- if (withControls || withSeekBar) {
152
- setControls(false);
153
- }
154
- };
155
- }, [current, withControls, withSeekBar, setControls, color, progressColor]);
156
- React.useEffect(function () {
157
- if (customMediaRef !== null) {
158
- customMediaRef(mediaRef.current);
159
- }
160
- }, [mediaRef.current]);
161
- var onAudioReady = React.useCallback(function () {
162
- setReady(true);
163
- }, [setReady]);
164
- var _useState3 = React.useState(null),
165
- _useState4 = _slicedToArray(_useState3, 2),
166
- currentTime = _useState4[0],
167
- setCurrentTime = _useState4[1];
168
- var _useState5 = React.useState(null),
169
- _useState6 = _slicedToArray(_useState5, 2),
170
- duration = _useState6[0],
171
- setDuration = _useState6[1];
172
- var isIOS = React.useMemo(function () {
173
- return utils.isIos();
174
- }, [utils.isIos]);
175
- React.useEffect(function () {
176
- if (current && autoPlay && !playing) {
177
- setPlaying(true);
178
- }
179
- }, [current, autoPlay]);
180
- var onTimeUpdate = React.useCallback(function (_ref4) {
181
- var _ref4$timeStamp = _ref4.timeStamp,
182
- timeStamp = _ref4$timeStamp === void 0 ? 0 : _ref4$timeStamp;
183
- setCurrentTime(timeStamp);
184
- }, [setCurrentTime, setDuration, duration]);
185
- var onProgressStep = React.useCallback(function (step) {
186
- trackScreenMedia(audio, "progress_".concat(Math.round(step * 100, 10), "%"));
187
- }, [trackScreenMedia, audio]);
188
- var onDurationChange = React.useCallback(function (dur) {
189
- setDuration(dur);
190
- }, [setDuration]);
191
- var onPlay = React.useCallback(function (_ref5) {
192
- var initial = _ref5.initial;
193
- trackScreenMedia(audio, initial ? 'play' : 'resume');
194
- }, [trackScreenMedia, audio]);
195
- var onPause = React.useCallback(function (_ref6) {
196
- var midway = _ref6.midway;
197
- trackScreenMedia(audio, midway ? 'pause' : 'ended');
198
- }, [trackScreenMedia, audio]);
199
- var onEnded = React.useCallback(function () {
200
- if (current) {
201
- setPlaying(false);
202
- }
203
- }, [current, setPlaying]);
204
- var onSeeked = React.useCallback(function (time) {
205
- if (time > 0) {
206
- trackScreenMedia(audio, 'seek');
207
- }
208
- }, [trackScreenMedia, audio]);
209
- var onPlayError = React.useCallback(function () {
210
- if (isView && playing && current && hasAudio && autoPlay) {
211
- setPlaying(false);
212
- setControlsSuggestPlay(true);
213
- }
214
- }, [isView, current, playing, hasAudio, autoPlay, setPlaying, setControlsSuggestPlay]);
215
- return /*#__PURE__*/React.createElement("div", {
216
- className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.placeholder, isPlaceholder), styles.isPreview, isPreview)]),
217
- "data-screen-ready": ready
218
- }, /*#__PURE__*/React.createElement(Container, {
219
- width: width,
220
- height: height,
221
- className: styles.content
222
- }, /*#__PURE__*/React.createElement(Layout, {
223
- fullscreen: true,
224
- style: !isPlaceholder ? {
225
- padding: spacing,
226
- paddingTop: (!isPreview ? viewerTopHeight : 0) + (hasHeader ? spacing / 2 : spacing)
227
- } : null
228
- }, hasHeader ? /*#__PURE__*/React.createElement(Header, header) : /*#__PURE__*/React.createElement(Layout.Spacer, {
229
- key: "spacer-top"
230
- }), /*#__PURE__*/React.createElement(components.ScreenElement, {
231
- key: "audio",
232
- placeholder: "audio",
233
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
234
- id: "MYZwSA",
235
- defaultMessage: [{
236
- "type": 0,
237
- "value": "Audio"
238
- }]
239
- }),
240
- emptyClassName: styles.empty,
241
- isEmpty: !hasAudioUrl
242
- }, /*#__PURE__*/React.createElement(Audio, Object.assign({}, finalAudio, {
243
- mediaRef: mediaRef,
244
- waveFake: isIOS || isPreview,
245
- waveProps: isPreview ? {
246
- sampleWidth: 10,
247
- sampleMargin: 5,
248
- minSampleHeight: 5,
249
- backgroundColor: color,
250
- progressColor: progressColor
251
- } : {
252
- backgroundColor: color,
253
- progressColor: progressColor
254
- },
255
- paused: !current || !playing,
256
- muted: muted,
257
- className: styles.audio,
258
- onReady: onAudioReady,
259
- onPlay: onPlay,
260
- onPause: onPause,
261
- onTimeUpdate: onTimeUpdate,
262
- onProgressStep: onProgressStep,
263
- onDurationChange: onDurationChange,
264
- onSeeked: onSeeked,
265
- onEnded: onEnded,
266
- onPlayError: onPlayError,
267
- withWave: showWave && withWave
268
- }))), /*#__PURE__*/React.createElement(Layout.Spacer, {
269
- key: "spacer-middle"
270
- }), !isPlaceholder ? /*#__PURE__*/React.createElement("div", {
271
- key: "bottom",
272
- className: styles.bottom,
273
- style: {
274
- transform: current && !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
275
- paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
276
- paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
277
- paddingBottom: spacing / 2,
278
- paddingTop: 0
279
- }
280
- }, hasClosedCaptions && !isPreview && !isCapture && !isStatic ? /*#__PURE__*/React.createElement(ClosedCaptions, Object.assign({
281
- className: styles.closedCaptions,
282
- media: closedCaptions
283
- }, captions, {
284
- currentTime: currentTime
285
- })) : null, hasFooter ? /*#__PURE__*/React.createElement(Footer, Object.assign({}, footerProps, {
286
- className: styles.callToAction
287
- })) : null) : null)), !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
288
- background: background,
289
- width: width,
290
- height: height,
291
- resolution: resolution,
292
- playing: backgroundPlaying,
293
- muted: muted,
294
- shouldLoad: mediaShouldLoad,
295
- withoutVideo: isPreview,
296
- className: styles.background
297
- }) : null);
298
- };
299
- AudioScreen.propTypes = propTypes;
300
- AudioScreen.defaultProps = defaultProps;
301
- var AudioScreen$1 = AudioScreen;
302
-
303
- // import * as transforms from './transforms/index';
304
-
305
- var definition = {
306
- id: 'audio',
307
- type: 'screen',
308
- group: {
309
- label: reactIntl.defineMessage({
310
- id: "+9akmg",
311
- defaultMessage: [{
312
- "type": 0,
313
- "value": "Audio and Video"
314
- }]
315
- }),
316
- order: 5
317
- },
318
- title: reactIntl.defineMessage({
319
- id: "bhEaUt",
320
- defaultMessage: [{
321
- "type": 0,
322
- "value": "Audio"
323
- }]
324
- }),
325
- component: AudioScreen$1,
326
- layouts: ['middle'],
327
- // transforms,
328
- fields: [{
329
- name: 'audio',
330
- type: 'audio-element',
331
- theme: {
332
- color: 'primary'
333
- },
334
- defaultValue: {
335
- autoPlay: true
336
- },
337
- label: reactIntl.defineMessage({
338
- id: "169xnt",
339
- defaultMessage: [{
340
- "type": 0,
341
- "value": "Audio"
342
- }]
343
- })
344
- }, {
345
- name: 'background',
346
- type: 'background',
347
- label: reactIntl.defineMessage({
348
- id: "+MPZRu",
349
- defaultMessage: [{
350
- "type": 0,
351
- "value": "Background"
352
- }]
353
- })
354
- }, {
355
- name: 'header',
356
- type: 'header',
357
- label: reactIntl.defineMessage({
358
- id: "rhuDxI",
359
- defaultMessage: [{
360
- "type": 0,
361
- "value": "Header"
362
- }]
363
- }),
364
- theme: {
365
- badge: {
366
- label: {
367
- textStyle: 'badge'
368
- },
369
- boxStyle: 'badge'
370
- }
371
- }
372
- }, {
373
- name: 'footer',
374
- type: 'footer',
375
- label: reactIntl.defineMessage({
376
- id: "g4nybp",
377
- defaultMessage: [{
378
- "type": 0,
379
- "value": "Footer"
380
- }]
381
- }),
382
- theme: {
383
- callToAction: {
384
- label: {
385
- textStyle: 'cta'
386
- },
387
- boxStyle: 'cta'
388
- }
389
- }
390
- }]
391
- };
392
-
393
- exports.AudioScreen = AudioScreen$1;
394
- exports.default = definition;