@mcesystems/apple-kit 1.0.8 → 1.0.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/dist/index.js +1082 -39
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +1112 -42
- package/dist/index.mjs.map +4 -4
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic/actions/proxy.d.ts +21 -2
- package/dist/types/logic/actions/proxy.d.ts.map +1 -1
- package/dist/types/logic/appleDeviceKit.d.ts +63 -9
- package/dist/types/logic/appleDeviceKit.d.ts.map +1 -1
- package/dist/types/types.d.ts +0 -4
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/portManager.d.ts +68 -0
- package/dist/types/utils/portManager.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,804 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js
|
|
34
|
+
var require_ms = __commonJS({
|
|
35
|
+
"../../node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js"(exports, module) {
|
|
36
|
+
var s = 1e3;
|
|
37
|
+
var m = s * 60;
|
|
38
|
+
var h = m * 60;
|
|
39
|
+
var d = h * 24;
|
|
40
|
+
var w = d * 7;
|
|
41
|
+
var y = d * 365.25;
|
|
42
|
+
module.exports = function(val, options) {
|
|
43
|
+
options = options || {};
|
|
44
|
+
var type = typeof val;
|
|
45
|
+
if (type === "string" && val.length > 0) {
|
|
46
|
+
return parse(val);
|
|
47
|
+
} else if (type === "number" && isFinite(val)) {
|
|
48
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(
|
|
51
|
+
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
function parse(str) {
|
|
55
|
+
str = String(str);
|
|
56
|
+
if (str.length > 100) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
60
|
+
str
|
|
61
|
+
);
|
|
62
|
+
if (!match) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
var n = parseFloat(match[1]);
|
|
66
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
67
|
+
switch (type) {
|
|
68
|
+
case "years":
|
|
69
|
+
case "year":
|
|
70
|
+
case "yrs":
|
|
71
|
+
case "yr":
|
|
72
|
+
case "y":
|
|
73
|
+
return n * y;
|
|
74
|
+
case "weeks":
|
|
75
|
+
case "week":
|
|
76
|
+
case "w":
|
|
77
|
+
return n * w;
|
|
78
|
+
case "days":
|
|
79
|
+
case "day":
|
|
80
|
+
case "d":
|
|
81
|
+
return n * d;
|
|
82
|
+
case "hours":
|
|
83
|
+
case "hour":
|
|
84
|
+
case "hrs":
|
|
85
|
+
case "hr":
|
|
86
|
+
case "h":
|
|
87
|
+
return n * h;
|
|
88
|
+
case "minutes":
|
|
89
|
+
case "minute":
|
|
90
|
+
case "mins":
|
|
91
|
+
case "min":
|
|
92
|
+
case "m":
|
|
93
|
+
return n * m;
|
|
94
|
+
case "seconds":
|
|
95
|
+
case "second":
|
|
96
|
+
case "secs":
|
|
97
|
+
case "sec":
|
|
98
|
+
case "s":
|
|
99
|
+
return n * s;
|
|
100
|
+
case "milliseconds":
|
|
101
|
+
case "millisecond":
|
|
102
|
+
case "msecs":
|
|
103
|
+
case "msec":
|
|
104
|
+
case "ms":
|
|
105
|
+
return n;
|
|
106
|
+
default:
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function fmtShort(ms) {
|
|
111
|
+
var msAbs = Math.abs(ms);
|
|
112
|
+
if (msAbs >= d) {
|
|
113
|
+
return Math.round(ms / d) + "d";
|
|
114
|
+
}
|
|
115
|
+
if (msAbs >= h) {
|
|
116
|
+
return Math.round(ms / h) + "h";
|
|
117
|
+
}
|
|
118
|
+
if (msAbs >= m) {
|
|
119
|
+
return Math.round(ms / m) + "m";
|
|
120
|
+
}
|
|
121
|
+
if (msAbs >= s) {
|
|
122
|
+
return Math.round(ms / s) + "s";
|
|
123
|
+
}
|
|
124
|
+
return ms + "ms";
|
|
125
|
+
}
|
|
126
|
+
function fmtLong(ms) {
|
|
127
|
+
var msAbs = Math.abs(ms);
|
|
128
|
+
if (msAbs >= d) {
|
|
129
|
+
return plural(ms, msAbs, d, "day");
|
|
130
|
+
}
|
|
131
|
+
if (msAbs >= h) {
|
|
132
|
+
return plural(ms, msAbs, h, "hour");
|
|
133
|
+
}
|
|
134
|
+
if (msAbs >= m) {
|
|
135
|
+
return plural(ms, msAbs, m, "minute");
|
|
136
|
+
}
|
|
137
|
+
if (msAbs >= s) {
|
|
138
|
+
return plural(ms, msAbs, s, "second");
|
|
139
|
+
}
|
|
140
|
+
return ms + " ms";
|
|
141
|
+
}
|
|
142
|
+
function plural(ms, msAbs, n, name) {
|
|
143
|
+
var isPlural = msAbs >= n * 1.5;
|
|
144
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js
|
|
150
|
+
var require_common = __commonJS({
|
|
151
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/common.js"(exports, module) {
|
|
152
|
+
function setup(env) {
|
|
153
|
+
createDebug2.debug = createDebug2;
|
|
154
|
+
createDebug2.default = createDebug2;
|
|
155
|
+
createDebug2.coerce = coerce;
|
|
156
|
+
createDebug2.disable = disable;
|
|
157
|
+
createDebug2.enable = enable;
|
|
158
|
+
createDebug2.enabled = enabled;
|
|
159
|
+
createDebug2.humanize = require_ms();
|
|
160
|
+
createDebug2.destroy = destroy;
|
|
161
|
+
Object.keys(env).forEach((key) => {
|
|
162
|
+
createDebug2[key] = env[key];
|
|
163
|
+
});
|
|
164
|
+
createDebug2.names = [];
|
|
165
|
+
createDebug2.skips = [];
|
|
166
|
+
createDebug2.formatters = {};
|
|
167
|
+
function selectColor(namespace) {
|
|
168
|
+
let hash = 0;
|
|
169
|
+
for (let i = 0; i < namespace.length; i++) {
|
|
170
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
171
|
+
hash |= 0;
|
|
172
|
+
}
|
|
173
|
+
return createDebug2.colors[Math.abs(hash) % createDebug2.colors.length];
|
|
174
|
+
}
|
|
175
|
+
createDebug2.selectColor = selectColor;
|
|
176
|
+
function createDebug2(namespace) {
|
|
177
|
+
let prevTime;
|
|
178
|
+
let enableOverride = null;
|
|
179
|
+
let namespacesCache;
|
|
180
|
+
let enabledCache;
|
|
181
|
+
function debug2(...args) {
|
|
182
|
+
if (!debug2.enabled) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const self = debug2;
|
|
186
|
+
const curr = Number(/* @__PURE__ */ new Date());
|
|
187
|
+
const ms = curr - (prevTime || curr);
|
|
188
|
+
self.diff = ms;
|
|
189
|
+
self.prev = prevTime;
|
|
190
|
+
self.curr = curr;
|
|
191
|
+
prevTime = curr;
|
|
192
|
+
args[0] = createDebug2.coerce(args[0]);
|
|
193
|
+
if (typeof args[0] !== "string") {
|
|
194
|
+
args.unshift("%O");
|
|
195
|
+
}
|
|
196
|
+
let index = 0;
|
|
197
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
198
|
+
if (match === "%%") {
|
|
199
|
+
return "%";
|
|
200
|
+
}
|
|
201
|
+
index++;
|
|
202
|
+
const formatter = createDebug2.formatters[format];
|
|
203
|
+
if (typeof formatter === "function") {
|
|
204
|
+
const val = args[index];
|
|
205
|
+
match = formatter.call(self, val);
|
|
206
|
+
args.splice(index, 1);
|
|
207
|
+
index--;
|
|
208
|
+
}
|
|
209
|
+
return match;
|
|
210
|
+
});
|
|
211
|
+
createDebug2.formatArgs.call(self, args);
|
|
212
|
+
const logFn = self.log || createDebug2.log;
|
|
213
|
+
logFn.apply(self, args);
|
|
214
|
+
}
|
|
215
|
+
debug2.namespace = namespace;
|
|
216
|
+
debug2.useColors = createDebug2.useColors();
|
|
217
|
+
debug2.color = createDebug2.selectColor(namespace);
|
|
218
|
+
debug2.extend = extend;
|
|
219
|
+
debug2.destroy = createDebug2.destroy;
|
|
220
|
+
Object.defineProperty(debug2, "enabled", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
configurable: false,
|
|
223
|
+
get: () => {
|
|
224
|
+
if (enableOverride !== null) {
|
|
225
|
+
return enableOverride;
|
|
226
|
+
}
|
|
227
|
+
if (namespacesCache !== createDebug2.namespaces) {
|
|
228
|
+
namespacesCache = createDebug2.namespaces;
|
|
229
|
+
enabledCache = createDebug2.enabled(namespace);
|
|
230
|
+
}
|
|
231
|
+
return enabledCache;
|
|
232
|
+
},
|
|
233
|
+
set: (v) => {
|
|
234
|
+
enableOverride = v;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
if (typeof createDebug2.init === "function") {
|
|
238
|
+
createDebug2.init(debug2);
|
|
239
|
+
}
|
|
240
|
+
return debug2;
|
|
241
|
+
}
|
|
242
|
+
function extend(namespace, delimiter) {
|
|
243
|
+
const newDebug = createDebug2(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
244
|
+
newDebug.log = this.log;
|
|
245
|
+
return newDebug;
|
|
246
|
+
}
|
|
247
|
+
function enable(namespaces) {
|
|
248
|
+
createDebug2.save(namespaces);
|
|
249
|
+
createDebug2.namespaces = namespaces;
|
|
250
|
+
createDebug2.names = [];
|
|
251
|
+
createDebug2.skips = [];
|
|
252
|
+
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
253
|
+
for (const ns of split) {
|
|
254
|
+
if (ns[0] === "-") {
|
|
255
|
+
createDebug2.skips.push(ns.slice(1));
|
|
256
|
+
} else {
|
|
257
|
+
createDebug2.names.push(ns);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function matchesTemplate(search, template) {
|
|
262
|
+
let searchIndex = 0;
|
|
263
|
+
let templateIndex = 0;
|
|
264
|
+
let starIndex = -1;
|
|
265
|
+
let matchIndex = 0;
|
|
266
|
+
while (searchIndex < search.length) {
|
|
267
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
268
|
+
if (template[templateIndex] === "*") {
|
|
269
|
+
starIndex = templateIndex;
|
|
270
|
+
matchIndex = searchIndex;
|
|
271
|
+
templateIndex++;
|
|
272
|
+
} else {
|
|
273
|
+
searchIndex++;
|
|
274
|
+
templateIndex++;
|
|
275
|
+
}
|
|
276
|
+
} else if (starIndex !== -1) {
|
|
277
|
+
templateIndex = starIndex + 1;
|
|
278
|
+
matchIndex++;
|
|
279
|
+
searchIndex = matchIndex;
|
|
280
|
+
} else {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
285
|
+
templateIndex++;
|
|
286
|
+
}
|
|
287
|
+
return templateIndex === template.length;
|
|
288
|
+
}
|
|
289
|
+
function disable() {
|
|
290
|
+
const namespaces = [
|
|
291
|
+
...createDebug2.names,
|
|
292
|
+
...createDebug2.skips.map((namespace) => "-" + namespace)
|
|
293
|
+
].join(",");
|
|
294
|
+
createDebug2.enable("");
|
|
295
|
+
return namespaces;
|
|
296
|
+
}
|
|
297
|
+
function enabled(name) {
|
|
298
|
+
for (const skip of createDebug2.skips) {
|
|
299
|
+
if (matchesTemplate(name, skip)) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
for (const ns of createDebug2.names) {
|
|
304
|
+
if (matchesTemplate(name, ns)) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
function coerce(val) {
|
|
311
|
+
if (val instanceof Error) {
|
|
312
|
+
return val.stack || val.message;
|
|
313
|
+
}
|
|
314
|
+
return val;
|
|
315
|
+
}
|
|
316
|
+
function destroy() {
|
|
317
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
318
|
+
}
|
|
319
|
+
createDebug2.enable(createDebug2.load());
|
|
320
|
+
return createDebug2;
|
|
321
|
+
}
|
|
322
|
+
module.exports = setup;
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js
|
|
327
|
+
var require_browser = __commonJS({
|
|
328
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js"(exports, module) {
|
|
329
|
+
exports.formatArgs = formatArgs;
|
|
330
|
+
exports.save = save;
|
|
331
|
+
exports.load = load;
|
|
332
|
+
exports.useColors = useColors;
|
|
333
|
+
exports.storage = localstorage();
|
|
334
|
+
exports.destroy = /* @__PURE__ */ (() => {
|
|
335
|
+
let warned = false;
|
|
336
|
+
return () => {
|
|
337
|
+
if (!warned) {
|
|
338
|
+
warned = true;
|
|
339
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
})();
|
|
343
|
+
exports.colors = [
|
|
344
|
+
"#0000CC",
|
|
345
|
+
"#0000FF",
|
|
346
|
+
"#0033CC",
|
|
347
|
+
"#0033FF",
|
|
348
|
+
"#0066CC",
|
|
349
|
+
"#0066FF",
|
|
350
|
+
"#0099CC",
|
|
351
|
+
"#0099FF",
|
|
352
|
+
"#00CC00",
|
|
353
|
+
"#00CC33",
|
|
354
|
+
"#00CC66",
|
|
355
|
+
"#00CC99",
|
|
356
|
+
"#00CCCC",
|
|
357
|
+
"#00CCFF",
|
|
358
|
+
"#3300CC",
|
|
359
|
+
"#3300FF",
|
|
360
|
+
"#3333CC",
|
|
361
|
+
"#3333FF",
|
|
362
|
+
"#3366CC",
|
|
363
|
+
"#3366FF",
|
|
364
|
+
"#3399CC",
|
|
365
|
+
"#3399FF",
|
|
366
|
+
"#33CC00",
|
|
367
|
+
"#33CC33",
|
|
368
|
+
"#33CC66",
|
|
369
|
+
"#33CC99",
|
|
370
|
+
"#33CCCC",
|
|
371
|
+
"#33CCFF",
|
|
372
|
+
"#6600CC",
|
|
373
|
+
"#6600FF",
|
|
374
|
+
"#6633CC",
|
|
375
|
+
"#6633FF",
|
|
376
|
+
"#66CC00",
|
|
377
|
+
"#66CC33",
|
|
378
|
+
"#9900CC",
|
|
379
|
+
"#9900FF",
|
|
380
|
+
"#9933CC",
|
|
381
|
+
"#9933FF",
|
|
382
|
+
"#99CC00",
|
|
383
|
+
"#99CC33",
|
|
384
|
+
"#CC0000",
|
|
385
|
+
"#CC0033",
|
|
386
|
+
"#CC0066",
|
|
387
|
+
"#CC0099",
|
|
388
|
+
"#CC00CC",
|
|
389
|
+
"#CC00FF",
|
|
390
|
+
"#CC3300",
|
|
391
|
+
"#CC3333",
|
|
392
|
+
"#CC3366",
|
|
393
|
+
"#CC3399",
|
|
394
|
+
"#CC33CC",
|
|
395
|
+
"#CC33FF",
|
|
396
|
+
"#CC6600",
|
|
397
|
+
"#CC6633",
|
|
398
|
+
"#CC9900",
|
|
399
|
+
"#CC9933",
|
|
400
|
+
"#CCCC00",
|
|
401
|
+
"#CCCC33",
|
|
402
|
+
"#FF0000",
|
|
403
|
+
"#FF0033",
|
|
404
|
+
"#FF0066",
|
|
405
|
+
"#FF0099",
|
|
406
|
+
"#FF00CC",
|
|
407
|
+
"#FF00FF",
|
|
408
|
+
"#FF3300",
|
|
409
|
+
"#FF3333",
|
|
410
|
+
"#FF3366",
|
|
411
|
+
"#FF3399",
|
|
412
|
+
"#FF33CC",
|
|
413
|
+
"#FF33FF",
|
|
414
|
+
"#FF6600",
|
|
415
|
+
"#FF6633",
|
|
416
|
+
"#FF9900",
|
|
417
|
+
"#FF9933",
|
|
418
|
+
"#FFCC00",
|
|
419
|
+
"#FFCC33"
|
|
420
|
+
];
|
|
421
|
+
function useColors() {
|
|
422
|
+
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
let m;
|
|
429
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
|
430
|
+
typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
|
431
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
432
|
+
typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
|
433
|
+
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
434
|
+
}
|
|
435
|
+
function formatArgs(args) {
|
|
436
|
+
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
437
|
+
if (!this.useColors) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const c = "color: " + this.color;
|
|
441
|
+
args.splice(1, 0, c, "color: inherit");
|
|
442
|
+
let index = 0;
|
|
443
|
+
let lastC = 0;
|
|
444
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
445
|
+
if (match === "%%") {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
index++;
|
|
449
|
+
if (match === "%c") {
|
|
450
|
+
lastC = index;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
args.splice(lastC, 0, c);
|
|
454
|
+
}
|
|
455
|
+
exports.log = console.debug || console.log || (() => {
|
|
456
|
+
});
|
|
457
|
+
function save(namespaces) {
|
|
458
|
+
try {
|
|
459
|
+
if (namespaces) {
|
|
460
|
+
exports.storage.setItem("debug", namespaces);
|
|
461
|
+
} else {
|
|
462
|
+
exports.storage.removeItem("debug");
|
|
463
|
+
}
|
|
464
|
+
} catch (error) {
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
function load() {
|
|
468
|
+
let r;
|
|
469
|
+
try {
|
|
470
|
+
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
471
|
+
} catch (error) {
|
|
472
|
+
}
|
|
473
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
474
|
+
r = process.env.DEBUG;
|
|
475
|
+
}
|
|
476
|
+
return r;
|
|
477
|
+
}
|
|
478
|
+
function localstorage() {
|
|
479
|
+
try {
|
|
480
|
+
return localStorage;
|
|
481
|
+
} catch (error) {
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
module.exports = require_common()(exports);
|
|
485
|
+
var { formatters } = module.exports;
|
|
486
|
+
formatters.j = function(v) {
|
|
487
|
+
try {
|
|
488
|
+
return JSON.stringify(v);
|
|
489
|
+
} catch (error) {
|
|
490
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
// ../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js
|
|
497
|
+
var require_has_flag = __commonJS({
|
|
498
|
+
"../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js"(exports, module) {
|
|
499
|
+
"use strict";
|
|
500
|
+
module.exports = (flag, argv = process.argv) => {
|
|
501
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
502
|
+
const position = argv.indexOf(prefix + flag);
|
|
503
|
+
const terminatorPosition = argv.indexOf("--");
|
|
504
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js
|
|
510
|
+
var require_supports_color = __commonJS({
|
|
511
|
+
"../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js"(exports, module) {
|
|
512
|
+
"use strict";
|
|
513
|
+
var os = __require("os");
|
|
514
|
+
var tty = __require("tty");
|
|
515
|
+
var hasFlag = require_has_flag();
|
|
516
|
+
var { env } = process;
|
|
517
|
+
var forceColor;
|
|
518
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
519
|
+
forceColor = 0;
|
|
520
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
521
|
+
forceColor = 1;
|
|
522
|
+
}
|
|
523
|
+
if ("FORCE_COLOR" in env) {
|
|
524
|
+
if (env.FORCE_COLOR === "true") {
|
|
525
|
+
forceColor = 1;
|
|
526
|
+
} else if (env.FORCE_COLOR === "false") {
|
|
527
|
+
forceColor = 0;
|
|
528
|
+
} else {
|
|
529
|
+
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
function translateLevel(level) {
|
|
533
|
+
if (level === 0) {
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
return {
|
|
537
|
+
level,
|
|
538
|
+
hasBasic: true,
|
|
539
|
+
has256: level >= 2,
|
|
540
|
+
has16m: level >= 3
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
function supportsColor(haveStream, streamIsTTY) {
|
|
544
|
+
if (forceColor === 0) {
|
|
545
|
+
return 0;
|
|
546
|
+
}
|
|
547
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
548
|
+
return 3;
|
|
549
|
+
}
|
|
550
|
+
if (hasFlag("color=256")) {
|
|
551
|
+
return 2;
|
|
552
|
+
}
|
|
553
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
554
|
+
return 0;
|
|
555
|
+
}
|
|
556
|
+
const min = forceColor || 0;
|
|
557
|
+
if (env.TERM === "dumb") {
|
|
558
|
+
return min;
|
|
559
|
+
}
|
|
560
|
+
if (process.platform === "win32") {
|
|
561
|
+
const osRelease = os.release().split(".");
|
|
562
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
563
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
564
|
+
}
|
|
565
|
+
return 1;
|
|
566
|
+
}
|
|
567
|
+
if ("CI" in env) {
|
|
568
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
569
|
+
return 1;
|
|
570
|
+
}
|
|
571
|
+
return min;
|
|
572
|
+
}
|
|
573
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
574
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
575
|
+
}
|
|
576
|
+
if (env.COLORTERM === "truecolor") {
|
|
577
|
+
return 3;
|
|
578
|
+
}
|
|
579
|
+
if ("TERM_PROGRAM" in env) {
|
|
580
|
+
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
581
|
+
switch (env.TERM_PROGRAM) {
|
|
582
|
+
case "iTerm.app":
|
|
583
|
+
return version >= 3 ? 3 : 2;
|
|
584
|
+
case "Apple_Terminal":
|
|
585
|
+
return 2;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
589
|
+
return 2;
|
|
590
|
+
}
|
|
591
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
592
|
+
return 1;
|
|
593
|
+
}
|
|
594
|
+
if ("COLORTERM" in env) {
|
|
595
|
+
return 1;
|
|
596
|
+
}
|
|
597
|
+
return min;
|
|
598
|
+
}
|
|
599
|
+
function getSupportLevel(stream) {
|
|
600
|
+
const level = supportsColor(stream, stream && stream.isTTY);
|
|
601
|
+
return translateLevel(level);
|
|
602
|
+
}
|
|
603
|
+
module.exports = {
|
|
604
|
+
supportsColor: getSupportLevel,
|
|
605
|
+
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
606
|
+
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js
|
|
612
|
+
var require_node = __commonJS({
|
|
613
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/node.js"(exports, module) {
|
|
614
|
+
var tty = __require("tty");
|
|
615
|
+
var util = __require("util");
|
|
616
|
+
exports.init = init;
|
|
617
|
+
exports.log = log;
|
|
618
|
+
exports.formatArgs = formatArgs;
|
|
619
|
+
exports.save = save;
|
|
620
|
+
exports.load = load;
|
|
621
|
+
exports.useColors = useColors;
|
|
622
|
+
exports.destroy = util.deprecate(
|
|
623
|
+
() => {
|
|
624
|
+
},
|
|
625
|
+
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
626
|
+
);
|
|
627
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
628
|
+
try {
|
|
629
|
+
const supportsColor = require_supports_color();
|
|
630
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
631
|
+
exports.colors = [
|
|
632
|
+
20,
|
|
633
|
+
21,
|
|
634
|
+
26,
|
|
635
|
+
27,
|
|
636
|
+
32,
|
|
637
|
+
33,
|
|
638
|
+
38,
|
|
639
|
+
39,
|
|
640
|
+
40,
|
|
641
|
+
41,
|
|
642
|
+
42,
|
|
643
|
+
43,
|
|
644
|
+
44,
|
|
645
|
+
45,
|
|
646
|
+
56,
|
|
647
|
+
57,
|
|
648
|
+
62,
|
|
649
|
+
63,
|
|
650
|
+
68,
|
|
651
|
+
69,
|
|
652
|
+
74,
|
|
653
|
+
75,
|
|
654
|
+
76,
|
|
655
|
+
77,
|
|
656
|
+
78,
|
|
657
|
+
79,
|
|
658
|
+
80,
|
|
659
|
+
81,
|
|
660
|
+
92,
|
|
661
|
+
93,
|
|
662
|
+
98,
|
|
663
|
+
99,
|
|
664
|
+
112,
|
|
665
|
+
113,
|
|
666
|
+
128,
|
|
667
|
+
129,
|
|
668
|
+
134,
|
|
669
|
+
135,
|
|
670
|
+
148,
|
|
671
|
+
149,
|
|
672
|
+
160,
|
|
673
|
+
161,
|
|
674
|
+
162,
|
|
675
|
+
163,
|
|
676
|
+
164,
|
|
677
|
+
165,
|
|
678
|
+
166,
|
|
679
|
+
167,
|
|
680
|
+
168,
|
|
681
|
+
169,
|
|
682
|
+
170,
|
|
683
|
+
171,
|
|
684
|
+
172,
|
|
685
|
+
173,
|
|
686
|
+
178,
|
|
687
|
+
179,
|
|
688
|
+
184,
|
|
689
|
+
185,
|
|
690
|
+
196,
|
|
691
|
+
197,
|
|
692
|
+
198,
|
|
693
|
+
199,
|
|
694
|
+
200,
|
|
695
|
+
201,
|
|
696
|
+
202,
|
|
697
|
+
203,
|
|
698
|
+
204,
|
|
699
|
+
205,
|
|
700
|
+
206,
|
|
701
|
+
207,
|
|
702
|
+
208,
|
|
703
|
+
209,
|
|
704
|
+
214,
|
|
705
|
+
215,
|
|
706
|
+
220,
|
|
707
|
+
221
|
|
708
|
+
];
|
|
709
|
+
}
|
|
710
|
+
} catch (error) {
|
|
711
|
+
}
|
|
712
|
+
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
713
|
+
return /^debug_/i.test(key);
|
|
714
|
+
}).reduce((obj, key) => {
|
|
715
|
+
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
716
|
+
return k.toUpperCase();
|
|
717
|
+
});
|
|
718
|
+
let val = process.env[key];
|
|
719
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
720
|
+
val = true;
|
|
721
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
722
|
+
val = false;
|
|
723
|
+
} else if (val === "null") {
|
|
724
|
+
val = null;
|
|
725
|
+
} else {
|
|
726
|
+
val = Number(val);
|
|
727
|
+
}
|
|
728
|
+
obj[prop] = val;
|
|
729
|
+
return obj;
|
|
730
|
+
}, {});
|
|
731
|
+
function useColors() {
|
|
732
|
+
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
733
|
+
}
|
|
734
|
+
function formatArgs(args) {
|
|
735
|
+
const { namespace: name, useColors: useColors2 } = this;
|
|
736
|
+
if (useColors2) {
|
|
737
|
+
const c = this.color;
|
|
738
|
+
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
739
|
+
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
740
|
+
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
741
|
+
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
742
|
+
} else {
|
|
743
|
+
args[0] = getDate() + name + " " + args[0];
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
function getDate() {
|
|
747
|
+
if (exports.inspectOpts.hideDate) {
|
|
748
|
+
return "";
|
|
749
|
+
}
|
|
750
|
+
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
751
|
+
}
|
|
752
|
+
function log(...args) {
|
|
753
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + "\n");
|
|
754
|
+
}
|
|
755
|
+
function save(namespaces) {
|
|
756
|
+
if (namespaces) {
|
|
757
|
+
process.env.DEBUG = namespaces;
|
|
758
|
+
} else {
|
|
759
|
+
delete process.env.DEBUG;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
function load() {
|
|
763
|
+
return process.env.DEBUG;
|
|
764
|
+
}
|
|
765
|
+
function init(debug2) {
|
|
766
|
+
debug2.inspectOpts = {};
|
|
767
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
768
|
+
for (let i = 0; i < keys.length; i++) {
|
|
769
|
+
debug2.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
module.exports = require_common()(exports);
|
|
773
|
+
var { formatters } = module.exports;
|
|
774
|
+
formatters.o = function(v) {
|
|
775
|
+
this.inspectOpts.colors = this.useColors;
|
|
776
|
+
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
777
|
+
};
|
|
778
|
+
formatters.O = function(v) {
|
|
779
|
+
this.inspectOpts.colors = this.useColors;
|
|
780
|
+
return util.inspect(v, this.inspectOpts);
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
// ../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js
|
|
786
|
+
var require_src = __commonJS({
|
|
787
|
+
"../../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/index.js"(exports, module) {
|
|
788
|
+
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
789
|
+
module.exports = require_browser();
|
|
790
|
+
} else {
|
|
791
|
+
module.exports = require_node();
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
|
|
1
796
|
// src/utils/debug.ts
|
|
2
|
-
|
|
3
|
-
var debug =
|
|
4
|
-
var debugTask =
|
|
5
|
-
var debugWarning =
|
|
6
|
-
var debugError =
|
|
797
|
+
var import_debug = __toESM(require_src());
|
|
798
|
+
var debug = (0, import_debug.default)("apple-kit");
|
|
799
|
+
var debugTask = (0, import_debug.default)("apple-kit:task");
|
|
800
|
+
var debugWarning = (0, import_debug.default)("apple-kit:warning");
|
|
801
|
+
var debugError = (0, import_debug.default)("apple-kit:error");
|
|
7
802
|
function logInfo(message) {
|
|
8
803
|
debug(message);
|
|
9
804
|
}
|
|
@@ -11,6 +806,134 @@ function logTask(message) {
|
|
|
11
806
|
debugTask(message);
|
|
12
807
|
}
|
|
13
808
|
|
|
809
|
+
// src/utils/portManager.ts
|
|
810
|
+
import { createServer } from "node:net";
|
|
811
|
+
var PortManager = class {
|
|
812
|
+
allocations = /* @__PURE__ */ new Map();
|
|
813
|
+
basePort;
|
|
814
|
+
maxPortRange;
|
|
815
|
+
/**
|
|
816
|
+
* Create a new PortManager
|
|
817
|
+
*
|
|
818
|
+
* @param basePort Starting port number for allocation (default: 30000)
|
|
819
|
+
* @param maxPortRange Maximum range of ports to search (default: 1000)
|
|
820
|
+
*/
|
|
821
|
+
constructor(basePort = 3e4, maxPortRange = 1e3) {
|
|
822
|
+
this.basePort = basePort;
|
|
823
|
+
this.maxPortRange = maxPortRange;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Find an available port starting from the given port number
|
|
827
|
+
*/
|
|
828
|
+
async findAvailablePort(startPort) {
|
|
829
|
+
const maxPort = this.basePort + this.maxPortRange;
|
|
830
|
+
for (let port = startPort; port < maxPort; port++) {
|
|
831
|
+
const isAllocated = Array.from(this.allocations.values()).some(
|
|
832
|
+
(a) => a.localPort === port
|
|
833
|
+
);
|
|
834
|
+
if (isAllocated) {
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
const isAvailable = await this.isPortAvailable(port);
|
|
838
|
+
if (isAvailable) {
|
|
839
|
+
return port;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
throw new Error(
|
|
843
|
+
`No available ports found in range ${startPort}-${maxPort}`
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Check if a port is available for binding
|
|
848
|
+
*/
|
|
849
|
+
isPortAvailable(port) {
|
|
850
|
+
return new Promise((resolve) => {
|
|
851
|
+
const server = createServer();
|
|
852
|
+
server.once("error", () => {
|
|
853
|
+
resolve(false);
|
|
854
|
+
});
|
|
855
|
+
server.once("listening", () => {
|
|
856
|
+
server.close(() => {
|
|
857
|
+
resolve(true);
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
server.listen(port, "127.0.0.1");
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* Allocate a local port for a logical port
|
|
865
|
+
*
|
|
866
|
+
* @param logicalPort The logical port number (USB hub position)
|
|
867
|
+
* @param devicePort The device port to forward to
|
|
868
|
+
* @returns The allocated port info
|
|
869
|
+
*/
|
|
870
|
+
async allocate(logicalPort, devicePort) {
|
|
871
|
+
const existing = this.allocations.get(logicalPort);
|
|
872
|
+
if (existing) {
|
|
873
|
+
logTask(`Reusing existing port allocation for logical port ${logicalPort}: ${existing.localPort}`);
|
|
874
|
+
return existing;
|
|
875
|
+
}
|
|
876
|
+
const preferredPort = this.basePort + logicalPort;
|
|
877
|
+
let localPort;
|
|
878
|
+
const preferredAvailable = await this.isPortAvailable(preferredPort);
|
|
879
|
+
if (preferredAvailable) {
|
|
880
|
+
localPort = preferredPort;
|
|
881
|
+
} else {
|
|
882
|
+
localPort = await this.findAvailablePort(this.basePort);
|
|
883
|
+
}
|
|
884
|
+
const allocation = {
|
|
885
|
+
logicalPort,
|
|
886
|
+
localPort,
|
|
887
|
+
devicePort
|
|
888
|
+
};
|
|
889
|
+
this.allocations.set(logicalPort, allocation);
|
|
890
|
+
logTask(`Allocated port ${localPort} for logical port ${logicalPort} -> device port ${devicePort}`);
|
|
891
|
+
return allocation;
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* Release the port allocation for a logical port
|
|
895
|
+
*/
|
|
896
|
+
release(logicalPort) {
|
|
897
|
+
const allocation = this.allocations.get(logicalPort);
|
|
898
|
+
if (allocation) {
|
|
899
|
+
logTask(`Released port ${allocation.localPort} for logical port ${logicalPort}`);
|
|
900
|
+
this.allocations.delete(logicalPort);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Get the current allocation for a logical port
|
|
905
|
+
*/
|
|
906
|
+
getAllocation(logicalPort) {
|
|
907
|
+
return this.allocations.get(logicalPort);
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Get all current allocations
|
|
911
|
+
*/
|
|
912
|
+
getAllAllocations() {
|
|
913
|
+
return Array.from(this.allocations.values());
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Release all allocations
|
|
917
|
+
*/
|
|
918
|
+
releaseAll() {
|
|
919
|
+
logTask(`Releasing all port allocations (${this.allocations.size} ports)`);
|
|
920
|
+
this.allocations.clear();
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Check if a logical port has an allocation
|
|
924
|
+
*/
|
|
925
|
+
hasAllocation(logicalPort) {
|
|
926
|
+
return this.allocations.has(logicalPort);
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
var sharedPortManager = null;
|
|
930
|
+
function getSharedPortManager() {
|
|
931
|
+
if (!sharedPortManager) {
|
|
932
|
+
sharedPortManager = new PortManager();
|
|
933
|
+
}
|
|
934
|
+
return sharedPortManager;
|
|
935
|
+
}
|
|
936
|
+
|
|
14
937
|
// src/logic/actions/device.ts
|
|
15
938
|
import { exec as execCallback } from "node:child_process";
|
|
16
939
|
import { existsSync } from "node:fs";
|
|
@@ -408,51 +1331,107 @@ async function launchAppWithPymobiledevice3(bundleId, args, udid) {
|
|
|
408
1331
|
}
|
|
409
1332
|
|
|
410
1333
|
// src/logic/actions/proxy.ts
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
"
|
|
417
|
-
udid
|
|
418
|
-
]);
|
|
419
|
-
return {
|
|
420
|
-
localPort,
|
|
421
|
-
devicePort,
|
|
422
|
-
...result
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
async function startPortForwardAsync(localPort, devicePort, udid, _timeout = 5e3) {
|
|
426
|
-
const result = await startPortForward(localPort, devicePort, udid);
|
|
427
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
428
|
-
if (result.stdout.includes("error") || result.stderr.includes("error")) {
|
|
429
|
-
throw new Error("Port forwarding failed to start");
|
|
1334
|
+
import { spawn } from "node:child_process";
|
|
1335
|
+
import { join as join2 } from "node:path";
|
|
1336
|
+
function getResourcesBinPath2() {
|
|
1337
|
+
const binPath = process.env.IDeviceBinPath;
|
|
1338
|
+
if (!binPath) {
|
|
1339
|
+
throw new Error("IDeviceBinPath is not set");
|
|
430
1340
|
}
|
|
431
|
-
return
|
|
1341
|
+
return binPath;
|
|
1342
|
+
}
|
|
1343
|
+
function startPortForward(localPort, devicePort, udid, startupTimeout = 500) {
|
|
1344
|
+
return new Promise((resolve, reject) => {
|
|
1345
|
+
logTask(`Starting port forward ${localPort} -> ${devicePort} for device ${udid}`);
|
|
1346
|
+
const binPath = getResourcesBinPath2();
|
|
1347
|
+
const toolPath = join2(binPath, `iproxy${process.platform === "win32" ? ".exe" : ""}`);
|
|
1348
|
+
const child = spawn(
|
|
1349
|
+
toolPath,
|
|
1350
|
+
[localPort.toString(), devicePort.toString(), "-u", udid],
|
|
1351
|
+
{
|
|
1352
|
+
cwd: binPath,
|
|
1353
|
+
windowsHide: true,
|
|
1354
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1355
|
+
}
|
|
1356
|
+
);
|
|
1357
|
+
let hasResolved = false;
|
|
1358
|
+
let stderrOutput = "";
|
|
1359
|
+
child.stderr?.on("data", (data) => {
|
|
1360
|
+
const msg = data.toString();
|
|
1361
|
+
stderrOutput += msg;
|
|
1362
|
+
if (msg.toLowerCase().includes("error") && !hasResolved) {
|
|
1363
|
+
hasResolved = true;
|
|
1364
|
+
child.kill();
|
|
1365
|
+
reject(new Error(`Port forwarding failed: ${msg}`));
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
child.on("error", (error) => {
|
|
1369
|
+
if (!hasResolved) {
|
|
1370
|
+
hasResolved = true;
|
|
1371
|
+
reject(new Error(`Failed to start iproxy: ${error.message}`));
|
|
1372
|
+
}
|
|
1373
|
+
});
|
|
1374
|
+
child.on("exit", (code) => {
|
|
1375
|
+
if (!hasResolved) {
|
|
1376
|
+
hasResolved = true;
|
|
1377
|
+
if (code !== 0 && code !== null) {
|
|
1378
|
+
reject(new Error(`iproxy exited with code ${code}: ${stderrOutput}`));
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
setTimeout(() => {
|
|
1383
|
+
if (!hasResolved) {
|
|
1384
|
+
hasResolved = true;
|
|
1385
|
+
logTask(`Port forward started: ${localPort} -> ${devicePort} for device ${udid}`);
|
|
1386
|
+
resolve({
|
|
1387
|
+
result: {
|
|
1388
|
+
localPort,
|
|
1389
|
+
devicePort
|
|
1390
|
+
},
|
|
1391
|
+
process: child
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
}, startupTimeout);
|
|
1395
|
+
});
|
|
432
1396
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
1397
|
+
function killPortForwardProcess(process2) {
|
|
1398
|
+
if (process2 && !process2.killed) {
|
|
1399
|
+
logTask("Killing port forward process");
|
|
1400
|
+
process2.kill();
|
|
1401
|
+
}
|
|
436
1402
|
}
|
|
437
1403
|
|
|
438
1404
|
// src/logic/appleDeviceKit.ts
|
|
439
1405
|
var AppleDeviceKit = class {
|
|
440
|
-
constructor(udid,
|
|
441
|
-
this.
|
|
1406
|
+
constructor(udid, logicalPort) {
|
|
1407
|
+
this.logicalPort = logicalPort;
|
|
442
1408
|
this.deviceId = udid;
|
|
443
|
-
logInfo(`AppleDeviceKit initialized for device: ${this.deviceId}`);
|
|
1409
|
+
logInfo(`AppleDeviceKit initialized for device: ${this.deviceId}, logical port: ${this.logicalPort}`);
|
|
444
1410
|
}
|
|
445
1411
|
deviceId;
|
|
1412
|
+
proxyProcess = null;
|
|
1413
|
+
portAllocation = null;
|
|
1414
|
+
isDisposed = false;
|
|
1415
|
+
/**
|
|
1416
|
+
* Throws if the kit has been disposed
|
|
1417
|
+
*/
|
|
1418
|
+
ensureNotDisposed() {
|
|
1419
|
+
if (this.isDisposed) {
|
|
1420
|
+
throw new Error("AppleDeviceKit has been disposed");
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
446
1423
|
/**
|
|
447
1424
|
* Get detailed device information
|
|
448
1425
|
*/
|
|
449
1426
|
async getDeviceInfo() {
|
|
1427
|
+
this.ensureNotDisposed();
|
|
450
1428
|
return getDeviceInfo(this.deviceId);
|
|
451
1429
|
}
|
|
452
1430
|
/**
|
|
453
1431
|
* Check if device is paired/trusted with this computer
|
|
454
1432
|
*/
|
|
455
1433
|
async isPaired() {
|
|
1434
|
+
this.ensureNotDisposed();
|
|
456
1435
|
return isPaired(this.deviceId);
|
|
457
1436
|
}
|
|
458
1437
|
/**
|
|
@@ -463,6 +1442,7 @@ var AppleDeviceKit = class {
|
|
|
463
1442
|
* @param pollInterval Poll interval in milliseconds (default: 1000)
|
|
464
1443
|
*/
|
|
465
1444
|
async waitForPairing(timeout = 12e4, pollInterval = 1e3) {
|
|
1445
|
+
this.ensureNotDisposed();
|
|
466
1446
|
return waitForPairing(this.deviceId, timeout, pollInterval);
|
|
467
1447
|
}
|
|
468
1448
|
/**
|
|
@@ -470,6 +1450,7 @@ var AppleDeviceKit = class {
|
|
|
470
1450
|
* User must accept the trust dialog on the device
|
|
471
1451
|
*/
|
|
472
1452
|
async pair() {
|
|
1453
|
+
this.ensureNotDisposed();
|
|
473
1454
|
return pair(this.deviceId);
|
|
474
1455
|
}
|
|
475
1456
|
/**
|
|
@@ -486,12 +1467,14 @@ var AppleDeviceKit = class {
|
|
|
486
1467
|
* @returns true if device is now trusted
|
|
487
1468
|
*/
|
|
488
1469
|
async trustDevice(timeout = 6e4, onWaitingForTrust) {
|
|
1470
|
+
this.ensureNotDisposed();
|
|
489
1471
|
return trustDevice(this.deviceId, timeout, onWaitingForTrust);
|
|
490
1472
|
}
|
|
491
1473
|
/**
|
|
492
1474
|
* Unpair/untrust the device
|
|
493
1475
|
*/
|
|
494
1476
|
async unpair() {
|
|
1477
|
+
this.ensureNotDisposed();
|
|
495
1478
|
return unpair(this.deviceId);
|
|
496
1479
|
}
|
|
497
1480
|
/**
|
|
@@ -500,6 +1483,7 @@ var AppleDeviceKit = class {
|
|
|
500
1483
|
* @param ipaPath Path to the IPA file
|
|
501
1484
|
*/
|
|
502
1485
|
async installApp(ipaPath) {
|
|
1486
|
+
this.ensureNotDisposed();
|
|
503
1487
|
installApp(ipaPath, this.deviceId);
|
|
504
1488
|
}
|
|
505
1489
|
/**
|
|
@@ -508,6 +1492,7 @@ var AppleDeviceKit = class {
|
|
|
508
1492
|
* @param bundleId Application bundle identifier
|
|
509
1493
|
*/
|
|
510
1494
|
async uninstallApp(bundleId) {
|
|
1495
|
+
this.ensureNotDisposed();
|
|
511
1496
|
uninstallApp(bundleId, this.deviceId);
|
|
512
1497
|
}
|
|
513
1498
|
/**
|
|
@@ -516,12 +1501,14 @@ var AppleDeviceKit = class {
|
|
|
516
1501
|
* @param bundleId Application bundle identifier
|
|
517
1502
|
*/
|
|
518
1503
|
async isAppInstalled(bundleId) {
|
|
1504
|
+
this.ensureNotDisposed();
|
|
519
1505
|
return isAppInstalled(bundleId, this.deviceId);
|
|
520
1506
|
}
|
|
521
1507
|
/**
|
|
522
1508
|
* List all installed user applications
|
|
523
1509
|
*/
|
|
524
1510
|
async listApps() {
|
|
1511
|
+
this.ensureNotDisposed();
|
|
525
1512
|
return listApps(this.deviceId);
|
|
526
1513
|
}
|
|
527
1514
|
/**
|
|
@@ -531,24 +1518,62 @@ var AppleDeviceKit = class {
|
|
|
531
1518
|
* @param args Application arguments
|
|
532
1519
|
*/
|
|
533
1520
|
async launchApp(bundleId, args = []) {
|
|
1521
|
+
this.ensureNotDisposed();
|
|
534
1522
|
return launchApp(bundleId, args, this.deviceId);
|
|
535
1523
|
}
|
|
536
1524
|
/**
|
|
537
1525
|
* Start port forwarding and wait for it to be ready.
|
|
538
|
-
*
|
|
1526
|
+
* The local port is automatically allocated based on the logical port.
|
|
1527
|
+
*
|
|
1528
|
+
* We need port forwarding to be able to connect to the device from the computer
|
|
539
1529
|
* and communicate with it using the local port.
|
|
540
1530
|
*
|
|
541
|
-
*
|
|
1531
|
+
* Note: Only one port forward can be active at a time per kit instance.
|
|
1532
|
+
* Starting a new port forward will kill any existing one.
|
|
1533
|
+
*
|
|
542
1534
|
* @param devicePort Device port to forward to
|
|
543
|
-
* @param
|
|
1535
|
+
* @param startupTimeout Time to wait for proxy to start (ms)
|
|
1536
|
+
* @returns The port forward result with the allocated local port
|
|
544
1537
|
*/
|
|
545
|
-
async startPortForwardAsync(
|
|
546
|
-
|
|
1538
|
+
async startPortForwardAsync(devicePort, startupTimeout = 500) {
|
|
1539
|
+
this.ensureNotDisposed();
|
|
1540
|
+
this.killProxyProcess();
|
|
1541
|
+
const portManager = getSharedPortManager();
|
|
1542
|
+
this.portAllocation = await portManager.allocate(this.logicalPort, devicePort);
|
|
1543
|
+
const { result, process: process2 } = await startPortForward(
|
|
1544
|
+
this.portAllocation.localPort,
|
|
1545
|
+
devicePort,
|
|
1546
|
+
this.deviceId,
|
|
1547
|
+
startupTimeout
|
|
1548
|
+
);
|
|
1549
|
+
this.proxyProcess = process2;
|
|
1550
|
+
return result;
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Kill the current port forwarding process if running
|
|
1554
|
+
*/
|
|
1555
|
+
killProxyProcess() {
|
|
1556
|
+
if (this.proxyProcess) {
|
|
1557
|
+
killPortForwardProcess(this.proxyProcess);
|
|
1558
|
+
this.proxyProcess = null;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Close the current port forwarding session and release the port
|
|
1563
|
+
*/
|
|
1564
|
+
closePortForward() {
|
|
1565
|
+
this.killProxyProcess();
|
|
1566
|
+
if (this.portAllocation) {
|
|
1567
|
+
const portManager = getSharedPortManager();
|
|
1568
|
+
portManager.release(this.logicalPort);
|
|
1569
|
+
this.portAllocation = null;
|
|
1570
|
+
}
|
|
547
1571
|
}
|
|
548
1572
|
/**
|
|
549
1573
|
* Get the activation state of the device
|
|
550
1574
|
*/
|
|
551
1575
|
async getActivationState() {
|
|
1576
|
+
this.ensureNotDisposed();
|
|
552
1577
|
return getActivationState(this.deviceId);
|
|
553
1578
|
}
|
|
554
1579
|
/**
|
|
@@ -562,6 +1587,7 @@ var AppleDeviceKit = class {
|
|
|
562
1587
|
* precondition: the device must be paired and trusted
|
|
563
1588
|
*/
|
|
564
1589
|
async activate() {
|
|
1590
|
+
this.ensureNotDisposed();
|
|
565
1591
|
return activate(this.deviceId);
|
|
566
1592
|
}
|
|
567
1593
|
/**
|
|
@@ -571,16 +1597,60 @@ var AppleDeviceKit = class {
|
|
|
571
1597
|
return this.deviceId;
|
|
572
1598
|
}
|
|
573
1599
|
/**
|
|
574
|
-
* Get the logical port number
|
|
1600
|
+
* Get the logical port number (USB hub position)
|
|
1601
|
+
*/
|
|
1602
|
+
getLogicalPort() {
|
|
1603
|
+
return this.logicalPort;
|
|
1604
|
+
}
|
|
1605
|
+
/**
|
|
1606
|
+
* Get the currently allocated local port for forwarding
|
|
1607
|
+
* Returns undefined if no port forward is active
|
|
1608
|
+
*/
|
|
1609
|
+
getAllocatedPort() {
|
|
1610
|
+
return this.portAllocation?.localPort;
|
|
1611
|
+
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Get the current port allocation info
|
|
575
1614
|
*/
|
|
576
|
-
|
|
577
|
-
return this.
|
|
1615
|
+
getPortAllocation() {
|
|
1616
|
+
return this.portAllocation;
|
|
578
1617
|
}
|
|
579
|
-
|
|
580
|
-
|
|
1618
|
+
/**
|
|
1619
|
+
* Check if this kit has been disposed
|
|
1620
|
+
*/
|
|
1621
|
+
get disposed() {
|
|
1622
|
+
return this.isDisposed;
|
|
1623
|
+
}
|
|
1624
|
+
/**
|
|
1625
|
+
* Check if a port forward is currently active
|
|
1626
|
+
*/
|
|
1627
|
+
get hasActivePortForward() {
|
|
1628
|
+
return this.proxyProcess !== null && !this.proxyProcess.killed;
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Dispose of the kit and clean up all resources.
|
|
1632
|
+
* This will kill any running proxy processes and release port allocations.
|
|
1633
|
+
*
|
|
1634
|
+
* After calling dispose(), the kit instance should not be used.
|
|
1635
|
+
*/
|
|
1636
|
+
dispose() {
|
|
1637
|
+
if (this.isDisposed) {
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
logInfo(`Disposing AppleDeviceKit for device: ${this.deviceId}`);
|
|
1641
|
+
this.closePortForward();
|
|
1642
|
+
this.isDisposed = true;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Symbol.dispose implementation for using with `using` keyword (TypeScript 5.2+)
|
|
1646
|
+
*/
|
|
1647
|
+
[Symbol.dispose]() {
|
|
1648
|
+
this.dispose();
|
|
581
1649
|
}
|
|
582
1650
|
};
|
|
583
1651
|
export {
|
|
584
|
-
AppleDeviceKit
|
|
1652
|
+
AppleDeviceKit,
|
|
1653
|
+
PortManager,
|
|
1654
|
+
getSharedPortManager
|
|
585
1655
|
};
|
|
586
1656
|
//# sourceMappingURL=index.mjs.map
|