diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fb171801..cc088e0ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,99 +6,84 @@ on: branches: [main] jobs: - swiftwasm_bundle_5_4: + swiftwasm_bundle_5_6: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.4 + - uses: swiftwasm/swiftwasm-action@main with: shell-action: carton bundle --product TokamakDemo - swiftwasm_test_5_4: + swiftwasm_test_5_6: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.4 + - uses: swiftwasm/swiftwasm-action@main with: shell-action: carton test - swiftwasm_bundle_5_5: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.5 - with: - shell-action: carton bundle --product TokamakDemo - - swiftwasm_test_5_5: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.5 - with: - shell-action: carton test - - core_macos_build: - runs-on: macos-11 - - steps: - - uses: actions/checkout@v2 - - name: Run the test suite on macOS, build the demo project for iOS - shell: bash - run: | - set -ex - sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer/ - # avoid building unrelated products for testing by specifying the test product explicitly - swift build --product TokamakPackageTests - `xcrun --find xctest` .build/debug/TokamakPackageTests.xctest || - (cp -r /var/folders/*/*/*/*Tests . ; exit 1) - - rm -rf Sources/TokamakGTKCHelpers/*.c - - xcodebuild -version - - # Make sure Tokamak can be built on macOS so that Xcode autocomplete works. - # Disable macOS builds until Monterey is available on GHA. - # xcodebuild -scheme TokamakDemo -destination 'generic/platform=macOS' \ - # CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | \ - # xcpretty --color - - cd "NativeDemo" - xcodebuild -scheme iOS -destination 'generic/platform=iOS' \ - CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | \ - xcpretty --color - cd .. - - ./benchmark.sh - - - name: Upload failed snapshots - uses: actions/upload-artifact@v2 - if: ${{ failure() }} - with: - name: Failed snapshots - path: '*Tests' - - gtk_macos_build: - runs-on: macos-11 - - steps: - - uses: actions/checkout@v2 - - name: Build the GTK renderer on macOS - shell: bash - run: | - set -ex - sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer/ - - brew install gtk+3 - - make build + # Disabled until macos-12 is available on GitHub Actions, which is required for Xcode 13.3 + # core_macos_build: + # runs-on: macos-11 + + # steps: + # - uses: actions/checkout@v2 + # - name: Run the test suite on macOS, build the demo project for iOS + # shell: bash + # run: | + # set -ex + # sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer/ + # # avoid building unrelated products for testing by specifying the test product explicitly + # swift build --product TokamakPackageTests + # `xcrun --find xctest` .build/debug/TokamakPackageTests.xctest || + # (cp -r /var/folders/*/*/*/*Tests . ; exit 1) + + # rm -rf Sources/TokamakGTKCHelpers/*.c + + # xcodebuild -version + + # # Make sure Tokamak can be built on macOS so that Xcode autocomplete works. + # # Disable macOS builds until Monterey is available on GHA. + # # xcodebuild -scheme TokamakDemo -destination 'generic/platform=macOS' \ + # # CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | \ + # # xcpretty --color + + # cd "NativeDemo" + # xcodebuild -scheme iOS -destination 'generic/platform=iOS' \ + # CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO | \ + # xcpretty --color + # cd .. + + # ./benchmark.sh + + # - name: Upload failed snapshots + # uses: actions/upload-artifact@v2 + # if: ${{ failure() }} + # with: + # name: Failed snapshots + # path: '*Tests' + + # gtk_macos_build: + # runs-on: macos-11 + + # steps: + # - uses: actions/checkout@v2 + # - name: Build the GTK renderer on macOS + # shell: bash + # run: | + # set -ex + # sudo xcode-select --switch /Applications/Xcode_13.0.app/Contents/Developer/ + + # brew install gtk+3 + + # make build gtk_ubuntu_18_04_build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + container: + image: swiftlang/swift:nightly-bionic steps: - uses: actions/checkout@v2 @@ -106,13 +91,14 @@ jobs: shell: bash run: | set -ex - sudo apt-get update - sudo apt-get install libgtk+-3.0 gtk+-3.0 + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential libgtk+-3.0 gtk+-3.0 make build gtk_ubuntu_20_04_build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest + container: + image: swiftlang/swift:nightly-focal steps: - uses: actions/checkout@v2 @@ -120,7 +106,6 @@ jobs: shell: bash run: | set -ex - sudo apt-get update - sudo apt-get install libgtk+-3.0 gtk+-3.0 + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential libgtk+-3.0 gtk+-3.0 make build diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 0c71d264e..bfe844cd9 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,4 +1,3 @@ - name: Codecov on: @@ -9,21 +8,21 @@ on: jobs: codecov: container: - image: swift:5.4-bionic + image: swiftlang/swift:nightly-focal runs-on: ubuntu-latest steps: - - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 + - run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y gtk+-3.0 libgtk+-3.0 - name: Checkout Branch uses: actions/checkout@v2 - name: Build Test Target - run: swift build --enable-test-discovery -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests + run: swift build -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests - name: Run Tests - run: swift test --enable-test-discovery --enable-code-coverage --skip-build + run: swift test --enable-code-coverage --skip-build - name: Generate Branch Coverage Report - uses: mattpolzin/swift-codecov-action@0.6.1 + uses: mattpolzin/swift-codecov-action@0.7.1 id: cov with: - MINIMUM_COVERAGE: 20 + MINIMUM_COVERAGE: 15 - name: Post Positive Results if: ${{ success() }} run: | @@ -32,4 +31,3 @@ jobs: if: ${{ failure() }} run: | echo "::error file=Package.swift,line=1,col=1::The current code coverage percentage is failing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)." - diff --git a/.gitignore b/.gitignore index 5dfe99d01..ce73c35b3 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ Pods/ # SwiftPM .build /Packages + +# VS Code +.vscode/launch.json diff --git a/.swift-version b/.swift-version new file mode 100644 index 000000000..08ddfb781 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +wasm-5.6.0-RELEASE diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 680681503..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "preLaunchTask": "make", - "type": "lldb", - "request": "launch", - "name": "Debug", - "program": "${workspaceFolder}/.build/debug/TokamakGTKDemo", - "args": [], - "cwd": "${workspaceFolder}" - } - ] -} \ No newline at end of file diff --git a/Package.resolved b/Package.resolved index 34c860ff7..6de7c28eb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/swiftwasm/JavaScriptKit.git", "state": { "branch": null, - "revision": "6c31bad4b1ef18385262f5154845648c8c95ae94", - "version": "0.12.0" + "revision": "9a3b7d5f316e6d1709bd25e3e0392efca357f525", + "version": "0.14.0" } }, { diff --git a/Package.swift b/Package.swift index e14cae7ac..be7bc2660 100644 --- a/Package.swift +++ b/Package.swift @@ -1,32 +1,7 @@ -// swift-tools-version:5.4 +// swift-tools-version:5.6 import PackageDescription -var tokamakDOMDependencies: [Target.Dependency] = [ - "TokamakCore", - "TokamakStaticHTML", - .product( - name: "OpenCombineShim", - package: "OpenCombine" - ), - .product( - name: "JavaScriptKit", - package: "JavaScriptKit", - condition: .when(platforms: [.wasi]) - ), - "OpenCombineJS", -] - -#if compiler(>=5.5) && (canImport(Concurrency) || canImport(_Concurrency)) -tokamakDOMDependencies.append( - .product( - name: "JavaScriptEventLoop", - package: "JavaScriptKit", - condition: .when(platforms: [.wasi]) - ) -) -#endif - let package = Package( name: "Tokamak", platforms: [ @@ -72,7 +47,7 @@ let package = Package( dependencies: [ .package( url: "https://github.com/swiftwasm/JavaScriptKit.git", - .upToNextMinor(from: "0.12.0") + .upToNextMinor(from: "0.14.0") ), .package( url: "https://github.com/OpenCombine/OpenCombine.git", @@ -83,12 +58,10 @@ let package = Package( .upToNextMinor(from: "0.1.2") ), .package( - name: "Benchmark", url: "https://github.com/google/swift-benchmark", from: "0.1.0" ), .package( - name: "SnapshotTesting", url: "https://github.com/pointfreeco/swift-snapshot-testing.git", from: "1.9.0" ), @@ -160,20 +133,38 @@ let package = Package( .executableTarget( name: "TokamakCoreBenchmark", dependencies: [ - "Benchmark", + .product(name: "Benchmark", package: "swift-benchmark"), "TokamakCore", ] ), .executableTarget( name: "TokamakStaticHTMLBenchmark", dependencies: [ - "Benchmark", + .product(name: "Benchmark", package: "swift-benchmark"), "TokamakStaticHTML", ] ), .target( name: "TokamakDOM", - dependencies: tokamakDOMDependencies + dependencies: [ + "TokamakCore", + "TokamakStaticHTML", + .product( + name: "OpenCombineShim", + package: "OpenCombine" + ), + .product( + name: "JavaScriptKit", + package: "JavaScriptKit", + condition: .when(platforms: [.wasi]) + ), + .product( + name: "JavaScriptEventLoop", + package: "JavaScriptKit", + condition: .when(platforms: [.wasi]) + ), + "OpenCombineJS", + ] ), .executableTarget( name: "TokamakDemo", @@ -213,7 +204,7 @@ let package = Package( "TokamakStaticHTML", .product( name: "SnapshotTesting", - package: "SnapshotTesting", + package: "swift-snapshot-testing", condition: .when(platforms: [.macOS]) ), ], diff --git a/README.md b/README.md index c7374c471..67e359e16 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,8 @@ struct MouseEventsView: View { listeners: [ "mousemove": { event in guard - let x = event.offsetX.jsValue().number, - let y = event.offsetY.jsValue().number + let x = event.offsetX.jsValue.number, + let y = event.offsetY.jsValue.number else { return } position = CGPoint(x: x, y: y) @@ -142,10 +142,10 @@ app. ### For app developers -- macOS 11 and Xcode 13.0 or later. Xcode 13.2 or later is recommended if you're developing -multi-platform apps that target WebAssembly and macOS at the same time, as these versions support -Swift concurrency back-deployment. -- [Swift 5.4 or later](https://swift.org/download/) and Ubuntu 18.04 if you'd like to use Linux. +- macOS 11 and Xcode 13.2 or later when using VS Code. macOS 12 and Xcode 13.3 or later are recommended if +you'd like to use Xcode for auto-completion, or when developing multi-platform apps that target WebAssembly +and macOS at the same time. +- [Swift 5.6 or later](https://swift.org/download/) and Ubuntu 18.04/20.04 if you'd like to use Linux. Other Linux distributions are currently not supported. ### For users of apps depending on Tokamak @@ -183,7 +183,7 @@ app by following these steps: brew install swiftwasm/tap/carton ``` -If you had `carton` installed before this, make sure you have version 0.12.0 or greater: +If you had `carton` installed before this, make sure you have version 0.14.0 or greater: ``` carton --version @@ -269,7 +269,7 @@ doesn't provide an official build of the extension on the VSCode Marketplace unf All contributions, no matter how small, are very welcome. You don't have to be a web developer or a SwiftUI expert to meaningfully contribute. In fact, by checking out how some of the simplest views are -implemented in Tokamak you may learn more how SwiftUI may work under the hood. +implemented in Tokamak you may learn more how SwiftUI may work under the hood. Updating our [documentation](https://github.com/TokamakUI/Tokamak/tree/main/docs) and taking on [the starter bugs](https://github.com/TokamakUI/Tokamak/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) diff --git a/Sources/TokamakCore/Environment/EnvironmentValues.swift b/Sources/TokamakCore/Environment/EnvironmentValues.swift index e54a00f86..dc1ec51d7 100644 --- a/Sources/TokamakCore/Environment/EnvironmentValues.swift +++ b/Sources/TokamakCore/Environment/EnvironmentValues.swift @@ -47,7 +47,7 @@ public struct EnvironmentValues: CustomStringConvertible { @_spi(TokamakCore) public mutating func merge(_ other: Self?) { if let other = other { - values.merge(other.values) { existing, new in + values.merge(other.values) { _, new in new } } diff --git a/Sources/TokamakCore/Modifiers/Effects/ScaleEffect.swift b/Sources/TokamakCore/Modifiers/Effects/ScaleEffect.swift index 4fcc7b425..9e03cc416 100644 --- a/Sources/TokamakCore/Modifiers/Effects/ScaleEffect.swift +++ b/Sources/TokamakCore/Modifiers/Effects/ScaleEffect.swift @@ -48,9 +48,11 @@ public extension View { } @inlinable - func scaleEffect(x: CGFloat = 1.0, y: CGFloat = 1.0, - anchor: UnitPoint = .center) -> some View - { + func scaleEffect( + x: CGFloat = 1.0, + y: CGFloat = 1.0, + anchor: UnitPoint = .center + ) -> some View { scaleEffect(CGSize(width: x, height: y), anchor: anchor) } } diff --git a/Sources/TokamakCore/Modifiers/Navigation.swift b/Sources/TokamakCore/Modifiers/Navigation.swift index 84b6046ec..5018f6d78 100644 --- a/Sources/TokamakCore/Modifiers/Navigation.swift +++ b/Sources/TokamakCore/Modifiers/Navigation.swift @@ -28,9 +28,10 @@ public extension View { deprecated, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)" ) - func navigationBarTitle(_ title: Text, - displayMode: NavigationBarItem.TitleDisplayMode) -> some View - { + func navigationBarTitle( + _ title: Text, + displayMode: NavigationBarItem.TitleDisplayMode + ) -> some View { navigationTitle(title) .navigationBarTitleDisplayMode(displayMode) } @@ -62,9 +63,10 @@ public extension View { preference(key: NavigationTitleKey.self, value: AnyView(title())) } - func navigationBarTitleDisplayMode(_ displayMode: NavigationBarItem - .TitleDisplayMode) -> some View - { + func navigationBarTitleDisplayMode( + _ displayMode: NavigationBarItem + .TitleDisplayMode + ) -> some View { preference(key: NavigationBarItemKey.self, value: .init(displayMode: displayMode)) } } diff --git a/Sources/TokamakCore/Modifiers/TaskModifier.swift b/Sources/TokamakCore/Modifiers/TaskModifier.swift index 304203eb1..0cf5bace3 100644 --- a/Sources/TokamakCore/Modifiers/TaskModifier.swift +++ b/Sources/TokamakCore/Modifiers/TaskModifier.swift @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if compiler(>=5.5) && (canImport(Concurrency) || canImport(_Concurrency)) - public extension View { func task( priority: TaskPriority = .userInitiated, @@ -28,5 +26,3 @@ public extension View { } } } - -#endif diff --git a/Sources/TokamakCore/Tokens/Font/Font.swift b/Sources/TokamakCore/Tokens/Font/Font.swift index e5e9bdee1..415493d57 100644 --- a/Sources/TokamakCore/Tokens/Font/Font.swift +++ b/Sources/TokamakCore/Tokens/Font/Font.swift @@ -52,9 +52,11 @@ public enum _FontNames: Hashable { } public extension Font { - static func system(size: CGFloat, weight: Weight = .regular, - design: Design = .default) -> Self - { + static func system( + size: CGFloat, + weight: Weight = .regular, + design: Design = .default + ) -> Self { .init( _ConcreteFontBox( .init( diff --git a/Sources/TokamakCore/ViewTraits/Transition/Transition.swift b/Sources/TokamakCore/ViewTraits/Transition/Transition.swift index 5f53a7cd0..d6de7d9b2 100644 --- a/Sources/TokamakCore/ViewTraits/Transition/Transition.swift +++ b/Sources/TokamakCore/ViewTraits/Transition/Transition.swift @@ -59,7 +59,7 @@ public extension View { /// A `ViewModifier` used to apply a primitive transition to a `View`. public protocol _AnyTransitionModifier: AnimatableModifier - where Body == Self.Content + where Body == Content { var isActive: Bool { get } } diff --git a/Sources/TokamakCore/Views/Canvas/TimelineView.swift b/Sources/TokamakCore/Views/Canvas/TimelineView.swift index 00c68cf5b..c6f2e3100 100644 --- a/Sources/TokamakCore/Views/Canvas/TimelineView.swift +++ b/Sources/TokamakCore/Views/Canvas/TimelineView.swift @@ -132,9 +132,10 @@ public struct EveryMinuteTimelineSchedule: TimelineSchedule { public init() {} - public func entries(from startDate: Date, - mode: TimelineScheduleMode) -> EveryMinuteTimelineSchedule.Entries - { + public func entries( + from startDate: Date, + mode: TimelineScheduleMode + ) -> EveryMinuteTimelineSchedule.Entries { Entries(date: startDate) } } diff --git a/Sources/TokamakCore/Views/Image.swift b/Sources/TokamakCore/Views/Image.swift index 9cd0fbcfe..314560b66 100644 --- a/Sources/TokamakCore/Views/Image.swift +++ b/Sources/TokamakCore/Views/Image.swift @@ -133,9 +133,10 @@ public extension Image { case stretch } - func resizable(capInsets: EdgeInsets = EdgeInsets(), - resizingMode: ResizingMode = .stretch) -> Image - { + func resizable( + capInsets: EdgeInsets = EdgeInsets(), + resizingMode: ResizingMode = .stretch + ) -> Image { .init(ResizableProvider(parent: provider, capInsets: capInsets, resizingMode: resizingMode)) } } diff --git a/Sources/TokamakCore/Views/Navigation/ToolbarContentBuilder.swift b/Sources/TokamakCore/Views/Navigation/ToolbarContentBuilder.swift index 1d05936ba..5babfecbf 100644 --- a/Sources/TokamakCore/Views/Navigation/ToolbarContentBuilder.swift +++ b/Sources/TokamakCore/Views/Navigation/ToolbarContentBuilder.swift @@ -29,8 +29,10 @@ public enum ToolbarContentBuilder { // swiftlint:disable function_parameter_count public extension ToolbarContentBuilder { - static func buildBlock(_ c0: ToolbarItem, - _ c1: ToolbarItem) -> ToolbarItemGroup< + static func buildBlock( + _ c0: ToolbarItem, + _ c1: ToolbarItem + ) -> ToolbarItemGroup< ID, (ToolbarItem, ToolbarItem) > @@ -41,8 +43,11 @@ public extension ToolbarContentBuilder { } public extension ToolbarContentBuilder { - static func buildBlock(_ c0: ToolbarItem, _ c1: ToolbarItem, - _ c2: ToolbarItem) + static func buildBlock( + _ c0: ToolbarItem, + _ c1: ToolbarItem, + _ c2: ToolbarItem + ) -> ToolbarItemGroup, ToolbarItem, ToolbarItem)> where C0: View, C1: View, C2: View { diff --git a/Sources/TokamakCore/Views/View.swift b/Sources/TokamakCore/Views/View.swift index 4e6f4ad2f..6f921e56c 100644 --- a/Sources/TokamakCore/Views/View.swift +++ b/Sources/TokamakCore/Views/View.swift @@ -28,7 +28,7 @@ public extension Never { } } -extension Never: _PrimitiveView {} +extension Never: View {} /// A `View` that offers primitive functionality, which renders its `body` inaccessible. public protocol _PrimitiveView: View where Body == Never {} diff --git a/Sources/TokamakDOM/DOMNode.swift b/Sources/TokamakDOM/DOMNode.swift index fbe2b9d75..de3d0452b 100644 --- a/Sources/TokamakDOM/DOMNode.swift +++ b/Sources/TokamakDOM/DOMNode.swift @@ -46,7 +46,7 @@ extension _AnimationBoxBase._Resolved._RepeatStyle { var jsValue: JSValue { switch self { case let .fixed(count, _): - return count.jsValue() + return count.jsValue case .forever: return JSObject.global.Infinity } @@ -179,16 +179,16 @@ final class DOMNode: Target { ) -> JSValue? { let resolved = _AnimationProxy(animation).resolve() return ref.animate?( - keyframes.jsValue(), + keyframes, [ - "duration": (resolved.duration / resolved.speed) * 1000, - "delay": resolved.delay * 1000, - "easing": resolved.style.cssValue, + "duration": ((resolved.duration / resolved.speed) * 1000).jsValue, + "delay": (resolved.delay * 1000).jsValue, + "easing": resolved.style.cssValue.jsValue, "iterations": resolved.repeatStyle.jsValue, - "direction": resolved.repeatStyle.autoreverses ? "alternate" : "normal", + "direction": (resolved.repeatStyle.autoreverses ? "alternate" : "normal").jsValue, // Keep the last keyframe applied when done, and the first applied during a delay. - "fill": "both", - "iterationStart": iterationStart, + "fill": "both".jsValue, + "iterationStart": iterationStart.jsValue, ] ) } @@ -202,7 +202,7 @@ final class DOMNode: Target { let startStyle = Dictionary(uniqueKeysWithValues: extractStyles(compute: computeStart).map { ($0.animatableProperty, $1) - }).jsValue() + }).jsValue ref.style.object?.cssText = .string(style) let endStyle = Dictionary(uniqueKeysWithValues: extractStyles().map { ($0.animatableProperty, $1) @@ -215,7 +215,7 @@ final class DOMNode: Target { for iterationStart in stride(from: 0, to: 1, by: 0.01) { // Create and immediately cancel an animation after reading the computed values. if let animation = animate( - keyframes: [startStyle, endStyle.jsValue()], + keyframes: [startStyle, endStyle.jsValue], with: Animation.linear(duration: resolved.duration).delay(resolved.delay), offsetBy: iterationStart )?.object, @@ -235,10 +235,10 @@ final class DOMNode: Target { * Double(values.count - 1) var res = values[Int(solved)] res["offset"] = "\(offset)" - return res.jsValue() - } + [endStyle.jsValue()] // Add the end for good measure. + return res.jsValue + } + [endStyle.jsValue] // Add the end for good measure. } else { - keyframes = [startStyle, endStyle.jsValue()] + keyframes = [startStyle, endStyle.jsValue] } // Animate the styles. animate(keyframes: keyframes, with: animation) diff --git a/Sources/TokamakDOM/DOMRenderer.swift b/Sources/TokamakDOM/DOMRenderer.swift index e429227c9..6a381d0e5 100644 --- a/Sources/TokamakDOM/DOMRenderer.swift +++ b/Sources/TokamakDOM/DOMRenderer.swift @@ -15,15 +15,12 @@ // Created by Max Desiatov on 11/04/2020. // +import JavaScriptEventLoop import JavaScriptKit import OpenCombineJS @_spi(TokamakCore) import TokamakCore import TokamakStaticHTML -#if compiler(>=5.5) && (canImport(Concurrency) || canImport(_Concurrency)) -import JavaScriptEventLoop -#endif - public typealias Sanitizers = TokamakStaticHTML.Sanitizers extension EnvironmentValues { @@ -91,9 +88,7 @@ final class DOMRenderer: Renderer { rootRef = ref appendRootStyle(ref) - #if compiler(>=5.5) && (canImport(Concurrency) || canImport(_Concurrency)) JavaScriptEventLoop.installGlobalExecutor() - #endif let scheduler = JSScheduler() self.scheduler = scheduler diff --git a/Sources/TokamakDOM/Views/Canvas/Canvas.swift b/Sources/TokamakDOM/Views/Canvas/Canvas.swift index a6f10c85c..d98d63a51 100644 --- a/Sources/TokamakDOM/Views/Canvas/Canvas.swift +++ b/Sources/TokamakDOM/Views/Canvas/Canvas.swift @@ -187,9 +187,11 @@ struct _Canvas: View { } extension GraphicsContext.Shading { - func cssValue(in environment: EnvironmentValues, with canvas: JSObject, - bounds: CGRect) -> JSValue - { + func cssValue( + in environment: EnvironmentValues, + with canvas: JSObject, + bounds: CGRect + ) -> JSValue { if case let .resolved(resolved) = _resolve(in: environment)._storage { return resolved.cssValue(in: environment, with: canvas, bounds: bounds) } @@ -198,9 +200,11 @@ extension GraphicsContext.Shading { } extension GraphicsContext._ResolvedShading { - func cssValue(in environment: EnvironmentValues, with canvas: JSObject, - bounds: CGRect) -> JSValue - { + func cssValue( + in environment: EnvironmentValues, + with canvas: JSObject, + bounds: CGRect + ) -> JSValue { switch self { case let .levels(palette): guard let primary = palette.first else { break } diff --git a/Sources/TokamakGTK/Widget.swift b/Sources/TokamakGTK/Widget.swift index c8cb5a894..115a527d8 100644 --- a/Sources/TokamakGTK/Widget.swift +++ b/Sources/TokamakGTK/Widget.swift @@ -31,11 +31,12 @@ struct WidgetView: View, AnyWidget, ParentView { let content: Content let expand: Bool - init(build: @escaping (UnsafeMutablePointer) -> UnsafeMutablePointer, - update: @escaping (Widget) -> () = { _ in }, - expand: Bool = false, - @ViewBuilder content: () -> Content) - { + init( + build: @escaping (UnsafeMutablePointer) -> UnsafeMutablePointer, + update: @escaping (Widget) -> () = { _ in }, + expand: Bool = false, + @ViewBuilder content: () -> Content + ) { self.build = build self.expand = expand self.content = content() @@ -62,9 +63,10 @@ struct WidgetView: View, AnyWidget, ParentView { } extension WidgetView where Content == EmptyView { - init(build: @escaping (UnsafeMutablePointer) -> UnsafeMutablePointer, - expand: Bool = false) - { + init( + build: @escaping (UnsafeMutablePointer) -> UnsafeMutablePointer, + expand: Bool = false + ) { self.init(build: build, expand: expand) { EmptyView() } } } diff --git a/Sources/TokamakStaticHTML/Views/Text/Text.swift b/Sources/TokamakStaticHTML/Views/Text/Text.swift index 49c986c9e..c0511404f 100644 --- a/Sources/TokamakStaticHTML/Views/Text/Text.swift +++ b/Sources/TokamakStaticHTML/Views/Text/Text.swift @@ -168,9 +168,9 @@ extension Text { var fontStack: [Font] = [] var color: Color? - var italic: Bool = false + var italic = false var weight: Font.Weight? - var kerning: String = "normal" + var kerning = "normal" var baseline: CGFloat? var strikethrough: (Bool, Color?)? var underline: (Bool, Color?)?