@midscene/visualizer 0.26.2 → 0.26.3-beta-20250813021342.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/blank_polyfill.mjs +2 -0
- package/dist/es/component/blackboard.css +12 -5
- package/dist/es/component/blackboard.mjs +266 -0
- package/dist/es/component/color.mjs +35 -0
- package/dist/es/component/describer.css +9 -5
- package/dist/es/component/describer.mjs +128 -0
- package/dist/es/component/env-config.mjs +112 -0
- package/dist/es/component/github-star.css +1 -0
- package/dist/es/component/github-star.mjs +20 -0
- package/dist/es/component/logo.css +5 -3
- package/dist/es/component/logo.mjs +20 -0
- package/dist/es/component/misc.mjs +54 -0
- package/dist/es/component/pixi-loader.mjs +16 -0
- package/dist/es/component/player.css +88 -70
- package/dist/es/component/player.mjs +628 -0
- package/dist/es/component/playground/ConfigSelector.mjs +53 -0
- package/dist/es/component/playground/ContextPreview.mjs +39 -0
- package/dist/es/component/playground/HistorySelector.mjs +193 -0
- package/dist/es/component/playground/PlaygroundResult.mjs +60 -0
- package/dist/es/component/playground/PromptInput.mjs +225 -0
- package/dist/es/component/playground/ServiceModeControl.mjs +100 -0
- package/dist/es/component/playground/index.css +140 -98
- package/dist/es/component/playground/playground-constants.mjs +45 -0
- package/dist/es/component/playground/playground-utils.mjs +89 -0
- package/dist/es/component/playground/useServerValid.mjs +27 -0
- package/dist/es/component/playground/useStaticPageAgent.mjs +12 -0
- package/dist/es/component/replay-scripts.mjs +271 -0
- package/dist/es/component/shiny-text.css +33 -22
- package/dist/es/component/shiny-text.mjs +15 -0
- package/dist/es/component/store/history.mjs +55 -0
- package/dist/es/component/store/store.mjs +128 -0
- package/dist/es/icons/close.mjs +19 -0
- package/dist/es/icons/history.mjs +30 -0
- package/dist/es/icons/magnifying-glass.mjs +39 -0
- package/dist/es/icons/setting.mjs +20 -0
- package/dist/es/index.mjs +21 -0
- package/dist/es/init.mjs +10 -0
- package/dist/es/{utils.js → utils.mjs} +51 -75
- package/dist/lib/blank_polyfill.js +34 -38
- package/dist/lib/component/blackboard.css +12 -5
- package/dist/lib/component/blackboard.js +293 -306
- package/dist/lib/component/color.js +64 -74
- package/dist/lib/component/describer.css +9 -5
- package/dist/lib/component/describer.js +158 -198
- package/dist/lib/component/env-config.js +142 -147
- package/dist/lib/component/github-star.css +1 -0
- package/dist/lib/component/github-star.js +51 -62
- package/dist/lib/component/logo.css +5 -3
- package/dist/lib/component/logo.js +53 -56
- package/dist/lib/component/misc.js +85 -84
- package/dist/lib/component/pixi-loader.js +49 -80
- package/dist/lib/component/player.css +88 -70
- package/dist/lib/component/player.js +627 -738
- package/dist/lib/component/playground/ConfigSelector.js +91 -92
- package/dist/lib/component/playground/ContextPreview.js +80 -72
- package/dist/lib/component/playground/HistorySelector.js +234 -197
- package/dist/lib/component/playground/PlaygroundResult.js +100 -103
- package/dist/lib/component/playground/PromptInput.js +250 -237
- package/dist/lib/component/playground/ServiceModeControl.js +124 -124
- package/dist/lib/component/playground/index.css +140 -98
- package/dist/lib/component/playground/playground-constants.js +97 -73
- package/dist/lib/component/playground/playground-types.js +17 -31
- package/dist/lib/component/playground/playground-utils.js +140 -168
- package/dist/lib/component/playground/useServerValid.js +55 -86
- package/dist/lib/component/playground/useStaticPageAgent.js +45 -51
- package/dist/lib/component/replay-scripts.js +291 -373
- package/dist/lib/component/shiny-text.css +33 -22
- package/dist/lib/component/shiny-text.js +46 -57
- package/dist/lib/component/store/history.js +58 -64
- package/dist/lib/component/store/store.js +132 -128
- package/dist/lib/icons/close.js +53 -0
- package/dist/lib/icons/history.js +64 -0
- package/dist/lib/icons/magnifying-glass.js +73 -0
- package/dist/lib/icons/setting.js +54 -0
- package/dist/lib/index.js +158 -124
- package/dist/lib/init.js +39 -46
- package/dist/lib/utils.js +105 -109
- package/dist/types/blank_polyfill.d.ts +2 -2
- package/dist/types/component/playground/ConfigSelector.d.ts +1 -0
- package/dist/types/component/playground/ContextPreview.d.ts +1 -0
- package/dist/types/component/playground/HistorySelector.d.ts +1 -0
- package/dist/types/component/playground/PlaygroundResult.d.ts +1 -0
- package/dist/types/component/playground/PromptInput.d.ts +1 -0
- package/dist/types/component/playground/ServiceModeControl.d.ts +1 -0
- package/package.json +16 -18
- package/dist/es/assets/close.909351c0.svg +0 -4
- package/dist/es/assets/history.164a4eab.svg +0 -4
- package/dist/es/assets/magnifying-glass.9498e70e.svg +0 -12
- package/dist/es/assets/setting.80ab7285.svg +0 -11
- package/dist/es/blank_polyfill.js +0 -10
- package/dist/es/component/blackboard.js +0 -286
- package/dist/es/component/color.js +0 -49
- package/dist/es/component/describer.js +0 -173
- package/dist/es/component/env-config.js +0 -117
- package/dist/es/component/github-star.js +0 -31
- package/dist/es/component/logo.js +0 -25
- package/dist/es/component/misc.js +0 -63
- package/dist/es/component/pixi-loader.js +0 -51
- package/dist/es/component/player.js +0 -746
- package/dist/es/component/playground/ConfigSelector.js +0 -64
- package/dist/es/component/playground/ContextPreview.js +0 -42
- package/dist/es/component/playground/HistorySelector.js +0 -168
- package/dist/es/component/playground/PlaygroundResult.js +0 -73
- package/dist/es/component/playground/PromptInput.js +0 -212
- package/dist/es/component/playground/ServiceModeControl.js +0 -100
- package/dist/es/component/playground/playground-constants.js +0 -39
- package/dist/es/component/playground/playground-types.js +0 -6
- package/dist/es/component/playground/playground-utils.js +0 -141
- package/dist/es/component/playground/useServerValid.js +0 -58
- package/dist/es/component/playground/useStaticPageAgent.js +0 -20
- package/dist/es/component/replay-scripts.js +0 -361
- package/dist/es/component/shiny-text.js +0 -30
- package/dist/es/component/store/history.js +0 -34
- package/dist/es/component/store/store.js +0 -99
- package/dist/es/index.js +0 -79
- package/dist/es/init.js +0 -17
- package/dist/index.css +0 -595
- package/dist/index.js +0 -1
- package/dist/lib/assets/close.909351c0.svg +0 -4
- package/dist/lib/assets/history.164a4eab.svg +0 -4
- package/dist/lib/assets/magnifying-glass.9498e70e.svg +0 -12
- package/dist/lib/assets/setting.80ab7285.svg +0 -11
- package/dist/lib/component/common.css +0 -0
- /package/dist/es/component/{common.css → playground/playground-types.mjs} +0 -0
|
@@ -1,773 +1,662 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __export = (target, all) => {
|
|
24
|
-
for (var name in all)
|
|
25
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
-
};
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (let key of __getOwnPropNames(from))
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
-
}
|
|
33
|
-
return to;
|
|
34
|
-
};
|
|
35
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
36
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
37
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
38
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
39
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
40
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
41
|
-
mod
|
|
42
|
-
));
|
|
43
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
44
|
-
var __publicField = (obj, key, value) => {
|
|
45
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
46
|
-
return value;
|
|
47
|
-
};
|
|
48
|
-
var __async = (__this, __arguments, generator) => {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
var fulfilled = (value) => {
|
|
51
|
-
try {
|
|
52
|
-
step(generator.next(value));
|
|
53
|
-
} catch (e) {
|
|
54
|
-
reject(e);
|
|
55
|
-
}
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
56
10
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
63
23
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
__export(player_exports, {
|
|
70
|
-
Player: () => Player
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
Player: ()=>Player
|
|
71
29
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
30
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
31
|
+
require("pixi.js/unsafe-eval");
|
|
32
|
+
const external_pixi_js_namespaceObject = require("pixi.js");
|
|
33
|
+
const external_react_namespaceObject = require("react");
|
|
34
|
+
require("./player.css");
|
|
35
|
+
const external_utils_js_namespaceObject = require("../utils.js");
|
|
36
|
+
const icons_namespaceObject = require("@ant-design/icons");
|
|
37
|
+
const extractor_namespaceObject = require("@midscene/shared/extractor");
|
|
38
|
+
const external_antd_namespaceObject = require("antd");
|
|
39
|
+
const external_blackboard_js_namespaceObject = require("./blackboard.js");
|
|
40
|
+
const external_pixi_loader_js_namespaceObject = require("./pixi-loader.js");
|
|
41
|
+
function _define_property(obj, key, value) {
|
|
42
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
43
|
+
value: value,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true
|
|
47
|
+
});
|
|
48
|
+
else obj[key] = value;
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
90
51
|
const canvasPaddingLeft = 0;
|
|
91
52
|
const canvasPaddingTop = 0;
|
|
92
|
-
const cubicBezier = (t, p0, p1, p2, p3)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
const cubicImage = (t) => {
|
|
97
|
-
return linear(t);
|
|
98
|
-
};
|
|
99
|
-
const cubicInsightElement = (t) => {
|
|
100
|
-
return cubicBezier(t, 0, 0.5, 0.5, 1);
|
|
53
|
+
const cubicBezier = (t, p0, p1, p2, p3)=>{
|
|
54
|
+
const t2 = 1 - t;
|
|
55
|
+
return p0 * t2 * t2 * t2 + 3 * p1 * t * t2 * t2 + 3 * p2 * t * t * t2 + p3 * t * t * t;
|
|
101
56
|
};
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const linear = (t)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
57
|
+
const cubicImage = (t)=>linear(t);
|
|
58
|
+
const cubicInsightElement = (t)=>cubicBezier(t, 0, 0.5, 0.5, 1);
|
|
59
|
+
const cubicMouse = (t)=>linear(t);
|
|
60
|
+
const linear = (t)=>t;
|
|
61
|
+
const sleep = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
62
|
+
const ERROR_FRAME_CANCEL = 'frame cancel (this is an error on purpose)';
|
|
63
|
+
const frameKit = ()=>{
|
|
64
|
+
let cancelFlag = false;
|
|
65
|
+
return {
|
|
66
|
+
frame: (callback)=>{
|
|
67
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
68
|
+
requestAnimationFrame(()=>{
|
|
69
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
70
|
+
callback(performance.now());
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
timeout: (callback, ms)=>{
|
|
74
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
75
|
+
setTimeout(()=>{
|
|
76
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
77
|
+
callback();
|
|
78
|
+
}, ms);
|
|
79
|
+
},
|
|
80
|
+
cancel: ()=>{
|
|
81
|
+
cancelFlag = true;
|
|
122
82
|
}
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
},
|
|
126
|
-
timeout: (callback, ms) => {
|
|
127
|
-
if (cancelFlag) {
|
|
128
|
-
throw new Error(ERROR_FRAME_CANCEL);
|
|
129
|
-
}
|
|
130
|
-
setTimeout(() => {
|
|
131
|
-
if (cancelFlag) {
|
|
132
|
-
throw new Error(ERROR_FRAME_CANCEL);
|
|
133
|
-
}
|
|
134
|
-
callback();
|
|
135
|
-
}, ms);
|
|
136
|
-
},
|
|
137
|
-
cancel: () => {
|
|
138
|
-
cancelFlag = true;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
83
|
+
};
|
|
141
84
|
};
|
|
142
85
|
const singleElementFadeInDuration = 80;
|
|
143
86
|
const LAYER_ORDER_IMG = 0;
|
|
144
87
|
const LAYER_ORDER_INSIGHT = 1;
|
|
145
88
|
const LAYER_ORDER_POINTER = 2;
|
|
146
89
|
const LAYER_ORDER_SPINNING_POINTER = 3;
|
|
147
|
-
const downloadReport = (content)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
90
|
+
const downloadReport = (content)=>{
|
|
91
|
+
const blob = new Blob([
|
|
92
|
+
content
|
|
93
|
+
], {
|
|
94
|
+
type: 'text/html'
|
|
95
|
+
});
|
|
96
|
+
const url = URL.createObjectURL(blob);
|
|
97
|
+
const a = document.createElement('a');
|
|
98
|
+
a.href = url;
|
|
99
|
+
a.download = 'midscene_report.html';
|
|
100
|
+
a.click();
|
|
154
101
|
};
|
|
155
102
|
class RecordingSession {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
mimeType: "video/webm"
|
|
168
|
-
});
|
|
169
|
-
mediaRecorder.ondataavailable = (event) => {
|
|
170
|
-
if (event.data.size > 0) {
|
|
171
|
-
this.chunks.push(event.data);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
this.mediaRecorder = mediaRecorder;
|
|
175
|
-
this.recording = true;
|
|
176
|
-
return this.mediaRecorder.start();
|
|
177
|
-
}
|
|
178
|
-
stop() {
|
|
179
|
-
var _a;
|
|
180
|
-
if (!this.recording || !this.mediaRecorder) {
|
|
181
|
-
import_console_browserify.default.warn("not recording");
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
this.mediaRecorder.onstop = () => {
|
|
185
|
-
const blob = new Blob(this.chunks, { type: "video/webm" });
|
|
186
|
-
const url = URL.createObjectURL(blob);
|
|
187
|
-
const a = document.createElement("a");
|
|
188
|
-
a.href = url;
|
|
189
|
-
a.download = "midscene_replay.webm";
|
|
190
|
-
a.click();
|
|
191
|
-
URL.revokeObjectURL(url);
|
|
192
|
-
};
|
|
193
|
-
(_a = this.mediaRecorder) == null ? void 0 : _a.stop();
|
|
194
|
-
this.recording = false;
|
|
195
|
-
this.mediaRecorder = null;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
function Player(props) {
|
|
199
|
-
var _a;
|
|
200
|
-
const [titleText, setTitleText] = (0, import_react.useState)("");
|
|
201
|
-
const [subTitleText, setSubTitleText] = (0, import_react.useState)("");
|
|
202
|
-
const scripts = props == null ? void 0 : props.replayScripts;
|
|
203
|
-
const imageWidth = (props == null ? void 0 : props.imageWidth) || 1920;
|
|
204
|
-
const imageHeight = (props == null ? void 0 : props.imageHeight) || 1080;
|
|
205
|
-
const fitMode = (props == null ? void 0 : props.fitMode) || "height";
|
|
206
|
-
const currentImg = (0, import_react.useRef)(((_a = scripts == null ? void 0 : scripts[0]) == null ? void 0 : _a.img) || null);
|
|
207
|
-
const divContainerRef = (0, import_react.useRef)(null);
|
|
208
|
-
const app = (0, import_react.useMemo)(() => new PIXI.Application(), []);
|
|
209
|
-
const pointerSprite = (0, import_react.useRef)(null);
|
|
210
|
-
const spinningPointerSprite = (0, import_react.useRef)(null);
|
|
211
|
-
const [replayMark, setReplayMark] = (0, import_react.useState)(0);
|
|
212
|
-
const triggerReplay = () => {
|
|
213
|
-
setReplayMark(Date.now());
|
|
214
|
-
};
|
|
215
|
-
const windowContentContainer = (0, import_react.useMemo)(() => {
|
|
216
|
-
const container = new PIXI.Container();
|
|
217
|
-
return container;
|
|
218
|
-
}, []);
|
|
219
|
-
const insightMarkContainer = (0, import_react.useMemo)(() => {
|
|
220
|
-
const container = new PIXI.Container();
|
|
221
|
-
container.zIndex = LAYER_ORDER_INSIGHT;
|
|
222
|
-
return container;
|
|
223
|
-
}, []);
|
|
224
|
-
const basicCameraState = {
|
|
225
|
-
left: 0,
|
|
226
|
-
top: 0,
|
|
227
|
-
width: imageWidth,
|
|
228
|
-
pointerLeft: Math.round(imageWidth / 2),
|
|
229
|
-
pointerTop: Math.round(imageHeight / 2)
|
|
230
|
-
};
|
|
231
|
-
const [animationProgress, setAnimationProgress] = (0, import_react.useState)(-1);
|
|
232
|
-
const cancelFlag = (0, import_react.useRef)(false);
|
|
233
|
-
(0, import_react.useEffect)(() => {
|
|
234
|
-
cancelFlag.current = false;
|
|
235
|
-
return () => {
|
|
236
|
-
cancelFlag.current = true;
|
|
237
|
-
};
|
|
238
|
-
}, []);
|
|
239
|
-
const cameraState = (0, import_react.useRef)(__spreadValues({}, basicCameraState));
|
|
240
|
-
const repaintImage = () => __async(this, null, function* () {
|
|
241
|
-
const imgToUpdate = currentImg.current;
|
|
242
|
-
if (!imgToUpdate) {
|
|
243
|
-
import_console_browserify.default.warn("no image to update");
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (!(0, import_pixi_loader.getTextureFromCache)(imgToUpdate)) {
|
|
247
|
-
import_console_browserify.default.warn("image not loaded", imgToUpdate);
|
|
248
|
-
yield (0, import_pixi_loader.loadTexture)(imgToUpdate);
|
|
249
|
-
}
|
|
250
|
-
const texture = (0, import_pixi_loader.getTextureFromCache)(imgToUpdate);
|
|
251
|
-
if (!texture) {
|
|
252
|
-
throw new Error("texture not found");
|
|
253
|
-
}
|
|
254
|
-
const sprite = PIXI.Sprite.from(texture);
|
|
255
|
-
if (!sprite) {
|
|
256
|
-
throw new Error("sprite not found");
|
|
103
|
+
start() {
|
|
104
|
+
const stream = this.canvas.captureStream(60);
|
|
105
|
+
const mediaRecorder = new MediaRecorder(stream, {
|
|
106
|
+
mimeType: 'video/webm'
|
|
107
|
+
});
|
|
108
|
+
mediaRecorder.ondataavailable = (event)=>{
|
|
109
|
+
if (event.data.size > 0) this.chunks.push(event.data);
|
|
110
|
+
};
|
|
111
|
+
this.mediaRecorder = mediaRecorder;
|
|
112
|
+
this.recording = true;
|
|
113
|
+
return this.mediaRecorder.start();
|
|
257
114
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
115
|
+
stop() {
|
|
116
|
+
var _this_mediaRecorder;
|
|
117
|
+
if (!this.recording || !this.mediaRecorder) return void console.warn('not recording');
|
|
118
|
+
this.mediaRecorder.onstop = ()=>{
|
|
119
|
+
const blob = new Blob(this.chunks, {
|
|
120
|
+
type: 'video/webm'
|
|
121
|
+
});
|
|
122
|
+
const url = URL.createObjectURL(blob);
|
|
123
|
+
const a = document.createElement('a');
|
|
124
|
+
a.href = url;
|
|
125
|
+
a.download = 'midscene_replay.webm';
|
|
126
|
+
a.click();
|
|
127
|
+
URL.revokeObjectURL(url);
|
|
128
|
+
};
|
|
129
|
+
null == (_this_mediaRecorder = this.mediaRecorder) || _this_mediaRecorder.stop();
|
|
130
|
+
this.recording = false;
|
|
131
|
+
this.mediaRecorder = null;
|
|
262
132
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
var _a2, _b;
|
|
271
|
-
if (!spinningPointerSprite.current) {
|
|
272
|
-
spinningPointerSprite.current = PIXI.Sprite.from(import_utils.mouseLoading);
|
|
273
|
-
spinningPointerSprite.current.zIndex = LAYER_ORDER_SPINNING_POINTER;
|
|
274
|
-
spinningPointerSprite.current.anchor.set(0.5, 0.5);
|
|
275
|
-
spinningPointerSprite.current.scale.set(0.5);
|
|
276
|
-
spinningPointerSprite.current.label = "spinning-pointer";
|
|
133
|
+
constructor(canvas){
|
|
134
|
+
_define_property(this, "canvas", void 0);
|
|
135
|
+
_define_property(this, "mediaRecorder", null);
|
|
136
|
+
_define_property(this, "chunks", void 0);
|
|
137
|
+
_define_property(this, "recording", false);
|
|
138
|
+
this.canvas = canvas;
|
|
139
|
+
this.chunks = [];
|
|
277
140
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
141
|
+
}
|
|
142
|
+
function Player(props) {
|
|
143
|
+
var _scripts_;
|
|
144
|
+
const [titleText, setTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
145
|
+
const [subTitleText, setSubTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
146
|
+
const scripts = null == props ? void 0 : props.replayScripts;
|
|
147
|
+
const imageWidth = (null == props ? void 0 : props.imageWidth) || 1920;
|
|
148
|
+
const imageHeight = (null == props ? void 0 : props.imageHeight) || 1080;
|
|
149
|
+
const fitMode = (null == props ? void 0 : props.fitMode) || 'height';
|
|
150
|
+
const currentImg = (0, external_react_namespaceObject.useRef)((null == scripts ? void 0 : null == (_scripts_ = scripts[0]) ? void 0 : _scripts_.img) || null);
|
|
151
|
+
const divContainerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
152
|
+
const app = (0, external_react_namespaceObject.useMemo)(()=>new external_pixi_js_namespaceObject.Application(), []);
|
|
153
|
+
const pointerSprite = (0, external_react_namespaceObject.useRef)(null);
|
|
154
|
+
const spinningPointerSprite = (0, external_react_namespaceObject.useRef)(null);
|
|
155
|
+
const [replayMark, setReplayMark] = (0, external_react_namespaceObject.useState)(0);
|
|
156
|
+
const triggerReplay = ()=>{
|
|
157
|
+
setReplayMark(Date.now());
|
|
295
158
|
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
159
|
+
const windowContentContainer = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
160
|
+
const container = new external_pixi_js_namespaceObject.Container();
|
|
161
|
+
return container;
|
|
162
|
+
}, []);
|
|
163
|
+
const insightMarkContainer = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
164
|
+
const container = new external_pixi_js_namespaceObject.Container();
|
|
165
|
+
container.zIndex = LAYER_ORDER_INSIGHT;
|
|
166
|
+
return container;
|
|
167
|
+
}, []);
|
|
168
|
+
const basicCameraState = {
|
|
169
|
+
left: 0,
|
|
170
|
+
top: 0,
|
|
171
|
+
width: imageWidth,
|
|
172
|
+
pointerLeft: Math.round(imageWidth / 2),
|
|
173
|
+
pointerTop: Math.round(imageHeight / 2)
|
|
302
174
|
};
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
throw new Error("texture not found");
|
|
314
|
-
}
|
|
315
|
-
const sprite = PIXI.Sprite.from(texture);
|
|
316
|
-
let targetX = (_a2 = pointerSprite.current) == null ? void 0 : _a2.x;
|
|
317
|
-
let targetY = (_b = pointerSprite.current) == null ? void 0 : _b.y;
|
|
318
|
-
if (typeof x === "number") {
|
|
319
|
-
targetX = x;
|
|
320
|
-
}
|
|
321
|
-
if (typeof y === "number") {
|
|
322
|
-
targetY = y;
|
|
323
|
-
}
|
|
324
|
-
if (typeof targetX === "undefined" || typeof targetY === "undefined") {
|
|
325
|
-
import_console_browserify.default.warn("invalid pointer position", x, y);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (pointerSprite.current) {
|
|
329
|
-
const pointer = windowContentContainer.getChildByLabel("pointer");
|
|
330
|
-
if (pointer) {
|
|
331
|
-
windowContentContainer.removeChild(pointer);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
pointerSprite.current = sprite;
|
|
335
|
-
pointerSprite.current.x = targetX;
|
|
336
|
-
pointerSprite.current.y = targetY;
|
|
337
|
-
pointerSprite.current.label = "pointer";
|
|
338
|
-
pointerSprite.current.zIndex = LAYER_ORDER_POINTER;
|
|
339
|
-
windowContentContainer.addChild(pointerSprite.current);
|
|
340
|
-
});
|
|
341
|
-
const updateCamera = (state) => {
|
|
342
|
-
cameraState.current = state;
|
|
343
|
-
const newScale = Math.max(1, imageWidth / state.width);
|
|
344
|
-
windowContentContainer.scale.set(newScale);
|
|
345
|
-
windowContentContainer.x = Math.round(
|
|
346
|
-
canvasPaddingLeft - state.left * newScale
|
|
347
|
-
);
|
|
348
|
-
windowContentContainer.y = Math.round(
|
|
349
|
-
canvasPaddingTop - state.top * newScale
|
|
350
|
-
);
|
|
351
|
-
const pointer = windowContentContainer.getChildByLabel("pointer");
|
|
352
|
-
if (pointer) {
|
|
353
|
-
pointer.scale.set(1 / newScale);
|
|
354
|
-
if (typeof state.pointerLeft === "number" && typeof state.pointerTop === "number") {
|
|
355
|
-
pointer.x = state.pointerLeft;
|
|
356
|
-
pointer.y = state.pointerTop;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
const cameraAnimation = (targetState, duration, frame) => __async(this, null, function* () {
|
|
361
|
-
const currentState = __spreadValues({}, cameraState.current);
|
|
362
|
-
const startLeft = currentState.left;
|
|
363
|
-
const startTop = currentState.top;
|
|
364
|
-
const startPointerLeft = currentState.pointerLeft;
|
|
365
|
-
const startPointerTop = currentState.pointerTop;
|
|
366
|
-
const startScale = currentState.width / imageWidth;
|
|
367
|
-
const startTime = performance.now();
|
|
368
|
-
const shouldMovePointer = typeof targetState.pointerLeft === "number" && typeof targetState.pointerTop === "number" && (targetState.pointerLeft !== startPointerLeft || targetState.pointerTop !== startPointerTop);
|
|
369
|
-
const pointerMoveDuration = shouldMovePointer ? duration * 0.375 : 0;
|
|
370
|
-
const cameraMoveStart = pointerMoveDuration;
|
|
371
|
-
const cameraMoveDuration = duration - pointerMoveDuration;
|
|
372
|
-
yield new Promise((resolve) => {
|
|
373
|
-
const animate = (currentTime) => {
|
|
374
|
-
const nextState = __spreadValues({}, cameraState.current);
|
|
375
|
-
const elapsedTime = currentTime - startTime;
|
|
376
|
-
if (shouldMovePointer) {
|
|
377
|
-
if (elapsedTime <= pointerMoveDuration) {
|
|
378
|
-
const rawMouseProgress = Math.min(
|
|
379
|
-
elapsedTime / pointerMoveDuration,
|
|
380
|
-
1
|
|
381
|
-
);
|
|
382
|
-
const mouseProgress = cubicMouse(rawMouseProgress);
|
|
383
|
-
nextState.pointerLeft = startPointerLeft + (targetState.pointerLeft - startPointerLeft) * mouseProgress;
|
|
384
|
-
nextState.pointerTop = startPointerTop + (targetState.pointerTop - startPointerTop) * mouseProgress;
|
|
385
|
-
} else {
|
|
386
|
-
nextState.pointerLeft = targetState.pointerLeft;
|
|
387
|
-
nextState.pointerTop = targetState.pointerTop;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
if (elapsedTime > cameraMoveStart) {
|
|
391
|
-
const cameraElapsedTime = elapsedTime - cameraMoveStart;
|
|
392
|
-
const rawCameraProgress = Math.min(
|
|
393
|
-
cameraElapsedTime / cameraMoveDuration,
|
|
394
|
-
1
|
|
395
|
-
);
|
|
396
|
-
const cameraProgress = cubicImage(rawCameraProgress);
|
|
397
|
-
const targetScale = targetState.width / imageWidth;
|
|
398
|
-
const progressScale = startScale + (targetScale - startScale) * cameraProgress;
|
|
399
|
-
const progressWidth = imageWidth * progressScale;
|
|
400
|
-
const progressHeight = imageHeight * progressScale;
|
|
401
|
-
nextState.width = progressWidth;
|
|
402
|
-
const progressLeft = startLeft + (targetState.left - startLeft) * cameraProgress;
|
|
403
|
-
const progressTop = startTop + (targetState.top - startTop) * cameraProgress;
|
|
404
|
-
const horizontalExceed = progressLeft + progressWidth - imageWidth;
|
|
405
|
-
const verticalExceed = progressTop + progressHeight - imageHeight;
|
|
406
|
-
nextState.left = horizontalExceed > 0 ? progressLeft + horizontalExceed : progressLeft;
|
|
407
|
-
nextState.top = verticalExceed > 0 ? progressTop + verticalExceed : progressTop;
|
|
408
|
-
}
|
|
409
|
-
updateCamera(nextState);
|
|
410
|
-
if (elapsedTime < duration) {
|
|
411
|
-
frame(animate);
|
|
412
|
-
} else {
|
|
413
|
-
resolve();
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
frame(animate);
|
|
175
|
+
const [animationProgress, setAnimationProgress] = (0, external_react_namespaceObject.useState)(-1);
|
|
176
|
+
const cancelFlag = (0, external_react_namespaceObject.useRef)(false);
|
|
177
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
178
|
+
cancelFlag.current = false;
|
|
179
|
+
return ()=>{
|
|
180
|
+
cancelFlag.current = true;
|
|
181
|
+
};
|
|
182
|
+
}, []);
|
|
183
|
+
const cameraState = (0, external_react_namespaceObject.useRef)({
|
|
184
|
+
...basicCameraState
|
|
417
185
|
});
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const progress = Math.min(elapsedTime / duration, 1);
|
|
425
|
-
graphics.alpha = targetAlpha === 0 ? 1 - linear(progress) : linear(progress);
|
|
426
|
-
if (elapsedTime < duration) {
|
|
427
|
-
frame(animate);
|
|
428
|
-
} else {
|
|
429
|
-
resolve();
|
|
186
|
+
const repaintImage = async ()=>{
|
|
187
|
+
const imgToUpdate = currentImg.current;
|
|
188
|
+
if (!imgToUpdate) return void console.warn('no image to update');
|
|
189
|
+
if (!(0, external_pixi_loader_js_namespaceObject.getTextureFromCache)(imgToUpdate)) {
|
|
190
|
+
console.warn('image not loaded', imgToUpdate);
|
|
191
|
+
await (0, external_pixi_loader_js_namespaceObject.loadTexture)(imgToUpdate);
|
|
430
192
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const randomIndex = Math.floor(Math.random() * elementsToAdd.length);
|
|
453
|
-
const element = elementsToAdd.splice(randomIndex, 1)[0];
|
|
454
|
-
if (element) {
|
|
455
|
-
const [insightMarkGraphic] = (0, import_blackboard.rectMarkForItem)(
|
|
456
|
-
element.rect,
|
|
457
|
-
element.content,
|
|
458
|
-
"element"
|
|
459
|
-
);
|
|
460
|
-
insightMarkGraphic.alpha = 0;
|
|
461
|
-
insightMarkContainer.addChild(insightMarkGraphic);
|
|
462
|
-
childrenCount++;
|
|
463
|
-
fadeInGraphics(
|
|
464
|
-
insightMarkGraphic,
|
|
465
|
-
singleElementFadeInDuration,
|
|
466
|
-
frame
|
|
467
|
-
);
|
|
468
|
-
}
|
|
193
|
+
const texture = (0, external_pixi_loader_js_namespaceObject.getTextureFromCache)(imgToUpdate);
|
|
194
|
+
if (!texture) throw new Error('texture not found');
|
|
195
|
+
const sprite = external_pixi_js_namespaceObject.Sprite.from(texture);
|
|
196
|
+
if (!sprite) throw new Error('sprite not found');
|
|
197
|
+
const mainImgLabel = 'main-img';
|
|
198
|
+
const child = windowContentContainer.getChildByLabel(mainImgLabel);
|
|
199
|
+
if (child) windowContentContainer.removeChild(child);
|
|
200
|
+
sprite.label = mainImgLabel;
|
|
201
|
+
sprite.zIndex = LAYER_ORDER_IMG;
|
|
202
|
+
sprite.width = imageWidth;
|
|
203
|
+
sprite.height = imageHeight;
|
|
204
|
+
windowContentContainer.addChild(sprite);
|
|
205
|
+
};
|
|
206
|
+
const spinningPointer = (frame)=>{
|
|
207
|
+
var _pointerSprite_current, _pointerSprite_current1;
|
|
208
|
+
if (!spinningPointerSprite.current) {
|
|
209
|
+
spinningPointerSprite.current = external_pixi_js_namespaceObject.Sprite.from(external_utils_js_namespaceObject.mouseLoading);
|
|
210
|
+
spinningPointerSprite.current.zIndex = LAYER_ORDER_SPINNING_POINTER;
|
|
211
|
+
spinningPointerSprite.current.anchor.set(0.5, 0.5);
|
|
212
|
+
spinningPointerSprite.current.scale.set(0.5);
|
|
213
|
+
spinningPointerSprite.current.label = 'spinning-pointer';
|
|
469
214
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
);
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
);
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
const [insightMarkGraphic] = (0, import_blackboard.rectMarkForItem)(
|
|
497
|
-
element.rect,
|
|
498
|
-
element.content || "",
|
|
499
|
-
"highlight"
|
|
500
|
-
);
|
|
501
|
-
insightMarkGraphic.alpha = 1;
|
|
502
|
-
insightMarkContainer.addChild(insightMarkGraphic);
|
|
503
|
-
});
|
|
504
|
-
resolve();
|
|
215
|
+
spinningPointerSprite.current.x = (null == (_pointerSprite_current = pointerSprite.current) ? void 0 : _pointerSprite_current.x) || 0;
|
|
216
|
+
spinningPointerSprite.current.y = (null == (_pointerSprite_current1 = pointerSprite.current) ? void 0 : _pointerSprite_current1.y) || 0;
|
|
217
|
+
windowContentContainer.addChild(spinningPointerSprite.current);
|
|
218
|
+
let startTime;
|
|
219
|
+
let isCancelled = false;
|
|
220
|
+
const animate = (currentTime)=>{
|
|
221
|
+
if (isCancelled) return;
|
|
222
|
+
if (!startTime) startTime = currentTime;
|
|
223
|
+
const elapsedTime = currentTime - startTime;
|
|
224
|
+
const progress = (Math.sin(elapsedTime / 500 - Math.PI / 2) + 1) / 2;
|
|
225
|
+
const rotation = progress * Math.PI * 2;
|
|
226
|
+
if (spinningPointerSprite.current) spinningPointerSprite.current.rotation = rotation;
|
|
227
|
+
frame(animate);
|
|
228
|
+
};
|
|
229
|
+
frame(animate);
|
|
230
|
+
const stopFn = ()=>{
|
|
231
|
+
if (spinningPointerSprite.current) windowContentContainer.removeChild(spinningPointerSprite.current);
|
|
232
|
+
isCancelled = true;
|
|
233
|
+
};
|
|
234
|
+
return stopFn;
|
|
235
|
+
};
|
|
236
|
+
const updatePointer = async (img, x, y)=>{
|
|
237
|
+
var _pointerSprite_current, _pointerSprite_current1;
|
|
238
|
+
if (!(0, external_pixi_loader_js_namespaceObject.getTextureFromCache)(img)) {
|
|
239
|
+
console.warn('image not loaded', img);
|
|
240
|
+
await (0, external_pixi_loader_js_namespaceObject.loadTexture)(img);
|
|
505
241
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
autoDensity: true,
|
|
518
|
-
antialias: true
|
|
519
|
-
});
|
|
520
|
-
if (!divContainerRef.current)
|
|
521
|
-
return;
|
|
522
|
-
divContainerRef.current.appendChild(app.canvas);
|
|
523
|
-
windowContentContainer.x = 0;
|
|
524
|
-
windowContentContainer.y = 0;
|
|
525
|
-
app.stage.addChild(windowContentContainer);
|
|
526
|
-
insightMarkContainer.x = 0;
|
|
527
|
-
insightMarkContainer.y = 0;
|
|
528
|
-
windowContentContainer.addChild(insightMarkContainer);
|
|
529
|
-
});
|
|
530
|
-
const [isRecording, setIsRecording] = (0, import_react.useState)(false);
|
|
531
|
-
const recorderSessionRef = (0, import_react.useRef)(null);
|
|
532
|
-
const handleExport = () => {
|
|
533
|
-
if (recorderSessionRef.current) {
|
|
534
|
-
import_console_browserify.default.warn("recorderSession exists");
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
if (!app.canvas) {
|
|
538
|
-
import_console_browserify.default.warn("canvas is not initialized");
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
recorderSessionRef.current = new RecordingSession(app.canvas);
|
|
542
|
-
setIsRecording(true);
|
|
543
|
-
triggerReplay();
|
|
544
|
-
};
|
|
545
|
-
const play = () => {
|
|
546
|
-
let cancelFn;
|
|
547
|
-
Promise.resolve(
|
|
548
|
-
(() => __async(this, null, function* () {
|
|
549
|
-
var _a2;
|
|
550
|
-
if (!app) {
|
|
551
|
-
throw new Error("app is not initialized");
|
|
242
|
+
const texture = (0, external_pixi_loader_js_namespaceObject.getTextureFromCache)(img);
|
|
243
|
+
if (!texture) throw new Error('texture not found');
|
|
244
|
+
const sprite = external_pixi_js_namespaceObject.Sprite.from(texture);
|
|
245
|
+
let targetX = null == (_pointerSprite_current = pointerSprite.current) ? void 0 : _pointerSprite_current.x;
|
|
246
|
+
let targetY = null == (_pointerSprite_current1 = pointerSprite.current) ? void 0 : _pointerSprite_current1.y;
|
|
247
|
+
if ('number' == typeof x) targetX = x;
|
|
248
|
+
if ('number' == typeof y) targetY = y;
|
|
249
|
+
if (void 0 === targetX || void 0 === targetY) return void console.warn('invalid pointer position', x, y);
|
|
250
|
+
if (pointerSprite.current) {
|
|
251
|
+
const pointer = windowContentContainer.getChildByLabel('pointer');
|
|
252
|
+
if (pointer) windowContentContainer.removeChild(pointer);
|
|
552
253
|
}
|
|
553
|
-
|
|
554
|
-
|
|
254
|
+
pointerSprite.current = sprite;
|
|
255
|
+
pointerSprite.current.x = targetX;
|
|
256
|
+
pointerSprite.current.y = targetY;
|
|
257
|
+
pointerSprite.current.label = 'pointer';
|
|
258
|
+
pointerSprite.current.zIndex = LAYER_ORDER_POINTER;
|
|
259
|
+
windowContentContainer.addChild(pointerSprite.current);
|
|
260
|
+
};
|
|
261
|
+
const updateCamera = (state)=>{
|
|
262
|
+
cameraState.current = state;
|
|
263
|
+
const newScale = Math.max(1, imageWidth / state.width);
|
|
264
|
+
windowContentContainer.scale.set(newScale);
|
|
265
|
+
windowContentContainer.x = Math.round(canvasPaddingLeft - state.left * newScale);
|
|
266
|
+
windowContentContainer.y = Math.round(canvasPaddingTop - state.top * newScale);
|
|
267
|
+
const pointer = windowContentContainer.getChildByLabel('pointer');
|
|
268
|
+
if (pointer) {
|
|
269
|
+
pointer.scale.set(1 / newScale);
|
|
270
|
+
if ('number' == typeof state.pointerLeft && 'number' == typeof state.pointerTop) {
|
|
271
|
+
pointer.x = state.pointerLeft;
|
|
272
|
+
pointer.y = state.pointerTop;
|
|
273
|
+
}
|
|
555
274
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
[...allImages, import_utils.mouseLoading, import_utils.mousePointer].map(import_pixi_loader.loadTexture)
|
|
561
|
-
);
|
|
562
|
-
insightMarkContainer.removeChildren();
|
|
563
|
-
yield updatePointer(import_utils.mousePointer, imageWidth / 2, imageHeight / 2);
|
|
564
|
-
yield repaintImage();
|
|
565
|
-
yield updateCamera(__spreadValues({}, basicCameraState));
|
|
566
|
-
const totalDuration = scripts.reduce((acc, item) => {
|
|
567
|
-
return acc + item.duration + (item.camera && item.insightCameraDuration ? item.insightCameraDuration : 0);
|
|
568
|
-
}, 0);
|
|
569
|
-
const progressUpdateInterval = 200;
|
|
570
|
-
const startTime = performance.now();
|
|
571
|
-
setAnimationProgress(0);
|
|
572
|
-
const updateProgress = () => {
|
|
573
|
-
const progress = Math.min(
|
|
574
|
-
(performance.now() - startTime) / totalDuration,
|
|
575
|
-
1
|
|
576
|
-
);
|
|
577
|
-
setAnimationProgress(progress);
|
|
578
|
-
if (progress < 1) {
|
|
579
|
-
return timeout(updateProgress, progressUpdateInterval);
|
|
580
|
-
}
|
|
275
|
+
};
|
|
276
|
+
const cameraAnimation = async (targetState, duration, frame)=>{
|
|
277
|
+
const currentState = {
|
|
278
|
+
...cameraState.current
|
|
581
279
|
};
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
280
|
+
const startLeft = currentState.left;
|
|
281
|
+
const startTop = currentState.top;
|
|
282
|
+
const startPointerLeft = currentState.pointerLeft;
|
|
283
|
+
const startPointerTop = currentState.pointerTop;
|
|
284
|
+
const startScale = currentState.width / imageWidth;
|
|
285
|
+
const startTime = performance.now();
|
|
286
|
+
const shouldMovePointer = 'number' == typeof targetState.pointerLeft && 'number' == typeof targetState.pointerTop && (targetState.pointerLeft !== startPointerLeft || targetState.pointerTop !== startPointerTop);
|
|
287
|
+
const pointerMoveDuration = shouldMovePointer ? 0.375 * duration : 0;
|
|
288
|
+
const cameraMoveStart = pointerMoveDuration;
|
|
289
|
+
const cameraMoveDuration = duration - pointerMoveDuration;
|
|
290
|
+
await new Promise((resolve)=>{
|
|
291
|
+
const animate = (currentTime)=>{
|
|
292
|
+
const nextState = {
|
|
293
|
+
...cameraState.current
|
|
294
|
+
};
|
|
295
|
+
const elapsedTime = currentTime - startTime;
|
|
296
|
+
if (shouldMovePointer) if (elapsedTime <= pointerMoveDuration) {
|
|
297
|
+
const rawMouseProgress = Math.min(elapsedTime / pointerMoveDuration, 1);
|
|
298
|
+
const mouseProgress = cubicMouse(rawMouseProgress);
|
|
299
|
+
nextState.pointerLeft = startPointerLeft + (targetState.pointerLeft - startPointerLeft) * mouseProgress;
|
|
300
|
+
nextState.pointerTop = startPointerTop + (targetState.pointerTop - startPointerTop) * mouseProgress;
|
|
301
|
+
} else {
|
|
302
|
+
nextState.pointerLeft = targetState.pointerLeft;
|
|
303
|
+
nextState.pointerTop = targetState.pointerTop;
|
|
304
|
+
}
|
|
305
|
+
if (elapsedTime > cameraMoveStart) {
|
|
306
|
+
const cameraElapsedTime = elapsedTime - cameraMoveStart;
|
|
307
|
+
const rawCameraProgress = Math.min(cameraElapsedTime / cameraMoveDuration, 1);
|
|
308
|
+
const cameraProgress = cubicImage(rawCameraProgress);
|
|
309
|
+
const targetScale = targetState.width / imageWidth;
|
|
310
|
+
const progressScale = startScale + (targetScale - startScale) * cameraProgress;
|
|
311
|
+
const progressWidth = imageWidth * progressScale;
|
|
312
|
+
const progressHeight = imageHeight * progressScale;
|
|
313
|
+
nextState.width = progressWidth;
|
|
314
|
+
const progressLeft = startLeft + (targetState.left - startLeft) * cameraProgress;
|
|
315
|
+
const progressTop = startTop + (targetState.top - startTop) * cameraProgress;
|
|
316
|
+
const horizontalExceed = progressLeft + progressWidth - imageWidth;
|
|
317
|
+
const verticalExceed = progressTop + progressHeight - imageHeight;
|
|
318
|
+
nextState.left = horizontalExceed > 0 ? progressLeft + horizontalExceed : progressLeft;
|
|
319
|
+
nextState.top = verticalExceed > 0 ? progressTop + verticalExceed : progressTop;
|
|
320
|
+
}
|
|
321
|
+
updateCamera(nextState);
|
|
322
|
+
if (elapsedTime < duration) frame(animate);
|
|
323
|
+
else resolve();
|
|
324
|
+
};
|
|
325
|
+
frame(animate);
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
const fadeInGraphics = function(graphics, duration, frame) {
|
|
329
|
+
let targetAlpha = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 1;
|
|
330
|
+
return new Promise((resolve)=>{
|
|
331
|
+
const startTime = performance.now();
|
|
332
|
+
const animate = (currentTime)=>{
|
|
333
|
+
const elapsedTime = currentTime - startTime;
|
|
334
|
+
const progress = Math.min(elapsedTime / duration, 1);
|
|
335
|
+
graphics.alpha = 0 === targetAlpha ? 1 - linear(progress) : linear(progress);
|
|
336
|
+
if (elapsedTime < duration) frame(animate);
|
|
337
|
+
else resolve();
|
|
338
|
+
};
|
|
339
|
+
frame(animate);
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
const fadeOutItem = async (graphics, duration, frame)=>fadeInGraphics(graphics, duration, frame, 0);
|
|
343
|
+
const insightElementsAnimation = async (elements, highlightElements, searchArea, duration, frame)=>{
|
|
344
|
+
insightMarkContainer.removeChildren();
|
|
345
|
+
const elementsToAdd = [
|
|
346
|
+
...elements
|
|
347
|
+
];
|
|
348
|
+
const totalLength = elementsToAdd.length;
|
|
349
|
+
let childrenCount = 0;
|
|
350
|
+
await new Promise((resolve)=>{
|
|
351
|
+
const startTime = performance.now();
|
|
352
|
+
const animate = (currentTime)=>{
|
|
353
|
+
const elapsedTime = currentTime - startTime;
|
|
354
|
+
const progress = cubicInsightElement(Math.min(elapsedTime / duration, 1));
|
|
355
|
+
const elementsToAddNow = Math.floor(progress * totalLength);
|
|
356
|
+
while(childrenCount < elementsToAddNow){
|
|
357
|
+
const randomIndex = Math.floor(Math.random() * elementsToAdd.length);
|
|
358
|
+
const element = elementsToAdd.splice(randomIndex, 1)[0];
|
|
359
|
+
if (element) {
|
|
360
|
+
const [insightMarkGraphic] = (0, external_blackboard_js_namespaceObject.rectMarkForItem)(element.rect, element.content, 'element');
|
|
361
|
+
insightMarkGraphic.alpha = 0;
|
|
362
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
363
|
+
childrenCount++;
|
|
364
|
+
fadeInGraphics(insightMarkGraphic, singleElementFadeInDuration, frame);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (elapsedTime < duration) frame(animate);
|
|
368
|
+
else {
|
|
369
|
+
while(elementsToAdd.length > 0){
|
|
370
|
+
const randomIndex = Math.floor(Math.random() * elementsToAdd.length);
|
|
371
|
+
const element = elementsToAdd.splice(randomIndex, 1)[0];
|
|
372
|
+
const [insightMarkGraphic] = (0, external_blackboard_js_namespaceObject.rectMarkForItem)(element.rect, element.content, 'element');
|
|
373
|
+
insightMarkGraphic.alpha = 1;
|
|
374
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
375
|
+
}
|
|
376
|
+
if (searchArea) {
|
|
377
|
+
const [searchAreaGraphic] = (0, external_blackboard_js_namespaceObject.rectMarkForItem)(searchArea, 'Search Area', 'searchArea');
|
|
378
|
+
searchAreaGraphic.alpha = 1;
|
|
379
|
+
insightMarkContainer.addChild(searchAreaGraphic);
|
|
380
|
+
}
|
|
381
|
+
highlightElements.map((element)=>{
|
|
382
|
+
const [insightMarkGraphic] = (0, external_blackboard_js_namespaceObject.rectMarkForItem)(element.rect, element.content || '', 'highlight');
|
|
383
|
+
insightMarkGraphic.alpha = 1;
|
|
384
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
385
|
+
});
|
|
386
|
+
resolve();
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
frame(animate);
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
const init = async ()=>{
|
|
393
|
+
if (!divContainerRef.current || !scripts) return;
|
|
394
|
+
await app.init({
|
|
395
|
+
width: imageWidth,
|
|
396
|
+
height: imageHeight,
|
|
397
|
+
background: 0xf4f4f4,
|
|
398
|
+
autoDensity: true,
|
|
399
|
+
antialias: true
|
|
400
|
+
});
|
|
401
|
+
if (!divContainerRef.current) return;
|
|
402
|
+
divContainerRef.current.appendChild(app.canvas);
|
|
403
|
+
windowContentContainer.x = 0;
|
|
404
|
+
windowContentContainer.y = 0;
|
|
405
|
+
app.stage.addChild(windowContentContainer);
|
|
406
|
+
insightMarkContainer.x = 0;
|
|
407
|
+
insightMarkContainer.y = 0;
|
|
408
|
+
windowContentContainer.addChild(insightMarkContainer);
|
|
409
|
+
};
|
|
410
|
+
const [isRecording, setIsRecording] = (0, external_react_namespaceObject.useState)(false);
|
|
411
|
+
const recorderSessionRef = (0, external_react_namespaceObject.useRef)(null);
|
|
412
|
+
const handleExport = ()=>{
|
|
413
|
+
if (recorderSessionRef.current) return void console.warn('recorderSession exists');
|
|
414
|
+
if (!app.canvas) return void console.warn('canvas is not initialized');
|
|
415
|
+
recorderSessionRef.current = new RecordingSession(app.canvas);
|
|
416
|
+
setIsRecording(true);
|
|
417
|
+
triggerReplay();
|
|
418
|
+
};
|
|
419
|
+
const play = ()=>{
|
|
420
|
+
let cancelFn;
|
|
421
|
+
Promise.resolve((async ()=>{
|
|
422
|
+
if (!app) throw new Error('app is not initialized');
|
|
423
|
+
if (!scripts) throw new Error("scripts is required");
|
|
424
|
+
const { frame, cancel, timeout } = frameKit();
|
|
425
|
+
cancelFn = cancel;
|
|
426
|
+
const allImages = scripts.filter((item)=>!!item.img).map((item)=>item.img);
|
|
427
|
+
await Promise.all([
|
|
428
|
+
...allImages,
|
|
429
|
+
external_utils_js_namespaceObject.mouseLoading,
|
|
430
|
+
external_utils_js_namespaceObject.mousePointer
|
|
431
|
+
].map(external_pixi_loader_js_namespaceObject.loadTexture));
|
|
619
432
|
insightMarkContainer.removeChildren();
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
433
|
+
await updatePointer(external_utils_js_namespaceObject.mousePointer, imageWidth / 2, imageHeight / 2);
|
|
434
|
+
await repaintImage();
|
|
435
|
+
await updateCamera({
|
|
436
|
+
...basicCameraState
|
|
437
|
+
});
|
|
438
|
+
const totalDuration = scripts.reduce((acc, item)=>acc + item.duration + (item.camera && item.insightCameraDuration ? item.insightCameraDuration : 0), 0);
|
|
439
|
+
const progressUpdateInterval = 200;
|
|
440
|
+
const startTime = performance.now();
|
|
441
|
+
setAnimationProgress(0);
|
|
442
|
+
const updateProgress = ()=>{
|
|
443
|
+
const progress = Math.min((performance.now() - startTime) / totalDuration, 1);
|
|
444
|
+
setAnimationProgress(progress);
|
|
445
|
+
if (progress < 1) return timeout(updateProgress, progressUpdateInterval);
|
|
446
|
+
};
|
|
447
|
+
frame(updateProgress);
|
|
448
|
+
if (recorderSessionRef.current) recorderSessionRef.current.start();
|
|
449
|
+
for(const index in scripts){
|
|
450
|
+
const item = scripts[index];
|
|
451
|
+
setTitleText(item.title || '');
|
|
452
|
+
setSubTitleText(item.subTitle || '');
|
|
453
|
+
if ('sleep' === item.type) await sleep(item.duration);
|
|
454
|
+
else if ('insight' === item.type) {
|
|
455
|
+
var _item_context;
|
|
456
|
+
if (!item.img) throw new Error('img is required');
|
|
457
|
+
currentImg.current = item.img;
|
|
458
|
+
await repaintImage();
|
|
459
|
+
const elements = (null == (_item_context = item.context) ? void 0 : _item_context.tree) ? (0, extractor_namespaceObject.treeToList)(item.context.tree) : [];
|
|
460
|
+
const highlightElements = item.highlightElement ? [
|
|
461
|
+
item.highlightElement
|
|
462
|
+
] : [];
|
|
463
|
+
await insightElementsAnimation(elements, highlightElements, item.searchArea, item.duration, frame);
|
|
464
|
+
if (item.camera) {
|
|
465
|
+
if (!item.insightCameraDuration) throw new Error('insightCameraDuration is required');
|
|
466
|
+
await cameraAnimation(item.camera, item.insightCameraDuration, frame);
|
|
467
|
+
}
|
|
468
|
+
} else if ('clear-insight' === item.type) {
|
|
469
|
+
await fadeOutItem(insightMarkContainer, item.duration, frame);
|
|
470
|
+
insightMarkContainer.removeChildren();
|
|
471
|
+
insightMarkContainer.alpha = 1;
|
|
472
|
+
} else if ('img' === item.type) {
|
|
473
|
+
if (item.img && item.img !== currentImg.current) {
|
|
474
|
+
currentImg.current = item.img;
|
|
475
|
+
await repaintImage();
|
|
476
|
+
}
|
|
477
|
+
if (item.camera) await cameraAnimation(item.camera, item.duration, frame);
|
|
478
|
+
else await sleep(item.duration);
|
|
479
|
+
} else if ('pointer' === item.type) {
|
|
480
|
+
if (!item.img) throw new Error('pointer img is required');
|
|
481
|
+
await updatePointer(item.img);
|
|
482
|
+
} else if ('spinning-pointer' === item.type) {
|
|
483
|
+
const stop = spinningPointer(frame);
|
|
484
|
+
await sleep(item.duration);
|
|
485
|
+
stop();
|
|
486
|
+
}
|
|
630
487
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
488
|
+
if (recorderSessionRef.current) {
|
|
489
|
+
recorderSessionRef.current.stop();
|
|
490
|
+
recorderSessionRef.current = null;
|
|
491
|
+
setIsRecording(false);
|
|
634
492
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
642
|
-
if (recorderSessionRef.current) {
|
|
643
|
-
recorderSessionRef.current.stop();
|
|
644
|
-
recorderSessionRef.current = null;
|
|
645
|
-
setIsRecording(false);
|
|
646
|
-
}
|
|
647
|
-
}))().catch((e) => {
|
|
648
|
-
import_console_browserify.default.error("player error", e);
|
|
649
|
-
})
|
|
650
|
-
);
|
|
651
|
-
return () => {
|
|
652
|
-
cancelFn == null ? void 0 : cancelFn();
|
|
653
|
-
};
|
|
654
|
-
};
|
|
655
|
-
(0, import_react.useEffect)(() => {
|
|
656
|
-
Promise.resolve(
|
|
657
|
-
(() => __async(this, null, function* () {
|
|
658
|
-
yield init();
|
|
659
|
-
if (divContainerRef.current && imageWidth && imageHeight) {
|
|
660
|
-
const aspectRatio = imageWidth / imageHeight;
|
|
661
|
-
divContainerRef.current.style.setProperty(
|
|
662
|
-
"--canvas-aspect-ratio",
|
|
663
|
-
aspectRatio.toString()
|
|
664
|
-
);
|
|
665
|
-
divContainerRef.current.setAttribute("data-fit-mode", fitMode);
|
|
666
|
-
const playerContainer = divContainerRef.current.closest(
|
|
667
|
-
".player-container"
|
|
668
|
-
);
|
|
669
|
-
if (playerContainer) {
|
|
670
|
-
playerContainer.setAttribute("data-fit-mode", fitMode);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
triggerReplay();
|
|
674
|
-
}))()
|
|
675
|
-
);
|
|
676
|
-
return () => {
|
|
677
|
-
try {
|
|
678
|
-
app.destroy(true, { children: true, texture: true });
|
|
679
|
-
} catch (e) {
|
|
680
|
-
import_console_browserify.default.warn("destroy failed", e);
|
|
681
|
-
}
|
|
493
|
+
})().catch((e)=>{
|
|
494
|
+
console.error('player error', e);
|
|
495
|
+
}));
|
|
496
|
+
return ()=>{
|
|
497
|
+
null == cancelFn || cancelFn();
|
|
498
|
+
};
|
|
682
499
|
};
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
}
|
|
729
|
-
) }) }),
|
|
730
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "player-tools-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "player-tools", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "player-control", children: [
|
|
731
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "status-text", children: [
|
|
732
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "title", children: titleText }),
|
|
733
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: subTitleText, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "subtitle", children: subTitleText }) })
|
|
734
|
-
] }),
|
|
735
|
-
isRecording ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
736
|
-
"div",
|
|
737
|
-
{
|
|
738
|
-
className: "status-icon",
|
|
739
|
-
onMouseEnter: () => setMouseOverStatusIcon(true),
|
|
740
|
-
onMouseLeave: () => setMouseOverStatusIcon(false),
|
|
741
|
-
onClick: statusOnClick,
|
|
742
|
-
children: statusIconElement
|
|
743
|
-
}
|
|
744
|
-
),
|
|
745
|
-
(props == null ? void 0 : props.reportFileContent) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: "Download Report", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
746
|
-
"div",
|
|
747
|
-
{
|
|
748
|
-
className: "status-icon",
|
|
749
|
-
onMouseEnter: () => setMouseOverStatusIcon(true),
|
|
750
|
-
onMouseLeave: () => setMouseOverStatusIcon(false),
|
|
751
|
-
onClick: () => downloadReport(props.reportFileContent),
|
|
752
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.DownloadOutlined, { color: "#333" })
|
|
753
|
-
}
|
|
754
|
-
) }) : null,
|
|
755
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Tooltip, { title: isRecording ? "Generating..." : "Export Video", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
756
|
-
"div",
|
|
757
|
-
{
|
|
758
|
-
className: "status-icon",
|
|
759
|
-
onClick: isRecording ? void 0 : handleExport,
|
|
760
|
-
style: {
|
|
761
|
-
opacity: isRecording ? 0.5 : 1,
|
|
762
|
-
cursor: isRecording ? "not-allowed" : "pointer"
|
|
763
|
-
},
|
|
764
|
-
children: isRecording ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Spin, { size: "default", percent: progressString }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.ExportOutlined, {})
|
|
500
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
501
|
+
Promise.resolve((async ()=>{
|
|
502
|
+
await init();
|
|
503
|
+
if (divContainerRef.current && imageWidth && imageHeight) {
|
|
504
|
+
const aspectRatio = imageWidth / imageHeight;
|
|
505
|
+
divContainerRef.current.style.setProperty('--canvas-aspect-ratio', aspectRatio.toString());
|
|
506
|
+
divContainerRef.current.setAttribute('data-fit-mode', fitMode);
|
|
507
|
+
const playerContainer = divContainerRef.current.closest('.player-container');
|
|
508
|
+
if (playerContainer) playerContainer.setAttribute('data-fit-mode', fitMode);
|
|
509
|
+
}
|
|
510
|
+
triggerReplay();
|
|
511
|
+
})());
|
|
512
|
+
return ()=>{
|
|
513
|
+
try {
|
|
514
|
+
app.destroy(true, {
|
|
515
|
+
children: true,
|
|
516
|
+
texture: true
|
|
517
|
+
});
|
|
518
|
+
} catch (e) {
|
|
519
|
+
console.warn('destroy failed', e);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}, [
|
|
523
|
+
imageWidth,
|
|
524
|
+
imageHeight,
|
|
525
|
+
fitMode
|
|
526
|
+
]);
|
|
527
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
528
|
+
if (replayMark) return play();
|
|
529
|
+
}, [
|
|
530
|
+
replayMark
|
|
531
|
+
]);
|
|
532
|
+
const [mouseOverStatusIcon, setMouseOverStatusIcon] = (0, external_react_namespaceObject.useState)(false);
|
|
533
|
+
const progressString = Math.round(100 * animationProgress);
|
|
534
|
+
const transitionStyle = 0 === animationProgress ? 'none' : '0.3s';
|
|
535
|
+
const canReplayNow = 1 === animationProgress;
|
|
536
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
537
|
+
if (canReplayNow) {
|
|
538
|
+
const listener = (event)=>{
|
|
539
|
+
if (' ' === event.key) triggerReplay();
|
|
540
|
+
};
|
|
541
|
+
window.addEventListener('keydown', listener);
|
|
542
|
+
return ()=>{
|
|
543
|
+
window.removeEventListener('keydown', listener);
|
|
544
|
+
};
|
|
765
545
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
546
|
+
}, [
|
|
547
|
+
canReplayNow
|
|
548
|
+
]);
|
|
549
|
+
let statusIconElement;
|
|
550
|
+
let statusOnClick = ()=>{};
|
|
551
|
+
if (animationProgress < 1) statusIconElement = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
552
|
+
indicator: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.LoadingOutlined, {
|
|
553
|
+
spin: true,
|
|
554
|
+
color: "#333"
|
|
555
|
+
}),
|
|
556
|
+
size: "default"
|
|
557
|
+
});
|
|
558
|
+
else if (mouseOverStatusIcon) {
|
|
559
|
+
statusIconElement = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
560
|
+
indicator: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.CaretRightOutlined, {
|
|
561
|
+
color: "#333"
|
|
562
|
+
}),
|
|
563
|
+
size: "default"
|
|
564
|
+
});
|
|
565
|
+
statusOnClick = ()=>triggerReplay();
|
|
566
|
+
} else statusIconElement = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
567
|
+
indicator: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.CaretRightOutlined, {
|
|
568
|
+
color: "#333"
|
|
569
|
+
}),
|
|
570
|
+
size: "default"
|
|
571
|
+
});
|
|
572
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
573
|
+
className: "player-container",
|
|
574
|
+
children: [
|
|
575
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
576
|
+
className: "canvas-container",
|
|
577
|
+
ref: divContainerRef
|
|
578
|
+
}),
|
|
579
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
580
|
+
className: "player-timeline-wrapper",
|
|
581
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
582
|
+
className: "player-timeline",
|
|
583
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
584
|
+
className: "player-timeline-progress",
|
|
585
|
+
style: {
|
|
586
|
+
width: `${progressString}%`,
|
|
587
|
+
transition: transitionStyle
|
|
588
|
+
}
|
|
589
|
+
})
|
|
590
|
+
})
|
|
591
|
+
}),
|
|
592
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
593
|
+
className: "player-tools-wrapper",
|
|
594
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
595
|
+
className: "player-tools",
|
|
596
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
597
|
+
className: "player-control",
|
|
598
|
+
children: [
|
|
599
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
600
|
+
className: "status-text",
|
|
601
|
+
children: [
|
|
602
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
603
|
+
className: "title",
|
|
604
|
+
children: titleText
|
|
605
|
+
}),
|
|
606
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
607
|
+
title: subTitleText,
|
|
608
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
609
|
+
className: "subtitle",
|
|
610
|
+
children: subTitleText
|
|
611
|
+
})
|
|
612
|
+
})
|
|
613
|
+
]
|
|
614
|
+
}),
|
|
615
|
+
isRecording ? null : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
616
|
+
className: "status-icon",
|
|
617
|
+
onMouseEnter: ()=>setMouseOverStatusIcon(true),
|
|
618
|
+
onMouseLeave: ()=>setMouseOverStatusIcon(false),
|
|
619
|
+
onClick: statusOnClick,
|
|
620
|
+
children: statusIconElement
|
|
621
|
+
}),
|
|
622
|
+
(null == props ? void 0 : props.reportFileContent) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
623
|
+
title: "Download Report",
|
|
624
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
625
|
+
className: "status-icon",
|
|
626
|
+
onMouseEnter: ()=>setMouseOverStatusIcon(true),
|
|
627
|
+
onMouseLeave: ()=>setMouseOverStatusIcon(false),
|
|
628
|
+
onClick: ()=>downloadReport(props.reportFileContent),
|
|
629
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.DownloadOutlined, {
|
|
630
|
+
color: "#333"
|
|
631
|
+
})
|
|
632
|
+
})
|
|
633
|
+
}) : null,
|
|
634
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
635
|
+
title: isRecording ? 'Generating...' : 'Export Video',
|
|
636
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
637
|
+
className: "status-icon",
|
|
638
|
+
onClick: isRecording ? void 0 : handleExport,
|
|
639
|
+
style: {
|
|
640
|
+
opacity: isRecording ? 0.5 : 1,
|
|
641
|
+
cursor: isRecording ? 'not-allowed' : 'pointer'
|
|
642
|
+
},
|
|
643
|
+
children: isRecording ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
644
|
+
size: "default",
|
|
645
|
+
percent: progressString
|
|
646
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.ExportOutlined, {})
|
|
647
|
+
})
|
|
648
|
+
})
|
|
649
|
+
]
|
|
650
|
+
})
|
|
651
|
+
})
|
|
652
|
+
})
|
|
653
|
+
]
|
|
654
|
+
});
|
|
769
655
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
656
|
+
exports.Player = __webpack_exports__.Player;
|
|
657
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
658
|
+
"Player"
|
|
659
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
660
|
+
Object.defineProperty(exports, '__esModule', {
|
|
661
|
+
value: true
|
|
773
662
|
});
|