The abundance of `@_spi(TokamakCore)` makes it harder to parse some of our code visually when skimming. I propose consistently moving attributes on declarations to separate lines. Here's an update to `.swiftformat` config with the new settings applied to the codebase.
* Tweak formatting rules
* Improve readability with newlines
* More newlines to visually separate declarations
* Fix build error caused by merge conflict
Co-authored-by: Carson Katri <Carson.katri@gmail.com>
Most of the changes are related to the use of OpenCombineShim (available in upstream OpenCombine now) instead of CombineShim. But there is also a new test added during the investigation of #367, where an app is rendered end-to end, which is a good way to expand our test suite I think.
* Use immediate scheduler in TestRenderer
This allows running our test suite on WASI too, which doesn't have Dispatch and also can't wait on XCTest expectations. Previously none of our tests (especially runtime reflection tests) ran on WASI.
* Run `carton test` and `carton bundle` in separate jobs
* Bump year in the `LICENSE` file
* Add reconciler stress tests for elaborate testing
* Move default App implementation to TestRenderer
* Use OpenCombineShim instead of CombineShim
Adds `_spi(TokamakCore)` to the modules:
1. TokamakCore
2. TokamakDOM
3. TokamakGTK
4. TokamakStaticHTML
The attribute is applied to:
1. All `View` bodies in TokamakCore — either primitive or regular like `Color`
2. `ViewDeferredToRenderer` bodies
4. `ParentView` `children` members
5. `View` modifiers (such as `_onMount(perform:)`)
6. Other members of types (like `Color._withScheme`, and `_AnyApp._launch`)
The attribute semantics (from my brief testing)
1. It can only be applied to `public` declarations
2. It ensures that every SPI declaration is exposed only by other SPI declarations (i.e. `@_spi(Module) public enum A {}; public var a: A` is illegal)
3. Regularly importing a library prohibits clients from accessing SPI declarations that are not protocol witnesses (with an error).
4. Regularly importing a library "discourages" clients from accessing SPI protocol witnesses by hiding them from the autocompletion suggestions (i.e. users can still access `body` of `Text`, but autocompletion hides it).
5. For a declaration marked with `@_spi(Module)`, a client has to write `@_spi(Module) import Library` in order to normally access such SPI declarations.
* Add '_spi(TokamakCore)' to ideally internal public members.
* Remove `_spi` attribute on '_ConditionalContent'.
* Remove spi from 'Path._PathBox', 'Font._Font', and '_TupleScene.body'.
* Remove spi from types.
* Remove trailing whitespace.
* Apply spi to 'View' modifiers.
* Add _spi imports.
* Introduce 'PrimitiveView'.
* Remove 'PrimitiveView' conformances outside of TokamakCore.
* Fix `PrimitiveView` default implementation.
* Remove "BubbleCore" references.
* Update to the latest version of SwiftFormat
This fixes inconsistencies in argument and parameter formatting that we previously had.
* Fix function length in `Path.swift`
* Fix linter warnings
* More formatting cleanups
* Add `StrokeStyle.zero` in the `StaticHTML` module
We can't run our basic reconciler tests in a WASI environment yet because `XCTestExpectation` is not available on WASI as it relies on the presence of `Dispatch`. We can run these tests on macOS though, and even on Linux in the future when Swift 5.3 is available for Linux on GitHub Actions.
My current OpenCombine fork doesn't build on macOS and it was much easier to add a new `CombineShim` module that uses native Combine there.