@midscene/playground-app 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/PlaygroundApp.css +0 -128
- package/dist/es/PlaygroundApp.mjs +74 -464
- package/dist/es/PlaygroundThemeProvider.mjs +10 -0
- package/dist/es/PreviewRenderer.mjs +4 -1
- package/dist/es/ScrcpyPanel.mjs +97 -89
- package/dist/es/SessionSetupPanel.css +292 -0
- package/dist/es/SessionSetupPanel.mjs +60 -39
- package/dist/es/controller/ai-config.mjs +37 -0
- package/dist/es/controller/auto-create.mjs +19 -0
- package/dist/es/controller/selectors.mjs +66 -0
- package/dist/es/controller/types.mjs +0 -0
- package/dist/es/controller/usePlaygroundController.mjs +356 -0
- package/dist/es/icons/dropdown-chevron.mjs +61 -0
- package/dist/es/icons/midscene-logo.mjs +247 -0
- package/dist/es/index.mjs +4 -1
- package/dist/es/panels/PlaygroundConversationPanel.css +20 -0
- package/dist/es/panels/PlaygroundConversationPanel.mjs +134 -0
- package/dist/es/scrcpy-preview.mjs +30 -0
- package/dist/lib/PlaygroundApp.css +0 -128
- package/dist/lib/PlaygroundApp.js +70 -460
- package/dist/lib/PlaygroundThemeProvider.js +44 -0
- package/dist/lib/PreviewRenderer.js +4 -1
- package/dist/lib/ScrcpyPanel.js +96 -88
- package/dist/lib/SessionSetupPanel.css +292 -0
- package/dist/lib/SessionSetupPanel.js +70 -38
- package/dist/lib/controller/ai-config.js +74 -0
- package/dist/lib/controller/auto-create.js +59 -0
- package/dist/lib/controller/selectors.js +103 -0
- package/dist/lib/controller/types.js +18 -0
- package/dist/lib/controller/usePlaygroundController.js +390 -0
- package/dist/lib/icons/dropdown-chevron.js +95 -0
- package/dist/lib/icons/midscene-logo.js +281 -0
- package/dist/lib/index.js +14 -2
- package/dist/lib/panels/PlaygroundConversationPanel.css +20 -0
- package/dist/lib/panels/PlaygroundConversationPanel.js +168 -0
- package/dist/lib/scrcpy-preview.js +79 -0
- package/dist/types/PlaygroundPreview.d.ts +6 -0
- package/dist/types/PlaygroundThemeProvider.d.ts +2 -0
- package/dist/types/PreviewRenderer.d.ts +7 -1
- package/dist/types/ScrcpyPanel.d.ts +14 -1
- package/dist/types/SessionSetupPanel.d.ts +4 -3
- package/dist/types/controller/ai-config.d.ts +4 -0
- package/dist/types/controller/auto-create.d.ts +15 -0
- package/dist/types/controller/selectors.d.ts +5 -0
- package/dist/types/controller/types.d.ts +36 -0
- package/dist/types/controller/usePlaygroundController.d.ts +9 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/panels/PlaygroundConversationPanel.d.ts +20 -0
- package/dist/types/scrcpy-preview.d.ts +11 -0
- package/package.json +4 -3
|
@@ -36,227 +36,29 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
36
|
PlaygroundApp: ()=>PlaygroundApp
|
|
37
37
|
});
|
|
38
38
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
39
|
-
const playground_namespaceObject = require("@midscene/playground");
|
|
40
39
|
const visualizer_namespaceObject = require("@midscene/visualizer");
|
|
41
40
|
const external_antd_namespaceObject = require("antd");
|
|
42
41
|
const external_react_namespaceObject = require("react");
|
|
43
42
|
const external_react_resizable_panels_namespaceObject = require("react-resizable-panels");
|
|
44
|
-
const
|
|
45
|
-
const
|
|
43
|
+
const external_PlaygroundPreview_js_namespaceObject = require("./PlaygroundPreview.js");
|
|
44
|
+
const external_PlaygroundThemeProvider_js_namespaceObject = require("./PlaygroundThemeProvider.js");
|
|
45
|
+
const usePlaygroundController_js_namespaceObject = require("./controller/usePlaygroundController.js");
|
|
46
46
|
const server_offline_background_js_namespaceObject = require("./icons/server-offline-background.js");
|
|
47
47
|
var server_offline_background_js_default = /*#__PURE__*/ __webpack_require__.n(server_offline_background_js_namespaceObject);
|
|
48
48
|
const server_offline_foreground_js_namespaceObject = require("./icons/server-offline-foreground.js");
|
|
49
49
|
var server_offline_foreground_js_default = /*#__PURE__*/ __webpack_require__.n(server_offline_foreground_js_namespaceObject);
|
|
50
|
-
const
|
|
51
|
-
const external_session_state_js_namespaceObject = require("./session-state.js");
|
|
52
|
-
const external_useServerStatus_js_namespaceObject = require("./useServerStatus.js");
|
|
50
|
+
const PlaygroundConversationPanel_js_namespaceObject = require("./panels/PlaygroundConversationPanel.js");
|
|
53
51
|
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
52
|
const { Content } = external_antd_namespaceObject.Layout;
|
|
123
|
-
const { Text } = external_antd_namespaceObject.Typography;
|
|
124
|
-
function getPlatformSelectorFieldKey(setup) {
|
|
125
|
-
var _setup_platformSelector;
|
|
126
|
-
return null == setup ? void 0 : null == (_setup_platformSelector = setup.platformSelector) ? void 0 : _setup_platformSelector.fieldKey;
|
|
127
|
-
}
|
|
128
53
|
function PlaygroundApp({ serverUrl, appVersion, title = 'Playground', defaultDeviceType = 'web', branding, playgroundConfig, offlineTitle = 'Midscene Playground', offlineStatusText = 'Server offline...', pollIntervalMs = 5000 }) {
|
|
129
54
|
var _playgroundConfig_executionUx;
|
|
130
55
|
const [isNarrowScreen, setIsNarrowScreen] = (0, external_react_namespaceObject.useState)(false);
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const [messageApi, messageContextHolder] = external_antd_namespaceObject.message.useMessage();
|
|
138
|
-
var _playgroundConfig_executionUx_countdownSeconds;
|
|
139
|
-
const countdownSeconds = null != (_playgroundConfig_executionUx_countdownSeconds = null == playgroundConfig ? void 0 : null == (_playgroundConfig_executionUx = playgroundConfig.executionUx) ? void 0 : _playgroundConfig_executionUx.countdownSeconds) ? _playgroundConfig_executionUx_countdownSeconds : 3;
|
|
140
|
-
const platformSelectorFieldKey = getPlatformSelectorFieldKey(sessionSetup);
|
|
141
|
-
var _Form_useWatch;
|
|
142
|
-
const selectedPlatformId = null != (_Form_useWatch = external_antd_namespaceObject.Form.useWatch(platformSelectorFieldKey || 'platformId', setupForm)) ? _Form_useWatch : void 0;
|
|
143
|
-
const playgroundSDK = (0, external_react_namespaceObject.useMemo)(()=>new playground_namespaceObject.PlaygroundSDK({
|
|
144
|
-
type: 'remote-execution',
|
|
145
|
-
serverUrl
|
|
146
|
-
}), [
|
|
147
|
-
serverUrl
|
|
148
|
-
]);
|
|
149
|
-
const { serverOnline, isUserOperating, deviceType, runtimeInfo, executionUxHints, refreshServerState } = (0, external_useServerStatus_js_namespaceObject.useServerStatus)(playgroundSDK, defaultDeviceType, pollIntervalMs);
|
|
150
|
-
const sessionViewState = (0, external_react_namespaceObject.useMemo)(()=>(0, external_session_state_js_namespaceObject.resolveSessionViewState)(runtimeInfo), [
|
|
151
|
-
runtimeInfo
|
|
152
|
-
]);
|
|
153
|
-
const countdownTimerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
154
|
-
const countdownResolveRef = (0, external_react_namespaceObject.useRef)(null);
|
|
155
|
-
const mountedRef = (0, external_react_namespaceObject.useRef)(true);
|
|
156
|
-
const lastSetupPlatformIdRef = (0, external_react_namespaceObject.useRef)(void 0);
|
|
157
|
-
const autoCreateSignatureRef = (0, external_react_namespaceObject.useRef)(null);
|
|
158
|
-
const autoCreateDisabledRef = (0, external_react_namespaceObject.useRef)(false);
|
|
159
|
-
const finishCountdown = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
160
|
-
if (null !== countdownTimerRef.current) {
|
|
161
|
-
window.clearInterval(countdownTimerRef.current);
|
|
162
|
-
countdownTimerRef.current = null;
|
|
163
|
-
}
|
|
164
|
-
const resolve = countdownResolveRef.current;
|
|
165
|
-
countdownResolveRef.current = null;
|
|
166
|
-
if (mountedRef.current) setCountdown(null);
|
|
167
|
-
null == resolve || resolve();
|
|
168
|
-
}, []);
|
|
169
|
-
const showCountdownModal = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
170
|
-
if (countdownSeconds <= 0) return;
|
|
171
|
-
finishCountdown();
|
|
172
|
-
return new Promise((resolve)=>{
|
|
173
|
-
countdownResolveRef.current = resolve;
|
|
174
|
-
let count = countdownSeconds;
|
|
175
|
-
if (mountedRef.current) setCountdown(count);
|
|
176
|
-
countdownTimerRef.current = window.setInterval(()=>{
|
|
177
|
-
count -= 1;
|
|
178
|
-
if (count > 0) {
|
|
179
|
-
if (mountedRef.current) setCountdown(count);
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (0 === count) {
|
|
183
|
-
if (mountedRef.current) setCountdown('GO!');
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
finishCountdown();
|
|
187
|
-
}, 1000);
|
|
188
|
-
});
|
|
189
|
-
})(), [
|
|
190
|
-
countdownSeconds,
|
|
191
|
-
finishCountdown
|
|
192
|
-
]);
|
|
193
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
194
|
-
mountedRef.current = true;
|
|
195
|
-
return ()=>{
|
|
196
|
-
mountedRef.current = false;
|
|
197
|
-
finishCountdown();
|
|
198
|
-
};
|
|
199
|
-
}, [
|
|
200
|
-
finishCountdown
|
|
201
|
-
]);
|
|
202
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
203
|
-
if (!executionUxHints.includes('countdown-before-run')) return void playgroundSDK.setBeforeActionHook(void 0);
|
|
204
|
-
playgroundSDK.setBeforeActionHook(()=>_async_to_generator(function*() {
|
|
205
|
-
yield showCountdownModal();
|
|
206
|
-
})());
|
|
207
|
-
return ()=>{
|
|
208
|
-
playgroundSDK.setBeforeActionHook(void 0);
|
|
209
|
-
};
|
|
210
|
-
}, [
|
|
211
|
-
executionUxHints,
|
|
212
|
-
playgroundSDK,
|
|
213
|
-
showCountdownModal
|
|
214
|
-
]);
|
|
215
|
-
const refreshSessionSetup = (0, external_react_namespaceObject.useCallback)((input)=>_async_to_generator(function*() {
|
|
216
|
-
const currentValues = _object_spread({}, setupForm.getFieldsValue(true), input || {});
|
|
217
|
-
setSessionLoading(true);
|
|
218
|
-
try {
|
|
219
|
-
const setup = yield playgroundSDK.getSessionSetup(input);
|
|
220
|
-
setSessionSetup(setup);
|
|
221
|
-
setSessionSetupError(null);
|
|
222
|
-
const currentPlatformSelectorFieldKey = getPlatformSelectorFieldKey(setup);
|
|
223
|
-
lastSetupPlatformIdRef.current = currentPlatformSelectorFieldKey && 'string' == typeof currentValues[currentPlatformSelectorFieldKey] ? currentValues[currentPlatformSelectorFieldKey] : void 0;
|
|
224
|
-
setupForm.setFieldsValue((0, external_session_state_js_namespaceObject.buildSessionInitialValues)(setup, currentValues));
|
|
225
|
-
} catch (error) {
|
|
226
|
-
console.error('Failed to load session setup:', error);
|
|
227
|
-
setSessionSetupError(error instanceof Error ? error.message : 'Failed to load session setup');
|
|
228
|
-
} finally{
|
|
229
|
-
setSessionLoading(false);
|
|
230
|
-
}
|
|
231
|
-
})(), [
|
|
232
|
-
playgroundSDK,
|
|
233
|
-
setupForm
|
|
234
|
-
]);
|
|
235
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
236
|
-
if (!serverOnline || sessionViewState.connected) return;
|
|
237
|
-
refreshSessionSetup();
|
|
238
|
-
}, [
|
|
239
|
-
refreshSessionSetup,
|
|
240
|
-
serverOnline,
|
|
241
|
-
sessionViewState.connected
|
|
242
|
-
]);
|
|
243
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
244
|
-
if (!serverOnline || sessionViewState.connected || !selectedPlatformId) return;
|
|
245
|
-
const currentPlatformSelectorFieldKey = getPlatformSelectorFieldKey(sessionSetup);
|
|
246
|
-
if (!currentPlatformSelectorFieldKey) return;
|
|
247
|
-
if (lastSetupPlatformIdRef.current === selectedPlatformId) return;
|
|
248
|
-
refreshSessionSetup(_object_spread_props(_object_spread({}, setupForm.getFieldsValue(true)), {
|
|
249
|
-
[currentPlatformSelectorFieldKey]: selectedPlatformId
|
|
250
|
-
}));
|
|
251
|
-
}, [
|
|
252
|
-
platformSelectorFieldKey,
|
|
253
|
-
refreshSessionSetup,
|
|
254
|
-
selectedPlatformId,
|
|
255
|
-
serverOnline,
|
|
256
|
-
sessionSetup,
|
|
257
|
-
sessionViewState.connected,
|
|
258
|
-
setupForm
|
|
259
|
-
]);
|
|
56
|
+
const controller = (0, usePlaygroundController_js_namespaceObject.usePlaygroundController)({
|
|
57
|
+
serverUrl,
|
|
58
|
+
defaultDeviceType,
|
|
59
|
+
countdownSeconds: null == playgroundConfig ? void 0 : null == (_playgroundConfig_executionUx = playgroundConfig.executionUx) ? void 0 : _playgroundConfig_executionUx.countdownSeconds,
|
|
60
|
+
pollIntervalMs
|
|
61
|
+
});
|
|
260
62
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
261
63
|
const handleResize = ()=>{
|
|
262
64
|
setIsNarrowScreen(window.innerWidth <= 1024);
|
|
@@ -265,105 +67,7 @@ function PlaygroundApp({ serverUrl, appVersion, title = 'Playground', defaultDev
|
|
|
265
67
|
window.addEventListener('resize', handleResize);
|
|
266
68
|
return ()=>window.removeEventListener('resize', handleResize);
|
|
267
69
|
}, []);
|
|
268
|
-
|
|
269
|
-
showContextPreview: false,
|
|
270
|
-
layout: 'vertical',
|
|
271
|
-
showVersionInfo: true,
|
|
272
|
-
enableScrollToBottom: true,
|
|
273
|
-
serverMode: true,
|
|
274
|
-
showEnvConfigReminder: true,
|
|
275
|
-
deviceType,
|
|
276
|
-
executionUx: {
|
|
277
|
-
hints: executionUxHints,
|
|
278
|
-
countdownSeconds
|
|
279
|
-
}
|
|
280
|
-
}, playgroundConfig);
|
|
281
|
-
var _runtimeInfo_title, _runtimeInfo_platformId, _ref, _ref1;
|
|
282
|
-
const mergedBranding = _object_spread_props(_object_spread({}, branding), {
|
|
283
|
-
title: null != (_runtimeInfo_title = null == runtimeInfo ? void 0 : runtimeInfo.title) ? _runtimeInfo_title : title,
|
|
284
|
-
version: appVersion,
|
|
285
|
-
targetName: null != (_ref1 = null != (_ref = null != (_runtimeInfo_platformId = null == runtimeInfo ? void 0 : runtimeInfo.platformId) ? _runtimeInfo_platformId : null == branding ? void 0 : branding.targetName) ? _ref : deviceType) ? _ref1 : 'screen'
|
|
286
|
-
});
|
|
287
|
-
const createSession = (0, external_react_namespaceObject.useCallback)((input, options)=>_async_to_generator(function*() {
|
|
288
|
-
try {
|
|
289
|
-
const values = null != input ? input : yield setupForm.validateFields();
|
|
290
|
-
setSessionMutating(true);
|
|
291
|
-
yield playgroundSDK.createSession(values);
|
|
292
|
-
if (!(null == options ? void 0 : options.silent)) messageApi.success('Agent created');
|
|
293
|
-
yield refreshServerState();
|
|
294
|
-
return true;
|
|
295
|
-
} catch (error) {
|
|
296
|
-
if (error.errorFields) return false;
|
|
297
|
-
const errorMessage = error instanceof Error ? error.message : 'Failed to create Agent';
|
|
298
|
-
messageApi.error(errorMessage);
|
|
299
|
-
return false;
|
|
300
|
-
} finally{
|
|
301
|
-
setSessionMutating(false);
|
|
302
|
-
}
|
|
303
|
-
})(), [
|
|
304
|
-
messageApi,
|
|
305
|
-
playgroundSDK,
|
|
306
|
-
refreshServerState,
|
|
307
|
-
setupForm
|
|
308
|
-
]);
|
|
309
|
-
const handleCreateSession = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
310
|
-
autoCreateDisabledRef.current = true;
|
|
311
|
-
yield createSession();
|
|
312
|
-
})(), [
|
|
313
|
-
createSession
|
|
314
|
-
]);
|
|
315
|
-
const handleDestroySession = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
316
|
-
try {
|
|
317
|
-
autoCreateDisabledRef.current = true;
|
|
318
|
-
setSessionMutating(true);
|
|
319
|
-
yield playgroundSDK.destroySession();
|
|
320
|
-
messageApi.success('Session disconnected');
|
|
321
|
-
yield refreshServerState();
|
|
322
|
-
yield refreshSessionSetup();
|
|
323
|
-
} catch (error) {
|
|
324
|
-
const errorMessage = error instanceof Error ? error.message : 'Failed to disconnect session';
|
|
325
|
-
messageApi.error(errorMessage);
|
|
326
|
-
} finally{
|
|
327
|
-
setSessionMutating(false);
|
|
328
|
-
}
|
|
329
|
-
})(), [
|
|
330
|
-
messageApi,
|
|
331
|
-
playgroundSDK,
|
|
332
|
-
refreshServerState,
|
|
333
|
-
refreshSessionSetup
|
|
334
|
-
]);
|
|
335
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
336
|
-
if (sessionViewState.connected) {
|
|
337
|
-
autoCreateSignatureRef.current = null;
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
if (!serverOnline || sessionLoading || sessionMutating || sessionSetupError || autoCreateDisabledRef.current) return;
|
|
341
|
-
const autoCreateInput = (0, external_session_setup_js_namespaceObject.resolveAutoCreateSessionInput)(sessionSetup, setupForm.getFieldsValue(true));
|
|
342
|
-
if (!autoCreateInput) {
|
|
343
|
-
autoCreateSignatureRef.current = null;
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
const signature = JSON.stringify(autoCreateInput);
|
|
347
|
-
if (autoCreateSignatureRef.current === signature) return;
|
|
348
|
-
autoCreateSignatureRef.current = signature;
|
|
349
|
-
(()=>_async_to_generator(function*() {
|
|
350
|
-
const created = yield createSession(autoCreateInput, {
|
|
351
|
-
silent: true
|
|
352
|
-
});
|
|
353
|
-
if (!created) autoCreateSignatureRef.current = null;
|
|
354
|
-
})())();
|
|
355
|
-
}, [
|
|
356
|
-
createSession,
|
|
357
|
-
serverOnline,
|
|
358
|
-
sessionLoading,
|
|
359
|
-
sessionMutating,
|
|
360
|
-
sessionSetup,
|
|
361
|
-
sessionSetupError,
|
|
362
|
-
sessionViewState.connected,
|
|
363
|
-
setupForm
|
|
364
|
-
]);
|
|
365
|
-
if (!serverOnline) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.ConfigProvider, {
|
|
366
|
-
theme: (0, visualizer_namespaceObject.globalThemeConfig)(),
|
|
70
|
+
if (!controller.state.serverOnline) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PlaygroundThemeProvider_js_namespaceObject.PlaygroundThemeProvider, {
|
|
367
71
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
368
72
|
className: "server-offline-container",
|
|
369
73
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
@@ -397,166 +101,72 @@ function PlaygroundApp({ serverUrl, appVersion, title = 'Playground', defaultDev
|
|
|
397
101
|
})
|
|
398
102
|
})
|
|
399
103
|
});
|
|
400
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
type: "default",
|
|
409
|
-
children: "Skip countdown"
|
|
410
|
-
}),
|
|
411
|
-
closable: true,
|
|
412
|
-
maskClosable: true,
|
|
413
|
-
onCancel: finishCountdown,
|
|
414
|
-
centered: true,
|
|
415
|
-
width: 400,
|
|
416
|
-
style: {
|
|
417
|
-
top: '30%'
|
|
418
|
-
},
|
|
419
|
-
styles: {
|
|
420
|
-
mask: {
|
|
421
|
-
backgroundColor: 'rgba(0, 0, 0, 0.75)'
|
|
422
|
-
}
|
|
423
|
-
},
|
|
424
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
425
|
-
style: {
|
|
426
|
-
textAlign: 'center',
|
|
427
|
-
padding: '40px 20px'
|
|
428
|
-
},
|
|
104
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PlaygroundThemeProvider_js_namespaceObject.PlaygroundThemeProvider, {
|
|
105
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Layout, {
|
|
106
|
+
className: "app-container playground-container",
|
|
107
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Content, {
|
|
108
|
+
className: "app-content",
|
|
109
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_react_resizable_panels_namespaceObject.PanelGroup, {
|
|
110
|
+
autoSaveId: "playground-layout",
|
|
111
|
+
direction: isNarrowScreen ? 'vertical' : 'horizontal',
|
|
429
112
|
children: [
|
|
430
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
})
|
|
461
|
-
}),
|
|
462
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Layout, {
|
|
463
|
-
className: "app-container playground-container",
|
|
464
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Content, {
|
|
465
|
-
className: "app-content",
|
|
466
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_react_resizable_panels_namespaceObject.PanelGroup, {
|
|
467
|
-
autoSaveId: "playground-layout",
|
|
468
|
-
direction: isNarrowScreen ? 'vertical' : 'horizontal',
|
|
469
|
-
children: [
|
|
470
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
|
|
471
|
-
defaultSize: isNarrowScreen ? 67 : 32,
|
|
472
|
-
maxSize: isNarrowScreen ? 85 : 60,
|
|
473
|
-
minSize: isNarrowScreen ? 67 : 25,
|
|
474
|
-
className: "app-panel left-panel",
|
|
475
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
476
|
-
className: "panel-content left-panel-content",
|
|
477
|
-
children: [
|
|
478
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
479
|
-
className: "playground-panel-header",
|
|
480
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
481
|
-
className: "header-row",
|
|
482
|
-
children: [
|
|
483
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.Logo, {}),
|
|
484
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.NavActions, {
|
|
485
|
-
showTooltipWhenEmpty: false,
|
|
486
|
-
showModelName: false,
|
|
487
|
-
playgroundSDK: playgroundSDK
|
|
488
|
-
})
|
|
489
|
-
]
|
|
490
|
-
})
|
|
491
|
-
}),
|
|
492
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
493
|
-
className: "playground-panel-playground",
|
|
494
|
-
children: sessionViewState.connected ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.UniversalPlayground, {
|
|
495
|
-
playgroundSDK: playgroundSDK,
|
|
496
|
-
config: mergedConfig,
|
|
497
|
-
branding: mergedBranding,
|
|
498
|
-
className: "playground-container"
|
|
499
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_SessionSetupPanel_js_namespaceObject.SessionSetupPanel, {
|
|
500
|
-
form: setupForm,
|
|
501
|
-
sessionSetup: sessionSetup,
|
|
502
|
-
sessionSetupError: sessionSetupError,
|
|
503
|
-
sessionViewState: sessionViewState,
|
|
504
|
-
sessionLoading: sessionLoading,
|
|
505
|
-
sessionMutating: sessionMutating,
|
|
506
|
-
onCreateSession: handleCreateSession,
|
|
507
|
-
onRefreshTargets: ()=>refreshSessionSetup(setupForm.getFieldsValue(true))
|
|
508
|
-
})
|
|
113
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
|
|
114
|
+
defaultSize: isNarrowScreen ? 67 : 32,
|
|
115
|
+
maxSize: isNarrowScreen ? 85 : 60,
|
|
116
|
+
minSize: isNarrowScreen ? 67 : 25,
|
|
117
|
+
className: "app-panel left-panel",
|
|
118
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
119
|
+
className: "panel-content left-panel-content",
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
122
|
+
className: "playground-panel-header",
|
|
123
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
124
|
+
className: "header-row",
|
|
125
|
+
children: [
|
|
126
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.Logo, {}),
|
|
127
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.NavActions, {
|
|
128
|
+
showTooltipWhenEmpty: false,
|
|
129
|
+
showModelName: false,
|
|
130
|
+
playgroundSDK: controller.state.playgroundSDK
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
})
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
136
|
+
className: "playground-panel-playground",
|
|
137
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(PlaygroundConversationPanel_js_namespaceObject.PlaygroundConversationPanel, {
|
|
138
|
+
controller: controller,
|
|
139
|
+
appVersion: appVersion,
|
|
140
|
+
branding: branding,
|
|
141
|
+
playgroundConfig: playgroundConfig,
|
|
142
|
+
title: title
|
|
509
143
|
})
|
|
510
|
-
]
|
|
511
|
-
})
|
|
512
|
-
}),
|
|
513
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.PanelResizeHandle, {
|
|
514
|
-
className: `panel-resize-handle ${isNarrowScreen ? 'vertical' : 'horizontal'}`
|
|
515
|
-
}),
|
|
516
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
|
|
517
|
-
className: "app-panel right-panel",
|
|
518
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
519
|
-
className: "panel-content right-panel-content",
|
|
520
|
-
children: sessionViewState.connected ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
521
|
-
children: [
|
|
522
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
523
|
-
className: "session-toolbar",
|
|
524
|
-
children: [
|
|
525
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Text, {
|
|
526
|
-
strong: true,
|
|
527
|
-
children: sessionViewState.displayName || 'Connected session'
|
|
528
|
-
}),
|
|
529
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Space, {
|
|
530
|
-
size: 8,
|
|
531
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
|
|
532
|
-
onClick: handleDestroySession,
|
|
533
|
-
loading: sessionMutating,
|
|
534
|
-
children: "Change target"
|
|
535
|
-
})
|
|
536
|
-
})
|
|
537
|
-
]
|
|
538
|
-
}),
|
|
539
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PreviewRenderer_js_namespaceObject.PreviewRenderer, {
|
|
540
|
-
playgroundSDK: playgroundSDK,
|
|
541
|
-
runtimeInfo: runtimeInfo,
|
|
542
|
-
serverUrl: serverUrl,
|
|
543
|
-
serverOnline: serverOnline,
|
|
544
|
-
isUserOperating: isUserOperating
|
|
545
|
-
})
|
|
546
|
-
]
|
|
547
|
-
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Alert, {
|
|
548
|
-
type: "info",
|
|
549
|
-
showIcon: true,
|
|
550
|
-
message: mergedBranding.title || 'Playground session',
|
|
551
|
-
description: 'blocked' === sessionViewState.setupState ? sessionViewState.setupBlockingReason || 'Resolve the local setup issue before creating an Agent.' : 'Create an Agent from the left panel to enable preview and execution.'
|
|
552
144
|
})
|
|
145
|
+
]
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.PanelResizeHandle, {
|
|
149
|
+
className: "panel-resize-handle"
|
|
150
|
+
}),
|
|
151
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_resizable_panels_namespaceObject.Panel, {
|
|
152
|
+
defaultSize: isNarrowScreen ? 33 : 68,
|
|
153
|
+
minSize: isNarrowScreen ? 15 : 40,
|
|
154
|
+
className: "app-panel right-panel",
|
|
155
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
156
|
+
className: "panel-content right-panel-content",
|
|
157
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PlaygroundPreview_js_namespaceObject.PlaygroundPreview, {
|
|
158
|
+
playgroundSDK: controller.state.playgroundSDK,
|
|
159
|
+
runtimeInfo: controller.state.runtimeInfo,
|
|
160
|
+
serverUrl: serverUrl,
|
|
161
|
+
serverOnline: controller.state.serverOnline,
|
|
162
|
+
isUserOperating: controller.state.isUserOperating
|
|
553
163
|
})
|
|
554
164
|
})
|
|
555
|
-
|
|
556
|
-
|
|
165
|
+
})
|
|
166
|
+
]
|
|
557
167
|
})
|
|
558
168
|
})
|
|
559
|
-
|
|
169
|
+
})
|
|
560
170
|
});
|
|
561
171
|
}
|
|
562
172
|
exports.PlaygroundApp = __webpack_exports__.PlaygroundApp;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
PlaygroundThemeProvider: ()=>PlaygroundThemeProvider
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const visualizer_namespaceObject = require("@midscene/visualizer");
|
|
31
|
+
const external_antd_namespaceObject = require("antd");
|
|
32
|
+
function PlaygroundThemeProvider({ children }) {
|
|
33
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.ConfigProvider, {
|
|
34
|
+
theme: (0, visualizer_namespaceObject.globalThemeConfig)(),
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.PlaygroundThemeProvider = __webpack_exports__.PlaygroundThemeProvider;
|
|
39
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
|
+
"PlaygroundThemeProvider"
|
|
41
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
42
|
+
Object.defineProperty(exports, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
@@ -41,7 +41,7 @@ function isNonLocalhostHttp() {
|
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
function PreviewRenderer({ playgroundSDK, runtimeInfo, serverUrl, serverOnline, isUserOperating }) {
|
|
44
|
+
function PreviewRenderer({ connectingOverlay, onScrcpyStatusChange, renderErrorOverlay, playgroundSDK, runtimeInfo, serverUrl, serverOnline, isUserOperating }) {
|
|
45
45
|
const previewConnection = (0, external_runtime_info_js_namespaceObject.resolvePreviewConnectionInfo)(runtimeInfo, serverUrl);
|
|
46
46
|
const scrcpyAvailable = 'scrcpy' === previewConnection.type && scrcpy_decoder_webcodecs_namespaceObject.WebCodecsVideoDecoder.isSupported;
|
|
47
47
|
const useScreenshot = 'screenshot' === previewConnection.type || 'scrcpy' === previewConnection.type && !scrcpyAvailable;
|
|
@@ -146,6 +146,9 @@ function PreviewRenderer({ playgroundSDK, runtimeInfo, serverUrl, serverOnline,
|
|
|
146
146
|
message: "Preview unavailable",
|
|
147
147
|
description: "This session did not expose a preview capability in runtime metadata."
|
|
148
148
|
}) : scrcpyAvailable ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ScrcpyPanel_js_namespaceObject.ScrcpyPanel, {
|
|
149
|
+
connectingOverlay: connectingOverlay,
|
|
150
|
+
onStatusChange: onScrcpyStatusChange,
|
|
151
|
+
renderErrorOverlay: renderErrorOverlay,
|
|
149
152
|
serverUrl: previewConnection.scrcpyUrl
|
|
150
153
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(visualizer_namespaceObject.ScreenshotViewer, {
|
|
151
154
|
getScreenshot: ()=>useScreenshot ? playgroundSDK.getScreenshot() : Promise.resolve(null),
|