@@ -18,30 +18,35 @@ import class Foundation.JSONDecoder
1818
1919 func _update( swiftSource: String , dtsSource: String ) throws -> PlayBridgeJSOutput {
2020 let moduleName = " Playground "
21- let exportSwift = ExportSwift ( progress : . silent , moduleName : moduleName , exposeToGlobal : false )
22- let sourceFile = Parser . parse ( source : swiftSource )
23- try exportSwift . addSourceFile ( sourceFile , " Playground.swift " )
24- let exportResult = try exportSwift . finalize ( )
21+
22+ let swiftToSkeleton = SwiftToSkeleton ( progress : . silent , moduleName : moduleName , exposeToGlobal : false )
23+ swiftToSkeleton . addSourceFile ( Parser . parse ( source : swiftSource ) , inputFilePath : " Playground.swift " )
24+
2525 let ts2swift = try createTS2Swift ( )
2626 let importSwiftMacroDecls = try ts2swift. convert ( dtsSource)
27- let importSwift = ImportSwiftMacros ( progress: . silent, moduleName: moduleName)
28- let importSourceFile = Parser . parse ( source: importSwiftMacroDecls)
29- importSwift. addSourceFile ( importSourceFile, " Playground.Macros.swift " )
30- importSwift. addSourceFile ( sourceFile, " Playground.swift " )
31- let importResult = try importSwift. finalize ( )
32- let skeleton = BridgeJSSkeleton (
33- moduleName: moduleName,
34- exported: exportResult. map { $0. outputSkeleton } ,
35- imported: importResult. outputSkeleton
27+ swiftToSkeleton. addSourceFile (
28+ Parser . parse ( source: importSwiftMacroDecls) ,
29+ inputFilePath: " Playground.Macros.swift "
3630 )
31+
32+ let skeleton = try swiftToSkeleton. finalize ( )
33+
34+ let exportResult = try skeleton. exported. flatMap {
35+ let exportSwift = ExportSwift ( progress: . silent, moduleName: moduleName, skeleton: $0)
36+ return try exportSwift. finalize ( )
37+ }
38+ let importResult = try skeleton. imported. flatMap {
39+ let importTS = ImportTS ( progress: . silent, moduleName: moduleName, skeleton: $0)
40+ return try importTS. finalize ( )
41+ }
3742 let linker = BridgeJSLink ( skeletons: [ skeleton] , sharedMemory: false )
3843 let linked = try linker. link ( )
3944
4045 return PlayBridgeJSOutput (
4146 outputJs: linked. outputJs,
4247 outputDts: linked. outputDts,
4348 importSwiftMacroDecls: importSwiftMacroDecls,
44- swiftGlue: ( importResult. outputSwift ?? " " ) + " \n \n " + ( exportResult? . outputSwift ?? " " )
49+ swiftGlue: ( importResult ?? " " ) + " \n \n " + ( exportResult ?? " " )
4550 )
4651 }
4752}
0 commit comments