@tracecode/harness 0.6.6 → 0.7.0-beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +134 -15
- package/THIRD_PARTY_NOTICES.md +170 -0
- package/dist/browser.cjs +2361 -1033
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +33 -3
- package/dist/browser.d.ts +33 -3
- package/dist/browser.js +2357 -1033
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +160 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +161 -24
- package/dist/cli.js.map +1 -1
- package/dist/core.cjs +748 -867
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +21 -85
- package/dist/core.d.ts +21 -85
- package/dist/core.js +734 -855
- package/dist/core.js.map +1 -1
- package/dist/cpp-worker-client-Bn7kC0_L.d.ts +84 -0
- package/dist/cpp-worker-client-BzdJLuZa.d.cts +84 -0
- package/dist/cpp.cjs +1063 -0
- package/dist/cpp.cjs.map +1 -0
- package/dist/cpp.d.cts +7 -0
- package/dist/cpp.d.ts +7 -0
- package/dist/cpp.js +1035 -0
- package/dist/cpp.js.map +1 -0
- package/dist/csharp-worker-client-DMHIa2YG.d.cts +69 -0
- package/dist/csharp-worker-client-JwqS6LiX.d.ts +69 -0
- package/dist/csharp.cjs +1012 -0
- package/dist/csharp.cjs.map +1 -0
- package/dist/csharp.d.cts +7 -0
- package/dist/csharp.d.ts +7 -0
- package/dist/csharp.js +984 -0
- package/dist/csharp.js.map +1 -0
- package/dist/index.cjs +3142 -1160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +3117 -1148
- package/dist/index.js.map +1 -1
- package/dist/internal/browser.cjs +1639 -30
- package/dist/internal/browser.cjs.map +1 -1
- package/dist/internal/browser.d.cts +6 -199
- package/dist/internal/browser.d.ts +6 -199
- package/dist/internal/browser.js +1636 -30
- package/dist/internal/browser.js.map +1 -1
- package/dist/java-worker-client-BOwKW-11.d.cts +72 -0
- package/dist/java-worker-client-C97DDnCp.d.ts +72 -0
- package/dist/java.cjs +1225 -0
- package/dist/java.cjs.map +1 -0
- package/dist/java.d.cts +7 -0
- package/dist/java.d.ts +7 -0
- package/dist/java.js +1197 -0
- package/dist/java.js.map +1 -0
- package/dist/javascript-worker-client-CYBGEEvc.d.cts +51 -0
- package/dist/javascript-worker-client-DIX1Mp21.d.ts +51 -0
- package/dist/javascript.cjs +1063 -19
- package/dist/javascript.cjs.map +1 -1
- package/dist/javascript.d.cts +7 -4
- package/dist/javascript.d.ts +7 -4
- package/dist/javascript.js +1061 -19
- package/dist/javascript.js.map +1 -1
- package/dist/pyodide-worker-client-C-2rfHj9.d.ts +111 -0
- package/dist/pyodide-worker-client-Cn0a8Uv3.d.cts +111 -0
- package/dist/python.cjs +1282 -74
- package/dist/python.cjs.map +1 -1
- package/dist/python.d.cts +20 -14
- package/dist/python.d.ts +20 -14
- package/dist/python.js +1279 -74
- package/dist/python.js.map +1 -1
- package/dist/runtime-language-info-BFUSti3-.d.ts +43 -0
- package/dist/runtime-language-info-Bxza1cI2.d.cts +43 -0
- package/dist/runtime-types-2qM0MukN.d.cts +244 -0
- package/dist/runtime-types-2qM0MukN.d.ts +244 -0
- package/package.json +73 -8
- package/workers/cpp/cpp-compiler-frame.html +82 -0
- package/workers/cpp/cpp-compiler-worker.js +131 -0
- package/workers/cpp/cpp-worker.js +5790 -0
- package/workers/cpp/tracecode_runtime.hpp +6147 -0
- package/workers/csharp/csharp-worker.js +301 -0
- package/workers/java/.build/classes/harness/browser/JavaRewriteLibrary.class +0 -0
- package/workers/java/java-source-augmentations.js +880 -0
- package/workers/java/java-worker.js +2149 -178
- package/workers/java/src/harness/browser/JavaRewriteLibrary.java +1645 -32
- package/workers/java/src/javafx/util/Pair.java +42 -0
- package/workers/java/src/tracecode/browser/BrowserCompileAndTraceLibrary.java +714 -0
- package/workers/java/src/tracecode/browser/BrowserCompileAndTraceMain.java +76 -0
- package/workers/java/src/tracecode/browser/RuntimeProbeMain.java +14 -0
- package/workers/java/src/tracecode/user/TraceHooks.java +1406 -0
- package/workers/javascript/javascript-libraries-entry.js +71 -0
- package/workers/javascript/javascript-worker.js +2054 -424
- package/workers/python/generated-python-harness-snippets.js +4 -4
- package/workers/python/pyodide-worker.js +222 -61
- package/workers/python/runtime-core.js +1387 -301
- package/workers/vendor/csharp/.stamp +0 -0
- package/workers/vendor/csharp/TraceCode.CSharpHost.runtimeconfig.json +32 -0
- package/workers/vendor/csharp/_framework/Microsoft.CSharp.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.CSharp.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.Win32.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.Win32.Registry.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.AppContext.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Buffers.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Concurrent.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Immutable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.NonGeneric.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Specialized.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.Annotations.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.DataAnnotations.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.EventBasedAsync.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Configuration.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Console.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Core.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.Common.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.DataSetExtensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Contracts.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Debug.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.DiagnosticSource.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.FileVersionInfo.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Process.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.StackTrace.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.TextWriterTraceListener.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Tools.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.TraceSource.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Tracing.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Drawing.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Drawing.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Dynamic.Runtime.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Formats.Asn1.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Formats.Tar.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.Calendars.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.Brotli.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.FileSystem.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.ZipFile.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.DriveInfo.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.Watcher.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.IsolatedStorage.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.MemoryMappedFiles.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipelines.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipes.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipes.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.UnmanagedMemoryStream.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.AsyncEnumerable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Expressions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Parallel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Queryable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Memory.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Http.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Http.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.HttpListener.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Mail.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.NameResolution.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.NetworkInformation.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Ping.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Quic.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Requests.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Security.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.ServerSentEvents.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.ServicePoint.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Sockets.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebClient.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebHeaderCollection.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebProxy.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebSockets.Client.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebSockets.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Numerics.Vectors.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Numerics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ObjectModel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.CoreLib.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.DataContractSerialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Uri.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Xml.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.DispatchProxy.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.ILGeneration.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.Lightweight.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Metadata.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.TypeExtensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.Reader.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.ResourceManager.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.Writer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.Unsafe.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.VisualC.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Handles.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.RuntimeInformation.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Intrinsics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Loader.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Numerics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Formatters.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Claims.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Algorithms.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Cng.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Csp.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Encoding.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.OpenSsl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.X509Certificates.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Principal.Windows.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Principal.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.SecureString.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ServiceModel.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ServiceProcess.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.CodePages.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encodings.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.RegularExpressions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Channels.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Overlapped.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Dataflow.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Parallel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Thread.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.ThreadPool.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Timer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Transactions.Local.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Transactions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ValueTuple.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Web.HttpUtility.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Windows.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.ReaderWriter.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.Serialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XPath.XDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XPath.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XmlDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XmlSerializer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.wasm +0 -0
- package/workers/vendor/csharp/_framework/TraceCode.CSharpHost.wasm +0 -0
- package/workers/vendor/csharp/_framework/WindowsBase.wasm +0 -0
- package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/dotnet.boot.js +1958 -0
- package/workers/vendor/csharp/_framework/dotnet.js +4 -0
- package/workers/vendor/csharp/_framework/dotnet.js.map +1 -0
- package/workers/vendor/csharp/_framework/dotnet.native.js +6687 -0
- package/workers/vendor/csharp/_framework/dotnet.native.wasm +0 -0
- package/workers/vendor/csharp/_framework/dotnet.runtime.js +4 -0
- package/workers/vendor/csharp/_framework/dotnet.runtime.js.map +1 -0
- package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/mscorlib.wasm +0 -0
- package/workers/vendor/csharp/_framework/netstandard.wasm +0 -0
- package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/0_Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/100_System.Reflection.Emit.ILGeneration.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/101_System.Reflection.Emit.Lightweight.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/102_System.Reflection.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/103_System.Reflection.Metadata.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/104_System.Reflection.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/105_System.Reflection.TypeExtensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/106_System.Resources.Reader.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/107_System.Resources.ResourceManager.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/108_System.Resources.Writer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/109_System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/10_System.Buffers.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/110_System.Runtime.CompilerServices.VisualC.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/111_System.Runtime.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/112_System.Runtime.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/113_System.Runtime.Handles.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/114_System.Runtime.InteropServices.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/115_System.Runtime.InteropServices.JavaScript.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/116_System.Runtime.InteropServices.RuntimeInformation.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/117_System.Runtime.Intrinsics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/118_System.Runtime.Loader.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/119_System.Runtime.Numerics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/11_System.Collections.Concurrent.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/120_System.Runtime.Serialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/121_System.Runtime.Serialization.Formatters.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/122_System.Runtime.Serialization.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/123_System.Runtime.Serialization.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/124_System.Runtime.Serialization.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/125_System.Security.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/126_System.Security.Claims.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/127_System.Security.Cryptography.Algorithms.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/128_System.Security.Cryptography.Cng.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/129_System.Security.Cryptography.Csp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/12_System.Collections.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/130_System.Security.Cryptography.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/131_System.Security.Cryptography.Encoding.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/132_System.Security.Cryptography.OpenSsl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/133_System.Security.Cryptography.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/134_System.Security.Cryptography.X509Certificates.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/135_System.Security.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/136_System.Security.Principal.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/137_System.Security.Principal.Windows.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/138_System.Security.SecureString.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/139_System.ServiceModel.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/13_System.Collections.Immutable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/140_System.ServiceProcess.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/141_System.Text.Encoding.CodePages.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/142_System.Text.Encoding.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/143_System.Text.Encoding.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/144_System.Text.Encodings.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/145_System.Text.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/146_System.Text.RegularExpressions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/147_System.Threading.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/148_System.Threading.Channels.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/149_System.Threading.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/14_System.Collections.NonGeneric.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/150_System.Threading.Overlapped.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/151_System.Threading.Tasks.Dataflow.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/152_System.Threading.Tasks.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/153_System.Threading.Tasks.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/154_System.Threading.Tasks.Parallel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/155_System.Threading.Thread.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/156_System.Threading.ThreadPool.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/157_System.Threading.Timer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/158_System.Transactions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/159_System.Transactions.Local.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/15_System.Collections.Specialized.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/160_System.ValueTuple.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/161_System.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/162_System.Web.HttpUtility.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/163_System.Windows.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/164_System.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/165_System.Xml.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/166_System.Xml.ReaderWriter.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/167_System.Xml.Serialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/168_System.Xml.XDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/169_System.Xml.XmlDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/16_System.ComponentModel.Annotations.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/170_System.Xml.XmlSerializer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/171_System.Xml.XPath.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/172_System.Xml.XPath.XDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/173_TraceCode.CSharpHost.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/174_WindowsBase.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/17_System.ComponentModel.DataAnnotations.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/18_System.ComponentModel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/19_System.ComponentModel.EventBasedAsync.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/1_Microsoft.CodeAnalysis.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/20_System.ComponentModel.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/21_System.ComponentModel.TypeConverter.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/22_System.Configuration.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/23_System.Console.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/24_System.Core.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/25_System.Data.Common.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/26_System.Data.DataSetExtensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/27_System.Data.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/28_System.Diagnostics.Contracts.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/29_System.Diagnostics.Debug.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/2_Microsoft.CSharp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/30_System.Diagnostics.DiagnosticSource.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/31_System.Diagnostics.FileVersionInfo.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/32_System.Diagnostics.Process.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/33_System.Diagnostics.StackTrace.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/34_System.Diagnostics.TextWriterTraceListener.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/35_System.Diagnostics.Tools.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/36_System.Diagnostics.TraceSource.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/37_System.Diagnostics.Tracing.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/38_System.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/39_System.Drawing.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/3_Microsoft.VisualBasic.Core.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/40_System.Drawing.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/41_System.Dynamic.Runtime.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/42_System.Formats.Asn1.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/43_System.Formats.Tar.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/44_System.Globalization.Calendars.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/45_System.Globalization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/46_System.Globalization.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/47_System.IO.Compression.Brotli.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/48_System.IO.Compression.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/49_System.IO.Compression.FileSystem.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/4_Microsoft.VisualBasic.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/50_System.IO.Compression.ZipFile.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/51_System.IO.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/52_System.IO.FileSystem.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/53_System.IO.FileSystem.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/54_System.IO.FileSystem.DriveInfo.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/55_System.IO.FileSystem.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/56_System.IO.FileSystem.Watcher.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/57_System.IO.IsolatedStorage.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/58_System.IO.MemoryMappedFiles.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/59_System.IO.Pipelines.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/5_Microsoft.Win32.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/60_System.IO.Pipes.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/61_System.IO.Pipes.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/62_System.IO.UnmanagedMemoryStream.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/63_System.Linq.AsyncEnumerable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/64_System.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/65_System.Linq.Expressions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/66_System.Linq.Parallel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/67_System.Linq.Queryable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/68_System.Memory.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/69_System.Net.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/6_Microsoft.Win32.Registry.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/70_System.Net.Http.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/71_System.Net.Http.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/72_System.Net.HttpListener.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/73_System.Net.Mail.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/74_System.Net.NameResolution.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/75_System.Net.NetworkInformation.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/76_System.Net.Ping.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/77_System.Net.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/78_System.Net.Quic.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/79_System.Net.Requests.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/7_mscorlib.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/80_System.Net.Security.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/81_System.Net.ServerSentEvents.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/82_System.Net.ServicePoint.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/83_System.Net.Sockets.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/84_System.Net.WebClient.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/85_System.Net.WebHeaderCollection.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/86_System.Net.WebProxy.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/87_System.Net.WebSockets.Client.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/88_System.Net.WebSockets.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/89_System.Numerics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/8_netstandard.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/90_System.Numerics.Vectors.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/91_System.ObjectModel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/92_System.Private.CoreLib.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/93_System.Private.DataContractSerialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/94_System.Private.Uri.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/95_System.Private.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/96_System.Private.Xml.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/97_System.Reflection.DispatchProxy.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/98_System.Reflection.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/99_System.Reflection.Emit.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/9_System.AppContext.dll +0 -0
- package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/main.mjs +5 -0
- package/workers/vendor/csharp/package.json +1 -0
- package/workers/vendor/java-browser-helper.jar +0 -0
- package/workers/vendor/java-rewriter.jar +0 -0
- package/workers/vendor/javascript-libraries.js +10106 -0
- package/dist/runtime-types-89nchXlY.d.cts +0 -89
- package/dist/runtime-types-CCQ-ZLc9.d.ts +0 -89
- package/dist/types-zyvpJKCi.d.cts +0 -100
- package/dist/types-zyvpJKCi.d.ts +0 -100
- package/workers/java/java-source-augmentations.cjs +0 -242
- package/workers/java/src/spike/user/TraceHooks.java +0 -619
- package/workers/vendor/java-browser-spike-helper.jar +0 -0
- package/workers/vendor/java-practice-rewriter.jar +0 -0
- package/workers/vendor/java-rewrite-bridge.jar +0 -0
|
@@ -20,14 +20,52 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// packages/harness-browser/src/internal.ts
|
|
21
21
|
var internal_exports = {};
|
|
22
22
|
__export(internal_exports, {
|
|
23
|
+
CSharpWorkerClient: () => CSharpWorkerClient,
|
|
24
|
+
CppWorkerClient: () => CppWorkerClient,
|
|
23
25
|
JavaScriptWorkerClient: () => JavaScriptWorkerClient,
|
|
24
26
|
JavaWorkerClient: () => JavaWorkerClient,
|
|
25
|
-
PyodideWorkerClient: () =>
|
|
27
|
+
PyodideWorkerClient: () => PythonWorkerClient,
|
|
28
|
+
PythonWorkerClient: () => PythonWorkerClient,
|
|
26
29
|
isJavaScriptWorkerSupported: () => isJavaScriptWorkerSupported,
|
|
27
30
|
isWorkerSupported: () => isWorkerSupported
|
|
28
31
|
});
|
|
29
32
|
module.exports = __toCommonJS(internal_exports);
|
|
30
33
|
|
|
34
|
+
// packages/harness-core/src/runtime-trace.ts
|
|
35
|
+
var RUNTIME_TRACE_SCHEMA_VERSION = "runtime-trace-2026-04-28";
|
|
36
|
+
function createEmptyRuntimeTrace(language, options = {}) {
|
|
37
|
+
return {
|
|
38
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
39
|
+
language,
|
|
40
|
+
runId: options.runId ?? `${language}:run`,
|
|
41
|
+
events: [],
|
|
42
|
+
lineEventCount: 0,
|
|
43
|
+
traceStepCount: 0
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// packages/harness-browser/src/runtime-diagnostics.ts
|
|
48
|
+
var CONSOLE_METHOD_BY_LEVEL = {
|
|
49
|
+
debug: "debug",
|
|
50
|
+
info: "info",
|
|
51
|
+
warn: "warn",
|
|
52
|
+
error: "error"
|
|
53
|
+
};
|
|
54
|
+
function runtimeDiagnosticEvent(params) {
|
|
55
|
+
return {
|
|
56
|
+
schema: "tracecode.runtime-diagnostic.v1",
|
|
57
|
+
source: "harness",
|
|
58
|
+
...params
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function logRuntimeDiagnostic(level, params, options = {}) {
|
|
62
|
+
if (options.enabled === false && level !== "error") {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const method = CONSOLE_METHOD_BY_LEVEL[level] ?? "info";
|
|
66
|
+
console[method]("[TraceRuntime]", runtimeDiagnosticEvent(params));
|
|
67
|
+
}
|
|
68
|
+
|
|
31
69
|
// packages/harness-browser/src/pyodide-worker-client.ts
|
|
32
70
|
var EXECUTION_TIMEOUT_MS = 1e4;
|
|
33
71
|
var INTERVIEW_MODE_TIMEOUT_MS = 5e3;
|
|
@@ -35,7 +73,7 @@ var TRACING_TIMEOUT_MS = 3e4;
|
|
|
35
73
|
var INIT_TIMEOUT_MS = 12e4;
|
|
36
74
|
var MESSAGE_TIMEOUT_MS = 2e4;
|
|
37
75
|
var WORKER_READY_TIMEOUT_MS = 1e4;
|
|
38
|
-
var
|
|
76
|
+
var PythonWorkerClient = class {
|
|
39
77
|
constructor(options) {
|
|
40
78
|
this.options = options;
|
|
41
79
|
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
@@ -45,6 +83,7 @@ var PyodideWorkerClient = class {
|
|
|
45
83
|
messageId = 0;
|
|
46
84
|
isInitializing = false;
|
|
47
85
|
initPromise = null;
|
|
86
|
+
warmupPromise = null;
|
|
48
87
|
workerReadyPromise = null;
|
|
49
88
|
workerReadyResolve = null;
|
|
50
89
|
workerReadyReject = null;
|
|
@@ -75,11 +114,22 @@ var PyodideWorkerClient = class {
|
|
|
75
114
|
this.workerReadyResolve?.();
|
|
76
115
|
this.workerReadyResolve = null;
|
|
77
116
|
this.workerReadyReject = null;
|
|
78
|
-
|
|
117
|
+
logRuntimeDiagnostic("info", {
|
|
118
|
+
component: "PythonWorkerClient",
|
|
119
|
+
runtime: "python",
|
|
120
|
+
phase: "worker-ready",
|
|
121
|
+
message: "Python worker is ready."
|
|
122
|
+
}, { enabled: this.debug });
|
|
79
123
|
return;
|
|
80
124
|
}
|
|
81
125
|
if (this.debug && !id) {
|
|
82
|
-
|
|
126
|
+
logRuntimeDiagnostic("debug", {
|
|
127
|
+
component: "PythonWorkerClient",
|
|
128
|
+
runtime: "python",
|
|
129
|
+
phase: "worker-event",
|
|
130
|
+
message: "Python worker emitted an unsolicited event.",
|
|
131
|
+
detail: { type, payload }
|
|
132
|
+
}, { enabled: this.debug });
|
|
83
133
|
}
|
|
84
134
|
if (id) {
|
|
85
135
|
const pending = this.pendingMessages.get(id);
|
|
@@ -89,14 +139,31 @@ var PyodideWorkerClient = class {
|
|
|
89
139
|
if (type === "error") {
|
|
90
140
|
pending.reject(new Error(payload.error));
|
|
91
141
|
} else {
|
|
92
|
-
|
|
142
|
+
logRuntimeDiagnostic("debug", {
|
|
143
|
+
component: "PythonWorkerClient",
|
|
144
|
+
runtime: "python",
|
|
145
|
+
phase: "worker-response",
|
|
146
|
+
message: "Python worker response received.",
|
|
147
|
+
detail: { id, type }
|
|
148
|
+
}, { enabled: this.debug });
|
|
93
149
|
pending.resolve(payload);
|
|
94
150
|
}
|
|
95
151
|
}
|
|
96
152
|
}
|
|
97
153
|
};
|
|
98
154
|
this.worker.onerror = (error) => {
|
|
99
|
-
|
|
155
|
+
logRuntimeDiagnostic("error", {
|
|
156
|
+
component: "PythonWorkerClient",
|
|
157
|
+
runtime: "python",
|
|
158
|
+
phase: "worker-error",
|
|
159
|
+
message: "Python worker emitted an error event.",
|
|
160
|
+
detail: {
|
|
161
|
+
message: error.message,
|
|
162
|
+
filename: error.filename,
|
|
163
|
+
lineno: error.lineno,
|
|
164
|
+
colno: error.colno
|
|
165
|
+
}
|
|
166
|
+
});
|
|
100
167
|
const workerError = new Error("Worker error");
|
|
101
168
|
this.workerReadyReject?.(workerError);
|
|
102
169
|
this.workerReadyResolve = null;
|
|
@@ -126,9 +193,13 @@ var PyodideWorkerClient = class {
|
|
|
126
193
|
const timeoutError = new Error(
|
|
127
194
|
`Python worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS / 1e3)}s)`
|
|
128
195
|
);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
196
|
+
logRuntimeDiagnostic("warn", {
|
|
197
|
+
component: "PythonWorkerClient",
|
|
198
|
+
runtime: "python",
|
|
199
|
+
phase: "worker-ready-timeout",
|
|
200
|
+
message: "Python worker did not send worker-ready before the timeout.",
|
|
201
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS }
|
|
202
|
+
}, { enabled: this.debug });
|
|
132
203
|
this.terminateAndReset(timeoutError);
|
|
133
204
|
reject(timeoutError);
|
|
134
205
|
}, WORKER_READY_TIMEOUT_MS);
|
|
@@ -157,12 +228,24 @@ var PyodideWorkerClient = class {
|
|
|
157
228
|
resolve,
|
|
158
229
|
reject
|
|
159
230
|
});
|
|
160
|
-
|
|
231
|
+
logRuntimeDiagnostic("debug", {
|
|
232
|
+
component: "PythonWorkerClient",
|
|
233
|
+
runtime: "python",
|
|
234
|
+
phase: "worker-request",
|
|
235
|
+
message: "Sending request to Python worker.",
|
|
236
|
+
detail: { id, type }
|
|
237
|
+
}, { enabled: this.debug });
|
|
161
238
|
const timeoutId = globalThis.setTimeout(() => {
|
|
162
239
|
const pending2 = this.pendingMessages.get(id);
|
|
163
240
|
if (!pending2) return;
|
|
164
241
|
this.pendingMessages.delete(id);
|
|
165
|
-
|
|
242
|
+
logRuntimeDiagnostic("warn", {
|
|
243
|
+
component: "PythonWorkerClient",
|
|
244
|
+
runtime: "python",
|
|
245
|
+
phase: "worker-request-timeout",
|
|
246
|
+
message: "Python worker request timed out.",
|
|
247
|
+
detail: { id, type, timeoutMs }
|
|
248
|
+
}, { enabled: this.debug });
|
|
166
249
|
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
167
250
|
}, timeoutMs);
|
|
168
251
|
const pending = this.pendingMessages.get(id);
|
|
@@ -179,9 +262,13 @@ var PyodideWorkerClient = class {
|
|
|
179
262
|
const timeoutId = globalThis.setTimeout(() => {
|
|
180
263
|
if (settled) return;
|
|
181
264
|
settled = true;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
265
|
+
logRuntimeDiagnostic("warn", {
|
|
266
|
+
component: "PythonWorkerClient",
|
|
267
|
+
runtime: "python",
|
|
268
|
+
phase: "execution-timeout",
|
|
269
|
+
message: "Python execution timed out; terminating worker.",
|
|
270
|
+
detail: { timeoutMs }
|
|
271
|
+
}, { enabled: this.debug });
|
|
185
272
|
this.terminateAndReset();
|
|
186
273
|
const seconds = Math.round(timeoutMs / 1e3);
|
|
187
274
|
reject(new Error(`Execution timed out (possible infinite loop). Code execution was stopped after ${seconds} seconds.`));
|
|
@@ -209,6 +296,7 @@ var PyodideWorkerClient = class {
|
|
|
209
296
|
this.worker = null;
|
|
210
297
|
}
|
|
211
298
|
this.initPromise = null;
|
|
299
|
+
this.warmupPromise = null;
|
|
212
300
|
this.isInitializing = false;
|
|
213
301
|
this.workerReadyPromise = null;
|
|
214
302
|
this.workerReadyResolve = null;
|
|
@@ -219,7 +307,7 @@ var PyodideWorkerClient = class {
|
|
|
219
307
|
this.pendingMessages.clear();
|
|
220
308
|
}
|
|
221
309
|
/**
|
|
222
|
-
* Initialize
|
|
310
|
+
* Initialize the Python worker. Runtime loading is lazy unless warmup() is called.
|
|
223
311
|
*/
|
|
224
312
|
async init() {
|
|
225
313
|
if (this.initPromise) {
|
|
@@ -239,9 +327,13 @@ var PyodideWorkerClient = class {
|
|
|
239
327
|
if (!shouldRetry) {
|
|
240
328
|
throw error;
|
|
241
329
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
330
|
+
logRuntimeDiagnostic("warn", {
|
|
331
|
+
component: "PythonWorkerClient",
|
|
332
|
+
runtime: "python",
|
|
333
|
+
phase: "init-retry",
|
|
334
|
+
message: "Python worker init failed; resetting worker and retrying once.",
|
|
335
|
+
detail: { message }
|
|
336
|
+
}, { enabled: this.debug });
|
|
245
337
|
this.terminateAndReset();
|
|
246
338
|
return this.sendMessage("init", void 0, INIT_TIMEOUT_MS);
|
|
247
339
|
}
|
|
@@ -256,6 +348,19 @@ var PyodideWorkerClient = class {
|
|
|
256
348
|
this.isInitializing = false;
|
|
257
349
|
}
|
|
258
350
|
}
|
|
351
|
+
async warmup() {
|
|
352
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
353
|
+
this.warmupPromise = (async () => {
|
|
354
|
+
try {
|
|
355
|
+
await this.init();
|
|
356
|
+
return await this.sendMessage("warmup", void 0, INIT_TIMEOUT_MS);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
this.warmupPromise = null;
|
|
359
|
+
throw error;
|
|
360
|
+
}
|
|
361
|
+
})();
|
|
362
|
+
return this.warmupPromise;
|
|
363
|
+
}
|
|
259
364
|
/**
|
|
260
365
|
* Execute Python code with tracing for step-by-step visualization
|
|
261
366
|
* @param options.maxLineEvents - Max line events before abort (for complexity analysis, use higher values)
|
|
@@ -281,7 +386,7 @@ var PyodideWorkerClient = class {
|
|
|
281
386
|
return {
|
|
282
387
|
success: false,
|
|
283
388
|
error: errorMessage,
|
|
284
|
-
trace:
|
|
389
|
+
trace: createEmptyRuntimeTrace("python", { runId: "python:run", file: "solution.py" }),
|
|
285
390
|
executionTimeMs: TRACING_TIMEOUT_MS,
|
|
286
391
|
consoleOutput: [],
|
|
287
392
|
traceLimitExceeded: true,
|
|
@@ -381,10 +486,11 @@ function isWorkerSupported() {
|
|
|
381
486
|
}
|
|
382
487
|
|
|
383
488
|
// packages/harness-browser/src/javascript-worker-client.ts
|
|
384
|
-
var EXECUTION_TIMEOUT_MS2 =
|
|
489
|
+
var EXECUTION_TIMEOUT_MS2 = 2e4;
|
|
385
490
|
var INTERVIEW_MODE_TIMEOUT_MS2 = 5e3;
|
|
386
|
-
var TRACING_TIMEOUT_MS2 =
|
|
491
|
+
var TRACING_TIMEOUT_MS2 = 2e4;
|
|
387
492
|
var INIT_TIMEOUT_MS2 = 1e4;
|
|
493
|
+
var TYPESCRIPT_WARMUP_TIMEOUT_MS = 3e4;
|
|
388
494
|
var MESSAGE_TIMEOUT_MS2 = 12e3;
|
|
389
495
|
var WORKER_READY_TIMEOUT_MS2 = 1e4;
|
|
390
496
|
var JavaScriptWorkerClient = class {
|
|
@@ -397,6 +503,7 @@ var JavaScriptWorkerClient = class {
|
|
|
397
503
|
messageId = 0;
|
|
398
504
|
isInitializing = false;
|
|
399
505
|
initPromise = null;
|
|
506
|
+
warmupPromises = /* @__PURE__ */ new Map();
|
|
400
507
|
workerReadyPromise = null;
|
|
401
508
|
workerReadyResolve = null;
|
|
402
509
|
workerReadyReject = null;
|
|
@@ -421,7 +528,12 @@ var JavaScriptWorkerClient = class {
|
|
|
421
528
|
this.workerReadyResolve?.();
|
|
422
529
|
this.workerReadyResolve = null;
|
|
423
530
|
this.workerReadyReject = null;
|
|
424
|
-
|
|
531
|
+
logRuntimeDiagnostic("info", {
|
|
532
|
+
component: "JavaScriptWorkerClient",
|
|
533
|
+
runtime: "javascript",
|
|
534
|
+
phase: "worker-ready",
|
|
535
|
+
message: "JavaScript worker is ready."
|
|
536
|
+
}, { enabled: this.debug });
|
|
425
537
|
return;
|
|
426
538
|
}
|
|
427
539
|
if (id) {
|
|
@@ -437,7 +549,18 @@ var JavaScriptWorkerClient = class {
|
|
|
437
549
|
}
|
|
438
550
|
};
|
|
439
551
|
this.worker.onerror = (error) => {
|
|
440
|
-
|
|
552
|
+
logRuntimeDiagnostic("error", {
|
|
553
|
+
component: "JavaScriptWorkerClient",
|
|
554
|
+
runtime: "javascript",
|
|
555
|
+
phase: "worker-error",
|
|
556
|
+
message: "JavaScript worker emitted an error event.",
|
|
557
|
+
detail: {
|
|
558
|
+
message: error.message,
|
|
559
|
+
filename: error.filename,
|
|
560
|
+
lineno: error.lineno,
|
|
561
|
+
colno: error.colno
|
|
562
|
+
}
|
|
563
|
+
});
|
|
441
564
|
const workerError = new Error("Worker error");
|
|
442
565
|
this.workerReadyReject?.(workerError);
|
|
443
566
|
this.workerReadyResolve = null;
|
|
@@ -530,6 +653,7 @@ var JavaScriptWorkerClient = class {
|
|
|
530
653
|
this.worker = null;
|
|
531
654
|
}
|
|
532
655
|
this.initPromise = null;
|
|
656
|
+
this.warmupPromises.clear();
|
|
533
657
|
this.isInitializing = false;
|
|
534
658
|
this.workerReadyPromise = null;
|
|
535
659
|
this.workerReadyResolve = null;
|
|
@@ -557,6 +681,25 @@ var JavaScriptWorkerClient = class {
|
|
|
557
681
|
this.isInitializing = false;
|
|
558
682
|
}
|
|
559
683
|
}
|
|
684
|
+
async warmup(language = "javascript") {
|
|
685
|
+
const existing = this.warmupPromises.get(language);
|
|
686
|
+
if (existing) return existing;
|
|
687
|
+
const warmupPromise = (async () => {
|
|
688
|
+
await this.init();
|
|
689
|
+
return this.sendMessage(
|
|
690
|
+
"warmup",
|
|
691
|
+
{ language },
|
|
692
|
+
language === "typescript" ? TYPESCRIPT_WARMUP_TIMEOUT_MS : INIT_TIMEOUT_MS2
|
|
693
|
+
);
|
|
694
|
+
})();
|
|
695
|
+
this.warmupPromises.set(language, warmupPromise);
|
|
696
|
+
try {
|
|
697
|
+
return await warmupPromise;
|
|
698
|
+
} catch (error) {
|
|
699
|
+
this.warmupPromises.delete(language);
|
|
700
|
+
throw error;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
560
703
|
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function", language = "javascript") {
|
|
561
704
|
await this.init();
|
|
562
705
|
return this.executeWithTimeout(
|
|
@@ -639,11 +782,351 @@ function isJavaScriptWorkerSupported() {
|
|
|
639
782
|
return typeof Worker !== "undefined";
|
|
640
783
|
}
|
|
641
784
|
|
|
785
|
+
// packages/harness-core/src/runtime-raw-emission-contract.ts
|
|
786
|
+
function sortedUnique(values) {
|
|
787
|
+
return [...new Set(values)].sort((left, right) => left.localeCompare(right));
|
|
788
|
+
}
|
|
789
|
+
var FORBIDDEN_RUNTIME_TRACE_TOKENS = [
|
|
790
|
+
"visualization",
|
|
791
|
+
"objectKinds",
|
|
792
|
+
"hashMaps",
|
|
793
|
+
"graph-adjacency",
|
|
794
|
+
"linked-list",
|
|
795
|
+
"tree"
|
|
796
|
+
];
|
|
797
|
+
var FORBIDDEN_RUNTIME_TRACE_KEYS = /* @__PURE__ */ new Set([
|
|
798
|
+
"visualization",
|
|
799
|
+
"objectKinds",
|
|
800
|
+
"hashMaps",
|
|
801
|
+
"graph-adjacency",
|
|
802
|
+
"linked-list"
|
|
803
|
+
]);
|
|
804
|
+
function normalizeJavaNativeTraceJsonPayload(payload) {
|
|
805
|
+
return payload.replace(/(?<![A-Za-z0-9_"])-Infinity(?![A-Za-z0-9_"])/g, '"-Infinity"').replace(/(?<![A-Za-z0-9_"])Infinity(?![A-Za-z0-9_"])/g, '"Infinity"').replace(/(?<![A-Za-z0-9_"])NaN(?![A-Za-z0-9_"])/g, '"NaN"');
|
|
806
|
+
}
|
|
807
|
+
function forbiddenRuntimeTraceTokens(value) {
|
|
808
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
809
|
+
collectForbiddenRuntimeTraceTokens(value, tokens, null, false);
|
|
810
|
+
return FORBIDDEN_RUNTIME_TRACE_TOKENS.filter((token) => tokens.has(token));
|
|
811
|
+
}
|
|
812
|
+
function collectForbiddenRuntimeTraceTokens(value, tokens, parentKey, semanticPayload) {
|
|
813
|
+
if (typeof value === "string") {
|
|
814
|
+
if ((semanticPayload || parentKey === "kind" || parentKey === "type" || parentKey === "category") && FORBIDDEN_RUNTIME_TRACE_TOKENS.includes(value)) {
|
|
815
|
+
tokens.add(value);
|
|
816
|
+
}
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (value === null || typeof value !== "object") return;
|
|
820
|
+
if (Array.isArray(value)) {
|
|
821
|
+
for (const item of value) collectForbiddenRuntimeTraceTokens(item, tokens, parentKey, semanticPayload);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
const entries = Object.entries(value);
|
|
825
|
+
const objectSemanticPayload = entries.some(([key, child]) => {
|
|
826
|
+
if (parentKey !== "args" && FORBIDDEN_RUNTIME_TRACE_KEYS.has(key)) return true;
|
|
827
|
+
return (key === "kind" || key === "type" || key === "category") && typeof child === "string" && FORBIDDEN_RUNTIME_TRACE_TOKENS.includes(child);
|
|
828
|
+
});
|
|
829
|
+
for (const [key, child] of entries) {
|
|
830
|
+
if (parentKey !== "args" && FORBIDDEN_RUNTIME_TRACE_KEYS.has(key)) {
|
|
831
|
+
tokens.add(key);
|
|
832
|
+
}
|
|
833
|
+
if (key === "target" || key === "variable" || key === "function") continue;
|
|
834
|
+
collectForbiddenRuntimeTraceTokens(child, tokens, key, semanticPayload || objectSemanticPayload);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
function unsupportedForbiddenPayload(label, value) {
|
|
838
|
+
const tokens = forbiddenRuntimeTraceTokens(value);
|
|
839
|
+
if (tokens.length === 0) return null;
|
|
840
|
+
return `${label} contains forbidden runtime trace token(s): ${tokens.join(", ")}`;
|
|
841
|
+
}
|
|
842
|
+
function javaNativeTracePayloadKind(event) {
|
|
843
|
+
if (!event.startsWith("trace:")) return null;
|
|
844
|
+
try {
|
|
845
|
+
const parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
|
|
846
|
+
if (parsed.kind === "line") return "line";
|
|
847
|
+
if (parsed.kind === "call") return "call";
|
|
848
|
+
if (parsed.kind === "return") return "return";
|
|
849
|
+
if (parsed.kind === "exception") return "exception";
|
|
850
|
+
if (parsed.kind === "timeout") return "timeout";
|
|
851
|
+
if (parsed.kind === "stdout") return "stdout";
|
|
852
|
+
if (parsed.kind === "snapshot") return "snapshot";
|
|
853
|
+
if (parsed.kind === "read") return "read";
|
|
854
|
+
if (parsed.kind === "write") return "write";
|
|
855
|
+
if (parsed.kind === "mutate") return "mutate";
|
|
856
|
+
} catch {
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
859
|
+
return null;
|
|
860
|
+
}
|
|
861
|
+
function summarizeJavaRawEmissions(events) {
|
|
862
|
+
const kinds = [];
|
|
863
|
+
const unsupported = [];
|
|
864
|
+
for (const [index, event] of events.entries()) {
|
|
865
|
+
if (event.startsWith("trace:")) {
|
|
866
|
+
try {
|
|
867
|
+
const parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
|
|
868
|
+
const forbiddenPayload = unsupportedForbiddenPayload(`java trace event ${index}`, parsed);
|
|
869
|
+
if (forbiddenPayload) {
|
|
870
|
+
unsupported.push(forbiddenPayload);
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
} catch {
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
const nativeKind = javaNativeTracePayloadKind(event);
|
|
877
|
+
if (nativeKind) {
|
|
878
|
+
kinds.push(nativeKind);
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
unsupported.push(event);
|
|
882
|
+
}
|
|
883
|
+
return {
|
|
884
|
+
language: "java",
|
|
885
|
+
kinds: sortedUnique(kinds),
|
|
886
|
+
unsupported
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function assertSupportedRawEmissions(summary, label) {
|
|
890
|
+
if (summary.unsupported.length > 0) {
|
|
891
|
+
throw new Error(
|
|
892
|
+
`${label} emitted unsupported raw runtime payloads:
|
|
893
|
+
${summary.unsupported.slice(0, 20).join("\n")}`
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// packages/harness-core/src/trace-adapters/java.ts
|
|
899
|
+
function isNativeJavaTraceEvent(event) {
|
|
900
|
+
return event.startsWith("trace:");
|
|
901
|
+
}
|
|
902
|
+
function stripInlineComments(line, inBlockComment) {
|
|
903
|
+
let result = "";
|
|
904
|
+
let index = 0;
|
|
905
|
+
let inBlock = inBlockComment;
|
|
906
|
+
while (index < line.length) {
|
|
907
|
+
const current = line[index];
|
|
908
|
+
const next = index + 1 < line.length ? line[index + 1] : "";
|
|
909
|
+
if (inBlock) {
|
|
910
|
+
if (current === "*" && next === "/") {
|
|
911
|
+
inBlock = false;
|
|
912
|
+
index += 2;
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
915
|
+
index += 1;
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
if (current === "/" && next === "*") {
|
|
919
|
+
inBlock = true;
|
|
920
|
+
index += 2;
|
|
921
|
+
continue;
|
|
922
|
+
}
|
|
923
|
+
if (current === "/" && next === "/") break;
|
|
924
|
+
result += current;
|
|
925
|
+
index += 1;
|
|
926
|
+
}
|
|
927
|
+
return { text: result, inBlockComment: inBlock };
|
|
928
|
+
}
|
|
929
|
+
function isMethodDeclarationLine(line) {
|
|
930
|
+
const trimmed = line.trim();
|
|
931
|
+
if (!trimmed) return false;
|
|
932
|
+
if (trimmed.startsWith("@")) return false;
|
|
933
|
+
if (!trimmed.includes("(") || !trimmed.includes(")")) return false;
|
|
934
|
+
if (trimmed.endsWith(";")) return false;
|
|
935
|
+
if (trimmed.includes("->")) return false;
|
|
936
|
+
if (/^(?:if|for|while|switch|catch|do|try|else|return|throw|new)\b/.test(trimmed)) return false;
|
|
937
|
+
if (!/[A-Za-z_][A-Za-z0-9_]*\s*\([^{};]*\)/.test(trimmed)) return false;
|
|
938
|
+
return /(?:\{\s*)?$/.test(trimmed);
|
|
939
|
+
}
|
|
940
|
+
function buildLocalDeclarationNamesByLine(sourceText) {
|
|
941
|
+
const namesByLine = /* @__PURE__ */ new Map();
|
|
942
|
+
if (typeof sourceText !== "string" || sourceText.length === 0) return namesByLine;
|
|
943
|
+
const lines = sourceText.split(/\r?\n/);
|
|
944
|
+
let inBlockComment = false;
|
|
945
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
946
|
+
const { text, inBlockComment: nextInBlockComment } = stripInlineComments(lines[index] ?? "", inBlockComment);
|
|
947
|
+
inBlockComment = nextInBlockComment;
|
|
948
|
+
if (isMethodDeclarationLine(text)) continue;
|
|
949
|
+
const names = [];
|
|
950
|
+
const declarationPattern = /\b(?:final\s+)?(?:[A-Za-z_][A-Za-z0-9_.$]*(?:\s*<[^;=(){}]+>)?(?:\s*\[\])?)\s+([A-Za-z_][A-Za-z0-9_]*)\s*=/g;
|
|
951
|
+
for (const match of text.matchAll(declarationPattern)) {
|
|
952
|
+
if (match[1]) names.push(match[1]);
|
|
953
|
+
}
|
|
954
|
+
if (names.length > 0) namesByLine.set(index + 1, names);
|
|
955
|
+
}
|
|
956
|
+
return namesByLine;
|
|
957
|
+
}
|
|
958
|
+
function removeSameLineMutationDeclarationSnapshotEvents(events, sourceText) {
|
|
959
|
+
const declarationNamesByLine = buildLocalDeclarationNamesByLine(sourceText);
|
|
960
|
+
if (declarationNamesByLine.size === 0) return events;
|
|
961
|
+
const mutationVariablesByLine = /* @__PURE__ */ new Map();
|
|
962
|
+
for (const event of events) {
|
|
963
|
+
if (event.kind !== "mutate" || typeof event.line !== "number" || !("variable" in event.target)) continue;
|
|
964
|
+
const variables = mutationVariablesByLine.get(event.line) ?? /* @__PURE__ */ new Set();
|
|
965
|
+
variables.add(event.target.variable);
|
|
966
|
+
mutationVariablesByLine.set(event.line, variables);
|
|
967
|
+
}
|
|
968
|
+
if (mutationVariablesByLine.size === 0) return events;
|
|
969
|
+
return events.filter((event) => {
|
|
970
|
+
if (event.kind !== "snapshot" || typeof event.line !== "number" || !("variable" in event.target)) return true;
|
|
971
|
+
const declaredNames = declarationNamesByLine.get(event.line);
|
|
972
|
+
if (!declaredNames?.includes(event.target.variable)) return true;
|
|
973
|
+
const mutationVariables = mutationVariablesByLine.get(event.line);
|
|
974
|
+
return mutationVariables?.has(event.target.variable) === true;
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
function collectJavaLineDeclarationsForHeaderExpansion(line) {
|
|
978
|
+
const names = [];
|
|
979
|
+
const declarationPattern = /\b(?:final\s+)?((?:boolean|byte|char|short|int|long|float|double|String|Object|[A-Za-z_][A-Za-z0-9_<>.?]*(?:\s*<[^,;=(){}:]+>)?)\s*(?:\[\s*\])*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?==)/g;
|
|
980
|
+
const skippedNames = /* @__PURE__ */ new Set(["class", "interface", "enum", "record", "return", "new"]);
|
|
981
|
+
for (const match of line.matchAll(declarationPattern)) {
|
|
982
|
+
const typeSource = match[1] ?? "";
|
|
983
|
+
const name = match[2];
|
|
984
|
+
if (!name || skippedNames.has(name) || name.startsWith("__tracecode")) continue;
|
|
985
|
+
if (typeSource.includes("[")) continue;
|
|
986
|
+
names.push(name);
|
|
987
|
+
}
|
|
988
|
+
return names;
|
|
989
|
+
}
|
|
990
|
+
function collectJavaControlHeaderDeclarations(line) {
|
|
991
|
+
const forMatch = /\bfor\s*\(\s*(?:final\s+)?(?:[A-Za-z_][A-Za-z0-9_<>.?]*(?:\s*<[^;=(){}:]+>)?|\w+(?:\s*\[\s*\])*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:=|:)/.exec(line);
|
|
992
|
+
return forMatch?.[1] ? [forMatch[1]] : [];
|
|
993
|
+
}
|
|
994
|
+
function buildJavaControlHeaderInfo(sourceText) {
|
|
995
|
+
if (typeof sourceText !== "string" || sourceText.length === 0) return null;
|
|
996
|
+
const lines = sourceText.split(/\r?\n/);
|
|
997
|
+
const loopBodyLineToHeader = /* @__PURE__ */ new Map();
|
|
998
|
+
const headerLineToExcludedVariables = /* @__PURE__ */ new Map();
|
|
999
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
1000
|
+
const line = lines[index] ?? "";
|
|
1001
|
+
const isLoopHeader = /\b(?:for|while)\s*\(/.test(line);
|
|
1002
|
+
const isControlHeader = /\b(?:for|while|if|else\s+if)\s*\(/.test(line);
|
|
1003
|
+
if (!isControlHeader || !line.includes("{")) continue;
|
|
1004
|
+
for (let bodyIndex = index + 1; bodyIndex < lines.length; bodyIndex += 1) {
|
|
1005
|
+
const trimmed = (lines[bodyIndex] ?? "").trim();
|
|
1006
|
+
if (trimmed.length === 0) continue;
|
|
1007
|
+
if (trimmed.startsWith("}")) break;
|
|
1008
|
+
const headerInfo = {
|
|
1009
|
+
line: index + 1,
|
|
1010
|
+
excludedVariables: new Set(collectJavaLineDeclarationsForHeaderExpansion(lines[bodyIndex] ?? "")),
|
|
1011
|
+
headerVariables: new Set(collectJavaControlHeaderDeclarations(line))
|
|
1012
|
+
};
|
|
1013
|
+
if (isLoopHeader) loopBodyLineToHeader.set(bodyIndex + 1, headerInfo);
|
|
1014
|
+
headerLineToExcludedVariables.set(index + 1, headerInfo.excludedVariables);
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
if (loopBodyLineToHeader.size === 0 && headerLineToExcludedVariables.size === 0) return null;
|
|
1019
|
+
return { loopBodyLineToHeader, headerLineToExcludedVariables };
|
|
1020
|
+
}
|
|
1021
|
+
function eventLine(event) {
|
|
1022
|
+
return typeof event.line === "number" && Number.isFinite(event.line) && event.line > 0 ? event.line : null;
|
|
1023
|
+
}
|
|
1024
|
+
function eventSnapshotVariable(event) {
|
|
1025
|
+
if (event.kind !== "snapshot") return null;
|
|
1026
|
+
const target = event.target;
|
|
1027
|
+
if (!target || typeof target !== "object" || !("variable" in target)) return null;
|
|
1028
|
+
const variable = target.variable;
|
|
1029
|
+
return typeof variable === "string" && variable.length > 0 ? variable : null;
|
|
1030
|
+
}
|
|
1031
|
+
function cloneRuntimeEventAtLine(event, line) {
|
|
1032
|
+
return { ...event, line };
|
|
1033
|
+
}
|
|
1034
|
+
function expandJavaLoopHeaderTraceEvents(events, sourceText) {
|
|
1035
|
+
if (events.length === 0) return events;
|
|
1036
|
+
const controlHeaderInfo = buildJavaControlHeaderInfo(sourceText);
|
|
1037
|
+
if (!controlHeaderInfo) return events;
|
|
1038
|
+
const { loopBodyLineToHeader, headerLineToExcludedVariables } = controlHeaderInfo;
|
|
1039
|
+
const expanded = [];
|
|
1040
|
+
const latestSnapshotByVariable = /* @__PURE__ */ new Map();
|
|
1041
|
+
let lastLineEventLine = null;
|
|
1042
|
+
for (let index = 0; index < events.length; index += 1) {
|
|
1043
|
+
const event = events[index];
|
|
1044
|
+
const line = eventLine(event);
|
|
1045
|
+
const snapshotVariable = eventSnapshotVariable(event);
|
|
1046
|
+
if (line !== null && snapshotVariable && headerLineToExcludedVariables.get(line)?.has(snapshotVariable)) {
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
const headerInfo = line === null ? void 0 : loopBodyLineToHeader.get(line);
|
|
1050
|
+
const headerLine = headerInfo?.line;
|
|
1051
|
+
if (headerInfo && typeof headerLine === "number" && event.kind === "line" && lastLineEventLine !== headerLine) {
|
|
1052
|
+
expanded.push(cloneRuntimeEventAtLine(event, headerLine));
|
|
1053
|
+
for (const [variable, snapshotEvent] of latestSnapshotByVariable) {
|
|
1054
|
+
if (headerInfo.excludedVariables.has(variable)) continue;
|
|
1055
|
+
expanded.push(cloneRuntimeEventAtLine(snapshotEvent, headerLine));
|
|
1056
|
+
}
|
|
1057
|
+
lastLineEventLine = headerLine;
|
|
1058
|
+
}
|
|
1059
|
+
if (headerInfo && typeof headerLine === "number" && event.kind === "line") {
|
|
1060
|
+
for (let lookahead = index + 1; lookahead < events.length; lookahead += 1) {
|
|
1061
|
+
if (eventLine(events[lookahead]) !== line) break;
|
|
1062
|
+
const variable = eventSnapshotVariable(events[lookahead]);
|
|
1063
|
+
if (!variable || !headerInfo.headerVariables.has(variable)) continue;
|
|
1064
|
+
expanded.push(cloneRuntimeEventAtLine(events[lookahead], headerLine));
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
expanded.push(event);
|
|
1068
|
+
if (event.kind === "line") {
|
|
1069
|
+
lastLineEventLine = line;
|
|
1070
|
+
}
|
|
1071
|
+
if (snapshotVariable) {
|
|
1072
|
+
latestSnapshotByVariable.set(snapshotVariable, event);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return expanded;
|
|
1076
|
+
}
|
|
1077
|
+
function nativeJavaTraceEventsToTrace(events, sourceText, options = {}) {
|
|
1078
|
+
const runId = options.runId ?? "java:run";
|
|
1079
|
+
let parsedEvents = events.map((event) => {
|
|
1080
|
+
let parsed;
|
|
1081
|
+
try {
|
|
1082
|
+
parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
|
|
1083
|
+
} catch (error) {
|
|
1084
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1085
|
+
throw new Error(`Invalid Java native runtime trace event: ${message}
|
|
1086
|
+
${event.slice(0, 500)}`);
|
|
1087
|
+
}
|
|
1088
|
+
return {
|
|
1089
|
+
...parsed,
|
|
1090
|
+
runId,
|
|
1091
|
+
...options.file ? { file: options.file } : {}
|
|
1092
|
+
};
|
|
1093
|
+
});
|
|
1094
|
+
parsedEvents = removeSameLineMutationDeclarationSnapshotEvents(parsedEvents, sourceText);
|
|
1095
|
+
parsedEvents = expandJavaLoopHeaderTraceEvents(parsedEvents, sourceText);
|
|
1096
|
+
return {
|
|
1097
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1098
|
+
language: "java",
|
|
1099
|
+
runId,
|
|
1100
|
+
events: parsedEvents,
|
|
1101
|
+
lineEventCount: parsedEvents.filter((event) => event.kind === "line").length,
|
|
1102
|
+
traceStepCount: parsedEvents.length
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
function javaTraceHooksEventsToRuntimeTrace(events, sourceText, options = {}) {
|
|
1106
|
+
assertSupportedRawEmissions(summarizeJavaRawEmissions(events), "java");
|
|
1107
|
+
if (events.length === 0) {
|
|
1108
|
+
return {
|
|
1109
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1110
|
+
language: "java",
|
|
1111
|
+
runId: options.runId ?? "java:run",
|
|
1112
|
+
events: [],
|
|
1113
|
+
lineEventCount: 0,
|
|
1114
|
+
traceStepCount: 0
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
if (!events.every(isNativeJavaTraceEvent)) {
|
|
1118
|
+
throw new Error("Java TraceHooks must emit native runtime trace events. Unsupported line=... events are no longer supported.");
|
|
1119
|
+
}
|
|
1120
|
+
return nativeJavaTraceEventsToTrace(events, sourceText, options);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
642
1123
|
// packages/harness-browser/src/java-worker-client.ts
|
|
1124
|
+
var EXECUTION_TIMEOUT_MS3 = 2e4;
|
|
643
1125
|
var TRACING_TIMEOUT_MS3 = 25e3;
|
|
644
|
-
var INIT_TIMEOUT_MS3 =
|
|
1126
|
+
var INIT_TIMEOUT_MS3 = 12e4;
|
|
645
1127
|
var MESSAGE_TIMEOUT_MS3 = 3e4;
|
|
646
1128
|
var WORKER_READY_TIMEOUT_MS3 = 1e4;
|
|
1129
|
+
var JAVA_DEFAULT_FILE = "solution.java";
|
|
647
1130
|
var JavaWorkerClient = class {
|
|
648
1131
|
constructor(options) {
|
|
649
1132
|
this.options = options;
|
|
@@ -654,6 +1137,7 @@ var JavaWorkerClient = class {
|
|
|
654
1137
|
messageId = 0;
|
|
655
1138
|
isInitializing = false;
|
|
656
1139
|
initPromise = null;
|
|
1140
|
+
warmupPromise = null;
|
|
657
1141
|
workerReadyPromise = null;
|
|
658
1142
|
workerReadyResolve = null;
|
|
659
1143
|
workerReadyReject = null;
|
|
@@ -678,6 +1162,22 @@ var JavaWorkerClient = class {
|
|
|
678
1162
|
this.workerReadyResolve?.();
|
|
679
1163
|
this.workerReadyResolve = null;
|
|
680
1164
|
this.workerReadyReject = null;
|
|
1165
|
+
logRuntimeDiagnostic("info", {
|
|
1166
|
+
component: "JavaWorkerClient",
|
|
1167
|
+
runtime: "java",
|
|
1168
|
+
phase: "worker-ready",
|
|
1169
|
+
message: "Java worker is ready."
|
|
1170
|
+
}, { enabled: this.debug });
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
if (type === "idle-timeout") {
|
|
1174
|
+
logRuntimeDiagnostic("info", {
|
|
1175
|
+
component: "JavaWorkerClient",
|
|
1176
|
+
runtime: "java",
|
|
1177
|
+
phase: "idle-timeout",
|
|
1178
|
+
message: "Java worker closed after idle timeout."
|
|
1179
|
+
}, { enabled: this.debug });
|
|
1180
|
+
this.terminateAndReset(new Error("Java worker closed after idle timeout"));
|
|
681
1181
|
return;
|
|
682
1182
|
}
|
|
683
1183
|
if (!id) return;
|
|
@@ -692,6 +1192,18 @@ var JavaWorkerClient = class {
|
|
|
692
1192
|
pending.resolve(payload);
|
|
693
1193
|
};
|
|
694
1194
|
this.worker.onerror = (error) => {
|
|
1195
|
+
logRuntimeDiagnostic("error", {
|
|
1196
|
+
component: "JavaWorkerClient",
|
|
1197
|
+
runtime: "java",
|
|
1198
|
+
phase: "worker-error",
|
|
1199
|
+
message: "Java worker emitted an error event.",
|
|
1200
|
+
detail: {
|
|
1201
|
+
message: error.message,
|
|
1202
|
+
filename: error.filename,
|
|
1203
|
+
lineno: error.lineno,
|
|
1204
|
+
colno: error.colno
|
|
1205
|
+
}
|
|
1206
|
+
});
|
|
695
1207
|
const workerError = new Error(error.message || "Java worker error");
|
|
696
1208
|
this.workerReadyReject?.(workerError);
|
|
697
1209
|
this.workerReadyResolve = null;
|
|
@@ -716,6 +1228,13 @@ var JavaWorkerClient = class {
|
|
|
716
1228
|
const timeoutError = new Error(
|
|
717
1229
|
`Java worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS3 / 1e3)}s)`
|
|
718
1230
|
);
|
|
1231
|
+
logRuntimeDiagnostic("warn", {
|
|
1232
|
+
component: "JavaWorkerClient",
|
|
1233
|
+
runtime: "java",
|
|
1234
|
+
phase: "worker-ready-timeout",
|
|
1235
|
+
message: "Java worker did not send worker-ready before the timeout.",
|
|
1236
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS3 }
|
|
1237
|
+
}, { enabled: this.debug });
|
|
719
1238
|
this.terminateAndReset(timeoutError);
|
|
720
1239
|
reject(timeoutError);
|
|
721
1240
|
}, WORKER_READY_TIMEOUT_MS3);
|
|
@@ -745,6 +1264,13 @@ var JavaWorkerClient = class {
|
|
|
745
1264
|
const pending2 = this.pendingMessages.get(id);
|
|
746
1265
|
if (!pending2) return;
|
|
747
1266
|
this.pendingMessages.delete(id);
|
|
1267
|
+
logRuntimeDiagnostic("warn", {
|
|
1268
|
+
component: "JavaWorkerClient",
|
|
1269
|
+
runtime: "java",
|
|
1270
|
+
phase: "worker-request-timeout",
|
|
1271
|
+
message: "Java worker request timed out.",
|
|
1272
|
+
detail: { id, type, timeoutMs }
|
|
1273
|
+
}, { enabled: this.debug });
|
|
748
1274
|
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
749
1275
|
}, timeoutMs);
|
|
750
1276
|
const pending = this.pendingMessages.get(id);
|
|
@@ -758,6 +1284,13 @@ var JavaWorkerClient = class {
|
|
|
758
1284
|
const timeoutId = globalThis.setTimeout(() => {
|
|
759
1285
|
if (settled) return;
|
|
760
1286
|
settled = true;
|
|
1287
|
+
logRuntimeDiagnostic("warn", {
|
|
1288
|
+
component: "JavaWorkerClient",
|
|
1289
|
+
runtime: "java",
|
|
1290
|
+
phase: "execution-timeout",
|
|
1291
|
+
message: "Java execution timed out; terminating worker.",
|
|
1292
|
+
detail: { timeoutMs }
|
|
1293
|
+
}, { enabled: this.debug });
|
|
761
1294
|
this.terminateAndReset();
|
|
762
1295
|
reject(
|
|
763
1296
|
new Error(
|
|
@@ -785,6 +1318,7 @@ var JavaWorkerClient = class {
|
|
|
785
1318
|
this.worker = null;
|
|
786
1319
|
}
|
|
787
1320
|
this.initPromise = null;
|
|
1321
|
+
this.warmupPromise = null;
|
|
788
1322
|
this.isInitializing = false;
|
|
789
1323
|
this.workerReadyPromise = null;
|
|
790
1324
|
this.workerReadyResolve = null;
|
|
@@ -802,7 +1336,26 @@ var JavaWorkerClient = class {
|
|
|
802
1336
|
return this.init();
|
|
803
1337
|
}
|
|
804
1338
|
this.isInitializing = true;
|
|
805
|
-
this.initPromise =
|
|
1339
|
+
this.initPromise = (async () => {
|
|
1340
|
+
try {
|
|
1341
|
+
return await this.sendMessage("init", this.workerOptionsPayload(), INIT_TIMEOUT_MS3);
|
|
1342
|
+
} catch (error) {
|
|
1343
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1344
|
+
const shouldRetry = message.includes("Worker request timed out: init") || message.includes("Worker was terminated") || message.includes("Java worker error") || message.includes("failed to initialize in time");
|
|
1345
|
+
if (!shouldRetry) {
|
|
1346
|
+
throw error;
|
|
1347
|
+
}
|
|
1348
|
+
logRuntimeDiagnostic("warn", {
|
|
1349
|
+
component: "JavaWorkerClient",
|
|
1350
|
+
runtime: "java",
|
|
1351
|
+
phase: "init-retry",
|
|
1352
|
+
message: "Java worker init failed; resetting worker and retrying once.",
|
|
1353
|
+
detail: { message }
|
|
1354
|
+
}, { enabled: this.debug });
|
|
1355
|
+
this.terminateAndReset(error instanceof Error ? error : new Error(message));
|
|
1356
|
+
return this.sendMessage("init", this.workerOptionsPayload(), INIT_TIMEOUT_MS3);
|
|
1357
|
+
}
|
|
1358
|
+
})();
|
|
806
1359
|
try {
|
|
807
1360
|
return await this.initPromise;
|
|
808
1361
|
} catch (error) {
|
|
@@ -812,9 +1365,29 @@ var JavaWorkerClient = class {
|
|
|
812
1365
|
this.isInitializing = false;
|
|
813
1366
|
}
|
|
814
1367
|
}
|
|
1368
|
+
workerOptionsPayload() {
|
|
1369
|
+
return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
|
|
1370
|
+
}
|
|
1371
|
+
async warmup() {
|
|
1372
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
1373
|
+
this.warmupPromise = (async () => {
|
|
1374
|
+
try {
|
|
1375
|
+
await this.init();
|
|
1376
|
+
return await this.sendMessage(
|
|
1377
|
+
"warmup",
|
|
1378
|
+
this.workerOptionsPayload(),
|
|
1379
|
+
INIT_TIMEOUT_MS3
|
|
1380
|
+
);
|
|
1381
|
+
} catch (error) {
|
|
1382
|
+
this.warmupPromise = null;
|
|
1383
|
+
throw error;
|
|
1384
|
+
}
|
|
1385
|
+
})();
|
|
1386
|
+
return this.warmupPromise;
|
|
1387
|
+
}
|
|
815
1388
|
async executeWithTracing(code, functionName, inputs, options, executionStyle) {
|
|
816
1389
|
await this.init();
|
|
817
|
-
|
|
1390
|
+
const result = await this.executeWithTimeout(
|
|
818
1391
|
() => this.sendMessage(
|
|
819
1392
|
"execute-with-tracing",
|
|
820
1393
|
{ code, functionName, inputs, options, executionStyle },
|
|
@@ -822,26 +1395,1059 @@ var JavaWorkerClient = class {
|
|
|
822
1395
|
),
|
|
823
1396
|
TRACING_TIMEOUT_MS3
|
|
824
1397
|
);
|
|
1398
|
+
return {
|
|
1399
|
+
...result,
|
|
1400
|
+
trace: result.success ? javaTraceHooksEventsToRuntimeTrace(result.events, result.sourceText, {
|
|
1401
|
+
runId: "java:run",
|
|
1402
|
+
file: JAVA_DEFAULT_FILE
|
|
1403
|
+
}) : createEmptyRuntimeTrace("java", { runId: "java:run", file: JAVA_DEFAULT_FILE })
|
|
1404
|
+
};
|
|
825
1405
|
}
|
|
826
1406
|
async executeCode(code, functionName, inputs, options, executionStyle) {
|
|
827
|
-
|
|
1407
|
+
return this.executeCodeMessage("execute-code", code, functionName, inputs, options, executionStyle);
|
|
1408
|
+
}
|
|
1409
|
+
async executeCodeMessage(type, code, functionName, inputs, options, executionStyle) {
|
|
1410
|
+
await this.init();
|
|
1411
|
+
const result = await this.executeWithTimeout(
|
|
1412
|
+
() => this.sendMessage(
|
|
1413
|
+
type,
|
|
1414
|
+
{ code, functionName, inputs, options, executionStyle },
|
|
1415
|
+
EXECUTION_TIMEOUT_MS3 + 5e3
|
|
1416
|
+
),
|
|
1417
|
+
EXECUTION_TIMEOUT_MS3
|
|
1418
|
+
);
|
|
828
1419
|
if (!result.success) {
|
|
829
1420
|
return {
|
|
830
1421
|
success: false,
|
|
831
1422
|
output: null,
|
|
832
1423
|
error: result.error ?? "Java execution failed",
|
|
833
1424
|
...result.errorLine !== void 0 ? { errorLine: result.errorLine } : {},
|
|
834
|
-
consoleOutput: result.consoleOutput
|
|
1425
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1426
|
+
timings: result.timings
|
|
835
1427
|
};
|
|
836
1428
|
}
|
|
837
1429
|
return {
|
|
838
1430
|
success: true,
|
|
839
1431
|
output: result.output,
|
|
840
|
-
consoleOutput: result.consoleOutput
|
|
1432
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1433
|
+
timings: result.timings
|
|
841
1434
|
};
|
|
842
1435
|
}
|
|
843
1436
|
async executeCodeInterviewMode(code, functionName, inputs, options, executionStyle) {
|
|
844
|
-
return this.
|
|
1437
|
+
return this.executeCodeMessage("execute-code-interview", code, functionName, inputs, options, executionStyle);
|
|
1438
|
+
}
|
|
1439
|
+
terminate() {
|
|
1440
|
+
this.terminateAndReset();
|
|
1441
|
+
}
|
|
1442
|
+
};
|
|
1443
|
+
|
|
1444
|
+
// packages/harness-browser/src/csharp-worker-client.ts
|
|
1445
|
+
var EXECUTION_TIMEOUT_MS4 = 2e4;
|
|
1446
|
+
var TRACING_TIMEOUT_MS4 = 2e4;
|
|
1447
|
+
var INTERVIEW_MODE_TIMEOUT_MS3 = 5e3;
|
|
1448
|
+
var INIT_TIMEOUT_MS4 = 45e3;
|
|
1449
|
+
var MESSAGE_TIMEOUT_MS4 = 3e4;
|
|
1450
|
+
var WORKER_READY_TIMEOUT_MS4 = 1e4;
|
|
1451
|
+
var CSHARP_DEFAULT_FILE = "solution.cs";
|
|
1452
|
+
var CSHARP_LEGACY_USER_FILE = "UserCode.cs";
|
|
1453
|
+
function isCSharpUserFile(file) {
|
|
1454
|
+
return Boolean(file?.endsWith(CSHARP_DEFAULT_FILE) || file?.endsWith(CSHARP_LEGACY_USER_FILE));
|
|
1455
|
+
}
|
|
1456
|
+
function isCSharpUserDiagnostic(diagnostic) {
|
|
1457
|
+
return isCSharpUserFile(diagnostic.file);
|
|
1458
|
+
}
|
|
1459
|
+
function normalizeCSharpTraceEventFile(event) {
|
|
1460
|
+
return isCSharpUserFile(event.file) ? { ...event, file: CSHARP_DEFAULT_FILE } : event;
|
|
1461
|
+
}
|
|
1462
|
+
var CSharpWorkerClient = class {
|
|
1463
|
+
constructor(options) {
|
|
1464
|
+
this.options = options;
|
|
1465
|
+
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
1466
|
+
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS4;
|
|
1467
|
+
this.executionTimeoutMs = options.executionTimeoutMs ?? EXECUTION_TIMEOUT_MS4;
|
|
1468
|
+
this.tracingTimeoutMs = options.tracingTimeoutMs ?? TRACING_TIMEOUT_MS4;
|
|
1469
|
+
this.interviewTimeoutMs = options.interviewTimeoutMs ?? INTERVIEW_MODE_TIMEOUT_MS3;
|
|
1470
|
+
}
|
|
1471
|
+
worker = null;
|
|
1472
|
+
pendingMessages = /* @__PURE__ */ new Map();
|
|
1473
|
+
messageId = 0;
|
|
1474
|
+
isInitializing = false;
|
|
1475
|
+
initPromise = null;
|
|
1476
|
+
warmupPromise = null;
|
|
1477
|
+
workerReadyPromise = null;
|
|
1478
|
+
workerReadyResolve = null;
|
|
1479
|
+
workerReadyReject = null;
|
|
1480
|
+
debug;
|
|
1481
|
+
initTimeoutMs;
|
|
1482
|
+
executionTimeoutMs;
|
|
1483
|
+
tracingTimeoutMs;
|
|
1484
|
+
interviewTimeoutMs;
|
|
1485
|
+
isSupported() {
|
|
1486
|
+
return typeof Worker !== "undefined";
|
|
1487
|
+
}
|
|
1488
|
+
getWorker() {
|
|
1489
|
+
if (this.worker) return this.worker;
|
|
1490
|
+
if (!this.isSupported()) {
|
|
1491
|
+
throw new Error("Web Workers are not supported in this environment");
|
|
1492
|
+
}
|
|
1493
|
+
this.workerReadyPromise = new Promise((resolve, reject) => {
|
|
1494
|
+
this.workerReadyResolve = resolve;
|
|
1495
|
+
this.workerReadyReject = (error) => reject(error);
|
|
1496
|
+
});
|
|
1497
|
+
const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
|
|
1498
|
+
this.worker = new Worker(workerUrl, { type: "module" });
|
|
1499
|
+
this.worker.onmessage = (event) => {
|
|
1500
|
+
const { id, type, payload } = event.data;
|
|
1501
|
+
if (type === "worker-ready") {
|
|
1502
|
+
this.workerReadyResolve?.();
|
|
1503
|
+
this.workerReadyResolve = null;
|
|
1504
|
+
this.workerReadyReject = null;
|
|
1505
|
+
logRuntimeDiagnostic("info", {
|
|
1506
|
+
component: "CSharpWorkerClient",
|
|
1507
|
+
runtime: "csharp",
|
|
1508
|
+
phase: "worker-ready",
|
|
1509
|
+
message: "C# worker is ready."
|
|
1510
|
+
}, { enabled: this.debug });
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1513
|
+
if (type === "idle-timeout") {
|
|
1514
|
+
logRuntimeDiagnostic("info", {
|
|
1515
|
+
component: "CSharpWorkerClient",
|
|
1516
|
+
runtime: "csharp",
|
|
1517
|
+
phase: "idle-timeout",
|
|
1518
|
+
message: "C# worker closed after idle timeout."
|
|
1519
|
+
}, { enabled: this.debug });
|
|
1520
|
+
this.terminateAndReset(new Error("C# worker closed after idle timeout"));
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
if (!id) return;
|
|
1524
|
+
const pending = this.pendingMessages.get(id);
|
|
1525
|
+
if (!pending) return;
|
|
1526
|
+
this.pendingMessages.delete(id);
|
|
1527
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
1528
|
+
if (type === "error") {
|
|
1529
|
+
pending.reject(new Error(payload.error));
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
pending.resolve(payload);
|
|
1533
|
+
};
|
|
1534
|
+
this.worker.onerror = (error) => {
|
|
1535
|
+
logRuntimeDiagnostic("error", {
|
|
1536
|
+
component: "CSharpWorkerClient",
|
|
1537
|
+
runtime: "csharp",
|
|
1538
|
+
phase: "worker-error",
|
|
1539
|
+
message: "C# worker emitted an error event.",
|
|
1540
|
+
detail: {
|
|
1541
|
+
message: error.message,
|
|
1542
|
+
filename: error.filename,
|
|
1543
|
+
lineno: error.lineno,
|
|
1544
|
+
colno: error.colno
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
const workerError = new Error(error.message || "C# worker error");
|
|
1548
|
+
this.workerReadyReject?.(workerError);
|
|
1549
|
+
this.workerReadyResolve = null;
|
|
1550
|
+
this.workerReadyReject = null;
|
|
1551
|
+
for (const [, pending] of this.pendingMessages) {
|
|
1552
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
1553
|
+
pending.reject(workerError);
|
|
1554
|
+
}
|
|
1555
|
+
this.pendingMessages.clear();
|
|
1556
|
+
this.terminateAndReset(workerError);
|
|
1557
|
+
};
|
|
1558
|
+
return this.worker;
|
|
1559
|
+
}
|
|
1560
|
+
async waitForWorkerReady() {
|
|
1561
|
+
const readyPromise = this.workerReadyPromise;
|
|
1562
|
+
if (!readyPromise) return;
|
|
1563
|
+
await new Promise((resolve, reject) => {
|
|
1564
|
+
let settled = false;
|
|
1565
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1566
|
+
if (settled) return;
|
|
1567
|
+
settled = true;
|
|
1568
|
+
const timeoutError = new Error(
|
|
1569
|
+
`C# worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS4 / 1e3)}s)`
|
|
1570
|
+
);
|
|
1571
|
+
logRuntimeDiagnostic("warn", {
|
|
1572
|
+
component: "CSharpWorkerClient",
|
|
1573
|
+
runtime: "csharp",
|
|
1574
|
+
phase: "worker-ready-timeout",
|
|
1575
|
+
message: "C# worker did not send worker-ready before the timeout.",
|
|
1576
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS4 }
|
|
1577
|
+
}, { enabled: this.debug });
|
|
1578
|
+
this.terminateAndReset(timeoutError);
|
|
1579
|
+
reject(timeoutError);
|
|
1580
|
+
}, WORKER_READY_TIMEOUT_MS4);
|
|
1581
|
+
readyPromise.then(() => {
|
|
1582
|
+
if (settled) return;
|
|
1583
|
+
settled = true;
|
|
1584
|
+
globalThis.clearTimeout(timeoutId);
|
|
1585
|
+
resolve();
|
|
1586
|
+
}).catch((error) => {
|
|
1587
|
+
if (settled) return;
|
|
1588
|
+
settled = true;
|
|
1589
|
+
globalThis.clearTimeout(timeoutId);
|
|
1590
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
1591
|
+
});
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS4) {
|
|
1595
|
+
const worker = this.getWorker();
|
|
1596
|
+
await this.waitForWorkerReady();
|
|
1597
|
+
const id = String(++this.messageId);
|
|
1598
|
+
return new Promise((resolve, reject) => {
|
|
1599
|
+
this.pendingMessages.set(id, {
|
|
1600
|
+
resolve,
|
|
1601
|
+
reject
|
|
1602
|
+
});
|
|
1603
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1604
|
+
const pending2 = this.pendingMessages.get(id);
|
|
1605
|
+
if (!pending2) return;
|
|
1606
|
+
this.pendingMessages.delete(id);
|
|
1607
|
+
logRuntimeDiagnostic("warn", {
|
|
1608
|
+
component: "CSharpWorkerClient",
|
|
1609
|
+
runtime: "csharp",
|
|
1610
|
+
phase: "worker-request-timeout",
|
|
1611
|
+
message: "C# worker request timed out.",
|
|
1612
|
+
detail: { id, type, timeoutMs }
|
|
1613
|
+
}, { enabled: this.debug });
|
|
1614
|
+
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
1615
|
+
}, timeoutMs);
|
|
1616
|
+
const pending = this.pendingMessages.get(id);
|
|
1617
|
+
if (pending) pending.timeoutId = timeoutId;
|
|
1618
|
+
worker.postMessage({ id, type, payload });
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
async executeWithTimeout(executor, timeoutMs) {
|
|
1622
|
+
return new Promise((resolve, reject) => {
|
|
1623
|
+
let settled = false;
|
|
1624
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1625
|
+
if (settled) return;
|
|
1626
|
+
settled = true;
|
|
1627
|
+
logRuntimeDiagnostic("warn", {
|
|
1628
|
+
component: "CSharpWorkerClient",
|
|
1629
|
+
runtime: "csharp",
|
|
1630
|
+
phase: "execution-timeout",
|
|
1631
|
+
message: "C# execution timed out; terminating worker.",
|
|
1632
|
+
detail: { timeoutMs }
|
|
1633
|
+
}, { enabled: this.debug });
|
|
1634
|
+
this.terminateAndReset();
|
|
1635
|
+
reject(new Error(`C# execution timed out after ${Math.round(timeoutMs / 1e3)} seconds.`));
|
|
1636
|
+
}, timeoutMs);
|
|
1637
|
+
executor().then((result) => {
|
|
1638
|
+
if (settled) return;
|
|
1639
|
+
settled = true;
|
|
1640
|
+
globalThis.clearTimeout(timeoutId);
|
|
1641
|
+
resolve(result);
|
|
1642
|
+
}).catch((error) => {
|
|
1643
|
+
if (settled) return;
|
|
1644
|
+
settled = true;
|
|
1645
|
+
globalThis.clearTimeout(timeoutId);
|
|
1646
|
+
reject(error);
|
|
1647
|
+
});
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
terminateAndReset(reason = new Error("Worker was terminated")) {
|
|
1651
|
+
this.workerReadyReject?.(reason);
|
|
1652
|
+
if (this.worker) {
|
|
1653
|
+
this.worker.terminate();
|
|
1654
|
+
this.worker = null;
|
|
1655
|
+
}
|
|
1656
|
+
this.initPromise = null;
|
|
1657
|
+
this.warmupPromise = null;
|
|
1658
|
+
this.isInitializing = false;
|
|
1659
|
+
this.workerReadyPromise = null;
|
|
1660
|
+
this.workerReadyResolve = null;
|
|
1661
|
+
this.workerReadyReject = null;
|
|
1662
|
+
for (const [, pending] of this.pendingMessages) {
|
|
1663
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
1664
|
+
pending.reject(reason);
|
|
1665
|
+
}
|
|
1666
|
+
this.pendingMessages.clear();
|
|
1667
|
+
}
|
|
1668
|
+
shouldRetryInit(error) {
|
|
1669
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1670
|
+
return message.includes("timed out") || message.includes("Worker request timed out") || message.includes("worker error") || message.includes("Failed to fetch") || message.includes("was terminated") || message.includes("closed after idle timeout");
|
|
1671
|
+
}
|
|
1672
|
+
sendInitMessage() {
|
|
1673
|
+
return this.sendMessage(
|
|
1674
|
+
"init",
|
|
1675
|
+
{ assetBaseUrl: this.options.assetBaseUrl, ...this.workerOptionsPayload() },
|
|
1676
|
+
this.initTimeoutMs
|
|
1677
|
+
);
|
|
1678
|
+
}
|
|
1679
|
+
workerOptionsPayload() {
|
|
1680
|
+
return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
|
|
1681
|
+
}
|
|
1682
|
+
async init() {
|
|
1683
|
+
if (this.initPromise) return this.initPromise;
|
|
1684
|
+
if (this.isInitializing) {
|
|
1685
|
+
await new Promise((resolve) => globalThis.setTimeout(resolve, 100));
|
|
1686
|
+
return this.init();
|
|
1687
|
+
}
|
|
1688
|
+
this.isInitializing = true;
|
|
1689
|
+
this.initPromise = (async () => {
|
|
1690
|
+
try {
|
|
1691
|
+
return await this.sendInitMessage();
|
|
1692
|
+
} catch (error) {
|
|
1693
|
+
if (!this.shouldRetryInit(error)) throw error;
|
|
1694
|
+
this.terminateAndReset(error instanceof Error ? error : new Error(String(error)));
|
|
1695
|
+
return this.sendInitMessage();
|
|
1696
|
+
}
|
|
1697
|
+
})();
|
|
1698
|
+
try {
|
|
1699
|
+
return await this.initPromise;
|
|
1700
|
+
} catch (error) {
|
|
1701
|
+
this.initPromise = null;
|
|
1702
|
+
throw error;
|
|
1703
|
+
} finally {
|
|
1704
|
+
this.isInitializing = false;
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
async warmup() {
|
|
1708
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
1709
|
+
this.warmupPromise = (async () => {
|
|
1710
|
+
try {
|
|
1711
|
+
await this.init();
|
|
1712
|
+
return await this.sendMessage(
|
|
1713
|
+
"warmup",
|
|
1714
|
+
{ assetBaseUrl: this.options.assetBaseUrl, ...this.workerOptionsPayload() },
|
|
1715
|
+
this.initTimeoutMs
|
|
1716
|
+
);
|
|
1717
|
+
} catch (error) {
|
|
1718
|
+
this.warmupPromise = null;
|
|
1719
|
+
throw error;
|
|
1720
|
+
}
|
|
1721
|
+
})();
|
|
1722
|
+
return this.warmupPromise;
|
|
1723
|
+
}
|
|
1724
|
+
async executeCode(code, functionName, inputs, executionStyle) {
|
|
1725
|
+
await this.init();
|
|
1726
|
+
const result = await this.executeWithTimeout(
|
|
1727
|
+
() => this.sendMessage(
|
|
1728
|
+
"execute-code",
|
|
1729
|
+
{
|
|
1730
|
+
code,
|
|
1731
|
+
functionName,
|
|
1732
|
+
inputs,
|
|
1733
|
+
executionStyle,
|
|
1734
|
+
assetBaseUrl: this.options.assetBaseUrl,
|
|
1735
|
+
timeoutMs: Math.max(100, this.executionTimeoutMs - 1e3),
|
|
1736
|
+
...this.workerOptionsPayload()
|
|
1737
|
+
},
|
|
1738
|
+
this.executionTimeoutMs + 5e3
|
|
1739
|
+
),
|
|
1740
|
+
this.executionTimeoutMs
|
|
1741
|
+
);
|
|
1742
|
+
if (!result.success) {
|
|
1743
|
+
const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
|
|
1744
|
+
return {
|
|
1745
|
+
success: false,
|
|
1746
|
+
output: null,
|
|
1747
|
+
error: result.error ?? "C# execution failed",
|
|
1748
|
+
...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
|
|
1749
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1750
|
+
timings: result.timings
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
return {
|
|
1754
|
+
success: true,
|
|
1755
|
+
output: result.output,
|
|
1756
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1757
|
+
timings: result.timings
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle) {
|
|
1761
|
+
await this.init();
|
|
1762
|
+
let result;
|
|
1763
|
+
try {
|
|
1764
|
+
result = await this.executeWithTimeout(
|
|
1765
|
+
() => this.sendMessage(
|
|
1766
|
+
"execute-code-interview",
|
|
1767
|
+
{
|
|
1768
|
+
code,
|
|
1769
|
+
functionName,
|
|
1770
|
+
inputs,
|
|
1771
|
+
executionStyle,
|
|
1772
|
+
assetBaseUrl: this.options.assetBaseUrl,
|
|
1773
|
+
timeoutMs: Math.max(100, this.interviewTimeoutMs - 1e3),
|
|
1774
|
+
...this.workerOptionsPayload()
|
|
1775
|
+
},
|
|
1776
|
+
this.interviewTimeoutMs + 5e3
|
|
1777
|
+
),
|
|
1778
|
+
this.interviewTimeoutMs
|
|
1779
|
+
);
|
|
1780
|
+
} catch {
|
|
1781
|
+
return {
|
|
1782
|
+
success: false,
|
|
1783
|
+
output: null,
|
|
1784
|
+
error: "Time Limit Exceeded",
|
|
1785
|
+
timeoutReason: "client-timeout",
|
|
1786
|
+
diagnosticStage: "interview",
|
|
1787
|
+
consoleOutput: [],
|
|
1788
|
+
timings: { totalMs: this.interviewTimeoutMs }
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
if (!result.success) {
|
|
1792
|
+
const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
|
|
1793
|
+
if (this.isInterviewTimeoutLike(result)) {
|
|
1794
|
+
return {
|
|
1795
|
+
success: false,
|
|
1796
|
+
output: null,
|
|
1797
|
+
error: "Time Limit Exceeded",
|
|
1798
|
+
timeoutReason: result.timeoutReason ?? "client-timeout",
|
|
1799
|
+
diagnosticStage: "interview",
|
|
1800
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1801
|
+
timings: result.timings
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
return {
|
|
1805
|
+
success: false,
|
|
1806
|
+
output: null,
|
|
1807
|
+
error: result.error ?? "C# execution failed",
|
|
1808
|
+
...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
|
|
1809
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1810
|
+
timings: result.timings
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
return {
|
|
1814
|
+
success: true,
|
|
1815
|
+
output: result.output,
|
|
1816
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1817
|
+
timings: result.timings
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle) {
|
|
1821
|
+
await this.init();
|
|
1822
|
+
let result;
|
|
1823
|
+
try {
|
|
1824
|
+
result = await this.executeWithTimeout(
|
|
1825
|
+
() => this.sendMessage(
|
|
1826
|
+
"execute-with-tracing",
|
|
1827
|
+
{
|
|
1828
|
+
code,
|
|
1829
|
+
functionName,
|
|
1830
|
+
inputs,
|
|
1831
|
+
executionStyle,
|
|
1832
|
+
assetBaseUrl: this.options.assetBaseUrl,
|
|
1833
|
+
timeoutMs: Math.max(100, this.tracingTimeoutMs - 1e3),
|
|
1834
|
+
maxTraceSteps: options?.maxTraceSteps,
|
|
1835
|
+
maxLineEvents: options?.maxLineEvents,
|
|
1836
|
+
maxSingleLineHits: options?.maxSingleLineHits,
|
|
1837
|
+
maxStoredEvents: options?.maxStoredEvents,
|
|
1838
|
+
minimalTrace: options?.minimalTrace,
|
|
1839
|
+
...this.workerOptionsPayload()
|
|
1840
|
+
},
|
|
1841
|
+
this.tracingTimeoutMs + 5e3
|
|
1842
|
+
),
|
|
1843
|
+
this.tracingTimeoutMs
|
|
1844
|
+
);
|
|
1845
|
+
} catch (error) {
|
|
1846
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1847
|
+
const trace2 = this.createTrace([
|
|
1848
|
+
{
|
|
1849
|
+
kind: "timeout",
|
|
1850
|
+
runId: "csharp:run",
|
|
1851
|
+
file: CSHARP_DEFAULT_FILE,
|
|
1852
|
+
message
|
|
1853
|
+
}
|
|
1854
|
+
]);
|
|
1855
|
+
return {
|
|
1856
|
+
success: false,
|
|
1857
|
+
output: null,
|
|
1858
|
+
error: message,
|
|
1859
|
+
trace: trace2,
|
|
1860
|
+
executionTimeMs: this.tracingTimeoutMs,
|
|
1861
|
+
consoleOutput: [],
|
|
1862
|
+
traceLimitExceeded: true,
|
|
1863
|
+
timeoutReason: "client-timeout",
|
|
1864
|
+
lineEventCount: trace2.lineEventCount,
|
|
1865
|
+
traceStepCount: trace2.traceStepCount,
|
|
1866
|
+
timings: { totalMs: this.tracingTimeoutMs }
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
const consoleOutput = result.consoleOutput ?? [];
|
|
1870
|
+
const events = [
|
|
1871
|
+
...result.events ?? [],
|
|
1872
|
+
...consoleOutput.map((text) => ({
|
|
1873
|
+
kind: "stdout",
|
|
1874
|
+
runId: "csharp:run",
|
|
1875
|
+
file: CSHARP_DEFAULT_FILE,
|
|
1876
|
+
text
|
|
1877
|
+
}))
|
|
1878
|
+
];
|
|
1879
|
+
const trace = this.createTrace(events);
|
|
1880
|
+
if (!result.success) {
|
|
1881
|
+
const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
|
|
1882
|
+
return {
|
|
1883
|
+
success: false,
|
|
1884
|
+
output: null,
|
|
1885
|
+
error: result.error ?? "C# execution failed",
|
|
1886
|
+
...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
|
|
1887
|
+
trace,
|
|
1888
|
+
executionTimeMs: result.executionTimeMs ?? 0,
|
|
1889
|
+
consoleOutput,
|
|
1890
|
+
...result.traceLimitExceeded !== void 0 ? { traceLimitExceeded: result.traceLimitExceeded } : {},
|
|
1891
|
+
...result.timeoutReason ? { timeoutReason: result.timeoutReason } : {},
|
|
1892
|
+
lineEventCount: trace.lineEventCount,
|
|
1893
|
+
traceStepCount: trace.traceStepCount,
|
|
1894
|
+
timings: result.timings
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
return {
|
|
1898
|
+
success: true,
|
|
1899
|
+
output: result.output,
|
|
1900
|
+
trace,
|
|
1901
|
+
executionTimeMs: result.executionTimeMs ?? 0,
|
|
1902
|
+
consoleOutput,
|
|
1903
|
+
...result.traceLimitExceeded !== void 0 ? { traceLimitExceeded: result.traceLimitExceeded } : {},
|
|
1904
|
+
...result.timeoutReason ? { timeoutReason: result.timeoutReason } : {},
|
|
1905
|
+
lineEventCount: trace.lineEventCount,
|
|
1906
|
+
traceStepCount: trace.traceStepCount,
|
|
1907
|
+
timings: result.timings
|
|
1908
|
+
};
|
|
1909
|
+
}
|
|
1910
|
+
createTrace(events) {
|
|
1911
|
+
return {
|
|
1912
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1913
|
+
language: "csharp",
|
|
1914
|
+
runId: "csharp:run",
|
|
1915
|
+
events: events.map(normalizeCSharpTraceEventFile),
|
|
1916
|
+
lineEventCount: events.filter((event) => event.kind === "line").length,
|
|
1917
|
+
traceStepCount: events.length
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
isInterviewTimeoutLike(result) {
|
|
1921
|
+
if (result.timeoutReason) return true;
|
|
1922
|
+
const normalized = String(result.error ?? "").toLowerCase();
|
|
1923
|
+
return normalized.includes("timed out") || normalized.includes("trace-limit") || normalized.includes("line-limit") || normalized.includes("single-line-limit") || normalized.includes("recursion-limit") || normalized.includes("memory-limit");
|
|
1924
|
+
}
|
|
1925
|
+
terminate() {
|
|
1926
|
+
this.terminateAndReset();
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
// packages/harness-browser/src/cpp-worker-client.ts
|
|
1931
|
+
var CppClientTimeoutError = class extends Error {
|
|
1932
|
+
constructor(message, stage, timeoutMs) {
|
|
1933
|
+
super(message);
|
|
1934
|
+
this.stage = stage;
|
|
1935
|
+
this.timeoutMs = timeoutMs;
|
|
1936
|
+
this.name = "CppClientTimeoutError";
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
var INIT_TIMEOUT_MS5 = 12e4;
|
|
1940
|
+
var EXECUTION_TIMEOUT_MS5 = 6e4;
|
|
1941
|
+
var TRACING_TIMEOUT_MS5 = 6e4;
|
|
1942
|
+
var INTERVIEW_MODE_TIMEOUT_MS4 = 3e4;
|
|
1943
|
+
var MESSAGE_TIMEOUT_MS5 = 3e4;
|
|
1944
|
+
var WORKER_READY_TIMEOUT_MS5 = 1e4;
|
|
1945
|
+
var CPP_DEFAULT_FILE = "solution.cpp";
|
|
1946
|
+
var CppWorkerClient = class {
|
|
1947
|
+
constructor(options) {
|
|
1948
|
+
this.options = options;
|
|
1949
|
+
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
1950
|
+
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS5;
|
|
1951
|
+
this.executionTimeoutMs = options.executionTimeoutMs ?? EXECUTION_TIMEOUT_MS5;
|
|
1952
|
+
this.tracingTimeoutMs = options.tracingTimeoutMs ?? TRACING_TIMEOUT_MS5;
|
|
1953
|
+
this.interviewTimeoutMs = options.interviewTimeoutMs ?? INTERVIEW_MODE_TIMEOUT_MS4;
|
|
1954
|
+
this.compilerFrameUrl = options.compilerFrameUrl;
|
|
1955
|
+
}
|
|
1956
|
+
worker = null;
|
|
1957
|
+
pendingMessages = /* @__PURE__ */ new Map();
|
|
1958
|
+
messageId = 0;
|
|
1959
|
+
initPromise = null;
|
|
1960
|
+
warmupPromise = null;
|
|
1961
|
+
workerReadyPromise = null;
|
|
1962
|
+
workerReadyResolve = null;
|
|
1963
|
+
workerReadyReject = null;
|
|
1964
|
+
debug;
|
|
1965
|
+
initTimeoutMs;
|
|
1966
|
+
executionTimeoutMs;
|
|
1967
|
+
tracingTimeoutMs;
|
|
1968
|
+
interviewTimeoutMs;
|
|
1969
|
+
compilerFrameUrl;
|
|
1970
|
+
activeCompilerFrames = /* @__PURE__ */ new Set();
|
|
1971
|
+
compilerFrame = null;
|
|
1972
|
+
compilerFrameReadyPromise = null;
|
|
1973
|
+
compilerFrameReadyResolve = null;
|
|
1974
|
+
compilerFrameReadyReject = null;
|
|
1975
|
+
compilerFrameTargetOrigin = "";
|
|
1976
|
+
compilerFrameRequestId = 0;
|
|
1977
|
+
compilerFrameMessageHandler = null;
|
|
1978
|
+
pendingCompilerFrameRequests = /* @__PURE__ */ new Map();
|
|
1979
|
+
isSupported() {
|
|
1980
|
+
return typeof Worker !== "undefined";
|
|
1981
|
+
}
|
|
1982
|
+
getWorker() {
|
|
1983
|
+
if (this.worker) return this.worker;
|
|
1984
|
+
if (!this.isSupported()) {
|
|
1985
|
+
throw new Error("Web Workers are not supported in this environment");
|
|
1986
|
+
}
|
|
1987
|
+
this.workerReadyPromise = new Promise((resolve, reject) => {
|
|
1988
|
+
this.workerReadyResolve = resolve;
|
|
1989
|
+
this.workerReadyReject = (error) => reject(error);
|
|
1990
|
+
});
|
|
1991
|
+
const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
|
|
1992
|
+
this.worker = new Worker(workerUrl, { type: "module" });
|
|
1993
|
+
this.worker.onmessage = (event) => {
|
|
1994
|
+
const { id, type, payload } = event.data;
|
|
1995
|
+
if (type === "worker-ready") {
|
|
1996
|
+
this.workerReadyResolve?.();
|
|
1997
|
+
this.workerReadyResolve = null;
|
|
1998
|
+
this.workerReadyReject = null;
|
|
1999
|
+
logRuntimeDiagnostic("info", {
|
|
2000
|
+
component: "CppWorkerClient",
|
|
2001
|
+
runtime: "cpp",
|
|
2002
|
+
phase: "worker-ready",
|
|
2003
|
+
message: "C++ worker is ready."
|
|
2004
|
+
}, { enabled: this.debug });
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
if (type === "idle-timeout") {
|
|
2008
|
+
logRuntimeDiagnostic("info", {
|
|
2009
|
+
component: "CppWorkerClient",
|
|
2010
|
+
runtime: "cpp",
|
|
2011
|
+
phase: "idle-timeout",
|
|
2012
|
+
message: "C++ worker closed after idle timeout."
|
|
2013
|
+
}, { enabled: this.debug });
|
|
2014
|
+
this.terminateAndReset(new Error("C++ worker closed after idle timeout"));
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
if (type === "compile-request") {
|
|
2018
|
+
this.handleCompileRequest(event.data).catch((error) => {
|
|
2019
|
+
if (!event.data.requestId) return;
|
|
2020
|
+
this.worker?.postMessage({
|
|
2021
|
+
type: "compile-response",
|
|
2022
|
+
requestId: event.data.requestId,
|
|
2023
|
+
payload: { success: false, error: error instanceof Error ? error.message : String(error) }
|
|
2024
|
+
});
|
|
2025
|
+
});
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2028
|
+
if (!id) return;
|
|
2029
|
+
const pending = this.pendingMessages.get(id);
|
|
2030
|
+
if (!pending) return;
|
|
2031
|
+
this.pendingMessages.delete(id);
|
|
2032
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
2033
|
+
if (type === "error") {
|
|
2034
|
+
pending.reject(new Error(payload.error));
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
pending.resolve(payload);
|
|
2038
|
+
};
|
|
2039
|
+
this.worker.onerror = (error) => {
|
|
2040
|
+
logRuntimeDiagnostic("error", {
|
|
2041
|
+
component: "CppWorkerClient",
|
|
2042
|
+
runtime: "cpp",
|
|
2043
|
+
phase: "worker-error",
|
|
2044
|
+
message: "C++ worker emitted an error event.",
|
|
2045
|
+
detail: {
|
|
2046
|
+
message: error.message,
|
|
2047
|
+
filename: error.filename,
|
|
2048
|
+
lineno: error.lineno,
|
|
2049
|
+
colno: error.colno
|
|
2050
|
+
}
|
|
2051
|
+
});
|
|
2052
|
+
const workerError = new Error(error.message || "C++ worker error");
|
|
2053
|
+
this.workerReadyReject?.(workerError);
|
|
2054
|
+
this.workerReadyResolve = null;
|
|
2055
|
+
this.workerReadyReject = null;
|
|
2056
|
+
this.terminateAndReset(workerError);
|
|
2057
|
+
};
|
|
2058
|
+
return this.worker;
|
|
2059
|
+
}
|
|
2060
|
+
async waitForWorkerReady() {
|
|
2061
|
+
const readyPromise = this.workerReadyPromise;
|
|
2062
|
+
if (!readyPromise) return;
|
|
2063
|
+
await new Promise((resolve, reject) => {
|
|
2064
|
+
let settled = false;
|
|
2065
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2066
|
+
if (settled) return;
|
|
2067
|
+
settled = true;
|
|
2068
|
+
const timeoutError = new Error(
|
|
2069
|
+
`C++ worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS5 / 1e3)}s)`
|
|
2070
|
+
);
|
|
2071
|
+
logRuntimeDiagnostic("warn", {
|
|
2072
|
+
component: "CppWorkerClient",
|
|
2073
|
+
runtime: "cpp",
|
|
2074
|
+
phase: "worker-ready-timeout",
|
|
2075
|
+
message: "C++ worker did not send worker-ready before the timeout.",
|
|
2076
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS5 }
|
|
2077
|
+
}, { enabled: this.debug });
|
|
2078
|
+
this.terminateAndReset(timeoutError);
|
|
2079
|
+
reject(timeoutError);
|
|
2080
|
+
}, WORKER_READY_TIMEOUT_MS5);
|
|
2081
|
+
readyPromise.then(() => {
|
|
2082
|
+
if (settled) return;
|
|
2083
|
+
settled = true;
|
|
2084
|
+
globalThis.clearTimeout(timeoutId);
|
|
2085
|
+
resolve();
|
|
2086
|
+
}).catch((error) => {
|
|
2087
|
+
if (settled) return;
|
|
2088
|
+
settled = true;
|
|
2089
|
+
globalThis.clearTimeout(timeoutId);
|
|
2090
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2091
|
+
});
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS5) {
|
|
2095
|
+
const worker = this.getWorker();
|
|
2096
|
+
await this.waitForWorkerReady();
|
|
2097
|
+
const id = String(++this.messageId);
|
|
2098
|
+
return new Promise((resolve, reject) => {
|
|
2099
|
+
this.pendingMessages.set(id, {
|
|
2100
|
+
resolve,
|
|
2101
|
+
reject
|
|
2102
|
+
});
|
|
2103
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2104
|
+
const pending2 = this.pendingMessages.get(id);
|
|
2105
|
+
if (!pending2) return;
|
|
2106
|
+
this.pendingMessages.delete(id);
|
|
2107
|
+
logRuntimeDiagnostic("warn", {
|
|
2108
|
+
component: "CppWorkerClient",
|
|
2109
|
+
runtime: "cpp",
|
|
2110
|
+
phase: "worker-request-timeout",
|
|
2111
|
+
message: "C++ worker request timed out.",
|
|
2112
|
+
detail: { id, type, timeoutMs }
|
|
2113
|
+
}, { enabled: this.debug });
|
|
2114
|
+
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
2115
|
+
}, timeoutMs);
|
|
2116
|
+
const pending = this.pendingMessages.get(id);
|
|
2117
|
+
if (pending) pending.timeoutId = timeoutId;
|
|
2118
|
+
worker.postMessage({ id, type, payload });
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
async executeWithTimeout(executor, timeoutMs, stage) {
|
|
2122
|
+
return new Promise((resolve, reject) => {
|
|
2123
|
+
let settled = false;
|
|
2124
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2125
|
+
if (settled) return;
|
|
2126
|
+
settled = true;
|
|
2127
|
+
const timeoutLabel = stage === "trace" ? "tracing" : stage === "interview" ? "interview execution" : "compile/run";
|
|
2128
|
+
const timeoutError = new CppClientTimeoutError(
|
|
2129
|
+
`C++ ${timeoutLabel} timed out after ${Math.round(timeoutMs / 1e3)} seconds.`,
|
|
2130
|
+
stage,
|
|
2131
|
+
timeoutMs
|
|
2132
|
+
);
|
|
2133
|
+
logRuntimeDiagnostic("warn", {
|
|
2134
|
+
component: "CppWorkerClient",
|
|
2135
|
+
runtime: "cpp",
|
|
2136
|
+
phase: "execution-timeout",
|
|
2137
|
+
message: "C++ execution timed out; terminating worker.",
|
|
2138
|
+
detail: { timeoutMs, stage }
|
|
2139
|
+
}, { enabled: this.debug });
|
|
2140
|
+
this.terminateAndReset(timeoutError);
|
|
2141
|
+
reject(timeoutError);
|
|
2142
|
+
}, timeoutMs);
|
|
2143
|
+
executor().then((result) => {
|
|
2144
|
+
if (settled) return;
|
|
2145
|
+
settled = true;
|
|
2146
|
+
globalThis.clearTimeout(timeoutId);
|
|
2147
|
+
resolve(result);
|
|
2148
|
+
}).catch((error) => {
|
|
2149
|
+
if (settled) return;
|
|
2150
|
+
settled = true;
|
|
2151
|
+
globalThis.clearTimeout(timeoutId);
|
|
2152
|
+
reject(error);
|
|
2153
|
+
});
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
isClientTimeout(error) {
|
|
2157
|
+
return error instanceof CppClientTimeoutError || error instanceof Error && error.message.includes("C++") && error.message.includes("timed out");
|
|
2158
|
+
}
|
|
2159
|
+
timeoutCodeResult(error) {
|
|
2160
|
+
const timeoutError = error instanceof CppClientTimeoutError ? error : null;
|
|
2161
|
+
return {
|
|
2162
|
+
success: false,
|
|
2163
|
+
output: null,
|
|
2164
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2165
|
+
consoleOutput: [],
|
|
2166
|
+
timeoutReason: "client-timeout",
|
|
2167
|
+
diagnosticStage: timeoutError?.stage === "interview" ? "interview" : "runtime",
|
|
2168
|
+
timings: { totalMs: timeoutError?.timeoutMs ?? this.executionTimeoutMs }
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
timeoutTraceResult(error) {
|
|
2172
|
+
const timeoutError = error instanceof CppClientTimeoutError ? error : null;
|
|
2173
|
+
const trace = createEmptyRuntimeTrace("cpp", { runId: "cpp:run", file: CPP_DEFAULT_FILE });
|
|
2174
|
+
trace.events = [
|
|
2175
|
+
{
|
|
2176
|
+
kind: "timeout",
|
|
2177
|
+
runId: "cpp:run",
|
|
2178
|
+
file: CPP_DEFAULT_FILE,
|
|
2179
|
+
message: error instanceof Error ? error.message : String(error)
|
|
2180
|
+
}
|
|
2181
|
+
];
|
|
2182
|
+
trace.traceStepCount = 1;
|
|
2183
|
+
return {
|
|
2184
|
+
success: false,
|
|
2185
|
+
output: null,
|
|
2186
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2187
|
+
trace,
|
|
2188
|
+
executionTimeMs: timeoutError?.timeoutMs ?? this.tracingTimeoutMs,
|
|
2189
|
+
consoleOutput: [],
|
|
2190
|
+
traceLimitExceeded: true,
|
|
2191
|
+
timeoutReason: "client-timeout",
|
|
2192
|
+
lineEventCount: 0,
|
|
2193
|
+
traceStepCount: 1,
|
|
2194
|
+
timings: { totalMs: timeoutError?.timeoutMs ?? this.tracingTimeoutMs }
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
terminateAndReset(reason = new Error("Worker was terminated")) {
|
|
2198
|
+
this.workerReadyReject?.(reason);
|
|
2199
|
+
if (this.worker) {
|
|
2200
|
+
this.worker.terminate();
|
|
2201
|
+
this.worker = null;
|
|
2202
|
+
}
|
|
2203
|
+
this.initPromise = null;
|
|
2204
|
+
this.warmupPromise = null;
|
|
2205
|
+
this.workerReadyPromise = null;
|
|
2206
|
+
this.workerReadyResolve = null;
|
|
2207
|
+
this.workerReadyReject = null;
|
|
2208
|
+
for (const [, pending] of this.pendingMessages) {
|
|
2209
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
2210
|
+
pending.reject(reason);
|
|
2211
|
+
}
|
|
2212
|
+
this.pendingMessages.clear();
|
|
2213
|
+
this.clearCompilerFrames();
|
|
2214
|
+
}
|
|
2215
|
+
shouldRetryInit(error) {
|
|
2216
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2217
|
+
return message.includes("timed out") || message.includes("Worker request timed out") || message.includes("worker error") || message.includes("Failed to fetch") || message.includes("was terminated") || message.includes("closed after idle timeout");
|
|
2218
|
+
}
|
|
2219
|
+
sendInitMessage() {
|
|
2220
|
+
return this.sendMessage(
|
|
2221
|
+
"init",
|
|
2222
|
+
{
|
|
2223
|
+
assets: {
|
|
2224
|
+
clangWasmUrl: this.options.clangWasmUrl,
|
|
2225
|
+
lldWasmUrl: this.options.lldWasmUrl,
|
|
2226
|
+
sysrootUrl: this.options.sysrootUrl,
|
|
2227
|
+
runtimeHeaderUrl: this.options.runtimeHeaderUrl,
|
|
2228
|
+
compilerBundleUrl: this.options.compilerBundleUrl,
|
|
2229
|
+
compilerFrameEnabled: Boolean(this.compilerFrameUrl && typeof document !== "undefined"),
|
|
2230
|
+
compilerFrameUrl: this.compilerFrameUrl,
|
|
2231
|
+
compilerWorkerUrl: this.options.compilerWorkerUrl
|
|
2232
|
+
},
|
|
2233
|
+
...this.workerOptionsPayload()
|
|
2234
|
+
},
|
|
2235
|
+
this.initTimeoutMs
|
|
2236
|
+
);
|
|
2237
|
+
}
|
|
2238
|
+
async init() {
|
|
2239
|
+
if (this.initPromise) return this.initPromise;
|
|
2240
|
+
this.initPromise = (async () => {
|
|
2241
|
+
try {
|
|
2242
|
+
return await this.sendInitMessage();
|
|
2243
|
+
} catch (error) {
|
|
2244
|
+
if (!this.shouldRetryInit(error)) throw error;
|
|
2245
|
+
this.terminateAndReset(error instanceof Error ? error : new Error(String(error)));
|
|
2246
|
+
return this.sendInitMessage();
|
|
2247
|
+
}
|
|
2248
|
+
})();
|
|
2249
|
+
try {
|
|
2250
|
+
return await this.initPromise;
|
|
2251
|
+
} catch (error) {
|
|
2252
|
+
this.initPromise = null;
|
|
2253
|
+
throw error;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
workerOptionsPayload() {
|
|
2257
|
+
return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
|
|
2258
|
+
}
|
|
2259
|
+
async warmup() {
|
|
2260
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
2261
|
+
this.warmupPromise = (async () => {
|
|
2262
|
+
try {
|
|
2263
|
+
await this.init();
|
|
2264
|
+
return await this.sendMessage("warmup", this.workerOptionsPayload(), this.initTimeoutMs);
|
|
2265
|
+
} catch (error) {
|
|
2266
|
+
this.warmupPromise = null;
|
|
2267
|
+
throw error;
|
|
2268
|
+
}
|
|
2269
|
+
})();
|
|
2270
|
+
return this.warmupPromise;
|
|
2271
|
+
}
|
|
2272
|
+
clearCompilerFrames(reason = new Error("C++ compiler frame was closed")) {
|
|
2273
|
+
this.compilerFrameReadyReject?.(reason);
|
|
2274
|
+
this.compilerFrameReadyPromise = null;
|
|
2275
|
+
this.compilerFrameReadyResolve = null;
|
|
2276
|
+
this.compilerFrameReadyReject = null;
|
|
2277
|
+
if (this.compilerFrameMessageHandler) {
|
|
2278
|
+
globalThis.removeEventListener("message", this.compilerFrameMessageHandler);
|
|
2279
|
+
this.compilerFrameMessageHandler = null;
|
|
2280
|
+
}
|
|
2281
|
+
for (const [, pending] of this.pendingCompilerFrameRequests) {
|
|
2282
|
+
globalThis.clearTimeout(pending.timeoutId);
|
|
2283
|
+
pending.resolve({ success: false, error: reason.message });
|
|
2284
|
+
}
|
|
2285
|
+
this.pendingCompilerFrameRequests.clear();
|
|
2286
|
+
this.compilerFrame = null;
|
|
2287
|
+
this.compilerFrameTargetOrigin = "";
|
|
2288
|
+
for (const frame of this.activeCompilerFrames) {
|
|
2289
|
+
frame.remove();
|
|
2290
|
+
}
|
|
2291
|
+
this.activeCompilerFrames.clear();
|
|
2292
|
+
}
|
|
2293
|
+
async handleCompileRequest(message) {
|
|
2294
|
+
if (!message.requestId) return;
|
|
2295
|
+
const worker = this.worker;
|
|
2296
|
+
if (!worker) return;
|
|
2297
|
+
const result = await this.compileInFrame(message.payload);
|
|
2298
|
+
const transfer = result?.programBuffer instanceof ArrayBuffer ? [result.programBuffer] : [];
|
|
2299
|
+
worker.postMessage(
|
|
2300
|
+
{
|
|
2301
|
+
type: "compile-response",
|
|
2302
|
+
requestId: message.requestId,
|
|
2303
|
+
payload: result
|
|
2304
|
+
},
|
|
2305
|
+
transfer
|
|
2306
|
+
);
|
|
2307
|
+
}
|
|
2308
|
+
ensureCompilerFrame() {
|
|
2309
|
+
if (!this.compilerFrameUrl || typeof document === "undefined") {
|
|
2310
|
+
return Promise.reject(new Error("C++ compiler frame is not available."));
|
|
2311
|
+
}
|
|
2312
|
+
if (this.compilerFrame && this.compilerFrameReadyPromise) return this.compilerFrameReadyPromise;
|
|
2313
|
+
const frameUrl = new URL(this.compilerFrameUrl, globalThis.location?.href);
|
|
2314
|
+
this.compilerFrameTargetOrigin = frameUrl.origin;
|
|
2315
|
+
const iframe = document.createElement("iframe");
|
|
2316
|
+
iframe.src = frameUrl.href;
|
|
2317
|
+
iframe.style.display = "none";
|
|
2318
|
+
iframe.setAttribute("aria-hidden", "true");
|
|
2319
|
+
this.compilerFrame = iframe;
|
|
2320
|
+
this.activeCompilerFrames.add(iframe);
|
|
2321
|
+
this.compilerFrameReadyPromise = new Promise((resolve, reject) => {
|
|
2322
|
+
let settled = false;
|
|
2323
|
+
let timeoutId;
|
|
2324
|
+
const finishReady = () => {
|
|
2325
|
+
if (settled) return;
|
|
2326
|
+
settled = true;
|
|
2327
|
+
globalThis.clearTimeout(timeoutId);
|
|
2328
|
+
this.compilerFrameReadyResolve = null;
|
|
2329
|
+
this.compilerFrameReadyReject = null;
|
|
2330
|
+
resolve();
|
|
2331
|
+
};
|
|
2332
|
+
const onMessage = (event) => {
|
|
2333
|
+
if (event.source !== iframe.contentWindow) return;
|
|
2334
|
+
if (event.origin !== this.compilerFrameTargetOrigin) return;
|
|
2335
|
+
if (event.data?.type === "frame-ready") {
|
|
2336
|
+
finishReady();
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
const requestId = event.data?.id;
|
|
2340
|
+
if (!requestId) return;
|
|
2341
|
+
const pending = this.pendingCompilerFrameRequests.get(requestId);
|
|
2342
|
+
if (!pending) return;
|
|
2343
|
+
this.pendingCompilerFrameRequests.delete(requestId);
|
|
2344
|
+
globalThis.clearTimeout(pending.timeoutId);
|
|
2345
|
+
const response = event.data;
|
|
2346
|
+
pending.resolve(response.payload ?? { success: false, error: "C++ compiler frame returned an empty response." });
|
|
2347
|
+
};
|
|
2348
|
+
this.compilerFrameMessageHandler = onMessage;
|
|
2349
|
+
timeoutId = globalThis.setTimeout(() => {
|
|
2350
|
+
const error = new Error("C++ compiler frame request timed out.");
|
|
2351
|
+
this.clearCompilerFrames(error);
|
|
2352
|
+
reject(error);
|
|
2353
|
+
}, this.initTimeoutMs);
|
|
2354
|
+
this.compilerFrameReadyResolve = finishReady;
|
|
2355
|
+
this.compilerFrameReadyReject = (error) => {
|
|
2356
|
+
if (settled) return;
|
|
2357
|
+
settled = true;
|
|
2358
|
+
globalThis.clearTimeout(timeoutId);
|
|
2359
|
+
reject(error);
|
|
2360
|
+
};
|
|
2361
|
+
globalThis.addEventListener("message", onMessage);
|
|
2362
|
+
document.body.appendChild(iframe);
|
|
2363
|
+
});
|
|
2364
|
+
return this.compilerFrameReadyPromise;
|
|
2365
|
+
}
|
|
2366
|
+
async compileInFrame(payload) {
|
|
2367
|
+
try {
|
|
2368
|
+
await this.ensureCompilerFrame();
|
|
2369
|
+
} catch (error) {
|
|
2370
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
2371
|
+
}
|
|
2372
|
+
const iframe = this.compilerFrame;
|
|
2373
|
+
const frameWindow = iframe?.contentWindow;
|
|
2374
|
+
if (!frameWindow) {
|
|
2375
|
+
return { success: false, error: "C++ compiler frame is not available." };
|
|
2376
|
+
}
|
|
2377
|
+
return new Promise((resolve) => {
|
|
2378
|
+
const requestId = `compile-${++this.compilerFrameRequestId}`;
|
|
2379
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2380
|
+
this.pendingCompilerFrameRequests.delete(requestId);
|
|
2381
|
+
resolve({ success: false, error: "C++ compiler frame request timed out." });
|
|
2382
|
+
}, this.initTimeoutMs);
|
|
2383
|
+
this.pendingCompilerFrameRequests.set(requestId, { resolve, timeoutId });
|
|
2384
|
+
frameWindow.postMessage(
|
|
2385
|
+
{
|
|
2386
|
+
id: requestId,
|
|
2387
|
+
type: "compile",
|
|
2388
|
+
payload
|
|
2389
|
+
},
|
|
2390
|
+
this.compilerFrameTargetOrigin
|
|
2391
|
+
);
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
async executeCode(code, functionName, inputs, executionStyle) {
|
|
2395
|
+
await this.init();
|
|
2396
|
+
try {
|
|
2397
|
+
return await this.executeWithTimeout(
|
|
2398
|
+
() => this.sendMessage(
|
|
2399
|
+
"compile-run",
|
|
2400
|
+
{ code, functionName, inputs, executionStyle },
|
|
2401
|
+
this.executionTimeoutMs + 5e3
|
|
2402
|
+
),
|
|
2403
|
+
this.executionTimeoutMs,
|
|
2404
|
+
"compile-run"
|
|
2405
|
+
);
|
|
2406
|
+
} catch (error) {
|
|
2407
|
+
if (this.isClientTimeout(error)) return this.timeoutCodeResult(error);
|
|
2408
|
+
throw error;
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle) {
|
|
2412
|
+
await this.init();
|
|
2413
|
+
try {
|
|
2414
|
+
return await this.executeWithTimeout(
|
|
2415
|
+
() => this.sendMessage(
|
|
2416
|
+
"execute-with-tracing",
|
|
2417
|
+
{ code, functionName, inputs, options, executionStyle },
|
|
2418
|
+
this.tracingTimeoutMs + 5e3
|
|
2419
|
+
),
|
|
2420
|
+
this.tracingTimeoutMs,
|
|
2421
|
+
"trace"
|
|
2422
|
+
);
|
|
2423
|
+
} catch (error) {
|
|
2424
|
+
if (this.isClientTimeout(error)) return this.timeoutTraceResult(error);
|
|
2425
|
+
throw error;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle) {
|
|
2429
|
+
await this.init();
|
|
2430
|
+
try {
|
|
2431
|
+
return await this.executeWithTimeout(
|
|
2432
|
+
() => this.sendMessage(
|
|
2433
|
+
"execute-code-interview",
|
|
2434
|
+
{ code, functionName, inputs, executionStyle },
|
|
2435
|
+
this.interviewTimeoutMs + 5e3
|
|
2436
|
+
),
|
|
2437
|
+
this.interviewTimeoutMs,
|
|
2438
|
+
"interview"
|
|
2439
|
+
);
|
|
2440
|
+
} catch {
|
|
2441
|
+
return {
|
|
2442
|
+
success: false,
|
|
2443
|
+
output: null,
|
|
2444
|
+
error: "Time Limit Exceeded",
|
|
2445
|
+
timeoutReason: "client-timeout",
|
|
2446
|
+
diagnosticStage: "interview",
|
|
2447
|
+
consoleOutput: [],
|
|
2448
|
+
timings: { totalMs: this.interviewTimeoutMs }
|
|
2449
|
+
};
|
|
2450
|
+
}
|
|
845
2451
|
}
|
|
846
2452
|
terminate() {
|
|
847
2453
|
this.terminateAndReset();
|
|
@@ -849,9 +2455,12 @@ var JavaWorkerClient = class {
|
|
|
849
2455
|
};
|
|
850
2456
|
// Annotate the CommonJS export names for ESM import in node:
|
|
851
2457
|
0 && (module.exports = {
|
|
2458
|
+
CSharpWorkerClient,
|
|
2459
|
+
CppWorkerClient,
|
|
852
2460
|
JavaScriptWorkerClient,
|
|
853
2461
|
JavaWorkerClient,
|
|
854
2462
|
PyodideWorkerClient,
|
|
2463
|
+
PythonWorkerClient,
|
|
855
2464
|
isJavaScriptWorkerSupported,
|
|
856
2465
|
isWorkerSupported
|
|
857
2466
|
});
|