@midscene/visualizer 0.28.10-beta-20250919084614.0 → 0.28.10-beta-20250919094051.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/player/index.mjs +15 -38
- package/dist/es/component/universal-playground/index.css +1 -1
- package/dist/es/component/universal-playground/index.mjs +5 -29
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +3 -42
- package/dist/es/hooks/usePlaygroundState.mjs +3 -28
- package/dist/es/index.mjs +2 -2
- package/dist/es/utils/replay-scripts.mjs +32 -59
- package/dist/lib/component/player/index.js +15 -38
- package/dist/lib/component/universal-playground/index.css +1 -1
- package/dist/lib/component/universal-playground/index.js +3 -27
- package/dist/lib/component/universal-playground/providers/storage-provider.js +3 -60
- package/dist/lib/hooks/usePlaygroundState.js +3 -28
- package/dist/lib/index.js +2 -14
- package/dist/lib/utils/replay-scripts.js +32 -59
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +0 -16
- package/dist/types/hooks/usePlaygroundExecution.d.ts +1 -1
- package/dist/types/hooks/usePlaygroundState.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/replay-scripts.d.ts +0 -2
- package/package.json +5 -5
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +0 -207
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +0 -247
- package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +0 -71
|
@@ -91,10 +91,10 @@
|
|
|
91
91
|
.playground-container .middle-dialog-area .scroll-to-bottom-button {
|
|
92
92
|
z-index: 10;
|
|
93
93
|
background: #fff;
|
|
94
|
-
border: 1px solid rgba(0, 0, 0, .08);
|
|
95
94
|
position: absolute;
|
|
96
95
|
bottom: 10px;
|
|
97
96
|
right: 0;
|
|
97
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, .04);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
.playground-container .middle-dialog-area .scroll-to-bottom-button:hover {
|
|
@@ -81,35 +81,11 @@ function UniversalPlayground(param) {
|
|
|
81
81
|
let { playgroundSDK, storage, contextProvider, config: componentConfig = {}, branding = {}, className = '', dryMode = false, showContextPreview = true } = param;
|
|
82
82
|
const [form] = external_antd_namespaceObject.Form.useForm();
|
|
83
83
|
const { config } = (0, store_js_namespaceObject.useEnvConfig)();
|
|
84
|
-
const
|
|
85
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
86
|
-
const initializeSDK = async ()=>{
|
|
87
|
-
if (playgroundSDK && 'function' == typeof playgroundSDK.checkStatus) try {
|
|
88
|
-
await playgroundSDK.checkStatus();
|
|
89
|
-
setSdkReady(true);
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.warn('Failed to initialize SDK, using default namespace:', error);
|
|
92
|
-
setSdkReady(true);
|
|
93
|
-
}
|
|
94
|
-
else setSdkReady(true);
|
|
95
|
-
};
|
|
96
|
-
initializeSDK();
|
|
97
|
-
}, [
|
|
98
|
-
playgroundSDK
|
|
99
|
-
]);
|
|
100
|
-
const effectiveStorage = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
84
|
+
const effectiveStorage = (()=>{
|
|
101
85
|
if (storage) return storage;
|
|
102
|
-
if (!sdkReady) return null;
|
|
103
86
|
const namespace = componentConfig.storageNamespace || getSDKId(playgroundSDK);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return (0, storage_provider_js_namespaceObject.createStorageProvider)(bestStorageType, namespace);
|
|
107
|
-
}, [
|
|
108
|
-
storage,
|
|
109
|
-
sdkReady,
|
|
110
|
-
componentConfig.storageNamespace,
|
|
111
|
-
playgroundSDK
|
|
112
|
-
]);
|
|
87
|
+
return new storage_provider_js_namespaceObject.LocalStorageProvider(namespace);
|
|
88
|
+
})();
|
|
113
89
|
const { loading, setLoading, infoList, setInfoList, actionSpace, actionSpaceLoading, uiContextPreview, setUiContextPreview, showScrollToBottomButton, verticalMode, replayCounter, setReplayCounter, infoListRef, currentRunningIdRef, interruptedFlagRef, clearInfoList, handleScrollToBottom } = (0, usePlaygroundState_js_namespaceObject.usePlaygroundState)(playgroundSDK, effectiveStorage, contextProvider);
|
|
114
90
|
const { handleRun: executeAction, handleStop, canStop } = (0, usePlaygroundExecution_js_namespaceObject.usePlaygroundExecution)(playgroundSDK, effectiveStorage, actionSpace, loading, setLoading, infoList, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef);
|
|
115
91
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
@@ -24,17 +24,10 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
IndexedDBStorageProvider: ()=>external_indexeddb_storage_provider_js_namespaceObject.IndexedDBStorageProvider,
|
|
28
|
-
StorageType: ()=>storage_provider_StorageType,
|
|
29
|
-
detectBestStorageType: ()=>detectBestStorageType,
|
|
30
|
-
IndexedDBMemoryStorageProvider: ()=>external_indexeddb_storage_provider_js_namespaceObject.MemoryStorageProvider,
|
|
31
|
-
IndexedDBNoOpStorageProvider: ()=>external_indexeddb_storage_provider_js_namespaceObject.NoOpStorageProvider,
|
|
32
27
|
LocalStorageProvider: ()=>LocalStorageProvider,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
MemoryStorageProvider: ()=>MemoryStorageProvider
|
|
28
|
+
MemoryStorageProvider: ()=>MemoryStorageProvider,
|
|
29
|
+
NoOpStorageProvider: ()=>NoOpStorageProvider
|
|
36
30
|
});
|
|
37
|
-
const external_indexeddb_storage_provider_js_namespaceObject = require("./indexeddb-storage-provider.js");
|
|
38
31
|
function _define_property(obj, key, value) {
|
|
39
32
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
40
33
|
value: value,
|
|
@@ -205,63 +198,13 @@ class NoOpStorageProvider {
|
|
|
205
198
|
async clearMessages() {}
|
|
206
199
|
async saveResult(_id, _result) {}
|
|
207
200
|
}
|
|
208
|
-
var storage_provider_StorageType = /*#__PURE__*/ function(StorageType) {
|
|
209
|
-
StorageType["INDEXEDDB"] = "indexeddb";
|
|
210
|
-
StorageType["LOCALSTORAGE"] = "localStorage";
|
|
211
|
-
StorageType["MEMORY"] = "memory";
|
|
212
|
-
StorageType["NONE"] = "none";
|
|
213
|
-
return StorageType;
|
|
214
|
-
}({});
|
|
215
|
-
function createStorageProvider() {
|
|
216
|
-
let type = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "indexeddb", namespace = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 'playground';
|
|
217
|
-
switch(type){
|
|
218
|
-
case "indexeddb":
|
|
219
|
-
if ('undefined' != typeof indexedDB) return new external_indexeddb_storage_provider_js_namespaceObject.IndexedDBStorageProvider(namespace);
|
|
220
|
-
console.warn('IndexedDB not available, falling back to localStorage');
|
|
221
|
-
return createStorageProvider("localStorage", namespace);
|
|
222
|
-
case "localStorage":
|
|
223
|
-
if ('undefined' != typeof localStorage) return new LocalStorageProvider(namespace);
|
|
224
|
-
console.warn('localStorage not available, falling back to memory storage');
|
|
225
|
-
return createStorageProvider("memory", namespace);
|
|
226
|
-
case "memory":
|
|
227
|
-
return new MemoryStorageProvider();
|
|
228
|
-
case "none":
|
|
229
|
-
return new NoOpStorageProvider();
|
|
230
|
-
default:
|
|
231
|
-
throw new Error(`Unknown storage type: ${type}`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function detectBestStorageType() {
|
|
235
|
-
if ('undefined' != typeof indexedDB) try {
|
|
236
|
-
indexedDB.open('test', 1).onerror = ()=>{};
|
|
237
|
-
return "indexeddb";
|
|
238
|
-
} catch (e) {}
|
|
239
|
-
if ('undefined' != typeof localStorage) try {
|
|
240
|
-
localStorage.setItem('test', 'test');
|
|
241
|
-
localStorage.removeItem('test');
|
|
242
|
-
return "localStorage";
|
|
243
|
-
} catch (e) {}
|
|
244
|
-
return "memory";
|
|
245
|
-
}
|
|
246
|
-
exports.IndexedDBMemoryStorageProvider = __webpack_exports__.IndexedDBMemoryStorageProvider;
|
|
247
|
-
exports.IndexedDBNoOpStorageProvider = __webpack_exports__.IndexedDBNoOpStorageProvider;
|
|
248
|
-
exports.IndexedDBStorageProvider = __webpack_exports__.IndexedDBStorageProvider;
|
|
249
201
|
exports.LocalStorageProvider = __webpack_exports__.LocalStorageProvider;
|
|
250
202
|
exports.MemoryStorageProvider = __webpack_exports__.MemoryStorageProvider;
|
|
251
203
|
exports.NoOpStorageProvider = __webpack_exports__.NoOpStorageProvider;
|
|
252
|
-
exports.StorageType = __webpack_exports__.StorageType;
|
|
253
|
-
exports.createStorageProvider = __webpack_exports__.createStorageProvider;
|
|
254
|
-
exports.detectBestStorageType = __webpack_exports__.detectBestStorageType;
|
|
255
204
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
256
|
-
"IndexedDBMemoryStorageProvider",
|
|
257
|
-
"IndexedDBNoOpStorageProvider",
|
|
258
|
-
"IndexedDBStorageProvider",
|
|
259
205
|
"LocalStorageProvider",
|
|
260
206
|
"MemoryStorageProvider",
|
|
261
|
-
"NoOpStorageProvider"
|
|
262
|
-
"StorageType",
|
|
263
|
-
"createStorageProvider",
|
|
264
|
-
"detectBestStorageType"
|
|
207
|
+
"NoOpStorageProvider"
|
|
265
208
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
266
209
|
Object.defineProperty(exports, '__esModule', {
|
|
267
210
|
value: true
|
|
@@ -27,7 +27,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
usePlaygroundState: ()=>usePlaygroundState
|
|
28
28
|
});
|
|
29
29
|
const external_react_namespaceObject = require("react");
|
|
30
|
-
const storage_provider_js_namespaceObject = require("../component/universal-playground/providers/storage-provider.js");
|
|
31
30
|
const constants_js_namespaceObject = require("../utils/constants.js");
|
|
32
31
|
function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
33
32
|
const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -41,25 +40,7 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
|
41
40
|
const infoListRef = (0, external_react_namespaceObject.useRef)(null);
|
|
42
41
|
const currentRunningIdRef = (0, external_react_namespaceObject.useRef)(null);
|
|
43
42
|
const interruptedFlagRef = (0, external_react_namespaceObject.useRef)({});
|
|
44
|
-
const initializedRef = (0, external_react_namespaceObject.useRef)(false);
|
|
45
43
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
46
|
-
const migrateFromOldNamespace = async ()=>{
|
|
47
|
-
const oldStorage = (0, storage_provider_js_namespaceObject.createStorageProvider)((0, storage_provider_js_namespaceObject.detectBestStorageType)(), 'playground-default');
|
|
48
|
-
try {
|
|
49
|
-
if (null == oldStorage ? void 0 : oldStorage.loadMessages) {
|
|
50
|
-
const oldMessages = await oldStorage.loadMessages();
|
|
51
|
-
if (oldMessages.length > 1) {
|
|
52
|
-
console.log('Found data in old namespace, migrating...');
|
|
53
|
-
if (null == storage ? void 0 : storage.saveMessages) await storage.saveMessages(oldMessages);
|
|
54
|
-
if (oldStorage.clearMessages) await oldStorage.clearMessages();
|
|
55
|
-
return oldMessages;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} catch (error) {
|
|
59
|
-
console.debug('No data found in old namespace:', error);
|
|
60
|
-
}
|
|
61
|
-
return [];
|
|
62
|
-
};
|
|
63
44
|
const initializeMessages = async ()=>{
|
|
64
45
|
const welcomeMessage = {
|
|
65
46
|
...constants_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
|
|
@@ -67,8 +48,7 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
|
67
48
|
timestamp: new Date()
|
|
68
49
|
};
|
|
69
50
|
if (null == storage ? void 0 : storage.loadMessages) try {
|
|
70
|
-
|
|
71
|
-
if (0 === storedMessages.length) storedMessages = await migrateFromOldNamespace();
|
|
51
|
+
const storedMessages = await storage.loadMessages();
|
|
72
52
|
const hasWelcomeMessage = storedMessages.some((msg)=>'welcome' === msg.id);
|
|
73
53
|
hasWelcomeMessage ? setInfoList(storedMessages) : setInfoList([
|
|
74
54
|
welcomeMessage,
|
|
@@ -84,13 +64,8 @@ function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
|
84
64
|
welcomeMessage
|
|
85
65
|
]);
|
|
86
66
|
};
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
initializeMessages();
|
|
90
|
-
} else if (!storage && 0 === infoList.length) initializeMessages();
|
|
91
|
-
}, [
|
|
92
|
-
storage
|
|
93
|
-
]);
|
|
67
|
+
if (0 === infoList.length) initializeMessages();
|
|
68
|
+
}, []);
|
|
94
69
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
95
70
|
if ((null == storage ? void 0 : storage.saveMessages) && infoList.length > 1) storage.saveMessages(infoList).catch((error)=>{
|
|
96
71
|
if (error instanceof DOMException && 'QuotaExceededError' === error.name) console.warn('Storage quota exceeded - some messages may not be saved persistently');
|
package/dist/lib/index.js
CHANGED
|
@@ -34,7 +34,6 @@ var __webpack_exports__ = {};
|
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
timeCostStrElement: ()=>misc_index_js_namespaceObject.timeCostStrElement,
|
|
37
|
-
StorageType: ()=>storage_provider_js_namespaceObject.StorageType,
|
|
38
37
|
actionNameForType: ()=>playground_utils_js_namespaceObject.actionNameForType,
|
|
39
38
|
PlaygroundResultView: ()=>playground_result_index_js_namespaceObject.PlaygroundResultView,
|
|
40
39
|
timeStr: ()=>external_utils_index_js_namespaceObject.timeStr,
|
|
@@ -54,9 +53,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
54
53
|
safeOverrideAIConfig: ()=>useSafeOverrideAIConfig_js_namespaceObject.safeOverrideAIConfig,
|
|
55
54
|
Logo: ()=>logo_index_js_namespaceObject.Logo,
|
|
56
55
|
UniversalPlayground: ()=>universal_playground_index_js_namespaceObject.UniversalPlayground,
|
|
57
|
-
IndexedDBStorageProvider: ()=>storage_provider_js_namespaceObject.IndexedDBStorageProvider,
|
|
58
56
|
NavActions: ()=>nav_actions_index_js_namespaceObject.NavActions,
|
|
59
|
-
detectBestStorageType: ()=>storage_provider_js_namespaceObject.detectBestStorageType,
|
|
60
57
|
useEnvConfig: ()=>store_js_namespaceObject.useEnvConfig,
|
|
61
58
|
NoOpStorageProvider: ()=>storage_provider_js_namespaceObject.NoOpStorageProvider,
|
|
62
59
|
ContextPreview: ()=>context_preview_index_js_namespaceObject.ContextPreview,
|
|
@@ -69,10 +66,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
69
66
|
filterBase64Value: ()=>external_utils_index_js_namespaceObject.filterBase64Value,
|
|
70
67
|
NoOpContextProvider: ()=>context_provider_js_namespaceObject.NoOpContextProvider,
|
|
71
68
|
highlightColorForType: ()=>color_js_namespaceObject.highlightColorForType,
|
|
72
|
-
createStorageProvider: ()=>storage_provider_js_namespaceObject.createStorageProvider,
|
|
73
69
|
globalThemeConfig: ()=>color_js_namespaceObject.globalThemeConfig,
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
iconForStatus: ()=>misc_index_js_namespaceObject.iconForStatus,
|
|
71
|
+
MemoryStorageProvider: ()=>storage_provider_js_namespaceObject.MemoryStorageProvider
|
|
76
72
|
});
|
|
77
73
|
require("./component/playground/index.css");
|
|
78
74
|
require("./component/universal-playground/index.css");
|
|
@@ -106,7 +102,6 @@ exports.Blackboard = __webpack_exports__.Blackboard;
|
|
|
106
102
|
exports.ContextPreview = __webpack_exports__.ContextPreview;
|
|
107
103
|
exports.EnvConfig = __webpack_exports__.EnvConfig;
|
|
108
104
|
exports.EnvConfigReminder = __webpack_exports__.EnvConfigReminder;
|
|
109
|
-
exports.IndexedDBStorageProvider = __webpack_exports__.IndexedDBStorageProvider;
|
|
110
105
|
exports.LocalStorageProvider = __webpack_exports__.LocalStorageProvider;
|
|
111
106
|
exports.Logo = __webpack_exports__.Logo;
|
|
112
107
|
exports.MemoryStorageProvider = __webpack_exports__.MemoryStorageProvider;
|
|
@@ -119,14 +114,11 @@ exports.PromptInput = __webpack_exports__.PromptInput;
|
|
|
119
114
|
exports.ServiceModeControl = __webpack_exports__.ServiceModeControl;
|
|
120
115
|
exports.ShinyText = __webpack_exports__.ShinyText;
|
|
121
116
|
exports.StaticContextProvider = __webpack_exports__.StaticContextProvider;
|
|
122
|
-
exports.StorageType = __webpack_exports__.StorageType;
|
|
123
117
|
exports.UniversalPlayground = __webpack_exports__.UniversalPlayground;
|
|
124
118
|
exports.UniversalPlaygroundDefault = __webpack_exports__.UniversalPlaygroundDefault;
|
|
125
119
|
exports.actionNameForType = __webpack_exports__.actionNameForType;
|
|
126
120
|
exports.allScriptsFromDump = __webpack_exports__.allScriptsFromDump;
|
|
127
121
|
exports.colorForName = __webpack_exports__.colorForName;
|
|
128
|
-
exports.createStorageProvider = __webpack_exports__.createStorageProvider;
|
|
129
|
-
exports.detectBestStorageType = __webpack_exports__.detectBestStorageType;
|
|
130
122
|
exports.filterBase64Value = __webpack_exports__.filterBase64Value;
|
|
131
123
|
exports.generateAnimationScripts = __webpack_exports__.generateAnimationScripts;
|
|
132
124
|
exports.getPlaceholderForType = __webpack_exports__.getPlaceholderForType;
|
|
@@ -147,7 +139,6 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
147
139
|
"ContextPreview",
|
|
148
140
|
"EnvConfig",
|
|
149
141
|
"EnvConfigReminder",
|
|
150
|
-
"IndexedDBStorageProvider",
|
|
151
142
|
"LocalStorageProvider",
|
|
152
143
|
"Logo",
|
|
153
144
|
"MemoryStorageProvider",
|
|
@@ -160,14 +151,11 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
160
151
|
"ServiceModeControl",
|
|
161
152
|
"ShinyText",
|
|
162
153
|
"StaticContextProvider",
|
|
163
|
-
"StorageType",
|
|
164
154
|
"UniversalPlayground",
|
|
165
155
|
"UniversalPlaygroundDefault",
|
|
166
156
|
"actionNameForType",
|
|
167
157
|
"allScriptsFromDump",
|
|
168
158
|
"colorForName",
|
|
169
|
-
"createStorageProvider",
|
|
170
|
-
"detectBestStorageType",
|
|
171
159
|
"filterBase64Value",
|
|
172
160
|
"generateAnimationScripts",
|
|
173
161
|
"getPlaceholderForType",
|
|
@@ -73,9 +73,8 @@ const capitalizeFirstLetter = (str)=>{
|
|
|
73
73
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
74
74
|
};
|
|
75
75
|
const allScriptsFromDump = (dump)=>{
|
|
76
|
-
|
|
77
|
-
let
|
|
78
|
-
let firstHeight;
|
|
76
|
+
let width;
|
|
77
|
+
let height;
|
|
79
78
|
let sdkVersion;
|
|
80
79
|
const modelBriefsSet = new Set();
|
|
81
80
|
dump.executions.forEach((execution)=>{
|
|
@@ -83,17 +82,12 @@ const allScriptsFromDump = (dump)=>{
|
|
|
83
82
|
execution.tasks.forEach((task)=>{
|
|
84
83
|
var _task_uiContext_size, _task_uiContext;
|
|
85
84
|
if (null == (_task_uiContext = task.uiContext) ? void 0 : null == (_task_uiContext_size = _task_uiContext.size) ? void 0 : _task_uiContext_size.width) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (!firstWidth) {
|
|
89
|
-
firstWidth = w;
|
|
90
|
-
firstHeight = h;
|
|
91
|
-
}
|
|
92
|
-
dimensionsSet.add(`${w}x${h}`);
|
|
85
|
+
width = task.uiContext.size.width;
|
|
86
|
+
height = task.uiContext.size.height;
|
|
93
87
|
}
|
|
94
88
|
});
|
|
95
89
|
});
|
|
96
|
-
if (!
|
|
90
|
+
if (!width || !height) {
|
|
97
91
|
console.warn('width or height is missing in dump file');
|
|
98
92
|
return {
|
|
99
93
|
scripts: [],
|
|
@@ -103,7 +97,7 @@ const allScriptsFromDump = (dump)=>{
|
|
|
103
97
|
}
|
|
104
98
|
const allScripts = [];
|
|
105
99
|
dump.executions.forEach((execution)=>{
|
|
106
|
-
const scripts = generateAnimationScripts(execution, -1,
|
|
100
|
+
const scripts = generateAnimationScripts(execution, -1, width, height);
|
|
107
101
|
if (scripts) allScripts.push(...scripts);
|
|
108
102
|
execution.tasks.forEach((task)=>{
|
|
109
103
|
if (task.usage) {
|
|
@@ -130,8 +124,8 @@ const allScriptsFromDump = (dump)=>{
|
|
|
130
124
|
})();
|
|
131
125
|
return {
|
|
132
126
|
scripts: allScriptsWithoutIntermediateDoneFrame,
|
|
133
|
-
width
|
|
134
|
-
height
|
|
127
|
+
width,
|
|
128
|
+
height,
|
|
135
129
|
sdkVersion,
|
|
136
130
|
modelBriefs
|
|
137
131
|
};
|
|
@@ -180,16 +174,14 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
180
174
|
if ('Planning' === task.type) {
|
|
181
175
|
const planningTask = task;
|
|
182
176
|
if (planningTask.recorder && planningTask.recorder.length > 0) {
|
|
183
|
-
var _planningTask_recorder_, _planningTask_recorder
|
|
177
|
+
var _planningTask_recorder_, _planningTask_recorder;
|
|
184
178
|
scripts.push({
|
|
185
179
|
type: 'img',
|
|
186
180
|
img: null == (_planningTask_recorder = planningTask.recorder) ? void 0 : null == (_planningTask_recorder_ = _planningTask_recorder[0]) ? void 0 : _planningTask_recorder_.screenshot,
|
|
187
181
|
camera: 0 === index ? fullPageCameraState : void 0,
|
|
188
182
|
duration: stillDuration,
|
|
189
183
|
title: (0, agent_namespaceObject.typeStr)(task),
|
|
190
|
-
subTitle: (0, agent_namespaceObject.paramStr)(task)
|
|
191
|
-
imageWidth: (null == (_task_uiContext = task.uiContext) ? void 0 : null == (_task_uiContext_size = _task_uiContext.size) ? void 0 : _task_uiContext_size.width) || imageWidth,
|
|
192
|
-
imageHeight: (null == (_task_uiContext1 = task.uiContext) ? void 0 : null == (_task_uiContext_size1 = _task_uiContext1.size) ? void 0 : _task_uiContext_size1.height) || imageHeight
|
|
184
|
+
subTitle: (0, agent_namespaceObject.paramStr)(task)
|
|
193
185
|
});
|
|
194
186
|
}
|
|
195
187
|
} else if ('Insight' === task.type && 'Locate' === task.subType) {
|
|
@@ -205,21 +197,16 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
205
197
|
};
|
|
206
198
|
const context = insightTask.uiContext;
|
|
207
199
|
if (null == context ? void 0 : context.screenshotBase64) {
|
|
208
|
-
var _insightTask_log, _insightTask_output1, _insightDump_taskInfo
|
|
200
|
+
var _insightTask_log, _insightTask_output1, _insightDump_taskInfo;
|
|
209
201
|
const insightDump = null == (_insightTask_log = insightTask.log) ? void 0 : _insightTask_log.dump;
|
|
210
202
|
const insightContentLength = context.tree ? (0, extractor_namespaceObject.treeToList)(context.tree).length : 0;
|
|
211
|
-
if (context.screenshotBase64) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
subTitle,
|
|
219
|
-
imageWidth: (null == (_context_size2 = context.size) ? void 0 : _context_size2.width) || imageWidth,
|
|
220
|
-
imageHeight: (null == (_context_size3 = context.size) ? void 0 : _context_size3.height) || imageHeight
|
|
221
|
-
});
|
|
222
|
-
}
|
|
203
|
+
if (context.screenshotBase64) scripts.push({
|
|
204
|
+
type: 'img',
|
|
205
|
+
img: context.screenshotBase64,
|
|
206
|
+
duration: stillAfterInsightDuration,
|
|
207
|
+
title,
|
|
208
|
+
subTitle
|
|
209
|
+
});
|
|
223
210
|
let cameraState;
|
|
224
211
|
cameraState = currentCameraState === fullPageCameraState ? void 0 : insightCameraState ? mergeTwoCameraState(currentCameraState, insightCameraState) : void 0;
|
|
225
212
|
scripts.push({
|
|
@@ -232,9 +219,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
232
219
|
duration: insightContentLength > 20 ? locateDuration : 0.5 * locateDuration,
|
|
233
220
|
insightCameraDuration: locateDuration,
|
|
234
221
|
title,
|
|
235
|
-
subTitle
|
|
236
|
-
imageWidth: (null == (_context_size = context.size) ? void 0 : _context_size.width) || imageWidth,
|
|
237
|
-
imageHeight: (null == (_context_size1 = context.size) ? void 0 : _context_size1.height) || imageHeight
|
|
222
|
+
subTitle
|
|
238
223
|
});
|
|
239
224
|
scripts.push({
|
|
240
225
|
type: 'sleep',
|
|
@@ -245,7 +230,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
245
230
|
insightOnTop = true;
|
|
246
231
|
}
|
|
247
232
|
} else if ('Action' === task.type && 'FalsyConditionStatement' !== task.subType) {
|
|
248
|
-
var _task_recorder_, _task_recorder,
|
|
233
|
+
var _task_recorder_, _task_recorder, _task_recorder_1, _task_recorder1;
|
|
249
234
|
const title = (0, agent_namespaceObject.typeStr)(task);
|
|
250
235
|
const subTitle = (0, agent_namespaceObject.paramStr)(task);
|
|
251
236
|
scripts.push(pointerScript(external_index_js_namespaceObject.mousePointer, title, subTitle));
|
|
@@ -256,9 +241,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
256
241
|
duration: actionDuration,
|
|
257
242
|
camera: 'Sleep' === task.subType ? fullPageCameraState : insightCameraState,
|
|
258
243
|
title,
|
|
259
|
-
subTitle
|
|
260
|
-
imageWidth: (null == (_task_uiContext2 = task.uiContext) ? void 0 : null == (_task_uiContext_size2 = _task_uiContext2.size) ? void 0 : _task_uiContext_size2.width) || imageWidth,
|
|
261
|
-
imageHeight: (null == (_task_uiContext3 = task.uiContext) ? void 0 : null == (_task_uiContext_size3 = _task_uiContext3.size) ? void 0 : _task_uiContext_size3.height) || imageHeight
|
|
244
|
+
subTitle
|
|
262
245
|
});
|
|
263
246
|
if (insightOnTop) {
|
|
264
247
|
scripts.push({
|
|
@@ -271,7 +254,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
271
254
|
}
|
|
272
255
|
const imgStillDuration = index < taskCount - 1 ? stillDuration : 0;
|
|
273
256
|
if (null == (_task_recorder1 = task.recorder) ? void 0 : null == (_task_recorder_1 = _task_recorder1[1]) ? void 0 : _task_recorder_1.screenshot) {
|
|
274
|
-
var _task_recorder_2, _task_recorder2
|
|
257
|
+
var _task_recorder_2, _task_recorder2;
|
|
275
258
|
scripts.push({
|
|
276
259
|
type: 'spinning-pointer',
|
|
277
260
|
duration: actionSpinningPointerDuration,
|
|
@@ -284,9 +267,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
284
267
|
img: null == (_task_recorder2 = task.recorder) ? void 0 : null == (_task_recorder_2 = _task_recorder2[1]) ? void 0 : _task_recorder_2.screenshot,
|
|
285
268
|
duration: imgStillDuration,
|
|
286
269
|
title,
|
|
287
|
-
subTitle
|
|
288
|
-
imageWidth: (null == (_task_uiContext4 = task.uiContext) ? void 0 : null == (_task_uiContext_size4 = _task_uiContext4.size) ? void 0 : _task_uiContext_size4.width) || imageWidth,
|
|
289
|
-
imageHeight: (null == (_task_uiContext5 = task.uiContext) ? void 0 : null == (_task_uiContext_size5 = _task_uiContext5.size) ? void 0 : _task_uiContext_size5.height) || imageHeight
|
|
270
|
+
subTitle
|
|
290
271
|
});
|
|
291
272
|
} else scripts.push({
|
|
292
273
|
type: 'sleep',
|
|
@@ -299,22 +280,16 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
299
280
|
const title = (0, agent_namespaceObject.typeStr)(task);
|
|
300
281
|
const subTitle = (0, agent_namespaceObject.paramStr)(task);
|
|
301
282
|
const screenshot = null == (_task_recorder3 = task.recorder) ? void 0 : null == (_task_recorder_3 = _task_recorder3[task.recorder.length - 1]) ? void 0 : _task_recorder_3.screenshot;
|
|
302
|
-
if (screenshot) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
subTitle,
|
|
311
|
-
imageWidth: (null == (_task_uiContext6 = task.uiContext) ? void 0 : null == (_task_uiContext_size6 = _task_uiContext6.size) ? void 0 : _task_uiContext_size6.width) || imageWidth,
|
|
312
|
-
imageHeight: (null == (_task_uiContext7 = task.uiContext) ? void 0 : null == (_task_uiContext_size7 = _task_uiContext7.size) ? void 0 : _task_uiContext_size7.height) || imageHeight
|
|
313
|
-
});
|
|
314
|
-
}
|
|
283
|
+
if (screenshot) scripts.push({
|
|
284
|
+
type: 'img',
|
|
285
|
+
img: screenshot,
|
|
286
|
+
duration: stillDuration,
|
|
287
|
+
camera: fullPageCameraState,
|
|
288
|
+
title,
|
|
289
|
+
subTitle
|
|
290
|
+
});
|
|
315
291
|
}
|
|
316
292
|
if ('finished' !== task.status) {
|
|
317
|
-
var _task_uiContext_size8, _task_uiContext8, _task_uiContext_size9, _task_uiContext9;
|
|
318
293
|
errorStateFlag = true;
|
|
319
294
|
const errorTitle = (0, agent_namespaceObject.typeStr)(task);
|
|
320
295
|
const errorMsg = task.errorMessage || 'unknown error';
|
|
@@ -325,9 +300,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
|
|
|
325
300
|
camera: fullPageCameraState,
|
|
326
301
|
duration: stillDuration,
|
|
327
302
|
title: errorTitle,
|
|
328
|
-
subTitle: errorSubTitle
|
|
329
|
-
imageWidth: (null == (_task_uiContext8 = task.uiContext) ? void 0 : null == (_task_uiContext_size8 = _task_uiContext8.size) ? void 0 : _task_uiContext_size8.width) || imageWidth,
|
|
330
|
-
imageHeight: (null == (_task_uiContext9 = task.uiContext) ? void 0 : null == (_task_uiContext_size9 = _task_uiContext9.size) ? void 0 : _task_uiContext_size9.height) || imageHeight
|
|
303
|
+
subTitle: errorSubTitle
|
|
331
304
|
});
|
|
332
305
|
return;
|
|
333
306
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { InfoListItem, StorageProvider } from '../../../types';
|
|
2
|
-
import { MemoryStorageProvider as IndexedDBMemoryStorageProvider, NoOpStorageProvider as IndexedDBNoOpStorageProvider, IndexedDBStorageProvider } from './indexeddb-storage-provider';
|
|
3
2
|
/**
|
|
4
3
|
* Local Storage implementation for playground message persistence
|
|
5
4
|
*/
|
|
@@ -41,18 +40,3 @@ export declare class NoOpStorageProvider implements StorageProvider {
|
|
|
41
40
|
clearMessages(): Promise<void>;
|
|
42
41
|
saveResult(_id: string, _result: InfoListItem): Promise<void>;
|
|
43
42
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Storage type enumeration
|
|
46
|
-
*/
|
|
47
|
-
export declare enum StorageType {
|
|
48
|
-
INDEXEDDB = "indexeddb",
|
|
49
|
-
LOCALSTORAGE = "localStorage",
|
|
50
|
-
MEMORY = "memory",
|
|
51
|
-
NONE = "none"
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Factory function to create the appropriate storage provider
|
|
55
|
-
*/
|
|
56
|
-
export declare function createStorageProvider(type?: StorageType, namespace?: string): StorageProvider;
|
|
57
|
-
export declare function detectBestStorageType(): StorageType;
|
|
58
|
-
export { IndexedDBStorageProvider, IndexedDBMemoryStorageProvider, IndexedDBNoOpStorageProvider, };
|
|
@@ -3,7 +3,7 @@ import type { FormValue, InfoListItem, PlaygroundSDKLike, StorageProvider } from
|
|
|
3
3
|
/**
|
|
4
4
|
* Hook for handling playground execution logic
|
|
5
5
|
*/
|
|
6
|
-
export declare function usePlaygroundExecution(playgroundSDK: PlaygroundSDKLike | null, storage: StorageProvider | undefined
|
|
6
|
+
export declare function usePlaygroundExecution(playgroundSDK: PlaygroundSDKLike | null, storage: StorageProvider | undefined, actionSpace: DeviceAction<unknown>[], loading: boolean, setLoading: (loading: boolean) => void, infoList: InfoListItem[], setInfoList: React.Dispatch<React.SetStateAction<InfoListItem[]>>, replayCounter: number, setReplayCounter: React.Dispatch<React.SetStateAction<number>>, verticalMode: boolean, currentRunningIdRef: React.MutableRefObject<number | null>, interruptedFlagRef: React.MutableRefObject<Record<number, boolean>>): {
|
|
7
7
|
handleRun: (value: FormValue) => Promise<void>;
|
|
8
8
|
handleStop: () => Promise<void>;
|
|
9
9
|
canStop: boolean;
|
|
@@ -3,7 +3,7 @@ import type { ContextProvider, InfoListItem, PlaygroundSDKLike, StorageProvider
|
|
|
3
3
|
/**
|
|
4
4
|
* Hook for managing playground state
|
|
5
5
|
*/
|
|
6
|
-
export declare function usePlaygroundState(playgroundSDK: PlaygroundSDKLike | null, storage?: StorageProvider
|
|
6
|
+
export declare function usePlaygroundState(playgroundSDK: PlaygroundSDKLike | null, storage?: StorageProvider, contextProvider?: ContextProvider): {
|
|
7
7
|
loading: boolean;
|
|
8
8
|
setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
9
9
|
infoList: InfoListItem[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export { timeStr, filterBase64Value } from './utils';
|
|
|
23
23
|
export { default as ShinyText } from './component/shiny-text';
|
|
24
24
|
export { UniversalPlayground, default as UniversalPlaygroundDefault, } from './component/universal-playground';
|
|
25
25
|
export type { UniversalPlaygroundProps, PlaygroundSDKLike, StorageProvider, ContextProvider, UniversalPlaygroundConfig, PlaygroundBranding, InfoListItem, FormValue, ExecutionOptions, ProgressCallback, } from './types';
|
|
26
|
-
export { LocalStorageProvider, MemoryStorageProvider, NoOpStorageProvider,
|
|
26
|
+
export { LocalStorageProvider, MemoryStorageProvider, NoOpStorageProvider, } from './component/universal-playground/providers/storage-provider';
|
|
27
27
|
export { BaseContextProvider, AgentContextProvider, StaticContextProvider, NoOpContextProvider, } from './component/universal-playground/providers/context-provider';
|
|
@@ -18,8 +18,6 @@ export interface AnimationScript {
|
|
|
18
18
|
insightCameraDuration?: number;
|
|
19
19
|
title?: string;
|
|
20
20
|
subTitle?: string;
|
|
21
|
-
imageWidth?: number;
|
|
22
|
-
imageHeight?: number;
|
|
23
21
|
}
|
|
24
22
|
export declare const cameraStateForRect: (rect: Rect, imageWidth: number, imageHeight: number) => TargetCameraState;
|
|
25
23
|
export declare const mergeTwoCameraState: (cameraState1: TargetCameraState, cameraState2: TargetCameraState) => TargetCameraState;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/visualizer",
|
|
3
|
-
"version": "0.28.10-beta-
|
|
3
|
+
"version": "0.28.10-beta-20250919094051.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",
|
|
@@ -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.10-beta-
|
|
74
|
-
"@midscene/shared": "0.28.10-beta-
|
|
75
|
-
"@midscene/
|
|
76
|
-
"@midscene/
|
|
73
|
+
"@midscene/core": "0.28.10-beta-20250919094051.0",
|
|
74
|
+
"@midscene/shared": "0.28.10-beta-20250919094051.0",
|
|
75
|
+
"@midscene/web": "0.28.10-beta-20250919094051.0",
|
|
76
|
+
"@midscene/playground": "0.28.10-beta-20250919094051.0"
|
|
77
77
|
},
|
|
78
78
|
"license": "MIT",
|
|
79
79
|
"scripts": {
|