@micromag/core 0.4.71 → 0.4.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/styles.css +0 -1
- package/assets/css/vendor.css +2 -3
- package/es/components.d.ts +99 -56
- package/es/components.js +5098 -2330
- package/es/contexts.d.ts +139 -67
- package/es/contexts.js +2182 -1239
- package/es/hooks.d.ts +28 -72
- package/es/hooks.js +2515 -2145
- package/es/index.d.ts +51 -8
- package/es/index.js +1284 -1525
- package/es/styles.css +0 -1
- package/es/utils.d.ts +155 -15
- package/es/utils.js +739 -888
- package/package.json +36 -40
- package/lib/components.js +0 -3404
- package/lib/contexts.js +0 -1762
- package/lib/hooks.js +0 -2532
- package/lib/index.js +0 -1713
- package/lib/styles.css +0 -35
- package/lib/utils.js +0 -1300
package/es/hooks.js
CHANGED
|
@@ -1,811 +1,965 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
1
|
+
import { c } from 'react/compiler-runtime';
|
|
2
|
+
import { useRef, useState, useEffect, useCallback, useMemo, startTransition } from 'react';
|
|
3
3
|
import { EventsManager, MediasParser, StoryParser, ThemeParser } from '@micromag/core';
|
|
4
|
-
import { createUseEvent,
|
|
5
|
-
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
|
+
import { createUseEvent, getMediaIsBuffering, getMediaFilename, getMediaIsPlaying, getMediaIsMuted, getMediaSrc, getMediaTimestampOffset, getMediaCurrentTime, getMediaDuration } from '@micromag/core/utils';
|
|
6
5
|
import { useSpringRef, useSpring, useSprings } from '@react-spring/core';
|
|
7
6
|
import { useGesture, useDrag } from '@use-gesture/react';
|
|
8
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
9
7
|
import { useForm as useForm$1 } from '@folklore/forms';
|
|
10
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
11
8
|
import classNames from 'classnames';
|
|
12
9
|
import screenfull from 'screenfull';
|
|
13
|
-
import
|
|
14
|
-
|
|
10
|
+
import { useResizeObserver, useIntersectionObserver, useWindowSize } from '@folklore/hooks';
|
|
11
|
+
export { useIntersectionObserver, useResizeObserver } from '@folklore/hooks';
|
|
15
12
|
import isObject from 'lodash/isObject';
|
|
16
13
|
import raf from 'raf';
|
|
17
14
|
import createDebug from 'debug';
|
|
18
15
|
import { useScreensManager, useFieldsManager, useTracking, useScreen } from '@micromag/core/contexts';
|
|
19
16
|
import isEmpty from 'lodash/isEmpty';
|
|
20
|
-
import { useWindowSize } from '@folklore/hooks';
|
|
21
17
|
import { match } from 'css-mediaquery';
|
|
18
|
+
import isArray from 'lodash/isArray';
|
|
22
19
|
import dayjs from 'dayjs';
|
|
23
20
|
import isString from 'lodash/isString';
|
|
24
21
|
import { useIntl } from 'react-intl';
|
|
25
22
|
import clamp from 'lodash/clamp';
|
|
26
23
|
|
|
27
|
-
function useActivityDetector() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!detectedRef.current) {
|
|
57
|
-
detectedRef.current = true;
|
|
58
|
-
setDetected(true);
|
|
59
|
-
}
|
|
60
|
-
timeout = setTimeout(function () {
|
|
61
|
-
detectedRef.current = false;
|
|
62
|
-
setDetected(false);
|
|
63
|
-
}, timeoutDelay);
|
|
64
|
-
}
|
|
65
|
-
element.addEventListener('keydown', onActivity);
|
|
66
|
-
element.addEventListener('mousedown', onActivity);
|
|
67
|
-
element.addEventListener('mousemove', onActivity);
|
|
68
|
-
element.addEventListener('mouseup', onActivity);
|
|
69
|
-
element.addEventListener('pointerdown', onActivity);
|
|
70
|
-
element.addEventListener('pointermove', onActivity);
|
|
71
|
-
element.addEventListener('pointerup', onActivity);
|
|
72
|
-
element.addEventListener('touchmove', onActivity);
|
|
73
|
-
element.addEventListener('touchstart', onActivity);
|
|
74
|
-
return function () {
|
|
75
|
-
if (timeout !== null) {
|
|
76
|
-
clearTimeout(timeout);
|
|
77
|
-
timeout = null;
|
|
24
|
+
function useActivityDetector(t0) {
|
|
25
|
+
const $ = c(8);
|
|
26
|
+
let t1;
|
|
27
|
+
if ($[0] !== t0) {
|
|
28
|
+
t1 = t0 === undefined ? {} : t0;
|
|
29
|
+
$[0] = t0;
|
|
30
|
+
$[1] = t1;
|
|
31
|
+
} else {
|
|
32
|
+
t1 = $[1];
|
|
33
|
+
}
|
|
34
|
+
const {
|
|
35
|
+
disabled: t2,
|
|
36
|
+
timeout: t3
|
|
37
|
+
} = t1;
|
|
38
|
+
const disabled = t2 === undefined ? false : t2;
|
|
39
|
+
const timeoutDelay = t3 === undefined ? 2000 : t3;
|
|
40
|
+
const ref = useRef(null);
|
|
41
|
+
const [detected, setDetected] = useState(false);
|
|
42
|
+
const detectedRef = useRef(detected);
|
|
43
|
+
let t4;
|
|
44
|
+
let t5;
|
|
45
|
+
if ($[2] !== disabled || $[3] !== timeoutDelay) {
|
|
46
|
+
t4 = () => {
|
|
47
|
+
const {
|
|
48
|
+
current: t6
|
|
49
|
+
} = ref;
|
|
50
|
+
const element = t6 === undefined ? null : t6;
|
|
51
|
+
if (element === null || disabled) {
|
|
52
|
+
return _temp$a;
|
|
78
53
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
54
|
+
let timeout = null;
|
|
55
|
+
const onActivity = function onActivity() {
|
|
56
|
+
if (timeout !== null) {
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
timeout = null;
|
|
59
|
+
}
|
|
60
|
+
if (!detectedRef.current) {
|
|
61
|
+
detectedRef.current = true;
|
|
62
|
+
setDetected(true);
|
|
63
|
+
}
|
|
64
|
+
timeout = setTimeout(() => {
|
|
65
|
+
detectedRef.current = false;
|
|
66
|
+
setDetected(false);
|
|
67
|
+
}, timeoutDelay);
|
|
68
|
+
};
|
|
69
|
+
element.addEventListener("keydown", onActivity);
|
|
70
|
+
element.addEventListener("mousedown", onActivity);
|
|
71
|
+
element.addEventListener("mousemove", onActivity);
|
|
72
|
+
element.addEventListener("mouseup", onActivity);
|
|
73
|
+
element.addEventListener("pointerdown", onActivity);
|
|
74
|
+
element.addEventListener("pointermove", onActivity);
|
|
75
|
+
element.addEventListener("pointerup", onActivity);
|
|
76
|
+
element.addEventListener("touchmove", onActivity);
|
|
77
|
+
element.addEventListener("touchstart", onActivity);
|
|
78
|
+
return () => {
|
|
79
|
+
if (timeout !== null) {
|
|
80
|
+
clearTimeout(timeout);
|
|
81
|
+
timeout = null;
|
|
82
|
+
}
|
|
83
|
+
element.removeEventListener("keydown", onActivity);
|
|
84
|
+
element.removeEventListener("mousedown", onActivity);
|
|
85
|
+
element.removeEventListener("mousemove", onActivity);
|
|
86
|
+
element.removeEventListener("mouseup", onActivity);
|
|
87
|
+
element.removeEventListener("pointerdown", onActivity);
|
|
88
|
+
element.removeEventListener("pointermove", onActivity);
|
|
89
|
+
element.removeEventListener("pointerup", onActivity);
|
|
90
|
+
element.removeEventListener("touchmove", onActivity);
|
|
91
|
+
element.removeEventListener("touchstart", onActivity);
|
|
92
|
+
};
|
|
88
93
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
t5 = [disabled, timeoutDelay];
|
|
95
|
+
$[2] = disabled;
|
|
96
|
+
$[3] = timeoutDelay;
|
|
97
|
+
$[4] = t4;
|
|
98
|
+
$[5] = t5;
|
|
99
|
+
} else {
|
|
100
|
+
t4 = $[4];
|
|
101
|
+
t5 = $[5];
|
|
102
|
+
}
|
|
103
|
+
useEffect(t4, t5);
|
|
104
|
+
let t6;
|
|
105
|
+
if ($[6] !== detected) {
|
|
106
|
+
t6 = {
|
|
107
|
+
ref,
|
|
108
|
+
detected
|
|
109
|
+
};
|
|
110
|
+
$[6] = detected;
|
|
111
|
+
$[7] = t6;
|
|
112
|
+
} else {
|
|
113
|
+
t6 = $[7];
|
|
114
|
+
}
|
|
115
|
+
return t6;
|
|
94
116
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
function _temp$a() {}
|
|
118
|
+
|
|
119
|
+
const useAnimationFrame = (onFrame, t0) => {
|
|
120
|
+
const $ = c(9);
|
|
121
|
+
let t1;
|
|
122
|
+
if ($[0] !== t0) {
|
|
123
|
+
t1 = t0 === undefined ? {} : t0;
|
|
124
|
+
$[0] = t0;
|
|
125
|
+
$[1] = t1;
|
|
126
|
+
} else {
|
|
127
|
+
t1 = $[1];
|
|
128
|
+
}
|
|
129
|
+
const {
|
|
130
|
+
disabled: t2
|
|
131
|
+
} = t1;
|
|
132
|
+
const disabled = t2 === undefined ? false : t2;
|
|
133
|
+
const requestRef = useRef(null);
|
|
134
|
+
const startTimeRef = useRef(null);
|
|
135
|
+
let callback;
|
|
136
|
+
if ($[2] !== onFrame) {
|
|
137
|
+
callback = time => {
|
|
138
|
+
if (!startTimeRef.current) {
|
|
139
|
+
startTimeRef.current = time;
|
|
140
|
+
}
|
|
141
|
+
const progress = time - startTimeRef.current;
|
|
142
|
+
onFrame(progress);
|
|
143
|
+
requestRef.current = requestAnimationFrame(callback);
|
|
144
|
+
};
|
|
145
|
+
$[2] = onFrame;
|
|
146
|
+
$[3] = callback;
|
|
147
|
+
} else {
|
|
148
|
+
callback = $[3];
|
|
149
|
+
}
|
|
150
|
+
let t3;
|
|
151
|
+
if ($[4] !== callback || $[5] !== disabled) {
|
|
152
|
+
t3 = () => {
|
|
153
|
+
if (!disabled) {
|
|
154
|
+
requestRef.current = requestAnimationFrame(callback);
|
|
117
155
|
}
|
|
156
|
+
return () => {
|
|
157
|
+
if (requestRef.current !== null) {
|
|
158
|
+
cancelAnimationFrame(requestRef.current);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
118
161
|
};
|
|
119
|
-
|
|
162
|
+
$[4] = callback;
|
|
163
|
+
$[5] = disabled;
|
|
164
|
+
$[6] = t3;
|
|
165
|
+
} else {
|
|
166
|
+
t3 = $[6];
|
|
167
|
+
}
|
|
168
|
+
let t4;
|
|
169
|
+
if ($[7] !== disabled) {
|
|
170
|
+
t4 = [disabled];
|
|
171
|
+
$[7] = disabled;
|
|
172
|
+
$[8] = t4;
|
|
173
|
+
} else {
|
|
174
|
+
t4 = $[8];
|
|
175
|
+
}
|
|
176
|
+
useEffect(t3, t4);
|
|
120
177
|
};
|
|
121
178
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return useCallback(function (date) {
|
|
132
|
-
var dateToFormat = isString(date) ? dayjs(date) : date;
|
|
179
|
+
const useFormattedDate = (options = null) => {
|
|
180
|
+
const {
|
|
181
|
+
format = null,
|
|
182
|
+
showToday = true
|
|
183
|
+
} = options || {};
|
|
184
|
+
const intl = useIntl();
|
|
185
|
+
const today = dayjs();
|
|
186
|
+
return useCallback(date => {
|
|
187
|
+
const dateToFormat = isString(date) ? dayjs(date) : date;
|
|
133
188
|
if (showToday && dateToFormat.format('YYYY-MM-DD') === today.format('YYYY-MM-DD')) {
|
|
134
189
|
return intl.formatMessage({
|
|
135
190
|
id: "v4Qtl9",
|
|
136
|
-
defaultMessage:
|
|
137
|
-
"type": 0,
|
|
138
|
-
"value": "Today"
|
|
139
|
-
}]
|
|
191
|
+
defaultMessage: "Today"
|
|
140
192
|
});
|
|
141
193
|
}
|
|
142
|
-
return intl.formatDate(dayjs(date).toDate(),
|
|
194
|
+
return intl.formatDate(dayjs(date).toDate(), {
|
|
143
195
|
year: 'numeric',
|
|
144
196
|
month: 'long',
|
|
145
|
-
day: '2-digit'
|
|
146
|
-
|
|
197
|
+
day: '2-digit',
|
|
198
|
+
...format
|
|
199
|
+
});
|
|
147
200
|
}, [today, showToday, format]);
|
|
148
201
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
var now = dayjs();
|
|
160
|
-
return useCallback(function (date) {
|
|
161
|
-
var dateToFormat = isString(date) ? dayjs(date) : date;
|
|
202
|
+
const useFormattedTime = (options = null) => {
|
|
203
|
+
const {
|
|
204
|
+
format = null,
|
|
205
|
+
showNow = true,
|
|
206
|
+
timeGap = 2
|
|
207
|
+
} = options || {};
|
|
208
|
+
const intl = useIntl();
|
|
209
|
+
const now = dayjs();
|
|
210
|
+
return useCallback(date => {
|
|
211
|
+
const dateToFormat = isString(date) ? dayjs(date) : date;
|
|
162
212
|
if (showNow && dateToFormat.format('YYYY-MM-DD') === now.format('YYYY-MM-DD') && dateToFormat.hour() === now.hour() && dateToFormat.minute() > now.minute() - timeGap && dateToFormat.minute() < now.minute() + timeGap) {
|
|
163
213
|
return intl.formatMessage({
|
|
164
214
|
id: "3na7F8",
|
|
165
|
-
defaultMessage:
|
|
166
|
-
"type": 0,
|
|
167
|
-
"value": "Now"
|
|
168
|
-
}]
|
|
215
|
+
defaultMessage: "Now"
|
|
169
216
|
});
|
|
170
217
|
}
|
|
171
|
-
return intl.formatTime(dateToFormat.toDate(),
|
|
218
|
+
return intl.formatTime(dateToFormat.toDate(), {
|
|
172
219
|
hour: 'numeric',
|
|
173
|
-
minute: 'numeric'
|
|
174
|
-
|
|
220
|
+
minute: 'numeric',
|
|
221
|
+
...format
|
|
222
|
+
});
|
|
175
223
|
}, [now, showNow, timeGap, format]);
|
|
176
224
|
};
|
|
177
225
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
226
|
+
const useDebounced = (handler, watchedValue, t0) => {
|
|
227
|
+
const $ = c(7);
|
|
228
|
+
const delay = t0 === undefined ? 300 : t0;
|
|
229
|
+
let t1;
|
|
230
|
+
if ($[0] !== delay || $[1] !== handler || $[2] !== watchedValue) {
|
|
231
|
+
t1 = () => {
|
|
232
|
+
const timeoutHandler = setTimeout(() => {
|
|
233
|
+
if (handler !== null) {
|
|
234
|
+
handler(watchedValue);
|
|
235
|
+
}
|
|
236
|
+
}, delay);
|
|
237
|
+
return () => {
|
|
238
|
+
clearTimeout(timeoutHandler);
|
|
239
|
+
};
|
|
188
240
|
};
|
|
189
|
-
|
|
241
|
+
$[0] = delay;
|
|
242
|
+
$[1] = handler;
|
|
243
|
+
$[2] = watchedValue;
|
|
244
|
+
$[3] = t1;
|
|
245
|
+
} else {
|
|
246
|
+
t1 = $[3];
|
|
247
|
+
}
|
|
248
|
+
let t2;
|
|
249
|
+
if ($[4] !== delay || $[5] !== watchedValue) {
|
|
250
|
+
t2 = [watchedValue, delay];
|
|
251
|
+
$[4] = delay;
|
|
252
|
+
$[5] = watchedValue;
|
|
253
|
+
$[6] = t2;
|
|
254
|
+
} else {
|
|
255
|
+
t2 = $[6];
|
|
256
|
+
}
|
|
257
|
+
useEffect(t1, t2);
|
|
190
258
|
};
|
|
191
259
|
|
|
192
|
-
|
|
193
|
-
|
|
260
|
+
const eventsManager$1 = typeof document !== 'undefined' ? new EventsManager(document) : null;
|
|
261
|
+
const useDocumentEvent = createUseEvent(eventsManager$1);
|
|
194
262
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
onProgress
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
263
|
+
const defaultDragOptions = {
|
|
264
|
+
filterTaps: true
|
|
265
|
+
};
|
|
266
|
+
function useDragProgress(t0) {
|
|
267
|
+
const $ = c(41);
|
|
268
|
+
const {
|
|
269
|
+
progress: wantedProgress,
|
|
270
|
+
onTap: t1,
|
|
271
|
+
disabled: t2,
|
|
272
|
+
dragDisabled: t3,
|
|
273
|
+
computeProgress: t4,
|
|
274
|
+
onProgress: t5,
|
|
275
|
+
onPointerDown: t6,
|
|
276
|
+
onResolve: t7,
|
|
277
|
+
onScroll: t8,
|
|
278
|
+
springParams: t9,
|
|
279
|
+
dragOptions: t10
|
|
280
|
+
} = t0;
|
|
281
|
+
const onTap = t1 === undefined ? null : t1;
|
|
282
|
+
const disabled = t2 === undefined ? false : t2;
|
|
283
|
+
const dragDisabled = t3 === undefined ? false : t3;
|
|
284
|
+
const computeProgress = t4 === undefined ? null : t4;
|
|
285
|
+
const onProgress = t5 === undefined ? null : t5;
|
|
286
|
+
const onPointerDown = t6 === undefined ? null : t6;
|
|
287
|
+
const onResolve = t7 === undefined ? null : t7;
|
|
288
|
+
const onScroll = t8 === undefined ? null : t8;
|
|
289
|
+
const springParams = t9 === undefined ? undefined : t9;
|
|
290
|
+
const dragOptions = t10 === undefined ? defaultDragOptions : t10;
|
|
291
|
+
const draggingRef = useRef(false);
|
|
292
|
+
const progressRef = useRef(wantedProgress);
|
|
293
|
+
const [dragging, setDragging] = useState(false);
|
|
294
|
+
const [direction, setDirection] = useState(0);
|
|
295
|
+
const [transitioned, setTransitioned] = useState(true);
|
|
296
|
+
let t11;
|
|
297
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
298
|
+
t11 = () => {
|
|
299
|
+
setTransitioned(false);
|
|
300
|
+
};
|
|
301
|
+
$[0] = t11;
|
|
302
|
+
} else {
|
|
303
|
+
t11 = $[0];
|
|
304
|
+
}
|
|
305
|
+
const onTransitionStart = t11;
|
|
306
|
+
let t12;
|
|
307
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
308
|
+
t12 = () => {
|
|
309
|
+
setTransitioned(true);
|
|
310
|
+
};
|
|
311
|
+
$[1] = t12;
|
|
312
|
+
} else {
|
|
313
|
+
t12 = $[1];
|
|
314
|
+
}
|
|
315
|
+
const onTransitionComplete = t12;
|
|
316
|
+
const imperativeRef = useSpringRef();
|
|
317
|
+
let t13;
|
|
318
|
+
if ($[2] !== imperativeRef || $[3] !== springParams || $[4] !== wantedProgress) {
|
|
319
|
+
t13 = () => ({
|
|
320
|
+
ref: imperativeRef,
|
|
321
|
+
from: {
|
|
322
|
+
progress: wantedProgress
|
|
323
|
+
},
|
|
324
|
+
onStart: onTransitionStart,
|
|
325
|
+
onRest: onTransitionComplete,
|
|
326
|
+
...springParams
|
|
327
|
+
});
|
|
328
|
+
$[2] = imperativeRef;
|
|
329
|
+
$[3] = springParams;
|
|
330
|
+
$[4] = wantedProgress;
|
|
331
|
+
$[5] = t13;
|
|
332
|
+
} else {
|
|
333
|
+
t13 = $[5];
|
|
334
|
+
}
|
|
335
|
+
const [t14, api] = useSpring(t13);
|
|
336
|
+
const {
|
|
337
|
+
progress
|
|
338
|
+
} = t14;
|
|
339
|
+
let t15;
|
|
340
|
+
if ($[6] !== api || $[7] !== computeProgress || $[8] !== disabled || $[9] !== dragDisabled || $[10] !== dragging || $[11] !== onProgress || $[12] !== onResolve || $[13] !== onTap || $[14] !== springParams || $[15] !== wantedProgress) {
|
|
341
|
+
t15 = gestureState => {
|
|
342
|
+
const {
|
|
343
|
+
active,
|
|
344
|
+
tap,
|
|
345
|
+
first
|
|
346
|
+
} = gestureState;
|
|
347
|
+
console.log("DRAG");
|
|
348
|
+
if (disabled) {
|
|
349
|
+
draggingRef.current = false;
|
|
350
|
+
return;
|
|
282
351
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}, [setDragging, disabled, onTap, computeProgress, dragging, onProgress, _onResolve]);
|
|
288
|
-
var bind = useGesture({
|
|
289
|
-
onDrag: onDrag,
|
|
290
|
-
onPointerDown: onPointerDown !== null ? onPointerDown : function () {},
|
|
291
|
-
onScroll: onScroll !== null ? onScroll : function () {}
|
|
292
|
-
}, {
|
|
293
|
-
drag: dragOptions
|
|
294
|
-
});
|
|
295
|
-
useEffect(function () {
|
|
296
|
-
if (!draggingRef.current && wantedProgress !== progressRef.current) {
|
|
297
|
-
setDirection(wantedProgress < progressRef.current ? -1 : 1);
|
|
298
|
-
progressRef.current = wantedProgress;
|
|
299
|
-
api.start(_objectSpread({
|
|
300
|
-
progress: wantedProgress,
|
|
301
|
-
immediate: disabled,
|
|
302
|
-
onResolve: function onResolve(e) {
|
|
303
|
-
setDirection(0);
|
|
304
|
-
if (_onResolve !== null) _onResolve(e);
|
|
352
|
+
if (tap) {
|
|
353
|
+
draggingRef.current = false;
|
|
354
|
+
if (onTap !== null) {
|
|
355
|
+
onTap(gestureState);
|
|
305
356
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (dragDisabled) {
|
|
360
|
+
draggingRef.current = false;
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const newProgress = computeProgress(gestureState);
|
|
364
|
+
draggingRef.current = active;
|
|
365
|
+
setDirection(newProgress < wantedProgress ? -1 : 1);
|
|
366
|
+
progressRef.current = newProgress;
|
|
367
|
+
if (active !== dragging) {
|
|
368
|
+
setDragging(active);
|
|
369
|
+
}
|
|
370
|
+
api.start({
|
|
371
|
+
progress: newProgress,
|
|
372
|
+
immediate: active,
|
|
373
|
+
onResolve: e => {
|
|
374
|
+
if (!active) {
|
|
375
|
+
setDirection(0);
|
|
376
|
+
}
|
|
377
|
+
if (onResolve !== null) {
|
|
378
|
+
onResolve(e);
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
onStart: first ? onTransitionStart : undefined,
|
|
382
|
+
onRest: !active ? onTransitionComplete : undefined,
|
|
383
|
+
...springParams
|
|
384
|
+
});
|
|
385
|
+
if (onProgress !== null) {
|
|
386
|
+
onProgress(newProgress, gestureState);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
$[6] = api;
|
|
390
|
+
$[7] = computeProgress;
|
|
391
|
+
$[8] = disabled;
|
|
392
|
+
$[9] = dragDisabled;
|
|
393
|
+
$[10] = dragging;
|
|
394
|
+
$[11] = onProgress;
|
|
395
|
+
$[12] = onResolve;
|
|
396
|
+
$[13] = onTap;
|
|
397
|
+
$[14] = springParams;
|
|
398
|
+
$[15] = wantedProgress;
|
|
399
|
+
$[16] = t15;
|
|
400
|
+
} else {
|
|
401
|
+
t15 = $[16];
|
|
402
|
+
}
|
|
403
|
+
const onDrag = t15;
|
|
404
|
+
const t16 = onPointerDown !== null ? onPointerDown : undefined;
|
|
405
|
+
const t17 = onScroll !== null ? onScroll : undefined;
|
|
406
|
+
let t18;
|
|
407
|
+
if ($[17] !== onDrag || $[18] !== t16 || $[19] !== t17) {
|
|
408
|
+
t18 = {
|
|
409
|
+
onDrag,
|
|
410
|
+
onPointerDown: t16,
|
|
411
|
+
onScroll: t17
|
|
412
|
+
};
|
|
413
|
+
$[17] = onDrag;
|
|
414
|
+
$[18] = t16;
|
|
415
|
+
$[19] = t17;
|
|
416
|
+
$[20] = t18;
|
|
417
|
+
} else {
|
|
418
|
+
t18 = $[20];
|
|
419
|
+
}
|
|
420
|
+
let t19;
|
|
421
|
+
if ($[21] !== dragOptions) {
|
|
422
|
+
t19 = {
|
|
423
|
+
drag: dragOptions
|
|
424
|
+
};
|
|
425
|
+
$[21] = dragOptions;
|
|
426
|
+
$[22] = t19;
|
|
427
|
+
} else {
|
|
428
|
+
t19 = $[22];
|
|
429
|
+
}
|
|
430
|
+
const bind = useGesture(t18, t19);
|
|
431
|
+
const [lastWantedProgress, setLastWantedProgress] = useState(wantedProgress);
|
|
432
|
+
let t20;
|
|
433
|
+
let t21;
|
|
434
|
+
if ($[23] !== api || $[24] !== disabled || $[25] !== onResolve || $[26] !== springParams || $[27] !== wantedProgress) {
|
|
435
|
+
t20 = () => {
|
|
436
|
+
if (!draggingRef.current && wantedProgress !== progressRef.current) {
|
|
437
|
+
setDirection(wantedProgress < progressRef.current ? -1 : 1);
|
|
438
|
+
setLastWantedProgress(wantedProgress);
|
|
439
|
+
progressRef.current = wantedProgress;
|
|
440
|
+
api.start({
|
|
441
|
+
progress: wantedProgress,
|
|
442
|
+
immediate: disabled,
|
|
443
|
+
onResolve: e_0 => {
|
|
444
|
+
setDirection(0);
|
|
445
|
+
if (onResolve !== null) {
|
|
446
|
+
onResolve(e_0);
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
onStart: onTransitionStart,
|
|
450
|
+
onRest: onTransitionComplete,
|
|
451
|
+
...springParams
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
t21 = [api, wantedProgress, disabled, onResolve, springParams, onTransitionStart, onTransitionComplete];
|
|
456
|
+
$[23] = api;
|
|
457
|
+
$[24] = disabled;
|
|
458
|
+
$[25] = onResolve;
|
|
459
|
+
$[26] = springParams;
|
|
460
|
+
$[27] = wantedProgress;
|
|
461
|
+
$[28] = t20;
|
|
462
|
+
$[29] = t21;
|
|
463
|
+
} else {
|
|
464
|
+
t20 = $[28];
|
|
465
|
+
t21 = $[29];
|
|
466
|
+
}
|
|
467
|
+
useEffect(t20, t21);
|
|
468
|
+
let t22;
|
|
469
|
+
if ($[30] !== dragging || $[31] !== progress || $[32] !== transitioned || $[33] !== wantedProgress) {
|
|
470
|
+
t22 = wantedProgress !== progress.get() || progress.isAnimating || dragging || !transitioned;
|
|
471
|
+
$[30] = dragging;
|
|
472
|
+
$[31] = progress;
|
|
473
|
+
$[32] = transitioned;
|
|
474
|
+
$[33] = wantedProgress;
|
|
475
|
+
$[34] = t22;
|
|
476
|
+
} else {
|
|
477
|
+
t22 = $[34];
|
|
478
|
+
}
|
|
479
|
+
const transitioning = t22;
|
|
480
|
+
const t23 = wantedProgress !== lastWantedProgress ? wantedProgress < lastWantedProgress ? -1 : 1 : direction;
|
|
481
|
+
let t24;
|
|
482
|
+
if ($[35] !== bind || $[36] !== dragging || $[37] !== progress || $[38] !== t23 || $[39] !== transitioning) {
|
|
483
|
+
t24 = {
|
|
484
|
+
transitioning,
|
|
485
|
+
bind,
|
|
486
|
+
dragging,
|
|
487
|
+
progress,
|
|
488
|
+
direction: t23
|
|
489
|
+
};
|
|
490
|
+
$[35] = bind;
|
|
491
|
+
$[36] = dragging;
|
|
492
|
+
$[37] = progress;
|
|
493
|
+
$[38] = t23;
|
|
494
|
+
$[39] = transitioning;
|
|
495
|
+
$[40] = t24;
|
|
496
|
+
} else {
|
|
497
|
+
t24 = $[40];
|
|
498
|
+
}
|
|
499
|
+
return t24;
|
|
319
500
|
}
|
|
320
501
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
502
|
+
function useForm(t0) {
|
|
503
|
+
const $ = c(23);
|
|
504
|
+
let t1;
|
|
505
|
+
if ($[0] !== t0) {
|
|
506
|
+
t1 = t0 === undefined ? {} : t0;
|
|
507
|
+
$[0] = t0;
|
|
508
|
+
$[1] = t1;
|
|
509
|
+
} else {
|
|
510
|
+
t1 = $[1];
|
|
511
|
+
}
|
|
512
|
+
let opts;
|
|
513
|
+
let t2;
|
|
514
|
+
let t3;
|
|
515
|
+
if ($[2] !== t1) {
|
|
516
|
+
({
|
|
517
|
+
fields: t2,
|
|
518
|
+
injectInFields: t3,
|
|
519
|
+
...opts
|
|
520
|
+
} = t1);
|
|
521
|
+
$[2] = t1;
|
|
522
|
+
$[3] = opts;
|
|
523
|
+
$[4] = t2;
|
|
524
|
+
$[5] = t3;
|
|
525
|
+
} else {
|
|
526
|
+
opts = $[3];
|
|
527
|
+
t2 = $[4];
|
|
528
|
+
t3 = $[5];
|
|
529
|
+
}
|
|
530
|
+
let t4;
|
|
531
|
+
if ($[6] !== t2) {
|
|
532
|
+
t4 = t2 === undefined ? [] : t2;
|
|
533
|
+
$[6] = t2;
|
|
534
|
+
$[7] = t4;
|
|
535
|
+
} else {
|
|
536
|
+
t4 = $[7];
|
|
537
|
+
}
|
|
538
|
+
const providedFields = t4;
|
|
539
|
+
const injectInFields = t3 === undefined ? false : t3;
|
|
540
|
+
let t5;
|
|
541
|
+
if ($[8] !== providedFields) {
|
|
542
|
+
t5 = providedFields.length > 0 ? providedFields.map(_temp$9) : [];
|
|
543
|
+
$[8] = providedFields;
|
|
544
|
+
$[9] = t5;
|
|
545
|
+
} else {
|
|
546
|
+
t5 = $[9];
|
|
547
|
+
}
|
|
548
|
+
const fieldsNames = t5;
|
|
549
|
+
let t6;
|
|
550
|
+
if ($[10] !== fieldsNames || $[11] !== opts) {
|
|
551
|
+
t6 = {
|
|
552
|
+
fields: fieldsNames,
|
|
553
|
+
...opts
|
|
554
|
+
};
|
|
555
|
+
$[10] = fieldsNames;
|
|
556
|
+
$[11] = opts;
|
|
557
|
+
$[12] = t6;
|
|
558
|
+
} else {
|
|
559
|
+
t6 = $[12];
|
|
560
|
+
}
|
|
561
|
+
const t7 = useForm$1(t6);
|
|
562
|
+
let fields;
|
|
563
|
+
let form;
|
|
564
|
+
if ($[13] !== t7) {
|
|
565
|
+
({
|
|
566
|
+
fields,
|
|
567
|
+
...form
|
|
568
|
+
} = t7);
|
|
569
|
+
$[13] = t7;
|
|
570
|
+
$[14] = fields;
|
|
571
|
+
$[15] = form;
|
|
572
|
+
} else {
|
|
573
|
+
fields = $[14];
|
|
574
|
+
form = $[15];
|
|
575
|
+
}
|
|
576
|
+
let t8;
|
|
577
|
+
if ($[16] !== fields || $[17] !== injectInFields || $[18] !== providedFields) {
|
|
578
|
+
t8 = injectInFields ? providedFields.map(it => ({
|
|
579
|
+
...it,
|
|
580
|
+
...(fields[it.name] || null)
|
|
581
|
+
})) : providedFields;
|
|
582
|
+
$[16] = fields;
|
|
583
|
+
$[17] = injectInFields;
|
|
584
|
+
$[18] = providedFields;
|
|
585
|
+
$[19] = t8;
|
|
586
|
+
} else {
|
|
587
|
+
t8 = $[19];
|
|
588
|
+
}
|
|
589
|
+
let t9;
|
|
590
|
+
if ($[20] !== form || $[21] !== t8) {
|
|
591
|
+
t9 = {
|
|
592
|
+
...form,
|
|
593
|
+
fields: t8
|
|
594
|
+
};
|
|
595
|
+
$[20] = form;
|
|
596
|
+
$[21] = t8;
|
|
597
|
+
$[22] = t9;
|
|
598
|
+
} else {
|
|
599
|
+
t9 = $[22];
|
|
600
|
+
}
|
|
601
|
+
return t9;
|
|
602
|
+
}
|
|
603
|
+
function _temp$9(t0) {
|
|
604
|
+
const {
|
|
605
|
+
name
|
|
606
|
+
} = t0;
|
|
607
|
+
return name;
|
|
608
|
+
}
|
|
349
609
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
var direction = useMemo(function () {
|
|
357
|
-
var currentPartsCount = paths.length;
|
|
610
|
+
const useFormTransition = (initialPaths = null, initialStyles = {}) => {
|
|
611
|
+
const paths = initialPaths || [];
|
|
612
|
+
const styles = initialStyles || {};
|
|
613
|
+
const lastPageRef = useRef(paths || []);
|
|
614
|
+
const direction = useMemo(() => {
|
|
615
|
+
const currentPartsCount = paths.length;
|
|
358
616
|
if (lastPageRef.current) {
|
|
359
|
-
|
|
617
|
+
const previousPartsCount = lastPageRef.current.length;
|
|
360
618
|
lastPageRef.current = paths || [];
|
|
361
619
|
return currentPartsCount > previousPartsCount ? 'right' : 'left';
|
|
362
620
|
}
|
|
363
621
|
return null;
|
|
364
622
|
}, [paths]);
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}
|
|
372
|
-
|
|
623
|
+
const name = useMemo(() => ({
|
|
624
|
+
enter: classNames({
|
|
625
|
+
[styles.enterRight]: direction === 'right',
|
|
626
|
+
[styles.enterLeft]: direction === 'left',
|
|
627
|
+
[styles.enterTop]: direction === 'top',
|
|
628
|
+
[styles.enterBottom]: direction === 'bottom'
|
|
629
|
+
}) || 'none',
|
|
630
|
+
enterActive: classNames({
|
|
631
|
+
[styles.enterActiveHorizontal]: direction === 'left' || direction === 'right',
|
|
632
|
+
[styles.enterActiveVertical]: direction === 'top' || direction === 'bottom'
|
|
633
|
+
}) || 'none',
|
|
634
|
+
leave: styles.leave || 'none',
|
|
635
|
+
leaveActive: classNames({
|
|
636
|
+
[styles.leaveActiveRight]: direction === 'right',
|
|
637
|
+
[styles.leaveActiveLeft]: direction === 'left',
|
|
638
|
+
[styles.leaveActiveTop]: direction === 'top',
|
|
639
|
+
[styles.leaveActiveBottom]: direction === 'bottom'
|
|
640
|
+
}) || 'none'
|
|
641
|
+
}), [direction]);
|
|
373
642
|
return {
|
|
374
|
-
direction
|
|
375
|
-
name
|
|
643
|
+
direction,
|
|
644
|
+
name,
|
|
376
645
|
timeout: direction === 'left' || direction === 'right' ? 300 : 10
|
|
377
646
|
};
|
|
378
647
|
};
|
|
379
648
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
649
|
+
const useFullscreen = () => {
|
|
650
|
+
const $ = c(9);
|
|
651
|
+
const ref = useRef(null);
|
|
652
|
+
const [enabled, setEnabled] = useState(_temp$8);
|
|
653
|
+
const [active, setActive] = useState(false);
|
|
654
|
+
let t0;
|
|
655
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
656
|
+
t0 = () => {
|
|
657
|
+
const {
|
|
658
|
+
current: t1
|
|
659
|
+
} = ref;
|
|
660
|
+
const element = t1 === undefined ? null : t1;
|
|
661
|
+
if (screenfull.isEnabled) {
|
|
662
|
+
if (element !== null) {
|
|
663
|
+
screenfull.request(element);
|
|
664
|
+
} else {
|
|
665
|
+
screenfull.request();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
$[0] = t0;
|
|
670
|
+
} else {
|
|
671
|
+
t0 = $[0];
|
|
672
|
+
}
|
|
673
|
+
const fullscreen = t0;
|
|
674
|
+
const unFullscreen = _temp2$2;
|
|
675
|
+
let t1;
|
|
676
|
+
if ($[1] !== active) {
|
|
677
|
+
t1 = () => {
|
|
678
|
+
if (!active) {
|
|
679
|
+
fullscreen();
|
|
390
680
|
} else {
|
|
391
|
-
|
|
681
|
+
unFullscreen();
|
|
392
682
|
}
|
|
393
|
-
}
|
|
394
|
-
}, [element]);
|
|
395
|
-
var unFullscreen = useCallback(function () {
|
|
396
|
-
if (screenfull.isEnabled) {
|
|
397
|
-
screenfull.exit();
|
|
398
|
-
}
|
|
399
|
-
}, []);
|
|
400
|
-
var toggle = useCallback(function () {
|
|
401
|
-
if (!active) {
|
|
402
|
-
fullscreen();
|
|
403
|
-
} else {
|
|
404
|
-
unFullscreen();
|
|
405
|
-
}
|
|
406
|
-
}, [active, fullscreen, unFullscreen]);
|
|
407
|
-
useEffect(function () {
|
|
408
|
-
var onChange = function onChange() {
|
|
409
|
-
setActive(screenfull.isFullscreen);
|
|
410
683
|
};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
684
|
+
$[1] = active;
|
|
685
|
+
$[2] = t1;
|
|
686
|
+
} else {
|
|
687
|
+
t1 = $[2];
|
|
688
|
+
}
|
|
689
|
+
const toggle = t1;
|
|
690
|
+
let t2;
|
|
691
|
+
let t3;
|
|
692
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
693
|
+
t2 = () => {
|
|
694
|
+
setEnabled(screenfull.isEnabled);
|
|
695
|
+
const onChange = () => {
|
|
696
|
+
setActive(screenfull.isFullscreen);
|
|
697
|
+
};
|
|
415
698
|
if (screenfull.isEnabled) {
|
|
416
|
-
screenfull.
|
|
699
|
+
screenfull.on("change", onChange);
|
|
417
700
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
toggle: toggle,
|
|
422
|
-
fullscreen: fullscreen,
|
|
423
|
-
unFullscreen: unFullscreen,
|
|
424
|
-
active: active,
|
|
425
|
-
enabled: enabled
|
|
426
|
-
};
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
var _excluded$2 = ["entry"];
|
|
430
|
-
var buildThresholdArray = function buildThresholdArray() {
|
|
431
|
-
return [0, 1.0];
|
|
432
|
-
};
|
|
433
|
-
var observersCache = new Map();
|
|
434
|
-
var getOptionsKey = function getOptionsKey(_ref) {
|
|
435
|
-
var _ref$root = _ref.root,
|
|
436
|
-
root = _ref$root === void 0 ? null : _ref$root,
|
|
437
|
-
rootMargin = _ref.rootMargin,
|
|
438
|
-
_ref$threshold = _ref.threshold,
|
|
439
|
-
threshold = _ref$threshold === void 0 ? null : _ref$threshold;
|
|
440
|
-
return "root_".concat(root, "_rootMargin_").concat(rootMargin || null, "_threshold_").concat(threshold);
|
|
441
|
-
};
|
|
442
|
-
var createObserver = function createObserver(Observer) {
|
|
443
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
444
|
-
var subscribers = [];
|
|
445
|
-
var addSubscriber = function addSubscriber(element, callback) {
|
|
446
|
-
var currentSubscriber = subscribers.find(function (it) {
|
|
447
|
-
return it.element === element;
|
|
448
|
-
}) || null;
|
|
449
|
-
if (currentSubscriber !== null) {
|
|
450
|
-
return subscribers.map(function (it) {
|
|
451
|
-
return it.element === element && it.callbacks.indexOf(callback) === -1 ? _objectSpread(_objectSpread({}, it), {}, {
|
|
452
|
-
callbacks: [].concat(_toConsumableArray(it.callbacks), [callback])
|
|
453
|
-
}) : it;
|
|
454
|
-
}).filter(function (it) {
|
|
455
|
-
return it.callbacks.length > 0;
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
return [].concat(_toConsumableArray(subscribers), [{
|
|
459
|
-
element: element,
|
|
460
|
-
callbacks: [callback]
|
|
461
|
-
}]);
|
|
462
|
-
};
|
|
463
|
-
var removeSubscriber = function removeSubscriber(element, callback) {
|
|
464
|
-
return subscribers.map(function (it) {
|
|
465
|
-
return it.element === element ? _objectSpread(_objectSpread({}, it), {}, {
|
|
466
|
-
callbacks: it.callbacks.filter(function (subCallback) {
|
|
467
|
-
return subCallback !== callback;
|
|
468
|
-
})
|
|
469
|
-
}) : it;
|
|
470
|
-
}).filter(function (it) {
|
|
471
|
-
return it.callbacks.length > 0;
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
var onUpdate = function onUpdate(entries) {
|
|
475
|
-
entries.forEach(function (entry) {
|
|
476
|
-
subscribers.forEach(function (_ref2) {
|
|
477
|
-
var element = _ref2.element,
|
|
478
|
-
callbacks = _ref2.callbacks;
|
|
479
|
-
if (element === entry.target) {
|
|
480
|
-
callbacks.forEach(function (callback) {
|
|
481
|
-
callback(entry);
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
};
|
|
487
|
-
var observer = new Observer(onUpdate, options);
|
|
488
|
-
var unsubscribe = function unsubscribe(element) {
|
|
489
|
-
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
490
|
-
subscribers = removeSubscriber(element, callback);
|
|
491
|
-
if (typeof observer.unobserve === 'undefined') {
|
|
492
|
-
observer.disconnect();
|
|
493
|
-
subscribers.forEach(function (subscriber) {
|
|
494
|
-
observer.observe(subscriber.element);
|
|
495
|
-
});
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
var currentSubscriber = subscribers.find(function (it) {
|
|
499
|
-
return it.element === element;
|
|
500
|
-
}) || null;
|
|
501
|
-
if (currentSubscriber === null) {
|
|
502
|
-
observer.unobserve(element);
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
var subscribe = function subscribe(element, callback) {
|
|
506
|
-
var currentSubscriber = subscribers.find(function (it) {
|
|
507
|
-
return it.element === element;
|
|
508
|
-
}) || null;
|
|
509
|
-
subscribers = addSubscriber(element, callback);
|
|
510
|
-
if (currentSubscriber === null) {
|
|
511
|
-
observer.observe(element);
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
return {
|
|
515
|
-
subscribe: subscribe,
|
|
516
|
-
unsubscribe: unsubscribe,
|
|
517
|
-
observer: observer
|
|
518
|
-
};
|
|
519
|
-
};
|
|
520
|
-
var getObserver = function getObserver(Observer) {
|
|
521
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
522
|
-
var observerKey = getOptionsKey(options);
|
|
523
|
-
if (!observersCache.has(Observer)) {
|
|
524
|
-
observersCache.set(Observer, {});
|
|
525
|
-
}
|
|
526
|
-
var observers = observersCache.get(Observer);
|
|
527
|
-
if (typeof observers[observerKey] === 'undefined') {
|
|
528
|
-
observers[observerKey] = createObserver(Observer, options);
|
|
529
|
-
observersCache.set(Observer, observers);
|
|
530
|
-
}
|
|
531
|
-
return observers[observerKey];
|
|
532
|
-
};
|
|
533
|
-
var useObserver = function useObserver(Observer) {
|
|
534
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
535
|
-
var initialEntry = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
536
|
-
var _ref3 = opts || {},
|
|
537
|
-
_ref3$root = _ref3.root,
|
|
538
|
-
root = _ref3$root === void 0 ? null : _ref3$root,
|
|
539
|
-
_ref3$rootMargin = _ref3.rootMargin,
|
|
540
|
-
rootMargin = _ref3$rootMargin === void 0 ? null : _ref3$rootMargin,
|
|
541
|
-
_ref3$threshold = _ref3.threshold,
|
|
542
|
-
threshold = _ref3$threshold === void 0 ? null : _ref3$threshold,
|
|
543
|
-
_ref3$disabled = _ref3.disabled,
|
|
544
|
-
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled;
|
|
545
|
-
var _useState = useState(initialEntry),
|
|
546
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
547
|
-
entry = _useState2[0],
|
|
548
|
-
setEntry = _useState2[1];
|
|
549
|
-
var nodeRef = useRef(null);
|
|
550
|
-
var currentElement = useRef(null);
|
|
551
|
-
var elementChanged = nodeRef.current !== currentElement.current;
|
|
552
|
-
useEffect(function () {
|
|
553
|
-
var nodeElement = nodeRef.current;
|
|
554
|
-
var callback = function callback(newEntry) {
|
|
555
|
-
return setEntry(function (prev) {
|
|
556
|
-
// Avoid re-renders when ResizeObserver fires with unchanged dimensions
|
|
557
|
-
if (prev !== null && prev !== void 0 && prev.contentRect && newEntry !== null && newEntry !== void 0 && newEntry.contentRect) {
|
|
558
|
-
var p = prev.contentRect;
|
|
559
|
-
var n = newEntry.contentRect;
|
|
560
|
-
if (p.width === n.width && p.height === n.height) {
|
|
561
|
-
return prev;
|
|
562
|
-
}
|
|
701
|
+
return () => {
|
|
702
|
+
if (screenfull.isEnabled) {
|
|
703
|
+
screenfull.off("change", onChange);
|
|
563
704
|
}
|
|
564
|
-
|
|
565
|
-
});
|
|
705
|
+
};
|
|
566
706
|
};
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
currentElement.current = nodeElement;
|
|
586
|
-
return function () {
|
|
587
|
-
if (unsubscribe !== null) {
|
|
588
|
-
unsubscribe(nodeElement, callback);
|
|
589
|
-
}
|
|
707
|
+
t3 = [];
|
|
708
|
+
$[3] = t2;
|
|
709
|
+
$[4] = t3;
|
|
710
|
+
} else {
|
|
711
|
+
t2 = $[3];
|
|
712
|
+
t3 = $[4];
|
|
713
|
+
}
|
|
714
|
+
useEffect(t2, t3);
|
|
715
|
+
let t4;
|
|
716
|
+
if ($[5] !== active || $[6] !== enabled || $[7] !== toggle) {
|
|
717
|
+
t4 = {
|
|
718
|
+
ref,
|
|
719
|
+
toggle,
|
|
720
|
+
fullscreen,
|
|
721
|
+
unFullscreen,
|
|
722
|
+
active,
|
|
723
|
+
enabled
|
|
590
724
|
};
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
* Intersection Observer
|
|
600
|
-
*/
|
|
601
|
-
var thresholdArray = buildThresholdArray();
|
|
602
|
-
var intersectionObserverInitialEntry = {
|
|
603
|
-
target: null,
|
|
604
|
-
time: null,
|
|
605
|
-
isVisible: false,
|
|
606
|
-
isIntersecting: false,
|
|
607
|
-
intersectionRatio: 0,
|
|
608
|
-
intersectionRect: null,
|
|
609
|
-
boundingClientRect: null,
|
|
610
|
-
rootBounds: null
|
|
611
|
-
};
|
|
612
|
-
var useIntersectionObserver = function useIntersectionObserver() {
|
|
613
|
-
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
614
|
-
_ref4$root = _ref4.root,
|
|
615
|
-
root = _ref4$root === void 0 ? null : _ref4$root,
|
|
616
|
-
_ref4$rootMargin = _ref4.rootMargin,
|
|
617
|
-
rootMargin = _ref4$rootMargin === void 0 ? '0px' : _ref4$rootMargin,
|
|
618
|
-
_ref4$threshold = _ref4.threshold,
|
|
619
|
-
threshold = _ref4$threshold === void 0 ? thresholdArray : _ref4$threshold,
|
|
620
|
-
_ref4$disabled = _ref4.disabled,
|
|
621
|
-
disabled = _ref4$disabled === void 0 ? false : _ref4$disabled;
|
|
622
|
-
return useObserver(typeof window !== 'undefined' ? IntersectionObserver : null, {
|
|
623
|
-
root: root,
|
|
624
|
-
rootMargin: rootMargin,
|
|
625
|
-
threshold: threshold,
|
|
626
|
-
disabled: disabled
|
|
627
|
-
}, intersectionObserverInitialEntry);
|
|
725
|
+
$[5] = active;
|
|
726
|
+
$[6] = enabled;
|
|
727
|
+
$[7] = toggle;
|
|
728
|
+
$[8] = t4;
|
|
729
|
+
} else {
|
|
730
|
+
t4 = $[8];
|
|
731
|
+
}
|
|
732
|
+
return t4;
|
|
628
733
|
};
|
|
734
|
+
function _temp$8() {
|
|
735
|
+
return screenfull.isEnabled;
|
|
736
|
+
}
|
|
737
|
+
function _temp2$2() {
|
|
738
|
+
if (screenfull.isEnabled) {
|
|
739
|
+
screenfull.exit();
|
|
740
|
+
}
|
|
741
|
+
}
|
|
629
742
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
};
|
|
743
|
+
function useDimensionObserver(t0) {
|
|
744
|
+
const $ = c(16);
|
|
745
|
+
let t1;
|
|
746
|
+
if ($[0] !== t0) {
|
|
747
|
+
t1 = t0 === undefined ? {} : t0;
|
|
748
|
+
$[0] = t0;
|
|
749
|
+
$[1] = t1;
|
|
750
|
+
} else {
|
|
751
|
+
t1 = $[1];
|
|
752
|
+
}
|
|
753
|
+
const opts = t1;
|
|
754
|
+
const t2 = useResizeObserver(opts);
|
|
755
|
+
let entry;
|
|
756
|
+
let rest;
|
|
757
|
+
if ($[2] !== t2) {
|
|
758
|
+
({
|
|
759
|
+
entry,
|
|
760
|
+
...rest
|
|
761
|
+
} = t2);
|
|
762
|
+
$[2] = t2;
|
|
763
|
+
$[3] = entry;
|
|
764
|
+
$[4] = rest;
|
|
765
|
+
} else {
|
|
766
|
+
entry = $[3];
|
|
767
|
+
rest = $[4];
|
|
768
|
+
}
|
|
769
|
+
let t3;
|
|
770
|
+
if ($[5] !== entry) {
|
|
771
|
+
t3 = entry || {};
|
|
772
|
+
$[5] = entry;
|
|
773
|
+
$[6] = t3;
|
|
774
|
+
} else {
|
|
775
|
+
t3 = $[6];
|
|
776
|
+
}
|
|
777
|
+
const {
|
|
778
|
+
contentRect: t4,
|
|
779
|
+
borderBoxSize: t5
|
|
780
|
+
} = t3;
|
|
781
|
+
const contentRect = t4 === undefined ? null : t4;
|
|
782
|
+
const borderBoxSize = t5 === undefined ? null : t5;
|
|
783
|
+
let t6;
|
|
784
|
+
if ($[7] !== contentRect) {
|
|
785
|
+
t6 = contentRect || {};
|
|
786
|
+
$[7] = contentRect;
|
|
787
|
+
$[8] = t6;
|
|
788
|
+
} else {
|
|
789
|
+
t6 = $[8];
|
|
790
|
+
}
|
|
791
|
+
const {
|
|
792
|
+
width: t7,
|
|
793
|
+
height: t8
|
|
794
|
+
} = t6;
|
|
795
|
+
const width = t7 === undefined ? 0 : t7;
|
|
796
|
+
const height = t8 === undefined ? 0 : t8;
|
|
797
|
+
let t9;
|
|
798
|
+
if ($[9] !== borderBoxSize) {
|
|
799
|
+
t9 = isArray(borderBoxSize) ? borderBoxSize[0] || {} : borderBoxSize || {};
|
|
800
|
+
$[9] = borderBoxSize;
|
|
801
|
+
$[10] = t9;
|
|
802
|
+
} else {
|
|
803
|
+
t9 = $[10];
|
|
804
|
+
}
|
|
805
|
+
const {
|
|
806
|
+
blockSize: t10,
|
|
807
|
+
inlineSize: t11
|
|
808
|
+
} = t9;
|
|
809
|
+
const blockSize = t10 === undefined ? null : t10;
|
|
810
|
+
const inlineSize = t11 === undefined ? null : t11;
|
|
811
|
+
const t12 = inlineSize || width;
|
|
812
|
+
const t13 = blockSize || height;
|
|
813
|
+
let t14;
|
|
814
|
+
if ($[11] !== entry || $[12] !== rest || $[13] !== t12 || $[14] !== t13) {
|
|
815
|
+
t14 = {
|
|
816
|
+
...rest,
|
|
817
|
+
entry,
|
|
818
|
+
width: t12,
|
|
819
|
+
height: t13
|
|
820
|
+
};
|
|
821
|
+
$[11] = entry;
|
|
822
|
+
$[12] = rest;
|
|
823
|
+
$[13] = t12;
|
|
824
|
+
$[14] = t13;
|
|
825
|
+
$[15] = t14;
|
|
826
|
+
} else {
|
|
827
|
+
t14 = $[15];
|
|
828
|
+
}
|
|
829
|
+
return t14;
|
|
830
|
+
}
|
|
673
831
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
832
|
+
const useIsVisible = t0 => {
|
|
833
|
+
const $ = c(8);
|
|
834
|
+
let t1;
|
|
835
|
+
if ($[0] !== t0) {
|
|
836
|
+
t1 = t0 === undefined ? {} : t0;
|
|
837
|
+
$[0] = t0;
|
|
838
|
+
$[1] = t1;
|
|
839
|
+
} else {
|
|
840
|
+
t1 = $[1];
|
|
841
|
+
}
|
|
842
|
+
const {
|
|
843
|
+
rootMargin,
|
|
844
|
+
persist: t2,
|
|
845
|
+
disabled: t3
|
|
846
|
+
} = t1;
|
|
847
|
+
const persist = t2 === undefined ? false : t2;
|
|
848
|
+
const disabled = t3 === undefined ? false : t3;
|
|
849
|
+
let t4;
|
|
850
|
+
if ($[2] !== disabled || $[3] !== rootMargin) {
|
|
851
|
+
t4 = {
|
|
852
|
+
rootMargin,
|
|
853
|
+
disabled
|
|
854
|
+
};
|
|
855
|
+
$[2] = disabled;
|
|
856
|
+
$[3] = rootMargin;
|
|
857
|
+
$[4] = t4;
|
|
858
|
+
} else {
|
|
859
|
+
t4 = $[4];
|
|
860
|
+
}
|
|
861
|
+
const {
|
|
862
|
+
ref,
|
|
863
|
+
entry: t5
|
|
864
|
+
} = useIntersectionObserver(t4);
|
|
865
|
+
const {
|
|
866
|
+
isIntersecting
|
|
867
|
+
} = t5;
|
|
868
|
+
const [wasIntersecting, setWasIntersecting] = useState(isIntersecting);
|
|
869
|
+
if (isIntersecting && !wasIntersecting) {
|
|
870
|
+
setWasIntersecting(isIntersecting);
|
|
871
|
+
}
|
|
872
|
+
const isVisible = !persist && isIntersecting || persist && wasIntersecting;
|
|
873
|
+
let t6;
|
|
874
|
+
if ($[5] !== isVisible || $[6] !== ref) {
|
|
875
|
+
t6 = {
|
|
876
|
+
ref,
|
|
877
|
+
visible: isVisible
|
|
878
|
+
};
|
|
879
|
+
$[5] = isVisible;
|
|
880
|
+
$[6] = ref;
|
|
881
|
+
$[7] = t6;
|
|
882
|
+
} else {
|
|
883
|
+
t6 = $[7];
|
|
884
|
+
}
|
|
885
|
+
return t6;
|
|
696
886
|
};
|
|
697
887
|
|
|
698
|
-
|
|
888
|
+
const fontsMap = {
|
|
699
889
|
loading: [],
|
|
700
890
|
active: []
|
|
701
891
|
};
|
|
702
|
-
|
|
703
|
-
|
|
892
|
+
const isFontLoading = name => fontsMap.loading.indexOf(name) !== -1;
|
|
893
|
+
const isFontActive = name => fontsMap.active.indexOf(name) !== -1;
|
|
894
|
+
const addFontLoading = name => {
|
|
895
|
+
fontsMap.active = fontsMap.active.filter(it => it !== name);
|
|
896
|
+
fontsMap.loading = [...fontsMap.loading, name];
|
|
704
897
|
};
|
|
705
|
-
|
|
706
|
-
|
|
898
|
+
const removeFontLoading = name => {
|
|
899
|
+
fontsMap.loading = fontsMap.loading.filter(it => it !== name);
|
|
707
900
|
};
|
|
708
|
-
|
|
709
|
-
fontsMap.
|
|
710
|
-
|
|
711
|
-
});
|
|
712
|
-
fontsMap.loading = [].concat(_toConsumableArray(fontsMap.loading), [name]);
|
|
713
|
-
};
|
|
714
|
-
var removeFontLoading = function removeFontLoading(name) {
|
|
715
|
-
fontsMap.loading = fontsMap.loading.filter(function (it) {
|
|
716
|
-
return it !== name;
|
|
717
|
-
});
|
|
901
|
+
const addFontActive = name => {
|
|
902
|
+
fontsMap.loading = fontsMap.loading.filter(it => it !== name);
|
|
903
|
+
fontsMap.active = [...fontsMap.active, name];
|
|
718
904
|
};
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
var config = fonts.reduce(function (newConfig, font) {
|
|
732
|
-
var _ref = isObject(font) ? font : {
|
|
733
|
-
type: 'system',
|
|
734
|
-
name: font
|
|
735
|
-
},
|
|
736
|
-
type = _ref.type,
|
|
737
|
-
name = _ref.name,
|
|
738
|
-
_ref$variants = _ref.variants,
|
|
739
|
-
variants = _ref$variants === void 0 ? [] : _ref$variants;
|
|
905
|
+
const useLoadedFonts = fonts => {
|
|
906
|
+
const [loaded, setLoaded] = useState(false);
|
|
907
|
+
useEffect(() => {
|
|
908
|
+
const config = fonts.reduce((newConfig, font) => {
|
|
909
|
+
const {
|
|
910
|
+
type,
|
|
911
|
+
name,
|
|
912
|
+
variants = []
|
|
913
|
+
} = isObject(font) ? font : {
|
|
914
|
+
type: 'system',
|
|
915
|
+
name: font
|
|
916
|
+
};
|
|
740
917
|
if ((type === 'google' || type === 'custom') && !isFontLoading(name) && !isFontActive(name)) {
|
|
741
|
-
return
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
_ref2$style = _ref2.style,
|
|
754
|
-
style = _ref2$style === void 0 ? null : _ref2$style;
|
|
755
|
-
return fvd || [style, weight].filter(function (it) {
|
|
756
|
-
return it !== null;
|
|
757
|
-
}).map(function (it) {
|
|
758
|
-
return "".concat(it).substr(0, 1);
|
|
759
|
-
}).join('');
|
|
760
|
-
}).filter(function (it) {
|
|
761
|
-
return it !== null && it.length > 0;
|
|
762
|
-
}).join(',')].filter(function (it) {
|
|
763
|
-
return it !== null && it.length > 0;
|
|
764
|
-
}).join(':')])
|
|
765
|
-
}));
|
|
918
|
+
return {
|
|
919
|
+
...newConfig,
|
|
920
|
+
[type]: {
|
|
921
|
+
families: [...(newConfig !== null ? (newConfig[type] || {}).families || [] : []), type === 'google' ? [name, (variants || []).filter(it => it !== null).join(',')].filter(it_0 => it_0 !== null && it_0.length > 0).join(':') : [name, (variants !== null ? [{
|
|
922
|
+
fvd: 'n4'
|
|
923
|
+
}, ...variants] : []).map(({
|
|
924
|
+
fvd = null,
|
|
925
|
+
weight = null,
|
|
926
|
+
style = null
|
|
927
|
+
}) => fvd || [style, weight].filter(it_1 => it_1 !== null).map(it_2 => `${it_2}`.substr(0, 1)).join('')).filter(it_3 => it_3 !== null && it_3.length > 0).join(',')].filter(it_4 => it_4 !== null && it_4.length > 0).join(':')]
|
|
928
|
+
}
|
|
929
|
+
};
|
|
766
930
|
}
|
|
767
931
|
return newConfig;
|
|
768
932
|
}, null);
|
|
769
|
-
|
|
933
|
+
const hasConfig = config !== null;
|
|
770
934
|
if (hasConfig && typeof window !== 'undefined') {
|
|
771
|
-
import('webfontloader').then(
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
fontactive: function fontactive(name) {
|
|
782
|
-
return addFontActive(name);
|
|
783
|
-
},
|
|
784
|
-
fontinactive: function fontinactive(name) {
|
|
785
|
-
return removeFontLoading(name);
|
|
786
|
-
}
|
|
787
|
-
}));
|
|
788
|
-
});
|
|
935
|
+
import('webfontloader').then(({
|
|
936
|
+
default: WebFont
|
|
937
|
+
}) => WebFont.load({
|
|
938
|
+
...config,
|
|
939
|
+
timeout: 3000,
|
|
940
|
+
active: () => setLoaded(true),
|
|
941
|
+
fontloading: name_0 => addFontLoading(name_0),
|
|
942
|
+
fontactive: name_1 => addFontActive(name_1),
|
|
943
|
+
fontinactive: name_2 => removeFontLoading(name_2)
|
|
944
|
+
}));
|
|
789
945
|
} else {
|
|
790
946
|
setLoaded(true);
|
|
791
947
|
}
|
|
792
948
|
}, [fonts, setLoaded]);
|
|
793
949
|
return {
|
|
794
|
-
loaded
|
|
950
|
+
loaded
|
|
795
951
|
};
|
|
796
952
|
};
|
|
797
953
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
};
|
|
801
|
-
var preventDefault = function preventDefault(event) {
|
|
954
|
+
const isTouchEvent = event => 'touches' in event;
|
|
955
|
+
const preventDefault = event => {
|
|
802
956
|
if (!isTouchEvent(event)) return false;
|
|
803
957
|
if (event.touches.length < 2 && event.preventDefault) {
|
|
804
958
|
event.preventDefault();
|
|
805
959
|
}
|
|
806
960
|
return false;
|
|
807
961
|
};
|
|
808
|
-
|
|
962
|
+
const preventClickDefault = e => {
|
|
809
963
|
if (e.preventDefault) {
|
|
810
964
|
e.preventDefault();
|
|
811
965
|
}
|
|
@@ -813,35 +967,22 @@ var preventClickDefault = function preventClickDefault(e) {
|
|
|
813
967
|
e.stopPropagation();
|
|
814
968
|
}
|
|
815
969
|
};
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
_ref$delay = _ref.delay,
|
|
833
|
-
delay = _ref$delay === void 0 ? 350 : _ref$delay;
|
|
834
|
-
var _useState = useState(false),
|
|
835
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
836
|
-
pressed = _useState2[0],
|
|
837
|
-
setPressed = _useState2[1];
|
|
838
|
-
var _useState3 = useState(false),
|
|
839
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
840
|
-
triggered = _useState4[0],
|
|
841
|
-
setTriggered = _useState4[1];
|
|
842
|
-
var timeout = useRef(null);
|
|
843
|
-
var target = useRef(null);
|
|
844
|
-
var start = useCallback(function (event, props) {
|
|
970
|
+
const useLongPress = ({
|
|
971
|
+
onLongPress = null,
|
|
972
|
+
onLongPressStart = null,
|
|
973
|
+
onLongPressEnd = null,
|
|
974
|
+
onClick = null,
|
|
975
|
+
shouldPreventDefault = true,
|
|
976
|
+
shouldStopPropagation = false,
|
|
977
|
+
preventClick = false,
|
|
978
|
+
// lockOnceTriggered = false,
|
|
979
|
+
delay = 350
|
|
980
|
+
} = {}) => {
|
|
981
|
+
const [pressed, setPressed] = useState(false);
|
|
982
|
+
const [triggered, setTriggered] = useState(false);
|
|
983
|
+
const timeout = useRef(null);
|
|
984
|
+
const target = useRef(null);
|
|
985
|
+
const start = useCallback((event, props) => {
|
|
845
986
|
setPressed(true);
|
|
846
987
|
if (shouldStopPropagation) {
|
|
847
988
|
event.stopPropagation();
|
|
@@ -852,7 +993,7 @@ var useLongPress = function useLongPress() {
|
|
|
852
993
|
if (onLongPressStart !== null) {
|
|
853
994
|
onLongPressStart(event, props);
|
|
854
995
|
}
|
|
855
|
-
timeout.current = setTimeout(
|
|
996
|
+
timeout.current = setTimeout(() => {
|
|
856
997
|
if (shouldPreventDefault && target.current !== null) {
|
|
857
998
|
target.current.addEventListener('touchend', preventDefault, {
|
|
858
999
|
passive: false
|
|
@@ -869,8 +1010,7 @@ var useLongPress = function useLongPress() {
|
|
|
869
1010
|
timeout.current = null;
|
|
870
1011
|
}, delay);
|
|
871
1012
|
}, [onLongPress, onLongPressStart, delay, setPressed, shouldPreventDefault]);
|
|
872
|
-
|
|
873
|
-
var shouldTriggerClick = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
1013
|
+
const clear = useCallback((event_0, props_0, shouldTriggerClick = true) => {
|
|
874
1014
|
setPressed(false);
|
|
875
1015
|
if (preventClick && triggered) {
|
|
876
1016
|
return;
|
|
@@ -878,1408 +1018,1575 @@ var useLongPress = function useLongPress() {
|
|
|
878
1018
|
if (timeout.current !== null) {
|
|
879
1019
|
clearTimeout(timeout.current);
|
|
880
1020
|
} else if (shouldPreventDefault && target.current !== null) {
|
|
881
|
-
preventDefault(
|
|
1021
|
+
preventDefault(event_0);
|
|
882
1022
|
target.current.removeEventListener('touchend', preventDefault);
|
|
883
|
-
setTimeout(
|
|
1023
|
+
setTimeout(() => {
|
|
884
1024
|
target.current.removeEventListener('click', preventClickDefault);
|
|
885
1025
|
}, 10);
|
|
886
1026
|
}
|
|
887
1027
|
if (shouldTriggerClick && !triggered && onClick !== null) {
|
|
888
|
-
onClick(
|
|
1028
|
+
onClick(props_0);
|
|
889
1029
|
}
|
|
890
|
-
onLongPressEnd(
|
|
1030
|
+
onLongPressEnd(event_0, props_0, triggered);
|
|
891
1031
|
setTriggered(false);
|
|
892
1032
|
}, [shouldPreventDefault, onClick, onLongPressEnd, setPressed, triggered, preventClick]);
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
return start(e, props);
|
|
901
|
-
},
|
|
902
|
-
onMouseUp: function onMouseUp(e) {
|
|
903
|
-
return clear(e, props);
|
|
904
|
-
},
|
|
905
|
-
onMouseLeave: function onMouseLeave(e) {
|
|
906
|
-
return clear(e, props, false);
|
|
907
|
-
},
|
|
908
|
-
onTouchEnd: function onTouchEnd(e) {
|
|
909
|
-
return clear(e, props);
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
};
|
|
1033
|
+
const bind = (props_1 = null) => ({
|
|
1034
|
+
onMouseDown: e => start(e, props_1),
|
|
1035
|
+
onTouchStart: e_0 => start(e_0, props_1),
|
|
1036
|
+
onMouseUp: e_1 => clear(e_1, props_1),
|
|
1037
|
+
onMouseLeave: e_2 => clear(e_2, props_1, false),
|
|
1038
|
+
onTouchEnd: e_3 => clear(e_3, props_1)
|
|
1039
|
+
});
|
|
913
1040
|
return {
|
|
914
|
-
bind
|
|
915
|
-
pressed
|
|
916
|
-
triggered
|
|
1041
|
+
bind,
|
|
1042
|
+
pressed,
|
|
1043
|
+
triggered
|
|
917
1044
|
};
|
|
918
1045
|
};
|
|
919
1046
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
onEnded = _ref$onEnded === void 0 ? null : _ref$onEnded,
|
|
939
|
-
_ref$onSeeked = _ref.onSeeked,
|
|
940
|
-
onSeeked = _ref$onSeeked === void 0 ? null : _ref$onSeeked,
|
|
941
|
-
_ref$onSuspend = _ref.onSuspend,
|
|
942
|
-
onSuspend = _ref$onSuspend === void 0 ? null : _ref$onSuspend,
|
|
943
|
-
_ref$onLoadStart = _ref.onLoadStart,
|
|
944
|
-
onLoadStart = _ref$onLoadStart === void 0 ? null : _ref$onLoadStart,
|
|
945
|
-
_ref$onCanPlayThough = _ref.onCanPlayThough,
|
|
946
|
-
onCanPlayThough = _ref$onCanPlayThough === void 0 ? null : _ref$onCanPlayThough,
|
|
947
|
-
_ref$onCanPlay = _ref.onCanPlay,
|
|
948
|
-
onCanPlay = _ref$onCanPlay === void 0 ? null : _ref$onCanPlay,
|
|
949
|
-
_ref$onLoadedData = _ref.onLoadedData,
|
|
950
|
-
onLoadedData = _ref$onLoadedData === void 0 ? null : _ref$onLoadedData,
|
|
951
|
-
_ref$onLoadedMetadata = _ref.onLoadedMetadata,
|
|
952
|
-
onLoadedMetadata = _ref$onLoadedMetadata === void 0 ? null : _ref$onLoadedMetadata;
|
|
953
|
-
var ref = useRef(null);
|
|
954
|
-
var _useState = useState(null),
|
|
955
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
956
|
-
currentTime = _useState2[0],
|
|
957
|
-
setCurrentTime = _useState2[1];
|
|
958
|
-
var _useState3 = useState(null),
|
|
959
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
960
|
-
duration = _useState4[0],
|
|
961
|
-
setDuration = _useState4[1];
|
|
962
|
-
var _useState5 = useState(false),
|
|
963
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
964
|
-
playing = _useState6[0],
|
|
965
|
-
setPlaying = _useState6[1];
|
|
966
|
-
var _useState7 = useState(false),
|
|
967
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
968
|
-
ready = _useState8[0],
|
|
969
|
-
setReady = _useState8[1];
|
|
970
|
-
var _useState9 = useState(false),
|
|
971
|
-
_useState0 = _slicedToArray(_useState9, 2),
|
|
972
|
-
dataReady = _useState0[0],
|
|
973
|
-
setDataReady = _useState0[1];
|
|
974
|
-
var _useState1 = useState(true),
|
|
975
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
976
|
-
initialPlay = _useState10[0],
|
|
977
|
-
setInitialPlay = _useState10[1];
|
|
978
|
-
var _useState11 = useState(false),
|
|
979
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
980
|
-
suspended = _useState12[0],
|
|
981
|
-
setSuspended = _useState12[1];
|
|
982
|
-
var progressStepsReached = useRef({});
|
|
983
|
-
var paused = !playing;
|
|
984
|
-
|
|
985
|
-
// Exposed methods
|
|
986
|
-
|
|
987
|
-
var play = useCallback(function () {
|
|
988
|
-
var media = ref.current;
|
|
989
|
-
if (media !== null) {
|
|
990
|
-
media.play();
|
|
991
|
-
}
|
|
992
|
-
}, []);
|
|
993
|
-
var pause = useCallback(function () {
|
|
994
|
-
var media = ref.current;
|
|
995
|
-
if (media !== null) {
|
|
996
|
-
media.pause();
|
|
997
|
-
}
|
|
998
|
-
}, []);
|
|
999
|
-
var stop = useCallback(function () {
|
|
1000
|
-
var media = ref.current;
|
|
1001
|
-
if (media !== null) {
|
|
1002
|
-
media.pause();
|
|
1003
|
-
media.currentTime = 0;
|
|
1004
|
-
}
|
|
1005
|
-
}, []);
|
|
1006
|
-
var seek = useCallback(function (time) {
|
|
1007
|
-
var media = ref.current;
|
|
1008
|
-
if (media !== null) {
|
|
1009
|
-
media.currentTime = time;
|
|
1010
|
-
}
|
|
1011
|
-
}, []);
|
|
1012
|
-
|
|
1013
|
-
// const mute = useCallback(() => {
|
|
1014
|
-
// const { current: media } = ref;
|
|
1015
|
-
// if (media !== null) {
|
|
1016
|
-
// media.muted = true;
|
|
1017
|
-
// }
|
|
1018
|
-
// }, []);
|
|
1019
|
-
|
|
1020
|
-
// const unMute = useCallback(() => {
|
|
1021
|
-
// const { current: media } = ref;
|
|
1022
|
-
// if (media !== null) {
|
|
1023
|
-
// media.muted = false;
|
|
1024
|
-
// }
|
|
1025
|
-
// }, []);
|
|
1026
|
-
|
|
1027
|
-
// Media events callbacks
|
|
1028
|
-
|
|
1029
|
-
var onCustomPlay = useCallback(function () {
|
|
1030
|
-
if (onPlay !== null) {
|
|
1031
|
-
onPlay({
|
|
1032
|
-
initial: initialPlay
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
if (initialPlay) {
|
|
1036
|
-
setInitialPlay(false);
|
|
1037
|
-
}
|
|
1038
|
-
setPlaying(true);
|
|
1039
|
-
setSuspended(false);
|
|
1040
|
-
}, [initialPlay, setPlaying, onPlay]);
|
|
1041
|
-
var onCustomPlaying = useCallback(function () {
|
|
1042
|
-
setPlaying(true);
|
|
1043
|
-
setSuspended(false);
|
|
1044
|
-
}, []);
|
|
1045
|
-
var onCustomPause = useCallback(function (e) {
|
|
1046
|
-
var eventMedia = e.currentTarget;
|
|
1047
|
-
setPlaying(false);
|
|
1048
|
-
if (onPause !== null) {
|
|
1049
|
-
onPause({
|
|
1050
|
-
midway: eventMedia.currentTime > 0 && eventMedia.currentTime < eventMedia.duration
|
|
1051
|
-
});
|
|
1052
|
-
}
|
|
1053
|
-
}, [setPlaying, onPause]);
|
|
1054
|
-
var onCustomEnded = useCallback(function (e) {
|
|
1055
|
-
var eventMedia = e.currentTarget;
|
|
1056
|
-
eventMedia.currentTime = 0;
|
|
1057
|
-
if (onEnded !== null) {
|
|
1058
|
-
onEnded();
|
|
1059
|
-
}
|
|
1060
|
-
setInitialPlay(true);
|
|
1061
|
-
}, [setInitialPlay, onEnded]);
|
|
1062
|
-
var onCustomTimeUpdate = useCallback(function (e) {
|
|
1063
|
-
var eventMedia = e.currentTarget;
|
|
1064
|
-
setCurrentTime(eventMedia.currentTime);
|
|
1065
|
-
if (onTimeUpdate !== null) {
|
|
1066
|
-
onTimeUpdate(eventMedia.currentTime);
|
|
1067
|
-
}
|
|
1068
|
-
var progress = eventMedia.currentTime / eventMedia.duration;
|
|
1069
|
-
var currentSteps = progressStepsReached.current;
|
|
1070
|
-
var stepsToTrack = progressSteps.filter(function (step) {
|
|
1071
|
-
return progress > step && typeof currentSteps[step] === 'undefined';
|
|
1072
|
-
});
|
|
1073
|
-
stepsToTrack.forEach(function (step) {
|
|
1074
|
-
if (onProgressStep !== null) {
|
|
1075
|
-
onProgressStep(step);
|
|
1076
|
-
}
|
|
1077
|
-
currentSteps[step] = true;
|
|
1078
|
-
});
|
|
1079
|
-
}, [setCurrentTime, onTimeUpdate, onProgressStep]);
|
|
1080
|
-
var onCustomDurationChange = useCallback(function (e) {
|
|
1081
|
-
var eventMedia = e.currentTarget;
|
|
1082
|
-
setDuration(eventMedia.duration);
|
|
1083
|
-
if (onDurationChange !== null) {
|
|
1084
|
-
onDurationChange(eventMedia.duration);
|
|
1085
|
-
}
|
|
1086
|
-
}, [setDuration, onDurationChange]);
|
|
1087
|
-
var onCustomSeeked = useCallback(function (e) {
|
|
1088
|
-
var eventMedia = e.currentTarget;
|
|
1089
|
-
if (onSeeked !== null) {
|
|
1090
|
-
onSeeked(eventMedia.currentTime);
|
|
1091
|
-
}
|
|
1092
|
-
}, [onSeeked]);
|
|
1093
|
-
var onCustomVolumeChange = useCallback(function (e) {
|
|
1094
|
-
var eventMedia = e.currentTarget;
|
|
1095
|
-
|
|
1096
|
-
// setMuted(eventMedia.muted);
|
|
1097
|
-
if (onVolumeChange !== null) {
|
|
1098
|
-
onVolumeChange(eventMedia.volume);
|
|
1099
|
-
}
|
|
1100
|
-
}, [onVolumeChange]);
|
|
1101
|
-
var onCustomLoadStart = useCallback(function () {
|
|
1102
|
-
if (onLoadStart !== null) {
|
|
1103
|
-
onLoadStart();
|
|
1104
|
-
}
|
|
1105
|
-
}, [setReady, onLoadStart]);
|
|
1106
|
-
var onCustomCanPlayThrough = useCallback(function () {
|
|
1107
|
-
setReady(true);
|
|
1108
|
-
if (onCanPlayThough !== null) {
|
|
1109
|
-
onCanPlayThough();
|
|
1110
|
-
}
|
|
1111
|
-
}, [setReady, onCanPlayThough]);
|
|
1112
|
-
var onCustomCanPlay = useCallback(function () {
|
|
1113
|
-
setReady(true);
|
|
1114
|
-
if (onCanPlay !== null) {
|
|
1115
|
-
onCanPlay();
|
|
1116
|
-
}
|
|
1117
|
-
}, [setReady, onCanPlay]);
|
|
1118
|
-
var onCustomLoadedMetadata = useCallback(function () {
|
|
1119
|
-
setReady(true);
|
|
1120
|
-
if (onLoadedMetadata !== null) {
|
|
1121
|
-
onLoadedMetadata();
|
|
1122
|
-
}
|
|
1123
|
-
}, [setReady, onLoadedMetadata]);
|
|
1124
|
-
var onCustomLoadedData = useCallback(function () {
|
|
1125
|
-
setDataReady(true);
|
|
1126
|
-
if (onLoadedData !== null) {
|
|
1127
|
-
onLoadedData();
|
|
1128
|
-
}
|
|
1129
|
-
}, [setDataReady, onLoadedData]);
|
|
1130
|
-
var onCustomSuspended = useCallback(function () {
|
|
1131
|
-
setSuspended(true);
|
|
1132
|
-
if (onSuspend !== null) {
|
|
1133
|
-
onSuspend();
|
|
1134
|
-
}
|
|
1135
|
-
}, [setSuspended, onSuspended]);
|
|
1136
|
-
useEffect(function () {
|
|
1137
|
-
var _ref$current = ref.current,
|
|
1138
|
-
media = _ref$current === void 0 ? null : _ref$current;
|
|
1139
|
-
|
|
1140
|
-
// console.log('actions', url);
|
|
1141
|
-
|
|
1142
|
-
if (media !== null) {
|
|
1143
|
-
media.addEventListener('volumechange', onCustomVolumeChange);
|
|
1144
|
-
media.addEventListener('play', onCustomPlay);
|
|
1145
|
-
media.addEventListener('playing', onCustomPlaying);
|
|
1146
|
-
media.addEventListener('pause', onCustomPause);
|
|
1147
|
-
media.addEventListener('ended', onCustomEnded);
|
|
1148
|
-
media.addEventListener('seeked', onCustomSeeked);
|
|
1149
|
-
// media.addEventListener('loadstart', onCustomLoadStart);
|
|
1150
|
-
// media.addEventListener('canplaythrough', onCustomCanPlayThrough);
|
|
1151
|
-
// media.addEventListener('canplay', onCustomCanPlay);
|
|
1152
|
-
// media.addEventListener('loadedmetadata', onCustomLoadedMetadata);
|
|
1153
|
-
// media.addEventListener('loadeddata', onCustomLoadedData);
|
|
1154
|
-
}
|
|
1155
|
-
return function () {
|
|
1156
|
-
if (media !== null) {
|
|
1157
|
-
media.removeEventListener('volumechange', onCustomVolumeChange);
|
|
1158
|
-
media.removeEventListener('play', onCustomPlay);
|
|
1159
|
-
media.removeEventListener('playing', onCustomPlaying);
|
|
1160
|
-
media.removeEventListener('pause', onCustomPause);
|
|
1161
|
-
media.removeEventListener('ended', onCustomEnded);
|
|
1162
|
-
media.removeEventListener('seeked', onCustomSeeked);
|
|
1163
|
-
// media.removeEventListener('loadstart', onCustomLoadStart);
|
|
1164
|
-
// media.removeEventListener('canplaythrough', onCustomCanPlayThrough);
|
|
1165
|
-
// media.removeEventListener('canplay', onCustomCanPlay);
|
|
1166
|
-
// media.removeEventListener('loadedmetadata', onCustomLoadedMetadata);
|
|
1167
|
-
}
|
|
1168
|
-
};
|
|
1169
|
-
}, [url, onCustomVolumeChange, onCustomPlay, onCustomPause, onCustomEnded, onCustomSeeked, onCustomSuspended
|
|
1170
|
-
// onCustomLoadStart,
|
|
1171
|
-
// onCustomCanPlayThrough,
|
|
1172
|
-
// onCustomCanPlay,
|
|
1173
|
-
// onCustomLoadedMetadata,
|
|
1174
|
-
]);
|
|
1175
|
-
useEffect(function () {
|
|
1176
|
-
var _ref$current2 = ref.current,
|
|
1177
|
-
media = _ref$current2 === void 0 ? null : _ref$current2;
|
|
1178
|
-
if (media !== null) {
|
|
1179
|
-
media.addEventListener('loadstart', onCustomLoadStart);
|
|
1180
|
-
media.addEventListener('canplaythrough', onCustomCanPlayThrough);
|
|
1181
|
-
media.addEventListener('canplay', onCustomCanPlay);
|
|
1182
|
-
media.addEventListener('loadedmetadata', onCustomLoadedMetadata);
|
|
1183
|
-
media.addEventListener('loadeddata', onCustomLoadedData);
|
|
1184
|
-
media.addEventListener('suspend', onCustomSuspended);
|
|
1185
|
-
}
|
|
1186
|
-
return function () {
|
|
1187
|
-
if (media !== null) {
|
|
1188
|
-
media.removeEventListener('loadstart', onCustomLoadStart);
|
|
1189
|
-
media.removeEventListener('canplaythrough', onCustomCanPlayThrough);
|
|
1190
|
-
media.removeEventListener('canplay', onCustomCanPlay);
|
|
1191
|
-
media.removeEventListener('loadedmetadata', onCustomLoadedMetadata);
|
|
1192
|
-
media.removeEventListener('suspend', onCustomSuspended);
|
|
1193
|
-
}
|
|
1194
|
-
};
|
|
1195
|
-
}, [url, onCustomLoadStart, onCustomCanPlayThrough, onCustomCanPlay, onCustomLoadedMetadata, onCustomSuspended]);
|
|
1196
|
-
|
|
1197
|
-
// Duration
|
|
1198
|
-
useEffect(function () {
|
|
1199
|
-
var _ref$current3 = ref.current,
|
|
1200
|
-
media = _ref$current3 === void 0 ? null : _ref$current3;
|
|
1201
|
-
if (media !== null) {
|
|
1202
|
-
media.addEventListener('durationchange', onCustomDurationChange);
|
|
1203
|
-
}
|
|
1204
|
-
return function () {
|
|
1205
|
-
if (media !== null) {
|
|
1206
|
-
media.removeEventListener('durationchange', onCustomDurationChange);
|
|
1207
|
-
}
|
|
1208
|
-
};
|
|
1209
|
-
}, [url, onCustomDurationChange]);
|
|
1210
|
-
|
|
1211
|
-
// Timeupdate
|
|
1212
|
-
useEffect(function () {
|
|
1213
|
-
var _ref$current4 = ref.current,
|
|
1214
|
-
media = _ref$current4 === void 0 ? null : _ref$current4;
|
|
1215
|
-
// console.log('timeupdate', url);
|
|
1216
|
-
if (media !== null) {
|
|
1217
|
-
media.addEventListener('timeupdate', onCustomTimeUpdate);
|
|
1218
|
-
}
|
|
1219
|
-
return function () {
|
|
1220
|
-
if (media !== null) {
|
|
1221
|
-
media.removeEventListener('timeupdate', onCustomTimeUpdate);
|
|
1047
|
+
const useMediaBuffering = t0 => {
|
|
1048
|
+
const $ = c(7);
|
|
1049
|
+
const media = t0 === undefined ? null : t0;
|
|
1050
|
+
let t1;
|
|
1051
|
+
if ($[0] !== media) {
|
|
1052
|
+
t1 = () => getMediaIsBuffering(media);
|
|
1053
|
+
$[0] = media;
|
|
1054
|
+
$[1] = t1;
|
|
1055
|
+
} else {
|
|
1056
|
+
t1 = $[1];
|
|
1057
|
+
}
|
|
1058
|
+
const [buffering, setBuffering] = useState(t1);
|
|
1059
|
+
let t2;
|
|
1060
|
+
let t3;
|
|
1061
|
+
if ($[2] !== media) {
|
|
1062
|
+
t2 = () => {
|
|
1063
|
+
if (media === null) {
|
|
1064
|
+
return _temp$7;
|
|
1222
1065
|
}
|
|
1066
|
+
const onBufferingEvent = function onBufferingEvent(e) {
|
|
1067
|
+
setBuffering(getMediaIsBuffering(e.currentTarget));
|
|
1068
|
+
};
|
|
1069
|
+
media.addEventListener("canplay", onBufferingEvent);
|
|
1070
|
+
media.addEventListener("waiting", onBufferingEvent);
|
|
1071
|
+
media.addEventListener("stalled", onBufferingEvent);
|
|
1072
|
+
media.addEventListener("play", onBufferingEvent);
|
|
1073
|
+
media.addEventListener("playing", onBufferingEvent);
|
|
1074
|
+
media.addEventListener("pause", onBufferingEvent);
|
|
1075
|
+
media.addEventListener("ended", onBufferingEvent);
|
|
1076
|
+
return () => {
|
|
1077
|
+
media.removeEventListener("canplay", onBufferingEvent);
|
|
1078
|
+
media.removeEventListener("waiting", onBufferingEvent);
|
|
1079
|
+
media.removeEventListener("stalled", onBufferingEvent);
|
|
1080
|
+
media.removeEventListener("play", onBufferingEvent);
|
|
1081
|
+
media.removeEventListener("playing", onBufferingEvent);
|
|
1082
|
+
media.removeEventListener("pause", onBufferingEvent);
|
|
1083
|
+
media.removeEventListener("ended", onBufferingEvent);
|
|
1084
|
+
};
|
|
1223
1085
|
};
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
}
|
|
1238
|
-
}, [url]);
|
|
1239
|
-
return {
|
|
1240
|
-
ref: ref,
|
|
1241
|
-
play: play,
|
|
1242
|
-
pause: pause,
|
|
1243
|
-
stop: stop,
|
|
1244
|
-
seek: seek,
|
|
1245
|
-
currentTime: currentTime,
|
|
1246
|
-
duration: duration,
|
|
1247
|
-
playing: playing,
|
|
1248
|
-
paused: paused,
|
|
1249
|
-
ready: ready,
|
|
1250
|
-
dataReady: dataReady,
|
|
1251
|
-
suspended: suspended
|
|
1252
|
-
};
|
|
1253
|
-
};
|
|
1254
|
-
|
|
1255
|
-
var useMediaBuffering = function useMediaBuffering() {
|
|
1256
|
-
var mediaElement = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
1257
|
-
var _useState = useState(false),
|
|
1258
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1259
|
-
buffering = _useState2[0],
|
|
1260
|
-
setBuffering = _useState2[1];
|
|
1261
|
-
useEffect(function () {
|
|
1262
|
-
if (mediaElement === null) {
|
|
1263
|
-
return function () {};
|
|
1264
|
-
}
|
|
1265
|
-
function onBufferingEvent(e) {
|
|
1266
|
-
// networkstate
|
|
1267
|
-
if (mediaElement.networkState === mediaElement.NETWORK_LOADING) {
|
|
1268
|
-
// The user agent is actively trying to download data.
|
|
1269
|
-
setBuffering(true);
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
// readystate
|
|
1273
|
-
if (mediaElement.readyState < mediaElement.HAVE_FUTURE_DATA) {
|
|
1274
|
-
// There is not enough data to keep playing from this point
|
|
1275
|
-
setBuffering(true);
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
function onPlay() {
|
|
1279
|
-
setBuffering(false);
|
|
1280
|
-
}
|
|
1281
|
-
function onPlaying() {
|
|
1282
|
-
setBuffering(false);
|
|
1283
|
-
}
|
|
1284
|
-
function onPause() {
|
|
1285
|
-
setBuffering(false);
|
|
1286
|
-
}
|
|
1287
|
-
function onEnded() {
|
|
1288
|
-
setBuffering(false);
|
|
1289
|
-
}
|
|
1290
|
-
mediaElement.addEventListener('waiting', onBufferingEvent);
|
|
1291
|
-
mediaElement.addEventListener('stalled', onBufferingEvent);
|
|
1292
|
-
mediaElement.addEventListener('play', onPlay);
|
|
1293
|
-
mediaElement.addEventListener('playing', onPlaying);
|
|
1294
|
-
mediaElement.addEventListener('pause', onPause);
|
|
1295
|
-
mediaElement.addEventListener('ended', onEnded);
|
|
1296
|
-
return function () {
|
|
1297
|
-
mediaElement.removeEventListener('waiting', onBufferingEvent);
|
|
1298
|
-
mediaElement.removeEventListener('stalled', onBufferingEvent);
|
|
1299
|
-
mediaElement.removeEventListener('play', onPlay);
|
|
1300
|
-
mediaElement.removeEventListener('playing', onPlaying);
|
|
1301
|
-
mediaElement.removeEventListener('pause', onPause);
|
|
1302
|
-
mediaElement.removeEventListener('ended', onEnded);
|
|
1086
|
+
t3 = [media];
|
|
1087
|
+
$[2] = media;
|
|
1088
|
+
$[3] = t2;
|
|
1089
|
+
$[4] = t3;
|
|
1090
|
+
} else {
|
|
1091
|
+
t2 = $[3];
|
|
1092
|
+
t3 = $[4];
|
|
1093
|
+
}
|
|
1094
|
+
useEffect(t2, t3);
|
|
1095
|
+
let t4;
|
|
1096
|
+
if ($[5] !== buffering) {
|
|
1097
|
+
t4 = {
|
|
1098
|
+
buffering
|
|
1303
1099
|
};
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
// let lastPlayPos = 0;
|
|
1311
|
-
// let currentPlayPos = 0;
|
|
1312
|
-
// let bufferingDetected = false;
|
|
1313
|
-
|
|
1314
|
-
// function checkBuffering(player, checkInterval) {
|
|
1315
|
-
// currentPlayPos = player.currentTime;
|
|
1316
|
-
|
|
1317
|
-
// // checking offset should be at most the check interval
|
|
1318
|
-
// // but allow for some margin
|
|
1319
|
-
// const offset = (checkInterval - 20) / 1000;
|
|
1320
|
-
|
|
1321
|
-
// // if no buffering is currently detected,
|
|
1322
|
-
// // and the position does not seem to increase
|
|
1323
|
-
// // and the player isn't manually paused...
|
|
1324
|
-
// if (!bufferingDetected && currentPlayPos < lastPlayPos + offset && !player.paused) {
|
|
1325
|
-
// console.log('buffering!');
|
|
1326
|
-
// bufferingDetected = true;
|
|
1327
|
-
// }
|
|
1328
|
-
|
|
1329
|
-
// // if we were buffering but the player has advanced,
|
|
1330
|
-
// // then there is no buffering
|
|
1331
|
-
// if (bufferingDetected && currentPlayPos > lastPlayPos + offset && !player.paused) {
|
|
1332
|
-
// console.log('not buffering anymore!');
|
|
1333
|
-
// bufferingDetected = false;
|
|
1334
|
-
// }
|
|
1335
|
-
// lastPlayPos = currentPlayPos;
|
|
1336
|
-
|
|
1337
|
-
// return bufferingDetected;
|
|
1338
|
-
// }
|
|
1339
|
-
|
|
1340
|
-
// const id = setInterval(() => {
|
|
1341
|
-
// setBuffering(checkBuffering(mediaElement, interval));
|
|
1342
|
-
// }, interval);
|
|
1343
|
-
|
|
1344
|
-
// return () => {
|
|
1345
|
-
// clearInterval(id);
|
|
1346
|
-
// };
|
|
1347
|
-
// }, [mediaElement, interval]);
|
|
1348
|
-
|
|
1349
|
-
return {
|
|
1350
|
-
buffering: buffering
|
|
1351
|
-
};
|
|
1100
|
+
$[5] = buffering;
|
|
1101
|
+
$[6] = t4;
|
|
1102
|
+
} else {
|
|
1103
|
+
t4 = $[6];
|
|
1104
|
+
}
|
|
1105
|
+
return t4;
|
|
1352
1106
|
};
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
}
|
|
1418
|
-
function onPlaying() {
|
|
1419
|
-
debug('onPlaying');
|
|
1420
|
-
setPlaying(true);
|
|
1421
|
-
setBuffering(false);
|
|
1422
|
-
}
|
|
1423
|
-
function onTimeUpdate(e) {
|
|
1424
|
-
debug('onTimeUpdate');
|
|
1425
|
-
setPlaying(!e.currentTarget.paused && !e.currentTarget.ended);
|
|
1426
|
-
setBuffering(false);
|
|
1427
|
-
}
|
|
1428
|
-
function onPause() {
|
|
1429
|
-
debug('onPause');
|
|
1430
|
-
setPlaying(false);
|
|
1431
|
-
setBuffering(false);
|
|
1432
|
-
}
|
|
1433
|
-
function onEnded() {
|
|
1434
|
-
debug('onEnded');
|
|
1435
|
-
setPlaying(false);
|
|
1436
|
-
setBuffering(false);
|
|
1437
|
-
}
|
|
1438
|
-
function onSuspend(e) {
|
|
1439
|
-
debug('onSuspend');
|
|
1440
|
-
setPlaying(!e.currentTarget.paused && !e.currentTarget.ended);
|
|
1107
|
+
function _temp$7() {}
|
|
1108
|
+
|
|
1109
|
+
function useMediaState(t0, t1) {
|
|
1110
|
+
const $ = c(35);
|
|
1111
|
+
const media = t0 === undefined ? null : t0;
|
|
1112
|
+
let t2;
|
|
1113
|
+
if ($[0] !== t1) {
|
|
1114
|
+
t2 = t1 === undefined ? {} : t1;
|
|
1115
|
+
$[0] = t1;
|
|
1116
|
+
$[1] = t2;
|
|
1117
|
+
} else {
|
|
1118
|
+
t2 = $[1];
|
|
1119
|
+
}
|
|
1120
|
+
const {
|
|
1121
|
+
playing: t3,
|
|
1122
|
+
muted: t4
|
|
1123
|
+
} = t2;
|
|
1124
|
+
const wantedPlaying = t3 === undefined ? false : t3;
|
|
1125
|
+
const wantedMuted = t4 === undefined ? false : t4;
|
|
1126
|
+
const [currentMediaElement, setCurrentMediaElement] = useState(media);
|
|
1127
|
+
let t5;
|
|
1128
|
+
if ($[2] !== media) {
|
|
1129
|
+
t5 = () => getMediaSrc(media);
|
|
1130
|
+
$[2] = media;
|
|
1131
|
+
$[3] = t5;
|
|
1132
|
+
} else {
|
|
1133
|
+
t5 = $[3];
|
|
1134
|
+
}
|
|
1135
|
+
const [src, setSrc] = useState(t5);
|
|
1136
|
+
let t6;
|
|
1137
|
+
if ($[4] !== media || $[5] !== wantedPlaying) {
|
|
1138
|
+
t6 = () => getMediaIsPlaying(media) || wantedPlaying;
|
|
1139
|
+
$[4] = media;
|
|
1140
|
+
$[5] = wantedPlaying;
|
|
1141
|
+
$[6] = t6;
|
|
1142
|
+
} else {
|
|
1143
|
+
t6 = $[6];
|
|
1144
|
+
}
|
|
1145
|
+
const [playing, setPlaying] = useState(t6);
|
|
1146
|
+
const [buffering, setBuffering] = useState(false);
|
|
1147
|
+
let t7;
|
|
1148
|
+
if ($[7] !== media || $[8] !== wantedMuted) {
|
|
1149
|
+
t7 = () => getMediaIsMuted(media) || wantedMuted;
|
|
1150
|
+
$[7] = media;
|
|
1151
|
+
$[8] = wantedMuted;
|
|
1152
|
+
$[9] = t7;
|
|
1153
|
+
} else {
|
|
1154
|
+
t7 = $[9];
|
|
1155
|
+
}
|
|
1156
|
+
const [muted, setMuted] = useState(t7);
|
|
1157
|
+
let t8;
|
|
1158
|
+
if ($[10] !== src) {
|
|
1159
|
+
t8 = getMediaFilename(src);
|
|
1160
|
+
$[10] = src;
|
|
1161
|
+
$[11] = t8;
|
|
1162
|
+
} else {
|
|
1163
|
+
t8 = $[11];
|
|
1164
|
+
}
|
|
1165
|
+
const mediaKey = t8;
|
|
1166
|
+
let debug;
|
|
1167
|
+
if ($[12] !== currentMediaElement || $[13] !== media || $[14] !== mediaKey || $[15] !== wantedMuted || $[16] !== wantedPlaying) {
|
|
1168
|
+
debug = createDebug(mediaKey !== null ? `micromag:media:${mediaKey}` : "micromag:media");
|
|
1169
|
+
if (media !== currentMediaElement) {
|
|
1170
|
+
setPlaying(getMediaIsPlaying(media) || wantedPlaying);
|
|
1441
1171
|
setBuffering(false);
|
|
1172
|
+
setMuted(getMediaIsMuted(media) || wantedMuted);
|
|
1173
|
+
setCurrentMediaElement(media);
|
|
1174
|
+
setSrc(getMediaSrc(media));
|
|
1175
|
+
debug("Unset media: %o", {
|
|
1176
|
+
wantedPlaying,
|
|
1177
|
+
wantedMuted
|
|
1178
|
+
});
|
|
1442
1179
|
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
return function () {
|
|
1462
|
-
mediaElement.removeEventListener('waiting', onBufferingEvent);
|
|
1463
|
-
mediaElement.removeEventListener('stalled', onBufferingEvent);
|
|
1464
|
-
mediaElement.removeEventListener('timeupdate', onTimeUpdate);
|
|
1465
|
-
mediaElement.removeEventListener('play', onPlay);
|
|
1466
|
-
mediaElement.removeEventListener('playing', onPlaying);
|
|
1467
|
-
mediaElement.removeEventListener('pause', onPause);
|
|
1468
|
-
mediaElement.removeEventListener('suspend', onSuspend);
|
|
1469
|
-
mediaElement.removeEventListener('ended', onEnded);
|
|
1470
|
-
mediaElement.removeEventListener('volumechange', onVolumeChange);
|
|
1180
|
+
$[12] = currentMediaElement;
|
|
1181
|
+
$[13] = media;
|
|
1182
|
+
$[14] = mediaKey;
|
|
1183
|
+
$[15] = wantedMuted;
|
|
1184
|
+
$[16] = wantedPlaying;
|
|
1185
|
+
$[17] = debug;
|
|
1186
|
+
} else {
|
|
1187
|
+
debug = $[17];
|
|
1188
|
+
}
|
|
1189
|
+
let t10;
|
|
1190
|
+
let t9;
|
|
1191
|
+
if ($[18] !== buffering || $[19] !== debug || $[20] !== muted || $[21] !== playing) {
|
|
1192
|
+
t9 = () => {
|
|
1193
|
+
debug("State change %o", {
|
|
1194
|
+
playing,
|
|
1195
|
+
buffering,
|
|
1196
|
+
muted
|
|
1197
|
+
});
|
|
1471
1198
|
};
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
var mutationType = _ref2.type;
|
|
1497
|
-
if (mutationType === 'attributes') {
|
|
1498
|
-
setTimestampOffset(getTimestampOffset());
|
|
1199
|
+
t10 = [playing, buffering, muted, debug];
|
|
1200
|
+
$[18] = buffering;
|
|
1201
|
+
$[19] = debug;
|
|
1202
|
+
$[20] = muted;
|
|
1203
|
+
$[21] = playing;
|
|
1204
|
+
$[22] = t10;
|
|
1205
|
+
$[23] = t9;
|
|
1206
|
+
} else {
|
|
1207
|
+
t10 = $[22];
|
|
1208
|
+
t9 = $[23];
|
|
1209
|
+
}
|
|
1210
|
+
useEffect(t9, t10);
|
|
1211
|
+
let t11;
|
|
1212
|
+
if ($[24] !== debug || $[25] !== media) {
|
|
1213
|
+
t11 = () => {
|
|
1214
|
+
if (media === null) {
|
|
1215
|
+
return _temp$6;
|
|
1216
|
+
}
|
|
1217
|
+
const onBufferingEvent = function onBufferingEvent(e) {
|
|
1218
|
+
if (e.currentTarget.networkState === e.currentTarget.NETWORK_LOADING) {
|
|
1219
|
+
debug("onBufferingEvent: NETWORK_LOADING");
|
|
1220
|
+
} else {
|
|
1221
|
+
if (e.currentTarget.readyState < e.currentTarget.HAVE_FUTURE_DATA) {
|
|
1222
|
+
debug("onBufferingEvent: HAVE_FUTURE_DATA");
|
|
1499
1223
|
}
|
|
1224
|
+
}
|
|
1225
|
+
setBuffering(getMediaIsBuffering(e.currentTarget));
|
|
1226
|
+
};
|
|
1227
|
+
let timeUpdated = false;
|
|
1228
|
+
const onPlay = function onPlay() {
|
|
1229
|
+
timeUpdated = false;
|
|
1230
|
+
debug("onPlay");
|
|
1231
|
+
setPlaying(true);
|
|
1232
|
+
setBuffering(false);
|
|
1233
|
+
};
|
|
1234
|
+
const onPlaying = function onPlaying() {
|
|
1235
|
+
timeUpdated = false;
|
|
1236
|
+
debug("onPlaying");
|
|
1237
|
+
setPlaying(true);
|
|
1238
|
+
setBuffering(false);
|
|
1239
|
+
};
|
|
1240
|
+
const onTimeUpdate = function onTimeUpdate(e_0) {
|
|
1241
|
+
if (!timeUpdated) {
|
|
1242
|
+
debug("onTimeUpdate");
|
|
1243
|
+
timeUpdated = true;
|
|
1244
|
+
}
|
|
1245
|
+
setPlaying(true);
|
|
1246
|
+
setBuffering(false);
|
|
1247
|
+
};
|
|
1248
|
+
const onPause = function onPause() {
|
|
1249
|
+
timeUpdated = false;
|
|
1250
|
+
debug("onPause");
|
|
1251
|
+
setPlaying(false);
|
|
1252
|
+
setBuffering(false);
|
|
1253
|
+
};
|
|
1254
|
+
const onEnded = function onEnded() {
|
|
1255
|
+
timeUpdated = false;
|
|
1256
|
+
debug("onEnded");
|
|
1257
|
+
setPlaying(false);
|
|
1258
|
+
setBuffering(false);
|
|
1259
|
+
};
|
|
1260
|
+
const onSuspend = function onSuspend(e_1) {
|
|
1261
|
+
timeUpdated = false;
|
|
1262
|
+
debug("onSuspend");
|
|
1263
|
+
setPlaying(getMediaIsPlaying(e_1.currentTarget));
|
|
1264
|
+
setBuffering(getMediaIsBuffering(e_1.currentTarget));
|
|
1265
|
+
};
|
|
1266
|
+
const onVolumeChange = function onVolumeChange(e_2) {
|
|
1267
|
+
debug("onVolumeChange");
|
|
1268
|
+
setMuted(getMediaIsMuted(e_2.currentTarget));
|
|
1269
|
+
};
|
|
1270
|
+
const onLoadChange = function onLoadChange(e_3) {
|
|
1271
|
+
debug("onLoadChange %s", e_3.type);
|
|
1272
|
+
setSrc(getMediaSrc(e_3.currentTarget));
|
|
1273
|
+
setBuffering(getMediaIsBuffering(e_3.currentTarget));
|
|
1274
|
+
};
|
|
1275
|
+
media.addEventListener("canplay", onLoadChange);
|
|
1276
|
+
media.addEventListener("loadstart", onLoadChange);
|
|
1277
|
+
media.addEventListener("loadeddata", onLoadChange);
|
|
1278
|
+
media.addEventListener("loadedmetadata", onLoadChange);
|
|
1279
|
+
media.addEventListener("waiting", onBufferingEvent);
|
|
1280
|
+
media.addEventListener("stalled", onBufferingEvent);
|
|
1281
|
+
media.addEventListener("timeupdate", onTimeUpdate);
|
|
1282
|
+
media.addEventListener("play", onPlay);
|
|
1283
|
+
media.addEventListener("playing", onPlaying);
|
|
1284
|
+
media.addEventListener("pause", onPause);
|
|
1285
|
+
media.addEventListener("suspend", onSuspend);
|
|
1286
|
+
media.addEventListener("ended", onEnded);
|
|
1287
|
+
media.addEventListener("volumechange", onVolumeChange);
|
|
1288
|
+
return () => {
|
|
1289
|
+
media.removeEventListener("canplay", onLoadChange);
|
|
1290
|
+
media.removeEventListener("loadstart", onLoadChange);
|
|
1291
|
+
media.removeEventListener("loadeddata", onLoadChange);
|
|
1292
|
+
media.removeEventListener("loadedmetadata", onLoadChange);
|
|
1293
|
+
media.removeEventListener("waiting", onBufferingEvent);
|
|
1294
|
+
media.removeEventListener("stalled", onBufferingEvent);
|
|
1295
|
+
media.removeEventListener("timeupdate", onTimeUpdate);
|
|
1296
|
+
media.removeEventListener("play", onPlay);
|
|
1297
|
+
media.removeEventListener("playing", onPlaying);
|
|
1298
|
+
media.removeEventListener("pause", onPause);
|
|
1299
|
+
media.removeEventListener("suspend", onSuspend);
|
|
1300
|
+
media.removeEventListener("ended", onEnded);
|
|
1301
|
+
media.removeEventListener("volumechange", onVolumeChange);
|
|
1302
|
+
};
|
|
1303
|
+
};
|
|
1304
|
+
$[24] = debug;
|
|
1305
|
+
$[25] = media;
|
|
1306
|
+
$[26] = t11;
|
|
1307
|
+
} else {
|
|
1308
|
+
t11 = $[26];
|
|
1309
|
+
}
|
|
1310
|
+
let t12;
|
|
1311
|
+
if ($[27] !== debug || $[28] !== media || $[29] !== src) {
|
|
1312
|
+
t12 = [media, debug, src];
|
|
1313
|
+
$[27] = debug;
|
|
1314
|
+
$[28] = media;
|
|
1315
|
+
$[29] = src;
|
|
1316
|
+
$[30] = t12;
|
|
1317
|
+
} else {
|
|
1318
|
+
t12 = $[30];
|
|
1319
|
+
}
|
|
1320
|
+
useEffect(t11, t12);
|
|
1321
|
+
let t13;
|
|
1322
|
+
if ($[31] !== buffering || $[32] !== muted || $[33] !== playing) {
|
|
1323
|
+
t13 = {
|
|
1324
|
+
playing,
|
|
1325
|
+
muted,
|
|
1326
|
+
buffering
|
|
1327
|
+
};
|
|
1328
|
+
$[31] = buffering;
|
|
1329
|
+
$[32] = muted;
|
|
1330
|
+
$[33] = playing;
|
|
1331
|
+
$[34] = t13;
|
|
1332
|
+
} else {
|
|
1333
|
+
t13 = $[34];
|
|
1334
|
+
}
|
|
1335
|
+
return t13;
|
|
1336
|
+
}
|
|
1337
|
+
function _temp$6() {}
|
|
1338
|
+
|
|
1339
|
+
function useMediaTimestampOffset(element, t0) {
|
|
1340
|
+
const $ = c(9);
|
|
1341
|
+
let t1;
|
|
1342
|
+
if ($[0] !== t0) {
|
|
1343
|
+
t1 = t0 === undefined ? {} : t0;
|
|
1344
|
+
$[0] = t0;
|
|
1345
|
+
$[1] = t1;
|
|
1346
|
+
} else {
|
|
1347
|
+
t1 = $[1];
|
|
1348
|
+
}
|
|
1349
|
+
const {
|
|
1350
|
+
attributeName: t2
|
|
1351
|
+
} = t1;
|
|
1352
|
+
const attributeName = t2 === undefined ? "data-ts-offset" : t2;
|
|
1353
|
+
let t3;
|
|
1354
|
+
if ($[2] !== attributeName || $[3] !== element) {
|
|
1355
|
+
t3 = () => getMediaTimestampOffset(element, attributeName);
|
|
1356
|
+
$[2] = attributeName;
|
|
1357
|
+
$[3] = element;
|
|
1358
|
+
$[4] = t3;
|
|
1359
|
+
} else {
|
|
1360
|
+
t3 = $[4];
|
|
1361
|
+
}
|
|
1362
|
+
const [timestampOffset, setTimestampOffset] = useState(t3);
|
|
1363
|
+
const observerRef = useRef(null);
|
|
1364
|
+
let t4;
|
|
1365
|
+
let t5;
|
|
1366
|
+
if ($[5] !== attributeName || $[6] !== element) {
|
|
1367
|
+
t4 = () => {
|
|
1368
|
+
if (element !== null) {
|
|
1369
|
+
observerRef.current = new MutationObserver(mutations => {
|
|
1370
|
+
mutations.forEach(t6 => {
|
|
1371
|
+
const {
|
|
1372
|
+
type: mutationType
|
|
1373
|
+
} = t6;
|
|
1374
|
+
if (mutationType === "attributes") {
|
|
1375
|
+
setTimestampOffset(getMediaTimestampOffset(element, attributeName));
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
});
|
|
1379
|
+
observerRef.current.observe(element, {
|
|
1380
|
+
attributes: true,
|
|
1381
|
+
attributeFilter: [attributeName]
|
|
1500
1382
|
});
|
|
1501
|
-
});
|
|
1502
|
-
observerRef.current.observe(element, {
|
|
1503
|
-
attributes: true,
|
|
1504
|
-
attributeFilter: [attributeName]
|
|
1505
|
-
});
|
|
1506
|
-
}
|
|
1507
|
-
return function () {
|
|
1508
|
-
if (observerRef.current !== null) {
|
|
1509
|
-
observerRef.current.disconnect();
|
|
1510
1383
|
}
|
|
1384
|
+
return () => {
|
|
1385
|
+
if (observerRef.current !== null) {
|
|
1386
|
+
observerRef.current.disconnect();
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1511
1389
|
};
|
|
1512
|
-
|
|
1390
|
+
t5 = [element, attributeName];
|
|
1391
|
+
$[5] = attributeName;
|
|
1392
|
+
$[6] = element;
|
|
1393
|
+
$[7] = t4;
|
|
1394
|
+
$[8] = t5;
|
|
1395
|
+
} else {
|
|
1396
|
+
t4 = $[7];
|
|
1397
|
+
t5 = $[8];
|
|
1398
|
+
}
|
|
1399
|
+
useEffect(t4, t5);
|
|
1513
1400
|
return timestampOffset;
|
|
1514
1401
|
}
|
|
1515
1402
|
|
|
1516
|
-
function useMediaCurrentTime(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
customOnUpdate = _ref$onUpdate === void 0 ? null : _ref$onUpdate;
|
|
1526
|
-
var _useState = useState(0),
|
|
1527
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1528
|
-
currentTime = _useState2[0],
|
|
1529
|
-
setCurrentTime = _useState2[1];
|
|
1530
|
-
var realCurrentTime = useRef(currentTime);
|
|
1531
|
-
var tsOffset = useMediaTimestampOffset(element);
|
|
1532
|
-
var finalId = id || element;
|
|
1533
|
-
var lastIdRef = useRef(finalId);
|
|
1534
|
-
var idChanged = lastIdRef.current !== finalId;
|
|
1535
|
-
var disabledRef = useRef(disabled);
|
|
1536
|
-
var disabledChanged = disabledRef.current !== disabled;
|
|
1537
|
-
if (idChanged || disabledChanged) {
|
|
1538
|
-
realCurrentTime.current = element !== null ? Math.max((element.currentTime || 0) - tsOffset, 0) : 0;
|
|
1539
|
-
lastIdRef.current = finalId;
|
|
1540
|
-
disabledRef.current = disabled;
|
|
1403
|
+
function useMediaCurrentTime(media, t0) {
|
|
1404
|
+
const $ = c(17);
|
|
1405
|
+
let t1;
|
|
1406
|
+
if ($[0] !== t0) {
|
|
1407
|
+
t1 = t0 === undefined ? {} : t0;
|
|
1408
|
+
$[0] = t0;
|
|
1409
|
+
$[1] = t1;
|
|
1410
|
+
} else {
|
|
1411
|
+
t1 = $[1];
|
|
1541
1412
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1413
|
+
const {
|
|
1414
|
+
id: t2,
|
|
1415
|
+
disabled: t3,
|
|
1416
|
+
updateInterval: t4,
|
|
1417
|
+
onUpdate: t5
|
|
1418
|
+
} = t1;
|
|
1419
|
+
const id = t2 === undefined ? null : t2;
|
|
1420
|
+
const disabled = t3 === undefined ? false : t3;
|
|
1421
|
+
const updateInterval = t4 === undefined ? 1000 : t4;
|
|
1422
|
+
const customOnUpdate = t5 === undefined ? null : t5;
|
|
1423
|
+
const tsOffset = useMediaTimestampOffset(media);
|
|
1424
|
+
let t6;
|
|
1425
|
+
if ($[2] !== media || $[3] !== tsOffset) {
|
|
1426
|
+
t6 = () => getMediaCurrentTime(media, tsOffset);
|
|
1427
|
+
$[2] = media;
|
|
1428
|
+
$[3] = tsOffset;
|
|
1429
|
+
$[4] = t6;
|
|
1430
|
+
} else {
|
|
1431
|
+
t6 = $[4];
|
|
1432
|
+
}
|
|
1433
|
+
const [currentTime, setCurrentTime] = useState(t6);
|
|
1434
|
+
const [currentDisabled, setCurrentDisabled] = useState(disabled);
|
|
1435
|
+
const finalId = id || media;
|
|
1436
|
+
const [identifier, setIdentifier] = useState(finalId);
|
|
1437
|
+
if (finalId !== identifier) {
|
|
1438
|
+
setCurrentTime(getMediaCurrentTime(media, tsOffset));
|
|
1439
|
+
setIdentifier(finalId);
|
|
1440
|
+
} else {
|
|
1441
|
+
if (disabled !== currentDisabled) {
|
|
1442
|
+
setCurrentTime(getMediaCurrentTime(media, tsOffset));
|
|
1443
|
+
setCurrentDisabled(disabled);
|
|
1570
1444
|
}
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1445
|
+
}
|
|
1446
|
+
let t7;
|
|
1447
|
+
if ($[5] !== customOnUpdate || $[6] !== media || $[7] !== tsOffset || $[8] !== updateInterval) {
|
|
1448
|
+
t7 = () => {
|
|
1449
|
+
if (media === null) {
|
|
1450
|
+
return _temp$5;
|
|
1575
1451
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1452
|
+
let lastTime = getMediaCurrentTime(media, tsOffset);
|
|
1453
|
+
const updateTime = function updateTime() {
|
|
1454
|
+
const newTime = getMediaCurrentTime(media, tsOffset);
|
|
1455
|
+
if (newTime !== lastTime) {
|
|
1456
|
+
lastTime = newTime;
|
|
1457
|
+
setCurrentTime(newTime);
|
|
1458
|
+
if (customOnUpdate !== null) {
|
|
1459
|
+
customOnUpdate(newTime);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
return newTime;
|
|
1463
|
+
};
|
|
1464
|
+
let timeout = null;
|
|
1465
|
+
function loop() {
|
|
1466
|
+
const duration = getMediaDuration(media, tsOffset);
|
|
1467
|
+
const time = updateTime();
|
|
1468
|
+
const remainingTime = Math.floor(((duration || 0) - time) * 1000);
|
|
1469
|
+
timeout = setTimeout(loop, Math.max(Math.min(updateInterval, remainingTime), updateInterval));
|
|
1578
1470
|
}
|
|
1471
|
+
timeout = setTimeout(loop, updateInterval);
|
|
1472
|
+
return () => {
|
|
1473
|
+
if (timeout !== null) {
|
|
1474
|
+
clearTimeout(timeout);
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1579
1477
|
};
|
|
1580
|
-
|
|
1581
|
-
|
|
1478
|
+
$[5] = customOnUpdate;
|
|
1479
|
+
$[6] = media;
|
|
1480
|
+
$[7] = tsOffset;
|
|
1481
|
+
$[8] = updateInterval;
|
|
1482
|
+
$[9] = t7;
|
|
1483
|
+
} else {
|
|
1484
|
+
t7 = $[9];
|
|
1485
|
+
}
|
|
1486
|
+
let t8;
|
|
1487
|
+
if ($[10] !== customOnUpdate || $[11] !== disabled || $[12] !== identifier || $[13] !== media || $[14] !== tsOffset || $[15] !== updateInterval) {
|
|
1488
|
+
t8 = [identifier, media, tsOffset, setCurrentTime, disabled, updateInterval, customOnUpdate];
|
|
1489
|
+
$[10] = customOnUpdate;
|
|
1490
|
+
$[11] = disabled;
|
|
1491
|
+
$[12] = identifier;
|
|
1492
|
+
$[13] = media;
|
|
1493
|
+
$[14] = tsOffset;
|
|
1494
|
+
$[15] = updateInterval;
|
|
1495
|
+
$[16] = t8;
|
|
1496
|
+
} else {
|
|
1497
|
+
t8 = $[16];
|
|
1498
|
+
}
|
|
1499
|
+
useEffect(t7, t8);
|
|
1500
|
+
return currentTime;
|
|
1582
1501
|
}
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1502
|
+
function _temp$5() {}
|
|
1503
|
+
|
|
1504
|
+
function useMediaDuration(media, t0) {
|
|
1505
|
+
const $ = c(12);
|
|
1506
|
+
let t1;
|
|
1507
|
+
if ($[0] !== t0) {
|
|
1508
|
+
t1 = t0 === undefined ? {} : t0;
|
|
1509
|
+
$[0] = t0;
|
|
1510
|
+
$[1] = t1;
|
|
1511
|
+
} else {
|
|
1512
|
+
t1 = $[1];
|
|
1513
|
+
}
|
|
1514
|
+
const {
|
|
1515
|
+
id: t2
|
|
1516
|
+
} = t1;
|
|
1517
|
+
const id = t2 === undefined ? null : t2;
|
|
1518
|
+
const tsOffset = useMediaTimestampOffset(media);
|
|
1519
|
+
let t3;
|
|
1520
|
+
if ($[2] !== media || $[3] !== tsOffset) {
|
|
1521
|
+
t3 = () => getMediaDuration(media, tsOffset);
|
|
1522
|
+
$[2] = media;
|
|
1523
|
+
$[3] = tsOffset;
|
|
1524
|
+
$[4] = t3;
|
|
1525
|
+
} else {
|
|
1526
|
+
t3 = $[4];
|
|
1527
|
+
}
|
|
1528
|
+
const [duration, setDuration] = useState(t3);
|
|
1529
|
+
const finalId = id || media;
|
|
1530
|
+
const [identifier, setIdentifier] = useState(finalId);
|
|
1531
|
+
if (finalId !== identifier) {
|
|
1532
|
+
setDuration(getMediaDuration(media, tsOffset));
|
|
1533
|
+
setIdentifier(finalId);
|
|
1534
|
+
} else {
|
|
1535
|
+
if (media === null && duration !== 0) {
|
|
1604
1536
|
setDuration(0);
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
var newDuration = Math.max((element.duration || 0) - tsOffset, 0);
|
|
1609
|
-
if (newDuration !== realDuration.current) {
|
|
1610
|
-
realDuration.current = newDuration;
|
|
1611
|
-
setDuration(newDuration);
|
|
1537
|
+
} else {
|
|
1538
|
+
if (duration === 0 && getMediaDuration(media, tsOffset) > 0) {
|
|
1539
|
+
setDuration(getMediaDuration(media, tsOffset));
|
|
1612
1540
|
}
|
|
1613
1541
|
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1542
|
+
}
|
|
1543
|
+
let t4;
|
|
1544
|
+
if ($[5] !== media || $[6] !== tsOffset) {
|
|
1545
|
+
t4 = () => {
|
|
1546
|
+
if (media === null) {
|
|
1547
|
+
return _temp$4;
|
|
1548
|
+
}
|
|
1549
|
+
const updateDuration = function updateDuration(e) {
|
|
1550
|
+
setDuration(getMediaDuration(e.currentTarget, tsOffset));
|
|
1551
|
+
};
|
|
1552
|
+
media.addEventListener("canplay", updateDuration);
|
|
1553
|
+
media.addEventListener("loadedmetadata", updateDuration);
|
|
1554
|
+
media.addEventListener("durationchange", updateDuration);
|
|
1555
|
+
return () => {
|
|
1556
|
+
media.removeEventListener("canplay", updateDuration);
|
|
1557
|
+
media.removeEventListener("loadedmetadata", updateDuration);
|
|
1558
|
+
media.removeEventListener("durationchange", updateDuration);
|
|
1559
|
+
};
|
|
1622
1560
|
};
|
|
1623
|
-
|
|
1624
|
-
|
|
1561
|
+
$[5] = media;
|
|
1562
|
+
$[6] = tsOffset;
|
|
1563
|
+
$[7] = t4;
|
|
1564
|
+
} else {
|
|
1565
|
+
t4 = $[7];
|
|
1566
|
+
}
|
|
1567
|
+
let t5;
|
|
1568
|
+
if ($[8] !== identifier || $[9] !== media || $[10] !== tsOffset) {
|
|
1569
|
+
t5 = [identifier, media, setDuration, tsOffset];
|
|
1570
|
+
$[8] = identifier;
|
|
1571
|
+
$[9] = media;
|
|
1572
|
+
$[10] = tsOffset;
|
|
1573
|
+
$[11] = t5;
|
|
1574
|
+
} else {
|
|
1575
|
+
t5 = $[11];
|
|
1576
|
+
}
|
|
1577
|
+
useEffect(t4, t5);
|
|
1578
|
+
return duration;
|
|
1625
1579
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1580
|
+
function _temp$4() {}
|
|
1581
|
+
|
|
1582
|
+
function useMediaLoad(element, t0) {
|
|
1583
|
+
const $ = c(7);
|
|
1584
|
+
let t1;
|
|
1585
|
+
if ($[0] !== t0) {
|
|
1586
|
+
t1 = t0 === undefined ? {} : t0;
|
|
1587
|
+
$[0] = t0;
|
|
1588
|
+
$[1] = t1;
|
|
1589
|
+
} else {
|
|
1590
|
+
t1 = $[1];
|
|
1591
|
+
}
|
|
1592
|
+
const {
|
|
1593
|
+
preload: t2,
|
|
1594
|
+
shouldLoad: t3
|
|
1595
|
+
} = t1;
|
|
1596
|
+
const preload = t2 === undefined ? "auto" : t2;
|
|
1597
|
+
const shouldLoad = t3 === undefined ? false : t3;
|
|
1598
|
+
const firstPreloadRef = useRef(preload);
|
|
1599
|
+
const firstShouldLoadRef = useRef(shouldLoad);
|
|
1600
|
+
const hasLoadedRef = useRef(preload !== "none" && preload !== "metadata" && shouldLoad);
|
|
1601
|
+
let t4;
|
|
1602
|
+
let t5;
|
|
1603
|
+
if ($[2] !== element || $[3] !== preload || $[4] !== shouldLoad) {
|
|
1604
|
+
t4 = () => {
|
|
1605
|
+
const canLoad = preload !== "none" && preload !== "metadata" && shouldLoad;
|
|
1606
|
+
const preloadHasChanged = firstPreloadRef.current !== preload;
|
|
1607
|
+
const shouldLoadHasChanged = firstShouldLoadRef.current !== shouldLoad;
|
|
1608
|
+
if (canLoad && (preloadHasChanged || shouldLoadHasChanged) && !hasLoadedRef.current && element !== null && typeof element.load !== "undefined") {
|
|
1609
|
+
hasLoadedRef.current = true;
|
|
1610
|
+
element.load();
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
t5 = [element, shouldLoad, preload];
|
|
1614
|
+
$[2] = element;
|
|
1615
|
+
$[3] = preload;
|
|
1616
|
+
$[4] = shouldLoad;
|
|
1617
|
+
$[5] = t4;
|
|
1618
|
+
$[6] = t5;
|
|
1619
|
+
} else {
|
|
1620
|
+
t4 = $[5];
|
|
1621
|
+
t5 = $[6];
|
|
1622
|
+
}
|
|
1623
|
+
useEffect(t4, t5);
|
|
1645
1624
|
}
|
|
1646
1625
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1626
|
+
function useMediaProgress(t0, t1) {
|
|
1627
|
+
const $ = c(28);
|
|
1628
|
+
const media = t0 === undefined ? null : t0;
|
|
1629
|
+
const options = t1 === undefined ? null : t1;
|
|
1630
|
+
let t2;
|
|
1631
|
+
if ($[0] !== options) {
|
|
1632
|
+
t2 = options || {};
|
|
1633
|
+
$[0] = options;
|
|
1634
|
+
$[1] = t2;
|
|
1635
|
+
} else {
|
|
1636
|
+
t2 = $[1];
|
|
1637
|
+
}
|
|
1638
|
+
let props;
|
|
1639
|
+
let t3;
|
|
1640
|
+
if ($[2] !== t2) {
|
|
1641
|
+
({
|
|
1642
|
+
disabled: t3,
|
|
1643
|
+
...props
|
|
1644
|
+
} = t2);
|
|
1645
|
+
$[2] = t2;
|
|
1646
|
+
$[3] = props;
|
|
1647
|
+
$[4] = t3;
|
|
1648
|
+
} else {
|
|
1649
|
+
props = $[3];
|
|
1650
|
+
t3 = $[4];
|
|
1651
|
+
}
|
|
1652
|
+
const disabled = t3 === undefined ? false : t3;
|
|
1653
|
+
let t4;
|
|
1654
|
+
if ($[5] !== disabled || $[6] !== media) {
|
|
1655
|
+
t4 = () => !disabled && getMediaIsPlaying(media);
|
|
1656
|
+
$[5] = disabled;
|
|
1657
|
+
$[6] = media;
|
|
1658
|
+
$[7] = t4;
|
|
1659
|
+
} else {
|
|
1660
|
+
t4 = $[7];
|
|
1661
|
+
}
|
|
1662
|
+
const [playing, setPlaying] = useState(t4);
|
|
1663
|
+
const t5 = disabled || !playing;
|
|
1664
|
+
let t6;
|
|
1665
|
+
if ($[8] !== props || $[9] !== t5) {
|
|
1666
|
+
t6 = {
|
|
1667
|
+
disabled: t5,
|
|
1668
|
+
...props
|
|
1669
|
+
};
|
|
1670
|
+
$[8] = props;
|
|
1671
|
+
$[9] = t5;
|
|
1672
|
+
$[10] = t6;
|
|
1673
|
+
} else {
|
|
1674
|
+
t6 = $[10];
|
|
1675
|
+
}
|
|
1676
|
+
const duration = useMediaDuration(media, t6);
|
|
1677
|
+
const [progressMedia, setProgressMedia] = useState(media);
|
|
1678
|
+
const [progress, setProgress] = useState(0);
|
|
1679
|
+
const [updateTime, setUpdateTime] = useState(_temp$3);
|
|
1680
|
+
if (media !== progressMedia) {
|
|
1681
|
+
const newProgress = media !== null && (media?.currentTime || 0) > 0 && (media?.duration || 0) > 0 ? media.currentTime / media.duration : 0;
|
|
1682
|
+
setUpdateTime(Date.now() / 1000);
|
|
1671
1683
|
setProgress(newProgress);
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
media.addEventListener('stalled', onPause);
|
|
1710
|
-
media.addEventListener('seeking', onPause);
|
|
1711
|
-
media.addEventListener('suspend', onUpdate);
|
|
1712
|
-
// if (media.paused) {
|
|
1713
|
-
// onPause();
|
|
1714
|
-
// } else {
|
|
1715
|
-
// onResume();
|
|
1716
|
-
// }
|
|
1717
|
-
return function () {
|
|
1718
|
-
media.removeEventListener('play', onResume);
|
|
1719
|
-
media.removeEventListener('seeked', onResume);
|
|
1720
|
-
media.removeEventListener('playing', onResume);
|
|
1721
|
-
// media.removeEventListener('timeupdate', onResume);
|
|
1722
|
-
media.removeEventListener('pause', onPause);
|
|
1723
|
-
media.removeEventListener('ended', onPause);
|
|
1724
|
-
media.removeEventListener('waiting', onPause);
|
|
1725
|
-
media.removeEventListener('stalled', onPause);
|
|
1726
|
-
media.removeEventListener('seeking', onPause);
|
|
1727
|
-
media.removeEventListener('suspend', onUpdate);
|
|
1684
|
+
setPlaying(getMediaIsPlaying(media));
|
|
1685
|
+
setProgressMedia(media);
|
|
1686
|
+
}
|
|
1687
|
+
let t7;
|
|
1688
|
+
if ($[11] !== media) {
|
|
1689
|
+
t7 = () => {
|
|
1690
|
+
if (media === null) {
|
|
1691
|
+
return _temp2$1;
|
|
1692
|
+
}
|
|
1693
|
+
const onUpdate = function onUpdate(e) {
|
|
1694
|
+
setPlaying(getMediaIsPlaying(e.currentTarget));
|
|
1695
|
+
const newProgress_0 = e.currentTarget.currentTime / e.currentTarget.duration;
|
|
1696
|
+
startTransition(() => {
|
|
1697
|
+
setUpdateTime(Date.now() / 1000);
|
|
1698
|
+
setProgress(newProgress_0);
|
|
1699
|
+
});
|
|
1700
|
+
};
|
|
1701
|
+
media.addEventListener("play", onUpdate);
|
|
1702
|
+
media.addEventListener("playing", onUpdate);
|
|
1703
|
+
media.addEventListener("seeked", onUpdate);
|
|
1704
|
+
media.addEventListener("pause", onUpdate);
|
|
1705
|
+
media.addEventListener("ended", onUpdate);
|
|
1706
|
+
media.addEventListener("waiting", onUpdate);
|
|
1707
|
+
media.addEventListener("stalled", onUpdate);
|
|
1708
|
+
media.addEventListener("seeking", onUpdate);
|
|
1709
|
+
media.addEventListener("suspend", onUpdate);
|
|
1710
|
+
return () => {
|
|
1711
|
+
media.removeEventListener("play", onUpdate);
|
|
1712
|
+
media.removeEventListener("playing", onUpdate);
|
|
1713
|
+
media.removeEventListener("seeked", onUpdate);
|
|
1714
|
+
media.removeEventListener("pause", onUpdate);
|
|
1715
|
+
media.removeEventListener("ended", onUpdate);
|
|
1716
|
+
media.removeEventListener("waiting", onUpdate);
|
|
1717
|
+
media.removeEventListener("stalled", onUpdate);
|
|
1718
|
+
media.removeEventListener("seeking", onUpdate);
|
|
1719
|
+
media.removeEventListener("suspend", onUpdate);
|
|
1720
|
+
};
|
|
1728
1721
|
};
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1722
|
+
$[11] = media;
|
|
1723
|
+
$[12] = t7;
|
|
1724
|
+
} else {
|
|
1725
|
+
t7 = $[12];
|
|
1726
|
+
}
|
|
1727
|
+
let t8;
|
|
1728
|
+
if ($[13] !== media || $[14] !== playing) {
|
|
1729
|
+
t8 = [media, setPlaying, playing];
|
|
1730
|
+
$[13] = media;
|
|
1731
|
+
$[14] = playing;
|
|
1732
|
+
$[15] = t8;
|
|
1733
|
+
} else {
|
|
1734
|
+
t8 = $[15];
|
|
1735
|
+
}
|
|
1736
|
+
useEffect(t7, t8);
|
|
1737
|
+
let t9;
|
|
1738
|
+
if ($[16] !== disabled || $[17] !== duration || $[18] !== media || $[19] !== playing || $[20] !== progress || $[21] !== updateTime) {
|
|
1739
|
+
t9 = () => {
|
|
1740
|
+
if (media === null || !playing || disabled) {
|
|
1741
|
+
return _temp3$1;
|
|
1739
1742
|
}
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1743
|
+
let handle;
|
|
1744
|
+
let canceled = false;
|
|
1745
|
+
let currentProgress = progress;
|
|
1746
|
+
let currentUpdateTime = updateTime;
|
|
1747
|
+
function tick() {
|
|
1748
|
+
if (canceled) {
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
const newTime = Date.now() / 1000;
|
|
1752
|
+
const elapsed = newTime - currentUpdateTime;
|
|
1753
|
+
const step = elapsed / duration;
|
|
1754
|
+
const newProgress_1 = currentProgress < 0.1 ? media.currentTime / media.duration : currentProgress + step;
|
|
1755
|
+
startTransition(() => {
|
|
1756
|
+
setUpdateTime(Date.now() / 1000);
|
|
1757
|
+
setProgress(newProgress_1);
|
|
1758
|
+
});
|
|
1759
|
+
currentUpdateTime = newTime;
|
|
1760
|
+
currentProgress = newProgress_1;
|
|
1761
|
+
handle = raf(tick);
|
|
1762
|
+
}
|
|
1763
|
+
tick();
|
|
1764
|
+
return () => {
|
|
1765
|
+
canceled = true;
|
|
1766
|
+
raf.cancel(handle);
|
|
1767
|
+
};
|
|
1751
1768
|
};
|
|
1752
|
-
|
|
1753
|
-
|
|
1769
|
+
$[16] = disabled;
|
|
1770
|
+
$[17] = duration;
|
|
1771
|
+
$[18] = media;
|
|
1772
|
+
$[19] = playing;
|
|
1773
|
+
$[20] = progress;
|
|
1774
|
+
$[21] = updateTime;
|
|
1775
|
+
$[22] = t9;
|
|
1776
|
+
} else {
|
|
1777
|
+
t9 = $[22];
|
|
1778
|
+
}
|
|
1779
|
+
let t10;
|
|
1780
|
+
if ($[23] !== disabled || $[24] !== duration || $[25] !== media || $[26] !== playing) {
|
|
1781
|
+
t10 = [media, playing, disabled, duration, setProgress];
|
|
1782
|
+
$[23] = disabled;
|
|
1783
|
+
$[24] = duration;
|
|
1784
|
+
$[25] = media;
|
|
1785
|
+
$[26] = playing;
|
|
1786
|
+
$[27] = t10;
|
|
1787
|
+
} else {
|
|
1788
|
+
t10 = $[27];
|
|
1789
|
+
}
|
|
1790
|
+
useEffect(t9, t10);
|
|
1791
|
+
return progress;
|
|
1792
|
+
}
|
|
1793
|
+
function _temp3$1() {}
|
|
1794
|
+
function _temp2$1() {}
|
|
1795
|
+
function _temp$3() {
|
|
1796
|
+
return Date.now() / 1000;
|
|
1754
1797
|
}
|
|
1755
1798
|
|
|
1756
|
-
function useMediaReady(
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1799
|
+
function useMediaReady(media, t0) {
|
|
1800
|
+
const $ = c(11);
|
|
1801
|
+
let t1;
|
|
1802
|
+
if ($[0] !== t0) {
|
|
1803
|
+
t1 = t0 === undefined ? {} : t0;
|
|
1804
|
+
$[0] = t0;
|
|
1805
|
+
$[1] = t1;
|
|
1806
|
+
} else {
|
|
1807
|
+
t1 = $[1];
|
|
1808
|
+
}
|
|
1809
|
+
const {
|
|
1810
|
+
id: t2
|
|
1811
|
+
} = t1;
|
|
1812
|
+
const id = t2 === undefined ? null : t2;
|
|
1813
|
+
let t3;
|
|
1814
|
+
if ($[2] !== media) {
|
|
1815
|
+
t3 = () => media !== null && media.readyState > 0;
|
|
1816
|
+
$[2] = media;
|
|
1817
|
+
$[3] = t3;
|
|
1818
|
+
} else {
|
|
1819
|
+
t3 = $[3];
|
|
1820
|
+
}
|
|
1821
|
+
const [ready, setReady] = useState(t3);
|
|
1822
|
+
const finalId = id || media;
|
|
1823
|
+
const [identifier, setIdentifier] = useState(finalId);
|
|
1824
|
+
if (finalId !== identifier) {
|
|
1825
|
+
setReady(media !== null && media.readyState > 0);
|
|
1826
|
+
setIdentifier(finalId);
|
|
1827
|
+
} else {
|
|
1828
|
+
if (media === null && ready) {
|
|
1829
|
+
setReady(false);
|
|
1830
|
+
} else {
|
|
1831
|
+
if (!ready && media !== null && media.readyState > 0) {
|
|
1778
1832
|
setReady(true);
|
|
1779
|
-
currentReady = true;
|
|
1780
|
-
} else if (ready && element !== null && element.readyState === 0) {
|
|
1781
|
-
setReady(false);
|
|
1782
|
-
currentReady = false;
|
|
1783
1833
|
}
|
|
1784
|
-
realReady.current = currentReady;
|
|
1785
|
-
return currentReady;
|
|
1786
|
-
}
|
|
1787
|
-
var currentReady = updateReady();
|
|
1788
|
-
if (currentReady) {
|
|
1789
|
-
return function () {};
|
|
1790
1834
|
}
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1835
|
+
}
|
|
1836
|
+
let t4;
|
|
1837
|
+
if ($[4] !== media || $[5] !== ready) {
|
|
1838
|
+
t4 = () => {
|
|
1839
|
+
if (media === null || ready) {
|
|
1840
|
+
return _temp$2;
|
|
1841
|
+
}
|
|
1842
|
+
const updateReady = function updateReady() {
|
|
1843
|
+
setReady(media.readyState > 0);
|
|
1844
|
+
};
|
|
1845
|
+
media.addEventListener("loadstart", updateReady);
|
|
1846
|
+
media.addEventListener("loadeddata", updateReady);
|
|
1847
|
+
media.addEventListener("loadedmetadata", updateReady);
|
|
1848
|
+
media.addEventListener("canplay", updateReady);
|
|
1849
|
+
media.addEventListener("canplaythrough", updateReady);
|
|
1850
|
+
return () => {
|
|
1851
|
+
media.removeEventListener("loadstart", updateReady);
|
|
1852
|
+
media.removeEventListener("loadeddata", updateReady);
|
|
1853
|
+
media.removeEventListener("loadedmetadata", updateReady);
|
|
1854
|
+
media.removeEventListener("canplay", updateReady);
|
|
1855
|
+
media.removeEventListener("canplaythrough", updateReady);
|
|
1856
|
+
};
|
|
1802
1857
|
};
|
|
1803
|
-
|
|
1804
|
-
|
|
1858
|
+
$[4] = media;
|
|
1859
|
+
$[5] = ready;
|
|
1860
|
+
$[6] = t4;
|
|
1861
|
+
} else {
|
|
1862
|
+
t4 = $[6];
|
|
1863
|
+
}
|
|
1864
|
+
let t5;
|
|
1865
|
+
if ($[7] !== id || $[8] !== media || $[9] !== ready) {
|
|
1866
|
+
t5 = [media, id, ready];
|
|
1867
|
+
$[7] = id;
|
|
1868
|
+
$[8] = media;
|
|
1869
|
+
$[9] = ready;
|
|
1870
|
+
$[10] = t5;
|
|
1871
|
+
} else {
|
|
1872
|
+
t5 = $[10];
|
|
1873
|
+
}
|
|
1874
|
+
useEffect(t4, t5);
|
|
1875
|
+
return ready;
|
|
1805
1876
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1877
|
+
function _temp$2() {}
|
|
1878
|
+
|
|
1879
|
+
const useMediasParser = () => {
|
|
1880
|
+
const $ = c(11);
|
|
1881
|
+
const screensManager = useScreensManager();
|
|
1882
|
+
const fieldsManager = useFieldsManager();
|
|
1883
|
+
let t0;
|
|
1884
|
+
if ($[0] !== fieldsManager || $[1] !== screensManager) {
|
|
1885
|
+
t0 = new MediasParser({
|
|
1886
|
+
screensManager,
|
|
1887
|
+
fieldsManager
|
|
1816
1888
|
});
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1889
|
+
$[0] = fieldsManager;
|
|
1890
|
+
$[1] = screensManager;
|
|
1891
|
+
$[2] = t0;
|
|
1892
|
+
} else {
|
|
1893
|
+
t0 = $[2];
|
|
1894
|
+
}
|
|
1895
|
+
const parser = t0;
|
|
1896
|
+
let t1;
|
|
1897
|
+
if ($[3] !== parser) {
|
|
1898
|
+
t1 = story => parser.toPath(story);
|
|
1899
|
+
$[3] = parser;
|
|
1900
|
+
$[4] = t1;
|
|
1901
|
+
} else {
|
|
1902
|
+
t1 = $[4];
|
|
1903
|
+
}
|
|
1904
|
+
const toPath = t1;
|
|
1905
|
+
let t2;
|
|
1906
|
+
if ($[5] !== parser) {
|
|
1907
|
+
t2 = story_0 => parser.fromPath(story_0);
|
|
1908
|
+
$[5] = parser;
|
|
1909
|
+
$[6] = t2;
|
|
1910
|
+
} else {
|
|
1911
|
+
t2 = $[6];
|
|
1912
|
+
}
|
|
1913
|
+
const fromPath = t2;
|
|
1914
|
+
let t3;
|
|
1915
|
+
if ($[7] !== fromPath || $[8] !== parser || $[9] !== toPath) {
|
|
1916
|
+
t3 = {
|
|
1917
|
+
toPath,
|
|
1918
|
+
fromPath,
|
|
1919
|
+
parser
|
|
1920
|
+
};
|
|
1921
|
+
$[7] = fromPath;
|
|
1922
|
+
$[8] = parser;
|
|
1923
|
+
$[9] = toPath;
|
|
1924
|
+
$[10] = t3;
|
|
1925
|
+
} else {
|
|
1926
|
+
t3 = $[10];
|
|
1927
|
+
}
|
|
1928
|
+
return t3;
|
|
1829
1929
|
};
|
|
1830
1930
|
|
|
1831
|
-
function
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
var audioCtx = new AudioContext();
|
|
1908
|
-
return audioCtx.decodeAudioData(arrayBuffer);
|
|
1909
|
-
}).then(function (buffer) {
|
|
1910
|
-
var channelsCount = buffer.numberOfChannels;
|
|
1911
|
-
if (channelsCount > 0) {
|
|
1912
|
-
var leftChannelData = buffer.getChannelData(0);
|
|
1913
|
-
setAudioLevels(leftChannelData.reduce(function (newArray, level) {
|
|
1914
|
-
// eslint-disable-next-line no-param-reassign
|
|
1915
|
-
newArray[newArray.length] = Math.abs(level);
|
|
1916
|
-
return newArray;
|
|
1917
|
-
}, []));
|
|
1931
|
+
function useMediaWaveform(media, t0) {
|
|
1932
|
+
const $ = c(15);
|
|
1933
|
+
let t1;
|
|
1934
|
+
if ($[0] !== t0) {
|
|
1935
|
+
t1 = t0 === undefined ? {} : t0;
|
|
1936
|
+
$[0] = t0;
|
|
1937
|
+
$[1] = t1;
|
|
1938
|
+
} else {
|
|
1939
|
+
t1 = $[1];
|
|
1940
|
+
}
|
|
1941
|
+
const {
|
|
1942
|
+
fake: t2,
|
|
1943
|
+
reduceBufferFactor: t3
|
|
1944
|
+
} = t1;
|
|
1945
|
+
const fake = t2 === undefined ? false : t2;
|
|
1946
|
+
const reduceBufferFactor = t3 === undefined ? 100 : t3;
|
|
1947
|
+
let t4;
|
|
1948
|
+
if ($[2] !== media) {
|
|
1949
|
+
t4 = media || {};
|
|
1950
|
+
$[2] = media;
|
|
1951
|
+
$[3] = t4;
|
|
1952
|
+
} else {
|
|
1953
|
+
t4 = $[3];
|
|
1954
|
+
}
|
|
1955
|
+
const {
|
|
1956
|
+
url: t5,
|
|
1957
|
+
metadata: t6
|
|
1958
|
+
} = t4;
|
|
1959
|
+
const url = t5 === undefined ? null : t5;
|
|
1960
|
+
const metadata = t6 === undefined ? null : t6;
|
|
1961
|
+
let t7;
|
|
1962
|
+
if ($[4] !== metadata) {
|
|
1963
|
+
t7 = metadata || {};
|
|
1964
|
+
$[4] = metadata;
|
|
1965
|
+
$[5] = t7;
|
|
1966
|
+
} else {
|
|
1967
|
+
t7 = $[5];
|
|
1968
|
+
}
|
|
1969
|
+
const {
|
|
1970
|
+
waveform: t8
|
|
1971
|
+
} = t7;
|
|
1972
|
+
const waveform = t8 === undefined ? null : t8;
|
|
1973
|
+
const [audioLevels, setAudioLevels] = useState(null);
|
|
1974
|
+
let t9;
|
|
1975
|
+
if ($[6] !== fake || $[7] !== url || $[8] !== waveform) {
|
|
1976
|
+
t9 = () => {
|
|
1977
|
+
let canceled = false;
|
|
1978
|
+
const AudioContext = typeof window !== "undefined" ? window.AudioContext || window.webkitAudioContext : null;
|
|
1979
|
+
if (waveform !== null) {
|
|
1980
|
+
setAudioLevels(waveform.map(_temp$1));
|
|
1981
|
+
} else {
|
|
1982
|
+
if (url !== null && fake) {
|
|
1983
|
+
setAudioLevels([...new Array(1000)].map(_temp2));
|
|
1984
|
+
} else {
|
|
1985
|
+
if (url !== null && AudioContext !== null) {
|
|
1986
|
+
fetch(url, {
|
|
1987
|
+
mode: "cors"
|
|
1988
|
+
}).then(response => {
|
|
1989
|
+
if (canceled) {
|
|
1990
|
+
throw new Error("Audio loading canceled");
|
|
1991
|
+
}
|
|
1992
|
+
return response.arrayBuffer();
|
|
1993
|
+
}).then(arrayBuffer => {
|
|
1994
|
+
if (canceled) {
|
|
1995
|
+
throw new Error("Audio loading canceled");
|
|
1996
|
+
}
|
|
1997
|
+
const audioCtx = new AudioContext();
|
|
1998
|
+
return audioCtx.decodeAudioData(arrayBuffer);
|
|
1999
|
+
}).then(buffer => {
|
|
2000
|
+
const channelsCount = buffer.numberOfChannels;
|
|
2001
|
+
if (channelsCount > 0) {
|
|
2002
|
+
const leftChannelData = buffer.getChannelData(0);
|
|
2003
|
+
setAudioLevels(leftChannelData.reduce(_temp3, []));
|
|
2004
|
+
}
|
|
2005
|
+
}).catch(_temp4);
|
|
2006
|
+
}
|
|
1918
2007
|
}
|
|
1919
|
-
})["catch"](function (e) {
|
|
1920
|
-
throw e;
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
return function () {
|
|
1924
|
-
if (url === null) {
|
|
1925
|
-
canceled = true;
|
|
1926
2008
|
}
|
|
2009
|
+
return () => {
|
|
2010
|
+
if (url === null) {
|
|
2011
|
+
canceled = true;
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
1927
2014
|
};
|
|
1928
|
-
|
|
2015
|
+
$[6] = fake;
|
|
2016
|
+
$[7] = url;
|
|
2017
|
+
$[8] = waveform;
|
|
2018
|
+
$[9] = t9;
|
|
2019
|
+
} else {
|
|
2020
|
+
t9 = $[9];
|
|
2021
|
+
}
|
|
2022
|
+
let t10;
|
|
2023
|
+
if ($[10] !== fake || $[11] !== reduceBufferFactor || $[12] !== url || $[13] !== waveform) {
|
|
2024
|
+
t10 = [url, waveform, setAudioLevels, reduceBufferFactor, fake];
|
|
2025
|
+
$[10] = fake;
|
|
2026
|
+
$[11] = reduceBufferFactor;
|
|
2027
|
+
$[12] = url;
|
|
2028
|
+
$[13] = waveform;
|
|
2029
|
+
$[14] = t10;
|
|
2030
|
+
} else {
|
|
2031
|
+
t10 = $[14];
|
|
2032
|
+
}
|
|
2033
|
+
useEffect(t9, t10);
|
|
1929
2034
|
return audioLevels;
|
|
1930
2035
|
}
|
|
2036
|
+
function _temp4(e) {
|
|
2037
|
+
throw e;
|
|
2038
|
+
}
|
|
2039
|
+
function _temp3(newArray, level) {
|
|
2040
|
+
newArray[newArray.length] = Math.abs(level);
|
|
2041
|
+
return newArray;
|
|
2042
|
+
}
|
|
2043
|
+
function _temp2() {
|
|
2044
|
+
return Math.random();
|
|
2045
|
+
}
|
|
2046
|
+
function _temp$1(it) {
|
|
2047
|
+
return (it + 128) / 256;
|
|
2048
|
+
}
|
|
1931
2049
|
|
|
1932
2050
|
// const debug = createDebug('core:useParsedStory');
|
|
1933
2051
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
return new StoryParser({
|
|
1950
|
-
screensManager: screensManager,
|
|
1951
|
-
fieldsManager: fieldsManager,
|
|
1952
|
-
fieldsPattern: screensManager.getFieldsPattern()
|
|
1953
|
-
});
|
|
1954
|
-
}, [screensManager, fieldsManager]);
|
|
1955
|
-
var newStory = useMemo(function () {
|
|
2052
|
+
const useParsedStory = (story, {
|
|
2053
|
+
disabled = false,
|
|
2054
|
+
withTheme = true,
|
|
2055
|
+
withMedias = true,
|
|
2056
|
+
withFonts = true,
|
|
2057
|
+
withMigrations = true
|
|
2058
|
+
} = {}) => {
|
|
2059
|
+
const screensManager = useScreensManager();
|
|
2060
|
+
const fieldsManager = useFieldsManager();
|
|
2061
|
+
const [parser] = useState(() => new StoryParser({
|
|
2062
|
+
screensManager,
|
|
2063
|
+
fieldsManager,
|
|
2064
|
+
fieldsPattern: screensManager.getFieldsPattern()
|
|
2065
|
+
}));
|
|
2066
|
+
const newStory = useMemo(() => {
|
|
1956
2067
|
if (disabled) {
|
|
1957
2068
|
return story;
|
|
1958
2069
|
}
|
|
1959
2070
|
return parser.parse(story, {
|
|
1960
|
-
withMedias
|
|
1961
|
-
withTheme
|
|
1962
|
-
withFonts
|
|
1963
|
-
withMigrations
|
|
2071
|
+
withMedias,
|
|
2072
|
+
withTheme,
|
|
2073
|
+
withFonts,
|
|
2074
|
+
withMigrations
|
|
1964
2075
|
});
|
|
1965
2076
|
}, [parser, disabled, withMedias, withTheme, withFonts, story]);
|
|
1966
2077
|
return newStory;
|
|
1967
2078
|
};
|
|
1968
2079
|
|
|
1969
2080
|
function usePlaceholderStyle(selector, placeholderStyle) {
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
return !isEmpty(value) ?
|
|
2081
|
+
const styles = placeholderStyle !== null ? Object.keys(placeholderStyle).reduce((styles, key) => {
|
|
2082
|
+
const value = placeholderStyle[key];
|
|
2083
|
+
return !isEmpty(value) ? {
|
|
2084
|
+
...styles,
|
|
2085
|
+
[key.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()]: value
|
|
2086
|
+
} : styles;
|
|
1973
2087
|
}, {}) : null;
|
|
1974
|
-
return styles !== null && Object.keys(styles).length > 0 ?
|
|
1975
|
-
|
|
1976
|
-
|
|
2088
|
+
return styles !== null && Object.keys(styles).length > 0 ? `
|
|
2089
|
+
${selector}::placeholder {
|
|
2090
|
+
${Object.keys(styles).map(key => `${key}: ${styles[key]};`).join('\n')}
|
|
2091
|
+
}
|
|
2092
|
+
` : null;
|
|
1977
2093
|
}
|
|
1978
2094
|
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
onStep
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2095
|
+
const defaultSteps = [0.1, 0.25, 0.5, 0.75, 0.9];
|
|
2096
|
+
function useProgressSteps(t0) {
|
|
2097
|
+
const $ = c(8);
|
|
2098
|
+
const {
|
|
2099
|
+
disabled: t1,
|
|
2100
|
+
currentTime,
|
|
2101
|
+
duration,
|
|
2102
|
+
onStep: t2,
|
|
2103
|
+
steps: t3
|
|
2104
|
+
} = t0;
|
|
2105
|
+
const disabled = t1 === undefined ? false : t1;
|
|
2106
|
+
const onStep = t2 === undefined ? null : t2;
|
|
2107
|
+
const steps = t3 === undefined ? defaultSteps : t3;
|
|
2108
|
+
let t4;
|
|
2109
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2110
|
+
t4 = {};
|
|
2111
|
+
$[0] = t4;
|
|
2112
|
+
} else {
|
|
2113
|
+
t4 = $[0];
|
|
2114
|
+
}
|
|
2115
|
+
const progressStepsReachedRef = useRef(t4);
|
|
2116
|
+
let t5;
|
|
2117
|
+
let t6;
|
|
2118
|
+
if ($[1] !== currentTime || $[2] !== disabled || $[3] !== duration || $[4] !== onStep || $[5] !== steps) {
|
|
2119
|
+
t5 = () => {
|
|
2120
|
+
if (duration === 0 || disabled) {
|
|
2121
|
+
return;
|
|
2005
2122
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2123
|
+
const progress = currentTime / duration;
|
|
2124
|
+
const currentSteps = progressStepsReachedRef.current;
|
|
2125
|
+
const stepsToTrack = steps.filter(step => progress > step && typeof currentSteps[step] === "undefined");
|
|
2126
|
+
stepsToTrack.forEach(step_0 => {
|
|
2127
|
+
if (onStep !== null) {
|
|
2128
|
+
onStep(step_0, {
|
|
2129
|
+
duration,
|
|
2130
|
+
currentTime
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
currentSteps[step_0] = true;
|
|
2134
|
+
});
|
|
2135
|
+
};
|
|
2136
|
+
t6 = [duration, currentTime, disabled, onStep, steps];
|
|
2137
|
+
$[1] = currentTime;
|
|
2138
|
+
$[2] = disabled;
|
|
2139
|
+
$[3] = duration;
|
|
2140
|
+
$[4] = onStep;
|
|
2141
|
+
$[5] = steps;
|
|
2142
|
+
$[6] = t5;
|
|
2143
|
+
$[7] = t6;
|
|
2144
|
+
} else {
|
|
2145
|
+
t5 = $[6];
|
|
2146
|
+
t6 = $[7];
|
|
2147
|
+
}
|
|
2148
|
+
useEffect(t5, t6);
|
|
2009
2149
|
}
|
|
2010
2150
|
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2151
|
+
const useDevicePixelRatio = () => {
|
|
2152
|
+
const $ = c(2);
|
|
2153
|
+
const [pixelRatio, setPixelRatio] = useState(1);
|
|
2154
|
+
let t0;
|
|
2155
|
+
let t1;
|
|
2156
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2157
|
+
t0 = () => {
|
|
2158
|
+
setPixelRatio(typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1);
|
|
2159
|
+
const media = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
2160
|
+
const onChange = function onChange() {
|
|
2161
|
+
setPixelRatio(window.devicePixelRatio || 1);
|
|
2162
|
+
};
|
|
2163
|
+
media.addEventListener("change", onChange, {
|
|
2164
|
+
once: true
|
|
2165
|
+
});
|
|
2166
|
+
return () => {
|
|
2167
|
+
media.removeEventListener("change", onChange);
|
|
2168
|
+
};
|
|
2169
|
+
};
|
|
2170
|
+
t1 = [setPixelRatio];
|
|
2171
|
+
$[0] = t0;
|
|
2172
|
+
$[1] = t1;
|
|
2173
|
+
} else {
|
|
2174
|
+
t0 = $[0];
|
|
2175
|
+
t1 = $[1];
|
|
2176
|
+
}
|
|
2177
|
+
useEffect(t0, t1);
|
|
2020
2178
|
return pixelRatio;
|
|
2021
2179
|
};
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
height
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2180
|
+
const useScreenSize = t0 => {
|
|
2181
|
+
const $ = c(23);
|
|
2182
|
+
const {
|
|
2183
|
+
width: t1,
|
|
2184
|
+
height: t2,
|
|
2185
|
+
landscape: t3,
|
|
2186
|
+
menuOverScreen: t4,
|
|
2187
|
+
screens: t5,
|
|
2188
|
+
mediaType: t6,
|
|
2189
|
+
media: t7,
|
|
2190
|
+
scale: t8
|
|
2191
|
+
} = t0;
|
|
2192
|
+
const width = t1 === undefined ? null : t1;
|
|
2193
|
+
const height = t2 === undefined ? null : t2;
|
|
2194
|
+
const landscape = t3 === undefined ? false : t3;
|
|
2195
|
+
const menuOverScreen = t4 === undefined ? false : t4;
|
|
2196
|
+
const initialScreens = t5 === undefined ? null : t5;
|
|
2197
|
+
const mediaType = t6 === undefined ? "screen" : t6;
|
|
2198
|
+
const providedMedia = t7 === undefined ? null : t7;
|
|
2199
|
+
const scale = t8 === undefined ? null : t8;
|
|
2200
|
+
const devicePixelRatio = useDevicePixelRatio();
|
|
2201
|
+
let t10;
|
|
2202
|
+
let t9;
|
|
2203
|
+
if ($[0] !== height || $[1] !== initialScreens || $[2] !== mediaType || $[3] !== providedMedia || $[4] !== width) {
|
|
2204
|
+
const screens = initialScreens || [];
|
|
2205
|
+
let t11;
|
|
2206
|
+
if ($[7] !== height || $[8] !== mediaType || $[9] !== providedMedia || $[10] !== width) {
|
|
2207
|
+
t11 = providedMedia !== null ? providedMedia : {
|
|
2208
|
+
type: mediaType,
|
|
2209
|
+
width: `${width}px`,
|
|
2210
|
+
height: `${height}px`
|
|
2211
|
+
};
|
|
2212
|
+
$[7] = height;
|
|
2213
|
+
$[8] = mediaType;
|
|
2214
|
+
$[9] = providedMedia;
|
|
2215
|
+
$[10] = width;
|
|
2216
|
+
$[11] = t11;
|
|
2217
|
+
} else {
|
|
2218
|
+
t11 = $[11];
|
|
2219
|
+
}
|
|
2220
|
+
const media = t11;
|
|
2221
|
+
let t12;
|
|
2222
|
+
if ($[12] !== media) {
|
|
2223
|
+
t12 = t13 => {
|
|
2224
|
+
const {
|
|
2225
|
+
mediaQuery: t14
|
|
2226
|
+
} = t13;
|
|
2227
|
+
const mediaQuery = t14 === undefined ? null : t14;
|
|
2228
|
+
return mediaQuery === null || match(mediaQuery, media);
|
|
2229
|
+
};
|
|
2230
|
+
$[12] = media;
|
|
2231
|
+
$[13] = t12;
|
|
2232
|
+
} else {
|
|
2233
|
+
t12 = $[13];
|
|
2234
|
+
}
|
|
2235
|
+
const matchingScreens = [...screens].reverse().filter(t12);
|
|
2236
|
+
t9 = matchingScreens.length > 0 ? matchingScreens[0].name : null;
|
|
2237
|
+
t10 = [...matchingScreens].reverse().map(_temp);
|
|
2238
|
+
$[0] = height;
|
|
2239
|
+
$[1] = initialScreens;
|
|
2240
|
+
$[2] = mediaType;
|
|
2241
|
+
$[3] = providedMedia;
|
|
2242
|
+
$[4] = width;
|
|
2243
|
+
$[5] = t10;
|
|
2244
|
+
$[6] = t9;
|
|
2245
|
+
} else {
|
|
2246
|
+
t10 = $[5];
|
|
2247
|
+
t9 = $[6];
|
|
2248
|
+
}
|
|
2249
|
+
const t11 = scale !== null ? scale * devicePixelRatio : devicePixelRatio;
|
|
2250
|
+
const t12 = scale !== null ? Math.max(scale, devicePixelRatio) : devicePixelRatio;
|
|
2251
|
+
let t13;
|
|
2252
|
+
if ($[14] !== height || $[15] !== landscape || $[16] !== menuOverScreen || $[17] !== t10 || $[18] !== t11 || $[19] !== t12 || $[20] !== t9 || $[21] !== width) {
|
|
2253
|
+
t13 = {
|
|
2254
|
+
screen: t9,
|
|
2255
|
+
screens: t10,
|
|
2256
|
+
width,
|
|
2257
|
+
height,
|
|
2258
|
+
landscape,
|
|
2259
|
+
menuOverScreen,
|
|
2260
|
+
resolution: t11,
|
|
2261
|
+
imageResolution: t12
|
|
2064
2262
|
};
|
|
2065
|
-
|
|
2066
|
-
|
|
2263
|
+
$[14] = height;
|
|
2264
|
+
$[15] = landscape;
|
|
2265
|
+
$[16] = menuOverScreen;
|
|
2266
|
+
$[17] = t10;
|
|
2267
|
+
$[18] = t11;
|
|
2268
|
+
$[19] = t12;
|
|
2269
|
+
$[20] = t9;
|
|
2270
|
+
$[21] = width;
|
|
2271
|
+
$[22] = t13;
|
|
2272
|
+
} else {
|
|
2273
|
+
t13 = $[22];
|
|
2274
|
+
}
|
|
2275
|
+
return t13;
|
|
2067
2276
|
};
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2277
|
+
const defaultLandscapeMinRatio = 2 / 3;
|
|
2278
|
+
const useScreenSizeFromElement = t0 => {
|
|
2279
|
+
const $ = c(25);
|
|
2280
|
+
const options = t0 === undefined ? null : t0;
|
|
2281
|
+
let t1;
|
|
2282
|
+
if ($[0] !== options) {
|
|
2283
|
+
t1 = options || {};
|
|
2284
|
+
$[0] = options;
|
|
2285
|
+
$[1] = t1;
|
|
2286
|
+
} else {
|
|
2287
|
+
t1 = $[1];
|
|
2288
|
+
}
|
|
2289
|
+
let opts;
|
|
2290
|
+
let t2;
|
|
2291
|
+
let t3;
|
|
2292
|
+
if ($[2] !== t1) {
|
|
2293
|
+
({
|
|
2294
|
+
width: t2,
|
|
2295
|
+
height: t3,
|
|
2296
|
+
...opts
|
|
2297
|
+
} = t1);
|
|
2298
|
+
$[2] = t1;
|
|
2299
|
+
$[3] = opts;
|
|
2300
|
+
$[4] = t2;
|
|
2301
|
+
$[5] = t3;
|
|
2302
|
+
} else {
|
|
2303
|
+
opts = $[3];
|
|
2304
|
+
t2 = $[4];
|
|
2305
|
+
t3 = $[5];
|
|
2306
|
+
}
|
|
2307
|
+
const width = t2 === undefined ? null : t2;
|
|
2308
|
+
const height = t3 === undefined ? null : t3;
|
|
2309
|
+
const {
|
|
2310
|
+
ref,
|
|
2311
|
+
width: t4,
|
|
2312
|
+
height: t5
|
|
2313
|
+
} = useDimensionObserver();
|
|
2314
|
+
const calculatedWidth = t4 === undefined ? 0 : t4;
|
|
2315
|
+
const calculatedHeight = t5 === undefined ? 0 : t5;
|
|
2316
|
+
const devicePixelRatio = useDevicePixelRatio();
|
|
2317
|
+
const fullWidth = width !== null ? width : calculatedWidth;
|
|
2318
|
+
const fullHeight = height !== null ? height : calculatedHeight;
|
|
2319
|
+
let t6;
|
|
2320
|
+
if ($[6] !== opts) {
|
|
2321
|
+
t6 = opts || {};
|
|
2322
|
+
$[6] = opts;
|
|
2323
|
+
$[7] = t6;
|
|
2324
|
+
} else {
|
|
2325
|
+
t6 = $[7];
|
|
2326
|
+
}
|
|
2327
|
+
const {
|
|
2328
|
+
screenWidth: t7,
|
|
2329
|
+
screenHeight: t8,
|
|
2330
|
+
withoutMaxSize: t9,
|
|
2331
|
+
landscapeMinHeight: t10,
|
|
2332
|
+
menuAlwaysOverScreen: t11,
|
|
2333
|
+
landscapeMinRatio: t12,
|
|
2334
|
+
withoutScale: t13
|
|
2335
|
+
} = t6;
|
|
2336
|
+
const screenWidth = t7 === undefined ? 320 : t7;
|
|
2337
|
+
const screenHeight = t8 === undefined ? 480 : t8;
|
|
2338
|
+
const withoutMaxSize = t9 === undefined ? false : t9;
|
|
2339
|
+
const landscapeMinHeight = t10 === undefined ? 600 : t10;
|
|
2340
|
+
const menuAlwaysOverScreen = t11 === undefined ? true : t11;
|
|
2341
|
+
const landscapeMinRatio = t12 === undefined ? defaultLandscapeMinRatio : t12;
|
|
2342
|
+
const withoutScale = t13 === undefined ? false : t13;
|
|
2343
|
+
const screenRatio = screenWidth / screenHeight;
|
|
2344
|
+
const elementRatio = fullWidth / fullHeight;
|
|
2345
|
+
const landscape = fullHeight > 0 && elementRatio > (landscapeMinRatio || screenRatio);
|
|
2346
|
+
const landscapeWithMaxSize = landscape && !withoutMaxSize;
|
|
2347
|
+
let finalWidth = fullWidth;
|
|
2348
|
+
let finalHeight = fullHeight;
|
|
2349
|
+
let menuOverScreen = !landscape;
|
|
2107
2350
|
if (landscapeWithMaxSize) {
|
|
2108
2351
|
if (fullHeight < landscapeMinHeight || menuAlwaysOverScreen) {
|
|
2109
2352
|
menuOverScreen = true;
|
|
2110
2353
|
} else {
|
|
2111
2354
|
finalHeight = fullHeight - 100;
|
|
2112
2355
|
}
|
|
2113
|
-
|
|
2356
|
+
let t14;
|
|
2357
|
+
if ($[8] !== finalHeight || $[9] !== screenRatio) {
|
|
2358
|
+
t14 = Math.round(finalHeight * screenRatio);
|
|
2359
|
+
$[8] = finalHeight;
|
|
2360
|
+
$[9] = screenRatio;
|
|
2361
|
+
$[10] = t14;
|
|
2362
|
+
} else {
|
|
2363
|
+
t14 = $[10];
|
|
2364
|
+
}
|
|
2365
|
+
finalWidth = t14;
|
|
2114
2366
|
}
|
|
2115
2367
|
if (finalWidth % 2 === 1) {
|
|
2116
|
-
finalWidth
|
|
2368
|
+
finalWidth = finalWidth - 1;
|
|
2117
2369
|
}
|
|
2118
2370
|
if (finalHeight % 2 === 1) {
|
|
2119
|
-
finalHeight
|
|
2120
|
-
}
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2371
|
+
finalHeight = finalHeight - 1;
|
|
2372
|
+
}
|
|
2373
|
+
const scale = finalWidth > 0 ? finalWidth / screenWidth : null;
|
|
2374
|
+
const t14 = withoutScale || scale === null ? finalWidth : screenWidth;
|
|
2375
|
+
const t15 = withoutScale || scale === null ? finalHeight : finalHeight / scale;
|
|
2376
|
+
const t16 = !withoutScale ? scale : null;
|
|
2377
|
+
let t17;
|
|
2378
|
+
if ($[11] !== landscape || $[12] !== menuOverScreen || $[13] !== opts || $[14] !== t14 || $[15] !== t15 || $[16] !== t16) {
|
|
2379
|
+
t17 = {
|
|
2380
|
+
width: t14,
|
|
2381
|
+
height: t15,
|
|
2382
|
+
landscape,
|
|
2383
|
+
menuOverScreen,
|
|
2384
|
+
scale: t16,
|
|
2385
|
+
...opts
|
|
2386
|
+
};
|
|
2387
|
+
$[11] = landscape;
|
|
2388
|
+
$[12] = menuOverScreen;
|
|
2389
|
+
$[13] = opts;
|
|
2390
|
+
$[14] = t14;
|
|
2391
|
+
$[15] = t15;
|
|
2392
|
+
$[16] = t16;
|
|
2393
|
+
$[17] = t17;
|
|
2394
|
+
} else {
|
|
2395
|
+
t17 = $[17];
|
|
2396
|
+
}
|
|
2397
|
+
const screenSize = useScreenSize(t17);
|
|
2398
|
+
const t18 = !withoutScale ? scale : null;
|
|
2399
|
+
const t19 = !withoutScale ? scale * devicePixelRatio : devicePixelRatio;
|
|
2400
|
+
let t20;
|
|
2401
|
+
if ($[18] !== fullHeight || $[19] !== fullWidth || $[20] !== ref || $[21] !== screenSize || $[22] !== t18 || $[23] !== t19) {
|
|
2402
|
+
t20 = {
|
|
2403
|
+
ref,
|
|
2404
|
+
fullWidth,
|
|
2405
|
+
fullHeight,
|
|
2406
|
+
screenSize,
|
|
2407
|
+
scale: t18,
|
|
2408
|
+
resolution: t19
|
|
2409
|
+
};
|
|
2410
|
+
$[18] = fullHeight;
|
|
2411
|
+
$[19] = fullWidth;
|
|
2412
|
+
$[20] = ref;
|
|
2413
|
+
$[21] = screenSize;
|
|
2414
|
+
$[22] = t18;
|
|
2415
|
+
$[23] = t19;
|
|
2416
|
+
$[24] = t20;
|
|
2417
|
+
} else {
|
|
2418
|
+
t20 = $[24];
|
|
2419
|
+
}
|
|
2420
|
+
return t20;
|
|
2137
2421
|
};
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2422
|
+
const useScreenSizeFromWindow = opts => {
|
|
2423
|
+
const $ = c(3);
|
|
2424
|
+
const windowSize = useWindowSize();
|
|
2425
|
+
let t0;
|
|
2426
|
+
if ($[0] !== opts || $[1] !== windowSize) {
|
|
2427
|
+
t0 = {
|
|
2428
|
+
...opts,
|
|
2429
|
+
...windowSize
|
|
2430
|
+
};
|
|
2431
|
+
$[0] = opts;
|
|
2432
|
+
$[1] = windowSize;
|
|
2433
|
+
$[2] = t0;
|
|
2434
|
+
} else {
|
|
2435
|
+
t0 = $[2];
|
|
2436
|
+
}
|
|
2437
|
+
return useScreenSize(t0);
|
|
2141
2438
|
};
|
|
2439
|
+
function _temp(t0) {
|
|
2440
|
+
const {
|
|
2441
|
+
name
|
|
2442
|
+
} = t0;
|
|
2443
|
+
return name;
|
|
2444
|
+
}
|
|
2142
2445
|
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
p
|
|
2446
|
+
const getValueFromSpring = s => {
|
|
2447
|
+
const {
|
|
2448
|
+
value: v = null
|
|
2449
|
+
} = s || {};
|
|
2450
|
+
const {
|
|
2451
|
+
progress: p
|
|
2452
|
+
} = v || {};
|
|
2149
2453
|
return p;
|
|
2150
2454
|
};
|
|
2151
2455
|
function useSpringValue(wantedProgress, immediate, params) {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2456
|
+
const $ = c(5);
|
|
2457
|
+
const [progress, setProgress] = useState(wantedProgress);
|
|
2458
|
+
let t0;
|
|
2459
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2460
|
+
t0 = spring => setProgress(getValueFromSpring(spring));
|
|
2461
|
+
$[0] = t0;
|
|
2462
|
+
} else {
|
|
2463
|
+
t0 = $[0];
|
|
2464
|
+
}
|
|
2465
|
+
const onChange = t0;
|
|
2466
|
+
let t1;
|
|
2467
|
+
if ($[1] !== immediate || $[2] !== params || $[3] !== wantedProgress) {
|
|
2468
|
+
t1 = {
|
|
2469
|
+
progress: wantedProgress,
|
|
2470
|
+
onChange,
|
|
2471
|
+
immediate,
|
|
2472
|
+
...params
|
|
2473
|
+
};
|
|
2474
|
+
$[1] = immediate;
|
|
2475
|
+
$[2] = params;
|
|
2476
|
+
$[3] = wantedProgress;
|
|
2477
|
+
$[4] = t1;
|
|
2478
|
+
} else {
|
|
2479
|
+
t1 = $[4];
|
|
2480
|
+
}
|
|
2481
|
+
useSpring(t1);
|
|
2164
2482
|
return immediate ? wantedProgress : progress;
|
|
2165
2483
|
}
|
|
2166
2484
|
|
|
2167
2485
|
function checkWebpSupport() {
|
|
2168
|
-
return new Promise(
|
|
2169
|
-
|
|
2170
|
-
img.onload =
|
|
2486
|
+
return new Promise(resolve => {
|
|
2487
|
+
const img = document.createElement('img');
|
|
2488
|
+
img.onload = () => {
|
|
2171
2489
|
resolve(img.width > 0 && img.height > 0);
|
|
2172
2490
|
};
|
|
2173
|
-
img.onerror =
|
|
2491
|
+
img.onerror = () => {
|
|
2174
2492
|
resolve(false);
|
|
2175
2493
|
};
|
|
2176
2494
|
img.src = 'data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoCAAEAAQAcJaQAA3AA/v3AgAA=';
|
|
2177
2495
|
});
|
|
2178
2496
|
}
|
|
2179
|
-
function useSupportsWebp() {
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2497
|
+
function useSupportsWebp(t0) {
|
|
2498
|
+
const $ = c(3);
|
|
2499
|
+
const defaultValue = t0 === undefined ? true : t0;
|
|
2500
|
+
const [supportsWebp, setSupportsWebp] = useState(defaultValue);
|
|
2501
|
+
let t1;
|
|
2502
|
+
if ($[0] !== supportsWebp) {
|
|
2503
|
+
t1 = () => {
|
|
2504
|
+
let canceled = false;
|
|
2505
|
+
checkWebpSupport().then(newSupport => {
|
|
2506
|
+
if (!canceled && newSupport !== supportsWebp) {
|
|
2507
|
+
setSupportsWebp(newSupport);
|
|
2508
|
+
}
|
|
2509
|
+
});
|
|
2510
|
+
return () => {
|
|
2511
|
+
canceled = true;
|
|
2512
|
+
};
|
|
2194
2513
|
};
|
|
2195
|
-
|
|
2514
|
+
$[0] = supportsWebp;
|
|
2515
|
+
$[1] = t1;
|
|
2516
|
+
} else {
|
|
2517
|
+
t1 = $[1];
|
|
2518
|
+
}
|
|
2519
|
+
let t2;
|
|
2520
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
2521
|
+
t2 = [];
|
|
2522
|
+
$[2] = t2;
|
|
2523
|
+
} else {
|
|
2524
|
+
t2 = $[2];
|
|
2525
|
+
}
|
|
2526
|
+
useEffect(t1, t2);
|
|
2196
2527
|
return supportsWebp;
|
|
2197
2528
|
}
|
|
2198
2529
|
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
var scale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
2236
|
-
return {
|
|
2237
|
-
x: x,
|
|
2238
|
-
zIndex: idx,
|
|
2239
|
-
scale: scale
|
|
2240
|
-
};
|
|
2241
|
-
});
|
|
2242
|
-
var getItems = useCallback(function () {
|
|
2243
|
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
2244
|
-
_ref2$down = _ref2.down,
|
|
2245
|
-
down = _ref2$down === void 0 ? false : _ref2$down,
|
|
2246
|
-
_ref2$mx = _ref2.mx,
|
|
2247
|
-
mx = _ref2$mx === void 0 ? 0 : _ref2$mx;
|
|
2248
|
-
return items.map(function (item, i) {
|
|
2249
|
-
var x = disabled ? 0 : (i - index.current) * currentWidth + (down ? mx : 0);
|
|
2250
|
-
var scale = !animateScale || disabled || !down ? 1 : 1 - Math.abs(mx) / currentWidth / 2;
|
|
2251
|
-
return getItem(x, i, scale);
|
|
2252
|
-
});
|
|
2253
|
-
}, [disabled, items, index, currentWidth, animateScale]);
|
|
2530
|
+
const useSwipe = ({
|
|
2531
|
+
width = null,
|
|
2532
|
+
items: initialItems = null,
|
|
2533
|
+
withSpring = true,
|
|
2534
|
+
swipeWidthThreshold = 3,
|
|
2535
|
+
animateScale = false,
|
|
2536
|
+
disabled = false,
|
|
2537
|
+
lockAxis = false,
|
|
2538
|
+
onSwipeStart = null,
|
|
2539
|
+
onSwipeEnd = null,
|
|
2540
|
+
onSwipeCancel = null,
|
|
2541
|
+
onTap = null
|
|
2542
|
+
} = {}) => {
|
|
2543
|
+
const items = initialItems || [];
|
|
2544
|
+
const swipingIndex = useRef(null);
|
|
2545
|
+
const index = useRef(0);
|
|
2546
|
+
const lockedAxis = useRef(null);
|
|
2547
|
+
const hasWidth = width !== null;
|
|
2548
|
+
const {
|
|
2549
|
+
width: windowWidth
|
|
2550
|
+
} = useWindowSize();
|
|
2551
|
+
const currentWidth = hasWidth ? width : windowWidth;
|
|
2552
|
+
const count = items.length;
|
|
2553
|
+
const getItem = useCallback((x = 0, idx = 0, scale = 1) => ({
|
|
2554
|
+
x,
|
|
2555
|
+
zIndex: idx,
|
|
2556
|
+
scale
|
|
2557
|
+
}));
|
|
2558
|
+
const getItems = useCallback(({
|
|
2559
|
+
down = false,
|
|
2560
|
+
mx = 0
|
|
2561
|
+
} = {}) => items.map((item, i) => {
|
|
2562
|
+
const x_0 = disabled ? 0 : (i - index.current) * currentWidth + (down ? mx : 0);
|
|
2563
|
+
const scale_0 = !animateScale || disabled || !down ? 1 : 1 - Math.abs(mx) / currentWidth / 2;
|
|
2564
|
+
return getItem(x_0, i, scale_0);
|
|
2565
|
+
}), [disabled, items, index, currentWidth, animateScale]);
|
|
2254
2566
|
|
|
2255
2567
|
// Initial items state
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
my = _ref3$movement[1],
|
|
2274
|
-
_ref3$direction = _slicedToArray(_ref3.direction, 1),
|
|
2275
|
-
xDir = _ref3$direction[0],
|
|
2276
|
-
cancel = _ref3.cancel,
|
|
2277
|
-
tap = _ref3.tap;
|
|
2568
|
+
const [itemsWithProps, set] = useSprings(items.length, i_0 => ({
|
|
2569
|
+
x: disabled ? 0 : i_0 * currentWidth,
|
|
2570
|
+
y: 0,
|
|
2571
|
+
zIndex: i_0,
|
|
2572
|
+
config: {
|
|
2573
|
+
...(!withSpring ? {
|
|
2574
|
+
duration: 1
|
|
2575
|
+
} : null)
|
|
2576
|
+
}
|
|
2577
|
+
}));
|
|
2578
|
+
const bind = useDrag(({
|
|
2579
|
+
down: down_0,
|
|
2580
|
+
movement: [mx_0, my],
|
|
2581
|
+
direction: [xDir],
|
|
2582
|
+
cancel,
|
|
2583
|
+
tap
|
|
2584
|
+
}) => {
|
|
2278
2585
|
if (disabled) {
|
|
2279
2586
|
cancel();
|
|
2280
2587
|
return;
|
|
2281
2588
|
}
|
|
2282
|
-
if (!
|
|
2589
|
+
if (!down_0 && swipingIndex.current === index.current) {
|
|
2283
2590
|
lockedAxis.current = null;
|
|
2284
2591
|
if (onSwipeCancel !== null) {
|
|
2285
2592
|
onSwipeCancel(index.current);
|
|
@@ -2298,9 +2605,9 @@ var useSwipe = function useSwipe() {
|
|
|
2298
2605
|
}
|
|
2299
2606
|
*/
|
|
2300
2607
|
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
if (
|
|
2608
|
+
const movementX = !lockAxis || lockedAxis.current === 'x' ? mx_0 : 0;
|
|
2609
|
+
const movementY = !lockAxis || lockedAxis.current === 'y' ? my : 0;
|
|
2610
|
+
if (down_0) {
|
|
2304
2611
|
// Snap to next slide
|
|
2305
2612
|
if (Math.abs(movementX) > currentWidth / swipeWidthThreshold) {
|
|
2306
2613
|
index.current = clamp(index.current + (xDir > 0 ? -1 : 1), 0, count - 1);
|
|
@@ -2313,19 +2620,19 @@ var useSwipe = function useSwipe() {
|
|
|
2313
2620
|
}
|
|
2314
2621
|
}
|
|
2315
2622
|
set(getItems({
|
|
2316
|
-
down:
|
|
2623
|
+
down: down_0,
|
|
2317
2624
|
mx: movementX,
|
|
2318
2625
|
my: movementY
|
|
2319
2626
|
}));
|
|
2320
2627
|
|
|
2321
2628
|
// saving current swiping index in a ref in order to have a section called only once when swipe just started or a tap was detected
|
|
2322
2629
|
if (swipingIndex.current !== index.current) {
|
|
2323
|
-
if (
|
|
2630
|
+
if (down_0 && !tap) {
|
|
2324
2631
|
if (onSwipeStart !== null) {
|
|
2325
2632
|
onSwipeStart(index.current);
|
|
2326
2633
|
}
|
|
2327
2634
|
}
|
|
2328
|
-
if (!
|
|
2635
|
+
if (!down_0 && tap) {
|
|
2329
2636
|
if (onTap !== null) {
|
|
2330
2637
|
onTap();
|
|
2331
2638
|
}
|
|
@@ -2333,153 +2640,216 @@ var useSwipe = function useSwipe() {
|
|
|
2333
2640
|
}
|
|
2334
2641
|
|
|
2335
2642
|
// lock swiping on axis from initial 3 pixels distance (Y axis requires to swipe down)
|
|
2336
|
-
if (lockAxis &&
|
|
2337
|
-
|
|
2338
|
-
|
|
2643
|
+
if (lockAxis && down_0 && lockedAxis.current === null) {
|
|
2644
|
+
const distanceX = Math.abs(mx_0);
|
|
2645
|
+
const distanceY = Math.abs(my);
|
|
2339
2646
|
if (distanceX !== distanceY && (distanceY > 2 || distanceX > 2)) {
|
|
2340
2647
|
lockedAxis.current = distanceY > distanceX ? 'y' : 'x';
|
|
2341
2648
|
}
|
|
2342
2649
|
}
|
|
2343
|
-
swipingIndex.current =
|
|
2650
|
+
swipingIndex.current = down_0 && !tap ? index.current : null;
|
|
2344
2651
|
}, {
|
|
2345
2652
|
filterTaps: true
|
|
2346
2653
|
});
|
|
2347
|
-
|
|
2654
|
+
const reset = useCallback(() => {
|
|
2348
2655
|
set(getItems());
|
|
2349
2656
|
}, [disabled, items, index, currentWidth]);
|
|
2350
|
-
|
|
2351
|
-
index.current =
|
|
2657
|
+
const setIndex = useCallback(idx_0 => {
|
|
2658
|
+
index.current = idx_0;
|
|
2352
2659
|
reset();
|
|
2353
2660
|
}, [reset]);
|
|
2354
2661
|
|
|
2355
2662
|
// Reset on resize or others
|
|
2356
|
-
useEffect(
|
|
2663
|
+
useEffect(() => {
|
|
2357
2664
|
set(getItems());
|
|
2358
2665
|
}, [items, width, set, disabled]);
|
|
2359
2666
|
return {
|
|
2360
2667
|
items: itemsWithProps,
|
|
2361
|
-
bind
|
|
2668
|
+
bind,
|
|
2362
2669
|
index: index.current,
|
|
2363
|
-
setIndex
|
|
2670
|
+
setIndex
|
|
2364
2671
|
};
|
|
2365
2672
|
};
|
|
2366
2673
|
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2674
|
+
const useThemeParser = () => {
|
|
2675
|
+
const $ = c(4);
|
|
2676
|
+
const screensManager = useScreensManager();
|
|
2677
|
+
let t0;
|
|
2678
|
+
if ($[0] !== screensManager) {
|
|
2679
|
+
t0 = new ThemeParser({
|
|
2680
|
+
screensManager
|
|
2372
2681
|
});
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2682
|
+
$[0] = screensManager;
|
|
2683
|
+
$[1] = t0;
|
|
2684
|
+
} else {
|
|
2685
|
+
t0 = $[1];
|
|
2686
|
+
}
|
|
2687
|
+
const parser = t0;
|
|
2688
|
+
let t1;
|
|
2689
|
+
if ($[2] !== parser) {
|
|
2690
|
+
t1 = story => parser.parse(story);
|
|
2691
|
+
$[2] = parser;
|
|
2692
|
+
$[3] = t1;
|
|
2693
|
+
} else {
|
|
2694
|
+
t1 = $[3];
|
|
2695
|
+
}
|
|
2696
|
+
const parse = t1;
|
|
2377
2697
|
return parse;
|
|
2378
2698
|
};
|
|
2379
2699
|
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
var screenType = ctxScreenType !== null ? ctxScreenType : optsScreenType;
|
|
2700
|
+
const getScreenOptions = (screenContext, opts) => {
|
|
2701
|
+
const {
|
|
2702
|
+
data: ctxData = null
|
|
2703
|
+
} = screenContext || {};
|
|
2704
|
+
const {
|
|
2705
|
+
id: ctxScreenId = null,
|
|
2706
|
+
type: ctxScreenType
|
|
2707
|
+
} = ctxData || {};
|
|
2708
|
+
const {
|
|
2709
|
+
screenId: optsScreenId = null,
|
|
2710
|
+
screenType: optsScreenType = null
|
|
2711
|
+
} = opts || {};
|
|
2712
|
+
const screenId = ctxScreenId !== null ? ctxScreenId : optsScreenId;
|
|
2713
|
+
const screenType = ctxScreenType !== null ? ctxScreenType : optsScreenType;
|
|
2395
2714
|
return {
|
|
2396
|
-
screenId
|
|
2397
|
-
screenType
|
|
2715
|
+
screenId,
|
|
2716
|
+
screenType
|
|
2398
2717
|
};
|
|
2399
2718
|
};
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2719
|
+
const hasTracking = tracking => typeof tracking !== 'undefined' && tracking !== null;
|
|
2720
|
+
const useTrackScreenView = () => {
|
|
2721
|
+
const $ = c(2);
|
|
2722
|
+
const tracking = useTracking();
|
|
2723
|
+
let t0;
|
|
2724
|
+
if ($[0] !== tracking) {
|
|
2725
|
+
t0 = (t1, t2) => {
|
|
2726
|
+
const screen = t1 === undefined ? null : t1;
|
|
2727
|
+
const index = t2 === undefined ? null : t2;
|
|
2728
|
+
if (!hasTracking(tracking)) {
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
if (screen !== null && index !== null) {
|
|
2732
|
+
tracking.trackScreenView(screen, index);
|
|
2733
|
+
}
|
|
2734
|
+
};
|
|
2735
|
+
$[0] = tracking;
|
|
2736
|
+
$[1] = t0;
|
|
2737
|
+
} else {
|
|
2738
|
+
t0 = $[1];
|
|
2739
|
+
}
|
|
2740
|
+
return t0;
|
|
2415
2741
|
};
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2742
|
+
const useTrackScreenEvent = t0 => {
|
|
2743
|
+
const $ = c(4);
|
|
2744
|
+
const type = t0 === undefined ? null : t0;
|
|
2745
|
+
const tracking = useTracking();
|
|
2746
|
+
const screenContext = useScreen();
|
|
2747
|
+
let t1;
|
|
2748
|
+
if ($[0] !== screenContext || $[1] !== tracking || $[2] !== type) {
|
|
2749
|
+
t1 = (t2, t3, t4) => {
|
|
2750
|
+
const action = t2 === undefined ? null : t2;
|
|
2751
|
+
const label = t3 === undefined ? null : t3;
|
|
2752
|
+
const opts = t4 === undefined ? null : t4;
|
|
2753
|
+
if (!hasTracking(tracking) || screenContext.renderContext !== "view") {
|
|
2754
|
+
return;
|
|
2755
|
+
}
|
|
2756
|
+
if (type !== null && action !== null) {
|
|
2757
|
+
tracking.trackEvent(`screen_${type}`, action, label, {
|
|
2758
|
+
...opts,
|
|
2759
|
+
...getScreenOptions(screenContext, opts)
|
|
2760
|
+
});
|
|
2761
|
+
}
|
|
2762
|
+
};
|
|
2763
|
+
$[0] = screenContext;
|
|
2764
|
+
$[1] = tracking;
|
|
2765
|
+
$[2] = type;
|
|
2766
|
+
$[3] = t1;
|
|
2767
|
+
} else {
|
|
2768
|
+
t1 = $[3];
|
|
2769
|
+
}
|
|
2770
|
+
return t1;
|
|
2434
2771
|
};
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2772
|
+
const useTrackScreenMedia = t0 => {
|
|
2773
|
+
const $ = c(4);
|
|
2774
|
+
const type = t0 === undefined ? null : t0;
|
|
2775
|
+
const tracking = useTracking();
|
|
2776
|
+
const screenContext = useScreen();
|
|
2777
|
+
let t1;
|
|
2778
|
+
if ($[0] !== screenContext || $[1] !== tracking || $[2] !== type) {
|
|
2779
|
+
t1 = (t2, t3, t4) => {
|
|
2780
|
+
const media = t2 === undefined ? null : t2;
|
|
2781
|
+
const action = t3 === undefined ? null : t3;
|
|
2782
|
+
const opts = t4 === undefined ? null : t4;
|
|
2783
|
+
if (!hasTracking(tracking) || screenContext.renderContext !== "view") {
|
|
2784
|
+
return;
|
|
2785
|
+
}
|
|
2786
|
+
if (type !== null && media !== null && action !== null) {
|
|
2787
|
+
tracking.trackMedia(`screen_${type}`, media, action, {
|
|
2788
|
+
...opts,
|
|
2789
|
+
...getScreenOptions(screenContext, opts)
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
};
|
|
2793
|
+
$[0] = screenContext;
|
|
2794
|
+
$[1] = tracking;
|
|
2795
|
+
$[2] = type;
|
|
2796
|
+
$[3] = t1;
|
|
2797
|
+
} else {
|
|
2798
|
+
t1 = $[3];
|
|
2799
|
+
}
|
|
2800
|
+
return t1;
|
|
2450
2801
|
};
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2802
|
+
const useTrackEvent = () => {
|
|
2803
|
+
const $ = c(2);
|
|
2804
|
+
const tracking = useTracking();
|
|
2805
|
+
let t0;
|
|
2806
|
+
if ($[0] !== tracking) {
|
|
2807
|
+
t0 = (t1, t2, t3, t4) => {
|
|
2808
|
+
const category = t1 === undefined ? null : t1;
|
|
2809
|
+
const action = t2 === undefined ? null : t2;
|
|
2810
|
+
const label = t3 === undefined ? null : t3;
|
|
2811
|
+
const opts = t4 === undefined ? null : t4;
|
|
2812
|
+
if (!hasTracking(tracking)) {
|
|
2813
|
+
return;
|
|
2814
|
+
}
|
|
2815
|
+
if (category !== null && action !== null) {
|
|
2816
|
+
tracking.trackEvent(category, action, label, opts);
|
|
2817
|
+
}
|
|
2818
|
+
};
|
|
2819
|
+
$[0] = tracking;
|
|
2820
|
+
$[1] = t0;
|
|
2821
|
+
} else {
|
|
2822
|
+
t0 = $[1];
|
|
2823
|
+
}
|
|
2824
|
+
return t0;
|
|
2465
2825
|
};
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2826
|
+
const useTrackMedia = t0 => {
|
|
2827
|
+
const $ = c(3);
|
|
2828
|
+
const type = t0 === undefined ? null : t0;
|
|
2829
|
+
const tracking = useTracking();
|
|
2830
|
+
let t1;
|
|
2831
|
+
if ($[0] !== tracking || $[1] !== type) {
|
|
2832
|
+
t1 = (t2, t3, t4) => {
|
|
2833
|
+
const media = t2 === undefined ? null : t2;
|
|
2834
|
+
const action = t3 === undefined ? null : t3;
|
|
2835
|
+
const opts = t4 === undefined ? null : t4;
|
|
2836
|
+
if (!hasTracking(tracking)) {
|
|
2837
|
+
return;
|
|
2838
|
+
}
|
|
2839
|
+
if (type !== null && media !== null && action !== null) {
|
|
2840
|
+
tracking.trackMedia(type, media, action, opts);
|
|
2841
|
+
}
|
|
2842
|
+
};
|
|
2843
|
+
$[0] = tracking;
|
|
2844
|
+
$[1] = type;
|
|
2845
|
+
$[2] = t1;
|
|
2846
|
+
} else {
|
|
2847
|
+
t1 = $[2];
|
|
2848
|
+
}
|
|
2849
|
+
return t1;
|
|
2480
2850
|
};
|
|
2481
2851
|
|
|
2482
|
-
|
|
2483
|
-
|
|
2852
|
+
const eventsManager = typeof window !== 'undefined' ? new EventsManager(window) : null;
|
|
2853
|
+
const useWindowEvent = createUseEvent(eventsManager);
|
|
2484
2854
|
|
|
2485
|
-
export {
|
|
2855
|
+
export { useActivityDetector, useAnimationFrame, useDebounced as useDebounce, useDevicePixelRatio, useDimensionObserver, useDocumentEvent, useDragProgress, useForm, useFormTransition, useFormattedDate, useFormattedTime, useFullscreen, useIsVisible, useLoadedFonts, useLongPress, useMediaBuffering, useMediaCurrentTime, useMediaDuration, useMediaLoad, useMediaProgress, useMediaReady, useMediaState, useMediaTimestampOffset, useMediaWaveform, useMediasParser, useParsedStory, usePlaceholderStyle, useProgressSteps, useScreenSizeFromElement, useScreenSizeFromWindow, useSpringValue, useSupportsWebp, useSwipe, useThemeParser, useTrackEvent, useTrackMedia, useTrackScreenEvent, useTrackScreenMedia, useTrackScreenView, useWindowEvent };
|