@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,285 @@
|
|
|
1
|
+
/// How a change is animated. Encoded for the renderer as documented in
|
|
2
|
+
/// docs/ops-protocol.md (Phase 3).
|
|
3
|
+
public struct Animation: Equatable, Sendable {
|
|
4
|
+
enum Kind: String, Sendable {
|
|
5
|
+
case `default`, linear, easeIn, easeOut, easeInOut, spring
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var kind: Kind
|
|
9
|
+
var duration: Double
|
|
10
|
+
var bounce: Double
|
|
11
|
+
var delayBy: Double
|
|
12
|
+
/// `.repeatCount` / `.repeatForever`: `count` nil with `forever` false means once.
|
|
13
|
+
var repeatCount: Int?
|
|
14
|
+
var repeatForever = false
|
|
15
|
+
var autoreverses = true
|
|
16
|
+
|
|
17
|
+
init(kind: Kind, duration: Double = 0.35, bounce: Double = 0, delay: Double = 0) {
|
|
18
|
+
self.kind = kind
|
|
19
|
+
self.duration = duration
|
|
20
|
+
self.bounce = bounce
|
|
21
|
+
self.delayBy = delay
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static let `default` = Animation(kind: .default)
|
|
25
|
+
public static let linear = Animation(kind: .linear)
|
|
26
|
+
public static let easeIn = Animation(kind: .easeIn)
|
|
27
|
+
public static let easeOut = Animation(kind: .easeOut)
|
|
28
|
+
public static let easeInOut = Animation(kind: .easeInOut)
|
|
29
|
+
public static let spring = Animation(kind: .spring, duration: 0.5, bounce: 0)
|
|
30
|
+
public static let bouncy = Animation(kind: .spring, duration: 0.5, bounce: 0.3)
|
|
31
|
+
public static let smooth = Animation(kind: .spring, duration: 0.5, bounce: 0)
|
|
32
|
+
public static let snappy = Animation(kind: .spring, duration: 0.5, bounce: 0.15)
|
|
33
|
+
|
|
34
|
+
public static func linear(duration: Double) -> Animation { Animation(kind: .linear, duration: duration) }
|
|
35
|
+
public static func easeIn(duration: Double) -> Animation { Animation(kind: .easeIn, duration: duration) }
|
|
36
|
+
public static func easeOut(duration: Double) -> Animation { Animation(kind: .easeOut, duration: duration) }
|
|
37
|
+
public static func easeInOut(duration: Double) -> Animation { Animation(kind: .easeInOut, duration: duration) }
|
|
38
|
+
public static func spring(duration: Double = 0.5, bounce: Double = 0) -> Animation {
|
|
39
|
+
Animation(kind: .spring, duration: duration, bounce: bounce)
|
|
40
|
+
}
|
|
41
|
+
/// The pre-iOS 17 spring: `response` is the duration, the damping fraction
|
|
42
|
+
/// maps onto bounce (`1` is a smooth spring, lower values overshoot).
|
|
43
|
+
public static func spring(response: Double = 0.5, dampingFraction: Double = 0.825,
|
|
44
|
+
blendDuration: Double = 0) -> Animation {
|
|
45
|
+
Animation(kind: .spring, duration: response, bounce: max(0, min(1, 1 - dampingFraction)))
|
|
46
|
+
}
|
|
47
|
+
public static func interactiveSpring(response: Double = 0.15, dampingFraction: Double = 0.86,
|
|
48
|
+
blendDuration: Double = 0.25) -> Animation {
|
|
49
|
+
spring(response: response, dampingFraction: dampingFraction, blendDuration: blendDuration)
|
|
50
|
+
}
|
|
51
|
+
public static func bouncy(duration: Double = 0.5, extraBounce: Double = 0) -> Animation {
|
|
52
|
+
Animation(kind: .spring, duration: duration, bounce: 0.3 + extraBounce)
|
|
53
|
+
}
|
|
54
|
+
public static func smooth(duration: Double = 0.5, extraBounce: Double = 0) -> Animation {
|
|
55
|
+
Animation(kind: .spring, duration: duration, bounce: extraBounce)
|
|
56
|
+
}
|
|
57
|
+
public static func snappy(duration: Double = 0.5, extraBounce: Double = 0) -> Animation {
|
|
58
|
+
Animation(kind: .spring, duration: duration, bounce: 0.15 + extraBounce)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public func delay(_ delay: Double) -> Animation {
|
|
62
|
+
var copy = self
|
|
63
|
+
copy.delayBy = delay
|
|
64
|
+
return copy
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public func speed(_ speed: Double) -> Animation {
|
|
68
|
+
var copy = self
|
|
69
|
+
copy.duration = speed > 0 ? duration / speed : duration
|
|
70
|
+
return copy
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Repeats the animation `repeatCount` times, reversing on alternate runs
|
|
74
|
+
/// when `autoreverses`.
|
|
75
|
+
public func repeatCount(_ repeatCount: Int, autoreverses: Bool = true) -> Animation {
|
|
76
|
+
var copy = self
|
|
77
|
+
copy.repeatCount = repeatCount
|
|
78
|
+
copy.repeatForever = false
|
|
79
|
+
copy.autoreverses = autoreverses
|
|
80
|
+
return copy
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public func repeatForever(autoreverses: Bool = true) -> Animation {
|
|
84
|
+
var copy = self
|
|
85
|
+
copy.repeatCount = nil
|
|
86
|
+
copy.repeatForever = true
|
|
87
|
+
copy.autoreverses = autoreverses
|
|
88
|
+
return copy
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var _json: _JSON {
|
|
92
|
+
var object: [String: _JSON] = ["type": .string(kind.rawValue), "duration": .number(duration)]
|
|
93
|
+
if bounce != 0 { object["bounce"] = .number(bounce) }
|
|
94
|
+
if delayBy != 0 { object["delay"] = .number(delayBy) }
|
|
95
|
+
if repeatForever || repeatCount != nil {
|
|
96
|
+
object["repeat"] = .object([
|
|
97
|
+
"count": repeatForever ? .string("forever") : .number(Double(repeatCount ?? 1)),
|
|
98
|
+
"autoreverses": .bool(autoreverses),
|
|
99
|
+
])
|
|
100
|
+
}
|
|
101
|
+
return .object(object)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
extension Binding {
|
|
106
|
+
/// A binding whose writes animate the view changes they cause.
|
|
107
|
+
public func animation(_ animation: Animation? = .default) -> Binding<Value> {
|
|
108
|
+
let setter = self.setter
|
|
109
|
+
return Binding(get: getter) { value in
|
|
110
|
+
// Bindings are written from the main actor (event handlers, bodies).
|
|
111
|
+
let outer = MainActor.assumeIsolated { _Runtime.shared.beginTransaction(animation) }
|
|
112
|
+
setter(value)
|
|
113
|
+
MainActor.assumeIsolated { _Runtime.shared.endTransaction(outer) }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// Runs `body` and animates the view changes it causes.
|
|
119
|
+
@MainActor
|
|
120
|
+
public func withAnimation<Result>(_ animation: Animation? = .default,
|
|
121
|
+
_ body: () throws -> Result) rethrows -> Result {
|
|
122
|
+
try _Runtime.shared.runInTransaction(animation, body)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/// Runs `body` in `transaction`: its animation (none when it disables
|
|
126
|
+
/// animations) animates the view changes `body` causes.
|
|
127
|
+
@MainActor
|
|
128
|
+
public func withTransaction<Result>(_ transaction: Transaction, _ body: () throws -> Result) rethrows -> Result {
|
|
129
|
+
try _Runtime.shared.runInTransaction(transaction.disablesAnimations ? nil : transaction.animation, body)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/// `withTransaction` with one property of a fresh transaction set.
|
|
133
|
+
@MainActor
|
|
134
|
+
public func withTransaction<Result, Value>(_ keyPath: WritableKeyPath<Transaction, Value>, _ value: Value,
|
|
135
|
+
_ body: () throws -> Result) rethrows -> Result {
|
|
136
|
+
var transaction = Transaction()
|
|
137
|
+
transaction[keyPath: keyPath] = value
|
|
138
|
+
return try withTransaction(transaction, body)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// MARK: - Transitions
|
|
142
|
+
|
|
143
|
+
/// How a view appears and disappears when inserted or removed with animation.
|
|
144
|
+
public struct AnyTransition: Sendable {
|
|
145
|
+
struct Part: Sendable {
|
|
146
|
+
var kind: String
|
|
147
|
+
var edge: Edge?
|
|
148
|
+
var scale: Double?
|
|
149
|
+
var offset: CGSize?
|
|
150
|
+
/// `asymmetric`: the transitions for insertion and removal.
|
|
151
|
+
var insertion: [Part]?
|
|
152
|
+
var removal: [Part]?
|
|
153
|
+
|
|
154
|
+
var _json: _JSON {
|
|
155
|
+
var object: [String: _JSON] = ["kind": .string(kind)]
|
|
156
|
+
if let edge { object["edge"] = .string(edge.name) }
|
|
157
|
+
if let scale { object["scale"] = .number(scale) }
|
|
158
|
+
if let offset {
|
|
159
|
+
object["x"] = .number(offset.width)
|
|
160
|
+
object["y"] = .number(offset.height)
|
|
161
|
+
}
|
|
162
|
+
if let insertion { object["insertion"] = AnyTransition(parts: insertion)._json }
|
|
163
|
+
if let removal { object["removal"] = AnyTransition(parts: removal)._json }
|
|
164
|
+
return .object(object)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public static func asymmetric(insertion: AnyTransition, removal: AnyTransition) -> AnyTransition {
|
|
169
|
+
AnyTransition(parts: [Part(kind: "asymmetric", insertion: insertion.parts, removal: removal.parts)])
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var parts: [Part]
|
|
173
|
+
|
|
174
|
+
public static let identity = AnyTransition(parts: [Part(kind: "identity")])
|
|
175
|
+
public static let opacity = AnyTransition(parts: [Part(kind: "opacity")])
|
|
176
|
+
public static let slide = AnyTransition(parts: [Part(kind: "slide")])
|
|
177
|
+
public static let scale = AnyTransition(parts: [Part(kind: "scale", scale: 0.5)])
|
|
178
|
+
|
|
179
|
+
public static func scale(scale: Double) -> AnyTransition {
|
|
180
|
+
AnyTransition(parts: [Part(kind: "scale", scale: scale)])
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/// The anchor is accepted for source compatibility; scaling is about the center.
|
|
184
|
+
public static func scale(scale: Double, anchor: UnitPoint) -> AnyTransition {
|
|
185
|
+
AnyTransition(parts: [Part(kind: "scale", scale: scale)])
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/// iOS 17's spelling, `.scale(0.5)`.
|
|
189
|
+
public static func scale(_ scale: Double, anchor: UnitPoint = .center) -> AnyTransition {
|
|
190
|
+
AnyTransition(parts: [Part(kind: "scale", scale: scale)])
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/// Slides in from / out to the given offset (points).
|
|
194
|
+
public static func offset(x: CGFloat = 0, y: CGFloat = 0) -> AnyTransition {
|
|
195
|
+
AnyTransition(parts: [Part(kind: "offset", offset: CGSize(width: x, height: y))])
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public static func offset(_ offset: CGSize) -> AnyTransition {
|
|
199
|
+
AnyTransition(parts: [Part(kind: "offset", offset: offset)])
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public static func move(edge: Edge) -> AnyTransition {
|
|
203
|
+
AnyTransition(parts: [Part(kind: "move", edge: edge)])
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public func combined(with other: AnyTransition) -> AnyTransition {
|
|
207
|
+
AnyTransition(parts: parts + other.parts)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// A transition between two states of a `ViewModifier`. The shim cannot
|
|
211
|
+
/// diff arbitrary modifiers, so it is accepted and rendered as `opacity`
|
|
212
|
+
/// (docs/ops-protocol.md, Phase 8).
|
|
213
|
+
public static func modifier<E: ViewModifier>(active: E, identity: E) -> AnyTransition {
|
|
214
|
+
.opacity
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
var _json: _JSON {
|
|
218
|
+
parts.count == 1 ? parts[0]._json : .array(parts.map(\._json))
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
extension Edge {
|
|
223
|
+
var name: String {
|
|
224
|
+
switch self {
|
|
225
|
+
case .top: "top"
|
|
226
|
+
case .leading: "leading"
|
|
227
|
+
case .bottom: "bottom"
|
|
228
|
+
case .trailing: "trailing"
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// MARK: - Modifiers
|
|
234
|
+
|
|
235
|
+
/// Views whose subtree animates when `value` changes.
|
|
236
|
+
protocol _AnimatedView: _TraitBearing {
|
|
237
|
+
var _animation: Animation? { get }
|
|
238
|
+
/// Whether the tracked value differs from a previously stored one.
|
|
239
|
+
func _changed(since previous: Any?) -> Bool
|
|
240
|
+
var _value: Any { get }
|
|
241
|
+
var _content: [any View] { get }
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
struct _AnimationView<Content: View, Value: Equatable> {
|
|
245
|
+
let content: Content
|
|
246
|
+
let animation: Animation?
|
|
247
|
+
let value: Value
|
|
248
|
+
}
|
|
249
|
+
extension _AnimationView: _PrimitiveView {}
|
|
250
|
+
extension _AnimationView: _HostView {
|
|
251
|
+
var _kind: String { "styled" }
|
|
252
|
+
func _props(in environment: EnvironmentValues) -> _JSON { .object(["style": .object([:])]) }
|
|
253
|
+
var _content: [any View] { [content] }
|
|
254
|
+
}
|
|
255
|
+
extension _AnimationView: _AnimatedView {
|
|
256
|
+
var _animation: Animation? { animation }
|
|
257
|
+
var _value: Any { value }
|
|
258
|
+
func _changed(since previous: Any?) -> Bool {
|
|
259
|
+
guard let previous = previous as? Value else { return true }
|
|
260
|
+
return previous != value
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
nonisolated extension View {
|
|
265
|
+
/// Animates changes to this view whenever `value` changes.
|
|
266
|
+
public func animation<V: Equatable>(_ animation: Animation?, value: V) -> some View {
|
|
267
|
+
_AnimationView(content: self, animation: animation, value: value)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// The transition to use when this view is inserted or removed with animation.
|
|
271
|
+
public func transition(_ transition: AnyTransition) -> some View {
|
|
272
|
+
_styled { $0.transition = transition }
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// MARK: - Transaction
|
|
277
|
+
|
|
278
|
+
/// The context of a state change. Accepted where SwiftUI takes one
|
|
279
|
+
/// (`AsyncImage(url:transaction:content:)`); the renderer animates what
|
|
280
|
+
/// `withAnimation` asked for, so the value itself is not consulted.
|
|
281
|
+
public struct Transaction: Sendable {
|
|
282
|
+
public var animation: Animation?
|
|
283
|
+
public var disablesAnimations: Bool = false
|
|
284
|
+
public init(animation: Animation? = nil) { self.animation = animation }
|
|
285
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/// A part of an app's user interface with a life cycle managed by the system.
|
|
2
|
+
@MainActor @preconcurrency
|
|
3
|
+
public protocol Scene {
|
|
4
|
+
associatedtype Body: Scene
|
|
5
|
+
@SceneBuilder var body: Self.Body { get }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
extension Never: Scene {}
|
|
9
|
+
|
|
10
|
+
/// Scenes the runtime can mount directly.
|
|
11
|
+
protocol _RootScene {
|
|
12
|
+
@MainActor var _rootView: any View { get }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@resultBuilder
|
|
16
|
+
public enum SceneBuilder {
|
|
17
|
+
public static func buildBlock<Content: Scene>(_ content: Content) -> Content { content }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/// A scene that presents a view hierarchy in a window (on the web, the screen).
|
|
21
|
+
public struct WindowGroup<Content: View> {
|
|
22
|
+
let content: Content
|
|
23
|
+
|
|
24
|
+
public init(@ViewBuilder content: () -> Content) {
|
|
25
|
+
self.content = content()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public init(_ title: String, @ViewBuilder content: () -> Content) {
|
|
29
|
+
self.content = content()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
extension WindowGroup: Scene {
|
|
34
|
+
public typealias Body = Never
|
|
35
|
+
public var body: Never { fatalError("WindowGroup is a primitive scene") }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
extension WindowGroup: _RootScene {
|
|
39
|
+
var _rootView: any View { content }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// A scene whose root view is wrapped in a view modifier: how another module
|
|
43
|
+
/// adds a scene modifier (SwiftData's `.modelContainer`) that applies to the
|
|
44
|
+
/// whole window's content.
|
|
45
|
+
public struct _RootModifiedScene<Content: Scene, Modifier: ViewModifier> {
|
|
46
|
+
let content: Content
|
|
47
|
+
let modifier: Modifier
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
extension _RootModifiedScene: Scene {
|
|
51
|
+
public typealias Body = Never
|
|
52
|
+
public var body: Never { fatalError("_RootModifiedScene is a primitive scene") }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
extension _RootModifiedScene: _RootScene {
|
|
56
|
+
var _rootView: any View {
|
|
57
|
+
guard let root = content as? any _RootScene else {
|
|
58
|
+
fatalError("\(Content.self) is not a scene the runtime can present. Use WindowGroup.")
|
|
59
|
+
}
|
|
60
|
+
func wrap<V: View>(_ view: V) -> any View { view.modifier(modifier) }
|
|
61
|
+
return wrap(root._rootView)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
extension Scene {
|
|
66
|
+
/// Applies `modifier` to the scene's root view.
|
|
67
|
+
public func _modifyingRootView<M: ViewModifier>(_ modifier: M) -> _RootModifiedScene<Self, M> {
|
|
68
|
+
_RootModifiedScene(content: self, modifier: modifier)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// The structure and behavior of an app. Mark the conforming type `@main`.
|
|
73
|
+
@MainActor @preconcurrency
|
|
74
|
+
public protocol App {
|
|
75
|
+
associatedtype Body: Scene
|
|
76
|
+
@SceneBuilder var body: Self.Body { get }
|
|
77
|
+
init()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
extension App {
|
|
81
|
+
/// Entry point used by `@main`. Mounts the app's root view and, in the
|
|
82
|
+
/// browser, returns while the module stays alive to receive events.
|
|
83
|
+
public static func main() {
|
|
84
|
+
_installHostExecutor()
|
|
85
|
+
_Runtime.shared.launch(Self())
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// A binding to a mutable collection is a collection of bindings to its
|
|
2
|
+
// elements, as in SwiftUI (iOS 15): `$items.isEmpty`, `$items.count` and
|
|
3
|
+
// `$items[0]` read and write through the binding to the whole collection.
|
|
4
|
+
|
|
5
|
+
extension Binding: Sequence where Value: MutableCollection {
|
|
6
|
+
public typealias Element = Binding<Value.Element>
|
|
7
|
+
public typealias Iterator = IndexingIterator<Binding<Value>>
|
|
8
|
+
public typealias SubSequence = Slice<Binding<Value>>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
extension Binding: Collection where Value: MutableCollection {
|
|
12
|
+
public typealias Index = Value.Index
|
|
13
|
+
public typealias Indices = Value.Indices
|
|
14
|
+
|
|
15
|
+
public var startIndex: Value.Index { wrappedValue.startIndex }
|
|
16
|
+
public var endIndex: Value.Index { wrappedValue.endIndex }
|
|
17
|
+
public var indices: Value.Indices { wrappedValue.indices }
|
|
18
|
+
|
|
19
|
+
public func index(after i: Value.Index) -> Value.Index { wrappedValue.index(after: i) }
|
|
20
|
+
|
|
21
|
+
public func formIndex(after i: inout Value.Index) { wrappedValue.formIndex(after: &i) }
|
|
22
|
+
|
|
23
|
+
public subscript(position: Value.Index) -> Binding<Value.Element> {
|
|
24
|
+
let whole = self
|
|
25
|
+
return Binding<Value.Element>(get: { whole.wrappedValue[position] }, set: { whole.wrappedValue[position] = $0 })
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
extension Binding: BidirectionalCollection where Value: BidirectionalCollection, Value: MutableCollection {
|
|
30
|
+
public func index(before i: Value.Index) -> Value.Index { wrappedValue.index(before: i) }
|
|
31
|
+
|
|
32
|
+
public func formIndex(before i: inout Value.Index) { wrappedValue.formIndex(before: &i) }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
extension Binding: RandomAccessCollection where Value: RandomAccessCollection, Value: MutableCollection {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// `ForEach($items) { $item in … }` (iOS 15): a row per element, each with a
|
|
2
|
+
/// binding to its element (`Binding(projectedValue:)`, in State.swift, lets
|
|
3
|
+
/// the closure take its parameter as `$item`). Plus the older
|
|
4
|
+
/// `Picker(selection:label:content:)`.
|
|
5
|
+
|
|
6
|
+
extension ForEach where Content: View {
|
|
7
|
+
/// A row per element of the bound collection, identified by its `id`.
|
|
8
|
+
public init<C: MutableCollection & RandomAccessCollection>(
|
|
9
|
+
_ data: Binding<C>, @ViewBuilder content: @escaping (Binding<C.Element>) -> Content
|
|
10
|
+
) where Data == [Binding<C.Element>], C.Element: Identifiable, ID == C.Element.ID {
|
|
11
|
+
self.init(_data: data.map { $0 }, id: { $0.wrappedValue.id }, content: content)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/// A row per element of the bound collection, identified by `id`.
|
|
15
|
+
public init<C: MutableCollection & RandomAccessCollection>(
|
|
16
|
+
_ data: Binding<C>, id: KeyPath<C.Element, ID>, @ViewBuilder content: @escaping (Binding<C.Element>) -> Content
|
|
17
|
+
) where Data == [Binding<C.Element>] {
|
|
18
|
+
self.init(_data: data.map { $0 }, id: { $0.wrappedValue[keyPath: id] }, content: content)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
extension Picker {
|
|
23
|
+
/// The pre-iOS 16 form, with the label first.
|
|
24
|
+
public init(selection: Binding<SelectionValue>, label: Label, @ViewBuilder content: () -> Content) {
|
|
25
|
+
self.init(selection: selection, content: content, label: { label })
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
// `UIImage` and `CGImage`, as far as SwiftUI apps use them: made from an
|
|
4
|
+
// image file's bytes, from Core Image (Sources/CoreImage), from an SF Symbol
|
|
5
|
+
// or a catalog name, and shown with `Image(uiImage:)`. On iOS SwiftUI
|
|
6
|
+
// re-exports UIKit's `UIImage` and Core Graphics' `CGImage`, so a file that
|
|
7
|
+
// imports SwiftUI alone uses both; here they live in the shim for the same
|
|
8
|
+
// reason. Neither holds pixels: each is a recipe the page draws
|
|
9
|
+
// (Runtime/ImageSource.swift, docs/ops-protocol.md, "Bitmaps and Core Image").
|
|
10
|
+
|
|
11
|
+
/// A bitmap: `width` × `height` pixels the page produces from a recipe.
|
|
12
|
+
public final class CGImage: @unchecked Sendable {
|
|
13
|
+
public let width: Int
|
|
14
|
+
public let height: Int
|
|
15
|
+
/// The recipe, ending at this image's pixel grid (extent `(0, 0, width, height)`).
|
|
16
|
+
public let _recipe: _ImageRecipe
|
|
17
|
+
|
|
18
|
+
/// Made by Core Image (`CIContext.createCGImage`) from a rendered recipe.
|
|
19
|
+
public init(_recipe recipe: _ImageRecipe) {
|
|
20
|
+
_recipe = recipe
|
|
21
|
+
let extent = recipe.extent.isNull || recipe.extent.isInfinite ? CGRect.zero : recipe.extent
|
|
22
|
+
width = Int(extent.width)
|
|
23
|
+
height = Int(extent.height)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public var bitsPerComponent: Int { 8 }
|
|
27
|
+
public var bitsPerPixel: Int { 32 }
|
|
28
|
+
public var bytesPerRow: Int { width * 4 }
|
|
29
|
+
|
|
30
|
+
/// The part of the image inside `rect` (pixels, origin at the top left),
|
|
31
|
+
/// clipped to the image; nil when they do not overlap.
|
|
32
|
+
public func cropping(to rect: CGRect) -> CGImage? {
|
|
33
|
+
let bounds = CGRect(x: 0, y: 0, width: Double(width), height: Double(height))
|
|
34
|
+
let box = rect.integral.intersection(bounds)
|
|
35
|
+
guard !box.isNull, box.width >= 1, box.height >= 1 else { return nil }
|
|
36
|
+
// Core Image's origin is at the bottom left.
|
|
37
|
+
let flipped = CGRect(x: box.minX, y: Double(height) - box.maxY, width: box.width, height: box.height)
|
|
38
|
+
return _recipe.rendered(in: flipped).map(CGImage.init(_recipe:))
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// UIKit's image: a bitmap with a scale (pixels per point), or an SF Symbol
|
|
43
|
+
/// or asset-catalog image the page draws by name.
|
|
44
|
+
public final class UIImage: Hashable, @unchecked Sendable {
|
|
45
|
+
public enum Orientation: Int, Sendable {
|
|
46
|
+
case up, down, left, right, upMirrored, downMirrored, leftMirrored, rightMirrored
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
enum Content {
|
|
50
|
+
case bitmap(_ImageRecipe)
|
|
51
|
+
case system(String)
|
|
52
|
+
case named(String)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let content: Content
|
|
56
|
+
/// The size in points: pixels ÷ `scale`.
|
|
57
|
+
public let size: CGSize
|
|
58
|
+
public let scale: CGFloat
|
|
59
|
+
/// Always `.up` for decoded files: the page draws them with their EXIF
|
|
60
|
+
/// rotation applied, and their size already accounts for it.
|
|
61
|
+
public let imageOrientation: Orientation
|
|
62
|
+
/// The `CIImage` a Core Image-backed image was made from (`UIImage(ciImage:)`).
|
|
63
|
+
public let _ciImage: AnyObject?
|
|
64
|
+
/// UIKit's `renderingMode`: 0 automatic, 1 always original, 2 always template.
|
|
65
|
+
public private(set) var _renderingMode = 0
|
|
66
|
+
|
|
67
|
+
private init(content: Content, size: CGSize, scale: CGFloat, orientation: Orientation, ciImage: AnyObject?) {
|
|
68
|
+
self.content = content
|
|
69
|
+
self.size = size
|
|
70
|
+
self.scale = scale
|
|
71
|
+
imageOrientation = orientation
|
|
72
|
+
_ciImage = ciImage
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// The same image with another rendering mode (UIKit's `withRenderingMode`),
|
|
76
|
+
/// or another bitmap of the same size (`withTintColor`).
|
|
77
|
+
public func _copy(recipe: _ImageRecipe? = nil, renderingMode: Int) -> UIImage {
|
|
78
|
+
let copy = UIImage(content: recipe.map(Content.bitmap) ?? content, size: size, scale: scale, orientation: imageOrientation,
|
|
79
|
+
ciImage: recipe == nil ? _ciImage : nil)
|
|
80
|
+
copy._renderingMode = renderingMode
|
|
81
|
+
return copy
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// Whether the image is an SF Symbol (drawn by the page by name).
|
|
85
|
+
public var _isSymbol: Bool {
|
|
86
|
+
if case .system = content { return true }
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// An empty image, 0 × 0.
|
|
91
|
+
public init() {
|
|
92
|
+
content = .bitmap(.empty)
|
|
93
|
+
size = .zero
|
|
94
|
+
scale = 1
|
|
95
|
+
imageOrientation = .up
|
|
96
|
+
_ciImage = nil
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/// The image in a PNG, JPEG, GIF, WebP, BMP, HEIC or AVIF file; nil when
|
|
100
|
+
/// the data is not one. Only the header is read here; the page decodes
|
|
101
|
+
/// the file when it draws it. (Chromium and Firefox draw no HEIC.)
|
|
102
|
+
public convenience init?(data: Data) {
|
|
103
|
+
self.init(data: data, scale: 1)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public init?(data: Data, scale: CGFloat) {
|
|
107
|
+
guard let source = _ImageSource(encoded: [UInt8](data)) else { return nil }
|
|
108
|
+
let factor = scale > 0 ? scale : 1
|
|
109
|
+
content = .bitmap(_ImageRecipe(source: source))
|
|
110
|
+
size = CGSize(width: Double(source.width) / factor, height: Double(source.height) / factor)
|
|
111
|
+
self.scale = factor
|
|
112
|
+
imageOrientation = .up
|
|
113
|
+
_ciImage = nil
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public convenience init(cgImage: CGImage) {
|
|
117
|
+
self.init(cgImage: cgImage, scale: 1, orientation: .up)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// `orientation` is recorded, not applied: the page draws the bitmap upright.
|
|
121
|
+
public init(cgImage: CGImage, scale: CGFloat, orientation: Orientation) {
|
|
122
|
+
let factor = scale > 0 ? scale : 1
|
|
123
|
+
content = .bitmap(cgImage._recipe)
|
|
124
|
+
size = CGSize(width: Double(cgImage.width) / factor, height: Double(cgImage.height) / factor)
|
|
125
|
+
self.scale = factor
|
|
126
|
+
imageOrientation = orientation
|
|
127
|
+
_ciImage = nil
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// A bitmap from a recipe whose extent is its pixel grid, `(0, 0, w, h)`
|
|
131
|
+
/// (Core Image's `UIImage(ciImage:)`).
|
|
132
|
+
public init(_recipe recipe: _ImageRecipe, scale: CGFloat, ciImage: AnyObject?) {
|
|
133
|
+
let factor = scale > 0 ? scale : 1
|
|
134
|
+
let extent = recipe.extent.isNull || recipe.extent.isInfinite ? CGRect.zero : recipe.extent
|
|
135
|
+
content = .bitmap(recipe)
|
|
136
|
+
size = CGSize(width: extent.width / factor, height: extent.height / factor)
|
|
137
|
+
self.scale = factor
|
|
138
|
+
imageOrientation = .up
|
|
139
|
+
_ciImage = ciImage
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/// An SF Symbol. Never nil: the shim cannot tell which names exist, and
|
|
143
|
+
/// the page draws a placeholder for one it does not know. The size is
|
|
144
|
+
/// that of a symbol at the body text style.
|
|
145
|
+
public init?(systemName: String) {
|
|
146
|
+
content = .system(systemName)
|
|
147
|
+
size = CGSize(width: 20, height: 20)
|
|
148
|
+
scale = 1
|
|
149
|
+
imageOrientation = .up
|
|
150
|
+
_ciImage = nil
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// An asset-catalog image. Never nil, and its size is zero: the catalog
|
|
154
|
+
/// is the page's (docs/ops-protocol.md, "Phase 5"), so only the page knows it.
|
|
155
|
+
public init?(named name: String) {
|
|
156
|
+
content = .named(name)
|
|
157
|
+
size = .zero
|
|
158
|
+
scale = 1
|
|
159
|
+
imageOrientation = .up
|
|
160
|
+
_ciImage = nil
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/// The bitmap, for an image made from data or a `CGImage`; nil for a
|
|
164
|
+
/// symbol, a catalog image, an empty image or one backed by a `CIImage`
|
|
165
|
+
/// (as on iOS).
|
|
166
|
+
public var cgImage: CGImage? {
|
|
167
|
+
guard _ciImage == nil, case .bitmap(let recipe) = content, recipe.source != nil else { return nil }
|
|
168
|
+
return CGImage(_recipe: recipe)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// The recipe the page draws; nil for a symbol or a catalog image.
|
|
172
|
+
public var _recipe: _ImageRecipe? {
|
|
173
|
+
if case .bitmap(let recipe) = content { return recipe }
|
|
174
|
+
return nil
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public static func == (lhs: UIImage, rhs: UIImage) -> Bool { lhs === rhs }
|
|
178
|
+
public func hash(into hasher: inout Hasher) { hasher.combine(ObjectIdentifier(self)) }
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
extension Image {
|
|
182
|
+
/// The way `Image(_:scale:orientation:label:)` takes a `CGImage`.
|
|
183
|
+
/// Recorded, not applied: the page draws the bitmap upright.
|
|
184
|
+
public enum Orientation: UInt8, CaseIterable, Hashable, Sendable {
|
|
185
|
+
case up, upMirrored, down, downMirrored, left, leftMirrored, right, rightMirrored
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/// A `UIImage`: its bitmap (drawn by the page from its recipe), or the
|
|
189
|
+
/// symbol or catalog image it names. The intrinsic size is the image's
|
|
190
|
+
/// size in points.
|
|
191
|
+
public init(uiImage: UIImage) {
|
|
192
|
+
switch uiImage.content {
|
|
193
|
+
case .system(let name): self.init(source: .system(name), isResizable: false)
|
|
194
|
+
case .named(let name): self.init(source: .named(name), isResizable: false)
|
|
195
|
+
case .bitmap(let recipe):
|
|
196
|
+
self.init(source: .bitmap(recipe, width: uiImage.size.width, height: uiImage.size.height), isResizable: false)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public init(_ cgImage: CGImage, scale: CGFloat, orientation: Orientation = .up, label: Text) {
|
|
201
|
+
let factor = scale > 0 ? scale : 1
|
|
202
|
+
self.init(source: .bitmap(cgImage._recipe, width: Double(cgImage.width) / factor, height: Double(cgImage.height) / factor),
|
|
203
|
+
isResizable: false)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public init(decorative cgImage: CGImage, scale: CGFloat, orientation: Orientation = .up) {
|
|
207
|
+
self.init(cgImage, scale: scale, orientation: orientation, label: Text(""))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/// Sends the bitmap's source to the page once (an `imagedata` op), before
|
|
211
|
+
/// the element that draws it.
|
|
212
|
+
@MainActor func _sendBitmapSource(through runtime: _Runtime) {
|
|
213
|
+
if case .bitmap(let recipe, _, _) = source, let source = recipe.source { runtime._sendImageSource(source) }
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Core Graphics' rectangle helpers that Core Image's extents need.
|
|
218
|
+
extension CGRect {
|
|
219
|
+
/// A rectangle covering the whole plane (a `clampedToExtent()` image's extent).
|
|
220
|
+
public static let infinite = CGRect(x: -Double.greatestFiniteMagnitude / 2, y: -Double.greatestFiniteMagnitude / 2,
|
|
221
|
+
width: Double.greatestFiniteMagnitude, height: Double.greatestFiniteMagnitude)
|
|
222
|
+
/// No rectangle at all (the intersection of two that do not meet).
|
|
223
|
+
public static let null = CGRect(x: Double.infinity, y: Double.infinity, width: 0, height: 0)
|
|
224
|
+
|
|
225
|
+
public var isInfinite: Bool { size.width >= Double.greatestFiniteMagnitude || size.height >= Double.greatestFiniteMagnitude }
|
|
226
|
+
public var isNull: Bool { origin.x == .infinity || origin.y == .infinity }
|
|
227
|
+
|
|
228
|
+
/// The overlap of two rectangles; `.null` when they do not overlap.
|
|
229
|
+
public func intersection(_ other: CGRect) -> CGRect {
|
|
230
|
+
if isNull || other.isNull { return .null }
|
|
231
|
+
if isInfinite { return other }
|
|
232
|
+
if other.isInfinite { return self }
|
|
233
|
+
let x0 = max(minX, other.minX), y0 = max(minY, other.minY)
|
|
234
|
+
let x1 = min(maxX, other.maxX), y1 = min(maxY, other.maxY)
|
|
235
|
+
guard x1 > x0, y1 > y0 else { return .null }
|
|
236
|
+
return CGRect(x: x0, y: y0, width: x1 - x0, height: y1 - y0)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/// The smallest rectangle containing both.
|
|
240
|
+
public func union(_ other: CGRect) -> CGRect {
|
|
241
|
+
if isNull { return other }
|
|
242
|
+
if other.isNull { return self }
|
|
243
|
+
if isInfinite || other.isInfinite { return .infinite }
|
|
244
|
+
let x0 = min(minX, other.minX), y0 = min(minY, other.minY)
|
|
245
|
+
return CGRect(x: x0, y: y0, width: max(maxX, other.maxX) - x0, height: max(maxY, other.maxY) - y0)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/// The smallest rectangle with integer coordinates containing this one.
|
|
249
|
+
public var integral: CGRect {
|
|
250
|
+
if isNull || isInfinite { return self }
|
|
251
|
+
let x0 = minX.rounded(.down), y0 = minY.rounded(.down)
|
|
252
|
+
return CGRect(x: x0, y: y0, width: maxX.rounded(.up) - x0, height: maxY.rounded(.up) - y0)
|
|
253
|
+
}
|
|
254
|
+
}
|