@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
package/dist/browser.cjs
CHANGED
|
@@ -21,22 +21,383 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS: () => DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS,
|
|
24
|
+
LANGUAGE_RUNTIME_INFOS: () => LANGUAGE_RUNTIME_INFOS,
|
|
24
25
|
LANGUAGE_RUNTIME_PROFILES: () => LANGUAGE_RUNTIME_PROFILES,
|
|
25
26
|
SUPPORTED_LANGUAGES: () => SUPPORTED_LANGUAGES,
|
|
27
|
+
SUPPORTED_LANGUAGE_RUNTIME_INFOS: () => SUPPORTED_LANGUAGE_RUNTIME_INFOS,
|
|
26
28
|
assertRuntimeRequestSupported: () => assertRuntimeRequestSupported,
|
|
27
29
|
createBrowserHarness: () => createBrowserHarness,
|
|
30
|
+
getLanguageRuntimeInfo: () => getLanguageRuntimeInfo,
|
|
28
31
|
getLanguageRuntimeProfile: () => getLanguageRuntimeProfile,
|
|
29
32
|
getSupportedLanguageProfiles: () => getSupportedLanguageProfiles,
|
|
33
|
+
getSupportedLanguageRuntimeInfos: () => getSupportedLanguageRuntimeInfos,
|
|
30
34
|
isLanguageSupported: () => isLanguageSupported,
|
|
31
35
|
resolveBrowserHarnessAssets: () => resolveBrowserHarnessAssets
|
|
32
36
|
});
|
|
33
37
|
module.exports = __toCommonJS(src_exports);
|
|
34
38
|
|
|
39
|
+
// packages/harness-core/src/generated/runtime-language-info-data.ts
|
|
40
|
+
var LANGUAGE_RUNTIME_INFOS = Object.freeze({
|
|
41
|
+
"python": {
|
|
42
|
+
"language": "python",
|
|
43
|
+
"displayName": "Python",
|
|
44
|
+
"versionLabel": "Python 3.13.2 (Pyodide 0.29.0)",
|
|
45
|
+
"description": "Python 3.13.2 (Pyodide 0.29.0).\n\nCommon algorithm helpers are imported automatically, including array, bisect, collections, functools, heapq, itertools. Other standard-library modules can be imported normally.\n\nsortedcontainers 2.4.0 is available for TreeMap, ordered-set, and sorted-list style workflows.",
|
|
46
|
+
"runtime": {
|
|
47
|
+
"name": "Pyodide",
|
|
48
|
+
"version": "0.29.0",
|
|
49
|
+
"detail": "CPython 3.13.2 compiled to WebAssembly."
|
|
50
|
+
},
|
|
51
|
+
"defaultImports": [
|
|
52
|
+
"array",
|
|
53
|
+
"bisect",
|
|
54
|
+
"collections",
|
|
55
|
+
"functools",
|
|
56
|
+
"heapq",
|
|
57
|
+
"itertools",
|
|
58
|
+
"operator",
|
|
59
|
+
"re",
|
|
60
|
+
"string",
|
|
61
|
+
"typing"
|
|
62
|
+
],
|
|
63
|
+
"libraries": [
|
|
64
|
+
{
|
|
65
|
+
"name": "sortedcontainers",
|
|
66
|
+
"version": "2.4.0",
|
|
67
|
+
"importName": "sortedcontainers",
|
|
68
|
+
"detail": "SortedDict, SortedList, and SortedSet are loaded for tree-map/tree-set style use cases."
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"javascript": {
|
|
73
|
+
"language": "javascript",
|
|
74
|
+
"displayName": "JavaScript",
|
|
75
|
+
"versionLabel": "JavaScript (ECMAScript 2023)",
|
|
76
|
+
"runtime": {
|
|
77
|
+
"name": "Browser Worker JavaScript runtime",
|
|
78
|
+
"detail": "Runs in the host browser worker; Node.js is not required for browser execution."
|
|
79
|
+
},
|
|
80
|
+
"libraries": [
|
|
81
|
+
{
|
|
82
|
+
"name": "lodash",
|
|
83
|
+
"version": "4.17.21",
|
|
84
|
+
"importName": "lodash",
|
|
85
|
+
"globalName": "_"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "@datastructures-js/binary-search-tree",
|
|
89
|
+
"version": "5.4.0",
|
|
90
|
+
"importName": "@datastructures-js/binary-search-tree"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "@datastructures-js/deque",
|
|
94
|
+
"version": "1.0.8",
|
|
95
|
+
"importName": "@datastructures-js/deque"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "@datastructures-js/graph",
|
|
99
|
+
"version": "5.3.1",
|
|
100
|
+
"importName": "@datastructures-js/graph"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "@datastructures-js/heap",
|
|
104
|
+
"version": "4.3.7",
|
|
105
|
+
"importName": "@datastructures-js/heap"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"name": "@datastructures-js/linked-list",
|
|
109
|
+
"version": "6.1.4",
|
|
110
|
+
"importName": "@datastructures-js/linked-list"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "@datastructures-js/priority-queue",
|
|
114
|
+
"version": "6.3.5",
|
|
115
|
+
"importName": "@datastructures-js/priority-queue"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "@datastructures-js/queue",
|
|
119
|
+
"version": "4.3.0",
|
|
120
|
+
"importName": "@datastructures-js/queue"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "@datastructures-js/set",
|
|
124
|
+
"version": "4.2.2",
|
|
125
|
+
"importName": "@datastructures-js/set"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "@datastructures-js/stack",
|
|
129
|
+
"version": "3.1.6",
|
|
130
|
+
"importName": "@datastructures-js/stack"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "@datastructures-js/trie",
|
|
134
|
+
"version": "4.2.3",
|
|
135
|
+
"importName": "@datastructures-js/trie"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"standard": "ECMAScript 2023-compatible syntax in the browser worker lane.",
|
|
139
|
+
"description": 'JavaScript runs in an isolated browser Web Worker with ECMAScript 2023-compatible syntax.\n\nLodash 4.17.21 is available as both lodash and _.\n\nThe @datastructures-js packages are bundled for common algorithm data structures. Queue, Stack, Deque, Heap, PriorityQueue, MinPriorityQueue, and MaxPriorityQueue are available globally.\n\nBundled @datastructures-js versions:\n\n"@datastructures-js/binary-search-tree": "5.4.0"\n"@datastructures-js/deque": "1.0.8"\n"@datastructures-js/graph": "5.3.1"\n"@datastructures-js/heap": "4.3.7"\n"@datastructures-js/linked-list": "6.1.4"\n"@datastructures-js/priority-queue": "6.3.5"\n"@datastructures-js/queue": "4.3.0"\n"@datastructures-js/set": "4.2.2"\n"@datastructures-js/stack": "3.1.6"\n"@datastructures-js/trie": "4.2.3"\n\nBinary Search Tree, Trie, and Graph are bundled too, but are not exposed globally because those names can collide with problem definitions. Import or require the matching package when you need one.'
|
|
140
|
+
},
|
|
141
|
+
"typescript": {
|
|
142
|
+
"language": "typescript",
|
|
143
|
+
"displayName": "TypeScript",
|
|
144
|
+
"versionLabel": "TypeScript 5.9.3",
|
|
145
|
+
"description": 'TypeScript 5.9.3 is compiled in the browser and then executed on the JavaScript worker runtime.\n\nCompiler options: --target ES2020 --module None --strict false --esModuleInterop\n\nLodash 4.17.21 is available as both lodash and _.\n\nThe @datastructures-js packages are bundled for common algorithm data structures. Queue, Stack, Deque, Heap, PriorityQueue, MinPriorityQueue, and MaxPriorityQueue are available globally.\n\nBundled @datastructures-js versions:\n\n"@datastructures-js/binary-search-tree": "5.4.0"\n"@datastructures-js/deque": "1.0.8"\n"@datastructures-js/graph": "5.3.1"\n"@datastructures-js/heap": "4.3.7"\n"@datastructures-js/linked-list": "6.1.4"\n"@datastructures-js/priority-queue": "6.3.5"\n"@datastructures-js/queue": "4.3.0"\n"@datastructures-js/set": "4.2.2"\n"@datastructures-js/stack": "3.1.6"\n"@datastructures-js/trie": "4.2.3"\n\nBinary Search Tree, Trie, and Graph are bundled too, but are not exposed globally because those names can collide with problem definitions. Import or require the matching package when you need one.\n\nThe compiled output runs on the same browser worker execution lane as JavaScript submissions.',
|
|
146
|
+
"runtime": {
|
|
147
|
+
"name": "Browser Worker JavaScript runtime",
|
|
148
|
+
"detail": "TypeScript is compiled before execution and runs on the JavaScript worker lane."
|
|
149
|
+
},
|
|
150
|
+
"compiler": {
|
|
151
|
+
"name": "TypeScript",
|
|
152
|
+
"version": "5.9.3"
|
|
153
|
+
},
|
|
154
|
+
"standard": "Transpiles to JavaScript for the browser worker lane.",
|
|
155
|
+
"libraries": [
|
|
156
|
+
{
|
|
157
|
+
"name": "lodash",
|
|
158
|
+
"version": "4.17.21",
|
|
159
|
+
"importName": "lodash",
|
|
160
|
+
"globalName": "_"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "@datastructures-js/binary-search-tree",
|
|
164
|
+
"version": "5.4.0",
|
|
165
|
+
"importName": "@datastructures-js/binary-search-tree"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"name": "@datastructures-js/deque",
|
|
169
|
+
"version": "1.0.8",
|
|
170
|
+
"importName": "@datastructures-js/deque"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "@datastructures-js/graph",
|
|
174
|
+
"version": "5.3.1",
|
|
175
|
+
"importName": "@datastructures-js/graph"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "@datastructures-js/heap",
|
|
179
|
+
"version": "4.3.7",
|
|
180
|
+
"importName": "@datastructures-js/heap"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "@datastructures-js/linked-list",
|
|
184
|
+
"version": "6.1.4",
|
|
185
|
+
"importName": "@datastructures-js/linked-list"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"name": "@datastructures-js/priority-queue",
|
|
189
|
+
"version": "6.3.5",
|
|
190
|
+
"importName": "@datastructures-js/priority-queue"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "@datastructures-js/queue",
|
|
194
|
+
"version": "4.3.0",
|
|
195
|
+
"importName": "@datastructures-js/queue"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"name": "@datastructures-js/set",
|
|
199
|
+
"version": "4.2.2",
|
|
200
|
+
"importName": "@datastructures-js/set"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"name": "@datastructures-js/stack",
|
|
204
|
+
"version": "3.1.6",
|
|
205
|
+
"importName": "@datastructures-js/stack"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"name": "@datastructures-js/trie",
|
|
209
|
+
"version": "4.2.3",
|
|
210
|
+
"importName": "@datastructures-js/trie"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
"java": {
|
|
215
|
+
"language": "java",
|
|
216
|
+
"displayName": "Java",
|
|
217
|
+
"versionLabel": "Java 17",
|
|
218
|
+
"description": "Java 17 is compiled with javac 17 and executed in the browser through CheerpJ 4.2.\n\nCommon imports are added automatically: java.util.*, java.io.*, java.math.*, java.util.stream.*, javafx.util.Pair.",
|
|
219
|
+
"runtime": {
|
|
220
|
+
"name": "CheerpJ browser-local OpenJDK runtime",
|
|
221
|
+
"version": "17",
|
|
222
|
+
"detail": "Loaded through CheerpJ 4.2."
|
|
223
|
+
},
|
|
224
|
+
"compiler": {
|
|
225
|
+
"name": "javac",
|
|
226
|
+
"version": "17"
|
|
227
|
+
},
|
|
228
|
+
"defaultImports": [
|
|
229
|
+
"java.util.*",
|
|
230
|
+
"java.io.*",
|
|
231
|
+
"java.math.*",
|
|
232
|
+
"java.util.stream.*",
|
|
233
|
+
"javafx.util.Pair"
|
|
234
|
+
],
|
|
235
|
+
"libraries": [
|
|
236
|
+
{
|
|
237
|
+
"name": "JavaParser",
|
|
238
|
+
"version": "3.25.10",
|
|
239
|
+
"detail": "Used internally for Java source rewriting."
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"name": "javafx.util.Pair",
|
|
243
|
+
"detail": "Small compatibility Pair class bundled with the Java helper jar."
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
"csharp": {
|
|
248
|
+
"language": "csharp",
|
|
249
|
+
"displayName": "C#",
|
|
250
|
+
"versionLabel": "C# 14 (.NET 10.0.8)",
|
|
251
|
+
"description": "C# 14 with .NET 10.0.8 runtime.\n\nCode is compiled with Microsoft.CodeAnalysis.CSharp 5.3.0 and executed by a browser-local .NET WebAssembly runtime.\n\nCommon namespaces are imported automatically: System, System.Collections, System.Collections.Generic, System.Linq, System.Numerics, System.Text, System.Text.RegularExpressions.",
|
|
252
|
+
"runtime": {
|
|
253
|
+
"name": ".NET WebAssembly runtime",
|
|
254
|
+
"version": "10.0.8",
|
|
255
|
+
"detail": "Browser-local .NET runtime targeting net10.0."
|
|
256
|
+
},
|
|
257
|
+
"compiler": {
|
|
258
|
+
"name": "Microsoft.CodeAnalysis.CSharp",
|
|
259
|
+
"version": "5.3.0"
|
|
260
|
+
},
|
|
261
|
+
"standard": "C# 14",
|
|
262
|
+
"defaultImports": [
|
|
263
|
+
"System",
|
|
264
|
+
"System.Collections",
|
|
265
|
+
"System.Collections.Generic",
|
|
266
|
+
"System.Linq",
|
|
267
|
+
"System.Numerics",
|
|
268
|
+
"System.Text",
|
|
269
|
+
"System.Text.RegularExpressions"
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
"cpp": {
|
|
273
|
+
"language": "cpp",
|
|
274
|
+
"displayName": "C++",
|
|
275
|
+
"versionLabel": "C++23 (YoWASP Clang 22)",
|
|
276
|
+
"description": "C++ is compiled with YoWASP Clang/LLD 22.0.0-git20542-10 using the C++23 standard.\n\nSubmissions compile to WebAssembly and run in a browser-local WASI-style execution lane. The harness currently compiles with -O0 and -fno-exceptions, with a fixed program stack size.\n\nCommon standard library headers are included automatically, including <algorithm>, <array>, <bitset>, <climits>, <cmath>, <cstdint>, <functional>, <limits>, <numeric>, <sstream>, <tuple>, <vector>, <unordered_map>, <unordered_set> and more.",
|
|
277
|
+
"runtime": {
|
|
278
|
+
"name": "WASI/WebAssembly execution lane",
|
|
279
|
+
"detail": "Compiled and executed in a browser-local WASI-style worker lane."
|
|
280
|
+
},
|
|
281
|
+
"compiler": {
|
|
282
|
+
"name": "YoWASP Clang/LLD",
|
|
283
|
+
"version": "22.0.0-git20542-10"
|
|
284
|
+
},
|
|
285
|
+
"standard": "C++23",
|
|
286
|
+
"defaultImports": [
|
|
287
|
+
"<algorithm>",
|
|
288
|
+
"<array>",
|
|
289
|
+
"<bitset>",
|
|
290
|
+
"<climits>",
|
|
291
|
+
"<cmath>",
|
|
292
|
+
"<cstdint>",
|
|
293
|
+
"<functional>",
|
|
294
|
+
"<limits>",
|
|
295
|
+
"<numeric>",
|
|
296
|
+
"<sstream>",
|
|
297
|
+
"<tuple>",
|
|
298
|
+
"<vector>",
|
|
299
|
+
"<unordered_map>",
|
|
300
|
+
"<unordered_set>",
|
|
301
|
+
"<map>",
|
|
302
|
+
"<set>",
|
|
303
|
+
"<deque>",
|
|
304
|
+
"<queue>",
|
|
305
|
+
"<stack>",
|
|
306
|
+
"<utility>",
|
|
307
|
+
"<string>",
|
|
308
|
+
"<span>",
|
|
309
|
+
"<ranges>",
|
|
310
|
+
"<concepts>",
|
|
311
|
+
"<any>",
|
|
312
|
+
"<bit>",
|
|
313
|
+
"<cctype>",
|
|
314
|
+
"<cerrno>",
|
|
315
|
+
"<cfloat>",
|
|
316
|
+
"<charconv>",
|
|
317
|
+
"<chrono>",
|
|
318
|
+
"<cinttypes>",
|
|
319
|
+
"<compare>",
|
|
320
|
+
"<complex>",
|
|
321
|
+
"<cstddef>",
|
|
322
|
+
"<cstdio>",
|
|
323
|
+
"<cstdlib>",
|
|
324
|
+
"<cstring>",
|
|
325
|
+
"<exception>",
|
|
326
|
+
"<expected>",
|
|
327
|
+
"<forward_list>",
|
|
328
|
+
"<initializer_list>",
|
|
329
|
+
"<iomanip>",
|
|
330
|
+
"<ios>",
|
|
331
|
+
"<iostream>",
|
|
332
|
+
"<iterator>",
|
|
333
|
+
"<list>",
|
|
334
|
+
"<memory>",
|
|
335
|
+
"<numbers>",
|
|
336
|
+
"<optional>",
|
|
337
|
+
"<random>",
|
|
338
|
+
"<ratio>",
|
|
339
|
+
"<regex>",
|
|
340
|
+
"<stdexcept>",
|
|
341
|
+
"<string_view>",
|
|
342
|
+
"<type_traits>",
|
|
343
|
+
"<typeindex>",
|
|
344
|
+
"<typeinfo>",
|
|
345
|
+
"<valarray>",
|
|
346
|
+
"<variant>",
|
|
347
|
+
"<version>"
|
|
348
|
+
],
|
|
349
|
+
"libraries": [
|
|
350
|
+
{
|
|
351
|
+
"name": "C++ standard library and WASI libc",
|
|
352
|
+
"detail": "Provided by the YoWASP Clang toolchain bundle."
|
|
353
|
+
}
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// packages/harness-core/src/runtime-language-info.ts
|
|
359
|
+
var SUPPORTED_LANGUAGE_RUNTIME_INFOS = Object.freeze(
|
|
360
|
+
Object.values(LANGUAGE_RUNTIME_INFOS)
|
|
361
|
+
);
|
|
362
|
+
function getLanguageRuntimeInfo(language) {
|
|
363
|
+
const info = LANGUAGE_RUNTIME_INFOS[language];
|
|
364
|
+
if (!info) {
|
|
365
|
+
throw new Error(`Runtime info for language "${language}" is not implemented yet.`);
|
|
366
|
+
}
|
|
367
|
+
return info;
|
|
368
|
+
}
|
|
369
|
+
function getSupportedLanguageRuntimeInfos() {
|
|
370
|
+
return SUPPORTED_LANGUAGE_RUNTIME_INFOS;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// packages/harness-browser/src/runtime-diagnostics.ts
|
|
374
|
+
var CONSOLE_METHOD_BY_LEVEL = {
|
|
375
|
+
debug: "debug",
|
|
376
|
+
info: "info",
|
|
377
|
+
warn: "warn",
|
|
378
|
+
error: "error"
|
|
379
|
+
};
|
|
380
|
+
function runtimeDiagnosticEvent(params) {
|
|
381
|
+
return {
|
|
382
|
+
schema: "tracecode.runtime-diagnostic.v1",
|
|
383
|
+
source: "harness",
|
|
384
|
+
...params
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function logRuntimeDiagnostic(level, params, options = {}) {
|
|
388
|
+
if (options.enabled === false && level !== "error") {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const method = CONSOLE_METHOD_BY_LEVEL[level] ?? "info";
|
|
392
|
+
console[method]("[TraceRuntime]", runtimeDiagnosticEvent(params));
|
|
393
|
+
}
|
|
394
|
+
|
|
35
395
|
// packages/harness-browser/src/javascript-worker-client.ts
|
|
36
|
-
var EXECUTION_TIMEOUT_MS =
|
|
396
|
+
var EXECUTION_TIMEOUT_MS = 2e4;
|
|
37
397
|
var INTERVIEW_MODE_TIMEOUT_MS = 5e3;
|
|
38
|
-
var TRACING_TIMEOUT_MS =
|
|
398
|
+
var TRACING_TIMEOUT_MS = 2e4;
|
|
39
399
|
var INIT_TIMEOUT_MS = 1e4;
|
|
400
|
+
var TYPESCRIPT_WARMUP_TIMEOUT_MS = 3e4;
|
|
40
401
|
var MESSAGE_TIMEOUT_MS = 12e3;
|
|
41
402
|
var WORKER_READY_TIMEOUT_MS = 1e4;
|
|
42
403
|
var JavaScriptWorkerClient = class {
|
|
@@ -49,6 +410,7 @@ var JavaScriptWorkerClient = class {
|
|
|
49
410
|
messageId = 0;
|
|
50
411
|
isInitializing = false;
|
|
51
412
|
initPromise = null;
|
|
413
|
+
warmupPromises = /* @__PURE__ */ new Map();
|
|
52
414
|
workerReadyPromise = null;
|
|
53
415
|
workerReadyResolve = null;
|
|
54
416
|
workerReadyReject = null;
|
|
@@ -73,7 +435,12 @@ var JavaScriptWorkerClient = class {
|
|
|
73
435
|
this.workerReadyResolve?.();
|
|
74
436
|
this.workerReadyResolve = null;
|
|
75
437
|
this.workerReadyReject = null;
|
|
76
|
-
|
|
438
|
+
logRuntimeDiagnostic("info", {
|
|
439
|
+
component: "JavaScriptWorkerClient",
|
|
440
|
+
runtime: "javascript",
|
|
441
|
+
phase: "worker-ready",
|
|
442
|
+
message: "JavaScript worker is ready."
|
|
443
|
+
}, { enabled: this.debug });
|
|
77
444
|
return;
|
|
78
445
|
}
|
|
79
446
|
if (id) {
|
|
@@ -89,7 +456,18 @@ var JavaScriptWorkerClient = class {
|
|
|
89
456
|
}
|
|
90
457
|
};
|
|
91
458
|
this.worker.onerror = (error) => {
|
|
92
|
-
|
|
459
|
+
logRuntimeDiagnostic("error", {
|
|
460
|
+
component: "JavaScriptWorkerClient",
|
|
461
|
+
runtime: "javascript",
|
|
462
|
+
phase: "worker-error",
|
|
463
|
+
message: "JavaScript worker emitted an error event.",
|
|
464
|
+
detail: {
|
|
465
|
+
message: error.message,
|
|
466
|
+
filename: error.filename,
|
|
467
|
+
lineno: error.lineno,
|
|
468
|
+
colno: error.colno
|
|
469
|
+
}
|
|
470
|
+
});
|
|
93
471
|
const workerError = new Error("Worker error");
|
|
94
472
|
this.workerReadyReject?.(workerError);
|
|
95
473
|
this.workerReadyResolve = null;
|
|
@@ -182,6 +560,7 @@ var JavaScriptWorkerClient = class {
|
|
|
182
560
|
this.worker = null;
|
|
183
561
|
}
|
|
184
562
|
this.initPromise = null;
|
|
563
|
+
this.warmupPromises.clear();
|
|
185
564
|
this.isInitializing = false;
|
|
186
565
|
this.workerReadyPromise = null;
|
|
187
566
|
this.workerReadyResolve = null;
|
|
@@ -209,6 +588,25 @@ var JavaScriptWorkerClient = class {
|
|
|
209
588
|
this.isInitializing = false;
|
|
210
589
|
}
|
|
211
590
|
}
|
|
591
|
+
async warmup(language = "javascript") {
|
|
592
|
+
const existing = this.warmupPromises.get(language);
|
|
593
|
+
if (existing) return existing;
|
|
594
|
+
const warmupPromise = (async () => {
|
|
595
|
+
await this.init();
|
|
596
|
+
return this.sendMessage(
|
|
597
|
+
"warmup",
|
|
598
|
+
{ language },
|
|
599
|
+
language === "typescript" ? TYPESCRIPT_WARMUP_TIMEOUT_MS : INIT_TIMEOUT_MS
|
|
600
|
+
);
|
|
601
|
+
})();
|
|
602
|
+
this.warmupPromises.set(language, warmupPromise);
|
|
603
|
+
try {
|
|
604
|
+
return await warmupPromise;
|
|
605
|
+
} catch (error) {
|
|
606
|
+
this.warmupPromises.delete(language);
|
|
607
|
+
throw error;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
212
610
|
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function", language = "javascript") {
|
|
213
611
|
await this.init();
|
|
214
612
|
return this.executeWithTimeout(
|
|
@@ -288,344 +686,6 @@ var JavaScriptWorkerClient = class {
|
|
|
288
686
|
}
|
|
289
687
|
};
|
|
290
688
|
|
|
291
|
-
// packages/harness-core/src/trace-contract.ts
|
|
292
|
-
var RUNTIME_TRACE_CONTRACT_SCHEMA_VERSION = "2026-04-21";
|
|
293
|
-
var TRACE_EVENTS = /* @__PURE__ */ new Set([
|
|
294
|
-
"line",
|
|
295
|
-
"call",
|
|
296
|
-
"return",
|
|
297
|
-
"exception",
|
|
298
|
-
"timeout",
|
|
299
|
-
"stdout"
|
|
300
|
-
]);
|
|
301
|
-
var TRACE_ACCESS_KINDS = /* @__PURE__ */ new Set([
|
|
302
|
-
"indexed-read",
|
|
303
|
-
"indexed-write",
|
|
304
|
-
"cell-read",
|
|
305
|
-
"cell-write",
|
|
306
|
-
"mutating-call"
|
|
307
|
-
]);
|
|
308
|
-
function normalizeLineNumber(value, fallback = 1) {
|
|
309
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
|
310
|
-
const normalized = Math.floor(value);
|
|
311
|
-
return normalized > 0 ? normalized : fallback;
|
|
312
|
-
}
|
|
313
|
-
function normalizeOutputLineCount(value) {
|
|
314
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
315
|
-
const normalized = Math.floor(value);
|
|
316
|
-
return normalized >= 0 ? normalized : void 0;
|
|
317
|
-
}
|
|
318
|
-
function normalizeEvent(value) {
|
|
319
|
-
if (typeof value === "string" && TRACE_EVENTS.has(value)) {
|
|
320
|
-
return value;
|
|
321
|
-
}
|
|
322
|
-
return "line";
|
|
323
|
-
}
|
|
324
|
-
function normalizeAccessKind(value) {
|
|
325
|
-
if (typeof value === "string" && TRACE_ACCESS_KINDS.has(value)) {
|
|
326
|
-
return value;
|
|
327
|
-
}
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
function normalizeFunctionName(value) {
|
|
331
|
-
if (typeof value === "string" && value.length > 0) return value;
|
|
332
|
-
return "<module>";
|
|
333
|
-
}
|
|
334
|
-
function normalizeKind(value) {
|
|
335
|
-
if (value === "map" || value === "set" || value === "hashmap" || value === "object") {
|
|
336
|
-
return value;
|
|
337
|
-
}
|
|
338
|
-
return "hashmap";
|
|
339
|
-
}
|
|
340
|
-
function normalizeObjectKind(value) {
|
|
341
|
-
if (value === "hashmap" || value === "object" || value === "map" || value === "set" || value === "tree" || value === "linked-list" || value === "graph-adjacency") {
|
|
342
|
-
return value;
|
|
343
|
-
}
|
|
344
|
-
return null;
|
|
345
|
-
}
|
|
346
|
-
function normalizeScalar(value) {
|
|
347
|
-
if (value === null || value === void 0) return value;
|
|
348
|
-
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
349
|
-
if (typeof value === "number") return Number.isFinite(value) ? value : String(value);
|
|
350
|
-
if (typeof value === "bigint") {
|
|
351
|
-
const asNumber = Number(value);
|
|
352
|
-
return Number.isSafeInteger(asNumber) ? asNumber : String(value);
|
|
353
|
-
}
|
|
354
|
-
if (typeof value === "function") return "<function>";
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
function normalizeUnknown(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
|
|
358
|
-
if (depth > 48) return "<max depth>";
|
|
359
|
-
const scalar = normalizeScalar(value);
|
|
360
|
-
if (scalar !== null || value === null || value === void 0) {
|
|
361
|
-
return scalar;
|
|
362
|
-
}
|
|
363
|
-
if (Array.isArray(value)) {
|
|
364
|
-
return value.map((item) => {
|
|
365
|
-
if (item === void 0) return null;
|
|
366
|
-
return normalizeUnknown(item, depth + 1, seen);
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
if (typeof value === "object" && value) {
|
|
370
|
-
if (seen.has(value)) return "<cycle>";
|
|
371
|
-
seen.add(value);
|
|
372
|
-
const normalized = {};
|
|
373
|
-
for (const key of Object.keys(value).sort()) {
|
|
374
|
-
const child = value[key];
|
|
375
|
-
if (child === void 0) continue;
|
|
376
|
-
normalized[key] = normalizeUnknown(child, depth + 1, seen);
|
|
377
|
-
}
|
|
378
|
-
seen.delete(value);
|
|
379
|
-
return normalized;
|
|
380
|
-
}
|
|
381
|
-
return String(value);
|
|
382
|
-
}
|
|
383
|
-
function normalizeAccesses(accesses) {
|
|
384
|
-
if (!Array.isArray(accesses) || accesses.length === 0) {
|
|
385
|
-
return void 0;
|
|
386
|
-
}
|
|
387
|
-
const normalized = accesses.map((access) => {
|
|
388
|
-
const variable = typeof access?.variable === "string" && access.variable.length > 0 ? access.variable : "";
|
|
389
|
-
const kind = normalizeAccessKind(access?.kind);
|
|
390
|
-
if (!variable || !kind) {
|
|
391
|
-
return null;
|
|
392
|
-
}
|
|
393
|
-
const indices = Array.isArray(access?.indices) ? access.indices.map(
|
|
394
|
-
(index) => typeof index === "number" && Number.isFinite(index) ? Math.floor(index) : null
|
|
395
|
-
).filter((index) => index !== null) : void 0;
|
|
396
|
-
const pathDepth = access?.pathDepth === 1 || access?.pathDepth === 2 ? access.pathDepth : void 0;
|
|
397
|
-
const method = typeof access?.method === "string" && access.method.length > 0 ? access.method : void 0;
|
|
398
|
-
const payload = {
|
|
399
|
-
variable,
|
|
400
|
-
kind
|
|
401
|
-
};
|
|
402
|
-
if (indices && indices.length > 0) {
|
|
403
|
-
payload.indices = indices;
|
|
404
|
-
}
|
|
405
|
-
if (pathDepth !== void 0) {
|
|
406
|
-
payload.pathDepth = pathDepth;
|
|
407
|
-
}
|
|
408
|
-
if (method) {
|
|
409
|
-
payload.method = method;
|
|
410
|
-
}
|
|
411
|
-
return payload;
|
|
412
|
-
}).filter((access) => access !== null);
|
|
413
|
-
if (normalized.length === 0) {
|
|
414
|
-
return void 0;
|
|
415
|
-
}
|
|
416
|
-
const statsByVariable = /* @__PURE__ */ new Map();
|
|
417
|
-
for (const access of normalized) {
|
|
418
|
-
const stats = statsByVariable.get(access.variable) ?? { hasCellRead: false, hasCellWrite: false };
|
|
419
|
-
if (access.kind === "cell-read") stats.hasCellRead = true;
|
|
420
|
-
if (access.kind === "cell-write") stats.hasCellWrite = true;
|
|
421
|
-
statsByVariable.set(access.variable, stats);
|
|
422
|
-
}
|
|
423
|
-
const deduped = /* @__PURE__ */ new Set();
|
|
424
|
-
const collapsed = normalized.filter((access) => {
|
|
425
|
-
const stats = statsByVariable.get(access.variable);
|
|
426
|
-
if (access.kind === "indexed-read" && (stats?.hasCellRead || stats?.hasCellWrite)) {
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
if (access.kind === "indexed-write" && stats?.hasCellWrite) {
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
const key = JSON.stringify([
|
|
433
|
-
access.variable,
|
|
434
|
-
access.kind,
|
|
435
|
-
access.indices ?? null,
|
|
436
|
-
access.pathDepth ?? null,
|
|
437
|
-
access.method ?? null
|
|
438
|
-
]);
|
|
439
|
-
if (deduped.has(key)) {
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
deduped.add(key);
|
|
443
|
-
return true;
|
|
444
|
-
});
|
|
445
|
-
return collapsed.length > 0 ? collapsed : void 0;
|
|
446
|
-
}
|
|
447
|
-
function normalizeRecord(value) {
|
|
448
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
449
|
-
return normalizeUnknown(value);
|
|
450
|
-
}
|
|
451
|
-
function normalizeVariableSources(value) {
|
|
452
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
453
|
-
const entries = Object.entries(value).filter(
|
|
454
|
-
([name, source]) => typeof name === "string" && name.length > 0 && (source === "user" || source === "user-input" || source === "harness-prelude")
|
|
455
|
-
).sort((a, b) => a[0].localeCompare(b[0]));
|
|
456
|
-
if (entries.length === 0) return void 0;
|
|
457
|
-
return Object.fromEntries(entries);
|
|
458
|
-
}
|
|
459
|
-
function normalizeCallStackFrame(frame) {
|
|
460
|
-
return {
|
|
461
|
-
function: normalizeFunctionName(frame?.function),
|
|
462
|
-
line: normalizeLineNumber(frame?.line, 1),
|
|
463
|
-
args: normalizeRecord(frame?.args)
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
function normalizeVisualizationPayload(payload) {
|
|
467
|
-
const hashMaps = Array.isArray(payload?.hashMaps) ? payload.hashMaps.map((entry) => ({
|
|
468
|
-
name: typeof entry?.name === "string" ? entry.name : "",
|
|
469
|
-
kind: normalizeKind(entry?.kind),
|
|
470
|
-
entries: Array.isArray(entry?.entries) ? entry.entries.map((item) => ({
|
|
471
|
-
key: normalizeUnknown(item?.key),
|
|
472
|
-
value: normalizeUnknown(item?.value),
|
|
473
|
-
...item?.highlight ? { highlight: true } : {}
|
|
474
|
-
})) : [],
|
|
475
|
-
...entry?.highlightedKey !== void 0 ? { highlightedKey: normalizeUnknown(entry.highlightedKey) } : {},
|
|
476
|
-
...entry?.deletedKey !== void 0 ? { deletedKey: normalizeUnknown(entry.deletedKey) } : {},
|
|
477
|
-
...typeof entry?.objectClassName === "string" && entry.objectClassName.length > 0 ? { objectClassName: entry.objectClassName } : {},
|
|
478
|
-
...typeof entry?.objectId === "string" && entry.objectId.length > 0 ? { objectId: entry.objectId } : {}
|
|
479
|
-
})).sort((a, b) => `${a.name}:${a.kind}`.localeCompare(`${b.name}:${b.kind}`)) : [];
|
|
480
|
-
const objectKinds = payload?.objectKinds && typeof payload.objectKinds === "object" ? Object.fromEntries(
|
|
481
|
-
Object.entries(payload.objectKinds).filter(([name]) => typeof name === "string" && name.length > 0).map(([name, kind]) => [name, normalizeObjectKind(kind)]).filter((entry) => entry[1] !== null).sort((a, b) => a[0].localeCompare(b[0]))
|
|
482
|
-
) : void 0;
|
|
483
|
-
if (hashMaps.length === 0 && (!objectKinds || Object.keys(objectKinds).length === 0)) {
|
|
484
|
-
return void 0;
|
|
485
|
-
}
|
|
486
|
-
return {
|
|
487
|
-
...hashMaps.length > 0 ? { hashMaps } : {},
|
|
488
|
-
...objectKinds && Object.keys(objectKinds).length > 0 ? { objectKinds } : {}
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
function normalizeTraceStep(step) {
|
|
492
|
-
const normalizedStdoutCount = normalizeOutputLineCount(step?.stdoutLineCount);
|
|
493
|
-
const normalizedVisualization = normalizeVisualizationPayload(step?.visualization);
|
|
494
|
-
const normalizedAccesses = normalizeAccesses(step?.accesses);
|
|
495
|
-
const normalizedVariableSources = normalizeVariableSources(step?.variableSources);
|
|
496
|
-
return {
|
|
497
|
-
event: normalizeEvent(step?.event),
|
|
498
|
-
line: normalizeLineNumber(step?.line, 1),
|
|
499
|
-
function: normalizeFunctionName(step?.function),
|
|
500
|
-
variables: normalizeRecord(step?.variables),
|
|
501
|
-
...normalizedVariableSources ? { variableSources: normalizedVariableSources } : {},
|
|
502
|
-
...Array.isArray(step?.callStack) && step.callStack.length > 0 ? { callStack: step.callStack.map(normalizeCallStackFrame) } : {},
|
|
503
|
-
...normalizedAccesses ? { accesses: normalizedAccesses } : {},
|
|
504
|
-
...step?.returnValue !== void 0 ? { returnValue: normalizeUnknown(step.returnValue) } : {},
|
|
505
|
-
...normalizedStdoutCount !== void 0 ? { stdoutLineCount: normalizedStdoutCount } : {},
|
|
506
|
-
...normalizedVisualization ? { visualization: normalizedVisualization } : {}
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
function collapseTraceAccessNoise(trace) {
|
|
510
|
-
const variablesWithCellAccess = /* @__PURE__ */ new Set();
|
|
511
|
-
const accessStatsByVariable = /* @__PURE__ */ new Map();
|
|
512
|
-
for (const step of trace) {
|
|
513
|
-
for (const access of step.accesses ?? []) {
|
|
514
|
-
const stats = accessStatsByVariable.get(access.variable) ?? {
|
|
515
|
-
hasCellRead: false,
|
|
516
|
-
hasCellWrite: false,
|
|
517
|
-
hasMutatingCall: false,
|
|
518
|
-
hasIndexedWrite: false
|
|
519
|
-
};
|
|
520
|
-
if (access.kind === "cell-read" || access.kind === "cell-write") {
|
|
521
|
-
variablesWithCellAccess.add(access.variable);
|
|
522
|
-
}
|
|
523
|
-
if (access.kind === "cell-read") stats.hasCellRead = true;
|
|
524
|
-
if (access.kind === "cell-write") stats.hasCellWrite = true;
|
|
525
|
-
if (access.kind === "mutating-call") stats.hasMutatingCall = true;
|
|
526
|
-
if (access.kind === "indexed-write") stats.hasIndexedWrite = true;
|
|
527
|
-
accessStatsByVariable.set(access.variable, stats);
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
if (variablesWithCellAccess.size === 0) {
|
|
531
|
-
return trace;
|
|
532
|
-
}
|
|
533
|
-
return trace.map((step) => {
|
|
534
|
-
if (!step.accesses?.length) {
|
|
535
|
-
return step;
|
|
536
|
-
}
|
|
537
|
-
const filtered = step.accesses.filter((access) => {
|
|
538
|
-
const stats = accessStatsByVariable.get(access.variable);
|
|
539
|
-
if (variablesWithCellAccess.has(access.variable)) {
|
|
540
|
-
return access.kind !== "indexed-read" && access.kind !== "indexed-write";
|
|
541
|
-
}
|
|
542
|
-
if (access.kind === "mutating-call" && stats?.hasIndexedWrite && !stats.hasCellRead && !stats.hasCellWrite) {
|
|
543
|
-
return false;
|
|
544
|
-
}
|
|
545
|
-
if (access.kind === "indexed-read" && stats?.hasMutatingCall && !stats.hasIndexedWrite && !stats.hasCellRead && !stats.hasCellWrite) {
|
|
546
|
-
return false;
|
|
547
|
-
}
|
|
548
|
-
return true;
|
|
549
|
-
});
|
|
550
|
-
if (filtered.length === step.accesses.length) {
|
|
551
|
-
return step;
|
|
552
|
-
}
|
|
553
|
-
return {
|
|
554
|
-
...step,
|
|
555
|
-
...filtered.length > 0 ? { accesses: filtered } : {},
|
|
556
|
-
...filtered.length === 0 ? { accesses: void 0 } : {}
|
|
557
|
-
};
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
function normalizeRuntimeTraceContract(language, result) {
|
|
561
|
-
const rawNormalizedTrace = collapseTraceAccessNoise(
|
|
562
|
-
Array.isArray(result.trace) ? result.trace.map(normalizeTraceStep) : []
|
|
563
|
-
);
|
|
564
|
-
const maxTraceSteps = typeof result.maxTraceSteps === "number" && Number.isFinite(result.maxTraceSteps) ? Math.max(1, Math.floor(result.maxTraceSteps)) : void 0;
|
|
565
|
-
const traceWasClipped = maxTraceSteps !== void 0 && rawNormalizedTrace.length > maxTraceSteps;
|
|
566
|
-
const normalizedTrace = traceWasClipped && maxTraceSteps !== void 0 ? rawNormalizedTrace.slice(0, maxTraceSteps) : rawNormalizedTrace;
|
|
567
|
-
const lineEventCount = typeof result.lineEventCount === "number" && Number.isFinite(result.lineEventCount) ? Math.floor(result.lineEventCount) : normalizedTrace.filter((step) => step.event === "line").length;
|
|
568
|
-
const normalizedConsole = Array.isArray(result.consoleOutput) ? result.consoleOutput.map((line) => String(line)) : [];
|
|
569
|
-
return {
|
|
570
|
-
schemaVersion: RUNTIME_TRACE_CONTRACT_SCHEMA_VERSION,
|
|
571
|
-
language,
|
|
572
|
-
success: Boolean(result.success),
|
|
573
|
-
...Object.prototype.hasOwnProperty.call(result, "output") ? { output: normalizeUnknown(result.output) } : {},
|
|
574
|
-
...typeof result.error === "string" && result.error.length > 0 ? { error: result.error } : {},
|
|
575
|
-
...typeof result.errorLine === "number" && Number.isFinite(result.errorLine) ? { errorLine: Math.floor(result.errorLine) } : {},
|
|
576
|
-
consoleOutput: normalizedConsole,
|
|
577
|
-
trace: normalizedTrace,
|
|
578
|
-
...result.traceLimitExceeded !== void 0 || traceWasClipped ? { traceLimitExceeded: Boolean(result.traceLimitExceeded) || traceWasClipped } : {},
|
|
579
|
-
...typeof result.timeoutReason === "string" && result.timeoutReason.length > 0 ? { timeoutReason: result.timeoutReason } : {},
|
|
580
|
-
lineEventCount: Math.max(0, lineEventCount),
|
|
581
|
-
traceStepCount: normalizedTrace.length
|
|
582
|
-
};
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
// packages/harness-core/src/trace-adapters/shared.ts
|
|
586
|
-
function denormalizeCallStackFrame(frame) {
|
|
587
|
-
return {
|
|
588
|
-
function: frame.function,
|
|
589
|
-
line: frame.line,
|
|
590
|
-
args: frame.args
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
function denormalizeTraceStep(step) {
|
|
594
|
-
return {
|
|
595
|
-
line: step.line,
|
|
596
|
-
event: step.event,
|
|
597
|
-
variables: step.variables,
|
|
598
|
-
function: step.function,
|
|
599
|
-
...step.callStack ? { callStack: step.callStack.map(denormalizeCallStackFrame) } : {},
|
|
600
|
-
...step.accesses ? { accesses: step.accesses } : {},
|
|
601
|
-
...step.returnValue !== void 0 ? { returnValue: step.returnValue } : {},
|
|
602
|
-
...step.stdoutLineCount !== void 0 ? { stdoutLineCount: step.stdoutLineCount } : {},
|
|
603
|
-
...step.visualization ? { visualization: step.visualization } : {}
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
function adaptTraceExecutionResult(language, result) {
|
|
607
|
-
const normalized = normalizeRuntimeTraceContract(language, result);
|
|
608
|
-
const adaptedTrace = normalized.trace.map(denormalizeTraceStep);
|
|
609
|
-
return {
|
|
610
|
-
success: normalized.success,
|
|
611
|
-
...Object.prototype.hasOwnProperty.call(normalized, "output") ? { output: normalized.output } : {},
|
|
612
|
-
...normalized.error ? { error: normalized.error } : {},
|
|
613
|
-
...normalized.errorLine !== void 0 ? { errorLine: normalized.errorLine } : {},
|
|
614
|
-
trace: adaptedTrace,
|
|
615
|
-
executionTimeMs: typeof result.executionTimeMs === "number" && Number.isFinite(result.executionTimeMs) ? result.executionTimeMs : 0,
|
|
616
|
-
consoleOutput: normalized.consoleOutput,
|
|
617
|
-
...normalized.traceLimitExceeded !== void 0 ? { traceLimitExceeded: normalized.traceLimitExceeded } : {},
|
|
618
|
-
...normalized.timeoutReason ? { timeoutReason: normalized.timeoutReason } : {},
|
|
619
|
-
lineEventCount: normalized.lineEventCount,
|
|
620
|
-
traceStepCount: adaptedTrace.length
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// packages/harness-core/src/trace-adapters/javascript.ts
|
|
625
|
-
function adaptJavaScriptTraceExecutionResult(language, result) {
|
|
626
|
-
return adaptTraceExecutionResult(language, result);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
689
|
// packages/harness-browser/src/runtime-capability-guards.ts
|
|
630
690
|
function isScriptRequest(functionName) {
|
|
631
691
|
if (functionName == null) return true;
|
|
@@ -718,12 +778,6 @@ var PYTHON_RUNTIME_PROFILE = {
|
|
|
718
778
|
setSerialization: true,
|
|
719
779
|
graphSerialization: true,
|
|
720
780
|
cycleReferences: true
|
|
721
|
-
},
|
|
722
|
-
visualization: {
|
|
723
|
-
runtimePayloads: true,
|
|
724
|
-
objectKinds: true,
|
|
725
|
-
hashMaps: true,
|
|
726
|
-
stepVisualization: true
|
|
727
781
|
}
|
|
728
782
|
}
|
|
729
783
|
};
|
|
@@ -780,12 +834,6 @@ var JAVASCRIPT_RUNTIME_PROFILE = {
|
|
|
780
834
|
setSerialization: true,
|
|
781
835
|
graphSerialization: true,
|
|
782
836
|
cycleReferences: true
|
|
783
|
-
},
|
|
784
|
-
visualization: {
|
|
785
|
-
runtimePayloads: true,
|
|
786
|
-
objectKinds: true,
|
|
787
|
-
hashMaps: true,
|
|
788
|
-
stepVisualization: true
|
|
789
837
|
}
|
|
790
838
|
}
|
|
791
839
|
};
|
|
@@ -842,12 +890,6 @@ var TYPESCRIPT_RUNTIME_PROFILE = {
|
|
|
842
890
|
setSerialization: true,
|
|
843
891
|
graphSerialization: true,
|
|
844
892
|
cycleReferences: true
|
|
845
|
-
},
|
|
846
|
-
visualization: {
|
|
847
|
-
runtimePayloads: true,
|
|
848
|
-
objectKinds: true,
|
|
849
|
-
hashMaps: true,
|
|
850
|
-
stepVisualization: true
|
|
851
893
|
}
|
|
852
894
|
}
|
|
853
895
|
};
|
|
@@ -904,12 +946,6 @@ var JAVA_RUNTIME_PROFILE = {
|
|
|
904
946
|
setSerialization: true,
|
|
905
947
|
graphSerialization: false,
|
|
906
948
|
cycleReferences: true
|
|
907
|
-
},
|
|
908
|
-
visualization: {
|
|
909
|
-
runtimePayloads: true,
|
|
910
|
-
objectKinds: true,
|
|
911
|
-
hashMaps: true,
|
|
912
|
-
stepVisualization: true
|
|
913
949
|
}
|
|
914
950
|
},
|
|
915
951
|
notes: [
|
|
@@ -918,37 +954,168 @@ var JAVA_RUNTIME_PROFILE = {
|
|
|
918
954
|
'Script-style Java uses an empty function name with executionStyle="function" and reads the top-level result variable.'
|
|
919
955
|
]
|
|
920
956
|
};
|
|
921
|
-
var
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
957
|
+
var CSHARP_RUNTIME_PROFILE = {
|
|
958
|
+
language: "csharp",
|
|
959
|
+
maturity: "experimental",
|
|
960
|
+
capabilities: {
|
|
961
|
+
execution: {
|
|
962
|
+
styles: {
|
|
963
|
+
function: true,
|
|
964
|
+
solutionMethod: true,
|
|
965
|
+
opsClass: true,
|
|
966
|
+
script: true,
|
|
967
|
+
interviewMode: true
|
|
968
|
+
},
|
|
969
|
+
timeouts: {
|
|
970
|
+
clientTimeouts: true,
|
|
971
|
+
runtimeTimeouts: true
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
tracing: {
|
|
975
|
+
supported: true,
|
|
976
|
+
events: {
|
|
977
|
+
line: true,
|
|
978
|
+
call: true,
|
|
979
|
+
return: true,
|
|
980
|
+
exception: true,
|
|
981
|
+
stdout: true,
|
|
982
|
+
timeout: true
|
|
983
|
+
},
|
|
984
|
+
controls: {
|
|
985
|
+
maxTraceSteps: true,
|
|
986
|
+
maxLineEvents: true,
|
|
987
|
+
maxSingleLineHits: true,
|
|
988
|
+
maxStoredEvents: true,
|
|
989
|
+
minimalTrace: true
|
|
990
|
+
},
|
|
991
|
+
fidelity: {
|
|
992
|
+
preciseLineMapping: true,
|
|
993
|
+
stableFunctionNames: true,
|
|
994
|
+
callStack: true
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
diagnostics: {
|
|
998
|
+
compileErrors: true,
|
|
999
|
+
runtimeErrors: true,
|
|
1000
|
+
mappedErrorLines: true,
|
|
1001
|
+
stackTraces: false
|
|
1002
|
+
},
|
|
1003
|
+
structures: {
|
|
1004
|
+
treeNodeRefs: true,
|
|
1005
|
+
listNodeRefs: true,
|
|
1006
|
+
mapSerialization: true,
|
|
1007
|
+
setSerialization: true,
|
|
1008
|
+
graphSerialization: true,
|
|
1009
|
+
cycleReferences: true
|
|
1010
|
+
}
|
|
1011
|
+
},
|
|
1012
|
+
notes: [
|
|
1013
|
+
"C# support is browser-local and experimental.",
|
|
1014
|
+
"C# supports named function-style requests where the browser-local host can bind the named method.",
|
|
1015
|
+
'Script-style C# uses an empty function name with executionStyle="function" and reads the top-level result variable.',
|
|
1016
|
+
"Interview-mode C# uses the same browser-local worker execution path with interview timeout normalization.",
|
|
1017
|
+
"The first C# slice supports public class Solution methods.",
|
|
1018
|
+
"ListNode and TreeNode inputs are hydrated from level-order arrays or object-shaped JSON.",
|
|
1019
|
+
"Dictionary, HashSet, List, and array return values serialize through the browser-local worker.",
|
|
1020
|
+
"Tracing currently supports line, call, return, stdout, and simple local variable write events.",
|
|
1021
|
+
"Structural visualization is added after execution and diagnostics are proven."
|
|
1022
|
+
]
|
|
926
1023
|
};
|
|
927
|
-
var
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1024
|
+
var CPP_RUNTIME_PROFILE = {
|
|
1025
|
+
language: "cpp",
|
|
1026
|
+
maturity: "experimental",
|
|
1027
|
+
capabilities: {
|
|
1028
|
+
execution: {
|
|
1029
|
+
styles: {
|
|
1030
|
+
function: true,
|
|
1031
|
+
solutionMethod: true,
|
|
1032
|
+
opsClass: true,
|
|
1033
|
+
script: true,
|
|
1034
|
+
interviewMode: true
|
|
1035
|
+
},
|
|
1036
|
+
timeouts: {
|
|
1037
|
+
clientTimeouts: true,
|
|
1038
|
+
runtimeTimeouts: true
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
tracing: {
|
|
1042
|
+
supported: true,
|
|
1043
|
+
events: {
|
|
1044
|
+
line: true,
|
|
1045
|
+
call: true,
|
|
1046
|
+
return: true,
|
|
1047
|
+
exception: true,
|
|
1048
|
+
stdout: true,
|
|
1049
|
+
timeout: true
|
|
1050
|
+
},
|
|
1051
|
+
controls: {
|
|
1052
|
+
maxTraceSteps: true,
|
|
1053
|
+
maxLineEvents: true,
|
|
1054
|
+
maxSingleLineHits: true,
|
|
1055
|
+
maxStoredEvents: true,
|
|
1056
|
+
minimalTrace: true
|
|
1057
|
+
},
|
|
1058
|
+
fidelity: {
|
|
1059
|
+
preciseLineMapping: true,
|
|
1060
|
+
stableFunctionNames: true,
|
|
1061
|
+
callStack: true
|
|
1062
|
+
}
|
|
1063
|
+
},
|
|
1064
|
+
diagnostics: {
|
|
1065
|
+
compileErrors: true,
|
|
1066
|
+
runtimeErrors: true,
|
|
1067
|
+
mappedErrorLines: true,
|
|
1068
|
+
stackTraces: false
|
|
1069
|
+
},
|
|
1070
|
+
structures: {
|
|
1071
|
+
treeNodeRefs: true,
|
|
1072
|
+
listNodeRefs: true,
|
|
1073
|
+
mapSerialization: true,
|
|
1074
|
+
setSerialization: true,
|
|
1075
|
+
graphSerialization: true,
|
|
1076
|
+
cycleReferences: true
|
|
1077
|
+
}
|
|
1078
|
+
},
|
|
1079
|
+
notes: [
|
|
1080
|
+
"C++ uses a focused browser-local Clang/LLD/WASI compiler lane with TraceCode-owned execution glue.",
|
|
1081
|
+
"The runtime intentionally does not depend on a generic multi-language container/runtime SDK.",
|
|
1082
|
+
'Script-style C++ uses an empty function name with executionStyle="function"; the snippet must assign a serializable result variable.',
|
|
1083
|
+
"Interview-mode C++ reuses the tracing compiler path with a trace budget and returns a non-trace execution result."
|
|
1084
|
+
]
|
|
1085
|
+
};
|
|
1086
|
+
var LANGUAGE_RUNTIME_PROFILES = {
|
|
1087
|
+
python: PYTHON_RUNTIME_PROFILE,
|
|
1088
|
+
javascript: JAVASCRIPT_RUNTIME_PROFILE,
|
|
1089
|
+
typescript: TYPESCRIPT_RUNTIME_PROFILE,
|
|
1090
|
+
java: JAVA_RUNTIME_PROFILE,
|
|
1091
|
+
csharp: CSHARP_RUNTIME_PROFILE,
|
|
1092
|
+
cpp: CPP_RUNTIME_PROFILE
|
|
1093
|
+
};
|
|
1094
|
+
var SUPPORTED_LANGUAGES = Object.freeze(
|
|
1095
|
+
Object.keys(LANGUAGE_RUNTIME_PROFILES)
|
|
1096
|
+
);
|
|
1097
|
+
function getLanguageRuntimeProfile(language) {
|
|
1098
|
+
const profile = LANGUAGE_RUNTIME_PROFILES[language];
|
|
1099
|
+
if (!profile) {
|
|
1100
|
+
throw new Error(`Runtime profile for language "${language}" is not implemented yet.`);
|
|
1101
|
+
}
|
|
1102
|
+
return profile;
|
|
1103
|
+
}
|
|
1104
|
+
function getSupportedLanguageProfiles() {
|
|
1105
|
+
return SUPPORTED_LANGUAGES.map((language) => LANGUAGE_RUNTIME_PROFILES[language]);
|
|
1106
|
+
}
|
|
1107
|
+
function isLanguageSupported(language) {
|
|
1108
|
+
return SUPPORTED_LANGUAGES.includes(language);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// packages/harness-browser/src/javascript-runtime-client.ts
|
|
1112
|
+
var JavaScriptRuntimeClient = class {
|
|
1113
|
+
constructor(runtimeLanguage, workerClient) {
|
|
1114
|
+
this.runtimeLanguage = runtimeLanguage;
|
|
1115
|
+
this.workerClient = workerClient;
|
|
1116
|
+
}
|
|
1117
|
+
async init() {
|
|
1118
|
+
return this.workerClient.init();
|
|
952
1119
|
}
|
|
953
1120
|
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
|
|
954
1121
|
assertRuntimeRequestSupported(getLanguageRuntimeProfile(this.runtimeLanguage), {
|
|
@@ -956,7 +1123,7 @@ var JavaScriptRuntimeClient = class {
|
|
|
956
1123
|
executionStyle,
|
|
957
1124
|
functionName
|
|
958
1125
|
});
|
|
959
|
-
|
|
1126
|
+
return this.workerClient.executeWithTracing(
|
|
960
1127
|
code,
|
|
961
1128
|
functionName,
|
|
962
1129
|
inputs,
|
|
@@ -964,7 +1131,6 @@ var JavaScriptRuntimeClient = class {
|
|
|
964
1131
|
executionStyle,
|
|
965
1132
|
this.runtimeLanguage
|
|
966
1133
|
);
|
|
967
|
-
return adaptJavaScriptTraceExecutionResult(this.runtimeLanguage, rawResult);
|
|
968
1134
|
}
|
|
969
1135
|
async executeCode(code, functionName, inputs, executionStyle = "function") {
|
|
970
1136
|
assertRuntimeRequestSupported(getLanguageRuntimeProfile(this.runtimeLanguage), {
|
|
@@ -999,11 +1165,364 @@ function createJavaScriptRuntimeClient(runtimeLanguage, workerClient) {
|
|
|
999
1165
|
return new JavaScriptRuntimeClient(runtimeLanguage, workerClient);
|
|
1000
1166
|
}
|
|
1001
1167
|
|
|
1168
|
+
// packages/harness-core/src/runtime-trace.ts
|
|
1169
|
+
var RUNTIME_TRACE_SCHEMA_VERSION = "runtime-trace-2026-04-28";
|
|
1170
|
+
function createEmptyRuntimeTrace(language, options = {}) {
|
|
1171
|
+
return {
|
|
1172
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1173
|
+
language,
|
|
1174
|
+
runId: options.runId ?? `${language}:run`,
|
|
1175
|
+
events: [],
|
|
1176
|
+
lineEventCount: 0,
|
|
1177
|
+
traceStepCount: 0
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
// packages/harness-core/src/runtime-raw-emission-contract.ts
|
|
1182
|
+
function sortedUnique(values) {
|
|
1183
|
+
return [...new Set(values)].sort((left, right) => left.localeCompare(right));
|
|
1184
|
+
}
|
|
1185
|
+
var FORBIDDEN_RUNTIME_TRACE_TOKENS = [
|
|
1186
|
+
"visualization",
|
|
1187
|
+
"objectKinds",
|
|
1188
|
+
"hashMaps",
|
|
1189
|
+
"graph-adjacency",
|
|
1190
|
+
"linked-list",
|
|
1191
|
+
"tree"
|
|
1192
|
+
];
|
|
1193
|
+
var FORBIDDEN_RUNTIME_TRACE_KEYS = /* @__PURE__ */ new Set([
|
|
1194
|
+
"visualization",
|
|
1195
|
+
"objectKinds",
|
|
1196
|
+
"hashMaps",
|
|
1197
|
+
"graph-adjacency",
|
|
1198
|
+
"linked-list"
|
|
1199
|
+
]);
|
|
1200
|
+
function normalizeJavaNativeTraceJsonPayload(payload) {
|
|
1201
|
+
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"');
|
|
1202
|
+
}
|
|
1203
|
+
function forbiddenRuntimeTraceTokens(value) {
|
|
1204
|
+
const tokens = /* @__PURE__ */ new Set();
|
|
1205
|
+
collectForbiddenRuntimeTraceTokens(value, tokens, null, false);
|
|
1206
|
+
return FORBIDDEN_RUNTIME_TRACE_TOKENS.filter((token) => tokens.has(token));
|
|
1207
|
+
}
|
|
1208
|
+
function collectForbiddenRuntimeTraceTokens(value, tokens, parentKey, semanticPayload) {
|
|
1209
|
+
if (typeof value === "string") {
|
|
1210
|
+
if ((semanticPayload || parentKey === "kind" || parentKey === "type" || parentKey === "category") && FORBIDDEN_RUNTIME_TRACE_TOKENS.includes(value)) {
|
|
1211
|
+
tokens.add(value);
|
|
1212
|
+
}
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
if (value === null || typeof value !== "object") return;
|
|
1216
|
+
if (Array.isArray(value)) {
|
|
1217
|
+
for (const item of value) collectForbiddenRuntimeTraceTokens(item, tokens, parentKey, semanticPayload);
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
const entries = Object.entries(value);
|
|
1221
|
+
const objectSemanticPayload = entries.some(([key, child]) => {
|
|
1222
|
+
if (parentKey !== "args" && FORBIDDEN_RUNTIME_TRACE_KEYS.has(key)) return true;
|
|
1223
|
+
return (key === "kind" || key === "type" || key === "category") && typeof child === "string" && FORBIDDEN_RUNTIME_TRACE_TOKENS.includes(child);
|
|
1224
|
+
});
|
|
1225
|
+
for (const [key, child] of entries) {
|
|
1226
|
+
if (parentKey !== "args" && FORBIDDEN_RUNTIME_TRACE_KEYS.has(key)) {
|
|
1227
|
+
tokens.add(key);
|
|
1228
|
+
}
|
|
1229
|
+
if (key === "target" || key === "variable" || key === "function") continue;
|
|
1230
|
+
collectForbiddenRuntimeTraceTokens(child, tokens, key, semanticPayload || objectSemanticPayload);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
function unsupportedForbiddenPayload(label, value) {
|
|
1234
|
+
const tokens = forbiddenRuntimeTraceTokens(value);
|
|
1235
|
+
if (tokens.length === 0) return null;
|
|
1236
|
+
return `${label} contains forbidden runtime trace token(s): ${tokens.join(", ")}`;
|
|
1237
|
+
}
|
|
1238
|
+
function javaNativeTracePayloadKind(event) {
|
|
1239
|
+
if (!event.startsWith("trace:")) return null;
|
|
1240
|
+
try {
|
|
1241
|
+
const parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
|
|
1242
|
+
if (parsed.kind === "line") return "line";
|
|
1243
|
+
if (parsed.kind === "call") return "call";
|
|
1244
|
+
if (parsed.kind === "return") return "return";
|
|
1245
|
+
if (parsed.kind === "exception") return "exception";
|
|
1246
|
+
if (parsed.kind === "timeout") return "timeout";
|
|
1247
|
+
if (parsed.kind === "stdout") return "stdout";
|
|
1248
|
+
if (parsed.kind === "snapshot") return "snapshot";
|
|
1249
|
+
if (parsed.kind === "read") return "read";
|
|
1250
|
+
if (parsed.kind === "write") return "write";
|
|
1251
|
+
if (parsed.kind === "mutate") return "mutate";
|
|
1252
|
+
} catch {
|
|
1253
|
+
return null;
|
|
1254
|
+
}
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1257
|
+
function summarizeJavaRawEmissions(events) {
|
|
1258
|
+
const kinds = [];
|
|
1259
|
+
const unsupported = [];
|
|
1260
|
+
for (const [index, event] of events.entries()) {
|
|
1261
|
+
if (event.startsWith("trace:")) {
|
|
1262
|
+
try {
|
|
1263
|
+
const parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
|
|
1264
|
+
const forbiddenPayload = unsupportedForbiddenPayload(`java trace event ${index}`, parsed);
|
|
1265
|
+
if (forbiddenPayload) {
|
|
1266
|
+
unsupported.push(forbiddenPayload);
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
} catch {
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
const nativeKind = javaNativeTracePayloadKind(event);
|
|
1273
|
+
if (nativeKind) {
|
|
1274
|
+
kinds.push(nativeKind);
|
|
1275
|
+
continue;
|
|
1276
|
+
}
|
|
1277
|
+
unsupported.push(event);
|
|
1278
|
+
}
|
|
1279
|
+
return {
|
|
1280
|
+
language: "java",
|
|
1281
|
+
kinds: sortedUnique(kinds),
|
|
1282
|
+
unsupported
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
function assertSupportedRawEmissions(summary, label) {
|
|
1286
|
+
if (summary.unsupported.length > 0) {
|
|
1287
|
+
throw new Error(
|
|
1288
|
+
`${label} emitted unsupported raw runtime payloads:
|
|
1289
|
+
${summary.unsupported.slice(0, 20).join("\n")}`
|
|
1290
|
+
);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// packages/harness-core/src/trace-adapters/java.ts
|
|
1295
|
+
function isNativeJavaTraceEvent(event) {
|
|
1296
|
+
return event.startsWith("trace:");
|
|
1297
|
+
}
|
|
1298
|
+
function stripInlineComments(line, inBlockComment) {
|
|
1299
|
+
let result = "";
|
|
1300
|
+
let index = 0;
|
|
1301
|
+
let inBlock = inBlockComment;
|
|
1302
|
+
while (index < line.length) {
|
|
1303
|
+
const current = line[index];
|
|
1304
|
+
const next = index + 1 < line.length ? line[index + 1] : "";
|
|
1305
|
+
if (inBlock) {
|
|
1306
|
+
if (current === "*" && next === "/") {
|
|
1307
|
+
inBlock = false;
|
|
1308
|
+
index += 2;
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
index += 1;
|
|
1312
|
+
continue;
|
|
1313
|
+
}
|
|
1314
|
+
if (current === "/" && next === "*") {
|
|
1315
|
+
inBlock = true;
|
|
1316
|
+
index += 2;
|
|
1317
|
+
continue;
|
|
1318
|
+
}
|
|
1319
|
+
if (current === "/" && next === "/") break;
|
|
1320
|
+
result += current;
|
|
1321
|
+
index += 1;
|
|
1322
|
+
}
|
|
1323
|
+
return { text: result, inBlockComment: inBlock };
|
|
1324
|
+
}
|
|
1325
|
+
function isMethodDeclarationLine(line) {
|
|
1326
|
+
const trimmed = line.trim();
|
|
1327
|
+
if (!trimmed) return false;
|
|
1328
|
+
if (trimmed.startsWith("@")) return false;
|
|
1329
|
+
if (!trimmed.includes("(") || !trimmed.includes(")")) return false;
|
|
1330
|
+
if (trimmed.endsWith(";")) return false;
|
|
1331
|
+
if (trimmed.includes("->")) return false;
|
|
1332
|
+
if (/^(?:if|for|while|switch|catch|do|try|else|return|throw|new)\b/.test(trimmed)) return false;
|
|
1333
|
+
if (!/[A-Za-z_][A-Za-z0-9_]*\s*\([^{};]*\)/.test(trimmed)) return false;
|
|
1334
|
+
return /(?:\{\s*)?$/.test(trimmed);
|
|
1335
|
+
}
|
|
1336
|
+
function buildLocalDeclarationNamesByLine(sourceText) {
|
|
1337
|
+
const namesByLine = /* @__PURE__ */ new Map();
|
|
1338
|
+
if (typeof sourceText !== "string" || sourceText.length === 0) return namesByLine;
|
|
1339
|
+
const lines = sourceText.split(/\r?\n/);
|
|
1340
|
+
let inBlockComment = false;
|
|
1341
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
1342
|
+
const { text, inBlockComment: nextInBlockComment } = stripInlineComments(lines[index] ?? "", inBlockComment);
|
|
1343
|
+
inBlockComment = nextInBlockComment;
|
|
1344
|
+
if (isMethodDeclarationLine(text)) continue;
|
|
1345
|
+
const names = [];
|
|
1346
|
+
const declarationPattern = /\b(?:final\s+)?(?:[A-Za-z_][A-Za-z0-9_.$]*(?:\s*<[^;=(){}]+>)?(?:\s*\[\])?)\s+([A-Za-z_][A-Za-z0-9_]*)\s*=/g;
|
|
1347
|
+
for (const match of text.matchAll(declarationPattern)) {
|
|
1348
|
+
if (match[1]) names.push(match[1]);
|
|
1349
|
+
}
|
|
1350
|
+
if (names.length > 0) namesByLine.set(index + 1, names);
|
|
1351
|
+
}
|
|
1352
|
+
return namesByLine;
|
|
1353
|
+
}
|
|
1354
|
+
function removeSameLineMutationDeclarationSnapshotEvents(events, sourceText) {
|
|
1355
|
+
const declarationNamesByLine = buildLocalDeclarationNamesByLine(sourceText);
|
|
1356
|
+
if (declarationNamesByLine.size === 0) return events;
|
|
1357
|
+
const mutationVariablesByLine = /* @__PURE__ */ new Map();
|
|
1358
|
+
for (const event of events) {
|
|
1359
|
+
if (event.kind !== "mutate" || typeof event.line !== "number" || !("variable" in event.target)) continue;
|
|
1360
|
+
const variables = mutationVariablesByLine.get(event.line) ?? /* @__PURE__ */ new Set();
|
|
1361
|
+
variables.add(event.target.variable);
|
|
1362
|
+
mutationVariablesByLine.set(event.line, variables);
|
|
1363
|
+
}
|
|
1364
|
+
if (mutationVariablesByLine.size === 0) return events;
|
|
1365
|
+
return events.filter((event) => {
|
|
1366
|
+
if (event.kind !== "snapshot" || typeof event.line !== "number" || !("variable" in event.target)) return true;
|
|
1367
|
+
const declaredNames = declarationNamesByLine.get(event.line);
|
|
1368
|
+
if (!declaredNames?.includes(event.target.variable)) return true;
|
|
1369
|
+
const mutationVariables = mutationVariablesByLine.get(event.line);
|
|
1370
|
+
return mutationVariables?.has(event.target.variable) === true;
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
function collectJavaLineDeclarationsForHeaderExpansion(line) {
|
|
1374
|
+
const names = [];
|
|
1375
|
+
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;
|
|
1376
|
+
const skippedNames = /* @__PURE__ */ new Set(["class", "interface", "enum", "record", "return", "new"]);
|
|
1377
|
+
for (const match of line.matchAll(declarationPattern)) {
|
|
1378
|
+
const typeSource = match[1] ?? "";
|
|
1379
|
+
const name = match[2];
|
|
1380
|
+
if (!name || skippedNames.has(name) || name.startsWith("__tracecode")) continue;
|
|
1381
|
+
if (typeSource.includes("[")) continue;
|
|
1382
|
+
names.push(name);
|
|
1383
|
+
}
|
|
1384
|
+
return names;
|
|
1385
|
+
}
|
|
1386
|
+
function collectJavaControlHeaderDeclarations(line) {
|
|
1387
|
+
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);
|
|
1388
|
+
return forMatch?.[1] ? [forMatch[1]] : [];
|
|
1389
|
+
}
|
|
1390
|
+
function buildJavaControlHeaderInfo(sourceText) {
|
|
1391
|
+
if (typeof sourceText !== "string" || sourceText.length === 0) return null;
|
|
1392
|
+
const lines = sourceText.split(/\r?\n/);
|
|
1393
|
+
const loopBodyLineToHeader = /* @__PURE__ */ new Map();
|
|
1394
|
+
const headerLineToExcludedVariables = /* @__PURE__ */ new Map();
|
|
1395
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
1396
|
+
const line = lines[index] ?? "";
|
|
1397
|
+
const isLoopHeader = /\b(?:for|while)\s*\(/.test(line);
|
|
1398
|
+
const isControlHeader = /\b(?:for|while|if|else\s+if)\s*\(/.test(line);
|
|
1399
|
+
if (!isControlHeader || !line.includes("{")) continue;
|
|
1400
|
+
for (let bodyIndex = index + 1; bodyIndex < lines.length; bodyIndex += 1) {
|
|
1401
|
+
const trimmed = (lines[bodyIndex] ?? "").trim();
|
|
1402
|
+
if (trimmed.length === 0) continue;
|
|
1403
|
+
if (trimmed.startsWith("}")) break;
|
|
1404
|
+
const headerInfo = {
|
|
1405
|
+
line: index + 1,
|
|
1406
|
+
excludedVariables: new Set(collectJavaLineDeclarationsForHeaderExpansion(lines[bodyIndex] ?? "")),
|
|
1407
|
+
headerVariables: new Set(collectJavaControlHeaderDeclarations(line))
|
|
1408
|
+
};
|
|
1409
|
+
if (isLoopHeader) loopBodyLineToHeader.set(bodyIndex + 1, headerInfo);
|
|
1410
|
+
headerLineToExcludedVariables.set(index + 1, headerInfo.excludedVariables);
|
|
1411
|
+
break;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
if (loopBodyLineToHeader.size === 0 && headerLineToExcludedVariables.size === 0) return null;
|
|
1415
|
+
return { loopBodyLineToHeader, headerLineToExcludedVariables };
|
|
1416
|
+
}
|
|
1417
|
+
function eventLine(event) {
|
|
1418
|
+
return typeof event.line === "number" && Number.isFinite(event.line) && event.line > 0 ? event.line : null;
|
|
1419
|
+
}
|
|
1420
|
+
function eventSnapshotVariable(event) {
|
|
1421
|
+
if (event.kind !== "snapshot") return null;
|
|
1422
|
+
const target = event.target;
|
|
1423
|
+
if (!target || typeof target !== "object" || !("variable" in target)) return null;
|
|
1424
|
+
const variable = target.variable;
|
|
1425
|
+
return typeof variable === "string" && variable.length > 0 ? variable : null;
|
|
1426
|
+
}
|
|
1427
|
+
function cloneRuntimeEventAtLine(event, line) {
|
|
1428
|
+
return { ...event, line };
|
|
1429
|
+
}
|
|
1430
|
+
function expandJavaLoopHeaderTraceEvents(events, sourceText) {
|
|
1431
|
+
if (events.length === 0) return events;
|
|
1432
|
+
const controlHeaderInfo = buildJavaControlHeaderInfo(sourceText);
|
|
1433
|
+
if (!controlHeaderInfo) return events;
|
|
1434
|
+
const { loopBodyLineToHeader, headerLineToExcludedVariables } = controlHeaderInfo;
|
|
1435
|
+
const expanded = [];
|
|
1436
|
+
const latestSnapshotByVariable = /* @__PURE__ */ new Map();
|
|
1437
|
+
let lastLineEventLine = null;
|
|
1438
|
+
for (let index = 0; index < events.length; index += 1) {
|
|
1439
|
+
const event = events[index];
|
|
1440
|
+
const line = eventLine(event);
|
|
1441
|
+
const snapshotVariable = eventSnapshotVariable(event);
|
|
1442
|
+
if (line !== null && snapshotVariable && headerLineToExcludedVariables.get(line)?.has(snapshotVariable)) {
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
const headerInfo = line === null ? void 0 : loopBodyLineToHeader.get(line);
|
|
1446
|
+
const headerLine = headerInfo?.line;
|
|
1447
|
+
if (headerInfo && typeof headerLine === "number" && event.kind === "line" && lastLineEventLine !== headerLine) {
|
|
1448
|
+
expanded.push(cloneRuntimeEventAtLine(event, headerLine));
|
|
1449
|
+
for (const [variable, snapshotEvent] of latestSnapshotByVariable) {
|
|
1450
|
+
if (headerInfo.excludedVariables.has(variable)) continue;
|
|
1451
|
+
expanded.push(cloneRuntimeEventAtLine(snapshotEvent, headerLine));
|
|
1452
|
+
}
|
|
1453
|
+
lastLineEventLine = headerLine;
|
|
1454
|
+
}
|
|
1455
|
+
if (headerInfo && typeof headerLine === "number" && event.kind === "line") {
|
|
1456
|
+
for (let lookahead = index + 1; lookahead < events.length; lookahead += 1) {
|
|
1457
|
+
if (eventLine(events[lookahead]) !== line) break;
|
|
1458
|
+
const variable = eventSnapshotVariable(events[lookahead]);
|
|
1459
|
+
if (!variable || !headerInfo.headerVariables.has(variable)) continue;
|
|
1460
|
+
expanded.push(cloneRuntimeEventAtLine(events[lookahead], headerLine));
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
expanded.push(event);
|
|
1464
|
+
if (event.kind === "line") {
|
|
1465
|
+
lastLineEventLine = line;
|
|
1466
|
+
}
|
|
1467
|
+
if (snapshotVariable) {
|
|
1468
|
+
latestSnapshotByVariable.set(snapshotVariable, event);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
return expanded;
|
|
1472
|
+
}
|
|
1473
|
+
function nativeJavaTraceEventsToTrace(events, sourceText, options = {}) {
|
|
1474
|
+
const runId = options.runId ?? "java:run";
|
|
1475
|
+
let parsedEvents = events.map((event) => {
|
|
1476
|
+
let parsed;
|
|
1477
|
+
try {
|
|
1478
|
+
parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
|
|
1479
|
+
} catch (error) {
|
|
1480
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1481
|
+
throw new Error(`Invalid Java native runtime trace event: ${message}
|
|
1482
|
+
${event.slice(0, 500)}`);
|
|
1483
|
+
}
|
|
1484
|
+
return {
|
|
1485
|
+
...parsed,
|
|
1486
|
+
runId,
|
|
1487
|
+
...options.file ? { file: options.file } : {}
|
|
1488
|
+
};
|
|
1489
|
+
});
|
|
1490
|
+
parsedEvents = removeSameLineMutationDeclarationSnapshotEvents(parsedEvents, sourceText);
|
|
1491
|
+
parsedEvents = expandJavaLoopHeaderTraceEvents(parsedEvents, sourceText);
|
|
1492
|
+
return {
|
|
1493
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1494
|
+
language: "java",
|
|
1495
|
+
runId,
|
|
1496
|
+
events: parsedEvents,
|
|
1497
|
+
lineEventCount: parsedEvents.filter((event) => event.kind === "line").length,
|
|
1498
|
+
traceStepCount: parsedEvents.length
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
function javaTraceHooksEventsToRuntimeTrace(events, sourceText, options = {}) {
|
|
1502
|
+
assertSupportedRawEmissions(summarizeJavaRawEmissions(events), "java");
|
|
1503
|
+
if (events.length === 0) {
|
|
1504
|
+
return {
|
|
1505
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1506
|
+
language: "java",
|
|
1507
|
+
runId: options.runId ?? "java:run",
|
|
1508
|
+
events: [],
|
|
1509
|
+
lineEventCount: 0,
|
|
1510
|
+
traceStepCount: 0
|
|
1511
|
+
};
|
|
1512
|
+
}
|
|
1513
|
+
if (!events.every(isNativeJavaTraceEvent)) {
|
|
1514
|
+
throw new Error("Java TraceHooks must emit native runtime trace events. Unsupported line=... events are no longer supported.");
|
|
1515
|
+
}
|
|
1516
|
+
return nativeJavaTraceEventsToTrace(events, sourceText, options);
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1002
1519
|
// packages/harness-browser/src/java-worker-client.ts
|
|
1520
|
+
var EXECUTION_TIMEOUT_MS2 = 2e4;
|
|
1003
1521
|
var TRACING_TIMEOUT_MS2 = 25e3;
|
|
1004
|
-
var INIT_TIMEOUT_MS2 =
|
|
1522
|
+
var INIT_TIMEOUT_MS2 = 12e4;
|
|
1005
1523
|
var MESSAGE_TIMEOUT_MS2 = 3e4;
|
|
1006
1524
|
var WORKER_READY_TIMEOUT_MS2 = 1e4;
|
|
1525
|
+
var JAVA_DEFAULT_FILE = "solution.java";
|
|
1007
1526
|
var JavaWorkerClient = class {
|
|
1008
1527
|
constructor(options) {
|
|
1009
1528
|
this.options = options;
|
|
@@ -1014,6 +1533,7 @@ var JavaWorkerClient = class {
|
|
|
1014
1533
|
messageId = 0;
|
|
1015
1534
|
isInitializing = false;
|
|
1016
1535
|
initPromise = null;
|
|
1536
|
+
warmupPromise = null;
|
|
1017
1537
|
workerReadyPromise = null;
|
|
1018
1538
|
workerReadyResolve = null;
|
|
1019
1539
|
workerReadyReject = null;
|
|
@@ -1038,6 +1558,22 @@ var JavaWorkerClient = class {
|
|
|
1038
1558
|
this.workerReadyResolve?.();
|
|
1039
1559
|
this.workerReadyResolve = null;
|
|
1040
1560
|
this.workerReadyReject = null;
|
|
1561
|
+
logRuntimeDiagnostic("info", {
|
|
1562
|
+
component: "JavaWorkerClient",
|
|
1563
|
+
runtime: "java",
|
|
1564
|
+
phase: "worker-ready",
|
|
1565
|
+
message: "Java worker is ready."
|
|
1566
|
+
}, { enabled: this.debug });
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
if (type === "idle-timeout") {
|
|
1570
|
+
logRuntimeDiagnostic("info", {
|
|
1571
|
+
component: "JavaWorkerClient",
|
|
1572
|
+
runtime: "java",
|
|
1573
|
+
phase: "idle-timeout",
|
|
1574
|
+
message: "Java worker closed after idle timeout."
|
|
1575
|
+
}, { enabled: this.debug });
|
|
1576
|
+
this.terminateAndReset(new Error("Java worker closed after idle timeout"));
|
|
1041
1577
|
return;
|
|
1042
1578
|
}
|
|
1043
1579
|
if (!id) return;
|
|
@@ -1052,6 +1588,18 @@ var JavaWorkerClient = class {
|
|
|
1052
1588
|
pending.resolve(payload);
|
|
1053
1589
|
};
|
|
1054
1590
|
this.worker.onerror = (error) => {
|
|
1591
|
+
logRuntimeDiagnostic("error", {
|
|
1592
|
+
component: "JavaWorkerClient",
|
|
1593
|
+
runtime: "java",
|
|
1594
|
+
phase: "worker-error",
|
|
1595
|
+
message: "Java worker emitted an error event.",
|
|
1596
|
+
detail: {
|
|
1597
|
+
message: error.message,
|
|
1598
|
+
filename: error.filename,
|
|
1599
|
+
lineno: error.lineno,
|
|
1600
|
+
colno: error.colno
|
|
1601
|
+
}
|
|
1602
|
+
});
|
|
1055
1603
|
const workerError = new Error(error.message || "Java worker error");
|
|
1056
1604
|
this.workerReadyReject?.(workerError);
|
|
1057
1605
|
this.workerReadyResolve = null;
|
|
@@ -1076,6 +1624,13 @@ var JavaWorkerClient = class {
|
|
|
1076
1624
|
const timeoutError = new Error(
|
|
1077
1625
|
`Java worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS2 / 1e3)}s)`
|
|
1078
1626
|
);
|
|
1627
|
+
logRuntimeDiagnostic("warn", {
|
|
1628
|
+
component: "JavaWorkerClient",
|
|
1629
|
+
runtime: "java",
|
|
1630
|
+
phase: "worker-ready-timeout",
|
|
1631
|
+
message: "Java worker did not send worker-ready before the timeout.",
|
|
1632
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS2 }
|
|
1633
|
+
}, { enabled: this.debug });
|
|
1079
1634
|
this.terminateAndReset(timeoutError);
|
|
1080
1635
|
reject(timeoutError);
|
|
1081
1636
|
}, WORKER_READY_TIMEOUT_MS2);
|
|
@@ -1105,6 +1660,13 @@ var JavaWorkerClient = class {
|
|
|
1105
1660
|
const pending2 = this.pendingMessages.get(id);
|
|
1106
1661
|
if (!pending2) return;
|
|
1107
1662
|
this.pendingMessages.delete(id);
|
|
1663
|
+
logRuntimeDiagnostic("warn", {
|
|
1664
|
+
component: "JavaWorkerClient",
|
|
1665
|
+
runtime: "java",
|
|
1666
|
+
phase: "worker-request-timeout",
|
|
1667
|
+
message: "Java worker request timed out.",
|
|
1668
|
+
detail: { id, type, timeoutMs }
|
|
1669
|
+
}, { enabled: this.debug });
|
|
1108
1670
|
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
1109
1671
|
}, timeoutMs);
|
|
1110
1672
|
const pending = this.pendingMessages.get(id);
|
|
@@ -1118,6 +1680,13 @@ var JavaWorkerClient = class {
|
|
|
1118
1680
|
const timeoutId = globalThis.setTimeout(() => {
|
|
1119
1681
|
if (settled) return;
|
|
1120
1682
|
settled = true;
|
|
1683
|
+
logRuntimeDiagnostic("warn", {
|
|
1684
|
+
component: "JavaWorkerClient",
|
|
1685
|
+
runtime: "java",
|
|
1686
|
+
phase: "execution-timeout",
|
|
1687
|
+
message: "Java execution timed out; terminating worker.",
|
|
1688
|
+
detail: { timeoutMs }
|
|
1689
|
+
}, { enabled: this.debug });
|
|
1121
1690
|
this.terminateAndReset();
|
|
1122
1691
|
reject(
|
|
1123
1692
|
new Error(
|
|
@@ -1145,6 +1714,7 @@ var JavaWorkerClient = class {
|
|
|
1145
1714
|
this.worker = null;
|
|
1146
1715
|
}
|
|
1147
1716
|
this.initPromise = null;
|
|
1717
|
+
this.warmupPromise = null;
|
|
1148
1718
|
this.isInitializing = false;
|
|
1149
1719
|
this.workerReadyPromise = null;
|
|
1150
1720
|
this.workerReadyResolve = null;
|
|
@@ -1162,7 +1732,26 @@ var JavaWorkerClient = class {
|
|
|
1162
1732
|
return this.init();
|
|
1163
1733
|
}
|
|
1164
1734
|
this.isInitializing = true;
|
|
1165
|
-
this.initPromise =
|
|
1735
|
+
this.initPromise = (async () => {
|
|
1736
|
+
try {
|
|
1737
|
+
return await this.sendMessage("init", this.workerOptionsPayload(), INIT_TIMEOUT_MS2);
|
|
1738
|
+
} catch (error) {
|
|
1739
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1740
|
+
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");
|
|
1741
|
+
if (!shouldRetry) {
|
|
1742
|
+
throw error;
|
|
1743
|
+
}
|
|
1744
|
+
logRuntimeDiagnostic("warn", {
|
|
1745
|
+
component: "JavaWorkerClient",
|
|
1746
|
+
runtime: "java",
|
|
1747
|
+
phase: "init-retry",
|
|
1748
|
+
message: "Java worker init failed; resetting worker and retrying once.",
|
|
1749
|
+
detail: { message }
|
|
1750
|
+
}, { enabled: this.debug });
|
|
1751
|
+
this.terminateAndReset(error instanceof Error ? error : new Error(message));
|
|
1752
|
+
return this.sendMessage("init", this.workerOptionsPayload(), INIT_TIMEOUT_MS2);
|
|
1753
|
+
}
|
|
1754
|
+
})();
|
|
1166
1755
|
try {
|
|
1167
1756
|
return await this.initPromise;
|
|
1168
1757
|
} catch (error) {
|
|
@@ -1172,9 +1761,29 @@ var JavaWorkerClient = class {
|
|
|
1172
1761
|
this.isInitializing = false;
|
|
1173
1762
|
}
|
|
1174
1763
|
}
|
|
1764
|
+
workerOptionsPayload() {
|
|
1765
|
+
return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
|
|
1766
|
+
}
|
|
1767
|
+
async warmup() {
|
|
1768
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
1769
|
+
this.warmupPromise = (async () => {
|
|
1770
|
+
try {
|
|
1771
|
+
await this.init();
|
|
1772
|
+
return await this.sendMessage(
|
|
1773
|
+
"warmup",
|
|
1774
|
+
this.workerOptionsPayload(),
|
|
1775
|
+
INIT_TIMEOUT_MS2
|
|
1776
|
+
);
|
|
1777
|
+
} catch (error) {
|
|
1778
|
+
this.warmupPromise = null;
|
|
1779
|
+
throw error;
|
|
1780
|
+
}
|
|
1781
|
+
})();
|
|
1782
|
+
return this.warmupPromise;
|
|
1783
|
+
}
|
|
1175
1784
|
async executeWithTracing(code, functionName, inputs, options, executionStyle) {
|
|
1176
1785
|
await this.init();
|
|
1177
|
-
|
|
1786
|
+
const result = await this.executeWithTimeout(
|
|
1178
1787
|
() => this.sendMessage(
|
|
1179
1788
|
"execute-with-tracing",
|
|
1180
1789
|
{ code, functionName, inputs, options, executionStyle },
|
|
@@ -1182,668 +1791,1225 @@ var JavaWorkerClient = class {
|
|
|
1182
1791
|
),
|
|
1183
1792
|
TRACING_TIMEOUT_MS2
|
|
1184
1793
|
);
|
|
1794
|
+
return {
|
|
1795
|
+
...result,
|
|
1796
|
+
trace: result.success ? javaTraceHooksEventsToRuntimeTrace(result.events, result.sourceText, {
|
|
1797
|
+
runId: "java:run",
|
|
1798
|
+
file: JAVA_DEFAULT_FILE
|
|
1799
|
+
}) : createEmptyRuntimeTrace("java", { runId: "java:run", file: JAVA_DEFAULT_FILE })
|
|
1800
|
+
};
|
|
1185
1801
|
}
|
|
1186
1802
|
async executeCode(code, functionName, inputs, options, executionStyle) {
|
|
1187
|
-
|
|
1803
|
+
return this.executeCodeMessage("execute-code", code, functionName, inputs, options, executionStyle);
|
|
1804
|
+
}
|
|
1805
|
+
async executeCodeMessage(type, code, functionName, inputs, options, executionStyle) {
|
|
1806
|
+
await this.init();
|
|
1807
|
+
const result = await this.executeWithTimeout(
|
|
1808
|
+
() => this.sendMessage(
|
|
1809
|
+
type,
|
|
1810
|
+
{ code, functionName, inputs, options, executionStyle },
|
|
1811
|
+
EXECUTION_TIMEOUT_MS2 + 5e3
|
|
1812
|
+
),
|
|
1813
|
+
EXECUTION_TIMEOUT_MS2
|
|
1814
|
+
);
|
|
1188
1815
|
if (!result.success) {
|
|
1189
1816
|
return {
|
|
1190
1817
|
success: false,
|
|
1191
1818
|
output: null,
|
|
1192
1819
|
error: result.error ?? "Java execution failed",
|
|
1193
1820
|
...result.errorLine !== void 0 ? { errorLine: result.errorLine } : {},
|
|
1194
|
-
consoleOutput: result.consoleOutput
|
|
1821
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1822
|
+
timings: result.timings
|
|
1195
1823
|
};
|
|
1196
1824
|
}
|
|
1197
1825
|
return {
|
|
1198
1826
|
success: true,
|
|
1199
1827
|
output: result.output,
|
|
1200
|
-
consoleOutput: result.consoleOutput
|
|
1828
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
1829
|
+
timings: result.timings
|
|
1201
1830
|
};
|
|
1202
1831
|
}
|
|
1203
1832
|
async executeCodeInterviewMode(code, functionName, inputs, options, executionStyle) {
|
|
1204
|
-
return this.
|
|
1833
|
+
return this.executeCodeMessage("execute-code-interview", code, functionName, inputs, options, executionStyle);
|
|
1205
1834
|
}
|
|
1206
1835
|
terminate() {
|
|
1207
1836
|
this.terminateAndReset();
|
|
1208
1837
|
}
|
|
1209
1838
|
};
|
|
1210
1839
|
|
|
1211
|
-
// packages/harness-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
if (/^-?\d+$/.test(raw)) return Number.parseInt(raw, 10);
|
|
1217
|
-
if (/^-?\d+\.\d+$/.test(raw)) return Number.parseFloat(raw);
|
|
1218
|
-
if (raw.startsWith('"') && raw.endsWith('"') || raw.startsWith("[") && raw.endsWith("]") || raw.startsWith("{") && raw.endsWith("}")) {
|
|
1219
|
-
try {
|
|
1220
|
-
return JSON.parse(raw);
|
|
1221
|
-
} catch {
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
return raw;
|
|
1225
|
-
}
|
|
1226
|
-
function normalizeJavaSerializedResult(output) {
|
|
1227
|
-
if (typeof output !== "string") {
|
|
1228
|
-
return output;
|
|
1229
|
-
}
|
|
1230
|
-
try {
|
|
1231
|
-
return JSON.parse(output);
|
|
1232
|
-
} catch {
|
|
1233
|
-
return output;
|
|
1840
|
+
// packages/harness-browser/src/java-runtime-client.ts
|
|
1841
|
+
var JAVA_DEFAULT_FILE2 = "solution.java";
|
|
1842
|
+
var JavaRuntimeClient = class {
|
|
1843
|
+
constructor(workerClient) {
|
|
1844
|
+
this.workerClient = workerClient;
|
|
1234
1845
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
const variables = {};
|
|
1238
|
-
const matches = Array.from(fragment.matchAll(/\b([A-Za-z_][A-Za-z0-9_.]*)=/g));
|
|
1239
|
-
for (let index = 0; index < matches.length; index += 1) {
|
|
1240
|
-
const match = matches[index];
|
|
1241
|
-
const rawKey = match[1];
|
|
1242
|
-
const valueStart = (match.index ?? 0) + match[0].length;
|
|
1243
|
-
const valueEnd = index + 1 < matches.length ? matches[index + 1].index ?? fragment.length : fragment.length;
|
|
1244
|
-
const rawValue = fragment.slice(valueStart, valueEnd).trim();
|
|
1245
|
-
if (!rawKey || rawValue === void 0) continue;
|
|
1246
|
-
if (rawKey === "method") continue;
|
|
1247
|
-
variables[rawKey.replaceAll(".", "_")] = parseScalar(rawValue);
|
|
1248
|
-
}
|
|
1249
|
-
return variables;
|
|
1250
|
-
}
|
|
1251
|
-
function extractLineMetadata(event) {
|
|
1252
|
-
const match = event.match(/^line=(\d+)(?:\s+(.*))?$/);
|
|
1253
|
-
if (!match) {
|
|
1254
|
-
return { line: 1, payload: event };
|
|
1846
|
+
async init() {
|
|
1847
|
+
return this.workerClient.init();
|
|
1255
1848
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1849
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
|
|
1850
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
|
|
1851
|
+
request: "trace",
|
|
1852
|
+
executionStyle,
|
|
1853
|
+
functionName
|
|
1854
|
+
});
|
|
1855
|
+
const rawResult = await this.workerClient.executeWithTracing(
|
|
1856
|
+
code,
|
|
1857
|
+
functionName ?? "",
|
|
1858
|
+
inputs,
|
|
1859
|
+
options,
|
|
1860
|
+
executionStyle
|
|
1861
|
+
);
|
|
1862
|
+
if (!rawResult.success) {
|
|
1863
|
+
return {
|
|
1864
|
+
success: false,
|
|
1865
|
+
error: rawResult.error ?? "Java tracing failed",
|
|
1866
|
+
...rawResult.errorLine !== void 0 ? { errorLine: rawResult.errorLine } : {},
|
|
1867
|
+
trace: createEmptyRuntimeTrace("java", { runId: "java:run", file: JAVA_DEFAULT_FILE2 }),
|
|
1868
|
+
executionTimeMs: rawResult.executionTimeMs,
|
|
1869
|
+
consoleOutput: rawResult.consoleOutput,
|
|
1870
|
+
...rawResult.traceLimitExceeded !== void 0 ? { traceLimitExceeded: rawResult.traceLimitExceeded } : {},
|
|
1871
|
+
...rawResult.timeoutReason ? { timeoutReason: rawResult.timeoutReason } : {},
|
|
1872
|
+
lineEventCount: 0,
|
|
1873
|
+
traceStepCount: 0,
|
|
1874
|
+
timings: rawResult.timings
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
return {
|
|
1878
|
+
success: true,
|
|
1879
|
+
output: rawResult.output,
|
|
1880
|
+
trace: rawResult.trace,
|
|
1881
|
+
consoleOutput: rawResult.consoleOutput,
|
|
1882
|
+
executionTimeMs: rawResult.executionTimeMs,
|
|
1883
|
+
...rawResult.traceLimitExceeded !== void 0 ? { traceLimitExceeded: rawResult.traceLimitExceeded } : {},
|
|
1884
|
+
...rawResult.timeoutReason ? { timeoutReason: rawResult.timeoutReason } : {},
|
|
1885
|
+
lineEventCount: rawResult.trace.lineEventCount,
|
|
1886
|
+
traceStepCount: rawResult.trace.traceStepCount,
|
|
1887
|
+
timings: rawResult.timings
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
async executeCode(code, functionName, inputs, executionStyle = "function") {
|
|
1891
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
|
|
1892
|
+
request: "execute",
|
|
1893
|
+
executionStyle,
|
|
1894
|
+
functionName
|
|
1895
|
+
});
|
|
1896
|
+
return this.workerClient.executeCode(
|
|
1897
|
+
code,
|
|
1898
|
+
functionName,
|
|
1899
|
+
inputs,
|
|
1900
|
+
void 0,
|
|
1901
|
+
executionStyle
|
|
1902
|
+
);
|
|
1903
|
+
}
|
|
1904
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "function") {
|
|
1905
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
|
|
1906
|
+
request: "interview",
|
|
1907
|
+
executionStyle,
|
|
1908
|
+
functionName
|
|
1909
|
+
});
|
|
1910
|
+
return this.workerClient.executeCodeInterviewMode(
|
|
1911
|
+
code,
|
|
1912
|
+
functionName,
|
|
1913
|
+
inputs,
|
|
1914
|
+
void 0,
|
|
1915
|
+
executionStyle
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
};
|
|
1919
|
+
function createJavaRuntimeClient(workerClient) {
|
|
1920
|
+
return new JavaRuntimeClient(workerClient);
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
// packages/harness-browser/src/csharp-worker-client.ts
|
|
1924
|
+
var EXECUTION_TIMEOUT_MS3 = 2e4;
|
|
1925
|
+
var TRACING_TIMEOUT_MS3 = 2e4;
|
|
1926
|
+
var INTERVIEW_MODE_TIMEOUT_MS2 = 5e3;
|
|
1927
|
+
var INIT_TIMEOUT_MS3 = 45e3;
|
|
1928
|
+
var MESSAGE_TIMEOUT_MS3 = 3e4;
|
|
1929
|
+
var WORKER_READY_TIMEOUT_MS3 = 1e4;
|
|
1930
|
+
var CSHARP_DEFAULT_FILE = "solution.cs";
|
|
1931
|
+
var CSHARP_LEGACY_USER_FILE = "UserCode.cs";
|
|
1932
|
+
function isCSharpUserFile(file) {
|
|
1933
|
+
return Boolean(file?.endsWith(CSHARP_DEFAULT_FILE) || file?.endsWith(CSHARP_LEGACY_USER_FILE));
|
|
1934
|
+
}
|
|
1935
|
+
function isCSharpUserDiagnostic(diagnostic) {
|
|
1936
|
+
return isCSharpUserFile(diagnostic.file);
|
|
1937
|
+
}
|
|
1938
|
+
function normalizeCSharpTraceEventFile(event) {
|
|
1939
|
+
return isCSharpUserFile(event.file) ? { ...event, file: CSHARP_DEFAULT_FILE } : event;
|
|
1940
|
+
}
|
|
1941
|
+
var CSharpWorkerClient = class {
|
|
1942
|
+
constructor(options) {
|
|
1943
|
+
this.options = options;
|
|
1944
|
+
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
1945
|
+
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS3;
|
|
1946
|
+
this.executionTimeoutMs = options.executionTimeoutMs ?? EXECUTION_TIMEOUT_MS3;
|
|
1947
|
+
this.tracingTimeoutMs = options.tracingTimeoutMs ?? TRACING_TIMEOUT_MS3;
|
|
1948
|
+
this.interviewTimeoutMs = options.interviewTimeoutMs ?? INTERVIEW_MODE_TIMEOUT_MS2;
|
|
1949
|
+
}
|
|
1950
|
+
worker = null;
|
|
1951
|
+
pendingMessages = /* @__PURE__ */ new Map();
|
|
1952
|
+
messageId = 0;
|
|
1953
|
+
isInitializing = false;
|
|
1954
|
+
initPromise = null;
|
|
1955
|
+
warmupPromise = null;
|
|
1956
|
+
workerReadyPromise = null;
|
|
1957
|
+
workerReadyResolve = null;
|
|
1958
|
+
workerReadyReject = null;
|
|
1959
|
+
debug;
|
|
1960
|
+
initTimeoutMs;
|
|
1961
|
+
executionTimeoutMs;
|
|
1962
|
+
tracingTimeoutMs;
|
|
1963
|
+
interviewTimeoutMs;
|
|
1964
|
+
isSupported() {
|
|
1965
|
+
return typeof Worker !== "undefined";
|
|
1966
|
+
}
|
|
1967
|
+
getWorker() {
|
|
1968
|
+
if (this.worker) return this.worker;
|
|
1969
|
+
if (!this.isSupported()) {
|
|
1970
|
+
throw new Error("Web Workers are not supported in this environment");
|
|
1971
|
+
}
|
|
1972
|
+
this.workerReadyPromise = new Promise((resolve, reject) => {
|
|
1973
|
+
this.workerReadyResolve = resolve;
|
|
1974
|
+
this.workerReadyReject = (error) => reject(error);
|
|
1975
|
+
});
|
|
1976
|
+
const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
|
|
1977
|
+
this.worker = new Worker(workerUrl, { type: "module" });
|
|
1978
|
+
this.worker.onmessage = (event) => {
|
|
1979
|
+
const { id, type, payload } = event.data;
|
|
1980
|
+
if (type === "worker-ready") {
|
|
1981
|
+
this.workerReadyResolve?.();
|
|
1982
|
+
this.workerReadyResolve = null;
|
|
1983
|
+
this.workerReadyReject = null;
|
|
1984
|
+
logRuntimeDiagnostic("info", {
|
|
1985
|
+
component: "CSharpWorkerClient",
|
|
1986
|
+
runtime: "csharp",
|
|
1987
|
+
phase: "worker-ready",
|
|
1988
|
+
message: "C# worker is ready."
|
|
1989
|
+
}, { enabled: this.debug });
|
|
1990
|
+
return;
|
|
1991
|
+
}
|
|
1992
|
+
if (type === "idle-timeout") {
|
|
1993
|
+
logRuntimeDiagnostic("info", {
|
|
1994
|
+
component: "CSharpWorkerClient",
|
|
1995
|
+
runtime: "csharp",
|
|
1996
|
+
phase: "idle-timeout",
|
|
1997
|
+
message: "C# worker closed after idle timeout."
|
|
1998
|
+
}, { enabled: this.debug });
|
|
1999
|
+
this.terminateAndReset(new Error("C# worker closed after idle timeout"));
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
if (!id) return;
|
|
2003
|
+
const pending = this.pendingMessages.get(id);
|
|
2004
|
+
if (!pending) return;
|
|
2005
|
+
this.pendingMessages.delete(id);
|
|
2006
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
2007
|
+
if (type === "error") {
|
|
2008
|
+
pending.reject(new Error(payload.error));
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
pending.resolve(payload);
|
|
2012
|
+
};
|
|
2013
|
+
this.worker.onerror = (error) => {
|
|
2014
|
+
logRuntimeDiagnostic("error", {
|
|
2015
|
+
component: "CSharpWorkerClient",
|
|
2016
|
+
runtime: "csharp",
|
|
2017
|
+
phase: "worker-error",
|
|
2018
|
+
message: "C# worker emitted an error event.",
|
|
2019
|
+
detail: {
|
|
2020
|
+
message: error.message,
|
|
2021
|
+
filename: error.filename,
|
|
2022
|
+
lineno: error.lineno,
|
|
2023
|
+
colno: error.colno
|
|
2024
|
+
}
|
|
2025
|
+
});
|
|
2026
|
+
const workerError = new Error(error.message || "C# worker error");
|
|
2027
|
+
this.workerReadyReject?.(workerError);
|
|
2028
|
+
this.workerReadyResolve = null;
|
|
2029
|
+
this.workerReadyReject = null;
|
|
2030
|
+
for (const [, pending] of this.pendingMessages) {
|
|
2031
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
2032
|
+
pending.reject(workerError);
|
|
2033
|
+
}
|
|
2034
|
+
this.pendingMessages.clear();
|
|
2035
|
+
this.terminateAndReset(workerError);
|
|
2036
|
+
};
|
|
2037
|
+
return this.worker;
|
|
2038
|
+
}
|
|
2039
|
+
async waitForWorkerReady() {
|
|
2040
|
+
const readyPromise = this.workerReadyPromise;
|
|
2041
|
+
if (!readyPromise) return;
|
|
2042
|
+
await new Promise((resolve, reject) => {
|
|
2043
|
+
let settled = false;
|
|
2044
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2045
|
+
if (settled) return;
|
|
2046
|
+
settled = true;
|
|
2047
|
+
const timeoutError = new Error(
|
|
2048
|
+
`C# worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS3 / 1e3)}s)`
|
|
2049
|
+
);
|
|
2050
|
+
logRuntimeDiagnostic("warn", {
|
|
2051
|
+
component: "CSharpWorkerClient",
|
|
2052
|
+
runtime: "csharp",
|
|
2053
|
+
phase: "worker-ready-timeout",
|
|
2054
|
+
message: "C# worker did not send worker-ready before the timeout.",
|
|
2055
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS3 }
|
|
2056
|
+
}, { enabled: this.debug });
|
|
2057
|
+
this.terminateAndReset(timeoutError);
|
|
2058
|
+
reject(timeoutError);
|
|
2059
|
+
}, WORKER_READY_TIMEOUT_MS3);
|
|
2060
|
+
readyPromise.then(() => {
|
|
2061
|
+
if (settled) return;
|
|
2062
|
+
settled = true;
|
|
2063
|
+
globalThis.clearTimeout(timeoutId);
|
|
2064
|
+
resolve();
|
|
2065
|
+
}).catch((error) => {
|
|
2066
|
+
if (settled) return;
|
|
2067
|
+
settled = true;
|
|
2068
|
+
globalThis.clearTimeout(timeoutId);
|
|
2069
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2070
|
+
});
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS3) {
|
|
2074
|
+
const worker = this.getWorker();
|
|
2075
|
+
await this.waitForWorkerReady();
|
|
2076
|
+
const id = String(++this.messageId);
|
|
2077
|
+
return new Promise((resolve, reject) => {
|
|
2078
|
+
this.pendingMessages.set(id, {
|
|
2079
|
+
resolve,
|
|
2080
|
+
reject
|
|
2081
|
+
});
|
|
2082
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2083
|
+
const pending2 = this.pendingMessages.get(id);
|
|
2084
|
+
if (!pending2) return;
|
|
2085
|
+
this.pendingMessages.delete(id);
|
|
2086
|
+
logRuntimeDiagnostic("warn", {
|
|
2087
|
+
component: "CSharpWorkerClient",
|
|
2088
|
+
runtime: "csharp",
|
|
2089
|
+
phase: "worker-request-timeout",
|
|
2090
|
+
message: "C# worker request timed out.",
|
|
2091
|
+
detail: { id, type, timeoutMs }
|
|
2092
|
+
}, { enabled: this.debug });
|
|
2093
|
+
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
2094
|
+
}, timeoutMs);
|
|
2095
|
+
const pending = this.pendingMessages.get(id);
|
|
2096
|
+
if (pending) pending.timeoutId = timeoutId;
|
|
2097
|
+
worker.postMessage({ id, type, payload });
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
async executeWithTimeout(executor, timeoutMs) {
|
|
2101
|
+
return new Promise((resolve, reject) => {
|
|
2102
|
+
let settled = false;
|
|
2103
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2104
|
+
if (settled) return;
|
|
2105
|
+
settled = true;
|
|
2106
|
+
logRuntimeDiagnostic("warn", {
|
|
2107
|
+
component: "CSharpWorkerClient",
|
|
2108
|
+
runtime: "csharp",
|
|
2109
|
+
phase: "execution-timeout",
|
|
2110
|
+
message: "C# execution timed out; terminating worker.",
|
|
2111
|
+
detail: { timeoutMs }
|
|
2112
|
+
}, { enabled: this.debug });
|
|
2113
|
+
this.terminateAndReset();
|
|
2114
|
+
reject(new Error(`C# execution timed out after ${Math.round(timeoutMs / 1e3)} seconds.`));
|
|
2115
|
+
}, timeoutMs);
|
|
2116
|
+
executor().then((result) => {
|
|
2117
|
+
if (settled) return;
|
|
2118
|
+
settled = true;
|
|
2119
|
+
globalThis.clearTimeout(timeoutId);
|
|
2120
|
+
resolve(result);
|
|
2121
|
+
}).catch((error) => {
|
|
2122
|
+
if (settled) return;
|
|
2123
|
+
settled = true;
|
|
2124
|
+
globalThis.clearTimeout(timeoutId);
|
|
2125
|
+
reject(error);
|
|
2126
|
+
});
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
terminateAndReset(reason = new Error("Worker was terminated")) {
|
|
2130
|
+
this.workerReadyReject?.(reason);
|
|
2131
|
+
if (this.worker) {
|
|
2132
|
+
this.worker.terminate();
|
|
2133
|
+
this.worker = null;
|
|
2134
|
+
}
|
|
2135
|
+
this.initPromise = null;
|
|
2136
|
+
this.warmupPromise = null;
|
|
2137
|
+
this.isInitializing = false;
|
|
2138
|
+
this.workerReadyPromise = null;
|
|
2139
|
+
this.workerReadyResolve = null;
|
|
2140
|
+
this.workerReadyReject = null;
|
|
2141
|
+
for (const [, pending] of this.pendingMessages) {
|
|
2142
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
2143
|
+
pending.reject(reason);
|
|
2144
|
+
}
|
|
2145
|
+
this.pendingMessages.clear();
|
|
2146
|
+
}
|
|
2147
|
+
shouldRetryInit(error) {
|
|
2148
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2149
|
+
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");
|
|
2150
|
+
}
|
|
2151
|
+
sendInitMessage() {
|
|
2152
|
+
return this.sendMessage(
|
|
2153
|
+
"init",
|
|
2154
|
+
{ assetBaseUrl: this.options.assetBaseUrl, ...this.workerOptionsPayload() },
|
|
2155
|
+
this.initTimeoutMs
|
|
2156
|
+
);
|
|
2157
|
+
}
|
|
2158
|
+
workerOptionsPayload() {
|
|
2159
|
+
return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
|
|
2160
|
+
}
|
|
2161
|
+
async init() {
|
|
2162
|
+
if (this.initPromise) return this.initPromise;
|
|
2163
|
+
if (this.isInitializing) {
|
|
2164
|
+
await new Promise((resolve) => globalThis.setTimeout(resolve, 100));
|
|
2165
|
+
return this.init();
|
|
2166
|
+
}
|
|
2167
|
+
this.isInitializing = true;
|
|
2168
|
+
this.initPromise = (async () => {
|
|
2169
|
+
try {
|
|
2170
|
+
return await this.sendInitMessage();
|
|
2171
|
+
} catch (error) {
|
|
2172
|
+
if (!this.shouldRetryInit(error)) throw error;
|
|
2173
|
+
this.terminateAndReset(error instanceof Error ? error : new Error(String(error)));
|
|
2174
|
+
return this.sendInitMessage();
|
|
2175
|
+
}
|
|
2176
|
+
})();
|
|
2177
|
+
try {
|
|
2178
|
+
return await this.initPromise;
|
|
2179
|
+
} catch (error) {
|
|
2180
|
+
this.initPromise = null;
|
|
2181
|
+
throw error;
|
|
2182
|
+
} finally {
|
|
2183
|
+
this.isInitializing = false;
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
async warmup() {
|
|
2187
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
2188
|
+
this.warmupPromise = (async () => {
|
|
2189
|
+
try {
|
|
2190
|
+
await this.init();
|
|
2191
|
+
return await this.sendMessage(
|
|
2192
|
+
"warmup",
|
|
2193
|
+
{ assetBaseUrl: this.options.assetBaseUrl, ...this.workerOptionsPayload() },
|
|
2194
|
+
this.initTimeoutMs
|
|
2195
|
+
);
|
|
2196
|
+
} catch (error) {
|
|
2197
|
+
this.warmupPromise = null;
|
|
2198
|
+
throw error;
|
|
2199
|
+
}
|
|
2200
|
+
})();
|
|
2201
|
+
return this.warmupPromise;
|
|
2202
|
+
}
|
|
2203
|
+
async executeCode(code, functionName, inputs, executionStyle) {
|
|
2204
|
+
await this.init();
|
|
2205
|
+
const result = await this.executeWithTimeout(
|
|
2206
|
+
() => this.sendMessage(
|
|
2207
|
+
"execute-code",
|
|
2208
|
+
{
|
|
2209
|
+
code,
|
|
2210
|
+
functionName,
|
|
2211
|
+
inputs,
|
|
2212
|
+
executionStyle,
|
|
2213
|
+
assetBaseUrl: this.options.assetBaseUrl,
|
|
2214
|
+
timeoutMs: Math.max(100, this.executionTimeoutMs - 1e3),
|
|
2215
|
+
...this.workerOptionsPayload()
|
|
2216
|
+
},
|
|
2217
|
+
this.executionTimeoutMs + 5e3
|
|
2218
|
+
),
|
|
2219
|
+
this.executionTimeoutMs
|
|
2220
|
+
);
|
|
2221
|
+
if (!result.success) {
|
|
2222
|
+
const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
|
|
2223
|
+
return {
|
|
2224
|
+
success: false,
|
|
2225
|
+
output: null,
|
|
2226
|
+
error: result.error ?? "C# execution failed",
|
|
2227
|
+
...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
|
|
2228
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
2229
|
+
timings: result.timings
|
|
2230
|
+
};
|
|
2231
|
+
}
|
|
2232
|
+
return {
|
|
2233
|
+
success: true,
|
|
2234
|
+
output: result.output,
|
|
2235
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
2236
|
+
timings: result.timings
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2239
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle) {
|
|
2240
|
+
await this.init();
|
|
2241
|
+
let result;
|
|
2242
|
+
try {
|
|
2243
|
+
result = await this.executeWithTimeout(
|
|
2244
|
+
() => this.sendMessage(
|
|
2245
|
+
"execute-code-interview",
|
|
2246
|
+
{
|
|
2247
|
+
code,
|
|
2248
|
+
functionName,
|
|
2249
|
+
inputs,
|
|
2250
|
+
executionStyle,
|
|
2251
|
+
assetBaseUrl: this.options.assetBaseUrl,
|
|
2252
|
+
timeoutMs: Math.max(100, this.interviewTimeoutMs - 1e3),
|
|
2253
|
+
...this.workerOptionsPayload()
|
|
2254
|
+
},
|
|
2255
|
+
this.interviewTimeoutMs + 5e3
|
|
2256
|
+
),
|
|
2257
|
+
this.interviewTimeoutMs
|
|
2258
|
+
);
|
|
2259
|
+
} catch {
|
|
2260
|
+
return {
|
|
2261
|
+
success: false,
|
|
2262
|
+
output: null,
|
|
2263
|
+
error: "Time Limit Exceeded",
|
|
2264
|
+
timeoutReason: "client-timeout",
|
|
2265
|
+
diagnosticStage: "interview",
|
|
2266
|
+
consoleOutput: [],
|
|
2267
|
+
timings: { totalMs: this.interviewTimeoutMs }
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
if (!result.success) {
|
|
2271
|
+
const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
|
|
2272
|
+
if (this.isInterviewTimeoutLike(result)) {
|
|
2273
|
+
return {
|
|
2274
|
+
success: false,
|
|
2275
|
+
output: null,
|
|
2276
|
+
error: "Time Limit Exceeded",
|
|
2277
|
+
timeoutReason: result.timeoutReason ?? "client-timeout",
|
|
2278
|
+
diagnosticStage: "interview",
|
|
2279
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
2280
|
+
timings: result.timings
|
|
2281
|
+
};
|
|
1273
2282
|
}
|
|
1274
|
-
|
|
1275
|
-
|
|
2283
|
+
return {
|
|
2284
|
+
success: false,
|
|
2285
|
+
output: null,
|
|
2286
|
+
error: result.error ?? "C# execution failed",
|
|
2287
|
+
...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
|
|
2288
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
2289
|
+
timings: result.timings
|
|
2290
|
+
};
|
|
1276
2291
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
2292
|
+
return {
|
|
2293
|
+
success: true,
|
|
2294
|
+
output: result.output,
|
|
2295
|
+
consoleOutput: result.consoleOutput ?? [],
|
|
2296
|
+
timings: result.timings
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle) {
|
|
2300
|
+
await this.init();
|
|
2301
|
+
let result;
|
|
2302
|
+
try {
|
|
2303
|
+
result = await this.executeWithTimeout(
|
|
2304
|
+
() => this.sendMessage(
|
|
2305
|
+
"execute-with-tracing",
|
|
2306
|
+
{
|
|
2307
|
+
code,
|
|
2308
|
+
functionName,
|
|
2309
|
+
inputs,
|
|
2310
|
+
executionStyle,
|
|
2311
|
+
assetBaseUrl: this.options.assetBaseUrl,
|
|
2312
|
+
timeoutMs: Math.max(100, this.tracingTimeoutMs - 1e3),
|
|
2313
|
+
maxTraceSteps: options?.maxTraceSteps,
|
|
2314
|
+
maxLineEvents: options?.maxLineEvents,
|
|
2315
|
+
maxSingleLineHits: options?.maxSingleLineHits,
|
|
2316
|
+
maxStoredEvents: options?.maxStoredEvents,
|
|
2317
|
+
minimalTrace: options?.minimalTrace,
|
|
2318
|
+
...this.workerOptionsPayload()
|
|
2319
|
+
},
|
|
2320
|
+
this.tracingTimeoutMs + 5e3
|
|
2321
|
+
),
|
|
2322
|
+
this.tracingTimeoutMs
|
|
2323
|
+
);
|
|
2324
|
+
} catch (error) {
|
|
2325
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2326
|
+
const trace2 = this.createTrace([
|
|
2327
|
+
{
|
|
2328
|
+
kind: "timeout",
|
|
2329
|
+
runId: "csharp:run",
|
|
2330
|
+
file: CSHARP_DEFAULT_FILE,
|
|
2331
|
+
message
|
|
2332
|
+
}
|
|
2333
|
+
]);
|
|
2334
|
+
return {
|
|
2335
|
+
success: false,
|
|
2336
|
+
output: null,
|
|
2337
|
+
error: message,
|
|
2338
|
+
trace: trace2,
|
|
2339
|
+
executionTimeMs: this.tracingTimeoutMs,
|
|
2340
|
+
consoleOutput: [],
|
|
2341
|
+
traceLimitExceeded: true,
|
|
2342
|
+
timeoutReason: "client-timeout",
|
|
2343
|
+
lineEventCount: trace2.lineEventCount,
|
|
2344
|
+
traceStepCount: trace2.traceStepCount,
|
|
2345
|
+
timings: { totalMs: this.tracingTimeoutMs }
|
|
2346
|
+
};
|
|
1281
2347
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
2348
|
+
const consoleOutput = result.consoleOutput ?? [];
|
|
2349
|
+
const events = [
|
|
2350
|
+
...result.events ?? [],
|
|
2351
|
+
...consoleOutput.map((text) => ({
|
|
2352
|
+
kind: "stdout",
|
|
2353
|
+
runId: "csharp:run",
|
|
2354
|
+
file: CSHARP_DEFAULT_FILE,
|
|
2355
|
+
text
|
|
2356
|
+
}))
|
|
2357
|
+
];
|
|
2358
|
+
const trace = this.createTrace(events);
|
|
2359
|
+
if (!result.success) {
|
|
2360
|
+
const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
|
|
2361
|
+
return {
|
|
2362
|
+
success: false,
|
|
2363
|
+
output: null,
|
|
2364
|
+
error: result.error ?? "C# execution failed",
|
|
2365
|
+
...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
|
|
2366
|
+
trace,
|
|
2367
|
+
executionTimeMs: result.executionTimeMs ?? 0,
|
|
2368
|
+
consoleOutput,
|
|
2369
|
+
...result.traceLimitExceeded !== void 0 ? { traceLimitExceeded: result.traceLimitExceeded } : {},
|
|
2370
|
+
...result.timeoutReason ? { timeoutReason: result.timeoutReason } : {},
|
|
2371
|
+
lineEventCount: trace.lineEventCount,
|
|
2372
|
+
traceStepCount: trace.traceStepCount,
|
|
2373
|
+
timings: result.timings
|
|
2374
|
+
};
|
|
1284
2375
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
2376
|
+
return {
|
|
2377
|
+
success: true,
|
|
2378
|
+
output: result.output,
|
|
2379
|
+
trace,
|
|
2380
|
+
executionTimeMs: result.executionTimeMs ?? 0,
|
|
2381
|
+
consoleOutput,
|
|
2382
|
+
...result.traceLimitExceeded !== void 0 ? { traceLimitExceeded: result.traceLimitExceeded } : {},
|
|
2383
|
+
...result.timeoutReason ? { timeoutReason: result.timeoutReason } : {},
|
|
2384
|
+
lineEventCount: trace.lineEventCount,
|
|
2385
|
+
traceStepCount: trace.traceStepCount,
|
|
2386
|
+
timings: result.timings
|
|
2387
|
+
};
|
|
1287
2388
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
if (/^(?:if|for|while|switch|catch|do|try|else|return|throw|new)\b/.test(trimmed)) {
|
|
1298
|
-
return false;
|
|
2389
|
+
createTrace(events) {
|
|
2390
|
+
return {
|
|
2391
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
2392
|
+
language: "csharp",
|
|
2393
|
+
runId: "csharp:run",
|
|
2394
|
+
events: events.map(normalizeCSharpTraceEventFile),
|
|
2395
|
+
lineEventCount: events.filter((event) => event.kind === "line").length,
|
|
2396
|
+
traceStepCount: events.length
|
|
2397
|
+
};
|
|
1299
2398
|
}
|
|
1300
|
-
|
|
1301
|
-
return
|
|
2399
|
+
isInterviewTimeoutLike(result) {
|
|
2400
|
+
if (result.timeoutReason) return true;
|
|
2401
|
+
const normalized = String(result.error ?? "").toLowerCase();
|
|
2402
|
+
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");
|
|
1302
2403
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
function buildLineRemap(sourceText) {
|
|
1306
|
-
if (typeof sourceText !== "string" || sourceText.length === 0) {
|
|
1307
|
-
return null;
|
|
2404
|
+
terminate() {
|
|
2405
|
+
this.terminateAndReset();
|
|
1308
2406
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
if (text.trim().length > 0) {
|
|
1316
|
-
executable.add(index + 1);
|
|
1317
|
-
}
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2409
|
+
// packages/harness-browser/src/csharp-runtime-client.ts
|
|
2410
|
+
var CSharpRuntimeClient = class {
|
|
2411
|
+
constructor(workerClient) {
|
|
2412
|
+
this.workerClient = workerClient;
|
|
1318
2413
|
}
|
|
1319
|
-
|
|
1320
|
-
return
|
|
2414
|
+
async init() {
|
|
2415
|
+
return this.workerClient.init();
|
|
1321
2416
|
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
}
|
|
1328
|
-
|
|
2417
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle = "solution-method") {
|
|
2418
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("csharp"), {
|
|
2419
|
+
request: "trace",
|
|
2420
|
+
executionStyle,
|
|
2421
|
+
functionName
|
|
2422
|
+
});
|
|
2423
|
+
return this.workerClient.executeWithTracing(
|
|
2424
|
+
code,
|
|
2425
|
+
functionName ?? "",
|
|
2426
|
+
inputs,
|
|
2427
|
+
options,
|
|
2428
|
+
executionStyle
|
|
2429
|
+
);
|
|
1329
2430
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
}
|
|
1336
|
-
|
|
2431
|
+
async executeCode(code, functionName, inputs, executionStyle = "solution-method") {
|
|
2432
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("csharp"), {
|
|
2433
|
+
request: "execute",
|
|
2434
|
+
executionStyle,
|
|
2435
|
+
functionName
|
|
2436
|
+
});
|
|
2437
|
+
return this.workerClient.executeCode(
|
|
2438
|
+
code,
|
|
2439
|
+
functionName,
|
|
2440
|
+
inputs,
|
|
2441
|
+
executionStyle
|
|
2442
|
+
);
|
|
1337
2443
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
2444
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "solution-method") {
|
|
2445
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("csharp"), {
|
|
2446
|
+
request: "interview",
|
|
2447
|
+
executionStyle,
|
|
2448
|
+
functionName
|
|
2449
|
+
});
|
|
2450
|
+
return this.workerClient.executeCodeInterviewMode(
|
|
2451
|
+
code,
|
|
2452
|
+
functionName,
|
|
2453
|
+
inputs,
|
|
2454
|
+
executionStyle
|
|
2455
|
+
);
|
|
1347
2456
|
}
|
|
1348
|
-
|
|
2457
|
+
};
|
|
2458
|
+
function createCSharpRuntimeClient(workerClient) {
|
|
2459
|
+
return new CSharpRuntimeClient(workerClient);
|
|
1349
2460
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
2461
|
+
|
|
2462
|
+
// packages/harness-browser/src/cpp-worker-client.ts
|
|
2463
|
+
var CppClientTimeoutError = class extends Error {
|
|
2464
|
+
constructor(message, stage, timeoutMs) {
|
|
2465
|
+
super(message);
|
|
2466
|
+
this.stage = stage;
|
|
2467
|
+
this.timeoutMs = timeoutMs;
|
|
2468
|
+
this.name = "CppClientTimeoutError";
|
|
1353
2469
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
2470
|
+
};
|
|
2471
|
+
var INIT_TIMEOUT_MS4 = 12e4;
|
|
2472
|
+
var EXECUTION_TIMEOUT_MS4 = 6e4;
|
|
2473
|
+
var TRACING_TIMEOUT_MS4 = 6e4;
|
|
2474
|
+
var INTERVIEW_MODE_TIMEOUT_MS3 = 3e4;
|
|
2475
|
+
var MESSAGE_TIMEOUT_MS4 = 3e4;
|
|
2476
|
+
var WORKER_READY_TIMEOUT_MS4 = 1e4;
|
|
2477
|
+
var CPP_DEFAULT_FILE = "solution.cpp";
|
|
2478
|
+
var CppWorkerClient = class {
|
|
2479
|
+
constructor(options) {
|
|
2480
|
+
this.options = options;
|
|
2481
|
+
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
2482
|
+
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS4;
|
|
2483
|
+
this.executionTimeoutMs = options.executionTimeoutMs ?? EXECUTION_TIMEOUT_MS4;
|
|
2484
|
+
this.tracingTimeoutMs = options.tracingTimeoutMs ?? TRACING_TIMEOUT_MS4;
|
|
2485
|
+
this.interviewTimeoutMs = options.interviewTimeoutMs ?? INTERVIEW_MODE_TIMEOUT_MS3;
|
|
2486
|
+
this.compilerFrameUrl = options.compilerFrameUrl;
|
|
1363
2487
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
return
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
}];
|
|
1415
|
-
}
|
|
1416
|
-
const indexedMutatingCall = payload.match(/^mutate-indexed ([A-Za-z_][A-Za-z0-9_]*)\[(\d+)\] method=([A-Za-z_][A-Za-z0-9_]*)$/);
|
|
1417
|
-
if (indexedMutatingCall) {
|
|
1418
|
-
return [{
|
|
1419
|
-
variable: indexedMutatingCall[1],
|
|
1420
|
-
kind: "mutating-call",
|
|
1421
|
-
indices: [Number.parseInt(indexedMutatingCall[2], 10)],
|
|
1422
|
-
method: indexedMutatingCall[3],
|
|
1423
|
-
pathDepth: 1
|
|
1424
|
-
}];
|
|
1425
|
-
}
|
|
1426
|
-
const keyedCall = payload.match(/^keyed-call ([A-Za-z_][A-Za-z0-9_]*) method=([A-Za-z_][A-Za-z0-9_]*)(?:\s+.*)?$/);
|
|
1427
|
-
if (keyedCall) {
|
|
1428
|
-
return [{
|
|
1429
|
-
variable: keyedCall[1],
|
|
1430
|
-
kind: "mutating-call",
|
|
1431
|
-
method: keyedCall[2],
|
|
1432
|
-
pathDepth: 1
|
|
1433
|
-
}];
|
|
1434
|
-
}
|
|
1435
|
-
return void 0;
|
|
1436
|
-
}
|
|
1437
|
-
function parseStructureState(payload) {
|
|
1438
|
-
const match = payload.match(/^state (linked-list|tree|graph-adjacency) ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
|
|
1439
|
-
if (!match) return null;
|
|
1440
|
-
return {
|
|
1441
|
-
structure: match[1],
|
|
1442
|
-
variable: match[2],
|
|
1443
|
-
value: JSON.parse(match[3])
|
|
1444
|
-
};
|
|
1445
|
-
}
|
|
1446
|
-
function parseObjectState(payload) {
|
|
1447
|
-
const match = payload.match(/^object-state ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
|
|
1448
|
-
if (!match) return null;
|
|
1449
|
-
return {
|
|
1450
|
-
variable: match[1],
|
|
1451
|
-
visualization: JSON.parse(match[2])
|
|
1452
|
-
};
|
|
1453
|
-
}
|
|
1454
|
-
function parseMapState(payload) {
|
|
1455
|
-
const match = payload.match(/^map-state ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
|
|
1456
|
-
if (!match) return null;
|
|
1457
|
-
return {
|
|
1458
|
-
variable: match[1],
|
|
1459
|
-
visualization: JSON.parse(match[2])
|
|
1460
|
-
};
|
|
1461
|
-
}
|
|
1462
|
-
function parseSetState(payload) {
|
|
1463
|
-
const match = payload.match(/^set-state ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
|
|
1464
|
-
if (!match) return null;
|
|
1465
|
-
return {
|
|
1466
|
-
variable: match[1],
|
|
1467
|
-
visualization: JSON.parse(match[2])
|
|
1468
|
-
};
|
|
1469
|
-
}
|
|
1470
|
-
function parseObjectFieldEvent(payload) {
|
|
1471
|
-
const match = payload.match(/^(access|write) ([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
|
|
1472
|
-
if (!match) return null;
|
|
1473
|
-
return {
|
|
1474
|
-
variable: match[2],
|
|
1475
|
-
field: match[3],
|
|
1476
|
-
value: parseScalar(match[4])
|
|
1477
|
-
};
|
|
1478
|
-
}
|
|
1479
|
-
function isArrayLengthAccessEvent(payload) {
|
|
1480
|
-
return /^access [A-Za-z_][A-Za-z0-9_]*\.length=\d+$/.test(payload);
|
|
1481
|
-
}
|
|
1482
|
-
function buildFieldVisualization(event) {
|
|
1483
|
-
return {
|
|
1484
|
-
objectKinds: {
|
|
1485
|
-
[event.variable]: "object"
|
|
1486
|
-
},
|
|
1487
|
-
hashMaps: [
|
|
1488
|
-
{
|
|
1489
|
-
name: event.variable,
|
|
1490
|
-
kind: "object",
|
|
1491
|
-
objectClassName: event.field === "next" || event.field === "prev" ? "ListNode" : event.field === "left" || event.field === "right" ? "TreeNode" : void 0,
|
|
1492
|
-
objectId: `${event.variable}-object`,
|
|
1493
|
-
highlightedKey: event.field,
|
|
1494
|
-
entries: [{ key: event.field, value: event.value, highlight: true }]
|
|
2488
|
+
worker = null;
|
|
2489
|
+
pendingMessages = /* @__PURE__ */ new Map();
|
|
2490
|
+
messageId = 0;
|
|
2491
|
+
initPromise = null;
|
|
2492
|
+
warmupPromise = null;
|
|
2493
|
+
workerReadyPromise = null;
|
|
2494
|
+
workerReadyResolve = null;
|
|
2495
|
+
workerReadyReject = null;
|
|
2496
|
+
debug;
|
|
2497
|
+
initTimeoutMs;
|
|
2498
|
+
executionTimeoutMs;
|
|
2499
|
+
tracingTimeoutMs;
|
|
2500
|
+
interviewTimeoutMs;
|
|
2501
|
+
compilerFrameUrl;
|
|
2502
|
+
activeCompilerFrames = /* @__PURE__ */ new Set();
|
|
2503
|
+
compilerFrame = null;
|
|
2504
|
+
compilerFrameReadyPromise = null;
|
|
2505
|
+
compilerFrameReadyResolve = null;
|
|
2506
|
+
compilerFrameReadyReject = null;
|
|
2507
|
+
compilerFrameTargetOrigin = "";
|
|
2508
|
+
compilerFrameRequestId = 0;
|
|
2509
|
+
compilerFrameMessageHandler = null;
|
|
2510
|
+
pendingCompilerFrameRequests = /* @__PURE__ */ new Map();
|
|
2511
|
+
isSupported() {
|
|
2512
|
+
return typeof Worker !== "undefined";
|
|
2513
|
+
}
|
|
2514
|
+
getWorker() {
|
|
2515
|
+
if (this.worker) return this.worker;
|
|
2516
|
+
if (!this.isSupported()) {
|
|
2517
|
+
throw new Error("Web Workers are not supported in this environment");
|
|
2518
|
+
}
|
|
2519
|
+
this.workerReadyPromise = new Promise((resolve, reject) => {
|
|
2520
|
+
this.workerReadyResolve = resolve;
|
|
2521
|
+
this.workerReadyReject = (error) => reject(error);
|
|
2522
|
+
});
|
|
2523
|
+
const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
|
|
2524
|
+
this.worker = new Worker(workerUrl, { type: "module" });
|
|
2525
|
+
this.worker.onmessage = (event) => {
|
|
2526
|
+
const { id, type, payload } = event.data;
|
|
2527
|
+
if (type === "worker-ready") {
|
|
2528
|
+
this.workerReadyResolve?.();
|
|
2529
|
+
this.workerReadyResolve = null;
|
|
2530
|
+
this.workerReadyReject = null;
|
|
2531
|
+
logRuntimeDiagnostic("info", {
|
|
2532
|
+
component: "CppWorkerClient",
|
|
2533
|
+
runtime: "cpp",
|
|
2534
|
+
phase: "worker-ready",
|
|
2535
|
+
message: "C++ worker is ready."
|
|
2536
|
+
}, { enabled: this.debug });
|
|
2537
|
+
return;
|
|
1495
2538
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
2539
|
+
if (type === "idle-timeout") {
|
|
2540
|
+
logRuntimeDiagnostic("info", {
|
|
2541
|
+
component: "CppWorkerClient",
|
|
2542
|
+
runtime: "cpp",
|
|
2543
|
+
phase: "idle-timeout",
|
|
2544
|
+
message: "C++ worker closed after idle timeout."
|
|
2545
|
+
}, { enabled: this.debug });
|
|
2546
|
+
this.terminateAndReset(new Error("C++ worker closed after idle timeout"));
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
if (type === "compile-request") {
|
|
2550
|
+
this.handleCompileRequest(event.data).catch((error) => {
|
|
2551
|
+
if (!event.data.requestId) return;
|
|
2552
|
+
this.worker?.postMessage({
|
|
2553
|
+
type: "compile-response",
|
|
2554
|
+
requestId: event.data.requestId,
|
|
2555
|
+
payload: { success: false, error: error instanceof Error ? error.message : String(error) }
|
|
2556
|
+
});
|
|
2557
|
+
});
|
|
2558
|
+
return;
|
|
2559
|
+
}
|
|
2560
|
+
if (!id) return;
|
|
2561
|
+
const pending = this.pendingMessages.get(id);
|
|
2562
|
+
if (!pending) return;
|
|
2563
|
+
this.pendingMessages.delete(id);
|
|
2564
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
2565
|
+
if (type === "error") {
|
|
2566
|
+
pending.reject(new Error(payload.error));
|
|
2567
|
+
return;
|
|
2568
|
+
}
|
|
2569
|
+
pending.resolve(payload);
|
|
2570
|
+
};
|
|
2571
|
+
this.worker.onerror = (error) => {
|
|
2572
|
+
logRuntimeDiagnostic("error", {
|
|
2573
|
+
component: "CppWorkerClient",
|
|
2574
|
+
runtime: "cpp",
|
|
2575
|
+
phase: "worker-error",
|
|
2576
|
+
message: "C++ worker emitted an error event.",
|
|
2577
|
+
detail: {
|
|
2578
|
+
message: error.message,
|
|
2579
|
+
filename: error.filename,
|
|
2580
|
+
lineno: error.lineno,
|
|
2581
|
+
colno: error.colno
|
|
2582
|
+
}
|
|
2583
|
+
});
|
|
2584
|
+
const workerError = new Error(error.message || "C++ worker error");
|
|
2585
|
+
this.workerReadyReject?.(workerError);
|
|
2586
|
+
this.workerReadyResolve = null;
|
|
2587
|
+
this.workerReadyReject = null;
|
|
2588
|
+
this.terminateAndReset(workerError);
|
|
2589
|
+
};
|
|
2590
|
+
return this.worker;
|
|
2591
|
+
}
|
|
2592
|
+
async waitForWorkerReady() {
|
|
2593
|
+
const readyPromise = this.workerReadyPromise;
|
|
2594
|
+
if (!readyPromise) return;
|
|
2595
|
+
await new Promise((resolve, reject) => {
|
|
2596
|
+
let settled = false;
|
|
2597
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2598
|
+
if (settled) return;
|
|
2599
|
+
settled = true;
|
|
2600
|
+
const timeoutError = new Error(
|
|
2601
|
+
`C++ worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS4 / 1e3)}s)`
|
|
2602
|
+
);
|
|
2603
|
+
logRuntimeDiagnostic("warn", {
|
|
2604
|
+
component: "CppWorkerClient",
|
|
2605
|
+
runtime: "cpp",
|
|
2606
|
+
phase: "worker-ready-timeout",
|
|
2607
|
+
message: "C++ worker did not send worker-ready before the timeout.",
|
|
2608
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS4 }
|
|
2609
|
+
}, { enabled: this.debug });
|
|
2610
|
+
this.terminateAndReset(timeoutError);
|
|
2611
|
+
reject(timeoutError);
|
|
2612
|
+
}, WORKER_READY_TIMEOUT_MS4);
|
|
2613
|
+
readyPromise.then(() => {
|
|
2614
|
+
if (settled) return;
|
|
2615
|
+
settled = true;
|
|
2616
|
+
globalThis.clearTimeout(timeoutId);
|
|
2617
|
+
resolve();
|
|
2618
|
+
}).catch((error) => {
|
|
2619
|
+
if (settled) return;
|
|
2620
|
+
settled = true;
|
|
2621
|
+
globalThis.clearTimeout(timeoutId);
|
|
2622
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2623
|
+
});
|
|
2624
|
+
});
|
|
1521
2625
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
2626
|
+
async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS4) {
|
|
2627
|
+
const worker = this.getWorker();
|
|
2628
|
+
await this.waitForWorkerReady();
|
|
2629
|
+
const id = String(++this.messageId);
|
|
2630
|
+
return new Promise((resolve, reject) => {
|
|
2631
|
+
this.pendingMessages.set(id, {
|
|
2632
|
+
resolve,
|
|
2633
|
+
reject
|
|
2634
|
+
});
|
|
2635
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2636
|
+
const pending2 = this.pendingMessages.get(id);
|
|
2637
|
+
if (!pending2) return;
|
|
2638
|
+
this.pendingMessages.delete(id);
|
|
2639
|
+
logRuntimeDiagnostic("warn", {
|
|
2640
|
+
component: "CppWorkerClient",
|
|
2641
|
+
runtime: "cpp",
|
|
2642
|
+
phase: "worker-request-timeout",
|
|
2643
|
+
message: "C++ worker request timed out.",
|
|
2644
|
+
detail: { id, type, timeoutMs }
|
|
2645
|
+
}, { enabled: this.debug });
|
|
2646
|
+
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
2647
|
+
}, timeoutMs);
|
|
2648
|
+
const pending = this.pendingMessages.get(id);
|
|
2649
|
+
if (pending) pending.timeoutId = timeoutId;
|
|
2650
|
+
worker.postMessage({ id, type, payload });
|
|
2651
|
+
});
|
|
1525
2652
|
}
|
|
1526
|
-
|
|
1527
|
-
return
|
|
2653
|
+
async executeWithTimeout(executor, timeoutMs, stage) {
|
|
2654
|
+
return new Promise((resolve, reject) => {
|
|
2655
|
+
let settled = false;
|
|
2656
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2657
|
+
if (settled) return;
|
|
2658
|
+
settled = true;
|
|
2659
|
+
const timeoutLabel = stage === "trace" ? "tracing" : stage === "interview" ? "interview execution" : "compile/run";
|
|
2660
|
+
const timeoutError = new CppClientTimeoutError(
|
|
2661
|
+
`C++ ${timeoutLabel} timed out after ${Math.round(timeoutMs / 1e3)} seconds.`,
|
|
2662
|
+
stage,
|
|
2663
|
+
timeoutMs
|
|
2664
|
+
);
|
|
2665
|
+
logRuntimeDiagnostic("warn", {
|
|
2666
|
+
component: "CppWorkerClient",
|
|
2667
|
+
runtime: "cpp",
|
|
2668
|
+
phase: "execution-timeout",
|
|
2669
|
+
message: "C++ execution timed out; terminating worker.",
|
|
2670
|
+
detail: { timeoutMs, stage }
|
|
2671
|
+
}, { enabled: this.debug });
|
|
2672
|
+
this.terminateAndReset(timeoutError);
|
|
2673
|
+
reject(timeoutError);
|
|
2674
|
+
}, timeoutMs);
|
|
2675
|
+
executor().then((result) => {
|
|
2676
|
+
if (settled) return;
|
|
2677
|
+
settled = true;
|
|
2678
|
+
globalThis.clearTimeout(timeoutId);
|
|
2679
|
+
resolve(result);
|
|
2680
|
+
}).catch((error) => {
|
|
2681
|
+
if (settled) return;
|
|
2682
|
+
settled = true;
|
|
2683
|
+
globalThis.clearTimeout(timeoutId);
|
|
2684
|
+
reject(error);
|
|
2685
|
+
});
|
|
2686
|
+
});
|
|
1528
2687
|
}
|
|
1529
|
-
|
|
1530
|
-
return
|
|
2688
|
+
isClientTimeout(error) {
|
|
2689
|
+
return error instanceof CppClientTimeoutError || error instanceof Error && error.message.includes("C++") && error.message.includes("timed out");
|
|
1531
2690
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
2691
|
+
timeoutCodeResult(error) {
|
|
2692
|
+
const timeoutError = error instanceof CppClientTimeoutError ? error : null;
|
|
2693
|
+
return {
|
|
2694
|
+
success: false,
|
|
2695
|
+
output: null,
|
|
2696
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2697
|
+
consoleOutput: [],
|
|
2698
|
+
timeoutReason: "client-timeout",
|
|
2699
|
+
diagnosticStage: timeoutError?.stage === "interview" ? "interview" : "runtime",
|
|
2700
|
+
timings: { totalMs: timeoutError?.timeoutMs ?? this.executionTimeoutMs }
|
|
2701
|
+
};
|
|
1535
2702
|
}
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
2703
|
+
timeoutTraceResult(error) {
|
|
2704
|
+
const timeoutError = error instanceof CppClientTimeoutError ? error : null;
|
|
2705
|
+
const trace = createEmptyRuntimeTrace("cpp", { runId: "cpp:run", file: CPP_DEFAULT_FILE });
|
|
2706
|
+
trace.events = [
|
|
2707
|
+
{
|
|
2708
|
+
kind: "timeout",
|
|
2709
|
+
runId: "cpp:run",
|
|
2710
|
+
file: CPP_DEFAULT_FILE,
|
|
2711
|
+
message: error instanceof Error ? error.message : String(error)
|
|
2712
|
+
}
|
|
2713
|
+
];
|
|
2714
|
+
trace.traceStepCount = 1;
|
|
2715
|
+
return {
|
|
2716
|
+
success: false,
|
|
2717
|
+
output: null,
|
|
2718
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2719
|
+
trace,
|
|
2720
|
+
executionTimeMs: timeoutError?.timeoutMs ?? this.tracingTimeoutMs,
|
|
2721
|
+
consoleOutput: [],
|
|
2722
|
+
traceLimitExceeded: true,
|
|
2723
|
+
timeoutReason: "client-timeout",
|
|
2724
|
+
lineEventCount: 0,
|
|
2725
|
+
traceStepCount: 1,
|
|
2726
|
+
timings: { totalMs: timeoutError?.timeoutMs ?? this.tracingTimeoutMs }
|
|
2727
|
+
};
|
|
1542
2728
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
if (
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
if (!Array.isArray(value)) {
|
|
1549
|
-
return true;
|
|
2729
|
+
terminateAndReset(reason = new Error("Worker was terminated")) {
|
|
2730
|
+
this.workerReadyReject?.(reason);
|
|
2731
|
+
if (this.worker) {
|
|
2732
|
+
this.worker.terminate();
|
|
2733
|
+
this.worker = null;
|
|
1550
2734
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
2735
|
+
this.initPromise = null;
|
|
2736
|
+
this.warmupPromise = null;
|
|
2737
|
+
this.workerReadyPromise = null;
|
|
2738
|
+
this.workerReadyResolve = null;
|
|
2739
|
+
this.workerReadyReject = null;
|
|
2740
|
+
for (const [, pending] of this.pendingMessages) {
|
|
2741
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
2742
|
+
pending.reject(reason);
|
|
1553
2743
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
if (entries.length === 0) {
|
|
1557
|
-
return void 0;
|
|
1558
|
-
}
|
|
1559
|
-
return Object.fromEntries(entries);
|
|
1560
|
-
}
|
|
1561
|
-
function appendJavaTraceStep(trace, step, pendingAccesses, options = {}) {
|
|
1562
|
-
const nextStep = pendingAccesses.length > 0 ? { ...step, accesses: [...pendingAccesses] } : step;
|
|
1563
|
-
pendingAccesses.length = 0;
|
|
1564
|
-
if (options.allowMerge !== false && maybeMergeConsecutiveLineStep(trace, nextStep)) {
|
|
1565
|
-
return;
|
|
2744
|
+
this.pendingMessages.clear();
|
|
2745
|
+
this.clearCompilerFrames();
|
|
1566
2746
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
const candidate = trace.at(-1);
|
|
1571
|
-
if (!candidate || candidate.event !== "line") {
|
|
1572
|
-
return false;
|
|
2747
|
+
shouldRetryInit(error) {
|
|
2748
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2749
|
+
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");
|
|
1573
2750
|
}
|
|
1574
|
-
|
|
1575
|
-
return
|
|
2751
|
+
sendInitMessage() {
|
|
2752
|
+
return this.sendMessage(
|
|
2753
|
+
"init",
|
|
2754
|
+
{
|
|
2755
|
+
assets: {
|
|
2756
|
+
clangWasmUrl: this.options.clangWasmUrl,
|
|
2757
|
+
lldWasmUrl: this.options.lldWasmUrl,
|
|
2758
|
+
sysrootUrl: this.options.sysrootUrl,
|
|
2759
|
+
runtimeHeaderUrl: this.options.runtimeHeaderUrl,
|
|
2760
|
+
compilerBundleUrl: this.options.compilerBundleUrl,
|
|
2761
|
+
compilerFrameEnabled: Boolean(this.compilerFrameUrl && typeof document !== "undefined"),
|
|
2762
|
+
compilerFrameUrl: this.compilerFrameUrl,
|
|
2763
|
+
compilerWorkerUrl: this.options.compilerWorkerUrl
|
|
2764
|
+
},
|
|
2765
|
+
...this.workerOptionsPayload()
|
|
2766
|
+
},
|
|
2767
|
+
this.initTimeoutMs
|
|
2768
|
+
);
|
|
1576
2769
|
}
|
|
1577
|
-
|
|
1578
|
-
return
|
|
2770
|
+
async init() {
|
|
2771
|
+
if (this.initPromise) return this.initPromise;
|
|
2772
|
+
this.initPromise = (async () => {
|
|
2773
|
+
try {
|
|
2774
|
+
return await this.sendInitMessage();
|
|
2775
|
+
} catch (error) {
|
|
2776
|
+
if (!this.shouldRetryInit(error)) throw error;
|
|
2777
|
+
this.terminateAndReset(error instanceof Error ? error : new Error(String(error)));
|
|
2778
|
+
return this.sendInitMessage();
|
|
2779
|
+
}
|
|
2780
|
+
})();
|
|
2781
|
+
try {
|
|
2782
|
+
return await this.initPromise;
|
|
2783
|
+
} catch (error) {
|
|
2784
|
+
this.initPromise = null;
|
|
2785
|
+
throw error;
|
|
2786
|
+
}
|
|
1579
2787
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
candidate.accesses = [...candidate.accesses ?? [], ...patch.accesses];
|
|
2788
|
+
workerOptionsPayload() {
|
|
2789
|
+
return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
|
|
1583
2790
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
if (rawEvent === "clear" || rawEvent === "reset") continue;
|
|
1606
|
-
const metadata = extractLineMetadata(rawEvent);
|
|
1607
|
-
const previousEventRawLine = previousRawLine;
|
|
1608
|
-
previousRawLine = metadata.line;
|
|
1609
|
-
const line = lineRemap?.get(metadata.line) ?? metadata.line;
|
|
1610
|
-
const payload = metadata.payload;
|
|
1611
|
-
const isDeclarationLine = declarationLines?.has(line) === true;
|
|
1612
|
-
if (payload.startsWith("call ")) {
|
|
1613
|
-
const match = payload.match(/^call\s+(\S+)(?:\s+(.*))?$/);
|
|
1614
|
-
const functionName = match?.[1] ?? currentFunction;
|
|
1615
|
-
const argsFragment = match?.[2] ?? "";
|
|
1616
|
-
const args = parseKeyValuePairs(argsFragment);
|
|
1617
|
-
Object.assign(variables, args);
|
|
1618
|
-
currentFunction = functionName || currentFunction;
|
|
1619
|
-
stack.push({ function: currentFunction, line, args });
|
|
1620
|
-
appendJavaTraceStep(trace, {
|
|
1621
|
-
line,
|
|
1622
|
-
event: "call",
|
|
1623
|
-
function: currentFunction,
|
|
1624
|
-
variables: { ...variables },
|
|
1625
|
-
callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } }))
|
|
1626
|
-
}, pendingAccesses);
|
|
1627
|
-
continue;
|
|
1628
|
-
}
|
|
1629
|
-
if (payload.startsWith("return ")) {
|
|
1630
|
-
const match = payload.match(/^return\s+(\S+)(?:\s+value=(.*))?$/);
|
|
1631
|
-
const functionName = match?.[1] ?? currentFunction;
|
|
1632
|
-
const returnValue = match?.[2] !== void 0 ? parseScalar(match[2].trim()) : void 0;
|
|
1633
|
-
const returnVariables = functionName === "<module>" ? { ...variables } : filterStructuredVariables(variables) ?? {};
|
|
1634
|
-
appendJavaTraceStep(trace, {
|
|
1635
|
-
line,
|
|
1636
|
-
event: "return",
|
|
1637
|
-
function: functionName || currentFunction,
|
|
1638
|
-
variables: returnVariables,
|
|
1639
|
-
callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
|
|
1640
|
-
...returnValue !== void 0 ? { returnValue } : {}
|
|
1641
|
-
}, pendingAccesses);
|
|
1642
|
-
stack.pop();
|
|
1643
|
-
currentFunction = stack[stack.length - 1]?.function ?? "<module>";
|
|
1644
|
-
continue;
|
|
1645
|
-
}
|
|
1646
|
-
if (isDeclarationLine) {
|
|
1647
|
-
continue;
|
|
2791
|
+
async warmup() {
|
|
2792
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
2793
|
+
this.warmupPromise = (async () => {
|
|
2794
|
+
try {
|
|
2795
|
+
await this.init();
|
|
2796
|
+
return await this.sendMessage("warmup", this.workerOptionsPayload(), this.initTimeoutMs);
|
|
2797
|
+
} catch (error) {
|
|
2798
|
+
this.warmupPromise = null;
|
|
2799
|
+
throw error;
|
|
2800
|
+
}
|
|
2801
|
+
})();
|
|
2802
|
+
return this.warmupPromise;
|
|
2803
|
+
}
|
|
2804
|
+
clearCompilerFrames(reason = new Error("C++ compiler frame was closed")) {
|
|
2805
|
+
this.compilerFrameReadyReject?.(reason);
|
|
2806
|
+
this.compilerFrameReadyPromise = null;
|
|
2807
|
+
this.compilerFrameReadyResolve = null;
|
|
2808
|
+
this.compilerFrameReadyReject = null;
|
|
2809
|
+
if (this.compilerFrameMessageHandler) {
|
|
2810
|
+
globalThis.removeEventListener("message", this.compilerFrameMessageHandler);
|
|
2811
|
+
this.compilerFrameMessageHandler = null;
|
|
1648
2812
|
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
event: "line",
|
|
1653
|
-
function: currentFunction,
|
|
1654
|
-
variables: { ...variables },
|
|
1655
|
-
...stack.length > 0 ? { callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })) } : {}
|
|
1656
|
-
}, pendingAccesses, { allowMerge: previousEventRawLine !== metadata.line });
|
|
1657
|
-
continue;
|
|
2813
|
+
for (const [, pending] of this.pendingCompilerFrameRequests) {
|
|
2814
|
+
globalThis.clearTimeout(pending.timeoutId);
|
|
2815
|
+
pending.resolve({ success: false, error: reason.message });
|
|
1658
2816
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
line,
|
|
1665
|
-
event: "line",
|
|
1666
|
-
function: currentFunction,
|
|
1667
|
-
variables: { ...variables },
|
|
1668
|
-
callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
|
|
1669
|
-
visualization: {
|
|
1670
|
-
objectKinds: { ...objectKinds }
|
|
1671
|
-
}
|
|
1672
|
-
}, pendingAccesses);
|
|
1673
|
-
continue;
|
|
2817
|
+
this.pendingCompilerFrameRequests.clear();
|
|
2818
|
+
this.compilerFrame = null;
|
|
2819
|
+
this.compilerFrameTargetOrigin = "";
|
|
2820
|
+
for (const frame of this.activeCompilerFrames) {
|
|
2821
|
+
frame.remove();
|
|
1674
2822
|
}
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
},
|
|
1689
|
-
|
|
2823
|
+
this.activeCompilerFrames.clear();
|
|
2824
|
+
}
|
|
2825
|
+
async handleCompileRequest(message) {
|
|
2826
|
+
if (!message.requestId) return;
|
|
2827
|
+
const worker = this.worker;
|
|
2828
|
+
if (!worker) return;
|
|
2829
|
+
const result = await this.compileInFrame(message.payload);
|
|
2830
|
+
const transfer = result?.programBuffer instanceof ArrayBuffer ? [result.programBuffer] : [];
|
|
2831
|
+
worker.postMessage(
|
|
2832
|
+
{
|
|
2833
|
+
type: "compile-response",
|
|
2834
|
+
requestId: message.requestId,
|
|
2835
|
+
payload: result
|
|
2836
|
+
},
|
|
2837
|
+
transfer
|
|
2838
|
+
);
|
|
2839
|
+
}
|
|
2840
|
+
ensureCompilerFrame() {
|
|
2841
|
+
if (!this.compilerFrameUrl || typeof document === "undefined") {
|
|
2842
|
+
return Promise.reject(new Error("C++ compiler frame is not available."));
|
|
1690
2843
|
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
2844
|
+
if (this.compilerFrame && this.compilerFrameReadyPromise) return this.compilerFrameReadyPromise;
|
|
2845
|
+
const frameUrl = new URL(this.compilerFrameUrl, globalThis.location?.href);
|
|
2846
|
+
this.compilerFrameTargetOrigin = frameUrl.origin;
|
|
2847
|
+
const iframe = document.createElement("iframe");
|
|
2848
|
+
iframe.src = frameUrl.href;
|
|
2849
|
+
iframe.style.display = "none";
|
|
2850
|
+
iframe.setAttribute("aria-hidden", "true");
|
|
2851
|
+
this.compilerFrame = iframe;
|
|
2852
|
+
this.activeCompilerFrames.add(iframe);
|
|
2853
|
+
this.compilerFrameReadyPromise = new Promise((resolve, reject) => {
|
|
2854
|
+
let settled = false;
|
|
2855
|
+
let timeoutId;
|
|
2856
|
+
const finishReady = () => {
|
|
2857
|
+
if (settled) return;
|
|
2858
|
+
settled = true;
|
|
2859
|
+
globalThis.clearTimeout(timeoutId);
|
|
2860
|
+
this.compilerFrameReadyResolve = null;
|
|
2861
|
+
this.compilerFrameReadyReject = null;
|
|
2862
|
+
resolve();
|
|
2863
|
+
};
|
|
2864
|
+
const onMessage = (event) => {
|
|
2865
|
+
if (event.source !== iframe.contentWindow) return;
|
|
2866
|
+
if (event.origin !== this.compilerFrameTargetOrigin) return;
|
|
2867
|
+
if (event.data?.type === "frame-ready") {
|
|
2868
|
+
finishReady();
|
|
2869
|
+
return;
|
|
1704
2870
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
2871
|
+
const requestId = event.data?.id;
|
|
2872
|
+
if (!requestId) return;
|
|
2873
|
+
const pending = this.pendingCompilerFrameRequests.get(requestId);
|
|
2874
|
+
if (!pending) return;
|
|
2875
|
+
this.pendingCompilerFrameRequests.delete(requestId);
|
|
2876
|
+
globalThis.clearTimeout(pending.timeoutId);
|
|
2877
|
+
const response = event.data;
|
|
2878
|
+
pending.resolve(response.payload ?? { success: false, error: "C++ compiler frame returned an empty response." });
|
|
2879
|
+
};
|
|
2880
|
+
this.compilerFrameMessageHandler = onMessage;
|
|
2881
|
+
timeoutId = globalThis.setTimeout(() => {
|
|
2882
|
+
const error = new Error("C++ compiler frame request timed out.");
|
|
2883
|
+
this.clearCompilerFrames(error);
|
|
2884
|
+
reject(error);
|
|
2885
|
+
}, this.initTimeoutMs);
|
|
2886
|
+
this.compilerFrameReadyResolve = finishReady;
|
|
2887
|
+
this.compilerFrameReadyReject = (error) => {
|
|
2888
|
+
if (settled) return;
|
|
2889
|
+
settled = true;
|
|
2890
|
+
globalThis.clearTimeout(timeoutId);
|
|
2891
|
+
reject(error);
|
|
2892
|
+
};
|
|
2893
|
+
globalThis.addEventListener("message", onMessage);
|
|
2894
|
+
document.body.appendChild(iframe);
|
|
2895
|
+
});
|
|
2896
|
+
return this.compilerFrameReadyPromise;
|
|
2897
|
+
}
|
|
2898
|
+
async compileInFrame(payload) {
|
|
2899
|
+
try {
|
|
2900
|
+
await this.ensureCompilerFrame();
|
|
2901
|
+
} catch (error) {
|
|
2902
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
1707
2903
|
}
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
appendJavaTraceStep(trace, {
|
|
1713
|
-
line,
|
|
1714
|
-
event: "line",
|
|
1715
|
-
function: currentFunction,
|
|
1716
|
-
variables: { ...variables },
|
|
1717
|
-
callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
|
|
1718
|
-
visualization: {
|
|
1719
|
-
objectKinds: { [setState.variable]: "set" },
|
|
1720
|
-
hashMaps: [setState.visualization]
|
|
1721
|
-
}
|
|
1722
|
-
}, pendingAccesses);
|
|
1723
|
-
continue;
|
|
2904
|
+
const iframe = this.compilerFrame;
|
|
2905
|
+
const frameWindow = iframe?.contentWindow;
|
|
2906
|
+
if (!frameWindow) {
|
|
2907
|
+
return { success: false, error: "C++ compiler frame is not available." };
|
|
1724
2908
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
2909
|
+
return new Promise((resolve) => {
|
|
2910
|
+
const requestId = `compile-${++this.compilerFrameRequestId}`;
|
|
2911
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
2912
|
+
this.pendingCompilerFrameRequests.delete(requestId);
|
|
2913
|
+
resolve({ success: false, error: "C++ compiler frame request timed out." });
|
|
2914
|
+
}, this.initTimeoutMs);
|
|
2915
|
+
this.pendingCompilerFrameRequests.set(requestId, { resolve, timeoutId });
|
|
2916
|
+
frameWindow.postMessage(
|
|
2917
|
+
{
|
|
2918
|
+
id: requestId,
|
|
2919
|
+
type: "compile",
|
|
2920
|
+
payload
|
|
2921
|
+
},
|
|
2922
|
+
this.compilerFrameTargetOrigin
|
|
2923
|
+
);
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
async executeCode(code, functionName, inputs, executionStyle) {
|
|
2927
|
+
await this.init();
|
|
2928
|
+
try {
|
|
2929
|
+
return await this.executeWithTimeout(
|
|
2930
|
+
() => this.sendMessage(
|
|
2931
|
+
"compile-run",
|
|
2932
|
+
{ code, functionName, inputs, executionStyle },
|
|
2933
|
+
this.executionTimeoutMs + 5e3
|
|
2934
|
+
),
|
|
2935
|
+
this.executionTimeoutMs,
|
|
2936
|
+
"compile-run"
|
|
2937
|
+
);
|
|
2938
|
+
} catch (error) {
|
|
2939
|
+
if (this.isClientTimeout(error)) return this.timeoutCodeResult(error);
|
|
2940
|
+
throw error;
|
|
1727
2941
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
2942
|
+
}
|
|
2943
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle) {
|
|
2944
|
+
await this.init();
|
|
2945
|
+
try {
|
|
2946
|
+
return await this.executeWithTimeout(
|
|
2947
|
+
() => this.sendMessage(
|
|
2948
|
+
"execute-with-tracing",
|
|
2949
|
+
{ code, functionName, inputs, options, executionStyle },
|
|
2950
|
+
this.tracingTimeoutMs + 5e3
|
|
2951
|
+
),
|
|
2952
|
+
this.tracingTimeoutMs,
|
|
2953
|
+
"trace"
|
|
2954
|
+
);
|
|
2955
|
+
} catch (error) {
|
|
2956
|
+
if (this.isClientTimeout(error)) return this.timeoutTraceResult(error);
|
|
2957
|
+
throw error;
|
|
1736
2958
|
}
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
2959
|
+
}
|
|
2960
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle) {
|
|
2961
|
+
await this.init();
|
|
2962
|
+
try {
|
|
2963
|
+
return await this.executeWithTimeout(
|
|
2964
|
+
() => this.sendMessage(
|
|
2965
|
+
"execute-code-interview",
|
|
2966
|
+
{ code, functionName, inputs, executionStyle },
|
|
2967
|
+
this.interviewTimeoutMs + 5e3
|
|
2968
|
+
),
|
|
2969
|
+
this.interviewTimeoutMs,
|
|
2970
|
+
"interview"
|
|
2971
|
+
);
|
|
2972
|
+
} catch {
|
|
2973
|
+
return {
|
|
2974
|
+
success: false,
|
|
2975
|
+
output: null,
|
|
2976
|
+
error: "Time Limit Exceeded",
|
|
2977
|
+
timeoutReason: "client-timeout",
|
|
2978
|
+
diagnosticStage: "interview",
|
|
2979
|
+
consoleOutput: [],
|
|
2980
|
+
timings: { totalMs: this.interviewTimeoutMs }
|
|
2981
|
+
};
|
|
1757
2982
|
}
|
|
1758
|
-
Object.assign(variables, parseKeyValuePairs(payload));
|
|
1759
|
-
appendJavaTraceStep(trace, {
|
|
1760
|
-
line,
|
|
1761
|
-
event: "line",
|
|
1762
|
-
function: currentFunction,
|
|
1763
|
-
variables: { ...variables },
|
|
1764
|
-
...stack.length > 0 ? { callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })) } : {}
|
|
1765
|
-
}, pendingAccesses);
|
|
1766
2983
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
last.accesses = [...last.accesses ?? [], ...pendingAccesses];
|
|
2984
|
+
terminate() {
|
|
2985
|
+
this.terminateAndReset();
|
|
1770
2986
|
}
|
|
1771
|
-
|
|
1772
|
-
}
|
|
1773
|
-
function buildJavaExecutionResult(output, events, executionTimeMs = 0, traceLimitExceeded, timeoutReason, maxTraceSteps, sourceText, options = {}) {
|
|
1774
|
-
const trace = eventsToRawTrace(events, sourceText);
|
|
1775
|
-
return {
|
|
1776
|
-
success: true,
|
|
1777
|
-
output: options.outputIsSerialized === false ? output : normalizeJavaSerializedResult(output),
|
|
1778
|
-
trace,
|
|
1779
|
-
executionTimeMs,
|
|
1780
|
-
consoleOutput: [],
|
|
1781
|
-
...traceLimitExceeded !== void 0 ? { traceLimitExceeded } : {},
|
|
1782
|
-
...maxTraceSteps !== void 0 ? { maxTraceSteps } : {},
|
|
1783
|
-
...timeoutReason ? { timeoutReason } : {},
|
|
1784
|
-
lineEventCount: trace.filter((step) => step.event === "line").length,
|
|
1785
|
-
traceStepCount: trace.length
|
|
1786
|
-
};
|
|
1787
|
-
}
|
|
1788
|
-
function adaptJavaTraceExecutionResult(result) {
|
|
1789
|
-
return adaptTraceExecutionResult("java", result);
|
|
1790
|
-
}
|
|
2987
|
+
};
|
|
1791
2988
|
|
|
1792
|
-
// packages/harness-browser/src/
|
|
1793
|
-
var
|
|
2989
|
+
// packages/harness-browser/src/cpp-runtime-client.ts
|
|
2990
|
+
var CppRuntimeClient = class {
|
|
1794
2991
|
constructor(workerClient) {
|
|
1795
2992
|
this.workerClient = workerClient;
|
|
1796
2993
|
}
|
|
1797
2994
|
async init() {
|
|
1798
2995
|
return this.workerClient.init();
|
|
1799
2996
|
}
|
|
1800
|
-
async executeWithTracing(code, functionName, inputs, options, executionStyle = "
|
|
1801
|
-
assertRuntimeRequestSupported(getLanguageRuntimeProfile("
|
|
2997
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle = "solution-method") {
|
|
2998
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("cpp"), {
|
|
1802
2999
|
request: "trace",
|
|
1803
3000
|
executionStyle,
|
|
1804
3001
|
functionName
|
|
1805
3002
|
});
|
|
1806
|
-
|
|
3003
|
+
return this.workerClient.executeWithTracing(
|
|
1807
3004
|
code,
|
|
1808
3005
|
functionName ?? "",
|
|
1809
3006
|
inputs,
|
|
1810
3007
|
options,
|
|
1811
3008
|
executionStyle
|
|
1812
3009
|
);
|
|
1813
|
-
if (!rawResult.success) {
|
|
1814
|
-
return {
|
|
1815
|
-
success: false,
|
|
1816
|
-
error: rawResult.error ?? "Java tracing failed",
|
|
1817
|
-
...rawResult.errorLine !== void 0 ? { errorLine: rawResult.errorLine } : {},
|
|
1818
|
-
trace: [],
|
|
1819
|
-
executionTimeMs: rawResult.executionTimeMs,
|
|
1820
|
-
consoleOutput: rawResult.consoleOutput,
|
|
1821
|
-
...rawResult.traceLimitExceeded !== void 0 ? { traceLimitExceeded: rawResult.traceLimitExceeded } : {},
|
|
1822
|
-
...rawResult.timeoutReason ? { timeoutReason: rawResult.timeoutReason } : {},
|
|
1823
|
-
lineEventCount: 0,
|
|
1824
|
-
traceStepCount: 0
|
|
1825
|
-
};
|
|
1826
|
-
}
|
|
1827
|
-
const adapted = adaptJavaTraceExecutionResult(
|
|
1828
|
-
buildJavaExecutionResult(
|
|
1829
|
-
rawResult.output,
|
|
1830
|
-
rawResult.events,
|
|
1831
|
-
rawResult.executionTimeMs,
|
|
1832
|
-
rawResult.traceLimitExceeded,
|
|
1833
|
-
rawResult.timeoutReason,
|
|
1834
|
-
void 0,
|
|
1835
|
-
rawResult.sourceText,
|
|
1836
|
-
{ outputIsSerialized: false }
|
|
1837
|
-
)
|
|
1838
|
-
);
|
|
1839
|
-
return {
|
|
1840
|
-
...adapted,
|
|
1841
|
-
consoleOutput: rawResult.consoleOutput,
|
|
1842
|
-
executionTimeMs: rawResult.executionTimeMs
|
|
1843
|
-
};
|
|
1844
3010
|
}
|
|
1845
|
-
async executeCode(code, functionName, inputs, executionStyle = "
|
|
1846
|
-
assertRuntimeRequestSupported(getLanguageRuntimeProfile("
|
|
3011
|
+
async executeCode(code, functionName, inputs, executionStyle = "solution-method") {
|
|
3012
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("cpp"), {
|
|
1847
3013
|
request: "execute",
|
|
1848
3014
|
executionStyle,
|
|
1849
3015
|
functionName
|
|
@@ -1852,12 +3018,11 @@ var JavaRuntimeClient = class {
|
|
|
1852
3018
|
code,
|
|
1853
3019
|
functionName,
|
|
1854
3020
|
inputs,
|
|
1855
|
-
void 0,
|
|
1856
3021
|
executionStyle
|
|
1857
3022
|
);
|
|
1858
3023
|
}
|
|
1859
|
-
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "
|
|
1860
|
-
assertRuntimeRequestSupported(getLanguageRuntimeProfile("
|
|
3024
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "solution-method") {
|
|
3025
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("cpp"), {
|
|
1861
3026
|
request: "interview",
|
|
1862
3027
|
executionStyle,
|
|
1863
3028
|
functionName
|
|
@@ -1866,23 +3031,22 @@ var JavaRuntimeClient = class {
|
|
|
1866
3031
|
code,
|
|
1867
3032
|
functionName,
|
|
1868
3033
|
inputs,
|
|
1869
|
-
void 0,
|
|
1870
3034
|
executionStyle
|
|
1871
3035
|
);
|
|
1872
3036
|
}
|
|
1873
3037
|
};
|
|
1874
|
-
function
|
|
1875
|
-
return new
|
|
3038
|
+
function createCppRuntimeClient(workerClient) {
|
|
3039
|
+
return new CppRuntimeClient(workerClient);
|
|
1876
3040
|
}
|
|
1877
3041
|
|
|
1878
3042
|
// packages/harness-browser/src/pyodide-worker-client.ts
|
|
1879
|
-
var
|
|
1880
|
-
var
|
|
1881
|
-
var
|
|
1882
|
-
var
|
|
1883
|
-
var
|
|
1884
|
-
var
|
|
1885
|
-
var
|
|
3043
|
+
var EXECUTION_TIMEOUT_MS5 = 1e4;
|
|
3044
|
+
var INTERVIEW_MODE_TIMEOUT_MS4 = 5e3;
|
|
3045
|
+
var TRACING_TIMEOUT_MS5 = 3e4;
|
|
3046
|
+
var INIT_TIMEOUT_MS5 = 12e4;
|
|
3047
|
+
var MESSAGE_TIMEOUT_MS5 = 2e4;
|
|
3048
|
+
var WORKER_READY_TIMEOUT_MS5 = 1e4;
|
|
3049
|
+
var PythonWorkerClient = class {
|
|
1886
3050
|
constructor(options) {
|
|
1887
3051
|
this.options = options;
|
|
1888
3052
|
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
@@ -1892,6 +3056,7 @@ var PyodideWorkerClient = class {
|
|
|
1892
3056
|
messageId = 0;
|
|
1893
3057
|
isInitializing = false;
|
|
1894
3058
|
initPromise = null;
|
|
3059
|
+
warmupPromise = null;
|
|
1895
3060
|
workerReadyPromise = null;
|
|
1896
3061
|
workerReadyResolve = null;
|
|
1897
3062
|
workerReadyReject = null;
|
|
@@ -1922,11 +3087,22 @@ var PyodideWorkerClient = class {
|
|
|
1922
3087
|
this.workerReadyResolve?.();
|
|
1923
3088
|
this.workerReadyResolve = null;
|
|
1924
3089
|
this.workerReadyReject = null;
|
|
1925
|
-
|
|
3090
|
+
logRuntimeDiagnostic("info", {
|
|
3091
|
+
component: "PythonWorkerClient",
|
|
3092
|
+
runtime: "python",
|
|
3093
|
+
phase: "worker-ready",
|
|
3094
|
+
message: "Python worker is ready."
|
|
3095
|
+
}, { enabled: this.debug });
|
|
1926
3096
|
return;
|
|
1927
3097
|
}
|
|
1928
3098
|
if (this.debug && !id) {
|
|
1929
|
-
|
|
3099
|
+
logRuntimeDiagnostic("debug", {
|
|
3100
|
+
component: "PythonWorkerClient",
|
|
3101
|
+
runtime: "python",
|
|
3102
|
+
phase: "worker-event",
|
|
3103
|
+
message: "Python worker emitted an unsolicited event.",
|
|
3104
|
+
detail: { type, payload }
|
|
3105
|
+
}, { enabled: this.debug });
|
|
1930
3106
|
}
|
|
1931
3107
|
if (id) {
|
|
1932
3108
|
const pending = this.pendingMessages.get(id);
|
|
@@ -1936,14 +3112,31 @@ var PyodideWorkerClient = class {
|
|
|
1936
3112
|
if (type === "error") {
|
|
1937
3113
|
pending.reject(new Error(payload.error));
|
|
1938
3114
|
} else {
|
|
1939
|
-
|
|
3115
|
+
logRuntimeDiagnostic("debug", {
|
|
3116
|
+
component: "PythonWorkerClient",
|
|
3117
|
+
runtime: "python",
|
|
3118
|
+
phase: "worker-response",
|
|
3119
|
+
message: "Python worker response received.",
|
|
3120
|
+
detail: { id, type }
|
|
3121
|
+
}, { enabled: this.debug });
|
|
1940
3122
|
pending.resolve(payload);
|
|
1941
3123
|
}
|
|
1942
3124
|
}
|
|
1943
3125
|
}
|
|
1944
3126
|
};
|
|
1945
3127
|
this.worker.onerror = (error) => {
|
|
1946
|
-
|
|
3128
|
+
logRuntimeDiagnostic("error", {
|
|
3129
|
+
component: "PythonWorkerClient",
|
|
3130
|
+
runtime: "python",
|
|
3131
|
+
phase: "worker-error",
|
|
3132
|
+
message: "Python worker emitted an error event.",
|
|
3133
|
+
detail: {
|
|
3134
|
+
message: error.message,
|
|
3135
|
+
filename: error.filename,
|
|
3136
|
+
lineno: error.lineno,
|
|
3137
|
+
colno: error.colno
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
1947
3140
|
const workerError = new Error("Worker error");
|
|
1948
3141
|
this.workerReadyReject?.(workerError);
|
|
1949
3142
|
this.workerReadyResolve = null;
|
|
@@ -1971,14 +3164,18 @@ var PyodideWorkerClient = class {
|
|
|
1971
3164
|
if (settled) return;
|
|
1972
3165
|
settled = true;
|
|
1973
3166
|
const timeoutError = new Error(
|
|
1974
|
-
`Python worker failed to initialize in time (${Math.round(
|
|
3167
|
+
`Python worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS5 / 1e3)}s)`
|
|
1975
3168
|
);
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
3169
|
+
logRuntimeDiagnostic("warn", {
|
|
3170
|
+
component: "PythonWorkerClient",
|
|
3171
|
+
runtime: "python",
|
|
3172
|
+
phase: "worker-ready-timeout",
|
|
3173
|
+
message: "Python worker did not send worker-ready before the timeout.",
|
|
3174
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS5 }
|
|
3175
|
+
}, { enabled: this.debug });
|
|
1979
3176
|
this.terminateAndReset(timeoutError);
|
|
1980
3177
|
reject(timeoutError);
|
|
1981
|
-
},
|
|
3178
|
+
}, WORKER_READY_TIMEOUT_MS5);
|
|
1982
3179
|
readyPromise.then(() => {
|
|
1983
3180
|
if (settled) return;
|
|
1984
3181
|
settled = true;
|
|
@@ -1995,7 +3192,7 @@ var PyodideWorkerClient = class {
|
|
|
1995
3192
|
/**
|
|
1996
3193
|
* Send a message to the worker and wait for a response
|
|
1997
3194
|
*/
|
|
1998
|
-
async sendMessage(type, payload, timeoutMs =
|
|
3195
|
+
async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS5) {
|
|
1999
3196
|
const worker = this.getWorker();
|
|
2000
3197
|
await this.waitForWorkerReady();
|
|
2001
3198
|
const id = String(++this.messageId);
|
|
@@ -2004,12 +3201,24 @@ var PyodideWorkerClient = class {
|
|
|
2004
3201
|
resolve,
|
|
2005
3202
|
reject
|
|
2006
3203
|
});
|
|
2007
|
-
|
|
3204
|
+
logRuntimeDiagnostic("debug", {
|
|
3205
|
+
component: "PythonWorkerClient",
|
|
3206
|
+
runtime: "python",
|
|
3207
|
+
phase: "worker-request",
|
|
3208
|
+
message: "Sending request to Python worker.",
|
|
3209
|
+
detail: { id, type }
|
|
3210
|
+
}, { enabled: this.debug });
|
|
2008
3211
|
const timeoutId = globalThis.setTimeout(() => {
|
|
2009
3212
|
const pending2 = this.pendingMessages.get(id);
|
|
2010
3213
|
if (!pending2) return;
|
|
2011
3214
|
this.pendingMessages.delete(id);
|
|
2012
|
-
|
|
3215
|
+
logRuntimeDiagnostic("warn", {
|
|
3216
|
+
component: "PythonWorkerClient",
|
|
3217
|
+
runtime: "python",
|
|
3218
|
+
phase: "worker-request-timeout",
|
|
3219
|
+
message: "Python worker request timed out.",
|
|
3220
|
+
detail: { id, type, timeoutMs }
|
|
3221
|
+
}, { enabled: this.debug });
|
|
2013
3222
|
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
2014
3223
|
}, timeoutMs);
|
|
2015
3224
|
const pending = this.pendingMessages.get(id);
|
|
@@ -2020,15 +3229,19 @@ var PyodideWorkerClient = class {
|
|
|
2020
3229
|
/**
|
|
2021
3230
|
* Execute code with a timeout - terminates worker if execution takes too long
|
|
2022
3231
|
*/
|
|
2023
|
-
async executeWithTimeout(executor, timeoutMs =
|
|
3232
|
+
async executeWithTimeout(executor, timeoutMs = EXECUTION_TIMEOUT_MS5) {
|
|
2024
3233
|
return new Promise((resolve, reject) => {
|
|
2025
3234
|
let settled = false;
|
|
2026
3235
|
const timeoutId = globalThis.setTimeout(() => {
|
|
2027
3236
|
if (settled) return;
|
|
2028
3237
|
settled = true;
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
3238
|
+
logRuntimeDiagnostic("warn", {
|
|
3239
|
+
component: "PythonWorkerClient",
|
|
3240
|
+
runtime: "python",
|
|
3241
|
+
phase: "execution-timeout",
|
|
3242
|
+
message: "Python execution timed out; terminating worker.",
|
|
3243
|
+
detail: { timeoutMs }
|
|
3244
|
+
}, { enabled: this.debug });
|
|
2032
3245
|
this.terminateAndReset();
|
|
2033
3246
|
const seconds = Math.round(timeoutMs / 1e3);
|
|
2034
3247
|
reject(new Error(`Execution timed out (possible infinite loop). Code execution was stopped after ${seconds} seconds.`));
|
|
@@ -2056,6 +3269,7 @@ var PyodideWorkerClient = class {
|
|
|
2056
3269
|
this.worker = null;
|
|
2057
3270
|
}
|
|
2058
3271
|
this.initPromise = null;
|
|
3272
|
+
this.warmupPromise = null;
|
|
2059
3273
|
this.isInitializing = false;
|
|
2060
3274
|
this.workerReadyPromise = null;
|
|
2061
3275
|
this.workerReadyResolve = null;
|
|
@@ -2066,7 +3280,7 @@ var PyodideWorkerClient = class {
|
|
|
2066
3280
|
this.pendingMessages.clear();
|
|
2067
3281
|
}
|
|
2068
3282
|
/**
|
|
2069
|
-
* Initialize
|
|
3283
|
+
* Initialize the Python worker. Runtime loading is lazy unless warmup() is called.
|
|
2070
3284
|
*/
|
|
2071
3285
|
async init() {
|
|
2072
3286
|
if (this.initPromise) {
|
|
@@ -2079,18 +3293,22 @@ var PyodideWorkerClient = class {
|
|
|
2079
3293
|
this.isInitializing = true;
|
|
2080
3294
|
this.initPromise = (async () => {
|
|
2081
3295
|
try {
|
|
2082
|
-
return await this.sendMessage("init", void 0,
|
|
3296
|
+
return await this.sendMessage("init", void 0, INIT_TIMEOUT_MS5);
|
|
2083
3297
|
} catch (error) {
|
|
2084
3298
|
const message = error instanceof Error ? error.message : String(error);
|
|
2085
3299
|
const shouldRetry = message.includes("Worker request timed out: init") || message.includes("Worker was terminated") || message.includes("Worker error") || message.includes("failed to initialize in time");
|
|
2086
3300
|
if (!shouldRetry) {
|
|
2087
3301
|
throw error;
|
|
2088
3302
|
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
3303
|
+
logRuntimeDiagnostic("warn", {
|
|
3304
|
+
component: "PythonWorkerClient",
|
|
3305
|
+
runtime: "python",
|
|
3306
|
+
phase: "init-retry",
|
|
3307
|
+
message: "Python worker init failed; resetting worker and retrying once.",
|
|
3308
|
+
detail: { message }
|
|
3309
|
+
}, { enabled: this.debug });
|
|
2092
3310
|
this.terminateAndReset();
|
|
2093
|
-
return this.sendMessage("init", void 0,
|
|
3311
|
+
return this.sendMessage("init", void 0, INIT_TIMEOUT_MS5);
|
|
2094
3312
|
}
|
|
2095
3313
|
})();
|
|
2096
3314
|
try {
|
|
@@ -2103,6 +3321,19 @@ var PyodideWorkerClient = class {
|
|
|
2103
3321
|
this.isInitializing = false;
|
|
2104
3322
|
}
|
|
2105
3323
|
}
|
|
3324
|
+
async warmup() {
|
|
3325
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
3326
|
+
this.warmupPromise = (async () => {
|
|
3327
|
+
try {
|
|
3328
|
+
await this.init();
|
|
3329
|
+
return await this.sendMessage("warmup", void 0, INIT_TIMEOUT_MS5);
|
|
3330
|
+
} catch (error) {
|
|
3331
|
+
this.warmupPromise = null;
|
|
3332
|
+
throw error;
|
|
3333
|
+
}
|
|
3334
|
+
})();
|
|
3335
|
+
return this.warmupPromise;
|
|
3336
|
+
}
|
|
2106
3337
|
/**
|
|
2107
3338
|
* Execute Python code with tracing for step-by-step visualization
|
|
2108
3339
|
* @param options.maxLineEvents - Max line events before abort (for complexity analysis, use higher values)
|
|
@@ -2117,9 +3348,9 @@ var PyodideWorkerClient = class {
|
|
|
2117
3348
|
inputs,
|
|
2118
3349
|
executionStyle,
|
|
2119
3350
|
options
|
|
2120
|
-
},
|
|
3351
|
+
}, TRACING_TIMEOUT_MS5 + 5e3),
|
|
2121
3352
|
// Message timeout slightly longer than execution timeout
|
|
2122
|
-
|
|
3353
|
+
TRACING_TIMEOUT_MS5
|
|
2123
3354
|
);
|
|
2124
3355
|
} catch (error) {
|
|
2125
3356
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -2128,8 +3359,8 @@ var PyodideWorkerClient = class {
|
|
|
2128
3359
|
return {
|
|
2129
3360
|
success: false,
|
|
2130
3361
|
error: errorMessage,
|
|
2131
|
-
trace:
|
|
2132
|
-
executionTimeMs:
|
|
3362
|
+
trace: createEmptyRuntimeTrace("python", { runId: "python:run", file: "solution.py" }),
|
|
3363
|
+
executionTimeMs: TRACING_TIMEOUT_MS5,
|
|
2133
3364
|
consoleOutput: [],
|
|
2134
3365
|
traceLimitExceeded: true,
|
|
2135
3366
|
timeoutReason: "client-timeout",
|
|
@@ -2151,8 +3382,8 @@ var PyodideWorkerClient = class {
|
|
|
2151
3382
|
functionName,
|
|
2152
3383
|
inputs,
|
|
2153
3384
|
executionStyle
|
|
2154
|
-
},
|
|
2155
|
-
|
|
3385
|
+
}, EXECUTION_TIMEOUT_MS5 + 5e3),
|
|
3386
|
+
EXECUTION_TIMEOUT_MS5
|
|
2156
3387
|
);
|
|
2157
3388
|
}
|
|
2158
3389
|
/**
|
|
@@ -2168,8 +3399,8 @@ var PyodideWorkerClient = class {
|
|
|
2168
3399
|
functionName,
|
|
2169
3400
|
inputs,
|
|
2170
3401
|
executionStyle
|
|
2171
|
-
},
|
|
2172
|
-
|
|
3402
|
+
}, INTERVIEW_MODE_TIMEOUT_MS4 + 2e3),
|
|
3403
|
+
INTERVIEW_MODE_TIMEOUT_MS4
|
|
2173
3404
|
);
|
|
2174
3405
|
if (!result.success && result.error) {
|
|
2175
3406
|
const normalizedError = result.error.toLowerCase();
|
|
@@ -2224,11 +3455,6 @@ var PyodideWorkerClient = class {
|
|
|
2224
3455
|
}
|
|
2225
3456
|
};
|
|
2226
3457
|
|
|
2227
|
-
// packages/harness-core/src/trace-adapters/python.ts
|
|
2228
|
-
function adaptPythonTraceExecutionResult(result) {
|
|
2229
|
-
return adaptTraceExecutionResult("python", result);
|
|
2230
|
-
}
|
|
2231
|
-
|
|
2232
3458
|
// packages/harness-browser/src/python-runtime-client.ts
|
|
2233
3459
|
var PythonRuntimeClient = class {
|
|
2234
3460
|
constructor(workerClient) {
|
|
@@ -2243,14 +3469,13 @@ var PythonRuntimeClient = class {
|
|
|
2243
3469
|
executionStyle,
|
|
2244
3470
|
functionName
|
|
2245
3471
|
});
|
|
2246
|
-
|
|
3472
|
+
return this.workerClient.executeWithTracing(
|
|
2247
3473
|
code,
|
|
2248
3474
|
functionName,
|
|
2249
3475
|
inputs,
|
|
2250
3476
|
options,
|
|
2251
3477
|
executionStyle
|
|
2252
3478
|
);
|
|
2253
|
-
return adaptPythonTraceExecutionResult(rawResult);
|
|
2254
3479
|
}
|
|
2255
3480
|
async executeCode(code, functionName, inputs, executionStyle = "function") {
|
|
2256
3481
|
assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
|
|
@@ -2291,7 +3516,17 @@ var DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS = Object.freeze({
|
|
|
2291
3516
|
pythonSnippets: "generated-python-harness-snippets.js",
|
|
2292
3517
|
javascriptWorker: "javascript-worker.js",
|
|
2293
3518
|
javaWorker: "java-worker.js",
|
|
2294
|
-
|
|
3519
|
+
csharpWorker: "csharp-worker.js",
|
|
3520
|
+
csharpAssetBaseUrl: "vendor/csharp",
|
|
3521
|
+
typescriptCompiler: "vendor/typescript.js",
|
|
3522
|
+
cppWorker: "cpp-worker.js",
|
|
3523
|
+
cppCompilerFrame: "cpp-compiler-frame.html",
|
|
3524
|
+
cppCompilerWorker: "cpp-compiler-worker.js",
|
|
3525
|
+
cppClangWasm: "",
|
|
3526
|
+
cppLldWasm: "",
|
|
3527
|
+
cppSysroot: "",
|
|
3528
|
+
cppRuntimeHeader: "cpp/tracecode_runtime.hpp",
|
|
3529
|
+
cppCompilerBundle: "vendor/cpp/yowasp/bundle.js"
|
|
2295
3530
|
});
|
|
2296
3531
|
function isExplicitAssetPath(pathname) {
|
|
2297
3532
|
return pathname.startsWith("/") || pathname.startsWith("./") || pathname.startsWith("../") || pathname.startsWith("http://") || pathname.startsWith("https://") || pathname.startsWith("data:") || pathname.startsWith("blob:");
|
|
@@ -2303,6 +3538,9 @@ function trimLeadingSlash(value) {
|
|
|
2303
3538
|
return value.replace(/^\/+/, "");
|
|
2304
3539
|
}
|
|
2305
3540
|
function resolveAssetPath(baseUrl, pathname) {
|
|
3541
|
+
if (pathname === "") {
|
|
3542
|
+
return "";
|
|
3543
|
+
}
|
|
2306
3544
|
if (isExplicitAssetPath(pathname)) {
|
|
2307
3545
|
return pathname;
|
|
2308
3546
|
}
|
|
@@ -2325,9 +3563,34 @@ function resolveBrowserHarnessAssets(options = {}) {
|
|
|
2325
3563
|
assets.javascriptWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.javascriptWorker
|
|
2326
3564
|
),
|
|
2327
3565
|
javaWorker: resolveAssetPath(assetBaseUrl, assets.javaWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.javaWorker),
|
|
3566
|
+
csharpWorker: resolveAssetPath(assetBaseUrl, assets.csharpWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.csharpWorker),
|
|
3567
|
+
csharpAssetBaseUrl: resolveAssetPath(
|
|
3568
|
+
assetBaseUrl,
|
|
3569
|
+
assets.csharpAssetBaseUrl ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.csharpAssetBaseUrl
|
|
3570
|
+
),
|
|
2328
3571
|
typescriptCompiler: resolveAssetPath(
|
|
2329
3572
|
assetBaseUrl,
|
|
2330
3573
|
assets.typescriptCompiler ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.typescriptCompiler
|
|
3574
|
+
),
|
|
3575
|
+
cppWorker: resolveAssetPath(assetBaseUrl, assets.cppWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppWorker),
|
|
3576
|
+
cppCompilerFrame: resolveAssetPath(
|
|
3577
|
+
assetBaseUrl,
|
|
3578
|
+
assets.cppCompilerFrame ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppCompilerFrame
|
|
3579
|
+
),
|
|
3580
|
+
cppCompilerWorker: resolveAssetPath(
|
|
3581
|
+
assetBaseUrl,
|
|
3582
|
+
assets.cppCompilerWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppCompilerWorker
|
|
3583
|
+
),
|
|
3584
|
+
cppClangWasm: resolveAssetPath(assetBaseUrl, assets.cppClangWasm ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppClangWasm),
|
|
3585
|
+
cppLldWasm: resolveAssetPath(assetBaseUrl, assets.cppLldWasm ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppLldWasm),
|
|
3586
|
+
cppSysroot: resolveAssetPath(assetBaseUrl, assets.cppSysroot ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppSysroot),
|
|
3587
|
+
cppRuntimeHeader: resolveAssetPath(
|
|
3588
|
+
assetBaseUrl,
|
|
3589
|
+
assets.cppRuntimeHeader ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppRuntimeHeader
|
|
3590
|
+
),
|
|
3591
|
+
cppCompilerBundle: resolveAssetPath(
|
|
3592
|
+
assetBaseUrl,
|
|
3593
|
+
assets.cppCompilerBundle ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppCompilerBundle
|
|
2331
3594
|
)
|
|
2332
3595
|
};
|
|
2333
3596
|
}
|
|
@@ -2339,10 +3602,12 @@ var BrowserHarnessRuntime = class {
|
|
|
2339
3602
|
pythonWorkerClient;
|
|
2340
3603
|
javaScriptWorkerClient;
|
|
2341
3604
|
javaWorkerClient;
|
|
3605
|
+
csharpWorkerClient;
|
|
3606
|
+
cppWorkerClient;
|
|
2342
3607
|
clients;
|
|
2343
3608
|
constructor(options = {}) {
|
|
2344
3609
|
this.assets = resolveBrowserHarnessAssets(options);
|
|
2345
|
-
this.pythonWorkerClient = new
|
|
3610
|
+
this.pythonWorkerClient = new PythonWorkerClient({
|
|
2346
3611
|
workerUrl: this.assets.pythonWorker,
|
|
2347
3612
|
debug: options.debug
|
|
2348
3613
|
});
|
|
@@ -2352,13 +3617,38 @@ var BrowserHarnessRuntime = class {
|
|
|
2352
3617
|
});
|
|
2353
3618
|
this.javaWorkerClient = new JavaWorkerClient({
|
|
2354
3619
|
workerUrl: this.assets.javaWorker,
|
|
2355
|
-
debug: options.debug
|
|
3620
|
+
debug: options.debug,
|
|
3621
|
+
workerIdleTimeoutMs: options.java?.workerIdleTimeoutMs
|
|
3622
|
+
});
|
|
3623
|
+
this.csharpWorkerClient = new CSharpWorkerClient({
|
|
3624
|
+
workerUrl: this.assets.csharpWorker,
|
|
3625
|
+
assetBaseUrl: this.assets.csharpAssetBaseUrl,
|
|
3626
|
+
debug: options.debug,
|
|
3627
|
+
workerIdleTimeoutMs: options.csharp?.workerIdleTimeoutMs
|
|
3628
|
+
});
|
|
3629
|
+
this.cppWorkerClient = new CppWorkerClient({
|
|
3630
|
+
workerUrl: this.assets.cppWorker,
|
|
3631
|
+
compilerFrameUrl: this.assets.cppCompilerFrame,
|
|
3632
|
+
compilerWorkerUrl: this.assets.cppCompilerWorker,
|
|
3633
|
+
clangWasmUrl: this.assets.cppClangWasm,
|
|
3634
|
+
lldWasmUrl: this.assets.cppLldWasm,
|
|
3635
|
+
sysrootUrl: this.assets.cppSysroot,
|
|
3636
|
+
runtimeHeaderUrl: this.assets.cppRuntimeHeader,
|
|
3637
|
+
compilerBundleUrl: this.assets.cppCompilerBundle,
|
|
3638
|
+
debug: options.debug,
|
|
3639
|
+
initTimeoutMs: options.cpp?.initTimeoutMs,
|
|
3640
|
+
executionTimeoutMs: options.cpp?.executionTimeoutMs,
|
|
3641
|
+
tracingTimeoutMs: options.cpp?.tracingTimeoutMs,
|
|
3642
|
+
interviewTimeoutMs: options.cpp?.interviewTimeoutMs,
|
|
3643
|
+
workerIdleTimeoutMs: options.cpp?.workerIdleTimeoutMs
|
|
2356
3644
|
});
|
|
2357
3645
|
this.clients = {
|
|
2358
3646
|
python: createPythonRuntimeClient(this.pythonWorkerClient),
|
|
2359
3647
|
javascript: createJavaScriptRuntimeClient("javascript", this.javaScriptWorkerClient),
|
|
2360
3648
|
typescript: createJavaScriptRuntimeClient("typescript", this.javaScriptWorkerClient),
|
|
2361
|
-
java: createJavaRuntimeClient(this.javaWorkerClient)
|
|
3649
|
+
java: createJavaRuntimeClient(this.javaWorkerClient),
|
|
3650
|
+
csharp: createCSharpRuntimeClient(this.csharpWorkerClient),
|
|
3651
|
+
cpp: createCppRuntimeClient(this.cppWorkerClient)
|
|
2362
3652
|
};
|
|
2363
3653
|
}
|
|
2364
3654
|
getClient(language) {
|
|
@@ -2374,9 +3664,33 @@ var BrowserHarnessRuntime = class {
|
|
|
2374
3664
|
getSupportedLanguageProfiles() {
|
|
2375
3665
|
return getSupportedLanguageProfiles();
|
|
2376
3666
|
}
|
|
3667
|
+
getLanguageInfo(language) {
|
|
3668
|
+
return getLanguageRuntimeInfo(language);
|
|
3669
|
+
}
|
|
3670
|
+
getSupportedLanguageInfos() {
|
|
3671
|
+
return getSupportedLanguageRuntimeInfos();
|
|
3672
|
+
}
|
|
2377
3673
|
isLanguageSupported(language) {
|
|
2378
3674
|
return isLanguageSupported(language);
|
|
2379
3675
|
}
|
|
3676
|
+
warmLanguage(language) {
|
|
3677
|
+
if (language === "python") {
|
|
3678
|
+
return this.pythonWorkerClient.warmup();
|
|
3679
|
+
}
|
|
3680
|
+
if (language === "java") {
|
|
3681
|
+
return this.javaWorkerClient.warmup();
|
|
3682
|
+
}
|
|
3683
|
+
if (language === "cpp") {
|
|
3684
|
+
return this.cppWorkerClient.warmup();
|
|
3685
|
+
}
|
|
3686
|
+
if (language === "csharp") {
|
|
3687
|
+
return this.csharpWorkerClient.warmup();
|
|
3688
|
+
}
|
|
3689
|
+
if (language === "typescript") {
|
|
3690
|
+
return this.javaScriptWorkerClient.warmup("typescript");
|
|
3691
|
+
}
|
|
3692
|
+
return this.getClient(language).init();
|
|
3693
|
+
}
|
|
2380
3694
|
disposeLanguage(language) {
|
|
2381
3695
|
if (language === "python") {
|
|
2382
3696
|
this.pythonWorkerClient.terminate();
|
|
@@ -2386,12 +3700,22 @@ var BrowserHarnessRuntime = class {
|
|
|
2386
3700
|
this.javaWorkerClient.terminate();
|
|
2387
3701
|
return;
|
|
2388
3702
|
}
|
|
3703
|
+
if (language === "csharp") {
|
|
3704
|
+
this.csharpWorkerClient.terminate();
|
|
3705
|
+
return;
|
|
3706
|
+
}
|
|
3707
|
+
if (language === "cpp") {
|
|
3708
|
+
this.cppWorkerClient.terminate();
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
2389
3711
|
this.javaScriptWorkerClient.terminate();
|
|
2390
3712
|
}
|
|
2391
3713
|
dispose() {
|
|
2392
3714
|
this.pythonWorkerClient.terminate();
|
|
2393
3715
|
this.javaScriptWorkerClient.terminate();
|
|
2394
3716
|
this.javaWorkerClient.terminate();
|
|
3717
|
+
this.csharpWorkerClient.terminate();
|
|
3718
|
+
this.cppWorkerClient.terminate();
|
|
2395
3719
|
}
|
|
2396
3720
|
};
|
|
2397
3721
|
function createBrowserHarness(options = {}) {
|
|
@@ -2400,12 +3724,16 @@ function createBrowserHarness(options = {}) {
|
|
|
2400
3724
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2401
3725
|
0 && (module.exports = {
|
|
2402
3726
|
DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS,
|
|
3727
|
+
LANGUAGE_RUNTIME_INFOS,
|
|
2403
3728
|
LANGUAGE_RUNTIME_PROFILES,
|
|
2404
3729
|
SUPPORTED_LANGUAGES,
|
|
3730
|
+
SUPPORTED_LANGUAGE_RUNTIME_INFOS,
|
|
2405
3731
|
assertRuntimeRequestSupported,
|
|
2406
3732
|
createBrowserHarness,
|
|
3733
|
+
getLanguageRuntimeInfo,
|
|
2407
3734
|
getLanguageRuntimeProfile,
|
|
2408
3735
|
getSupportedLanguageProfiles,
|
|
3736
|
+
getSupportedLanguageRuntimeInfos,
|
|
2409
3737
|
isLanguageSupported,
|
|
2410
3738
|
resolveBrowserHarnessAssets
|
|
2411
3739
|
});
|