decord/source/962__isFetchSupported.js

97 lines
2.8 KiB
JavaScript
Raw Normal View History

2026-07-20 16:05:17 +00:00
// Module ID: 962
2026-07-25 08:10:48 +00:00
// Function ID: 10427
2026-07-20 16:05:17 +00:00
// Name: _isFetchSupported
2026-07-23 10:11:24 +00:00
// Dependencies: [798, 800, 801]
2026-07-20 16:05:17 +00:00
// Module 962 (_isFetchSupported)
2026-07-23 10:11:24 +00:00
const require = arg1;
const dependencyMap = arg6;
2026-07-20 16:05:17 +00:00
function _isFetchSupported() {
2026-07-23 10:11:24 +00:00
if ("fetch" in require(798).GLOBAL_OBJ) {
2026-07-20 16:05:17 +00:00
const _Headers = Headers;
const headers = new Headers();
const _Request = Request;
const request = new Request("data:,");
const _Response = Response;
const response = new Response();
return true;
} else {
return false;
}
}
function isNativeFunction(arg0) {
let isMatch = arg0;
if (arg0) {
isMatch = /^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/.test(arg0.toString());
const obj = /^function\s+\w+\(\)\s+\{\s+\[native code\]\s+\}$/;
}
return isMatch;
}
Object.defineProperty(arg5, Symbol.toStringTag, { value: "Module" });
arg5.isNativeFunction = isNativeFunction;
arg5.supportsDOMError = function supportsDOMError() {
const dOMError = new globalThis.DOMError("");
return true;
};
arg5.supportsDOMException = function supportsDOMException() {
const dOMException = new globalThis.DOMException("");
return true;
};
arg5.supportsErrorEvent = function supportsErrorEvent() {
const errorEvent = new globalThis.ErrorEvent("");
return true;
};
arg5.supportsFetch = _isFetchSupported;
arg5.supportsHistory = function supportsHistory() {
2026-07-23 10:11:24 +00:00
let history = "history" in require(798).GLOBAL_OBJ;
2026-07-20 16:05:17 +00:00
if (history) {
2026-07-23 10:11:24 +00:00
history = require(798).GLOBAL_OBJ.history;
2026-07-20 16:05:17 +00:00
}
return history;
};
arg5.supportsNativeFetch = function supportsNativeFetch() {
if ("string" === typeof globalThis.EdgeRuntime) {
return true;
} else if (_isFetchSupported()) {
2026-07-23 10:11:24 +00:00
if (isNativeFunction(require(798).GLOBAL_OBJ.fetch)) {
2026-07-20 16:05:17 +00:00
return true;
} else {
2026-07-23 10:11:24 +00:00
const _document = require(798).GLOBAL_OBJ.document;
2026-07-20 16:05:17 +00:00
if (_document) {
if ("function" === typeof obj.createElement) {
const element = <iframe />;
element.hidden = true;
const head2 = obj.head;
head2.appendChild(element);
const contentWindow = element.contentWindow;
let _fetch = tmp17;
if (null != contentWindow) {
_fetch = contentWindow.fetch;
}
if (_fetch) {
isNativeFunction(tmp13.contentWindow.fetch);
}
const head = _document.head;
head.removeChild(element);
2026-07-23 10:11:24 +00:00
tmp13 = element;
2026-07-20 16:05:17 +00:00
}
}
}
} else {
return false;
}
};
arg5.supportsReferrerPolicy = function supportsReferrerPolicy() {
if (_isFetchSupported()) {
const _Request = Request;
const obj = { referrerPolicy: "origin" };
const request = new Request("_", obj);
return true;
} else {
return false;
}
};
arg5.supportsReportingObserver = function supportsReportingObserver() {
2026-07-23 10:11:24 +00:00
return "ReportingObserver" in require(798).GLOBAL_OBJ;
2026-07-20 16:05:17 +00:00
};