@stim-cli/server 1.10.1 → 1.12.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 +247 -27
- package/dist/protocol-BElQc2vm.mjs +808 -0
- package/dist/protocol.d.mts +286 -11
- package/dist/protocol.mjs +2 -2
- package/dist/protocol.schema.json +1004 -148
- package/dist/stim-frames/EmulatorDiscovery.swift +49 -0
- package/dist/stim-frames/EmulatorInput.swift +141 -0
- package/dist/stim-frames/EmulatorPosture.swift +73 -0
- package/dist/stim-frames/EmulatorRotation.swift +59 -0
- package/dist/stim-frames/GrpcFraming.swift +85 -0
- package/dist/stim-frames/InputMessages.swift +123 -0
- package/dist/stim-frames/ScreenshotMessages.swift +152 -0
- package/dist/stim-frames/ScreenshotStream.swift +130 -0
- package/dist/stim-frames/SimulatorDisplay.swift +116 -0
- package/dist/stim-frames/SimulatorHID.swift +336 -0
- package/dist/stim-frames/SimulatorRotation.swift +64 -0
- package/dist/stim-frames/VideoEncoder.swift +282 -0
- package/dist/stim-frames/main.swift +623 -0
- package/dist/stim-frames/sim-fold.entitlements +8 -0
- package/dist/stim-frames/sim-fold.m +47 -0
- package/dist/stim-server.mjs +2135 -208
- package/package.json +4 -4
- package/dist/protocol-B3k9Ykuu.mjs +0 -407
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stim-cli/server",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Serves Stim status to paired
|
|
3
|
+
"version": "1.12.0",
|
|
4
|
+
"description": "Serves Stim status to paired clients over Tailscale, and runs reload and stop for clients granted control.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"./protocol.schema.json": "./dist/protocol.schema.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@stim-cli/core": "^1.
|
|
32
|
-
"stim": "1.
|
|
31
|
+
"@stim-cli/core": "^1.12.0",
|
|
32
|
+
"stim": "1.12.0",
|
|
33
33
|
"ws": "^8.21.3"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
//#region src/protocol.ts
|
|
2
|
-
const PROTOCOL_VERSION = 1;
|
|
3
|
-
const PROTOCOL_SCHEMA_FILE = "protocol.schema.json";
|
|
4
|
-
const CAPABILITIES = ["read"];
|
|
5
|
-
const METHODS = [
|
|
6
|
-
"hello",
|
|
7
|
-
"status.subscribe",
|
|
8
|
-
"logs.query",
|
|
9
|
-
"logs.subscribe",
|
|
10
|
-
"stats.get",
|
|
11
|
-
"settings.get",
|
|
12
|
-
"frames.subscribe",
|
|
13
|
-
"unsubscribe"
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* `unauthorized`, `pairing-expired` and `protocol-unsupported` refuse the client until it pairs again or
|
|
17
|
-
* updates; clients retry the others.
|
|
18
|
-
*/
|
|
19
|
-
const ERROR_CODES = [
|
|
20
|
-
"unauthorized",
|
|
21
|
-
"pairing-expired",
|
|
22
|
-
"protocol-unsupported",
|
|
23
|
-
"identity-unavailable",
|
|
24
|
-
"bad-request",
|
|
25
|
-
"unknown-method",
|
|
26
|
-
"already-authenticated",
|
|
27
|
-
"unknown-subscription",
|
|
28
|
-
"unknown-workspace",
|
|
29
|
-
"limit-exceeded",
|
|
30
|
-
"slow-client",
|
|
31
|
-
"status-failed",
|
|
32
|
-
"logs-failed",
|
|
33
|
-
"stim-failed",
|
|
34
|
-
"frames-failed"
|
|
35
|
-
];
|
|
36
|
-
const LOG_SOURCES = [
|
|
37
|
-
"metro",
|
|
38
|
-
"client",
|
|
39
|
-
"device",
|
|
40
|
-
"build"
|
|
41
|
-
];
|
|
42
|
-
const LOG_LEVELS = [
|
|
43
|
-
"debug",
|
|
44
|
-
"info",
|
|
45
|
-
"warn",
|
|
46
|
-
"error",
|
|
47
|
-
"fatal"
|
|
48
|
-
];
|
|
49
|
-
const MAX_LOG_TAIL = 5e3;
|
|
50
|
-
const requestId = { type: ["integer", "string"] };
|
|
51
|
-
const protocolError = {
|
|
52
|
-
type: "object",
|
|
53
|
-
required: ["code", "message"],
|
|
54
|
-
additionalProperties: false,
|
|
55
|
-
properties: {
|
|
56
|
-
code: { enum: [...ERROR_CODES] },
|
|
57
|
-
message: { type: "string" }
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
function request(method, params) {
|
|
61
|
-
return {
|
|
62
|
-
type: "object",
|
|
63
|
-
required: params ? [
|
|
64
|
-
"id",
|
|
65
|
-
"method",
|
|
66
|
-
"params"
|
|
67
|
-
] : ["id", "method"],
|
|
68
|
-
additionalProperties: false,
|
|
69
|
-
properties: {
|
|
70
|
-
id: requestId,
|
|
71
|
-
method: { const: method },
|
|
72
|
-
params: params ?? {
|
|
73
|
-
type: "object",
|
|
74
|
-
maxProperties: 0
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function optionalParams(method, params) {
|
|
80
|
-
return {
|
|
81
|
-
type: "object",
|
|
82
|
-
required: ["id", "method"],
|
|
83
|
-
additionalProperties: false,
|
|
84
|
-
properties: {
|
|
85
|
-
id: requestId,
|
|
86
|
-
method: { const: method },
|
|
87
|
-
params
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
/** The JSON Schema of every message on the wire, written to `dist/protocol.schema.json` at build time. */
|
|
92
|
-
function protocolJsonSchema() {
|
|
93
|
-
return {
|
|
94
|
-
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
95
|
-
title: "Stim server protocol",
|
|
96
|
-
description: `Messages exchanged over the stim-server WebSocket, protocol version 1.`,
|
|
97
|
-
"x-stim-protocol": 1,
|
|
98
|
-
$defs: {
|
|
99
|
-
ProtocolError: protocolError,
|
|
100
|
-
HelloParams: {
|
|
101
|
-
type: "object",
|
|
102
|
-
required: [
|
|
103
|
-
"protocol",
|
|
104
|
-
"client",
|
|
105
|
-
"auth"
|
|
106
|
-
],
|
|
107
|
-
additionalProperties: false,
|
|
108
|
-
properties: {
|
|
109
|
-
protocol: { type: "integer" },
|
|
110
|
-
client: {
|
|
111
|
-
type: "object",
|
|
112
|
-
required: ["name", "version"],
|
|
113
|
-
properties: {
|
|
114
|
-
name: { type: "string" },
|
|
115
|
-
version: { type: "string" }
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
auth: { oneOf: [{
|
|
119
|
-
type: "object",
|
|
120
|
-
required: ["pairingToken", "deviceName"],
|
|
121
|
-
additionalProperties: false,
|
|
122
|
-
properties: {
|
|
123
|
-
pairingToken: { type: "string" },
|
|
124
|
-
deviceName: {
|
|
125
|
-
type: "string",
|
|
126
|
-
minLength: 1
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
type: "object",
|
|
131
|
-
required: ["deviceToken"],
|
|
132
|
-
additionalProperties: false,
|
|
133
|
-
properties: { deviceToken: { type: "string" } }
|
|
134
|
-
}] }
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
HelloResult: {
|
|
138
|
-
type: "object",
|
|
139
|
-
required: [
|
|
140
|
-
"protocol",
|
|
141
|
-
"server",
|
|
142
|
-
"capabilities",
|
|
143
|
-
"device"
|
|
144
|
-
],
|
|
145
|
-
additionalProperties: false,
|
|
146
|
-
properties: {
|
|
147
|
-
protocol: { type: "integer" },
|
|
148
|
-
server: {
|
|
149
|
-
type: "object",
|
|
150
|
-
required: [
|
|
151
|
-
"name",
|
|
152
|
-
"version",
|
|
153
|
-
"stim"
|
|
154
|
-
],
|
|
155
|
-
additionalProperties: false,
|
|
156
|
-
properties: {
|
|
157
|
-
name: { type: "string" },
|
|
158
|
-
version: { type: "string" },
|
|
159
|
-
stim: { type: "string" }
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
capabilities: {
|
|
163
|
-
type: "array",
|
|
164
|
-
items: { enum: [...CAPABILITIES] }
|
|
165
|
-
},
|
|
166
|
-
device: {
|
|
167
|
-
type: "object",
|
|
168
|
-
required: ["id", "name"],
|
|
169
|
-
additionalProperties: false,
|
|
170
|
-
properties: {
|
|
171
|
-
id: { type: "string" },
|
|
172
|
-
name: { type: "string" }
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
deviceToken: { type: "string" }
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
LogRecord: {
|
|
179
|
-
type: "object",
|
|
180
|
-
description: "One record as `stim logs --json` prints it.",
|
|
181
|
-
properties: {
|
|
182
|
-
ts: { type: "number" },
|
|
183
|
-
src: { type: "string" },
|
|
184
|
-
level: { type: "string" },
|
|
185
|
-
msg: { type: "string" }
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
LogFilter: {
|
|
189
|
-
type: "object",
|
|
190
|
-
required: ["workspace"],
|
|
191
|
-
additionalProperties: false,
|
|
192
|
-
properties: {
|
|
193
|
-
workspace: {
|
|
194
|
-
type: "string",
|
|
195
|
-
description: "An environment path from a status payload."
|
|
196
|
-
},
|
|
197
|
-
sources: {
|
|
198
|
-
type: "array",
|
|
199
|
-
minItems: 1,
|
|
200
|
-
items: { enum: [...LOG_SOURCES] }
|
|
201
|
-
},
|
|
202
|
-
level: { enum: [...LOG_LEVELS] },
|
|
203
|
-
slot: {
|
|
204
|
-
type: "string",
|
|
205
|
-
minLength: 1
|
|
206
|
-
},
|
|
207
|
-
grep: {
|
|
208
|
-
type: "string",
|
|
209
|
-
description: "A regular expression matched against each message."
|
|
210
|
-
},
|
|
211
|
-
errors: { type: "boolean" },
|
|
212
|
-
tail: {
|
|
213
|
-
type: "integer",
|
|
214
|
-
minimum: 1,
|
|
215
|
-
maximum: MAX_LOG_TAIL,
|
|
216
|
-
default: MAX_LOG_TAIL
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
FrameTarget: {
|
|
221
|
-
type: "object",
|
|
222
|
-
required: ["workspace", "platform"],
|
|
223
|
-
additionalProperties: false,
|
|
224
|
-
properties: {
|
|
225
|
-
workspace: {
|
|
226
|
-
type: "string",
|
|
227
|
-
description: "An environment path from a status payload."
|
|
228
|
-
},
|
|
229
|
-
platform: { enum: ["ios", "android"] },
|
|
230
|
-
slot: {
|
|
231
|
-
type: "string",
|
|
232
|
-
minLength: 1,
|
|
233
|
-
default: "default"
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
WorkspaceParams: {
|
|
238
|
-
type: "object",
|
|
239
|
-
additionalProperties: false,
|
|
240
|
-
properties: { workspace: {
|
|
241
|
-
type: "string",
|
|
242
|
-
description: "An environment path from a status payload."
|
|
243
|
-
} }
|
|
244
|
-
},
|
|
245
|
-
ClientRequest: { oneOf: [
|
|
246
|
-
request("hello", { $ref: "#/$defs/HelloParams" }),
|
|
247
|
-
request("status.subscribe"),
|
|
248
|
-
request("logs.query", { $ref: "#/$defs/LogFilter" }),
|
|
249
|
-
request("logs.subscribe", { $ref: "#/$defs/LogFilter" }),
|
|
250
|
-
request("frames.subscribe", { $ref: "#/$defs/FrameTarget" }),
|
|
251
|
-
optionalParams("stats.get", { $ref: "#/$defs/WorkspaceParams" }),
|
|
252
|
-
optionalParams("settings.get", { $ref: "#/$defs/WorkspaceParams" }),
|
|
253
|
-
request("unsubscribe", {
|
|
254
|
-
type: "object",
|
|
255
|
-
required: ["subscription"],
|
|
256
|
-
additionalProperties: false,
|
|
257
|
-
properties: { subscription: { type: "string" } }
|
|
258
|
-
})
|
|
259
|
-
] },
|
|
260
|
-
ServerResponse: { oneOf: [{
|
|
261
|
-
type: "object",
|
|
262
|
-
required: ["id", "result"],
|
|
263
|
-
additionalProperties: false,
|
|
264
|
-
properties: {
|
|
265
|
-
id: requestId,
|
|
266
|
-
result: { anyOf: [
|
|
267
|
-
{ $ref: "#/$defs/HelloResult" },
|
|
268
|
-
{
|
|
269
|
-
type: "object",
|
|
270
|
-
required: ["subscription"],
|
|
271
|
-
additionalProperties: false,
|
|
272
|
-
properties: { subscription: { type: "string" } }
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
type: "object",
|
|
276
|
-
required: ["records"],
|
|
277
|
-
additionalProperties: false,
|
|
278
|
-
properties: { records: {
|
|
279
|
-
type: "array",
|
|
280
|
-
items: { $ref: "#/$defs/LogRecord" }
|
|
281
|
-
} }
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
type: "object",
|
|
285
|
-
description: "The payload of `stim stats --json` or `stim settings --json`, or {} for unsubscribe."
|
|
286
|
-
}
|
|
287
|
-
] }
|
|
288
|
-
}
|
|
289
|
-
}, {
|
|
290
|
-
type: "object",
|
|
291
|
-
required: ["id", "error"],
|
|
292
|
-
additionalProperties: false,
|
|
293
|
-
properties: {
|
|
294
|
-
id: { type: [
|
|
295
|
-
"integer",
|
|
296
|
-
"string",
|
|
297
|
-
"null"
|
|
298
|
-
] },
|
|
299
|
-
error: { $ref: "#/$defs/ProtocolError" }
|
|
300
|
-
}
|
|
301
|
-
}] },
|
|
302
|
-
ServerEvent: { oneOf: [
|
|
303
|
-
{
|
|
304
|
-
type: "object",
|
|
305
|
-
required: [
|
|
306
|
-
"event",
|
|
307
|
-
"subscription",
|
|
308
|
-
"payload"
|
|
309
|
-
],
|
|
310
|
-
additionalProperties: false,
|
|
311
|
-
properties: {
|
|
312
|
-
event: { const: "status" },
|
|
313
|
-
subscription: { type: "string" },
|
|
314
|
-
payload: {
|
|
315
|
-
type: "object",
|
|
316
|
-
description: "A full payload, as `stim status --watch --json` prints it."
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
type: "object",
|
|
322
|
-
required: [
|
|
323
|
-
"event",
|
|
324
|
-
"subscription",
|
|
325
|
-
"records"
|
|
326
|
-
],
|
|
327
|
-
additionalProperties: false,
|
|
328
|
-
properties: {
|
|
329
|
-
event: { const: "logs" },
|
|
330
|
-
subscription: { type: "string" },
|
|
331
|
-
records: {
|
|
332
|
-
type: "array",
|
|
333
|
-
items: { $ref: "#/$defs/LogRecord" }
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
type: "object",
|
|
339
|
-
required: [
|
|
340
|
-
"event",
|
|
341
|
-
"subscription",
|
|
342
|
-
"platform",
|
|
343
|
-
"slot",
|
|
344
|
-
"mime",
|
|
345
|
-
"width",
|
|
346
|
-
"height",
|
|
347
|
-
"capturedAt",
|
|
348
|
-
"data"
|
|
349
|
-
],
|
|
350
|
-
additionalProperties: false,
|
|
351
|
-
properties: {
|
|
352
|
-
event: { const: "frame" },
|
|
353
|
-
subscription: { type: "string" },
|
|
354
|
-
platform: { enum: ["ios", "android"] },
|
|
355
|
-
slot: { type: "string" },
|
|
356
|
-
mime: { const: "image/jpeg" },
|
|
357
|
-
width: { type: "integer" },
|
|
358
|
-
height: { type: "integer" },
|
|
359
|
-
capturedAt: {
|
|
360
|
-
type: "string",
|
|
361
|
-
format: "date-time"
|
|
362
|
-
},
|
|
363
|
-
data: {
|
|
364
|
-
type: "string",
|
|
365
|
-
contentEncoding: "base64"
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
type: "object",
|
|
371
|
-
required: [
|
|
372
|
-
"event",
|
|
373
|
-
"subscription",
|
|
374
|
-
"delayed"
|
|
375
|
-
],
|
|
376
|
-
additionalProperties: false,
|
|
377
|
-
properties: {
|
|
378
|
-
event: { const: "frame-delayed" },
|
|
379
|
-
subscription: { type: "string" },
|
|
380
|
-
delayed: { type: "boolean" }
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
type: "object",
|
|
385
|
-
required: [
|
|
386
|
-
"event",
|
|
387
|
-
"subscription",
|
|
388
|
-
"error"
|
|
389
|
-
],
|
|
390
|
-
additionalProperties: false,
|
|
391
|
-
properties: {
|
|
392
|
-
event: { const: "error" },
|
|
393
|
-
subscription: { type: "string" },
|
|
394
|
-
error: { $ref: "#/$defs/ProtocolError" }
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
] }
|
|
398
|
-
},
|
|
399
|
-
oneOf: [
|
|
400
|
-
{ $ref: "#/$defs/ClientRequest" },
|
|
401
|
-
{ $ref: "#/$defs/ServerResponse" },
|
|
402
|
-
{ $ref: "#/$defs/ServerEvent" }
|
|
403
|
-
]
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
//#endregion
|
|
407
|
-
export { MAX_LOG_TAIL as a, PROTOCOL_VERSION as c, LOG_SOURCES as i, protocolJsonSchema as l, ERROR_CODES as n, METHODS as o, LOG_LEVELS as r, PROTOCOL_SCHEMA_FILE as s, CAPABILITIES as t };
|