@midscene/visualizer 0.28.2-beta-20250910020051.0 → 0.28.2-beta-20250910024129.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/{blackboard/index.mjs → blackboard.mjs} +3 -3
- package/dist/es/component/describer.css +25 -0
- package/dist/es/component/{env-config/index.mjs → env-config.mjs} +1 -1
- package/dist/es/component/{github-star/index.mjs → github-star.mjs} +1 -1
- package/dist/es/component/{logo/index.mjs → logo.mjs} +1 -1
- package/dist/es/component/{misc/index.mjs → misc.mjs} +2 -42
- package/dist/es/component/{player/index.mjs → player.mjs} +8 -8
- package/dist/es/component/{config-selector/index.mjs → playground/ConfigSelector.mjs} +3 -2
- package/dist/es/component/{context-preview/index.mjs → playground/ContextPreview.mjs} +4 -3
- package/dist/es/component/{history-selector/index.mjs → playground/HistorySelector.mjs} +1 -1
- package/dist/es/component/{playground-result/index.mjs → playground/PlaygroundResult.mjs} +4 -3
- package/dist/es/component/{prompt-input/index.mjs → playground/PromptInput.mjs} +9 -9
- package/dist/es/component/{service-mode-control/index.mjs → playground/ServiceModeControl.mjs} +5 -4
- package/dist/es/component/playground/index.css +161 -29
- package/dist/es/{utils/constants.mjs → component/playground/playground-constants.mjs} +2 -1
- package/dist/es/component/playground/playground-types.mjs +0 -0
- package/dist/es/{utils → component/playground}/playground-utils.mjs +1 -1
- package/dist/es/{types.mjs → component/playground/types.mjs} +1 -23
- package/dist/es/{utils → component}/replay-scripts.mjs +2 -1
- package/dist/es/component/{shiny-text/index.mjs → shiny-text.mjs} +1 -1
- package/dist/es/index.mjs +18 -22
- package/dist/es/init.mjs +10 -0
- package/dist/lib/component/{blackboard/index.js → blackboard.js} +5 -5
- package/dist/lib/component/describer.css +25 -0
- package/dist/lib/component/{env-config/index.js → env-config.js} +1 -1
- package/dist/lib/component/{github-star/index.js → github-star.js} +1 -1
- package/dist/lib/component/{logo/index.js → logo.js} +1 -1
- package/dist/lib/component/{misc/index.js → misc.js} +1 -60
- package/dist/lib/component/{player/index.js → player.js} +23 -23
- package/dist/lib/component/{config-selector/index.js → playground/ConfigSelector.js} +7 -6
- package/dist/lib/component/{context-preview/index.js → playground/ContextPreview.js} +9 -8
- package/dist/lib/component/{history-selector/index.js → playground/HistorySelector.js} +1 -1
- package/dist/lib/component/{playground-result/index.js → playground/PlaygroundResult.js} +9 -8
- package/dist/lib/component/{prompt-input/index.js → playground/PromptInput.js} +37 -37
- package/dist/lib/component/{service-mode-control/index.js → playground/ServiceModeControl.js} +9 -8
- package/dist/lib/component/playground/index.css +161 -29
- package/dist/lib/{utils/constants.js → component/playground/playground-constants.js} +4 -3
- package/dist/lib/component/playground/playground-types.js +18 -0
- package/dist/lib/{utils → component/playground}/playground-utils.js +1 -1
- package/dist/lib/{types.js → component/playground/types.js} +0 -28
- package/dist/lib/{utils → component}/replay-scripts.js +4 -3
- package/dist/lib/component/{shiny-text/index.js → shiny-text.js} +1 -1
- package/dist/lib/index.js +34 -66
- package/dist/lib/{icons/avatar.js → init.js} +12 -16
- package/dist/types/component/{blackboard/index.d.ts → blackboard.d.ts} +2 -2
- package/dist/types/component/{github-star/index.d.ts → github-star.d.ts} +1 -1
- package/dist/types/component/{logo/index.d.ts → logo.d.ts} +1 -1
- package/dist/types/component/misc.d.ts +2 -0
- package/dist/types/component/{player/index.d.ts → player.d.ts} +2 -2
- package/dist/types/component/{config-selector/index.d.ts → playground/ConfigSelector.d.ts} +1 -0
- package/dist/types/component/{context-preview/index.d.ts → playground/ContextPreview.d.ts} +1 -0
- package/dist/types/component/{history-selector/index.d.ts → playground/HistorySelector.d.ts} +1 -1
- package/dist/types/component/{playground-result/index.d.ts → playground/PlaygroundResult.d.ts} +4 -3
- package/dist/types/component/{prompt-input/index.d.ts → playground/PromptInput.d.ts} +2 -3
- package/dist/types/component/{service-mode-control/index.d.ts → playground/ServiceModeControl.d.ts} +1 -0
- package/dist/types/{utils/constants.d.ts → component/playground/playground-constants.d.ts} +1 -0
- package/dist/types/component/playground/playground-types.d.ts +19 -0
- package/dist/types/component/playground/types.d.ts +72 -0
- package/dist/types/{utils → component}/replay-scripts.d.ts +1 -0
- package/dist/types/component/{shiny-text/index.d.ts → shiny-text.d.ts} +1 -1
- package/dist/types/index.d.ts +10 -15
- package/dist/types/init.d.ts +1 -0
- package/package.json +5 -10
- package/dist/es/browser.mjs +0 -18
- package/dist/es/component/history-selector/index.css +0 -132
- package/dist/es/component/index.mjs +0 -1
- package/dist/es/component/playground/index.mjs +0 -8
- package/dist/es/component/playground-result/index.css +0 -29
- package/dist/es/component/prompt-input/index.css +0 -330
- package/dist/es/component/universal-playground/index.css +0 -341
- package/dist/es/component/universal-playground/index.mjs +0 -273
- package/dist/es/component/universal-playground/providers/context-provider.mjs +0 -52
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +0 -107
- package/dist/es/hooks/usePlaygroundExecution.mjs +0 -170
- package/dist/es/hooks/usePlaygroundState.mjs +0 -173
- package/dist/es/icons/avatar.mjs +0 -14
- package/dist/lib/browser.js +0 -132
- package/dist/lib/component/history-selector/index.css +0 -132
- package/dist/lib/component/index.js +0 -60
- package/dist/lib/component/playground/index.js +0 -113
- package/dist/lib/component/playground-result/index.css +0 -29
- package/dist/lib/component/prompt-input/index.css +0 -330
- package/dist/lib/component/universal-playground/index.css +0 -341
- package/dist/lib/component/universal-playground/index.js +0 -321
- package/dist/lib/component/universal-playground/providers/context-provider.js +0 -95
- package/dist/lib/component/universal-playground/providers/storage-provider.js +0 -147
- package/dist/lib/hooks/usePlaygroundExecution.js +0 -204
- package/dist/lib/hooks/usePlaygroundState.js +0 -207
- package/dist/types/browser.d.ts +0 -19
- package/dist/types/component/index.d.ts +0 -1
- package/dist/types/component/misc/index.d.ts +0 -6
- package/dist/types/component/playground/index.d.ts +0 -7
- package/dist/types/component/universal-playground/index.d.ts +0 -4
- package/dist/types/component/universal-playground/providers/context-provider.d.ts +0 -37
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +0 -33
- package/dist/types/hooks/usePlaygroundExecution.d.ts +0 -10
- package/dist/types/hooks/usePlaygroundState.d.ts +0 -26
- package/dist/types/types.d.ts +0 -166
- /package/dist/es/component/{blackboard/index.css → blackboard.css} +0 -0
- /package/dist/es/{utils → component}/color.mjs +0 -0
- /package/dist/es/component/{github-star/index.css → github-star.css} +0 -0
- /package/dist/es/component/{logo/index.css → logo.css} +0 -0
- /package/dist/es/{utils → component}/pixi-loader.mjs +0 -0
- /package/dist/es/component/{player/index.css → player.css} +0 -0
- /package/dist/es/component/{form-field/index.mjs → playground/FormField.mjs} +0 -0
- /package/dist/es/{hooks → component/playground}/useServerValid.mjs +0 -0
- /package/dist/es/component/{playground/playground-demo-ui-context.json → playground-demo-ui-context.json} +0 -0
- /package/dist/es/component/{shiny-text/index.css → shiny-text.css} +0 -0
- /package/dist/es/{store → component/store}/history.mjs +0 -0
- /package/dist/es/{store → component/store}/store.mjs +0 -0
- /package/dist/es/{utils/index.mjs → utils.mjs} +0 -0
- /package/dist/lib/component/{blackboard/index.css → blackboard.css} +0 -0
- /package/dist/lib/{utils → component}/color.js +0 -0
- /package/dist/lib/component/{github-star/index.css → github-star.css} +0 -0
- /package/dist/lib/component/{logo/index.css → logo.css} +0 -0
- /package/dist/lib/{utils → component}/pixi-loader.js +0 -0
- /package/dist/lib/component/{player/index.css → player.css} +0 -0
- /package/dist/lib/component/{form-field/index.js → playground/FormField.js} +0 -0
- /package/dist/lib/{hooks → component/playground}/useServerValid.js +0 -0
- /package/dist/lib/component/{playground/playground-demo-ui-context.json → playground-demo-ui-context.json} +0 -0
- /package/dist/lib/component/{shiny-text/index.css → shiny-text.css} +0 -0
- /package/dist/lib/{store → component/store}/history.js +0 -0
- /package/dist/lib/{store → component/store}/store.js +0 -0
- /package/dist/lib/{utils/index.js → utils.js} +0 -0
- /package/dist/types/{utils → component}/color.d.ts +0 -0
- /package/dist/types/component/{env-config/index.d.ts → env-config.d.ts} +0 -0
- /package/dist/types/{utils → component}/pixi-loader.d.ts +0 -0
- /package/dist/types/component/{form-field/index.d.ts → playground/FormField.d.ts} +0 -0
- /package/dist/types/{utils → component/playground}/playground-utils.d.ts +0 -0
- /package/dist/types/{hooks → component/playground}/useServerValid.d.ts +0 -0
- /package/dist/types/{store → component/store}/history.d.ts +0 -0
- /package/dist/types/{store → component/store}/store.d.ts +0 -0
- /package/dist/types/{utils/index.d.ts → utils.d.ts} +0 -0
|
@@ -1,204 +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
|
-
usePlaygroundExecution: ()=>usePlaygroundExecution
|
|
28
|
-
});
|
|
29
|
-
const external_react_namespaceObject = require("react");
|
|
30
|
-
const external_types_js_namespaceObject = require("../types.js");
|
|
31
|
-
const replay_scripts_js_namespaceObject = require("../utils/replay-scripts.js");
|
|
32
|
-
const noReplayAPIs = [
|
|
33
|
-
'aiQuery',
|
|
34
|
-
'aiAssert'
|
|
35
|
-
];
|
|
36
|
-
function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, infoList, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef) {
|
|
37
|
-
const handleRun = (0, external_react_namespaceObject.useCallback)(async (value)=>{
|
|
38
|
-
Date.now();
|
|
39
|
-
null == actionSpace || actionSpace.find((a)=>a.interfaceAlias === value.type || a.name === value.type);
|
|
40
|
-
const thisRunningId = Date.now();
|
|
41
|
-
const actionType = value.type;
|
|
42
|
-
const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
|
|
43
|
-
const userItem = {
|
|
44
|
-
id: `user-${Date.now()}`,
|
|
45
|
-
type: 'user',
|
|
46
|
-
content: displayContent,
|
|
47
|
-
timestamp: new Date()
|
|
48
|
-
};
|
|
49
|
-
setInfoList((prev)=>[
|
|
50
|
-
...prev,
|
|
51
|
-
userItem
|
|
52
|
-
]);
|
|
53
|
-
setLoading(true);
|
|
54
|
-
const result = {
|
|
55
|
-
...external_types_js_namespaceObject.BLANK_RESULT
|
|
56
|
-
};
|
|
57
|
-
const systemItem = {
|
|
58
|
-
id: `system-${thisRunningId}`,
|
|
59
|
-
type: 'system',
|
|
60
|
-
content: '',
|
|
61
|
-
timestamp: new Date(),
|
|
62
|
-
loading: true,
|
|
63
|
-
loadingProgressText: ''
|
|
64
|
-
};
|
|
65
|
-
setInfoList((prev)=>[
|
|
66
|
-
...prev,
|
|
67
|
-
systemItem
|
|
68
|
-
]);
|
|
69
|
-
try {
|
|
70
|
-
currentRunningIdRef.current = thisRunningId;
|
|
71
|
-
interruptedFlagRef.current[thisRunningId] = false;
|
|
72
|
-
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate((tip)=>{
|
|
73
|
-
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
74
|
-
const progressItem = {
|
|
75
|
-
id: `progress-${thisRunningId}-${Date.now()}`,
|
|
76
|
-
type: 'progress',
|
|
77
|
-
content: tip,
|
|
78
|
-
timestamp: new Date()
|
|
79
|
-
};
|
|
80
|
-
setInfoList((prev)=>[
|
|
81
|
-
...prev,
|
|
82
|
-
progressItem
|
|
83
|
-
]);
|
|
84
|
-
});
|
|
85
|
-
result.result = await playgroundSDK.executeAction(actionType, value, {
|
|
86
|
-
requestId: thisRunningId.toString()
|
|
87
|
-
});
|
|
88
|
-
if ('object' == typeof result.result && null !== result.result) {
|
|
89
|
-
const resultObj = result.result;
|
|
90
|
-
if (resultObj.dump) result.dump = resultObj.dump;
|
|
91
|
-
if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
|
|
92
|
-
if (resultObj.error) result.error = resultObj.error;
|
|
93
|
-
if (void 0 !== resultObj.result) result.result = resultObj.result;
|
|
94
|
-
}
|
|
95
|
-
} catch (e) {
|
|
96
|
-
result.error = (null == e ? void 0 : e.message) || String(e);
|
|
97
|
-
console.error('Playground execution error:', e);
|
|
98
|
-
}
|
|
99
|
-
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
100
|
-
setLoading(false);
|
|
101
|
-
currentRunningIdRef.current = null;
|
|
102
|
-
let replayInfo = null;
|
|
103
|
-
let counter = replayCounter;
|
|
104
|
-
if ((null == result ? void 0 : result.dump) && !noReplayAPIs.includes(actionType)) {
|
|
105
|
-
const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(result.dump);
|
|
106
|
-
setReplayCounter((c)=>c + 1);
|
|
107
|
-
replayInfo = info;
|
|
108
|
-
counter = replayCounter + 1;
|
|
109
|
-
}
|
|
110
|
-
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? {
|
|
111
|
-
...item,
|
|
112
|
-
content: '',
|
|
113
|
-
loading: false,
|
|
114
|
-
loadingProgressText: ''
|
|
115
|
-
} : item));
|
|
116
|
-
const resultItem = {
|
|
117
|
-
id: `result-${thisRunningId}`,
|
|
118
|
-
type: 'result',
|
|
119
|
-
content: 'Execution result',
|
|
120
|
-
timestamp: new Date(),
|
|
121
|
-
result: result,
|
|
122
|
-
loading: false,
|
|
123
|
-
replayScriptsInfo: replayInfo,
|
|
124
|
-
replayCounter: counter,
|
|
125
|
-
loadingProgressText: '',
|
|
126
|
-
verticalMode: verticalMode
|
|
127
|
-
};
|
|
128
|
-
setInfoList((prev)=>[
|
|
129
|
-
...prev,
|
|
130
|
-
resultItem
|
|
131
|
-
]);
|
|
132
|
-
if (null == storage ? void 0 : storage.saveResult) try {
|
|
133
|
-
await storage.saveResult(resultItem.id, resultItem);
|
|
134
|
-
} catch (error) {
|
|
135
|
-
console.error('Failed to save result:', error);
|
|
136
|
-
}
|
|
137
|
-
const separatorItem = {
|
|
138
|
-
id: `separator-${thisRunningId}`,
|
|
139
|
-
type: 'separator',
|
|
140
|
-
content: 'New Session',
|
|
141
|
-
timestamp: new Date()
|
|
142
|
-
};
|
|
143
|
-
setInfoList((prev)=>[
|
|
144
|
-
...prev,
|
|
145
|
-
separatorItem
|
|
146
|
-
]);
|
|
147
|
-
}, [
|
|
148
|
-
playgroundSDK,
|
|
149
|
-
storage,
|
|
150
|
-
actionSpace,
|
|
151
|
-
setLoading,
|
|
152
|
-
setInfoList,
|
|
153
|
-
replayCounter,
|
|
154
|
-
setReplayCounter,
|
|
155
|
-
verticalMode,
|
|
156
|
-
currentRunningIdRef,
|
|
157
|
-
interruptedFlagRef
|
|
158
|
-
]);
|
|
159
|
-
const handleStop = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
160
|
-
const thisRunningId = currentRunningIdRef.current;
|
|
161
|
-
if (thisRunningId && playgroundSDK.cancelExecution) try {
|
|
162
|
-
await playgroundSDK.cancelExecution(thisRunningId.toString());
|
|
163
|
-
interruptedFlagRef.current[thisRunningId] = true;
|
|
164
|
-
setLoading(false);
|
|
165
|
-
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` && item.loading ? {
|
|
166
|
-
...item,
|
|
167
|
-
content: 'Operation stopped',
|
|
168
|
-
loading: false,
|
|
169
|
-
loadingProgressText: ''
|
|
170
|
-
} : item));
|
|
171
|
-
const separatorItem = {
|
|
172
|
-
id: `separator-${thisRunningId}`,
|
|
173
|
-
type: 'separator',
|
|
174
|
-
content: 'New Session',
|
|
175
|
-
timestamp: new Date()
|
|
176
|
-
};
|
|
177
|
-
setInfoList((prev)=>[
|
|
178
|
-
...prev,
|
|
179
|
-
separatorItem
|
|
180
|
-
]);
|
|
181
|
-
} catch (error) {
|
|
182
|
-
console.error('Failed to stop execution:', error);
|
|
183
|
-
}
|
|
184
|
-
}, [
|
|
185
|
-
playgroundSDK,
|
|
186
|
-
currentRunningIdRef,
|
|
187
|
-
interruptedFlagRef,
|
|
188
|
-
setLoading,
|
|
189
|
-
setInfoList
|
|
190
|
-
]);
|
|
191
|
-
const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK.cancelExecution;
|
|
192
|
-
return {
|
|
193
|
-
handleRun,
|
|
194
|
-
handleStop,
|
|
195
|
-
canStop
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
exports.usePlaygroundExecution = __webpack_exports__.usePlaygroundExecution;
|
|
199
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
200
|
-
"usePlaygroundExecution"
|
|
201
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
202
|
-
Object.defineProperty(exports, '__esModule', {
|
|
203
|
-
value: true
|
|
204
|
-
});
|
|
@@ -1,207 +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
|
-
usePlaygroundState: ()=>usePlaygroundState
|
|
28
|
-
});
|
|
29
|
-
const external_react_namespaceObject = require("react");
|
|
30
|
-
const external_types_js_namespaceObject = require("../types.js");
|
|
31
|
-
function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
32
|
-
const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
33
|
-
const [infoList, setInfoList] = (0, external_react_namespaceObject.useState)([]);
|
|
34
|
-
const [actionSpace, setActionSpace] = (0, external_react_namespaceObject.useState)([]);
|
|
35
|
-
const [actionSpaceLoading, setActionSpaceLoading] = (0, external_react_namespaceObject.useState)(true);
|
|
36
|
-
const [uiContextPreview, setUiContextPreview] = (0, external_react_namespaceObject.useState)();
|
|
37
|
-
const [showScrollToBottomButton, setShowScrollToBottomButton] = (0, external_react_namespaceObject.useState)(false);
|
|
38
|
-
const [verticalMode, setVerticalMode] = (0, external_react_namespaceObject.useState)(false);
|
|
39
|
-
const [replayCounter, setReplayCounter] = (0, external_react_namespaceObject.useState)(0);
|
|
40
|
-
const infoListRef = (0, external_react_namespaceObject.useRef)(null);
|
|
41
|
-
const currentRunningIdRef = (0, external_react_namespaceObject.useRef)(null);
|
|
42
|
-
const interruptedFlagRef = (0, external_react_namespaceObject.useRef)({});
|
|
43
|
-
const welcomeMessage = {
|
|
44
|
-
...external_types_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
|
|
45
|
-
id: 'welcome',
|
|
46
|
-
timestamp: new Date()
|
|
47
|
-
};
|
|
48
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
49
|
-
const initializeMessages = async ()=>{
|
|
50
|
-
if (null == storage ? void 0 : storage.loadMessages) try {
|
|
51
|
-
const storedMessages = await storage.loadMessages();
|
|
52
|
-
setInfoList([
|
|
53
|
-
welcomeMessage,
|
|
54
|
-
...storedMessages
|
|
55
|
-
]);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.error('Failed to load messages:', error);
|
|
58
|
-
setInfoList([
|
|
59
|
-
welcomeMessage
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
else setInfoList([
|
|
63
|
-
welcomeMessage
|
|
64
|
-
]);
|
|
65
|
-
};
|
|
66
|
-
initializeMessages();
|
|
67
|
-
}, [
|
|
68
|
-
storage
|
|
69
|
-
]);
|
|
70
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
71
|
-
if ((null == storage ? void 0 : storage.saveMessages) && infoList.length > 1) storage.saveMessages(infoList).catch((error)=>{
|
|
72
|
-
console.error('Failed to save messages:', error);
|
|
73
|
-
});
|
|
74
|
-
}, [
|
|
75
|
-
infoList,
|
|
76
|
-
storage
|
|
77
|
-
]);
|
|
78
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
79
|
-
if (!(null == contextProvider ? void 0 : contextProvider.getUIContext) || uiContextPreview) return;
|
|
80
|
-
contextProvider.getUIContext().then((context)=>setUiContextPreview(context)).catch((error)=>{
|
|
81
|
-
console.error('Failed to get UI context:', error);
|
|
82
|
-
});
|
|
83
|
-
}, [
|
|
84
|
-
contextProvider,
|
|
85
|
-
uiContextPreview
|
|
86
|
-
]);
|
|
87
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
88
|
-
const loadActionSpace = async ()=>{
|
|
89
|
-
setActionSpaceLoading(true);
|
|
90
|
-
try {
|
|
91
|
-
var _contextProvider_getUIContext;
|
|
92
|
-
const context = uiContextPreview || await (null == contextProvider ? void 0 : null == (_contextProvider_getUIContext = contextProvider.getUIContext) ? void 0 : _contextProvider_getUIContext.call(contextProvider));
|
|
93
|
-
const space = await playgroundSDK.getActionSpace(context);
|
|
94
|
-
setActionSpace(space || []);
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.error('Failed to load action space:', error);
|
|
97
|
-
setActionSpace([]);
|
|
98
|
-
} finally{
|
|
99
|
-
setActionSpaceLoading(false);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
loadActionSpace();
|
|
103
|
-
}, [
|
|
104
|
-
playgroundSDK,
|
|
105
|
-
uiContextPreview,
|
|
106
|
-
contextProvider
|
|
107
|
-
]);
|
|
108
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
109
|
-
const sizeThreshold = 750;
|
|
110
|
-
setVerticalMode(window.innerWidth < sizeThreshold);
|
|
111
|
-
const handleResize = ()=>{
|
|
112
|
-
setVerticalMode(window.innerWidth < sizeThreshold);
|
|
113
|
-
};
|
|
114
|
-
window.addEventListener('resize', handleResize);
|
|
115
|
-
return ()=>window.removeEventListener('resize', handleResize);
|
|
116
|
-
}, []);
|
|
117
|
-
const scrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
118
|
-
setTimeout(()=>{
|
|
119
|
-
if (infoListRef.current) infoListRef.current.scrollTop = infoListRef.current.scrollHeight;
|
|
120
|
-
}, 100);
|
|
121
|
-
}, []);
|
|
122
|
-
const checkIfScrolledToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
123
|
-
if (infoListRef.current) {
|
|
124
|
-
const { scrollTop, scrollHeight, clientHeight } = infoListRef.current;
|
|
125
|
-
const isAtBottom = scrollTop + clientHeight >= scrollHeight - 10;
|
|
126
|
-
setShowScrollToBottomButton(!isAtBottom);
|
|
127
|
-
}
|
|
128
|
-
}, []);
|
|
129
|
-
const handleScrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
130
|
-
if (infoListRef.current) {
|
|
131
|
-
infoListRef.current.scrollTo({
|
|
132
|
-
top: infoListRef.current.scrollHeight,
|
|
133
|
-
behavior: 'smooth'
|
|
134
|
-
});
|
|
135
|
-
setShowScrollToBottomButton(false);
|
|
136
|
-
}
|
|
137
|
-
}, []);
|
|
138
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
139
|
-
if (infoList.length > 0) scrollToBottom();
|
|
140
|
-
}, [
|
|
141
|
-
infoList,
|
|
142
|
-
scrollToBottom
|
|
143
|
-
]);
|
|
144
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
145
|
-
const container = infoListRef.current;
|
|
146
|
-
if (container) {
|
|
147
|
-
container.addEventListener('scroll', checkIfScrolledToBottom);
|
|
148
|
-
checkIfScrolledToBottom();
|
|
149
|
-
return ()=>{
|
|
150
|
-
container.removeEventListener('scroll', checkIfScrolledToBottom);
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}, [
|
|
154
|
-
checkIfScrolledToBottom
|
|
155
|
-
]);
|
|
156
|
-
const clearInfoList = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
157
|
-
setInfoList([
|
|
158
|
-
welcomeMessage
|
|
159
|
-
]);
|
|
160
|
-
if (null == storage ? void 0 : storage.clearMessages) try {
|
|
161
|
-
await storage.clearMessages();
|
|
162
|
-
} catch (error) {
|
|
163
|
-
console.error('Failed to clear stored messages:', error);
|
|
164
|
-
}
|
|
165
|
-
}, [
|
|
166
|
-
storage,
|
|
167
|
-
welcomeMessage
|
|
168
|
-
]);
|
|
169
|
-
const refreshContext = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
170
|
-
if (null == contextProvider ? void 0 : contextProvider.refreshContext) try {
|
|
171
|
-
const newContext = await contextProvider.refreshContext();
|
|
172
|
-
setUiContextPreview(newContext);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
console.error('Failed to refresh context:', error);
|
|
175
|
-
}
|
|
176
|
-
}, [
|
|
177
|
-
contextProvider
|
|
178
|
-
]);
|
|
179
|
-
return {
|
|
180
|
-
loading,
|
|
181
|
-
setLoading,
|
|
182
|
-
infoList,
|
|
183
|
-
setInfoList,
|
|
184
|
-
actionSpace,
|
|
185
|
-
actionSpaceLoading,
|
|
186
|
-
uiContextPreview,
|
|
187
|
-
setUiContextPreview,
|
|
188
|
-
showScrollToBottomButton,
|
|
189
|
-
verticalMode,
|
|
190
|
-
replayCounter,
|
|
191
|
-
setReplayCounter,
|
|
192
|
-
infoListRef,
|
|
193
|
-
currentRunningIdRef,
|
|
194
|
-
interruptedFlagRef,
|
|
195
|
-
clearInfoList,
|
|
196
|
-
refreshContext,
|
|
197
|
-
handleScrollToBottom,
|
|
198
|
-
scrollToBottom
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
exports.usePlaygroundState = __webpack_exports__.usePlaygroundState;
|
|
202
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
203
|
-
"usePlaygroundState"
|
|
204
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
205
|
-
Object.defineProperty(exports, '__esModule', {
|
|
206
|
-
value: true
|
|
207
|
-
});
|
package/dist/types/browser.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import './component/index.less';
|
|
2
|
-
import './component/universal-playground/index.less';
|
|
3
|
-
export { useEnvConfig } from './store/store';
|
|
4
|
-
export { colorForName, highlightColorForType, globalThemeConfig, } from './utils/color';
|
|
5
|
-
export { EnvConfig } from './component/env-config';
|
|
6
|
-
export { Logo } from './component/logo';
|
|
7
|
-
export { iconForStatus, timeCostStrElement } from './component/misc';
|
|
8
|
-
export { PlaygroundResultView } from './component/playground-result';
|
|
9
|
-
export type { PlaygroundResult } from './types';
|
|
10
|
-
export { ContextPreview } from './component/context-preview';
|
|
11
|
-
export { Player } from './component/player';
|
|
12
|
-
export { Blackboard } from './component/blackboard';
|
|
13
|
-
export { GithubStar } from './component/github-star';
|
|
14
|
-
export { timeStr, filterBase64Value } from './utils';
|
|
15
|
-
export { default as ShinyText } from './component/shiny-text';
|
|
16
|
-
export { UniversalPlayground, default as UniversalPlaygroundDefault, } from './component/universal-playground';
|
|
17
|
-
export type { UniversalPlaygroundProps, PlaygroundSDKLike, StorageProvider, ContextProvider, UniversalPlaygroundConfig, PlaygroundBranding, InfoListItem, FormValue, ExecutionOptions, ProgressCallback, } from './types';
|
|
18
|
-
export { LocalStorageProvider, MemoryStorageProvider, NoOpStorageProvider, } from './component/universal-playground/providers/storage-provider';
|
|
19
|
-
export { BaseContextProvider, StaticContextProvider, NoOpContextProvider, } from './component/universal-playground/providers/context-provider';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../types';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
export declare function timeCostStrElement(timeCost?: number): React.JSX.Element;
|
|
3
|
-
export declare const iconForStatus: (status: string) => React.JSX.Element;
|
|
4
|
-
export declare const errorMessageServerNotReady: React.JSX.Element;
|
|
5
|
-
export declare const serverLaunchTip: (notReadyMessage?: React.ReactNode | string) => React.JSX.Element;
|
|
6
|
-
export declare const emptyResultTip: React.JSX.Element;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { ContextPreview } from '../context-preview';
|
|
2
|
-
export { PlaygroundResultView } from '../playground-result';
|
|
3
|
-
export { PromptInput } from '../prompt-input';
|
|
4
|
-
export { useServerValid } from '../../hooks/useServerValid';
|
|
5
|
-
export { ServiceModeControl } from '../service-mode-control';
|
|
6
|
-
export * from '../../types';
|
|
7
|
-
export { useEnvConfig } from '../../store/store';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { UniversalPlaygroundProps } from '../../types';
|
|
2
|
-
import './index.less';
|
|
3
|
-
export declare function UniversalPlayground({ playgroundSDK, storage, contextProvider, config: componentConfig, branding, className, dryMode, showContextPreview, }: UniversalPlaygroundProps): import("react").JSX.Element;
|
|
4
|
-
export default UniversalPlayground;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { UIContext } from '@midscene/core';
|
|
2
|
-
import type { ContextProvider } from '../../../types';
|
|
3
|
-
/**
|
|
4
|
-
* Base context provider implementation
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class BaseContextProvider implements ContextProvider {
|
|
7
|
-
protected cachedContext?: UIContext;
|
|
8
|
-
abstract getUIContext(): Promise<UIContext>;
|
|
9
|
-
refreshContext(): Promise<UIContext>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Agent-based context provider for local execution modes
|
|
13
|
-
*/
|
|
14
|
-
export declare class AgentContextProvider extends BaseContextProvider {
|
|
15
|
-
private getAgent;
|
|
16
|
-
private options?;
|
|
17
|
-
constructor(getAgent: () => any, options?: {
|
|
18
|
-
forceSameTabNavigation?: boolean;
|
|
19
|
-
} | undefined);
|
|
20
|
-
getUIContext(): Promise<UIContext>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Static context provider for pre-determined UI contexts
|
|
24
|
-
*/
|
|
25
|
-
export declare class StaticContextProvider extends BaseContextProvider {
|
|
26
|
-
private context;
|
|
27
|
-
constructor(context: UIContext);
|
|
28
|
-
getUIContext(): Promise<UIContext>;
|
|
29
|
-
refreshContext(): Promise<UIContext>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* No-op context provider for cases where context preview is disabled
|
|
33
|
-
*/
|
|
34
|
-
export declare class NoOpContextProvider implements ContextProvider {
|
|
35
|
-
getUIContext(): Promise<UIContext>;
|
|
36
|
-
refreshContext(): Promise<UIContext>;
|
|
37
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { InfoListItem, StorageProvider } from '../../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Local Storage implementation for playground message persistence
|
|
4
|
-
*/
|
|
5
|
-
export declare class LocalStorageProvider implements StorageProvider {
|
|
6
|
-
private readonly messagesKey;
|
|
7
|
-
private readonly resultsKey;
|
|
8
|
-
constructor(namespace?: string);
|
|
9
|
-
saveMessages(messages: InfoListItem[]): Promise<void>;
|
|
10
|
-
loadMessages(): Promise<InfoListItem[]>;
|
|
11
|
-
clearMessages(): Promise<void>;
|
|
12
|
-
saveResult(id: string, result: InfoListItem): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Memory-only storage implementation for non-persistent scenarios
|
|
16
|
-
*/
|
|
17
|
-
export declare class MemoryStorageProvider implements StorageProvider {
|
|
18
|
-
private messages;
|
|
19
|
-
private results;
|
|
20
|
-
saveMessages(messages: InfoListItem[]): Promise<void>;
|
|
21
|
-
loadMessages(): Promise<InfoListItem[]>;
|
|
22
|
-
clearMessages(): Promise<void>;
|
|
23
|
-
saveResult(id: string, result: InfoListItem): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* No-op storage implementation for cases where persistence is disabled
|
|
27
|
-
*/
|
|
28
|
-
export declare class NoOpStorageProvider implements StorageProvider {
|
|
29
|
-
saveMessages(_messages: InfoListItem[]): Promise<void>;
|
|
30
|
-
loadMessages(): Promise<InfoListItem[]>;
|
|
31
|
-
clearMessages(): Promise<void>;
|
|
32
|
-
saveResult(_id: string, _result: InfoListItem): Promise<void>;
|
|
33
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DeviceAction } from '@midscene/core';
|
|
2
|
-
import type { FormValue, InfoListItem, PlaygroundSDKLike, StorageProvider } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for handling playground execution logic
|
|
5
|
-
*/
|
|
6
|
-
export declare function usePlaygroundExecution(playgroundSDK: PlaygroundSDKLike, 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
|
-
handleRun: (value: FormValue) => Promise<void>;
|
|
8
|
-
handleStop: () => Promise<void>;
|
|
9
|
-
canStop: boolean;
|
|
10
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { DeviceAction, UIContext } from '@midscene/core';
|
|
2
|
-
import type { ContextProvider, InfoListItem, PlaygroundSDKLike, StorageProvider } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Hook for managing playground state
|
|
5
|
-
*/
|
|
6
|
-
export declare function usePlaygroundState(playgroundSDK: PlaygroundSDKLike, storage?: StorageProvider, contextProvider?: ContextProvider): {
|
|
7
|
-
loading: boolean;
|
|
8
|
-
setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
9
|
-
infoList: InfoListItem[];
|
|
10
|
-
setInfoList: import("react").Dispatch<import("react").SetStateAction<InfoListItem[]>>;
|
|
11
|
-
actionSpace: DeviceAction<unknown>[];
|
|
12
|
-
actionSpaceLoading: boolean;
|
|
13
|
-
uiContextPreview: UIContext<import("@midscene/core").BaseElement> | undefined;
|
|
14
|
-
setUiContextPreview: import("react").Dispatch<import("react").SetStateAction<UIContext<import("@midscene/core").BaseElement> | undefined>>;
|
|
15
|
-
showScrollToBottomButton: boolean;
|
|
16
|
-
verticalMode: boolean;
|
|
17
|
-
replayCounter: number;
|
|
18
|
-
setReplayCounter: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
19
|
-
infoListRef: import("react").RefObject<HTMLDivElement>;
|
|
20
|
-
currentRunningIdRef: import("react").MutableRefObject<number | null>;
|
|
21
|
-
interruptedFlagRef: import("react").MutableRefObject<Record<number, boolean>>;
|
|
22
|
-
clearInfoList: () => Promise<void>;
|
|
23
|
-
refreshContext: () => Promise<void>;
|
|
24
|
-
handleScrollToBottom: () => void;
|
|
25
|
-
scrollToBottom: () => void;
|
|
26
|
-
};
|