@userflow-tech/react-native 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -68
- package/app.plugin.js +13 -0
- package/babel-plugin/index.d.ts +43 -0
- package/babel-plugin/index.d.ts.map +1 -0
- package/babel-plugin/index.js +862 -0
- package/babel-plugin/index.js.map +1 -0
- package/babel-plugin.js +13 -0
- package/docs/anchoring.md +141 -13
- package/docs/deep-linking.md +20 -17
- package/docs/theme-mapping.md +44 -15
- package/docs/troubleshooting.md +37 -30
- package/expo-plugin/withUserflow.d.ts +17 -0
- package/expo-plugin/withUserflow.d.ts.map +1 -0
- package/expo-plugin/withUserflow.js +99 -0
- package/expo-plugin/withUserflow.js.map +1 -0
- package/lib/commonjs/anchors/AutoAnchorRegistry.js +125 -3
- package/lib/commonjs/anchors/AutoAnchorRegistry.js.map +1 -1
- package/lib/commonjs/anchors/anchorChangeTicker.js +10 -0
- package/lib/commonjs/anchors/anchorChangeTicker.js.map +1 -1
- package/lib/commonjs/anchors/autoAnchor.js +1 -1
- package/lib/commonjs/anchors/elementConditionEvaluator.js +25 -12
- package/lib/commonjs/anchors/elementConditionEvaluator.js.map +1 -1
- package/lib/commonjs/anchors/fiber/FiberScanRoot.js +11 -47
- package/lib/commonjs/anchors/fiber/FiberScanRoot.js.map +1 -1
- package/lib/commonjs/anchors/fiber/FiberScanRootStore.js +50 -0
- package/lib/commonjs/anchors/fiber/FiberScanRootStore.js.map +1 -0
- package/lib/commonjs/anchors/fiber/fiberInternals.js +145 -3
- package/lib/commonjs/anchors/fiber/fiberInternals.js.map +1 -1
- package/lib/commonjs/anchors/fiber/indexHostFibers.js +129 -0
- package/lib/commonjs/anchors/fiber/indexHostFibers.js.map +1 -0
- package/lib/commonjs/anchors/fiber/readHostContent.js +131 -0
- package/lib/commonjs/anchors/fiber/readHostContent.js.map +1 -0
- package/lib/commonjs/anchors/fiberAnchorCache.js +50 -0
- package/lib/commonjs/anchors/fiberAnchorCache.js.map +1 -0
- package/lib/commonjs/anchors/hintsCodec.js +1 -1
- package/lib/commonjs/anchors/resolveAnchorHost.js +15 -21
- package/lib/commonjs/anchors/resolveAnchorHost.js.map +1 -1
- package/lib/commonjs/anchors/resolveAutoAnchorHost.js +171 -0
- package/lib/commonjs/anchors/resolveAutoAnchorHost.js.map +1 -0
- package/lib/commonjs/anchors/semanticMatcher.js +285 -0
- package/lib/commonjs/anchors/semanticMatcher.js.map +1 -0
- package/lib/commonjs/authoring/ElementPickerOverlay.js +490 -0
- package/lib/commonjs/authoring/ElementPickerOverlay.js.map +1 -0
- package/lib/commonjs/authoring/capturePickerScreenshot.js +73 -0
- package/lib/commonjs/authoring/capturePickerScreenshot.js.map +1 -0
- package/lib/commonjs/authoring/chrome/ChromeBarTransition.js +94 -0
- package/lib/commonjs/authoring/chrome/ChromeBarTransition.js.map +1 -0
- package/lib/commonjs/authoring/chrome/ChromeBottomSheet.js +64 -0
- package/lib/commonjs/authoring/chrome/ChromeBottomSheet.js.map +1 -0
- package/lib/commonjs/authoring/chrome/ChromeButton.js +94 -0
- package/lib/commonjs/authoring/chrome/ChromeButton.js.map +1 -0
- package/lib/commonjs/authoring/chrome/ChromeDialog.js +131 -0
- package/lib/commonjs/authoring/chrome/ChromeDialog.js.map +1 -0
- package/lib/commonjs/authoring/chrome/ChromeIcon.js +39 -0
- package/lib/commonjs/authoring/chrome/ChromeIcon.js.map +1 -0
- package/lib/commonjs/authoring/chrome/ChromeTooltip.js +88 -0
- package/lib/commonjs/authoring/chrome/ChromeTooltip.js.map +1 -0
- package/lib/commonjs/authoring/chrome/ChromeTopBar.js +110 -0
- package/lib/commonjs/authoring/chrome/ChromeTopBar.js.map +1 -0
- package/lib/commonjs/authoring/chrome/DoubleTapBridge.js +57 -0
- package/lib/commonjs/authoring/chrome/DoubleTapBridge.js.map +1 -0
- package/lib/commonjs/authoring/chrome/doubleTapMonitor.js +80 -0
- package/lib/commonjs/authoring/chrome/doubleTapMonitor.js.map +1 -0
- package/lib/commonjs/authoring/chrome/icons/arrow-left-from-bracket.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/arrow-left-from-bracket@2x.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/arrow-left-from-bracket@3x.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/arrow-rotate-left.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/arrow-rotate-left@2x.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/arrow-rotate-left@3x.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/userflow-logomark.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/userflow-logomark@2x.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/userflow-logomark@3x.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/xmark.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/xmark@2x.png +0 -0
- package/lib/commonjs/authoring/chrome/icons/xmark@3x.png +0 -0
- package/lib/commonjs/authoring/chrome/tokens.js +150 -0
- package/lib/commonjs/authoring/chrome/tokens.js.map +1 -0
- package/lib/commonjs/authoring/doubleTap.js +23 -0
- package/lib/commonjs/authoring/doubleTap.js.map +1 -0
- package/lib/commonjs/authoring/elementPickerController.js +102 -0
- package/lib/commonjs/authoring/elementPickerController.js.map +1 -0
- package/lib/commonjs/authoring/fingerprintFromInstance.js +195 -0
- package/lib/commonjs/authoring/fingerprintFromInstance.js.map +1 -0
- package/lib/commonjs/authoring/hitTest.js +106 -0
- package/lib/commonjs/authoring/hitTest.js.map +1 -0
- package/lib/commonjs/content/RichContentRenderer.js +12 -2
- package/lib/commonjs/content/RichContentRenderer.js.map +1 -1
- package/lib/commonjs/content/StepButton.js +19 -4
- package/lib/commonjs/content/StepButton.js.map +1 -1
- package/lib/commonjs/content/resolveStepButtonChrome.js +8 -6
- package/lib/commonjs/content/resolveStepButtonChrome.js.map +1 -1
- package/lib/commonjs/content/themeColor.js +11 -0
- package/lib/commonjs/content/themeColor.js.map +1 -1
- package/lib/commonjs/deviceContext.js +158 -0
- package/lib/commonjs/deviceContext.js.map +1 -0
- package/lib/commonjs/expo-router/useUserflowExpoRouter.js +40 -4
- package/lib/commonjs/expo-router/useUserflowExpoRouter.js.map +1 -1
- package/lib/commonjs/hostAppVersion.js +242 -0
- package/lib/commonjs/hostAppVersion.js.map +1 -0
- package/lib/commonjs/index.js +118 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/lifecycle.js +2 -0
- package/lib/commonjs/lifecycle.js.map +1 -1
- package/lib/commonjs/navigation/WithUserflowReactNavigation.js +17 -8
- package/lib/commonjs/navigation/WithUserflowReactNavigation.js.map +1 -1
- package/lib/commonjs/navigation/isOverlayPresentation.js +64 -0
- package/lib/commonjs/navigation/isOverlayPresentation.js.map +1 -0
- package/lib/commonjs/pairing/PairingController.js +29 -2
- package/lib/commonjs/pairing/PairingController.js.map +1 -1
- package/lib/commonjs/pairing/PreviewModeBanner.js +211 -84
- package/lib/commonjs/pairing/PreviewModeBanner.js.map +1 -1
- package/lib/commonjs/pairing/diagnostics.js +11 -2
- package/lib/commonjs/pairing/diagnostics.js.map +1 -1
- package/lib/commonjs/pairing/elementPickerRelay.js +91 -0
- package/lib/commonjs/pairing/elementPickerRelay.js.map +1 -0
- package/lib/commonjs/pairing/resolvePreviewChrome.js +52 -0
- package/lib/commonjs/pairing/resolvePreviewChrome.js.map +1 -0
- package/lib/commonjs/pairing/tokenStorage.js +25 -2
- package/lib/commonjs/pairing/tokenStorage.js.map +1 -1
- package/lib/commonjs/pairing/usePairingState.js +3 -1
- package/lib/commonjs/pairing/usePairingState.js.map +1 -1
- package/lib/commonjs/runtime/FlowRenderer.js +45 -21
- package/lib/commonjs/runtime/FlowRenderer.js.map +1 -1
- package/lib/commonjs/runtime/FlowSurfaceFade.js +47 -24
- package/lib/commonjs/runtime/FlowSurfaceFade.js.map +1 -1
- package/lib/commonjs/runtime/TargetPressBridge.js +13 -44
- package/lib/commonjs/runtime/TargetPressBridge.js.map +1 -1
- package/lib/commonjs/runtime/UserflowProvider.js +74 -20
- package/lib/commonjs/runtime/UserflowProvider.js.map +1 -1
- package/lib/commonjs/runtime/changedTouchPoints.js +48 -0
- package/lib/commonjs/runtime/changedTouchPoints.js.map +1 -0
- package/lib/commonjs/runtime/flowEngine.js +3 -1
- package/lib/commonjs/runtime/flowEngine.js.map +1 -1
- package/lib/commonjs/runtime/flowSessionViewState.js +32 -7
- package/lib/commonjs/runtime/flowSessionViewState.js.map +1 -1
- package/lib/commonjs/runtime/useFlowSessionState.js +2 -1
- package/lib/commonjs/runtime/useFlowSessionState.js.map +1 -1
- package/lib/commonjs/screenTracker.js +46 -4
- package/lib/commonjs/screenTracker.js.map +1 -1
- package/lib/commonjs/surfaces/CardFade.js +31 -0
- package/lib/commonjs/surfaces/CardFade.js.map +1 -0
- package/lib/commonjs/surfaces/CloseButton.js +11 -6
- package/lib/commonjs/surfaces/CloseButton.js.map +1 -1
- package/lib/commonjs/surfaces/ModalSurface.js +50 -34
- package/lib/commonjs/surfaces/ModalSurface.js.map +1 -1
- package/lib/commonjs/surfaces/TooltipSurface.js +366 -87
- package/lib/commonjs/surfaces/TooltipSurface.js.map +1 -1
- package/lib/commonjs/surfaces/cardTransition.js +70 -0
- package/lib/commonjs/surfaces/cardTransition.js.map +1 -0
- package/lib/commonjs/surfaces/resolveHighlightChrome.js +109 -0
- package/lib/commonjs/surfaces/resolveHighlightChrome.js.map +1 -0
- package/lib/commonjs/surfaces/resolveModalLayout.js +7 -3
- package/lib/commonjs/surfaces/resolveModalLayout.js.map +1 -1
- package/lib/commonjs/surfaces/resolveTooltipLayout.js +0 -4
- package/lib/commonjs/surfaces/resolveTooltipLayout.js.map +1 -1
- package/lib/commonjs/surfaces/surfaceInteractionConfig.js +33 -0
- package/lib/commonjs/surfaces/surfaceInteractionConfig.js.map +1 -0
- package/lib/commonjs/surfaces/surfaceLayoutInsets.js +128 -0
- package/lib/commonjs/surfaces/surfaceLayoutInsets.js.map +1 -0
- package/lib/commonjs/surfaces/themeChrome.js +4 -1
- package/lib/commonjs/surfaces/themeChrome.js.map +1 -1
- package/lib/commonjs/surfaces/tooltip/TooltipBubble.js +142 -21
- package/lib/commonjs/surfaces/tooltip/TooltipBubble.js.map +1 -1
- package/lib/commonjs/surfaces/tooltip/TooltipCutout.js +100 -47
- package/lib/commonjs/surfaces/tooltip/TooltipCutout.js.map +1 -1
- package/lib/commonjs/surfaces/tooltip/TooltipHighlight.js +124 -0
- package/lib/commonjs/surfaces/tooltip/TooltipHighlight.js.map +1 -0
- package/lib/commonjs/surfaces/tooltip/computeTooltipPosition.js +67 -13
- package/lib/commonjs/surfaces/tooltip/computeTooltipPosition.js.map +1 -1
- package/lib/commonjs/surfaces/tooltip/inferTooltipPlacement.js +88 -19
- package/lib/commonjs/surfaces/tooltip/inferTooltipPlacement.js.map +1 -1
- package/lib/commonjs/surfaces/tooltip/placementDiagnostics.js +52 -0
- package/lib/commonjs/surfaces/tooltip/placementDiagnostics.js.map +1 -0
- package/lib/commonjs/surfaces/tooltip/rect.js +12 -0
- package/lib/commonjs/surfaces/tooltip/rect.js.map +1 -1
- package/lib/commonjs/surfaces/tooltip/resolveSideCardWidth.js +103 -0
- package/lib/commonjs/surfaces/tooltip/resolveSideCardWidth.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/anchors/AutoAnchorRegistry.js +126 -3
- package/lib/module/anchors/AutoAnchorRegistry.js.map +1 -1
- package/lib/module/anchors/anchorChangeTicker.js +10 -0
- package/lib/module/anchors/anchorChangeTicker.js.map +1 -1
- package/lib/module/anchors/autoAnchor.js +1 -1
- package/lib/module/anchors/elementConditionEvaluator.js +25 -12
- package/lib/module/anchors/elementConditionEvaluator.js.map +1 -1
- package/lib/module/anchors/fiber/FiberScanRoot.js +2 -43
- package/lib/module/anchors/fiber/FiberScanRoot.js.map +1 -1
- package/lib/module/anchors/fiber/FiberScanRootStore.js +46 -0
- package/lib/module/anchors/fiber/FiberScanRootStore.js.map +1 -0
- package/lib/module/anchors/fiber/fiberInternals.js +139 -3
- package/lib/module/anchors/fiber/fiberInternals.js.map +1 -1
- package/lib/module/anchors/fiber/indexHostFibers.js +122 -0
- package/lib/module/anchors/fiber/indexHostFibers.js.map +1 -0
- package/lib/module/anchors/fiber/readHostContent.js +127 -0
- package/lib/module/anchors/fiber/readHostContent.js.map +1 -0
- package/lib/module/anchors/fiberAnchorCache.js +40 -0
- package/lib/module/anchors/fiberAnchorCache.js.map +1 -0
- package/lib/module/anchors/hintsCodec.js +1 -1
- package/lib/module/anchors/resolveAnchorHost.js +15 -21
- package/lib/module/anchors/resolveAnchorHost.js.map +1 -1
- package/lib/module/anchors/resolveAutoAnchorHost.js +167 -0
- package/lib/module/anchors/resolveAutoAnchorHost.js.map +1 -0
- package/lib/module/anchors/semanticMatcher.js +280 -0
- package/lib/module/anchors/semanticMatcher.js.map +1 -0
- package/lib/module/authoring/ElementPickerOverlay.js +485 -0
- package/lib/module/authoring/ElementPickerOverlay.js.map +1 -0
- package/lib/module/authoring/capturePickerScreenshot.js +68 -0
- package/lib/module/authoring/capturePickerScreenshot.js.map +1 -0
- package/lib/module/authoring/chrome/ChromeBarTransition.js +88 -0
- package/lib/module/authoring/chrome/ChromeBarTransition.js.map +1 -0
- package/lib/module/authoring/chrome/ChromeBottomSheet.js +59 -0
- package/lib/module/authoring/chrome/ChromeBottomSheet.js.map +1 -0
- package/lib/module/authoring/chrome/ChromeButton.js +89 -0
- package/lib/module/authoring/chrome/ChromeButton.js.map +1 -0
- package/lib/module/authoring/chrome/ChromeDialog.js +126 -0
- package/lib/module/authoring/chrome/ChromeDialog.js.map +1 -0
- package/lib/module/authoring/chrome/ChromeIcon.js +33 -0
- package/lib/module/authoring/chrome/ChromeIcon.js.map +1 -0
- package/lib/module/authoring/chrome/ChromeTooltip.js +82 -0
- package/lib/module/authoring/chrome/ChromeTooltip.js.map +1 -0
- package/lib/module/authoring/chrome/ChromeTopBar.js +104 -0
- package/lib/module/authoring/chrome/ChromeTopBar.js.map +1 -0
- package/lib/module/authoring/chrome/DoubleTapBridge.js +52 -0
- package/lib/module/authoring/chrome/DoubleTapBridge.js.map +1 -0
- package/lib/module/authoring/chrome/doubleTapMonitor.js +75 -0
- package/lib/module/authoring/chrome/doubleTapMonitor.js.map +1 -0
- package/lib/module/authoring/chrome/icons/arrow-left-from-bracket.png +0 -0
- package/lib/module/authoring/chrome/icons/arrow-left-from-bracket@2x.png +0 -0
- package/lib/module/authoring/chrome/icons/arrow-left-from-bracket@3x.png +0 -0
- package/lib/module/authoring/chrome/icons/arrow-rotate-left.png +0 -0
- package/lib/module/authoring/chrome/icons/arrow-rotate-left@2x.png +0 -0
- package/lib/module/authoring/chrome/icons/arrow-rotate-left@3x.png +0 -0
- package/lib/module/authoring/chrome/icons/userflow-logomark.png +0 -0
- package/lib/module/authoring/chrome/icons/userflow-logomark@2x.png +0 -0
- package/lib/module/authoring/chrome/icons/userflow-logomark@3x.png +0 -0
- package/lib/module/authoring/chrome/icons/xmark.png +0 -0
- package/lib/module/authoring/chrome/icons/xmark@2x.png +0 -0
- package/lib/module/authoring/chrome/icons/xmark@3x.png +0 -0
- package/lib/module/authoring/chrome/tokens.js +146 -0
- package/lib/module/authoring/chrome/tokens.js.map +1 -0
- package/lib/module/authoring/doubleTap.js +18 -0
- package/lib/module/authoring/doubleTap.js.map +1 -0
- package/lib/module/authoring/elementPickerController.js +97 -0
- package/lib/module/authoring/elementPickerController.js.map +1 -0
- package/lib/module/authoring/fingerprintFromInstance.js +187 -0
- package/lib/module/authoring/fingerprintFromInstance.js.map +1 -0
- package/lib/module/authoring/hitTest.js +100 -0
- package/lib/module/authoring/hitTest.js.map +1 -0
- package/lib/module/content/RichContentRenderer.js +12 -2
- package/lib/module/content/RichContentRenderer.js.map +1 -1
- package/lib/module/content/StepButton.js +19 -4
- package/lib/module/content/StepButton.js.map +1 -1
- package/lib/module/content/resolveStepButtonChrome.js +8 -6
- package/lib/module/content/resolveStepButtonChrome.js.map +1 -1
- package/lib/module/content/themeColor.js +10 -0
- package/lib/module/content/themeColor.js.map +1 -1
- package/lib/module/deviceContext.js +142 -0
- package/lib/module/deviceContext.js.map +1 -0
- package/lib/module/expo-router/useUserflowExpoRouter.js +42 -6
- package/lib/module/expo-router/useUserflowExpoRouter.js.map +1 -1
- package/lib/module/hostAppVersion.js +225 -0
- package/lib/module/hostAppVersion.js.map +1 -0
- package/lib/module/index.js +119 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/lifecycle.js +2 -0
- package/lib/module/lifecycle.js.map +1 -1
- package/lib/module/navigation/WithUserflowReactNavigation.js +18 -9
- package/lib/module/navigation/WithUserflowReactNavigation.js.map +1 -1
- package/lib/module/navigation/isOverlayPresentation.js +58 -0
- package/lib/module/navigation/isOverlayPresentation.js.map +1 -0
- package/lib/module/pairing/PairingController.js +30 -3
- package/lib/module/pairing/PairingController.js.map +1 -1
- package/lib/module/pairing/PreviewModeBanner.js +212 -85
- package/lib/module/pairing/PreviewModeBanner.js.map +1 -1
- package/lib/module/pairing/diagnostics.js +10 -2
- package/lib/module/pairing/diagnostics.js.map +1 -1
- package/lib/module/pairing/elementPickerRelay.js +87 -0
- package/lib/module/pairing/elementPickerRelay.js.map +1 -0
- package/lib/module/pairing/resolvePreviewChrome.js +48 -0
- package/lib/module/pairing/resolvePreviewChrome.js.map +1 -0
- package/lib/module/pairing/tokenStorage.js +24 -2
- package/lib/module/pairing/tokenStorage.js.map +1 -1
- package/lib/module/pairing/usePairingState.js +3 -1
- package/lib/module/pairing/usePairingState.js.map +1 -1
- package/lib/module/runtime/FlowRenderer.js +45 -21
- package/lib/module/runtime/FlowRenderer.js.map +1 -1
- package/lib/module/runtime/FlowSurfaceFade.js +49 -26
- package/lib/module/runtime/FlowSurfaceFade.js.map +1 -1
- package/lib/module/runtime/TargetPressBridge.js +12 -43
- package/lib/module/runtime/TargetPressBridge.js.map +1 -1
- package/lib/module/runtime/UserflowProvider.js +74 -20
- package/lib/module/runtime/UserflowProvider.js.map +1 -1
- package/lib/module/runtime/changedTouchPoints.js +43 -0
- package/lib/module/runtime/changedTouchPoints.js.map +1 -0
- package/lib/module/runtime/flowEngine.js +3 -1
- package/lib/module/runtime/flowEngine.js.map +1 -1
- package/lib/module/runtime/flowSessionViewState.js +32 -7
- package/lib/module/runtime/flowSessionViewState.js.map +1 -1
- package/lib/module/runtime/useFlowSessionState.js +2 -1
- package/lib/module/runtime/useFlowSessionState.js.map +1 -1
- package/lib/module/screenTracker.js +42 -4
- package/lib/module/screenTracker.js.map +1 -1
- package/lib/module/surfaces/CardFade.js +26 -0
- package/lib/module/surfaces/CardFade.js.map +1 -0
- package/lib/module/surfaces/CloseButton.js +10 -6
- package/lib/module/surfaces/CloseButton.js.map +1 -1
- package/lib/module/surfaces/ModalSurface.js +52 -36
- package/lib/module/surfaces/ModalSurface.js.map +1 -1
- package/lib/module/surfaces/TooltipSurface.js +368 -90
- package/lib/module/surfaces/TooltipSurface.js.map +1 -1
- package/lib/module/surfaces/cardTransition.js +64 -0
- package/lib/module/surfaces/cardTransition.js.map +1 -0
- package/lib/module/surfaces/resolveHighlightChrome.js +102 -0
- package/lib/module/surfaces/resolveHighlightChrome.js.map +1 -0
- package/lib/module/surfaces/resolveModalLayout.js +7 -3
- package/lib/module/surfaces/resolveModalLayout.js.map +1 -1
- package/lib/module/surfaces/resolveTooltipLayout.js +1 -4
- package/lib/module/surfaces/resolveTooltipLayout.js.map +1 -1
- package/lib/module/surfaces/surfaceInteractionConfig.js +27 -0
- package/lib/module/surfaces/surfaceInteractionConfig.js.map +1 -0
- package/lib/module/surfaces/surfaceLayoutInsets.js +119 -0
- package/lib/module/surfaces/surfaceLayoutInsets.js.map +1 -0
- package/lib/module/surfaces/themeChrome.js +3 -1
- package/lib/module/surfaces/themeChrome.js.map +1 -1
- package/lib/module/surfaces/tooltip/TooltipBubble.js +143 -22
- package/lib/module/surfaces/tooltip/TooltipBubble.js.map +1 -1
- package/lib/module/surfaces/tooltip/TooltipCutout.js +100 -47
- package/lib/module/surfaces/tooltip/TooltipCutout.js.map +1 -1
- package/lib/module/surfaces/tooltip/TooltipHighlight.js +118 -0
- package/lib/module/surfaces/tooltip/TooltipHighlight.js.map +1 -0
- package/lib/module/surfaces/tooltip/computeTooltipPosition.js +67 -13
- package/lib/module/surfaces/tooltip/computeTooltipPosition.js.map +1 -1
- package/lib/module/surfaces/tooltip/inferTooltipPlacement.js +87 -19
- package/lib/module/surfaces/tooltip/inferTooltipPlacement.js.map +1 -1
- package/lib/module/surfaces/tooltip/placementDiagnostics.js +43 -0
- package/lib/module/surfaces/tooltip/placementDiagnostics.js.map +1 -0
- package/lib/module/surfaces/tooltip/rect.js +11 -0
- package/lib/module/surfaces/tooltip/rect.js.map +1 -1
- package/lib/module/surfaces/tooltip/resolveSideCardWidth.js +96 -0
- package/lib/module/surfaces/tooltip/resolveSideCardWidth.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/anchors/AutoAnchorRegistry.d.ts +27 -1
- package/lib/typescript/commonjs/src/anchors/AutoAnchorRegistry.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/anchorChangeTicker.d.ts +2 -0
- package/lib/typescript/commonjs/src/anchors/anchorChangeTicker.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/autoAnchor.d.ts +1 -1
- package/lib/typescript/commonjs/src/anchors/elementConditionEvaluator.d.ts +14 -10
- package/lib/typescript/commonjs/src/anchors/elementConditionEvaluator.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/fiber/FiberScanRoot.d.ts +1 -20
- package/lib/typescript/commonjs/src/anchors/fiber/FiberScanRoot.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/fiber/FiberScanRootStore.d.ts +21 -0
- package/lib/typescript/commonjs/src/anchors/fiber/FiberScanRootStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/fiber/fiberInternals.d.ts +42 -1
- package/lib/typescript/commonjs/src/anchors/fiber/fiberInternals.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/fiber/indexHostFibers.d.ts +42 -0
- package/lib/typescript/commonjs/src/anchors/fiber/indexHostFibers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/fiber/readHostContent.d.ts +17 -0
- package/lib/typescript/commonjs/src/anchors/fiber/readHostContent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/fiberAnchorCache.d.ts +20 -0
- package/lib/typescript/commonjs/src/anchors/fiberAnchorCache.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/hintsCodec.d.ts +1 -1
- package/lib/typescript/commonjs/src/anchors/resolveAnchorHost.d.ts +5 -5
- package/lib/typescript/commonjs/src/anchors/resolveAnchorHost.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/resolveAutoAnchorHost.d.ts +38 -0
- package/lib/typescript/commonjs/src/anchors/resolveAutoAnchorHost.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/semanticMatcher.d.ts +48 -0
- package/lib/typescript/commonjs/src/anchors/semanticMatcher.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/ElementPickerOverlay.d.ts +7 -0
- package/lib/typescript/commonjs/src/authoring/ElementPickerOverlay.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/capturePickerScreenshot.d.ts +11 -0
- package/lib/typescript/commonjs/src/authoring/capturePickerScreenshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeBarTransition.d.ts +32 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeBarTransition.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeBottomSheet.d.ts +13 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeBottomSheet.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeButton.d.ts +20 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeDialog.d.ts +14 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeDialog.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeIcon.d.ts +13 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeIcon.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeTooltip.d.ts +17 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeTooltip.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeTopBar.d.ts +25 -0
- package/lib/typescript/commonjs/src/authoring/chrome/ChromeTopBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/DoubleTapBridge.d.ts +12 -0
- package/lib/typescript/commonjs/src/authoring/chrome/DoubleTapBridge.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/doubleTapMonitor.d.ts +26 -0
- package/lib/typescript/commonjs/src/authoring/chrome/doubleTapMonitor.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/chrome/tokens.d.ts +141 -0
- package/lib/typescript/commonjs/src/authoring/chrome/tokens.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/doubleTap.d.ts +14 -0
- package/lib/typescript/commonjs/src/authoring/doubleTap.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/elementPickerController.d.ts +59 -0
- package/lib/typescript/commonjs/src/authoring/elementPickerController.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/fingerprintFromInstance.d.ts +26 -0
- package/lib/typescript/commonjs/src/authoring/fingerprintFromInstance.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/authoring/hitTest.d.ts +31 -0
- package/lib/typescript/commonjs/src/authoring/hitTest.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/content/RichContentRenderer.d.ts +6 -1
- package/lib/typescript/commonjs/src/content/RichContentRenderer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/content/StepButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/content/resolveStepButtonChrome.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/content/themeColor.d.ts +5 -0
- package/lib/typescript/commonjs/src/content/themeColor.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/deviceContext.d.ts +66 -0
- package/lib/typescript/commonjs/src/deviceContext.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/expo-router/useUserflowExpoRouter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hostAppVersion.d.ts +69 -0
- package/lib/typescript/commonjs/src/hostAppVersion.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +53 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/lifecycle.d.ts +6 -0
- package/lib/typescript/commonjs/src/lifecycle.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/navigation/WithUserflowReactNavigation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/navigation/isOverlayPresentation.d.ts +14 -0
- package/lib/typescript/commonjs/src/navigation/isOverlayPresentation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/pairing/PairingController.d.ts +7 -0
- package/lib/typescript/commonjs/src/pairing/PairingController.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/pairing/PreviewModeBanner.d.ts +6 -1
- package/lib/typescript/commonjs/src/pairing/PreviewModeBanner.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/pairing/diagnostics.d.ts +5 -0
- package/lib/typescript/commonjs/src/pairing/diagnostics.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/pairing/elementPickerRelay.d.ts +11 -0
- package/lib/typescript/commonjs/src/pairing/elementPickerRelay.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/pairing/resolvePreviewChrome.d.ts +16 -0
- package/lib/typescript/commonjs/src/pairing/resolvePreviewChrome.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/pairing/tokenStorage.d.ts +2 -0
- package/lib/typescript/commonjs/src/pairing/tokenStorage.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/pairing/usePairingState.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/FlowRenderer.d.ts +6 -3
- package/lib/typescript/commonjs/src/runtime/FlowRenderer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/FlowSurfaceFade.d.ts +20 -7
- package/lib/typescript/commonjs/src/runtime/FlowSurfaceFade.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/TargetPressBridge.d.ts +5 -1
- package/lib/typescript/commonjs/src/runtime/TargetPressBridge.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/UserflowProvider.d.ts +6 -4
- package/lib/typescript/commonjs/src/runtime/UserflowProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/changedTouchPoints.d.ts +10 -0
- package/lib/typescript/commonjs/src/runtime/changedTouchPoints.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/runtime/flowEngine.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/flowSessionViewState.d.ts +12 -3
- package/lib/typescript/commonjs/src/runtime/flowSessionViewState.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/useFlowSessionState.d.ts +1 -0
- package/lib/typescript/commonjs/src/runtime/useFlowSessionState.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/screenTracker.d.ts +21 -3
- package/lib/typescript/commonjs/src/screenTracker.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/CardFade.d.ts +12 -0
- package/lib/typescript/commonjs/src/surfaces/CardFade.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/CloseButton.d.ts +8 -2
- package/lib/typescript/commonjs/src/surfaces/CloseButton.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/MadeWithUserflow.d.ts +1 -1
- package/lib/typescript/commonjs/src/surfaces/ModalSurface.d.ts +1 -1
- package/lib/typescript/commonjs/src/surfaces/ModalSurface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/TooltipSurface.d.ts +12 -1
- package/lib/typescript/commonjs/src/surfaces/TooltipSurface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/cardTransition.d.ts +31 -0
- package/lib/typescript/commonjs/src/surfaces/cardTransition.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/resolveHighlightChrome.d.ts +44 -0
- package/lib/typescript/commonjs/src/surfaces/resolveHighlightChrome.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/resolveModalLayout.d.ts +1 -1
- package/lib/typescript/commonjs/src/surfaces/resolveModalLayout.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/resolveTooltipLayout.d.ts +0 -7
- package/lib/typescript/commonjs/src/surfaces/resolveTooltipLayout.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/surfaceInteractionConfig.d.ts +15 -0
- package/lib/typescript/commonjs/src/surfaces/surfaceInteractionConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/surfaceLayoutInsets.d.ts +38 -0
- package/lib/typescript/commonjs/src/surfaces/surfaceLayoutInsets.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/themeChrome.d.ts +3 -1
- package/lib/typescript/commonjs/src/surfaces/themeChrome.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/tooltip/TooltipBubble.d.ts +21 -6
- package/lib/typescript/commonjs/src/surfaces/tooltip/TooltipBubble.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/tooltip/TooltipCutout.d.ts +18 -10
- package/lib/typescript/commonjs/src/surfaces/tooltip/TooltipCutout.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/tooltip/TooltipHighlight.d.ts +25 -0
- package/lib/typescript/commonjs/src/surfaces/tooltip/TooltipHighlight.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/tooltip/computeTooltipPosition.d.ts +23 -0
- package/lib/typescript/commonjs/src/surfaces/tooltip/computeTooltipPosition.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/tooltip/inferTooltipPlacement.d.ts +47 -1
- package/lib/typescript/commonjs/src/surfaces/tooltip/inferTooltipPlacement.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/tooltip/placementDiagnostics.d.ts +39 -0
- package/lib/typescript/commonjs/src/surfaces/tooltip/placementDiagnostics.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/tooltip/rect.d.ts +2 -0
- package/lib/typescript/commonjs/src/surfaces/tooltip/rect.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/surfaces/tooltip/resolveSideCardWidth.d.ts +76 -0
- package/lib/typescript/commonjs/src/surfaces/tooltip/resolveSideCardWidth.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/anchors/AutoAnchorRegistry.d.ts +27 -1
- package/lib/typescript/module/src/anchors/AutoAnchorRegistry.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/anchorChangeTicker.d.ts +2 -0
- package/lib/typescript/module/src/anchors/anchorChangeTicker.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/autoAnchor.d.ts +1 -1
- package/lib/typescript/module/src/anchors/elementConditionEvaluator.d.ts +14 -10
- package/lib/typescript/module/src/anchors/elementConditionEvaluator.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/fiber/FiberScanRoot.d.ts +1 -20
- package/lib/typescript/module/src/anchors/fiber/FiberScanRoot.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/fiber/FiberScanRootStore.d.ts +21 -0
- package/lib/typescript/module/src/anchors/fiber/FiberScanRootStore.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/fiber/fiberInternals.d.ts +42 -1
- package/lib/typescript/module/src/anchors/fiber/fiberInternals.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/fiber/indexHostFibers.d.ts +42 -0
- package/lib/typescript/module/src/anchors/fiber/indexHostFibers.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/fiber/readHostContent.d.ts +17 -0
- package/lib/typescript/module/src/anchors/fiber/readHostContent.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/fiberAnchorCache.d.ts +20 -0
- package/lib/typescript/module/src/anchors/fiberAnchorCache.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/hintsCodec.d.ts +1 -1
- package/lib/typescript/module/src/anchors/resolveAnchorHost.d.ts +5 -5
- package/lib/typescript/module/src/anchors/resolveAnchorHost.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/resolveAutoAnchorHost.d.ts +38 -0
- package/lib/typescript/module/src/anchors/resolveAutoAnchorHost.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/semanticMatcher.d.ts +48 -0
- package/lib/typescript/module/src/anchors/semanticMatcher.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/ElementPickerOverlay.d.ts +7 -0
- package/lib/typescript/module/src/authoring/ElementPickerOverlay.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/capturePickerScreenshot.d.ts +11 -0
- package/lib/typescript/module/src/authoring/capturePickerScreenshot.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeBarTransition.d.ts +32 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeBarTransition.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeBottomSheet.d.ts +13 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeBottomSheet.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeButton.d.ts +20 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeButton.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeDialog.d.ts +14 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeDialog.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeIcon.d.ts +13 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeIcon.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeTooltip.d.ts +17 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeTooltip.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeTopBar.d.ts +25 -0
- package/lib/typescript/module/src/authoring/chrome/ChromeTopBar.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/DoubleTapBridge.d.ts +12 -0
- package/lib/typescript/module/src/authoring/chrome/DoubleTapBridge.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/doubleTapMonitor.d.ts +26 -0
- package/lib/typescript/module/src/authoring/chrome/doubleTapMonitor.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/chrome/tokens.d.ts +141 -0
- package/lib/typescript/module/src/authoring/chrome/tokens.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/doubleTap.d.ts +14 -0
- package/lib/typescript/module/src/authoring/doubleTap.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/elementPickerController.d.ts +59 -0
- package/lib/typescript/module/src/authoring/elementPickerController.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/fingerprintFromInstance.d.ts +26 -0
- package/lib/typescript/module/src/authoring/fingerprintFromInstance.d.ts.map +1 -0
- package/lib/typescript/module/src/authoring/hitTest.d.ts +31 -0
- package/lib/typescript/module/src/authoring/hitTest.d.ts.map +1 -0
- package/lib/typescript/module/src/content/RichContentRenderer.d.ts +6 -1
- package/lib/typescript/module/src/content/RichContentRenderer.d.ts.map +1 -1
- package/lib/typescript/module/src/content/StepButton.d.ts.map +1 -1
- package/lib/typescript/module/src/content/resolveStepButtonChrome.d.ts.map +1 -1
- package/lib/typescript/module/src/content/themeColor.d.ts +5 -0
- package/lib/typescript/module/src/content/themeColor.d.ts.map +1 -1
- package/lib/typescript/module/src/deviceContext.d.ts +66 -0
- package/lib/typescript/module/src/deviceContext.d.ts.map +1 -0
- package/lib/typescript/module/src/expo-router/useUserflowExpoRouter.d.ts.map +1 -1
- package/lib/typescript/module/src/hostAppVersion.d.ts +69 -0
- package/lib/typescript/module/src/hostAppVersion.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +53 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/lifecycle.d.ts +6 -0
- package/lib/typescript/module/src/lifecycle.d.ts.map +1 -1
- package/lib/typescript/module/src/navigation/WithUserflowReactNavigation.d.ts.map +1 -1
- package/lib/typescript/module/src/navigation/isOverlayPresentation.d.ts +14 -0
- package/lib/typescript/module/src/navigation/isOverlayPresentation.d.ts.map +1 -0
- package/lib/typescript/module/src/pairing/PairingController.d.ts +7 -0
- package/lib/typescript/module/src/pairing/PairingController.d.ts.map +1 -1
- package/lib/typescript/module/src/pairing/PreviewModeBanner.d.ts +6 -1
- package/lib/typescript/module/src/pairing/PreviewModeBanner.d.ts.map +1 -1
- package/lib/typescript/module/src/pairing/diagnostics.d.ts +5 -0
- package/lib/typescript/module/src/pairing/diagnostics.d.ts.map +1 -1
- package/lib/typescript/module/src/pairing/elementPickerRelay.d.ts +11 -0
- package/lib/typescript/module/src/pairing/elementPickerRelay.d.ts.map +1 -0
- package/lib/typescript/module/src/pairing/resolvePreviewChrome.d.ts +16 -0
- package/lib/typescript/module/src/pairing/resolvePreviewChrome.d.ts.map +1 -0
- package/lib/typescript/module/src/pairing/tokenStorage.d.ts +2 -0
- package/lib/typescript/module/src/pairing/tokenStorage.d.ts.map +1 -1
- package/lib/typescript/module/src/pairing/usePairingState.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/FlowRenderer.d.ts +6 -3
- package/lib/typescript/module/src/runtime/FlowRenderer.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/FlowSurfaceFade.d.ts +20 -7
- package/lib/typescript/module/src/runtime/FlowSurfaceFade.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/TargetPressBridge.d.ts +5 -1
- package/lib/typescript/module/src/runtime/TargetPressBridge.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/UserflowProvider.d.ts +6 -4
- package/lib/typescript/module/src/runtime/UserflowProvider.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/changedTouchPoints.d.ts +10 -0
- package/lib/typescript/module/src/runtime/changedTouchPoints.d.ts.map +1 -0
- package/lib/typescript/module/src/runtime/flowEngine.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/flowSessionViewState.d.ts +12 -3
- package/lib/typescript/module/src/runtime/flowSessionViewState.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/useFlowSessionState.d.ts +1 -0
- package/lib/typescript/module/src/runtime/useFlowSessionState.d.ts.map +1 -1
- package/lib/typescript/module/src/screenTracker.d.ts +21 -3
- package/lib/typescript/module/src/screenTracker.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/CardFade.d.ts +12 -0
- package/lib/typescript/module/src/surfaces/CardFade.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/CloseButton.d.ts +8 -2
- package/lib/typescript/module/src/surfaces/CloseButton.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/MadeWithUserflow.d.ts +1 -1
- package/lib/typescript/module/src/surfaces/ModalSurface.d.ts +1 -1
- package/lib/typescript/module/src/surfaces/ModalSurface.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/TooltipSurface.d.ts +12 -1
- package/lib/typescript/module/src/surfaces/TooltipSurface.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/cardTransition.d.ts +31 -0
- package/lib/typescript/module/src/surfaces/cardTransition.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/resolveHighlightChrome.d.ts +44 -0
- package/lib/typescript/module/src/surfaces/resolveHighlightChrome.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/resolveModalLayout.d.ts +1 -1
- package/lib/typescript/module/src/surfaces/resolveModalLayout.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/resolveTooltipLayout.d.ts +0 -7
- package/lib/typescript/module/src/surfaces/resolveTooltipLayout.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/surfaceInteractionConfig.d.ts +15 -0
- package/lib/typescript/module/src/surfaces/surfaceInteractionConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/surfaceLayoutInsets.d.ts +38 -0
- package/lib/typescript/module/src/surfaces/surfaceLayoutInsets.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/themeChrome.d.ts +3 -1
- package/lib/typescript/module/src/surfaces/themeChrome.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/tooltip/TooltipBubble.d.ts +21 -6
- package/lib/typescript/module/src/surfaces/tooltip/TooltipBubble.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/tooltip/TooltipCutout.d.ts +18 -10
- package/lib/typescript/module/src/surfaces/tooltip/TooltipCutout.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/tooltip/TooltipHighlight.d.ts +25 -0
- package/lib/typescript/module/src/surfaces/tooltip/TooltipHighlight.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/tooltip/computeTooltipPosition.d.ts +23 -0
- package/lib/typescript/module/src/surfaces/tooltip/computeTooltipPosition.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/tooltip/inferTooltipPlacement.d.ts +47 -1
- package/lib/typescript/module/src/surfaces/tooltip/inferTooltipPlacement.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/tooltip/placementDiagnostics.d.ts +39 -0
- package/lib/typescript/module/src/surfaces/tooltip/placementDiagnostics.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/tooltip/rect.d.ts +2 -0
- package/lib/typescript/module/src/surfaces/tooltip/rect.d.ts.map +1 -1
- package/lib/typescript/module/src/surfaces/tooltip/resolveSideCardWidth.d.ts +76 -0
- package/lib/typescript/module/src/surfaces/tooltip/resolveSideCardWidth.d.ts.map +1 -0
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +32 -18
- package/src/anchors/AutoAnchorRegistry.ts +140 -3
- package/src/anchors/anchorChangeTicker.ts +10 -0
- package/src/anchors/autoAnchor.ts +1 -1
- package/src/anchors/elementConditionEvaluator.ts +29 -16
- package/src/anchors/fiber/FiberScanRoot.tsx +2 -50
- package/src/anchors/fiber/FiberScanRootStore.ts +51 -0
- package/src/anchors/fiber/fiberInternals.ts +166 -3
- package/src/anchors/fiber/indexHostFibers.ts +136 -0
- package/src/anchors/fiber/readHostContent.ts +146 -0
- package/src/anchors/fiberAnchorCache.ts +45 -0
- package/src/anchors/hintsCodec.ts +1 -1
- package/src/anchors/resolveAnchorHost.ts +23 -23
- package/src/anchors/resolveAutoAnchorHost.ts +180 -0
- package/src/anchors/semanticMatcher.ts +361 -0
- package/src/authoring/ElementPickerOverlay.tsx +553 -0
- package/src/authoring/capturePickerScreenshot.ts +90 -0
- package/src/authoring/chrome/ChromeBarTransition.tsx +106 -0
- package/src/authoring/chrome/ChromeBottomSheet.tsx +69 -0
- package/src/authoring/chrome/ChromeButton.tsx +103 -0
- package/src/authoring/chrome/ChromeDialog.tsx +121 -0
- package/src/authoring/chrome/ChromeIcon.tsx +40 -0
- package/src/authoring/chrome/ChromeTooltip.tsx +89 -0
- package/src/authoring/chrome/ChromeTopBar.tsx +126 -0
- package/src/authoring/chrome/DoubleTapBridge.tsx +60 -0
- package/src/authoring/chrome/doubleTapMonitor.ts +80 -0
- package/src/authoring/chrome/icons/arrow-left-from-bracket.png +0 -0
- package/src/authoring/chrome/icons/arrow-left-from-bracket@2x.png +0 -0
- package/src/authoring/chrome/icons/arrow-left-from-bracket@3x.png +0 -0
- package/src/authoring/chrome/icons/arrow-rotate-left.png +0 -0
- package/src/authoring/chrome/icons/arrow-rotate-left@2x.png +0 -0
- package/src/authoring/chrome/icons/arrow-rotate-left@3x.png +0 -0
- package/src/authoring/chrome/icons/userflow-logomark.png +0 -0
- package/src/authoring/chrome/icons/userflow-logomark@2x.png +0 -0
- package/src/authoring/chrome/icons/userflow-logomark@3x.png +0 -0
- package/src/authoring/chrome/icons/xmark.png +0 -0
- package/src/authoring/chrome/icons/xmark@2x.png +0 -0
- package/src/authoring/chrome/icons/xmark@3x.png +0 -0
- package/src/authoring/chrome/tokens.ts +106 -0
- package/src/authoring/doubleTap.ts +27 -0
- package/src/authoring/elementPickerController.ts +135 -0
- package/src/authoring/fingerprintFromInstance.ts +152 -0
- package/src/authoring/hitTest.ts +133 -0
- package/src/content/RichContentRenderer.tsx +22 -1
- package/src/content/StepButton.tsx +17 -2
- package/src/content/resolveStepButtonChrome.ts +12 -6
- package/src/content/themeColor.ts +10 -0
- package/src/deviceContext.ts +168 -0
- package/src/expo-router/useUserflowExpoRouter.ts +47 -4
- package/src/hostAppVersion.ts +258 -0
- package/src/index.ts +148 -4
- package/src/lifecycle.ts +8 -0
- package/src/navigation/WithUserflowReactNavigation.tsx +23 -7
- package/src/navigation/isOverlayPresentation.ts +76 -0
- package/src/pairing/PairingController.ts +32 -3
- package/src/pairing/PreviewModeBanner.tsx +250 -94
- package/src/pairing/diagnostics.ts +10 -2
- package/src/pairing/elementPickerRelay.ts +100 -0
- package/src/pairing/resolvePreviewChrome.ts +57 -0
- package/src/pairing/tokenStorage.ts +31 -2
- package/src/pairing/usePairingState.ts +2 -0
- package/src/runtime/FlowRenderer.tsx +55 -27
- package/src/runtime/FlowSurfaceFade.tsx +51 -30
- package/src/runtime/TargetPressBridge.tsx +14 -32
- package/src/runtime/UserflowProvider.tsx +76 -13
- package/src/runtime/changedTouchPoints.ts +34 -0
- package/src/runtime/flowEngine.ts +2 -0
- package/src/runtime/flowSessionViewState.ts +42 -4
- package/src/runtime/useFlowSessionState.ts +2 -0
- package/src/screenTracker.ts +46 -4
- package/src/surfaces/CardFade.tsx +18 -0
- package/src/surfaces/CloseButton.tsx +17 -7
- package/src/surfaces/MadeWithUserflow.tsx +1 -1
- package/src/surfaces/ModalSurface.tsx +48 -35
- package/src/surfaces/TooltipSurface.tsx +406 -86
- package/src/surfaces/cardTransition.ts +67 -0
- package/src/surfaces/resolveHighlightChrome.ts +139 -0
- package/src/surfaces/resolveModalLayout.ts +16 -8
- package/src/surfaces/resolveTooltipLayout.ts +1 -14
- package/src/surfaces/surfaceInteractionConfig.ts +25 -0
- package/src/surfaces/surfaceLayoutInsets.tsx +135 -0
- package/src/surfaces/themeChrome.ts +5 -3
- package/src/surfaces/tooltip/TooltipBubble.tsx +154 -19
- package/src/surfaces/tooltip/TooltipCutout.tsx +106 -49
- package/src/surfaces/tooltip/TooltipHighlight.tsx +144 -0
- package/src/surfaces/tooltip/computeTooltipPosition.ts +98 -12
- package/src/surfaces/tooltip/inferTooltipPlacement.ts +107 -18
- package/src/surfaces/tooltip/placementDiagnostics.ts +70 -0
- package/src/surfaces/tooltip/rect.ts +11 -0
- package/src/surfaces/tooltip/resolveSideCardWidth.ts +121 -0
- package/src/version.ts +1 -1
- package/vendor/core/LICENSE +76 -0
- package/vendor/core/README.md +9 -0
- package/vendor/core/dist/attributes.d.ts +15 -0
- package/vendor/core/dist/attributes.d.ts.map +1 -0
- package/vendor/core/dist/attributes.js +55 -0
- package/vendor/core/dist/attributes.js.map +1 -0
- package/vendor/core/dist/constants.d.ts +21 -0
- package/vendor/core/dist/constants.d.ts.map +1 -0
- package/vendor/core/dist/constants.js +21 -0
- package/vendor/core/dist/constants.js.map +1 -0
- package/vendor/core/dist/engine/ClientConditionEngine.d.ts +68 -0
- package/vendor/core/dist/engine/ClientConditionEngine.d.ts.map +1 -0
- package/vendor/core/dist/engine/ClientConditionEngine.js +197 -0
- package/vendor/core/dist/engine/ClientConditionEngine.js.map +1 -0
- package/vendor/core/dist/engine/FlowSessionEngine.d.ts +160 -0
- package/vendor/core/dist/engine/FlowSessionEngine.d.ts.map +1 -0
- package/vendor/core/dist/engine/FlowSessionEngine.js +571 -0
- package/vendor/core/dist/engine/FlowSessionEngine.js.map +1 -0
- package/vendor/core/dist/engine/PairingEngine.d.ts +135 -0
- package/vendor/core/dist/engine/PairingEngine.d.ts.map +1 -0
- package/vendor/core/dist/engine/PairingEngine.js +396 -0
- package/vendor/core/dist/engine/PairingEngine.js.map +1 -0
- package/vendor/core/dist/engine/UserflowCore.d.ts +145 -0
- package/vendor/core/dist/engine/UserflowCore.d.ts.map +1 -0
- package/vendor/core/dist/engine/UserflowCore.js +329 -0
- package/vendor/core/dist/engine/UserflowCore.js.map +1 -0
- package/vendor/core/dist/engine/conditionOperators.d.ts +16 -0
- package/vendor/core/dist/engine/conditionOperators.d.ts.map +1 -0
- package/vendor/core/dist/engine/conditionOperators.js +168 -0
- package/vendor/core/dist/engine/conditionOperators.js.map +1 -0
- package/vendor/core/dist/engine/handleActions.d.ts +42 -0
- package/vendor/core/dist/engine/handleActions.d.ts.map +1 -0
- package/vendor/core/dist/engine/handleActions.js +198 -0
- package/vendor/core/dist/engine/handleActions.js.map +1 -0
- package/vendor/core/dist/engine/interpolateSessionData.d.ts +7 -0
- package/vendor/core/dist/engine/interpolateSessionData.d.ts.map +1 -0
- package/vendor/core/dist/engine/interpolateSessionData.js +29 -0
- package/vendor/core/dist/engine/interpolateSessionData.js.map +1 -0
- package/vendor/core/dist/engine/simpleObservable.d.ts +13 -0
- package/vendor/core/dist/engine/simpleObservable.d.ts.map +1 -0
- package/vendor/core/dist/engine/simpleObservable.js +29 -0
- package/vendor/core/dist/engine/simpleObservable.js.map +1 -0
- package/vendor/core/dist/engine/trackCondition.d.ts +25 -0
- package/vendor/core/dist/engine/trackCondition.d.ts.map +1 -0
- package/vendor/core/dist/engine/trackCondition.js +177 -0
- package/vendor/core/dist/engine/trackCondition.js.map +1 -0
- package/vendor/core/dist/engine/trackStepTriggers.d.ts +21 -0
- package/vendor/core/dist/engine/trackStepTriggers.d.ts.map +1 -0
- package/vendor/core/dist/engine/trackStepTriggers.js +49 -0
- package/vendor/core/dist/engine/trackStepTriggers.js.map +1 -0
- package/vendor/core/dist/errors.d.ts +9 -0
- package/vendor/core/dist/errors.d.ts.map +1 -0
- package/vendor/core/dist/errors.js +15 -0
- package/vendor/core/dist/errors.js.map +1 -0
- package/vendor/core/dist/eventAttributes.d.ts +7 -0
- package/vendor/core/dist/eventAttributes.d.ts.map +1 -0
- package/vendor/core/dist/eventAttributes.js +31 -0
- package/vendor/core/dist/eventAttributes.js.map +1 -0
- package/vendor/core/dist/index.d.ts +31 -0
- package/vendor/core/dist/index.d.ts.map +1 -0
- package/vendor/core/dist/index.js +22 -0
- package/vendor/core/dist/index.js.map +1 -0
- package/vendor/core/dist/normalizeAttributes.d.ts +8 -0
- package/vendor/core/dist/normalizeAttributes.d.ts.map +1 -0
- package/vendor/core/dist/normalizeAttributes.js +127 -0
- package/vendor/core/dist/normalizeAttributes.js.map +1 -0
- package/vendor/core/dist/transport/backoff.d.ts +11 -0
- package/vendor/core/dist/transport/backoff.d.ts.map +1 -0
- package/vendor/core/dist/transport/backoff.js +17 -0
- package/vendor/core/dist/transport/backoff.js.map +1 -0
- package/vendor/core/dist/transport/pairing.d.ts +121 -0
- package/vendor/core/dist/transport/pairing.d.ts.map +1 -0
- package/vendor/core/dist/transport/pairing.js +551 -0
- package/vendor/core/dist/transport/pairing.js.map +1 -0
- package/vendor/core/dist/transport/phoenix.d.ts +228 -0
- package/vendor/core/dist/transport/phoenix.d.ts.map +1 -0
- package/vendor/core/dist/transport/phoenix.js +811 -0
- package/vendor/core/dist/transport/phoenix.js.map +1 -0
- package/vendor/core/dist/transport/rateLimiter.d.ts +17 -0
- package/vendor/core/dist/transport/rateLimiter.d.ts.map +1 -0
- package/vendor/core/dist/transport/rateLimiter.js +30 -0
- package/vendor/core/dist/transport/rateLimiter.js.map +1 -0
- package/vendor/core/dist/transport/scheduler.d.ts +12 -0
- package/vendor/core/dist/transport/scheduler.d.ts.map +1 -0
- package/vendor/core/dist/transport/scheduler.js +11 -0
- package/vendor/core/dist/transport/scheduler.js.map +1 -0
- package/vendor/core/dist/types.d.ts +60 -0
- package/vendor/core/dist/types.d.ts.map +1 -0
- package/vendor/core/dist/types.js +2 -0
- package/vendor/core/dist/types.js.map +1 -0
- package/vendor/core/dist/version.d.ts +3 -0
- package/vendor/core/dist/version.d.ts.map +1 -0
- package/vendor/core/dist/version.js +3 -0
- package/vendor/core/dist/version.js.map +1 -0
- package/vendor/core/package.json +20 -0
- package/vendor/protocol/LICENSE +76 -0
- package/vendor/protocol/README.md +8 -0
- package/vendor/protocol/dist/attributes.d.ts +43 -0
- package/vendor/protocol/dist/attributes.d.ts.map +1 -0
- package/vendor/protocol/dist/attributes.js +15 -0
- package/vendor/protocol/dist/attributes.js.map +1 -0
- package/vendor/protocol/dist/autoData.d.ts +232 -0
- package/vendor/protocol/dist/autoData.d.ts.map +1 -0
- package/vendor/protocol/dist/autoData.js +78 -0
- package/vendor/protocol/dist/autoData.js.map +1 -0
- package/vendor/protocol/dist/events.d.ts +24 -0
- package/vendor/protocol/dist/events.d.ts.map +1 -0
- package/vendor/protocol/dist/events.js +8 -0
- package/vendor/protocol/dist/events.js.map +1 -0
- package/vendor/protocol/dist/flows.d.ts +360 -0
- package/vendor/protocol/dist/flows.d.ts.map +1 -0
- package/vendor/protocol/dist/flows.js +201 -0
- package/vendor/protocol/dist/flows.js.map +1 -0
- package/vendor/protocol/dist/index.d.ts +25 -0
- package/vendor/protocol/dist/index.d.ts.map +1 -0
- package/vendor/protocol/dist/index.js +17 -0
- package/vendor/protocol/dist/index.js.map +1 -0
- package/vendor/protocol/dist/messages.d.ts +187 -0
- package/vendor/protocol/dist/messages.d.ts.map +1 -0
- package/vendor/protocol/dist/messages.js +61 -0
- package/vendor/protocol/dist/messages.js.map +1 -0
- package/vendor/protocol/dist/pairing.d.ts +82 -0
- package/vendor/protocol/dist/pairing.d.ts.map +1 -0
- package/vendor/protocol/dist/pairing.js +146 -0
- package/vendor/protocol/dist/pairing.js.map +1 -0
- package/vendor/protocol/package.json +17 -0
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
import { isServerMessage, TargetPlatform } from '@userflow-tech/protocol';
|
|
2
|
+
import { UserflowAuthError, UserflowRateLimitError } from '../errors.js';
|
|
3
|
+
import { CORE_VERSION } from '../version.js';
|
|
4
|
+
import { createBackoff } from './backoff.js';
|
|
5
|
+
import { createRateLimiter, RATE_LIMIT_PER_MINUTE } from './rateLimiter.js';
|
|
6
|
+
import { defaultScheduler } from './scheduler.js';
|
|
7
|
+
const TIMEOUT_MS = 15000;
|
|
8
|
+
const HEARTBEAT_INTERVAL_MS = 30000;
|
|
9
|
+
/**
|
|
10
|
+
* How long to wait for a heartbeat reply before declaring the socket dead.
|
|
11
|
+
* A short, bounded liveness window (vs. waiting a full heartbeat interval)
|
|
12
|
+
* means a silently-dropped socket is detected in seconds instead of up to two
|
|
13
|
+
* intervals. Capped at the heartbeat interval so tiny test intervals behave.
|
|
14
|
+
*/
|
|
15
|
+
const HEARTBEAT_REPLY_TIMEOUT_MS = 10000;
|
|
16
|
+
/** WebSocket.OPEN readyState, referenced without the DOM/global type. */
|
|
17
|
+
const WS_OPEN = 1;
|
|
18
|
+
const PHOENIX_TOPIC = 'phoenix';
|
|
19
|
+
const DEFAULT_CLIENT_CONTEXT = {
|
|
20
|
+
pageUrl: '',
|
|
21
|
+
viewportWidth: 390,
|
|
22
|
+
viewportHeight: 844,
|
|
23
|
+
};
|
|
24
|
+
/** Builds the Phoenix websocket URL for a given endpoint and client token. */
|
|
25
|
+
export function buildWsUrl(serverEndpoint, clientToken) {
|
|
26
|
+
const host = serverEndpoint.replace(/\/$/, '');
|
|
27
|
+
const path = `/end-users/${encodeURIComponent(clientToken)}/socket/websocket?vsn=2.0.0`;
|
|
28
|
+
if (host.startsWith('http://'))
|
|
29
|
+
return `ws://${host.slice('http://'.length)}${path}`;
|
|
30
|
+
if (host.startsWith('https://'))
|
|
31
|
+
return `wss://${host.slice('https://'.length)}${path}`;
|
|
32
|
+
if (host.startsWith('ws://') || host.startsWith('wss://'))
|
|
33
|
+
return `${host}${path}`;
|
|
34
|
+
return `wss://${host}${path}`;
|
|
35
|
+
}
|
|
36
|
+
function uuid() {
|
|
37
|
+
const webcrypto = globalThis.crypto;
|
|
38
|
+
if (webcrypto?.randomUUID)
|
|
39
|
+
return webcrypto.randomUUID();
|
|
40
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (char) => {
|
|
41
|
+
const rand = (Math.random() * 16) | 0;
|
|
42
|
+
const value = char === 'x' ? rand : (rand & 0x3) | 0x8;
|
|
43
|
+
return value.toString(16);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function endUserJoinPayload(signature = null, flowSessionId = null, clientContext = DEFAULT_CLIENT_CONTEXT, clientConditions = []) {
|
|
47
|
+
return {
|
|
48
|
+
protocolVersion: 2,
|
|
49
|
+
userflowClientBuild: `mobile-${CORE_VERSION}`,
|
|
50
|
+
signature,
|
|
51
|
+
groupExternalId: null,
|
|
52
|
+
groupSignature: null,
|
|
53
|
+
flowSessionId,
|
|
54
|
+
checklistSessionId: null,
|
|
55
|
+
resourceCenterSessionId: null,
|
|
56
|
+
launchers: [],
|
|
57
|
+
trackers: [],
|
|
58
|
+
hasDraftSession: false,
|
|
59
|
+
clientConditions,
|
|
60
|
+
clientContext,
|
|
61
|
+
// Without this the server treats the socket as a web client and
|
|
62
|
+
// check_sessions immediately unsets any React Native draft preview.
|
|
63
|
+
targetPlatform: TargetPlatform.REACT_NATIVE,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function isSignatureRequiredError(error) {
|
|
67
|
+
return error instanceof UserflowAuthError && error.message.includes('user_signature_required');
|
|
68
|
+
}
|
|
69
|
+
function isNonIdempotentAttributeChange(value) {
|
|
70
|
+
if (value == null || typeof value !== 'object' || Array.isArray(value)) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return 'add' in value || 'subtract' in value || 'append' in value || 'prepend' in value;
|
|
74
|
+
}
|
|
75
|
+
function attributesHaveNonIdempotentOps(attributes) {
|
|
76
|
+
if (attributes == null || typeof attributes !== 'object' || Array.isArray(attributes)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return Object.values(attributes).some(isNonIdempotentAttributeChange);
|
|
80
|
+
}
|
|
81
|
+
/** Idempotent client_message payloads may be replayed after a dropped ack. */
|
|
82
|
+
function isReplayableClientMessage(payload) {
|
|
83
|
+
if (payload == null || typeof payload !== 'object') {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
const record = payload;
|
|
87
|
+
if (record.kind === 'UpsertUser') {
|
|
88
|
+
return !attributesHaveNonIdempotentOps(record.attributes);
|
|
89
|
+
}
|
|
90
|
+
if (record.kind === 'UpsertGroup') {
|
|
91
|
+
return (!attributesHaveNonIdempotentOps(record.groupAttributes) &&
|
|
92
|
+
!attributesHaveNonIdempotentOps(record.membershipAttributes));
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
function joinError(response) {
|
|
97
|
+
if (response && typeof response === 'object') {
|
|
98
|
+
const err = response;
|
|
99
|
+
if (err.code && err.message)
|
|
100
|
+
return `${err.code}: ${err.message}`;
|
|
101
|
+
if (err.message)
|
|
102
|
+
return err.message;
|
|
103
|
+
}
|
|
104
|
+
return 'channel join rejected';
|
|
105
|
+
}
|
|
106
|
+
function resolveSocketCtor(ctor) {
|
|
107
|
+
const provided = ctor ?? globalThis.WebSocket;
|
|
108
|
+
if (!provided) {
|
|
109
|
+
throw new UserflowAuthError('No WebSocket implementation is available');
|
|
110
|
+
}
|
|
111
|
+
return provided;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A resilient Phoenix websocket connection to the Userflow end-user endpoint.
|
|
115
|
+
* It speaks the v2 serialized frame protocol (`[joinRef, ref, topic, event,
|
|
116
|
+
* payload]`), tracks an explicit lifecycle, auto-reconnects with backoff,
|
|
117
|
+
* heartbeats to keep the socket alive, queues outbound pushes while
|
|
118
|
+
* disconnected, and can be suspended/resumed for app background handling.
|
|
119
|
+
*
|
|
120
|
+
* Liveness: each heartbeat arms a short reply deadline so a silently-dropped
|
|
121
|
+
* socket is detected in seconds rather than up to two heartbeat intervals.
|
|
122
|
+
* {@link ensureAlive} fires an immediate probe (e.g. on foreground or when the
|
|
123
|
+
* host reports connectivity restored) so recovery does not wait for the next
|
|
124
|
+
* scheduled heartbeat. This keeps recovery fast with zero external
|
|
125
|
+
* dependencies; a host-provided network signal that calls `ensureAlive` is an
|
|
126
|
+
* optional optimization, not a requirement.
|
|
127
|
+
*/
|
|
128
|
+
export class PhoenixConnection {
|
|
129
|
+
constructor(clientToken, serverEndpoint, socketCtor, options) {
|
|
130
|
+
this.clientToken = clientToken;
|
|
131
|
+
this.serverEndpoint = serverEndpoint;
|
|
132
|
+
this.socketCtor = socketCtor;
|
|
133
|
+
this.ws = null;
|
|
134
|
+
this.ref = 0;
|
|
135
|
+
this.pending = new Map();
|
|
136
|
+
this.channelJoinRef = null;
|
|
137
|
+
this.channelTopic = null;
|
|
138
|
+
this.channelJoined = false;
|
|
139
|
+
this.state = 'disconnected';
|
|
140
|
+
this.shouldBeConnected = false;
|
|
141
|
+
this.desiredTopic = null;
|
|
142
|
+
this.desiredJoinSignature = null;
|
|
143
|
+
this.outbound = [];
|
|
144
|
+
this.establishPromise = null;
|
|
145
|
+
this.pendingConnect = null;
|
|
146
|
+
this.reconnectHandle = null;
|
|
147
|
+
this.heartbeatHandle = null;
|
|
148
|
+
this.heartbeatReplyHandle = null;
|
|
149
|
+
this.pendingHeartbeatRef = null;
|
|
150
|
+
this.activeFlowSessionId = null;
|
|
151
|
+
this.clientContext = { ...DEFAULT_CLIENT_CONTEXT };
|
|
152
|
+
this.clientConditions = [];
|
|
153
|
+
this.serverMessageHandlers = new Set();
|
|
154
|
+
/** Kinds already warned about this connection lifetime (reset on disconnect). */
|
|
155
|
+
this.warnedUnhandledKinds = new Set();
|
|
156
|
+
this.scheduler = options?.scheduler ?? defaultScheduler;
|
|
157
|
+
this.backoff = createBackoff(options?.reconnectLadderMs);
|
|
158
|
+
this.heartbeatIntervalMs = options?.heartbeatIntervalMs ?? HEARTBEAT_INTERVAL_MS;
|
|
159
|
+
this.heartbeatReplyTimeoutMs =
|
|
160
|
+
options?.heartbeatReplyTimeoutMs ??
|
|
161
|
+
Math.min(HEARTBEAT_REPLY_TIMEOUT_MS, this.heartbeatIntervalMs);
|
|
162
|
+
this.rateLimitCapacity = options?.rateLimit?.capacity ?? RATE_LIMIT_PER_MINUTE;
|
|
163
|
+
this.rateLimiter = createRateLimiter({
|
|
164
|
+
...(options?.rateLimit?.capacity !== undefined
|
|
165
|
+
? { capacity: options.rateLimit.capacity }
|
|
166
|
+
: {}),
|
|
167
|
+
...(options?.rateLimit?.intervalMs !== undefined
|
|
168
|
+
? { intervalMs: options.rateLimit.intervalMs }
|
|
169
|
+
: {}),
|
|
170
|
+
...(options?.rateLimit?.now !== undefined ? { now: options.rateLimit.now } : {}),
|
|
171
|
+
});
|
|
172
|
+
this.warn = options?.warn ?? ((message) => console.warn(message));
|
|
173
|
+
}
|
|
174
|
+
/** The current lifecycle state (observability + tests). */
|
|
175
|
+
getState() {
|
|
176
|
+
return this.state;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Subscribe to inbound `server_message` frames on the joined end-user channel.
|
|
180
|
+
* Returns an unsubscribe function. Unknown message kinds are ignored (warned
|
|
181
|
+
* once per kind per connection lifetime).
|
|
182
|
+
*/
|
|
183
|
+
onServerMessage(handler) {
|
|
184
|
+
this.serverMessageHandlers.add(handler);
|
|
185
|
+
return () => {
|
|
186
|
+
this.serverMessageHandlers.delete(handler);
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Remember the active flow session id so every (re)join can resume it.
|
|
191
|
+
* Pass `null` when the session ends.
|
|
192
|
+
*/
|
|
193
|
+
setFlowSessionId(flowSessionId) {
|
|
194
|
+
this.activeFlowSessionId = flowSessionId;
|
|
195
|
+
}
|
|
196
|
+
/** The flow session id currently included in end-user join payloads. */
|
|
197
|
+
getFlowSessionId() {
|
|
198
|
+
return this.activeFlowSessionId;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Remember the client-condition snapshot so every (re)join can seed the
|
|
202
|
+
* server's tracked/true/false sets. Pass the current engine snapshot
|
|
203
|
+
* (including `isTrue: null` unknowns).
|
|
204
|
+
*/
|
|
205
|
+
setClientConditions(clientConditions) {
|
|
206
|
+
this.clientConditions = clientConditions.map((entry) => ({ ...entry }));
|
|
207
|
+
}
|
|
208
|
+
/** The client-condition snapshot currently included in end-user join payloads. */
|
|
209
|
+
getClientConditions() {
|
|
210
|
+
return this.clientConditions.map((entry) => ({ ...entry }));
|
|
211
|
+
}
|
|
212
|
+
/** The client context currently included in end-user join payloads. */
|
|
213
|
+
getClientContext() {
|
|
214
|
+
return { ...this.clientContext };
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Remember client context so every (re)join reports the latest screen/URL.
|
|
218
|
+
* Does not push to the server; use {@link updateClientContext} for that.
|
|
219
|
+
*/
|
|
220
|
+
setClientContext(clientContext) {
|
|
221
|
+
this.clientContext = { ...clientContext };
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Update remembered client context and push `UpdateClientContext` when joined.
|
|
225
|
+
* Mirrors the web client's URL-change → `pushUpdateClientContext` path.
|
|
226
|
+
*/
|
|
227
|
+
updateClientContext(clientContext) {
|
|
228
|
+
this.clientContext = { ...clientContext };
|
|
229
|
+
if (!this.channelTopic || !this.channelJoined) {
|
|
230
|
+
return Promise.resolve();
|
|
231
|
+
}
|
|
232
|
+
return this.enqueuePush('client_message', {
|
|
233
|
+
kind: 'UpdateClientContext',
|
|
234
|
+
clientContext: this.clientContext,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Push a Phase 3 client message on the joined channel. Reuses the outbound
|
|
239
|
+
* queue. `ToggleClientCondition` skips the rate limiter (web parity: meta
|
|
240
|
+
* messages must not be starved by UpsertUser / GoToStep traffic, and
|
|
241
|
+
* condition churn must not fail closed until the next rejoin).
|
|
242
|
+
* `BeginBatch` / `EndBatch` are the same class of meta message.
|
|
243
|
+
*/
|
|
244
|
+
send(message) {
|
|
245
|
+
if (!this.channelTopic || !this.channelJoined) {
|
|
246
|
+
return Promise.reject(new UserflowAuthError('Not joined to an end-user channel'));
|
|
247
|
+
}
|
|
248
|
+
return this.enqueuePush('client_message', message, {
|
|
249
|
+
skipRateLimit: message.kind === 'ToggleClientCondition' ||
|
|
250
|
+
message.kind === 'BeginBatch' ||
|
|
251
|
+
message.kind === 'EndBatch',
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/** Validates the client token by probing an anonymous end-user channel join. */
|
|
255
|
+
async validate() {
|
|
256
|
+
await this.openSocket();
|
|
257
|
+
try {
|
|
258
|
+
try {
|
|
259
|
+
await this.join(`end_users:anon-${uuid()}`, endUserJoinPayload());
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
if (!isSignatureRequiredError(error))
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
this.disconnect();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/** Joins the end-user channel for `userId` and upserts the given attributes. */
|
|
271
|
+
async identify(userId, attributes, signature = null) {
|
|
272
|
+
this.shouldBeConnected = true;
|
|
273
|
+
this.desiredJoinSignature = signature;
|
|
274
|
+
await this.ensureJoined(`end_users:${userId}`);
|
|
275
|
+
await this.enqueuePush('client_message', { kind: 'UpsertUser', attributes });
|
|
276
|
+
}
|
|
277
|
+
/** Joins (or re-joins) the end-user channel when the socket dropped since identify. */
|
|
278
|
+
async ensureEndUserChannel(userId, signature = null) {
|
|
279
|
+
this.shouldBeConnected = true;
|
|
280
|
+
this.desiredJoinSignature = signature;
|
|
281
|
+
await this.ensureJoined(`end_users:${userId}`);
|
|
282
|
+
}
|
|
283
|
+
/** Upserts a group and the current user's membership on the joined channel. */
|
|
284
|
+
async group(payload) {
|
|
285
|
+
if (!this.channelTopic || !this.channelJoined) {
|
|
286
|
+
return Promise.reject(new UserflowAuthError('Not joined to an end-user channel'));
|
|
287
|
+
}
|
|
288
|
+
await this.enqueuePush('client_message', {
|
|
289
|
+
kind: 'UpsertGroup',
|
|
290
|
+
groupExternalId: payload.groupExternalId,
|
|
291
|
+
groupSignature: payload.groupSignature,
|
|
292
|
+
groupAttributes: payload.groupAttributes,
|
|
293
|
+
membershipAttributes: payload.membershipAttributes,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
/** Push `UpsertUser` on an already-joined channel (no re-identify). */
|
|
297
|
+
async updateUser(attributes) {
|
|
298
|
+
if (!this.channelTopic || !this.channelJoined) {
|
|
299
|
+
return Promise.reject(new UserflowAuthError('Not joined to an end-user channel'));
|
|
300
|
+
}
|
|
301
|
+
await this.enqueuePush('client_message', { kind: 'UpsertUser', attributes });
|
|
302
|
+
}
|
|
303
|
+
/** Intentional teardown: stop everything, reject queued/in-flight work, clear intent. */
|
|
304
|
+
disconnect() {
|
|
305
|
+
this.shouldBeConnected = false;
|
|
306
|
+
this.desiredTopic = null;
|
|
307
|
+
this.desiredJoinSignature = null;
|
|
308
|
+
this.activeFlowSessionId = null;
|
|
309
|
+
this.clientContext = { ...DEFAULT_CLIENT_CONTEXT };
|
|
310
|
+
this.clientConditions = [];
|
|
311
|
+
this.warnedUnhandledKinds.clear();
|
|
312
|
+
this.state = 'disconnected';
|
|
313
|
+
this.cancelReconnect();
|
|
314
|
+
this.stopHeartbeat();
|
|
315
|
+
this.abortPendingConnect(new UserflowAuthError('Connection closed'));
|
|
316
|
+
this.discardInFlightPushes();
|
|
317
|
+
this.rejectPending(new UserflowAuthError('Connection closed'));
|
|
318
|
+
this.rejectQueue(new UserflowAuthError('Connection closed'));
|
|
319
|
+
this.detachAndClose(this.ws);
|
|
320
|
+
this.resetChannel();
|
|
321
|
+
}
|
|
322
|
+
/** Background handling: close but keep intent + queued pushes so `resume()` recovers. */
|
|
323
|
+
suspend() {
|
|
324
|
+
if (this.state === 'suspended')
|
|
325
|
+
return;
|
|
326
|
+
this.state = 'suspended';
|
|
327
|
+
this.cancelReconnect();
|
|
328
|
+
this.stopHeartbeat();
|
|
329
|
+
this.abortPendingConnect(new UserflowAuthError('Connection suspended'));
|
|
330
|
+
this.discardInFlightPushes();
|
|
331
|
+
this.rejectPending(new UserflowAuthError('Connection suspended'));
|
|
332
|
+
this.detachAndClose(this.ws);
|
|
333
|
+
this.resetChannel();
|
|
334
|
+
}
|
|
335
|
+
/** Foreground handling: reconnect, rejoin the desired topic, and flush the queue. */
|
|
336
|
+
resume() {
|
|
337
|
+
if (this.state !== 'suspended')
|
|
338
|
+
return;
|
|
339
|
+
if (!this.shouldBeConnected) {
|
|
340
|
+
this.state = 'disconnected';
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
this.state = 'reconnecting';
|
|
344
|
+
this.attemptEstablish();
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Eager reconnect when the host reports connectivity restored.
|
|
348
|
+
* No-op while suspended (lifecycle owns that path), while already connecting /
|
|
349
|
+
* connected, or when the SDK does not intend to be connected.
|
|
350
|
+
*/
|
|
351
|
+
reconnectNow() {
|
|
352
|
+
if (!this.shouldBeConnected)
|
|
353
|
+
return;
|
|
354
|
+
if (this.state === 'suspended' || this.state === 'connecting' || this.state === 'connected') {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
this.cancelReconnect();
|
|
358
|
+
this.backoff.reset();
|
|
359
|
+
this.state = 'reconnecting';
|
|
360
|
+
this.attemptEstablish();
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Verify the connection is really alive right now and recover fast if not.
|
|
364
|
+
* Called on foreground and other "the socket may have silently died" moments.
|
|
365
|
+
*
|
|
366
|
+
* - connected: fire an immediate heartbeat probe with a short reply deadline;
|
|
367
|
+
* a dead socket is detected within {@link heartbeatReplyTimeoutMs} instead of
|
|
368
|
+
* waiting for the next scheduled heartbeat.
|
|
369
|
+
* - reconnecting / disconnected (with intent): reconnect eagerly.
|
|
370
|
+
* - suspended / connecting: no-op (those paths already own recovery).
|
|
371
|
+
*
|
|
372
|
+
* This is the zero-dependency liveness path; it does not require any
|
|
373
|
+
* host-provided network signal.
|
|
374
|
+
*/
|
|
375
|
+
ensureAlive() {
|
|
376
|
+
if (!this.shouldBeConnected)
|
|
377
|
+
return;
|
|
378
|
+
if (this.state === 'connected' && this.ws) {
|
|
379
|
+
// A beat is already outstanding — its reply deadline will catch a death.
|
|
380
|
+
if (this.pendingHeartbeatRef !== null)
|
|
381
|
+
return;
|
|
382
|
+
this.clearHeartbeatTimer();
|
|
383
|
+
this.sendHeartbeat();
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
this.reconnectNow();
|
|
387
|
+
}
|
|
388
|
+
async ensureJoined(topic) {
|
|
389
|
+
this.desiredTopic = topic;
|
|
390
|
+
if (this.state === 'connected' && this.channelTopic === topic && this.channelJoined) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (this.state === 'connected' && this.channelTopic !== topic && this.ws) {
|
|
394
|
+
this.detachAndClose(this.ws);
|
|
395
|
+
this.resetChannel();
|
|
396
|
+
}
|
|
397
|
+
this.cancelReconnect();
|
|
398
|
+
await this.establish();
|
|
399
|
+
}
|
|
400
|
+
establish() {
|
|
401
|
+
if (this.establishPromise)
|
|
402
|
+
return this.establishPromise;
|
|
403
|
+
this.establishPromise = this.doEstablish().finally(() => {
|
|
404
|
+
this.establishPromise = null;
|
|
405
|
+
});
|
|
406
|
+
return this.establishPromise;
|
|
407
|
+
}
|
|
408
|
+
async doEstablish() {
|
|
409
|
+
this.state = 'connecting';
|
|
410
|
+
await this.openSocket();
|
|
411
|
+
if (this.desiredTopic) {
|
|
412
|
+
await this.joinChannel(this.desiredTopic);
|
|
413
|
+
}
|
|
414
|
+
this.state = 'connected';
|
|
415
|
+
this.backoff.reset();
|
|
416
|
+
this.startHeartbeat();
|
|
417
|
+
this.flush();
|
|
418
|
+
}
|
|
419
|
+
attemptEstablish() {
|
|
420
|
+
void this.establish().catch(() => {
|
|
421
|
+
if (this.shouldBeConnected && this.state !== 'suspended') {
|
|
422
|
+
this.scheduleReconnect();
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
openSocket() {
|
|
427
|
+
return new Promise((resolve, reject) => {
|
|
428
|
+
const SocketCtor = resolveSocketCtor(this.socketCtor);
|
|
429
|
+
const ws = new SocketCtor(buildWsUrl(this.serverEndpoint, this.clientToken));
|
|
430
|
+
this.ws = ws;
|
|
431
|
+
let settled = false;
|
|
432
|
+
const timer = this.scheduler.setTimeout(() => {
|
|
433
|
+
if (settled)
|
|
434
|
+
return;
|
|
435
|
+
settled = true;
|
|
436
|
+
this.pendingConnect = null;
|
|
437
|
+
this.detachAndClose(ws);
|
|
438
|
+
reject(new UserflowAuthError('WebSocket connection timed out'));
|
|
439
|
+
}, TIMEOUT_MS);
|
|
440
|
+
const finish = () => {
|
|
441
|
+
settled = true;
|
|
442
|
+
this.pendingConnect = null;
|
|
443
|
+
this.scheduler.clearTimeout(timer);
|
|
444
|
+
};
|
|
445
|
+
this.pendingConnect = {
|
|
446
|
+
reject: (error) => {
|
|
447
|
+
if (settled)
|
|
448
|
+
return;
|
|
449
|
+
finish();
|
|
450
|
+
this.detachAndClose(ws);
|
|
451
|
+
reject(error);
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
ws.onopen = () => {
|
|
455
|
+
if (settled)
|
|
456
|
+
return;
|
|
457
|
+
finish();
|
|
458
|
+
resolve();
|
|
459
|
+
};
|
|
460
|
+
ws.onmessage = (event) => this.handleMessage(event);
|
|
461
|
+
ws.onerror = () => {
|
|
462
|
+
if (!settled) {
|
|
463
|
+
finish();
|
|
464
|
+
this.detachAndClose(ws);
|
|
465
|
+
reject(new UserflowAuthError('WebSocket connection failed'));
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
this.onSocketDown(ws);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
ws.onclose = () => {
|
|
472
|
+
if (!settled) {
|
|
473
|
+
finish();
|
|
474
|
+
this.detachAndClose(ws);
|
|
475
|
+
reject(new UserflowAuthError('WebSocket closed before connect completed'));
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
this.onSocketDown(ws);
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
onSocketDown(socket) {
|
|
484
|
+
if (this.ws !== socket)
|
|
485
|
+
return;
|
|
486
|
+
this.detachAndClose(socket);
|
|
487
|
+
this.channelJoined = false;
|
|
488
|
+
this.channelJoinRef = null;
|
|
489
|
+
this.stopHeartbeat();
|
|
490
|
+
this.discardInFlightPushes();
|
|
491
|
+
this.rejectPending(new UserflowAuthError('Connection dropped'));
|
|
492
|
+
if (this.shouldBeConnected && this.state !== 'suspended') {
|
|
493
|
+
this.state = 'reconnecting';
|
|
494
|
+
this.scheduleReconnect();
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
this.state = 'disconnected';
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
scheduleReconnect() {
|
|
501
|
+
if (this.reconnectHandle !== null)
|
|
502
|
+
return;
|
|
503
|
+
const delay = this.backoff.nextDelay();
|
|
504
|
+
this.reconnectHandle = this.scheduler.setTimeout(() => {
|
|
505
|
+
this.reconnectHandle = null;
|
|
506
|
+
if (!this.shouldBeConnected || this.state === 'suspended')
|
|
507
|
+
return;
|
|
508
|
+
this.attemptEstablish();
|
|
509
|
+
}, delay);
|
|
510
|
+
}
|
|
511
|
+
cancelReconnect() {
|
|
512
|
+
if (this.reconnectHandle !== null) {
|
|
513
|
+
this.scheduler.clearTimeout(this.reconnectHandle);
|
|
514
|
+
this.reconnectHandle = null;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
startHeartbeat() {
|
|
518
|
+
this.stopHeartbeat();
|
|
519
|
+
this.scheduleNextHeartbeat();
|
|
520
|
+
}
|
|
521
|
+
stopHeartbeat() {
|
|
522
|
+
this.clearHeartbeatTimer();
|
|
523
|
+
this.clearHeartbeatReplyTimer();
|
|
524
|
+
this.pendingHeartbeatRef = null;
|
|
525
|
+
}
|
|
526
|
+
scheduleNextHeartbeat() {
|
|
527
|
+
this.clearHeartbeatTimer();
|
|
528
|
+
this.heartbeatHandle = this.scheduler.setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs);
|
|
529
|
+
}
|
|
530
|
+
clearHeartbeatTimer() {
|
|
531
|
+
if (this.heartbeatHandle !== null) {
|
|
532
|
+
this.scheduler.clearTimeout(this.heartbeatHandle);
|
|
533
|
+
this.heartbeatHandle = null;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
clearHeartbeatReplyTimer() {
|
|
537
|
+
if (this.heartbeatReplyHandle !== null) {
|
|
538
|
+
this.scheduler.clearTimeout(this.heartbeatReplyHandle);
|
|
539
|
+
this.heartbeatReplyHandle = null;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* Send one heartbeat and arm a short reply deadline. The next heartbeat is
|
|
544
|
+
* scheduled when the reply lands (see {@link handleMessage}); if the deadline
|
|
545
|
+
* fires first with the beat still pending, the socket is declared dead.
|
|
546
|
+
*/
|
|
547
|
+
sendHeartbeat() {
|
|
548
|
+
this.heartbeatHandle = null;
|
|
549
|
+
if (this.state !== 'connected' || !this.ws)
|
|
550
|
+
return;
|
|
551
|
+
// A prior beat was never answered (defensive; the reply timer normally
|
|
552
|
+
// catches this first).
|
|
553
|
+
if (this.pendingHeartbeatRef !== null) {
|
|
554
|
+
this.onSocketDown(this.ws);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const ref = this.nextRef();
|
|
558
|
+
this.pendingHeartbeatRef = ref;
|
|
559
|
+
this.ws.send(JSON.stringify([null, ref, PHOENIX_TOPIC, 'heartbeat', {}]));
|
|
560
|
+
this.armHeartbeatReplyTimeout();
|
|
561
|
+
}
|
|
562
|
+
armHeartbeatReplyTimeout() {
|
|
563
|
+
this.clearHeartbeatReplyTimer();
|
|
564
|
+
this.heartbeatReplyHandle = this.scheduler.setTimeout(() => {
|
|
565
|
+
this.heartbeatReplyHandle = null;
|
|
566
|
+
if (this.state !== 'connected' || !this.ws)
|
|
567
|
+
return;
|
|
568
|
+
if (this.pendingHeartbeatRef !== null) {
|
|
569
|
+
this.onSocketDown(this.ws);
|
|
570
|
+
}
|
|
571
|
+
}, this.heartbeatReplyTimeoutMs);
|
|
572
|
+
}
|
|
573
|
+
handleMessage(event) {
|
|
574
|
+
let frame;
|
|
575
|
+
try {
|
|
576
|
+
frame = JSON.parse(String(event.data));
|
|
577
|
+
}
|
|
578
|
+
catch {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
if (!Array.isArray(frame) || frame.length < 5)
|
|
582
|
+
return;
|
|
583
|
+
const [, id, topic, eventName, payload] = frame;
|
|
584
|
+
if (eventName === 'server_message') {
|
|
585
|
+
this.dispatchServerMessage(topic, payload);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
if (eventName !== 'phx_reply' || typeof id !== 'string')
|
|
589
|
+
return;
|
|
590
|
+
if (topic === PHOENIX_TOPIC && id === this.pendingHeartbeatRef) {
|
|
591
|
+
this.pendingHeartbeatRef = null;
|
|
592
|
+
this.clearHeartbeatReplyTimer();
|
|
593
|
+
if (this.state === 'connected')
|
|
594
|
+
this.scheduleNextHeartbeat();
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
const wait = this.pending.get(id);
|
|
598
|
+
if (!wait || wait.topic !== topic)
|
|
599
|
+
return;
|
|
600
|
+
this.pending.delete(id);
|
|
601
|
+
this.scheduler.clearTimeout(wait.timer);
|
|
602
|
+
const reply = payload;
|
|
603
|
+
if (reply.status === 'ok') {
|
|
604
|
+
wait.ok();
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
wait.fail(new UserflowAuthError(`${topic}: ${joinError(reply.response)}`));
|
|
608
|
+
}
|
|
609
|
+
dispatchServerMessage(topic, payload) {
|
|
610
|
+
if (!this.channelTopic || topic !== this.channelTopic)
|
|
611
|
+
return;
|
|
612
|
+
if (!isServerMessage(payload)) {
|
|
613
|
+
if (typeof payload === 'object' &&
|
|
614
|
+
payload !== null &&
|
|
615
|
+
'kind' in payload &&
|
|
616
|
+
typeof payload.kind === 'string') {
|
|
617
|
+
const kind = payload.kind;
|
|
618
|
+
if (!this.warnedUnhandledKinds.has(kind)) {
|
|
619
|
+
this.warnedUnhandledKinds.add(kind);
|
|
620
|
+
this.warn(`Userflow: ignoring unsupported server message kind "${kind}" ` +
|
|
621
|
+
'(not implemented by the mobile SDK)');
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
for (const handler of this.serverMessageHandlers) {
|
|
627
|
+
try {
|
|
628
|
+
handler(payload);
|
|
629
|
+
}
|
|
630
|
+
catch {
|
|
631
|
+
// Never let a subscriber break the socket message loop.
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
nextRef() {
|
|
636
|
+
this.ref += 1;
|
|
637
|
+
return String(this.ref);
|
|
638
|
+
}
|
|
639
|
+
async joinChannel(topic) {
|
|
640
|
+
this.channelTopic = topic;
|
|
641
|
+
await this.join(topic, endUserJoinPayload(this.desiredJoinSignature, this.activeFlowSessionId, this.clientContext, this.clientConditions));
|
|
642
|
+
this.channelJoined = true;
|
|
643
|
+
}
|
|
644
|
+
join(topic, payload) {
|
|
645
|
+
return this.request(topic, (joinRef, ref) => {
|
|
646
|
+
if (topic.startsWith('end_users:')) {
|
|
647
|
+
this.channelJoinRef = joinRef;
|
|
648
|
+
}
|
|
649
|
+
return [joinRef, ref, topic, 'phx_join', payload];
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
request(topic, buildFrame) {
|
|
653
|
+
return new Promise((ok, fail) => {
|
|
654
|
+
if (!this.ws || this.ws.readyState !== WS_OPEN) {
|
|
655
|
+
fail(new UserflowAuthError('WebSocket is not open'));
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const joinRef = topic.startsWith('end_users:')
|
|
659
|
+
? (this.channelJoinRef ?? this.nextRef())
|
|
660
|
+
: this.nextRef();
|
|
661
|
+
const ref = this.nextRef();
|
|
662
|
+
const timer = this.scheduler.setTimeout(() => {
|
|
663
|
+
const wait = this.pending.get(ref);
|
|
664
|
+
if (!wait)
|
|
665
|
+
return;
|
|
666
|
+
this.pending.delete(ref);
|
|
667
|
+
wait.fail(new UserflowAuthError(`${topic}: reply timed out`));
|
|
668
|
+
}, TIMEOUT_MS);
|
|
669
|
+
this.pending.set(ref, { topic, timer, ok, fail });
|
|
670
|
+
this.ws.send(JSON.stringify(buildFrame(joinRef, ref)));
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Enqueue an outbound push. Only `client_message` events pass through here.
|
|
675
|
+
* Channel joins (`phx_join`) and heartbeats bypass this gate. Meta messages
|
|
676
|
+
* such as `ToggleClientCondition` may set `skipRateLimit` so condition
|
|
677
|
+
* updates are not dropped under UpsertUser / GoToStep load.
|
|
678
|
+
*/
|
|
679
|
+
enqueuePush(event, payload, options) {
|
|
680
|
+
if (!options?.skipRateLimit && !this.rateLimiter.tryAcquire()) {
|
|
681
|
+
return Promise.reject(new UserflowRateLimitError(`Client message rate limit exceeded (${this.rateLimitCapacity}/min)`));
|
|
682
|
+
}
|
|
683
|
+
return new Promise((resolve, reject) => {
|
|
684
|
+
this.outbound.push({
|
|
685
|
+
event,
|
|
686
|
+
payload,
|
|
687
|
+
inFlight: false,
|
|
688
|
+
inFlightRef: null,
|
|
689
|
+
replay: isReplayableClientMessage(payload),
|
|
690
|
+
resolve,
|
|
691
|
+
reject,
|
|
692
|
+
});
|
|
693
|
+
this.flush();
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
flush() {
|
|
697
|
+
if (this.state !== 'connected' || !this.channelJoined || !this.ws)
|
|
698
|
+
return;
|
|
699
|
+
for (const item of this.outbound) {
|
|
700
|
+
if (item.inFlight)
|
|
701
|
+
continue;
|
|
702
|
+
this.sendPush(item);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
sendPush(item) {
|
|
706
|
+
if (!this.ws || !this.channelTopic || !this.channelJoinRef)
|
|
707
|
+
return;
|
|
708
|
+
const topic = this.channelTopic;
|
|
709
|
+
const joinRef = this.channelJoinRef;
|
|
710
|
+
const ref = this.nextRef();
|
|
711
|
+
const timer = this.scheduler.setTimeout(() => {
|
|
712
|
+
const wait = this.pending.get(ref);
|
|
713
|
+
if (!wait)
|
|
714
|
+
return;
|
|
715
|
+
this.pending.delete(ref);
|
|
716
|
+
wait.fail(new UserflowAuthError(`${topic}: reply timed out`));
|
|
717
|
+
}, TIMEOUT_MS);
|
|
718
|
+
this.pending.set(ref, {
|
|
719
|
+
topic,
|
|
720
|
+
timer,
|
|
721
|
+
ok: () => {
|
|
722
|
+
this.removeFromQueue(item);
|
|
723
|
+
item.resolve();
|
|
724
|
+
},
|
|
725
|
+
fail: (error) => {
|
|
726
|
+
this.removeFromQueue(item);
|
|
727
|
+
item.reject(error);
|
|
728
|
+
},
|
|
729
|
+
});
|
|
730
|
+
item.inFlight = true;
|
|
731
|
+
item.inFlightRef = ref;
|
|
732
|
+
this.ws.send(JSON.stringify([joinRef, ref, topic, item.event, item.payload]));
|
|
733
|
+
}
|
|
734
|
+
removeFromQueue(item) {
|
|
735
|
+
const index = this.outbound.indexOf(item);
|
|
736
|
+
if (index !== -1)
|
|
737
|
+
this.outbound.splice(index, 1);
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* On a drop/suspend, forget the in-flight reply for each queued push.
|
|
741
|
+
* Idempotent messages are reset and re-sent after the next (re)join
|
|
742
|
+
* (at-least-once). Non-idempotent attribute ops (`add` / `subtract` /
|
|
743
|
+
* `append` / `prepend`) are rejected instead, so a lost ack cannot apply
|
|
744
|
+
* the mutation twice.
|
|
745
|
+
*/
|
|
746
|
+
discardInFlightPushes() {
|
|
747
|
+
const kept = [];
|
|
748
|
+
for (const item of this.outbound) {
|
|
749
|
+
if (item.inFlight && item.inFlightRef) {
|
|
750
|
+
const wait = this.pending.get(item.inFlightRef);
|
|
751
|
+
if (wait) {
|
|
752
|
+
this.scheduler.clearTimeout(wait.timer);
|
|
753
|
+
this.pending.delete(item.inFlightRef);
|
|
754
|
+
}
|
|
755
|
+
if (!item.replay) {
|
|
756
|
+
item.reject(new UserflowAuthError('Connection dropped before acknowledgement'));
|
|
757
|
+
continue;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
item.inFlight = false;
|
|
761
|
+
item.inFlightRef = null;
|
|
762
|
+
kept.push(item);
|
|
763
|
+
}
|
|
764
|
+
this.outbound = kept;
|
|
765
|
+
}
|
|
766
|
+
rejectPending(error) {
|
|
767
|
+
for (const wait of this.pending.values()) {
|
|
768
|
+
this.scheduler.clearTimeout(wait.timer);
|
|
769
|
+
wait.fail(error);
|
|
770
|
+
}
|
|
771
|
+
this.pending.clear();
|
|
772
|
+
this.pendingHeartbeatRef = null;
|
|
773
|
+
}
|
|
774
|
+
rejectQueue(error) {
|
|
775
|
+
const items = this.outbound;
|
|
776
|
+
this.outbound = [];
|
|
777
|
+
for (const item of items)
|
|
778
|
+
item.reject(error);
|
|
779
|
+
}
|
|
780
|
+
abortPendingConnect(error) {
|
|
781
|
+
const pending = this.pendingConnect;
|
|
782
|
+
this.pendingConnect = null;
|
|
783
|
+
pending?.reject(error);
|
|
784
|
+
}
|
|
785
|
+
detachAndClose(ws) {
|
|
786
|
+
if (!ws)
|
|
787
|
+
return;
|
|
788
|
+
ws.onopen = null;
|
|
789
|
+
ws.onmessage = null;
|
|
790
|
+
ws.onerror = null;
|
|
791
|
+
ws.onclose = null;
|
|
792
|
+
try {
|
|
793
|
+
ws.close();
|
|
794
|
+
}
|
|
795
|
+
catch {
|
|
796
|
+
// ignore
|
|
797
|
+
}
|
|
798
|
+
if (this.ws === ws)
|
|
799
|
+
this.ws = null;
|
|
800
|
+
}
|
|
801
|
+
resetChannel() {
|
|
802
|
+
this.channelJoinRef = null;
|
|
803
|
+
this.channelTopic = null;
|
|
804
|
+
this.channelJoined = false;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
/** Convenience helper: open a connection, validate credentials, and close it. */
|
|
808
|
+
export function validateCredentials(clientToken, serverEndpoint, socketCtor) {
|
|
809
|
+
return new PhoenixConnection(clientToken, serverEndpoint, socketCtor).validate();
|
|
810
|
+
}
|
|
811
|
+
//# sourceMappingURL=phoenix.js.map
|