@midscene/visualizer 0.30.9 → 0.30.11-beta-20251218071621.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/component/blackboard/index.css +8 -0
- package/dist/es/component/blackboard/index.mjs +137 -68
- package/dist/es/component/config-selector/index.mjs +102 -4
- package/dist/es/component/context-preview/index.mjs +1 -2
- package/dist/es/component/env-config/index.mjs +1 -2
- package/dist/es/component/env-config-reminder/index.css +8 -0
- package/dist/es/component/env-config-reminder/index.mjs +1 -2
- package/dist/es/component/form-field/index.mjs +5 -10
- package/dist/es/component/history-selector/index.css +38 -1
- package/dist/es/component/history-selector/index.mjs +1 -2
- package/dist/es/component/logo/index.mjs +7 -3
- package/dist/es/component/misc/index.mjs +1 -4
- package/dist/es/component/nav-actions/index.mjs +1 -2
- package/dist/es/component/nav-actions/style.css +1 -1
- package/dist/es/component/player/index.css +26 -0
- package/dist/es/component/player/index.mjs +376 -364
- package/dist/es/component/playground/index.css +291 -31
- package/dist/es/component/playground-result/index.css +10 -0
- package/dist/es/component/playground-result/index.mjs +129 -10
- package/dist/es/component/prompt-input/index.css +281 -31
- package/dist/es/component/prompt-input/index.mjs +83 -25
- package/dist/es/component/screenshot-viewer/index.css +214 -0
- package/dist/es/component/screenshot-viewer/index.mjs +282 -0
- package/dist/es/component/service-mode-control/index.mjs +1 -2
- package/dist/es/component/shiny-text/index.css +35 -3
- package/dist/es/component/shiny-text/index.mjs +3 -3
- package/dist/es/component/universal-playground/index.css +61 -1
- package/dist/es/component/universal-playground/index.mjs +106 -83
- package/dist/es/component/universal-playground/providers/context-provider.mjs +56 -18
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +213 -139
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +199 -121
- package/dist/es/hooks/usePlaygroundExecution.mjs +297 -146
- package/dist/es/hooks/usePlaygroundState.mjs +141 -75
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +2 -6
- package/dist/es/hooks/useServerValid.mjs +37 -12
- package/dist/es/hooks/useTheme.mjs +25 -0
- package/dist/es/icons/avatar.mjs +46 -4
- package/dist/es/icons/close.mjs +46 -4
- package/dist/es/icons/global-perspective.mjs +47 -5
- package/dist/es/icons/history.mjs +48 -6
- package/dist/es/icons/magnifying-glass.mjs +47 -5
- package/dist/es/icons/player-setting.mjs +48 -6
- package/dist/es/icons/setting.mjs +47 -5
- package/dist/es/icons/show-marker.mjs +47 -5
- package/dist/es/index.mjs +4 -4
- package/dist/es/store/history.mjs +46 -7
- package/dist/es/store/store.mjs +68 -2
- package/dist/es/types.mjs +1 -1
- package/dist/es/utils/constants.mjs +7 -3
- package/dist/es/utils/index.mjs +4 -1
- package/dist/es/utils/pixi-loader.mjs +37 -11
- package/dist/es/utils/replay-scripts.mjs +160 -111
- package/dist/lib/component/blackboard/index.css +8 -0
- package/dist/lib/component/blackboard/index.js +139 -70
- package/dist/lib/component/config-selector/index.js +103 -5
- package/dist/lib/component/context-preview/index.js +3 -4
- package/dist/lib/component/env-config/index.js +3 -4
- package/dist/lib/component/env-config-reminder/index.css +8 -0
- package/dist/lib/component/env-config-reminder/index.js +3 -4
- package/dist/lib/component/form-field/index.js +10 -15
- package/dist/lib/component/history-selector/index.css +38 -1
- package/dist/lib/component/history-selector/index.js +3 -4
- package/dist/lib/component/index.js +6 -8
- package/dist/lib/component/logo/index.js +9 -5
- package/dist/lib/component/misc/index.js +6 -9
- package/dist/lib/component/nav-actions/index.js +3 -4
- package/dist/lib/component/nav-actions/style.css +1 -1
- package/dist/lib/component/player/index.css +26 -0
- package/dist/lib/component/player/index.js +376 -365
- package/dist/lib/component/playground/index.css +291 -31
- package/dist/lib/component/playground/index.js +31 -33
- package/dist/lib/component/playground-result/index.css +10 -0
- package/dist/lib/component/playground-result/index.js +131 -12
- package/dist/lib/component/prompt-input/index.css +281 -31
- package/dist/lib/component/prompt-input/index.js +84 -26
- package/dist/lib/component/screenshot-viewer/index.css +214 -0
- package/dist/lib/component/screenshot-viewer/index.js +316 -0
- package/dist/lib/component/service-mode-control/index.js +3 -4
- package/dist/lib/component/shiny-text/index.css +35 -3
- package/dist/lib/component/shiny-text/index.js +5 -5
- package/dist/lib/component/universal-playground/index.css +61 -1
- package/dist/lib/component/universal-playground/index.js +108 -84
- package/dist/lib/component/universal-playground/providers/context-provider.js +58 -20
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +217 -143
- package/dist/lib/component/universal-playground/providers/storage-provider.js +207 -129
- package/dist/lib/hooks/usePlaygroundExecution.js +299 -148
- package/dist/lib/hooks/usePlaygroundState.js +143 -77
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +4 -8
- package/dist/lib/hooks/useServerValid.js +39 -14
- package/dist/lib/hooks/useTheme.js +59 -0
- package/dist/lib/icons/avatar.js +48 -6
- package/dist/lib/icons/close.js +48 -6
- package/dist/lib/icons/global-perspective.js +49 -7
- package/dist/lib/icons/history.js +50 -8
- package/dist/lib/icons/magnifying-glass.js +49 -7
- package/dist/lib/icons/player-setting.js +50 -8
- package/dist/lib/icons/setting.js +49 -7
- package/dist/lib/icons/show-marker.js +49 -7
- package/dist/lib/index.js +44 -34
- package/dist/lib/store/history.js +48 -9
- package/dist/lib/store/store.js +74 -8
- package/dist/lib/types.js +3 -3
- package/dist/lib/utils/color.js +2 -2
- package/dist/lib/utils/constants.js +20 -4
- package/dist/lib/utils/index.js +10 -4
- package/dist/lib/utils/pixi-loader.js +41 -15
- package/dist/lib/utils/playground-utils.js +4 -4
- package/dist/lib/utils/replay-scripts.js +164 -115
- package/dist/types/component/config-selector/index.d.ts +2 -0
- package/dist/types/component/player/index.d.ts +0 -1
- package/dist/types/component/playground-result/index.d.ts +1 -0
- package/dist/types/component/prompt-input/index.d.ts +2 -1
- package/dist/types/component/screenshot-viewer/index.d.ts +15 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +1 -1
- package/dist/types/hooks/usePlaygroundState.d.ts +3 -3
- package/dist/types/hooks/useTheme.d.ts +7 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/store/store.d.ts +18 -1
- package/dist/types/types.d.ts +14 -4
- package/dist/types/utils/constants.d.ts +5 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/replay-scripts.d.ts +1 -1
- package/package.json +12 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use client';
|
|
2
1
|
"use strict";
|
|
2
|
+
"use client";
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
4
|
(()=>{
|
|
5
5
|
__webpack_require__.n = (module)=>{
|
|
@@ -43,17 +43,40 @@ const external_react_namespaceObject = require("react");
|
|
|
43
43
|
require("./index.css");
|
|
44
44
|
const index_js_namespaceObject = require("../../utils/index.js");
|
|
45
45
|
const icons_namespaceObject = require("@ant-design/icons");
|
|
46
|
-
const extractor_namespaceObject = require("@midscene/shared/extractor");
|
|
47
46
|
const external_antd_namespaceObject = require("antd");
|
|
48
47
|
const global_perspective_js_namespaceObject = require("../../icons/global-perspective.js");
|
|
49
48
|
var global_perspective_js_default = /*#__PURE__*/ __webpack_require__.n(global_perspective_js_namespaceObject);
|
|
50
49
|
const player_setting_js_namespaceObject = require("../../icons/player-setting.js");
|
|
51
50
|
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
51
|
const store_js_namespaceObject = require("../../store/store.js");
|
|
55
52
|
const pixi_loader_js_namespaceObject = require("../../utils/pixi-loader.js");
|
|
56
53
|
const external_blackboard_index_js_namespaceObject = require("../blackboard/index.js");
|
|
54
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
55
|
+
try {
|
|
56
|
+
var info = gen[key](arg);
|
|
57
|
+
var value = info.value;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
reject(error);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (info.done) resolve(value);
|
|
63
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
64
|
+
}
|
|
65
|
+
function _async_to_generator(fn) {
|
|
66
|
+
return function() {
|
|
67
|
+
var self = this, args = arguments;
|
|
68
|
+
return new Promise(function(resolve, reject) {
|
|
69
|
+
var gen = fn.apply(self, args);
|
|
70
|
+
function _next(value) {
|
|
71
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
72
|
+
}
|
|
73
|
+
function _throw(err) {
|
|
74
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
75
|
+
}
|
|
76
|
+
_next(void 0);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
}
|
|
57
80
|
function _define_property(obj, key, value) {
|
|
58
81
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
59
82
|
value: value,
|
|
@@ -64,6 +87,38 @@ function _define_property(obj, key, value) {
|
|
|
64
87
|
else obj[key] = value;
|
|
65
88
|
return obj;
|
|
66
89
|
}
|
|
90
|
+
function _object_spread(target) {
|
|
91
|
+
for(var i = 1; i < arguments.length; i++){
|
|
92
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
93
|
+
var ownKeys = Object.keys(source);
|
|
94
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
95
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
96
|
+
}));
|
|
97
|
+
ownKeys.forEach(function(key) {
|
|
98
|
+
_define_property(target, key, source[key]);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return target;
|
|
102
|
+
}
|
|
103
|
+
function player_ownKeys(object, enumerableOnly) {
|
|
104
|
+
var keys = Object.keys(object);
|
|
105
|
+
if (Object.getOwnPropertySymbols) {
|
|
106
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
107
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
108
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
109
|
+
});
|
|
110
|
+
keys.push.apply(keys, symbols);
|
|
111
|
+
}
|
|
112
|
+
return keys;
|
|
113
|
+
}
|
|
114
|
+
function _object_spread_props(target, source) {
|
|
115
|
+
source = null != source ? source : {};
|
|
116
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
117
|
+
else player_ownKeys(Object(source)).forEach(function(key) {
|
|
118
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
119
|
+
});
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
67
122
|
const canvasPaddingLeft = 0;
|
|
68
123
|
const canvasPaddingTop = 0;
|
|
69
124
|
const cubicBezier = (t, p0, p1, p2, p3)=>{
|
|
@@ -124,17 +179,32 @@ class RecordingSession {
|
|
|
124
179
|
mediaRecorder.ondataavailable = (event)=>{
|
|
125
180
|
if (event.data.size > 0) this.chunks.push(event.data);
|
|
126
181
|
};
|
|
182
|
+
mediaRecorder.onerror = (event)=>{
|
|
183
|
+
console.error('MediaRecorder error:', event);
|
|
184
|
+
external_antd_namespaceObject.message.error('Video recording failed. Please try again.');
|
|
185
|
+
this.recording = false;
|
|
186
|
+
this.mediaRecorder = null;
|
|
187
|
+
};
|
|
127
188
|
this.mediaRecorder = mediaRecorder;
|
|
128
189
|
this.recording = true;
|
|
129
190
|
return this.mediaRecorder.start();
|
|
130
191
|
}
|
|
131
192
|
stop() {
|
|
132
|
-
var _this_mediaRecorder;
|
|
133
193
|
if (!this.recording || !this.mediaRecorder) return void console.warn('not recording');
|
|
134
194
|
this.mediaRecorder.onstop = ()=>{
|
|
195
|
+
if (0 === this.chunks.length) {
|
|
196
|
+
console.error('No video data captured');
|
|
197
|
+
external_antd_namespaceObject.message.error('Video export failed: No data captured.');
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
135
200
|
const blob = new Blob(this.chunks, {
|
|
136
201
|
type: 'video/webm'
|
|
137
202
|
});
|
|
203
|
+
if (0 === blob.size) {
|
|
204
|
+
console.error('Video blob is empty');
|
|
205
|
+
external_antd_namespaceObject.message.error('Video export failed: Empty file.');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
138
208
|
const url = URL.createObjectURL(blob);
|
|
139
209
|
const a = document.createElement('a');
|
|
140
210
|
a.href = url;
|
|
@@ -142,7 +212,7 @@ class RecordingSession {
|
|
|
142
212
|
a.click();
|
|
143
213
|
URL.revokeObjectURL(url);
|
|
144
214
|
};
|
|
145
|
-
|
|
215
|
+
this.mediaRecorder.stop();
|
|
146
216
|
this.recording = false;
|
|
147
217
|
this.mediaRecorder = null;
|
|
148
218
|
}
|
|
@@ -159,19 +229,13 @@ function Player(props) {
|
|
|
159
229
|
var _scripts_;
|
|
160
230
|
const [titleText, setTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
161
231
|
const [subTitleText, setSubTitleText] = (0, external_react_namespaceObject.useState)('');
|
|
162
|
-
const { autoZoom, setAutoZoom
|
|
232
|
+
const { autoZoom, setAutoZoom } = (0, store_js_namespaceObject.useGlobalPreference)();
|
|
163
233
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
164
234
|
if ((null == props ? void 0 : props.autoZoom) !== void 0) setAutoZoom(props.autoZoom);
|
|
165
235
|
}, [
|
|
166
236
|
null == props ? void 0 : props.autoZoom,
|
|
167
237
|
setAutoZoom
|
|
168
238
|
]);
|
|
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
239
|
const scripts = null == props ? void 0 : props.replayScripts;
|
|
176
240
|
const imageWidth = (null == props ? void 0 : props.imageWidth) || 1920;
|
|
177
241
|
const imageHeight = (null == props ? void 0 : props.imageHeight) || 1080;
|
|
@@ -194,12 +258,6 @@ function Player(props) {
|
|
|
194
258
|
container.zIndex = LAYER_ORDER_INSIGHT;
|
|
195
259
|
return container;
|
|
196
260
|
}, []);
|
|
197
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
198
|
-
insightMarkContainer.visible = elementsVisible;
|
|
199
|
-
}, [
|
|
200
|
-
elementsVisible,
|
|
201
|
-
insightMarkContainer
|
|
202
|
-
]);
|
|
203
261
|
const basicCameraState = {
|
|
204
262
|
left: 0,
|
|
205
263
|
top: 0,
|
|
@@ -215,49 +273,47 @@ function Player(props) {
|
|
|
215
273
|
cancelFlag.current = true;
|
|
216
274
|
};
|
|
217
275
|
}, []);
|
|
218
|
-
const cameraState = (0, external_react_namespaceObject.useRef)({
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
276
|
+
const cameraState = (0, external_react_namespaceObject.useRef)(_object_spread({}, basicCameraState));
|
|
277
|
+
const resizeCanvasIfNeeded = (newWidth, newHeight)=>_async_to_generator(function*() {
|
|
278
|
+
if (app.screen.width !== newWidth || app.screen.height !== newHeight) {
|
|
279
|
+
app.renderer.resize(newWidth, newHeight);
|
|
280
|
+
if (divContainerRef.current) {
|
|
281
|
+
const aspectRatio = newWidth / newHeight;
|
|
282
|
+
divContainerRef.current.style.setProperty('--canvas-aspect-ratio', aspectRatio.toString());
|
|
283
|
+
}
|
|
284
|
+
const newBasicCameraState = {
|
|
285
|
+
left: 0,
|
|
286
|
+
top: 0,
|
|
287
|
+
width: newWidth,
|
|
288
|
+
pointerLeft: Math.round(newWidth / 2),
|
|
289
|
+
pointerTop: Math.round(newHeight / 2)
|
|
290
|
+
};
|
|
291
|
+
cameraState.current = newBasicCameraState;
|
|
227
292
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
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
|
-
};
|
|
293
|
+
})();
|
|
294
|
+
const repaintImage = (scriptWidth, scriptHeight)=>_async_to_generator(function*() {
|
|
295
|
+
const imgToUpdate = currentImg.current;
|
|
296
|
+
if (!imgToUpdate) return void console.warn('no image to update');
|
|
297
|
+
const targetWidth = scriptWidth || imageWidth;
|
|
298
|
+
const targetHeight = scriptHeight || imageHeight;
|
|
299
|
+
yield resizeCanvasIfNeeded(targetWidth, targetHeight);
|
|
300
|
+
if (!(0, pixi_loader_js_namespaceObject.getTextureFromCache)(imgToUpdate)) {
|
|
301
|
+
console.warn('image not loaded', imgToUpdate);
|
|
302
|
+
yield (0, pixi_loader_js_namespaceObject.loadTexture)(imgToUpdate);
|
|
303
|
+
}
|
|
304
|
+
const texture = (0, pixi_loader_js_namespaceObject.getTextureFromCache)(imgToUpdate);
|
|
305
|
+
if (!texture) throw new Error('texture not found');
|
|
306
|
+
const sprite = external_pixi_js_namespaceObject.Sprite.from(texture);
|
|
307
|
+
if (!sprite) throw new Error('sprite not found');
|
|
308
|
+
const mainImgLabel = 'main-img';
|
|
309
|
+
const child = windowContentContainer.getChildByLabel(mainImgLabel);
|
|
310
|
+
if (child) windowContentContainer.removeChild(child);
|
|
311
|
+
sprite.label = mainImgLabel;
|
|
312
|
+
sprite.zIndex = LAYER_ORDER_IMG;
|
|
313
|
+
sprite.width = targetWidth;
|
|
314
|
+
sprite.height = targetHeight;
|
|
315
|
+
windowContentContainer.addChild(sprite);
|
|
316
|
+
})();
|
|
261
317
|
const spinningPointer = (frame)=>{
|
|
262
318
|
var _pointerSprite_current, _pointerSprite_current1;
|
|
263
319
|
if (!spinningPointerSprite.current) {
|
|
@@ -288,31 +344,31 @@ function Player(props) {
|
|
|
288
344
|
};
|
|
289
345
|
return stopFn;
|
|
290
346
|
};
|
|
291
|
-
const updatePointer =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
347
|
+
const updatePointer = (img, x, y)=>_async_to_generator(function*() {
|
|
348
|
+
var _pointerSprite_current, _pointerSprite_current1;
|
|
349
|
+
if (!(0, pixi_loader_js_namespaceObject.getTextureFromCache)(img)) {
|
|
350
|
+
console.warn('image not loaded', img);
|
|
351
|
+
yield (0, pixi_loader_js_namespaceObject.loadTexture)(img);
|
|
352
|
+
}
|
|
353
|
+
const texture = (0, pixi_loader_js_namespaceObject.getTextureFromCache)(img);
|
|
354
|
+
if (!texture) throw new Error('texture not found');
|
|
355
|
+
const sprite = external_pixi_js_namespaceObject.Sprite.from(texture);
|
|
356
|
+
let targetX = null == (_pointerSprite_current = pointerSprite.current) ? void 0 : _pointerSprite_current.x;
|
|
357
|
+
let targetY = null == (_pointerSprite_current1 = pointerSprite.current) ? void 0 : _pointerSprite_current1.y;
|
|
358
|
+
if ('number' == typeof x) targetX = x;
|
|
359
|
+
if ('number' == typeof y) targetY = y;
|
|
360
|
+
if (void 0 === targetX || void 0 === targetY) return void console.warn('invalid pointer position', x, y);
|
|
361
|
+
if (pointerSprite.current) {
|
|
362
|
+
const pointer = windowContentContainer.getChildByLabel('pointer');
|
|
363
|
+
if (pointer) windowContentContainer.removeChild(pointer);
|
|
364
|
+
}
|
|
365
|
+
pointerSprite.current = sprite;
|
|
366
|
+
pointerSprite.current.x = targetX;
|
|
367
|
+
pointerSprite.current.y = targetY;
|
|
368
|
+
pointerSprite.current.label = 'pointer';
|
|
369
|
+
pointerSprite.current.zIndex = LAYER_ORDER_POINTER;
|
|
370
|
+
windowContentContainer.addChild(pointerSprite.current);
|
|
371
|
+
})();
|
|
316
372
|
const updateCamera = (state, currentWidth)=>{
|
|
317
373
|
cameraState.current = state;
|
|
318
374
|
const effectiveWidth = currentWidth || app.screen.width || imageWidth;
|
|
@@ -329,90 +385,81 @@ function Player(props) {
|
|
|
329
385
|
}
|
|
330
386
|
}
|
|
331
387
|
};
|
|
332
|
-
const cameraAnimation =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
388
|
+
const cameraAnimation = (targetState, duration, frame)=>_async_to_generator(function*() {
|
|
389
|
+
const currentCanvasWidth = app.screen.width || imageWidth;
|
|
390
|
+
const currentCanvasHeight = app.screen.height || imageHeight;
|
|
391
|
+
if (!autoZoom) {
|
|
392
|
+
const currentState = _object_spread({}, cameraState.current);
|
|
393
|
+
const startPointerLeft = currentState.pointerLeft;
|
|
394
|
+
const startPointerTop = currentState.pointerTop;
|
|
395
|
+
const startTime = performance.now();
|
|
396
|
+
const shouldMovePointer = 'number' == typeof targetState.pointerLeft && 'number' == typeof targetState.pointerTop && (targetState.pointerLeft !== startPointerLeft || targetState.pointerTop !== startPointerTop);
|
|
397
|
+
if (!shouldMovePointer) return;
|
|
398
|
+
yield new Promise((resolve)=>{
|
|
399
|
+
const animate = (currentTime)=>{
|
|
400
|
+
const elapsedTime = currentTime - startTime;
|
|
401
|
+
const rawProgress = Math.min(elapsedTime / duration, 1);
|
|
402
|
+
const progress = cubicMouse(rawProgress);
|
|
403
|
+
const nextState = _object_spread_props(_object_spread({}, currentState), {
|
|
404
|
+
pointerLeft: startPointerLeft + (targetState.pointerLeft - startPointerLeft) * progress,
|
|
405
|
+
pointerTop: startPointerTop + (targetState.pointerTop - startPointerTop) * progress
|
|
406
|
+
});
|
|
407
|
+
updateCamera(nextState, currentCanvasWidth);
|
|
408
|
+
if (elapsedTime < duration) frame(animate);
|
|
409
|
+
else resolve();
|
|
410
|
+
};
|
|
411
|
+
frame(animate);
|
|
412
|
+
});
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const currentState = _object_spread({}, cameraState.current);
|
|
416
|
+
const startLeft = currentState.left;
|
|
417
|
+
const startTop = currentState.top;
|
|
339
418
|
const startPointerLeft = currentState.pointerLeft;
|
|
340
419
|
const startPointerTop = currentState.pointerTop;
|
|
420
|
+
const startScale = currentState.width / currentCanvasWidth;
|
|
341
421
|
const startTime = performance.now();
|
|
342
422
|
const shouldMovePointer = 'number' == typeof targetState.pointerLeft && 'number' == typeof targetState.pointerTop && (targetState.pointerLeft !== startPointerLeft || targetState.pointerTop !== startPointerTop);
|
|
343
|
-
|
|
344
|
-
|
|
423
|
+
const pointerMoveDuration = shouldMovePointer ? 0.375 * duration : 0;
|
|
424
|
+
const cameraMoveStart = pointerMoveDuration;
|
|
425
|
+
const cameraMoveDuration = duration - pointerMoveDuration;
|
|
426
|
+
yield new Promise((resolve)=>{
|
|
345
427
|
const animate = (currentTime)=>{
|
|
428
|
+
const nextState = _object_spread({}, cameraState.current);
|
|
346
429
|
const elapsedTime = currentTime - startTime;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
430
|
+
if (shouldMovePointer) if (elapsedTime <= pointerMoveDuration) {
|
|
431
|
+
const rawMouseProgress = Math.min(elapsedTime / pointerMoveDuration, 1);
|
|
432
|
+
const mouseProgress = cubicMouse(rawMouseProgress);
|
|
433
|
+
nextState.pointerLeft = startPointerLeft + (targetState.pointerLeft - startPointerLeft) * mouseProgress;
|
|
434
|
+
nextState.pointerTop = startPointerTop + (targetState.pointerTop - startPointerTop) * mouseProgress;
|
|
435
|
+
} else {
|
|
436
|
+
nextState.pointerLeft = targetState.pointerLeft;
|
|
437
|
+
nextState.pointerTop = targetState.pointerTop;
|
|
438
|
+
}
|
|
439
|
+
if (elapsedTime > cameraMoveStart) {
|
|
440
|
+
const cameraElapsedTime = elapsedTime - cameraMoveStart;
|
|
441
|
+
const rawCameraProgress = Math.min(cameraElapsedTime / cameraMoveDuration, 1);
|
|
442
|
+
const cameraProgress = cubicImage(rawCameraProgress);
|
|
443
|
+
const targetScale = targetState.width / currentCanvasWidth;
|
|
444
|
+
const progressScale = startScale + (targetScale - startScale) * cameraProgress;
|
|
445
|
+
const progressWidth = currentCanvasWidth * progressScale;
|
|
446
|
+
const progressHeight = currentCanvasHeight * progressScale;
|
|
447
|
+
nextState.width = progressWidth;
|
|
448
|
+
const progressLeft = startLeft + (targetState.left - startLeft) * cameraProgress;
|
|
449
|
+
const progressTop = startTop + (targetState.top - startTop) * cameraProgress;
|
|
450
|
+
const horizontalExceed = progressLeft + progressWidth - currentCanvasWidth;
|
|
451
|
+
const verticalExceed = progressTop + progressHeight - currentCanvasHeight;
|
|
452
|
+
nextState.left = horizontalExceed > 0 ? progressLeft + horizontalExceed : progressLeft;
|
|
453
|
+
nextState.top = verticalExceed > 0 ? progressTop + verticalExceed : progressTop;
|
|
454
|
+
}
|
|
354
455
|
updateCamera(nextState, currentCanvasWidth);
|
|
355
456
|
if (elapsedTime < duration) frame(animate);
|
|
356
457
|
else resolve();
|
|
357
458
|
};
|
|
358
459
|
frame(animate);
|
|
359
460
|
});
|
|
360
|
-
|
|
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)=>{
|
|
461
|
+
})();
|
|
462
|
+
const fadeInGraphics = (graphics, duration, frame, targetAlpha = 1)=>new Promise((resolve)=>{
|
|
416
463
|
const startTime = performance.now();
|
|
417
464
|
const animate = (currentTime)=>{
|
|
418
465
|
const elapsedTime = currentTime - startTime;
|
|
@@ -423,178 +470,195 @@ function Player(props) {
|
|
|
423
470
|
};
|
|
424
471
|
frame(animate);
|
|
425
472
|
});
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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){
|
|
473
|
+
const fadeOutItem = (graphics, duration, frame)=>_async_to_generator(function*() {
|
|
474
|
+
return fadeInGraphics(graphics, duration, frame, 0);
|
|
475
|
+
})();
|
|
476
|
+
const insightElementsAnimation = (elements, highlightElements, searchArea, duration, frame)=>_async_to_generator(function*() {
|
|
477
|
+
insightMarkContainer.removeChildren();
|
|
478
|
+
const elementsToAdd = [
|
|
479
|
+
...elements
|
|
480
|
+
];
|
|
481
|
+
const totalLength = elementsToAdd.length;
|
|
482
|
+
let childrenCount = 0;
|
|
483
|
+
yield new Promise((resolve)=>{
|
|
484
|
+
const startTime = performance.now();
|
|
485
|
+
const animate = (currentTime)=>{
|
|
486
|
+
const elapsedTime = currentTime - startTime;
|
|
487
|
+
const progress = cubicInsightElement(Math.min(elapsedTime / duration, 1));
|
|
488
|
+
const elementsToAddNow = Math.floor(progress * totalLength);
|
|
489
|
+
while(childrenCount < elementsToAddNow){
|
|
455
490
|
const randomIndex = Math.floor(Math.random() * elementsToAdd.length);
|
|
456
491
|
const element = elementsToAdd.splice(randomIndex, 1)[0];
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
492
|
+
if (element) {
|
|
493
|
+
const [insightMarkGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(element.rect, element.content, 'element');
|
|
494
|
+
insightMarkGraphic.alpha = 0;
|
|
495
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
496
|
+
childrenCount++;
|
|
497
|
+
fadeInGraphics(insightMarkGraphic, singleElementFadeInDuration, frame);
|
|
498
|
+
}
|
|
460
499
|
}
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
500
|
+
if (elapsedTime < duration) frame(animate);
|
|
501
|
+
else {
|
|
502
|
+
while(elementsToAdd.length > 0){
|
|
503
|
+
const randomIndex = Math.floor(Math.random() * elementsToAdd.length);
|
|
504
|
+
const element = elementsToAdd.splice(randomIndex, 1)[0];
|
|
505
|
+
const [insightMarkGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(element.rect, element.content, 'element');
|
|
506
|
+
insightMarkGraphic.alpha = 1;
|
|
507
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
508
|
+
}
|
|
509
|
+
if (searchArea) {
|
|
510
|
+
const [searchAreaGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(searchArea, 'Search Area', 'searchArea');
|
|
511
|
+
searchAreaGraphic.alpha = 1;
|
|
512
|
+
insightMarkContainer.addChild(searchAreaGraphic);
|
|
513
|
+
}
|
|
514
|
+
highlightElements.map((element)=>{
|
|
515
|
+
const [insightMarkGraphic] = (0, external_blackboard_index_js_namespaceObject.rectMarkForItem)(element.rect, element.content || '', 'highlight');
|
|
516
|
+
insightMarkGraphic.alpha = 1;
|
|
517
|
+
insightMarkContainer.addChild(insightMarkGraphic);
|
|
518
|
+
});
|
|
519
|
+
resolve();
|
|
465
520
|
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
-
};
|
|
521
|
+
};
|
|
522
|
+
frame(animate);
|
|
523
|
+
});
|
|
524
|
+
})();
|
|
525
|
+
const init = ()=>_async_to_generator(function*() {
|
|
526
|
+
if (!divContainerRef.current || !scripts) return;
|
|
527
|
+
yield app.init({
|
|
528
|
+
width: imageWidth,
|
|
529
|
+
height: imageHeight,
|
|
530
|
+
background: 0xf4f4f4,
|
|
531
|
+
autoDensity: true,
|
|
532
|
+
antialias: true
|
|
533
|
+
});
|
|
534
|
+
if (!divContainerRef.current) return;
|
|
535
|
+
divContainerRef.current.appendChild(app.canvas);
|
|
536
|
+
windowContentContainer.x = 0;
|
|
537
|
+
windowContentContainer.y = 0;
|
|
538
|
+
app.stage.addChild(windowContentContainer);
|
|
539
|
+
insightMarkContainer.x = 0;
|
|
540
|
+
insightMarkContainer.y = 0;
|
|
541
|
+
windowContentContainer.addChild(insightMarkContainer);
|
|
542
|
+
})();
|
|
495
543
|
const [isRecording, setIsRecording] = (0, external_react_namespaceObject.useState)(false);
|
|
496
544
|
const recorderSessionRef = (0, external_react_namespaceObject.useRef)(null);
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
545
|
+
const cancelAnimationRef = (0, external_react_namespaceObject.useRef)(null);
|
|
546
|
+
const handleExport = ()=>_async_to_generator(function*() {
|
|
547
|
+
if (recorderSessionRef.current) return void console.warn('recorderSession exists');
|
|
548
|
+
if (!app.canvas) return void console.warn('canvas is not initialized');
|
|
549
|
+
if (cancelAnimationRef.current) {
|
|
550
|
+
cancelAnimationRef.current();
|
|
551
|
+
cancelAnimationRef.current = null;
|
|
552
|
+
yield new Promise((resolve)=>setTimeout(resolve, 100));
|
|
553
|
+
}
|
|
554
|
+
recorderSessionRef.current = new RecordingSession(app.canvas);
|
|
555
|
+
setIsRecording(true);
|
|
556
|
+
triggerReplay();
|
|
557
|
+
})();
|
|
504
558
|
const play = ()=>{
|
|
505
559
|
let cancelFn;
|
|
506
|
-
Promise.resolve((
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
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) {
|
|
560
|
+
Promise.resolve((()=>_async_to_generator(function*() {
|
|
561
|
+
if (!app) throw new Error('app is not initialized');
|
|
562
|
+
if (!scripts) throw new Error("scripts is required");
|
|
563
|
+
const { frame, cancel, timeout } = frameKit();
|
|
564
|
+
cancelFn = cancel;
|
|
565
|
+
cancelAnimationRef.current = cancel;
|
|
566
|
+
const allImages = scripts.filter((item)=>!!item.img).map((item)=>item.img);
|
|
567
|
+
yield Promise.all([
|
|
568
|
+
...allImages,
|
|
569
|
+
index_js_namespaceObject.mouseLoading,
|
|
570
|
+
index_js_namespaceObject.mousePointer
|
|
571
|
+
].map(pixi_loader_js_namespaceObject.loadTexture));
|
|
572
|
+
insightMarkContainer.removeChildren();
|
|
573
|
+
yield updatePointer(index_js_namespaceObject.mousePointer, imageWidth / 2, imageHeight / 2);
|
|
574
|
+
yield repaintImage();
|
|
575
|
+
yield updateCamera(_object_spread({}, basicCameraState));
|
|
576
|
+
const totalDuration = scripts.reduce((acc, item)=>acc + item.duration + (item.camera && item.insightCameraDuration ? item.insightCameraDuration : 0), 0);
|
|
577
|
+
const progressUpdateInterval = 200;
|
|
578
|
+
const startTime = performance.now();
|
|
579
|
+
setAnimationProgress(0);
|
|
580
|
+
const updateProgress = ()=>{
|
|
581
|
+
const progress = Math.min((performance.now() - startTime) / totalDuration, 1);
|
|
582
|
+
setAnimationProgress(progress);
|
|
583
|
+
if (progress < 1) return timeout(updateProgress, progressUpdateInterval);
|
|
584
|
+
};
|
|
585
|
+
frame(updateProgress);
|
|
586
|
+
if (recorderSessionRef.current) recorderSessionRef.current.start();
|
|
587
|
+
for(const index in scripts){
|
|
588
|
+
const item = scripts[index];
|
|
589
|
+
setTitleText(item.title || '');
|
|
590
|
+
setSubTitleText(item.subTitle || '');
|
|
591
|
+
if ('sleep' === item.type) yield sleep(item.duration);
|
|
592
|
+
else if ('insight' === item.type) {
|
|
593
|
+
if (!item.img) throw new Error('img is required');
|
|
559
594
|
currentImg.current = item.img;
|
|
560
|
-
|
|
595
|
+
yield repaintImage(item.imageWidth, item.imageHeight);
|
|
596
|
+
const highlightElements = item.highlightElement ? [
|
|
597
|
+
item.highlightElement
|
|
598
|
+
] : [];
|
|
599
|
+
yield insightElementsAnimation([], highlightElements, item.searchArea, item.duration, frame);
|
|
600
|
+
if (item.camera) {
|
|
601
|
+
if (!item.insightCameraDuration) throw new Error('insightCameraDuration is required');
|
|
602
|
+
yield cameraAnimation(item.camera, item.insightCameraDuration, frame);
|
|
603
|
+
}
|
|
604
|
+
} else if ('clear-insight' === item.type) {
|
|
605
|
+
yield fadeOutItem(insightMarkContainer, item.duration, frame);
|
|
606
|
+
insightMarkContainer.removeChildren();
|
|
607
|
+
insightMarkContainer.alpha = 1;
|
|
608
|
+
} else if ('img' === item.type) {
|
|
609
|
+
if (item.img && item.img !== currentImg.current) {
|
|
610
|
+
currentImg.current = item.img;
|
|
611
|
+
yield repaintImage(item.imageWidth, item.imageHeight);
|
|
612
|
+
}
|
|
613
|
+
if (item.camera) yield cameraAnimation(item.camera, item.duration, frame);
|
|
614
|
+
else yield sleep(item.duration);
|
|
615
|
+
} else if ('pointer' === item.type) {
|
|
616
|
+
if (!item.img) throw new Error('pointer img is required');
|
|
617
|
+
yield updatePointer(item.img);
|
|
618
|
+
} else if ('spinning-pointer' === item.type) {
|
|
619
|
+
const stop = spinningPointer(frame);
|
|
620
|
+
yield sleep(item.duration);
|
|
621
|
+
stop();
|
|
561
622
|
}
|
|
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
623
|
}
|
|
572
|
-
|
|
624
|
+
if (recorderSessionRef.current) {
|
|
625
|
+
yield sleep(1200);
|
|
626
|
+
recorderSessionRef.current.stop();
|
|
627
|
+
recorderSessionRef.current = null;
|
|
628
|
+
setIsRecording(false);
|
|
629
|
+
}
|
|
630
|
+
})())().catch((e)=>{
|
|
631
|
+
console.error('player error', e);
|
|
632
|
+
if ((null == e ? void 0 : e.message) === ERROR_FRAME_CANCEL) return void console.log('Animation cancelled (expected behavior)');
|
|
633
|
+
const wasRecording = !!recorderSessionRef.current;
|
|
573
634
|
if (recorderSessionRef.current) {
|
|
574
|
-
|
|
575
|
-
|
|
635
|
+
try {
|
|
636
|
+
recorderSessionRef.current.stop();
|
|
637
|
+
} catch (stopError) {
|
|
638
|
+
console.error('Error stopping recorder:', stopError);
|
|
639
|
+
}
|
|
576
640
|
recorderSessionRef.current = null;
|
|
577
|
-
setIsRecording(false);
|
|
578
641
|
}
|
|
579
|
-
|
|
580
|
-
|
|
642
|
+
setIsRecording(false);
|
|
643
|
+
if (wasRecording) external_antd_namespaceObject.message.error('Failed to export video. Please try again.');
|
|
581
644
|
}));
|
|
582
645
|
return ()=>{
|
|
583
646
|
null == cancelFn || cancelFn();
|
|
647
|
+
cancelAnimationRef.current = null;
|
|
584
648
|
};
|
|
585
649
|
};
|
|
586
650
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
587
|
-
Promise.resolve((
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
651
|
+
Promise.resolve((()=>_async_to_generator(function*() {
|
|
652
|
+
yield init();
|
|
653
|
+
if (divContainerRef.current && imageWidth && imageHeight) {
|
|
654
|
+
const aspectRatio = imageWidth / imageHeight;
|
|
655
|
+
divContainerRef.current.style.setProperty('--canvas-aspect-ratio', aspectRatio.toString());
|
|
656
|
+
divContainerRef.current.setAttribute('data-fit-mode', fitMode);
|
|
657
|
+
const playerContainer = divContainerRef.current.closest('.player-container');
|
|
658
|
+
if (playerContainer) playerContainer.setAttribute('data-fit-mode', fitMode);
|
|
659
|
+
}
|
|
660
|
+
triggerReplay();
|
|
661
|
+
})())());
|
|
598
662
|
return ()=>{
|
|
599
663
|
try {
|
|
600
664
|
app.destroy(true, {
|
|
@@ -810,59 +874,6 @@ function Player(props) {
|
|
|
810
874
|
})
|
|
811
875
|
]
|
|
812
876
|
})
|
|
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
877
|
}
|
|
867
878
|
]
|
|
868
879
|
},
|
|
@@ -894,9 +905,9 @@ function Player(props) {
|
|
|
894
905
|
});
|
|
895
906
|
}
|
|
896
907
|
exports.Player = __webpack_exports__.Player;
|
|
897
|
-
for(var
|
|
908
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
898
909
|
"Player"
|
|
899
|
-
].indexOf(
|
|
910
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
900
911
|
Object.defineProperty(exports, '__esModule', {
|
|
901
912
|
value: true
|
|
902
913
|
});
|