|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const FeatureDetection = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ambientLightSensor() {
|
|
|
return 'AmbientLightSensor' in window;
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
battery() {
|
|
|
return 'getBattery' in navigator;
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wakeLock() {
|
|
|
return 'wakeLock' in navigator;
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vr() {
|
|
|
return 'getVRDisplays' in navigator || 'xr' in navigator;
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isSupported(featureName) {
|
|
|
const detector = this[featureName];
|
|
|
if (typeof detector === 'function') {
|
|
|
try {
|
|
|
return detector();
|
|
|
} catch (e) {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getAllSupported() {
|
|
|
return {
|
|
|
ambientLightSensor: this.ambientLightSensor(),
|
|
|
battery: this.battery(),
|
|
|
wakeLock: this.wakeLock(),
|
|
|
vr: this.vr()
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(function suppressFeatureWarnings() {
|
|
|
|
|
|
if (window._featureWarningsSuppressed) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const originalWarn = console.warn;
|
|
|
const ignoredFeatures = [
|
|
|
'ambient-light-sensor',
|
|
|
'battery',
|
|
|
'document-domain',
|
|
|
'layout-animations',
|
|
|
'legacy-image-formats',
|
|
|
'oversized-images',
|
|
|
'vr',
|
|
|
'wake-lock'
|
|
|
];
|
|
|
|
|
|
console.warn = function(...args) {
|
|
|
const message = args[0]?.toString() || '';
|
|
|
|
|
|
|
|
|
const isPermissionsPolicyWarning = message.includes('Unrecognized feature:') &&
|
|
|
ignoredFeatures.some(feature => message.includes(feature));
|
|
|
|
|
|
|
|
|
const isHFSpaceWarning = message.includes('Datasourceforcryptocurrency') &&
|
|
|
message.includes('Unrecognized feature:');
|
|
|
|
|
|
if (isPermissionsPolicyWarning || isHFSpaceWarning) {
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
originalWarn.apply(console, args);
|
|
|
};
|
|
|
|
|
|
|
|
|
window._featureWarningsSuppressed = true;
|
|
|
})();
|
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
|
module.exports = FeatureDetection;
|
|
|
}
|
|
|
|
|
|
|
|
|
window.FeatureDetection = FeatureDetection;
|
|
|
|