@@ -13,6 +13,11 @@ import GameMath
1313import WinSDK
1414#endif
1515
16+ #if canImport(WebAPIBase) && canImport(JavaScriptKit)
17+ import JavaScriptKit
18+ import WebAPIBase
19+ #endif
20+
1621#if targetEnvironment(macCatalyst)
1722#error("macCatalyst is not a supported platform.")
1823#endif
@@ -98,10 +103,15 @@ internal enum Log {
98103 @_transparent @usableFromInline
99104 static func info( _ items: Any ... , separator: String = " " , terminator: String = " \n " ) {
100105 let message = _message ( prefix: " [GateEngine] " , items, separator: separator)
106+
107+ #if os(WASI) || GATEENGINE_ENABLE_WASI_IDE_SUPPORT
108+ console. info ( data: . string( message) )
109+ #else
101110 Swift . print ( message, terminator: terminator)
102111 #if os(Windows)
103112 WinSDK . OutputDebugStringW ( ( message + terminator) . windowsUTF16)
104113 #endif
114+ #endif
105115 }
106116
107117 @_transparent @usableFromInline
@@ -139,10 +149,16 @@ internal enum Log {
139149 } else {
140150 resolvedMessage = _message ( prefix: " [GateEngine] warning: " , items, separator: separator)
141151 }
142- Swift . print ( resolvedMessage, separator: separator, terminator: terminator)
152+ #if os(WASI) || GATEENGINE_ENABLE_WASI_IDE_SUPPORT
153+ console. warn ( data: . string( resolvedMessage) )
154+ #else
155+
143156 #if os(Windows)
144157 WinSDK . OutputDebugStringW ( ( resolvedMessage + terminator) . windowsUTF16)
145158 #endif
159+
160+ Swift . print ( resolvedMessage, separator: separator, terminator: terminator)
161+ #endif
146162 }
147163
148164 @_transparent @usableFromInline
@@ -162,10 +178,16 @@ internal enum Log {
162178 } else {
163179 resolvedMessage = self . _message ( prefix: " [GateEngine] error: " , items, separator: separator)
164180 }
165- Swift . print ( resolvedMessage, separator: separator, terminator: terminator)
181+ #if os(WASI) || GATEENGINE_ENABLE_WASI_IDE_SUPPORT
182+ console. error ( data: . string( resolvedMessage) )
183+ #else
184+
166185 #if canImport(WinSDK)
167186 WinSDK . OutputDebugStringW ( ( resolvedMessage + terminator) . windowsUTF16)
168187 #endif
188+
189+ Swift . print ( resolvedMessage, separator: separator, terminator: terminator)
190+ #endif
169191 }
170192
171193 @_transparent @usableFromInline
@@ -181,17 +203,23 @@ internal enum Log {
181203 static func assert( _ condition: @autoclosure ( ) -> Bool , _ message: @autoclosure ( ) -> String , file: StaticString = #file, line: UInt = #line) {
182204 #if DEBUG
183205 let condition = condition ( )
184- guard condition else { return }
206+ guard condition == false else { return }
185207
186208 let resolvedMessage : String
187209 if supportsColor {
188210 resolvedMessage = self . _message ( prefix: " [GateEngine] \( ANSIColors . red) error \( ANSIColors . default) : " , message ( ) , separator: " " )
189211 } else {
190212 resolvedMessage = self . _message ( prefix: " [GateEngine] error: " , message ( ) , separator: " " )
191213 }
214+
192215 #if canImport(WinSDK)
193216 WinSDK . OutputDebugStringW ( ( resolvedMessage + " /n " ) . windowsUTF16)
194217 #endif
218+
219+ #if os(WASI) || GATEENGINE_ENABLE_WASI_IDE_SUPPORT
220+ console. assert ( condition: condition, data: . string( resolvedMessage) )
221+ #endif
222+
195223 Swift . assert ( condition, resolvedMessage, file: file, line: line)
196224 #endif
197225 }
@@ -204,9 +232,15 @@ internal enum Log {
204232 } else {
205233 resolvedMessage = self . _message ( prefix: " [GateEngine] error: " , message, separator: " " )
206234 }
235+
207236 #if canImport(WinSDK)
208237 WinSDK . OutputDebugStringW ( ( resolvedMessage + " /n " ) . windowsUTF16)
209238 #endif
239+
240+ #if os(WASI) || GATEENGINE_ENABLE_WASI_IDE_SUPPORT
241+ console. assert ( condition: false , data: . string( resolvedMessage) )
242+ #endif
243+
210244 return Swift . fatalError ( resolvedMessage, file: file, line: line)
211245 }
212246}
0 commit comments