@enegalan/request-manager 1.0.1 → 1.0.3
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 +8 -17
- package/dist/request-manager.cjs.js +24 -14
- package/dist/request-manager.cjs.js.map +1 -1
- package/dist/request-manager.cjs.min.js +1 -5
- package/dist/request-manager.cjs.min.js.map +1 -1
- package/dist/request-manager.esm.js +24 -14
- package/dist/request-manager.esm.js.map +1 -1
- package/dist/request-manager.esm.min.js +1 -5
- package/dist/request-manager.esm.min.js.map +1 -1
- package/dist/request-manager.js +24 -14
- package/dist/request-manager.js.map +1 -1
- package/dist/request-manager.min.js +1 -5
- package/dist/request-manager.min.js.map +1 -1
- package/dist/request-manager.umd.js +24 -14
- package/dist/request-manager.umd.js.map +1 -1
- package/dist/request-manager.umd.min.js +1 -5
- package/dist/request-manager.umd.min.js.map +1 -1
- package/index.d.ts +4 -4
- package/main.js +24 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ RequestManager is a JavaScript library designed to manage and regulate HTTP requ
|
|
|
8
8
|
## Key Features
|
|
9
9
|
|
|
10
10
|
- **Universal Compatibility**: Works with any HTTP library that returns a Promise (fetch, axios, Ext.Ajax, etc.)
|
|
11
|
-
- **Automatic Cancellation**: When a request is repeated with the same
|
|
11
|
+
- **Automatic Cancellation**: When a request is repeated with the same `requestKey`, the previous request is automatically cancelled. This identifier is generated with `url` parameter or can be manually specified in `options`.
|
|
12
12
|
- **Prioritizes Recent Requests**: The library ensures that only the most recent request is processed, cancelling older ones
|
|
13
13
|
- **Simple API**: Easy to use and integrate into existing projects
|
|
14
14
|
- **Adapt to your requirements**: The library supports `options` for custom request management
|
|
@@ -55,7 +55,6 @@ import RequestManager, { RequestOptions, XhrResponse } from '@enegalan/request-m
|
|
|
55
55
|
|
|
56
56
|
const requestManager = new RequestManager({ verbose: true });
|
|
57
57
|
|
|
58
|
-
// Types are automatically inferred
|
|
59
58
|
const response: Response = await requestManager.fetch('/api/users');
|
|
60
59
|
const xhrResult: XhrResponse<{ name: string }> = await requestManager.xhr('/api/user/1');
|
|
61
60
|
```
|
|
@@ -69,7 +68,6 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
69
68
|
|
|
70
69
|
const requestManager = new RequestManager();
|
|
71
70
|
|
|
72
|
-
// Simple GET request - automatically uses cleaned URL as requestKey
|
|
73
71
|
requestManager.fetch('/api/users')
|
|
74
72
|
.then(response => response.json())
|
|
75
73
|
.then(data => console.log(data))
|
|
@@ -89,7 +87,6 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
89
87
|
|
|
90
88
|
const requestManager = new RequestManager();
|
|
91
89
|
|
|
92
|
-
// POST request with options
|
|
93
90
|
requestManager.fetch('/api/users', {
|
|
94
91
|
method: 'POST',
|
|
95
92
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -106,8 +103,6 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
106
103
|
|
|
107
104
|
const requestManager = new RequestManager();
|
|
108
105
|
|
|
109
|
-
// Using request() with a Promise
|
|
110
|
-
// The URL is used to generate the request ID (cleaned URL)
|
|
111
106
|
requestManager.request('/api/users', fetch('/api/users'))
|
|
112
107
|
.then(response => response.json())
|
|
113
108
|
.then(data => console.log(data));
|
|
@@ -120,8 +115,7 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
120
115
|
|
|
121
116
|
const requestManager = new RequestManager();
|
|
122
117
|
|
|
123
|
-
//
|
|
124
|
-
// The function receives { options } where options contains the signal
|
|
118
|
+
// Custom logic
|
|
125
119
|
requestManager.request('/api/users', ({ options }) => {
|
|
126
120
|
return fetch('/api/users', options);
|
|
127
121
|
})
|
|
@@ -229,8 +223,6 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
229
223
|
|
|
230
224
|
const requestManager = new RequestManager();
|
|
231
225
|
|
|
232
|
-
// Using axios with request() method
|
|
233
|
-
// The URL is used to generate the request ID
|
|
234
226
|
const CancelToken = axios.CancelToken;
|
|
235
227
|
const source = CancelToken.source();
|
|
236
228
|
|
|
@@ -257,7 +249,6 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
257
249
|
|
|
258
250
|
const requestManager = new RequestManager();
|
|
259
251
|
|
|
260
|
-
// Using axios with Function - The function receives { options } where options contains the signal
|
|
261
252
|
requestManager.request('/api/users', ({ options }) => {
|
|
262
253
|
const CancelToken = axios.CancelToken;
|
|
263
254
|
const source = CancelToken.source();
|
|
@@ -280,8 +271,6 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
280
271
|
|
|
281
272
|
const requestManager = new RequestManager();
|
|
282
273
|
|
|
283
|
-
// Example with a custom HTTP library using Function
|
|
284
|
-
// The function receives { options } where options contains the signal
|
|
285
274
|
requestManager.request('/api/data', ({ options }) => {
|
|
286
275
|
return new Promise((resolve, reject) => {
|
|
287
276
|
const xhr = new XMLHttpRequest();
|
|
@@ -308,7 +297,6 @@ import RequestManager from '@enegalan/request-manager';
|
|
|
308
297
|
|
|
309
298
|
const requestManager = new RequestManager();
|
|
310
299
|
|
|
311
|
-
// If you already have a Promise, you can pass it directly
|
|
312
300
|
const existingPromise = fetch('/api/data');
|
|
313
301
|
|
|
314
302
|
requestManager.request('/api/data', existingPromise, {
|
|
@@ -343,13 +331,16 @@ Executes an HTTP request, cancelling any previous request with the same identifi
|
|
|
343
331
|
|
|
344
332
|
**Parameters:**
|
|
345
333
|
- `url` (string): The URL of the request (used to generate request ID from cleaned URL)
|
|
346
|
-
- `requestPromise` (Promise|Function|string): The Promise returned by any HTTP library (fetch, axios, etc.), a Function that
|
|
334
|
+
- `requestPromise` (Promise|Function|string): The Promise returned by any HTTP library (fetch, axios, etc.), a Function that can receive `{ options }` and returns a Promise, or a URL string (which will be used with fetch internally)
|
|
347
335
|
- `options` (Object, optional): Configuration options
|
|
348
336
|
- `abortController` (AbortController): AbortController instance (created automatically if not provided)
|
|
349
337
|
- `cancelToken` (Function|Object): Cancel token or cancel function for other libraries
|
|
350
338
|
- `requestKey` (string|number|Function, optional): Key to identify duplicate requests. If provided, requests with the same key will share the same ID and cancel previous ones. If not provided, the cleaned URL is used as the key. Can be a string, number, or function that returns a key.
|
|
351
339
|
- `noCancel` (boolean): If true, this request will not cancel previous requests with the same ID, allowing concurrent requests. Useful for lazy loading scenarios where multiple requests should execute in parallel.
|
|
352
340
|
|
|
341
|
+
> [!TIP]
|
|
342
|
+
> When `requestPromise` is a Function, you can pass custom properties in `options`. These will be accessible inside the callback via the `{ options }` parameter.
|
|
343
|
+
|
|
353
344
|
**Returns:** Promise that resolves/rejects based on the most recent request
|
|
354
345
|
|
|
355
346
|
**Note:** The request ID is automatically generated from the cleaned URL (protocol and query params removed) unless `requestKey` is specified. When `noCancel` is true, a unique ID is generated for each request to prevent cancellation. When `requestPromise` is a Function, it receives `{ options }` where `options` contains the `signal` (AbortSignal) and any other fetch options.
|
|
@@ -417,12 +408,12 @@ requestManager.axios('/api/users', {
|
|
|
417
408
|
.then(response => console.log(response.data));
|
|
418
409
|
```
|
|
419
410
|
|
|
420
|
-
### `ajax(
|
|
411
|
+
### `ajax(ajaxFunction, url, options)`
|
|
421
412
|
|
|
422
413
|
Executes an HTTP request using a custom ajax method function, cancelling any previous request with the same identifier.
|
|
423
414
|
|
|
424
415
|
**Parameters:**
|
|
425
|
-
- `
|
|
416
|
+
- `ajaxFunction` (Function): A function that receives `{ url, ...options }` and returns a Promise. The function should accept an object with `url` and other options including the `signal` (AbortSignal).
|
|
426
417
|
- `url` (string): The URL to request
|
|
427
418
|
- `options` (Object, optional): Configuration options
|
|
428
419
|
- `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.
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RequestManager - A library for managing and regulating HTTP requests efficiently.
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
1
|
'use strict';
|
|
6
2
|
|
|
7
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -416,7 +412,7 @@ class RequestManager {
|
|
|
416
412
|
/**
|
|
417
413
|
* Executes an HTTP request using jQuery.ajax, cancelling any previous request with the same identifier.
|
|
418
414
|
*
|
|
419
|
-
* @param {Function}
|
|
415
|
+
* @param {Function} ajaxFunction - A function that receives { url, ...options } and returns a Promise
|
|
420
416
|
* @param {string} url - The URL to request
|
|
421
417
|
* @param {Object} options - Optional configuration
|
|
422
418
|
* @param {string|number|Function} options.requestKey - Key to identify duplicate requests.
|
|
@@ -428,11 +424,11 @@ class RequestManager {
|
|
|
428
424
|
*
|
|
429
425
|
* @example
|
|
430
426
|
* // Simple GET request
|
|
431
|
-
* requestManager.ajax(
|
|
427
|
+
* requestManager.ajax(ajaxFunction, '/api/users');
|
|
432
428
|
*
|
|
433
429
|
* @example
|
|
434
430
|
* // POST request with options
|
|
435
|
-
* requestManager.ajax(
|
|
431
|
+
* requestManager.ajax(ajaxFunction, '/api/users', {
|
|
436
432
|
* method: 'POST',
|
|
437
433
|
* headers: { 'Content-Type': 'application/json' },
|
|
438
434
|
* body: JSON.stringify({ name: 'John' })
|
|
@@ -440,18 +436,32 @@ class RequestManager {
|
|
|
440
436
|
*
|
|
441
437
|
* @example
|
|
442
438
|
* // Request with requestKey for custom cancellation grouping with requestKey
|
|
443
|
-
* requestManager.ajax(
|
|
439
|
+
* requestManager.ajax(ajaxFunction, '/api/users', {
|
|
444
440
|
* requestKey: 'get-users'
|
|
445
441
|
* });
|
|
446
442
|
*/
|
|
447
|
-
ajax(
|
|
448
|
-
if (typeof
|
|
443
|
+
ajax(ajaxFunction, url, options = {}) {
|
|
444
|
+
if (typeof ajaxFunction !== 'function') throw new Error('ajaxFunction parameter must be a function');
|
|
449
445
|
const requestOptions = options || {};
|
|
450
446
|
const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);
|
|
451
447
|
try {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
448
|
+
// AbortController is needed at this point, so we clear here any existing one.
|
|
449
|
+
// This is the same behavior as in the request method.
|
|
450
|
+
this.#_clearAbortController();
|
|
451
|
+
const abortController = options.abortController || this.getAbortController();
|
|
452
|
+
const req = ajaxFunction({ url, ...requestOptions });
|
|
453
|
+
// Determine abort method
|
|
454
|
+
let abortMethod = null;
|
|
455
|
+
if (req) {
|
|
456
|
+
if (typeof req.abort === 'function') {
|
|
457
|
+
abortMethod = req.abort.bind(req);
|
|
458
|
+
} else if (req.xhr && typeof req.xhr.abort === 'function') {
|
|
459
|
+
abortMethod = req.xhr.abort.bind(req.xhr);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (abortMethod) this.addAbortListener(abortMethod, abortController.signal);
|
|
463
|
+
// Pass the AbortController to avoid creating another one for this request
|
|
464
|
+
return this.#_request(requestId, req, { ...requestOptions, abortController: abortController });
|
|
455
465
|
} catch (error) {
|
|
456
466
|
return Promise.reject(error);
|
|
457
467
|
}
|
|
@@ -600,7 +610,7 @@ class RequestManager {
|
|
|
600
610
|
|
|
601
611
|
// Reject the wrapper promise
|
|
602
612
|
if (requestInfo.rejectWrapper && this.verbose) {
|
|
603
|
-
requestInfo.rejectWrapper(new Error(
|
|
613
|
+
requestInfo.rejectWrapper(new Error(`Request ${requestId} was cancelled`));
|
|
604
614
|
}
|
|
605
615
|
this.activeRequests.delete(requestId); // Remove from active requests
|
|
606
616
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-manager.cjs.js","sources":["../main.js"],"sourcesContent":["/**\n * RequestManager - A library for managing and regulating HTTP requests efficiently.\n * @license MIT\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\n * @param {Object} managerOptions - The options for the manager\n * @param {boolean} managerOptions.verbose - If true, cancellation errors will include messages\n * @returns {RequestManager} A new RequestManager instance\n*/\nclass RequestManager {\n constructor(managerOptions = {}) {\n /**\n * Map to store active requests by their unique identifier.\n * Each entry contains:\n * - promise: The original promise\n * - abortController: AbortController instance (if available)\n * - cancelToken: Cancel token (for axios compatibility)\n * - wrapperPromise: The promise that wraps the request\n * - resolveWrapper: The function to resolve the wrapper promise\n * - rejectWrapper: The function to reject the wrapper promise\n * - isCancelled: Whether the request has been cancelled\n * - verbose: Whether to include verbose messages in the cancellation error\n */\n this.activeRequests = new Map();\n /**\n * Verbose mode: if true, cancellation errors will include messages\n * @type {boolean}\n */\n this.verbose = managerOptions.verbose || false;\n /**\n * Manager options: the options that were passed to the constructor\n * @type {Object}\n */\n this.managerOptions = managerOptions;\n /**\n * Options for the current request: will be flushed after the request is completed\n * @type {Object}\n */\n this.options = {};\n /**\n * AbortController instance for the current request: will be flushed after the request is completed\n * @type {AbortController}\n */\n this.abortController = null;\n }\n\n /**\n * Flushes the options for the current request\n * @private\n */\n #_flushRequestOptions() {\n this.options = {};\n }\n\n /**\n * Gets the manager options\n * @returns {Object} Manager options\n */\n getOptions() {\n return this.managerOptions;\n }\n\n /**\n * Sets the manager options\n * @param {Object} options - The options to set\n */\n setOptions(options) {\n this.managerOptions = options;\n if (options.verbose !== undefined) {\n this.verbose = options.verbose;\n }\n }\n\n /**\n * Sets the options for the current request\n * @param {Object} options - The options to set\n * @private\n */\n #_setRequestOptions(options) {\n this.options = options;\n }\n\n /**\n * Creates an AbortController and returns its signal.\n * The AbortController is stored internally and will be used by the next request() call.\n * This allows users to get the signal before creating the request.\n * \n * @returns {AbortSignal} The signal from a new AbortController\n * \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 * Gets the current AbortController instance\n * Creates a new AbortController if none exists or if the current one is aborted\n * @returns {AbortController} The current AbortController instance\n */\n getAbortController() {\n // Create a new AbortController if none exists or if the current one is aborted\n if (!this.abortController || this.abortController.signal.aborted) {\n this.abortController = new AbortController();\n }\n return this.abortController;\n }\n\n /**\n * Clears the current AbortController\n * @private\n */\n #_clearAbortController() {\n this.abortController = null;\n }\n\n /**\n * Generates a request identifier based on the requestKey or URL\n * @param {string} url - The URL of the request\n * @param {string|number|Function} requestKey - Optional key to generate a deterministic ID.\n * If provided, requests with the same key will share the same ID.\n * If null or undefined, the cleaned URL will be used as the key.\n * @param {boolean} noCancel - If true, generates a unique ID to prevent cancellation\n * @returns {string} A unique request identifier\n * @private\n */\n #_generateRequestId(url, requestKey = null, noCancel = false) {\n if (noCancel) { // Generate a unique ID to prevent cancellation\n return `request_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;\n }\n if (requestKey !== null && requestKey !== undefined) {\n if (typeof requestKey === 'function') {\n try {\n requestKey = requestKey();\n } catch (error) {\n requestKey = null;\n }\n }\n if (requestKey !== null && requestKey !== undefined) return `request_${String(requestKey)}`;\n }\n // Use cleaned URL as key when requestKey is null/undefined\n let cleanedUrl = url || '';\n let hasProtocol = cleanedUrl.includes('://');\n if (hasProtocol) cleanedUrl = cleanedUrl.split('://')[1];\n let hasParams = cleanedUrl.includes('?');\n if (hasParams) cleanedUrl = cleanedUrl.split('?')[0];\n let hasHash = cleanedUrl.includes('#');\n if (hasHash) cleanedUrl = cleanedUrl.split('#')[0];\n return `request_${cleanedUrl}`;\n }\n\n /**\n * Prepares fetch options by merging options and removing custom properties\n * @param {Object} options - Configuration options\n * @param {AbortSignal} signal - Abort signal to add to fetch options\n * @param {Object} additionalOptions - Additional options to merge\n * @returns {Object} Prepared fetch options\n * @private\n */\n #_prepareFetchOptions(options, signal, additionalOptions = {}) {\n const fetchOptions = Object.assign({}, additionalOptions);\n const customOptions = ['abortController', 'cancelToken', 'requestKey', 'noCancel'];\n Object.keys(options).forEach(key => {\n if (customOptions.includes(key)) return;\n fetchOptions[key] = options[key];\n });\n fetchOptions.signal = signal;\n return fetchOptions;\n }\n\n /**\n * Internal method that handles the core request logic.\n * \n * @param {string} requestId - Unique identifier for the request\n * @param {Promise|Function|string} requestPromise - The request promise, function, or URL string\n * @param {Object} options - Configuration options\n * @param {AbortController} options.abortController - AbortController instance\n * @param {Function} options.cancelToken - Cancel token or cancel function\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @private\n */\n #_request(requestId, requestPromise, options = {}) {\n this.#_setRequestOptions(options);\n if (!options.abortController) this.#_clearAbortController(); // Clear any existing abortController to ensure each request gets a fresh one\n this.#_flushRequestOptions();\n const abortController = options.abortController || this.getAbortController();\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 const fetchOptions = this.#_prepareFetchOptions(options, abortController.signal);\n requestPromise = requestPromise({ options: fetchOptions });\n } else if (typeof requestPromise === 'string') {\n // String (URL): make fetch internally\n const fetchOptions = this.#_prepareFetchOptions(options, abortController.signal);\n requestPromise = fetch(requestPromise, fetchOptions);\n }\n\n // Cancel previous request with the same ID 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 // Store the request information\n const requestInfo = {\n promise: requestPromise,\n abortController: abortController,\n cancelToken: options.cancelToken || null,\n wrapperPromise: wrapperPromise,\n resolveWrapper: resolveWrapper,\n rejectWrapper: rejectWrapper,\n isCancelled: false,\n verbose: this.verbose\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 && !requestInfo.isCancelled) {\n this.activeRequests.delete(requestId);\n resolveWrapper(result);\n }\n });\n if (req.catch) 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 const currentRequestInfo = scope.activeRequests.get(requestId);\n if (currentRequestInfo !== requestInfo) return;\n // Only delete if this is still the active request\n scope.activeRequests.delete(requestId);\n if (!requestInfo.isCancelled) rejectWrapper(error);\n else if (requestInfo.isCancelled && requestInfo.verbose) rejectWrapper(new Error('Request was cancelled'));\n }\n } else {\n // If requestPromise is not a promise, we can't track its completion automatically\n // This can happen with libraries like ExtJS that return request objects instead of promises\n // In this case, the user should handle the request object themselves\n // We'll resolve the wrapper promise immediately to prevent it from hanging\n // The user can still use the request object returned by the library\n setTimeout(() => {\n if (this.activeRequests.get(requestId) === requestInfo && !requestInfo.isCancelled) {\n this.activeRequests.delete(requestId);\n resolveWrapper(requestPromise); // Resolve with the request object so the user can use it\n }\n }, 0);\n }\n return wrapperPromise;\n }\n\n /**\n * Executes an HTTP request, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to request\n * @param {Promise|Function} requestPromise - The request promise or function that returns a promise\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {AbortController} options.abortController - AbortController instance (created automatically if not provided)\n * @param {Function} options.cancelToken - Cancel token or cancel function for other libraries\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed as fetch options (method, headers, body, etc.)\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Request with Promise\n * requestManager.request('/api/users', axios.get('/api/users', { cancelToken: axios.CancelToken.source().token }));\n * \n * @example\n * // Request with Function\n * requestManager.request('/api/users', ({ options }) => fetch('/api/users', { signal: options.signal, ...options }));\n * \n * @example\n * // Request with Promise and custom cancellation grouping with requestKey\n * const options = {\n * requestKey: 'get-users',\n * cancelToken: axios.CancelToken.source().cancel\n * }\n * requestManager.request('/api/users', axios.get('/api/users', options), options);\n * \n * @example\n * // Request with noCancel to allow concurrent requests (e.g., lazy loading)\n * requestManager.request('/api/lazy?load=1', fetch('/api/lazy?load=1'), { noCancel: true });\n * requestManager.request('/api/lazy?load=2', fetch('/api/lazy?load=2'), { noCancel: true });\n * // Both requests will execute concurrently without canceling each other\n */\n request(url, requestPromise, options = {}) {\n const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n return this.#_request(requestId, requestPromise, requestOptions);\n }\n\n /**\n * Executes an HTTP request using fetch, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to fetch\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {AbortController} options.abortController - AbortController instance (created automatically if not provided)\n * @param {Function} options.cancelToken - Cancel token or cancel function for other libraries\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed as fetch options (method, headers, body, etc.)\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Simple GET request\n * requestManager.fetch('/api/users');\n * \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 * \n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.fetch('/api/users', {\n * requestKey: 'get-users'\n * });\n * \n * @example\n * // Request with noCancel to allow concurrent requests (e.g., lazy loading)\n * requestManager.fetch('/api/lazy?load=1', { noCancel: true });\n * requestManager.fetch('/api/lazy?load=2', { noCancel: true });\n * // Both requests will execute concurrently without canceling each other\n */\n fetch(url, options = {}) {\n const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n return this.#_request(requestId, url, requestOptions);\n }\n\n /**\n * Executes an HTTP request using axios, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to request\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed as axios options (method, headers, params, data, etc.)\n * @param {Object} 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 * \n * @example\n * // Simple GET request (uses global axios)\n * requestManager.axios('/api/users');\n * \n * @example\n * // With custom axios instance\n * const myAxios = axios.create({ baseURL: 'https://api.example.com' });\n * requestManager.axios('/users', {}, myAxios);\n * \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 * \n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.axios('/api/users', {\n * requestKey: 'get-users'\n * });\n * \n * @example\n * // Request with noCancel to allow concurrent requests\n * requestManager.axios('/api/lazy?load=1', { noCancel: true });\n * requestManager.axios('/api/lazy?load=2', { noCancel: true });\n */\n axios(url, options = {}, axiosInstance = null) {\n const requestOptions = options || {};\n const axiosLib = axiosInstance || axios;\n const cancelToken = axiosLib.CancelToken.source();\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n return this.#_request(requestId, axiosLib.get(url, { cancelToken: cancelToken.token, ...requestOptions }), {\n cancelToken: cancelToken,\n ...requestOptions\n });\n }\n\n /**\n * Executes an HTTP request using jQuery.ajax, cancelling any previous request with the same identifier.\n * \n * @param {Function} ajaxMethod - A function that receives { url, ...options } and returns a Promise\n * @param {string} url - The URL to request\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed to the ajax method function\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Simple GET request\n * requestManager.ajax(ajaxMethod, '/api/users');\n * \n * @example\n * // POST request with options\n * requestManager.ajax(ajaxMethod, '/api/users', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ name: 'John' })\n * });\n * \n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.ajax(ajaxMethod, '/api/users', {\n * requestKey: 'get-users'\n * });\n */\n ajax(ajaxMethod, url, options = {}) {\n if (typeof ajaxMethod !== 'function') throw new Error('ajaxMethod must be a function');\n const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n try {\n const req = ajaxMethod({ url, ...requestOptions });\n this.addAbortListener(req.abort, this.getSignal());\n return this.#_request(requestId, req, requestOptions);\n } catch (error) {\n return Promise.reject(error);\n }\n }\n\n /**\n * Executes an HTTP request using XMLHttpRequest, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to request\n * @param {Object} options - Optional configuration\n * @param {string} options.method - HTTP method (GET, POST, PUT, DELETE, etc.). Defaults to 'GET'.\n * @param {Object} options.headers - Headers object to set on the request\n * @param {string|FormData|Blob|ArrayBuffer} options.body - Request body\n * @param {string} options.responseType - Response type ('text', 'json', 'blob', 'arraybuffer', 'document'). Defaults to 'text'.\n * @param {boolean} options.withCredentials - Whether to send credentials with the request\n * @param {number} options.timeout - Request timeout in milliseconds\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Simple GET request\n * requestManager.xhr('/api/users');\n * \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 * \n * @example\n * // Request with requestKey for custom cancellation grouping\n * requestManager.xhr('/api/users', {\n * requestKey: 'get-users'\n * });\n * \n * @example\n * // Request with noCancel to allow concurrent requests\n * requestManager.xhr('/api/lazy?load=1', { noCancel: true });\n * requestManager.xhr('/api/lazy?load=2', { noCancel: true });\n */\n xhr(url, options = {}) {\n const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n const xhrFunction = ({ options: fetchOptions }) => {\n // Create XMLHttpRequest\n const xhr = new XMLHttpRequest();\n const method = (requestOptions.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 (requestOptions.responseType === 'json' ||\n (xhr.getResponseHeader('Content-Type') && xhr.getResponseHeader('Content-Type').includes('application/json'))) {\n try {\n response = JSON.parse(xhr.responseText);\n } catch (e) {\n response = xhr.responseText;\n }\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 (requestOptions.responseType) xhr.responseType = requestOptions.responseType;\n // Set withCredentials\n if (requestOptions.withCredentials !== undefined) xhr.withCredentials = requestOptions.withCredentials;\n // Set timeout\n if (requestOptions.timeout !== undefined) xhr.timeout = requestOptions.timeout;\n // Set headers\n if (requestOptions.headers) Object.keys(requestOptions.headers).forEach(key => {\n xhr.setRequestHeader(key, requestOptions.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(requestOptions.body || null);\n });\n return xhrPromise;\n };\n return this.#_request(requestId, xhrFunction, requestOptions);\n }\n\n /**\n * Cancels a specific request by its identifier.\n * \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 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 if (requestInfo.rejectWrapper && this.verbose) {\n requestInfo.rejectWrapper(new Error('Request was cancelled'));\n }\n this.activeRequests.delete(requestId); // Remove from active requests\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 (!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 * \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 * Checks if a request with the given identifier is currently active.\n * \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 * \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\nexport default RequestManager;\n\nexport { RequestManager };\n"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM,cAAc,CAAC;AACrB,IAAI,WAAW,CAAC,cAAc,GAAG,EAAE,EAAE;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE;AACvC;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,IAAI,KAAK;AACtD;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc;AAC5C;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE;AACzB;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI;AACnC,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE;AACzB,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,UAAU,GAAG;AACjB,QAAQ,OAAO,IAAI,CAAC,cAAc;AAClC,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,UAAU,CAAC,OAAO,EAAE;AACxB,QAAQ,IAAI,CAAC,cAAc,GAAG,OAAO;AACrC,QAAQ,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;AAC3C,YAAY,IAAI,CAAC,OAAO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AC,SAAS,CAAC,EAAE,cAAc,EAAE;AACxD,QAAQ,CAAC,CAAC;AACV,QAAQ,OAAO,cAAc;AAC7B,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,SAAS,EAAE;AACxB,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;AACjD,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI;AACvC,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,KAAK,GAAG;AACZ,QAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE;AACnC,IAAI;AACJ;;;;;"}
|
|
1
|
+
{"version":3,"file":"request-manager.cjs.js","sources":["../main.js"],"sourcesContent":["/**\n * RequestManager - A library for managing and regulating HTTP requests efficiently.\n * @license MIT\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\n * @param {Object} managerOptions - The options for the manager\n * @param {boolean} managerOptions.verbose - If true, cancellation errors will include messages\n * @returns {RequestManager} A new RequestManager instance\n*/\nclass RequestManager {\n constructor(managerOptions = {}) {\n /**\n * Map to store active requests by their unique identifier.\n * Each entry contains:\n * - promise: The original promise\n * - abortController: AbortController instance (if available)\n * - cancelToken: Cancel token (for axios compatibility)\n * - wrapperPromise: The promise that wraps the request\n * - resolveWrapper: The function to resolve the wrapper promise\n * - rejectWrapper: The function to reject the wrapper promise\n * - isCancelled: Whether the request has been cancelled\n * - verbose: Whether to include verbose messages in the cancellation error\n */\n this.activeRequests = new Map();\n /**\n * Verbose mode: if true, cancellation errors will include messages\n * @type {boolean}\n */\n this.verbose = managerOptions.verbose || false;\n /**\n * Manager options: the options that were passed to the constructor\n * @type {Object}\n */\n this.managerOptions = managerOptions;\n /**\n * Options for the current request: will be flushed after the request is completed\n * @type {Object}\n */\n this.options = {};\n /**\n * AbortController instance for the current request: will be flushed after the request is completed\n * @type {AbortController}\n */\n this.abortController = null;\n }\n\n /**\n * Flushes the options for the current request\n * @private\n */\n #_flushRequestOptions() {\n this.options = {};\n }\n\n /**\n * Gets the manager options\n * @returns {Object} Manager options\n */\n getOptions() {\n return this.managerOptions;\n }\n\n /**\n * Sets the manager options\n * @param {Object} options - The options to set\n */\n setOptions(options) {\n this.managerOptions = options;\n if (options.verbose !== undefined) {\n this.verbose = options.verbose;\n }\n }\n\n /**\n * Sets the options for the current request\n * @param {Object} options - The options to set\n * @private\n */\n #_setRequestOptions(options) {\n this.options = options;\n }\n\n /**\n * Creates an AbortController and returns its signal.\n * The AbortController is stored internally and will be used by the next request() call.\n * This allows users to get the signal before creating the request.\n * \n * @returns {AbortSignal} The signal from a new AbortController\n * \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 * Gets the current AbortController instance\n * Creates a new AbortController if none exists or if the current one is aborted\n * @returns {AbortController} The current AbortController instance\n */\n getAbortController() {\n // Create a new AbortController if none exists or if the current one is aborted\n if (!this.abortController || this.abortController.signal.aborted) {\n this.abortController = new AbortController();\n }\n return this.abortController;\n }\n\n /**\n * Clears the current AbortController\n * @private\n */\n #_clearAbortController() {\n this.abortController = null;\n }\n\n /**\n * Generates a request identifier based on the requestKey or URL\n * @param {string} url - The URL of the request\n * @param {string|number|Function} requestKey - Optional key to generate a deterministic ID.\n * If provided, requests with the same key will share the same ID.\n * If null or undefined, the cleaned URL will be used as the key.\n * @param {boolean} noCancel - If true, generates a unique ID to prevent cancellation\n * @returns {string} A unique request identifier\n * @private\n */\n #_generateRequestId(url, requestKey = null, noCancel = false) {\n if (noCancel) { // Generate a unique ID to prevent cancellation\n return `request_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`;\n }\n if (requestKey !== null && requestKey !== undefined) {\n if (typeof requestKey === 'function') {\n try {\n requestKey = requestKey();\n } catch (error) {\n requestKey = null;\n }\n }\n if (requestKey !== null && requestKey !== undefined) return `request_${String(requestKey)}`;\n }\n // Use cleaned URL as key when requestKey is null/undefined\n let cleanedUrl = url || '';\n let hasProtocol = cleanedUrl.includes('://');\n if (hasProtocol) cleanedUrl = cleanedUrl.split('://')[1];\n let hasParams = cleanedUrl.includes('?');\n if (hasParams) cleanedUrl = cleanedUrl.split('?')[0];\n let hasHash = cleanedUrl.includes('#');\n if (hasHash) cleanedUrl = cleanedUrl.split('#')[0];\n return `request_${cleanedUrl}`;\n }\n\n /**\n * Prepares fetch options by merging options and removing custom properties\n * @param {Object} options - Configuration options\n * @param {AbortSignal} signal - Abort signal to add to fetch options\n * @param {Object} additionalOptions - Additional options to merge\n * @returns {Object} Prepared fetch options\n * @private\n */\n #_prepareFetchOptions(options, signal, additionalOptions = {}) {\n const fetchOptions = Object.assign({}, additionalOptions);\n const customOptions = ['abortController', 'cancelToken', 'requestKey', 'noCancel'];\n Object.keys(options).forEach(key => {\n if (customOptions.includes(key)) return;\n fetchOptions[key] = options[key];\n });\n fetchOptions.signal = signal;\n return fetchOptions;\n }\n\n /**\n * Internal method that handles the core request logic.\n * \n * @param {string} requestId - Unique identifier for the request\n * @param {Promise|Function|string} requestPromise - The request promise, function, or URL string\n * @param {Object} options - Configuration options\n * @param {AbortController} options.abortController - AbortController instance\n * @param {Function} options.cancelToken - Cancel token or cancel function\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * @private\n */\n #_request(requestId, requestPromise, options = {}) {\n this.#_setRequestOptions(options);\n if (!options.abortController) this.#_clearAbortController(); // Clear any existing abortController to ensure each request gets a fresh one\n this.#_flushRequestOptions();\n const abortController = options.abortController || this.getAbortController();\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 const fetchOptions = this.#_prepareFetchOptions(options, abortController.signal);\n requestPromise = requestPromise({ options: fetchOptions });\n } else if (typeof requestPromise === 'string') {\n // String (URL): make fetch internally\n const fetchOptions = this.#_prepareFetchOptions(options, abortController.signal);\n requestPromise = fetch(requestPromise, fetchOptions);\n }\n\n // Cancel previous request with the same ID 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 // Store the request information\n const requestInfo = {\n promise: requestPromise,\n abortController: abortController,\n cancelToken: options.cancelToken || null,\n wrapperPromise: wrapperPromise,\n resolveWrapper: resolveWrapper,\n rejectWrapper: rejectWrapper,\n isCancelled: false,\n verbose: this.verbose\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 && !requestInfo.isCancelled) {\n this.activeRequests.delete(requestId);\n resolveWrapper(result);\n }\n });\n if (req.catch) 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 const currentRequestInfo = scope.activeRequests.get(requestId);\n if (currentRequestInfo !== requestInfo) return;\n // Only delete if this is still the active request\n scope.activeRequests.delete(requestId);\n if (!requestInfo.isCancelled) rejectWrapper(error);\n else if (requestInfo.isCancelled && requestInfo.verbose) rejectWrapper(new Error('Request was cancelled'));\n }\n } else {\n // If requestPromise is not a promise, we can't track its completion automatically\n // This can happen with libraries like ExtJS that return request objects instead of promises\n // In this case, the user should handle the request object themselves\n // We'll resolve the wrapper promise immediately to prevent it from hanging\n // The user can still use the request object returned by the library\n setTimeout(() => {\n if (this.activeRequests.get(requestId) === requestInfo && !requestInfo.isCancelled) {\n this.activeRequests.delete(requestId);\n resolveWrapper(requestPromise); // Resolve with the request object so the user can use it\n }\n }, 0);\n }\n return wrapperPromise;\n }\n\n /**\n * Executes an HTTP request, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to request\n * @param {Promise|Function} requestPromise - The request promise or function that returns a promise\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {AbortController} options.abortController - AbortController instance (created automatically if not provided)\n * @param {Function} options.cancelToken - Cancel token or cancel function for other libraries\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed as fetch options (method, headers, body, etc.)\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Request with Promise\n * requestManager.request('/api/users', axios.get('/api/users', { cancelToken: axios.CancelToken.source().token }));\n * \n * @example\n * // Request with Function\n * requestManager.request('/api/users', ({ options }) => fetch('/api/users', { signal: options.signal, ...options }));\n * \n * @example\n * // Request with Promise and custom cancellation grouping with requestKey\n * const options = {\n * requestKey: 'get-users',\n * cancelToken: axios.CancelToken.source().cancel\n * }\n * requestManager.request('/api/users', axios.get('/api/users', options), options);\n * \n * @example\n * // Request with noCancel to allow concurrent requests (e.g., lazy loading)\n * requestManager.request('/api/lazy?load=1', fetch('/api/lazy?load=1'), { noCancel: true });\n * requestManager.request('/api/lazy?load=2', fetch('/api/lazy?load=2'), { noCancel: true });\n * // Both requests will execute concurrently without canceling each other\n */\n request(url, requestPromise, options = {}) {\n const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n return this.#_request(requestId, requestPromise, requestOptions);\n }\n\n /**\n * Executes an HTTP request using fetch, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to fetch\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {AbortController} options.abortController - AbortController instance (created automatically if not provided)\n * @param {Function} options.cancelToken - Cancel token or cancel function for other libraries\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed as fetch options (method, headers, body, etc.)\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Simple GET request\n * requestManager.fetch('/api/users');\n * \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 * \n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.fetch('/api/users', {\n * requestKey: 'get-users'\n * });\n * \n * @example\n * // Request with noCancel to allow concurrent requests (e.g., lazy loading)\n * requestManager.fetch('/api/lazy?load=1', { noCancel: true });\n * requestManager.fetch('/api/lazy?load=2', { noCancel: true });\n * // Both requests will execute concurrently without canceling each other\n */\n fetch(url, options = {}) {\n const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n return this.#_request(requestId, url, requestOptions);\n }\n\n /**\n * Executes an HTTP request using axios, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to request\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed as axios options (method, headers, params, data, etc.)\n * @param {Object} 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 * \n * @example\n * // Simple GET request (uses global axios)\n * requestManager.axios('/api/users');\n * \n * @example\n * // With custom axios instance\n * const myAxios = axios.create({ baseURL: 'https://api.example.com' });\n * requestManager.axios('/users', {}, myAxios);\n * \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 * \n * @example\n * // Request with requestKey for custom cancellation grouping with requestKey\n * requestManager.axios('/api/users', {\n * requestKey: 'get-users'\n * });\n * \n * @example\n * // Request with noCancel to allow concurrent requests\n * requestManager.axios('/api/lazy?load=1', { noCancel: true });\n * requestManager.axios('/api/lazy?load=2', { noCancel: true });\n */\n axios(url, options = {}, axiosInstance = null) {\n const requestOptions = options || {};\n const axiosLib = axiosInstance || axios;\n const cancelToken = axiosLib.CancelToken.source();\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n return this.#_request(requestId, axiosLib.get(url, { cancelToken: cancelToken.token, ...requestOptions }), {\n cancelToken: cancelToken,\n ...requestOptions\n });\n }\n\n /**\n * Executes an HTTP request using jQuery.ajax, cancelling any previous request with the same identifier.\n * \n * @param {Function} ajaxFunction - A function that receives { url, ...options } and returns a Promise\n * @param {string} url - The URL to request\n * @param {Object} options - Optional configuration\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * Any other properties are passed to the ajax method function\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Simple GET request\n * requestManager.ajax(ajaxFunction, '/api/users');\n * \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 * \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 const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n try {\n // AbortController is needed at this point, so we clear here any existing one.\n // This is the same behavior as in the request method.\n this.#_clearAbortController();\n const abortController = options.abortController || this.getAbortController();\n const req = ajaxFunction({ url, ...requestOptions });\n // Determine abort method\n let abortMethod = null;\n if (req) {\n if (typeof req.abort === 'function') {\n abortMethod = req.abort.bind(req);\n } else if (req.xhr && typeof req.xhr.abort === 'function') {\n abortMethod = req.xhr.abort.bind(req.xhr);\n }\n }\n if (abortMethod) this.addAbortListener(abortMethod, abortController.signal);\n // Pass the AbortController to avoid creating another one for this request\n return this.#_request(requestId, req, { ...requestOptions, abortController: abortController });\n } catch (error) {\n return Promise.reject(error);\n }\n }\n\n /**\n * Executes an HTTP request using XMLHttpRequest, cancelling any previous request with the same identifier.\n * \n * @param {string} url - The URL to request\n * @param {Object} options - Optional configuration\n * @param {string} options.method - HTTP method (GET, POST, PUT, DELETE, etc.). Defaults to 'GET'.\n * @param {Object} options.headers - Headers object to set on the request\n * @param {string|FormData|Blob|ArrayBuffer} options.body - Request body\n * @param {string} options.responseType - Response type ('text', 'json', 'blob', 'arraybuffer', 'document'). Defaults to 'text'.\n * @param {boolean} options.withCredentials - Whether to send credentials with the request\n * @param {number} options.timeout - Request timeout in milliseconds\n * @param {string|number|Function} options.requestKey - Key to identify duplicate requests.\n * If provided, requests with the same key will cancel previous ones.\n * Can be a string, number, or function that returns a key.\n * @param {boolean} options.noCancel - If true, this request will not cancel previous requests with the same ID, allowing concurrent requests\n * @returns {Promise} A Promise that resolves/rejects based on the most recent request\n * \n * @example\n * // Simple GET request\n * requestManager.xhr('/api/users');\n * \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 * \n * @example\n * // Request with requestKey for custom cancellation grouping\n * requestManager.xhr('/api/users', {\n * requestKey: 'get-users'\n * });\n * \n * @example\n * // Request with noCancel to allow concurrent requests\n * requestManager.xhr('/api/lazy?load=1', { noCancel: true });\n * requestManager.xhr('/api/lazy?load=2', { noCancel: true });\n */\n xhr(url, options = {}) {\n const requestOptions = options || {};\n const requestId = this.#_generateRequestId(url, requestOptions.requestKey, requestOptions.noCancel);\n const xhrFunction = ({ options: fetchOptions }) => {\n // Create XMLHttpRequest\n const xhr = new XMLHttpRequest();\n const method = (requestOptions.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 (requestOptions.responseType === 'json' ||\n (xhr.getResponseHeader('Content-Type') && xhr.getResponseHeader('Content-Type').includes('application/json'))) {\n try {\n response = JSON.parse(xhr.responseText);\n } catch (e) {\n response = xhr.responseText;\n }\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 (requestOptions.responseType) xhr.responseType = requestOptions.responseType;\n // Set withCredentials\n if (requestOptions.withCredentials !== undefined) xhr.withCredentials = requestOptions.withCredentials;\n // Set timeout\n if (requestOptions.timeout !== undefined) xhr.timeout = requestOptions.timeout;\n // Set headers\n if (requestOptions.headers) Object.keys(requestOptions.headers).forEach(key => {\n xhr.setRequestHeader(key, requestOptions.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(requestOptions.body || null);\n });\n return xhrPromise;\n };\n return this.#_request(requestId, xhrFunction, requestOptions);\n }\n\n /**\n * Cancels a specific request by its identifier.\n * \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 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 if (requestInfo.rejectWrapper && this.verbose) {\n requestInfo.rejectWrapper(new Error(`Request ${requestId} was cancelled`));\n }\n this.activeRequests.delete(requestId); // Remove from active requests\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 (!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 * \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 * Checks if a request with the given identifier is currently active.\n * \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 * \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\nexport default RequestManager;\n\nexport { RequestManager };\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM,cAAc,CAAC;AACrB,IAAI,WAAW,CAAC,cAAc,GAAG,EAAE,EAAE;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI,GAAG,EAAE;AACvC;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,IAAI,KAAK;AACtD;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc;AAC5C;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE;AACzB;AACA;AACA;AACA;AACA,QAAQ,IAAI,CAAC,eAAe,GAAG,IAAI;AACnC,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,IAAI,CAAC,OAAO,GAAG,EAAE;AACzB,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,UAAU,GAAG;AACjB,QAAQ,OAAO,IAAI,CAAC,cAAc;AAClC,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,UAAU,CAAC,OAAO,EAAE;AACxB,QAAQ,IAAI,CAAC,cAAc,GAAG,OAAO;AACrC,QAAQ,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;AAC3C,YAAY,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO;AAC1C,QAAQ;AACR,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA,IAAI,mBAAmB,CAAC,OAAO,EAAE;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,EAAE;AACrB,QAAQ,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM;AAC/C,YAAY,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;AACnD,gBAAgB,IAAI;AACpB,oBAAoB,WAAW,EAAE;AACjC,gBAAgB,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC;AACjC,YAAY;AACZ,QAAQ,CAAC,CAAC;AACV,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA,IAAI,SAAS,GAAG;AAChB,QAAQ,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;AACjE,QAAQ,IAAI,cAAc,GAAG,CAAC;AAC9B,QAAQ,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,KAAK;AAC1C,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE;AACxD,QAAQ,CAAC,CAAC;AACV,QAAQ,OAAO,cAAc;AAC7B,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,QAAQ,CAAC,SAAS,EAAE;AACxB,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC;AACjD,IAAI;;AAEJ;AACA;AACA;AACA;AACA;AACA,IAAI,cAAc,GAAG;AACrB,QAAQ,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI;AACvC,IAAI;;AAEJ;AACA;AACA;AACA;AACA,IAAI,KAAK,GAAG;AACZ,QAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE;AACnC,IAAI;AACJ;;;;;"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RequestManager - A library for managing and regulating HTTP requests efficiently.
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
6
2
|
/**
|
|
7
3
|
* RequestManager - A library for managing and regulating HTTP requests efficiently.
|
|
@@ -14,5 +10,5 @@
|
|
|
14
10
|
* @param {boolean} managerOptions.verbose - If true, cancellation errors will include messages
|
|
15
11
|
* @returns {RequestManager} A new RequestManager instance
|
|
16
12
|
*/
|
|
17
|
-
class e{constructor(e={}){this.activeRequests=new Map,this.verbose=e.verbose||!1,this.managerOptions=e,this.options={},this.abortController=null}#e(){this.options={}}getOptions(){return this.managerOptions}setOptions(e){this.managerOptions=e,void 0!==e.verbose&&(this.verbose=e.verbose)}#t(e){this.options=e}getSignal(){return this.getAbortController().signal}getAbortController(){return this.abortController&&!this.abortController.signal.aborted||(this.abortController=new AbortController),this.abortController}#s(){this.abortController=null}#r(e,t=null,s=!1){if(s)return`request_${Date.now()}_${Math.random().toString(36).slice(2,11)}`;if(null!=t){if("function"==typeof t)try{t=t()}catch(e){t=null}if(null!=t)return`request_${String(t)}`}let r=e||"";return r.includes("://")&&(r=r.split("://")[1]),r.includes("?")&&(r=r.split("?")[0]),r.includes("#")&&(r=r.split("#")[0]),`request_${r}`}#n(e,t,s={}){const r=Object.assign({},s),n=["abortController","cancelToken","requestKey","noCancel"];return Object.keys(e).forEach(t=>{n.includes(t)||(r[t]=e[t])}),r.signal=t,r}#o(e,t,s={}){this.#t(s),s.abortController||this.#s(),this.#e();const r=s.abortController||this.getAbortController();if("function"==typeof t){const l=this.#n(s,r.signal);t=t({options:l})}else if("string"==typeof t){const c=this.#n(s,r.signal);t=fetch(t,c)}let n,o;s.noCancel||this.cancel(e);const a=new Promise((e,t)=>{n=e,o=t}),i={promise:t,abortController:r,cancelToken:s.cancelToken||null,wrapperPromise:a,resolveWrapper:n,rejectWrapper:o,isCancelled:!1,verbose:this.verbose};if(this.activeRequests.set(e,i),t&&"function"==typeof t.then){try{let h=t.then(t=>{this.activeRequests.get(e)!==i||i.isCancelled||(this.activeRequests.delete(e),n(t))});h.catch&&h.catch(e=>{u(this,e)})}catch(p){u(this,p)}function u(t,s){t.activeRequests.get(e)===i&&(t.activeRequests.delete(e),i.isCancelled?i.isCancelled&&i.verbose&&o(new Error("Request was cancelled")):o(s))}}else setTimeout(()=>{this.activeRequests.get(e)!==i||i.isCancelled||(this.activeRequests.delete(e),n(t))},0);return a}request(e,t,s={}){const r=s||{},n=this.#r(e,r.requestKey,r.noCancel);return this.#o(n,t,r)}fetch(e,t={}){const s=t||{},r=this.#r(e,s.requestKey,s.noCancel);return this.#o(r,e,s)}axios(e,t={},s=null){const r=t||{},n=s||axios,o=n.CancelToken.source(),a=this.#r(e,r.requestKey,r.noCancel);return this.#o(a,n.get(e,{cancelToken:o.token,...r}),{cancelToken:o,...r})}ajax(e,t,s={}){if("function"!=typeof e)throw new Error("
|
|
13
|
+
class e{constructor(e={}){this.activeRequests=new Map,this.verbose=e.verbose||!1,this.managerOptions=e,this.options={},this.abortController=null}#e(){this.options={}}getOptions(){return this.managerOptions}setOptions(e){this.managerOptions=e,void 0!==e.verbose&&(this.verbose=e.verbose)}#t(e){this.options=e}getSignal(){return this.getAbortController().signal}getAbortController(){return this.abortController&&!this.abortController.signal.aborted||(this.abortController=new AbortController),this.abortController}#s(){this.abortController=null}#r(e,t=null,s=!1){if(s)return`request_${Date.now()}_${Math.random().toString(36).slice(2,11)}`;if(null!=t){if("function"==typeof t)try{t=t()}catch(e){t=null}if(null!=t)return`request_${String(t)}`}let r=e||"";return r.includes("://")&&(r=r.split("://")[1]),r.includes("?")&&(r=r.split("?")[0]),r.includes("#")&&(r=r.split("#")[0]),`request_${r}`}#n(e,t,s={}){const r=Object.assign({},s),n=["abortController","cancelToken","requestKey","noCancel"];return Object.keys(e).forEach(t=>{n.includes(t)||(r[t]=e[t])}),r.signal=t,r}#o(e,t,s={}){this.#t(s),s.abortController||this.#s(),this.#e();const r=s.abortController||this.getAbortController();if("function"==typeof t){const l=this.#n(s,r.signal);t=t({options:l})}else if("string"==typeof t){const c=this.#n(s,r.signal);t=fetch(t,c)}let n,o;s.noCancel||this.cancel(e);const a=new Promise((e,t)=>{n=e,o=t}),i={promise:t,abortController:r,cancelToken:s.cancelToken||null,wrapperPromise:a,resolveWrapper:n,rejectWrapper:o,isCancelled:!1,verbose:this.verbose};if(this.activeRequests.set(e,i),t&&"function"==typeof t.then){try{let h=t.then(t=>{this.activeRequests.get(e)!==i||i.isCancelled||(this.activeRequests.delete(e),n(t))});h.catch&&h.catch(e=>{u(this,e)})}catch(p){u(this,p)}function u(t,s){t.activeRequests.get(e)===i&&(t.activeRequests.delete(e),i.isCancelled?i.isCancelled&&i.verbose&&o(new Error("Request was cancelled")):o(s))}}else setTimeout(()=>{this.activeRequests.get(e)!==i||i.isCancelled||(this.activeRequests.delete(e),n(t))},0);return a}request(e,t,s={}){const r=s||{},n=this.#r(e,r.requestKey,r.noCancel);return this.#o(n,t,r)}fetch(e,t={}){const s=t||{},r=this.#r(e,s.requestKey,s.noCancel);return this.#o(r,e,s)}axios(e,t={},s=null){const r=t||{},n=s||axios,o=n.CancelToken.source(),a=this.#r(e,r.requestKey,r.noCancel);return this.#o(a,n.get(e,{cancelToken:o.token,...r}),{cancelToken:o,...r})}ajax(e,t,s={}){if("function"!=typeof e)throw new Error("ajaxFunction parameter must be a function");const r=s||{},n=this.#r(t,r.requestKey,r.noCancel);try{this.#s();const o=s.abortController||this.getAbortController(),a=e({url:t,...r});let i=null;return a&&("function"==typeof a.abort?i=a.abort.bind(a):a.xhr&&"function"==typeof a.xhr.abort&&(i=a.xhr.abort.bind(a.xhr))),i&&this.addAbortListener(i,o.signal),this.#o(n,a,{...r,abortController:o})}catch(e){return Promise.reject(e)}}xhr(e,t={}){const s=t||{},r=this.#r(e,s.requestKey,s.noCancel);return this.#o(r,({options:t})=>{const r=new XMLHttpRequest,n=(s.method||"GET").toUpperCase();return new Promise((o,a)=>{r.onload=function(){if(r.status>=200&&r.status<300){let e=r.response;if("json"===s.responseType||r.getResponseHeader("Content-Type")&&r.getResponseHeader("Content-Type").includes("application/json"))try{e=JSON.parse(r.responseText)}catch(t){e=r.responseText}o({data:e,status:r.status,statusText:r.statusText,headers:r.getAllResponseHeaders(),xhr:r})}else a({message:`Request failed with status ${r.status}`,status:r.status,statusText:r.statusText,xhr:r})},r.onerror=function(){a({message:"Network error",xhr:r})},r.ontimeout=function(){a({message:"Request timeout",xhr:r})},r.open(n,e,!0),s.responseType&&(r.responseType=s.responseType),void 0!==s.withCredentials&&(r.withCredentials=s.withCredentials),void 0!==s.timeout&&(r.timeout=s.timeout),s.headers&&Object.keys(s.headers).forEach(e=>{r.setRequestHeader(e,s.headers[e])}),t.signal&&t.signal.addEventListener("abort",()=>r.abort()),r.send(s.body||null)})},s)}cancel(e){const t=this.activeRequests.get(e);if(!t)return!1;if(t.isCancelled=!0,t.abortController&&!t.abortController.signal.aborted)try{t.abortController.abort("Request was cancelled")}catch(e){}if(t.cancelToken)try{"function"==typeof t.cancelToken?t.cancelToken():t.cancelToken.cancel&&t.cancelToken.cancel()}catch(e){}return t.rejectWrapper&&this.verbose&&t.rejectWrapper(new Error(`Request ${e} was cancelled`)),this.activeRequests.delete(e),!0}addAbortListener(e,t){t&&t.addEventListener("abort",()=>{if("function"==typeof e)try{e()}catch(e){}})}cancelAll(){const e=Array.from(this.activeRequests.keys());let t=0;return e.forEach(e=>{this.cancel(e)&&t++}),t}isActive(e){return this.activeRequests.has(e)}getActiveCount(){return this.activeRequests.size}clear(){this.activeRequests.clear()}}exports.RequestManager=e,exports.default=e;
|
|
18
14
|
//# sourceMappingURL=request-manager.cjs.min.js.map
|