auto_interop_generator 0.2.5
auto_interop_generator: ^0.2.5 copied to clipboard
Code generator for auto_interop — auto-generates type-safe Dart bindings from native package APIs (npm, CocoaPods, Gradle).
0.2.5 #
Bug Fixes #
- Schema:
nativeNamefield — AddednativeNametoUtsType,UtsEnum, andUtsClassto preserve original native type names (e.g.,SHA2.Variant,UInt8) through the Dart mapping round-trip. - Parser: Nested type native names —
_prefixEnumand_prefixClassnow setnativeNameto the dotted form (e.g.,SHA2.Variant) when flattening nested types for Dart compatibility. - Parser: Sealed class → enum promotion — Sealed classes whose subclasses are all undefined in the schema are now promoted to enums at parse time, ensuring Swift/Kotlin glue generators see the correct
enumTypekind instead ofobject. - Type mapping: Sub-integer type preservation —
UInt8,Int16,Float, and other sub-integer Swift types now preserve their native name through theint/doubleDart mapping, preventingUInt8→Intloss in generated glue code. - Swift glue: Native name usage — Enum helpers, data class helpers, constructor calls, and type references now use
nativeName(e.g.,SHA2.Variant,UInt8) instead of flattened Dart names. - Kotlin glue: Native name usage — Mirrors Swift changes; also maps Swift sub-integer types to Kotlin equivalents (
UInt8→UByte,Int16→Short, etc.). - pbxproj patcher: Fixed reverse regex — The fallback regex in
_addToRunnerGroupnow correctly matches pbxproj structures wherechildrenappears beforepath/name = Runner.
0.2.4 #
Bug Fixes #
- Dart: Sealed class → enum fallback — Sealed classes whose subclasses aren't defined in the schema (e.g.,
HMAC.Variantwith casesmd5,sha1,sha2) now generate a Dartenuminstead of a brokensealed classwith undefinedfromMapreferences. - Dart: Double
?on nullable create() params — FixedList<int>??regression by checking iftoDartType()already ends with?before appending another. - Dart:
toMap()on unknown types —_serializeExprnow only calls.toMap()on types defined inschema.types, preventing calls on opaque types likeModethat don't havetoMap(). - Swift/Kotlin: Constructor param enum/type collection —
_enumsNeededByAutoGeneratedMethodsand_typesNeededByAutoGeneratedMethodsnow scanconstructorParameters, generating missing decoder helpers likedecodeSHA2Variant(). - Swift/Kotlin: List type argument conversion — Added typed array conversion in argument handling (e.g.,
[Any]→[UInt8]for Swift,List<*>→List<Int>for Kotlin) so native APIs receive correctly typed arrays. - pbxproj patcher: Robust Runner group matching — Added fallback regex patterns for
_addToRunnerGroupto handle projects where the Runner group usesname = Runnerorpath = Runnerattributes.
0.2.3 #
Bug Fixes #
- AST: Proper constructor parameters — Init declarations now populate
constructorParametersinstead of generating a spurious staticcreatemethod. Distinguishes no-init (null), parameterless init ([]), and parameterized init. - AST: Nested type parsing — Nested enums, structs, and classes inside class/struct bodies are now extracted and prefixed with the parent name (e.g.,
SHA2.Variant→SHA2Variant). - AST: Dotted type flattening —
MemberTypeSyntax(e.g.,SHA2.Variant) is now flattened to the full joined name instead of taking only the last component. - AST: Post-parse type resolution — After parsing, type references with
kind: "object"are resolved tokind: "enumType"when the name matches a known enum. - Schema:
constructorThrowsfield — New boolean field onUtsClasstracks whether a Swift init can throw, enabling try/catch wrapping in glue code. - Swift glue: Improved
_writeCreateCase— Now uses schema-aware type mapping, argument conversions, native arg list builder, and try/catch for throwing inits. - Kotlin glue: Improved
_writeCreateCase— Mirrors Swift improvements: schema-aware types, argument conversions, native arg list, and try/catch for throwing constructors. - Swift/Kotlin glue:
nativeObjecttype handling —UtsTypeKind.nativeObjectnow maps toString(handle-based) instead of falling through toAny. - Swift/Kotlin glue: Skip
createmethod — Methods loop skips the spuriouscreatemethod whenconstructorParametersis set. - pbxproj patcher: Correct build phase targeting —
_addToSourcesBuildPhasenow iterates allPBXSourcesBuildPhasematches and selects the Runner target (not RunnerTests).
0.2.2 #
Bug Fixes #
- Multi-line doc comments: Preserve line breaks in
///and/** */documentation instead of collapsing to a single line. - Duplicate
createmethod: Skip emitting acreatemethod in the methods loop when one is already generated as a factory constructor. - Abstract interface classes: No longer emit fields, constructors,
fromMap, ortoMapfor abstract interface classes (protocols without instance methods). - Nested types: Parse nested enums, structs, and classes inside Swift structs and classes (e.g.,
SHA2.VariantbecomesSHA2Variant). - Dotted type resolution: Resolve dotted type references (
Outer.InnertoOuterInner) throughout the schema, including enum type promotion. - Nullable
constructorParameters: Distinguish "no public init found" (null) from "parameterless init" ([]). Classes without public initializers no longer emit brokencreate()factories. - Glue method deduplication: Deduplicate methods in Swift and Kotlin glue generators to prevent duplicate
case/whenlabels for overloaded methods.
0.2.1 #
- Version bump to accompany
auto_interop0.2.1 (no generator changes).
0.2.0 #
AST-Based Parsing (Near-100% Reliability) #
- AST parsers as default — All three parsers now use real compiler APIs for accurate parsing, with automatic regex fallback on failure:
- Swift: SwiftSyntax via compiled helper binary
- Kotlin: Kotlin PSI via
kotlinc -scriptwith compiler-embeddable - TypeScript: TypeScript Compiler API via Node.js
- Backward-compatible SwiftSyntax — Conditional compilation (
#if compiler(>=6.0)) selects SwiftSyntax 600+ on Swift 6.x, 510 on Swift 5.x. Supports SwiftSyntax 602 API changes via#if compiler(>=6.2). - Kotlin extension function folding — Extension functions (
fun String.isValidEmail()) are folded into matching classes or emitted as top-level functions with the receiver as the first parameter. - Kotlin overload deduplication — When multiple overloads exist for the same function name, only the first is kept (Dart doesn't support overloading).
- Swift
throwspropagation — Throwing functions are markedisAsync: truein the schema so Dart generators wrap them inFuturewith error handling. Supports typed throws (throws(NetworkError)). - Mixed Kotlin/Java handling — Packages with both
.ktand.javafiles are parsed in parallel: Kotlin via AST, Java via regex. Results are merged into a single schema. - TypeScript default export handling —
export default class/interface/type/enumdeclarations are now correctly parsed.
Cache & Toolchain Improvements #
- Mtime-based Swift cache invalidation — The compiled Swift helper binary is automatically recompiled when
Package.swiftorSources/main.swiftchange (similar tomake). - Content-comparison Kotlin cache invalidation — The version-matched Kotlin script is rewritten only when its patched content differs from the cached version.
- Warm stamp auto-write — The "first use" Maven dependency warning now writes a warm stamp immediately, preventing repeated warnings across invocations.
setupcommand —dart run auto_interop_generator:generate setuppre-warms all AST helper caches (downloads Maven deps, compiles Swift binary).
Bug Fixes #
- Removed unused
dart:asyncimports from AST parser files. - Fixed Kotlin warm stamp being overly aggressive (no longer deleted on script logic changes, only on kotlinc version changes).
0.1.0 #
- Initial release.
- Parsers for npm (TypeScript
.d.ts), CocoaPods/SPM (Swift), and Gradle (Kotlin). - Unified Type Schema (UTS) intermediate representation.
- Dart binding generator with full type mapping.
- Kotlin glue generator (Android FlutterPlugin).
- Swift glue generator (iOS FlutterPlugin).
- JS interop generator (web
dart:js_interop). - Platform installers: npm, CocoaPods (Podfile), SPM (Package.swift), Gradle.
- Pre-built type definitions for date-fns, lodash, uuid, OkHttp, Alamofire, SDWebImage.
TypeDefinitionLoaderfor loading/saving UTS JSON definitions.- CLI tool with
generate,list, andaddcommands. build_runnerintegration viaAutoInteropBuilder.- Callback, stream, and native object lifecycle support in all generators.