@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.
- package/LICENSE +21 -0
- package/README.md +4 -0
- package/dist/es/DeviceInteractionLayer.mjs +383 -0
- package/dist/es/PlaygroundApp.css +207 -0
- package/dist/es/PlaygroundApp.mjs +776 -0
- package/dist/es/PlaygroundPreview.mjs +29 -0
- package/dist/es/PlaygroundThemeProvider.mjs +10 -0
- package/dist/es/PreviewRenderer.mjs +270 -0
- package/dist/es/ScrcpyPanel.mjs +390 -0
- package/dist/es/SessionSetupPanel.css +299 -0
- package/dist/es/SessionSetupPanel.mjs +169 -0
- package/dist/es/components/Header/index.css +19 -0
- package/dist/es/components/Header/index.mjs +37 -0
- package/dist/es/components/Nav/index.css +15 -0
- package/dist/es/components/Nav/index.mjs +93 -0
- package/dist/es/components/WinControlTool/index.css +5 -0
- package/dist/es/components/WinControlTool/index.mjs +76 -0
- package/dist/es/controller/ai-config.mjs +40 -0
- package/dist/es/controller/auto-create.mjs +19 -0
- package/dist/es/controller/selectors.mjs +78 -0
- package/dist/es/controller/single-flight.mjs +13 -0
- package/dist/es/controller/types.mjs +0 -0
- package/dist/es/controller/usePlaygroundController.mjs +400 -0
- package/dist/es/icons/dropdown-chevron.mjs +61 -0
- package/dist/es/icons/midscene-logo.mjs +247 -0
- package/dist/es/icons/server-offline-background.mjs +102 -0
- package/dist/es/icons/server-offline-foreground.mjs +200 -0
- package/dist/es/index.mjs +7 -0
- package/dist/es/manual-interaction.mjs +56 -0
- package/dist/es/panels/PlaygroundConversationPanel.css +20 -0
- package/dist/es/panels/PlaygroundConversationPanel.mjs +140 -0
- package/dist/es/runtime-info.mjs +128 -0
- package/dist/es/scrcpy-preview.mjs +30 -0
- package/dist/es/scrcpy-stream.mjs +53 -0
- package/dist/es/session-setup.mjs +13 -0
- package/dist/es/session-state.mjs +32 -0
- package/dist/es/useServerStatus.mjs +120 -0
- package/dist/lib/DeviceInteractionLayer.js +434 -0
- package/dist/lib/PlaygroundApp.css +207 -0
- package/dist/lib/PlaygroundApp.js +821 -0
- package/dist/lib/PlaygroundPreview.js +63 -0
- package/dist/lib/PlaygroundThemeProvider.js +44 -0
- package/dist/lib/PreviewRenderer.js +304 -0
- package/dist/lib/ScrcpyPanel.js +424 -0
- package/dist/lib/SessionSetupPanel.css +299 -0
- package/dist/lib/SessionSetupPanel.js +217 -0
- package/dist/lib/components/Header/index.css +19 -0
- package/dist/lib/components/Header/index.js +81 -0
- package/dist/lib/components/Nav/index.css +15 -0
- package/dist/lib/components/Nav/index.js +127 -0
- package/dist/lib/components/WinControlTool/index.css +5 -0
- package/dist/lib/components/WinControlTool/index.js +110 -0
- package/dist/lib/controller/ai-config.js +80 -0
- package/dist/lib/controller/auto-create.js +59 -0
- package/dist/lib/controller/selectors.js +115 -0
- package/dist/lib/controller/single-flight.js +47 -0
- package/dist/lib/controller/types.js +18 -0
- package/dist/lib/controller/usePlaygroundController.js +434 -0
- package/dist/lib/icons/dropdown-chevron.js +95 -0
- package/dist/lib/icons/midscene-logo.js +281 -0
- package/dist/lib/icons/server-offline-background.js +136 -0
- package/dist/lib/icons/server-offline-foreground.js +234 -0
- package/dist/lib/index.js +56 -0
- package/dist/lib/manual-interaction.js +90 -0
- package/dist/lib/panels/PlaygroundConversationPanel.css +20 -0
- package/dist/lib/panels/PlaygroundConversationPanel.js +174 -0
- package/dist/lib/runtime-info.js +174 -0
- package/dist/lib/scrcpy-preview.js +79 -0
- package/dist/lib/scrcpy-stream.js +87 -0
- package/dist/lib/session-setup.js +47 -0
- package/dist/lib/session-state.js +69 -0
- package/dist/lib/useServerStatus.js +154 -0
- package/dist/types/DeviceInteractionLayer.d.ts +50 -0
- package/dist/types/PlaygroundApp.d.ts +14 -0
- package/dist/types/PlaygroundPreview.d.ts +22 -0
- package/dist/types/PlaygroundThemeProvider.d.ts +2 -0
- package/dist/types/PreviewRenderer.d.ts +27 -0
- package/dist/types/ScrcpyPanel.d.ts +21 -0
- package/dist/types/SessionSetupPanel.d.ts +16 -0
- package/dist/types/components/Header/index.d.ts +3 -0
- package/dist/types/components/Nav/index.d.ts +3 -0
- package/dist/types/components/WinControlTool/index.d.ts +3 -0
- package/dist/types/controller/ai-config.d.ts +5 -0
- package/dist/types/controller/auto-create.d.ts +15 -0
- package/dist/types/controller/selectors.d.ts +5 -0
- package/dist/types/controller/single-flight.d.ts +3 -0
- package/dist/types/controller/types.d.ts +36 -0
- package/dist/types/controller/usePlaygroundController.d.ts +16 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/manual-interaction.d.ts +21 -0
- package/dist/types/panels/PlaygroundConversationPanel.d.ts +25 -0
- package/dist/types/runtime-info.d.ts +22 -0
- package/dist/types/scrcpy-preview.d.ts +11 -0
- package/dist/types/scrcpy-stream.d.ts +16 -0
- package/dist/types/session-setup.d.ts +2 -0
- package/dist/types/session-state.d.ts +9 -0
- package/dist/types/useServerStatus.d.ts +12 -0
- package/package.json +69 -0
|
@@ -0,0 +1,434 @@
|
|
|
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 ("u" > 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
|
+
usePlaygroundController: ()=>usePlaygroundController
|
|
28
|
+
});
|
|
29
|
+
const playground_namespaceObject = require("@godscene/playground");
|
|
30
|
+
const visualizer_namespaceObject = require("@godscene/visualizer");
|
|
31
|
+
const external_antd_namespaceObject = require("antd");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const external_session_setup_js_namespaceObject = require("../session-setup.js");
|
|
34
|
+
const external_session_state_js_namespaceObject = require("../session-state.js");
|
|
35
|
+
const external_useServerStatus_js_namespaceObject = require("../useServerStatus.js");
|
|
36
|
+
const external_ai_config_js_namespaceObject = require("./ai-config.js");
|
|
37
|
+
const external_auto_create_js_namespaceObject = require("./auto-create.js");
|
|
38
|
+
const external_single_flight_js_namespaceObject = require("./single-flight.js");
|
|
39
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
40
|
+
try {
|
|
41
|
+
var info = gen[key](arg);
|
|
42
|
+
var value = info.value;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
reject(error);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (info.done) resolve(value);
|
|
48
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
49
|
+
}
|
|
50
|
+
function _async_to_generator(fn) {
|
|
51
|
+
return function() {
|
|
52
|
+
var self = this, args = arguments;
|
|
53
|
+
return new Promise(function(resolve, reject) {
|
|
54
|
+
var gen = fn.apply(self, args);
|
|
55
|
+
function _next(value) {
|
|
56
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
57
|
+
}
|
|
58
|
+
function _throw(err) {
|
|
59
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
60
|
+
}
|
|
61
|
+
_next(void 0);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function _define_property(obj, key, value) {
|
|
66
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
67
|
+
value: value,
|
|
68
|
+
enumerable: true,
|
|
69
|
+
configurable: true,
|
|
70
|
+
writable: true
|
|
71
|
+
});
|
|
72
|
+
else obj[key] = value;
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
function _object_spread(target) {
|
|
76
|
+
for(var i = 1; i < arguments.length; i++){
|
|
77
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
78
|
+
var ownKeys = Object.keys(source);
|
|
79
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
80
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
81
|
+
}));
|
|
82
|
+
ownKeys.forEach(function(key) {
|
|
83
|
+
_define_property(target, key, source[key]);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function usePlaygroundController_ownKeys(object, enumerableOnly) {
|
|
89
|
+
var keys = Object.keys(object);
|
|
90
|
+
if (Object.getOwnPropertySymbols) {
|
|
91
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
92
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
93
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
94
|
+
});
|
|
95
|
+
keys.push.apply(keys, symbols);
|
|
96
|
+
}
|
|
97
|
+
return keys;
|
|
98
|
+
}
|
|
99
|
+
function _object_spread_props(target, source) {
|
|
100
|
+
source = null != source ? source : {};
|
|
101
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
102
|
+
else usePlaygroundController_ownKeys(Object(source)).forEach(function(key) {
|
|
103
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
104
|
+
});
|
|
105
|
+
return target;
|
|
106
|
+
}
|
|
107
|
+
function getPlatformSelectorFieldKey(setup) {
|
|
108
|
+
var _setup_platformSelector;
|
|
109
|
+
return null == setup ? void 0 : null == (_setup_platformSelector = setup.platformSelector) ? void 0 : _setup_platformSelector.fieldKey;
|
|
110
|
+
}
|
|
111
|
+
function usePlaygroundController({ serverUrl, defaultDeviceType = 'web', pollIntervalMs = 5000, countdownSeconds = 3, initialFormValues }) {
|
|
112
|
+
var _Form_useWatch;
|
|
113
|
+
const [form] = external_antd_namespaceObject.Form.useForm();
|
|
114
|
+
const initialFormValuesRef = (0, external_react_namespaceObject.useRef)(initialFormValues);
|
|
115
|
+
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
116
|
+
const seed = initialFormValuesRef.current;
|
|
117
|
+
if (!seed) return;
|
|
118
|
+
for (const [key, value] of Object.entries(seed))if (void 0 === form.getFieldValue(key)) form.setFieldsValue({
|
|
119
|
+
[key]: value
|
|
120
|
+
});
|
|
121
|
+
}, [
|
|
122
|
+
form
|
|
123
|
+
]);
|
|
124
|
+
const formValues = null != (_Form_useWatch = external_antd_namespaceObject.Form.useWatch([], form)) ? _Form_useWatch : {};
|
|
125
|
+
const [countdown, setCountdown] = (0, external_react_namespaceObject.useState)(null);
|
|
126
|
+
const [sessionSetup, setSessionSetup] = (0, external_react_namespaceObject.useState)(null);
|
|
127
|
+
const [sessionSetupError, setSessionSetupError] = (0, external_react_namespaceObject.useState)(null);
|
|
128
|
+
const [sessionLoading, setSessionLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
129
|
+
const [sessionMutating, setSessionMutating] = (0, external_react_namespaceObject.useState)(false);
|
|
130
|
+
const aiConfig = (0, visualizer_namespaceObject.useEnvConfig)((state)=>state.config);
|
|
131
|
+
const aiConfigSignature = (0, external_react_namespaceObject.useMemo)(()=>(0, external_ai_config_js_namespaceObject.serializePlaygroundAiConfig)(aiConfig), [
|
|
132
|
+
aiConfig
|
|
133
|
+
]);
|
|
134
|
+
const platformSelectorFieldKey = getPlatformSelectorFieldKey(sessionSetup);
|
|
135
|
+
const selectedPlatformId = 'string' == typeof platformSelectorFieldKey ? formValues[platformSelectorFieldKey] : void 0;
|
|
136
|
+
const playgroundSDK = (0, external_react_namespaceObject.useMemo)(()=>new playground_namespaceObject.PlaygroundSDK({
|
|
137
|
+
type: 'remote-execution',
|
|
138
|
+
serverUrl
|
|
139
|
+
}), [
|
|
140
|
+
serverUrl
|
|
141
|
+
]);
|
|
142
|
+
const { serverOnline, isUserOperating, deviceType, runtimeInfo, executionUxHints, refreshServerState } = (0, external_useServerStatus_js_namespaceObject.useServerStatus)(playgroundSDK, defaultDeviceType, pollIntervalMs);
|
|
143
|
+
const sessionViewState = (0, external_react_namespaceObject.useMemo)(()=>(0, external_session_state_js_namespaceObject.resolveSessionViewState)(runtimeInfo), [
|
|
144
|
+
runtimeInfo
|
|
145
|
+
]);
|
|
146
|
+
const countdownTimerRef = (0, external_react_namespaceObject.useRef)(null);
|
|
147
|
+
const countdownResolveRef = (0, external_react_namespaceObject.useRef)(null);
|
|
148
|
+
const mountedRef = (0, external_react_namespaceObject.useRef)(true);
|
|
149
|
+
const lastSetupPlatformIdRef = (0, external_react_namespaceObject.useRef)(void 0);
|
|
150
|
+
const autoCreateSignatureRef = (0, external_react_namespaceObject.useRef)(null);
|
|
151
|
+
const autoCreateBlockedSignatureRef = (0, external_react_namespaceObject.useRef)(null);
|
|
152
|
+
const sessionMutatingRef = (0, external_react_namespaceObject.useRef)(false);
|
|
153
|
+
const appliedAiConfigSignatureRef = (0, external_react_namespaceObject.useRef)(null);
|
|
154
|
+
const pendingCreateSessionRef = (0, external_react_namespaceObject.useRef)(null);
|
|
155
|
+
const pendingAiConfigApplicationRef = (0, external_react_namespaceObject.useRef)(null);
|
|
156
|
+
const applyAiConfig = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
157
|
+
if (!(0, external_ai_config_js_namespaceObject.hasPlaygroundAiConfig)(aiConfig)) {
|
|
158
|
+
appliedAiConfigSignatureRef.current = null;
|
|
159
|
+
pendingAiConfigApplicationRef.current = null;
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
if (appliedAiConfigSignatureRef.current === aiConfigSignature) return true;
|
|
163
|
+
const pendingApplication = pendingAiConfigApplicationRef.current;
|
|
164
|
+
if ((null == pendingApplication ? void 0 : pendingApplication.signature) === aiConfigSignature) return pendingApplication.promise;
|
|
165
|
+
const pendingApplicationState = {
|
|
166
|
+
promise: Promise.resolve(true),
|
|
167
|
+
signature: aiConfigSignature
|
|
168
|
+
};
|
|
169
|
+
const applyPromise = (()=>_async_to_generator(function*() {
|
|
170
|
+
try {
|
|
171
|
+
yield (0, external_ai_config_js_namespaceObject.applyPlaygroundAiConfig)(playgroundSDK, aiConfig);
|
|
172
|
+
appliedAiConfigSignatureRef.current = aiConfigSignature;
|
|
173
|
+
return true;
|
|
174
|
+
} catch (error) {
|
|
175
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to apply AI configuration';
|
|
176
|
+
external_antd_namespaceObject.message.error(errorMessage);
|
|
177
|
+
return false;
|
|
178
|
+
} finally{
|
|
179
|
+
if (pendingAiConfigApplicationRef.current === pendingApplicationState) pendingAiConfigApplicationRef.current = null;
|
|
180
|
+
}
|
|
181
|
+
})())();
|
|
182
|
+
pendingApplicationState.promise = applyPromise;
|
|
183
|
+
pendingAiConfigApplicationRef.current = pendingApplicationState;
|
|
184
|
+
return applyPromise;
|
|
185
|
+
})(), [
|
|
186
|
+
aiConfig,
|
|
187
|
+
aiConfigSignature,
|
|
188
|
+
playgroundSDK
|
|
189
|
+
]);
|
|
190
|
+
const finishCountdown = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
191
|
+
if (null !== countdownTimerRef.current) {
|
|
192
|
+
window.clearInterval(countdownTimerRef.current);
|
|
193
|
+
countdownTimerRef.current = null;
|
|
194
|
+
}
|
|
195
|
+
const resolve = countdownResolveRef.current;
|
|
196
|
+
countdownResolveRef.current = null;
|
|
197
|
+
if (mountedRef.current) setCountdown(null);
|
|
198
|
+
null == resolve || resolve();
|
|
199
|
+
}, []);
|
|
200
|
+
const showCountdownModal = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
201
|
+
if (countdownSeconds <= 0) return;
|
|
202
|
+
finishCountdown();
|
|
203
|
+
return new Promise((resolve)=>{
|
|
204
|
+
countdownResolveRef.current = resolve;
|
|
205
|
+
let count = countdownSeconds;
|
|
206
|
+
if (mountedRef.current) setCountdown(count);
|
|
207
|
+
countdownTimerRef.current = window.setInterval(()=>{
|
|
208
|
+
count -= 1;
|
|
209
|
+
if (count > 0) {
|
|
210
|
+
if (mountedRef.current) setCountdown(count);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (0 === count) {
|
|
214
|
+
if (mountedRef.current) setCountdown('GO!');
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
finishCountdown();
|
|
218
|
+
}, 1000);
|
|
219
|
+
});
|
|
220
|
+
})(), [
|
|
221
|
+
countdownSeconds,
|
|
222
|
+
finishCountdown
|
|
223
|
+
]);
|
|
224
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
225
|
+
mountedRef.current = true;
|
|
226
|
+
return ()=>{
|
|
227
|
+
mountedRef.current = false;
|
|
228
|
+
finishCountdown();
|
|
229
|
+
};
|
|
230
|
+
}, [
|
|
231
|
+
finishCountdown
|
|
232
|
+
]);
|
|
233
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
234
|
+
if (!executionUxHints.includes('countdown-before-run')) return void playgroundSDK.setBeforeActionHook(void 0);
|
|
235
|
+
playgroundSDK.setBeforeActionHook(()=>_async_to_generator(function*() {
|
|
236
|
+
yield showCountdownModal();
|
|
237
|
+
})());
|
|
238
|
+
return ()=>{
|
|
239
|
+
playgroundSDK.setBeforeActionHook(void 0);
|
|
240
|
+
};
|
|
241
|
+
}, [
|
|
242
|
+
executionUxHints,
|
|
243
|
+
playgroundSDK,
|
|
244
|
+
showCountdownModal
|
|
245
|
+
]);
|
|
246
|
+
const refreshSessionSetup = (0, external_react_namespaceObject.useCallback)((input)=>_async_to_generator(function*() {
|
|
247
|
+
const currentValues = _object_spread({}, form.getFieldsValue(true), input || {});
|
|
248
|
+
setSessionLoading(true);
|
|
249
|
+
try {
|
|
250
|
+
const setup = yield playgroundSDK.getSessionSetup(input);
|
|
251
|
+
setSessionSetup(setup);
|
|
252
|
+
setSessionSetupError(null);
|
|
253
|
+
const currentPlatformSelectorFieldKey = getPlatformSelectorFieldKey(setup);
|
|
254
|
+
lastSetupPlatformIdRef.current = currentPlatformSelectorFieldKey && 'string' == typeof currentValues[currentPlatformSelectorFieldKey] ? currentValues[currentPlatformSelectorFieldKey] : void 0;
|
|
255
|
+
form.setFieldsValue((0, external_session_state_js_namespaceObject.buildSessionInitialValues)(setup, currentValues));
|
|
256
|
+
} catch (error) {
|
|
257
|
+
console.error('Failed to load session setup:', error);
|
|
258
|
+
setSessionSetupError(error instanceof Error ? error.message : 'Failed to load session setup');
|
|
259
|
+
} finally{
|
|
260
|
+
setSessionLoading(false);
|
|
261
|
+
}
|
|
262
|
+
})(), [
|
|
263
|
+
form,
|
|
264
|
+
playgroundSDK
|
|
265
|
+
]);
|
|
266
|
+
const createSession = (0, external_react_namespaceObject.useCallback)((input, options)=>_async_to_generator(function*() {
|
|
267
|
+
return (0, external_single_flight_js_namespaceObject.runSingleFlight)(pendingCreateSessionRef, ()=>_async_to_generator(function*() {
|
|
268
|
+
try {
|
|
269
|
+
sessionMutatingRef.current = true;
|
|
270
|
+
setSessionMutating(true);
|
|
271
|
+
if (!(yield applyAiConfig())) return false;
|
|
272
|
+
const values = null != input ? input : yield form.validateFields();
|
|
273
|
+
yield playgroundSDK.createSession(values);
|
|
274
|
+
if ((0, external_auto_create_js_namespaceObject.shouldResetAutoCreateBlock)(options)) autoCreateBlockedSignatureRef.current = null;
|
|
275
|
+
if (!(null == options ? void 0 : options.silent)) external_antd_namespaceObject.message.success('Agent created');
|
|
276
|
+
yield refreshServerState();
|
|
277
|
+
return true;
|
|
278
|
+
} catch (error) {
|
|
279
|
+
if (error.errorFields) return false;
|
|
280
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to create Agent';
|
|
281
|
+
external_antd_namespaceObject.message.error(errorMessage);
|
|
282
|
+
return false;
|
|
283
|
+
} finally{
|
|
284
|
+
sessionMutatingRef.current = false;
|
|
285
|
+
setSessionMutating(false);
|
|
286
|
+
}
|
|
287
|
+
})());
|
|
288
|
+
})(), [
|
|
289
|
+
applyAiConfig,
|
|
290
|
+
form,
|
|
291
|
+
playgroundSDK,
|
|
292
|
+
refreshServerState
|
|
293
|
+
]);
|
|
294
|
+
const destroySession = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
295
|
+
try {
|
|
296
|
+
autoCreateBlockedSignatureRef.current = (0, external_auto_create_js_namespaceObject.serializeAutoCreateInput)((0, external_session_setup_js_namespaceObject.resolveAutoCreateSessionInput)(sessionSetup, form.getFieldsValue(true)));
|
|
297
|
+
sessionMutatingRef.current = true;
|
|
298
|
+
setSessionMutating(true);
|
|
299
|
+
yield playgroundSDK.destroySession();
|
|
300
|
+
external_antd_namespaceObject.message.success('Session disconnected');
|
|
301
|
+
yield refreshServerState();
|
|
302
|
+
yield refreshSessionSetup();
|
|
303
|
+
} catch (error) {
|
|
304
|
+
const errorMessage = error instanceof Error ? error.message : 'Failed to disconnect session';
|
|
305
|
+
external_antd_namespaceObject.message.error(errorMessage);
|
|
306
|
+
} finally{
|
|
307
|
+
sessionMutatingRef.current = false;
|
|
308
|
+
setSessionMutating(false);
|
|
309
|
+
}
|
|
310
|
+
})(), [
|
|
311
|
+
form,
|
|
312
|
+
playgroundSDK,
|
|
313
|
+
refreshServerState,
|
|
314
|
+
refreshSessionSetup,
|
|
315
|
+
sessionSetup
|
|
316
|
+
]);
|
|
317
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
318
|
+
if (!serverOnline) return;
|
|
319
|
+
applyAiConfig();
|
|
320
|
+
}, [
|
|
321
|
+
applyAiConfig,
|
|
322
|
+
serverOnline
|
|
323
|
+
]);
|
|
324
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
325
|
+
if (!serverOnline || sessionViewState.connected) return;
|
|
326
|
+
let disposed = false;
|
|
327
|
+
let refreshing = false;
|
|
328
|
+
const refreshTargets = ()=>_async_to_generator(function*() {
|
|
329
|
+
if (disposed || refreshing) return;
|
|
330
|
+
refreshing = true;
|
|
331
|
+
try {
|
|
332
|
+
yield refreshSessionSetup(form.getFieldsValue(true));
|
|
333
|
+
} finally{
|
|
334
|
+
refreshing = false;
|
|
335
|
+
}
|
|
336
|
+
})();
|
|
337
|
+
refreshTargets();
|
|
338
|
+
const intervalId = window.setInterval(()=>{
|
|
339
|
+
refreshTargets();
|
|
340
|
+
}, pollIntervalMs);
|
|
341
|
+
return ()=>{
|
|
342
|
+
disposed = true;
|
|
343
|
+
window.clearInterval(intervalId);
|
|
344
|
+
};
|
|
345
|
+
}, [
|
|
346
|
+
form,
|
|
347
|
+
pollIntervalMs,
|
|
348
|
+
refreshSessionSetup,
|
|
349
|
+
serverOnline,
|
|
350
|
+
sessionViewState.connected
|
|
351
|
+
]);
|
|
352
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
353
|
+
if (!serverOnline || sessionViewState.connected || !selectedPlatformId) return;
|
|
354
|
+
const currentPlatformSelectorFieldKey = getPlatformSelectorFieldKey(sessionSetup);
|
|
355
|
+
if (!currentPlatformSelectorFieldKey) return;
|
|
356
|
+
if (lastSetupPlatformIdRef.current === selectedPlatformId) return;
|
|
357
|
+
refreshSessionSetup(_object_spread_props(_object_spread({}, form.getFieldsValue(true)), {
|
|
358
|
+
[currentPlatformSelectorFieldKey]: selectedPlatformId
|
|
359
|
+
}));
|
|
360
|
+
}, [
|
|
361
|
+
form,
|
|
362
|
+
refreshSessionSetup,
|
|
363
|
+
selectedPlatformId,
|
|
364
|
+
serverOnline,
|
|
365
|
+
sessionSetup,
|
|
366
|
+
sessionViewState.connected
|
|
367
|
+
]);
|
|
368
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
369
|
+
if (sessionViewState.connected) {
|
|
370
|
+
autoCreateSignatureRef.current = null;
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (!serverOnline || sessionLoading || sessionMutating || sessionMutatingRef.current || sessionSetupError) return;
|
|
374
|
+
const autoCreateInput = (0, external_session_setup_js_namespaceObject.resolveAutoCreateSessionInput)(sessionSetup, form.getFieldsValue(true));
|
|
375
|
+
const { signature, shouldCreate } = (0, external_auto_create_js_namespaceObject.resolveAutoCreateDecision)({
|
|
376
|
+
autoCreateInput,
|
|
377
|
+
lastAttemptedSignature: autoCreateSignatureRef.current,
|
|
378
|
+
blockedSignature: autoCreateBlockedSignatureRef.current
|
|
379
|
+
});
|
|
380
|
+
if (!shouldCreate || !signature) {
|
|
381
|
+
if (!signature) autoCreateSignatureRef.current = null;
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
autoCreateSignatureRef.current = signature;
|
|
385
|
+
(()=>_async_to_generator(function*() {
|
|
386
|
+
const created = yield createSession(null != autoCreateInput ? autoCreateInput : void 0, {
|
|
387
|
+
silent: true
|
|
388
|
+
});
|
|
389
|
+
if (!created) autoCreateSignatureRef.current = null;
|
|
390
|
+
})())();
|
|
391
|
+
}, [
|
|
392
|
+
createSession,
|
|
393
|
+
form,
|
|
394
|
+
serverOnline,
|
|
395
|
+
sessionLoading,
|
|
396
|
+
sessionMutating,
|
|
397
|
+
sessionSetup,
|
|
398
|
+
sessionSetupError,
|
|
399
|
+
sessionViewState.connected
|
|
400
|
+
]);
|
|
401
|
+
return {
|
|
402
|
+
state: {
|
|
403
|
+
playgroundSDK,
|
|
404
|
+
form,
|
|
405
|
+
formValues,
|
|
406
|
+
serverOnline,
|
|
407
|
+
isUserOperating,
|
|
408
|
+
deviceType,
|
|
409
|
+
runtimeInfo,
|
|
410
|
+
executionUxHints,
|
|
411
|
+
sessionViewState,
|
|
412
|
+
sessionSetup,
|
|
413
|
+
sessionSetupError,
|
|
414
|
+
sessionLoading,
|
|
415
|
+
sessionMutating,
|
|
416
|
+
countdown,
|
|
417
|
+
countdownSeconds
|
|
418
|
+
},
|
|
419
|
+
actions: {
|
|
420
|
+
refreshServerState,
|
|
421
|
+
refreshSessionSetup,
|
|
422
|
+
createSession,
|
|
423
|
+
destroySession,
|
|
424
|
+
finishCountdown
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
exports.usePlaygroundController = __webpack_exports__.usePlaygroundController;
|
|
429
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
430
|
+
"usePlaygroundController"
|
|
431
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
432
|
+
Object.defineProperty(exports, '__esModule', {
|
|
433
|
+
value: true
|
|
434
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
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 ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>dropdown_chevron
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
require("react");
|
|
31
|
+
function _define_property(obj, key, value) {
|
|
32
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
else obj[key] = value;
|
|
39
|
+
return obj;
|
|
40
|
+
}
|
|
41
|
+
function _object_spread(target) {
|
|
42
|
+
for(var i = 1; i < arguments.length; i++){
|
|
43
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
44
|
+
var ownKeys = Object.keys(source);
|
|
45
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
46
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
47
|
+
}));
|
|
48
|
+
ownKeys.forEach(function(key) {
|
|
49
|
+
_define_property(target, key, source[key]);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return target;
|
|
53
|
+
}
|
|
54
|
+
function dropdown_chevron_ownKeys(object, enumerableOnly) {
|
|
55
|
+
var keys = Object.keys(object);
|
|
56
|
+
if (Object.getOwnPropertySymbols) {
|
|
57
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
58
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
59
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
60
|
+
});
|
|
61
|
+
keys.push.apply(keys, symbols);
|
|
62
|
+
}
|
|
63
|
+
return keys;
|
|
64
|
+
}
|
|
65
|
+
function _object_spread_props(target, source) {
|
|
66
|
+
source = null != source ? source : {};
|
|
67
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
68
|
+
else dropdown_chevron_ownKeys(Object(source)).forEach(function(key) {
|
|
69
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
70
|
+
});
|
|
71
|
+
return target;
|
|
72
|
+
}
|
|
73
|
+
const SvgDropdownChevron = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("svg", _object_spread_props(_object_spread({
|
|
74
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
75
|
+
width: 16,
|
|
76
|
+
height: 16,
|
|
77
|
+
fill: "none",
|
|
78
|
+
viewBox: "0 0 16 16"
|
|
79
|
+
}, props), {
|
|
80
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
|
|
81
|
+
stroke: "#333",
|
|
82
|
+
strokeLinecap: "round",
|
|
83
|
+
strokeLinejoin: "round",
|
|
84
|
+
strokeWidth: 1.333,
|
|
85
|
+
d: "m12 6-4 4-4-4"
|
|
86
|
+
})
|
|
87
|
+
}));
|
|
88
|
+
const dropdown_chevron = SvgDropdownChevron;
|
|
89
|
+
exports["default"] = __webpack_exports__["default"];
|
|
90
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
91
|
+
"default"
|
|
92
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
93
|
+
Object.defineProperty(exports, '__esModule', {
|
|
94
|
+
value: true
|
|
95
|
+
});
|