Files
discord-decomp/_bundle/Module1641.js
T
2026-11-01 12:12:55 +02:00

669 lines
24 KiB
JavaScript

// Metro module 1641 (f1642).
import _classCallCheck from "./_classCallCheck";
import _createClass from "./_createClass";
import _possibleConstructorReturn from "./_possibleConstructorReturn";
import _getPrototypeOf from "./_getPrototypeOf";
import _inherits from "./_inherits";
import "./startObservingProgress";
import Module19 from "react";
import { Platform, processColor, StyleSheet } from "react-native";
import { jsx } from "react/jsx-runtime";
import { isWeb, isJest, isReact19, shouldBeUseWeb, isFabric } from "./Module1609";
import { configureWebLayoutAnimations, saveSnapshot, getReducedMotionFromConfig, startWebLayoutAnimation, tryActivateLayoutTransition } from "./Module1660";
import Module38 from "./Module38";
import JSPropsUpdaterPaper from "./JSPropsUpdaterPaper";
import { InlinePropManager } from "./isInlineStyleTransform";
import { PropsFilter } from "./dummyListener";
import setAndForwardRef from "./setAndForwardRef";
import { enableLayoutAnimations, markNodeAsRemovable } from "./Module1650";
import { LayoutAnimationType } from "./Module1631";
import { NativeEventsManager } from "./NativeEventsManager";
import { PropsRegistryGarbageCollector } from "./unprocessProps";
import { ComponentRegistry } from "./Module1709";
import { addHTMLMutationObserver } from "./findDescendantWithExitingAnimation";
import { getReduceMotionFromConfig } from "./recognizePrefixSuffix";
import { findHostInstance } from "./Module1635";
import { ReanimatedError } from "./Module1617";
import { getViewInfo } from "./Module1719";
import { getShadowNodeWrapperFromRef } from "./Module1634";
import { flattenArray } from "./Module1703";
import { adaptViewConfig } from "./configureProps";
import { updateLayoutAnimations } from "./Module1720";
import { maybeBuild } from "./Module1721";
import { SharedTransition } from "./Module1722";
import { SkipEnteringContext } from "./SkipEntering";
import { componentWithRef } from "./Module1745";
function $mk69587($env) {
return (a0) => !(a0 ? "viewDescriptors" in a0 : a0);
}
function $mk69588($env) {
return (a0) => {
let r15;
const isArray = Array.isArray(a0);
let r9 = a0;
if (isArray) {
let r10 = a0;
if (a0) {
if (Array.isArray(a0)) {
const r16 = $env;
r15 = a0.filter($mk69587(void 0)).map($mk69588(r16));
} else {
r15 = a0?.viewDescriptors ? {} : a0;
}
r10 = r15;
}
r9 = r10;
}
return r9;
};
}
let c1297_13, c1297_14, c1297_15, c1297_16;
let env1297 = {};
env1297[12] = function _isNativeReflectConstruct() {
let c13140_0;
try {
c13140_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch ($e) {}
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
return !!c13140_0;
};
env1297[12] = _isNativeReflectConstruct2;
return _isNativeReflectConstruct2();
};
Platform;
c1297_13 = isWeb();
c1297_14 = isJest();
c1297_15 = isReact19();
c1297_16 = shouldBeUseWeb();
if (c1297_13) {
configureWebLayoutAnimations();
}
env1297[17] = 0;
export function createAnimatedComponent(a0, a1) {
let env13141 = {
$parent: env1297
};
env13141[0] = a0;
env13141[1] = a1;
if (!c1297_15) {
Module38(typeof a0 === "function" ? a0.prototype && a0.prototype.isReactComponent : typeof a0 !== "function", `Looks like you're passing a function component \`${a0.name}\` to \`createAnimatedComponent\` function which supports only class components. Please wrap your function component with \`React.forwardRef()\` or use a class component instead.`);
}
const AnimatedComponent2 = function AnimatedComponent(a0) {
_classCallCheck(this, AnimatedComponent2);
const r11 = [a0];
const r10 = _getPrototypeOf(AnimatedComponent2);
const r28 = _possibleConstructorReturn(this, (0, env1297[12])() ? Reflect.construct(r10, r11, _getPrototypeOf(this).constructor) : r10.apply(this, r11));
r28._styles = null;
r28._isFirstRender = true;
r28.jestAnimatedStyle = {
value: {}
};
r28.jestAnimatedProps = {
value: {}
};
r28._componentRef = null;
r28._componentDOMRef = null;
r28._sharedElementTransition = null;
r28._jsPropsUpdater = new JSPropsUpdaterPaper();
r28._InlinePropManager = new InlinePropManager();
r28._PropsFilter = new PropsFilter();
const reanimatedID = +env1297[17];
env1297[17] = reanimatedID + 1;
r28.reanimatedID = reanimatedID;
r28._willUnmount = false;
r28._resolveComponentRef = (a0) => {
let r5;
L8: {
if (a0 && a0.getAnimatableRef) {
r5 = a0.getAnimatableRef();
} else {
r5 = a0;
if (c1297_16) {
if (a0 && a0.elementRef) {
this._componentDOMRef = a0.elementRef.current;
r5 = a0;
break L8;
}
this._componentDOMRef = a0;
r5 = a0;
}
}
}
return r5;
};
r28._setComponentRef = setAndForwardRef({
getForwardedRef: () => this.props.forwardedRef,
setLocalRef: (a0) => {
L21: {
if (a0) {
if (a0 !== this._componentRef) {
this._componentRef = this._resolveComponentRef(a0);
this._viewInfo = void 0;
}
const props = this.props;
const { layout, entering, exiting, sharedTransitionTag } = props;
if (!layout && !entering && !exiting && !sharedTransitionTag) {
break L21;
}
if (!c1297_16) {
enableLayoutAnimations(true, false);
}
if (sharedTransitionTag) {
this._configureSharedTransition();
}
const current = this.context?.current;
if (!((entering ? isFabric() : !entering) || current || c1297_13)) {
this._configureLayoutAnimation(LayoutAnimationType.ENTERING, this.props.entering);
}
}
}
}
});
if (c1297_14) {
r28.jestAnimatedStyle = {
value: {}
};
r28.jestAnimatedProps = {
value: {}
};
}
r28.state = {
settledProps: {},
reanimatedProps: {}
};
r28.props.entering;
const current = r28.context?.current;
if (isFabric() && !current) {
r28._configureLayoutAnimation(LayoutAnimationType.ENTERING, r28.props.entering);
}
return r28;
};
_inherits(AnimatedComponent2, Module19.Component);
const r60 = _createClass(AnimatedComponent2, [{
key: "componentDidMount",
value: function componentDidMount() {
let firstChild;
if (!c1297_13) {
this._NativeEventsManager = new NativeEventsManager(this, env13141[1]);
}
const _NativeEventsManager2 = this._NativeEventsManager;
if (_NativeEventsManager2 != null) {
_NativeEventsManager2.attachEvents();
}
this._jsPropsUpdater.addOnJSPropsChangeListener(this);
this._attachAnimatedStyles();
this._InlinePropManager.attachInlineProps(this, this._getViewInfo());
const componentViewTag = this.getComponentViewTag();
if (isFabric() && componentViewTag !== -1) {
PropsRegistryGarbageCollector.registerView(componentViewTag, this);
}
if (componentViewTag !== -1) {
ComponentRegistry.register(componentViewTag, this);
}
this._configureLayoutAnimation(LayoutAnimationType.LAYOUT, this.props.layout);
this._configureLayoutAnimation(LayoutAnimationType.EXITING, this.props.exiting);
let r72 = dependencyMap;
let r73 = require;
if (c1297_13) {
const _componentDOMRef = this._componentDOMRef;
r72 = dependencyMap;
r73 = require;
if (_componentDOMRef) {
const _componentDOMRef2 = this._componentDOMRef;
const dummyClone = _componentDOMRef2.dummyClone;
if (dummyClone?.firstChild) {
do {
_componentDOMRef2.appendChild(dummyClone.firstChild);
firstChild = dummyClone?.firstChild;
} while (firstChild);
}
delete _componentDOMRef2["dummyClone"];
if (this.props.exiting) {
saveSnapshot(_componentDOMRef2);
}
if (!this.props.entering) {
this._isFirstRender = false;
return void 0;
}
if (getReducedMotionFromConfig(this.props.entering)) {
this._isFirstRender = false;
const entering = this.props.entering;
const callbackV = entering.callbackV;
if (callbackV != null) {
callbackV.call(entering, true);
}
return void 0;
}
if (this.context?.current) {
const style = _componentDOMRef2.style;
r72 = dependencyMap;
r73 = require;
if (style) {
_componentDOMRef2.style.visibility = "initial";
r72 = dependencyMap;
r73 = require;
}
} else {
startWebLayoutAnimation(this.props, _componentDOMRef2, LayoutAnimationType.ENTERING);
r72 = dependencyMap;
r73 = require;
}
}
}
if ((c1297_16 ? !c1297_16 : r73(r72[9]).isFabric()) && this._willUnmount && typeof componentViewTag === "number") {
r73(r72[16]).unmarkNodeAsRemovable(componentViewTag);
}
this._isFirstRender = false;
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
const _NativeEventsManager2 = this._NativeEventsManager;
if (_NativeEventsManager2 != null) {
_NativeEventsManager2.detachEvents();
}
this._jsPropsUpdater.removeOnJSPropsChangeListener(this);
const componentViewTag = this.getComponentViewTag();
if (isFabric() && componentViewTag !== -1) {
PropsRegistryGarbageCollector.unregisterView(componentViewTag);
}
this._detachStyles();
this._InlinePropManager.detachInlineProps();
if (this.props.sharedTransitionTag) {
this._configureSharedTransition(true);
}
const _sharedElementTransition = this._sharedElementTransition;
if (_sharedElementTransition != null) {
_sharedElementTransition.unregisterTransition(this.getComponentViewTag(), true);
}
const exiting = this.props.exiting;
if (componentViewTag !== -1) {
ComponentRegistry.unregister(componentViewTag);
}
if (c1297_13 && (this._componentDOMRef && exiting)) {
if (getReducedMotionFromConfig(exiting)) {
const callbackV = exiting.callbackV;
if (callbackV != null) {
callbackV.call(exiting, true);
}
return void 0;
}
addHTMLMutationObserver();
startWebLayoutAnimation(this.props, this._componentDOMRef, LayoutAnimationType.EXITING);
} else if (exiting && !c1297_13 && !isFabric() && !("getReduceMotion" in exiting && typeof exiting.getReduceMotion === "function" ? getReduceMotionFromConfig(exiting.getReduceMotion()) : getReduceMotionFromConfig())) {
this._configureLayoutAnimation(LayoutAnimationType.EXITING, exiting);
}
const shadowNodeWrapper2 = this._viewInfo?.shadowNodeWrapper;
if ((c1297_16 ? !c1297_16 : isFabric()) && shadowNodeWrapper2) {
markNodeAsRemovable(shadowNodeWrapper2);
}
this._willUnmount = true;
}
}, {
key: "_syncStylePropsBackToReact",
value: function _syncStylePropsBackToReact(c28920_0) {
this.setState((state) => ({
settledProps: {
...state.settledProps,
...c28920_0
}
}));
}
}, {
key: "getComponentViewTag",
value: function getComponentViewTag() {
return this._getViewInfo().viewTag;
}
}, {
key: "_detachStyles",
value: function _detachStyles() {
let r18;
const componentViewTag = this.getComponentViewTag();
if (componentViewTag !== -1 && this._styles !== null) {
let r5 = this._styles[Symbol.iterator]();
const next = r5.next;
while (true) {
const r24 = r5 === void 0 ? void 0 : (r18 = next.call(r5)).done ? r5 = void 0 : r18.value;
if (r5 === void 0) {
if (!this.props.animatedProps?.viewDescriptors) {
break;
}
this.props.animatedProps.viewDescriptors.remove(componentViewTag);
break;
}
try {
r24.viewDescriptors.remove(componentViewTag);
} catch (r28) {
if (r5 !== void 0 && typeof r5.return === "function") {
try {
r5.return();
} catch {}
}
throw r28;
}
}
}
}
}, {
key: "_updateFromNative",
value: function _updateFromNative(a0) {
const r6 = env13141[1];
if (r6?.setNativeProps) {
r6.setNativeProps(this._componentRef, a0);
} else {
const _componentRef = this._componentRef;
if (_componentRef != null) {
const setNativeProps = _componentRef.setNativeProps;
if (setNativeProps != null) {
setNativeProps.call(_componentRef, a0);
}
}
}
}
}, {
key: "_updateReanimatedProps",
value: function _updateReanimatedProps(a0) {
let r18, r29;
if (!env13141[1]?.disableReactSync) {
const r15 = {};
let c28921_0 = r15;
for (const key in a0) {
L15: {
r18 = key;
const r20 = a0[r18];
if (!(!(r18 !== "color" && !r18.endsWith("Color")) && (r20 && typeof r20 === "string"))) {
if (r18 != "top" && r18 != "bottom" && !r18.startsWith("margin")) {
const r19 = r18.startsWith("padding");
r29 = r20;
if (!r19) {
break L15;
}
}
return void 0;
}
r29 = (0, processColor)(r20);
}
r15[r18] = r29;
}
this.setState((state) => ({
reanimatedProps: {
...state.reanimatedProps,
...c28921_0
}
}));
}
}
}, {
key: "_getViewInfo",
value: function _getViewInfo() {
let _componentDOMRef, _componentRef, shadowNodeWrapper2, viewConfig, viewName2;
if (this._viewInfo !== void 0) {
return this._viewInfo;
}
if (c1297_16) {
_componentRef = this._componentRef;
_componentDOMRef = this._componentDOMRef;
shadowNodeWrapper2 = null;
viewConfig = null;
viewName2 = null;
} else {
const r9 = findHostInstance(this);
if (!r9) {
throw new ReanimatedError("Cannot find host instance for this component. Maybe it renders nothing?");
}
const viewInfo = getViewInfo(r9);
_componentRef = viewInfo.viewTag;
viewName2 = viewInfo.viewName;
viewConfig = viewInfo.viewConfig;
shadowNodeWrapper2 = isFabric() ? getShadowNodeWrapperFromRef(this, r9) : null;
_componentDOMRef = null;
}
this._viewInfo = {
viewTag: _componentRef,
viewName: viewName2,
shadowNodeWrapper: shadowNodeWrapper2,
viewConfig
};
if (_componentDOMRef) {
this._viewInfo.DOMElement = _componentDOMRef;
}
return this._viewInfo;
}
}, {
key: "_attachAnimatedStyles",
value: function _attachAnimatedStyles() {
let isStyleAttached2, _styles, viewTag, viewName, shadowNodeWrapper;
const _this = this;
const styles = this.props.style ? (function onlyAnimatedStyles(a0) {
return a0.filter((item) => item?.viewDescriptors);
})(flattenArray(this.props.style)) : [];
const animatedProps = this.props.animatedProps;
_styles = this._styles;
this._styles = styles;
const _animatedProps = this._animatedProps;
this._animatedProps = animatedProps;
const r44 = this._getViewInfo();
viewTag = r44.viewTag;
viewName = r44.viewName;
shadowNodeWrapper = r44.shadowNodeWrapper;
const viewConfig = r44.viewConfig;
if ((this.props.animatedProps?.viewDescriptors || styles.length) && viewConfig) {
adaptViewConfig(viewConfig);
}
const set = new Set(styles);
isStyleAttached2 = (a0) => {};
const r60 = _styles != null && styles.length === _styles.length && styles.every((style, index) => style === _styles[index] && style.viewDescriptors.has(viewTag));
const viewDescriptors = this.props.animatedProps?.viewDescriptors;
const r68 = viewDescriptors ? _animatedProps === this.props.animatedProps && this.props.animatedProps.viewDescriptors.has(viewTag) : !viewDescriptors;
if (!(r60 && r68)) {
if (_styles) {
const _loop = function _loop(a0) {
if (!styles.some((style) => !(style !== a0 || !style.viewDescriptors.has(viewTag)))) {
a0.viewDescriptors.remove(viewTag);
}
};
for (const _style of _styles) {
_loop(_style);
}
}
if (animatedProps && c1297_14) {
const jestAnimatedProps = this.jestAnimatedProps;
jestAnimatedProps.value = {
...this.jestAnimatedProps.value,
...animatedProps == null ? void 0 : animatedProps.initial?.value
};
if (animatedProps?.jestAnimatedValues) {
animatedProps.jestAnimatedValues.current = this.jestAnimatedProps;
}
}
if (!r60) {
set.forEach((item) => {
item.viewDescriptors.add({
tag: viewTag,
name: viewName,
shadowNodeWrapper
}, item.styleUpdaterContainer);
if (c1297_14) {
_this.jestAnimatedStyle.value = {
..._this.jestAnimatedStyle.value,
...item.initial.value
};
item.jestAnimatedValues.current = _this.jestAnimatedStyle;
}
});
}
if (_animatedProps && _animatedProps !== this.props.animatedProps) {
_animatedProps.viewDescriptors.remove(viewTag);
}
if (r68 ? !r68 : this.props.animatedProps?.viewDescriptors) {
this.props.animatedProps.viewDescriptors.add({
tag: viewTag,
name: viewName,
shadowNodeWrapper
}, this.props.animatedProps.styleUpdaterContainer);
}
}
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(a0, a1, a2) {
this._configureLayoutAnimation(LayoutAnimationType.LAYOUT, this.props.layout, a0.layout);
this._configureLayoutAnimation(LayoutAnimationType.EXITING, this.props.exiting, a0.exiting);
if (!(this.props.sharedTransitionTag === void 0 && a0.sharedTransitionTag === void 0)) {
this._configureSharedTransition();
}
const _NativeEventsManager2 = this._NativeEventsManager;
if (_NativeEventsManager2 != null) {
_NativeEventsManager2.updateEvents(a0);
}
this._attachAnimatedStyles();
this._InlinePropManager.attachInlineProps(this, this._getViewInfo());
if (c1297_13 && this.props.exiting && this._componentDOMRef) {
saveSnapshot(this._componentDOMRef);
}
if (c1297_13 && a2 && this.props.layout) {
if (getReducedMotionFromConfig(this.props.layout)) {
const layout = this.props.layout;
const callbackV = layout.callbackV;
if (callbackV != null) {
callbackV.call(layout, true);
}
return void 0;
}
tryActivateLayoutTransition(this.props, this._componentDOMRef, a2);
}
}
}, {
key: "_configureLayoutAnimation",
value: function _configureLayoutAnimation(a0, a1, a2) {
if (!c1297_13 && a1 !== a2) {
const r14 = this._isReducedMotion(a1);
let r11 = a1;
if (r14) {
r11 = void 0;
if (!a2) {
return void 0;
}
}
updateLayoutAnimations(isFabric() && a0 === LayoutAnimationType.ENTERING ? this.reanimatedID : this.getComponentViewTag(), a0, r11 && maybeBuild(r11, a0 !== LayoutAnimationType.LAYOUT ? this.props?.style : void 0, AnimatedComponent2.displayName));
}
}
}, {
key: "_configureSharedTransition",
value: function _configureSharedTransition(r7 = false) {
if (!c1297_13) {
const sharedTransitionTag = this.props.sharedTransitionTag;
if (!sharedTransitionTag) {
const _sharedElementTransition = this._sharedElementTransition;
if (_sharedElementTransition != null) {
_sharedElementTransition.unregisterTransition(this.getComponentViewTag(), r7);
}
this._sharedElementTransition = null;
return void 0;
}
let sharedTransitionStyle = this.props.sharedTransitionStyle;
if (sharedTransitionStyle == null) {
sharedTransitionStyle = this._sharedElementTransition;
}
if (sharedTransitionStyle == null) {
sharedTransitionStyle = new SharedTransition();
}
sharedTransitionStyle.registerTransition(this.getComponentViewTag(), sharedTransitionTag, r7);
this._sharedElementTransition = sharedTransitionStyle;
}
}
}, {
key: "_isReducedMotion",
value: function _isReducedMotion(a0) {
return a0 && ("getReduceMotion" in a0 && typeof a0.getReduceMotion === "function") ? getReduceMotionFromConfig(a0.getReduceMotion()) : getReduceMotionFromConfig();
}
}, {
key: "getSnapshotBeforeUpdate",
value: function getSnapshotBeforeUpdate() {
return c1297_13 ? this.props.layout ? this._componentDOMRef?.getBoundingClientRect ? this._componentDOMRef.getBoundingClientRect() : null : null : null;
}
}, {
key: "render",
value: function render() {
let r52, style4;
const r10 = this._PropsFilter.filterNonAnimatedProps(this);
const r16 = env1297;
if (c1297_14) {
r10.jestAnimatedStyle = this.jestAnimatedStyle;
r10.jestAnimatedProps = this.jestAnimatedProps;
}
if (this._isFirstRender && c1297_13 && r10.entering && !getReducedMotionFromConfig(r10.entering)) {
const isArray = Array.isArray(r10.style);
const style2 = r10.style;
if (isArray) {
style4 = style2.concat([{
visibility: "hidden"
}]);
} else {
let r31 = style2;
if (r31 == null) {
r31 = {};
}
style4 = {
...r31,
visibility: "hidden"
};
}
r10.style = style4;
}
const nativeID = this.context?.current ? void 0 : isFabric() ? `${this.reanimatedID}` : void 0;
if (c1297_14) {
let style3 = this.props.style;
if (style3) {
const style = this.props.style;
style3 = style && (Array.isArray(style) ? style.filter($mk69587(void 0)).map($mk69588(r16)) : style?.viewDescriptors ? {} : style);
}
r52 = {
jestInlineStyle: style3,
jestAnimatedStyle: this.jestAnimatedStyle,
jestAnimatedProps: this.jestAnimatedProps
};
} else {
r52 = {};
}
const r72 = {
collapsable: false
};
if (isFabric()) {
return jsx(env13141[0], {
nativeID,
...r10,
...r52,
style: {
...StyleSheet.flatten(r10.style),
...this.state.settledProps
},
...this.state.settledProps,
...this.state.reanimatedProps,
ref: this._setComponentRef,
...r72
});
}
return jsx(env13141[0], {
nativeID,
...r10,
...r52,
...this.state.reanimatedProps,
ref: this._setComponentRef,
...r72
});
}
}]);
env13141[2] = r60;
r60.contextType = SkipEnteringContext;
r60.displayName = `AnimatedComponent(${a0.displayName || a0.name || "Component"})`;
const r77 = componentWithRef((a0, a1) => jsx(env13141[2], {
...a0,
...a1 !== null ? {
forwardedRef: a1
} : null
}));
r77.displayName = a0.displayName || a0.name || "Component";
return r77;
}