GeezerVison is showing github.com — Use availablility guarded APIs under available attr for Xcode develop… · swiftwasm/JavaScriptKit@170ff51
File treeExpand file treeCollapse file tree Open diff view settings Sources/JavaScriptEventLoop
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Sources/JavaScriptEventLoop/JavaScriptEventLoop.swift +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import JavaScriptKit | 2 | 2 | import _CJavaScriptEventLoop | 3 | 3 |
| | 4 | +// NOTE: `@available` annotations are semantically wrong, but they make it easier to develop applications targeting WebAssembly in Xcode. | | 5 | + | 4 | 6 | #if compiler(>=5.5) | 5 | 7 |
| | 8 | +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) | 6 | 9 | public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable { | 7 | 10 |
| 8 | 11 | /// A function that queues a given closure as a microtask into JavaScript event loop. | @@ -94,6 +97,7 @@ public final class JavaScriptEventLoop: SerialExecutor, @unchecked Sendable { | 94 | 97 | } | 95 | 98 | } | 96 | 99 |
| | 100 | +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) | 97 | 101 | public extension JSPromise { | 98 | 102 | /// Wait for the promise to complete, returning (or throwing) its result. | 99 | 103 | var value: JSValue { | |
Collapse file Copy file name to clipboardExpand all lines: Sources/JavaScriptEventLoop/JobQueue.swift +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 | import _CJavaScriptEventLoop | 6 | 6 |
| 7 | 7 | #if compiler(>=5.5) | | 8 | + | | 9 | +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) | 8 | 10 | struct QueueState: Sendable { | 9 | 11 | fileprivate var headJob: UnownedJob? = nil | 10 | 12 | fileprivate var isSpinning: Bool = false | 11 | 13 | } | 12 | 14 |
| | 15 | +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) | 13 | 16 | extension JavaScriptEventLoop { | 14 | 17 |
| 15 | 18 | func insertJobQueue(job newJob: UnownedJob) { | @@ -55,6 +58,7 @@ extension JavaScriptEventLoop { | 55 | 58 | } | 56 | 59 | } | 57 | 60 |
| | 61 | +@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) | 58 | 62 | fileprivate extension UnownedJob { | 59 | 63 | private func asImpl() -> UnsafeMutablePointer<_CJavaScriptEventLoop.Job> { | 60 | 64 | unsafeBitCast(self, to: UnsafeMutablePointer<_CJavaScriptEventLoop.Job>.self) | |
|