2
This commit is contained in:
59
parent_dir/20240530212112Z/node_modules/axios/lib/adapters/adapters.js
generated
vendored
Normal file
59
parent_dir/20240530212112Z/node_modules/axios/lib/adapters/adapters.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import utils from '../utils.js';
|
||||
import httpAdapter from './http.js';
|
||||
import xhrAdapter from './xhr.js';
|
||||
import AxiosError from "../core/AxiosError.js";
|
||||
|
||||
const knownAdapters = {
|
||||
http: httpAdapter,
|
||||
xhr: xhrAdapter
|
||||
}
|
||||
|
||||
utils.forEach(knownAdapters, (fn, value) => {
|
||||
if(fn) {
|
||||
try {
|
||||
Object.defineProperty(fn, 'name', {value});
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-empty
|
||||
}
|
||||
Object.defineProperty(fn, 'adapterName', {value});
|
||||
}
|
||||
});
|
||||
|
||||
export default {
|
||||
getAdapter: (adapters) => {
|
||||
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
||||
|
||||
const {length} = adapters;
|
||||
let nameOrAdapter;
|
||||
let adapter;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
nameOrAdapter = adapters[i];
|
||||
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!adapter) {
|
||||
if (adapter === false) {
|
||||
throw new AxiosError(
|
||||
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
||||
'ERR_NOT_SUPPORT'
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
||||
`Adapter '${nameOrAdapter}' is not available in the build` :
|
||||
`Unknown adapter '${nameOrAdapter}'`
|
||||
);
|
||||
}
|
||||
|
||||
if (!utils.isFunction(adapter)) {
|
||||
throw new TypeError('adapter is not a function');
|
||||
}
|
||||
|
||||
return adapter;
|
||||
},
|
||||
adapters: knownAdapters
|
||||
}
|
249
parent_dir/20240530212112Z/node_modules/axios/lib/adapters/xhr.js
generated
vendored
Normal file
249
parent_dir/20240530212112Z/node_modules/axios/lib/adapters/xhr.js
generated
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
import settle from './../core/settle.js';
|
||||
import cookies from './../helpers/cookies.js';
|
||||
import buildURL from './../helpers/buildURL.js';
|
||||
import buildFullPath from '../core/buildFullPath.js';
|
||||
import isURLSameOrigin from './../helpers/isURLSameOrigin.js';
|
||||
import transitionalDefaults from '../defaults/transitional.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
import CanceledError from '../cancel/CanceledError.js';
|
||||
import parseProtocol from '../helpers/parseProtocol.js';
|
||||
import platform from '../platform/index.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import speedometer from '../helpers/speedometer.js';
|
||||
|
||||
function progressEventReducer(listener, isDownloadStream) {
|
||||
let bytesNotified = 0;
|
||||
const _speedometer = speedometer(50, 250);
|
||||
|
||||
return e => {
|
||||
const loaded = e.loaded;
|
||||
const total = e.lengthComputable ? e.total : undefined;
|
||||
const progressBytes = loaded - bytesNotified;
|
||||
const rate = _speedometer(progressBytes);
|
||||
const inRange = loaded <= total;
|
||||
|
||||
bytesNotified = loaded;
|
||||
|
||||
const data = {
|
||||
loaded,
|
||||
total,
|
||||
progress: total ? (loaded / total) : undefined,
|
||||
bytes: progressBytes,
|
||||
rate: rate ? rate : undefined,
|
||||
estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
|
||||
event: e
|
||||
};
|
||||
|
||||
data[isDownloadStream ? 'download' : 'upload'] = true;
|
||||
|
||||
listener(data);
|
||||
};
|
||||
}
|
||||
|
||||
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
||||
|
||||
export default isXHRAdapterSupported && function (config) {
|
||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||
let requestData = config.data;
|
||||
const requestHeaders = AxiosHeaders.from(config.headers).normalize();
|
||||
const responseType = config.responseType;
|
||||
let onCanceled;
|
||||
function done() {
|
||||
if (config.cancelToken) {
|
||||
config.cancelToken.unsubscribe(onCanceled);
|
||||
}
|
||||
|
||||
if (config.signal) {
|
||||
config.signal.removeEventListener('abort', onCanceled);
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
|
||||
requestHeaders.setContentType(false); // Let the browser set it
|
||||
}
|
||||
|
||||
let request = new XMLHttpRequest();
|
||||
|
||||
// HTTP basic authentication
|
||||
if (config.auth) {
|
||||
const username = config.auth.username || '';
|
||||
const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
||||
requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
|
||||
}
|
||||
|
||||
const fullPath = buildFullPath(config.baseURL, config.url);
|
||||
|
||||
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
||||
|
||||
// Set the request timeout in MS
|
||||
request.timeout = config.timeout;
|
||||
|
||||
function onloadend() {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
// Prepare the response
|
||||
const responseHeaders = AxiosHeaders.from(
|
||||
'getAllResponseHeaders' in request && request.getAllResponseHeaders()
|
||||
);
|
||||
const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
||||
request.responseText : request.response;
|
||||
const response = {
|
||||
data: responseData,
|
||||
status: request.status,
|
||||
statusText: request.statusText,
|
||||
headers: responseHeaders,
|
||||
config,
|
||||
request
|
||||
};
|
||||
|
||||
settle(function _resolve(value) {
|
||||
resolve(value);
|
||||
done();
|
||||
}, function _reject(err) {
|
||||
reject(err);
|
||||
done();
|
||||
}, response);
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
}
|
||||
|
||||
if ('onloadend' in request) {
|
||||
// Use onloadend if available
|
||||
request.onloadend = onloadend;
|
||||
} else {
|
||||
// Listen for ready state to emulate onloadend
|
||||
request.onreadystatechange = function handleLoad() {
|
||||
if (!request || request.readyState !== 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The request errored out and we didn't get a response, this will be
|
||||
// handled by onerror instead
|
||||
// With one exception: request that using file: protocol, most browsers
|
||||
// will return status as 0 even though it's a successful request
|
||||
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
||||
return;
|
||||
}
|
||||
// readystate handler is calling before onerror or ontimeout handlers,
|
||||
// so we should call onloadend on the next 'tick'
|
||||
setTimeout(onloadend);
|
||||
};
|
||||
}
|
||||
|
||||
// Handle browser request cancellation (as opposed to a manual cancellation)
|
||||
request.onabort = function handleAbort() {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
|
||||
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Handle low level network errors
|
||||
request.onerror = function handleError() {
|
||||
// Real errors are hidden from us by the browser
|
||||
// onerror should only fire if it's a network error
|
||||
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Handle timeout
|
||||
request.ontimeout = function handleTimeout() {
|
||||
let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
||||
const transitional = config.transitional || transitionalDefaults;
|
||||
if (config.timeoutErrorMessage) {
|
||||
timeoutErrorMessage = config.timeoutErrorMessage;
|
||||
}
|
||||
reject(new AxiosError(
|
||||
timeoutErrorMessage,
|
||||
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
||||
config,
|
||||
request));
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
};
|
||||
|
||||
// Add xsrf header
|
||||
// This is only done if running in a standard browser environment.
|
||||
// Specifically not if we're in a web worker, or react-native.
|
||||
if (platform.isStandardBrowserEnv) {
|
||||
// Add xsrf header
|
||||
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
|
||||
&& config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
||||
|
||||
if (xsrfValue) {
|
||||
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove Content-Type if data is undefined
|
||||
requestData === undefined && requestHeaders.setContentType(null);
|
||||
|
||||
// Add headers to the request
|
||||
if ('setRequestHeader' in request) {
|
||||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
||||
request.setRequestHeader(key, val);
|
||||
});
|
||||
}
|
||||
|
||||
// Add withCredentials to request if needed
|
||||
if (!utils.isUndefined(config.withCredentials)) {
|
||||
request.withCredentials = !!config.withCredentials;
|
||||
}
|
||||
|
||||
// Add responseType to request if needed
|
||||
if (responseType && responseType !== 'json') {
|
||||
request.responseType = config.responseType;
|
||||
}
|
||||
|
||||
// Handle progress if needed
|
||||
if (typeof config.onDownloadProgress === 'function') {
|
||||
request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
|
||||
}
|
||||
|
||||
// Not all browsers support upload events
|
||||
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
||||
request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
|
||||
}
|
||||
|
||||
if (config.cancelToken || config.signal) {
|
||||
// Handle cancellation
|
||||
// eslint-disable-next-line func-names
|
||||
onCanceled = cancel => {
|
||||
if (!request) {
|
||||
return;
|
||||
}
|
||||
reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
|
||||
request.abort();
|
||||
request = null;
|
||||
};
|
||||
|
||||
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
||||
if (config.signal) {
|
||||
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
||||
}
|
||||
}
|
||||
|
||||
const protocol = parseProtocol(fullPath);
|
||||
|
||||
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
||||
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Send the request
|
||||
request.send(requestData || null);
|
||||
});
|
||||
}
|
86
parent_dir/20240530212112Z/node_modules/axios/lib/axios.js
generated
vendored
Normal file
86
parent_dir/20240530212112Z/node_modules/axios/lib/axios.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './utils.js';
|
||||
import bind from './helpers/bind.js';
|
||||
import Axios from './core/Axios.js';
|
||||
import mergeConfig from './core/mergeConfig.js';
|
||||
import defaults from './defaults/index.js';
|
||||
import formDataToJSON from './helpers/formDataToJSON.js';
|
||||
import CanceledError from './cancel/CanceledError.js';
|
||||
import CancelToken from './cancel/CancelToken.js';
|
||||
import isCancel from './cancel/isCancel.js';
|
||||
import {VERSION} from './env/data.js';
|
||||
import toFormData from './helpers/toFormData.js';
|
||||
import AxiosError from './core/AxiosError.js';
|
||||
import spread from './helpers/spread.js';
|
||||
import isAxiosError from './helpers/isAxiosError.js';
|
||||
import AxiosHeaders from "./core/AxiosHeaders.js";
|
||||
import HttpStatusCode from './helpers/HttpStatusCode.js';
|
||||
|
||||
/**
|
||||
* Create an instance of Axios
|
||||
*
|
||||
* @param {Object} defaultConfig The default config for the instance
|
||||
*
|
||||
* @returns {Axios} A new instance of Axios
|
||||
*/
|
||||
function createInstance(defaultConfig) {
|
||||
const context = new Axios(defaultConfig);
|
||||
const instance = bind(Axios.prototype.request, context);
|
||||
|
||||
// Copy axios.prototype to instance
|
||||
utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
|
||||
|
||||
// Copy context to instance
|
||||
utils.extend(instance, context, null, {allOwnKeys: true});
|
||||
|
||||
// Factory for creating new instances
|
||||
instance.create = function create(instanceConfig) {
|
||||
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
||||
};
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Create the default instance to be exported
|
||||
const axios = createInstance(defaults);
|
||||
|
||||
// Expose Axios class to allow class inheritance
|
||||
axios.Axios = Axios;
|
||||
|
||||
// Expose Cancel & CancelToken
|
||||
axios.CanceledError = CanceledError;
|
||||
axios.CancelToken = CancelToken;
|
||||
axios.isCancel = isCancel;
|
||||
axios.VERSION = VERSION;
|
||||
axios.toFormData = toFormData;
|
||||
|
||||
// Expose AxiosError class
|
||||
axios.AxiosError = AxiosError;
|
||||
|
||||
// alias for CanceledError for backward compatibility
|
||||
axios.Cancel = axios.CanceledError;
|
||||
|
||||
// Expose all/spread
|
||||
axios.all = function all(promises) {
|
||||
return Promise.all(promises);
|
||||
};
|
||||
|
||||
axios.spread = spread;
|
||||
|
||||
// Expose isAxiosError
|
||||
axios.isAxiosError = isAxiosError;
|
||||
|
||||
// Expose mergeConfig
|
||||
axios.mergeConfig = mergeConfig;
|
||||
|
||||
axios.AxiosHeaders = AxiosHeaders;
|
||||
|
||||
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
||||
|
||||
axios.HttpStatusCode = HttpStatusCode;
|
||||
|
||||
axios.default = axios;
|
||||
|
||||
// this module should only have a default export
|
||||
export default axios
|
121
parent_dir/20240530212112Z/node_modules/axios/lib/cancel/CancelToken.js
generated
vendored
Normal file
121
parent_dir/20240530212112Z/node_modules/axios/lib/cancel/CancelToken.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
|
||||
import CanceledError from './CanceledError.js';
|
||||
|
||||
/**
|
||||
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
||||
*
|
||||
* @param {Function} executor The executor function.
|
||||
*
|
||||
* @returns {CancelToken}
|
||||
*/
|
||||
class CancelToken {
|
||||
constructor(executor) {
|
||||
if (typeof executor !== 'function') {
|
||||
throw new TypeError('executor must be a function.');
|
||||
}
|
||||
|
||||
let resolvePromise;
|
||||
|
||||
this.promise = new Promise(function promiseExecutor(resolve) {
|
||||
resolvePromise = resolve;
|
||||
});
|
||||
|
||||
const token = this;
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
this.promise.then(cancel => {
|
||||
if (!token._listeners) return;
|
||||
|
||||
let i = token._listeners.length;
|
||||
|
||||
while (i-- > 0) {
|
||||
token._listeners[i](cancel);
|
||||
}
|
||||
token._listeners = null;
|
||||
});
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
this.promise.then = onfulfilled => {
|
||||
let _resolve;
|
||||
// eslint-disable-next-line func-names
|
||||
const promise = new Promise(resolve => {
|
||||
token.subscribe(resolve);
|
||||
_resolve = resolve;
|
||||
}).then(onfulfilled);
|
||||
|
||||
promise.cancel = function reject() {
|
||||
token.unsubscribe(_resolve);
|
||||
};
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
executor(function cancel(message, config, request) {
|
||||
if (token.reason) {
|
||||
// Cancellation has already been requested
|
||||
return;
|
||||
}
|
||||
|
||||
token.reason = new CanceledError(message, config, request);
|
||||
resolvePromise(token.reason);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws a `CanceledError` if cancellation has been requested.
|
||||
*/
|
||||
throwIfRequested() {
|
||||
if (this.reason) {
|
||||
throw this.reason;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to the cancel signal
|
||||
*/
|
||||
|
||||
subscribe(listener) {
|
||||
if (this.reason) {
|
||||
listener(this.reason);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._listeners) {
|
||||
this._listeners.push(listener);
|
||||
} else {
|
||||
this._listeners = [listener];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from the cancel signal
|
||||
*/
|
||||
|
||||
unsubscribe(listener) {
|
||||
if (!this._listeners) {
|
||||
return;
|
||||
}
|
||||
const index = this._listeners.indexOf(listener);
|
||||
if (index !== -1) {
|
||||
this._listeners.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
||||
* cancels the `CancelToken`.
|
||||
*/
|
||||
static source() {
|
||||
let cancel;
|
||||
const token = new CancelToken(function executor(c) {
|
||||
cancel = c;
|
||||
});
|
||||
return {
|
||||
token,
|
||||
cancel
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default CancelToken;
|
25
parent_dir/20240530212112Z/node_modules/axios/lib/cancel/CanceledError.js
generated
vendored
Normal file
25
parent_dir/20240530212112Z/node_modules/axios/lib/cancel/CanceledError.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
import utils from '../utils.js';
|
||||
|
||||
/**
|
||||
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
||||
*
|
||||
* @param {string=} message The message.
|
||||
* @param {Object=} config The config.
|
||||
* @param {Object=} request The request.
|
||||
*
|
||||
* @returns {CanceledError} The created error.
|
||||
*/
|
||||
function CanceledError(message, config, request) {
|
||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
||||
this.name = 'CanceledError';
|
||||
}
|
||||
|
||||
utils.inherits(CanceledError, AxiosError, {
|
||||
__CANCEL__: true
|
||||
});
|
||||
|
||||
export default CanceledError;
|
5
parent_dir/20240530212112Z/node_modules/axios/lib/cancel/isCancel.js
generated
vendored
Normal file
5
parent_dir/20240530212112Z/node_modules/axios/lib/cancel/isCancel.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
export default function isCancel(value) {
|
||||
return !!(value && value.__CANCEL__);
|
||||
}
|
203
parent_dir/20240530212112Z/node_modules/axios/lib/core/Axios.js
generated
vendored
Normal file
203
parent_dir/20240530212112Z/node_modules/axios/lib/core/Axios.js
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
import buildURL from '../helpers/buildURL.js';
|
||||
import InterceptorManager from './InterceptorManager.js';
|
||||
import dispatchRequest from './dispatchRequest.js';
|
||||
import mergeConfig from './mergeConfig.js';
|
||||
import buildFullPath from './buildFullPath.js';
|
||||
import validator from '../helpers/validator.js';
|
||||
import AxiosHeaders from './AxiosHeaders.js';
|
||||
|
||||
const validators = validator.validators;
|
||||
|
||||
/**
|
||||
* Create a new instance of Axios
|
||||
*
|
||||
* @param {Object} instanceConfig The default config for the instance
|
||||
*
|
||||
* @return {Axios} A new instance of Axios
|
||||
*/
|
||||
class Axios {
|
||||
constructor(instanceConfig) {
|
||||
this.defaults = instanceConfig;
|
||||
this.interceptors = {
|
||||
request: new InterceptorManager(),
|
||||
response: new InterceptorManager()
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a request
|
||||
*
|
||||
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
||||
* @param {?Object} config
|
||||
*
|
||||
* @returns {Promise} The Promise to be fulfilled
|
||||
*/
|
||||
request(configOrUrl, config) {
|
||||
/*eslint no-param-reassign:0*/
|
||||
// Allow for axios('example/url'[, config]) a la fetch API
|
||||
if (typeof configOrUrl === 'string') {
|
||||
config = config || {};
|
||||
config.url = configOrUrl;
|
||||
} else {
|
||||
config = configOrUrl || {};
|
||||
}
|
||||
|
||||
config = mergeConfig(this.defaults, config);
|
||||
|
||||
const {transitional, paramsSerializer, headers} = config;
|
||||
|
||||
if (transitional !== undefined) {
|
||||
validator.assertOptions(transitional, {
|
||||
silentJSONParsing: validators.transitional(validators.boolean),
|
||||
forcedJSONParsing: validators.transitional(validators.boolean),
|
||||
clarifyTimeoutError: validators.transitional(validators.boolean)
|
||||
}, false);
|
||||
}
|
||||
|
||||
if (paramsSerializer != null) {
|
||||
if (utils.isFunction(paramsSerializer)) {
|
||||
config.paramsSerializer = {
|
||||
serialize: paramsSerializer
|
||||
}
|
||||
} else {
|
||||
validator.assertOptions(paramsSerializer, {
|
||||
encode: validators.function,
|
||||
serialize: validators.function
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set config.method
|
||||
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
||||
|
||||
let contextHeaders;
|
||||
|
||||
// Flatten headers
|
||||
contextHeaders = headers && utils.merge(
|
||||
headers.common,
|
||||
headers[config.method]
|
||||
);
|
||||
|
||||
contextHeaders && utils.forEach(
|
||||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
||||
(method) => {
|
||||
delete headers[method];
|
||||
}
|
||||
);
|
||||
|
||||
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
||||
|
||||
// filter out skipped interceptors
|
||||
const requestInterceptorChain = [];
|
||||
let synchronousRequestInterceptors = true;
|
||||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
||||
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
||||
|
||||
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
||||
});
|
||||
|
||||
const responseInterceptorChain = [];
|
||||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
||||
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
||||
});
|
||||
|
||||
let promise;
|
||||
let i = 0;
|
||||
let len;
|
||||
|
||||
if (!synchronousRequestInterceptors) {
|
||||
const chain = [dispatchRequest.bind(this), undefined];
|
||||
chain.unshift.apply(chain, requestInterceptorChain);
|
||||
chain.push.apply(chain, responseInterceptorChain);
|
||||
len = chain.length;
|
||||
|
||||
promise = Promise.resolve(config);
|
||||
|
||||
while (i < len) {
|
||||
promise = promise.then(chain[i++], chain[i++]);
|
||||
}
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
len = requestInterceptorChain.length;
|
||||
|
||||
let newConfig = config;
|
||||
|
||||
i = 0;
|
||||
|
||||
while (i < len) {
|
||||
const onFulfilled = requestInterceptorChain[i++];
|
||||
const onRejected = requestInterceptorChain[i++];
|
||||
try {
|
||||
newConfig = onFulfilled(newConfig);
|
||||
} catch (error) {
|
||||
onRejected.call(this, error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
promise = dispatchRequest.call(this, newConfig);
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
len = responseInterceptorChain.length;
|
||||
|
||||
while (i < len) {
|
||||
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
||||
}
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
getUri(config) {
|
||||
config = mergeConfig(this.defaults, config);
|
||||
const fullPath = buildFullPath(config.baseURL, config.url);
|
||||
return buildURL(fullPath, config.params, config.paramsSerializer);
|
||||
}
|
||||
}
|
||||
|
||||
// Provide aliases for supported request methods
|
||||
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
||||
/*eslint func-names:0*/
|
||||
Axios.prototype[method] = function(url, config) {
|
||||
return this.request(mergeConfig(config || {}, {
|
||||
method,
|
||||
url,
|
||||
data: (config || {}).data
|
||||
}));
|
||||
};
|
||||
});
|
||||
|
||||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||
/*eslint func-names:0*/
|
||||
|
||||
function generateHTTPMethod(isForm) {
|
||||
return function httpMethod(url, data, config) {
|
||||
return this.request(mergeConfig(config || {}, {
|
||||
method,
|
||||
headers: isForm ? {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
} : {},
|
||||
url,
|
||||
data
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
Axios.prototype[method] = generateHTTPMethod();
|
||||
|
||||
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
||||
});
|
||||
|
||||
export default Axios;
|
100
parent_dir/20240530212112Z/node_modules/axios/lib/core/AxiosError.js
generated
vendored
Normal file
100
parent_dir/20240530212112Z/node_modules/axios/lib/core/AxiosError.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
|
||||
/**
|
||||
* Create an Error with the specified message, config, error code, request and response.
|
||||
*
|
||||
* @param {string} message The error message.
|
||||
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
||||
* @param {Object} [config] The config.
|
||||
* @param {Object} [request] The request.
|
||||
* @param {Object} [response] The response.
|
||||
*
|
||||
* @returns {Error} The created error.
|
||||
*/
|
||||
function AxiosError(message, code, config, request, response) {
|
||||
Error.call(this);
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
} else {
|
||||
this.stack = (new Error()).stack;
|
||||
}
|
||||
|
||||
this.message = message;
|
||||
this.name = 'AxiosError';
|
||||
code && (this.code = code);
|
||||
config && (this.config = config);
|
||||
request && (this.request = request);
|
||||
response && (this.response = response);
|
||||
}
|
||||
|
||||
utils.inherits(AxiosError, Error, {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
// Standard
|
||||
message: this.message,
|
||||
name: this.name,
|
||||
// Microsoft
|
||||
description: this.description,
|
||||
number: this.number,
|
||||
// Mozilla
|
||||
fileName: this.fileName,
|
||||
lineNumber: this.lineNumber,
|
||||
columnNumber: this.columnNumber,
|
||||
stack: this.stack,
|
||||
// Axios
|
||||
config: utils.toJSONObject(this.config),
|
||||
code: this.code,
|
||||
status: this.response && this.response.status ? this.response.status : null
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
const prototype = AxiosError.prototype;
|
||||
const descriptors = {};
|
||||
|
||||
[
|
||||
'ERR_BAD_OPTION_VALUE',
|
||||
'ERR_BAD_OPTION',
|
||||
'ECONNABORTED',
|
||||
'ETIMEDOUT',
|
||||
'ERR_NETWORK',
|
||||
'ERR_FR_TOO_MANY_REDIRECTS',
|
||||
'ERR_DEPRECATED',
|
||||
'ERR_BAD_RESPONSE',
|
||||
'ERR_BAD_REQUEST',
|
||||
'ERR_CANCELED',
|
||||
'ERR_NOT_SUPPORT',
|
||||
'ERR_INVALID_URL'
|
||||
// eslint-disable-next-line func-names
|
||||
].forEach(code => {
|
||||
descriptors[code] = {value: code};
|
||||
});
|
||||
|
||||
Object.defineProperties(AxiosError, descriptors);
|
||||
Object.defineProperty(prototype, 'isAxiosError', {value: true});
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
AxiosError.from = (error, code, config, request, response, customProps) => {
|
||||
const axiosError = Object.create(prototype);
|
||||
|
||||
utils.toFlatObject(error, axiosError, function filter(obj) {
|
||||
return obj !== Error.prototype;
|
||||
}, prop => {
|
||||
return prop !== 'isAxiosError';
|
||||
});
|
||||
|
||||
AxiosError.call(axiosError, error.message, code, config, request, response);
|
||||
|
||||
axiosError.cause = error;
|
||||
|
||||
axiosError.name = error.name;
|
||||
|
||||
customProps && Object.assign(axiosError, customProps);
|
||||
|
||||
return axiosError;
|
||||
};
|
||||
|
||||
export default AxiosError;
|
288
parent_dir/20240530212112Z/node_modules/axios/lib/core/AxiosHeaders.js
generated
vendored
Normal file
288
parent_dir/20240530212112Z/node_modules/axios/lib/core/AxiosHeaders.js
generated
vendored
Normal file
@@ -0,0 +1,288 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
import parseHeaders from '../helpers/parseHeaders.js';
|
||||
|
||||
const $internals = Symbol('internals');
|
||||
|
||||
function normalizeHeader(header) {
|
||||
return header && String(header).trim().toLowerCase();
|
||||
}
|
||||
|
||||
function normalizeValue(value) {
|
||||
if (value === false || value == null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
||||
}
|
||||
|
||||
function parseTokens(str) {
|
||||
const tokens = Object.create(null);
|
||||
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
||||
let match;
|
||||
|
||||
while ((match = tokensRE.exec(str))) {
|
||||
tokens[match[1]] = match[2];
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
||||
|
||||
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
||||
if (utils.isFunction(filter)) {
|
||||
return filter.call(this, value, header);
|
||||
}
|
||||
|
||||
if (isHeaderNameFilter) {
|
||||
value = header;
|
||||
}
|
||||
|
||||
if (!utils.isString(value)) return;
|
||||
|
||||
if (utils.isString(filter)) {
|
||||
return value.indexOf(filter) !== -1;
|
||||
}
|
||||
|
||||
if (utils.isRegExp(filter)) {
|
||||
return filter.test(value);
|
||||
}
|
||||
}
|
||||
|
||||
function formatHeader(header) {
|
||||
return header.trim()
|
||||
.toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
||||
return char.toUpperCase() + str;
|
||||
});
|
||||
}
|
||||
|
||||
function buildAccessors(obj, header) {
|
||||
const accessorName = utils.toCamelCase(' ' + header);
|
||||
|
||||
['get', 'set', 'has'].forEach(methodName => {
|
||||
Object.defineProperty(obj, methodName + accessorName, {
|
||||
value: function(arg1, arg2, arg3) {
|
||||
return this[methodName].call(this, header, arg1, arg2, arg3);
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class AxiosHeaders {
|
||||
constructor(headers) {
|
||||
headers && this.set(headers);
|
||||
}
|
||||
|
||||
set(header, valueOrRewrite, rewrite) {
|
||||
const self = this;
|
||||
|
||||
function setHeader(_value, _header, _rewrite) {
|
||||
const lHeader = normalizeHeader(_header);
|
||||
|
||||
if (!lHeader) {
|
||||
throw new Error('header name must be a non-empty string');
|
||||
}
|
||||
|
||||
const key = utils.findKey(self, lHeader);
|
||||
|
||||
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
||||
self[key || _header] = normalizeValue(_value);
|
||||
}
|
||||
}
|
||||
|
||||
const setHeaders = (headers, _rewrite) =>
|
||||
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
||||
|
||||
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
||||
setHeaders(header, valueOrRewrite)
|
||||
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
||||
setHeaders(parseHeaders(header), valueOrRewrite);
|
||||
} else {
|
||||
header != null && setHeader(valueOrRewrite, header, rewrite);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
get(header, parser) {
|
||||
header = normalizeHeader(header);
|
||||
|
||||
if (header) {
|
||||
const key = utils.findKey(this, header);
|
||||
|
||||
if (key) {
|
||||
const value = this[key];
|
||||
|
||||
if (!parser) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (parser === true) {
|
||||
return parseTokens(value);
|
||||
}
|
||||
|
||||
if (utils.isFunction(parser)) {
|
||||
return parser.call(this, value, key);
|
||||
}
|
||||
|
||||
if (utils.isRegExp(parser)) {
|
||||
return parser.exec(value);
|
||||
}
|
||||
|
||||
throw new TypeError('parser must be boolean|regexp|function');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
has(header, matcher) {
|
||||
header = normalizeHeader(header);
|
||||
|
||||
if (header) {
|
||||
const key = utils.findKey(this, header);
|
||||
|
||||
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
delete(header, matcher) {
|
||||
const self = this;
|
||||
let deleted = false;
|
||||
|
||||
function deleteHeader(_header) {
|
||||
_header = normalizeHeader(_header);
|
||||
|
||||
if (_header) {
|
||||
const key = utils.findKey(self, _header);
|
||||
|
||||
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
||||
delete self[key];
|
||||
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isArray(header)) {
|
||||
header.forEach(deleteHeader);
|
||||
} else {
|
||||
deleteHeader(header);
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
clear(matcher) {
|
||||
const keys = Object.keys(this);
|
||||
let i = keys.length;
|
||||
let deleted = false;
|
||||
|
||||
while (i--) {
|
||||
const key = keys[i];
|
||||
if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
||||
delete this[key];
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
normalize(format) {
|
||||
const self = this;
|
||||
const headers = {};
|
||||
|
||||
utils.forEach(this, (value, header) => {
|
||||
const key = utils.findKey(headers, header);
|
||||
|
||||
if (key) {
|
||||
self[key] = normalizeValue(value);
|
||||
delete self[header];
|
||||
return;
|
||||
}
|
||||
|
||||
const normalized = format ? formatHeader(header) : String(header).trim();
|
||||
|
||||
if (normalized !== header) {
|
||||
delete self[header];
|
||||
}
|
||||
|
||||
self[normalized] = normalizeValue(value);
|
||||
|
||||
headers[normalized] = true;
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
concat(...targets) {
|
||||
return this.constructor.concat(this, ...targets);
|
||||
}
|
||||
|
||||
toJSON(asStrings) {
|
||||
const obj = Object.create(null);
|
||||
|
||||
utils.forEach(this, (value, header) => {
|
||||
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return Object.entries(this.toJSON())[Symbol.iterator]();
|
||||
}
|
||||
|
||||
toString() {
|
||||
return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag]() {
|
||||
return 'AxiosHeaders';
|
||||
}
|
||||
|
||||
static from(thing) {
|
||||
return thing instanceof this ? thing : new this(thing);
|
||||
}
|
||||
|
||||
static concat(first, ...targets) {
|
||||
const computed = new this(first);
|
||||
|
||||
targets.forEach((target) => computed.set(target));
|
||||
|
||||
return computed;
|
||||
}
|
||||
|
||||
static accessor(header) {
|
||||
const internals = this[$internals] = (this[$internals] = {
|
||||
accessors: {}
|
||||
});
|
||||
|
||||
const accessors = internals.accessors;
|
||||
const prototype = this.prototype;
|
||||
|
||||
function defineAccessor(_header) {
|
||||
const lHeader = normalizeHeader(_header);
|
||||
|
||||
if (!accessors[lHeader]) {
|
||||
buildAccessors(prototype, _header);
|
||||
accessors[lHeader] = true;
|
||||
}
|
||||
}
|
||||
|
||||
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
||||
|
||||
utils.freezeMethods(AxiosHeaders.prototype);
|
||||
utils.freezeMethods(AxiosHeaders);
|
||||
|
||||
export default AxiosHeaders;
|
71
parent_dir/20240530212112Z/node_modules/axios/lib/core/InterceptorManager.js
generated
vendored
Normal file
71
parent_dir/20240530212112Z/node_modules/axios/lib/core/InterceptorManager.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
|
||||
class InterceptorManager {
|
||||
constructor() {
|
||||
this.handlers = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new interceptor to the stack
|
||||
*
|
||||
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
||||
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
||||
*
|
||||
* @return {Number} An ID used to remove interceptor later
|
||||
*/
|
||||
use(fulfilled, rejected, options) {
|
||||
this.handlers.push({
|
||||
fulfilled,
|
||||
rejected,
|
||||
synchronous: options ? options.synchronous : false,
|
||||
runWhen: options ? options.runWhen : null
|
||||
});
|
||||
return this.handlers.length - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an interceptor from the stack
|
||||
*
|
||||
* @param {Number} id The ID that was returned by `use`
|
||||
*
|
||||
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
||||
*/
|
||||
eject(id) {
|
||||
if (this.handlers[id]) {
|
||||
this.handlers[id] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all interceptors from the stack
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
clear() {
|
||||
if (this.handlers) {
|
||||
this.handlers = [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over all the registered interceptors
|
||||
*
|
||||
* This method is particularly useful for skipping over any
|
||||
* interceptors that may have become `null` calling `eject`.
|
||||
*
|
||||
* @param {Function} fn The function to call for each interceptor
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
forEach(fn) {
|
||||
utils.forEach(this.handlers, function forEachHandler(h) {
|
||||
if (h !== null) {
|
||||
fn(h);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default InterceptorManager;
|
21
parent_dir/20240530212112Z/node_modules/axios/lib/core/buildFullPath.js
generated
vendored
Normal file
21
parent_dir/20240530212112Z/node_modules/axios/lib/core/buildFullPath.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
import isAbsoluteURL from '../helpers/isAbsoluteURL.js';
|
||||
import combineURLs from '../helpers/combineURLs.js';
|
||||
|
||||
/**
|
||||
* Creates a new URL by combining the baseURL with the requestedURL,
|
||||
* only when the requestedURL is not already an absolute URL.
|
||||
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
||||
*
|
||||
* @param {string} baseURL The base URL
|
||||
* @param {string} requestedURL Absolute or relative URL to combine
|
||||
*
|
||||
* @returns {string} The combined full path
|
||||
*/
|
||||
export default function buildFullPath(baseURL, requestedURL) {
|
||||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||||
return combineURLs(baseURL, requestedURL);
|
||||
}
|
||||
return requestedURL;
|
||||
}
|
81
parent_dir/20240530212112Z/node_modules/axios/lib/core/dispatchRequest.js
generated
vendored
Normal file
81
parent_dir/20240530212112Z/node_modules/axios/lib/core/dispatchRequest.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
|
||||
import transformData from './transformData.js';
|
||||
import isCancel from '../cancel/isCancel.js';
|
||||
import defaults from '../defaults/index.js';
|
||||
import CanceledError from '../cancel/CanceledError.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
import adapters from "../adapters/adapters.js";
|
||||
|
||||
/**
|
||||
* Throws a `CanceledError` if cancellation has been requested.
|
||||
*
|
||||
* @param {Object} config The config that is to be used for the request
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function throwIfCancellationRequested(config) {
|
||||
if (config.cancelToken) {
|
||||
config.cancelToken.throwIfRequested();
|
||||
}
|
||||
|
||||
if (config.signal && config.signal.aborted) {
|
||||
throw new CanceledError(null, config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch a request to the server using the configured adapter.
|
||||
*
|
||||
* @param {object} config The config that is to be used for the request
|
||||
*
|
||||
* @returns {Promise} The Promise to be fulfilled
|
||||
*/
|
||||
export default function dispatchRequest(config) {
|
||||
throwIfCancellationRequested(config);
|
||||
|
||||
config.headers = AxiosHeaders.from(config.headers);
|
||||
|
||||
// Transform request data
|
||||
config.data = transformData.call(
|
||||
config,
|
||||
config.transformRequest
|
||||
);
|
||||
|
||||
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
||||
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
||||
}
|
||||
|
||||
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
||||
|
||||
return adapter(config).then(function onAdapterResolution(response) {
|
||||
throwIfCancellationRequested(config);
|
||||
|
||||
// Transform response data
|
||||
response.data = transformData.call(
|
||||
config,
|
||||
config.transformResponse,
|
||||
response
|
||||
);
|
||||
|
||||
response.headers = AxiosHeaders.from(response.headers);
|
||||
|
||||
return response;
|
||||
}, function onAdapterRejection(reason) {
|
||||
if (!isCancel(reason)) {
|
||||
throwIfCancellationRequested(config);
|
||||
|
||||
// Transform response data
|
||||
if (reason && reason.response) {
|
||||
reason.response.data = transformData.call(
|
||||
config,
|
||||
config.transformResponse,
|
||||
reason.response
|
||||
);
|
||||
reason.response.headers = AxiosHeaders.from(reason.response.headers);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(reason);
|
||||
});
|
||||
}
|
105
parent_dir/20240530212112Z/node_modules/axios/lib/core/mergeConfig.js
generated
vendored
Normal file
105
parent_dir/20240530212112Z/node_modules/axios/lib/core/mergeConfig.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
import AxiosHeaders from "./AxiosHeaders.js";
|
||||
|
||||
const headersToObject = (thing) => thing instanceof AxiosHeaders ? thing.toJSON() : thing;
|
||||
|
||||
/**
|
||||
* Config-specific merge-function which creates a new config-object
|
||||
* by merging two configuration objects together.
|
||||
*
|
||||
* @param {Object} config1
|
||||
* @param {Object} config2
|
||||
*
|
||||
* @returns {Object} New object resulting from merging config2 to config1
|
||||
*/
|
||||
export default function mergeConfig(config1, config2) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
config2 = config2 || {};
|
||||
const config = {};
|
||||
|
||||
function getMergedValue(target, source, caseless) {
|
||||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
||||
return utils.merge.call({caseless}, target, source);
|
||||
} else if (utils.isPlainObject(source)) {
|
||||
return utils.merge({}, source);
|
||||
} else if (utils.isArray(source)) {
|
||||
return source.slice();
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
function mergeDeepProperties(a, b, caseless) {
|
||||
if (!utils.isUndefined(b)) {
|
||||
return getMergedValue(a, b, caseless);
|
||||
} else if (!utils.isUndefined(a)) {
|
||||
return getMergedValue(undefined, a, caseless);
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
function valueFromConfig2(a, b) {
|
||||
if (!utils.isUndefined(b)) {
|
||||
return getMergedValue(undefined, b);
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
function defaultToConfig2(a, b) {
|
||||
if (!utils.isUndefined(b)) {
|
||||
return getMergedValue(undefined, b);
|
||||
} else if (!utils.isUndefined(a)) {
|
||||
return getMergedValue(undefined, a);
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
function mergeDirectKeys(a, b, prop) {
|
||||
if (prop in config2) {
|
||||
return getMergedValue(a, b);
|
||||
} else if (prop in config1) {
|
||||
return getMergedValue(undefined, a);
|
||||
}
|
||||
}
|
||||
|
||||
const mergeMap = {
|
||||
url: valueFromConfig2,
|
||||
method: valueFromConfig2,
|
||||
data: valueFromConfig2,
|
||||
baseURL: defaultToConfig2,
|
||||
transformRequest: defaultToConfig2,
|
||||
transformResponse: defaultToConfig2,
|
||||
paramsSerializer: defaultToConfig2,
|
||||
timeout: defaultToConfig2,
|
||||
timeoutMessage: defaultToConfig2,
|
||||
withCredentials: defaultToConfig2,
|
||||
adapter: defaultToConfig2,
|
||||
responseType: defaultToConfig2,
|
||||
xsrfCookieName: defaultToConfig2,
|
||||
xsrfHeaderName: defaultToConfig2,
|
||||
onUploadProgress: defaultToConfig2,
|
||||
onDownloadProgress: defaultToConfig2,
|
||||
decompress: defaultToConfig2,
|
||||
maxContentLength: defaultToConfig2,
|
||||
maxBodyLength: defaultToConfig2,
|
||||
beforeRedirect: defaultToConfig2,
|
||||
transport: defaultToConfig2,
|
||||
httpAgent: defaultToConfig2,
|
||||
httpsAgent: defaultToConfig2,
|
||||
cancelToken: defaultToConfig2,
|
||||
socketPath: defaultToConfig2,
|
||||
responseEncoding: defaultToConfig2,
|
||||
validateStatus: mergeDirectKeys,
|
||||
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
||||
};
|
||||
|
||||
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
||||
const merge = mergeMap[prop] || mergeDeepProperties;
|
||||
const configValue = merge(config1[prop], config2[prop], prop);
|
||||
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
27
parent_dir/20240530212112Z/node_modules/axios/lib/core/settle.js
generated
vendored
Normal file
27
parent_dir/20240530212112Z/node_modules/axios/lib/core/settle.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
import AxiosError from './AxiosError.js';
|
||||
|
||||
/**
|
||||
* Resolve or reject a Promise based on response status.
|
||||
*
|
||||
* @param {Function} resolve A function that resolves the promise.
|
||||
* @param {Function} reject A function that rejects the promise.
|
||||
* @param {object} response The response.
|
||||
*
|
||||
* @returns {object} The response.
|
||||
*/
|
||||
export default function settle(resolve, reject, response) {
|
||||
const validateStatus = response.config.validateStatus;
|
||||
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||||
resolve(response);
|
||||
} else {
|
||||
reject(new AxiosError(
|
||||
'Request failed with status code ' + response.status,
|
||||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
||||
response.config,
|
||||
response.request,
|
||||
response
|
||||
));
|
||||
}
|
||||
}
|
28
parent_dir/20240530212112Z/node_modules/axios/lib/core/transformData.js
generated
vendored
Normal file
28
parent_dir/20240530212112Z/node_modules/axios/lib/core/transformData.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
import defaults from '../defaults/index.js';
|
||||
import AxiosHeaders from '../core/AxiosHeaders.js';
|
||||
|
||||
/**
|
||||
* Transform the data for a request or a response
|
||||
*
|
||||
* @param {Array|Function} fns A single function or Array of functions
|
||||
* @param {?Object} response The response object
|
||||
*
|
||||
* @returns {*} The resulting transformed data
|
||||
*/
|
||||
export default function transformData(fns, response) {
|
||||
const config = this || defaults;
|
||||
const context = response || config;
|
||||
const headers = AxiosHeaders.from(context.headers);
|
||||
let data = context.data;
|
||||
|
||||
utils.forEach(fns, function transform(fn) {
|
||||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
||||
});
|
||||
|
||||
headers.normalize();
|
||||
|
||||
return data;
|
||||
}
|
166
parent_dir/20240530212112Z/node_modules/axios/lib/defaults/index.js
generated
vendored
Normal file
166
parent_dir/20240530212112Z/node_modules/axios/lib/defaults/index.js
generated
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
import transitionalDefaults from './transitional.js';
|
||||
import toFormData from '../helpers/toFormData.js';
|
||||
import toURLEncodedForm from '../helpers/toURLEncodedForm.js';
|
||||
import platform from '../platform/index.js';
|
||||
import formDataToJSON from '../helpers/formDataToJSON.js';
|
||||
|
||||
const DEFAULT_CONTENT_TYPE = {
|
||||
'Content-Type': undefined
|
||||
};
|
||||
|
||||
/**
|
||||
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
||||
* of the input
|
||||
*
|
||||
* @param {any} rawValue - The value to be stringified.
|
||||
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
||||
* @param {Function} encoder - A function that takes a value and returns a string.
|
||||
*
|
||||
* @returns {string} A stringified version of the rawValue.
|
||||
*/
|
||||
function stringifySafely(rawValue, parser, encoder) {
|
||||
if (utils.isString(rawValue)) {
|
||||
try {
|
||||
(parser || JSON.parse)(rawValue);
|
||||
return utils.trim(rawValue);
|
||||
} catch (e) {
|
||||
if (e.name !== 'SyntaxError') {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (encoder || JSON.stringify)(rawValue);
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
|
||||
transitional: transitionalDefaults,
|
||||
|
||||
adapter: ['xhr', 'http'],
|
||||
|
||||
transformRequest: [function transformRequest(data, headers) {
|
||||
const contentType = headers.getContentType() || '';
|
||||
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||
const isObjectPayload = utils.isObject(data);
|
||||
|
||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||
data = new FormData(data);
|
||||
}
|
||||
|
||||
const isFormData = utils.isFormData(data);
|
||||
|
||||
if (isFormData) {
|
||||
if (!hasJSONContentType) {
|
||||
return data;
|
||||
}
|
||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(data) ||
|
||||
utils.isBuffer(data) ||
|
||||
utils.isStream(data) ||
|
||||
utils.isFile(data) ||
|
||||
utils.isBlob(data)
|
||||
) {
|
||||
return data;
|
||||
}
|
||||
if (utils.isArrayBufferView(data)) {
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isURLSearchParams(data)) {
|
||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
let isFileList;
|
||||
|
||||
if (isObjectPayload) {
|
||||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||
}
|
||||
|
||||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||
const _FormData = this.env && this.env.FormData;
|
||||
|
||||
return toFormData(
|
||||
isFileList ? {'files[]': data} : data,
|
||||
_FormData && new _FormData(),
|
||||
this.formSerializer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isObjectPayload || hasJSONContentType ) {
|
||||
headers.setContentType('application/json', false);
|
||||
return stringifySafely(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}],
|
||||
|
||||
transformResponse: [function transformResponse(data) {
|
||||
const transitional = this.transitional || defaults.transitional;
|
||||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||
const JSONRequested = this.responseType === 'json';
|
||||
|
||||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
||||
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||
|
||||
try {
|
||||
return JSON.parse(data);
|
||||
} catch (e) {
|
||||
if (strictJSONParsing) {
|
||||
if (e.name === 'SyntaxError') {
|
||||
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}],
|
||||
|
||||
/**
|
||||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||
* timeout is not created.
|
||||
*/
|
||||
timeout: 0,
|
||||
|
||||
xsrfCookieName: 'XSRF-TOKEN',
|
||||
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||||
|
||||
maxContentLength: -1,
|
||||
maxBodyLength: -1,
|
||||
|
||||
env: {
|
||||
FormData: platform.classes.FormData,
|
||||
Blob: platform.classes.Blob
|
||||
},
|
||||
|
||||
validateStatus: function validateStatus(status) {
|
||||
return status >= 200 && status < 300;
|
||||
},
|
||||
|
||||
headers: {
|
||||
common: {
|
||||
'Accept': 'application/json, text/plain, */*'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
||||
defaults.headers[method] = {};
|
||||
});
|
||||
|
||||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
||||
});
|
||||
|
||||
export default defaults;
|
7
parent_dir/20240530212112Z/node_modules/axios/lib/defaults/transitional.js
generated
vendored
Normal file
7
parent_dir/20240530212112Z/node_modules/axios/lib/defaults/transitional.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
export default {
|
||||
silentJSONParsing: true,
|
||||
forcedJSONParsing: true,
|
||||
clarifyTimeoutError: false
|
||||
};
|
1
parent_dir/20240530212112Z/node_modules/axios/lib/env/data.js
generated
vendored
Normal file
1
parent_dir/20240530212112Z/node_modules/axios/lib/env/data.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const VERSION = "1.3.5";
|
58
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/AxiosURLSearchParams.js
generated
vendored
Normal file
58
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/AxiosURLSearchParams.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
import toFormData from './toFormData.js';
|
||||
|
||||
/**
|
||||
* It encodes a string by replacing all characters that are not in the unreserved set with
|
||||
* their percent-encoded equivalents
|
||||
*
|
||||
* @param {string} str - The string to encode.
|
||||
*
|
||||
* @returns {string} The encoded string.
|
||||
*/
|
||||
function encode(str) {
|
||||
const charMap = {
|
||||
'!': '%21',
|
||||
"'": '%27',
|
||||
'(': '%28',
|
||||
')': '%29',
|
||||
'~': '%7E',
|
||||
'%20': '+',
|
||||
'%00': '\x00'
|
||||
};
|
||||
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
||||
return charMap[match];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* It takes a params object and converts it to a FormData object
|
||||
*
|
||||
* @param {Object<string, any>} params - The parameters to be converted to a FormData object.
|
||||
* @param {Object<string, any>} options - The options object passed to the Axios constructor.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function AxiosURLSearchParams(params, options) {
|
||||
this._pairs = [];
|
||||
|
||||
params && toFormData(params, this, options);
|
||||
}
|
||||
|
||||
const prototype = AxiosURLSearchParams.prototype;
|
||||
|
||||
prototype.append = function append(name, value) {
|
||||
this._pairs.push([name, value]);
|
||||
};
|
||||
|
||||
prototype.toString = function toString(encoder) {
|
||||
const _encode = encoder ? function(value) {
|
||||
return encoder.call(this, value, encode);
|
||||
} : encode;
|
||||
|
||||
return this._pairs.map(function each(pair) {
|
||||
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
||||
}, '').join('&');
|
||||
};
|
||||
|
||||
export default AxiosURLSearchParams;
|
71
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/HttpStatusCode.js
generated
vendored
Normal file
71
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/HttpStatusCode.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
const HttpStatusCode = {
|
||||
Continue: 100,
|
||||
SwitchingProtocols: 101,
|
||||
Processing: 102,
|
||||
EarlyHints: 103,
|
||||
Ok: 200,
|
||||
Created: 201,
|
||||
Accepted: 202,
|
||||
NonAuthoritativeInformation: 203,
|
||||
NoContent: 204,
|
||||
ResetContent: 205,
|
||||
PartialContent: 206,
|
||||
MultiStatus: 207,
|
||||
AlreadyReported: 208,
|
||||
ImUsed: 226,
|
||||
MultipleChoices: 300,
|
||||
MovedPermanently: 301,
|
||||
Found: 302,
|
||||
SeeOther: 303,
|
||||
NotModified: 304,
|
||||
UseProxy: 305,
|
||||
Unused: 306,
|
||||
TemporaryRedirect: 307,
|
||||
PermanentRedirect: 308,
|
||||
BadRequest: 400,
|
||||
Unauthorized: 401,
|
||||
PaymentRequired: 402,
|
||||
Forbidden: 403,
|
||||
NotFound: 404,
|
||||
MethodNotAllowed: 405,
|
||||
NotAcceptable: 406,
|
||||
ProxyAuthenticationRequired: 407,
|
||||
RequestTimeout: 408,
|
||||
Conflict: 409,
|
||||
Gone: 410,
|
||||
LengthRequired: 411,
|
||||
PreconditionFailed: 412,
|
||||
PayloadTooLarge: 413,
|
||||
UriTooLong: 414,
|
||||
UnsupportedMediaType: 415,
|
||||
RangeNotSatisfiable: 416,
|
||||
ExpectationFailed: 417,
|
||||
ImATeapot: 418,
|
||||
MisdirectedRequest: 421,
|
||||
UnprocessableEntity: 422,
|
||||
Locked: 423,
|
||||
FailedDependency: 424,
|
||||
TooEarly: 425,
|
||||
UpgradeRequired: 426,
|
||||
PreconditionRequired: 428,
|
||||
TooManyRequests: 429,
|
||||
RequestHeaderFieldsTooLarge: 431,
|
||||
UnavailableForLegalReasons: 451,
|
||||
InternalServerError: 500,
|
||||
NotImplemented: 501,
|
||||
BadGateway: 502,
|
||||
ServiceUnavailable: 503,
|
||||
GatewayTimeout: 504,
|
||||
HttpVersionNotSupported: 505,
|
||||
VariantAlsoNegotiates: 506,
|
||||
InsufficientStorage: 507,
|
||||
LoopDetected: 508,
|
||||
NotExtended: 510,
|
||||
NetworkAuthenticationRequired: 511,
|
||||
};
|
||||
|
||||
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
||||
HttpStatusCode[value] = key;
|
||||
});
|
||||
|
||||
export default HttpStatusCode;
|
7
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/bind.js
generated
vendored
Normal file
7
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/bind.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
export default function bind(fn, thisArg) {
|
||||
return function wrap() {
|
||||
return fn.apply(thisArg, arguments);
|
||||
};
|
||||
}
|
63
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/buildURL.js
generated
vendored
Normal file
63
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/buildURL.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
import AxiosURLSearchParams from '../helpers/AxiosURLSearchParams.js';
|
||||
|
||||
/**
|
||||
* It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
|
||||
* URI encoded counterparts
|
||||
*
|
||||
* @param {string} val The value to be encoded.
|
||||
*
|
||||
* @returns {string} The encoded value.
|
||||
*/
|
||||
function encode(val) {
|
||||
return encodeURIComponent(val).
|
||||
replace(/%3A/gi, ':').
|
||||
replace(/%24/g, '$').
|
||||
replace(/%2C/gi, ',').
|
||||
replace(/%20/g, '+').
|
||||
replace(/%5B/gi, '[').
|
||||
replace(/%5D/gi, ']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a URL by appending params to the end
|
||||
*
|
||||
* @param {string} url The base of the url (e.g., http://www.google.com)
|
||||
* @param {object} [params] The params to be appended
|
||||
* @param {?object} options
|
||||
*
|
||||
* @returns {string} The formatted url
|
||||
*/
|
||||
export default function buildURL(url, params, options) {
|
||||
/*eslint no-param-reassign:0*/
|
||||
if (!params) {
|
||||
return url;
|
||||
}
|
||||
|
||||
const _encode = options && options.encode || encode;
|
||||
|
||||
const serializeFn = options && options.serialize;
|
||||
|
||||
let serializedParams;
|
||||
|
||||
if (serializeFn) {
|
||||
serializedParams = serializeFn(params, options);
|
||||
} else {
|
||||
serializedParams = utils.isURLSearchParams(params) ?
|
||||
params.toString() :
|
||||
new AxiosURLSearchParams(params, options).toString(_encode);
|
||||
}
|
||||
|
||||
if (serializedParams) {
|
||||
const hashmarkIndex = url.indexOf("#");
|
||||
|
||||
if (hashmarkIndex !== -1) {
|
||||
url = url.slice(0, hashmarkIndex);
|
||||
}
|
||||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
15
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/combineURLs.js
generated
vendored
Normal file
15
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/combineURLs.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Creates a new URL by combining the specified URLs
|
||||
*
|
||||
* @param {string} baseURL The base URL
|
||||
* @param {string} relativeURL The relative URL
|
||||
*
|
||||
* @returns {string} The combined URL
|
||||
*/
|
||||
export default function combineURLs(baseURL, relativeURL) {
|
||||
return relativeURL
|
||||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
||||
: baseURL;
|
||||
}
|
52
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/cookies.js
generated
vendored
Normal file
52
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/cookies.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
import platform from '../platform/index.js';
|
||||
|
||||
export default platform.isStandardBrowserEnv ?
|
||||
|
||||
// Standard browser envs support document.cookie
|
||||
(function standardBrowserEnv() {
|
||||
return {
|
||||
write: function write(name, value, expires, path, domain, secure) {
|
||||
const cookie = [];
|
||||
cookie.push(name + '=' + encodeURIComponent(value));
|
||||
|
||||
if (utils.isNumber(expires)) {
|
||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||
}
|
||||
|
||||
if (utils.isString(path)) {
|
||||
cookie.push('path=' + path);
|
||||
}
|
||||
|
||||
if (utils.isString(domain)) {
|
||||
cookie.push('domain=' + domain);
|
||||
}
|
||||
|
||||
if (secure === true) {
|
||||
cookie.push('secure');
|
||||
}
|
||||
|
||||
document.cookie = cookie.join('; ');
|
||||
},
|
||||
|
||||
read: function read(name) {
|
||||
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||||
return (match ? decodeURIComponent(match[3]) : null);
|
||||
},
|
||||
|
||||
remove: function remove(name) {
|
||||
this.write(name, '', Date.now() - 86400000);
|
||||
}
|
||||
};
|
||||
})() :
|
||||
|
||||
// Non standard browser env (web workers, react-native) lack needed support.
|
||||
(function nonStandardBrowserEnv() {
|
||||
return {
|
||||
write: function write() {},
|
||||
read: function read() { return null; },
|
||||
remove: function remove() {}
|
||||
};
|
||||
})();
|
92
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/formDataToJSON.js
generated
vendored
Normal file
92
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/formDataToJSON.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
|
||||
/**
|
||||
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
||||
*
|
||||
* @param {string} name - The name of the property to get.
|
||||
*
|
||||
* @returns An array of strings.
|
||||
*/
|
||||
function parsePropPath(name) {
|
||||
// foo[x][y][z]
|
||||
// foo.x.y.z
|
||||
// foo-x-y-z
|
||||
// foo x y z
|
||||
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
||||
return match[0] === '[]' ? '' : match[1] || match[0];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an array to an object.
|
||||
*
|
||||
* @param {Array<any>} arr - The array to convert to an object.
|
||||
*
|
||||
* @returns An object with the same keys and values as the array.
|
||||
*/
|
||||
function arrayToObject(arr) {
|
||||
const obj = {};
|
||||
const keys = Object.keys(arr);
|
||||
let i;
|
||||
const len = keys.length;
|
||||
let key;
|
||||
for (i = 0; i < len; i++) {
|
||||
key = keys[i];
|
||||
obj[key] = arr[key];
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* It takes a FormData object and returns a JavaScript object
|
||||
*
|
||||
* @param {string} formData The FormData object to convert to JSON.
|
||||
*
|
||||
* @returns {Object<string, any> | null} The converted object.
|
||||
*/
|
||||
function formDataToJSON(formData) {
|
||||
function buildPath(path, value, target, index) {
|
||||
let name = path[index++];
|
||||
const isNumericKey = Number.isFinite(+name);
|
||||
const isLast = index >= path.length;
|
||||
name = !name && utils.isArray(target) ? target.length : name;
|
||||
|
||||
if (isLast) {
|
||||
if (utils.hasOwnProp(target, name)) {
|
||||
target[name] = [target[name], value];
|
||||
} else {
|
||||
target[name] = value;
|
||||
}
|
||||
|
||||
return !isNumericKey;
|
||||
}
|
||||
|
||||
if (!target[name] || !utils.isObject(target[name])) {
|
||||
target[name] = [];
|
||||
}
|
||||
|
||||
const result = buildPath(path, value, target[name], index);
|
||||
|
||||
if (result && utils.isArray(target[name])) {
|
||||
target[name] = arrayToObject(target[name]);
|
||||
}
|
||||
|
||||
return !isNumericKey;
|
||||
}
|
||||
|
||||
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
||||
const obj = {};
|
||||
|
||||
utils.forEachEntry(formData, (name, value) => {
|
||||
buildPath(parsePropPath(name), value, obj, 0);
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default formDataToJSON;
|
15
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/isAbsoluteURL.js
generated
vendored
Normal file
15
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/isAbsoluteURL.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Determines whether the specified URL is absolute
|
||||
*
|
||||
* @param {string} url The URL to test
|
||||
*
|
||||
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
||||
*/
|
||||
export default function isAbsoluteURL(url) {
|
||||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
||||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
||||
// by any combination of letters, digits, plus, period, or hyphen.
|
||||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||
}
|
14
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/isAxiosError.js
generated
vendored
Normal file
14
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/isAxiosError.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
|
||||
/**
|
||||
* Determines whether the payload is an error thrown by Axios
|
||||
*
|
||||
* @param {*} payload The value to test
|
||||
*
|
||||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
||||
*/
|
||||
export default function isAxiosError(payload) {
|
||||
return utils.isObject(payload) && (payload.isAxiosError === true);
|
||||
}
|
67
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/isURLSameOrigin.js
generated
vendored
Normal file
67
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/isURLSameOrigin.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
import platform from '../platform/index.js';
|
||||
|
||||
export default platform.isStandardBrowserEnv ?
|
||||
|
||||
// Standard browser envs have full support of the APIs needed to test
|
||||
// whether the request URL is of the same origin as current location.
|
||||
(function standardBrowserEnv() {
|
||||
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
||||
const urlParsingNode = document.createElement('a');
|
||||
let originURL;
|
||||
|
||||
/**
|
||||
* Parse a URL to discover it's components
|
||||
*
|
||||
* @param {String} url The URL to be parsed
|
||||
* @returns {Object}
|
||||
*/
|
||||
function resolveURL(url) {
|
||||
let href = url;
|
||||
|
||||
if (msie) {
|
||||
// IE needs attribute set twice to normalize properties
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
href = urlParsingNode.href;
|
||||
}
|
||||
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
|
||||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||
return {
|
||||
href: urlParsingNode.href,
|
||||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||||
host: urlParsingNode.host,
|
||||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||||
hostname: urlParsingNode.hostname,
|
||||
port: urlParsingNode.port,
|
||||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
||||
urlParsingNode.pathname :
|
||||
'/' + urlParsingNode.pathname
|
||||
};
|
||||
}
|
||||
|
||||
originURL = resolveURL(window.location.href);
|
||||
|
||||
/**
|
||||
* Determine if a URL shares the same origin as the current location
|
||||
*
|
||||
* @param {String} requestURL The URL to test
|
||||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||||
*/
|
||||
return function isURLSameOrigin(requestURL) {
|
||||
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
||||
return (parsed.protocol === originURL.protocol &&
|
||||
parsed.host === originURL.host);
|
||||
};
|
||||
})() :
|
||||
|
||||
// Non standard browser envs (web workers, react-native) lack needed support.
|
||||
(function nonStandardBrowserEnv() {
|
||||
return function isURLSameOrigin() {
|
||||
return true;
|
||||
};
|
||||
})();
|
2
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/null.js
generated
vendored
Normal file
2
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/null.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// eslint-disable-next-line strict
|
||||
export default null;
|
55
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/parseHeaders.js
generated
vendored
Normal file
55
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/parseHeaders.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
import utils from './../utils.js';
|
||||
|
||||
// RawAxiosHeaders whose duplicates are ignored by node
|
||||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||
const ignoreDuplicateOf = utils.toObjectSet([
|
||||
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
||||
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
||||
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
||||
'referer', 'retry-after', 'user-agent'
|
||||
]);
|
||||
|
||||
/**
|
||||
* Parse headers into an object
|
||||
*
|
||||
* ```
|
||||
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
||||
* Content-Type: application/json
|
||||
* Connection: keep-alive
|
||||
* Transfer-Encoding: chunked
|
||||
* ```
|
||||
*
|
||||
* @param {String} rawHeaders Headers needing to be parsed
|
||||
*
|
||||
* @returns {Object} Headers parsed into an object
|
||||
*/
|
||||
export default rawHeaders => {
|
||||
const parsed = {};
|
||||
let key;
|
||||
let val;
|
||||
let i;
|
||||
|
||||
rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
|
||||
i = line.indexOf(':');
|
||||
key = line.substring(0, i).trim().toLowerCase();
|
||||
val = line.substring(i + 1).trim();
|
||||
|
||||
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (key === 'set-cookie') {
|
||||
if (parsed[key]) {
|
||||
parsed[key].push(val);
|
||||
} else {
|
||||
parsed[key] = [val];
|
||||
}
|
||||
} else {
|
||||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||||
}
|
||||
});
|
||||
|
||||
return parsed;
|
||||
};
|
6
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/parseProtocol.js
generated
vendored
Normal file
6
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/parseProtocol.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
export default function parseProtocol(url) {
|
||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||
return match && match[1] || '';
|
||||
}
|
55
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/speedometer.js
generated
vendored
Normal file
55
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/speedometer.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Calculate data maxRate
|
||||
* @param {Number} [samplesCount= 10]
|
||||
* @param {Number} [min= 1000]
|
||||
* @returns {Function}
|
||||
*/
|
||||
function speedometer(samplesCount, min) {
|
||||
samplesCount = samplesCount || 10;
|
||||
const bytes = new Array(samplesCount);
|
||||
const timestamps = new Array(samplesCount);
|
||||
let head = 0;
|
||||
let tail = 0;
|
||||
let firstSampleTS;
|
||||
|
||||
min = min !== undefined ? min : 1000;
|
||||
|
||||
return function push(chunkLength) {
|
||||
const now = Date.now();
|
||||
|
||||
const startedAt = timestamps[tail];
|
||||
|
||||
if (!firstSampleTS) {
|
||||
firstSampleTS = now;
|
||||
}
|
||||
|
||||
bytes[head] = chunkLength;
|
||||
timestamps[head] = now;
|
||||
|
||||
let i = tail;
|
||||
let bytesCount = 0;
|
||||
|
||||
while (i !== head) {
|
||||
bytesCount += bytes[i++];
|
||||
i = i % samplesCount;
|
||||
}
|
||||
|
||||
head = (head + 1) % samplesCount;
|
||||
|
||||
if (head === tail) {
|
||||
tail = (tail + 1) % samplesCount;
|
||||
}
|
||||
|
||||
if (now - firstSampleTS < min) {
|
||||
return;
|
||||
}
|
||||
|
||||
const passed = startedAt && now - startedAt;
|
||||
|
||||
return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export default speedometer;
|
28
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/spread.js
generated
vendored
Normal file
28
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/spread.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
||||
*
|
||||
* Common use case would be to use `Function.prototype.apply`.
|
||||
*
|
||||
* ```js
|
||||
* function f(x, y, z) {}
|
||||
* var args = [1, 2, 3];
|
||||
* f.apply(null, args);
|
||||
* ```
|
||||
*
|
||||
* With `spread` this example can be re-written.
|
||||
*
|
||||
* ```js
|
||||
* spread(function(x, y, z) {})([1, 2, 3]);
|
||||
* ```
|
||||
*
|
||||
* @param {Function} callback
|
||||
*
|
||||
* @returns {Function}
|
||||
*/
|
||||
export default function spread(callback) {
|
||||
return function wrap(arr) {
|
||||
return callback.apply(null, arr);
|
||||
};
|
||||
}
|
219
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/toFormData.js
generated
vendored
Normal file
219
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/toFormData.js
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
// temporary hotfix to avoid circular references until AxiosURLSearchParams is refactored
|
||||
import PlatformFormData from '../platform/node/classes/FormData.js';
|
||||
|
||||
/**
|
||||
* Determines if the given thing is a array or js object.
|
||||
*
|
||||
* @param {string} thing - The object or array to be visited.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isVisitable(thing) {
|
||||
return utils.isPlainObject(thing) || utils.isArray(thing);
|
||||
}
|
||||
|
||||
/**
|
||||
* It removes the brackets from the end of a string
|
||||
*
|
||||
* @param {string} key - The key of the parameter.
|
||||
*
|
||||
* @returns {string} the key without the brackets.
|
||||
*/
|
||||
function removeBrackets(key) {
|
||||
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
||||
}
|
||||
|
||||
/**
|
||||
* It takes a path, a key, and a boolean, and returns a string
|
||||
*
|
||||
* @param {string} path - The path to the current key.
|
||||
* @param {string} key - The key of the current object being iterated over.
|
||||
* @param {string} dots - If true, the key will be rendered with dots instead of brackets.
|
||||
*
|
||||
* @returns {string} The path to the current key.
|
||||
*/
|
||||
function renderKey(path, key, dots) {
|
||||
if (!path) return key;
|
||||
return path.concat(key).map(function each(token, i) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
token = removeBrackets(token);
|
||||
return !dots && i ? '[' + token + ']' : token;
|
||||
}).join(dots ? '.' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* If the array is an array and none of its elements are visitable, then it's a flat array.
|
||||
*
|
||||
* @param {Array<any>} arr - The array to check
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isFlatArray(arr) {
|
||||
return utils.isArray(arr) && !arr.some(isVisitable);
|
||||
}
|
||||
|
||||
const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
||||
return /^is[A-Z]/.test(prop);
|
||||
});
|
||||
|
||||
/**
|
||||
* Convert a data object to FormData
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {?Object} [formData]
|
||||
* @param {?Object} [options]
|
||||
* @param {Function} [options.visitor]
|
||||
* @param {Boolean} [options.metaTokens = true]
|
||||
* @param {Boolean} [options.dots = false]
|
||||
* @param {?Boolean} [options.indexes = false]
|
||||
*
|
||||
* @returns {Object}
|
||||
**/
|
||||
|
||||
/**
|
||||
* It converts an object into a FormData object
|
||||
*
|
||||
* @param {Object<any, any>} obj - The object to convert to form data.
|
||||
* @param {string} formData - The FormData object to append to.
|
||||
* @param {Object<string, any>} options
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
function toFormData(obj, formData, options) {
|
||||
if (!utils.isObject(obj)) {
|
||||
throw new TypeError('target must be an object');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
formData = formData || new (PlatformFormData || FormData)();
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = utils.toFlatObject(options, {
|
||||
metaTokens: true,
|
||||
dots: false,
|
||||
indexes: false
|
||||
}, false, function defined(option, source) {
|
||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||
return !utils.isUndefined(source[option]);
|
||||
});
|
||||
|
||||
const metaTokens = options.metaTokens;
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
const visitor = options.visitor || defaultVisitor;
|
||||
const dots = options.dots;
|
||||
const indexes = options.indexes;
|
||||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
||||
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
||||
|
||||
if (!utils.isFunction(visitor)) {
|
||||
throw new TypeError('visitor must be a function');
|
||||
}
|
||||
|
||||
function convertValue(value) {
|
||||
if (value === null) return '';
|
||||
|
||||
if (utils.isDate(value)) {
|
||||
return value.toISOString();
|
||||
}
|
||||
|
||||
if (!useBlob && utils.isBlob(value)) {
|
||||
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
||||
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default visitor.
|
||||
*
|
||||
* @param {*} value
|
||||
* @param {String|Number} key
|
||||
* @param {Array<String|Number>} path
|
||||
* @this {FormData}
|
||||
*
|
||||
* @returns {boolean} return true to visit the each prop of the value recursively
|
||||
*/
|
||||
function defaultVisitor(value, key, path) {
|
||||
let arr = value;
|
||||
|
||||
if (value && !path && typeof value === 'object') {
|
||||
if (utils.endsWith(key, '{}')) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
key = metaTokens ? key : key.slice(0, -2);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
value = JSON.stringify(value);
|
||||
} else if (
|
||||
(utils.isArray(value) && isFlatArray(value)) ||
|
||||
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
||||
)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
key = removeBrackets(key);
|
||||
|
||||
arr.forEach(function each(el, index) {
|
||||
!(utils.isUndefined(el) || el === null) && formData.append(
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
||||
convertValue(el)
|
||||
);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isVisitable(value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
formData.append(renderKey(path, key, dots), convertValue(value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const stack = [];
|
||||
|
||||
const exposedHelpers = Object.assign(predicates, {
|
||||
defaultVisitor,
|
||||
convertValue,
|
||||
isVisitable
|
||||
});
|
||||
|
||||
function build(value, path) {
|
||||
if (utils.isUndefined(value)) return;
|
||||
|
||||
if (stack.indexOf(value) !== -1) {
|
||||
throw Error('Circular reference detected in ' + path.join('.'));
|
||||
}
|
||||
|
||||
stack.push(value);
|
||||
|
||||
utils.forEach(value, function each(el, key) {
|
||||
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
||||
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
||||
);
|
||||
|
||||
if (result === true) {
|
||||
build(el, path ? path.concat(key) : [key]);
|
||||
}
|
||||
});
|
||||
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
if (!utils.isObject(obj)) {
|
||||
throw new TypeError('data must be an object');
|
||||
}
|
||||
|
||||
build(obj);
|
||||
|
||||
return formData;
|
||||
}
|
||||
|
||||
export default toFormData;
|
18
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/toURLEncodedForm.js
generated
vendored
Normal file
18
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/toURLEncodedForm.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
import utils from '../utils.js';
|
||||
import toFormData from './toFormData.js';
|
||||
import platform from '../platform/index.js';
|
||||
|
||||
export default function toURLEncodedForm(data, options) {
|
||||
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
||||
visitor: function(value, key, path, helpers) {
|
||||
if (platform.isNode && utils.isBuffer(value)) {
|
||||
this.append(key, value.toString('base64'));
|
||||
return false;
|
||||
}
|
||||
|
||||
return helpers.defaultVisitor.apply(this, arguments);
|
||||
}
|
||||
}, options));
|
||||
}
|
91
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/validator.js
generated
vendored
Normal file
91
parent_dir/20240530212112Z/node_modules/axios/lib/helpers/validator.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
import {VERSION} from '../env/data.js';
|
||||
import AxiosError from '../core/AxiosError.js';
|
||||
|
||||
const validators = {};
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
|
||||
validators[type] = function validator(thing) {
|
||||
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
||||
};
|
||||
});
|
||||
|
||||
const deprecatedWarnings = {};
|
||||
|
||||
/**
|
||||
* Transitional option validator
|
||||
*
|
||||
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
||||
* @param {string?} version - deprecated version / removed since version
|
||||
* @param {string?} message - some message with additional info
|
||||
*
|
||||
* @returns {function}
|
||||
*/
|
||||
validators.transitional = function transitional(validator, version, message) {
|
||||
function formatMessage(opt, desc) {
|
||||
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
return (value, opt, opts) => {
|
||||
if (validator === false) {
|
||||
throw new AxiosError(
|
||||
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
||||
AxiosError.ERR_DEPRECATED
|
||||
);
|
||||
}
|
||||
|
||||
if (version && !deprecatedWarnings[opt]) {
|
||||
deprecatedWarnings[opt] = true;
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
formatMessage(
|
||||
opt,
|
||||
' has been deprecated since v' + version + ' and will be removed in the near future'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return validator ? validator(value, opt, opts) : true;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Assert object's properties type
|
||||
*
|
||||
* @param {object} options
|
||||
* @param {object} schema
|
||||
* @param {boolean?} allowUnknown
|
||||
*
|
||||
* @returns {object}
|
||||
*/
|
||||
|
||||
function assertOptions(options, schema, allowUnknown) {
|
||||
if (typeof options !== 'object') {
|
||||
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
||||
}
|
||||
const keys = Object.keys(options);
|
||||
let i = keys.length;
|
||||
while (i-- > 0) {
|
||||
const opt = keys[i];
|
||||
const validator = schema[opt];
|
||||
if (validator) {
|
||||
const value = options[opt];
|
||||
const result = value === undefined || validator(value, opt, options);
|
||||
if (result !== true) {
|
||||
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (allowUnknown !== true) {
|
||||
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
assertOptions,
|
||||
validators
|
||||
};
|
3
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/classes/Blob.js
generated
vendored
Normal file
3
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/classes/Blob.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict'
|
||||
|
||||
export default typeof Blob !== 'undefined' ? Blob : null
|
3
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/classes/FormData.js
generated
vendored
Normal file
3
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/classes/FormData.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
export default typeof FormData !== 'undefined' ? FormData : null;
|
4
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js
generated
vendored
Normal file
4
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
import AxiosURLSearchParams from '../../../helpers/AxiosURLSearchParams.js';
|
||||
export default typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
|
64
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/index.js
generated
vendored
Normal file
64
parent_dir/20240530212112Z/node_modules/axios/lib/platform/browser/index.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import URLSearchParams from './classes/URLSearchParams.js'
|
||||
import FormData from './classes/FormData.js'
|
||||
import Blob from './classes/Blob.js'
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser environment
|
||||
*
|
||||
* This allows axios to run in a web worker, and react-native.
|
||||
* Both environments support XMLHttpRequest, but not fully standard globals.
|
||||
*
|
||||
* web workers:
|
||||
* typeof window -> undefined
|
||||
* typeof document -> undefined
|
||||
*
|
||||
* react-native:
|
||||
* navigator.product -> 'ReactNative'
|
||||
* nativescript
|
||||
* navigator.product -> 'NativeScript' or 'NS'
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isStandardBrowserEnv = (() => {
|
||||
let product;
|
||||
if (typeof navigator !== 'undefined' && (
|
||||
(product = navigator.product) === 'ReactNative' ||
|
||||
product === 'NativeScript' ||
|
||||
product === 'NS')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
})();
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser webWorker environment
|
||||
*
|
||||
* Although the `isStandardBrowserEnv` method indicates that
|
||||
* `allows axios to run in a web worker`, the WebWorker will still be
|
||||
* filtered out due to its judgment standard
|
||||
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
||||
* This leads to a problem when axios post `FormData` in webWorker
|
||||
*/
|
||||
const isStandardBrowserWebWorkerEnv = (() => {
|
||||
return (
|
||||
typeof WorkerGlobalScope !== 'undefined' &&
|
||||
// eslint-disable-next-line no-undef
|
||||
self instanceof WorkerGlobalScope &&
|
||||
typeof self.importScripts === 'function'
|
||||
);
|
||||
})();
|
||||
|
||||
|
||||
export default {
|
||||
isBrowser: true,
|
||||
classes: {
|
||||
URLSearchParams,
|
||||
FormData,
|
||||
Blob
|
||||
},
|
||||
isStandardBrowserEnv,
|
||||
isStandardBrowserWebWorkerEnv,
|
||||
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
||||
};
|
711
parent_dir/20240530212112Z/node_modules/axios/lib/utils.js
generated
vendored
Normal file
711
parent_dir/20240530212112Z/node_modules/axios/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,711 @@
|
||||
'use strict';
|
||||
|
||||
import bind from './helpers/bind.js';
|
||||
|
||||
// utils is a library of generic helper functions non-specific to axios
|
||||
|
||||
const {toString} = Object.prototype;
|
||||
const {getPrototypeOf} = Object;
|
||||
|
||||
const kindOf = (cache => thing => {
|
||||
const str = toString.call(thing);
|
||||
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
||||
})(Object.create(null));
|
||||
|
||||
const kindOfTest = (type) => {
|
||||
type = type.toLowerCase();
|
||||
return (thing) => kindOf(thing) === type
|
||||
}
|
||||
|
||||
const typeOfTest = type => thing => typeof thing === type;
|
||||
|
||||
/**
|
||||
* Determine if a value is an Array
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is an Array, otherwise false
|
||||
*/
|
||||
const {isArray} = Array;
|
||||
|
||||
/**
|
||||
* Determine if a value is undefined
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if the value is undefined, otherwise false
|
||||
*/
|
||||
const isUndefined = typeOfTest('undefined');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Buffer
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a Buffer, otherwise false
|
||||
*/
|
||||
function isBuffer(val) {
|
||||
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
|
||||
&& isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an ArrayBuffer
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||||
*/
|
||||
const isArrayBuffer = kindOfTest('ArrayBuffer');
|
||||
|
||||
|
||||
/**
|
||||
* Determine if a value is a view on an ArrayBuffer
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBufferView(val) {
|
||||
let result;
|
||||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
||||
result = ArrayBuffer.isView(val);
|
||||
} else {
|
||||
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a String
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a String, otherwise false
|
||||
*/
|
||||
const isString = typeOfTest('string');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Function
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
* @returns {boolean} True if value is a Function, otherwise false
|
||||
*/
|
||||
const isFunction = typeOfTest('function');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Number
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a Number, otherwise false
|
||||
*/
|
||||
const isNumber = typeOfTest('number');
|
||||
|
||||
/**
|
||||
* Determine if a value is an Object
|
||||
*
|
||||
* @param {*} thing The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is an Object, otherwise false
|
||||
*/
|
||||
const isObject = (thing) => thing !== null && typeof thing === 'object';
|
||||
|
||||
/**
|
||||
* Determine if a value is a Boolean
|
||||
*
|
||||
* @param {*} thing The value to test
|
||||
* @returns {boolean} True if value is a Boolean, otherwise false
|
||||
*/
|
||||
const isBoolean = thing => thing === true || thing === false;
|
||||
|
||||
/**
|
||||
* Determine if a value is a plain Object
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a plain Object, otherwise false
|
||||
*/
|
||||
const isPlainObject = (val) => {
|
||||
if (kindOf(val) !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const prototype = getPrototypeOf(val);
|
||||
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Date
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a Date, otherwise false
|
||||
*/
|
||||
const isDate = kindOfTest('Date');
|
||||
|
||||
/**
|
||||
* Determine if a value is a File
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a File, otherwise false
|
||||
*/
|
||||
const isFile = kindOfTest('File');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Blob
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a Blob, otherwise false
|
||||
*/
|
||||
const isBlob = kindOfTest('Blob');
|
||||
|
||||
/**
|
||||
* Determine if a value is a FileList
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a File, otherwise false
|
||||
*/
|
||||
const isFileList = kindOfTest('FileList');
|
||||
|
||||
/**
|
||||
* Determine if a value is a Stream
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a Stream, otherwise false
|
||||
*/
|
||||
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
||||
|
||||
/**
|
||||
* Determine if a value is a FormData
|
||||
*
|
||||
* @param {*} thing The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is an FormData, otherwise false
|
||||
*/
|
||||
const isFormData = (thing) => {
|
||||
const pattern = '[object FormData]';
|
||||
return thing && (
|
||||
(typeof FormData === 'function' && thing instanceof FormData) ||
|
||||
toString.call(thing) === pattern ||
|
||||
(isFunction(thing.toString) && thing.toString() === pattern)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a URLSearchParams object
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
||||
*/
|
||||
const isURLSearchParams = kindOfTest('URLSearchParams');
|
||||
|
||||
/**
|
||||
* Trim excess whitespace off the beginning and end of a string
|
||||
*
|
||||
* @param {String} str The String to trim
|
||||
*
|
||||
* @returns {String} The String freed of excess whitespace
|
||||
*/
|
||||
const trim = (str) => str.trim ?
|
||||
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
||||
|
||||
/**
|
||||
* Iterate over an Array or an Object invoking a function for each item.
|
||||
*
|
||||
* If `obj` is an Array callback will be called passing
|
||||
* the value, index, and complete array for each item.
|
||||
*
|
||||
* If 'obj' is an Object callback will be called passing
|
||||
* the value, key, and complete object for each property.
|
||||
*
|
||||
* @param {Object|Array} obj The object to iterate
|
||||
* @param {Function} fn The callback to invoke for each item
|
||||
*
|
||||
* @param {Boolean} [allOwnKeys = false]
|
||||
* @returns {any}
|
||||
*/
|
||||
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
||||
// Don't bother if no value provided
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
let i;
|
||||
let l;
|
||||
|
||||
// Force an array if not already something iterable
|
||||
if (typeof obj !== 'object') {
|
||||
/*eslint no-param-reassign:0*/
|
||||
obj = [obj];
|
||||
}
|
||||
|
||||
if (isArray(obj)) {
|
||||
// Iterate over array values
|
||||
for (i = 0, l = obj.length; i < l; i++) {
|
||||
fn.call(null, obj[i], i, obj);
|
||||
}
|
||||
} else {
|
||||
// Iterate over object keys
|
||||
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
||||
const len = keys.length;
|
||||
let key;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
key = keys[i];
|
||||
fn.call(null, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function findKey(obj, key) {
|
||||
key = key.toLowerCase();
|
||||
const keys = Object.keys(obj);
|
||||
let i = keys.length;
|
||||
let _key;
|
||||
while (i-- > 0) {
|
||||
_key = keys[i];
|
||||
if (key === _key.toLowerCase()) {
|
||||
return _key;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const _global = (() => {
|
||||
/*eslint no-undef:0*/
|
||||
if (typeof globalThis !== "undefined") return globalThis;
|
||||
return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
|
||||
})();
|
||||
|
||||
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
||||
|
||||
/**
|
||||
* Accepts varargs expecting each argument to be an object, then
|
||||
* immutably merges the properties of each object and returns result.
|
||||
*
|
||||
* When multiple objects contain the same key the later object in
|
||||
* the arguments list will take precedence.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* var result = merge({foo: 123}, {foo: 456});
|
||||
* console.log(result.foo); // outputs 456
|
||||
* ```
|
||||
*
|
||||
* @param {Object} obj1 Object to merge
|
||||
*
|
||||
* @returns {Object} Result of all merge properties
|
||||
*/
|
||||
function merge(/* obj1, obj2, obj3, ... */) {
|
||||
const {caseless} = isContextDefined(this) && this || {};
|
||||
const result = {};
|
||||
const assignValue = (val, key) => {
|
||||
const targetKey = caseless && findKey(result, key) || key;
|
||||
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
||||
result[targetKey] = merge(result[targetKey], val);
|
||||
} else if (isPlainObject(val)) {
|
||||
result[targetKey] = merge({}, val);
|
||||
} else if (isArray(val)) {
|
||||
result[targetKey] = val.slice();
|
||||
} else {
|
||||
result[targetKey] = val;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0, l = arguments.length; i < l; i++) {
|
||||
arguments[i] && forEach(arguments[i], assignValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends object a by mutably adding to it the properties of object b.
|
||||
*
|
||||
* @param {Object} a The object to be extended
|
||||
* @param {Object} b The object to copy properties from
|
||||
* @param {Object} thisArg The object to bind function to
|
||||
*
|
||||
* @param {Boolean} [allOwnKeys]
|
||||
* @returns {Object} The resulting value of object a
|
||||
*/
|
||||
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
||||
forEach(b, (val, key) => {
|
||||
if (thisArg && isFunction(val)) {
|
||||
a[key] = bind(val, thisArg);
|
||||
} else {
|
||||
a[key] = val;
|
||||
}
|
||||
}, {allOwnKeys});
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
||||
*
|
||||
* @param {string} content with BOM
|
||||
*
|
||||
* @returns {string} content value without BOM
|
||||
*/
|
||||
const stripBOM = (content) => {
|
||||
if (content.charCodeAt(0) === 0xFEFF) {
|
||||
content = content.slice(1);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another
|
||||
* @param {function} constructor
|
||||
* @param {function} superConstructor
|
||||
* @param {object} [props]
|
||||
* @param {object} [descriptors]
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
const inherits = (constructor, superConstructor, props, descriptors) => {
|
||||
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
||||
constructor.prototype.constructor = constructor;
|
||||
Object.defineProperty(constructor, 'super', {
|
||||
value: superConstructor.prototype
|
||||
});
|
||||
props && Object.assign(constructor.prototype, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve object with deep prototype chain to a flat object
|
||||
* @param {Object} sourceObj source object
|
||||
* @param {Object} [destObj]
|
||||
* @param {Function|Boolean} [filter]
|
||||
* @param {Function} [propFilter]
|
||||
*
|
||||
* @returns {Object}
|
||||
*/
|
||||
const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
|
||||
let props;
|
||||
let i;
|
||||
let prop;
|
||||
const merged = {};
|
||||
|
||||
destObj = destObj || {};
|
||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||
if (sourceObj == null) return destObj;
|
||||
|
||||
do {
|
||||
props = Object.getOwnPropertyNames(sourceObj);
|
||||
i = props.length;
|
||||
while (i-- > 0) {
|
||||
prop = props[i];
|
||||
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
||||
destObj[prop] = sourceObj[prop];
|
||||
merged[prop] = true;
|
||||
}
|
||||
}
|
||||
sourceObj = filter !== false && getPrototypeOf(sourceObj);
|
||||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
||||
|
||||
return destObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a string ends with the characters of a specified string
|
||||
*
|
||||
* @param {String} str
|
||||
* @param {String} searchString
|
||||
* @param {Number} [position= 0]
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const endsWith = (str, searchString, position) => {
|
||||
str = String(str);
|
||||
if (position === undefined || position > str.length) {
|
||||
position = str.length;
|
||||
}
|
||||
position -= searchString.length;
|
||||
const lastIndex = str.indexOf(searchString, position);
|
||||
return lastIndex !== -1 && lastIndex === position;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns new array from array like object or null if failed
|
||||
*
|
||||
* @param {*} [thing]
|
||||
*
|
||||
* @returns {?Array}
|
||||
*/
|
||||
const toArray = (thing) => {
|
||||
if (!thing) return null;
|
||||
if (isArray(thing)) return thing;
|
||||
let i = thing.length;
|
||||
if (!isNumber(i)) return null;
|
||||
const arr = new Array(i);
|
||||
while (i-- > 0) {
|
||||
arr[i] = thing[i];
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checking if the Uint8Array exists and if it does, it returns a function that checks if the
|
||||
* thing passed in is an instance of Uint8Array
|
||||
*
|
||||
* @param {TypedArray}
|
||||
*
|
||||
* @returns {Array}
|
||||
*/
|
||||
// eslint-disable-next-line func-names
|
||||
const isTypedArray = (TypedArray => {
|
||||
// eslint-disable-next-line func-names
|
||||
return thing => {
|
||||
return TypedArray && thing instanceof TypedArray;
|
||||
};
|
||||
})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
|
||||
|
||||
/**
|
||||
* For each entry in the object, call the function with the key and value.
|
||||
*
|
||||
* @param {Object<any, any>} obj - The object to iterate over.
|
||||
* @param {Function} fn - The function to call for each entry.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
const forEachEntry = (obj, fn) => {
|
||||
const generator = obj && obj[Symbol.iterator];
|
||||
|
||||
const iterator = generator.call(obj);
|
||||
|
||||
let result;
|
||||
|
||||
while ((result = iterator.next()) && !result.done) {
|
||||
const pair = result.value;
|
||||
fn.call(obj, pair[0], pair[1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* It takes a regular expression and a string, and returns an array of all the matches
|
||||
*
|
||||
* @param {string} regExp - The regular expression to match against.
|
||||
* @param {string} str - The string to search.
|
||||
*
|
||||
* @returns {Array<boolean>}
|
||||
*/
|
||||
const matchAll = (regExp, str) => {
|
||||
let matches;
|
||||
const arr = [];
|
||||
|
||||
while ((matches = regExp.exec(str)) !== null) {
|
||||
arr.push(matches);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
||||
const isHTMLForm = kindOfTest('HTMLFormElement');
|
||||
|
||||
const toCamelCase = str => {
|
||||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
||||
function replacer(m, p1, p2) {
|
||||
return p1.toUpperCase() + p2;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/* Creating a function that will check if an object has a property. */
|
||||
const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
|
||||
|
||||
/**
|
||||
* Determine if a value is a RegExp object
|
||||
*
|
||||
* @param {*} val The value to test
|
||||
*
|
||||
* @returns {boolean} True if value is a RegExp object, otherwise false
|
||||
*/
|
||||
const isRegExp = kindOfTest('RegExp');
|
||||
|
||||
const reduceDescriptors = (obj, reducer) => {
|
||||
const descriptors = Object.getOwnPropertyDescriptors(obj);
|
||||
const reducedDescriptors = {};
|
||||
|
||||
forEach(descriptors, (descriptor, name) => {
|
||||
if (reducer(descriptor, name, obj) !== false) {
|
||||
reducedDescriptors[name] = descriptor;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperties(obj, reducedDescriptors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes all methods read-only
|
||||
* @param {Object} obj
|
||||
*/
|
||||
|
||||
const freezeMethods = (obj) => {
|
||||
reduceDescriptors(obj, (descriptor, name) => {
|
||||
// skip restricted props in strict mode
|
||||
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const value = obj[name];
|
||||
|
||||
if (!isFunction(value)) return;
|
||||
|
||||
descriptor.enumerable = false;
|
||||
|
||||
if ('writable' in descriptor) {
|
||||
descriptor.writable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!descriptor.set) {
|
||||
descriptor.set = () => {
|
||||
throw Error('Can not rewrite read-only method \'' + name + '\'');
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const toObjectSet = (arrayOrString, delimiter) => {
|
||||
const obj = {};
|
||||
|
||||
const define = (arr) => {
|
||||
arr.forEach(value => {
|
||||
obj[value] = true;
|
||||
});
|
||||
}
|
||||
|
||||
isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
const noop = () => {}
|
||||
|
||||
const toFiniteNumber = (value, defaultValue) => {
|
||||
value = +value;
|
||||
return Number.isFinite(value) ? value : defaultValue;
|
||||
}
|
||||
|
||||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz'
|
||||
|
||||
const DIGIT = '0123456789';
|
||||
|
||||
const ALPHABET = {
|
||||
DIGIT,
|
||||
ALPHA,
|
||||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
||||
}
|
||||
|
||||
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
||||
let str = '';
|
||||
const {length} = alphabet;
|
||||
while (size--) {
|
||||
str += alphabet[Math.random() * length|0]
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliantForm(thing) {
|
||||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
||||
}
|
||||
|
||||
const toJSONObject = (obj) => {
|
||||
const stack = new Array(10);
|
||||
|
||||
const visit = (source, i) => {
|
||||
|
||||
if (isObject(source)) {
|
||||
if (stack.indexOf(source) >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!('toJSON' in source)) {
|
||||
stack[i] = source;
|
||||
const target = isArray(source) ? [] : {};
|
||||
|
||||
forEach(source, (value, key) => {
|
||||
const reducedValue = visit(value, i + 1);
|
||||
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
||||
});
|
||||
|
||||
stack[i] = undefined;
|
||||
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
return visit(obj, 0);
|
||||
}
|
||||
|
||||
export default {
|
||||
isArray,
|
||||
isArrayBuffer,
|
||||
isBuffer,
|
||||
isFormData,
|
||||
isArrayBufferView,
|
||||
isString,
|
||||
isNumber,
|
||||
isBoolean,
|
||||
isObject,
|
||||
isPlainObject,
|
||||
isUndefined,
|
||||
isDate,
|
||||
isFile,
|
||||
isBlob,
|
||||
isRegExp,
|
||||
isFunction,
|
||||
isStream,
|
||||
isURLSearchParams,
|
||||
isTypedArray,
|
||||
isFileList,
|
||||
forEach,
|
||||
merge,
|
||||
extend,
|
||||
trim,
|
||||
stripBOM,
|
||||
inherits,
|
||||
toFlatObject,
|
||||
kindOf,
|
||||
kindOfTest,
|
||||
endsWith,
|
||||
toArray,
|
||||
forEachEntry,
|
||||
matchAll,
|
||||
isHTMLForm,
|
||||
hasOwnProperty,
|
||||
hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
|
||||
reduceDescriptors,
|
||||
freezeMethods,
|
||||
toObjectSet,
|
||||
toCamelCase,
|
||||
noop,
|
||||
toFiniteNumber,
|
||||
findKey,
|
||||
global: _global,
|
||||
isContextDefined,
|
||||
ALPHABET,
|
||||
generateString,
|
||||
isSpecCompliantForm,
|
||||
toJSONObject
|
||||
};
|
77
parent_dir/20240530212112Z/node_modules/bowser/src/bowser.js
generated
vendored
Normal file
77
parent_dir/20240530212112Z/node_modules/bowser/src/bowser.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*!
|
||||
* Bowser - a browser detector
|
||||
* https://github.com/lancedikson/bowser
|
||||
* MIT License | (c) Dustin Diaz 2012-2015
|
||||
* MIT License | (c) Denis Demchenko 2015-2019
|
||||
*/
|
||||
import Parser from './parser.js';
|
||||
import {
|
||||
BROWSER_MAP,
|
||||
ENGINE_MAP,
|
||||
OS_MAP,
|
||||
PLATFORMS_MAP,
|
||||
} from './constants.js';
|
||||
|
||||
/**
|
||||
* Bowser class.
|
||||
* Keep it simple as much as it can be.
|
||||
* It's supposed to work with collections of {@link Parser} instances
|
||||
* rather then solve one-instance problems.
|
||||
* All the one-instance stuff is located in Parser class.
|
||||
*
|
||||
* @class
|
||||
* @classdesc Bowser is a static object, that provides an API to the Parsers
|
||||
* @hideconstructor
|
||||
*/
|
||||
class Bowser {
|
||||
/**
|
||||
* Creates a {@link Parser} instance
|
||||
*
|
||||
* @param {String} UA UserAgent string
|
||||
* @param {Boolean} [skipParsing=false] Will make the Parser postpone parsing until you ask it
|
||||
* explicitly. Same as `skipParsing` for {@link Parser}.
|
||||
* @returns {Parser}
|
||||
* @throws {Error} when UA is not a String
|
||||
*
|
||||
* @example
|
||||
* const parser = Bowser.getParser(window.navigator.userAgent);
|
||||
* const result = parser.getResult();
|
||||
*/
|
||||
static getParser(UA, skipParsing = false) {
|
||||
if (typeof UA !== 'string') {
|
||||
throw new Error('UserAgent should be a string');
|
||||
}
|
||||
return new Parser(UA, skipParsing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Parser} instance and runs {@link Parser.getResult} immediately
|
||||
*
|
||||
* @param UA
|
||||
* @return {ParsedResult}
|
||||
*
|
||||
* @example
|
||||
* const result = Bowser.parse(window.navigator.userAgent);
|
||||
*/
|
||||
static parse(UA) {
|
||||
return (new Parser(UA)).getResult();
|
||||
}
|
||||
|
||||
static get BROWSER_MAP() {
|
||||
return BROWSER_MAP;
|
||||
}
|
||||
|
||||
static get ENGINE_MAP() {
|
||||
return ENGINE_MAP;
|
||||
}
|
||||
|
||||
static get OS_MAP() {
|
||||
return OS_MAP;
|
||||
}
|
||||
|
||||
static get PLATFORMS_MAP() {
|
||||
return PLATFORMS_MAP;
|
||||
}
|
||||
}
|
||||
|
||||
export default Bowser;
|
116
parent_dir/20240530212112Z/node_modules/bowser/src/constants.js
generated
vendored
Normal file
116
parent_dir/20240530212112Z/node_modules/bowser/src/constants.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
// NOTE: this list must be up-to-date with browsers listed in
|
||||
// test/acceptance/useragentstrings.yml
|
||||
export const BROWSER_ALIASES_MAP = {
|
||||
'Amazon Silk': 'amazon_silk',
|
||||
'Android Browser': 'android',
|
||||
Bada: 'bada',
|
||||
BlackBerry: 'blackberry',
|
||||
Chrome: 'chrome',
|
||||
Chromium: 'chromium',
|
||||
Electron: 'electron',
|
||||
Epiphany: 'epiphany',
|
||||
Firefox: 'firefox',
|
||||
Focus: 'focus',
|
||||
Generic: 'generic',
|
||||
'Google Search': 'google_search',
|
||||
Googlebot: 'googlebot',
|
||||
'Internet Explorer': 'ie',
|
||||
'K-Meleon': 'k_meleon',
|
||||
Maxthon: 'maxthon',
|
||||
'Microsoft Edge': 'edge',
|
||||
'MZ Browser': 'mz',
|
||||
'NAVER Whale Browser': 'naver',
|
||||
Opera: 'opera',
|
||||
'Opera Coast': 'opera_coast',
|
||||
PhantomJS: 'phantomjs',
|
||||
Puffin: 'puffin',
|
||||
QupZilla: 'qupzilla',
|
||||
QQ: 'qq',
|
||||
QQLite: 'qqlite',
|
||||
Safari: 'safari',
|
||||
Sailfish: 'sailfish',
|
||||
'Samsung Internet for Android': 'samsung_internet',
|
||||
SeaMonkey: 'seamonkey',
|
||||
Sleipnir: 'sleipnir',
|
||||
Swing: 'swing',
|
||||
Tizen: 'tizen',
|
||||
'UC Browser': 'uc',
|
||||
Vivaldi: 'vivaldi',
|
||||
'WebOS Browser': 'webos',
|
||||
WeChat: 'wechat',
|
||||
'Yandex Browser': 'yandex',
|
||||
Roku: 'roku',
|
||||
};
|
||||
|
||||
export const BROWSER_MAP = {
|
||||
amazon_silk: 'Amazon Silk',
|
||||
android: 'Android Browser',
|
||||
bada: 'Bada',
|
||||
blackberry: 'BlackBerry',
|
||||
chrome: 'Chrome',
|
||||
chromium: 'Chromium',
|
||||
electron: 'Electron',
|
||||
epiphany: 'Epiphany',
|
||||
firefox: 'Firefox',
|
||||
focus: 'Focus',
|
||||
generic: 'Generic',
|
||||
googlebot: 'Googlebot',
|
||||
google_search: 'Google Search',
|
||||
ie: 'Internet Explorer',
|
||||
k_meleon: 'K-Meleon',
|
||||
maxthon: 'Maxthon',
|
||||
edge: 'Microsoft Edge',
|
||||
mz: 'MZ Browser',
|
||||
naver: 'NAVER Whale Browser',
|
||||
opera: 'Opera',
|
||||
opera_coast: 'Opera Coast',
|
||||
phantomjs: 'PhantomJS',
|
||||
puffin: 'Puffin',
|
||||
qupzilla: 'QupZilla',
|
||||
qq: 'QQ Browser',
|
||||
qqlite: 'QQ Browser Lite',
|
||||
safari: 'Safari',
|
||||
sailfish: 'Sailfish',
|
||||
samsung_internet: 'Samsung Internet for Android',
|
||||
seamonkey: 'SeaMonkey',
|
||||
sleipnir: 'Sleipnir',
|
||||
swing: 'Swing',
|
||||
tizen: 'Tizen',
|
||||
uc: 'UC Browser',
|
||||
vivaldi: 'Vivaldi',
|
||||
webos: 'WebOS Browser',
|
||||
wechat: 'WeChat',
|
||||
yandex: 'Yandex Browser',
|
||||
};
|
||||
|
||||
export const PLATFORMS_MAP = {
|
||||
tablet: 'tablet',
|
||||
mobile: 'mobile',
|
||||
desktop: 'desktop',
|
||||
tv: 'tv',
|
||||
};
|
||||
|
||||
export const OS_MAP = {
|
||||
WindowsPhone: 'Windows Phone',
|
||||
Windows: 'Windows',
|
||||
MacOS: 'macOS',
|
||||
iOS: 'iOS',
|
||||
Android: 'Android',
|
||||
WebOS: 'WebOS',
|
||||
BlackBerry: 'BlackBerry',
|
||||
Bada: 'Bada',
|
||||
Tizen: 'Tizen',
|
||||
Linux: 'Linux',
|
||||
ChromeOS: 'Chrome OS',
|
||||
PlayStation4: 'PlayStation 4',
|
||||
Roku: 'Roku',
|
||||
};
|
||||
|
||||
export const ENGINE_MAP = {
|
||||
EdgeHTML: 'EdgeHTML',
|
||||
Blink: 'Blink',
|
||||
Trident: 'Trident',
|
||||
Presto: 'Presto',
|
||||
Gecko: 'Gecko',
|
||||
WebKit: 'WebKit',
|
||||
};
|
700
parent_dir/20240530212112Z/node_modules/bowser/src/parser-browsers.js
generated
vendored
Normal file
700
parent_dir/20240530212112Z/node_modules/bowser/src/parser-browsers.js
generated
vendored
Normal file
@@ -0,0 +1,700 @@
|
||||
/**
|
||||
* Browsers' descriptors
|
||||
*
|
||||
* The idea of descriptors is simple. You should know about them two simple things:
|
||||
* 1. Every descriptor has a method or property called `test` and a `describe` method.
|
||||
* 2. Order of descriptors is important.
|
||||
*
|
||||
* More details:
|
||||
* 1. Method or property `test` serves as a way to detect whether the UA string
|
||||
* matches some certain browser or not. The `describe` method helps to make a result
|
||||
* object with params that show some browser-specific things: name, version, etc.
|
||||
* 2. Order of descriptors is important because a Parser goes through them one by one
|
||||
* in course. For example, if you insert Chrome's descriptor as the first one,
|
||||
* more then a half of browsers will be described as Chrome, because they will pass
|
||||
* the Chrome descriptor's test.
|
||||
*
|
||||
* Descriptor's `test` could be a property with an array of RegExps, where every RegExp
|
||||
* will be applied to a UA string to test it whether it matches or not.
|
||||
* If a descriptor has two or more regexps in the `test` array it tests them one by one
|
||||
* with a logical sum operation. Parser stops if it has found any RegExp that matches the UA.
|
||||
*
|
||||
* Or `test` could be a method. In that case it gets a Parser instance and should
|
||||
* return true/false to get the Parser know if this browser descriptor matches the UA or not.
|
||||
*/
|
||||
|
||||
import Utils from './utils.js';
|
||||
|
||||
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
||||
|
||||
const browsersList = [
|
||||
/* Googlebot */
|
||||
{
|
||||
test: [/googlebot/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Googlebot',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/googlebot\/(\d+(\.\d+))/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
|
||||
/* Opera < 13.0 */
|
||||
{
|
||||
test: [/opera/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Opera',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
|
||||
/* Opera > 13.0 */
|
||||
{
|
||||
test: [/opr\/|opios/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Opera',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/SamsungBrowser/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Samsung Internet for Android',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/Whale/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'NAVER Whale Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/MZBrowser/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'MZ Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/focus/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Focus',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/swing/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Swing',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/coast/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Opera Coast',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/opt\/\d+(?:.?_?\d+)+/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Opera Touch',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/yabrowser/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Yandex Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/ucbrowser/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'UC Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/Maxthon|mxios/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Maxthon',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/epiphany/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Epiphany',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/puffin/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Puffin',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/sleipnir/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Sleipnir',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/k-meleon/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'K-Meleon',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/micromessenger/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'WeChat',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/qqbrowser/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: (/qqbrowserlite/i).test(ua) ? 'QQ Browser Lite' : 'QQ Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/msie|trident/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Internet Explorer',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/\sedg\//i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Microsoft Edge',
|
||||
};
|
||||
|
||||
const version = Utils.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/edg([ea]|ios)/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Microsoft Edge',
|
||||
};
|
||||
|
||||
const version = Utils.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/vivaldi/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Vivaldi',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/seamonkey/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'SeaMonkey',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/sailfish/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Sailfish',
|
||||
};
|
||||
|
||||
const version = Utils.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/silk/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Amazon Silk',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/phantom/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'PhantomJS',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/slimerjs/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'SlimerJS',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'BlackBerry',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/(web|hpw)[o0]s/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'WebOS Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua) || Utils.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/bada/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Bada',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/tizen/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Tizen',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/qupzilla/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'QupZilla',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/firefox|iceweasel|fxios/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Firefox',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/electron/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Electron',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/MiuiBrowser/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Miui',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/chromium/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Chromium',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i, ua) || Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/chrome|crios|crmo/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Chrome',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
{
|
||||
test: [/GSA/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Google Search',
|
||||
};
|
||||
const version = Utils.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
|
||||
/* Android Browser */
|
||||
{
|
||||
test(parser) {
|
||||
const notLikeAndroid = !parser.test(/like android/i);
|
||||
const butAndroid = parser.test(/android/i);
|
||||
return notLikeAndroid && butAndroid;
|
||||
},
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Android Browser',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
|
||||
/* PlayStation 4 */
|
||||
{
|
||||
test: [/playstation 4/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'PlayStation 4',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
|
||||
/* Safari */
|
||||
{
|
||||
test: [/safari|applewebkit/i],
|
||||
describe(ua) {
|
||||
const browser = {
|
||||
name: 'Safari',
|
||||
};
|
||||
const version = Utils.getFirstMatch(commonVersionIdentifier, ua);
|
||||
|
||||
if (version) {
|
||||
browser.version = version;
|
||||
}
|
||||
|
||||
return browser;
|
||||
},
|
||||
},
|
||||
|
||||
/* Something else */
|
||||
{
|
||||
test: [/.*/i],
|
||||
describe(ua) {
|
||||
/* Here we try to make sure that there are explicit details about the device
|
||||
* in order to decide what regexp exactly we want to apply
|
||||
* (as there is a specific decision based on that conclusion)
|
||||
*/
|
||||
const regexpWithoutDeviceSpec = /^(.*)\/(.*) /;
|
||||
const regexpWithDeviceSpec = /^(.*)\/(.*)[ \t]\((.*)/;
|
||||
const hasDeviceSpec = ua.search('\\(') !== -1;
|
||||
const regexp = hasDeviceSpec ? regexpWithDeviceSpec : regexpWithoutDeviceSpec;
|
||||
return {
|
||||
name: Utils.getFirstMatch(regexp, ua),
|
||||
version: Utils.getSecondMatch(regexp, ua),
|
||||
};
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export default browsersList;
|
120
parent_dir/20240530212112Z/node_modules/bowser/src/parser-engines.js
generated
vendored
Normal file
120
parent_dir/20240530212112Z/node_modules/bowser/src/parser-engines.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
import Utils from './utils.js';
|
||||
import { ENGINE_MAP } from './constants.js';
|
||||
|
||||
/*
|
||||
* More specific goes first
|
||||
*/
|
||||
export default [
|
||||
/* EdgeHTML */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getBrowserName(true) === 'microsoft edge';
|
||||
},
|
||||
describe(ua) {
|
||||
const isBlinkBased = /\sedg\//i.test(ua);
|
||||
|
||||
// return blink if it's blink-based one
|
||||
if (isBlinkBased) {
|
||||
return {
|
||||
name: ENGINE_MAP.Blink,
|
||||
};
|
||||
}
|
||||
|
||||
// otherwise match the version and return EdgeHTML
|
||||
const version = Utils.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
return {
|
||||
name: ENGINE_MAP.EdgeHTML,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Trident */
|
||||
{
|
||||
test: [/trident/i],
|
||||
describe(ua) {
|
||||
const engine = {
|
||||
name: ENGINE_MAP.Trident,
|
||||
};
|
||||
|
||||
const version = Utils.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
engine.version = version;
|
||||
}
|
||||
|
||||
return engine;
|
||||
},
|
||||
},
|
||||
|
||||
/* Presto */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.test(/presto/i);
|
||||
},
|
||||
describe(ua) {
|
||||
const engine = {
|
||||
name: ENGINE_MAP.Presto,
|
||||
};
|
||||
|
||||
const version = Utils.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
engine.version = version;
|
||||
}
|
||||
|
||||
return engine;
|
||||
},
|
||||
},
|
||||
|
||||
/* Gecko */
|
||||
{
|
||||
test(parser) {
|
||||
const isGecko = parser.test(/gecko/i);
|
||||
const likeGecko = parser.test(/like gecko/i);
|
||||
return isGecko && !likeGecko;
|
||||
},
|
||||
describe(ua) {
|
||||
const engine = {
|
||||
name: ENGINE_MAP.Gecko,
|
||||
};
|
||||
|
||||
const version = Utils.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
engine.version = version;
|
||||
}
|
||||
|
||||
return engine;
|
||||
},
|
||||
},
|
||||
|
||||
/* Blink */
|
||||
{
|
||||
test: [/(apple)?webkit\/537\.36/i],
|
||||
describe() {
|
||||
return {
|
||||
name: ENGINE_MAP.Blink,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* WebKit */
|
||||
{
|
||||
test: [/(apple)?webkit/i],
|
||||
describe(ua) {
|
||||
const engine = {
|
||||
name: ENGINE_MAP.WebKit,
|
||||
};
|
||||
|
||||
const version = Utils.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i, ua);
|
||||
|
||||
if (version) {
|
||||
engine.version = version;
|
||||
}
|
||||
|
||||
return engine;
|
||||
},
|
||||
},
|
||||
];
|
199
parent_dir/20240530212112Z/node_modules/bowser/src/parser-os.js
generated
vendored
Normal file
199
parent_dir/20240530212112Z/node_modules/bowser/src/parser-os.js
generated
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
import Utils from './utils.js';
|
||||
import { OS_MAP } from './constants.js';
|
||||
|
||||
export default [
|
||||
/* Roku */
|
||||
{
|
||||
test: [/Roku\/DVP/],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i, ua);
|
||||
return {
|
||||
name: OS_MAP.Roku,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Windows Phone */
|
||||
{
|
||||
test: [/windows phone/i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i, ua);
|
||||
return {
|
||||
name: OS_MAP.WindowsPhone,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Windows */
|
||||
{
|
||||
test: [/windows /i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i, ua);
|
||||
const versionName = Utils.getWindowsVersionName(version);
|
||||
|
||||
return {
|
||||
name: OS_MAP.Windows,
|
||||
version,
|
||||
versionName,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Firefox on iPad */
|
||||
{
|
||||
test: [/Macintosh(.*?) FxiOS(.*?)\//],
|
||||
describe(ua) {
|
||||
const result = {
|
||||
name: OS_MAP.iOS,
|
||||
};
|
||||
const version = Utils.getSecondMatch(/(Version\/)(\d[\d.]+)/, ua);
|
||||
if (version) {
|
||||
result.version = version;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
},
|
||||
|
||||
/* macOS */
|
||||
{
|
||||
test: [/macintosh/i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i, ua).replace(/[_\s]/g, '.');
|
||||
const versionName = Utils.getMacOSVersionName(version);
|
||||
|
||||
const os = {
|
||||
name: OS_MAP.MacOS,
|
||||
version,
|
||||
};
|
||||
if (versionName) {
|
||||
os.versionName = versionName;
|
||||
}
|
||||
return os;
|
||||
},
|
||||
},
|
||||
|
||||
/* iOS */
|
||||
{
|
||||
test: [/(ipod|iphone|ipad)/i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i, ua).replace(/[_\s]/g, '.');
|
||||
|
||||
return {
|
||||
name: OS_MAP.iOS,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Android */
|
||||
{
|
||||
test(parser) {
|
||||
const notLikeAndroid = !parser.test(/like android/i);
|
||||
const butAndroid = parser.test(/android/i);
|
||||
return notLikeAndroid && butAndroid;
|
||||
},
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i, ua);
|
||||
const versionName = Utils.getAndroidVersionName(version);
|
||||
const os = {
|
||||
name: OS_MAP.Android,
|
||||
version,
|
||||
};
|
||||
if (versionName) {
|
||||
os.versionName = versionName;
|
||||
}
|
||||
return os;
|
||||
},
|
||||
},
|
||||
|
||||
/* WebOS */
|
||||
{
|
||||
test: [/(web|hpw)[o0]s/i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i, ua);
|
||||
const os = {
|
||||
name: OS_MAP.WebOS,
|
||||
};
|
||||
|
||||
if (version && version.length) {
|
||||
os.version = version;
|
||||
}
|
||||
return os;
|
||||
},
|
||||
},
|
||||
|
||||
/* BlackBerry */
|
||||
{
|
||||
test: [/blackberry|\bbb\d+/i, /rim\stablet/i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i, ua)
|
||||
|| Utils.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i, ua)
|
||||
|| Utils.getFirstMatch(/\bbb(\d+)/i, ua);
|
||||
|
||||
return {
|
||||
name: OS_MAP.BlackBerry,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Bada */
|
||||
{
|
||||
test: [/bada/i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/bada\/(\d+(\.\d+)*)/i, ua);
|
||||
|
||||
return {
|
||||
name: OS_MAP.Bada,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Tizen */
|
||||
{
|
||||
test: [/tizen/i],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i, ua);
|
||||
|
||||
return {
|
||||
name: OS_MAP.Tizen,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Linux */
|
||||
{
|
||||
test: [/linux/i],
|
||||
describe() {
|
||||
return {
|
||||
name: OS_MAP.Linux,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Chrome OS */
|
||||
{
|
||||
test: [/CrOS/],
|
||||
describe() {
|
||||
return {
|
||||
name: OS_MAP.ChromeOS,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Playstation 4 */
|
||||
{
|
||||
test: [/PlayStation 4/],
|
||||
describe(ua) {
|
||||
const version = Utils.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i, ua);
|
||||
return {
|
||||
name: OS_MAP.PlayStation4,
|
||||
version,
|
||||
};
|
||||
},
|
||||
},
|
||||
];
|
266
parent_dir/20240530212112Z/node_modules/bowser/src/parser-platforms.js
generated
vendored
Normal file
266
parent_dir/20240530212112Z/node_modules/bowser/src/parser-platforms.js
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
import Utils from './utils.js';
|
||||
import { PLATFORMS_MAP } from './constants.js';
|
||||
|
||||
/*
|
||||
* Tablets go first since usually they have more specific
|
||||
* signs to detect.
|
||||
*/
|
||||
|
||||
export default [
|
||||
/* Googlebot */
|
||||
{
|
||||
test: [/googlebot/i],
|
||||
describe() {
|
||||
return {
|
||||
type: 'bot',
|
||||
vendor: 'Google',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Huawei */
|
||||
{
|
||||
test: [/huawei/i],
|
||||
describe(ua) {
|
||||
const model = Utils.getFirstMatch(/(can-l01)/i, ua) && 'Nova';
|
||||
const platform = {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
vendor: 'Huawei',
|
||||
};
|
||||
if (model) {
|
||||
platform.model = model;
|
||||
}
|
||||
return platform;
|
||||
},
|
||||
},
|
||||
|
||||
/* Nexus Tablet */
|
||||
{
|
||||
test: [/nexus\s*(?:7|8|9|10).*/i],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tablet,
|
||||
vendor: 'Nexus',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* iPad */
|
||||
{
|
||||
test: [/ipad/i],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tablet,
|
||||
vendor: 'Apple',
|
||||
model: 'iPad',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Firefox on iPad */
|
||||
{
|
||||
test: [/Macintosh(.*?) FxiOS(.*?)\//],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tablet,
|
||||
vendor: 'Apple',
|
||||
model: 'iPad',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Amazon Kindle Fire */
|
||||
{
|
||||
test: [/kftt build/i],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tablet,
|
||||
vendor: 'Amazon',
|
||||
model: 'Kindle Fire HD 7',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Another Amazon Tablet with Silk */
|
||||
{
|
||||
test: [/silk/i],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tablet,
|
||||
vendor: 'Amazon',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Tablet */
|
||||
{
|
||||
test: [/tablet(?! pc)/i],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tablet,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* iPod/iPhone */
|
||||
{
|
||||
test(parser) {
|
||||
const iDevice = parser.test(/ipod|iphone/i);
|
||||
const likeIDevice = parser.test(/like (ipod|iphone)/i);
|
||||
return iDevice && !likeIDevice;
|
||||
},
|
||||
describe(ua) {
|
||||
const model = Utils.getFirstMatch(/(ipod|iphone)/i, ua);
|
||||
return {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
vendor: 'Apple',
|
||||
model,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Nexus Mobile */
|
||||
{
|
||||
test: [/nexus\s*[0-6].*/i, /galaxy nexus/i],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
vendor: 'Nexus',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Mobile */
|
||||
{
|
||||
test: [/[^-]mobi/i],
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* BlackBerry */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getBrowserName(true) === 'blackberry';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
vendor: 'BlackBerry',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Bada */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getBrowserName(true) === 'bada';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Windows Phone */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getBrowserName() === 'windows phone';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
vendor: 'Microsoft',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Android Tablet */
|
||||
{
|
||||
test(parser) {
|
||||
const osMajorVersion = Number(String(parser.getOSVersion()).split('.')[0]);
|
||||
return parser.getOSName(true) === 'android' && (osMajorVersion >= 3);
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tablet,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Android Mobile */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getOSName(true) === 'android';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.mobile,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* desktop */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getOSName(true) === 'macos';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.desktop,
|
||||
vendor: 'Apple',
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Windows */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getOSName(true) === 'windows';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.desktop,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Linux */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getOSName(true) === 'linux';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.desktop,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* PlayStation 4 */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getOSName(true) === 'playstation 4';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tv,
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
/* Roku */
|
||||
{
|
||||
test(parser) {
|
||||
return parser.getOSName(true) === 'roku';
|
||||
},
|
||||
describe() {
|
||||
return {
|
||||
type: PLATFORMS_MAP.tv,
|
||||
};
|
||||
},
|
||||
},
|
||||
];
|
496
parent_dir/20240530212112Z/node_modules/bowser/src/parser.js
generated
vendored
Normal file
496
parent_dir/20240530212112Z/node_modules/bowser/src/parser.js
generated
vendored
Normal file
@@ -0,0 +1,496 @@
|
||||
import browserParsersList from './parser-browsers.js';
|
||||
import osParsersList from './parser-os.js';
|
||||
import platformParsersList from './parser-platforms.js';
|
||||
import enginesParsersList from './parser-engines.js';
|
||||
import Utils from './utils.js';
|
||||
|
||||
/**
|
||||
* The main class that arranges the whole parsing process.
|
||||
*/
|
||||
class Parser {
|
||||
/**
|
||||
* Create instance of Parser
|
||||
*
|
||||
* @param {String} UA User-Agent string
|
||||
* @param {Boolean} [skipParsing=false] parser can skip parsing in purpose of performance
|
||||
* improvements if you need to make a more particular parsing
|
||||
* like {@link Parser#parseBrowser} or {@link Parser#parsePlatform}
|
||||
*
|
||||
* @throw {Error} in case of empty UA String
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
constructor(UA, skipParsing = false) {
|
||||
if (UA === void (0) || UA === null || UA === '') {
|
||||
throw new Error("UserAgent parameter can't be empty");
|
||||
}
|
||||
|
||||
this._ua = UA;
|
||||
|
||||
/**
|
||||
* @typedef ParsedResult
|
||||
* @property {Object} browser
|
||||
* @property {String|undefined} [browser.name]
|
||||
* Browser name, like `"Chrome"` or `"Internet Explorer"`
|
||||
* @property {String|undefined} [browser.version] Browser version as a String `"12.01.45334.10"`
|
||||
* @property {Object} os
|
||||
* @property {String|undefined} [os.name] OS name, like `"Windows"` or `"macOS"`
|
||||
* @property {String|undefined} [os.version] OS version, like `"NT 5.1"` or `"10.11.1"`
|
||||
* @property {String|undefined} [os.versionName] OS name, like `"XP"` or `"High Sierra"`
|
||||
* @property {Object} platform
|
||||
* @property {String|undefined} [platform.type]
|
||||
* platform type, can be either `"desktop"`, `"tablet"` or `"mobile"`
|
||||
* @property {String|undefined} [platform.vendor] Vendor of the device,
|
||||
* like `"Apple"` or `"Samsung"`
|
||||
* @property {String|undefined} [platform.model] Device model,
|
||||
* like `"iPhone"` or `"Kindle Fire HD 7"`
|
||||
* @property {Object} engine
|
||||
* @property {String|undefined} [engine.name]
|
||||
* Can be any of this: `WebKit`, `Blink`, `Gecko`, `Trident`, `Presto`, `EdgeHTML`
|
||||
* @property {String|undefined} [engine.version] String version of the engine
|
||||
*/
|
||||
this.parsedResult = {};
|
||||
|
||||
if (skipParsing !== true) {
|
||||
this.parse();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get UserAgent string of current Parser instance
|
||||
* @return {String} User-Agent String of the current <Parser> object
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getUA() {
|
||||
return this._ua;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a UA string for a regexp
|
||||
* @param {RegExp} regex
|
||||
* @return {Boolean}
|
||||
*/
|
||||
test(regex) {
|
||||
return regex.test(this._ua);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed browser object
|
||||
* @return {Object}
|
||||
*/
|
||||
parseBrowser() {
|
||||
this.parsedResult.browser = {};
|
||||
|
||||
const browserDescriptor = Utils.find(browserParsersList, (_browser) => {
|
||||
if (typeof _browser.test === 'function') {
|
||||
return _browser.test(this);
|
||||
}
|
||||
|
||||
if (_browser.test instanceof Array) {
|
||||
return _browser.test.some(condition => this.test(condition));
|
||||
}
|
||||
|
||||
throw new Error("Browser's test function is not valid");
|
||||
});
|
||||
|
||||
if (browserDescriptor) {
|
||||
this.parsedResult.browser = browserDescriptor.describe(this.getUA());
|
||||
}
|
||||
|
||||
return this.parsedResult.browser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed browser object
|
||||
* @return {Object}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getBrowser() {
|
||||
if (this.parsedResult.browser) {
|
||||
return this.parsedResult.browser;
|
||||
}
|
||||
|
||||
return this.parseBrowser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get browser's name
|
||||
* @return {String} Browser's name or an empty string
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getBrowserName(toLowerCase) {
|
||||
if (toLowerCase) {
|
||||
return String(this.getBrowser().name).toLowerCase() || '';
|
||||
}
|
||||
return this.getBrowser().name || '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get browser's version
|
||||
* @return {String} version of browser
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getBrowserVersion() {
|
||||
return this.getBrowser().version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OS
|
||||
* @return {Object}
|
||||
*
|
||||
* @example
|
||||
* this.getOS();
|
||||
* {
|
||||
* name: 'macOS',
|
||||
* version: '10.11.12'
|
||||
* }
|
||||
*/
|
||||
getOS() {
|
||||
if (this.parsedResult.os) {
|
||||
return this.parsedResult.os;
|
||||
}
|
||||
|
||||
return this.parseOS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse OS and save it to this.parsedResult.os
|
||||
* @return {*|{}}
|
||||
*/
|
||||
parseOS() {
|
||||
this.parsedResult.os = {};
|
||||
|
||||
const os = Utils.find(osParsersList, (_os) => {
|
||||
if (typeof _os.test === 'function') {
|
||||
return _os.test(this);
|
||||
}
|
||||
|
||||
if (_os.test instanceof Array) {
|
||||
return _os.test.some(condition => this.test(condition));
|
||||
}
|
||||
|
||||
throw new Error("Browser's test function is not valid");
|
||||
});
|
||||
|
||||
if (os) {
|
||||
this.parsedResult.os = os.describe(this.getUA());
|
||||
}
|
||||
|
||||
return this.parsedResult.os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OS name
|
||||
* @param {Boolean} [toLowerCase] return lower-cased value
|
||||
* @return {String} name of the OS — macOS, Windows, Linux, etc.
|
||||
*/
|
||||
getOSName(toLowerCase) {
|
||||
const { name } = this.getOS();
|
||||
|
||||
if (toLowerCase) {
|
||||
return String(name).toLowerCase() || '';
|
||||
}
|
||||
|
||||
return name || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OS version
|
||||
* @return {String} full version with dots ('10.11.12', '5.6', etc)
|
||||
*/
|
||||
getOSVersion() {
|
||||
return this.getOS().version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed platform
|
||||
* @return {{}}
|
||||
*/
|
||||
getPlatform() {
|
||||
if (this.parsedResult.platform) {
|
||||
return this.parsedResult.platform;
|
||||
}
|
||||
|
||||
return this.parsePlatform();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get platform name
|
||||
* @param {Boolean} [toLowerCase=false]
|
||||
* @return {*}
|
||||
*/
|
||||
getPlatformType(toLowerCase = false) {
|
||||
const { type } = this.getPlatform();
|
||||
|
||||
if (toLowerCase) {
|
||||
return String(type).toLowerCase() || '';
|
||||
}
|
||||
|
||||
return type || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed platform
|
||||
* @return {{}}
|
||||
*/
|
||||
parsePlatform() {
|
||||
this.parsedResult.platform = {};
|
||||
|
||||
const platform = Utils.find(platformParsersList, (_platform) => {
|
||||
if (typeof _platform.test === 'function') {
|
||||
return _platform.test(this);
|
||||
}
|
||||
|
||||
if (_platform.test instanceof Array) {
|
||||
return _platform.test.some(condition => this.test(condition));
|
||||
}
|
||||
|
||||
throw new Error("Browser's test function is not valid");
|
||||
});
|
||||
|
||||
if (platform) {
|
||||
this.parsedResult.platform = platform.describe(this.getUA());
|
||||
}
|
||||
|
||||
return this.parsedResult.platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed engine
|
||||
* @return {{}}
|
||||
*/
|
||||
getEngine() {
|
||||
if (this.parsedResult.engine) {
|
||||
return this.parsedResult.engine;
|
||||
}
|
||||
|
||||
return this.parseEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get engines's name
|
||||
* @return {String} Engines's name or an empty string
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getEngineName(toLowerCase) {
|
||||
if (toLowerCase) {
|
||||
return String(this.getEngine().name).toLowerCase() || '';
|
||||
}
|
||||
return this.getEngine().name || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed platform
|
||||
* @return {{}}
|
||||
*/
|
||||
parseEngine() {
|
||||
this.parsedResult.engine = {};
|
||||
|
||||
const engine = Utils.find(enginesParsersList, (_engine) => {
|
||||
if (typeof _engine.test === 'function') {
|
||||
return _engine.test(this);
|
||||
}
|
||||
|
||||
if (_engine.test instanceof Array) {
|
||||
return _engine.test.some(condition => this.test(condition));
|
||||
}
|
||||
|
||||
throw new Error("Browser's test function is not valid");
|
||||
});
|
||||
|
||||
if (engine) {
|
||||
this.parsedResult.engine = engine.describe(this.getUA());
|
||||
}
|
||||
|
||||
return this.parsedResult.engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse full information about the browser
|
||||
* @returns {Parser}
|
||||
*/
|
||||
parse() {
|
||||
this.parseBrowser();
|
||||
this.parseOS();
|
||||
this.parsePlatform();
|
||||
this.parseEngine();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parsed result
|
||||
* @return {ParsedResult}
|
||||
*/
|
||||
getResult() {
|
||||
return Utils.assign({}, this.parsedResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if parsed browser matches certain conditions
|
||||
*
|
||||
* @param {Object} checkTree It's one or two layered object,
|
||||
* which can include a platform or an OS on the first layer
|
||||
* and should have browsers specs on the bottom-laying layer
|
||||
*
|
||||
* @returns {Boolean|undefined} Whether the browser satisfies the set conditions or not.
|
||||
* Returns `undefined` when the browser is no described in the checkTree object.
|
||||
*
|
||||
* @example
|
||||
* const browser = Bowser.getParser(window.navigator.userAgent);
|
||||
* if (browser.satisfies({chrome: '>118.01.1322' }))
|
||||
* // or with os
|
||||
* if (browser.satisfies({windows: { chrome: '>118.01.1322' } }))
|
||||
* // or with platforms
|
||||
* if (browser.satisfies({desktop: { chrome: '>118.01.1322' } }))
|
||||
*/
|
||||
satisfies(checkTree) {
|
||||
const platformsAndOSes = {};
|
||||
let platformsAndOSCounter = 0;
|
||||
const browsers = {};
|
||||
let browsersCounter = 0;
|
||||
|
||||
const allDefinitions = Object.keys(checkTree);
|
||||
|
||||
allDefinitions.forEach((key) => {
|
||||
const currentDefinition = checkTree[key];
|
||||
if (typeof currentDefinition === 'string') {
|
||||
browsers[key] = currentDefinition;
|
||||
browsersCounter += 1;
|
||||
} else if (typeof currentDefinition === 'object') {
|
||||
platformsAndOSes[key] = currentDefinition;
|
||||
platformsAndOSCounter += 1;
|
||||
}
|
||||
});
|
||||
|
||||
if (platformsAndOSCounter > 0) {
|
||||
const platformsAndOSNames = Object.keys(platformsAndOSes);
|
||||
const OSMatchingDefinition = Utils.find(platformsAndOSNames, name => (this.isOS(name)));
|
||||
|
||||
if (OSMatchingDefinition) {
|
||||
const osResult = this.satisfies(platformsAndOSes[OSMatchingDefinition]);
|
||||
|
||||
if (osResult !== void 0) {
|
||||
return osResult;
|
||||
}
|
||||
}
|
||||
|
||||
const platformMatchingDefinition = Utils.find(
|
||||
platformsAndOSNames,
|
||||
name => (this.isPlatform(name)),
|
||||
);
|
||||
if (platformMatchingDefinition) {
|
||||
const platformResult = this.satisfies(platformsAndOSes[platformMatchingDefinition]);
|
||||
|
||||
if (platformResult !== void 0) {
|
||||
return platformResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (browsersCounter > 0) {
|
||||
const browserNames = Object.keys(browsers);
|
||||
const matchingDefinition = Utils.find(browserNames, name => (this.isBrowser(name, true)));
|
||||
|
||||
if (matchingDefinition !== void 0) {
|
||||
return this.compareVersion(browsers[matchingDefinition]);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the browser name equals the passed string
|
||||
* @param browserName The string to compare with the browser name
|
||||
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isBrowser(browserName, includingAlias = false) {
|
||||
const defaultBrowserName = this.getBrowserName().toLowerCase();
|
||||
let browserNameLower = browserName.toLowerCase();
|
||||
const alias = Utils.getBrowserTypeByAlias(browserNameLower);
|
||||
|
||||
if (includingAlias && alias) {
|
||||
browserNameLower = alias.toLowerCase();
|
||||
}
|
||||
return browserNameLower === defaultBrowserName;
|
||||
}
|
||||
|
||||
compareVersion(version) {
|
||||
let expectedResults = [0];
|
||||
let comparableVersion = version;
|
||||
let isLoose = false;
|
||||
|
||||
const currentBrowserVersion = this.getBrowserVersion();
|
||||
|
||||
if (typeof currentBrowserVersion !== 'string') {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
if (version[0] === '>' || version[0] === '<') {
|
||||
comparableVersion = version.substr(1);
|
||||
if (version[1] === '=') {
|
||||
isLoose = true;
|
||||
comparableVersion = version.substr(2);
|
||||
} else {
|
||||
expectedResults = [];
|
||||
}
|
||||
if (version[0] === '>') {
|
||||
expectedResults.push(1);
|
||||
} else {
|
||||
expectedResults.push(-1);
|
||||
}
|
||||
} else if (version[0] === '=') {
|
||||
comparableVersion = version.substr(1);
|
||||
} else if (version[0] === '~') {
|
||||
isLoose = true;
|
||||
comparableVersion = version.substr(1);
|
||||
}
|
||||
|
||||
return expectedResults.indexOf(
|
||||
Utils.compareVersions(currentBrowserVersion, comparableVersion, isLoose),
|
||||
) > -1;
|
||||
}
|
||||
|
||||
isOS(osName) {
|
||||
return this.getOSName(true) === String(osName).toLowerCase();
|
||||
}
|
||||
|
||||
isPlatform(platformType) {
|
||||
return this.getPlatformType(true) === String(platformType).toLowerCase();
|
||||
}
|
||||
|
||||
isEngine(engineName) {
|
||||
return this.getEngineName(true) === String(engineName).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is anything? Check if the browser is called "anything",
|
||||
* the OS called "anything" or the platform called "anything"
|
||||
* @param {String} anything
|
||||
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
is(anything, includingAlias = false) {
|
||||
return this.isBrowser(anything, includingAlias) || this.isOS(anything)
|
||||
|| this.isPlatform(anything);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any of the given values satisfies this.is(anything)
|
||||
* @param {String[]} anythings
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
some(anythings = []) {
|
||||
return anythings.some(anything => this.is(anything));
|
||||
}
|
||||
}
|
||||
|
||||
export default Parser;
|
309
parent_dir/20240530212112Z/node_modules/bowser/src/utils.js
generated
vendored
Normal file
309
parent_dir/20240530212112Z/node_modules/bowser/src/utils.js
generated
vendored
Normal file
@@ -0,0 +1,309 @@
|
||||
import { BROWSER_MAP, BROWSER_ALIASES_MAP } from './constants.js';
|
||||
|
||||
export default class Utils {
|
||||
/**
|
||||
* Get first matched item for a string
|
||||
* @param {RegExp} regexp
|
||||
* @param {String} ua
|
||||
* @return {Array|{index: number, input: string}|*|boolean|string}
|
||||
*/
|
||||
static getFirstMatch(regexp, ua) {
|
||||
const match = ua.match(regexp);
|
||||
return (match && match.length > 0 && match[1]) || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get second matched item for a string
|
||||
* @param regexp
|
||||
* @param {String} ua
|
||||
* @return {Array|{index: number, input: string}|*|boolean|string}
|
||||
*/
|
||||
static getSecondMatch(regexp, ua) {
|
||||
const match = ua.match(regexp);
|
||||
return (match && match.length > 1 && match[2]) || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Match a regexp and return a constant or undefined
|
||||
* @param {RegExp} regexp
|
||||
* @param {String} ua
|
||||
* @param {*} _const Any const that will be returned if regexp matches the string
|
||||
* @return {*}
|
||||
*/
|
||||
static matchAndReturnConst(regexp, ua, _const) {
|
||||
if (regexp.test(ua)) {
|
||||
return _const;
|
||||
}
|
||||
return void (0);
|
||||
}
|
||||
|
||||
static getWindowsVersionName(version) {
|
||||
switch (version) {
|
||||
case 'NT': return 'NT';
|
||||
case 'XP': return 'XP';
|
||||
case 'NT 5.0': return '2000';
|
||||
case 'NT 5.1': return 'XP';
|
||||
case 'NT 5.2': return '2003';
|
||||
case 'NT 6.0': return 'Vista';
|
||||
case 'NT 6.1': return '7';
|
||||
case 'NT 6.2': return '8';
|
||||
case 'NT 6.3': return '8.1';
|
||||
case 'NT 10.0': return '10';
|
||||
default: return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get macOS version name
|
||||
* 10.5 - Leopard
|
||||
* 10.6 - Snow Leopard
|
||||
* 10.7 - Lion
|
||||
* 10.8 - Mountain Lion
|
||||
* 10.9 - Mavericks
|
||||
* 10.10 - Yosemite
|
||||
* 10.11 - El Capitan
|
||||
* 10.12 - Sierra
|
||||
* 10.13 - High Sierra
|
||||
* 10.14 - Mojave
|
||||
* 10.15 - Catalina
|
||||
*
|
||||
* @example
|
||||
* getMacOSVersionName("10.14") // 'Mojave'
|
||||
*
|
||||
* @param {string} version
|
||||
* @return {string} versionName
|
||||
*/
|
||||
static getMacOSVersionName(version) {
|
||||
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
|
||||
v.push(0);
|
||||
if (v[0] !== 10) return undefined;
|
||||
switch (v[1]) {
|
||||
case 5: return 'Leopard';
|
||||
case 6: return 'Snow Leopard';
|
||||
case 7: return 'Lion';
|
||||
case 8: return 'Mountain Lion';
|
||||
case 9: return 'Mavericks';
|
||||
case 10: return 'Yosemite';
|
||||
case 11: return 'El Capitan';
|
||||
case 12: return 'Sierra';
|
||||
case 13: return 'High Sierra';
|
||||
case 14: return 'Mojave';
|
||||
case 15: return 'Catalina';
|
||||
default: return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Android version name
|
||||
* 1.5 - Cupcake
|
||||
* 1.6 - Donut
|
||||
* 2.0 - Eclair
|
||||
* 2.1 - Eclair
|
||||
* 2.2 - Froyo
|
||||
* 2.x - Gingerbread
|
||||
* 3.x - Honeycomb
|
||||
* 4.0 - Ice Cream Sandwich
|
||||
* 4.1 - Jelly Bean
|
||||
* 4.4 - KitKat
|
||||
* 5.x - Lollipop
|
||||
* 6.x - Marshmallow
|
||||
* 7.x - Nougat
|
||||
* 8.x - Oreo
|
||||
* 9.x - Pie
|
||||
*
|
||||
* @example
|
||||
* getAndroidVersionName("7.0") // 'Nougat'
|
||||
*
|
||||
* @param {string} version
|
||||
* @return {string} versionName
|
||||
*/
|
||||
static getAndroidVersionName(version) {
|
||||
const v = version.split('.').splice(0, 2).map(s => parseInt(s, 10) || 0);
|
||||
v.push(0);
|
||||
if (v[0] === 1 && v[1] < 5) return undefined;
|
||||
if (v[0] === 1 && v[1] < 6) return 'Cupcake';
|
||||
if (v[0] === 1 && v[1] >= 6) return 'Donut';
|
||||
if (v[0] === 2 && v[1] < 2) return 'Eclair';
|
||||
if (v[0] === 2 && v[1] === 2) return 'Froyo';
|
||||
if (v[0] === 2 && v[1] > 2) return 'Gingerbread';
|
||||
if (v[0] === 3) return 'Honeycomb';
|
||||
if (v[0] === 4 && v[1] < 1) return 'Ice Cream Sandwich';
|
||||
if (v[0] === 4 && v[1] < 4) return 'Jelly Bean';
|
||||
if (v[0] === 4 && v[1] >= 4) return 'KitKat';
|
||||
if (v[0] === 5) return 'Lollipop';
|
||||
if (v[0] === 6) return 'Marshmallow';
|
||||
if (v[0] === 7) return 'Nougat';
|
||||
if (v[0] === 8) return 'Oreo';
|
||||
if (v[0] === 9) return 'Pie';
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get version precisions count
|
||||
*
|
||||
* @example
|
||||
* getVersionPrecision("1.10.3") // 3
|
||||
*
|
||||
* @param {string} version
|
||||
* @return {number}
|
||||
*/
|
||||
static getVersionPrecision(version) {
|
||||
return version.split('.').length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate browser version weight
|
||||
*
|
||||
* @example
|
||||
* compareVersions('1.10.2.1', '1.8.2.1.90') // 1
|
||||
* compareVersions('1.010.2.1', '1.09.2.1.90'); // 1
|
||||
* compareVersions('1.10.2.1', '1.10.2.1'); // 0
|
||||
* compareVersions('1.10.2.1', '1.0800.2'); // -1
|
||||
* compareVersions('1.10.2.1', '1.10', true); // 0
|
||||
*
|
||||
* @param {String} versionA versions versions to compare
|
||||
* @param {String} versionB versions versions to compare
|
||||
* @param {boolean} [isLoose] enable loose comparison
|
||||
* @return {Number} comparison result: -1 when versionA is lower,
|
||||
* 1 when versionA is bigger, 0 when both equal
|
||||
*/
|
||||
/* eslint consistent-return: 1 */
|
||||
static compareVersions(versionA, versionB, isLoose = false) {
|
||||
// 1) get common precision for both versions, for example for "10.0" and "9" it should be 2
|
||||
const versionAPrecision = Utils.getVersionPrecision(versionA);
|
||||
const versionBPrecision = Utils.getVersionPrecision(versionB);
|
||||
|
||||
let precision = Math.max(versionAPrecision, versionBPrecision);
|
||||
let lastPrecision = 0;
|
||||
|
||||
const chunks = Utils.map([versionA, versionB], (version) => {
|
||||
const delta = precision - Utils.getVersionPrecision(version);
|
||||
|
||||
// 2) "9" -> "9.0" (for precision = 2)
|
||||
const _version = version + new Array(delta + 1).join('.0');
|
||||
|
||||
// 3) "9.0" -> ["000000000"", "000000009"]
|
||||
return Utils.map(_version.split('.'), chunk => new Array(20 - chunk.length).join('0') + chunk).reverse();
|
||||
});
|
||||
|
||||
// adjust precision for loose comparison
|
||||
if (isLoose) {
|
||||
lastPrecision = precision - Math.min(versionAPrecision, versionBPrecision);
|
||||
}
|
||||
|
||||
// iterate in reverse order by reversed chunks array
|
||||
precision -= 1;
|
||||
while (precision >= lastPrecision) {
|
||||
// 4) compare: "000000009" > "000000010" = false (but "9" > "10" = true)
|
||||
if (chunks[0][precision] > chunks[1][precision]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (chunks[0][precision] === chunks[1][precision]) {
|
||||
if (precision === lastPrecision) {
|
||||
// all version chunks are same
|
||||
return 0;
|
||||
}
|
||||
|
||||
precision -= 1;
|
||||
} else if (chunks[0][precision] < chunks[1][precision]) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array::map polyfill
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @param {Function} iterator
|
||||
* @return {Array}
|
||||
*/
|
||||
static map(arr, iterator) {
|
||||
const result = [];
|
||||
let i;
|
||||
if (Array.prototype.map) {
|
||||
return Array.prototype.map.call(arr, iterator);
|
||||
}
|
||||
for (i = 0; i < arr.length; i += 1) {
|
||||
result.push(iterator(arr[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array::find polyfill
|
||||
*
|
||||
* @param {Array} arr
|
||||
* @param {Function} predicate
|
||||
* @return {Array}
|
||||
*/
|
||||
static find(arr, predicate) {
|
||||
let i;
|
||||
let l;
|
||||
if (Array.prototype.find) {
|
||||
return Array.prototype.find.call(arr, predicate);
|
||||
}
|
||||
for (i = 0, l = arr.length; i < l; i += 1) {
|
||||
const value = arr[i];
|
||||
if (predicate(value, i)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object::assign polyfill
|
||||
*
|
||||
* @param {Object} obj
|
||||
* @param {Object} ...objs
|
||||
* @return {Object}
|
||||
*/
|
||||
static assign(obj, ...assigners) {
|
||||
const result = obj;
|
||||
let i;
|
||||
let l;
|
||||
if (Object.assign) {
|
||||
return Object.assign(obj, ...assigners);
|
||||
}
|
||||
for (i = 0, l = assigners.length; i < l; i += 1) {
|
||||
const assigner = assigners[i];
|
||||
if (typeof assigner === 'object' && assigner !== null) {
|
||||
const keys = Object.keys(assigner);
|
||||
keys.forEach((key) => {
|
||||
result[key] = assigner[key];
|
||||
});
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get short version/alias for a browser name
|
||||
*
|
||||
* @example
|
||||
* getBrowserAlias('Microsoft Edge') // edge
|
||||
*
|
||||
* @param {string} browserName
|
||||
* @return {string}
|
||||
*/
|
||||
static getBrowserAlias(browserName) {
|
||||
return BROWSER_ALIASES_MAP[browserName];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get short version/alias for a browser name
|
||||
*
|
||||
* @example
|
||||
* getBrowserAlias('edge') // Microsoft Edge
|
||||
*
|
||||
* @param {string} browserAlias
|
||||
* @return {string}
|
||||
*/
|
||||
static getBrowserTypeByAlias(browserAlias) {
|
||||
return BROWSER_MAP[browserAlias] || '';
|
||||
}
|
||||
}
|
27
parent_dir/20240530212112Z/node_modules/brillout/json-serializer/dist/esm/parse.js
generated
vendored
Normal file
27
parent_dir/20240530212112Z/node_modules/brillout/json-serializer/dist/esm/parse.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
export { parse };
|
||||
import { types } from './types';
|
||||
function parse(str) {
|
||||
// We don't use the reviver option in `JSON.parse(str, reviver)` because it doesn't support `undefined` values
|
||||
const value = JSON.parse(str);
|
||||
return modifier(value);
|
||||
}
|
||||
function modifier(value) {
|
||||
if (typeof value === 'string') {
|
||||
return reviver(value);
|
||||
}
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
Object.entries(value).forEach(([key, val]) => {
|
||||
;
|
||||
value[key] = modifier(val);
|
||||
});
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function reviver(value) {
|
||||
for (const { match, deserialize } of types) {
|
||||
if (match(value)) {
|
||||
return deserialize(value, parse);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
80
parent_dir/20240530212112Z/node_modules/brillout/json-serializer/dist/esm/types.js
generated
vendored
Normal file
80
parent_dir/20240530212112Z/node_modules/brillout/json-serializer/dist/esm/types.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
export { types };
|
||||
const types = [
|
||||
ts({
|
||||
is: (val) => val === undefined,
|
||||
match: (str) => str === '!undefined',
|
||||
serialize: () => '!undefined',
|
||||
deserialize: () => undefined
|
||||
}),
|
||||
ts({
|
||||
is: (val) => val === Infinity,
|
||||
match: (str) => str === '!Infinity',
|
||||
serialize: () => '!Infinity',
|
||||
deserialize: () => Infinity
|
||||
}),
|
||||
ts({
|
||||
is: (val) => val === -Infinity,
|
||||
match: (str) => str === '!-Infinity',
|
||||
serialize: () => '!-Infinity',
|
||||
deserialize: () => -Infinity
|
||||
}),
|
||||
ts({
|
||||
is: (val) => typeof val === 'number' && isNaN(val),
|
||||
match: (str) => str === '!NaN',
|
||||
serialize: () => '!NaN',
|
||||
deserialize: () => NaN
|
||||
}),
|
||||
ts({
|
||||
is: (val) => val instanceof Date,
|
||||
match: (str) => str.startsWith('!Date:'),
|
||||
serialize: (val) => '!Date:' + val.toISOString(),
|
||||
deserialize: (str) => new Date(str.slice('!Date:'.length))
|
||||
}),
|
||||
ts({
|
||||
is: (val) => typeof val === 'bigint',
|
||||
match: (str) => str.startsWith('!BigInt:'),
|
||||
serialize: (val) => '!BigInt:' + val.toString(),
|
||||
deserialize: (str) => {
|
||||
if (typeof BigInt === 'undefined') {
|
||||
throw new Error('Your JavaScript environement does not support BigInt. Consider adding a polyfill.');
|
||||
}
|
||||
return BigInt(str.slice('!BigInt:'.length));
|
||||
}
|
||||
}),
|
||||
ts({
|
||||
is: (val) => val instanceof RegExp,
|
||||
match: (str) => str.startsWith('!RegExp:'),
|
||||
serialize: (val) => '!RegExp:' + val.toString(),
|
||||
deserialize: (str) => {
|
||||
str = str.slice('!RegExp:'.length);
|
||||
// const args: string[] = str.match(/\/(.*?)\/([gimy])?$/)!
|
||||
const args = str.match(/\/(.*)\/(.*)?/);
|
||||
const pattern = args[1];
|
||||
const flags = args[2];
|
||||
return new RegExp(pattern, flags);
|
||||
}
|
||||
}),
|
||||
ts({
|
||||
is: (val) => val instanceof Map,
|
||||
match: (str) => str.startsWith('!Map:'),
|
||||
serialize: (val, serializer) => '!Map:' + serializer(Array.from(val.entries())),
|
||||
deserialize: (str, deserializer) => new Map(deserializer(str.slice('!Map:'.length)))
|
||||
}),
|
||||
ts({
|
||||
is: (val) => val instanceof Set,
|
||||
match: (str) => str.startsWith('!Set:'),
|
||||
serialize: (val, serializer) => '!Set:' + serializer(Array.from(val.values())),
|
||||
deserialize: (str, deserializer) => new Set(deserializer(str.slice('!Set:'.length)))
|
||||
}),
|
||||
// Avoid collisions with the special strings defined above
|
||||
ts({
|
||||
is: (val) => typeof val === 'string' && val.startsWith('!'),
|
||||
match: (str) => str.startsWith('!'),
|
||||
serialize: (val) => '!' + val,
|
||||
deserialize: (str) => str.slice(1)
|
||||
})
|
||||
];
|
||||
// Type check
|
||||
function ts(t) {
|
||||
return t;
|
||||
}
|
7181
parent_dir/20240530212112Z/node_modules/cdek-ui-kit/vue/dist/vue-ui-kit.es.js
generated
vendored
Normal file
7181
parent_dir/20240530212112Z/node_modules/cdek-ui-kit/vue/dist/vue-ui-kit.es.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
133
parent_dir/20240530212112Z/node_modules/deepmerge/dist/cjs.js
generated
vendored
Normal file
133
parent_dir/20240530212112Z/node_modules/deepmerge/dist/cjs.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
'use strict';
|
||||
|
||||
var isMergeableObject = function isMergeableObject(value) {
|
||||
return isNonNullObject(value)
|
||||
&& !isSpecial(value)
|
||||
};
|
||||
|
||||
function isNonNullObject(value) {
|
||||
return !!value && typeof value === 'object'
|
||||
}
|
||||
|
||||
function isSpecial(value) {
|
||||
var stringValue = Object.prototype.toString.call(value);
|
||||
|
||||
return stringValue === '[object RegExp]'
|
||||
|| stringValue === '[object Date]'
|
||||
|| isReactElement(value)
|
||||
}
|
||||
|
||||
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
||||
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
||||
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
||||
|
||||
function isReactElement(value) {
|
||||
return value.$$typeof === REACT_ELEMENT_TYPE
|
||||
}
|
||||
|
||||
function emptyTarget(val) {
|
||||
return Array.isArray(val) ? [] : {}
|
||||
}
|
||||
|
||||
function cloneUnlessOtherwiseSpecified(value, options) {
|
||||
return (options.clone !== false && options.isMergeableObject(value))
|
||||
? deepmerge(emptyTarget(value), value, options)
|
||||
: value
|
||||
}
|
||||
|
||||
function defaultArrayMerge(target, source, options) {
|
||||
return target.concat(source).map(function(element) {
|
||||
return cloneUnlessOtherwiseSpecified(element, options)
|
||||
})
|
||||
}
|
||||
|
||||
function getMergeFunction(key, options) {
|
||||
if (!options.customMerge) {
|
||||
return deepmerge
|
||||
}
|
||||
var customMerge = options.customMerge(key);
|
||||
return typeof customMerge === 'function' ? customMerge : deepmerge
|
||||
}
|
||||
|
||||
function getEnumerableOwnPropertySymbols(target) {
|
||||
return Object.getOwnPropertySymbols
|
||||
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
||||
return Object.propertyIsEnumerable.call(target, symbol)
|
||||
})
|
||||
: []
|
||||
}
|
||||
|
||||
function getKeys(target) {
|
||||
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
||||
}
|
||||
|
||||
function propertyIsOnObject(object, property) {
|
||||
try {
|
||||
return property in object
|
||||
} catch(_) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
||||
function propertyIsUnsafe(target, key) {
|
||||
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
||||
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
||||
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
||||
}
|
||||
|
||||
function mergeObject(target, source, options) {
|
||||
var destination = {};
|
||||
if (options.isMergeableObject(target)) {
|
||||
getKeys(target).forEach(function(key) {
|
||||
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
||||
});
|
||||
}
|
||||
getKeys(source).forEach(function(key) {
|
||||
if (propertyIsUnsafe(target, key)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
||||
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
||||
} else {
|
||||
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
||||
}
|
||||
});
|
||||
return destination
|
||||
}
|
||||
|
||||
function deepmerge(target, source, options) {
|
||||
options = options || {};
|
||||
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
||||
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
||||
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
||||
// implementations can use it. The caller may not replace it.
|
||||
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
||||
|
||||
var sourceIsArray = Array.isArray(source);
|
||||
var targetIsArray = Array.isArray(target);
|
||||
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
||||
|
||||
if (!sourceAndTargetTypesMatch) {
|
||||
return cloneUnlessOtherwiseSpecified(source, options)
|
||||
} else if (sourceIsArray) {
|
||||
return options.arrayMerge(target, source, options)
|
||||
} else {
|
||||
return mergeObject(target, source, options)
|
||||
}
|
||||
}
|
||||
|
||||
deepmerge.all = function deepmergeAll(array, options) {
|
||||
if (!Array.isArray(array)) {
|
||||
throw new Error('first argument should be an array')
|
||||
}
|
||||
|
||||
return array.reduce(function(prev, next) {
|
||||
return deepmerge(prev, next, options)
|
||||
}, {})
|
||||
};
|
||||
|
||||
var deepmerge_1 = deepmerge;
|
||||
|
||||
module.exports = deepmerge_1;
|
1029
parent_dir/20240530212112Z/node_modules/floating-ui/core/dist/floating-ui.core.esm.js
generated
vendored
Normal file
1029
parent_dir/20240530212112Z/node_modules/floating-ui/core/dist/floating-ui.core.esm.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
488
parent_dir/20240530212112Z/node_modules/floating-ui/dom/dist/floating-ui.dom.esm.js
generated
vendored
Normal file
488
parent_dir/20240530212112Z/node_modules/floating-ui/dom/dist/floating-ui.dom.esm.js
generated
vendored
Normal file
@@ -0,0 +1,488 @@
|
||||
import { rectToClientRect, computePosition as computePosition$1 } from '@floating-ui/core';
|
||||
export { arrow, autoPlacement, detectOverflow, flip, hide, inline, limitShift, offset, shift, size } from '@floating-ui/core';
|
||||
|
||||
function isWindow(value) {
|
||||
return (value == null ? void 0 : value.toString()) === '[object Window]';
|
||||
}
|
||||
function getWindow(node) {
|
||||
if (node == null) {
|
||||
return window;
|
||||
}
|
||||
|
||||
if (!isWindow(node)) {
|
||||
const ownerDocument = node.ownerDocument;
|
||||
return ownerDocument ? ownerDocument.defaultView || window : window;
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function getComputedStyle$1(element) {
|
||||
return getWindow(element).getComputedStyle(element);
|
||||
}
|
||||
|
||||
function getNodeName(node) {
|
||||
return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
|
||||
}
|
||||
|
||||
function isHTMLElement(value) {
|
||||
return value instanceof getWindow(value).HTMLElement;
|
||||
}
|
||||
function isElement(value) {
|
||||
return value instanceof getWindow(value).Element;
|
||||
}
|
||||
function isNode(value) {
|
||||
return value instanceof getWindow(value).Node;
|
||||
}
|
||||
function isShadowRoot(node) {
|
||||
const OwnElement = getWindow(node).ShadowRoot;
|
||||
return node instanceof OwnElement || node instanceof ShadowRoot;
|
||||
}
|
||||
function isScrollParent(element) {
|
||||
// Firefox wants us to check `-x` and `-y` variations as well
|
||||
const {
|
||||
overflow,
|
||||
overflowX,
|
||||
overflowY
|
||||
} = getComputedStyle$1(element);
|
||||
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
||||
}
|
||||
function isTableElement(element) {
|
||||
return ['table', 'td', 'th'].includes(getNodeName(element));
|
||||
}
|
||||
function isContainingBlock(element) {
|
||||
// TODO: Try and use feature detection here instead
|
||||
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
||||
const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
|
||||
// create a containing block.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
||||
|
||||
return css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
|
||||
}
|
||||
|
||||
const min = Math.min;
|
||||
const max = Math.max;
|
||||
const round = Math.round;
|
||||
|
||||
function getBoundingClientRect(element, includeScale) {
|
||||
if (includeScale === void 0) {
|
||||
includeScale = false;
|
||||
}
|
||||
|
||||
const clientRect = element.getBoundingClientRect();
|
||||
let scaleX = 1;
|
||||
let scaleY = 1;
|
||||
|
||||
if (includeScale && isHTMLElement(element)) {
|
||||
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
||||
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
||||
}
|
||||
|
||||
return {
|
||||
width: clientRect.width / scaleX,
|
||||
height: clientRect.height / scaleY,
|
||||
top: clientRect.top / scaleY,
|
||||
right: clientRect.right / scaleX,
|
||||
bottom: clientRect.bottom / scaleY,
|
||||
left: clientRect.left / scaleX,
|
||||
x: clientRect.left / scaleX,
|
||||
y: clientRect.top / scaleY
|
||||
};
|
||||
}
|
||||
|
||||
function getDocumentElement(node) {
|
||||
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
||||
}
|
||||
|
||||
function getNodeScroll(element) {
|
||||
if (isWindow(element)) {
|
||||
return {
|
||||
scrollLeft: element.pageXOffset,
|
||||
scrollTop: element.pageYOffset
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
scrollLeft: element.scrollLeft,
|
||||
scrollTop: element.scrollTop
|
||||
};
|
||||
}
|
||||
|
||||
function getWindowScrollBarX(element) {
|
||||
// If <html> has a CSS width greater than the viewport, then this will be
|
||||
// incorrect for RTL.
|
||||
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
||||
}
|
||||
|
||||
function isScaled(element) {
|
||||
const rect = getBoundingClientRect(element);
|
||||
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
||||
}
|
||||
|
||||
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent));
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
const offsets = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
||||
if (getNodeName(offsetParent) !== 'body' || isScrollParent(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
|
||||
if (isHTMLElement(offsetParent)) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent, true);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
} else if (documentElement) {
|
||||
offsets.x = getWindowScrollBarX(documentElement);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
x: rect.left + scroll.scrollLeft - offsets.x,
|
||||
y: rect.top + scroll.scrollTop - offsets.y,
|
||||
width: rect.width,
|
||||
height: rect.height
|
||||
};
|
||||
}
|
||||
|
||||
function getParentNode(node) {
|
||||
if (getNodeName(node) === 'html') {
|
||||
return node;
|
||||
}
|
||||
|
||||
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
||||
// @ts-ignore
|
||||
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
||||
node.parentNode || ( // DOM Element detected
|
||||
isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
|
||||
getDocumentElement(node) // fallback
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
function getTrueOffsetParent(element) {
|
||||
if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return element.offsetParent;
|
||||
}
|
||||
|
||||
function getContainingBlock(element) {
|
||||
let currentNode = getParentNode(element);
|
||||
|
||||
while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
|
||||
if (isContainingBlock(currentNode)) {
|
||||
return currentNode;
|
||||
} else {
|
||||
currentNode = currentNode.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
||||
// such as table ancestors and cross browser bugs.
|
||||
|
||||
|
||||
function getOffsetParent(element) {
|
||||
const window = getWindow(element);
|
||||
let offsetParent = getTrueOffsetParent(element);
|
||||
|
||||
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
||||
offsetParent = getTrueOffsetParent(offsetParent);
|
||||
}
|
||||
|
||||
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
|
||||
return window;
|
||||
}
|
||||
|
||||
return offsetParent || getContainingBlock(element) || window;
|
||||
}
|
||||
|
||||
function getDimensions(element) {
|
||||
return {
|
||||
width: element.offsetWidth,
|
||||
height: element.offsetHeight
|
||||
};
|
||||
}
|
||||
|
||||
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
||||
let {
|
||||
rect,
|
||||
offsetParent,
|
||||
strategy
|
||||
} = _ref;
|
||||
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
||||
const documentElement = getDocumentElement(offsetParent);
|
||||
|
||||
if (offsetParent === documentElement) {
|
||||
return rect;
|
||||
}
|
||||
|
||||
let scroll = {
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
};
|
||||
const offsets = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
|
||||
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
|
||||
if (getNodeName(offsetParent) !== 'body' || isScrollParent(documentElement)) {
|
||||
scroll = getNodeScroll(offsetParent);
|
||||
}
|
||||
|
||||
if (isHTMLElement(offsetParent)) {
|
||||
const offsetRect = getBoundingClientRect(offsetParent, true);
|
||||
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
||||
offsets.y = offsetRect.y + offsetParent.clientTop;
|
||||
} // This doesn't appear to be need to be negated.
|
||||
// else if (documentElement) {
|
||||
// offsets.x = getWindowScrollBarX(documentElement);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
return { ...rect,
|
||||
x: rect.x - scroll.scrollLeft + offsets.x,
|
||||
y: rect.y - scroll.scrollTop + offsets.y
|
||||
};
|
||||
}
|
||||
|
||||
function getViewportRect(element) {
|
||||
const win = getWindow(element);
|
||||
const html = getDocumentElement(element);
|
||||
const visualViewport = win.visualViewport;
|
||||
let width = html.clientWidth;
|
||||
let height = html.clientHeight;
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
|
||||
if (visualViewport) {
|
||||
width = visualViewport.width;
|
||||
height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
|
||||
// In Chrome, it returns a value very close to 0 (+/-) but contains rounding
|
||||
// errors due to floating point numbers, so we need to check precision.
|
||||
// Safari returns a number <= 0, usually < -1 when pinch-zoomed
|
||||
|
||||
if (Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) < 0.01) {
|
||||
x = visualViewport.offsetLeft;
|
||||
y = visualViewport.offsetTop;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
||||
|
||||
function getDocumentRect(element) {
|
||||
var _element$ownerDocumen;
|
||||
|
||||
const html = getDocumentElement(element);
|
||||
const scroll = getNodeScroll(element);
|
||||
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
||||
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
||||
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
||||
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
||||
const y = -scroll.scrollTop;
|
||||
|
||||
if (getComputedStyle$1(body || html).direction === 'rtl') {
|
||||
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
||||
}
|
||||
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y
|
||||
};
|
||||
}
|
||||
|
||||
function getScrollParent(node) {
|
||||
if (['html', 'body', '#document'].includes(getNodeName(node))) {
|
||||
// @ts-ignore assume body is always available
|
||||
return node.ownerDocument.body;
|
||||
}
|
||||
|
||||
if (isHTMLElement(node) && isScrollParent(node)) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return getScrollParent(getParentNode(node));
|
||||
}
|
||||
|
||||
function getScrollParents(node, list) {
|
||||
var _node$ownerDocument;
|
||||
|
||||
if (list === void 0) {
|
||||
list = [];
|
||||
}
|
||||
|
||||
const scrollParent = getScrollParent(node);
|
||||
const isBody = scrollParent === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
||||
const win = getWindow(scrollParent);
|
||||
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
||||
const updatedList = list.concat(target);
|
||||
return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
|
||||
updatedList.concat(getScrollParents(getParentNode(target)));
|
||||
}
|
||||
|
||||
function contains(parent, child) {
|
||||
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
|
||||
|
||||
if (parent.contains(child)) {
|
||||
return true;
|
||||
} // then fallback to custom implementation with Shadow DOM support
|
||||
else if (rootNode && isShadowRoot(rootNode)) {
|
||||
let next = child;
|
||||
|
||||
do {
|
||||
// use `===` replace node.isSameNode()
|
||||
if (next && parent === next) {
|
||||
return true;
|
||||
} // @ts-ignore: need a better way to handle this...
|
||||
|
||||
|
||||
next = next.parentNode || next.host;
|
||||
} while (next);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getInnerBoundingClientRect(element) {
|
||||
const clientRect = getBoundingClientRect(element);
|
||||
const top = clientRect.top + element.clientTop;
|
||||
const left = clientRect.left + element.clientLeft;
|
||||
return {
|
||||
top,
|
||||
left,
|
||||
x: left,
|
||||
y: top,
|
||||
right: left + element.clientWidth,
|
||||
bottom: top + element.clientHeight,
|
||||
width: element.clientWidth,
|
||||
height: element.clientHeight
|
||||
};
|
||||
}
|
||||
|
||||
function getClientRectFromClippingParent(element, clippingParent) {
|
||||
if (clippingParent === 'viewport') {
|
||||
return rectToClientRect(getViewportRect(element));
|
||||
}
|
||||
|
||||
if (isElement(clippingParent)) {
|
||||
return getInnerBoundingClientRect(clippingParent);
|
||||
}
|
||||
|
||||
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
||||
} // A "clipping parent" is an overflowable container with the characteristic of
|
||||
// clipping (or hiding) overflowing elements with a position different from
|
||||
// `initial`
|
||||
|
||||
|
||||
function getClippingParents(element) {
|
||||
const clippingParents = getScrollParents(getParentNode(element));
|
||||
const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
|
||||
const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
||||
|
||||
if (!isElement(clipperElement)) {
|
||||
return [];
|
||||
} // @ts-ignore isElement check ensures we return Array<Element>
|
||||
|
||||
|
||||
return clippingParents.filter(clippingParent => isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body');
|
||||
} // Gets the maximum area that the element is visible in due to any number of
|
||||
// clipping parents
|
||||
|
||||
|
||||
function getClippingClientRect(_ref) {
|
||||
let {
|
||||
element,
|
||||
boundary,
|
||||
rootBoundary
|
||||
} = _ref;
|
||||
const mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
||||
const clippingParents = [...mainClippingParents, rootBoundary];
|
||||
const firstClippingParent = clippingParents[0];
|
||||
const clippingRect = clippingParents.reduce((accRect, clippingParent) => {
|
||||
const rect = getClientRectFromClippingParent(element, clippingParent);
|
||||
accRect.top = max(rect.top, accRect.top);
|
||||
accRect.right = min(rect.right, accRect.right);
|
||||
accRect.bottom = min(rect.bottom, accRect.bottom);
|
||||
accRect.left = max(rect.left, accRect.left);
|
||||
return accRect;
|
||||
}, getClientRectFromClippingParent(element, firstClippingParent));
|
||||
clippingRect.width = clippingRect.right - clippingRect.left;
|
||||
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
||||
clippingRect.x = clippingRect.left;
|
||||
clippingRect.y = clippingRect.top;
|
||||
return clippingRect;
|
||||
}
|
||||
|
||||
const platform = {
|
||||
getElementRects: _ref => {
|
||||
let {
|
||||
reference,
|
||||
floating,
|
||||
strategy
|
||||
} = _ref;
|
||||
return {
|
||||
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
||||
floating: { ...getDimensions(floating),
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
convertOffsetParentRelativeRectToViewportRelativeRect: args => convertOffsetParentRelativeRectToViewportRelativeRect(args),
|
||||
getOffsetParent: _ref2 => {
|
||||
let {
|
||||
element
|
||||
} = _ref2;
|
||||
return getOffsetParent(element);
|
||||
},
|
||||
isElement: value => isElement(value),
|
||||
getDocumentElement: _ref3 => {
|
||||
let {
|
||||
element
|
||||
} = _ref3;
|
||||
return getDocumentElement(element);
|
||||
},
|
||||
getClippingClientRect: args => getClippingClientRect(args),
|
||||
getDimensions: _ref4 => {
|
||||
let {
|
||||
element
|
||||
} = _ref4;
|
||||
return getDimensions(element);
|
||||
},
|
||||
getClientRects: _ref5 => {
|
||||
let {
|
||||
element
|
||||
} = _ref5;
|
||||
return element.getClientRects();
|
||||
}
|
||||
};
|
||||
|
||||
const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
|
||||
platform,
|
||||
...options
|
||||
});
|
||||
|
||||
export { computePosition, getScrollParents };
|
1833
parent_dir/20240530212112Z/node_modules/floating-vue/dist/floating-vue.es.js
generated
vendored
Normal file
1833
parent_dir/20240530212112Z/node_modules/floating-vue/dist/floating-vue.es.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
290
parent_dir/20240530212112Z/node_modules/hookable/dist/index.mjs
generated
vendored
Normal file
290
parent_dir/20240530212112Z/node_modules/hookable/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
function flatHooks(configHooks, hooks = {}, parentName) {
|
||||
for (const key in configHooks) {
|
||||
const subHook = configHooks[key];
|
||||
const name = parentName ? `${parentName}:${key}` : key;
|
||||
if (typeof subHook === "object" && subHook !== null) {
|
||||
flatHooks(subHook, hooks, name);
|
||||
} else if (typeof subHook === "function") {
|
||||
hooks[name] = subHook;
|
||||
}
|
||||
}
|
||||
return hooks;
|
||||
}
|
||||
function mergeHooks(...hooks) {
|
||||
const finalHooks = {};
|
||||
for (const hook of hooks) {
|
||||
const flatenHook = flatHooks(hook);
|
||||
for (const key in flatenHook) {
|
||||
if (finalHooks[key]) {
|
||||
finalHooks[key].push(flatenHook[key]);
|
||||
} else {
|
||||
finalHooks[key] = [flatenHook[key]];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const key in finalHooks) {
|
||||
if (finalHooks[key].length > 1) {
|
||||
const array = finalHooks[key];
|
||||
finalHooks[key] = (...arguments_) => serial(array, (function_) => function_(...arguments_));
|
||||
} else {
|
||||
finalHooks[key] = finalHooks[key][0];
|
||||
}
|
||||
}
|
||||
return finalHooks;
|
||||
}
|
||||
function serial(tasks, function_) {
|
||||
return tasks.reduce(
|
||||
(promise, task) => promise.then(() => function_(task)),
|
||||
Promise.resolve()
|
||||
);
|
||||
}
|
||||
const defaultTask = { run: (function_) => function_() };
|
||||
const _createTask = () => defaultTask;
|
||||
const createTask = typeof console.createTask !== "undefined" ? console.createTask : _createTask;
|
||||
function serialTaskCaller(hooks, args) {
|
||||
const name = args.shift();
|
||||
const task = createTask(name);
|
||||
return hooks.reduce(
|
||||
(promise, hookFunction) => promise.then(() => task.run(() => hookFunction(...args))),
|
||||
Promise.resolve()
|
||||
);
|
||||
}
|
||||
function parallelTaskCaller(hooks, args) {
|
||||
const name = args.shift();
|
||||
const task = createTask(name);
|
||||
return Promise.all(hooks.map((hook) => task.run(() => hook(...args))));
|
||||
}
|
||||
function serialCaller(hooks, arguments_) {
|
||||
return hooks.reduce(
|
||||
(promise, hookFunction) => promise.then(() => hookFunction(...arguments_ || [])),
|
||||
Promise.resolve()
|
||||
);
|
||||
}
|
||||
function parallelCaller(hooks, args) {
|
||||
return Promise.all(hooks.map((hook) => hook(...args || [])));
|
||||
}
|
||||
function callEachWith(callbacks, arg0) {
|
||||
for (const callback of [...callbacks]) {
|
||||
callback(arg0);
|
||||
}
|
||||
}
|
||||
|
||||
class Hookable {
|
||||
constructor() {
|
||||
this._hooks = {};
|
||||
this._before = void 0;
|
||||
this._after = void 0;
|
||||
this._deprecatedMessages = void 0;
|
||||
this._deprecatedHooks = {};
|
||||
this.hook = this.hook.bind(this);
|
||||
this.callHook = this.callHook.bind(this);
|
||||
this.callHookWith = this.callHookWith.bind(this);
|
||||
}
|
||||
hook(name, function_, options = {}) {
|
||||
if (!name || typeof function_ !== "function") {
|
||||
return () => {
|
||||
};
|
||||
}
|
||||
const originalName = name;
|
||||
let dep;
|
||||
while (this._deprecatedHooks[name]) {
|
||||
dep = this._deprecatedHooks[name];
|
||||
name = dep.to;
|
||||
}
|
||||
if (dep && !options.allowDeprecated) {
|
||||
let message = dep.message;
|
||||
if (!message) {
|
||||
message = `${originalName} hook has been deprecated` + (dep.to ? `, please use ${dep.to}` : "");
|
||||
}
|
||||
if (!this._deprecatedMessages) {
|
||||
this._deprecatedMessages = /* @__PURE__ */ new Set();
|
||||
}
|
||||
if (!this._deprecatedMessages.has(message)) {
|
||||
console.warn(message);
|
||||
this._deprecatedMessages.add(message);
|
||||
}
|
||||
}
|
||||
if (!function_.name) {
|
||||
try {
|
||||
Object.defineProperty(function_, "name", {
|
||||
get: () => "_" + name.replace(/\W+/g, "_") + "_hook_cb",
|
||||
configurable: true
|
||||
});
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
this._hooks[name] = this._hooks[name] || [];
|
||||
this._hooks[name].push(function_);
|
||||
return () => {
|
||||
if (function_) {
|
||||
this.removeHook(name, function_);
|
||||
function_ = void 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
hookOnce(name, function_) {
|
||||
let _unreg;
|
||||
let _function = (...arguments_) => {
|
||||
if (typeof _unreg === "function") {
|
||||
_unreg();
|
||||
}
|
||||
_unreg = void 0;
|
||||
_function = void 0;
|
||||
return function_(...arguments_);
|
||||
};
|
||||
_unreg = this.hook(name, _function);
|
||||
return _unreg;
|
||||
}
|
||||
removeHook(name, function_) {
|
||||
if (this._hooks[name]) {
|
||||
const index = this._hooks[name].indexOf(function_);
|
||||
if (index !== -1) {
|
||||
this._hooks[name].splice(index, 1);
|
||||
}
|
||||
if (this._hooks[name].length === 0) {
|
||||
delete this._hooks[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
deprecateHook(name, deprecated) {
|
||||
this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
|
||||
const _hooks = this._hooks[name] || [];
|
||||
delete this._hooks[name];
|
||||
for (const hook of _hooks) {
|
||||
this.hook(name, hook);
|
||||
}
|
||||
}
|
||||
deprecateHooks(deprecatedHooks) {
|
||||
Object.assign(this._deprecatedHooks, deprecatedHooks);
|
||||
for (const name in deprecatedHooks) {
|
||||
this.deprecateHook(name, deprecatedHooks[name]);
|
||||
}
|
||||
}
|
||||
addHooks(configHooks) {
|
||||
const hooks = flatHooks(configHooks);
|
||||
const removeFns = Object.keys(hooks).map(
|
||||
(key) => this.hook(key, hooks[key])
|
||||
);
|
||||
return () => {
|
||||
for (const unreg of removeFns.splice(0, removeFns.length)) {
|
||||
unreg();
|
||||
}
|
||||
};
|
||||
}
|
||||
removeHooks(configHooks) {
|
||||
const hooks = flatHooks(configHooks);
|
||||
for (const key in hooks) {
|
||||
this.removeHook(key, hooks[key]);
|
||||
}
|
||||
}
|
||||
removeAllHooks() {
|
||||
for (const key in this._hooks) {
|
||||
delete this._hooks[key];
|
||||
}
|
||||
}
|
||||
callHook(name, ...arguments_) {
|
||||
arguments_.unshift(name);
|
||||
return this.callHookWith(serialTaskCaller, name, ...arguments_);
|
||||
}
|
||||
callHookParallel(name, ...arguments_) {
|
||||
arguments_.unshift(name);
|
||||
return this.callHookWith(parallelTaskCaller, name, ...arguments_);
|
||||
}
|
||||
callHookWith(caller, name, ...arguments_) {
|
||||
const event = this._before || this._after ? { name, args: arguments_, context: {} } : void 0;
|
||||
if (this._before) {
|
||||
callEachWith(this._before, event);
|
||||
}
|
||||
const result = caller(
|
||||
name in this._hooks ? [...this._hooks[name]] : [],
|
||||
arguments_
|
||||
);
|
||||
if (result instanceof Promise) {
|
||||
return result.finally(() => {
|
||||
if (this._after && event) {
|
||||
callEachWith(this._after, event);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this._after && event) {
|
||||
callEachWith(this._after, event);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
beforeEach(function_) {
|
||||
this._before = this._before || [];
|
||||
this._before.push(function_);
|
||||
return () => {
|
||||
if (this._before !== void 0) {
|
||||
const index = this._before.indexOf(function_);
|
||||
if (index !== -1) {
|
||||
this._before.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
afterEach(function_) {
|
||||
this._after = this._after || [];
|
||||
this._after.push(function_);
|
||||
return () => {
|
||||
if (this._after !== void 0) {
|
||||
const index = this._after.indexOf(function_);
|
||||
if (index !== -1) {
|
||||
this._after.splice(index, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
function createHooks() {
|
||||
return new Hookable();
|
||||
}
|
||||
|
||||
const isBrowser = typeof window !== "undefined";
|
||||
function createDebugger(hooks, _options = {}) {
|
||||
const options = {
|
||||
inspect: isBrowser,
|
||||
group: isBrowser,
|
||||
filter: () => true,
|
||||
..._options
|
||||
};
|
||||
const _filter = options.filter;
|
||||
const filter = typeof _filter === "string" ? (name) => name.startsWith(_filter) : _filter;
|
||||
const _tag = options.tag ? `[${options.tag}] ` : "";
|
||||
const logPrefix = (event) => _tag + event.name + "".padEnd(event._id, "\0");
|
||||
const _idCtr = {};
|
||||
const unsubscribeBefore = hooks.beforeEach((event) => {
|
||||
if (filter !== void 0 && !filter(event.name)) {
|
||||
return;
|
||||
}
|
||||
_idCtr[event.name] = _idCtr[event.name] || 0;
|
||||
event._id = _idCtr[event.name]++;
|
||||
console.time(logPrefix(event));
|
||||
});
|
||||
const unsubscribeAfter = hooks.afterEach((event) => {
|
||||
if (filter !== void 0 && !filter(event.name)) {
|
||||
return;
|
||||
}
|
||||
if (options.group) {
|
||||
console.groupCollapsed(event.name);
|
||||
}
|
||||
if (options.inspect) {
|
||||
console.timeLog(logPrefix(event), event.args);
|
||||
} else {
|
||||
console.timeEnd(logPrefix(event));
|
||||
}
|
||||
if (options.group) {
|
||||
console.groupEnd();
|
||||
}
|
||||
_idCtr[event.name]--;
|
||||
});
|
||||
return {
|
||||
/** Stop debugging and remove listeners */
|
||||
close: () => {
|
||||
unsubscribeBefore();
|
||||
unsubscribeAfter();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { Hookable, createDebugger, createHooks, flatHooks, mergeHooks, parallelCaller, serial, serialCaller };
|
1573
parent_dir/20240530212112Z/node_modules/intlify/core-base/dist/core-base.esm-bundler.js
generated
vendored
Normal file
1573
parent_dir/20240530212112Z/node_modules/intlify/core-base/dist/core-base.esm-bundler.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11
parent_dir/20240530212112Z/node_modules/intlify/devtools-if/dist/devtools-if.esm-bundler.js
generated
vendored
Normal file
11
parent_dir/20240530212112Z/node_modules/intlify/devtools-if/dist/devtools-if.esm-bundler.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* devtools-if v9.2.2
|
||||
* (c) 2022 kazuya kawaguchi
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
const IntlifyDevToolsHooks = {
|
||||
I18nInit: 'i18n:init',
|
||||
FunctionTranslate: 'function:translate'
|
||||
};
|
||||
|
||||
export { IntlifyDevToolsHooks };
|
1372
parent_dir/20240530212112Z/node_modules/intlify/message-compiler/dist/message-compiler.esm-bundler.js
generated
vendored
Normal file
1372
parent_dir/20240530212112Z/node_modules/intlify/message-compiler/dist/message-compiler.esm-bundler.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
192
parent_dir/20240530212112Z/node_modules/intlify/shared/dist/shared.esm-bundler.js
generated
vendored
Normal file
192
parent_dir/20240530212112Z/node_modules/intlify/shared/dist/shared.esm-bundler.js
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
/*!
|
||||
* shared v9.2.2
|
||||
* (c) 2022 kazuya kawaguchi
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
/**
|
||||
* Original Utilities
|
||||
* written by kazuya kawaguchi
|
||||
*/
|
||||
const inBrowser = typeof window !== 'undefined';
|
||||
let mark;
|
||||
let measure;
|
||||
if ((process.env.NODE_ENV !== 'production')) {
|
||||
const perf = inBrowser && window.performance;
|
||||
if (perf &&
|
||||
perf.mark &&
|
||||
perf.measure &&
|
||||
perf.clearMarks &&
|
||||
perf.clearMeasures) {
|
||||
mark = (tag) => perf.mark(tag);
|
||||
measure = (name, startTag, endTag) => {
|
||||
perf.measure(name, startTag, endTag);
|
||||
perf.clearMarks(startTag);
|
||||
perf.clearMarks(endTag);
|
||||
};
|
||||
}
|
||||
}
|
||||
const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g;
|
||||
/* eslint-disable */
|
||||
function format(message, ...args) {
|
||||
if (args.length === 1 && isObject(args[0])) {
|
||||
args = args[0];
|
||||
}
|
||||
if (!args || !args.hasOwnProperty) {
|
||||
args = {};
|
||||
}
|
||||
return message.replace(RE_ARGS, (match, identifier) => {
|
||||
return args.hasOwnProperty(identifier) ? args[identifier] : '';
|
||||
});
|
||||
}
|
||||
const hasSymbol = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
|
||||
const makeSymbol = (name) => hasSymbol ? Symbol(name) : name;
|
||||
const generateFormatCacheKey = (locale, key, source) => friendlyJSONstringify({ l: locale, k: key, s: source });
|
||||
const friendlyJSONstringify = (json) => JSON.stringify(json)
|
||||
.replace(/\u2028/g, '\\u2028')
|
||||
.replace(/\u2029/g, '\\u2029')
|
||||
.replace(/\u0027/g, '\\u0027');
|
||||
const isNumber = (val) => typeof val === 'number' && isFinite(val);
|
||||
const isDate = (val) => toTypeString(val) === '[object Date]';
|
||||
const isRegExp = (val) => toTypeString(val) === '[object RegExp]';
|
||||
const isEmptyObject = (val) => isPlainObject(val) && Object.keys(val).length === 0;
|
||||
function warn(msg, err) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console.warn(`[intlify] ` + msg);
|
||||
/* istanbul ignore if */
|
||||
if (err) {
|
||||
console.warn(err.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
const assign = Object.assign;
|
||||
let _globalThis;
|
||||
const getGlobalThis = () => {
|
||||
// prettier-ignore
|
||||
return (_globalThis ||
|
||||
(_globalThis =
|
||||
typeof globalThis !== 'undefined'
|
||||
? globalThis
|
||||
: typeof self !== 'undefined'
|
||||
? self
|
||||
: typeof window !== 'undefined'
|
||||
? window
|
||||
: typeof global !== 'undefined'
|
||||
? global
|
||||
: {}));
|
||||
};
|
||||
function escapeHtml(rawText) {
|
||||
return rawText
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
function hasOwn(obj, key) {
|
||||
return hasOwnProperty.call(obj, key);
|
||||
}
|
||||
/* eslint-enable */
|
||||
/**
|
||||
* Useful Utilities By Evan you
|
||||
* Modified by kazuya kawaguchi
|
||||
* MIT License
|
||||
* https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts
|
||||
* https://github.com/vuejs/vue-next/blob/master/packages/shared/src/codeframe.ts
|
||||
*/
|
||||
const isArray = Array.isArray;
|
||||
const isFunction = (val) => typeof val === 'function';
|
||||
const isString = (val) => typeof val === 'string';
|
||||
const isBoolean = (val) => typeof val === 'boolean';
|
||||
const isSymbol = (val) => typeof val === 'symbol';
|
||||
const isObject = (val) => // eslint-disable-line
|
||||
val !== null && typeof val === 'object';
|
||||
const isPromise = (val) => {
|
||||
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
||||
};
|
||||
const objectToString = Object.prototype.toString;
|
||||
const toTypeString = (value) => objectToString.call(value);
|
||||
const isPlainObject = (val) => toTypeString(val) === '[object Object]';
|
||||
// for converting list and named values to displayed strings.
|
||||
const toDisplayString = (val) => {
|
||||
return val == null
|
||||
? ''
|
||||
: isArray(val) || (isPlainObject(val) && val.toString === objectToString)
|
||||
? JSON.stringify(val, null, 2)
|
||||
: String(val);
|
||||
};
|
||||
const RANGE = 2;
|
||||
function generateCodeFrame(source, start = 0, end = source.length) {
|
||||
const lines = source.split(/\r?\n/);
|
||||
let count = 0;
|
||||
const res = [];
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
count += lines[i].length + 1;
|
||||
if (count >= start) {
|
||||
for (let j = i - RANGE; j <= i + RANGE || end > count; j++) {
|
||||
if (j < 0 || j >= lines.length)
|
||||
continue;
|
||||
const line = j + 1;
|
||||
res.push(`${line}${' '.repeat(3 - String(line).length)}| ${lines[j]}`);
|
||||
const lineLength = lines[j].length;
|
||||
if (j === i) {
|
||||
// push underline
|
||||
const pad = start - (count - lineLength) + 1;
|
||||
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
||||
res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
||||
}
|
||||
else if (j > i) {
|
||||
if (end > count) {
|
||||
const length = Math.max(Math.min(end - count, lineLength), 1);
|
||||
res.push(` | ` + '^'.repeat(length));
|
||||
}
|
||||
count += lineLength + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Event emitter, forked from the below:
|
||||
* - original repository url: https://github.com/developit/mitt
|
||||
* - code url: https://github.com/developit/mitt/blob/master/src/index.ts
|
||||
* - author: Jason Miller (https://github.com/developit)
|
||||
* - license: MIT
|
||||
*/
|
||||
/**
|
||||
* Create a event emitter
|
||||
*
|
||||
* @returns An event emitter
|
||||
*/
|
||||
function createEmitter() {
|
||||
const events = new Map();
|
||||
const emitter = {
|
||||
events,
|
||||
on(event, handler) {
|
||||
const handlers = events.get(event);
|
||||
const added = handlers && handlers.push(handler);
|
||||
if (!added) {
|
||||
events.set(event, [handler]);
|
||||
}
|
||||
},
|
||||
off(event, handler) {
|
||||
const handlers = events.get(event);
|
||||
if (handlers) {
|
||||
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
|
||||
}
|
||||
},
|
||||
emit(event, payload) {
|
||||
(events.get(event) || [])
|
||||
.slice()
|
||||
.map(handler => handler(payload));
|
||||
(events.get('*') || [])
|
||||
.slice()
|
||||
.map(handler => handler(event, payload));
|
||||
}
|
||||
};
|
||||
return emitter;
|
||||
}
|
||||
|
||||
export { assign, createEmitter, escapeHtml, format, friendlyJSONstringify, generateCodeFrame, generateFormatCacheKey, getGlobalThis, hasOwn, inBrowser, isArray, isBoolean, isDate, isEmptyObject, isFunction, isNumber, isObject, isPlainObject, isPromise, isRegExp, isString, isSymbol, makeSymbol, mark, measure, objectToString, toDisplayString, toTypeString, warn };
|
56
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/ParseError.js
generated
vendored
Normal file
56
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/ParseError.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
||||
|
||||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
||||
|
||||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
||||
|
||||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
// https://stackoverflow.com/a/46971044/970769
|
||||
// "Breaking changes in Typescript 2.1"
|
||||
// "Extending built-ins like Error, Array, and Map may no longer work."
|
||||
// "As a recommendation, you can manually adjust the prototype immediately after any super(...) calls."
|
||||
// https://github.com/Microsoft/TypeScript-wiki/blob/main/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
|
||||
var ParseError = /*#__PURE__*/function (_Error) {
|
||||
_inherits(ParseError, _Error);
|
||||
|
||||
var _super = _createSuper(ParseError);
|
||||
|
||||
function ParseError(code) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, ParseError);
|
||||
|
||||
_this = _super.call(this, code); // Set the prototype explicitly.
|
||||
// Any subclass of FooError will have to manually set the prototype as well.
|
||||
|
||||
Object.setPrototypeOf(_assertThisInitialized(_this), ParseError.prototype);
|
||||
_this.name = _this.constructor.name;
|
||||
return _this;
|
||||
}
|
||||
|
||||
return _createClass(ParseError);
|
||||
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
||||
|
||||
export { ParseError as default };
|
||||
//# sourceMappingURL=ParseError.js.map
|
176
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/PhoneNumber.js
generated
vendored
Normal file
176
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/PhoneNumber.js
generated
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
|
||||
import Metadata from './metadata.js';
|
||||
import isPossibleNumber from './isPossible.js';
|
||||
import isValidNumber from './isValid.js'; // import checkNumberLength from './helpers/checkNumberLength.js'
|
||||
|
||||
import getNumberType from './helpers/getNumberType.js';
|
||||
import getPossibleCountriesForNumber from './helpers/getPossibleCountriesForNumber.js';
|
||||
import formatNumber from './format.js';
|
||||
var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
|
||||
|
||||
var PhoneNumber = /*#__PURE__*/function () {
|
||||
/**
|
||||
* @param {string} countryOrCountryCallingCode
|
||||
* @param {string} nationalNumber
|
||||
* @param {object} metadata — Metadata JSON
|
||||
* @return {PhoneNumber}
|
||||
*/
|
||||
function PhoneNumber(countryOrCountryCallingCode, nationalNumber, metadata) {
|
||||
_classCallCheck(this, PhoneNumber);
|
||||
|
||||
if (!countryOrCountryCallingCode) {
|
||||
throw new TypeError('`country` or `countryCallingCode` not passed');
|
||||
}
|
||||
|
||||
if (!nationalNumber) {
|
||||
throw new TypeError('`nationalNumber` not passed');
|
||||
}
|
||||
|
||||
if (!metadata) {
|
||||
throw new TypeError('`metadata` not passed');
|
||||
}
|
||||
|
||||
var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata),
|
||||
country = _getCountryAndCountry.country,
|
||||
countryCallingCode = _getCountryAndCountry.countryCallingCode;
|
||||
|
||||
this.country = country;
|
||||
this.countryCallingCode = countryCallingCode;
|
||||
this.nationalNumber = nationalNumber;
|
||||
this.number = '+' + this.countryCallingCode + this.nationalNumber;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
_createClass(PhoneNumber, [{
|
||||
key: "setExt",
|
||||
value: function setExt(ext) {
|
||||
this.ext = ext;
|
||||
}
|
||||
}, {
|
||||
key: "getPossibleCountries",
|
||||
value: function getPossibleCountries() {
|
||||
if (this.country) {
|
||||
return [this.country];
|
||||
}
|
||||
|
||||
return getPossibleCountriesForNumber(this.countryCallingCode, this.nationalNumber, this.metadata);
|
||||
}
|
||||
}, {
|
||||
key: "isPossible",
|
||||
value: function isPossible() {
|
||||
return isPossibleNumber(this, {
|
||||
v2: true
|
||||
}, this.metadata);
|
||||
}
|
||||
}, {
|
||||
key: "isValid",
|
||||
value: function isValid() {
|
||||
return isValidNumber(this, {
|
||||
v2: true
|
||||
}, this.metadata);
|
||||
}
|
||||
}, {
|
||||
key: "isNonGeographic",
|
||||
value: function isNonGeographic() {
|
||||
var metadata = new Metadata(this.metadata);
|
||||
return metadata.isNonGeographicCallingCode(this.countryCallingCode);
|
||||
}
|
||||
}, {
|
||||
key: "isEqual",
|
||||
value: function isEqual(phoneNumber) {
|
||||
return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
|
||||
} // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
|
||||
// but later it was found out that it doesn't include the possible `TOO_SHORT` result
|
||||
// returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
|
||||
// so eventually I simply commented out this method from the `PhoneNumber` class
|
||||
// and just left the `validatePhoneNumberLength()` function, even though that one would require
|
||||
// and additional step to also validate the actual country / calling code of the phone number.
|
||||
// validateLength() {
|
||||
// const metadata = new Metadata(this.metadata)
|
||||
// metadata.selectNumberingPlan(this.countryCallingCode)
|
||||
// const result = checkNumberLength(this.nationalNumber, metadata)
|
||||
// if (result !== 'IS_POSSIBLE') {
|
||||
// return result
|
||||
// }
|
||||
// }
|
||||
|
||||
}, {
|
||||
key: "getType",
|
||||
value: function getType() {
|
||||
return getNumberType(this, {
|
||||
v2: true
|
||||
}, this.metadata);
|
||||
}
|
||||
}, {
|
||||
key: "format",
|
||||
value: function format(_format, options) {
|
||||
return formatNumber(this, _format, options ? _objectSpread(_objectSpread({}, options), {}, {
|
||||
v2: true
|
||||
}) : {
|
||||
v2: true
|
||||
}, this.metadata);
|
||||
}
|
||||
}, {
|
||||
key: "formatNational",
|
||||
value: function formatNational(options) {
|
||||
return this.format('NATIONAL', options);
|
||||
}
|
||||
}, {
|
||||
key: "formatInternational",
|
||||
value: function formatInternational(options) {
|
||||
return this.format('INTERNATIONAL', options);
|
||||
}
|
||||
}, {
|
||||
key: "getURI",
|
||||
value: function getURI(options) {
|
||||
return this.format('RFC3966', options);
|
||||
}
|
||||
}]);
|
||||
|
||||
return PhoneNumber;
|
||||
}();
|
||||
|
||||
export { PhoneNumber as default };
|
||||
|
||||
var isCountryCode = function isCountryCode(value) {
|
||||
return /^[A-Z]{2}$/.test(value);
|
||||
};
|
||||
|
||||
function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
|
||||
var country;
|
||||
var countryCallingCode;
|
||||
var metadata = new Metadata(metadataJson); // If country code is passed then derive `countryCallingCode` from it.
|
||||
// Also store the country code as `.country`.
|
||||
|
||||
if (isCountryCode(countryOrCountryCallingCode)) {
|
||||
country = countryOrCountryCallingCode;
|
||||
metadata.selectNumberingPlan(country);
|
||||
countryCallingCode = metadata.countryCallingCode();
|
||||
} else {
|
||||
countryCallingCode = countryOrCountryCallingCode;
|
||||
/* istanbul ignore if */
|
||||
|
||||
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
|
||||
if (metadata.isNonGeographicCallingCode(countryCallingCode)) {
|
||||
country = '001';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
country: country,
|
||||
countryCallingCode: countryCallingCode
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=PhoneNumber.js.map
|
25
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/constants.js
generated
vendored
Normal file
25
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/constants.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// The minimum length of the national significant number.
|
||||
export var MIN_LENGTH_FOR_NSN = 2; // The ITU says the maximum length should be 15,
|
||||
// but one can find longer numbers in Germany.
|
||||
|
||||
export var MAX_LENGTH_FOR_NSN = 17; // The maximum length of the country calling code.
|
||||
|
||||
export var MAX_LENGTH_COUNTRY_CODE = 3; // Digits accepted in phone numbers
|
||||
// (ascii, fullwidth, arabic-indic, and eastern arabic digits).
|
||||
|
||||
export var VALID_DIGITS = "0-9\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9"; // `DASHES` will be right after the opening square bracket of the "character class"
|
||||
|
||||
var DASHES = "-\u2010-\u2015\u2212\u30FC\uFF0D";
|
||||
var SLASHES = "\uFF0F/";
|
||||
var DOTS = "\uFF0E.";
|
||||
export var WHITESPACE = " \xA0\xAD\u200B\u2060\u3000";
|
||||
var BRACKETS = "()\uFF08\uFF09\uFF3B\uFF3D\\[\\]"; // export const OPENING_BRACKETS = '(\uFF08\uFF3B\\\['
|
||||
|
||||
var TILDES = "~\u2053\u223C\uFF5E"; // Regular expression of acceptable punctuation found in phone numbers. This
|
||||
// excludes punctuation found as a leading character only. This consists of dash
|
||||
// characters, white space characters, full stops, slashes, square brackets,
|
||||
// parentheses and tildes. Full-width variants are also present.
|
||||
|
||||
export var VALID_PUNCTUATION = "".concat(DASHES).concat(SLASHES).concat(DOTS).concat(WHITESPACE).concat(BRACKETS).concat(TILDES);
|
||||
export var PLUS_CHARS = "+\uFF0B"; // const LEADING_PLUS_CHARS_PATTERN = new RegExp('^[' + PLUS_CHARS + ']+')
|
||||
//# sourceMappingURL=constants.js.map
|
190
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/format.js
generated
vendored
Normal file
190
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/format.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
// This is a port of Google Android `libphonenumber`'s
|
||||
// `phonenumberutil.js` of December 31th, 2018.
|
||||
//
|
||||
// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
|
||||
import matchesEntirely from './helpers/matchesEntirely.js';
|
||||
import formatNationalNumberUsingFormat from './helpers/formatNationalNumberUsingFormat.js';
|
||||
import Metadata, { getCountryCallingCode } from './metadata.js';
|
||||
import getIddPrefix from './helpers/getIddPrefix.js';
|
||||
import { formatRFC3966 } from './helpers/RFC3966.js';
|
||||
var DEFAULT_OPTIONS = {
|
||||
formatExtension: function formatExtension(formattedNumber, extension, metadata) {
|
||||
return "".concat(formattedNumber).concat(metadata.ext()).concat(extension);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Formats a phone number.
|
||||
*
|
||||
* format(phoneNumberInstance, 'INTERNATIONAL', { ..., v2: true }, metadata)
|
||||
* format(phoneNumberInstance, 'NATIONAL', { ..., v2: true }, metadata)
|
||||
*
|
||||
* format({ phone: '8005553535', country: 'RU' }, 'INTERNATIONAL', { ... }, metadata)
|
||||
* format({ phone: '8005553535', country: 'RU' }, 'NATIONAL', undefined, metadata)
|
||||
*
|
||||
* @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
|
||||
* @param {string} format
|
||||
* @param {object} [options]
|
||||
* @param {object} metadata
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
export default function formatNumber(input, format, options, metadata) {
|
||||
// Apply default options.
|
||||
if (options) {
|
||||
options = _objectSpread(_objectSpread({}, DEFAULT_OPTIONS), options);
|
||||
} else {
|
||||
options = DEFAULT_OPTIONS;
|
||||
}
|
||||
|
||||
metadata = new Metadata(metadata);
|
||||
|
||||
if (input.country && input.country !== '001') {
|
||||
// Validate `input.country`.
|
||||
if (!metadata.hasCountry(input.country)) {
|
||||
throw new Error("Unknown country: ".concat(input.country));
|
||||
}
|
||||
|
||||
metadata.country(input.country);
|
||||
} else if (input.countryCallingCode) {
|
||||
metadata.selectNumberingPlan(input.countryCallingCode);
|
||||
} else return input.phone || '';
|
||||
|
||||
var countryCallingCode = metadata.countryCallingCode();
|
||||
var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // This variable should have been declared inside `case`s
|
||||
// but Babel has a bug and it says "duplicate variable declaration".
|
||||
|
||||
var number;
|
||||
|
||||
switch (format) {
|
||||
case 'NATIONAL':
|
||||
// Legacy argument support.
|
||||
// (`{ country: ..., phone: '' }`)
|
||||
if (!nationalNumber) {
|
||||
return '';
|
||||
}
|
||||
|
||||
number = formatNationalNumber(nationalNumber, input.carrierCode, 'NATIONAL', metadata, options);
|
||||
return addExtension(number, input.ext, metadata, options.formatExtension);
|
||||
|
||||
case 'INTERNATIONAL':
|
||||
// Legacy argument support.
|
||||
// (`{ country: ..., phone: '' }`)
|
||||
if (!nationalNumber) {
|
||||
return "+".concat(countryCallingCode);
|
||||
}
|
||||
|
||||
number = formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata, options);
|
||||
number = "+".concat(countryCallingCode, " ").concat(number);
|
||||
return addExtension(number, input.ext, metadata, options.formatExtension);
|
||||
|
||||
case 'E.164':
|
||||
// `E.164` doesn't define "phone number extensions".
|
||||
return "+".concat(countryCallingCode).concat(nationalNumber);
|
||||
|
||||
case 'RFC3966':
|
||||
return formatRFC3966({
|
||||
number: "+".concat(countryCallingCode).concat(nationalNumber),
|
||||
ext: input.ext
|
||||
});
|
||||
// For reference, here's Google's IDD formatter:
|
||||
// https://github.com/google/libphonenumber/blob/32719cf74e68796788d1ca45abc85dcdc63ba5b9/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L1546
|
||||
// Not saying that this IDD formatter replicates it 1:1, but it seems to work.
|
||||
// Who would even need to format phone numbers in IDD format anyway?
|
||||
|
||||
case 'IDD':
|
||||
if (!options.fromCountry) {
|
||||
return; // throw new Error('`fromCountry` option not passed for IDD-prefixed formatting.')
|
||||
}
|
||||
|
||||
var formattedNumber = formatIDD(nationalNumber, input.carrierCode, countryCallingCode, options.fromCountry, metadata);
|
||||
return addExtension(formattedNumber, input.ext, metadata, options.formatExtension);
|
||||
|
||||
default:
|
||||
throw new Error("Unknown \"format\" argument passed to \"formatNumber()\": \"".concat(format, "\""));
|
||||
}
|
||||
}
|
||||
|
||||
function formatNationalNumber(number, carrierCode, formatAs, metadata, options) {
|
||||
var format = chooseFormatForNumber(metadata.formats(), number);
|
||||
|
||||
if (!format) {
|
||||
return number;
|
||||
}
|
||||
|
||||
return formatNationalNumberUsingFormat(number, format, {
|
||||
useInternationalFormat: formatAs === 'INTERNATIONAL',
|
||||
withNationalPrefix: format.nationalPrefixIsOptionalWhenFormattingInNationalFormat() && options && options.nationalPrefix === false ? false : true,
|
||||
carrierCode: carrierCode,
|
||||
metadata: metadata
|
||||
});
|
||||
}
|
||||
|
||||
export function chooseFormatForNumber(availableFormats, nationalNnumber) {
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(availableFormats), _step; !(_step = _iterator()).done;) {
|
||||
var format = _step.value;
|
||||
|
||||
// Validate leading digits.
|
||||
// The test case for "else path" could be found by searching for
|
||||
// "format.leadingDigitsPatterns().length === 0".
|
||||
if (format.leadingDigitsPatterns().length > 0) {
|
||||
// The last leading_digits_pattern is used here, as it is the most detailed
|
||||
var lastLeadingDigitsPattern = format.leadingDigitsPatterns()[format.leadingDigitsPatterns().length - 1]; // If leading digits don't match then move on to the next phone number format
|
||||
|
||||
if (nationalNnumber.search(lastLeadingDigitsPattern) !== 0) {
|
||||
continue;
|
||||
}
|
||||
} // Check that the national number matches the phone number format regular expression
|
||||
|
||||
|
||||
if (matchesEntirely(nationalNnumber, format.pattern())) {
|
||||
return format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addExtension(formattedNumber, ext, metadata, formatExtension) {
|
||||
return ext ? formatExtension(formattedNumber, ext, metadata) : formattedNumber;
|
||||
}
|
||||
|
||||
function formatIDD(nationalNumber, carrierCode, countryCallingCode, fromCountry, metadata) {
|
||||
var fromCountryCallingCode = getCountryCallingCode(fromCountry, metadata.metadata); // When calling within the same country calling code.
|
||||
|
||||
if (fromCountryCallingCode === countryCallingCode) {
|
||||
var formattedNumber = formatNationalNumber(nationalNumber, carrierCode, 'NATIONAL', metadata); // For NANPA regions, return the national format for these regions
|
||||
// but prefix it with the country calling code.
|
||||
|
||||
if (countryCallingCode === '1') {
|
||||
return countryCallingCode + ' ' + formattedNumber;
|
||||
} // If regions share a country calling code, the country calling code need
|
||||
// not be dialled. This also applies when dialling within a region, so this
|
||||
// if clause covers both these cases. Technically this is the case for
|
||||
// dialling from La Reunion to other overseas departments of France (French
|
||||
// Guiana, Martinique, Guadeloupe), but not vice versa - so we don't cover
|
||||
// this edge case for now and for those cases return the version including
|
||||
// country calling code. Details here:
|
||||
// http://www.petitfute.com/voyage/225-info-pratiques-reunion
|
||||
//
|
||||
|
||||
|
||||
return formattedNumber;
|
||||
}
|
||||
|
||||
var iddPrefix = getIddPrefix(fromCountry, undefined, metadata.metadata);
|
||||
|
||||
if (iddPrefix) {
|
||||
return "".concat(iddPrefix, " ").concat(countryCallingCode, " ").concat(formatNationalNumber(nationalNumber, null, 'INTERNATIONAL', metadata));
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=format.js.map
|
90
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/RFC3966.js
generated
vendored
Normal file
90
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/RFC3966.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
import isViablePhoneNumber from './isViablePhoneNumber.js'; // https://www.ietf.org/rfc/rfc3966.txt
|
||||
|
||||
/**
|
||||
* @param {string} text - Phone URI (RFC 3966).
|
||||
* @return {object} `{ ?number, ?ext }`.
|
||||
*/
|
||||
|
||||
export function parseRFC3966(text) {
|
||||
var number;
|
||||
var ext; // Replace "tel:" with "tel=" for parsing convenience.
|
||||
|
||||
text = text.replace(/^tel:/, 'tel=');
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(text.split(';')), _step; !(_step = _iterator()).done;) {
|
||||
var part = _step.value;
|
||||
|
||||
var _part$split = part.split('='),
|
||||
_part$split2 = _slicedToArray(_part$split, 2),
|
||||
name = _part$split2[0],
|
||||
value = _part$split2[1];
|
||||
|
||||
switch (name) {
|
||||
case 'tel':
|
||||
number = value;
|
||||
break;
|
||||
|
||||
case 'ext':
|
||||
ext = value;
|
||||
break;
|
||||
|
||||
case 'phone-context':
|
||||
// Only "country contexts" are supported.
|
||||
// "Domain contexts" are ignored.
|
||||
if (value[0] === '+') {
|
||||
number = value + number;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
} // If the phone number is not viable, then abort.
|
||||
|
||||
|
||||
if (!isViablePhoneNumber(number)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
var result = {
|
||||
number: number
|
||||
};
|
||||
|
||||
if (ext) {
|
||||
result.ext = ext;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* @param {object} - `{ ?number, ?extension }`.
|
||||
* @return {string} Phone URI (RFC 3966).
|
||||
*/
|
||||
|
||||
export function formatRFC3966(_ref) {
|
||||
var number = _ref.number,
|
||||
ext = _ref.ext;
|
||||
|
||||
if (!number) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (number[0] !== '+') {
|
||||
throw new Error("\"formatRFC3966()\" expects \"number\" to be in E.164 format.");
|
||||
}
|
||||
|
||||
return "tel:".concat(number).concat(ext ? ';ext=' + ext : '');
|
||||
}
|
||||
//# sourceMappingURL=RFC3966.js.map
|
35
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js
generated
vendored
Normal file
35
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/applyInternationalSeparatorStyle.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import { VALID_PUNCTUATION } from '../constants.js'; // Removes brackets and replaces dashes with spaces.
|
||||
//
|
||||
// E.g. "(999) 111-22-33" -> "999 111 22 33"
|
||||
//
|
||||
// For some reason Google's metadata contains `<intlFormat/>`s with brackets and dashes.
|
||||
// Meanwhile, there's no single opinion about using punctuation in international phone numbers.
|
||||
//
|
||||
// For example, Google's `<intlFormat/>` for USA is `+1 213-373-4253`.
|
||||
// And here's a quote from WikiPedia's "North American Numbering Plan" page:
|
||||
// https://en.wikipedia.org/wiki/North_American_Numbering_Plan
|
||||
//
|
||||
// "The country calling code for all countries participating in the NANP is 1.
|
||||
// In international format, an NANP number should be listed as +1 301 555 01 00,
|
||||
// where 301 is an area code (Maryland)."
|
||||
//
|
||||
// I personally prefer the international format without any punctuation.
|
||||
// For example, brackets are remnants of the old age, meaning that the
|
||||
// phone number part in brackets (so called "area code") can be omitted
|
||||
// if dialing within the same "area".
|
||||
// And hyphens were clearly introduced for splitting local numbers into memorizable groups.
|
||||
// For example, remembering "5553535" is difficult but "555-35-35" is much simpler.
|
||||
// Imagine a man taking a bus from home to work and seeing an ad with a phone number.
|
||||
// He has a couple of seconds to memorize that number until it passes by.
|
||||
// If it were spaces instead of hyphens the man wouldn't necessarily get it,
|
||||
// but with hyphens instead of spaces the grouping is more explicit.
|
||||
// I personally think that hyphens introduce visual clutter,
|
||||
// so I prefer replacing them with spaces in international numbers.
|
||||
// In the modern age all output is done on displays where spaces are clearly distinguishable
|
||||
// so hyphens can be safely replaced with spaces without losing any legibility.
|
||||
//
|
||||
|
||||
export default function applyInternationalSeparatorStyle(formattedNumber) {
|
||||
return formattedNumber.replace(new RegExp("[".concat(VALID_PUNCTUATION, "]+"), 'g'), ' ').trim();
|
||||
}
|
||||
//# sourceMappingURL=applyInternationalSeparatorStyle.js.map
|
80
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js
generated
vendored
Normal file
80
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/checkNumberLength.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
import mergeArrays from './mergeArrays.js';
|
||||
export default function checkNumberLength(nationalNumber, metadata) {
|
||||
return checkNumberLengthForType(nationalNumber, undefined, metadata);
|
||||
} // Checks whether a number is possible for the country based on its length.
|
||||
// Should only be called for the "new" metadata which has "possible lengths".
|
||||
|
||||
export function checkNumberLengthForType(nationalNumber, type, metadata) {
|
||||
var type_info = metadata.type(type); // There should always be "<possiblePengths/>" set for every type element.
|
||||
// This is declared in the XML schema.
|
||||
// For size efficiency, where a sub-description (e.g. fixed-line)
|
||||
// has the same "<possiblePengths/>" as the "general description", this is missing,
|
||||
// so we fall back to the "general description". Where no numbers of the type
|
||||
// exist at all, there is one possible length (-1) which is guaranteed
|
||||
// not to match the length of any real phone number.
|
||||
|
||||
var possible_lengths = type_info && type_info.possibleLengths() || metadata.possibleLengths(); // let local_lengths = type_info && type.possibleLengthsLocal() || metadata.possibleLengthsLocal()
|
||||
// Metadata before version `1.0.18` didn't contain `possible_lengths`.
|
||||
|
||||
if (!possible_lengths) {
|
||||
return 'IS_POSSIBLE';
|
||||
}
|
||||
|
||||
if (type === 'FIXED_LINE_OR_MOBILE') {
|
||||
// No such country in metadata.
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (!metadata.type('FIXED_LINE')) {
|
||||
// The rare case has been encountered where no fixedLine data is available
|
||||
// (true for some non-geographic entities), so we just check mobile.
|
||||
return checkNumberLengthForType(nationalNumber, 'MOBILE', metadata);
|
||||
}
|
||||
|
||||
var mobile_type = metadata.type('MOBILE');
|
||||
|
||||
if (mobile_type) {
|
||||
// Merge the mobile data in if there was any. "Concat" creates a new
|
||||
// array, it doesn't edit possible_lengths in place, so we don't need a copy.
|
||||
// Note that when adding the possible lengths from mobile, we have
|
||||
// to again check they aren't empty since if they are this indicates
|
||||
// they are the same as the general desc and should be obtained from there.
|
||||
possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths()); // The current list is sorted; we need to merge in the new list and
|
||||
// re-sort (duplicates are okay). Sorting isn't so expensive because
|
||||
// the lists are very small.
|
||||
// if (local_lengths) {
|
||||
// local_lengths = mergeArrays(local_lengths, mobile_type.possibleLengthsLocal())
|
||||
// } else {
|
||||
// local_lengths = mobile_type.possibleLengthsLocal()
|
||||
// }
|
||||
}
|
||||
} // If the type doesn't exist then return 'INVALID_LENGTH'.
|
||||
else if (type && !type_info) {
|
||||
return 'INVALID_LENGTH';
|
||||
}
|
||||
|
||||
var actual_length = nationalNumber.length; // In `libphonenumber-js` all "local-only" formats are dropped for simplicity.
|
||||
// // This is safe because there is never an overlap beween the possible lengths
|
||||
// // and the local-only lengths; this is checked at build time.
|
||||
// if (local_lengths && local_lengths.indexOf(nationalNumber.length) >= 0)
|
||||
// {
|
||||
// return 'IS_POSSIBLE_LOCAL_ONLY'
|
||||
// }
|
||||
|
||||
var minimum_length = possible_lengths[0];
|
||||
|
||||
if (minimum_length === actual_length) {
|
||||
return 'IS_POSSIBLE';
|
||||
}
|
||||
|
||||
if (minimum_length > actual_length) {
|
||||
return 'TOO_SHORT';
|
||||
}
|
||||
|
||||
if (possible_lengths[possible_lengths.length - 1] < actual_length) {
|
||||
return 'TOO_LONG';
|
||||
} // We skip the first element since we've already checked it.
|
||||
|
||||
|
||||
return possible_lengths.indexOf(actual_length, 1) >= 0 ? 'IS_POSSIBLE' : 'INVALID_LENGTH';
|
||||
}
|
||||
//# sourceMappingURL=checkNumberLength.js.map
|
108
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js
generated
vendored
Normal file
108
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extension/createExtensionPattern.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
import { VALID_DIGITS } from '../../constants.js'; // The RFC 3966 format for extensions.
|
||||
|
||||
var RFC3966_EXTN_PREFIX = ';ext=';
|
||||
/**
|
||||
* Helper method for constructing regular expressions for parsing. Creates
|
||||
* an expression that captures up to max_length digits.
|
||||
* @return {string} RegEx pattern to capture extension digits.
|
||||
*/
|
||||
|
||||
var getExtensionDigitsPattern = function getExtensionDigitsPattern(maxLength) {
|
||||
return "([".concat(VALID_DIGITS, "]{1,").concat(maxLength, "})");
|
||||
};
|
||||
/**
|
||||
* Helper initialiser method to create the regular-expression pattern to match
|
||||
* extensions.
|
||||
* Copy-pasted from Google's `libphonenumber`:
|
||||
* https://github.com/google/libphonenumber/blob/55b2646ec9393f4d3d6661b9c82ef9e258e8b829/javascript/i18n/phonenumbers/phonenumberutil.js#L759-L766
|
||||
* @return {string} RegEx pattern to capture extensions.
|
||||
*/
|
||||
|
||||
|
||||
export default function createExtensionPattern(purpose) {
|
||||
// We cap the maximum length of an extension based on the ambiguity of the way
|
||||
// the extension is prefixed. As per ITU, the officially allowed length for
|
||||
// extensions is actually 40, but we don't support this since we haven't seen real
|
||||
// examples and this introduces many false interpretations as the extension labels
|
||||
// are not standardized.
|
||||
|
||||
/** @type {string} */
|
||||
var extLimitAfterExplicitLabel = '20';
|
||||
/** @type {string} */
|
||||
|
||||
var extLimitAfterLikelyLabel = '15';
|
||||
/** @type {string} */
|
||||
|
||||
var extLimitAfterAmbiguousChar = '9';
|
||||
/** @type {string} */
|
||||
|
||||
var extLimitWhenNotSure = '6';
|
||||
/** @type {string} */
|
||||
|
||||
var possibleSeparatorsBetweenNumberAndExtLabel = "[ \xA0\\t,]*"; // Optional full stop (.) or colon, followed by zero or more spaces/tabs/commas.
|
||||
|
||||
/** @type {string} */
|
||||
|
||||
var possibleCharsAfterExtLabel = "[:\\.\uFF0E]?[ \xA0\\t,-]*";
|
||||
/** @type {string} */
|
||||
|
||||
var optionalExtnSuffix = "#?"; // Here the extension is called out in more explicit way, i.e mentioning it obvious
|
||||
// patterns like "ext.".
|
||||
|
||||
/** @type {string} */
|
||||
|
||||
var explicitExtLabels = "(?:e?xt(?:ensi(?:o\u0301?|\xF3))?n?|\uFF45?\uFF58\uFF54\uFF4E?|\u0434\u043E\u0431|anexo)"; // One-character symbols that can be used to indicate an extension, and less
|
||||
// commonly used or more ambiguous extension labels.
|
||||
|
||||
/** @type {string} */
|
||||
|
||||
var ambiguousExtLabels = "(?:[x\uFF58#\uFF03~\uFF5E]|int|\uFF49\uFF4E\uFF54)"; // When extension is not separated clearly.
|
||||
|
||||
/** @type {string} */
|
||||
|
||||
var ambiguousSeparator = "[- ]+"; // This is the same as possibleSeparatorsBetweenNumberAndExtLabel, but not matching
|
||||
// comma as extension label may have it.
|
||||
|
||||
/** @type {string} */
|
||||
|
||||
var possibleSeparatorsNumberExtLabelNoComma = "[ \xA0\\t]*"; // ",," is commonly used for auto dialling the extension when connected. First
|
||||
// comma is matched through possibleSeparatorsBetweenNumberAndExtLabel, so we do
|
||||
// not repeat it here. Semi-colon works in Iphone and Android also to pop up a
|
||||
// button with the extension number following.
|
||||
|
||||
/** @type {string} */
|
||||
|
||||
var autoDiallingAndExtLabelsFound = "(?:,{2}|;)";
|
||||
/** @type {string} */
|
||||
|
||||
var rfcExtn = RFC3966_EXTN_PREFIX + getExtensionDigitsPattern(extLimitAfterExplicitLabel);
|
||||
/** @type {string} */
|
||||
|
||||
var explicitExtn = possibleSeparatorsBetweenNumberAndExtLabel + explicitExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterExplicitLabel) + optionalExtnSuffix;
|
||||
/** @type {string} */
|
||||
|
||||
var ambiguousExtn = possibleSeparatorsBetweenNumberAndExtLabel + ambiguousExtLabels + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix;
|
||||
/** @type {string} */
|
||||
|
||||
var americanStyleExtnWithSuffix = ambiguousSeparator + getExtensionDigitsPattern(extLimitWhenNotSure) + "#";
|
||||
/** @type {string} */
|
||||
|
||||
var autoDiallingExtn = possibleSeparatorsNumberExtLabelNoComma + autoDiallingAndExtLabelsFound + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterLikelyLabel) + optionalExtnSuffix;
|
||||
/** @type {string} */
|
||||
|
||||
var onlyCommasExtn = possibleSeparatorsNumberExtLabelNoComma + "(?:,)+" + possibleCharsAfterExtLabel + getExtensionDigitsPattern(extLimitAfterAmbiguousChar) + optionalExtnSuffix; // The first regular expression covers RFC 3966 format, where the extension is added
|
||||
// using ";ext=". The second more generic where extension is mentioned with explicit
|
||||
// labels like "ext:". In both the above cases we allow more numbers in extension than
|
||||
// any other extension labels. The third one captures when single character extension
|
||||
// labels or less commonly used labels are used. In such cases we capture fewer
|
||||
// extension digits in order to reduce the chance of falsely interpreting two
|
||||
// numbers beside each other as a number + extension. The fourth one covers the
|
||||
// special case of American numbers where the extension is written with a hash
|
||||
// at the end, such as "- 503#". The fifth one is exclusively for extension
|
||||
// autodialling formats which are used when dialling and in this case we accept longer
|
||||
// extensions. The last one is more liberal on the number of commas that acts as
|
||||
// extension labels, so we have a strict cap on the number of digits in such extensions.
|
||||
|
||||
return rfcExtn + "|" + explicitExtn + "|" + ambiguousExtn + "|" + americanStyleExtnWithSuffix + "|" + autoDiallingExtn + "|" + onlyCommasExtn;
|
||||
}
|
||||
//# sourceMappingURL=createExtensionPattern.js.map
|
32
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js
generated
vendored
Normal file
32
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extension/extractExtension.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import createExtensionPattern from './createExtensionPattern.js'; // Regexp of all known extension prefixes used by different regions followed by
|
||||
// 1 or more valid digits, for use when parsing.
|
||||
|
||||
var EXTN_PATTERN = new RegExp('(?:' + createExtensionPattern() + ')$', 'i'); // Strips any extension (as in, the part of the number dialled after the call is
|
||||
// connected, usually indicated with extn, ext, x or similar) from the end of
|
||||
// the number, and returns it.
|
||||
|
||||
export default function extractExtension(number) {
|
||||
var start = number.search(EXTN_PATTERN);
|
||||
|
||||
if (start < 0) {
|
||||
return {};
|
||||
} // If we find a potential extension, and the number preceding this is a viable
|
||||
// number, we assume it is an extension.
|
||||
|
||||
|
||||
var numberWithoutExtension = number.slice(0, start);
|
||||
var matches = number.match(EXTN_PATTERN);
|
||||
var i = 1;
|
||||
|
||||
while (i < matches.length) {
|
||||
if (matches[i]) {
|
||||
return {
|
||||
number: numberWithoutExtension,
|
||||
ext: matches[i]
|
||||
};
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=extractExtension.js.map
|
142
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js
generated
vendored
Normal file
142
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCode.js
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
import stripIddPrefix from './stripIddPrefix.js';
|
||||
import extractCountryCallingCodeFromInternationalNumberWithoutPlusSign from './extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js';
|
||||
import Metadata from '../metadata.js';
|
||||
import { MAX_LENGTH_COUNTRY_CODE } from '../constants.js';
|
||||
/**
|
||||
* Converts a phone number digits (possibly with a `+`)
|
||||
* into a calling code and the rest phone number digits.
|
||||
* The "rest phone number digits" could include
|
||||
* a national prefix, carrier code, and national
|
||||
* (significant) number.
|
||||
* @param {string} number — Phone number digits (possibly with a `+`).
|
||||
* @param {string} [country] — Default country.
|
||||
* @param {string} [callingCode] — Default calling code (some phone numbering plans are non-geographic).
|
||||
* @param {object} metadata
|
||||
* @return {object} `{ countryCallingCodeSource: string?, countryCallingCode: string?, number: string }`
|
||||
* @example
|
||||
* // Returns `{ countryCallingCode: "1", number: "2133734253" }`.
|
||||
* extractCountryCallingCode('2133734253', 'US', null, metadata)
|
||||
* extractCountryCallingCode('2133734253', null, '1', metadata)
|
||||
* extractCountryCallingCode('+12133734253', null, null, metadata)
|
||||
* extractCountryCallingCode('+12133734253', 'RU', null, metadata)
|
||||
*/
|
||||
|
||||
export default function extractCountryCallingCode(number, country, callingCode, metadata) {
|
||||
if (!number) {
|
||||
return {};
|
||||
}
|
||||
|
||||
var isNumberWithIddPrefix; // If this is not an international phone number,
|
||||
// then either extract an "IDD" prefix, or extract a
|
||||
// country calling code from a number by autocorrecting it
|
||||
// by prepending a leading `+` in cases when it starts
|
||||
// with the country calling code.
|
||||
// https://wikitravel.org/en/International_dialling_prefix
|
||||
// https://github.com/catamphetamine/libphonenumber-js/issues/376
|
||||
|
||||
if (number[0] !== '+') {
|
||||
// Convert an "out-of-country" dialing phone number
|
||||
// to a proper international phone number.
|
||||
var numberWithoutIDD = stripIddPrefix(number, country, callingCode, metadata); // If an IDD prefix was stripped then
|
||||
// convert the number to international one
|
||||
// for subsequent parsing.
|
||||
|
||||
if (numberWithoutIDD && numberWithoutIDD !== number) {
|
||||
isNumberWithIddPrefix = true;
|
||||
number = '+' + numberWithoutIDD;
|
||||
} else {
|
||||
// Check to see if the number starts with the country calling code
|
||||
// for the default country. If so, we remove the country calling code,
|
||||
// and do some checks on the validity of the number before and after.
|
||||
// https://github.com/catamphetamine/libphonenumber-js/issues/376
|
||||
if (country || callingCode) {
|
||||
var _extractCountryCallin = extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata),
|
||||
countryCallingCode = _extractCountryCallin.countryCallingCode,
|
||||
shorterNumber = _extractCountryCallin.number;
|
||||
|
||||
if (countryCallingCode) {
|
||||
return {
|
||||
countryCallingCodeSource: 'FROM_NUMBER_WITHOUT_PLUS_SIGN',
|
||||
countryCallingCode: countryCallingCode,
|
||||
number: shorterNumber
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
// No need to set it to `UNSPECIFIED`. It can be just `undefined`.
|
||||
// countryCallingCodeSource: 'UNSPECIFIED',
|
||||
number: number
|
||||
};
|
||||
}
|
||||
} // Fast abortion: country codes do not begin with a '0'
|
||||
|
||||
|
||||
if (number[1] === '0') {
|
||||
return {};
|
||||
}
|
||||
|
||||
metadata = new Metadata(metadata); // The thing with country phone codes
|
||||
// is that they are orthogonal to each other
|
||||
// i.e. there's no such country phone code A
|
||||
// for which country phone code B exists
|
||||
// where B starts with A.
|
||||
// Therefore, while scanning digits,
|
||||
// if a valid country code is found,
|
||||
// that means that it is the country code.
|
||||
//
|
||||
|
||||
var i = 2;
|
||||
|
||||
while (i - 1 <= MAX_LENGTH_COUNTRY_CODE && i <= number.length) {
|
||||
var _countryCallingCode = number.slice(1, i);
|
||||
|
||||
if (metadata.hasCallingCode(_countryCallingCode)) {
|
||||
metadata.selectNumberingPlan(_countryCallingCode);
|
||||
return {
|
||||
countryCallingCodeSource: isNumberWithIddPrefix ? 'FROM_NUMBER_WITH_IDD' : 'FROM_NUMBER_WITH_PLUS_SIGN',
|
||||
countryCallingCode: _countryCallingCode,
|
||||
number: number.slice(i)
|
||||
};
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return {};
|
||||
} // The possible values for the returned `countryCallingCodeSource` are:
|
||||
//
|
||||
// Copy-pasted from:
|
||||
// https://github.com/google/libphonenumber/blob/master/resources/phonenumber.proto
|
||||
//
|
||||
// // The source from which the country_code is derived. This is not set in the
|
||||
// // general parsing method, but in the method that parses and keeps raw_input.
|
||||
// // New fields could be added upon request.
|
||||
// enum CountryCodeSource {
|
||||
// // Default value returned if this is not set, because the phone number was
|
||||
// // created using parse, not parseAndKeepRawInput. hasCountryCodeSource will
|
||||
// // return false if this is the case.
|
||||
// UNSPECIFIED = 0;
|
||||
//
|
||||
// // The country_code is derived based on a phone number with a leading "+",
|
||||
// // e.g. the French number "+33 1 42 68 53 00".
|
||||
// FROM_NUMBER_WITH_PLUS_SIGN = 1;
|
||||
//
|
||||
// // The country_code is derived based on a phone number with a leading IDD,
|
||||
// // e.g. the French number "011 33 1 42 68 53 00", as it is dialled from US.
|
||||
// FROM_NUMBER_WITH_IDD = 5;
|
||||
//
|
||||
// // The country_code is derived based on a phone number without a leading
|
||||
// // "+", e.g. the French number "33 1 42 68 53 00" when defaultCountry is
|
||||
// // supplied as France.
|
||||
// FROM_NUMBER_WITHOUT_PLUS_SIGN = 10;
|
||||
//
|
||||
// // The country_code is derived NOT based on the phone number itself, but
|
||||
// // from the defaultCountry parameter provided in the parsing function by the
|
||||
// // clients. This happens mostly for numbers written in the national format
|
||||
// // (without country code). For example, this would be set when parsing the
|
||||
// // French number "01 42 68 53 00", when defaultCountry is supplied as
|
||||
// // France.
|
||||
// FROM_DEFAULT_COUNTRY = 20;
|
||||
// }
|
||||
//# sourceMappingURL=extractCountryCallingCode.js.map
|
50
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js
generated
vendored
Normal file
50
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import Metadata from '../metadata.js';
|
||||
import matchesEntirely from './matchesEntirely.js';
|
||||
import extractNationalNumber from './extractNationalNumber.js';
|
||||
import checkNumberLength from './checkNumberLength.js';
|
||||
import getCountryCallingCode from '../getCountryCallingCode.js';
|
||||
/**
|
||||
* Sometimes some people incorrectly input international phone numbers
|
||||
* without the leading `+`. This function corrects such input.
|
||||
* @param {string} number — Phone number digits.
|
||||
* @param {string?} country
|
||||
* @param {string?} callingCode
|
||||
* @param {object} metadata
|
||||
* @return {object} `{ countryCallingCode: string?, number: string }`.
|
||||
*/
|
||||
|
||||
export default function extractCountryCallingCodeFromInternationalNumberWithoutPlusSign(number, country, callingCode, metadata) {
|
||||
var countryCallingCode = country ? getCountryCallingCode(country, metadata) : callingCode;
|
||||
|
||||
if (number.indexOf(countryCallingCode) === 0) {
|
||||
metadata = new Metadata(metadata);
|
||||
metadata.selectNumberingPlan(country, callingCode);
|
||||
var possibleShorterNumber = number.slice(countryCallingCode.length);
|
||||
|
||||
var _extractNationalNumbe = extractNationalNumber(possibleShorterNumber, metadata),
|
||||
possibleShorterNationalNumber = _extractNationalNumbe.nationalNumber;
|
||||
|
||||
var _extractNationalNumbe2 = extractNationalNumber(number, metadata),
|
||||
nationalNumber = _extractNationalNumbe2.nationalNumber; // If the number was not valid before but is valid now,
|
||||
// or if it was too long before, we consider the number
|
||||
// with the country calling code stripped to be a better result
|
||||
// and keep that instead.
|
||||
// For example, in Germany (+49), `49` is a valid area code,
|
||||
// so if a number starts with `49`, it could be both a valid
|
||||
// national German number or an international number without
|
||||
// a leading `+`.
|
||||
|
||||
|
||||
if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) && matchesEntirely(possibleShorterNationalNumber, metadata.nationalNumberPattern()) || checkNumberLength(nationalNumber, metadata) === 'TOO_LONG') {
|
||||
return {
|
||||
countryCallingCode: countryCallingCode,
|
||||
number: possibleShorterNumber
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
number: number
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=extractCountryCallingCodeFromInternationalNumberWithoutPlusSign.js.map
|
70
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js
generated
vendored
Normal file
70
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import extractPhoneContext, { isPhoneContextValid, PLUS_SIGN, RFC3966_PREFIX_, RFC3966_PHONE_CONTEXT_, RFC3966_ISDN_SUBADDRESS_ } from './extractPhoneContext.js';
|
||||
import ParseError from '../ParseError.js';
|
||||
/**
|
||||
* @param {string} numberToParse
|
||||
* @param {string} nationalNumber
|
||||
* @return {}
|
||||
*/
|
||||
|
||||
export default function extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(numberToParse, _ref) {
|
||||
var extractFormattedPhoneNumber = _ref.extractFormattedPhoneNumber;
|
||||
var phoneContext = extractPhoneContext(numberToParse);
|
||||
|
||||
if (!isPhoneContextValid(phoneContext)) {
|
||||
throw new ParseError('NOT_A_NUMBER');
|
||||
}
|
||||
|
||||
var phoneNumberString;
|
||||
|
||||
if (phoneContext === null) {
|
||||
// Extract a possible number from the string passed in.
|
||||
// (this strips leading characters that could not be the start of a phone number)
|
||||
phoneNumberString = extractFormattedPhoneNumber(numberToParse) || '';
|
||||
} else {
|
||||
phoneNumberString = ''; // If the phone context contains a phone number prefix, we need to capture
|
||||
// it, whereas domains will be ignored.
|
||||
|
||||
if (phoneContext.charAt(0) === PLUS_SIGN) {
|
||||
phoneNumberString += phoneContext;
|
||||
} // Now append everything between the "tel:" prefix and the phone-context.
|
||||
// This should include the national number, an optional extension or
|
||||
// isdn-subaddress component. Note we also handle the case when "tel:" is
|
||||
// missing, as we have seen in some of the phone number inputs.
|
||||
// In that case, we append everything from the beginning.
|
||||
|
||||
|
||||
var indexOfRfc3966Prefix = numberToParse.indexOf(RFC3966_PREFIX_);
|
||||
var indexOfNationalNumber; // RFC 3966 "tel:" prefix is preset at this stage because
|
||||
// `isPhoneContextValid()` requires it to be present.
|
||||
|
||||
/* istanbul ignore else */
|
||||
|
||||
if (indexOfRfc3966Prefix >= 0) {
|
||||
indexOfNationalNumber = indexOfRfc3966Prefix + RFC3966_PREFIX_.length;
|
||||
} else {
|
||||
indexOfNationalNumber = 0;
|
||||
}
|
||||
|
||||
var indexOfPhoneContext = numberToParse.indexOf(RFC3966_PHONE_CONTEXT_);
|
||||
phoneNumberString += numberToParse.substring(indexOfNationalNumber, indexOfPhoneContext);
|
||||
} // Delete the isdn-subaddress and everything after it if it is present.
|
||||
// Note extension won't appear at the same time with isdn-subaddress
|
||||
// according to paragraph 5.3 of the RFC3966 spec.
|
||||
|
||||
|
||||
var indexOfIsdn = phoneNumberString.indexOf(RFC3966_ISDN_SUBADDRESS_);
|
||||
|
||||
if (indexOfIsdn > 0) {
|
||||
phoneNumberString = phoneNumberString.substring(0, indexOfIsdn);
|
||||
} // If both phone context and isdn-subaddress are absent but other
|
||||
// parameters are present, the parameters are left in nationalNumber.
|
||||
// This is because we are concerned about deleting content from a potential
|
||||
// number string when there is no strong evidence that the number is
|
||||
// actually written in RFC3966.
|
||||
|
||||
|
||||
if (phoneNumberString !== '') {
|
||||
return phoneNumberString;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js.map
|
111
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js
generated
vendored
Normal file
111
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractNationalNumber.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
import extractNationalNumberFromPossiblyIncompleteNumber from './extractNationalNumberFromPossiblyIncompleteNumber.js';
|
||||
import matchesEntirely from './matchesEntirely.js';
|
||||
import checkNumberLength from './checkNumberLength.js';
|
||||
/**
|
||||
* Strips national prefix and carrier code from a complete phone number.
|
||||
* The difference from the non-"FromCompleteNumber" function is that
|
||||
* it won't extract national prefix if the resultant number is too short
|
||||
* to be a complete number for the selected phone numbering plan.
|
||||
* @param {string} number — Complete phone number digits.
|
||||
* @param {Metadata} metadata — Metadata with a phone numbering plan selected.
|
||||
* @return {object} `{ nationalNumber: string, carrierCode: string? }`.
|
||||
*/
|
||||
|
||||
export default function extractNationalNumber(number, metadata) {
|
||||
// Parsing national prefixes and carrier codes
|
||||
// is only required for local phone numbers
|
||||
// but some people don't understand that
|
||||
// and sometimes write international phone numbers
|
||||
// with national prefixes (or maybe even carrier codes).
|
||||
// http://ucken.blogspot.ru/2016/03/trunk-prefixes-in-skype4b.html
|
||||
// Google's original library forgives such mistakes
|
||||
// and so does this library, because it has been requested:
|
||||
// https://github.com/catamphetamine/libphonenumber-js/issues/127
|
||||
var _extractNationalNumbe = extractNationalNumberFromPossiblyIncompleteNumber(number, metadata),
|
||||
carrierCode = _extractNationalNumbe.carrierCode,
|
||||
nationalNumber = _extractNationalNumbe.nationalNumber;
|
||||
|
||||
if (nationalNumber !== number) {
|
||||
if (!shouldHaveExtractedNationalPrefix(number, nationalNumber, metadata)) {
|
||||
// Don't strip the national prefix.
|
||||
return {
|
||||
nationalNumber: number
|
||||
};
|
||||
} // Check the national (significant) number length after extracting national prefix and carrier code.
|
||||
// Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature.
|
||||
|
||||
|
||||
if (metadata.possibleLengths()) {
|
||||
// The number remaining after stripping the national prefix and carrier code
|
||||
// should be long enough to have a possible length for the country.
|
||||
// Otherwise, don't strip the national prefix and carrier code,
|
||||
// since the original number could be a valid number.
|
||||
// This check has been copy-pasted "as is" from Google's original library:
|
||||
// https://github.com/google/libphonenumber/blob/876268eb1ad6cdc1b7b5bef17fc5e43052702d57/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L3236-L3250
|
||||
// It doesn't check for the "possibility" of the original `number`.
|
||||
// I guess it's fine not checking that one. It works as is anyway.
|
||||
if (!isPossibleIncompleteNationalNumber(nationalNumber, metadata)) {
|
||||
// Don't strip the national prefix.
|
||||
return {
|
||||
nationalNumber: number
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
nationalNumber: nationalNumber,
|
||||
carrierCode: carrierCode
|
||||
};
|
||||
} // In some countries, the same digit could be a national prefix
|
||||
// or a leading digit of a valid phone number.
|
||||
// For example, in Russia, national prefix is `8`,
|
||||
// and also `800 555 35 35` is a valid number
|
||||
// in which `8` is not a national prefix, but the first digit
|
||||
// of a national (significant) number.
|
||||
// Same's with Belarus:
|
||||
// `82004910060` is a valid national (significant) number,
|
||||
// but `2004910060` is not.
|
||||
// To support such cases (to prevent the code from always stripping
|
||||
// national prefix), a condition is imposed: a national prefix
|
||||
// is not extracted when the original number is "viable" and the
|
||||
// resultant number is not, a "viable" national number being the one
|
||||
// that matches `national_number_pattern`.
|
||||
|
||||
function shouldHaveExtractedNationalPrefix(nationalNumberBefore, nationalNumberAfter, metadata) {
|
||||
// The equivalent in Google's code is:
|
||||
// https://github.com/google/libphonenumber/blob/e326fa1fc4283bb05eb35cb3c15c18f98a31af33/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java#L2969-L3004
|
||||
if (matchesEntirely(nationalNumberBefore, metadata.nationalNumberPattern()) && !matchesEntirely(nationalNumberAfter, metadata.nationalNumberPattern())) {
|
||||
return false;
|
||||
} // This "is possible" national number (length) check has been commented out
|
||||
// because it's superceded by the (effectively) same check done in the
|
||||
// `extractNationalNumber()` function after it calls `shouldHaveExtractedNationalPrefix()`.
|
||||
// In other words, why run the same check twice if it could only be run once.
|
||||
// // Check the national (significant) number length after extracting national prefix and carrier code.
|
||||
// // Fixes a minor "weird behavior" bug: https://gitlab.com/catamphetamine/libphonenumber-js/-/issues/57
|
||||
// // (Legacy generated metadata (before `1.0.18`) didn't support the "possible lengths" feature).
|
||||
// if (metadata.possibleLengths()) {
|
||||
// if (isPossibleIncompleteNationalNumber(nationalNumberBefore, metadata) &&
|
||||
// !isPossibleIncompleteNationalNumber(nationalNumberAfter, metadata)) {
|
||||
// return false
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function isPossibleIncompleteNationalNumber(nationalNumber, metadata) {
|
||||
switch (checkNumberLength(nationalNumber, metadata)) {
|
||||
case 'TOO_SHORT':
|
||||
case 'INVALID_LENGTH':
|
||||
// This library ignores "local-only" phone numbers (for simplicity).
|
||||
// See the readme for more info on what are "local-only" phone numbers.
|
||||
// case 'IS_POSSIBLE_LOCAL_ONLY':
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=extractNationalNumber.js.map
|
107
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js
generated
vendored
Normal file
107
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* Strips any national prefix (such as 0, 1) present in a
|
||||
* (possibly incomplete) number provided.
|
||||
* "Carrier codes" are only used in Colombia and Brazil,
|
||||
* and only when dialing within those countries from a mobile phone to a fixed line number.
|
||||
* Sometimes it won't actually strip national prefix
|
||||
* and will instead prepend some digits to the `number`:
|
||||
* for example, when number `2345678` is passed with `VI` country selected,
|
||||
* it will return `{ number: "3402345678" }`, because `340` area code is prepended.
|
||||
* @param {string} number — National number digits.
|
||||
* @param {object} metadata — Metadata with country selected.
|
||||
* @return {object} `{ nationalNumber: string, nationalPrefix: string? carrierCode: string? }`. Even if a national prefix was extracted, it's not necessarily present in the returned object, so don't rely on its presence in the returned object in order to find out whether a national prefix has been extracted or not.
|
||||
*/
|
||||
export default function extractNationalNumberFromPossiblyIncompleteNumber(number, metadata) {
|
||||
if (number && metadata.numberingPlan.nationalPrefixForParsing()) {
|
||||
// See METADATA.md for the description of
|
||||
// `national_prefix_for_parsing` and `national_prefix_transform_rule`.
|
||||
// Attempt to parse the first digits as a national prefix.
|
||||
var prefixPattern = new RegExp('^(?:' + metadata.numberingPlan.nationalPrefixForParsing() + ')');
|
||||
var prefixMatch = prefixPattern.exec(number);
|
||||
|
||||
if (prefixMatch) {
|
||||
var nationalNumber;
|
||||
var carrierCode; // https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/METADATA.md#national_prefix_for_parsing--national_prefix_transform_rule
|
||||
// If a `national_prefix_for_parsing` has any "capturing groups"
|
||||
// then it means that the national (significant) number is equal to
|
||||
// those "capturing groups" transformed via `national_prefix_transform_rule`,
|
||||
// and nothing could be said about the actual national prefix:
|
||||
// what is it and was it even there.
|
||||
// If a `national_prefix_for_parsing` doesn't have any "capturing groups",
|
||||
// then everything it matches is a national prefix.
|
||||
// To determine whether `national_prefix_for_parsing` matched any
|
||||
// "capturing groups", the value of the result of calling `.exec()`
|
||||
// is looked at, and if it has non-undefined values where there're
|
||||
// "capturing groups" in the regular expression, then it means
|
||||
// that "capturing groups" have been matched.
|
||||
// It's not possible to tell whether there'll be any "capturing gropus"
|
||||
// before the matching process, because a `national_prefix_for_parsing`
|
||||
// could exhibit both behaviors.
|
||||
|
||||
var capturedGroupsCount = prefixMatch.length - 1;
|
||||
var hasCapturedGroups = capturedGroupsCount > 0 && prefixMatch[capturedGroupsCount];
|
||||
|
||||
if (metadata.nationalPrefixTransformRule() && hasCapturedGroups) {
|
||||
nationalNumber = number.replace(prefixPattern, metadata.nationalPrefixTransformRule()); // If there's more than one captured group,
|
||||
// then carrier code is the second one.
|
||||
|
||||
if (capturedGroupsCount > 1) {
|
||||
carrierCode = prefixMatch[1];
|
||||
}
|
||||
} // If there're no "capturing groups",
|
||||
// or if there're "capturing groups" but no
|
||||
// `national_prefix_transform_rule`,
|
||||
// then just strip the national prefix from the number,
|
||||
// and possibly a carrier code.
|
||||
// Seems like there could be more.
|
||||
else {
|
||||
// `prefixBeforeNationalNumber` is the whole substring matched by
|
||||
// the `national_prefix_for_parsing` regular expression.
|
||||
// There seem to be no guarantees that it's just a national prefix.
|
||||
// For example, if there's a carrier code, it's gonna be a
|
||||
// part of `prefixBeforeNationalNumber` too.
|
||||
var prefixBeforeNationalNumber = prefixMatch[0];
|
||||
nationalNumber = number.slice(prefixBeforeNationalNumber.length); // If there's at least one captured group,
|
||||
// then carrier code is the first one.
|
||||
|
||||
if (hasCapturedGroups) {
|
||||
carrierCode = prefixMatch[1];
|
||||
}
|
||||
} // Tries to guess whether a national prefix was present in the input.
|
||||
// This is not something copy-pasted from Google's library:
|
||||
// they don't seem to have an equivalent for that.
|
||||
// So this isn't an "officially approved" way of doing something like that.
|
||||
// But since there seems no other existing method, this library uses it.
|
||||
|
||||
|
||||
var nationalPrefix;
|
||||
|
||||
if (hasCapturedGroups) {
|
||||
var possiblePositionOfTheFirstCapturedGroup = number.indexOf(prefixMatch[1]);
|
||||
var possibleNationalPrefix = number.slice(0, possiblePositionOfTheFirstCapturedGroup); // Example: an Argentinian (AR) phone number `0111523456789`.
|
||||
// `prefixMatch[0]` is `01115`, and `$1` is `11`,
|
||||
// and the rest of the phone number is `23456789`.
|
||||
// The national number is transformed via `9$1` to `91123456789`.
|
||||
// National prefix `0` is detected being present at the start.
|
||||
// if (possibleNationalPrefix.indexOf(metadata.numberingPlan.nationalPrefix()) === 0) {
|
||||
|
||||
if (possibleNationalPrefix === metadata.numberingPlan.nationalPrefix()) {
|
||||
nationalPrefix = metadata.numberingPlan.nationalPrefix();
|
||||
}
|
||||
} else {
|
||||
nationalPrefix = prefixMatch[0];
|
||||
}
|
||||
|
||||
return {
|
||||
nationalNumber: nationalNumber,
|
||||
nationalPrefix: nationalPrefix,
|
||||
carrierCode: carrierCode
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
nationalNumber: number
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=extractNationalNumberFromPossiblyIncompleteNumber.js.map
|
82
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js
generated
vendored
Normal file
82
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/extractPhoneContext.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
// When phone numbers are written in `RFC3966` format — `"tel:+12133734253"` —
|
||||
// they can have their "calling code" part written separately in a `phone-context` parameter.
|
||||
// Example: `"tel:12133734253;phone-context=+1"`.
|
||||
// This function parses the full phone number from the local number and the `phone-context`
|
||||
// when the `phone-context` contains a `+` sign.
|
||||
import { VALID_DIGITS // PLUS_CHARS
|
||||
} from '../constants.js';
|
||||
export var PLUS_SIGN = '+';
|
||||
var RFC3966_VISUAL_SEPARATOR_ = '[\\-\\.\\(\\)]?';
|
||||
var RFC3966_PHONE_DIGIT_ = '(' + '[' + VALID_DIGITS + ']' + '|' + RFC3966_VISUAL_SEPARATOR_ + ')';
|
||||
var RFC3966_GLOBAL_NUMBER_DIGITS_ = '^' + '\\' + PLUS_SIGN + RFC3966_PHONE_DIGIT_ + '*' + '[' + VALID_DIGITS + ']' + RFC3966_PHONE_DIGIT_ + '*' + '$';
|
||||
/**
|
||||
* Regular expression of valid global-number-digits for the phone-context
|
||||
* parameter, following the syntax defined in RFC3966.
|
||||
*/
|
||||
|
||||
var RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_ = new RegExp(RFC3966_GLOBAL_NUMBER_DIGITS_, 'g'); // In this port of Google's library, we don't accept alpha characters in phone numbers.
|
||||
// const ALPHANUM_ = VALID_ALPHA_ + VALID_DIGITS
|
||||
|
||||
var ALPHANUM_ = VALID_DIGITS;
|
||||
var RFC3966_DOMAINLABEL_ = '[' + ALPHANUM_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
|
||||
var VALID_ALPHA_ = 'a-zA-Z';
|
||||
var RFC3966_TOPLABEL_ = '[' + VALID_ALPHA_ + ']+((\\-)*[' + ALPHANUM_ + '])*';
|
||||
var RFC3966_DOMAINNAME_ = '^(' + RFC3966_DOMAINLABEL_ + '\\.)*' + RFC3966_TOPLABEL_ + '\\.?$';
|
||||
/**
|
||||
* Regular expression of valid domainname for the phone-context parameter,
|
||||
* following the syntax defined in RFC3966.
|
||||
*/
|
||||
|
||||
var RFC3966_DOMAINNAME_PATTERN_ = new RegExp(RFC3966_DOMAINNAME_, 'g');
|
||||
export var RFC3966_PREFIX_ = 'tel:';
|
||||
export var RFC3966_PHONE_CONTEXT_ = ';phone-context=';
|
||||
export var RFC3966_ISDN_SUBADDRESS_ = ';isub=';
|
||||
/**
|
||||
* Extracts the value of the phone-context parameter of `numberToExtractFrom`,
|
||||
* following the syntax defined in RFC3966.
|
||||
*
|
||||
* @param {string} numberToExtractFrom
|
||||
* @return {string|null} the extracted string (possibly empty), or `null` if no phone-context parameter is found.
|
||||
*/
|
||||
|
||||
export default function extractPhoneContext(numberToExtractFrom) {
|
||||
var indexOfPhoneContext = numberToExtractFrom.indexOf(RFC3966_PHONE_CONTEXT_); // If no phone-context parameter is present
|
||||
|
||||
if (indexOfPhoneContext < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT_.length; // If phone-context parameter is empty
|
||||
|
||||
if (phoneContextStart >= numberToExtractFrom.length) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var phoneContextEnd = numberToExtractFrom.indexOf(';', phoneContextStart); // If phone-context is not the last parameter
|
||||
|
||||
if (phoneContextEnd >= 0) {
|
||||
return numberToExtractFrom.substring(phoneContextStart, phoneContextEnd);
|
||||
} else {
|
||||
return numberToExtractFrom.substring(phoneContextStart);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns whether the value of phoneContext follows the syntax defined in RFC3966.
|
||||
*
|
||||
* @param {string|null} phoneContext
|
||||
* @return {boolean}
|
||||
*/
|
||||
|
||||
export function isPhoneContextValid(phoneContext) {
|
||||
if (phoneContext === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (phoneContext.length === 0) {
|
||||
return false;
|
||||
} // Does phone-context value match pattern of global-number-digits or domainname.
|
||||
|
||||
|
||||
return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.test(phoneContext) || RFC3966_DOMAINNAME_PATTERN_.test(phoneContext);
|
||||
}
|
||||
//# sourceMappingURL=extractPhoneContext.js.map
|
33
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js
generated
vendored
Normal file
33
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/formatNationalNumberUsingFormat.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import applyInternationalSeparatorStyle from './applyInternationalSeparatorStyle.js'; // This was originally set to $1 but there are some countries for which the
|
||||
// first group is not used in the national pattern (e.g. Argentina) so the $1
|
||||
// group does not match correctly. Therefore, we use `\d`, so that the first
|
||||
// group actually used in the pattern will be matched.
|
||||
|
||||
export var FIRST_GROUP_PATTERN = /(\$\d)/;
|
||||
export default function formatNationalNumberUsingFormat(number, format, _ref) {
|
||||
var useInternationalFormat = _ref.useInternationalFormat,
|
||||
withNationalPrefix = _ref.withNationalPrefix,
|
||||
carrierCode = _ref.carrierCode,
|
||||
metadata = _ref.metadata;
|
||||
var formattedNumber = number.replace(new RegExp(format.pattern()), useInternationalFormat ? format.internationalFormat() : // This library doesn't use `domestic_carrier_code_formatting_rule`,
|
||||
// because that one is only used when formatting phone numbers
|
||||
// for dialing from a mobile phone, and this is not a dialing library.
|
||||
// carrierCode && format.domesticCarrierCodeFormattingRule()
|
||||
// // First, replace the $CC in the formatting rule with the desired carrier code.
|
||||
// // Then, replace the $FG in the formatting rule with the first group
|
||||
// // and the carrier code combined in the appropriate way.
|
||||
// ? format.format().replace(FIRST_GROUP_PATTERN, format.domesticCarrierCodeFormattingRule().replace('$CC', carrierCode))
|
||||
// : (
|
||||
// withNationalPrefix && format.nationalPrefixFormattingRule()
|
||||
// ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule())
|
||||
// : format.format()
|
||||
// )
|
||||
withNationalPrefix && format.nationalPrefixFormattingRule() ? format.format().replace(FIRST_GROUP_PATTERN, format.nationalPrefixFormattingRule()) : format.format());
|
||||
|
||||
if (useInternationalFormat) {
|
||||
return applyInternationalSeparatorStyle(formattedNumber);
|
||||
}
|
||||
|
||||
return formattedNumber;
|
||||
}
|
||||
//# sourceMappingURL=formatNationalNumberUsingFormat.js.map
|
25
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js
generated
vendored
Normal file
25
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getCountryByCallingCode.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import getCountryByNationalNumber from './getCountryByNationalNumber.js';
|
||||
var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
|
||||
export default function getCountryByCallingCode(callingCode, nationalPhoneNumber, metadata) {
|
||||
/* istanbul ignore if */
|
||||
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
|
||||
if (metadata.isNonGeographicCallingCode(callingCode)) {
|
||||
return '001';
|
||||
}
|
||||
}
|
||||
|
||||
var possibleCountries = metadata.getCountryCodesForCallingCode(callingCode);
|
||||
|
||||
if (!possibleCountries) {
|
||||
return;
|
||||
} // If there's just one country corresponding to the country code,
|
||||
// then just return it, without further phone number digits validation.
|
||||
|
||||
|
||||
if (possibleCountries.length === 1) {
|
||||
return possibleCountries[0];
|
||||
}
|
||||
|
||||
return getCountryByNationalNumber(possibleCountries, nationalPhoneNumber, metadata.metadata);
|
||||
}
|
||||
//# sourceMappingURL=getCountryByCallingCode.js.map
|
35
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js
generated
vendored
Normal file
35
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getCountryByNationalNumber.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
import Metadata from '../metadata.js';
|
||||
import getNumberType from './getNumberType.js';
|
||||
export default function getCountryByNationalNumber(possibleCountries, nationalPhoneNumber, metadata) {
|
||||
// Re-create `metadata` because it will be selecting a `country`.
|
||||
metadata = new Metadata(metadata);
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(possibleCountries), _step; !(_step = _iterator()).done;) {
|
||||
var country = _step.value;
|
||||
metadata.country(country); // "Leading digits" patterns are only defined for about 20% of all countries.
|
||||
// By definition, matching "leading digits" is a sufficient but not a necessary
|
||||
// condition for a phone number to belong to a country.
|
||||
// The point of "leading digits" check is that it's the fastest one to get a match.
|
||||
// https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md#leading_digits
|
||||
|
||||
if (metadata.leadingDigits()) {
|
||||
if (nationalPhoneNumber && nationalPhoneNumber.search(metadata.leadingDigits()) === 0) {
|
||||
return country;
|
||||
}
|
||||
} // Else perform full validation with all of those
|
||||
// fixed-line/mobile/etc regular expressions.
|
||||
else if (getNumberType({
|
||||
phone: nationalPhoneNumber,
|
||||
country: country
|
||||
}, undefined, metadata.metadata)) {
|
||||
return country;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=getCountryByNationalNumber.js.map
|
27
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js
generated
vendored
Normal file
27
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getIddPrefix.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import Metadata from '../metadata.js';
|
||||
/**
|
||||
* Pattern that makes it easy to distinguish whether a region has a single
|
||||
* international dialing prefix or not. If a region has a single international
|
||||
* prefix (e.g. 011 in USA), it will be represented as a string that contains
|
||||
* a sequence of ASCII digits, and possibly a tilde, which signals waiting for
|
||||
* the tone. If there are multiple available international prefixes in a
|
||||
* region, they will be represented as a regex string that always contains one
|
||||
* or more characters that are not ASCII digits or a tilde.
|
||||
*/
|
||||
|
||||
var SINGLE_IDD_PREFIX_REG_EXP = /^[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?$/; // For regions that have multiple IDD prefixes
|
||||
// a preferred IDD prefix is returned.
|
||||
|
||||
export default function getIddPrefix(country, callingCode, metadata) {
|
||||
var countryMetadata = new Metadata(metadata);
|
||||
countryMetadata.selectNumberingPlan(country, callingCode);
|
||||
|
||||
if (countryMetadata.defaultIDDPrefix()) {
|
||||
return countryMetadata.defaultIDDPrefix();
|
||||
}
|
||||
|
||||
if (SINGLE_IDD_PREFIX_REG_EXP.test(countryMetadata.IDDPrefix())) {
|
||||
return countryMetadata.IDDPrefix();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=getIddPrefix.js.map
|
90
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getNumberType.js
generated
vendored
Normal file
90
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getNumberType.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
import Metadata from '../metadata.js';
|
||||
import matchesEntirely from './matchesEntirely.js';
|
||||
var NON_FIXED_LINE_PHONE_TYPES = ['MOBILE', 'PREMIUM_RATE', 'TOLL_FREE', 'SHARED_COST', 'VOIP', 'PERSONAL_NUMBER', 'PAGER', 'UAN', 'VOICEMAIL']; // Finds out national phone number type (fixed line, mobile, etc)
|
||||
|
||||
export default function getNumberType(input, options, metadata) {
|
||||
// If assigning the `{}` default value is moved to the arguments above,
|
||||
// code coverage would decrease for some weird reason.
|
||||
options = options || {}; // When `parse()` returned `{}`
|
||||
// meaning that the phone number is not a valid one.
|
||||
|
||||
if (!input.country) {
|
||||
return;
|
||||
}
|
||||
|
||||
metadata = new Metadata(metadata);
|
||||
metadata.selectNumberingPlan(input.country, input.countryCallingCode);
|
||||
var nationalNumber = options.v2 ? input.nationalNumber : input.phone; // The following is copy-pasted from the original function:
|
||||
// https://github.com/googlei18n/libphonenumber/blob/3ea547d4fbaa2d0b67588904dfa5d3f2557c27ff/javascript/i18n/phonenumbers/phonenumberutil.js#L2835
|
||||
// Is this national number even valid for this country
|
||||
|
||||
if (!matchesEntirely(nationalNumber, metadata.nationalNumberPattern())) {
|
||||
return;
|
||||
} // Is it fixed line number
|
||||
|
||||
|
||||
if (isNumberTypeEqualTo(nationalNumber, 'FIXED_LINE', metadata)) {
|
||||
// Because duplicate regular expressions are removed
|
||||
// to reduce metadata size, if "mobile" pattern is ""
|
||||
// then it means it was removed due to being a duplicate of the fixed-line pattern.
|
||||
//
|
||||
if (metadata.type('MOBILE') && metadata.type('MOBILE').pattern() === '') {
|
||||
return 'FIXED_LINE_OR_MOBILE';
|
||||
} // `MOBILE` type pattern isn't included if it matched `FIXED_LINE` one.
|
||||
// For example, for "US" country.
|
||||
// Old metadata (< `1.0.18`) had a specific "types" data structure
|
||||
// that happened to be `undefined` for `MOBILE` in that case.
|
||||
// Newer metadata (>= `1.0.18`) has another data structure that is
|
||||
// not `undefined` for `MOBILE` in that case (it's just an empty array).
|
||||
// So this `if` is just for backwards compatibility with old metadata.
|
||||
|
||||
|
||||
if (!metadata.type('MOBILE')) {
|
||||
return 'FIXED_LINE_OR_MOBILE';
|
||||
} // Check if the number happens to qualify as both fixed line and mobile.
|
||||
// (no such country in the minimal metadata set)
|
||||
|
||||
/* istanbul ignore if */
|
||||
|
||||
|
||||
if (isNumberTypeEqualTo(nationalNumber, 'MOBILE', metadata)) {
|
||||
return 'FIXED_LINE_OR_MOBILE';
|
||||
}
|
||||
|
||||
return 'FIXED_LINE';
|
||||
}
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
|
||||
var type = _step.value;
|
||||
|
||||
if (isNumberTypeEqualTo(nationalNumber, type, metadata)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
export function isNumberTypeEqualTo(nationalNumber, type, metadata) {
|
||||
type = metadata.type(type);
|
||||
|
||||
if (!type || !type.pattern()) {
|
||||
return false;
|
||||
} // Check if any possible number lengths are present;
|
||||
// if so, we use them to avoid checking
|
||||
// the validation pattern if they don't match.
|
||||
// If they are absent, this means they match
|
||||
// the general description, which we have
|
||||
// already checked before a specific number type.
|
||||
|
||||
|
||||
if (type.possibleLengths() && type.possibleLengths().indexOf(nationalNumber.length) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return matchesEntirely(nationalNumber, type.pattern());
|
||||
}
|
||||
//# sourceMappingURL=getNumberType.js.map
|
35
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js
generated
vendored
Normal file
35
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/getPossibleCountriesForNumber.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import Metadata from '../metadata.js';
|
||||
/**
|
||||
* Returns a list of countries that the phone number could potentially belong to.
|
||||
* @param {string} callingCode — Calling code.
|
||||
* @param {string} nationalNumber — National (significant) number.
|
||||
* @param {object} metadata — Metadata.
|
||||
* @return {string[]} A list of possible countries.
|
||||
*/
|
||||
|
||||
export default function getPossibleCountriesForNumber(callingCode, nationalNumber, metadata) {
|
||||
var _metadata = new Metadata(metadata);
|
||||
|
||||
var possibleCountries = _metadata.getCountryCodesForCallingCode(callingCode);
|
||||
|
||||
if (!possibleCountries) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return possibleCountries.filter(function (country) {
|
||||
return couldNationalNumberBelongToCountry(nationalNumber, country, metadata);
|
||||
});
|
||||
}
|
||||
|
||||
function couldNationalNumberBelongToCountry(nationalNumber, country, metadata) {
|
||||
var _metadata = new Metadata(metadata);
|
||||
|
||||
_metadata.selectNumberingPlan(country);
|
||||
|
||||
if (_metadata.numberingPlan.possibleLengths().indexOf(nationalNumber.length) >= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
//# sourceMappingURL=getPossibleCountriesForNumber.js.map
|
69
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js
generated
vendored
Normal file
69
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/isViablePhoneNumber.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import { MIN_LENGTH_FOR_NSN, VALID_DIGITS, VALID_PUNCTUATION, PLUS_CHARS } from '../constants.js';
|
||||
import createExtensionPattern from './extension/createExtensionPattern.js'; // Regular expression of viable phone numbers. This is location independent.
|
||||
// Checks we have at least three leading digits, and only valid punctuation,
|
||||
// alpha characters and digits in the phone number. Does not include extension
|
||||
// data. The symbol 'x' is allowed here as valid punctuation since it is often
|
||||
// used as a placeholder for carrier codes, for example in Brazilian phone
|
||||
// numbers. We also allow multiple '+' characters at the start.
|
||||
//
|
||||
// Corresponds to the following:
|
||||
// [digits]{minLengthNsn}|
|
||||
// plus_sign*
|
||||
// (([punctuation]|[star])*[digits]){3,}([punctuation]|[star]|[digits]|[alpha])*
|
||||
//
|
||||
// The first reg-ex is to allow short numbers (two digits long) to be parsed if
|
||||
// they are entered as "15" etc, but only if there is no punctuation in them.
|
||||
// The second expression restricts the number of digits to three or more, but
|
||||
// then allows them to be in international form, and to have alpha-characters
|
||||
// and punctuation. We split up the two reg-exes here and combine them when
|
||||
// creating the reg-ex VALID_PHONE_NUMBER_PATTERN itself so we can prefix it
|
||||
// with ^ and append $ to each branch.
|
||||
//
|
||||
// "Note VALID_PUNCTUATION starts with a -,
|
||||
// so must be the first in the range" (c) Google devs.
|
||||
// (wtf did they mean by saying that; probably nothing)
|
||||
//
|
||||
|
||||
var MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'; //
|
||||
// And this is the second reg-exp:
|
||||
// (see MIN_LENGTH_PHONE_NUMBER_PATTERN for a full description of this reg-exp)
|
||||
//
|
||||
|
||||
export var VALID_PHONE_NUMBER = '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){3,}' + '[' + VALID_PUNCTUATION + VALID_DIGITS + ']*'; // This regular expression isn't present in Google's `libphonenumber`
|
||||
// and is only used to determine whether the phone number being input
|
||||
// is too short for it to even consider it a "valid" number.
|
||||
// This is just a way to differentiate between a really invalid phone
|
||||
// number like "abcde" and a valid phone number that a user has just
|
||||
// started inputting, like "+1" or "1": both these cases would be
|
||||
// considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
|
||||
// library can provide a more detailed error message — whether it's
|
||||
// really "not a number", or is it just a start of a valid phone number.
|
||||
|
||||
var VALID_PHONE_NUMBER_START_REG_EXP = new RegExp('^' + '[' + PLUS_CHARS + ']{0,1}' + '(?:' + '[' + VALID_PUNCTUATION + ']*' + '[' + VALID_DIGITS + ']' + '){1,2}' + '$', 'i');
|
||||
export var VALID_PHONE_NUMBER_WITH_EXTENSION = VALID_PHONE_NUMBER + // Phone number extensions
|
||||
'(?:' + createExtensionPattern() + ')?'; // The combined regular expression for valid phone numbers:
|
||||
//
|
||||
|
||||
var VALID_PHONE_NUMBER_PATTERN = new RegExp( // Either a short two-digit-only phone number
|
||||
'^' + MIN_LENGTH_PHONE_NUMBER_PATTERN + '$' + '|' + // Or a longer fully parsed phone number (min 3 characters)
|
||||
'^' + VALID_PHONE_NUMBER_WITH_EXTENSION + '$', 'i'); // Checks to see if the string of characters could possibly be a phone number at
|
||||
// all. At the moment, checks to see that the string begins with at least 2
|
||||
// digits, ignoring any punctuation commonly found in phone numbers. This method
|
||||
// does not require the number to be normalized in advance - but does assume
|
||||
// that leading non-number symbols have been removed, such as by the method
|
||||
// `extract_possible_number`.
|
||||
//
|
||||
|
||||
export default function isViablePhoneNumber(number) {
|
||||
return number.length >= MIN_LENGTH_FOR_NSN && VALID_PHONE_NUMBER_PATTERN.test(number);
|
||||
} // This is just a way to differentiate between a really invalid phone
|
||||
// number like "abcde" and a valid phone number that a user has just
|
||||
// started inputting, like "+1" or "1": both these cases would be
|
||||
// considered `NOT_A_NUMBER` by Google's `libphonenumber`, but this
|
||||
// library can provide a more detailed error message — whether it's
|
||||
// really "not a number", or is it just a start of a valid phone number.
|
||||
|
||||
export function isViablePhoneNumberStart(number) {
|
||||
return VALID_PHONE_NUMBER_START_REG_EXP.test(number);
|
||||
}
|
||||
//# sourceMappingURL=isViablePhoneNumber.js.map
|
12
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js
generated
vendored
Normal file
12
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/matchesEntirely.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Checks whether the entire input sequence can be matched
|
||||
* against the regular expression.
|
||||
* @return {boolean}
|
||||
*/
|
||||
export default function matchesEntirely(text, regular_expression) {
|
||||
// If assigning the `''` default value is moved to the arguments above,
|
||||
// code coverage would decrease for some weird reason.
|
||||
text = text || '';
|
||||
return new RegExp('^(?:' + regular_expression + ')$').test(text);
|
||||
}
|
||||
//# sourceMappingURL=matchesEntirely.js.map
|
33
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/mergeArrays.js
generated
vendored
Normal file
33
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/mergeArrays.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
/**
|
||||
* Merges two arrays.
|
||||
* @param {*} a
|
||||
* @param {*} b
|
||||
* @return {*}
|
||||
*/
|
||||
export default function mergeArrays(a, b) {
|
||||
var merged = a.slice();
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(b), _step; !(_step = _iterator()).done;) {
|
||||
var element = _step.value;
|
||||
|
||||
if (a.indexOf(element) < 0) {
|
||||
merged.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
return merged.sort(function (a, b) {
|
||||
return a - b;
|
||||
}); // ES6 version, requires Set polyfill.
|
||||
// let merged = new Set(a)
|
||||
// for (const element of b) {
|
||||
// merged.add(i)
|
||||
// }
|
||||
// return Array.from(merged).sort((a, b) => a - b)
|
||||
}
|
||||
//# sourceMappingURL=mergeArrays.js.map
|
121
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/parseDigits.js
generated
vendored
Normal file
121
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/parseDigits.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
// These mappings map a character (key) to a specific digit that should
|
||||
// replace it for normalization purposes. Non-European digits that
|
||||
// may be used in phone numbers are mapped to a European equivalent.
|
||||
//
|
||||
// E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
|
||||
//
|
||||
export var DIGITS = {
|
||||
'0': '0',
|
||||
'1': '1',
|
||||
'2': '2',
|
||||
'3': '3',
|
||||
'4': '4',
|
||||
'5': '5',
|
||||
'6': '6',
|
||||
'7': '7',
|
||||
'8': '8',
|
||||
'9': '9',
|
||||
"\uFF10": '0',
|
||||
// Fullwidth digit 0
|
||||
"\uFF11": '1',
|
||||
// Fullwidth digit 1
|
||||
"\uFF12": '2',
|
||||
// Fullwidth digit 2
|
||||
"\uFF13": '3',
|
||||
// Fullwidth digit 3
|
||||
"\uFF14": '4',
|
||||
// Fullwidth digit 4
|
||||
"\uFF15": '5',
|
||||
// Fullwidth digit 5
|
||||
"\uFF16": '6',
|
||||
// Fullwidth digit 6
|
||||
"\uFF17": '7',
|
||||
// Fullwidth digit 7
|
||||
"\uFF18": '8',
|
||||
// Fullwidth digit 8
|
||||
"\uFF19": '9',
|
||||
// Fullwidth digit 9
|
||||
"\u0660": '0',
|
||||
// Arabic-indic digit 0
|
||||
"\u0661": '1',
|
||||
// Arabic-indic digit 1
|
||||
"\u0662": '2',
|
||||
// Arabic-indic digit 2
|
||||
"\u0663": '3',
|
||||
// Arabic-indic digit 3
|
||||
"\u0664": '4',
|
||||
// Arabic-indic digit 4
|
||||
"\u0665": '5',
|
||||
// Arabic-indic digit 5
|
||||
"\u0666": '6',
|
||||
// Arabic-indic digit 6
|
||||
"\u0667": '7',
|
||||
// Arabic-indic digit 7
|
||||
"\u0668": '8',
|
||||
// Arabic-indic digit 8
|
||||
"\u0669": '9',
|
||||
// Arabic-indic digit 9
|
||||
"\u06F0": '0',
|
||||
// Eastern-Arabic digit 0
|
||||
"\u06F1": '1',
|
||||
// Eastern-Arabic digit 1
|
||||
"\u06F2": '2',
|
||||
// Eastern-Arabic digit 2
|
||||
"\u06F3": '3',
|
||||
// Eastern-Arabic digit 3
|
||||
"\u06F4": '4',
|
||||
// Eastern-Arabic digit 4
|
||||
"\u06F5": '5',
|
||||
// Eastern-Arabic digit 5
|
||||
"\u06F6": '6',
|
||||
// Eastern-Arabic digit 6
|
||||
"\u06F7": '7',
|
||||
// Eastern-Arabic digit 7
|
||||
"\u06F8": '8',
|
||||
// Eastern-Arabic digit 8
|
||||
"\u06F9": '9' // Eastern-Arabic digit 9
|
||||
|
||||
};
|
||||
export function parseDigit(character) {
|
||||
return DIGITS[character];
|
||||
}
|
||||
/**
|
||||
* Parses phone number digits from a string.
|
||||
* Drops all punctuation leaving only digits.
|
||||
* Also converts wide-ascii and arabic-indic numerals to conventional numerals.
|
||||
* E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
|
||||
* @param {string} string
|
||||
* @return {string}
|
||||
* @example
|
||||
* ```js
|
||||
* parseDigits('8 (800) 555')
|
||||
* // Outputs '8800555'.
|
||||
* ```
|
||||
*/
|
||||
|
||||
export default function parseDigits(string) {
|
||||
var result = ''; // Using `.split('')` here instead of normal `for ... of`
|
||||
// because the importing application doesn't neccessarily include an ES6 polyfill.
|
||||
// The `.split('')` approach discards "exotic" UTF-8 characters
|
||||
// (the ones consisting of four bytes) but digits
|
||||
// (including non-European ones) don't fall into that range
|
||||
// so such "exotic" characters would be discarded anyway.
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(string.split('')), _step; !(_step = _iterator()).done;) {
|
||||
var character = _step.value;
|
||||
var digit = parseDigit(character);
|
||||
|
||||
if (digit) {
|
||||
result += digit;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
//# sourceMappingURL=parseDigits.js.map
|
34
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js
generated
vendored
Normal file
34
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/helpers/stripIddPrefix.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import Metadata from '../metadata.js';
|
||||
import { VALID_DIGITS } from '../constants.js';
|
||||
var CAPTURING_DIGIT_PATTERN = new RegExp('([' + VALID_DIGITS + '])');
|
||||
export default function stripIddPrefix(number, country, callingCode, metadata) {
|
||||
if (!country) {
|
||||
return;
|
||||
} // Check if the number is IDD-prefixed.
|
||||
|
||||
|
||||
var countryMetadata = new Metadata(metadata);
|
||||
countryMetadata.selectNumberingPlan(country, callingCode);
|
||||
var IDDPrefixPattern = new RegExp(countryMetadata.IDDPrefix());
|
||||
|
||||
if (number.search(IDDPrefixPattern) !== 0) {
|
||||
return;
|
||||
} // Strip IDD prefix.
|
||||
|
||||
|
||||
number = number.slice(number.match(IDDPrefixPattern)[0].length); // If there're any digits after an IDD prefix,
|
||||
// then those digits are a country calling code.
|
||||
// Since no country code starts with a `0`,
|
||||
// the code below validates that the next digit (if present) is not `0`.
|
||||
|
||||
var matchedGroups = number.match(CAPTURING_DIGIT_PATTERN);
|
||||
|
||||
if (matchedGroups && matchedGroups[1] != null && matchedGroups[1].length > 0) {
|
||||
if (matchedGroups[1] === '0') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return number;
|
||||
}
|
||||
//# sourceMappingURL=stripIddPrefix.js.map
|
84
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/isPossible.js
generated
vendored
Normal file
84
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/isPossible.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
import Metadata from './metadata.js';
|
||||
import checkNumberLength from './helpers/checkNumberLength.js';
|
||||
/**
|
||||
* Checks if a phone number is "possible" (basically just checks its length).
|
||||
*
|
||||
* isPossible(phoneNumberInstance, { ..., v2: true }, metadata)
|
||||
*
|
||||
* isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
|
||||
* isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
|
||||
*
|
||||
* @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
|
||||
* @param {object} [options]
|
||||
* @param {object} metadata
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
export default function isPossiblePhoneNumber(input, options, metadata) {
|
||||
/* istanbul ignore if */
|
||||
if (options === undefined) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
metadata = new Metadata(metadata);
|
||||
|
||||
if (options.v2) {
|
||||
if (!input.countryCallingCode) {
|
||||
throw new Error('Invalid phone number object passed');
|
||||
}
|
||||
|
||||
metadata.selectNumberingPlan(input.countryCallingCode);
|
||||
} else {
|
||||
if (!input.phone) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input.country) {
|
||||
if (!metadata.hasCountry(input.country)) {
|
||||
throw new Error("Unknown country: ".concat(input.country));
|
||||
}
|
||||
|
||||
metadata.country(input.country);
|
||||
} else {
|
||||
if (!input.countryCallingCode) {
|
||||
throw new Error('Invalid phone number object passed');
|
||||
}
|
||||
|
||||
metadata.selectNumberingPlan(input.countryCallingCode);
|
||||
}
|
||||
} // Old metadata (< 1.0.18) had no "possible length" data.
|
||||
|
||||
|
||||
if (metadata.possibleLengths()) {
|
||||
return isPossibleNumber(input.phone || input.nationalNumber, metadata);
|
||||
} else {
|
||||
// There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
|
||||
// were missing for "non-geographical" numbering plans.
|
||||
// Just assume the number is possible in such cases:
|
||||
// it's unlikely that anyone generated their custom metadata
|
||||
// in that short period of time (one day).
|
||||
// This code can be removed in some future major version update.
|
||||
if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
|
||||
// "Non-geographic entities" did't have `possibleLengths`
|
||||
// due to a bug in metadata generation process.
|
||||
return true;
|
||||
} else {
|
||||
throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
|
||||
}
|
||||
}
|
||||
}
|
||||
export function isPossibleNumber(nationalNumber, metadata) {
|
||||
//, isInternational) {
|
||||
switch (checkNumberLength(nationalNumber, metadata)) {
|
||||
case 'IS_POSSIBLE':
|
||||
return true;
|
||||
// This library ignores "local-only" phone numbers (for simplicity).
|
||||
// See the readme for more info on what are "local-only" phone numbers.
|
||||
// case 'IS_POSSIBLE_LOCAL_ONLY':
|
||||
// return !isInternational
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=isPossible.js.map
|
65
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/isValid.js
generated
vendored
Normal file
65
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/isValid.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import Metadata from './metadata.js';
|
||||
import matchesEntirely from './helpers/matchesEntirely.js';
|
||||
import getNumberType from './helpers/getNumberType.js';
|
||||
/**
|
||||
* Checks if a given phone number is valid.
|
||||
*
|
||||
* isValid(phoneNumberInstance, { ..., v2: true }, metadata)
|
||||
*
|
||||
* isPossible({ phone: '8005553535', country: 'RU' }, { ... }, metadata)
|
||||
* isPossible({ phone: '8005553535', country: 'RU' }, undefined, metadata)
|
||||
*
|
||||
* If the `number` is a string, it will be parsed to an object,
|
||||
* but only if it contains only valid phone number characters (including punctuation).
|
||||
* If the `number` is an object, it is used as is.
|
||||
*
|
||||
* The optional `defaultCountry` argument is the default country.
|
||||
* I.e. it does not restrict to just that country,
|
||||
* e.g. in those cases where several countries share
|
||||
* the same phone numbering rules (NANPA, Britain, etc).
|
||||
* For example, even though the number `07624 369230`
|
||||
* belongs to the Isle of Man ("IM" country code)
|
||||
* calling `isValidNumber('07624369230', 'GB', metadata)`
|
||||
* still returns `true` because the country is not restricted to `GB`,
|
||||
* it's just that `GB` is the default one for the phone numbering rules.
|
||||
* For restricting the country see `isValidNumberForRegion()`
|
||||
* though restricting a country might not be a good idea.
|
||||
* https://github.com/googlei18n/libphonenumber/blob/master/FAQ.md#when-should-i-use-isvalidnumberforregion
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* ```js
|
||||
* isValidNumber('+78005553535', metadata)
|
||||
* isValidNumber('8005553535', 'RU', metadata)
|
||||
* isValidNumber('88005553535', 'RU', metadata)
|
||||
* isValidNumber({ phone: '8005553535', country: 'RU' }, metadata)
|
||||
* ```
|
||||
*/
|
||||
|
||||
export default function isValidNumber(input, options, metadata) {
|
||||
// If assigning the `{}` default value is moved to the arguments above,
|
||||
// code coverage would decrease for some weird reason.
|
||||
options = options || {};
|
||||
metadata = new Metadata(metadata);
|
||||
/**
|
||||
* Checks if a phone number is "possible" (basically just checks its length).
|
||||
*
|
||||
* @param {object|PhoneNumber} input — If `options.v2: true` flag is passed, the `input` should be a `PhoneNumber` instance. Otherwise, it should be an object of shape `{ phone: '...', country: '...' }`.
|
||||
* @param {object} [options]
|
||||
* @param {object} metadata
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
metadata.selectNumberingPlan(input.country, input.countryCallingCode); // By default, countries only have type regexps when it's required for
|
||||
// distinguishing different countries having the same `countryCallingCode`.
|
||||
|
||||
if (metadata.hasTypes()) {
|
||||
return getNumberType(input, options, metadata.metadata) !== undefined;
|
||||
} // If there are no type regexps for this country in metadata then use
|
||||
// `nationalNumberPattern` as a "better than nothing" replacement.
|
||||
|
||||
|
||||
var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
|
||||
return matchesEntirely(nationalNumber, metadata.nationalNumberPattern());
|
||||
}
|
||||
//# sourceMappingURL=isValid.js.map
|
662
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/metadata.js
generated
vendored
Normal file
662
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/metadata.js
generated
vendored
Normal file
@@ -0,0 +1,662 @@
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
|
||||
import compare from './tools/semver-compare.js'; // Added "possibleLengths" and renamed
|
||||
// "country_phone_code_to_countries" to "country_calling_codes".
|
||||
|
||||
var V2 = '1.0.18'; // Added "idd_prefix" and "default_idd_prefix".
|
||||
|
||||
var V3 = '1.2.0'; // Moved `001` country code to "nonGeographic" section of metadata.
|
||||
|
||||
var V4 = '1.7.35';
|
||||
var DEFAULT_EXT_PREFIX = ' ext. ';
|
||||
var CALLING_CODE_REG_EXP = /^\d+$/;
|
||||
/**
|
||||
* See: https://gitlab.com/catamphetamine/libphonenumber-js/blob/master/METADATA.md
|
||||
*/
|
||||
|
||||
var Metadata = /*#__PURE__*/function () {
|
||||
function Metadata(metadata) {
|
||||
_classCallCheck(this, Metadata);
|
||||
|
||||
validateMetadata(metadata);
|
||||
this.metadata = metadata;
|
||||
setVersion.call(this, metadata);
|
||||
}
|
||||
|
||||
_createClass(Metadata, [{
|
||||
key: "getCountries",
|
||||
value: function getCountries() {
|
||||
return Object.keys(this.metadata.countries).filter(function (_) {
|
||||
return _ !== '001';
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "getCountryMetadata",
|
||||
value: function getCountryMetadata(countryCode) {
|
||||
return this.metadata.countries[countryCode];
|
||||
}
|
||||
}, {
|
||||
key: "nonGeographic",
|
||||
value: function nonGeographic() {
|
||||
if (this.v1 || this.v2 || this.v3) return; // `nonGeographical` was a typo.
|
||||
// It's present in metadata generated from `1.7.35` to `1.7.37`.
|
||||
// The test case could be found by searching for "nonGeographical".
|
||||
|
||||
return this.metadata.nonGeographic || this.metadata.nonGeographical;
|
||||
}
|
||||
}, {
|
||||
key: "hasCountry",
|
||||
value: function hasCountry(country) {
|
||||
return this.getCountryMetadata(country) !== undefined;
|
||||
}
|
||||
}, {
|
||||
key: "hasCallingCode",
|
||||
value: function hasCallingCode(callingCode) {
|
||||
if (this.getCountryCodesForCallingCode(callingCode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.nonGeographic()) {
|
||||
if (this.nonGeographic()[callingCode]) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// A hacky workaround for old custom metadata (generated before V4).
|
||||
var countryCodes = this.countryCallingCodes()[callingCode];
|
||||
|
||||
if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "isNonGeographicCallingCode",
|
||||
value: function isNonGeographicCallingCode(callingCode) {
|
||||
if (this.nonGeographic()) {
|
||||
return this.nonGeographic()[callingCode] ? true : false;
|
||||
} else {
|
||||
return this.getCountryCodesForCallingCode(callingCode) ? false : true;
|
||||
}
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "country",
|
||||
value: function country(countryCode) {
|
||||
return this.selectNumberingPlan(countryCode);
|
||||
}
|
||||
}, {
|
||||
key: "selectNumberingPlan",
|
||||
value: function selectNumberingPlan(countryCode, callingCode) {
|
||||
// Supports just passing `callingCode` as the first argument.
|
||||
if (countryCode && CALLING_CODE_REG_EXP.test(countryCode)) {
|
||||
callingCode = countryCode;
|
||||
countryCode = null;
|
||||
}
|
||||
|
||||
if (countryCode && countryCode !== '001') {
|
||||
if (!this.hasCountry(countryCode)) {
|
||||
throw new Error("Unknown country: ".concat(countryCode));
|
||||
}
|
||||
|
||||
this.numberingPlan = new NumberingPlan(this.getCountryMetadata(countryCode), this);
|
||||
} else if (callingCode) {
|
||||
if (!this.hasCallingCode(callingCode)) {
|
||||
throw new Error("Unknown calling code: ".concat(callingCode));
|
||||
}
|
||||
|
||||
this.numberingPlan = new NumberingPlan(this.getNumberingPlanMetadata(callingCode), this);
|
||||
} else {
|
||||
this.numberingPlan = undefined;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "getCountryCodesForCallingCode",
|
||||
value: function getCountryCodesForCallingCode(callingCode) {
|
||||
var countryCodes = this.countryCallingCodes()[callingCode];
|
||||
|
||||
if (countryCodes) {
|
||||
// Metadata before V4 included "non-geographic entity" calling codes
|
||||
// inside `country_calling_codes` (for example, `"881":["001"]`).
|
||||
// Now the semantics of `country_calling_codes` has changed:
|
||||
// it's specifically for "countries" now.
|
||||
// Older versions of custom metadata will simply skip parsing
|
||||
// "non-geographic entity" phone numbers with new versions
|
||||
// of this library: it's not considered a bug,
|
||||
// because such numbers are extremely rare,
|
||||
// and developers extremely rarely use custom metadata.
|
||||
if (countryCodes.length === 1 && countryCodes[0].length === 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
return countryCodes;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getCountryCodeForCallingCode",
|
||||
value: function getCountryCodeForCallingCode(callingCode) {
|
||||
var countryCodes = this.getCountryCodesForCallingCode(callingCode);
|
||||
|
||||
if (countryCodes) {
|
||||
return countryCodes[0];
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "getNumberingPlanMetadata",
|
||||
value: function getNumberingPlanMetadata(callingCode) {
|
||||
var countryCode = this.getCountryCodeForCallingCode(callingCode);
|
||||
|
||||
if (countryCode) {
|
||||
return this.getCountryMetadata(countryCode);
|
||||
}
|
||||
|
||||
if (this.nonGeographic()) {
|
||||
var metadata = this.nonGeographic()[callingCode];
|
||||
|
||||
if (metadata) {
|
||||
return metadata;
|
||||
}
|
||||
} else {
|
||||
// A hacky workaround for old custom metadata (generated before V4).
|
||||
// In that metadata, there was no concept of "non-geographic" metadata
|
||||
// so metadata for `001` country code was stored along with other countries.
|
||||
// The test case can be found by searching for:
|
||||
// "should work around `nonGeographic` metadata not existing".
|
||||
var countryCodes = this.countryCallingCodes()[callingCode];
|
||||
|
||||
if (countryCodes && countryCodes.length === 1 && countryCodes[0] === '001') {
|
||||
return this.metadata.countries['001'];
|
||||
}
|
||||
}
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "countryCallingCode",
|
||||
value: function countryCallingCode() {
|
||||
return this.numberingPlan.callingCode();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "IDDPrefix",
|
||||
value: function IDDPrefix() {
|
||||
return this.numberingPlan.IDDPrefix();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "defaultIDDPrefix",
|
||||
value: function defaultIDDPrefix() {
|
||||
return this.numberingPlan.defaultIDDPrefix();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "nationalNumberPattern",
|
||||
value: function nationalNumberPattern() {
|
||||
return this.numberingPlan.nationalNumberPattern();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "possibleLengths",
|
||||
value: function possibleLengths() {
|
||||
return this.numberingPlan.possibleLengths();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "formats",
|
||||
value: function formats() {
|
||||
return this.numberingPlan.formats();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "nationalPrefixForParsing",
|
||||
value: function nationalPrefixForParsing() {
|
||||
return this.numberingPlan.nationalPrefixForParsing();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "nationalPrefixTransformRule",
|
||||
value: function nationalPrefixTransformRule() {
|
||||
return this.numberingPlan.nationalPrefixTransformRule();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "leadingDigits",
|
||||
value: function leadingDigits() {
|
||||
return this.numberingPlan.leadingDigits();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "hasTypes",
|
||||
value: function hasTypes() {
|
||||
return this.numberingPlan.hasTypes();
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "type",
|
||||
value: function type(_type) {
|
||||
return this.numberingPlan.type(_type);
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "ext",
|
||||
value: function ext() {
|
||||
return this.numberingPlan.ext();
|
||||
}
|
||||
}, {
|
||||
key: "countryCallingCodes",
|
||||
value: function countryCallingCodes() {
|
||||
if (this.v1) return this.metadata.country_phone_code_to_countries;
|
||||
return this.metadata.country_calling_codes;
|
||||
} // Deprecated.
|
||||
|
||||
}, {
|
||||
key: "chooseCountryByCountryCallingCode",
|
||||
value: function chooseCountryByCountryCallingCode(callingCode) {
|
||||
return this.selectNumberingPlan(callingCode);
|
||||
}
|
||||
}, {
|
||||
key: "hasSelectedNumberingPlan",
|
||||
value: function hasSelectedNumberingPlan() {
|
||||
return this.numberingPlan !== undefined;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Metadata;
|
||||
}();
|
||||
|
||||
export { Metadata as default };
|
||||
|
||||
var NumberingPlan = /*#__PURE__*/function () {
|
||||
function NumberingPlan(metadata, globalMetadataObject) {
|
||||
_classCallCheck(this, NumberingPlan);
|
||||
|
||||
this.globalMetadataObject = globalMetadataObject;
|
||||
this.metadata = metadata;
|
||||
setVersion.call(this, globalMetadataObject.metadata);
|
||||
}
|
||||
|
||||
_createClass(NumberingPlan, [{
|
||||
key: "callingCode",
|
||||
value: function callingCode() {
|
||||
return this.metadata[0];
|
||||
} // Formatting information for regions which share
|
||||
// a country calling code is contained by only one region
|
||||
// for performance reasons. For example, for NANPA region
|
||||
// ("North American Numbering Plan Administration",
|
||||
// which includes USA, Canada, Cayman Islands, Bahamas, etc)
|
||||
// it will be contained in the metadata for `US`.
|
||||
|
||||
}, {
|
||||
key: "getDefaultCountryMetadataForRegion",
|
||||
value: function getDefaultCountryMetadataForRegion() {
|
||||
return this.globalMetadataObject.getNumberingPlanMetadata(this.callingCode());
|
||||
} // Is always present.
|
||||
|
||||
}, {
|
||||
key: "IDDPrefix",
|
||||
value: function IDDPrefix() {
|
||||
if (this.v1 || this.v2) return;
|
||||
return this.metadata[1];
|
||||
} // Is only present when a country supports multiple IDD prefixes.
|
||||
|
||||
}, {
|
||||
key: "defaultIDDPrefix",
|
||||
value: function defaultIDDPrefix() {
|
||||
if (this.v1 || this.v2) return;
|
||||
return this.metadata[12];
|
||||
}
|
||||
}, {
|
||||
key: "nationalNumberPattern",
|
||||
value: function nationalNumberPattern() {
|
||||
if (this.v1 || this.v2) return this.metadata[1];
|
||||
return this.metadata[2];
|
||||
} // "possible length" data is always present in Google's metadata.
|
||||
|
||||
}, {
|
||||
key: "possibleLengths",
|
||||
value: function possibleLengths() {
|
||||
if (this.v1) return;
|
||||
return this.metadata[this.v2 ? 2 : 3];
|
||||
}
|
||||
}, {
|
||||
key: "_getFormats",
|
||||
value: function _getFormats(metadata) {
|
||||
return metadata[this.v1 ? 2 : this.v2 ? 3 : 4];
|
||||
} // For countries of the same region (e.g. NANPA)
|
||||
// formats are all stored in the "main" country for that region.
|
||||
// E.g. "RU" and "KZ", "US" and "CA".
|
||||
|
||||
}, {
|
||||
key: "formats",
|
||||
value: function formats() {
|
||||
var _this = this;
|
||||
|
||||
var formats = this._getFormats(this.metadata) || this._getFormats(this.getDefaultCountryMetadataForRegion()) || [];
|
||||
return formats.map(function (_) {
|
||||
return new Format(_, _this);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "nationalPrefix",
|
||||
value: function nationalPrefix() {
|
||||
return this.metadata[this.v1 ? 3 : this.v2 ? 4 : 5];
|
||||
}
|
||||
}, {
|
||||
key: "_getNationalPrefixFormattingRule",
|
||||
value: function _getNationalPrefixFormattingRule(metadata) {
|
||||
return metadata[this.v1 ? 4 : this.v2 ? 5 : 6];
|
||||
} // For countries of the same region (e.g. NANPA)
|
||||
// national prefix formatting rule is stored in the "main" country for that region.
|
||||
// E.g. "RU" and "KZ", "US" and "CA".
|
||||
|
||||
}, {
|
||||
key: "nationalPrefixFormattingRule",
|
||||
value: function nationalPrefixFormattingRule() {
|
||||
return this._getNationalPrefixFormattingRule(this.metadata) || this._getNationalPrefixFormattingRule(this.getDefaultCountryMetadataForRegion());
|
||||
}
|
||||
}, {
|
||||
key: "_nationalPrefixForParsing",
|
||||
value: function _nationalPrefixForParsing() {
|
||||
return this.metadata[this.v1 ? 5 : this.v2 ? 6 : 7];
|
||||
}
|
||||
}, {
|
||||
key: "nationalPrefixForParsing",
|
||||
value: function nationalPrefixForParsing() {
|
||||
// If `national_prefix_for_parsing` is not set explicitly,
|
||||
// then infer it from `national_prefix` (if any)
|
||||
return this._nationalPrefixForParsing() || this.nationalPrefix();
|
||||
}
|
||||
}, {
|
||||
key: "nationalPrefixTransformRule",
|
||||
value: function nationalPrefixTransformRule() {
|
||||
return this.metadata[this.v1 ? 6 : this.v2 ? 7 : 8];
|
||||
}
|
||||
}, {
|
||||
key: "_getNationalPrefixIsOptionalWhenFormatting",
|
||||
value: function _getNationalPrefixIsOptionalWhenFormatting() {
|
||||
return !!this.metadata[this.v1 ? 7 : this.v2 ? 8 : 9];
|
||||
} // For countries of the same region (e.g. NANPA)
|
||||
// "national prefix is optional when formatting" flag is
|
||||
// stored in the "main" country for that region.
|
||||
// E.g. "RU" and "KZ", "US" and "CA".
|
||||
|
||||
}, {
|
||||
key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
|
||||
value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
|
||||
return this._getNationalPrefixIsOptionalWhenFormatting(this.metadata) || this._getNationalPrefixIsOptionalWhenFormatting(this.getDefaultCountryMetadataForRegion());
|
||||
}
|
||||
}, {
|
||||
key: "leadingDigits",
|
||||
value: function leadingDigits() {
|
||||
return this.metadata[this.v1 ? 8 : this.v2 ? 9 : 10];
|
||||
}
|
||||
}, {
|
||||
key: "types",
|
||||
value: function types() {
|
||||
return this.metadata[this.v1 ? 9 : this.v2 ? 10 : 11];
|
||||
}
|
||||
}, {
|
||||
key: "hasTypes",
|
||||
value: function hasTypes() {
|
||||
// Versions 1.2.0 - 1.2.4: can be `[]`.
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (this.types() && this.types().length === 0) {
|
||||
return false;
|
||||
} // Versions <= 1.2.4: can be `undefined`.
|
||||
// Version >= 1.2.5: can be `0`.
|
||||
|
||||
|
||||
return !!this.types();
|
||||
}
|
||||
}, {
|
||||
key: "type",
|
||||
value: function type(_type2) {
|
||||
if (this.hasTypes() && getType(this.types(), _type2)) {
|
||||
return new Type(getType(this.types(), _type2), this);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "ext",
|
||||
value: function ext() {
|
||||
if (this.v1 || this.v2) return DEFAULT_EXT_PREFIX;
|
||||
return this.metadata[13] || DEFAULT_EXT_PREFIX;
|
||||
}
|
||||
}]);
|
||||
|
||||
return NumberingPlan;
|
||||
}();
|
||||
|
||||
var Format = /*#__PURE__*/function () {
|
||||
function Format(format, metadata) {
|
||||
_classCallCheck(this, Format);
|
||||
|
||||
this._format = format;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
_createClass(Format, [{
|
||||
key: "pattern",
|
||||
value: function pattern() {
|
||||
return this._format[0];
|
||||
}
|
||||
}, {
|
||||
key: "format",
|
||||
value: function format() {
|
||||
return this._format[1];
|
||||
}
|
||||
}, {
|
||||
key: "leadingDigitsPatterns",
|
||||
value: function leadingDigitsPatterns() {
|
||||
return this._format[2] || [];
|
||||
}
|
||||
}, {
|
||||
key: "nationalPrefixFormattingRule",
|
||||
value: function nationalPrefixFormattingRule() {
|
||||
return this._format[3] || this.metadata.nationalPrefixFormattingRule();
|
||||
}
|
||||
}, {
|
||||
key: "nationalPrefixIsOptionalWhenFormattingInNationalFormat",
|
||||
value: function nationalPrefixIsOptionalWhenFormattingInNationalFormat() {
|
||||
return !!this._format[4] || this.metadata.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
|
||||
}
|
||||
}, {
|
||||
key: "nationalPrefixIsMandatoryWhenFormattingInNationalFormat",
|
||||
value: function nationalPrefixIsMandatoryWhenFormattingInNationalFormat() {
|
||||
// National prefix is omitted if there's no national prefix formatting rule
|
||||
// set for this country, or when the national prefix formatting rule
|
||||
// contains no national prefix itself, or when this rule is set but
|
||||
// national prefix is optional for this phone number format
|
||||
// (and it is not enforced explicitly)
|
||||
return this.usesNationalPrefix() && !this.nationalPrefixIsOptionalWhenFormattingInNationalFormat();
|
||||
} // Checks whether national prefix formatting rule contains national prefix.
|
||||
|
||||
}, {
|
||||
key: "usesNationalPrefix",
|
||||
value: function usesNationalPrefix() {
|
||||
return this.nationalPrefixFormattingRule() && // Check that national prefix formatting rule is not a "dummy" one.
|
||||
!FIRST_GROUP_ONLY_PREFIX_PATTERN.test(this.nationalPrefixFormattingRule()) // In compressed metadata, `this.nationalPrefixFormattingRule()` is `0`
|
||||
// when `national_prefix_formatting_rule` is not present.
|
||||
// So, `true` or `false` are returned explicitly here, so that
|
||||
// `0` number isn't returned.
|
||||
? true : false;
|
||||
}
|
||||
}, {
|
||||
key: "internationalFormat",
|
||||
value: function internationalFormat() {
|
||||
return this._format[5] || this.format();
|
||||
}
|
||||
}]);
|
||||
|
||||
return Format;
|
||||
}();
|
||||
/**
|
||||
* A pattern that is used to determine if the national prefix formatting rule
|
||||
* has the first group only, i.e., does not start with the national prefix.
|
||||
* Note that the pattern explicitly allows for unbalanced parentheses.
|
||||
*/
|
||||
|
||||
|
||||
var FIRST_GROUP_ONLY_PREFIX_PATTERN = /^\(?\$1\)?$/;
|
||||
|
||||
var Type = /*#__PURE__*/function () {
|
||||
function Type(type, metadata) {
|
||||
_classCallCheck(this, Type);
|
||||
|
||||
this.type = type;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
_createClass(Type, [{
|
||||
key: "pattern",
|
||||
value: function pattern() {
|
||||
if (this.metadata.v1) return this.type;
|
||||
return this.type[0];
|
||||
}
|
||||
}, {
|
||||
key: "possibleLengths",
|
||||
value: function possibleLengths() {
|
||||
if (this.metadata.v1) return;
|
||||
return this.type[1] || this.metadata.possibleLengths();
|
||||
}
|
||||
}]);
|
||||
|
||||
return Type;
|
||||
}();
|
||||
|
||||
function getType(types, type) {
|
||||
switch (type) {
|
||||
case 'FIXED_LINE':
|
||||
return types[0];
|
||||
|
||||
case 'MOBILE':
|
||||
return types[1];
|
||||
|
||||
case 'TOLL_FREE':
|
||||
return types[2];
|
||||
|
||||
case 'PREMIUM_RATE':
|
||||
return types[3];
|
||||
|
||||
case 'PERSONAL_NUMBER':
|
||||
return types[4];
|
||||
|
||||
case 'VOICEMAIL':
|
||||
return types[5];
|
||||
|
||||
case 'UAN':
|
||||
return types[6];
|
||||
|
||||
case 'PAGER':
|
||||
return types[7];
|
||||
|
||||
case 'VOIP':
|
||||
return types[8];
|
||||
|
||||
case 'SHARED_COST':
|
||||
return types[9];
|
||||
}
|
||||
}
|
||||
|
||||
export function validateMetadata(metadata) {
|
||||
if (!metadata) {
|
||||
throw new Error('[libphonenumber-js] `metadata` argument not passed. Check your arguments.');
|
||||
} // `country_phone_code_to_countries` was renamed to
|
||||
// `country_calling_codes` in `1.0.18`.
|
||||
|
||||
|
||||
if (!is_object(metadata) || !is_object(metadata.countries)) {
|
||||
throw new Error("[libphonenumber-js] `metadata` argument was passed but it's not a valid metadata. Must be an object having `.countries` child object property. Got ".concat(is_object(metadata) ? 'an object of shape: { ' + Object.keys(metadata).join(', ') + ' }' : 'a ' + type_of(metadata) + ': ' + metadata, "."));
|
||||
}
|
||||
} // Babel transforms `typeof` into some "branches"
|
||||
// so istanbul will show this as "branch not covered".
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
var is_object = function is_object(_) {
|
||||
return _typeof(_) === 'object';
|
||||
}; // Babel transforms `typeof` into some "branches"
|
||||
// so istanbul will show this as "branch not covered".
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
|
||||
var type_of = function type_of(_) {
|
||||
return _typeof(_);
|
||||
};
|
||||
/**
|
||||
* Returns extension prefix for a country.
|
||||
* @param {string} country
|
||||
* @param {object} metadata
|
||||
* @return {string?}
|
||||
* @example
|
||||
* // Returns " ext. "
|
||||
* getExtPrefix("US")
|
||||
*/
|
||||
|
||||
|
||||
export function getExtPrefix(country, metadata) {
|
||||
metadata = new Metadata(metadata);
|
||||
|
||||
if (metadata.hasCountry(country)) {
|
||||
return metadata.country(country).ext();
|
||||
}
|
||||
|
||||
return DEFAULT_EXT_PREFIX;
|
||||
}
|
||||
/**
|
||||
* Returns "country calling code" for a country.
|
||||
* Throws an error if the country doesn't exist or isn't supported by this library.
|
||||
* @param {string} country
|
||||
* @param {object} metadata
|
||||
* @return {string}
|
||||
* @example
|
||||
* // Returns "44"
|
||||
* getCountryCallingCode("GB")
|
||||
*/
|
||||
|
||||
export function getCountryCallingCode(country, metadata) {
|
||||
metadata = new Metadata(metadata);
|
||||
|
||||
if (metadata.hasCountry(country)) {
|
||||
return metadata.country(country).countryCallingCode();
|
||||
}
|
||||
|
||||
throw new Error("Unknown country: ".concat(country));
|
||||
}
|
||||
export function isSupportedCountry(country, metadata) {
|
||||
// metadata = new Metadata(metadata)
|
||||
// return metadata.hasCountry(country)
|
||||
return metadata.countries[country] !== undefined;
|
||||
}
|
||||
|
||||
function setVersion(metadata) {
|
||||
var version = metadata.version;
|
||||
|
||||
if (typeof version === 'number') {
|
||||
this.v1 = version === 1;
|
||||
this.v2 = version === 2;
|
||||
this.v3 = version === 3;
|
||||
this.v4 = version === 4;
|
||||
} else {
|
||||
if (!version) {
|
||||
this.v1 = true;
|
||||
} else if (compare(version, V3) === -1) {
|
||||
this.v2 = true;
|
||||
} else if (compare(version, V4) === -1) {
|
||||
this.v3 = true;
|
||||
} else {
|
||||
this.v4 = true;
|
||||
}
|
||||
}
|
||||
} // const ISO_COUNTRY_CODE = /^[A-Z]{2}$/
|
||||
// function isCountryCode(countryCode) {
|
||||
// return ISO_COUNTRY_CODE.test(countryCodeOrCountryCallingCode)
|
||||
// }
|
||||
//# sourceMappingURL=metadata.js.map
|
81
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/normalizeArguments.js
generated
vendored
Normal file
81
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/normalizeArguments.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
||||
|
||||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
||||
|
||||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
||||
|
||||
// Extracts the following properties from function arguments:
|
||||
// * input `text`
|
||||
// * `options` object
|
||||
// * `metadata` JSON
|
||||
export default function normalizeArguments(args) {
|
||||
var _Array$prototype$slic = Array.prototype.slice.call(args),
|
||||
_Array$prototype$slic2 = _slicedToArray(_Array$prototype$slic, 4),
|
||||
arg_1 = _Array$prototype$slic2[0],
|
||||
arg_2 = _Array$prototype$slic2[1],
|
||||
arg_3 = _Array$prototype$slic2[2],
|
||||
arg_4 = _Array$prototype$slic2[3];
|
||||
|
||||
var text;
|
||||
var options;
|
||||
var metadata; // If the phone number is passed as a string.
|
||||
// `parsePhoneNumber('88005553535', ...)`.
|
||||
|
||||
if (typeof arg_1 === 'string') {
|
||||
text = arg_1;
|
||||
} else throw new TypeError('A text for parsing must be a string.'); // If "default country" argument is being passed then move it to `options`.
|
||||
// `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
|
||||
|
||||
|
||||
if (!arg_2 || typeof arg_2 === 'string') {
|
||||
if (arg_4) {
|
||||
options = arg_3;
|
||||
metadata = arg_4;
|
||||
} else {
|
||||
options = undefined;
|
||||
metadata = arg_3;
|
||||
}
|
||||
|
||||
if (arg_2) {
|
||||
options = _objectSpread({
|
||||
defaultCountry: arg_2
|
||||
}, options);
|
||||
}
|
||||
} // `defaultCountry` is not passed.
|
||||
// Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
|
||||
else if (isObject(arg_2)) {
|
||||
if (arg_3) {
|
||||
options = arg_2;
|
||||
metadata = arg_3;
|
||||
} else {
|
||||
metadata = arg_2;
|
||||
}
|
||||
} else throw new Error("Invalid second argument: ".concat(arg_2));
|
||||
|
||||
return {
|
||||
text: text,
|
||||
options: options,
|
||||
metadata: metadata
|
||||
};
|
||||
} // Otherwise istanbul would show this as "branch not covered".
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
var isObject = function isObject(_) {
|
||||
return _typeof(_) === 'object';
|
||||
};
|
||||
//# sourceMappingURL=normalizeArguments.js.map
|
361
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parse.js
generated
vendored
Normal file
361
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parse.js
generated
vendored
Normal file
@@ -0,0 +1,361 @@
|
||||
// This is a port of Google Android `libphonenumber`'s
|
||||
// `phonenumberutil.js` of December 31th, 2018.
|
||||
//
|
||||
// https://github.com/googlei18n/libphonenumber/commits/master/javascript/i18n/phonenumbers/phonenumberutil.js
|
||||
import { VALID_DIGITS, PLUS_CHARS, MIN_LENGTH_FOR_NSN, MAX_LENGTH_FOR_NSN } from './constants.js';
|
||||
import ParseError from './ParseError.js';
|
||||
import Metadata from './metadata.js';
|
||||
import isViablePhoneNumber, { isViablePhoneNumberStart } from './helpers/isViablePhoneNumber.js';
|
||||
import extractExtension from './helpers/extension/extractExtension.js';
|
||||
import parseIncompletePhoneNumber from './parseIncompletePhoneNumber.js';
|
||||
import getCountryCallingCode from './getCountryCallingCode.js';
|
||||
import { isPossibleNumber } from './isPossible.js'; // import { parseRFC3966 } from './helpers/RFC3966.js'
|
||||
|
||||
import PhoneNumber from './PhoneNumber.js';
|
||||
import matchesEntirely from './helpers/matchesEntirely.js';
|
||||
import extractCountryCallingCode from './helpers/extractCountryCallingCode.js';
|
||||
import extractNationalNumber from './helpers/extractNationalNumber.js';
|
||||
import stripIddPrefix from './helpers/stripIddPrefix.js';
|
||||
import getCountryByCallingCode from './helpers/getCountryByCallingCode.js';
|
||||
import extractFormattedPhoneNumberFromPossibleRfc3966NumberUri from './helpers/extractFormattedPhoneNumberFromPossibleRfc3966NumberUri.js'; // We don't allow input strings for parsing to be longer than 250 chars.
|
||||
// This prevents malicious input from consuming CPU.
|
||||
|
||||
var MAX_INPUT_STRING_LENGTH = 250; // This consists of the plus symbol, digits, and arabic-indic digits.
|
||||
|
||||
var PHONE_NUMBER_START_PATTERN = new RegExp('[' + PLUS_CHARS + VALID_DIGITS + ']'); // Regular expression of trailing characters that we want to remove.
|
||||
// A trailing `#` is sometimes used when writing phone numbers with extensions in US.
|
||||
// Example: "+1 (645) 123 1234-910#" number has extension "910".
|
||||
|
||||
var AFTER_PHONE_NUMBER_END_PATTERN = new RegExp('[^' + VALID_DIGITS + '#' + ']+$');
|
||||
var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false; // Examples:
|
||||
//
|
||||
// ```js
|
||||
// parse('8 (800) 555-35-35', 'RU')
|
||||
// parse('8 (800) 555-35-35', 'RU', metadata)
|
||||
// parse('8 (800) 555-35-35', { country: { default: 'RU' } })
|
||||
// parse('8 (800) 555-35-35', { country: { default: 'RU' } }, metadata)
|
||||
// parse('+7 800 555 35 35')
|
||||
// parse('+7 800 555 35 35', metadata)
|
||||
// ```
|
||||
//
|
||||
|
||||
/**
|
||||
* Parses a phone number.
|
||||
*
|
||||
* parse('123456789', { defaultCountry: 'RU', v2: true }, metadata)
|
||||
* parse('123456789', { defaultCountry: 'RU' }, metadata)
|
||||
* parse('123456789', undefined, metadata)
|
||||
*
|
||||
* @param {string} input
|
||||
* @param {object} [options]
|
||||
* @param {object} metadata
|
||||
* @return {object|PhoneNumber?} If `options.v2: true` flag is passed, it returns a `PhoneNumber?` instance. Otherwise, returns an object of shape `{ phone: '...', country: '...' }` (or just `{}` if no phone number was parsed).
|
||||
*/
|
||||
|
||||
export default function parse(text, options, metadata) {
|
||||
// If assigning the `{}` default value is moved to the arguments above,
|
||||
// code coverage would decrease for some weird reason.
|
||||
options = options || {};
|
||||
metadata = new Metadata(metadata); // Validate `defaultCountry`.
|
||||
|
||||
if (options.defaultCountry && !metadata.hasCountry(options.defaultCountry)) {
|
||||
if (options.v2) {
|
||||
throw new ParseError('INVALID_COUNTRY');
|
||||
}
|
||||
|
||||
throw new Error("Unknown country: ".concat(options.defaultCountry));
|
||||
} // Parse the phone number.
|
||||
|
||||
|
||||
var _parseInput = parseInput(text, options.v2, options.extract),
|
||||
formattedPhoneNumber = _parseInput.number,
|
||||
ext = _parseInput.ext,
|
||||
error = _parseInput.error; // If the phone number is not viable then return nothing.
|
||||
|
||||
|
||||
if (!formattedPhoneNumber) {
|
||||
if (options.v2) {
|
||||
if (error === 'TOO_SHORT') {
|
||||
throw new ParseError('TOO_SHORT');
|
||||
}
|
||||
|
||||
throw new ParseError('NOT_A_NUMBER');
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
var _parsePhoneNumber = parsePhoneNumber(formattedPhoneNumber, options.defaultCountry, options.defaultCallingCode, metadata),
|
||||
country = _parsePhoneNumber.country,
|
||||
nationalNumber = _parsePhoneNumber.nationalNumber,
|
||||
countryCallingCode = _parsePhoneNumber.countryCallingCode,
|
||||
countryCallingCodeSource = _parsePhoneNumber.countryCallingCodeSource,
|
||||
carrierCode = _parsePhoneNumber.carrierCode;
|
||||
|
||||
if (!metadata.hasSelectedNumberingPlan()) {
|
||||
if (options.v2) {
|
||||
throw new ParseError('INVALID_COUNTRY');
|
||||
}
|
||||
|
||||
return {};
|
||||
} // Validate national (significant) number length.
|
||||
|
||||
|
||||
if (!nationalNumber || nationalNumber.length < MIN_LENGTH_FOR_NSN) {
|
||||
// Won't throw here because the regexp already demands length > 1.
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (options.v2) {
|
||||
throw new ParseError('TOO_SHORT');
|
||||
} // Google's demo just throws an error in this case.
|
||||
|
||||
|
||||
return {};
|
||||
} // Validate national (significant) number length.
|
||||
//
|
||||
// A sidenote:
|
||||
//
|
||||
// They say that sometimes national (significant) numbers
|
||||
// can be longer than `MAX_LENGTH_FOR_NSN` (e.g. in Germany).
|
||||
// https://github.com/googlei18n/libphonenumber/blob/7e1748645552da39c4e1ba731e47969d97bdb539/resources/phonenumber.proto#L36
|
||||
// Such numbers will just be discarded.
|
||||
//
|
||||
|
||||
|
||||
if (nationalNumber.length > MAX_LENGTH_FOR_NSN) {
|
||||
if (options.v2) {
|
||||
throw new ParseError('TOO_LONG');
|
||||
} // Google's demo just throws an error in this case.
|
||||
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
if (options.v2) {
|
||||
var phoneNumber = new PhoneNumber(countryCallingCode, nationalNumber, metadata.metadata);
|
||||
|
||||
if (country) {
|
||||
phoneNumber.country = country;
|
||||
}
|
||||
|
||||
if (carrierCode) {
|
||||
phoneNumber.carrierCode = carrierCode;
|
||||
}
|
||||
|
||||
if (ext) {
|
||||
phoneNumber.ext = ext;
|
||||
}
|
||||
|
||||
phoneNumber.__countryCallingCodeSource = countryCallingCodeSource;
|
||||
return phoneNumber;
|
||||
} // Check if national phone number pattern matches the number.
|
||||
// National number pattern is different for each country,
|
||||
// even for those ones which are part of the "NANPA" group.
|
||||
|
||||
|
||||
var valid = (options.extended ? metadata.hasSelectedNumberingPlan() : country) ? matchesEntirely(nationalNumber, metadata.nationalNumberPattern()) : false;
|
||||
|
||||
if (!options.extended) {
|
||||
return valid ? result(country, nationalNumber, ext) : {};
|
||||
} // isInternational: countryCallingCode !== undefined
|
||||
|
||||
|
||||
return {
|
||||
country: country,
|
||||
countryCallingCode: countryCallingCode,
|
||||
carrierCode: carrierCode,
|
||||
valid: valid,
|
||||
possible: valid ? true : options.extended === true && metadata.possibleLengths() && isPossibleNumber(nationalNumber, metadata) ? true : false,
|
||||
phone: nationalNumber,
|
||||
ext: ext
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Extracts a formatted phone number from text.
|
||||
* Doesn't guarantee that the extracted phone number
|
||||
* is a valid phone number (for example, doesn't validate its length).
|
||||
* @param {string} text
|
||||
* @param {boolean} [extract] — If `false`, then will parse the entire `text` as a phone number.
|
||||
* @param {boolean} [throwOnError] — By default, it won't throw if the text is too long.
|
||||
* @return {string}
|
||||
* @example
|
||||
* // Returns "(213) 373-4253".
|
||||
* extractFormattedPhoneNumber("Call (213) 373-4253 for assistance.")
|
||||
*/
|
||||
|
||||
function _extractFormattedPhoneNumber(text, extract, throwOnError) {
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (text.length > MAX_INPUT_STRING_LENGTH) {
|
||||
if (throwOnError) {
|
||||
throw new ParseError('TOO_LONG');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (extract === false) {
|
||||
return text;
|
||||
} // Attempt to extract a possible number from the string passed in
|
||||
|
||||
|
||||
var startsAt = text.search(PHONE_NUMBER_START_PATTERN);
|
||||
|
||||
if (startsAt < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
return text // Trim everything to the left of the phone number
|
||||
.slice(startsAt) // Remove trailing non-numerical characters
|
||||
.replace(AFTER_PHONE_NUMBER_END_PATTERN, '');
|
||||
}
|
||||
/**
|
||||
* @param {string} text - Input.
|
||||
* @param {boolean} v2 - Legacy API functions don't pass `v2: true` flag.
|
||||
* @param {boolean} [extract] - Whether to extract a phone number from `text`, or attempt to parse the entire text as a phone number.
|
||||
* @return {object} `{ ?number, ?ext }`.
|
||||
*/
|
||||
|
||||
|
||||
function parseInput(text, v2, extract) {
|
||||
// // Parse RFC 3966 phone number URI.
|
||||
// if (text && text.indexOf('tel:') === 0) {
|
||||
// return parseRFC3966(text)
|
||||
// }
|
||||
// let number = extractFormattedPhoneNumber(text, extract, v2)
|
||||
var number = extractFormattedPhoneNumberFromPossibleRfc3966NumberUri(text, {
|
||||
extractFormattedPhoneNumber: function extractFormattedPhoneNumber(text) {
|
||||
return _extractFormattedPhoneNumber(text, extract, v2);
|
||||
}
|
||||
}); // If the phone number is not viable, then abort.
|
||||
|
||||
if (!number) {
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!isViablePhoneNumber(number)) {
|
||||
if (isViablePhoneNumberStart(number)) {
|
||||
return {
|
||||
error: 'TOO_SHORT'
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
} // Attempt to parse extension first, since it doesn't require region-specific
|
||||
// data and we want to have the non-normalised number here.
|
||||
|
||||
|
||||
var withExtensionStripped = extractExtension(number);
|
||||
|
||||
if (withExtensionStripped.ext) {
|
||||
return withExtensionStripped;
|
||||
}
|
||||
|
||||
return {
|
||||
number: number
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Creates `parse()` result object.
|
||||
*/
|
||||
|
||||
|
||||
function result(country, nationalNumber, ext) {
|
||||
var result = {
|
||||
country: country,
|
||||
phone: nationalNumber
|
||||
};
|
||||
|
||||
if (ext) {
|
||||
result.ext = ext;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Parses a viable phone number.
|
||||
* @param {string} formattedPhoneNumber — Example: "(213) 373-4253".
|
||||
* @param {string} [defaultCountry]
|
||||
* @param {string} [defaultCallingCode]
|
||||
* @param {Metadata} metadata
|
||||
* @return {object} Returns `{ country: string?, countryCallingCode: string?, nationalNumber: string? }`.
|
||||
*/
|
||||
|
||||
|
||||
function parsePhoneNumber(formattedPhoneNumber, defaultCountry, defaultCallingCode, metadata) {
|
||||
// Extract calling code from phone number.
|
||||
var _extractCountryCallin = extractCountryCallingCode(parseIncompletePhoneNumber(formattedPhoneNumber), defaultCountry, defaultCallingCode, metadata.metadata),
|
||||
countryCallingCodeSource = _extractCountryCallin.countryCallingCodeSource,
|
||||
countryCallingCode = _extractCountryCallin.countryCallingCode,
|
||||
number = _extractCountryCallin.number; // Choose a country by `countryCallingCode`.
|
||||
|
||||
|
||||
var country;
|
||||
|
||||
if (countryCallingCode) {
|
||||
metadata.selectNumberingPlan(countryCallingCode);
|
||||
} // If `formattedPhoneNumber` is passed in "national" format
|
||||
// then `number` is defined and `countryCallingCode` is `undefined`.
|
||||
else if (number && (defaultCountry || defaultCallingCode)) {
|
||||
metadata.selectNumberingPlan(defaultCountry, defaultCallingCode);
|
||||
|
||||
if (defaultCountry) {
|
||||
country = defaultCountry;
|
||||
} else {
|
||||
/* istanbul ignore if */
|
||||
if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
|
||||
if (metadata.isNonGeographicCallingCode(defaultCallingCode)) {
|
||||
country = '001';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
countryCallingCode = defaultCallingCode || getCountryCallingCode(defaultCountry, metadata.metadata);
|
||||
} else return {};
|
||||
|
||||
if (!number) {
|
||||
return {
|
||||
countryCallingCodeSource: countryCallingCodeSource,
|
||||
countryCallingCode: countryCallingCode
|
||||
};
|
||||
}
|
||||
|
||||
var _extractNationalNumbe = extractNationalNumber(parseIncompletePhoneNumber(number), metadata),
|
||||
nationalNumber = _extractNationalNumbe.nationalNumber,
|
||||
carrierCode = _extractNationalNumbe.carrierCode; // Sometimes there are several countries
|
||||
// corresponding to the same country phone code
|
||||
// (e.g. NANPA countries all having `1` country phone code).
|
||||
// Therefore, to reliably determine the exact country,
|
||||
// national (significant) number should have been parsed first.
|
||||
//
|
||||
// When `metadata.json` is generated, all "ambiguous" country phone codes
|
||||
// get their countries populated with the full set of
|
||||
// "phone number type" regular expressions.
|
||||
//
|
||||
|
||||
|
||||
var exactCountry = getCountryByCallingCode(countryCallingCode, nationalNumber, metadata);
|
||||
|
||||
if (exactCountry) {
|
||||
country = exactCountry;
|
||||
/* istanbul ignore if */
|
||||
|
||||
if (exactCountry === '001') {// Can't happen with `USE_NON_GEOGRAPHIC_COUNTRY_CODE` being `false`.
|
||||
// If `USE_NON_GEOGRAPHIC_COUNTRY_CODE` is set to `true` for some reason,
|
||||
// then remove the "istanbul ignore if".
|
||||
} else {
|
||||
metadata.country(country);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
country: country,
|
||||
countryCallingCode: countryCallingCode,
|
||||
countryCallingCodeSource: countryCallingCodeSource,
|
||||
nationalNumber: nationalNumber,
|
||||
carrierCode: carrierCode
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=parse.js.map
|
66
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js
generated
vendored
Normal file
66
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parseIncompletePhoneNumber.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
||||
|
||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||
|
||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||
|
||||
import { parseDigit } from './helpers/parseDigits.js';
|
||||
/**
|
||||
* Parses phone number characters from a string.
|
||||
* Drops all punctuation leaving only digits and the leading `+` sign (if any).
|
||||
* Also converts wide-ascii and arabic-indic numerals to conventional numerals.
|
||||
* E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.
|
||||
* @param {string} string
|
||||
* @return {string}
|
||||
* @example
|
||||
* ```js
|
||||
* // Outputs '8800555'.
|
||||
* parseIncompletePhoneNumber('8 (800) 555')
|
||||
* // Outputs '+7800555'.
|
||||
* parseIncompletePhoneNumber('+7 800 555')
|
||||
* ```
|
||||
*/
|
||||
|
||||
export default function parseIncompletePhoneNumber(string) {
|
||||
var result = ''; // Using `.split('')` here instead of normal `for ... of`
|
||||
// because the importing application doesn't neccessarily include an ES6 polyfill.
|
||||
// The `.split('')` approach discards "exotic" UTF-8 characters
|
||||
// (the ones consisting of four bytes) but digits
|
||||
// (including non-European ones) don't fall into that range
|
||||
// so such "exotic" characters would be discarded anyway.
|
||||
|
||||
for (var _iterator = _createForOfIteratorHelperLoose(string.split('')), _step; !(_step = _iterator()).done;) {
|
||||
var character = _step.value;
|
||||
result += parsePhoneNumberCharacter(character, result) || '';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Parses next character while parsing phone number digits (including a `+`)
|
||||
* from text: discards everything except `+` and digits, and `+` is only allowed
|
||||
* at the start of a phone number.
|
||||
* For example, is used in `react-phone-number-input` where it uses
|
||||
* [`input-format`](https://gitlab.com/catamphetamine/input-format).
|
||||
* @param {string} character - Yet another character from raw input string.
|
||||
* @param {string?} prevParsedCharacters - Previous parsed characters.
|
||||
* @param {object} meta - Optional custom use-case-specific metadata.
|
||||
* @return {string?} The parsed character.
|
||||
*/
|
||||
|
||||
export function parsePhoneNumberCharacter(character, prevParsedCharacters) {
|
||||
// Only allow a leading `+`.
|
||||
if (character === '+') {
|
||||
// If this `+` is not the first parsed character
|
||||
// then discard it.
|
||||
if (prevParsedCharacters) {
|
||||
return;
|
||||
}
|
||||
|
||||
return '+';
|
||||
} // Allow digits.
|
||||
|
||||
|
||||
return parseDigit(character);
|
||||
}
|
||||
//# sourceMappingURL=parseIncompletePhoneNumber.js.map
|
11
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parsePhoneNumber.js
generated
vendored
Normal file
11
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parsePhoneNumber.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import normalizeArguments from './normalizeArguments.js';
|
||||
import parsePhoneNumber_ from './parsePhoneNumber_.js';
|
||||
export default function parsePhoneNumber() {
|
||||
var _normalizeArguments = normalizeArguments(arguments),
|
||||
text = _normalizeArguments.text,
|
||||
options = _normalizeArguments.options,
|
||||
metadata = _normalizeArguments.metadata;
|
||||
|
||||
return parsePhoneNumber_(text, options, metadata);
|
||||
}
|
||||
//# sourceMappingURL=parsePhoneNumber.js.map
|
13
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js
generated
vendored
Normal file
13
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parsePhoneNumberWithError_.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import parse from './parse.js';
|
||||
export default function parsePhoneNumberWithError(text, options, metadata) {
|
||||
return parse(text, _objectSpread(_objectSpread({}, options), {}, {
|
||||
v2: true
|
||||
}), metadata);
|
||||
}
|
||||
//# sourceMappingURL=parsePhoneNumberWithError_.js.map
|
29
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js
generated
vendored
Normal file
29
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/parsePhoneNumber_.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
import parsePhoneNumberWithError from './parsePhoneNumberWithError_.js';
|
||||
import ParseError from './ParseError.js';
|
||||
import { isSupportedCountry } from './metadata.js';
|
||||
export default function parsePhoneNumber(text, options, metadata) {
|
||||
// Validate `defaultCountry`.
|
||||
if (options && options.defaultCountry && !isSupportedCountry(options.defaultCountry, metadata)) {
|
||||
options = _objectSpread(_objectSpread({}, options), {}, {
|
||||
defaultCountry: undefined
|
||||
});
|
||||
} // Parse phone number.
|
||||
|
||||
|
||||
try {
|
||||
return parsePhoneNumberWithError(text, options, metadata);
|
||||
} catch (error) {
|
||||
/* istanbul ignore else */
|
||||
if (error instanceof ParseError) {//
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=parsePhoneNumber_.js.map
|
30
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/tools/semver-compare.js
generated
vendored
Normal file
30
parent_dir/20240530212112Z/node_modules/libphonenumber-js/es6/tools/semver-compare.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// Copy-pasted from:
|
||||
// https://github.com/substack/semver-compare/blob/master/index.js
|
||||
//
|
||||
// Inlining this function because some users reported issues with
|
||||
// importing from `semver-compare` in a browser with ES6 "native" modules.
|
||||
//
|
||||
// Fixes `semver-compare` not being able to compare versions with alpha/beta/etc "tags".
|
||||
// https://github.com/catamphetamine/libphonenumber-js/issues/381
|
||||
export default function (a, b) {
|
||||
a = a.split('-');
|
||||
b = b.split('-');
|
||||
var pa = a[0].split('.');
|
||||
var pb = b[0].split('.');
|
||||
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var na = Number(pa[i]);
|
||||
var nb = Number(pb[i]);
|
||||
if (na > nb) return 1;
|
||||
if (nb > na) return -1;
|
||||
if (!isNaN(na) && isNaN(nb)) return 1;
|
||||
if (isNaN(na) && !isNaN(nb)) return -1;
|
||||
}
|
||||
|
||||
if (a[1] && b[1]) {
|
||||
return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
|
||||
}
|
||||
|
||||
return !a[1] && b[1] ? 1 : a[1] && !b[1] ? -1 : 0;
|
||||
}
|
||||
//# sourceMappingURL=semver-compare.js.map
|
6
parent_dir/20240530212112Z/node_modules/libphonenumber-js/max/exports/parsePhoneNumber.js
generated
vendored
Normal file
6
parent_dir/20240530212112Z/node_modules/libphonenumber-js/max/exports/parsePhoneNumber.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import withMetadataArgument from './withMetadataArgument.js'
|
||||
import { default as _parsePhoneNumber } from '../../core/index.js'
|
||||
|
||||
export function parsePhoneNumber() {
|
||||
return withMetadataArgument(_parsePhoneNumber, arguments)
|
||||
}
|
9
parent_dir/20240530212112Z/node_modules/libphonenumber-js/max/exports/withMetadataArgument.js
generated
vendored
Normal file
9
parent_dir/20240530212112Z/node_modules/libphonenumber-js/max/exports/withMetadataArgument.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
// Importing from a ".js" file is a workaround for Node.js "ES Modules"
|
||||
// importing system which is even uncapable of importing "*.json" files.
|
||||
import metadata from '../../metadata.max.json.js'
|
||||
|
||||
export default function withMetadataArgument(func, _arguments) {
|
||||
var args = Array.prototype.slice.call(_arguments)
|
||||
args.push(metadata)
|
||||
return func.apply(this, args)
|
||||
}
|
4
parent_dir/20240530212112Z/node_modules/libphonenumber-js/metadata.max.json.js
generated
vendored
Normal file
4
parent_dir/20240530212112Z/node_modules/libphonenumber-js/metadata.max.json.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user