febs-browser 1.2.9 → 1.2.11

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.9
3
- * Copyright (c) 2021 bpoint.lee@gmail.com All Rights Reserved.
2
+ * febs v1.2.11
3
+ * Copyright (c) 2026 bpoint.lee@gmail.com All Rights Reserved.
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -14,10 +14,6 @@ function createCommonjsModule(fn, module) {
14
14
  return module = { exports: {} }, fn(module, module.exports), module.exports;
15
15
  }
16
16
 
17
- function getCjsExportFromNamespace (n) {
18
- return n && n['default'] || n;
19
- }
20
-
21
17
  var check = function (it) {
22
18
  return it && it.Math == Math && it;
23
19
  };
@@ -1432,10 +1428,6 @@ if ( typeof nativePromiseConstructor == 'function' && !nativePromiseConstructor.
1432
1428
  };
1433
1429
  })();
1434
1430
 
1435
- var promiseFinallyPolyfill = /*#__PURE__*/Object.freeze({
1436
- __proto__: null
1437
- });
1438
-
1439
1431
  var slice = [].slice;
1440
1432
  var MSIE = /MSIE .\./.test(engineUserAgent); // <- dirty ie9- check
1441
1433
 
@@ -4671,7 +4663,7 @@ function ajax(ctx) {
4671
4663
  if (cbError) cbError(xhr, null, new TypeError('Network request failed'));
4672
4664
  };
4673
4665
 
4674
- if (ctx.progress) {
4666
+ if (ctx && ctx.progress) {
4675
4667
  if ('upload' in xhr && 'onprogress' in xhr.upload) {
4676
4668
  xhr.upload.onprogress = function (event) {
4677
4669
  if (event.lengthComputable) {
@@ -5537,10 +5529,40 @@ var net$1 = {}; //--------------------------------------------------------
5537
5529
  //--------------------------------------------------------
5538
5530
 
5539
5531
  {
5532
+ var AbortController = function AbortController() {
5533
+ var _this = this;
5534
+
5535
+ Object.defineProperty(this, 'signal', {
5536
+ get: function get() {
5537
+ if (!_this.__signalWrap) {
5538
+ _this.__signalWrap = {};
5539
+ }
5540
+
5541
+ return _this.__signalWrap;
5542
+ },
5543
+ enumerable: true,
5544
+ configurable: true
5545
+ });
5546
+ };
5547
+
5540
5548
  if (!Promise) {
5541
5549
  throw new Error('unsupported Promise');
5542
- } // https://github.com/github/fetch
5550
+ }
5551
+
5552
+ AbortController.prototype.abort = function () {
5553
+ if (this.__signalWrap && this.__signalWrap.__xhr) {
5554
+ try {
5555
+ this.__signalWrap.__xhr.abort();
5556
+ } catch (e) {
5557
+ console.log(e);
5558
+ }
5559
+
5560
+ this.__signalWrap.__xhr = null;
5561
+ }
5562
+ };
5543
5563
 
5564
+ Window$2._AbortController = AbortController;
5565
+ net$1.AbortController = AbortController; // https://github.com/github/fetch
5544
5566
 
5545
5567
  febsnet.normalizeName = function (name) {
5546
5568
  if (typeof name !== 'string') {
@@ -5922,7 +5944,7 @@ var net$1 = {}; //--------------------------------------------------------
5922
5944
  var status = xhr.status === 1223 ? 204 : xhr.status;
5923
5945
 
5924
5946
  if (status < 100 || status > 599) {
5925
- reject(new exception('Network request failed', 'NetworkFailed', __filename, __line, __column));
5947
+ reject(new exception('Network request failed', 'NetworkFailed', null, null, null));
5926
5948
  return;
5927
5949
  }
5928
5950
 
@@ -5938,21 +5960,25 @@ var net$1 = {}; //--------------------------------------------------------
5938
5960
  };
5939
5961
 
5940
5962
  xhr.ontimeout = function () {
5941
- reject(new exception('Network timeout', 'NetworkTimeout', __filename, __line, __column));
5963
+ reject(new exception('Network timeout', 'NetworkTimeout', null, null, null));
5942
5964
  };
5943
5965
 
5944
5966
  xhr.onerror = function () {
5945
- reject(new exception('Network request failed', 'NetworkFailed', __filename, __line, __column));
5967
+ reject(new exception('Network request failed', 'NetworkFailed', null, null, null));
5946
5968
  };
5947
5969
 
5948
- if (init.progress) {
5970
+ if (init && init.progress) {
5949
5971
  xhr.onprogress = function (event) {
5950
5972
  if (event.lengthComputable) {
5951
- init.progress(event.position / event.totalSize);
5973
+ init.progress((event.position || event.loaded || 0) / (event.totalSize || event.total || 1));
5952
5974
  }
5953
5975
  };
5954
5976
  }
5955
5977
 
5978
+ if (init && init.signal) {
5979
+ init.signal.__xhr = xhr;
5980
+ }
5981
+
5956
5982
  xhr.open(request.method, request.url, true);
5957
5983
  var timeout = init ? init.timeout : null;
5958
5984
  xhr.timeout = timeout !== undefined && timeout !== null ? timeout : net_transfer.DefaultTimeout;
@@ -5975,7 +6001,11 @@ var net$1 = {}; //--------------------------------------------------------
5975
6001
  console.log('fetch can\'t set headers');
5976
6002
  }
5977
6003
 
5978
- xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
6004
+ try {
6005
+ xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
6006
+ } catch (e) {
6007
+ reject(new exception('Network request failed', 'NetworkFailed', null, null, null));
6008
+ }
5979
6009
  });
5980
6010
  };
5981
6011
 
@@ -6057,6 +6087,7 @@ var net_jsonp = net$2;
6057
6087
 
6058
6088
  var net$3 = {
6059
6089
  ajax: net_ajax.ajax,
6090
+ AbortController: net_fetch.AbortController,
6060
6091
  fetch: net_fetch.fetch,
6061
6092
  jsonp: net_jsonp.jsonp
6062
6093
  };
@@ -7964,8 +7995,6 @@ var dom = {
7964
7995
  CreateDom: CreateDom_1
7965
7996
  };
7966
7997
 
7967
- getCjsExportFromNamespace(promiseFinallyPolyfill);
7968
-
7969
7998
  var Window$5 = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : undefined;
7970
7999
 
7971
8000
  if (!Window$5.__line) {
@@ -12117,18 +12146,16 @@ var utils_bigint_12 = utils_bigint.bigint_less_than_e;
12117
12146
  var utils_bigint_13 = utils_bigint.bigint_mod;
12118
12147
  var utils_bigint_14 = utils_bigint.bigint_toFixed;
12119
12148
 
12120
- var febs$1 = getCjsExportFromNamespace(index_base);
12121
-
12122
12149
  var BigNumber = utils_bigint.BigNumber;
12123
- var __debug$1 = febs$1.__debug;
12124
- var date$2 = febs$1.date;
12125
- var utils$2 = febs$1.utils.mergeMap(febs$1.utils, utils_bigint);
12126
- var string$2 = febs$1.string;
12127
- var crypt$2 = febs$1.crypt;
12128
- var net$5 = febs$1.net;
12129
- var $$1 = febs$1['$'];
12130
- var dom$2 = febs$1.dom;
12131
- var exception$2 = febs$1.exception;
12150
+ var __debug$1 = index_base.__debug;
12151
+ var date$2 = index_base.date;
12152
+ var utils$2 = index_base.utils.mergeMap(index_base.utils, utils_bigint);
12153
+ var string$2 = index_base.string;
12154
+ var crypt$2 = index_base.crypt;
12155
+ var net$5 = index_base.net;
12156
+ var $$1 = index_base['$'];
12157
+ var dom$2 = index_base.dom;
12158
+ var exception$2 = index_base.exception;
12132
12159
 
12133
12160
  exports.$ = $$1;
12134
12161
  exports.BigNumber = BigNumber;