Commit Graph

528 Commits

Author SHA1 Message Date
Max Desiatov 1b814d0583
Add @kateinoigakukun to the list of maintainers (#310) 2020-12-04 11:20:26 +00:00
Jed Fox 797c0d849f
Add `Image` implementation, bump JSKit to 0.9.0 (#155)
* Add Image view

* Add image to demo

* Update progress.md

* Alt text

* Use Bundle type to load images, remove systemName

* Add `logo-header.png` resource to `TokamakDemo`

* Reduce image size in the demo

* Allow bundles passed to `Image` to be optional

* Pass `nil` as a default `bundle` to `Image`

Co-authored-by: Max Desiatov <max@desiatov.com>
2020-12-04 11:19:55 +00:00
Carson Katri 9d347f49f3
Add Preferences (#307)
This adds the `PreferenceKey` protocol and related modifiers.

* Initial PreferenceKey implementation

* Don't send default value to match SwiftUI behavior

* Add CustomDebugStringConvertible conformance to Color

* PR fixes

* Fix onAppear and preference modification calls

* Attempt macOS build fix

* Fix <background/overlay>PreferenceValue

* Implement/revise transformPreference

* Fix linter warnings, apply SwiftFormat

Co-authored-by: Max Desiatov <max@desiatov.com>
2020-12-04 11:19:14 +00:00
Max Desiatov 2e8e458b9c
Remove unused Dangerfile.swift (#311)
We already use SwiftLint as a separate action, and don't run Danger checks on CI anyway.
2020-11-28 14:31:51 +00:00
Max Desiatov cabe5abef5
Bump version to 0.5.3, update `CHANGELOG.md` 2020-11-28 11:39:30 +00:00
Max Desiatov dfcacc862f
Fix update of `checked` property of checkbox input (#309)
Resolve #287.

The `checked` attribute is a peculiar one, as any value on it keeps the checkbox checked. Attribute updates in `DOMRenderer` don't handle removals of attributes, but this seems to be the only case where this is relevant. I've added special handling for this attribute and checkbox inputs, and also had to declare `HTMLAttribute.checked` to set `isUpdatedAsProperty: true` on it for it to fully work.
2020-11-28 11:27:18 +00:00
Max Desiatov c754b313ef
Use latest macOS and Xcode on CI (#308)
* Use latest macOS and Xcode on CI

* Update ci.yml
2020-11-27 14:17:45 +00:00
Max Desiatov b26eb71f3e
Fix `carton dev` guidance for the demo product 2020-11-26 13:53:23 +00:00
Max Desiatov 05465be93d
Use `JSScheduler` from `OpenCombineJS` package (#304)
Now that OpenCombineJS had its first release, we can rely on its `JSScheduler` implementation.
2020-11-26 09:01:54 +00:00
Max Desiatov d5a50e7045
Bump version to 0.5.2, update CHANGELOG and README 2020-11-12 14:44:16 +00:00
Max Desiatov 3451d9ea12
Pass sibling to `Renderer.mount`, fix update order (#301)
Resolves, but adds no tests cases to the test suite for #294. See the issue for the detailed description of the problem.

I will add end-to-end tests for this in future PRs.

I've tested these cases manually so far:

```swift
struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        Group {
          Text("true")
          Text("true")
        }
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}
```

Note the `Group` view with multiple children in this one, it uncovered required checks for `GroupView` conformance.

Also tested these more simple cases:

```swift
struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        Group {
          // single child
          Text("true")
        }
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}
```

and

```swift
struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        // single child, no nesting
        Text("true")
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}
```
2020-11-11 19:34:45 +00:00
Max Desiatov 33adba20ab
Fix build after SwiftFormat changes 2020-11-09 12:47:27 +00:00
Max Desiatov fb3ab974df
Bump version to 0.5.1, update `CHANGELOG.md` 2020-11-09 12:27:26 +00:00
Max Desiatov f24a09f006
Apply latest SwiftFormat 2020-11-09 12:27:17 +00:00
Max Desiatov bff7c1bf27
Remove unused `.swift-version` file 2020-11-09 12:25:04 +00:00
Yuta Saito c813061b17
Update Package.resolved (#300) 2020-11-09 12:20:41 +00:00
Max Desiatov 7320de9857
Allow use of Combine to enable Xcode autocomplete (#299)
It looks weird, but it works 🤷‍♂️
2020-11-09 12:20:22 +00:00
Max Desiatov 082fa19398
Fix linter warning 2020-11-09 12:02:25 +00:00
Max Desiatov 18da2d279e
Fix typo in CHANGELOG.md 2020-11-08 23:47:03 +00:00
Max Desiatov 014383f751
Bump version to 0.5.0, update `CHANGELOG.md` (#298)
* Bump version to 0.5.0, update `CHANGELOG.md`

* Update CHANGELOG.md

Co-authored-by: Carson Katri <Carson.katri@gmail.com>

Co-authored-by: Carson Katri <Carson.katri@gmail.com>
2020-11-08 23:22:36 +00:00
Yuta Saito af08c1a6f6
Xcode compatibility (#297)
* Ignore xcodeproj generated by SwiftPM

* Update to use official OpenCombine to avoid Xcode build error

* Use forked version with ObservableObject implementation

* Fix ambigious error

* Ignore SwiftPM edit mode package

* Update toolchain version
2020-11-08 19:42:25 +09:00
Max Desiatov 9681b91a84
Allow tests to be run on macOS (#295)
Requires #276 to be merged, as earlier versions of JavaScriptKit can't be depended on in macOS builds due to unsafe flags.

* Add Link View

* Add Publish support

* Remove #if checks

* Upgrade swift snapshot

* Try swiftwasm-action@main

* Remove Publish support from this repo

* Remove TokamakPublish target

* Allow tests to be run on macOS

* Update `ci.yml` to build and run the test product

* Trigger CI on all PRs without branch restrictions

* Rename linux_build to swiftwasm_build in ci.yml

Co-authored-by: Carson Katri <carson.katri@gmail.com>
2020-11-07 10:11:35 +00:00
Carson Katri 348408eba1
Add Link view, update JavaScriptKit to 0.8.0 (#276)
* Add Link View

* Add Publish support

* Remove #if checks

* Upgrade swift snapshot

* Try swiftwasm-action@main

* Remove Publish support from this repo

* Remove TokamakPublish target
2020-11-05 16:37:56 -05:00
Carson Katri a5da04989e
Add `AnyColorBox` and `AnyFontBox` (#291)
* Add AnyColorBox implementation

* Add TokenDeferredToRenderer

* Implement AnyFontBox

* Add Any[Color/Font]BoxDeferredToRenderer

* Resolve linter errors

* Appease the linter
2020-10-28 18:26:42 -04:00
Max Desiatov 94dc934fe4
Replace Danger with SwiftLint to improve warnings (#293)
Looks like the Danger action duplicates warning comments. The new SwiftLint action does not, although warnings only show up in the diff view, which I think is an acceptable trade-off.
2020-10-27 21:43:42 +00:00
Max Desiatov 1e43d98bb2
Use v5.3 tag of `swiftwasm-action` in `ci.yml` (#292)
`swiftwasm-action@master` no longer exists, and we should use a tag to rely on more stable action code anyway.
2020-10-25 12:40:48 +00:00
Max Desiatov af225afab7
Add @carson-katri and @kateinoigakukun to `FUNDING.yml` (#289)
* Add @carson-katri and @kateinoigakukun to `FUNDING.yml`

* Update README.md
2020-10-07 08:07:45 +01:00
Max Desiatov dbd1ee46c4
Add `URLHashDemo` w/ `window.onhashchange` closure (#288)
* Add `URLHashDemo` w/ `window.onhashchange` closure

Resolves #284

* Assign `.undefined` in HashState.deinit
2020-10-06 21:18:18 +01:00
Max Desiatov a631d181e6
Update required `carton` version in `README.md` 2020-10-04 18:16:23 +01:00
Max Desiatov b5b68c4186
Update `CHANGELOG.md` for 0.4.0 release 2020-09-30 11:22:45 +01:00
Max Desiatov ee0006a6a3
Fix compatibility with JavaScriptKit 0.7 (#281)
This PR requires `carton` 0.6.0 that you can install from Homebrew as usual.

To cleanly manage scheduler closures, new `JSScheduler` class is introduced that conforms to OpenCombine's `Scheduler` protocol. I think it will be moved to OpenCombineJS in the future.

* Fix compatibility with JavaScriptKit 0.7

* Formatting update

* Specify `carton` 0.6.0 as a requirement

* Optimize immediate schedule function

* Update formatting
2020-09-30 10:17:19 +01:00
Yuta Saito 278201cbd3
Re-export HTML in TokamakDOM (#275) 2020-09-24 00:26:01 +09:00
Max Desiatov de72316efa
Use setAttribute, not properties to fix SVG update (#279)
Property assignment does not update SVG elements. We may want to use properties instead of `setAttribute` in the future for optimizations. For now I think that `setAttribute` works in all cases, including SVG, and seems safer to me.

Resolves #278.

* Use setAttribute, not properties to fix SVG update

* Add HTMLAttribute to cleanly apply DOM updates

* Add doc comment to HTMLAttribute

* Update Sources/TokamakStaticHTML/Views/HTML.swift

Co-authored-by: Jed Fox <git@jedfox.com>

* Use static func property in TokamakDOM/TextField.swift

* Make `static func property` public

* Declare `static let value` on `HTMLAttribute`

Co-authored-by: Jed Fox <git@jedfox.com>
2020-09-23 09:13:22 +01:00
Yuta Saito ba7af1d014
Allow non-body mount host node (#271) 2020-08-31 08:38:55 -04:00
Jed Fox 5141bee7d7
Fix the sizing of sliders (#268) 2020-08-26 22:29:21 -04:00
Jed Fox 523c53f14a
Add `Slider` implementation (#228)
* Slider MVP

* Update progress.md

* Update Slider.swift

* Update SliderDemo.swift

* Allow any BinaryFloatingPoint

* Add Mac Catalyst Tokamak demo

* Add basic onEditingChanged support

This likely has bugs if you touch down multiple fingers on the slider then lift one finger.

* Demo improvements

* Update ScrollView to match SwiftUI

This isn’t documented but it visually appears to wrap the content in a VStack

* Restyle the sliders

* Update Slider.swift

* Make convert functions private

* Fix line length

* Update progress.md and FIXMEs

* Wrap comments
2020-08-26 13:33:06 -04:00
Max Desiatov 5f450d0e38
Fix typo in 0.3.0 entry in `CHANGELOG.md` 2020-08-20 15:50:03 +01:00
Max Desiatov 8ce22014dd
Update 0.3.0 entry in `CHANGELOG.md` 2020-08-20 12:41:21 +01:00
Max Desiatov 6affca5931
Specify `carton` 0.5.0 version as a requirement in `README.md` 2020-08-20 12:02:12 +01:00
Max Desiatov 0fe81a060d
Remove Xcode 12 warning from README.md (#264)
The latest 5.3 snapshots are compatible with Xcode 12, so the warning is no longer needed.
2020-08-20 12:01:17 +01:00
Max Desiatov ca5d4fc4ac
Add missing JavaScriptKit import to `README.md` (#265)
The import is currently missing, which may be confusing, especially if example code is copied without any context.
2020-08-20 00:30:12 +01:00
Max Desiatov 75d178e5dd
Update `CHANGELOG.md` for 0.3.0 release 2020-08-19 10:11:34 +01:00
Max Desiatov 82111c54a0
Set versions of dependencies in `Package.swift` (#262)
This allows specifying 0.3 (to be released after this PR is merged) dependency on Tokamak in `carton` templates, otherwise branch/commit dependencies in our `Package.swift` can't be correctly resolved.

`swift test` is temporarily disabled on macOS as the upstream Swift toolchain doesn't support unsafe flags in the JavaScriptKit dependency together with a `from` constraint. We could run it on Linux, but my OpenCombine fork doesn't support Linux builds yet (logged as #263).
2020-08-19 10:08:00 +01:00
Max Desiatov d97a5f3215
Update `CHANGELOG.md` for 0.3.0 release 2020-08-17 18:31:31 +01:00
Max Desiatov 2383a17c2d
Implement `StateObject` property wrapper (#260)
Resolves #158.

Fixes a bug where `NavigationView` destination was reset after scene phase changes (or any re-renders caused by environment changes for that matter).

This was caused by `@ObservedObject` destination being recreated, now `@StateObject` persists it across re-renders.

The `setter` property of the `ValueStorage` protocol is now moved to a separate `WritableValueStorage` protocol. The reasoning is that `StateObject` doesn't need its wrapped value to be set directly as it operates on it by reference, not by value, thus `StateObject` doesn't need any wrapped value setters.
2020-08-17 16:01:49 +01:00
Max Desiatov b9f5ef07ab
Fix `NavigationView` broken state after re-render (#259) 2020-08-15 18:07:19 +01:00
Max Desiatov b7434a2e54
Add `GeometryReader` implementation (#239)
This is just an empty API at the moment. I hope it can be implemented purely in the `deferredBody` of `GeometryReader` with [the ResizeObserver API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) without requiring any tweaks in the `Renderer` protocol or the reconciler.

Seems like I need the `domRef` modifier that writes `JSObjectRef` to a given binding working first, as discussed in #231.
2020-08-11 16:47:12 +01:00
Carson Katri c43d2db1b3
Add default dark styles for Views (#241) 2020-08-10 16:05:53 -04:00
Max Desiatov 2a49b7808b
Link to the renderers guide from `README.md` (#251)
* Link to the renderers guide from `README.md`

The guide itself was merged into a single file for easier navigation.

* Update RenderersGuide.md
2020-08-07 16:01:27 +01:00
Max Desiatov e11effdd8c
Use the latest 5.3 snapshot in `.swift-version` (#252)
* Use the latest 5.3 snapshot in `.swift-version`

These SwiftWasm snapshots should be more stable in general and also have a workaround for https://github.com/swiftwasm/JavaScriptKit/issues/6 included. They still use the old metadata layout, so Runtime and OpenCombine dependencies had to be updated in `Package.swift` for `@ObservableObject` to work with these snapshots.

* Fix linter warning
2020-08-06 13:57:36 +01:00