stream-chat-react-native-core 9.7.0 → 9.7.1-beta.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/lib/commonjs/components/Message/utils/measureInWindow.js +49 -8
- package/lib/commonjs/components/Message/utils/measureInWindow.js.map +1 -1
- package/lib/commonjs/components/UIComponents/PortalWhileClosingView.js +6 -13
- package/lib/commonjs/components/UIComponents/PortalWhileClosingView.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Message/utils/measureInWindow.js +49 -8
- package/lib/module/components/Message/utils/measureInWindow.js.map +1 -1
- package/lib/module/components/UIComponents/PortalWhileClosingView.js +6 -13
- package/lib/module/components/UIComponents/PortalWhileClosingView.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Message/utils/measureInWindow.d.ts +12 -2
- package/lib/typescript/components/Message/utils/measureInWindow.d.ts.map +1 -1
- package/lib/typescript/components/UIComponents/PortalWhileClosingView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Message/utils/__tests__/measureInWindow.test.ts +178 -0
- package/src/components/Message/utils/measureInWindow.ts +57 -6
- package/src/components/UIComponents/PortalWhileClosingView.tsx +9 -14
- package/src/version.json +1 -1
|
@@ -1,18 +1,59 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", {
|
|
2
2
|
value: true
|
|
3
3
|
});
|
|
4
|
-
exports.measureInWindow = void 0;
|
|
4
|
+
exports.measureInWindow = exports.isMeasuredRectBogus = void 0;
|
|
5
5
|
var _reactNative = require("react-native");
|
|
6
|
+
var SCREEN_BOUND_MULTIPLIER = 2;
|
|
7
|
+
var isMeasuredRectBogus = (x, y, w, h) => {
|
|
8
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(w) || !Number.isFinite(h)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (w <= 0 || h <= 0) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
var _Dimensions$get = _reactNative.Dimensions.get('screen'),
|
|
15
|
+
width = _Dimensions$get.width,
|
|
16
|
+
height = _Dimensions$get.height;
|
|
17
|
+
if (width <= 0 || height <= 0) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return Math.abs(x) > width * SCREEN_BOUND_MULTIPLIER || Math.abs(y) > height * SCREEN_BOUND_MULTIPLIER;
|
|
21
|
+
};
|
|
22
|
+
exports.isMeasuredRectBogus = isMeasuredRectBogus;
|
|
6
23
|
var measureInWindow = (node, insets) => {
|
|
7
24
|
return new Promise((resolve, reject) => {
|
|
8
25
|
var handle = node.current;
|
|
9
|
-
if (!handle)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
x,
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
if (!handle) {
|
|
27
|
+
return reject(new Error('The native handle could not be found while invoking measureInWindow.'));
|
|
28
|
+
}
|
|
29
|
+
handle.measureInWindow((x, y, w, h) => {
|
|
30
|
+
if (!isMeasuredRectBogus(x, y, w, h)) {
|
|
31
|
+
resolve({
|
|
32
|
+
h,
|
|
33
|
+
w,
|
|
34
|
+
x,
|
|
35
|
+
y: y + (_reactNative.Platform.OS === 'android' ? insets.top : 0)
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (typeof handle.measure !== 'function') {
|
|
40
|
+
resolve({
|
|
41
|
+
h,
|
|
42
|
+
w,
|
|
43
|
+
x,
|
|
44
|
+
y: y + (_reactNative.Platform.OS === 'android' ? insets.top : 0)
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
handle.measure((_x, _y, width, height, pageX, pageY) => {
|
|
49
|
+
resolve({
|
|
50
|
+
h: height,
|
|
51
|
+
w: width,
|
|
52
|
+
x: pageX,
|
|
53
|
+
y: pageY
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
16
57
|
});
|
|
17
58
|
};
|
|
18
59
|
exports.measureInWindow = measureInWindow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","measureInWindow","node","insets","Promise","resolve","reject","handle","current","Error","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","SCREEN_BOUND_MULTIPLIER","isMeasuredRectBogus","x","y","w","h","Number","isFinite","_Dimensions$get","Dimensions","get","width","height","Math","abs","exports","measureInWindow","node","insets","Promise","resolve","reject","handle","current","Error","Platform","OS","top","measure","_x","_y","pageX","pageY"],"sourceRoot":"../../../../../src","sources":["components/Message/utils/measureInWindow.ts"],"mappings":";;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAMC,uBAAuB,GAAG,CAAC;AAS1B,IAAMC,mBAAmB,GAAGA,CAACC,CAAS,EAAEC,CAAS,EAAEC,CAAS,EAAEC,CAAS,KAAc;EAC1F,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACL,CAAC,CAAC,IAAI,CAACI,MAAM,CAACC,QAAQ,CAACJ,CAAC,CAAC,IAAI,CAACG,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,IAAI,CAACE,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAC,EAAE;IAC5F,OAAO,IAAI;EACb;EACA,IAAID,CAAC,IAAI,CAAC,IAAIC,CAAC,IAAI,CAAC,EAAE;IACpB,OAAO,IAAI;EACb;EACA,IAAAG,eAAA,GAA0BC,uBAAU,CAACC,GAAG,CAAC,QAAQ,CAAC;IAA1CC,KAAK,GAAAH,eAAA,CAALG,KAAK;IAAEC,MAAM,GAAAJ,eAAA,CAANI,MAAM;EACrB,IAAID,KAAK,IAAI,CAAC,IAAIC,MAAM,IAAI,CAAC,EAAE;IAE7B,OAAO,KAAK;EACd;EACA,OACEC,IAAI,CAACC,GAAG,CAACZ,CAAC,CAAC,GAAGS,KAAK,GAAGX,uBAAuB,IAAIa,IAAI,CAACC,GAAG,CAACX,CAAC,CAAC,GAAGS,MAAM,GAAGZ,uBAAu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CAAC;EACJ,CAAC,CAAC;AACJ,CAAC;AAACjB,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ var _reactNative = require("react-native");
|
|
|
7
7
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
8
8
|
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
9
9
|
var _reactNativeTeleport = require("react-native-teleport");
|
|
10
|
+
var _measureInWindow = require("../../components/Message/utils/measureInWindow");
|
|
10
11
|
var _hooks = require("../../hooks");
|
|
11
12
|
var _stateStore = require("../../state-store");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -67,21 +68,13 @@ var useSyncingApi = (portalHostName, registrationId) => {
|
|
|
67
68
|
if (!hasActiveId && !isClosing) {
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
var absolute = {
|
|
72
|
-
x,
|
|
73
|
-
y: y + (_reactNative.Platform.OS === 'android' ? insets.top : 0)
|
|
74
|
-
};
|
|
71
|
+
(0, _measureInWindow.measureInWindow)(containerRef, insets).then(rect => {
|
|
75
72
|
placeholderLayout.value = {
|
|
76
|
-
h:
|
|
77
|
-
w:
|
|
73
|
+
h: rect.h,
|
|
74
|
+
w: rect.w
|
|
78
75
|
};
|
|
79
|
-
(0, _stateStore.setClosingPortalLayout)(portalHostName, registrationId,
|
|
80
|
-
|
|
81
|
-
h: height,
|
|
82
|
-
w: width
|
|
83
|
-
});
|
|
84
|
-
});
|
|
76
|
+
(0, _stateStore.setClosingPortalLayout)(portalHostName, registrationId, rect);
|
|
77
|
+
}).catch(() => {});
|
|
85
78
|
});
|
|
86
79
|
(0, _react.useEffect)(() => {
|
|
87
80
|
if (hasActiveId || isClosing) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeSafeAreaContext","_reactNativeTeleport","_hooks","_stateStore","_jsxRuntime","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PortalWhileClosingView","children","portalHostName","portalName","registrationIdRef","useRef","current","createClosingPortalLayoutRegistrationId","registrationId","_useSyncingApi","useSyncingApi","syncPortalLayout","containerRef","placeholderLayout","shouldTeleport","useShouldTeleportToClosingPortal","useEffect","clearClosingPortalLayout","placeholderStyle","useAnimatedStyle","height","value","h","width","w","jsxs","Fragment","jsx","Portal","hostName","undefined","name","View","collapsable","ref","onLayout","pointerEvents","style","testID","exports","useSharedValue","insets","useSafeAreaInsets","hasActiveId","useHasActiveId","isClosing","useIsOverlayClosing","useStableCallback","measureInWindow","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeSafeAreaContext","_reactNativeTeleport","_measureInWindow","_hooks","_stateStore","_jsxRuntime","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PortalWhileClosingView","children","portalHostName","portalName","registrationIdRef","useRef","current","createClosingPortalLayoutRegistrationId","registrationId","_useSyncingApi","useSyncingApi","syncPortalLayout","containerRef","placeholderLayout","shouldTeleport","useShouldTeleportToClosingPortal","useEffect","clearClosingPortalLayout","placeholderStyle","useAnimatedStyle","height","value","h","width","w","jsxs","Fragment","jsx","Portal","hostName","undefined","name","View","collapsable","ref","onLayout","pointerEvents","style","testID","exports","useSharedValue","insets","useSafeAreaInsets","hasActiveId","useHasActiveId","isClosing","useIsOverlayClosing","useStableCallback","measureInWindow","then","rect","setClosingPortalLayout","catch","bottom","useMemo"],"sourceRoot":"../../../../src","sources":["components/UIComponents/PortalWhileClosingView.tsx"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IA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,EAAE0C,IAAI,CAAC;IAC9D,CAAC,CAAC,CACDE,KAAK,CAAC,MAAM,CAEb,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,IAAApC,gBAAS,EAAC,MAAM;IACd,IAAI2B,WAAW,IAAIE,SAAS,EAAE;MAC5BlC,gBAAgB,CAAC,CAAC;IACpB;EACF,CAAC,EAAE,CAAC8B,MAAM,CAACY,MAAM,EAAER,SAAS,EAAEF,WAAW,EAAEhC,gBAAgB,CAAC,CAAC;EAE7D,OAAO,IAAA2C,cAAO,EACZ,OAAO;IAAE3C,gBAAgB;IAAEC,YAAY;IAAEC;EAAkB,CAAC,CAAC,EAC7D,CAACA,iBAAiB,EAAEF,gBAAgB,CACtC,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,18 +1,59 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", {
|
|
2
2
|
value: true
|
|
3
3
|
});
|
|
4
|
-
exports.measureInWindow = void 0;
|
|
4
|
+
exports.measureInWindow = exports.isMeasuredRectBogus = void 0;
|
|
5
5
|
var _reactNative = require("react-native");
|
|
6
|
+
var SCREEN_BOUND_MULTIPLIER = 2;
|
|
7
|
+
var isMeasuredRectBogus = (x, y, w, h) => {
|
|
8
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(w) || !Number.isFinite(h)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (w <= 0 || h <= 0) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
var _Dimensions$get = _reactNative.Dimensions.get('screen'),
|
|
15
|
+
width = _Dimensions$get.width,
|
|
16
|
+
height = _Dimensions$get.height;
|
|
17
|
+
if (width <= 0 || height <= 0) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return Math.abs(x) > width * SCREEN_BOUND_MULTIPLIER || Math.abs(y) > height * SCREEN_BOUND_MULTIPLIER;
|
|
21
|
+
};
|
|
22
|
+
exports.isMeasuredRectBogus = isMeasuredRectBogus;
|
|
6
23
|
var measureInWindow = (node, insets) => {
|
|
7
24
|
return new Promise((resolve, reject) => {
|
|
8
25
|
var handle = node.current;
|
|
9
|
-
if (!handle)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
x,
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
if (!handle) {
|
|
27
|
+
return reject(new Error('The native handle could not be found while invoking measureInWindow.'));
|
|
28
|
+
}
|
|
29
|
+
handle.measureInWindow((x, y, w, h) => {
|
|
30
|
+
if (!isMeasuredRectBogus(x, y, w, h)) {
|
|
31
|
+
resolve({
|
|
32
|
+
h,
|
|
33
|
+
w,
|
|
34
|
+
x,
|
|
35
|
+
y: y + (_reactNative.Platform.OS === 'android' ? insets.top : 0)
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (typeof handle.measure !== 'function') {
|
|
40
|
+
resolve({
|
|
41
|
+
h,
|
|
42
|
+
w,
|
|
43
|
+
x,
|
|
44
|
+
y: y + (_reactNative.Platform.OS === 'android' ? insets.top : 0)
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
handle.measure((_x, _y, width, height, pageX, pageY) => {
|
|
49
|
+
resolve({
|
|
50
|
+
h: height,
|
|
51
|
+
w: width,
|
|
52
|
+
x: pageX,
|
|
53
|
+
y: pageY
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
16
57
|
});
|
|
17
58
|
};
|
|
18
59
|
exports.measureInWindow = measureInWindow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","measureInWindow","node","insets","Promise","resolve","reject","handle","current","Error","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","SCREEN_BOUND_MULTIPLIER","isMeasuredRectBogus","x","y","w","h","Number","isFinite","_Dimensions$get","Dimensions","get","width","height","Math","abs","exports","measureInWindow","node","insets","Promise","resolve","reject","handle","current","Error","Platform","OS","top","measure","_x","_y","pageX","pageY"],"sourceRoot":"../../../../../src","sources":["components/Message/utils/measureInWindow.ts"],"mappings":";;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAWA,IAAMC,uBAAuB,GAAG,CAAC;AAS1B,IAAMC,mBAAmB,GAAGA,CAACC,CAAS,EAAEC,CAAS,EAAEC,CAAS,EAAEC,CAAS,KAAc;EAC1F,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACL,CAAC,CAAC,IAAI,CAACI,MAAM,CAACC,QAAQ,CAACJ,CAAC,CAAC,IAAI,CAACG,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,IAAI,CAACE,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAC,EAAE;IAC5F,OAAO,IAAI;EACb;EACA,IAAID,CAAC,IAAI,CAAC,IAAIC,CAAC,IAAI,CAAC,EAAE;IACpB,OAAO,IAAI;EACb;EACA,IAAAG,eAAA,GAA0BC,uBAAU,CAACC,GAAG,CAAC,QAAQ,CAAC;IAA1CC,KAAK,GAAAH,eAAA,CAALG,KAAK;IAAEC,MAAM,GAAAJ,eAAA,CAANI,MAAM;EACrB,IAAID,KAAK,IAAI,CAAC,IAAIC,MAAM,IAAI,CAAC,EAAE;IAE7B,OAAO,KAAK;EACd;EACA,OACEC,IAAI,CAACC,GAAG,CAACZ,CAAC,CAAC,GAAGS,KAAK,GAAGX,uBAAuB,IAAIa,IAAI,CAACC,GAAG,CAACX,CAAC,CAAC,GAAGS,MAAM,GAAGZ,uBAAuB;AAEnG,CAAC;AAACe,OAAA,CAAAd,mBAAA,GAAAA,mBAAA;AAEK,IAAMe,eAAe,GAAGA,CAC7BC,IAAkC,EAClCC,MAAkB,KACQ;EAC1B,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtC,IAAMC,MAAM,GAAGL,IAAI,CAACM,OAAO;IAC3B,IAAI,CAACD,MAAM,EAAE;MACX,OAAOD,MAAM,CACX,IAAIG,KAAK,CAAC,sEAAsE,CAClF,CAAC;IACH;IAEAF,MAAM,CAACN,eAAe,CAAC,CAACd,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,KAAK;MACrC,IAAI,CAACJ,mBAAmB,CAACC,CAAC,EAAEC,CAAC,EAAEC,CAAC,EAAEC,CAAC,CAAC,EAAE;QACpCe,OAAO,CAAC;UAAEf,CAAC;UAAED,CAAC;UAAEF,CAAC;UAAEC,CAAC,EAAEA,CAAC,IAAIsB,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,MAAM,CAACS,GAAG,GAAG,CAAC;QAAE,CAAC,CAAC;QACzE;MACF;MAMA,IAAI,OAAOL,MAAM,CAACM,OAAO,KAAK,UAAU,EAAE;QACxCR,OAAO,CAAC;UAAEf,CAAC;UAAED,CAAC;UAAEF,CAAC;UAAEC,CAAC,EAAEA,CAAC,IAAIsB,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAGR,MAAM,CAACS,GAAG,GAAG,CAAC;QAAE,CAAC,CAAC;QACzE;MACF;MAEAL,MAAM,CAACM,OAAO,CAAC,CAACC,EAAE,EAAEC,EAAE,EAAEnB,KAAK,EAAEC,MAAM,EAAEmB,KAAK,EAAEC,KAAK,KAAK;QACtDZ,OAAO,CAAC;UAAEf,CAAC,EAAEO,MAAM;UAAER,CAAC,EAAEO,KAAK;UAAET,CAAC,EAAE6B,KAAK;UAAE5B,CAAC,EAAE6B;QAAM,CAAC,CAAC;MACtD,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC;AAACjB,OAAA,CAAAC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ var _reactNative = require("react-native");
|
|
|
7
7
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
8
8
|
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
9
9
|
var _reactNativeTeleport = require("react-native-teleport");
|
|
10
|
+
var _measureInWindow = require("../../components/Message/utils/measureInWindow");
|
|
10
11
|
var _hooks = require("../../hooks");
|
|
11
12
|
var _stateStore = require("../../state-store");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -67,21 +68,13 @@ var useSyncingApi = (portalHostName, registrationId) => {
|
|
|
67
68
|
if (!hasActiveId && !isClosing) {
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
var absolute = {
|
|
72
|
-
x,
|
|
73
|
-
y: y + (_reactNative.Platform.OS === 'android' ? insets.top : 0)
|
|
74
|
-
};
|
|
71
|
+
(0, _measureInWindow.measureInWindow)(containerRef, insets).then(rect => {
|
|
75
72
|
placeholderLayout.value = {
|
|
76
|
-
h:
|
|
77
|
-
w:
|
|
73
|
+
h: rect.h,
|
|
74
|
+
w: rect.w
|
|
78
75
|
};
|
|
79
|
-
(0, _stateStore.setClosingPortalLayout)(portalHostName, registrationId,
|
|
80
|
-
|
|
81
|
-
h: height,
|
|
82
|
-
w: width
|
|
83
|
-
});
|
|
84
|
-
});
|
|
76
|
+
(0, _stateStore.setClosingPortalLayout)(portalHostName, registrationId, rect);
|
|
77
|
+
}).catch(() => {});
|
|
85
78
|
});
|
|
86
79
|
(0, _react.useEffect)(() => {
|
|
87
80
|
if (hasActiveId || isClosing) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeSafeAreaContext","_reactNativeTeleport","_hooks","_stateStore","_jsxRuntime","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PortalWhileClosingView","children","portalHostName","portalName","registrationIdRef","useRef","current","createClosingPortalLayoutRegistrationId","registrationId","_useSyncingApi","useSyncingApi","syncPortalLayout","containerRef","placeholderLayout","shouldTeleport","useShouldTeleportToClosingPortal","useEffect","clearClosingPortalLayout","placeholderStyle","useAnimatedStyle","height","value","h","width","w","jsxs","Fragment","jsx","Portal","hostName","undefined","name","View","collapsable","ref","onLayout","pointerEvents","style","testID","exports","useSharedValue","insets","useSafeAreaInsets","hasActiveId","useHasActiveId","isClosing","useIsOverlayClosing","useStableCallback","measureInWindow","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeSafeAreaContext","_reactNativeTeleport","_measureInWindow","_hooks","_stateStore","_jsxRuntime","_jsxFileName","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PortalWhileClosingView","children","portalHostName","portalName","registrationIdRef","useRef","current","createClosingPortalLayoutRegistrationId","registrationId","_useSyncingApi","useSyncingApi","syncPortalLayout","containerRef","placeholderLayout","shouldTeleport","useShouldTeleportToClosingPortal","useEffect","clearClosingPortalLayout","placeholderStyle","useAnimatedStyle","height","value","h","width","w","jsxs","Fragment","jsx","Portal","hostName","undefined","name","View","collapsable","ref","onLayout","pointerEvents","style","testID","exports","useSharedValue","insets","useSafeAreaInsets","hasActiveId","useHasActiveId","isClosing","useIsOverlayClosing","useStableCallback","measureInWindow","then","rect","setClosingPortalLayout","catch","bottom","useMemo"],"sourceRoot":"../../../../src","sources":["components/UIComponents/PortalWhileClosingView.tsx"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AAEA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAO2B,IAAAQ,WAAA,GAAAR,OAAA;AAAA,IAAAS,YAAA;AAAA,SAAAV,wBAAAW,CAAA,EAAAC,CAAA,6BAAAC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EAE7D,OAAO,IAAA2C,cAAO,EACZ,OAAO;IAAE3C,gBAAgB;IAAEC,YAAY;IAAEC;EAAkB,CAAC,CAAC,EAC7D,CAACA,iBAAiB,EAAEF,gBAAgB,CACtC,CAAC;AACH,CAAC","ignoreList":[]}
|
package/lib/module/version.json
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { EdgeInsets } from 'react-native-safe-area-context';
|
|
4
|
-
|
|
4
|
+
type MeasuredRect = {
|
|
5
5
|
x: number;
|
|
6
6
|
y: number;
|
|
7
7
|
w: number;
|
|
8
8
|
h: number;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* `measureInWindow` can return wildly out of bounds coordinates on Android when the native window has
|
|
12
|
+
* been forced edge-to-edge behind React Native's back (i.e a library setting `FLAG_LAYOUT_NO_LIMITS`,
|
|
13
|
+
* as `react-native-system-navigation-bar` does for a transparent nav bar) while RN's own edge-to-edge
|
|
14
|
+
* (`edgeToEdgeEnabled`) is off. In that state the window relative measurement is corrupted and would
|
|
15
|
+
* return a position of the View far offscreen.
|
|
16
|
+
*/
|
|
17
|
+
export declare const isMeasuredRectBogus: (x: number, y: number, w: number, h: number) => boolean;
|
|
18
|
+
export declare const measureInWindow: (node: React.RefObject<View | null>, insets: EdgeInsets) => Promise<MeasuredRect>;
|
|
19
|
+
export {};
|
|
10
20
|
//# sourceMappingURL=measureInWindow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measureInWindow.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/utils/measureInWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"measureInWindow.d.ts","sourceRoot":"","sources":["../../../../../src/components/Message/utils/measureInWindow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,IAAI,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,KAAK,YAAY,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAUnE;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,KAAG,OAehF,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,MAAM,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,EAClC,QAAQ,UAAU,KACjB,OAAO,CAAC,YAAY,CA6BtB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PortalWhileClosingView.d.ts","sourceRoot":"","sources":["../../../../src/components/UIComponents/PortalWhileClosingView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PortalWhileClosingView.d.ts","sourceRoot":"","sources":["../../../../src/components/UIComponents/PortalWhileClosingView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAA8B,MAAM,OAAO,CAAC;AAkBrE,KAAK,2BAA2B,GAAG;IACjC;;;OAGG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,sBAAsB,GAAI,2CAIpC,2BAA2B,sBA0C7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stream-chat-react-native-core",
|
|
3
3
|
"description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
|
|
4
|
-
"version": "9.7.
|
|
4
|
+
"version": "9.7.1-beta.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"company": "Stream.io Inc",
|
|
7
7
|
"name": "Stream.io Inc"
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { Dimensions, Platform, View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { EdgeInsets } from 'react-native-safe-area-context';
|
|
4
|
+
|
|
5
|
+
import { isMeasuredRectBogus, measureInWindow } from '../measureInWindow';
|
|
6
|
+
|
|
7
|
+
// `measureInWindow` is globally mocked in jest-setup so other suites don't hit native
|
|
8
|
+
// measurement; this suite exercises the real implementation.
|
|
9
|
+
jest.unmock('../measureInWindow');
|
|
10
|
+
|
|
11
|
+
// screen 400x800 => bogus threshold is |x| > 800 and |y| > 1600 (2x each)
|
|
12
|
+
const SCREEN = { fontScale: 1, height: 800, scale: 2, width: 400 };
|
|
13
|
+
const INSETS: EdgeInsets = { bottom: 10, left: 0, right: 0, top: 24 };
|
|
14
|
+
|
|
15
|
+
const setPlatform = (os: typeof Platform.OS) => {
|
|
16
|
+
Object.defineProperty(Platform, 'OS', { configurable: true, get: () => os });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type MeasureInWindowTuple = [number, number, number, number];
|
|
20
|
+
type MeasureTuple = [number, number, number, number, number, number];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Builds a fake native handle whose `measureInWindow`/`measure` callbacks fire synchronously
|
|
24
|
+
* (as Fabric does). Omitting `measure` produces a handle without the method, exercising the
|
|
25
|
+
* "no fallback available" branch.
|
|
26
|
+
*/
|
|
27
|
+
const makeNode = ({
|
|
28
|
+
measure,
|
|
29
|
+
measureInWindow: miw,
|
|
30
|
+
}: {
|
|
31
|
+
measure?: MeasureTuple;
|
|
32
|
+
measureInWindow: MeasureInWindowTuple;
|
|
33
|
+
}): { current: View | null } => {
|
|
34
|
+
const handle: Record<string, unknown> = {
|
|
35
|
+
measureInWindow: (cb: (...args: MeasureInWindowTuple) => void) => cb(...miw),
|
|
36
|
+
};
|
|
37
|
+
if (measure) {
|
|
38
|
+
handle.measure = (cb: (...args: MeasureTuple) => void) => cb(...measure);
|
|
39
|
+
}
|
|
40
|
+
return { current: handle as unknown as View };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
describe('isMeasuredRectBogus', () => {
|
|
44
|
+
beforeEach(() => {
|
|
45
|
+
jest.spyOn(Dimensions, 'get').mockReturnValue(SCREEN);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
jest.restoreAllMocks();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('accepts a normal on-screen rect', () => {
|
|
53
|
+
expect(isMeasuredRectBogus(50, 300, 200, 40)).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('accepts a rect within the 2x margin (e.g. partially off-screen)', () => {
|
|
57
|
+
expect(isMeasuredRectBogus(50, 1500, 200, 40)).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it.each([
|
|
61
|
+
['NaN x', [NaN, 10, 20, 20]],
|
|
62
|
+
['NaN y', [10, NaN, 20, 20]],
|
|
63
|
+
['Infinity x', [Infinity, 10, 20, 20]],
|
|
64
|
+
['-Infinity y', [10, -Infinity, 20, 20]],
|
|
65
|
+
['NaN width', [10, 10, NaN, 20]],
|
|
66
|
+
['Infinity height', [10, 10, 20, Infinity]],
|
|
67
|
+
] as [string, MeasureInWindowTuple][])('flags non-finite values: %s', (_label, [x, y, w, h]) => {
|
|
68
|
+
expect(isMeasuredRectBogus(x, y, w, h)).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it.each([
|
|
72
|
+
['zero width', [10, 10, 0, 40]],
|
|
73
|
+
['zero height', [10, 10, 40, 0]],
|
|
74
|
+
['negative width', [10, 10, -5, 40]],
|
|
75
|
+
['negative height', [10, 10, 40, -5]],
|
|
76
|
+
] as [string, MeasureInWindowTuple][])(
|
|
77
|
+
'flags non-positive dimensions: %s',
|
|
78
|
+
(_label, [x, y, w, h]) => {
|
|
79
|
+
expect(isMeasuredRectBogus(x, y, w, h)).toBe(true);
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
it.each([
|
|
84
|
+
['huge y (the FLAG_LAYOUT_NO_LIMITS failure)', [50, 29000, 40, 36]],
|
|
85
|
+
['huge x', [29000, 300, 40, 36]],
|
|
86
|
+
['huge negative x', [-2000, 300, 40, 36]],
|
|
87
|
+
['huge negative y', [50, -2000, 40, 36]],
|
|
88
|
+
] as [string, MeasureInWindowTuple][])(
|
|
89
|
+
'flags coordinates beyond 2x the screen: %s',
|
|
90
|
+
(_label, [x, y, w, h]) => {
|
|
91
|
+
expect(isMeasuredRectBogus(x, y, w, h)).toBe(true);
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
it('treats the exact 2x boundary as valid and just past it as bogus', () => {
|
|
96
|
+
// bounds are 800 (x) and 1600 (y); the check uses strict `>`
|
|
97
|
+
expect(isMeasuredRectBogus(800, 1600, 40, 36)).toBe(false);
|
|
98
|
+
expect(isMeasuredRectBogus(801, 300, 40, 36)).toBe(true);
|
|
99
|
+
expect(isMeasuredRectBogus(50, 1601, 40, 36)).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('trusts the measurement when screen dimensions are unavailable', () => {
|
|
103
|
+
jest.spyOn(Dimensions, 'get').mockReturnValue({ ...SCREEN, height: 0, width: 0 });
|
|
104
|
+
expect(isMeasuredRectBogus(99999, 99999, 40, 36)).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
describe('measureInWindow', () => {
|
|
109
|
+
const originalOS = Platform.OS;
|
|
110
|
+
|
|
111
|
+
beforeEach(() => {
|
|
112
|
+
jest.spyOn(Dimensions, 'get').mockReturnValue(SCREEN);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
afterEach(() => {
|
|
116
|
+
jest.restoreAllMocks();
|
|
117
|
+
setPlatform(originalOS);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('rejects when the node is not mounted', async () => {
|
|
121
|
+
await expect(measureInWindow({ current: null }, INSETS)).rejects.toThrow(/native handle/);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('healthy measurement (primary path)', () => {
|
|
125
|
+
it('resolves with the window rect unchanged on iOS', async () => {
|
|
126
|
+
setPlatform('ios');
|
|
127
|
+
const node = makeNode({ measureInWindow: [10, 300, 200, 40] });
|
|
128
|
+
await expect(measureInWindow(node, INSETS)).resolves.toEqual({
|
|
129
|
+
h: 40,
|
|
130
|
+
w: 200,
|
|
131
|
+
x: 10,
|
|
132
|
+
y: 300,
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('compensates by insets.top on Android', async () => {
|
|
137
|
+
setPlatform('android');
|
|
138
|
+
const node = makeNode({ measureInWindow: [10, 300, 200, 40] });
|
|
139
|
+
await expect(measureInWindow(node, INSETS)).resolves.toEqual({
|
|
140
|
+
h: 40,
|
|
141
|
+
w: 200,
|
|
142
|
+
x: 10,
|
|
143
|
+
y: 324,
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe('bogus measurement (measure() fallback)', () => {
|
|
149
|
+
it('falls back to root-relative pageX/pageY', async () => {
|
|
150
|
+
setPlatform('ios');
|
|
151
|
+
const node = makeNode({
|
|
152
|
+
measure: [0, 0, 64, 36, 12, 717],
|
|
153
|
+
measureInWindow: [28903, 29088, 64, 36],
|
|
154
|
+
});
|
|
155
|
+
await expect(measureInWindow(node, INSETS)).resolves.toEqual({ h: 36, w: 64, x: 12, y: 717 });
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('does not add insets.top to the fallback, since pageY already accounts for it', async () => {
|
|
159
|
+
setPlatform('android');
|
|
160
|
+
const node = makeNode({
|
|
161
|
+
measure: [0, 0, 64, 36, 12, 717],
|
|
162
|
+
measureInWindow: [28903, 29088, 64, 36],
|
|
163
|
+
});
|
|
164
|
+
await expect(measureInWindow(node, INSETS)).resolves.toEqual({ h: 36, w: 64, x: 12, y: 717 });
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('returns the compensated window rect when no measure() fallback is available', async () => {
|
|
168
|
+
setPlatform('android');
|
|
169
|
+
const node = makeNode({ measureInWindow: [28903, 29088, 64, 36] });
|
|
170
|
+
await expect(measureInWindow(node, INSETS)).resolves.toEqual({
|
|
171
|
+
h: 36,
|
|
172
|
+
w: 64,
|
|
173
|
+
x: 28903,
|
|
174
|
+
y: 29112,
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -1,20 +1,71 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Platform, View } from 'react-native';
|
|
2
|
+
import { Dimensions, Platform, View } from 'react-native';
|
|
3
3
|
import { EdgeInsets } from 'react-native-safe-area-context';
|
|
4
4
|
|
|
5
|
+
type MeasuredRect = { x: number; y: number; w: number; h: number };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* How many screen lengths away from the origin a measured coordinate may fall before we treat it as
|
|
9
|
+
* bogus. Real targets (a view currently on screen) always measure well within one screen and the failure
|
|
10
|
+
* mode we guard against is off by tens of screens, so a generous multiplier cleanly separates the two
|
|
11
|
+
* with no risk of false positives on legitimate values.
|
|
12
|
+
*/
|
|
13
|
+
const SCREEN_BOUND_MULTIPLIER = 2;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `measureInWindow` can return wildly out of bounds coordinates on Android when the native window has
|
|
17
|
+
* been forced edge-to-edge behind React Native's back (i.e a library setting `FLAG_LAYOUT_NO_LIMITS`,
|
|
18
|
+
* as `react-native-system-navigation-bar` does for a transparent nav bar) while RN's own edge-to-edge
|
|
19
|
+
* (`edgeToEdgeEnabled`) is off. In that state the window relative measurement is corrupted and would
|
|
20
|
+
* return a position of the View far offscreen.
|
|
21
|
+
*/
|
|
22
|
+
export const isMeasuredRectBogus = (x: number, y: number, w: number, h: number): boolean => {
|
|
23
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(w) || !Number.isFinite(h)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (w <= 0 || h <= 0) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
const { width, height } = Dimensions.get('screen');
|
|
30
|
+
if (width <= 0 || height <= 0) {
|
|
31
|
+
// can't reason about bounds, trust the measurement
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return (
|
|
35
|
+
Math.abs(x) > width * SCREEN_BOUND_MULTIPLIER || Math.abs(y) > height * SCREEN_BOUND_MULTIPLIER
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
5
39
|
export const measureInWindow = (
|
|
6
40
|
node: React.RefObject<View | null>,
|
|
7
41
|
insets: EdgeInsets,
|
|
8
|
-
): Promise<
|
|
42
|
+
): Promise<MeasuredRect> => {
|
|
9
43
|
return new Promise((resolve, reject) => {
|
|
10
44
|
const handle = node.current;
|
|
11
|
-
if (!handle)
|
|
45
|
+
if (!handle) {
|
|
12
46
|
return reject(
|
|
13
47
|
new Error('The native handle could not be found while invoking measureInWindow.'),
|
|
14
48
|
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handle.measureInWindow((x, y, w, h) => {
|
|
52
|
+
if (!isMeasuredRectBogus(x, y, w, h)) {
|
|
53
|
+
resolve({ h, w, x, y: y + (Platform.OS === 'android' ? insets.top : 0) });
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// If `measureInWindow` returned an out of bounds rect, fallback to `measure()`, whose
|
|
58
|
+
// `pageX`/`pageY` are relative to the app root and are the same coordinate space as the window.
|
|
59
|
+
// They will stays correct when the window frame has been mutated out from under
|
|
60
|
+
// React Native.
|
|
61
|
+
if (typeof handle.measure !== 'function') {
|
|
62
|
+
resolve({ h, w, x, y: y + (Platform.OS === 'android' ? insets.top : 0) });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
15
65
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
66
|
+
handle.measure((_x, _y, width, height, pageX, pageY) => {
|
|
67
|
+
resolve({ h: height, w: width, x: pageX, y: pageY });
|
|
68
|
+
});
|
|
69
|
+
});
|
|
19
70
|
});
|
|
20
71
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { ReactNode, useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
6
|
import { Portal } from 'react-native-teleport';
|
|
7
7
|
|
|
8
|
+
import { measureInWindow } from '../../components/Message/utils/measureInWindow';
|
|
8
9
|
import { useStableCallback } from '../../hooks';
|
|
9
10
|
import {
|
|
10
11
|
clearClosingPortalLayout,
|
|
@@ -124,20 +125,14 @@ const useSyncingApi = (portalHostName: string, registrationId: string) => {
|
|
|
124
125
|
return;
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
setClosingPortalLayout(portalHostName, registrationId, {
|
|
136
|
-
...absolute,
|
|
137
|
-
h: height,
|
|
138
|
-
w: width,
|
|
128
|
+
measureInWindow(containerRef, insets)
|
|
129
|
+
.then((rect) => {
|
|
130
|
+
placeholderLayout.value = { h: rect.h, w: rect.w };
|
|
131
|
+
setClosingPortalLayout(portalHostName, registrationId, rect);
|
|
132
|
+
})
|
|
133
|
+
.catch(() => {
|
|
134
|
+
// the container isn't measurable yet; the next layout/effect pass will retry
|
|
139
135
|
});
|
|
140
|
-
});
|
|
141
136
|
});
|
|
142
137
|
|
|
143
138
|
useEffect(() => {
|
package/src/version.json
CHANGED