@limrun/ui 0.13.9 → 0.14.0-rc.2
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 +3 -3
- package/dist/app-store-relay/index.d.ts +3 -5
- package/dist/app-store-relay/index.js +56 -58
- package/dist/app-store-relay/react.cjs +1 -1
- package/dist/app-store-relay/react.d.ts +2 -2
- package/dist/app-store-relay/react.js +35 -34
- package/dist/client-BtC4n_qf.js +1 -0
- package/dist/client-CBX-hLnL.mjs +189 -0
- package/dist/core/device-install/apple/client.d.ts +5 -4
- package/dist/core/device-install/apple/relay.d.ts +24 -13
- package/dist/core/device-install/operations/limbuild-client.d.ts +2 -1
- package/dist/core/device-install/operations/operations.d.ts +19 -4
- package/dist/core/device-install/operations/relay-client.d.ts +2 -1
- package/dist/device-build/index.cjs +1 -1
- package/dist/device-build/index.js +1 -1
- package/dist/device-build/react.cjs +1 -1
- package/dist/device-build/react.d.ts +1 -0
- package/dist/device-build/react.js +34 -33
- package/dist/device-install/index.cjs +1 -1
- package/dist/device-install/index.d.ts +1 -1
- package/dist/device-install/index.js +121 -119
- package/dist/device-install/react.cjs +1 -1
- package/dist/device-install/react.d.ts +4 -3
- package/dist/device-install/react.js +58 -54
- package/dist/limbuild-client-BagK_FWE.mjs +83 -0
- package/dist/limbuild-client-CVDwq54z.js +1 -0
- package/package.json +1 -1
- package/src/app-store-relay/index.test.ts +19 -29
- package/src/app-store-relay/index.ts +6 -9
- package/src/app-store-relay/react.ts +5 -4
- package/src/core/device-install/apple/client.ts +22 -33
- package/src/core/device-install/apple/relay.ts +108 -148
- package/src/core/device-install/operations/limbuild-client.ts +3 -0
- package/src/core/device-install/operations/operations.ts +21 -9
- package/src/core/device-install/operations/relay-client.ts +3 -2
- package/src/device-build/react.ts +2 -0
- package/src/device-install/README.md +4 -4
- package/src/device-install/demo/demo.tsx +26 -28
- package/src/device-install/index.ts +1 -0
- package/src/device-install/react.ts +12 -6
- package/dist/client-ASLtHFLh.js +0 -1
- package/dist/client-CGdh8yoJ.mjs +0 -234
- package/dist/limbuild-client-CgEncrgx.js +0 -1
- package/dist/limbuild-client-D7U7w342.mjs +0 -81
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
const v = 1,
|
|
1
|
+
import { j as be, n as Ue, k as Se } from "../browser-storage-Cx9eW-bm.mjs";
|
|
2
|
+
const v = 1, f = 16, s = {
|
|
3
3
|
DeviceHello: 1,
|
|
4
4
|
OpenStream: 2,
|
|
5
5
|
OpenResult: 3,
|
|
@@ -13,40 +13,40 @@ const v = 1, u = 16, s = {
|
|
|
13
13
|
StartInstall: 11,
|
|
14
14
|
PairRecordReady: 12
|
|
15
15
|
};
|
|
16
|
-
function D(e) {
|
|
17
|
-
const t = new Uint8Array(u + e.payload.byteLength), n = new DataView(t.buffer);
|
|
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
|
-
}
|
|
20
16
|
function V(e) {
|
|
21
|
-
|
|
17
|
+
const t = new Uint8Array(f + e.payload.byteLength), n = new DataView(t.buffer);
|
|
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, f), t;
|
|
19
|
+
}
|
|
20
|
+
function A(e) {
|
|
21
|
+
if (e.byteLength < f)
|
|
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
24
|
if (n !== v)
|
|
25
25
|
throw new Error(`Unsupported relay protocol version ${n}`);
|
|
26
26
|
const r = t.getUint32(12);
|
|
27
|
-
if (e.byteLength !==
|
|
27
|
+
if (e.byteLength !== f + r)
|
|
28
28
|
throw new Error(
|
|
29
|
-
`Relay frame length mismatch: got ${e.byteLength}, expected ${
|
|
29
|
+
`Relay frame length mismatch: got ${e.byteLength}, expected ${f + r}`
|
|
30
30
|
);
|
|
31
31
|
return {
|
|
32
32
|
type: t.getUint8(1),
|
|
33
33
|
requestId: t.getUint32(4),
|
|
34
34
|
streamId: t.getUint32(8),
|
|
35
|
-
payload: e.slice(
|
|
35
|
+
payload: e.slice(f)
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function l(e) {
|
|
39
39
|
return new TextEncoder().encode(JSON.stringify(e));
|
|
40
40
|
}
|
|
41
41
|
function h(e) {
|
|
42
42
|
return JSON.parse(new TextDecoder().decode(e));
|
|
43
43
|
}
|
|
44
|
-
async function
|
|
44
|
+
async function C() {
|
|
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 L(e) {
|
|
50
50
|
const t = [], n = e.configuration?.configurationValue, r = e.configurations.find(
|
|
51
51
|
(a) => a.configurationValue === n
|
|
52
52
|
);
|
|
@@ -67,10 +67,10 @@ function U(e) {
|
|
|
67
67
|
});
|
|
68
68
|
return t;
|
|
69
69
|
}
|
|
70
|
-
async function
|
|
70
|
+
async function T(e, t) {
|
|
71
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 W(e) {
|
|
74
74
|
const t = e.endpoints.find(
|
|
75
75
|
(r) => r.direction === "out" && r.type === "bulk"
|
|
76
76
|
), n = e.endpoints.find(
|
|
@@ -86,32 +86,32 @@ async function R(e, t, n) {
|
|
|
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 B(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 E = 0,
|
|
96
|
-
async function
|
|
97
|
-
const { inEndpoint: n, outEndpoint: r } =
|
|
95
|
+
const E = 0, F = 2, k = 6, _ = 4277009102, y = 2, M = 4, d = 16, j = 49152;
|
|
96
|
+
async function H(e, t) {
|
|
97
|
+
const { inEndpoint: n, outEndpoint: r } = W(t), a = new Uint8Array(12), i = new DataView(a.buffer);
|
|
98
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),
|
|
99
|
+
const o = await P(e, n, 1), c = new DataView(o.payload.buffer, o.payload.byteOffset).getUint32(0), u = {
|
|
100
100
|
device: e,
|
|
101
101
|
candidate: t,
|
|
102
102
|
inEndpoint: n,
|
|
103
103
|
outEndpoint: r,
|
|
104
|
-
muxVersion:
|
|
104
|
+
muxVersion: c,
|
|
105
105
|
txSeq: 0,
|
|
106
106
|
rxSeq: 65535,
|
|
107
|
-
nextSport:
|
|
107
|
+
nextSport: j,
|
|
108
108
|
streams: /* @__PURE__ */ new Map(),
|
|
109
109
|
writeChain: Promise.resolve(),
|
|
110
110
|
closed: !1
|
|
111
111
|
};
|
|
112
|
-
return
|
|
112
|
+
return c >= 2 && await x(u, F, new Uint8Array([7])), Y(u), u;
|
|
113
113
|
}
|
|
114
|
-
async function
|
|
114
|
+
async function J(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 H(e, t) {
|
|
|
129
129
|
resolveOpened: n,
|
|
130
130
|
rejectOpened: r
|
|
131
131
|
};
|
|
132
|
-
return e.streams.set(m(t, a.sport), a), await
|
|
132
|
+
return e.streams.set(m(t, a.sport), a), await w(a, y, new Uint8Array()), await a.opened, a;
|
|
133
133
|
}
|
|
134
|
-
async function
|
|
134
|
+
async function G(e, t) {
|
|
135
135
|
if (e.session.closed)
|
|
136
136
|
throw new Error("usbmux session is closed.");
|
|
137
|
-
await
|
|
137
|
+
await w(e, d, t), e.seq += t.byteLength;
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
139
|
+
async function Q(e) {
|
|
140
140
|
if (e.queue.length > 0)
|
|
141
141
|
return e.queue.shift();
|
|
142
142
|
if (e.error)
|
|
@@ -152,7 +152,7 @@ function I(e) {
|
|
|
152
152
|
t.waiters.shift()(new Uint8Array());
|
|
153
153
|
e.streams.clear();
|
|
154
154
|
}
|
|
155
|
-
async function
|
|
155
|
+
async function w(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,11 +161,11 @@ 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 ?
|
|
164
|
+
const r = e.muxVersion >= 2 ? z(t, n, e.txSeq++, e.rxSeq) : O(t, n);
|
|
165
165
|
await R(e.device, e.outEndpoint, r);
|
|
166
166
|
}), e.writeChain;
|
|
167
167
|
}
|
|
168
|
-
async function
|
|
168
|
+
async function Y(e) {
|
|
169
169
|
try {
|
|
170
170
|
for (; ; ) {
|
|
171
171
|
if (e.closed) return;
|
|
@@ -173,19 +173,19 @@ async function Q(e) {
|
|
|
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 = X(t.payload), r = e.streams.get(m(n.sport, n.dport));
|
|
177
177
|
if (r) {
|
|
178
|
-
if (n.flags &
|
|
178
|
+
if (n.flags & M) {
|
|
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
181
|
e.streams.delete(m(r.dport, r.sport));
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
|
-
if ((n.flags & (y |
|
|
185
|
-
r.seq += 1, r.ack = n.seq + 1, await
|
|
184
|
+
if ((n.flags & (y | d)) === (y | d)) {
|
|
185
|
+
r.seq += 1, r.ack = n.seq + 1, await w(r, d, 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 w(r, d, new Uint8Array()), r.waiters.length > 0 ? r.waiters.shift()(n.payload) : r.queue.push(n.payload));
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
} catch {
|
|
@@ -194,7 +194,7 @@ async function Q(e) {
|
|
|
194
194
|
}
|
|
195
195
|
async function P(e, t, n) {
|
|
196
196
|
for (; ; ) {
|
|
197
|
-
const r = await
|
|
197
|
+
const r = await B(e, t), a = K(r, n);
|
|
198
198
|
if (!(n === 1 && a.protocol !== E))
|
|
199
199
|
return a;
|
|
200
200
|
}
|
|
@@ -203,11 +203,11 @@ 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
|
-
function
|
|
206
|
+
function z(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, _), i.setUint16(12, n), i.setUint16(14, r), a.set(t, 16), a;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function K(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;
|
|
212
212
|
return {
|
|
213
213
|
protocol: r,
|
|
@@ -216,7 +216,7 @@ function z(e, t) {
|
|
|
216
216
|
payload: e.slice(i, a)
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function X(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),
|
|
@@ -230,7 +230,7 @@ function K(e) {
|
|
|
230
230
|
function m(e, t) {
|
|
231
231
|
return `${e}:${t}`;
|
|
232
232
|
}
|
|
233
|
-
class
|
|
233
|
+
class Z {
|
|
234
234
|
constructor(t, n, r, a) {
|
|
235
235
|
this.webSocketUrl = t, this.session = n, this.deviceHello = r, this.log = a;
|
|
236
236
|
}
|
|
@@ -254,7 +254,7 @@ class X {
|
|
|
254
254
|
type: s.DeviceHello,
|
|
255
255
|
requestId: 0,
|
|
256
256
|
streamId: 0,
|
|
257
|
-
payload:
|
|
257
|
+
payload: l(this.deviceHello)
|
|
258
258
|
}), this.log("Connected WebSocket relay");
|
|
259
259
|
}
|
|
260
260
|
async startPairing() {
|
|
@@ -265,22 +265,22 @@ class X {
|
|
|
265
265
|
type: s.StartPairing,
|
|
266
266
|
requestId: 0,
|
|
267
267
|
streamId: 0,
|
|
268
|
-
payload:
|
|
268
|
+
payload: l({})
|
|
269
269
|
}), this.log("Pairing requested"), t;
|
|
270
270
|
}
|
|
271
|
-
async startInstall(t) {
|
|
271
|
+
async startInstall(t, n) {
|
|
272
272
|
await this.send({
|
|
273
273
|
type: s.StartInstall,
|
|
274
274
|
requestId: 0,
|
|
275
275
|
streamId: 0,
|
|
276
|
-
payload:
|
|
276
|
+
payload: l({ ...t, ...n })
|
|
277
277
|
}), this.log("Installation requested");
|
|
278
278
|
}
|
|
279
279
|
close() {
|
|
280
280
|
this.closed = !0, this.socket?.close();
|
|
281
281
|
}
|
|
282
282
|
enqueueFrame(t) {
|
|
283
|
-
this.frameQueue = this.frameQueue.then(() => this.handleFrame(
|
|
283
|
+
this.frameQueue = this.frameQueue.then(() => this.handleFrame(A(t))).catch((n) => {
|
|
284
284
|
this.log("Relay frame handling failed", n instanceof Error ? n.message : String(n));
|
|
285
285
|
});
|
|
286
286
|
}
|
|
@@ -296,14 +296,14 @@ class X {
|
|
|
296
296
|
case s.StreamData: {
|
|
297
297
|
const n = this.streams.get(t.streamId);
|
|
298
298
|
if (!n) throw new Error(`Unknown stream ${t.streamId}`);
|
|
299
|
-
await
|
|
299
|
+
await G(n, t.payload);
|
|
300
300
|
break;
|
|
301
301
|
}
|
|
302
302
|
case s.StreamClose:
|
|
303
303
|
this.streams.delete(t.streamId);
|
|
304
304
|
break;
|
|
305
305
|
case s.InstallProgress:
|
|
306
|
-
this.log(
|
|
306
|
+
this.log(te(h(t.payload).message));
|
|
307
307
|
break;
|
|
308
308
|
case s.Error:
|
|
309
309
|
this.handleError(t.payload);
|
|
@@ -322,7 +322,7 @@ class X {
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
handleError(t) {
|
|
325
|
-
const n =
|
|
325
|
+
const n = ee(t);
|
|
326
326
|
this.log("Server error", n), this.pairRecordWaiter && (this.pairRecordWaiter.reject(new Error(n)), this.pairRecordWaiter = void 0);
|
|
327
327
|
}
|
|
328
328
|
handlePairRecordReady(t) {
|
|
@@ -330,12 +330,12 @@ class X {
|
|
|
330
330
|
}
|
|
331
331
|
async handleOpenStream(t, n, r) {
|
|
332
332
|
try {
|
|
333
|
-
const a = await
|
|
333
|
+
const a = await J(this.session, r);
|
|
334
334
|
this.streams.set(n, a), await this.send({
|
|
335
335
|
type: s.OpenResult,
|
|
336
336
|
requestId: t,
|
|
337
337
|
streamId: n,
|
|
338
|
-
payload:
|
|
338
|
+
payload: l({ ok: !0 })
|
|
339
339
|
}), this.log(`Opened device stream ${n} to port ${r}`), this.pumpDeviceToServer(n, a);
|
|
340
340
|
} catch (a) {
|
|
341
341
|
this.log(
|
|
@@ -345,7 +345,7 @@ class X {
|
|
|
345
345
|
type: s.OpenResult,
|
|
346
346
|
requestId: t,
|
|
347
347
|
streamId: n,
|
|
348
|
-
payload:
|
|
348
|
+
payload: l({
|
|
349
349
|
ok: !1,
|
|
350
350
|
error: a instanceof Error ? a.message : String(a)
|
|
351
351
|
})
|
|
@@ -355,7 +355,7 @@ class X {
|
|
|
355
355
|
async pumpDeviceToServer(t, n) {
|
|
356
356
|
try {
|
|
357
357
|
for (; ; ) {
|
|
358
|
-
const r = await
|
|
358
|
+
const r = await Q(n);
|
|
359
359
|
if (this.closed) return;
|
|
360
360
|
await this.send({
|
|
361
361
|
type: s.StreamData,
|
|
@@ -369,7 +369,7 @@ class X {
|
|
|
369
369
|
type: s.StreamClose,
|
|
370
370
|
requestId: 0,
|
|
371
371
|
streamId: t,
|
|
372
|
-
payload:
|
|
372
|
+
payload: l({
|
|
373
373
|
reason: r instanceof Error ? r.message : String(r)
|
|
374
374
|
})
|
|
375
375
|
});
|
|
@@ -381,11 +381,11 @@ class X {
|
|
|
381
381
|
this.closed = !0;
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
this.socket.send(
|
|
384
|
+
this.socket.send(V(t));
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
function
|
|
388
|
+
function ee(e) {
|
|
389
389
|
const t = new TextDecoder().decode(e);
|
|
390
390
|
try {
|
|
391
391
|
const n = JSON.parse(t);
|
|
@@ -397,67 +397,69 @@ function Z(e) {
|
|
|
397
397
|
function S(e) {
|
|
398
398
|
return e.replace(/libimobiledevice/g, "").trim();
|
|
399
399
|
}
|
|
400
|
-
function
|
|
400
|
+
function te(e) {
|
|
401
401
|
const t = "install status: ";
|
|
402
402
|
if (!e.startsWith(t))
|
|
403
403
|
return e;
|
|
404
|
-
const n = e.slice(t.length), r =
|
|
404
|
+
const n = e.slice(t.length), r = p(n, "Error");
|
|
405
405
|
if (r) {
|
|
406
|
-
const o =
|
|
406
|
+
const o = p(n, "ErrorDescription");
|
|
407
407
|
return `Install error: ${r}${o ? ` — ${o}` : ""}`;
|
|
408
408
|
}
|
|
409
|
-
const a =
|
|
409
|
+
const a = p(n, "Status") ?? "Unknown", i = p(n, "PercentComplete");
|
|
410
410
|
return `Install progress: ${i ? `${i}% ` : ""}${a}`;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function p(e, t) {
|
|
413
413
|
const r = new RegExp(
|
|
414
|
-
`<key>\\s*${
|
|
414
|
+
`<key>\\s*${ne(
|
|
415
415
|
t
|
|
416
416
|
)}\\s*</key>\\s*<(?:string|integer|real)>([\\s\\S]*?)</(?:string|integer|real)>`
|
|
417
417
|
).exec(e);
|
|
418
|
-
return r ?
|
|
418
|
+
return r ? re(r[1].trim()) : void 0;
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function ne(e) {
|
|
421
421
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function re(e) {
|
|
424
424
|
return e.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, "&");
|
|
425
425
|
}
|
|
426
|
-
async function
|
|
426
|
+
async function ae({ log: e }) {
|
|
427
427
|
e("Selecting USB device");
|
|
428
|
-
const t = await
|
|
428
|
+
const t = await C(), n = ue(t);
|
|
429
429
|
return e(
|
|
430
430
|
"Selected USB device",
|
|
431
431
|
`${t.manufacturerName ?? ""} ${t.productName ?? ""} ${t.serialNumber ?? ""}`.trim()
|
|
432
432
|
), n;
|
|
433
433
|
}
|
|
434
|
-
async function
|
|
435
|
-
const
|
|
436
|
-
let
|
|
434
|
+
async function ie({ registryApiUrl: e, token: t, organizationId: n, log: r, target: a }) {
|
|
435
|
+
const i = N(e, t, n);
|
|
436
|
+
let o;
|
|
437
437
|
try {
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
return { relay:
|
|
441
|
-
} catch (
|
|
442
|
-
throw
|
|
438
|
+
o = await $(i, a, r);
|
|
439
|
+
const c = await o.startPairing();
|
|
440
|
+
return { relay: o, pairRecord: c, target: a };
|
|
441
|
+
} catch (c) {
|
|
442
|
+
throw o?.close(), c;
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
|
-
async function
|
|
446
|
-
|
|
445
|
+
async function oe({
|
|
446
|
+
registryApiUrl: e,
|
|
447
447
|
token: t,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
448
|
+
organizationId: n,
|
|
449
|
+
log: r,
|
|
450
|
+
target: a,
|
|
451
|
+
pairRecord: i,
|
|
452
|
+
installSource: o
|
|
451
453
|
}) {
|
|
452
|
-
const
|
|
453
|
-
let
|
|
454
|
+
const c = N(e, t, n);
|
|
455
|
+
let u;
|
|
454
456
|
try {
|
|
455
|
-
return
|
|
456
|
-
} catch (
|
|
457
|
-
throw
|
|
457
|
+
return u = await $(c, a, r), await u.startInstall(i, o), u;
|
|
458
|
+
} catch (D) {
|
|
459
|
+
throw u?.close(), D;
|
|
458
460
|
}
|
|
459
461
|
}
|
|
460
|
-
async function
|
|
462
|
+
async function se(e, t) {
|
|
461
463
|
if (e) {
|
|
462
464
|
if (e.session && (I(e.session), e.session = void 0), e.claimedInterfaceNumber !== void 0)
|
|
463
465
|
try {
|
|
@@ -476,22 +478,22 @@ async function oe(e, t) {
|
|
|
476
478
|
}
|
|
477
479
|
}
|
|
478
480
|
async function $(e, t, n) {
|
|
479
|
-
await
|
|
480
|
-
const r = new
|
|
481
|
+
await ce(t, n);
|
|
482
|
+
const r = new Z(e, t.session, t.hello, n);
|
|
481
483
|
return await r.connect(), r;
|
|
482
484
|
}
|
|
483
|
-
async function
|
|
485
|
+
async function ce(e, t) {
|
|
484
486
|
if (!e.session)
|
|
485
487
|
try {
|
|
486
|
-
e.candidate = await
|
|
488
|
+
e.candidate = await le(e, t), e.session = await H(e.device, e.candidate), t("Created usbmux session");
|
|
487
489
|
} catch (n) {
|
|
488
|
-
throw await
|
|
490
|
+
throw await se(e, t), n;
|
|
489
491
|
}
|
|
490
492
|
}
|
|
491
|
-
function
|
|
493
|
+
function ue(e) {
|
|
492
494
|
return {
|
|
493
495
|
device: e,
|
|
494
|
-
candidate:
|
|
496
|
+
candidate: fe(e),
|
|
495
497
|
hello: {
|
|
496
498
|
serialNumber: e.serialNumber,
|
|
497
499
|
productName: e.productName,
|
|
@@ -501,7 +503,7 @@ function ce(e) {
|
|
|
501
503
|
}
|
|
502
504
|
};
|
|
503
505
|
}
|
|
504
|
-
async function
|
|
506
|
+
async function le(e, t) {
|
|
505
507
|
const n = q(e.device);
|
|
506
508
|
if (n.length === 0) throw new Error("No Apple usbmux interface found.");
|
|
507
509
|
let r;
|
|
@@ -511,7 +513,7 @@ async function ue(e, t) {
|
|
|
511
513
|
return e.device.opened || await e.device.open(), t(
|
|
512
514
|
"Claiming usbmux interface",
|
|
513
515
|
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}, alternate ${a.alternateSetting}, attempt ${i}`
|
|
514
|
-
), await
|
|
516
|
+
), await T(e.device, a), e.claimedInterfaceNumber = a.interfaceNumber, t(
|
|
515
517
|
"Claimed usbmux interface",
|
|
516
518
|
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}`
|
|
517
519
|
), a;
|
|
@@ -519,30 +521,30 @@ async function ue(e, t) {
|
|
|
519
521
|
r = o, t(
|
|
520
522
|
"USB interface claim failed",
|
|
521
523
|
`configuration ${a.configurationValue}, interface ${a.interfaceNumber}: ${g(o)}`
|
|
522
|
-
), await
|
|
524
|
+
), await de(e), await pe(250);
|
|
523
525
|
}
|
|
524
526
|
throw r instanceof Error ? r : new Error("Unable to claim any Apple usbmux interface.");
|
|
525
527
|
}
|
|
526
|
-
function
|
|
528
|
+
function fe(e) {
|
|
527
529
|
const t = q(e)[0];
|
|
528
530
|
if (!t) throw new Error("No Apple usbmux interface found.");
|
|
529
531
|
return t;
|
|
530
532
|
}
|
|
531
533
|
function q(e) {
|
|
532
|
-
const t =
|
|
534
|
+
const t = L(e), n = e.configuration?.configurationValue;
|
|
533
535
|
return [
|
|
534
536
|
...t.filter((r) => r.configurationValue === n),
|
|
535
537
|
...t.filter((r) => r.configurationValue !== n)
|
|
536
538
|
];
|
|
537
539
|
}
|
|
538
|
-
function N(e, t) {
|
|
539
|
-
const
|
|
540
|
-
return
|
|
540
|
+
function N(e, t, n) {
|
|
541
|
+
const r = new URL(e);
|
|
542
|
+
return r.protocol = r.protocol === "https:" ? "wss:" : "ws:", r.pathname = `${r.pathname.replace(/\/$/, "")}/ios/device/ws`, t && r.searchParams.set("token", t), n && r.searchParams.set("organization", n), r.toString();
|
|
541
543
|
}
|
|
542
544
|
function g(e) {
|
|
543
545
|
return e instanceof Error ? e.message : String(e);
|
|
544
546
|
}
|
|
545
|
-
async function
|
|
547
|
+
async function de(e) {
|
|
546
548
|
if (e.claimedInterfaceNumber !== void 0) {
|
|
547
549
|
try {
|
|
548
550
|
await e.device.releaseInterface(e.claimedInterfaceNumber);
|
|
@@ -556,30 +558,30 @@ async function fe(e) {
|
|
|
556
558
|
} catch {
|
|
557
559
|
}
|
|
558
560
|
}
|
|
559
|
-
function
|
|
561
|
+
function pe(e) {
|
|
560
562
|
return new Promise((t) => setTimeout(t, e));
|
|
561
563
|
}
|
|
562
|
-
async function
|
|
563
|
-
return
|
|
564
|
-
}
|
|
565
|
-
async function we(e) {
|
|
566
|
-
return ae({ ...e, log: e.log ?? b });
|
|
564
|
+
async function we(e = {}) {
|
|
565
|
+
return ae({ log: e.log ?? b });
|
|
567
566
|
}
|
|
568
567
|
async function he(e) {
|
|
569
568
|
return ie({ ...e, log: e.log ?? b });
|
|
570
569
|
}
|
|
570
|
+
async function ye(e) {
|
|
571
|
+
return oe({ ...e, log: e.log ?? b });
|
|
572
|
+
}
|
|
571
573
|
function b() {
|
|
572
574
|
}
|
|
573
575
|
export {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
+
Z as RelayClient,
|
|
577
|
+
se as closeDeviceRelayTarget,
|
|
576
578
|
N as deviceRelayWebSocketUrl,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
579
|
+
be as getPairRecord,
|
|
580
|
+
Ue as normalizeUDID,
|
|
581
|
+
he as pairDevice,
|
|
582
|
+
Se as putPairRecord,
|
|
583
|
+
we as requestUSBAccess,
|
|
584
|
+
ye as startDeviceInstall,
|
|
585
|
+
oe as startDeviceInstallRelay,
|
|
586
|
+
ie as startDevicePairingRelay
|
|
585
587
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),o=require("./index.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),o=require("./index.cjs"),p=require("../browser-storage-jJaIht4K.js");function C({apiUrl:c,token:d,organizationId:v,log:h=E}){const[e,S]=r.useState(),[l,g]=r.useState(),[R,u]=r.useState(),[D,n]=r.useState(),[P,f]=r.useState(!1),y=r.useRef(void 0),b=r.useRef(void 0),t=r.useRef(h);t.current=h;const s=r.useCallback(async()=>{y.current?.close(),y.current=void 0,await o.closeDeviceRelayTarget(b.current,t.current)},[]);r.useEffect(()=>{b.current=e},[e]),r.useEffect(()=>()=>{s()},[s]);const m=r.useCallback(async()=>{u("usb"),n(void 0),f(!1);let a;try{await s(),a=await o.requestUSBAccess({log:t.current});const i=await p.getPairRecord(a.hello.serialNumber);return S(a),g(i),t.current(i?"Pair record found":"No pair record found",a.hello.serialNumber),a}catch(i){await o.closeDeviceRelayTarget(a,t.current),S(void 0),g(void 0),n(w(i));return}finally{u(void 0)}},[s]),q=r.useCallback(async()=>{if(!c||!e)throw new Error("Select a USB device before pairing.");u("pair"),n(void 0),f(!1);try{await s();const a=await o.pairDevice({registryApiUrl:c,token:d,organizationId:v,log:t.current,target:e}),i=await p.putPairRecord(a.pairRecord,{productName:e.hello.productName});return a.relay.close(),await o.closeDeviceRelayTarget(e,t.current),g(i),f(!1),t.current("Device paired","The pair record was stored locally in this browser."),i}catch(a){await o.closeDeviceRelayTarget(e,t.current),f(!0),n(w(a));return}finally{u(void 0)}},[c,s,e,v,d]),A=r.useCallback(async a=>{if(!c||!e||!l)throw new Error("Select and pair a USB device before starting installation.");u("install"),n(void 0);try{return await s(),y.current=await o.startDeviceInstall({registryApiUrl:c,token:d,organizationId:v,log:t.current,target:e,pairRecord:l,installSource:a}),t.current("Device install started","Installation will continue through the connected iPhone."),y.current}catch(i){await o.closeDeviceRelayTarget(e,t.current),n(w(i));return}finally{u(void 0)}},[c,s,e,v,l,d]),B=r.useCallback(()=>{s(),t.current("Device relay stopped")},[s]);return{device:e,pairRecord:l,busyAction:R,error:D,pairConfirmationRequired:P,hasPairRecord:!!l,canPair:!!c&&!R&&!!e,canInstall:!!c&&!R&&!!e&&!!l,requestUSBAccess:m,pairBrowser:q,startInstallation:A,stopRelay:B,clearError:()=>n(void 0)}}function E(){}function w(c){return c instanceof Error?c.message:String(c)}exports.useDeviceInstallRelay=C;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { DeviceInstallLog, DeviceRelayTarget, RelayClient, StoredPairRecord } from './index';
|
|
1
|
+
import { DeviceInstallLog, DeviceRelayTarget, InstallSource, RelayClient, StoredPairRecord } from './index';
|
|
2
2
|
export type DeviceInstallRelayBusyAction = 'usb' | 'pair' | 'install';
|
|
3
3
|
export type UseDeviceInstallRelayOptions = {
|
|
4
4
|
apiUrl?: string;
|
|
5
5
|
token?: string;
|
|
6
|
+
organizationId?: string;
|
|
6
7
|
log?: DeviceInstallLog;
|
|
7
8
|
};
|
|
8
9
|
export type UseDeviceInstallRelayResult = {
|
|
@@ -16,8 +17,8 @@ export type UseDeviceInstallRelayResult = {
|
|
|
16
17
|
canInstall: boolean;
|
|
17
18
|
requestUSBAccess: () => Promise<DeviceRelayTarget | undefined>;
|
|
18
19
|
pairBrowser: () => Promise<StoredPairRecord | undefined>;
|
|
19
|
-
startInstallation: () => Promise<RelayClient | undefined>;
|
|
20
|
+
startInstallation: (installSource: InstallSource) => Promise<RelayClient | undefined>;
|
|
20
21
|
stopRelay: () => void;
|
|
21
22
|
clearError: () => void;
|
|
22
23
|
};
|
|
23
|
-
export declare function useDeviceInstallRelay({ apiUrl, token, log, }: UseDeviceInstallRelayOptions): UseDeviceInstallRelayResult;
|
|
24
|
+
export declare function useDeviceInstallRelay({ apiUrl, token, organizationId, log, }: UseDeviceInstallRelayOptions): UseDeviceInstallRelayResult;
|