Skip to content

Commit a72da56

Browse files
authored
Merge pull request #2 from MacPaw/feat/fix-wate-timeout
fix: wait timeout type
2 parents 7c3a2bb + 6bbe096 commit a72da56

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macpaw/browser-deeplink",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"main": "dist/index.js",
55
"module": "src/index",
66
"license": "MIT",

rollup.config.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import buble from '@rollup/plugin-buble';
22

3-
export default {
3+
const config = {
44
input: './src/index.js',
55
output: {
66
file: './dist/index.js',
77
format: 'cjs',
88
indent: false
99
},
1010
plugins: [buble()],
11-
};
11+
};
12+
13+
export default config;

src/index.d.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
declare module '@macpaw/browser-deeplink' {
2-
export function browserDeeplink(appLink : string): Promise<void>;
2+
export function browserDeeplink(appLink : string, options: {
3+
waitTimeout?: number
4+
}): Promise<void>;
35
}

src/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ function ejectIframe(iframe) {
1414
document.body.removeChild(iframe);
1515
}
1616

17-
export function browserDeeplink(appLink, options = {}) {
17+
export function browserDeeplink(appLink, options = {
18+
waitTimeout: 200,
19+
}) {
1820
const { waitTimeout } = options;
19-
const WAIT_TIMEOUT = typeof (waitTimeout) === 'number' ? options.wait : 200;
2021

2122
return new Promise(((resolve, reject) => {
2223
const iframe = injectIframe(appLink);
2324
const timeout = setTimeout(() => {
2425
window.removeEventListener('blur', windowBlurListener);
2526
ejectIframe(iframe);
2627
reject(Error(`Can't open ${appLink}`));
27-
}, WAIT_TIMEOUT);
28+
}, waitTimeout);
2829

2930
function windowBlurListener() {
3031
window.removeEventListener('blur', windowBlurListener);

0 commit comments

Comments
 (0)