@swiftbrowser/swift 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/Package.swift +214 -0
  2. package/README.md +10 -2
  3. package/Sources/AVFoundation/AVFoundation.swift +131 -0
  4. package/Sources/AVFoundation/Asset.swift +487 -0
  5. package/Sources/AVFoundation/AudioSession.swift +144 -0
  6. package/Sources/AVFoundation/CMTime.swift +303 -0
  7. package/Sources/AVFoundation/Capture.swift +688 -0
  8. package/Sources/AVFoundation/Player.swift +749 -0
  9. package/Sources/AVFoundation/PlayerView.swift +117 -0
  10. package/Sources/AVKit/AVKit.swift +132 -0
  11. package/Sources/Accelerate/Accelerate.swift +122 -0
  12. package/Sources/AppIntents/AppIntents.swift +144 -0
  13. package/Sources/AppIntents/Parameters.swift +220 -0
  14. package/Sources/AppIntents/Shortcuts.swift +159 -0
  15. package/Sources/AudioToolbox/AudioToolbox.swift +55 -0
  16. package/Sources/AuthenticationServices/AuthenticationServices.swift +257 -0
  17. package/Sources/AuthenticationServices/Authorization.swift +251 -0
  18. package/Sources/Charts/Charts.swift +61 -0
  19. package/Sources/Combine/AnyCancellable.swift +65 -0
  20. package/Sources/Combine/AnyPublisher.swift +148 -0
  21. package/Sources/Combine/AnySubscriber.swift +230 -0
  22. package/Sources/Combine/Cancellable.swift +35 -0
  23. package/Sources/Combine/Codable.swift +29 -0
  24. package/Sources/Combine/CombineIdentifier.swift +45 -0
  25. package/Sources/Combine/Concurrency/ConcurrencyHelpers.swift +24 -0
  26. package/Sources/Combine/Concurrency/Future+Concurrency.swift +136 -0
  27. package/Sources/Combine/Concurrency/GENERATED-Publisher+Concurrency.swift +397 -0
  28. package/Sources/Combine/CurrentValueSubject.swift +252 -0
  29. package/Sources/Combine/CustomCombineIdentifierConvertible.swift +28 -0
  30. package/Sources/Combine/Future.swift +228 -0
  31. package/Sources/Combine/GENERATED-RootProtocols.swift +426 -0
  32. package/Sources/Combine/Helpers/ConduitBase.swift +40 -0
  33. package/Sources/Combine/Helpers/ConduitList.swift +59 -0
  34. package/Sources/Combine/Helpers/DebugHook.swift +177 -0
  35. package/Sources/Combine/Helpers/FilterProducer.swift +174 -0
  36. package/Sources/Combine/Helpers/Locking.swift +30 -0
  37. package/Sources/Combine/Helpers/PartialCompletion.swift +26 -0
  38. package/Sources/Combine/Helpers/ReduceProducer.swift +249 -0
  39. package/Sources/Combine/Helpers/SubjectSubscriber.swift +96 -0
  40. package/Sources/Combine/Helpers/SubscriberTap.swift +69 -0
  41. package/Sources/Combine/Helpers/SubscriptionStatus.swift +33 -0
  42. package/Sources/Combine/Helpers/SubscriptionTap.swift +33 -0
  43. package/Sources/Combine/Helpers/Utils.swift +30 -0
  44. package/Sources/Combine/Helpers/Violations.swift +33 -0
  45. package/Sources/Combine/ImmediateScheduler.swift +178 -0
  46. package/Sources/Combine/LICENSE +21 -0
  47. package/Sources/Combine/NotificationPublisher.swift +48 -0
  48. package/Sources/Combine/ObjectWillChange.swift +46 -0
  49. package/Sources/Combine/PassthroughSubject.swift +222 -0
  50. package/Sources/Combine/Publisher+Subscribe.swift +53 -0
  51. package/Sources/Combine/Publishers/Deferred.swift +48 -0
  52. package/Sources/Combine/Publishers/Empty.swift +54 -0
  53. package/Sources/Combine/Publishers/Fail.swift +42 -0
  54. package/Sources/Combine/Publishers/GENERATED-Publishers.Catch.swift +673 -0
  55. package/Sources/Combine/Publishers/GENERATED-Publishers.Encode.swift +388 -0
  56. package/Sources/Combine/Publishers/GENERATED-Publishers.MapKeyPath.swift +384 -0
  57. package/Sources/Combine/Publishers/Just.swift +313 -0
  58. package/Sources/Combine/Publishers/Optional.Publisher.swift +315 -0
  59. package/Sources/Combine/Publishers/Publishers.AllSatisfy.swift +217 -0
  60. package/Sources/Combine/Publishers/Publishers.AssertNoFailure.swift +158 -0
  61. package/Sources/Combine/Publishers/Publishers.Autoconnect.swift +193 -0
  62. package/Sources/Combine/Publishers/Publishers.Breakpoint.swift +231 -0
  63. package/Sources/Combine/Publishers/Publishers.Buffer.swift +356 -0
  64. package/Sources/Combine/Publishers/Publishers.Collect.swift +102 -0
  65. package/Sources/Combine/Publishers/Publishers.CollectByCount.swift +195 -0
  66. package/Sources/Combine/Publishers/Publishers.CompactMap.swift +241 -0
  67. package/Sources/Combine/Publishers/Publishers.Comparison.swift +371 -0
  68. package/Sources/Combine/Publishers/Publishers.Concatenate.swift +474 -0
  69. package/Sources/Combine/Publishers/Publishers.Contains.swift +293 -0
  70. package/Sources/Combine/Publishers/Publishers.Count.swift +87 -0
  71. package/Sources/Combine/Publishers/Publishers.Debounce.swift +332 -0
  72. package/Sources/Combine/Publishers/Publishers.Delay.swift +269 -0
  73. package/Sources/Combine/Publishers/Publishers.Drop.swift +155 -0
  74. package/Sources/Combine/Publishers/Publishers.DropUntilOutput.swift +283 -0
  75. package/Sources/Combine/Publishers/Publishers.DropWhile.swift +378 -0
  76. package/Sources/Combine/Publishers/Publishers.Filter.swift +248 -0
  77. package/Sources/Combine/Publishers/Publishers.First.swift +261 -0
  78. package/Sources/Combine/Publishers/Publishers.FlatMap.swift +533 -0
  79. package/Sources/Combine/Publishers/Publishers.HandleEvents.swift +260 -0
  80. package/Sources/Combine/Publishers/Publishers.IgnoreOutput.swift +109 -0
  81. package/Sources/Combine/Publishers/Publishers.Last.swift +252 -0
  82. package/Sources/Combine/Publishers/Publishers.MakeConnectable.swift +82 -0
  83. package/Sources/Combine/Publishers/Publishers.Map.swift +351 -0
  84. package/Sources/Combine/Publishers/Publishers.MapError.swift +140 -0
  85. package/Sources/Combine/Publishers/Publishers.MeasureInterval.swift +187 -0
  86. package/Sources/Combine/Publishers/Publishers.Multicast.swift +284 -0
  87. package/Sources/Combine/Publishers/Publishers.Output.swift +241 -0
  88. package/Sources/Combine/Publishers/Publishers.PrefixUntilOutput.swift +197 -0
  89. package/Sources/Combine/Publishers/Publishers.PrefixWhile.swift +176 -0
  90. package/Sources/Combine/Publishers/Publishers.Print.swift +206 -0
  91. package/Sources/Combine/Publishers/Publishers.ReceiveOn.swift +227 -0
  92. package/Sources/Combine/Publishers/Publishers.Reduce.swift +204 -0
  93. package/Sources/Combine/Publishers/Publishers.RemoveDuplicates.swift +264 -0
  94. package/Sources/Combine/Publishers/Publishers.ReplaceEmpty.swift +201 -0
  95. package/Sources/Combine/Publishers/Publishers.ReplaceError.swift +211 -0
  96. package/Sources/Combine/Publishers/Publishers.Retry.swift +274 -0
  97. package/Sources/Combine/Publishers/Publishers.Scan.swift +331 -0
  98. package/Sources/Combine/Publishers/Publishers.Sequence.swift +437 -0
  99. package/Sources/Combine/Publishers/Publishers.SetFailureType.swift +120 -0
  100. package/Sources/Combine/Publishers/Publishers.Share.swift +104 -0
  101. package/Sources/Combine/Publishers/Publishers.SubscribeOn.swift +197 -0
  102. package/Sources/Combine/Publishers/Publishers.SwitchToLatest.swift +444 -0
  103. package/Sources/Combine/Publishers/Publishers.Throttle.swift +359 -0
  104. package/Sources/Combine/Publishers/Publishers.Timeout.swift +301 -0
  105. package/Sources/Combine/Publishers/Publishers.Zip.swift +720 -0
  106. package/Sources/Combine/Publishers/Publishers.swift +13 -0
  107. package/Sources/Combine/Publishers/Record.swift +237 -0
  108. package/Sources/Combine/Publishers/Result.Publisher.swift +337 -0
  109. package/Sources/Combine/Result.swift +46 -0
  110. package/Sources/Combine/Scheduler.swift +89 -0
  111. package/Sources/Combine/Schedulers.swift +211 -0
  112. package/Sources/Combine/Subject+Void.swift +17 -0
  113. package/Sources/Combine/Subscriber+Void.swift +20 -0
  114. package/Sources/Combine/Subscribers/Subscribers.Assign.swift +175 -0
  115. package/Sources/Combine/Subscribers/Subscribers.Completion.swift +90 -0
  116. package/Sources/Combine/Subscribers/Subscribers.Demand.swift +476 -0
  117. package/Sources/Combine/Subscribers/Subscribers.Sink.swift +206 -0
  118. package/Sources/Combine/Subscribers/Subscribers.swift +9 -0
  119. package/Sources/Combine/Subscription.swift +22 -0
  120. package/Sources/Combine/Subscriptions.swift +42 -0
  121. package/Sources/Combine/SwiftUIObservation.swift +10 -0
  122. package/Sources/Combine/_Introspection.swift +107 -0
  123. package/Sources/CommonCrypto/CommonCrypto.swift +80 -0
  124. package/Sources/Compression/Compression.swift +365 -0
  125. package/Sources/Compression/Deflate.swift +407 -0
  126. package/Sources/Compression/Zlib.swift +179 -0
  127. package/Sources/CoreFoundationTypes/CoreFoundationTypes.swift +101 -0
  128. package/Sources/CoreGraphics/CoreGraphics.swift +411 -0
  129. package/Sources/CoreGraphics/ProjectionTransforms.swift +28 -0
  130. package/Sources/CoreHaptics/CoreHaptics.swift +399 -0
  131. package/Sources/CoreImage/CIColor.swift +41 -0
  132. package/Sources/CoreImage/CIContext.swift +31 -0
  133. package/Sources/CoreImage/CIDetector.swift +57 -0
  134. package/Sources/CoreImage/CIFilter.swift +243 -0
  135. package/Sources/CoreImage/CIFilterBuiltins.swift +136 -0
  136. package/Sources/CoreImage/CIImage.swift +162 -0
  137. package/Sources/CoreImage/QRCode.swift +393 -0
  138. package/Sources/CoreLocation/Coordinate.swift +30 -0
  139. package/Sources/CoreLocation/Location.swift +65 -0
  140. package/Sources/CoreML/Evaluation.swift +414 -0
  141. package/Sources/CoreML/FeatureValue.swift +266 -0
  142. package/Sources/CoreML/Model.swift +269 -0
  143. package/Sources/CoreML/MultiArray.swift +92 -0
  144. package/Sources/CoreML/Specification.swift +233 -0
  145. package/Sources/CoreText/CoreText.swift +64 -0
  146. package/Sources/CoreTransferable/CoreTransferable.swift +606 -0
  147. package/Sources/CryptoKit/ChaChaPoly.swift +258 -0
  148. package/Sources/CryptoKit/CryptoKit.swift +375 -0
  149. package/Sources/CryptoKit/Curve25519.swift +317 -0
  150. package/Sources/CryptoKit/P256.swift +321 -0
  151. package/Sources/FoundationBridge/AppStorage.swift +165 -0
  152. package/Sources/FoundationBridge/AssetResources.swift +90 -0
  153. package/Sources/FoundationBridge/AsyncBytes.swift +128 -0
  154. package/Sources/FoundationBridge/AsyncImage.swift +116 -0
  155. package/Sources/FoundationBridge/AttributedStrings.swift +16 -0
  156. package/Sources/FoundationBridge/Bundle.swift +119 -0
  157. package/Sources/FoundationBridge/CombineExports.swift +8 -0
  158. package/Sources/FoundationBridge/CoreFoundation.swift +77 -0
  159. package/Sources/FoundationBridge/Dispatch.swift +458 -0
  160. package/Sources/FoundationBridge/EnvironmentFoundation.swift +41 -0
  161. package/Sources/FoundationBridge/FileImporter.swift +128 -0
  162. package/Sources/FoundationBridge/FileSystem.swift +68 -0
  163. package/Sources/FoundationBridge/FoundationBridge.swift +29 -0
  164. package/Sources/FoundationBridge/HostResolution.swift +31 -0
  165. package/Sources/FoundationBridge/ItemProvider.swift +655 -0
  166. package/Sources/FoundationBridge/KeyValueObserving.swift +138 -0
  167. package/Sources/FoundationBridge/Links.swift +127 -0
  168. package/Sources/FoundationBridge/ListFormatter.swift +32 -0
  169. package/Sources/FoundationBridge/Locale.swift +86 -0
  170. package/Sources/FoundationBridge/Localization.swift +149 -0
  171. package/Sources/FoundationBridge/Locks.swift +50 -0
  172. package/Sources/FoundationBridge/Markdown.swift +527 -0
  173. package/Sources/FoundationBridge/MeasurementFormat.swift +95 -0
  174. package/Sources/FoundationBridge/NotificationCenter.swift +154 -0
  175. package/Sources/FoundationBridge/OpenURLHandlers.swift +60 -0
  176. package/Sources/FoundationBridge/Operation.swift +195 -0
  177. package/Sources/FoundationBridge/ProcessInfo.swift +32 -0
  178. package/Sources/FoundationBridge/RelativeDateTimeFormatter.swift +136 -0
  179. package/Sources/FoundationBridge/SceneStorage.swift +78 -0
  180. package/Sources/FoundationBridge/SecurityExports.swift +8 -0
  181. package/Sources/FoundationBridge/Selector.swift +226 -0
  182. package/Sources/FoundationBridge/StringComparators.swift +17 -0
  183. package/Sources/FoundationBridge/Table.swift +211 -0
  184. package/Sources/FoundationBridge/TextAttributes.swift +42 -0
  185. package/Sources/FoundationBridge/Timer.swift +53 -0
  186. package/Sources/FoundationBridge/UITextChecker.swift +30 -0
  187. package/Sources/FoundationBridge/URLSession.swift +718 -0
  188. package/Sources/FoundationBridge/UserDefaults.swift +183 -0
  189. package/Sources/FoundationBridge/WebAuthRedirects.swift +227 -0
  190. package/Sources/FoundationBridge/WebSocket.swift +187 -0
  191. package/Sources/FoundationModels/FoundationModels.swift +1098 -0
  192. package/Sources/ImageIO/GIF.swift +72 -0
  193. package/Sources/ImageIO/ImageIO.swift +248 -0
  194. package/Sources/ImageIO/ImageTypes.swift +28 -0
  195. package/Sources/LinkPresentation/LinkPresentation.swift +249 -0
  196. package/Sources/LocalAuthentication/LAContext.swift +86 -0
  197. package/Sources/MapKit/Geometry.swift +223 -0
  198. package/Sources/MapKit/Map.swift +638 -0
  199. package/Sources/MapKit/MapView.swift +229 -0
  200. package/Sources/MobileCoreServices/MobileCoreServices.swift +28 -0
  201. package/Sources/NaturalLanguage/LanguageIdentifier.swift +317 -0
  202. package/Sources/NaturalLanguage/NaturalLanguage.swift +135 -0
  203. package/Sources/OSLog/OSLog.swift +6 -0
  204. package/Sources/Photos/Photos.swift +572 -0
  205. package/Sources/PhotosUI/PhotosPicker.swift +248 -0
  206. package/Sources/PhotosUI/PhotosPickerItem.swift +261 -0
  207. package/Sources/QuickLook/QuickLook.swift +168 -0
  208. package/Sources/SafariServices/SafariServices.swift +106 -0
  209. package/Sources/Security/Security.swift +332 -0
  210. package/Sources/StoreKit/AppStore.swift +207 -0
  211. package/Sources/StoreKit/Products.swift +280 -0
  212. package/Sources/StoreKit/RequestReview.swift +28 -0
  213. package/Sources/StoreKit/StoreKit1.swift +486 -0
  214. package/Sources/StoreKit/StoreViews.swift +428 -0
  215. package/Sources/StoreKit/Transactions.swift +197 -0
  216. package/Sources/SwiftData/Macros.swift +58 -0
  217. package/Sources/SwiftData/ModelActor.swift +38 -0
  218. package/Sources/SwiftData/ModelContainer.swift +129 -0
  219. package/Sources/SwiftData/ModelContext.swift +451 -0
  220. package/Sources/SwiftData/PersistentModel.swift +238 -0
  221. package/Sources/SwiftData/Properties.swift +261 -0
  222. package/Sources/SwiftData/Query.swift +256 -0
  223. package/Sources/SwiftData/Schema.swift +192 -0
  224. package/Sources/SwiftData/Store.swift +146 -0
  225. package/Sources/SwiftData/StringPredicates.swift +125 -0
  226. package/Sources/SwiftDataMacros/EntryMacro.swift +82 -0
  227. package/Sources/SwiftDataMacros/GenerableMacro.swift +183 -0
  228. package/Sources/SwiftDataMacros/ModelActorMacro.swift +46 -0
  229. package/Sources/SwiftDataMacros/ModelMacro.swift +260 -0
  230. package/Sources/SwiftDataMacros/Plugin.swift +18 -0
  231. package/Sources/SwiftDataMacros/PredicateMacro.swift +1244 -0
  232. package/Sources/SwiftUI/API/Accessibility.swift +181 -0
  233. package/Sources/SwiftUI/API/AccessibilityExtras.swift +33 -0
  234. package/Sources/SwiftUI/API/AccessibilityFocus.swift +63 -0
  235. package/Sources/SwiftUI/API/Alert.swift +221 -0
  236. package/Sources/SwiftUI/API/AlignmentGuides.swift +65 -0
  237. package/Sources/SwiftUI/API/Animation.swift +285 -0
  238. package/Sources/SwiftUI/API/App.swift +87 -0
  239. package/Sources/SwiftUI/API/BindingCollections.swift +35 -0
  240. package/Sources/SwiftUI/API/BindingForEach.swift +27 -0
  241. package/Sources/SwiftUI/API/Bitmaps.swift +254 -0
  242. package/Sources/SwiftUI/API/ButtonStyles.swift +96 -0
  243. package/Sources/SwiftUI/API/Canvas.swift +337 -0
  244. package/Sources/SwiftUI/API/Color.swift +237 -0
  245. package/Sources/SwiftUI/API/ColorEffects.swift +52 -0
  246. package/Sources/SwiftUI/API/ColorPickerAndLabeledContent.swift +138 -0
  247. package/Sources/SwiftUI/API/ColorSpaces.swift +161 -0
  248. package/Sources/SwiftUI/API/Commands.swift +106 -0
  249. package/Sources/SwiftUI/API/ContainerBackground.swift +28 -0
  250. package/Sources/SwiftUI/API/ContentShape.swift +33 -0
  251. package/Sources/SwiftUI/API/ContentSizeCategory.swift +35 -0
  252. package/Sources/SwiftUI/API/ContentUnavailable.swift +101 -0
  253. package/Sources/SwiftUI/API/Controls.swift +300 -0
  254. package/Sources/SwiftUI/API/CustomLayout.swift +442 -0
  255. package/Sources/SwiftUI/API/CustomToolbarContent.swift +46 -0
  256. package/Sources/SwiftUI/API/Decorations.swift +92 -0
  257. package/Sources/SwiftUI/API/EditMode.swift +212 -0
  258. package/Sources/SwiftUI/API/Effects.swift +388 -0
  259. package/Sources/SwiftUI/API/Entry.swift +8 -0
  260. package/Sources/SwiftUI/API/Environment.swift +439 -0
  261. package/Sources/SwiftUI/API/EnvironmentSendable.swift +6 -0
  262. package/Sources/SwiftUI/API/Focus.swift +137 -0
  263. package/Sources/SwiftUI/API/Font.swift +131 -0
  264. package/Sources/SwiftUI/API/Gauge.swift +290 -0
  265. package/Sources/SwiftUI/API/Geometry.swift +89 -0
  266. package/Sources/SwiftUI/API/GeometryEffects.swift +232 -0
  267. package/Sources/SwiftUI/API/GeometryReader.swift +135 -0
  268. package/Sources/SwiftUI/API/GestureState.swift +65 -0
  269. package/Sources/SwiftUI/API/Gestures.swift +342 -0
  270. package/Sources/SwiftUI/API/Glass.swift +127 -0
  271. package/Sources/SwiftUI/API/Grid.swift +188 -0
  272. package/Sources/SwiftUI/API/GroupBoxAndControlGroup.swift +130 -0
  273. package/Sources/SwiftUI/API/KeyPress.swift +54 -0
  274. package/Sources/SwiftUI/API/LabelStyle.swift +124 -0
  275. package/Sources/SwiftUI/API/Layout.swift +220 -0
  276. package/Sources/SwiftUI/API/LazyStacks.swift +49 -0
  277. package/Sources/SwiftUI/API/LegacyAlert.swift +97 -0
  278. package/Sources/SwiftUI/API/Lists.swift +331 -0
  279. package/Sources/SwiftUI/API/Menu.swift +58 -0
  280. package/Sources/SwiftUI/API/Modifiers.swift +313 -0
  281. package/Sources/SwiftUI/API/MoreModifiers.swift +100 -0
  282. package/Sources/SwiftUI/API/Namespace.swift +44 -0
  283. package/Sources/SwiftUI/API/Navigation.swift +386 -0
  284. package/Sources/SwiftUI/API/NavigationDestinationBindings.swift +55 -0
  285. package/Sources/SwiftUI/API/ObservableObject.swift +293 -0
  286. package/Sources/SwiftUI/API/OnChange.swift +48 -0
  287. package/Sources/SwiftUI/API/Path.swift +543 -0
  288. package/Sources/SwiftUI/API/Phase8Controls.swift +411 -0
  289. package/Sources/SwiftUI/API/PhaseAnimator.swift +130 -0
  290. package/Sources/SwiftUI/API/Picker.swift +185 -0
  291. package/Sources/SwiftUI/API/PointerAndKeyboard.swift +77 -0
  292. package/Sources/SwiftUI/API/Popover.swift +41 -0
  293. package/Sources/SwiftUI/API/Preferences.swift +262 -0
  294. package/Sources/SwiftUI/API/Presentation.swift +122 -0
  295. package/Sources/SwiftUI/API/PresentationExtras.swift +60 -0
  296. package/Sources/SwiftUI/API/Primitives.swift +517 -0
  297. package/Sources/SwiftUI/API/Publishers.swift +107 -0
  298. package/Sources/SwiftUI/API/Redaction.swift +75 -0
  299. package/Sources/SwiftUI/API/RowActions.swift +84 -0
  300. package/Sources/SwiftUI/API/Scenes.swift +131 -0
  301. package/Sources/SwiftUI/API/ScrollModifiers.swift +132 -0
  302. package/Sources/SwiftUI/API/ScrollTargets.swift +104 -0
  303. package/Sources/SwiftUI/API/ScrollViewReader.swift +144 -0
  304. package/Sources/SwiftUI/API/SectionSupplements.swift +96 -0
  305. package/Sources/SwiftUI/API/Shape.swift +214 -0
  306. package/Sources/SwiftUI/API/ShapeStyle.swift +409 -0
  307. package/Sources/SwiftUI/API/ShapeTrim.swift +78 -0
  308. package/Sources/SwiftUI/API/Sharing.swift +193 -0
  309. package/Sources/SwiftUI/API/StackLayouts.swift +199 -0
  310. package/Sources/SwiftUI/API/State.swift +144 -0
  311. package/Sources/SwiftUI/API/StatusGaps.swift +121 -0
  312. package/Sources/SwiftUI/API/StrokeStyle.swift +30 -0
  313. package/Sources/SwiftUI/API/SymbolEffects.swift +203 -0
  314. package/Sources/SwiftUI/API/TabContent.swift +841 -0
  315. package/Sources/SwiftUI/API/Table.swift +382 -0
  316. package/Sources/SwiftUI/API/Tabs.swift +263 -0
  317. package/Sources/SwiftUI/API/Tasks.swift +35 -0
  318. package/Sources/SwiftUI/API/Text.swift +386 -0
  319. package/Sources/SwiftUI/API/TextDates.swift +61 -0
  320. package/Sources/SwiftUI/API/TextDecorations.swift +52 -0
  321. package/Sources/SwiftUI/API/TextFieldAxis.swift +103 -0
  322. package/Sources/SwiftUI/API/TextFieldCommit.swift +52 -0
  323. package/Sources/SwiftUI/API/Timeline.swift +212 -0
  324. package/Sources/SwiftUI/API/Toolbar.swift +251 -0
  325. package/Sources/SwiftUI/API/Transfer.swift +145 -0
  326. package/Sources/SwiftUI/API/UnevenRoundedRectangle.swift +66 -0
  327. package/Sources/SwiftUI/API/Video.swift +64 -0
  328. package/Sources/SwiftUI/API/View.swift +215 -0
  329. package/Sources/SwiftUI/API/ViewModifier.swift +43 -0
  330. package/Sources/SwiftUI/API/VisualEffect.swift +155 -0
  331. package/Sources/SwiftUI/API/Windows.swift +25 -0
  332. package/Sources/SwiftUI/Charts/Axis.swift +325 -0
  333. package/Sources/SwiftUI/Charts/AxisFormatsAndRanges.swift +68 -0
  334. package/Sources/SwiftUI/Charts/Chart.swift +660 -0
  335. package/Sources/SwiftUI/Charts/ChartContent.swift +376 -0
  336. package/Sources/SwiftUI/Charts/ChartProxy.swift +57 -0
  337. package/Sources/SwiftUI/Charts/Marks.swift +204 -0
  338. package/Sources/SwiftUI/Charts/Plottable.swift +99 -0
  339. package/Sources/SwiftUI/Charts/Scales.swift +326 -0
  340. package/Sources/SwiftUI/Localization/Localization.swift +498 -0
  341. package/Sources/SwiftUI/Localization/PluralRules.swift +127 -0
  342. package/Sources/SwiftUI/Runtime/Executor.swift +85 -0
  343. package/Sources/SwiftUI/Runtime/Exports.swift +101 -0
  344. package/Sources/SwiftUI/Runtime/ImageSource.swift +310 -0
  345. package/Sources/SwiftUI/Runtime/JSON.swift +143 -0
  346. package/Sources/SwiftUI/Runtime/JSONParser.swift +443 -0
  347. package/Sources/SwiftUI/Runtime/LazyRows.swift +99 -0
  348. package/Sources/SwiftUI/Runtime/Measurements.swift +140 -0
  349. package/Sources/SwiftUI/Runtime/Ops.swift +152 -0
  350. package/Sources/SwiftUI/Runtime/Reconciler.swift +219 -0
  351. package/Sources/SwiftUI/Runtime/Replay.swift +382 -0
  352. package/Sources/SwiftUI/Runtime/Runtime.swift +2146 -0
  353. package/Sources/SwiftUI/Runtime/Sameness.swift +152 -0
  354. package/Sources/SwiftUI/Runtime/ViewPath.swift +89 -0
  355. package/Sources/SwiftUI/Runtime/ViewTraits.swift +175 -0
  356. package/Sources/SwiftUI/Runtime/WebAuthHeadless.swift +49 -0
  357. package/Sources/Symbols/Symbols.swift +25 -0
  358. package/Sources/Translation/Translation.swift +423 -0
  359. package/Sources/UIKit/Activity.swift +213 -0
  360. package/Sources/UIKit/Alerts.swift +69 -0
  361. package/Sources/UIKit/AppDelegate.swift +222 -0
  362. package/Sources/UIKit/Appearance.swift +84 -0
  363. package/Sources/UIKit/ColorConversions.swift +70 -0
  364. package/Sources/UIKit/Controls.swift +225 -0
  365. package/Sources/UIKit/Device.swift +200 -0
  366. package/Sources/UIKit/Feedback.swift +65 -0
  367. package/Sources/UIKit/Font.swift +307 -0
  368. package/Sources/UIKit/Graphics.swift +204 -0
  369. package/Sources/UIKit/HostingController.swift +185 -0
  370. package/Sources/UIKit/Identity.swift +24 -0
  371. package/Sources/UIKit/Introspectable.swift +510 -0
  372. package/Sources/UIKit/Pasteboard.swift +363 -0
  373. package/Sources/UIKit/PhotoAlbum.swift +81 -0
  374. package/Sources/UIKit/RemoteNotifications.swift +15 -0
  375. package/Sources/UIKit/Representable.swift +288 -0
  376. package/Sources/UIKit/SafeArea.swift +12 -0
  377. package/Sources/UIKit/SceneDelegates.swift +132 -0
  378. package/Sources/UIKit/Scenes.swift +40 -0
  379. package/Sources/UIKit/ScrollView.swift +157 -0
  380. package/Sources/UIKit/ShortcutItems.swift +67 -0
  381. package/Sources/UIKit/SymbolConfiguration.swift +124 -0
  382. package/Sources/UIKit/TargetAction.swift +123 -0
  383. package/Sources/UIKit/TextPaste.swift +161 -0
  384. package/Sources/UIKit/TextView.swift +538 -0
  385. package/Sources/UIKit/UIKit.swift +292 -0
  386. package/Sources/UIKit/UIView.swift +855 -0
  387. package/Sources/UIKit/ViewTranslation.swift +311 -0
  388. package/Sources/UniformTypeIdentifiers/UTType.swift +196 -0
  389. package/Sources/UserNotifications/Content.swift +370 -0
  390. package/Sources/UserNotifications/NotificationCenter.swift +309 -0
  391. package/Sources/WeatherKit/WeatherKit.swift +228 -0
  392. package/Sources/WebKit/WebKit.swift +245 -0
  393. package/Sources/os/os.swift +376 -0
  394. package/Sources/zlib/zlib.swift +6 -0
  395. package/index.d.ts +2 -0
  396. package/index.mjs +16 -0
  397. package/manifest.d.mts +2 -0
  398. package/manifest.mjs +39 -0
  399. package/package.json +30 -4
  400. package/sync-sources.mjs +33 -0
@@ -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
+ }
@@ -0,0 +1,28 @@
1
+ // `.containerBackground(for:)` (iOS 17): a background for the container a
2
+ // view is placed in (a navigation stack, a widget, StoreKit's subscription
3
+ // store). The browser draws it behind the view itself, which is where it
4
+ // shows for a view that fills its container.
5
+
6
+ /// Where a container background goes. Frameworks add their own placements
7
+ /// (StoreKit's `.subscriptionStore`) through `init(_name:)`.
8
+ public struct ContainerBackgroundPlacement: Hashable, Sendable {
9
+ public let _name: String
10
+ public init(_name: String) { self._name = _name }
11
+
12
+ public static let navigation = ContainerBackgroundPlacement(_name: "navigation")
13
+ public static let navigationSplitView = ContainerBackgroundPlacement(_name: "navigationSplitView")
14
+ public static let tabView = ContainerBackgroundPlacement(_name: "tabView")
15
+ public static let widget = ContainerBackgroundPlacement(_name: "widget")
16
+ }
17
+
18
+ extension View {
19
+ /// Draws `content` behind the view.
20
+ public func containerBackground<V: View>(for container: ContainerBackgroundPlacement, alignment: Alignment = .center, @ViewBuilder content: () -> V) -> some View {
21
+ background(alignment: alignment, content: content)
22
+ }
23
+
24
+ /// Fills the area behind the view with `style`.
25
+ public func containerBackground<S: ShapeStyle>(_ style: S, for container: ContainerBackgroundPlacement) -> some View {
26
+ background(style)
27
+ }
28
+ }
@@ -0,0 +1,33 @@
1
+ // `.contentShape(_:)`: on iOS it makes the whole shape hit-testable (a tap
2
+ // on the gap of an `HStack` with a `Spacer` reaches its gesture). On the page
3
+ // every element's hit area is already its whole box, so the modifier is
4
+ // accepted without adding to the tree; a non-rectangular shape (`Circle()`)
5
+ // still hits as its bounding box (an approximation).
6
+
7
+ public struct ContentShapeKinds: OptionSet, Hashable, Sendable {
8
+ public let rawValue: Int
9
+ public init(rawValue: Int) { self.rawValue = rawValue }
10
+ public static let interaction = ContentShapeKinds(rawValue: 1 << 0)
11
+ public static let dragPreview = ContentShapeKinds(rawValue: 1 << 1)
12
+ public static let contextMenuPreview = ContentShapeKinds(rawValue: 1 << 2)
13
+ public static let hoverEffect = ContentShapeKinds(rawValue: 1 << 3)
14
+ public static let focusEffect = ContentShapeKinds(rawValue: 1 << 4)
15
+ public static let accessibility = ContentShapeKinds(rawValue: 1 << 5)
16
+ }
17
+
18
+ nonisolated extension View {
19
+ public func contentShape<S: Shape>(_ shape: S, eoFill: Bool = false) -> some View { self }
20
+
21
+ public func contentShape<S: Shape>(_ kind: ContentShapeKinds, _ shape: S, eoFill: Bool = false) -> some View { self }
22
+ }
23
+
24
+ nonisolated extension View {
25
+ /// The iOS 17 tap with its location: the point in the view's own
26
+ /// coordinates, which the page sends with the tap (a named or global
27
+ /// space gets the local point too). `count` is ignored as for
28
+ /// `onTapGesture(count:perform:)`.
29
+ public func onTapGesture(count: Int = 1, coordinateSpace: CoordinateSpace = .local,
30
+ perform action: @escaping @MainActor (CGPoint) -> Void) -> some View {
31
+ _TapGestureView(content: self, locatedAction: action)
32
+ }
33
+ }
@@ -0,0 +1,35 @@
1
+ // `ContentSizeCategory` and `EnvironmentValues.sizeCategory`: SwiftUI's
2
+ // Dynamic Type sizes before `DynamicTypeSize` (iOS 15), still read by UIKit
3
+ // code that scales its fonts (Ice Cubes' composer). The value is the
4
+ // environment's `dynamicTypeSize` under its old names.
5
+
6
+ /// A Dynamic Type size, by its pre-iOS 15 name.
7
+ public enum ContentSizeCategory: Hashable, CaseIterable, Sendable {
8
+ case extraSmall, small, medium, large, extraLarge, extraExtraLarge, extraExtraExtraLarge
9
+ case accessibilityMedium, accessibilityLarge, accessibilityExtraLarge
10
+ case accessibilityExtraExtraLarge, accessibilityExtraExtraExtraLarge
11
+
12
+ public var isAccessibilityCategory: Bool { DynamicTypeSize(self).isAccessibilitySize }
13
+ }
14
+
15
+ extension DynamicTypeSize {
16
+ /// The size a `ContentSizeCategory` names.
17
+ public init(_ category: ContentSizeCategory) {
18
+ self = DynamicTypeSize.allCases[ContentSizeCategory.allCases.firstIndex(of: category) ?? 3]
19
+ }
20
+ }
21
+
22
+ extension ContentSizeCategory {
23
+ /// The category of a `DynamicTypeSize`.
24
+ public init(_ size: DynamicTypeSize) {
25
+ self = ContentSizeCategory.allCases[size.rawValue]
26
+ }
27
+ }
28
+
29
+ extension EnvironmentValues {
30
+ /// `dynamicTypeSize` as a `ContentSizeCategory`.
31
+ public var sizeCategory: ContentSizeCategory {
32
+ get { ContentSizeCategory(dynamicTypeSize) }
33
+ set { dynamicTypeSize = DynamicTypeSize(newValue) }
34
+ }
35
+ }
@@ -0,0 +1,101 @@
1
+ // `ContentUnavailableView`: the centered icon, title, description and
2
+ // actions iOS shows for an empty or failed state, built from the shim's
3
+ // own views (a large secondary icon over a bold title, a secondary
4
+ // description, then the actions), filling the space it is given.
5
+
6
+ public struct ContentUnavailableView<Label: View, Description: View, Actions: View>: View {
7
+ let label: Label
8
+ let description: Description
9
+ let actions: Actions
10
+
11
+ public init(@ViewBuilder label: () -> Label,
12
+ @ViewBuilder description: () -> Description = { EmptyView() },
13
+ @ViewBuilder actions: () -> Actions = { EmptyView() }) {
14
+ self.label = label()
15
+ self.description = description()
16
+ self.actions = actions()
17
+ }
18
+
19
+ public var body: some View {
20
+ VStack(spacing: 16) {
21
+ VStack(spacing: 8) {
22
+ label.labelStyle(_ContentUnavailableLabelStyle())
23
+ description
24
+ .font(.callout)
25
+ .foregroundStyle(.secondary)
26
+ .multilineTextAlignment(.center)
27
+ }
28
+ actions
29
+ }
30
+ .padding(.horizontal, 32)
31
+ .frame(maxWidth: .infinity, maxHeight: .infinity)
32
+ }
33
+ }
34
+
35
+ extension ContentUnavailableView where Label == SwiftUI.Label<Text, Image>, Description == Text?, Actions == EmptyView {
36
+ public init(_ titleKey: LocalizedStringKey, systemImage name: String, description: Text? = nil) {
37
+ self.init(label: { SwiftUI.Label(titleKey, systemImage: name) }, description: { description })
38
+ }
39
+
40
+ public init(_ titleKey: LocalizedStringKey, image name: String, description: Text? = nil) {
41
+ self.init(label: { SwiftUI.Label(Text(titleKey).content, image: name) }, description: { description })
42
+ }
43
+
44
+ @_disfavoredOverload
45
+ public init<S: StringProtocol>(_ title: S, systemImage name: String, description: Text? = nil) {
46
+ self.init(label: { SwiftUI.Label(title, systemImage: name) }, description: { description })
47
+ }
48
+
49
+ @_disfavoredOverload
50
+ public init<S: StringProtocol>(_ title: S, image name: String, description: Text? = nil) {
51
+ self.init(label: { SwiftUI.Label(title, image: name) }, description: { description })
52
+ }
53
+ }
54
+
55
+ /// The content of `ContentUnavailableView.search`.
56
+ public enum SearchUnavailableContent {
57
+ public struct Label: View {
58
+ let text: String?
59
+ public var body: some View {
60
+ SwiftUI.Label(text.map { "No Results for \u{201C}\($0)\u{201D}" } ?? "No Results", systemImage: "magnifyingglass")
61
+ }
62
+ }
63
+
64
+ public struct Description: View {
65
+ public var body: some View { Text("Check the spelling or try a new search.") }
66
+ }
67
+
68
+ public struct Actions: View {
69
+ public var body: some View { EmptyView() }
70
+ }
71
+ }
72
+
73
+ extension ContentUnavailableView where Label == SearchUnavailableContent.Label,
74
+ Description == SearchUnavailableContent.Description,
75
+ Actions == SearchUnavailableContent.Actions {
76
+ /// "No Results" for a search.
77
+ public static var search: ContentUnavailableView { search(nil) }
78
+
79
+ /// "No Results for “text”" for a search.
80
+ public static func search(text: String) -> ContentUnavailableView { search(text) }
81
+
82
+ private static func search(_ text: String?) -> ContentUnavailableView {
83
+ ContentUnavailableView(label: { SearchUnavailableContent.Label(text: text) },
84
+ description: { SearchUnavailableContent.Description() },
85
+ actions: { SearchUnavailableContent.Actions() })
86
+ }
87
+ }
88
+
89
+ /// The icon large and secondary above a bold title.
90
+ struct _ContentUnavailableLabelStyle: LabelStyle {
91
+ func makeBody(configuration: Configuration) -> some View {
92
+ VStack(spacing: 12) {
93
+ configuration.icon
94
+ .font(.system(size: 48))
95
+ .foregroundStyle(.secondary)
96
+ configuration.title
97
+ .font(.title2.bold())
98
+ .multilineTextAlignment(.center)
99
+ }
100
+ }
101
+ }