@godscene/playground-electron 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 (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/es/DeviceInteractionLayer.mjs +383 -0
  4. package/dist/es/PlaygroundApp.css +207 -0
  5. package/dist/es/PlaygroundApp.mjs +776 -0
  6. package/dist/es/PlaygroundPreview.mjs +29 -0
  7. package/dist/es/PlaygroundThemeProvider.mjs +10 -0
  8. package/dist/es/PreviewRenderer.mjs +270 -0
  9. package/dist/es/ScrcpyPanel.mjs +390 -0
  10. package/dist/es/SessionSetupPanel.css +299 -0
  11. package/dist/es/SessionSetupPanel.mjs +169 -0
  12. package/dist/es/components/Header/index.css +19 -0
  13. package/dist/es/components/Header/index.mjs +37 -0
  14. package/dist/es/components/Nav/index.css +15 -0
  15. package/dist/es/components/Nav/index.mjs +93 -0
  16. package/dist/es/components/WinControlTool/index.css +5 -0
  17. package/dist/es/components/WinControlTool/index.mjs +76 -0
  18. package/dist/es/controller/ai-config.mjs +40 -0
  19. package/dist/es/controller/auto-create.mjs +19 -0
  20. package/dist/es/controller/selectors.mjs +78 -0
  21. package/dist/es/controller/single-flight.mjs +13 -0
  22. package/dist/es/controller/types.mjs +0 -0
  23. package/dist/es/controller/usePlaygroundController.mjs +400 -0
  24. package/dist/es/icons/dropdown-chevron.mjs +61 -0
  25. package/dist/es/icons/midscene-logo.mjs +247 -0
  26. package/dist/es/icons/server-offline-background.mjs +102 -0
  27. package/dist/es/icons/server-offline-foreground.mjs +200 -0
  28. package/dist/es/index.mjs +7 -0
  29. package/dist/es/manual-interaction.mjs +56 -0
  30. package/dist/es/panels/PlaygroundConversationPanel.css +20 -0
  31. package/dist/es/panels/PlaygroundConversationPanel.mjs +140 -0
  32. package/dist/es/runtime-info.mjs +128 -0
  33. package/dist/es/scrcpy-preview.mjs +30 -0
  34. package/dist/es/scrcpy-stream.mjs +53 -0
  35. package/dist/es/session-setup.mjs +13 -0
  36. package/dist/es/session-state.mjs +32 -0
  37. package/dist/es/useServerStatus.mjs +120 -0
  38. package/dist/lib/DeviceInteractionLayer.js +434 -0
  39. package/dist/lib/PlaygroundApp.css +207 -0
  40. package/dist/lib/PlaygroundApp.js +821 -0
  41. package/dist/lib/PlaygroundPreview.js +63 -0
  42. package/dist/lib/PlaygroundThemeProvider.js +44 -0
  43. package/dist/lib/PreviewRenderer.js +304 -0
  44. package/dist/lib/ScrcpyPanel.js +424 -0
  45. package/dist/lib/SessionSetupPanel.css +299 -0
  46. package/dist/lib/SessionSetupPanel.js +217 -0
  47. package/dist/lib/components/Header/index.css +19 -0
  48. package/dist/lib/components/Header/index.js +81 -0
  49. package/dist/lib/components/Nav/index.css +15 -0
  50. package/dist/lib/components/Nav/index.js +127 -0
  51. package/dist/lib/components/WinControlTool/index.css +5 -0
  52. package/dist/lib/components/WinControlTool/index.js +110 -0
  53. package/dist/lib/controller/ai-config.js +80 -0
  54. package/dist/lib/controller/auto-create.js +59 -0
  55. package/dist/lib/controller/selectors.js +115 -0
  56. package/dist/lib/controller/single-flight.js +47 -0
  57. package/dist/lib/controller/types.js +18 -0
  58. package/dist/lib/controller/usePlaygroundController.js +434 -0
  59. package/dist/lib/icons/dropdown-chevron.js +95 -0
  60. package/dist/lib/icons/midscene-logo.js +281 -0
  61. package/dist/lib/icons/server-offline-background.js +136 -0
  62. package/dist/lib/icons/server-offline-foreground.js +234 -0
  63. package/dist/lib/index.js +56 -0
  64. package/dist/lib/manual-interaction.js +90 -0
  65. package/dist/lib/panels/PlaygroundConversationPanel.css +20 -0
  66. package/dist/lib/panels/PlaygroundConversationPanel.js +174 -0
  67. package/dist/lib/runtime-info.js +174 -0
  68. package/dist/lib/scrcpy-preview.js +79 -0
  69. package/dist/lib/scrcpy-stream.js +87 -0
  70. package/dist/lib/session-setup.js +47 -0
  71. package/dist/lib/session-state.js +69 -0
  72. package/dist/lib/useServerStatus.js +154 -0
  73. package/dist/types/DeviceInteractionLayer.d.ts +50 -0
  74. package/dist/types/PlaygroundApp.d.ts +14 -0
  75. package/dist/types/PlaygroundPreview.d.ts +22 -0
  76. package/dist/types/PlaygroundThemeProvider.d.ts +2 -0
  77. package/dist/types/PreviewRenderer.d.ts +27 -0
  78. package/dist/types/ScrcpyPanel.d.ts +21 -0
  79. package/dist/types/SessionSetupPanel.d.ts +16 -0
  80. package/dist/types/components/Header/index.d.ts +3 -0
  81. package/dist/types/components/Nav/index.d.ts +3 -0
  82. package/dist/types/components/WinControlTool/index.d.ts +3 -0
  83. package/dist/types/controller/ai-config.d.ts +5 -0
  84. package/dist/types/controller/auto-create.d.ts +15 -0
  85. package/dist/types/controller/selectors.d.ts +5 -0
  86. package/dist/types/controller/single-flight.d.ts +3 -0
  87. package/dist/types/controller/types.d.ts +36 -0
  88. package/dist/types/controller/usePlaygroundController.d.ts +16 -0
  89. package/dist/types/index.d.ts +13 -0
  90. package/dist/types/manual-interaction.d.ts +21 -0
  91. package/dist/types/panels/PlaygroundConversationPanel.d.ts +25 -0
  92. package/dist/types/runtime-info.d.ts +22 -0
  93. package/dist/types/scrcpy-preview.d.ts +11 -0
  94. package/dist/types/scrcpy-stream.d.ts +16 -0
  95. package/dist/types/session-setup.d.ts +2 -0
  96. package/dist/types/session-state.d.ts +9 -0
  97. package/dist/types/useServerStatus.d.ts +12 -0
  98. package/package.json +69 -0
@@ -0,0 +1,821 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ PlaygroundApp: ()=>PlaygroundApp
37
+ });
38
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
39
+ const visualizer_namespaceObject = require("@godscene/visualizer");
40
+ const external_antd_namespaceObject = require("antd");
41
+ const external_react_namespaceObject = require("react");
42
+ const external_react_resizable_panels_namespaceObject = require("react-resizable-panels");
43
+ const external_PlaygroundThemeProvider_js_namespaceObject = require("./PlaygroundThemeProvider.js");
44
+ const usePlaygroundController_js_namespaceObject = require("./controller/usePlaygroundController.js");
45
+ const server_offline_background_js_namespaceObject = require("./icons/server-offline-background.js");
46
+ var server_offline_background_js_default = /*#__PURE__*/ __webpack_require__.n(server_offline_background_js_namespaceObject);
47
+ const server_offline_foreground_js_namespaceObject = require("./icons/server-offline-foreground.js");
48
+ var server_offline_foreground_js_default = /*#__PURE__*/ __webpack_require__.n(server_offline_foreground_js_namespaceObject);
49
+ const PlaygroundConversationPanel_js_namespaceObject = require("./panels/PlaygroundConversationPanel.js");
50
+ const index_js_namespaceObject = require("./components/Header/index.js");
51
+ const Nav_index_js_namespaceObject = require("./components/Nav/index.js");
52
+ const constants_namespaceObject = require("@godscene/shared/constants");
53
+ require("./PlaygroundApp.css");
54
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
55
+ try {
56
+ var info = gen[key](arg);
57
+ var value = info.value;
58
+ } catch (error) {
59
+ reject(error);
60
+ return;
61
+ }
62
+ if (info.done) resolve(value);
63
+ else Promise.resolve(value).then(_next, _throw);
64
+ }
65
+ function _async_to_generator(fn) {
66
+ return function() {
67
+ var self = this, args = arguments;
68
+ return new Promise(function(resolve, reject) {
69
+ var gen = fn.apply(self, args);
70
+ function _next(value) {
71
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
72
+ }
73
+ function _throw(err) {
74
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
75
+ }
76
+ _next(void 0);
77
+ });
78
+ };
79
+ }
80
+ function _define_property(obj, key, value) {
81
+ if (key in obj) Object.defineProperty(obj, key, {
82
+ value: value,
83
+ enumerable: true,
84
+ configurable: true,
85
+ writable: true
86
+ });
87
+ else obj[key] = value;
88
+ return obj;
89
+ }
90
+ function _object_spread(target) {
91
+ for(var i = 1; i < arguments.length; i++){
92
+ var source = null != arguments[i] ? arguments[i] : {};
93
+ var ownKeys = Object.keys(source);
94
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
95
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
96
+ }));
97
+ ownKeys.forEach(function(key) {
98
+ _define_property(target, key, source[key]);
99
+ });
100
+ }
101
+ return target;
102
+ }
103
+ function PlaygroundApp_ownKeys(object, enumerableOnly) {
104
+ var keys = Object.keys(object);
105
+ if (Object.getOwnPropertySymbols) {
106
+ var symbols = Object.getOwnPropertySymbols(object);
107
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
108
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
109
+ });
110
+ keys.push.apply(keys, symbols);
111
+ }
112
+ return keys;
113
+ }
114
+ function _object_spread_props(target, source) {
115
+ source = null != source ? source : {};
116
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
117
+ else PlaygroundApp_ownKeys(Object(source)).forEach(function(key) {
118
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
119
+ });
120
+ return target;
121
+ }
122
+ const { Content } = external_antd_namespaceObject.Layout;
123
+ function PlaygroundApp({ serverUrl, appVersion, title = 'Playground', defaultDeviceType = 'web', branding, playgroundConfig, offlineTitle = 'Midscene Playground', offlineStatusText = 'Server offline...', pollIntervalMs = 5000 }) {
124
+ var _playgroundConfig_executionUx;
125
+ const [isNarrowScreen, setIsNarrowScreen] = (0, external_react_namespaceObject.useState)(false);
126
+ const controller = (0, usePlaygroundController_js_namespaceObject.usePlaygroundController)({
127
+ serverUrl,
128
+ defaultDeviceType,
129
+ countdownSeconds: null == playgroundConfig ? void 0 : null == (_playgroundConfig_executionUx = playgroundConfig.executionUx) ? void 0 : _playgroundConfig_executionUx.countdownSeconds,
130
+ pollIntervalMs
131
+ });
132
+ (0, external_react_namespaceObject.useEffect)(()=>{
133
+ const handleResize = ()=>{
134
+ setIsNarrowScreen(window.innerWidth <= 1024);
135
+ };
136
+ handleResize();
137
+ window.addEventListener('resize', handleResize);
138
+ return ()=>window.removeEventListener('resize', handleResize);
139
+ }, []);
140
+ const rightRef = (0, external_react_namespaceObject.useRef)(null);
141
+ const viewRef = (0, external_react_namespaceObject.useRef)(null);
142
+ const actionRef = (0, external_react_namespaceObject.useRef)(null);
143
+ const [agentReady, setAgentReady] = (0, external_react_namespaceObject.useState)(false);
144
+ const [dialogInfo, setDialogInfo] = (0, external_react_namespaceObject.useState)(null);
145
+ (0, external_react_namespaceObject.useEffect)(()=>{
146
+ var _window_electron;
147
+ null == (_window_electron = window.electron) || _window_electron.ipcRenderer.on('agent:ready', (event, value)=>{
148
+ if (!value) external_antd_namespaceObject.Modal.warning({
149
+ title: '初始化失败',
150
+ content: '请确认是否购买了token',
151
+ getContainer: ()=>rightRef.current,
152
+ mask: false,
153
+ className: "insert-modal",
154
+ wrapClassName: 'insert-modal-wrap',
155
+ zIndex: 99999
156
+ });
157
+ setAgentReady(value);
158
+ });
159
+ }, []);
160
+ (0, external_react_namespaceObject.useEffect)(()=>{
161
+ actionRef.current = {
162
+ receiveMsg (msgData) {
163
+ return _async_to_generator(function*() {
164
+ const { message } = msgData;
165
+ const { pageName, actionName, data } = message;
166
+ console.log('/////////////receive-msg/////////', message);
167
+ if ('initialize' === actionName) setDialogInfo(_object_spread({
168
+ pageName
169
+ }, data));
170
+ else if ('insertScriptCommandResult' === actionName) {
171
+ const { success, message } = data;
172
+ switch(success){
173
+ case true:
174
+ external_antd_namespaceObject.Modal.success({
175
+ title: '使用命令成功',
176
+ content: '已为您生成命令,请在设计器主页查看命令详情',
177
+ getContainer: ()=>rightRef.current,
178
+ mask: false,
179
+ className: "insert-modal",
180
+ wrapClassName: 'insert-modal-wrap',
181
+ zIndex: 99999
182
+ });
183
+ break;
184
+ case false:
185
+ external_antd_namespaceObject.Modal.warning({
186
+ title: '使用命令失败',
187
+ content: message || '使用命令失败,请稍后再试',
188
+ getContainer: ()=>rightRef.current,
189
+ mask: false,
190
+ className: "insert-modal",
191
+ wrapClassName: 'insert-modal-wrap',
192
+ zIndex: 99999
193
+ });
194
+ break;
195
+ default:
196
+ break;
197
+ }
198
+ }
199
+ })();
200
+ }
201
+ };
202
+ }, []);
203
+ (0, external_react_namespaceObject.useEffect)(()=>{
204
+ console.log(!!viewRef.current, 'viewRef.current');
205
+ const resizeObserver = new ResizeObserver((entries)=>{
206
+ for (let entry of entries){
207
+ var _window_electron;
208
+ console.log(entry.contentRect.width, entry.contentRect.height, 'entry.contentRect.width, entry.contentRect.height');
209
+ null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('playgroundViewer:resize', entry.contentRect.width, entry.contentRect.height);
210
+ }
211
+ });
212
+ if (viewRef.current) {
213
+ var _window_electron;
214
+ console.log(viewRef.current.clientWidth, viewRef.current.clientHeight, 'viewRef.current.clientWidth, viewRef.current.clientHeight');
215
+ null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('playgroundViewer:resize', viewRef.current.clientWidth, viewRef.current.clientHeight);
216
+ resizeObserver.observe(viewRef.current);
217
+ }
218
+ return ()=>{
219
+ if (viewRef.current) resizeObserver.unobserve(viewRef.current);
220
+ resizeObserver.disconnect();
221
+ };
222
+ }, [
223
+ viewRef,
224
+ agentReady,
225
+ controller.state.serverOnline
226
+ ]);
227
+ const handler = (0, external_react_namespaceObject.useCallback)((msgData)=>{
228
+ var _actionRef_current;
229
+ null == (_actionRef_current = actionRef.current) || _actionRef_current.receiveMsg(msgData);
230
+ }, [
231
+ actionRef
232
+ ]);
233
+ (0, external_react_namespaceObject.useEffect)(()=>{
234
+ var _window___Window;
235
+ if (null == (_window___Window = window.__Window) ? void 0 : _window___Window.receiveMessage) window.__Window.receiveMessage(handler);
236
+ }, [
237
+ handler
238
+ ]);
239
+ const onHumanUse = (0, external_react_namespaceObject.useCallback)((recommendResult)=>{
240
+ if (!(null == recommendResult ? void 0 : recommendResult.length)) return external_antd_namespaceObject.message.warning('暂无可使用的命令');
241
+ console.log(recommendResult, 'recommendResult');
242
+ try {
243
+ const data = recommendResult.map((item)=>{
244
+ var _commandMap_item_subType, _commandMap_item_subType1;
245
+ let res = {
246
+ CommandName: null == (_commandMap_item_subType = constants_namespaceObject.commandMap[item.subType]) ? void 0 : _commandMap_item_subType.CommandName,
247
+ DisplayName: null == (_commandMap_item_subType1 = constants_namespaceObject.commandMap[item.subType]) ? void 0 : _commandMap_item_subType1.DisplayName,
248
+ Parameters: {}
249
+ };
250
+ switch(item.subType){
251
+ case constants_namespaceObject.rpasceneCommand.Scroll:
252
+ {
253
+ const { scrollType, direction, distance } = item.param || {};
254
+ if ("untilBottom" === scrollType) res.Parameters = {
255
+ ScrollPosition: {
256
+ Key: "ScrollPosition",
257
+ Name: "滚动位置",
258
+ Value: "Bottom"
259
+ }
260
+ };
261
+ else if ("untilTop" === scrollType) res.Parameters = {
262
+ ScrollPosition: {
263
+ Key: "ScrollPosition",
264
+ Name: "滚动位置",
265
+ Value: "Top"
266
+ }
267
+ };
268
+ else if ('untilRight' === scrollType) res.Parameters = {
269
+ ScrollPosition: {
270
+ Key: "ScrollPosition",
271
+ Name: "滚动位置",
272
+ Value: "Position"
273
+ },
274
+ ScrollWidth: {
275
+ Key: "ScrollWidth",
276
+ Name: "滚动到横坐标位置",
277
+ Value: 999999
278
+ }
279
+ };
280
+ else if ('untilLeft' === scrollType) res.Parameters = {
281
+ ScrollPosition: {
282
+ Key: "ScrollPosition",
283
+ Name: "滚动位置",
284
+ Value: "Position"
285
+ },
286
+ ScrollWidth: {
287
+ Key: "ScrollWidth",
288
+ Name: "滚动到横坐标位置",
289
+ Value: -999999
290
+ }
291
+ };
292
+ else if ('once' === scrollType) {
293
+ if ('left' === direction || 'right' === direction) res.Parameters = {
294
+ ScrollPosition: {
295
+ Key: "ScrollPosition",
296
+ Name: "滚动位置",
297
+ Value: "Position"
298
+ },
299
+ ScrollWidth: {
300
+ Key: "ScrollWidth",
301
+ Name: "滚动到横坐标位置",
302
+ Value: distance
303
+ }
304
+ };
305
+ if ('up' === direction || 'down' === direction) res.Parameters = {
306
+ ScrollPosition: {
307
+ Key: "ScrollPosition",
308
+ Name: "滚动位置",
309
+ Value: "Position"
310
+ },
311
+ ScrollHeight: {
312
+ Key: "ScrollWidth",
313
+ Name: "滚动到纵坐标位置",
314
+ Value: distance
315
+ }
316
+ };
317
+ }
318
+ if (item.param.locate) {
319
+ var _item_param_locate_allPaths_, _item_param_locate_allPaths, _item_param_locate, _item_param_locate1;
320
+ res.CommandName = constants_namespaceObject.rpastudioCommand.SeleniumElementScrollCommand;
321
+ res.Parameters = _object_spread_props(_object_spread({}, res.Parameters), {
322
+ SearchParameter: {
323
+ Key: "SearchParameter",
324
+ Value: null == (_item_param_locate = item.param.locate) ? void 0 : null == (_item_param_locate_allPaths = _item_param_locate.allPaths) ? void 0 : null == (_item_param_locate_allPaths_ = _item_param_locate_allPaths[0]) ? void 0 : _item_param_locate_allPaths_.value
325
+ },
326
+ ElementName: {
327
+ Key: "ElementName",
328
+ Name: "元素名称",
329
+ Value: item.locateDescription
330
+ },
331
+ ContainerXpath: {
332
+ Key: "ContainerXpath",
333
+ Name: "父级Xpath",
334
+ Value: JSON.stringify((null == (_item_param_locate1 = item.param.locate) ? void 0 : _item_param_locate1.containerPaths) || [])
335
+ },
336
+ ElementIndex: {
337
+ Key: "ElementIndex",
338
+ Value: 1
339
+ }
340
+ });
341
+ } else res.CommandName = constants_namespaceObject.rpastudioCommand.SeleniumWindowScrollCommand;
342
+ break;
343
+ }
344
+ case constants_namespaceObject.rpasceneCommand.KeyboardPress:
345
+ {
346
+ var _item_param;
347
+ let keyName = (null == (_item_param = item.param) ? void 0 : _item_param.keyName) || '';
348
+ let useSeleniumElementSendKeysCommand = false;
349
+ if (useSeleniumElementSendKeysCommand && item.param.locate) {
350
+ var _item_param_locate2, _item_param1, _item_param_locate_allPaths_1, _item_param_locate_allPaths1, _item_param_locate3, _item_param2;
351
+ const keyValue = keyName.split('+').map((item)=>{
352
+ const key = item.trim();
353
+ switch(key.toLowerCase()){
354
+ case 'backspace':
355
+ return '{BACKSPACE}';
356
+ case 'capslock':
357
+ return '{CAPSLOCK}';
358
+ case 'delete':
359
+ return '{DELETE}';
360
+ case 'arrowdown':
361
+ return '{DOWN}';
362
+ case 'end':
363
+ return '{END}';
364
+ case 'enter':
365
+ return '{ENTER}';
366
+ case 'escape':
367
+ return '{ESC}';
368
+ case 'help':
369
+ return '{HELP}';
370
+ case 'home':
371
+ return '{HOME}';
372
+ case 'insert':
373
+ return '{Insert}';
374
+ case 'arrowleft':
375
+ return '{LEFT}';
376
+ case 'numlock':
377
+ return 'NUMLOCK';
378
+ case 'pagedown':
379
+ return '{PGDN}';
380
+ case 'pageup':
381
+ return '{PGUP}';
382
+ case 'printscreen':
383
+ return '{PRTSC}';
384
+ case 'arrowright':
385
+ return '{RIGHT}';
386
+ case 'scrolllock':
387
+ return '{SCROLLLOCK}';
388
+ case 'tab':
389
+ return '{TAB}';
390
+ case 'arrowup':
391
+ return '{UP}';
392
+ case 'f1':
393
+ return '{F1}';
394
+ case 'f2':
395
+ return '{F2}';
396
+ case 'f3':
397
+ return '{F3}';
398
+ case 'f4':
399
+ return '{F4}';
400
+ case 'f5':
401
+ return '{F5}';
402
+ case 'f6':
403
+ return '{F6}';
404
+ case 'f7':
405
+ return '{F7}';
406
+ case 'f8':
407
+ return '{F8}';
408
+ case 'f9':
409
+ return '{F9}';
410
+ case 'f10':
411
+ return '{F10}';
412
+ case 'f11':
413
+ return '{F11}';
414
+ case 'f12':
415
+ return '{F12}';
416
+ case 'numpadadd':
417
+ return '{ADD}';
418
+ case 'numpadsubtract':
419
+ return '{SUBTRACT}';
420
+ case 'numpadmultiply':
421
+ return '{MULTIPLY}';
422
+ case 'numpaddivide':
423
+ return '{DIVIDE}';
424
+ case 'shift':
425
+ return '+';
426
+ case 'control':
427
+ return '^';
428
+ case 'alt':
429
+ return '%';
430
+ default:
431
+ return key;
432
+ }
433
+ }).filter(Boolean).join('');
434
+ res.CommandName = constants_namespaceObject.rpastudioCommand.SeleniumElementSendKeysCommand;
435
+ res.Parameters = {
436
+ ContainerXpath: {
437
+ Key: "ContainerXpath",
438
+ Name: "父级Xpath",
439
+ Value: JSON.stringify((null == (_item_param1 = item.param) ? void 0 : null == (_item_param_locate2 = _item_param1.locate) ? void 0 : _item_param_locate2.containerPaths) || [])
440
+ },
441
+ ElementName: {
442
+ Key: "ElementName",
443
+ Name: "元素名称",
444
+ Value: item.locateDescription || ''
445
+ },
446
+ SearchParameter: {
447
+ Key: "SearchParameter",
448
+ Name: "元素搜索参数",
449
+ Value: (null == (_item_param2 = item.param) ? void 0 : null == (_item_param_locate3 = _item_param2.locate) ? void 0 : null == (_item_param_locate_allPaths1 = _item_param_locate3.allPaths) ? void 0 : null == (_item_param_locate_allPaths_1 = _item_param_locate_allPaths1[0]) ? void 0 : _item_param_locate_allPaths_1.value) || ''
450
+ },
451
+ SearchType: {
452
+ Key: "SearchType",
453
+ Name: "元素搜索方式",
454
+ Value: "Find Element By XPath"
455
+ },
456
+ Value: {
457
+ Key: "Value",
458
+ Name: "文本内容",
459
+ Value: keyValue
460
+ }
461
+ };
462
+ } else {
463
+ const keyValue = keyName.split('+').map((item)=>{
464
+ const key = item.trim();
465
+ switch(key.toLowerCase()){
466
+ case 'backspace':
467
+ return 'BACKSPACE';
468
+ case 'delete':
469
+ return 'DELETE';
470
+ case 'arrowdown':
471
+ return 'DOWN';
472
+ case 'end':
473
+ return 'END';
474
+ case 'enter':
475
+ return 'ENTER';
476
+ case 'escape':
477
+ return 'ESC';
478
+ case 'help':
479
+ return 'HELP';
480
+ case 'home':
481
+ return 'HOME';
482
+ case 'insert':
483
+ return 'INSERT';
484
+ case 'arrowleft':
485
+ return 'LEFT';
486
+ case 'pagedown':
487
+ return 'PGDN';
488
+ case 'pageup':
489
+ return 'PGUP';
490
+ case 'arrowright':
491
+ return 'RIGHT';
492
+ case 'tab':
493
+ return 'TAB';
494
+ case 'arrowup':
495
+ return 'UP';
496
+ case 'f1':
497
+ return 'F1';
498
+ case 'f2':
499
+ return 'F2';
500
+ case 'f3':
501
+ return 'F3';
502
+ case 'f4':
503
+ return 'F4';
504
+ case 'f5':
505
+ return 'F5';
506
+ case 'f6':
507
+ return 'F6';
508
+ case 'f7':
509
+ return 'F7';
510
+ case 'f8':
511
+ return 'F8';
512
+ case 'f9':
513
+ return 'F9';
514
+ case 'f10':
515
+ return 'F10';
516
+ case 'f11':
517
+ return 'F11';
518
+ case 'f12':
519
+ return 'F12';
520
+ case 'numpadadd':
521
+ return 'ADD';
522
+ case 'numpadsubtract':
523
+ return 'SUBTRACT';
524
+ case 'numpadmultiply':
525
+ return 'MULTIPLY';
526
+ case 'numpaddivide':
527
+ return 'DIVIDE';
528
+ case 'shift':
529
+ return 'SHIFT';
530
+ case 'control':
531
+ return 'CTRL';
532
+ case 'alt':
533
+ return 'ALT';
534
+ case 'capslock':
535
+ return 'CAPSLOCK';
536
+ case 'numlock':
537
+ return 'NUMLOCK';
538
+ case 'printscreen':
539
+ return 'PRTSC';
540
+ case 'scrolllock':
541
+ return 'SCROLLLOCK';
542
+ default:
543
+ return key;
544
+ }
545
+ }).filter(Boolean).join('');
546
+ res.CommandName = constants_namespaceObject.rpastudioCommand.SeleniumSendKeysCommand;
547
+ res.Parameters = {
548
+ TextToSend: {
549
+ Key: "TextToSend",
550
+ Name: "请输入要发送的文本",
551
+ Value: keyValue
552
+ }
553
+ };
554
+ }
555
+ break;
556
+ }
557
+ case constants_namespaceObject.rpasceneCommand.Tap:
558
+ case constants_namespaceObject.rpasceneCommand.RightClick:
559
+ case constants_namespaceObject.rpasceneCommand.DoubleClick:
560
+ case constants_namespaceObject.rpasceneCommand.Hover:
561
+ case constants_namespaceObject.rpasceneCommand.ClearInput:
562
+ var _item_param_locate_allPaths_2, _item_param_locate_allPaths2, _item_param_locate4, _item_param3, _item_param_locate5, _item_param4;
563
+ res.Parameters = {
564
+ SearchParameter: {
565
+ Key: "SearchParameter",
566
+ Value: (null == (_item_param3 = item.param) ? void 0 : null == (_item_param_locate4 = _item_param3.locate) ? void 0 : null == (_item_param_locate_allPaths2 = _item_param_locate4.allPaths) ? void 0 : null == (_item_param_locate_allPaths_2 = _item_param_locate_allPaths2[0]) ? void 0 : _item_param_locate_allPaths_2.value) || ''
567
+ },
568
+ ElementName: {
569
+ Key: "ElementName",
570
+ Name: "元素名称",
571
+ Value: item.locateDescription || ''
572
+ },
573
+ ContainerXpath: {
574
+ Key: "ContainerXpath",
575
+ Name: "父级Xpath",
576
+ Value: JSON.stringify((null == (_item_param4 = item.param) ? void 0 : null == (_item_param_locate5 = _item_param4.locate) ? void 0 : _item_param_locate5.containerPaths) || [])
577
+ },
578
+ ElementIndex: {
579
+ Key: "ElementIndex",
580
+ Value: 1
581
+ }
582
+ };
583
+ break;
584
+ case constants_namespaceObject.rpasceneCommand.Input:
585
+ var _item_param_locate_allPaths_3, _item_param_locate_allPaths3, _item_param_locate6, _item_param5, _item_param_locate7, _item_param6, _item_param7, _item_param8;
586
+ res.Parameters = {
587
+ SearchParameter: {
588
+ Key: "SearchParameter",
589
+ Name: "元素搜索参数",
590
+ Value: (null == (_item_param5 = item.param) ? void 0 : null == (_item_param_locate6 = _item_param5.locate) ? void 0 : null == (_item_param_locate_allPaths3 = _item_param_locate6.allPaths) ? void 0 : null == (_item_param_locate_allPaths_3 = _item_param_locate_allPaths3[0]) ? void 0 : _item_param_locate_allPaths_3.value) || ''
591
+ },
592
+ ContainerXpath: {
593
+ Key: "ContainerXpath",
594
+ Name: "父级Xpath",
595
+ Value: JSON.stringify((null == (_item_param6 = item.param) ? void 0 : null == (_item_param_locate7 = _item_param6.locate) ? void 0 : _item_param_locate7.containerPaths) || [])
596
+ },
597
+ ElementName: {
598
+ Key: "ElementName",
599
+ Name: "元素名称",
600
+ Value: item.locateDescription || ''
601
+ },
602
+ Value: {
603
+ Key: "Value",
604
+ Name: '文本内容',
605
+ Value: (null == (_item_param7 = item.param) ? void 0 : _item_param7.value) || ''
606
+ },
607
+ ClearBeforeInput: {
608
+ Key: "ClearBeforeInput",
609
+ Name: "输入前是否清空",
610
+ Value: (null == (_item_param8 = item.param) ? void 0 : _item_param8.mode) !== "append"
611
+ }
612
+ };
613
+ break;
614
+ case constants_namespaceObject.rpasceneCommand.Sleep:
615
+ var _ref;
616
+ var _item_param9;
617
+ res.Parameters = {
618
+ PauseLength: {
619
+ Key: "PauseLength",
620
+ Name: "暂停时间(毫秒)",
621
+ Value: null != (_ref = null == (_item_param9 = item.param) ? void 0 : _item_param9.timeMs) ? _ref : 0
622
+ }
623
+ };
624
+ break;
625
+ case constants_namespaceObject.rpasceneCommand.DragAndDrop:
626
+ var _item_param_from, _item_param10, _item_param_from1, _item_param11, _item_param_from_allPaths_, _item_param_from_allPaths, _item_param_from2, _item_param12, _item_param_to, _item_param13, _item_param_to_allPaths_, _item_param_to_allPaths, _item_param_to1, _item_param14;
627
+ res.Parameters = {
628
+ ContainerXpath: {
629
+ Key: "ContainerXpath",
630
+ Name: "拖动元素父级Xpath",
631
+ Value: JSON.stringify((null == (_item_param10 = item.param) ? void 0 : null == (_item_param_from = _item_param10.from) ? void 0 : _item_param_from.containerPaths) || [])
632
+ },
633
+ ElementName: {
634
+ Key: "ElementName",
635
+ Name: "拖动元素名称",
636
+ Value: (null == (_item_param11 = item.param) ? void 0 : null == (_item_param_from1 = _item_param11.from) ? void 0 : _item_param_from1.locateDescription) || ''
637
+ },
638
+ SearchParameter: {
639
+ Key: "SearchParameter",
640
+ Name: "拖动元素搜索参数",
641
+ Value: (null == (_item_param12 = item.param) ? void 0 : null == (_item_param_from2 = _item_param12.from) ? void 0 : null == (_item_param_from_allPaths = _item_param_from2.allPaths) ? void 0 : null == (_item_param_from_allPaths_ = _item_param_from_allPaths[0]) ? void 0 : _item_param_from_allPaths_.value) || ''
642
+ },
643
+ SearchType: {
644
+ Key: "SearchType",
645
+ Name: "拖动元素搜索方式",
646
+ Value: "Find Element By XPath"
647
+ },
648
+ TargetContainerXpath: {
649
+ Key: "TargetContainerXpath",
650
+ Name: "目标元素父级Xpath",
651
+ Value: JSON.stringify((null == (_item_param13 = item.param) ? void 0 : null == (_item_param_to = _item_param13.to) ? void 0 : _item_param_to.containerPaths) || [])
652
+ },
653
+ TargetSearchParameter: {
654
+ Key: "TargetSearchParameter",
655
+ Name: "目标元素搜索参数",
656
+ Value: (null == (_item_param14 = item.param) ? void 0 : null == (_item_param_to1 = _item_param14.to) ? void 0 : null == (_item_param_to_allPaths = _item_param_to1.allPaths) ? void 0 : null == (_item_param_to_allPaths_ = _item_param_to_allPaths[0]) ? void 0 : _item_param_to_allPaths_.value) || ''
657
+ },
658
+ TargetSearchType: {
659
+ Key: "TargetSearchType",
660
+ Name: "目标元素搜索方式",
661
+ Value: "Find Element By XPath"
662
+ }
663
+ };
664
+ break;
665
+ case constants_namespaceObject.rpasceneCommand.Reload:
666
+ case constants_namespaceObject.rpasceneCommand.GoBack:
667
+ res.Parameters = {};
668
+ break;
669
+ case constants_namespaceObject.rpasceneCommand.Navigate:
670
+ var _item_param15;
671
+ res.Parameters = {
672
+ URL: {
673
+ Key: "URL",
674
+ Name: "网址",
675
+ Value: (null == (_item_param15 = item.param) ? void 0 : _item_param15.url) || ''
676
+ }
677
+ };
678
+ break;
679
+ default:
680
+ res = null;
681
+ }
682
+ return res;
683
+ }).filter(Boolean);
684
+ console.log(data, '生成的命令data------------------------');
685
+ (null == dialogInfo ? void 0 : dialogInfo.parentToken) && window.__Window.sendMessage({
686
+ from: dialogInfo.token,
687
+ to: dialogInfo.parentToken,
688
+ token: `${Math.random()}`,
689
+ message: {
690
+ pageName: 'aiGenerateScript',
691
+ actionName: 'insertScriptCommand',
692
+ data
693
+ }
694
+ });
695
+ } catch (error) {
696
+ console.error(error, 'error');
697
+ }
698
+ }, [
699
+ null == dialogInfo ? void 0 : dialogInfo.token,
700
+ null == dialogInfo ? void 0 : dialogInfo.parentToken
701
+ ]);
702
+ if (!controller.state.serverOnline) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PlaygroundThemeProvider_js_namespaceObject.PlaygroundThemeProvider, {
703
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
704
+ className: "server-offline-container",
705
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
706
+ className: "server-offline-message",
707
+ children: [
708
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.Logo, {}),
709
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
710
+ className: "server-offline-content",
711
+ children: [
712
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
713
+ className: "server-offline-icon",
714
+ children: [
715
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(server_offline_background_js_default(), {
716
+ className: "icon-background"
717
+ }),
718
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(server_offline_foreground_js_default(), {
719
+ className: "icon-foreground"
720
+ })
721
+ ]
722
+ }),
723
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h1", {
724
+ children: offlineTitle
725
+ }),
726
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
727
+ className: "connection-status",
728
+ children: offlineStatusText
729
+ })
730
+ ]
731
+ })
732
+ ]
733
+ })
734
+ })
735
+ });
736
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PlaygroundThemeProvider_js_namespaceObject.PlaygroundThemeProvider, {
737
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_antd_namespaceObject.Layout, {
738
+ className: "app-container playground-container",
739
+ children: [
740
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.Header, _object_spread({}, dialogInfo || {})),
741
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Content, {
742
+ className: "app-content",
743
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_react_resizable_panels_namespaceObject.PanelGroup, {
744
+ autoSaveId: "playground-layout",
745
+ direction: isNarrowScreen ? 'vertical' : 'horizontal',
746
+ children: [
747
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
748
+ defaultSize: isNarrowScreen ? 33 : 68,
749
+ minSize: isNarrowScreen ? 15 : 40,
750
+ className: "app-panel right-panel",
751
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
752
+ className: "panel-content right-panel-content",
753
+ children: [
754
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Nav_index_js_namespaceObject.Nav, {}),
755
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
756
+ className: "screenshot-viewer offline",
757
+ ref: viewRef,
758
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
759
+ className: "screenshot-placeholder",
760
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h3", {
761
+ children: "Screen Preview"
762
+ })
763
+ })
764
+ })
765
+ ]
766
+ })
767
+ }),
768
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.PanelResizeHandle, {
769
+ className: "panel-resize-handle"
770
+ }),
771
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
772
+ defaultSize: isNarrowScreen ? 67 : 32,
773
+ maxSize: isNarrowScreen ? 85 : 60,
774
+ minSize: isNarrowScreen ? 67 : 25,
775
+ className: "app-panel left-panel",
776
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
777
+ className: "panel-content left-panel-content",
778
+ ref: rightRef,
779
+ children: [
780
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
781
+ className: "playground-panel-header",
782
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
783
+ className: "header-row",
784
+ children: [
785
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.Logo, {}),
786
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.NavActions, {
787
+ showTooltipWhenEmpty: false,
788
+ showModelName: false,
789
+ playgroundSDK: controller.state.playgroundSDK
790
+ })
791
+ ]
792
+ })
793
+ }),
794
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
795
+ className: "playground-panel-playground",
796
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(PlaygroundConversationPanel_js_namespaceObject.PlaygroundConversationPanel, {
797
+ controller: controller,
798
+ appVersion: appVersion,
799
+ branding: branding,
800
+ playgroundConfig: playgroundConfig,
801
+ title: title,
802
+ onHumanUse: onHumanUse
803
+ })
804
+ })
805
+ ]
806
+ })
807
+ })
808
+ ]
809
+ })
810
+ })
811
+ ]
812
+ })
813
+ });
814
+ }
815
+ exports.PlaygroundApp = __webpack_exports__.PlaygroundApp;
816
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
817
+ "PlaygroundApp"
818
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
819
+ Object.defineProperty(exports, '__esModule', {
820
+ value: true
821
+ });