@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,572 @@
|
|
|
1
|
+
// `import Photos` for the browser. A web page has no photo library: it can
|
|
2
|
+
// neither read the viewer's photos nor add to them. What it can do is hand
|
|
3
|
+
// the viewer a file, and that is what saving does here:
|
|
4
|
+
//
|
|
5
|
+
// - Adding (`PHPhotoLibrary.performChanges` with a `PHAssetChangeRequest`
|
|
6
|
+
// or `PHAssetCreationRequest`, and UIKit's `UIImageWriteToSavedPhotosAlbum`)
|
|
7
|
+
// downloads each new photo or video through the page (a `download` host
|
|
8
|
+
// request; docs/ops-protocol.md, "Sharing and media"). So `.addOnly`
|
|
9
|
+
// access is `.authorized`, which is what apps check before saving.
|
|
10
|
+
// - Reading finds nothing: fetches return no assets, and image requests
|
|
11
|
+
// answer nil. `.readWrite` access is `.limited`, iOS's answer when the
|
|
12
|
+
// viewer shared only some photos, which here are none; photos reach the
|
|
13
|
+
// app through PhotosUI's `PhotosPicker` instead (the page's file chooser).
|
|
14
|
+
//
|
|
15
|
+
// Change observers are registered and never called; nothing else changes
|
|
16
|
+
// the library while the app runs.
|
|
17
|
+
|
|
18
|
+
@_exported import Foundation
|
|
19
|
+
import FoundationBridge
|
|
20
|
+
import SwiftUI
|
|
21
|
+
import UIKit
|
|
22
|
+
|
|
23
|
+
// MARK: - Authorization
|
|
24
|
+
|
|
25
|
+
public enum PHAccessLevel: Int, Sendable {
|
|
26
|
+
case addOnly = 1
|
|
27
|
+
case readWrite = 2
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public enum PHAuthorizationStatus: Int, Sendable {
|
|
31
|
+
case notDetermined = 0
|
|
32
|
+
case restricted = 1
|
|
33
|
+
case denied = 2
|
|
34
|
+
case authorized = 3
|
|
35
|
+
case limited = 4
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// MARK: - Errors
|
|
39
|
+
|
|
40
|
+
public let PHPhotosErrorDomain = "PHPhotosErrorDomain"
|
|
41
|
+
|
|
42
|
+
/// A photo library error, with Photos' codes.
|
|
43
|
+
public struct PHPhotosError: Error, Hashable, Sendable, CustomNSError {
|
|
44
|
+
public enum Code: Int, Sendable {
|
|
45
|
+
case internalError = -1
|
|
46
|
+
case userCancelled = 3072
|
|
47
|
+
case libraryVolumeOffline = 3114
|
|
48
|
+
case relinquishingLibraryBundleToWriter = 3142
|
|
49
|
+
case switchingSystemPhotoLibrary = 3143
|
|
50
|
+
case networkAccessRequired = 3164
|
|
51
|
+
case networkError = 3169
|
|
52
|
+
case identifierNotFound = 3201
|
|
53
|
+
case multipleIdentifiersFound = 3202
|
|
54
|
+
case changeNotSupported = 3300
|
|
55
|
+
case operationInterrupted = 3301
|
|
56
|
+
case invalidResource = 3302
|
|
57
|
+
case missingResource = 3303
|
|
58
|
+
case notEnoughSpace = 3305
|
|
59
|
+
case requestNotSupportedForAsset = 3306
|
|
60
|
+
case accessRestricted = 3310
|
|
61
|
+
case accessUserDenied = 3311
|
|
62
|
+
case libraryInFileProviderSyncRoot = 5423
|
|
63
|
+
case persistentChangeTokenExpired = 3105
|
|
64
|
+
case persistentChangeDetailsUnavailable = 3210
|
|
65
|
+
case invalid = -2
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public let code: Code
|
|
69
|
+
public init(_ code: Code) { self.code = code }
|
|
70
|
+
|
|
71
|
+
public static var errorDomain: String { PHPhotosErrorDomain }
|
|
72
|
+
public var errorCode: Int { code.rawValue }
|
|
73
|
+
public var errorUserInfo: [String: Any] { [:] }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// MARK: - The library
|
|
77
|
+
|
|
78
|
+
/// Told about changes to the library. Registered and never called.
|
|
79
|
+
public protocol PHPhotoLibraryChangeObserver: AnyObject {
|
|
80
|
+
func photoLibraryDidChange(_ changeInstance: PHChange)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/// A set of changes to the library. Never made in the browser.
|
|
84
|
+
public final class PHChange: @unchecked Sendable {
|
|
85
|
+
init() {}
|
|
86
|
+
public func changeDetails<T: PHObject>(for object: T) -> PHObjectChangeDetails<T>? { nil }
|
|
87
|
+
public func changeDetails<T: PHObject>(for fetchResult: PHFetchResult<T>) -> PHFetchResultChangeDetails<T>? { nil }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public final class PHObjectChangeDetails<ObjectType: PHObject>: @unchecked Sendable {
|
|
91
|
+
init() {}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public final class PHFetchResultChangeDetails<ObjectType: AnyObject>: @unchecked Sendable {
|
|
95
|
+
init() {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/// The photo library (see the top of the file): saving downloads, reading finds nothing.
|
|
99
|
+
public final class PHPhotoLibrary: @unchecked Sendable {
|
|
100
|
+
private static let library = PHPhotoLibrary()
|
|
101
|
+
public static func shared() -> PHPhotoLibrary { library }
|
|
102
|
+
|
|
103
|
+
init() {}
|
|
104
|
+
|
|
105
|
+
/// `.authorized` for `.addOnly` (saving downloads), `.limited` for
|
|
106
|
+
/// `.readWrite` (the library shows the app nothing).
|
|
107
|
+
public static func authorizationStatus(for accessLevel: PHAccessLevel) -> PHAuthorizationStatus {
|
|
108
|
+
accessLevel == .addOnly ? .authorized : .limited
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/// iOS 13's form, which reports `.authorized` for limited access.
|
|
112
|
+
@available(*, deprecated, renamed: "authorizationStatus(for:)")
|
|
113
|
+
public static func authorizationStatus() -> PHAuthorizationStatus { .authorized }
|
|
114
|
+
|
|
115
|
+
/// Answers at once: nothing asks the viewer.
|
|
116
|
+
public static func requestAuthorization(for accessLevel: PHAccessLevel) async -> PHAuthorizationStatus {
|
|
117
|
+
authorizationStatus(for: accessLevel)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public static func requestAuthorization(for accessLevel: PHAccessLevel,
|
|
121
|
+
handler: @escaping @Sendable (PHAuthorizationStatus) -> Void) {
|
|
122
|
+
handler(authorizationStatus(for: accessLevel))
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@available(*, deprecated, renamed: "requestAuthorization(for:handler:)")
|
|
126
|
+
public static func requestAuthorization(_ handler: @escaping @Sendable (PHAuthorizationStatus) -> Void) {
|
|
127
|
+
handler(.authorized)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// Runs `changeBlock` at once, then saves what it created (downloads);
|
|
131
|
+
/// `completionHandler` hears whether every save went through.
|
|
132
|
+
public func performChanges(_ changeBlock: @escaping () -> Void,
|
|
133
|
+
completionHandler: (@Sendable (Bool, (any Error)?) -> Void)? = nil) {
|
|
134
|
+
let saves = Self.collect(changeBlock)
|
|
135
|
+
let box = _PhotosBox(saves)
|
|
136
|
+
Task { @MainActor in
|
|
137
|
+
do {
|
|
138
|
+
try await Self.perform(box.value)
|
|
139
|
+
completionHandler?(true, nil)
|
|
140
|
+
} catch {
|
|
141
|
+
completionHandler?(false, error)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
nonisolated(nonsending) public func performChanges(_ changeBlock: @escaping () -> Void) async throws {
|
|
147
|
+
let saves = Self.collect(changeBlock)
|
|
148
|
+
let box = _PhotosBox(saves)
|
|
149
|
+
try await Task { @MainActor in try await Self.perform(box.value) }.value
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// Runs `changeBlock`; the downloads start without being waited for.
|
|
153
|
+
public func performChangesAndWait(_ changeBlock: () -> Void) throws {
|
|
154
|
+
let saves = withoutActuallyEscaping(changeBlock) { Self.collect($0) }
|
|
155
|
+
let box = _PhotosBox(saves)
|
|
156
|
+
Task { @MainActor in try? await Self.perform(box.value) }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public func register(_ observer: any PHPhotoLibraryChangeObserver) {}
|
|
160
|
+
public func unregisterChangeObserver(_ observer: any PHPhotoLibraryChangeObserver) {}
|
|
161
|
+
|
|
162
|
+
/// Nothing to show: the page has no library picker (PhotosUI's
|
|
163
|
+
/// `PhotosPicker` opens the file chooser).
|
|
164
|
+
@MainActor public func presentLimitedLibraryPicker(from controller: UIViewController) {}
|
|
165
|
+
@MainActor public func presentLimitedLibraryPicker(from controller: UIViewController) async -> [String] { [] }
|
|
166
|
+
|
|
167
|
+
public var unavailabilityReason: (any Error)? { nil }
|
|
168
|
+
|
|
169
|
+
// MARK: Changes
|
|
170
|
+
|
|
171
|
+
/// The change requests made while a change block runs.
|
|
172
|
+
nonisolated(unsafe) static var pending: [PHAssetChangeRequest]?
|
|
173
|
+
|
|
174
|
+
private static func collect(_ changeBlock: () -> Void) -> [PHAssetChangeRequest] {
|
|
175
|
+
let outer = pending
|
|
176
|
+
pending = []
|
|
177
|
+
changeBlock()
|
|
178
|
+
let made = pending ?? []
|
|
179
|
+
pending = outer
|
|
180
|
+
return made
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/// Saves what the requests created, as downloads (the other changes, to
|
|
184
|
+
/// assets the library does not have, do nothing).
|
|
185
|
+
@MainActor
|
|
186
|
+
private static func perform(_ requests: [PHAssetChangeRequest]) async throws {
|
|
187
|
+
for request in requests {
|
|
188
|
+
guard let (fields, title) = try request.download() else { continue }
|
|
189
|
+
try await _PageFiles.download(fields, title: title)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private struct _PhotosBox<Value>: @unchecked Sendable {
|
|
195
|
+
let value: Value
|
|
196
|
+
init(_ value: Value) { self.value = value }
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// MARK: - Objects and fetches
|
|
200
|
+
|
|
201
|
+
/// A library object.
|
|
202
|
+
open class PHObject: Hashable, @unchecked Sendable {
|
|
203
|
+
public let localIdentifier: String
|
|
204
|
+
|
|
205
|
+
init(localIdentifier: String) { self.localIdentifier = localIdentifier }
|
|
206
|
+
|
|
207
|
+
public static func == (lhs: PHObject, rhs: PHObject) -> Bool { lhs.localIdentifier == rhs.localIdentifier }
|
|
208
|
+
public func hash(into hasher: inout Hasher) { hasher.combine(localIdentifier) }
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/// Stands for an asset a change block created, by identifier.
|
|
212
|
+
public final class PHObjectPlaceholder: PHObject, @unchecked Sendable {}
|
|
213
|
+
|
|
214
|
+
public enum PHAssetMediaType: Int, Sendable {
|
|
215
|
+
case unknown = 0, image = 1, video = 2, audio = 3
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public struct PHAssetMediaSubtype: OptionSet, Hashable, Sendable {
|
|
219
|
+
public let rawValue: UInt
|
|
220
|
+
public init(rawValue: UInt) { self.rawValue = rawValue }
|
|
221
|
+
public static let photoPanorama = PHAssetMediaSubtype(rawValue: 1 << 0)
|
|
222
|
+
public static let photoHDR = PHAssetMediaSubtype(rawValue: 1 << 1)
|
|
223
|
+
public static let photoScreenshot = PHAssetMediaSubtype(rawValue: 1 << 2)
|
|
224
|
+
public static let photoLive = PHAssetMediaSubtype(rawValue: 1 << 3)
|
|
225
|
+
public static let photoDepthEffect = PHAssetMediaSubtype(rawValue: 1 << 4)
|
|
226
|
+
public static let spatialMedia = PHAssetMediaSubtype(rawValue: 1 << 10)
|
|
227
|
+
public static let videoStreamed = PHAssetMediaSubtype(rawValue: 1 << 16)
|
|
228
|
+
public static let videoHighFrameRate = PHAssetMediaSubtype(rawValue: 1 << 17)
|
|
229
|
+
public static let videoTimelapse = PHAssetMediaSubtype(rawValue: 1 << 18)
|
|
230
|
+
public static let videoCinematic = PHAssetMediaSubtype(rawValue: 1 << 21)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
public struct PHAssetSourceType: OptionSet, Hashable, Sendable {
|
|
234
|
+
public let rawValue: UInt
|
|
235
|
+
public init(rawValue: UInt) { self.rawValue = rawValue }
|
|
236
|
+
public static let typeUserLibrary = PHAssetSourceType(rawValue: 1 << 0)
|
|
237
|
+
public static let typeCloudShared = PHAssetSourceType(rawValue: 1 << 1)
|
|
238
|
+
public static let typeiTunesSynced = PHAssetSourceType(rawValue: 1 << 2)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
public enum PHAssetPlaybackStyle: Int, Sendable {
|
|
242
|
+
case unsupported = 0, image, imageAnimated, livePhoto, video, videoLooping
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/// A photo or video in the library. The browser's library has none, so no
|
|
246
|
+
/// fetch returns one.
|
|
247
|
+
public final class PHAsset: PHObject, @unchecked Sendable {
|
|
248
|
+
public let mediaType: PHAssetMediaType
|
|
249
|
+
public let mediaSubtypes: PHAssetMediaSubtype
|
|
250
|
+
public let pixelWidth: Int
|
|
251
|
+
public let pixelHeight: Int
|
|
252
|
+
public let creationDate: Date?
|
|
253
|
+
public let modificationDate: Date?
|
|
254
|
+
public let duration: TimeInterval
|
|
255
|
+
public let isFavorite: Bool
|
|
256
|
+
public let isHidden: Bool
|
|
257
|
+
public let sourceType: PHAssetSourceType
|
|
258
|
+
public let playbackStyle: PHAssetPlaybackStyle
|
|
259
|
+
public let location: AnyObject?
|
|
260
|
+
public let burstIdentifier: String?
|
|
261
|
+
|
|
262
|
+
init(localIdentifier: String, mediaType: PHAssetMediaType) {
|
|
263
|
+
self.mediaType = mediaType
|
|
264
|
+
mediaSubtypes = []
|
|
265
|
+
pixelWidth = 0
|
|
266
|
+
pixelHeight = 0
|
|
267
|
+
creationDate = nil
|
|
268
|
+
modificationDate = nil
|
|
269
|
+
duration = 0
|
|
270
|
+
isFavorite = false
|
|
271
|
+
isHidden = false
|
|
272
|
+
sourceType = .typeUserLibrary
|
|
273
|
+
playbackStyle = mediaType == .video ? .video : .image
|
|
274
|
+
location = nil
|
|
275
|
+
burstIdentifier = nil
|
|
276
|
+
super.init(localIdentifier: localIdentifier)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public static func fetchAssets(with mediaType: PHAssetMediaType, options: PHFetchOptions?) -> PHFetchResult<PHAsset> { PHFetchResult() }
|
|
280
|
+
public static func fetchAssets(with options: PHFetchOptions?) -> PHFetchResult<PHAsset> { PHFetchResult() }
|
|
281
|
+
public static func fetchAssets(withLocalIdentifiers identifiers: [String], options: PHFetchOptions?) -> PHFetchResult<PHAsset> { PHFetchResult() }
|
|
282
|
+
public static func fetchAssets(in assetCollection: PHAssetCollection, options: PHFetchOptions?) -> PHFetchResult<PHAsset> { PHFetchResult() }
|
|
283
|
+
public static func fetchKeyAssets(in assetCollection: PHAssetCollection, options: PHFetchOptions?) -> PHFetchResult<PHAsset>? { nil }
|
|
284
|
+
|
|
285
|
+
public func canPerform(_ editOperation: PHAssetEditOperation) -> Bool { false }
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
public enum PHAssetEditOperation: Int, Sendable {
|
|
289
|
+
case delete = 1, content = 2, properties = 3
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/// An album. The browser's library has none.
|
|
293
|
+
public final class PHAssetCollection: PHObject, @unchecked Sendable {
|
|
294
|
+
public let localizedTitle: String? = nil
|
|
295
|
+
|
|
296
|
+
public static func fetchAssetCollections(with type: PHAssetCollectionType, subtype: PHAssetCollectionSubtype,
|
|
297
|
+
options: PHFetchOptions?) -> PHFetchResult<PHAssetCollection> { PHFetchResult() }
|
|
298
|
+
public static func fetchAssetCollections(withLocalIdentifiers identifiers: [String],
|
|
299
|
+
options: PHFetchOptions?) -> PHFetchResult<PHAssetCollection> { PHFetchResult() }
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public enum PHAssetCollectionType: Int, Sendable {
|
|
303
|
+
case album = 1, smartAlbum = 2, moment = 3
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public enum PHAssetCollectionSubtype: Int, Sendable {
|
|
307
|
+
case albumRegular = 2, albumSyncedEvent = 3, albumSyncedFaces = 4, albumSyncedAlbum = 5, albumImported = 6
|
|
308
|
+
case albumMyPhotoStream = 100, albumCloudShared = 101
|
|
309
|
+
case smartAlbumGeneric = 200, smartAlbumPanoramas = 201, smartAlbumVideos = 202, smartAlbumFavorites = 203
|
|
310
|
+
case smartAlbumTimelapses = 204, smartAlbumAllHidden = 205, smartAlbumRecentlyAdded = 206, smartAlbumBursts = 207
|
|
311
|
+
case smartAlbumSlomoVideos = 208, smartAlbumUserLibrary = 209, smartAlbumSelfPortraits = 210, smartAlbumScreenshots = 211
|
|
312
|
+
case smartAlbumDepthEffect = 212, smartAlbumLivePhotos = 213, smartAlbumAnimated = 214, smartAlbumLongExposures = 215
|
|
313
|
+
case smartAlbumUnableToUpload = 216, smartAlbumRAW = 217, smartAlbumCinematic = 218, smartAlbumSpatial = 219
|
|
314
|
+
#if _pointerBitWidth(_64)
|
|
315
|
+
case any = 9_223_372_036_854_775_807
|
|
316
|
+
#else
|
|
317
|
+
case any = 2_147_483_647
|
|
318
|
+
#endif
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/// How a fetch filters and orders. Kept: fetches return nothing.
|
|
322
|
+
public final class PHFetchOptions: @unchecked Sendable {
|
|
323
|
+
public var predicate: NSPredicate?
|
|
324
|
+
public var sortDescriptors: [NSSortDescriptor]?
|
|
325
|
+
public var includeHiddenAssets = false
|
|
326
|
+
public var includeAllBurstAssets = false
|
|
327
|
+
public var includeAssetSourceTypes: PHAssetSourceType = []
|
|
328
|
+
public var fetchLimit = 0
|
|
329
|
+
public var wantsIncrementalChangeDetails = true
|
|
330
|
+
|
|
331
|
+
public init() {}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
extension NSSortDescriptor {
|
|
335
|
+
/// A descriptor by key, as `PHFetchOptions.sortDescriptors` takes them
|
|
336
|
+
/// (`creationDate`…). Corelibs Foundation has no key-value coding, so its
|
|
337
|
+
/// own initializer is unavailable; this one, visible where Photos is
|
|
338
|
+
/// imported, compiles the fetch options. The descriptor does not sort by
|
|
339
|
+
/// `key` (nothing reads it: fetches return nothing).
|
|
340
|
+
public convenience init(key: String?, ascending: Bool) {
|
|
341
|
+
self.init(keyPath: \NSObject.hash, ascending: ascending)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/// The objects a fetch found: none, in the browser.
|
|
346
|
+
public final class PHFetchResult<ObjectType: AnyObject>: @unchecked Sendable, RandomAccessCollection {
|
|
347
|
+
private let objects: [ObjectType]
|
|
348
|
+
|
|
349
|
+
init(_ objects: [ObjectType] = []) { self.objects = objects }
|
|
350
|
+
|
|
351
|
+
public var count: Int { objects.count }
|
|
352
|
+
public var firstObject: ObjectType? { objects.first }
|
|
353
|
+
public var lastObject: ObjectType? { objects.last }
|
|
354
|
+
public func object(at index: Int) -> ObjectType { objects[index] }
|
|
355
|
+
public func objects(at indexes: IndexSet) -> [ObjectType] { indexes.map { objects[$0] } }
|
|
356
|
+
public func contains(_ anObject: ObjectType) -> Bool { objects.contains { $0 === anObject } }
|
|
357
|
+
public func index(of anObject: ObjectType) -> Int { objects.firstIndex { $0 === anObject } ?? NSNotFound }
|
|
358
|
+
public func countOfAssets(with mediaType: PHAssetMediaType) -> Int { 0 }
|
|
359
|
+
|
|
360
|
+
public func enumerateObjects(_ block: (ObjectType, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
|
|
361
|
+
var stop = ObjCBool(false)
|
|
362
|
+
for (index, object) in objects.enumerated() {
|
|
363
|
+
block(object, index, &stop)
|
|
364
|
+
if stop.boolValue { return }
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
public var startIndex: Int { objects.startIndex }
|
|
369
|
+
public var endIndex: Int { objects.endIndex }
|
|
370
|
+
public subscript(index: Int) -> ObjectType { objects[index] }
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// MARK: - Change requests
|
|
374
|
+
|
|
375
|
+
/// Creates, edits or deletes an asset inside `performChanges`. Creating
|
|
376
|
+
/// one downloads its photo or video (see the top of the file); edits and
|
|
377
|
+
/// deletions find no asset to change.
|
|
378
|
+
open class PHAssetChangeRequest: @unchecked Sendable {
|
|
379
|
+
/// What a request creates an asset from.
|
|
380
|
+
public struct _Source: @unchecked Sendable {
|
|
381
|
+
enum Kind {
|
|
382
|
+
case image(UIImage)
|
|
383
|
+
case file(URL)
|
|
384
|
+
case resources([(PHAssetResourceType, Data?, URL?, PHAssetResourceCreationOptions?)])
|
|
385
|
+
case none
|
|
386
|
+
}
|
|
387
|
+
var kind: Kind
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
var source: _Source.Kind
|
|
391
|
+
public private(set) var placeholderForCreatedAsset: PHObjectPlaceholder?
|
|
392
|
+
open var creationDate: Date?
|
|
393
|
+
open var isFavorite = false
|
|
394
|
+
open var isHidden = false
|
|
395
|
+
open var location: AnyObject?
|
|
396
|
+
open var contentEditingOutput: AnyObject?
|
|
397
|
+
|
|
398
|
+
/// Made by the class methods; joins the change block that is running.
|
|
399
|
+
public required init(_source: _Source) {
|
|
400
|
+
source = _source.kind
|
|
401
|
+
if case .none = source {} else {
|
|
402
|
+
placeholderForCreatedAsset = PHObjectPlaceholder(localIdentifier: "\(UUID().uuidString)/L0/001")
|
|
403
|
+
}
|
|
404
|
+
PHPhotoLibrary.pending?.append(self)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/// Edits an asset: the browser's library has none to edit.
|
|
408
|
+
public convenience init(for asset: PHAsset) { self.init(_source: _Source(kind: .none)) }
|
|
409
|
+
|
|
410
|
+
open class func creationRequestForAsset(from image: UIImage) -> Self {
|
|
411
|
+
Self(_source: _Source(kind: .image(image)))
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
open class func creationRequestForAssetFromImage(atFileURL fileURL: URL) -> Self? {
|
|
415
|
+
FileManager.default.fileExists(atPath: fileURL.path) ? Self(_source: _Source(kind: .file(fileURL))) : nil
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
open class func creationRequestForAssetFromVideo(atFileURL fileURL: URL) -> Self? {
|
|
419
|
+
FileManager.default.fileExists(atPath: fileURL.path) ? Self(_source: _Source(kind: .file(fileURL))) : nil
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
open class func deleteAssets(_ assets: any Sequence) {}
|
|
423
|
+
|
|
424
|
+
/// The `download` request fields that save what this request created; nil when it created nothing.
|
|
425
|
+
@MainActor
|
|
426
|
+
func download() throws -> ([String: _JSON], String)? {
|
|
427
|
+
switch source {
|
|
428
|
+
case .none:
|
|
429
|
+
return nil
|
|
430
|
+
case .image(let image):
|
|
431
|
+
return (_PageFiles.fields(for: image, name: "Photo"), "Photo")
|
|
432
|
+
case .file(let url):
|
|
433
|
+
return (["files": .array([try _PageFiles.entry(fileURL: url)])], url.deletingPathExtension().lastPathComponent)
|
|
434
|
+
case .resources(let resources):
|
|
435
|
+
var files: [_JSON] = []
|
|
436
|
+
for (type, data, url, options) in resources {
|
|
437
|
+
if let url {
|
|
438
|
+
files.append(try _PageFiles.entry(fileURL: url))
|
|
439
|
+
} else if let data {
|
|
440
|
+
let uti = options?.uniformTypeIdentifier.flatMap { UTType($0) }
|
|
441
|
+
let fallback: UTType = type == .video || type == .pairedVideo ? .movie : .image
|
|
442
|
+
let sniffed = UIImage(data: data)?._encodedFile.flatMap { UTType(mimeType: $0.mime) }
|
|
443
|
+
let contentType = uti ?? sniffed ?? fallback
|
|
444
|
+
let name = options?.originalFilename
|
|
445
|
+
?? "Photo.\(contentType.preferredFilenameExtension ?? (fallback == .movie ? "mov" : "jpeg"))"
|
|
446
|
+
files.append(_PageFiles.entry(name: name, type: contentType.preferredMIMEType ?? "application/octet-stream", data: data))
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return files.isEmpty ? nil : (["files": .array(files)], "Photo")
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/// Creates an asset from its resources (photo and video files, or data).
|
|
455
|
+
open class PHAssetCreationRequest: PHAssetChangeRequest, @unchecked Sendable {
|
|
456
|
+
open class func forAsset() -> Self { Self(_source: _Source(kind: .resources([]))) }
|
|
457
|
+
|
|
458
|
+
open class func supportsAssetResourceTypes(_ types: [NSNumber]) -> Bool { true }
|
|
459
|
+
|
|
460
|
+
open func addResource(with type: PHAssetResourceType, fileURL: URL, options: PHAssetResourceCreationOptions?) {
|
|
461
|
+
guard case .resources(let resources) = source else { return }
|
|
462
|
+
source = .resources(resources + [(type, nil, fileURL, options)])
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
open func addResource(with type: PHAssetResourceType, data: Data, options: PHAssetResourceCreationOptions?) {
|
|
466
|
+
guard case .resources(let resources) = source else { return }
|
|
467
|
+
source = .resources(resources + [(type, data, nil, options)])
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
public enum PHAssetResourceType: Int, Sendable {
|
|
472
|
+
case photo = 1, video = 2, audio = 3, alternatePhoto = 4, fullSizePhoto = 5, fullSizeVideo = 6, adjustmentData = 7
|
|
473
|
+
case adjustmentBasePhoto = 8, pairedVideo = 9, fullSizePairedVideo = 10, adjustmentBasePairedVideo = 11
|
|
474
|
+
case adjustmentBaseVideo = 12, photoProxy = 19
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
public final class PHAssetResourceCreationOptions: @unchecked Sendable {
|
|
478
|
+
public var originalFilename: String?
|
|
479
|
+
public var uniformTypeIdentifier: String?
|
|
480
|
+
public var shouldMoveFile = false
|
|
481
|
+
public init() {}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// MARK: - Image requests
|
|
485
|
+
|
|
486
|
+
public typealias PHImageRequestID = Int32
|
|
487
|
+
public let PHInvalidImageRequestID: PHImageRequestID = 0
|
|
488
|
+
public let PHImageManagerMaximumSize = CGSize(width: -1, height: -1)
|
|
489
|
+
|
|
490
|
+
public let PHImageResultIsInCloudKey = "PHImageResultIsInCloudKey"
|
|
491
|
+
public let PHImageResultIsDegradedKey = "PHImageResultIsDegradedKey"
|
|
492
|
+
public let PHImageCancelledKey = "PHImageCancelledKey"
|
|
493
|
+
public let PHImageErrorKey = "PHImageErrorKey"
|
|
494
|
+
public let PHImageResultRequestIDKey = "PHImageResultRequestIDKey"
|
|
495
|
+
|
|
496
|
+
public enum PHImageContentMode: Int, Sendable {
|
|
497
|
+
case aspectFit = 0, aspectFill = 1
|
|
498
|
+
public static let `default` = PHImageContentMode.aspectFit
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
public enum PHImageRequestOptionsVersion: Int, Sendable { case current = 0, unadjusted = 1, original = 2 }
|
|
502
|
+
public enum PHImageRequestOptionsDeliveryMode: Int, Sendable { case opportunistic = 0, highQualityFormat = 1, fastFormat = 2 }
|
|
503
|
+
public enum PHImageRequestOptionsResizeMode: Int, Sendable { case none = 0, fast = 1, exact = 2 }
|
|
504
|
+
|
|
505
|
+
/// How an image request should deliver. Kept: requests find nothing.
|
|
506
|
+
public final class PHImageRequestOptions: @unchecked Sendable {
|
|
507
|
+
public var version = PHImageRequestOptionsVersion.current
|
|
508
|
+
public var deliveryMode = PHImageRequestOptionsDeliveryMode.opportunistic
|
|
509
|
+
public var resizeMode = PHImageRequestOptionsResizeMode.fast
|
|
510
|
+
public var normalizedCropRect = CGRect.zero
|
|
511
|
+
public var isNetworkAccessAllowed = false
|
|
512
|
+
public var isSynchronous = false
|
|
513
|
+
public var allowSecondaryDegradedImage = false
|
|
514
|
+
public var progressHandler: ((Double, (any Error)?, UnsafeMutablePointer<ObjCBool>, [AnyHashable: Any]?) -> Void)?
|
|
515
|
+
public init() {}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/// Loads assets' images. The browser's library has no assets, so every
|
|
519
|
+
/// request answers at once with nil and an error under `PHImageErrorKey`.
|
|
520
|
+
open class PHImageManager: @unchecked Sendable {
|
|
521
|
+
private static let shared = PHImageManager()
|
|
522
|
+
open class func `default`() -> PHImageManager { shared }
|
|
523
|
+
|
|
524
|
+
private var nextID: PHImageRequestID = 1
|
|
525
|
+
|
|
526
|
+
public init() {}
|
|
527
|
+
|
|
528
|
+
private func failure(_ id: PHImageRequestID) -> [AnyHashable: Any] {
|
|
529
|
+
[PHImageErrorKey: PHPhotosError(.identifierNotFound), PHImageResultIsDegradedKey: false, PHImageResultRequestIDKey: id]
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
private func newID() -> PHImageRequestID {
|
|
533
|
+
defer { nextID += 1 }
|
|
534
|
+
return nextID
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
@discardableResult
|
|
538
|
+
open func requestImage(for asset: PHAsset, targetSize: CGSize, contentMode: PHImageContentMode, options: PHImageRequestOptions?,
|
|
539
|
+
resultHandler: @escaping (UIImage?, [AnyHashable: Any]?) -> Void) -> PHImageRequestID {
|
|
540
|
+
let id = newID()
|
|
541
|
+
resultHandler(nil, failure(id))
|
|
542
|
+
return id
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
@discardableResult
|
|
546
|
+
open func requestImageDataAndOrientation(for asset: PHAsset, options: PHImageRequestOptions?,
|
|
547
|
+
resultHandler: @escaping (Data?, String?, CGImagePropertyOrientation, [AnyHashable: Any]?) -> Void)
|
|
548
|
+
-> PHImageRequestID {
|
|
549
|
+
let id = newID()
|
|
550
|
+
resultHandler(nil, nil, .up, failure(id))
|
|
551
|
+
return id
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
@available(*, deprecated, renamed: "requestImageDataAndOrientation(for:options:resultHandler:)")
|
|
555
|
+
@discardableResult
|
|
556
|
+
open func requestImageData(for asset: PHAsset, options: PHImageRequestOptions?,
|
|
557
|
+
resultHandler: @escaping (Data?, String?, UIImage.Orientation, [AnyHashable: Any]?) -> Void) -> PHImageRequestID {
|
|
558
|
+
let id = newID()
|
|
559
|
+
resultHandler(nil, nil, .up, failure(id))
|
|
560
|
+
return id
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
open func cancelImageRequest(_ requestID: PHImageRequestID) {}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/// An image manager that caches ahead. Nothing to cache in the browser.
|
|
567
|
+
open class PHCachingImageManager: PHImageManager, @unchecked Sendable {
|
|
568
|
+
open var allowsCachingHighQualityImages = true
|
|
569
|
+
open func startCachingImages(for assets: [PHAsset], targetSize: CGSize, contentMode: PHImageContentMode, options: PHImageRequestOptions?) {}
|
|
570
|
+
open func stopCachingImages(for assets: [PHAsset], targetSize: CGSize, contentMode: PHImageContentMode, options: PHImageRequestOptions?) {}
|
|
571
|
+
open func stopCachingImagesForAllAssets() {}
|
|
572
|
+
}
|