decord/source/modules/rpc/server/commands/images.tsx

82 lines
2.6 KiB
TypeScript
Raw Normal View History

2026-07-27 11:26:19 +00:00
// Module ID: 13466
// Function ID: 103521
// Dependencies: [1850, 4034, 653, 10557, 1392, 10554, 1447, 2]
2026-07-20 16:05:17 +00:00
2026-07-27 11:26:19 +00:00
// Module 13466
2026-07-23 10:11:24 +00:00
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import ME from "ME";
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
const require = arg1;
const RPCErrors = ME.RPCErrors;
let obj = {
scope: require("RPC_SCOPE_CONFIG").RPC_LOCAL_SCOPE,
validation(string) {
2026-07-27 11:26:19 +00:00
let obj = importDefault(10557)(string);
2026-07-23 10:11:24 +00:00
obj = {};
const requiredResult = obj.required();
const stringResult = string.string();
obj.type = string.string().required().valid(["user"]);
const requiredResult1 = string.string().required();
obj.id = string.string().required();
const stringResult1 = string.string();
const stringResult2 = string.string();
obj.format = string.string().required().valid(["png", "webp", "jpg"]);
const requiredResult2 = string.string().required();
const numberResult = string.number();
obj.size = string.number().required().valid([16, 32, 64, 128, 256, 512, 1024]);
return requiredResult.keys(obj);
},
handler(args) {
let format;
let id;
args = args.args;
({ id, format } = args);
if (format === undefined) {
format = "png";
}
let num = args.size;
if (num === undefined) {
num = 128;
}
let text;
if ("user" === args.type) {
user = user.getUser(id);
if (null == user) {
2026-07-27 11:26:19 +00:00
let tmp15 = importDefault(10554);
2026-07-23 10:11:24 +00:00
let obj = { errorCode: RPCErrors.INVALID_USER };
const _HermesInternal = HermesInternal;
const prototype2 = tmp15.prototype;
tmp15 = new tmp15(obj, "Invalid user id: " + id);
throw tmp15;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
const obj3 = importDefault(1392);
const userAvatarURL = obj3.getUserAvatarURL(user, false, num, format);
const _window = window;
let tmp2 = null != CDN_HOST;
if (tmp2) {
tmp2 = -1 !== userAvatarURL.indexOf(CDN_HOST);
}
text = userAvatarURL;
if (tmp2) {
text = `${arr}&_=`;
}
2026-07-20 16:05:17 +00:00
}
}
2026-07-23 10:11:24 +00:00
if (null == text) {
2026-07-27 11:26:19 +00:00
let tmp6 = importDefault(10554);
2026-07-23 10:11:24 +00:00
obj = { errorCode: RPCErrors.INVALID_COMMAND };
const prototype = tmp6.prototype;
tmp6 = new tmp6(obj, "No valid type.");
throw tmp6;
} else {
const _fetch = fetch;
const response = fetch(text);
const nextPromise = response.then((blob) => blob.blob());
return response.then((blob) => blob.blob()).then((arg0) => outer1_0(outer1_2[6]).readFileAsBase64(arg0)).then((data_url) => ({ data_url }));
}
2026-07-20 16:05:17 +00:00
}
};
2026-07-23 10:11:24 +00:00
const result = require("ME").fileFinishedImporting("modules/rpc/server/commands/images.tsx");
export default { [ME.RPCCommands.GET_IMAGE]: obj };