@solana/wallet-adapter-base
Advanced tools
Comparing version 0.9.3 to 0.9.4
@@ -70,2 +70,2 @@ import { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js'; | ||
} | ||
export declare function scopePollingDetectionStrategy(performDetection: () => boolean): void; | ||
export declare function scopePollingDetectionStrategy(detect: () => boolean): void; |
@@ -44,7 +44,20 @@ "use strict"; | ||
exports.BaseWalletAdapter = BaseWalletAdapter; | ||
function scopePollingDetectionStrategy(performDetection) { | ||
function scopePollingDetectionStrategy(detect) { | ||
// Early return when server-side rendering | ||
if (typeof window === 'undefined' || typeof document === 'undefined') | ||
return; | ||
const poll = () => { | ||
// Wallet detected, nothing more to do | ||
if (detect()) | ||
return; | ||
// Wallet not detected yet, try detecting every second | ||
const interval = setInterval(() => { | ||
// Wallet detected, nothing more to do | ||
if (detect()) { | ||
clearInterval(interval); | ||
} | ||
}, 1000); | ||
}; | ||
if (document.readyState === 'complete') { | ||
performDetection(); | ||
poll(); | ||
return; | ||
@@ -54,3 +67,3 @@ } | ||
window.removeEventListener('load', listener); | ||
performDetection(); | ||
poll(); | ||
} | ||
@@ -57,0 +70,0 @@ window.addEventListener('load', listener); |
@@ -70,2 +70,2 @@ import { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js'; | ||
} | ||
export declare function scopePollingDetectionStrategy(performDetection: () => boolean): void; | ||
export declare function scopePollingDetectionStrategy(detect: () => boolean): void; |
{ | ||
"name": "@solana/wallet-adapter-base", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"author": "Solana Maintainers <maintainers@solana.foundation>", | ||
@@ -33,3 +33,3 @@ "repository": "https://github.com/solana-labs/wallet-adapter", | ||
}, | ||
"gitHead": "0373f0da94309cc72d4cdb3c56176ca9355f95cc" | ||
"gitHead": "42bcf2853e268be2bb0eb5fac71a5b9d7204f420" | ||
} |
@@ -92,13 +92,29 @@ import { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js'; | ||
export function scopePollingDetectionStrategy(performDetection: () => boolean): void { | ||
export function scopePollingDetectionStrategy(detect: () => boolean): void { | ||
// Early return when server-side rendering | ||
if (typeof window === 'undefined' || typeof document === 'undefined') return; | ||
const poll = () => { | ||
// Wallet detected, nothing more to do | ||
if (detect()) return; | ||
// Wallet not detected yet, try detecting every second | ||
const interval = setInterval(() => { | ||
// Wallet detected, nothing more to do | ||
if (detect()) { | ||
clearInterval(interval); | ||
} | ||
}, 1000); | ||
}; | ||
if (document.readyState === 'complete') { | ||
performDetection(); | ||
poll(); | ||
return; | ||
} | ||
function listener() { | ||
window.removeEventListener('load', listener); | ||
performDetection(); | ||
poll(); | ||
} | ||
window.addEventListener('load', listener); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61505
1021