Repository navigation
refactor(nitro): Nitrogen specs, bridge boundaries, typed snapshots - #6
Merged
Merged
Conversation
The method table, pure virtual interface, and iOS registration duplicated the TypeScript API, and a missed registerHybridMethod only showed up at runtime. Generate them from the specs so a missing override fails to compile. Result payloads stay handwritten: one task's result type varies, and SmbFileInfo is recursive. - add src/specs and nitrogen/generated; register ReactNativeSmb from the generated autolinking +load instead of OnLoad.mm - move domain structs to SmbModels and take SmbTask off HybridObject; HybridSMB and HybridSmbTask implement the generated specs - keep getResultValue and drainEntries as raw methods, and keep the SmbFileInfo JSIConverter - depend on Nitro 0.37.2, make react-native-nitro-modules an optional peer, and set FOLLY_CFG_NO_COROUTINES while excluding generated Swift from the pod - rerun nitrogen in CI and fail when nitrogen/ drifts
Generated Nitrogen headers target 0.37.2, so an older peer would compile against the wrong APIs. Keep the peer optional for non-RN consumers of the TypeScript surface. - set peerDependencies.react-native-nitro-modules to >=0.37.2
Domain tasks stored results as any plus a jsi::Runtime converter, so operators and SmbTaskCore depended on Nitro headers. Publish a typed variant instead and convert only in HybridSmbTask. - add SmbTaskResult and ListingResult; EntryStream still holds listing rows - move hand-written JSIConverters into bridge/DomainConverters.hpp - strip jsi includes from SmbTaskCore, SmbTask, and OperatorBase
Entry streaming methods belonged on every HybridSmbTask even though only listDirectory uses them, and every task allocated an EntryStream. Generate a listing HybridObject that extends NativeSmbTask and create the stream only for ListDirectory. - add NativeSmbListTask.nitro.ts and HybridSmbListTask with raw drainEntries - keep getResultValue on HybridSmbTask; listDirectory returns the list hybrid - Nitrogen uses virtual inheritance for the HybridObject diamond
String-map snapshots forced a hand-written codec on both sides and hid enum/struct types from Nitrogen. Specs now carry SmbTaskState and PoolInfo so the bridge maps domain DTOs once and JS consumes typed values. - add TaskStatus/SmbOperatorKind/SlotState plus snapshot/pool structs to specs - bridge with toBridge; drop TaskSnapshotCodec and decode.ts - update SmbTask/TransferStore/SmbClient and test mocks to typed objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor: Nitrogen specs, bridge boundaries, typed snapshots
Why
The bridge was still mostly hand-written: easy to drift from the TS API, easy to miss a method at runtime. Snapshots were string maps on both sides. JSI had leaked into domain code. Every task looked like a list task. Peer deps didn’t match what Nitrogen 0.37.2 actually generates.
What
Nitrogen owns the HybridObject surface now (
src/specs→nitrogen/generated). Domain stays JSI-free; bridge owns conversion. List streaming lives onNativeSmbListTaskonly. Task and pool snapshots are typed structs—codec anddecode.tsare gone. Peer isreact-native-nitro-modules >= 0.37.2.App TS API unchanged.
getResultValue/drainEntriesstay raw until recursiveSmbFileInfocan be generated.Notes for reviewers
Big generated diff is expected. Review specs + bridge, not every generated line. Example still uses
file:...