Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Document the cards in ARCHITECTURE.md, fix two stale source paths in comments
v0lumehifc008b31c102
diff --git a/frontend-qt/nspb_qt/style.py b/frontend-qt/nspb_qt/style.pyindex 44a7d1e7..5dff7e5c 100644--- a/frontend-qt/nspb_qt/style.py+++ b/frontend-qt/nspb_qt/style.py@@ -1,7 +1,7 @@"""Visual language: the Mac launcher's near-black look with a cream accent, in Qt style sheets.The palette, the Manrope typeface and the control shapes follow the SwiftUI launcher-(`frontend/Sources/NXLauncher/LauncherPalette.swift` and `frontend/Sources/NX2Apple/LauncherStyles.swift`),+(`frontend/Sources/NXLauncher/LauncherPalette.swift` and `frontend/Sources/NXLauncher/LauncherStyles.swift`),so the two front ends stay recognisable as the same product. The translucent white fills of theMac controls are pre-mixed here into opaque colours, since a Qt style sheet has no cheap overlay."""diff --git a/frontend/ARCHITECTURE.md b/frontend/ARCHITECTURE.mdindex ff93d6e9..310e3711 100644--- a/frontend/ARCHITECTURE.md+++ b/frontend/ARCHITECTURE.md@@ -13,9 +13,9 @@ The plan and the steps are in [LNPANDY/NX2Apple#387](https://github.com/LNPANDY/## Where it stands-Step 1 of #387 made the targets and moved the files that already fit. Step 2 moved the language out of `BuildModel` into the `Localizer` store. Step 3 moved the build log into the `BuildLog` store. Step 4 moved the pure logic into `NXCore`. Step 5 added the first services. Step 6 added the first store, `AppUpdateStore`, the reference for the others. Step 7 moved the rest one store per PR: the repository, the engine sync, the dependencies, the devices, then the build. `BuildModel` is gone. The views still live in the app target and move with step 8.+Step 1 of #387 made the targets and moved the files that already fit. Step 2 moved the language out of `BuildModel` into the `Localizer` store. Step 3 moved the build log into the `BuildLog` store. Step 4 moved the pure logic into `NXCore`. Step 5 added the first services. Step 6 added the first store, `AppUpdateStore`, the reference for the others. Step 7 moved the rest one store per PR: the repository, the engine sync, the dependencies, the devices, then the build. `BuildModel` is gone. Step 8 split `BuilderView` into one view per card and deleted `ContentView.swift`. The window's root view is `LauncherView`.-- `LauncherStores` (app target, `LauncherStores.swift`) is the wiring and nothing else: it creates the services and the stores, connects them and hands them to the views. Every store is a `let`. It holds no logic and no `@Published` state. The views that still live in the app target (`LauncherView`, `BuilderView`, the sheets) take the stores they show as parameters, so they cannot leave the app target before step 8.+- `LauncherStores` (app target, `LauncherStores.swift`) is the wiring and nothing else: it creates the services and the stores, connects them and hands them to the views. Every store is a `let`. It holds no logic and no `@Published` state. The views take the stores they show as parameters.- `NXCore` holds the value types and static functions that need only Foundation: app and engine update parsing, `Localization.swift`, the release notes, the device and signing tools, the cloud folder and saves migration, the bundled tools, input staging, the build target and the pipe reader. Step 4 added four types: `TitleID` (parse a title ID from a file name, its owner, the update version, the build key), `GameInputs` (classify files into the four rows, row mismatch, allowed file types), `BuildProgress` (stage lines, progress details, durations, the steps of Xcode and the install, failure info) and `Toolchain` (probing Python, the venv, dotnet and Xcode, and the dependency rows `Dep`). `Stage` and `StepState` moved with `BuildProgress`. Step 5 added the first services (step 6 added `ReleaseSource`, see below): `ProcessRunner` (a protocol, with `SystemProcessRunner` as the real one), `ProcessGroups` (the process groups that Stop and quitting end) and `GitCheckout` (a protocol, with `SystemGitCheckout`, plus `GitRules` for the decisions that need no git). `ProcessRunner` is where a build process starts: `capture` runs to the end and keeps the output, `stream` hands out lines, `start` returns at once and can lead a process group. `LauncherStores` creates a runner and a checkout and hands them to the stores that use them: the clone, fetch, pull and adoption of a ZIP copy (`RepoStore`), the build run, the tools of a stage, the archive step and `openOnDevice` (`BuildStore`). `Toolchain`, `Diagnostics`, `OlderTools`, `Uninstall`, `EngineLayout.runSync` and the update staging take a runner or a checkout as a parameter with the real one as default. Tests pass in a fake. These still start a `Process` themselves and move with the step that owns them: `EngineInstaller` (ditto, in `NXCore` since the engine sync store), the administrator prompt in `LiveOnboardingDriver` and the game start in `LiveConsoleDriver`. The tools of the device store (`DeviceTools`, `AppSignature`, `DeviceControl`, `ShellInstaller`) moved onto `ProcessRunner` with the device store, see below. What reads `OnboardingDefaults` (`needsIOSPlatform`, the platform choice that asks for a new dependency check) stays in the app target, in `LauncherStores`, because the guided setup owns those keys.- Step 6 moved the self-update out of `BuildModel`. `AppUpdate` (`NXCore`) now also holds the release parsing (`release(fromJSON:)`, `check(latest:current:)`), the version compare (`isNewer`), the asset names, the staging of a download (`stage`, `StageFailure`) and the install, which clears the quarantine flag through a `ProcessRunner`. `ReleaseSource` is the second service (a protocol, with `GitHubReleases` as the real one): the latest release and the download. `Uninstall` moved to `NXCore` too, because the store holds its plan. `AppUpdate.relaunch` still starts its detached shell itself, and the store gets it as a closure.- `NXCoreTests` tests `NXCore` alone. It links no other target, so these tests run without SwiftUI. New tests of pure logic go there.@@ -27,8 +27,8 @@ Step 1 of #387 made the targets and moved the files that already fit. Step 2 mov- `NXModel` holds `DeviceStore` (step 7, devices): the paired devices and their refresh (`devicectl list devices`), the signing teams, whether the listing ran (`checked`), the chosen install device and team (saved in the defaults), and the copy flow of the shared app: the question before the game data goes over (`shellCopy`, answered with `answerCopy`) and the wait for a cable (`shellWaiting`, `cancelWait`). The install runs on a background queue, so `askCopy`, `setWaiting` and `waitCancelled` are the blocking bridge it calls. `xcrun` is an injected value of the store (and of `LauncherStores.init`), no longer a loose property that tests assign. `LauncherStores` creates the store with its runner. The listings are closures with the real ones as default (`listDevices`, `readTeams`), so a test gives the store devices and teams. `LauncherStores.init(xcrun:volumesRoot:)` takes the two values that were loose hooks. `volumesRoot` (where external drives are mounted) is read by the failure classifier, not by a device tool, so it is an injected `let` of the build store. The views that show the install target (the Builds page) and the copy card observe the store. `NXCore` got what the store needs: `ShellCopyPlan`, `ShellCopyDecision` and `ShellConnection` (`ShellInstall.Connection` is an alias), `DeviceControl` (devicectl for the save transfer) and `LockedFlag`. `ProcessLaunch` got a `timeout` and an `input`, `ProcessResult` got `timedOut`, and `ProcessRunner` got one primitive, `streamLines` (merged output as whole lines, a callback when the process has started, an optional process group), with fakes and tests. `DeviceTools`, `AppSignature`, `DeviceControl` and `ShellInstaller` start their tools through a runner now. `NXModelTests` tests the store without SwiftUI, and `NXCoreTests` tests the tools against a fake runner.- `NXModel` holds `BuildStore` (step 7, build, the last store): the build inputs (the four rows `Slot`, the game folder, the output folder), the target, the stage list and whether a build runs, the handling of the script's JSON events (`ingest`), the run (the script's arguments and environment, stopping, the archive step), the install hand-off (`installShell`, the retry of the game data, the reinstall, the re-sign, the IPA, `openOnDevice`), the failure the card shows (`noteFailure`, `noteInstallFailure`), "Build anyway" and the fix buttons, the stale frameworks question and the files a drop adds. It decides whether a build may start (`canBuild`, and the checks at the top of `startBuild`). It is a class with six `BuildStore+` files, because no file may pass 800 lines. It gets what it needs through narrow protocols: `RepoLocation`, `DependencyInstalling` (`DependencyStatus` plus the install the fix buttons run), `EngineSyncing` (the sync a stale `engine/` needs) and `InstallTarget` (the device, the team, the teams the Mac knows and the copy flow). `DependencyStore`, `EngineSyncStore` and `DeviceStore` conform. AppKit reaches it as closures: the open, folder and save panels (`choosePaths`, `chooseFolder`, `chooseSaveLocation`), the notice (`showNotice`), the Finder (`revealFolder`, `openApp`) and `targetChanged`, which `LauncherStores` answers with a new dependency check when a Mac-only setup changes target. `NXCore` got what it needs: `ShellInstall`, `ShellLibrary`, `ShellInstaller` and `BannerCache` (the install of the shared app), `BuildFailureClassifier`, `VolumePath`, and `RomFSArchive` and `BuildCommands` (the archive stamp, the add-on content copy, the reinstall and IPA commands, the tools' PATH). `ShellCLI` (the terminal install) stays in the app target. `NXModelTests` tests the store with fake stores and a fake runner, without SwiftUI. The build's process start and its output callbacks are tested in the app target through the real build script stand-ins in `ShellInstallTests`.- `NXModel` also holds `BuildLog`: the log text, its tail trimming and the line buffer. `BuildStore` holds it in a `let` and does not publish it, and only `BuildLogView` (in `NXLauncher`) observes it. A log line redraws the log and no game card. `LauncherPerformanceTests` writes 1000 lines during a build and allows 0 cards.-- `NXLauncher` holds the views and styles that do not need the stores: `LauncherPalette`, `Typography`, `LauncherStyles`, `LauncherDropdown`, `PadFocus` and `EmbeddedFonts`.-- `NX2Apple` holds everything else: the wiring (`LauncherStores`), the views, the panels and the drivers.+- `NXLauncher` holds the views and styles that need only `NXModel`, `NXCore`, SwiftUI and AppKit (step 8). The styles: `LauncherPalette`, `Typography`, `LauncherStyles`, `LauncherDropdown`, `PadFocus` and `EmbeddedFonts`. The pieces of a card (`LauncherCard.swift`: `CardGroup`, `CardRow`, `CardDivider`, `CardDisclosure`, `CardPageHeading` and `LauncherPageScroll`, the scrolling column of a page). One view per card of the Builds page: `SetupHintCard`, `TargetCard`, `InstallCard`, `LogCard` (with `BuildLogView`), `ActionCard`, `OutcomeCard` and `ProgressCard`, and the cards that belong beside them, `ShellCopyCard`, `BuildFailureCard` and `EngineSyncBanner`. One view per card of the Settings page: `ControlsCard`, `ToolsCard` and `AppCard`. Also `UpdateSheet`, the `GameFilesDrop` target, `RowScroller` and `DockProgress`. Each card declares the stores it shows as `@ObservedObject` parameters and observes nothing else. A value from another store comes as a value (`buildRunning`, `shellCachePath`) or a closure, never through another store. What only the app can give a card comes as a binding or a view builder: the switches kept in the app's defaults (`AppCard`, `ControlsCard`) and the diagnostics button (`ToolsCard`). `AppCard.languageCodes` lists the languages of the picker.+- `NX2Apple` holds everything else: the wiring (`LauncherStores`), the root view `LauncherView` and the views that need an app type, the panels and the drivers. `CardPages` is the scrolling column both settings and builds pages share (it keeps the scroll position, the open log and the open extra rows when someone goes from one page to the other) and `BuildPage` and `SettingsPage` only list the cards of their page. `FilesCard` stays here because it runs `KeyCheck`, which needs CommonCrypto. `LibraryCard` observes `GameLibrary`. The other views stay because they read an app type: `LauncherView`, `Library`, `ManageMenu` and `LaunchOptionsView` read `GameLibrary`, `LibraryGame` or `LauncherGamepad`, `CheatsView` reads `CheatFiles`, `FrameTimesView` reads `FrameTimes`, the console views read `ConsoleState` and the glyphs read `LauncherGamepad`, `OnboardingView` reads `OnboardingState` and its drivers. They move when those types do.## Access level@@ -73,7 +73,7 @@ A view observes only the stores it shows. A change in one store invalidates only- Parsing, formatting, classification, anything that is a function of its input: `NXCore`, as a value type or a static function, with a test.- Running a process or reading and writing files: a service in `NXCore` behind a protocol.- State that a view shows and changes: a store in `NXModel`.-- A view: `NXLauncher`, observing the stores it shows.+- A view: `NXLauncher`, observing the stores it shows. A new card is one view there, listed in `BuildPage` or `SettingsPage`. A view that needs an app type stays in `NX2Apple`.- Creating the services and stores and handing them to the views: `NX2Apple`, nothing else.`BuildModel` is gone. Do not put logic in `LauncherStores`: it only creates and connects.diff --git a/tools/engine.py b/tools/engine.pyindex 79981a08..adac8d0f 100755--- a/tools/engine.py+++ b/tools/engine.py@@ -96,7 +96,7 @@ def pin(root):def stamp_key(root):"""The digest of what engine/ is built from: the pin, and each patch of the series by name and content, in order.- frontend/Sources/NX2Apple/Engine.swift and frontend-qt/nspb_qt/engine.py compute the same, so the launchers can+ frontend/Sources/NXCore/EngineLayout.swift and frontend-qt/nspb_qt/engine.py compute the same, so the launchers cantell a stale engine/ without starting Python."""h = hashlib.sha256()h.update(b'pin ' + pin(root).encode() + b'\n')