-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for JSKit 0.11.1, add async task
modifier
#457
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
67ca99b
Update for JSKit 0.11.0, add async `task` modifier
MaxDesiatov d0bff4b
Add back new file locations to `NativeDemo`
MaxDesiatov 8932bd0
Add compiler `#if` check to `TaskDemo`
MaxDesiatov b65300f
Update to JavaScriptKit 0.11.1
MaxDesiatov 2ee9fc5
Restrict `TaskDemo` with `compiler(>=5.5)` check
MaxDesiatov 534784c
Replace `compiler` with `swift` in some places
MaxDesiatov 7382291
Revert "Replace `compiler` with `swift` in some places"
MaxDesiatov 63d044f
Use Xcode 13.2 on GitHub Actions hosts
MaxDesiatov 68c845b
Find `TokamakPackageTests` in the build directory
MaxDesiatov 3ccbc98
Fix macOS tests bundle path
MaxDesiatov bac82ce
Make `task` modifier available only on macOS Monterey
MaxDesiatov 4d25ff4
Revert "Use Xcode 13.2 on GitHub Actions hosts"
MaxDesiatov 2fa2e3e
Revert "Fix macOS tests bundle path"
MaxDesiatov 55001d2
Revert "Find `TokamakPackageTests` in the build directory"
MaxDesiatov 05728f5
Use `canImport(Concurrency)` as an ultimate check
MaxDesiatov 226fce6
Use `compiler(>=5.5) && canImport(Concurrency)`
MaxDesiatov a9bbf19
Clarify new browser version requirements in `README.md`
MaxDesiatov d23a296
Account for `_Concurrency` naming
MaxDesiatov 14ace42
Update `README.md`
MaxDesiatov cf0ad83
Update README.md
MaxDesiatov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2021 Tokamak contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// 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, | ||
_ action: @escaping @Sendable () async -> () | ||
) -> some View { | ||
var task: Task<(), Never>? | ||
return onAppear { | ||
task = Task(priority: priority, operation: action) | ||
} | ||
.onDisappear { | ||
task?.cancel() | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2021 Tokamak contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import TokamakShim | ||
|
||
struct ShadowDemo: View { | ||
var body: some View { | ||
Color.red.frame(width: 60, height: 60, alignment: .center) | ||
.shadow(color: .black, radius: 5, x: 0, y: 10) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright 2021 Tokamak contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#if os(WASI) && compiler(>=5.5) && (canImport(Concurrency) || canImport(_Concurrency)) | ||
import JavaScriptKit | ||
import TokamakDOM | ||
|
||
private let jsFetch = JSObject.global.fetch.function! | ||
private func fetch(_ url: String) -> JSPromise { | ||
JSPromise(jsFetch(url).object!)! | ||
} | ||
|
||
private struct Response: Decodable { | ||
let uuid: String | ||
} | ||
|
||
struct TaskDemo: View { | ||
@State private var response: Result<Response, Error>? | ||
|
||
var body: some View { | ||
VStack { | ||
switch response { | ||
case let .success(response): | ||
Text("Fetched UUID is \(response.uuid)") | ||
case let .failure(error): | ||
Text("Error is \(error)") | ||
default: | ||
Text("Response not available yet") | ||
} | ||
|
||
Button("Fetch new UUID asynchronously") { | ||
response = nil | ||
Task { await fetchResponse() } | ||
} | ||
}.task { | ||
await fetchResponse() | ||
} | ||
} | ||
|
||
func fetchResponse() async { | ||
do { | ||
let fetchResult = try await fetch("https://httpbin.org/uuid").value | ||
let json = try await JSPromise(fetchResult.json().object!)!.value | ||
response = Result { try JSValueDecoder().decode(Response.self, from: json) } | ||
} catch { | ||
response = .failure(error) | ||
} | ||
} | ||
} | ||
#endif |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was moved from existing
ShadowDemo.swift
, but for some reason git didn't pick it up.