@swiftbrowser/swift 0.1.0 → 0.3.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 +200 -9
- package/README.md +7 -9
- 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 +0 -4
- 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/{_FoundationCommon → FoundationBridge}/Bundle.swift +41 -4
- 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 +24 -72
- 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/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 +6 -1
- package/Sources/FoundationBridge/URLSession.swift +718 -0
- package/Sources/{_FoundationCommon → FoundationBridge}/UserDefaults.swift +17 -4
- 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 +55 -6
- package/Sources/SwiftUI/API/AccessibilityExtras.swift +33 -0
- package/Sources/SwiftUI/API/AccessibilityFocus.swift +63 -0
- package/Sources/SwiftUI/API/Alert.swift +1 -1
- package/Sources/SwiftUI/API/AlignmentGuides.swift +68 -0
- package/Sources/SwiftUI/API/Animation.swift +37 -5
- package/Sources/SwiftUI/API/App.swift +31 -1
- 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 +104 -28
- 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 +59 -27
- package/Sources/SwiftUI/API/CustomLayout.swift +49 -10
- package/Sources/SwiftUI/API/CustomToolbarContent.swift +46 -0
- package/Sources/SwiftUI/API/Decorations.swift +1 -1
- package/Sources/SwiftUI/API/EditMode.swift +25 -82
- package/Sources/SwiftUI/API/Effects.swift +125 -10
- package/Sources/SwiftUI/API/Entry.swift +8 -0
- package/Sources/SwiftUI/API/Environment.swift +100 -9
- package/Sources/SwiftUI/API/EnvironmentSendable.swift +6 -0
- package/Sources/SwiftUI/API/Focus.swift +11 -3
- package/Sources/SwiftUI/API/Gauge.swift +26 -10
- package/Sources/SwiftUI/API/GeometryEffects.swift +232 -0
- package/Sources/SwiftUI/API/GeometryReader.swift +13 -2
- package/Sources/SwiftUI/API/GestureState.swift +65 -0
- package/Sources/SwiftUI/API/Gestures.swift +1 -1
- package/Sources/SwiftUI/API/Glass.swift +127 -0
- package/Sources/SwiftUI/API/Grid.swift +1 -1
- package/Sources/SwiftUI/API/GroupBoxAndControlGroup.swift +130 -0
- package/Sources/SwiftUI/API/KeyPress.swift +54 -0
- package/Sources/SwiftUI/API/LabelStyle.swift +13 -6
- package/Sources/SwiftUI/API/Layout.swift +71 -12
- package/Sources/SwiftUI/API/LazyStacks.swift +49 -0
- package/Sources/SwiftUI/API/LegacyAlert.swift +97 -0
- package/Sources/SwiftUI/API/Lists.swift +61 -6
- package/Sources/SwiftUI/API/Menu.swift +8 -1
- package/Sources/SwiftUI/API/Modifiers.swift +88 -12
- package/Sources/SwiftUI/API/MoreModifiers.swift +100 -0
- package/Sources/SwiftUI/API/Namespace.swift +44 -0
- package/Sources/SwiftUI/API/Navigation.swift +24 -9
- package/Sources/SwiftUI/API/NavigationDestinationBindings.swift +55 -0
- package/Sources/SwiftUI/API/ObservableObject.swift +16 -2
- package/Sources/SwiftUI/API/Path.swift +543 -0
- package/Sources/SwiftUI/API/Phase8Controls.swift +48 -31
- package/Sources/SwiftUI/API/PhaseAnimator.swift +130 -0
- package/Sources/SwiftUI/API/Picker.swift +14 -4
- 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 +17 -4
- package/Sources/SwiftUI/API/PresentationExtras.swift +60 -0
- package/Sources/SwiftUI/API/Primitives.swift +168 -39
- package/Sources/SwiftUI/API/Publishers.swift +4 -4
- package/Sources/SwiftUI/API/Redaction.swift +75 -0
- package/Sources/SwiftUI/API/RowActions.swift +3 -2
- package/Sources/SwiftUI/API/Scenes.swift +131 -0
- package/Sources/SwiftUI/API/ScrollModifiers.swift +132 -0
- package/Sources/SwiftUI/API/ScrollTargets.swift +3 -3
- package/Sources/SwiftUI/API/ScrollViewReader.swift +144 -0
- package/Sources/SwiftUI/API/SectionSupplements.swift +86 -0
- package/Sources/SwiftUI/API/Shape.swift +214 -0
- package/Sources/SwiftUI/API/ShapeStyle.swift +187 -8
- 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 +18 -1
- package/Sources/SwiftUI/API/StatusGaps.swift +121 -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 +148 -4
- package/Sources/SwiftUI/API/Tasks.swift +2 -2
- 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/Toolbar.swift +52 -16
- 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 +46 -2
- package/Sources/SwiftUI/API/ViewModifier.swift +4 -1
- package/Sources/SwiftUI/API/VisualEffect.swift +74 -1
- package/Sources/SwiftUI/API/Windows.swift +25 -0
- package/Sources/SwiftUI/Charts/Axis.swift +7 -1
- package/Sources/SwiftUI/Charts/AxisFormatsAndRanges.swift +68 -0
- package/Sources/SwiftUI/Charts/Chart.swift +17 -3
- package/Sources/SwiftUI/Charts/ChartProxy.swift +57 -0
- package/Sources/SwiftUI/Localization/Localization.swift +524 -0
- package/Sources/SwiftUI/Localization/PluralRules.swift +127 -0
- package/Sources/SwiftUI/Runtime/Executor.swift +2 -0
- package/Sources/SwiftUI/Runtime/Exports.swift +37 -1
- package/Sources/SwiftUI/Runtime/ImageSource.swift +310 -0
- package/Sources/SwiftUI/Runtime/JSON.swift +76 -4
- package/Sources/SwiftUI/Runtime/LazyRows.swift +99 -0
- package/Sources/SwiftUI/Runtime/Measurements.swift +140 -0
- package/Sources/SwiftUI/Runtime/Ops.swift +58 -12
- package/Sources/SwiftUI/Runtime/Reconciler.swift +10 -1
- package/Sources/SwiftUI/Runtime/Replay.swift +382 -0
- package/Sources/SwiftUI/Runtime/Runtime.swift +977 -198
- 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 +1 -1
- package/index.mjs +2 -2
- package/manifest.d.mts +2 -0
- package/manifest.mjs +41 -0
- package/package.json +5 -3
- package/sync-sources.mjs +21 -7
- package/Sources/FoundationLite/Common.swift +0 -3
- package/Sources/FoundationLite/FoundationLite.swift +0 -171
- package/Sources/FoundationLite/Interaction.swift +0 -146
- package/Sources/FoundationLite/Timer.swift +0 -48
- package/Sources/_FoundationCommon/_FoundationCommon.swift +0 -10
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
// StoreKit 1 (the original in-app purchase API), as code written against it
|
|
2
|
+
// calls it: products requests, the payment queue and its transactions,
|
|
3
|
+
// receipts. The browser has no App Store behind any of it: a products
|
|
4
|
+
// request answers no products (every identifier comes back invalid),
|
|
5
|
+
// `SKPaymentQueue.canMakePayments()` is false, a payment added to the queue
|
|
6
|
+
// fails at once with `SKError.paymentNotAllowed`, restoring finds nothing,
|
|
7
|
+
// and a receipt refresh fails with `SKError.unsupportedPlatform`. Observers
|
|
8
|
+
// and delegates hear about all of it on the main actor's next turn, as
|
|
9
|
+
// StoreKit calls them on the main thread. RevenueCat's StoreKit 1 path runs
|
|
10
|
+
// against these, unchanged.
|
|
11
|
+
//
|
|
12
|
+
// The classes are `NSObject` subclasses, as in Apple's SDK, so they hash by
|
|
13
|
+
// identity and can key dictionaries. The `@objc optional` protocol
|
|
14
|
+
// requirements are ordinary requirements with default implementations
|
|
15
|
+
// that do nothing.
|
|
16
|
+
|
|
17
|
+
import Foundation
|
|
18
|
+
|
|
19
|
+
// MARK: - Errors
|
|
20
|
+
|
|
21
|
+
public let SKErrorDomain = "SKErrorDomain"
|
|
22
|
+
|
|
23
|
+
/// A StoreKit 1 error: a code in `SKErrorDomain`, plus the user info.
|
|
24
|
+
public struct SKError: CustomNSError, Hashable, @unchecked Sendable {
|
|
25
|
+
public enum Code: Int, Sendable, Hashable {
|
|
26
|
+
case unknown = 0
|
|
27
|
+
case clientInvalid = 1
|
|
28
|
+
case paymentCancelled = 2
|
|
29
|
+
case paymentInvalid = 3
|
|
30
|
+
case paymentNotAllowed = 4
|
|
31
|
+
case storeProductNotAvailable = 5
|
|
32
|
+
case cloudServicePermissionDenied = 6
|
|
33
|
+
case cloudServiceNetworkConnectionFailed = 7
|
|
34
|
+
case cloudServiceRevoked = 8
|
|
35
|
+
case privacyAcknowledgementRequired = 9
|
|
36
|
+
case unauthorizedRequestData = 10
|
|
37
|
+
case invalidOfferIdentifier = 11
|
|
38
|
+
case invalidSignature = 12
|
|
39
|
+
case missingOfferParams = 13
|
|
40
|
+
case invalidOfferPrice = 14
|
|
41
|
+
case overlayCancelled = 15
|
|
42
|
+
case overlayInvalidConfiguration = 16
|
|
43
|
+
case overlayTimeout = 17
|
|
44
|
+
case ineligibleForOffer = 18
|
|
45
|
+
case unsupportedPlatform = 19
|
|
46
|
+
case overlayPresentedInBackgroundScene = 20
|
|
47
|
+
case paymentMethodBindingConfigurationRequired = 21
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public let code: Code
|
|
51
|
+
public let userInfo: [String: Any]
|
|
52
|
+
|
|
53
|
+
public init(_ code: Code, userInfo: [String: Any] = [:]) {
|
|
54
|
+
self.code = code
|
|
55
|
+
self.userInfo = userInfo
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public init(_nsError error: NSError) {
|
|
59
|
+
code = Code(rawValue: error.code) ?? .unknown
|
|
60
|
+
userInfo = error.userInfo
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public static var errorDomain: String { SKErrorDomain }
|
|
64
|
+
public var errorCode: Int { code.rawValue }
|
|
65
|
+
public var errorUserInfo: [String: Any] { userInfo }
|
|
66
|
+
public var localizedDescription: String {
|
|
67
|
+
(userInfo[NSLocalizedDescriptionKey] as? String) ?? "The operation couldn’t be completed. (SKErrorDomain error \(code.rawValue).)"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public static func == (lhs: SKError, rhs: SKError) -> Bool { lhs.code == rhs.code }
|
|
71
|
+
public func hash(into hasher: inout Hasher) { hasher.combine(code) }
|
|
72
|
+
|
|
73
|
+
public static var unknown: Code { .unknown }
|
|
74
|
+
public static var clientInvalid: Code { .clientInvalid }
|
|
75
|
+
public static var paymentCancelled: Code { .paymentCancelled }
|
|
76
|
+
public static var paymentInvalid: Code { .paymentInvalid }
|
|
77
|
+
public static var paymentNotAllowed: Code { .paymentNotAllowed }
|
|
78
|
+
public static var storeProductNotAvailable: Code { .storeProductNotAvailable }
|
|
79
|
+
public static var cloudServicePermissionDenied: Code { .cloudServicePermissionDenied }
|
|
80
|
+
public static var cloudServiceNetworkConnectionFailed: Code { .cloudServiceNetworkConnectionFailed }
|
|
81
|
+
public static var cloudServiceRevoked: Code { .cloudServiceRevoked }
|
|
82
|
+
public static var privacyAcknowledgementRequired: Code { .privacyAcknowledgementRequired }
|
|
83
|
+
public static var unauthorizedRequestData: Code { .unauthorizedRequestData }
|
|
84
|
+
public static var invalidOfferIdentifier: Code { .invalidOfferIdentifier }
|
|
85
|
+
public static var invalidSignature: Code { .invalidSignature }
|
|
86
|
+
public static var missingOfferParams: Code { .missingOfferParams }
|
|
87
|
+
public static var invalidOfferPrice: Code { .invalidOfferPrice }
|
|
88
|
+
public static var overlayCancelled: Code { .overlayCancelled }
|
|
89
|
+
public static var overlayInvalidConfiguration: Code { .overlayInvalidConfiguration }
|
|
90
|
+
public static var overlayTimeout: Code { .overlayTimeout }
|
|
91
|
+
public static var ineligibleForOffer: Code { .ineligibleForOffer }
|
|
92
|
+
public static var unsupportedPlatform: Code { .unsupportedPlatform }
|
|
93
|
+
public static var overlayPresentedInBackgroundScene: Code { .overlayPresentedInBackgroundScene }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// `catch SKError.paymentCancelled`: matches an `SKError` with that code.
|
|
97
|
+
public func ~= (code: SKError.Code, error: any Error) -> Bool {
|
|
98
|
+
(error as? SKError)?.code == code
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// Runs `body` on the main actor's next turn, as StoreKit calls its
|
|
102
|
+
/// observers and delegates on the main thread later.
|
|
103
|
+
func _onMainActorLater(_ body: @escaping @MainActor () -> Void) {
|
|
104
|
+
let box = _UncheckedBox(body)
|
|
105
|
+
Task { @MainActor in box.value() }
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// Carries a value the compiler cannot prove `Sendable` to the main actor;
|
|
109
|
+
/// StoreKit's objects are only touched there.
|
|
110
|
+
struct _UncheckedBox<Value>: @unchecked Sendable {
|
|
111
|
+
let value: Value
|
|
112
|
+
init(_ value: Value) { self.value = value }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// MARK: - Products
|
|
116
|
+
|
|
117
|
+
/// A product the App Store sells. A products request in the browser finds
|
|
118
|
+
/// none, so the only instances are the ones code makes itself (tests and
|
|
119
|
+
/// previews subclass it and override the properties).
|
|
120
|
+
open class SKProduct: NSObject {
|
|
121
|
+
public enum PeriodUnit: UInt, Sendable, Hashable {
|
|
122
|
+
case day = 0, week = 1, month = 2, year = 3
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override public init() {}
|
|
126
|
+
|
|
127
|
+
open var localizedDescription: String { "" }
|
|
128
|
+
open var localizedTitle: String { "" }
|
|
129
|
+
open var price: NSDecimalNumber { .zero }
|
|
130
|
+
open var priceLocale: Locale { .current }
|
|
131
|
+
open var productIdentifier: String { "" }
|
|
132
|
+
open var isDownloadable: Bool { false }
|
|
133
|
+
open var downloadContentLengths: [NSNumber] { [] }
|
|
134
|
+
open var contentVersion: String { "" }
|
|
135
|
+
open var downloadContentVersion: String { "" }
|
|
136
|
+
open var isFamilyShareable: Bool { false }
|
|
137
|
+
open var subscriptionPeriod: SKProductSubscriptionPeriod? { nil }
|
|
138
|
+
open var introductoryPrice: SKProductDiscount? { nil }
|
|
139
|
+
open var subscriptionGroupIdentifier: String? { nil }
|
|
140
|
+
open var discounts: [SKProductDiscount] { [] }
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// How long a subscription period is.
|
|
144
|
+
open class SKProductSubscriptionPeriod: NSObject {
|
|
145
|
+
override public init() {}
|
|
146
|
+
open var numberOfUnits: Int { 0 }
|
|
147
|
+
open var unit: SKProduct.PeriodUnit { .day }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// An introductory or promotional price of a subscription.
|
|
151
|
+
open class SKProductDiscount: NSObject {
|
|
152
|
+
public enum PaymentMode: UInt, Sendable, Hashable {
|
|
153
|
+
case payAsYouGo = 0, payUpFront = 1, freeTrial = 2
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public enum `Type`: UInt, Sendable, Hashable {
|
|
157
|
+
case introductory = 0, subscription = 1
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
override public init() {}
|
|
161
|
+
|
|
162
|
+
open var price: NSDecimalNumber { .zero }
|
|
163
|
+
open var priceLocale: Locale { .current }
|
|
164
|
+
open var identifier: String? { nil }
|
|
165
|
+
open var subscriptionPeriod: SKProductSubscriptionPeriod { SKProductSubscriptionPeriod() }
|
|
166
|
+
open var numberOfPeriods: Int { 0 }
|
|
167
|
+
open var paymentMode: PaymentMode { .payAsYouGo }
|
|
168
|
+
open var type: `Type` { .introductory }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// The store's region.
|
|
172
|
+
open class SKStorefront: NSObject {
|
|
173
|
+
override public init() {}
|
|
174
|
+
open var countryCode: String { "" }
|
|
175
|
+
open var identifier: String { "" }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// MARK: - Requests
|
|
179
|
+
|
|
180
|
+
/// What a request tells its delegate. Both methods are optional.
|
|
181
|
+
public protocol SKRequestDelegate: NSObjectProtocol {
|
|
182
|
+
func requestDidFinish(_ request: SKRequest)
|
|
183
|
+
func request(_ request: SKRequest, didFailWithError error: any Error)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
extension SKRequestDelegate {
|
|
187
|
+
public func requestDidFinish(_ request: SKRequest) {}
|
|
188
|
+
public func request(_ request: SKRequest, didFailWithError error: any Error) {}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// A request to the App Store. `start()` answers on the main actor's next
|
|
192
|
+
/// turn; `cancel()` before then means the delegate hears nothing.
|
|
193
|
+
open class SKRequest: NSObject {
|
|
194
|
+
open weak var delegate: (any SKRequestDelegate)?
|
|
195
|
+
var cancelled = false
|
|
196
|
+
|
|
197
|
+
override public init() {}
|
|
198
|
+
|
|
199
|
+
open func start() {
|
|
200
|
+
cancelled = false
|
|
201
|
+
let request = _UncheckedBox(self)
|
|
202
|
+
_onMainActorLater {
|
|
203
|
+
guard !request.value.cancelled else { return }
|
|
204
|
+
request.value._answer()
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
open func cancel() { cancelled = true }
|
|
209
|
+
|
|
210
|
+
/// What the browser answers: subclasses say.
|
|
211
|
+
func _answer() { delegate?.requestDidFinish(self) }
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/// What a products request found: in the browser, no products, and every
|
|
215
|
+
/// identifier asked for among the invalid ones.
|
|
216
|
+
open class SKProductsResponse: NSObject {
|
|
217
|
+
public let products: [SKProduct]
|
|
218
|
+
public let invalidProductIdentifiers: [String]
|
|
219
|
+
|
|
220
|
+
public init(products: [SKProduct], invalidProductIdentifiers: [String]) {
|
|
221
|
+
self.products = products
|
|
222
|
+
self.invalidProductIdentifiers = invalidProductIdentifiers
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
override public convenience init() { self.init(products: [], invalidProductIdentifiers: []) }
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public protocol SKProductsRequestDelegate: SKRequestDelegate {
|
|
229
|
+
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/// Asks the App Store about products. The browser's store has none: the
|
|
233
|
+
/// delegate gets an empty response, then `requestDidFinish`.
|
|
234
|
+
open class SKProductsRequest: SKRequest {
|
|
235
|
+
let productIdentifiers: Set<String>
|
|
236
|
+
|
|
237
|
+
public init(productIdentifiers: Set<String>) {
|
|
238
|
+
self.productIdentifiers = productIdentifiers
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
override func _answer() {
|
|
242
|
+
let response = SKProductsResponse(products: [], invalidProductIdentifiers: productIdentifiers.sorted())
|
|
243
|
+
(delegate as? any SKProductsRequestDelegate)?.productsRequest(self, didReceive: response)
|
|
244
|
+
delegate?.requestDidFinish(self)
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public let SKReceiptPropertyIsExpired = "expired"
|
|
249
|
+
public let SKReceiptPropertyIsRevoked = "revoked"
|
|
250
|
+
public let SKReceiptPropertyIsVolumePurchase = "vpp"
|
|
251
|
+
|
|
252
|
+
/// Asks the App Store for a fresh receipt. There is no receipt in the
|
|
253
|
+
/// browser: the delegate gets `SKError.unsupportedPlatform`.
|
|
254
|
+
open class SKReceiptRefreshRequest: SKRequest {
|
|
255
|
+
public let receiptProperties: [String: Any]?
|
|
256
|
+
|
|
257
|
+
public init(receiptProperties properties: [String: Any]?) {
|
|
258
|
+
receiptProperties = properties
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
override public convenience init() { self.init(receiptProperties: nil) }
|
|
262
|
+
|
|
263
|
+
override func _answer() {
|
|
264
|
+
delegate?.request(self, didFailWithError: SKError(.unsupportedPlatform, userInfo: [NSLocalizedDescriptionKey: "The browser has no App Store receipt."]))
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// MARK: - Payments
|
|
269
|
+
|
|
270
|
+
/// A discount offer's signed parameters, attached to a payment.
|
|
271
|
+
open class SKPaymentDiscount: NSObject {
|
|
272
|
+
public let identifier: String
|
|
273
|
+
public let keyIdentifier: String
|
|
274
|
+
public let nonce: UUID
|
|
275
|
+
public let signature: String
|
|
276
|
+
public let timestamp: NSNumber
|
|
277
|
+
|
|
278
|
+
public init(identifier: String, keyIdentifier: String, nonce: UUID, signature: String, timestamp: NSNumber) {
|
|
279
|
+
self.identifier = identifier
|
|
280
|
+
self.keyIdentifier = keyIdentifier
|
|
281
|
+
self.nonce = nonce
|
|
282
|
+
self.signature = signature
|
|
283
|
+
self.timestamp = timestamp
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/// A request to buy a product.
|
|
288
|
+
open class SKPayment: NSObject {
|
|
289
|
+
var _productIdentifier: String
|
|
290
|
+
var _quantity = 1
|
|
291
|
+
var _requestData: Data?
|
|
292
|
+
var _applicationUsername: String?
|
|
293
|
+
var _simulatesAskToBuyInSandbox = false
|
|
294
|
+
var _paymentDiscount: SKPaymentDiscount?
|
|
295
|
+
|
|
296
|
+
public init(product: SKProduct) {
|
|
297
|
+
_productIdentifier = product.productIdentifier
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
init(productIdentifier: String) {
|
|
301
|
+
_productIdentifier = productIdentifier
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
open var productIdentifier: String { _productIdentifier }
|
|
305
|
+
open var quantity: Int { _quantity }
|
|
306
|
+
open var requestData: Data? { _requestData }
|
|
307
|
+
open var applicationUsername: String? { _applicationUsername }
|
|
308
|
+
open var simulatesAskToBuyInSandbox: Bool { _simulatesAskToBuyInSandbox }
|
|
309
|
+
open var paymentDiscount: SKPaymentDiscount? { _paymentDiscount }
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/// A payment whose details can be changed before it is added to the queue.
|
|
313
|
+
open class SKMutablePayment: SKPayment {
|
|
314
|
+
override public init(product: SKProduct) { super.init(product: product) }
|
|
315
|
+
|
|
316
|
+
override open var productIdentifier: String {
|
|
317
|
+
get { _productIdentifier }
|
|
318
|
+
set { _productIdentifier = newValue }
|
|
319
|
+
}
|
|
320
|
+
override open var quantity: Int {
|
|
321
|
+
get { _quantity }
|
|
322
|
+
set { _quantity = newValue }
|
|
323
|
+
}
|
|
324
|
+
override open var requestData: Data? {
|
|
325
|
+
get { _requestData }
|
|
326
|
+
set { _requestData = newValue }
|
|
327
|
+
}
|
|
328
|
+
override open var applicationUsername: String? {
|
|
329
|
+
get { _applicationUsername }
|
|
330
|
+
set { _applicationUsername = newValue }
|
|
331
|
+
}
|
|
332
|
+
override open var simulatesAskToBuyInSandbox: Bool {
|
|
333
|
+
get { _simulatesAskToBuyInSandbox }
|
|
334
|
+
set { _simulatesAskToBuyInSandbox = newValue }
|
|
335
|
+
}
|
|
336
|
+
override open var paymentDiscount: SKPaymentDiscount? {
|
|
337
|
+
get { _paymentDiscount }
|
|
338
|
+
set { _paymentDiscount = newValue }
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
public enum SKPaymentTransactionState: Int, Sendable, Hashable {
|
|
343
|
+
case purchasing = 0, purchased = 1, failed = 2, restored = 3, deferred = 4
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/// Content a purchase downloads from the App Store. Never any in the browser.
|
|
347
|
+
open class SKDownload: NSObject {
|
|
348
|
+
override public init() {}
|
|
349
|
+
open var contentIdentifier: String { "" }
|
|
350
|
+
open var contentURL: URL? { nil }
|
|
351
|
+
open var error: (any Error)? { nil }
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/// A payment in the queue. In the browser every one has failed.
|
|
355
|
+
open class SKPaymentTransaction: NSObject {
|
|
356
|
+
let _payment: SKPayment
|
|
357
|
+
let _state: SKPaymentTransactionState
|
|
358
|
+
let _error: (any Error)?
|
|
359
|
+
|
|
360
|
+
init(payment: SKPayment, state: SKPaymentTransactionState, error: (any Error)?) {
|
|
361
|
+
_payment = payment
|
|
362
|
+
_state = state
|
|
363
|
+
_error = error
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
open var payment: SKPayment { _payment }
|
|
367
|
+
open var transactionState: SKPaymentTransactionState { _state }
|
|
368
|
+
open var error: (any Error)? { _error }
|
|
369
|
+
open var original: SKPaymentTransaction? { nil }
|
|
370
|
+
open var transactionDate: Date? { nil }
|
|
371
|
+
open var transactionIdentifier: String? { nil }
|
|
372
|
+
open var transactionReceipt: Data? { nil }
|
|
373
|
+
open var downloads: [SKDownload] { [] }
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/// What the payment queue tells its observers. Only the first method is
|
|
377
|
+
/// required.
|
|
378
|
+
public protocol SKPaymentTransactionObserver: NSObjectProtocol {
|
|
379
|
+
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
|
|
380
|
+
func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction])
|
|
381
|
+
func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: any Error)
|
|
382
|
+
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue)
|
|
383
|
+
func paymentQueue(_ queue: SKPaymentQueue, updatedDownloads downloads: [SKDownload])
|
|
384
|
+
func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool
|
|
385
|
+
func paymentQueueDidChangeStorefront(_ queue: SKPaymentQueue)
|
|
386
|
+
func paymentQueue(_ queue: SKPaymentQueue, didRevokeEntitlementsForProductIdentifiers productIdentifiers: [String])
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
extension SKPaymentTransactionObserver {
|
|
390
|
+
public func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {}
|
|
391
|
+
public func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: any Error) {}
|
|
392
|
+
public func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {}
|
|
393
|
+
public func paymentQueue(_ queue: SKPaymentQueue, updatedDownloads downloads: [SKDownload]) {}
|
|
394
|
+
public func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool { true }
|
|
395
|
+
public func paymentQueueDidChangeStorefront(_ queue: SKPaymentQueue) {}
|
|
396
|
+
public func paymentQueue(_ queue: SKPaymentQueue, didRevokeEntitlementsForProductIdentifiers productIdentifiers: [String]) {}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/// What the payment queue asks its delegate. Both methods are optional.
|
|
400
|
+
public protocol SKPaymentQueueDelegate: NSObjectProtocol {
|
|
401
|
+
func paymentQueue(_ paymentQueue: SKPaymentQueue, shouldContinue transaction: SKPaymentTransaction, in newStorefront: SKStorefront) -> Bool
|
|
402
|
+
func paymentQueueShouldShowPriceConsent(_ paymentQueue: SKPaymentQueue) -> Bool
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
extension SKPaymentQueueDelegate {
|
|
406
|
+
public func paymentQueue(_ paymentQueue: SKPaymentQueue, shouldContinue transaction: SKPaymentTransaction, in newStorefront: SKStorefront) -> Bool { true }
|
|
407
|
+
public func paymentQueueShouldShowPriceConsent(_ paymentQueue: SKPaymentQueue) -> Bool { true }
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/// The queue of payments. In the browser nothing can be paid for: a
|
|
411
|
+
/// payment added to it becomes a failed transaction
|
|
412
|
+
/// (`SKError.paymentNotAllowed`) that observers hear about and that stays in
|
|
413
|
+
/// `transactions` until it is finished; restoring finishes at once with
|
|
414
|
+
/// nothing restored. The storefront is unknown (nil).
|
|
415
|
+
open class SKPaymentQueue: NSObject {
|
|
416
|
+
nonisolated(unsafe) static let shared = SKPaymentQueue()
|
|
417
|
+
|
|
418
|
+
open class func `default`() -> SKPaymentQueue { shared }
|
|
419
|
+
|
|
420
|
+
/// False: the browser has no App Store to pay through.
|
|
421
|
+
open class func canMakePayments() -> Bool { false }
|
|
422
|
+
|
|
423
|
+
open weak var delegate: (any SKPaymentQueueDelegate)?
|
|
424
|
+
open var storefront: SKStorefront? { nil }
|
|
425
|
+
open private(set) var transactions: [SKPaymentTransaction] = []
|
|
426
|
+
var observers: [any SKPaymentTransactionObserver] = []
|
|
427
|
+
|
|
428
|
+
override public init() {}
|
|
429
|
+
|
|
430
|
+
open var transactionObservers: [any SKPaymentTransactionObserver] { observers }
|
|
431
|
+
|
|
432
|
+
open func add(_ observer: any SKPaymentTransactionObserver) {
|
|
433
|
+
guard !observers.contains(where: { $0 === observer }) else { return }
|
|
434
|
+
observers.append(observer)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
open func remove(_ observer: any SKPaymentTransactionObserver) {
|
|
438
|
+
observers.removeAll { $0 === observer }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/// Fails the payment: the browser cannot charge for anything.
|
|
442
|
+
open func add(_ payment: SKPayment) {
|
|
443
|
+
let error = SKError(.paymentNotAllowed, userInfo: [NSLocalizedDescriptionKey: "Purchases are not available in the browser."])
|
|
444
|
+
let transaction = SKPaymentTransaction(payment: payment, state: .failed, error: error)
|
|
445
|
+
transactions.append(transaction)
|
|
446
|
+
let box = _UncheckedBox((queue: self, transaction: transaction))
|
|
447
|
+
_onMainActorLater {
|
|
448
|
+
let (queue, transaction) = box.value
|
|
449
|
+
for observer in queue.observers { observer.paymentQueue(queue, updatedTransactions: [transaction]) }
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/// Finds nothing to restore.
|
|
454
|
+
open func restoreCompletedTransactions() {
|
|
455
|
+
let queue = _UncheckedBox(self)
|
|
456
|
+
_onMainActorLater {
|
|
457
|
+
for observer in queue.value.observers { observer.paymentQueueRestoreCompletedTransactionsFinished(queue.value) }
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
open func restoreCompletedTransactions(withApplicationUsername username: String?) {
|
|
462
|
+
restoreCompletedTransactions()
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/// Removes the transaction from the queue and tells the observers.
|
|
466
|
+
open func finishTransaction(_ transaction: SKPaymentTransaction) {
|
|
467
|
+
guard let index = transactions.firstIndex(where: { $0 === transaction }) else { return }
|
|
468
|
+
transactions.remove(at: index)
|
|
469
|
+
let box = _UncheckedBox((queue: self, transaction: transaction))
|
|
470
|
+
_onMainActorLater {
|
|
471
|
+
let (queue, transaction) = box.value
|
|
472
|
+
for observer in queue.observers { observer.paymentQueue(queue, removedTransactions: [transaction]) }
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
open func start(_ downloads: [SKDownload]) {}
|
|
477
|
+
open func pause(_ downloads: [SKDownload]) {}
|
|
478
|
+
open func resume(_ downloads: [SKDownload]) {}
|
|
479
|
+
open func cancel(_ downloads: [SKDownload]) {}
|
|
480
|
+
|
|
481
|
+
/// A no-op: there are no price increases to consent to.
|
|
482
|
+
open func showPriceConsentIfNeeded() {}
|
|
483
|
+
|
|
484
|
+
/// A no-op: the browser has no sheet for redeeming offer codes.
|
|
485
|
+
open func presentCodeRedemptionSheet() {}
|
|
486
|
+
}
|