decord/source/modules/search/SearchFetcher.tsx
github-actions da5b5e5efe chore: update source for alpha 346.6
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4821.js (118.4 MB)
2026-09-12 13:45:10 +00:00

255 lines
8 KiB
TypeScript

// Module ID: 12479
// Function ID: 12480
// Name: SearchFetcher
// Dependencies: [5, 1957, 1074, 1090, 3, 1272, 1471, 2]
// Module 12479 (SearchFetcher)
import HTTPUtils from "HTTPUtils" /* 1272 */;
import _modDef1471 from "module_1471" /* 1471 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import ChannelStore from "ChannelStore" /* 1957 */;
require = fn;
const Constants = fn(1074);
({ SearchTypes: hasOwnProperty, Endpoints: metroRequire } = Constants);
class SearchFetcher {
constructor(arg0, arg1, arg2) {
merged = Object.assign({ isCanceled: false });
merged.searchId = global;
merged.searchType = fn;
merged.query = importDefault;
return merged;
}
}
const prototype = SearchFetcher.prototype;
prototype["fetch"] = function fetch(arg0, arg1, arg2) {
closure_0 = arg0;
closure_1 = arg1;
closure_2 = arg2;
const self = this;
return self(function*(arg0, value) {
if (c6 === 2) {
c6 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
const obj3 = { value, done: true };
return obj3;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c6 = 2;
if (0 === c5) {
if (arg0 === 1) {
c6 = 3;
throw value;
} else if (arg0 === 2) {
c6 = 3;
const obj4 = { value, done: true };
return obj4;
} else {
closure_1 = tmp7;
closure_129_0 = undefined;
closure_129_1 = undefined;
if (!self.isCanceled) {
c4 = 1;
c5 = 2;
c6 = 1;
const obj5 = { value: self.makeRequest({ rejectWithError: false }), done: false };
return obj5;
}
}
} else {
if (1 === tmp7) {
c4 = 0;
closure_129_2 = closure_3;
const obj2 = new closure_1(tmp3[4])("SearchFetcher");
obj2.error(closure_129_2);
closure_130_2(closure_129_2);
} else if (arg0 === 1) {
c6 = 3;
throw value;
} else if (arg0 === 2) {
c4 = 0;
c6 = 3;
const obj = { value, done: true };
return obj;
} else {
closure_129_0 = value;
if (null == closure_129_0) {
c4 = 0;
c6 = 3;
return { value: "HermesInternal", done: null };
} else if (!closure_130_3.isCanceled) {
if (200 === closure_129_0.status) {
closure_130_0(closure_129_0);
} else if (202 === closure_129_0.status) {
const attempts = closure_130_3.query.attempts;
c0 = attempts;
if (attempts == null) {
c0 = 0;
}
closure_130_3.query.attempts = c0 + 1;
if (closure_130_3.query.attempts > 5) {
c4 = 0;
c6 = 3;
return { value: "HermesInternal", done: null };
} else {
const _parseInt = parseInt;
closure_129_1 = parseInt(closure_129_0.headers["retry-after"]);
const _isNaN = isNaN;
let num2 = 5000;
if (!isNaN(closure_129_1)) {
num2 = 5000;
if (0 !== closure_129_1) {
num2 = closure_129_1 * closure_1(tmp3[3]).Millis.SECOND;
}
}
closure_130_3.retryDelay = num2;
closure_130_3.retryLater(closure_130_0, closure_130_1, closure_130_2);
closure_130_1(closure_129_0);
}
}
c4 = 0;
}
}
c4 = 0;
c6 = 3;
return { value: "HermesInternal", done: null };
}
c6 = 3;
} catch (tmp49) {
closure_3 = tmp49;
if (tmp4 === c4) {
c6 = tmp2;
throw tmp49;
} else {
c5 = tmp;
}
}
}
})();
};
prototype["cancel"] = function cancel() {
this.isCanceled = true;
if (null != this.indexingPollId) {
const _clearTimeout = clearTimeout;
clearTimeout(tmp.indexingPollId);
}
};
prototype["retryLater"] = function retryLater(c165, cache, serializer) {
const self = this;
if (null != this.indexingPollId) {
const _clearTimeout = clearTimeout;
clearTimeout(self.indexingPollId);
}
const _fetch = self.fetch;
self.indexingPollId = setTimeout(_fetch.bind(self, c165, cache, serializer), self.retryDelay);
};
const size = fn(2);
const result = size.fileFinishedImporting("modules/search/SearchFetcher.tsx");
class SearchFetcherImpl extends SearchFetcher {
}
const prototype2 = SearchFetcherImpl.prototype;
prototype2["getEndpoint"] = function getEndpoint() {
const self = this;
const searchType = this.searchType;
if (constants.GUILD === searchType) {
if (null != self.searchId) {
if ("" !== self.searchId) {
return timestampProducer.SEARCH_GUILD(self.searchId);
}
}
} else if (tmp.GUILD_CHANNEL === searchType) {
if (null != self.searchId) {
if ("" !== self.searchId) {
const channel = ChannelStore.getChannel(self.searchId);
let guildId;
if (channel != null) {
guildId = channel.getGuildId();
}
if (null != guildId) {
return timestampProducer.SEARCH_GUILD(guildId);
}
}
}
} else if (tmp.CHANNEL === searchType) {
if (null != self.searchId) {
if ("" !== self.searchId) {
return timestampProducer.SEARCH_CHANNEL(self.searchId);
}
}
} else {
const _Error = Error;
const _HermesInternal = HermesInternal;
const error = new Error("[SearchFetcher] Unhandled search type: " + self.searchType);
throw error;
}
};
prototype2["makeRequest"] = function makeRequest(rejectWithError) {
const endpoint = this.getEndpoint();
value = null;
if (null != endpoint) {
const HTTP = HTTPUtils.HTTP;
const request = { url: endpoint, query: _modDef1471.stringify(this.query), oldFormErrors: true, rejectWithError: rejectWithError.rejectWithError };
value = HTTP.get(request);
}
return value;
};
class SearchTabFetcherImpl extends SearchFetcher {
constructor(arg0, arg1, arg2, arg3) {
tmp1 = new tmp(global, fn, importDefault, new.target);
tmp1.payload = importAll;
return tmp1;
}
}
const prototype3 = SearchTabFetcherImpl.prototype;
prototype3["getEndpoint"] = function getEndpoint() {
const self = this;
const searchType = this.searchType;
if (constants.DMS === searchType) {
return timestampProducer.SEARCH_TABS_DMS;
} else {
if (tmp.GUILD_CHANNEL !== searchType) {
if (tmp.GUILD !== searchType) {
if (tmp.THREAD !== searchType) {
if (tmp.CHANNEL === searchType) {
if (null != self.searchId) {
if ("" !== self.searchId) {
return timestampProducer.SEARCH_TABS_CHANNEL(self.searchId);
}
}
} else {
const _Error = Error;
const _HermesInternal = HermesInternal;
const error = new Error("[SearchFetcher] Unhandled search type: " + self.searchType);
throw error;
}
}
}
}
if (null != self.searchId) {
if ("" !== self.searchId) {
return timestampProducer.SEARCH_TABS_GUILD(self.searchId);
}
}
}
};
prototype3["makeRequest"] = function makeRequest(rejectWithError) {
const endpoint = this.getEndpoint();
let postResult = null;
if (null != endpoint) {
const HTTP = HTTPUtils.HTTP;
const request = { url: endpoint, body: this.payload, oldFormErrors: true, rejectWithError: rejectWithError.rejectWithError };
postResult = HTTP.post(request);
}
return postResult;
};
export { SearchFetcher };
export { SearchFetcherImpl };
export { SearchTabFetcherImpl };