@wiajs/req 1.7.32 → 1.7.33

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/dist/node/req.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wia/req v1.7.32
2
+ * @wia/req v1.7.33
3
3
  * (c) 2024-2025 Sibyl Yu, Matt Zabriskie and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -10,9 +10,9 @@ const url = require('url');
10
10
  const agent = require('@wiajs/agent');
11
11
  const log$1 = require('@wiajs/log');
12
12
  const request = require('@wiajs/request');
13
- const util = require('util');
14
13
  const events = require('events');
15
14
  const stream = require('stream');
15
+ const util = require('util');
16
16
  const zlib = require('zlib');
17
17
 
18
18
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -248,8 +248,8 @@ function findKey(obj, key) {
248
248
  return null;
249
249
  }
250
250
  const _global = (()=>{
251
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
252
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
251
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
252
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
253
253
  })();
254
254
  const isContextDefined = (context)=>!isUndefined(context) && context !== _global;
255
255
  /**
@@ -317,7 +317,7 @@ const isContextDefined = (context)=>!isUndefined(context) && context !== _global
317
317
  *
318
318
  * @returns {string} content value without BOM
319
319
  */ const stripBOM = (content)=>{
320
- if (content.charCodeAt(0) === 0xFEFF) {
320
+ if (content.charCodeAt(0) === 0xfeff) {
321
321
  content = content.slice(1);
322
322
  }
323
323
  return content;
@@ -494,7 +494,7 @@ const reduceDescriptors = (obj, reducer)=>{
494
494
  }
495
495
  if (!descriptor.set) {
496
496
  descriptor.set = ()=>{
497
- throw Error('Can not rewrite read-only method \'' + name + '\'');
497
+ throw Error("Can not rewrite read-only method '" + name + "'");
498
498
  };
499
499
  }
500
500
  });
@@ -568,14 +568,14 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported)=>{
568
568
  return setImmediate;
569
569
  }
570
570
  return postMessageSupported ? ((token, callbacks)=>{
571
- _global.addEventListener("message", ({ source, data })=>{
571
+ _global.addEventListener('message', ({ source, data })=>{
572
572
  if (source === _global && data === token) {
573
573
  callbacks.length && callbacks.shift()();
574
574
  }
575
575
  }, false);
576
576
  return (cb)=>{
577
577
  callbacks.push(cb);
578
- _global.postMessage(token, "*");
578
+ _global.postMessage(token, '*');
579
579
  };
580
580
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
581
581
  })(typeof setImmediate === 'function', isFunction(_global.postMessage));
@@ -2249,7 +2249,6 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2249
2249
  const protocol = parsed.protocol || supportedProtocols[0];
2250
2250
  _.protocol = protocol;
2251
2251
  if (protocol === 'data:' && method !== 'GET') {
2252
- // throw error
2253
2252
  const response = {
2254
2253
  status: 405,
2255
2254
  statusText: 'method not allowed',
@@ -2367,12 +2366,12 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2367
2366
  if (config.httpAgent) options.agents = {
2368
2367
  http: config.httpAgent
2369
2368
  };
2370
- if (config.httpsAgent) options.agents.https = config.httpAgent;
2371
- // ! 配置了 agent,使用Agent,否则使用缺省 agent,agents 优于agent
2369
+ if (config.httpsAgent) options.agents.https = config.httpsAgent;
2370
+ // axios 侧一般传 agents(用于重定向按协议选 agent
2372
2371
  if (config.agents) options.agents = config.agents;
2373
2372
  else if (config.agent) options.agents = new agent.Agent(config.agent);
2374
2373
  const isHttpsRequest = isHttps.test(options.protocol);
2375
- // agents 优先于 agent,在 request中根据协议从 agents 中获取
2374
+ // agents 优先于 agent(Node request 内部会按协议从 agents 取):contentReference[oaicite:4]{index=4}
2376
2375
  options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
2377
2376
  // cacheable-lookup integration hotfix
2378
2377
  if (!utils$1.isUndefined(lookup)) options.lookup = lookup;
@@ -2431,9 +2430,7 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2431
2430
  }
2432
2431
  if (responseType === 'text') {
2433
2432
  convertedData = convertedData.toString(responseEncoding);
2434
- if (!responseEncoding || responseEncoding === 'utf8') {
2435
- convertedData = utils$1.stripBOM(convertedData);
2436
- }
2433
+ if (!responseEncoding || responseEncoding === 'utf8') convertedData = utils$1.stripBOM(convertedData);
2437
2434
  } else if (responseType === 'stream') {
2438
2435
  convertedData = stream.Readable.from(convertedData);
2439
2436
  }
@@ -2461,8 +2458,6 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2461
2458
  options.stream = (_config_stream = config.stream) != null ? _config_stream : false;
2462
2459
  var _config_decompress;
2463
2460
  options.decompress = (_config_decompress = config.decompress) != null ? _config_decompress : true;
2464
- // Create the request,promise false: return stream
2465
- // log.debug('request', {options});
2466
2461
  const req = transport ? transport.request(options) : request(options);
2467
2462
  if (!req) return reject(new AxiosError('Request failed.', AxiosError.ERR_BAD_REQUEST, config));
2468
2463
  _.req = req;
@@ -2503,9 +2498,7 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2503
2498
  if (_.isDone) return;
2504
2499
  let timeoutErrorMessage = config.timeout ? `timeout of ${config.timeout}ms exceeded` : 'timeout exceeded';
2505
2500
  const transitional = config.transitional || transitionalDefaults;
2506
- if (config.timeoutErrorMessage) {
2507
- timeoutErrorMessage = config.timeoutErrorMessage;
2508
- }
2501
+ if (config.timeoutErrorMessage) timeoutErrorMessage = config.timeoutErrorMessage;
2509
2502
  reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, req));
2510
2503
  abort();
2511
2504
  });
@@ -2519,8 +2512,8 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2519
2512
  // 非stream模式,等待响应数据,返回数据
2520
2513
  req.on('response', /**
2521
2514
  * @param {*} res 原数据流
2522
- * @param {*} stream 解压等处理后的数据流
2523
- */ (res, stream)=>{
2515
+ * @param {*} stream2 解压等处理后的数据流
2516
+ */ (res, stream2)=>{
2524
2517
  if (req.destroyed) return;
2525
2518
  // 'transfer-encoding': 'chunked'时,无content-length,axios v1.2 不能自动解压
2526
2519
  const responseLength = +res.headers['content-length'];
@@ -2540,36 +2533,36 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2540
2533
  };
2541
2534
  // 直接返回 responseStream
2542
2535
  if (responseType === 'stream') {
2543
- response.data = stream;
2536
+ response.data = stream2;
2544
2537
  settle(resolve, reject, response);
2545
2538
  } else {
2546
2539
  // 处理 responseStream
2547
2540
  /** @type {*} */ const responseBuffer = [];
2548
2541
  let totalResponseBytes = 0;
2549
2542
  // 处理数据
2550
- stream.on('data', /** @param {*} chunk */ (chunk)=>{
2543
+ stream2.on('data', /** @param {*} chunk */ (chunk)=>{
2551
2544
  responseBuffer.push(chunk);
2552
2545
  totalResponseBytes += chunk.length;
2553
2546
  // make sure the content length is not over the maxContentLength if specified
2554
2547
  if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
2555
2548
  // stream.destroy() emit aborted event before calling reject() on Node.js v16
2556
2549
  _.rejected = true;
2557
- stream.destroy();
2550
+ stream2.destroy();
2558
2551
  reject(new AxiosError(`maxContentLength size of ${config.maxContentLength} exceeded`, AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
2559
2552
  }
2560
2553
  });
2561
- stream.on('aborted', function handlerStreamAborted() {
2554
+ stream2.on('aborted', function handlerStreamAborted() {
2562
2555
  if (_.rejected) return;
2563
2556
  const err = new AxiosError(`maxContentLength size of ${config.maxContentLength} exceeded`, AxiosError.ERR_BAD_RESPONSE, config, lastRequest);
2564
- stream.destroy(err);
2557
+ stream2.destroy(err);
2565
2558
  reject(err);
2566
2559
  });
2567
- stream.on('error', function handleStreamError(err) {
2560
+ stream2.on('error', function handleStreamError(err) {
2568
2561
  if (req.destroyed) return;
2569
2562
  reject(AxiosError.from(err, null, config, lastRequest));
2570
2563
  });
2571
2564
  // 数据传输结束
2572
- stream.on('end', function handleStreamEnd() {
2565
+ stream2.on('end', function handleStreamEnd() {
2573
2566
  try {
2574
2567
  let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
2575
2568
  if (responseType !== 'arraybuffer') {
@@ -2586,9 +2579,9 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2586
2579
  });
2587
2580
  }
2588
2581
  emitter.once('abort', (err)=>{
2589
- if (!stream.destroyed) {
2590
- stream.emit('error', err);
2591
- stream.destroy();
2582
+ if (!stream2.destroyed) {
2583
+ stream2.emit('error', err);
2584
+ stream2.destroy();
2592
2585
  }
2593
2586
  });
2594
2587
  });
@@ -2619,7 +2612,7 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils$1.kindOf(
2619
2612
  }
2620
2613
  _.done(R);
2621
2614
  } catch (e) {
2622
- log.error(e, 'request');
2615
+ log.err(e, 'request catch');
2623
2616
  _.done(e, true);
2624
2617
  throw e;
2625
2618
  }
package/dist/req.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wia/req v1.7.32
2
+ * @wia/req v1.7.33
3
3
  * (c) 2024-2025 Sibyl Yu, Matt Zabriskie and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -241,8 +241,8 @@
241
241
  return null;
242
242
  }
243
243
  const _global$1 = (()=>{
244
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
245
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
244
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
245
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
246
246
  })();
247
247
  const isContextDefined$1 = (context)=>!isUndefined$1(context) && context !== _global$1;
248
248
  /**
@@ -310,7 +310,7 @@
310
310
  *
311
311
  * @returns {string} content value without BOM
312
312
  */ const stripBOM$1 = (content)=>{
313
- if (content.charCodeAt(0) === 0xFEFF) {
313
+ if (content.charCodeAt(0) === 0xfeff) {
314
314
  content = content.slice(1);
315
315
  }
316
316
  return content;
@@ -487,7 +487,7 @@
487
487
  }
488
488
  if (!descriptor.set) {
489
489
  descriptor.set = ()=>{
490
- throw Error('Can not rewrite read-only method \'' + name + '\'');
490
+ throw Error("Can not rewrite read-only method '" + name + "'");
491
491
  };
492
492
  }
493
493
  });
@@ -561,14 +561,14 @@
561
561
  return setImmediate;
562
562
  }
563
563
  return postMessageSupported ? ((token, callbacks)=>{
564
- _global$1.addEventListener("message", ({ source, data })=>{
564
+ _global$1.addEventListener('message', ({ source, data })=>{
565
565
  if (source === _global$1 && data === token) {
566
566
  callbacks.length && callbacks.shift()();
567
567
  }
568
568
  }, false);
569
569
  return (cb)=>{
570
570
  callbacks.push(cb);
571
- _global$1.postMessage(token, "*");
571
+ _global$1.postMessage(token, '*');
572
572
  };
573
573
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
574
574
  })(typeof setImmediate === 'function', isFunction$1(_global$1.postMessage));
@@ -1294,8 +1294,8 @@
1294
1294
  return null;
1295
1295
  }
1296
1296
  const _global = (()=>{
1297
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
1298
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
1297
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
1298
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
1299
1299
  })();
1300
1300
  const isContextDefined = (context)=>!isUndefined(context) && context !== _global;
1301
1301
  /**
@@ -1363,7 +1363,7 @@
1363
1363
  *
1364
1364
  * @returns {string} content value without BOM
1365
1365
  */ const stripBOM = (content)=>{
1366
- if (content.charCodeAt(0) === 0xFEFF) {
1366
+ if (content.charCodeAt(0) === 0xfeff) {
1367
1367
  content = content.slice(1);
1368
1368
  }
1369
1369
  return content;
@@ -1540,7 +1540,7 @@
1540
1540
  }
1541
1541
  if (!descriptor.set) {
1542
1542
  descriptor.set = ()=>{
1543
- throw Error('Can not rewrite read-only method \'' + name + '\'');
1543
+ throw Error("Can not rewrite read-only method '" + name + "'");
1544
1544
  };
1545
1545
  }
1546
1546
  });
@@ -1614,14 +1614,14 @@
1614
1614
  return setImmediate;
1615
1615
  }
1616
1616
  return postMessageSupported ? ((token, callbacks)=>{
1617
- _global.addEventListener("message", ({ source, data })=>{
1617
+ _global.addEventListener('message', ({ source, data })=>{
1618
1618
  if (source === _global && data === token) {
1619
1619
  callbacks.length && callbacks.shift()();
1620
1620
  }
1621
1621
  }, false);
1622
1622
  return (cb)=>{
1623
1623
  callbacks.push(cb);
1624
- _global.postMessage(token, "*");
1624
+ _global.postMessage(token, '*');
1625
1625
  };
1626
1626
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
1627
1627
  })(typeof setImmediate === 'function', isFunction(_global.postMessage));
package/dist/req.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wia/req v1.7.32
2
+ * @wia/req v1.7.33
3
3
  * (c) 2024-2025 Sibyl Yu, Matt Zabriskie and contributors
4
4
  * Released under the MIT License.
5
5
  */
package/dist/web/req.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wia/req v1.7.32
2
+ * @wia/req v1.7.33
3
3
  * (c) 2024-2025 Sibyl Yu, Matt Zabriskie and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -237,8 +237,8 @@ function findKey$1(obj, key) {
237
237
  return null;
238
238
  }
239
239
  const _global$1 = (()=>{
240
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
241
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
240
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
241
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
242
242
  })();
243
243
  const isContextDefined$1 = (context)=>!isUndefined$1(context) && context !== _global$1;
244
244
  /**
@@ -306,7 +306,7 @@ const isContextDefined$1 = (context)=>!isUndefined$1(context) && context !== _gl
306
306
  *
307
307
  * @returns {string} content value without BOM
308
308
  */ const stripBOM$1 = (content)=>{
309
- if (content.charCodeAt(0) === 0xFEFF) {
309
+ if (content.charCodeAt(0) === 0xfeff) {
310
310
  content = content.slice(1);
311
311
  }
312
312
  return content;
@@ -483,7 +483,7 @@ const reduceDescriptors$1 = (obj, reducer)=>{
483
483
  }
484
484
  if (!descriptor.set) {
485
485
  descriptor.set = ()=>{
486
- throw Error('Can not rewrite read-only method \'' + name + '\'');
486
+ throw Error("Can not rewrite read-only method '" + name + "'");
487
487
  };
488
488
  }
489
489
  });
@@ -557,14 +557,14 @@ const _setImmediate$1 = ((setImmediateSupported, postMessageSupported)=>{
557
557
  return setImmediate;
558
558
  }
559
559
  return postMessageSupported ? ((token, callbacks)=>{
560
- _global$1.addEventListener("message", ({ source, data })=>{
560
+ _global$1.addEventListener('message', ({ source, data })=>{
561
561
  if (source === _global$1 && data === token) {
562
562
  callbacks.length && callbacks.shift()();
563
563
  }
564
564
  }, false);
565
565
  return (cb)=>{
566
566
  callbacks.push(cb);
567
- _global$1.postMessage(token, "*");
567
+ _global$1.postMessage(token, '*');
568
568
  };
569
569
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
570
570
  })(typeof setImmediate === 'function', isFunction$1(_global$1.postMessage));
@@ -1290,8 +1290,8 @@ function findKey(obj, key) {
1290
1290
  return null;
1291
1291
  }
1292
1292
  const _global = (()=>{
1293
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
1294
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
1293
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
1294
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
1295
1295
  })();
1296
1296
  const isContextDefined = (context)=>!isUndefined(context) && context !== _global;
1297
1297
  /**
@@ -1359,7 +1359,7 @@ const isContextDefined = (context)=>!isUndefined(context) && context !== _global
1359
1359
  *
1360
1360
  * @returns {string} content value without BOM
1361
1361
  */ const stripBOM = (content)=>{
1362
- if (content.charCodeAt(0) === 0xFEFF) {
1362
+ if (content.charCodeAt(0) === 0xfeff) {
1363
1363
  content = content.slice(1);
1364
1364
  }
1365
1365
  return content;
@@ -1536,7 +1536,7 @@ const reduceDescriptors = (obj, reducer)=>{
1536
1536
  }
1537
1537
  if (!descriptor.set) {
1538
1538
  descriptor.set = ()=>{
1539
- throw Error('Can not rewrite read-only method \'' + name + '\'');
1539
+ throw Error("Can not rewrite read-only method '" + name + "'");
1540
1540
  };
1541
1541
  }
1542
1542
  });
@@ -1610,14 +1610,14 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported)=>{
1610
1610
  return setImmediate;
1611
1611
  }
1612
1612
  return postMessageSupported ? ((token, callbacks)=>{
1613
- _global.addEventListener("message", ({ source, data })=>{
1613
+ _global.addEventListener('message', ({ source, data })=>{
1614
1614
  if (source === _global && data === token) {
1615
1615
  callbacks.length && callbacks.shift()();
1616
1616
  }
1617
1617
  }, false);
1618
1618
  return (cb)=>{
1619
1619
  callbacks.push(cb);
1620
- _global.postMessage(token, "*");
1620
+ _global.postMessage(token, '*');
1621
1621
  };
1622
1622
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
1623
1623
  })(typeof setImmediate === 'function', isFunction(_global.postMessage));
package/dist/web/req.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wia/req v1.7.32
2
+ * @wia/req v1.7.33
3
3
  * (c) 2024-2025 Sibyl Yu, Matt Zabriskie and contributors
4
4
  * Released under the MIT License.
5
5
  */
@@ -235,8 +235,8 @@ function findKey$1(obj, key) {
235
235
  return null;
236
236
  }
237
237
  const _global$1 = (()=>{
238
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
239
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
238
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
239
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
240
240
  })();
241
241
  const isContextDefined$1 = (context)=>!isUndefined$1(context) && context !== _global$1;
242
242
  /**
@@ -304,7 +304,7 @@ const isContextDefined$1 = (context)=>!isUndefined$1(context) && context !== _gl
304
304
  *
305
305
  * @returns {string} content value without BOM
306
306
  */ const stripBOM$1 = (content)=>{
307
- if (content.charCodeAt(0) === 0xFEFF) {
307
+ if (content.charCodeAt(0) === 0xfeff) {
308
308
  content = content.slice(1);
309
309
  }
310
310
  return content;
@@ -481,7 +481,7 @@ const reduceDescriptors$1 = (obj, reducer)=>{
481
481
  }
482
482
  if (!descriptor.set) {
483
483
  descriptor.set = ()=>{
484
- throw Error('Can not rewrite read-only method \'' + name + '\'');
484
+ throw Error("Can not rewrite read-only method '" + name + "'");
485
485
  };
486
486
  }
487
487
  });
@@ -555,14 +555,14 @@ const _setImmediate$1 = ((setImmediateSupported, postMessageSupported)=>{
555
555
  return setImmediate;
556
556
  }
557
557
  return postMessageSupported ? ((token, callbacks)=>{
558
- _global$1.addEventListener("message", ({ source, data })=>{
558
+ _global$1.addEventListener('message', ({ source, data })=>{
559
559
  if (source === _global$1 && data === token) {
560
560
  callbacks.length && callbacks.shift()();
561
561
  }
562
562
  }, false);
563
563
  return (cb)=>{
564
564
  callbacks.push(cb);
565
- _global$1.postMessage(token, "*");
565
+ _global$1.postMessage(token, '*');
566
566
  };
567
567
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
568
568
  })(typeof setImmediate === 'function', isFunction$1(_global$1.postMessage));
@@ -1288,8 +1288,8 @@ function findKey(obj, key) {
1288
1288
  return null;
1289
1289
  }
1290
1290
  const _global = (()=>{
1291
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
1292
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
1291
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
1292
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
1293
1293
  })();
1294
1294
  const isContextDefined = (context)=>!isUndefined(context) && context !== _global;
1295
1295
  /**
@@ -1357,7 +1357,7 @@ const isContextDefined = (context)=>!isUndefined(context) && context !== _global
1357
1357
  *
1358
1358
  * @returns {string} content value without BOM
1359
1359
  */ const stripBOM = (content)=>{
1360
- if (content.charCodeAt(0) === 0xFEFF) {
1360
+ if (content.charCodeAt(0) === 0xfeff) {
1361
1361
  content = content.slice(1);
1362
1362
  }
1363
1363
  return content;
@@ -1534,7 +1534,7 @@ const reduceDescriptors = (obj, reducer)=>{
1534
1534
  }
1535
1535
  if (!descriptor.set) {
1536
1536
  descriptor.set = ()=>{
1537
- throw Error('Can not rewrite read-only method \'' + name + '\'');
1537
+ throw Error("Can not rewrite read-only method '" + name + "'");
1538
1538
  };
1539
1539
  }
1540
1540
  });
@@ -1608,14 +1608,14 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported)=>{
1608
1608
  return setImmediate;
1609
1609
  }
1610
1610
  return postMessageSupported ? ((token, callbacks)=>{
1611
- _global.addEventListener("message", ({ source, data })=>{
1611
+ _global.addEventListener('message', ({ source, data })=>{
1612
1612
  if (source === _global && data === token) {
1613
1613
  callbacks.length && callbacks.shift()();
1614
1614
  }
1615
1615
  }, false);
1616
1616
  return (cb)=>{
1617
1617
  callbacks.push(cb);
1618
- _global.postMessage(token, "*");
1618
+ _global.postMessage(token, '*');
1619
1619
  };
1620
1620
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
1621
1621
  })(typeof setImmediate === 'function', isFunction(_global.postMessage));
@@ -1,43 +1,29 @@
1
1
  import { Agent } from '@wiajs/agent';
2
2
  import { log as Log, name } from '@wiajs/log';
3
3
  import request from '@wiajs/request';
4
- import buildFullPath from '../core/buildFullPath.js';
5
- import settle from '../core/settle.js';
6
- import buildURL from '../helpers/buildURL.js';
7
- import utils from '../utils.js';
8
- // import {getProxyForUrl} from 'proxy-from-env';
9
- import util from 'util';
10
4
  // import followRedirects from 'follow-redirects';
11
5
  // import Redirect from '../request/index.js'
12
6
  import { EventEmitter } from 'events';
13
7
  import stream from 'stream';
8
+ // import {getProxyForUrl} from 'proxy-from-env';
9
+ import util from 'util';
14
10
  import zlib from 'zlib';
15
11
  import CanceledError from '../cancel/CanceledError.js';
16
12
  import AxiosError from '../core/AxiosError.js';
17
13
  import AxiosHeaders from '../core/AxiosHeaders.js';
14
+ import buildFullPath from '../core/buildFullPath.js';
15
+ import settle from '../core/settle.js';
18
16
  import transitionalDefaults from '../defaults/transitional.js';
19
17
  import { VERSION } from '../env/data.js';
20
18
  import AxiosTransformStream from '../helpers/AxiosTransformStream.js';
19
+ import buildURL from '../helpers/buildURL.js';
21
20
  import callbackify from '../helpers/callbackify.js';
22
21
  import formDataToStream from '../helpers/formDataToStream.js';
23
22
  import fromDataURI from '../helpers/fromDataURI.js';
24
23
  import { asyncDecorator, progressEventDecorator, progressEventReducer } from '../helpers/progressEventReducer.js';
25
24
  import readBlob from '../helpers/readBlob.js';
26
25
  import platform from '../platform/index.js';
27
- const px = {
28
- host: '114.98.163.61:17813'
29
- };
30
- const agent = {
31
- // proxy: `http://${px.host}`, // 高效、隧道
32
- proxy: `socks://${px.host}`,
33
- // 连接复用,目的主机如关闭,则重新连接,连接代理keepAlive需为true
34
- keepAlive: true,
35
- // 同一目的网址最大并发连接,超过排队,隧道代理或服务器限制并发时需设置,否则报错,默认值:Infinity
36
- // maxSockets: 5, // 无连接,并发连接时,此参数无效,转发代理支持并发无需设置或设置并发数
37
- // maxFreeSockets: 5, // 同一目的主机空闲最大连接,超过关闭。keepAlive true 时有效。默认值:256
38
- // timeout: 10000, // 建立连接时长,缺省 30000
39
- rejectUnauthorized: false
40
- };
26
+ import utils from '../utils.js';
41
27
  const log = Log({
42
28
  env: `wia:req:${name(import.meta.url)}`
43
29
  });
@@ -140,7 +126,6 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
140
126
  const protocol = parsed.protocol || supportedProtocols[0];
141
127
  _.protocol = protocol;
142
128
  if (protocol === 'data:' && method !== 'GET') {
143
- // throw error
144
129
  const response = {
145
130
  status: 405,
146
131
  statusText: 'method not allowed',
@@ -260,12 +245,12 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
260
245
  if (config.httpAgent) options.agents = {
261
246
  http: config.httpAgent
262
247
  };
263
- if (config.httpsAgent) options.agents.https = config.httpAgent;
264
- // ! 配置了 agent,使用Agent,否则使用缺省 agent,agents 优于agent
248
+ if (config.httpsAgent) options.agents.https = config.httpsAgent;
249
+ // axios 侧一般传 agents(用于重定向按协议选 agent
265
250
  if (config.agents) options.agents = config.agents;
266
251
  else if (config.agent) options.agents = new Agent(config.agent);
267
252
  const isHttpsRequest = isHttps.test(options.protocol);
268
- // agents 优先于 agent,在 request中根据协议从 agents 中获取
253
+ // agents 优先于 agent(Node request 内部会按协议从 agents 取):contentReference[oaicite:4]{index=4}
269
254
  options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
270
255
  // cacheable-lookup integration hotfix
271
256
  if (!utils.isUndefined(lookup)) options.lookup = lookup;
@@ -324,9 +309,7 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
324
309
  }
325
310
  if (responseType === 'text') {
326
311
  convertedData = convertedData.toString(responseEncoding);
327
- if (!responseEncoding || responseEncoding === 'utf8') {
328
- convertedData = utils.stripBOM(convertedData);
329
- }
312
+ if (!responseEncoding || responseEncoding === 'utf8') convertedData = utils.stripBOM(convertedData);
330
313
  } else if (responseType === 'stream') {
331
314
  convertedData = stream.Readable.from(convertedData);
332
315
  }
@@ -354,8 +337,6 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
354
337
  options.stream = (_config_stream = config.stream) != null ? _config_stream : false;
355
338
  var _config_decompress;
356
339
  options.decompress = (_config_decompress = config.decompress) != null ? _config_decompress : true;
357
- // Create the request,promise false: return stream
358
- // log.debug('request', {options});
359
340
  const req = transport ? transport.request(options) : request(options);
360
341
  if (!req) return reject(new AxiosError('Request failed.', AxiosError.ERR_BAD_REQUEST, config));
361
342
  _.req = req;
@@ -396,9 +377,7 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
396
377
  if (_.isDone) return;
397
378
  let timeoutErrorMessage = config.timeout ? `timeout of ${config.timeout}ms exceeded` : 'timeout exceeded';
398
379
  const transitional = config.transitional || transitionalDefaults;
399
- if (config.timeoutErrorMessage) {
400
- timeoutErrorMessage = config.timeoutErrorMessage;
401
- }
380
+ if (config.timeoutErrorMessage) timeoutErrorMessage = config.timeoutErrorMessage;
402
381
  reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, req));
403
382
  abort();
404
383
  });
@@ -412,8 +391,8 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
412
391
  // 非stream模式,等待响应数据,返回数据
413
392
  req.on('response', /**
414
393
  * @param {*} res 原数据流
415
- * @param {*} stream 解压等处理后的数据流
416
- */ (res, stream)=>{
394
+ * @param {*} stream2 解压等处理后的数据流
395
+ */ (res, stream2)=>{
417
396
  if (req.destroyed) return;
418
397
  // 'transfer-encoding': 'chunked'时,无content-length,axios v1.2 不能自动解压
419
398
  const responseLength = +res.headers['content-length'];
@@ -433,36 +412,36 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
433
412
  };
434
413
  // 直接返回 responseStream
435
414
  if (responseType === 'stream') {
436
- response.data = stream;
415
+ response.data = stream2;
437
416
  settle(resolve, reject, response);
438
417
  } else {
439
418
  // 处理 responseStream
440
419
  /** @type {*} */ const responseBuffer = [];
441
420
  let totalResponseBytes = 0;
442
421
  // 处理数据
443
- stream.on('data', /** @param {*} chunk */ (chunk)=>{
422
+ stream2.on('data', /** @param {*} chunk */ (chunk)=>{
444
423
  responseBuffer.push(chunk);
445
424
  totalResponseBytes += chunk.length;
446
425
  // make sure the content length is not over the maxContentLength if specified
447
426
  if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
448
427
  // stream.destroy() emit aborted event before calling reject() on Node.js v16
449
428
  _.rejected = true;
450
- stream.destroy();
429
+ stream2.destroy();
451
430
  reject(new AxiosError(`maxContentLength size of ${config.maxContentLength} exceeded`, AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
452
431
  }
453
432
  });
454
- stream.on('aborted', function handlerStreamAborted() {
433
+ stream2.on('aborted', function handlerStreamAborted() {
455
434
  if (_.rejected) return;
456
435
  const err = new AxiosError(`maxContentLength size of ${config.maxContentLength} exceeded`, AxiosError.ERR_BAD_RESPONSE, config, lastRequest);
457
- stream.destroy(err);
436
+ stream2.destroy(err);
458
437
  reject(err);
459
438
  });
460
- stream.on('error', function handleStreamError(err) {
439
+ stream2.on('error', function handleStreamError(err) {
461
440
  if (req.destroyed) return;
462
441
  reject(AxiosError.from(err, null, config, lastRequest));
463
442
  });
464
443
  // 数据传输结束
465
- stream.on('end', function handleStreamEnd() {
444
+ stream2.on('end', function handleStreamEnd() {
466
445
  try {
467
446
  let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
468
447
  if (responseType !== 'arraybuffer') {
@@ -479,9 +458,9 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
479
458
  });
480
459
  }
481
460
  emitter.once('abort', (err)=>{
482
- if (!stream.destroyed) {
483
- stream.emit('error', err);
484
- stream.destroy();
461
+ if (!stream2.destroyed) {
462
+ stream2.emit('error', err);
463
+ stream2.destroy();
485
464
  }
486
465
  });
487
466
  });
@@ -512,7 +491,7 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
512
491
  }
513
492
  _.done(R);
514
493
  } catch (e) {
515
- log.error(e, 'request');
494
+ log.err(e, 'request catch');
516
495
  _.done(e, true);
517
496
  throw e;
518
497
  }
package/lib/utils.js CHANGED
@@ -1,4 +1,3 @@
1
- 'use strict';
2
1
  import bind from './helpers/bind.js';
3
2
  // utils is a library of generic helper functions non-specific to axios
4
3
  const { toString } = Object.prototype;
@@ -226,8 +225,8 @@ function findKey(obj, key) {
226
225
  return null;
227
226
  }
228
227
  const _global = (()=>{
229
- /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
230
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
228
+ /*eslint no-undef:0*/ if (typeof globalThis !== 'undefined') return globalThis;
229
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
231
230
  })();
232
231
  const isContextDefined = (context)=>!isUndefined(context) && context !== _global;
233
232
  /**
@@ -295,7 +294,7 @@ const isContextDefined = (context)=>!isUndefined(context) && context !== _global
295
294
  *
296
295
  * @returns {string} content value without BOM
297
296
  */ const stripBOM = (content)=>{
298
- if (content.charCodeAt(0) === 0xFEFF) {
297
+ if (content.charCodeAt(0) === 0xfeff) {
299
298
  content = content.slice(1);
300
299
  }
301
300
  return content;
@@ -472,7 +471,7 @@ const reduceDescriptors = (obj, reducer)=>{
472
471
  }
473
472
  if (!descriptor.set) {
474
473
  descriptor.set = ()=>{
475
- throw Error('Can not rewrite read-only method \'' + name + '\'');
474
+ throw Error("Can not rewrite read-only method '" + name + "'");
476
475
  };
477
476
  }
478
477
  });
@@ -546,14 +545,14 @@ const _setImmediate = ((setImmediateSupported, postMessageSupported)=>{
546
545
  return setImmediate;
547
546
  }
548
547
  return postMessageSupported ? ((token, callbacks)=>{
549
- _global.addEventListener("message", ({ source, data })=>{
548
+ _global.addEventListener('message', ({ source, data })=>{
550
549
  if (source === _global && data === token) {
551
550
  callbacks.length && callbacks.shift()();
552
551
  }
553
552
  }, false);
554
553
  return (cb)=>{
555
554
  callbacks.push(cb);
556
- _global.postMessage(token, "*");
555
+ _global.postMessage(token, '*');
557
556
  };
558
557
  })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
559
558
  })(typeof setImmediate === 'function', isFunction(_global.postMessage));
package/package.json CHANGED
@@ -1,226 +1,223 @@
1
1
  {
2
- "name": "@wiajs/req",
3
- "version": "1.7.32",
4
- "description": "Promise And Stream based AXIOS client for the browser and node.js",
5
- "type": "module",
6
- "types": "index.d.ts",
7
- "main": "index.js",
8
- "exports": {
9
- ".": {
10
- "types": {
11
- "require": "./index.d.cts",
12
- "default": "./index.d.ts"
13
- },
14
- "browser": {
15
- "require": "./dist/web/req.cjs",
16
- "default": "./index.js"
17
- },
18
- "default": {
19
- "require": "./dist/node/req.cjs",
20
- "default": "./index.js"
21
- }
22
- },
23
- "./lib/adapters/http.js": "./lib/adapters/http.js",
24
- "./lib/adapters/xhr.js": "./lib/adapters/xhr.js",
25
- "./unsafe/*": "./lib/*",
26
- "./unsafe/core/settle.js": "./lib/core/settle.js",
27
- "./unsafe/core/buildFullPath.js": "./lib/core/buildFullPath.js",
28
- "./unsafe/helpers/isAbsoluteURL.js": "./lib/helpers/isAbsoluteURL.js",
29
- "./unsafe/helpers/buildURL.js": "./lib/helpers/buildURL.js",
30
- "./unsafe/helpers/combineURLs.js": "./lib/helpers/combineURLs.js",
31
- "./unsafe/adapters/http.js": "./lib/adapters/http.js",
32
- "./unsafe/adapters/xhr.js": "./lib/adapters/xhr.js",
33
- "./unsafe/utils.js": "./lib/utils.js",
34
- "./package.json": "./package.json"
35
- },
36
- "browser": {
37
- "./src/adapters/http.js": "./lib/helpers/null.js",
38
- "./src/platform/node/index.js": "./lib/platform/browser/index.js",
39
- "./src/platform/node/classes/FormData.js": "./lib/helpers/null.js"
40
- },
41
- "scripts": {
42
- "test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports",
43
- "test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js",
44
- "test:dtslint": "dtslint --localTs node_modules/typescript/lib",
45
- "test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit",
46
- "test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit",
47
- "test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run",
48
- "test:karma:firefox": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: Browsers=Firefox karma start karma.conf.cjs --single-run",
49
- "test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs",
50
- "test:build:version": "node ./bin/check-build-version.js",
51
- "start": "node ./sandbox/server.js",
52
- "preversion-x": "gulp version",
53
- "version": "npm run build && git add dist && git add package.json",
54
- "prepublishOnly-x": "npm run test:build:version",
55
- "postpublish": "git push && git push --tags",
56
- "build-x": "gulp clear && cross-env NODE_ENV=production rollup -c -m",
57
- "bin": "swc --config-file ./bin.swcrc ./src -d bin -w --strip-leading-paths",
58
- "build": "cross-env NODE_ENV=production gulp build",
59
- "examples": "node ./examples/server.js",
60
- "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
61
- "fix": "eslint --fix lib/**/*.js",
62
- "prepare-x": "husky install && npm run prepare:hooks",
63
- "prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"",
64
- "release:dry": "release-it --dry-run --no-npm",
65
- "release:info": "release-it --release-version",
66
- "release:beta:no-npm": "release-it --preRelease=beta --no-npm",
67
- "release:beta": "release-it --preRelease=beta",
68
- "release:no-npm": "release-it --no-npm",
69
- "release:changelog:fix": "node ./bin/injectContributorsList.js && git add CHANGELOG.md",
70
- "release": "release-it"
71
- },
72
- "repository": {
73
- "type": "git",
74
- "url": "https://github.com/wiajs/req.git"
75
- },
76
- "keywords": [
77
- "xhr",
78
- "http",
79
- "ajax",
80
- "promise",
81
- "stream",
82
- "node"
83
- ],
84
- "author": "Sibyl Yu <sibyl@wia.pub>",
85
- "bugs": "https://github.com/wiajs/req/issues",
86
- "homepage": "https://wiajs.pub/req",
87
- "license": "MIT",
88
- "publishConfig": {
89
- "access": "public"
90
- },
91
- "devDependencies": {
92
- "@babel/core": "^7.23.9",
93
- "@babel/preset-env": "^7.23.9",
94
- "@commitlint/cli": "^17.8.1",
95
- "@commitlint/config-conventional": "^17.8.1",
96
- "@release-it/conventional-changelog": "^5.1.1",
97
- "@rollup/plugin-alias": "^5.1.0",
98
- "@rollup/plugin-babel": "^5.3.1",
99
- "@rollup/plugin-commonjs": "^15.1.0",
100
- "@rollup/plugin-json": "^4.1.0",
101
- "@rollup/plugin-multi-entry": "^4.1.0",
102
- "@rollup/plugin-node-resolve": "^9.0.0",
103
- "abortcontroller-polyfill": "^1.7.5",
104
- "auto-changelog": "^2.4.0",
105
- "body-parser": "^1.20.2",
106
- "chalk": "^5.3.0",
107
- "coveralls": "^3.1.1",
108
- "cross-env": "^7.0.3",
109
- "dev-null": "^0.1.1",
110
- "dtslint": "^4.2.1",
111
- "es6-promise": "^4.2.8",
112
- "eslint": "^8.56.0",
113
- "express": "^4.18.2",
114
- "formdata-node": "^5.0.1",
115
- "formidable": "^2.1.2",
116
- "fs-extra": "^10.1.0",
117
- "get-stream": "^3.0.0",
118
- "gulp": "^4.0.2",
119
- "gzip-size": "^7.0.0",
120
- "handlebars": "^4.7.8",
121
- "husky": "^8.0.3",
122
- "istanbul-instrumenter-loader": "^3.0.1",
123
- "jasmine-core": "^2.99.1",
124
- "karma": "^6.3.17",
125
- "karma-chrome-launcher": "^3.2.0",
126
- "karma-firefox-launcher": "^2.1.2",
127
- "karma-jasmine": "^1.1.2",
128
- "karma-jasmine-ajax": "^0.1.13",
129
- "karma-rollup-preprocessor": "^7.0.8",
130
- "karma-safari-launcher": "^1.0.0",
131
- "karma-sauce-launcher": "^4.3.6",
132
- "karma-sinon": "^1.0.5",
133
- "karma-sourcemap-loader": "^0.3.8",
134
- "memoizee": "^0.4.15",
135
- "minimist": "^1.2.8",
136
- "mocha": "^10.3.0",
137
- "multer": "^1.4.4",
138
- "pretty-bytes": "^6.1.1",
139
- "release-it": "^15.11.0",
140
- "rollup": "^2.79.1",
141
- "rollup-plugin-auto-external": "^2.0.0",
142
- "rollup-plugin-bundle-size": "^1.0.3",
143
- "rollup-plugin-terser": "^7.0.2",
144
- "sinon": "^4.5.0",
145
- "stream-throttle": "^0.1.3",
146
- "string-replace-async": "^3.0.2",
147
- "terser-webpack-plugin": "^4.2.3",
148
- "typescript": "^4.9.5"
149
- },
150
- "dependencies": {
151
- "@wiajs/agent": "^1.0.21",
152
- "@wiajs/log": "^4.3.19",
153
- "@wiajs/request": "^3.0.32",
154
- "form-data": "^4.0.0",
155
- "proxy-from-env": "^1.1.0"
156
- },
157
- "jsdelivr": "dist/req.min.js",
158
- "unpkg": "dist/req.min.js",
159
- "typings": "./index.d.ts",
160
- "bundlesize": [
161
- {
162
- "path": "./dist/req.min.js",
163
- "threshold": "5kB"
164
- }
165
- ],
166
- "contributors": [
167
- "Sibyl Yu (https://github.com/wiajs)",
168
- "Matt Zabriskie (https://github.com/mzabriskie)",
169
- "Nick Uraltsev (https://github.com/nickuraltsev)",
170
- "Dmitriy Mozgovoy (https://github.com/DigitalBrainJS)",
171
- "Jay (https://github.com/jasonsaayman)",
172
- "Emily Morehouse (https://github.com/emilyemorehouse)",
173
- "Rubén Norte (https://github.com/rubennorte)",
174
- "Justin Beckwith (https://github.com/JustinBeckwith)",
175
- "Martti Laine (https://github.com/codeclown)",
176
- "Xianming Zhong (https://github.com/chinesedfan)",
177
- "Rikki Gibson (https://github.com/RikkiGibson)",
178
- "Remco Haszing (https://github.com/remcohaszing)",
179
- "Yasu Flores (https://github.com/yasuf)",
180
- "Ben Carp (https://github.com/carpben)"
181
- ],
182
- "sideEffects": false,
183
- "release-it": {
184
- "git": {
185
- "commitMessage": "chore(release): v${version}",
186
- "push": true,
187
- "commit": true,
188
- "tag": true,
189
- "requireCommits": false,
190
- "requireCleanWorkingDir": false
191
- },
192
- "github": {
193
- "release": true,
194
- "draft": true
195
- },
196
- "npm": {
197
- "publish": false,
198
- "ignoreVersion": false
199
- },
200
- "plugins": {
201
- "@release-it/conventional-changelog": {
202
- "preset": "angular",
203
- "infile": "CHANGELOG.md",
204
- "header": "# Changelog"
205
- }
206
- },
207
- "hooks": {
208
- "before:init": "npm test",
209
- "after:bump": "gulp version --bump ${version} && npm run build && npm run test:build:version && git add ./dist && git add ./package-lock.json",
210
- "before:release": "npm run release:changelog:fix",
211
- "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
212
- }
213
- },
214
- "commitlint": {
215
- "rules": {
216
- "header-max-length": [
217
- 2,
218
- "always",
219
- 130
220
- ]
221
- },
222
- "extends": [
223
- "@commitlint/config-conventional"
224
- ]
225
- }
2
+ "name": "@wiajs/req",
3
+ "version": "1.7.33",
4
+ "description": "Promise And Stream based AXIOS client for the browser and node.js",
5
+ "type": "module",
6
+ "types": "index.d.ts",
7
+ "main": "index.js",
8
+ "exports": {
9
+ ".": {
10
+ "types": {
11
+ "require": "./index.d.cts",
12
+ "default": "./index.d.ts"
13
+ },
14
+ "browser": {
15
+ "require": "./dist/web/req.cjs",
16
+ "default": "./index.js"
17
+ },
18
+ "default": {
19
+ "require": "./dist/node/req.cjs",
20
+ "default": "./index.js"
21
+ }
22
+ },
23
+ "./lib/adapters/http.js": "./lib/adapters/http.js",
24
+ "./lib/adapters/xhr.js": "./lib/adapters/xhr.js",
25
+ "./unsafe/*": "./lib/*",
26
+ "./unsafe/core/settle.js": "./lib/core/settle.js",
27
+ "./unsafe/core/buildFullPath.js": "./lib/core/buildFullPath.js",
28
+ "./unsafe/helpers/isAbsoluteURL.js": "./lib/helpers/isAbsoluteURL.js",
29
+ "./unsafe/helpers/buildURL.js": "./lib/helpers/buildURL.js",
30
+ "./unsafe/helpers/combineURLs.js": "./lib/helpers/combineURLs.js",
31
+ "./unsafe/adapters/http.js": "./lib/adapters/http.js",
32
+ "./unsafe/adapters/xhr.js": "./lib/adapters/xhr.js",
33
+ "./unsafe/utils.js": "./lib/utils.js",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "browser": {
37
+ "./src/adapters/http.js": "./lib/helpers/null.js",
38
+ "./src/platform/node/index.js": "./lib/platform/browser/index.js",
39
+ "./src/platform/node/classes/FormData.js": "./lib/helpers/null.js"
40
+ },
41
+ "scripts": {
42
+ "test": "npm run test:eslint && npm run test:mocha && npm run test:karma && npm run test:dtslint && npm run test:exports",
43
+ "test:eslint": "node bin/ssl_hotfix.js eslint lib/**/*.js",
44
+ "test:dtslint": "dtslint --localTs node_modules/typescript/lib",
45
+ "test:mocha": "node bin/ssl_hotfix.js mocha test/unit/**/*.js --timeout 30000 --exit",
46
+ "test:exports": "node bin/ssl_hotfix.js mocha test/module/test.js --timeout 30000 --exit",
47
+ "test:karma": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: karma start karma.conf.cjs --single-run",
48
+ "test:karma:firefox": "node bin/ssl_hotfix.js cross-env LISTEN_ADDR=:: Browsers=Firefox karma start karma.conf.cjs --single-run",
49
+ "test:karma:server": "node bin/ssl_hotfix.js cross-env karma start karma.conf.cjs",
50
+ "test:build:version": "node ./bin/check-build-version.js",
51
+ "start": "node ./sandbox/server.js",
52
+ "preversion-x": "gulp version",
53
+ "version": "npm run build && git add dist && git add package.json",
54
+ "prepublishOnly-x": "npm run test:build:version",
55
+ "postpublish": "git push && git push --tags",
56
+ "build-x": "gulp clear && cross-env NODE_ENV=production rollup -c -m",
57
+ "bin": "swc --config-file ./bin.swcrc ./src -d bin -w --strip-leading-paths",
58
+ "build": "cross-env NODE_ENV=production gulp build",
59
+ "examples": "node ./examples/server.js",
60
+ "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
61
+ "fix": "eslint --fix lib/**/*.js",
62
+ "prepare-x": "husky install && npm run prepare:hooks",
63
+ "prepare:hooks": "npx husky set .husky/commit-msg \"npx commitlint --edit $1\"",
64
+ "release:dry": "release-it --dry-run --no-npm",
65
+ "release:info": "release-it --release-version",
66
+ "release:beta:no-npm": "release-it --preRelease=beta --no-npm",
67
+ "release:beta": "release-it --preRelease=beta",
68
+ "release:no-npm": "release-it --no-npm",
69
+ "release:changelog:fix": "node ./bin/injectContributorsList.js && git add CHANGELOG.md",
70
+ "release": "release-it"
71
+ },
72
+ "repository": {
73
+ "type": "git",
74
+ "url": "https://github.com/wiajs/req.git"
75
+ },
76
+ "keywords": [
77
+ "xhr",
78
+ "http",
79
+ "ajax",
80
+ "promise",
81
+ "stream",
82
+ "node"
83
+ ],
84
+ "author": "Sibyl Yu <sibyl@wia.pub>",
85
+ "bugs": "https://github.com/wiajs/req/issues",
86
+ "homepage": "https://wiajs.pub/req",
87
+ "license": "MIT",
88
+ "publishConfig": {
89
+ "access": "public"
90
+ },
91
+ "devDependencies": {
92
+ "@commitlint/cli": "^17.8.1",
93
+ "@commitlint/config-conventional": "^17.8.1",
94
+ "@release-it/conventional-changelog": "^5.1.1",
95
+ "@rollup/plugin-alias": "^5.1.0",
96
+ "@rollup/plugin-babel": "^5.3.1",
97
+ "@rollup/plugin-commonjs": "^15.1.0",
98
+ "@rollup/plugin-json": "^4.1.0",
99
+ "@rollup/plugin-multi-entry": "^4.1.0",
100
+ "@rollup/plugin-node-resolve": "^9.0.0",
101
+ "abortcontroller-polyfill": "^1.7.5",
102
+ "auto-changelog": "^2.4.0",
103
+ "body-parser": "^1.20.2",
104
+ "chalk": "^5.3.0",
105
+ "coveralls": "^3.1.1",
106
+ "cross-env": "^7.0.3",
107
+ "dev-null": "^0.1.1",
108
+ "dtslint": "^4.2.1",
109
+ "es6-promise": "^4.2.8",
110
+ "eslint": "^8.56.0",
111
+ "express": "^4.18.2",
112
+ "formdata-node": "^5.0.1",
113
+ "formidable": "^2.1.2",
114
+ "fs-extra": "^10.1.0",
115
+ "get-stream": "^3.0.0",
116
+ "gulp": "^4.0.2",
117
+ "gzip-size": "^7.0.0",
118
+ "handlebars": "^4.7.8",
119
+ "husky": "^8.0.3",
120
+ "istanbul-instrumenter-loader": "^3.0.1",
121
+ "jasmine-core": "^2.99.1",
122
+ "karma": "^6.3.17",
123
+ "karma-chrome-launcher": "^3.2.0",
124
+ "karma-firefox-launcher": "^2.1.2",
125
+ "karma-jasmine": "^1.1.2",
126
+ "karma-jasmine-ajax": "^0.1.13",
127
+ "karma-rollup-preprocessor": "^7.0.8",
128
+ "karma-safari-launcher": "^1.0.0",
129
+ "karma-sauce-launcher": "^4.3.6",
130
+ "karma-sinon": "^1.0.5",
131
+ "karma-sourcemap-loader": "^0.3.8",
132
+ "memoizee": "^0.4.15",
133
+ "minimist": "^1.2.8",
134
+ "mocha": "^10.3.0",
135
+ "multer": "^1.4.4",
136
+ "pretty-bytes": "^6.1.1",
137
+ "release-it": "^15.11.0",
138
+ "rollup": "^2.79.1",
139
+ "rollup-plugin-auto-external": "^2.0.0",
140
+ "rollup-plugin-bundle-size": "^1.0.3",
141
+ "rollup-plugin-terser": "^7.0.2",
142
+ "sinon": "^4.5.0",
143
+ "stream-throttle": "^0.1.3",
144
+ "string-replace-async": "^3.0.2",
145
+ "terser-webpack-plugin": "^4.2.3",
146
+ "typescript": "^4.9.5"
147
+ },
148
+ "dependencies": {
149
+ "@wiajs/agent": "^1.0.30",
150
+ "@wiajs/log": "^4.3.21",
151
+ "@wiajs/request": "^3.0.39",
152
+ "form-data": "^4.0.0"
153
+ },
154
+ "jsdelivr": "dist/req.min.js",
155
+ "unpkg": "dist/req.min.js",
156
+ "typings": "./index.d.ts",
157
+ "bundlesize": [
158
+ {
159
+ "path": "./dist/req.min.js",
160
+ "threshold": "5kB"
161
+ }
162
+ ],
163
+ "contributors": [
164
+ "Sibyl Yu (https://github.com/wiajs)",
165
+ "Matt Zabriskie (https://github.com/mzabriskie)",
166
+ "Nick Uraltsev (https://github.com/nickuraltsev)",
167
+ "Dmitriy Mozgovoy (https://github.com/DigitalBrainJS)",
168
+ "Jay (https://github.com/jasonsaayman)",
169
+ "Emily Morehouse (https://github.com/emilyemorehouse)",
170
+ "Rubén Norte (https://github.com/rubennorte)",
171
+ "Justin Beckwith (https://github.com/JustinBeckwith)",
172
+ "Martti Laine (https://github.com/codeclown)",
173
+ "Xianming Zhong (https://github.com/chinesedfan)",
174
+ "Rikki Gibson (https://github.com/RikkiGibson)",
175
+ "Remco Haszing (https://github.com/remcohaszing)",
176
+ "Yasu Flores (https://github.com/yasuf)",
177
+ "Ben Carp (https://github.com/carpben)"
178
+ ],
179
+ "sideEffects": false,
180
+ "release-it": {
181
+ "git": {
182
+ "commitMessage": "chore(release): v${version}",
183
+ "push": true,
184
+ "commit": true,
185
+ "tag": true,
186
+ "requireCommits": false,
187
+ "requireCleanWorkingDir": false
188
+ },
189
+ "github": {
190
+ "release": true,
191
+ "draft": true
192
+ },
193
+ "npm": {
194
+ "publish": false,
195
+ "ignoreVersion": false
196
+ },
197
+ "plugins": {
198
+ "@release-it/conventional-changelog": {
199
+ "preset": "angular",
200
+ "infile": "CHANGELOG.md",
201
+ "header": "# Changelog"
202
+ }
203
+ },
204
+ "hooks": {
205
+ "before:init": "npm test",
206
+ "after:bump": "gulp version --bump ${version} && npm run build && npm run test:build:version && git add ./dist && git add ./package-lock.json",
207
+ "before:release": "npm run release:changelog:fix",
208
+ "after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
209
+ }
210
+ },
211
+ "commitlint": {
212
+ "rules": {
213
+ "header-max-length": [
214
+ 2,
215
+ "always",
216
+ 130
217
+ ]
218
+ },
219
+ "extends": [
220
+ "@commitlint/config-conventional"
221
+ ]
222
+ }
226
223
  }