Commit Graph

646 Commits

Author SHA1 Message Date
Max Desiatov c0c4534352
Clarify testing commands in `CONTRIBUTING.md` (#488)
This should help new contributors to run the test suite locally.
2022-05-24 15:42:31 +01:00
Max Desiatov a604ef5269
Revert "Add html5 doctype to static renderer (#486)" (#487)
* Revert "Add html5 doctype to static renderer (#486)"

This reverts commit 3081f5521a which causes failing layout snapshots we've recently turned back on in https://github.com/TokamakUI/Tokamak/pull/484.

* Fix newlines inconsistency
2022-05-24 10:59:21 +01:00
Andrew Barba 3081f5521a
Add html5 doctype to static renderer (#486)
- Add `<!DOCTYPE html>` to the top of static rendered pages
2022-05-24 10:08:08 +01:00
ezraberch 2e7f561276
Reenable macOS CI builds, using macOS 12 and Xcode 13.4 (#484) 2022-05-24 05:07:22 -04:00
Andrew Barba 2ba548810c
Support meta tags in StaticHTMLRenderer (#483)
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>
```
2022-05-23 20:03:28 +00:00
Carson Katri 8177fc8cae
Experimental "React Fiber"-like Reconciler (#471)
* 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>
2022-05-23 12:14:16 -04:00
Max Desiatov a41ac37500
Update `carton` version in "Requirements" section 2022-05-20 14:05:00 +01:00
Max Desiatov 5b7e7058e8 Bump version to 0.10.1, update `CHANGELOG.md` 2022-05-20 13:48:32 +01:00
Max Desiatov 337b80a4c4
Update JSKit dependency (#482)
* Update JSKit dependency

* Fix deprecations in `Package.swift`

* Use `main` branch of JSKit

* Update JavaScriptKit dependency to stable version
2022-05-19 14:53:48 +01:00
Max Desiatov 528fe056e0
Explicitly mention `carton` version in "Requirements" (#481)
* 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>
2022-05-10 15:41:05 +01:00
Max Desiatov 39d37a96c8
Use stable `v5.6` version of `swiftwasm-action` (#477)
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.
2022-05-02 22:07:17 +01:00
Max Desiatov 6905fdff19
Bump version to 0.10.0, update `CHANGELOG.md` (#476)
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.
2022-04-09 12:55:30 +01:00
Max Desiatov fd64eafde8
Build and test with SwiftWasm 5.6 on CI (#475)
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.
2022-04-08 21:36:52 +01:00
Max Desiatov eef6bb2da3
Update "Contributing" section in `README.md` 2022-02-21 15:51:47 +00:00
Max Desiatov 1952170ce8
Update "Contributing" section of `README.md` 2022-02-21 15:50:06 +00:00
Max Desiatov 3c649d5ead
Update CHANGELOG.md 2022-02-16 10:41:23 +00:00
yonihemi 12606a809e
Update JavascriptKit (#468)
* 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
2022-02-16 10:41:05 +00:00
Vincent Esche a9addc8cb1
Fix `rootEnvironment` not merged with `.defaultEnvironment` (#461)
* 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(_:)`
2022-01-03 08:13:14 -05:00
Vincent Esche 077c0cdfcb
Fix typos (#462) 2021-12-31 18:07:30 +00:00
Max Desiatov 5c3bc9d783
Build and test with SwiftWasm 5.5 on CI (#460)
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.
2021-12-21 12:52:50 +01:00
Max Desiatov d2d79c2bbf
Add `DynamicHTML` example code to `README.md` (#459)
This should help our users to get started with `DynamicHTML`.
2021-12-13 18:00:43 +01:00
Max Desiatov 32616fe9d4
Update `CHANGELOG.md` for 0.9.0 release (#458) 2021-11-26 18:06:05 +01:00
Max Desiatov cbfdc34793
Update for JSKit 0.11.1, add async `task` modifier (#457)
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>
2021-11-23 15:31:28 +01:00
Max Desiatov a5a05b4826
Mark Xcode 13.1 as unsupported in `README.md` 2021-11-12 12:34:23 +01:00
Max Desiatov 2ad85b329d
Switch to Xcode 13.0 in `gtk_macos_build` job (#454) 2021-10-23 21:26:39 +01:00
Max Desiatov f07b9fa883
Link to `CONTRIBUTING.md` from `README.md` 2021-10-01 12:11:24 +01:00
Max Desiatov dfc79e4148
Create CONTRIBUTING.md 2021-10-01 12:11:00 +01:00
Carson Katri 005996262a
Add Canvas and TimelineView to DOM renderer (#449)
* 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>
2021-09-28 10:27:35 -04:00
Adam Gastineau da66063918
Initial implementation of `onHover` (#448)
Adds a basic implementation of action modifiers, allowing for dynamic event handling. For testing, adds a trivial `onHover` example.
2021-09-20 16:13:30 +01:00
ezraberch 8788fd64e9
Refactor NavigationView (#446)
Workaround for #445
2021-09-16 11:17:30 -04:00
Brandon Williams 88cee68bee
Save HTML snapshots with .html extension. (#447)
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>
2021-09-11 20:12:11 +01:00
ezraberch 19bcf2746b
Add HTML renderer support for AngularGradient (#444)
* Add HTML renderer support for AngularGradient
* Change UnitPoint constants to match SwiftUI
2021-09-10 10:45:29 -04:00
Max Desiatov 3d9558f1b8
Bump requirements to Swift 5.4, migrate to `@resultBuilder` (#442)
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.
2021-09-08 10:18:53 +01:00
ezraberch e1fcd180d7
Add HTML sanitizer to Text (#437)
* Add HTML sanitizer to Text
* Add Security section to README
2021-08-24 11:27:45 -04:00
Max Desiatov bd1d8138c3
Add `@ezraberch` to the list of maintainers (#440)
* Add `@ezraberch` to the list of maintainers

* Update README.md

Co-authored-by: ezraberch <49635435+ezraberch@users.noreply.github.com>
2021-08-17 13:15:07 +01:00
Max Desiatov c2ed28ca40
Update `CHANGELOG.md` for the 0.8.0 release (#438)
* Update `CHANGELOG.md` for the 0.8.0 release

* Update `CHANGELOG.md`

* Apply suggestions from code review

Co-authored-by: Carson Katri <Carson.katri@gmail.com>
2021-08-16 18:13:57 +01:00
Carson Katri 4609b0a203
Revise ShapeStyle and add Gradients (#435) 2021-08-14 18:26:39 -04:00
Carson Katri 21c21cd328
Add `Toolbar` implementation for HTML renderer (#169)
`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.
2021-08-05 16:17:30 +01:00
ezraberch a8c6eae94e
Fix SwiftLint action (#434)
* Update SwiftLint action
2021-07-28 09:56:25 -04:00
Carson Katri 9a568ab9cf
Add View Traits and transitions (#426) 2021-07-28 09:40:12 -04:00
Max Desiatov ae0db4d1f1
Add `ToolbarItem` and its builder functions (#430)
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
2021-07-25 16:01:29 +01:00
Carson Katri 22ea230ce0
Add controlSize/controlProminence modifiers (#431) 2021-07-19 13:58:14 -04:00
Carson Katri 6792dbb02c
Fix background/overlay layout in DOM/HTML renderers (#429) 2021-07-17 15:45:32 -04:00
Carson Katri 12a6256ec0
Add ProgressView (#425)
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>
2021-07-17 16:43:51 +01:00
Carson Katri ab5e564ada
Animation implementation using the Web Animations API (#427) 2021-07-13 08:48:45 -04:00
Carson Katri a064956095
Add `scaleEffect` modifier (#424) 2021-07-13 08:48:28 -04:00
Carson Katri ff3f81dbfd
Add `aspectRatio` modifier (#422) 2021-07-12 16:59:24 -04:00
Carson Katri b6790c5c6d
Add support for custom fonts (#421) 2021-07-12 12:10:26 -04:00
Carson Katri 30f55d9814
Check minWidth/Height == nil (#420) 2021-07-09 09:58:38 -04:00
Carson Katri 2efa80a57d
Add Primary/Secondary/Tertiary/QuaternaryContentStyle (#419) 2021-07-07 18:44:34 -04:00