Commit Graph

48 Commits

Author SHA1 Message Date
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 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 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
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
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 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 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 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 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 f24a09f006
Apply latest SwiftFormat 2020-11-09 12:27:17 +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
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
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 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
Carson Katri 4c654da456
Add Static HTML Renderer and Documentation (#204) 2020-08-01 16:27:12 -04:00
Max Desiatov 2c539d9319
Make reconciler tests build and run on macOS (#229)
We can't run our basic reconciler tests in a WASI environment yet because `XCTestExpectation` is not available on WASI as it relies on the presence of `Dispatch`. We can run these tests on macOS though, and even on Linux in the future when Swift 5.3 is available for Linux on GitHub Actions.

My current OpenCombine fork doesn't build on macOS and it was much easier to add a new `CombineShim` module that uses native Combine there.
2020-07-30 16:48:09 +01:00
Max Desiatov 6e4e93602a
Bump JavaScriptKit to 0.5.0 (#201)
This change is required to make Tokamak compatible with `carton` 0.4, which bundles the latest JavaScriptKit runtime. Currently the new runtime and old Swift parts of JavaScriptKit are incompatible with each other, which leads to a white screen when building and running Tokamak from `main` with `carton` 0.4.

It's already a part of a couple of other PRs, but opening this one separately to expedite it as `carton` 0.4 is already released. I haven't announced it widely yet, so I hope we can merge this in quickly to avoid any confusion among our early adopters who try to use Tokamak with the latest version of `carton` 🙂
2020-07-22 16:32:10 +01:00
Max Desiatov 5f3822257d
Add `TokamakShim` module to simplify imports (#192)
Adding this module as a dependency, Tokamak users would only need to add a single import regardless of the platform they're targeting. Thus, instead of

```swift
#if canImport(SwiftUI)
import SwiftUI
#else
import TokamakDOM
#endif
```

a single `import TokamakShim` is enough. `TokamakShim` re-exports correct modules based on a target platform.

I've also renamed the `TokamakDemo Native` directory to `NativeDemo` for brevity.

`xcodebuild` output in the `macos_demo_build` job is now passed to `xcpretty` for more readable build logs.
2020-07-19 20:53:27 +01:00
Max Desiatov ffa686c7dc
Add @ObservedObject implementation (#171)
This pulls a fork of OpenCombine that can be compiled with the same SwiftWasm snapshot we use in `main`.

The only caveat is that this doesn't work for `ObservableObject`s that are subclasses of other classes with `@Published` properties. This issue needs to be fixed in [the Runtime library fork](https://github.com/MaxDesiatov/Runtime). Since this is a rare case, and fixing it wouldn't change this `@ObservedObject` implementation, I think it's ready for review as is.
2020-07-16 20:39:47 +01:00
Max Desiatov b29aa57aa2
Remove TokamakTestRenderer product (for now) 2020-06-23 12:07:00 +01:00
Max Desiatov 735251fb13
Rename Tokamak module to TokamakCore 2020-06-23 11:47:54 +01:00
Max Desiatov 83730ca55a
Revert "Add separate TokamakHTML module"
This reverts commit 498f033a43.
2020-06-23 11:31:27 +01:00
Max Desiatov 498f033a43
Add separate TokamakHTML module 2020-06-22 23:01:11 +01:00
Max Desiatov a25908a966
Use the latest JavaScriptKit dependency to fix RC 2020-06-21 22:32:50 +01:00
Max Desiatov 57fd08ab4e
Update JavaScriptKit, refine example Counter code 2020-06-20 00:59:03 +01:00
Max Desiatov 76de3eab74
Implement simple DOM updates 2020-06-17 21:50:22 +01:00
Max Desiatov 426bb999c5
Add basic DOM renderer 2020-06-17 00:58:10 +01:00
Max Desiatov 5e85356a1c
Migrate CI to GitHub Actions, test on Linux 2020-06-10 18:26:43 +01:00
Max Desiatov 8462bec94c
Remove unused .xcodeproj, update Runtime deps 2020-05-04 16:52:15 +01:00
Max Desiatov e1fb4f7c32
Add TokamakDOM, ViewDeferredToRenderer protocol 2020-04-11 21:58:24 +01:00
Max Desiatov 9407dd0674
Migrate reconciler and TestRenderer to View API (#107)
* Migrate reconciler and AppKit renderer to View API

* Fix building tests, cleanup unused code

* Remove more unused code

* Remove TokamakAppKit, add ParentView/GroupView

* Remove unused code, make testMount pass

* Cleanup more unused code

* Add ValueStorage protocol

* Add getter/setter internal properties on State

* Fix more State test assertions

* Fix all the reconciler tests 🎉
2020-04-11 18:21:04 +01:00
Max Desiatov 62f43d30fb
Add Binding property wrapper, remove unused code (#106) 2020-04-07 15:26:42 +01:00
matvii d0016c3141
Add TokamakLogger (#104)
* Init TokamakLogger

* Add TokamakLogger

* Apply swiftformat

* Fix var name

* Add TokamakLogger to project

* Add TokamakLoggerTest

* Remove unused code form TokamakLogger

* Remove logLevel proxying

* Add TokamakLoggerTest

* Add TokamakLoggerTest

* Add TokamakLogger to TokamakCLI

* Remove logLevel assignment

* Add TokamakCLI options bloc to Linter.md

* Remove force unwrap

* Add Logger

* Refactor TokamakLogHandler

* Apply swift format

* Fix error names

* Make error enum public
2019-06-04 16:52:58 +03:00
Max Desiatov 78fa74d592
Rename TokamakCLI executable to plain tokamak (#90) 2019-05-06 11:28:41 +01:00
matvii ee1f2d93c8
Add SwiftCLI dependency to TokamakCLI (#89)
* Add public lintFile

* Add SwiftCLI package

* Add CLI to TokamakCLI

* Apply swiftformat

* Fix TokamakCLI version

* Fix typo

* Update TokamakCLI error catch

* Update TokamakCLI path

* Update Linter.md

* Remove SRCROOT

* Update Linter.md

* Update XcodeReporter

* Update project.pbxproj

* Remove commented print
2019-05-03 19:26:08 +03:00
matvii 472dca3d36
Add TokamakLint module (#79)
* Init TokamakLint

* Fix Package.swift

* Move TokamakLint to Source

* Add SwiftSyntax to TokamakLint dependencies

* Rename TokamakLint to TokamaCLI

* Rename Lint.swift to main.swift

* Update TokamakCLI

* Init Lint Test

* Gererate project

* Update package.swift

* Clean and build

* Add Lint module

* Init test for one file

* Init file to test props

* Add test to check Props is Equatable

* Add lint warning

* Add warning to Props is not conformance from Equatable

* Init Linter doc & clean files

* Clean up code

* Format code

* Fix TokamakCLITest

* Fix Lint functions

* Remove IOU from TokenVisitor with optional

* Remove Encodable conformance from Node

* Remove unused file

* Rename test file

* Add comment of usage to `TestPropsEquatable`

* Remove unwanted methods

* Add scheme variable to TokamakCLI

* Update Linter.md

* Update TokamakCLI scheme

* Update Tokamak project

* Refactor TokamaLint

* Fix typo

* Add negative test to TokamakCLI

* Change output error function

* Simplify TokamakLint

* Fix TokamakLintTests

* Add error print to TokamakCLI

* Add error print to TokamakCLI

* Remove escapeHtmlSpecialCharacters

* Add print error to TokamakLint

* Add LintError

* Remove unused LintError case

* Expand LintError message

* Format LintError

* Format LintError
2019-04-08 17:07:55 +03:00
Max Desiatov b6c94827ef
Add build jobs/stages to .travis.yml (#80)
This will enable testing backward compatibility thanks to the build jobs for Xcode 10.0, 10.1 and 10.2.
2019-04-01 09:44:20 +01:00
Max Desiatov de0726914c
Add TokamakAppKit module (#60)
This also adds separate `TokamakDemo` module in the main project, which will host all examples that can be cross-platform. A few `Style` properties were removed, which were duplicated in UIKit and duplicated versions couldn't be cleanly mapped in AppKit. `contentMode` was moved from `Style` to `Image` as `NSView` doesn't have `contentMode` at all, and for UIKit the only use that I know of is related to `UIImage` anyway.

Resolves #1

* Mostly empty TokamakAppKit module, fix copyright text
* Add TokamakDemo module, working counter on macOS
* Fix layer props and accessibility for AppKit
* Fix linter issues, completely remove `center` prop
* Fix line length in NSViewComponent
* Remove unused and broken ScrollView for AppKit
* Add macOS column to StandardComponents.md
* Make contentMode on Image non-optional
* Fix missing initializer call in ImageView.swift
* Change the domain name for the docs dir
* Fix TokamakAppKit after text Children -> Props fix
2019-03-12 11:37:22 +00:00
Max Desiatov c197701e36
Rename Gluon to Tokamak (#44)
* Rename Gluon to Tokamak
* Fix scheme in .travis.yml, fix storyboard
2019-02-18 10:54:49 +00:00
Max Desiatov 0d467edbf8
Add .swiftlint.yml and fix linter warnings/errors 2018-12-29 14:41:46 +00:00
Max Desiatov e4ea316b3a
Apply SwiftFormat changes 2018-12-28 21:54:16 +00:00
Max Desiatov 5e4cd27726
Add GluonTestRenderer target, bump iOS version 2018-12-18 13:27:37 +00:00
Max Desiatov 072c37f693
Change file layout to support SwiftPM 2018-12-07 11:21:37 +00:00