Repository navigation
Commit 56174d6
authored
feat(vite): choose each device's dev server origin, with the iOS USB tunnel (#6210)
When the project's @nativescript/vite lists the platform under nativescriptCli.devServerFile, the CLI chooses each device's dev server origin and delivers { origin, token } as dev-server.json next to bundle.mjs, per device. First match: NS_HMR_HOST; Android with adb reverse working, 127.0.0.1; an emulator without reverse, 10.0.2.2; an iOS/visionOS simulator, 127.0.0.1; a physical iOS device with an open USB tunnel, the Mac's end of that tunnel (http://[fdXX::2]:5173); otherwise the Mac's LAN IPv4. NS_HTTPS gives an https origin, NS_HMR_NO_ADB_REVERSE skips the reverse and NS_HMR_PREFER_LAN_HOST gives every device the LAN origin. The CLI generates the dev server's WebSocket token once per platform and passes it as NS_HMR_TOKEN.
Delivery: written into the installed simulator .app after the sync and after a reinstall; an app/dev-server.json entry in a physical iOS device's sync.zip; on Android, sent from memory over the livesync socket on every full sync (AndroidLivesyncTool.sendFileFromBuffer). A native rebuild or recovery reinstall delivers the file again, and a failed delivery is retried on the device's next sync.
USB tunnel: for each physical iOS 17+ / visionOS device on USB, the CLI holds the CoreDevice tunnel with `devicectl device notification observe` and waits (bounded) for it to connect. When a tunnel drops, the CLI opens a new one for a device still on USB (at most once a minute per device), otherwise chooses another origin, rewrites that device's dev-server.json and restarts only its app. Hot updates over the tunnel need @valor/nativescript-websockets 2.0.4 or later.
An @nativescript/vite without devServerFile keeps the bundle-baked origin and the NS_ADB_* hand-off, and opens no tunnel.1 parent b4c2654 commit 56174d6
26 files changed
Lines changed: 3115 additions & 71 deletions
File tree
- lib
- contracts
- internal
- controllers
- definitions
- services
- bundler
- device
- ios
- livesync
- test
- controllers
- services
- bundler
- ios
- livesync
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
694 | 696 | | |
695 | 697 | | |
696 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
697 | 715 | | |
698 | 716 | | |
699 | 717 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
0 commit comments