This fixes#320 by adding a SwiftUI-compatible `DatePicker`. However, `DatePickerStyle` is not supported.
This uses the HTML inputs `date`, `time`, or `datetime-local`, depending on the given `displayedComponents`. This means that not all browsers show the picker, as Mac Safari currently does not support them. Safari on Mac will just show an ISO-format text field. If the date is in an invalid format, the binding will not receive updates until it becomes parseable by JSDate.
On supported browsers, the binding gets updated in real time, as you would expect, with a Foundation.Date, just like SwiftUI.
* Add DatePicker to TokamakCore and TokamakDOM
* Fix crash on invalid date
* Update progress.md and add credit
* Fix time zone related issues with the DatePicker
* Add DatePickerDemo to the TokamakDemo
* Fix overview for DatePicker
* Fix NativeDemo build
Resolves#218.
`String(describing:)` initializer applied to metatypes does not include a module name, which can cause problems if two different types with same name come from different modules.
OTOH `String(reflecting:)` does include module name, which makes these reflection strings slightly longer, but should prevent obscure issues with name collisions from happening.
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.
* 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
Closes https://github.com/TokamakUI/Tokamak/issues/350.
Adds simple code coverage analysis. Until the GitHub token is set up in this repo, you can see the results including a comment on the PR here: https://github.com/mattpolzin/Tokamak/pull/2
* Adding codecov CI workflow.
* doh. forgot to skip build.
* drop unneeded llvm env var from build invocation. make comment always run.
* try a way to update a previous comment
* try to get comments to run on failure.
* use bug fix to codecov action.
* fix comment search string and drop min coverage
* use replace on comment updates
* attempt at diffing coverage from main branch
* comment out tests to affect test coverage
* try method for multiline outputs
* do i need to put it in its own script file
* right, switch coverage gen order to have branch checked out second.
* attempt to get code quotation around diff output.
* switch to git diff
* add note about the new script.
* try echoing a warning.
* post warning on success and error on failure.
* uncomment tests
* Add checks for metadata state
Type metadata actually *is* mutable, is updated by the runtime, and we need to be careful when reading from it.
* Add a precondition for type metadata state
* Replace `precondition` with an `assert`
* Add missing license headers
Our OpenCombine fork no longer depends on Runtime, and we don't need much from it other than struct metadata. I removed the unused bits and bobs and kept only a minimal subset of it that we really need. This should make it easier for us to test and debug, as #367 has shown that some weird stuff may still lurk in that area.
* Add a test for environment injection
We had some issues in this code area previously and I'm thinking of refactoring it in attempt to fix#367. Would be great to increase the test coverage here before further refactoring.
* Update copyright years in `MountedElement.swift`
* Update copyright years in the rest of the files
* Vend the Runtime library directly
* Remove unused class, enum, tuple, func reflection
* Remove unused models and protocol metadata
* Remove unused MetadataType and NominalMetadataType
* Remove unused protocols, rename RelativePointer
* Remove more unused protocols
* Use immutable pointers for reflection
* Update copyright headers
David has previously submitted super useful bug reports and fixes, and his experience in porting larger projects from SwiftUI to Tokamak is very valuable. Welcome to the team!
* Add a test for environment injection
We had some issues in this code area previously and I'm thinking of refactoring it in attempt to fix#367. Would be great to increase the test coverage here before further refactoring.
* Update copyright years in `MountedElement.swift`
* Update copyright years in the rest of the files
This should allow us to remove the Runtime dependency eventually, which seems to be unstable, especially across different platforms and Swift versions.
Seems to resolve in one instance https://github.com/TokamakUI/Tokamak/issues/367. There are a few other places where `typeInfo` is still used, I'll clean that up in a follow-up PR.
* Replace uses of the Runtime library with stdlib
* Remove irrelevant Runtime library imports
* Add TokamakCoreBenchmark target
`macos-latest` still points to macOS 10.15 right now, which has more agent's capacity, and macOS 11.0 agents are slow and unreliable. At the dame time, we have to keep using macOS 11.0 for the core build to have access to the new `App` lifecycle in the native demo project.
* Add a benchmark target and a script to run it
Benchmarks need to be built in the release mode, that's why I created a separate `benchmark.sh` script to build it and run it.
I've also cleaned up a compiler warning in `TextEditor.swift` and bumped macOS agents to use Xcode 12.3 instead of 12.2.
* Benchmark `App` and `WindowGroup` rendering
* Add a `benchmark` task to `tasks.json`
* Exit `NativeDemo` directory before benchmarking
Both of these issues are fixes to `CustomStringConvertible` implementations that either directly or indirectly called themselves via `String(describing:)`.
* Add support for shadow modifier
Closes#324
* Convert radius to match iOS shadows closer
* Use correct environment values
* Include shadow demo in XCode project
An extra space was added at the beginning of the 'ry' attribute value of a rect. Safari reported: Error: Invalid value for <rect> attribute ry=" 25.0".
The code was clearing the queuedRerenders set after processing all of the updates on each re-renderer. However, during processing it is possible that new values were enqueued. By clearing the set afterwards, these newly queued re-renderers were accidentally dropped.
This would cause some Views to not update when @State was changed.
* Build the GTK renderer on Ubuntu on CI
* Add `--enable-test-discovery` flag to `Makefile`
* Use OpenCombine branch w/ no Runtime dependency
* Run `sudo apt-get update` on Ubuntu hosts
* Update OpenCombine dependency
* Pin OpenCombineJS dependency
* Update label.yml
* GTK shape support
* Support for ellipsis
* Allow drawing 'outside' of current frame. Experimental.
* Correctly support Capsules (rounded rects with nil cornerSize)
* Use boundingRect.size for Path size
* Refactored GdkRGBA from AnyColorBox.ResolvedValue to be reusable
* Added 'resolveToCairo(in environment:)' extension on Color
* Create slightly lighter View type hierarchies.
* Add a "bug report" issue template
We currently receive bug reports that don't always provide a self-contained code sample or screenshots to help us reproduce issues quickly or to add test cases. I hope that this issue template alleviates that.
* Apply suggestions from code review
Co-authored-by: Jed Fox <git@jedfox.com>
Co-authored-by: Jed Fox <git@jedfox.com>
Re-created #340.
* Added background modifier support for color backgrounds
* Fix indentation
* Allow WidgetView to be initialized with an update closure in order to fix updates to children of WidgetViews
* Fix indentation
Co-authored-by: Morten Bek Ditlevsen <morten@ka-ching.dk>
Based on the work discussed in #306.
* TokamakGTK implementation
* Fix macOS GTK Renderer impl
* Always release text in Picker. Use 'destroy_data' parameter to release closure boxes in GSignal.swift
* Revert commenting out this code
* Specify the product explicitly in Makefile
* Add GTK renderer build for macOS on CI
* Prevent xcodebuild from seeing GTK code
Co-authored-by: Carson Katri <carson.katri@gmail.com>
Co-authored-by: Morten Bek Ditlevsen <morten@ka-ching.dk>
This code had a missing `document` reference, and was plain outdated and not working with the latest version of JavaScriptKit.
Also, it turns out that `insertAdjacentHTML` does not work for script injection, although it does seem to work for styles injection. Separate `createElement`, `setAttribute`, and `appendChild` calls do seem to work for scripts.
* Add `TextEditor` implementation
Resolves#173.
* Clean up and bump requirements in the demo project
* Use a single `_tokamak-formcontrol` CSS class
* Add missing CSS class to `TextEditor.swift`
Co-authored-by: Jed Fox <git@jedfox.com>
Co-authored-by: Jed Fox <git@jedfox.com>
* Add `PreviewProvider` protocol
No functionality behind, just makes it easier to integrate with existing SwiftUI projects.
* Update PreviewProvider.swift
* Add missing preview-related types and modifiers