@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,174 @@
|
|
|
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
|
+
buildFallbackRuntimeInfo: ()=>buildFallbackRuntimeInfo,
|
|
28
|
+
filterValidExecutionUxHints: ()=>filterValidExecutionUxHints,
|
|
29
|
+
isValidDeviceType: ()=>isValidDeviceType,
|
|
30
|
+
normalizeRuntimeDeviceType: ()=>normalizeRuntimeDeviceType,
|
|
31
|
+
resolvePreviewConnectionInfo: ()=>resolvePreviewConnectionInfo
|
|
32
|
+
});
|
|
33
|
+
function _define_property(obj, key, value) {
|
|
34
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
35
|
+
value: value,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true
|
|
39
|
+
});
|
|
40
|
+
else obj[key] = value;
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
function _object_spread(target) {
|
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
|
45
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
48
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
49
|
+
}));
|
|
50
|
+
ownKeys.forEach(function(key) {
|
|
51
|
+
_define_property(target, key, source[key]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return target;
|
|
55
|
+
}
|
|
56
|
+
function ownKeys(object, enumerableOnly) {
|
|
57
|
+
var keys = Object.keys(object);
|
|
58
|
+
if (Object.getOwnPropertySymbols) {
|
|
59
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
60
|
+
if (enumerableOnly) symbols = symbols.filter(function(sym) {
|
|
61
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
62
|
+
});
|
|
63
|
+
keys.push.apply(keys, symbols);
|
|
64
|
+
}
|
|
65
|
+
return keys;
|
|
66
|
+
}
|
|
67
|
+
function _object_spread_props(target, source) {
|
|
68
|
+
source = null != source ? source : {};
|
|
69
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
70
|
+
else ownKeys(Object(source)).forEach(function(key) {
|
|
71
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
72
|
+
});
|
|
73
|
+
return target;
|
|
74
|
+
}
|
|
75
|
+
function isRemoteAndroidDeviceId(value) {
|
|
76
|
+
return 'string' == typeof value && /^\d+\.\d+\.\d+\.\d+:\d+$/.test(value);
|
|
77
|
+
}
|
|
78
|
+
const VALID_DEVICE_TYPES = [
|
|
79
|
+
'android',
|
|
80
|
+
'ios',
|
|
81
|
+
'web',
|
|
82
|
+
'harmony',
|
|
83
|
+
'computer'
|
|
84
|
+
];
|
|
85
|
+
const VALID_EXECUTION_UX_HINTS = [
|
|
86
|
+
'countdown-before-run'
|
|
87
|
+
];
|
|
88
|
+
function isValidDeviceType(type) {
|
|
89
|
+
return VALID_DEVICE_TYPES.includes(type);
|
|
90
|
+
}
|
|
91
|
+
function normalizeRuntimeDeviceType(runtimeInfo, fallback) {
|
|
92
|
+
var _runtimeInfo_interface;
|
|
93
|
+
const candidates = [
|
|
94
|
+
null == runtimeInfo ? void 0 : runtimeInfo.platformId,
|
|
95
|
+
null == runtimeInfo ? void 0 : null == (_runtimeInfo_interface = runtimeInfo.interface) ? void 0 : _runtimeInfo_interface.type
|
|
96
|
+
].filter((value)=>Boolean(value));
|
|
97
|
+
for (const candidate of candidates){
|
|
98
|
+
const normalized = candidate.toLowerCase();
|
|
99
|
+
if (isValidDeviceType(normalized)) return normalized;
|
|
100
|
+
}
|
|
101
|
+
return fallback;
|
|
102
|
+
}
|
|
103
|
+
function buildFallbackRuntimeInfo(previousRuntimeInfo, interfaceInfo) {
|
|
104
|
+
return _object_spread_props(_object_spread({}, previousRuntimeInfo), {
|
|
105
|
+
interface: interfaceInfo,
|
|
106
|
+
preview: (null == previousRuntimeInfo ? void 0 : previousRuntimeInfo.preview) || {
|
|
107
|
+
kind: 'none',
|
|
108
|
+
capabilities: []
|
|
109
|
+
},
|
|
110
|
+
executionUxHints: (null == previousRuntimeInfo ? void 0 : previousRuntimeInfo.executionUxHints) || [],
|
|
111
|
+
metadata: (null == previousRuntimeInfo ? void 0 : previousRuntimeInfo.metadata) || {}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function filterValidExecutionUxHints(runtimeInfo) {
|
|
115
|
+
return ((null == runtimeInfo ? void 0 : runtimeInfo.executionUxHints) || []).filter((hint)=>VALID_EXECUTION_UX_HINTS.includes(hint));
|
|
116
|
+
}
|
|
117
|
+
function resolvePreviewConnectionInfo(runtimeInfo, serverUrl) {
|
|
118
|
+
const preview = null == runtimeInfo ? void 0 : runtimeInfo.preview;
|
|
119
|
+
if (!preview || 'none' === preview.kind || 'custom' === preview.kind) return {
|
|
120
|
+
type: 'none'
|
|
121
|
+
};
|
|
122
|
+
const resolvedServerUrl = serverUrl || "u" > typeof window && window.location.origin || '';
|
|
123
|
+
if ('mjpeg' === preview.kind) {
|
|
124
|
+
const mjpegPath = preview.mjpegPath || '/mjpeg';
|
|
125
|
+
if (!resolvedServerUrl) return {
|
|
126
|
+
type: 'screenshot'
|
|
127
|
+
};
|
|
128
|
+
return {
|
|
129
|
+
type: 'mjpeg',
|
|
130
|
+
mjpegUrl: new URL(mjpegPath, `${resolvedServerUrl}/`).toString()
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if ('scrcpy' === preview.kind) {
|
|
134
|
+
var _runtimeInfo_metadata, _preview_custom;
|
|
135
|
+
const runtimeDeviceId = 'string' == typeof (null == runtimeInfo ? void 0 : null == (_runtimeInfo_metadata = runtimeInfo.metadata) ? void 0 : _runtimeInfo_metadata.deviceId) ? runtimeInfo.metadata.deviceId.trim() : void 0;
|
|
136
|
+
if (isRemoteAndroidDeviceId(runtimeDeviceId)) return {
|
|
137
|
+
type: 'screenshot'
|
|
138
|
+
};
|
|
139
|
+
const scrcpyPort = Number(null == (_preview_custom = preview.custom) ? void 0 : _preview_custom.scrcpyPort);
|
|
140
|
+
const resolvedScrcpyPort = Number.isFinite(scrcpyPort) ? scrcpyPort : void 0;
|
|
141
|
+
const scrcpyUrl = resolvedScrcpyPort && resolvedServerUrl ? (()=>{
|
|
142
|
+
const url = new URL(resolvedServerUrl);
|
|
143
|
+
url.port = String(resolvedScrcpyPort);
|
|
144
|
+
url.pathname = '/';
|
|
145
|
+
url.search = '';
|
|
146
|
+
url.hash = '';
|
|
147
|
+
return url.toString();
|
|
148
|
+
})() : void 0;
|
|
149
|
+
return {
|
|
150
|
+
deviceId: runtimeDeviceId,
|
|
151
|
+
type: 'scrcpy',
|
|
152
|
+
scrcpyPort: resolvedScrcpyPort,
|
|
153
|
+
scrcpyUrl
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
type: 'screenshot'
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
exports.buildFallbackRuntimeInfo = __webpack_exports__.buildFallbackRuntimeInfo;
|
|
161
|
+
exports.filterValidExecutionUxHints = __webpack_exports__.filterValidExecutionUxHints;
|
|
162
|
+
exports.isValidDeviceType = __webpack_exports__.isValidDeviceType;
|
|
163
|
+
exports.normalizeRuntimeDeviceType = __webpack_exports__.normalizeRuntimeDeviceType;
|
|
164
|
+
exports.resolvePreviewConnectionInfo = __webpack_exports__.resolvePreviewConnectionInfo;
|
|
165
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
166
|
+
"buildFallbackRuntimeInfo",
|
|
167
|
+
"filterValidExecutionUxHints",
|
|
168
|
+
"isValidDeviceType",
|
|
169
|
+
"normalizeRuntimeDeviceType",
|
|
170
|
+
"resolvePreviewConnectionInfo"
|
|
171
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
172
|
+
Object.defineProperty(exports, '__esModule', {
|
|
173
|
+
value: true
|
|
174
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
SCRCPY_METADATA_TIMEOUT_MS: ()=>SCRCPY_METADATA_TIMEOUT_MS,
|
|
28
|
+
getScrcpyDecoderStatusText: ()=>getScrcpyDecoderStatusText,
|
|
29
|
+
getScrcpyPreviewStatusText: ()=>getScrcpyPreviewStatusText,
|
|
30
|
+
getScrcpyMetadataTimeoutMessage: ()=>getScrcpyMetadataTimeoutMessage,
|
|
31
|
+
isScrcpyPreviewStatusEvent: ()=>isScrcpyPreviewStatusEvent,
|
|
32
|
+
getDefaultScrcpyWaitingStatusText: ()=>getDefaultScrcpyWaitingStatusText
|
|
33
|
+
});
|
|
34
|
+
const constants_namespaceObject = require("@godscene/shared/constants");
|
|
35
|
+
const SCRCPY_METADATA_TIMEOUT_MS = constants_namespaceObject.SCRCPY_PREVIEW_METADATA_TIMEOUT_MS;
|
|
36
|
+
function isScrcpyPreviewStatusEvent(value) {
|
|
37
|
+
return 'object' == typeof value && null !== value && 'message' in value && 'string' == typeof value.message;
|
|
38
|
+
}
|
|
39
|
+
function getDefaultScrcpyWaitingStatusText() {
|
|
40
|
+
return 'Preparing Android device connection…';
|
|
41
|
+
}
|
|
42
|
+
function getScrcpyDecoderStatusText() {
|
|
43
|
+
return 'Starting video decoder…';
|
|
44
|
+
}
|
|
45
|
+
function getScrcpyPreviewStatusText(status, waitingMessage = getDefaultScrcpyWaitingStatusText()) {
|
|
46
|
+
switch(status){
|
|
47
|
+
case 'connected':
|
|
48
|
+
return 'Live scrcpy preview connected';
|
|
49
|
+
case 'waiting-for-stream':
|
|
50
|
+
return waitingMessage;
|
|
51
|
+
case 'error':
|
|
52
|
+
return 'Unable to start scrcpy preview';
|
|
53
|
+
case 'disconnected':
|
|
54
|
+
return 'scrcpy preview disconnected, retrying…';
|
|
55
|
+
default:
|
|
56
|
+
return 'Connecting to scrcpy preview server…';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function getScrcpyMetadataTimeoutMessage(timeoutMs = SCRCPY_METADATA_TIMEOUT_MS) {
|
|
60
|
+
const seconds = Math.max(1, Math.round(timeoutMs / 1000));
|
|
61
|
+
return `Timed out waiting ${seconds}s for scrcpy video stream metadata.`;
|
|
62
|
+
}
|
|
63
|
+
exports.SCRCPY_METADATA_TIMEOUT_MS = __webpack_exports__.SCRCPY_METADATA_TIMEOUT_MS;
|
|
64
|
+
exports.getDefaultScrcpyWaitingStatusText = __webpack_exports__.getDefaultScrcpyWaitingStatusText;
|
|
65
|
+
exports.getScrcpyDecoderStatusText = __webpack_exports__.getScrcpyDecoderStatusText;
|
|
66
|
+
exports.getScrcpyMetadataTimeoutMessage = __webpack_exports__.getScrcpyMetadataTimeoutMessage;
|
|
67
|
+
exports.getScrcpyPreviewStatusText = __webpack_exports__.getScrcpyPreviewStatusText;
|
|
68
|
+
exports.isScrcpyPreviewStatusEvent = __webpack_exports__.isScrcpyPreviewStatusEvent;
|
|
69
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
70
|
+
"SCRCPY_METADATA_TIMEOUT_MS",
|
|
71
|
+
"getDefaultScrcpyWaitingStatusText",
|
|
72
|
+
"getScrcpyDecoderStatusText",
|
|
73
|
+
"getScrcpyMetadataTimeoutMessage",
|
|
74
|
+
"getScrcpyPreviewStatusText",
|
|
75
|
+
"isScrcpyPreviewStatusEvent"
|
|
76
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
createScrcpyVideoStream: ()=>createScrcpyVideoStream
|
|
28
|
+
});
|
|
29
|
+
function createScrcpyVideoStream(socket) {
|
|
30
|
+
let configurationPacketSent = false;
|
|
31
|
+
let pendingDataPackets = [];
|
|
32
|
+
const transformStream = new TransformStream({
|
|
33
|
+
transform (chunk, controller) {
|
|
34
|
+
if ('configuration' === chunk.type) {
|
|
35
|
+
configurationPacketSent = true;
|
|
36
|
+
controller.enqueue(chunk);
|
|
37
|
+
pendingDataPackets.forEach((queuedPacket)=>controller.enqueue(queuedPacket));
|
|
38
|
+
pendingDataPackets = [];
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if ('data' === chunk.type && !configurationPacketSent) return void pendingDataPackets.push(chunk);
|
|
42
|
+
controller.enqueue(chunk);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
let cleanupListeners;
|
|
46
|
+
const readable = new ReadableStream({
|
|
47
|
+
start (controller) {
|
|
48
|
+
const handleVideoData = (data)=>{
|
|
49
|
+
try {
|
|
50
|
+
const payload = new Uint8Array(data.data);
|
|
51
|
+
if ('configuration' === data.type) return void controller.enqueue({
|
|
52
|
+
type: 'configuration',
|
|
53
|
+
data: payload
|
|
54
|
+
});
|
|
55
|
+
controller.enqueue({
|
|
56
|
+
type: 'data',
|
|
57
|
+
data: payload,
|
|
58
|
+
keyframe: data.keyFrame
|
|
59
|
+
});
|
|
60
|
+
} catch (error) {
|
|
61
|
+
controller.error(error);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const handleDisconnect = ()=>controller.close();
|
|
65
|
+
const handleError = (error)=>controller.error(error);
|
|
66
|
+
cleanupListeners = ()=>{
|
|
67
|
+
socket.off('video-data', handleVideoData);
|
|
68
|
+
socket.off('disconnect', handleDisconnect);
|
|
69
|
+
socket.off('error', handleError);
|
|
70
|
+
};
|
|
71
|
+
socket.on('video-data', handleVideoData);
|
|
72
|
+
socket.on('disconnect', handleDisconnect);
|
|
73
|
+
socket.on('error', handleError);
|
|
74
|
+
},
|
|
75
|
+
cancel () {
|
|
76
|
+
null == cleanupListeners || cleanupListeners();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return readable.pipeThrough(transformStream);
|
|
80
|
+
}
|
|
81
|
+
exports.createScrcpyVideoStream = __webpack_exports__.createScrcpyVideoStream;
|
|
82
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
83
|
+
"createScrcpyVideoStream"
|
|
84
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
resolveAutoCreateSessionInput: ()=>resolveAutoCreateSessionInput
|
|
28
|
+
});
|
|
29
|
+
const external_session_state_js_namespaceObject = require("./session-state.js");
|
|
30
|
+
function hasSessionFieldValue(value) {
|
|
31
|
+
return null != value && '' !== value;
|
|
32
|
+
}
|
|
33
|
+
function resolveAutoCreateSessionInput(setup, existingValues = {}) {
|
|
34
|
+
if (!(null == setup ? void 0 : setup.autoSubmitWhenReady)) return null;
|
|
35
|
+
const values = (0, external_session_state_js_namespaceObject.buildSessionInitialValues)(setup, existingValues);
|
|
36
|
+
for (const field of setup.fields)if (field.required) {
|
|
37
|
+
if (!hasSessionFieldValue(values[field.key])) return null;
|
|
38
|
+
}
|
|
39
|
+
return values;
|
|
40
|
+
}
|
|
41
|
+
exports.resolveAutoCreateSessionInput = __webpack_exports__.resolveAutoCreateSessionInput;
|
|
42
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
43
|
+
"resolveAutoCreateSessionInput"
|
|
44
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
45
|
+
Object.defineProperty(exports, '__esModule', {
|
|
46
|
+
value: true
|
|
47
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
buildSessionInitialValues: ()=>buildSessionInitialValues,
|
|
28
|
+
resolveSessionViewState: ()=>resolveSessionViewState
|
|
29
|
+
});
|
|
30
|
+
function resolveSessionViewState(runtimeInfo) {
|
|
31
|
+
const metadata = (null == runtimeInfo ? void 0 : runtimeInfo.metadata) || {};
|
|
32
|
+
const rawSetupState = metadata.setupState;
|
|
33
|
+
const setupState = 'blocked' === rawSetupState || 'ready' === rawSetupState || 'required' === rawSetupState ? rawSetupState : 'ready';
|
|
34
|
+
return {
|
|
35
|
+
connected: Boolean(metadata.sessionConnected),
|
|
36
|
+
displayName: 'string' == typeof metadata.sessionDisplayName ? metadata.sessionDisplayName : void 0,
|
|
37
|
+
setupState,
|
|
38
|
+
setupBlockingReason: 'string' == typeof metadata.setupBlockingReason ? metadata.setupBlockingReason : void 0
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function buildSessionInitialValues(setup, existingValues = {}) {
|
|
42
|
+
if (!setup) return {};
|
|
43
|
+
return Object.fromEntries(setup.fields.map((field)=>[
|
|
44
|
+
field.key,
|
|
45
|
+
resolveSessionFieldValue(field, existingValues[field.key])
|
|
46
|
+
]));
|
|
47
|
+
}
|
|
48
|
+
function hasSessionFieldValue(value) {
|
|
49
|
+
return null != value && '' !== value;
|
|
50
|
+
}
|
|
51
|
+
function resolveSessionFieldValue(field, existingValue) {
|
|
52
|
+
var _ref;
|
|
53
|
+
if (hasSessionFieldValue(existingValue)) return existingValue;
|
|
54
|
+
if ('select' === field.type) {
|
|
55
|
+
var _ref1, _field_defaultValue;
|
|
56
|
+
var _field_options_, _field_options;
|
|
57
|
+
return null != (_ref1 = null != (_field_defaultValue = field.defaultValue) ? _field_defaultValue : null == (_field_options = field.options) ? void 0 : null == (_field_options_ = _field_options[0]) ? void 0 : _field_options_.value) ? _ref1 : '';
|
|
58
|
+
}
|
|
59
|
+
return null != (_ref = null != existingValue ? existingValue : field.defaultValue) ? _ref : '';
|
|
60
|
+
}
|
|
61
|
+
exports.buildSessionInitialValues = __webpack_exports__.buildSessionInitialValues;
|
|
62
|
+
exports.resolveSessionViewState = __webpack_exports__.resolveSessionViewState;
|
|
63
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
64
|
+
"buildSessionInitialValues",
|
|
65
|
+
"resolveSessionViewState"
|
|
66
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
67
|
+
Object.defineProperty(exports, '__esModule', {
|
|
68
|
+
value: true
|
|
69
|
+
});
|
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
useServerStatus: ()=>useServerStatus
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const external_runtime_info_js_namespaceObject = require("./runtime-info.js");
|
|
31
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
32
|
+
try {
|
|
33
|
+
var info = gen[key](arg);
|
|
34
|
+
var value = info.value;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
reject(error);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (info.done) resolve(value);
|
|
40
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
41
|
+
}
|
|
42
|
+
function _async_to_generator(fn) {
|
|
43
|
+
return function() {
|
|
44
|
+
var self = this, args = arguments;
|
|
45
|
+
return new Promise(function(resolve, reject) {
|
|
46
|
+
var gen = fn.apply(self, args);
|
|
47
|
+
function _next(value) {
|
|
48
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
49
|
+
}
|
|
50
|
+
function _throw(err) {
|
|
51
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
52
|
+
}
|
|
53
|
+
_next(void 0);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function useServerStatus(playgroundSDK, defaultDeviceType, pollIntervalMs) {
|
|
58
|
+
const [serverOnline, setServerOnline] = (0, external_react_namespaceObject.useState)(false);
|
|
59
|
+
const [isUserOperating, setIsUserOperating] = (0, external_react_namespaceObject.useState)(false);
|
|
60
|
+
const [deviceType, setDeviceType] = (0, external_react_namespaceObject.useState)(defaultDeviceType);
|
|
61
|
+
const [runtimeInfo, setRuntimeInfo] = (0, external_react_namespaceObject.useState)(null);
|
|
62
|
+
const [executionUxHints, setExecutionUxHints] = (0, external_react_namespaceObject.useState)([]);
|
|
63
|
+
const runtimeInfoRef = (0, external_react_namespaceObject.useRef)(null);
|
|
64
|
+
const mountedRef = (0, external_react_namespaceObject.useRef)(true);
|
|
65
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
66
|
+
mountedRef.current = true;
|
|
67
|
+
return ()=>{
|
|
68
|
+
mountedRef.current = false;
|
|
69
|
+
};
|
|
70
|
+
}, []);
|
|
71
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
72
|
+
runtimeInfoRef.current = runtimeInfo;
|
|
73
|
+
}, [
|
|
74
|
+
runtimeInfo
|
|
75
|
+
]);
|
|
76
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
77
|
+
playgroundSDK.onProgressUpdate((tip)=>{
|
|
78
|
+
setIsUserOperating(Boolean(tip));
|
|
79
|
+
});
|
|
80
|
+
}, [
|
|
81
|
+
playgroundSDK
|
|
82
|
+
]);
|
|
83
|
+
const refreshServerState = (0, external_react_namespaceObject.useCallback)(()=>_async_to_generator(function*() {
|
|
84
|
+
try {
|
|
85
|
+
const online = yield playgroundSDK.checkStatus();
|
|
86
|
+
if (!mountedRef.current) return;
|
|
87
|
+
setServerOnline(online);
|
|
88
|
+
if (!online) {
|
|
89
|
+
runtimeInfoRef.current = null;
|
|
90
|
+
setRuntimeInfo(null);
|
|
91
|
+
setExecutionUxHints([]);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const nextRuntimeInfo = yield playgroundSDK.getRuntimeInfo();
|
|
96
|
+
if (!mountedRef.current) return;
|
|
97
|
+
if (nextRuntimeInfo) {
|
|
98
|
+
runtimeInfoRef.current = nextRuntimeInfo;
|
|
99
|
+
setRuntimeInfo(nextRuntimeInfo);
|
|
100
|
+
setDeviceType((0, external_runtime_info_js_namespaceObject.normalizeRuntimeDeviceType)(nextRuntimeInfo, defaultDeviceType));
|
|
101
|
+
setExecutionUxHints((0, external_runtime_info_js_namespaceObject.filterValidExecutionUxHints)(nextRuntimeInfo));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
console.warn('Failed to get runtime info:', error);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const interfaceInfo = yield playgroundSDK.getInterfaceInfo();
|
|
109
|
+
if (!mountedRef.current || !(null == interfaceInfo ? void 0 : interfaceInfo.type)) return;
|
|
110
|
+
const fallbackRuntimeInfo = (0, external_runtime_info_js_namespaceObject.buildFallbackRuntimeInfo)(runtimeInfoRef.current, interfaceInfo);
|
|
111
|
+
runtimeInfoRef.current = fallbackRuntimeInfo;
|
|
112
|
+
setRuntimeInfo(fallbackRuntimeInfo);
|
|
113
|
+
setDeviceType((0, external_runtime_info_js_namespaceObject.normalizeRuntimeDeviceType)(fallbackRuntimeInfo, defaultDeviceType));
|
|
114
|
+
setExecutionUxHints((0, external_runtime_info_js_namespaceObject.filterValidExecutionUxHints)(fallbackRuntimeInfo));
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.warn('Failed to get interface info:', error);
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
if (!mountedRef.current) return;
|
|
120
|
+
console.error('Failed to check server status:', error);
|
|
121
|
+
setServerOnline(false);
|
|
122
|
+
}
|
|
123
|
+
})(), [
|
|
124
|
+
defaultDeviceType,
|
|
125
|
+
playgroundSDK
|
|
126
|
+
]);
|
|
127
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
128
|
+
refreshServerState();
|
|
129
|
+
const interval = window.setInterval(()=>{
|
|
130
|
+
refreshServerState();
|
|
131
|
+
}, pollIntervalMs);
|
|
132
|
+
return ()=>{
|
|
133
|
+
window.clearInterval(interval);
|
|
134
|
+
};
|
|
135
|
+
}, [
|
|
136
|
+
pollIntervalMs,
|
|
137
|
+
refreshServerState
|
|
138
|
+
]);
|
|
139
|
+
return {
|
|
140
|
+
serverOnline,
|
|
141
|
+
isUserOperating,
|
|
142
|
+
deviceType,
|
|
143
|
+
runtimeInfo,
|
|
144
|
+
executionUxHints,
|
|
145
|
+
refreshServerState
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
exports.useServerStatus = __webpack_exports__.useServerStatus;
|
|
149
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
150
|
+
"useServerStatus"
|
|
151
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
152
|
+
Object.defineProperty(exports, '__esModule', {
|
|
153
|
+
value: true
|
|
154
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { type CSSProperties } from 'react';
|
|
2
|
+
export interface DeviceSize {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
export interface DeviceInteractionLayerProps {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
deviceSize?: DeviceSize | null;
|
|
9
|
+
onTap?: (point: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}) => void;
|
|
13
|
+
onSwipe?: (start: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}, end: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}, duration: number) => void;
|
|
20
|
+
keyboardEnabled?: boolean;
|
|
21
|
+
onTextInput?: (text: string, point?: {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}) => void;
|
|
25
|
+
onKeyboardPress?: (keyName: string, point?: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Tap classification thresholds. Pointer movement below this distance and
|
|
31
|
+
* total duration below this delay is reported as a Tap; anything else is a
|
|
32
|
+
* Swipe.
|
|
33
|
+
*/
|
|
34
|
+
tapMaxDistance?: number;
|
|
35
|
+
tapMaxDurationMs?: number;
|
|
36
|
+
style?: CSSProperties;
|
|
37
|
+
}
|
|
38
|
+
export declare function keyNameForKeyboardEvent(event: Pick<React.KeyboardEvent, 'altKey' | 'ctrlKey' | 'key' | 'metaKey' | 'shiftKey'>): string | null;
|
|
39
|
+
export declare function inscribedContentRect(panel: {
|
|
40
|
+
left: number;
|
|
41
|
+
top: number;
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
}, deviceSize: DeviceSize): {
|
|
45
|
+
left: number;
|
|
46
|
+
top: number;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
};
|
|
50
|
+
export declare function DeviceInteractionLayer({ enabled, deviceSize, onTap, onSwipe, keyboardEnabled, onTextInput, onKeyboardPress, tapMaxDistance, tapMaxDurationMs, style, }: DeviceInteractionLayerProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DeviceType, type PlaygroundBranding, type UniversalPlaygroundConfig } from '@godscene/visualizer';
|
|
2
|
+
import './PlaygroundApp.less';
|
|
3
|
+
export interface PlaygroundAppProps {
|
|
4
|
+
serverUrl: string;
|
|
5
|
+
appVersion: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
defaultDeviceType?: DeviceType;
|
|
8
|
+
branding?: Partial<PlaygroundBranding>;
|
|
9
|
+
playgroundConfig?: Partial<UniversalPlaygroundConfig>;
|
|
10
|
+
offlineTitle?: string;
|
|
11
|
+
offlineStatusText?: string;
|
|
12
|
+
pollIntervalMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function PlaygroundApp({ serverUrl, appVersion, title, defaultDeviceType, branding, playgroundConfig, offlineTitle, offlineStatusText, pollIntervalMs, }: PlaygroundAppProps): import("react").JSX.Element;
|