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>
This is a small thing I noticed while browsing the code. If you save the snapshots with the `html` extension then you can make it easy to see preview the actual html in a browser locally.
* Save HTML snapshots with .html extension.
* Apply suggestions from code review
Co-authored-by: Max Desiatov <max@desiatov.com>
This updates the project to use Swift 5.4 across all platforms. Swift 5.4 is now also the required version, which allows us to use `@resultBuilder` instead of the deprecated version of this attribute from Swift 5.3.
Use `carton` 0.11.0 or later from now on to build with SwiftWasm 5.4.0.
`Toolbar` is new in SwiftUI. It is coupled fairly closely with `NavigationView`, so this should be integrated with that somehow (#130). It was made similar to macOS which allows more than a leading/trailing `ToolbarItem`.
Resolves#316.
No functional change is introduced, only core APIs are added but aren't implemented anywhere yet.
This is a step towards reducing the size of #169.
* Add `ToolbarItem` and its builder functions
* Silence file_length linter warning
This adds `ProgressView` using the `<progress>` tag on the web.
* Add ProgressView implementation
* Fix native demo
* Enable Foundation.Progress in non-WASI environments
* Fix wasm build
* Update progress coc
* Improve snapshot copy error handling
* Use RenderingTests as directory name
* Fix snapshots CI script
* Make test failures fail the CI job
* Snapshot script debugging
* Copy failed snapshots in a different way
* Call `exit 1` when tests fail
* Use correct directory in the upload step
* Update test image
* Update .github/workflows/ci.yml
Co-authored-by: ezraberch <49635435+ezraberch@users.noreply.github.com>
Co-authored-by: Max Desiatov <max@desiatov.com>