auto_interop_generator 0.2.5 copy "auto_interop_generator: ^0.2.5" to clipboard
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: nativeName field — Added nativeName to UtsType, UtsEnum, and UtsClass to preserve original native type names (e.g., SHA2.Variant, UInt8) through the Dart mapping round-trip.
  • Parser: Nested type native names_prefixEnum and _prefixClass now set nativeName to 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 enumType kind instead of object.
  • Type mapping: Sub-integer type preservationUInt8, Int16, Float, and other sub-integer Swift types now preserve their native name through the int/double Dart mapping, preventing UInt8Int loss 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 (UInt8UByte, Int16Short, etc.).
  • pbxproj patcher: Fixed reverse regex — The fallback regex in _addToRunnerGroup now correctly matches pbxproj structures where children appears before path/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.Variant with cases md5, sha1, sha2) now generate a Dart enum instead of a broken sealed class with undefined fromMap references.
  • Dart: Double ? on nullable create() params — Fixed List<int>?? regression by checking if toDartType() already ends with ? before appending another.
  • Dart: toMap() on unknown types_serializeExpr now only calls .toMap() on types defined in schema.types, preventing calls on opaque types like Mode that don't have toMap().
  • Swift/Kotlin: Constructor param enum/type collection_enumsNeededByAutoGeneratedMethods and _typesNeededByAutoGeneratedMethods now scan constructorParameters, generating missing decoder helpers like decodeSHA2Variant().
  • 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 _addToRunnerGroup to handle projects where the Runner group uses name = Runner or path = Runner attributes.

0.2.3 #

Bug Fixes #

  • AST: Proper constructor parameters — Init declarations now populate constructorParameters instead of generating a spurious static create method. 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.VariantSHA2Variant).
  • AST: Dotted type flatteningMemberTypeSyntax (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 to kind: "enumType" when the name matches a known enum.
  • Schema: constructorThrows field — New boolean field on UtsClass tracks 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: nativeObject type handlingUtsTypeKind.nativeObject now maps to String (handle-based) instead of falling through to Any.
  • Swift/Kotlin glue: Skip create method — Methods loop skips the spurious create method when constructorParameters is set.
  • pbxproj patcher: Correct build phase targeting_addToSourcesBuildPhase now iterates all PBXSourcesBuildPhase matches 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 create method: Skip emitting a create method in the methods loop when one is already generated as a factory constructor.
  • Abstract interface classes: No longer emit fields, constructors, fromMap, or toMap for abstract interface classes (protocols without instance methods).
  • Nested types: Parse nested enums, structs, and classes inside Swift structs and classes (e.g., SHA2.Variant becomes SHA2Variant).
  • Dotted type resolution: Resolve dotted type references (Outer.Inner to OuterInner) 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 broken create() factories.
  • Glue method deduplication: Deduplicate methods in Swift and Kotlin glue generators to prevent duplicate case/when labels for overloaded methods.

0.2.1 #

  • Version bump to accompany auto_interop 0.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 -script with 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 throws propagation — Throwing functions are marked isAsync: true in the schema so Dart generators wrap them in Future with error handling. Supports typed throws (throws(NetworkError)).
  • Mixed Kotlin/Java handling — Packages with both .kt and .java files are parsed in parallel: Kotlin via AST, Java via regex. Results are merged into a single schema.
  • TypeScript default export handlingexport default class/interface/type/enum declarations are now correctly parsed.

Cache & Toolchain Improvements #

  • Mtime-based Swift cache invalidation — The compiled Swift helper binary is automatically recompiled when Package.swift or Sources/main.swift change (similar to make).
  • 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.
  • setup commanddart run auto_interop_generator:generate setup pre-warms all AST helper caches (downloads Maven deps, compiles Swift binary).

Bug Fixes #

  • Removed unused dart:async imports 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.
  • TypeDefinitionLoader for loading/saving UTS JSON definitions.
  • CLI tool with generate, list, and add commands.
  • build_runner integration via AutoInteropBuilder.
  • Callback, stream, and native object lifecycle support in all generators.
1
likes
150
points
312
downloads

Publisher

verified publisherflutterplaza.com

Weekly Downloads

Code generator for auto_interop — auto-generates type-safe Dart bindings from native package APIs (npm, CocoaPods, Gradle).

Repository (GitHub)
View/report issues

Topics

#flutter #codegen #build-runner #native #bindings

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

build, code_builder, crypto, dart_style, json_annotation, path, source_gen, yaml

More

Packages that depend on auto_interop_generator