@godscene/visualizer 1.7.11
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/component/blackboard/highlights.mjs +47 -0
- package/dist/es/component/blackboard/index.css +118 -0
- package/dist/es/component/blackboard/index.mjs +122 -0
- package/dist/es/component/config-selector/index.mjs +251 -0
- package/dist/es/component/context-preview/index.mjs +37 -0
- package/dist/es/component/env-config/index.mjs +237 -0
- package/dist/es/component/env-config-reminder/index.css +30 -0
- package/dist/es/component/env-config-reminder/index.mjs +27 -0
- package/dist/es/component/form-field/index.mjs +158 -0
- package/dist/es/component/history-selector/index.css +237 -0
- package/dist/es/component/history-selector/index.mjs +197 -0
- package/dist/es/component/index.mjs +1 -0
- package/dist/es/component/logo/index.css +19 -0
- package/dist/es/component/logo/index.mjs +20 -0
- package/dist/es/component/logo/logo.mjs +2 -0
- package/dist/es/component/misc/index.mjs +96 -0
- package/dist/es/component/nav-actions/index.mjs +14 -0
- package/dist/es/component/nav-actions/style.css +35 -0
- package/dist/es/component/player/index.css +296 -0
- package/dist/es/component/player/index.mjs +702 -0
- package/dist/es/component/player/playback-controls.mjs +4 -0
- package/dist/es/component/player/report-download.mjs +61 -0
- package/dist/es/component/player/scenes/StepScene.mjs +194 -0
- package/dist/es/component/player/scenes/derive-frame-state.mjs +229 -0
- package/dist/es/component/player/scenes/export-branded-video.mjs +360 -0
- package/dist/es/component/player/scenes/frame-calculator.mjs +149 -0
- package/dist/es/component/player/scenes/playback-frame.mjs +6 -0
- package/dist/es/component/player/scenes/playback-layout.mjs +12 -0
- package/dist/es/component/player/scenes/pointer-layout.mjs +36 -0
- package/dist/es/component/player/use-frame-player.mjs +87 -0
- package/dist/es/component/playground/index.css +930 -0
- package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/es/component/playground-result/index.css +92 -0
- package/dist/es/component/playground-result/index.mjs +232 -0
- package/dist/es/component/prompt-input/index.css +832 -0
- package/dist/es/component/prompt-input/index.mjs +959 -0
- package/dist/es/component/screenshot-viewer/index.css +237 -0
- package/dist/es/component/screenshot-viewer/index.mjs +319 -0
- package/dist/es/component/service-mode-control/index.mjs +107 -0
- package/dist/es/component/shiny-text/index.css +107 -0
- package/dist/es/component/shiny-text/index.mjs +15 -0
- package/dist/es/component/universal-playground/empty-state.mjs +5 -0
- package/dist/es/component/universal-playground/index.css +619 -0
- package/dist/es/component/universal-playground/index.mjs +558 -0
- package/dist/es/component/universal-playground/providers/context-provider.mjs +90 -0
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +280 -0
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +279 -0
- package/dist/es/component/universal-playground/universal-playground-electron.mjs +668 -0
- package/dist/es/hooks/useMinimalTypeGate.mjs +47 -0
- package/dist/es/hooks/usePlaygroundExecution.mjs +435 -0
- package/dist/es/hooks/usePlaygroundState.mjs +278 -0
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +20 -0
- package/dist/es/hooks/useServerValid.mjs +55 -0
- package/dist/es/hooks/useTheme.mjs +25 -0
- package/dist/es/icons/action-chevron.mjs +61 -0
- package/dist/es/icons/avatar.mjs +70 -0
- package/dist/es/icons/close.mjs +61 -0
- package/dist/es/icons/global-perspective.mjs +58 -0
- package/dist/es/icons/history.mjs +72 -0
- package/dist/es/icons/magnifying-glass.mjs +81 -0
- package/dist/es/icons/player-setting.mjs +68 -0
- package/dist/es/icons/prompt-history.mjs +70 -0
- package/dist/es/icons/setting.mjs +62 -0
- package/dist/es/icons/show-marker.mjs +58 -0
- package/dist/es/index.mjs +26 -0
- package/dist/es/static/image/logo.png +0 -0
- package/dist/es/store/history.mjs +128 -0
- package/dist/es/store/store.mjs +277 -0
- package/dist/es/types.mjs +73 -0
- package/dist/es/utils/action-label.mjs +15 -0
- package/dist/es/utils/color.mjs +35 -0
- package/dist/es/utils/constants.mjs +99 -0
- package/dist/es/utils/device-capabilities.mjs +13 -0
- package/dist/es/utils/empty-state-scroll.mjs +8 -0
- package/dist/es/utils/highlight-element.mjs +62 -0
- package/dist/es/utils/index.mjs +13 -0
- package/dist/es/utils/playground-utils.mjs +43 -0
- package/dist/es/utils/progress-action-icon.mjs +30 -0
- package/dist/es/utils/prompt-input-utils.mjs +49 -0
- package/dist/es/utils/prompt-placeholder.mjs +19 -0
- package/dist/es/utils/replay-scripts.mjs +428 -0
- package/dist/lib/component/blackboard/highlights.js +84 -0
- package/dist/lib/component/blackboard/index.css +118 -0
- package/dist/lib/component/blackboard/index.js +169 -0
- package/dist/lib/component/config-selector/index.js +295 -0
- package/dist/lib/component/context-preview/index.js +82 -0
- package/dist/lib/component/env-config/index.js +271 -0
- package/dist/lib/component/env-config-reminder/index.css +30 -0
- package/dist/lib/component/env-config-reminder/index.js +61 -0
- package/dist/lib/component/form-field/index.js +204 -0
- package/dist/lib/component/history-selector/index.css +237 -0
- package/dist/lib/component/history-selector/index.js +243 -0
- package/dist/lib/component/index.js +58 -0
- package/dist/lib/component/logo/index.css +19 -0
- package/dist/lib/component/logo/index.js +67 -0
- package/dist/lib/component/logo/logo.js +24 -0
- package/dist/lib/component/misc/index.js +152 -0
- package/dist/lib/component/nav-actions/index.js +48 -0
- package/dist/lib/component/nav-actions/style.css +35 -0
- package/dist/lib/component/player/index.css +296 -0
- package/dist/lib/component/player/index.js +747 -0
- package/dist/lib/component/player/playback-controls.js +38 -0
- package/dist/lib/component/player/report-download.js +98 -0
- package/dist/lib/component/player/scenes/StepScene.js +228 -0
- package/dist/lib/component/player/scenes/derive-frame-state.js +266 -0
- package/dist/lib/component/player/scenes/export-branded-video.js +403 -0
- package/dist/lib/component/player/scenes/frame-calculator.js +186 -0
- package/dist/lib/component/player/scenes/playback-frame.js +40 -0
- package/dist/lib/component/player/scenes/playback-layout.js +46 -0
- package/dist/lib/component/player/scenes/pointer-layout.js +88 -0
- package/dist/lib/component/player/use-frame-player.js +121 -0
- package/dist/lib/component/playground/index.css +930 -0
- package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/lib/component/playground-result/index.css +92 -0
- package/dist/lib/component/playground-result/index.js +276 -0
- package/dist/lib/component/prompt-input/index.css +832 -0
- package/dist/lib/component/prompt-input/index.js +1005 -0
- package/dist/lib/component/screenshot-viewer/index.css +237 -0
- package/dist/lib/component/screenshot-viewer/index.js +353 -0
- package/dist/lib/component/service-mode-control/index.js +141 -0
- package/dist/lib/component/shiny-text/index.css +107 -0
- package/dist/lib/component/shiny-text/index.js +49 -0
- package/dist/lib/component/universal-playground/empty-state.js +39 -0
- package/dist/lib/component/universal-playground/index.css +619 -0
- package/dist/lib/component/universal-playground/index.js +607 -0
- package/dist/lib/component/universal-playground/providers/context-provider.js +133 -0
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +320 -0
- package/dist/lib/component/universal-playground/providers/storage-provider.js +337 -0
- package/dist/lib/component/universal-playground/universal-playground-electron.js +717 -0
- package/dist/lib/hooks/useMinimalTypeGate.js +81 -0
- package/dist/lib/hooks/usePlaygroundExecution.js +478 -0
- package/dist/lib/hooks/usePlaygroundState.js +312 -0
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +57 -0
- package/dist/lib/hooks/useServerValid.js +89 -0
- package/dist/lib/hooks/useTheme.js +59 -0
- package/dist/lib/icons/action-chevron.js +95 -0
- package/dist/lib/icons/avatar.js +104 -0
- package/dist/lib/icons/close.js +95 -0
- package/dist/lib/icons/global-perspective.js +92 -0
- package/dist/lib/icons/history.js +106 -0
- package/dist/lib/icons/magnifying-glass.js +115 -0
- package/dist/lib/icons/player-setting.js +102 -0
- package/dist/lib/icons/prompt-history.js +104 -0
- package/dist/lib/icons/setting.js +96 -0
- package/dist/lib/icons/show-marker.js +92 -0
- package/dist/lib/index.js +204 -0
- package/dist/lib/static/image/logo.png +0 -0
- package/dist/lib/store/history.js +135 -0
- package/dist/lib/store/store.js +287 -0
- package/dist/lib/types.js +119 -0
- package/dist/lib/utils/action-label.js +52 -0
- package/dist/lib/utils/color.js +75 -0
- package/dist/lib/utils/constants.js +172 -0
- package/dist/lib/utils/device-capabilities.js +50 -0
- package/dist/lib/utils/empty-state-scroll.js +42 -0
- package/dist/lib/utils/highlight-element.js +99 -0
- package/dist/lib/utils/index.js +69 -0
- package/dist/lib/utils/playground-utils.js +86 -0
- package/dist/lib/utils/progress-action-icon.js +67 -0
- package/dist/lib/utils/prompt-input-utils.js +89 -0
- package/dist/lib/utils/prompt-placeholder.js +53 -0
- package/dist/lib/utils/replay-scripts.js +474 -0
- package/dist/types/component/blackboard/highlights.d.ts +11 -0
- package/dist/types/component/blackboard/index.d.ts +10 -0
- package/dist/types/component/config-selector/index.d.ts +15 -0
- package/dist/types/component/context-preview/index.d.ts +9 -0
- package/dist/types/component/env-config/index.d.ts +8 -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 +13 -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 +12 -0
- package/dist/types/component/player/index.d.ts +15 -0
- package/dist/types/component/player/playback-controls.d.ts +1 -0
- package/dist/types/component/player/report-download.d.ts +32 -0
- package/dist/types/component/player/scenes/StepScene.d.ts +9 -0
- package/dist/types/component/player/scenes/derive-frame-state.d.ts +40 -0
- package/dist/types/component/player/scenes/export-branded-video.d.ts +33 -0
- package/dist/types/component/player/scenes/frame-calculator.d.ts +40 -0
- package/dist/types/component/player/scenes/playback-frame.d.ts +3 -0
- package/dist/types/component/player/scenes/playback-layout.d.ts +7 -0
- package/dist/types/component/player/scenes/pointer-layout.d.ts +20 -0
- package/dist/types/component/player/use-frame-player.d.ts +17 -0
- package/dist/types/component/playground-result/index.d.ts +22 -0
- package/dist/types/component/prompt-input/index.d.ts +23 -0
- package/dist/types/component/screenshot-viewer/index.d.ts +23 -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/empty-state.d.ts +3 -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/component/universal-playground/universal-playground-electron.d.ts +4 -0
- package/dist/types/hooks/useMinimalTypeGate.d.ts +72 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +40 -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/hooks/useTheme.d.ts +7 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/store/history.d.ts +16 -0
- package/dist/types/store/store.d.ts +57 -0
- package/dist/types/types.d.ts +278 -0
- package/dist/types/utils/action-label.d.ts +11 -0
- package/dist/types/utils/color.d.ts +4 -0
- package/dist/types/utils/constants.d.ts +80 -0
- package/dist/types/utils/device-capabilities.d.ts +9 -0
- package/dist/types/utils/empty-state-scroll.d.ts +11 -0
- package/dist/types/utils/highlight-element.d.ts +3 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/playground-utils.d.ts +11 -0
- package/dist/types/utils/progress-action-icon.d.ts +12 -0
- package/dist/types/utils/prompt-input-utils.d.ts +24 -0
- package/dist/types/utils/prompt-placeholder.d.ts +1 -0
- package/dist/types/utils/replay-scripts.d.ts +50 -0
- package/package.json +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function formatCenterKey(center) {
|
|
2
|
+
return `${center[0]}:${center[1]}`;
|
|
3
|
+
}
|
|
4
|
+
function formatRectKey(rect) {
|
|
5
|
+
return `${rect.left}:${rect.top}:${rect.width}:${rect.height}`;
|
|
6
|
+
}
|
|
7
|
+
function getElementLabel(element) {
|
|
8
|
+
if ('content' in element && element.content) return element.content;
|
|
9
|
+
if ("description" in element && element.description) return element.description;
|
|
10
|
+
}
|
|
11
|
+
function normalizeBlackboardHighlights(elements) {
|
|
12
|
+
if (!(null == elements ? void 0 : elements.length)) return [];
|
|
13
|
+
const deduped = new Map();
|
|
14
|
+
elements.forEach((element, index)=>{
|
|
15
|
+
if (!(null == element ? void 0 : element.rect) || !(null == element ? void 0 : element.center)) return;
|
|
16
|
+
const label = getElementLabel(element);
|
|
17
|
+
const dedupeKey = [
|
|
18
|
+
'id' in element ? element.id : '',
|
|
19
|
+
label || '',
|
|
20
|
+
formatCenterKey(element.center),
|
|
21
|
+
formatRectKey(element.rect)
|
|
22
|
+
].join('|');
|
|
23
|
+
if (!deduped.has(dedupeKey)) deduped.set(dedupeKey, {
|
|
24
|
+
key: 'id' in element && element.id || `${dedupeKey || 'highlight'}-${index}`,
|
|
25
|
+
label,
|
|
26
|
+
center: element.center,
|
|
27
|
+
rect: element.rect
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return Array.from(deduped.values());
|
|
31
|
+
}
|
|
32
|
+
function roundRect(rect) {
|
|
33
|
+
return {
|
|
34
|
+
left: Math.round(rect.left),
|
|
35
|
+
top: Math.round(rect.top),
|
|
36
|
+
width: Math.round(rect.width),
|
|
37
|
+
height: Math.round(rect.height)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function formatBlackboardHighlightSummary(highlight) {
|
|
41
|
+
const center = `[${Math.round(highlight.center[0])}, ${Math.round(highlight.center[1])}]`;
|
|
42
|
+
const rect = roundRect(highlight.rect);
|
|
43
|
+
const rectText = `rect=${JSON.stringify(rect)}`;
|
|
44
|
+
if (highlight.label) return `${highlight.label} center=${center}, ${rectText}`;
|
|
45
|
+
return `center=${center}, ${rectText}`;
|
|
46
|
+
}
|
|
47
|
+
export { formatBlackboardHighlightSummary, normalizeBlackboardHighlights };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
.blackboard .footer {
|
|
2
|
+
color: #aaa;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.blackboard ul {
|
|
6
|
+
padding-left: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.blackboard li {
|
|
10
|
+
list-style: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.blackboard .bottom-tip {
|
|
14
|
+
height: 30px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.blackboard .bottom-tip-item {
|
|
18
|
+
color: #aaa;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
word-wrap: break-word;
|
|
21
|
+
max-width: 500px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.blackboard-main-content {
|
|
25
|
+
position: relative;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.blackboard-screenshot {
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
border: 1px solid #888;
|
|
32
|
+
width: 100%;
|
|
33
|
+
display: block;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.blackboard-overlay {
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
width: 100%;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0;
|
|
41
|
+
left: 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.blackboard-rect {
|
|
45
|
+
box-sizing: content-box;
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
z-index: 1;
|
|
48
|
+
position: absolute;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.blackboard-rect-label {
|
|
52
|
+
white-space: nowrap;
|
|
53
|
+
padding: 1px 4px;
|
|
54
|
+
font-size: 14px;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
line-height: 1.4;
|
|
57
|
+
position: absolute;
|
|
58
|
+
bottom: 100%;
|
|
59
|
+
left: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.blackboard-rect-search {
|
|
63
|
+
border: calc(1px * var(--ui-scale, 1)) solid #028391;
|
|
64
|
+
background: rgba(2, 131, 145, .15);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.blackboard-rect-search .blackboard-rect-label {
|
|
68
|
+
color: #028391;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.blackboard-rect-highlight {
|
|
72
|
+
border: calc(1px * var(--ui-scale, 1)) solid #fd5907;
|
|
73
|
+
background: rgba(253, 89, 7, .15);
|
|
74
|
+
animation: 1.2s ease-in-out infinite blackboard-pulse;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.blackboard-rect-highlight .blackboard-rect-label {
|
|
78
|
+
color: #000;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.blackboard-point {
|
|
82
|
+
width: calc(20px * var(--ui-scale, 1));
|
|
83
|
+
height: calc(20px * var(--ui-scale, 1));
|
|
84
|
+
margin-left: calc(-10px * var(--ui-scale, 1));
|
|
85
|
+
margin-top: calc(-10px * var(--ui-scale, 1));
|
|
86
|
+
border: calc(2px * var(--ui-scale, 1)) solid #fd5907;
|
|
87
|
+
box-shadow: 0 0 calc(6px * var(--ui-scale, 1)) rgba(253, 89, 7, .5);
|
|
88
|
+
pointer-events: none;
|
|
89
|
+
z-index: 2;
|
|
90
|
+
background: rgba(253, 89, 7, .4);
|
|
91
|
+
border-radius: 50%;
|
|
92
|
+
animation: 1.2s ease-in-out infinite blackboard-pulse;
|
|
93
|
+
position: absolute;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@keyframes blackboard-pulse {
|
|
97
|
+
0%, 100% {
|
|
98
|
+
opacity: .4;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
50% {
|
|
102
|
+
opacity: 1;
|
|
103
|
+
box-shadow: 0 0 12px rgba(253, 89, 7, .5);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[data-theme="dark"] .blackboard .footer, [data-theme="dark"] .blackboard .bottom-tip-item {
|
|
108
|
+
color: rgba(255, 255, 255, .45);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[data-theme="dark"] .blackboard-screenshot {
|
|
112
|
+
border-color: rgba(255, 255, 255, .12);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[data-theme="dark"] .blackboard-rect-highlight .blackboard-rect-label {
|
|
116
|
+
color: #fff;
|
|
117
|
+
}
|
|
118
|
+
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import react from "react";
|
|
4
|
+
import { getCenterHighlightBox } from "../../utils/highlight-element.mjs";
|
|
5
|
+
import { normalizeBlackboardHighlights } from "./highlights.mjs";
|
|
6
|
+
import "./index.css";
|
|
7
|
+
const Blackboard = (props)=>{
|
|
8
|
+
var _props_uiContext;
|
|
9
|
+
const highlightElements = props.highlightElements || [];
|
|
10
|
+
const highlightRect = props.highlightRect;
|
|
11
|
+
if (!(null == (_props_uiContext = props.uiContext) ? void 0 : _props_uiContext.shotSize)) return /*#__PURE__*/ jsx("div", {
|
|
12
|
+
className: "blackboard",
|
|
13
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
14
|
+
className: "blackboard-main-content",
|
|
15
|
+
style: {
|
|
16
|
+
padding: '20px'
|
|
17
|
+
},
|
|
18
|
+
children: "No UI context available"
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
const context = props.uiContext;
|
|
22
|
+
const { shotSize, screenshot } = context;
|
|
23
|
+
const screenWidth = shotSize.width;
|
|
24
|
+
const screenHeight = shotSize.height;
|
|
25
|
+
const highlightOverlays = react.useMemo(()=>normalizeBlackboardHighlights(highlightElements), [
|
|
26
|
+
highlightElements
|
|
27
|
+
]);
|
|
28
|
+
const screenshotBase64 = react.useMemo(()=>{
|
|
29
|
+
if (!screenshot) return '';
|
|
30
|
+
if ('object' == typeof screenshot && 'base64' in screenshot) return screenshot.base64;
|
|
31
|
+
if ('string' == typeof screenshot) return screenshot;
|
|
32
|
+
return '';
|
|
33
|
+
}, [
|
|
34
|
+
screenshot
|
|
35
|
+
]);
|
|
36
|
+
const highlightBoxes = highlightOverlays.map((highlight)=>getCenterHighlightBox(highlight));
|
|
37
|
+
let bottomTipA = null;
|
|
38
|
+
if (1 === highlightBoxes.length) bottomTipA = /*#__PURE__*/ jsx("div", {
|
|
39
|
+
className: "bottom-tip",
|
|
40
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
41
|
+
className: "bottom-tip-item",
|
|
42
|
+
children: [
|
|
43
|
+
"Element: ",
|
|
44
|
+
JSON.stringify(highlightBoxes[0])
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
else if (highlightBoxes.length > 1) bottomTipA = /*#__PURE__*/ jsx("div", {
|
|
49
|
+
className: "bottom-tip",
|
|
50
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
51
|
+
className: "bottom-tip-item",
|
|
52
|
+
children: [
|
|
53
|
+
"Element: ",
|
|
54
|
+
JSON.stringify(highlightBoxes)
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
59
|
+
className: "blackboard",
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ jsxs("div", {
|
|
62
|
+
className: "blackboard-main-content",
|
|
63
|
+
style: {
|
|
64
|
+
width: 'fit-content',
|
|
65
|
+
maxWidth: '100%',
|
|
66
|
+
position: 'relative'
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
screenshotBase64 && /*#__PURE__*/ jsx("img", {
|
|
70
|
+
src: screenshotBase64,
|
|
71
|
+
alt: "screenshot",
|
|
72
|
+
className: "blackboard-screenshot",
|
|
73
|
+
draggable: false
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ jsxs("div", {
|
|
76
|
+
className: "blackboard-overlay",
|
|
77
|
+
style: {
|
|
78
|
+
aspectRatio: `${screenWidth}/${screenHeight}`,
|
|
79
|
+
'--ui-scale': Math.max(1, Math.sqrt(screenWidth / 1920))
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
highlightRect && /*#__PURE__*/ jsx("div", {
|
|
83
|
+
className: "blackboard-rect blackboard-rect-search",
|
|
84
|
+
style: {
|
|
85
|
+
left: `${highlightRect.left / screenWidth * 100}%`,
|
|
86
|
+
top: `${highlightRect.top / screenHeight * 100}%`,
|
|
87
|
+
width: `${highlightRect.width / screenWidth * 100}%`,
|
|
88
|
+
height: `${highlightRect.height / screenHeight * 100}%`
|
|
89
|
+
},
|
|
90
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
91
|
+
className: "blackboard-rect-label",
|
|
92
|
+
children: "Search Area"
|
|
93
|
+
})
|
|
94
|
+
}),
|
|
95
|
+
highlightOverlays.map((el)=>{
|
|
96
|
+
const highlightBox = getCenterHighlightBox(el);
|
|
97
|
+
return /*#__PURE__*/ jsx("div", {
|
|
98
|
+
className: "blackboard-rect blackboard-rect-highlight",
|
|
99
|
+
style: {
|
|
100
|
+
left: `${highlightBox.left / screenWidth * 100}%`,
|
|
101
|
+
top: `${highlightBox.top / screenHeight * 100}%`,
|
|
102
|
+
width: `${highlightBox.width / screenWidth * 100}%`,
|
|
103
|
+
height: `${highlightBox.height / screenHeight * 100}%`
|
|
104
|
+
}
|
|
105
|
+
}, `${el.key}-rect`);
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ jsx("div", {
|
|
112
|
+
className: "bottom-tip",
|
|
113
|
+
style: {
|
|
114
|
+
display: props.hideController ? 'none' : 'block'
|
|
115
|
+
},
|
|
116
|
+
children: bottomTipA
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
const blackboard = Blackboard;
|
|
122
|
+
export { Blackboard, blackboard as default };
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox, Dropdown, Radio, Tooltip } from "antd";
|
|
3
|
+
import setting from "../../icons/setting.mjs";
|
|
4
|
+
import { useEnvConfig } from "../../store/store.mjs";
|
|
5
|
+
import { alwaysRefreshScreenInfoTip, autoDismissKeyboardTip, deepLocateTip, deepThinkTip, domIncludedTip, imeStrategyTip, keyboardDismissStrategyTip, screenshotIncludedTip, trackingTip } from "../../utils/constants.mjs";
|
|
6
|
+
import { getDeviceCapabilities, hasDeviceSpecificConfig } from "../../utils/device-capabilities.mjs";
|
|
7
|
+
const ConfigSelector = ({ showDeepLocateOption = false, showDeepThinkOption = false, enableTracking = false, showDataExtractionOptions = false, hideDomAndScreenshotOptions = false, deviceType, trigger, popupPlacement = 'bottomRight' })=>{
|
|
8
|
+
const forceSameTabNavigation = useEnvConfig((state)=>state.forceSameTabNavigation);
|
|
9
|
+
const setForceSameTabNavigation = useEnvConfig((state)=>state.setForceSameTabNavigation);
|
|
10
|
+
const deepLocate = useEnvConfig((state)=>state.deepLocate);
|
|
11
|
+
const setDeepLocate = useEnvConfig((state)=>state.setDeepLocate);
|
|
12
|
+
const deepThink = useEnvConfig((state)=>state.deepThink);
|
|
13
|
+
const setDeepThink = useEnvConfig((state)=>state.setDeepThink);
|
|
14
|
+
const screenshotIncluded = useEnvConfig((state)=>state.screenshotIncluded);
|
|
15
|
+
const setScreenshotIncluded = useEnvConfig((state)=>state.setScreenshotIncluded);
|
|
16
|
+
const domIncluded = useEnvConfig((state)=>state.domIncluded);
|
|
17
|
+
const setDomIncluded = useEnvConfig((state)=>state.setDomIncluded);
|
|
18
|
+
const imeStrategy = useEnvConfig((state)=>state.imeStrategy);
|
|
19
|
+
const setImeStrategy = useEnvConfig((state)=>state.setImeStrategy);
|
|
20
|
+
const autoDismissKeyboard = useEnvConfig((state)=>state.autoDismissKeyboard);
|
|
21
|
+
const setAutoDismissKeyboard = useEnvConfig((state)=>state.setAutoDismissKeyboard);
|
|
22
|
+
const keyboardDismissStrategy = useEnvConfig((state)=>state.keyboardDismissStrategy);
|
|
23
|
+
const setKeyboardDismissStrategy = useEnvConfig((state)=>state.setKeyboardDismissStrategy);
|
|
24
|
+
const alwaysRefreshScreenInfo = useEnvConfig((state)=>state.alwaysRefreshScreenInfo);
|
|
25
|
+
const setAlwaysRefreshScreenInfo = useEnvConfig((state)=>state.setAlwaysRefreshScreenInfo);
|
|
26
|
+
const deviceCapabilities = getDeviceCapabilities(deviceType);
|
|
27
|
+
const hasDeviceOptions = hasDeviceSpecificConfig(deviceType);
|
|
28
|
+
if (!enableTracking && !showDeepLocateOption && !showDeepThinkOption && !showDataExtractionOptions && !hasDeviceOptions) return null;
|
|
29
|
+
const configItems = buildConfigItems();
|
|
30
|
+
return /*#__PURE__*/ jsx("div", {
|
|
31
|
+
className: "selector-trigger",
|
|
32
|
+
children: /*#__PURE__*/ jsx(Dropdown, {
|
|
33
|
+
getPopupContainer: (triggerNode)=>triggerNode.ownerDocument.body,
|
|
34
|
+
menu: {
|
|
35
|
+
items: configItems
|
|
36
|
+
},
|
|
37
|
+
overlayClassName: "config-selector-dropdown",
|
|
38
|
+
overlayStyle: {
|
|
39
|
+
zIndex: 10010
|
|
40
|
+
},
|
|
41
|
+
placement: popupPlacement,
|
|
42
|
+
trigger: [
|
|
43
|
+
'click'
|
|
44
|
+
],
|
|
45
|
+
children: null != trigger ? trigger : /*#__PURE__*/ jsx(setting, {
|
|
46
|
+
width: 24,
|
|
47
|
+
height: 24
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
function buildConfigItems() {
|
|
52
|
+
const items = [];
|
|
53
|
+
if (enableTracking) items.push({
|
|
54
|
+
label: /*#__PURE__*/ jsx(Checkbox, {
|
|
55
|
+
onChange: (e)=>setForceSameTabNavigation(e.target.checked),
|
|
56
|
+
checked: forceSameTabNavigation,
|
|
57
|
+
children: trackingTip
|
|
58
|
+
}),
|
|
59
|
+
key: 'track-config'
|
|
60
|
+
});
|
|
61
|
+
if (showDeepLocateOption) items.push({
|
|
62
|
+
label: /*#__PURE__*/ jsx(Checkbox, {
|
|
63
|
+
onChange: (e)=>{
|
|
64
|
+
setDeepLocate(e.target.checked);
|
|
65
|
+
},
|
|
66
|
+
checked: deepLocate,
|
|
67
|
+
children: deepLocateTip
|
|
68
|
+
}),
|
|
69
|
+
key: 'deep-locate-config'
|
|
70
|
+
});
|
|
71
|
+
if (showDeepThinkOption) items.push({
|
|
72
|
+
label: /*#__PURE__*/ jsxs("div", {
|
|
73
|
+
style: {
|
|
74
|
+
padding: '4px 0'
|
|
75
|
+
},
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ jsx("div", {
|
|
78
|
+
style: {
|
|
79
|
+
marginBottom: '4px',
|
|
80
|
+
fontSize: '14px'
|
|
81
|
+
},
|
|
82
|
+
children: deepThinkTip
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ jsxs(Radio.Group, {
|
|
85
|
+
size: "small",
|
|
86
|
+
value: deepThink,
|
|
87
|
+
onChange: (e)=>setDeepThink(e.target.value),
|
|
88
|
+
children: [
|
|
89
|
+
/*#__PURE__*/ jsx(Tooltip, {
|
|
90
|
+
title: "Controlled by MIDSCENE_MODEL_REASONING_ENABLED env variable",
|
|
91
|
+
children: /*#__PURE__*/ jsx(Radio, {
|
|
92
|
+
value: 'unset',
|
|
93
|
+
children: "Auto"
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
97
|
+
value: true,
|
|
98
|
+
children: "On"
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
101
|
+
value: false,
|
|
102
|
+
children: "Off"
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
}),
|
|
108
|
+
key: 'deep-think-config'
|
|
109
|
+
});
|
|
110
|
+
if (showDataExtractionOptions && !hideDomAndScreenshotOptions) {
|
|
111
|
+
items.push({
|
|
112
|
+
label: /*#__PURE__*/ jsx(Checkbox, {
|
|
113
|
+
onChange: (e)=>{
|
|
114
|
+
setScreenshotIncluded(e.target.checked);
|
|
115
|
+
},
|
|
116
|
+
checked: screenshotIncluded,
|
|
117
|
+
children: screenshotIncludedTip
|
|
118
|
+
}),
|
|
119
|
+
key: 'screenshot-included-config'
|
|
120
|
+
});
|
|
121
|
+
items.push({
|
|
122
|
+
label: /*#__PURE__*/ jsxs("div", {
|
|
123
|
+
style: {
|
|
124
|
+
padding: '4px 0'
|
|
125
|
+
},
|
|
126
|
+
children: [
|
|
127
|
+
/*#__PURE__*/ jsx("div", {
|
|
128
|
+
style: {
|
|
129
|
+
marginBottom: '4px',
|
|
130
|
+
fontSize: '14px'
|
|
131
|
+
},
|
|
132
|
+
children: domIncludedTip
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ jsxs(Radio.Group, {
|
|
135
|
+
size: "small",
|
|
136
|
+
value: domIncluded,
|
|
137
|
+
onChange: (e)=>setDomIncluded(e.target.value),
|
|
138
|
+
children: [
|
|
139
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
140
|
+
value: false,
|
|
141
|
+
children: "Off"
|
|
142
|
+
}),
|
|
143
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
144
|
+
value: true,
|
|
145
|
+
children: "All"
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
148
|
+
value: 'visible-only',
|
|
149
|
+
children: "Visible only"
|
|
150
|
+
})
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
]
|
|
154
|
+
}),
|
|
155
|
+
key: 'dom-included-config'
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (deviceCapabilities.supportsImeStrategy) {
|
|
159
|
+
items.push({
|
|
160
|
+
label: /*#__PURE__*/ jsxs("div", {
|
|
161
|
+
style: {
|
|
162
|
+
padding: '4px 0'
|
|
163
|
+
},
|
|
164
|
+
children: [
|
|
165
|
+
/*#__PURE__*/ jsx("div", {
|
|
166
|
+
style: {
|
|
167
|
+
marginBottom: '4px',
|
|
168
|
+
fontSize: '14px'
|
|
169
|
+
},
|
|
170
|
+
children: imeStrategyTip
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ jsxs(Radio.Group, {
|
|
173
|
+
size: "small",
|
|
174
|
+
value: imeStrategy,
|
|
175
|
+
onChange: (e)=>setImeStrategy(e.target.value),
|
|
176
|
+
children: [
|
|
177
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
178
|
+
value: "always-yadb",
|
|
179
|
+
children: "Always YADB"
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
182
|
+
value: "yadb-for-non-ascii",
|
|
183
|
+
children: "YADB for non-ASCII"
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
})
|
|
187
|
+
]
|
|
188
|
+
}),
|
|
189
|
+
key: 'ime-strategy-config'
|
|
190
|
+
});
|
|
191
|
+
if (deviceCapabilities.supportsAutoDismissKeyboard) items.push({
|
|
192
|
+
label: /*#__PURE__*/ jsx(Checkbox, {
|
|
193
|
+
onChange: (e)=>setAutoDismissKeyboard(e.target.checked),
|
|
194
|
+
checked: autoDismissKeyboard,
|
|
195
|
+
children: autoDismissKeyboardTip
|
|
196
|
+
}),
|
|
197
|
+
key: 'auto-dismiss-keyboard-config'
|
|
198
|
+
});
|
|
199
|
+
if (deviceCapabilities.supportsKeyboardDismissStrategy) items.push({
|
|
200
|
+
label: /*#__PURE__*/ jsxs("div", {
|
|
201
|
+
style: {
|
|
202
|
+
padding: '4px 0'
|
|
203
|
+
},
|
|
204
|
+
children: [
|
|
205
|
+
/*#__PURE__*/ jsx("div", {
|
|
206
|
+
style: {
|
|
207
|
+
marginBottom: '4px',
|
|
208
|
+
fontSize: '14px'
|
|
209
|
+
},
|
|
210
|
+
children: keyboardDismissStrategyTip
|
|
211
|
+
}),
|
|
212
|
+
/*#__PURE__*/ jsxs(Radio.Group, {
|
|
213
|
+
size: "small",
|
|
214
|
+
value: keyboardDismissStrategy,
|
|
215
|
+
onChange: (e)=>setKeyboardDismissStrategy(e.target.value),
|
|
216
|
+
children: [
|
|
217
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
218
|
+
value: "esc-first",
|
|
219
|
+
children: "ESC first"
|
|
220
|
+
}),
|
|
221
|
+
/*#__PURE__*/ jsx(Radio, {
|
|
222
|
+
value: "back-first",
|
|
223
|
+
children: "Back first"
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
}),
|
|
229
|
+
key: 'keyboard-dismiss-strategy-config'
|
|
230
|
+
});
|
|
231
|
+
if (deviceCapabilities.supportsAlwaysRefreshScreenInfo) items.push({
|
|
232
|
+
label: /*#__PURE__*/ jsx(Checkbox, {
|
|
233
|
+
onChange: (e)=>setAlwaysRefreshScreenInfo(e.target.checked),
|
|
234
|
+
checked: alwaysRefreshScreenInfo,
|
|
235
|
+
children: alwaysRefreshScreenInfoTip
|
|
236
|
+
}),
|
|
237
|
+
key: 'always-refresh-screen-info-config'
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (!deviceCapabilities.supportsImeStrategy && deviceCapabilities.supportsAutoDismissKeyboard) items.push({
|
|
241
|
+
label: /*#__PURE__*/ jsx(Checkbox, {
|
|
242
|
+
onChange: (e)=>setAutoDismissKeyboard(e.target.checked),
|
|
243
|
+
checked: autoDismissKeyboard,
|
|
244
|
+
children: autoDismissKeyboardTip
|
|
245
|
+
}),
|
|
246
|
+
key: 'auto-dismiss-keyboard-config'
|
|
247
|
+
});
|
|
248
|
+
return items;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
export { ConfigSelector };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "antd";
|
|
3
|
+
import blackboard from "../blackboard/index.mjs";
|
|
4
|
+
import { iconForStatus } from "../misc/index.mjs";
|
|
5
|
+
import playground_demo_ui_context from "../playground/playground-demo-ui-context.json";
|
|
6
|
+
const ContextPreview = ({ uiContextPreview, setUiContextPreview, showContextPreview })=>{
|
|
7
|
+
if (!showContextPreview) return null;
|
|
8
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
9
|
+
className: "form-part context-panel",
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsx("h3", {
|
|
12
|
+
children: "UI Context"
|
|
13
|
+
}),
|
|
14
|
+
uiContextPreview ? /*#__PURE__*/ jsx(blackboard, {
|
|
15
|
+
uiContext: uiContextPreview,
|
|
16
|
+
hideController: true
|
|
17
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
18
|
+
children: [
|
|
19
|
+
iconForStatus('failed'),
|
|
20
|
+
" No UI context",
|
|
21
|
+
/*#__PURE__*/ jsx(Button, {
|
|
22
|
+
type: "link",
|
|
23
|
+
onClick: (e)=>{
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
setUiContextPreview(playground_demo_ui_context);
|
|
26
|
+
},
|
|
27
|
+
children: "Load Demo"
|
|
28
|
+
}),
|
|
29
|
+
/*#__PURE__*/ jsx("div", {
|
|
30
|
+
children: "To load the UI context, you can either use the demo data above, or click the 'Send to Playground' in the report page."
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export { ContextPreview };
|