This is a document we could redirect people to with questions about our layout system, naming, and history of the project. Feel free to expand this with more relevant topics.
Co-authored-by: Carson Katri <Carson.katri@gmail.com>
Errors started cropping up during CI runs on https://github.com/TokamakUI/Tokamak/pull/511. I think it's better to disable this job until we find a good way to fix it. It wasn't a job required for merging PRs anyway, as GTK renderer is currently experimental.
* Pass preferences up the Fiber tree
* Working preferences (except for backgroundPreferenceValue)
* Initial StateObject support
* Fix layout caching bug
* Support StateObject/EnvironmentObject/custom DynamicProperty
* Add doc comments for bindProperties and updateDynamicProperties
* Use immediate scheduling in static HTML and test renderers
* Add preferences test
* Add state tests and improve testing API
* Attempt to fix tests
* Fix preference tests
* Attempt to fix tests when Dispatch is unavailable
* #if out on os(WASI)
* Add check for WASI to test
* Add check for WASI to TestViewProxy
* #if out of import Dispatch when os == WASI
* Remove all Dispatch code
* Remove address from debugDescription
* Move TestViewProxy to TokamakTestRenderer
* Add memory address to Fiber.debugDescription
* Fix copyright year
* Add several missing types to Core.swift
* Add missing LayoutValueKey to Core.swift
* Fix issues with view trait propagation
* Enable App/SceneStorage in DOMFiberRenderer
* Address review comments
* Revise preference implementation
* Support image and aspect ratio
* Fix measureImage implementation in test renderer
* Improve accuracy of aspectRatio
* Rename intrinsicSize to hide from autocomplete
* Initial pass at Layout protocol implementation
* Move layout into a separate pass
* Split reconciler into separate FiberReconcilerPass-es
* Cleanup reconcile pass
* Simplify cache implementation
* Optimize array capacity and persist cache between runs
* Revert viewChildrenCount
* Improve accuracy of stack layout
* Try caching sizeThatFits
* Revise caching of sizeThatFits
* Cleanup layout files and split up
* Further cleanup
* Add ContainedZLayout
* Add frame layouts
* Add snapshots tests that compare against native SwiftUI
* Perform updates from the top of the view hierarchy for dynamic layout
* Add Package.swift
* Fix reconciler bug
* Add test case for reconciler insert bug
* Respect spacing preferences
* Revise cache and spacing logic to match SwiftUI default implementations
* Allow spacing changes based on adjacent View type
* Support view traits in FiberReconciler (and LayoutValueKey by extension)
* Propagate cache invalidation
* Cleanup attributes
* Simplify LayoutPass and improve accuracy
* Cleanup logs
* Add layoutPriority tests
* Revise conflict with main
* Dictionary performance catch
* Remove unneccesary capacity preservation
* Update TokamakCoreBenchmark to handle LayoutView addition at hierarchy root
* Implement AnyLayout and replace LayoutActions
* Allow VStack/HStack to be created without children
* Fix padding implementation
* Formatting fixes
* Space out ViewArguments.swift properties
* Add backing storage to LayoutSubview to move out of ReconcilePass and slightly optimize stack usage
* Initial Reconciler using visitor pattern
* Preliminary static HTML renderer using the new reconciler
* Add environment
* Initial DOM renderer
* Nearly-working and simplified reconciler
* Working reconciler for HTML/DOM renderers
* Rename files, and split code across files
* Add some documentation and refinements
* Remove GraphRendererTests
* Initial layout engine (only implemented for the TestRenderer)
* Layout engine for the DOM renderer
* Refined layout pass
* Revise positioning and restoration of position styles on .update
* Re-add Optional.body for StackReconciler-based renderers
* Add text measurement
* Add spacing to StackLayout
* Add benchmarks to compare the stack/fiber reconcilers
* Fix some issues created for the StackReconciler, and add update benchmarks
* Add BenchmarkState.measure to only calculate the time to update
* Fix hang in update shallow benchmark
* Fix build errors
* Address build issues
* Remove File.swift headers
* Rename Element -> FiberElement and Element.Data -> FiberElement.Content
* Add doc comment explaining unowned usage
* Add doc comments explaining implicitly unwrapped optionals
* Attempt to use Swift instead of JS for applying mutations
* Fix issue with not applying updates to DOMFiberElement
* Add comment explaining manual implementation of Hashable for PropertyInfo
* Fix linter issues
* Remove dynamicMember label from subscript
* Re-enable carton test
* Attempt GTK fix
* Add option to disable layout in the FiberReconciler
* Re-enable TokamakDemo with StackReconciler
* Restore CI config
* Restore CI config
* Add file headers and cleanup structure
* Add 'px' to font-size in test outputs
* Remove extra newlines
* Keep track of 'elementChildren' so children are positioned in the correct order
* Use a ViewVisitor to pass the correct View type to the proposeSize function
* Add support for view modifiers
* Add frame modifier to demonstrate modifiers
* Fix TestRenderer
* Remove unused property
* Add PaddingLayoutComputer
* Fix doc comment
* Fix doc comment
* Fix linter issues and refactor slightly
* Fix benchmark builds
* Attempt to fix benchmarks
* Fix sibling layout issues
* Restore original demo
* Address review comments
* Remove maxAxis and fitAxis properties
* Use switch instead of ternary operators
* Add more documentation to layout steps
* Resolve reconciler issue due to alternate child not being cleared/released
* Apply suggestions from code review
Co-authored-by: Max Desiatov <max@desiatov.com>
* Reuse Text resolution code.
* Add more documentation
* Fix typo
* Use structs for LayoutComputers
* Update AlignmentID demo
* Fix weird formatting
* Fix copyright year
* Restore original demo
* Move attribute to newline
* Address review comments
Co-authored-by: Max Desiatov <max@desiatov.com>
* Initial Reconciler using visitor pattern
* Preliminary static HTML renderer using the new reconciler
* Add environment
* Initial DOM renderer
* Nearly-working and simplified reconciler
* Working reconciler for HTML/DOM renderers
* Rename files, and split code across files
* Add some documentation and refinements
* Remove GraphRendererTests
* Initial layout engine (only implemented for the TestRenderer)
* Layout engine for the DOM renderer
* Refined layout pass
* Revise positioning and restoration of position styles on .update
* Re-add Optional.body for StackReconciler-based renderers
* Add text measurement
* Add spacing to StackLayout
* Add benchmarks to compare the stack/fiber reconcilers
* Fix some issues created for the StackReconciler, and add update benchmarks
* Add BenchmarkState.measure to only calculate the time to update
* Fix hang in update shallow benchmark
* Fix build errors
* Address build issues
* Remove File.swift headers
* Rename Element -> FiberElement and Element.Data -> FiberElement.Content
* Add doc comment explaining unowned usage
* Add doc comments explaining implicitly unwrapped optionals
* Attempt to use Swift instead of JS for applying mutations
* Fix issue with not applying updates to DOMFiberElement
* Add comment explaining manual implementation of Hashable for PropertyInfo
* Fix linter issues
* Remove dynamicMember label from subscript
* Re-enable carton test
* Attempt GTK fix
* Add option to disable layout in the FiberReconciler
* Re-enable TokamakDemo with StackReconciler
* Restore CI config
* Restore CI config
* Add file headers and cleanup structure
* Add 'px' to font-size in test outputs
* Remove extra newlines
* Keep track of 'elementChildren' so children are positioned in the correct order
* Use a ViewVisitor to pass the correct View type to the proposeSize function
* Add support for view modifiers
* Add frame modifier to demonstrate modifiers
* Fix TestRenderer
* Remove unused property
* Fix doc comment
* Fix linter issues and refactor slightly
* Fix benchmark builds
* Attempt to fix benchmarks
* Fix sibling layout issues
* Restore original demo
* Support overriding visit function in renderer and _ShapeView drawing
* Support background modifier
* Resolve reconciler issues due to Optionals and elementIndex being set at wrong phase
* Remove Brewfile.lock.json
* Attempt to fix rendering tests
* Formatting nits
* Fix Gradient rendering
Co-authored-by: Max Desiatov <max@desiatov.com>
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>
* Initial Reconciler using visitor pattern
* Preliminary static HTML renderer using the new reconciler
* Add environment
* Initial DOM renderer
* Nearly-working and simplified reconciler
* Working reconciler for HTML/DOM renderers
* Rename files, and split code across files
* Add some documentation and refinements
* Remove GraphRendererTests
* Initial layout engine (only implemented for the TestRenderer)
* Layout engine for the DOM renderer
* Refined layout pass
* Revise positioning and restoration of position styles on .update
* Re-add Optional.body for StackReconciler-based renderers
* Add text measurement
* Add spacing to StackLayout
* Add benchmarks to compare the stack/fiber reconcilers
* Fix some issues created for the StackReconciler, and add update benchmarks
* Add BenchmarkState.measure to only calculate the time to update
* Fix hang in update shallow benchmark
* Fix build errors
* Address build issues
* Remove File.swift headers
* Rename Element -> FiberElement and Element.Data -> FiberElement.Content
* Add doc comment explaining unowned usage
* Add doc comments explaining implicitly unwrapped optionals
* Attempt to use Swift instead of JS for applying mutations
* Fix issue with not applying updates to DOMFiberElement
* Add comment explaining manual implementation of Hashable for PropertyInfo
* Fix linter issues
* Remove dynamicMember label from subscript
* Re-enable carton test
* Attempt GTK fix
* Add option to disable layout in the FiberReconciler
* Re-enable TokamakDemo with StackReconciler
* Restore CI config
* Restore CI config
* Add file headers and cleanup structure
* Add 'px' to font-size in test outputs
* Remove extra newlines
* Keep track of 'elementChildren' so children are positioned in the correct order
* Use a ViewVisitor to pass the correct View type to the proposeSize function
* Add support for view modifiers
* Add frame modifier to demonstrate modifiers
* Fix TestRenderer
* Remove unused property
* Fix doc comment
* Fix linter issues and refactor slightly
* Fix benchmark builds
* Attempt to fix benchmarks
* Fix sibling layout issues
* Restore original demo
* Address review comments
* Remove maxAxis and fitAxis properties
* Use switch instead of ternary operators
* Add more documentation to layout steps
* Resolve reconciler issue due to alternate child not being cleared/released
* Apply suggestions from code review
Co-authored-by: Max Desiatov <max@desiatov.com>
* Reuse Text resolution code.
* Add more documentation
* Fix typo
* Use structs for LayoutComputers
* Update AlignmentID demo
* Fix weird formatting
Co-authored-by: Max Desiatov <max@desiatov.com>
This PR adds the ability to control `<head>` tags using a new `HTMLTitle` view and `HTMLMeta` view. Taking inspiration from Next.js `<NextHead>`, you can use these views anywhere in your view hierarchy and they will be hoisted to the top `<head>` section of the html.
Use as a view:
```swift
var body: some View {
VStack {
...
HTMLTitle("Hello, Tokamak")
HTMLMeta(charset: "utf-8")
...
}
}
```
Use as a view modifier:
```swift
var body: some View {
VStack {
...
}
.htmlTitle("Hello, Tokamak")
.htmlMeta(charset: "utf-8")
}
```
And the resulting html (no matter where these are used in your view hierarchy):
```html
<html>
<head>
<title>Hello, Tokamak</title>
<meta charset="utf-8">
</head>
<body>
...
</body>
</html>
```
* Initial Reconciler using visitor pattern
* Preliminary static HTML renderer using the new reconciler
* Add environment
* Initial DOM renderer
* Nearly-working and simplified reconciler
* Working reconciler for HTML/DOM renderers
* Rename files, and split code across files
* Add some documentation and refinements
* Remove GraphRendererTests
* Re-add Optional.body for StackReconciler-based renderers
* Add benchmarks to compare the stack/fiber reconcilers
* Fix some issues created for the StackReconciler, and add update benchmarks
* Add BenchmarkState.measure to only calculate the time to update
* Fix hang in update shallow benchmark
* Fix build errors
* Address build issues
* Remove File.swift headers
* Rename Element -> FiberElement and Element.Data -> FiberElement.Content
* Add doc comment explaining unowned usage
* Add doc comments explaining implicitly unwrapped optionals
* Attempt to use Swift instead of JS for applying mutations
* Fix issue with not applying updates to DOMFiberElement
* Add comment explaining manual implementation of Hashable for PropertyInfo
* Fix linter issues
* Remove dynamicMember label from subscript
* Re-enable carton test
* Re-enable TokamakDemo with StackReconciler
Co-authored-by: Max Desiatov <max@desiatov.com>
* Explicitly mention `carton` version in "Requirements"
This makes the version number of `carton` required for successful builds more explicit.
* Update README.md
Co-authored-by: Jed Fox <git@jedfox.com>
After `carton` 0.14.0 was tagged, I've updated `swiftwasm-action` to use that latest release. With that, corresponding `v5.6` was tagged, which I propose to use in `ci.yml` instead of the `main` branch.
I'd be happy to include #471 as well, but I personally prefer rolling out big changes in stages. #471 deserves its own release, while in this release the only meaningful change is the Swift version requirement and JSKit/`carton` dependencies bump.
Had to drop support for Swift 5.4/5.5 and macOS 5.6 jobs, see https://github.com/TokamakUI/Tokamak/pull/475#issuecomment-1092662828 for more details.
Linux builds and `codecov` job were updated to use nightly Swift, which have crashes reproducible in 5.6.0 release fixed.
Also applied a few formatting changes with the latest SwiftFormat.
* Bump JavaScriptKit dependency to 0.12.0.
* Update CHANGELOG.md for 0.9.1 release.
* Fix access to `hash` property
(now that JSObject conforms to Hashable it has a Swift hash property which overrides callAsFunction)
* Update CHANGELOG.md
* Make actual use of `rootEnvironment` passed into functions, falling back to `.defaultEnvironment`
* Add `.merge(_:)`/`.merging(_:)` to `EnvironmentValues`
* Merge `.defaultEnvironment` with `rootEnvironment`
* Add `@_spi(TokamakCore)` protection for `EnvironmentValues.merge(_:)`/`.merging(_:)`
Configuration for simultaneous builds with SwiftWasm 5.4 and 5.5 can't be specified more succinctly due to https://github.com/swiftwasm/swiftwasm-action/issues/3. I had to create almost duplicate job descriptions because of that.
I've also moved sources in `TokamakDemo` directory into their respective subdirectories for easier navigation.
* Update for JSKit 0.11.0, add async `task` modifier
* Add back new file locations to `NativeDemo`
* Add compiler `#if` check to `TaskDemo`
* Update to JavaScriptKit 0.11.1
* Restrict `TaskDemo` with `compiler(>=5.5)` check
* Replace `compiler` with `swift` in some places
* Revert "Replace `compiler` with `swift` in some places"
This reverts commit 534784ca7b.
* Use Xcode 13.2 on GitHub Actions hosts
* Find `TokamakPackageTests` in the build directory
* Fix macOS tests bundle path
* Make `task` modifier available only on macOS Monterey
* Revert "Use Xcode 13.2 on GitHub Actions hosts"
This reverts commit 63d044f2d5.
* Revert "Fix macOS tests bundle path"
This reverts commit 3ccbc98a2d.
* Revert "Find `TokamakPackageTests` in the build directory"
This reverts commit 68c845bc19.
* Use `canImport(Concurrency)` as an ultimate check
* Use `compiler(>=5.5) && canImport(Concurrency)`
* Clarify new browser version requirements in `README.md`
* Account for `_Concurrency` naming
* Update `README.md`
* Update README.md
Co-authored-by: ezraberch <49635435+ezraberch@users.noreply.github.com>
* Add initial implementations of Canvas and TimelineView
* Add CanvasDemo
* Add the demo to the native project
* Use Xcode 13.0 for macOS builds
* Disable macOS builds until Monterey is available
* Mark CanvasDemo as iOS 15/macOS 12 only, fix LinkButtonStyle reference on iOS
* Add _VariadicView and symbol rendering
* Fix linter warnings
* Add image support
* Revise AnimationTimelineSchedule and requestAnimationFrame cancellation
* Fix pausing of animated TimelineView in TokamakDOM
Co-authored-by: Max Desiatov <max@desiatov.com>