@enegalan/request-manager 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{request-manager.cjs.js → request-manager.cjs} +22 -6
- package/dist/request-manager.cjs.map +1 -0
- package/dist/request-manager.esm.js +21 -5
- package/dist/request-manager.esm.js.map +1 -1
- package/dist/request-manager.esm.min.js +2 -2
- package/dist/request-manager.esm.min.js.map +1 -1
- package/dist/request-manager.js +21 -5
- package/dist/request-manager.js.map +1 -1
- package/dist/request-manager.min.cjs +10 -0
- package/dist/request-manager.min.cjs.map +1 -0
- package/dist/request-manager.min.js +2 -2
- package/dist/request-manager.min.js.map +1 -1
- package/dist/request-manager.umd.js +21 -5
- package/dist/request-manager.umd.js.map +1 -1
- package/dist/request-manager.umd.min.js +2 -2
- package/dist/request-manager.umd.min.js.map +1 -1
- package/index.d.ts +8 -1
- package/main.js +32 -5
- package/package.json +3 -3
- package/dist/request-manager.cjs.js.map +0 -1
- package/dist/request-manager.cjs.min.js +0 -10
- package/dist/request-manager.cjs.min.js.map +0 -1
package/README.md
CHANGED
|
@@ -485,7 +485,6 @@ Calls `ajaxFunction({ url, ...options })`, then auto-wires cancel by inspecting
|
|
|
485
485
|
- `requestKey` (string|number|Function, optional): Key to identify duplicate requests. If provided, requests with the same key will cancel previous ones. Can be a string, number, or function that returns a key.
|
|
486
486
|
- `abortController` (AbortController): AbortController instance (created automatically if not provided)
|
|
487
487
|
- `cancelToken` (Function|Object): Cancel token or cancel function for other libraries
|
|
488
|
-
- `verbose` (boolean): If true, cancellation rejects with a message that includes the request id
|
|
489
488
|
- `noCancel` (boolean): If true, this request will not cancel previous requests with the same ID, allowing concurrent requests
|
|
490
489
|
- `includeQuery` (boolean): If true, keeps the query string in the URL-based request ID
|
|
491
490
|
- `includeMethod` (boolean): If true (default), the HTTP method is part of the URL-based request ID
|
|
@@ -527,7 +526,6 @@ Executes an HTTP request using XMLHttpRequest, cancelling any previous request w
|
|
|
527
526
|
- `timeout` (number): Request timeout in milliseconds
|
|
528
527
|
- `requestKey` (string|number|Function, optional): Key to identify duplicate requests. If provided, requests with the same key will cancel previous ones. Can be a string, number, or function that returns a key.
|
|
529
528
|
- `abortController` (AbortController): AbortController instance (created automatically if not provided)
|
|
530
|
-
- `verbose` (boolean): If true, cancellation rejects with a message that includes the request id
|
|
531
529
|
- `noCancel` (boolean): If true, this request will not cancel previous requests with the same ID, allowing concurrent requests
|
|
532
530
|
- `includeQuery` (boolean): If true, keeps the query string in the URL-based request ID
|
|
533
531
|
- `includeMethod` (boolean): If true (default), the HTTP method is part of the URL-based request ID
|
|
@@ -540,6 +538,8 @@ Executes an HTTP request using XMLHttpRequest, cancelling any previous request w
|
|
|
540
538
|
- `headers`: Response headers string
|
|
541
539
|
- `xhr`: The XMLHttpRequest instance
|
|
542
540
|
|
|
541
|
+
**Note:** If you abort the request yourself (via your own `AbortController` or `xhr.abort()`), the returned promise rejects with `{ message: 'Request was cancelled', xhr }` and the manager removes the entry from its active requests.
|
|
542
|
+
|
|
543
543
|
**Example:**
|
|
544
544
|
|
|
545
545
|
```javascript
|
|
@@ -280,7 +280,10 @@ class RequestManager {
|
|
|
280
280
|
axios(url) {
|
|
281
281
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
282
282
|
var axiosInstance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
283
|
-
var axiosLib = axiosInstance || axios;
|
|
283
|
+
var axiosLib = axiosInstance || (typeof axios !== 'undefined' ? axios : null);
|
|
284
|
+
if (!axiosLib) {
|
|
285
|
+
throw new Error('axios was not found: pass an axios instance as the third argument of requestManager.axios() or make sure axios is available globally');
|
|
286
|
+
}
|
|
284
287
|
_assertClassBrand(_RequestManager_brand, this, _checkAxiosVersion).call(this, axiosLib);
|
|
285
288
|
return _assertClassBrand(_RequestManager_brand, this, _request).call(this, this.getRequestId(url, options), _ref => {
|
|
286
289
|
var requestOptions = _ref.options;
|
|
@@ -346,7 +349,6 @@ class RequestManager {
|
|
|
346
349
|
*/
|
|
347
350
|
xhr(url) {
|
|
348
351
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
349
|
-
var requestId = this.getRequestId(url, options);
|
|
350
352
|
/** @type {import('./index.d.ts').RequestFunction<import('./index.d.ts').XhrResponse>} */
|
|
351
353
|
var xhrFunction = _ref3 => {
|
|
352
354
|
var fetchOptions = _ref3.options;
|
|
@@ -356,6 +358,7 @@ class RequestManager {
|
|
|
356
358
|
// Create a promise that wraps the XHR request
|
|
357
359
|
var xhrPromise = new Promise((resolve, reject) => {
|
|
358
360
|
xhr.onload = function () {
|
|
361
|
+
detachAbortListener();
|
|
359
362
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
360
363
|
var _xhr$getResponseHeade;
|
|
361
364
|
var response = xhr.response;
|
|
@@ -381,12 +384,14 @@ class RequestManager {
|
|
|
381
384
|
}
|
|
382
385
|
};
|
|
383
386
|
xhr.onerror = function () {
|
|
387
|
+
detachAbortListener();
|
|
384
388
|
reject({
|
|
385
389
|
message: 'Network error',
|
|
386
390
|
xhr: xhr
|
|
387
391
|
});
|
|
388
392
|
};
|
|
389
393
|
xhr.ontimeout = function () {
|
|
394
|
+
detachAbortListener();
|
|
390
395
|
reject({
|
|
391
396
|
message: 'Request timeout',
|
|
392
397
|
xhr: xhr
|
|
@@ -408,14 +413,25 @@ class RequestManager {
|
|
|
408
413
|
});
|
|
409
414
|
|
|
410
415
|
// Connect abort signal to xhr.abort()
|
|
411
|
-
|
|
416
|
+
var abortListener = () => xhr.abort();
|
|
417
|
+
if (fetchOptions.signal) fetchOptions.signal.addEventListener('abort', abortListener);
|
|
418
|
+
// Detach the listener once the request settles so completed requests do not keep it alive
|
|
419
|
+
var detachAbortListener = () => {
|
|
420
|
+
if (fetchOptions.signal) fetchOptions.signal.removeEventListener('abort', abortListener);
|
|
421
|
+
};
|
|
422
|
+
xhr.onabort = function () {
|
|
423
|
+
reject({
|
|
424
|
+
message: 'Request was cancelled',
|
|
425
|
+
xhr: xhr
|
|
426
|
+
});
|
|
427
|
+
};
|
|
412
428
|
|
|
413
429
|
// Send the request
|
|
414
430
|
xhr.send(options.body || null);
|
|
415
431
|
});
|
|
416
432
|
return xhrPromise;
|
|
417
433
|
};
|
|
418
|
-
return _assertClassBrand(_RequestManager_brand, this, _request).call(this,
|
|
434
|
+
return _assertClassBrand(_RequestManager_brand, this, _request).call(this, this.getRequestId(url, options), xhrFunction, options);
|
|
419
435
|
}
|
|
420
436
|
|
|
421
437
|
/**
|
|
@@ -547,7 +563,7 @@ function _resolveAbortMethod(req) {
|
|
|
547
563
|
*/
|
|
548
564
|
function _prepareRequestOptions(options, signal) {
|
|
549
565
|
var requestOptions = {};
|
|
550
|
-
var customOptions = ['abortController', 'cancelToken', 'requestKey', 'noCancel', 'includeQuery'];
|
|
566
|
+
var customOptions = ['abortController', 'cancelToken', 'requestKey', 'noCancel', 'includeQuery', 'includeMethod', 'verbose'];
|
|
551
567
|
Object.keys(options).forEach(key => {
|
|
552
568
|
if (customOptions.includes(key)) return;
|
|
553
569
|
requestOptions[key] = options[key];
|
|
@@ -701,4 +717,4 @@ function _request(requestId, requestPromise) {
|
|
|
701
717
|
|
|
702
718
|
exports.RequestManager = RequestManager;
|
|
703
719
|
exports.default = RequestManager;
|
|
704
|
-
//# sourceMappingURL=request-manager.cjs.
|
|
720
|
+
//# sourceMappingURL=request-manager.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-manager.cjs","sources":["../main.js"],"sourcesContent":["/**\n * RequestManager - A library for managing and regulating HTTP requests efficiently.\n * @license MIT\n * @author Eneko Galan <enekogalanelorza@gmail.com>\n * This library allows you to manage HTTP requests from any library (ajax, Ext.Ajax, axios, fetch, etc.)\n * by accepting Promises as parameters. When a request is repeated with the same identifier,\n * the previous request is automatically cancelled and the new one is executed, giving priority to the most recent requests.\n */\nclass RequestManager {\n constructor(options = {}) {\n /**\n * @type {Map<string, import('./index.d.ts').ActiveRequest>}\n */\n this.activeRequests = new Map();\n /**\n * @type {import('./index.d.ts').Options}\n */\n this.options = options;\n /**\n * One-shot AbortController for getSignal()/getAbortController() handoff.\n * Consumed by the next request that does not pass options.abortController.\n * @type {AbortController|null}\n */\n this.abortController = null;\n }\n\n /**\n * Gets the manager options\n * @returns {import('./index.d.ts').Options} Manager options\n */\n getOptions() {\n return this.options;\n }\n\n /**\n * Sets the manager options\n * @param {import('./index.d.ts').Options} options - The options to set\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n * Creates a new AbortController and returns its signal for the next request()\n * (one getSignal → one request). Do not use for parallel requests; use fetch(),\n * axios(), or request(url, ({ options }) => ...) instead — they create their own signal.\n * @returns {AbortSignal} The signal from a new AbortController\n * @example\n * const signal = requestManager.getSignal();\n * requestManager.request('/api/users', fetch('/api/users', { signal }));\n */\n getSignal() {\n return this.getAbortController().signal;\n }\n\n /**\n * Creates a new AbortController for the next request handoff.\n * Always returns a fresh controller (never reuses one from another in-flight request).\n * @returns {AbortController} A new AbortController instance\n */\n getAbortController() {\n this.abortController = new AbortController();\n return this.abortController;\n }\n\n /**\n * Checks if a request with the given identifier is currently active.\n * @param {string} requestId - The unique identifier to check\n * @returns {boolean} True if the request is active, false otherwise\n */\n isActive(requestId) {\n return this.activeRequests.has(requestId);\n }\n\n /**\n * Gets the number of active requests.\n * @returns {number} The number of currently active requests\n */\n getActiveCount() {\n return this.activeRequests.size;\n }\n\n /**\n * Clears all active requests without cancelling them.\n * Use with caution - this will not cancel the underlying HTTP requests.\n */\n clear() {\n this.activeRequests.clear();\n }\n\n /**\n * Executes an HTTP request, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {Promise|import('./index.d.ts').RequestFunction|string} requestPromise - The request promise or function that returns a promise\n * @param {import('./index.d.ts').RequestOptions} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Request with Promise\n * requestManager.request('/api/users', axios.get('/api/users'));\n * @example\n * // Request with Function\n * requestManager.request('/api/users', ({ options }) => fetch('/api/users', { signal: options.signal, ...options }));\n * @example\n * // Request with Promise and custom cancellation grouping with requestKey\n * const options = {\n * requestKey: 'get-users'\n * }\n * requestManager.request('/api/users', axios.get('/api/users', options), options);\n */\n request(url, requestPromise, options = {}) {\n return this.#_request(this.getRequestId(url, options), requestPromise, options);\n }\n\n /**\n * Executes an HTTP request using fetch, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to fetch\n * @param {import('./index.d.ts').FetchOptions} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.fetch('/api/users');\n * @example\n * // POST request with options\n * requestManager.fetch('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.fetch('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n fetch(url, options = {}) {\n return this.#_request(this.getRequestId(url, options), url, options);\n }\n\n /**\n * Executes an HTTP request using axios, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').AxiosRequestOptions} options - Optional configuration\n * @param {import('./index.d.ts').AxiosInstance|import('./index.d.ts').AxiosStatic|null} axiosInstance - Optional axios instance to use. If not provided, uses global axios.\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request (uses global axios)\n * requestManager.axios('/api/users');\n * @example\n * // With custom axios instance\n * const myAxios = axios.create({ baseURL: 'https://api.example.com' });\n * requestManager.axios('/users', {}, myAxios);\n * @example\n * // POST request with options\n * requestManager.axios('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.axios('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n axios(url, options = {}, axiosInstance = null) {\n const axiosLib = axiosInstance || (typeof axios !== 'undefined' ? axios : null);\n if (!axiosLib) {\n throw new Error(\n 'axios was not found: pass an axios instance as the third argument of requestManager.axios() or make sure axios is available globally'\n );\n }\n this.#_checkAxiosVersion(axiosLib);\n return this.#_request(\n this.getRequestId(url, options),\n ({ options: requestOptions }) => axiosLib({ url, ...requestOptions }),\n options\n );\n }\n\n /**\n * Executes an HTTP request using jQuery.ajax, cancelling any previous request with the same identifier.\n * @param {import('./index.d.ts').AjaxFunction} ajaxFunction - A function that receives { url, ...options } and returns a Promise\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').BaseRequestOptions & Record<string, any>} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.ajax(ajaxFunction, '/api/users');\n * @example\n * // POST request with options\n * requestManager.ajax(ajaxFunction, '/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.ajax(ajaxFunction, '/api/users', {\n * requestKey: 'get-users'\n * });\n */\n ajax(ajaxFunction, url, options = {}) {\n if (typeof ajaxFunction !== 'function') throw new Error('ajaxFunction parameter must be a function');\n return this.#_request(\n this.getRequestId(url, options),\n ({ options: requestOptions }) => ajaxFunction({ url, ...requestOptions }),\n options\n );\n }\n\n /**\n * Executes an HTTP request using XMLHttpRequest, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').XhrOptions} options - Optional configuration\n * @returns {Promise<import('./index.d.ts').XhrResponse>} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.xhr('/api/users');\n * @example\n * // POST request with options\n * requestManager.xhr('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping\n * requestManager.xhr('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n xhr(url, options = {}) {\n /** @type {import('./index.d.ts').RequestFunction<import('./index.d.ts').XhrResponse>} */\n const xhrFunction = ({ options: fetchOptions }) => {\n // Create XMLHttpRequest\n const xhr = new XMLHttpRequest();\n const method = (options.method || 'GET').toUpperCase();\n // Create a promise that wraps the XHR request\n const xhrPromise = new Promise((resolve, reject) => {\n xhr.onload = function () {\n detachAbortListener();\n if (xhr.status >= 200 && xhr.status < 300) {\n let response = xhr.response;\n if (\n options.responseType === 'json' ||\n ((!options.responseType || options.responseType === 'text') &&\n xhr.getResponseHeader('Content-Type')?.includes('application/json') &&\n typeof response === 'string')\n ) {\n try {\n response = JSON.parse(response);\n } catch {}\n }\n resolve({\n data: response,\n status: xhr.status,\n statusText: xhr.statusText,\n headers: xhr.getAllResponseHeaders(),\n xhr: xhr,\n });\n } else {\n reject({\n message: `Request failed with status ${xhr.status}`,\n status: xhr.status,\n statusText: xhr.statusText,\n xhr: xhr,\n });\n }\n };\n xhr.onerror = function () {\n detachAbortListener();\n reject({\n message: 'Network error',\n xhr: xhr,\n });\n };\n xhr.ontimeout = function () {\n detachAbortListener();\n reject({\n message: 'Request timeout',\n xhr: xhr,\n });\n };\n\n // Open the request\n xhr.open(method, url, true);\n\n // Set response type\n if (options.responseType) xhr.responseType = options.responseType;\n // Set withCredentials\n if (options.withCredentials !== undefined) xhr.withCredentials = options.withCredentials;\n // Set timeout\n if (options.timeout !== undefined) xhr.timeout = options.timeout;\n // Set headers\n if (options.headers)\n Object.keys(options.headers).forEach((key) => {\n xhr.setRequestHeader(key, options.headers[key]);\n });\n\n // Connect abort signal to xhr.abort()\n const abortListener = () => xhr.abort();\n if (fetchOptions.signal) fetchOptions.signal.addEventListener('abort', abortListener);\n // Detach the listener once the request settles so completed requests do not keep it alive\n const detachAbortListener = () => {\n if (fetchOptions.signal) fetchOptions.signal.removeEventListener('abort', abortListener);\n };\n\n xhr.onabort = function () {\n reject({\n message: 'Request was cancelled',\n xhr: xhr,\n });\n };\n\n // Send the request\n xhr.send(options.body || null);\n });\n return xhrPromise;\n };\n return this.#_request(this.getRequestId(url, options), xhrFunction, options);\n }\n\n /**\n * Returns the request identifier for a URL and options.\n * @param {string} url - The URL used when starting the request\n * @param {import('./index.d.ts').BaseRequestOptions} options - Same options used for the request\n * @returns {string} The request identifier\n * @example\n * requestManager.fetch('/api/users');\n * const id = requestManager.getRequestId('/api/users');\n * requestManager.cancel(id);\n */\n getRequestId(url, options = {}) {\n let requestKey = options.requestKey;\n\n const prefix = 'request_';\n\n // Generate a unique identifier to prevent cancellation for non cancelable requests\n if (options.noCancel) {\n return `${prefix}${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;\n }\n\n // Handle function requestKey\n if (typeof requestKey === 'function') {\n try {\n requestKey = requestKey();\n } catch {\n requestKey = null;\n }\n }\n if (requestKey !== null && requestKey !== undefined) return `${prefix}${String(requestKey)}`;\n\n // Use cleaned URL as key as fallback\n let cleanedUrl = url || '';\n if (cleanedUrl.includes('://')) cleanedUrl = cleanedUrl.split('://')[1];\n if (cleanedUrl.includes('#')) cleanedUrl = cleanedUrl.split('#')[0];\n if (!options.includeQuery && cleanedUrl.includes('?')) cleanedUrl = cleanedUrl.split('?')[0];\n\n const methodPrefix =\n options.includeMethod === false ? '' : `${(options.method || options.type || 'GET').toUpperCase()}_`;\n\n return `${prefix}${methodPrefix}${cleanedUrl}`;\n }\n\n /**\n * Cancels a specific request by its identifier.\n * @param {string} requestId - The unique identifier of the request to cancel\n * @returns {boolean} True if the request was found and cancelled, false otherwise\n */\n cancel(requestId) {\n /** @type {import('./index.d.ts').ActiveRequest|undefined} */\n const requestInfo = this.activeRequests.get(requestId);\n if (!requestInfo) return false;\n\n requestInfo.isCancelled = true; // Mark as cancelled\n\n // Try to abort using AbortController (for fetch)\n if (requestInfo.abortController && !requestInfo.abortController.signal.aborted) {\n try {\n requestInfo.abortController.abort('Request was cancelled');\n } catch (error) {}\n }\n\n // Try to cancel using cancel token/function (for axios and others)\n if (requestInfo.cancelToken) {\n try {\n if (typeof requestInfo.cancelToken === 'function') requestInfo.cancelToken();\n else if (requestInfo.cancelToken.cancel) requestInfo.cancelToken.cancel();\n } catch (error) {}\n }\n\n // Reject the wrapper promise\n this.#_deleteRequest(\n requestId,\n requestInfo.rejectWrapper,\n this.getOptions().verbose ? new Error(`Request ${requestId} was cancelled`) : null\n );\n return true;\n }\n\n /**\n * Link abort signal with HTTP client abort method.\n * Useful for custom HTTP clients that only support the abort method to cancel requests.\n * @param {Function} abortMethod - The abort method to call when the signal is aborted\n * @param {AbortSignal} signal - The signal to listen to\n */\n addAbortListener(abortMethod, signal) {\n if (!abortMethod || !signal) return;\n signal.addEventListener('abort', () => {\n if (typeof abortMethod === 'function') {\n try {\n abortMethod();\n } catch (error) {}\n }\n });\n }\n\n /**\n * Cancels all active requests.\n * @returns {number} The number of requests that were cancelled\n */\n cancelAll() {\n const requestIds = Array.from(this.activeRequests.keys());\n let cancelledCount = 0;\n requestIds.forEach((requestId) => {\n if (this.cancel(requestId)) cancelledCount++;\n });\n return cancelledCount;\n }\n\n /**\n * Resolves the AbortController for a request: explicit option, pending handoff, or new.\n * Clears the pending handoff so concurrent requests do not share it.\n * @param {AbortController|undefined} provided - Optional AbortController from options\n * @returns {AbortController}\n * @private\n */\n #_resolveAbortController(provided) {\n const abortController = provided || this.abortController || new AbortController();\n this.abortController = null;\n return abortController;\n }\n\n /**\n * Picks the best abort callback for a client request object.\n * @param {Object} req - The request object\n * @returns {Function|null}\n * @private\n */\n #_resolveAbortMethod(req) {\n if (!req) return null;\n if (typeof req.abort === 'function') return () => req.abort();\n const ExtAjax =\n typeof globalThis !== 'undefined' && globalThis.Ext && globalThis.Ext.Ajax ? globalThis.Ext.Ajax : null;\n if (req.xhr && ExtAjax && typeof ExtAjax.abort === 'function') {\n return () => ExtAjax.abort(req);\n }\n if (req.xhr && typeof req.xhr.abort === 'function') return () => req.xhr.abort();\n return null;\n }\n\n /**\n * Prepares request options by merging options and removing custom properties\n * @param {import('./index.d.ts').RequestOptions} options - Configuration options\n * @param {AbortSignal} signal - Abort signal to add to request options\n * @returns {Object} Prepared request options\n * @private\n */\n #_prepareRequestOptions(options, signal) {\n const requestOptions = {};\n const customOptions = [\n 'abortController',\n 'cancelToken',\n 'requestKey',\n 'noCancel',\n 'includeQuery',\n 'includeMethod',\n 'verbose',\n ];\n Object.keys(options).forEach((key) => {\n if (customOptions.includes(key)) return;\n requestOptions[key] = options[key];\n });\n requestOptions.signal = signal;\n return requestOptions;\n }\n\n /**\n * Warns when the provided axios instance predates 0.22.0, the first version\n * supporting AbortSignal cancellation. Older instances silently ignore\n * options.signal, so duplicate requests would not be cancelled.\n * @param {object} axiosLib - The axios instance about to be used\n * @private\n */\n #_checkAxiosVersion(axiosLib) {\n const version = typeof axiosLib?.VERSION === 'string' ? axiosLib.VERSION : null;\n if (!version) return;\n const [major, minor] = version.split('.').map(Number);\n if (major === 0 && minor < 22) {\n console.warn(\n `[request-manager] axios >= 0.22.0 is required: axios ${version} ignores the AbortSignal used for automatic cancellation. Please upgrade axios.`\n );\n }\n }\n\n /**\n * Deletes a request from the active requests map and rejects the wrapper promise\n * @param {string} requestId - The unique identifier of the request\n * @param {Function} rejectWrapper - The function to reject the wrapper promise\n * @param {*} error - The error to reject the wrapper promise with; the wrapper is not rejected if null/undefined\n * @private\n */\n #_deleteRequest(requestId, rejectWrapper, error) {\n this.activeRequests.delete(requestId);\n if (error !== null && error !== undefined) {\n rejectWrapper(error);\n }\n }\n\n /**\n * Completes a request by deleting it from the active requests map and resolving the wrapper promise\n * @param {string} requestId - The unique identifier of the request\n * @param {Function} resolveWrapper - The function to resolve the wrapper promise\n * @param {Promise} requestPromise - The request promise\n * @param {boolean} isCancelled - Whether the request was cancelled\n * @private\n */\n #_completeRequest(requestId, resolveWrapper, requestPromise, isCancelled) {\n this.activeRequests.delete(requestId);\n if (!isCancelled) {\n resolveWrapper(requestPromise);\n }\n }\n\n /**\n * Internal method that handles the core request logic.\n * @param {string} requestId - Unique identifier for the request\n * @param {Promise|import('./index.d.ts').RequestFunction|string} requestPromise - The request promise, function, or URL string\n * @param {import('./index.d.ts').BaseRequestOptions} options - Configuration options\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @private\n */\n #_request(requestId, requestPromise, options = {}) {\n const abortController = this.#_resolveAbortController(options.abortController);\n\n // Handle different types of requestPromise inputs\n // Priority: Function (Custom logic) > String (URL) > Promise (axios, fetch, etc.)\n if (typeof requestPromise === 'function') {\n // Function: custom logic for any library (axios, ajax, etc.)\n try {\n requestPromise = requestPromise({\n options: this.#_prepareRequestOptions(options, abortController.signal),\n });\n } catch (error) {\n return Promise.reject(error);\n }\n } else if (typeof requestPromise === 'string') {\n // String (URL): make fetch internally\n try {\n requestPromise = fetch(requestPromise, this.#_prepareRequestOptions(options, abortController.signal));\n } catch (error) {\n return Promise.reject(error);\n }\n }\n\n // Link the request object's abort method (Ext.Ajax, XHR, etc.) to the cancellation signal\n this.addAbortListener(this.#_resolveAbortMethod(requestPromise), abortController.signal);\n\n // Cancel previous request with the same identifier if it exists\n if (!options.noCancel) this.cancel(requestId);\n\n // Create a wrapper promise that will be resolved/rejected based on the request\n let resolveWrapper, rejectWrapper;\n const wrapperPromise = new Promise((resolve, reject) => {\n resolveWrapper = resolve;\n rejectWrapper = reject;\n });\n\n /**\n * @type {import('./index.d.ts').ActiveRequest}\n */\n const requestInfo = {\n promise: requestPromise,\n abortController: abortController,\n cancelToken: options.cancelToken || null,\n resolveWrapper: resolveWrapper,\n rejectWrapper: rejectWrapper,\n isCancelled: false,\n };\n\n this.activeRequests.set(requestId, requestInfo);\n\n // Handle request promise completion\n if (requestPromise && typeof requestPromise.then === 'function') {\n try {\n let req = requestPromise.then((result) => {\n if (this.activeRequests.get(requestId) !== requestInfo) return;\n this.#_completeRequest(requestId, resolveWrapper, result, requestInfo.isCancelled);\n });\n if (req.catch)\n req.catch((error) => {\n onError(this, error);\n });\n } catch (error) {\n onError(this, error);\n }\n function onError(scope, error) {\n // Check if this requestInfo is still the active one, or if it was cancelled\n if (scope.activeRequests.get(requestId) !== requestInfo) return;\n if (requestInfo.isCancelled) {\n // Already cancelled: let cancel() handle cleanup and reject the wrapper promise\n scope.cancel(requestId);\n return;\n }\n // Only delete if this is still the active request\n scope.#_deleteRequest(requestId, rejectWrapper, error);\n }\n } else {\n // Non-promise (Ext.Ajax request object, raw XHR, etc.). Keep tracked until the\n // underlying XHR finishes so a later duplicate can still cancel it.\n const xhr =\n requestPromise &&\n (requestPromise.xhr ||\n (typeof XMLHttpRequest !== 'undefined' && requestPromise instanceof XMLHttpRequest\n ? requestPromise\n : null));\n const finish = () => {\n if (this.activeRequests.get(requestId) !== requestInfo) return;\n this.#_completeRequest(requestId, resolveWrapper, requestPromise, requestInfo.isCancelled);\n };\n if (xhr && typeof xhr.addEventListener === 'function') {\n xhr.addEventListener('loadend', finish);\n } else {\n setTimeout(finish, 0);\n }\n }\n return wrapperPromise;\n }\n}\n\nexport default RequestManager;\n\nexport { RequestManager };\n"],"names":["RequestManager","constructor","options","arguments","length","undefined","_classPrivateMethodInitSpec","_RequestManager_brand","activeRequests","Map","abortController","getOptions","setOptions","getSignal","getAbortController","signal","AbortController","isActive","requestId","has","getActiveCount","size","clear","request","url","requestPromise","_assertClassBrand","_request","call","getRequestId","fetch","axios","axiosInstance","axiosLib","Error","_checkAxiosVersion","_ref","requestOptions","_objectSpread","ajax","ajaxFunction","_ref2","xhr","xhrFunction","_ref3","fetchOptions","XMLHttpRequest","method","toUpperCase","xhrPromise","Promise","resolve","reject","onload","detachAbortListener","status","_xhr$getResponseHeade","response","responseType","getResponseHeader","includes","JSON","parse","_unused","data","statusText","headers","getAllResponseHeaders","message","concat","onerror","ontimeout","open","withCredentials","timeout","Object","keys","forEach","key","setRequestHeader","abortListener","abort","addEventListener","removeEventListener","onabort","send","body","requestKey","prefix","noCancel","Date","now","Math","random","toString","slice","_unused2","String","cleanedUrl","split","includeQuery","methodPrefix","includeMethod","type","cancel","requestInfo","get","isCancelled","aborted","error","cancelToken","_deleteRequest","rejectWrapper","verbose","addAbortListener","abortMethod","cancelAll","requestIds","Array","from","cancelledCount","_resolveAbortController","provided","_resolveAbortMethod","req","ExtAjax","globalThis","Ext","Ajax","_prepareRequestOptions","customOptions","version","VERSION","_version$split$map","map","Number","_version$split$map2","_slicedToArray","major","minor","console","warn","delete","_completeRequest","resolveWrapper","wrapperPromise","promise","set","then","result","catch","onError","scope","finish","setTimeout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,CAAC;AACjBC,EAAAA,WAAWA,GAAe;AAAA,IAAA,IAAdC,QAAO,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAqaxB;AACJ;AACA;AACA;AACA;AACA;AACA;AANIG,IAAAA,2BAAA,OAAAC,qBAAA,CAAA;AApaI;AACR;AACA;AACQ,IAAA,IAAI,CAACC,cAAc,GAAG,IAAIC,GAAG,EAAE;AAC/B;AACR;AACA;IACQ,IAAI,CAACP,OAAO,GAAGA,QAAO;AACtB;AACR;AACA;AACA;AACA;IACQ,IAAI,CAACQ,eAAe,GAAG,IAAI;AAC/B,EAAA;;AAEA;AACJ;AACA;AACA;AACIC,EAAAA,UAAUA,GAAG;IACT,OAAO,IAAI,CAACT,OAAO;AACvB,EAAA;;AAEA;AACJ;AACA;AACA;EACIU,UAAUA,CAACV,OAAO,EAAE;IAChB,IAAI,CAACA,OAAO,GAAGA,OAAO;AAC1B,EAAA;;AAEA;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI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nH,IAAA,CAAtB,IAAI,EAAmBV,SAAS,EAAE8H,cAAc,EAAEvH,cAAc,EAAEgF,WAAW,CAACE,WAAW,CAAA;IAC7F,CAAC;IACD,IAAIjE,GAAG,IAAI,OAAOA,GAAG,CAACwC,gBAAgB,KAAK,UAAU,EAAE;AACnDxC,MAAAA,GAAG,CAACwC,gBAAgB,CAAC,SAAS,EAAEuE,MAAM,CAAC;AAC3C,IAAA,CAAC,MAAM;AACHC,MAAAA,UAAU,CAACD,MAAM,EAAE,CAAC,CAAC;AACzB,IAAA;AACJ,EAAA;AACA,EAAA,OAAOR,cAAc;AACzB;;;;;"}
|
|
@@ -276,7 +276,10 @@ class RequestManager {
|
|
|
276
276
|
axios(url) {
|
|
277
277
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
278
278
|
var axiosInstance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
279
|
-
var axiosLib = axiosInstance || axios;
|
|
279
|
+
var axiosLib = axiosInstance || (typeof axios !== 'undefined' ? axios : null);
|
|
280
|
+
if (!axiosLib) {
|
|
281
|
+
throw new Error('axios was not found: pass an axios instance as the third argument of requestManager.axios() or make sure axios is available globally');
|
|
282
|
+
}
|
|
280
283
|
_assertClassBrand(_RequestManager_brand, this, _checkAxiosVersion).call(this, axiosLib);
|
|
281
284
|
return _assertClassBrand(_RequestManager_brand, this, _request).call(this, this.getRequestId(url, options), _ref => {
|
|
282
285
|
var requestOptions = _ref.options;
|
|
@@ -342,7 +345,6 @@ class RequestManager {
|
|
|
342
345
|
*/
|
|
343
346
|
xhr(url) {
|
|
344
347
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
345
|
-
var requestId = this.getRequestId(url, options);
|
|
346
348
|
/** @type {import('./index.d.ts').RequestFunction<import('./index.d.ts').XhrResponse>} */
|
|
347
349
|
var xhrFunction = _ref3 => {
|
|
348
350
|
var fetchOptions = _ref3.options;
|
|
@@ -352,6 +354,7 @@ class RequestManager {
|
|
|
352
354
|
// Create a promise that wraps the XHR request
|
|
353
355
|
var xhrPromise = new Promise((resolve, reject) => {
|
|
354
356
|
xhr.onload = function () {
|
|
357
|
+
detachAbortListener();
|
|
355
358
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
356
359
|
var _xhr$getResponseHeade;
|
|
357
360
|
var response = xhr.response;
|
|
@@ -377,12 +380,14 @@ class RequestManager {
|
|
|
377
380
|
}
|
|
378
381
|
};
|
|
379
382
|
xhr.onerror = function () {
|
|
383
|
+
detachAbortListener();
|
|
380
384
|
reject({
|
|
381
385
|
message: 'Network error',
|
|
382
386
|
xhr: xhr
|
|
383
387
|
});
|
|
384
388
|
};
|
|
385
389
|
xhr.ontimeout = function () {
|
|
390
|
+
detachAbortListener();
|
|
386
391
|
reject({
|
|
387
392
|
message: 'Request timeout',
|
|
388
393
|
xhr: xhr
|
|
@@ -404,14 +409,25 @@ class RequestManager {
|
|
|
404
409
|
});
|
|
405
410
|
|
|
406
411
|
// Connect abort signal to xhr.abort()
|
|
407
|
-
|
|
412
|
+
var abortListener = () => xhr.abort();
|
|
413
|
+
if (fetchOptions.signal) fetchOptions.signal.addEventListener('abort', abortListener);
|
|
414
|
+
// Detach the listener once the request settles so completed requests do not keep it alive
|
|
415
|
+
var detachAbortListener = () => {
|
|
416
|
+
if (fetchOptions.signal) fetchOptions.signal.removeEventListener('abort', abortListener);
|
|
417
|
+
};
|
|
418
|
+
xhr.onabort = function () {
|
|
419
|
+
reject({
|
|
420
|
+
message: 'Request was cancelled',
|
|
421
|
+
xhr: xhr
|
|
422
|
+
});
|
|
423
|
+
};
|
|
408
424
|
|
|
409
425
|
// Send the request
|
|
410
426
|
xhr.send(options.body || null);
|
|
411
427
|
});
|
|
412
428
|
return xhrPromise;
|
|
413
429
|
};
|
|
414
|
-
return _assertClassBrand(_RequestManager_brand, this, _request).call(this,
|
|
430
|
+
return _assertClassBrand(_RequestManager_brand, this, _request).call(this, this.getRequestId(url, options), xhrFunction, options);
|
|
415
431
|
}
|
|
416
432
|
|
|
417
433
|
/**
|
|
@@ -543,7 +559,7 @@ function _resolveAbortMethod(req) {
|
|
|
543
559
|
*/
|
|
544
560
|
function _prepareRequestOptions(options, signal) {
|
|
545
561
|
var requestOptions = {};
|
|
546
|
-
var customOptions = ['abortController', 'cancelToken', 'requestKey', 'noCancel', 'includeQuery'];
|
|
562
|
+
var customOptions = ['abortController', 'cancelToken', 'requestKey', 'noCancel', 'includeQuery', 'includeMethod', 'verbose'];
|
|
547
563
|
Object.keys(options).forEach(key => {
|
|
548
564
|
if (customOptions.includes(key)) return;
|
|
549
565
|
requestOptions[key] = options[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-manager.esm.js","sources":["../main.js"],"sourcesContent":["/**\n * RequestManager - A library for managing and regulating HTTP requests efficiently.\n * @license MIT\n * @author Eneko Galan <enekogalanelorza@gmail.com>\n * This library allows you to manage HTTP requests from any library (ajax, Ext.Ajax, axios, fetch, etc.)\n * by accepting Promises as parameters. When a request is repeated with the same identifier,\n * the previous request is automatically cancelled and the new one is executed, giving priority to the most recent requests.\n */\nclass RequestManager {\n constructor(options = {}) {\n /**\n * @type {Map<string, import('./index.d.ts').ActiveRequest>}\n */\n this.activeRequests = new Map();\n /**\n * @type {import('./index.d.ts').Options}\n */\n this.options = options;\n /**\n * One-shot AbortController for getSignal()/getAbortController() handoff.\n * Consumed by the next request that does not pass options.abortController.\n * @type {AbortController|null}\n */\n this.abortController = null;\n }\n\n /**\n * Gets the manager options\n * @returns {import('./index.d.ts').Options} Manager options\n */\n getOptions() {\n return this.options;\n }\n\n /**\n * Sets the manager options\n * @param {import('./index.d.ts').Options} options - The options to set\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n * Creates a new AbortController and returns its signal for the next request()\n * (one getSignal → one request). Do not use for parallel requests; use fetch(),\n * axios(), or request(url, ({ options }) => ...) instead — they create their own signal.\n * @returns {AbortSignal} The signal from a new AbortController\n * @example\n * const signal = requestManager.getSignal();\n * requestManager.request('/api/users', fetch('/api/users', { signal }));\n */\n getSignal() {\n return this.getAbortController().signal;\n }\n\n /**\n * Creates a new AbortController for the next request handoff.\n * Always returns a fresh controller (never reuses one from another in-flight request).\n * @returns {AbortController} A new AbortController instance\n */\n getAbortController() {\n this.abortController = new AbortController();\n return this.abortController;\n }\n\n /**\n * Checks if a request with the given identifier is currently active.\n * @param {string} requestId - The unique identifier to check\n * @returns {boolean} True if the request is active, false otherwise\n */\n isActive(requestId) {\n return this.activeRequests.has(requestId);\n }\n\n /**\n * Gets the number of active requests.\n * @returns {number} The number of currently active requests\n */\n getActiveCount() {\n return this.activeRequests.size;\n }\n\n /**\n * Clears all active requests without cancelling them.\n * Use with caution - this will not cancel the underlying HTTP requests.\n */\n clear() {\n this.activeRequests.clear();\n }\n\n /**\n * Executes an HTTP request, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {Promise|import('./index.d.ts').RequestFunction|string} requestPromise - The request promise or function that returns a promise\n * @param {import('./index.d.ts').RequestOptions} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Request with Promise\n * requestManager.request('/api/users', axios.get('/api/users'));\n * @example\n * // Request with Function\n * requestManager.request('/api/users', ({ options }) => fetch('/api/users', { signal: options.signal, ...options }));\n * @example\n * // Request with Promise and custom cancellation grouping with requestKey\n * const options = {\n * requestKey: 'get-users'\n * }\n * requestManager.request('/api/users', axios.get('/api/users', options), options);\n */\n request(url, requestPromise, options = {}) {\n return this.#_request(this.getRequestId(url, options), requestPromise, options);\n }\n\n /**\n * Executes an HTTP request using fetch, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to fetch\n * @param {import('./index.d.ts').FetchOptions} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.fetch('/api/users');\n * @example\n * // POST request with options\n * requestManager.fetch('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.fetch('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n fetch(url, options = {}) {\n return this.#_request(this.getRequestId(url, options), url, options);\n }\n\n /**\n * Executes an HTTP request using axios, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').AxiosRequestOptions} options - Optional configuration\n * @param {import('./index.d.ts').AxiosInstance|import('./index.d.ts').AxiosStatic|null} axiosInstance - Optional axios instance to use. If not provided, uses global axios.\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request (uses global axios)\n * requestManager.axios('/api/users');\n * @example\n * // With custom axios instance\n * const myAxios = axios.create({ baseURL: 'https://api.example.com' });\n * requestManager.axios('/users', {}, myAxios);\n * @example\n * // POST request with options\n * requestManager.axios('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.axios('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n axios(url, options = {}, axiosInstance = null) {\n const axiosLib = axiosInstance || axios;\n this.#_checkAxiosVersion(axiosLib);\n return this.#_request(\n this.getRequestId(url, options),\n ({ options: requestOptions }) => axiosLib({ url, ...requestOptions }),\n options\n );\n }\n\n /**\n * Executes an HTTP request using jQuery.ajax, cancelling any previous request with the same identifier.\n * @param {import('./index.d.ts').AjaxFunction} ajaxFunction - A function that receives { url, ...options } and returns a Promise\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').BaseRequestOptions & Record<string, any>} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.ajax(ajaxFunction, '/api/users');\n * @example\n * // POST request with options\n * requestManager.ajax(ajaxFunction, '/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.ajax(ajaxFunction, '/api/users', {\n * requestKey: 'get-users'\n * });\n */\n ajax(ajaxFunction, url, options = {}) {\n if (typeof ajaxFunction !== 'function') throw new Error('ajaxFunction parameter must be a function');\n return this.#_request(\n this.getRequestId(url, options),\n ({ options: requestOptions }) => ajaxFunction({ url, ...requestOptions }),\n options\n );\n }\n\n /**\n * Executes an HTTP request using XMLHttpRequest, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').XhrOptions} options - Optional configuration\n * @returns {Promise<import('./index.d.ts').XhrResponse>} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.xhr('/api/users');\n * @example\n * // POST request with options\n * requestManager.xhr('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping\n * requestManager.xhr('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n xhr(url, options = {}) {\n const requestId = this.getRequestId(url, options);\n /** @type {import('./index.d.ts').RequestFunction<import('./index.d.ts').XhrResponse>} */\n const xhrFunction = ({ options: fetchOptions }) => {\n // Create XMLHttpRequest\n const xhr = new XMLHttpRequest();\n const method = (options.method || 'GET').toUpperCase();\n // Create a promise that wraps the XHR request\n const xhrPromise = new Promise((resolve, reject) => {\n xhr.onload = function () {\n if (xhr.status >= 200 && xhr.status < 300) {\n let response = xhr.response;\n if (\n options.responseType === 'json' ||\n ((!options.responseType || options.responseType === 'text') &&\n xhr.getResponseHeader('Content-Type')?.includes('application/json') &&\n typeof response === 'string')\n ) {\n try {\n response = JSON.parse(response);\n } catch {}\n }\n resolve({\n data: response,\n status: xhr.status,\n statusText: xhr.statusText,\n headers: xhr.getAllResponseHeaders(),\n xhr: xhr,\n });\n } else {\n reject({\n message: `Request failed with status ${xhr.status}`,\n status: xhr.status,\n statusText: xhr.statusText,\n xhr: xhr,\n });\n }\n };\n xhr.onerror = function () {\n reject({\n message: 'Network error',\n xhr: xhr,\n });\n };\n xhr.ontimeout = function () {\n reject({\n message: 'Request timeout',\n xhr: xhr,\n });\n };\n\n // Open the request\n xhr.open(method, url, true);\n\n // Set response type\n if (options.responseType) xhr.responseType = options.responseType;\n // Set withCredentials\n if (options.withCredentials !== undefined) xhr.withCredentials = options.withCredentials;\n // Set timeout\n if (options.timeout !== undefined) xhr.timeout = options.timeout;\n // Set headers\n if (options.headers)\n Object.keys(options.headers).forEach((key) => {\n xhr.setRequestHeader(key, options.headers[key]);\n });\n\n // Connect abort signal to xhr.abort()\n if (fetchOptions.signal) fetchOptions.signal.addEventListener('abort', () => xhr.abort());\n\n // Send the request\n xhr.send(options.body || null);\n });\n return xhrPromise;\n };\n return this.#_request(requestId, xhrFunction, options);\n }\n\n /**\n * Returns the request identifier for a URL and options.\n * @param {string} url - The URL used when starting the request\n * @param {import('./index.d.ts').BaseRequestOptions} options - Same options used for the request\n * @returns {string} The request identifier\n * @example\n * requestManager.fetch('/api/users');\n * const id = requestManager.getRequestId('/api/users');\n * requestManager.cancel(id);\n */\n getRequestId(url, options = {}) {\n let requestKey = options.requestKey;\n\n const prefix = 'request_';\n\n // Generate a unique identifier to prevent cancellation for non cancelable requests\n if (options.noCancel) {\n return `${prefix}${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;\n }\n\n // Handle function requestKey\n if (typeof requestKey === 'function') {\n try {\n requestKey = requestKey();\n } catch {\n requestKey = null;\n }\n }\n if (requestKey !== null && requestKey !== undefined) return `${prefix}${String(requestKey)}`;\n\n // Use cleaned URL as key as fallback\n let cleanedUrl = url || '';\n if (cleanedUrl.includes('://')) cleanedUrl = cleanedUrl.split('://')[1];\n if (cleanedUrl.includes('#')) cleanedUrl = cleanedUrl.split('#')[0];\n if (!options.includeQuery && cleanedUrl.includes('?')) cleanedUrl = cleanedUrl.split('?')[0];\n\n const methodPrefix =\n options.includeMethod === false ? '' : `${(options.method || options.type || 'GET').toUpperCase()}_`;\n\n return `${prefix}${methodPrefix}${cleanedUrl}`;\n }\n\n /**\n * Cancels a specific request by its identifier.\n * @param {string} requestId - The unique identifier of the request to cancel\n * @returns {boolean} True if the request was found and cancelled, false otherwise\n */\n cancel(requestId) {\n /** @type {import('./index.d.ts').ActiveRequest|undefined} */\n const requestInfo = this.activeRequests.get(requestId);\n if (!requestInfo) return false;\n\n requestInfo.isCancelled = true; // Mark as cancelled\n\n // Try to abort using AbortController (for fetch)\n if (requestInfo.abortController && !requestInfo.abortController.signal.aborted) {\n try {\n requestInfo.abortController.abort('Request was cancelled');\n } catch (error) {}\n }\n\n // Try to cancel using cancel token/function (for axios and others)\n if (requestInfo.cancelToken) {\n try {\n if (typeof requestInfo.cancelToken === 'function') requestInfo.cancelToken();\n else if (requestInfo.cancelToken.cancel) requestInfo.cancelToken.cancel();\n } catch (error) {}\n }\n\n // Reject the wrapper promise\n this.#_deleteRequest(\n requestId,\n requestInfo.rejectWrapper,\n this.getOptions().verbose ? new Error(`Request ${requestId} was cancelled`) : null\n );\n return true;\n }\n\n /**\n * Link abort signal with HTTP client abort method.\n * Useful for custom HTTP clients that only support the abort method to cancel requests.\n * @param {Function} abortMethod - The abort method to call when the signal is aborted\n * @param {AbortSignal} signal - The signal to listen to\n */\n addAbortListener(abortMethod, signal) {\n if (!abortMethod || !signal) return;\n signal.addEventListener('abort', () => {\n if (typeof abortMethod === 'function') {\n try {\n abortMethod();\n } catch (error) {}\n }\n });\n }\n\n /**\n * Cancels all active requests.\n * @returns {number} The number of requests that were cancelled\n */\n cancelAll() {\n const requestIds = Array.from(this.activeRequests.keys());\n let cancelledCount = 0;\n requestIds.forEach((requestId) => {\n if (this.cancel(requestId)) cancelledCount++;\n });\n return cancelledCount;\n }\n\n /**\n * Resolves the AbortController for a request: explicit option, pending handoff, or new.\n * Clears the pending handoff so concurrent requests do not share it.\n * @param {AbortController|undefined} provided - Optional AbortController from options\n * @returns {AbortController}\n * @private\n */\n #_resolveAbortController(provided) {\n const abortController = provided || this.abortController || new AbortController();\n this.abortController = null;\n return abortController;\n }\n\n /**\n * Picks the best abort callback for a client request object.\n * @param {Object} req - The request object\n * @returns {Function|null}\n * @private\n */\n #_resolveAbortMethod(req) {\n if (!req) return null;\n if (typeof req.abort === 'function') return () => req.abort();\n const ExtAjax =\n typeof globalThis !== 'undefined' && globalThis.Ext && globalThis.Ext.Ajax ? globalThis.Ext.Ajax : null;\n if (req.xhr && ExtAjax && typeof ExtAjax.abort === 'function') {\n return () => ExtAjax.abort(req);\n }\n if (req.xhr && typeof req.xhr.abort === 'function') return () => req.xhr.abort();\n return null;\n }\n\n /**\n * Prepares request options by merging options and removing custom properties\n * @param {import('./index.d.ts').RequestOptions} options - Configuration options\n * @param {AbortSignal} signal - Abort signal to add to request options\n * @returns {Object} Prepared request options\n * @private\n */\n #_prepareRequestOptions(options, signal) {\n const requestOptions = {};\n const customOptions = ['abortController', 'cancelToken', 'requestKey', 'noCancel', 'includeQuery'];\n Object.keys(options).forEach((key) => {\n if (customOptions.includes(key)) return;\n requestOptions[key] = options[key];\n });\n requestOptions.signal = signal;\n return requestOptions;\n }\n\n /**\n * Warns when the provided axios instance predates 0.22.0, the first version\n * supporting AbortSignal cancellation. Older instances silently ignore\n * options.signal, so duplicate requests would not be cancelled.\n * @param {object} axiosLib - The axios instance about to be used\n * @private\n */\n #_checkAxiosVersion(axiosLib) {\n const version = typeof axiosLib?.VERSION === 'string' ? axiosLib.VERSION : null;\n if (!version) return;\n const [major, minor] = version.split('.').map(Number);\n if (major === 0 && minor < 22) {\n console.warn(\n `[request-manager] axios >= 0.22.0 is required: axios ${version} ignores the AbortSignal used for automatic cancellation. Please upgrade axios.`\n );\n }\n }\n\n /**\n * Deletes a request from the active requests map and rejects the wrapper promise\n * @param {string} requestId - The unique identifier of the request\n * @param {Function} rejectWrapper - The function to reject the wrapper promise\n * @param {*} error - The error to reject the wrapper promise with; the wrapper is not rejected if null/undefined\n * @private\n */\n #_deleteRequest(requestId, rejectWrapper, error) {\n this.activeRequests.delete(requestId);\n if (error !== null && error !== undefined) {\n rejectWrapper(error);\n }\n }\n\n /**\n * Completes a request by deleting it from the active requests map and resolving the wrapper promise\n * @param {string} requestId - The unique identifier of the request\n * @param {Function} resolveWrapper - The function to resolve the wrapper promise\n * @param {Promise} requestPromise - The request promise\n * @param {boolean} isCancelled - Whether the request was cancelled\n * @private\n */\n #_completeRequest(requestId, resolveWrapper, requestPromise, isCancelled) {\n this.activeRequests.delete(requestId);\n if (!isCancelled) {\n resolveWrapper(requestPromise);\n }\n }\n\n /**\n * Internal method that handles the core request logic.\n * @param {string} requestId - Unique identifier for the request\n * @param {Promise|import('./index.d.ts').RequestFunction|string} requestPromise - The request promise, function, or URL string\n * @param {import('./index.d.ts').BaseRequestOptions} options - Configuration options\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @private\n */\n #_request(requestId, requestPromise, options = {}) {\n const abortController = this.#_resolveAbortController(options.abortController);\n\n // Handle different types of requestPromise inputs\n // Priority: Function (Custom logic) > String (URL) > Promise (axios, fetch, etc.)\n if (typeof requestPromise === 'function') {\n // Function: custom logic for any library (axios, ajax, etc.)\n try {\n requestPromise = requestPromise({\n options: this.#_prepareRequestOptions(options, abortController.signal),\n });\n } catch (error) {\n return Promise.reject(error);\n }\n } else if (typeof requestPromise === 'string') {\n // String (URL): make fetch internally\n try {\n requestPromise = fetch(requestPromise, this.#_prepareRequestOptions(options, abortController.signal));\n } catch (error) {\n return Promise.reject(error);\n }\n }\n\n // Link the request object's abort method (Ext.Ajax, XHR, etc.) to the cancellation signal\n this.addAbortListener(this.#_resolveAbortMethod(requestPromise), abortController.signal);\n\n // Cancel previous request with the same identifier if it exists\n if (!options.noCancel) this.cancel(requestId);\n\n // Create a wrapper promise that will be resolved/rejected based on the request\n let resolveWrapper, rejectWrapper;\n const wrapperPromise = new Promise((resolve, reject) => {\n resolveWrapper = resolve;\n rejectWrapper = reject;\n });\n\n /**\n * @type {import('./index.d.ts').ActiveRequest}\n */\n const requestInfo = {\n promise: requestPromise,\n abortController: abortController,\n cancelToken: options.cancelToken || null,\n resolveWrapper: resolveWrapper,\n rejectWrapper: rejectWrapper,\n isCancelled: false,\n };\n\n this.activeRequests.set(requestId, requestInfo);\n\n // Handle request promise completion\n if (requestPromise && typeof requestPromise.then === 'function') {\n try {\n let req = requestPromise.then((result) => {\n if (this.activeRequests.get(requestId) !== requestInfo) return;\n this.#_completeRequest(requestId, resolveWrapper, result, requestInfo.isCancelled);\n });\n if (req.catch)\n req.catch((error) => {\n onError(this, error);\n });\n } catch (error) {\n onError(this, error);\n }\n function onError(scope, error) {\n // Check if this requestInfo is still the active one, or if it was cancelled\n if (scope.activeRequests.get(requestId) !== requestInfo) return;\n if (requestInfo.isCancelled) {\n // Already cancelled: let cancel() handle cleanup and reject the wrapper promise\n scope.cancel(requestId);\n return;\n }\n // Only delete if this is still the active request\n scope.#_deleteRequest(requestId, rejectWrapper, error);\n }\n } else {\n // Non-promise (Ext.Ajax request object, raw XHR, etc.). Keep tracked until the\n // underlying XHR finishes so a later duplicate can still cancel it.\n const xhr =\n requestPromise &&\n (requestPromise.xhr ||\n (typeof XMLHttpRequest !== 'undefined' && requestPromise instanceof XMLHttpRequest\n ? requestPromise\n : null));\n const finish = () => {\n if (this.activeRequests.get(requestId) !== requestInfo) return;\n this.#_completeRequest(requestId, resolveWrapper, requestPromise, requestInfo.isCancelled);\n };\n if (xhr && typeof xhr.addEventListener === 'function') {\n xhr.addEventListener('loadend', finish);\n } else {\n setTimeout(finish, 0);\n }\n }\n return wrapperPromise;\n }\n}\n\nexport default RequestManager;\n\nexport { RequestManager };\n"],"names":["RequestManager","constructor","options","arguments","length","undefined","_classPrivateMethodInitSpec","_RequestManager_brand","activeRequests","Map","abortController","getOptions","setOptions","getSignal","getAbortController","signal","AbortController","isActive","requestId","has","getActiveCount","size","clear","request","url","requestPromise","_assertClassBrand","_request","call","getRequestId","fetch","axios","axiosInstance","axiosLib","_checkAxiosVersion","_ref","requestOptions","_objectSpread","ajax","ajaxFunction","Error","_ref2","xhr","xhrFunction","_ref3","fetchOptions","XMLHttpRequest","method","toUpperCase","xhrPromise","Promise","resolve","reject","onload","status","_xhr$getResponseHeade","response","responseType","getResponseHeader","includes","JSON","parse","_unused","data","statusText","headers","getAllResponseHeaders","message","concat","onerror","ontimeout","open","withCredentials","timeout","Object","keys","forEach","key","setRequestHeader","addEventListener","abort","send","body","requestKey","prefix","noCancel","Date","now","Math","random","toString","slice","_unused2","String","cleanedUrl","split","includeQuery","methodPrefix","includeMethod","type","cancel","requestInfo","get","isCancelled","aborted","error","cancelToken","_deleteRequest","rejectWrapper","verbose","addAbortListener","abortMethod","cancelAll","requestIds","Array","from","cancelledCount","_resolveAbortController","provided","_resolveAbortMethod","req","ExtAjax","globalThis","Ext","Ajax","_prepareRequestOptions","customOptions","version","VERSION","_version$split$map","map","Number","_version$split$map2","_slicedToArray","major","minor","console","warn","delete","_completeRequest","resolveWrapper","wrapperPromise","promise","set","then","result","catch","onError","scope","finish","setTimeout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,CAAC;AACjBC,EAAAA,WAAWA,GAAe;AAAA,IAAA,IAAdC,QAAO,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAkZxB;AACJ;AACA;AACA;AACA;AACA;AACA;AANIG,IAAAA,2BAAA,OAAAC,qBAAA,CAAA;AAjZI;AACR;AACA;AACQ,IAAA,IAAI,CAACC,cAAc,GAAG,IAAIC,GAAG,EAAE;AAC/B;AACR;AACA;IACQ,IAAI,CAACP,OA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AEsE,MAAM,CAAC;AAC3C,IAAA,CAAC,MAAM;AACHC,MAAAA,UAAU,CAACD,MAAM,EAAE,CAAC,CAAC;AACzB,IAAA;AACJ,EAAA;AACA,EAAA,OAAOR,cAAc;AACzB;;;;"}
|
|
1
|
+
{"version":3,"file":"request-manager.esm.js","sources":["../main.js"],"sourcesContent":["/**\n * RequestManager - A library for managing and regulating HTTP requests efficiently.\n * @license MIT\n * @author Eneko Galan <enekogalanelorza@gmail.com>\n * This library allows you to manage HTTP requests from any library (ajax, Ext.Ajax, axios, fetch, etc.)\n * by accepting Promises as parameters. When a request is repeated with the same identifier,\n * the previous request is automatically cancelled and the new one is executed, giving priority to the most recent requests.\n */\nclass RequestManager {\n constructor(options = {}) {\n /**\n * @type {Map<string, import('./index.d.ts').ActiveRequest>}\n */\n this.activeRequests = new Map();\n /**\n * @type {import('./index.d.ts').Options}\n */\n this.options = options;\n /**\n * One-shot AbortController for getSignal()/getAbortController() handoff.\n * Consumed by the next request that does not pass options.abortController.\n * @type {AbortController|null}\n */\n this.abortController = null;\n }\n\n /**\n * Gets the manager options\n * @returns {import('./index.d.ts').Options} Manager options\n */\n getOptions() {\n return this.options;\n }\n\n /**\n * Sets the manager options\n * @param {import('./index.d.ts').Options} options - The options to set\n */\n setOptions(options) {\n this.options = options;\n }\n\n /**\n * Creates a new AbortController and returns its signal for the next request()\n * (one getSignal → one request). Do not use for parallel requests; use fetch(),\n * axios(), or request(url, ({ options }) => ...) instead — they create their own signal.\n * @returns {AbortSignal} The signal from a new AbortController\n * @example\n * const signal = requestManager.getSignal();\n * requestManager.request('/api/users', fetch('/api/users', { signal }));\n */\n getSignal() {\n return this.getAbortController().signal;\n }\n\n /**\n * Creates a new AbortController for the next request handoff.\n * Always returns a fresh controller (never reuses one from another in-flight request).\n * @returns {AbortController} A new AbortController instance\n */\n getAbortController() {\n this.abortController = new AbortController();\n return this.abortController;\n }\n\n /**\n * Checks if a request with the given identifier is currently active.\n * @param {string} requestId - The unique identifier to check\n * @returns {boolean} True if the request is active, false otherwise\n */\n isActive(requestId) {\n return this.activeRequests.has(requestId);\n }\n\n /**\n * Gets the number of active requests.\n * @returns {number} The number of currently active requests\n */\n getActiveCount() {\n return this.activeRequests.size;\n }\n\n /**\n * Clears all active requests without cancelling them.\n * Use with caution - this will not cancel the underlying HTTP requests.\n */\n clear() {\n this.activeRequests.clear();\n }\n\n /**\n * Executes an HTTP request, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {Promise|import('./index.d.ts').RequestFunction|string} requestPromise - The request promise or function that returns a promise\n * @param {import('./index.d.ts').RequestOptions} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Request with Promise\n * requestManager.request('/api/users', axios.get('/api/users'));\n * @example\n * // Request with Function\n * requestManager.request('/api/users', ({ options }) => fetch('/api/users', { signal: options.signal, ...options }));\n * @example\n * // Request with Promise and custom cancellation grouping with requestKey\n * const options = {\n * requestKey: 'get-users'\n * }\n * requestManager.request('/api/users', axios.get('/api/users', options), options);\n */\n request(url, requestPromise, options = {}) {\n return this.#_request(this.getRequestId(url, options), requestPromise, options);\n }\n\n /**\n * Executes an HTTP request using fetch, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to fetch\n * @param {import('./index.d.ts').FetchOptions} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.fetch('/api/users');\n * @example\n * // POST request with options\n * requestManager.fetch('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.fetch('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n fetch(url, options = {}) {\n return this.#_request(this.getRequestId(url, options), url, options);\n }\n\n /**\n * Executes an HTTP request using axios, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').AxiosRequestOptions} options - Optional configuration\n * @param {import('./index.d.ts').AxiosInstance|import('./index.d.ts').AxiosStatic|null} axiosInstance - Optional axios instance to use. If not provided, uses global axios.\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request (uses global axios)\n * requestManager.axios('/api/users');\n * @example\n * // With custom axios instance\n * const myAxios = axios.create({ baseURL: 'https://api.example.com' });\n * requestManager.axios('/users', {}, myAxios);\n * @example\n * // POST request with options\n * requestManager.axios('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.axios('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n axios(url, options = {}, axiosInstance = null) {\n const axiosLib = axiosInstance || (typeof axios !== 'undefined' ? axios : null);\n if (!axiosLib) {\n throw new Error(\n 'axios was not found: pass an axios instance as the third argument of requestManager.axios() or make sure axios is available globally'\n );\n }\n this.#_checkAxiosVersion(axiosLib);\n return this.#_request(\n this.getRequestId(url, options),\n ({ options: requestOptions }) => axiosLib({ url, ...requestOptions }),\n options\n );\n }\n\n /**\n * Executes an HTTP request using jQuery.ajax, cancelling any previous request with the same identifier.\n * @param {import('./index.d.ts').AjaxFunction} ajaxFunction - A function that receives { url, ...options } and returns a Promise\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').BaseRequestOptions & Record<string, any>} options - Optional configuration\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.ajax(ajaxFunction, '/api/users');\n * @example\n * // POST request with options\n * requestManager.ajax(ajaxFunction, '/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.ajax(ajaxFunction, '/api/users', {\n * requestKey: 'get-users'\n * });\n */\n ajax(ajaxFunction, url, options = {}) {\n if (typeof ajaxFunction !== 'function') throw new Error('ajaxFunction parameter must be a function');\n return this.#_request(\n this.getRequestId(url, options),\n ({ options: requestOptions }) => ajaxFunction({ url, ...requestOptions }),\n options\n );\n }\n\n /**\n * Executes an HTTP request using XMLHttpRequest, cancelling any previous request with the same identifier.\n * @param {string} url - The URL to request\n * @param {import('./index.d.ts').XhrOptions} options - Optional configuration\n * @returns {Promise<import('./index.d.ts').XhrResponse>} A Promise that resolves/rejects based on the most recent request\n * @example\n * // Simple GET request\n * requestManager.xhr('/api/users');\n * @example\n * // POST request with options\n * requestManager.xhr('/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * @example\n * // Request with requestKey for custom cancellation grouping\n * requestManager.xhr('/api/users', {\n * requestKey: 'get-users'\n * });\n */\n xhr(url, options = {}) {\n /** @type {import('./index.d.ts').RequestFunction<import('./index.d.ts').XhrResponse>} */\n const xhrFunction = ({ options: fetchOptions }) => {\n // Create XMLHttpRequest\n const xhr = new XMLHttpRequest();\n const method = (options.method || 'GET').toUpperCase();\n // Create a promise that wraps the XHR request\n const xhrPromise = new Promise((resolve, reject) => {\n xhr.onload = function () {\n detachAbortListener();\n if (xhr.status >= 200 && xhr.status < 300) {\n let response = xhr.response;\n if (\n options.responseType === 'json' ||\n ((!options.responseType || options.responseType === 'text') &&\n xhr.getResponseHeader('Content-Type')?.includes('application/json') &&\n typeof response === 'string')\n ) {\n try {\n response = JSON.parse(response);\n } catch {}\n }\n resolve({\n data: response,\n status: xhr.status,\n statusText: xhr.statusText,\n headers: xhr.getAllResponseHeaders(),\n xhr: xhr,\n });\n } else {\n reject({\n message: `Request failed with status ${xhr.status}`,\n status: xhr.status,\n statusText: xhr.statusText,\n xhr: xhr,\n });\n }\n };\n xhr.onerror = function () {\n detachAbortListener();\n reject({\n message: 'Network error',\n xhr: xhr,\n });\n };\n xhr.ontimeout = function () {\n detachAbortListener();\n reject({\n message: 'Request timeout',\n xhr: xhr,\n });\n };\n\n // Open the request\n xhr.open(method, url, true);\n\n // Set response type\n if (options.responseType) xhr.responseType = options.responseType;\n // Set withCredentials\n if (options.withCredentials !== undefined) xhr.withCredentials = options.withCredentials;\n // Set timeout\n if (options.timeout !== undefined) xhr.timeout = options.timeout;\n // Set headers\n if (options.headers)\n Object.keys(options.headers).forEach((key) => {\n xhr.setRequestHeader(key, options.headers[key]);\n });\n\n // Connect abort signal to xhr.abort()\n const abortListener = () => xhr.abort();\n if (fetchOptions.signal) fetchOptions.signal.addEventListener('abort', abortListener);\n // Detach the listener once the request settles so completed requests do not keep it alive\n const detachAbortListener = () => {\n if (fetchOptions.signal) fetchOptions.signal.removeEventListener('abort', abortListener);\n };\n\n xhr.onabort = function () {\n reject({\n message: 'Request was cancelled',\n xhr: xhr,\n });\n };\n\n // Send the request\n xhr.send(options.body || null);\n });\n return xhrPromise;\n };\n return this.#_request(this.getRequestId(url, options), xhrFunction, options);\n }\n\n /**\n * Returns the request identifier for a URL and options.\n * @param {string} url - The URL used when starting the request\n * @param {import('./index.d.ts').BaseRequestOptions} options - Same options used for the request\n * @returns {string} The request identifier\n * @example\n * requestManager.fetch('/api/users');\n * const id = requestManager.getRequestId('/api/users');\n * requestManager.cancel(id);\n */\n getRequestId(url, options = {}) {\n let requestKey = options.requestKey;\n\n const prefix = 'request_';\n\n // Generate a unique identifier to prevent cancellation for non cancelable requests\n if (options.noCancel) {\n return `${prefix}${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;\n }\n\n // Handle function requestKey\n if (typeof requestKey === 'function') {\n try {\n requestKey = requestKey();\n } catch {\n requestKey = null;\n }\n }\n if (requestKey !== null && requestKey !== undefined) return `${prefix}${String(requestKey)}`;\n\n // Use cleaned URL as key as fallback\n let cleanedUrl = url || '';\n if (cleanedUrl.includes('://')) cleanedUrl = cleanedUrl.split('://')[1];\n if (cleanedUrl.includes('#')) cleanedUrl = cleanedUrl.split('#')[0];\n if (!options.includeQuery && cleanedUrl.includes('?')) cleanedUrl = cleanedUrl.split('?')[0];\n\n const methodPrefix =\n options.includeMethod === false ? '' : `${(options.method || options.type || 'GET').toUpperCase()}_`;\n\n return `${prefix}${methodPrefix}${cleanedUrl}`;\n }\n\n /**\n * Cancels a specific request by its identifier.\n * @param {string} requestId - The unique identifier of the request to cancel\n * @returns {boolean} True if the request was found and cancelled, false otherwise\n */\n cancel(requestId) {\n /** @type {import('./index.d.ts').ActiveRequest|undefined} */\n const requestInfo = this.activeRequests.get(requestId);\n if (!requestInfo) return false;\n\n requestInfo.isCancelled = true; // Mark as cancelled\n\n // Try to abort using AbortController (for fetch)\n if (requestInfo.abortController && !requestInfo.abortController.signal.aborted) {\n try {\n requestInfo.abortController.abort('Request was cancelled');\n } catch (error) {}\n }\n\n // Try to cancel using cancel token/function (for axios and others)\n if (requestInfo.cancelToken) {\n try {\n if (typeof requestInfo.cancelToken === 'function') requestInfo.cancelToken();\n else if (requestInfo.cancelToken.cancel) requestInfo.cancelToken.cancel();\n } catch (error) {}\n }\n\n // Reject the wrapper promise\n this.#_deleteRequest(\n requestId,\n requestInfo.rejectWrapper,\n this.getOptions().verbose ? new Error(`Request ${requestId} was cancelled`) : null\n );\n return true;\n }\n\n /**\n * Link abort signal with HTTP client abort method.\n * Useful for custom HTTP clients that only support the abort method to cancel requests.\n * @param {Function} abortMethod - The abort method to call when the signal is aborted\n * @param {AbortSignal} signal - The signal to listen to\n */\n addAbortListener(abortMethod, signal) {\n if (!abortMethod || !signal) return;\n signal.addEventListener('abort', () => {\n if (typeof abortMethod === 'function') {\n try {\n abortMethod();\n } catch (error) {}\n }\n });\n }\n\n /**\n * Cancels all active requests.\n * @returns {number} The number of requests that were cancelled\n */\n cancelAll() {\n const requestIds = Array.from(this.activeRequests.keys());\n let cancelledCount = 0;\n requestIds.forEach((requestId) => {\n if (this.cancel(requestId)) cancelledCount++;\n });\n return cancelledCount;\n }\n\n /**\n * Resolves the AbortController for a request: explicit option, pending handoff, or new.\n * Clears the pending handoff so concurrent requests do not share it.\n * @param {AbortController|undefined} provided - Optional AbortController from options\n * @returns {AbortController}\n * @private\n */\n #_resolveAbortController(provided) {\n const abortController = provided || this.abortController || new AbortController();\n this.abortController = null;\n return abortController;\n }\n\n /**\n * Picks the best abort callback for a client request object.\n * @param {Object} req - The request object\n * @returns {Function|null}\n * @private\n */\n #_resolveAbortMethod(req) {\n if (!req) return null;\n if (typeof req.abort === 'function') return () => req.abort();\n const ExtAjax =\n typeof globalThis !== 'undefined' && globalThis.Ext && globalThis.Ext.Ajax ? globalThis.Ext.Ajax : null;\n if (req.xhr && ExtAjax && typeof ExtAjax.abort === 'function') {\n return () => ExtAjax.abort(req);\n }\n if (req.xhr && typeof req.xhr.abort === 'function') return () => req.xhr.abort();\n return null;\n }\n\n /**\n * Prepares request options by merging options and removing custom properties\n * @param {import('./index.d.ts').RequestOptions} options - Configuration options\n * @param {AbortSignal} signal - Abort signal to add to request options\n * @returns {Object} Prepared request options\n * @private\n */\n #_prepareRequestOptions(options, signal) {\n const requestOptions = {};\n const customOptions = [\n 'abortController',\n 'cancelToken',\n 'requestKey',\n 'noCancel',\n 'includeQuery',\n 'includeMethod',\n 'verbose',\n ];\n Object.keys(options).forEach((key) => {\n if (customOptions.includes(key)) return;\n requestOptions[key] = options[key];\n });\n requestOptions.signal = signal;\n return requestOptions;\n }\n\n /**\n * Warns when the provided axios instance predates 0.22.0, the first version\n * supporting AbortSignal cancellation. Older instances silently ignore\n * options.signal, so duplicate requests would not be cancelled.\n * @param {object} axiosLib - The axios instance about to be used\n * @private\n */\n #_checkAxiosVersion(axiosLib) {\n const version = typeof axiosLib?.VERSION === 'string' ? axiosLib.VERSION : null;\n if (!version) return;\n const [major, minor] = version.split('.').map(Number);\n if (major === 0 && minor < 22) {\n console.warn(\n `[request-manager] axios >= 0.22.0 is required: axios ${version} ignores the AbortSignal used for automatic cancellation. Please upgrade axios.`\n );\n }\n }\n\n /**\n * Deletes a request from the active requests map and rejects the wrapper promise\n * @param {string} requestId - The unique identifier of the request\n * @param {Function} rejectWrapper - The function to reject the wrapper promise\n * @param {*} error - The error to reject the wrapper promise with; the wrapper is not rejected if null/undefined\n * @private\n */\n #_deleteRequest(requestId, rejectWrapper, error) {\n this.activeRequests.delete(requestId);\n if (error !== null && error !== undefined) {\n rejectWrapper(error);\n }\n }\n\n /**\n * Completes a request by deleting it from the active requests map and resolving the wrapper promise\n * @param {string} requestId - The unique identifier of the request\n * @param {Function} resolveWrapper - The function to resolve the wrapper promise\n * @param {Promise} requestPromise - The request promise\n * @param {boolean} isCancelled - Whether the request was cancelled\n * @private\n */\n #_completeRequest(requestId, resolveWrapper, requestPromise, isCancelled) {\n this.activeRequests.delete(requestId);\n if (!isCancelled) {\n resolveWrapper(requestPromise);\n }\n }\n\n /**\n * Internal method that handles the core request logic.\n * @param {string} requestId - Unique identifier for the request\n * @param {Promise|import('./index.d.ts').RequestFunction|string} requestPromise - The request promise, function, or URL string\n * @param {import('./index.d.ts').BaseRequestOptions} options - Configuration options\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @private\n */\n #_request(requestId, requestPromise, options = {}) {\n const abortController = this.#_resolveAbortController(options.abortController);\n\n // Handle different types of requestPromise inputs\n // Priority: Function (Custom logic) > String (URL) > Promise (axios, fetch, etc.)\n if (typeof requestPromise === 'function') {\n // Function: custom logic for any library (axios, ajax, etc.)\n try {\n requestPromise = requestPromise({\n options: this.#_prepareRequestOptions(options, abortController.signal),\n });\n } catch (error) {\n return Promise.reject(error);\n }\n } else if (typeof requestPromise === 'string') {\n // String (URL): make fetch internally\n try {\n requestPromise = fetch(requestPromise, this.#_prepareRequestOptions(options, abortController.signal));\n } catch (error) {\n return Promise.reject(error);\n }\n }\n\n // Link the request object's abort method (Ext.Ajax, XHR, etc.) to the cancellation signal\n this.addAbortListener(this.#_resolveAbortMethod(requestPromise), abortController.signal);\n\n // Cancel previous request with the same identifier if it exists\n if (!options.noCancel) this.cancel(requestId);\n\n // Create a wrapper promise that will be resolved/rejected based on the request\n let resolveWrapper, rejectWrapper;\n const wrapperPromise = new Promise((resolve, reject) => {\n resolveWrapper = resolve;\n rejectWrapper = reject;\n });\n\n /**\n * @type {import('./index.d.ts').ActiveRequest}\n */\n const requestInfo = {\n promise: requestPromise,\n abortController: abortController,\n cancelToken: options.cancelToken || null,\n resolveWrapper: resolveWrapper,\n rejectWrapper: rejectWrapper,\n isCancelled: false,\n };\n\n this.activeRequests.set(requestId, requestInfo);\n\n // Handle request promise completion\n if (requestPromise && typeof requestPromise.then === 'function') {\n try {\n let req = requestPromise.then((result) => {\n if (this.activeRequests.get(requestId) !== requestInfo) return;\n this.#_completeRequest(requestId, resolveWrapper, result, requestInfo.isCancelled);\n });\n if (req.catch)\n req.catch((error) => {\n onError(this, error);\n });\n } catch (error) {\n onError(this, error);\n }\n function onError(scope, error) {\n // Check if this requestInfo is still the active one, or if it was cancelled\n if (scope.activeRequests.get(requestId) !== requestInfo) return;\n if (requestInfo.isCancelled) {\n // Already cancelled: let cancel() handle cleanup and reject the wrapper promise\n scope.cancel(requestId);\n return;\n }\n // Only delete if this is still the active request\n scope.#_deleteRequest(requestId, rejectWrapper, error);\n }\n } else {\n // Non-promise (Ext.Ajax request object, raw XHR, etc.). Keep tracked until the\n // underlying XHR finishes so a later duplicate can still cancel it.\n const xhr =\n requestPromise &&\n (requestPromise.xhr ||\n (typeof XMLHttpRequest !== 'undefined' && requestPromise instanceof XMLHttpRequest\n ? requestPromise\n : null));\n const finish = () => {\n if (this.activeRequests.get(requestId) !== requestInfo) return;\n this.#_completeRequest(requestId, resolveWrapper, requestPromise, requestInfo.isCancelled);\n };\n if (xhr && typeof xhr.addEventListener === 'function') {\n xhr.addEventListener('loadend', finish);\n } else {\n setTimeout(finish, 0);\n }\n }\n return wrapperPromise;\n }\n}\n\nexport default RequestManager;\n\nexport { RequestManager };\n"],"names":["RequestManager","constructor","options","arguments","length","undefined","_classPrivateMethodInitSpec","_RequestManager_brand","activeRequests","Map","abortController","getOptions","setOptions","getSignal","getAbortController","signal","AbortController","isActive","requestId","has","getActiveCount","size","clear","request","url","requestPromise","_assertClassBrand","_request","call","getRequestId","fetch","axios","axiosInstance","axiosLib","Error","_checkAxiosVersion","_ref","requestOptions","_objectSpread","ajax","ajaxFunction","_ref2","xhr","xhrFunction","_ref3","fetchOptions","XMLHttpRequest","method","toUpperCase","xhrPromise","Promise","resolve","reject","onload","detachAbortListener","status","_xhr$getResponseHeade","response","responseType","getResponseHeader","includes","JSON","parse","_unused","data","statusText","headers","getAllResponseHeaders","message","concat","onerror","ontimeout","open","withCredentials","timeout","Object","keys","forEach","key","setRequestHeader","abortListener","abort","addEventListener","removeEventListener","onabort","send","body","requestKey","prefix","noCancel","Date","now","Math","random","toString","slice","_unused2","String","cleanedUrl","split","includeQuery","methodPrefix","includeMethod","type","cancel","requestInfo","get","isCancelled","aborted","error","cancelToken","_deleteRequest","rejectWrapper","verbose","addAbortListener","abortMethod","cancelAll","requestIds","Array","from","cancelledCount","_resolveAbortController","provided","_resolveAbortMethod","req","ExtAjax","globalThis","Ext","Ajax","_prepareRequestOptions","customOptions","version","VERSION","_version$split$map","map","Number","_version$split$map2","_slicedToArray","major","minor","console","warn","delete","_completeRequest","resolveWrapper","wrapperPromise","promise","set","then","result","catch","onError","scope","finish","setTimeout"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,CAAC;AACjBC,EAAAA,WAAWA,GAAe;AAAA,IAAA,IAAdC,QAAO,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE;AAqaxB;AACJ;AACA;AACA;AACA;AACA;AACA;AANIG,IAAAA,2BAAA,OAAAC,qBAAA,CAAA;AApaI;AACR;AACA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,EAAE8F,aAAa,EAAEH,KAAK,CAAA;AACzD,IAAA;AACJ,EAAA,CAAC,MAAM;AACH;AACA;IACA,IAAMnE,GAAG,GACLjB,cAAc,KACbA,cAAc,CAACiB,GAAG,KACd,OAAOI,cAAc,KAAK,WAAW,IAAIrB,cAAc,YAAYqB,cAAc,GAC5ErB,cAAc,GACd,IAAI,CAAC,CAAC;IACpB,IAAMgI,MAAM,GAAGA,MAAM;MACjB,IAAI,IAAI,CAACjJ,cAAc,CAACkG,GAAG,CAACxF,SAAS,CAAC,KAAKuF,WAAW,EAAE;AACxD/E,MAAAA,iBAAA,CAAAnB,qBAAA,EAAA,IAAI,EAACwI,gBAAgB,CAAC,CAAAnH,IAAA,CAAtB,IAAI,EAAmBV,SAAS,EAAE8H,cAAc,EAAEvH,cAAc,EAAEgF,WAAW,CAACE,WAAW,CAAA;IAC7F,CAAC;IACD,IAAIjE,GAAG,IAAI,OAAOA,GAAG,CAACwC,gBAAgB,KAAK,UAAU,EAAE;AACnDxC,MAAAA,GAAG,CAACwC,gBAAgB,CAAC,SAAS,EAAEuE,MAAM,CAAC;AAC3C,IAAA,CAAC,MAAM;AACHC,MAAAA,UAAU,CAACD,MAAM,EAAE,CAAC,CAAC;AACzB,IAAA;AACJ,EAAA;AACA,EAAA,OAAOR,cAAc;AACzB;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function e(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}function r(t,e){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.add(t)}function n(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function
|
|
1
|
+
function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function e(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}function r(t,e){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.add(t)}function n(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach(function(e){n(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function a(e,r){return function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,s=[],l=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e);else for(;!(l=(n=i.call(r)).done)&&(s.push(n.value),s.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,r)||function(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var s=new WeakSet;
|
|
2
2
|
/**
|
|
3
3
|
* RequestManager - A library for managing and regulating HTTP requests efficiently.
|
|
4
4
|
* @license MIT
|
|
@@ -6,5 +6,5 @@ function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r
|
|
|
6
6
|
* This library allows you to manage HTTP requests from any library (ajax, Ext.Ajax, axios, fetch, etc.)
|
|
7
7
|
* by accepting Promises as parameters. When a request is repeated with the same identifier,
|
|
8
8
|
* the previous request is automatically cancelled and the new one is executed, giving priority to the most recent requests.
|
|
9
|
-
*/class l{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,
|
|
9
|
+
*/class l{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,s),this.activeRequests=new Map,this.options=t,this.abortController=null}getOptions(){return this.options}setOptions(t){this.options=t}getSignal(){return this.getAbortController().signal}getAbortController(){return this.abortController=new AbortController,this.abortController}isActive(t){return this.activeRequests.has(t)}getActiveCount(){return this.activeRequests.size}clear(){this.activeRequests.clear()}request(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e(s,this,v).call(this,this.getRequestId(t,n),r,n)}fetch(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e(s,this,v).call(this,this.getRequestId(t,r),t,r)}axios(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)||("undefined"!=typeof axios?axios:null);if(!n)throw new Error("axios was not found: pass an axios instance as the third argument of requestManager.axios() or make sure axios is available globally");return e(s,this,f).call(this,n),e(s,this,v).call(this,this.getRequestId(t,r),e=>{var r=e.options;return n(i({url:t},r))},r)}ajax(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("function"!=typeof t)throw new Error("ajaxFunction parameter must be a function");return e(s,this,v).call(this,this.getRequestId(r,n),e=>{var n=e.options;return t(i({url:r},n))},n)}xhr(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e(s,this,v).call(this,this.getRequestId(t,r),e=>{var n=e.options,o=new XMLHttpRequest,i=(r.method||"GET").toUpperCase();return new Promise((e,a)=>{o.onload=function(){if(l(),o.status>=200&&o.status<300){var t,n=o.response;if("json"===r.responseType||(!r.responseType||"text"===r.responseType)&&null!==(t=o.getResponseHeader("Content-Type"))&&void 0!==t&&t.includes("application/json")&&"string"==typeof n)try{n=JSON.parse(n)}catch(t){}e({data:n,status:o.status,statusText:o.statusText,headers:o.getAllResponseHeaders(),xhr:o})}else a({message:"Request failed with status ".concat(o.status),status:o.status,statusText:o.statusText,xhr:o})},o.onerror=function(){l(),a({message:"Network error",xhr:o})},o.ontimeout=function(){l(),a({message:"Request timeout",xhr:o})},o.open(i,t,!0),r.responseType&&(o.responseType=r.responseType),void 0!==r.withCredentials&&(o.withCredentials=r.withCredentials),void 0!==r.timeout&&(o.timeout=r.timeout),r.headers&&Object.keys(r.headers).forEach(t=>{o.setRequestHeader(t,r.headers[t])});var s=()=>o.abort();n.signal&&n.signal.addEventListener("abort",s);var l=()=>{n.signal&&n.signal.removeEventListener("abort",s)};o.onabort=function(){a({message:"Request was cancelled",xhr:o})},o.send(r.body||null)})},r)}getRequestId(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.requestKey,n="request_";if(e.noCancel)return"".concat(n).concat(Date.now(),"_").concat(Math.random().toString(36).slice(2,11));if("function"==typeof r)try{r=r()}catch(t){r=null}if(null!=r)return"".concat(n).concat(String(r));var o=t||"";o.includes("://")&&(o=o.split("://")[1]),o.includes("#")&&(o=o.split("#")[0]),!e.includeQuery&&o.includes("?")&&(o=o.split("?")[0]);var i=!1===e.includeMethod?"":"".concat((e.method||e.type||"GET").toUpperCase(),"_");return"".concat(n).concat(i).concat(o)}cancel(t){var r=this.activeRequests.get(t);if(!r)return!1;if(r.isCancelled=!0,r.abortController&&!r.abortController.signal.aborted)try{r.abortController.abort("Request was cancelled")}catch(t){}if(r.cancelToken)try{"function"==typeof r.cancelToken?r.cancelToken():r.cancelToken.cancel&&r.cancelToken.cancel()}catch(t){}return e(s,this,p).call(this,t,r.rejectWrapper,this.getOptions().verbose?new Error("Request ".concat(t," was cancelled")):null),!0}addAbortListener(t,e){t&&e&&e.addEventListener("abort",()=>{if("function"==typeof t)try{t()}catch(t){}})}cancelAll(){var t=Array.from(this.activeRequests.keys()),e=0;return t.forEach(t=>{this.cancel(t)&&e++}),e}}function c(t){var e=t||this.abortController||new AbortController;return this.abortController=null,e}function u(t){if(!t)return null;if("function"==typeof t.abort)return()=>t.abort();var e="undefined"!=typeof globalThis&&globalThis.Ext&&globalThis.Ext.Ajax?globalThis.Ext.Ajax:null;return t.xhr&&e&&"function"==typeof e.abort?()=>e.abort(t):t.xhr&&"function"==typeof t.xhr.abort?()=>t.xhr.abort():null}function h(t,e){var r={},n=["abortController","cancelToken","requestKey","noCancel","includeQuery","includeMethod","verbose"];return Object.keys(t).forEach(e=>{n.includes(e)||(r[e]=t[e])}),r.signal=e,r}function f(t){var e="string"==typeof(null==t?void 0:t.VERSION)?t.VERSION:null;if(e){var r=a(e.split(".").map(Number),2),n=r[0],o=r[1];0===n&&o<22&&console.warn("[request-manager] axios >= 0.22.0 is required: axios ".concat(e," ignores the AbortSignal used for automatic cancellation. Please upgrade axios."))}}function p(t,e,r){this.activeRequests.delete(t),null!=r&&e(r)}function d(t,e,r,n){this.activeRequests.delete(t),n||e(r)}function v(t,r){var n,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=e(s,this,c).call(this,i.abortController);if("function"==typeof r)try{r=r({options:e(s,this,h).call(this,i,a.signal)})}catch(g){return Promise.reject(g)}else if("string"==typeof r)try{r=fetch(r,e(s,this,h).call(this,i,a.signal))}catch(m){return Promise.reject(m)}this.addAbortListener(e(s,this,u).call(this,r),a.signal),i.noCancel||this.cancel(t);var l=new Promise((t,e)=>{n=t,o=e}),f={promise:r,abortController:a,cancelToken:i.cancelToken||null,resolveWrapper:n,rejectWrapper:o,isCancelled:!1};if(this.activeRequests.set(t,f),r&&"function"==typeof r.then){try{var v=r.then(r=>{this.activeRequests.get(t)===f&&e(s,this,d).call(this,t,n,r,f.isCancelled)});v.catch&&v.catch(t=>{w(this,t)})}catch(x){w(this,x)}function w(r,n){r.activeRequests.get(t)===f&&(f.isCancelled?r.cancel(t):e(s,r,p).call(r,t,o,n))}}else{var y=r&&(r.xhr||("undefined"!=typeof XMLHttpRequest&&r instanceof XMLHttpRequest?r:null)),b=()=>{this.activeRequests.get(t)===f&&e(s,this,d).call(this,t,n,r,f.isCancelled)};y&&"function"==typeof y.addEventListener?y.addEventListener("loadend",b):setTimeout(b,0)}return l}export{l as RequestManager,l as default};
|
|
10
10
|
//# sourceMappingURL=request-manager.esm.min.js.map
|