Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Native apps on macOS and iOS, and Swift servers on Linux, cannot use
ondine/compiler/wasmwithout a JavaScript engine. iOS allows no JIT, so these apps need a WebAssembly interpreter and a wrapper for the module's ABI. Each app now writes and maintains its own wrapper.Changes
Package.swiftat the repository root with theOndinelibrary underswift/. It runs a caller-supplied module in WasmKit 0.4.Ondine.Compiler(module:)takes one module:all.generated.wasmfor every diagram type, or the module of one type, which renders only that type.Ondine.Optionshas the fields ofrender.Optionsand sends the same JSON. Afuelbudget stops a pathological source withRenderError.fuelExhausted.Options.defaultFuelis one billion instructions, about one second in an optimized build, and callers can raise it.Ondine.RenderError.diagnosticcarries the code, line, column, snippet, and message ofRenderError. After a trap, the next render uses a fresh instance.CompilerisSendable, and a lock serializes its renders.Example
Validation
swift testpasses with Swift 6.4.2 and in theswift:6.3-noblecontainer (8 tests). Diagnostics, links, and widths in the tests matchondine/compiler/wasmfor the same source and modules. Every sample intest/vectors/samples.jsonrenders within ten million fuel, and one billion fuel runs out in 0.6 s in a release build.pnpm checkandpnpm check:typespass.Open Question
Should the package stay in this repository, with callers copying the
.wasmfrom the npm package, or move to a separate repository such asondine-swift? Tagged releases there could bundle the module as a resource, so Swift apps add one dependency and SwiftPM pins versions (this repository has no semver tags). The in-repo package needs no release process, while a separate repository must publish a release for eachondineversion.