@midscene/visualizer 0.26.2-beta-20250812091127.0 → 0.26.3-beta-20250813021342.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/blank_polyfill.mjs +2 -0
- package/dist/es/component/blackboard.css +12 -5
- package/dist/es/component/blackboard.mjs +266 -0
- package/dist/es/component/color.mjs +35 -0
- package/dist/es/component/describer.css +9 -5
- package/dist/es/component/describer.mjs +128 -0
- package/dist/es/component/env-config.mjs +112 -0
- package/dist/es/component/github-star.css +1 -0
- package/dist/es/component/github-star.mjs +20 -0
- package/dist/es/component/logo.css +5 -3
- package/dist/es/component/logo.mjs +20 -0
- package/dist/es/component/misc.mjs +54 -0
- package/dist/es/component/pixi-loader.mjs +16 -0
- package/dist/es/component/player.css +88 -70
- package/dist/es/component/player.mjs +628 -0
- package/dist/es/component/playground/ConfigSelector.mjs +53 -0
- package/dist/es/component/playground/ContextPreview.mjs +39 -0
- package/dist/es/component/playground/HistorySelector.mjs +193 -0
- package/dist/es/component/playground/PlaygroundResult.mjs +60 -0
- package/dist/es/component/playground/PromptInput.mjs +225 -0
- package/dist/es/component/playground/ServiceModeControl.mjs +100 -0
- package/dist/es/component/playground/index.css +140 -98
- package/dist/es/component/playground/playground-constants.mjs +45 -0
- package/dist/es/component/playground/playground-utils.mjs +89 -0
- package/dist/es/component/playground/useServerValid.mjs +27 -0
- package/dist/es/component/playground/useStaticPageAgent.mjs +12 -0
- package/dist/es/component/replay-scripts.mjs +271 -0
- package/dist/es/component/shiny-text.css +33 -22
- package/dist/es/component/shiny-text.mjs +15 -0
- package/dist/es/component/store/history.mjs +55 -0
- package/dist/es/component/store/store.mjs +128 -0
- package/dist/es/icons/close.mjs +19 -0
- package/dist/es/icons/history.mjs +30 -0
- package/dist/es/icons/magnifying-glass.mjs +39 -0
- package/dist/es/icons/setting.mjs +20 -0
- package/dist/es/index.mjs +21 -0
- package/dist/es/init.mjs +10 -0
- package/dist/es/{utils.js → utils.mjs} +51 -75
- package/dist/lib/blank_polyfill.js +34 -38
- package/dist/lib/component/blackboard.css +12 -5
- package/dist/lib/component/blackboard.js +293 -306
- package/dist/lib/component/color.js +64 -74
- package/dist/lib/component/describer.css +9 -5
- package/dist/lib/component/describer.js +158 -198
- package/dist/lib/component/env-config.js +142 -147
- package/dist/lib/component/github-star.css +1 -0
- package/dist/lib/component/github-star.js +51 -62
- package/dist/lib/component/logo.css +5 -3
- package/dist/lib/component/logo.js +53 -56
- package/dist/lib/component/misc.js +85 -84
- package/dist/lib/component/pixi-loader.js +49 -80
- package/dist/lib/component/player.css +88 -70
- package/dist/lib/component/player.js +627 -738
- package/dist/lib/component/playground/ConfigSelector.js +91 -92
- package/dist/lib/component/playground/ContextPreview.js +80 -72
- package/dist/lib/component/playground/HistorySelector.js +234 -197
- package/dist/lib/component/playground/PlaygroundResult.js +100 -103
- package/dist/lib/component/playground/PromptInput.js +250 -237
- package/dist/lib/component/playground/ServiceModeControl.js +124 -124
- package/dist/lib/component/playground/index.css +140 -98
- package/dist/lib/component/playground/playground-constants.js +97 -73
- package/dist/lib/component/playground/playground-types.js +17 -31
- package/dist/lib/component/playground/playground-utils.js +140 -168
- package/dist/lib/component/playground/useServerValid.js +55 -86
- package/dist/lib/component/playground/useStaticPageAgent.js +45 -51
- package/dist/lib/component/replay-scripts.js +291 -373
- package/dist/lib/component/shiny-text.css +33 -22
- package/dist/lib/component/shiny-text.js +46 -57
- package/dist/lib/component/store/history.js +58 -64
- package/dist/lib/component/store/store.js +132 -128
- package/dist/lib/icons/close.js +53 -0
- package/dist/lib/icons/history.js +64 -0
- package/dist/lib/icons/magnifying-glass.js +73 -0
- package/dist/lib/icons/setting.js +54 -0
- package/dist/lib/index.js +158 -124
- package/dist/lib/init.js +39 -46
- package/dist/lib/utils.js +105 -109
- package/dist/types/blank_polyfill.d.ts +2 -2
- package/dist/types/component/playground/ConfigSelector.d.ts +1 -0
- package/dist/types/component/playground/ContextPreview.d.ts +1 -0
- package/dist/types/component/playground/HistorySelector.d.ts +1 -0
- package/dist/types/component/playground/PlaygroundResult.d.ts +1 -0
- package/dist/types/component/playground/PromptInput.d.ts +1 -0
- package/dist/types/component/playground/ServiceModeControl.d.ts +1 -0
- package/package.json +16 -18
- package/dist/es/assets/close.909351c0.svg +0 -4
- package/dist/es/assets/history.164a4eab.svg +0 -4
- package/dist/es/assets/magnifying-glass.9498e70e.svg +0 -12
- package/dist/es/assets/setting.80ab7285.svg +0 -11
- package/dist/es/blank_polyfill.js +0 -10
- package/dist/es/component/blackboard.js +0 -286
- package/dist/es/component/color.js +0 -49
- package/dist/es/component/describer.js +0 -173
- package/dist/es/component/env-config.js +0 -117
- package/dist/es/component/github-star.js +0 -31
- package/dist/es/component/logo.js +0 -25
- package/dist/es/component/misc.js +0 -63
- package/dist/es/component/pixi-loader.js +0 -51
- package/dist/es/component/player.js +0 -746
- package/dist/es/component/playground/ConfigSelector.js +0 -64
- package/dist/es/component/playground/ContextPreview.js +0 -42
- package/dist/es/component/playground/HistorySelector.js +0 -168
- package/dist/es/component/playground/PlaygroundResult.js +0 -73
- package/dist/es/component/playground/PromptInput.js +0 -212
- package/dist/es/component/playground/ServiceModeControl.js +0 -100
- package/dist/es/component/playground/playground-constants.js +0 -39
- package/dist/es/component/playground/playground-types.js +0 -6
- package/dist/es/component/playground/playground-utils.js +0 -141
- package/dist/es/component/playground/useServerValid.js +0 -58
- package/dist/es/component/playground/useStaticPageAgent.js +0 -20
- package/dist/es/component/replay-scripts.js +0 -361
- package/dist/es/component/shiny-text.js +0 -30
- package/dist/es/component/store/history.js +0 -34
- package/dist/es/component/store/store.js +0 -99
- package/dist/es/index.js +0 -79
- package/dist/es/init.js +0 -17
- package/dist/index.css +0 -595
- package/dist/index.js +0 -1
- package/dist/lib/assets/close.909351c0.svg +0 -4
- package/dist/lib/assets/history.164a4eab.svg +0 -4
- package/dist/lib/assets/magnifying-glass.9498e70e.svg +0 -12
- package/dist/lib/assets/setting.80ab7285.svg +0 -11
- package/dist/lib/component/common.css +0 -0
- /package/dist/es/component/{common.css → playground/playground-types.mjs} +0 -0
|
@@ -1,322 +1,309 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var __async = (__this, __arguments, generator) => {
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
var fulfilled = (value) => {
|
|
33
|
-
try {
|
|
34
|
-
step(generator.next(value));
|
|
35
|
-
} catch (e) {
|
|
36
|
-
reject(e);
|
|
37
|
-
}
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
38
10
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
45
23
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
pointMarkForItem: () => pointMarkForItem,
|
|
55
|
-
rectMarkForItem: () => rectMarkForItem
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
pointMarkForItem: ()=>pointMarkForItem,
|
|
29
|
+
default: ()=>blackboard,
|
|
30
|
+
Blackboard: ()=>Blackboard,
|
|
31
|
+
rectMarkForItem: ()=>rectMarkForItem
|
|
56
32
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var PIXI = __toESM(require("pixi.js"));
|
|
68
|
-
var import_react = require("react");
|
|
69
|
-
var import_color = require("./color");
|
|
70
|
-
var import_blackboard = require("./blackboard.css");
|
|
71
|
-
var import_extractor = require("@midscene/shared/extractor");
|
|
72
|
-
var import_pixi_filters = require("pixi-filters");
|
|
73
|
-
var import_store = require("./store/store");
|
|
33
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
34
|
+
require("pixi.js/unsafe-eval");
|
|
35
|
+
const external_antd_namespaceObject = require("antd");
|
|
36
|
+
const external_pixi_js_namespaceObject = require("pixi.js");
|
|
37
|
+
const external_react_namespaceObject = require("react");
|
|
38
|
+
const external_color_js_namespaceObject = require("./color.js");
|
|
39
|
+
require("./blackboard.css");
|
|
40
|
+
const extractor_namespaceObject = require("@midscene/shared/extractor");
|
|
41
|
+
const external_pixi_filters_namespaceObject = require("pixi-filters");
|
|
42
|
+
const store_js_namespaceObject = require("./store/store.js");
|
|
74
43
|
const itemFillAlpha = 0.4;
|
|
75
44
|
const highlightAlpha = 0.4;
|
|
76
45
|
const pointRadius = 10;
|
|
77
|
-
const pointMarkForItem = (point, type)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
46
|
+
const pointMarkForItem = (point, type)=>{
|
|
47
|
+
const [x, y] = point;
|
|
48
|
+
const themeColor = (0, external_color_js_namespaceObject.highlightColorForType)('element');
|
|
49
|
+
const graphics = new external_pixi_js_namespaceObject.Graphics();
|
|
50
|
+
graphics.beginFill(themeColor, itemFillAlpha);
|
|
51
|
+
graphics.drawCircle(x, y, pointRadius);
|
|
52
|
+
graphics.endFill();
|
|
53
|
+
return graphics;
|
|
85
54
|
};
|
|
86
|
-
const rectMarkForItem = (rect, name, type)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
themeColor
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
55
|
+
const rectMarkForItem = (rect, name, type)=>{
|
|
56
|
+
const { left, top, width, height } = rect;
|
|
57
|
+
let themeColor;
|
|
58
|
+
themeColor = 'element' === type ? (0, external_color_js_namespaceObject.colorForName)(name) : 'searchArea' === type ? (0, external_color_js_namespaceObject.highlightColorForType)('searchArea') : (0, external_color_js_namespaceObject.highlightColorForType)('element');
|
|
59
|
+
const alpha = 'highlight' === type ? highlightAlpha : itemFillAlpha;
|
|
60
|
+
const graphics = new external_pixi_js_namespaceObject.Graphics();
|
|
61
|
+
graphics.beginFill(themeColor, alpha);
|
|
62
|
+
graphics.lineStyle(1, themeColor, 1);
|
|
63
|
+
graphics.drawRect(left, top, width, height);
|
|
64
|
+
graphics.endFill();
|
|
65
|
+
const dropShadowFilter = new external_pixi_filters_namespaceObject.DropShadowFilter({
|
|
66
|
+
blur: 2,
|
|
67
|
+
quality: 3,
|
|
68
|
+
alpha: 0.4,
|
|
69
|
+
offset: {
|
|
70
|
+
x: 4,
|
|
71
|
+
y: 4
|
|
72
|
+
},
|
|
73
|
+
color: 0x333333
|
|
74
|
+
});
|
|
75
|
+
graphics.filters = [
|
|
76
|
+
dropShadowFilter
|
|
77
|
+
];
|
|
78
|
+
const nameFontSize = 18;
|
|
79
|
+
if (!name) return [
|
|
80
|
+
graphics
|
|
81
|
+
];
|
|
82
|
+
const texts = new external_pixi_js_namespaceObject.Text(name, {
|
|
83
|
+
fontSize: nameFontSize,
|
|
84
|
+
fill: 0x0
|
|
85
|
+
});
|
|
86
|
+
texts.x = left;
|
|
87
|
+
texts.y = Math.max(top - (nameFontSize + 4), 0);
|
|
88
|
+
return [
|
|
89
|
+
graphics,
|
|
90
|
+
texts
|
|
91
|
+
];
|
|
121
92
|
};
|
|
122
|
-
const Blackboard = (props)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
93
|
+
const Blackboard = (props)=>{
|
|
94
|
+
const highlightElements = props.highlightElements || [];
|
|
95
|
+
const highlightIds = highlightElements.map((e)=>e.id);
|
|
96
|
+
const highlightRect = props.highlightRect;
|
|
97
|
+
const highlightPoints = props.highlightPoints;
|
|
98
|
+
const context = props.uiContext;
|
|
99
|
+
const { size, screenshotBase64 } = context;
|
|
100
|
+
const screenWidth = size.width;
|
|
101
|
+
const screenHeight = size.height;
|
|
102
|
+
const domRef = (0, external_react_namespaceObject.useRef)(null);
|
|
103
|
+
const app = (0, external_react_namespaceObject.useMemo)(()=>new external_pixi_js_namespaceObject.Application(), []);
|
|
104
|
+
const [appInitialed, setAppInitialed] = (0, external_react_namespaceObject.useState)(false);
|
|
105
|
+
const highlightContainer = (0, external_react_namespaceObject.useMemo)(()=>new external_pixi_js_namespaceObject.Container(), []);
|
|
106
|
+
const elementMarkContainer = (0, external_react_namespaceObject.useMemo)(()=>new external_pixi_js_namespaceObject.Container(), []);
|
|
107
|
+
const [hoverElement, setHoverElement] = (0, external_react_namespaceObject.useState)(null);
|
|
108
|
+
const pixiBgRef = (0, external_react_namespaceObject.useRef)(void 0);
|
|
109
|
+
const { markerVisible, setMarkerVisible, elementsVisible, setTextsVisible } = (0, store_js_namespaceObject.useBlackboardPreference)();
|
|
110
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
111
|
+
Promise.resolve((async ()=>{
|
|
112
|
+
if (!domRef.current || !screenWidth) return;
|
|
113
|
+
await app.init({
|
|
114
|
+
width: screenWidth,
|
|
115
|
+
height: screenHeight,
|
|
116
|
+
background: 0xffffff
|
|
117
|
+
});
|
|
118
|
+
const canvasEl = domRef.current;
|
|
119
|
+
domRef.current.appendChild(app.canvas);
|
|
120
|
+
const { clientWidth } = domRef.current.parentElement;
|
|
121
|
+
const targetHeight = 0.6 * window.innerHeight;
|
|
122
|
+
const viewportRatio = clientWidth / targetHeight;
|
|
123
|
+
if (screenWidth / screenHeight <= viewportRatio) {
|
|
124
|
+
const ratio = targetHeight / screenHeight;
|
|
125
|
+
canvasEl.style.width = `${Math.floor(screenWidth * ratio)}px`;
|
|
126
|
+
canvasEl.style.height = `${Math.floor(screenHeight * ratio)}px`;
|
|
127
|
+
}
|
|
128
|
+
app.stage.addChild(highlightContainer);
|
|
129
|
+
app.stage.addChild(elementMarkContainer);
|
|
130
|
+
setAppInitialed(true);
|
|
131
|
+
})());
|
|
132
|
+
return ()=>{
|
|
133
|
+
console.log('will destroy');
|
|
134
|
+
try {
|
|
135
|
+
app.destroy(true, {
|
|
136
|
+
children: true,
|
|
137
|
+
texture: true
|
|
138
|
+
});
|
|
139
|
+
} catch (e) {
|
|
140
|
+
console.warn('destroy failed', e);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}, [
|
|
144
|
+
app,
|
|
145
|
+
screenWidth,
|
|
146
|
+
screenHeight
|
|
147
|
+
]);
|
|
148
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
149
|
+
if (!appInitialed) return;
|
|
150
|
+
app.stage.eventMode = 'static';
|
|
151
|
+
app.stage.hitArea = new external_pixi_js_namespaceObject.Rectangle(0, 0, screenWidth, screenHeight);
|
|
152
|
+
const clickHandler = (event)=>{
|
|
153
|
+
var _props_onCanvasClick;
|
|
154
|
+
console.log('pixi click', event);
|
|
155
|
+
const { x, y } = event.data.global;
|
|
156
|
+
null == (_props_onCanvasClick = props.onCanvasClick) || _props_onCanvasClick.call(props, [
|
|
157
|
+
Math.round(x),
|
|
158
|
+
Math.round(y)
|
|
159
|
+
]);
|
|
160
|
+
};
|
|
161
|
+
app.stage.on('click', clickHandler);
|
|
162
|
+
return ()=>{
|
|
163
|
+
var _app_stage;
|
|
164
|
+
null == app || null == (_app_stage = app.stage) || _app_stage.off('click');
|
|
165
|
+
};
|
|
166
|
+
}, [
|
|
167
|
+
appInitialed,
|
|
168
|
+
props.onCanvasClick,
|
|
169
|
+
screenWidth,
|
|
170
|
+
screenHeight
|
|
171
|
+
]);
|
|
172
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
173
|
+
if (!appInitialed) return;
|
|
174
|
+
const img = new Image();
|
|
175
|
+
img.onload = ()=>{
|
|
176
|
+
if (!app.stage) return;
|
|
177
|
+
const screenshotTexture = external_pixi_js_namespaceObject.Texture.from(img);
|
|
178
|
+
const backgroundSprite = new external_pixi_js_namespaceObject.Sprite(screenshotTexture);
|
|
179
|
+
backgroundSprite.x = 0;
|
|
180
|
+
backgroundSprite.y = 0;
|
|
181
|
+
backgroundSprite.width = screenWidth;
|
|
182
|
+
backgroundSprite.height = screenHeight;
|
|
183
|
+
backgroundSprite.eventMode = 'passive';
|
|
184
|
+
app.stage.addChildAt(backgroundSprite, 0);
|
|
185
|
+
pixiBgRef.current = backgroundSprite;
|
|
186
|
+
};
|
|
187
|
+
img.onerror = (e)=>{
|
|
188
|
+
console.error('load screenshot failed', e);
|
|
189
|
+
};
|
|
190
|
+
img.src = screenshotBase64;
|
|
191
|
+
}, [
|
|
192
|
+
app.stage,
|
|
193
|
+
appInitialed,
|
|
194
|
+
screenWidth,
|
|
195
|
+
screenHeight
|
|
196
|
+
]);
|
|
197
|
+
const { highlightElementRects } = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
198
|
+
const highlightElementRects = [];
|
|
199
|
+
highlightContainer.removeChildren();
|
|
200
|
+
elementMarkContainer.removeChildren();
|
|
201
|
+
highlightContainer.eventMode = 'passive';
|
|
202
|
+
elementMarkContainer.eventMode = 'passive';
|
|
203
|
+
if (highlightRect) {
|
|
204
|
+
const [graphics] = rectMarkForItem(highlightRect, 'Search Area', 'searchArea');
|
|
205
|
+
highlightContainer.addChild(graphics);
|
|
144
206
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
207
|
+
if (highlightElements.length) highlightElements.forEach((element)=>{
|
|
208
|
+
const { rect, content, id } = element;
|
|
209
|
+
const [graphics] = rectMarkForItem(rect, content, 'highlight');
|
|
210
|
+
highlightContainer.addChild(graphics);
|
|
149
211
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
173
|
-
}, [app, screenWidth, screenHeight]);
|
|
174
|
-
(0, import_react.useEffect)(() => {
|
|
175
|
-
if (!appInitialed) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
app.stage.eventMode = "static";
|
|
179
|
-
app.stage.hitArea = new PIXI.Rectangle(0, 0, screenWidth, screenHeight);
|
|
180
|
-
const clickHandler = (event) => {
|
|
181
|
-
var _a;
|
|
182
|
-
import_console_browserify.default.log("pixi click", event);
|
|
183
|
-
const { x, y } = event.data.global;
|
|
184
|
-
(_a = props.onCanvasClick) == null ? void 0 : _a.call(props, [Math.round(x), Math.round(y)]);
|
|
185
|
-
};
|
|
186
|
-
app.stage.on("click", clickHandler);
|
|
187
|
-
return () => {
|
|
188
|
-
var _a;
|
|
189
|
-
(_a = app == null ? void 0 : app.stage) == null ? void 0 : _a.off("click");
|
|
190
|
-
};
|
|
191
|
-
}, [appInitialed, props.onCanvasClick, screenWidth, screenHeight]);
|
|
192
|
-
(0, import_react.useEffect)(() => {
|
|
193
|
-
if (!appInitialed) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const img = new Image();
|
|
197
|
-
img.onload = () => {
|
|
198
|
-
if (!app.stage)
|
|
199
|
-
return;
|
|
200
|
-
const screenshotTexture = PIXI.Texture.from(img);
|
|
201
|
-
const backgroundSprite = new PIXI.Sprite(screenshotTexture);
|
|
202
|
-
backgroundSprite.x = 0;
|
|
203
|
-
backgroundSprite.y = 0;
|
|
204
|
-
backgroundSprite.width = screenWidth;
|
|
205
|
-
backgroundSprite.height = screenHeight;
|
|
206
|
-
backgroundSprite.eventMode = "passive";
|
|
207
|
-
app.stage.addChildAt(backgroundSprite, 0);
|
|
208
|
-
pixiBgRef.current = backgroundSprite;
|
|
209
|
-
};
|
|
210
|
-
img.onerror = (e) => {
|
|
211
|
-
import_console_browserify.default.error("load screenshot failed", e);
|
|
212
|
-
};
|
|
213
|
-
img.src = screenshotBase64;
|
|
214
|
-
}, [app.stage, appInitialed, screenWidth, screenHeight]);
|
|
215
|
-
const { highlightElementRects } = (0, import_react.useMemo)(() => {
|
|
216
|
-
const highlightElementRects2 = [];
|
|
217
|
-
highlightContainer.removeChildren();
|
|
218
|
-
elementMarkContainer.removeChildren();
|
|
219
|
-
highlightContainer.eventMode = "passive";
|
|
220
|
-
elementMarkContainer.eventMode = "passive";
|
|
221
|
-
if (highlightRect) {
|
|
222
|
-
const [graphics] = rectMarkForItem(
|
|
212
|
+
if (null == highlightPoints ? void 0 : highlightPoints.length) highlightPoints.forEach((point)=>{
|
|
213
|
+
const graphics = pointMarkForItem(point, 'highlightPoint');
|
|
214
|
+
highlightContainer.addChild(graphics);
|
|
215
|
+
});
|
|
216
|
+
const elements = (0, extractor_namespaceObject.treeToList)(context.tree);
|
|
217
|
+
elements.forEach((element)=>{
|
|
218
|
+
const { rect, content, id } = element;
|
|
219
|
+
const ifHighlight = highlightIds.includes(id) || (null == hoverElement ? void 0 : hoverElement.id) === id;
|
|
220
|
+
if (ifHighlight) return;
|
|
221
|
+
const [graphics] = rectMarkForItem(rect, content, 'element');
|
|
222
|
+
elementMarkContainer.addChild(graphics);
|
|
223
|
+
});
|
|
224
|
+
elementMarkContainer.visible = elementsVisible;
|
|
225
|
+
return {
|
|
226
|
+
highlightElementRects
|
|
227
|
+
};
|
|
228
|
+
}, [
|
|
229
|
+
app,
|
|
230
|
+
appInitialed,
|
|
231
|
+
highlightElements,
|
|
232
|
+
context.tree,
|
|
233
|
+
hoverElement,
|
|
223
234
|
highlightRect,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (highlightElements.length) {
|
|
230
|
-
highlightElements.forEach((element) => {
|
|
231
|
-
const { rect, content, id } = element;
|
|
232
|
-
const [graphics] = rectMarkForItem(rect, content, "highlight");
|
|
233
|
-
highlightContainer.addChild(graphics);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
if (highlightPoints == null ? void 0 : highlightPoints.length) {
|
|
237
|
-
highlightPoints.forEach((point) => {
|
|
238
|
-
const graphics = pointMarkForItem(point, "highlightPoint");
|
|
239
|
-
highlightContainer.addChild(graphics);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
const elements = (0, import_extractor.treeToList)(context.tree);
|
|
243
|
-
elements.forEach((element) => {
|
|
244
|
-
const { rect, content, id } = element;
|
|
245
|
-
const ifHighlight = highlightIds.includes(id) || (hoverElement == null ? void 0 : hoverElement.id) === id;
|
|
246
|
-
if (ifHighlight) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
const [graphics] = rectMarkForItem(rect, content, "element");
|
|
250
|
-
elementMarkContainer.addChild(graphics);
|
|
251
|
-
});
|
|
252
|
-
elementMarkContainer.visible = elementsVisible;
|
|
253
|
-
return {
|
|
254
|
-
highlightElementRects: highlightElementRects2
|
|
235
|
+
highlightPoints
|
|
236
|
+
]);
|
|
237
|
+
const onSetElementsVisible = (e)=>{
|
|
238
|
+
setTextsVisible(e.target.checked);
|
|
239
|
+
elementMarkContainer.visible = e.target.checked;
|
|
255
240
|
};
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
setMarkerVisible(e.target.checked);
|
|
269
|
-
if (pixiBgRef.current) {
|
|
270
|
-
pixiBgRef.current.visible = e.target.checked;
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
const onSetElementsVisible = (e) => {
|
|
274
|
-
setTextsVisible(e.target.checked);
|
|
275
|
-
elementMarkContainer.visible = e.target.checked;
|
|
276
|
-
};
|
|
277
|
-
let bottomTipA = null;
|
|
278
|
-
if (highlightElementRects.length === 1) {
|
|
279
|
-
bottomTipA = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bottom-tip", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "bottom-tip-item", children: [
|
|
280
|
-
"Element: ",
|
|
281
|
-
JSON.stringify(highlightElementRects[0])
|
|
282
|
-
] }) });
|
|
283
|
-
} else if (highlightElementRects.length > 1) {
|
|
284
|
-
bottomTipA = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "bottom-tip", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "bottom-tip-item", children: [
|
|
285
|
-
"Element: ",
|
|
286
|
-
JSON.stringify(highlightElementRects)
|
|
287
|
-
] }) });
|
|
288
|
-
}
|
|
289
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "blackboard", children: [
|
|
290
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
291
|
-
"div",
|
|
292
|
-
{
|
|
293
|
-
className: "blackboard-main-content",
|
|
294
|
-
style: { width: "100%" },
|
|
295
|
-
ref: domRef
|
|
296
|
-
}
|
|
297
|
-
),
|
|
298
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
299
|
-
"div",
|
|
300
|
-
{
|
|
301
|
-
className: "blackboard-filter",
|
|
302
|
-
style: { display: props.hideController ? "none" : "block" },
|
|
303
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "overlay-control", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Checkbox, { checked: elementsVisible, onChange: onSetElementsVisible, children: "Elements" }) })
|
|
304
|
-
}
|
|
305
|
-
),
|
|
306
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
307
|
-
"div",
|
|
308
|
-
{
|
|
241
|
+
let bottomTipA = null;
|
|
242
|
+
if (1 === highlightElementRects.length) bottomTipA = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
243
|
+
className: "bottom-tip",
|
|
244
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
245
|
+
className: "bottom-tip-item",
|
|
246
|
+
children: [
|
|
247
|
+
"Element: ",
|
|
248
|
+
JSON.stringify(highlightElementRects[0])
|
|
249
|
+
]
|
|
250
|
+
})
|
|
251
|
+
});
|
|
252
|
+
else if (highlightElementRects.length > 1) bottomTipA = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
309
253
|
className: "bottom-tip",
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
254
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
255
|
+
className: "bottom-tip-item",
|
|
256
|
+
children: [
|
|
257
|
+
"Element: ",
|
|
258
|
+
JSON.stringify(highlightElementRects)
|
|
259
|
+
]
|
|
260
|
+
})
|
|
261
|
+
});
|
|
262
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
263
|
+
className: "blackboard",
|
|
264
|
+
children: [
|
|
265
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
266
|
+
className: "blackboard-main-content",
|
|
267
|
+
style: {
|
|
268
|
+
width: '100%'
|
|
269
|
+
},
|
|
270
|
+
ref: domRef
|
|
271
|
+
}),
|
|
272
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
273
|
+
className: "blackboard-filter",
|
|
274
|
+
style: {
|
|
275
|
+
display: props.hideController ? 'none' : 'block'
|
|
276
|
+
},
|
|
277
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
278
|
+
className: "overlay-control",
|
|
279
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Checkbox, {
|
|
280
|
+
checked: elementsVisible,
|
|
281
|
+
onChange: onSetElementsVisible,
|
|
282
|
+
children: "Elements"
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
}),
|
|
286
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
287
|
+
className: "bottom-tip",
|
|
288
|
+
style: {
|
|
289
|
+
display: props.hideController ? 'none' : 'block'
|
|
290
|
+
},
|
|
291
|
+
children: bottomTipA
|
|
292
|
+
})
|
|
293
|
+
]
|
|
294
|
+
});
|
|
315
295
|
};
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
296
|
+
const blackboard = Blackboard;
|
|
297
|
+
exports.Blackboard = __webpack_exports__.Blackboard;
|
|
298
|
+
exports["default"] = __webpack_exports__["default"];
|
|
299
|
+
exports.pointMarkForItem = __webpack_exports__.pointMarkForItem;
|
|
300
|
+
exports.rectMarkForItem = __webpack_exports__.rectMarkForItem;
|
|
301
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
302
|
+
"Blackboard",
|
|
303
|
+
"default",
|
|
304
|
+
"pointMarkForItem",
|
|
305
|
+
"rectMarkForItem"
|
|
306
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
307
|
+
Object.defineProperty(exports, '__esModule', {
|
|
308
|
+
value: true
|
|
322
309
|
});
|