@swiftbrowser/swift 0.1.0 → 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 +200 -9
- package/README.md +7 -9
- package/Sources/AVFoundation/AVFoundation.swift +131 -0
- package/Sources/AVFoundation/Asset.swift +487 -0
- package/Sources/AVFoundation/AudioSession.swift +144 -0
- package/Sources/AVFoundation/CMTime.swift +303 -0
- package/Sources/AVFoundation/Capture.swift +688 -0
- package/Sources/AVFoundation/Player.swift +749 -0
- package/Sources/AVFoundation/PlayerView.swift +117 -0
- package/Sources/AVKit/AVKit.swift +132 -0
- package/Sources/Accelerate/Accelerate.swift +122 -0
- package/Sources/AppIntents/AppIntents.swift +144 -0
- package/Sources/AppIntents/Parameters.swift +220 -0
- package/Sources/AppIntents/Shortcuts.swift +159 -0
- package/Sources/AudioToolbox/AudioToolbox.swift +55 -0
- package/Sources/AuthenticationServices/AuthenticationServices.swift +257 -0
- package/Sources/AuthenticationServices/Authorization.swift +251 -0
- package/Sources/Charts/Charts.swift +0 -4
- package/Sources/Combine/AnyCancellable.swift +65 -0
- package/Sources/Combine/AnyPublisher.swift +148 -0
- package/Sources/Combine/AnySubscriber.swift +230 -0
- package/Sources/Combine/Cancellable.swift +35 -0
- package/Sources/Combine/Codable.swift +29 -0
- package/Sources/Combine/CombineIdentifier.swift +45 -0
- package/Sources/Combine/Concurrency/ConcurrencyHelpers.swift +24 -0
- package/Sources/Combine/Concurrency/Future+Concurrency.swift +136 -0
- package/Sources/Combine/Concurrency/GENERATED-Publisher+Concurrency.swift +397 -0
- package/Sources/Combine/CurrentValueSubject.swift +252 -0
- package/Sources/Combine/CustomCombineIdentifierConvertible.swift +28 -0
- package/Sources/Combine/Future.swift +228 -0
- package/Sources/Combine/GENERATED-RootProtocols.swift +426 -0
- package/Sources/Combine/Helpers/ConduitBase.swift +40 -0
- package/Sources/Combine/Helpers/ConduitList.swift +59 -0
- package/Sources/Combine/Helpers/DebugHook.swift +177 -0
- package/Sources/Combine/Helpers/FilterProducer.swift +174 -0
- package/Sources/Combine/Helpers/Locking.swift +30 -0
- package/Sources/Combine/Helpers/PartialCompletion.swift +26 -0
- package/Sources/Combine/Helpers/ReduceProducer.swift +249 -0
- package/Sources/Combine/Helpers/SubjectSubscriber.swift +96 -0
- package/Sources/Combine/Helpers/SubscriberTap.swift +69 -0
- package/Sources/Combine/Helpers/SubscriptionStatus.swift +33 -0
- package/Sources/Combine/Helpers/SubscriptionTap.swift +33 -0
- package/Sources/Combine/Helpers/Utils.swift +30 -0
- package/Sources/Combine/Helpers/Violations.swift +33 -0
- package/Sources/Combine/ImmediateScheduler.swift +178 -0
- package/Sources/Combine/LICENSE +21 -0
- package/Sources/Combine/NotificationPublisher.swift +48 -0
- package/Sources/Combine/ObjectWillChange.swift +46 -0
- package/Sources/Combine/PassthroughSubject.swift +222 -0
- package/Sources/Combine/Publisher+Subscribe.swift +53 -0
- package/Sources/Combine/Publishers/Deferred.swift +48 -0
- package/Sources/Combine/Publishers/Empty.swift +54 -0
- package/Sources/Combine/Publishers/Fail.swift +42 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.Catch.swift +673 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.Encode.swift +388 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.MapKeyPath.swift +384 -0
- package/Sources/Combine/Publishers/Just.swift +313 -0
- package/Sources/Combine/Publishers/Optional.Publisher.swift +315 -0
- package/Sources/Combine/Publishers/Publishers.AllSatisfy.swift +217 -0
- package/Sources/Combine/Publishers/Publishers.AssertNoFailure.swift +158 -0
- package/Sources/Combine/Publishers/Publishers.Autoconnect.swift +193 -0
- package/Sources/Combine/Publishers/Publishers.Breakpoint.swift +231 -0
- package/Sources/Combine/Publishers/Publishers.Buffer.swift +356 -0
- package/Sources/Combine/Publishers/Publishers.Collect.swift +102 -0
- package/Sources/Combine/Publishers/Publishers.CollectByCount.swift +195 -0
- package/Sources/Combine/Publishers/Publishers.CompactMap.swift +241 -0
- package/Sources/Combine/Publishers/Publishers.Comparison.swift +371 -0
- package/Sources/Combine/Publishers/Publishers.Concatenate.swift +474 -0
- package/Sources/Combine/Publishers/Publishers.Contains.swift +293 -0
- package/Sources/Combine/Publishers/Publishers.Count.swift +87 -0
- package/Sources/Combine/Publishers/Publishers.Debounce.swift +332 -0
- package/Sources/Combine/Publishers/Publishers.Delay.swift +269 -0
- package/Sources/Combine/Publishers/Publishers.Drop.swift +155 -0
- package/Sources/Combine/Publishers/Publishers.DropUntilOutput.swift +283 -0
- package/Sources/Combine/Publishers/Publishers.DropWhile.swift +378 -0
- package/Sources/Combine/Publishers/Publishers.Filter.swift +248 -0
- package/Sources/Combine/Publishers/Publishers.First.swift +261 -0
- package/Sources/Combine/Publishers/Publishers.FlatMap.swift +533 -0
- package/Sources/Combine/Publishers/Publishers.HandleEvents.swift +260 -0
- package/Sources/Combine/Publishers/Publishers.IgnoreOutput.swift +109 -0
- package/Sources/Combine/Publishers/Publishers.Last.swift +252 -0
- package/Sources/Combine/Publishers/Publishers.MakeConnectable.swift +82 -0
- package/Sources/Combine/Publishers/Publishers.Map.swift +351 -0
- package/Sources/Combine/Publishers/Publishers.MapError.swift +140 -0
- package/Sources/Combine/Publishers/Publishers.MeasureInterval.swift +187 -0
- package/Sources/Combine/Publishers/Publishers.Multicast.swift +284 -0
- package/Sources/Combine/Publishers/Publishers.Output.swift +241 -0
- package/Sources/Combine/Publishers/Publishers.PrefixUntilOutput.swift +197 -0
- package/Sources/Combine/Publishers/Publishers.PrefixWhile.swift +176 -0
- package/Sources/Combine/Publishers/Publishers.Print.swift +206 -0
- package/Sources/Combine/Publishers/Publishers.ReceiveOn.swift +227 -0
- package/Sources/Combine/Publishers/Publishers.Reduce.swift +204 -0
- package/Sources/Combine/Publishers/Publishers.RemoveDuplicates.swift +264 -0
- package/Sources/Combine/Publishers/Publishers.ReplaceEmpty.swift +201 -0
- package/Sources/Combine/Publishers/Publishers.ReplaceError.swift +211 -0
- package/Sources/Combine/Publishers/Publishers.Retry.swift +274 -0
- package/Sources/Combine/Publishers/Publishers.Scan.swift +331 -0
- package/Sources/Combine/Publishers/Publishers.Sequence.swift +437 -0
- package/Sources/Combine/Publishers/Publishers.SetFailureType.swift +120 -0
- package/Sources/Combine/Publishers/Publishers.Share.swift +104 -0
- package/Sources/Combine/Publishers/Publishers.SubscribeOn.swift +197 -0
- package/Sources/Combine/Publishers/Publishers.SwitchToLatest.swift +444 -0
- package/Sources/Combine/Publishers/Publishers.Throttle.swift +359 -0
- package/Sources/Combine/Publishers/Publishers.Timeout.swift +301 -0
- package/Sources/Combine/Publishers/Publishers.Zip.swift +720 -0
- package/Sources/Combine/Publishers/Publishers.swift +13 -0
- package/Sources/Combine/Publishers/Record.swift +237 -0
- package/Sources/Combine/Publishers/Result.Publisher.swift +337 -0
- package/Sources/Combine/Result.swift +46 -0
- package/Sources/Combine/Scheduler.swift +89 -0
- package/Sources/Combine/Schedulers.swift +211 -0
- package/Sources/Combine/Subject+Void.swift +17 -0
- package/Sources/Combine/Subscriber+Void.swift +20 -0
- package/Sources/Combine/Subscribers/Subscribers.Assign.swift +175 -0
- package/Sources/Combine/Subscribers/Subscribers.Completion.swift +90 -0
- package/Sources/Combine/Subscribers/Subscribers.Demand.swift +476 -0
- package/Sources/Combine/Subscribers/Subscribers.Sink.swift +206 -0
- package/Sources/Combine/Subscribers/Subscribers.swift +9 -0
- package/Sources/Combine/Subscription.swift +22 -0
- package/Sources/Combine/Subscriptions.swift +42 -0
- package/Sources/Combine/SwiftUIObservation.swift +10 -0
- package/Sources/Combine/_Introspection.swift +107 -0
- package/Sources/CommonCrypto/CommonCrypto.swift +80 -0
- package/Sources/Compression/Compression.swift +365 -0
- package/Sources/Compression/Deflate.swift +407 -0
- package/Sources/Compression/Zlib.swift +179 -0
- package/Sources/CoreFoundationTypes/CoreFoundationTypes.swift +101 -0
- package/Sources/CoreGraphics/CoreGraphics.swift +411 -0
- package/Sources/CoreGraphics/ProjectionTransforms.swift +28 -0
- package/Sources/CoreHaptics/CoreHaptics.swift +399 -0
- package/Sources/CoreImage/CIColor.swift +41 -0
- package/Sources/CoreImage/CIContext.swift +31 -0
- package/Sources/CoreImage/CIDetector.swift +57 -0
- package/Sources/CoreImage/CIFilter.swift +243 -0
- package/Sources/CoreImage/CIFilterBuiltins.swift +136 -0
- package/Sources/CoreImage/CIImage.swift +162 -0
- package/Sources/CoreImage/QRCode.swift +393 -0
- package/Sources/CoreLocation/Coordinate.swift +30 -0
- package/Sources/CoreLocation/Location.swift +65 -0
- package/Sources/CoreML/Evaluation.swift +414 -0
- package/Sources/CoreML/FeatureValue.swift +266 -0
- package/Sources/CoreML/Model.swift +269 -0
- package/Sources/CoreML/MultiArray.swift +92 -0
- package/Sources/CoreML/Specification.swift +233 -0
- package/Sources/CoreText/CoreText.swift +64 -0
- package/Sources/CoreTransferable/CoreTransferable.swift +606 -0
- package/Sources/CryptoKit/ChaChaPoly.swift +258 -0
- package/Sources/CryptoKit/CryptoKit.swift +375 -0
- package/Sources/CryptoKit/Curve25519.swift +317 -0
- package/Sources/CryptoKit/P256.swift +321 -0
- package/Sources/FoundationBridge/AppStorage.swift +165 -0
- package/Sources/FoundationBridge/AssetResources.swift +90 -0
- package/Sources/FoundationBridge/AsyncBytes.swift +128 -0
- package/Sources/FoundationBridge/AsyncImage.swift +116 -0
- package/Sources/FoundationBridge/AttributedStrings.swift +16 -0
- package/Sources/{_FoundationCommon → FoundationBridge}/Bundle.swift +41 -4
- package/Sources/FoundationBridge/CombineExports.swift +8 -0
- package/Sources/FoundationBridge/CoreFoundation.swift +77 -0
- package/Sources/FoundationBridge/Dispatch.swift +458 -0
- package/Sources/FoundationBridge/EnvironmentFoundation.swift +41 -0
- package/Sources/FoundationBridge/FileImporter.swift +128 -0
- package/Sources/FoundationBridge/FileSystem.swift +68 -0
- package/Sources/FoundationBridge/FoundationBridge.swift +24 -72
- package/Sources/FoundationBridge/HostResolution.swift +31 -0
- package/Sources/FoundationBridge/ItemProvider.swift +655 -0
- package/Sources/FoundationBridge/KeyValueObserving.swift +138 -0
- package/Sources/FoundationBridge/Links.swift +127 -0
- package/Sources/FoundationBridge/ListFormatter.swift +32 -0
- package/Sources/FoundationBridge/Localization.swift +149 -0
- package/Sources/FoundationBridge/Locks.swift +50 -0
- package/Sources/FoundationBridge/Markdown.swift +527 -0
- package/Sources/FoundationBridge/MeasurementFormat.swift +95 -0
- package/Sources/FoundationBridge/NotificationCenter.swift +154 -0
- package/Sources/FoundationBridge/OpenURLHandlers.swift +60 -0
- package/Sources/FoundationBridge/Operation.swift +195 -0
- package/Sources/FoundationBridge/ProcessInfo.swift +32 -0
- package/Sources/FoundationBridge/RelativeDateTimeFormatter.swift +136 -0
- package/Sources/FoundationBridge/SceneStorage.swift +78 -0
- package/Sources/FoundationBridge/SecurityExports.swift +8 -0
- package/Sources/FoundationBridge/Selector.swift +226 -0
- package/Sources/FoundationBridge/StringComparators.swift +17 -0
- package/Sources/FoundationBridge/Table.swift +211 -0
- package/Sources/FoundationBridge/TextAttributes.swift +42 -0
- package/Sources/FoundationBridge/Timer.swift +6 -1
- package/Sources/FoundationBridge/URLSession.swift +718 -0
- package/Sources/{_FoundationCommon → FoundationBridge}/UserDefaults.swift +17 -4
- package/Sources/FoundationBridge/WebAuthRedirects.swift +227 -0
- package/Sources/FoundationBridge/WebSocket.swift +187 -0
- package/Sources/FoundationModels/FoundationModels.swift +1098 -0
- package/Sources/ImageIO/GIF.swift +72 -0
- package/Sources/ImageIO/ImageIO.swift +248 -0
- package/Sources/ImageIO/ImageTypes.swift +28 -0
- package/Sources/LinkPresentation/LinkPresentation.swift +249 -0
- package/Sources/LocalAuthentication/LAContext.swift +86 -0
- package/Sources/MapKit/Geometry.swift +223 -0
- package/Sources/MapKit/Map.swift +638 -0
- package/Sources/MapKit/MapView.swift +229 -0
- package/Sources/MobileCoreServices/MobileCoreServices.swift +28 -0
- package/Sources/NaturalLanguage/LanguageIdentifier.swift +317 -0
- package/Sources/NaturalLanguage/NaturalLanguage.swift +135 -0
- package/Sources/OSLog/OSLog.swift +6 -0
- package/Sources/Photos/Photos.swift +572 -0
- package/Sources/PhotosUI/PhotosPicker.swift +248 -0
- package/Sources/PhotosUI/PhotosPickerItem.swift +261 -0
- package/Sources/QuickLook/QuickLook.swift +168 -0
- package/Sources/SafariServices/SafariServices.swift +106 -0
- package/Sources/Security/Security.swift +332 -0
- package/Sources/StoreKit/AppStore.swift +207 -0
- package/Sources/StoreKit/Products.swift +280 -0
- package/Sources/StoreKit/RequestReview.swift +28 -0
- package/Sources/StoreKit/StoreKit1.swift +486 -0
- package/Sources/StoreKit/StoreViews.swift +428 -0
- package/Sources/StoreKit/Transactions.swift +197 -0
- package/Sources/SwiftData/Macros.swift +58 -0
- package/Sources/SwiftData/ModelActor.swift +38 -0
- package/Sources/SwiftData/ModelContainer.swift +129 -0
- package/Sources/SwiftData/ModelContext.swift +451 -0
- package/Sources/SwiftData/PersistentModel.swift +238 -0
- package/Sources/SwiftData/Properties.swift +261 -0
- package/Sources/SwiftData/Query.swift +256 -0
- package/Sources/SwiftData/Schema.swift +192 -0
- package/Sources/SwiftData/Store.swift +146 -0
- package/Sources/SwiftData/StringPredicates.swift +125 -0
- package/Sources/SwiftDataMacros/EntryMacro.swift +82 -0
- package/Sources/SwiftDataMacros/GenerableMacro.swift +183 -0
- package/Sources/SwiftDataMacros/ModelActorMacro.swift +46 -0
- package/Sources/SwiftDataMacros/ModelMacro.swift +260 -0
- package/Sources/SwiftDataMacros/Plugin.swift +18 -0
- package/Sources/SwiftDataMacros/PredicateMacro.swift +1244 -0
- package/Sources/SwiftUI/API/Accessibility.swift +55 -6
- package/Sources/SwiftUI/API/AccessibilityExtras.swift +33 -0
- package/Sources/SwiftUI/API/AccessibilityFocus.swift +63 -0
- package/Sources/SwiftUI/API/Alert.swift +1 -1
- package/Sources/SwiftUI/API/AlignmentGuides.swift +65 -0
- package/Sources/SwiftUI/API/Animation.swift +37 -5
- package/Sources/SwiftUI/API/App.swift +31 -1
- package/Sources/SwiftUI/API/BindingCollections.swift +35 -0
- package/Sources/SwiftUI/API/BindingForEach.swift +27 -0
- package/Sources/SwiftUI/API/Bitmaps.swift +254 -0
- package/Sources/SwiftUI/API/ButtonStyles.swift +96 -0
- package/Sources/SwiftUI/API/Canvas.swift +337 -0
- package/Sources/SwiftUI/API/Color.swift +104 -28
- package/Sources/SwiftUI/API/ColorEffects.swift +52 -0
- package/Sources/SwiftUI/API/ColorPickerAndLabeledContent.swift +138 -0
- package/Sources/SwiftUI/API/ColorSpaces.swift +161 -0
- package/Sources/SwiftUI/API/Commands.swift +106 -0
- package/Sources/SwiftUI/API/ContainerBackground.swift +28 -0
- package/Sources/SwiftUI/API/ContentShape.swift +33 -0
- package/Sources/SwiftUI/API/ContentSizeCategory.swift +35 -0
- package/Sources/SwiftUI/API/ContentUnavailable.swift +101 -0
- package/Sources/SwiftUI/API/Controls.swift +59 -27
- package/Sources/SwiftUI/API/CustomLayout.swift +49 -10
- package/Sources/SwiftUI/API/CustomToolbarContent.swift +46 -0
- package/Sources/SwiftUI/API/Decorations.swift +1 -1
- package/Sources/SwiftUI/API/EditMode.swift +25 -82
- package/Sources/SwiftUI/API/Effects.swift +105 -7
- package/Sources/SwiftUI/API/Entry.swift +8 -0
- package/Sources/SwiftUI/API/Environment.swift +93 -9
- package/Sources/SwiftUI/API/EnvironmentSendable.swift +6 -0
- package/Sources/SwiftUI/API/Focus.swift +11 -3
- package/Sources/SwiftUI/API/Gauge.swift +3 -2
- package/Sources/SwiftUI/API/GeometryEffects.swift +232 -0
- package/Sources/SwiftUI/API/GeometryReader.swift +13 -2
- package/Sources/SwiftUI/API/GestureState.swift +65 -0
- package/Sources/SwiftUI/API/Gestures.swift +1 -1
- package/Sources/SwiftUI/API/Glass.swift +127 -0
- package/Sources/SwiftUI/API/Grid.swift +1 -1
- package/Sources/SwiftUI/API/GroupBoxAndControlGroup.swift +130 -0
- package/Sources/SwiftUI/API/KeyPress.swift +54 -0
- package/Sources/SwiftUI/API/LabelStyle.swift +13 -6
- package/Sources/SwiftUI/API/Layout.swift +67 -12
- package/Sources/SwiftUI/API/LazyStacks.swift +49 -0
- package/Sources/SwiftUI/API/LegacyAlert.swift +97 -0
- package/Sources/SwiftUI/API/Lists.swift +61 -6
- package/Sources/SwiftUI/API/Menu.swift +8 -1
- package/Sources/SwiftUI/API/Modifiers.swift +80 -10
- package/Sources/SwiftUI/API/MoreModifiers.swift +100 -0
- package/Sources/SwiftUI/API/Namespace.swift +44 -0
- package/Sources/SwiftUI/API/Navigation.swift +24 -9
- package/Sources/SwiftUI/API/NavigationDestinationBindings.swift +55 -0
- package/Sources/SwiftUI/API/ObservableObject.swift +16 -2
- package/Sources/SwiftUI/API/Path.swift +543 -0
- package/Sources/SwiftUI/API/Phase8Controls.swift +48 -31
- package/Sources/SwiftUI/API/PhaseAnimator.swift +130 -0
- package/Sources/SwiftUI/API/Picker.swift +11 -2
- package/Sources/SwiftUI/API/PointerAndKeyboard.swift +77 -0
- package/Sources/SwiftUI/API/Popover.swift +41 -0
- package/Sources/SwiftUI/API/Preferences.swift +262 -0
- package/Sources/SwiftUI/API/Presentation.swift +17 -4
- package/Sources/SwiftUI/API/PresentationExtras.swift +60 -0
- package/Sources/SwiftUI/API/Primitives.swift +164 -37
- package/Sources/SwiftUI/API/Publishers.swift +4 -4
- package/Sources/SwiftUI/API/Redaction.swift +75 -0
- package/Sources/SwiftUI/API/RowActions.swift +3 -2
- package/Sources/SwiftUI/API/Scenes.swift +131 -0
- package/Sources/SwiftUI/API/ScrollModifiers.swift +132 -0
- package/Sources/SwiftUI/API/ScrollTargets.swift +3 -3
- package/Sources/SwiftUI/API/ScrollViewReader.swift +144 -0
- package/Sources/SwiftUI/API/SectionSupplements.swift +96 -0
- package/Sources/SwiftUI/API/Shape.swift +214 -0
- package/Sources/SwiftUI/API/ShapeStyle.swift +105 -7
- package/Sources/SwiftUI/API/ShapeTrim.swift +78 -0
- package/Sources/SwiftUI/API/Sharing.swift +193 -0
- package/Sources/SwiftUI/API/StackLayouts.swift +199 -0
- package/Sources/SwiftUI/API/State.swift +18 -1
- package/Sources/SwiftUI/API/StatusGaps.swift +121 -0
- package/Sources/SwiftUI/API/SymbolEffects.swift +203 -0
- package/Sources/SwiftUI/API/TabContent.swift +841 -0
- package/Sources/SwiftUI/API/Table.swift +382 -0
- package/Sources/SwiftUI/API/Tabs.swift +148 -4
- package/Sources/SwiftUI/API/Tasks.swift +2 -2
- package/Sources/SwiftUI/API/Text.swift +386 -0
- package/Sources/SwiftUI/API/TextDates.swift +61 -0
- package/Sources/SwiftUI/API/TextDecorations.swift +52 -0
- package/Sources/SwiftUI/API/TextFieldAxis.swift +103 -0
- package/Sources/SwiftUI/API/TextFieldCommit.swift +52 -0
- package/Sources/SwiftUI/API/Toolbar.swift +52 -16
- package/Sources/SwiftUI/API/Transfer.swift +145 -0
- package/Sources/SwiftUI/API/UnevenRoundedRectangle.swift +66 -0
- package/Sources/SwiftUI/API/Video.swift +64 -0
- package/Sources/SwiftUI/API/View.swift +10 -2
- package/Sources/SwiftUI/API/ViewModifier.swift +4 -1
- package/Sources/SwiftUI/API/VisualEffect.swift +74 -1
- package/Sources/SwiftUI/API/Windows.swift +25 -0
- package/Sources/SwiftUI/Charts/Axis.swift +7 -1
- package/Sources/SwiftUI/Charts/AxisFormatsAndRanges.swift +68 -0
- package/Sources/SwiftUI/Charts/Chart.swift +17 -3
- package/Sources/SwiftUI/Charts/ChartProxy.swift +57 -0
- package/Sources/SwiftUI/Localization/Localization.swift +498 -0
- package/Sources/SwiftUI/Localization/PluralRules.swift +127 -0
- package/Sources/SwiftUI/Runtime/Executor.swift +2 -0
- package/Sources/SwiftUI/Runtime/Exports.swift +37 -1
- package/Sources/SwiftUI/Runtime/ImageSource.swift +310 -0
- package/Sources/SwiftUI/Runtime/JSON.swift +76 -4
- package/Sources/SwiftUI/Runtime/LazyRows.swift +99 -0
- package/Sources/SwiftUI/Runtime/Measurements.swift +140 -0
- package/Sources/SwiftUI/Runtime/Ops.swift +58 -12
- package/Sources/SwiftUI/Runtime/Reconciler.swift +10 -1
- package/Sources/SwiftUI/Runtime/Replay.swift +382 -0
- package/Sources/SwiftUI/Runtime/Runtime.swift +977 -198
- package/Sources/SwiftUI/Runtime/Sameness.swift +152 -0
- package/Sources/SwiftUI/Runtime/ViewPath.swift +89 -0
- package/Sources/SwiftUI/Runtime/ViewTraits.swift +175 -0
- package/Sources/SwiftUI/Runtime/WebAuthHeadless.swift +49 -0
- package/Sources/Symbols/Symbols.swift +25 -0
- package/Sources/Translation/Translation.swift +423 -0
- package/Sources/UIKit/Activity.swift +213 -0
- package/Sources/UIKit/Alerts.swift +69 -0
- package/Sources/UIKit/AppDelegate.swift +222 -0
- package/Sources/UIKit/Appearance.swift +84 -0
- package/Sources/UIKit/ColorConversions.swift +70 -0
- package/Sources/UIKit/Controls.swift +225 -0
- package/Sources/UIKit/Device.swift +200 -0
- package/Sources/UIKit/Feedback.swift +65 -0
- package/Sources/UIKit/Font.swift +307 -0
- package/Sources/UIKit/Graphics.swift +204 -0
- package/Sources/UIKit/HostingController.swift +185 -0
- package/Sources/UIKit/Identity.swift +24 -0
- package/Sources/UIKit/Introspectable.swift +510 -0
- package/Sources/UIKit/Pasteboard.swift +363 -0
- package/Sources/UIKit/PhotoAlbum.swift +81 -0
- package/Sources/UIKit/RemoteNotifications.swift +15 -0
- package/Sources/UIKit/Representable.swift +288 -0
- package/Sources/UIKit/SafeArea.swift +12 -0
- package/Sources/UIKit/SceneDelegates.swift +132 -0
- package/Sources/UIKit/Scenes.swift +40 -0
- package/Sources/UIKit/ScrollView.swift +157 -0
- package/Sources/UIKit/ShortcutItems.swift +67 -0
- package/Sources/UIKit/SymbolConfiguration.swift +124 -0
- package/Sources/UIKit/TargetAction.swift +123 -0
- package/Sources/UIKit/TextPaste.swift +161 -0
- package/Sources/UIKit/TextView.swift +538 -0
- package/Sources/UIKit/UIKit.swift +292 -0
- package/Sources/UIKit/UIView.swift +855 -0
- package/Sources/UIKit/ViewTranslation.swift +311 -0
- package/Sources/UniformTypeIdentifiers/UTType.swift +196 -0
- package/Sources/UserNotifications/Content.swift +370 -0
- package/Sources/UserNotifications/NotificationCenter.swift +309 -0
- package/Sources/WeatherKit/WeatherKit.swift +228 -0
- package/Sources/WebKit/WebKit.swift +245 -0
- package/Sources/os/os.swift +376 -0
- package/Sources/zlib/zlib.swift +6 -0
- package/index.d.ts +1 -1
- package/index.mjs +2 -2
- package/manifest.d.mts +2 -0
- package/manifest.mjs +39 -0
- package/package.json +5 -3
- package/sync-sources.mjs +21 -7
- package/Sources/FoundationLite/Common.swift +0 -3
- package/Sources/FoundationLite/FoundationLite.swift +0 -171
- package/Sources/FoundationLite/Interaction.swift +0 -146
- package/Sources/FoundationLite/Timer.swift +0 -48
- package/Sources/_FoundationCommon/_FoundationCommon.swift +0 -10
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Whether a view value a parent re-created is the same input as the one a
|
|
2
|
+
// mounted node holds, so that the node (and its subtree) can be skipped
|
|
3
|
+
// instead of re-running its body. SwiftUI makes the same decision by
|
|
4
|
+
// comparing a view's stored properties; here the comparison is done by
|
|
5
|
+
// reflection and is conservative: anything it cannot prove equal (a closure,
|
|
6
|
+
// a binding, a type it does not understand, a value too large to walk) is
|
|
7
|
+
// "different", which only costs the re-run the runtime did before.
|
|
8
|
+
|
|
9
|
+
/// A value the runtime re-creates on every pass that nevertheless stands for
|
|
10
|
+
/// the same thing each time (a screen's dismiss action, the edit-mode binding
|
|
11
|
+
/// a node owns). It compares by its identity; without one it is never equal.
|
|
12
|
+
protocol _RuntimeIdentified {
|
|
13
|
+
var _runtimeIdentity: AnyHashable? { get }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
enum _Sameness {
|
|
17
|
+
/// How many values one comparison may visit before it gives up.
|
|
18
|
+
static let budget = 256
|
|
19
|
+
|
|
20
|
+
/// Whether two values of a view (or of an environment) are the same input.
|
|
21
|
+
/// - Value types that are `Equatable` compare with `==`.
|
|
22
|
+
/// - Class instances compare by identity, never by `==`: a different
|
|
23
|
+
/// object is a different observation even when it claims equality.
|
|
24
|
+
/// - `@State`, `@StateObject`, `@FocusState`, `@Environment`,
|
|
25
|
+
/// `@EnvironmentObject` and `@ScaledMetric` are equal: their values belong
|
|
26
|
+
/// to the mounted node or come from the environment, which is compared
|
|
27
|
+
/// separately.
|
|
28
|
+
/// - Structs, tuples, enums, optionals and collections compare member by
|
|
29
|
+
/// member, labels included.
|
|
30
|
+
/// - Anything else (closures, metatypes) is different.
|
|
31
|
+
static func same(_ a: Any, _ b: Any, budget: inout Int) -> Bool {
|
|
32
|
+
budget -= 1
|
|
33
|
+
if budget < 0 { return false }
|
|
34
|
+
let typeA = type(of: a)
|
|
35
|
+
guard typeA == type(of: b) else { return false }
|
|
36
|
+
switch kind(of: a, type: typeA) {
|
|
37
|
+
case .ignored:
|
|
38
|
+
return true
|
|
39
|
+
case .identified(let read):
|
|
40
|
+
guard let identity = read(a), let other = read(b) else { return false }
|
|
41
|
+
return identity == other
|
|
42
|
+
case .object:
|
|
43
|
+
return ObjectIdentifier(a as AnyObject) == ObjectIdentifier(b as AnyObject)
|
|
44
|
+
case .equatable(let equal):
|
|
45
|
+
return equal(a, b)
|
|
46
|
+
case .structural(let isEnum):
|
|
47
|
+
let mirrorA = Mirror(reflecting: a)
|
|
48
|
+
let mirrorB = Mirror(reflecting: b)
|
|
49
|
+
if isEnum, mirrorA.children.isEmpty, mirrorB.children.isEmpty {
|
|
50
|
+
// Two payload-less cases of an enum that is not Equatable.
|
|
51
|
+
return String(describing: a) == String(describing: b)
|
|
52
|
+
}
|
|
53
|
+
var childrenB = mirrorB.children.makeIterator()
|
|
54
|
+
for childA in mirrorA.children {
|
|
55
|
+
guard let childB = childrenB.next(), childA.label == childB.label,
|
|
56
|
+
same(childA.value, childB.value, budget: &budget) else { return false }
|
|
57
|
+
}
|
|
58
|
+
return childrenB.next() == nil
|
|
59
|
+
case .never:
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/// How values of one type compare, worked out once per type: the dynamic
|
|
65
|
+
/// casts that decide it are the expensive part of a comparison.
|
|
66
|
+
private enum Kind {
|
|
67
|
+
case ignored
|
|
68
|
+
case identified((Any) -> AnyHashable?)
|
|
69
|
+
case object
|
|
70
|
+
case equatable((Any, Any) -> Bool)
|
|
71
|
+
case structural(isEnum: Bool)
|
|
72
|
+
case never
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
nonisolated(unsafe) private static var kinds: [ObjectIdentifier: Kind] = [:]
|
|
76
|
+
|
|
77
|
+
private static func kind(of value: Any, type: Any.Type) -> Kind {
|
|
78
|
+
let key = ObjectIdentifier(type)
|
|
79
|
+
if let known = kinds[key] { return known }
|
|
80
|
+
let kind: Kind
|
|
81
|
+
// A cast to a protocol looks inside an optional: `Optional<any
|
|
82
|
+
// ShapeStyle>` holding a `Color` casts to `any Equatable` as the
|
|
83
|
+
// `Color`. Its kind is cached for the optional's type, which holds
|
|
84
|
+
// other types too, so it only counts when the cast kept the type; an
|
|
85
|
+
// optional is otherwise compared by its payload (structural).
|
|
86
|
+
if value is any _StateProperty || value is any _EnvironmentProperty {
|
|
87
|
+
kind = .ignored
|
|
88
|
+
} else if let identified = value as? any _RuntimeIdentified, openedType(identified) == type {
|
|
89
|
+
kind = .identified(identity(of: identified))
|
|
90
|
+
} else if type is AnyObject.Type {
|
|
91
|
+
kind = .object
|
|
92
|
+
} else if let equatable = value as? any Equatable, openedType(equatable) == type {
|
|
93
|
+
kind = .equatable(equality(of: equatable))
|
|
94
|
+
} else {
|
|
95
|
+
switch Mirror(reflecting: value).displayStyle {
|
|
96
|
+
case .struct?, .tuple?, .optional?, .collection?, .set?, .dictionary?:
|
|
97
|
+
kind = .structural(isEnum: false)
|
|
98
|
+
case .enum?:
|
|
99
|
+
kind = .structural(isEnum: true)
|
|
100
|
+
default:
|
|
101
|
+
kind = .never
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
kinds[key] = kind
|
|
105
|
+
return kind
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/// Reads the identity of values of `T` with a cast to `T`, not to the
|
|
109
|
+
/// protocol (a conformance lookup per comparison).
|
|
110
|
+
private static func identity<T: _RuntimeIdentified>(of _: T) -> (Any) -> AnyHashable? {
|
|
111
|
+
{ ($0 as! T)._runtimeIdentity }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private static func openedType<T>(_: T) -> Any.Type { T.self }
|
|
115
|
+
|
|
116
|
+
private static func equality<T: Equatable>(of _: T) -> (Any, Any) -> Bool {
|
|
117
|
+
{ a, b in (a as! T) == (b as! T) }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// Whether values shaped like `value` can ever compare equal: comparing it
|
|
121
|
+
/// with itself fails only when it holds a closure, a binding without an
|
|
122
|
+
/// identity, or something else this comparison does not understand.
|
|
123
|
+
static func canEverBeSame(_ value: Any) -> Bool {
|
|
124
|
+
var budget = 4096
|
|
125
|
+
return same(value, value, budget: &budget)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// Whether `new` is the same view as `old` (of the same type).
|
|
129
|
+
static func sameView(_ old: any View, _ new: any View) -> Bool {
|
|
130
|
+
var budget = budget
|
|
131
|
+
return same(old, new, budget: &budget)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
extension EnvironmentValues {
|
|
136
|
+
/// Whether every entry is the same (see `_Sameness.same`) as in `other`.
|
|
137
|
+
func _isSame(as other: EnvironmentValues) -> Bool {
|
|
138
|
+
_sameStorage(as: other)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
extension DismissAction: _RuntimeIdentified {
|
|
143
|
+
var _runtimeIdentity: AnyHashable? { identity.map(AnyHashable.init) }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
extension Binding: _RuntimeIdentified {
|
|
147
|
+
var _runtimeIdentity: AnyHashable? { identity.map(AnyHashable.init) }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
extension _ListSelection: _RuntimeIdentified {
|
|
151
|
+
var _runtimeIdentity: AnyHashable? { identity.map(AnyHashable.init) }
|
|
152
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// A node's position from the root, `Type/index:Type/key:Type/...`: it keys
|
|
2
|
+
// state snapshots (hot reload) and the root-level sheets and alerts, and a
|
|
3
|
+
// node whose parent passes the same path and context may skip its body.
|
|
4
|
+
//
|
|
5
|
+
// Every child gets one on every pass. As text, each was its parent's text
|
|
6
|
+
// copied and appended to (a tenth of the reconciler's time in Ice Cubes);
|
|
7
|
+
// here it is a link to the parent's path plus this step, with a hash for
|
|
8
|
+
// comparing, and the text is made only when something asks for it.
|
|
9
|
+
|
|
10
|
+
@MainActor
|
|
11
|
+
final class _ViewPath {
|
|
12
|
+
enum Step: Hashable {
|
|
13
|
+
case root
|
|
14
|
+
case index(Int)
|
|
15
|
+
case key(AnyHashable)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let parent: _ViewPath?
|
|
19
|
+
let step: Step
|
|
20
|
+
let type: Any.Type
|
|
21
|
+
private let hash: Int
|
|
22
|
+
private var cachedText: String?
|
|
23
|
+
|
|
24
|
+
init(root type: Any.Type) {
|
|
25
|
+
parent = nil
|
|
26
|
+
step = .root
|
|
27
|
+
self.type = type
|
|
28
|
+
var hasher = Hasher()
|
|
29
|
+
hasher.combine(ObjectIdentifier(type))
|
|
30
|
+
hash = hasher.finalize()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private init(parent: _ViewPath, step: Step, type: Any.Type) {
|
|
34
|
+
self.parent = parent
|
|
35
|
+
self.step = step
|
|
36
|
+
self.type = type
|
|
37
|
+
var hasher = Hasher()
|
|
38
|
+
hasher.combine(parent.hash)
|
|
39
|
+
hasher.combine(step)
|
|
40
|
+
hasher.combine(ObjectIdentifier(type))
|
|
41
|
+
hash = hasher.finalize()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func child(_ step: Step, _ type: Any.Type) -> _ViewPath {
|
|
45
|
+
_ViewPath(parent: self, step: step, type: type)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// `Type/index:Type/key:Type/...`, the type names without generic arguments.
|
|
49
|
+
var text: String {
|
|
50
|
+
if let cachedText { return cachedText }
|
|
51
|
+
let name = Self.name(of: type)
|
|
52
|
+
let text: String
|
|
53
|
+
switch step {
|
|
54
|
+
case .root: text = name
|
|
55
|
+
case .index(let index): text = "\(parent?.text ?? "")/\(index):\(name)"
|
|
56
|
+
case .key(let key): text = "\(parent?.text ?? "")/\(key.base):\(name)"
|
|
57
|
+
}
|
|
58
|
+
cachedText = text
|
|
59
|
+
return text
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/// The same steps through the same types from the root.
|
|
63
|
+
func matches(_ other: _ViewPath) -> Bool {
|
|
64
|
+
var a = self, b = other
|
|
65
|
+
while a !== b {
|
|
66
|
+
guard a.hash == b.hash, a.step == b.step, a.type == b.type else { return false }
|
|
67
|
+
switch (a.parent, b.parent) {
|
|
68
|
+
case (nil, nil): return true
|
|
69
|
+
case (let pa?, let pb?): a = pa; b = pb
|
|
70
|
+
default: return false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private static var names: [ObjectIdentifier: String] = [:]
|
|
77
|
+
|
|
78
|
+
/// A type's name without its generic arguments.
|
|
79
|
+
private static func name(of type: Any.Type) -> String {
|
|
80
|
+
let key = ObjectIdentifier(type)
|
|
81
|
+
if let cached = names[key] { return cached }
|
|
82
|
+
// `String(describing:)` would first look up three printing protocols
|
|
83
|
+
// for the metatype (ViewTraits.swift: lookups are slow in WebAssembly).
|
|
84
|
+
let full = Swift._typeName(type, qualified: false)
|
|
85
|
+
let name = if let angle = full.firstIndex(of: "<") { String(full[..<angle]) } else { full }
|
|
86
|
+
names[key] = name
|
|
87
|
+
return name
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Which of the runtime's protocols a view type conforms to, worked out once
|
|
2
|
+
// per type. The reconciler asks each node's view about two dozen of them, and
|
|
3
|
+
// a dynamic cast to a protocol existential is a conformance lookup each time;
|
|
4
|
+
// a node's answers are now a bit test. The casts that remain (to read the
|
|
5
|
+
// view's values) run only for the protocols the type conforms to.
|
|
6
|
+
//
|
|
7
|
+
// The answers come from the type, not the value: a cast of an `Optional`
|
|
8
|
+
// value unwraps it, so `Optional<SomeSheetView>.some(...)` used to answer
|
|
9
|
+
// "sheet" as well as "group" (running its `onAppear` twice, once per node).
|
|
10
|
+
// An optional is a group and nothing else.
|
|
11
|
+
|
|
12
|
+
/// Refined by every protocol `_ViewTraits` asks about, so that one lookup
|
|
13
|
+
/// answers "none of them" for a type that conforms to none: an app's own
|
|
14
|
+
/// views, most of a tree's types. In WebAssembly the first lookup of each
|
|
15
|
+
/// type and protocol scans every conformance record in the module (tens of
|
|
16
|
+
/// thousands in a large app), which made trait discovery a seventh of Ice
|
|
17
|
+
/// Cubes' Swift time at startup.
|
|
18
|
+
protocol _TraitBearing {}
|
|
19
|
+
|
|
20
|
+
/// Refined by the property protocols the runtime looks for in a view's
|
|
21
|
+
/// stored properties (`_reflectedProperties`), for the same reason.
|
|
22
|
+
public protocol _RuntimeProperty {}
|
|
23
|
+
|
|
24
|
+
/// A view that stores a `ViewModifier` or `ButtonStyle` whose own `@State`
|
|
25
|
+
/// and `@Environment` properties the runtime manages like the view's:
|
|
26
|
+
/// `ModifiedContent` and `_ButtonStyleBody`.
|
|
27
|
+
protocol _HoldsModifier: _TraitBearing {}
|
|
28
|
+
|
|
29
|
+
struct _ViewTraits: OptionSet {
|
|
30
|
+
let rawValue: UInt64
|
|
31
|
+
|
|
32
|
+
static let environmentModifying = _ViewTraits(rawValue: 1 << 0)
|
|
33
|
+
static let preferredColorScheme = _ViewTraits(rawValue: 1 << 1)
|
|
34
|
+
static let scrollTargetContainer = _ViewTraits(rawValue: 1 << 2)
|
|
35
|
+
static let navigationTitle = _ViewTraits(rawValue: 1 << 3)
|
|
36
|
+
static let onAppearing = _ViewTraits(rawValue: 1 << 4)
|
|
37
|
+
static let detents = _ViewTraits(rawValue: 1 << 5)
|
|
38
|
+
static let animated = _ViewTraits(rawValue: 1 << 6)
|
|
39
|
+
static let destinationRegistering = _ViewTraits(rawValue: 1 << 7)
|
|
40
|
+
static let splitSidebar = _ViewTraits(rawValue: 1 << 8)
|
|
41
|
+
static let listSelection = _ViewTraits(rawValue: 1 << 9)
|
|
42
|
+
static let taskStarting = _ViewTraits(rawValue: 1 << 10)
|
|
43
|
+
static let navigationSplit = _ViewTraits(rawValue: 1 << 11)
|
|
44
|
+
static let navigationStack = _ViewTraits(rawValue: 1 << 12)
|
|
45
|
+
static let navScreen = _ViewTraits(rawValue: 1 << 13)
|
|
46
|
+
static let navigationLink = _ViewTraits(rawValue: 1 << 14)
|
|
47
|
+
static let navigationValueLink = _ViewTraits(rawValue: 1 << 15)
|
|
48
|
+
static let tabView = _ViewTraits(rawValue: 1 << 16)
|
|
49
|
+
static let tabScreen = _ViewTraits(rawValue: 1 << 17)
|
|
50
|
+
static let picker = _ViewTraits(rawValue: 1 << 18)
|
|
51
|
+
static let geometryReading = _ViewTraits(rawValue: 1 << 19)
|
|
52
|
+
static let sheet = _ViewTraits(rawValue: 1 << 20)
|
|
53
|
+
static let alert = _ViewTraits(rawValue: 1 << 21)
|
|
54
|
+
static let group = _ViewTraits(rawValue: 1 << 22)
|
|
55
|
+
static let host = _ViewTraits(rawValue: 1 << 23)
|
|
56
|
+
static let refreshing = _ViewTraits(rawValue: 1 << 24)
|
|
57
|
+
static let environmentHandling = _ViewTraits(rawValue: 1 << 25)
|
|
58
|
+
static let tagProviding = _ViewTraits(rawValue: 1 << 26)
|
|
59
|
+
static let rowEditingDisabling = _ViewTraits(rawValue: 1 << 27)
|
|
60
|
+
static let deletableGroup = _ViewTraits(rawValue: 1 << 28)
|
|
61
|
+
static let accessibilityProviding = _ViewTraits(rawValue: 1 << 29)
|
|
62
|
+
static let onDisappearing = _ViewTraits(rawValue: 1 << 30)
|
|
63
|
+
static let preferenceWriting = _ViewTraits(rawValue: 1 << 31)
|
|
64
|
+
static let preferenceReading = _ViewTraits(rawValue: 1 << 32)
|
|
65
|
+
static let preferenceDecorating = _ViewTraits(rawValue: 1 << 33)
|
|
66
|
+
static let sizeReporting = _ViewTraits(rawValue: 1 << 34)
|
|
67
|
+
static let lazyRows = _ViewTraits(rawValue: 1 << 35)
|
|
68
|
+
static let section = _ViewTraits(rawValue: 1 << 36)
|
|
69
|
+
static let lazyMenu = _ViewTraits(rawValue: 1 << 37)
|
|
70
|
+
static let holdsModifier = _ViewTraits(rawValue: 1 << 38)
|
|
71
|
+
static let pathDrawing = _ViewTraits(rawValue: 1 << 39)
|
|
72
|
+
static let layoutValueProviding = _ViewTraits(rawValue: 1 << 40)
|
|
73
|
+
|
|
74
|
+
/// Views without a body of their own: the shim's containers and primitives.
|
|
75
|
+
static let bodiless: _ViewTraits = [.group, .host, .geometryReading, .sheet, .alert, .picker, .navigationLink]
|
|
76
|
+
|
|
77
|
+
/// Views that set something on an ancestor while reconciled.
|
|
78
|
+
static let contextWriting: _ViewTraits = [
|
|
79
|
+
.navigationTitle, .destinationRegistering, .detents, .listSelection, .navigationSplit,
|
|
80
|
+
.navigationStack, .navScreen, .splitSidebar, .tabView, .tabScreen,
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
nonisolated(unsafe) private static var known: [ObjectIdentifier: _ViewTraits] = [:]
|
|
84
|
+
|
|
85
|
+
nonisolated(unsafe) private static var knownDeclarations: [UnsafeRawPointer: _ViewTraits] = [:]
|
|
86
|
+
|
|
87
|
+
static func of(_ view: any View) -> _ViewTraits {
|
|
88
|
+
let type = type(of: view)
|
|
89
|
+
let key = ObjectIdentifier(type)
|
|
90
|
+
if let traits = known[key] { return traits }
|
|
91
|
+
// Every instantiation of a generic view (`ModifiedContent<A, B>`, a
|
|
92
|
+
// stack of some content) is a type of its own to the runtime, with
|
|
93
|
+
// lookups of its own; most of a tree's types are such instantiations
|
|
94
|
+
// of the shim's views. Their conformances to these protocols do not
|
|
95
|
+
// depend on the arguments (the only conditional ones, `Optional` and
|
|
96
|
+
// `ForEach`, require `View`, which a view's arguments satisfy), so
|
|
97
|
+
// the answers are kept per declaration too.
|
|
98
|
+
let declaration = nominalDescriptor(of: type)
|
|
99
|
+
if let declaration, let traits = knownDeclarations[declaration] {
|
|
100
|
+
known[key] = traits
|
|
101
|
+
return traits
|
|
102
|
+
}
|
|
103
|
+
let traits = compute(type)
|
|
104
|
+
known[key] = traits
|
|
105
|
+
if let declaration { knownDeclarations[declaration] = traits }
|
|
106
|
+
return traits
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/// Whether `type` is a struct (`MetadataKind` 0x200).
|
|
110
|
+
static func isStruct(_ type: Any.Type) -> Bool {
|
|
111
|
+
unsafeBitCast(type, to: UnsafeRawPointer.self).load(as: UInt.self) == 0x200
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/// The declaration a struct or enum type instantiates: the nominal type
|
|
115
|
+
/// descriptor in the second word of its metadata (ABI-stable layout). Nil
|
|
116
|
+
/// for other kinds of types (classes, tuples, functions).
|
|
117
|
+
private static func nominalDescriptor(of type: Any.Type) -> UnsafeRawPointer? {
|
|
118
|
+
let metadata = unsafeBitCast(type, to: UnsafeRawPointer.self)
|
|
119
|
+
// MetadataKind: struct 0x200, enum 0x201, optional 0x202.
|
|
120
|
+
switch metadata.load(as: UInt.self) {
|
|
121
|
+
case 0x200, 0x201, 0x202:
|
|
122
|
+
return metadata.load(fromByteOffset: MemoryLayout<UInt>.size, as: UnsafeRawPointer?.self)
|
|
123
|
+
default:
|
|
124
|
+
return nil
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
private static func compute(_ type: Any.Type) -> _ViewTraits {
|
|
129
|
+
var traits: _ViewTraits = []
|
|
130
|
+
func add(_ trait: _ViewTraits, _ conforms: Bool) { if conforms { traits.insert(trait) } }
|
|
131
|
+
add(.splitSidebar, type == _SplitSidebarView.self)
|
|
132
|
+
add(.navScreen, type == _NavScreenView.self)
|
|
133
|
+
add(.tabScreen, type == _TabScreenView.self)
|
|
134
|
+
guard type is any _TraitBearing.Type else { return traits }
|
|
135
|
+
add(.environmentModifying, type is any _EnvironmentModifying.Type)
|
|
136
|
+
add(.preferredColorScheme, type is any _PreferredColorSchemeModifying.Type)
|
|
137
|
+
add(.scrollTargetContainer, type is any _ScrollTargetContainer.Type)
|
|
138
|
+
add(.navigationTitle, type is any _NavigationTitleModifying.Type)
|
|
139
|
+
add(.onAppearing, type is any _OnAppearing.Type)
|
|
140
|
+
add(.onDisappearing, type is any _OnDisappearing.Type)
|
|
141
|
+
add(.detents, type is any _DetentsModifying.Type)
|
|
142
|
+
add(.animated, type is any _AnimatedView.Type)
|
|
143
|
+
add(.destinationRegistering, type is any _DestinationRegistering.Type)
|
|
144
|
+
add(.listSelection, type is any _ListSelectionProviding.Type)
|
|
145
|
+
add(.taskStarting, type is any _TaskStarting.Type)
|
|
146
|
+
add(.navigationSplit, type is any _NavigationSplitHost.Type)
|
|
147
|
+
add(.navigationStack, type is any _NavigationStackView.Type)
|
|
148
|
+
add(.navigationLink, type is any _NavigationLinkView.Type)
|
|
149
|
+
add(.navigationValueLink, type is any _NavigationValueLinkView.Type)
|
|
150
|
+
add(.tabView, type is any _TabViewHost.Type)
|
|
151
|
+
add(.picker, type is any _PickerHost.Type)
|
|
152
|
+
add(.geometryReading, type is any _GeometryReading.Type)
|
|
153
|
+
add(.sheet, type is any _SheetPresenting.Type)
|
|
154
|
+
add(.alert, type is any _AlertPresenting.Type)
|
|
155
|
+
add(.group, type is any _GroupView.Type)
|
|
156
|
+
add(.host, type is any _HostView.Type)
|
|
157
|
+
add(.refreshing, type is any _Refreshing.Type)
|
|
158
|
+
add(.environmentHandling, type is any _EnvironmentHandling.Type)
|
|
159
|
+
add(.tagProviding, type is any _TagProviding.Type)
|
|
160
|
+
add(.rowEditingDisabling, type is any _RowEditingDisabling.Type)
|
|
161
|
+
add(.accessibilityProviding, type is any _AccessibilityProviding.Type)
|
|
162
|
+
add(.deletableGroup, type is any _DeletableGroup.Type)
|
|
163
|
+
add(.preferenceWriting, type is any _PreferenceWriting.Type)
|
|
164
|
+
add(.preferenceReading, type is any _PreferenceReading.Type)
|
|
165
|
+
add(.preferenceDecorating, type is any _PreferenceValueDecorating.Type)
|
|
166
|
+
add(.sizeReporting, type is any _SizeReporting.Type)
|
|
167
|
+
add(.lazyRows, type is any _LazyRowsContainer.Type)
|
|
168
|
+
add(.section, type is any _SectionView.Type)
|
|
169
|
+
add(.lazyMenu, type is any _LazyMenuHost.Type)
|
|
170
|
+
add(.holdsModifier, type is any _HoldsModifier.Type)
|
|
171
|
+
add(.pathDrawing, type is any _PathDrawing.Type)
|
|
172
|
+
add(.layoutValueProviding, type is any _LayoutValueProviding.Type)
|
|
173
|
+
return traits
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Headless answers to `webAuth` requests (AuthenticationServices' sign-in
|
|
2
|
+
// window; docs/ops-protocol.md, "Signing in"). No page opens a window, so an
|
|
3
|
+
// `SB_RESPONSES` entry plays the provider: one whose `url` (exact) or
|
|
4
|
+
// `prefix` matches the authorize URL and that carries either
|
|
5
|
+
//
|
|
6
|
+
// - `callback`: the URL the window ends at, as is (the callback page's URL,
|
|
7
|
+
// or the app's own `myapp://?code=…`), or
|
|
8
|
+
// - `code`: the provider's usual answer, a redirect to the authorize URL's
|
|
9
|
+
// `redirect_uri` with `code` (and the request's `state`, if any) added.
|
|
10
|
+
//
|
|
11
|
+
// Without such an entry the viewer "closed the window": the request fails
|
|
12
|
+
// with `cancelled: …`, which the session reports as a cancelled login.
|
|
13
|
+
|
|
14
|
+
import Foundation
|
|
15
|
+
|
|
16
|
+
extension _Runtime {
|
|
17
|
+
/// The `response` fields (`value` or `error`) for a headless `webAuth` request.
|
|
18
|
+
nonisolated static func _headlessWebAuth(params: _JSON, fixtures: [_JSON]) -> [String: _JSON] {
|
|
19
|
+
guard case .object(let request) = params else { return ["error": .string("malformed request")] }
|
|
20
|
+
if case .string("cancel")? = request["action"] { return ["value": .object([:])] }
|
|
21
|
+
guard case .string(let url)? = request["url"] else { return ["error": .string("malformed request")] }
|
|
22
|
+
let fixture = fixtures.first { item in
|
|
23
|
+
guard case .object(let fields) = item, fields["callback"] != nil || fields["code"] != nil else { return false }
|
|
24
|
+
if case .string(let exact)? = fields["url"], exact == url { return true }
|
|
25
|
+
if case .string(let prefix)? = fields["prefix"], url.hasPrefix(prefix) { return true }
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
guard case .object(let fields)? = fixture else {
|
|
29
|
+
return ["error": .string("cancelled: headless, no SB_RESPONSES entry with a callback for \(url)")]
|
|
30
|
+
}
|
|
31
|
+
if case .string(let callback)? = fields["callback"] {
|
|
32
|
+
return ["value": .object(["url": .string(callback)])]
|
|
33
|
+
}
|
|
34
|
+
guard case .string(let code)? = fields["code"] else { return ["error": .string("malformed fixture")] }
|
|
35
|
+
let items = URLComponents(string: url)?.queryItems ?? []
|
|
36
|
+
guard let redirect = items.first(where: { $0.name == "redirect_uri" })?.value else {
|
|
37
|
+
return ["error": .string("headless: \(url) has no redirect_uri to send the code to")]
|
|
38
|
+
}
|
|
39
|
+
var added = "code=\(_queryEncoded(code))"
|
|
40
|
+
if let state = items.first(where: { $0.name == "state" })?.value { added += "&state=\(_queryEncoded(state))" }
|
|
41
|
+
let separator = redirect.contains("?") ? "&" : "?"
|
|
42
|
+
return ["value": .object(["url": .string(redirect + separator + added)])]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// Percent-encodes everything but RFC 3986's unreserved characters.
|
|
47
|
+
private func _queryEncoded(_ text: String) -> String {
|
|
48
|
+
text.addingPercentEncoding(withAllowedCharacters: CharacterSet(charactersIn: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~")) ?? text
|
|
49
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// `import Symbols` for the browser: SF Symbols' effect types. They are
|
|
2
|
+
// declared in the SwiftUI shim (API/SymbolEffects.swift), which re-exports
|
|
3
|
+
// them on iOS and whose `.symbolEffect` modifiers take them; this module
|
|
4
|
+
// re-exports them for files that import Symbols on its own. The page draws
|
|
5
|
+
// symbols as still glyphs, so effects keep their options and do not animate.
|
|
6
|
+
|
|
7
|
+
@_exported import protocol SwiftUI.SymbolEffect
|
|
8
|
+
@_exported import protocol SwiftUI.DiscreteSymbolEffect
|
|
9
|
+
@_exported import protocol SwiftUI.IndefiniteSymbolEffect
|
|
10
|
+
@_exported import protocol SwiftUI.TransitionSymbolEffect
|
|
11
|
+
@_exported import protocol SwiftUI.ContentTransitionSymbolEffect
|
|
12
|
+
@_exported import struct SwiftUI.SymbolEffectOptions
|
|
13
|
+
@_exported import struct SwiftUI.BounceSymbolEffect
|
|
14
|
+
@_exported import struct SwiftUI.PulseSymbolEffect
|
|
15
|
+
@_exported import struct SwiftUI.VariableColorSymbolEffect
|
|
16
|
+
@_exported import struct SwiftUI.ScaleSymbolEffect
|
|
17
|
+
@_exported import struct SwiftUI.AppearSymbolEffect
|
|
18
|
+
@_exported import struct SwiftUI.DisappearSymbolEffect
|
|
19
|
+
@_exported import struct SwiftUI.ReplaceSymbolEffect
|
|
20
|
+
@_exported import struct SwiftUI.AutomaticSymbolEffect
|
|
21
|
+
@_exported import struct SwiftUI.BreatheSymbolEffect
|
|
22
|
+
@_exported import struct SwiftUI.RotateSymbolEffect
|
|
23
|
+
@_exported import struct SwiftUI.WiggleSymbolEffect
|
|
24
|
+
@_exported import struct SwiftUI.DrawOnSymbolEffect
|
|
25
|
+
@_exported import struct SwiftUI.DrawOffSymbolEffect
|