@limrun/ui 0.7.0 → 0.9.0-rc.1

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.
Files changed (72) hide show
  1. package/README.md +9 -0
  2. package/dist/components/device-install/device-install-dialog.d.ts +5 -0
  3. package/dist/components/device-install/index.d.ts +2 -0
  4. package/dist/components/remote-control.d.ts +2 -0
  5. package/dist/core/device-install/apple/client.d.ts +16 -0
  6. package/dist/core/device-install/apple/crypto.d.ts +20 -0
  7. package/dist/core/device-install/apple/gsa-srp.d.ts +26 -0
  8. package/dist/core/device-install/apple/index.d.ts +5 -0
  9. package/dist/core/device-install/apple/provisioning.d.ts +150 -0
  10. package/dist/core/device-install/apple/relay.d.ts +33 -0
  11. package/dist/core/device-install/index.d.ts +4 -0
  12. package/dist/core/device-install/operations/index.d.ts +6 -0
  13. package/dist/core/device-install/operations/limbuild-client.d.ts +28 -0
  14. package/dist/core/device-install/operations/operations.d.ts +32 -0
  15. package/dist/core/device-install/operations/relay-client.d.ts +25 -0
  16. package/dist/core/device-install/operations/relay-protocol.d.ts +27 -0
  17. package/dist/core/device-install/operations/usbmux.d.ts +32 -0
  18. package/dist/core/device-install/operations/webusb.d.ts +21 -0
  19. package/dist/core/device-install/storage/browser-storage.d.ts +25 -0
  20. package/dist/core/device-install/storage/index.d.ts +1 -0
  21. package/dist/core/device-install/types.d.ts +48 -0
  22. package/dist/demo.d.ts +1 -0
  23. package/dist/device-install/index.cjs +9 -0
  24. package/dist/device-install/index.d.ts +3 -0
  25. package/dist/device-install/index.js +212 -0
  26. package/dist/device-install/react.cjs +1 -0
  27. package/dist/device-install/react.d.ts +1 -0
  28. package/dist/device-install/react.js +4 -0
  29. package/dist/device-install-dialog-CTwVViYY.js +2 -0
  30. package/dist/device-install-dialog-zzKJu7SM.mjs +328 -0
  31. package/dist/device-install-dialog.css +1 -0
  32. package/dist/hooks/index.d.ts +1 -0
  33. package/dist/hooks/use-device-install.d.ts +55 -0
  34. package/dist/index.cjs +1 -1
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.js +526 -510
  37. package/dist/use-device-install-CgrOKKyi.mjs +13042 -0
  38. package/dist/use-device-install-DDKRf6IL.js +23 -0
  39. package/index.html +199 -0
  40. package/package.json +54 -41
  41. package/src/components/device-install/device-install-dialog.css +244 -0
  42. package/src/components/device-install/device-install-dialog.tsx +363 -0
  43. package/src/components/device-install/index.ts +2 -0
  44. package/src/components/remote-control.css +1 -1
  45. package/src/components/remote-control.tsx +222 -110
  46. package/src/core/device-install/apple/client.ts +64 -0
  47. package/src/core/device-install/apple/crypto.ts +202 -0
  48. package/src/core/device-install/apple/gsa-srp.ts +127 -0
  49. package/src/core/device-install/apple/index.ts +5 -0
  50. package/src/core/device-install/apple/provisioning.ts +255 -0
  51. package/src/core/device-install/apple/relay.ts +305 -0
  52. package/src/core/device-install/index.ts +4 -0
  53. package/src/core/device-install/operations/index.ts +6 -0
  54. package/src/core/device-install/operations/limbuild-client.ts +104 -0
  55. package/src/core/device-install/operations/operations.ts +217 -0
  56. package/src/core/device-install/operations/relay-client.ts +255 -0
  57. package/src/core/device-install/operations/relay-protocol.ts +71 -0
  58. package/src/core/device-install/operations/usbmux.ts +270 -0
  59. package/src/core/device-install/operations/webusb-dom.d.ts +54 -0
  60. package/src/core/device-install/operations/webusb.ts +105 -0
  61. package/src/core/device-install/storage/browser-storage.ts +238 -0
  62. package/src/core/device-install/storage/index.ts +1 -0
  63. package/src/core/device-install/types.ts +65 -0
  64. package/src/demo.tsx +185 -0
  65. package/src/device-install/index.ts +3 -0
  66. package/src/device-install/react.ts +1 -0
  67. package/src/hooks/index.ts +1 -0
  68. package/src/hooks/use-device-install.ts +522 -0
  69. package/src/index.ts +2 -0
  70. package/tsconfig.json +25 -25
  71. package/tsconfig.node.json +25 -25
  72. package/vite.config.ts +6 -2
@@ -0,0 +1,363 @@
1
+ import { useId, useState, type ChangeEvent, type ReactNode } from 'react';
2
+ import { clsx } from 'clsx';
3
+ import { useDeviceInstall, type UseDeviceInstallOptions } from '../../hooks/use-device-install';
4
+ import type { DeviceInstallStep, DeviceInstallStepStatus } from '../../core/device-install';
5
+ import './device-install-dialog.css';
6
+
7
+ export type DeviceInstallDialogProps = UseDeviceInstallOptions & {
8
+ disabled?: boolean;
9
+ };
10
+
11
+ const steps: Array<{ id: DeviceInstallStep; title: string; description: string }> = [
12
+ {
13
+ id: 'build',
14
+ title: 'Start a device build',
15
+ description: 'Upload signing assets if needed, then follow the live build logs until the device build succeeds.',
16
+ },
17
+ {
18
+ id: 'usb',
19
+ title: 'Access USB procedures',
20
+ description: 'Allow WebUSB access to the connected iPhone from a Chromium browser on a secure origin.',
21
+ },
22
+ {
23
+ id: 'pair',
24
+ title: 'Pair with this browser',
25
+ description: 'Pair once and store the pair record locally so future installs can reuse it.',
26
+ },
27
+ {
28
+ id: 'install',
29
+ title: 'Start installation',
30
+ description: 'Relay the last successful device build to the paired iPhone.',
31
+ },
32
+ ];
33
+
34
+ export function DeviceInstallDialog({
35
+ disabled,
36
+ ...hookOptions
37
+ }: DeviceInstallDialogProps) {
38
+ const [open, setOpen] = useState(false);
39
+ const [appleAccountName, setAppleAccountName] = useState('');
40
+ const [applePassword, setApplePassword] = useState('');
41
+ const [appleTwoFactorCode, setAppleTwoFactorCode] = useState('');
42
+ const dialogTitleId = useId();
43
+ const deviceInstall = useDeviceInstall(hookOptions);
44
+
45
+ const updateSigningFiles = (field: 'certificateFile' | 'provisioningProfileFile', event: ChangeEvent<HTMLInputElement>) => {
46
+ deviceInstall.setSigningFiles({
47
+ [field]: event.currentTarget.files?.[0],
48
+ });
49
+ };
50
+
51
+ return (
52
+ <div className="lr-device-install">
53
+ <button
54
+ type="button"
55
+ className="lr-device-install__trigger"
56
+ disabled={disabled || !hookOptions.apiUrl}
57
+ onClick={() => setOpen(true)}
58
+ >
59
+ Install to iPhone
60
+ </button>
61
+
62
+ {open && (
63
+ <div className="lr-device-install__backdrop" role="presentation">
64
+ <section
65
+ aria-labelledby={dialogTitleId}
66
+ aria-modal="true"
67
+ className="lr-device-install__dialog"
68
+ role="dialog"
69
+ >
70
+ <header className="lr-device-install__header">
71
+ <div>
72
+ <h2 id={dialogTitleId}>Install to a real iPhone</h2>
73
+ <p>Follow each step to build, authorize USB, pair, and install from this browser.</p>
74
+ </div>
75
+ <button type="button" className="lr-device-install__icon-button" onClick={() => setOpen(false)}>
76
+ Close
77
+ </button>
78
+ </header>
79
+
80
+ {deviceInstall.error && <div className="lr-device-install__error">{deviceInstall.error}</div>}
81
+
82
+ <div className="lr-device-install__steps">
83
+ {steps.map((step, index) => (
84
+ <StepCard
85
+ key={step.id}
86
+ index={index + 1}
87
+ step={step}
88
+ active={deviceInstall.currentStep === step.id}
89
+ status={deviceInstall.stepStatuses[step.id]}
90
+ >
91
+ {step.id === 'build' && (
92
+ <div className="lr-device-install__step-body">
93
+ <div className="lr-device-install__grid">
94
+ <label className="lr-device-install__field">
95
+ <span>Apple ID</span>
96
+ <input
97
+ type="email"
98
+ autoComplete="username"
99
+ placeholder="name@example.com"
100
+ value={appleAccountName}
101
+ onChange={(event) => setAppleAccountName(event.currentTarget.value)}
102
+ />
103
+ </label>
104
+ <label className="lr-device-install__field">
105
+ <span>Apple ID password</span>
106
+ <input
107
+ type="password"
108
+ autoComplete="current-password"
109
+ placeholder="Password stays in this browser"
110
+ value={applePassword}
111
+ onChange={(event) => setApplePassword(event.currentTarget.value)}
112
+ />
113
+ </label>
114
+ <label className="lr-device-install__field">
115
+ <span>Generated .p12 password</span>
116
+ <input
117
+ type="password"
118
+ placeholder="Used when exporting Apple certificate"
119
+ onChange={(event) =>
120
+ deviceInstall.setSigningFiles({ certificatePassword: event.currentTarget.value })
121
+ }
122
+ />
123
+ </label>
124
+ </div>
125
+ <div className="lr-device-install__actions">
126
+ <button
127
+ type="button"
128
+ className="lr-device-install__secondary"
129
+ disabled={
130
+ disabled ||
131
+ !hookOptions.apiUrl ||
132
+ !appleAccountName ||
133
+ !applePassword ||
134
+ deviceInstall.busyAction === 'build'
135
+ }
136
+ onClick={() =>
137
+ void deviceInstall.startAppleIDLogin({
138
+ accountName: appleAccountName,
139
+ password: applePassword,
140
+ })
141
+ }
142
+ >
143
+ {deviceInstall.appleSigningStatus === 'authenticating'
144
+ ? 'Signing in...'
145
+ : 'Sign in with Apple ID'}
146
+ </button>
147
+ <span className="lr-device-install__hint">
148
+ Apple password is used only by browser-side SRP. Status: {deviceInstall.appleSigningStatus}
149
+ </span>
150
+ </div>
151
+ {deviceInstall.appleSigningStatus === 'two-factor-required' && (
152
+ <div className="lr-device-install__grid">
153
+ <label className="lr-device-install__field">
154
+ <span>Two-factor code</span>
155
+ <input
156
+ type="text"
157
+ inputMode="numeric"
158
+ autoComplete="one-time-code"
159
+ value={appleTwoFactorCode}
160
+ onChange={(event) => setAppleTwoFactorCode(event.currentTarget.value)}
161
+ />
162
+ </label>
163
+ <button
164
+ type="button"
165
+ className="lr-device-install__secondary"
166
+ disabled={!appleTwoFactorCode || deviceInstall.busyAction === 'build'}
167
+ onClick={() => void deviceInstall.submitAppleTwoFactorCode(appleTwoFactorCode)}
168
+ >
169
+ Submit Apple ID code
170
+ </button>
171
+ </div>
172
+ )}
173
+ {deviceInstall.appleTeams.length > 0 && (
174
+ <label className="lr-device-install__field">
175
+ <span>Apple Developer team</span>
176
+ <select
177
+ value={deviceInstall.selectedAppleTeamID ?? ''}
178
+ onChange={(event) =>
179
+ deviceInstall.setSelectedAppleTeamID(event.currentTarget.value || undefined)
180
+ }
181
+ >
182
+ {deviceInstall.appleTeams.map((team, index) => {
183
+ const teamID =
184
+ team.teamId ??
185
+ (team.providerId === undefined ? undefined : String(team.providerId)) ??
186
+ team.publicProviderId ??
187
+ '';
188
+ return (
189
+ <option key={`${teamID}-${index}`} value={teamID}>
190
+ {team.name ?? 'Apple Developer Team'} {teamID ? `(${teamID})` : ''}
191
+ </option>
192
+ );
193
+ })}
194
+ </select>
195
+ </label>
196
+ )}
197
+ <div className="lr-device-install__grid">
198
+ <label className="lr-device-install__field">
199
+ <span>Certificate (.p12)</span>
200
+ <input
201
+ type="file"
202
+ accept=".p12,application/x-pkcs12"
203
+ onChange={(event) => updateSigningFiles('certificateFile', event)}
204
+ />
205
+ </label>
206
+ <label className="lr-device-install__field">
207
+ <span>Provisioning profile</span>
208
+ <input
209
+ type="file"
210
+ accept=".mobileprovision"
211
+ onChange={(event) => updateSigningFiles('provisioningProfileFile', event)}
212
+ />
213
+ </label>
214
+ <label className="lr-device-install__field">
215
+ <span>Uploaded .p12 password</span>
216
+ <input
217
+ type="password"
218
+ placeholder="Export password"
219
+ onChange={(event) =>
220
+ deviceInstall.setSigningFiles({ certificatePassword: event.currentTarget.value })
221
+ }
222
+ />
223
+ </label>
224
+ </div>
225
+ <button
226
+ type="button"
227
+ className="lr-device-install__primary"
228
+ disabled={disabled || !deviceInstall.canBuild}
229
+ onClick={() => void deviceInstall.startDeviceBuild()}
230
+ >
231
+ {deviceInstall.busyAction === 'build' ? 'Starting build...' : 'Start device build'}
232
+ </button>
233
+ <details
234
+ className="lr-device-install__build-logs"
235
+ open={deviceInstall.buildLogPanelOpen}
236
+ onToggle={(event) => deviceInstall.setBuildLogPanelOpen(event.currentTarget.open)}
237
+ >
238
+ <summary>Build logs ({deviceInstall.buildStatus})</summary>
239
+ <pre>
240
+ {deviceInstall.buildLogs.length > 0
241
+ ? deviceInstall.buildLogs
242
+ .filter((line) => line.type !== 'meta')
243
+ .map((line) => line.data)
244
+ .join('\n')
245
+ : 'Build logs will appear here while the device build is running.'}
246
+ </pre>
247
+ </details>
248
+ </div>
249
+ )}
250
+
251
+ {step.id === 'usb' && (
252
+ <div className="lr-device-install__step-body">
253
+ <p>
254
+ WebUSB works in Chromium browsers on secure origins. Connect the iPhone over USB and approve
255
+ the browser permission prompt.
256
+ </p>
257
+ <button
258
+ type="button"
259
+ className="lr-device-install__primary"
260
+ disabled={disabled || !deviceInstall.canRequestUSBAccess}
261
+ onClick={() => void deviceInstall.requestUSBAccess()}
262
+ >
263
+ {deviceInstall.busyAction === 'usb' ? 'Selecting iPhone...' : 'Allow USB access'}
264
+ </button>
265
+ {deviceInstall.device && (
266
+ <div className="lr-device-install__device">
267
+ {`${deviceInstall.device.productName ?? 'iPhone'} ${
268
+ deviceInstall.device.serialNumber ?? ''
269
+ }`.trim()}
270
+ </div>
271
+ )}
272
+ </div>
273
+ )}
274
+
275
+ {step.id === 'pair' && (
276
+ <div className="lr-device-install__step-body">
277
+ {deviceInstall.pairConfirmationRequired && (
278
+ <p>
279
+ Unlock the iPhone and tap <strong>Trust</strong> in the system dialog, then confirm the pair
280
+ record.
281
+ </p>
282
+ )}
283
+ <button
284
+ type="button"
285
+ className="lr-device-install__primary"
286
+ disabled={disabled || !deviceInstall.canPairBrowser}
287
+ onClick={() => void deviceInstall.pairBrowser()}
288
+ >
289
+ {deviceInstall.busyAction === 'pair'
290
+ ? 'Pairing...'
291
+ : deviceInstall.pairConfirmationRequired
292
+ ? 'Confirm pair record'
293
+ : 'Pair browser'}
294
+ </button>
295
+ <p>
296
+ {deviceInstall.hasPairRecord
297
+ ? 'Pair record is stored locally. Installation is available.'
298
+ : 'Pair this browser once before installing.'}
299
+ </p>
300
+ </div>
301
+ )}
302
+
303
+ {step.id === 'install' && (
304
+ <div className="lr-device-install__step-body">
305
+ <button
306
+ type="button"
307
+ className="lr-device-install__primary"
308
+ disabled={disabled || !deviceInstall.canInstall}
309
+ onClick={() => void deviceInstall.startInstallation()}
310
+ >
311
+ {deviceInstall.busyAction === 'install' ? 'Installing...' : 'Install last build'}
312
+ </button>
313
+ <button type="button" className="lr-device-install__secondary" onClick={deviceInstall.stopRelay}>
314
+ Stop relay
315
+ </button>
316
+ </div>
317
+ )}
318
+ </StepCard>
319
+ ))}
320
+ </div>
321
+
322
+ <footer className="lr-device-install__logs">
323
+ <h3>Progress</h3>
324
+ <ol>
325
+ {deviceInstall.logs.map((entry, index) => (
326
+ <li key={`${index}-${entry.slice(0, 24)}`}>{entry}</li>
327
+ ))}
328
+ </ol>
329
+ </footer>
330
+ </section>
331
+ </div>
332
+ )}
333
+ </div>
334
+ );
335
+ }
336
+
337
+ function StepCard({
338
+ index,
339
+ step,
340
+ active,
341
+ status,
342
+ children,
343
+ }: {
344
+ index: number;
345
+ step: { id: DeviceInstallStep; title: string; description: string };
346
+ active: boolean;
347
+ status: DeviceInstallStepStatus;
348
+ children: ReactNode;
349
+ }) {
350
+ return (
351
+ <article className={clsx('lr-device-install__step', active && 'lr-device-install__step--active')}>
352
+ <div className="lr-device-install__step-header">
353
+ <div className="lr-device-install__step-number">{index}</div>
354
+ <div>
355
+ <h3>{step.title}</h3>
356
+ <p>{step.description}</p>
357
+ </div>
358
+ <span className={clsx('lr-device-install__status', `lr-device-install__status--${status}`)}>{status}</span>
359
+ </div>
360
+ {children}
361
+ </article>
362
+ );
363
+ }
@@ -0,0 +1,2 @@
1
+ export { DeviceInstallDialog, DeviceInstallDialog as DeviceInstallRelay } from './device-install-dialog';
2
+ export type { DeviceInstallDialogProps } from './device-install-dialog';
@@ -96,4 +96,4 @@
96
96
  .rc-retry-button:focus-visible {
97
97
  outline: 2px solid #2563eb;
98
98
  outline-offset: 2px;
99
- }
99
+ }