@stim-cli/server 1.14.0 → 1.15.0
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/README.md +1584 -89
- package/dist/protocol-MBMvJpvV.mjs +2715 -0
- package/dist/protocol.d.mts +2 -496
- package/dist/protocol.mjs +3 -2
- package/dist/protocol.schema.json +5074 -549
- package/dist/scrcpy/LICENSE +204 -0
- package/dist/scrcpy/NOTICE +22 -0
- package/dist/scrcpy/scrcpy-server +0 -0
- package/dist/stats-read.d.mts +1 -0
- package/dist/stats-read.mjs +46 -0
- package/dist/stim-frames/AndroidDeviceStream.swift +284 -0
- package/dist/stim-frames/DevToolsClient.swift +180 -0
- package/dist/stim-frames/DeviceFrameGeometry.swift +41 -0
- package/dist/stim-frames/DeviceFrameView.swift +167 -0
- package/dist/stim-frames/DuoCaptureSource.swift +132 -0
- package/dist/stim-frames/DuoDeviceProfile.swift +37 -0
- package/dist/stim-frames/DuoFrameRenderer.swift +111 -0
- package/dist/stim-frames/DuoHingeMonitor.swift +89 -0
- package/dist/stim-frames/DuoMesh.swift +100 -0
- package/dist/stim-frames/DuoModelView.swift +275 -0
- package/dist/stim-frames/DuoPoseClip.swift +140 -0
- package/dist/stim-frames/DuoScreenHitMesh.swift +200 -0
- package/dist/stim-frames/EmulatorFrameArtwork.swift +113 -0
- package/dist/stim-frames/EmulatorInput.swift +13 -2
- package/dist/stim-frames/EmulatorPosture.swift +2 -2
- package/dist/stim-frames/FrameArtwork.swift +37 -0
- package/dist/stim-frames/H264Decoder.swift +109 -0
- package/dist/stim-frames/InputMessages.swift +27 -6
- package/dist/stim-frames/KeyboardLayoutMap.swift +70 -0
- package/dist/stim-frames/MacosSource.swift +677 -0
- package/dist/stim-frames/OwnedAppWindowReader.swift +87 -0
- package/dist/stim-frames/OwnedAppWindows.swift +108 -0
- package/dist/stim-frames/PhoneSource.swift +315 -0
- package/dist/stim-frames/ProcessStream.swift +155 -0
- package/dist/stim-frames/ScrcpyProtocol.swift +167 -0
- package/dist/stim-frames/SimulatorDevelopmentOptions.swift +81 -0
- package/dist/stim-frames/SimulatorFrameArtwork.swift +118 -0
- package/dist/stim-frames/SimulatorHID.swift +70 -29
- package/dist/stim-frames/SimulatorHingeAngle.swift +56 -0
- package/dist/stim-frames/SimulatorPosture.swift +277 -0
- package/dist/stim-frames/SimulatorRotation.swift +28 -8
- package/dist/stim-frames/Siniulator-LICENSE.txt +21 -0
- package/dist/stim-frames/StoragePaths.swift +42 -0
- package/dist/stim-frames/VideoEncoder.swift +8 -6
- package/dist/stim-frames/WebPage.swift +301 -0
- package/dist/stim-frames/main.swift +651 -22
- package/dist/stim-host/Info.plist +28 -0
- package/dist/stim-host/stim-host.c +153 -0
- package/dist/stim-server-OiJI9xLU.mjs +13336 -0
- package/dist/stim-server.mjs +6 -4421
- package/package.json +3 -3
- package/dist/protocol-IroIg8Td.mjs +0 -865
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>en</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>stim-host</string>
|
|
9
|
+
<key>CFBundleIdentifier</key>
|
|
10
|
+
<string>dev.stim.host</string>
|
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
12
|
+
<string>6.0</string>
|
|
13
|
+
<key>CFBundleName</key>
|
|
14
|
+
<string>Stim Host</string>
|
|
15
|
+
<key>CFBundleDisplayName</key>
|
|
16
|
+
<string>Stim Host</string>
|
|
17
|
+
<key>CFBundlePackageType</key>
|
|
18
|
+
<string>APPL</string>
|
|
19
|
+
<key>CFBundleShortVersionString</key>
|
|
20
|
+
<string>0.1.0</string>
|
|
21
|
+
<key>CFBundleVersion</key>
|
|
22
|
+
<string>1</string>
|
|
23
|
+
<key>LSMinimumSystemVersion</key>
|
|
24
|
+
<string>14.0</string>
|
|
25
|
+
<key>LSUIElement</key>
|
|
26
|
+
<true/>
|
|
27
|
+
</dict>
|
|
28
|
+
</plist>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#include <ApplicationServices/ApplicationServices.h>
|
|
2
|
+
#include <CoreGraphics/CoreGraphics.h>
|
|
3
|
+
#include <errno.h>
|
|
4
|
+
#include <limits.h>
|
|
5
|
+
#include <mach-o/dyld.h>
|
|
6
|
+
#include <signal.h>
|
|
7
|
+
#include <spawn.h>
|
|
8
|
+
#include <stdio.h>
|
|
9
|
+
#include <stdlib.h>
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include <sys/wait.h>
|
|
12
|
+
#include <unistd.h>
|
|
13
|
+
|
|
14
|
+
extern char **environ;
|
|
15
|
+
|
|
16
|
+
#define PROMPT_WAIT_SECONDS 120
|
|
17
|
+
#define PROMPT_POLL_MICROSECONDS 100000
|
|
18
|
+
#define PROMPT_APPEAR_POLLS 100
|
|
19
|
+
|
|
20
|
+
static pid_t child = 0;
|
|
21
|
+
|
|
22
|
+
static void forward(int sig) {
|
|
23
|
+
if (child > 0) kill(child, sig);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static bool control_allowed(void) { return AXIsProcessTrusted() && CGPreflightPostEventAccess(); }
|
|
27
|
+
|
|
28
|
+
static int run(int argc, char **argv) {
|
|
29
|
+
if (argc < 3) {
|
|
30
|
+
fprintf(stderr, "stim-host: run needs a program to start.\n");
|
|
31
|
+
return 64;
|
|
32
|
+
}
|
|
33
|
+
char raw[PATH_MAX], self[PATH_MAX];
|
|
34
|
+
uint32_t size = sizeof raw;
|
|
35
|
+
if (_NSGetExecutablePath(raw, &size) != 0 || !realpath(raw, self)) {
|
|
36
|
+
fprintf(stderr, "stim-host: could not resolve its own path.\n");
|
|
37
|
+
return 70;
|
|
38
|
+
}
|
|
39
|
+
setenv("STIM_HOST_EXECUTABLE", self, 1);
|
|
40
|
+
sigset_t forwarded, empty;
|
|
41
|
+
sigemptyset(&forwarded);
|
|
42
|
+
sigaddset(&forwarded, SIGTERM);
|
|
43
|
+
sigaddset(&forwarded, SIGINT);
|
|
44
|
+
sigaddset(&forwarded, SIGHUP);
|
|
45
|
+
sigemptyset(&empty);
|
|
46
|
+
sigprocmask(SIG_BLOCK, &forwarded, NULL);
|
|
47
|
+
posix_spawnattr_t attributes;
|
|
48
|
+
posix_spawnattr_init(&attributes);
|
|
49
|
+
posix_spawnattr_setsigmask(&attributes, &empty);
|
|
50
|
+
posix_spawnattr_setflags(&attributes, POSIX_SPAWN_SETSIGMASK);
|
|
51
|
+
int error = posix_spawn(&child, argv[2], NULL, &attributes, argv + 2, environ);
|
|
52
|
+
posix_spawnattr_destroy(&attributes);
|
|
53
|
+
if (error) {
|
|
54
|
+
fprintf(stderr, "stim-host: could not start %s: %s\n", argv[2], strerror(error));
|
|
55
|
+
return 127;
|
|
56
|
+
}
|
|
57
|
+
signal(SIGTERM, forward);
|
|
58
|
+
signal(SIGINT, forward);
|
|
59
|
+
signal(SIGHUP, forward);
|
|
60
|
+
sigprocmask(SIG_UNBLOCK, &forwarded, NULL);
|
|
61
|
+
int status;
|
|
62
|
+
while (waitpid(child, &status, 0) < 0) {
|
|
63
|
+
if (errno != EINTR) {
|
|
64
|
+
fprintf(stderr, "stim-host: waitpid failed: %s\n", strerror(errno));
|
|
65
|
+
return 70;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return WIFEXITED(status) ? WEXITSTATUS(status) : 128 + WTERMSIG(status);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static int permissions(void) {
|
|
72
|
+
printf("{\"screenRecording\":%s,\"accessibility\":%s}\n", CGPreflightScreenCaptureAccess() ? "true" : "false",
|
|
73
|
+
control_allowed() ? "true" : "false");
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/* macOS shows one permission dialog at a time; its window belongs to the system process universalAccessAuthWarn. */
|
|
78
|
+
static bool prompt_visible(void) {
|
|
79
|
+
CFArrayRef windows = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
|
|
80
|
+
if (!windows) return false;
|
|
81
|
+
bool found = false;
|
|
82
|
+
for (CFIndex i = 0; !found && i < CFArrayGetCount(windows); i++) {
|
|
83
|
+
CFDictionaryRef window = CFArrayGetValueAtIndex(windows, i);
|
|
84
|
+
CFStringRef owner = CFDictionaryGetValue(window, kCGWindowOwnerName);
|
|
85
|
+
found = owner && CFStringCompare(owner, CFSTR("universalAccessAuthWarn"), 0) == kCFCompareEqualTo;
|
|
86
|
+
}
|
|
87
|
+
CFRelease(windows);
|
|
88
|
+
return found;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static bool wait_for_prompt_to_close(void) {
|
|
92
|
+
for (int i = 0; i < PROMPT_WAIT_SECONDS && prompt_visible(); i++) sleep(1);
|
|
93
|
+
return !prompt_visible();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static bool wait_for_prompt(void) {
|
|
97
|
+
int i = 0;
|
|
98
|
+
while (i < PROMPT_APPEAR_POLLS && !prompt_visible()) {
|
|
99
|
+
usleep(PROMPT_POLL_MICROSECONDS);
|
|
100
|
+
i++;
|
|
101
|
+
}
|
|
102
|
+
if (i == PROMPT_APPEAR_POLLS) return false;
|
|
103
|
+
wait_for_prompt_to_close();
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static void open_control_pane(void) {
|
|
108
|
+
char *args[] = {"open", "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility", NULL};
|
|
109
|
+
pid_t opener;
|
|
110
|
+
int status;
|
|
111
|
+
if (posix_spawn(&opener, "/usr/bin/open", NULL, NULL, args, environ) == 0) waitpid(opener, &status, 0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static int request_permissions(void) {
|
|
115
|
+
if (getppid() != 1) {
|
|
116
|
+
fprintf(stderr, "stim-host: request-permissions must be launched with `open` so macOS asks about this app.\n");
|
|
117
|
+
return 64;
|
|
118
|
+
}
|
|
119
|
+
if (!CGPreflightScreenCaptureAccess()) {
|
|
120
|
+
CGRequestScreenCaptureAccess();
|
|
121
|
+
wait_for_prompt();
|
|
122
|
+
}
|
|
123
|
+
if (control_allowed()) return 0;
|
|
124
|
+
if (!wait_for_prompt_to_close()) {
|
|
125
|
+
open_control_pane();
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
if (!AXIsProcessTrusted()) {
|
|
129
|
+
const void *keys[] = {kAXTrustedCheckOptionPrompt};
|
|
130
|
+
const void *values[] = {kCFBooleanTrue};
|
|
131
|
+
CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, &kCFTypeDictionaryKeyCallBacks,
|
|
132
|
+
&kCFTypeDictionaryValueCallBacks);
|
|
133
|
+
AXIsProcessTrustedWithOptions(options);
|
|
134
|
+
CFRelease(options);
|
|
135
|
+
if (!wait_for_prompt() && !AXIsProcessTrusted()) {
|
|
136
|
+
open_control_pane();
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (AXIsProcessTrusted() && !CGPreflightPostEventAccess()) {
|
|
141
|
+
CGRequestPostEventAccess();
|
|
142
|
+
if (!wait_for_prompt() && !control_allowed()) open_control_pane();
|
|
143
|
+
}
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
int main(int argc, char **argv) {
|
|
148
|
+
if (argc >= 2 && strcmp(argv[1], "run") == 0) return run(argc, argv);
|
|
149
|
+
if (argc == 2 && strcmp(argv[1], "permissions") == 0) return permissions();
|
|
150
|
+
if (argc == 2 && strcmp(argv[1], "request-permissions") == 0) return request_permissions();
|
|
151
|
+
fprintf(stderr, "usage: stim-host run <program> [args...] | permissions | request-permissions\n");
|
|
152
|
+
return 64;
|
|
153
|
+
}
|