@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
|
@@ -13,7 +13,7 @@ public struct Color: Hashable, Sendable {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/// A color from the asset catalog, possibly namespaced (`"dough/plain-bg"`).
|
|
16
|
-
///
|
|
16
|
+
/// `Color(_:bundle:)` is FoundationBridge's (see `Image.init(_:)`).
|
|
17
17
|
public init(_ name: String) {
|
|
18
18
|
storage = .named(name: name, opacity: 1)
|
|
19
19
|
}
|
|
@@ -26,20 +26,45 @@ public struct Color: Hashable, Sendable {
|
|
|
26
26
|
storage = .semantic(name: name, opacity: 1)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
public
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
/// A color from hue, saturation and brightness (each 0…1; a hue of 1 is red again).
|
|
30
|
+
public init(hue: Double, saturation: Double, brightness: Double, opacity: Double = 1) {
|
|
31
|
+
let h = (hue - hue.rounded(.down)) * 6
|
|
32
|
+
let s = max(0, min(1, saturation)), v = max(0, min(1, brightness))
|
|
33
|
+
let sector = Int(h) % 6
|
|
34
|
+
let f = h - Double(Int(h))
|
|
35
|
+
let (p, q, t) = (v * (1 - s), v * (1 - s * f), v * (1 - s * (1 - f)))
|
|
36
|
+
let (r, g, b): (Double, Double, Double) = switch sector {
|
|
37
|
+
case 0: (v, t, p)
|
|
38
|
+
case 1: (q, v, p)
|
|
39
|
+
case 2: (p, v, t)
|
|
40
|
+
case 3: (p, q, v)
|
|
41
|
+
case 4: (t, p, v)
|
|
42
|
+
default: (v, p, q)
|
|
43
|
+
}
|
|
44
|
+
storage = .rgba(red: r, green: g, blue: b, opacity: opacity)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// A semantic color the page resolves per color scheme, by its iOS name
|
|
48
|
+
/// (`label`, `systemGroupedBackground`…): UIKit's `Color(uiColor:)`.
|
|
49
|
+
public init(_semantic name: String, opacity: Double = 1) {
|
|
50
|
+
storage = .semantic(name: name, opacity: opacity)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// iOS system palette: semantic, so the page draws each in the color
|
|
54
|
+
// scheme's appearance (`--sb-color-<name>`), as iOS does.
|
|
55
|
+
public static let red = Color(semantic: "red")
|
|
56
|
+
public static let orange = Color(semantic: "orange")
|
|
57
|
+
public static let yellow = Color(semantic: "yellow")
|
|
58
|
+
public static let green = Color(semantic: "green")
|
|
59
|
+
public static let mint = Color(semantic: "mint")
|
|
60
|
+
public static let teal = Color(semantic: "teal")
|
|
61
|
+
public static let cyan = Color(semantic: "cyan")
|
|
62
|
+
public static let blue = Color(semantic: "blue")
|
|
63
|
+
public static let indigo = Color(semantic: "indigo")
|
|
64
|
+
public static let purple = Color(semantic: "purple")
|
|
65
|
+
public static let pink = Color(semantic: "pink")
|
|
66
|
+
public static let brown = Color(semantic: "brown")
|
|
67
|
+
public static let gray = Color(semantic: "gray")
|
|
43
68
|
public static let black = Color(red: 0, green: 0, blue: 0)
|
|
44
69
|
public static let white = Color(red: 1, green: 1, blue: 1)
|
|
45
70
|
|
|
@@ -74,17 +99,32 @@ public struct Color: Hashable, Sendable {
|
|
|
74
99
|
}
|
|
75
100
|
}
|
|
76
101
|
|
|
77
|
-
// MARK: - Shapes
|
|
78
|
-
|
|
79
|
-
|
|
102
|
+
// MARK: - Shapes
|
|
103
|
+
|
|
104
|
+
/// A 2D shape: its outline for a rectangle, drawn as a view (filled with the
|
|
105
|
+
/// foreground style unless `fill` or `stroke` say otherwise).
|
|
106
|
+
///
|
|
107
|
+
/// The built-in shapes (`_name` other than `"path"`) are drawn by the page
|
|
108
|
+
/// from their name and corner radius. Any other shape is drawn from its
|
|
109
|
+
/// `path(in:)` (Shape.swift): the page reports the size it laid the shape out
|
|
110
|
+
/// at, and the path for that size comes back as SVG, one render later.
|
|
111
|
+
public protocol Shape: Sendable, Animatable, View {
|
|
112
|
+
func path(in rect: CGRect) -> Path
|
|
113
|
+
/// The built-in shape the page draws by name, or `"path"`.
|
|
80
114
|
var _name: String { get }
|
|
81
115
|
var _cornerRadius: CGFloat { get }
|
|
82
116
|
}
|
|
83
117
|
|
|
84
|
-
|
|
118
|
+
nonisolated extension Shape {
|
|
119
|
+
public var _name: String { "path" }
|
|
120
|
+
public var _cornerRadius: CGFloat { 0 }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
nonisolated public struct Rectangle: Shape {
|
|
85
124
|
public init() {}
|
|
86
125
|
public var _name: String { "rectangle" }
|
|
87
126
|
public var _cornerRadius: CGFloat { 0 }
|
|
127
|
+
public func path(in rect: CGRect) -> Path { Path(rect) }
|
|
88
128
|
}
|
|
89
129
|
|
|
90
130
|
/// Accepted for source compatibility; corners render continuous either way.
|
|
@@ -92,7 +132,7 @@ public enum RoundedCornerStyle: Hashable, Sendable {
|
|
|
92
132
|
case circular, continuous
|
|
93
133
|
}
|
|
94
134
|
|
|
95
|
-
public struct RoundedRectangle: Shape {
|
|
135
|
+
nonisolated public struct RoundedRectangle: Shape {
|
|
96
136
|
public var cornerRadius: CGFloat
|
|
97
137
|
public var style: RoundedCornerStyle
|
|
98
138
|
public init(cornerRadius: CGFloat, style: RoundedCornerStyle = .continuous) {
|
|
@@ -105,32 +145,68 @@ public struct RoundedRectangle: Shape {
|
|
|
105
145
|
}
|
|
106
146
|
public var _name: String { "roundedRectangle" }
|
|
107
147
|
public var _cornerRadius: CGFloat { cornerRadius }
|
|
148
|
+
public func path(in rect: CGRect) -> Path { Path(roundedRect: rect, cornerRadius: cornerRadius, style: style) }
|
|
108
149
|
}
|
|
109
150
|
|
|
110
|
-
public struct Circle: Shape {
|
|
151
|
+
nonisolated public struct Circle: Shape {
|
|
111
152
|
public init() {}
|
|
112
153
|
public var _name: String { "circle" }
|
|
113
154
|
public var _cornerRadius: CGFloat { 9999 }
|
|
155
|
+
/// The largest circle centered in `rect`.
|
|
156
|
+
public func path(in rect: CGRect) -> Path {
|
|
157
|
+
let side = min(rect.width, rect.height)
|
|
158
|
+
return Path(ellipseIn: CGRect(x: rect.midX - side / 2, y: rect.midY - side / 2, width: side, height: side))
|
|
159
|
+
}
|
|
114
160
|
}
|
|
115
161
|
|
|
116
|
-
public struct Capsule: Shape {
|
|
117
|
-
public
|
|
162
|
+
nonisolated public struct Capsule: Shape {
|
|
163
|
+
public var style: RoundedCornerStyle
|
|
164
|
+
public init(style: RoundedCornerStyle = .continuous) { self.style = style }
|
|
118
165
|
public var _name: String { "capsule" }
|
|
119
166
|
public var _cornerRadius: CGFloat { 9999 }
|
|
167
|
+
public func path(in rect: CGRect) -> Path {
|
|
168
|
+
Path(roundedRect: rect, cornerRadius: min(rect.width, rect.height) / 2, style: style)
|
|
169
|
+
}
|
|
120
170
|
}
|
|
121
171
|
|
|
122
|
-
public struct Ellipse: Shape {
|
|
172
|
+
nonisolated public struct Ellipse: Shape {
|
|
123
173
|
public init() {}
|
|
124
174
|
public var _name: String { "ellipse" }
|
|
125
175
|
public var _cornerRadius: CGFloat { 9999 }
|
|
176
|
+
public func path(in rect: CGRect) -> Path { Path(ellipseIn: rect) }
|
|
126
177
|
}
|
|
127
178
|
|
|
128
|
-
/// The container
|
|
129
|
-
///
|
|
130
|
-
|
|
179
|
+
/// The shape of the nearest container (`.containerShape(_:)`): its corner
|
|
180
|
+
/// radius, read from the environment where the shape is drawn
|
|
181
|
+
/// (`_resolvedCornerRadius`); a rectangle when no container sets one, as in
|
|
182
|
+
/// SwiftUI. Its own path (a custom shape's use) is a rectangle.
|
|
183
|
+
nonisolated public struct ContainerRelativeShape: Shape {
|
|
131
184
|
public init() {}
|
|
132
185
|
public var _name: String { "containerRelative" }
|
|
133
|
-
public var _cornerRadius: CGFloat {
|
|
186
|
+
public var _cornerRadius: CGFloat { 0 }
|
|
187
|
+
public func path(in rect: CGRect) -> Path { Path(rect) }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// The corner radius `shape` is drawn with in `environment`: a
|
|
191
|
+
/// `ContainerRelativeShape` takes its container's.
|
|
192
|
+
func _resolvedCornerRadius(_ shape: some Shape, in environment: EnvironmentValues) -> CGFloat {
|
|
193
|
+
if shape is ContainerRelativeShape { return environment._containerShapeRadius ?? 0 }
|
|
194
|
+
if let inset = shape as? _InsetShape<ContainerRelativeShape> {
|
|
195
|
+
return max(0, (environment._containerShapeRadius ?? 0) - inset.amount)
|
|
196
|
+
}
|
|
197
|
+
return shape._cornerRadius
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private struct _ContainerShapeRadiusKey: EnvironmentKey {
|
|
201
|
+
static var defaultValue: CGFloat? { nil }
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
extension EnvironmentValues {
|
|
205
|
+
/// The corner radius of the shape `.containerShape(_:)` set above (nil: none).
|
|
206
|
+
var _containerShapeRadius: CGFloat? {
|
|
207
|
+
get { self[_ContainerShapeRadiusKey.self] }
|
|
208
|
+
set { self[_ContainerShapeRadiusKey.self] = newValue }
|
|
209
|
+
}
|
|
134
210
|
}
|
|
135
211
|
|
|
136
212
|
// Shapes as static members (`.clipShape(.capsule)`, `.background(.red, in: .rect(cornerRadius: 8))`).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// Color adjustments of a rendered view: `.brightness`, `.saturation`,
|
|
2
|
+
/// `.contrast`, `.grayscale`, `.hueRotation`, `.colorInvert` and `.colorMultiply`. Each is a
|
|
3
|
+
/// style key the page draws as a CSS filter on the view's box (Web/src/
|
|
4
|
+
/// styles.ts `effectsCSS`), so nested modifiers apply innermost first, as
|
|
5
|
+
/// in SwiftUI. Saturation, contrast, grayscale, hue rotation and inversion
|
|
6
|
+
/// are CSS's own filters. SwiftUI's brightness adds `amount` to each color
|
|
7
|
+
/// component, which CSS has no filter for: it is drawn as CSS
|
|
8
|
+
/// `brightness(1 + amount)`, which scales them (the same for mid-gray, darker
|
|
9
|
+
/// for dark colors, and black stays black).
|
|
10
|
+
|
|
11
|
+
nonisolated extension View {
|
|
12
|
+
/// Brightens (positive) or darkens (negative) the view; `amount` is in -1…1.
|
|
13
|
+
public func brightness(_ amount: Double) -> some View {
|
|
14
|
+
_styled { $0.extras["brightness"] = .number(amount) }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// Scales the colors' saturation: 0 is gray, 1 unchanged.
|
|
18
|
+
public func saturation(_ amount: Double) -> some View {
|
|
19
|
+
_styled { $0.extras["saturation"] = .number(amount) }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// Scales the contrast: 0 is mid-gray, 1 unchanged.
|
|
23
|
+
public func contrast(_ amount: Double) -> some View {
|
|
24
|
+
_styled { $0.extras["contrast"] = .number(amount) }
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// Removes `amount` (0…1) of the colors' saturation.
|
|
28
|
+
public func grayscale(_ amount: Double) -> some View {
|
|
29
|
+
_styled { $0.extras["grayscale"] = .number(amount) }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// Turns the colors' hue by `angle`.
|
|
33
|
+
public func hueRotation(_ angle: Angle) -> some View {
|
|
34
|
+
_styled { $0.extras["hueRotation"] = .number(angle.degrees) }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// Inverts the colors.
|
|
38
|
+
public func colorInvert() -> some View {
|
|
39
|
+
_styled { $0.extras["colorInvert"] = .bool(true) }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/// Multiplies each color component (and the alpha) by `color`'s: a white
|
|
43
|
+
/// shape takes the color, a black one stays black. The page draws it with
|
|
44
|
+
/// an SVG `feColorMatrix` filter.
|
|
45
|
+
public func colorMultiply(_ color: Color) -> some View {
|
|
46
|
+
_styled { $0.extras["colorMultiply"] = color._json }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// Mirrors the view in a right-to-left layout. The page lays out left to
|
|
50
|
+
/// right, so the view draws as it is.
|
|
51
|
+
public func flipsForRightToLeftLayoutDirection(_ enabled: Bool) -> some View { self }
|
|
52
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// `ColorPicker` and `LabeledContent`.
|
|
4
|
+
///
|
|
5
|
+
/// - `ColorPicker` is a row with its label and a swatch of the color, as on
|
|
6
|
+
/// iOS. Tapping it opens the browser's color chooser through a `pickColor`
|
|
7
|
+
/// host request (`{ "color": "#rrggbb" }`, answered with the chosen color,
|
|
8
|
+
/// or `{}` when the viewer closes it; Web/src/colorPicker.ts), sent within
|
|
9
|
+
/// the tap as a browser requires. The chooser has no opacity: a picked
|
|
10
|
+
/// color is opaque, whatever `supportsOpacity` says. A catalog color starts
|
|
11
|
+
/// the chooser at mid gray (`Color.resolve(in:)`'s answer for it).
|
|
12
|
+
/// Headless runs answer `{}`.
|
|
13
|
+
/// - `LabeledContent` is its label and, after a spacer, its content in the
|
|
14
|
+
/// secondary style: the row a form shows. `.labeledContentStyle` is accepted.
|
|
15
|
+
|
|
16
|
+
public struct ColorPicker<Label: View>: View {
|
|
17
|
+
let selection: Binding<Color>
|
|
18
|
+
let label: Label
|
|
19
|
+
|
|
20
|
+
public init(selection: Binding<Color>, supportsOpacity: Bool = true, @ViewBuilder label: () -> Label) {
|
|
21
|
+
self.selection = selection
|
|
22
|
+
self.label = label()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public var body: some View {
|
|
26
|
+
let selection = selection
|
|
27
|
+
return Button {
|
|
28
|
+
let hex = Self.hex(selection.wrappedValue)
|
|
29
|
+
Task { @MainActor in
|
|
30
|
+
let answer = try? await _Runtime.shared._hostRequest(kind: "pickColor", params: .object(["color": .string(hex)]),
|
|
31
|
+
headless: .object([:]))
|
|
32
|
+
guard case .object(let fields)? = answer, case .string(let chosen)? = fields["color"],
|
|
33
|
+
let color = Self.color(hex: chosen) else { return }
|
|
34
|
+
selection.wrappedValue = color
|
|
35
|
+
}
|
|
36
|
+
} label: {
|
|
37
|
+
HStack {
|
|
38
|
+
label
|
|
39
|
+
Spacer()
|
|
40
|
+
Circle()
|
|
41
|
+
.fill(selection.wrappedValue)
|
|
42
|
+
.frame(width: 28, height: 28)
|
|
43
|
+
.overlay(Circle().strokeBorder(Color.secondary.opacity(0.3), lineWidth: 1))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
.buttonStyle(.plain)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// `#rrggbb` of the color's sRGB components.
|
|
50
|
+
static func hex(_ color: Color) -> String {
|
|
51
|
+
let resolved = color.resolve(in: EnvironmentValues())
|
|
52
|
+
func byte(_ value: Float) -> String {
|
|
53
|
+
let n = Int((min(1, max(0, value)) * 255).rounded())
|
|
54
|
+
let digits = String(n, radix: 16)
|
|
55
|
+
return n < 16 ? "0" + digits : digits
|
|
56
|
+
}
|
|
57
|
+
return "#" + byte(resolved.red) + byte(resolved.green) + byte(resolved.blue)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// The color of `#rrggbb`, or nil.
|
|
61
|
+
static func color(hex: String) -> Color? {
|
|
62
|
+
let digits = hex.hasPrefix("#") ? String(hex.dropFirst()) : hex
|
|
63
|
+
guard digits.count == 6, let value = Int(digits, radix: 16) else { return nil }
|
|
64
|
+
return Color(red: Double((value >> 16) & 0xFF) / 255, green: Double((value >> 8) & 0xFF) / 255,
|
|
65
|
+
blue: Double(value & 0xFF) / 255)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
extension ColorPicker where Label == Text {
|
|
70
|
+
public init(_ titleKey: LocalizedStringKey, selection: Binding<Color>, supportsOpacity: Bool = true) {
|
|
71
|
+
self.init(selection: selection, supportsOpacity: supportsOpacity) { Text(titleKey) }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@_disfavoredOverload
|
|
75
|
+
public init<S: StringProtocol>(_ title: S, selection: Binding<Color>, supportsOpacity: Bool = true) {
|
|
76
|
+
self.init(selection: selection, supportsOpacity: supportsOpacity) { Text(title) }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public struct LabeledContent<Label: View, Content: View>: View {
|
|
81
|
+
let label: Label
|
|
82
|
+
let content: Content
|
|
83
|
+
|
|
84
|
+
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label) {
|
|
85
|
+
self.content = content()
|
|
86
|
+
self.label = label()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public var body: some View {
|
|
90
|
+
HStack {
|
|
91
|
+
label
|
|
92
|
+
Spacer()
|
|
93
|
+
content.foregroundStyle(.secondary)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
extension LabeledContent where Label == Text, Content == Text {
|
|
99
|
+
public init<S: StringProtocol>(_ titleKey: LocalizedStringKey, value: S) {
|
|
100
|
+
self.init(content: { Text(value) }, label: { Text(titleKey) })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@_disfavoredOverload
|
|
104
|
+
public init<S1: StringProtocol, S2: StringProtocol>(_ title: S1, value: S2) {
|
|
105
|
+
self.init(content: { Text(value) }, label: { Text(title) })
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public init<F: FormatStyle>(_ titleKey: LocalizedStringKey, value: F.FormatInput, format: F) where F.FormatOutput == String {
|
|
109
|
+
self.init(content: { Text(format.format(value)) }, label: { Text(titleKey) })
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@_disfavoredOverload
|
|
113
|
+
public init<S: StringProtocol, F: FormatStyle>(_ title: S, value: F.FormatInput, format: F) where F.FormatOutput == String {
|
|
114
|
+
self.init(content: { Text(format.format(value)) }, label: { Text(title) })
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
extension LabeledContent where Label == Text {
|
|
119
|
+
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content) {
|
|
120
|
+
self.init(content: content, label: { Text(titleKey) })
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@_disfavoredOverload
|
|
124
|
+
public init<S: StringProtocol>(_ title: S, @ViewBuilder content: () -> Content) {
|
|
125
|
+
self.init(content: content, label: { Text(title) })
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// How labeled content is drawn; accepted.
|
|
130
|
+
public protocol LabeledContentStyle {}
|
|
131
|
+
public struct AutomaticLabeledContentStyle: LabeledContentStyle { public init() {} }
|
|
132
|
+
extension LabeledContentStyle where Self == AutomaticLabeledContentStyle {
|
|
133
|
+
public static var automatic: AutomaticLabeledContentStyle { AutomaticLabeledContentStyle() }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
nonisolated extension View {
|
|
137
|
+
public func labeledContentStyle<S: LabeledContentStyle>(_ style: S) -> some View { self }
|
|
138
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
// `Color(.sRGB, red:green:blue:opacity:)` and friends. The page paints in
|
|
4
|
+
// sRGB: sRGB components pass through, linear sRGB components are gamma
|
|
5
|
+
// encoded first, and Display P3 components are taken as sRGB (an
|
|
6
|
+
// approximation: a P3 color outside the sRGB gamut is clipped to its edge,
|
|
7
|
+
// and one inside shifts slightly).
|
|
8
|
+
|
|
9
|
+
extension Color {
|
|
10
|
+
public enum RGBColorSpace: Hashable, Sendable {
|
|
11
|
+
case sRGB
|
|
12
|
+
case sRGBLinear
|
|
13
|
+
case displayP3
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public init(_ colorSpace: RGBColorSpace, red: Double, green: Double, blue: Double, opacity: Double = 1) {
|
|
17
|
+
if colorSpace == .sRGBLinear {
|
|
18
|
+
self.init(red: Color._sRGBEncoded(red), green: Color._sRGBEncoded(green), blue: Color._sRGBEncoded(blue),
|
|
19
|
+
opacity: opacity)
|
|
20
|
+
} else {
|
|
21
|
+
self.init(red: red, green: green, blue: blue, opacity: opacity)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public init(_ colorSpace: RGBColorSpace, white: Double, opacity: Double = 1) {
|
|
26
|
+
let value = colorSpace == .sRGBLinear ? Color._sRGBEncoded(white) : white
|
|
27
|
+
self.init(white: value, opacity: opacity)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/// The sRGB transfer function: a linear component to its encoded form.
|
|
31
|
+
static func _sRGBEncoded(_ linear: Double) -> Double {
|
|
32
|
+
let value = min(max(linear, 0), 1)
|
|
33
|
+
return value <= 0.0031308 ? 12.92 * value : 1.055 * pow(value, 1 / 2.4) - 0.055
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// MARK: - Resolved colors
|
|
38
|
+
|
|
39
|
+
// `Color.resolve(in:)` (iOS 17): the color's sRGB components. Explicit
|
|
40
|
+
// colors resolve exactly. The semantic colors resolve to their iOS values
|
|
41
|
+
// for the environment's color scheme (primary black or white, secondary the
|
|
42
|
+
// label gray at 60 %, the accent system blue). An asset catalog color is
|
|
43
|
+
// only known to the page, so it resolves to a mid gray (an approximation).
|
|
44
|
+
|
|
45
|
+
extension Color {
|
|
46
|
+
public struct Resolved: Hashable, Sendable {
|
|
47
|
+
public var red: Float
|
|
48
|
+
public var green: Float
|
|
49
|
+
public var blue: Float
|
|
50
|
+
public var opacity: Float
|
|
51
|
+
|
|
52
|
+
public init(red: Float, green: Float, blue: Float, opacity: Float = 1) {
|
|
53
|
+
self.red = red
|
|
54
|
+
self.green = green
|
|
55
|
+
self.blue = blue
|
|
56
|
+
self.opacity = opacity
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public init(colorSpace: RGBColorSpace = .sRGB, red: Float, green: Float, blue: Float, opacity: Float = 1) {
|
|
60
|
+
if colorSpace == .sRGBLinear {
|
|
61
|
+
self.init(red: Float(Color._sRGBEncoded(Double(red))), green: Float(Color._sRGBEncoded(Double(green))),
|
|
62
|
+
blue: Float(Color._sRGBEncoded(Double(blue))), opacity: opacity)
|
|
63
|
+
} else {
|
|
64
|
+
self.init(red: red, green: green, blue: blue, opacity: opacity)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// The components without the sRGB transfer function.
|
|
69
|
+
public var linearRed: Float { Self.linear(red) }
|
|
70
|
+
public var linearGreen: Float { Self.linear(green) }
|
|
71
|
+
public var linearBlue: Float { Self.linear(blue) }
|
|
72
|
+
|
|
73
|
+
static func linear(_ encoded: Float) -> Float {
|
|
74
|
+
encoded <= 0.04045 ? encoded / 12.92 : powf((encoded + 0.055) / 1.055, 2.4)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public init(_ resolved: Resolved) {
|
|
79
|
+
self.init(red: Double(resolved.red), green: Double(resolved.green), blue: Double(resolved.blue),
|
|
80
|
+
opacity: Double(resolved.opacity))
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public func resolve(in environment: EnvironmentValues) -> Resolved {
|
|
84
|
+
let dark = environment.colorScheme == .dark
|
|
85
|
+
func resolved(_ r: Double, _ g: Double, _ b: Double, _ a: Double) -> Resolved {
|
|
86
|
+
Resolved(red: Float(r), green: Float(g), blue: Float(b), opacity: Float(a))
|
|
87
|
+
}
|
|
88
|
+
switch storage {
|
|
89
|
+
case .rgba(let r, let g, let b, let a):
|
|
90
|
+
return resolved(r, g, b, a)
|
|
91
|
+
case .semantic(let name, let a):
|
|
92
|
+
switch name {
|
|
93
|
+
case "primary": return dark ? resolved(1, 1, 1, a) : resolved(0, 0, 0, a)
|
|
94
|
+
case "secondary":
|
|
95
|
+
return dark ? resolved(0.922, 0.922, 0.961, 0.6 * a) : resolved(0.235, 0.235, 0.263, 0.6 * a)
|
|
96
|
+
case "accent": return dark ? resolved(0.039, 0.518, 1, a) : resolved(0, 0.478, 1, a)
|
|
97
|
+
case "clear": return resolved(0, 0, 0, 0)
|
|
98
|
+
default:
|
|
99
|
+
guard let (light, darkValue) = Color.semanticValues[name] else { return resolved(0.5, 0.5, 0.5, a) }
|
|
100
|
+
let c = dark ? darkValue : light
|
|
101
|
+
return resolved(c.0, c.1, c.2, c.3 * a)
|
|
102
|
+
}
|
|
103
|
+
case .named(_, let a):
|
|
104
|
+
return resolved(0.5, 0.5, 0.5, a)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
extension Color {
|
|
110
|
+
/// The system palette and UIKit's semantic colors (`Color(uiColor:)`),
|
|
111
|
+
/// light and dark, as iOS defines them; the page's tokens for them
|
|
112
|
+
/// (styles.css) match.
|
|
113
|
+
static let semanticValues: [String: (light: (Double, Double, Double, Double), dark: (Double, Double, Double, Double))] = {
|
|
114
|
+
func rgb(_ r: Double, _ g: Double, _ b: Double, _ a: Double = 1) -> (Double, Double, Double, Double) { (r / 255, g / 255, b / 255, a) }
|
|
115
|
+
return [
|
|
116
|
+
"red": (rgb(255, 59, 48), rgb(255, 69, 58)),
|
|
117
|
+
"orange": (rgb(255, 149, 0), rgb(255, 159, 10)),
|
|
118
|
+
"yellow": (rgb(255, 204, 0), rgb(255, 214, 10)),
|
|
119
|
+
"green": (rgb(52, 199, 89), rgb(48, 209, 88)),
|
|
120
|
+
"mint": (rgb(0, 199, 190), rgb(99, 230, 226)),
|
|
121
|
+
"teal": (rgb(48, 176, 199), rgb(64, 200, 224)),
|
|
122
|
+
"cyan": (rgb(50, 173, 230), rgb(100, 210, 255)),
|
|
123
|
+
"blue": (rgb(0, 122, 255), rgb(10, 132, 255)),
|
|
124
|
+
"indigo": (rgb(88, 86, 214), rgb(94, 92, 230)),
|
|
125
|
+
"purple": (rgb(175, 82, 222), rgb(191, 90, 242)),
|
|
126
|
+
"pink": (rgb(255, 45, 85), rgb(255, 55, 95)),
|
|
127
|
+
"brown": (rgb(162, 132, 94), rgb(172, 142, 104)),
|
|
128
|
+
"gray": (rgb(142, 142, 147), rgb(142, 142, 147)),
|
|
129
|
+
"systemBackground": (rgb(255, 255, 255), rgb(0, 0, 0)),
|
|
130
|
+
"secondarySystemBackground": (rgb(242, 242, 247), rgb(28, 28, 30)),
|
|
131
|
+
"tertiarySystemBackground": (rgb(255, 255, 255), rgb(44, 44, 46)),
|
|
132
|
+
"systemGroupedBackground": (rgb(242, 242, 247), rgb(0, 0, 0)),
|
|
133
|
+
"secondarySystemGroupedBackground": (rgb(255, 255, 255), rgb(28, 28, 30)),
|
|
134
|
+
"tertiarySystemGroupedBackground": (rgb(242, 242, 247), rgb(44, 44, 46)),
|
|
135
|
+
"label": (rgb(0, 0, 0), rgb(255, 255, 255)),
|
|
136
|
+
"secondaryLabel": (rgb(60, 60, 67, 0.6), rgb(235, 235, 245, 0.6)),
|
|
137
|
+
"tertiaryLabel": (rgb(60, 60, 67, 0.3), rgb(235, 235, 245, 0.3)),
|
|
138
|
+
"quaternaryLabel": (rgb(60, 60, 67, 0.18), rgb(235, 235, 245, 0.16)),
|
|
139
|
+
"placeholderText": (rgb(60, 60, 67, 0.3), rgb(235, 235, 245, 0.3)),
|
|
140
|
+
"separator": (rgb(60, 60, 67, 0.29), rgb(84, 84, 88, 0.6)),
|
|
141
|
+
"opaqueSeparator": (rgb(198, 198, 200), rgb(56, 56, 58)),
|
|
142
|
+
"systemFill": (rgb(120, 120, 128, 0.2), rgb(120, 120, 128, 0.36)),
|
|
143
|
+
"secondarySystemFill": (rgb(120, 120, 128, 0.16), rgb(120, 120, 128, 0.32)),
|
|
144
|
+
"tertiarySystemFill": (rgb(118, 118, 128, 0.12), rgb(118, 118, 128, 0.24)),
|
|
145
|
+
"quaternarySystemFill": (rgb(116, 116, 128, 0.08), rgb(118, 118, 128, 0.18)),
|
|
146
|
+
"systemGray2": (rgb(174, 174, 178), rgb(99, 99, 102)),
|
|
147
|
+
"systemGray3": (rgb(199, 199, 204), rgb(72, 72, 74)),
|
|
148
|
+
"systemGray4": (rgb(209, 209, 214), rgb(58, 58, 60)),
|
|
149
|
+
"systemGray5": (rgb(229, 229, 234), rgb(44, 44, 46)),
|
|
150
|
+
"systemGray6": (rgb(242, 242, 247), rgb(28, 28, 30)),
|
|
151
|
+
]
|
|
152
|
+
}()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// A resolved color paints as its components, as in SwiftUI (iOS 17), and is
|
|
156
|
+
/// what `Color` resolves to as a `ShapeStyle`.
|
|
157
|
+
extension Color.Resolved: ShapeStyle {
|
|
158
|
+
public var _json: _JSON {
|
|
159
|
+
.object(["r": .number(Double(red)), "g": .number(Double(green)), "b": .number(Double(blue)), "a": .number(Double(opacity))])
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/// The menu bar's commands (iPad and Mac): `Commands`, `CommandGroup`,
|
|
2
|
+
/// `CommandMenu` and `.commands { }`. The page shows an iPhone, which has no
|
|
3
|
+
/// menu bar, so the commands are built and not shown; their buttons'
|
|
4
|
+
/// keyboard shortcuts do nothing either (PointerAndKeyboard.swift).
|
|
5
|
+
|
|
6
|
+
@MainActor @preconcurrency
|
|
7
|
+
public protocol Commands {
|
|
8
|
+
associatedtype Body: Commands
|
|
9
|
+
@CommandsBuilder var body: Body { get }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
extension Never: Commands {}
|
|
13
|
+
|
|
14
|
+
extension Commands where Body == Never {
|
|
15
|
+
public var body: Never { fatalError("\(Self.self) is a primitive command") }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// No commands.
|
|
19
|
+
public struct EmptyCommands: Commands {
|
|
20
|
+
public typealias Body = Never
|
|
21
|
+
public init() {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Several commands in order.
|
|
25
|
+
public struct _CommandsList: Commands {
|
|
26
|
+
public typealias Body = Never
|
|
27
|
+
let parts: [any Commands]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@resultBuilder @MainActor
|
|
31
|
+
public enum CommandsBuilder {
|
|
32
|
+
public static func buildBlock() -> EmptyCommands { EmptyCommands() }
|
|
33
|
+
public static func buildBlock<C: Commands>(_ content: C) -> C { content }
|
|
34
|
+
public static func buildBlock<each C: Commands>(_ content: repeat each C) -> _CommandsList {
|
|
35
|
+
var parts: [any Commands] = []
|
|
36
|
+
for part in repeat each content { parts.append(part) }
|
|
37
|
+
return _CommandsList(parts: parts)
|
|
38
|
+
}
|
|
39
|
+
public static func buildExpression<C: Commands>(_ content: C) -> C { content }
|
|
40
|
+
public static func buildOptional<C: Commands>(_ content: C?) -> _CommandsList { _CommandsList(parts: content.map { [$0] } ?? []) }
|
|
41
|
+
public static func buildEither<C: Commands>(first content: C) -> _CommandsList { _CommandsList(parts: [content]) }
|
|
42
|
+
public static func buildEither<C: Commands>(second content: C) -> _CommandsList { _CommandsList(parts: [content]) }
|
|
43
|
+
public static func buildLimitedAvailability<C: Commands>(_ content: C) -> _CommandsList { _CommandsList(parts: [content]) }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// Where a command group goes among the standard menus' items.
|
|
47
|
+
public struct CommandGroupPlacement: Sendable {
|
|
48
|
+
let name: String
|
|
49
|
+
public static let appInfo = CommandGroupPlacement(name: "appInfo")
|
|
50
|
+
public static let appSettings = CommandGroupPlacement(name: "appSettings")
|
|
51
|
+
public static let systemServices = CommandGroupPlacement(name: "systemServices")
|
|
52
|
+
public static let appVisibility = CommandGroupPlacement(name: "appVisibility")
|
|
53
|
+
public static let appTermination = CommandGroupPlacement(name: "appTermination")
|
|
54
|
+
public static let newItem = CommandGroupPlacement(name: "newItem")
|
|
55
|
+
public static let saveItem = CommandGroupPlacement(name: "saveItem")
|
|
56
|
+
public static let importExport = CommandGroupPlacement(name: "importExport")
|
|
57
|
+
public static let printItem = CommandGroupPlacement(name: "printItem")
|
|
58
|
+
public static let undoRedo = CommandGroupPlacement(name: "undoRedo")
|
|
59
|
+
public static let pasteboard = CommandGroupPlacement(name: "pasteboard")
|
|
60
|
+
public static let textEditing = CommandGroupPlacement(name: "textEditing")
|
|
61
|
+
public static let textFormatting = CommandGroupPlacement(name: "textFormatting")
|
|
62
|
+
public static let toolbar = CommandGroupPlacement(name: "toolbar")
|
|
63
|
+
public static let sidebar = CommandGroupPlacement(name: "sidebar")
|
|
64
|
+
public static let windowSize = CommandGroupPlacement(name: "windowSize")
|
|
65
|
+
public static let windowList = CommandGroupPlacement(name: "windowList")
|
|
66
|
+
public static let singleWindowList = CommandGroupPlacement(name: "singleWindowList")
|
|
67
|
+
public static let windowArrangement = CommandGroupPlacement(name: "windowArrangement")
|
|
68
|
+
public static let help = CommandGroupPlacement(name: "help")
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// Items added to, or replacing, a standard menu's group.
|
|
72
|
+
public struct CommandGroup<Content: View>: Commands {
|
|
73
|
+
public typealias Body = Never
|
|
74
|
+
let content: Content
|
|
75
|
+
|
|
76
|
+
public init(before group: CommandGroupPlacement, @ViewBuilder addition: () -> Content) { content = addition() }
|
|
77
|
+
public init(after group: CommandGroupPlacement, @ViewBuilder addition: () -> Content) { content = addition() }
|
|
78
|
+
public init(replacing group: CommandGroupPlacement, @ViewBuilder addition: () -> Content) { content = addition() }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/// A menu of the app's own in the menu bar.
|
|
82
|
+
public struct CommandMenu<Content: View>: Commands {
|
|
83
|
+
public typealias Body = Never
|
|
84
|
+
let content: Content
|
|
85
|
+
|
|
86
|
+
public init(_ nameKey: LocalizedStringKey, @ViewBuilder content: () -> Content) { self.content = content() }
|
|
87
|
+
public init(_ name: Text, @ViewBuilder content: () -> Content) { self.content = content() }
|
|
88
|
+
@_disfavoredOverload
|
|
89
|
+
public init<S: StringProtocol>(_ name: S, @ViewBuilder content: () -> Content) { self.content = content() }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/// The standard command sets.
|
|
93
|
+
public struct SidebarCommands: Commands { public typealias Body = Never; public init() {} }
|
|
94
|
+
public struct ToolbarCommands: Commands { public typealias Body = Never; public init() {} }
|
|
95
|
+
public struct TextEditingCommands: Commands { public typealias Body = Never; public init() {} }
|
|
96
|
+
public struct TextFormattingCommands: Commands { public typealias Body = Never; public init() {} }
|
|
97
|
+
public struct InspectorCommands: Commands { public typealias Body = Never; public init() {} }
|
|
98
|
+
public struct ImportFromDevicesCommands: Commands { public typealias Body = Never; public init() {} }
|
|
99
|
+
|
|
100
|
+
extension Scene {
|
|
101
|
+
/// Accepted: there is no menu bar (see the file comment).
|
|
102
|
+
public func commands<C: Commands>(@CommandsBuilder content: () -> C) -> some Scene {
|
|
103
|
+
_ = content()
|
|
104
|
+
return self
|
|
105
|
+
}
|
|
106
|
+
}
|