one
Version:
One is a React framework for web, iOS, and Android apps.
3,289 lines • 123 kB
text/typescript
// generated by bun run generate from the SwiftUI SDK and codegen/catalog.ts.
// edit the generator or catalog, then regenerate.
import {
NativeModules,
processColor,
type ColorValue,
type ProcessedColorValue,
} from 'react-native'
import { animatorStyleNative, animatorStyleOf } from '../animatorStyle'
import type { OneNativeStyle } from './controlTypes'
export type OneNativeStyleNative = Readonly<{
fontSize?: number
fontWeight?: string
fontDesign?: string
textStyle?: string
foregroundStyle?: ProcessedColorValue
tint?: ProcessedColorValue
background?: ProcessedColorValue
padding?: number
paddingTop?: number
paddingLeading?: number
paddingBottom?: number
paddingTrailing?: number
width?: number
height?: number
minWidth?: number
idealWidth?: number
maxWidth?: number
minHeight?: number
idealHeight?: number
maxHeight?: number
cornerRadius?: number
opacity?: number
borderColor?: ProcessedColorValue
borderWidth?: number
glassEffect?: string
glassEffectInteractive?: boolean
glassEffectTint?: ProcessedColorValue
glassEffectShape?: string
material?: string
sdkModifiers?: string
}>
const colorFields = [
'foregroundStyle',
'tint',
'background',
'borderColor',
'glassEffectTint',
] as const
const sdkKinds = {
accentColor: 'optionalEnum',
accessibilityAction: 'event',
accessibilityActionWithAppIntent: 'registeredValue',
accessibilityActivationPointWithActivationPointAndIsEnabled: 'record',
accessibilityActivationPointWithUnitPoint: 'string',
accessibilityAddTraits: 'string',
accessibilityAdjustableAction: 'eventEnum',
accessibilityChartDescriptor: 'chartDescriptor',
accessibilityCustomContent: 'record',
accessibilityDefaultFocus: 'defaultFocusBoolean',
accessibilityDirectTouch: 'record',
accessibilityDragPointWithPointAndDescription: 'record',
accessibilityDragPointWithPointAndDescriptionAndIsEnabled: 'record',
accessibilityDropPointWithPointAndDescription: 'record',
accessibilityDropPointWithPointAndDescriptionAndIsEnabled: 'record',
accessibilityElement: 'string',
accessibilityFocused: 'bindingFocusBoolean',
accessibilityHeading: 'string',
accessibilityHiddenWithBool: 'boolean',
accessibilityHiddenWithHiddenAndIsEnabled: 'record',
accessibilityHintWithHintAndIsEnabled: 'record',
accessibilityHintWithText: 'string',
accessibilityIdentifierWithIdentifierAndIsEnabled: 'record',
accessibilityIdentifierWithString: 'string',
accessibilityIgnoresInvertColors: 'boolean',
accessibilityInputLabels: 'record',
accessibilityLabeledPair: 'record',
accessibilityLabelWithLabelAndIsEnabled: 'record',
accessibilityLabelWithText: 'string',
accessibilityLinkedGroup: 'record',
accessibilityRemoveTraits: 'string',
accessibilityRespondsToUserInteractionWithBool: 'boolean',
accessibilityRespondsToUserInteractionWithRespondsToUserInteractionAndIsEnabled:
'record',
accessibilityRotor: 'record',
accessibilityRotorEntry: 'record',
accessibilityScrollAction: 'eventEnum',
accessibilityScrollStatus: 'record',
accessibilityShowsLargeContentViewer: 'boolean',
accessibilitySortPriority: 'number',
accessibilityTextContentType: 'string',
accessibilityValueWithText: 'string',
accessibilityValueWithValueDescriptionAndIsEnabled: 'record',
accessibilityWithActivationPoint: 'string',
accessibilityWithAddTraits: 'string',
accessibilityWithHidden: 'boolean',
accessibilityWithHint: 'string',
accessibilityWithIdentifier: 'string',
accessibilityWithLabel: 'string',
accessibilityWithRemoveTraits: 'string',
accessibilityWithSortPriority: 'number',
accessibilityWithValue: 'string',
accessibilityZoomAction: 'eventStruct',
actionSheet: 'record',
addPassToWalletButtonStyle: 'string',
alert: 'record',
alignmentGuideWithHorizontalAlignment: 'record',
alignmentGuideWithVerticalAlignment: 'record',
allowedDynamicRange: 'optionalEnum',
allowsHitTesting: 'boolean',
allowsTightening: 'boolean',
allowsWindowActivationEventsWithNoArguments: 'boolean',
allowsWindowActivationEventsWithOptionalBool: 'optionalBoolean',
anchorPreference: 'eventStruct',
animation: 'optionalEnum',
appEntityIdentifier: 'optionalString',
appEntityUIElements: 'registeredValue',
appStoreMerchandising: 'record',
appStoreOverlayWithAppClipConfiguration: 'record',
appStoreOverlayWithAppConfiguration: 'record',
aspectRatio: 'record',
assistiveAccessNavigationIconWithImage: 'string',
assistiveAccessNavigationIconWithSystemImage: 'string',
asyncImageURLSession: 'string',
attributedTextFormattingDefinition: 'registeredValue',
autocapitalization: 'string',
autocorrectionDisabled: 'boolean',
backgroundExtensionEffectWithIsEnabled: 'boolean',
backgroundExtensionEffectWithNoArguments: 'boolean',
backgroundStyle: 'style',
badgeProminence: 'string',
badgeWithInt: 'number',
badgeWithOptionalText: 'optionalString',
baselineOffset: 'number',
blendMode: 'string',
blur: 'record',
bold: 'boolean',
brightness: 'number',
buttonBorderShape: 'string',
buttonRepeatBehavior: 'string',
buttonSizing: 'string',
buttonStyle: 'style',
clipped: 'boolean',
clipShape: 'style',
colorEffect: 'record',
colorInvert: 'boolean',
colorMultiply: 'string',
colorScheme: 'string',
compositingGroup: 'boolean',
containerCornerOffset: 'record',
containerRelativeFrameWithAxesAndAlignment: 'record',
containerRelativeFrameWithAxesAndCountAndSpanAndSpacingAndAlignment: 'record',
containerShape: 'style',
containerValue: 'registeredValue',
contentMarginsWithEdgesAndLengthAndPlacement: 'record',
contentMarginsWithLengthAndPlacement: 'record',
contentShape: 'style',
contentTransition: 'string',
contrast: 'number',
controlGroupStyle: 'style',
controlSize: 'string',
coordinateSpace: 'string',
copyable: 'record',
cornerRadiusWithRadiusAndAntialiased: 'record',
currentEntitlementTask: 'eventAsyncStruct',
cuttable: 'eventReturnArray',
dataDetection: 'boolean',
datePickerStyle: 'style',
defaultAdaptableTabBarPlacement: 'string',
defaultAppStorage: 'string',
defaultFocus: 'defaultFocusBoolean',
defaultHoverEffect: 'optionalEnum',
defaultScrollAnchorWithAnchorAndRole: 'record',
defaultScrollAnchorWithOptionalUnitPoint: 'optionalEnum',
defaultTabBarPlacement: 'string',
defersSystemGestures: 'string',
deleteDisabled: 'boolean',
dialogIcon: 'optionalString',
dialogSuppressionToggle: 'bindingBoolean',
dialogSuppressionToggleWithLabelAndIsSuppressed: 'record',
disableAutocorrection: 'optionalBoolean',
disabled: 'boolean',
disclosureGroupStyle: 'style',
distortionEffect: 'record',
documentLaunchSubtitle: 'string',
documentLaunchTitle: 'string',
dragConfiguration: 'boolean',
dragContainer: 'dragContainer',
dragContainerSelection: 'dragSelection',
draggable: 'record',
draggableWithContainerItemID: 'dragItemID',
drawingGroup: 'record',
dropConfiguration: 'eventReturnEnum',
dropDestination: 'eventStruct',
dynamicTypeSize: 'string',
edgesIgnoringSafeArea: 'string',
environment: 'registeredValue',
environmentAccessibilityEnabled: 'boolean',
environmentAccessibilityPrefersCrossFadeTransitions: 'boolean',
environmentAllowedDynamicRange: 'optionalEnum',
environmentAllowsTightening: 'boolean',
environmentAppearsActive: 'boolean',
environmentAutocorrectionDisabled: 'boolean',
environmentBackgroundMaterial: 'optionalEnum',
environmentBackgroundProminence: 'string',
environmentBadgeProminence: 'string',
environmentCalendar: 'string',
environmentColorScheme: 'string',
environmentContentTransition: 'string',
environmentContentTransitionAddsDrawingGroup: 'boolean',
environmentControlSize: 'string',
environmentDefaultMinListHeaderHeight: 'optionalNumber',
environmentDefaultMinListRowHeight: 'number',
environmentDisableAutocorrection: 'optionalBoolean',
environmentDisplayScale: 'number',
environmentDynamicTypeSize: 'string',
environmentFont: 'optionalEnum',
environmentHeaderProminence: 'string',
environmentHorizontalScrollBounceBehavior: 'string',
environmentHorizontalScrollIndicatorVisibility: 'string',
environmentHorizontalSizeClass: 'optionalEnum',
environmentImageScale: 'string',
environmentIsEnabled: 'boolean',
environmentIsFocusEffectEnabled: 'boolean',
environmentIsHoverEffectEnabled: 'boolean',
environmentIsLuminanceReduced: 'boolean',
environmentIsSceneCaptured: 'boolean',
environmentIsScrollEnabled: 'boolean',
environmentLabelsVisibility: 'string',
environmentLayoutDirection: 'string',
environmentLegibilityWeight: 'optionalEnum',
environmentLineHeight: 'optionalEnum',
environmentLineLimit: 'optionalNumber',
environmentLineSpacing: 'number',
environmentLocale: 'string',
environmentMaterialActiveAppearance: 'string',
environmentMenuIndicatorVisibility: 'string',
environmentMenuOrder: 'string',
environmentMinimumScaleFactor: 'number',
environmentMultilineTextAlignment: 'string',
environmentObject: 'registeredValue',
environmentRealityViewCameraControls: 'string',
environmentRedactionReasons: 'string',
environmentScenePhase: 'string',
environmentScrollDismissesKeyboardMode: 'string',
environmentSidebarRowSize: 'string',
environmentSizeCategory: 'string',
environmentSymbolColorRenderingMode: 'optionalEnum',
environmentSymbolRenderingMode: 'optionalEnum',
environmentSymbolVariableValueMode: 'optionalEnum',
environmentSymbolVariants: 'string',
environmentSystemPrefersReducedResourceUsage: 'boolean',
environmentTextCase: 'optionalEnum',
environmentTextSelectionAffinity: 'string',
environmentTimeZone: 'string',
environmentTruncationMode: 'string',
environmentVerticalScrollBounceBehavior: 'string',
environmentVerticalScrollIndicatorVisibility: 'string',
environmentVerticalSizeClass: 'optionalEnum',
equatable: 'equatableKey',
fileDialogBrowserOptions: 'string',
fileDialogConfirmationLabel: 'optionalString',
fileDialogCustomizationID: 'string',
fileDialogDefaultDirectory: 'optionalURL',
fileDialogImportsUnresolvedAliases: 'boolean',
fileDialogMessage: 'optionalString',
fileDialogURLEnabled: 'boolean',
fileExporter: 'record',
fileExporterFilenameLabel: 'optionalString',
fileImporterWithIsPresentedAndAllowedContentTypesAndAllowsMultipleSelectionAndOnCompletion:
'record',
fileImporterWithIsPresentedAndAllowedContentTypesAndOnCompletion: 'record',
fileMover: 'record',
findDisabled: 'boolean',
findNavigator: 'bindingBoolean',
fixedSizeWithHorizontalAndVertical: 'record',
fixedSizeWithNoArguments: 'boolean',
flipsForRightToLeftLayoutDirection: 'boolean',
focusableWithBool: 'boolean',
focusableWithIsFocusableAndInteractions: 'record',
focused: 'bindingFocusBoolean',
focusedObject: 'registeredValue',
focusedSceneObject: 'registeredValue',
focusedSceneValue: 'registeredValue',
focusedValue: 'registeredValue',
focusEffectDisabled: 'boolean',
font: 'optionalEnum',
fontDesignWithOptionalDesign: 'optionalEnum',
fontWeightWithOptionalWeight: 'optionalEnum',
fontWidth: 'optionalEnum',
foregroundColor: 'optionalEnum',
formStyle: 'style',
frameWithMinWidthAndIdealWidthAndMaxWidthAndMinHeightAndIdealHeightAndMaxHeightAndAlignment:
'record',
frameWithNoArguments: 'boolean',
frameWithWidthAndHeightAndAlignment: 'record',
gaugeStyle: 'style',
geometryGroup: 'boolean',
gesture: 'gesture',
gestureWithUITapRecognizer: 'event',
glassEffectID: 'record',
glassEffectTransition: 'string',
glassEffectUnion: 'record',
glassEffectWithGlass: 'string',
grayscale: 'number',
gridCellAnchor: 'string',
gridCellColumns: 'number',
gridCellUnsizedAxes: 'string',
gridColumnAlignment: 'string',
groupBoxStyle: 'style',
handGestureShortcut: 'record',
handlesExternalEvents: 'record',
handlesGameControllerEvents: 'string',
headerProminence: 'string',
help: 'string',
hidden: 'boolean',
highPriorityGesture: 'gesture',
hoverEffectDisabled: 'boolean',
hoverEffectWithHoverEffect: 'string',
hoverEffectWithHoverEffectFromSwiftUICore: 'string',
hueRotation: 'string',
id: 'string',
ignoresSafeAreaWithRegionsAndEdgesAndAlignment: 'record',
ignoresSafeAreaWithSafeAreaRegions: 'string',
imageScale: 'string',
inAppPurchaseOptions: 'optionSet',
indexViewStyle: 'style',
inspectorColumnWidthWithCGFloat: 'number',
inspectorColumnWidthWithMinAndIdealAndMax: 'record',
interactionActivityTrackingTag: 'string',
interactiveDismissDisabled: 'boolean',
invalidatableContent: 'boolean',
italic: 'boolean',
itemProvider: 'string',
kerning: 'number',
keyboardShortcutWithKeyAndModifiers: 'record',
keyboardShortcutWithKeyAndModifiersAndLocalization: 'record',
keyboardShortcutWithKeyboardShortcut: 'string',
keyboardShortcutWithOptionalKeyboardShortcut: 'optionalEnum',
keyboardType: 'string',
keyframeAnimator: 'keyframeAnimation',
labeledContentStyle: 'style',
labelIconToTitleSpacing: 'number',
labelReservedIconWidth: 'number',
labelsHidden: 'boolean',
labelStyle: 'style',
labelsVisibility: 'string',
layerEffect: 'record',
layoutDirectionBehavior: 'string',
layoutPriority: 'number',
layoutValue: 'registeredValue',
lineHeight: 'optionalEnum',
lineLimitWithLimitAndReservesSpace: 'record',
lineLimitWithOptionalInt: 'optionalNumber',
lineSpacing: 'number',
listItemTintWithOptionalColor: 'optionalEnum',
listItemTintWithOptionalListItemTint: 'optionalEnum',
listRowInsets: 'record',
listRowSeparator: 'record',
listRowSeparatorTint: 'record',
listRowSpacing: 'optionalNumber',
listSectionIndexVisibility: 'string',
listSectionMargins: 'record',
listSectionSeparator: 'record',
listSectionSeparatorTint: 'record',
listSectionSpacingWithCGFloat: 'number',
listSectionSpacingWithListSectionSpacing: 'string',
listStyle: 'style',
lookAroundViewer: 'asyncObjectRequest',
luminanceToAlpha: 'boolean',
manageSubscriptionsSheet: 'bindingBoolean',
manageSubscriptionsSheetWithIsPresentedAndSubscriptionGroupID: 'record',
mapCameraKeyframeAnimator: 'seedKeyframeAnimation',
mapControlVisibility: 'string',
mapFeatureSelectionAccessory: 'optionalEnum',
mapFeatureSelectionContent: 'registeredValue',
mapFeatureSelectionDisabled: 'boolean',
mapItemDetailPopoverWithCurrentLocation: 'record',
mapItemDetailPopoverWithCurrentLocationAndArrowEdge: 'record',
mapItemDetailSheetWithCurrentLocation: 'record',
mapScope: 'boolean',
mapStyle: 'string',
matchedGeometryEffect: 'record',
matchedTransitionSource: 'record',
materialActiveAppearance: 'string',
menuActionDismissBehavior: 'string',
menuIndicator: 'string',
menuOrder: 'string',
menuStyle: 'style',
minimumScaleFactor: 'number',
modelContainer: 'registeredValue',
modelContext: 'registeredValue',
modifier: 'registeredValue',
monospaced: 'boolean',
monospacedDigit: 'boolean',
moveDisabled: 'boolean',
multilineTextAlignmentWithStrategy: 'string',
multilineTextAlignmentWithTextAlignment: 'string',
musicPickerWithMusicVideo: 'pickerSelection',
musicPickerWithSong: 'pickerSelection',
musicPickerWithTrack: 'pickerSelection',
musicSubscriptionOffer: 'bindingBoolean',
navigationBarBackButtonHidden: 'boolean',
navigationBarHidden: 'boolean',
navigationBarTitleDisplayMode: 'string',
navigationBarTitleWithText: 'string',
navigationBarTitleWithTitleAndDisplayMode: 'record',
navigationDocument: 'url',
navigationLinkIndicatorVisibility: 'string',
navigationSplitViewColumnWidthWithCGFloat: 'number',
navigationSplitViewColumnWidthWithMinAndIdealAndMax: 'record',
navigationSplitViewStyle: 'style',
navigationSubtitle: 'string',
navigationTitleWithBindingString: 'bindingString',
navigationTitleWithText: 'string',
navigationTransition: 'style',
navigationViewStyle: 'style',
offerCodeRedemption: 'bindingBoolean',
offset: 'record',
onAppear: 'event',
onAppIntentExecution: 'registeredValue',
onApplePayCouponCodeChange: 'registeredValue',
onApplePayPaymentMethodChange: 'registeredValue',
onApplePayShippingContactChange: 'registeredValue',
onApplePayShippingMethodChange: 'registeredValue',
onCameraCaptureEvent: 'eventStruct',
onCameraCaptureEventWithIsEnabledAndDefaultSoundDisabledAndPrimaryActionAndSecondaryAction:
'record',
onCameraCaptureEventWithIsEnabledAndPrimaryActionAndSecondaryAction: 'record',
onChange: 'eventValueString',
onContinueUserActivity: 'record',
onContinuousHover: 'eventAssociatedEnum',
onDisappear: 'event',
onDrag: 'string',
onDragSessionUpdated: 'eventStruct',
onDrop: 'eventDrop',
onDropSessionUpdated: 'eventStruct',
onGeometryChangeWithSize: 'eventStruct',
onHover: 'eventBoolean',
onInAppPurchaseCompletion: 'eventAsyncStruct',
onInAppPurchaseStart: 'eventAsyncStruct',
onInteractiveResizeChange: 'eventBoolean',
onKeyPress: 'eventReturnEnum',
onLongPressGesture: 'event',
onMapCameraChange: 'event',
onMapCameraChangeWithEventStruct: 'eventStruct',
onOpenURLWithPerform: 'eventString',
onOpenURLWithPrefersInApp: 'boolean',
onPencilDoubleTap: 'eventStruct',
onPencilSqueeze: 'eventAssociatedEnum',
onPreferenceChangePreferredColorScheme: 'eventStruct',
onReceive: 'eventNotification',
onScrollGeometryChangeWithContainerSize: 'eventStruct',
onScrollGeometryChangeWithContentOffset: 'eventStruct',
onScrollGeometryChangeWithContentSize: 'eventStruct',
onScrollPhaseChange: 'eventEnumPair',
onScrollTargetVisibilityChange: 'eventStruct',
onScrollVisibilityChange: 'eventBoolean',
onSubmit: 'event',
onTapGestureWithPerform: 'eventStruct',
onTapGestureWithPerformFromSwiftUICore: 'event',
paddingWithSet: 'string',
paletteSelectionEffect: 'string',
pasteDestination: 'eventStruct',
payLaterViewAction: 'string',
payLaterViewDisplayStyle: 'string',
payWithApplePayButtonDisableCardArt: 'boolean',
payWithApplePayButtonStyle: 'string',
persistentSystemOverlays: 'string',
phaseAnimator: 'phaseAnimation',
photosPicker: 'transferSelection',
photosPickerAccessoryVisibility: 'record',
photosPickerDisabledCapabilities: 'string',
photosPickerMetadataOptions: 'string',
photosPickerSearchText: 'optionalString',
photosPickerStyle: 'string',
photosReferenceImageViewer: 'record',
photosSharedAlbumCreationSheet: 'record',
photosSharedAlbumCustomizationSheet: 'record',
photosSharedAlbumPostingSheet: 'record',
pickerStyle: 'style',
position: 'record',
postToPhotosSharedAlbumSheet: 'record',
preferencePreferredColorScheme: 'optionalEnum',
preferredColorScheme: 'optionalEnum',
preferredSubscriptionOffer: 'selectionID',
preferredSubscriptionPricingTerms: 'selectionIndex',
presentationBackground: 'style',
presentationBackgroundInteraction: 'string',
presentationCompactAdaptationWithHorizontalAdaptationAndVerticalAdaptation: 'record',
presentationCompactAdaptationWithPresentationAdaptation: 'string',
presentationContentInteraction: 'string',
presentationCornerRadius: 'optionalNumber',
presentationDetents: 'caseSet',
presentationDragIndicator: 'string',
presentationPlacement: 'string',
presentationSizing: 'style',
previewContext: 'record',
previewDevice: 'optionalString',
previewDisplayName: 'optionalString',
previewInterfaceOrientation: 'string',
previewLayout: 'string',
privacySensitive: 'boolean',
productDescription: 'string',
productIconBorder: 'boolean',
productViewStyle: 'style',
progressViewStyle: 'style',
projectionEffect: 'record',
quickLookPreview: 'bindingOptionalString',
realityViewCameraControls: 'string',
realityViewLayoutBehavior: 'string',
redacted: 'string',
refreshable: 'eventAsync',
refundRequestSheet: 'record',
renameAction: 'event',
reorderContainer: 'registeredValue',
replaceDisabled: 'boolean',
rotation3DEffect: 'record',
rotationEffect: 'record',
safeAreaPaddingWithCGFloat: 'number',
safeAreaPaddingWithSet: 'string',
saturation: 'number',
scaledToFill: 'boolean',
scaledToFit: 'boolean',
scaleEffectWithSAndAnchor: 'record',
scaleEffectWithXAndYAndAnchor: 'record',
scenePaddingWithPaddingAndEdges: 'record',
scenePaddingWithSet: 'string',
scrollBounceBehavior: 'record',
scrollClipDisabled: 'boolean',
scrollContentBackground: 'string',
scrollDisabled: 'boolean',
scrollDismissesKeyboard: 'string',
scrollEdgeEffectHidden: 'record',
scrollEdgeEffectStyle: 'record',
scrollIndicators: 'record',
scrollIndicatorsFlash: 'boolean',
scrollPositionWithBindingPoint: 'bindingPoint',
scrollPositionWithId: 'bindingOptionalString',
scrollTargetBehavior: 'style',
scrollTargetLayout: 'boolean',
scrollTransition: 'visualEffect',
searchable: 'bindingString',
searchCompletion: 'string',
searchDictationBehavior: 'string',
searchFocused: 'bindingFocusBoolean',
searchPresentationToolbarBehavior: 'string',
searchSelection: 'bindingTextSelection',
searchSuggestions: 'record',
searchToolbarBehavior: 'string',
sectionIndexLabel: 'optionalString',
selectionDisabled: 'boolean',
sensoryFeedback: 'record',
shadow: 'record',
shortcutsLinkStyle: 'string',
signInWithAppleButtonStyle: 'string',
simultaneousGesture: 'gesture',
siriTipViewStyle: 'string',
sliderThumbVisibility: 'string',
speechAdjustedPitch: 'number',
speechAlwaysIncludesPunctuation: 'boolean',
speechAnnouncementsQueued: 'boolean',
speechSpellsOutCharacters: 'boolean',
springLoadingBehavior: 'string',
statusBar: 'boolean',
statusBarHidden: 'boolean',
storeButton: 'record',
storeProductsTask: 'eventAsyncStruct',
storeProductTask: 'eventAsyncStruct',
strikethrough: 'record',
submitLabel: 'string',
submitScope: 'boolean',
subscriptionIntroductoryOffer: 'eventAsyncString',
subscriptionOfferViewButtonVisibility: 'record',
subscriptionOfferViewDetailAction: 'event',
subscriptionOfferViewStyle: 'style',
subscriptionPromotionalOffer: 'eventAsyncString',
subscriptionStatusTask: 'eventAsyncStruct',
subscriptionStoreButtonLabel: 'string',
subscriptionStoreControlBackground: 'string',
subscriptionStoreControlStyle: 'style',
subscriptionStoreOptionGroupStyle: 'style',
subscriptionStorePickerItemBackground: 'style',
subscriptionStorePolicyDestination: 'record',
subscriptionStorePolicyForegroundStyle: 'style',
subscriptionStoreSignInAction: 'event',
swipeActionsContainer: 'boolean',
symbolColorRenderingMode: 'optionalEnum',
symbolEffect: 'style',
symbolEffectsRemoved: 'boolean',
symbolRenderingMode: 'optionalEnum',
symbolVariableValueMode: 'optionalEnum',
symbolVariant: 'string',
tabBarMinimizeBehavior: 'string',
tableColumnHeaders: 'string',
tableStyle: 'style',
tabViewCustomization: 'bindingCodable',
tabViewSearchActivation: 'string',
tabViewStyle: 'style',
tag: 'string',
task: 'eventAsync',
textCase: 'optionalEnum',
textContentType: 'optionalEnum',
textEditorStyle: 'style',
textFieldStyle: 'style',
textInputAutocapitalization: 'optionalEnum',
textInputBorderShape: 'string',
textInputFormattingControlVisibility: 'record',
textRenderer: 'registeredValue',
textScale: 'record',
textSelection: 'style',
textSelectionAffinity: 'string',
tintWithOptionalColor: 'optionalEnum',
toggleStyle: 'style',
toolbarBackground: 'record',
toolbarBackgroundVisibility: 'record',
toolbarColorScheme: 'record',
toolbarMinimizationBehavior: 'record',
toolbarMinimizationRestoration: 'record',
toolbarMinimizationSafeAreaAdjustment: 'record',
toolbarRole: 'string',
toolbarTitleDisplayMode: 'string',
toolbarVisibility: 'record',
toolbarWithRemoving: 'optionalEnum',
toolbarWithVisibilityAndBars: 'record',
tracking: 'number',
transaction: 'record',
transactionTask: 'registeredValue',
transformAnchorPreference: 'eventStruct',
transformEffect: 'record',
transformEnvironmentAccessibilityEnabled: 'boolean',
transformEnvironmentAccessibilityPrefersCrossFadeTransitions: 'boolean',
transformEnvironmentAllowsTightening: 'boolean',
transformEnvironmentAppearsActive: 'boolean',
transformEnvironmentAutocorrectionDisabled: 'boolean',
transformEnvironmentContentTransitionAddsDrawingGroup: 'boolean',
transformEnvironmentDefaultMinListRowHeight: 'number',
transformEnvironmentDisplayScale: 'number',
transformEnvironmentIsEnabled: 'boolean',
transformEnvironmentIsFocusEffectEnabled: 'boolean',
transformEnvironmentIsHoverEffectEnabled: 'boolean',
transformEnvironmentIsLuminanceReduced: 'boolean',
transformEnvironmentIsSceneCaptured: 'boolean',
transformEnvironmentIsScrollEnabled: 'boolean',
transformEnvironmentLineSpacing: 'number',
transformEnvironmentMinimumScaleFactor: 'number',
transformEnvironmentSystemPrefersReducedResourceUsage: 'boolean',
transformPreferencePreferredColorScheme: 'optionalEnum',
transition: 'string',
translationPresentation: 'record',
translationTask: 'sessionRequest',
truncationMode: 'string',
typeSelectEquivalent: 'optionalString',
typesettingLanguage: 'record',
underline: 'record',
unredacted: 'boolean',
userActivity: 'record',
verifyIdentityWithWalletButtonStyle: 'string',
visualEffect: 'visualEffect',
webViewBackForwardNavigationGestures: 'string',
webViewContentBackground: 'string',
webViewElementFullscreenBehavior: 'string',
webViewLinkPreviews: 'string',
webViewMagnificationGestures: 'string',
webViewOnScrollGeometryChangeWithContainerSize: 'eventStruct',
webViewOnScrollGeometryChangeWithContentOffset: 'eventStruct',
webViewOnScrollGeometryChangeWithContentSize: 'eventStruct',
webViewScrollPosition: 'bindingPoint',
webViewTextSelection: 'style',
windowToolbarFullScreenVisibility: 'string',
workoutPreview: 'record',
writingDirection: 'string',
writingToolsAffordanceVisibility: 'string',
writingToolsBehavior: 'string',
zIndex: 'number',
} as const
const sdkSeedKeyframeFields: Record<string, readonly string[]> = {
mapCameraKeyframeAnimator: ['distance', 'heading', 'pitch'],
}
function validScalarEffect(effect: unknown, value: unknown): value is number {
if (typeof value !== 'number' || !Number.isFinite(value)) return false
if (effect === 'opacity') return value >= 0 && value <= 1
return (effect === 'scale' || effect === 'blur') && value >= 0
}
const sdkEventCases: Record<string, readonly string[]> = {
accessibilityAdjustableAction: ['increment', 'decrement'],
accessibilityScrollAction: ['top', 'leading', 'bottom', 'trailing'],
dropConfiguration: ['cancel', 'forbidden', 'copy', 'move'],
onKeyPress: ['handled', 'ignored'],
onScrollPhaseChange: ['idle', 'tracking', 'interacting', 'decelerating', 'animating'],
presentationDetents: ['medium', 'large'],
}
const sdkVisualEffects: Record<string, readonly string[]> = {
scrollTransition: ['opacity', 'scaleEffect'],
visualEffect: ['opacity', 'scaleEffect'],
}
const sdkOptionSets: Record<string, readonly { field: string; kind: string }[]> = {
inAppPurchaseOptions: [
{ field: 'quantity', kind: 'number' },
{ field: 'simulatesAskToBuyInSandbox', kind: 'boolean' },
{ field: 'introductoryOfferEligibility', kind: 'string' },
],
}
export type SDKEventValueShape =
| { kind: 'number' | 'string' | 'boolean' | 'point' | 'size' | 'description' }
| { kind: 'enum'; cases: readonly string[]; open?: true }
| { kind: 'optional' | 'array'; value: SDKEventValueShape }
| { kind: 'object'; fields: readonly { name: string; value: SDKEventValueShape }[] }
| { kind: 'result'; value: SDKEventValueShape }
| { kind: 'verification' }
| {
kind: 'associatedEnum'
cases: readonly { name: string; values: readonly SDKEventValueShape[] }[]
open?: true
}
const sdkAssociatedCases: Record<
string,
Record<string, readonly SDKEventValueShape[]>
> = {
onContinuousHover: { active: [{ kind: 'point' }], ended: [] },
onPencilSqueeze: {
active: [
{
kind: 'object',
fields: [
{
name: 'hoverPose',
value: {
kind: 'optional',
value: {
kind: 'object',
fields: [
{ name: 'location', value: { kind: 'point' } },
{
name: 'anchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'zDistance', value: { kind: 'number' } },
{
name: 'altitude',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'azimuth',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'roll',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
],
},
},
},
],
},
],
ended: [
{
kind: 'object',
fields: [
{
name: 'hoverPose',
value: {
kind: 'optional',
value: {
kind: 'object',
fields: [
{ name: 'location', value: { kind: 'point' } },
{
name: 'anchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'zDistance', value: { kind: 'number' } },
{
name: 'altitude',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'azimuth',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'roll',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
],
},
},
},
],
},
],
failed: [],
},
}
const sdkEventStructs: Record<string, SDKEventValueShape> = {
accessibilityZoomAction: {
kind: 'object',
fields: [
{ name: 'direction', value: { kind: 'enum', cases: ['zoomIn', 'zoomOut'] } },
{
name: 'location',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'point', value: { kind: 'point' } },
],
},
anchorPreference: {
kind: 'object',
fields: [
{ name: 'origin', value: { kind: 'point' } },
{ name: 'size', value: { kind: 'size' } },
],
},
currentEntitlementTask: {
kind: 'associatedEnum',
cases: [
{ name: 'loading', values: [] },
{ name: 'failure', values: [{ kind: 'description' }] },
{
name: 'success',
values: [{ kind: 'optional', value: { kind: 'verification' } }],
},
],
open: true,
},
dropConfiguration: {
kind: 'object',
fields: [
{ name: 'itemsCount', value: { kind: 'number' } },
{
name: 'suggestedOperations',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'number' } }],
},
},
{ name: 'size', value: { kind: 'size' } },
{ name: 'location', value: { kind: 'point' } },
],
},
dropDestination: {
kind: 'object',
fields: [
{ name: 'items', value: { kind: 'array', value: { kind: 'string' } } },
{
name: 'session',
value: {
kind: 'object',
fields: [
{ name: 'itemsCount', value: { kind: 'number' } },
{
name: 'suggestedOperations',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'number' } }],
},
},
{ name: 'size', value: { kind: 'size' } },
{ name: 'location', value: { kind: 'point' } },
],
},
},
],
},
onCameraCaptureEvent: {
kind: 'object',
fields: [
{
name: 'phase',
value: { kind: 'enum', cases: ['began', 'cancelled', 'ended'], open: true },
},
],
},
onDragSessionUpdated: {
kind: 'object',
fields: [{ name: 'location', value: { kind: 'point' } }],
},
onDrop: {
kind: 'object',
fields: [
{ name: 'type', value: { kind: 'string' } },
{ name: 'data', value: { kind: 'string' } },
],
},
onDropSessionUpdated: {
kind: 'object',
fields: [
{ name: 'itemsCount', value: { kind: 'number' } },
{
name: 'suggestedOperations',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'number' } }],
},
},
{ name: 'size', value: { kind: 'size' } },
{ name: 'location', value: { kind: 'point' } },
],
},
onGeometryChangeWithSize: {
kind: 'object',
fields: [
{ name: 'oldValue', value: { kind: 'size' } },
{ name: 'newValue', value: { kind: 'size' } },
],
},
onInAppPurchaseCompletion: {
kind: 'object',
fields: [
{
name: 'value',
value: {
kind: 'object',
fields: [
{ name: 'id', value: { kind: 'string' } },
{
name: 'type',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
{ name: 'displayName', value: { kind: 'string' } },
{ name: 'description', value: { kind: 'string' } },
{ name: 'displayPrice', value: { kind: 'string' } },
{ name: 'isFamilyShareable', value: { kind: 'boolean' } },
],
},
},
{
name: 'result',
value: {
kind: 'result',
value: {
kind: 'associatedEnum',
cases: [
{ name: 'success', values: [{ kind: 'verification' }] },
{ name: 'userCancelled', values: [] },
{ name: 'pending', values: [] },
],
open: true,
},
},
},
],
},
onInAppPurchaseStart: {
kind: 'object',
fields: [
{ name: 'id', value: { kind: 'string' } },
{
name: 'type',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
{ name: 'displayName', value: { kind: 'string' } },
{ name: 'description', value: { kind: 'string' } },
{ name: 'displayPrice', value: { kind: 'string' } },
{ name: 'isFamilyShareable', value: { kind: 'boolean' } },
],
},
onKeyPress: {
kind: 'object',
fields: [
{ name: 'characters', value: { kind: 'string' } },
{
name: 'modifiers',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'number' } }],
},
},
],
},
onMapCameraChangeWithEventStruct: {
kind: 'object',
fields: [
{
name: 'camera',
value: {
kind: 'object',
fields: [
{ name: 'distance', value: { kind: 'number' } },
{ name: 'heading', value: { kind: 'number' } },
{ name: 'pitch', value: { kind: 'number' } },
],
},
},
],
},
onPencilDoubleTap: {
kind: 'object',
fields: [
{
name: 'hoverPose',
value: {
kind: 'optional',
value: {
kind: 'object',
fields: [
{ name: 'location', value: { kind: 'point' } },
{
name: 'anchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'zDistance', value: { kind: 'number' } },
{
name: 'altitude',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'azimuth',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'roll',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
],
},
},
},
],
},
onPreferenceChangePreferredColorScheme: {
kind: 'optional',
value: { kind: 'enum', cases: ['light', 'dark'], open: true },
},
onScrollGeometryChangeWithContainerSize: {
kind: 'object',
fields: [
{ name: 'oldValue', value: { kind: 'size' } },
{ name: 'newValue', value: { kind: 'size' } },
],
},
onScrollGeometryChangeWithContentOffset: {
kind: 'object',
fields: [
{ name: 'oldValue', value: { kind: 'point' } },
{ name: 'newValue', value: { kind: 'point' } },
],
},
onScrollGeometryChangeWithContentSize: {
kind: 'object',
fields: [
{ name: 'oldValue', value: { kind: 'size' } },
{ name: 'newValue', value: { kind: 'size' } },
],
},
onScrollTargetVisibilityChange: { kind: 'array', value: { kind: 'string' } },
onTapGestureWithPerform: { kind: 'point' },
pasteDestination: { kind: 'array', value: { kind: 'string' } },
storeProductsTask: {
kind: 'associatedEnum',
cases: [
{ name: 'loading', values: [] },
{ name: 'failure', values: [{ kind: 'description' }] },
{
name: 'success',
values: [
{
kind: 'array',
value: {
kind: 'object',
fields: [
{ name: 'id', value: { kind: 'string' } },
{
name: 'type',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
{ name: 'displayName', value: { kind: 'string' } },
{ name: 'description', value: { kind: 'string' } },
{ name: 'displayPrice', value: { kind: 'string' } },
{ name: 'isFamilyShareable', value: { kind: 'boolean' } },
],
},
},
{ kind: 'array', value: { kind: 'string' } },
],
},
],
open: true,
},
storeProductTask: {
kind: 'associatedEnum',
cases: [
{ name: 'loading', values: [] },
{ name: 'unavailable', values: [] },
{ name: 'failure', values: [{ kind: 'description' }] },
{
name: 'success',
values: [
{
kind: 'object',
fields: [
{ name: 'id', value: { kind: 'string' } },
{
name: 'type',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
{ name: 'displayName', value: { kind: 'string' } },
{ name: 'description', value: { kind: 'string' } },
{ name: 'displayPrice', value: { kind: 'string' } },
{ name: 'isFamilyShareable', value: { kind: 'boolean' } },
],
},
],
},
],
open: true,
},
subscriptionIntroductoryOffer: {
kind: 'object',
fields: [
{
name: 'product',
value: {
kind: 'object',
fields: [
{ name: 'id', value: { kind: 'string' } },
{
name: 'type',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
{ name: 'displayName', value: { kind: 'string' } },
{ name: 'description', value: { kind: 'string' } },
{ name: 'displayPrice', value: { kind: 'string' } },
{ name: 'isFamilyShareable', value: { kind: 'boolean' } },
],
},
},
{
name: 'subscriptionInfo',
value: {
kind: 'object',
fields: [{ name: 'subscriptionGroupID', value: { kind: 'string' } }],
},
},
],
},
subscriptionPromotionalOffer: {
kind: 'object',
fields: [
{
name: 'product',
value: {
kind: 'object',
fields: [
{ name: 'id', value: { kind: 'string' } },
{
name: 'type',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
{ name: 'displayName', value: { kind: 'string' } },
{ name: 'description', value: { kind: 'string' } },
{ name: 'displayPrice', value: { kind: 'string' } },
{ name: 'isFamilyShareable', value: { kind: 'boolean' } },
],
},
},
{
name: 'subscriptionInfo',
value: {
kind: 'object',
fields: [{ name: 'subscriptionGroupID', value: { kind: 'string' } }],
},
},
{
name: 'promotionalOffer',
value: {
kind: 'object',
fields: [
{ name: 'id', value: { kind: 'optional', value: { kind: 'string' } } },
{
name: 'type',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
{ name: 'displayPrice', value: { kind: 'string' } },
{ name: 'periodCount', value: { kind: 'number' } },
{
name: 'paymentMode',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'string' } }],
},
},
],
},
},
],
},
subscriptionStatusTask: {
kind: 'associatedEnum',
cases: [
{ name: 'loading', values: [] },
{ name: 'failure', values: [{ kind: 'description' }] },
{
name: 'success',
values: [
{
kind: 'array',
value: {
kind: 'object',
fields: [
{
name: 'state',
value: {
kind: 'object',
fields: [{ name: 'rawValue', value: { kind: 'number' } }],
},
},
{ name: 'transaction', value: { kind: 'verification' } },
{ name: 'renewalInfo', value: { kind: 'verification' } },
],
},
},
],
},
],
open: true,
},
transformAnchorPreference: {
kind: 'object',
fields: [
{ name: 'origin', value: { kind: 'point' } },
{ name: 'size', value: { kind: 'size' } },
],
},
webViewOnScrollGeometryChangeWithContainerSize: {
kind: 'object',
fields: [
{ name: 'oldValue', value: { kind: 'size' } },
{ name: 'newValue', value: { kind: 'size' } },
],
},
webViewOnScrollGeometryChangeWithContentOffset: {
kind: 'object',
fields: [
{ name: 'oldValue', value: { kind: 'point' } },
{ name: 'newValue', value: { kind: 'point' } },
],
},
webViewOnScrollGeometryChangeWithContentSize: {
kind: 'object',
fields: [
{ name: 'oldValue', value: { kind: 'size' } },
{ name: 'newValue', value: { kind: 'size' } },
],
},
}
const sdkAsyncArguments: Record<string, readonly { field: string; kind: string }[]> = {
currentEntitlementTask: [{ field: 'productID', kind: 'string' }],
storeProductsTask: [{ field: 'ids', kind: 'stringArray' }],
storeProductTask: [{ field: 'id', kind: 'string' }],
subscriptionStatusTask: [{ field: 'groupID', kind: 'string' }],
}
const sdkAsyncStringFields: Record<
string,
{ predicate: string; callback: string; selects: boolean }
> = {
subscriptionIntroductoryOffer: {
predicate: 'applyOffer',
callback: 'compactJWS',
selects: false,
},
subscriptionPromotionalOffer: {
predicate: 'offer',
callback: 'compactJWS',
selects: true,
},
}
const sdkSessionRequests: Record<
string,
{ inputField: string; outputFields: readonly string[] }
> = {
translationTask: {
inputField: 'sourceText',
outputFields: ['sourceText', 'targetText'],
},
}
const sdkAsyncObjectRequestBindings: Record<string, string> = {
lookAroundViewer: 'isPresented',
}
const sdkGestureOptions: Record<string, Record<string, SDKEventValueShape | null>> = {
gesture: {
drag: {
kind: 'object',
fields: [
{ name: 'location', value: { kind: 'point' } },
{ name: 'startLocation', value: { kind: 'point' } },
],
},
longPress: { kind: 'boolean' },
magnify: {
kind: 'object',
fields: [
{ name: 'magnification', value: { kind: 'number' } },
{ name: 'velocity', value: { kind: 'number' } },
{
name: 'startAnchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'startLocation', value: { kind: 'point' } },
],
},
rotate: {
kind: 'object',
fields: [
{
name: 'rotation',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'velocity',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'startAnchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'startLocation', value: { kind: 'point' } },
],
},
spatialTap: {
kind: 'object',
fields: [{ name: 'location', value: { kind: 'point' } }],
},
tap: null,
},
highPriorityGesture: {
drag: {
kind: 'object',
fields: [
{ name: 'location', value: { kind: 'point' } },
{ name: 'startLocation', value: { kind: 'point' } },
],
},
longPress: { kind: 'boolean' },
magnify: {
kind: 'object',
fields: [
{ name: 'magnification', value: { kind: 'number' } },
{ name: 'velocity', value: { kind: 'number' } },
{
name: 'startAnchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'startLocation', value: { kind: 'point' } },
],
},
rotate: {
kind: 'object',
fields: [
{
name: 'rotation',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'velocity',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'startAnchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'startLocation', value: { kind: 'point' } },
],
},
spatialTap: {
kind: 'object',
fields: [{ name: 'location', value: { kind: 'point' } }],
},
tap: null,
},
simultaneousGesture: {
drag: {
kind: 'object',
fields: [
{ name: 'location', value: { kind: 'point' } },
{ name: 'startLocation', value: { kind: 'point' } },
],
},
longPress: { kind: 'boolean' },
magnify: {
kind: 'object',
fields: [
{ name: 'magnification', value: { kind: 'number' } },
{ name: 'velocity', value: { kind: 'number' } },
{
name: 'startAnchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'startLocation', value: { kind: 'point' } },
],
},
rotate: {
kind: 'object',
fields: [
{
name: 'rotation',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'velocity',
value: {
kind: 'object',
fields: [{ name: 'radians', value: { kind: 'number' } }],
},
},
{
name: 'startAnchor',
value: {
kind: 'object',
fields: [
{ name: 'x', value: { kind: 'number' } },
{ name: 'y', value: { kind: 'number' } },
],
},
},
{ name: 'startLocation', value: { kind: 'point' } },
],
},
spatialTap: {
kind: 'object',
fields: [{ name: 'location', value: { kind: 'point' } }],
},
tap: null,
},
}
const sdkCodableOptional: Record<string, boolean> = { tabViewCustomization: true }
const sdkRecords: Record<
string,
readonly {
field: string
kind: string
optional: boolean
unique?: boolean
fields?: readonly { name: string; type: string; integer: boolean }[]
eventValue?: SDKEventValueShape
}[]
> = {
accessibilityActivationPointWithActivationPointAndIsEnabled: [
{ field: 'activationPoint', kind: 'enum', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityCustomContent: [
{ field: 'label', kind: 'string', optional: false },
{ field: 'value', kind: 'string', optional: false },
],
accessibilityDirectTouch: [
{ field: 'isDirectTouchArea', kind: 'boolean', optional: false },
{ field: 'options', kind: 'enum', optional: false },
],
accessibilityDragPointWithPointAndDescription: [
{ field: 'point', kind: 'enum', optional: false },
{ field: 'description', kind: 'string', optional: false },
],
accessibilityDragPointWithPointAndDescriptionAndIsEnabled: [
{ field: 'point', kind: 'enum', optional: false },
{ field: 'description', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityDropPointWithPointAndDescription: [
{ field: 'point', kind: 'enum', optional: false },
{ field: 'description', kind: 'string', optional: false },
],
accessibilityDropPointWithPointAndDescriptionAndIsEnabled: [
{ field: 'point', kind: 'enum', optional: false },
{ field: 'description', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityHiddenWithHiddenAndIsEnabled: [
{ field: 'hidden', kind: 'boolean', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityHintWithHintAndIsEnabled: [
{ field: 'hint', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityIdentifierWithIdentifierAndIsEnabled: [
{ field: 'identifier', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityInputLabels: [
{ field: 'inputLabels', kind: 'stringArray', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityLabeledPair: [
{ field: 'role', kind: 'enum', optional: false },
{ field: 'id', kind: 'string', optional: false },
],
accessibilityLabelWithLabelAndIsEnabled: [
{ field: 'label', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityLinkedGroup: [{ field: 'id', kind: 'string', optional: false }],
accessibilityRespondsToUserInteractionWithRespondsToUserInteractionAndIsEnabled: [
{ field: 'respondsToUserInteraction', kind: 'boolean', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityRotor: [
{ field: 'rotorLabel', kind: 'string', optional: false },
{ field: 'entries', kind: 'stringArray', optional: false, unique: true },
],
accessibilityRotorEntry: [{ field: 'id', kind: 'string', optional: false }],
accessibilityScrollStatus: [
{ field: 'status', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
accessibilityValueWithValueDescriptionAndIsEnabled: [
{ field: 'valueDescription', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
actionSheet: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'title', kind: 'string', optional: false },
],
alert: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'title', kind: 'string', optional: false },
],
alignmentGuideWithHorizontalAlignment: [
{ field: 'g', kind: 'enum', optional: false },
{ field: 'computeValue', kind: 'number', optional: false },
],
alignmentGuideWithVerticalAlignment: [
{ field: 'g', kind: 'enum', optional: false },
{ field: 'computeValue', kind: 'number', optional: false },
],
appStoreMerchandising: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'kind', kind: 'string', optional: false },
],
appStoreOverlayWithAppClipConfiguration: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'position', kind: 'enum', optional: false },
],
appStoreOverlayWithAppConfiguration: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'appIdentifier', kind: 'string', optional: false },
{ field: 'position', kind: 'enum', optional: false },
],
aspectRatio: [
{ field: 'aspectRatio', kind: 'number', optional: true },
{ field: 'contentMode', kind: 'enum', optional: false },
],
blur: [
{ field: 'radius', kind: 'number', optional: false },
{ field: 'opaque', kind: 'boolean', optional: false },
],
colorEffect: [
{ field: 'shader', kind: 'string', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
containerCornerOffset: [
{ field: 'edges', kind: 'enum', optional: false },
{ field: 'sizeToFit', kind: 'boolean', optional: false },
],
containerRelativeFrameWithAxesAndAlignment: [
{ field: 'axes', kind: 'enum', optional: false },
{ field: 'alignment', kind: 'enum', optional: false },
],
containerRelativeFrameWithAxesAndCountAndSpanAndSpacingAndAlignment: [
{ field: 'axes', kind: 'enum', optional: false },
{ field: 'count', kind: 'number', optional: false },
{ field: 'span', kind: 'number', optional: false },
{ field: 'spacing', kind: 'number', optional: false },
{ field: 'alignment', kind: 'enum', optional: false },
],
contentMarginsWithEdgesAndLengthAndPlacement: [
{ field: 'edges', kind: 'enum', optional: false },
{ field: 'length', kind: 'number', optional: true },
{ field: 'placement', kind: 'enum', optional: false },
],
contentMarginsWithLengthAndPlacement: [
{ field: 'length', kind: 'number', optional: false },
{ field: 'placement', kind: 'enum', optional: false },
],
copyable: [{ field: 'payload', kind: 'stringArray', optional: false }],
cornerRadiusWithRadiusAndAntialiased: [
{ field: 'radius', kind: 'number', optional: false },
{ field: 'antialiased', kind: 'boolean', optional: false },
],
defaultScrollAnchorWithAnchorAndRole: [
{ field: 'anchor', kind: 'enum', optional: true },
{ field: 'role', kind: 'enum', optional: false },
],
dialogSuppressionToggleWithLabelAndIsSuppressed: [
{ field: 'label', kind: 'string', optional: false },
{ field: 'isSuppressed', kind: 'bindingBoolean', optional: false },
],
distortionEffect: [
{ field: 'shader', kind: 'string', optional: false },
{
field: 'maxSampleOffset',
kind: 'numericStruct',
optional: false,
fields: [
{ name: 'width', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'height', type: 'CoreFoundation.CGFloat', integer: false },
],
},
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
draggable: [{ field: 'payload', kind: 'string', optional: false }],
drawingGroup: [
{ field: 'opaque', kind: 'boolean', optional: false },
{ field: 'colorMode', kind: 'enum', optional: false },
],
fileExporter: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'item', kind: 'string', optional: true },
{ field: 'onCompletion', kind: 'resultURL', optional: false },
],
fileImporterWithIsPresentedAndAllowedContentTypesAndAllowsMultipleSelectionAndOnCompletion:
[
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'allowedContentTypes', kind: 'stringArray', optional: false },
{ field: 'allowsMultipleSelection', kind: 'boolean', optional: false },
{ field: 'onCompletion', kind: 'resultURLArray', optional: false },
],
fileImporterWithIsPresentedAndAllowedContentTypesAndOnCompletion: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'allowedContentTypes', kind: 'stringArray', optional: false },
{ field: 'onCompletion', kind: 'resultURL', optional: false },
],
fileMover: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'file', kind: 'url', optional: true },
{ field: 'onCompletion', kind: 'resultURL', optional: false },
],
fixedSizeWithHorizontalAndVertical: [
{ field: 'horizontal', kind: 'boolean', optional: false },
{ field: 'vertical', kind: 'boolean', optional: false },
],
focusableWithIsFocusableAndInteractions: [
{ field: 'isFocusable', kind: 'boolean', optional: false },
{ field: 'interactions', kind: 'enum', optional: false },
],
frameWithMinWidthAndIdealWidthAndMaxWidthAndMinHeightAndIdealHeightAndMaxHeightAndAlignment:
[
{ field: 'minWidth', kind: 'number', optional: true },
{ field: 'idealWidth', kind: 'number', optional: true },
{ field: 'maxWidth', kind: 'number', optional: true },
{ field: 'minHeight', kind: 'number', optional: true },
{ field: 'idealHeight', kind: 'number', optional: true },
{ field: 'maxHeight', kind: 'number', optional: true },
{ field: 'alignment', kind: 'enum', optional: false },
],
frameWithWidthAndHeightAndAlignment: [
{ field: 'width', kind: 'number', optional: true },
{ field: 'height', kind: 'number', optional: true },
{ field: 'alignment', kind: 'enum', optional: false },
],
glassEffectID: [{ field: 'id', kind: 'string', optional: true }],
glassEffectUnion: [{ field: 'id', kind: 'string', optional: true }],
handGestureShortcut: [
{ field: 'shortcut', kind: 'enum', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
handlesExternalEvents: [
{ field: 'preferring', kind: 'stringSet', optional: false },
{ field: 'allowing', kind: 'stringSet', optional: false },
],
ignoresSafeAreaWithRegionsAndEdgesAndAlignment: [
{ field: 'regions', kind: 'enum', optional: false },
{ field: 'edges', kind: 'enum', optional: false },
{ field: 'alignment', kind: 'enum', optional: true },
],
inspectorColumnWidthWithMinAndIdealAndMax: [
{ field: 'min', kind: 'number', optional: true },
{ field: 'ideal', kind: 'number', optional: false },
{ field: 'max', kind: 'number', optional: true },
],
keyboardShortcutWithKeyAndModifiers: [
{ field: 'key', kind: 'enum', optional: false },
{ field: 'modifiers', kind: 'enum', optional: false },
],
keyboardShortcutWithKeyAndModifiersAndLocalization: [
{ field: 'key', kind: 'enum', optional: false },
{ field: 'modifiers', kind: 'enum', optional: false },
{ field: 'localization', kind: 'enum', optional: false },
],
layerEffect: [
{ field: 'shader', kind: 'string', optional: false },
{
field: 'maxSampleOffset',
kind: 'numericStruct',
optional: false,
fields: [
{ name: 'width', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'height', type: 'CoreFoundation.CGFloat', integer: false },
],
},
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
lineLimitWithLimitAndReservesSpace: [
{ field: 'limit', kind: 'number', optional: false },
{ field: 'reservesSpace', kind: 'boolean', optional: false },
],
listRowInsets: [
{ field: 'edges', kind: 'enum', optional: false },
{ field: 'length', kind: 'number', optional: true },
],
listRowSeparator: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'edges', kind: 'enum', optional: false },
],
listRowSeparatorTint: [
{ field: 'color', kind: 'enum', optional: true },
{ field: 'edges', kind: 'enum', optional: false },
],
listSectionMargins: [
{ field: 'edges', kind: 'enum', optional: false },
{ field: 'length', kind: 'number', optional: true },
],
listSectionSeparator: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'edges', kind: 'enum', optional: false },
],
listSectionSeparatorTint: [
{ field: 'color', kind: 'enum', optional: true },
{ field: 'edges', kind: 'enum', optional: false },
],
manageSubscriptionsSheetWithIsPresentedAndSubscriptionGroupID: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'subscriptionGroupID', kind: 'string', optional: false },
],
mapItemDetailPopoverWithCurrentLocation: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
],
mapItemDetailPopoverWithCurrentLocationAndArrowEdge: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'arrowEdge', kind: 'enum', optional: false },
],
mapItemDetailSheetWithCurrentLocation: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
],
matchedGeometryEffect: [{ field: 'id', kind: 'string', optional: false }],
matchedTransitionSource: [{ field: 'id', kind: 'string', optional: false }],
navigationBarTitleWithTitleAndDisplayMode: [
{ field: 'title', kind: 'string', optional: false },
{ field: 'displayMode', kind: 'enum', optional: false },
],
navigationSplitViewColumnWidthWithMinAndIdealAndMax: [
{ field: 'min', kind: 'number', optional: true },
{ field: 'ideal', kind: 'number', optional: false },
{ field: 'max', kind: 'number', optional: true },
],
offset: [
{ field: 'x', kind: 'number', optional: false },
{ field: 'y', kind: 'number', optional: false },
],
onCameraCaptureEventWithIsEnabledAndDefaultSoundDisabledAndPrimaryActionAndSecondaryAction:
[
{ field: 'isEnabled', kind: 'boolean', optional: false },
{ field: 'defaultSoundDisabled', kind: 'boolean', optional: false },
{
field: 'primaryAction',
kind: 'eventStruct',
optional: false,
eventValue: {
kind: 'object',
fields: [
{
name: 'phase',
value: { kind: 'enum', cases: ['began', 'cancelled', 'ended'], open: true },
},
{ name: 'shouldPlaySound', value: { kind: 'boolean' } },
],
},
},
{
field: 'secondaryAction',
kind: 'eventStruct',
optional: false,
eventValue: {
kind: 'object',
fields: [
{
name: 'phase',
value: { kind: 'enum', cases: ['began', 'cancelled', 'ended'], open: true },
},
{ name: 'shouldPlaySound', value: { kind: 'boolean' } },
],
},
},
],
onCameraCaptureEventWithIsEnabledAndPrimaryActionAndSecondaryAction: [
{ field: 'isEnabled', kind: 'boolean', optional: false },
{
field: 'primaryAction',
kind: 'eventStruct',
optional: false,
eventValue: {
kind: 'object',
fields: [
{
name: 'phase',
value: { kind: 'enum', cases: ['began', 'cancelled', 'ended'], open: true },
},
],
},
},
{
field: 'secondaryAction',
kind: 'eventStruct',
optional: false,
eventValue: {
kind: 'object',
fields: [
{
name: 'phase',
value: { kind: 'enum', cases: ['began', 'cancelled', 'ended'], open: true },
},
],
},
},
],
onContinueUserActivity: [
{ field: 'activityType', kind: 'string', optional: false },
{
field: 'action',
kind: 'eventStruct',
optional: false,
eventValue: {
kind: 'object',
fields: [
{ name: 'activityType', value: { kind: 'string' } },
{ name: 'isEligibleForHandoff', value: { kind: 'boolean' } },
{ name: 'isEligibleForPrediction', value: { kind: 'boolean' } },
{ name: 'isEligibleForPublicIndexing', value: { kind: 'boolean' } },
{ name: 'isEligibleForSearch', value: { kind: 'boolean' } },
{ name: 'needsSave', value: { kind: 'boolean' } },
{ name: 'supportsContinuationStreams', value: { kind: 'boolean' } },
{
name: 'targetContentIdentifier',
value: { kind: 'optional', value: { kind: 'string' } },
},
{ name: 'title', value: { kind: 'optional', value: { kind: 'string' } } },
],
},
},
],
photosPickerAccessoryVisibility: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'edges', kind: 'enum', optional: false },
],
photosReferenceImageViewer: [
{ field: 'fileURL', kind: 'bindingOptionalURL', optional: false },
{ field: 'onProcessingCompletion', kind: 'resultURL', optional: false },
],
photosSharedAlbumCreationSheet: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
],
photosSharedAlbumCustomizationSheet: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'albumIdentifier', kind: 'string', optional: true },
],
photosSharedAlbumPostingSheet: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'items', kind: 'stringArray', optional: false },
],
position: [
{ field: 'x', kind: 'number', optional: false },
{ field: 'y', kind: 'number', optional: false },
],
postToPhotosSharedAlbumSheet: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'items', kind: 'stringArray', optional: false },
],
presentationCompactAdaptationWithHorizontalAdaptationAndVerticalAdaptation: [
{ field: 'horizontalAdaptation', kind: 'enum', optional: false },
{ field: 'verticalAdaptation', kind: 'enum', optional: false },
],
previewContext: [{ field: 'family', kind: 'enum', optional: false }],
projectionEffect: [
{
field: 'transform',
kind: 'numericStruct',
optional: false,
fields: [
{ name: 'a', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'b', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'c', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'd', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'tx', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'ty', type: 'CoreFoundation.CGFloat', integer: false },
],
},
],
refundRequestSheet: [
{ field: 'transactionID', kind: 'string', optional: false },
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
],
rotation3DEffect: [
{
field: 'angle',
kind: 'numericStruct',
optional: false,
fields: [{ name: 'radians', type: 'Swift.Double', integer: false }],
},
{
field: 'axis',
kind: 'numericTuple',
optional: false,
fields: [
{ name: 'x', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'y', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'z', type: 'CoreFoundation.CGFloat', integer: false },
],
},
{ field: 'anchor', kind: 'enum', optional: false },
{ field: 'anchorZ', kind: 'number', optional: false },
{ field: 'perspective', kind: 'number', optional: false },
],
rotationEffect: [
{ field: 'angle', kind: 'enum', optional: false },
{ field: 'anchor', kind: 'enum', optional: false },
],
scaleEffectWithSAndAnchor: [
{ field: 's', kind: 'number', optional: false },
{ field: 'anchor', kind: 'enum', optional: false },
],
scaleEffectWithXAndYAndAnchor: [
{ field: 'x', kind: 'number', optional: false },
{ field: 'y', kind: 'number', optional: false },
{ field: 'anchor', kind: 'enum', optional: false },
],
scenePaddingWithPaddingAndEdges: [
{ field: 'padding', kind: 'enum', optional: false },
{ field: 'edges', kind: 'enum', optional: false },
],
scrollBounceBehavior: [
{ field: 'behavior', kind: 'enum', optional: false },
{ field: 'axes', kind: 'enum', optional: false },
],
scrollEdgeEffectHidden: [
{ field: 'hidden', kind: 'boolean', optional: false },
{ field: 'edges', kind: 'enum', optional: false },
],
scrollEdgeEffectStyle: [
{ field: 'style', kind: 'enum', optional: true },
{ field: 'edges', kind: 'enum', optional: false },
],
scrollIndicators: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'axes', kind: 'enum', optional: false },
],
searchSuggestions: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'placements', kind: 'enum', optional: false },
],
sensoryFeedback: [
{ field: 'feedback', kind: 'enum', optional: false },
{ field: 'trigger', kind: 'string', optional: false },
],
shadow: [
{ field: 'color', kind: 'enum', optional: false },
{ field: 'radius', kind: 'number', optional: false },
{ field: 'x', kind: 'number', optional: false },
{ field: 'y', kind: 'number', optional: false },
],
storeButton: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'buttonKinds', kind: 'enum', optional: false },
],
strikethrough: [
{ field: 'isActive', kind: 'boolean', optional: false },
{ field: 'pattern', kind: 'enum', optional: false },
{ field: 'color', kind: 'enum', optional: true },
],
subscriptionOfferViewButtonVisibility: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'buttonKinds', kind: 'enum', optional: false },
],
subscriptionStorePolicyDestination: [
{ field: 'url', kind: 'url', optional: false },
{ field: 'button', kind: 'enum', optional: false },
],
textInputFormattingControlVisibility: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'placement', kind: 'enum', optional: false },
],
textScale: [
{ field: 'scale', kind: 'enum', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
toolbarBackground: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'bars', kind: 'enum', optional: false },
],
toolbarBackgroundVisibility: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'bars', kind: 'enum', optional: false },
],
toolbarColorScheme: [
{ field: 'colorScheme', kind: 'enum', optional: true },
{ field: 'bars', kind: 'enum', optional: false },
],
toolbarMinimizationBehavior: [
{ field: 'behavior', kind: 'enum', optional: false },
{ field: 'bars', kind: 'enum', optional: false },
],
toolbarMinimizationRestoration: [
{ field: 'restoration', kind: 'enum', optional: false },
{ field: 'bars', kind: 'enum', optional: false },
],
toolbarMinimizationSafeAreaAdjustment: [
{ field: 'adjustment', kind: 'enum', optional: false },
{ field: 'bars', kind: 'enum', optional: false },
],
toolbarVisibility: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'bars', kind: 'enum', optional: false },
],
toolbarWithVisibilityAndBars: [
{ field: 'visibility', kind: 'enum', optional: false },
{ field: 'bars', kind: 'enum', optional: false },
],
transaction: [
{
field: 'transform',
kind: 'structUpdate',
optional: false,
fields: [
{ name: 'isContinuous', type: 'Swift.Bool', integer: false },
{
name: 'scrollPositionUpdatePreservesVelocity',
type: 'Swift.Bool',
integer: false,
},
{ name: 'disablesAnimations', type: 'Swift.Bool', integer: false },
{ name: 'tracksVelocity', type: 'Swift.Bool', integer: false },
],
},
],
transformEffect: [
{
field: 'transform',
kind: 'numericStruct',
optional: false,
fields: [
{ name: 'a', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'b', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'c', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'd', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'tx', type: 'CoreFoundation.CGFloat', integer: false },
{ name: 'ty', type: 'CoreFoundation.CGFloat', integer: false },
],
},
],
translationPresentation: [
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
{ field: 'text', kind: 'string', optional: false },
],
typesettingLanguage: [
{ field: 'language', kind: 'enum', optional: false },
{ field: 'isEnabled', kind: 'boolean', optional: false },
],
underline: [
{ field: 'isActive', kind: 'boolean', optional: false },
{ field: 'pattern', kind: 'enum', optional: false },
{ field: 'color', kind: 'enum', optional: true },
],
userActivity: [
{ field: 'activityType', kind: 'string', optional: false },
{ field: 'isActive', kind: 'boolean', optional: false },
{
field: 'update',
kind: 'classUpdate',
optional: false,
fields: [
{ name: 'isEligibleForHandoff', type: 'Swift.Bool', integer: false },
{ name: 'isEligibleForPrediction', type: 'Swift.Bool', integer: false },
{ name: 'isEligibleForPublicIndexing', type: 'Swift.Bool', integer: false },
{ name: 'isEligibleForSearch', type: 'Swift.Bool', integer: false },
{ name: 'needsSave', type: 'Swift.Bool', integer: false },
{ name: 'supportsContinuationStreams', type: 'Swift.Bool', integer: false },
{ name: 'targetContentIdentifier', type: 'Swift.String?', integer: false },
{ name: 'title', type: 'Swift.String?', integer: false },
],
},
],
workoutPreview: [
{ field: 'workout', kind: 'string', optional: false },
{ field: 'isPresented', kind: 'bindingBoolean', optional: false },
],
}
export function validSDKEventValue(value: unknown, shape: SDKEventValueShape): boolean {
if (shape.kind === 'optional')
return value === null || validSDKEventValue(value, shape.value)
if (shape.kind === 'array')
return (
Array.isArray(value) && value.every((item) => validSDKEventValue(item, shape.value))
)
if (shape.kind === 'number') return typeof value === 'number' && Number.isFinite(value)
if (shape.kind === 'string' || shape.kind === 'description' || shape.kind === 'boolean')
return typeof value === (shape.kind === 'description' ? 'string' : shape.kind)
if (shape.kind === 'enum')
return (
typeof value === 'string' &&
(shape.cases.includes(value) || (shape.open === true && value === 'unknown'))
)
if (shape.kind === 'verification')
return Boolean(
value &&
typeof value === 'object' &&
((value as { case?: unknown }).case === 'verified' ||
(value as { case?: unknown }).case === 'unverified') &&
typeof (value as { jwsRepresentation?: unknown }).jwsRepresentation === 'string' &&
((value as { case: string; error?: unknown }).case === 'verified'
? (value as { error?: unknown }).error === null
: typeof (value as { error?: unknown }).error === 'string')
)
if (shape.kind === 'result')
return Boolean(
value &&
typeof value === 'object' &&
((value as { case?: unknown }).case === 'success'
? validSDKEventValue((value as { value?: unknown }).value, shape.value)
: (value as { case?: unknown }).case === 'failure' &&
typeof (value as { error?: unknown }).error === 'string')
)
if (shape.kind === 'associatedEnum') {
if (!value || typeof value !== 'object') return false
if (shape.open && (value as { case?: unknown }).case === 'unknown')
return (
Array.isArray((value as { values?: unknown }).values) &&
(value as { values: unknown[] }).values.length === 0
)
const item = shape.cases.find(
(entry) => entry.name === (value as { case?: unknown }).case
)
return Boolean(
item &&
Array.isArray((value as { values?: unknown }).values) &&
(value as { values: unknown[] }).values.length === item.values.length &&
item.values.every((nested, index) =>
validSDKEventValue((value as { values: unknown[] }).values[index], nested)
)
)
}
if (!value || typeof value !== 'object') return false
const record = value as Record<string, unknown>
if (shape.kind === 'point')
return (
typeof record.x === 'number' &&
Number.isFinite(record.x) &&
typeof record.y === 'number' &&
Number.isFinite(record.y)
)
if (shape.kind === 'size')
return (
typeof record.width === 'number' &&
Number.isFinite(record.width) &&
typeof record.height === 'number' &&
Number.isFinite(record.height)
)
if (shape.kind !== 'object') return false
return shape.fields.every(
(field) =>
Object.hasOwn(record, field.name) &&
validSDKEventValue(record[field.name], field.value)
)
}
type OneNativeTextRanges = readonly (readonly [start: number, end: number])[] | null
function validTextRanges(value: unknown, text: string): value is OneNativeTextRanges {
if (value === null) return true
if (!Array.isArray(value) || value.length === 0) return false
let previousEnd = -1
for (const pair of value) {
if (!Array.isArray(pair) || pair.length !== 2) return false
const [start, end] = pair
if (
!Number.isSafeInteger(start) ||
!Number.isSafeInteger(end) ||
start < 0 ||
start > end ||
end > text.length ||
start <= previousEnd ||
(value.length > 1 && start === end)
)
return false
for (const offset of [start, end]) {
const before = text.charCodeAt(offset - 1)
const after = text.charCodeAt(offset)
if (before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff)
return false
}
previousEnd = end
}
return true
}
export function swiftStyleNative(
style: OneNativeStyle | undefined
): OneNativeStyleNative | undefined {
if (!style) return undefined
// a PhaseAnimator or KeyframeAnimator child carries every evaluation of its
// content closure; native resolves the current one from its animator.
const animator = animatorStyleOf(style)
if (animator) return animatorStyleNative(animator, swiftStyleNative)
const native: Record<string, unknown> = {}
const sdkModifiers: [string, string][] = []
for (const [name, value] of Object.entries(style)) {
if (value === undefined) continue
if (Object.hasOwn(sdkKinds, name)) {
const kind = sdkKinds[name as keyof typeof sdkKinds]
if (kind === 'record') {
if (typeof value !== 'object' || value === null || Array.isArray(value))
throw new Error(name + ' must be a record')
const record = value as Record<string, unknown>
const values = sdkRecords[name].map((argument) => {
const item = record[argument.field]
if (argument.optional && item === null) return null
if (argument.kind === 'bindingBoolean') {
if (
!item ||
typeof item !== 'object' ||
typeof (item as { value?: unknown }).value !== 'boolean' ||
typeof (item as { onChange?: unknown }).onChange !== 'function'
)
throw new Error(name + '.' + argument.field + ' must be a boolean binding')
return String((item as { value: boolean }).value)
}
if (argument.kind === 'bindingOptionalURL') {
if (
!item ||
typeof item !== 'object' ||
((item as { value?: unknown }).value !== null &&
typeof (item as { value?: unknown }).value !== 'string') ||
typeof (item as { onChange?: unknown }).onChange !== 'function'
)
throw new Error(name + '.' + argument.field + ' must be a URL binding')
return JSON.stringify((item as { value: string | null }).value)
}
if (
argument.kind === 'resultURL' ||
argument.kind === 'resultURLArray' ||
argument.kind === 'eventStruct'
) {
if (typeof item !== 'function')
throw new Error(name + '.' + argument.field + ' must be a callback')
return ''
}
if (argument.kind === 'classUpdate' || argument.kind === 'structUpdate') {
if (
!item ||
typeof item !== 'object' ||
Array.isArray(item) ||
Object.keys(item).length === 0 ||
Object.entries(item).some(([key, fieldValue]) => {
const field = argument.fields?.find((entry) => entry.name === key)
return (
!field ||
(field.type === 'Swift.Bool'
? typeof fieldValue !== 'boolean'
: field.type.endsWith('?') && fieldValue === null
? false
: typeof fieldValue !== 'string')
)
})
)
throw new Error(
name +
'.' +
argument.field +
(argument.kind === 'classUpdate'
? ' must be an SDK class update'
: ' must be an SDK struct update')
)
return JSON.stringify(item)
}
if (
argument.kind === 'number' &&
(typeof item !== 'number' || !Number.isFinite(item))
)
throw new Error(name + '.' + argument.field + ' must be finite')
if (argument.kind === 'boolean' && typeof item !== 'boolean')
throw new Error(name + '.' + argument.field + ' must be a boolean')
if (
(argument.kind === 'string' ||
argument.kind === 'url' ||
argument.kind === 'enum') &&
typeof item !== 'string'
)
throw new Error(name + '.' + argument.field + ' must be a string')
if (
(argument.kind === 'stringArray' || argument.kind === 'stringSet') &&
(!Array.isArray(item) || item.some((element) => typeof element !== 'string'))
)
throw new Error(name + '.' + argument.field + ' must be a string array')
if (
argument.unique &&
new Set(item as string[]).size !== (item as string[]).length
)
throw new Error(
name + '.' + argument.field + ' must contain distinct strings'
)
if (argument.kind === 'numericStruct' || argument.kind === 'numericTuple') {
if (
!item ||
typeof item !== 'object' ||
Array.isArray(item) ||
Object.keys(item).length !== argument.fields!.length ||
argument.fields!.some((field) => {
const number = (item as Record<string, unknown>)[field.name]
return (
typeof number !== 'number' ||
!Number.isFinite(number) ||
(field.integer && !Number.isSafeInteger(number))
)
})
)
throw new Error(name + '.' + argument.field + ' must be a numeric object')
return JSON.stringify(item)
}
return argument.kind === 'stringArray' || argument.kind === 'stringSet'
? JSON.stringify(item)
: String(item)
})
sdkModifiers.push([name, JSON.stringify(values)])
continue
}
if (kind === 'gesture') {
if (
!value ||
typeof value !== 'object' ||
Array.isArray(value) ||
typeof (value as { kind?: unknown }).kind !== 'string' ||
!Object.hasOwn(sdkGestureOptions[name], (value as { kind: string }).kind) ||
typeof (value as { onEnded?: unknown }).onEnded !== 'function'
)
throw new Error(name + ' must be an SDK gesture and callback')
sdkModifiers.push([name, (value as { kind: string }).kind])
continue
}
if (kind === 'visualEffect') {
if (
!value ||
typeof value !== 'object' ||
Array.isArray(value) ||
typeof (value as { kind?: unknown }).kind !== 'string' ||
!sdkVisualEffects[name].includes((value as { kind: string }).kind) ||
typeof (value as { value?: unknown }).value !== 'number' ||
!Number.isFinite((value as { value: number }).value)
)
throw new Error(name + ' must be a visual effect and finite value')
sdkModifiers.push([
name,
JSON.stringify([
(value as { kind: string }).kind,
String((value as { value: number }).value),
]),
])
continue
}
if (kind === 'optionSet') {
if (!value || typeof value !== 'object' || Array.isArray(value))
throw new Error(name + ' must be an SDK option set')
const record = value as Record<string, unknown>
const options: Record<string, string> = {}
for (const [field, item] of Object.entries(record)) {
const argument = sdkOptionSets[name].find((entry) => entry.field === field)
if (!argument) throw new Error(name + '.' + field + ' is not an SDK option')
if (
argument.kind === 'number' &&
(typeof item !== 'number' || !Number.isSafeInteger(item))
)
throw new Error(name + '.' + field + ' must be finite')
if (argument.kind === 'boolean' && typeof item !== 'boolean')
throw new Error(name + '.' + field + ' must be a boolean')
if (argument.kind === 'string' && typeof item !== 'string')
throw new Error(name + '.' + field + ' must be a string')
options[field] = String(item)
}
sdkModifiers.push([name, JSON.stringify(options)])
continue
}
if (kind === 'caseSet') {
if (
!Array.isArray(value) ||
value.some(
(item) => typeof item !== 'string' || !sdkEventCases[name].includes(item)
)
)
throw new Error(name + ' must be public SDK values')
sdkModifiers.push([name, JSON.stringify(value)])
continue
}
if (kind === 'bindingTextSelection') {
const binding = value as
| { text?: unknown; value?: unknown; onChange?: unknown }
| undefined
if (
!binding ||
typeof binding.text !== 'string' ||
!validTextRanges(binding.value, binding.text) ||
typeof binding.onChange !== 'function'
)
throw new Error(
name + ' must have search text, UTF-16 ranges, and an onChange callback'
)
sdkModifiers.push([
name,
JSON.stringify([binding.text, JSON.stringify(binding.value)]),
])
continue
}
if (kind === 'chartDescriptor') {
if (!value || typeof value !== 'object' || Array.isArray(value))
throw new Error(name + ' must be a chart descriptor')
const chart = value as Record<string, unknown>
if (
(chart.title !== undefined && typeof chart.title !== 'string') ||
(chart.summary !== undefined && typeof chart.summary !== 'string') ||
!Array.isArray(chart.series) ||
chart.series.some((series) => {
if (!series || typeof series !== 'object' || Array.isArray(series))
return true
const item = series as Record<string, unknown>
return (
typeof item.name !== 'string' ||
typeof item.isContinuous !== 'boolean' ||
!Array.isArray(item.points) ||
item.points.some((point) => {
if (!point || typeof point !== 'object' || Array.isArray(point))
return true
const coordinate = point as Record<string, unknown>
return (
typeof coordinate.x !== 'number' ||
!Number.isFinite(coordinate.x) ||
(coordinate.y !== undefined &&
(typeof coordinate.y !== 'number' ||
!Number.isFinite(coordinate.y))) ||
(coordinate.label !== undefined && typeof coordinate.label !== 'string')
)
})
)
}) ||
[chart.xAxis, chart.yAxis].some((axis, index) => {
if (index === 1 && axis === undefined) return false
if (!axis || typeof axis !== 'object' || Array.isArray(axis)) return true
const item = axis as Record<string, unknown>
return (
typeof item.title !== 'string' ||
!Array.isArray(item.range) ||
item.range.length !== 2 ||
item.range.some(
(bound) => typeof bound !== 'number' || !Number.isFinite(bound)
) ||
item.range[0] > item.range[1] ||
(item.gridlinePositions !== undefined &&
(!Array.isArray(item.gridlinePositions) ||
item.gridlinePositions.some(
(position) =>
typeof position !== 'number' || !Number.isFinite(position)
)))
)
})
)
throw new Error(name + ' must contain finite axes and series points')
sdkModifiers.push([name, JSON.stringify(value)])
continue
}
if (kind === 'phaseAnimation') {
if (!value || typeof value !== 'object' || Array.isArray(value))
throw new Error(name + ' must be a scalar phase animation')
const config = value as Record<string, unknown>
if (
!Array.isArray(config.phases) ||
config.phases.length < 2 ||
config.phases.some((phase) => !validScalarEffect(config.effect, phase)) ||
typeof config.duration !== 'number' ||
!Number.isFinite(config.duration) ||
config.duration <= 0
)
throw new Error(name + ' must have finite phases and positive duration')
sdkModifiers.push([name, JSON.stringify(value)])
continue
}
if (kind === 'keyframeAnimation') {
if (!value || typeof value !== 'object' || Array.isArray(value))
throw new Error(name + ' must be a scalar keyframe animation')
const config = value as Record<string, unknown>
if (
!validScalarEffect(config.effect, config.initialValue) ||
(config.repeating !== undefined && typeof config.repeating !== 'boolean') ||
!Array.isArray(config.frames) ||
!config.frames.length ||
config.frames.some((frame) => {
if (!frame || typeof frame !== 'object' || Array.isArray(frame)) return true
const item = frame as Record<string, unknown>
return (
!validScalarEffect(config.effect, item.value) ||
typeof item.duration !== 'number' ||
!Number.isFinite(item.duration) ||
item.duration <= 0
)
})
)
throw new Error(name + ' must have finite keyframes and positive durations')
sdkModifiers.push([name, JSON.stringify(value)])
continue
}
if (kind === 'seedKeyframeAnimation') {
if (!value || typeof value !== 'object' || Array.isArray(value))
throw new Error(name + ' must be a numeric keyframe animation')
const config = value as Record<string, unknown>
if (
typeof config.trigger !== 'string' ||
typeof config.property !== 'string' ||
!sdkSeedKeyframeFields[name]?.includes(config.property) ||
!Array.isArray(config.frames) ||
!config.frames.length ||
config.frames.some((frame) => {
if (!frame || typeof frame !== 'object' || Array.isArray(frame)) return true
const item = frame as Record<string, unknown>
return (
typeof item.value !== 'number' ||
!Number.isFinite(item.value) ||
typeof item.duration !== 'number' ||
!Number.isFinite(item.duration) ||
item.duration <= 0
)
})
)
throw new Error(
name + ' must have a trigger, numeric property and timed keyframes'
)
sdkModifiers.push([name, JSON.stringify(value)])
continue
}
if (kind === 'registeredValue') {
if (typeof value !== 'string' || !value)
throw new Error(name + ' must name a registered native Swift value')
sdkModifiers.push([name, value])
continue
}
if (kind === 'eventAsyncStruct' && sdkAsyncArguments[name]) {
if (
!value ||
typeof value !== 'object' ||
Array.isArray(value) ||
typeof (value as { onAction?: unknown }).onAction !== 'function'
)
throw new Error(name + ' must be an async SDK callback and arguments')
const record = value as Record<string, unknown>
const argumentsFromSDK = sdkAsyncArguments[name].map(({ field, kind }) => {
const item = record[field]
if (kind === 'stringArray') {
if (!Array.isArray(item) || item.some((value) => typeof value !== 'string'))
throw new Error(name + '.' + field + ' must be a string array')
return JSON.stringify(item)
}
if (typeof item !== 'string')
throw new Error(name + '.' + field + ' must be a string')
return item
})
sdkModifiers.push([name, JSON.stringify(argumentsFromSDK)])
continue
}
if (kind === 'eventAsyncString') {
const fields = sdkAsyncStringFields[name]
if (
!value ||
typeof value !== 'object' ||
Array.isArray(value) ||
typeof (value as Record<string, unknown>)[fields.predicate] !==
(fields.selects ? 'string' : 'boolean') ||
typeof (value as Record<string, unknown>)[fields.callback] !== 'function'
)
throw new Error(name + ' must be an async string callback and SDK decision')
sdkModifiers.push([
name,
String((value as Record<string, unknown>)[fields.predicate]),
])
continue
}
if (kind === 'sessionRequest') {
const inputField = sdkSessionRequests[name].inputField
if (
!value ||
typeof value !== 'object' ||
Array.isArray(value) ||
typeof (value as Record<string, unknown>)[inputField] !== 'string' ||
typeof (value as { onResult?: unknown }).onResult !== 'function'
)
throw new Error(name + ' must have source text and an onResult callback')
sdkModifiers.push([name, (value as Record<string, string>)[inputField]])
continue
}
if (kind === 'pickerSelection') {
const picker = value as
| {
isPresented?: { value?: unknown; onChange?: unknown }
title?: unknown
onSelection?: unknown
}
| undefined
if (
!picker ||
typeof picker !== 'object' ||
typeof picker.isPresented?.value !== 'boolean' ||
typeof picker.isPresented.onChange !== 'function' ||
(picker.title !== undefined && typeof picker.title !== 'string') ||
typeof picker.onSelection !== 'function'
)
throw new Error(
name + ' must have a presentation binding and selection callback'
)
sdkModifiers.push([
name,
JSON.stringify([String(picker.isPresented.value), picker.title ?? null]),
])
continue
}
if (kind === 'transferSelection') {
const picker = value as
| {
isPresented?: { value?: unknown; onChange?: unknown }
onSelection?: unknown
onError?: unknown
}
| undefined
if (
!picker ||
typeof picker !== 'object' ||
typeof picker.isPresented?.value !== 'boolean' ||
typeof picker.isPresented.onChange !== 'function' ||
typeof picker.onSelection !== 'function' ||
typeof picker.onError !== 'function'
)
throw new Error(
name +
' must have a presentation binding, selection callback, and error callback'
)
sdkModifiers.push([name, String(picker.isPresented.value)])
continue
}
if (kind === 'eventDrop') {
const record = value as { of?: unknown; onDrop?: unknown } | undefined
if (
!record ||
!Array.isArray(record.of) ||
record.of.length === 0 ||
record.of.some((item) => typeof item !== 'string' || !item) ||
typeof record.onDrop !== 'function'
)
throw new Error(name + ' must have content types and an onDrop callback')
sdkModifiers.push([name, JSON.stringify(record.of)])
continue
}
if (kind === 'eventNotification') {
const record = value as { name?: unknown; onAction?: unknown } | undefined
if (
!record ||
typeof record.name !== 'string' ||
!record.name ||
typeof record.onAction !== 'function'
)
throw new Error(
name + ' must have a notification name and an onAction callback'
)
sdkModifiers.push([name, record.name])
continue
}
if (kind === 'dragSelection') {
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string'))
throw new Error(name + ' must be an array of string IDs')
sdkModifiers.push([name, JSON.stringify(value)])
continue
}
if (kind === 'asyncObjectRequest') {
const record = value as Record<string, unknown> | undefined
const binding = record?.[sdkAsyncObjectRequestBindings[name]] as
| { value?: unknown; onChange?: unknown }
| undefined
if (
!record ||
!binding ||
typeof binding.value !== 'boolean' ||
typeof binding.onChange !== 'function' ||
typeof record.latitude !== 'number' ||
!Number.isFinite(record.latitude) ||
record.latitude < -90 ||
record.latitude > 90 ||
typeof record.longitude !== 'number' ||
!Number.isFinite(record.longitude) ||
record.longitude < -180 ||
record.longitude > 180
)
throw new Error(
name + ' must have a presentation binding and valid coordinates'
)
sdkModifiers.push([
name,
JSON.stringify([
String(binding.value),
String(record.latitude),
String(record.longitude),
]),
])
continue
}
if (kind === 'number' && (typeof value !== 'number' || !Number.isFinite(value)))
throw new Error(name + ' must be finite')
if (
kind === 'optionalNumber' &&
value !== null &&
(typeof value !== 'number' || !Number.isFinite(value))
)
throw new Error(name + ' must be finite or null')
if (
(kind === 'boolean' || kind === 'defaultFocusBoolean') &&
typeof value !== 'boolean'
)
throw new Error(name + ' must be a boolean')
if (kind === 'dragContainer' && typeof value !== 'boolean')
throw new Error(name + ' must be a boolean')
if (kind === 'dragItemID' && typeof value !== 'string')
throw new Error(name + ' must be a string ID')
if (kind === 'optionalBoolean' && value !== null && typeof value !== 'boolean')
throw new Error(name + ' must be a boolean or null')
if (kind === 'string' && typeof value !== 'string')
throw new Error(name + ' must be a string')
if (kind === 'equatableKey' && typeof value !== 'string')
throw new Error(name + ' must be an equality key')
if (kind === 'selectionID' && typeof value !== 'string')
throw new Error(name + ' must be a string')
if (
kind === 'selectionIndex' &&
(typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0)
)
throw new Error(name + ' must be a nonnegative index')
if (kind === 'url' && typeof value !== 'string')
throw new Error(name + ' must be a URL string')
if (kind === 'optionalURL' && value !== null && typeof value !== 'string')
throw new Error(name + ' must be a URL string or null')
if (kind === 'optionalEnum' && value !== null && typeof value !== 'string')
throw new Error(name + ' must be a string or null')
if (kind === 'optionalString' && value !== null && typeof value !== 'string')
throw new Error(name + ' must be a string or null')
if (
kind.startsWith('event') &&
kind !== 'eventValueString' &&
kind !== 'eventReturnArray' &&
kind !== 'eventReturnEnum' &&
typeof value !== 'function'
)
throw new Error(name + ' must be a callback')
if (
kind === 'eventValueString' &&
(typeof value !== 'object' ||
value === null ||
typeof (value as { value?: unknown }).value !== 'string' ||
typeof (value as { onChange?: unknown }).onChange !== 'function')
)
throw new Error(name + ' must be a string value and callback')
if (
kind === 'eventReturnArray' &&
(typeof value !== 'object' ||
value === null ||
!Array.isArray((value as { items?: unknown }).items) ||
!(value as { items: unknown[] }).items.every(
(item) => typeof item === 'string'
) ||
typeof (value as { onAction?: unknown }).onAction !== 'function')
)
throw new Error(name + ' must be a string array and callback')
if (
kind === 'eventReturnEnum' &&
(typeof value !== 'object' ||
value === null ||
typeof (value as { result?: unknown }).result !== 'string' ||
!sdkEventCases[name].includes((value as { result: string }).result) ||
typeof (value as { onAction?: unknown }).onAction !== 'function')
)
throw new Error(name + ' must be an SDK result and callback')
if (
(kind === 'bindingBoolean' ||
kind === 'bindingFocusBoolean' ||
kind === 'bindingString' ||
kind === 'bindingOptionalString' ||
kind === 'bindingCodable') &&
(typeof value !== 'object' ||
value === null ||
typeof (value as { onChange?: unknown }).onChange !== 'function' ||
(kind === 'bindingOptionalString' ||
(kind === 'bindingCodable' && sdkCodableOptional[name])
? (value as { value?: unknown }).value !== null &&
typeof (value as { value?: unknown }).value !== 'string'
: typeof (value as { value?: unknown }).value !==
(kind === 'bindingBoolean' || kind === 'bindingFocusBoolean'
? 'boolean'
: 'string')))
)
throw new Error(name + ' must be a binding')
if (kind === 'bindingCodable' && (value as { value: string | null }).value !== null)
JSON.parse((value as { value: string }).value)
if (
kind === 'bindingPoint' &&
(typeof value !== 'object' ||
value === null ||
typeof (value as { onChange?: unknown }).onChange !== 'function' ||
((value as { value?: unknown }).value !== null &&
!validSDKEventValue((value as { value?: unknown }).value, { kind: 'point' })))
)
throw new Error(name + ' must be a point binding')
sdkModifiers.push([
name,
kind === 'eventValueString'
? (value as { value: string }).value
: kind === 'eventReturnArray'
? JSON.stringify((value as { items: string[] }).items)
: kind === 'eventReturnEnum'
? (value as { result: string }).result
: kind.startsWith('event')
? ''
: kind === 'bindingOptionalString' || kind === 'bindingPoint'
? JSON.stringify((value as { value: unknown }).value)
: kind === 'bindingCodable' &&
(value as { value: string | null }).value === null
? 'null'
: kind.startsWith('binding')
? String((value as { value: unknown }).value)
: kind === 'optionalString' || kind === 'optionalURL'
? (JSON.stringify(value) as string)
: String(value),
])
} else if (colorFields.includes(name as (typeof colorFields)[number])) {
native[name] = processColor(value as ColorValue) ?? undefined
} else {
native[name] = value
}
}
if (sdkModifiers.length) native.sdkModifiers = JSON.stringify(sdkModifiers)
return native as OneNativeStyleNative
}
export function dispatchSDKEvent(
style: OneNativeStyle | undefined,
name: string,
value: string
): void {
const separator = name.indexOf('.')
if (separator !== -1) {
const parent = name.slice(0, separator)
const field = name.slice(separator + 1)
if (sdkKinds[parent as keyof typeof sdkKinds] === 'pickerSelection') {
const picker = (style as Record<string, unknown> | undefined)?.[parent] as
| {
isPresented: { onChange: (value: boolean) => void }
onSelection: (id: string) => void
}
| undefined
if (field === 'isPresented') {
if (value !== 'true' && value !== 'false')
throw new Error(name + ' emitted an invalid boolean')
picker?.isPresented.onChange(value === 'true')
} else if (field === 'onSelection') picker?.onSelection(value)
else throw new Error(name + ' emitted an invalid picker event')
return
}
if (sdkKinds[parent as keyof typeof sdkKinds] === 'transferSelection') {
const picker = (style as Record<string, unknown> | undefined)?.[parent] as
| {
isPresented: { onChange: (value: boolean) => void }
onSelection: (url: string) => void
onError: (message: string) => void
onItemIdentifier?: (id: string) => void
}
| undefined
if (field === 'isPresented') {
if (value !== 'true' && value !== 'false')
throw new Error(name + ' emitted an invalid boolean')
picker?.isPresented.onChange(value === 'true')
} else if (field === 'onSelection') picker?.onSelection(value)
else if (field === 'onError') picker?.onError(value)
else if (field === 'onItemIdentifier') picker?.onItemIdentifier?.(value)
else throw new Error(name + ' emitted an invalid transfer event')
return
}
if (
sdkRecords[parent]?.some(
(argument) => argument.field === field && argument.kind === 'bindingBoolean'
)
) {
if (value !== 'true' && value !== 'false')
throw new Error(name + ' emitted an invalid boolean')
const record = (style as Record<string, unknown> | undefined)?.[parent] as
| Record<string, unknown>
| undefined
;(record?.[field] as { onChange: (value: boolean) => void } | undefined)?.onChange(
value === 'true'
)
return
}
if (
sdkRecords[parent]?.some(
(argument) => argument.field === field && argument.kind === 'bindingOptionalURL'
)
) {
const decoded: unknown = JSON.parse(value)
if (decoded !== null && typeof decoded !== 'string')
throw new Error(name + ' emitted an invalid URL')
const record = (style as Record<string, unknown> | undefined)?.[parent] as
| Record<string, unknown>
| undefined
;(
record?.[field] as { onChange: (value: string | null) => void } | undefined
)?.onChange(decoded)
return
}
const result = sdkRecords[parent]?.find(
(argument) =>
argument.field === field &&
(argument.kind === 'resultURL' || argument.kind === 'resultURLArray')
)
if (result) {
const decoded: unknown = JSON.parse(value)
if (!decoded || typeof decoded !== 'object' || Array.isArray(decoded))
throw new Error(name + ' emitted an invalid result')
const payload = decoded as Record<string, unknown>
const success = payload.success
const failure = payload.failure
const validSuccess =
result.kind === 'resultURL'
? typeof success === 'string'
: Array.isArray(success) && success.every((item) => typeof item === 'string')
if (
!(
(validSuccess && failure === undefined) ||
(success === undefined && typeof failure === 'string')
) ||
Object.keys(payload).length !== 1
)
throw new Error(name + ' emitted an invalid result')
const record = (style as Record<string, unknown> | undefined)?.[parent] as
| Record<string, unknown>
| undefined
;(record?.[field] as ((result: unknown) => void) | undefined)?.(payload)
return
}
const event = sdkRecords[parent]?.find(
(argument) => argument.field === field && argument.kind === 'eventStruct'
)
if (event) {
const payload: unknown = JSON.parse(value)
if (!validSDKEventValue(payload, event.eventValue!))
throw new Error(name + ' emitted an invalid struct value')
const record = (style as Record<string, unknown> | undefined)?.[parent] as
| Record<string, unknown>
| undefined
;(record?.[field] as ((value: unknown) => void) | undefined)?.(payload)
return
}
}
const modifier = (style as Record<string, unknown> | undefined)?.[name]
const kind = sdkKinds[name as keyof typeof sdkKinds] as string | undefined
if (kind === 'gesture') {
const config = modifier as
| { kind: string; onEnded: (value?: unknown) => void }
| undefined
const shape = config && sdkGestureOptions[name]?.[config.kind]
if (shape === undefined) throw new Error(name + ' emitted an invalid gesture')
if (shape === null) {
if (value !== '') throw new Error(name + ' emitted an invalid gesture event')
config?.onEnded()
} else {
const payload: unknown = JSON.parse(value)
if (!validSDKEventValue(payload, shape))
throw new Error(name + ' emitted an invalid gesture event')
config?.onEnded(payload)
}
} else if (kind === 'event') (modifier as (() => void) | undefined)?.()
else if (kind === 'eventAsync') {
const native = NativeModules.OneNativeAsyncActionModule as
| { complete(identifier: string): void }
| undefined
if (!native) throw new Error('OneNativeAsyncActionModule is unavailable')
void Promise.resolve()
.then(() => (modifier as (() => void | Promise<void>) | undefined)?.())
.finally(() => native.complete(value))
} else if (kind === 'eventAsyncStruct') {
const native = NativeModules.OneNativeAsyncActionModule as
| { complete(identifier: string): void }
| undefined
if (!native) throw new Error('OneNativeAsyncActionModule is unavailable')
const envelope: unknown = JSON.parse(value)
if (
!envelope ||
typeof envelope !== 'object' ||
typeof (envelope as { id?: unknown }).id !== 'string' ||
typeof (envelope as { value?: unknown }).value !== 'string'
)
throw new Error(name + ' emitted an invalid async event')
const identifier = (envelope as { id: string }).id
const payload: unknown = JSON.parse((envelope as { value: string }).value)
if (!validSDKEventValue(payload, sdkEventStructs[name]))
throw new Error(name + ' emitted an invalid async value')
const action =
typeof modifier === 'function'
? modifier
: (
modifier as
| { onAction?: (value: unknown) => void | Promise<void> }
| undefined
)?.onAction
void Promise.resolve()
.then(() => action?.(payload))
.finally(() => native.complete(identifier))
} else if (kind === 'eventAsyncString') {
const native = NativeModules.OneNativeAsyncActionModule as
| {
completeString(
identifier: string,
value: string | null,
error: string | null
): void
}
| undefined
if (!native) throw new Error('OneNativeAsyncActionModule is unavailable')
const envelope: unknown = JSON.parse(value)
if (
!envelope ||
typeof envelope !== 'object' ||
typeof (envelope as { id?: unknown }).id !== 'string' ||
typeof (envelope as { value?: unknown }).value !== 'string'
)
throw new Error(name + ' emitted an invalid async string event')
const identifier = (envelope as { id: string }).id
try {
const payload: unknown = JSON.parse((envelope as { value: string }).value)
if (!validSDKEventValue(payload, sdkEventStructs[name]))
throw new Error(name + ' emitted an invalid async string value')
const action = (modifier as Record<string, unknown> | undefined)?.[
sdkAsyncStringFields[name].callback
] as ((value: unknown) => string | Promise<string>) | undefined
void Promise.resolve()
.then(() => action?.(payload))
.then((result) => {
if (typeof result !== 'string') throw new Error(name + ' must return a string')
native.completeString(identifier, result, null)
})
.catch((error) => native.completeString(identifier, null, String(error)))
} catch (error) {
native.completeString(identifier, null, String(error))
throw error
}
} else if (kind === 'sessionRequest') {
const payload: unknown = JSON.parse(value)
if (!payload || typeof payload !== 'object' || Array.isArray(payload))
throw new Error(name + ' emitted an invalid session response')
const result = payload as Record<string, unknown>
const fields = sdkSessionRequests[name].outputFields
const success =
result.error === null && fields.every((field) => typeof result[field] === 'string')
const failure =
typeof result.error === 'string' && fields.every((field) => result[field] === null)
if (!success && !failure)
throw new Error(name + ' emitted an invalid session response')
;(modifier as { onResult: (value: unknown) => void } | undefined)?.onResult(result)
} else if (kind === 'eventReturnArray')
(modifier as { onAction: () => void } | undefined)?.onAction()
else if (kind === 'eventReturnEnum') {
const payload: unknown = JSON.parse(value)
if (!validSDKEventValue(payload, sdkEventStructs[name]))
throw new Error(name + ' emitted an invalid result event')
;(modifier as { onAction: (value: unknown) => void } | undefined)?.onAction(payload)
} else if (kind === 'eventBoolean') {
if (value !== 'true' && value !== 'false')
throw new Error(name + ' emitted an invalid boolean')
;(modifier as ((value: boolean) => void) | undefined)?.(value === 'true')
} else if (kind === 'eventNumber') {
const number = Number(value)
if (!Number.isFinite(number)) throw new Error(name + ' emitted an invalid number')
;(modifier as ((value: number) => void) | undefined)?.(number)
} else if (kind === 'eventString')
(modifier as ((value: string) => void) | undefined)?.(value)
else if (kind === 'eventEnum') {
if (!sdkEventCases[name].includes(value))
throw new Error(name + ' emitted an invalid enum value')
;(modifier as ((value: string) => void) | undefined)?.(value)
} else if (kind === 'eventEnumPair') {
const pair: unknown = JSON.parse(value)
if (
!Array.isArray(pair) ||
pair.length !== 2 ||
pair.some((item) => typeof item !== 'string' || !sdkEventCases[name].includes(item))
)
throw new Error(name + ' emitted invalid enum values')
;(modifier as ((oldValue: string, newValue: string) => void) | undefined)?.(
pair[0],
pair[1]
)
} else if (kind === 'eventAssociatedEnum') {
const payload: unknown = JSON.parse(value)
if (!payload || typeof payload !== 'object')
throw new Error(name + ' emitted an invalid enum payload')
const event = payload as { case?: unknown; values?: unknown }
const kinds =
typeof event.case === 'string' ? sdkAssociatedCases[name]?.[event.case] : undefined
if (!kinds || !Array.isArray(event.values) || event.values.length !== kinds.length)
throw new Error(name + ' emitted an invalid enum case')
for (const [index, item] of event.values.entries()) {
if (!validSDKEventValue(item, kinds[index]))
throw new Error(name + ' emitted an invalid ' + kinds[index].kind)
}
;(modifier as ((value: unknown) => void) | undefined)?.(event)
} else if (kind === 'eventStruct') {
const payload: unknown = JSON.parse(value)
if (!validSDKEventValue(payload, sdkEventStructs[name]))
throw new Error(name + ' emitted an invalid struct value')
;(modifier as ((value: unknown) => void) | undefined)?.(payload)
} else if (kind === 'eventDrop') {
const payload: unknown = JSON.parse(value)
if (!validSDKEventValue(payload, sdkEventStructs[name]))
throw new Error(name + ' emitted an invalid drop value')
;(modifier as { onDrop: (value: unknown) => void } | undefined)?.onDrop(payload)
} else if (kind === 'eventNotification') {
if (value !== '') throw new Error(name + ' emitted an invalid notification event')
;(modifier as { onAction: () => void } | undefined)?.onAction()
} else if (kind === 'asyncObjectRequest') {
if (value !== 'true' && value !== 'false')
throw new Error(name + ' emitted an invalid presentation value')
const binding = (modifier as Record<string, unknown> | undefined)?.[
sdkAsyncObjectRequestBindings[name]
] as { onChange: (value: boolean) => void } | undefined
binding?.onChange(value === 'true')
} else if (kind === 'bindingBoolean' || kind === 'bindingFocusBoolean') {
if (value !== 'true' && value !== 'false')
throw new Error(name + ' emitted an invalid boolean')
;(modifier as { onChange: (value: boolean) => void } | undefined)?.onChange(
value === 'true'
)
} else if (kind === 'bindingString' || kind === 'bindingCodable')
(modifier as { onChange: (value: string) => void } | undefined)?.onChange(value)
else if (kind === 'bindingOptionalString') {
const decoded: unknown = JSON.parse(value)
if (decoded !== null && typeof decoded !== 'string')
throw new Error(name + ' emitted an invalid optional string')
;(modifier as { onChange: (value: string | null) => void } | undefined)?.onChange(
decoded
)
} else if (kind === 'bindingPoint') {
const decoded: unknown = JSON.parse(value)
if (decoded !== null && !validSDKEventValue(decoded, { kind: 'point' }))
throw new Error(name + ' emitted an invalid point')
;(
modifier as
| { onChange: (value: { x: number; y: number } | null) => void }
| undefined
)?.onChange(decoded as { x: number; y: number } | null)
} else if (kind === 'bindingTextSelection') {
const binding = modifier as
| { text: string; onChange: (value: OneNativeTextRanges) => void }
| undefined
if (!binding) return
const decoded: unknown = JSON.parse(value)
if (!validTextRanges(decoded, binding.text))
throw new Error(name + ' emitted invalid UTF-16 ranges')
binding.onChange(decoded)
} else if (kind === 'eventValueString')
(modifier as { onChange: (value: string) => void } | undefined)?.onChange(value)
}