Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
target: "wasm32-unknown-wasi"
- os: ubuntu-22.04
toolchain:
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a-ubuntu22.04.tar.gz
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a-ubuntu22.04.tar.gz
wasi-backend: Node
target: "wasm32-unknown-wasi"
target: "wasm32-unknown-wasip1"
- os: ubuntu-22.04
toolchain:
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a-ubuntu22.04.tar.gz
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a-ubuntu22.04.tar.gz
wasi-backend: Node
target: "wasm32-unknown-wasip1-threads"

Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- uses: actions/checkout@v5
- uses: ./.github/actions/install-swift
with:
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a-ubuntu22.04.tar.gz
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a-ubuntu22.04.tar.gz
- run: make bootstrap
- run: ./Utilities/bridge-js-generate.sh
- name: Check if BridgeJS generated files are up-to-date
Expand All @@ -112,17 +112,17 @@ jobs:
- uses: actions/checkout@v5
- uses: ./.github/actions/install-swift
with:
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a/swift-DEVELOPMENT-SNAPSHOT-2025-06-12-a-ubuntu22.04.tar.gz
download-url: https://download.swift.org/development/ubuntu2204/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a/swift-DEVELOPMENT-SNAPSHOT-2025-08-27-a-ubuntu22.04.tar.gz
- uses: swiftwasm/setup-swiftwasm@v2
id: setup-wasm32-unknown-wasi
with: { target: wasm32-unknown-wasi }
id: setup-wasm32-unknown-wasip1
with: { target: wasm32-unknown-wasip1 }
- uses: swiftwasm/setup-swiftwasm@v2
id: setup-wasm32-unknown-wasip1-threads
with: { target: wasm32-unknown-wasip1-threads }
- run: ./Utilities/build-examples.sh
env:
SWIFT_SDK_ID_wasm32_unknown_wasip1_threads: ${{ steps.setup-wasm32-unknown-wasip1-threads.outputs.swift-sdk-id }}
SWIFT_SDK_ID_wasm32_unknown_wasi: ${{ steps.setup-wasm32-unknown-wasi.outputs.swift-sdk-id }}
SWIFT_SDK_ID_wasm32_unknown_wasip1: ${{ steps.setup-wasm32-unknown-wasip1.outputs.swift-sdk-id }}
- name: Upload static files as artifact
id: deployment
uses: actions/upload-pages-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion Examples/Basic/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
set -euxo pipefail
swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasi:-${SWIFT_SDK_ID:-wasm32-unknown-wasi}}" -c "${1:-debug}" js --use-cdn
swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1}}" -c "${1:-debug}" js --use-cdn
2 changes: 1 addition & 1 deletion Examples/PlayBridgeJS/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -euxo pipefail
env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasi:-${SWIFT_SDK_ID:-wasm32-unknown-wasi}}" -c "${1:-debug}" \
env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package --swift-sdk "${SWIFT_SDK_ID_wasm32_unknown_wasip1:-${SWIFT_SDK_ID:-wasm32-unknown-wasip1}}" -c "${1:-debug}" \
plugin --allow-writing-to-package-directory \
js --use-cdn --output ./Bundle
9 changes: 9 additions & 0 deletions Plugins/PackageToJS/Tests/ExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ extension Trait where Self == ConditionTrait {
else {
return false
}
guard
["wasm32-unknown-wasi", "wasm32-unknown-wasip1"].contains(where: {
swiftSDKID.hasSuffix($0)
})
else {
// Only non-threads SDKs are supported for embedded in Swift SDK
return false
}
let embeddedSDKID = "\(swiftSDKID)-embedded"
return isSwiftSDKAvailable(embeddedSDKID, swiftPath: swiftPath)
}(),
Expand Down Expand Up @@ -206,6 +214,7 @@ extension Trait where Self == ConditionTrait {
Swift package should build successfully, check \(destination.appending(path: path).path) for details
stdout: \(stdoutPath.path)
stderr: \(stderrPath.path)
arguments: \(args)

\((try? String(contentsOf: stdoutPath, encoding: .utf8)) ?? "<<stdout is empty>>")
\((try? String(contentsOf: stderrPath, encoding: .utf8)) ?? "<<stderr is empty>>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,37 @@ extension JavaScriptEventLoop: MainExecutor {
extension JavaScriptEventLoop: TaskExecutor {}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *)
extension JavaScriptEventLoop: SchedulableExecutor {
extension JavaScriptEventLoop: SchedulingExecutor {
public func enqueue<C: Clock>(
_ job: consuming ExecutorJob,
after delay: C.Duration,
tolerance: C.Duration?,
clock: C
) {
let milliseconds = Self.delayInMilliseconds(from: delay, clock: clock)
let duration: Duration
// Handle clocks we know
if let _ = clock as? ContinuousClock {
duration = delay as! ContinuousClock.Duration
} else if let _ = clock as? SuspendingClock {
duration = delay as! SuspendingClock.Duration
} else {
// Hand-off the scheduling work to Clock implementation for unknown clocks
clock.enqueue(
job,
on: self,
at: clock.now.advanced(by: delay),
tolerance: tolerance
)
return
}
let milliseconds = Self.delayInMilliseconds(from: duration)
self.enqueue(
UnownedJob(job),
withDelay: milliseconds
)
}

private static func delayInMilliseconds<C: Clock>(from duration: C.Duration, clock: C) -> Double {
let swiftDuration = clock.convert(from: duration)!
private static func delayInMilliseconds(from swiftDuration: Duration) -> Double {
let (seconds, attoseconds) = swiftDuration.components
return Double(seconds) * 1_000 + (Double(attoseconds) / 1_000_000_000_000_000)
}
Expand All @@ -52,7 +67,7 @@ extension JavaScriptEventLoop: SchedulableExecutor {
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999, *)
extension JavaScriptEventLoop: ExecutorFactory {
// Forward all operations to the current thread's JavaScriptEventLoop instance
final class CurrentThread: TaskExecutor, SchedulableExecutor, MainExecutor, SerialExecutor {
final class CurrentThread: TaskExecutor, SchedulingExecutor, MainExecutor, SerialExecutor {
func checkIsolated() {}

func enqueue(_ job: consuming ExecutorJob) {
Expand Down