febs-browser 1.2.13 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/libs/net.ajax.js CHANGED
@@ -28,34 +28,36 @@ var net = {};
28
28
  */
29
29
  function ajax( ctx )
30
30
  {
31
- //if (!!Window.ActiveXObject || "ActiveXObject" in Window) // ie11.
31
+ // 不修改调用方传入的 ctx.url, 只在本次请求的 url 上追加标记.
32
+ var url = ctx.url;
33
+ if (url)
32
34
  {
33
- if (ctx.url)
34
- {
35
- if (!Window[Ajaxmark]) Window[Ajaxmark] = 1;
36
- var i = ctx.url.indexOf('?');
37
- if (i < 0) {
38
- ctx.url += "?ajaxmark="+Window[Ajaxmark];
35
+ if (!Window[Ajaxmark]) Window[Ajaxmark] = 1;
36
+ var i = url.indexOf('?');
37
+ if (i < 0) {
38
+ url += "?ajaxmark="+Window[Ajaxmark];
39
+ } else {
40
+ if (i == url.length-1) {
41
+ url += "ajaxmark="+Window[Ajaxmark];
39
42
  } else {
40
- if (i == ctx.url.length-1) {
41
- ctx.url += "ajaxmark="+Window[Ajaxmark];
42
- } else {
43
- ctx.url += "&ajaxmark="+Window[Ajaxmark];
44
- }
43
+ url += "&ajaxmark="+Window[Ajaxmark];
45
44
  }
46
45
  }
47
- Window[Ajaxmark]++;
48
- } // if.
46
+ }
47
+ Window[Ajaxmark]++;
49
48
 
50
49
  var cbError = ctx.error || function(){}
51
50
  var cbSuccess = ctx.success || function(){}
52
51
  var cbComplete = ctx.complete || function(){}
53
52
 
54
- ctx.processData = ctx.hasOwnProperty('processData') ? ctx.processData : true;
53
+ var processData = ctx.hasOwnProperty('processData') ? ctx.processData : true;
55
54
 
56
55
  //
57
56
  // net transfer.
58
57
  var xhr = transfer.transfer(Window);
58
+ if (!xhr) {
59
+ throw new Error('XMLHttpRequest is not supported in current environment');
60
+ }
59
61
 
60
62
  // xhr.onload = function() {
61
63
  // var status = (xhr.status === 1223) ? 204 : xhr.status
@@ -83,7 +85,7 @@ function ajax( ctx )
83
85
  }
84
86
 
85
87
  var body = 'response' in xhr ? xhr.response : xhr.responseText;
86
- if (status == 200)
88
+ if ((status >= 200 && status < 300) || status == 304)
87
89
  cbSuccess(body, xhr.statusText, xhr);
88
90
 
89
91
  cbComplete(xhr, xhr.statusText);
@@ -111,16 +113,13 @@ function ajax( ctx )
111
113
  }
112
114
  }
113
115
 
114
- xhr.open(ctx.type, ctx.url, ctx.async===false?false:true);
116
+ xhr.open(ctx.type, url, ctx.async===false?false:true);
115
117
  var timeout = (ctx.async===false?false:true)? ctx.timeout: 0;
116
118
  xhr.timeout = (timeout !== undefined && timeout !== null) ? timeout : transfer.DefaultTimeout;
117
119
 
118
120
  if (ctx.hasOwnProperty('withCredentials')) {
119
121
  xhr.withCredentials = ctx.withCredentials;
120
122
  }
121
- else {
122
- xhr.withCredentials = true;
123
- }
124
123
 
125
124
  if (ctx.headers) {
126
125
  if (xhr.setRequestHeader) {
@@ -138,14 +137,14 @@ function ajax( ctx )
138
137
  }
139
138
  }
140
139
 
141
- if (!ctx.headers || !ctx.headers.hasOwnProperty('Content-Type')) {
140
+ if ((!ctx.headers || !ctx.headers.hasOwnProperty('Content-Type')) && xhr.setRequestHeader) {
142
141
  xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
143
142
  }
144
143
 
145
144
  // auto content-type.
146
145
  var data_content = ctx.data;
147
146
  if (data_content) {
148
- if (ctx.processData && typeof data_content !== 'string') {
147
+ if (processData && typeof data_content !== 'string') {
149
148
  try {
150
149
 
151
150
  if (ctx.headers && ctx.headers['Content-Type'] && ctx.headers['Content-Type'].toLowerCase().indexOf('json') >= 0) {
@@ -6,20 +6,14 @@
6
6
 
7
7
  exports.DefaultTimeout = 5000;
8
8
 
9
+ /**
10
+ * @desc: 创建 XMLHttpRequest 实例.
11
+ * 不再支持 IE8/9 的 ActiveXObject.
12
+ */
9
13
  exports.transfer = function(window) {
10
- var xhr;
11
- if (window.XMLHttpRequest) xhr = new XMLHttpRequest();
12
- else if (window.XDomainRequest) xhr = new XDomainRequest();
13
- else {
14
- var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
15
- for (var i = 0; i < XmlHttpVersions.length && !xmlHttp; i++) {
16
- try {
17
- xhr = new ActiveXObject(XmlHttpVersions[i]);
18
- }
19
- catch (e) {
20
- }
21
- }
14
+ if (window && window.XMLHttpRequest) {
15
+ return new window.XMLHttpRequest();
22
16
  }
23
-
24
- return xhr;
25
- }
17
+
18
+ return null;
19
+ }
package/package.json CHANGED
@@ -1,44 +1,8 @@
1
1
  {
2
2
  "description": "febs is a useful utilities set in browser",
3
3
  "devDependencies": {
4
- "@babel/cli": "^7.8.4",
5
- "@babel/core": "^7.9.0",
6
- "@babel/polyfill": "^7.8.7",
7
- "@babel/preset-env": "^7.9.5",
8
- "@rollup/plugin-commonjs": "^11.0.2",
9
- "@rollup/plugin-node-resolve": "^7.1.1",
10
- "babel-core": "^6.26.0",
11
- "babel-eslint": "^10.0.1",
12
- "babel-loader": "^6.4.1",
13
- "babel-plugin-component": "^1.1.1",
14
- "babel-plugin-istanbul": "^4.1.6",
15
- "babel-plugin-module-resolver": "^4.0.0",
16
- "babel-plugin-transform-es2015-modules-simple-commonjs": "^0.3.0",
17
- "babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
18
- "babel-plugin-transform-es3-property-literals": "^6.22.0",
19
- "babel-plugin-transform-runtime": "^6.23.0",
20
- "babel-polyfill": "^6.26.0",
21
- "babel-preset-env": "^1.6.1",
22
- "babel-preset-es2015": "^6.24.1",
23
- "babel-preset-es2015-loose": "^8.0.0",
24
- "babel-preset-stage-0": "^6.24.1",
25
- "babel-preset-stage-1": "^6.24.1",
26
- "babel-preset-stage-2": "^6.24.1",
27
- "babel-runtime": "^6.26.0",
28
- "core-js": "^3.6.5",
29
- "es3ify-loader": "^0.2.0",
30
- "es3ify-webpack-plugin": "0.0.1",
31
- "es5-shim": "^4.5.10",
32
- "es6-promise": "^4.2.4",
33
- "ora": "^2.1.0",
34
- "rollup": "^1.31.1",
35
- "rollup-plugin-analyzer": "^3.3.0",
36
- "rollup-plugin-babel": "^4.4.0",
37
- "rollup-plugin-babel-minify": "^9.1.1",
38
- "tap": "^14.10.6",
39
- "uglify-js": "^3.2.1",
40
- "webpack": "^2.6.1",
41
- "webpack-bundle-analyzer": ">=3.3.2"
4
+ "tsup": "^8.5.0",
5
+ "typescript": "^5.9.0"
42
6
  },
43
7
  "directories": {},
44
8
  "homepage": "https://github.com/brainpoint/febs#readme",
@@ -71,10 +35,7 @@
71
35
  "wxmini-package",
72
36
  "index.base.js",
73
37
  "index.js",
74
- "index.noBignumber.js",
75
- "index.ie8.base.js",
76
- "index.ie8.js",
77
- "index.ie8.noBignumber.js"
38
+ "index.noBignumber.js"
78
39
  ],
79
40
  "license": "MIT",
80
41
  "main": "./dist/index.common.min.js",
@@ -84,12 +45,13 @@
84
45
  "maintainers": [
85
46
  {
86
47
  "name": "brainpoint",
87
- "email": "bpoint.lee@gmail.com"
48
+ "email": "bpoint.lee@live.com"
88
49
  }
89
50
  ],
90
51
  "scripts": {
91
- "build": "node --max-old-space-size=4096 scripts/webpack.build.js && cp -rf dist/wxmini/index.js wxmini-package/ && node --max-old-space-size=4096 scripts/bundle.js"
52
+ "build": "tsup",
53
+ "build:watch": "tsup --watch"
92
54
  },
93
55
  "name": "febs-browser",
94
- "version": "1.2.13"
56
+ "version": "1.3.2"
95
57
  }
package/types/fetch.d.ts CHANGED
@@ -103,6 +103,7 @@ export type Fetch = (
103
103
 
104
104
  export interface AbortControllerClass {
105
105
  new(): AbortControllerClass;
106
- get signal(): any;
106
+ readonly signal: any;
107
107
  abort(): void;
108
108
  }
109
+