From 7c85175e4d39a9009e79a62b5161f5caca2f9262 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 5 Apr 2022 10:33:18 +0100 Subject: [PATCH 01/25] Build and test with SwiftWasm 5.6 on CI Configuration for simultaneous builds with SwiftWasm 5.4, 5.5, and 5.6 can't be specified more succinctly due to swiftwasm/swiftwasm-action#3. I had to create almost duplicate job descriptions because of that. --- .github/workflows/ci.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fb171801..b81b9d97c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,24 @@ jobs: with: shell-action: carton test + swiftwasm_bundle_5_6: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - uses: swiftwasm/swiftwasm-action@v5.6 + with: + shell-action: carton bundle --product TokamakDemo + + swiftwasm_test_5_6: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + - uses: swiftwasm/swiftwasm-action@v5.6 + with: + shell-action: carton test + core_macos_build: runs-on: macos-11 From e7b44b4413e5f02b587e4a3abcc7aedeb24ca195 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 5 Apr 2022 10:34:28 +0100 Subject: [PATCH 02/25] Create .swift-version --- .swift-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .swift-version 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 From ef4eb7b9e3e79acd17a383c1c675d99c23f49566 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 5 Apr 2022 10:37:35 +0100 Subject: [PATCH 03/25] Specify `main` version for 5.6 jobs --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b81b9d97c..167f962c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.6 + - uses: swiftwasm/swiftwasm-action@main with: shell-action: carton bundle --product TokamakDemo @@ -56,7 +56,7 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.6 + - uses: swiftwasm/swiftwasm-action@main with: shell-action: carton test From 006ddbc8f10e9062dd51238327e470b47fe51bdf Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Tue, 5 Apr 2022 11:17:56 +0100 Subject: [PATCH 04/25] Fix build issue with SwiftWasm 5.6 --- .../Environment/EnvironmentValues.swift | 2 +- .../Modifiers/Effects/ScaleEffect.swift | 8 +++++--- Sources/TokamakCore/Modifiers/Navigation.swift | 14 ++++++++------ Sources/TokamakCore/Tokens/Font/Font.swift | 8 +++++--- .../Views/Canvas/TimelineView.swift | 7 ++++--- Sources/TokamakCore/Views/Image.swift | 7 ++++--- .../Navigation/ToolbarContentBuilder.swift | 13 +++++++++---- Sources/TokamakCore/Views/View.swift | 2 +- Sources/TokamakDOM/Views/Canvas/Canvas.swift | 16 ++++++++++------ Sources/TokamakGTK/Widget.swift | 18 ++++++++++-------- .../TokamakStaticHTML/Views/Text/Text.swift | 4 ++-- 11 files changed, 59 insertions(+), 40 deletions(-) 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/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/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/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?)? From e5dd8fea5b94528af5e49ced00aec3250842944b Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 7 Apr 2022 04:20:58 +0900 Subject: [PATCH 05/25] Update JavaScriptKit to 0.13.0 --- Package.resolved | 4 ++-- Package.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Package.resolved b/Package.resolved index 34c860ff7..1b85d83e5 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": "2011cc0422eb820c36d7cc275e0992ec5ca9ab34", + "version": "0.13.0" } }, { diff --git a/Package.swift b/Package.swift index e14cae7ac..673dd0299 100644 --- a/Package.swift +++ b/Package.swift @@ -72,7 +72,7 @@ let package = Package( dependencies: [ .package( url: "https://github.com/swiftwasm/JavaScriptKit.git", - .upToNextMinor(from: "0.12.0") + .upToNextMinor(from: "0.13.0") ), .package( url: "https://github.com/OpenCombine/OpenCombine.git", From 991c603f1c95a4fab7371fb1a19d4a0318fe646c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:23:04 +0100 Subject: [PATCH 06/25] Update to latest JSKit, drop SwiftWasm 5.4/5.5 --- .github/workflows/ci.yml | 36 --------- .vscode/launch.json | 131 +++++++++++++++++++++++++++---- Package.resolved | 4 +- Package.swift | 57 ++++++-------- README.md | 14 ++-- Sources/TokamakDOM/DOMNode.swift | 26 +++--- 6 files changed, 160 insertions(+), 108 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 167f962c0..0f4c861c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,42 +6,6 @@ on: branches: [main] jobs: - swiftwasm_bundle_5_4: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.4 - with: - shell-action: carton bundle --product TokamakDemo - - swiftwasm_test_5_4: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v2 - - uses: swiftwasm/swiftwasm-action@v5.4 - 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 - swiftwasm_bundle_5_6: runs-on: ubuntu-20.04 diff --git a/.vscode/launch.json b/.vscode/launch.json index 680681503..bead6bf4e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,17 +1,116 @@ { - // 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 + // 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}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug TokamakDemo", + "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakDemo", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Debug TokamakDemo" + }, + { + "type": "lldb", + "request": "launch", + "name": "Release TokamakDemo", + "program": "${workspaceFolder:Tokamak}/.build/release/TokamakDemo", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Release TokamakDemo" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug TokamakStaticHTMLDemo", + "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakStaticHTMLDemo", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Debug TokamakStaticHTMLDemo" + }, + { + "type": "lldb", + "request": "launch", + "name": "Release TokamakStaticHTMLDemo", + "program": "${workspaceFolder:Tokamak}/.build/release/TokamakStaticHTMLDemo", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Release TokamakStaticHTMLDemo" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug TokamakGTKDemo", + "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakGTKDemo", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Debug TokamakGTKDemo" + }, + { + "type": "lldb", + "request": "launch", + "name": "Release TokamakGTKDemo", + "program": "${workspaceFolder:Tokamak}/.build/release/TokamakGTKDemo", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Release TokamakGTKDemo" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug TokamakStaticHTMLBenchmark", + "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakStaticHTMLBenchmark", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Debug TokamakStaticHTMLBenchmark" + }, + { + "type": "lldb", + "request": "launch", + "name": "Release TokamakStaticHTMLBenchmark", + "program": "${workspaceFolder:Tokamak}/.build/release/TokamakStaticHTMLBenchmark", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Release TokamakStaticHTMLBenchmark" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug TokamakCoreBenchmark", + "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakCoreBenchmark", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Debug TokamakCoreBenchmark" + }, + { + "type": "lldb", + "request": "launch", + "name": "Release TokamakCoreBenchmark", + "program": "${workspaceFolder:Tokamak}/.build/release/TokamakCoreBenchmark", + "args": [], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build Release TokamakCoreBenchmark" + }, + { + "type": "lldb", + "request": "launch", + "name": "Test Tokamak", + "program": "/Applications/Xcode.app/Contents/Developer/usr/bin/xctest", + "args": [".build/debug/TokamakPackageTests.xctest"], + "cwd": "${workspaceFolder:Tokamak}", + "preLaunchTask": "swift: Build All" + } + ] +} diff --git a/Package.resolved b/Package.resolved index 1b85d83e5..6de7c28eb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/swiftwasm/JavaScriptKit.git", "state": { "branch": null, - "revision": "2011cc0422eb820c36d7cc275e0992ec5ca9ab34", - "version": "0.13.0" + "revision": "9a3b7d5f316e6d1709bd25e3e0392efca357f525", + "version": "0.14.0" } }, { diff --git a/Package.swift b/Package.swift index 673dd0299..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.13.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..ed0f1c44d 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,8 @@ 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 12 and Xcode 13.3 or later. +- [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 +181,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 +267,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/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) From 3f0037101791d10d459e54dd3060e67d9f24462f Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:26:26 +0100 Subject: [PATCH 07/25] Temporarily disable `macos-11` builds --- .github/workflows/ci.yml | 108 +++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f4c861c7..e957ed6f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,60 +24,60 @@ jobs: 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 + # 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 From 4b78644e77b0944162afacbd530228d2c109f901 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:31:05 +0100 Subject: [PATCH 08/25] Try to avoid 5.6 crash on Linux --- Sources/TokamakCore/ViewTraits/Transition/Transition.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 } } From b6175c11666a87a073963560601a5e6f5bac2790 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:34:07 +0100 Subject: [PATCH 09/25] Disable broken CI jobs --- .github/workflows/ci.yml | 48 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e957ed6f9..4e531c89d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,7 @@ jobs: with: shell-action: carton test + # Disabled until macos-12 is available on GitHub Actions, which is required for Xcode 13.3 # core_macos_build: # runs-on: macos-11 @@ -79,30 +80,31 @@ jobs: # make build - gtk_ubuntu_18_04_build: - runs-on: ubuntu-18.04 + # Disabled due to Swift 5.6 on Linux crashing on protocol constraints + # gtk_ubuntu_18_04_build: + # runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - name: Build the GTK renderer on Ubuntu 18.04 - shell: bash - run: | - set -ex - sudo apt-get update - sudo apt-get install libgtk+-3.0 gtk+-3.0 + # steps: + # - uses: actions/checkout@v2 + # - name: Build the GTK renderer on Ubuntu 18.04 + # shell: bash + # run: | + # set -ex + # sudo apt-get update + # sudo apt-get install libgtk+-3.0 gtk+-3.0 - make build + # make build - gtk_ubuntu_20_04_build: - runs-on: ubuntu-20.04 + # gtk_ubuntu_20_04_build: + # runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Build the GTK renderer on Ubuntu 20.04 - shell: bash - run: | - set -ex - sudo apt-get update - sudo apt-get install libgtk+-3.0 gtk+-3.0 - - make build + # steps: + # - uses: actions/checkout@v2 + # - name: Build the GTK renderer on Ubuntu 20.04 + # shell: bash + # run: | + # set -ex + # sudo apt-get update + # sudo apt-get install libgtk+-3.0 gtk+-3.0 + + # make build From 11ab7d59ad61ccdc0689cd2081c0cf5d4b2b8a3b Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:39:27 +0100 Subject: [PATCH 10/25] Try to use Swift 5.6 in `codecov.yml` --- .github/workflows/codecov.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 0c71d264e..66624eaa2 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -9,16 +9,16 @@ on: jobs: codecov: container: - image: swift:5.4-bionic + image: swift:5.6 runs-on: ubuntu-latest steps: - run: apt-get update && 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 id: cov @@ -32,4 +32,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 }}%)." - From ec0a9d73e96c18b7a5f5684184a1b63865a1b1cc Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:44:09 +0100 Subject: [PATCH 11/25] Disable `codecov.yml` job for now --- .github/workflows/codecov.yml | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 66624eaa2..07ce470d2 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -7,28 +7,29 @@ on: branches: [main] jobs: - codecov: - container: - image: swift:5.6 - runs-on: ubuntu-latest - steps: - - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 - - name: Checkout Branch - uses: actions/checkout@v2 - - name: Build Test Target - run: swift build -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests - - name: Run Tests - run: swift test --enable-code-coverage --skip-build - - name: Generate Branch Coverage Report - uses: mattpolzin/swift-codecov-action@0.6.1 - id: cov - with: - MINIMUM_COVERAGE: 20 - - name: Post Positive Results - if: ${{ success() }} - run: | - echo "::warning file=Package.swift,line=1,col=1::The current code coverage percentage is passing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)." - - name: Post Negative Results - 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 }}%)." + # Disable until crashes with Swift 5.6 are fixed. + # codecov: + # container: + # image: swift:5.6 + # runs-on: ubuntu-latest + # steps: + # - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 + # - name: Checkout Branch + # uses: actions/checkout@v2 + # - name: Build Test Target + # run: swift build -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests + # - name: Run Tests + # run: swift test --enable-code-coverage --skip-build + # - name: Generate Branch Coverage Report + # uses: mattpolzin/swift-codecov-action@0.6.1 + # id: cov + # with: + # MINIMUM_COVERAGE: 20 + # - name: Post Positive Results + # if: ${{ success() }} + # run: | + # echo "::warning file=Package.swift,line=1,col=1::The current code coverage percentage is passing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)." + # - name: Post Negative Results + # 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 }}%)." From 643ad2be0fd7cd3ba0dd155ebd4b3fba8cc2e4e2 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:45:16 +0100 Subject: [PATCH 12/25] Fully disable `codecov.yml` --- .github/workflows/codecov.yml | 65 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 07ce470d2..385b11bd5 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,35 +1,34 @@ +# Disable until crashes with Swift 5.6 are fixed. +# name: Codecov -name: Codecov +# on: +# pull_request: +# push: +# branches: [main] -on: - pull_request: - push: - branches: [main] - -jobs: - # Disable until crashes with Swift 5.6 are fixed. - # codecov: - # container: - # image: swift:5.6 - # runs-on: ubuntu-latest - # steps: - # - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 - # - name: Checkout Branch - # uses: actions/checkout@v2 - # - name: Build Test Target - # run: swift build -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests - # - name: Run Tests - # run: swift test --enable-code-coverage --skip-build - # - name: Generate Branch Coverage Report - # uses: mattpolzin/swift-codecov-action@0.6.1 - # id: cov - # with: - # MINIMUM_COVERAGE: 20 - # - name: Post Positive Results - # if: ${{ success() }} - # run: | - # echo "::warning file=Package.swift,line=1,col=1::The current code coverage percentage is passing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)." - # - name: Post Negative Results - # 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 }}%)." +# jobs: +# codecov: +# container: +# image: swift:5.6 +# runs-on: ubuntu-latest +# steps: +# - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 +# - name: Checkout Branch +# uses: actions/checkout@v2 +# - name: Build Test Target +# run: swift build -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests +# - name: Run Tests +# run: swift test --enable-code-coverage --skip-build +# - name: Generate Branch Coverage Report +# uses: mattpolzin/swift-codecov-action@0.6.1 +# id: cov +# with: +# MINIMUM_COVERAGE: 20 +# - name: Post Positive Results +# if: ${{ success() }} +# run: | +# echo "::warning file=Package.swift,line=1,col=1::The current code coverage percentage is passing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)." +# - name: Post Negative Results +# 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 }}%)." From 01d4ed168242ee09646a4d8fb4d5e7d48e984c8c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 10:49:16 +0100 Subject: [PATCH 13/25] Clean up `launch.json` --- .gitignore | 3 ++ .vscode/launch.json | 116 -------------------------------------------- 2 files changed, 3 insertions(+), 116 deletions(-) delete mode 100644 .vscode/launch.json 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/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index bead6bf4e..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,116 +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}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug TokamakDemo", - "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakDemo", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Debug TokamakDemo" - }, - { - "type": "lldb", - "request": "launch", - "name": "Release TokamakDemo", - "program": "${workspaceFolder:Tokamak}/.build/release/TokamakDemo", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Release TokamakDemo" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug TokamakStaticHTMLDemo", - "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakStaticHTMLDemo", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Debug TokamakStaticHTMLDemo" - }, - { - "type": "lldb", - "request": "launch", - "name": "Release TokamakStaticHTMLDemo", - "program": "${workspaceFolder:Tokamak}/.build/release/TokamakStaticHTMLDemo", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Release TokamakStaticHTMLDemo" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug TokamakGTKDemo", - "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakGTKDemo", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Debug TokamakGTKDemo" - }, - { - "type": "lldb", - "request": "launch", - "name": "Release TokamakGTKDemo", - "program": "${workspaceFolder:Tokamak}/.build/release/TokamakGTKDemo", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Release TokamakGTKDemo" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug TokamakStaticHTMLBenchmark", - "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakStaticHTMLBenchmark", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Debug TokamakStaticHTMLBenchmark" - }, - { - "type": "lldb", - "request": "launch", - "name": "Release TokamakStaticHTMLBenchmark", - "program": "${workspaceFolder:Tokamak}/.build/release/TokamakStaticHTMLBenchmark", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Release TokamakStaticHTMLBenchmark" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug TokamakCoreBenchmark", - "program": "${workspaceFolder:Tokamak}/.build/debug/TokamakCoreBenchmark", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Debug TokamakCoreBenchmark" - }, - { - "type": "lldb", - "request": "launch", - "name": "Release TokamakCoreBenchmark", - "program": "${workspaceFolder:Tokamak}/.build/release/TokamakCoreBenchmark", - "args": [], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build Release TokamakCoreBenchmark" - }, - { - "type": "lldb", - "request": "launch", - "name": "Test Tokamak", - "program": "/Applications/Xcode.app/Contents/Developer/usr/bin/xctest", - "args": [".build/debug/TokamakPackageTests.xctest"], - "cwd": "${workspaceFolder:Tokamak}", - "preLaunchTask": "swift: Build All" - } - ] -} From a2659203faeb281526a2215eafb1ebcd3e7163d7 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 11:02:33 +0100 Subject: [PATCH 14/25] Clarify requirements in `README.md` --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ed0f1c44d..67e359e16 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,9 @@ app. ### For app developers -- macOS 12 and Xcode 13.3 or later. +- 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. From 34148583e6c5784bd5e767976d5cfd749f241b76 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:03:07 +0100 Subject: [PATCH 15/25] Try nightly-5.6 image in `codecov.yml` --- .github/workflows/codecov.yml | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 385b11bd5..a544e63be 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,34 +1,34 @@ # Disable until crashes with Swift 5.6 are fixed. -# name: Codecov +name: Codecov -# on: -# pull_request: -# push: -# branches: [main] +on: + pull_request: + push: + branches: [main] -# jobs: -# codecov: -# container: -# image: swift:5.6 -# runs-on: ubuntu-latest -# steps: -# - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 -# - name: Checkout Branch -# uses: actions/checkout@v2 -# - name: Build Test Target -# run: swift build -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests -# - name: Run Tests -# run: swift test --enable-code-coverage --skip-build -# - name: Generate Branch Coverage Report -# uses: mattpolzin/swift-codecov-action@0.6.1 -# id: cov -# with: -# MINIMUM_COVERAGE: 20 -# - name: Post Positive Results -# if: ${{ success() }} -# run: | -# echo "::warning file=Package.swift,line=1,col=1::The current code coverage percentage is passing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)." -# - name: Post Negative Results -# 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 }}%)." +jobs: + codecov: + container: + image: swiftlang/swift:nightly-5.6 + runs-on: ubuntu-latest + steps: + - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 + - name: Checkout Branch + uses: actions/checkout@v2 + - name: Build Test Target + run: swift build -Xswiftc -profile-coverage-mapping -Xswiftc -profile-generate --product TokamakPackageTests + - name: Run Tests + run: swift test --enable-code-coverage --skip-build + - name: Generate Branch Coverage Report + uses: mattpolzin/swift-codecov-action@0.6.1 + id: cov + with: + MINIMUM_COVERAGE: 20 + - name: Post Positive Results + if: ${{ success() }} + run: | + echo "::warning file=Package.swift,line=1,col=1::The current code coverage percentage is passing with ${{ steps.cov.outputs.codecov }} (minimum allowed: ${{ steps.cov.outputs.minimum_coverage }}%)." + - name: Post Negative Results + 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 }}%)." From b4bf6b579831a8fc18aae3d777dafb3ff573e018 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:05:27 +0100 Subject: [PATCH 16/25] Try `nightly-5.6-focal` in `codecov.yml` --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index a544e63be..da814cdf7 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -9,7 +9,7 @@ on: jobs: codecov: container: - image: swiftlang/swift:nightly-5.6 + image: swiftlang/swift:nightly-5.6-focal runs-on: ubuntu-latest steps: - run: apt-get update && apt-get install -y gtk+-3.0 libgtk+-3.0 From 128c3dcba54484607f7bd22b9f59656bd7e74f7f Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:13:33 +0100 Subject: [PATCH 17/25] Add `DEBIAN_FRONTEND=noninteractive` in `codecov.yml` --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index da814cdf7..4660b8e8e 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -12,7 +12,7 @@ jobs: image: swiftlang/swift:nightly-5.6-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 From bbe98207c7cec85681e4b22db9c3a01988c63e58 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:19:14 +0100 Subject: [PATCH 18/25] Try `nightly-focal` image in `codecov.yml` --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 4660b8e8e..c60be352b 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -9,7 +9,7 @@ on: jobs: codecov: container: - image: swiftlang/swift:nightly-5.6-focal + image: swiftlang/swift:nightly-focal runs-on: ubuntu-latest steps: - run: apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y gtk+-3.0 libgtk+-3.0 From 002c41fe53f8a6b5b6a2067ebf3ecff0fbc41d13 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:31:28 +0100 Subject: [PATCH 19/25] Use nightly Swift for GTK Linux builds --- .github/workflows/ci.yml | 47 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e531c89d..717946960 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,31 +80,32 @@ jobs: # make build - # Disabled due to Swift 5.6 on Linux crashing on protocol constraints - # gtk_ubuntu_18_04_build: - # runs-on: ubuntu-18.04 + gtk_ubuntu_18_04_build: + runs-on: ubuntu-latest + container: + image: swiftlang/swift:nightly-bionic - # steps: - # - uses: actions/checkout@v2 - # - name: Build the GTK renderer on Ubuntu 18.04 - # shell: bash - # run: | - # set -ex - # sudo apt-get update - # sudo apt-get install libgtk+-3.0 gtk+-3.0 + steps: + - uses: actions/checkout@v2 + - name: Build the GTK renderer on Ubuntu 18.04 + shell: bash + run: | + set -ex + sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y libgtk+-3.0 gtk+-3.0 - # make build + make build - # gtk_ubuntu_20_04_build: - # runs-on: ubuntu-20.04 + gtk_ubuntu_20_04_build: + runs-on: ubuntu-latest + container: + image: swiftlang/swift:nightly-focal - # steps: - # - uses: actions/checkout@v2 - # - name: Build the GTK renderer on Ubuntu 20.04 - # shell: bash - # run: | - # set -ex - # sudo apt-get update - # sudo apt-get install libgtk+-3.0 gtk+-3.0 + steps: + - uses: actions/checkout@v2 + - name: Build the GTK renderer on Ubuntu 20.04 + shell: bash + run: | + set -ex + sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y libgtk+-3.0 gtk+-3.0 - # make build + make build From 812b44f75218b907d8ab06598c6e91417ccde0b9 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:34:32 +0100 Subject: [PATCH 20/25] Avoid using `sudo` when building in a Docker container --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 717946960..c17d04301 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: shell: bash run: | set -ex - sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y libgtk+-3.0 gtk+-3.0 + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libgtk+-3.0 gtk+-3.0 make build @@ -106,6 +106,6 @@ jobs: shell: bash run: | set -ex - sudo apt-get update && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y libgtk+-3.0 gtk+-3.0 + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y libgtk+-3.0 gtk+-3.0 make build From cc76eb814982f6957c1c581937f48018264d99e6 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:38:14 +0100 Subject: [PATCH 21/25] Add `build-essential` for Ubuntu Docker jobs --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c17d04301..cc088e0ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: shell: bash run: | set -ex - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y 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 @@ -106,6 +106,6 @@ jobs: shell: bash run: | set -ex - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y 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 From 0d3af14f1d9940845ddb05b95fff88aa51cdeefb Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 13:43:18 +0100 Subject: [PATCH 22/25] Use `swift-codecov-action@0.7.1` in `codecov.yml` --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index c60be352b..0703e32e0 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -20,7 +20,7 @@ jobs: - name: Run Tests 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 From e6a0eded6f8f3f2cf9872ca47b1a1bfbec2da0ef Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 14:00:38 +0100 Subject: [PATCH 23/25] Update codecov.yml --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 0703e32e0..3fe08ac68 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -23,7 +23,7 @@ jobs: uses: mattpolzin/swift-codecov-action@0.7.1 id: cov with: - MINIMUM_COVERAGE: 20 + MINIMUM_COVERAGE: 15 - name: Post Positive Results if: ${{ success() }} run: | From 42d1a21093eb85b6632a76322715da3ea35d932c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 15:51:47 +0100 Subject: [PATCH 24/25] Remove unused compiler version checks --- Sources/TokamakCore/Modifiers/TaskModifier.swift | 4 ---- Sources/TokamakDOM/DOMRenderer.swift | 7 +------ 2 files changed, 1 insertion(+), 10 deletions(-) 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/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 From 498b28613794a2f4f76bed0d319f96a0e00bae7b Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Fri, 8 Apr 2022 16:44:34 +0100 Subject: [PATCH 25/25] Update .github/workflows/codecov.yml --- .github/workflows/codecov.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 3fe08ac68..bfe844cd9 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,4 +1,3 @@ -# Disable until crashes with Swift 5.6 are fixed. name: Codecov on: