web: fix web app on Safari

This commit is contained in:
Abdullah Atta
2025-01-20 10:35:23 +05:00
parent 8ffbda9626
commit 46105b2175
3 changed files with 284 additions and 1848 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -71,7 +71,7 @@ declare global {
}
interface Window {
ApplePaySession?: {
canMakePayments(): boolean;
canMakePayments(): boolean | Promise<boolean>;
};
}
}

View File

@@ -22,9 +22,18 @@ const FEATURE_CHECKS = {
cache: false,
indexedDB: false,
clonableCryptoKey: false,
applePaySupported: !!window.ApplePaySession?.canMakePayments()
applePaySupported: false
};
async function isApplePaySupported() {
try {
FEATURE_CHECKS.applePaySupported =
!!(await window.ApplePaySession?.canMakePayments());
} catch {
FEATURE_CHECKS.applePaySupported = false;
}
}
async function isOPFSSupported() {
const hasGetDirectory =
"getDirectory" in window.navigator.storage &&
@@ -93,7 +102,8 @@ export async function initializeFeatureChecks() {
isOPFSSupported(),
isCacheSupported(),
isIndexedDBSupported(),
isCryptoKeyClonable()
isCryptoKeyClonable(),
isApplePaySupported()
]);
}