@sqaitech/visualizer 0.30.10
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/index.css +33 -0
- package/dist/es/component/blackboard/index.mjs +278 -0
- package/dist/es/component/config-selector/index.mjs +104 -0
- package/dist/es/component/context-preview/index.mjs +38 -0
- package/dist/es/component/env-config/index.mjs +112 -0
- package/dist/es/component/env-config-reminder/index.css +22 -0
- package/dist/es/component/env-config-reminder/index.mjs +28 -0
- package/dist/es/component/form-field/index.mjs +163 -0
- package/dist/es/component/history-selector/index.css +135 -0
- package/dist/es/component/history-selector/index.mjs +170 -0
- package/dist/es/component/index.mjs +1 -0
- package/dist/es/component/logo/index.css +13 -0
- package/dist/es/component/logo/index.mjs +20 -0
- package/dist/es/component/misc/index.mjs +94 -0
- package/dist/es/component/nav-actions/index.mjs +32 -0
- package/dist/es/component/nav-actions/style.css +35 -0
- package/dist/es/component/player/index.css +185 -0
- package/dist/es/component/player/index.mjs +856 -0
- package/dist/es/component/playground/index.css +431 -0
- package/dist/es/component/playground/index.mjs +8 -0
- package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/es/component/playground-result/index.css +34 -0
- package/dist/es/component/playground-result/index.mjs +62 -0
- package/dist/es/component/prompt-input/index.css +391 -0
- package/dist/es/component/prompt-input/index.mjs +730 -0
- package/dist/es/component/service-mode-control/index.mjs +105 -0
- package/dist/es/component/shiny-text/index.css +75 -0
- package/dist/es/component/shiny-text/index.mjs +15 -0
- package/dist/es/component/universal-playground/index.css +341 -0
- package/dist/es/component/universal-playground/index.mjs +302 -0
- package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +207 -0
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +210 -0
- package/dist/es/hooks/usePlaygroundExecution.mjs +180 -0
- package/dist/es/hooks/usePlaygroundState.mjs +203 -0
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +24 -0
- package/dist/es/hooks/useServerValid.mjs +30 -0
- package/dist/es/icons/avatar.mjs +28 -0
- package/dist/es/icons/close.mjs +19 -0
- package/dist/es/icons/global-perspective.mjs +16 -0
- package/dist/es/icons/history.mjs +30 -0
- package/dist/es/icons/magnifying-glass.mjs +39 -0
- package/dist/es/icons/player-setting.mjs +26 -0
- package/dist/es/icons/setting.mjs +20 -0
- package/dist/es/icons/show-marker.mjs +16 -0
- package/dist/es/index.mjs +25 -0
- package/dist/es/store/history.mjs +89 -0
- package/dist/es/store/store.mjs +186 -0
- package/dist/es/types.mjs +70 -0
- package/dist/es/utils/color.mjs +35 -0
- package/dist/es/utils/constants.mjs +99 -0
- package/dist/es/utils/index.mjs +10 -0
- package/dist/es/utils/pixi-loader.mjs +16 -0
- package/dist/es/utils/playground-utils.mjs +67 -0
- package/dist/es/utils/replay-scripts.mjs +312 -0
- package/dist/lib/component/blackboard/index.css +33 -0
- package/dist/lib/component/blackboard/index.js +321 -0
- package/dist/lib/component/config-selector/index.js +148 -0
- package/dist/lib/component/context-preview/index.js +83 -0
- package/dist/lib/component/env-config/index.js +146 -0
- package/dist/lib/component/env-config-reminder/index.css +22 -0
- package/dist/lib/component/env-config-reminder/index.js +62 -0
- package/dist/lib/component/form-field/index.js +209 -0
- package/dist/lib/component/history-selector/index.css +135 -0
- package/dist/lib/component/history-selector/index.js +216 -0
- package/dist/lib/component/index.js +60 -0
- package/dist/lib/component/logo/index.css +13 -0
- package/dist/lib/component/logo/index.js +57 -0
- package/dist/lib/component/misc/index.js +150 -0
- package/dist/lib/component/nav-actions/index.js +66 -0
- package/dist/lib/component/nav-actions/style.css +35 -0
- package/dist/lib/component/player/index.css +185 -0
- package/dist/lib/component/player/index.js +902 -0
- package/dist/lib/component/playground/index.css +431 -0
- package/dist/lib/component/playground/index.js +113 -0
- package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/lib/component/playground-result/index.css +34 -0
- package/dist/lib/component/playground-result/index.js +106 -0
- package/dist/lib/component/prompt-input/index.css +391 -0
- package/dist/lib/component/prompt-input/index.js +774 -0
- package/dist/lib/component/service-mode-control/index.js +139 -0
- package/dist/lib/component/shiny-text/index.css +75 -0
- package/dist/lib/component/shiny-text/index.js +49 -0
- package/dist/lib/component/universal-playground/index.css +341 -0
- package/dist/lib/component/universal-playground/index.js +350 -0
- package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +247 -0
- package/dist/lib/component/universal-playground/providers/storage-provider.js +268 -0
- package/dist/lib/hooks/usePlaygroundExecution.js +214 -0
- package/dist/lib/hooks/usePlaygroundState.js +237 -0
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +61 -0
- package/dist/lib/hooks/useServerValid.js +64 -0
- package/dist/lib/icons/avatar.js +62 -0
- package/dist/lib/icons/close.js +53 -0
- package/dist/lib/icons/global-perspective.js +50 -0
- package/dist/lib/icons/history.js +64 -0
- package/dist/lib/icons/magnifying-glass.js +73 -0
- package/dist/lib/icons/player-setting.js +60 -0
- package/dist/lib/icons/setting.js +54 -0
- package/dist/lib/icons/show-marker.js +50 -0
- package/dist/lib/index.js +187 -0
- package/dist/lib/store/history.js +96 -0
- package/dist/lib/store/store.js +196 -0
- package/dist/lib/types.js +116 -0
- package/dist/lib/utils/color.js +75 -0
- package/dist/lib/utils/constants.js +154 -0
- package/dist/lib/utils/index.js +63 -0
- package/dist/lib/utils/pixi-loader.js +56 -0
- package/dist/lib/utils/playground-utils.js +110 -0
- package/dist/lib/utils/replay-scripts.js +355 -0
- package/dist/types/component/blackboard/index.d.ts +15 -0
- package/dist/types/component/config-selector/index.d.ts +9 -0
- package/dist/types/component/context-preview/index.d.ts +9 -0
- package/dist/types/component/env-config/index.d.ts +6 -0
- package/dist/types/component/env-config-reminder/index.d.ts +6 -0
- package/dist/types/component/form-field/index.d.ts +17 -0
- package/dist/types/component/history-selector/index.d.ts +10 -0
- package/dist/types/component/index.d.ts +1 -0
- package/dist/types/component/logo/index.d.ts +5 -0
- package/dist/types/component/misc/index.d.ts +6 -0
- package/dist/types/component/nav-actions/index.d.ts +10 -0
- package/dist/types/component/player/index.d.ts +13 -0
- package/dist/types/component/playground/index.d.ts +7 -0
- package/dist/types/component/playground-result/index.d.ts +20 -0
- package/dist/types/component/prompt-input/index.d.ts +22 -0
- package/dist/types/component/service-mode-control/index.d.ts +6 -0
- package/dist/types/component/shiny-text/index.d.ts +12 -0
- package/dist/types/component/universal-playground/index.d.ts +4 -0
- package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
- package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +10 -0
- package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
- package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
- package/dist/types/hooks/useServerValid.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/store/history.d.ts +16 -0
- package/dist/types/store/store.d.ts +36 -0
- package/dist/types/types.d.ts +161 -0
- package/dist/types/utils/color.d.ts +4 -0
- package/dist/types/utils/constants.d.ts +74 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/pixi-loader.d.ts +5 -0
- package/dist/types/utils/playground-utils.d.ts +6 -0
- package/dist/types/utils/replay-scripts.d.ts +34 -0
- package/package.json +85 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Form, Input, InputNumber, Select } from "antd";
|
|
3
|
+
const { TextArea } = Input;
|
|
4
|
+
const renderLabel = (label, isOptional)=>`${label}${isOptional ? ' (Optional)' : ''}`;
|
|
5
|
+
const TextField = (param)=>{
|
|
6
|
+
let { name, label, isRequired, marginBottom, placeholder: customPlaceholder } = param;
|
|
7
|
+
const placeholder = customPlaceholder || `Enter ${name}`;
|
|
8
|
+
return /*#__PURE__*/ jsx(Form.Item, {
|
|
9
|
+
name: [
|
|
10
|
+
'params',
|
|
11
|
+
name
|
|
12
|
+
],
|
|
13
|
+
label: renderLabel(label, !isRequired),
|
|
14
|
+
rules: isRequired ? [
|
|
15
|
+
{
|
|
16
|
+
required: true,
|
|
17
|
+
message: `Please input ${name}`
|
|
18
|
+
}
|
|
19
|
+
] : [],
|
|
20
|
+
style: {
|
|
21
|
+
marginBottom
|
|
22
|
+
},
|
|
23
|
+
colon: false,
|
|
24
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
25
|
+
placeholder: placeholder
|
|
26
|
+
})
|
|
27
|
+
}, name);
|
|
28
|
+
};
|
|
29
|
+
const LocateField = (param)=>{
|
|
30
|
+
let { name, label, isRequired, marginBottom, placeholder: customPlaceholder } = param;
|
|
31
|
+
const placeholder = customPlaceholder || `Describe the ${name}, use natural language`;
|
|
32
|
+
return /*#__PURE__*/ jsx(Form.Item, {
|
|
33
|
+
name: [
|
|
34
|
+
'params',
|
|
35
|
+
name
|
|
36
|
+
],
|
|
37
|
+
label: renderLabel(label, !isRequired),
|
|
38
|
+
rules: isRequired ? [
|
|
39
|
+
{
|
|
40
|
+
required: true,
|
|
41
|
+
message: `The ${name} is required`
|
|
42
|
+
}
|
|
43
|
+
] : [],
|
|
44
|
+
style: {
|
|
45
|
+
marginBottom
|
|
46
|
+
},
|
|
47
|
+
colon: false,
|
|
48
|
+
children: /*#__PURE__*/ jsx(TextArea, {
|
|
49
|
+
rows: 2,
|
|
50
|
+
placeholder: placeholder
|
|
51
|
+
})
|
|
52
|
+
}, name);
|
|
53
|
+
};
|
|
54
|
+
const EnumField = (param)=>{
|
|
55
|
+
let { name, label, fieldSchema, isRequired, marginBottom, placeholder: customPlaceholder } = param;
|
|
56
|
+
var _fieldSchema__def;
|
|
57
|
+
const enumValues = (null == (_fieldSchema__def = fieldSchema._def) ? void 0 : _fieldSchema__def.values) || [];
|
|
58
|
+
const selectOptions = enumValues.map((value)=>({
|
|
59
|
+
value,
|
|
60
|
+
label: value.charAt(0).toUpperCase() + value.slice(1)
|
|
61
|
+
}));
|
|
62
|
+
return /*#__PURE__*/ jsx(Form.Item, {
|
|
63
|
+
name: [
|
|
64
|
+
'params',
|
|
65
|
+
name
|
|
66
|
+
],
|
|
67
|
+
label: label,
|
|
68
|
+
rules: isRequired ? [
|
|
69
|
+
{
|
|
70
|
+
required: true,
|
|
71
|
+
message: `Please select ${name}`
|
|
72
|
+
}
|
|
73
|
+
] : [],
|
|
74
|
+
style: {
|
|
75
|
+
marginBottom
|
|
76
|
+
},
|
|
77
|
+
colon: false,
|
|
78
|
+
children: /*#__PURE__*/ jsx(Select, {
|
|
79
|
+
placeholder: customPlaceholder || `Select ${name}`,
|
|
80
|
+
options: selectOptions
|
|
81
|
+
})
|
|
82
|
+
}, name);
|
|
83
|
+
};
|
|
84
|
+
const NumberField = (param)=>{
|
|
85
|
+
let { name, label, isRequired, marginBottom, placeholder: customPlaceholder } = param;
|
|
86
|
+
const defaultPlaceholder = 'distance' === name ? 500 : 0;
|
|
87
|
+
const placeholderValue = customPlaceholder ? Number(customPlaceholder) || defaultPlaceholder : defaultPlaceholder;
|
|
88
|
+
const min = 0;
|
|
89
|
+
const max = 'distance' === name ? 10000 : void 0;
|
|
90
|
+
return /*#__PURE__*/ jsx(Form.Item, {
|
|
91
|
+
name: [
|
|
92
|
+
'params',
|
|
93
|
+
name
|
|
94
|
+
],
|
|
95
|
+
label: `${label}${'distance' === name ? ' (px)' : ''}`,
|
|
96
|
+
rules: isRequired ? [
|
|
97
|
+
{
|
|
98
|
+
required: true,
|
|
99
|
+
message: `Please input ${name}`
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: 'number',
|
|
103
|
+
min,
|
|
104
|
+
message: `${label} must be at least ${min}`
|
|
105
|
+
}
|
|
106
|
+
] : [
|
|
107
|
+
{
|
|
108
|
+
type: 'number',
|
|
109
|
+
min,
|
|
110
|
+
message: `${label} must be at least ${min}`
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
style: {
|
|
114
|
+
flex: 'distance' === name ? 1 : void 0,
|
|
115
|
+
marginBottom
|
|
116
|
+
},
|
|
117
|
+
colon: false,
|
|
118
|
+
children: /*#__PURE__*/ jsx(InputNumber, {
|
|
119
|
+
placeholder: placeholderValue.toString(),
|
|
120
|
+
min: min,
|
|
121
|
+
max: max,
|
|
122
|
+
step: 'distance' === name ? 10 : 1,
|
|
123
|
+
style: {
|
|
124
|
+
width: '100%'
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
}, name);
|
|
128
|
+
};
|
|
129
|
+
const BooleanField = (param)=>{
|
|
130
|
+
let { name, label, isRequired, marginBottom, placeholder: customPlaceholder } = param;
|
|
131
|
+
const selectOptions = [
|
|
132
|
+
{
|
|
133
|
+
value: true,
|
|
134
|
+
label: 'True'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
value: false,
|
|
138
|
+
label: 'False'
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
return /*#__PURE__*/ jsx(Form.Item, {
|
|
142
|
+
name: [
|
|
143
|
+
'params',
|
|
144
|
+
name
|
|
145
|
+
],
|
|
146
|
+
label: renderLabel(label, !isRequired),
|
|
147
|
+
rules: isRequired ? [
|
|
148
|
+
{
|
|
149
|
+
required: true,
|
|
150
|
+
message: `Please select ${name}`
|
|
151
|
+
}
|
|
152
|
+
] : [],
|
|
153
|
+
style: {
|
|
154
|
+
marginBottom
|
|
155
|
+
},
|
|
156
|
+
colon: false,
|
|
157
|
+
children: /*#__PURE__*/ jsx(Select, {
|
|
158
|
+
placeholder: customPlaceholder || `Select ${name}`,
|
|
159
|
+
options: selectOptions
|
|
160
|
+
})
|
|
161
|
+
}, name);
|
|
162
|
+
};
|
|
163
|
+
export { BooleanField, EnumField, LocateField, NumberField, TextField };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
.history-selector-wrapper {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.history-modal-overlay {
|
|
6
|
+
z-index: 9999;
|
|
7
|
+
background: #fff;
|
|
8
|
+
border: 1px solid rgba(0, 0, 0, .08);
|
|
9
|
+
border-radius: 12px;
|
|
10
|
+
width: 320px;
|
|
11
|
+
height: 400px;
|
|
12
|
+
position: fixed;
|
|
13
|
+
top: auto;
|
|
14
|
+
bottom: 20px;
|
|
15
|
+
right: 20px;
|
|
16
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.history-modal-container {
|
|
20
|
+
border-radius: 12px;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
display: flex;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.history-modal-container .history-modal-header {
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
align-items: center;
|
|
31
|
+
height: 48px;
|
|
32
|
+
padding: 0 25px;
|
|
33
|
+
line-height: 48px;
|
|
34
|
+
display: flex;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.history-modal-container .history-modal-header .close-button {
|
|
38
|
+
justify-content: center;
|
|
39
|
+
align-items: center;
|
|
40
|
+
margin-right: -4px;
|
|
41
|
+
padding: 4px;
|
|
42
|
+
display: flex;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.history-modal-container .history-modal-header .close-button .anticon {
|
|
46
|
+
color: #999;
|
|
47
|
+
font-size: 18px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.history-modal-container .history-modal-header .close-button:hover .anticon {
|
|
51
|
+
color: #666;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.history-modal-container .history-search-section {
|
|
55
|
+
background: #fff;
|
|
56
|
+
padding: 16px 20px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.history-modal-container .history-search-section .search-input-wrapper {
|
|
60
|
+
color: rgba(0, 0, 0, .25);
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: 12px;
|
|
63
|
+
display: flex;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.history-modal-container .history-search-section .search-input-wrapper .search-input {
|
|
67
|
+
background: #f1f2f3;
|
|
68
|
+
border: none;
|
|
69
|
+
border-radius: 16px;
|
|
70
|
+
flex: 1;
|
|
71
|
+
height: 36px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.history-modal-container .history-search-section .search-input-wrapper .search-input .ant-input {
|
|
75
|
+
box-shadow: none;
|
|
76
|
+
background: none;
|
|
77
|
+
border: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.history-modal-container .history-search-section .search-input-wrapper .search-input:hover, .history-modal-container .history-search-section .search-input-wrapper .search-input:focus-within {
|
|
81
|
+
background: #fff;
|
|
82
|
+
border-color: #d9d9d9;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.history-modal-container .history-search-section .search-input-wrapper .clear-button {
|
|
86
|
+
color: #1890ff;
|
|
87
|
+
height: auto;
|
|
88
|
+
padding: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.history-modal-container .history-search-section .search-input-wrapper .clear-button:hover {
|
|
92
|
+
color: #40a9ff;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.history-modal-container .history-content {
|
|
96
|
+
flex: 1;
|
|
97
|
+
padding: 0 25px 25px;
|
|
98
|
+
overflow-y: auto;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.history-modal-container .history-content .history-group {
|
|
102
|
+
margin-bottom: 10px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.history-modal-container .history-content .history-group .history-group-title {
|
|
106
|
+
color: rgba(0, 0, 0, .45);
|
|
107
|
+
height: 40px;
|
|
108
|
+
font-size: 12px;
|
|
109
|
+
font-weight: 400;
|
|
110
|
+
line-height: 40px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.history-modal-container .history-content .history-group .history-item {
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
color: rgba(0, 0, 0, .85);
|
|
116
|
+
white-space: nowrap;
|
|
117
|
+
text-overflow: ellipsis;
|
|
118
|
+
height: 40px;
|
|
119
|
+
font-size: 14px;
|
|
120
|
+
line-height: 40px;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.history-modal-container .history-content .history-group .history-item:hover {
|
|
125
|
+
background: #f2f4f7;
|
|
126
|
+
margin: 0 -8px;
|
|
127
|
+
padding: 0 8px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.history-modal-container .history-content .no-results {
|
|
131
|
+
text-align: center;
|
|
132
|
+
color: #999;
|
|
133
|
+
padding: 40px 20px;
|
|
134
|
+
}
|
|
135
|
+
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Input, Typography } from "antd";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import icons_close from "../../icons/close.mjs";
|
|
5
|
+
import icons_history from "../../icons/history.mjs";
|
|
6
|
+
import magnifying_glass from "../../icons/magnifying-glass.mjs";
|
|
7
|
+
import { useHistoryStore } from "../../store/history.mjs";
|
|
8
|
+
import "./index.css";
|
|
9
|
+
const { Text } = Typography;
|
|
10
|
+
const HistorySelector = (param)=>{
|
|
11
|
+
let { onSelect, history, currentType } = param;
|
|
12
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
13
|
+
const [searchText, setSearchText] = useState('');
|
|
14
|
+
const clearHistory = useHistoryStore((state)=>state.clearHistory);
|
|
15
|
+
const modalRef = useRef(null);
|
|
16
|
+
const groupedHistory = useMemo(()=>{
|
|
17
|
+
const now = Date.now();
|
|
18
|
+
const sevenDaysAgo = now - 604800000;
|
|
19
|
+
const oneYearAgo = now - 31536000000;
|
|
20
|
+
const filteredHistory = history.filter((item)=>item.prompt.toLowerCase().includes(searchText.toLowerCase()));
|
|
21
|
+
const groups = {
|
|
22
|
+
recent7Days: filteredHistory.filter((item)=>item.timestamp >= sevenDaysAgo),
|
|
23
|
+
recent1Year: filteredHistory.filter((item)=>item.timestamp < sevenDaysAgo && item.timestamp >= oneYearAgo),
|
|
24
|
+
older: filteredHistory.filter((item)=>item.timestamp < oneYearAgo)
|
|
25
|
+
};
|
|
26
|
+
return groups;
|
|
27
|
+
}, [
|
|
28
|
+
history,
|
|
29
|
+
searchText
|
|
30
|
+
]);
|
|
31
|
+
const handleHistoryClick = (item)=>{
|
|
32
|
+
onSelect(item);
|
|
33
|
+
setIsModalOpen(false);
|
|
34
|
+
};
|
|
35
|
+
const handleClearHistory = ()=>{
|
|
36
|
+
clearHistory(currentType);
|
|
37
|
+
setSearchText('');
|
|
38
|
+
setIsModalOpen(false);
|
|
39
|
+
};
|
|
40
|
+
useEffect(()=>{
|
|
41
|
+
if (!isModalOpen) return;
|
|
42
|
+
const handleClickOutside = (event)=>{
|
|
43
|
+
if (modalRef.current && !modalRef.current.contains(event.target)) setIsModalOpen(false);
|
|
44
|
+
};
|
|
45
|
+
const timer = setTimeout(()=>{
|
|
46
|
+
document.addEventListener('click', handleClickOutside);
|
|
47
|
+
}, 100);
|
|
48
|
+
return ()=>{
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
document.removeEventListener('click', handleClickOutside);
|
|
51
|
+
};
|
|
52
|
+
}, [
|
|
53
|
+
isModalOpen
|
|
54
|
+
]);
|
|
55
|
+
const renderHistoryGroup = (title, items)=>{
|
|
56
|
+
if (0 === items.length) return null;
|
|
57
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
58
|
+
className: "history-group",
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ jsx("div", {
|
|
61
|
+
className: "history-group-title",
|
|
62
|
+
children: title
|
|
63
|
+
}),
|
|
64
|
+
items.map((item, index)=>/*#__PURE__*/ jsx("div", {
|
|
65
|
+
className: "history-item",
|
|
66
|
+
onClick: ()=>handleHistoryClick(item),
|
|
67
|
+
children: item.prompt
|
|
68
|
+
}, `${item.timestamp}-${index}`))
|
|
69
|
+
]
|
|
70
|
+
}, title);
|
|
71
|
+
};
|
|
72
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
73
|
+
className: "history-selector-wrapper",
|
|
74
|
+
children: [
|
|
75
|
+
/*#__PURE__*/ jsx("div", {
|
|
76
|
+
className: "selector-trigger",
|
|
77
|
+
onClick: ()=>setIsModalOpen(true),
|
|
78
|
+
children: /*#__PURE__*/ jsx(icons_history, {
|
|
79
|
+
width: 24,
|
|
80
|
+
height: 24
|
|
81
|
+
})
|
|
82
|
+
}),
|
|
83
|
+
isModalOpen && /*#__PURE__*/ jsx("div", {
|
|
84
|
+
className: "history-modal-overlay",
|
|
85
|
+
ref: modalRef,
|
|
86
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
87
|
+
className: "history-modal-container",
|
|
88
|
+
children: [
|
|
89
|
+
/*#__PURE__*/ jsxs("div", {
|
|
90
|
+
className: "history-modal-header",
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ jsxs(Text, {
|
|
93
|
+
strong: true,
|
|
94
|
+
style: {
|
|
95
|
+
fontSize: '16px'
|
|
96
|
+
},
|
|
97
|
+
children: [
|
|
98
|
+
"History (",
|
|
99
|
+
history.length,
|
|
100
|
+
")"
|
|
101
|
+
]
|
|
102
|
+
}),
|
|
103
|
+
/*#__PURE__*/ jsx(Button, {
|
|
104
|
+
size: "small",
|
|
105
|
+
type: "text",
|
|
106
|
+
icon: /*#__PURE__*/ jsx(icons_close, {
|
|
107
|
+
width: 16,
|
|
108
|
+
height: 16
|
|
109
|
+
}),
|
|
110
|
+
onClick: ()=>setIsModalOpen(false),
|
|
111
|
+
className: "close-button"
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ jsx("div", {
|
|
116
|
+
className: "history-search-section",
|
|
117
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
118
|
+
className: "search-input-wrapper",
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ jsx(Input, {
|
|
121
|
+
placeholder: "Search",
|
|
122
|
+
value: searchText,
|
|
123
|
+
onChange: (e)=>setSearchText(e.target.value),
|
|
124
|
+
prefix: /*#__PURE__*/ jsx(magnifying_glass, {
|
|
125
|
+
width: 18,
|
|
126
|
+
height: 18
|
|
127
|
+
}),
|
|
128
|
+
className: "search-input",
|
|
129
|
+
allowClear: true
|
|
130
|
+
}),
|
|
131
|
+
/*#__PURE__*/ jsx(Button, {
|
|
132
|
+
type: "link",
|
|
133
|
+
onClick: handleClearHistory,
|
|
134
|
+
className: "clear-button",
|
|
135
|
+
disabled: 0 === history.length,
|
|
136
|
+
children: "Clear"
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ jsx("div", {
|
|
142
|
+
className: "history-content",
|
|
143
|
+
children: 0 === history.length ? /*#__PURE__*/ jsx("div", {
|
|
144
|
+
className: "no-results",
|
|
145
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
146
|
+
type: "secondary",
|
|
147
|
+
children: "No history record"
|
|
148
|
+
})
|
|
149
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
150
|
+
children: [
|
|
151
|
+
renderHistoryGroup('Last 7 days', groupedHistory.recent7Days),
|
|
152
|
+
renderHistoryGroup('Last 1 year', groupedHistory.recent1Year),
|
|
153
|
+
renderHistoryGroup('Earlier', groupedHistory.older),
|
|
154
|
+
searchText && 0 === groupedHistory.recent7Days.length && 0 === groupedHistory.recent1Year.length && 0 === groupedHistory.older.length && /*#__PURE__*/ jsx("div", {
|
|
155
|
+
className: "no-results",
|
|
156
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
157
|
+
type: "secondary",
|
|
158
|
+
children: "No matching history record"
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
export { HistorySelector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../types.mjs";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "./index.css";
|
|
3
|
+
const LogoUrl = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/vhaeh7vhabf/Midscene.png';
|
|
4
|
+
const Logo = (param)=>{
|
|
5
|
+
let { hideLogo = false } = param;
|
|
6
|
+
if (hideLogo) return null;
|
|
7
|
+
return /*#__PURE__*/ jsx("div", {
|
|
8
|
+
className: "logo",
|
|
9
|
+
children: /*#__PURE__*/ jsx("a", {
|
|
10
|
+
href: "https://midscenejs.com/",
|
|
11
|
+
target: "_blank",
|
|
12
|
+
rel: "noreferrer",
|
|
13
|
+
children: /*#__PURE__*/ jsx("img", {
|
|
14
|
+
alt: "Midscene_logo",
|
|
15
|
+
src: "https://lf3-static.bytednsdoc.com/obj/eden-cn/vhaeh7vhabf/Midscene.png"
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export { Logo, LogoUrl };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowRightOutlined, CheckOutlined, ClockCircleOutlined, CloseOutlined, LogoutOutlined, MinusOutlined, WarningOutlined } from "@ant-design/icons";
|
|
3
|
+
import { Alert } from "antd";
|
|
4
|
+
import shiny_text from "../shiny-text/index.mjs";
|
|
5
|
+
function timeCostStrElement(timeCost) {
|
|
6
|
+
let str;
|
|
7
|
+
str = 'number' != typeof timeCost ? '-' : `${(timeCost / 1000).toFixed(2)}s`;
|
|
8
|
+
return /*#__PURE__*/ jsx("span", {
|
|
9
|
+
style: {
|
|
10
|
+
fontVariantNumeric: 'tabular-nums',
|
|
11
|
+
fontFeatureSettings: 'tnum'
|
|
12
|
+
},
|
|
13
|
+
children: str
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const iconForStatus = (status)=>{
|
|
17
|
+
switch(status){
|
|
18
|
+
case 'finished':
|
|
19
|
+
case 'passed':
|
|
20
|
+
case 'success':
|
|
21
|
+
case 'connected':
|
|
22
|
+
return /*#__PURE__*/ jsx("span", {
|
|
23
|
+
style: {
|
|
24
|
+
color: '#00AD4B'
|
|
25
|
+
},
|
|
26
|
+
children: /*#__PURE__*/ jsx(CheckOutlined, {})
|
|
27
|
+
});
|
|
28
|
+
case 'finishedWithWarning':
|
|
29
|
+
return /*#__PURE__*/ jsx("span", {
|
|
30
|
+
style: {
|
|
31
|
+
color: '#f7bb05'
|
|
32
|
+
},
|
|
33
|
+
children: /*#__PURE__*/ jsx(WarningOutlined, {})
|
|
34
|
+
});
|
|
35
|
+
case 'failed':
|
|
36
|
+
case 'closed':
|
|
37
|
+
case 'timedOut':
|
|
38
|
+
case 'interrupted':
|
|
39
|
+
return /*#__PURE__*/ jsx("span", {
|
|
40
|
+
style: {
|
|
41
|
+
color: '#FF0A0A'
|
|
42
|
+
},
|
|
43
|
+
children: /*#__PURE__*/ jsx(CloseOutlined, {})
|
|
44
|
+
});
|
|
45
|
+
case 'pending':
|
|
46
|
+
return /*#__PURE__*/ jsx(ClockCircleOutlined, {});
|
|
47
|
+
case 'cancelled':
|
|
48
|
+
case 'skipped':
|
|
49
|
+
return /*#__PURE__*/ jsx(LogoutOutlined, {});
|
|
50
|
+
case 'running':
|
|
51
|
+
return /*#__PURE__*/ jsx(ArrowRightOutlined, {});
|
|
52
|
+
default:
|
|
53
|
+
return /*#__PURE__*/ jsx(MinusOutlined, {});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const errorMessageServerNotReady = /*#__PURE__*/ jsxs("span", {
|
|
57
|
+
children: [
|
|
58
|
+
"Don't worry, just one more step to launch the playground server.",
|
|
59
|
+
/*#__PURE__*/ jsx("br", {}),
|
|
60
|
+
"Please run one of the commands under the midscene project directory:",
|
|
61
|
+
/*#__PURE__*/ jsx("br", {}),
|
|
62
|
+
"a. ",
|
|
63
|
+
/*#__PURE__*/ jsx("strong", {
|
|
64
|
+
children: "npx midscene-playground"
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ jsx("br", {}),
|
|
67
|
+
"b. ",
|
|
68
|
+
/*#__PURE__*/ jsx("strong", {
|
|
69
|
+
children: "npx --yes @sqaitech/web"
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
const serverLaunchTip = function() {
|
|
74
|
+
let notReadyMessage = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : errorMessageServerNotReady;
|
|
75
|
+
return /*#__PURE__*/ jsx("div", {
|
|
76
|
+
className: "server-tip",
|
|
77
|
+
children: /*#__PURE__*/ jsx(Alert, {
|
|
78
|
+
message: "Playground Server Not Ready",
|
|
79
|
+
description: notReadyMessage,
|
|
80
|
+
type: "warning"
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const emptyResultTip = /*#__PURE__*/ jsx("div", {
|
|
85
|
+
className: "result-empty-tip",
|
|
86
|
+
style: {
|
|
87
|
+
textAlign: 'center'
|
|
88
|
+
},
|
|
89
|
+
children: /*#__PURE__*/ jsx(shiny_text, {
|
|
90
|
+
disabled: true,
|
|
91
|
+
text: "The result will be shown here"
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
export { emptyResultTip, errorMessageServerNotReady, iconForStatus, serverLaunchTip, timeCostStrElement };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GithubOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
3
|
+
import { Typography } from "antd";
|
|
4
|
+
import { EnvConfig } from "../env-config/index.mjs";
|
|
5
|
+
import "./style.css";
|
|
6
|
+
function NavActions(param) {
|
|
7
|
+
let { showEnvConfig = true, showTooltipWhenEmpty = false, showModelName = false, githubUrl = 'https://github.com/web-infra-dev/midscene', helpUrl = 'https://midscenejs.com/quick-experience.html', className = '' } = param;
|
|
8
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
9
|
+
className: `nav-actions ${className}`,
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsx(Typography.Link, {
|
|
12
|
+
href: githubUrl,
|
|
13
|
+
target: "_blank",
|
|
14
|
+
children: /*#__PURE__*/ jsx(GithubOutlined, {
|
|
15
|
+
className: "nav-icon"
|
|
16
|
+
})
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ jsx(Typography.Link, {
|
|
19
|
+
href: helpUrl,
|
|
20
|
+
target: "_blank",
|
|
21
|
+
children: /*#__PURE__*/ jsx(QuestionCircleOutlined, {
|
|
22
|
+
className: "nav-icon"
|
|
23
|
+
})
|
|
24
|
+
}),
|
|
25
|
+
showEnvConfig && /*#__PURE__*/ jsx(EnvConfig, {
|
|
26
|
+
showTooltipWhenEmpty: showTooltipWhenEmpty,
|
|
27
|
+
showModelName: showModelName
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export { NavActions };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.nav-actions {
|
|
2
|
+
align-items: center;
|
|
3
|
+
gap: 8px;
|
|
4
|
+
display: flex;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.nav-actions .nav-icon {
|
|
8
|
+
color: rgba(0, 0, 0, .65);
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
font-size: 16px;
|
|
11
|
+
transition: color .3s;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.nav-actions .nav-icon:hover {
|
|
15
|
+
color: #2b83ff;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.nav-actions a {
|
|
19
|
+
align-items: center;
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
display: flex;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.nav-actions a:hover .nav-icon {
|
|
25
|
+
color: #2b83ff;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[data-theme="dark"] .nav-actions .nav-icon {
|
|
29
|
+
color: rgba(255, 255, 255, .65);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-theme="dark"] .nav-actions .nav-icon:hover {
|
|
33
|
+
color: #2b83ff;
|
|
34
|
+
}
|
|
35
|
+
|