febs-browser 1.2.10 → 1.2.12

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 CHANGED
@@ -93,14 +93,24 @@ febs.string.replace();
93
93
 
94
94
  ![](../doc/framework.png)
95
95
 
96
- - [dom](#dom)
97
- - [date](#date)
98
- - [utils](#utils)
99
- - [string](#string)
100
- - [crypt](#crypt)
101
- - [animationFrame](#animationFrame)
102
- - [net](#net)
103
- - [jquery $](#jquery)
96
+ - [Install](#install)
97
+ - [commonjs](#commonjs)
98
+ - [browser](#browser)
99
+ - [babel](#babel)
100
+ - [framework](#framework)
101
+ - [说明](#说明)
102
+ - [polyfill](#polyfill)
103
+ - [dom](#dom)
104
+ - [date](#date)
105
+ - [utils](#utils)
106
+ - [string](#string)
107
+ - [crypt](#crypt)
108
+ - [animationFrame](#animationframe)
109
+ - [net](#net)
110
+ - [jquery](#jquery)
111
+ - [常用](#常用)
112
+ - [事件.](#事件)
113
+ - [遍历](#遍历)
104
114
 
105
115
  # 说明
106
116
 
@@ -574,6 +584,7 @@ febs.net.ajax(cfg:any):{abort:()=>void}
574
584
  timeout, // 超时 (ms), 默认为5000,
575
585
  credentials, // 携带了credentials='include'则服务器需设置Access-Control-Allow-Credentials
576
586
  progress, // 允许设置进度cb. function(percent) {}
587
+ signal?: any; // AbortControllerObject.signal
577
588
  }
578
589
  * @return: 返回 Promise;
579
590
  * @e.g.
@@ -583,6 +594,11 @@ febs.net.ajax(cfg:any):{abort:()=>void}
583
594
  .catch(err=>{
584
595
  if (err === 'timeout) // 超时.
585
596
  });
597
+ * @e.g.
598
+ // abort fetch.
599
+ let abortController = new. febs.net.AbortController();
600
+ febs.net.fetch(url, {signal: abortController.signal}).then(...);
601
+ abortController.abort(); // abort network.
586
602
  */
587
603
  febs.net.fetch(url, option)
588
604
  /**
package/dist/README.md CHANGED
@@ -40,16 +40,16 @@ npm install febs-browser --save
40
40
 
41
41
  | 类型 | 路径 |
42
42
  | ---------------------------------- | -------------------------------------------- |
43
- | 不包含BigNumber相关的库 (体积较小) | `febs-browser` |
44
- | 包含BigNumber相关的库 | `febs-browser/dist/index.noBignumber.min.js` |
43
+ | 不包含BigNumber相关的库 (体积较小) | `febs-browser/dist/index.noBignumber.min.js` |
44
+ | 包含BigNumber相关的库 | `febs-browser` |
45
45
 
46
46
  同时提供如下三种模式的库:
47
47
 
48
- | 类型 | 文件名规则 |
48
+ | 类型 | 对应文件 |
49
49
  | -------- | ---------------------------------------------------------- |
50
- | umd | `dist/index.js`, `dist/index.noBignumber.js` |
51
- | commonjs | `dist/index.common.js`, `dist/index.noBignumber.common.js` |
52
- | esm | `dist/index.esm.js`, `dist/index.noBignumber.esm.js` |
50
+ | umd | `dist/index.js` 或 `dist/index.noBignumber.js` |
51
+ | commonjs | `dist/index.common.js` 或 `dist/index.noBignumber.common.js` |
52
+ | esm | `dist/index.esm.js` 或 `dist/index.noBignumber.esm.js` |
53
53
 
54
54
 
55
55
  ## commonjs
@@ -331,6 +331,26 @@ febs.utils.browserIEVer()
331
331
  * @desc: the browser is support html5.
332
332
  */
333
333
  febs.utils.browserIsSupportHtml5() `服务端不支持`
334
+ /**
335
+ * @desc: 判断是否是safari.
336
+ */
337
+ febs.utils.browserIsSafari()
338
+ /**
339
+ * @desc: 判断是否是opera.
340
+ */
341
+ febs.utils.browserIsOpera()
342
+ /**
343
+ * @desc: 判断是否是firefox.
344
+ */
345
+ febs.utils.browserIsFirefox()
346
+ /**
347
+ * @desc: 判断是否是chrome.
348
+ */
349
+ febs.utils.browserIsChrome()
350
+ /**
351
+ * @desc: 判断是否是edge.
352
+ */
353
+ febs.utils.browserIsEdge()
334
354
  ```
335
355
  ```js
336
356
  /**
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * febs v1.2.10
3
- * Copyright (c) 2021 bpoint.lee@gmail.com All Rights Reserved.
2
+ * febs v1.2.12
3
+ * Copyright (c) 2026 bpoint.lee@gmail.com All Rights Reserved.
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -5537,10 +5537,40 @@ var net$1 = {}; //--------------------------------------------------------
5537
5537
  //--------------------------------------------------------
5538
5538
 
5539
5539
  {
5540
+ var AbortController = function AbortController() {
5541
+ var _this = this;
5542
+
5543
+ Object.defineProperty(this, 'signal', {
5544
+ get: function get() {
5545
+ if (!_this.__signalWrap) {
5546
+ _this.__signalWrap = {};
5547
+ }
5548
+
5549
+ return _this.__signalWrap;
5550
+ },
5551
+ enumerable: true,
5552
+ configurable: true
5553
+ });
5554
+ };
5555
+
5540
5556
  if (!Promise) {
5541
5557
  throw new Error('unsupported Promise');
5542
- } // https://github.com/github/fetch
5558
+ }
5559
+
5560
+ AbortController.prototype.abort = function () {
5561
+ if (this.__signalWrap && this.__signalWrap.__xhr) {
5562
+ try {
5563
+ this.__signalWrap.__xhr.abort();
5564
+ } catch (e) {
5565
+ console.log(e);
5566
+ }
5567
+
5568
+ this.__signalWrap.__xhr = null;
5569
+ }
5570
+ };
5543
5571
 
5572
+ Window$2._AbortController = AbortController;
5573
+ net$1.AbortController = AbortController; // https://github.com/github/fetch
5544
5574
 
5545
5575
  febsnet.normalizeName = function (name) {
5546
5576
  if (typeof name !== 'string') {
@@ -5922,7 +5952,7 @@ var net$1 = {}; //--------------------------------------------------------
5922
5952
  var status = xhr.status === 1223 ? 204 : xhr.status;
5923
5953
 
5924
5954
  if (status < 100 || status > 599) {
5925
- reject(new exception('Network request failed', 'NetworkFailed', __filename, __line, __column));
5955
+ reject(new exception('Network request failed', 'NetworkFailed', null, null, null));
5926
5956
  return;
5927
5957
  }
5928
5958
 
@@ -5938,21 +5968,25 @@ var net$1 = {}; //--------------------------------------------------------
5938
5968
  };
5939
5969
 
5940
5970
  xhr.ontimeout = function () {
5941
- reject(new exception('Network timeout', 'NetworkTimeout', __filename, __line, __column));
5971
+ reject(new exception('Network timeout', 'NetworkTimeout', null, null, null));
5942
5972
  };
5943
5973
 
5944
5974
  xhr.onerror = function () {
5945
- reject(new exception('Network request failed', 'NetworkFailed', __filename, __line, __column));
5975
+ reject(new exception('Network request failed', 'NetworkFailed', null, null, null));
5946
5976
  };
5947
5977
 
5948
5978
  if (init && init.progress) {
5949
5979
  xhr.onprogress = function (event) {
5950
5980
  if (event.lengthComputable) {
5951
- init.progress(event.position / event.totalSize);
5981
+ init.progress((event.position || event.loaded || 0) / (event.totalSize || event.total || 1));
5952
5982
  }
5953
5983
  };
5954
5984
  }
5955
5985
 
5986
+ if (init && init.signal) {
5987
+ init.signal.__xhr = xhr;
5988
+ }
5989
+
5956
5990
  xhr.open(request.method, request.url, true);
5957
5991
  var timeout = init ? init.timeout : null;
5958
5992
  xhr.timeout = timeout !== undefined && timeout !== null ? timeout : net_transfer.DefaultTimeout;
@@ -5969,13 +6003,17 @@ var net$1 = {}; //--------------------------------------------------------
5969
6003
 
5970
6004
  if (xhr.setRequestHeader) {
5971
6005
  request.headers.forEach(function (value, name) {
5972
- xhr.setRequestHeader(name, value);
6006
+ xhr.setRequestHeader(name, value.join(','));
5973
6007
  });
5974
6008
  } else if (request.headers && request.headers.map.length > 0) {
5975
6009
  console.log('fetch can\'t set headers');
5976
6010
  }
5977
6011
 
5978
- xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
6012
+ try {
6013
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
6014
+ } catch (e) {
6015
+ reject(new exception('Network request failed', 'NetworkFailed', null, null, null));
6016
+ }
5979
6017
  });
5980
6018
  };
5981
6019
 
@@ -6057,6 +6095,7 @@ var net_jsonp = net$2;
6057
6095
 
6058
6096
  var net$3 = {
6059
6097
  ajax: net_ajax.ajax,
6098
+ AbortController: net_fetch.AbortController,
6060
6099
  fetch: net_fetch.fetch,
6061
6100
  jsonp: net_jsonp.jsonp
6062
6101
  };