265 lines
9.4 KiB
JavaScript
265 lines
9.4 KiB
JavaScript
// Metro module 263 (f264).
|
|
import _classCallCheck from "./_classCallCheck";
|
|
import _createClass from "./_createClass";
|
|
import ReactNativeElement from "./ReactNativeElement";
|
|
import * as _getTargetFromInstanceHandle from "./getTargetFromInstanceHandle";
|
|
import { unregisterObserver, registerObserver } from "./getTargetFromInstanceHandle";
|
|
import { setPlatformObject } from "./Module126";
|
|
let env274 = {};
|
|
const IntersectionObserver2 = function(a0, a1) {
|
|
let r51, r93, _rootThresholds, _thresholds;
|
|
_classCallCheck(this, IntersectionObserver2);
|
|
this._observationTargets = new Set();
|
|
if (a0 == null) {
|
|
throw new TypeError("Failed to construct 'IntersectionObserver': 1 argument required, but only 0 present.");
|
|
}
|
|
if (typeof a0 !== "function") {
|
|
throw new TypeError("Failed to construct 'IntersectionObserver': parameter 1 is not of type 'Function'.");
|
|
}
|
|
if (a1?.root != null && !(a1?.root instanceof ReactNativeElement)) {
|
|
throw new TypeError("Failed to construct 'IntersectionObserver': Failed to read the 'root' property from 'IntersectionObserverInit': The provided value is not of type '(null or ReactNativeElement)");
|
|
}
|
|
if (a1 != null && "delay" in a1) {
|
|
throw new Error("Failed to construct 'IntersectionObserver': The 'delay' option is not supported.");
|
|
}
|
|
if (a1 != null && "scrollMargin" in a1) {
|
|
throw new Error("Failed to construct 'IntersectionObserver': The 'scrollMargin' option is not supported.");
|
|
}
|
|
if (a1 != null && "trackVisibility" in a1) {
|
|
throw new Error("Failed to construct 'IntersectionObserver': The 'trackVisibility' option is not supported.");
|
|
}
|
|
this._callback = a0;
|
|
const rnRootThreshold = a1?.rnRootThreshold;
|
|
const isArray = Array.isArray(rnRootThreshold);
|
|
if (isArray) {
|
|
const r81 = rnRootThreshold.map((item) => {
|
|
let r2;
|
|
L6: {
|
|
r2 = null;
|
|
if (item != null) {
|
|
const r14 = Number(item);
|
|
if (Number.isFinite(r14)) {
|
|
if (!(r14 < 0)) {
|
|
r2 = r14;
|
|
if (!(r2 > 1)) {
|
|
break L6;
|
|
}
|
|
}
|
|
throw new RangeError("Failed to construct 'IntersectionObserver': Threshold values must be numbers between 0 and 1");
|
|
}
|
|
throw new TypeError(`Failed to read the 'rnRootThreshold' property from 'IntersectionObserverInit': The provided double value is non-finite.`);
|
|
}
|
|
}
|
|
return r2;
|
|
}).filter((item) => item != null).sort();
|
|
_rootThresholds = r81.length !== 0 ? r81 : null;
|
|
} else {
|
|
L24: {
|
|
const r50 = rnRootThreshold == null;
|
|
r51 = null;
|
|
if (!r50) {
|
|
const r53 = Number(rnRootThreshold);
|
|
if (Number.isFinite(r53)) {
|
|
if (!(r53 < 0)) {
|
|
r51 = r53;
|
|
if (!(r51 > 1)) {
|
|
break L24;
|
|
}
|
|
}
|
|
throw new RangeError("Failed to construct 'IntersectionObserver': Threshold values must be numbers between 0 and 1");
|
|
}
|
|
throw new TypeError(`Failed to read the 'rnRootThreshold' property from 'IntersectionObserverInit': The provided double value is non-finite.`);
|
|
}
|
|
}
|
|
_rootThresholds = r51 == null ? null : [r51];
|
|
}
|
|
this._rootThresholds = _rootThresholds;
|
|
const threshold = a1?.threshold;
|
|
const r88 = this._rootThresholds != null;
|
|
const isArray2 = Array.isArray(threshold);
|
|
if (isArray2) {
|
|
_thresholds = threshold.length > 0 ? threshold.map((item) => {
|
|
let r2;
|
|
L6: {
|
|
r2 = null;
|
|
if (item != null) {
|
|
const r14 = Number(item);
|
|
if (Number.isFinite(r14)) {
|
|
if (!(r14 < 0)) {
|
|
r2 = r14;
|
|
if (!(r2 > 1)) {
|
|
break L6;
|
|
}
|
|
}
|
|
throw new RangeError("Failed to construct 'IntersectionObserver': Threshold values must be numbers between 0 and 1");
|
|
}
|
|
throw new TypeError(`Failed to read the 'threshold' property from 'IntersectionObserverInit': The provided double value is non-finite.`);
|
|
}
|
|
}
|
|
return r2;
|
|
}).map((item) => item == null ? 0 : item).sort() : r88 ? [] : [0];
|
|
} else {
|
|
L39: {
|
|
const r4 = threshold == null;
|
|
r93 = null;
|
|
if (!r4) {
|
|
const r95 = Number(threshold);
|
|
if (Number.isFinite(r95)) {
|
|
if (!(r95 < 0)) {
|
|
r93 = r95;
|
|
if (!(r93 > 1)) {
|
|
break L39;
|
|
}
|
|
}
|
|
throw new RangeError("Failed to construct 'IntersectionObserver': Threshold values must be numbers between 0 and 1");
|
|
}
|
|
throw new TypeError(`Failed to read the 'threshold' property from 'IntersectionObserverInit': The provided double value is non-finite.`);
|
|
}
|
|
}
|
|
_thresholds = r93 == null ? r88 ? [] : [0] : [r93];
|
|
}
|
|
this._thresholds = _thresholds;
|
|
let _root = a1?.root;
|
|
if (_root == null) {
|
|
_root = null;
|
|
}
|
|
this._root = _root;
|
|
this._rootMargin = (function normalizeRootMargin(a0) {
|
|
let r49;
|
|
if (a0 != null && a0 !== "") {
|
|
if (typeof a0 !== "string") {
|
|
throw new TypeError("Failed to construct 'IntersectionObserver': Failed to read the 'rootMargin' property from 'IntersectionObserverInit': The provided value is not of type 'string'.");
|
|
}
|
|
const r25 = a0.trim();
|
|
if (r25 === "") {
|
|
return "0px 0px 0px 0px";
|
|
}
|
|
const r28 = r25.split(/\s+/);
|
|
if (r28.length > 4) {
|
|
throw new SyntaxError("Failed to construct 'IntersectionObserver': Failed to parse rootMargin: Too many values (expected 1-4).");
|
|
}
|
|
const r4 = /^-?\d+(\.\d+)?(px|%)$/;
|
|
for (const item of r28) {
|
|
if (!r4.test(item)) {
|
|
throw new SyntaxError(`Failed to construct 'IntersectionObserver': Failed to parse rootMargin: '${item}' is not a valid length. Only 'px' and '%' units are allowed.`);
|
|
}
|
|
}
|
|
const length = r28.length;
|
|
if (length === 1) {
|
|
r49 = [r28[0], r28[0], r28[0], r28[0]];
|
|
} else if (length === 2) {
|
|
r49 = [r28[0], r28[1], r28[0], r28[1]];
|
|
} else if (length === 3) {
|
|
r49 = [r28[0], r28[1], r28[2], r28[1]];
|
|
} else {
|
|
r49 = r28;
|
|
if (length !== 4) {
|
|
throw new SyntaxError("Failed to construct 'IntersectionObserver': Failed to parse rootMargin.");
|
|
}
|
|
}
|
|
return r49.join(" ");
|
|
}
|
|
return "0px 0px 0px 0px";
|
|
})(a1?.rootMargin);
|
|
};
|
|
const r43 = _createClass(IntersectionObserver2, [{
|
|
key: "root",
|
|
get: function get() {
|
|
return this._root;
|
|
}
|
|
}, {
|
|
key: "rootMargin",
|
|
get: function get() {
|
|
return this._rootMargin;
|
|
}
|
|
}, {
|
|
key: "thresholds",
|
|
get: function get() {
|
|
return this._thresholds;
|
|
}
|
|
}, {
|
|
key: "rnRootThresholds",
|
|
get: function get() {
|
|
return this._rootThresholds;
|
|
}
|
|
}, {
|
|
key: "delay",
|
|
get: function get() {
|
|
throw new Error("Failed to read the 'delay' property from 'IntersectionObserver': This property is not supported.");
|
|
}
|
|
}, {
|
|
key: "scrollMargin",
|
|
get: function get() {
|
|
throw new Error("Failed to read the 'scrollMargin' property from 'IntersectionObserver': This property is not supported.");
|
|
}
|
|
}, {
|
|
key: "trackVisibility",
|
|
get: function get() {
|
|
throw new Error("Failed to read the 'trackVisibility' property from 'IntersectionObserver': This property is not supported.");
|
|
}
|
|
}, {
|
|
key: "observe",
|
|
value: function observe(a0) {
|
|
if (a0 == null) {
|
|
throw new TypeError("Failed to execute 'observe' on 'IntersectionObserver': parameter 1 is null or undefined.");
|
|
}
|
|
if (a0 instanceof ReactNativeElement) {
|
|
if (!this._observationTargets.has(a0) && _getTargetFromInstanceHandle.observe({
|
|
intersectionObserverId: this._getOrCreateIntersectionObserverId(),
|
|
root: this._root,
|
|
target: a0
|
|
})) {
|
|
this._observationTargets.add(a0);
|
|
}
|
|
return void 0;
|
|
}
|
|
throw new TypeError("Failed to execute 'observe' on 'IntersectionObserver': parameter 1 is not of type 'ReactNativeElement'.");
|
|
}
|
|
}, {
|
|
key: "unobserve",
|
|
value: function unobserve(a0) {
|
|
if (a0 instanceof ReactNativeElement) {
|
|
if (this._observationTargets.has(a0)) {
|
|
const _intersectionObserverId = this._intersectionObserverId;
|
|
if (_intersectionObserverId != null) {
|
|
_getTargetFromInstanceHandle.unobserve(_intersectionObserverId, a0);
|
|
this._observationTargets.delete(a0);
|
|
if (this._observationTargets.size === 0) {
|
|
unregisterObserver(_intersectionObserverId);
|
|
this._intersectionObserverId = null;
|
|
}
|
|
} else {
|
|
console.error("Unexpected state in 'IntersectionObserver': could not find observer ID to unobserve target.");
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
throw new TypeError("Failed to execute 'unobserve' on 'IntersectionObserver': parameter 1 is not of type 'ReactNativeElement'.");
|
|
}
|
|
}, {
|
|
key: "disconnect",
|
|
value: function disconnect() {
|
|
for (const item of this._observationTargets.keys()) {
|
|
this.unobserve(item);
|
|
}
|
|
}
|
|
}, {
|
|
key: "_getOrCreateIntersectionObserverId",
|
|
value: function _getOrCreateIntersectionObserverId() {
|
|
let _intersectionObserverId = this._intersectionObserverId;
|
|
if (_intersectionObserverId == null) {
|
|
const _intersectionObserverId2 = registerObserver(this, this._callback);
|
|
this._intersectionObserverId = _intersectionObserverId2;
|
|
_intersectionObserverId = _intersectionObserverId2;
|
|
}
|
|
return _intersectionObserverId;
|
|
}
|
|
}, {
|
|
key: "__getObserverID",
|
|
value: function __getObserverID() {
|
|
return this._intersectionObserverId;
|
|
}
|
|
}]);
|
|
setPlatformObject(r43);
|
|
export default r43;
|