@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,169 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, Form, Input, InputNumber, Radio, Select } from "antd";
|
|
3
|
+
import dropdown_chevron from "./icons/dropdown-chevron.mjs";
|
|
4
|
+
import midscene_logo from "./icons/midscene-logo.mjs";
|
|
5
|
+
import "./SessionSetupPanel.css";
|
|
6
|
+
function getPlatformSelectorFieldKey(setup) {
|
|
7
|
+
var _setup_platformSelector;
|
|
8
|
+
return null == setup ? void 0 : null == (_setup_platformSelector = setup.platformSelector) ? void 0 : _setup_platformSelector.fieldKey;
|
|
9
|
+
}
|
|
10
|
+
function getPlatformSelectorOptions(field, setup) {
|
|
11
|
+
var _setup_platformRegistry;
|
|
12
|
+
if (getPlatformSelectorFieldKey(setup) !== field.key || !(null == setup ? void 0 : null == (_setup_platformRegistry = setup.platformRegistry) ? void 0 : _setup_platformRegistry.length)) return field.options;
|
|
13
|
+
const registryOptions = setup.platformRegistry.map((platform)=>({
|
|
14
|
+
label: platform.label,
|
|
15
|
+
value: platform.id,
|
|
16
|
+
description: [
|
|
17
|
+
platform.description,
|
|
18
|
+
platform.unavailableReason
|
|
19
|
+
].filter(Boolean).join(' · ') || void 0
|
|
20
|
+
}));
|
|
21
|
+
return registryOptions.length > 0 ? registryOptions : field.options;
|
|
22
|
+
}
|
|
23
|
+
function DropdownSuffix() {
|
|
24
|
+
return /*#__PURE__*/ jsx(dropdown_chevron, {
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
className: "session-setup-select-icon"
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function renderSessionField(field, sessionSetup) {
|
|
30
|
+
if ('number' === field.type) return /*#__PURE__*/ jsx(InputNumber, {
|
|
31
|
+
style: {
|
|
32
|
+
width: '100%'
|
|
33
|
+
},
|
|
34
|
+
placeholder: field.placeholder
|
|
35
|
+
});
|
|
36
|
+
if ('select' === field.type) {
|
|
37
|
+
var _ref;
|
|
38
|
+
var _sessionSetup_platformSelector;
|
|
39
|
+
const platformSelectorFieldKey = getPlatformSelectorFieldKey(sessionSetup);
|
|
40
|
+
const platformOptions = getPlatformSelectorOptions(field, sessionSetup);
|
|
41
|
+
const shouldRenderPlatformSelector = platformSelectorFieldKey === field.key && (null == sessionSetup ? void 0 : null == (_sessionSetup_platformSelector = sessionSetup.platformSelector) ? void 0 : _sessionSetup_platformSelector.variant) === 'cards';
|
|
42
|
+
if (shouldRenderPlatformSelector) return /*#__PURE__*/ jsx(Radio.Group, {
|
|
43
|
+
className: "platform-selector-group",
|
|
44
|
+
children: (platformOptions || []).map((option)=>/*#__PURE__*/ jsxs(Radio.Button, {
|
|
45
|
+
value: option.value,
|
|
46
|
+
className: "platform-selector-card",
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ jsx("div", {
|
|
49
|
+
className: "platform-selector-title",
|
|
50
|
+
children: option.label
|
|
51
|
+
}),
|
|
52
|
+
option.description ? /*#__PURE__*/ jsx("div", {
|
|
53
|
+
className: "platform-selector-description",
|
|
54
|
+
children: option.description
|
|
55
|
+
}) : null
|
|
56
|
+
]
|
|
57
|
+
}, String(option.value)))
|
|
58
|
+
});
|
|
59
|
+
return /*#__PURE__*/ jsx(Select, {
|
|
60
|
+
placeholder: field.placeholder,
|
|
61
|
+
suffixIcon: /*#__PURE__*/ jsx(DropdownSuffix, {}),
|
|
62
|
+
options: (null != (_ref = null != platformOptions ? platformOptions : field.options) ? _ref : []).map((option)=>({
|
|
63
|
+
label: option.label,
|
|
64
|
+
value: option.value,
|
|
65
|
+
description: option.description
|
|
66
|
+
})),
|
|
67
|
+
optionRender: (option)=>{
|
|
68
|
+
const description = option.data.description;
|
|
69
|
+
if (!description) return option.data.label;
|
|
70
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
71
|
+
className: "session-select-option",
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ jsx("div", {
|
|
74
|
+
className: "session-select-option-label",
|
|
75
|
+
children: option.data.label
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ jsx("div", {
|
|
78
|
+
className: "session-select-option-description",
|
|
79
|
+
children: description
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
87
|
+
placeholder: field.placeholder
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const DEFAULT_TITLE = 'Create Agent';
|
|
91
|
+
const DEFAULT_DESCRIPTION = 'Create a platform session before running actions.';
|
|
92
|
+
function SessionSetupPanel({ form, sessionSetup, sessionSetupError, sessionViewState, sessionLoading, sessionMutating, onCreateSession }) {
|
|
93
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
94
|
+
const submitDisabled = sessionMutating || sessionLoading || 'blocked' === sessionViewState.setupState;
|
|
95
|
+
const primaryLabel = null != (_ref = null == sessionSetup ? void 0 : sessionSetup.primaryActionLabel) ? _ref : DEFAULT_TITLE;
|
|
96
|
+
const title = null != (_ref1 = null == sessionSetup ? void 0 : sessionSetup.title) ? _ref1 : DEFAULT_TITLE;
|
|
97
|
+
const description = null != (_ref2 = null == sessionSetup ? void 0 : sessionSetup.description) ? _ref2 : DEFAULT_DESCRIPTION;
|
|
98
|
+
return /*#__PURE__*/ jsx("div", {
|
|
99
|
+
className: "session-setup-panel",
|
|
100
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
101
|
+
className: "session-setup-card",
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ jsx(midscene_logo, {
|
|
104
|
+
"aria-hidden": "true",
|
|
105
|
+
className: "session-setup-logo"
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ jsx("h1", {
|
|
108
|
+
className: "session-setup-title",
|
|
109
|
+
children: title
|
|
110
|
+
}),
|
|
111
|
+
/*#__PURE__*/ jsx("p", {
|
|
112
|
+
className: "session-setup-description",
|
|
113
|
+
children: description
|
|
114
|
+
}),
|
|
115
|
+
'blocked' === sessionViewState.setupState && sessionViewState.setupBlockingReason && /*#__PURE__*/ jsx(Alert, {
|
|
116
|
+
type: "error",
|
|
117
|
+
showIcon: true,
|
|
118
|
+
message: "Setup blocked",
|
|
119
|
+
description: sessionViewState.setupBlockingReason,
|
|
120
|
+
className: "session-setup-alert"
|
|
121
|
+
}),
|
|
122
|
+
sessionSetupError ? /*#__PURE__*/ jsx(Alert, {
|
|
123
|
+
type: "error",
|
|
124
|
+
showIcon: true,
|
|
125
|
+
message: "Failed to load setup",
|
|
126
|
+
description: sessionSetupError,
|
|
127
|
+
className: "session-setup-alert"
|
|
128
|
+
}) : null,
|
|
129
|
+
(null == sessionSetup ? void 0 : sessionSetup.notice) ? /*#__PURE__*/ jsx(Alert, {
|
|
130
|
+
type: sessionSetup.notice.type,
|
|
131
|
+
showIcon: true,
|
|
132
|
+
message: sessionSetup.notice.message,
|
|
133
|
+
description: sessionSetup.notice.description,
|
|
134
|
+
className: "session-setup-alert"
|
|
135
|
+
}) : null,
|
|
136
|
+
/*#__PURE__*/ jsxs(Form, {
|
|
137
|
+
form: form,
|
|
138
|
+
layout: "vertical",
|
|
139
|
+
className: "session-setup-form",
|
|
140
|
+
onFinish: ()=>{
|
|
141
|
+
if (submitDisabled) return;
|
|
142
|
+
onCreateSession();
|
|
143
|
+
},
|
|
144
|
+
children: [
|
|
145
|
+
(null != (_ref3 = null == sessionSetup ? void 0 : sessionSetup.fields) ? _ref3 : []).map((field)=>/*#__PURE__*/ jsx(Form.Item, {
|
|
146
|
+
label: field.label,
|
|
147
|
+
name: field.key,
|
|
148
|
+
tooltip: field.description,
|
|
149
|
+
rules: field.required ? [
|
|
150
|
+
{
|
|
151
|
+
required: true,
|
|
152
|
+
message: `${field.label} is required`
|
|
153
|
+
}
|
|
154
|
+
] : void 0,
|
|
155
|
+
children: renderSessionField(field, sessionSetup)
|
|
156
|
+
}, field.key)),
|
|
157
|
+
/*#__PURE__*/ jsx("button", {
|
|
158
|
+
type: "submit",
|
|
159
|
+
className: "session-setup-submit",
|
|
160
|
+
disabled: submitDisabled,
|
|
161
|
+
children: sessionMutating ? 'Creating...' : primaryLabel
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export { SessionSetupPanel, getPlatformSelectorOptions };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.app-region-drag {
|
|
2
|
+
-webkit-user-select: none;
|
|
3
|
+
-moz-user-select: none;
|
|
4
|
+
user-select: none;
|
|
5
|
+
app-region: drag;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.app-region-no-drag {
|
|
9
|
+
app-region: no-drag;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.header {
|
|
13
|
+
border-bottom: 1px solid #ccc;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
align-items: center;
|
|
16
|
+
padding: 8px 12px;
|
|
17
|
+
display: flex;
|
|
18
|
+
}
|
|
19
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import WinControlTool from "../WinControlTool/index.mjs";
|
|
4
|
+
import "./index.css";
|
|
5
|
+
function _define_property(obj, key, value) {
|
|
6
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
7
|
+
value: value,
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true
|
|
11
|
+
});
|
|
12
|
+
else obj[key] = value;
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
function _object_spread(target) {
|
|
16
|
+
for(var i = 1; i < arguments.length; i++){
|
|
17
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
18
|
+
var ownKeys = Object.keys(source);
|
|
19
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
+
}));
|
|
22
|
+
ownKeys.forEach(function(key) {
|
|
23
|
+
_define_property(target, key, source[key]);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return target;
|
|
27
|
+
}
|
|
28
|
+
function Header(props) {
|
|
29
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
30
|
+
className: "header app-region-drag",
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ jsx("div", {}),
|
|
33
|
+
/*#__PURE__*/ jsx(WinControlTool, _object_spread({}, props))
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export { Header };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.assistant-form {
|
|
2
|
+
gap: 16px;
|
|
3
|
+
display: flex;
|
|
4
|
+
padding: 8px !important;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.assistant-form .form-item-url {
|
|
8
|
+
flex: 1 !important;
|
|
9
|
+
margin-right: 0 !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.assistant-form .form-item-url .ant-input {
|
|
13
|
+
border-radius: 15px;
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { Button, Form, Input } from "antd";
|
|
4
|
+
import { ArrowLeftOutlined, ArrowRightOutlined, RedoOutlined } from "@ant-design/icons";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
7
|
+
try {
|
|
8
|
+
var info = gen[key](arg);
|
|
9
|
+
var value = info.value;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
reject(error);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (info.done) resolve(value);
|
|
15
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
16
|
+
}
|
|
17
|
+
function _async_to_generator(fn) {
|
|
18
|
+
return function() {
|
|
19
|
+
var self = this, args = arguments;
|
|
20
|
+
return new Promise(function(resolve, reject) {
|
|
21
|
+
var gen = fn.apply(self, args);
|
|
22
|
+
function _next(value) {
|
|
23
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
24
|
+
}
|
|
25
|
+
function _throw(err) {
|
|
26
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
27
|
+
}
|
|
28
|
+
_next(void 0);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function Nav() {
|
|
33
|
+
const [form] = Form.useForm();
|
|
34
|
+
const onFinish = (values)=>_async_to_generator(function*() {
|
|
35
|
+
if (values.url) {
|
|
36
|
+
var _window_electron;
|
|
37
|
+
let url = values.url.startsWith('http') ? values.url : `https://${values.url}`;
|
|
38
|
+
null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('view:navigate', url);
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
useEffect(()=>{
|
|
42
|
+
var _window_electron;
|
|
43
|
+
null == (_window_electron = window.electron) || _window_electron.ipcRenderer.on('update-url', (event, url)=>{
|
|
44
|
+
form.setFieldsValue({
|
|
45
|
+
url
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}, []);
|
|
49
|
+
return /*#__PURE__*/ jsxs(Form, {
|
|
50
|
+
layout: "inline",
|
|
51
|
+
className: "assistant-form",
|
|
52
|
+
form: form,
|
|
53
|
+
autoComplete: "off",
|
|
54
|
+
onFinish: onFinish,
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ jsx(Button, {
|
|
57
|
+
type: "text",
|
|
58
|
+
icon: /*#__PURE__*/ jsx(ArrowLeftOutlined, {}),
|
|
59
|
+
onClick: ()=>{
|
|
60
|
+
var _window_electron;
|
|
61
|
+
null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('view:goBack');
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ jsx(Button, {
|
|
65
|
+
type: "text",
|
|
66
|
+
icon: /*#__PURE__*/ jsx(ArrowRightOutlined, {}),
|
|
67
|
+
onClick: ()=>{
|
|
68
|
+
var _window_electron;
|
|
69
|
+
null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('view:goForward');
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ jsx(Button, {
|
|
73
|
+
type: "text",
|
|
74
|
+
icon: /*#__PURE__*/ jsx(RedoOutlined, {
|
|
75
|
+
rotate: 270
|
|
76
|
+
}),
|
|
77
|
+
onClick: ()=>{
|
|
78
|
+
var _window_electron;
|
|
79
|
+
null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('view:reload');
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ jsx(Form.Item, {
|
|
83
|
+
label: "",
|
|
84
|
+
name: "url",
|
|
85
|
+
className: "form-item-url",
|
|
86
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
87
|
+
placeholder: "url"
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export { Nav };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { Button } from "antd";
|
|
4
|
+
import { BorderOutlined, CloseOutlined, MinusOutlined, RotateRightOutlined } from "@ant-design/icons";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
function WinControlTool({ token, parentToken, pageName }) {
|
|
7
|
+
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
8
|
+
const handleCloseWindow = useCallback(()=>{
|
|
9
|
+
window.__Window.closeWindow();
|
|
10
|
+
token && parentToken && window.__Window.sendMessage({
|
|
11
|
+
from: token,
|
|
12
|
+
to: parentToken,
|
|
13
|
+
token: `${Math.random()}`,
|
|
14
|
+
message: {
|
|
15
|
+
pageName: pageName,
|
|
16
|
+
actionName: 'closeDialog'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}, [
|
|
20
|
+
token,
|
|
21
|
+
parentToken,
|
|
22
|
+
pageName
|
|
23
|
+
]);
|
|
24
|
+
useEffect(()=>{
|
|
25
|
+
window.addEventListener('beforeunload', handleCloseWindow);
|
|
26
|
+
return ()=>{
|
|
27
|
+
window.removeEventListener('beforeunload', handleCloseWindow);
|
|
28
|
+
};
|
|
29
|
+
}, [
|
|
30
|
+
handleCloseWindow
|
|
31
|
+
]);
|
|
32
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
33
|
+
className: "control-tool",
|
|
34
|
+
children: [
|
|
35
|
+
/*#__PURE__*/ jsx(Button, {
|
|
36
|
+
className: "app-region-no-drag",
|
|
37
|
+
type: "text",
|
|
38
|
+
onClick: ()=>{
|
|
39
|
+
var _window_electron;
|
|
40
|
+
return null == (_window_electron = window.electron) ? void 0 : _window_electron.ipcRenderer.send('win:invoke', 'min');
|
|
41
|
+
},
|
|
42
|
+
icon: /*#__PURE__*/ jsx(MinusOutlined, {})
|
|
43
|
+
}),
|
|
44
|
+
isFullScreen ? /*#__PURE__*/ jsx(Button, {
|
|
45
|
+
className: "app-region-no-drag",
|
|
46
|
+
type: "text",
|
|
47
|
+
onClick: ()=>{
|
|
48
|
+
var _window_electron;
|
|
49
|
+
setIsFullScreen(false);
|
|
50
|
+
null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('win:invoke', 'max');
|
|
51
|
+
},
|
|
52
|
+
icon: /*#__PURE__*/ jsx(RotateRightOutlined, {
|
|
53
|
+
rotate: 90
|
|
54
|
+
})
|
|
55
|
+
}) : /*#__PURE__*/ jsx(Button, {
|
|
56
|
+
className: "app-region-no-drag",
|
|
57
|
+
type: "text",
|
|
58
|
+
onClick: ()=>{
|
|
59
|
+
var _window_electron;
|
|
60
|
+
setIsFullScreen(true);
|
|
61
|
+
null == (_window_electron = window.electron) || _window_electron.ipcRenderer.send('win:invoke', 'max');
|
|
62
|
+
},
|
|
63
|
+
icon: /*#__PURE__*/ jsx(BorderOutlined, {})
|
|
64
|
+
}),
|
|
65
|
+
/*#__PURE__*/ jsx(Button, {
|
|
66
|
+
className: "app-region-no-drag",
|
|
67
|
+
type: "text",
|
|
68
|
+
onClick: ()=>{
|
|
69
|
+
handleCloseWindow();
|
|
70
|
+
},
|
|
71
|
+
icon: /*#__PURE__*/ jsx(CloseOutlined, {})
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
export { WinControlTool as default };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) resolve(value);
|
|
10
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
11
|
+
}
|
|
12
|
+
function _async_to_generator(fn) {
|
|
13
|
+
return function() {
|
|
14
|
+
var self = this, args = arguments;
|
|
15
|
+
return new Promise(function(resolve, reject) {
|
|
16
|
+
var gen = fn.apply(self, args);
|
|
17
|
+
function _next(value) {
|
|
18
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
19
|
+
}
|
|
20
|
+
function _throw(err) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
22
|
+
}
|
|
23
|
+
_next(void 0);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function hasPlaygroundAiConfig(config) {
|
|
28
|
+
return Object.keys(config).length > 0;
|
|
29
|
+
}
|
|
30
|
+
function serializePlaygroundAiConfig(config) {
|
|
31
|
+
return JSON.stringify(Object.entries(config).sort(([leftKey], [rightKey])=>leftKey.localeCompare(rightKey)));
|
|
32
|
+
}
|
|
33
|
+
function applyPlaygroundAiConfig(playgroundSDK, config) {
|
|
34
|
+
return _async_to_generator(function*() {
|
|
35
|
+
if (!hasPlaygroundAiConfig(config)) return false;
|
|
36
|
+
yield playgroundSDK.overrideConfig(config);
|
|
37
|
+
return true;
|
|
38
|
+
})();
|
|
39
|
+
}
|
|
40
|
+
export { applyPlaygroundAiConfig, hasPlaygroundAiConfig, serializePlaygroundAiConfig };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function serializeAutoCreateInput(autoCreateInput) {
|
|
2
|
+
if (!autoCreateInput) return null;
|
|
3
|
+
return JSON.stringify(autoCreateInput);
|
|
4
|
+
}
|
|
5
|
+
function resolveAutoCreateDecision({ autoCreateInput, lastAttemptedSignature, blockedSignature }) {
|
|
6
|
+
const signature = serializeAutoCreateInput(autoCreateInput);
|
|
7
|
+
if (!signature) return {
|
|
8
|
+
signature: null,
|
|
9
|
+
shouldCreate: false
|
|
10
|
+
};
|
|
11
|
+
return {
|
|
12
|
+
signature,
|
|
13
|
+
shouldCreate: signature !== lastAttemptedSignature && signature !== blockedSignature
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function shouldResetAutoCreateBlock(options) {
|
|
17
|
+
return !(null == options ? void 0 : options.silent);
|
|
18
|
+
}
|
|
19
|
+
export { resolveAutoCreateDecision, serializeAutoCreateInput, shouldResetAutoCreateBlock };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
3
|
+
value: value,
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true
|
|
7
|
+
});
|
|
8
|
+
else obj[key] = value;
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
function _object_spread(target) {
|
|
12
|
+
for(var i = 1; i < arguments.length; i++){
|
|
13
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
14
|
+
var ownKeys = Object.keys(source);
|
|
15
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
16
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
17
|
+
}));
|
|
18
|
+
ownKeys.forEach(function(key) {
|
|
19
|
+
_define_property(target, key, source[key]);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
24
|
+
function selectors_ownKeys(object, enumerableOnly) {
|
|
25
|
+
var keys = Object.keys(object);
|
|
26
|
+
if (Object.getOwnPropertySymbols) {
|
|
27
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
28
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
29
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
30
|
+
});
|
|
31
|
+
keys.push.apply(keys, symbols);
|
|
32
|
+
}
|
|
33
|
+
return keys;
|
|
34
|
+
}
|
|
35
|
+
function _object_spread_props(target, source) {
|
|
36
|
+
source = null != source ? source : {};
|
|
37
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
38
|
+
else selectors_ownKeys(Object(source)).forEach(function(key) {
|
|
39
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
40
|
+
});
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
43
|
+
function buildConversationConfig(state, playgroundConfig) {
|
|
44
|
+
const defaultConfig = {
|
|
45
|
+
showContextPreview: false,
|
|
46
|
+
layout: 'vertical',
|
|
47
|
+
showVersionInfo: false,
|
|
48
|
+
enableScrollToBottom: false,
|
|
49
|
+
serverMode: true,
|
|
50
|
+
showEnvConfigReminder: false,
|
|
51
|
+
showClearButton: false,
|
|
52
|
+
showSystemMessageHeader: false,
|
|
53
|
+
promptInputChrome: {
|
|
54
|
+
variant: 'minimal'
|
|
55
|
+
},
|
|
56
|
+
executionFlow: {
|
|
57
|
+
collapsible: true
|
|
58
|
+
},
|
|
59
|
+
deviceType: state.deviceType,
|
|
60
|
+
executionUx: {
|
|
61
|
+
hints: state.executionUxHints,
|
|
62
|
+
countdownSeconds: state.countdownSeconds
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return _object_spread_props(_object_spread({}, defaultConfig, playgroundConfig), {
|
|
66
|
+
executionFlow: _object_spread({}, defaultConfig.executionFlow, null == playgroundConfig ? void 0 : playgroundConfig.executionFlow),
|
|
67
|
+
executionUx: _object_spread({}, defaultConfig.executionUx, null == playgroundConfig ? void 0 : playgroundConfig.executionUx)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function buildConversationBranding(runtimeInfo, title, appVersion, deviceType, branding) {
|
|
71
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
72
|
+
return _object_spread_props(_object_spread({}, branding), {
|
|
73
|
+
title: null != (_ref = null == runtimeInfo ? void 0 : runtimeInfo.title) ? _ref : title,
|
|
74
|
+
version: appVersion,
|
|
75
|
+
targetName: null != (_ref1 = null != (_ref2 = null != (_ref3 = null == runtimeInfo ? void 0 : runtimeInfo.platformId) ? _ref3 : null == branding ? void 0 : branding.targetName) ? _ref2 : deviceType) ? _ref1 : 'screen'
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export { buildConversationBranding, buildConversationConfig };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function runSingleFlight(pendingRef, task) {
|
|
2
|
+
if (pendingRef.current) return pendingRef.current;
|
|
3
|
+
const taskPromise = task();
|
|
4
|
+
const pendingState = {
|
|
5
|
+
promise: null
|
|
6
|
+
};
|
|
7
|
+
pendingState.promise = taskPromise.finally(()=>{
|
|
8
|
+
if (pendingRef.current === pendingState.promise) pendingRef.current = null;
|
|
9
|
+
});
|
|
10
|
+
pendingRef.current = pendingState.promise;
|
|
11
|
+
return pendingState.promise;
|
|
12
|
+
}
|
|
13
|
+
export { runSingleFlight };
|
|
File without changes
|