@swiftbrowser/swift 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Package.swift +200 -9
- package/README.md +7 -9
- package/Sources/AVFoundation/AVFoundation.swift +131 -0
- package/Sources/AVFoundation/Asset.swift +487 -0
- package/Sources/AVFoundation/AudioSession.swift +144 -0
- package/Sources/AVFoundation/CMTime.swift +303 -0
- package/Sources/AVFoundation/Capture.swift +688 -0
- package/Sources/AVFoundation/Player.swift +749 -0
- package/Sources/AVFoundation/PlayerView.swift +117 -0
- package/Sources/AVKit/AVKit.swift +132 -0
- package/Sources/Accelerate/Accelerate.swift +122 -0
- package/Sources/AppIntents/AppIntents.swift +144 -0
- package/Sources/AppIntents/Parameters.swift +220 -0
- package/Sources/AppIntents/Shortcuts.swift +159 -0
- package/Sources/AudioToolbox/AudioToolbox.swift +55 -0
- package/Sources/AuthenticationServices/AuthenticationServices.swift +257 -0
- package/Sources/AuthenticationServices/Authorization.swift +251 -0
- package/Sources/Charts/Charts.swift +0 -4
- package/Sources/Combine/AnyCancellable.swift +65 -0
- package/Sources/Combine/AnyPublisher.swift +148 -0
- package/Sources/Combine/AnySubscriber.swift +230 -0
- package/Sources/Combine/Cancellable.swift +35 -0
- package/Sources/Combine/Codable.swift +29 -0
- package/Sources/Combine/CombineIdentifier.swift +45 -0
- package/Sources/Combine/Concurrency/ConcurrencyHelpers.swift +24 -0
- package/Sources/Combine/Concurrency/Future+Concurrency.swift +136 -0
- package/Sources/Combine/Concurrency/GENERATED-Publisher+Concurrency.swift +397 -0
- package/Sources/Combine/CurrentValueSubject.swift +252 -0
- package/Sources/Combine/CustomCombineIdentifierConvertible.swift +28 -0
- package/Sources/Combine/Future.swift +228 -0
- package/Sources/Combine/GENERATED-RootProtocols.swift +426 -0
- package/Sources/Combine/Helpers/ConduitBase.swift +40 -0
- package/Sources/Combine/Helpers/ConduitList.swift +59 -0
- package/Sources/Combine/Helpers/DebugHook.swift +177 -0
- package/Sources/Combine/Helpers/FilterProducer.swift +174 -0
- package/Sources/Combine/Helpers/Locking.swift +30 -0
- package/Sources/Combine/Helpers/PartialCompletion.swift +26 -0
- package/Sources/Combine/Helpers/ReduceProducer.swift +249 -0
- package/Sources/Combine/Helpers/SubjectSubscriber.swift +96 -0
- package/Sources/Combine/Helpers/SubscriberTap.swift +69 -0
- package/Sources/Combine/Helpers/SubscriptionStatus.swift +33 -0
- package/Sources/Combine/Helpers/SubscriptionTap.swift +33 -0
- package/Sources/Combine/Helpers/Utils.swift +30 -0
- package/Sources/Combine/Helpers/Violations.swift +33 -0
- package/Sources/Combine/ImmediateScheduler.swift +178 -0
- package/Sources/Combine/LICENSE +21 -0
- package/Sources/Combine/NotificationPublisher.swift +48 -0
- package/Sources/Combine/ObjectWillChange.swift +46 -0
- package/Sources/Combine/PassthroughSubject.swift +222 -0
- package/Sources/Combine/Publisher+Subscribe.swift +53 -0
- package/Sources/Combine/Publishers/Deferred.swift +48 -0
- package/Sources/Combine/Publishers/Empty.swift +54 -0
- package/Sources/Combine/Publishers/Fail.swift +42 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.Catch.swift +673 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.Encode.swift +388 -0
- package/Sources/Combine/Publishers/GENERATED-Publishers.MapKeyPath.swift +384 -0
- package/Sources/Combine/Publishers/Just.swift +313 -0
- package/Sources/Combine/Publishers/Optional.Publisher.swift +315 -0
- package/Sources/Combine/Publishers/Publishers.AllSatisfy.swift +217 -0
- package/Sources/Combine/Publishers/Publishers.AssertNoFailure.swift +158 -0
- package/Sources/Combine/Publishers/Publishers.Autoconnect.swift +193 -0
- package/Sources/Combine/Publishers/Publishers.Breakpoint.swift +231 -0
- package/Sources/Combine/Publishers/Publishers.Buffer.swift +356 -0
- package/Sources/Combine/Publishers/Publishers.Collect.swift +102 -0
- package/Sources/Combine/Publishers/Publishers.CollectByCount.swift +195 -0
- package/Sources/Combine/Publishers/Publishers.CompactMap.swift +241 -0
- package/Sources/Combine/Publishers/Publishers.Comparison.swift +371 -0
- package/Sources/Combine/Publishers/Publishers.Concatenate.swift +474 -0
- package/Sources/Combine/Publishers/Publishers.Contains.swift +293 -0
- package/Sources/Combine/Publishers/Publishers.Count.swift +87 -0
- package/Sources/Combine/Publishers/Publishers.Debounce.swift +332 -0
- package/Sources/Combine/Publishers/Publishers.Delay.swift +269 -0
- package/Sources/Combine/Publishers/Publishers.Drop.swift +155 -0
- package/Sources/Combine/Publishers/Publishers.DropUntilOutput.swift +283 -0
- package/Sources/Combine/Publishers/Publishers.DropWhile.swift +378 -0
- package/Sources/Combine/Publishers/Publishers.Filter.swift +248 -0
- package/Sources/Combine/Publishers/Publishers.First.swift +261 -0
- package/Sources/Combine/Publishers/Publishers.FlatMap.swift +533 -0
- package/Sources/Combine/Publishers/Publishers.HandleEvents.swift +260 -0
- package/Sources/Combine/Publishers/Publishers.IgnoreOutput.swift +109 -0
- package/Sources/Combine/Publishers/Publishers.Last.swift +252 -0
- package/Sources/Combine/Publishers/Publishers.MakeConnectable.swift +82 -0
- package/Sources/Combine/Publishers/Publishers.Map.swift +351 -0
- package/Sources/Combine/Publishers/Publishers.MapError.swift +140 -0
- package/Sources/Combine/Publishers/Publishers.MeasureInterval.swift +187 -0
- package/Sources/Combine/Publishers/Publishers.Multicast.swift +284 -0
- package/Sources/Combine/Publishers/Publishers.Output.swift +241 -0
- package/Sources/Combine/Publishers/Publishers.PrefixUntilOutput.swift +197 -0
- package/Sources/Combine/Publishers/Publishers.PrefixWhile.swift +176 -0
- package/Sources/Combine/Publishers/Publishers.Print.swift +206 -0
- package/Sources/Combine/Publishers/Publishers.ReceiveOn.swift +227 -0
- package/Sources/Combine/Publishers/Publishers.Reduce.swift +204 -0
- package/Sources/Combine/Publishers/Publishers.RemoveDuplicates.swift +264 -0
- package/Sources/Combine/Publishers/Publishers.ReplaceEmpty.swift +201 -0
- package/Sources/Combine/Publishers/Publishers.ReplaceError.swift +211 -0
- package/Sources/Combine/Publishers/Publishers.Retry.swift +274 -0
- package/Sources/Combine/Publishers/Publishers.Scan.swift +331 -0
- package/Sources/Combine/Publishers/Publishers.Sequence.swift +437 -0
- package/Sources/Combine/Publishers/Publishers.SetFailureType.swift +120 -0
- package/Sources/Combine/Publishers/Publishers.Share.swift +104 -0
- package/Sources/Combine/Publishers/Publishers.SubscribeOn.swift +197 -0
- package/Sources/Combine/Publishers/Publishers.SwitchToLatest.swift +444 -0
- package/Sources/Combine/Publishers/Publishers.Throttle.swift +359 -0
- package/Sources/Combine/Publishers/Publishers.Timeout.swift +301 -0
- package/Sources/Combine/Publishers/Publishers.Zip.swift +720 -0
- package/Sources/Combine/Publishers/Publishers.swift +13 -0
- package/Sources/Combine/Publishers/Record.swift +237 -0
- package/Sources/Combine/Publishers/Result.Publisher.swift +337 -0
- package/Sources/Combine/Result.swift +46 -0
- package/Sources/Combine/Scheduler.swift +89 -0
- package/Sources/Combine/Schedulers.swift +211 -0
- package/Sources/Combine/Subject+Void.swift +17 -0
- package/Sources/Combine/Subscriber+Void.swift +20 -0
- package/Sources/Combine/Subscribers/Subscribers.Assign.swift +175 -0
- package/Sources/Combine/Subscribers/Subscribers.Completion.swift +90 -0
- package/Sources/Combine/Subscribers/Subscribers.Demand.swift +476 -0
- package/Sources/Combine/Subscribers/Subscribers.Sink.swift +206 -0
- package/Sources/Combine/Subscribers/Subscribers.swift +9 -0
- package/Sources/Combine/Subscription.swift +22 -0
- package/Sources/Combine/Subscriptions.swift +42 -0
- package/Sources/Combine/SwiftUIObservation.swift +10 -0
- package/Sources/Combine/_Introspection.swift +107 -0
- package/Sources/CommonCrypto/CommonCrypto.swift +80 -0
- package/Sources/Compression/Compression.swift +365 -0
- package/Sources/Compression/Deflate.swift +407 -0
- package/Sources/Compression/Zlib.swift +179 -0
- package/Sources/CoreFoundationTypes/CoreFoundationTypes.swift +101 -0
- package/Sources/CoreGraphics/CoreGraphics.swift +411 -0
- package/Sources/CoreGraphics/ProjectionTransforms.swift +28 -0
- package/Sources/CoreHaptics/CoreHaptics.swift +399 -0
- package/Sources/CoreImage/CIColor.swift +41 -0
- package/Sources/CoreImage/CIContext.swift +31 -0
- package/Sources/CoreImage/CIDetector.swift +57 -0
- package/Sources/CoreImage/CIFilter.swift +243 -0
- package/Sources/CoreImage/CIFilterBuiltins.swift +136 -0
- package/Sources/CoreImage/CIImage.swift +162 -0
- package/Sources/CoreImage/QRCode.swift +393 -0
- package/Sources/CoreLocation/Coordinate.swift +30 -0
- package/Sources/CoreLocation/Location.swift +65 -0
- package/Sources/CoreML/Evaluation.swift +414 -0
- package/Sources/CoreML/FeatureValue.swift +266 -0
- package/Sources/CoreML/Model.swift +269 -0
- package/Sources/CoreML/MultiArray.swift +92 -0
- package/Sources/CoreML/Specification.swift +233 -0
- package/Sources/CoreText/CoreText.swift +64 -0
- package/Sources/CoreTransferable/CoreTransferable.swift +606 -0
- package/Sources/CryptoKit/ChaChaPoly.swift +258 -0
- package/Sources/CryptoKit/CryptoKit.swift +375 -0
- package/Sources/CryptoKit/Curve25519.swift +317 -0
- package/Sources/CryptoKit/P256.swift +321 -0
- package/Sources/FoundationBridge/AppStorage.swift +165 -0
- package/Sources/FoundationBridge/AssetResources.swift +90 -0
- package/Sources/FoundationBridge/AsyncBytes.swift +128 -0
- package/Sources/FoundationBridge/AsyncImage.swift +116 -0
- package/Sources/FoundationBridge/AttributedStrings.swift +16 -0
- package/Sources/{_FoundationCommon → FoundationBridge}/Bundle.swift +41 -4
- package/Sources/FoundationBridge/CombineExports.swift +8 -0
- package/Sources/FoundationBridge/CoreFoundation.swift +77 -0
- package/Sources/FoundationBridge/Dispatch.swift +458 -0
- package/Sources/FoundationBridge/EnvironmentFoundation.swift +41 -0
- package/Sources/FoundationBridge/FileImporter.swift +128 -0
- package/Sources/FoundationBridge/FileSystem.swift +68 -0
- package/Sources/FoundationBridge/FoundationBridge.swift +24 -72
- package/Sources/FoundationBridge/HostResolution.swift +31 -0
- package/Sources/FoundationBridge/ItemProvider.swift +655 -0
- package/Sources/FoundationBridge/KeyValueObserving.swift +138 -0
- package/Sources/FoundationBridge/Links.swift +127 -0
- package/Sources/FoundationBridge/ListFormatter.swift +32 -0
- package/Sources/FoundationBridge/Localization.swift +149 -0
- package/Sources/FoundationBridge/Locks.swift +50 -0
- package/Sources/FoundationBridge/Markdown.swift +527 -0
- package/Sources/FoundationBridge/MeasurementFormat.swift +95 -0
- package/Sources/FoundationBridge/NotificationCenter.swift +154 -0
- package/Sources/FoundationBridge/OpenURLHandlers.swift +60 -0
- package/Sources/FoundationBridge/Operation.swift +195 -0
- package/Sources/FoundationBridge/ProcessInfo.swift +32 -0
- package/Sources/FoundationBridge/RelativeDateTimeFormatter.swift +136 -0
- package/Sources/FoundationBridge/SceneStorage.swift +78 -0
- package/Sources/FoundationBridge/SecurityExports.swift +8 -0
- package/Sources/FoundationBridge/Selector.swift +226 -0
- package/Sources/FoundationBridge/StringComparators.swift +17 -0
- package/Sources/FoundationBridge/Table.swift +211 -0
- package/Sources/FoundationBridge/TextAttributes.swift +42 -0
- package/Sources/FoundationBridge/Timer.swift +6 -1
- package/Sources/FoundationBridge/URLSession.swift +718 -0
- package/Sources/{_FoundationCommon → FoundationBridge}/UserDefaults.swift +17 -4
- package/Sources/FoundationBridge/WebAuthRedirects.swift +227 -0
- package/Sources/FoundationBridge/WebSocket.swift +187 -0
- package/Sources/FoundationModels/FoundationModels.swift +1098 -0
- package/Sources/ImageIO/GIF.swift +72 -0
- package/Sources/ImageIO/ImageIO.swift +248 -0
- package/Sources/ImageIO/ImageTypes.swift +28 -0
- package/Sources/LinkPresentation/LinkPresentation.swift +249 -0
- package/Sources/LocalAuthentication/LAContext.swift +86 -0
- package/Sources/MapKit/Geometry.swift +223 -0
- package/Sources/MapKit/Map.swift +638 -0
- package/Sources/MapKit/MapView.swift +229 -0
- package/Sources/MobileCoreServices/MobileCoreServices.swift +28 -0
- package/Sources/NaturalLanguage/LanguageIdentifier.swift +317 -0
- package/Sources/NaturalLanguage/NaturalLanguage.swift +135 -0
- package/Sources/OSLog/OSLog.swift +6 -0
- package/Sources/Photos/Photos.swift +572 -0
- package/Sources/PhotosUI/PhotosPicker.swift +248 -0
- package/Sources/PhotosUI/PhotosPickerItem.swift +261 -0
- package/Sources/QuickLook/QuickLook.swift +168 -0
- package/Sources/SafariServices/SafariServices.swift +106 -0
- package/Sources/Security/Security.swift +332 -0
- package/Sources/StoreKit/AppStore.swift +207 -0
- package/Sources/StoreKit/Products.swift +280 -0
- package/Sources/StoreKit/RequestReview.swift +28 -0
- package/Sources/StoreKit/StoreKit1.swift +486 -0
- package/Sources/StoreKit/StoreViews.swift +428 -0
- package/Sources/StoreKit/Transactions.swift +197 -0
- package/Sources/SwiftData/Macros.swift +58 -0
- package/Sources/SwiftData/ModelActor.swift +38 -0
- package/Sources/SwiftData/ModelContainer.swift +129 -0
- package/Sources/SwiftData/ModelContext.swift +451 -0
- package/Sources/SwiftData/PersistentModel.swift +238 -0
- package/Sources/SwiftData/Properties.swift +261 -0
- package/Sources/SwiftData/Query.swift +256 -0
- package/Sources/SwiftData/Schema.swift +192 -0
- package/Sources/SwiftData/Store.swift +146 -0
- package/Sources/SwiftData/StringPredicates.swift +125 -0
- package/Sources/SwiftDataMacros/EntryMacro.swift +82 -0
- package/Sources/SwiftDataMacros/GenerableMacro.swift +183 -0
- package/Sources/SwiftDataMacros/ModelActorMacro.swift +46 -0
- package/Sources/SwiftDataMacros/ModelMacro.swift +260 -0
- package/Sources/SwiftDataMacros/Plugin.swift +18 -0
- package/Sources/SwiftDataMacros/PredicateMacro.swift +1244 -0
- package/Sources/SwiftUI/API/Accessibility.swift +55 -6
- package/Sources/SwiftUI/API/AccessibilityExtras.swift +33 -0
- package/Sources/SwiftUI/API/AccessibilityFocus.swift +63 -0
- package/Sources/SwiftUI/API/Alert.swift +1 -1
- package/Sources/SwiftUI/API/AlignmentGuides.swift +68 -0
- package/Sources/SwiftUI/API/Animation.swift +37 -5
- package/Sources/SwiftUI/API/App.swift +31 -1
- package/Sources/SwiftUI/API/BindingCollections.swift +35 -0
- package/Sources/SwiftUI/API/BindingForEach.swift +27 -0
- package/Sources/SwiftUI/API/Bitmaps.swift +254 -0
- package/Sources/SwiftUI/API/ButtonStyles.swift +96 -0
- package/Sources/SwiftUI/API/Canvas.swift +337 -0
- package/Sources/SwiftUI/API/Color.swift +104 -28
- package/Sources/SwiftUI/API/ColorEffects.swift +52 -0
- package/Sources/SwiftUI/API/ColorPickerAndLabeledContent.swift +138 -0
- package/Sources/SwiftUI/API/ColorSpaces.swift +161 -0
- package/Sources/SwiftUI/API/Commands.swift +106 -0
- package/Sources/SwiftUI/API/ContainerBackground.swift +28 -0
- package/Sources/SwiftUI/API/ContentShape.swift +33 -0
- package/Sources/SwiftUI/API/ContentSizeCategory.swift +35 -0
- package/Sources/SwiftUI/API/ContentUnavailable.swift +101 -0
- package/Sources/SwiftUI/API/Controls.swift +59 -27
- package/Sources/SwiftUI/API/CustomLayout.swift +49 -10
- package/Sources/SwiftUI/API/CustomToolbarContent.swift +46 -0
- package/Sources/SwiftUI/API/Decorations.swift +1 -1
- package/Sources/SwiftUI/API/EditMode.swift +25 -82
- package/Sources/SwiftUI/API/Effects.swift +125 -10
- package/Sources/SwiftUI/API/Entry.swift +8 -0
- package/Sources/SwiftUI/API/Environment.swift +100 -9
- package/Sources/SwiftUI/API/EnvironmentSendable.swift +6 -0
- package/Sources/SwiftUI/API/Focus.swift +11 -3
- package/Sources/SwiftUI/API/Gauge.swift +26 -10
- package/Sources/SwiftUI/API/GeometryEffects.swift +232 -0
- package/Sources/SwiftUI/API/GeometryReader.swift +13 -2
- package/Sources/SwiftUI/API/GestureState.swift +65 -0
- package/Sources/SwiftUI/API/Gestures.swift +1 -1
- package/Sources/SwiftUI/API/Glass.swift +127 -0
- package/Sources/SwiftUI/API/Grid.swift +1 -1
- package/Sources/SwiftUI/API/GroupBoxAndControlGroup.swift +130 -0
- package/Sources/SwiftUI/API/KeyPress.swift +54 -0
- package/Sources/SwiftUI/API/LabelStyle.swift +13 -6
- package/Sources/SwiftUI/API/Layout.swift +71 -12
- package/Sources/SwiftUI/API/LazyStacks.swift +49 -0
- package/Sources/SwiftUI/API/LegacyAlert.swift +97 -0
- package/Sources/SwiftUI/API/Lists.swift +61 -6
- package/Sources/SwiftUI/API/Menu.swift +8 -1
- package/Sources/SwiftUI/API/Modifiers.swift +88 -12
- package/Sources/SwiftUI/API/MoreModifiers.swift +100 -0
- package/Sources/SwiftUI/API/Namespace.swift +44 -0
- package/Sources/SwiftUI/API/Navigation.swift +24 -9
- package/Sources/SwiftUI/API/NavigationDestinationBindings.swift +55 -0
- package/Sources/SwiftUI/API/ObservableObject.swift +16 -2
- package/Sources/SwiftUI/API/Path.swift +543 -0
- package/Sources/SwiftUI/API/Phase8Controls.swift +48 -31
- package/Sources/SwiftUI/API/PhaseAnimator.swift +130 -0
- package/Sources/SwiftUI/API/Picker.swift +14 -4
- package/Sources/SwiftUI/API/PointerAndKeyboard.swift +77 -0
- package/Sources/SwiftUI/API/Popover.swift +41 -0
- package/Sources/SwiftUI/API/Preferences.swift +262 -0
- package/Sources/SwiftUI/API/Presentation.swift +17 -4
- package/Sources/SwiftUI/API/PresentationExtras.swift +60 -0
- package/Sources/SwiftUI/API/Primitives.swift +168 -39
- package/Sources/SwiftUI/API/Publishers.swift +4 -4
- package/Sources/SwiftUI/API/Redaction.swift +75 -0
- package/Sources/SwiftUI/API/RowActions.swift +3 -2
- package/Sources/SwiftUI/API/Scenes.swift +131 -0
- package/Sources/SwiftUI/API/ScrollModifiers.swift +132 -0
- package/Sources/SwiftUI/API/ScrollTargets.swift +3 -3
- package/Sources/SwiftUI/API/ScrollViewReader.swift +144 -0
- package/Sources/SwiftUI/API/SectionSupplements.swift +86 -0
- package/Sources/SwiftUI/API/Shape.swift +214 -0
- package/Sources/SwiftUI/API/ShapeStyle.swift +187 -8
- package/Sources/SwiftUI/API/ShapeTrim.swift +78 -0
- package/Sources/SwiftUI/API/Sharing.swift +193 -0
- package/Sources/SwiftUI/API/StackLayouts.swift +199 -0
- package/Sources/SwiftUI/API/State.swift +18 -1
- package/Sources/SwiftUI/API/StatusGaps.swift +121 -0
- package/Sources/SwiftUI/API/SymbolEffects.swift +203 -0
- package/Sources/SwiftUI/API/TabContent.swift +841 -0
- package/Sources/SwiftUI/API/Table.swift +382 -0
- package/Sources/SwiftUI/API/Tabs.swift +148 -4
- package/Sources/SwiftUI/API/Tasks.swift +2 -2
- package/Sources/SwiftUI/API/Text.swift +386 -0
- package/Sources/SwiftUI/API/TextDates.swift +61 -0
- package/Sources/SwiftUI/API/TextDecorations.swift +52 -0
- package/Sources/SwiftUI/API/TextFieldAxis.swift +103 -0
- package/Sources/SwiftUI/API/TextFieldCommit.swift +52 -0
- package/Sources/SwiftUI/API/Toolbar.swift +52 -16
- package/Sources/SwiftUI/API/Transfer.swift +145 -0
- package/Sources/SwiftUI/API/UnevenRoundedRectangle.swift +66 -0
- package/Sources/SwiftUI/API/Video.swift +64 -0
- package/Sources/SwiftUI/API/View.swift +46 -2
- package/Sources/SwiftUI/API/ViewModifier.swift +4 -1
- package/Sources/SwiftUI/API/VisualEffect.swift +74 -1
- package/Sources/SwiftUI/API/Windows.swift +25 -0
- package/Sources/SwiftUI/Charts/Axis.swift +7 -1
- package/Sources/SwiftUI/Charts/AxisFormatsAndRanges.swift +68 -0
- package/Sources/SwiftUI/Charts/Chart.swift +17 -3
- package/Sources/SwiftUI/Charts/ChartProxy.swift +57 -0
- package/Sources/SwiftUI/Localization/Localization.swift +524 -0
- package/Sources/SwiftUI/Localization/PluralRules.swift +127 -0
- package/Sources/SwiftUI/Runtime/Executor.swift +2 -0
- package/Sources/SwiftUI/Runtime/Exports.swift +37 -1
- package/Sources/SwiftUI/Runtime/ImageSource.swift +310 -0
- package/Sources/SwiftUI/Runtime/JSON.swift +76 -4
- package/Sources/SwiftUI/Runtime/LazyRows.swift +99 -0
- package/Sources/SwiftUI/Runtime/Measurements.swift +140 -0
- package/Sources/SwiftUI/Runtime/Ops.swift +58 -12
- package/Sources/SwiftUI/Runtime/Reconciler.swift +10 -1
- package/Sources/SwiftUI/Runtime/Replay.swift +382 -0
- package/Sources/SwiftUI/Runtime/Runtime.swift +977 -198
- package/Sources/SwiftUI/Runtime/Sameness.swift +152 -0
- package/Sources/SwiftUI/Runtime/ViewPath.swift +89 -0
- package/Sources/SwiftUI/Runtime/ViewTraits.swift +175 -0
- package/Sources/SwiftUI/Runtime/WebAuthHeadless.swift +49 -0
- package/Sources/Symbols/Symbols.swift +25 -0
- package/Sources/Translation/Translation.swift +423 -0
- package/Sources/UIKit/Activity.swift +213 -0
- package/Sources/UIKit/Alerts.swift +69 -0
- package/Sources/UIKit/AppDelegate.swift +222 -0
- package/Sources/UIKit/Appearance.swift +84 -0
- package/Sources/UIKit/ColorConversions.swift +70 -0
- package/Sources/UIKit/Controls.swift +225 -0
- package/Sources/UIKit/Device.swift +200 -0
- package/Sources/UIKit/Feedback.swift +65 -0
- package/Sources/UIKit/Font.swift +307 -0
- package/Sources/UIKit/Graphics.swift +204 -0
- package/Sources/UIKit/HostingController.swift +185 -0
- package/Sources/UIKit/Identity.swift +24 -0
- package/Sources/UIKit/Introspectable.swift +510 -0
- package/Sources/UIKit/Pasteboard.swift +363 -0
- package/Sources/UIKit/PhotoAlbum.swift +81 -0
- package/Sources/UIKit/RemoteNotifications.swift +15 -0
- package/Sources/UIKit/Representable.swift +288 -0
- package/Sources/UIKit/SafeArea.swift +12 -0
- package/Sources/UIKit/SceneDelegates.swift +132 -0
- package/Sources/UIKit/Scenes.swift +40 -0
- package/Sources/UIKit/ScrollView.swift +157 -0
- package/Sources/UIKit/ShortcutItems.swift +67 -0
- package/Sources/UIKit/SymbolConfiguration.swift +124 -0
- package/Sources/UIKit/TargetAction.swift +123 -0
- package/Sources/UIKit/TextPaste.swift +161 -0
- package/Sources/UIKit/TextView.swift +538 -0
- package/Sources/UIKit/UIKit.swift +292 -0
- package/Sources/UIKit/UIView.swift +855 -0
- package/Sources/UIKit/ViewTranslation.swift +311 -0
- package/Sources/UniformTypeIdentifiers/UTType.swift +196 -0
- package/Sources/UserNotifications/Content.swift +370 -0
- package/Sources/UserNotifications/NotificationCenter.swift +309 -0
- package/Sources/WeatherKit/WeatherKit.swift +228 -0
- package/Sources/WebKit/WebKit.swift +245 -0
- package/Sources/os/os.swift +376 -0
- package/Sources/zlib/zlib.swift +6 -0
- package/index.d.ts +1 -1
- package/index.mjs +2 -2
- package/manifest.d.mts +2 -0
- package/manifest.mjs +41 -0
- package/package.json +5 -3
- package/sync-sources.mjs +21 -7
- package/Sources/FoundationLite/Common.swift +0 -3
- package/Sources/FoundationLite/FoundationLite.swift +0 -171
- package/Sources/FoundationLite/Interaction.swift +0 -146
- package/Sources/FoundationLite/Timer.swift +0 -48
- package/Sources/_FoundationCommon/_FoundationCommon.swift +0 -10
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
// `import os` for the browser: Apple's unified logging, signposts and
|
|
2
|
+
// `os_unfair_lock`, as packages use them. The page has one thread, so the
|
|
3
|
+
// lock never waits (it still checks that it is not taken twice); log
|
|
4
|
+
// messages go to standard error, which the page shows in the console, and
|
|
5
|
+
// signposts are dropped.
|
|
6
|
+
|
|
7
|
+
/// A lock, as `os_unfair_lock_t` points to one.
|
|
8
|
+
public struct os_unfair_lock: Sendable {
|
|
9
|
+
var _locked = false
|
|
10
|
+
|
|
11
|
+
public init() {}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public typealias os_unfair_lock_t = UnsafeMutablePointer<os_unfair_lock>
|
|
15
|
+
public typealias os_unfair_lock_s = os_unfair_lock
|
|
16
|
+
|
|
17
|
+
public func os_unfair_lock_lock(_ lock: os_unfair_lock_t) {
|
|
18
|
+
precondition(!lock.pointee._locked, "os_unfair_lock_lock: the lock is already held (the browser has one thread, so this would wait forever)")
|
|
19
|
+
lock.pointee._locked = true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public func os_unfair_lock_unlock(_ lock: os_unfair_lock_t) {
|
|
23
|
+
lock.pointee._locked = false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public func os_unfair_lock_trylock(_ lock: os_unfair_lock_t) -> Bool {
|
|
27
|
+
guard !lock.pointee._locked else { return false }
|
|
28
|
+
lock.pointee._locked = true
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public func os_unfair_lock_assert_owner(_ lock: os_unfair_lock_t) {}
|
|
33
|
+
public func os_unfair_lock_assert_not_owner(_ lock: os_unfair_lock_t) {}
|
|
34
|
+
|
|
35
|
+
/// A lock that owns the state it protects (`OSAllocatedUnfairLock<State>`).
|
|
36
|
+
/// The page has one thread, so it never waits; taking it inside its own
|
|
37
|
+
/// `withLock` traps, as `os_unfair_lock` does.
|
|
38
|
+
public struct OSAllocatedUnfairLock<State>: @unchecked Sendable {
|
|
39
|
+
final class Storage {
|
|
40
|
+
var state: State
|
|
41
|
+
var locked = false
|
|
42
|
+
init(_ state: State) { self.state = state }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let storage: Storage
|
|
46
|
+
|
|
47
|
+
public init(uncheckedState initialState: State) { storage = Storage(initialState) }
|
|
48
|
+
public init(initialState: State) where State: Sendable { storage = Storage(initialState) }
|
|
49
|
+
|
|
50
|
+
public func withLock<R>(_ body: @Sendable (inout State) throws -> R) rethrows -> R where R: Sendable {
|
|
51
|
+
try withLockUnchecked(body)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public func withLockUnchecked<R>(_ body: (inout State) throws -> R) rethrows -> R {
|
|
55
|
+
Swift.precondition(!storage.locked, "OSAllocatedUnfairLock: the lock is already held (the browser has one thread, so this would wait forever)")
|
|
56
|
+
storage.locked = true
|
|
57
|
+
defer { storage.locked = false }
|
|
58
|
+
return try body(&storage.state)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public func withLockIfAvailable<R>(_ body: @Sendable (inout State) throws -> R) rethrows -> R? where R: Sendable {
|
|
62
|
+
guard !storage.locked else { return nil }
|
|
63
|
+
return try withLockUnchecked(body)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public func withLockIfAvailableUnchecked<R>(_ body: (inout State) throws -> R) rethrows -> R? {
|
|
67
|
+
guard !storage.locked else { return nil }
|
|
68
|
+
return try withLockUnchecked(body)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public func precondition(_ condition: Ownership) {}
|
|
72
|
+
|
|
73
|
+
public enum Ownership: Sendable { case owner, notOwner }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
extension OSAllocatedUnfairLock where State == () {
|
|
77
|
+
public init() { storage = Storage(()) }
|
|
78
|
+
|
|
79
|
+
public func lock() {
|
|
80
|
+
Swift.precondition(!storage.locked, "OSAllocatedUnfairLock: the lock is already held")
|
|
81
|
+
storage.locked = true
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public func unlock() { storage.locked = false }
|
|
85
|
+
|
|
86
|
+
public func lockIfAvailable() -> Bool {
|
|
87
|
+
guard !storage.locked else { return false }
|
|
88
|
+
storage.locked = true
|
|
89
|
+
return true
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public func withLock<R>(_ body: @Sendable () throws -> R) rethrows -> R where R: Sendable {
|
|
93
|
+
try withLockUnchecked { _ in try body() }
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// MARK: - Logging
|
|
98
|
+
|
|
99
|
+
/// The type of a log message.
|
|
100
|
+
public struct OSLogType: Equatable, Hashable, RawRepresentable, Sendable {
|
|
101
|
+
public let rawValue: UInt8
|
|
102
|
+
public init(rawValue: UInt8) { self.rawValue = rawValue }
|
|
103
|
+
public init(_ rawValue: UInt8) { self.rawValue = rawValue }
|
|
104
|
+
|
|
105
|
+
public static let `default` = OSLogType(rawValue: 0x00)
|
|
106
|
+
public static let info = OSLogType(rawValue: 0x01)
|
|
107
|
+
public static let debug = OSLogType(rawValue: 0x02)
|
|
108
|
+
public static let error = OSLogType(rawValue: 0x10)
|
|
109
|
+
public static let fault = OSLogType(rawValue: 0x11)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/// A log: a subsystem and a category its messages are tagged with.
|
|
113
|
+
public final class OSLog: @unchecked Sendable {
|
|
114
|
+
public struct Category: Sendable {
|
|
115
|
+
public let rawValue: String
|
|
116
|
+
public init(rawValue: String) { self.rawValue = rawValue }
|
|
117
|
+
public static let pointsOfInterest = Category(rawValue: "PointsOfInterest")
|
|
118
|
+
public static let dynamicTracing = Category(rawValue: "DynamicTracing")
|
|
119
|
+
public static let dynamicStackTracing = Category(rawValue: "DynamicStackTracing")
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public let subsystem: String
|
|
123
|
+
public let category: String
|
|
124
|
+
let enabled: Bool
|
|
125
|
+
|
|
126
|
+
public init(subsystem: String, category: String) {
|
|
127
|
+
self.subsystem = subsystem
|
|
128
|
+
self.category = category
|
|
129
|
+
self.enabled = true
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public convenience init(subsystem: String, category: Category) {
|
|
133
|
+
self.init(subsystem: subsystem, category: category.rawValue)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private init(disabled: Void) {
|
|
137
|
+
subsystem = ""
|
|
138
|
+
category = ""
|
|
139
|
+
enabled = false
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public static let `default` = OSLog(subsystem: "", category: "")
|
|
143
|
+
public static let disabled = OSLog(disabled: ())
|
|
144
|
+
|
|
145
|
+
public var signpostsEnabled: Bool { false }
|
|
146
|
+
|
|
147
|
+
public func isEnabled(type: OSLogType) -> Bool { enabled }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
func _write(_ log: OSLog, _ type: OSLogType, _ message: String) {
|
|
151
|
+
guard log.enabled, type != .debug else { return }
|
|
152
|
+
let tag = [log.subsystem, log.category].filter { !$0.isEmpty }.joined(separator: " ")
|
|
153
|
+
_standardError((tag.isEmpty ? "" : "[\(tag)] ") + message + "\n")
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/// `os_log("…", log: …, type: …, args…)`: the arguments fill the `%@`, `%d`,
|
|
157
|
+
/// `%s` (and `%{public}…`) placeholders in order.
|
|
158
|
+
public func os_log(_ message: StaticString, dso: UnsafeRawPointer? = nil, log: OSLog = .default, type: OSLogType = .default, _ args: any CVarArg...) {
|
|
159
|
+
_write(log, type, _format("\(message)", args))
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public func os_log(_ type: OSLogType, dso: UnsafeRawPointer? = nil, log: OSLog = .default, _ message: StaticString, _ args: any CVarArg...) {
|
|
163
|
+
_write(log, type, _format("\(message)", args))
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// Replaces each `%…` placeholder with the next argument.
|
|
167
|
+
func _format(_ format: String, _ args: [any CVarArg]) -> String {
|
|
168
|
+
var out = ""
|
|
169
|
+
var remaining = args[...]
|
|
170
|
+
var chars = format[...]
|
|
171
|
+
while let c = chars.first {
|
|
172
|
+
chars = chars.dropFirst()
|
|
173
|
+
guard c == "%" else { out.append(c); continue }
|
|
174
|
+
if chars.first == "%" { out.append("%"); chars = chars.dropFirst(); continue }
|
|
175
|
+
// Skip `{public}`-style privacy and the conversion's flags, up to its letter.
|
|
176
|
+
if chars.first == "{", let close = chars.firstIndex(of: "}") { chars = chars[chars.index(after: close)...] }
|
|
177
|
+
// Flags, width, precision and length modifiers, then one conversion character.
|
|
178
|
+
while let f = chars.first, "0123456789.-+ #'lhqzjtL".contains(f) { chars = chars.dropFirst() }
|
|
179
|
+
chars = chars.dropFirst()
|
|
180
|
+
if let next = remaining.first {
|
|
181
|
+
out += "\(next)"
|
|
182
|
+
remaining = remaining.dropFirst()
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return out
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/// The modern logging API: `Logger(subsystem:category:).info("…")`. A
|
|
189
|
+
/// message is an `OSLogMessage`, so interpolations take `privacy:`,
|
|
190
|
+
/// `format:` and `align:` as on Apple platforms; the browser's console is the
|
|
191
|
+
/// developer's own, so every value is written out whatever its privacy.
|
|
192
|
+
public struct Logger: Sendable {
|
|
193
|
+
let log: OSLog
|
|
194
|
+
|
|
195
|
+
public init(subsystem: String, category: String) { log = OSLog(subsystem: subsystem, category: category) }
|
|
196
|
+
public init(_ log: OSLog) { self.log = log }
|
|
197
|
+
public init() { log = .default }
|
|
198
|
+
|
|
199
|
+
public func log(level: OSLogType = .default, _ message: OSLogMessage) { _write(log, level, message.text) }
|
|
200
|
+
public func log(_ message: OSLogMessage) { _write(log, .default, message.text) }
|
|
201
|
+
public func trace(_ message: OSLogMessage) { _write(log, .debug, message.text) }
|
|
202
|
+
public func debug(_ message: OSLogMessage) { _write(log, .debug, message.text) }
|
|
203
|
+
public func info(_ message: OSLogMessage) { _write(log, .info, message.text) }
|
|
204
|
+
public func notice(_ message: OSLogMessage) { _write(log, .default, message.text) }
|
|
205
|
+
public func warning(_ message: OSLogMessage) { _write(log, .error, message.text) }
|
|
206
|
+
public func error(_ message: OSLogMessage) { _write(log, .error, message.text) }
|
|
207
|
+
public func critical(_ message: OSLogMessage) { _write(log, .fault, message.text) }
|
|
208
|
+
public func fault(_ message: OSLogMessage) { _write(log, .fault, message.text) }
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/// A log message: a string literal with interpolated values, each with its
|
|
212
|
+
/// privacy and formatting.
|
|
213
|
+
public struct OSLogMessage: ExpressibleByStringInterpolation, ExpressibleByStringLiteral, Sendable {
|
|
214
|
+
let text: String
|
|
215
|
+
|
|
216
|
+
public init(stringLiteral value: String) { text = value }
|
|
217
|
+
public init(stringInterpolation: OSLogInterpolation) { text = stringInterpolation.text }
|
|
218
|
+
|
|
219
|
+
public struct OSLogInterpolation: StringInterpolationProtocol, Sendable {
|
|
220
|
+
var text = ""
|
|
221
|
+
public init(literalCapacity: Int, interpolationCount: Int) { text.reserveCapacity(literalCapacity) }
|
|
222
|
+
public mutating func appendLiteral(_ literal: String) { text += literal }
|
|
223
|
+
|
|
224
|
+
public mutating func appendInterpolation<T>(_ value: @autoclosure () -> T, privacy: OSLogPrivacy = .auto, attributes: String = "") {
|
|
225
|
+
text += String(describing: value())
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public mutating func appendInterpolation<T>(_ value: @autoclosure () -> T, align: OSLogStringAlignment, privacy: OSLogPrivacy = .auto) {
|
|
229
|
+
text += align.aligned(String(describing: value()))
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
public mutating func appendInterpolation<T: BinaryInteger>(_ number: @autoclosure () -> T, format: OSLogIntegerFormatting = .decimal, align: OSLogStringAlignment = .none, privacy: OSLogPrivacy = .auto) {
|
|
233
|
+
text += align.aligned(format.formatted(number()))
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public mutating func appendInterpolation<T: BinaryFloatingPoint>(_ number: @autoclosure () -> T, format: OSLogFloatFormatting = .fixed, align: OSLogStringAlignment = .none, privacy: OSLogPrivacy = .auto) {
|
|
237
|
+
text += align.aligned(format.formatted(Double(number())))
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public mutating func appendInterpolation(_ boolean: @autoclosure () -> Bool, format: OSLogBoolFormat = .truth, privacy: OSLogPrivacy = .auto) {
|
|
241
|
+
let value = boolean()
|
|
242
|
+
text += format == .answer ? (value ? "YES" : "NO") : (value ? "true" : "false")
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
public typealias OSLogInterpolation = OSLogMessage.OSLogInterpolation
|
|
248
|
+
|
|
249
|
+
/// Who may read an interpolated value in the log. The browser's console
|
|
250
|
+
/// shows them all.
|
|
251
|
+
public struct OSLogPrivacy: Equatable, Sendable {
|
|
252
|
+
public enum Mask: Equatable, Sendable { case hash, none }
|
|
253
|
+
let name: String
|
|
254
|
+
public static let auto = OSLogPrivacy(name: "auto")
|
|
255
|
+
public static let `public` = OSLogPrivacy(name: "public")
|
|
256
|
+
public static let `private` = OSLogPrivacy(name: "private")
|
|
257
|
+
public static let sensitive = OSLogPrivacy(name: "sensitive")
|
|
258
|
+
public static func auto(mask: Mask) -> OSLogPrivacy { .auto }
|
|
259
|
+
public static func `private`(mask: Mask) -> OSLogPrivacy { .private }
|
|
260
|
+
public static func sensitive(mask: Mask) -> OSLogPrivacy { .sensitive }
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
public struct OSLogStringAlignment: Sendable {
|
|
264
|
+
let columns: Int
|
|
265
|
+
public static let none = OSLogStringAlignment(columns: 0)
|
|
266
|
+
public static func left(columns: @autoclosure () -> Int) -> OSLogStringAlignment { OSLogStringAlignment(columns: -columns()) }
|
|
267
|
+
public static func right(columns: @autoclosure () -> Int) -> OSLogStringAlignment { OSLogStringAlignment(columns: columns()) }
|
|
268
|
+
|
|
269
|
+
func aligned(_ text: String) -> String {
|
|
270
|
+
let pad = String(repeating: " ", count: max(0, abs(columns) - text.count))
|
|
271
|
+
return columns < 0 ? text + pad : pad + text
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public struct OSLogIntegerFormatting: Sendable {
|
|
276
|
+
let radix: Int
|
|
277
|
+
let prefix: String
|
|
278
|
+
let uppercase: Bool
|
|
279
|
+
let minDigits: Int
|
|
280
|
+
let explicitPositiveSign: Bool
|
|
281
|
+
|
|
282
|
+
public static let decimal = OSLogIntegerFormatting(radix: 10, prefix: "", uppercase: false, minDigits: 0, explicitPositiveSign: false)
|
|
283
|
+
public static let hex = OSLogIntegerFormatting(radix: 16, prefix: "", uppercase: false, minDigits: 0, explicitPositiveSign: false)
|
|
284
|
+
public static let octal = OSLogIntegerFormatting(radix: 8, prefix: "", uppercase: false, minDigits: 0, explicitPositiveSign: false)
|
|
285
|
+
|
|
286
|
+
public static func decimal(explicitPositiveSign: Bool = false, minDigits: @autoclosure () -> Int = 0) -> OSLogIntegerFormatting {
|
|
287
|
+
OSLogIntegerFormatting(radix: 10, prefix: "", uppercase: false, minDigits: minDigits(), explicitPositiveSign: explicitPositiveSign)
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public static func hex(explicitPositiveSign: Bool = false, includePrefix: Bool = false, uppercase: Bool = false, minDigits: @autoclosure () -> Int = 0) -> OSLogIntegerFormatting {
|
|
291
|
+
OSLogIntegerFormatting(radix: 16, prefix: includePrefix ? "0x" : "", uppercase: uppercase, minDigits: minDigits(), explicitPositiveSign: explicitPositiveSign)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public static func octal(explicitPositiveSign: Bool = false, includePrefix: Bool = false, uppercase: Bool = false, minDigits: @autoclosure () -> Int = 0) -> OSLogIntegerFormatting {
|
|
295
|
+
OSLogIntegerFormatting(radix: 8, prefix: includePrefix ? "0o" : "", uppercase: uppercase, minDigits: minDigits(), explicitPositiveSign: explicitPositiveSign)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
func formatted<T: BinaryInteger>(_ value: T) -> String {
|
|
299
|
+
var digits = String(value.magnitude, radix: radix, uppercase: uppercase)
|
|
300
|
+
if digits.count < minDigits { digits = String(repeating: "0", count: minDigits - digits.count) + digits }
|
|
301
|
+
let sign = value < 0 ? "-" : explicitPositiveSign ? "+" : ""
|
|
302
|
+
return sign + prefix + digits
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public struct OSLogFloatFormatting: Sendable {
|
|
307
|
+
let precision: Int?
|
|
308
|
+
public static let fixed = OSLogFloatFormatting(precision: nil)
|
|
309
|
+
public static let hybrid = OSLogFloatFormatting(precision: nil)
|
|
310
|
+
public static let exponential = OSLogFloatFormatting(precision: nil)
|
|
311
|
+
public static func fixed(precision: @autoclosure () -> Int, explicitPositiveSign: Bool = false, uppercase: Bool = false) -> OSLogFloatFormatting {
|
|
312
|
+
OSLogFloatFormatting(precision: precision())
|
|
313
|
+
}
|
|
314
|
+
public static func fixed(explicitPositiveSign: Bool = false, uppercase: Bool = false) -> OSLogFloatFormatting { .fixed }
|
|
315
|
+
public static func hybrid(precision: @autoclosure () -> Int, explicitPositiveSign: Bool = false, uppercase: Bool = false) -> OSLogFloatFormatting {
|
|
316
|
+
OSLogFloatFormatting(precision: precision())
|
|
317
|
+
}
|
|
318
|
+
public static func exponential(precision: @autoclosure () -> Int, explicitPositiveSign: Bool = false, uppercase: Bool = false) -> OSLogFloatFormatting {
|
|
319
|
+
OSLogFloatFormatting(precision: precision())
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
func formatted(_ value: Double) -> String {
|
|
323
|
+
guard let precision, value.isFinite else { return "\(value)" }
|
|
324
|
+
// Round half away from zero to `precision` digits after the point.
|
|
325
|
+
var scale = 1.0
|
|
326
|
+
for _ in 0..<precision { scale *= 10 }
|
|
327
|
+
let scaled = (abs(value) * scale).rounded()
|
|
328
|
+
let whole = Int(scaled / scale)
|
|
329
|
+
var fraction = String(Int(scaled) - whole * Int(scale))
|
|
330
|
+
fraction = String(repeating: "0", count: max(0, precision - fraction.count)) + fraction
|
|
331
|
+
return (value < 0 ? "-" : "") + String(whole) + (precision > 0 ? "." + fraction : "")
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
public enum OSLogBoolFormat: Sendable { case truth, answer }
|
|
336
|
+
|
|
337
|
+
// MARK: - Signposts
|
|
338
|
+
|
|
339
|
+
public enum OSSignpostType: Sendable {
|
|
340
|
+
case event, begin, end
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
public struct OSSignpostID: Equatable, Hashable, Comparable, Sendable {
|
|
344
|
+
public let rawValue: UInt64
|
|
345
|
+
public init(_ rawValue: UInt64) { self.rawValue = rawValue }
|
|
346
|
+
public init(log: OSLog) { rawValue = 1 }
|
|
347
|
+
public init(log: OSLog, object: AnyObject) { rawValue = UInt64(UInt(bitPattern: ObjectIdentifier(object).hashValue)) }
|
|
348
|
+
|
|
349
|
+
public static let exclusive = OSSignpostID(0xEEEE_B0B5_B2B2_EEEE)
|
|
350
|
+
public static let invalid = OSSignpostID(0)
|
|
351
|
+
public static let null = OSSignpostID(0)
|
|
352
|
+
|
|
353
|
+
public static func < (lhs: OSSignpostID, rhs: OSSignpostID) -> Bool { lhs.rawValue < rhs.rawValue }
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/// Dropped: the browser has no Instruments to show them.
|
|
357
|
+
public func os_signpost(_ type: OSSignpostType, dso: UnsafeRawPointer? = nil, log: OSLog, name: StaticString, signpostID: OSSignpostID = .exclusive) {}
|
|
358
|
+
|
|
359
|
+
public func os_signpost(_ type: OSSignpostType, dso: UnsafeRawPointer? = nil, log: OSLog, name: StaticString, signpostID: OSSignpostID = .exclusive, _ format: StaticString, _ arguments: any CVarArg...) {}
|
|
360
|
+
|
|
361
|
+
// MARK: - Output
|
|
362
|
+
|
|
363
|
+
#if canImport(WASILibc)
|
|
364
|
+
import WASILibc
|
|
365
|
+
#elseif canImport(Glibc)
|
|
366
|
+
import Glibc
|
|
367
|
+
#elseif canImport(Musl)
|
|
368
|
+
import Musl
|
|
369
|
+
#elseif canImport(Darwin)
|
|
370
|
+
import Darwin
|
|
371
|
+
#endif
|
|
372
|
+
|
|
373
|
+
func _standardError(_ text: String) {
|
|
374
|
+
var bytes = Array(text.utf8)
|
|
375
|
+
_ = bytes.withUnsafeMutableBytes { write(2, $0.baseAddress, $0.count) }
|
|
376
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `import zlib` for the browser: zlib's decompression API (`inflateInit2_`,
|
|
2
|
+
// `inflate`, `inflateEnd` over a `z_stream`) lives in the Compression module
|
|
3
|
+
// (Sources/Compression/Zlib.swift) next to the DEFLATE decoder it runs on,
|
|
4
|
+
// and this module re-exports it. RevenueCat gunzips its container elements
|
|
5
|
+
// this way.
|
|
6
|
+
@_exported import Compression
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Absolute path of a directory holding a Package.swift with the SwiftUI, Charts and
|
|
1
|
+
/** Absolute path of a directory holding a Package.swift with the SwiftUI, Charts and FoundationBridge products. */
|
|
2
2
|
export function swiftPackagePath(): string;
|
package/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Where the Swift package lives: next to this file once `Sources/` was synced
|
|
2
2
|
// (a published tarball), else the repository root (a checkout, whose
|
|
3
|
-
// Package.swift carries the same library products
|
|
3
|
+
// Package.swift carries the same library products).
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
|
|
10
|
-
/** Absolute path of a directory holding a Package.swift with the SwiftUI, Charts,
|
|
10
|
+
/** Absolute path of a directory holding a Package.swift with the SwiftUI, Charts, SwiftData and FoundationBridge products. */
|
|
11
11
|
export function swiftPackagePath() {
|
|
12
12
|
if (existsSync(path.join(here, 'Sources', 'SwiftUI'))) return here;
|
|
13
13
|
const repoRoot = path.resolve(here, '../..');
|
package/manifest.d.mts
ADDED
package/manifest.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// The published package's manifest, made from the repository's Package.swift
|
|
2
|
+
// so the two cannot drift: the same library products and targets, without the
|
|
3
|
+
// test targets and the HelloWasm executable (whose sources are not shipped),
|
|
4
|
+
// and without the lines marked `// repository only`, under this package's own
|
|
5
|
+
// header comment.
|
|
6
|
+
|
|
7
|
+
const HEADER = `// The SwiftBrowser Swift package as @swiftbrowser/cli ships it: every library
|
|
8
|
+
// of the repository's Package.swift (the SwiftUI shim, Charts, SwiftData,
|
|
9
|
+
// FoundationBridge and the framework and package stand-ins), library products
|
|
10
|
+
// only. Generated from that manifest by sync-sources.mjs (manifest.mjs), which
|
|
11
|
+
// also copies the targets' Sources/ in at \`npm pack\` time; in a repository
|
|
12
|
+
// checkout the CLI uses the repository's own Package.swift.
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
/** `rootManifest` (the repository's Package.swift) as this package's manifest. */
|
|
16
|
+
export function publishedManifest(rootManifest) {
|
|
17
|
+
const lines = rootManifest.split('\n');
|
|
18
|
+
const start = lines.findIndex((line) => line.startsWith('let package = Package('));
|
|
19
|
+
if (start < 0) throw new Error('manifest.mjs: no `let package = Package(` in the root manifest');
|
|
20
|
+
const imports = lines
|
|
21
|
+
.slice(0, start)
|
|
22
|
+
.filter((line) => (line.startsWith('// swift-tools-version') || line.startsWith('import ')) && !line.trim().endsWith('// repository only'));
|
|
23
|
+
const body = [];
|
|
24
|
+
for (const line of lines.slice(start)) {
|
|
25
|
+
const trimmed = line.trim();
|
|
26
|
+
if (trimmed.startsWith('.executable(') || trimmed.startsWith('.executableTarget(') || trimmed.startsWith('.testTarget(')) continue;
|
|
27
|
+
if (trimmed.endsWith('// repository only')) continue;
|
|
28
|
+
if (trimmed === '// Smallest possible Swift-on-Wasm program; CI runs it under wasmtime.') continue;
|
|
29
|
+
// Collapse the blank lines the removed declarations leave behind.
|
|
30
|
+
if (trimmed === '' && body.length > 0 && body[body.length - 1].trim() === '') continue;
|
|
31
|
+
body.push(line);
|
|
32
|
+
}
|
|
33
|
+
// A trailing blank line before the closing bracket of `targets:`.
|
|
34
|
+
const text = body.join('\n').replace(/\n\s*\n(\s*\]\n\))/, '\n$1');
|
|
35
|
+
return `${imports[0]}\n${HEADER}${imports.slice(1).join('\n')}\n\n${text}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The `Sources/<name>` folders a manifest's targets build from. */
|
|
39
|
+
export function sourceDirectories(manifest) {
|
|
40
|
+
return [...manifest.matchAll(/path: "Sources\/([^"/]+)"/g)].map((match) => match[1]);
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swiftbrowser/swift",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The SwiftBrowser Swift package (the SwiftUI shim, Charts,
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "The SwiftBrowser Swift package (the SwiftUI shim, Charts, SwiftData and FoundationBridge) as an npm package, so @swiftbrowser/cli builds apps against the exact version it ships with.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/noya-app/SwiftBrowser.git",
|
|
8
8
|
"directory": "packages/swift"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"Sources",
|
|
13
13
|
"index.mjs",
|
|
14
14
|
"index.d.ts",
|
|
15
|
+
"manifest.mjs",
|
|
16
|
+
"manifest.d.mts",
|
|
15
17
|
"sync-sources.mjs",
|
|
16
18
|
"README.md"
|
|
17
19
|
],
|
package/sync-sources.mjs
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
|
-
// `npm pack` / `npm publish` hook
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
1
|
+
// `npm pack` / `npm publish` hook (and CI, before building apps against the
|
|
2
|
+
// published layout): write this package's Package.swift from the
|
|
3
|
+
// repository's (manifest.mjs) and copy in the Sources/ folder of every target
|
|
4
|
+
// it declares, so the published tarball is a complete Swift package. The
|
|
5
|
+
// Sources copy is gitignored; the manifest is committed, and a CLI test checks
|
|
6
|
+
// it matches the repository's. `--manifest-only` writes the manifest and copies
|
|
7
|
+
// nothing (in a checkout, a synced Sources/ would make the CLI build against
|
|
8
|
+
// the copy instead of the repository's sources).
|
|
9
|
+
import { cpSync, existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
5
10
|
import path from 'node:path';
|
|
6
11
|
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { publishedManifest, sourceDirectories } from './manifest.mjs';
|
|
7
13
|
|
|
8
14
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const
|
|
15
|
+
const repoRoot = path.resolve(here, '../..');
|
|
16
|
+
const repoSources = path.join(repoRoot, 'Sources');
|
|
10
17
|
const dest = path.join(here, 'Sources');
|
|
11
18
|
if (!existsSync(repoSources)) {
|
|
12
19
|
console.error(`sync-sources: ${repoSources} not found; run from a repository checkout`);
|
|
13
20
|
process.exit(1);
|
|
14
21
|
}
|
|
22
|
+
const manifest = publishedManifest(readFileSync(path.join(repoRoot, 'Package.swift'), 'utf8'));
|
|
23
|
+
writeFileSync(path.join(here, 'Package.swift'), manifest);
|
|
24
|
+
if (process.argv.includes('--manifest-only')) {
|
|
25
|
+
console.log(`sync-sources: wrote ${path.join(here, 'Package.swift')}`);
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
15
28
|
rmSync(dest, { recursive: true, force: true });
|
|
16
|
-
|
|
29
|
+
const targets = sourceDirectories(manifest);
|
|
30
|
+
for (const target of targets) {
|
|
17
31
|
cpSync(path.join(repoSources, target), path.join(dest, target), { recursive: true });
|
|
18
32
|
}
|
|
19
|
-
console.log(`sync-sources: copied Sources/{
|
|
33
|
+
console.log(`sync-sources: wrote Package.swift and copied Sources/{${targets.join(',')}} into ${here}`);
|