nitro 0.3.3
nitro: ^0.3.3 copied to clipboard
High-performance Native Modules for Flutter (Nitro Modules equivalent). Runtime support for .native.dart spec generated bridges.
0.3.3 #
- Improved: Ecosystem Sync — Synchronized to version 0.3.3.
0.3.2 #
- Improved: Ecosystem Sync — Synchronized to version 0.3.2.
- Improved: Nested
@HybridStructintegration — Works seamlessly withnitro_generator0.3.2, which now generates correctPointer<NestedFfi>types, recursivefreeFields(), and typedtoNative()/toDart()for nested struct fields. - Improved: Struct constructor styles — Generated FFI extensions respect positional and named constructor parameters as declared in your
.native.dartspec, sotoDart()calls always match the actual constructor signature.
0.3.1 #
-
Improved:
IsolatePool— persistent reply port — replaced per-callReceivePortallocation with a single pool-level port kept alive for the pool's lifetime. Each call is tagged with a monotonically-increasingcallId; aMap<int, Completer>demuxes responses without any OS port operation per call. -
Improved:
IsolatePool— least-busy scheduling — replaced round-robin with a per-worker in-flight counter; the dispatcher always picks the worker with the fewest pending calls, preventing a slow JNI/FFI call from blocking the next task. -
Improved:
IsolatePool—Completer.sync()— reply completers useCompleter.sync()to deliver values in the same microtask as the port message, removing one extra microtask hop per async call. -
Improved:
IsolatePool.dispose()— now idempotent; in-flight calls are completed withStateErrorso awaiting code never hangs; the reply port is closed and worker shutdown is signalled gracefully. -
New:
IsolatePooltests — 21 tests covering pool creation, return values, error propagation, callId uniqueness, least-busy scheduling, dispose idempotency, in-flight cancellation, and stress scenarios. -
New:
LazyRecordList<T>—record_codec.dartgains aListBase<T>implementation backed by a rawPointer<Uint8>and a pre-parsed offset table. Items are decoded on first access and cached; aNativeFinalizerbacked bymalloc.nativeFreefrees the buffer on GC. -
New:
RecordWriter.encodeIndexedList<T>— serialises a list of records into the indexed wire format:[int32 count | int64[count] byte_offsets | item_blobs...], enabling O(1) random access by the Dart reader. -
New:
RecordWriter.encodeIndexedPrimitiveList<T>— same indexed format for primitive-typed lists. -
New:
RecordReader.fromPayloadOffset(Pointer<Uint8>, int)— constructs a reader at an arbitrary byte offset within an existing payload, used byLazyRecordListto decode individual items on demand.
0.3.0 #
- Breaking: C++ Interface Pointer Generation — The C++ bridge generator now generates
void*interface pointers instead of concrete class pointers forHybridObjecttypes.- Impact: Existing C++ code that directly casts these pointers to concrete types will break and require updates.
- Benefit: This change ensures compatibility with the new C++ build system and allows for more flexible native module integration.
- Improved: Memory Safety: FFI generated code now uses
try-finallyblocks for all async and sync record/struct return paths, ensuringmalloc.freeis called even if decoding fails. - Improved: Thread Safety: The
HybridObjectimplementation now enforcescheckDisposed()guards on all native methods, includingFastvariants, to prevent use-after-dispose crashes. - Fixed: Fail-Fast Initialization:
NitroRuntimenow explicitly validates return codes from native initialization (e.g.,Dart_InitializeApiDL). If initialization fails, aStateErroris thrown immediately instead of failing silently later.
0.2.3 #
- Improved: Native Visibility Visibility: Updated
nitro.hto includeNITRO_EXPORTmacros by default, ensuring all native symbols are correctly exported for FFI across iOS, Android, macOS, and Windows. - Improved: Dependency Sync: Synchronized the Nitro ecosystem to version 0.2.3.
0.2.2 #
- Improved: annotation compatibility — verified full compatibility with Nitrogen 0.2.2's stable annotation resolution system, ensuring re-exported
@NitroModule,@HybridStruct, and@HybridEnumannotations are correctly identified by the code generator. - Added explicit
voidsupport in return types for allHybridObjectmethods.
0.2.1 #
- Moved all annotations to the separate
nitro_annotationspackage to improve generator platform compatibility. - Re-exported
nitro_annotationsfor backward compatibility. - Added explicit support for
macos,windows, andlinuxto the plugin configuration to resolvepub.devplatform detection warnings.
0.2.0 #
- New: Binary
RecordWriterandRecordReaderCodec — Compact little-endian protocol for@HybridRecordtypes, replacing JSON text serialization with direct binary field access over rawuint8_t*buffers.- Wire format:
int64(8B),float64(8B),bool(1B),String(4-byte length + UTF-8), nullable (1-byte tag), andlist(4-byte count). - High-performance
encodeList/decodeListfor collections of records or primitives. - Retains
dart:convertre-exports forMap<String, T>which still uses the JSON path.
- Wire format:
- New:
IsolatePool&NitroRuntime.init()— Fixed-size pool of persistent worker isolates with round-robin dispatch. Pre-warmed byinit()to eliminate the ~1–5 msIsolate.spawnoverhead on everycallAsync. - New:
NitroConfigRuntime Singleton — Configurable runtime behavior:debugMode: Enables verbose logging of bridge calls, streams, isolates, and lifecycles.logLevel: Granular control (none,error,warning,verbose).logHandler: Custom sink for logs (e.g., Firebase, Sentry, Crashlytics).slowCallThresholdUs: Configurable warning threshold for long-running async calls (default 16ms).
- Improved:
NitroRuntimeRobustness — Stream unpack errors are now always logged aterrorlevel with stack traces, ensuring they are never silently swallowed. AddeddebugLabelto streams for easier debugging. - Fix: Style & Linting — Renamed internal state variables (e.g.,
_released→released) to follow Dart conventions for local variables.
0.1.0 #
- Initial release of Nitro runtime.
- Support for
HybridObject,HybridStruct, andHybridEnum. - Support for synchronous and asynchronous bridge calls.
- Unified FFI bridge support for Android and iOS.