@sqaitech/visualizer 0.5.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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/es/assets/sqai-logo.mjs +2 -0
- package/dist/es/component/blackboard/index.css +33 -0
- package/dist/es/component/blackboard/index.mjs +278 -0
- package/dist/es/component/config-selector/index.mjs +104 -0
- package/dist/es/component/context-preview/index.mjs +38 -0
- package/dist/es/component/env-config/index.mjs +112 -0
- package/dist/es/component/env-config-reminder/index.css +22 -0
- package/dist/es/component/env-config-reminder/index.mjs +28 -0
- package/dist/es/component/form-field/index.mjs +163 -0
- package/dist/es/component/history-selector/index.css +135 -0
- package/dist/es/component/history-selector/index.mjs +170 -0
- package/dist/es/component/index.mjs +1 -0
- package/dist/es/component/logo/index.css +13 -0
- package/dist/es/component/logo/index.mjs +21 -0
- package/dist/es/component/misc/index.mjs +94 -0
- package/dist/es/component/nav-actions/index.mjs +32 -0
- package/dist/es/component/nav-actions/style.css +35 -0
- package/dist/es/component/player/index.css +185 -0
- package/dist/es/component/player/index.mjs +856 -0
- package/dist/es/component/playground/index.css +431 -0
- package/dist/es/component/playground/index.mjs +8 -0
- package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/es/component/playground-result/index.css +34 -0
- package/dist/es/component/playground-result/index.mjs +62 -0
- package/dist/es/component/prompt-input/index.css +391 -0
- package/dist/es/component/prompt-input/index.mjs +730 -0
- package/dist/es/component/service-mode-control/index.mjs +105 -0
- package/dist/es/component/shiny-text/index.css +75 -0
- package/dist/es/component/shiny-text/index.mjs +15 -0
- package/dist/es/component/universal-playground/index.css +341 -0
- package/dist/es/component/universal-playground/index.mjs +302 -0
- package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +207 -0
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +210 -0
- package/dist/es/hooks/usePlaygroundExecution.mjs +180 -0
- package/dist/es/hooks/usePlaygroundState.mjs +203 -0
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +24 -0
- package/dist/es/hooks/useServerValid.mjs +30 -0
- package/dist/es/icons/avatar.mjs +28 -0
- package/dist/es/icons/close.mjs +19 -0
- package/dist/es/icons/global-perspective.mjs +16 -0
- package/dist/es/icons/history.mjs +30 -0
- package/dist/es/icons/magnifying-glass.mjs +39 -0
- package/dist/es/icons/player-setting.mjs +26 -0
- package/dist/es/icons/setting.mjs +20 -0
- package/dist/es/icons/show-marker.mjs +16 -0
- package/dist/es/index.mjs +25 -0
- package/dist/es/static/image/sqai-logo.png +0 -0
- package/dist/es/store/history.mjs +89 -0
- package/dist/es/store/store.mjs +186 -0
- package/dist/es/types.mjs +70 -0
- package/dist/es/utils/color.mjs +35 -0
- package/dist/es/utils/constants.mjs +99 -0
- package/dist/es/utils/index.mjs +10 -0
- package/dist/es/utils/pixi-loader.mjs +16 -0
- package/dist/es/utils/playground-utils.mjs +67 -0
- package/dist/es/utils/replay-scripts.mjs +312 -0
- package/dist/lib/assets/sqai-logo.js +24 -0
- package/dist/lib/component/blackboard/index.css +33 -0
- package/dist/lib/component/blackboard/index.js +321 -0
- package/dist/lib/component/config-selector/index.js +148 -0
- package/dist/lib/component/context-preview/index.js +83 -0
- package/dist/lib/component/env-config/index.js +146 -0
- package/dist/lib/component/env-config-reminder/index.css +22 -0
- package/dist/lib/component/env-config-reminder/index.js +62 -0
- package/dist/lib/component/form-field/index.js +209 -0
- package/dist/lib/component/history-selector/index.css +135 -0
- package/dist/lib/component/history-selector/index.js +216 -0
- package/dist/lib/component/index.js +60 -0
- package/dist/lib/component/logo/index.css +13 -0
- package/dist/lib/component/logo/index.js +68 -0
- package/dist/lib/component/misc/index.js +150 -0
- package/dist/lib/component/nav-actions/index.js +66 -0
- package/dist/lib/component/nav-actions/style.css +35 -0
- package/dist/lib/component/player/index.css +185 -0
- package/dist/lib/component/player/index.js +902 -0
- package/dist/lib/component/playground/index.css +431 -0
- package/dist/lib/component/playground/index.js +113 -0
- package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/lib/component/playground-result/index.css +34 -0
- package/dist/lib/component/playground-result/index.js +106 -0
- package/dist/lib/component/prompt-input/index.css +391 -0
- package/dist/lib/component/prompt-input/index.js +774 -0
- package/dist/lib/component/service-mode-control/index.js +139 -0
- package/dist/lib/component/shiny-text/index.css +75 -0
- package/dist/lib/component/shiny-text/index.js +49 -0
- package/dist/lib/component/universal-playground/index.css +341 -0
- package/dist/lib/component/universal-playground/index.js +350 -0
- package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +247 -0
- package/dist/lib/component/universal-playground/providers/storage-provider.js +268 -0
- package/dist/lib/hooks/usePlaygroundExecution.js +214 -0
- package/dist/lib/hooks/usePlaygroundState.js +237 -0
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +61 -0
- package/dist/lib/hooks/useServerValid.js +64 -0
- package/dist/lib/icons/avatar.js +62 -0
- package/dist/lib/icons/close.js +53 -0
- package/dist/lib/icons/global-perspective.js +50 -0
- package/dist/lib/icons/history.js +64 -0
- package/dist/lib/icons/magnifying-glass.js +73 -0
- package/dist/lib/icons/player-setting.js +60 -0
- package/dist/lib/icons/setting.js +54 -0
- package/dist/lib/icons/show-marker.js +50 -0
- package/dist/lib/index.js +187 -0
- package/dist/lib/static/image/sqai-logo.png +0 -0
- package/dist/lib/store/history.js +96 -0
- package/dist/lib/store/store.js +196 -0
- package/dist/lib/types.js +116 -0
- package/dist/lib/utils/color.js +75 -0
- package/dist/lib/utils/constants.js +154 -0
- package/dist/lib/utils/index.js +63 -0
- package/dist/lib/utils/pixi-loader.js +56 -0
- package/dist/lib/utils/playground-utils.js +110 -0
- package/dist/lib/utils/replay-scripts.js +355 -0
- package/dist/types/component/blackboard/index.d.ts +15 -0
- package/dist/types/component/config-selector/index.d.ts +9 -0
- package/dist/types/component/context-preview/index.d.ts +9 -0
- package/dist/types/component/env-config/index.d.ts +6 -0
- package/dist/types/component/env-config-reminder/index.d.ts +6 -0
- package/dist/types/component/form-field/index.d.ts +17 -0
- package/dist/types/component/history-selector/index.d.ts +10 -0
- package/dist/types/component/index.d.ts +1 -0
- package/dist/types/component/logo/index.d.ts +5 -0
- package/dist/types/component/misc/index.d.ts +6 -0
- package/dist/types/component/nav-actions/index.d.ts +10 -0
- package/dist/types/component/player/index.d.ts +13 -0
- package/dist/types/component/playground/index.d.ts +7 -0
- package/dist/types/component/playground-result/index.d.ts +20 -0
- package/dist/types/component/prompt-input/index.d.ts +22 -0
- package/dist/types/component/service-mode-control/index.d.ts +6 -0
- package/dist/types/component/shiny-text/index.d.ts +12 -0
- package/dist/types/component/universal-playground/index.d.ts +4 -0
- package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
- package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +10 -0
- package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
- package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
- package/dist/types/hooks/useServerValid.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/store/history.d.ts +16 -0
- package/dist/types/store/store.d.ts +36 -0
- package/dist/types/types.d.ts +161 -0
- package/dist/types/utils/color.d.ts +4 -0
- package/dist/types/utils/constants.d.ts +74 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/pixi-loader.d.ts +5 -0
- package/dist/types/utils/playground-utils.d.ts +6 -0
- package/dist/types/utils/replay-scripts.d.ts +34 -0
- package/package.json +85 -0
|
@@ -0,0 +1,902 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.n = (module)=>{
|
|
6
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
7
|
+
__webpack_require__.d(getter, {
|
|
8
|
+
a: getter
|
|
9
|
+
});
|
|
10
|
+
return getter;
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
(()=>{
|
|
14
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
15
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: definition[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
(()=>{
|
|
22
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.r = (exports1)=>{
|
|
26
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
27
|
+
value: 'Module'
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
30
|
+
value: true
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
var __webpack_exports__ = {};
|
|
35
|
+
__webpack_require__.r(__webpack_exports__);
|
|
36
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
37
|
+
Player: ()=>Player
|
|
38
|
+
});
|
|
39
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
40
|
+
require("pixi.js/unsafe-eval");
|
|
41
|
+
const external_pixi_js_namespaceObject = require("pixi.js");
|
|
42
|
+
const external_react_namespaceObject = require("react");
|
|
43
|
+
require("./index.css");
|
|
44
|
+
const index_js_namespaceObject = require("../../utils/index.js");
|
|
45
|
+
const icons_namespaceObject = require("@ant-design/icons");
|
|
46
|
+
const extractor_namespaceObject = require("@sqaitech/shared/extractor");
|
|
47
|
+
const external_antd_namespaceObject = require("antd");
|
|
48
|
+
const global_perspective_js_namespaceObject = require("../../icons/global-perspective.js");
|
|
49
|
+
var global_perspective_js_default = /*#__PURE__*/ __webpack_require__.n(global_perspective_js_namespaceObject);
|
|
50
|
+
const player_setting_js_namespaceObject = require("../../icons/player-setting.js");
|
|
51
|
+
var player_setting_js_default = /*#__PURE__*/ __webpack_require__.n(player_setting_js_namespaceObject);
|
|
52
|
+
const show_marker_js_namespaceObject = require("../../icons/show-marker.js");
|
|
53
|
+
var show_marker_js_default = /*#__PURE__*/ __webpack_require__.n(show_marker_js_namespaceObject);
|
|
54
|
+
const store_js_namespaceObject = require("../../store/store.js");
|
|
55
|
+
const pixi_loader_js_namespaceObject = require("../../utils/pixi-loader.js");
|
|
56
|
+
const external_blackboard_index_js_namespaceObject = require("../blackboard/index.js");
|
|
57
|
+
function _define_property(obj, key, value) {
|
|
58
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
59
|
+
value: value,
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true
|
|
63
|
+
});
|
|
64
|
+
else obj[key] = value;
|
|
65
|
+
return obj;
|
|
66
|
+
}
|
|
67
|
+
const canvasPaddingLeft = 0;
|
|
68
|
+
const canvasPaddingTop = 0;
|
|
69
|
+
const cubicBezier = (t, p0, p1, p2, p3)=>{
|
|
70
|
+
const t2 = 1 - t;
|
|
71
|
+
return p0 * t2 * t2 * t2 + 3 * p1 * t * t2 * t2 + 3 * p2 * t * t * t2 + p3 * t * t * t;
|
|
72
|
+
};
|
|
73
|
+
const cubicImage = (t)=>linear(t);
|
|
74
|
+
const cubicInsightElement = (t)=>cubicBezier(t, 0, 0.5, 0.5, 1);
|
|
75
|
+
const cubicMouse = (t)=>linear(t);
|
|
76
|
+
const linear = (t)=>t;
|
|
77
|
+
const sleep = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
78
|
+
const ERROR_FRAME_CANCEL = 'frame cancel (this is an error on purpose)';
|
|
79
|
+
const frameKit = ()=>{
|
|
80
|
+
let cancelFlag = false;
|
|
81
|
+
return {
|
|
82
|
+
frame: (callback)=>{
|
|
83
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
84
|
+
requestAnimationFrame(()=>{
|
|
85
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
86
|
+
callback(performance.now());
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
timeout: (callback, ms)=>{
|
|
90
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
91
|
+
setTimeout(()=>{
|
|
92
|
+
if (cancelFlag) throw new Error(ERROR_FRAME_CANCEL);
|
|
93
|
+
callback();
|
|
94
|
+
}, ms);
|
|
95
|
+
},
|
|
96
|
+
cancel: ()=>{
|
|
97
|
+
cancelFlag = true;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
const singleElementFadeInDuration = 80;
|
|
102
|
+
const LAYER_ORDER_IMG = 0;
|
|
103
|
+
const LAYER_ORDER_INSIGHT = 1;
|
|
104
|
+
const LAYER_ORDER_POINTER = 2;
|
|
105
|
+
const LAYER_ORDER_SPINNING_POINTER = 3;
|
|
106
|
+
const downloadReport = (content)=>{
|
|
107
|
+
const blob = new Blob([
|
|
108
|
+
content
|
|
109
|
+
], {
|
|
110
|
+
type: 'text/html'
|
|
111
|
+
});
|
|
112
|
+
const url = URL.createObjectURL(blob);
|
|
113
|
+
const a = document.createElement('a');
|
|
114
|
+
a.href = url;
|
|
115
|
+
a.download = 'sqai_report.html';
|
|
116
|
+
a.click();
|
|
117
|
+
};
|
|
118
|
+
class RecordingSession {
|
|
119
|
+
start() {
|
|
120
|
+
const stream = this.canvas.captureStream(60);
|
|
121
|
+
const mediaRecorder = new MediaRecorder(stream, {
|
|
122
|
+
mimeType: 'video/webm'
|
|
123
|
+
});
|
|
124
|
+
mediaRecorder.ondataavailable = (event)=>{
|
|
125
|
+
if (event.data.size > 0) this.chunks.push(event.data);
|
|
126
|
+
};
|
|
127
|
+
this.mediaRecorder = mediaRecorder;
|
|
128
|
+
this.recording = true;
|
|
129
|
+
return this.mediaRecorder.start();
|
|
130
|
+
}
|
|
131
|
+
stop() {
|
|
132
|
+
var _this_mediaRecorder;
|
|
133
|
+
if (!this.recording || !this.mediaRecorder) return void console.warn('not recording');
|
|
134
|
+
this.mediaRecorder.onstop = ()=>{
|
|
135
|
+
const blob = new Blob(this.chunks, {
|
|
136
|
+
type: 'video/webm'
|
|
137
|
+
});
|
|
138
|
+
const url = URL.createObjectURL(blob);
|
|
139
|
+
const a = document.createElement('a');
|
|
140
|
+
a.href = url;
|
|
141
|
+
a.download = 'sqai_replay.webm';
|
|
142
|
+
a.click();
|
|
143
|
+
URL.revokeObjectURL(url);
|
|
144
|
+
};
|
|
145
|
+
null == (_this_mediaRecorder = this.mediaRecorder) || _this_mediaRecorder.stop();
|
|
146
|
+
this.recording = false;
|
|
147
|
+
this.mediaRecorder = null;
|
|
148
|
+
}
|
|
149
|
+
constructor(canvas){
|
|
150
|
+
_define_property(this, "canvas", void 0);
|
|
151
|
+
_define_property(this, "mediaRecorder", null);
|
|
152
|
+
_define_property(this, "chunks", void 0);
|
|
153
|
+
_define_property(this, "recording", false);
|
|
154
|
+
this.canvas = canvas;
|
|
155
|
+
this.chunks = [];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function Player(props) {
|
|
159
|
+
var _scripts_;
|
|
160
|
+
const [titleText, setTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
161
|
+
const [subTitleText, setSubTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
162
|
+
const { autoZoom, setAutoZoom, elementsVisible, setElementsVisible } = (0, store_js_namespaceObject.useBlackboardPreference)();
|
|
163
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
164
|
+
if ((null == props ? void 0 : props.autoZoom) !== void 0) setAutoZoom(props.autoZoom);
|
|
165
|
+
}, [
|
|
166
|
+
null == props ? void 0 : props.autoZoom,
|
|
167
|
+
setAutoZoom
|
|
168
|
+
]);
|
|
169
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
170
|
+
if ((null == props ? void 0 : props.elementsVisible) !== void 0) setElementsVisible(props.elementsVisible);
|
|
171
|
+
}, [
|
|
172
|
+
null == props ? void 0 : props.elementsVisible,
|
|
173
|
+
setElementsVisible
|
|
174
|
+
]);
|
|
175
|
+
const scripts = null == props ? void 0 : props.replayScripts;
|
|
176
|
+
const imageWidth = (null == props ? void 0 : props.imageWidth) || 1920;
|
|
177
|
+
const imageHeight = (null == props ? void 0 : props.imageHeight) || 1080;
|
|
178
|
+
const fitMode = (null == props ? void 0 : props.fitMode) || 'height';
|
|
179
|
+
const currentImg = (0, external_react_namespaceObject.useRef)((null == scripts ? void 0 : null == (_scripts_ = scripts[0]) ? void 0 : _scripts_.img) || null);
|
|
180
|
+
const divContainerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
181
|
+
const app = (0, external_react_namespaceObject.useMemo)(()=>new external_pixi_js_namespaceObject.Application(), []);
|
|
182
|
+
const pointerSprite = (0, external_react_namespaceObject.useRef)(null);
|
|
183
|
+
const spinningPointerSprite = (0, external_react_namespaceObject.useRef)(null);
|
|
184
|
+
const [replayMark, setReplayMark] = (0, external_react_namespaceObject.useState)(0);
|
|
185
|
+
const triggerReplay = ()=>{
|
|
186
|
+
setReplayMark(Date.now());
|
|
187
|
+
};
|
|
188
|
+
const windowContentContainer = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
189
|
+
const container = new external_pixi_js_namespaceObject.Container();
|
|
190
|
+
return container;
|
|
191
|
+
}, []);
|
|
192
|
+
const insightMarkContainer = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
193
|
+
const container = new external_pixi_js_namespaceObject.Container();
|
|
194
|
+
container.zIndex = LAYER_ORDER_INSIGHT;
|
|
195
|
+
return container;
|
|
196
|
+
}, []);
|
|
197
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
198
|
+
insightMarkContainer.visible = elementsVisible;
|
|
199
|
+
}, [
|
|
200
|
+
elementsVisible,
|
|
201
|
+
insightMarkContainer
|
|
202
|
+
]);
|
|
203
|
+
const basicCameraState = {
|
|
204
|
+
left: 0,
|
|
205
|
+
top: 0,
|
|
206
|
+
width: imageWidth,
|
|
207
|
+
pointerLeft: Math.round(imageWidth / 2),
|
|
208
|
+
pointerTop: Math.round(imageHeight / 2)
|
|
209
|
+
};
|
|
210
|
+
const [animationProgress, setAnimationProgress] = (0, external_react_namespaceObject.useState)(-1);
|
|
211
|
+
const cancelFlag = (0, external_react_namespaceObject.useRef)(false);
|
|
212
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
213
|
+
cancelFlag.current = false;
|
|
214
|
+
return ()=>{
|
|
215
|
+
cancelFlag.current = true;
|
|
216
|
+
};
|
|
217
|
+
}, []);
|
|
218
|
+
const cameraState = (0, external_react_namespaceObject.useRef)({
|
|
219
|
+
...basicCameraState
|
|
220
|
+
});
|
|
221
|
+
const resizeCanvasIfNeeded = async (newWidth, newHeight)=>{
|
|
222
|
+
if (app.screen.width !== newWidth || app.screen.height !== newHeight) {
|
|
223
|
+
app.renderer.resize(newWidth, newHeight);
|
|
224
|
+
if (divContainerRef.current) {
|
|
225
|
+
const aspectRatio = newWidth / newHeight;
|
|
226
|
+
divContainerRef.current.style.setProperty('--canvas-aspect-ratio', aspectRatio.toString());
|
|
227
|
+
}
|
|
228
|
+
const newBasicCameraState = {
|
|
229
|
+
left: 0,
|
|
230
|
+
top: 0,
|
|
231
|
+
width: newWidth,
|
|
232
|
+
pointerLeft: Math.round(newWidth / 2),
|
|
233
|
+
pointerTop: Math.round(newHeight / 2)
|
|
234
|
+
};
|
|
235
|
+
cameraState.current = newBasicCameraState;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const repaintImage = async (scriptWidth, scriptHeight)=>{
|
|
239
|
+
const imgToUpdate = currentImg.current;
|
|
240
|
+
if (!imgToUpdate) return void console.warn('no image to update');
|
|
241
|
+
const targetWidth = scriptWidth || imageWidth;
|
|
242
|
+
const targetHeight = scriptHeight || imageHeight;
|
|
243
|
+
await resizeCanvasIfNeeded(targetWidth, targetHeight);
|
|
244
|
+
if (!(0, pixi_loader_js_namespaceObject.getTextureFromCache)(imgToUpdate)) {
|
|
245
|
+
console.warn('image not loaded', imgToUpdate);
|
|
246
|
+
await (0, pixi_loader_js_namespaceObject.loadTexture)(imgToUpdate);
|
|
247
|
+
}
|
|
248
|
+
const texture = (0, pixi_loader_js_namespaceObject.getTextureFromCache)(imgToUpdate);
|
|
249
|
+
if (!texture) throw new Error('texture not found');
|
|
250
|
+
const sprite = external_pixi_js_namespaceObject.Sprite.from(texture);
|
|
251
|
+
if (!sprite) throw new Error('sprite not found');
|
|
252
|
+
const mainImgLabel = 'main-img';
|
|
253
|
+
const child = windowContentContainer.getChildByLabel(mainImgLabel);
|
|
254
|
+
if (child) windowContentContainer.removeChild(child);
|
|
255
|
+
sprite.label = mainImgLabel;
|
|
256
|
+
sprite.zIndex = LAYER_ORDER_IMG;
|
|
257
|
+
sprite.width = targetWidth;
|
|
258
|
+
sprite.height = targetHeight;
|
|
259
|
+
windowContentContainer.addChild(sprite);
|
|
260
|
+
};
|
|
261
|
+
const spinningPointer = (frame)=>{
|
|
262
|
+
var _pointerSprite_current, _pointerSprite_current1;
|
|
263
|
+
if (!spinningPointerSprite.current) {
|
|
264
|
+
spinningPointerSprite.current = external_pixi_js_namespaceObject.Sprite.from(index_js_namespaceObject.mouseLoading);
|
|
265
|
+
spinningPointerSprite.current.zIndex = LAYER_ORDER_SPINNING_POINTER;
|
|
266
|
+
spinningPointerSprite.current.anchor.set(0.5, 0.5);
|
|
267
|
+
spinningPointerSprite.current.scale.set(0.5);
|
|
268
|
+
spinningPointerSprite.current.label = 'spinning-pointer';
|
|
269
|
+
}
|
|
270
|
+
spinningPointerSprite.current.x = (null == (_pointerSprite_current = pointerSprite.current) ? void 0 : _pointerSprite_current.x) || 0;
|
|
271
|
+
spinningPointerSprite.current.y = (null == (_pointerSprite_current1 = pointerSprite.current) ? void 0 : _pointerSprite_current1.y) || 0;
|
|
272
|
+
windowContentContainer.addChild(spinningPointerSprite.current);
|
|
273
|
+
let startTime;
|
|
274
|
+
let isCancelled = false;
|
|
275
|
+
const animate = (currentTime)=>{
|
|
276
|
+
if (isCancelled) return;
|
|
277
|
+
if (!startTime) startTime = currentTime;
|
|
278
|
+
const elapsedTime = currentTime - startTime;
|
|
279
|
+
const progress = (Math.sin(elapsedTime / 500 - Math.PI / 2) + 1) / 2;
|
|
280
|
+
const rotation = progress * Math.PI * 2;
|
|
281
|
+
if (spinningPointerSprite.current) spinningPointerSprite.current.rotation = rotation;
|
|
282
|
+
frame(animate);
|
|
283
|
+
};
|
|
284
|
+
frame(animate);
|
|
285
|
+
const stopFn = ()=>{
|
|
286
|
+
if (spinningPointerSprite.current) windowContentContainer.removeChild(spinningPointerSprite.current);
|
|
287
|
+
isCancelled = true;
|
|
288
|
+
};
|
|
289
|
+
return stopFn;
|
|
290
|
+
};
|
|
291
|
+
const updatePointer = async (img, x, y)=>{
|
|
292
|
+
var _pointerSprite_current, _pointerSprite_current1;
|
|
293
|
+
if (!(0, pixi_loader_js_namespaceObject.getTextureFromCache)(img)) {
|
|
294
|
+
console.warn('image not loaded', img);
|
|
295
|
+
await (0, pixi_loader_js_namespaceObject.loadTexture)(img);
|
|
296
|
+
}
|
|
297
|
+
const texture = (0, pixi_loader_js_namespaceObject.getTextureFromCache)(img);
|
|
298
|
+
if (!texture) throw new Error('texture not found');
|
|
299
|
+
const sprite = external_pixi_js_namespaceObject.Sprite.from(texture);
|
|
300
|
+
let targetX = null == (_pointerSprite_current = pointerSprite.current) ? void 0 : _pointerSprite_current.x;
|
|
301
|
+
let targetY = null == (_pointerSprite_current1 = pointerSprite.current) ? void 0 : _pointerSprite_current1.y;
|
|
302
|
+
if ('number' == typeof x) targetX = x;
|
|
303
|
+
if ('number' == typeof y) targetY = y;
|
|
304
|
+
if (void 0 === targetX || void 0 === targetY) return void console.warn('invalid pointer position', x, y);
|
|
305
|
+
if (pointerSprite.current) {
|
|
306
|
+
const pointer = windowContentContainer.getChildByLabel('pointer');
|
|
307
|
+
if (pointer) windowContentContainer.removeChild(pointer);
|
|
308
|
+
}
|
|
309
|
+
pointerSprite.current = sprite;
|
|
310
|
+
pointerSprite.current.x = targetX;
|
|
311
|
+
pointerSprite.current.y = targetY;
|
|
312
|
+
pointerSprite.current.label = 'pointer';
|
|
313
|
+
pointerSprite.current.zIndex = LAYER_ORDER_POINTER;
|
|
314
|
+
windowContentContainer.addChild(pointerSprite.current);
|
|
315
|
+
};
|
|
316
|
+
const updateCamera = (state, currentWidth)=>{
|
|
317
|
+
cameraState.current = state;
|
|
318
|
+
const effectiveWidth = currentWidth || app.screen.width || imageWidth;
|
|
319
|
+
const newScale = autoZoom ? Math.max(1, effectiveWidth / state.width) : 1;
|
|
320
|
+
windowContentContainer.scale.set(newScale);
|
|
321
|
+
windowContentContainer.x = autoZoom ? Math.round(canvasPaddingLeft - state.left * newScale) : canvasPaddingLeft;
|
|
322
|
+
windowContentContainer.y = autoZoom ? Math.round(canvasPaddingTop - state.top * newScale) : canvasPaddingTop;
|
|
323
|
+
const pointer = windowContentContainer.getChildByLabel('pointer');
|
|
324
|
+
if (pointer) {
|
|
325
|
+
pointer.scale.set(1 / newScale);
|
|
326
|
+
if ('number' == typeof state.pointerLeft && 'number' == typeof state.pointerTop) {
|
|
327
|
+
pointer.x = state.pointerLeft;
|
|
328
|
+
pointer.y = state.pointerTop;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
const cameraAnimation = async (targetState, duration, frame)=>{
|
|
333
|
+
const currentCanvasWidth = app.screen.width || imageWidth;
|
|
334
|
+
const currentCanvasHeight = app.screen.height || imageHeight;
|
|
335
|
+
if (!autoZoom) {
|
|
336
|
+
const currentState = {
|
|
337
|
+
...cameraState.current
|
|
338
|
+
};
|
|
339
|
+
const startPointerLeft = currentState.pointerLeft;
|
|
340
|
+
const startPointerTop = currentState.pointerTop;
|
|
341
|
+
const startTime = performance.now();
|
|
342
|
+
const shouldMovePointer = 'number' == typeof targetState.pointerLeft && 'number' == typeof targetState.pointerTop && (targetState.pointerLeft !== startPointerLeft || targetState.pointerTop !== startPointerTop);
|
|
343
|
+
if (!shouldMovePointer) return;
|
|
344
|
+
await new Promise((resolve)=>{
|
|
345
|
+
const animate = (currentTime)=>{
|
|
346
|
+
const elapsedTime = currentTime - startTime;
|
|
347
|
+
const rawProgress = Math.min(elapsedTime / duration, 1);
|
|
348
|
+
const progress = cubicMouse(rawProgress);
|
|
349
|
+
const nextState = {
|
|
350
|
+
...currentState,
|
|
351
|
+
pointerLeft: startPointerLeft + (targetState.pointerLeft - startPointerLeft) * progress,
|
|
352
|
+
pointerTop: startPointerTop + (targetState.pointerTop - startPointerTop) * progress
|
|
353
|
+
};
|
|
354
|
+
updateCamera(nextState, currentCanvasWidth);
|
|
355
|
+
if (elapsedTime < duration) frame(animate);
|
|
356
|
+
else resolve();
|
|
357
|
+
};
|
|
358
|
+
frame(animate);
|
|
359
|
+
});
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const currentState = {
|
|
363
|
+
...cameraState.current
|
|
364
|
+
};
|
|
365
|
+
const startLeft = currentState.left;
|
|
366
|
+
const startTop = currentState.top;
|
|
367
|
+
const startPointerLeft = currentState.pointerLeft;
|
|
368
|
+
const startPointerTop = currentState.pointerTop;
|
|
369
|
+
const startScale = currentState.width / currentCanvasWidth;
|
|
370
|
+
const startTime = performance.now();
|
|
371
|
+
const shouldMovePointer = 'number' == typeof targetState.pointerLeft && 'number' == typeof targetState.pointerTop && (targetState.pointerLeft !== startPointerLeft || targetState.pointerTop !== startPointerTop);
|
|
372
|
+
const pointerMoveDuration = shouldMovePointer ? 0.375 * duration : 0;
|
|
373
|
+
const cameraMoveStart = pointerMoveDuration;
|
|
374
|
+
const cameraMoveDuration = duration - pointerMoveDuration;
|
|
375
|
+
await new Promise((resolve)=>{
|
|
376
|
+
const animate = (currentTime)=>{
|
|
377
|
+
const nextState = {
|
|
378
|
+
...cameraState.current
|
|
379
|
+
};
|
|
380
|
+
const elapsedTime = currentTime - startTime;
|
|
381
|
+
if (shouldMovePointer) if (elapsedTime <= pointerMoveDuration) {
|
|
382
|
+
const rawMouseProgress = Math.min(elapsedTime / pointerMoveDuration, 1);
|
|
383
|
+
const mouseProgress = cubicMouse(rawMouseProgress);
|
|
384
|
+
nextState.pointerLeft = startPointerLeft + (targetState.pointerLeft - startPointerLeft) * mouseProgress;
|
|
385
|
+
nextState.pointerTop = startPointerTop + (targetState.pointerTop - startPointerTop) * mouseProgress;
|
|
386
|
+
} else {
|
|
387
|
+
nextState.pointerLeft = targetState.pointerLeft;
|
|
388
|
+
nextState.pointerTop = targetState.pointerTop;
|
|
389
|
+
}
|
|
390
|
+
if (elapsedTime > cameraMoveStart) {
|
|
391
|
+
const cameraElapsedTime = elapsedTime - cameraMoveStart;
|
|
392
|
+
const rawCameraProgress = Math.min(cameraElapsedTime / cameraMoveDuration, 1);
|
|
393
|
+
const cameraProgress = cubicImage(rawCameraProgress);
|
|
394
|
+
const targetScale = targetState.width / currentCanvasWidth;
|
|
395
|
+
const progressScale = startScale + (targetScale - startScale) * cameraProgress;
|
|
396
|
+
const progressWidth = currentCanvasWidth * progressScale;
|
|
397
|
+
const progressHeight = currentCanvasHeight * progressScale;
|
|
398
|
+
nextState.width = progressWidth;
|
|
399
|
+
const progressLeft = startLeft + (targetState.left - startLeft) * cameraProgress;
|
|
400
|
+
const progressTop = startTop + (targetState.top - startTop) * cameraProgress;
|
|
401
|
+
const horizontalExceed = progressLeft + progressWidth - currentCanvasWidth;
|
|
402
|
+
const verticalExceed = progressTop + progressHeight - currentCanvasHeight;
|
|
403
|
+
nextState.left = horizontalExceed > 0 ? progressLeft + horizontalExceed : progressLeft;
|
|
404
|
+
nextState.top = verticalExceed > 0 ? progressTop + verticalExceed : progressTop;
|
|
405
|
+
}
|
|
406
|
+
updateCamera(nextState, currentCanvasWidth);
|
|
407
|
+
if (elapsedTime < duration) frame(animate);
|
|
408
|
+
else resolve();
|
|
409
|
+
};
|
|
410
|
+
frame(animate);
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
const fadeInGraphics = function(graphics, duration, frame) {
|
|
414
|
+
let targetAlpha = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : 1;
|
|
415
|
+
return new Promise((resolve)=>{
|
|
416
|
+
const startTime = performance.now();
|
|
417
|
+
const animate = (currentTime)=>{
|
|
418
|
+
const elapsedTime = currentTime - startTime;
|
|
419
|
+
const progress = Math.min(elapsedTime / duration, 1);
|
|
420
|
+
graphics.alpha = 0 === targetAlpha ? 1 - linear(progress) : linear(progress);
|
|
421
|
+
if (elapsedTime < duration) frame(animate);
|
|
422
|
+
else resolve();
|
|
423
|
+
};
|
|
424
|
+
frame(animate);
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
const fadeOutItem = async (graphics, duration, frame)=>fadeInGraphics(graphics, duration, frame, 0);
|
|
428
|
+
const insightElementsAnimation = async (elements, highlightElements, searchArea, duration, frame)=>{
|
|
429
|
+
insightMarkContainer.removeChildren();
|
|
430
|
+
const elementsToAdd = [
|
|
431
|
+
...elements
|
|
432
|
+
];
|
|
433
|
+
const totalLength = elementsToAdd.length;
|
|
434
|
+
let childrenCount = 0;
|
|
435
|
+
await new Promise((resolve)=>{
|
|
436
|
+
const startTime = performance.now();
|
|
437
|
+
const animate = (currentTime)=>{
|
|
438
|
+
const elapsedTime = currentTime - startTime;
|
|
439
|
+
const progress = cubicInsightElement(Math.min(elapsedTime / duration, 1));
|
|
440
|
+
const elementsToAddNow = Math.floor(progress * totalLength);
|
|
441
|
+
while(childrenCount < elementsToAddNow){
|
|
442
|
+
const randomIndex = Math.floor(Math.random() * elementsToAdd.length);
|
|
443
|
+
const element = elementsToAdd.splice(randomIndex, 1)[0];
|
|
444
|
+
if (element) {
|
|
445
|
+
const [insightMarkGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(element.rect, element.content, 'element');
|
|
446
|
+
insightMarkGraphic.alpha = 0;
|
|
447
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
448
|
+
childrenCount++;
|
|
449
|
+
fadeInGraphics(insightMarkGraphic, singleElementFadeInDuration, frame);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
if (elapsedTime < duration) frame(animate);
|
|
453
|
+
else {
|
|
454
|
+
while(elementsToAdd.length > 0){
|
|
455
|
+
const randomIndex = Math.floor(Math.random() * elementsToAdd.length);
|
|
456
|
+
const element = elementsToAdd.splice(randomIndex, 1)[0];
|
|
457
|
+
const [insightMarkGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(element.rect, element.content, 'element');
|
|
458
|
+
insightMarkGraphic.alpha = 1;
|
|
459
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
460
|
+
}
|
|
461
|
+
if (searchArea) {
|
|
462
|
+
const [searchAreaGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(searchArea, 'Search Area', 'searchArea');
|
|
463
|
+
searchAreaGraphic.alpha = 1;
|
|
464
|
+
insightMarkContainer.addChild(searchAreaGraphic);
|
|
465
|
+
}
|
|
466
|
+
highlightElements.map((element)=>{
|
|
467
|
+
const [insightMarkGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(element.rect, element.content || '', 'highlight');
|
|
468
|
+
insightMarkGraphic.alpha = 1;
|
|
469
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
470
|
+
});
|
|
471
|
+
resolve();
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
frame(animate);
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
const init = async ()=>{
|
|
478
|
+
if (!divContainerRef.current || !scripts) return;
|
|
479
|
+
await app.init({
|
|
480
|
+
width: imageWidth,
|
|
481
|
+
height: imageHeight,
|
|
482
|
+
background: 0xf4f4f4,
|
|
483
|
+
autoDensity: true,
|
|
484
|
+
antialias: true
|
|
485
|
+
});
|
|
486
|
+
if (!divContainerRef.current) return;
|
|
487
|
+
divContainerRef.current.appendChild(app.canvas);
|
|
488
|
+
windowContentContainer.x = 0;
|
|
489
|
+
windowContentContainer.y = 0;
|
|
490
|
+
app.stage.addChild(windowContentContainer);
|
|
491
|
+
insightMarkContainer.x = 0;
|
|
492
|
+
insightMarkContainer.y = 0;
|
|
493
|
+
windowContentContainer.addChild(insightMarkContainer);
|
|
494
|
+
};
|
|
495
|
+
const [isRecording, setIsRecording] = (0, external_react_namespaceObject.useState)(false);
|
|
496
|
+
const recorderSessionRef = (0, external_react_namespaceObject.useRef)(null);
|
|
497
|
+
const handleExport = ()=>{
|
|
498
|
+
if (recorderSessionRef.current) return void console.warn('recorderSession exists');
|
|
499
|
+
if (!app.canvas) return void console.warn('canvas is not initialized');
|
|
500
|
+
recorderSessionRef.current = new RecordingSession(app.canvas);
|
|
501
|
+
setIsRecording(true);
|
|
502
|
+
triggerReplay();
|
|
503
|
+
};
|
|
504
|
+
const play = ()=>{
|
|
505
|
+
let cancelFn;
|
|
506
|
+
Promise.resolve((async ()=>{
|
|
507
|
+
if (!app) throw new Error('app is not initialized');
|
|
508
|
+
if (!scripts) throw new Error("scripts is required");
|
|
509
|
+
const { frame, cancel, timeout } = frameKit();
|
|
510
|
+
cancelFn = cancel;
|
|
511
|
+
const allImages = scripts.filter((item)=>!!item.img).map((item)=>item.img);
|
|
512
|
+
await Promise.all([
|
|
513
|
+
...allImages,
|
|
514
|
+
index_js_namespaceObject.mouseLoading,
|
|
515
|
+
index_js_namespaceObject.mousePointer
|
|
516
|
+
].map(pixi_loader_js_namespaceObject.loadTexture));
|
|
517
|
+
insightMarkContainer.removeChildren();
|
|
518
|
+
await updatePointer(index_js_namespaceObject.mousePointer, imageWidth / 2, imageHeight / 2);
|
|
519
|
+
await repaintImage();
|
|
520
|
+
await updateCamera({
|
|
521
|
+
...basicCameraState
|
|
522
|
+
});
|
|
523
|
+
const totalDuration = scripts.reduce((acc, item)=>acc + item.duration + (item.camera && item.insightCameraDuration ? item.insightCameraDuration : 0), 0);
|
|
524
|
+
const progressUpdateInterval = 200;
|
|
525
|
+
const startTime = performance.now();
|
|
526
|
+
setAnimationProgress(0);
|
|
527
|
+
const updateProgress = ()=>{
|
|
528
|
+
const progress = Math.min((performance.now() - startTime) / totalDuration, 1);
|
|
529
|
+
setAnimationProgress(progress);
|
|
530
|
+
if (progress < 1) return timeout(updateProgress, progressUpdateInterval);
|
|
531
|
+
};
|
|
532
|
+
frame(updateProgress);
|
|
533
|
+
if (recorderSessionRef.current) recorderSessionRef.current.start();
|
|
534
|
+
for(const index in scripts){
|
|
535
|
+
const item = scripts[index];
|
|
536
|
+
setTitleText(item.title || '');
|
|
537
|
+
setSubTitleText(item.subTitle || '');
|
|
538
|
+
if ('sleep' === item.type) await sleep(item.duration);
|
|
539
|
+
else if ('insight' === item.type) {
|
|
540
|
+
var _item_context;
|
|
541
|
+
if (!item.img) throw new Error('img is required');
|
|
542
|
+
currentImg.current = item.img;
|
|
543
|
+
await repaintImage(item.imageWidth, item.imageHeight);
|
|
544
|
+
const elements = (null == (_item_context = item.context) ? void 0 : _item_context.tree) ? (0, extractor_namespaceObject.treeToList)(item.context.tree) : [];
|
|
545
|
+
const highlightElements = item.highlightElement ? [
|
|
546
|
+
item.highlightElement
|
|
547
|
+
] : [];
|
|
548
|
+
await insightElementsAnimation(elements, highlightElements, item.searchArea, item.duration, frame);
|
|
549
|
+
if (item.camera) {
|
|
550
|
+
if (!item.insightCameraDuration) throw new Error('insightCameraDuration is required');
|
|
551
|
+
await cameraAnimation(item.camera, item.insightCameraDuration, frame);
|
|
552
|
+
}
|
|
553
|
+
} else if ('clear-insight' === item.type) {
|
|
554
|
+
await fadeOutItem(insightMarkContainer, item.duration, frame);
|
|
555
|
+
insightMarkContainer.removeChildren();
|
|
556
|
+
insightMarkContainer.alpha = 1;
|
|
557
|
+
} else if ('img' === item.type) {
|
|
558
|
+
if (item.img && item.img !== currentImg.current) {
|
|
559
|
+
currentImg.current = item.img;
|
|
560
|
+
await repaintImage(item.imageWidth, item.imageHeight);
|
|
561
|
+
}
|
|
562
|
+
if (item.camera) await cameraAnimation(item.camera, item.duration, frame);
|
|
563
|
+
else await sleep(item.duration);
|
|
564
|
+
} else if ('pointer' === item.type) {
|
|
565
|
+
if (!item.img) throw new Error('pointer img is required');
|
|
566
|
+
await updatePointer(item.img);
|
|
567
|
+
} else if ('spinning-pointer' === item.type) {
|
|
568
|
+
const stop = spinningPointer(frame);
|
|
569
|
+
await sleep(item.duration);
|
|
570
|
+
stop();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
if (recorderSessionRef.current) {
|
|
574
|
+
await sleep(1200);
|
|
575
|
+
recorderSessionRef.current.stop();
|
|
576
|
+
recorderSessionRef.current = null;
|
|
577
|
+
setIsRecording(false);
|
|
578
|
+
}
|
|
579
|
+
})().catch((e)=>{
|
|
580
|
+
console.error('player error', e);
|
|
581
|
+
}));
|
|
582
|
+
return ()=>{
|
|
583
|
+
null == cancelFn || cancelFn();
|
|
584
|
+
};
|
|
585
|
+
};
|
|
586
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
587
|
+
Promise.resolve((async ()=>{
|
|
588
|
+
await init();
|
|
589
|
+
if (divContainerRef.current && imageWidth && imageHeight) {
|
|
590
|
+
const aspectRatio = imageWidth / imageHeight;
|
|
591
|
+
divContainerRef.current.style.setProperty('--canvas-aspect-ratio', aspectRatio.toString());
|
|
592
|
+
divContainerRef.current.setAttribute('data-fit-mode', fitMode);
|
|
593
|
+
const playerContainer = divContainerRef.current.closest('.player-container');
|
|
594
|
+
if (playerContainer) playerContainer.setAttribute('data-fit-mode', fitMode);
|
|
595
|
+
}
|
|
596
|
+
triggerReplay();
|
|
597
|
+
})());
|
|
598
|
+
return ()=>{
|
|
599
|
+
try {
|
|
600
|
+
app.destroy(true, {
|
|
601
|
+
children: true,
|
|
602
|
+
texture: true
|
|
603
|
+
});
|
|
604
|
+
} catch (e) {
|
|
605
|
+
console.warn('destroy failed', e);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
}, [
|
|
609
|
+
imageWidth,
|
|
610
|
+
imageHeight,
|
|
611
|
+
fitMode
|
|
612
|
+
]);
|
|
613
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
614
|
+
if (replayMark) return play();
|
|
615
|
+
}, [
|
|
616
|
+
replayMark
|
|
617
|
+
]);
|
|
618
|
+
const [mouseOverStatusIcon, setMouseOverStatusIcon] = (0, external_react_namespaceObject.useState)(false);
|
|
619
|
+
const [mouseOverSettingsIcon, setMouseOverSettingsIcon] = (0, external_react_namespaceObject.useState)(false);
|
|
620
|
+
const progressString = Math.round(100 * animationProgress);
|
|
621
|
+
const transitionStyle = 0 === animationProgress ? 'none' : '0.3s';
|
|
622
|
+
const canReplayNow = 1 === animationProgress;
|
|
623
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
624
|
+
if (canReplayNow) {
|
|
625
|
+
const listener = (event)=>{
|
|
626
|
+
if (' ' === event.key) triggerReplay();
|
|
627
|
+
};
|
|
628
|
+
window.addEventListener('keydown', listener);
|
|
629
|
+
return ()=>{
|
|
630
|
+
window.removeEventListener('keydown', listener);
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
}, [
|
|
634
|
+
canReplayNow
|
|
635
|
+
]);
|
|
636
|
+
let statusIconElement;
|
|
637
|
+
let statusOnClick = ()=>{};
|
|
638
|
+
if (animationProgress < 1) statusIconElement = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
639
|
+
indicator: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.LoadingOutlined, {
|
|
640
|
+
spin: true,
|
|
641
|
+
color: "#333"
|
|
642
|
+
}),
|
|
643
|
+
size: "default"
|
|
644
|
+
});
|
|
645
|
+
else if (mouseOverStatusIcon) {
|
|
646
|
+
statusIconElement = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
647
|
+
indicator: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.CaretRightOutlined, {
|
|
648
|
+
color: "#333"
|
|
649
|
+
}),
|
|
650
|
+
size: "default"
|
|
651
|
+
});
|
|
652
|
+
statusOnClick = ()=>triggerReplay();
|
|
653
|
+
} else statusIconElement = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
654
|
+
indicator: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.CaretRightOutlined, {
|
|
655
|
+
color: "#333"
|
|
656
|
+
}),
|
|
657
|
+
size: "default"
|
|
658
|
+
});
|
|
659
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
660
|
+
className: "player-container",
|
|
661
|
+
children: [
|
|
662
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
663
|
+
className: "canvas-container",
|
|
664
|
+
ref: divContainerRef
|
|
665
|
+
}),
|
|
666
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
667
|
+
className: "player-timeline-wrapper",
|
|
668
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
669
|
+
className: "player-timeline",
|
|
670
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
671
|
+
className: "player-timeline-progress",
|
|
672
|
+
style: {
|
|
673
|
+
width: `${progressString}%`,
|
|
674
|
+
transition: transitionStyle
|
|
675
|
+
}
|
|
676
|
+
})
|
|
677
|
+
})
|
|
678
|
+
}),
|
|
679
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
680
|
+
className: "player-tools-wrapper",
|
|
681
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
682
|
+
className: "player-tools",
|
|
683
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
684
|
+
className: "player-control",
|
|
685
|
+
children: [
|
|
686
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
687
|
+
className: "status-text",
|
|
688
|
+
children: [
|
|
689
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
690
|
+
className: "title",
|
|
691
|
+
children: titleText
|
|
692
|
+
}),
|
|
693
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
694
|
+
title: subTitleText,
|
|
695
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
696
|
+
className: "subtitle",
|
|
697
|
+
children: subTitleText
|
|
698
|
+
})
|
|
699
|
+
})
|
|
700
|
+
]
|
|
701
|
+
}),
|
|
702
|
+
isRecording ? null : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
703
|
+
className: "status-icon",
|
|
704
|
+
onMouseEnter: ()=>setMouseOverStatusIcon(true),
|
|
705
|
+
onMouseLeave: ()=>setMouseOverStatusIcon(false),
|
|
706
|
+
onClick: statusOnClick,
|
|
707
|
+
children: statusIconElement
|
|
708
|
+
}),
|
|
709
|
+
(null == props ? void 0 : props.reportFileContent) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
710
|
+
title: "Download Report",
|
|
711
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
712
|
+
className: "status-icon",
|
|
713
|
+
onMouseEnter: ()=>setMouseOverStatusIcon(true),
|
|
714
|
+
onMouseLeave: ()=>setMouseOverStatusIcon(false),
|
|
715
|
+
onClick: ()=>downloadReport(props.reportFileContent),
|
|
716
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.DownloadOutlined, {
|
|
717
|
+
color: "#333"
|
|
718
|
+
})
|
|
719
|
+
})
|
|
720
|
+
}) : null,
|
|
721
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
722
|
+
title: isRecording ? 'Generating...' : 'Export Video',
|
|
723
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
724
|
+
className: "status-icon",
|
|
725
|
+
onClick: isRecording ? void 0 : handleExport,
|
|
726
|
+
style: {
|
|
727
|
+
opacity: isRecording ? 0.5 : 1,
|
|
728
|
+
cursor: isRecording ? 'not-allowed' : 'pointer'
|
|
729
|
+
},
|
|
730
|
+
children: isRecording ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {
|
|
731
|
+
size: "default",
|
|
732
|
+
percent: progressString
|
|
733
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.ExportOutlined, {})
|
|
734
|
+
})
|
|
735
|
+
}),
|
|
736
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Dropdown, {
|
|
737
|
+
trigger: [
|
|
738
|
+
'hover',
|
|
739
|
+
'click'
|
|
740
|
+
],
|
|
741
|
+
placement: "bottomRight",
|
|
742
|
+
overlayStyle: {
|
|
743
|
+
minWidth: '148px'
|
|
744
|
+
},
|
|
745
|
+
dropdownRender: (menu)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
746
|
+
style: {
|
|
747
|
+
borderRadius: '8px',
|
|
748
|
+
border: '1px solid rgba(0, 0, 0, 0.08)',
|
|
749
|
+
backgroundColor: '#fff',
|
|
750
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.08)',
|
|
751
|
+
overflow: 'hidden'
|
|
752
|
+
},
|
|
753
|
+
children: menu
|
|
754
|
+
}),
|
|
755
|
+
menu: {
|
|
756
|
+
style: {
|
|
757
|
+
borderRadius: '8px',
|
|
758
|
+
padding: 0
|
|
759
|
+
},
|
|
760
|
+
items: [
|
|
761
|
+
{
|
|
762
|
+
key: 'autoZoom',
|
|
763
|
+
style: {
|
|
764
|
+
height: '39px',
|
|
765
|
+
margin: 0,
|
|
766
|
+
padding: '0 12px'
|
|
767
|
+
},
|
|
768
|
+
label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
769
|
+
style: {
|
|
770
|
+
display: 'flex',
|
|
771
|
+
alignItems: 'center',
|
|
772
|
+
justifyContent: 'space-between',
|
|
773
|
+
width: '100%',
|
|
774
|
+
height: '39px'
|
|
775
|
+
},
|
|
776
|
+
children: [
|
|
777
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
778
|
+
style: {
|
|
779
|
+
display: 'flex',
|
|
780
|
+
alignItems: 'center',
|
|
781
|
+
gap: '4px'
|
|
782
|
+
},
|
|
783
|
+
children: [
|
|
784
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(global_perspective_js_default(), {
|
|
785
|
+
style: {
|
|
786
|
+
width: '16px',
|
|
787
|
+
height: '16px'
|
|
788
|
+
}
|
|
789
|
+
}),
|
|
790
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
791
|
+
style: {
|
|
792
|
+
fontSize: '12px',
|
|
793
|
+
marginRight: '16px'
|
|
794
|
+
},
|
|
795
|
+
children: "Focus on cursor"
|
|
796
|
+
})
|
|
797
|
+
]
|
|
798
|
+
}),
|
|
799
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Switch, {
|
|
800
|
+
size: "small",
|
|
801
|
+
checked: autoZoom,
|
|
802
|
+
onChange: (checked)=>{
|
|
803
|
+
setAutoZoom(checked);
|
|
804
|
+
triggerReplay();
|
|
805
|
+
},
|
|
806
|
+
onClick: (_, e)=>{
|
|
807
|
+
var _e_stopPropagation;
|
|
808
|
+
return null == e ? void 0 : null == (_e_stopPropagation = e.stopPropagation) ? void 0 : _e_stopPropagation.call(e);
|
|
809
|
+
}
|
|
810
|
+
})
|
|
811
|
+
]
|
|
812
|
+
})
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
key: 'elementsVisible',
|
|
816
|
+
style: {
|
|
817
|
+
height: '39px',
|
|
818
|
+
margin: 0,
|
|
819
|
+
padding: '0 12px'
|
|
820
|
+
},
|
|
821
|
+
label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
822
|
+
style: {
|
|
823
|
+
display: 'flex',
|
|
824
|
+
alignItems: 'center',
|
|
825
|
+
justifyContent: 'space-between',
|
|
826
|
+
width: '100%',
|
|
827
|
+
height: '39px'
|
|
828
|
+
},
|
|
829
|
+
children: [
|
|
830
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
831
|
+
style: {
|
|
832
|
+
display: 'flex',
|
|
833
|
+
alignItems: 'center',
|
|
834
|
+
gap: '4px'
|
|
835
|
+
},
|
|
836
|
+
children: [
|
|
837
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(show_marker_js_default(), {
|
|
838
|
+
style: {
|
|
839
|
+
width: '16px',
|
|
840
|
+
height: '16px'
|
|
841
|
+
}
|
|
842
|
+
}),
|
|
843
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
844
|
+
style: {
|
|
845
|
+
fontSize: '12px',
|
|
846
|
+
marginRight: '16px'
|
|
847
|
+
},
|
|
848
|
+
children: "Show element markers"
|
|
849
|
+
})
|
|
850
|
+
]
|
|
851
|
+
}),
|
|
852
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Switch, {
|
|
853
|
+
size: "small",
|
|
854
|
+
checked: elementsVisible,
|
|
855
|
+
onChange: (checked)=>{
|
|
856
|
+
setElementsVisible(checked);
|
|
857
|
+
triggerReplay();
|
|
858
|
+
},
|
|
859
|
+
onClick: (_, e)=>{
|
|
860
|
+
var _e_stopPropagation;
|
|
861
|
+
return null == e ? void 0 : null == (_e_stopPropagation = e.stopPropagation) ? void 0 : _e_stopPropagation.call(e);
|
|
862
|
+
}
|
|
863
|
+
})
|
|
864
|
+
]
|
|
865
|
+
})
|
|
866
|
+
}
|
|
867
|
+
]
|
|
868
|
+
},
|
|
869
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
870
|
+
className: "status-icon",
|
|
871
|
+
onMouseEnter: ()=>setMouseOverSettingsIcon(true),
|
|
872
|
+
onMouseLeave: ()=>setMouseOverSettingsIcon(false),
|
|
873
|
+
style: {
|
|
874
|
+
cursor: 'pointer',
|
|
875
|
+
display: 'flex',
|
|
876
|
+
alignItems: 'center',
|
|
877
|
+
justifyContent: 'center',
|
|
878
|
+
opacity: mouseOverSettingsIcon ? 1 : 0.7,
|
|
879
|
+
transition: 'opacity 0.2s'
|
|
880
|
+
},
|
|
881
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(player_setting_js_default(), {
|
|
882
|
+
style: {
|
|
883
|
+
width: '16px',
|
|
884
|
+
height: '16px'
|
|
885
|
+
}
|
|
886
|
+
})
|
|
887
|
+
})
|
|
888
|
+
})
|
|
889
|
+
]
|
|
890
|
+
})
|
|
891
|
+
})
|
|
892
|
+
})
|
|
893
|
+
]
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
exports.Player = __webpack_exports__.Player;
|
|
897
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
898
|
+
"Player"
|
|
899
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
900
|
+
Object.defineProperty(exports, '__esModule', {
|
|
901
|
+
value: true
|
|
902
|
+
});
|