(function () {
const __BlessCrawl = globalThis.BlessCrawl;
class BlessCrawl {
constructor(config = {}) {
this._instance = __BlessCrawl(config);
}
async scrape(url, options = {}) {
if (typeof url !== 'string') {
throw new Error('URL must be a string');
}
return new Promise((resolve, reject) => {
try {
const result = this._instance.scrape(url, options);
if (result.success) {
resolve(result.data);
} else {
reject(result.error);
}
} catch (error) {
reject(error);
}
});
}
async map(url, options = {}) {
if (typeof url !== 'string') {
throw new Error('URL must be a string');
}
return new Promise((resolve, reject) => {
try {
const result = this._instance.map(url, options);
if (result.success) {
resolve(result.data);
} else {
reject(result.error);
}
} catch (error) {
reject(error);
}
});
}
async crawl(url, options = {}) {
if (typeof url !== 'string') {
throw new Error('URL must be a string');
}
return new Promise((resolve, reject) => {
try {
const result = this._instance.crawl(url, options);
if (result.success) {
resolve(result.data);
} else {
reject(result.error);
}
} catch (error) {
reject(error);
}
});
}
}
globalThis.BlessCrawl = BlessCrawl;
Reflect.deleteProperty(globalThis, "__BlessCrawl");
})();