12.4 概念模块功能完善

This commit is contained in:
尚政杰
2025-12-04 17:41:33 +08:00
parent 4e64455b9b
commit 44842120da
5090 changed files with 9843 additions and 146120 deletions

View File

@@ -1,6 +0,0 @@
export declare const DEFAULT_BLOCKED_UA_STRS: string[];
/**
* Block various web spiders from executing our JS and sending false capturing data
*/
export declare const isBlockedUA: (ua: string | undefined, customBlockedUserAgents?: string[]) => boolean;
//# sourceMappingURL=bot-detection.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"bot-detection.d.ts","sourceRoot":"","sources":["../../src/utils/bot-detection.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,UA+FnC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,GAAa,IAAI,MAAM,GAAG,SAAS,EAAE,0BAAyB,MAAM,EAAO,KAAG,OAWrG,CAAA"}

View File

@@ -1,125 +0,0 @@
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
DEFAULT_BLOCKED_UA_STRS: ()=>DEFAULT_BLOCKED_UA_STRS,
isBlockedUA: ()=>isBlockedUA
});
const DEFAULT_BLOCKED_UA_STRS = [
'amazonbot',
'amazonproductbot',
'app.hypefactors.com',
'applebot',
'archive.org_bot',
'awariobot',
'backlinksextendedbot',
'baiduspider',
'bingbot',
'bingpreview',
'chrome-lighthouse',
'dataforseobot',
'deepscan',
'duckduckbot',
'facebookexternal',
'facebookcatalog',
'http://yandex.com/bots',
'hubspot',
'ia_archiver',
'leikibot',
'linkedinbot',
'meta-externalagent',
'mj12bot',
'msnbot',
'nessus',
'petalbot',
'pinterest',
'prerender',
'rogerbot',
'screaming frog',
'sebot-wa',
'sitebulb',
'slackbot',
'slurp',
'trendictionbot',
'turnitin',
'twitterbot',
'vercel-screenshot',
'vercelbot',
'yahoo! slurp',
'yandexbot',
'zoombot',
'bot.htm',
'bot.php',
'(bot;',
'bot/',
'crawler',
'ahrefsbot',
'ahrefssiteaudit',
'semrushbot',
'siteauditbot',
'splitsignalbot',
'gptbot',
'oai-searchbot',
'chatgpt-user',
'perplexitybot',
'better uptime bot',
'sentryuptimebot',
'uptimerobot',
'headlesschrome',
'cypress',
'google-hoteladsverifier',
'adsbot-google',
'apis-google',
'duplexweb-google',
'feedfetcher-google',
'google favicon',
'google web preview',
'google-read-aloud',
'googlebot',
'googleother',
'google-cloudvertexbot',
'googleweblight',
'mediapartners-google',
'storebot-google',
'google-inspectiontool',
'bytespider'
];
const isBlockedUA = function(ua, customBlockedUserAgents = []) {
if (!ua) return false;
const uaLower = ua.toLowerCase();
return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA)=>{
const blockedUaLower = blockedUA.toLowerCase();
return -1 !== uaLower.indexOf(blockedUaLower);
});
};
exports.DEFAULT_BLOCKED_UA_STRS = __webpack_exports__.DEFAULT_BLOCKED_UA_STRS;
exports.isBlockedUA = __webpack_exports__.isBlockedUA;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"DEFAULT_BLOCKED_UA_STRS",
"isBlockedUA"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,88 +0,0 @@
const DEFAULT_BLOCKED_UA_STRS = [
'amazonbot',
'amazonproductbot',
'app.hypefactors.com',
'applebot',
'archive.org_bot',
'awariobot',
'backlinksextendedbot',
'baiduspider',
'bingbot',
'bingpreview',
'chrome-lighthouse',
'dataforseobot',
'deepscan',
'duckduckbot',
'facebookexternal',
'facebookcatalog',
'http://yandex.com/bots',
'hubspot',
'ia_archiver',
'leikibot',
'linkedinbot',
'meta-externalagent',
'mj12bot',
'msnbot',
'nessus',
'petalbot',
'pinterest',
'prerender',
'rogerbot',
'screaming frog',
'sebot-wa',
'sitebulb',
'slackbot',
'slurp',
'trendictionbot',
'turnitin',
'twitterbot',
'vercel-screenshot',
'vercelbot',
'yahoo! slurp',
'yandexbot',
'zoombot',
'bot.htm',
'bot.php',
'(bot;',
'bot/',
'crawler',
'ahrefsbot',
'ahrefssiteaudit',
'semrushbot',
'siteauditbot',
'splitsignalbot',
'gptbot',
'oai-searchbot',
'chatgpt-user',
'perplexitybot',
'better uptime bot',
'sentryuptimebot',
'uptimerobot',
'headlesschrome',
'cypress',
'google-hoteladsverifier',
'adsbot-google',
'apis-google',
'duplexweb-google',
'feedfetcher-google',
'google favicon',
'google web preview',
'google-read-aloud',
'googlebot',
'googleother',
'google-cloudvertexbot',
'googleweblight',
'mediapartners-google',
'storebot-google',
'google-inspectiontool',
'bytespider'
];
const isBlockedUA = function(ua, customBlockedUserAgents = []) {
if (!ua) return false;
const uaLower = ua.toLowerCase();
return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA)=>{
const blockedUaLower = blockedUA.toLowerCase();
return -1 !== uaLower.indexOf(blockedUaLower);
});
};
export { DEFAULT_BLOCKED_UA_STRS, isBlockedUA };

View File

@@ -1,19 +0,0 @@
import { Logger } from '../types';
export declare class BucketedRateLimiter<T extends string | number> {
private _bucketSize;
private _refillRate;
private _refillInterval;
private _onBucketRateLimited?;
private _buckets;
constructor(options: {
bucketSize: number;
refillRate: number;
refillInterval: number;
_logger: Logger;
_onBucketRateLimited?: (key: T) => void;
});
private _applyRefill;
consumeRateLimit(key: T): boolean;
stop(): void;
}
//# sourceMappingURL=bucketed-rate-limiter.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"bucketed-rate-limiter.d.ts","sourceRoot":"","sources":["../../src/utils/bucketed-rate-limiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMjC,qBAAa,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,oBAAoB,CAAC,CAAkB;IAC/C,OAAO,CAAC,QAAQ,CAA6B;gBAEjC,OAAO,EAAE;QACnB,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;QAClB,cAAc,EAAE,MAAM,CAAA;QACtB,OAAO,EAAE,MAAM,CAAA;QACf,oBAAoB,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAA;KACxC;IAOD,OAAO,CAAC,YAAY;IAWb,gBAAgB,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IA0BjC,IAAI,IAAI,IAAI;CAGpB"}

View File

@@ -1,75 +0,0 @@
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
BucketedRateLimiter: ()=>BucketedRateLimiter
});
const external_number_utils_js_namespaceObject = require("./number-utils.js");
const ONE_DAY_IN_MS = 86400000;
class BucketedRateLimiter {
constructor(options){
this._buckets = {};
this._onBucketRateLimited = options._onBucketRateLimited;
this._bucketSize = (0, external_number_utils_js_namespaceObject.clampToRange)(options.bucketSize, 0, 100, options._logger);
this._refillRate = (0, external_number_utils_js_namespaceObject.clampToRange)(options.refillRate, 0, this._bucketSize, options._logger);
this._refillInterval = (0, external_number_utils_js_namespaceObject.clampToRange)(options.refillInterval, 0, ONE_DAY_IN_MS, options._logger);
}
_applyRefill(bucket, now) {
const elapsedMs = now - bucket.lastAccess;
const refillIntervals = Math.floor(elapsedMs / this._refillInterval);
if (refillIntervals > 0) {
const tokensToAdd = refillIntervals * this._refillRate;
bucket.tokens = Math.min(bucket.tokens + tokensToAdd, this._bucketSize);
bucket.lastAccess = bucket.lastAccess + refillIntervals * this._refillInterval;
}
}
consumeRateLimit(key) {
const now = Date.now();
const keyStr = String(key);
let bucket = this._buckets[keyStr];
if (bucket) this._applyRefill(bucket, now);
else {
bucket = {
tokens: this._bucketSize,
lastAccess: now
};
this._buckets[keyStr] = bucket;
}
if (0 === bucket.tokens) return true;
bucket.tokens--;
if (0 === bucket.tokens) this._onBucketRateLimited?.(key);
return 0 === bucket.tokens;
}
stop() {
this._buckets = {};
}
}
exports.BucketedRateLimiter = __webpack_exports__.BucketedRateLimiter;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"BucketedRateLimiter"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,41 +0,0 @@
import { clampToRange } from "./number-utils.mjs";
const ONE_DAY_IN_MS = 86400000;
class BucketedRateLimiter {
constructor(options){
this._buckets = {};
this._onBucketRateLimited = options._onBucketRateLimited;
this._bucketSize = clampToRange(options.bucketSize, 0, 100, options._logger);
this._refillRate = clampToRange(options.refillRate, 0, this._bucketSize, options._logger);
this._refillInterval = clampToRange(options.refillInterval, 0, ONE_DAY_IN_MS, options._logger);
}
_applyRefill(bucket, now) {
const elapsedMs = now - bucket.lastAccess;
const refillIntervals = Math.floor(elapsedMs / this._refillInterval);
if (refillIntervals > 0) {
const tokensToAdd = refillIntervals * this._refillRate;
bucket.tokens = Math.min(bucket.tokens + tokensToAdd, this._bucketSize);
bucket.lastAccess = bucket.lastAccess + refillIntervals * this._refillInterval;
}
}
consumeRateLimit(key) {
const now = Date.now();
const keyStr = String(key);
let bucket = this._buckets[keyStr];
if (bucket) this._applyRefill(bucket, now);
else {
bucket = {
tokens: this._bucketSize,
lastAccess: now
};
this._buckets[keyStr] = bucket;
}
if (0 === bucket.tokens) return true;
bucket.tokens--;
if (0 === bucket.tokens) this._onBucketRateLimited?.(key);
return 0 === bucket.tokens;
}
stop() {
this._buckets = {};
}
}
export { BucketedRateLimiter };

View File

@@ -1,31 +0,0 @@
import { FetchLike } from '../types';
export * from './bot-detection';
export * from './bucketed-rate-limiter';
export * from './number-utils';
export * from './string-utils';
export * from './type-utils';
export * from './promise-queue';
export * from './logger';
export declare const STRING_FORMAT = "utf8";
export declare function assert(truthyValue: any, message: string): void;
export declare function removeTrailingSlash(url: string): string;
export interface RetriableOptions {
retryCount: number;
retryDelay: number;
retryCheck: (err: unknown) => boolean;
}
export declare function retriable<T>(fn: () => Promise<T>, props: RetriableOptions): Promise<T>;
export declare function currentTimestamp(): number;
export declare function currentISOTime(): string;
export declare function safeSetTimeout(fn: () => void, timeout: number): any;
export declare const isPromise: (obj: any) => obj is Promise<any>;
export declare const isError: (x: unknown) => x is Error;
export declare function getFetch(): FetchLike | undefined;
export declare function allSettled<T>(promises: (Promise<T> | null | undefined)[]): Promise<({
status: 'fulfilled';
value: T;
} | {
status: 'rejected';
reason: any;
})[]>;
//# sourceMappingURL=index.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AAExB,eAAO,MAAM,aAAa,SAAS,CAAA;AAEnC,wBAAgB,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI9D;AASD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAA;CACtC;AAED,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,CAAC,CAAC,CAqB5F;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAOnE;AAGD,eAAO,MAAM,SAAS,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAEtD,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAEzC,CAAA;AAED,wBAAgB,QAAQ,IAAI,SAAS,GAAG,SAAS,CAEhD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAC1B,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC1C,OAAO,CAAC,CAAC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,EAAE,CAAC,CAStF"}

View File

@@ -1,291 +0,0 @@
"use strict";
var __webpack_modules__ = {
"./bot-detection": function(module) {
module.exports = require("./bot-detection.js");
},
"./bucketed-rate-limiter": function(module) {
module.exports = require("./bucketed-rate-limiter.js");
},
"./logger": function(module) {
module.exports = require("./logger.js");
},
"./number-utils": function(module) {
module.exports = require("./number-utils.js");
},
"./promise-queue": function(module) {
module.exports = require("./promise-queue.js");
},
"./string-utils": function(module) {
module.exports = require("./string-utils.js");
},
"./type-utils": function(module) {
module.exports = require("./type-utils.js");
}
};
var __webpack_module_cache__ = {};
function __webpack_require__(moduleId) {
var cachedModule = __webpack_module_cache__[moduleId];
if (void 0 !== cachedModule) return cachedModule.exports;
var module = __webpack_module_cache__[moduleId] = {
exports: {}
};
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
return module.exports;
}
(()=>{
__webpack_require__.n = (module)=>{
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
__webpack_require__.d(getter, {
a: getter
});
return getter;
};
})();
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
(()=>{
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
STRING_FORMAT: ()=>STRING_FORMAT,
allSettled: ()=>allSettled,
assert: ()=>assert,
currentISOTime: ()=>currentISOTime,
currentTimestamp: ()=>currentTimestamp,
getFetch: ()=>getFetch,
isError: ()=>isError,
isPromise: ()=>isPromise,
removeTrailingSlash: ()=>removeTrailingSlash,
retriable: ()=>retriable,
safeSetTimeout: ()=>safeSetTimeout
});
var _bot_detection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./bot-detection");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _bot_detection__WEBPACK_IMPORTED_MODULE_0__)if ([
"removeTrailingSlash",
"retriable",
"default",
"currentISOTime",
"currentTimestamp",
"STRING_FORMAT",
"isError",
"safeSetTimeout",
"getFetch",
"isPromise",
"assert",
"allSettled"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
return _bot_detection__WEBPACK_IMPORTED_MODULE_0__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
var _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./bucketed-rate-limiter");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_1__)if ([
"removeTrailingSlash",
"retriable",
"default",
"currentISOTime",
"currentTimestamp",
"STRING_FORMAT",
"isError",
"safeSetTimeout",
"getFetch",
"isPromise",
"assert",
"allSettled"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
return _bucketed_rate_limiter__WEBPACK_IMPORTED_MODULE_1__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
var _number_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./number-utils");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _number_utils__WEBPACK_IMPORTED_MODULE_2__)if ([
"removeTrailingSlash",
"retriable",
"default",
"currentISOTime",
"currentTimestamp",
"STRING_FORMAT",
"isError",
"safeSetTimeout",
"getFetch",
"isPromise",
"assert",
"allSettled"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
return _number_utils__WEBPACK_IMPORTED_MODULE_2__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
var _string_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./string-utils");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _string_utils__WEBPACK_IMPORTED_MODULE_3__)if ([
"removeTrailingSlash",
"retriable",
"default",
"currentISOTime",
"currentTimestamp",
"STRING_FORMAT",
"isError",
"safeSetTimeout",
"getFetch",
"isPromise",
"assert",
"allSettled"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
return _string_utils__WEBPACK_IMPORTED_MODULE_3__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
var _type_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./type-utils");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _type_utils__WEBPACK_IMPORTED_MODULE_4__)if ([
"removeTrailingSlash",
"retriable",
"default",
"currentISOTime",
"currentTimestamp",
"STRING_FORMAT",
"isError",
"safeSetTimeout",
"getFetch",
"isPromise",
"assert",
"allSettled"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
return _type_utils__WEBPACK_IMPORTED_MODULE_4__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
var _promise_queue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./promise-queue");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _promise_queue__WEBPACK_IMPORTED_MODULE_5__)if ([
"removeTrailingSlash",
"retriable",
"default",
"currentISOTime",
"currentTimestamp",
"STRING_FORMAT",
"isError",
"safeSetTimeout",
"getFetch",
"isPromise",
"assert",
"allSettled"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
return _promise_queue__WEBPACK_IMPORTED_MODULE_5__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
var _logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./logger");
var __WEBPACK_REEXPORT_OBJECT__ = {};
for(var __WEBPACK_IMPORT_KEY__ in _logger__WEBPACK_IMPORTED_MODULE_6__)if ([
"removeTrailingSlash",
"retriable",
"default",
"currentISOTime",
"currentTimestamp",
"STRING_FORMAT",
"isError",
"safeSetTimeout",
"getFetch",
"isPromise",
"assert",
"allSettled"
].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
return _logger__WEBPACK_IMPORTED_MODULE_6__[key];
}).bind(0, __WEBPACK_IMPORT_KEY__);
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
const STRING_FORMAT = 'utf8';
function assert(truthyValue, message) {
if (!truthyValue || 'string' != typeof truthyValue || isEmpty(truthyValue)) throw new Error(message);
}
function isEmpty(truthyValue) {
if (0 === truthyValue.trim().length) return true;
return false;
}
function removeTrailingSlash(url) {
return url?.replace(/\/+$/, '');
}
async function retriable(fn, props) {
let lastError = null;
for(let i = 0; i < props.retryCount + 1; i++){
if (i > 0) await new Promise((r)=>setTimeout(r, props.retryDelay));
try {
const res = await fn();
return res;
} catch (e) {
lastError = e;
if (!props.retryCheck(e)) throw e;
}
}
throw lastError;
}
function currentTimestamp() {
return new Date().getTime();
}
function currentISOTime() {
return new Date().toISOString();
}
function safeSetTimeout(fn, timeout) {
const t = setTimeout(fn, timeout);
t?.unref && t?.unref();
return t;
}
const isPromise = (obj)=>obj && 'function' == typeof obj.then;
const isError = (x)=>x instanceof Error;
function getFetch() {
return 'undefined' != typeof fetch ? fetch : void 0 !== globalThis.fetch ? globalThis.fetch : void 0;
}
function allSettled(promises) {
return Promise.all(promises.map((p)=>(p ?? Promise.resolve()).then((value)=>({
status: 'fulfilled',
value
}), (reason)=>({
status: 'rejected',
reason
}))));
}
})();
exports.STRING_FORMAT = __webpack_exports__.STRING_FORMAT;
exports.allSettled = __webpack_exports__.allSettled;
exports.assert = __webpack_exports__.assert;
exports.currentISOTime = __webpack_exports__.currentISOTime;
exports.currentTimestamp = __webpack_exports__.currentTimestamp;
exports.getFetch = __webpack_exports__.getFetch;
exports.isError = __webpack_exports__.isError;
exports.isPromise = __webpack_exports__.isPromise;
exports.removeTrailingSlash = __webpack_exports__.removeTrailingSlash;
exports.retriable = __webpack_exports__.retriable;
exports.safeSetTimeout = __webpack_exports__.safeSetTimeout;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"STRING_FORMAT",
"allSettled",
"assert",
"currentISOTime",
"currentTimestamp",
"getFetch",
"isError",
"isPromise",
"removeTrailingSlash",
"retriable",
"safeSetTimeout"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,58 +0,0 @@
export * from "./bot-detection.mjs";
export * from "./bucketed-rate-limiter.mjs";
export * from "./number-utils.mjs";
export * from "./string-utils.mjs";
export * from "./type-utils.mjs";
export * from "./promise-queue.mjs";
export * from "./logger.mjs";
const STRING_FORMAT = 'utf8';
function assert(truthyValue, message) {
if (!truthyValue || 'string' != typeof truthyValue || isEmpty(truthyValue)) throw new Error(message);
}
function isEmpty(truthyValue) {
if (0 === truthyValue.trim().length) return true;
return false;
}
function removeTrailingSlash(url) {
return url?.replace(/\/+$/, '');
}
async function retriable(fn, props) {
let lastError = null;
for(let i = 0; i < props.retryCount + 1; i++){
if (i > 0) await new Promise((r)=>setTimeout(r, props.retryDelay));
try {
const res = await fn();
return res;
} catch (e) {
lastError = e;
if (!props.retryCheck(e)) throw e;
}
}
throw lastError;
}
function currentTimestamp() {
return new Date().getTime();
}
function currentISOTime() {
return new Date().toISOString();
}
function safeSetTimeout(fn, timeout) {
const t = setTimeout(fn, timeout);
t?.unref && t?.unref();
return t;
}
const isPromise = (obj)=>obj && 'function' == typeof obj.then;
const isError = (x)=>x instanceof Error;
function getFetch() {
return 'undefined' != typeof fetch ? fetch : void 0 !== globalThis.fetch ? globalThis.fetch : void 0;
}
function allSettled(promises) {
return Promise.all(promises.map((p)=>(p ?? Promise.resolve()).then((value)=>({
status: 'fulfilled',
value
}), (reason)=>({
status: 'rejected',
reason
}))));
}
export { STRING_FORMAT, allSettled, assert, currentISOTime, currentTimestamp, getFetch, isError, isPromise, removeTrailingSlash, retriable, safeSetTimeout };

View File

@@ -1,11 +0,0 @@
import { Logger } from '../types';
type ConsoleLike = {
log: (...args: any[]) => void;
warn: (...args: any[]) => void;
error: (...args: any[]) => void;
debug: (...args: any[]) => void;
};
export declare const _createLogger: (prefix: string, maybeCall: (fn: () => void) => void, consoleLike: ConsoleLike) => Logger;
export declare function createLogger(prefix: string, maybeCall?: (fn: () => void) => void): Logger;
export {};
//# sourceMappingURL=logger.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC7B,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC9B,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAC/B,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAChC,CAAA;AAYD,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,EACd,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,EACnC,aAAa,WAAW,KACvB,MA6BF,CAAA;AAID,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAkB,UAE7F"}

View File

@@ -1,75 +0,0 @@
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
_createLogger: ()=>_createLogger,
createLogger: ()=>createLogger
});
function createConsole(consoleLike = console) {
const lockedMethods = {
log: consoleLike.log.bind(consoleLike),
warn: consoleLike.warn.bind(consoleLike),
error: consoleLike.error.bind(consoleLike),
debug: consoleLike.debug.bind(consoleLike)
};
return lockedMethods;
}
const _createLogger = (prefix, maybeCall, consoleLike)=>{
function _log(level, ...args) {
maybeCall(()=>{
const consoleMethod = consoleLike[level];
consoleMethod(prefix, ...args);
});
}
const logger = {
info: (...args)=>{
_log('log', ...args);
},
warn: (...args)=>{
_log('warn', ...args);
},
error: (...args)=>{
_log('error', ...args);
},
critical: (...args)=>{
consoleLike['error'](prefix, ...args);
},
createLogger: (additionalPrefix)=>_createLogger(`${prefix} ${additionalPrefix}`, maybeCall, consoleLike)
};
return logger;
};
const passThrough = (fn)=>fn();
function createLogger(prefix, maybeCall = passThrough) {
return _createLogger(prefix, maybeCall, createConsole());
}
exports._createLogger = __webpack_exports__._createLogger;
exports.createLogger = __webpack_exports__.createLogger;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"_createLogger",
"createLogger"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,38 +0,0 @@
function createConsole(consoleLike = console) {
const lockedMethods = {
log: consoleLike.log.bind(consoleLike),
warn: consoleLike.warn.bind(consoleLike),
error: consoleLike.error.bind(consoleLike),
debug: consoleLike.debug.bind(consoleLike)
};
return lockedMethods;
}
const _createLogger = (prefix, maybeCall, consoleLike)=>{
function _log(level, ...args) {
maybeCall(()=>{
const consoleMethod = consoleLike[level];
consoleMethod(prefix, ...args);
});
}
const logger = {
info: (...args)=>{
_log('log', ...args);
},
warn: (...args)=>{
_log('warn', ...args);
},
error: (...args)=>{
_log('error', ...args);
},
critical: (...args)=>{
consoleLike['error'](prefix, ...args);
},
createLogger: (additionalPrefix)=>_createLogger(`${prefix} ${additionalPrefix}`, maybeCall, consoleLike)
};
return logger;
};
const passThrough = (fn)=>fn();
function createLogger(prefix, maybeCall = passThrough) {
return _createLogger(prefix, maybeCall, createConsole());
}
export { _createLogger, createLogger };

View File

@@ -1,11 +0,0 @@
import { Logger } from '../types';
/**
* Clamps a value to a range.
* @param value the value to clamp
* @param min the minimum value
* @param max the maximum value
* @param label if provided then enables logging and prefixes all logs with labels
* @param fallbackValue if provided then returns this value if the value is not a valid number
*/
export declare function clampToRange(value: unknown, min: number, max: number, logger: Logger, fallbackValue?: number): number;
//# sourceMappingURL=number-utils.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"number-utils.d.ts","sourceRoot":"","sources":["../../src/utils/number-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBrH"}

View File

@@ -1,52 +0,0 @@
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
clampToRange: ()=>clampToRange
});
const external_type_utils_js_namespaceObject = require("./type-utils.js");
function clampToRange(value, min, max, logger, fallbackValue) {
if (min > max) {
logger.warn('min cannot be greater than max.');
min = max;
}
if ((0, external_type_utils_js_namespaceObject.isNumber)(value)) if (value > max) {
logger.warn(' cannot be greater than max: ' + max + '. Using max value instead.');
return max;
} else {
if (!(value < min)) return value;
logger.warn(' cannot be less than min: ' + min + '. Using min value instead.');
return min;
}
logger.warn(' must be a number. using max or fallback. max: ' + max + ', fallback: ' + fallbackValue);
return clampToRange(fallbackValue || max, min, max, logger);
}
exports.clampToRange = __webpack_exports__.clampToRange;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"clampToRange"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,18 +0,0 @@
import { isNumber } from "./type-utils.mjs";
function clampToRange(value, min, max, logger, fallbackValue) {
if (min > max) {
logger.warn('min cannot be greater than max.');
min = max;
}
if (isNumber(value)) if (value > max) {
logger.warn(' cannot be greater than max: ' + max + '. Using max value instead.');
return max;
} else {
if (!(value < min)) return value;
logger.warn(' cannot be less than min: ' + min + '. Using min value instead.');
return min;
}
logger.warn(' must be a number. using max or fallback. max: ' + max + ', fallback: ' + fallbackValue);
return clampToRange(fallbackValue || max, min, max, logger);
}
export { clampToRange };

View File

@@ -1,7 +0,0 @@
export declare class PromiseQueue {
private promiseByIds;
add(promise: Promise<any>): Promise<any>;
join(): Promise<void>;
get length(): number;
}
//# sourceMappingURL=promise-queue.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"promise-queue.d.ts","sourceRoot":"","sources":["../../src/utils/promise-queue.ts"],"names":[],"mappings":"AAEA,qBAAa,YAAY;IACvB,OAAO,CAAC,YAAY,CAAmC;IAEhD,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAWlC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlC,IAAW,MAAM,IAAI,MAAM,CAE1B;CACF"}

View File

@@ -1,61 +0,0 @@
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
PromiseQueue: ()=>PromiseQueue
});
const uuidv7_js_namespaceObject = require("../vendor/uuidv7.js");
class PromiseQueue {
add(promise) {
const promiseUUID = (0, uuidv7_js_namespaceObject.uuidv7)();
this.promiseByIds[promiseUUID] = promise;
promise.catch(()=>{}).finally(()=>{
delete this.promiseByIds[promiseUUID];
});
return promise;
}
async join() {
let promises = Object.values(this.promiseByIds);
let length = promises.length;
while(length > 0){
await Promise.all(promises);
promises = Object.values(this.promiseByIds);
length = promises.length;
}
}
get length() {
return Object.keys(this.promiseByIds).length;
}
constructor(){
this.promiseByIds = {};
}
}
exports.PromiseQueue = __webpack_exports__.PromiseQueue;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"PromiseQueue"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,27 +0,0 @@
import { uuidv7 } from "../vendor/uuidv7.mjs";
class PromiseQueue {
add(promise) {
const promiseUUID = uuidv7();
this.promiseByIds[promiseUUID] = promise;
promise.catch(()=>{}).finally(()=>{
delete this.promiseByIds[promiseUUID];
});
return promise;
}
async join() {
let promises = Object.values(this.promiseByIds);
let length = promises.length;
while(length > 0){
await Promise.all(promises);
promises = Object.values(this.promiseByIds);
length = promises.length;
}
}
get length() {
return Object.keys(this.promiseByIds).length;
}
constructor(){
this.promiseByIds = {};
}
}
export { PromiseQueue };

View File

@@ -1,6 +0,0 @@
export declare function includes(str: string, needle: string): boolean;
export declare function includes<T>(arr: T[], needle: T): boolean;
export declare const trim: (str: string) => string;
export declare const stripLeadingDollar: (s: string) => string;
export declare function isDistinctIdStringLike(value: string): boolean;
//# sourceMappingURL=string-utils.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../src/utils/string-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;AAC9D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAA;AAKzD,eAAO,MAAM,IAAI,GAAa,KAAK,MAAM,KAAG,MAM3C,CAAA;AAID,eAAO,MAAM,kBAAkB,GAAa,GAAG,MAAM,KAAG,MAEvD,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D"}

View File

@@ -1,59 +0,0 @@
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
includes: ()=>includes,
isDistinctIdStringLike: ()=>isDistinctIdStringLike,
stripLeadingDollar: ()=>stripLeadingDollar,
trim: ()=>trim
});
function includes(str, needle) {
return -1 !== str.indexOf(needle);
}
const trim = function(str) {
return str.trim();
};
const stripLeadingDollar = function(s) {
return s.replace(/^\$/, '');
};
function isDistinctIdStringLike(value) {
return [
'distinct_id',
'distinctid'
].includes(value.toLowerCase());
}
exports.includes = __webpack_exports__.includes;
exports.isDistinctIdStringLike = __webpack_exports__.isDistinctIdStringLike;
exports.stripLeadingDollar = __webpack_exports__.stripLeadingDollar;
exports.trim = __webpack_exports__.trim;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"includes",
"isDistinctIdStringLike",
"stripLeadingDollar",
"trim"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,16 +0,0 @@
function includes(str, needle) {
return -1 !== str.indexOf(needle);
}
const trim = function(str) {
return str.trim();
};
const stripLeadingDollar = function(s) {
return s.replace(/^\$/, '');
};
function isDistinctIdStringLike(value) {
return [
'distinct_id',
'distinctid'
].includes(value.toLowerCase());
}
export { includes, isDistinctIdStringLike, stripLeadingDollar, trim };

View File

@@ -1,30 +0,0 @@
import { KnownUnsafeEditableEvent } from '../types';
export declare const hasOwnProperty: (v: PropertyKey) => boolean;
export declare const isArray: (arg: any) => arg is any[];
export declare const isFunction: (x: unknown) => x is (...args: any[]) => any;
export declare const isNativeFunction: (x: unknown) => x is (...args: any[]) => any;
export declare const isObject: (x: unknown) => x is Record<string, any>;
export declare const isEmptyObject: (x: unknown) => boolean;
export declare const isUndefined: (x: unknown) => x is undefined;
export declare const isString: (x: unknown) => x is string;
export declare const isEmptyString: (x: unknown) => boolean;
export declare const isNull: (x: unknown) => x is null;
export declare const isNullish: (x: unknown) => x is null | undefined;
export declare const isNumber: (x: unknown) => x is number;
export declare const isBoolean: (x: unknown) => x is boolean;
export declare const isFormData: (x: unknown) => x is FormData;
export declare const isFile: (x: unknown) => x is File;
export declare const isPlainError: (x: unknown) => x is Error;
export declare const isKnownUnsafeEditableEvent: (x: unknown) => x is KnownUnsafeEditableEvent;
export declare function isInstanceOf(candidate: unknown, base: any): boolean;
export declare function isPrimitive(value: unknown): boolean;
export declare function isBuiltin(candidate: unknown, className: string): boolean;
export declare function isError(candidate: unknown): candidate is Error;
export declare function isErrorEvent(event: unknown): boolean;
export declare function isEvent(candidate: unknown): candidate is Event;
export declare function isPlainObject(candidate: unknown): candidate is Record<string, unknown>;
export declare const yesLikeValues: (string | number | boolean)[];
export declare const isYesLike: (val: string | boolean | number) => boolean;
export declare const noLikeValues: (string | number | boolean)[];
export declare const isNoLike: (val: string | boolean | number) => boolean;
//# sourceMappingURL=type-utils.d.ts.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../src/utils/type-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAM7E,eAAO,MAAM,cAAc,6BAA0B,CAAA;AAGrD,eAAO,MAAM,OAAO,4BAIjB,CAAA;AAKH,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAGhE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GACR,CAAA;AAG/D,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAG5D,CAAA;AACD,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,YAUvC,CAAA;AACD,eAAO,MAAM,WAAW,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,SAAyB,CAAA;AAEvE,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAG1C,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,OAA+C,CAAA;AAE1F,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,IAGxC,CAAA;AAMD,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,IAAI,GAAG,SAAwC,CAAA;AAE3F,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAG1C,CAAA;AACD,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,OAG3C,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,QAG5C,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,IAGxC,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAE9C,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,wBAE5D,CAAA;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAMnE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEnD;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAExE;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,KAAK,CAW9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,KAAK,CAE9D;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEtF;AAED,eAAO,MAAM,aAAa,+BAAgC,CAAA;AAC1D,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,GAAG,OAAO,GAAG,MAAM,KAAG,OAAuC,CAAA;AAClG,eAAO,MAAM,YAAY,+BAAiC,CAAA;AAC1D,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,GAAG,OAAO,GAAG,MAAM,KAAG,OAAsC,CAAA"}

View File

@@ -1,196 +0,0 @@
"use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, definition)=>{
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
get: definition[key]
});
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
isBoolean: ()=>isBoolean,
isBuiltin: ()=>isBuiltin,
isEmptyString: ()=>isEmptyString,
isNoLike: ()=>isNoLike,
isNull: ()=>isNull,
isNullish: ()=>isNullish,
isError: ()=>isError,
isEmptyObject: ()=>isEmptyObject,
hasOwnProperty: ()=>type_utils_hasOwnProperty,
isErrorEvent: ()=>isErrorEvent,
isNativeFunction: ()=>isNativeFunction,
isNumber: ()=>isNumber,
isPlainError: ()=>isPlainError,
isPlainObject: ()=>isPlainObject,
isPrimitive: ()=>isPrimitive,
isObject: ()=>isObject,
isUndefined: ()=>isUndefined,
isFunction: ()=>isFunction,
isArray: ()=>isArray,
isKnownUnsafeEditableEvent: ()=>isKnownUnsafeEditableEvent,
isString: ()=>isString,
noLikeValues: ()=>noLikeValues,
yesLikeValues: ()=>yesLikeValues,
isEvent: ()=>isEvent,
isFile: ()=>isFile,
isYesLike: ()=>isYesLike,
isFormData: ()=>isFormData,
isInstanceOf: ()=>isInstanceOf
});
const external_types_js_namespaceObject = require("../types.js");
const external_string_utils_js_namespaceObject = require("./string-utils.js");
const nativeIsArray = Array.isArray;
const ObjProto = Object.prototype;
const type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
const type_utils_toString = ObjProto.toString;
const isArray = nativeIsArray || function(obj) {
return '[object Array]' === type_utils_toString.call(obj);
};
const isFunction = (x)=>'function' == typeof x;
const isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');
const isObject = (x)=>x === Object(x) && !isArray(x);
const isEmptyObject = (x)=>{
if (isObject(x)) {
for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;
return true;
}
return false;
};
const isUndefined = (x)=>void 0 === x;
const isString = (x)=>'[object String]' == type_utils_toString.call(x);
const isEmptyString = (x)=>isString(x) && 0 === x.trim().length;
const isNull = (x)=>null === x;
const isNullish = (x)=>isUndefined(x) || isNull(x);
const isNumber = (x)=>'[object Number]' == type_utils_toString.call(x);
const isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);
const isFormData = (x)=>x instanceof FormData;
const isFile = (x)=>x instanceof File;
const isPlainError = (x)=>x instanceof Error;
const isKnownUnsafeEditableEvent = (x)=>(0, external_string_utils_js_namespaceObject.includes)(external_types_js_namespaceObject.knownUnsafeEditableEvent, x);
function isInstanceOf(candidate, base) {
try {
return candidate instanceof base;
} catch {
return false;
}
}
function isPrimitive(value) {
return null === value || 'object' != typeof value;
}
function isBuiltin(candidate, className) {
return Object.prototype.toString.call(candidate) === `[object ${className}]`;
}
function isError(candidate) {
switch(Object.prototype.toString.call(candidate)){
case '[object Error]':
case '[object Exception]':
case '[object DOMException]':
case '[object DOMError]':
case '[object WebAssembly.Exception]':
return true;
default:
return isInstanceOf(candidate, Error);
}
}
function isErrorEvent(event) {
return isBuiltin(event, 'ErrorEvent');
}
function isEvent(candidate) {
return !isUndefined(Event) && isInstanceOf(candidate, Event);
}
function isPlainObject(candidate) {
return isBuiltin(candidate, 'Object');
}
const yesLikeValues = [
true,
'true',
1,
'1',
'yes'
];
const isYesLike = (val)=>(0, external_string_utils_js_namespaceObject.includes)(yesLikeValues, val);
const noLikeValues = [
false,
'false',
0,
'0',
'no'
];
const isNoLike = (val)=>(0, external_string_utils_js_namespaceObject.includes)(noLikeValues, val);
exports.hasOwnProperty = __webpack_exports__.hasOwnProperty;
exports.isArray = __webpack_exports__.isArray;
exports.isBoolean = __webpack_exports__.isBoolean;
exports.isBuiltin = __webpack_exports__.isBuiltin;
exports.isEmptyObject = __webpack_exports__.isEmptyObject;
exports.isEmptyString = __webpack_exports__.isEmptyString;
exports.isError = __webpack_exports__.isError;
exports.isErrorEvent = __webpack_exports__.isErrorEvent;
exports.isEvent = __webpack_exports__.isEvent;
exports.isFile = __webpack_exports__.isFile;
exports.isFormData = __webpack_exports__.isFormData;
exports.isFunction = __webpack_exports__.isFunction;
exports.isInstanceOf = __webpack_exports__.isInstanceOf;
exports.isKnownUnsafeEditableEvent = __webpack_exports__.isKnownUnsafeEditableEvent;
exports.isNativeFunction = __webpack_exports__.isNativeFunction;
exports.isNoLike = __webpack_exports__.isNoLike;
exports.isNull = __webpack_exports__.isNull;
exports.isNullish = __webpack_exports__.isNullish;
exports.isNumber = __webpack_exports__.isNumber;
exports.isObject = __webpack_exports__.isObject;
exports.isPlainError = __webpack_exports__.isPlainError;
exports.isPlainObject = __webpack_exports__.isPlainObject;
exports.isPrimitive = __webpack_exports__.isPrimitive;
exports.isString = __webpack_exports__.isString;
exports.isUndefined = __webpack_exports__.isUndefined;
exports.isYesLike = __webpack_exports__.isYesLike;
exports.noLikeValues = __webpack_exports__.noLikeValues;
exports.yesLikeValues = __webpack_exports__.yesLikeValues;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
"hasOwnProperty",
"isArray",
"isBoolean",
"isBuiltin",
"isEmptyObject",
"isEmptyString",
"isError",
"isErrorEvent",
"isEvent",
"isFile",
"isFormData",
"isFunction",
"isInstanceOf",
"isKnownUnsafeEditableEvent",
"isNativeFunction",
"isNoLike",
"isNull",
"isNullish",
"isNumber",
"isObject",
"isPlainError",
"isPlainObject",
"isPrimitive",
"isString",
"isUndefined",
"isYesLike",
"noLikeValues",
"yesLikeValues"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
});

View File

@@ -1,81 +0,0 @@
import { knownUnsafeEditableEvent } from "../types.mjs";
import { includes } from "./string-utils.mjs";
const nativeIsArray = Array.isArray;
const ObjProto = Object.prototype;
const type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
const type_utils_toString = ObjProto.toString;
const isArray = nativeIsArray || function(obj) {
return '[object Array]' === type_utils_toString.call(obj);
};
const isFunction = (x)=>'function' == typeof x;
const isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');
const isObject = (x)=>x === Object(x) && !isArray(x);
const isEmptyObject = (x)=>{
if (isObject(x)) {
for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;
return true;
}
return false;
};
const isUndefined = (x)=>void 0 === x;
const isString = (x)=>'[object String]' == type_utils_toString.call(x);
const isEmptyString = (x)=>isString(x) && 0 === x.trim().length;
const isNull = (x)=>null === x;
const isNullish = (x)=>isUndefined(x) || isNull(x);
const isNumber = (x)=>'[object Number]' == type_utils_toString.call(x);
const isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);
const isFormData = (x)=>x instanceof FormData;
const isFile = (x)=>x instanceof File;
const isPlainError = (x)=>x instanceof Error;
const isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);
function isInstanceOf(candidate, base) {
try {
return candidate instanceof base;
} catch {
return false;
}
}
function isPrimitive(value) {
return null === value || 'object' != typeof value;
}
function isBuiltin(candidate, className) {
return Object.prototype.toString.call(candidate) === `[object ${className}]`;
}
function isError(candidate) {
switch(Object.prototype.toString.call(candidate)){
case '[object Error]':
case '[object Exception]':
case '[object DOMException]':
case '[object DOMError]':
case '[object WebAssembly.Exception]':
return true;
default:
return isInstanceOf(candidate, Error);
}
}
function isErrorEvent(event) {
return isBuiltin(event, 'ErrorEvent');
}
function isEvent(candidate) {
return !isUndefined(Event) && isInstanceOf(candidate, Event);
}
function isPlainObject(candidate) {
return isBuiltin(candidate, 'Object');
}
const yesLikeValues = [
true,
'true',
1,
'1',
'yes'
];
const isYesLike = (val)=>includes(yesLikeValues, val);
const noLikeValues = [
false,
'false',
0,
'0',
'no'
];
const isNoLike = (val)=>includes(noLikeValues, val);
export { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isInstanceOf, isKnownUnsafeEditableEvent, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };