@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,229 @@
1
+ // UIKit's map (`MKMapView`), for apps that show one through a representable
2
+ // (Apple's Food Truck puts one in a `UIViewControllerRepresentable`) and for
3
+ // code that names it (SwiftUI-Introspect's `.introspect(.map, on: .iOS(…))`).
4
+ // It keeps its region and settings, and its layer draws the SwiftUI `Map` of
5
+ // this module showing that region, with its annotations as markers, so it
6
+ // looks as a `Map` does: a surface with latitude and longitude lines, no map
7
+ // data. Gestures do not move it; the app's own changes do.
8
+
9
+ import SwiftUI
10
+ import UIKit
11
+
12
+ /// A point of view over the map: what it looks at and from how far (meters).
13
+ open class MKMapCamera: NSObject, @unchecked Sendable {
14
+ public var centerCoordinate: CLLocationCoordinate2D
15
+ public var centerCoordinateDistance: CLLocationDistance
16
+ public var pitch: CGFloat
17
+ public var heading: CLLocationDirection
18
+
19
+ public override init() {
20
+ centerCoordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0)
21
+ centerCoordinateDistance = 1000
22
+ pitch = 0
23
+ heading = 0
24
+ }
25
+
26
+ public init(lookingAtCenter centerCoordinate: CLLocationCoordinate2D, fromDistance distance: CLLocationDistance,
27
+ pitch: CGFloat, heading: CLLocationDirection) {
28
+ self.centerCoordinate = centerCoordinate
29
+ self.centerCoordinateDistance = distance
30
+ self.pitch = pitch
31
+ self.heading = heading
32
+ }
33
+
34
+ /// The altitude of the eye; the distance here (the browser's map has no pitch).
35
+ public var altitude: CLLocationDistance {
36
+ get { centerCoordinateDistance }
37
+ set { centerCoordinateDistance = newValue }
38
+ }
39
+
40
+ var mapCamera: MapCamera {
41
+ MapCamera(centerCoordinate: centerCoordinate, distance: centerCoordinateDistance, heading: heading, pitch: pitch)
42
+ }
43
+ }
44
+
45
+ /// How a map is drawn; kept (the browser's map is a plain surface).
46
+ open class MKMapConfiguration: NSObject, @unchecked Sendable {
47
+ public enum ElevationStyle: Int, Sendable { case flat, realistic }
48
+ public var elevationStyle: ElevationStyle = .flat
49
+ public override init() {}
50
+ }
51
+
52
+ open class MKStandardMapConfiguration: MKMapConfiguration, @unchecked Sendable {
53
+ public enum EmphasisStyle: Int, Sendable { case `default`, muted }
54
+ public var emphasisStyle: EmphasisStyle = .default
55
+ public var pointOfInterestFilter: MKPointOfInterestFilter?
56
+ public var showsTraffic = false
57
+
58
+ public override init() {}
59
+
60
+ public init(elevationStyle: ElevationStyle) {
61
+ super.init()
62
+ self.elevationStyle = elevationStyle
63
+ }
64
+
65
+ public init(elevationStyle: ElevationStyle, emphasisStyle: EmphasisStyle) {
66
+ super.init()
67
+ self.elevationStyle = elevationStyle
68
+ self.emphasisStyle = emphasisStyle
69
+ }
70
+
71
+ public init(emphasisStyle: EmphasisStyle) {
72
+ super.init()
73
+ self.emphasisStyle = emphasisStyle
74
+ }
75
+ }
76
+
77
+ open class MKHybridMapConfiguration: MKMapConfiguration, @unchecked Sendable {
78
+ public var pointOfInterestFilter: MKPointOfInterestFilter?
79
+ public var showsTraffic = false
80
+ }
81
+
82
+ open class MKImageryMapConfiguration: MKMapConfiguration, @unchecked Sendable {}
83
+
84
+ /// A kind of place a map may label.
85
+ public struct MKPointOfInterestCategory: RawRepresentable, Hashable, Sendable {
86
+ public let rawValue: String
87
+ public init(rawValue: String) { self.rawValue = rawValue }
88
+ public static let bakery = MKPointOfInterestCategory(rawValue: "MKPOICategoryBakery")
89
+ public static let cafe = MKPointOfInterestCategory(rawValue: "MKPOICategoryCafe")
90
+ public static let park = MKPointOfInterestCategory(rawValue: "MKPOICategoryPark")
91
+ public static let parking = MKPointOfInterestCategory(rawValue: "MKPOICategoryParking")
92
+ public static let restaurant = MKPointOfInterestCategory(rawValue: "MKPOICategoryRestaurant")
93
+ public static let store = MKPointOfInterestCategory(rawValue: "MKPOICategoryStore")
94
+ }
95
+
96
+ /// Which places a map labels; kept (the browser's map labels none).
97
+ public struct MKPointOfInterestFilter: Sendable {
98
+ public static let includingAll = MKPointOfInterestFilter()
99
+ public static let excludingAll = MKPointOfInterestFilter()
100
+ init() {}
101
+ public init(including categories: [MKPointOfInterestCategory]) {}
102
+ public init(excluding categories: [MKPointOfInterestCategory]) {}
103
+ }
104
+
105
+ /// How a map view draws the map; kept (the browser's map is a plain surface).
106
+ public enum MKMapType: UInt, Sendable {
107
+ case standard = 0
108
+ case satellite = 1
109
+ case hybrid = 2
110
+ case satelliteFlyover = 3
111
+ case hybridFlyover = 4
112
+ case mutedStandard = 5
113
+ }
114
+
115
+ /// Something placed on a map at a coordinate.
116
+ public protocol MKAnnotation: AnyObject {
117
+ var coordinate: CLLocationCoordinate2D { get }
118
+ var title: String? { get }
119
+ var subtitle: String? { get }
120
+ }
121
+
122
+ extension MKAnnotation {
123
+ public var title: String? { nil }
124
+ public var subtitle: String? { nil }
125
+ }
126
+
127
+ /// A plain annotation with a title.
128
+ open class MKPointAnnotation: NSObject, MKAnnotation {
129
+ public var coordinate: CLLocationCoordinate2D
130
+ public var title: String?
131
+ public var subtitle: String?
132
+
133
+ public override init() { coordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0) }
134
+
135
+ public init(coordinate: CLLocationCoordinate2D, title: String? = nil, subtitle: String? = nil) {
136
+ self.coordinate = coordinate
137
+ self.title = title
138
+ self.subtitle = subtitle
139
+ }
140
+ }
141
+
142
+ @MainActor
143
+ public protocol MKMapViewDelegate: AnyObject {}
144
+
145
+ /// A map in a UIKit view tree, drawn as this module's SwiftUI `Map` (see the top of this file).
146
+ @MainActor
147
+ open class MKMapView: UIView {
148
+ open override class var layerClass: AnyClass { _MKMapLayer.self }
149
+
150
+ public weak var delegate: (any MKMapViewDelegate)?
151
+ /// The region shown: what the map draws.
152
+ open var region = MKCoordinateRegion.world { didSet { layer._changed() } }
153
+ /// Where the map looks from; setting it shows the region it sees.
154
+ open var camera = MKMapCamera() {
155
+ didSet { region = camera.mapCamera.region }
156
+ }
157
+ public var preferredConfiguration: MKMapConfiguration = MKStandardMapConfiguration()
158
+ open var mapType: MKMapType = .standard
159
+ public var pointOfInterestFilter: MKPointOfInterestFilter?
160
+ open var isZoomEnabled = true
161
+ open var isScrollEnabled = true
162
+ open var isPitchEnabled = true
163
+ open var isRotateEnabled = true
164
+ public var showsCompass = true
165
+ public var showsScale = false
166
+ public var showsTraffic = false
167
+ public var showsBuildings = true
168
+ open var showsUserLocation = false
169
+ public private(set) var annotations: [any MKAnnotation] = []
170
+
171
+ public override init(frame: CGRect) {
172
+ super.init(frame: frame)
173
+ (layer as? _MKMapLayer)?.mapView = self
174
+ }
175
+
176
+ public required init?(coder: NSCoder) {
177
+ super.init(coder: coder)
178
+ (layer as? _MKMapLayer)?.mapView = self
179
+ }
180
+
181
+ /// The coordinate at the center of the region.
182
+ open var centerCoordinate: CLLocationCoordinate2D {
183
+ get { region.center }
184
+ set { region.center = newValue }
185
+ }
186
+
187
+ open func setRegion(_ region: MKCoordinateRegion, animated: Bool) {
188
+ self.region = region
189
+ }
190
+
191
+ open func setCenter(_ coordinate: CLLocationCoordinate2D, animated: Bool) {
192
+ centerCoordinate = coordinate
193
+ }
194
+
195
+ open func setCamera(_ camera: MKMapCamera, animated: Bool) { self.camera = camera }
196
+
197
+ open func addAnnotation(_ annotation: any MKAnnotation) { addAnnotations([annotation]) }
198
+
199
+ open func addAnnotations(_ annotations: [any MKAnnotation]) {
200
+ self.annotations += annotations
201
+ layer._changed()
202
+ }
203
+
204
+ open func removeAnnotation(_ annotation: any MKAnnotation) { removeAnnotations([annotation]) }
205
+
206
+ open func removeAnnotations(_ annotations: [any MKAnnotation]) {
207
+ self.annotations.removeAll { existing in annotations.contains { $0 === existing } }
208
+ layer._changed()
209
+ }
210
+
211
+ /// The map as SwiftUI: a `Map` at the camera, the annotations as markers.
212
+ var drawing: AnyView {
213
+ let markers = annotations.enumerated().map { (index: $0.offset, coordinate: $0.element.coordinate, title: $0.element.title ?? "") }
214
+ return AnyView(Map(position: .constant(.region(region)), interactionModes: []) {
215
+ ForEach(markers, id: \.index) { marker in
216
+ Marker(marker.title, coordinate: marker.coordinate)
217
+ }
218
+ })
219
+ }
220
+ }
221
+
222
+ /// The layer of an `MKMapView`, which draws its map.
223
+ final class _MKMapLayer: CALayer {
224
+ weak var mapView: MKMapView?
225
+
226
+ override var _drawing: AnyView? {
227
+ MainActor.assumeIsolated { mapView?.drawing }
228
+ }
229
+ }
@@ -0,0 +1,28 @@
1
+ // `import MobileCoreServices` for the browser. On iOS the framework is where
2
+ // the old `kUTType…` constants live, and importing it also brings `UTType`
3
+ // (Gifu imports it for that), so this module re-exports
4
+ // UniformTypeIdentifiers and declares the constants as identifier strings.
5
+
6
+ @_exported import UniformTypeIdentifiers
7
+
8
+ public let kUTTypeItem = UTType.item.identifier
9
+ public let kUTTypeContent = UTType.content.identifier
10
+ public let kUTTypeData = UTType.data.identifier
11
+ public let kUTTypeImage = UTType.image.identifier
12
+ public let kUTTypeJPEG = UTType.jpeg.identifier
13
+ public let kUTTypePNG = UTType.png.identifier
14
+ public let kUTTypeGIF = UTType.gif.identifier
15
+ public let kUTTypeTIFF = UTType.tiff.identifier
16
+ public let kUTTypeBMP = UTType.bmp.identifier
17
+ public let kUTTypeScalableVectorGraphics = UTType.svg.identifier
18
+ public let kUTTypeAudiovisualContent = UTType.audiovisualContent.identifier
19
+ public let kUTTypeMovie = UTType.movie.identifier
20
+ public let kUTTypeVideo = UTType.video.identifier
21
+ public let kUTTypeMPEG4 = UTType.mpeg4Movie.identifier
22
+ public let kUTTypeQuickTimeMovie = UTType.quickTimeMovie.identifier
23
+ public let kUTTypeAudio = UTType.audio.identifier
24
+ public let kUTTypeMP3 = UTType.mp3.identifier
25
+ public let kUTTypeText = UTType.text.identifier
26
+ public let kUTTypePlainText = UTType.plainText.identifier
27
+ public let kUTTypeJSON = UTType.json.identifier
28
+ public let kUTTypePDF = UTType.pdf.identifier
@@ -0,0 +1,317 @@
1
+ // How `NLLanguageRecognizer` decides, in three steps:
2
+ //
3
+ // 1. Each letter belongs to a writing system (`_Script`), by its Unicode
4
+ // block. Digits, punctuation, symbols, emoji and URLs count for nothing.
5
+ // 2. Each script with letters has its languages (a script of its own has
6
+ // one). Within a shared script every language starts from a prior and
7
+ // gains points for each of its most frequent words in the text and for
8
+ // each of its distinctive letters (ñ, ł, ő, і, پ, kana…). A word or
9
+ // letter that several languages share is split between them. The points
10
+ // become probabilities through a softmax: e^(1.5 × points), normalised. So
11
+ // about four of a language's common words make it ~90% likely, and a
12
+ // text with none of them leaves it among its neighbours.
13
+ // 3. A language's probability is its share within its script, times the
14
+ // script's share of the letters, times n / (n + 0.5) for the script's n
15
+ // letters (three letters are not much to go on).
16
+ //
17
+ // It knows a few dozen words for each Latin-script language, so a long text
18
+ // in a language it does not list (Tagalog, Esperanto) gets low, spread-out
19
+ // probabilities rather than a confident wrong answer.
20
+
21
+ import Foundation
22
+
23
+ enum _LanguageIdentifier {
24
+ /// How sharply points turn into probability.
25
+ static let sharpness = 1.5
26
+
27
+ static func hypotheses(for text: String, hints: [NLLanguage: Double], constraints: Set<NLLanguage>) -> [NLLanguage: Double] {
28
+ // URLs carry no language.
29
+ let cleaned = text.split(whereSeparator: \.isWhitespace)
30
+ .filter { !$0.contains("://") && !$0.lowercased().hasPrefix("www.") }
31
+ .joined(separator: " ")
32
+ .lowercased()
33
+
34
+ var letterCounts: [_Script: Int] = [:]
35
+ for scalar in cleaned.unicodeScalars {
36
+ if let script = _Script(scalar) { letterCounts[script, default: 0] += 1 }
37
+ }
38
+ let total = letterCounts.values.reduce(0, +)
39
+ guard total > 0 else { return [:] }
40
+
41
+ let characters = Array(cleaned)
42
+ let words = cleaned.split { !$0.isLetter }.map(String.init)
43
+ var result: [NLLanguage: Double] = [:]
44
+ for (script, count) in letterCounts {
45
+ let n = Double(count)
46
+ let weight = n / Double(total) * n / (n + 0.5)
47
+ let distribution = script.group.distribution(words: words, characters: characters,
48
+ hints: hints, constraints: constraints)
49
+ for (language, probability) in distribution {
50
+ result[language, default: 0] += weight * probability
51
+ }
52
+ }
53
+ return result.filter { $0.value >= 0.0001 }
54
+ }
55
+ }
56
+
57
+ // MARK: - Languages of a script
58
+
59
+ /// The languages written in one script, with what tells them apart.
60
+ struct _LanguageGroup: Sendable {
61
+ /// Each language and its prior, in points.
62
+ let candidates: [(NLLanguage, Double)]
63
+ /// Frequent words, each with the languages it is one of and the points it gives each.
64
+ var words: [String: [(NLLanguage, Double)]] = [:]
65
+ /// Distinctive letters, the same way.
66
+ var letters: [Character: [(NLLanguage, Double)]] = [:]
67
+ /// Letters known by their Unicode block (kana, Vietnamese's stacked diacritics).
68
+ var blocks: [(ClosedRange<UInt32>, NLLanguage, Double)] = []
69
+
70
+ init(_ candidates: [(NLLanguage, Double)]) { self.candidates = candidates }
71
+
72
+ /// `words` (space-separated) for each language; a word listed for k
73
+ /// languages gives each `points / k`.
74
+ func with(words lists: [NLLanguage: String], points: Double = 1) -> Self {
75
+ var copy = self
76
+ copy.words = Self.table(lists, points: points) { Array($0.split(separator: " ").map(String.init)) }
77
+ return copy
78
+ }
79
+
80
+ /// Distinctive letters (space-separated) for each language, like `with(words:)`.
81
+ func with(letters lists: [NLLanguage: String], points: Double = 0.5) -> Self {
82
+ var copy = self
83
+ for (key, entries) in Self.table(lists, points: points, split: { $0.split(separator: " ").compactMap(\.first) }) {
84
+ copy.letters[key, default: []] += entries
85
+ }
86
+ return copy
87
+ }
88
+
89
+ func with(block range: ClosedRange<UInt32>, _ language: NLLanguage, points: Double) -> Self {
90
+ var copy = self
91
+ copy.blocks.append((range, language, points))
92
+ return copy
93
+ }
94
+
95
+ private static func table<Key: Hashable>(_ lists: [NLLanguage: String], points: Double,
96
+ split: (String) -> [Key]) -> [Key: [(NLLanguage, Double)]] {
97
+ var owners: [Key: [NLLanguage]] = [:]
98
+ for (language, list) in lists {
99
+ for key in Set(split(list)) { owners[key, default: []].append(language) }
100
+ }
101
+ return owners.mapValues { languages in languages.map { ($0, points / Double(languages.count)) } }
102
+ }
103
+
104
+ func distribution(words text: [String], characters: [Character], hints: [NLLanguage: Double],
105
+ constraints: Set<NLLanguage>) -> [NLLanguage: Double] {
106
+ let candidates = constraints.isEmpty ? self.candidates : self.candidates.filter { constraints.contains($0.0) }
107
+ guard !candidates.isEmpty else { return [:] }
108
+ if candidates.count == 1 { return [candidates[0].0: 1] }
109
+
110
+ var points = Dictionary(candidates, uniquingKeysWith: { a, _ in a })
111
+ func add(_ entries: [(NLLanguage, Double)]?) {
112
+ for (language, value) in entries ?? [] where points[language] != nil { points[language]! += value }
113
+ }
114
+ if !words.isEmpty { for word in text { add(words[word]) } }
115
+ if !letters.isEmpty || !blocks.isEmpty {
116
+ for character in characters {
117
+ add(letters[character])
118
+ if let scalar = character.unicodeScalars.first?.value {
119
+ for (range, language, value) in blocks where range.contains(scalar) { add([(language, value)]) }
120
+ }
121
+ }
122
+ }
123
+
124
+ let smallestHint = hints.values.min() ?? 1
125
+ var logits = points.mapValues { _LanguageIdentifier.sharpness * $0 }
126
+ if !hints.isEmpty {
127
+ for language in logits.keys { logits[language]! += log(max(hints[language] ?? smallestHint, 1e-9)) }
128
+ }
129
+ let top = logits.values.max() ?? 0
130
+ let weights = logits.mapValues { exp($0 - top) }
131
+ let sum = weights.values.reduce(0, +)
132
+ return weights.mapValues { $0 / sum }
133
+ }
134
+ }
135
+
136
+ // MARK: - Scripts
137
+
138
+ enum _Script: Hashable, Sendable {
139
+ case latin, greek, cyrillic, armenian, hebrew, arabic, devanagari, bengali, gurmukhi, gujarati, oriya,
140
+ tamil, telugu, kannada, malayalam, sinhala, thai, lao, tibetan, myanmar, georgian, hangul,
141
+ ethiopic, cherokee, khmer, mongolian, cjk
142
+
143
+ /// The script of a letter, or nil for anything else.
144
+ init?(_ scalar: Unicode.Scalar) {
145
+ guard scalar.properties.isAlphabetic else { return nil }
146
+ switch scalar.value {
147
+ case 0x41...0x5A, 0x61...0x7A, 0xAA, 0xBA, 0xC0...0x24F, 0x1E00...0x1EFF, 0x2C60...0x2C7F,
148
+ 0xA720...0xA7FF, 0xFF21...0xFF3A, 0xFF41...0xFF5A: self = .latin
149
+ case 0x370...0x3FF, 0x1F00...0x1FFF: self = .greek
150
+ case 0x400...0x52F, 0x1C80...0x1C8F, 0x2DE0...0x2DFF, 0xA640...0xA69F: self = .cyrillic
151
+ case 0x530...0x58F: self = .armenian
152
+ case 0x590...0x5FF, 0xFB1D...0xFB4F: self = .hebrew
153
+ case 0x600...0x6FF, 0x750...0x77F, 0x8A0...0x8FF, 0xFB50...0xFDFF, 0xFE70...0xFEFF: self = .arabic
154
+ case 0x900...0x97F: self = .devanagari
155
+ case 0x980...0x9FF: self = .bengali
156
+ case 0xA00...0xA7F: self = .gurmukhi
157
+ case 0xA80...0xAFF: self = .gujarati
158
+ case 0xB00...0xB7F: self = .oriya
159
+ case 0xB80...0xBFF: self = .tamil
160
+ case 0xC00...0xC7F: self = .telugu
161
+ case 0xC80...0xCFF: self = .kannada
162
+ case 0xD00...0xD7F: self = .malayalam
163
+ case 0xD80...0xDFF: self = .sinhala
164
+ case 0xE00...0xE7F: self = .thai
165
+ case 0xE80...0xEFF: self = .lao
166
+ case 0xF00...0xFFF: self = .tibetan
167
+ case 0x1000...0x109F: self = .myanmar
168
+ case 0x10A0...0x10FF, 0x1C90...0x1CBF: self = .georgian
169
+ case 0x1100...0x11FF, 0x3130...0x318F, 0xAC00...0xD7AF: self = .hangul
170
+ case 0x1200...0x139F: self = .ethiopic
171
+ case 0x13A0...0x13FF, 0xAB70...0xABBF: self = .cherokee
172
+ case 0x1780...0x17FF: self = .khmer
173
+ case 0x1800...0x18AF: self = .mongolian
174
+ case 0x3040...0x30FF, 0x31F0...0x31FF, 0xFF66...0xFF9D, 0x3400...0x4DBF, 0x4E00...0x9FFF,
175
+ 0xF900...0xFAFF, 0x20000...0x2FA1F: self = .cjk
176
+ default: return nil
177
+ }
178
+ }
179
+
180
+ var group: _LanguageGroup {
181
+ switch self {
182
+ case .latin: _Groups.latin
183
+ case .cyrillic: _Groups.cyrillic
184
+ case .arabic: _Groups.arabic
185
+ case .devanagari: _Groups.devanagari
186
+ case .cjk: _Groups.cjk
187
+ case .greek: _Groups.single(.greek)
188
+ case .armenian: _Groups.single(.armenian)
189
+ case .hebrew: _Groups.single(.hebrew)
190
+ case .bengali: _Groups.single(.bengali)
191
+ case .gurmukhi: _Groups.single(.punjabi)
192
+ case .gujarati: _Groups.single(.gujarati)
193
+ case .oriya: _Groups.single(.oriya)
194
+ case .tamil: _Groups.single(.tamil)
195
+ case .telugu: _Groups.single(.telugu)
196
+ case .kannada: _Groups.single(.kannada)
197
+ case .malayalam: _Groups.single(.malayalam)
198
+ case .sinhala: _Groups.single(.sinhalese)
199
+ case .thai: _Groups.single(.thai)
200
+ case .lao: _Groups.single(.lao)
201
+ case .tibetan: _Groups.single(.tibetan)
202
+ case .myanmar: _Groups.single(.burmese)
203
+ case .georgian: _Groups.single(.georgian)
204
+ case .hangul: _Groups.single(.korean)
205
+ case .ethiopic: _Groups.single(.amharic)
206
+ case .cherokee: _Groups.single(.cherokee)
207
+ case .khmer: _Groups.single(.khmer)
208
+ case .mongolian: _Groups.single(.mongolian)
209
+ }
210
+ }
211
+ }
212
+
213
+ // MARK: - The tables
214
+
215
+ enum _Groups {
216
+ static func single(_ language: NLLanguage) -> _LanguageGroup { _LanguageGroup([(language, 0)]) }
217
+
218
+ static let latin = _LanguageGroup([
219
+ (.english, 0), (.french, 0), (.german, 0), (.spanish, 0), (.italian, 0), (.portuguese, 0), (.dutch, 0),
220
+ (.swedish, 0), (.danish, 0), (.norwegian, 0), (.finnish, 0), (.polish, 0), (.czech, 0), (.slovak, 0),
221
+ (.hungarian, 0), (.romanian, 0), (.turkish, 0), (.vietnamese, 0), (.indonesian, 0), (.malay, 0),
222
+ (.catalan, 0), (.croatian, 0), (.icelandic, 0),
223
+ ])
224
+ .with(words: [
225
+ .english: "i a one when up no more some them his her him who which how now time very really the and of to is in that it you for was with on are this have be not but they at what my just so we he she from has will can about there an or your me do if would all been were their our out like get",
226
+ .french: "pas ai as ont suis es on y ça cela mes tes ses nos vos votre notre aussi quand peut même le la les de des du un une et est en que qui dans pour pas sur au aux avec ce cette il elle je nous vous ne se sont mais ou plus très bien être avoir mon ma son sa leur ces tout fait comme été",
227
+ .german: "habe hast haben kein keine uns unser sehr schon mal jetzt hier was man heute dann doch ganz gibt diese dieser der die das und ist nicht ein eine ich du er sie es wir ihr mit auf für von zu den dem des auch sich im aber noch wie nur oder sind war wird bei nach kann mir mich dass einen hat",
228
+ .spanish: "te qué lo le les nos tengo tiene hoy quiero bien eso esto ese mis tu tus hasta desde porque donde el la los las de del que y en un una es por para con no se lo su al como más pero muy está son también yo me mi hay este esta ya cuando todo hace",
229
+ .italian: "ti cosa ci sei mio mia tuo tua oggi bene tutto perché quando dove questo quello fatto essere il lo la gli le di che e è un una per non in con del della sono mi ma si ho ha anche più questo questa come nel alla ci io molto sei",
230
+ .portuguese: "te meu minha seu sua hoje bem tudo porque quando onde aqui agora ainda sim vou vai o a os as de do da dos das que e é um uma em no na para com não por se mais mas como eu você ele ela isso muito está são foi tem nos ao também",
231
+ .dutch: "ben bent hebben heeft mijn jouw zijn haar ons onze hier daar waar hoe veel goed maken de het een en van ik je dat is niet op te zijn met voor er maar ook die wat als aan hij ze we nog naar wel dit heb kan om bij geen door nu zo",
232
+ .swedish: "mig dig vad hur där inget något vara blir bli kommer skulle och att det som en ett är på för med jag inte har av till den de om vi men du kan så var från eller hon han sig mycket här nu efter också bara",
233
+ .danish: "ingen noget være bliver blive kommer skulle hvordan og at det som en et er på for med jeg ikke har af til den de om vi men du kan så var fra eller hun han sig meget her nu efter også bare mig dig hvad der",
234
+ .norwegian: "ingen noe være blir bli kommer skulle hvordan og at det som en et er på for med jeg ikke har av til den de om vi men du kan så var fra eller hun han seg veldig her nå etter også bare meg deg hva der",
235
+ .finnish: "ja on ei se että oli hän mutta kun niin kuin tai myös minä sinä me te he tämä joka jos nyt vain ovat olen olla mitä siitä kanssa",
236
+ .polish: "mam masz ma jesteś jak gdzie kiedy dlaczego bo może nawet też jeszcze i w z na nie się to jest że do o jak ale po co tak za od jestem mnie już tylko czy ten są był bardzo przez dla",
237
+ .czech: "mám máš má jsi kde kdy proč protože může ještě tady a v se na je to že s z do o jak ale po co tak za od jsem mě už jen nebo ten jsou byl velmi pro také který není",
238
+ .slovak: "mám máš má si kde kedy prečo pretože môže ešte tu a v sa na je to že s z do o ako ale po čo tak za od som ma už len alebo ten sú bol veľmi pre aj ktorý nie",
239
+ .hungarian: "a az és hogy nem egy is van meg de ez el csak már még mint ki mi volt vagy nagyon kell lesz minden sem ha én te",
240
+ .romanian: "și şi de la în cu nu să pe ce din o un care mai este a sunt pentru dar am fost foarte acest această ei eu tu",
241
+ .turkish: "bana sana benim senin şimdi burada bugün nasıl neden ve bir bu da de için ne ile çok ama gibi daha var yok ben sen o biz onu mi mı değil olan kadar şey en her",
242
+ .vietnamese: "và của là có không được cho người trong những một các này với đã để khi tôi bạn đó từ cũng như rất về",
243
+ .indonesian: "dan yang di ke dari ini itu untuk dengan tidak ada saya kamu akan juga atau sudah bisa kita mereka karena pada dalam lebih tapi apa",
244
+ .malay: "dan yang di ke dari ini itu untuk dengan tidak ada saya anda akan juga atau sudah boleh kita mereka kerana pada dalam lebih tetapi apa",
245
+ .catalan: "el la els les de del i que en un una és per amb no es al com més però molt aquest aquesta jo hi ha són també seu",
246
+ .croatian: "i u je se na da za su od sa s ne to kao ali što ili ja ti smo ste bi bio sam iz po već samo jako",
247
+ .icelandic: "og að er í á ekki það sem til um við með ég hann hún en var af fyrir eru þetta þú hafa",
248
+ ])
249
+ .with(letters: [
250
+ .german: "ß ä ö ü",
251
+ .french: "à â ç è é ê ë î ï ô œ ù û ÿ",
252
+ .spanish: "á é í ñ ó ú ü ¿ ¡",
253
+ .portuguese: "á â ã à ç é ê í ó ô õ ú",
254
+ .italian: "à è é ì ò ù",
255
+ .catalan: "à ç è é í ï ò ó ú ü ·",
256
+ .polish: "ą ć ę ł ń ó ś ź ż",
257
+ .czech: "á č ď é ě í ň ó ř š ť ú ů ý ž",
258
+ .slovak: "á ä č ď é í ĺ ľ ň ó ô ŕ š ť ú ý ž",
259
+ .hungarian: "á é í ó ö ő ú ü ű",
260
+ .romanian: "ă â î ș ț ş ţ",
261
+ .turkish: "ç ğ ı ö ş ü â",
262
+ .swedish: "å ä ö",
263
+ .danish: "å æ ø",
264
+ .norwegian: "å æ ø",
265
+ .finnish: "ä ö",
266
+ .icelandic: "á æ é í ð ó ö þ ú ý",
267
+ .croatian: "č ć đ š ž",
268
+ .vietnamese: "à á â ã è é ê ì í ò ó ô õ ù ú ý ă đ ơ ư",
269
+ ])
270
+ .with(block: 0x1EA0...0x1EF9, .vietnamese, points: 0.5)
271
+
272
+ static let cyrillic = _LanguageGroup([(.russian, 2), (.ukrainian, 0), (.bulgarian, 0), (.kazakh, 0), (.mongolian, 0)])
273
+ .with(words: [
274
+ .russian: "и в не на что я с это как он а то все по но мы ты так его для у же вы бы мне меня был она они от",
275
+ .ukrainian: "і й та що не на це як з у в я але він ми ти для від до так його вже ви б мені мене був вона вони",
276
+ .bulgarian: "и в на не да се е за от че това като по са но ще с ти аз ние той тя бе съм",
277
+ .kazakh: "және мен бұл да де деп бір үшін ол біз сен жоқ бар емес",
278
+ .mongolian: "болон нь энэ би бид та юу байна байгаа гэж ч бол",
279
+ ])
280
+ .with(letters: [
281
+ .russian: "ы э ё",
282
+ .ukrainian: "і ї є ґ",
283
+ .bulgarian: "ъ",
284
+ .kazakh: "ә ғ қ ң ө ұ ү һ і ы э",
285
+ .mongolian: "ө ү ы э ё",
286
+ ])
287
+
288
+ static let arabic = _LanguageGroup([(.arabic, 2), (.persian, 0), (.urdu, 0)])
289
+ .with(words: [
290
+ .arabic: "في من على إلى أن هذا التي الذي عن مع كان ما لا هو هي و",
291
+ .persian: "و در به از که این را با است برای آن می یک هم",
292
+ .urdu: "کے میں کی ہے اور سے کو یہ نہیں ہیں پر کا ایک",
293
+ ])
294
+ .with(letters: [
295
+ .arabic: "ة ي ك ى إ أ ؤ ئ",
296
+ .persian: "پ چ ژ گ ی ک",
297
+ .urdu: "پ چ ژ گ ی ک ٹ ڈ ڑ ں ے ھ ۓ",
298
+ ])
299
+
300
+ static let devanagari = _LanguageGroup([(.hindi, 2), (.marathi, 0)])
301
+ .with(words: [
302
+ .hindi: "है के में की और का को से नहीं यह हैं भी पर था",
303
+ .marathi: "आहे आणि च्या ला नाही हे या मी आहेत तर पण",
304
+ ])
305
+ .with(letters: [.marathi: "ळ"])
306
+
307
+ /// Han and kana. Kana is Japanese; Han characters that differ between
308
+ /// the two Chinese scripts tell them apart (Japanese shares many simplified forms).
309
+ static let cjk = _LanguageGroup([(.simplifiedChinese, 1), (.traditionalChinese, 0), (.japanese, 0)])
310
+ .with(letters: [
311
+ .simplifiedChinese: "们 这 说 来 时 个 国 会 为 对 后 发 过 学 没 还 么 现 开 见 长 门 问 间 关 东 车 书 从 电 话 让 给 进 认 应 实 经 动 与 业 头 样 点 万 气 马 听 买 卖 爱 觉 写 读 难 边",
312
+ .traditionalChinese: "們 這 說 來 時 個 國 會 為 對 後 發 過 學 沒 還 麼 現 開 見 長 門 問 間 關 東 車 書 從 電 話 讓 給 進 認 應 實 經 動 與 業 頭 樣 點 萬 氣 馬 聽 買 賣 愛 覺 寫 讀 難 邊",
313
+ ], points: 2)
314
+ .with(block: 0x3040...0x30FF, .japanese, points: 1)
315
+ .with(block: 0x31F0...0x31FF, .japanese, points: 1)
316
+ .with(block: 0xFF66...0xFF9D, .japanese, points: 1)
317
+ }