@@ -20,7 +20,7 @@ import BridgeJSUtilities
2020public class ExportSwift {
2121 let progress : ProgressReporting
2222 let moduleName : String
23-
23+ private let exposeToGlobal : Bool
2424 private var exportedFunctions : [ ExportedFunction ] = [ ]
2525 private var exportedClasses : [ ExportedClass ] = [ ]
2626 private var exportedEnums : [ ExportedEnum ] = [ ]
@@ -30,9 +30,10 @@ public class ExportSwift {
3030 private let enumCodegen : EnumCodegen = EnumCodegen ( )
3131 private let closureCodegen = ClosureCodegen ( )
3232
33- public init ( progress: ProgressReporting , moduleName: String ) {
33+ public init ( progress: ProgressReporting , moduleName: String , exposeToGlobal : Bool ) {
3434 self . progress = progress
3535 self . moduleName = moduleName
36+ self . exposeToGlobal = exposeToGlobal
3637 }
3738
3839 /// Processes a Swift source file to find declarations marked with @JS
@@ -55,6 +56,8 @@ public class ExportSwift {
5556
5657 /// Finalizes the export process and generates the bridge code
5758 ///
59+ /// - Parameters:
60+ /// - exposeToGlobal: Whether to expose exported APIs to the global namespace (default: false)
5861 /// - Returns: A tuple containing the generated Swift code and a skeleton
5962 /// describing the exported APIs
6063 public func finalize( ) throws -> ( outputSwift: String , outputSkeleton: ExportedSkeleton ) ? {
@@ -68,7 +71,8 @@ public class ExportSwift {
6871 functions: exportedFunctions,
6972 classes: exportedClasses,
7073 enums: exportedEnums,
71- protocols: exportedProtocols
74+ protocols: exportedProtocols,
75+ exposeToGlobal: exposeToGlobal
7276 )
7377 )
7478 }
@@ -882,10 +886,18 @@ public class ExportSwift {
882886 message: " Enum visibility must be at least internal "
883887 )
884888
889+ let tsFullPath : String
890+ if let namespace = namespaceResult. namespace, !namespace. isEmpty {
891+ tsFullPath = namespace. joined ( separator: " . " ) + " . " + name
892+ } else {
893+ tsFullPath = name
894+ }
895+
885896 // Create enum directly in dictionary
886897 let exportedEnum = ExportedEnum (
887898 name: name,
888899 swiftCallName: swiftCallName,
900+ tsFullPath: tsFullPath,
889901 explicitAccessControl: explicitAccessControl,
890902 cases: [ ] , // Will be populated in visit(EnumCaseDeclSyntax)
891903 rawType: SwiftEnumRawType ( rawType) ,
0 commit comments