@userflow-tech/react-native 0.3.0 → 0.3.1
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 +325 -63
- package/docs/anchoring.md +58 -42
- package/docs/troubleshooting.md +63 -27
- package/expo-plugin/hostDependencyWarnings.d.ts +18 -0
- package/expo-plugin/hostDependencyWarnings.d.ts.map +1 -0
- package/expo-plugin/hostDependencyWarnings.js +91 -0
- package/expo-plugin/hostDependencyWarnings.js.map +1 -0
- package/expo-plugin/withUserflow.d.ts.map +1 -1
- package/expo-plugin/withUserflow.js +16 -0
- package/expo-plugin/withUserflow.js.map +1 -1
- package/lib/commonjs/anchors/AnchorRegistry.js +7 -0
- package/lib/commonjs/anchors/AnchorRegistry.js.map +1 -1
- package/lib/commonjs/anchors/elementConditionEvaluator.js +189 -55
- package/lib/commonjs/anchors/elementConditionEvaluator.js.map +1 -1
- package/lib/commonjs/anchors/elementTapMonitor.js +92 -0
- package/lib/commonjs/anchors/elementTapMonitor.js.map +1 -0
- package/lib/commonjs/anchors/elementTargetMatch.js +85 -0
- package/lib/commonjs/anchors/elementTargetMatch.js.map +1 -0
- package/lib/commonjs/anchors/fiber/findAnchorFiber.js +64 -39
- package/lib/commonjs/anchors/fiber/findAnchorFiber.js.map +1 -1
- package/lib/commonjs/anchors/fiber/touchTargetFiber.js +105 -0
- package/lib/commonjs/anchors/fiber/touchTargetFiber.js.map +1 -0
- package/lib/commonjs/anchors/resolveAnchorHost.js +2 -1
- package/lib/commonjs/anchors/resolveAnchorHost.js.map +1 -1
- package/lib/commonjs/anchors/resolveAutoAnchorHost.js +4 -2
- package/lib/commonjs/anchors/resolveAutoAnchorHost.js.map +1 -1
- package/lib/commonjs/anchors/resolveElementTargets.js +158 -0
- package/lib/commonjs/anchors/resolveElementTargets.js.map +1 -0
- package/lib/commonjs/anchors/targetPressMonitor.js +9 -3
- package/lib/commonjs/anchors/targetPressMonitor.js.map +1 -1
- package/lib/commonjs/anchors/useUserflowAnchor.js +1 -0
- package/lib/commonjs/anchors/useUserflowAnchor.js.map +1 -1
- package/lib/commonjs/anonymousId.js +16 -7
- package/lib/commonjs/anonymousId.js.map +1 -1
- package/lib/commonjs/index.js +5 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/installCheck.js +151 -0
- package/lib/commonjs/installCheck.js.map +1 -0
- package/lib/commonjs/pairing/deviceId.js +14 -11
- package/lib/commonjs/pairing/deviceId.js.map +1 -1
- package/lib/commonjs/runtime/TargetPressBridge.js +12 -1
- package/lib/commonjs/runtime/TargetPressBridge.js.map +1 -1
- package/lib/commonjs/runtime/UserflowProvider.js +6 -3
- package/lib/commonjs/runtime/UserflowProvider.js.map +1 -1
- package/lib/commonjs/storage/asyncStorage.js +67 -0
- package/lib/commonjs/storage/asyncStorage.js.map +1 -0
- package/lib/commonjs/surfaces/safeArea.js +68 -28
- package/lib/commonjs/surfaces/safeArea.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/anchors/AnchorRegistry.js +7 -0
- package/lib/module/anchors/AnchorRegistry.js.map +1 -1
- package/lib/module/anchors/elementConditionEvaluator.js +189 -55
- package/lib/module/anchors/elementConditionEvaluator.js.map +1 -1
- package/lib/module/anchors/elementTapMonitor.js +87 -0
- package/lib/module/anchors/elementTapMonitor.js.map +1 -0
- package/lib/module/anchors/elementTargetMatch.js +78 -0
- package/lib/module/anchors/elementTargetMatch.js.map +1 -0
- package/lib/module/anchors/fiber/findAnchorFiber.js +62 -39
- package/lib/module/anchors/fiber/findAnchorFiber.js.map +1 -1
- package/lib/module/anchors/fiber/touchTargetFiber.js +100 -0
- package/lib/module/anchors/fiber/touchTargetFiber.js.map +1 -0
- package/lib/module/anchors/resolveAnchorHost.js +2 -1
- package/lib/module/anchors/resolveAnchorHost.js.map +1 -1
- package/lib/module/anchors/resolveAutoAnchorHost.js +3 -3
- package/lib/module/anchors/resolveAutoAnchorHost.js.map +1 -1
- package/lib/module/anchors/resolveElementTargets.js +152 -0
- package/lib/module/anchors/resolveElementTargets.js.map +1 -0
- package/lib/module/anchors/targetPressMonitor.js +8 -3
- package/lib/module/anchors/targetPressMonitor.js.map +1 -1
- package/lib/module/anchors/useUserflowAnchor.js +1 -0
- package/lib/module/anchors/useUserflowAnchor.js.map +1 -1
- package/lib/module/anonymousId.js +15 -5
- package/lib/module/anonymousId.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/installCheck.js +139 -0
- package/lib/module/installCheck.js.map +1 -0
- package/lib/module/pairing/deviceId.js +14 -10
- package/lib/module/pairing/deviceId.js.map +1 -1
- package/lib/module/runtime/TargetPressBridge.js +12 -1
- package/lib/module/runtime/TargetPressBridge.js.map +1 -1
- package/lib/module/runtime/UserflowProvider.js +7 -4
- package/lib/module/runtime/UserflowProvider.js.map +1 -1
- package/lib/module/storage/asyncStorage.js +61 -0
- package/lib/module/storage/asyncStorage.js.map +1 -0
- package/lib/module/surfaces/safeArea.js +65 -28
- package/lib/module/surfaces/safeArea.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/src/anchors/AnchorRegistry.d.ts +7 -0
- package/lib/typescript/commonjs/src/anchors/AnchorRegistry.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/elementConditionEvaluator.d.ts +12 -16
- package/lib/typescript/commonjs/src/anchors/elementConditionEvaluator.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/elementTapMonitor.d.ts +36 -0
- package/lib/typescript/commonjs/src/anchors/elementTapMonitor.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/elementTargetMatch.d.ts +20 -0
- package/lib/typescript/commonjs/src/anchors/elementTargetMatch.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/fiber/findAnchorFiber.d.ts +17 -5
- package/lib/typescript/commonjs/src/anchors/fiber/findAnchorFiber.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/fiber/touchTargetFiber.d.ts +24 -0
- package/lib/typescript/commonjs/src/anchors/fiber/touchTargetFiber.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/resolveAnchorHost.d.ts +2 -1
- package/lib/typescript/commonjs/src/anchors/resolveAnchorHost.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/resolveAutoAnchorHost.d.ts +10 -1
- package/lib/typescript/commonjs/src/anchors/resolveAutoAnchorHost.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/resolveElementTargets.d.ts +39 -0
- package/lib/typescript/commonjs/src/anchors/resolveElementTargets.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/anchors/targetPressMonitor.d.ts +2 -0
- package/lib/typescript/commonjs/src/anchors/targetPressMonitor.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anchors/useUserflowAnchor.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/anonymousId.d.ts +2 -0
- package/lib/typescript/commonjs/src/anonymousId.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/installCheck.d.ts +33 -0
- package/lib/typescript/commonjs/src/installCheck.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/pairing/deviceId.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/TargetPressBridge.d.ts +2 -1
- package/lib/typescript/commonjs/src/runtime/TargetPressBridge.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/runtime/UserflowProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/storage/asyncStorage.d.ts +15 -0
- package/lib/typescript/commonjs/src/storage/asyncStorage.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/surfaces/safeArea.d.ts +4 -2
- package/lib/typescript/commonjs/src/surfaces/safeArea.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/version.d.ts +1 -1
- package/lib/typescript/module/src/anchors/AnchorRegistry.d.ts +7 -0
- package/lib/typescript/module/src/anchors/AnchorRegistry.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/elementConditionEvaluator.d.ts +12 -16
- package/lib/typescript/module/src/anchors/elementConditionEvaluator.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/elementTapMonitor.d.ts +36 -0
- package/lib/typescript/module/src/anchors/elementTapMonitor.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/elementTargetMatch.d.ts +20 -0
- package/lib/typescript/module/src/anchors/elementTargetMatch.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/fiber/findAnchorFiber.d.ts +17 -5
- package/lib/typescript/module/src/anchors/fiber/findAnchorFiber.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/fiber/touchTargetFiber.d.ts +24 -0
- package/lib/typescript/module/src/anchors/fiber/touchTargetFiber.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/resolveAnchorHost.d.ts +2 -1
- package/lib/typescript/module/src/anchors/resolveAnchorHost.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/resolveAutoAnchorHost.d.ts +10 -1
- package/lib/typescript/module/src/anchors/resolveAutoAnchorHost.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/resolveElementTargets.d.ts +39 -0
- package/lib/typescript/module/src/anchors/resolveElementTargets.d.ts.map +1 -0
- package/lib/typescript/module/src/anchors/targetPressMonitor.d.ts +2 -0
- package/lib/typescript/module/src/anchors/targetPressMonitor.d.ts.map +1 -1
- package/lib/typescript/module/src/anchors/useUserflowAnchor.d.ts.map +1 -1
- package/lib/typescript/module/src/anonymousId.d.ts +2 -0
- package/lib/typescript/module/src/anonymousId.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/installCheck.d.ts +33 -0
- package/lib/typescript/module/src/installCheck.d.ts.map +1 -0
- package/lib/typescript/module/src/pairing/deviceId.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/TargetPressBridge.d.ts +2 -1
- package/lib/typescript/module/src/runtime/TargetPressBridge.d.ts.map +1 -1
- package/lib/typescript/module/src/runtime/UserflowProvider.d.ts.map +1 -1
- package/lib/typescript/module/src/storage/asyncStorage.d.ts +15 -0
- package/lib/typescript/module/src/storage/asyncStorage.d.ts.map +1 -0
- package/lib/typescript/module/src/surfaces/safeArea.d.ts +4 -2
- package/lib/typescript/module/src/surfaces/safeArea.d.ts.map +1 -1
- package/lib/typescript/module/src/version.d.ts +1 -1
- package/package.json +13 -1
- package/src/anchors/AnchorRegistry.ts +12 -0
- package/src/anchors/elementConditionEvaluator.ts +235 -70
- package/src/anchors/elementTapMonitor.ts +95 -0
- package/src/anchors/elementTargetMatch.ts +90 -0
- package/src/anchors/fiber/findAnchorFiber.ts +66 -35
- package/src/anchors/fiber/touchTargetFiber.ts +125 -0
- package/src/anchors/resolveAnchorHost.ts +2 -1
- package/src/anchors/resolveAutoAnchorHost.ts +3 -3
- package/src/anchors/resolveElementTargets.ts +165 -0
- package/src/anchors/targetPressMonitor.ts +12 -3
- package/src/anchors/useUserflowAnchor.ts +1 -0
- package/src/anonymousId.ts +19 -8
- package/src/index.ts +10 -0
- package/src/installCheck.ts +191 -0
- package/src/pairing/deviceId.ts +14 -11
- package/src/runtime/TargetPressBridge.tsx +17 -1
- package/src/runtime/UserflowProvider.tsx +11 -4
- package/src/storage/asyncStorage.ts +88 -0
- package/src/surfaces/safeArea.ts +80 -40
- package/src/version.ts +1 -1
- package/vendor/core/dist/constants.d.ts +2 -0
- package/vendor/core/dist/constants.d.ts.map +1 -1
- package/vendor/core/dist/constants.js +2 -0
- package/vendor/core/dist/constants.js.map +1 -1
- package/vendor/core/dist/engine/ClientConditionEngine.d.ts +20 -1
- package/vendor/core/dist/engine/ClientConditionEngine.d.ts.map +1 -1
- package/vendor/core/dist/engine/ClientConditionEngine.js +13 -10
- package/vendor/core/dist/engine/ClientConditionEngine.js.map +1 -1
- package/vendor/core/dist/engine/UserflowCore.d.ts.map +1 -1
- package/vendor/core/dist/engine/UserflowCore.js +21 -2
- package/vendor/core/dist/engine/UserflowCore.js.map +1 -1
- package/vendor/core/dist/index.d.ts +1 -1
- package/vendor/core/dist/index.d.ts.map +1 -1
- package/vendor/core/dist/index.js.map +1 -1
- package/vendor/core/dist/version.d.ts +1 -1
- package/vendor/core/dist/version.js +1 -1
- package/vendor/core/package.json +1 -1
- package/vendor/protocol/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAsyncStorage = getAsyncStorage;
|
|
7
|
+
exports.isAsyncStorageLinked = isAsyncStorageLinked;
|
|
8
|
+
exports.resetAsyncStorageCacheForTests = resetAsyncStorageCacheForTests;
|
|
9
|
+
const ASYNC_STORAGE_NATIVE_MODULES = ['RNAsyncStorage', 'RNCAsyncStorage', 'RNC_AsyncSQLiteDBStorage', 'PlatformLocalStorage', 'AsyncSQLiteDBStorage', 'AsyncLocalStorage'];
|
|
10
|
+
let cached;
|
|
11
|
+
function loadReactNative() {
|
|
12
|
+
try {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
14
|
+
return require('react-native');
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function nativeModuleRegistered(name, reactNative) {
|
|
20
|
+
try {
|
|
21
|
+
const turbo = reactNative.TurboModuleRegistry;
|
|
22
|
+
if (typeof turbo?.get === 'function' && turbo.get(name) != null) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
// A missing turbo registry is not a failed link check.
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
return reactNative.NativeModules?.[name] != null;
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** True when some AsyncStorage native binary is in this build. */
|
|
36
|
+
function isAsyncStorageLinked() {
|
|
37
|
+
const reactNative = loadReactNative();
|
|
38
|
+
if (!reactNative) return false;
|
|
39
|
+
return ASYNC_STORAGE_NATIVE_MODULES.some(name => nativeModuleRegistered(name, reactNative));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The AsyncStorage JS API, or `null` when the package or its native module is
|
|
44
|
+
* missing. Never requires the package until the native module is registered.
|
|
45
|
+
*/
|
|
46
|
+
function getAsyncStorage() {
|
|
47
|
+
if (cached !== undefined) return cached;
|
|
48
|
+
if (typeof require !== 'function' || !isAsyncStorageLinked()) {
|
|
49
|
+
cached = null;
|
|
50
|
+
return cached;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
54
|
+
const mod = require('@react-native-async-storage/async-storage');
|
|
55
|
+
const storage = mod?.default ?? mod;
|
|
56
|
+
cached = typeof storage?.getItem === 'function' && typeof storage.setItem === 'function' && typeof storage.removeItem === 'function' ? storage : null;
|
|
57
|
+
} catch {
|
|
58
|
+
cached = null;
|
|
59
|
+
}
|
|
60
|
+
return cached;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** @internal */
|
|
64
|
+
function resetAsyncStorageCacheForTests() {
|
|
65
|
+
cached = undefined;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=asyncStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ASYNC_STORAGE_NATIVE_MODULES","cached","loadReactNative","require","nativeModuleRegistered","name","reactNative","turbo","TurboModuleRegistry","get","NativeModules","isAsyncStorageLinked","some","getAsyncStorage","undefined","mod","storage","default","getItem","setItem","removeItem","resetAsyncStorageCacheForTests"],"sourceRoot":"../../../src","sources":["storage/asyncStorage.ts"],"mappings":";;;;;;;;AAIA,MAAMA,4BAA4B,GAAG,CACnC,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAs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,EAAEE,OAAO,KAAK,UAAU,IACtC,OAAOF,OAAO,CAACG,OAAO,KAAK,UAAU,IACrC,OAAOH,OAAO,CAACI,UAAU,KAAK,UAAU,GACnCJ,OAAO,GACR,IAAI;EACZ,CAAC,CAAC,MAAM;IACNf,MAAM,GAAG,IAAI;EACf;EAEA,OAAOA,MAAM;AACf;;AAEA;AACO,SAASoB,8BAA8BA,CAAA,EAAS;EACrDpB,MAAM,GAAGa,SAAS;AACpB","ignoreList":[]}
|
|
@@ -3,42 +3,94 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.MISSING_SAFE_AREA_PROVIDER_WARNING = void 0;
|
|
6
7
|
exports.getSafeAreaInsetsContext = getSafeAreaInsetsContext;
|
|
7
8
|
exports.resetSafeAreaInsetsCacheForTests = resetSafeAreaInsetsCacheForTests;
|
|
9
|
+
exports.useParentSafeAreaInsets = useParentSafeAreaInsets;
|
|
8
10
|
exports.useUserflowSafeAreaInsets = useUserflowSafeAreaInsets;
|
|
11
|
+
var _react = _interopRequireDefault(require("react"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
13
|
const ZERO_INSETS = {
|
|
10
14
|
top: 0,
|
|
11
15
|
right: 0,
|
|
12
16
|
bottom: 0,
|
|
13
17
|
left: 0
|
|
14
18
|
};
|
|
15
|
-
let cachedHook;
|
|
16
|
-
let cachedInsetsContext;
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
+
* Used only when `react-native-safe-area-context` is not installed, so
|
|
22
|
+
* {@link useUserflowSafeAreaInsets} can call `useContext` unconditionally.
|
|
21
23
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const FallbackInsetsContext = /*#__PURE__*/_react.default.createContext(null);
|
|
25
|
+
const MISSING_SAFE_AREA_PROVIDER_WARNING = exports.MISSING_SAFE_AREA_PROVIDER_WARNING = '[Userflow] UserflowProvider is not inside a <SafeAreaProvider>, so flow cards use the ' + "device's initial safe-area insets. Wrap your app in <SafeAreaProvider> from " + 'react-native-safe-area-context.';
|
|
26
|
+
let cachedModule;
|
|
27
|
+
let warnedMissingProvider = false;
|
|
28
|
+
function loadSafeAreaModule() {
|
|
29
|
+
if (cachedModule !== undefined) return cachedModule;
|
|
24
30
|
if (typeof require !== 'function') {
|
|
25
|
-
|
|
26
|
-
return
|
|
31
|
+
cachedModule = null;
|
|
32
|
+
return null;
|
|
27
33
|
}
|
|
28
34
|
try {
|
|
29
35
|
// Optional peer — Expo / React Navigation apps usually have it.
|
|
30
36
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
31
37
|
const mod = require('react-native-safe-area-context');
|
|
32
|
-
|
|
38
|
+
cachedModule = mod?.SafeAreaInsetsContext ? mod : null;
|
|
33
39
|
} catch {
|
|
34
|
-
|
|
40
|
+
cachedModule = null;
|
|
35
41
|
}
|
|
36
|
-
return
|
|
42
|
+
return cachedModule;
|
|
43
|
+
}
|
|
44
|
+
function copyInsets(insets) {
|
|
45
|
+
if (!insets) return null;
|
|
46
|
+
const top = insets.top;
|
|
47
|
+
const right = insets.right;
|
|
48
|
+
const bottom = insets.bottom;
|
|
49
|
+
const left = insets.left;
|
|
50
|
+
if (typeof top !== 'number' || typeof right !== 'number' || typeof bottom !== 'number' || typeof left !== 'number') {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
top,
|
|
55
|
+
right,
|
|
56
|
+
bottom,
|
|
57
|
+
left
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Device insets from the optional peer, before any provider has measured. */
|
|
62
|
+
function readInitialInsets() {
|
|
63
|
+
return copyInsets(loadSafeAreaModule()?.initialWindowMetrics?.insets);
|
|
64
|
+
}
|
|
65
|
+
function warnMissingProvider() {
|
|
66
|
+
if (warnedMissingProvider || !__DEV__) return;
|
|
67
|
+
warnedMissingProvider = true;
|
|
68
|
+
// eslint-disable-next-line no-console -- intentional missing-provider diagnostic
|
|
69
|
+
console.warn(MISSING_SAFE_AREA_PROVIDER_WARNING);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Safe-area insets for flow chrome.
|
|
74
|
+
*
|
|
75
|
+
* Reads `SafeAreaInsetsContext` directly. `useSafeAreaInsets()` throws when the
|
|
76
|
+
* peer is installed but no `SafeAreaProvider` is mounted, which would take down
|
|
77
|
+
* the host tree. A missing provider falls back to `initialWindowMetrics`, then
|
|
78
|
+
* zero, and warns once in development.
|
|
79
|
+
*/
|
|
80
|
+
function insetsContext() {
|
|
81
|
+
return loadSafeAreaModule()?.SafeAreaInsetsContext ?? FallbackInsetsContext;
|
|
37
82
|
}
|
|
38
83
|
|
|
39
|
-
/**
|
|
84
|
+
/** Value from the nearest provider, or `null` when the peer or provider is absent. */
|
|
85
|
+
function useParentSafeAreaInsets() {
|
|
86
|
+
return copyInsets(_react.default.useContext(insetsContext()));
|
|
87
|
+
}
|
|
40
88
|
function useUserflowSafeAreaInsets() {
|
|
41
|
-
|
|
89
|
+
const fromProvider = useParentSafeAreaInsets();
|
|
90
|
+
if (fromProvider) return fromProvider;
|
|
91
|
+
if (!loadSafeAreaModule()) return ZERO_INSETS;
|
|
92
|
+
warnMissingProvider();
|
|
93
|
+
return readInitialInsets() ?? ZERO_INSETS;
|
|
42
94
|
}
|
|
43
95
|
|
|
44
96
|
/**
|
|
@@ -46,24 +98,12 @@ function useUserflowSafeAreaInsets() {
|
|
|
46
98
|
* In-flow banners override this so host screens do not add the inset the banner already consumed.
|
|
47
99
|
*/
|
|
48
100
|
function getSafeAreaInsetsContext() {
|
|
49
|
-
|
|
50
|
-
if (typeof require !== 'function') {
|
|
51
|
-
cachedInsetsContext = null;
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
56
|
-
const mod = require('react-native-safe-area-context');
|
|
57
|
-
cachedInsetsContext = mod.SafeAreaInsetsContext ?? null;
|
|
58
|
-
} catch {
|
|
59
|
-
cachedInsetsContext = null;
|
|
60
|
-
}
|
|
61
|
-
return cachedInsetsContext;
|
|
101
|
+
return loadSafeAreaModule()?.SafeAreaInsetsContext ?? null;
|
|
62
102
|
}
|
|
63
103
|
|
|
64
104
|
/** @internal */
|
|
65
105
|
function resetSafeAreaInsetsCacheForTests() {
|
|
66
|
-
|
|
67
|
-
|
|
106
|
+
cachedModule = undefined;
|
|
107
|
+
warnedMissingProvider = false;
|
|
68
108
|
}
|
|
69
109
|
//# sourceMappingURL=safeArea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ZERO_INSETS","top","right","bottom","left","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","e","__esModule","default","ZERO_INSETS","top","right","bottom","left","FallbackInsetsContext","React","createContext","MISSING_SAFE_AREA_PROVIDER_WARNING","exports","cachedModule","warnedMissingProvider","loadSafeAreaModule","undefined","mod","SafeAreaInsetsContext","copyInsets","insets","readInitialInsets","initialWindowMetrics","warnMissingProvider","__DEV__","console","warn","insetsContext","useParentSafeAreaInsets","useContext","useUserflowSafeAreaInsets","fromProvider","getSafeAreaInsetsContext","resetSafeAreaInsetsCacheForTests"],"sourceRoot":"../../../src","sources":["surfaces/safeArea.ts"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAS5C,MAAMG,WAAuB,GAAG;EAAEC,GAAG,EAAE,CAAC;EAAEC,KAAK,EAAE,CAAC;EAAEC,MAAM,EAAE,CAAC;EAAEC,IAAI,EAAE;AAAE,CAAC;;AAExE;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,gBA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;AAEA,SAASG,mBAAmBA,CAAA,EAAS;EACnC,IAAIT,qBAAqB,IAAI,CAACU,OAAO,EAAE;EACvCV,qBAAqB,GAAG,IAAI;EAC5B;EACAW,OAAO,CAACC,IAAI,CAACf,kCAAkC,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASgB,aAAaA,CAAA,EAA+B;EACnD,OAAOZ,kBAAkB,CAAC,CAAC,EAAEG,qBAAqB,IAAIV,qBAAqB;AAC7E;;AAEA;AACO,SAASoB,uBAAuBA,CAAA,EAAsB;EAC3D,OAAOT,UAAU,CAACV,cAAK,CAACoB,UAAU,CAACF,aAAa,CAAC,CAAC,CAAC,CAAC;AACtD;AAEO,SAASG,yBAAyBA,CAAA,EAAe;EACtD,MAAMC,YAAY,GAAGH,uBAAuB,CAAC,CAAC;EAC9C,IAAIG,YAAY,EAAE,OAAOA,YAAY;EACrC,IAAI,CAAChB,kBAAkB,CAAC,CAAC,EAAE,OAAOZ,WAAW;EAC7CoB,mBAAmB,CAAC,CAAC;EACrB,OAAOF,iBAAiB,CAAC,CAAC,IAAIlB,WAAW;AAC3C;;AAEA;AACA;AACA;AACA;AACO,SAAS6B,wBAAwBA,CAAA,EAAsC;EAC5E,OAAOjB,kBAAkB,CAAC,CAAC,EAAEG,qBAAqB,IAAI,IAAI;AAC5D;;AAEA;AACO,SAASe,gCAAgCA,CAAA,EAAS;EACvDpB,YAAY,GAAGG,SAAS;EACxBF,qBAAqB,GAAG,KAAK;AAC/B","ignoreList":[]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SDK_VERSION = void 0;
|
|
7
7
|
/** Generated by scripts/write-version.mjs — do not edit. */
|
|
8
|
-
const SDK_VERSION = exports.SDK_VERSION = '0.3.
|
|
8
|
+
const SDK_VERSION = exports.SDK_VERSION = '0.3.1';
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
|
@@ -39,6 +39,13 @@ export class AnchorRegistry {
|
|
|
39
39
|
return last;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/** Every host registered for `id`, in registration order. */
|
|
43
|
+
getAll(id) {
|
|
44
|
+
const set = this.anchors.get(id);
|
|
45
|
+
if (!set || set.size === 0) return [];
|
|
46
|
+
return [...set];
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
/** True when more than one host is registered for the same id. */
|
|
43
50
|
isAmbiguous(id) {
|
|
44
51
|
return (this.anchors.get(id)?.size ?? 0) > 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AnchorRegistry","anchors","Map","listeners","Set","register","id","host","set","get","add","emit","unregister","delete","size","last","isAmbiguous","subscribe","listener","clear","anchorRegistry"],"sourceRoot":"../../../src","sources":["anchors/AnchorRegistry.ts"],"mappings":";;AAAA;;
|
|
1
|
+
{"version":3,"names":["AnchorRegistry","anchors","Map","listeners","Set","register","id","host","set","get","add","emit","unregister","delete","size","last","getAll","isAmbiguous","subscribe","listener","clear","anchorRegistry"],"sourceRoot":"../../../src","sources":["anchors/AnchorRegistry.ts"],"mappings":";;AAAA;;AAmBA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,cAAc,CAAC;EACTC,OAAO,GAAG,IAAIC,GAAG,CAA0B,CAAC;EAC5CC,SAAS,GAAG,IAAIC,GAAG,CAAW,CAAC;EAEhDC,QAAQA,CAACC,EAAU,EAAEC,IAAgB,EAAQ;IAC3C,IAAI,CAACD,EAAE,EAAE;IACT,IAAIE,GAAG,GAAG,IAAI,CAACP,OAAO,CAACQ,GAAG,CAACH,EAAE,CAAC;IAC9B,IAAI,CAACE,GAAG,EAAE;MACRA,GAAG,GAAG,IAAIJ,GAAG,CAAC,CAAC;MACf,IAAI,CAACH,OAAO,CAACO,GAAG,CAACF,EAAE,EAAEE,GAAG,CAAC;IAC3B;IACAA,GAAG,CAACE,GAAG,CAACH,IAAI,CAAC;IACb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M,CAACM,QAAQ,CAAC;IACjC,CAAC;EACH;;EAEA;EACAC,KAAKA,CAAA,EAAS;IACZ,IAAI,CAACnB,OAAO,CAACmB,KAAK,CAAC,CAAC;IACpB,IAAI,CAACT,IAAI,CAAC,CAAC;EACb;EAEQA,IAAIA,CAAA,EAAS;IACnB,KAAK,MAAMQ,QAAQ,IAAI,IAAI,CAAChB,SAAS,EAAE;MACrCgB,QAAQ,CAAC,CAAC;IACZ;EACF;AACF;;AAEA;AACA,OAAO,MAAME,cAAc,GAAG,IAAIrB,cAAc,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { decodeMobileAutoData } from '@userflow-tech/protocol';
|
|
3
4
|
import { anchorChangeTicker } from "./anchorChangeTicker.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { elementTapMonitor } from "./elementTapMonitor.js";
|
|
6
|
+
import { fiberIsUnder, tapPathDisabled } from "./elementTargetMatch.js";
|
|
7
|
+
import { resolveElementTargets, tapMayHitSelector } from "./resolveElementTargets.js";
|
|
6
8
|
import { resolveManualAnchorId } from "./resolveManualAnchorId.js";
|
|
7
9
|
|
|
8
|
-
/**
|
|
9
|
-
const
|
|
10
|
+
/** How many hosts to measure before giving up on a crowded duplicate id. */
|
|
11
|
+
const MAX_MEASURED_HOSTS = 8;
|
|
12
|
+
|
|
13
|
+
/** Same bound tooltip measurement uses. A host that never calls back is unknown. */
|
|
14
|
+
const MEASURE_TIMEOUT_MS = 400;
|
|
10
15
|
|
|
11
16
|
/**
|
|
12
17
|
* Evaluate ELEMENT client conditions against manual anchors, fiber-resolved
|
|
13
|
-
* `testID` / `nativeID` / `accessibilityLabel` targets, and AUTO
|
|
14
|
-
* selectors.
|
|
18
|
+
* `userflowId` / `testID` / `nativeID` / `accessibilityLabel` targets, and AUTO
|
|
19
|
+
* (codeless) selectors.
|
|
15
20
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* just because the auto-anchor registry is empty. Web-interaction states
|
|
20
|
-
* (CLICK, DISABLED, …) still report unknown.
|
|
21
|
+
* PRESENT / NOT_PRESENT: any uniquely-or-not host on a visible navigator screen
|
|
22
|
+
* counts (web parity — duplicates are present). A measured 0×0 host counts as
|
|
23
|
+
* absent. AUTO `unknown` / `ambiguous` stay `null`.
|
|
21
24
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* ScrollView, opacity 0, etc.) would need async `measureInWindow` and is out
|
|
27
|
-
* of scope.
|
|
25
|
+
* CLICK / NOT_CLICK: latch from the first matching tap, including a tap on a
|
|
26
|
+
* descendant. The latch survives re-attach via `previousIsTrue` and is cleared
|
|
27
|
+
* when the server untracks. Disabled hosts are ignored. Until it latches, an
|
|
28
|
+
* AUTO selector that does not resolve reports `null`, like presence.
|
|
28
29
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* Element states are compared as string literals rather than protocol enums so
|
|
31
|
+
* the wire values stay obvious next to the branches. They match
|
|
32
|
+
* `FlowConditionElementState`.
|
|
32
33
|
*/
|
|
33
34
|
export function createElementConditionEvaluator(warn = message => {
|
|
34
35
|
if (__DEV__) {
|
|
@@ -42,51 +43,184 @@ export function createElementConditionEvaluator(warn = message => {
|
|
|
42
43
|
warnedConditionIds.add(conditionId);
|
|
43
44
|
warn(message);
|
|
44
45
|
};
|
|
45
|
-
return (condition, report) => {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
report
|
|
46
|
+
return (condition, report, context) => {
|
|
47
|
+
const elementState = condition.elementState;
|
|
48
|
+
if (elementState === 'PRESENT' || elementState === 'NOT_PRESENT') {
|
|
49
|
+
return trackPresence(condition, elementState, report, warnOnce);
|
|
50
|
+
}
|
|
51
|
+
if (elementState === 'CLICK' || elementState === 'NOT_CLICK') {
|
|
52
|
+
return trackClick(condition, elementState, report, context, warnOnce);
|
|
53
|
+
}
|
|
54
|
+
warnOnce(condition.id, `[Userflow] ELEMENT condition ${condition.id} uses unsupported elementState ` + `"${elementState ?? 'null'}" (supported: PRESENT, NOT_PRESENT, CLICK, NOT_CLICK); ` + 'leaving unknown');
|
|
55
|
+
report(null);
|
|
56
|
+
return () => {};
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function trackPresence(condition, elementState, report, warnOnce) {
|
|
60
|
+
// A synchronous result supersedes any older measurement. Only one
|
|
61
|
+
// measurement runs at a time, and a change during it re-runs once it settles
|
|
62
|
+
// instead of discarding it, so steady anchor churn cannot hold the condition
|
|
63
|
+
// at unknown.
|
|
64
|
+
let generation = 0;
|
|
65
|
+
let reportedGeneration = 0;
|
|
66
|
+
let measuring = false;
|
|
67
|
+
let changedWhileMeasuring = false;
|
|
68
|
+
let disposed = false;
|
|
69
|
+
const evaluate = () => {
|
|
70
|
+
if (disposed) return;
|
|
71
|
+
const gen = ++generation;
|
|
72
|
+
const resolution = resolveElementTargets(condition.selector);
|
|
73
|
+
if (resolution.status === 'unknown') {
|
|
74
|
+
if (!resolution.silent) warnUnknown(condition, warnOnce);
|
|
75
|
+
reportedGeneration = gen;
|
|
76
|
+
report(null);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (resolution.status === 'absent') {
|
|
80
|
+
reportedGeneration = gen;
|
|
81
|
+
report(elementState === 'PRESENT' ? false : true);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (measuring) {
|
|
85
|
+
changedWhileMeasuring = true;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
measuring = true;
|
|
89
|
+
void measureVisibility(resolution.targets).catch(() => 'unknown').then(visibility => {
|
|
90
|
+
measuring = false;
|
|
91
|
+
if (disposed) return;
|
|
92
|
+
if (gen > reportedGeneration) {
|
|
93
|
+
reportedGeneration = gen;
|
|
94
|
+
if (visibility === 'unknown') {
|
|
95
|
+
report(null);
|
|
96
|
+
} else {
|
|
97
|
+
const present = visibility === 'present';
|
|
98
|
+
report(elementState === 'PRESENT' ? present : !present);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (changedWhileMeasuring) {
|
|
102
|
+
changedWhileMeasuring = false;
|
|
103
|
+
evaluate();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
evaluate();
|
|
108
|
+
const unsubscribe = anchorChangeTicker.subscribe(evaluate);
|
|
109
|
+
return () => {
|
|
110
|
+
disposed = true;
|
|
111
|
+
unsubscribe();
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function trackClick(condition, elementState, report, context, warnOnce) {
|
|
115
|
+
if (!clickSelectorUsable(condition)) {
|
|
116
|
+
warnUnknown(condition, warnOnce);
|
|
117
|
+
report(null);
|
|
118
|
+
return () => {};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// CLICK starts false and latches true. NOT_CLICK starts true and latches false.
|
|
122
|
+
const valueWhenOccurred = elementState === 'CLICK';
|
|
123
|
+
if (context?.previousIsTrue === valueWhenOccurred) {
|
|
124
|
+
report(valueWhenOccurred);
|
|
125
|
+
return () => {};
|
|
126
|
+
}
|
|
127
|
+
let latched = false;
|
|
128
|
+
let stopWatchingResolution = () => {};
|
|
129
|
+
if (condition.selector?.type === 'AUTO') {
|
|
130
|
+
// An AUTO selector can stay unresolvable (empty auto-anchor registry, a
|
|
131
|
+
// tie between look-alikes), and then no tap can latch. Report unknown
|
|
132
|
+
// until it resolves, as presence does, rather than an unclicked value
|
|
133
|
+
// nothing could clear.
|
|
134
|
+
const reportUnclickedOnceResolvable = () => {
|
|
135
|
+
if (latched) return;
|
|
136
|
+
const resolution = resolveElementTargets(condition.selector);
|
|
137
|
+
if (resolution.status === 'unknown') {
|
|
138
|
+
if (!resolution.silent) warnUnknown(condition, warnOnce);
|
|
139
|
+
report(null);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
report(!valueWhenOccurred);
|
|
49
143
|
};
|
|
50
|
-
|
|
51
|
-
|
|
144
|
+
reportUnclickedOnceResolvable();
|
|
145
|
+
stopWatchingResolution = anchorChangeTicker.subscribe(reportUnclickedOnceResolvable);
|
|
146
|
+
} else {
|
|
147
|
+
report(!valueWhenOccurred);
|
|
148
|
+
}
|
|
149
|
+
const subscription = {
|
|
150
|
+
unsubscribe: () => {}
|
|
151
|
+
};
|
|
152
|
+
subscription.unsubscribe = elementTapMonitor.subscribe(tap => {
|
|
153
|
+
if (latched) return;
|
|
154
|
+
if (!tapMayHitSelector(condition.selector, tap)) return;
|
|
155
|
+
const resolution = resolveElementTargets(condition.selector);
|
|
156
|
+
if (resolution.status !== 'found') return;
|
|
157
|
+
const matched = resolution.targets.find(target => target.fiber != null && fiberIsUnder(tap.targetFiber, target.fiber));
|
|
158
|
+
if (!matched?.fiber) return;
|
|
159
|
+
if (tapPathDisabled(tap.targetFiber, matched.fiber)) return;
|
|
160
|
+
latched = true;
|
|
161
|
+
report(valueWhenOccurred, {
|
|
162
|
+
immediate: true
|
|
163
|
+
});
|
|
164
|
+
subscription.unsubscribe();
|
|
165
|
+
stopWatchingResolution();
|
|
166
|
+
});
|
|
167
|
+
return () => {
|
|
168
|
+
subscription.unsubscribe();
|
|
169
|
+
stopWatchingResolution();
|
|
52
170
|
};
|
|
53
171
|
}
|
|
54
|
-
function
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
172
|
+
function clickSelectorUsable(condition) {
|
|
173
|
+
const selector = condition.selector;
|
|
174
|
+
if (selector == null) return false;
|
|
175
|
+
if (selector.type === 'AUTO') {
|
|
176
|
+
// Without a fingerprint the selector can never resolve, so a definite
|
|
177
|
+
// NOT_CLICK true would start the flow on a target nobody can tap.
|
|
178
|
+
return decodeMobileAutoData(selector.autoData)?.fingerprint != null;
|
|
59
179
|
}
|
|
180
|
+
return resolveManualAnchorId(selector.css) != null;
|
|
181
|
+
}
|
|
182
|
+
function warnUnknown(condition, warnOnce) {
|
|
60
183
|
const selector = condition.selector;
|
|
61
184
|
if (selector == null) {
|
|
62
185
|
warnOnce(condition.id, `[Userflow] ELEMENT condition ${condition.id} has no selector; leaving unknown`);
|
|
63
|
-
return
|
|
186
|
+
return;
|
|
64
187
|
}
|
|
65
188
|
if (selector.type === 'AUTO') {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
warnOnce(condition.id, `[Userflow] ELEMENT condition ${condition.id} uses an AUTO (codeless) selector ` + 'that could not be resolved; leaving unknown');
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
if (resolution.status === 'ambiguous') {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
const present = resolution.status === 'found';
|
|
75
|
-
return elementState === 'PRESENT' ? present : !present;
|
|
189
|
+
warnOnce(condition.id, `[Userflow] ELEMENT condition ${condition.id} uses an AUTO (codeless) selector ` + 'that could not be resolved; leaving unknown');
|
|
190
|
+
return;
|
|
76
191
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// stay blocked rather than inventing a truth value.
|
|
86
|
-
if (resolution.status === 'ambiguous') {
|
|
87
|
-
return null;
|
|
192
|
+
warnOnce(condition.id, `[Userflow] ELEMENT condition ${condition.id} has no resolvable manual anchor id; ` + 'leaving unknown');
|
|
193
|
+
}
|
|
194
|
+
/** Measures hosts in parallel so duplicates cost one timeout, not one each. */
|
|
195
|
+
async function measureVisibility(targets) {
|
|
196
|
+
const slice = targets.slice(0, MAX_MEASURED_HOSTS);
|
|
197
|
+
const measured = await Promise.all(slice.map(measureHost));
|
|
198
|
+
if (measured.some(size => size !== 'timeout' && size.width > 0 && size.height > 0)) {
|
|
199
|
+
return 'present';
|
|
88
200
|
}
|
|
89
|
-
|
|
90
|
-
return
|
|
201
|
+
if (measured.includes('timeout') || targets.length > slice.length) return 'unknown';
|
|
202
|
+
return 'absent';
|
|
203
|
+
}
|
|
204
|
+
function measureHost(target) {
|
|
205
|
+
return new Promise(resolve => {
|
|
206
|
+
let settled = false;
|
|
207
|
+
const finish = value => {
|
|
208
|
+
if (settled) return;
|
|
209
|
+
settled = true;
|
|
210
|
+
clearTimeout(timer);
|
|
211
|
+
resolve(value);
|
|
212
|
+
};
|
|
213
|
+
const timer = setTimeout(() => finish('timeout'), MEASURE_TIMEOUT_MS);
|
|
214
|
+
try {
|
|
215
|
+
target.host.measureInWindow((_x, _y, width, height) => {
|
|
216
|
+
finish({
|
|
217
|
+
width,
|
|
218
|
+
height
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
} catch {
|
|
222
|
+
finish('timeout');
|
|
223
|
+
}
|
|
224
|
+
});
|
|
91
225
|
}
|
|
92
226
|
//# sourceMappingURL=elementConditionEvaluator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["anchorChangeTicker","
|
|
1
|
+
{"version":3,"names":["decodeMobileAutoData","anchorChangeTicker","elementTapMonitor","fiberIsUnder","tapPathDisabled","resolveElementTargets","tapMayHitSelector","resolveManualAnchorId","MAX_MEASURED_HOSTS","MEASURE_TIMEOUT_MS","createElementConditionEvaluator","warn","message","__DEV__","console","warnedConditionIds","Set","warnOnce","conditionId","has","add","condition","report","context","elementState","trackPresence","trackClick","id","generation","reportedGeneration","measuring","changedWhileMeasuring","disposed","evaluate","gen","resolution","selector","status","silent","warnUnknown","measureVisibility","targets","catch","then","visibility","present","unsubscribe","subscribe","clickSelectorUsable","valueWhenOccurred","previousIsTrue","latched","stopWatchingResolution","type","reportUnclickedOnceResolvable","subscription","tap","matched","find","target","fiber","targetFiber","immediate","autoData","fingerprint","css","slice","measured","Promise","all","map","measureHost","some","size","width","height","includes","length","resolve","settled","finish","value","clearTimeout","timer","setTimeout","host","measureInWindow","_x","_y"],"sourceRoot":"../../../src","sources":["anchors/elementConditionEvaluator.ts"],"mappings":";;AAKA,SAASA,oBAAoB,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