@limrun/ui 0.13.3-rc.1 → 0.13.4
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/app-store-relay/index.cjs +4 -4
- package/dist/app-store-relay/index.js +175 -119
- package/dist/app-store-relay/react.cjs +1 -1
- package/dist/app-store-relay/react.js +2 -2
- package/dist/{browser-storage-BJ__DGJ6.mjs → browser-storage-Cx9eW-bm.mjs} +48 -45
- package/dist/browser-storage-jJaIht4K.js +1 -0
- package/dist/{client-CnbCWvCs.js → client-ASLtHFLh.js} +1 -1
- package/dist/{client-Bk1N3XIF.mjs → client-CGdh8yoJ.mjs} +33 -27
- package/dist/components/remote-control.d.ts +144 -0
- package/dist/core/device-install/apple/provisioning.d.ts +4 -4
- package/dist/device-build/index.cjs +1 -1
- package/dist/device-build/index.js +5 -5
- package/dist/device-build/react.cjs +1 -1
- package/dist/device-build/react.js +15 -13
- package/dist/device-install/demo/demo.d.ts +0 -0
- package/dist/device-install/index.cjs +1 -1
- package/dist/device-install/index.d.ts +1 -1
- package/dist/device-install/index.js +134 -121
- package/dist/device-install/react.cjs +1 -1
- package/dist/device-install/react.js +55 -50
- package/dist/{index-BXg7HdIs.mjs → index-DFdCvi2_.mjs} +3 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +1336 -1089
- package/dist/limbuild-client-CgEncrgx.js +1 -0
- package/dist/{limbuild-client-CFJhYsRx.mjs → limbuild-client-D7U7w342.mjs} +4 -2
- package/dist/{provisioning-CdseoMJQ.mjs → provisioning-DKbkBO-p.mjs} +11 -11
- package/dist/{provisioning-D2ZZQeyX.js → provisioning-Va0PH4Kk.js} +1 -1
- package/package.json +1 -1
- package/src/app-store-relay/index.test.ts +1 -5
- package/src/app-store-relay/index.ts +109 -42
- package/src/app-store-relay/react.ts +6 -2
- package/src/components/remote-control.tsx +726 -0
- package/src/core/device-install/apple/client.ts +29 -22
- package/src/core/device-install/apple/crypto.ts +9 -6
- package/src/core/device-install/apple/gsa-srp.ts +3 -7
- package/src/core/device-install/apple/provisioning.ts +16 -18
- package/src/core/device-install/apple/relay.ts +5 -1
- package/src/core/device-install/operations/limbuild-client.ts +8 -1
- package/src/core/device-install/operations/operations.ts +3 -1
- package/src/core/device-install/operations/relay-client.ts +57 -27
- package/src/core/device-install/operations/usbmux.ts +3 -3
- package/src/core/device-install/operations/webusb.ts +9 -4
- package/src/core/device-install/storage/browser-storage.ts +20 -6
- package/src/core/device-install/types.ts +1 -7
- package/src/device-build/react.ts +4 -1
- package/src/device-install/README.md +423 -0
- package/src/device-install/demo/demo.css +493 -0
- package/src/device-install/demo/demo.tsx +1069 -0
- package/src/device-install/demo/index.html +12 -0
- package/src/device-install/index.ts +7 -7
- package/src/device-install/react.ts +26 -17
- package/src/index.ts +1 -1
- package/dist/browser-storage-C1jQLXat.js +0 -1
- package/dist/limbuild-client-C_CMNLYV.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
const
|
|
1
|
+
import { j as ge, n as be, k as Ue } from "../browser-storage-Cx9eW-bm.mjs";
|
|
2
|
+
const v = 1, u = 16, s = {
|
|
3
3
|
DeviceHello: 1,
|
|
4
4
|
OpenStream: 2,
|
|
5
5
|
OpenResult: 3,
|
|
@@ -15,13 +15,13 @@ const S = 1, u = 16, s = {
|
|
|
15
15
|
};
|
|
16
16
|
function D(e) {
|
|
17
17
|
const t = new Uint8Array(u + e.payload.byteLength), n = new DataView(t.buffer);
|
|
18
|
-
return n.setUint8(0,
|
|
18
|
+
return n.setUint8(0, v), n.setUint8(1, e.type), n.setUint8(2, 0), n.setUint8(3, 0), n.setUint32(4, e.requestId), n.setUint32(8, e.streamId), n.setUint32(12, e.payload.byteLength), t.set(e.payload, u), t;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function V(e) {
|
|
21
21
|
if (e.byteLength < u)
|
|
22
22
|
throw new Error(`Relay frame too short: ${e.byteLength}`);
|
|
23
23
|
const t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = t.getUint8(0);
|
|
24
|
-
if (n !==
|
|
24
|
+
if (n !== v)
|
|
25
25
|
throw new Error(`Unsupported relay protocol version ${n}`);
|
|
26
26
|
const r = t.getUint32(12);
|
|
27
27
|
if (e.byteLength !== u + r)
|
|
@@ -38,24 +38,24 @@ function A(e) {
|
|
|
38
38
|
function c(e) {
|
|
39
39
|
return new TextEncoder().encode(JSON.stringify(e));
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function h(e) {
|
|
42
42
|
return JSON.parse(new TextDecoder().decode(e));
|
|
43
43
|
}
|
|
44
|
-
async function
|
|
44
|
+
async function A() {
|
|
45
45
|
if (!navigator.usb)
|
|
46
46
|
throw new Error("WebUSB is not available in this browser.");
|
|
47
47
|
return navigator.usb.requestDevice({ filters: [{ vendorId: 1452 }] });
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function C(e) {
|
|
50
50
|
const t = [], n = e.configuration?.configurationValue, r = e.configurations.find(
|
|
51
51
|
(a) => a.configurationValue === n
|
|
52
52
|
);
|
|
53
|
-
r && t.push(...
|
|
53
|
+
r && t.push(...U(r));
|
|
54
54
|
for (const a of e.configurations)
|
|
55
|
-
a.configurationValue !== n && t.push(...
|
|
55
|
+
a.configurationValue !== n && t.push(...U(a));
|
|
56
56
|
return t;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function U(e) {
|
|
59
59
|
const t = [];
|
|
60
60
|
for (const n of e.interfaces)
|
|
61
61
|
for (const r of n.alternates)
|
|
@@ -67,10 +67,10 @@ function b(e) {
|
|
|
67
67
|
});
|
|
68
68
|
return t;
|
|
69
69
|
}
|
|
70
|
-
async function
|
|
71
|
-
e.opened || await e.open(), (!e.configuration || e.configuration.configurationValue !== t.configurationValue) && await e.selectConfiguration(t.configurationValue), await e.claimInterface(t.interfaceNumber),
|
|
70
|
+
async function L(e, t) {
|
|
71
|
+
e.opened || await e.open(), (!e.configuration || e.configuration.configurationValue !== t.configurationValue) && await e.selectConfiguration(t.configurationValue), await e.claimInterface(t.interfaceNumber), await e.selectAlternateInterface(t.interfaceNumber, t.alternateSetting);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function T(e) {
|
|
74
74
|
const t = e.endpoints.find(
|
|
75
75
|
(r) => r.direction === "out" && r.type === "bulk"
|
|
76
76
|
), n = e.endpoints.find(
|
|
@@ -80,38 +80,38 @@ function L(e) {
|
|
|
80
80
|
throw new Error("Could not find usbmux bulk endpoints.");
|
|
81
81
|
return { outEndpoint: t, inEndpoint: n };
|
|
82
82
|
}
|
|
83
|
-
async function
|
|
83
|
+
async function R(e, t, n) {
|
|
84
84
|
const r = await e.transferOut(t.endpointNumber, n);
|
|
85
85
|
if (r.status !== "ok")
|
|
86
86
|
throw new Error(`USB transferOut failed: ${r.status}`);
|
|
87
87
|
n.byteLength % t.packetSize === 0 && await e.transferOut(t.endpointNumber, new Uint8Array());
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
89
|
+
async function W(e, t, n = 16384) {
|
|
90
90
|
const r = await e.transferIn(t.endpointNumber, n);
|
|
91
91
|
if (r.status !== "ok" || !r.data)
|
|
92
92
|
throw new Error(`USB transferIn failed: ${r.status}`);
|
|
93
93
|
return new Uint8Array(r.data.buffer, r.data.byteOffset, r.data.byteLength);
|
|
94
94
|
}
|
|
95
|
-
const
|
|
96
|
-
async function
|
|
97
|
-
const { inEndpoint: n, outEndpoint: r } =
|
|
98
|
-
i.setUint32(0, 2), i.setUint32(4, 0), i.setUint32(8, 0), await
|
|
99
|
-
const o = await
|
|
95
|
+
const E = 0, B = 2, k = 6, F = 4277009102, y = 2, _ = 4, l = 16, M = 49152;
|
|
96
|
+
async function j(e, t) {
|
|
97
|
+
const { inEndpoint: n, outEndpoint: r } = T(t), a = new Uint8Array(12), i = new DataView(a.buffer);
|
|
98
|
+
i.setUint32(0, 2), i.setUint32(4, 0), i.setUint32(8, 0), await R(e, r, O(E, a));
|
|
99
|
+
const o = await P(e, n, 1), f = new DataView(o.payload.buffer, o.payload.byteOffset).getUint32(0), w = {
|
|
100
100
|
device: e,
|
|
101
101
|
candidate: t,
|
|
102
102
|
inEndpoint: n,
|
|
103
103
|
outEndpoint: r,
|
|
104
|
-
muxVersion:
|
|
104
|
+
muxVersion: f,
|
|
105
105
|
txSeq: 0,
|
|
106
106
|
rxSeq: 65535,
|
|
107
|
-
nextSport:
|
|
107
|
+
nextSport: M,
|
|
108
108
|
streams: /* @__PURE__ */ new Map(),
|
|
109
109
|
writeChain: Promise.resolve(),
|
|
110
110
|
closed: !1
|
|
111
111
|
};
|
|
112
|
-
return
|
|
112
|
+
return f >= 2 && await x(w, B, new Uint8Array([7])), Q(w), w;
|
|
113
113
|
}
|
|
114
|
-
async function
|
|
114
|
+
async function H(e, t) {
|
|
115
115
|
if (e.closed)
|
|
116
116
|
throw new Error("usbmux session is closed.");
|
|
117
117
|
let n, r;
|
|
@@ -129,14 +129,14 @@ async function j(e, t) {
|
|
|
129
129
|
resolveOpened: n,
|
|
130
130
|
rejectOpened: r
|
|
131
131
|
};
|
|
132
|
-
return e.streams.set(
|
|
132
|
+
return e.streams.set(m(t, a.sport), a), await p(a, y, new Uint8Array()), await a.opened, a;
|
|
133
133
|
}
|
|
134
|
-
async function
|
|
134
|
+
async function J(e, t) {
|
|
135
135
|
if (e.session.closed)
|
|
136
136
|
throw new Error("usbmux session is closed.");
|
|
137
|
-
await
|
|
137
|
+
await p(e, l, t), e.seq += t.byteLength;
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
139
|
+
async function G(e) {
|
|
140
140
|
if (e.queue.length > 0)
|
|
141
141
|
return e.queue.shift();
|
|
142
142
|
if (e.error)
|
|
@@ -145,14 +145,14 @@ async function J(e) {
|
|
|
145
145
|
e.waiters.push(t);
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function I(e) {
|
|
149
149
|
e.closed = !0;
|
|
150
150
|
for (const t of e.streams.values())
|
|
151
151
|
for (t.error = new Error("usbmux session closed"), t.rejectOpened(t.error); t.waiters.length > 0; )
|
|
152
152
|
t.waiters.shift()(new Uint8Array());
|
|
153
153
|
e.streams.clear();
|
|
154
154
|
}
|
|
155
|
-
async function
|
|
155
|
+
async function p(e, t, n) {
|
|
156
156
|
const r = new Uint8Array(20 + n.byteLength), a = new DataView(r.buffer);
|
|
157
157
|
a.setUint16(0, e.sport), a.setUint16(2, e.dport), a.setUint32(4, e.seq), a.setUint32(8, e.ack), a.setUint8(12, 80), a.setUint8(13, t), a.setUint16(14, 512), r.set(n, 20), await x(e.session, k, r);
|
|
158
158
|
}
|
|
@@ -161,51 +161,51 @@ async function x(e, t, n) {
|
|
|
161
161
|
throw new Error("usbmux session is closed.");
|
|
162
162
|
return e.writeChain = e.writeChain.then(async () => {
|
|
163
163
|
if (e.closed) return;
|
|
164
|
-
const r = e.muxVersion >= 2 ? Y(t, n, e.txSeq++, e.rxSeq) :
|
|
165
|
-
await
|
|
164
|
+
const r = e.muxVersion >= 2 ? Y(t, n, e.txSeq++, e.rxSeq) : O(t, n);
|
|
165
|
+
await R(e.device, e.outEndpoint, r);
|
|
166
166
|
}), e.writeChain;
|
|
167
167
|
}
|
|
168
|
-
async function
|
|
168
|
+
async function Q(e) {
|
|
169
169
|
try {
|
|
170
170
|
for (; ; ) {
|
|
171
171
|
if (e.closed) return;
|
|
172
|
-
const t = await
|
|
172
|
+
const t = await P(e.device, e.inEndpoint, e.muxVersion);
|
|
173
173
|
if (e.closed) return;
|
|
174
174
|
if (t.rxSeq !== void 0 && (e.rxSeq = t.rxSeq), t.protocol !== k)
|
|
175
175
|
continue;
|
|
176
|
-
const n =
|
|
176
|
+
const n = K(t.payload), r = e.streams.get(m(n.sport, n.dport));
|
|
177
177
|
if (r) {
|
|
178
|
-
if (n.flags &
|
|
178
|
+
if (n.flags & _) {
|
|
179
179
|
for (r.error = new Error(`Device reset stream ${r.dport}`), r.rejectOpened(r.error); r.waiters.length > 0; )
|
|
180
180
|
r.waiters.shift()(new Uint8Array());
|
|
181
|
-
e.streams.delete(
|
|
181
|
+
e.streams.delete(m(r.dport, r.sport));
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
|
-
if ((n.flags & (
|
|
185
|
-
r.seq += 1, r.ack = n.seq + 1, await
|
|
184
|
+
if ((n.flags & (y | l)) === (y | l)) {
|
|
185
|
+
r.seq += 1, r.ack = n.seq + 1, await p(r, l, new Uint8Array()), r.resolveOpened();
|
|
186
186
|
continue;
|
|
187
187
|
}
|
|
188
|
-
n.payload.byteLength !== 0 && (r.ack = n.seq + n.payload.byteLength, await
|
|
188
|
+
n.payload.byteLength !== 0 && (r.ack = n.seq + n.payload.byteLength, await p(r, l, new Uint8Array()), r.waiters.length > 0 ? r.waiters.shift()(n.payload) : r.queue.push(n.payload));
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
} catch {
|
|
192
|
-
e.closed ||
|
|
192
|
+
e.closed || I(e);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
async function
|
|
195
|
+
async function P(e, t, n) {
|
|
196
196
|
for (; ; ) {
|
|
197
|
-
const r = await
|
|
198
|
-
if (!(n === 1 && a.protocol !==
|
|
197
|
+
const r = await W(e, t), a = z(r, n);
|
|
198
|
+
if (!(n === 1 && a.protocol !== E))
|
|
199
199
|
return a;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function O(e, t) {
|
|
203
203
|
const n = new Uint8Array(8 + t.byteLength), r = new DataView(n.buffer);
|
|
204
204
|
return r.setUint32(0, e), r.setUint32(4, n.byteLength), n.set(t, 8), n;
|
|
205
205
|
}
|
|
206
206
|
function Y(e, t, n, r) {
|
|
207
207
|
const a = new Uint8Array(16 + t.byteLength), i = new DataView(a.buffer);
|
|
208
|
-
return i.setUint32(0, e), i.setUint32(4, a.byteLength), i.setUint32(8,
|
|
208
|
+
return i.setUint32(0, e), i.setUint32(4, a.byteLength), i.setUint32(8, F), i.setUint16(12, n), i.setUint16(14, r), a.set(t, 16), a;
|
|
209
209
|
}
|
|
210
210
|
function z(e, t) {
|
|
211
211
|
const n = new DataView(e.buffer, e.byteOffset, e.byteLength), r = n.getUint32(0), a = n.getUint32(4), i = t >= 2 ? 16 : 8;
|
|
@@ -216,7 +216,7 @@ function z(e, t) {
|
|
|
216
216
|
payload: e.slice(i, a)
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function K(e) {
|
|
220
220
|
const t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = (t.getUint8(12) >> 4) * 4;
|
|
221
221
|
return {
|
|
222
222
|
sport: t.getUint16(0),
|
|
@@ -227,10 +227,10 @@ function Q(e) {
|
|
|
227
227
|
payload: e.slice(n)
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function m(e, t) {
|
|
231
231
|
return `${e}:${t}`;
|
|
232
232
|
}
|
|
233
|
-
class
|
|
233
|
+
class X {
|
|
234
234
|
constructor(t, n, r, a) {
|
|
235
235
|
this.webSocketUrl = t, this.session = n, this.deviceHello = r, this.log = a;
|
|
236
236
|
}
|
|
@@ -242,7 +242,9 @@ class K {
|
|
|
242
242
|
async connect() {
|
|
243
243
|
const t = new WebSocket(this.webSocketUrl);
|
|
244
244
|
t.binaryType = "arraybuffer", this.socket = t, t.onclose = () => {
|
|
245
|
-
this.closed = !0, this.log("Relay socket closed"), this.
|
|
245
|
+
this.closed = !0, this.log("Relay socket closed"), this.frameQueue.finally(() => {
|
|
246
|
+
this.pairRecordWaiter && (this.pairRecordWaiter.reject(new Error("Relay socket closed")), this.pairRecordWaiter = void 0);
|
|
247
|
+
});
|
|
246
248
|
}, await new Promise((n, r) => {
|
|
247
249
|
t.onopen = () => n(), t.onerror = () => r(new Error("WebSocket connection failed"));
|
|
248
250
|
}), t.onmessage = (n) => {
|
|
@@ -278,7 +280,7 @@ class K {
|
|
|
278
280
|
this.closed = !0, this.socket?.close();
|
|
279
281
|
}
|
|
280
282
|
enqueueFrame(t) {
|
|
281
|
-
this.frameQueue = this.frameQueue.then(() => this.handleFrame(
|
|
283
|
+
this.frameQueue = this.frameQueue.then(() => this.handleFrame(V(t))).catch((n) => {
|
|
282
284
|
this.log("Relay frame handling failed", n instanceof Error ? n.message : String(n));
|
|
283
285
|
});
|
|
284
286
|
}
|
|
@@ -288,26 +290,26 @@ class K {
|
|
|
288
290
|
await this.handleOpenStream(
|
|
289
291
|
t.requestId,
|
|
290
292
|
t.streamId,
|
|
291
|
-
|
|
293
|
+
h(t.payload).port
|
|
292
294
|
);
|
|
293
295
|
break;
|
|
294
296
|
case s.StreamData: {
|
|
295
297
|
const n = this.streams.get(t.streamId);
|
|
296
298
|
if (!n) throw new Error(`Unknown stream ${t.streamId}`);
|
|
297
|
-
await
|
|
299
|
+
await J(n, t.payload);
|
|
298
300
|
break;
|
|
299
301
|
}
|
|
300
302
|
case s.StreamClose:
|
|
301
303
|
this.streams.delete(t.streamId);
|
|
302
304
|
break;
|
|
303
305
|
case s.InstallProgress:
|
|
304
|
-
this.log(
|
|
306
|
+
this.log(ee(h(t.payload).message));
|
|
305
307
|
break;
|
|
306
308
|
case s.Error:
|
|
307
309
|
this.handleError(t.payload);
|
|
308
310
|
break;
|
|
309
311
|
case s.PairRecordReady:
|
|
310
|
-
this.handlePairRecordReady(
|
|
312
|
+
this.handlePairRecordReady(h(t.payload));
|
|
311
313
|
break;
|
|
312
314
|
case s.Ping:
|
|
313
315
|
await this.send({
|
|
@@ -328,7 +330,7 @@ class K {
|
|
|
328
330
|
}
|
|
329
331
|
async handleOpenStream(t, n, r) {
|
|
330
332
|
try {
|
|
331
|
-
const a = await
|
|
333
|
+
const a = await H(this.session, r);
|
|
332
334
|
this.streams.set(n, a), await this.send({
|
|
333
335
|
type: s.OpenResult,
|
|
334
336
|
requestId: t,
|
|
@@ -336,7 +338,10 @@ class K {
|
|
|
336
338
|
payload: c({ ok: !0 })
|
|
337
339
|
}), this.log(`Opened device stream ${n} to port ${r}`), this.pumpDeviceToServer(n, a);
|
|
338
340
|
} catch (a) {
|
|
339
|
-
this.log(
|
|
341
|
+
this.log(
|
|
342
|
+
`Open device stream ${n} failed`,
|
|
343
|
+
a instanceof Error ? a.message : String(a)
|
|
344
|
+
), await this.send({
|
|
340
345
|
type: s.OpenResult,
|
|
341
346
|
requestId: t,
|
|
342
347
|
streamId: n,
|
|
@@ -350,7 +355,7 @@ class K {
|
|
|
350
355
|
async pumpDeviceToServer(t, n) {
|
|
351
356
|
try {
|
|
352
357
|
for (; ; ) {
|
|
353
|
-
const r = await
|
|
358
|
+
const r = await G(n);
|
|
354
359
|
if (this.closed) return;
|
|
355
360
|
await this.send({
|
|
356
361
|
type: s.StreamData,
|
|
@@ -384,52 +389,60 @@ function Z(e) {
|
|
|
384
389
|
const t = new TextDecoder().decode(e);
|
|
385
390
|
try {
|
|
386
391
|
const n = JSON.parse(t);
|
|
387
|
-
return
|
|
392
|
+
return S(n.error ?? t);
|
|
388
393
|
} catch {
|
|
389
|
-
return
|
|
394
|
+
return S(t);
|
|
390
395
|
}
|
|
391
396
|
}
|
|
392
|
-
function
|
|
397
|
+
function S(e) {
|
|
393
398
|
return e.replace(/libimobiledevice/g, "").trim();
|
|
394
399
|
}
|
|
395
|
-
function
|
|
400
|
+
function ee(e) {
|
|
396
401
|
const t = "install status: ";
|
|
397
402
|
if (!e.startsWith(t))
|
|
398
403
|
return e;
|
|
399
|
-
const n = e.slice(t.length),
|
|
400
|
-
if (
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
return `Install progress: ${i.PercentComplete ? `${i.PercentComplete}% ` : ""}${o}`;
|
|
404
|
-
}
|
|
405
|
-
function ee(e) {
|
|
406
|
-
const t = {}, n = Array.from(e.children);
|
|
407
|
-
for (let r = 0; r < n.length; r += 2) {
|
|
408
|
-
const a = n[r], i = n[r + 1];
|
|
409
|
-
!a || a.tagName !== "key" || !i || (t[a.textContent ?? ""] = i.textContent ?? "");
|
|
404
|
+
const n = e.slice(t.length), r = d(n, "Error");
|
|
405
|
+
if (r) {
|
|
406
|
+
const o = d(n, "ErrorDescription");
|
|
407
|
+
return `Install error: ${r}${o ? ` — ${o}` : ""}`;
|
|
410
408
|
}
|
|
411
|
-
|
|
409
|
+
const a = d(n, "Status") ?? "Unknown", i = d(n, "PercentComplete");
|
|
410
|
+
return `Install progress: ${i ? `${i}% ` : ""}${a}`;
|
|
411
|
+
}
|
|
412
|
+
function d(e, t) {
|
|
413
|
+
const r = new RegExp(
|
|
414
|
+
`<key>\\s*${te(
|
|
415
|
+
t
|
|
416
|
+
)}\\s*</key>\\s*<(?:string|integer|real)>([\\s\\S]*?)</(?:string|integer|real)>`
|
|
417
|
+
).exec(e);
|
|
418
|
+
return r ? ne(r[1].trim()) : void 0;
|
|
419
|
+
}
|
|
420
|
+
function te(e) {
|
|
421
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
422
|
+
}
|
|
423
|
+
function ne(e) {
|
|
424
|
+
return e.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
412
425
|
}
|
|
413
|
-
async function
|
|
426
|
+
async function re({ log: e }) {
|
|
414
427
|
e("Selecting USB device");
|
|
415
|
-
const t = await
|
|
428
|
+
const t = await A(), n = ce(t);
|
|
416
429
|
return e(
|
|
417
430
|
"Selected USB device",
|
|
418
431
|
`${t.manufacturerName ?? ""} ${t.productName ?? ""} ${t.serialNumber ?? ""}`.trim()
|
|
419
432
|
), n;
|
|
420
433
|
}
|
|
421
|
-
async function
|
|
434
|
+
async function ae({ limbuildApiUrl: e, token: t, log: n, target: r }) {
|
|
422
435
|
const a = N(e, t);
|
|
423
436
|
let i;
|
|
424
437
|
try {
|
|
425
|
-
i = await
|
|
438
|
+
i = await $(a, r, n);
|
|
426
439
|
const o = await i.startPairing();
|
|
427
440
|
return { relay: i, pairRecord: o, target: r };
|
|
428
441
|
} catch (o) {
|
|
429
442
|
throw i?.close(), o;
|
|
430
443
|
}
|
|
431
444
|
}
|
|
432
|
-
async function
|
|
445
|
+
async function ie({
|
|
433
446
|
limbuildApiUrl: e,
|
|
434
447
|
token: t,
|
|
435
448
|
log: n,
|
|
@@ -439,18 +452,18 @@ async function re({
|
|
|
439
452
|
const i = N(e, t);
|
|
440
453
|
let o;
|
|
441
454
|
try {
|
|
442
|
-
return o = await
|
|
443
|
-
} catch (
|
|
444
|
-
throw o?.close(),
|
|
455
|
+
return o = await $(i, r, n), await o.startInstall(a), o;
|
|
456
|
+
} catch (f) {
|
|
457
|
+
throw o?.close(), f;
|
|
445
458
|
}
|
|
446
459
|
}
|
|
447
|
-
async function
|
|
460
|
+
async function oe(e, t) {
|
|
448
461
|
if (e) {
|
|
449
|
-
if (e.session && (
|
|
462
|
+
if (e.session && (I(e.session), e.session = void 0), e.claimedInterfaceNumber !== void 0)
|
|
450
463
|
try {
|
|
451
464
|
await e.device.releaseInterface(e.claimedInterfaceNumber), t?.("Released usbmux interface");
|
|
452
465
|
} catch (n) {
|
|
453
|
-
t?.("USB interface release failed",
|
|
466
|
+
t?.("USB interface release failed", g(n));
|
|
454
467
|
} finally {
|
|
455
468
|
e.claimedInterfaceNumber = void 0;
|
|
456
469
|
}
|
|
@@ -458,27 +471,27 @@ async function ae(e, t) {
|
|
|
458
471
|
try {
|
|
459
472
|
await e.device.close(), t?.("Closed USB device");
|
|
460
473
|
} catch (n) {
|
|
461
|
-
t?.("USB device close failed",
|
|
474
|
+
t?.("USB device close failed", g(n));
|
|
462
475
|
}
|
|
463
476
|
}
|
|
464
477
|
}
|
|
465
|
-
async function
|
|
466
|
-
await
|
|
467
|
-
const r = new
|
|
478
|
+
async function $(e, t, n) {
|
|
479
|
+
await se(t, n);
|
|
480
|
+
const r = new X(e, t.session, t.hello, n);
|
|
468
481
|
return await r.connect(), r;
|
|
469
482
|
}
|
|
470
|
-
async function
|
|
483
|
+
async function se(e, t) {
|
|
471
484
|
if (!e.session)
|
|
472
485
|
try {
|
|
473
|
-
e.candidate = await
|
|
486
|
+
e.candidate = await ue(e, t), e.session = await j(e.device, e.candidate), t("Created usbmux session");
|
|
474
487
|
} catch (n) {
|
|
475
|
-
throw await
|
|
488
|
+
throw await oe(e, t), n;
|
|
476
489
|
}
|
|
477
490
|
}
|
|
478
|
-
function
|
|
491
|
+
function ce(e) {
|
|
479
492
|
return {
|
|
480
493
|
device: e,
|
|
481
|
-
candidate:
|
|
494
|
+
candidate: le(e),
|
|
482
495
|
hello: {
|
|
483
496
|
serialNumber: e.serialNumber,
|
|
484
497
|
productName: e.productName,
|
|
@@ -488,7 +501,7 @@ function oe(e) {
|
|
|
488
501
|
}
|
|
489
502
|
};
|
|
490
503
|
}
|
|
491
|
-
async function
|
|
504
|
+
async function ue(e, t) {
|
|
492
505
|
const n = q(e.device);
|
|
493
506
|
if (n.length === 0) throw new Error("No Apple usbmux interface found.");
|
|
494
507
|
let r;
|
|
@@ -498,25 +511,25 @@ async function se(e, t) {
|
|
|
498
511
|
return e.device.opened || await e.device.open(), t(
|
|
499
512
|
"Claiming usbmux interface",
|
|
500
513
|
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}, alternate ${a.alternateSetting}, attempt ${i}`
|
|
501
|
-
), await
|
|
514
|
+
), await L(e.device, a), e.claimedInterfaceNumber = a.interfaceNumber, t(
|
|
502
515
|
"Claimed usbmux interface",
|
|
503
516
|
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}`
|
|
504
517
|
), a;
|
|
505
518
|
} catch (o) {
|
|
506
519
|
r = o, t(
|
|
507
520
|
"USB interface claim failed",
|
|
508
|
-
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}: ${
|
|
509
|
-
), await
|
|
521
|
+
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}: ${g(o)}`
|
|
522
|
+
), await fe(e), await de(250);
|
|
510
523
|
}
|
|
511
524
|
throw r instanceof Error ? r : new Error("Unable to claim any Apple usbmux interface.");
|
|
512
525
|
}
|
|
513
|
-
function
|
|
526
|
+
function le(e) {
|
|
514
527
|
const t = q(e)[0];
|
|
515
528
|
if (!t) throw new Error("No Apple usbmux interface found.");
|
|
516
529
|
return t;
|
|
517
530
|
}
|
|
518
531
|
function q(e) {
|
|
519
|
-
const t =
|
|
532
|
+
const t = C(e), n = e.configuration?.configurationValue;
|
|
520
533
|
return [
|
|
521
534
|
...t.filter((r) => r.configurationValue === n),
|
|
522
535
|
...t.filter((r) => r.configurationValue !== n)
|
|
@@ -526,10 +539,10 @@ function N(e, t) {
|
|
|
526
539
|
const n = new URL(e);
|
|
527
540
|
return n.protocol = n.protocol === "https:" ? "wss:" : "ws:", n.pathname = `${n.pathname.replace(/\/$/, "")}/device/ws`, t && n.searchParams.set("token", t), n.toString();
|
|
528
541
|
}
|
|
529
|
-
function
|
|
542
|
+
function g(e) {
|
|
530
543
|
return e instanceof Error ? e.message : String(e);
|
|
531
544
|
}
|
|
532
|
-
async function
|
|
545
|
+
async function fe(e) {
|
|
533
546
|
if (e.claimedInterfaceNumber !== void 0) {
|
|
534
547
|
try {
|
|
535
548
|
await e.device.releaseInterface(e.claimedInterfaceNumber);
|
|
@@ -543,30 +556,30 @@ async function ue(e) {
|
|
|
543
556
|
} catch {
|
|
544
557
|
}
|
|
545
558
|
}
|
|
546
|
-
function
|
|
559
|
+
function de(e) {
|
|
547
560
|
return new Promise((t) => setTimeout(t, e));
|
|
548
561
|
}
|
|
549
|
-
async function
|
|
550
|
-
return
|
|
562
|
+
async function pe(e = {}) {
|
|
563
|
+
return re({ log: e.log ?? b });
|
|
551
564
|
}
|
|
552
|
-
async function
|
|
553
|
-
return
|
|
565
|
+
async function we(e) {
|
|
566
|
+
return ae({ ...e, log: e.log ?? b });
|
|
554
567
|
}
|
|
555
|
-
async function
|
|
556
|
-
return
|
|
568
|
+
async function he(e) {
|
|
569
|
+
return ie({ ...e, log: e.log ?? b });
|
|
557
570
|
}
|
|
558
|
-
function
|
|
571
|
+
function b() {
|
|
559
572
|
}
|
|
560
573
|
export {
|
|
561
|
-
|
|
562
|
-
|
|
574
|
+
X as RelayClient,
|
|
575
|
+
oe as closeDeviceRelayTarget,
|
|
563
576
|
N as deviceRelayWebSocketUrl,
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
577
|
+
ge as getPairRecord,
|
|
578
|
+
be as normalizeUDID,
|
|
579
|
+
we as pairDevice,
|
|
580
|
+
Ue as putPairRecord,
|
|
581
|
+
pe as requestUSBAccess,
|
|
582
|
+
he as startDeviceInstall,
|
|
583
|
+
ie as startDeviceInstallRelay,
|
|
584
|
+
ae as startDevicePairingRelay
|
|
572
585
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),o=require("./index.cjs"),S=require("../browser-storage-jJaIht4K.js");function B({apiUrl:c,token:d,log:w=C}){const[e,h]=r.useState(),[l,y]=r.useState(),[g,u]=r.useState(),[p,s]=r.useState(),[D,v]=r.useState(!1),f=r.useRef(void 0),b=r.useRef(void 0),t=r.useRef(w);t.current=w;const i=r.useCallback(async()=>{f.current?.close(),f.current=void 0,await o.closeDeviceRelayTarget(b.current,t.current)},[]);r.useEffect(()=>{b.current=e},[e]),r.useEffect(()=>()=>{i()},[i]);const m=r.useCallback(async()=>{u("usb"),s(void 0),v(!1);let a;try{await i(),a=await o.requestUSBAccess({log:t.current});const n=await S.getPairRecord(a.hello.serialNumber);return h(a),y(n),t.current(n?"Pair record found":"No pair record found",a.hello.serialNumber),a}catch(n){await o.closeDeviceRelayTarget(a,t.current),h(void 0),y(void 0),s(R(n));return}finally{u(void 0)}},[i]),P=r.useCallback(async()=>{if(!c||!e)throw new Error("Select a USB device before pairing.");u("pair"),s(void 0),v(!1);try{await i();const a=await o.pairDevice({limbuildApiUrl:c,token:d,log:t.current,target:e}),n=await S.putPairRecord(a.pairRecord,{productName:e.hello.productName});return a.relay.close(),await o.closeDeviceRelayTarget(e,t.current),y(n),v(!1),t.current("Device paired","The pair record was stored locally in this browser."),n}catch(a){await o.closeDeviceRelayTarget(e,t.current),v(!0),s(R(a));return}finally{u(void 0)}},[c,i,e,d]),q=r.useCallback(async()=>{if(!c||!e||!l)throw new Error("Select and pair a USB device before starting installation.");u("install"),s(void 0);try{return await i(),f.current=await o.startDeviceInstall({limbuildApiUrl:c,token:d,log:t.current,target:e,pairRecord:l}),t.current("Device install started","Installation will continue through the connected iPhone."),f.current}catch(a){await o.closeDeviceRelayTarget(e,t.current),s(R(a));return}finally{u(void 0)}},[c,i,e,l,d]),A=r.useCallback(()=>{i(),t.current("Device relay stopped")},[i]);return{device:e,pairRecord:l,busyAction:g,error:p,pairConfirmationRequired:D,hasPairRecord:!!l,canPair:!!c&&!g&&!!e,canInstall:!!c&&!g&&!!e&&!!l,requestUSBAccess:m,pairBrowser:P,startInstallation:q,stopRelay:A,clearError:()=>s(void 0)}}function C(){}function R(c){return c instanceof Error?c.message:String(c)}exports.useDeviceInstallRelay=B;
|