@@ -634,7 +634,7 @@ public struct ImportedGetterSkeleton: Codable {
634634 self . functionName = functionName
635635 }
636636
637- public func abiName ( context : ImportedTypeSkeleton ) -> String {
637+ public func abiName ( context : ImportedTypeSkeleton ? ) -> String {
638638 if let functionName = functionName {
639639 return ABINameGenerator . generateImportedABIName (
640640 baseName : functionName ,
@@ -669,7 +669,7 @@ public struct ImportedSetterSkeleton: Codable {
669669 self . functionName = functionName
670670 }
671671
672- public func abiName ( context : ImportedTypeSkeleton ) -> String {
672+ public func abiName ( context : ImportedTypeSkeleton ? ) -> String {
673673 if let functionName = functionName {
674674 return ABINameGenerator . generateImportedABIName (
675675 baseName : functionName ,
@@ -713,10 +713,48 @@ public struct ImportedTypeSkeleton: Codable {
713713public struct ImportedFileSkeleton : Codable {
714714 public let functions : [ ImportedFunctionSkeleton ]
715715 public let types : [ ImportedTypeSkeleton ]
716+ /// Global-scope imported properties (e.g. `@JSGetter var console: JSConsole`)
717+ public let globalGetters : [ ImportedGetterSkeleton ]
718+ /// Global-scope imported properties (future use; not currently emitted by macros)
719+ public let globalSetters : [ ImportedSetterSkeleton ]
716720
717- public init ( functions : [ ImportedFunctionSkeleton ] , types : [ ImportedTypeSkeleton ] ) {
721+ public init (
722+ functions : [ ImportedFunctionSkeleton ] ,
723+ types : [ ImportedTypeSkeleton ] ,
724+ globalGetters : [ ImportedGetterSkeleton ] = [ ] ,
725+ globalSetters : [ ImportedSetterSkeleton ] = [ ]
726+ ) {
718727 self . functions = functions
719728 self . types = types
729+ self . globalGetters = globalGetters
730+ self . globalSetters = globalSetters
731+ }
732+
733+ private enum CodingKeys : String , CodingKey {
734+ case functions
735+ case types
736+ case globalGetters
737+ case globalSetters
738+ }
739+
740+ public init ( from decoder : any Decoder ) throws {
741+ let container = try decoder . container ( keyedBy : CodingKeys . self )
742+ self . functions = try container . decode ( [ ImportedFunctionSkeleton ] . self , forKey : . functions )
743+ self . types = try container . decode ( [ ImportedTypeSkeleton ] . self , forKey : . types )
744+ self . globalGetters = try container . decodeIfPresent ( [ ImportedGetterSkeleton ] . self , forKey : . globalGetters ) ?? [ ]
745+ self . globalSetters = try container . decodeIfPresent ( [ ImportedSetterSkeleton ] . self , forKey : . globalSetters ) ?? [ ]
746+ }
747+
748+ public func encode ( to encoder : any Encoder ) throws {
749+ var container = encoder . container ( keyedBy : CodingKeys . self )
750+ try container . encode ( functions , forKey : . functions )
751+ try container . encode ( types , forKey : . types )
752+ if ! globalGetters . isEmpty {
753+ try container . encode ( globalGetters , forKey : . globalGetters )
754+ }
755+ if ! globalSetters . isEmpty {
756+ try container . encode ( globalSetters , forKey : . globalSetters )
757+ }
720758 }
721759}
722760
0 commit comments