@honeypot-run/core
Advanced tools
Comparing version
@@ -150,20 +150,7 @@ "use strict"; | ||
get() { | ||
var _a, _b; | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let timeoutMs = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.timeoutMs) || 600; | ||
const loadWithTimeout = (url) => __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
const timeout = setTimeout(() => reject(new Error("Load timeout")), timeoutMs + 5); | ||
this.load(url).then(() => { | ||
clearTimeout(timeout); | ||
resolve(null); | ||
}).catch((error) => { | ||
clearTimeout(timeout); | ||
reject(error); | ||
}); | ||
}); | ||
}); | ||
if (!this.didLoad && ((_b = this.config) === null || _b === void 0 ? void 0 : _b.url)) { | ||
if (!this.didLoad && ((_a = this.config) === null || _a === void 0 ? void 0 : _a.url)) { | ||
try { | ||
yield loadWithTimeout(this.config.url); | ||
yield this.load(this.config.url); | ||
if (window.honeypot) { | ||
@@ -174,7 +161,6 @@ return window.honeypot.get(); | ||
catch (error) { | ||
throw new Error(`Failed to load within the specified timeout: ${timeoutMs}`); | ||
throw new Error(`Failed to load`); | ||
} | ||
} | ||
return new Promise((resolve, reject) => { | ||
let t = Date.now(); | ||
const e = () => { | ||
@@ -184,7 +170,7 @@ if (window.honeypot && window.honeypot.honey) { | ||
} | ||
else if (Date.now() - t >= timeoutMs) { | ||
reject(new Error("Honey not found")); | ||
else if (window.honeypot) { | ||
return window.honeypot.get(); | ||
} | ||
else { | ||
setTimeout(e, 50); | ||
reject(new Error("Honey not found")); | ||
} | ||
@@ -191,0 +177,0 @@ }; |
@@ -6,3 +6,2 @@ import { honeypot } from "./Honeypot"; | ||
url?: string; | ||
timeoutMs?: number; | ||
debug?: boolean; | ||
@@ -9,0 +8,0 @@ } |
@@ -147,20 +147,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
get() { | ||
var _a, _b; | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let timeoutMs = ((_a = this.config) === null || _a === void 0 ? void 0 : _a.timeoutMs) || 600; | ||
const loadWithTimeout = (url) => __awaiter(this, void 0, void 0, function* () { | ||
return new Promise((resolve, reject) => { | ||
const timeout = setTimeout(() => reject(new Error("Load timeout")), timeoutMs + 5); | ||
this.load(url).then(() => { | ||
clearTimeout(timeout); | ||
resolve(null); | ||
}).catch((error) => { | ||
clearTimeout(timeout); | ||
reject(error); | ||
}); | ||
}); | ||
}); | ||
if (!this.didLoad && ((_b = this.config) === null || _b === void 0 ? void 0 : _b.url)) { | ||
if (!this.didLoad && ((_a = this.config) === null || _a === void 0 ? void 0 : _a.url)) { | ||
try { | ||
yield loadWithTimeout(this.config.url); | ||
yield this.load(this.config.url); | ||
if (window.honeypot) { | ||
@@ -171,7 +158,6 @@ return window.honeypot.get(); | ||
catch (error) { | ||
throw new Error(`Failed to load within the specified timeout: ${timeoutMs}`); | ||
throw new Error(`Failed to load`); | ||
} | ||
} | ||
return new Promise((resolve, reject) => { | ||
let t = Date.now(); | ||
const e = () => { | ||
@@ -181,7 +167,7 @@ if (window.honeypot && window.honeypot.honey) { | ||
} | ||
else if (Date.now() - t >= timeoutMs) { | ||
reject(new Error("Honey not found")); | ||
else if (window.honeypot) { | ||
return window.honeypot.get(); | ||
} | ||
else { | ||
setTimeout(e, 50); | ||
reject(new Error("Honey not found")); | ||
} | ||
@@ -188,0 +174,0 @@ }; |
@@ -6,3 +6,2 @@ import { honeypot } from "./Honeypot"; | ||
url?: string; | ||
timeoutMs?: number; | ||
debug?: boolean; | ||
@@ -9,0 +8,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "https://honeypot.run", | ||
"version": "0.2.4", | ||
"version": "0.2.41", | ||
"license": "BUSL-1.1", | ||
@@ -41,3 +41,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@rrweb/record": "^2.0.0-alpha.15" | ||
"@rrweb/record": "^2.0.0-alpha.4", | ||
"rrweb": "^2.0.0-alpha.4" | ||
}, | ||
@@ -44,0 +45,0 @@ "devDependencies": { |
23990
-6.12%2
100%616
-4.64%+ Added
Updated