@godscene/visualizer 1.7.11

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 (221) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/es/component/blackboard/highlights.mjs +47 -0
  4. package/dist/es/component/blackboard/index.css +118 -0
  5. package/dist/es/component/blackboard/index.mjs +122 -0
  6. package/dist/es/component/config-selector/index.mjs +251 -0
  7. package/dist/es/component/context-preview/index.mjs +37 -0
  8. package/dist/es/component/env-config/index.mjs +237 -0
  9. package/dist/es/component/env-config-reminder/index.css +30 -0
  10. package/dist/es/component/env-config-reminder/index.mjs +27 -0
  11. package/dist/es/component/form-field/index.mjs +158 -0
  12. package/dist/es/component/history-selector/index.css +237 -0
  13. package/dist/es/component/history-selector/index.mjs +197 -0
  14. package/dist/es/component/index.mjs +1 -0
  15. package/dist/es/component/logo/index.css +19 -0
  16. package/dist/es/component/logo/index.mjs +20 -0
  17. package/dist/es/component/logo/logo.mjs +2 -0
  18. package/dist/es/component/misc/index.mjs +96 -0
  19. package/dist/es/component/nav-actions/index.mjs +14 -0
  20. package/dist/es/component/nav-actions/style.css +35 -0
  21. package/dist/es/component/player/index.css +296 -0
  22. package/dist/es/component/player/index.mjs +702 -0
  23. package/dist/es/component/player/playback-controls.mjs +4 -0
  24. package/dist/es/component/player/report-download.mjs +61 -0
  25. package/dist/es/component/player/scenes/StepScene.mjs +194 -0
  26. package/dist/es/component/player/scenes/derive-frame-state.mjs +229 -0
  27. package/dist/es/component/player/scenes/export-branded-video.mjs +360 -0
  28. package/dist/es/component/player/scenes/frame-calculator.mjs +149 -0
  29. package/dist/es/component/player/scenes/playback-frame.mjs +6 -0
  30. package/dist/es/component/player/scenes/playback-layout.mjs +12 -0
  31. package/dist/es/component/player/scenes/pointer-layout.mjs +36 -0
  32. package/dist/es/component/player/use-frame-player.mjs +87 -0
  33. package/dist/es/component/playground/index.css +930 -0
  34. package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
  35. package/dist/es/component/playground-result/index.css +92 -0
  36. package/dist/es/component/playground-result/index.mjs +232 -0
  37. package/dist/es/component/prompt-input/index.css +832 -0
  38. package/dist/es/component/prompt-input/index.mjs +959 -0
  39. package/dist/es/component/screenshot-viewer/index.css +237 -0
  40. package/dist/es/component/screenshot-viewer/index.mjs +319 -0
  41. package/dist/es/component/service-mode-control/index.mjs +107 -0
  42. package/dist/es/component/shiny-text/index.css +107 -0
  43. package/dist/es/component/shiny-text/index.mjs +15 -0
  44. package/dist/es/component/universal-playground/empty-state.mjs +5 -0
  45. package/dist/es/component/universal-playground/index.css +619 -0
  46. package/dist/es/component/universal-playground/index.mjs +558 -0
  47. package/dist/es/component/universal-playground/providers/context-provider.mjs +90 -0
  48. package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +280 -0
  49. package/dist/es/component/universal-playground/providers/storage-provider.mjs +279 -0
  50. package/dist/es/component/universal-playground/universal-playground-electron.mjs +668 -0
  51. package/dist/es/hooks/useMinimalTypeGate.mjs +47 -0
  52. package/dist/es/hooks/usePlaygroundExecution.mjs +435 -0
  53. package/dist/es/hooks/usePlaygroundState.mjs +278 -0
  54. package/dist/es/hooks/useSafeOverrideAIConfig.mjs +20 -0
  55. package/dist/es/hooks/useServerValid.mjs +55 -0
  56. package/dist/es/hooks/useTheme.mjs +25 -0
  57. package/dist/es/icons/action-chevron.mjs +61 -0
  58. package/dist/es/icons/avatar.mjs +70 -0
  59. package/dist/es/icons/close.mjs +61 -0
  60. package/dist/es/icons/global-perspective.mjs +58 -0
  61. package/dist/es/icons/history.mjs +72 -0
  62. package/dist/es/icons/magnifying-glass.mjs +81 -0
  63. package/dist/es/icons/player-setting.mjs +68 -0
  64. package/dist/es/icons/prompt-history.mjs +70 -0
  65. package/dist/es/icons/setting.mjs +62 -0
  66. package/dist/es/icons/show-marker.mjs +58 -0
  67. package/dist/es/index.mjs +26 -0
  68. package/dist/es/static/image/logo.png +0 -0
  69. package/dist/es/store/history.mjs +128 -0
  70. package/dist/es/store/store.mjs +277 -0
  71. package/dist/es/types.mjs +73 -0
  72. package/dist/es/utils/action-label.mjs +15 -0
  73. package/dist/es/utils/color.mjs +35 -0
  74. package/dist/es/utils/constants.mjs +99 -0
  75. package/dist/es/utils/device-capabilities.mjs +13 -0
  76. package/dist/es/utils/empty-state-scroll.mjs +8 -0
  77. package/dist/es/utils/highlight-element.mjs +62 -0
  78. package/dist/es/utils/index.mjs +13 -0
  79. package/dist/es/utils/playground-utils.mjs +43 -0
  80. package/dist/es/utils/progress-action-icon.mjs +30 -0
  81. package/dist/es/utils/prompt-input-utils.mjs +49 -0
  82. package/dist/es/utils/prompt-placeholder.mjs +19 -0
  83. package/dist/es/utils/replay-scripts.mjs +428 -0
  84. package/dist/lib/component/blackboard/highlights.js +84 -0
  85. package/dist/lib/component/blackboard/index.css +118 -0
  86. package/dist/lib/component/blackboard/index.js +169 -0
  87. package/dist/lib/component/config-selector/index.js +295 -0
  88. package/dist/lib/component/context-preview/index.js +82 -0
  89. package/dist/lib/component/env-config/index.js +271 -0
  90. package/dist/lib/component/env-config-reminder/index.css +30 -0
  91. package/dist/lib/component/env-config-reminder/index.js +61 -0
  92. package/dist/lib/component/form-field/index.js +204 -0
  93. package/dist/lib/component/history-selector/index.css +237 -0
  94. package/dist/lib/component/history-selector/index.js +243 -0
  95. package/dist/lib/component/index.js +58 -0
  96. package/dist/lib/component/logo/index.css +19 -0
  97. package/dist/lib/component/logo/index.js +67 -0
  98. package/dist/lib/component/logo/logo.js +24 -0
  99. package/dist/lib/component/misc/index.js +152 -0
  100. package/dist/lib/component/nav-actions/index.js +48 -0
  101. package/dist/lib/component/nav-actions/style.css +35 -0
  102. package/dist/lib/component/player/index.css +296 -0
  103. package/dist/lib/component/player/index.js +747 -0
  104. package/dist/lib/component/player/playback-controls.js +38 -0
  105. package/dist/lib/component/player/report-download.js +98 -0
  106. package/dist/lib/component/player/scenes/StepScene.js +228 -0
  107. package/dist/lib/component/player/scenes/derive-frame-state.js +266 -0
  108. package/dist/lib/component/player/scenes/export-branded-video.js +403 -0
  109. package/dist/lib/component/player/scenes/frame-calculator.js +186 -0
  110. package/dist/lib/component/player/scenes/playback-frame.js +40 -0
  111. package/dist/lib/component/player/scenes/playback-layout.js +46 -0
  112. package/dist/lib/component/player/scenes/pointer-layout.js +88 -0
  113. package/dist/lib/component/player/use-frame-player.js +121 -0
  114. package/dist/lib/component/playground/index.css +930 -0
  115. package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
  116. package/dist/lib/component/playground-result/index.css +92 -0
  117. package/dist/lib/component/playground-result/index.js +276 -0
  118. package/dist/lib/component/prompt-input/index.css +832 -0
  119. package/dist/lib/component/prompt-input/index.js +1005 -0
  120. package/dist/lib/component/screenshot-viewer/index.css +237 -0
  121. package/dist/lib/component/screenshot-viewer/index.js +353 -0
  122. package/dist/lib/component/service-mode-control/index.js +141 -0
  123. package/dist/lib/component/shiny-text/index.css +107 -0
  124. package/dist/lib/component/shiny-text/index.js +49 -0
  125. package/dist/lib/component/universal-playground/empty-state.js +39 -0
  126. package/dist/lib/component/universal-playground/index.css +619 -0
  127. package/dist/lib/component/universal-playground/index.js +607 -0
  128. package/dist/lib/component/universal-playground/providers/context-provider.js +133 -0
  129. package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +320 -0
  130. package/dist/lib/component/universal-playground/providers/storage-provider.js +337 -0
  131. package/dist/lib/component/universal-playground/universal-playground-electron.js +717 -0
  132. package/dist/lib/hooks/useMinimalTypeGate.js +81 -0
  133. package/dist/lib/hooks/usePlaygroundExecution.js +478 -0
  134. package/dist/lib/hooks/usePlaygroundState.js +312 -0
  135. package/dist/lib/hooks/useSafeOverrideAIConfig.js +57 -0
  136. package/dist/lib/hooks/useServerValid.js +89 -0
  137. package/dist/lib/hooks/useTheme.js +59 -0
  138. package/dist/lib/icons/action-chevron.js +95 -0
  139. package/dist/lib/icons/avatar.js +104 -0
  140. package/dist/lib/icons/close.js +95 -0
  141. package/dist/lib/icons/global-perspective.js +92 -0
  142. package/dist/lib/icons/history.js +106 -0
  143. package/dist/lib/icons/magnifying-glass.js +115 -0
  144. package/dist/lib/icons/player-setting.js +102 -0
  145. package/dist/lib/icons/prompt-history.js +104 -0
  146. package/dist/lib/icons/setting.js +96 -0
  147. package/dist/lib/icons/show-marker.js +92 -0
  148. package/dist/lib/index.js +204 -0
  149. package/dist/lib/static/image/logo.png +0 -0
  150. package/dist/lib/store/history.js +135 -0
  151. package/dist/lib/store/store.js +287 -0
  152. package/dist/lib/types.js +119 -0
  153. package/dist/lib/utils/action-label.js +52 -0
  154. package/dist/lib/utils/color.js +75 -0
  155. package/dist/lib/utils/constants.js +172 -0
  156. package/dist/lib/utils/device-capabilities.js +50 -0
  157. package/dist/lib/utils/empty-state-scroll.js +42 -0
  158. package/dist/lib/utils/highlight-element.js +99 -0
  159. package/dist/lib/utils/index.js +69 -0
  160. package/dist/lib/utils/playground-utils.js +86 -0
  161. package/dist/lib/utils/progress-action-icon.js +67 -0
  162. package/dist/lib/utils/prompt-input-utils.js +89 -0
  163. package/dist/lib/utils/prompt-placeholder.js +53 -0
  164. package/dist/lib/utils/replay-scripts.js +474 -0
  165. package/dist/types/component/blackboard/highlights.d.ts +11 -0
  166. package/dist/types/component/blackboard/index.d.ts +10 -0
  167. package/dist/types/component/config-selector/index.d.ts +15 -0
  168. package/dist/types/component/context-preview/index.d.ts +9 -0
  169. package/dist/types/component/env-config/index.d.ts +8 -0
  170. package/dist/types/component/env-config-reminder/index.d.ts +6 -0
  171. package/dist/types/component/form-field/index.d.ts +17 -0
  172. package/dist/types/component/history-selector/index.d.ts +13 -0
  173. package/dist/types/component/index.d.ts +1 -0
  174. package/dist/types/component/logo/index.d.ts +5 -0
  175. package/dist/types/component/misc/index.d.ts +6 -0
  176. package/dist/types/component/nav-actions/index.d.ts +12 -0
  177. package/dist/types/component/player/index.d.ts +15 -0
  178. package/dist/types/component/player/playback-controls.d.ts +1 -0
  179. package/dist/types/component/player/report-download.d.ts +32 -0
  180. package/dist/types/component/player/scenes/StepScene.d.ts +9 -0
  181. package/dist/types/component/player/scenes/derive-frame-state.d.ts +40 -0
  182. package/dist/types/component/player/scenes/export-branded-video.d.ts +33 -0
  183. package/dist/types/component/player/scenes/frame-calculator.d.ts +40 -0
  184. package/dist/types/component/player/scenes/playback-frame.d.ts +3 -0
  185. package/dist/types/component/player/scenes/playback-layout.d.ts +7 -0
  186. package/dist/types/component/player/scenes/pointer-layout.d.ts +20 -0
  187. package/dist/types/component/player/use-frame-player.d.ts +17 -0
  188. package/dist/types/component/playground-result/index.d.ts +22 -0
  189. package/dist/types/component/prompt-input/index.d.ts +23 -0
  190. package/dist/types/component/screenshot-viewer/index.d.ts +23 -0
  191. package/dist/types/component/service-mode-control/index.d.ts +6 -0
  192. package/dist/types/component/shiny-text/index.d.ts +12 -0
  193. package/dist/types/component/universal-playground/empty-state.d.ts +3 -0
  194. package/dist/types/component/universal-playground/index.d.ts +4 -0
  195. package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
  196. package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
  197. package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
  198. package/dist/types/component/universal-playground/universal-playground-electron.d.ts +4 -0
  199. package/dist/types/hooks/useMinimalTypeGate.d.ts +72 -0
  200. package/dist/types/hooks/usePlaygroundExecution.d.ts +40 -0
  201. package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
  202. package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
  203. package/dist/types/hooks/useServerValid.d.ts +1 -0
  204. package/dist/types/hooks/useTheme.d.ts +7 -0
  205. package/dist/types/index.d.ts +29 -0
  206. package/dist/types/store/history.d.ts +16 -0
  207. package/dist/types/store/store.d.ts +57 -0
  208. package/dist/types/types.d.ts +278 -0
  209. package/dist/types/utils/action-label.d.ts +11 -0
  210. package/dist/types/utils/color.d.ts +4 -0
  211. package/dist/types/utils/constants.d.ts +80 -0
  212. package/dist/types/utils/device-capabilities.d.ts +9 -0
  213. package/dist/types/utils/empty-state-scroll.d.ts +11 -0
  214. package/dist/types/utils/highlight-element.d.ts +3 -0
  215. package/dist/types/utils/index.d.ts +5 -0
  216. package/dist/types/utils/playground-utils.d.ts +11 -0
  217. package/dist/types/utils/progress-action-icon.d.ts +12 -0
  218. package/dist/types/utils/prompt-input-utils.d.ts +24 -0
  219. package/dist/types/utils/prompt-placeholder.d.ts +1 -0
  220. package/dist/types/utils/replay-scripts.d.ts +50 -0
  221. package/package.json +82 -0
@@ -0,0 +1,668 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import icons, { ArrowDownOutlined, ClearOutlined, LoadingOutlined, UpOutlined } from "@ant-design/icons";
3
+ import { Alert, Button, Form, List, Typography } from "antd";
4
+ import { useCallback, useEffect, useMemo, useState } from "react";
5
+ import { usePlaygroundState } from "../../hooks/usePlaygroundState.mjs";
6
+ import { useEnvConfig } from "../../store/store.mjs";
7
+ import { ContextPreview } from "../context-preview/index.mjs";
8
+ import { EnvConfigReminder } from "../env-config-reminder/index.mjs";
9
+ import { PlaygroundResultView } from "../playground-result/index.mjs";
10
+ import avatar from "../../icons/avatar.mjs";
11
+ import { BLANK_RESULT, defaultMainButtons } from "../../utils/constants.mjs";
12
+ import { calculateEmptyStatePromptScrollTop } from "../../utils/empty-state-scroll.mjs";
13
+ import { resolveProgressActionIcon } from "../../utils/progress-action-icon.mjs";
14
+ import { shouldOffsetEmptyStateForPromptInput } from "../../utils/prompt-input-utils.mjs";
15
+ import shiny_text from "../shiny-text/index.mjs";
16
+ import { shouldRenderCustomEmptyState } from "./empty-state.mjs";
17
+ import { createStorageProvider, detectBestStorageType } from "./providers/storage-provider.mjs";
18
+ import { commandMap } from "@godscene/shared/constants";
19
+ import { buildProgressContent, formatError, wrapExecutionDumpForReplay } from "../../hooks/usePlaygroundExecution.mjs";
20
+ import { allScriptsFromDump } from "../../utils/replay-scripts.mjs";
21
+ import { typeStr } from "@godscene/core/agent";
22
+ import "./index.css";
23
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
24
+ try {
25
+ var info = gen[key](arg);
26
+ var value = info.value;
27
+ } catch (error) {
28
+ reject(error);
29
+ return;
30
+ }
31
+ if (info.done) resolve(value);
32
+ else Promise.resolve(value).then(_next, _throw);
33
+ }
34
+ function _async_to_generator(fn) {
35
+ return function() {
36
+ var self = this, args = arguments;
37
+ return new Promise(function(resolve, reject) {
38
+ var gen = fn.apply(self, args);
39
+ function _next(value) {
40
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
41
+ }
42
+ function _throw(err) {
43
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
44
+ }
45
+ _next(void 0);
46
+ });
47
+ };
48
+ }
49
+ function _define_property(obj, key, value) {
50
+ if (key in obj) Object.defineProperty(obj, key, {
51
+ value: value,
52
+ enumerable: true,
53
+ configurable: true,
54
+ writable: true
55
+ });
56
+ else obj[key] = value;
57
+ return obj;
58
+ }
59
+ function _object_spread(target) {
60
+ for(var i = 1; i < arguments.length; i++){
61
+ var source = null != arguments[i] ? arguments[i] : {};
62
+ var ownKeys = Object.keys(source);
63
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
65
+ }));
66
+ ownKeys.forEach(function(key) {
67
+ _define_property(target, key, source[key]);
68
+ });
69
+ }
70
+ return target;
71
+ }
72
+ function universal_playground_electron_ownKeys(object, enumerableOnly) {
73
+ var keys = Object.keys(object);
74
+ if (Object.getOwnPropertySymbols) {
75
+ var symbols = Object.getOwnPropertySymbols(object);
76
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
77
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
78
+ });
79
+ keys.push.apply(keys, symbols);
80
+ }
81
+ return keys;
82
+ }
83
+ function _object_spread_props(target, source) {
84
+ source = null != source ? source : {};
85
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
86
+ else universal_playground_electron_ownKeys(Object(source)).forEach(function(key) {
87
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
88
+ });
89
+ return target;
90
+ }
91
+ const { Text } = Typography;
92
+ function ErrorMessage({ error }) {
93
+ if (!error) return null;
94
+ const cleanError = error.replace(/^(Error:\s*)+/, 'Error: ');
95
+ return /*#__PURE__*/ jsx(Alert, {
96
+ message: /*#__PURE__*/ jsx("span", {
97
+ style: {
98
+ color: '#ff4d4f'
99
+ },
100
+ children: cleanError
101
+ }),
102
+ type: "error",
103
+ showIcon: true
104
+ });
105
+ }
106
+ function UniversalPlaygroundElectron({ storage, contextProvider, config: componentConfig = {}, branding = {}, className = '', dryMode = false, showContextPreview = true, showPromptInput = true, onHumanUse = ()=>{}, showHumanUse = false, defaultSelectedType }) {
107
+ var _componentConfig_executionFlow, _executionFlowConfig_label;
108
+ const [form] = Form.useForm();
109
+ const { config } = useEnvConfig();
110
+ const [sdkReady, setSdkReady] = useState(false);
111
+ useEffect(()=>{
112
+ form.setFieldsValue({
113
+ type: defaultMainButtons["0"]
114
+ });
115
+ }, [
116
+ form
117
+ ]);
118
+ const effectiveStorage = useMemo(()=>{
119
+ if (storage) return storage;
120
+ if (!sdkReady) return null;
121
+ const namespace = componentConfig.storageNamespace;
122
+ const bestStorageType = detectBestStorageType();
123
+ console.log(`Using ${bestStorageType} storage for namespace: ${namespace}`);
124
+ return createStorageProvider(bestStorageType, namespace);
125
+ }, [
126
+ storage,
127
+ sdkReady,
128
+ componentConfig.storageNamespace
129
+ ]);
130
+ const { loading, setLoading, infoList, setInfoList, actionSpace, actionSpaceLoading, uiContextPreview, setUiContextPreview, showScrollToBottomButton, verticalMode, replayCounter, setReplayCounter, infoListRef, currentRunningIdRef, interruptedFlagRef, clearInfoList, handleScrollToBottom } = usePlaygroundState(null, effectiveStorage, contextProvider, branding.targetName);
131
+ const handleFormRun = useCallback(()=>_async_to_generator(function*() {})(), [
132
+ form
133
+ ]);
134
+ Object.keys(config || {}).length;
135
+ const selectedType = form.getFieldValue('type');
136
+ const serviceMode = 'In-Browser-Extension';
137
+ const finalShowContextPreview = showContextPreview && false !== componentConfig.showContextPreview;
138
+ const layout = componentConfig.layout || 'vertical';
139
+ const showVersionInfo = false !== componentConfig.showVersionInfo;
140
+ const deviceType = componentConfig.deviceType;
141
+ const executionFlowConfig = null != (_componentConfig_executionFlow = componentConfig.executionFlow) ? _componentConfig_executionFlow : {};
142
+ const collapsibleProgressGroup = true === executionFlowConfig.collapsible;
143
+ const progressGroupLabel = null != (_executionFlowConfig_label = executionFlowConfig.label) ? _executionFlowConfig_label : 'Execution Flow';
144
+ const [collapsedProgressGroups, setCollapsedProgressGroups] = useState(()=>new Set());
145
+ const toggleProgressGroup = useCallback((groupId)=>{
146
+ setCollapsedProgressGroups((prev)=>{
147
+ const next = new Set(prev);
148
+ if (next.has(groupId)) next.delete(groupId);
149
+ else next.add(groupId);
150
+ return next;
151
+ });
152
+ }, []);
153
+ const { firstInProgressGroup, visibleInfoList } = useMemo(()=>{
154
+ const firstIds = new Set();
155
+ const visible = [];
156
+ let currentGroupFirstId = null;
157
+ const hideWelcome = infoList.length > 1;
158
+ for (const item of infoList)if (!hideWelcome || 'welcome' !== item.id) if ('progress' === item.type) {
159
+ if (null === currentGroupFirstId) {
160
+ currentGroupFirstId = item.id;
161
+ firstIds.add(item.id);
162
+ visible.push(item);
163
+ continue;
164
+ }
165
+ if (!collapsibleProgressGroup || !collapsedProgressGroups.has(currentGroupFirstId)) visible.push(item);
166
+ } else {
167
+ currentGroupFirstId = null;
168
+ visible.push(item);
169
+ }
170
+ return {
171
+ firstInProgressGroup: firstIds,
172
+ visibleInfoList: visible
173
+ };
174
+ }, [
175
+ collapsedProgressGroups,
176
+ collapsibleProgressGroup,
177
+ infoList
178
+ ]);
179
+ const latestProgressId = useMemo(()=>{
180
+ for(let i = infoList.length - 1; i >= 0; i--)if ('progress' === infoList[i].type) return infoList[i].id;
181
+ return null;
182
+ }, [
183
+ infoList
184
+ ]);
185
+ const renderCustomEmptyState = shouldRenderCustomEmptyState(visibleInfoList, componentConfig.emptyState);
186
+ const shouldOffsetEmptyStateForPrompt = useMemo(()=>renderCustomEmptyState && shouldOffsetEmptyStateForPromptInput(actionSpace, selectedType), [
187
+ actionSpace,
188
+ renderCustomEmptyState,
189
+ selectedType
190
+ ]);
191
+ useEffect(()=>{
192
+ if (!shouldOffsetEmptyStateForPrompt) return;
193
+ const adjustEmptyStateScroll = ()=>{
194
+ const container = infoListRef.current;
195
+ if (!container) return;
196
+ const wrapper = container.querySelector('.playground-empty-state-wrapper');
197
+ const contentStart = null == wrapper ? void 0 : wrapper.querySelector('[data-playground-empty-state-content-start]');
198
+ const contentEnd = null == wrapper ? void 0 : wrapper.querySelector('[data-playground-empty-state-content-end]');
199
+ if (!(contentStart instanceof HTMLElement) || !(contentEnd instanceof HTMLElement)) return;
200
+ const containerRect = container.getBoundingClientRect();
201
+ const startRect = contentStart.getBoundingClientRect();
202
+ const endRect = contentEnd.getBoundingClientRect();
203
+ const top = calculateEmptyStatePromptScrollTop({
204
+ currentScrollTop: container.scrollTop,
205
+ maxScrollTop: Math.max(0, container.scrollHeight - container.clientHeight),
206
+ containerTop: containerRect.top,
207
+ containerBottom: containerRect.bottom,
208
+ contentStartTop: startRect.top,
209
+ contentEndBottom: endRect.bottom
210
+ });
211
+ container.scrollTo({
212
+ top,
213
+ behavior: 'auto'
214
+ });
215
+ };
216
+ const animationFrameId = window.requestAnimationFrame(adjustEmptyStateScroll);
217
+ const timeoutId = window.setTimeout(adjustEmptyStateScroll, 160);
218
+ return ()=>{
219
+ window.cancelAnimationFrame(animationFrameId);
220
+ window.clearTimeout(timeoutId);
221
+ };
222
+ }, [
223
+ infoListRef,
224
+ selectedType,
225
+ shouldOffsetEmptyStateForPrompt
226
+ ]);
227
+ const emptyStateWrapperClassName = [
228
+ 'playground-empty-state-wrapper',
229
+ shouldOffsetEmptyStateForPrompt ? 'playground-empty-state-wrapper-offset-for-prompt' : ''
230
+ ].filter(Boolean).join(' ');
231
+ useEffect(()=>{
232
+ var _window_electron, _window_electron1, _window_electron2, _window_electron3;
233
+ clearInfoList();
234
+ null == (_window_electron = window.electron) || _window_electron.ipcRenderer.on('rpascene-execute-start', (e, value, thisRunningId)=>{
235
+ const sub = value.prompt || value.params ? value.prompt || JSON.stringify(value.params) : '';
236
+ const displayContent = sub;
237
+ const userItem = {
238
+ id: `user-${Date.now()}`,
239
+ type: 'user',
240
+ content: displayContent,
241
+ timestamp: new Date()
242
+ };
243
+ setInfoList((prev)=>[
244
+ ...prev,
245
+ userItem
246
+ ]);
247
+ setLoading(true);
248
+ const systemItem = {
249
+ id: `system-${thisRunningId}`,
250
+ type: 'system',
251
+ content: '',
252
+ timestamp: new Date(),
253
+ loading: true,
254
+ loadingProgressText: ''
255
+ };
256
+ setInfoList((prev)=>[
257
+ ...prev,
258
+ systemItem
259
+ ]);
260
+ });
261
+ null == (_window_electron1 = window.electron) || _window_electron1.ipcRenderer.on('rpascene-execute-result', (e, value, thisRunningId)=>{
262
+ console.log('rpascene-execute-result', value, thisRunningId);
263
+ const result = _object_spread({}, BLANK_RESULT);
264
+ try {
265
+ currentRunningIdRef.current = thisRunningId;
266
+ interruptedFlagRef.current[thisRunningId] = false;
267
+ result.result = value;
268
+ if ('object' == typeof result.result && null !== result.result) {
269
+ const resultObj = result.result;
270
+ if (resultObj.dump) result.dump = resultObj.dump;
271
+ if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
272
+ if (resultObj.error) result.error = formatError(resultObj.error);
273
+ if ('result' in resultObj) result.result = resultObj.result;
274
+ }
275
+ } catch (e) {
276
+ result.error = formatError(e);
277
+ console.error('Playground execution error:', e);
278
+ if ('object' == typeof e && null !== e) {
279
+ if (e.dump) result.dump = e.dump;
280
+ if (e.reportHTML) result.reportHTML = e.reportHTML;
281
+ }
282
+ }
283
+ if (interruptedFlagRef.current[thisRunningId]) return;
284
+ setLoading(false);
285
+ currentRunningIdRef.current = null;
286
+ let replayInfo = null;
287
+ let counter = replayCounter;
288
+ if (null == result ? void 0 : result.dump) {
289
+ if (result.dump.tasks && Array.isArray(result.dump.tasks)) {
290
+ const groupedDump = wrapExecutionDumpForReplay(result.dump, deviceType);
291
+ const info = allScriptsFromDump(groupedDump);
292
+ setReplayCounter((c)=>c + 1);
293
+ replayInfo = info;
294
+ counter = replayCounter + 1;
295
+ }
296
+ }
297
+ setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? _object_spread_props(_object_spread({}, item), {
298
+ content: '',
299
+ loading: false,
300
+ loadingProgressText: ''
301
+ }) : item));
302
+ const resultItem = {
303
+ id: `result-${thisRunningId}`,
304
+ type: 'result',
305
+ content: 'Execution result',
306
+ timestamp: new Date(),
307
+ result: result,
308
+ loading: false,
309
+ replayScriptsInfo: replayInfo,
310
+ replayCounter: counter,
311
+ loadingProgressText: '',
312
+ verticalMode: verticalMode,
313
+ actionType: 'aiAct'
314
+ };
315
+ setInfoList((prev)=>[
316
+ ...prev,
317
+ resultItem
318
+ ]);
319
+ });
320
+ null == (_window_electron2 = window.electron) || _window_electron2.ipcRenderer.on('rpascene-execute-prepare', (e, tip, thisRunningId)=>{
321
+ setLoading(true);
322
+ setInfoList((prev)=>{
323
+ const lastItem = prev[prev.length - 1];
324
+ if (lastItem && 'progress' === lastItem.type && lastItem.content === tip) return prev;
325
+ const progressItem = {
326
+ id: `progress-${thisRunningId}-${Date.now()}`,
327
+ type: 'progress',
328
+ content: tip,
329
+ loading: true,
330
+ timestamp: new Date()
331
+ };
332
+ return [
333
+ ...prev,
334
+ progressItem
335
+ ];
336
+ });
337
+ });
338
+ null == (_window_electron3 = window.electron) || _window_electron3.ipcRenderer.on('rpascene-execute-progress', (e, thisRunningId, executionDump)=>{
339
+ var _executionDump_tasks;
340
+ if (interruptedFlagRef.current[thisRunningId] || !(null == executionDump ? void 0 : null == (_executionDump_tasks = executionDump.tasks) ? void 0 : _executionDump_tasks.length)) return;
341
+ const progressItems = executionDump.tasks.map((task, index)=>{
342
+ var _task_timing;
343
+ return {
344
+ id: `progress-${thisRunningId}-task-${index}`,
345
+ type: 'progress',
346
+ content: buildProgressContent(task),
347
+ actionKind: typeStr(task),
348
+ timestamp: new Date((null == (_task_timing = task.timing) ? void 0 : _task_timing.start) || Date.now()),
349
+ result: task.error ? {
350
+ error: formatError(task.error),
351
+ result: null
352
+ } : void 0
353
+ };
354
+ });
355
+ setInfoList((prev)=>{
356
+ const systemItemIndex = prev.findIndex((item)=>item.id === `system-${thisRunningId}`);
357
+ if (-1 === systemItemIndex) return prev;
358
+ const listWithoutCurrentProgress = prev.filter((item)=>!('progress' === item.type && item.id.startsWith(`progress-${thisRunningId}-`)));
359
+ return [
360
+ ...listWithoutCurrentProgress.slice(0, systemItemIndex + 1),
361
+ ...progressItems,
362
+ ...listWithoutCurrentProgress.slice(systemItemIndex + 1)
363
+ ];
364
+ });
365
+ });
366
+ return ()=>{
367
+ var _window_electron, _window_electron1, _window_electron2, _window_electron3;
368
+ null == (_window_electron = window.electron) || _window_electron.ipcRenderer.removeAllListeners('rpascene-execute-prepare');
369
+ null == (_window_electron1 = window.electron) || _window_electron1.ipcRenderer.removeAllListeners('rpascene-execute-start');
370
+ null == (_window_electron2 = window.electron) || _window_electron2.ipcRenderer.removeAllListeners('rpascene-execute-result');
371
+ null == (_window_electron3 = window.electron) || _window_electron3.ipcRenderer.removeAllListeners('rpascene-execute-progress');
372
+ };
373
+ }, []);
374
+ return /*#__PURE__*/ jsx("div", {
375
+ className: `playground-container ${layout}-mode ${className}`.trim(),
376
+ children: /*#__PURE__*/ jsxs(Form, {
377
+ form: form,
378
+ onFinish: handleFormRun,
379
+ className: "command-form",
380
+ children: [
381
+ finalShowContextPreview && /*#__PURE__*/ jsx("div", {
382
+ className: "context-preview-section",
383
+ children: /*#__PURE__*/ jsx(ContextPreview, {
384
+ uiContextPreview: uiContextPreview,
385
+ setUiContextPreview: setUiContextPreview,
386
+ showContextPreview: finalShowContextPreview
387
+ })
388
+ }),
389
+ /*#__PURE__*/ jsxs("div", {
390
+ className: "middle-dialog-area",
391
+ children: [
392
+ false !== componentConfig.showClearButton && infoList.length > 1 && /*#__PURE__*/ jsx("div", {
393
+ className: "clear-button-container",
394
+ children: /*#__PURE__*/ jsx(Button, {
395
+ size: "small",
396
+ icon: /*#__PURE__*/ jsx(ClearOutlined, {}),
397
+ onClick: clearInfoList,
398
+ type: "text",
399
+ className: "clear-button"
400
+ })
401
+ }),
402
+ /*#__PURE__*/ jsx("div", {
403
+ ref: infoListRef,
404
+ className: "info-list-container",
405
+ children: renderCustomEmptyState ? /*#__PURE__*/ jsx("div", {
406
+ className: emptyStateWrapperClassName,
407
+ children: componentConfig.emptyState
408
+ }) : /*#__PURE__*/ jsx(List, {
409
+ itemLayout: "vertical",
410
+ dataSource: visibleInfoList,
411
+ renderItem: (item)=>{
412
+ const isFirstInProgressGroup = collapsibleProgressGroup && firstInProgressGroup.has(item.id);
413
+ const isCollapsedHeader = isFirstInProgressGroup && collapsedProgressGroups.has(item.id);
414
+ return /*#__PURE__*/ jsxs(List.Item, {
415
+ className: "list-item",
416
+ children: [
417
+ isFirstInProgressGroup ? /*#__PURE__*/ jsxs("button", {
418
+ type: "button",
419
+ className: `progress-group-toggle ${collapsedProgressGroups.has(item.id) ? 'is-collapsed' : 'is-expanded'}`,
420
+ "aria-expanded": !collapsedProgressGroups.has(item.id),
421
+ onClick: ()=>toggleProgressGroup(item.id),
422
+ children: [
423
+ /*#__PURE__*/ jsx("span", {
424
+ className: "progress-group-toggle-label",
425
+ children: progressGroupLabel
426
+ }),
427
+ /*#__PURE__*/ jsx(UpOutlined, {
428
+ className: "progress-group-toggle-chevron"
429
+ })
430
+ ]
431
+ }) : null,
432
+ isCollapsedHeader ? null : 'user' === item.type ? /*#__PURE__*/ jsx("div", {
433
+ className: "user-message-container",
434
+ children: /*#__PURE__*/ jsx("div", {
435
+ className: "user-message-bubble",
436
+ children: item.content
437
+ })
438
+ }) : 'progress' === item.type ? /*#__PURE__*/ jsx("div", {
439
+ children: (()=>{
440
+ var _parts_, _item_result, _item_result1;
441
+ const parts = item.content.split(' - ');
442
+ const action = null == (_parts_ = parts[0]) ? void 0 : _parts_.trim();
443
+ const description = parts.slice(1).join(' - ').trim();
444
+ const isLatestProgress = item.id === latestProgressId;
445
+ const shouldShowLoading = loading && isLatestProgress;
446
+ const state = shouldShowLoading ? 'loading' : (null == (_item_result = item.result) ? void 0 : _item_result.error) ? 'error' : 'completed';
447
+ const domainIcon = 'completed' === state ? resolveProgressActionIcon(item.actionKind, executionFlowConfig.resolveActionIcon) : null;
448
+ return /*#__PURE__*/ jsxs(Fragment, {
449
+ children: [
450
+ action && /*#__PURE__*/ jsxs("span", {
451
+ className: "progress-action-item",
452
+ children: [
453
+ action,
454
+ /*#__PURE__*/ jsx("span", {
455
+ className: `progress-status-icon ${state}`,
456
+ children: 'loading' === state ? /*#__PURE__*/ jsx(LoadingOutlined, {
457
+ spin: true
458
+ }) : 'error' === state ? '✗' : null !== domainIcon ? domainIcon : '✓'
459
+ })
460
+ ]
461
+ }),
462
+ description && /*#__PURE__*/ jsx("div", {
463
+ children: /*#__PURE__*/ jsx(shiny_text, {
464
+ text: description,
465
+ className: "progress-description",
466
+ disabled: !shouldShowLoading
467
+ })
468
+ }),
469
+ (null == (_item_result1 = item.result) ? void 0 : _item_result1.error) && /*#__PURE__*/ jsx(ErrorMessage, {
470
+ error: item.result.error
471
+ })
472
+ ]
473
+ });
474
+ })()
475
+ }) : 'separator' === item.type ? /*#__PURE__*/ jsxs("div", {
476
+ className: "new-conversation-separator",
477
+ children: [
478
+ /*#__PURE__*/ jsx("div", {
479
+ className: "separator-line"
480
+ }),
481
+ /*#__PURE__*/ jsx("div", {
482
+ className: "separator-text-container",
483
+ children: /*#__PURE__*/ jsx(Text, {
484
+ type: "secondary",
485
+ className: "separator-text",
486
+ children: item.content
487
+ })
488
+ })
489
+ ]
490
+ }) : /*#__PURE__*/ jsxs("div", {
491
+ className: "system-message-container",
492
+ children: [
493
+ false !== componentConfig.showSystemMessageHeader && /*#__PURE__*/ jsxs("div", {
494
+ className: "system-message-header",
495
+ children: [
496
+ /*#__PURE__*/ jsx(icons, {
497
+ component: branding.icon || avatar,
498
+ style: {
499
+ fontSize: 20
500
+ }
501
+ }),
502
+ /*#__PURE__*/ jsx("span", {
503
+ className: "system-message-title",
504
+ children: branding.title || 'Playground'
505
+ })
506
+ ]
507
+ }),
508
+ (item.content || item.result) && /*#__PURE__*/ jsx("div", {
509
+ className: "system-message-content",
510
+ children: 'result' === item.type ? /*#__PURE__*/ jsx(PlaygroundResultView, {
511
+ result: item.result || null,
512
+ loading: item.loading || false,
513
+ serverValid: true,
514
+ serviceMode: serviceMode,
515
+ replayScriptsInfo: item.replayScriptsInfo || null,
516
+ replayCounter: item.replayCounter || 0,
517
+ loadingProgressText: item.loadingProgressText || '',
518
+ verticalMode: item.verticalMode || false,
519
+ fitMode: "width",
520
+ actionType: item.actionType,
521
+ onDownloadReport: componentConfig.onDownloadReport,
522
+ canDownloadReport: false
523
+ }) : /*#__PURE__*/ jsxs(Fragment, {
524
+ children: [
525
+ /*#__PURE__*/ jsx("div", {
526
+ className: "system-message-text",
527
+ children: item.content
528
+ }),
529
+ item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
530
+ className: "loading-progress-text",
531
+ children: /*#__PURE__*/ jsx("span", {
532
+ children: item.loadingProgressText
533
+ })
534
+ })
535
+ ]
536
+ })
537
+ }),
538
+ (null == item ? void 0 : item.actionTasks) && (null == item ? void 0 : item.actionTasks.length) > 0 && /*#__PURE__*/ jsx("div", {
539
+ className: "system-message-content",
540
+ children: /*#__PURE__*/ jsxs(Fragment, {
541
+ children: [
542
+ /*#__PURE__*/ jsxs("div", {
543
+ className: "system-message-text",
544
+ children: [
545
+ /*#__PURE__*/ jsx("div", {
546
+ className: "action-result-title",
547
+ children: "此次生成如下命令,点击采用可插入到设计器"
548
+ }),
549
+ /*#__PURE__*/ jsx("ul", {
550
+ className: "action-result-list",
551
+ children: item.actionTasks.map((data, index)=>{
552
+ var _commandMap_data_subType, _data_param, _data_param1, _data_param2, _data_param3, _data_param4, _data_param_from, _data_param5, _data_param_to, _data_param6;
553
+ return /*#__PURE__*/ jsxs("li", {
554
+ title: data.locate,
555
+ children: [
556
+ /*#__PURE__*/ jsxs("div", {
557
+ className: "action-result-command",
558
+ children: [
559
+ "命令:",
560
+ (null == (_commandMap_data_subType = commandMap[data.subType]) ? void 0 : _commandMap_data_subType.DisplayName) || data.subType
561
+ ]
562
+ }),
563
+ (null == data ? void 0 : null == (_data_param = data.param) ? void 0 : _data_param.timeMs) && /*#__PURE__*/ jsxs("div", {
564
+ className: "action-result-command",
565
+ children: [
566
+ "暂停时间:",
567
+ data.param.timeMs
568
+ ]
569
+ }),
570
+ (null == data ? void 0 : null == (_data_param1 = data.param) ? void 0 : _data_param1.url) && /*#__PURE__*/ jsxs("div", {
571
+ className: "action-result-command",
572
+ children: [
573
+ "网址:",
574
+ data.param.url
575
+ ]
576
+ }),
577
+ (null == data ? void 0 : null == (_data_param2 = data.param) ? void 0 : _data_param2.keyName) && /*#__PURE__*/ jsxs("div", {
578
+ className: "action-result-command",
579
+ children: [
580
+ "按键:",
581
+ data.param.keyName
582
+ ]
583
+ }),
584
+ (null == data ? void 0 : null == (_data_param3 = data.param) ? void 0 : _data_param3.value) && /*#__PURE__*/ jsxs("div", {
585
+ className: "action-result-command",
586
+ children: [
587
+ "值:",
588
+ null == data ? void 0 : null == (_data_param4 = data.param) ? void 0 : _data_param4.value
589
+ ]
590
+ }),
591
+ (null == (_data_param5 = data.param) ? void 0 : null == (_data_param_from = _data_param5.from) ? void 0 : _data_param_from.locateDescription) && (null == (_data_param6 = data.param) ? void 0 : null == (_data_param_to = _data_param6.to) ? void 0 : _data_param_to.locateDescription) && /*#__PURE__*/ jsxs("div", {
592
+ className: "action-result-locate",
593
+ children: [
594
+ /*#__PURE__*/ jsx("span", {
595
+ children: "拖拽元素:"
596
+ }),
597
+ /*#__PURE__*/ jsx("span", {
598
+ children: data.param.from.locateDescription
599
+ }),
600
+ /*#__PURE__*/ jsx("span", {
601
+ children: "目标元素:"
602
+ }),
603
+ /*#__PURE__*/ jsx("span", {
604
+ children: data.param.to.locateDescription
605
+ })
606
+ ]
607
+ }),
608
+ data.locateDescription && /*#__PURE__*/ jsxs("div", {
609
+ className: "action-result-locate",
610
+ children: [
611
+ "元素:",
612
+ data.locateDescription
613
+ ]
614
+ })
615
+ ]
616
+ }, index);
617
+ })
618
+ })
619
+ ]
620
+ }),
621
+ /*#__PURE__*/ jsx("div", {
622
+ className: "action-result-btns",
623
+ children: /*#__PURE__*/ jsx(Button, {
624
+ type: "primary",
625
+ onClick: ()=>onHumanUse(item.actionTasks),
626
+ children: "采用"
627
+ })
628
+ })
629
+ ]
630
+ })
631
+ })
632
+ ]
633
+ })
634
+ ]
635
+ }, item.id);
636
+ }
637
+ })
638
+ }),
639
+ showScrollToBottomButton && false !== componentConfig.enableScrollToBottom && /*#__PURE__*/ jsx(Button, {
640
+ className: "scroll-to-bottom-button",
641
+ type: "primary",
642
+ shape: "circle",
643
+ icon: /*#__PURE__*/ jsx(ArrowDownOutlined, {}),
644
+ onClick: handleScrollToBottom,
645
+ size: "large"
646
+ })
647
+ ]
648
+ }),
649
+ /*#__PURE__*/ jsx("div", {
650
+ className: "bottom-input-section",
651
+ children: componentConfig.showEnvConfigReminder ? /*#__PURE__*/ jsx(EnvConfigReminder, {}) : null
652
+ }),
653
+ showVersionInfo && branding.version && /*#__PURE__*/ jsx("div", {
654
+ className: "version-info-section",
655
+ children: /*#__PURE__*/ jsxs("span", {
656
+ className: "version-text",
657
+ children: [
658
+ "version: ",
659
+ branding.version
660
+ ]
661
+ })
662
+ })
663
+ ]
664
+ })
665
+ });
666
+ }
667
+ const universal_playground_electron = UniversalPlaygroundElectron;
668
+ export { UniversalPlaygroundElectron, universal_playground_electron as default };