decord/beta/source/modules/user_settings/UserSettingsProtoUtils.tsx

43 lines
1.4 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 16:32:48 +00:00
// Module ID: 2047
// Function ID: 2048
// Name: UserSettingsProtoUtils
2026-10-12 16:32:48 +00:00
// Dependencies: [1247, 2]
// Exports: createModifiedProto, getProtoFieldClass
2026-10-12 16:32:48 +00:00
// Module 2047 (UserSettingsProtoUtils)
import ProtoUtils from "ProtoUtils" /* 1247 */;
import size from "module_2" /* 2 */;
const result = size.fileFinishedImporting("modules/user_settings/UserSettingsProtoUtils.tsx");
export const getProtoFieldClass = function getProtoFieldClass(PreloadedUserSettings, field) {
2026-10-01 14:13:23 +00:00
let closure_0 = field;
const fields = PreloadedUserSettings.fields;
2026-10-01 14:13:23 +00:00
const found = fields.find((localName) => localName.localName === field);
if (null == found) {
const _Error = Error;
const _String = String;
const _HermesInternal = HermesInternal;
throw Error("Unknown proto field name " + String(field));
} else {
return found.T();
}
};
export const createModifiedProto = function createModifiedProto(favoriteGifs, fn, protoFieldClass, PreloadedUserSettings, arg4) {
2026-10-01 14:13:23 +00:00
let fromBinaryResult;
if (null != favoriteGifs) {
2026-10-01 14:13:23 +00:00
const fromBinary = protoFieldClass.fromBinary;
const toBinaryResult = protoFieldClass.toBinary(favoriteGifs);
2026-10-01 14:13:23 +00:00
fromBinaryResult = fromBinary(toBinaryResult, ProtoUtils.BINARY_READ_OPTIONS);
} else {
fromBinaryResult = protoFieldClass.create();
}
if (false === fn(fromBinaryResult)) {
return null;
} else {
const obj = PreloadedUserSettings.create();
obj[arg4] = fromBinaryResult;
return obj;
}
};