@swiftbrowser/swift 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Package.swift +214 -0
- package/README.md +10 -2
- package/Sources/AVFoundation/AVFoundation.swift +131 -0
- package/Sources/AVFoundation/Asset.swift +487 -0
- package/Sources/AVFoundation/AudioSession.swift +144 -0
- package/Sources/AVFoundation/CMTime.swift +303 -0
- package/Sources/AVFoundation/Capture.swift +688 -0
- package/Sources/AVFoundation/Player.swift +749 -0
- package/Sources/AVFoundation/PlayerView.swift +117 -0
- package/Sources/AVKit/AVKit.swift +132 -0
- package/Sources/Accelerate/Accelerate.swift +122 -0
- package/Sources/AppIntents/AppIntents.swift +144 -0
- package/Sources/AppIntents/Parameters.swift +220 -0
- package/Sources/AppIntents/Shortcuts.swift +159 -0
- package/Sources/AudioToolbox/AudioToolbox.swift +55 -0
- package/Sources/AuthenticationServices/AuthenticationServices.swift +257 -0
- package/Sources/AuthenticationServices/Authorization.swift +251 -0
- package/Sources/Charts/Charts.swift +61 -0
- package/Sources/Combine/AnyCancellable.swift +65 -0
- package/Sources/Combine/AnyPublisher.swift +148 -0
- package/Sources/Combine/AnySubscriber.swift +230 -0
- package/Sources/Combine/Cancellable.swift +35 -0
- package/Sources/Combine/Codable.swift +29 -0
- package/Sources/Combine/CombineIdentifier.swift +45 -0
- package/Sources/Combine/Concurrency/ConcurrencyHelpers.swift +24 -0
- package/Sources/Combine/Concurrency/Future+Concurrency.swift +136 -0
- package/Sources/Combine/Concurrency/GENERATED-Publisher+Concurrency.swift +397 -0
- package/Sources/Combine/CurrentValueSubject.swift +252 -0
- package/Sources/Combine/CustomCombineIdentifierConvertible.swift +28 -0
- package/Sources/Combine/Future.swift +228 -0
- package/Sources/Combine/GENERATED-RootProtocols.swift +426 -0
- package/Sources/Combine/Helpers/ConduitBase.swift +40 -0
- package/Sources/Combine/Helpers/ConduitList.swift +59 -0
- package/Sources/Combine/Helpers/DebugHook.swift +177 -0
- package/Sources/Combine/Helpers/FilterProducer.swift +174 -0
- package/Sources/Combine/Helpers/Locking.swift +30 -0
- package/Sources/Combine/Helpers/PartialCompletion.swift +26 -0
- package/Sources/Combine/Helpers/ReduceProducer.swift +249 -0
- package/Sources/Combine/Helpers/SubjectSubscriber.swift +96 -0
- package/Sources/Combine/Helpers/SubscriberTap.swift +69 -0
- package/Sources/Combine/Helpers/SubscriptionStatus.swift +33 -0
- package/Sources/Combine/Helpers/SubscriptionTap.swift +33 -0
- package/Sources/Combine/Helpers/Utils.swift +30 -0
- package/Sources/Combine/Helpers/Violations.swift +33 -0
- package/Sources/Combine/ImmediateScheduler.swift +178 -0
- package/Sources/Combine/LICENSE +21 -0
- package/Sources/Combine/NotificationPublisher.swift +48 -0
- package/Sources/Combine/ObjectWillChange.swift +46 -0
- package/Sources/Combine/PassthroughSubject.swift +222 -0
- package/Sources/Combine/Publisher+Subscribe.swift +53 -0
- package/Sources/Combine/Publishers/Deferred.swift +48 -0
- package/Sources/Combine/Publishers/Empty.swift +54 -0
- package/Sources/Combine/Publishers/Fail.swift +42 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.Catch.swift +673 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.Encode.swift +388 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.MapKeyPath.swift +384 -0
- package/Sources/Combine/Publishers/Just.swift +313 -0
- package/Sources/Combine/Publishers/Optional.Publisher.swift +315 -0
- package/Sources/Combine/Publishers/Publishers.AllSatisfy.swift +217 -0
- package/Sources/Combine/Publishers/Publishers.AssertNoFailure.swift +158 -0
- package/Sources/Combine/Publishers/Publishers.Autoconnect.swift +193 -0
- package/Sources/Combine/Publishers/Publishers.Breakpoint.swift +231 -0
- package/Sources/Combine/Publishers/Publishers.Buffer.swift +356 -0
- package/Sources/Combine/Publishers/Publishers.Collect.swift +102 -0
- package/Sources/Combine/Publishers/Publishers.CollectByCount.swift +195 -0
- package/Sources/Combine/Publishers/Publishers.CompactMap.swift +241 -0
- package/Sources/Combine/Publishers/Publishers.Comparison.swift +371 -0
- package/Sources/Combine/Publishers/Publishers.Concatenate.swift +474 -0
- package/Sources/Combine/Publishers/Publishers.Contains.swift +293 -0
- package/Sources/Combine/Publishers/Publishers.Count.swift +87 -0
- package/Sources/Combine/Publishers/Publishers.Debounce.swift +332 -0
- package/Sources/Combine/Publishers/Publishers.Delay.swift +269 -0
- package/Sources/Combine/Publishers/Publishers.Drop.swift +155 -0
- package/Sources/Combine/Publishers/Publishers.DropUntilOutput.swift +283 -0
- package/Sources/Combine/Publishers/Publishers.DropWhile.swift +378 -0
- package/Sources/Combine/Publishers/Publishers.Filter.swift +248 -0
- package/Sources/Combine/Publishers/Publishers.First.swift +261 -0
- package/Sources/Combine/Publishers/Publishers.FlatMap.swift +533 -0
- package/Sources/Combine/Publishers/Publishers.HandleEvents.swift +260 -0
- package/Sources/Combine/Publishers/Publishers.IgnoreOutput.swift +109 -0
- package/Sources/Combine/Publishers/Publishers.Last.swift +252 -0
- package/Sources/Combine/Publishers/Publishers.MakeConnectable.swift +82 -0
- package/Sources/Combine/Publishers/Publishers.Map.swift +351 -0
- package/Sources/Combine/Publishers/Publishers.MapError.swift +140 -0
- package/Sources/Combine/Publishers/Publishers.MeasureInterval.swift +187 -0
- package/Sources/Combine/Publishers/Publishers.Multicast.swift +284 -0
- package/Sources/Combine/Publishers/Publishers.Output.swift +241 -0
- package/Sources/Combine/Publishers/Publishers.PrefixUntilOutput.swift +197 -0
- package/Sources/Combine/Publishers/Publishers.PrefixWhile.swift +176 -0
- package/Sources/Combine/Publishers/Publishers.Print.swift +206 -0
- package/Sources/Combine/Publishers/Publishers.ReceiveOn.swift +227 -0
- package/Sources/Combine/Publishers/Publishers.Reduce.swift +204 -0
- package/Sources/Combine/Publishers/Publishers.RemoveDuplicates.swift +264 -0
- package/Sources/Combine/Publishers/Publishers.ReplaceEmpty.swift +201 -0
- package/Sources/Combine/Publishers/Publishers.ReplaceError.swift +211 -0
- package/Sources/Combine/Publishers/Publishers.Retry.swift +274 -0
- package/Sources/Combine/Publishers/Publishers.Scan.swift +331 -0
- package/Sources/Combine/Publishers/Publishers.Sequence.swift +437 -0
- package/Sources/Combine/Publishers/Publishers.SetFailureType.swift +120 -0
- package/Sources/Combine/Publishers/Publishers.Share.swift +104 -0
- package/Sources/Combine/Publishers/Publishers.SubscribeOn.swift +197 -0
- package/Sources/Combine/Publishers/Publishers.SwitchToLatest.swift +444 -0
- package/Sources/Combine/Publishers/Publishers.Throttle.swift +359 -0
- package/Sources/Combine/Publishers/Publishers.Timeout.swift +301 -0
- package/Sources/Combine/Publishers/Publishers.Zip.swift +720 -0
- package/Sources/Combine/Publishers/Publishers.swift +13 -0
- package/Sources/Combine/Publishers/Record.swift +237 -0
- package/Sources/Combine/Publishers/Result.Publisher.swift +337 -0
- package/Sources/Combine/Result.swift +46 -0
- package/Sources/Combine/Scheduler.swift +89 -0
- package/Sources/Combine/Schedulers.swift +211 -0
- package/Sources/Combine/Subject+Void.swift +17 -0
- package/Sources/Combine/Subscriber+Void.swift +20 -0
- package/Sources/Combine/Subscribers/Subscribers.Assign.swift +175 -0
- package/Sources/Combine/Subscribers/Subscribers.Completion.swift +90 -0
- package/Sources/Combine/Subscribers/Subscribers.Demand.swift +476 -0
- package/Sources/Combine/Subscribers/Subscribers.Sink.swift +206 -0
- package/Sources/Combine/Subscribers/Subscribers.swift +9 -0
- package/Sources/Combine/Subscription.swift +22 -0
- package/Sources/Combine/Subscriptions.swift +42 -0
- package/Sources/Combine/SwiftUIObservation.swift +10 -0
- package/Sources/Combine/_Introspection.swift +107 -0
- package/Sources/CommonCrypto/CommonCrypto.swift +80 -0
- package/Sources/Compression/Compression.swift +365 -0
- package/Sources/Compression/Deflate.swift +407 -0
- package/Sources/Compression/Zlib.swift +179 -0
- package/Sources/CoreFoundationTypes/CoreFoundationTypes.swift +101 -0
- package/Sources/CoreGraphics/CoreGraphics.swift +411 -0
- package/Sources/CoreGraphics/ProjectionTransforms.swift +28 -0
- package/Sources/CoreHaptics/CoreHaptics.swift +399 -0
- package/Sources/CoreImage/CIColor.swift +41 -0
- package/Sources/CoreImage/CIContext.swift +31 -0
- package/Sources/CoreImage/CIDetector.swift +57 -0
- package/Sources/CoreImage/CIFilter.swift +243 -0
- package/Sources/CoreImage/CIFilterBuiltins.swift +136 -0
- package/Sources/CoreImage/CIImage.swift +162 -0
- package/Sources/CoreImage/QRCode.swift +393 -0
- package/Sources/CoreLocation/Coordinate.swift +30 -0
- package/Sources/CoreLocation/Location.swift +65 -0
- package/Sources/CoreML/Evaluation.swift +414 -0
- package/Sources/CoreML/FeatureValue.swift +266 -0
- package/Sources/CoreML/Model.swift +269 -0
- package/Sources/CoreML/MultiArray.swift +92 -0
- package/Sources/CoreML/Specification.swift +233 -0
- package/Sources/CoreText/CoreText.swift +64 -0
- package/Sources/CoreTransferable/CoreTransferable.swift +606 -0
- package/Sources/CryptoKit/ChaChaPoly.swift +258 -0
- package/Sources/CryptoKit/CryptoKit.swift +375 -0
- package/Sources/CryptoKit/Curve25519.swift +317 -0
- package/Sources/CryptoKit/P256.swift +321 -0
- package/Sources/FoundationBridge/AppStorage.swift +165 -0
- package/Sources/FoundationBridge/AssetResources.swift +90 -0
- package/Sources/FoundationBridge/AsyncBytes.swift +128 -0
- package/Sources/FoundationBridge/AsyncImage.swift +116 -0
- package/Sources/FoundationBridge/AttributedStrings.swift +16 -0
- package/Sources/FoundationBridge/Bundle.swift +119 -0
- package/Sources/FoundationBridge/CombineExports.swift +8 -0
- package/Sources/FoundationBridge/CoreFoundation.swift +77 -0
- package/Sources/FoundationBridge/Dispatch.swift +458 -0
- package/Sources/FoundationBridge/EnvironmentFoundation.swift +41 -0
- package/Sources/FoundationBridge/FileImporter.swift +128 -0
- package/Sources/FoundationBridge/FileSystem.swift +68 -0
- package/Sources/FoundationBridge/FoundationBridge.swift +29 -0
- package/Sources/FoundationBridge/HostResolution.swift +31 -0
- package/Sources/FoundationBridge/ItemProvider.swift +655 -0
- package/Sources/FoundationBridge/KeyValueObserving.swift +138 -0
- package/Sources/FoundationBridge/Links.swift +127 -0
- package/Sources/FoundationBridge/ListFormatter.swift +32 -0
- package/Sources/FoundationBridge/Locale.swift +86 -0
- package/Sources/FoundationBridge/Localization.swift +149 -0
- package/Sources/FoundationBridge/Locks.swift +50 -0
- package/Sources/FoundationBridge/Markdown.swift +527 -0
- package/Sources/FoundationBridge/MeasurementFormat.swift +95 -0
- package/Sources/FoundationBridge/NotificationCenter.swift +154 -0
- package/Sources/FoundationBridge/OpenURLHandlers.swift +60 -0
- package/Sources/FoundationBridge/Operation.swift +195 -0
- package/Sources/FoundationBridge/ProcessInfo.swift +32 -0
- package/Sources/FoundationBridge/RelativeDateTimeFormatter.swift +136 -0
- package/Sources/FoundationBridge/SceneStorage.swift +78 -0
- package/Sources/FoundationBridge/SecurityExports.swift +8 -0
- package/Sources/FoundationBridge/Selector.swift +226 -0
- package/Sources/FoundationBridge/StringComparators.swift +17 -0
- package/Sources/FoundationBridge/Table.swift +211 -0
- package/Sources/FoundationBridge/TextAttributes.swift +42 -0
- package/Sources/FoundationBridge/Timer.swift +53 -0
- package/Sources/FoundationBridge/UITextChecker.swift +30 -0
- package/Sources/FoundationBridge/URLSession.swift +718 -0
- package/Sources/FoundationBridge/UserDefaults.swift +183 -0
- package/Sources/FoundationBridge/WebAuthRedirects.swift +227 -0
- package/Sources/FoundationBridge/WebSocket.swift +187 -0
- package/Sources/FoundationModels/FoundationModels.swift +1098 -0
- package/Sources/ImageIO/GIF.swift +72 -0
- package/Sources/ImageIO/ImageIO.swift +248 -0
- package/Sources/ImageIO/ImageTypes.swift +28 -0
- package/Sources/LinkPresentation/LinkPresentation.swift +249 -0
- package/Sources/LocalAuthentication/LAContext.swift +86 -0
- package/Sources/MapKit/Geometry.swift +223 -0
- package/Sources/MapKit/Map.swift +638 -0
- package/Sources/MapKit/MapView.swift +229 -0
- package/Sources/MobileCoreServices/MobileCoreServices.swift +28 -0
- package/Sources/NaturalLanguage/LanguageIdentifier.swift +317 -0
- package/Sources/NaturalLanguage/NaturalLanguage.swift +135 -0
- package/Sources/OSLog/OSLog.swift +6 -0
- package/Sources/Photos/Photos.swift +572 -0
- package/Sources/PhotosUI/PhotosPicker.swift +248 -0
- package/Sources/PhotosUI/PhotosPickerItem.swift +261 -0
- package/Sources/QuickLook/QuickLook.swift +168 -0
- package/Sources/SafariServices/SafariServices.swift +106 -0
- package/Sources/Security/Security.swift +332 -0
- package/Sources/StoreKit/AppStore.swift +207 -0
- package/Sources/StoreKit/Products.swift +280 -0
- package/Sources/StoreKit/RequestReview.swift +28 -0
- package/Sources/StoreKit/StoreKit1.swift +486 -0
- package/Sources/StoreKit/StoreViews.swift +428 -0
- package/Sources/StoreKit/Transactions.swift +197 -0
- package/Sources/SwiftData/Macros.swift +58 -0
- package/Sources/SwiftData/ModelActor.swift +38 -0
- package/Sources/SwiftData/ModelContainer.swift +129 -0
- package/Sources/SwiftData/ModelContext.swift +451 -0
- package/Sources/SwiftData/PersistentModel.swift +238 -0
- package/Sources/SwiftData/Properties.swift +261 -0
- package/Sources/SwiftData/Query.swift +256 -0
- package/Sources/SwiftData/Schema.swift +192 -0
- package/Sources/SwiftData/Store.swift +146 -0
- package/Sources/SwiftData/StringPredicates.swift +125 -0
- package/Sources/SwiftDataMacros/EntryMacro.swift +82 -0
- package/Sources/SwiftDataMacros/GenerableMacro.swift +183 -0
- package/Sources/SwiftDataMacros/ModelActorMacro.swift +46 -0
- package/Sources/SwiftDataMacros/ModelMacro.swift +260 -0
- package/Sources/SwiftDataMacros/Plugin.swift +18 -0
- package/Sources/SwiftDataMacros/PredicateMacro.swift +1244 -0
- package/Sources/SwiftUI/API/Accessibility.swift +181 -0
- package/Sources/SwiftUI/API/AccessibilityExtras.swift +33 -0
- package/Sources/SwiftUI/API/AccessibilityFocus.swift +63 -0
- package/Sources/SwiftUI/API/Alert.swift +221 -0
- package/Sources/SwiftUI/API/AlignmentGuides.swift +65 -0
- package/Sources/SwiftUI/API/Animation.swift +285 -0
- package/Sources/SwiftUI/API/App.swift +87 -0
- package/Sources/SwiftUI/API/BindingCollections.swift +35 -0
- package/Sources/SwiftUI/API/BindingForEach.swift +27 -0
- package/Sources/SwiftUI/API/Bitmaps.swift +254 -0
- package/Sources/SwiftUI/API/ButtonStyles.swift +96 -0
- package/Sources/SwiftUI/API/Canvas.swift +337 -0
- package/Sources/SwiftUI/API/Color.swift +237 -0
- package/Sources/SwiftUI/API/ColorEffects.swift +52 -0
- package/Sources/SwiftUI/API/ColorPickerAndLabeledContent.swift +138 -0
- package/Sources/SwiftUI/API/ColorSpaces.swift +161 -0
- package/Sources/SwiftUI/API/Commands.swift +106 -0
- package/Sources/SwiftUI/API/ContainerBackground.swift +28 -0
- package/Sources/SwiftUI/API/ContentShape.swift +33 -0
- package/Sources/SwiftUI/API/ContentSizeCategory.swift +35 -0
- package/Sources/SwiftUI/API/ContentUnavailable.swift +101 -0
- package/Sources/SwiftUI/API/Controls.swift +300 -0
- package/Sources/SwiftUI/API/CustomLayout.swift +442 -0
- package/Sources/SwiftUI/API/CustomToolbarContent.swift +46 -0
- package/Sources/SwiftUI/API/Decorations.swift +92 -0
- package/Sources/SwiftUI/API/EditMode.swift +212 -0
- package/Sources/SwiftUI/API/Effects.swift +388 -0
- package/Sources/SwiftUI/API/Entry.swift +8 -0
- package/Sources/SwiftUI/API/Environment.swift +439 -0
- package/Sources/SwiftUI/API/EnvironmentSendable.swift +6 -0
- package/Sources/SwiftUI/API/Focus.swift +137 -0
- package/Sources/SwiftUI/API/Font.swift +131 -0
- package/Sources/SwiftUI/API/Gauge.swift +290 -0
- package/Sources/SwiftUI/API/Geometry.swift +89 -0
- package/Sources/SwiftUI/API/GeometryEffects.swift +232 -0
- package/Sources/SwiftUI/API/GeometryReader.swift +135 -0
- package/Sources/SwiftUI/API/GestureState.swift +65 -0
- package/Sources/SwiftUI/API/Gestures.swift +342 -0
- package/Sources/SwiftUI/API/Glass.swift +127 -0
- package/Sources/SwiftUI/API/Grid.swift +188 -0
- package/Sources/SwiftUI/API/GroupBoxAndControlGroup.swift +130 -0
- package/Sources/SwiftUI/API/KeyPress.swift +54 -0
- package/Sources/SwiftUI/API/LabelStyle.swift +124 -0
- package/Sources/SwiftUI/API/Layout.swift +220 -0
- package/Sources/SwiftUI/API/LazyStacks.swift +49 -0
- package/Sources/SwiftUI/API/LegacyAlert.swift +97 -0
- package/Sources/SwiftUI/API/Lists.swift +331 -0
- package/Sources/SwiftUI/API/Menu.swift +58 -0
- package/Sources/SwiftUI/API/Modifiers.swift +313 -0
- package/Sources/SwiftUI/API/MoreModifiers.swift +100 -0
- package/Sources/SwiftUI/API/Namespace.swift +44 -0
- package/Sources/SwiftUI/API/Navigation.swift +386 -0
- package/Sources/SwiftUI/API/NavigationDestinationBindings.swift +55 -0
- package/Sources/SwiftUI/API/ObservableObject.swift +293 -0
- package/Sources/SwiftUI/API/OnChange.swift +48 -0
- package/Sources/SwiftUI/API/Path.swift +543 -0
- package/Sources/SwiftUI/API/Phase8Controls.swift +411 -0
- package/Sources/SwiftUI/API/PhaseAnimator.swift +130 -0
- package/Sources/SwiftUI/API/Picker.swift +185 -0
- package/Sources/SwiftUI/API/PointerAndKeyboard.swift +77 -0
- package/Sources/SwiftUI/API/Popover.swift +41 -0
- package/Sources/SwiftUI/API/Preferences.swift +262 -0
- package/Sources/SwiftUI/API/Presentation.swift +122 -0
- package/Sources/SwiftUI/API/PresentationExtras.swift +60 -0
- package/Sources/SwiftUI/API/Primitives.swift +517 -0
- package/Sources/SwiftUI/API/Publishers.swift +107 -0
- package/Sources/SwiftUI/API/Redaction.swift +75 -0
- package/Sources/SwiftUI/API/RowActions.swift +84 -0
- package/Sources/SwiftUI/API/Scenes.swift +131 -0
- package/Sources/SwiftUI/API/ScrollModifiers.swift +132 -0
- package/Sources/SwiftUI/API/ScrollTargets.swift +104 -0
- package/Sources/SwiftUI/API/ScrollViewReader.swift +144 -0
- package/Sources/SwiftUI/API/SectionSupplements.swift +96 -0
- package/Sources/SwiftUI/API/Shape.swift +214 -0
- package/Sources/SwiftUI/API/ShapeStyle.swift +409 -0
- package/Sources/SwiftUI/API/ShapeTrim.swift +78 -0
- package/Sources/SwiftUI/API/Sharing.swift +193 -0
- package/Sources/SwiftUI/API/StackLayouts.swift +199 -0
- package/Sources/SwiftUI/API/State.swift +144 -0
- package/Sources/SwiftUI/API/StatusGaps.swift +121 -0
- package/Sources/SwiftUI/API/StrokeStyle.swift +30 -0
- package/Sources/SwiftUI/API/SymbolEffects.swift +203 -0
- package/Sources/SwiftUI/API/TabContent.swift +841 -0
- package/Sources/SwiftUI/API/Table.swift +382 -0
- package/Sources/SwiftUI/API/Tabs.swift +263 -0
- package/Sources/SwiftUI/API/Tasks.swift +35 -0
- package/Sources/SwiftUI/API/Text.swift +386 -0
- package/Sources/SwiftUI/API/TextDates.swift +61 -0
- package/Sources/SwiftUI/API/TextDecorations.swift +52 -0
- package/Sources/SwiftUI/API/TextFieldAxis.swift +103 -0
- package/Sources/SwiftUI/API/TextFieldCommit.swift +52 -0
- package/Sources/SwiftUI/API/Timeline.swift +212 -0
- package/Sources/SwiftUI/API/Toolbar.swift +251 -0
- package/Sources/SwiftUI/API/Transfer.swift +145 -0
- package/Sources/SwiftUI/API/UnevenRoundedRectangle.swift +66 -0
- package/Sources/SwiftUI/API/Video.swift +64 -0
- package/Sources/SwiftUI/API/View.swift +215 -0
- package/Sources/SwiftUI/API/ViewModifier.swift +43 -0
- package/Sources/SwiftUI/API/VisualEffect.swift +155 -0
- package/Sources/SwiftUI/API/Windows.swift +25 -0
- package/Sources/SwiftUI/Charts/Axis.swift +325 -0
- package/Sources/SwiftUI/Charts/AxisFormatsAndRanges.swift +68 -0
- package/Sources/SwiftUI/Charts/Chart.swift +660 -0
- package/Sources/SwiftUI/Charts/ChartContent.swift +376 -0
- package/Sources/SwiftUI/Charts/ChartProxy.swift +57 -0
- package/Sources/SwiftUI/Charts/Marks.swift +204 -0
- package/Sources/SwiftUI/Charts/Plottable.swift +99 -0
- package/Sources/SwiftUI/Charts/Scales.swift +326 -0
- package/Sources/SwiftUI/Localization/Localization.swift +498 -0
- package/Sources/SwiftUI/Localization/PluralRules.swift +127 -0
- package/Sources/SwiftUI/Runtime/Executor.swift +85 -0
- package/Sources/SwiftUI/Runtime/Exports.swift +101 -0
- package/Sources/SwiftUI/Runtime/ImageSource.swift +310 -0
- package/Sources/SwiftUI/Runtime/JSON.swift +143 -0
- package/Sources/SwiftUI/Runtime/JSONParser.swift +443 -0
- package/Sources/SwiftUI/Runtime/LazyRows.swift +99 -0
- package/Sources/SwiftUI/Runtime/Measurements.swift +140 -0
- package/Sources/SwiftUI/Runtime/Ops.swift +152 -0
- package/Sources/SwiftUI/Runtime/Reconciler.swift +219 -0
- package/Sources/SwiftUI/Runtime/Replay.swift +382 -0
- package/Sources/SwiftUI/Runtime/Runtime.swift +2146 -0
- package/Sources/SwiftUI/Runtime/Sameness.swift +152 -0
- package/Sources/SwiftUI/Runtime/ViewPath.swift +89 -0
- package/Sources/SwiftUI/Runtime/ViewTraits.swift +175 -0
- package/Sources/SwiftUI/Runtime/WebAuthHeadless.swift +49 -0
- package/Sources/Symbols/Symbols.swift +25 -0
- package/Sources/Translation/Translation.swift +423 -0
- package/Sources/UIKit/Activity.swift +213 -0
- package/Sources/UIKit/Alerts.swift +69 -0
- package/Sources/UIKit/AppDelegate.swift +222 -0
- package/Sources/UIKit/Appearance.swift +84 -0
- package/Sources/UIKit/ColorConversions.swift +70 -0
- package/Sources/UIKit/Controls.swift +225 -0
- package/Sources/UIKit/Device.swift +200 -0
- package/Sources/UIKit/Feedback.swift +65 -0
- package/Sources/UIKit/Font.swift +307 -0
- package/Sources/UIKit/Graphics.swift +204 -0
- package/Sources/UIKit/HostingController.swift +185 -0
- package/Sources/UIKit/Identity.swift +24 -0
- package/Sources/UIKit/Introspectable.swift +510 -0
- package/Sources/UIKit/Pasteboard.swift +363 -0
- package/Sources/UIKit/PhotoAlbum.swift +81 -0
- package/Sources/UIKit/RemoteNotifications.swift +15 -0
- package/Sources/UIKit/Representable.swift +288 -0
- package/Sources/UIKit/SafeArea.swift +12 -0
- package/Sources/UIKit/SceneDelegates.swift +132 -0
- package/Sources/UIKit/Scenes.swift +40 -0
- package/Sources/UIKit/ScrollView.swift +157 -0
- package/Sources/UIKit/ShortcutItems.swift +67 -0
- package/Sources/UIKit/SymbolConfiguration.swift +124 -0
- package/Sources/UIKit/TargetAction.swift +123 -0
- package/Sources/UIKit/TextPaste.swift +161 -0
- package/Sources/UIKit/TextView.swift +538 -0
- package/Sources/UIKit/UIKit.swift +292 -0
- package/Sources/UIKit/UIView.swift +855 -0
- package/Sources/UIKit/ViewTranslation.swift +311 -0
- package/Sources/UniformTypeIdentifiers/UTType.swift +196 -0
- package/Sources/UserNotifications/Content.swift +370 -0
- package/Sources/UserNotifications/NotificationCenter.swift +309 -0
- package/Sources/WeatherKit/WeatherKit.swift +228 -0
- package/Sources/WebKit/WebKit.swift +245 -0
- package/Sources/os/os.swift +376 -0
- package/Sources/zlib/zlib.swift +6 -0
- package/index.d.ts +2 -0
- package/index.mjs +16 -0
- package/manifest.d.mts +2 -0
- package/manifest.mjs +39 -0
- package/package.json +30 -4
- package/sync-sources.mjs +33 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Future.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Created by Max Desiatov on 24/11/2019.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
/// A publisher that eventually produces a single value and then finishes or fails.
|
|
9
|
+
public final class Future<Output, Failure: Error>: Publisher {
|
|
10
|
+
|
|
11
|
+
/// A type that represents a closure to invoke in the future, when an element or error
|
|
12
|
+
/// is available.
|
|
13
|
+
///
|
|
14
|
+
/// The promise closure receives one parameter: a `Result` that contains either
|
|
15
|
+
/// a single element published by a `Future`, or an error.
|
|
16
|
+
public typealias Promise = (Result<Output, Failure>) -> Void
|
|
17
|
+
|
|
18
|
+
private let lock = UnfairLock.allocate()
|
|
19
|
+
|
|
20
|
+
private var downstreams = ConduitList<Output, Failure>.empty
|
|
21
|
+
|
|
22
|
+
private var result: Result<Output, Failure>?
|
|
23
|
+
|
|
24
|
+
/// Creates a publisher that invokes a promise closure when the publisher emits
|
|
25
|
+
/// an element.
|
|
26
|
+
///
|
|
27
|
+
/// - Parameter attemptToFulfill: A `Promise` that the publisher invokes when
|
|
28
|
+
/// the publisher emits an element or terminates with an error.
|
|
29
|
+
public init(
|
|
30
|
+
_ attemptToFulfill: @escaping (@escaping Promise) -> Void
|
|
31
|
+
) {
|
|
32
|
+
attemptToFulfill(self.promise)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
deinit {
|
|
36
|
+
lock.deallocate()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private func promise(_ result: Result<Output, Failure>) {
|
|
40
|
+
lock.lock()
|
|
41
|
+
guard self.result == nil else {
|
|
42
|
+
lock.unlock()
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
self.result = result
|
|
46
|
+
let downstreams = self.downstreams.take()
|
|
47
|
+
lock.unlock()
|
|
48
|
+
switch result {
|
|
49
|
+
case .success(let output):
|
|
50
|
+
downstreams.forEach { $0.offer(output) }
|
|
51
|
+
case .failure(let error):
|
|
52
|
+
downstreams.forEach { $0.finish(completion: .failure(error)) }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public func receive<Downstream: Subscriber>(subscriber: Downstream)
|
|
57
|
+
where Output == Downstream.Input, Failure == Downstream.Failure
|
|
58
|
+
{
|
|
59
|
+
let conduit = Conduit(parent: self, downstream: subscriber)
|
|
60
|
+
lock.lock()
|
|
61
|
+
if let result = self.result {
|
|
62
|
+
downstreams.insert(conduit)
|
|
63
|
+
lock.unlock()
|
|
64
|
+
subscriber.receive(subscription: conduit)
|
|
65
|
+
conduit.fulfill(result)
|
|
66
|
+
} else {
|
|
67
|
+
downstreams.insert(conduit)
|
|
68
|
+
lock.unlock()
|
|
69
|
+
subscriber.receive(subscription: conduit)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private func disassociate(_ conduit: ConduitBase<Output, Failure>) {
|
|
74
|
+
lock.lock()
|
|
75
|
+
downstreams.remove(conduit)
|
|
76
|
+
lock.unlock()
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
extension Future {
|
|
81
|
+
|
|
82
|
+
private final class Conduit<Downstream: Subscriber>
|
|
83
|
+
: ConduitBase<Output, Failure>,
|
|
84
|
+
CustomStringConvertible,
|
|
85
|
+
CustomReflectable,
|
|
86
|
+
CustomPlaygroundDisplayConvertible
|
|
87
|
+
where Downstream.Input == Output, Downstream.Failure == Failure
|
|
88
|
+
{
|
|
89
|
+
private enum State {
|
|
90
|
+
case active(Downstream, hasAnyDemand: Bool)
|
|
91
|
+
case terminal
|
|
92
|
+
|
|
93
|
+
var downstream: Downstream? {
|
|
94
|
+
switch self {
|
|
95
|
+
case .active(let downstream, hasAnyDemand: _):
|
|
96
|
+
return downstream
|
|
97
|
+
case .terminal:
|
|
98
|
+
return nil
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var hasAnyDemand: Bool {
|
|
103
|
+
switch self {
|
|
104
|
+
case .active(_, let hasAnyDemand):
|
|
105
|
+
return hasAnyDemand
|
|
106
|
+
case .terminal:
|
|
107
|
+
return false
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private var parent: Future?
|
|
113
|
+
|
|
114
|
+
private var state: State
|
|
115
|
+
|
|
116
|
+
private var lock = UnfairLock.allocate()
|
|
117
|
+
|
|
118
|
+
private var downstreamLock = UnfairRecursiveLock.allocate()
|
|
119
|
+
|
|
120
|
+
fileprivate init(parent: Future, downstream: Downstream) {
|
|
121
|
+
self.parent = parent
|
|
122
|
+
self.state = .active(downstream, hasAnyDemand: false)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
deinit {
|
|
126
|
+
lock.deallocate()
|
|
127
|
+
downstreamLock.deallocate()
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
fileprivate func lockedFulfill(downstream: Downstream,
|
|
131
|
+
result: Result<Output, Failure>) {
|
|
132
|
+
switch result {
|
|
133
|
+
case .success(let output):
|
|
134
|
+
_ = downstream.receive(output)
|
|
135
|
+
downstream.receive(completion: .finished)
|
|
136
|
+
case .failure(let error):
|
|
137
|
+
downstream.receive(completion: .failure(error))
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
fileprivate func fulfill(_ result: Result<Output, Failure>) {
|
|
142
|
+
lock.lock()
|
|
143
|
+
guard case let .active(downstream, hasAnyDemand) = state else {
|
|
144
|
+
lock.unlock()
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
if case .success = result, !hasAnyDemand {
|
|
148
|
+
lock.unlock()
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
state = .terminal
|
|
153
|
+
lock.unlock()
|
|
154
|
+
downstreamLock.lock()
|
|
155
|
+
lockedFulfill(downstream: downstream, result: result)
|
|
156
|
+
downstreamLock.unlock()
|
|
157
|
+
lock.lock()
|
|
158
|
+
let parent = self.parent.take()
|
|
159
|
+
lock.unlock()
|
|
160
|
+
parent?.disassociate(self)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
override func offer(_ output: Output) {
|
|
164
|
+
fulfill(.success(output))
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
override func finish(completion: Subscribers.Completion<Failure>) {
|
|
168
|
+
switch completion {
|
|
169
|
+
case .finished:
|
|
170
|
+
assertionFailure("unreachable")
|
|
171
|
+
case .failure(let error):
|
|
172
|
+
fulfill(.failure(error))
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
override func request(_ demand: Subscribers.Demand) {
|
|
177
|
+
demand.assertNonZero()
|
|
178
|
+
lock.lock()
|
|
179
|
+
guard case .active(let downstream, hasAnyDemand: _) = state else {
|
|
180
|
+
lock.unlock()
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
state = .active(downstream, hasAnyDemand: true)
|
|
184
|
+
|
|
185
|
+
if let parent = parent, let result = parent.result {
|
|
186
|
+
// If the promise is already resolved, send the result downstream
|
|
187
|
+
// immediately
|
|
188
|
+
state = .terminal
|
|
189
|
+
lock.unlock()
|
|
190
|
+
downstreamLock.lock()
|
|
191
|
+
lockedFulfill(downstream: downstream, result: result)
|
|
192
|
+
downstreamLock.unlock()
|
|
193
|
+
parent.disassociate(self)
|
|
194
|
+
} else {
|
|
195
|
+
lock.unlock()
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
override func cancel() {
|
|
200
|
+
lock.lock()
|
|
201
|
+
switch state {
|
|
202
|
+
case .active:
|
|
203
|
+
state = .terminal
|
|
204
|
+
let parent = self.parent.take()
|
|
205
|
+
lock.unlock()
|
|
206
|
+
parent?.disassociate(self)
|
|
207
|
+
case .terminal:
|
|
208
|
+
lock.unlock()
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
var description: String { return "Future" }
|
|
213
|
+
|
|
214
|
+
var customMirror: Mirror {
|
|
215
|
+
lock.lock()
|
|
216
|
+
defer { lock.unlock() }
|
|
217
|
+
let children: [Mirror.Child] = [
|
|
218
|
+
("parent", parent as Any),
|
|
219
|
+
("downstream", state.downstream as Any),
|
|
220
|
+
("hasAnyDemand", state.hasAnyDemand),
|
|
221
|
+
("subject", parent as Any)
|
|
222
|
+
]
|
|
223
|
+
return Mirror(self, children: children)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
var playgroundDescription: Any { return description }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
|
|
2
|
+
// ┃ ┃
|
|
3
|
+
// ┃ Auto-generated from GYB template. DO NOT EDIT! ┃
|
|
4
|
+
// ┃ ┃
|
|
5
|
+
// ┃ ┃
|
|
6
|
+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|
7
|
+
//
|
|
8
|
+
// RootProtocols.swift
|
|
9
|
+
// OpenCombine
|
|
10
|
+
//
|
|
11
|
+
// Created by Sergej Jaskiewicz on 10.06.2019.
|
|
12
|
+
//
|
|
13
|
+
|
|
14
|
+
#if compiler(>=5.7)
|
|
15
|
+
/// Declares that a type can transmit a sequence of values over time.
|
|
16
|
+
///
|
|
17
|
+
/// A publisher delivers elements to one or more `Subscriber` instances.
|
|
18
|
+
/// The subscriber’s `Input` and `Failure` associated types must match the `Output` and
|
|
19
|
+
/// `Failure` types declared by the publisher.
|
|
20
|
+
/// The publisher implements the `receive(subscriber:)`method to accept a subscriber.
|
|
21
|
+
///
|
|
22
|
+
/// After this, the publisher can call the following methods on the subscriber:
|
|
23
|
+
/// - `receive(subscription:)`: Acknowledges the subscribe request and returns
|
|
24
|
+
/// a `Subscription` instance. The subscriber uses the subscription to demand elements
|
|
25
|
+
/// from the publisher and can use it to cancel publishing.
|
|
26
|
+
/// - `receive(_:)`: Delivers one element from the publisher to the subscriber.
|
|
27
|
+
/// - `receive(completion:)`: Informs the subscriber that publishing has ended,
|
|
28
|
+
/// either normally or with an error.
|
|
29
|
+
///
|
|
30
|
+
/// Every `Publisher` must adhere to this contract for downstream subscribers to function
|
|
31
|
+
/// correctly.
|
|
32
|
+
///
|
|
33
|
+
/// Extensions on `Publisher` define a wide variety of _operators_ that you compose to
|
|
34
|
+
/// create sophisticated event-processing chains.
|
|
35
|
+
/// Each operator returns a type that implements the `Publisher` protocol
|
|
36
|
+
/// Most of these types exist as extensions on the `Publishers` enumeration.
|
|
37
|
+
/// For example, the `map(_:)` operator returns an instance of `Publishers.Map`.
|
|
38
|
+
///
|
|
39
|
+
/// # Creating Your Own Publishers
|
|
40
|
+
///
|
|
41
|
+
/// Rather than implementing the `Publisher` protocol yourself, you can create your own
|
|
42
|
+
/// publisher by using one of several types provided by the OpenCombine framework:
|
|
43
|
+
///
|
|
44
|
+
/// - Use a concrete subclass of `Subject`, such as `PassthroughSubject`, to publish
|
|
45
|
+
/// values on-demand by calling its `send(_:)` method.
|
|
46
|
+
/// - Use a `CurrentValueSubject` to publish whenever you update the subject’s underlying
|
|
47
|
+
/// value.
|
|
48
|
+
/// - Add the `@Published` annotation to a property of one of your own types. In doing so,
|
|
49
|
+
/// the property gains a publisher that emits an event whenever the property’s value
|
|
50
|
+
/// changes. See the `Published` type for an example of this approach.
|
|
51
|
+
public protocol Publisher<Output, Failure> {
|
|
52
|
+
|
|
53
|
+
/// The kind of values published by this publisher.
|
|
54
|
+
associatedtype Output
|
|
55
|
+
|
|
56
|
+
/// The kind of errors this publisher might publish.
|
|
57
|
+
///
|
|
58
|
+
/// Use `Never` if this `Publisher` does not publish errors.
|
|
59
|
+
associatedtype Failure: Error
|
|
60
|
+
|
|
61
|
+
/// Attaches the specified subscriber to this publisher.
|
|
62
|
+
///
|
|
63
|
+
/// Always call this function instead of `receive(subscriber:)`.
|
|
64
|
+
/// Adopters of `Publisher` must implement `receive(subscriber:)`. The implementation
|
|
65
|
+
/// of `subscribe(_:)` provided by `Publisher` calls through to
|
|
66
|
+
/// `receive(subscriber:)`.
|
|
67
|
+
///
|
|
68
|
+
/// - Parameter subscriber: The subscriber to attach to this publisher. After
|
|
69
|
+
/// attaching, the subscriber can start to receive values.
|
|
70
|
+
func receive<Subscriber: Combine.Subscriber>(subscriber: Subscriber)
|
|
71
|
+
where Failure == Subscriber.Failure, Output == Subscriber.Input
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// A publisher that exposes a method for outside callers to publish elements.
|
|
75
|
+
///
|
|
76
|
+
/// A subject is a publisher that you can use to ”inject” values into a stream, by calling
|
|
77
|
+
/// its `send()` method. This can be useful for adapting existing imperative code to the
|
|
78
|
+
/// Combine model.
|
|
79
|
+
public protocol Subject<Output, Failure>: AnyObject, Publisher {
|
|
80
|
+
|
|
81
|
+
/// Sends a value to the subscriber.
|
|
82
|
+
///
|
|
83
|
+
/// - Parameter value: The value to send.
|
|
84
|
+
func send(_ value: Output)
|
|
85
|
+
|
|
86
|
+
/// Sends a completion signal to the subscriber.
|
|
87
|
+
///
|
|
88
|
+
/// - Parameter completion: A `Completion` instance which indicates whether publishing
|
|
89
|
+
/// has finished normally or failed with an error.
|
|
90
|
+
func send(completion: Subscribers.Completion<Failure>)
|
|
91
|
+
|
|
92
|
+
/// Sends a subscription to the subscriber.
|
|
93
|
+
///
|
|
94
|
+
/// This call provides the `Subject` an opportunity to establish demand for any new
|
|
95
|
+
/// upstream subscriptions.
|
|
96
|
+
///
|
|
97
|
+
/// - Parameter subscription: The subscription instance through which the subscriber
|
|
98
|
+
/// can request elements.
|
|
99
|
+
func send(subscription: Subscription)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// A publisher that provides an explicit means of connecting and canceling publication.
|
|
103
|
+
///
|
|
104
|
+
/// Use a `ConnectablePublisher` when you need to perform additional configuration or
|
|
105
|
+
/// setup prior to producing any elements.
|
|
106
|
+
///
|
|
107
|
+
/// This publisher doesn’t produce any elements until you call its `connect()` method.
|
|
108
|
+
///
|
|
109
|
+
/// Use `makeConnectable()` to create a `ConnectablePublisher` from any publisher whose
|
|
110
|
+
/// failure type is `Never`.
|
|
111
|
+
public protocol ConnectablePublisher<Output, Failure>: Publisher {
|
|
112
|
+
|
|
113
|
+
/// Connects to the publisher, allowing it to produce elements, and returns
|
|
114
|
+
/// an instance with which to cancel publishing.
|
|
115
|
+
///
|
|
116
|
+
/// - Returns: A `Cancellable` instance that you use to cancel publishing.
|
|
117
|
+
func connect() -> Cancellable
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// A protocol that declares a type that can receive input from a publisher.
|
|
121
|
+
///
|
|
122
|
+
/// A `Subscriber` instance receives a stream of elements from a `Publisher`, along with
|
|
123
|
+
/// life cycle events describing changes to their relationship. A given subscriber’s
|
|
124
|
+
/// `Input` and `Failure` associated types must match the `Output` and `Failure` of its
|
|
125
|
+
/// corresponding publisher.
|
|
126
|
+
///
|
|
127
|
+
/// You connect a subscriber to a publisher by calling the publisher’s `subscribe(_:)`
|
|
128
|
+
/// method. After making this call, the publisher invokes the subscriber’s
|
|
129
|
+
/// `receive(subscription:)` method. This gives the subscriber a `Subscription` instance,
|
|
130
|
+
/// which it uses to demand elements from the publisher, and to optionally cancel
|
|
131
|
+
/// the subscription. After the subscriber makes an initial demand, the publisher calls
|
|
132
|
+
/// `receive(_:)`, possibly asynchronously, to deliver newly-published elements.
|
|
133
|
+
/// If the publisher stops publishing, it calls `receive(completion:)`, using a parameter
|
|
134
|
+
/// of type `Subscribers.Completion` to indicate whether publishing completes normally or
|
|
135
|
+
/// with an error.
|
|
136
|
+
///
|
|
137
|
+
/// OpenCombine provides the following subscribers as operators on the `Publisher` type:
|
|
138
|
+
///
|
|
139
|
+
/// - `sink(receiveCompletion:receiveValue:)` executes arbitrary closures when
|
|
140
|
+
/// it receives a completion signal and each time it receives a new element.
|
|
141
|
+
/// - `assign(to:on:)` writes each newly-received value to a property identified by
|
|
142
|
+
/// a key path on a given instance.
|
|
143
|
+
public protocol Subscriber<Input, Failure>: CustomCombineIdentifierConvertible {
|
|
144
|
+
|
|
145
|
+
/// The kind of values this subscriber receives.
|
|
146
|
+
associatedtype Input
|
|
147
|
+
|
|
148
|
+
/// The kind of errors this subscriber might receive.
|
|
149
|
+
///
|
|
150
|
+
/// Use `Never` if this `Subscriber` cannot receive errors.
|
|
151
|
+
associatedtype Failure: Error
|
|
152
|
+
|
|
153
|
+
/// Tells the subscriber that it has successfully subscribed to the publisher and may
|
|
154
|
+
/// request items.
|
|
155
|
+
///
|
|
156
|
+
/// Use the received `Subscription` to request items from the publisher.
|
|
157
|
+
/// - Parameter subscription: A subscription that represents the connection between
|
|
158
|
+
/// publisher and subscriber.
|
|
159
|
+
func receive(subscription: Subscription)
|
|
160
|
+
|
|
161
|
+
/// Tells the subscriber that the publisher has produced an element.
|
|
162
|
+
///
|
|
163
|
+
/// - Parameter input: The published element.
|
|
164
|
+
/// - Returns: A `Subscribers.Demand` instance indicating how many more elements
|
|
165
|
+
/// the subscriber expects to receive.
|
|
166
|
+
func receive(_ input: Input) -> Subscribers.Demand
|
|
167
|
+
|
|
168
|
+
/// Tells the subscriber that the publisher has completed publishing, either normally
|
|
169
|
+
/// or with an error.
|
|
170
|
+
///
|
|
171
|
+
/// - Parameter completion: A `Subscribers.Completion` case indicating whether
|
|
172
|
+
/// publishing completed normally or with an error.
|
|
173
|
+
func receive(completion: Subscribers.Completion<Failure>)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/// A protocol that defines when and how to execute a closure.
|
|
177
|
+
///
|
|
178
|
+
/// You can use a scheduler to execute code as soon as possible, or after a future date.
|
|
179
|
+
/// Individual scheduler implementations use whatever time-keeping system makes sense
|
|
180
|
+
/// for them. Schedulers express this as their `SchedulerTimeType`. Since this type
|
|
181
|
+
/// conforms to `SchedulerTimeIntervalConvertible`, you can always express these times
|
|
182
|
+
/// with the convenience functions like `.milliseconds(500)`. Schedulers can accept
|
|
183
|
+
/// options to control how they execute the actions passed to them. These options may
|
|
184
|
+
/// control factors like which threads or dispatch queues execute the actions.
|
|
185
|
+
public protocol Scheduler<SchedulerTimeType> {
|
|
186
|
+
|
|
187
|
+
/// Describes an instant in time for this scheduler.
|
|
188
|
+
associatedtype SchedulerTimeType: Strideable
|
|
189
|
+
where SchedulerTimeType.Stride: SchedulerTimeIntervalConvertible
|
|
190
|
+
|
|
191
|
+
/// A type that defines options accepted by the scheduler.
|
|
192
|
+
///
|
|
193
|
+
/// This type is freely definable by each `Scheduler`. Typically, operations that
|
|
194
|
+
/// take a `Scheduler` parameter will also take `SchedulerOptions`.
|
|
195
|
+
associatedtype SchedulerOptions
|
|
196
|
+
|
|
197
|
+
/// This scheduler’s definition of the current moment in time.
|
|
198
|
+
var now: SchedulerTimeType { get }
|
|
199
|
+
|
|
200
|
+
/// The minimum tolerance allowed by the scheduler.
|
|
201
|
+
var minimumTolerance: SchedulerTimeType.Stride { get }
|
|
202
|
+
|
|
203
|
+
/// Performs the action at the next possible opportunity.
|
|
204
|
+
func schedule(options: SchedulerOptions?, _ action: @escaping () -> Void)
|
|
205
|
+
|
|
206
|
+
/// Performs the action at some time after the specified date.
|
|
207
|
+
func schedule(after date: SchedulerTimeType,
|
|
208
|
+
tolerance: SchedulerTimeType.Stride,
|
|
209
|
+
options: SchedulerOptions?,
|
|
210
|
+
_ action: @escaping () -> Void)
|
|
211
|
+
|
|
212
|
+
/// Performs the action at some time after the specified date, at the specified
|
|
213
|
+
/// frequency, optionally taking into account tolerance if possible.
|
|
214
|
+
func schedule(after date: SchedulerTimeType,
|
|
215
|
+
interval: SchedulerTimeType.Stride,
|
|
216
|
+
tolerance: SchedulerTimeType.Stride,
|
|
217
|
+
options: SchedulerOptions?,
|
|
218
|
+
_ action: @escaping () -> Void) -> Cancellable
|
|
219
|
+
}
|
|
220
|
+
#else
|
|
221
|
+
/// Declares that a type can transmit a sequence of values over time.
|
|
222
|
+
///
|
|
223
|
+
/// A publisher delivers elements to one or more `Subscriber` instances.
|
|
224
|
+
/// The subscriber’s `Input` and `Failure` associated types must match the `Output` and
|
|
225
|
+
/// `Failure` types declared by the publisher.
|
|
226
|
+
/// The publisher implements the `receive(subscriber:)`method to accept a subscriber.
|
|
227
|
+
///
|
|
228
|
+
/// After this, the publisher can call the following methods on the subscriber:
|
|
229
|
+
/// - `receive(subscription:)`: Acknowledges the subscribe request and returns
|
|
230
|
+
/// a `Subscription` instance. The subscriber uses the subscription to demand elements
|
|
231
|
+
/// from the publisher and can use it to cancel publishing.
|
|
232
|
+
/// - `receive(_:)`: Delivers one element from the publisher to the subscriber.
|
|
233
|
+
/// - `receive(completion:)`: Informs the subscriber that publishing has ended,
|
|
234
|
+
/// either normally or with an error.
|
|
235
|
+
///
|
|
236
|
+
/// Every `Publisher` must adhere to this contract for downstream subscribers to function
|
|
237
|
+
/// correctly.
|
|
238
|
+
///
|
|
239
|
+
/// Extensions on `Publisher` define a wide variety of _operators_ that you compose to
|
|
240
|
+
/// create sophisticated event-processing chains.
|
|
241
|
+
/// Each operator returns a type that implements the `Publisher` protocol
|
|
242
|
+
/// Most of these types exist as extensions on the `Publishers` enumeration.
|
|
243
|
+
/// For example, the `map(_:)` operator returns an instance of `Publishers.Map`.
|
|
244
|
+
///
|
|
245
|
+
/// # Creating Your Own Publishers
|
|
246
|
+
///
|
|
247
|
+
/// Rather than implementing the `Publisher` protocol yourself, you can create your own
|
|
248
|
+
/// publisher by using one of several types provided by the OpenCombine framework:
|
|
249
|
+
///
|
|
250
|
+
/// - Use a concrete subclass of `Subject`, such as `PassthroughSubject`, to publish
|
|
251
|
+
/// values on-demand by calling its `send(_:)` method.
|
|
252
|
+
/// - Use a `CurrentValueSubject` to publish whenever you update the subject’s underlying
|
|
253
|
+
/// value.
|
|
254
|
+
/// - Add the `@Published` annotation to a property of one of your own types. In doing so,
|
|
255
|
+
/// the property gains a publisher that emits an event whenever the property’s value
|
|
256
|
+
/// changes. See the `Published` type for an example of this approach.
|
|
257
|
+
public protocol Publisher {
|
|
258
|
+
|
|
259
|
+
/// The kind of values published by this publisher.
|
|
260
|
+
associatedtype Output
|
|
261
|
+
|
|
262
|
+
/// The kind of errors this publisher might publish.
|
|
263
|
+
///
|
|
264
|
+
/// Use `Never` if this `Publisher` does not publish errors.
|
|
265
|
+
associatedtype Failure: Error
|
|
266
|
+
|
|
267
|
+
/// Attaches the specified subscriber to this publisher.
|
|
268
|
+
///
|
|
269
|
+
/// Always call this function instead of `receive(subscriber:)`.
|
|
270
|
+
/// Adopters of `Publisher` must implement `receive(subscriber:)`. The implementation
|
|
271
|
+
/// of `subscribe(_:)` provided by `Publisher` calls through to
|
|
272
|
+
/// `receive(subscriber:)`.
|
|
273
|
+
///
|
|
274
|
+
/// - Parameter subscriber: The subscriber to attach to this publisher. After
|
|
275
|
+
/// attaching, the subscriber can start to receive values.
|
|
276
|
+
func receive<Subscriber: Combine.Subscriber>(subscriber: Subscriber)
|
|
277
|
+
where Failure == Subscriber.Failure, Output == Subscriber.Input
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/// A publisher that exposes a method for outside callers to publish elements.
|
|
281
|
+
///
|
|
282
|
+
/// A subject is a publisher that you can use to ”inject” values into a stream, by calling
|
|
283
|
+
/// its `send()` method. This can be useful for adapting existing imperative code to the
|
|
284
|
+
/// Combine model.
|
|
285
|
+
public protocol Subject: AnyObject, Publisher {
|
|
286
|
+
|
|
287
|
+
/// Sends a value to the subscriber.
|
|
288
|
+
///
|
|
289
|
+
/// - Parameter value: The value to send.
|
|
290
|
+
func send(_ value: Output)
|
|
291
|
+
|
|
292
|
+
/// Sends a completion signal to the subscriber.
|
|
293
|
+
///
|
|
294
|
+
/// - Parameter completion: A `Completion` instance which indicates whether publishing
|
|
295
|
+
/// has finished normally or failed with an error.
|
|
296
|
+
func send(completion: Subscribers.Completion<Failure>)
|
|
297
|
+
|
|
298
|
+
/// Sends a subscription to the subscriber.
|
|
299
|
+
///
|
|
300
|
+
/// This call provides the `Subject` an opportunity to establish demand for any new
|
|
301
|
+
/// upstream subscriptions.
|
|
302
|
+
///
|
|
303
|
+
/// - Parameter subscription: The subscription instance through which the subscriber
|
|
304
|
+
/// can request elements.
|
|
305
|
+
func send(subscription: Subscription)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/// A publisher that provides an explicit means of connecting and canceling publication.
|
|
309
|
+
///
|
|
310
|
+
/// Use a `ConnectablePublisher` when you need to perform additional configuration or
|
|
311
|
+
/// setup prior to producing any elements.
|
|
312
|
+
///
|
|
313
|
+
/// This publisher doesn’t produce any elements until you call its `connect()` method.
|
|
314
|
+
///
|
|
315
|
+
/// Use `makeConnectable()` to create a `ConnectablePublisher` from any publisher whose
|
|
316
|
+
/// failure type is `Never`.
|
|
317
|
+
public protocol ConnectablePublisher: Publisher {
|
|
318
|
+
|
|
319
|
+
/// Connects to the publisher, allowing it to produce elements, and returns
|
|
320
|
+
/// an instance with which to cancel publishing.
|
|
321
|
+
///
|
|
322
|
+
/// - Returns: A `Cancellable` instance that you use to cancel publishing.
|
|
323
|
+
func connect() -> Cancellable
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/// A protocol that declares a type that can receive input from a publisher.
|
|
327
|
+
///
|
|
328
|
+
/// A `Subscriber` instance receives a stream of elements from a `Publisher`, along with
|
|
329
|
+
/// life cycle events describing changes to their relationship. A given subscriber’s
|
|
330
|
+
/// `Input` and `Failure` associated types must match the `Output` and `Failure` of its
|
|
331
|
+
/// corresponding publisher.
|
|
332
|
+
///
|
|
333
|
+
/// You connect a subscriber to a publisher by calling the publisher’s `subscribe(_:)`
|
|
334
|
+
/// method. After making this call, the publisher invokes the subscriber’s
|
|
335
|
+
/// `receive(subscription:)` method. This gives the subscriber a `Subscription` instance,
|
|
336
|
+
/// which it uses to demand elements from the publisher, and to optionally cancel
|
|
337
|
+
/// the subscription. After the subscriber makes an initial demand, the publisher calls
|
|
338
|
+
/// `receive(_:)`, possibly asynchronously, to deliver newly-published elements.
|
|
339
|
+
/// If the publisher stops publishing, it calls `receive(completion:)`, using a parameter
|
|
340
|
+
/// of type `Subscribers.Completion` to indicate whether publishing completes normally or
|
|
341
|
+
/// with an error.
|
|
342
|
+
///
|
|
343
|
+
/// OpenCombine provides the following subscribers as operators on the `Publisher` type:
|
|
344
|
+
///
|
|
345
|
+
/// - `sink(receiveCompletion:receiveValue:)` executes arbitrary closures when
|
|
346
|
+
/// it receives a completion signal and each time it receives a new element.
|
|
347
|
+
/// - `assign(to:on:)` writes each newly-received value to a property identified by
|
|
348
|
+
/// a key path on a given instance.
|
|
349
|
+
public protocol Subscriber: CustomCombineIdentifierConvertible {
|
|
350
|
+
|
|
351
|
+
/// The kind of values this subscriber receives.
|
|
352
|
+
associatedtype Input
|
|
353
|
+
|
|
354
|
+
/// The kind of errors this subscriber might receive.
|
|
355
|
+
///
|
|
356
|
+
/// Use `Never` if this `Subscriber` cannot receive errors.
|
|
357
|
+
associatedtype Failure: Error
|
|
358
|
+
|
|
359
|
+
/// Tells the subscriber that it has successfully subscribed to the publisher and may
|
|
360
|
+
/// request items.
|
|
361
|
+
///
|
|
362
|
+
/// Use the received `Subscription` to request items from the publisher.
|
|
363
|
+
/// - Parameter subscription: A subscription that represents the connection between
|
|
364
|
+
/// publisher and subscriber.
|
|
365
|
+
func receive(subscription: Subscription)
|
|
366
|
+
|
|
367
|
+
/// Tells the subscriber that the publisher has produced an element.
|
|
368
|
+
///
|
|
369
|
+
/// - Parameter input: The published element.
|
|
370
|
+
/// - Returns: A `Subscribers.Demand` instance indicating how many more elements
|
|
371
|
+
/// the subscriber expects to receive.
|
|
372
|
+
func receive(_ input: Input) -> Subscribers.Demand
|
|
373
|
+
|
|
374
|
+
/// Tells the subscriber that the publisher has completed publishing, either normally
|
|
375
|
+
/// or with an error.
|
|
376
|
+
///
|
|
377
|
+
/// - Parameter completion: A `Subscribers.Completion` case indicating whether
|
|
378
|
+
/// publishing completed normally or with an error.
|
|
379
|
+
func receive(completion: Subscribers.Completion<Failure>)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/// A protocol that defines when and how to execute a closure.
|
|
383
|
+
///
|
|
384
|
+
/// You can use a scheduler to execute code as soon as possible, or after a future date.
|
|
385
|
+
/// Individual scheduler implementations use whatever time-keeping system makes sense
|
|
386
|
+
/// for them. Schedulers express this as their `SchedulerTimeType`. Since this type
|
|
387
|
+
/// conforms to `SchedulerTimeIntervalConvertible`, you can always express these times
|
|
388
|
+
/// with the convenience functions like `.milliseconds(500)`. Schedulers can accept
|
|
389
|
+
/// options to control how they execute the actions passed to them. These options may
|
|
390
|
+
/// control factors like which threads or dispatch queues execute the actions.
|
|
391
|
+
public protocol Scheduler {
|
|
392
|
+
|
|
393
|
+
/// Describes an instant in time for this scheduler.
|
|
394
|
+
associatedtype SchedulerTimeType: Strideable
|
|
395
|
+
where SchedulerTimeType.Stride: SchedulerTimeIntervalConvertible
|
|
396
|
+
|
|
397
|
+
/// A type that defines options accepted by the scheduler.
|
|
398
|
+
///
|
|
399
|
+
/// This type is freely definable by each `Scheduler`. Typically, operations that
|
|
400
|
+
/// take a `Scheduler` parameter will also take `SchedulerOptions`.
|
|
401
|
+
associatedtype SchedulerOptions
|
|
402
|
+
|
|
403
|
+
/// This scheduler’s definition of the current moment in time.
|
|
404
|
+
var now: SchedulerTimeType { get }
|
|
405
|
+
|
|
406
|
+
/// The minimum tolerance allowed by the scheduler.
|
|
407
|
+
var minimumTolerance: SchedulerTimeType.Stride { get }
|
|
408
|
+
|
|
409
|
+
/// Performs the action at the next possible opportunity.
|
|
410
|
+
func schedule(options: SchedulerOptions?, _ action: @escaping () -> Void)
|
|
411
|
+
|
|
412
|
+
/// Performs the action at some time after the specified date.
|
|
413
|
+
func schedule(after date: SchedulerTimeType,
|
|
414
|
+
tolerance: SchedulerTimeType.Stride,
|
|
415
|
+
options: SchedulerOptions?,
|
|
416
|
+
_ action: @escaping () -> Void)
|
|
417
|
+
|
|
418
|
+
/// Performs the action at some time after the specified date, at the specified
|
|
419
|
+
/// frequency, optionally taking into account tolerance if possible.
|
|
420
|
+
func schedule(after date: SchedulerTimeType,
|
|
421
|
+
interval: SchedulerTimeType.Stride,
|
|
422
|
+
tolerance: SchedulerTimeType.Stride,
|
|
423
|
+
options: SchedulerOptions?,
|
|
424
|
+
_ action: @escaping () -> Void) -> Cancellable
|
|
425
|
+
}
|
|
426
|
+
#endif
|