Commit Graph

572 Commits

Author SHA1 Message Date
Max Desiatov 282e8dc02a
Stop assuming pointer type for generic arguments 2021-02-21 20:34:59 +00:00
Max Desiatov 63e4f84bd0
Add `print` statements to reproduce the issue 2021-02-15 21:37:23 +00:00
Max Desiatov eeddfe9e4b
Use immediate scheduler in TestRenderer (#380)
* 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
2021-02-15 11:36:23 +00:00
Mathew Polzin ea94ef9bcc
Simple Code Coverage analysis (#378)
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
2021-02-05 11:47:56 +00:00
Max Desiatov 53b474c33f
Delete unused `codecov.yml` config 2021-02-01 22:08:59 +00:00
Max Desiatov 5d951ad0af
Delete unused `codecov.sh` script 2021-02-01 22:08:39 +00:00
Max Desiatov d75b185553
Add checks for metadata state (#375)
* 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
2021-02-01 10:02:49 +00:00
Max Desiatov 9a79548312
Use upstream OpenCombine instead of a fork (#377) 2021-01-30 10:26:30 +00:00
Max Desiatov 30b8d46aa8
Update JavaScriptKit, OpenCombineJS dependencies (#376) 2021-01-29 07:53:21 +00:00
Max Desiatov 0e89ea9529
Clean up metadata reflection code (#372)
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
2021-01-27 18:24:04 +00:00
Max Desiatov 07ccef88e1
Add @foscomputerservices to the list of maintainers (#373)
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!
2021-01-25 20:08:53 +00:00
Max Desiatov 192c43b140
Refactor environment injection, add a test (#371)
* 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
2021-01-25 11:39:09 +00:00
Max Desiatov e04b7934fb
Replace uses of the Runtime library with stdlib (#370)
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
2021-01-24 15:26:51 +00:00
Max Desiatov 9549282e53
Use `macos-latest` agent for the GTK build (#360)
`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.
2021-01-22 12:54:49 +00:00
Max Desiatov 6f0528fe06
Add a benchmark target and a script to run it (#365)
* 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
2021-01-20 21:09:54 +00:00
Max Desiatov 67aea3cc3b
Fix crashes in views with optional content (#364)
* Add TokamakStaticHTMLTests target

* Add AnyOptional, clarify conformances issues
2021-01-20 08:07:01 +03:00
Morten Bek Ditlevsen 163005dfe0
Add GTK support for `SecureField` (#363) 2021-01-19 18:20:39 +01:00
David Hunt ee4e8debc1
Two infinite loop fixes (#359)
Both of these issues are fixes to `CustomStringConvertible` implementations that either directly or indirectly called themselves via `String(describing:)`.
2021-01-19 15:13:48 +03:00
Morten Bek Ditlevsen 9199a90551
Added TextField support for GTK using GtkEntry (#361)
* Added TextField to TokamakGTK - WIP

* Made TextView update on gtk entry changes
2021-01-19 12:47:06 +01:00
Benjamin Kindle 5ca914818c
Add support for shadow modifier (#355)
* Add support for shadow modifier

Closes #324

* Convert radius to match iOS shadows closer

* Use correct environment values

* Include shadow demo in XCode project
2021-01-19 09:12:43 +00:00
David Hunt 1330b5306b
Removed an extra space that cause Safari to issue "Invalid value" errors and not load the pages (#358)
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".
2021-01-18 16:22:08 +03:00
David Hunt 6955e56f77
Fixed a small issue with re-renderers being dropped (#356)
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.
2021-01-18 15:39:03 +03:00
Max Desiatov e893e7ad8d
Add @mortenbekditlevsen to the list of maintainers in `README.md` (#352)
Just formalizing what was already a fact for a while, Morten has made some fantastic contributions to the GTK renderer!
2021-01-15 13:52:44 +00:00
Max Desiatov 3a0f8a8dd9
Build the GTK renderer on Ubuntu on CI (#347)
* 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
2021-01-13 10:40:28 +00:00
Max Desiatov 362be5a5fa
Add missing `Link` re-export to TokamakDOM (#351) 2021-01-13 01:05:13 +00:00
Morten Bek Ditlevsen 25e2191154
GTK shape support WIP (#348)
* 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.
2021-01-12 12:09:25 +01:00
Max Desiatov b55f703972
Add a "bug report" issue template (#349)
* 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>
2021-01-08 14:53:17 +00:00
Morten Bek Ditlevsen a97a05ffd2
Allow gtk modifiers to be expressed as css attributes. (#345) 2020-12-31 23:15:00 +01:00
Max Desiatov c9877dcbd7
GTK: `background` modifier, support widget updates in `WidgetView` (#344)
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>
2020-12-26 19:22:16 +00:00
Max Desiatov 6ef59293f5
Add `Image` implementation to the GTK renderer (#343)
* Add rudimentary Image support

* Added Image implementation and sample image

* Updated sample and scaled down image

* Removed commented code

* Update main.swift

Co-authored-by: Morten Bek Ditlevsen <morten@ka-ching.dk>
2020-12-26 19:21:01 +00:00
Max Desiatov 99bcfd12b9
Add `GTK renderer` to the list of supported labels 2020-12-26 16:26:10 +00:00
Max Desiatov bd38866cb2
Add basic GTK renderer code (#333)
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>
2020-12-26 16:11:06 +00:00
Jed Fox 8e5ad7f67f
Remove extra `path` element (#341)
The blue capsule in the PathDemo, rendered to HTML:

```diff
 <svg style="width: 100%;height: 100%; overflow: visible;">
   <rect
     x="0.0"
     height="100%"
     width="100%"
     y="0.0"
     ry="50%"
     stroke-width="0.0"
   ></rect>
-  <path style="stroke-width: 0.0;" d=""></path>
 </svg>
```

* Run swiftformat

* Remove excess `path` element
2020-12-22 23:03:00 +00:00
Max Desiatov 3c97be617a
Update script injection code in `README.md` (#332)
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.
2020-12-19 15:28:30 +00:00
David Hunt ba17b79b1d
Added some missing TokamakDOM/Core type typealiases (#331) 2020-12-10 10:42:59 +00:00
Max Desiatov 99581929a2
Add `TextEditor` implementation (#329)
* 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>
2020-12-07 21:13:24 +00:00
Max Desiatov 302cd3b108
Add `PreviewProvider` protocol (#328)
* 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
2020-12-07 17:55:20 +00:00
Max Desiatov 8230e98072
Add Discord link to `README.md` 2020-12-06 17:12:22 +00:00
Max Desiatov b4b0efca4d
Bump version to 0.6.1, update `CHANGELOG.md` 2020-12-06 14:34:12 +00:00
Max Desiatov e7f295954f
Add macOS `xcodebuild` invocation to `ci.yml` 2020-12-06 14:28:48 +00:00
Max Desiatov 37cdf6e454
Use `lowercased()` to fix Xcode autocomplete issue 2020-12-06 14:21:50 +00:00
Max Desiatov 8ad964c2f9
Mark `Link` view as implemented in `progress.md` 2020-12-06 13:56:53 +00:00
Max Desiatov abceb8609f
Update progress.md 2020-12-04 11:38:01 +00:00
Max Desiatov 2f97ecfe16
Bump version to 0.6.0, update `CHANGELOG.md` 2020-12-04 11:35:22 +00:00
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