@arcblock/terminal 2.13.70 → 3.0.1
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/lib/Player.js +148 -408
- package/lib/Terminal.js +55 -116
- package/lib/index.js +6 -20
- package/lib/terminal.css +32 -0
- package/lib/util.js +52 -159
- package/package.json +11 -18
- package/src/{Player.js → Player.jsx} +22 -10
- package/src/Player.stories.jsx +14 -0
- package/src/{Terminal.js → Terminal.jsx} +13 -20
- package/vite.config.mjs +29 -0
- package/lib/demo/fixtures/recording.json +0 -860
- package/lib/demo/fixtures/recording2.json +0 -556
- package/lib/player.css +0 -378
- package/lib/xterm.css +0 -171
package/lib/Player.js
CHANGED
|
@@ -1,418 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const options = Object.assign({}, _util.defaultOptions, props.options);
|
|
24
|
-
const {
|
|
25
|
-
frames,
|
|
26
|
-
totalDuration
|
|
27
|
-
} = (0, _util.formatFrames)(props.frames, options);
|
|
28
|
-
const terminalOptions = {
|
|
29
|
-
cols: options.cols,
|
|
30
|
-
rows: options.rows,
|
|
31
|
-
cursorStyle: options.cursorStyle,
|
|
32
|
-
fontFamily: options.fontFamily,
|
|
33
|
-
fontSize: options.fontSize,
|
|
34
|
-
lineHeight: options.lineHeight,
|
|
35
|
-
letterSpacing: options.letterSpacing,
|
|
36
|
-
allowTransparency: true,
|
|
1
|
+
import { jsxs as f, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as S, useState as O, useReducer as W, useEffect as b } from "react";
|
|
3
|
+
import l from "prop-types";
|
|
4
|
+
import H from "@arcblock/react-hooks/lib/useInterval";
|
|
5
|
+
import { useSize as I } from "ahooks";
|
|
6
|
+
import y from "lodash/isUndefined";
|
|
7
|
+
import h from "lodash/noop";
|
|
8
|
+
import A from "./Terminal.js";
|
|
9
|
+
/* empty css */
|
|
10
|
+
import { defaultOptions as U, formatFrames as L, defaultState as X, isFrameAt as F, findFrameAt as P, getPlayerClass as _, getFrameClass as $, formatTime as G } from "./util.js";
|
|
11
|
+
function K(C) {
|
|
12
|
+
const i = Object.assign({}, C);
|
|
13
|
+
y(i.onComplete) && (i.onComplete = h), y(i.onStart) && (i.onStart = h), y(i.onStop) && (i.onStop = h), y(i.onPause) && (i.onPause = h), y(i.onTick) && (i.onTick = h), y(i.onJump) && (i.onJump = h);
|
|
14
|
+
const t = Object.assign({}, U, i.options), { frames: u, totalDuration: m } = L(i.frames, t), R = {
|
|
15
|
+
cols: t.cols,
|
|
16
|
+
rows: t.rows,
|
|
17
|
+
cursorStyle: t.cursorStyle,
|
|
18
|
+
fontFamily: t.fontFamily,
|
|
19
|
+
fontSize: t.fontSize,
|
|
20
|
+
lineHeight: t.lineHeight,
|
|
21
|
+
letterSpacing: t.letterSpacing,
|
|
22
|
+
allowTransparency: !0,
|
|
37
23
|
scrollback: 0
|
|
38
24
|
// theme: options.theme,
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
case
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
case
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
case
|
|
62
|
-
return
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
case 'reset':
|
|
72
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
25
|
+
}, B = (a, e) => {
|
|
26
|
+
switch (e.type) {
|
|
27
|
+
case "jump":
|
|
28
|
+
return { ...a, isPlaying: !1, ...e.payload };
|
|
29
|
+
case "start":
|
|
30
|
+
return { ...a, isStarted: !0, lastTickTime: Date.now() };
|
|
31
|
+
case "play":
|
|
32
|
+
return {
|
|
33
|
+
...a,
|
|
34
|
+
isPlaying: !0,
|
|
35
|
+
lastTickTime: Date.now(),
|
|
36
|
+
...e.payload
|
|
37
|
+
};
|
|
38
|
+
case "pause":
|
|
39
|
+
return { ...a, isPlaying: !1, ...e.payload };
|
|
40
|
+
case "tickStart":
|
|
41
|
+
return {
|
|
42
|
+
...a,
|
|
43
|
+
isRendering: !0,
|
|
44
|
+
lastTickTime: Date.now(),
|
|
45
|
+
...e.payload
|
|
46
|
+
};
|
|
47
|
+
case "tickEnd":
|
|
48
|
+
return {
|
|
49
|
+
...a,
|
|
50
|
+
isRendering: !1,
|
|
51
|
+
lastTickTime: Date.now(),
|
|
52
|
+
...e.payload
|
|
53
|
+
};
|
|
54
|
+
case "reset":
|
|
55
|
+
return {
|
|
56
|
+
...a,
|
|
73
57
|
currentFrame: 0,
|
|
74
|
-
currentTime: 0
|
|
75
|
-
|
|
58
|
+
currentTime: 0,
|
|
59
|
+
...e.payload
|
|
60
|
+
};
|
|
76
61
|
default:
|
|
77
|
-
return
|
|
78
|
-
lastTickTime: Date.now()
|
|
79
|
-
}, action.payload);
|
|
62
|
+
return { ...a, lastTickTime: Date.now(), ...e.payload };
|
|
80
63
|
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!terminal.current) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
try {
|
|
94
|
-
const COLUMN_WIDTH = 972 / 121;
|
|
95
|
-
const child = container.current.getBoundingClientRect();
|
|
96
|
-
let containerWidth = child.x < 0 ? child.width + child.x : child.width;
|
|
97
|
-
if (container.current.parentNode) {
|
|
98
|
-
const parent = container.current.parentNode.getBoundingClientRect();
|
|
99
|
-
if (child.width > parent.width) {
|
|
100
|
-
containerWidth = parent.width;
|
|
64
|
+
}, o = S(null), k = S(null), d = S(null), [D, M] = O(0), v = I(document.body), [r, c] = W(B, X), j = (v == null ? void 0 : v.width) || 0;
|
|
65
|
+
b(() => {
|
|
66
|
+
if (o.current)
|
|
67
|
+
try {
|
|
68
|
+
const a = 8.03305785123967, e = d.current.getBoundingClientRect();
|
|
69
|
+
let s = e.x < 0 ? e.width + e.x : e.width;
|
|
70
|
+
if (d.current.parentNode) {
|
|
71
|
+
const x = d.current.parentNode.getBoundingClientRect();
|
|
72
|
+
e.width > x.width && (s = x.width);
|
|
101
73
|
}
|
|
74
|
+
t.controls && (s -= 12);
|
|
75
|
+
const T = Math.ceil(s / a), E = Math.min(Math.max(T, 40), t.cols);
|
|
76
|
+
o.current.resize(E, t.rows);
|
|
77
|
+
} catch {
|
|
102
78
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
79
|
+
}, [j, D]);
|
|
80
|
+
const w = (a, e) => {
|
|
81
|
+
const s = u[a];
|
|
82
|
+
s.content && (r.requireReset && o.current.reset(), o.current.write(s.content, () => {
|
|
83
|
+
typeof e == "function" && e();
|
|
84
|
+
}));
|
|
85
|
+
}, p = (a) => {
|
|
86
|
+
typeof i[a] == "function" && i[a]({ state: r, frames: u, options: t });
|
|
87
|
+
}, N = (a) => {
|
|
88
|
+
o.current.reset();
|
|
89
|
+
const e = P(u, a);
|
|
90
|
+
for (let s = 0; s < e; s++)
|
|
91
|
+
w(s);
|
|
92
|
+
}, q = (a) => {
|
|
93
|
+
if (!k.current || !o.current || !r.isStarted)
|
|
94
|
+
return !1;
|
|
95
|
+
const e = k.current.getBoundingClientRect().width, s = a.nativeEvent.offsetX, T = Math.floor(m * s / e);
|
|
96
|
+
return c({ type: "jump", payload: { currentTime: T } }), N(T), p("onJump"), !1;
|
|
97
|
+
}, g = () => (r.isStarted === !1 && (c({ type: "start" }), o.current.reset()), c({ type: "play" }), p("onStart"), !1), J = () => (c({ type: "pause" }), p("onPause"), !1), z = () => (r.currentFrame === u.length - 1 && r.currentTime === m && (c({ type: "reset" }), o.current.reset()), p("onPlay"), g());
|
|
98
|
+
return b(() => {
|
|
99
|
+
if (o.current) {
|
|
100
|
+
if (d.current)
|
|
101
|
+
try {
|
|
102
|
+
M(d.current.getBoundingClientRect().width);
|
|
103
|
+
} catch {
|
|
126
104
|
}
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
const onStart = () => {
|
|
168
|
-
if (state.isStarted === false) {
|
|
169
|
-
dispatch({
|
|
170
|
-
type: 'start'
|
|
171
|
-
});
|
|
172
|
-
terminal.current.reset();
|
|
173
|
-
}
|
|
174
|
-
dispatch({
|
|
175
|
-
type: 'play'
|
|
176
|
-
});
|
|
177
|
-
emitEvent('onStart');
|
|
178
|
-
return false;
|
|
179
|
-
};
|
|
180
|
-
const onPause = () => {
|
|
181
|
-
dispatch({
|
|
182
|
-
type: 'pause'
|
|
183
|
-
});
|
|
184
|
-
emitEvent('onPause');
|
|
185
|
-
return false;
|
|
186
|
-
};
|
|
187
|
-
const onPlay = () => {
|
|
188
|
-
if (state.currentFrame === frames.length - 1 && state.currentTime === totalDuration) {
|
|
189
|
-
dispatch({
|
|
190
|
-
type: 'reset'
|
|
191
|
-
});
|
|
192
|
-
terminal.current.reset();
|
|
193
|
-
}
|
|
194
|
-
emitEvent('onPlay');
|
|
195
|
-
return onStart();
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// Render thumbnailTime
|
|
199
|
-
(0, _react.useEffect)(() => {
|
|
200
|
-
if (!terminal.current) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (container.current) {
|
|
204
|
-
try {
|
|
205
|
-
setMaxWidth(container.current.getBoundingClientRect().width);
|
|
206
|
-
} catch (e) {
|
|
207
|
-
// Do nothing
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
if (options.autoplay) {
|
|
211
|
-
onStart();
|
|
212
|
-
} else {
|
|
213
|
-
doJump(Math.min(Math.abs(options.thumbnailTime), totalDuration));
|
|
214
|
-
}
|
|
215
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
216
|
-
}, []);
|
|
217
|
-
|
|
218
|
-
// Tick intervals
|
|
219
|
-
(0, _useInterval.default)(() => {
|
|
220
|
-
if (state.isRendering) {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
const tickDelay = Date.now() - state.lastTickTime;
|
|
224
|
-
const newState = {};
|
|
225
|
-
if (state.currentTime < totalDuration) {
|
|
226
|
-
newState.currentTime = state.currentTime + tickDelay;
|
|
227
|
-
}
|
|
228
|
-
if (state.currentTime > totalDuration) {
|
|
229
|
-
newState.currentTime = totalDuration;
|
|
230
|
-
}
|
|
231
|
-
const alreadyRendered = (0, _util.isFrameAt)(frames, newState.currentTime, state.currentFrame);
|
|
232
|
-
if (state.currentFrame !== -1 && alreadyRendered) {
|
|
233
|
-
return dispatch({
|
|
234
|
-
type: 'tick',
|
|
235
|
-
payload: newState
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Reached the end
|
|
240
|
-
if (state.currentFrame === frames.length - 1) {
|
|
241
|
-
emitEvent('onComplete');
|
|
242
|
-
if (options.repeat) {
|
|
243
|
-
// console.log('tick.restart', newState, state);
|
|
244
|
-
return dispatch({
|
|
245
|
-
type: 'reset',
|
|
246
|
-
payload: newState
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// console.log('tick.end', newState, state);
|
|
251
|
-
newState.currentTime = 0;
|
|
252
|
-
newState.currentFrame = 0;
|
|
253
|
-
newState.requireReset = true;
|
|
254
|
-
newState.isStarted = false;
|
|
255
|
-
return dispatch({
|
|
256
|
-
type: 'pause',
|
|
257
|
-
payload: newState
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Check if current time belongs to the next frame's duration
|
|
262
|
-
if ((0, _util.isFrameAt)(newState.currentTime, state.currentFrame + 1)) {
|
|
263
|
-
newState.currentFrame = state.currentFrame + 1;
|
|
264
|
-
} else {
|
|
265
|
-
newState.currentFrame = (0, _util.findFrameAt)(frames, newState.currentTime);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// console.log('tick.tick', newState, state);
|
|
269
|
-
dispatch({
|
|
270
|
-
type: 'tickStart',
|
|
271
|
-
payload: newState
|
|
272
|
-
});
|
|
273
|
-
return renderFrame(newState.currentFrame, () => {
|
|
274
|
-
if (state.requireReset) {
|
|
275
|
-
newState.requireReset = false;
|
|
276
|
-
}
|
|
277
|
-
dispatch({
|
|
278
|
-
type: 'tickEnd',
|
|
279
|
-
payload: newState
|
|
280
|
-
});
|
|
281
|
-
return emitEvent('onTick');
|
|
282
|
-
});
|
|
283
|
-
}, state.isPlaying ? 8 : null);
|
|
284
|
-
|
|
285
|
-
// If controls are enabled, we need to disable frameBox
|
|
286
|
-
if (options.controls) {
|
|
287
|
-
options.frameBox.title = null;
|
|
288
|
-
options.frameBox.type = null;
|
|
289
|
-
options.frameBox.style = {};
|
|
290
|
-
if (options.theme.background === 'transparent') {
|
|
291
|
-
options.frameBox.style.background = 'black';
|
|
292
|
-
} else {
|
|
293
|
-
options.frameBox.style.background = options.theme.background;
|
|
294
|
-
}
|
|
295
|
-
options.frameBox.style.padding = '10px';
|
|
296
|
-
options.frameBox.style.paddingBottom = '40px';
|
|
297
|
-
}
|
|
298
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
299
|
-
className: (0, _util.getPlayerClass)(options, state),
|
|
300
|
-
ref: container,
|
|
301
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
302
|
-
className: "cover",
|
|
303
|
-
onClick: onStart
|
|
304
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
305
|
-
className: "start",
|
|
306
|
-
onClick: onStart,
|
|
307
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
|
|
308
|
-
style: {
|
|
309
|
-
enableBackground: 'new 0 0 30 30'
|
|
310
|
-
},
|
|
311
|
-
viewBox: "0 0 30 30",
|
|
312
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("polygon", {
|
|
313
|
-
points: "6.583,3.186 5,4.004 5,15 26,15 26.483,14.128 "
|
|
314
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("polygon", {
|
|
315
|
-
points: "6.583,26.814 5,25.996 5,15 26,15 26.483,15.872 "
|
|
316
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", {
|
|
317
|
-
cx: "26",
|
|
318
|
-
cy: "15",
|
|
319
|
-
r: "1"
|
|
320
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", {
|
|
321
|
-
cx: "6",
|
|
322
|
-
cy: "4",
|
|
323
|
-
r: "1"
|
|
324
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", {
|
|
325
|
-
cx: "6",
|
|
326
|
-
cy: "26",
|
|
327
|
-
r: "1"
|
|
328
|
-
})]
|
|
329
|
-
})
|
|
330
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
331
|
-
className: "terminal",
|
|
332
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
333
|
-
className: (0, _util.getFrameClass)(options),
|
|
334
|
-
style: options.frameBox.style || {},
|
|
335
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
336
|
-
className: "terminal-titlebar",
|
|
337
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
338
|
-
className: "buttons",
|
|
339
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
340
|
-
className: "close-button"
|
|
341
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
342
|
-
className: "minimize-button"
|
|
343
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
344
|
-
className: "maximize-button"
|
|
345
|
-
})]
|
|
346
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
347
|
-
className: "title",
|
|
348
|
-
children: options.frameBox.title || ''
|
|
349
|
-
})]
|
|
350
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
351
|
-
className: "terminal-body",
|
|
352
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Terminal.default, {
|
|
353
|
-
ref: terminal,
|
|
354
|
-
options: terminalOptions
|
|
355
|
-
})
|
|
356
|
-
})]
|
|
357
|
-
})
|
|
358
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
359
|
-
className: "controller",
|
|
360
|
-
children: [state.isPlaying && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
361
|
-
className: "pause",
|
|
362
|
-
onClick: onPause,
|
|
363
|
-
title: "Pause",
|
|
364
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
365
|
-
className: "icon"
|
|
366
|
-
})
|
|
367
|
-
}), !state.isPlaying && state.isStarted && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
368
|
-
className: "play",
|
|
369
|
-
onClick: onPlay,
|
|
370
|
-
title: "Play",
|
|
371
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
372
|
-
className: "icon"
|
|
373
|
-
})
|
|
374
|
-
}), !state.isPlaying && !state.isStarted && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
375
|
-
className: "play",
|
|
376
|
-
onClick: onStart,
|
|
377
|
-
title: "Start",
|
|
378
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
379
|
-
className: "icon"
|
|
380
|
-
})
|
|
381
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
382
|
-
className: "timer",
|
|
383
|
-
children: (0, _util.formatTime)(state.currentTime)
|
|
384
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
385
|
-
className: "progressbar-wrapper",
|
|
386
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
387
|
-
className: "progressbar",
|
|
388
|
-
ref: progress,
|
|
389
|
-
onClick: onJump,
|
|
390
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
391
|
-
className: "progress",
|
|
392
|
-
style: {
|
|
393
|
-
width: "".concat(state.currentTime / totalDuration * 100, "%")
|
|
394
|
-
}
|
|
395
|
-
})
|
|
396
|
-
})
|
|
397
|
-
})]
|
|
398
|
-
})]
|
|
399
|
-
});
|
|
105
|
+
t.autoplay ? g() : N(Math.min(Math.abs(t.thumbnailTime), m));
|
|
106
|
+
}
|
|
107
|
+
}, []), H(
|
|
108
|
+
() => {
|
|
109
|
+
if (r.isRendering)
|
|
110
|
+
return !1;
|
|
111
|
+
const a = Date.now() - r.lastTickTime, e = {};
|
|
112
|
+
r.currentTime < m && (e.currentTime = r.currentTime + a), r.currentTime > m && (e.currentTime = m);
|
|
113
|
+
const s = F(u, e.currentTime, r.currentFrame);
|
|
114
|
+
return r.currentFrame !== -1 && s ? c({ type: "tick", payload: e }) : r.currentFrame === u.length - 1 ? (p("onComplete"), t.repeat ? c({ type: "reset", payload: e }) : (e.currentTime = 0, e.currentFrame = 0, e.requireReset = !0, e.isStarted = !1, c({ type: "pause", payload: e }))) : (F(e.currentTime, r.currentFrame + 1) ? e.currentFrame = r.currentFrame + 1 : e.currentFrame = P(u, e.currentTime), c({ type: "tickStart", payload: e }), w(e.currentFrame, () => (r.requireReset && (e.requireReset = !1), c({ type: "tickEnd", payload: e }), p("onTick"))));
|
|
115
|
+
},
|
|
116
|
+
r.isPlaying ? 8 : null
|
|
117
|
+
), t.controls && (t.frameBox.title = null, t.frameBox.type = null, t.frameBox.style = {}, t.theme.background === "transparent" ? t.frameBox.style.background = "black" : t.frameBox.style.background = t.theme.background, t.frameBox.style.padding = "10px", t.frameBox.style.paddingBottom = "40px"), /* @__PURE__ */ f("div", { className: _(t, r), ref: d, children: [
|
|
118
|
+
/* @__PURE__ */ n("div", { className: "cover", onClick: g }),
|
|
119
|
+
/* @__PURE__ */ n("div", { className: "start", onClick: g, children: /* @__PURE__ */ f("svg", { style: { enableBackground: "new 0 0 30 30" }, viewBox: "0 0 30 30", children: [
|
|
120
|
+
/* @__PURE__ */ n("polygon", { points: "6.583,3.186 5,4.004 5,15 26,15 26.483,14.128 " }),
|
|
121
|
+
/* @__PURE__ */ n("polygon", { points: "6.583,26.814 5,25.996 5,15 26,15 26.483,15.872 " }),
|
|
122
|
+
/* @__PURE__ */ n("circle", { cx: "26", cy: "15", r: "1" }),
|
|
123
|
+
/* @__PURE__ */ n("circle", { cx: "6", cy: "4", r: "1" }),
|
|
124
|
+
/* @__PURE__ */ n("circle", { cx: "6", cy: "26", r: "1" })
|
|
125
|
+
] }) }),
|
|
126
|
+
/* @__PURE__ */ n("div", { className: "terminal", children: /* @__PURE__ */ f("div", { className: $(t), style: t.frameBox.style || {}, children: [
|
|
127
|
+
/* @__PURE__ */ f("div", { className: "terminal-titlebar", children: [
|
|
128
|
+
/* @__PURE__ */ f("div", { className: "buttons", children: [
|
|
129
|
+
/* @__PURE__ */ n("div", { className: "close-button" }),
|
|
130
|
+
/* @__PURE__ */ n("div", { className: "minimize-button" }),
|
|
131
|
+
/* @__PURE__ */ n("div", { className: "maximize-button" })
|
|
132
|
+
] }),
|
|
133
|
+
/* @__PURE__ */ n("div", { className: "title", children: t.frameBox.title || "" })
|
|
134
|
+
] }),
|
|
135
|
+
/* @__PURE__ */ n("div", { className: "terminal-body", children: /* @__PURE__ */ n(A, { ref: o, options: R }) })
|
|
136
|
+
] }) }),
|
|
137
|
+
/* @__PURE__ */ f("div", { className: "controller", children: [
|
|
138
|
+
r.isPlaying && /* @__PURE__ */ n("div", { className: "pause", onClick: J, title: "Pause", children: /* @__PURE__ */ n("span", { className: "icon" }) }),
|
|
139
|
+
!r.isPlaying && r.isStarted && /* @__PURE__ */ n("div", { className: "play", onClick: z, title: "Play", children: /* @__PURE__ */ n("span", { className: "icon" }) }),
|
|
140
|
+
!r.isPlaying && !r.isStarted && /* @__PURE__ */ n("div", { className: "play", onClick: g, title: "Start", children: /* @__PURE__ */ n("span", { className: "icon" }) }),
|
|
141
|
+
/* @__PURE__ */ n("div", { className: "timer", children: G(r.currentTime) }),
|
|
142
|
+
/* @__PURE__ */ n("div", { className: "progressbar-wrapper", children: /* @__PURE__ */ n("div", { className: "progressbar", ref: k, onClick: q, children: /* @__PURE__ */ n("div", { className: "progress", style: { width: `${r.currentTime / m * 100}%` } }) }) })
|
|
143
|
+
] })
|
|
144
|
+
] });
|
|
400
145
|
}
|
|
401
|
-
|
|
402
|
-
frames:
|
|
403
|
-
options:
|
|
404
|
-
onComplete:
|
|
405
|
-
onStart:
|
|
406
|
-
onStop:
|
|
407
|
-
onPause:
|
|
408
|
-
onTick:
|
|
409
|
-
onJump:
|
|
146
|
+
K.propTypes = {
|
|
147
|
+
frames: l.array.isRequired,
|
|
148
|
+
options: l.object.isRequired,
|
|
149
|
+
onComplete: l.func,
|
|
150
|
+
onStart: l.func,
|
|
151
|
+
onStop: l.func,
|
|
152
|
+
onPause: l.func,
|
|
153
|
+
onTick: l.func,
|
|
154
|
+
onJump: l.func
|
|
155
|
+
};
|
|
156
|
+
export {
|
|
157
|
+
K as default
|
|
410
158
|
};
|
|
411
|
-
Player.defaultProps = {
|
|
412
|
-
onComplete: _noop.default,
|
|
413
|
-
onStart: _noop.default,
|
|
414
|
-
onStop: _noop.default,
|
|
415
|
-
onPause: _noop.default,
|
|
416
|
-
onTick: _noop.default,
|
|
417
|
-
onJump: _noop.default
|
|
418
|
-
};
|