@midscene/visualizer 0.28.2-beta-20250910043028.0 → 0.28.2-beta-20250910065550.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.
Files changed (134) hide show
  1. package/dist/es/blank_polyfill.mjs +2 -0
  2. package/dist/es/component/{blackboard/index.mjs → blackboard.mjs} +3 -3
  3. package/dist/es/component/describer.css +25 -0
  4. package/dist/es/component/{env-config/index.mjs → env-config.mjs} +1 -1
  5. package/dist/es/component/{github-star/index.mjs → github-star.mjs} +1 -1
  6. package/dist/es/component/{logo/index.mjs → logo.mjs} +1 -1
  7. package/dist/es/component/{misc/index.mjs → misc.mjs} +2 -42
  8. package/dist/es/component/{player/index.mjs → player.mjs} +8 -8
  9. package/dist/es/component/{config-selector/index.mjs → playground/ConfigSelector.mjs} +3 -2
  10. package/dist/es/component/{context-preview/index.mjs → playground/ContextPreview.mjs} +4 -3
  11. package/dist/es/component/{history-selector/index.mjs → playground/HistorySelector.mjs} +1 -1
  12. package/dist/es/component/{playground-result/index.mjs → playground/PlaygroundResult.mjs} +4 -3
  13. package/dist/es/component/{prompt-input/index.mjs → playground/PromptInput.mjs} +9 -9
  14. package/dist/es/component/{service-mode-control/index.mjs → playground/ServiceModeControl.mjs} +5 -4
  15. package/dist/es/component/playground/index.css +161 -29
  16. package/dist/es/{utils/constants.mjs → component/playground/playground-constants.mjs} +43 -23
  17. package/dist/es/component/playground/playground-types.mjs +0 -0
  18. package/dist/es/{utils → component/playground}/playground-utils.mjs +1 -1
  19. package/dist/es/{utils → component}/replay-scripts.mjs +2 -1
  20. package/dist/es/component/{shiny-text/index.mjs → shiny-text.mjs} +1 -1
  21. package/dist/es/index.mjs +18 -22
  22. package/dist/es/init.mjs +10 -0
  23. package/dist/lib/blank_polyfill.js +36 -0
  24. package/dist/lib/component/{blackboard/index.js → blackboard.js} +5 -5
  25. package/dist/lib/component/describer.css +25 -0
  26. package/dist/lib/component/{env-config/index.js → env-config.js} +1 -1
  27. package/dist/lib/component/{github-star/index.js → github-star.js} +1 -1
  28. package/dist/lib/component/{logo/index.js → logo.js} +1 -1
  29. package/dist/lib/component/{misc/index.js → misc.js} +1 -60
  30. package/dist/lib/component/{player/index.js → player.js} +23 -23
  31. package/dist/lib/component/{config-selector/index.js → playground/ConfigSelector.js} +7 -6
  32. package/dist/lib/component/{context-preview/index.js → playground/ContextPreview.js} +9 -8
  33. package/dist/lib/component/{history-selector/index.js → playground/HistorySelector.js} +1 -1
  34. package/dist/lib/component/{playground-result/index.js → playground/PlaygroundResult.js} +9 -8
  35. package/dist/lib/component/{prompt-input/index.js → playground/PromptInput.js} +37 -37
  36. package/dist/lib/component/{service-mode-control/index.js → playground/ServiceModeControl.js} +9 -8
  37. package/dist/lib/component/playground/index.css +161 -29
  38. package/dist/lib/{utils/constants.js → component/playground/playground-constants.js} +64 -31
  39. package/dist/lib/component/playground/playground-types.js +18 -0
  40. package/dist/lib/{utils → component/playground}/playground-utils.js +1 -1
  41. package/dist/lib/{utils → component}/replay-scripts.js +4 -3
  42. package/dist/lib/component/{shiny-text/index.js → shiny-text.js} +1 -1
  43. package/dist/lib/index.js +34 -66
  44. package/dist/lib/init.js +44 -0
  45. package/dist/types/blank_polyfill.d.ts +2 -0
  46. package/dist/types/component/{blackboard/index.d.ts → blackboard.d.ts} +2 -2
  47. package/dist/types/component/{github-star/index.d.ts → github-star.d.ts} +1 -1
  48. package/dist/types/component/{logo/index.d.ts → logo.d.ts} +1 -1
  49. package/dist/types/component/misc.d.ts +2 -0
  50. package/dist/types/component/{player/index.d.ts → player.d.ts} +2 -2
  51. package/dist/types/component/{config-selector/index.d.ts → playground/ConfigSelector.d.ts} +1 -0
  52. package/dist/types/component/{context-preview/index.d.ts → playground/ContextPreview.d.ts} +1 -0
  53. package/dist/types/component/{history-selector/index.d.ts → playground/HistorySelector.d.ts} +1 -1
  54. package/dist/types/component/{playground-result/index.d.ts → playground/PlaygroundResult.d.ts} +4 -3
  55. package/dist/types/component/{prompt-input/index.d.ts → playground/PromptInput.d.ts} +2 -3
  56. package/dist/types/component/{service-mode-control/index.d.ts → playground/ServiceModeControl.d.ts} +1 -0
  57. package/dist/types/{utils/constants.d.ts → component/playground/playground-constants.d.ts} +5 -3
  58. package/dist/types/component/playground/playground-types.d.ts +19 -0
  59. package/dist/types/component/playground/types.d.ts +72 -0
  60. package/dist/types/{utils → component}/replay-scripts.d.ts +1 -0
  61. package/dist/types/component/{shiny-text/index.d.ts → shiny-text.d.ts} +1 -1
  62. package/dist/types/index.d.ts +10 -15
  63. package/dist/types/init.d.ts +1 -0
  64. package/package.json +5 -5
  65. package/dist/es/component/history-selector/index.css +0 -132
  66. package/dist/es/component/index.mjs +0 -1
  67. package/dist/es/component/playground/index.mjs +0 -8
  68. package/dist/es/component/playground-result/index.css +0 -29
  69. package/dist/es/component/prompt-input/index.css +0 -330
  70. package/dist/es/component/universal-playground/index.css +0 -341
  71. package/dist/es/component/universal-playground/index.mjs +0 -273
  72. package/dist/es/component/universal-playground/providers/context-provider.mjs +0 -52
  73. package/dist/es/component/universal-playground/providers/storage-provider.mjs +0 -107
  74. package/dist/es/hooks/usePlaygroundExecution.mjs +0 -168
  75. package/dist/es/hooks/usePlaygroundState.mjs +0 -176
  76. package/dist/es/icons/avatar.mjs +0 -28
  77. package/dist/lib/component/history-selector/index.css +0 -132
  78. package/dist/lib/component/index.js +0 -60
  79. package/dist/lib/component/playground/index.js +0 -113
  80. package/dist/lib/component/playground-result/index.css +0 -29
  81. package/dist/lib/component/prompt-input/index.css +0 -330
  82. package/dist/lib/component/universal-playground/index.css +0 -341
  83. package/dist/lib/component/universal-playground/index.js +0 -321
  84. package/dist/lib/component/universal-playground/providers/context-provider.js +0 -95
  85. package/dist/lib/component/universal-playground/providers/storage-provider.js +0 -147
  86. package/dist/lib/hooks/usePlaygroundExecution.js +0 -202
  87. package/dist/lib/hooks/usePlaygroundState.js +0 -210
  88. package/dist/lib/icons/avatar.js +0 -62
  89. package/dist/types/component/index.d.ts +0 -1
  90. package/dist/types/component/misc/index.d.ts +0 -6
  91. package/dist/types/component/playground/index.d.ts +0 -7
  92. package/dist/types/component/universal-playground/index.d.ts +0 -4
  93. package/dist/types/component/universal-playground/providers/context-provider.d.ts +0 -37
  94. package/dist/types/component/universal-playground/providers/storage-provider.d.ts +0 -33
  95. package/dist/types/hooks/usePlaygroundExecution.d.ts +0 -10
  96. package/dist/types/hooks/usePlaygroundState.d.ts +0 -26
  97. package/dist/types/types.d.ts +0 -164
  98. /package/dist/es/component/{blackboard/index.css → blackboard.css} +0 -0
  99. /package/dist/es/{utils → component}/color.mjs +0 -0
  100. /package/dist/es/component/{github-star/index.css → github-star.css} +0 -0
  101. /package/dist/es/component/{logo/index.css → logo.css} +0 -0
  102. /package/dist/es/{utils → component}/pixi-loader.mjs +0 -0
  103. /package/dist/es/component/{player/index.css → player.css} +0 -0
  104. /package/dist/es/component/{form-field/index.mjs → playground/FormField.mjs} +0 -0
  105. /package/dist/es/{types.mjs → component/playground/types.mjs} +0 -0
  106. /package/dist/es/{hooks → component/playground}/useServerValid.mjs +0 -0
  107. /package/dist/es/component/{playground/playground-demo-ui-context.json → playground-demo-ui-context.json} +0 -0
  108. /package/dist/es/component/{shiny-text/index.css → shiny-text.css} +0 -0
  109. /package/dist/es/{store → component/store}/history.mjs +0 -0
  110. /package/dist/es/{store → component/store}/store.mjs +0 -0
  111. /package/dist/es/{utils/index.mjs → utils.mjs} +0 -0
  112. /package/dist/lib/component/{blackboard/index.css → blackboard.css} +0 -0
  113. /package/dist/lib/{utils → component}/color.js +0 -0
  114. /package/dist/lib/component/{github-star/index.css → github-star.css} +0 -0
  115. /package/dist/lib/component/{logo/index.css → logo.css} +0 -0
  116. /package/dist/lib/{utils → component}/pixi-loader.js +0 -0
  117. /package/dist/lib/component/{player/index.css → player.css} +0 -0
  118. /package/dist/lib/component/{form-field/index.js → playground/FormField.js} +0 -0
  119. /package/dist/lib/{types.js → component/playground/types.js} +0 -0
  120. /package/dist/lib/{hooks → component/playground}/useServerValid.js +0 -0
  121. /package/dist/lib/component/{playground/playground-demo-ui-context.json → playground-demo-ui-context.json} +0 -0
  122. /package/dist/lib/component/{shiny-text/index.css → shiny-text.css} +0 -0
  123. /package/dist/lib/{store → component/store}/history.js +0 -0
  124. /package/dist/lib/{store → component/store}/store.js +0 -0
  125. /package/dist/lib/{utils/index.js → utils.js} +0 -0
  126. /package/dist/types/{utils → component}/color.d.ts +0 -0
  127. /package/dist/types/component/{env-config/index.d.ts → env-config.d.ts} +0 -0
  128. /package/dist/types/{utils → component}/pixi-loader.d.ts +0 -0
  129. /package/dist/types/component/{form-field/index.d.ts → playground/FormField.d.ts} +0 -0
  130. /package/dist/types/{utils → component/playground}/playground-utils.d.ts +0 -0
  131. /package/dist/types/{hooks → component/playground}/useServerValid.d.ts +0 -0
  132. /package/dist/types/{store → component/store}/history.d.ts +0 -0
  133. /package/dist/types/{store → component/store}/store.d.ts +0 -0
  134. /package/dist/types/{utils/index.d.ts → utils.d.ts} +0 -0
@@ -1,202 +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 constants_js_namespaceObject = require("../utils/constants.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
- const thisRunningId = Date.now();
39
- const actionType = value.type;
40
- const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
41
- const userItem = {
42
- id: `user-${Date.now()}`,
43
- type: 'user',
44
- content: displayContent,
45
- timestamp: new Date()
46
- };
47
- setInfoList((prev)=>[
48
- ...prev,
49
- userItem
50
- ]);
51
- setLoading(true);
52
- const result = {
53
- ...constants_js_namespaceObject.BLANK_RESULT
54
- };
55
- const systemItem = {
56
- id: `system-${thisRunningId}`,
57
- type: 'system',
58
- content: '',
59
- timestamp: new Date(),
60
- loading: true,
61
- loadingProgressText: ''
62
- };
63
- setInfoList((prev)=>[
64
- ...prev,
65
- systemItem
66
- ]);
67
- try {
68
- currentRunningIdRef.current = thisRunningId;
69
- interruptedFlagRef.current[thisRunningId] = false;
70
- if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate((tip)=>{
71
- if (interruptedFlagRef.current[thisRunningId]) return;
72
- const progressItem = {
73
- id: `progress-${thisRunningId}-${Date.now()}`,
74
- type: 'progress',
75
- content: tip,
76
- timestamp: new Date()
77
- };
78
- setInfoList((prev)=>[
79
- ...prev,
80
- progressItem
81
- ]);
82
- });
83
- result.result = await playgroundSDK.executeAction(actionType, value, {
84
- requestId: thisRunningId.toString()
85
- });
86
- if ('object' == typeof result.result && null !== result.result) {
87
- const resultObj = result.result;
88
- if (resultObj.dump) result.dump = resultObj.dump;
89
- if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
90
- if (resultObj.error) result.error = resultObj.error;
91
- if (void 0 !== resultObj.result) result.result = resultObj.result;
92
- }
93
- } catch (e) {
94
- result.error = (null == e ? void 0 : e.message) || String(e);
95
- console.error('Playground execution error:', e);
96
- }
97
- if (interruptedFlagRef.current[thisRunningId]) return;
98
- setLoading(false);
99
- currentRunningIdRef.current = null;
100
- let replayInfo = null;
101
- let counter = replayCounter;
102
- if ((null == result ? void 0 : result.dump) && !noReplayAPIs.includes(actionType)) {
103
- const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(result.dump);
104
- setReplayCounter((c)=>c + 1);
105
- replayInfo = info;
106
- counter = replayCounter + 1;
107
- }
108
- setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? {
109
- ...item,
110
- content: '',
111
- loading: false,
112
- loadingProgressText: ''
113
- } : item));
114
- const resultItem = {
115
- id: `result-${thisRunningId}`,
116
- type: 'result',
117
- content: 'Execution result',
118
- timestamp: new Date(),
119
- result: result,
120
- loading: false,
121
- replayScriptsInfo: replayInfo,
122
- replayCounter: counter,
123
- loadingProgressText: '',
124
- verticalMode: verticalMode
125
- };
126
- setInfoList((prev)=>[
127
- ...prev,
128
- resultItem
129
- ]);
130
- if (null == storage ? void 0 : storage.saveResult) try {
131
- await storage.saveResult(resultItem.id, resultItem);
132
- } catch (error) {
133
- console.error('Failed to save result:', error);
134
- }
135
- const separatorItem = {
136
- id: `separator-${thisRunningId}`,
137
- type: 'separator',
138
- content: 'New Session',
139
- timestamp: new Date()
140
- };
141
- setInfoList((prev)=>[
142
- ...prev,
143
- separatorItem
144
- ]);
145
- }, [
146
- playgroundSDK,
147
- storage,
148
- actionSpace,
149
- setLoading,
150
- setInfoList,
151
- replayCounter,
152
- setReplayCounter,
153
- verticalMode,
154
- currentRunningIdRef,
155
- interruptedFlagRef
156
- ]);
157
- const handleStop = (0, external_react_namespaceObject.useCallback)(async ()=>{
158
- const thisRunningId = currentRunningIdRef.current;
159
- if (thisRunningId && playgroundSDK.cancelExecution) try {
160
- await playgroundSDK.cancelExecution(thisRunningId.toString());
161
- interruptedFlagRef.current[thisRunningId] = true;
162
- setLoading(false);
163
- setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` && item.loading ? {
164
- ...item,
165
- content: 'Operation stopped',
166
- loading: false,
167
- loadingProgressText: ''
168
- } : item));
169
- const separatorItem = {
170
- id: `separator-${thisRunningId}`,
171
- type: 'separator',
172
- content: 'New Session',
173
- timestamp: new Date()
174
- };
175
- setInfoList((prev)=>[
176
- ...prev,
177
- separatorItem
178
- ]);
179
- } catch (error) {
180
- console.error('Failed to stop execution:', error);
181
- }
182
- }, [
183
- playgroundSDK,
184
- currentRunningIdRef,
185
- interruptedFlagRef,
186
- setLoading,
187
- setInfoList
188
- ]);
189
- const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK.cancelExecution;
190
- return {
191
- handleRun,
192
- handleStop,
193
- canStop
194
- };
195
- }
196
- exports.usePlaygroundExecution = __webpack_exports__.usePlaygroundExecution;
197
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
198
- "usePlaygroundExecution"
199
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
200
- Object.defineProperty(exports, '__esModule', {
201
- value: true
202
- });
@@ -1,210 +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 constants_js_namespaceObject = require("../utils/constants.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
- (0, external_react_namespaceObject.useEffect)(()=>{
44
- const initializeMessages = async ()=>{
45
- const welcomeMessage = {
46
- ...constants_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
47
- id: 'welcome',
48
- timestamp: new Date()
49
- };
50
- if (null == storage ? void 0 : storage.loadMessages) try {
51
- const storedMessages = await storage.loadMessages();
52
- const hasWelcomeMessage = storedMessages.some((msg)=>'welcome' === msg.id);
53
- hasWelcomeMessage ? setInfoList(storedMessages) : setInfoList([
54
- welcomeMessage,
55
- ...storedMessages
56
- ]);
57
- } catch (error) {
58
- console.error('Failed to load messages:', error);
59
- setInfoList([
60
- welcomeMessage
61
- ]);
62
- }
63
- else setInfoList([
64
- welcomeMessage
65
- ]);
66
- };
67
- if (0 === infoList.length) initializeMessages();
68
- }, []);
69
- (0, external_react_namespaceObject.useEffect)(()=>{
70
- if ((null == storage ? void 0 : storage.saveMessages) && infoList.length > 1) storage.saveMessages(infoList).catch((error)=>{
71
- console.error('Failed to save messages:', error);
72
- });
73
- }, [
74
- infoList,
75
- storage
76
- ]);
77
- (0, external_react_namespaceObject.useEffect)(()=>{
78
- if (!(null == contextProvider ? void 0 : contextProvider.getUIContext) || uiContextPreview) return;
79
- contextProvider.getUIContext().then((context)=>setUiContextPreview(context)).catch((error)=>{
80
- console.error('Failed to get UI context:', error);
81
- });
82
- }, [
83
- contextProvider,
84
- uiContextPreview
85
- ]);
86
- (0, external_react_namespaceObject.useEffect)(()=>{
87
- const loadActionSpace = async ()=>{
88
- setActionSpaceLoading(true);
89
- try {
90
- var _contextProvider_getUIContext;
91
- const context = uiContextPreview || await (null == contextProvider ? void 0 : null == (_contextProvider_getUIContext = contextProvider.getUIContext) ? void 0 : _contextProvider_getUIContext.call(contextProvider));
92
- const space = await playgroundSDK.getActionSpace(context);
93
- setActionSpace(space || []);
94
- } catch (error) {
95
- console.error('Failed to load action space:', error);
96
- setActionSpace([]);
97
- } finally{
98
- setActionSpaceLoading(false);
99
- }
100
- };
101
- loadActionSpace();
102
- }, [
103
- playgroundSDK,
104
- uiContextPreview,
105
- contextProvider
106
- ]);
107
- (0, external_react_namespaceObject.useEffect)(()=>{
108
- const sizeThreshold = 750;
109
- setVerticalMode(window.innerWidth < sizeThreshold);
110
- const handleResize = ()=>{
111
- setVerticalMode(window.innerWidth < sizeThreshold);
112
- };
113
- window.addEventListener('resize', handleResize);
114
- return ()=>window.removeEventListener('resize', handleResize);
115
- }, []);
116
- const scrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
117
- setTimeout(()=>{
118
- if (infoListRef.current) infoListRef.current.scrollTop = infoListRef.current.scrollHeight;
119
- }, 100);
120
- }, []);
121
- const checkIfScrolledToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
122
- if (infoListRef.current) {
123
- const { scrollTop, scrollHeight, clientHeight } = infoListRef.current;
124
- const isAtBottom = scrollTop + clientHeight >= scrollHeight - 10;
125
- setShowScrollToBottomButton(!isAtBottom);
126
- }
127
- }, []);
128
- const handleScrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
129
- if (infoListRef.current) {
130
- infoListRef.current.scrollTo({
131
- top: infoListRef.current.scrollHeight,
132
- behavior: 'smooth'
133
- });
134
- setShowScrollToBottomButton(false);
135
- }
136
- }, []);
137
- (0, external_react_namespaceObject.useEffect)(()=>{
138
- if (infoList.length > 0) scrollToBottom();
139
- }, [
140
- infoList,
141
- scrollToBottom
142
- ]);
143
- (0, external_react_namespaceObject.useEffect)(()=>{
144
- const container = infoListRef.current;
145
- if (container) {
146
- container.addEventListener('scroll', checkIfScrolledToBottom);
147
- checkIfScrolledToBottom();
148
- return ()=>{
149
- container.removeEventListener('scroll', checkIfScrolledToBottom);
150
- };
151
- }
152
- }, [
153
- checkIfScrolledToBottom
154
- ]);
155
- const clearInfoList = (0, external_react_namespaceObject.useCallback)(async ()=>{
156
- const welcomeMessage = {
157
- ...constants_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
158
- id: 'welcome',
159
- timestamp: new Date()
160
- };
161
- setInfoList([
162
- welcomeMessage
163
- ]);
164
- if (null == storage ? void 0 : storage.clearMessages) try {
165
- await storage.clearMessages();
166
- } catch (error) {
167
- console.error('Failed to clear stored messages:', error);
168
- }
169
- }, [
170
- storage
171
- ]);
172
- const refreshContext = (0, external_react_namespaceObject.useCallback)(async ()=>{
173
- if (null == contextProvider ? void 0 : contextProvider.refreshContext) try {
174
- const newContext = await contextProvider.refreshContext();
175
- setUiContextPreview(newContext);
176
- } catch (error) {
177
- console.error('Failed to refresh context:', error);
178
- }
179
- }, [
180
- contextProvider
181
- ]);
182
- return {
183
- loading,
184
- setLoading,
185
- infoList,
186
- setInfoList,
187
- actionSpace,
188
- actionSpaceLoading,
189
- uiContextPreview,
190
- setUiContextPreview,
191
- showScrollToBottomButton,
192
- verticalMode,
193
- replayCounter,
194
- setReplayCounter,
195
- infoListRef,
196
- currentRunningIdRef,
197
- interruptedFlagRef,
198
- clearInfoList,
199
- refreshContext,
200
- handleScrollToBottom,
201
- scrollToBottom
202
- };
203
- }
204
- exports.usePlaygroundState = __webpack_exports__.usePlaygroundState;
205
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
206
- "usePlaygroundState"
207
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
208
- Object.defineProperty(exports, '__esModule', {
209
- value: true
210
- });
@@ -1,62 +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
- default: ()=>avatar
28
- });
29
- const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
- require("react");
31
- const SvgAvatar = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("svg", {
32
- xmlns: "http://www.w3.org/2000/svg",
33
- width: 20,
34
- height: 20,
35
- fill: "none",
36
- "aria-label": "Playground",
37
- viewBox: "0 0 20 20",
38
- ...props,
39
- children: [
40
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("rect", {
41
- width: 20,
42
- height: 20,
43
- fill: "#2B83FF",
44
- rx: 10
45
- }),
46
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
47
- fill: "#2B83FF",
48
- stroke: "#fff",
49
- strokeLinejoin: "round",
50
- strokeWidth: 1.125,
51
- d: "M6.866 5.882a.56.56 0 0 1 .667-.078l3.248 1.875 3.247 1.875a.563.563 0 0 1 0 .974l-3.247 1.875-3.248 1.875a.563.563 0 0 1-.784-.74l1.749-3.497-1.75-3.498a.56.56 0 0 1 .118-.661Z"
52
- })
53
- ]
54
- });
55
- const avatar = SvgAvatar;
56
- exports["default"] = __webpack_exports__["default"];
57
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
58
- "default"
59
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
60
- Object.defineProperty(exports, '__esModule', {
61
- value: true
62
- });
@@ -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
- };