Files
discord-decomp/sources/by-id/module-03929-useRiveFile.js
2026-07-28 01:06:53 +03:00

810 lines
44 KiB
JavaScript

/* Metro module 3929; source: unknown; dependencies: [5, 57, 31, 27, 3912, 3909] */
import Module00005 from './module-00005.js'; /* Metro dependency 5 */
import Module00057 from './module-00057.js'; /* Metro dependency 57 */
import * as ReactNativeModule from './module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from './module-00031-React.js'; /* Metro dependency 31 */
function _fun32265(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#32265, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:6, offset: 0x0101019b, size: 188 bytes, params: 8, frame: 19
let env0_0 = require;
const isUriInput = function(a0) {
return a0 != null && typeof a0 === 'object' && 'uri' in a0;
};
const transformFilesHandledMapping = function(a0) {
var object = {};
var env0_0 = object;
if (a0 !== undefined) {
global.Object.entries(a0).forEach(_fun32268);
return object;
}
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
exports.useRiveFile = useRiveFile;
function transformFilesHandledMapping(a0) { // fn#32267, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:261, offset: 0x0101027b, size: 55 bytes, params: 2, frame: 13
if (a0 !== undefined) {
global.Object.entries(a0).forEach(_fun32268);
return {};
}
function _fun32268(a0) { // fn#32268, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:359, offset: 0x010102b2, size: 59 bytes, params: 2, frame: 14
var environment;
let value = environment.__proto__;
value = env1_3(a0, 2);
env0_0[value[0]] = parsePossibleSources(value[1]);
function parsePossibleSources(a0) { // fn#32269, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:403, offset: 0x010102ed, size: 271 bytes, params: 2, frame: 16
var fileName;
var path;
var object;
if (a0 !== null && typeof a0 === 'object' && '__type' in a0 && a0.__type === 'HybridObject<RiveImage>') {
return {image: a0};
}
const source = a0.source;
value = typeof source;
if (value === 'number') {
value = environment.__proto__.__proto__;
value = Image.resolveAssetSource(source);
if (value) {
if (value.uri) {
return {sourceAssetId: value.uri};
}
throw new global.Error('Invalid asset source provided.');
}
throw new global.Error('Invalid asset source provided.');
}
const uri = source.uri;
value = value === 'object';
if (value) {
if (uri) {
return {sourceUrl: uri};
}
fileName = source.fileName;
path = source.path;
if (value) {
if (fileName) {
object = {sourceAsset: fileName};
if (path) {
object.path = path;
}
return object;
}
throw new global.Error('Invalid source provided.');
}
throw new global.Error('Invalid source provided.');
}
fileName = source.fileName;
path = source.path;
if (value) {
if (fileName) {
object = {sourceAsset: fileName};
if (path) {
object.path = path;
}
return object;
}
throw new global.Error('Invalid source provided.');
}
const Error = global.Error;
throw new Error('Invalid source provided.');
}
}
}
function useRiveFile(a0) { // fn#32270, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:950, offset: 0x010103fc, size: 289 bytes, params: 2, frame: 18
const value = a0;
const r2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
const [property, env0_1] = env0_3(useState({'riveFile': null, 'isLoading': true, 'error': null,
riveFile: undefined}), 2);
const value6 = useMemo(_fun32271, [r2.referencedAssets]);
var env0_3 = useRef(value6);
useEffect(function() {
var env0_0 = null;
_fun32273()();
return _fun32277;
}, [isUriInput(value) ? 'uri' : 'primitive', isUriInput(value) ? value.uri : value]);
useEffect(_fun32278, [value6, property.riveFile]);
return {riveFile: property.riveFile, isLoading: property.isLoading, error: property.error};
function _fun32271() { // fn#32271, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:1113, offset: 0x0101051d, size: 29 bytes, params: 1, frame: 11
return transformFilesHandledMapping(env0_0.referencedAssets);
}
function _fun32272() { // fn#32272, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:1272, offset: 0x0101053a, size: 30 bytes, params: 1, frame: 10
_fun32273()();
return _fun32277;
function _fun32273() { // fn#32273, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:1296, offset: 0x01010558, size: 32 bytes, params: 1, frame: 12
const env0_0 = env2_2(_fun32275);
return loadRiveFile;
function* _fun32275() { // fn#32275, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:1316, offset: 0x01010581, size: 676 bytes, params: 1, frame: 18
var r7;
var r6;
var r4;
var value3;
var object;
var value4;
var value6;
var value7;
var value8;
var ArrayBuffer;
var value9;
var value10;
var binding;
var binding2;
var property;
var value11;
var RiveFileFactory;
var fromBytes;
var current;
var value12;
var value13;
var value14;
var value15;
var value16;
var binding3;
var value17;
var fromSource;
var value18;
var value19;
var value20;
var value21;
var startsWith;
var value22;
var value23;
var value24;
var binding4;
var value25;
var fromResource;
var value26;
var value27;
var value28;
var value29;
var binding5;
var value30;
var fromURL;
var value31;
var value32;
var value33;
var value34;
var value35;
var Error;
var prototype;
var error;
var value37;
var console;
var error2;
if (true) {
value = environment.__proto__.__proto__.__proto__;
reducibleJoin4: while (true) {
reduciblePort128: while (true) {
exceptionLanding125: while (true) {
try {
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin4;
}
console = global.console;
error2 = console.error;
Reflect.apply(error2, console, [error]);
Error = global.Error;
reducibleJoin127: while (true) {
if (error instanceof Error) {
r4 = error;
break reducibleJoin127;
}
Error = global.Error;
prototype = Error.prototype;
value = Object.create(prototype, {constructor: {value: Error}});
error = new Error('Failed to load Rive file');
value = error instanceof Object ? error : value;
r4 = value;
break reducibleJoin127;
}
dependencyMap({'riveFile': null, 'isLoading': false, error: r4});
break reduciblePort128;
}
return undefined;
}
try {
value3 = useState === 'uri';
} catch (error) {
break exceptionLanding125;
}
if (value3) {
try {
object = {};
} catch (error) {
break exceptionLanding125;
}
try {
} catch (error) {
break exceptionLanding125;
}
try {
object.uri = useEffect;
} catch (error) {
break exceptionLanding125;
}
r7 = object;
} else {
try {
} catch (error) {
break exceptionLanding125;
}
r7 = useEffect;
}
try {
value4 = r7 == null;
} catch (error) {
break exceptionLanding125;
}
if (value4) {
try {
} catch (error) {
break exceptionLanding125;
}
try {
object = {'riveFile': null, 'isLoading': false};
} catch (error) {
break exceptionLanding125;
}
try {
Error = global.Error;
} catch (error) {
break exceptionLanding125;
}
try {
prototype = Error.prototype;
} catch (error) {
break exceptionLanding125;
}
try {
} catch (error) {
break exceptionLanding125;
}
try {
error = new Error('No Rive file input provided.');
} catch (error) {
break exceptionLanding125;
}
try {
value37 = error instanceof Object ? error : undefined;
} catch (error) {
break exceptionLanding125;
}
try {
object.error = value37;
} catch (error) {
break exceptionLanding125;
}
try {
dependencyMap(object);
} catch (error) {
break exceptionLanding125;
}
} else {
var value5 = typeof r7;
try {
value6 = value5 === 'string';
} catch (error) {
break exceptionLanding125;
}
if (value6) {
try {
startsWith = r7.startsWith;
} catch (error) {
break exceptionLanding125;
}
try {
value22 = Reflect.apply(startsWith, r7, ['http://']);
} catch (error) {
break exceptionLanding125;
}
reducibleJoin106: while (true) {
reducibleJoin103: while (true) {
if (value22) {
value29 = environment.__proto__.__proto__.__proto__.__proto__;
try {
binding = env4_0;
} catch (error) {
break exceptionLanding125;
}
try {
binding5 = env4_1;
} catch (error) {
break exceptionLanding125;
}
try {
property = binding5[4];
} catch (error) {
break exceptionLanding125;
}
try {
value30 = binding(property);
} catch (error) {
break exceptionLanding125;
}
try {
RiveFileFactory = value30.RiveFileFactory;
} catch (error) {
break exceptionLanding125;
}
try {
fromURL = RiveFileFactory.fromURL;
} catch (error) {
break exceptionLanding125;
}
try {
binding = env3_3;
} catch (error) {
break exceptionLanding125;
}
try {
current = binding.current;
} catch (error) {
break exceptionLanding125;
}
try {
value31 = Reflect.apply(fromURL, RiveFileFactory, [r7, current]);
} catch (error) {
break exceptionLanding125;
}
yield value31;
try {
value32 = undefined;
value33 = false;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin103;
}
try {
startsWith = r7.startsWith;
} catch (error) {
break exceptionLanding125;
}
try {
value23 = Reflect.apply(startsWith, r7, ['https://']);
} catch (error) {
break exceptionLanding125;
}
if (value23) {
value29 = environment.__proto__.__proto__.__proto__.__proto__;
try {
binding = env4_0;
} catch (error) {
break exceptionLanding125;
}
try {
binding5 = env4_1;
} catch (error) {
break exceptionLanding125;
}
try {
property = binding5[4];
} catch (error) {
break exceptionLanding125;
}
try {
value30 = binding(property);
} catch (error) {
break exceptionLanding125;
}
try {
RiveFileFactory = value30.RiveFileFactory;
} catch (error) {
break exceptionLanding125;
}
try {
fromURL = RiveFileFactory.fromURL;
} catch (error) {
break exceptionLanding125;
}
try {
binding = env3_3;
} catch (error) {
break exceptionLanding125;
}
try {
current = binding.current;
} catch (error) {
break exceptionLanding125;
}
try {
value31 = Reflect.apply(fromURL, RiveFileFactory, [r7, current]);
} catch (error) {
break exceptionLanding125;
}
yield value31;
try {
value32 = undefined;
value33 = false;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin103;
}
value24 = environment.__proto__.__proto__.__proto__.__proto__;
try {
binding = env4_0;
} catch (error) {
break exceptionLanding125;
}
try {
binding4 = env4_1;
} catch (error) {
break exceptionLanding125;
}
try {
property = binding4[4];
} catch (error) {
break exceptionLanding125;
}
try {
value25 = binding(property);
} catch (error) {
break exceptionLanding125;
}
try {
RiveFileFactory = value25.RiveFileFactory;
} catch (error) {
break exceptionLanding125;
}
try {
fromResource = RiveFileFactory.fromResource;
} catch (error) {
break exceptionLanding125;
}
try {
binding = env3_3;
} catch (error) {
break exceptionLanding125;
}
try {
current = binding.current;
} catch (error) {
break exceptionLanding125;
}
try {
value26 = Reflect.apply(fromResource, RiveFileFactory, [r7, current]);
} catch (error) {
break exceptionLanding125;
}
yield value26;
try {
value27 = undefined;
value28 = false;
} catch (error) {
break exceptionLanding125;
}
reducibleJoin104: while (true) {
if (value28) {
return value27;
}
r6 = value27;
break reducibleJoin104;
}
value34 = environment.__proto__.__proto__;
try {
env2_0 = r6;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin106;
}
if (value33) {
return value32;
}
r6 = value32;
value34 = environment.__proto__.__proto__;
try {
env2_0 = r6;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin106;
}
} else {
try {
value7 = value5 === 'number';
} catch (error) {
break exceptionLanding125;
}
reducibleJoin106: while (true) {
reducibleJoin58: while (true) {
if (!value7) {
try {
value8 = 'uri' in r7;
} catch (error) {
break exceptionLanding125;
}
if (value8) {
value16 = environment.__proto__.__proto__.__proto__.__proto__;
try {
binding = env4_0;
} catch (error) {
break exceptionLanding125;
}
try {
binding3 = env4_1;
} catch (error) {
break exceptionLanding125;
}
try {
property = binding3[4];
} catch (error) {
break exceptionLanding125;
}
try {
value17 = binding(property);
} catch (error) {
break exceptionLanding125;
}
try {
RiveFileFactory = value17.RiveFileFactory;
} catch (error) {
break exceptionLanding125;
}
try {
fromSource = RiveFileFactory.fromSource;
} catch (error) {
break exceptionLanding125;
}
try {
binding = env3_3;
} catch (error) {
break exceptionLanding125;
}
try {
current = binding.current;
} catch (error) {
break exceptionLanding125;
}
try {
value18 = Reflect.apply(fromSource, RiveFileFactory, [r7, current]);
} catch (error) {
break exceptionLanding125;
}
yield value18;
try {
value19 = undefined;
value20 = false;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin58;
}
try {
ArrayBuffer = global.ArrayBuffer;
} catch (error) {
break exceptionLanding125;
}
try {
value9 = r7 instanceof ArrayBuffer;
} catch (error) {
break exceptionLanding125;
}
reducibleJoin107: while (true) {
reducibleJoin106: while (true) {
if (value9) {
value10 = environment.__proto__.__proto__.__proto__.__proto__;
try {
binding = env4_0;
} catch (error) {
break exceptionLanding125;
}
try {
binding2 = env4_1;
} catch (error) {
break exceptionLanding125;
}
try {
property = binding2[4];
} catch (error) {
break exceptionLanding125;
}
try {
value11 = binding(property);
} catch (error) {
break exceptionLanding125;
}
try {
RiveFileFactory = value11.RiveFileFactory;
} catch (error) {
break exceptionLanding125;
}
try {
fromBytes = RiveFileFactory.fromBytes;
} catch (error) {
break exceptionLanding125;
}
try {
binding = env3_3;
} catch (error) {
break exceptionLanding125;
}
try {
current = binding.current;
} catch (error) {
break exceptionLanding125;
}
try {
value12 = Reflect.apply(fromBytes, RiveFileFactory, [r7, current]);
} catch (error) {
break exceptionLanding125;
}
yield value12;
try {
value13 = undefined;
value14 = false;
} catch (error) {
break exceptionLanding125;
}
if (value14) {
return value13;
}
value15 = environment.__proto__.__proto__;
try {
env2_0 = value13;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin106;
}
break reducibleJoin106;
}
try {
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin107;
}
try {
object = {'riveFile': null, 'isLoading': false, 'error': null};
} catch (error) {
break exceptionLanding125;
}
value35 = environment.__proto__.__proto__;
try {
binding = env2_0;
} catch (error) {
break exceptionLanding125;
}
try {
object.riveFile = binding;
} catch (error) {
break exceptionLanding125;
}
try {
dependencyMap(object);
} catch (error) {
break exceptionLanding125;
}
return undefined;
}
value16 = environment.__proto__.__proto__.__proto__.__proto__;
try {
binding = env4_0;
} catch (error) {
break exceptionLanding125;
}
try {
binding3 = env4_1;
} catch (error) {
break exceptionLanding125;
}
try {
property = binding3[4];
} catch (error) {
break exceptionLanding125;
}
try {
value17 = binding(property);
} catch (error) {
break exceptionLanding125;
}
try {
RiveFileFactory = value17.RiveFileFactory;
} catch (error) {
break exceptionLanding125;
}
try {
fromSource = RiveFileFactory.fromSource;
} catch (error) {
break exceptionLanding125;
}
try {
binding = env3_3;
} catch (error) {
break exceptionLanding125;
}
try {
current = binding.current;
} catch (error) {
break exceptionLanding125;
}
try {
value18 = Reflect.apply(fromSource, RiveFileFactory, [r7, current]);
} catch (error) {
break exceptionLanding125;
}
yield value18;
try {
value19 = undefined;
value20 = false;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin58;
}
if (value20) {
return value19;
}
value21 = environment.__proto__.__proto__;
try {
env2_0 = value19;
} catch (error) {
break exceptionLanding125;
}
break reducibleJoin106;
}
}
try {
} catch (error) {
break exceptionLanding125;
}
try {
object = {'riveFile': null, 'isLoading': false, 'error': null};
} catch (error) {
break exceptionLanding125;
}
try {
binding = env2_0;
} catch (error) {
break exceptionLanding125;
}
try {
object.riveFile = binding;
} catch (error) {
break exceptionLanding125;
}
try {
dependencyMap(object);
} catch (error) {
break exceptionLanding125;
}
}
}
}
function loadRiveFile() { // fn#32276, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:1982, offset: 0x00c3945f, size: 30 bytes, params: 1, frame: 13
return env0_0.apply(this, arguments);
}
}
function _fun32277() { // fn#32277, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:2052, offset: 0x01010825, size: 54 bytes, params: 1, frame: 12
var value2;
if (env0_0) {
value2 = environment.__proto__.__proto__;
(require(3909) /* metro dependency 3909 */).callDispose(env0_0);
}
}
}
function _fun32278() { // fn#32278, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4078:2126, offset: 0x0101085b, size: 82 bytes, params: 1, frame: 13
var riveFileBinding;
if (env0_3.current !== Module00005 && riveFile && Module00005) {
riveFileBinding = riveFile;
riveFileBinding.updateReferencedAssets({data: Module00005});
env0_3.current = Module00005;
}
}
}
}
global.__d(_fun32265, 3929, [5, 57, 31, 27, 3912,
3909]) /* metro module 3929, dependencies: [5, 57, 31, 27, 3912, 3909] */;