@midscene/visualizer 0.28.9 → 0.28.10-beta-20250917142241.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/component/history-selector/index.css +17 -15
- package/dist/es/component/history-selector/index.mjs +20 -4
- 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 +2 -2
- package/dist/es/component/playground/index.css +22 -6
- package/dist/es/component/prompt-input/index.css +22 -6
- package/dist/es/component/prompt-input/index.mjs +39 -7
- package/dist/es/component/universal-playground/index.css +2 -2
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +68 -4
- package/dist/es/hooks/usePlaygroundState.mjs +2 -1
- package/dist/es/index.mjs +2 -2
- package/dist/lib/component/history-selector/index.css +17 -15
- package/dist/lib/component/history-selector/index.js +19 -3
- 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 +2 -2
- package/dist/lib/component/playground/index.css +22 -6
- package/dist/lib/component/prompt-input/index.css +22 -6
- package/dist/lib/component/prompt-input/index.js +38 -6
- package/dist/lib/component/universal-playground/index.css +2 -2
- package/dist/lib/component/universal-playground/providers/storage-provider.js +68 -4
- package/dist/lib/hooks/usePlaygroundState.js +2 -1
- package/dist/lib/index.js +4 -4
- package/dist/types/component/nav-actions/index.d.ts +10 -0
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +9 -0
- package/dist/types/index.d.ts +2 -1
- package/package.json +6 -6
- package/dist/es/component/github-star/index.css +0 -4
- package/dist/es/component/github-star/index.mjs +0 -20
- package/dist/lib/component/github-star/index.css +0 -4
- package/dist/lib/component/github-star/index.js +0 -54
- package/dist/types/component/github-star/index.d.ts +0 -2
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
NavActions: ()=>NavActions
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const icons_namespaceObject = require("@ant-design/icons");
|
|
31
|
+
const external_antd_namespaceObject = require("antd");
|
|
32
|
+
const index_js_namespaceObject = require("../env-config/index.js");
|
|
33
|
+
require("./style.css");
|
|
34
|
+
function NavActions(param) {
|
|
35
|
+
let { showEnvConfig = true, showTooltipWhenEmpty = false, showModelName = false, githubUrl = 'https://github.com/web-infra-dev/midscene', helpUrl = 'https://midscenejs.com/quick-experience.html', className = '' } = param;
|
|
36
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
37
|
+
className: `nav-actions ${className}`,
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Link, {
|
|
40
|
+
href: githubUrl,
|
|
41
|
+
target: "_blank",
|
|
42
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.GithubOutlined, {
|
|
43
|
+
className: "nav-icon"
|
|
44
|
+
})
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Link, {
|
|
47
|
+
href: helpUrl,
|
|
48
|
+
target: "_blank",
|
|
49
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.QuestionCircleOutlined, {
|
|
50
|
+
className: "nav-icon"
|
|
51
|
+
})
|
|
52
|
+
}),
|
|
53
|
+
showEnvConfig && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.EnvConfig, {
|
|
54
|
+
showTooltipWhenEmpty: showTooltipWhenEmpty,
|
|
55
|
+
showModelName: showModelName
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
exports.NavActions = __webpack_exports__.NavActions;
|
|
61
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
62
|
+
"NavActions"
|
|
63
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
64
|
+
Object.defineProperty(exports, '__esModule', {
|
|
65
|
+
value: true
|
|
66
|
+
});
|
|
@@ -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
|
+
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
min-height: 200px;
|
|
31
31
|
aspect-ratio: var(--canvas-aspect-ratio, 16 / 9);
|
|
32
32
|
background-color: #fff;
|
|
33
|
-
border-top-left-radius:
|
|
34
|
-
border-top-right-radius:
|
|
33
|
+
border-top-left-radius: 4px;
|
|
34
|
+
border-top-right-radius: 4px;
|
|
35
35
|
flex: none;
|
|
36
36
|
justify-content: center;
|
|
37
37
|
align-items: center;
|
|
@@ -44,21 +44,34 @@
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group {
|
|
47
|
-
scrollbar-width:
|
|
48
|
-
-ms-overflow-style: none;
|
|
47
|
+
scrollbar-width: thin;
|
|
49
48
|
flex: 1;
|
|
50
49
|
align-items: center;
|
|
51
50
|
gap: 8px;
|
|
52
51
|
min-width: 0;
|
|
53
52
|
height: 100%;
|
|
54
|
-
margin-right:
|
|
53
|
+
margin-right: 60px;
|
|
55
54
|
display: flex;
|
|
56
55
|
overflow-x: auto;
|
|
57
56
|
overflow-y: hidden;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar {
|
|
61
|
-
|
|
60
|
+
height: 6px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar-track {
|
|
64
|
+
background: #f1f1f1;
|
|
65
|
+
border-radius: 3px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar-thumb {
|
|
69
|
+
background: #c1c1c1;
|
|
70
|
+
border-radius: 3px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar-thumb:hover {
|
|
74
|
+
background: #a8a8a8;
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-form-item {
|
|
@@ -146,10 +159,13 @@
|
|
|
146
159
|
|
|
147
160
|
.prompt-input-wrapper .mode-radio-group-wrapper .action-icons {
|
|
148
161
|
z-index: 10;
|
|
149
|
-
background: #fff;
|
|
162
|
+
background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(255, 255, 255, .5) 20%, rgba(255, 255, 255, .8) 40%, rgba(255, 255, 255, .95) 60%, #fff 70%);
|
|
150
163
|
flex-shrink: 0;
|
|
164
|
+
justify-content: flex-end;
|
|
151
165
|
align-items: center;
|
|
152
|
-
|
|
166
|
+
gap: 8px;
|
|
167
|
+
width: 80px;
|
|
168
|
+
padding-left: 20px;
|
|
153
169
|
display: flex;
|
|
154
170
|
position: absolute;
|
|
155
171
|
top: 50%;
|
|
@@ -10,21 +10,34 @@
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group {
|
|
13
|
-
scrollbar-width:
|
|
14
|
-
-ms-overflow-style: none;
|
|
13
|
+
scrollbar-width: thin;
|
|
15
14
|
flex: 1;
|
|
16
15
|
align-items: center;
|
|
17
16
|
gap: 8px;
|
|
18
17
|
min-width: 0;
|
|
19
18
|
height: 100%;
|
|
20
|
-
margin-right:
|
|
19
|
+
margin-right: 60px;
|
|
21
20
|
display: flex;
|
|
22
21
|
overflow-x: auto;
|
|
23
22
|
overflow-y: hidden;
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar {
|
|
27
|
-
|
|
26
|
+
height: 6px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar-track {
|
|
30
|
+
background: #f1f1f1;
|
|
31
|
+
border-radius: 3px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar-thumb {
|
|
35
|
+
background: #c1c1c1;
|
|
36
|
+
border-radius: 3px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group::-webkit-scrollbar-thumb:hover {
|
|
40
|
+
background: #a8a8a8;
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
.prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-form-item {
|
|
@@ -112,10 +125,13 @@
|
|
|
112
125
|
|
|
113
126
|
.prompt-input-wrapper .mode-radio-group-wrapper .action-icons {
|
|
114
127
|
z-index: 10;
|
|
115
|
-
background: #fff;
|
|
128
|
+
background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(255, 255, 255, .5) 20%, rgba(255, 255, 255, .8) 40%, rgba(255, 255, 255, .95) 60%, #fff 70%);
|
|
116
129
|
flex-shrink: 0;
|
|
130
|
+
justify-content: flex-end;
|
|
117
131
|
align-items: center;
|
|
118
|
-
|
|
132
|
+
gap: 8px;
|
|
133
|
+
width: 80px;
|
|
134
|
+
padding-left: 20px;
|
|
119
135
|
display: flex;
|
|
120
136
|
position: absolute;
|
|
121
137
|
top: 50%;
|
|
@@ -55,6 +55,7 @@ const PromptInput = (param)=>{
|
|
|
55
55
|
const [promptValue, setPromptValue] = (0, external_react_namespaceObject.useState)('');
|
|
56
56
|
const placeholder = (0, playground_utils_js_namespaceObject.getPlaceholderForType)(selectedType);
|
|
57
57
|
const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
|
|
58
|
+
const modeRadioGroupRef = (0, external_react_namespaceObject.useRef)(null);
|
|
58
59
|
const params = external_antd_namespaceObject.Form.useWatch('params', form);
|
|
59
60
|
const lastHistoryRef = (0, external_react_namespaceObject.useRef)(null);
|
|
60
61
|
const history = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.history);
|
|
@@ -198,6 +199,27 @@ const PromptInput = (param)=>{
|
|
|
198
199
|
lastSelectedType,
|
|
199
200
|
setLastSelectedType
|
|
200
201
|
]);
|
|
202
|
+
const scrollToSelectedItem = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
203
|
+
const container = modeRadioGroupRef.current;
|
|
204
|
+
if (!container) return;
|
|
205
|
+
let targetElement = null;
|
|
206
|
+
const selectedRadioButton = container.querySelector('.ant-radio-button-wrapper-checked');
|
|
207
|
+
const dropdownButton = container.querySelector('.more-apis-button.selected-from-dropdown');
|
|
208
|
+
if (selectedRadioButton) targetElement = selectedRadioButton;
|
|
209
|
+
else if (dropdownButton) targetElement = dropdownButton;
|
|
210
|
+
if (targetElement) {
|
|
211
|
+
const containerRect = container.getBoundingClientRect();
|
|
212
|
+
const targetRect = targetElement.getBoundingClientRect();
|
|
213
|
+
const targetLeft = targetRect.left - containerRect.left + container.scrollLeft;
|
|
214
|
+
const targetWidth = targetRect.width;
|
|
215
|
+
const containerWidth = containerRect.width;
|
|
216
|
+
const optimalScrollLeft = targetLeft - (containerWidth - targetWidth) / 2;
|
|
217
|
+
container.scrollTo({
|
|
218
|
+
left: Math.max(0, optimalScrollLeft),
|
|
219
|
+
behavior: 'smooth'
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}, []);
|
|
201
223
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
202
224
|
const lastHistory = historyForSelectedType[0];
|
|
203
225
|
if (lastHistory && lastHistoryRef.current && lastHistory.timestamp === lastHistoryRef.current.timestamp) return;
|
|
@@ -224,6 +246,15 @@ const PromptInput = (param)=>{
|
|
|
224
246
|
form,
|
|
225
247
|
getDefaultParams
|
|
226
248
|
]);
|
|
249
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
250
|
+
const timeoutId = setTimeout(()=>{
|
|
251
|
+
scrollToSelectedItem();
|
|
252
|
+
}, 100);
|
|
253
|
+
return ()=>clearTimeout(timeoutId);
|
|
254
|
+
}, [
|
|
255
|
+
selectedType,
|
|
256
|
+
scrollToSelectedItem
|
|
257
|
+
]);
|
|
227
258
|
const formPromptValue = external_antd_namespaceObject.Form.useWatch('prompt', form);
|
|
228
259
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
229
260
|
if (formPromptValue !== promptValue) setPromptValue(formPromptValue || '');
|
|
@@ -539,11 +570,12 @@ const PromptInput = (param)=>{
|
|
|
539
570
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
540
571
|
className: "prompt-input-wrapper",
|
|
541
572
|
children: [
|
|
542
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(
|
|
573
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
543
574
|
className: "mode-radio-group-wrapper",
|
|
544
575
|
children: [
|
|
545
576
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
546
577
|
className: "mode-radio-group",
|
|
578
|
+
ref: modeRadioGroupRef,
|
|
547
579
|
children: [
|
|
548
580
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
|
|
549
581
|
name: "type",
|
|
@@ -670,11 +702,6 @@ const PromptInput = (param)=>{
|
|
|
670
702
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
671
703
|
className: "action-icons",
|
|
672
704
|
children: [
|
|
673
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_history_selector_index_js_namespaceObject.HistorySelector, {
|
|
674
|
-
onSelect: handleSelectHistory,
|
|
675
|
-
history: historyForSelectedType,
|
|
676
|
-
currentType: selectedType
|
|
677
|
-
}),
|
|
678
705
|
hasConfigOptions && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
679
706
|
className: hoveringSettings ? 'settings-wrapper settings-wrapper-hover' : 'settings-wrapper',
|
|
680
707
|
onMouseEnter: handleMouseEnter,
|
|
@@ -685,6 +712,11 @@ const PromptInput = (param)=>{
|
|
|
685
712
|
showDataExtractionOptions: showDataExtractionOptions,
|
|
686
713
|
hideDomAndScreenshotOptions: hideDomAndScreenshotOptions
|
|
687
714
|
})
|
|
715
|
+
}),
|
|
716
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_history_selector_index_js_namespaceObject.HistorySelector, {
|
|
717
|
+
onSelect: handleSelectHistory,
|
|
718
|
+
history: historyForSelectedType,
|
|
719
|
+
currentType: selectedType
|
|
688
720
|
})
|
|
689
721
|
]
|
|
690
722
|
})
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
.playground-container .middle-dialog-area .clear-button-container {
|
|
33
33
|
z-index: 10;
|
|
34
34
|
position: absolute;
|
|
35
|
-
top:
|
|
36
|
-
right:
|
|
35
|
+
top: 16px;
|
|
36
|
+
right: 0;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
.playground-container .middle-dialog-area .clear-button-container .clear-button {
|
|
@@ -39,15 +39,48 @@ function _define_property(obj, key, value) {
|
|
|
39
39
|
return obj;
|
|
40
40
|
}
|
|
41
41
|
class LocalStorageProvider {
|
|
42
|
+
checkStorageSpace() {
|
|
43
|
+
try {
|
|
44
|
+
const testKey = 'storage-test';
|
|
45
|
+
const testData = 'x'.repeat(102400);
|
|
46
|
+
localStorage.setItem(testKey, testData);
|
|
47
|
+
localStorage.removeItem(testKey);
|
|
48
|
+
return true;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
42
53
|
async saveMessages(messages) {
|
|
43
54
|
try {
|
|
44
|
-
|
|
55
|
+
if (!this.checkStorageSpace()) {
|
|
56
|
+
console.warn('Low storage space detected, clearing old data...');
|
|
57
|
+
await this.handleQuotaExceeded();
|
|
58
|
+
}
|
|
59
|
+
const messagesToSave = messages.slice(-this.maxStorageItems);
|
|
60
|
+
const lightMessages = messagesToSave.map((msg)=>({
|
|
45
61
|
...msg,
|
|
46
62
|
result: void 0
|
|
47
63
|
}));
|
|
48
|
-
|
|
64
|
+
const messageData = JSON.stringify(lightMessages);
|
|
65
|
+
localStorage.setItem(this.messagesKey, messageData);
|
|
49
66
|
} catch (error) {
|
|
50
|
-
|
|
67
|
+
if (error instanceof DOMException && 'QuotaExceededError' === error.name) {
|
|
68
|
+
console.warn('LocalStorage quota exceeded, attempting to clear old data and retry...');
|
|
69
|
+
await this.handleQuotaExceeded();
|
|
70
|
+
try {
|
|
71
|
+
const recentMessages = messages.slice(-10);
|
|
72
|
+
const lightRecentMessages = recentMessages.map((msg)=>({
|
|
73
|
+
...msg,
|
|
74
|
+
result: void 0
|
|
75
|
+
}));
|
|
76
|
+
const messageData = JSON.stringify(lightRecentMessages);
|
|
77
|
+
localStorage.setItem(this.messagesKey, messageData);
|
|
78
|
+
console.info('Successfully saved recent messages after clearing storage');
|
|
79
|
+
} catch (retryError) {
|
|
80
|
+
console.error('Failed to save even after clearing storage:', retryError);
|
|
81
|
+
await this.clearMessages();
|
|
82
|
+
}
|
|
83
|
+
} else console.error('Failed to save messages to localStorage:', error);
|
|
51
84
|
}
|
|
52
85
|
}
|
|
53
86
|
async loadMessages() {
|
|
@@ -93,12 +126,43 @@ class LocalStorageProvider {
|
|
|
93
126
|
const resultKey = `${this.resultsKey}-${id}`;
|
|
94
127
|
localStorage.setItem(resultKey, JSON.stringify(result));
|
|
95
128
|
} catch (error) {
|
|
96
|
-
|
|
129
|
+
if (error instanceof DOMException && 'QuotaExceededError' === error.name) {
|
|
130
|
+
console.warn('LocalStorage quota exceeded when saving result, clearing old results...');
|
|
131
|
+
await this.handleQuotaExceeded();
|
|
132
|
+
try {
|
|
133
|
+
const resultKey = `${this.resultsKey}-${id}`;
|
|
134
|
+
localStorage.setItem(resultKey, JSON.stringify(result));
|
|
135
|
+
} catch (retryError) {
|
|
136
|
+
console.error('Failed to save result even after clearing storage:', retryError);
|
|
137
|
+
}
|
|
138
|
+
} else console.error('Failed to save result to localStorage:', error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async handleQuotaExceeded() {
|
|
142
|
+
try {
|
|
143
|
+
const keys = Object.keys(localStorage);
|
|
144
|
+
const resultKeys = keys.filter((key)=>key.startsWith(this.resultsKey));
|
|
145
|
+
const keysToRemove = resultKeys.slice(0, Math.max(1, Math.floor(resultKeys.length / 2)));
|
|
146
|
+
keysToRemove.forEach((key)=>{
|
|
147
|
+
localStorage.removeItem(key);
|
|
148
|
+
});
|
|
149
|
+
console.info(`Cleared ${keysToRemove.length} old result entries to free up storage space`);
|
|
150
|
+
const playgroundKeys = keys.filter((key)=>key.includes('playground') || key.includes('agent') || key.startsWith('midscene'));
|
|
151
|
+
if (playgroundKeys.length > 10) {
|
|
152
|
+
const additionalKeysToRemove = playgroundKeys.slice(0, Math.floor(playgroundKeys.length / 3));
|
|
153
|
+
additionalKeysToRemove.forEach((key)=>{
|
|
154
|
+
if (key !== this.messagesKey) localStorage.removeItem(key);
|
|
155
|
+
});
|
|
156
|
+
console.info(`Cleared ${additionalKeysToRemove.length} additional playground-related entries`);
|
|
157
|
+
}
|
|
158
|
+
} catch (error) {
|
|
159
|
+
console.error('Failed to handle quota exceeded:', error);
|
|
97
160
|
}
|
|
98
161
|
}
|
|
99
162
|
constructor(namespace = 'playground'){
|
|
100
163
|
_define_property(this, "messagesKey", void 0);
|
|
101
164
|
_define_property(this, "resultsKey", void 0);
|
|
165
|
+
_define_property(this, "maxStorageItems", 50);
|
|
102
166
|
this.messagesKey = `${namespace}-messages`;
|
|
103
167
|
this.resultsKey = `${namespace}-results`;
|
|
104
168
|
}
|
|
@@ -68,7 +68,8 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
|
68
68
|
}, []);
|
|
69
69
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
70
70
|
if ((null == storage ? void 0 : storage.saveMessages) && infoList.length > 1) storage.saveMessages(infoList).catch((error)=>{
|
|
71
|
-
console.
|
|
71
|
+
if (error instanceof DOMException && 'QuotaExceededError' === error.name) console.warn('Storage quota exceeded - some messages may not be saved persistently');
|
|
72
|
+
else console.error('Failed to save messages:', error);
|
|
72
73
|
});
|
|
73
74
|
}, [
|
|
74
75
|
infoList,
|
package/dist/lib/index.js
CHANGED
|
@@ -51,9 +51,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
51
51
|
BaseContextProvider: ()=>context_provider_js_namespaceObject.BaseContextProvider,
|
|
52
52
|
colorForName: ()=>color_js_namespaceObject.colorForName,
|
|
53
53
|
safeOverrideAIConfig: ()=>useSafeOverrideAIConfig_js_namespaceObject.safeOverrideAIConfig,
|
|
54
|
-
GithubStar: ()=>github_star_index_js_namespaceObject.GithubStar,
|
|
55
54
|
Logo: ()=>logo_index_js_namespaceObject.Logo,
|
|
56
55
|
UniversalPlayground: ()=>universal_playground_index_js_namespaceObject.UniversalPlayground,
|
|
56
|
+
NavActions: ()=>nav_actions_index_js_namespaceObject.NavActions,
|
|
57
57
|
useEnvConfig: ()=>store_js_namespaceObject.useEnvConfig,
|
|
58
58
|
NoOpStorageProvider: ()=>storage_provider_js_namespaceObject.NoOpStorageProvider,
|
|
59
59
|
ContextPreview: ()=>context_preview_index_js_namespaceObject.ContextPreview,
|
|
@@ -77,6 +77,7 @@ const store_js_namespaceObject = require("./store/store.js");
|
|
|
77
77
|
const color_js_namespaceObject = require("./utils/color.js");
|
|
78
78
|
const index_js_namespaceObject = require("./component/env-config/index.js");
|
|
79
79
|
const env_config_reminder_index_js_namespaceObject = require("./component/env-config-reminder/index.js");
|
|
80
|
+
const nav_actions_index_js_namespaceObject = require("./component/nav-actions/index.js");
|
|
80
81
|
const logo_index_js_namespaceObject = require("./component/logo/index.js");
|
|
81
82
|
const misc_index_js_namespaceObject = require("./component/misc/index.js");
|
|
82
83
|
const useServerValid_js_namespaceObject = require("./hooks/useServerValid.js");
|
|
@@ -87,7 +88,6 @@ const context_preview_index_js_namespaceObject = require("./component/context-pr
|
|
|
87
88
|
const prompt_input_index_js_namespaceObject = require("./component/prompt-input/index.js");
|
|
88
89
|
const player_index_js_namespaceObject = require("./component/player/index.js");
|
|
89
90
|
const blackboard_index_js_namespaceObject = require("./component/blackboard/index.js");
|
|
90
|
-
const github_star_index_js_namespaceObject = require("./component/github-star/index.js");
|
|
91
91
|
const playground_utils_js_namespaceObject = require("./utils/playground-utils.js");
|
|
92
92
|
const external_utils_index_js_namespaceObject = require("./utils/index.js");
|
|
93
93
|
const shiny_text_index_js_namespaceObject = require("./component/shiny-text/index.js");
|
|
@@ -102,10 +102,10 @@ exports.Blackboard = __webpack_exports__.Blackboard;
|
|
|
102
102
|
exports.ContextPreview = __webpack_exports__.ContextPreview;
|
|
103
103
|
exports.EnvConfig = __webpack_exports__.EnvConfig;
|
|
104
104
|
exports.EnvConfigReminder = __webpack_exports__.EnvConfigReminder;
|
|
105
|
-
exports.GithubStar = __webpack_exports__.GithubStar;
|
|
106
105
|
exports.LocalStorageProvider = __webpack_exports__.LocalStorageProvider;
|
|
107
106
|
exports.Logo = __webpack_exports__.Logo;
|
|
108
107
|
exports.MemoryStorageProvider = __webpack_exports__.MemoryStorageProvider;
|
|
108
|
+
exports.NavActions = __webpack_exports__.NavActions;
|
|
109
109
|
exports.NoOpContextProvider = __webpack_exports__.NoOpContextProvider;
|
|
110
110
|
exports.NoOpStorageProvider = __webpack_exports__.NoOpStorageProvider;
|
|
111
111
|
exports.Player = __webpack_exports__.Player;
|
|
@@ -139,10 +139,10 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
139
139
|
"ContextPreview",
|
|
140
140
|
"EnvConfig",
|
|
141
141
|
"EnvConfigReminder",
|
|
142
|
-
"GithubStar",
|
|
143
142
|
"LocalStorageProvider",
|
|
144
143
|
"Logo",
|
|
145
144
|
"MemoryStorageProvider",
|
|
145
|
+
"NavActions",
|
|
146
146
|
"NoOpContextProvider",
|
|
147
147
|
"NoOpStorageProvider",
|
|
148
148
|
"Player",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './style.less';
|
|
2
|
+
export interface NavActionsProps {
|
|
3
|
+
showEnvConfig?: boolean;
|
|
4
|
+
showTooltipWhenEmpty?: boolean;
|
|
5
|
+
showModelName?: boolean;
|
|
6
|
+
githubUrl?: string;
|
|
7
|
+
helpUrl?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function NavActions({ showEnvConfig, showTooltipWhenEmpty, showModelName, githubUrl, helpUrl, className, }: NavActionsProps): import("react").JSX.Element;
|
|
@@ -5,11 +5,20 @@ import type { InfoListItem, StorageProvider } from '../../../types';
|
|
|
5
5
|
export declare class LocalStorageProvider implements StorageProvider {
|
|
6
6
|
private readonly messagesKey;
|
|
7
7
|
private readonly resultsKey;
|
|
8
|
+
private readonly maxStorageItems;
|
|
8
9
|
constructor(namespace?: string);
|
|
10
|
+
/**
|
|
11
|
+
* Check available storage space
|
|
12
|
+
*/
|
|
13
|
+
private checkStorageSpace;
|
|
9
14
|
saveMessages(messages: InfoListItem[]): Promise<void>;
|
|
10
15
|
loadMessages(): Promise<InfoListItem[]>;
|
|
11
16
|
clearMessages(): Promise<void>;
|
|
12
17
|
saveResult(id: string, result: InfoListItem): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Handle quota exceeded by clearing old data
|
|
20
|
+
*/
|
|
21
|
+
private handleQuotaExceeded;
|
|
13
22
|
}
|
|
14
23
|
/**
|
|
15
24
|
* Memory-only storage implementation for non-persistent scenarios
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export { useEnvConfig } from './store/store';
|
|
|
5
5
|
export { colorForName, highlightColorForType, globalThemeConfig, } from './utils/color';
|
|
6
6
|
export { EnvConfig } from './component/env-config';
|
|
7
7
|
export { EnvConfigReminder } from './component/env-config-reminder';
|
|
8
|
+
export { NavActions } from './component/nav-actions';
|
|
9
|
+
export type { NavActionsProps } from './component/nav-actions';
|
|
8
10
|
export { Logo } from './component/logo';
|
|
9
11
|
export { iconForStatus, timeCostStrElement } from './component/misc';
|
|
10
12
|
export { useServerValid } from './hooks/useServerValid';
|
|
@@ -16,7 +18,6 @@ export { ContextPreview } from './component/context-preview';
|
|
|
16
18
|
export { PromptInput } from './component/prompt-input';
|
|
17
19
|
export { Player } from './component/player';
|
|
18
20
|
export { Blackboard } from './component/blackboard';
|
|
19
|
-
export { GithubStar } from './component/github-star';
|
|
20
21
|
export { actionNameForType, staticAgentFromContext, getPlaceholderForType, } from './utils/playground-utils';
|
|
21
22
|
export { timeStr, filterBase64Value } from './utils';
|
|
22
23
|
export { default as ShinyText } from './component/shiny-text';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/visualizer",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.10-beta-20250917142241.0",
|
|
4
4
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
5
5
|
"homepage": "https://midscenejs.com/",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"react-dom": "18.3.1",
|
|
53
53
|
"react-resizable-panels": "2.0.22",
|
|
54
54
|
"rimraf": "~3.0.2",
|
|
55
|
-
"tsx": "4.19.2",
|
|
55
|
+
"tsx": "^4.19.2",
|
|
56
56
|
"typescript": "^5.8.3",
|
|
57
57
|
"zustand": "4.5.2"
|
|
58
58
|
},
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"antd": "^5.21.6",
|
|
71
71
|
"buffer": "6.0.3",
|
|
72
72
|
"dayjs": "^1.11.11",
|
|
73
|
-
"@midscene/core": "0.28.
|
|
74
|
-
"@midscene/
|
|
75
|
-
"@midscene/
|
|
76
|
-
"@midscene/
|
|
73
|
+
"@midscene/core": "0.28.10-beta-20250917142241.0",
|
|
74
|
+
"@midscene/playground": "0.28.10-beta-20250917142241.0",
|
|
75
|
+
"@midscene/web": "0.28.10-beta-20250917142241.0",
|
|
76
|
+
"@midscene/shared": "0.28.10-beta-20250917142241.0"
|
|
77
77
|
},
|
|
78
78
|
"license": "MIT",
|
|
79
79
|
"scripts": {
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import "./index.css";
|
|
3
|
-
const GithubStar = ()=>/*#__PURE__*/ jsx("a", {
|
|
4
|
-
href: "https://github.com/web-infra-dev/midscene",
|
|
5
|
-
target: "_blank",
|
|
6
|
-
rel: "noreferrer",
|
|
7
|
-
style: {
|
|
8
|
-
display: 'flex',
|
|
9
|
-
alignItems: 'center'
|
|
10
|
-
},
|
|
11
|
-
children: /*#__PURE__*/ jsx("img", {
|
|
12
|
-
className: "github-star",
|
|
13
|
-
src: "https://img.shields.io/github/stars/web-infra-dev/midscene?style=social",
|
|
14
|
-
alt: "Github star",
|
|
15
|
-
style: {
|
|
16
|
-
display: 'block'
|
|
17
|
-
}
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
export { GithubStar };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
GithubStar: ()=>GithubStar
|
|
28
|
-
});
|
|
29
|
-
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
-
require("./index.css");
|
|
31
|
-
const GithubStar = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
32
|
-
href: "https://github.com/web-infra-dev/midscene",
|
|
33
|
-
target: "_blank",
|
|
34
|
-
rel: "noreferrer",
|
|
35
|
-
style: {
|
|
36
|
-
display: 'flex',
|
|
37
|
-
alignItems: 'center'
|
|
38
|
-
},
|
|
39
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("img", {
|
|
40
|
-
className: "github-star",
|
|
41
|
-
src: "https://img.shields.io/github/stars/web-infra-dev/midscene?style=social",
|
|
42
|
-
alt: "Github star",
|
|
43
|
-
style: {
|
|
44
|
-
display: 'block'
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
exports.GithubStar = __webpack_exports__.GithubStar;
|
|
49
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
50
|
-
"GithubStar"
|
|
51
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
52
|
-
Object.defineProperty(exports, '__esModule', {
|
|
53
|
-
value: true
|
|
54
|
-
});
|